Diffstat (limited to 'core/pim/osearch/mainwindow.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/pim/osearch/mainwindow.cpp | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/core/pim/osearch/mainwindow.cpp b/core/pim/osearch/mainwindow.cpp index e15cc7e..33a24bc 100644 --- a/core/pim/osearch/mainwindow.cpp +++ b/core/pim/osearch/mainwindow.cpp | |||
@@ -84,14 +84,16 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : | |||
84 | searches.append( new DocLnkSearch( resultsList, tr("documents") ) ); | 84 | searches.append( new DocLnkSearch( resultsList, tr("documents") ) ); |
85 | 85 | ||
86 | makeMenu(); | 86 | makeMenu(); |
87 | setCentralWidget( mainFrame ); | 87 | setCentralWidget( mainFrame ); |
88 | 88 | ||
89 | popupTimer = new QTimer(); | 89 | popupTimer = new QTimer(); |
90 | searchTimer = new QTimer(); | ||
90 | 91 | ||
91 | connect(popupTimer, SIGNAL(timeout()), SLOT(showPopup())); | 92 | connect(popupTimer, SIGNAL(timeout()), SLOT(showPopup())); |
93 | connect(searchTimer, SIGNAL(timeout()), SLOT(searchStringChanged())); | ||
92 | connect(resultsList, SIGNAL(pressed(QListViewItem*)), SLOT(setCurrent(QListViewItem*))); | 94 | connect(resultsList, SIGNAL(pressed(QListViewItem*)), SLOT(setCurrent(QListViewItem*))); |
93 | connect(resultsList, SIGNAL(clicked(QListViewItem*)), SLOT(stopTimer(QListViewItem*))); | 95 | connect(resultsList, SIGNAL(clicked(QListViewItem*)), SLOT(stopTimer(QListViewItem*))); |
94 | connect(buttonGroupActions, SIGNAL(clicked(int)), SLOT( slotAction(int) ) ); | 96 | connect(buttonGroupActions, SIGNAL(clicked(int)), SLOT( slotAction(int) ) ); |
95 | 97 | ||
96 | } | 98 | } |
97 | 99 | ||
@@ -108,24 +110,26 @@ void MainWindow::makeMenu() | |||
108 | toolBar->setHorizontalStretchable( true ); | 110 | toolBar->setHorizontalStretchable( true ); |
109 | menuBar->insertItem( tr( "Search" ), searchMenu ); | 111 | menuBar->insertItem( tr( "Search" ), searchMenu ); |
110 | // menuBar->insertItem( tr( "View" ), viewMenu ); | 112 | // menuBar->insertItem( tr( "View" ), viewMenu ); |
111 | // menuBar->insertItem( tr( "Settings" ), cfgMenu ); | 113 | // menuBar->insertItem( tr( "Settings" ), cfgMenu ); |
112 | 114 | ||
113 | //SEARCH | 115 | //SEARCH |
114 | QAction *action = new QAction( tr("Search all"),QString::null, 0, this, 0 ); | 116 | SearchAllAction = new QAction( tr("Search all"),QString::null, 0, this, 0 ); |
115 | connect( action, SIGNAL(activated()), this, SLOT(searchAll()) ); | 117 | SearchAllAction->setIconSet( Resource::loadIconSet( "find" ) ); |
116 | action->addTo( searchMenu ); | 118 | connect( SearchAllAction, SIGNAL(activated()), this, SLOT(searchAll()) ); |
119 | SearchAllAction->addTo( searchMenu ); | ||
117 | actionCaseSensitiv = new QAction( tr("Case sensitiv"),QString::null, 0, this, 0, true ); | 120 | actionCaseSensitiv = new QAction( tr("Case sensitiv"),QString::null, 0, this, 0, true ); |
118 | actionCaseSensitiv->addTo( searchMenu ); | 121 | actionCaseSensitiv->addTo( searchMenu ); |
119 | actionWildcards = new QAction( tr("Use wildcards"),QString::null, 0, this, 0, true ); | 122 | actionWildcards = new QAction( tr("Use wildcards"),QString::null, 0, this, 0, true ); |
120 | actionWildcards->addTo( searchMenu ); | 123 | actionWildcards->addTo( searchMenu ); |
121 | 124 | ||
122 | addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); | 125 | addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); |
123 | QLineEdit *searchEdit = new QLineEdit( searchBar, "seachEdit" ); | 126 | QLineEdit *searchEdit = new QLineEdit( searchBar, "seachEdit" ); |
124 | searchBar->setHorizontalStretchable( TRUE ); | 127 | searchBar->setHorizontalStretchable( TRUE ); |
125 | searchBar->setStretchableWidget( searchEdit ); | 128 | searchBar->setStretchableWidget( searchEdit ); |
129 | SearchAllAction->addTo( searchBar ); | ||
126 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), | 130 | connect( searchEdit, SIGNAL( textChanged( const QString & ) ), |
127 | this, SLOT( setSearch( const QString & ) ) ); | 131 | this, SLOT( setSearch( const QString & ) ) ); |
128 | 132 | ||
129 | } | 133 | } |
130 | 134 | ||
131 | MainWindow::~MainWindow() | 135 | MainWindow::~MainWindow() |
@@ -181,22 +185,30 @@ void MainWindow::showPopup() | |||
181 | qDebug("showPopup"); | 185 | qDebug("showPopup"); |
182 | if (!_currentItem) return; | 186 | if (!_currentItem) return; |
183 | } | 187 | } |
184 | 188 | ||
185 | void MainWindow::setSearch( const QString &key ) | 189 | void MainWindow::setSearch( const QString &key ) |
186 | { | 190 | { |
187 | QRegExp re( key, actionCaseSensitiv->isOn(), actionWildcards->isOn() ); | 191 | searchTimer->stop(); |
192 | _searchString = key; | ||
193 | searchTimer->start( 300 ); | ||
194 | } | ||
195 | |||
196 | void MainWindow::searchStringChanged() | ||
197 | { | ||
198 | searchTimer->stop(); | ||
199 | QRegExp re( _searchString, actionCaseSensitiv->isOn(), actionWildcards->isOn() ); | ||
188 | for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ) | 200 | for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ) |
189 | s->setSearch( re ); | 201 | s->setSearch( re ); |
190 | } | 202 | } |
191 | 203 | ||
192 | void MainWindow::searchAll() | 204 | void MainWindow::searchAll() |
193 | { | 205 | { |
194 | bool openState; | ||
195 | for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ){ | 206 | for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ){ |
196 | s->doSearch(); | 207 | s->doSearch(); |
208 | //resultsList->repaint(); | ||
197 | } | 209 | } |
198 | } | 210 | } |
199 | 211 | ||
200 | void MainWindow::slotAction( int act) | 212 | void MainWindow::slotAction( int act) |
201 | { | 213 | { |
202 | if (_currentItem->rtti() == OListViewItem::Result){ | 214 | if (_currentItem->rtti() == OListViewItem::Result){ |