SVN commit 1192769 by mutz: KeyTreeView: add convenience methods (dis)connectSearchBar() M +26 -0 keytreeview.cpp M +3 -0 keytreeview.h --- trunk/KDE/kdepim/kleopatra/view/keytreeview.cpp #1192768:1192769 @@ -351,4 +351,30 @@ } +static const struct { + const char * signal; + const char * slot; +} connections[] = { + { SIGNAL(stringFilterChanged(QString)), + SLOT(setStringFilter(QString)) }, + { SIGNAL(keyFilterChanged(boost::shared_ptr)), + SLOT(setKeyFilter(boost::shared_ptr)) }, +}; +static const unsigned int numConnections = sizeof connections / sizeof *connections ; + +void KeyTreeView::disconnectSearchBar( const QObject * bar ) { + for ( unsigned int i = 0 ; i < numConnections ; ++i ) { + disconnect( this, connections[i].signal, bar, connections[i].slot ); + disconnect( bar, connections[i].signal, this, connections[i].slot ); + } +} + +bool KeyTreeView::connectSearchBar( const QObject * bar ) { + for ( unsigned int i = 0 ; i < numConnections ; ++i ) + if ( !connect( this, connections[i].signal, bar, connections[i].slot ) || + !connect( bar, connections[i].signal, this, connections[i].slot ) ) + return false; + return true; +} + #include "moc_keytreeview.cpp" --- trunk/KDE/kdepim/kleopatra/view/keytreeview.h #1192768:1192769 @@ -97,6 +97,9 @@ virtual KeyTreeView * clone() const { return new KeyTreeView( *this ); } + void disconnectSearchBar( const QObject * bar ); + bool connectSearchBar( const QObject * bar ); + public Q_SLOTS: virtual void setStringFilter( const QString & text ); virtual void setKeyFilter( const boost::shared_ptr & filter );