summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/pim/osearch/applnksearch.cpp4
-rw-r--r--core/pim/osearch/applnksearch.h6
-rw-r--r--core/pim/osearch/doclnksearch.cpp56
-rw-r--r--core/pim/osearch/doclnksearch.h9
-rw-r--r--core/pim/osearch/mainwindow.cpp10
-rw-r--r--core/pim/osearch/searchgroup.cpp15
-rw-r--r--core/pim/osearch/searchgroup.h3
7 files changed, 85 insertions, 18 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
@@ -47,7 +47,9 @@ int AppLnkSearch::search()
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;
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
@@ -16,6 +16,7 @@
16#include "searchgroup.h" 16#include "searchgroup.h"
17 17
18class AppLnkSet; 18class AppLnkSet;
19class AppLnk;
19 20
20/** 21/**
21@author Patrick S. Vogt 22@author Patrick S. Vogt
@@ -24,14 +25,15 @@ class AppLnkSearch : public SearchGroup
24{ 25{
25public: 26public:
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
32protected:
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
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
@@ -10,25 +10,39 @@
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
22DocLnkSearch::DocLnkSearch(QListView* parent, QString name) 28DocLnkSearch::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
30DocLnkSearch::~DocLnkSearch() 41DocLnkSearch::~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
34void DocLnkSearch::load() 48void DocLnkSearch::load()
@@ -36,8 +50,42 @@ void DocLnkSearch::load()
36 _apps = new DocLnkSet(QPEApplication::documentDir()); 50 _apps = new DocLnkSet(QPEApplication::documentDir());
37} 51}
38 52
53bool 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
39void DocLnkSearch::insertItem( void *rec ) 77void 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
84QPopupMenu* 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
@@ -15,6 +15,9 @@
15 15
16#include "applnksearch.h" 16#include "applnksearch.h"
17 17
18class QAction;
19class QPopupMenu;
20
18/** 21/**
19@author Patrick S. Vogt 22@author Patrick S. Vogt
20*/ 23*/
@@ -24,9 +27,15 @@ public:
24 DocLnkSearch(QListView* parent, QString name); 27 DocLnkSearch(QListView* parent, QString name);
25 ~DocLnkSearch(); 28 ~DocLnkSearch();
26 29
30 virtual QPopupMenu* popupMenu();
31
27protected: 32protected:
28 virtual void load(); 33 virtual void load();
34 virtual bool searchFile(AppLnk*);
29 virtual void insertItem( void* ); 35 virtual void insertItem( void* );
36private:
37 QAction *actionSearchInFiles;
38 QPopupMenu *_popupMenu;
30 39
31}; 40};
32 41
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
@@ -20,6 +20,7 @@
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>
@@ -211,7 +212,6 @@ void MainWindow::stopTimer(QListViewItem*)
211 212
212void MainWindow::showPopup() 213void 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();
@@ -227,12 +227,15 @@ void MainWindow::setSearch( const QString &key )
227 227
228void MainWindow::searchStringChanged() 228void 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() );
@@ -242,6 +245,9 @@ void MainWindow::searchStringChanged()
242 245
243void MainWindow::searchAll() 246void 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();
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
@@ -10,15 +10,15 @@
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
23static OWait *wait = 0; 23static OWait *wait = 0;
24#endif 24#endif
@@ -39,7 +39,7 @@ SearchGroup::~SearchGroup()
39void SearchGroup::expand() 39void 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 );
@@ -69,24 +69,23 @@ void SearchGroup::setSearch(QRegExp re)
69 69
70int SearchGroup::realSearch() 70int 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}
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
@@ -34,10 +34,11 @@ public:
34 virtual int rtti() { return Searchgroup;} 34 virtual int rtti() { return Searchgroup;}
35 35
36protected: 36protected:
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;