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 | |||
@@ -49,3 +49,5 @@ int AppLnkSearch::search() | |||
49 | insertItem( app ); | 49 | insertItem( app ); |
50 | } | 50 | }else |
51 | if (searchFile( app )) | ||
52 | insertItem( app ); | ||
51 | qApp->processEvents( 100 ); | 53 | qApp->processEvents( 100 ); |
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 | |||
@@ -18,2 +18,3 @@ | |||
18 | class AppLnkSet; | 18 | class AppLnkSet; |
19 | class AppLnk; | ||
19 | 20 | ||
@@ -26,3 +27,2 @@ public: | |||
26 | AppLnkSearch(QListView* parent, QString name); | 27 | AppLnkSearch(QListView* parent, QString name); |
27 | |||
28 | ~AppLnkSearch(); | 28 | ~AppLnkSearch(); |
@@ -30,2 +30,4 @@ public: | |||
30 | virtual void setSearch(QRegExp); | 30 | virtual void setSearch(QRegExp); |
31 | |||
32 | protected: | ||
31 | virtual void load(); | 33 | virtual void load(); |
@@ -33,3 +35,3 @@ public: | |||
33 | virtual void insertItem( void* ); | 35 | virtual void insertItem( void* ); |
34 | 36 | virtual bool searchFile(AppLnk*) { return false; }; | |
35 | AppLnkSet *_apps; | 37 | AppLnkSet *_apps; |
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 | |||
@@ -12,13 +12,19 @@ | |||
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 | { |
@@ -26,2 +32,7 @@ DocLnkSearch::DocLnkSearch(QListView* parent, QString name) | |||
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 | } |
@@ -31,2 +42,5 @@ DocLnkSearch::~DocLnkSearch() | |||
31 | { | 42 | { |
43 | Config cfg( "osearch", Config::User ); | ||
44 | cfg.setGroup( "doclnk_settings" ); | ||
45 | cfg.writeEntry( "search_content", actionSearchInFiles->isOn() ); | ||
32 | } | 46 | } |
@@ -38,2 +52,26 @@ void DocLnkSearch::load() | |||
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 ) |
@@ -43 +81,11 @@ void DocLnkSearch::insertItem( void *rec ) | |||
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 | |||
@@ -4,3 +4,3 @@ | |||
4 | // | 4 | // |
5 | // Description: | 5 | // Description: |
6 | // | 6 | // |
@@ -17,2 +17,5 @@ | |||
17 | 17 | ||
18 | class QAction; | ||
19 | class QPopupMenu; | ||
20 | |||
18 | /** | 21 | /** |
@@ -20,3 +23,3 @@ | |||
20 | */ | 23 | */ |
21 | class DocLnkSearch : public AppLnkSearch | 24 | class DocLnkSearch : public AppLnkSearch |
22 | { | 25 | { |
@@ -26,5 +29,11 @@ public: | |||
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 | ||
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 | |||
@@ -22,2 +22,3 @@ | |||
22 | #include <qpe/global.h> | 22 | #include <qpe/global.h> |
23 | #include <opie/owait.h> | ||
23 | #include <qaction.h> | 24 | #include <qaction.h> |
@@ -213,3 +214,2 @@ void MainWindow::showPopup() | |||
213 | { | 214 | { |
214 | qDebug("showPopup"); | ||
215 | popupTimer->stop(); | 215 | popupTimer->stop(); |
@@ -229,2 +229,5 @@ void MainWindow::searchStringChanged() | |||
229 | { | 229 | { |
230 | #ifdef NEW_OWAIT | ||
231 | OWait("setting search string"); | ||
232 | #endif | ||
230 | searchTimer->stop(); | 233 | searchTimer->stop(); |
@@ -234,3 +237,3 @@ void MainWindow::searchStringChanged() | |||
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 ); |
@@ -244,2 +247,5 @@ 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() ){ |
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 | |||
@@ -12,4 +12,4 @@ | |||
12 | // | 12 | // |
13 | #include "searchgroup.h" | ||
14 | 13 | ||
14 | #include <qobject.h> | ||
15 | #include <qregexp.h> | 15 | #include <qregexp.h> |
@@ -19,4 +19,4 @@ | |||
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 |
@@ -41,3 +41,3 @@ void SearchGroup::expand() | |||
41 | //expanded = true; | 41 | //expanded = true; |
42 | clearList(); | 42 | if (_lastSearch != _search) clearList(); |
43 | if (_search.isEmpty()) return; | 43 | if (_search.isEmpty()) return; |
@@ -71,4 +71,4 @@ 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" ); |
@@ -77,4 +77,4 @@ int SearchGroup::realSearch() | |||
77 | #else | 77 | #else |
78 | qDebug("using NEW_OWAIT"); | 78 | qDebug("********** NEW_OWAIT *************"); |
79 | OWait::start( "osearch" ); | 79 | OWait( "searching" ); |
80 | #endif | 80 | #endif |
@@ -83,2 +83,3 @@ int SearchGroup::realSearch() | |||
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 ) + ")"); |
@@ -87,4 +88,2 @@ int SearchGroup::realSearch() | |||
87 | wait->hide(); | 88 | wait->hide(); |
88 | #else | ||
89 | OWait::stop(); | ||
90 | #endif | 89 | #endif |
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 | |||
@@ -36,3 +36,2 @@ public: | |||
36 | protected: | 36 | protected: |
37 | QRegExp _search; | ||
38 | virtual void load() = 0; | 37 | virtual void load() = 0; |
@@ -40,2 +39,4 @@ protected: | |||
40 | virtual void insertItem( void* ) = 0; | 39 | virtual void insertItem( void* ) = 0; |
40 | QRegExp _search; | ||
41 | QRegExp _lastSearch; | ||
41 | QString _name; | 42 | QString _name; |