summaryrefslogtreecommitdiff
path: root/core/pim/osearch
Unidiff
Diffstat (limited to 'core/pim/osearch') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/osearch/applnksearch.cpp5
-rw-r--r--core/pim/osearch/contactitem.cpp4
-rw-r--r--core/pim/osearch/datebooksearch.cpp53
-rw-r--r--core/pim/osearch/datebooksearch.h8
-rw-r--r--core/pim/osearch/doclnksearch.cpp1
-rw-r--r--core/pim/osearch/mainwindow.cpp45
-rw-r--r--core/pim/osearch/mainwindow.h2
-rw-r--r--core/pim/osearch/olistviewitem.cpp11
-rw-r--r--core/pim/osearch/olistviewitem.h3
-rw-r--r--core/pim/osearch/searchgroup.cpp50
-rw-r--r--core/pim/osearch/searchgroup.h9
-rw-r--r--core/pim/osearch/todosearch.cpp37
-rw-r--r--core/pim/osearch/todosearch.h6
13 files changed, 175 insertions, 59 deletions
diff --git a/core/pim/osearch/applnksearch.cpp b/core/pim/osearch/applnksearch.cpp
index d5b181b..5fa36bb 100644
--- a/core/pim/osearch/applnksearch.cpp
+++ b/core/pim/osearch/applnksearch.cpp
@@ -41,23 +41,22 @@ void AppLnkSearch::load()
41 41
42int AppLnkSearch::search() 42int AppLnkSearch::search()
43{ 43{
44 int count = 0;
45 QList<AppLnk> appList = _apps->children(); 44 QList<AppLnk> appList = _apps->children();
46 for ( AppLnk *app = appList.first(); app != 0; app = appList.next() ){ 45 for ( AppLnk *app = appList.first(); app != 0; app = appList.next() ){
47 if ( (_search.match( app->name() ) != -1) 46 if ( (_search.match( app->name() ) != -1)
48 || (_search.match(app->comment()) != -1) 47 || (_search.match(app->comment()) != -1)
49 || (_search.match(app->exec()) != -1) ) { 48 || (_search.match(app->exec()) != -1) ) {
50 count++;
51 insertItem( app ); 49 insertItem( app );
52 } 50 }
53 qApp->processEvents( 100 ); 51 qApp->processEvents( 100 );
54 } 52 }
55 return count; 53 return _resultCount;
56} 54}
57 55
58void AppLnkSearch::insertItem( void *rec ) 56void AppLnkSearch::insertItem( void *rec )
59{ 57{
60 new AppLnkItem( this, (AppLnk*)rec ); 58 new AppLnkItem( this, (AppLnk*)rec );
59 _resultCount++;
61} 60}
62 61
63void AppLnkSearch::setSearch(QRegExp re) 62void AppLnkSearch::setSearch(QRegExp re)
diff --git a/core/pim/osearch/contactitem.cpp b/core/pim/osearch/contactitem.cpp
index 1d24b18..ad43ba2 100644
--- a/core/pim/osearch/contactitem.cpp
+++ b/core/pim/osearch/contactitem.cpp
@@ -70,14 +70,14 @@ void ContactItem::setIcon()
70 case Qtopia::Suffix: 70 case Qtopia::Suffix:
71 case Qtopia::Nickname: 71 case Qtopia::Nickname:
72 case Qtopia::FileAs: 72 case Qtopia::FileAs:
73 icon = Resource::loadPixmap( "addressbook/identity" ); 73 icon = Resource::loadPixmap( "osearch/identity" );
74 break; 74 break;
75 case Qtopia::HomeStreet: 75 case Qtopia::HomeStreet:
76 case Qtopia::HomeCity: 76 case Qtopia::HomeCity:
77 case Qtopia::HomeState: 77 case Qtopia::HomeState:
78 case Qtopia::HomeZip: 78 case Qtopia::HomeZip:
79 case Qtopia::HomeCountry: 79 case Qtopia::HomeCountry:
80 icon = Resource::loadPixmap( "addressbook/addresshome" ); 80 icon = Resource::loadPixmap( "osearch/addresshome" );
81 break; 81 break;
82 case Qtopia::Company: 82 case Qtopia::Company:
83 case Qtopia::BusinessCity: 83 case Qtopia::BusinessCity:
diff --git a/core/pim/osearch/datebooksearch.cpp b/core/pim/osearch/datebooksearch.cpp
index 7aabcea..5da7ae9 100644
--- a/core/pim/osearch/datebooksearch.cpp
+++ b/core/pim/osearch/datebooksearch.cpp
@@ -14,24 +14,40 @@
14 14
15#include "eventitem.h" 15#include "eventitem.h"
16 16
17#include <qpe/resource.h>
18#include <qpe/config.h>
17#include <opie/oevent.h> 19#include <opie/oevent.h>
20#include <opie/orecur.h>
18#include <opie/odatebookaccess.h> 21#include <opie/odatebookaccess.h>
19#include <qiconset.h> 22#include <qiconset.h>
20#include <qpe/resource.h> 23#include <qaction.h>
24#include <qdatetime.h>
25#include <qpopupmenu.h>
21 26
22DatebookSearch::DatebookSearch(QListView* parent, QString name) 27DatebookSearch::DatebookSearch(QListView* parent, QString name)
23: SearchGroup(parent, name) 28: SearchGroup(parent, name), _dates(0), _popupMenu(0)
24{ 29{
25 _dates = 0;
26 QIconSet is = Resource::loadIconSet( "datebook/DateBook" ); 30 QIconSet is = Resource::loadIconSet( "datebook/DateBook" );
27 setPixmap( 0, is.pixmap( QIconSet::Small, true ) ); 31 setPixmap( 0, is.pixmap( QIconSet::Small, true ) );
28 32 actionShowPastEvents = new QAction( QObject::tr("show past events"),QString::null, 0, 0, 0, true );
33 actionSearchInDates = new QAction( QObject::tr("search in dates"),QString::null, 0, 0, 0, true );
34 Config cfg( "osearch", Config::User );
35 cfg.setGroup( "datebook_settings" );
36 actionShowPastEvents->setOn( cfg.readBoolEntry( "show_past_events", false ) );
37 actionSearchInDates->setOn( cfg.readBoolEntry( "search_in_dates", true ) );
29} 38}
30 39
31
32DatebookSearch::~DatebookSearch() 40DatebookSearch::~DatebookSearch()
33{ 41{
42 qDebug("SAVE DATEBOOK SEARCH CONFIG");
43 Config cfg( "osearch", Config::User );
44 cfg.setGroup( "datebook_settings" );
45 cfg.writeEntry( "show_past_events", actionShowPastEvents->isOn() );
46 cfg.writeEntry( "search_in_dates", actionSearchInDates->isOn() );
34 delete _dates; 47 delete _dates;
48 delete _popupMenu;
49 delete actionShowPastEvents;
50 delete actionSearchInDates;
35} 51}
36 52
37 53
@@ -45,11 +61,32 @@ int DatebookSearch::search()
45{ 61{
46 ORecordList<OEvent> results = _dates->matchRegexp(_search); 62 ORecordList<OEvent> results = _dates->matchRegexp(_search);
47 for (uint i = 0; i < results.count(); i++) 63 for (uint i = 0; i < results.count(); i++)
48 new EventItem( this, new OEvent( results[i] )); 64 insertItem( new OEvent( results[i] ) );
49 return results.count(); 65 return _resultCount;
50} 66}
51 67
52void DatebookSearch::insertItem( void* ) 68void DatebookSearch::insertItem( void *rec )
53{ 69{
70 OEvent *ev = (OEvent*)rec;
71 if ( !actionShowPastEvents->isOn() &&
72 ev->endDateTime() < QDateTime::currentDateTime() &&
73 !ev->recurrence().doesRecur()
74 ) return;
75 if ( !actionSearchInDates->isOn() && (
76 ev->lastHitField() == Qtopia::StartDateTime ||
77 ev->lastHitField() == Qtopia::EndDateTime )
78 ) return;
79 new EventItem( this, ev );
80 _resultCount++;
81}
54 82
83QPopupMenu* DatebookSearch::popupMenu()
84{
85 if (!_popupMenu){
86 _popupMenu = new QPopupMenu( 0 );
87 actionShowPastEvents->addTo( _popupMenu );
88 actionSearchInDates->addTo( _popupMenu );
89 }
90 return _popupMenu;
55} 91}
92
diff --git a/core/pim/osearch/datebooksearch.h b/core/pim/osearch/datebooksearch.h
index bb31462..a6d115e 100644
--- a/core/pim/osearch/datebooksearch.h
+++ b/core/pim/osearch/datebooksearch.h
@@ -16,6 +16,7 @@
16#include "searchgroup.h" 16#include "searchgroup.h"
17 17
18class ODateBookAccess; 18class ODateBookAccess;
19class QAction;
19 20
20/** 21/**
21@author Patrick S. Vogt 22@author Patrick S. Vogt
@@ -24,9 +25,10 @@ class DatebookSearch : public SearchGroup
24{ 25{
25public: 26public:
26 DatebookSearch(QListView* parent, QString name); 27 DatebookSearch(QListView* parent, QString name);
27
28 ~DatebookSearch(); 28 ~DatebookSearch();
29 29
30 virtual QPopupMenu* popupMenu();
31
30protected: 32protected:
31 virtual void load(); 33 virtual void load();
32 virtual int search(); 34 virtual int search();
@@ -34,7 +36,9 @@ protected:
34 36
35private: 37private:
36 ODateBookAccess *_dates; 38 ODateBookAccess *_dates;
37 39 QAction *actionShowPastEvents;
40 QAction *actionSearchInDates;
41 QPopupMenu *_popupMenu;
38}; 42};
39 43
40#endif 44#endif
diff --git a/core/pim/osearch/doclnksearch.cpp b/core/pim/osearch/doclnksearch.cpp
index 123eaa0..d97eeb8 100644
--- a/core/pim/osearch/doclnksearch.cpp
+++ b/core/pim/osearch/doclnksearch.cpp
@@ -39,4 +39,5 @@ void DocLnkSearch::load()
39void DocLnkSearch::insertItem( void *rec ) 39void DocLnkSearch::insertItem( void *rec )
40{ 40{
41 new DocLnkItem( this, (DocLnk*)rec ); 41 new DocLnkItem( this, (DocLnk*)rec );
42 _resultCount++;
42} 43}
diff --git a/core/pim/osearch/mainwindow.cpp b/core/pim/osearch/mainwindow.cpp
index b80c637..89ab690 100644
--- a/core/pim/osearch/mainwindow.cpp
+++ b/core/pim/osearch/mainwindow.cpp
@@ -19,6 +19,7 @@
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 <qaction.h> 23#include <qaction.h>
23#include <qmessagebox.h> 24#include <qmessagebox.h>
24#include <qpopupmenu.h> 25#include <qpopupmenu.h>
@@ -84,7 +85,6 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) :
84 searches.append( new DatebookSearch( resultsList, tr("datebook") ) ); 85 searches.append( new DatebookSearch( resultsList, tr("datebook") ) );
85 searches.append( new AdressSearch( resultsList, tr("adressbook") ) ); 86 searches.append( new AdressSearch( resultsList, tr("adressbook") ) );
86 87
87 makeMenu();
88 setCentralWidget( mainFrame ); 88 setCentralWidget( mainFrame );
89 89
90 popupTimer = new QTimer(); 90 popupTimer = new QTimer();
@@ -96,11 +96,13 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) :
96 connect(resultsList, SIGNAL(clicked(QListViewItem*)), SLOT(stopTimer(QListViewItem*))); 96 connect(resultsList, SIGNAL(clicked(QListViewItem*)), SLOT(stopTimer(QListViewItem*)));
97 connect(buttonGroupActions, SIGNAL(clicked(int)), SLOT( slotAction(int) ) ); 97 connect(buttonGroupActions, SIGNAL(clicked(int)), SLOT( slotAction(int) ) );
98 98
99 makeMenu();
99 100
100 Config cfg( "osearch", Config::User ); 101 Config cfg( "osearch", Config::User );
101 cfg.setGroup( "search_settings" ); 102 cfg.setGroup( "search_settings" );
102 actionCaseSensitiv->setOn( cfg.readBoolEntry( "caseSensitiv", false ) ); 103 actionCaseSensitiv->setOn( cfg.readBoolEntry( "caseSensitiv", false ) );
103 actionWildcards->setOn( cfg.readBoolEntry( "wildcards", false ) ); 104 actionWildcards->setOn( cfg.readBoolEntry( "wildcards", false ) );
105// actionWholeWordsOnly->setOn( cfg.readBoolEntry( "whole_words_only", false ) );
104} 106}
105 107
106void MainWindow::makeMenu() 108void MainWindow::makeMenu()
@@ -117,7 +119,18 @@ void MainWindow::makeMenu()
117 toolBar->setHorizontalStretchable( true ); 119 toolBar->setHorizontalStretchable( true );
118 menuBar->insertItem( tr( "Search" ), searchMenu ); 120 menuBar->insertItem( tr( "Search" ), searchMenu );
119 menuBar->insertItem( tr( "Settings" ), cfgMenu ); 121 menuBar->insertItem( tr( "Settings" ), cfgMenu );
122
123 //SETTINGS MENU
120 cfgMenu->insertItem( tr( "Search" ), searchOptions ); 124 cfgMenu->insertItem( tr( "Search" ), searchOptions );
125 QPopupMenu *pop;
126 for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ){
127 pop = s->popupMenu();
128 if (pop){
129 qDebug("inserting settings menu for %s",s->text(0).latin1());
130 cfgMenu->insertItem( s->text(0), pop );
131 //connect( pop, SIGNAL( activated(int) ), SLOT( optionChanged(int) ) );
132 }
133 }
121 134
122 135
123 //SEARCH 136 //SEARCH
@@ -126,8 +139,11 @@ void MainWindow::makeMenu()
126 connect( SearchAllAction, SIGNAL(activated()), this, SLOT(searchAll()) ); 139 connect( SearchAllAction, SIGNAL(activated()), this, SLOT(searchAll()) );
127 SearchAllAction->addTo( searchMenu ); 140 SearchAllAction->addTo( searchMenu );
128 searchMenu->insertItem( tr( "Options" ), searchOptions ); 141 searchMenu->insertItem( tr( "Options" ), searchOptions );
142 //connect( searchOptions, SIGNAL( activated(int) ), SLOT( optionChanged(int) ) );
129 143
130 //SEARCH OPTIONS 144 //SEARCH OPTIONS
145 //actionWholeWordsOnly = new QAction( tr("Whole words only"),QString::null, 0, this, 0, true );
146 //actionWholeWordsOnly->addTo( searchOptions );
131 actionCaseSensitiv = new QAction( tr("Case sensitiv"),QString::null, 0, this, 0, true ); 147 actionCaseSensitiv = new QAction( tr("Case sensitiv"),QString::null, 0, this, 0, true );
132 actionCaseSensitiv->addTo( searchOptions ); 148 actionCaseSensitiv->addTo( searchOptions );
133 actionWildcards = new QAction( tr("Use wildcards"),QString::null, 0, this, 0, true ); 149 actionWildcards = new QAction( tr("Use wildcards"),QString::null, 0, this, 0, true );
@@ -151,6 +167,7 @@ MainWindow::~MainWindow()
151 cfg.setGroup( "search_settings" ); 167 cfg.setGroup( "search_settings" );
152 cfg.writeEntry( "caseSensitiv", actionCaseSensitiv->isOn() ); 168 cfg.writeEntry( "caseSensitiv", actionCaseSensitiv->isOn() );
153 cfg.writeEntry( "wildcards", actionWildcards->isOn() ); 169 cfg.writeEntry( "wildcards", actionWildcards->isOn() );
170 //cfg.writeEntry( "whole_words_only", actionWholeWordsOnly->isOn() );
154} 171}
155 172
156void MainWindow::setCurrent(QListViewItem *item) 173void MainWindow::setCurrent(QListViewItem *item)
@@ -182,14 +199,9 @@ void MainWindow::setCurrent(QListViewItem *item)
182 if (button) button->hide(); 199 if (button) button->hide();
183 } 200 }
184 _buttonCount = acts.count(); 201 _buttonCount = acts.count();
185 // buttonShow = new QPushButton( detailsFrame, "Show" ) ;
186 // buttonShow->setText( "test" );
187 // buttonLayout->addWidget( buttonShow, 0 );
188// buttonGroupActions->insert(buttonShow);
189 detailsFrame->show(); 202 detailsFrame->show();
190 }else detailsFrame->hide(); 203 }else detailsFrame->hide();
191 //_currentItem = (OListViewItem*)item; 204 popupTimer->start( 300, true );
192 popupTimer->start( 300 );
193} 205}
194 206
195void MainWindow::stopTimer(QListViewItem*) 207void MainWindow::stopTimer(QListViewItem*)
@@ -200,7 +212,10 @@ void MainWindow::stopTimer(QListViewItem*)
200void MainWindow::showPopup() 212void MainWindow::showPopup()
201{ 213{
202 qDebug("showPopup"); 214 qDebug("showPopup");
215 popupTimer->stop();
203 if (!_currentItem) return; 216 if (!_currentItem) return;
217 QPopupMenu *pop = _currentItem->popupMenu();
218 if (pop) pop->popup( QCursor::pos() );
204} 219}
205 220
206void MainWindow::setSearch( const QString &key ) 221void MainWindow::setSearch( const QString &key )
@@ -213,7 +228,14 @@ void MainWindow::setSearch( const QString &key )
213void MainWindow::searchStringChanged() 228void MainWindow::searchStringChanged()
214{ 229{
215 searchTimer->stop(); 230 searchTimer->stop();
216 QRegExp re( _searchString, actionCaseSensitiv->isOn(), actionWildcards->isOn() ); 231 QString ss = _searchString;
232 //ss = Global::stringQuote( _searchString );
233 //if (actionWholeWordsOnly->isOn())
234 // ss = "\\s"+_searchString+"\\s";
235 qDebug(" set searchString >%s<",ss.latin1());
236 QRegExp re( ss );
237 re.setCaseSensitive( actionCaseSensitiv->isOn() );
238 re.setWildcard( actionWildcards->isOn() );
217 for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ) 239 for (SearchGroup *s = searches.first(); s != 0; s = searches.next() )
218 s->setSearch( re ); 240 s->setSearch( re );
219} 241}
@@ -226,7 +248,7 @@ void MainWindow::searchAll()
226 } 248 }
227} 249}
228 250
229void MainWindow::slotAction( int act) 251void MainWindow::slotAction( int act )
230{ 252{
231 if (_currentItem->rtti() == OListViewItem::Result){ 253 if (_currentItem->rtti() == OListViewItem::Result){
232 ResultItem *res = (ResultItem*)_currentItem; 254 ResultItem *res = (ResultItem*)_currentItem;
@@ -235,3 +257,8 @@ void MainWindow::slotAction( int act)
235 } 257 }
236} 258}
237 259
260void MainWindow::optionChanged(int i)
261{
262 qDebug("optionChanged(%i)",i);
263 searchStringChanged();
264}
diff --git a/core/pim/osearch/mainwindow.h b/core/pim/osearch/mainwindow.h
index 939762e..cba11c5 100644
--- a/core/pim/osearch/mainwindow.h
+++ b/core/pim/osearch/mainwindow.h
@@ -51,6 +51,7 @@ protected slots:
51 void showPopup(); 51 void showPopup();
52 void stopTimer( QListViewItem* ); 52 void stopTimer( QListViewItem* );
53 void searchStringChanged(); 53 void searchStringChanged();
54 void optionChanged(int);
54 55
55private: 56private:
56 OListView *resultsList; 57 OListView *resultsList;
@@ -68,6 +69,7 @@ private:
68 QAction *SearchAllAction; 69 QAction *SearchAllAction;
69 QAction *actionCaseSensitiv; 70 QAction *actionCaseSensitiv;
70 QAction *actionWildcards; 71 QAction *actionWildcards;
72 //QAction *actionWholeWordsOnly;
71 uint _buttonCount; 73 uint _buttonCount;
72 void makeMenu(); 74 void makeMenu();
73}; 75};
diff --git a/core/pim/osearch/olistviewitem.cpp b/core/pim/osearch/olistviewitem.cpp
index 29c5942..2d67559 100644
--- a/core/pim/osearch/olistviewitem.cpp
+++ b/core/pim/osearch/olistviewitem.cpp
@@ -28,3 +28,14 @@ OListViewItem::~OListViewItem()
28{ 28{
29} 29}
30 30
31void OListViewItem::clearList()
32{
33 QListViewItem *item = firstChild();
34 QListViewItem *toDel;
35 while ( item != 0 ) {
36 toDel = item;
37 item = item->nextSibling();
38 delete toDel;
39 }
40}
41
diff --git a/core/pim/osearch/olistviewitem.h b/core/pim/osearch/olistviewitem.h
index 66471f1..9e072a1 100644
--- a/core/pim/osearch/olistviewitem.h
+++ b/core/pim/osearch/olistviewitem.h
@@ -24,6 +24,9 @@ public:
24 24
25 virtual void expand(){}; 25 virtual void expand(){};
26 virtual int rtti() { return Raw;} 26 virtual int rtti() { return Raw;}
27 virtual QPopupMenu* popupMenu() { return 0;};
28 void clearList();
29
27}; 30};
28 31
29#endif 32#endif
diff --git a/core/pim/osearch/searchgroup.cpp b/core/pim/osearch/searchgroup.cpp
index 490deea..e307696 100644
--- a/core/pim/osearch/searchgroup.cpp
+++ b/core/pim/osearch/searchgroup.cpp
@@ -13,11 +13,16 @@
13#include "searchgroup.h" 13#include "searchgroup.h"
14 14
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 20
21//#define NEW_OWAIT
22#ifndef NEW_OWAIT
23static OWait *wait = 0;
24#endif
25
21SearchGroup::SearchGroup(QListView* parent, QString name) 26SearchGroup::SearchGroup(QListView* parent, QString name)
22: OListViewItem(parent, name) 27: OListViewItem(parent, name)
23{ 28{
@@ -49,24 +54,13 @@ void SearchGroup::doSearch()
49{ 54{
50 clearList(); 55 clearList();
51 if (_search.isEmpty()) return; 56 if (_search.isEmpty()) return;
52 int res_count = realSearch(); 57 _resultCount = realSearch();
53 setText(0, _name + " - " + _search.pattern() + " (" + QString::number( res_count ) + ")");
54 //repaint(); 58 //repaint();
55} 59}
56 60
57void SearchGroup::clearList()
58{
59 QListViewItem *item = firstChild();
60 QListViewItem *toDel;
61 while ( item != 0 ) {
62 toDel = item;
63 item = item->nextSibling();
64 delete toDel;
65 }
66}
67
68void SearchGroup::setSearch(QRegExp re) 61void SearchGroup::setSearch(QRegExp re)
69{ 62{
63 if (re == _search) return;
70 setText(0, _name+" - "+re.pattern() ); 64 setText(0, _name+" - "+re.pattern() );
71 _search = re; 65 _search = re;
72 if (isOpen()) expand(); 66 if (isOpen()) expand();
@@ -75,13 +69,25 @@ void SearchGroup::setSearch(QRegExp re)
75 69
76int SearchGroup::realSearch() 70int SearchGroup::realSearch()
77{ 71{
78 //emit isSearching( tr(" Searching for %s in %s" ).arg( _search.pattern().latin1()).arg( _name ) ); 72#ifndef NEW_OWAIT
79 /*OWait *wait = new OWait( qApp->mainWidget(), "test" ); 73 qDebug("NOT using NEW_OWAIT");
80 wait->show();*/ 74 if (!wait) wait = new OWait( qApp->mainWidget(), "osearch" );
75 wait->show();
76 qApp->processEvents();
77#else
78 qDebug("using NEW_OWAIT");
79 OWait::start( "osearch" );
80#endif
81 if (!loaded) load(); 81 if (!loaded) load();
82 int count = search(); 82 _resultCount = 0;
83 /*wait->hide(); 83 _resultCount = search();
84 delete wait;*/ 84 setText(0, _name + " - " + _search.pattern() + " (" + QString::number( _resultCount ) + ")");
85 return count; 85
86#ifndef NEW_OWAIT
87 wait->hide();
88#else
89 OWait::stop();
90#endif
91 return _resultCount;
86} 92}
87 93
diff --git a/core/pim/osearch/searchgroup.h b/core/pim/osearch/searchgroup.h
index 32f32e0..a755e06 100644
--- a/core/pim/osearch/searchgroup.h
+++ b/core/pim/osearch/searchgroup.h
@@ -16,13 +16,13 @@
16#include "olistviewitem.h" 16#include "olistviewitem.h"
17 17
18class QRegExp; 18class QRegExp;
19class QPopupMenu;
19 20
20/** 21/**
21@author Patrick S. Vogt 22@author Patrick S. Vogt
22*/ 23*/
23class SearchGroup : public OListViewItem //, QObject 24class SearchGroup : public OListViewItem
24{ 25{
25//Q_OBJECT
26public: 26public:
27 SearchGroup(QListView* parent, QString name); 27 SearchGroup(QListView* parent, QString name);
28 28
@@ -33,17 +33,14 @@ public:
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// signals:
37 // isSearching(QString);
38
39protected: 36protected:
40 QRegExp _search; 37 QRegExp _search;
41 virtual void load() = 0; 38 virtual void load() = 0;
42 virtual int search() = 0; 39 virtual int search() = 0;
43 virtual void insertItem( void* ) = 0; 40 virtual void insertItem( void* ) = 0;
44 void clearList();
45 QString _name; 41 QString _name;
46 bool loaded; 42 bool loaded;
43 int _resultCount;
47private: 44private:
48 int realSearch(); 45 int realSearch();
49}; 46};
diff --git a/core/pim/osearch/todosearch.cpp b/core/pim/osearch/todosearch.cpp
index c9fa61a..08bbe93 100644
--- a/core/pim/osearch/todosearch.cpp
+++ b/core/pim/osearch/todosearch.cpp
@@ -14,23 +14,35 @@
14 14
15#include <opie/otodoaccess.h> 15#include <opie/otodoaccess.h>
16#include <opie/otodo.h> 16#include <opie/otodo.h>
17#include <qiconset.h>
18#include <qpe/resource.h> 17#include <qpe/resource.h>
18#include <qpe/config.h>
19#include <qiconset.h>
20#include <qaction.h>
21#include <qpopupmenu.h>
19#include "todoitem.h" 22#include "todoitem.h"
20 23
21TodoSearch::TodoSearch(QListView* parent, QString name) 24TodoSearch::TodoSearch(QListView* parent, QString name)
22: SearchGroup(parent, name) 25: SearchGroup(parent, name), _todos(0), _popupMenu(0)
23{ 26{
24 _todos = 0;
25 //AppLnkSet als(QPEApplication::qpeDir()); 27 //AppLnkSet als(QPEApplication::qpeDir());
26 //setPixmap( 0, als.findExec("todolist")->pixmap() ); 28 //setPixmap( 0, als.findExec("todolist")->pixmap() );
27 QIconSet is = Resource::loadIconSet( "todo/TodoList" ); 29 QIconSet is = Resource::loadIconSet( "todo/TodoList" );
28 setPixmap( 0, is.pixmap( QIconSet::Small, true ) ); 30 setPixmap( 0, is.pixmap( QIconSet::Small, true ) );
31 actionShowCompleted = new QAction( QObject::tr("show completed tasks"),QString::null, 0, 0, 0, true );
32 Config cfg( "osearch", Config::User );
33 cfg.setGroup( "todo_settings" );
34 actionShowCompleted->setOn( cfg.readBoolEntry( "show_completed_tasks", false ) );
35
29} 36}
30 37
31 38
32TodoSearch::~TodoSearch() 39TodoSearch::~TodoSearch()
33{ 40{
41 Config cfg( "osearch", Config::User );
42 cfg.setGroup( "todo_settings" );
43 cfg.writeEntry( "show_completed_tasks", actionShowCompleted->isOn() );
44 delete _popupMenu;
45 delete actionShowCompleted;
34 delete _todos; 46 delete _todos;
35} 47}
36 48
@@ -45,11 +57,24 @@ int TodoSearch::search()
45{ 57{
46 ORecordList<OTodo> results = _todos->matchRegexp(_search); 58 ORecordList<OTodo> results = _todos->matchRegexp(_search);
47 for (uint i = 0; i < results.count(); i++) 59 for (uint i = 0; i < results.count(); i++)
48 new TodoItem( this, new OTodo( results[i] )); 60 insertItem( new OTodo( results[i] ));
49 return results.count(); 61 return _resultCount;
50} 62}
51 63
52void TodoSearch::insertItem( void* ) 64void TodoSearch::insertItem( void *rec )
53{ 65{
66 OTodo *todo = (OTodo*)rec;
67 if (!actionShowCompleted->isOn() &&
68 todo->isCompleted() ) return;
69 new TodoItem( this, todo );
70 _resultCount++;
71}
54 72
73QPopupMenu* TodoSearch::popupMenu()
74{
75 if (!_popupMenu){
76 _popupMenu = new QPopupMenu( 0 );
77 actionShowCompleted->addTo( _popupMenu );
78 }
79 return _popupMenu;
55} 80}
diff --git a/core/pim/osearch/todosearch.h b/core/pim/osearch/todosearch.h
index 1d025d6..ee175da 100644
--- a/core/pim/osearch/todosearch.h
+++ b/core/pim/osearch/todosearch.h
@@ -16,6 +16,7 @@
16#include "searchgroup.h" 16#include "searchgroup.h"
17 17
18class OTodoAccess; 18class OTodoAccess;
19class QAction;
19 20
20/** 21/**
21@author Patrick S. Vogt 22@author Patrick S. Vogt
@@ -24,9 +25,10 @@ class TodoSearch : public SearchGroup
24{ 25{
25public: 26public:
26 TodoSearch(QListView* parent, QString name); 27 TodoSearch(QListView* parent, QString name);
27
28 ~TodoSearch(); 28 ~TodoSearch();
29 29
30 virtual QPopupMenu* popupMenu();
31
30protected: 32protected:
31 virtual void load(); 33 virtual void load();
32 virtual int search(); 34 virtual int search();
@@ -34,6 +36,8 @@ protected:
34 36
35private: 37private:
36 OTodoAccess *_todos; 38 OTodoAccess *_todos;
39 QAction *actionShowCompleted;
40 QPopupMenu *_popupMenu;
37}; 41};
38 42
39#endif 43#endif