From: nds Date: Mon, 13 Apr 2009 11:26:52 +0000 (+0000) Subject: It expands content of the search tool. It appends: X-Git-Tag: V2_1_0_beta~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1b8b513771dffe27df8046eb2985667b34fc2506;p=modules%2Fgui.git It expands content of the search tool. It appends: 1. method updateContents(bool) to color content of the search control 2. handling of resultChanged() signal for searcher, to update color content of the search control. This is necessary to move searching in external thread in ACHERON. --- diff --git a/src/Qtx/QtxSearchTool.cxx b/src/Qtx/QtxSearchTool.cxx index 88e2bae13..a5770a8ae 100644 --- a/src/Qtx/QtxSearchTool.cxx +++ b/src/Qtx/QtxSearchTool.cxx @@ -380,6 +380,8 @@ void QtxSearchTool::setSearcher( QtxSearchTool::Searcher* s ) if ( mySearcher ) delete mySearcher; mySearcher = s; + connect( mySearcher, SIGNAL( resultChanged( bool ) ), + this, SLOT( searchResultChanged( bool ) ) ); } /*! @@ -824,12 +826,6 @@ void QtxSearchTool::find( const QString& what, int where ) if ( !isVisible() ) show(); - QPalette p = myData->palette(); - p.setColor( QPalette::Active, - QPalette::Base, - QApplication::palette( myData ).color( QPalette::Active, - QPalette::Base ) ); - bool found = true; if ( mySearcher && !what.isEmpty() ) { @@ -849,13 +845,10 @@ void QtxSearchTool::find( const QString& what, int where ) } } - if ( !found ) - p.setColor( QPalette::Active, QPalette::Base, QColor( highlightColor ) ); - if ( !focused() && myAutoHideEnabled ) myAutoHideTimer->start(); - myData->setPalette( p ); + updateContent( found ); } /*! @@ -867,6 +860,15 @@ void QtxSearchTool::modifierSwitched() find( myData->text() ); } +/*! + \brief Called when the search result's changed. It updates validity of the current content + \internal +*/ +void QtxSearchTool::searchResultChanged( bool theResult ) +{ + updateContent( theResult ); +} + /*! \brief Initialize the search tool widget. \internal @@ -1063,6 +1065,20 @@ void QtxSearchTool::updateControls() myModWidget->setVisible( myControls & Modifiers ); } +/*! + \brief Colors the data content in valid/invalid value. + \param validState flag tells about validity of the current content + \internal +*/ +void QtxSearchTool::updateContent( const bool& validState ) +{ + QPalette p = myData->palette(); + p.setColor( QPalette::Active, QPalette::Base, validState + ? QApplication::palette( myData ).color( QPalette::Active, QPalette::Base ) + : QColor( highlightColor ) ); + myData->setPalette( p ); +} + /*! \class QtxSearchTool::Searcher \brief Generic searcher class. diff --git a/src/Qtx/QtxSearchTool.h b/src/Qtx/QtxSearchTool.h index f91d00ff0..ec65e9b08 100644 --- a/src/Qtx/QtxSearchTool.h +++ b/src/Qtx/QtxSearchTool.h @@ -127,6 +127,7 @@ public slots: private slots: void find( const QString&, int = fAny ); void modifierSwitched(); + void searchResultChanged( bool ); private: void init(); @@ -135,6 +136,7 @@ private: void initShortcuts( const QList& ); void updateShortcuts(); void updateControls(); + void updateContent( const bool& ); private: typedef QPointer ShortcutPtr; @@ -162,8 +164,10 @@ private: QMap myWidgets; }; -class QTX_EXPORT QtxSearchTool::Searcher +class QTX_EXPORT QtxSearchTool::Searcher : public QObject { + Q_OBJECT + public: Searcher(); virtual ~Searcher(); @@ -173,6 +177,9 @@ public: virtual bool findPrevious( const QString&, QtxSearchTool* ) = 0; virtual bool findFirst( const QString&, QtxSearchTool* ) = 0; virtual bool findLast( const QString&, QtxSearchTool* ) = 0; + +signals: + void resultChanged( bool ); }; class QTX_EXPORT QtxTreeViewSearcher : public QtxSearchTool::Searcher