author | tille <tille> | 2003-05-16 15:18:21 (UTC) |
---|---|---|
committer | tille <tille> | 2003-05-16 15:18:21 (UTC) |
commit | 75f1e9815410e75a6f9ae76d8db716c0c315ea45 (patch) (unidiff) | |
tree | f21eea4fb09db52644dc0141f8d368997ec322f0 | |
parent | 708f1846703c3f13f7c9ac67130b6930f9607523 (diff) | |
download | opie-75f1e9815410e75a6f9ae76d8db716c0c315ea45.zip opie-75f1e9815410e75a6f9ae76d8db716c0c315ea45.tar.gz opie-75f1e9815410e75a6f9ae76d8db716c0c315ea45.tar.bz2 |
search in text documents
-rw-r--r-- | core/pim/osearch/applnksearch.cpp | 4 | ||||
-rw-r--r-- | core/pim/osearch/applnksearch.h | 6 | ||||
-rw-r--r-- | core/pim/osearch/doclnksearch.cpp | 56 | ||||
-rw-r--r-- | core/pim/osearch/doclnksearch.h | 13 | ||||
-rw-r--r-- | core/pim/osearch/mainwindow.cpp | 10 | ||||
-rw-r--r-- | core/pim/osearch/searchgroup.cpp | 15 | ||||
-rw-r--r-- | core/pim/osearch/searchgroup.h | 3 |
7 files changed, 87 insertions, 20 deletions
diff --git a/core/pim/osearch/applnksearch.cpp b/core/pim/osearch/applnksearch.cpp index 5fa36bb..403c719 100644 --- a/core/pim/osearch/applnksearch.cpp +++ b/core/pim/osearch/applnksearch.cpp | |||
@@ -26,42 +26,44 @@ AppLnkSearch::AppLnkSearch(QListView* parent, QString name): SearchGroup(parent, | |||
26 | //QIconSet is = Resource::loadIconSet( "AppsIcon" ); | 26 | //QIconSet is = Resource::loadIconSet( "AppsIcon" ); |
27 | setPixmap( 0, is.pixmap( QIconSet::Small, true ) ); | 27 | setPixmap( 0, is.pixmap( QIconSet::Small, true ) ); |
28 | } | 28 | } |
29 | 29 | ||
30 | 30 | ||
31 | AppLnkSearch::~AppLnkSearch() | 31 | AppLnkSearch::~AppLnkSearch() |
32 | { | 32 | { |
33 | delete _apps; | 33 | delete _apps; |
34 | } | 34 | } |
35 | 35 | ||
36 | 36 | ||
37 | void AppLnkSearch::load() | 37 | void AppLnkSearch::load() |
38 | { | 38 | { |
39 | _apps = new AppLnkSet(QPEApplication::qpeDir()); | 39 | _apps = new AppLnkSet(QPEApplication::qpeDir()); |
40 | } | 40 | } |
41 | 41 | ||
42 | int AppLnkSearch::search() | 42 | int AppLnkSearch::search() |
43 | { | 43 | { |
44 | QList<AppLnk> appList = _apps->children(); | 44 | QList<AppLnk> appList = _apps->children(); |
45 | for ( AppLnk *app = appList.first(); app != 0; app = appList.next() ){ | 45 | for ( AppLnk *app = appList.first(); app != 0; app = appList.next() ){ |
46 | if ( (_search.match( app->name() ) != -1) | 46 | if ( (_search.match( app->name() ) != -1) |
47 | || (_search.match(app->comment()) != -1) | 47 | || (_search.match(app->comment()) != -1) |
48 | || (_search.match(app->exec()) != -1) ) { | 48 | || (_search.match(app->exec()) != -1) ) { |
49 | insertItem( app ); | 49 | insertItem( app ); |
50 | } | 50 | }else |
51 | if (searchFile( app )) | ||
52 | insertItem( app ); | ||
51 | qApp->processEvents( 100 ); | 53 | qApp->processEvents( 100 ); |
52 | } | 54 | } |
53 | return _resultCount; | 55 | return _resultCount; |
54 | } | 56 | } |
55 | 57 | ||
56 | void AppLnkSearch::insertItem( void *rec ) | 58 | void AppLnkSearch::insertItem( void *rec ) |
57 | { | 59 | { |
58 | new AppLnkItem( this, (AppLnk*)rec ); | 60 | new AppLnkItem( this, (AppLnk*)rec ); |
59 | _resultCount++; | 61 | _resultCount++; |
60 | } | 62 | } |
61 | 63 | ||
62 | void AppLnkSearch::setSearch(QRegExp re) | 64 | void AppLnkSearch::setSearch(QRegExp re) |
63 | { | 65 | { |
64 | setOpen( false ); | 66 | setOpen( false ); |
65 | SearchGroup::setSearch( re ); | 67 | SearchGroup::setSearch( re ); |
66 | } | 68 | } |
67 | 69 | ||
diff --git a/core/pim/osearch/applnksearch.h b/core/pim/osearch/applnksearch.h index 6bb7486..853064d 100644 --- a/core/pim/osearch/applnksearch.h +++ b/core/pim/osearch/applnksearch.h | |||
@@ -1,38 +1,40 @@ | |||
1 | // | 1 | // |
2 | // | 2 | // |
3 | // C++ Interface: $MODULE$ | 3 | // C++ Interface: $MODULE$ |
4 | // | 4 | // |
5 | // Description: | 5 | // Description: |
6 | // | 6 | // |
7 | // | 7 | // |
8 | // Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 | 8 | // Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 |
9 | // | 9 | // |
10 | // Copyright: See COPYING file that comes with this distribution | 10 | // Copyright: See COPYING file that comes with this distribution |
11 | // | 11 | // |
12 | // | 12 | // |
13 | #ifndef APPLNKSEARCH_H | 13 | #ifndef APPLNKSEARCH_H |
14 | #define APPLNKSEARCH_H | 14 | #define APPLNKSEARCH_H |
15 | 15 | ||
16 | #include "searchgroup.h" | 16 | #include "searchgroup.h" |
17 | 17 | ||
18 | class AppLnkSet; | 18 | class AppLnkSet; |
19 | class AppLnk; | ||
19 | 20 | ||
20 | /** | 21 | /** |
21 | @author Patrick S. Vogt | 22 | @author Patrick S. Vogt |
22 | */ | 23 | */ |
23 | class AppLnkSearch : public SearchGroup | 24 | class AppLnkSearch : public SearchGroup |
24 | { | 25 | { |
25 | public: | 26 | public: |
26 | AppLnkSearch(QListView* parent, QString name); | 27 | AppLnkSearch(QListView* parent, QString name); |
27 | |||
28 | ~AppLnkSearch(); | 28 | ~AppLnkSearch(); |
29 | 29 | ||
30 | virtual void setSearch(QRegExp); | 30 | virtual void setSearch(QRegExp); |
31 | |||
32 | protected: | ||
31 | virtual void load(); | 33 | virtual void load(); |
32 | virtual int search(); | 34 | virtual int search(); |
33 | virtual void insertItem( void* ); | 35 | virtual void insertItem( void* ); |
34 | 36 | virtual bool searchFile(AppLnk*) { return false; }; | |
35 | AppLnkSet *_apps; | 37 | AppLnkSet *_apps; |
36 | }; | 38 | }; |
37 | 39 | ||
38 | #endif | 40 | #endif |
diff --git a/core/pim/osearch/doclnksearch.cpp b/core/pim/osearch/doclnksearch.cpp index d97eeb8..321d011 100644 --- a/core/pim/osearch/doclnksearch.cpp +++ b/core/pim/osearch/doclnksearch.cpp | |||
@@ -1,43 +1,91 @@ | |||
1 | // | 1 | // |
2 | // | 2 | // |
3 | // C++ Implementation: $MODULE$ | 3 | // C++ Implementation: $MODULE$ |
4 | // | 4 | // |
5 | // Description: | 5 | // Description: |
6 | // | 6 | // |
7 | // | 7 | // |
8 | // Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 | 8 | // Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 |
9 | // | 9 | // |
10 | // Copyright: See COPYING file that comes with this distribution | 10 | // Copyright: See COPYING file that comes with this distribution |
11 | // | 11 | // |
12 | // | 12 | // |
13 | #include "doclnksearch.h" | ||
14 | 13 | ||
15 | #include <qpe/applnk.h> | 14 | #include <qaction.h> |
16 | #include <qpe/qpeapplication.h> | 15 | #include <qfile.h> |
17 | #include <qiconset.h> | 16 | #include <qiconset.h> |
17 | #include <qpopupmenu.h> | ||
18 | #include <qtextstream.h> | ||
19 | #include <qpe/applnk.h> | ||
20 | #include <qpe/config.h> | ||
18 | #include <qpe/resource.h> | 21 | #include <qpe/resource.h> |
22 | #include <qpe/qpeapplication.h> | ||
23 | #include <opie/owait.h> | ||
19 | 24 | ||
20 | #include "doclnkitem.h" | 25 | #include "doclnkitem.h" |
26 | #include "doclnksearch.h" | ||
21 | 27 | ||
22 | DocLnkSearch::DocLnkSearch(QListView* parent, QString name) | 28 | DocLnkSearch::DocLnkSearch(QListView* parent, QString name) |
23 | : AppLnkSearch(parent, name) | 29 | : AppLnkSearch(parent, name), _popupMenu(0) |
24 | { | 30 | { |
25 | QIconSet is = Resource::loadIconSet( "osearch/documents" ); | 31 | QIconSet is = Resource::loadIconSet( "osearch/documents" ); |
26 | setPixmap( 0, is.pixmap( QIconSet::Small, true ) ); | 32 | setPixmap( 0, is.pixmap( QIconSet::Small, true ) ); |
33 | |||
34 | actionSearchInFiles = new QAction( QObject::tr("search content"),QString::null, 0, 0, 0, true ); | ||
35 | Config cfg( "osearch", Config::User ); | ||
36 | cfg.setGroup( "doclnk_settings" ); | ||
37 | actionSearchInFiles->setOn( cfg.readBoolEntry( "search_content", false ) ); | ||
27 | } | 38 | } |
28 | 39 | ||
29 | 40 | ||
30 | DocLnkSearch::~DocLnkSearch() | 41 | DocLnkSearch::~DocLnkSearch() |
31 | { | 42 | { |
43 | Config cfg( "osearch", Config::User ); | ||
44 | cfg.setGroup( "doclnk_settings" ); | ||
45 | cfg.writeEntry( "search_content", actionSearchInFiles->isOn() ); | ||
32 | } | 46 | } |
33 | 47 | ||
34 | void DocLnkSearch::load() | 48 | void DocLnkSearch::load() |
35 | { | 49 | { |
36 | _apps = new DocLnkSet(QPEApplication::documentDir()); | 50 | _apps = new DocLnkSet(QPEApplication::documentDir()); |
37 | } | 51 | } |
38 | 52 | ||
53 | bool DocLnkSearch::searchFile( AppLnk *app ) | ||
54 | { | ||
55 | if (!actionSearchInFiles->isOn()) return false; | ||
56 | DocLnk *doc = (DocLnk*)app; | ||
57 | bool found = false; | ||
58 | if ( doc->type().contains( "text" ) ){ | ||
59 | #ifdef NEW_OWAIT | ||
60 | QString ouput = QObject::tr("searching %1").arg(doc->file()); | ||
61 | OWait( output ); | ||
62 | #endif | ||
63 | QFile f(doc->file()); | ||
64 | if ( f.open(IO_ReadOnly) ) { | ||
65 | QTextStream t( &f ); | ||
66 | while ( !t.eof() ) | ||
67 | if (_search.match( t.readLine()) != -1) { | ||
68 | found = true; | ||
69 | break; | ||
70 | } | ||
71 | } | ||
72 | f.close(); | ||
73 | } | ||
74 | return found; | ||
75 | } | ||
76 | |||
39 | void DocLnkSearch::insertItem( void *rec ) | 77 | void DocLnkSearch::insertItem( void *rec ) |
40 | { | 78 | { |
41 | new DocLnkItem( this, (DocLnk*)rec ); | 79 | new DocLnkItem( this, (DocLnk*)rec ); |
42 | _resultCount++; | 80 | _resultCount++; |
43 | } | 81 | } |
82 | |||
83 | |||
84 | QPopupMenu* DocLnkSearch::popupMenu() | ||
85 | { | ||
86 | if (!_popupMenu){ | ||
87 | _popupMenu = new QPopupMenu( 0 ); | ||
88 | actionSearchInFiles->addTo( _popupMenu ); | ||
89 | } | ||
90 | return _popupMenu; | ||
91 | } | ||
diff --git a/core/pim/osearch/doclnksearch.h b/core/pim/osearch/doclnksearch.h index e2ac40b..81a8e62 100644 --- a/core/pim/osearch/doclnksearch.h +++ b/core/pim/osearch/doclnksearch.h | |||
@@ -1,33 +1,42 @@ | |||
1 | // | 1 | // |
2 | // | 2 | // |
3 | // C++ Interface: $MODULE$ | 3 | // C++ Interface: $MODULE$ |
4 | // | 4 | // |
5 | // Description: | 5 | // Description: |
6 | // | 6 | // |
7 | // | 7 | // |
8 | // Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 | 8 | // Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 |
9 | // | 9 | // |
10 | // Copyright: See COPYING file that comes with this distribution | 10 | // Copyright: See COPYING file that comes with this distribution |
11 | // | 11 | // |
12 | // | 12 | // |
13 | #ifndef DOCLNKSEARCH_H | 13 | #ifndef DOCLNKSEARCH_H |
14 | #define DOCLNKSEARCH_H | 14 | #define DOCLNKSEARCH_H |
15 | 15 | ||
16 | #include "applnksearch.h" | 16 | #include "applnksearch.h" |
17 | 17 | ||
18 | class QAction; | ||
19 | class QPopupMenu; | ||
20 | |||
18 | /** | 21 | /** |
19 | @author Patrick S. Vogt | 22 | @author Patrick S. Vogt |
20 | */ | 23 | */ |
21 | class DocLnkSearch : public AppLnkSearch | 24 | class DocLnkSearch : public AppLnkSearch |
22 | { | 25 | { |
23 | public: | 26 | public: |
24 | DocLnkSearch(QListView* parent, QString name); | 27 | DocLnkSearch(QListView* parent, QString name); |
25 | ~DocLnkSearch(); | 28 | ~DocLnkSearch(); |
26 | 29 | ||
30 | virtual QPopupMenu* popupMenu(); | ||
31 | |||
27 | protected: | 32 | protected: |
28 | virtual void load(); | 33 | virtual void load(); |
34 | virtual bool searchFile(AppLnk*); | ||
29 | virtual void insertItem( void* ); | 35 | virtual void insertItem( void* ); |
36 | private: | ||
37 | QAction *actionSearchInFiles; | ||
38 | QPopupMenu *_popupMenu; | ||
30 | 39 | ||
31 | }; | 40 | }; |
32 | 41 | ||
33 | #endif | 42 | #endif |
diff --git a/core/pim/osearch/mainwindow.cpp b/core/pim/osearch/mainwindow.cpp index 89ab690..6070fdf 100644 --- a/core/pim/osearch/mainwindow.cpp +++ b/core/pim/osearch/mainwindow.cpp | |||
@@ -1,46 +1,47 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | * * | 2 | * * |
3 | * This program is free software; you can redistribute it and/or modify * | 3 | * This program is free software; you can redistribute it and/or modify * |
4 | * it under the terms of the GNU General Public License as published by * | 4 | * it under the terms of the GNU General Public License as published by * |
5 | * the Free Software Foundation; either version 2 of the License, or * | 5 | * the Free Software Foundation; either version 2 of the License, or * |
6 | * (at your option) any later version. * | 6 | * (at your option) any later version. * |
7 | * * | 7 | * * |
8 | ***************************************************************************/ | 8 | ***************************************************************************/ |
9 | 9 | ||
10 | // (c) 2002 Patrick S. Vogt <tille@handhelds.org> | 10 | // (c) 2002 Patrick S. Vogt <tille@handhelds.org> |
11 | 11 | ||
12 | 12 | ||
13 | #include "mainwindow.h" | 13 | #include "mainwindow.h" |
14 | 14 | ||
15 | #include <qpe/qpemenubar.h> | 15 | #include <qpe/qpemenubar.h> |
16 | #include <qpe/qpemessagebox.h> | 16 | #include <qpe/qpemessagebox.h> |
17 | #include <qpe/resource.h> | 17 | #include <qpe/resource.h> |
18 | #include <qpe/config.h> | 18 | #include <qpe/config.h> |
19 | #include <qpe/qpetoolbar.h> | 19 | #include <qpe/qpetoolbar.h> |
20 | #include <qpe/qpeapplication.h> | 20 | #include <qpe/qpeapplication.h> |
21 | #include <qpe/config.h> | 21 | #include <qpe/config.h> |
22 | #include <qpe/global.h> | 22 | #include <qpe/global.h> |
23 | #include <opie/owait.h> | ||
23 | #include <qaction.h> | 24 | #include <qaction.h> |
24 | #include <qmessagebox.h> | 25 | #include <qmessagebox.h> |
25 | #include <qpopupmenu.h> | 26 | #include <qpopupmenu.h> |
26 | #include <qtoolbutton.h> | 27 | #include <qtoolbutton.h> |
27 | #include <qstring.h> | 28 | #include <qstring.h> |
28 | #include <qlabel.h> | 29 | #include <qlabel.h> |
29 | #include <qfile.h> | 30 | #include <qfile.h> |
30 | #include <qhbuttongroup.h> | 31 | #include <qhbuttongroup.h> |
31 | #include <qpushbutton.h> | 32 | #include <qpushbutton.h> |
32 | #include <qintdict.h> | 33 | #include <qintdict.h> |
33 | #include <qlayout.h> | 34 | #include <qlayout.h> |
34 | #include <qlineedit.h> | 35 | #include <qlineedit.h> |
35 | #include <qtextbrowser.h> | 36 | #include <qtextbrowser.h> |
36 | #include <qregexp.h> | 37 | #include <qregexp.h> |
37 | 38 | ||
38 | #include "olistview.h" | 39 | #include "olistview.h" |
39 | #include "olistviewitem.h" | 40 | #include "olistviewitem.h" |
40 | #include "resultitem.h" | 41 | #include "resultitem.h" |
41 | #include "adresssearch.h" | 42 | #include "adresssearch.h" |
42 | #include "todosearch.h" | 43 | #include "todosearch.h" |
43 | #include "datebooksearch.h" | 44 | #include "datebooksearch.h" |
44 | #include "applnksearch.h" | 45 | #include "applnksearch.h" |
45 | #include "doclnksearch.h" | 46 | #include "doclnksearch.h" |
46 | 47 | ||
@@ -190,75 +191,80 @@ void MainWindow::setCurrent(QListViewItem *item) | |||
190 | buttonLayout->addWidget( button, 0 ); | 191 | buttonLayout->addWidget( button, 0 ); |
191 | buttonGroupActions->insert( button, i); | 192 | buttonGroupActions->insert( button, i); |
192 | } | 193 | } |
193 | button->setText( *acts[i] ); | 194 | button->setText( *acts[i] ); |
194 | button->show(); | 195 | button->show(); |
195 | } | 196 | } |
196 | for (uint i = acts.count(); i < _buttonCount; i++){ | 197 | for (uint i = acts.count(); i < _buttonCount; i++){ |
197 | qDebug("remove button %i of %i",i, _buttonCount); | 198 | qDebug("remove button %i of %i",i, _buttonCount); |
198 | button = buttonGroupActions->find( i ); | 199 | button = buttonGroupActions->find( i ); |
199 | if (button) button->hide(); | 200 | if (button) button->hide(); |
200 | } | 201 | } |
201 | _buttonCount = acts.count(); | 202 | _buttonCount = acts.count(); |
202 | detailsFrame->show(); | 203 | detailsFrame->show(); |
203 | }else detailsFrame->hide(); | 204 | }else detailsFrame->hide(); |
204 | popupTimer->start( 300, true ); | 205 | popupTimer->start( 300, true ); |
205 | } | 206 | } |
206 | 207 | ||
207 | void MainWindow::stopTimer(QListViewItem*) | 208 | void MainWindow::stopTimer(QListViewItem*) |
208 | { | 209 | { |
209 | popupTimer->stop(); | 210 | popupTimer->stop(); |
210 | } | 211 | } |
211 | 212 | ||
212 | void MainWindow::showPopup() | 213 | void MainWindow::showPopup() |
213 | { | 214 | { |
214 | qDebug("showPopup"); | ||
215 | popupTimer->stop(); | 215 | popupTimer->stop(); |
216 | if (!_currentItem) return; | 216 | if (!_currentItem) return; |
217 | QPopupMenu *pop = _currentItem->popupMenu(); | 217 | QPopupMenu *pop = _currentItem->popupMenu(); |
218 | if (pop) pop->popup( QCursor::pos() ); | 218 | if (pop) pop->popup( QCursor::pos() ); |
219 | } | 219 | } |
220 | 220 | ||
221 | void MainWindow::setSearch( const QString &key ) | 221 | void MainWindow::setSearch( const QString &key ) |
222 | { | 222 | { |
223 | searchTimer->stop(); | 223 | searchTimer->stop(); |
224 | _searchString = key; | 224 | _searchString = key; |
225 | searchTimer->start( 300 ); | 225 | searchTimer->start( 300 ); |
226 | } | 226 | } |
227 | 227 | ||
228 | void MainWindow::searchStringChanged() | 228 | void MainWindow::searchStringChanged() |
229 | { | 229 | { |
230 | #ifdef NEW_OWAIT | ||
231 | OWait("setting search string"); | ||
232 | #endif | ||
230 | searchTimer->stop(); | 233 | searchTimer->stop(); |
231 | QString ss = _searchString; | 234 | QString ss = _searchString; |
232 | //ss = Global::stringQuote( _searchString ); | 235 | //ss = Global::stringQuote( _searchString ); |
233 | //if (actionWholeWordsOnly->isOn()) | 236 | //if (actionWholeWordsOnly->isOn()) |
234 | // ss = "\\s"+_searchString+"\\s"; | 237 | // ss = "\\s"+_searchString+"\\s"; |
235 | qDebug(" set searchString >%s<",ss.latin1()); | 238 | //qDebug(" set searchString >%s<",ss.latin1()); |
236 | QRegExp re( ss ); | 239 | QRegExp re( ss ); |
237 | re.setCaseSensitive( actionCaseSensitiv->isOn() ); | 240 | re.setCaseSensitive( actionCaseSensitiv->isOn() ); |
238 | re.setWildcard( actionWildcards->isOn() ); | 241 | re.setWildcard( actionWildcards->isOn() ); |
239 | for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ) | 242 | for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ) |
240 | s->setSearch( re ); | 243 | s->setSearch( re ); |
241 | } | 244 | } |
242 | 245 | ||
243 | void MainWindow::searchAll() | 246 | void MainWindow::searchAll() |
244 | { | 247 | { |
248 | #ifdef NEW_OWAIT | ||
249 | OWait("searching..."); | ||
250 | #endif | ||
245 | for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ){ | 251 | for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ){ |
246 | s->doSearch(); | 252 | s->doSearch(); |
247 | //resultsList->repaint(); | 253 | //resultsList->repaint(); |
248 | } | 254 | } |
249 | } | 255 | } |
250 | 256 | ||
251 | void MainWindow::slotAction( int act ) | 257 | void MainWindow::slotAction( int act ) |
252 | { | 258 | { |
253 | if (_currentItem->rtti() == OListViewItem::Result){ | 259 | if (_currentItem->rtti() == OListViewItem::Result){ |
254 | ResultItem *res = (ResultItem*)_currentItem; | 260 | ResultItem *res = (ResultItem*)_currentItem; |
255 | // ResultItem *res = dynamic_cast<ResultItem*>(item); | 261 | // ResultItem *res = dynamic_cast<ResultItem*>(item); |
256 | res->action(act); | 262 | res->action(act); |
257 | } | 263 | } |
258 | } | 264 | } |
259 | 265 | ||
260 | void MainWindow::optionChanged(int i) | 266 | void MainWindow::optionChanged(int i) |
261 | { | 267 | { |
262 | qDebug("optionChanged(%i)",i); | 268 | qDebug("optionChanged(%i)",i); |
263 | searchStringChanged(); | 269 | searchStringChanged(); |
264 | } | 270 | } |
diff --git a/core/pim/osearch/searchgroup.cpp b/core/pim/osearch/searchgroup.cpp index e307696..0b58176 100644 --- a/core/pim/osearch/searchgroup.cpp +++ b/core/pim/osearch/searchgroup.cpp | |||
@@ -1,93 +1,92 @@ | |||
1 | // | 1 | // |
2 | // | 2 | // |
3 | // C++ Implementation: $MODULE$ | 3 | // C++ Implementation: $MODULE$ |
4 | // | 4 | // |
5 | // Description: | 5 | // Description: |
6 | // | 6 | // |
7 | // | 7 | // |
8 | // Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 | 8 | // Author: Patrick S. Vogt <tille@handhelds.org>, (C) 2003 |
9 | // | 9 | // |
10 | // Copyright: See COPYING file that comes with this distribution | 10 | // Copyright: See COPYING file that comes with this distribution |
11 | // | 11 | // |
12 | // | 12 | // |
13 | #include "searchgroup.h" | ||
14 | 13 | ||
14 | #include <qobject.h> | ||
15 | #include <qregexp.h> | 15 | #include <qregexp.h> |
16 | #include <qapplication.h> | 16 | #include <qapplication.h> |
17 | #include <opie/owait.h> | 17 | #include <opie/owait.h> |
18 | 18 | ||
19 | #include "olistviewitem.h" | 19 | #include "olistviewitem.h" |
20 | #include "searchgroup.h" | ||
20 | 21 | ||
21 | //#define NEW_OWAIT | ||
22 | #ifndef NEW_OWAIT | 22 | #ifndef NEW_OWAIT |
23 | static OWait *wait = 0; | 23 | static OWait *wait = 0; |
24 | #endif | 24 | #endif |
25 | 25 | ||
26 | SearchGroup::SearchGroup(QListView* parent, QString name) | 26 | SearchGroup::SearchGroup(QListView* parent, QString name) |
27 | : OListViewItem(parent, name) | 27 | : OListViewItem(parent, name) |
28 | { | 28 | { |
29 | _name = name; | 29 | _name = name; |
30 | loaded = false; | 30 | loaded = false; |
31 | } | 31 | } |
32 | 32 | ||
33 | 33 | ||
34 | SearchGroup::~SearchGroup() | 34 | SearchGroup::~SearchGroup() |
35 | { | 35 | { |
36 | } | 36 | } |
37 | 37 | ||
38 | 38 | ||
39 | void SearchGroup::expand() | 39 | void SearchGroup::expand() |
40 | { | 40 | { |
41 | //expanded = true; | 41 | //expanded = true; |
42 | clearList(); | 42 | if (_lastSearch != _search) clearList(); |
43 | if (_search.isEmpty()) return; | 43 | if (_search.isEmpty()) return; |
44 | OListViewItem *dummy = new OListViewItem( this, "searching..."); | 44 | OListViewItem *dummy = new OListViewItem( this, "searching..."); |
45 | setOpen( true ); | 45 | setOpen( true ); |
46 | repaint(); | 46 | repaint(); |
47 | int res_count = realSearch(); | 47 | int res_count = realSearch(); |
48 | setText(0, _name + " - " + _search.pattern() + " (" + QString::number( res_count ) + ")"); | 48 | setText(0, _name + " - " + _search.pattern() + " (" + QString::number( res_count ) + ")"); |
49 | delete dummy; | 49 | delete dummy; |
50 | repaint(); | 50 | repaint(); |
51 | } | 51 | } |
52 | 52 | ||
53 | void SearchGroup::doSearch() | 53 | void SearchGroup::doSearch() |
54 | { | 54 | { |
55 | clearList(); | 55 | clearList(); |
56 | if (_search.isEmpty()) return; | 56 | if (_search.isEmpty()) return; |
57 | _resultCount = realSearch(); | 57 | _resultCount = realSearch(); |
58 | //repaint(); | 58 | //repaint(); |
59 | } | 59 | } |
60 | 60 | ||
61 | void SearchGroup::setSearch(QRegExp re) | 61 | void SearchGroup::setSearch(QRegExp re) |
62 | { | 62 | { |
63 | if (re == _search) return; | 63 | if (re == _search) return; |
64 | setText(0, _name+" - "+re.pattern() ); | 64 | setText(0, _name+" - "+re.pattern() ); |
65 | _search = re; | 65 | _search = re; |
66 | if (isOpen()) expand(); | 66 | if (isOpen()) expand(); |
67 | else new OListViewItem( this, "searching..."); | 67 | else new OListViewItem( this, "searching..."); |
68 | } | 68 | } |
69 | 69 | ||
70 | int SearchGroup::realSearch() | 70 | int SearchGroup::realSearch() |
71 | { | 71 | { |
72 | if (_lastSearch == _search) return _resultCount; | ||
72 | #ifndef NEW_OWAIT | 73 | #ifndef NEW_OWAIT |
73 | qDebug("NOT using NEW_OWAIT"); | ||
74 | if (!wait) wait = new OWait( qApp->mainWidget(), "osearch" ); | 74 | if (!wait) wait = new OWait( qApp->mainWidget(), "osearch" ); |
75 | wait->show(); | 75 | wait->show(); |
76 | qApp->processEvents(); | 76 | qApp->processEvents(); |
77 | #else | 77 | #else |
78 | qDebug("using NEW_OWAIT"); | 78 | qDebug("********** NEW_OWAIT *************"); |
79 | OWait::start( "osearch" ); | 79 | OWait( "searching" ); |
80 | #endif | 80 | #endif |
81 | if (!loaded) load(); | 81 | if (!loaded) load(); |
82 | _resultCount = 0; | 82 | _resultCount = 0; |
83 | _resultCount = search(); | 83 | _resultCount = search(); |
84 | _lastSearch = _search; | ||
84 | setText(0, _name + " - " + _search.pattern() + " (" + QString::number( _resultCount ) + ")"); | 85 | setText(0, _name + " - " + _search.pattern() + " (" + QString::number( _resultCount ) + ")"); |
85 | 86 | ||
86 | #ifndef NEW_OWAIT | 87 | #ifndef NEW_OWAIT |
87 | wait->hide(); | 88 | wait->hide(); |
88 | #else | ||
89 | OWait::stop(); | ||
90 | #endif | 89 | #endif |
91 | return _resultCount; | 90 | return _resultCount; |
92 | } | 91 | } |
93 | 92 | ||
diff --git a/core/pim/osearch/searchgroup.h b/core/pim/osearch/searchgroup.h index a755e06..ad37d4e 100644 --- a/core/pim/osearch/searchgroup.h +++ b/core/pim/osearch/searchgroup.h | |||
@@ -13,36 +13,37 @@ | |||
13 | #ifndef SEARCHGROUP_H | 13 | #ifndef SEARCHGROUP_H |
14 | #define SEARCHGROUP_H | 14 | #define SEARCHGROUP_H |
15 | 15 | ||
16 | #include "olistviewitem.h" | 16 | #include "olistviewitem.h" |
17 | 17 | ||
18 | class QRegExp; | 18 | class QRegExp; |
19 | class QPopupMenu; | 19 | class QPopupMenu; |
20 | 20 | ||
21 | /** | 21 | /** |
22 | @author Patrick S. Vogt | 22 | @author Patrick S. Vogt |
23 | */ | 23 | */ |
24 | class SearchGroup : public OListViewItem | 24 | class SearchGroup : public OListViewItem |
25 | { | 25 | { |
26 | public: | 26 | public: |
27 | SearchGroup(QListView* parent, QString name); | 27 | SearchGroup(QListView* parent, QString name); |
28 | 28 | ||
29 | ~SearchGroup(); | 29 | ~SearchGroup(); |
30 | 30 | ||
31 | virtual void expand(); | 31 | virtual void expand(); |
32 | virtual void doSearch(); | 32 | virtual void doSearch(); |
33 | virtual void setSearch(QRegExp); | 33 | virtual void setSearch(QRegExp); |
34 | virtual int rtti() { return Searchgroup;} | 34 | virtual int rtti() { return Searchgroup;} |
35 | 35 | ||
36 | protected: | 36 | protected: |
37 | QRegExp _search; | ||
38 | virtual void load() = 0; | 37 | virtual void load() = 0; |
39 | virtual int search() = 0; | 38 | virtual int search() = 0; |
40 | virtual void insertItem( void* ) = 0; | 39 | virtual void insertItem( void* ) = 0; |
40 | QRegExp _search; | ||
41 | QRegExp _lastSearch; | ||
41 | QString _name; | 42 | QString _name; |
42 | bool loaded; | 43 | bool loaded; |
43 | int _resultCount; | 44 | int _resultCount; |
44 | private: | 45 | private: |
45 | int realSearch(); | 46 | int realSearch(); |
46 | }; | 47 | }; |
47 | 48 | ||
48 | #endif | 49 | #endif |