if ( mySearcher )
delete mySearcher;
mySearcher = s;
+ connect( mySearcher, SIGNAL( resultChanged( bool ) ),
+ this, SLOT( searchResultChanged( bool ) ) );
}
/*!
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() )
{
}
}
- if ( !found )
- p.setColor( QPalette::Active, QPalette::Base, QColor( highlightColor ) );
-
if ( !focused() && myAutoHideEnabled )
myAutoHideTimer->start();
- myData->setPalette( p );
+ updateContent( found );
}
/*!
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
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.
private slots:
void find( const QString&, int = fAny );
void modifierSwitched();
+ void searchResultChanged( bool );
private:
void init();
void initShortcuts( const QList<QKeySequence>& );
void updateShortcuts();
void updateControls();
+ void updateContent( const bool& );
private:
typedef QPointer<QShortcut> ShortcutPtr;
QMap<int, QWidget*> myWidgets;
};
-class QTX_EXPORT QtxSearchTool::Searcher
+class QTX_EXPORT QtxSearchTool::Searcher : public QObject
{
+ Q_OBJECT
+
public:
Searcher();
virtual ~Searcher();
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