From 9c50187980a9e3b2891add82199060e3312ffad7 Mon Sep 17 00:00:00 2001 From: Jakob Leben Date: Tue, 9 Aug 2011 08:17:18 +0200 Subject: [PATCH] qt gui: add QPopUpMenu-allowsReselection(_) Duplicate the behavior of JSCPopUpMenu-allowsReselection(_). --- QtCollider/widgets/BasicWidgets.cpp | 4 ++-- QtCollider/widgets/BasicWidgets.h | 4 ++++ SCClassLibrary/QtCollider/BasicViews.sc | 4 ++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/QtCollider/widgets/BasicWidgets.cpp b/QtCollider/widgets/BasicWidgets.cpp index dedaa3680..3f578d75a 100644 --- a/QtCollider/widgets/BasicWidgets.cpp +++ b/QtCollider/widgets/BasicWidgets.cpp @@ -113,7 +113,7 @@ bool QcListWidget::eventFilter( QObject *o, QEvent *e ) QcWidgetFactory popUpMenuFactory; QcPopUpMenu::QcPopUpMenu() -: lastChoice( -1 ) +: lastChoice( -1 ), _reactivation(false) { connect( this, SIGNAL(activated(int)), this, SLOT(doAction(int)) ); } @@ -127,7 +127,7 @@ void QcPopUpMenu::setItems( const VariantList & items ) void QcPopUpMenu::doAction( int choice ) { - if( choice != lastChoice ) { + if( _reactivation || (choice != lastChoice) ) { lastChoice = choice; Q_EMIT( action() ); } diff --git a/QtCollider/widgets/BasicWidgets.h b/QtCollider/widgets/BasicWidgets.h index e17f5a7d5..4aa9a39da 100644 --- a/QtCollider/widgets/BasicWidgets.h +++ b/QtCollider/widgets/BasicWidgets.h @@ -87,9 +87,12 @@ class QcPopUpMenu : public QComboBox, public QcHelper { Q_OBJECT Q_PROPERTY( VariantList items READ dummyVariantList WRITE setItems ); + Q_PROPERTY( bool signalReactivation READ signalReactivation WRITE setSignalReactivation ) public: QcPopUpMenu(); + bool signalReactivation() const { return _reactivation; } + void setSignalReactivation( bool b ) { _reactivation = b; } Q_SIGNALS: void action(); private Q_SLOTS: @@ -97,6 +100,7 @@ class QcPopUpMenu : public QComboBox, public QcHelper private: void setItems( const VariantList & ); int lastChoice; + bool _reactivation; }; class QcTextField : public QLineEdit diff --git a/SCClassLibrary/QtCollider/BasicViews.sc b/SCClassLibrary/QtCollider/BasicViews.sc index 08865df8d..5a173f7ee 100644 --- a/SCClassLibrary/QtCollider/BasicViews.sc +++ b/SCClassLibrary/QtCollider/BasicViews.sc @@ -347,6 +347,10 @@ QPopUpMenu : QItemViewBase { *qtClass { ^"QcPopUpMenu" } + allowsReselection { ^this.getProperty( \signalReactivation ) } + + allowsReselection_ { arg flag; ^this.setProperty( \signalReactivation, flag ) } + value { var v = this.getProperty( \currentIndex ); if( v < 0 ) { ^nil } { ^v }; -- 2.11.4.GIT