summaryrefslogtreecommitdiff
path: root/core
authortille <tille>2003-05-15 13:55:07 (UTC)
committer tille <tille>2003-05-15 13:55:07 (UTC)
commit80e9fd1b08a3a7173ecf443b2830df4ca6e83ce6 (patch) (unidiff)
tree4245ef4caf67784b452b908a9528ae03f988bf4c /core
parentded2a7a5715af1d1f6aab0b79ba90d8a815a9adc (diff)
downloadopie-80e9fd1b08a3a7173ecf443b2830df4ca6e83ce6.zip
opie-80e9fd1b08a3a7173ecf443b2830df4ca6e83ce6.tar.gz
opie-80e9fd1b08a3a7173ecf443b2830df4ca6e83ce6.tar.bz2
owait and settings for search group:
- hide completed todos - show only later events - do not display hits in datebook dated
Diffstat (limited to 'core') (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
@@ -38,29 +38,28 @@ void AppLnkSearch::load()
38{ 38{
39 _apps = new AppLnkSet(QPEApplication::qpeDir()); 39 _apps = new AppLnkSet(QPEApplication::qpeDir());
40} 40}
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)
64{ 63{
65 setOpen( false ); 64 setOpen( false );
66 SearchGroup::setSearch( re ); 65 SearchGroup::setSearch( 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
@@ -67,20 +67,20 @@ void ContactItem::setIcon()
67 case Qtopia::FirstName: 67 case Qtopia::FirstName:
68 case Qtopia::MiddleName: 68 case Qtopia::MiddleName:
69 case Qtopia::LastName: 69 case Qtopia::LastName:
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:
84 case Qtopia::BusinessStreet: 84 case Qtopia::BusinessStreet:
85 case Qtopia::BusinessZip: 85 case Qtopia::BusinessZip:
86 case Qtopia::BusinessCountry: 86 case Qtopia::BusinessCountry:
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
@@ -11,30 +11,46 @@
11// 11//
12// 12//
13#include "datebooksearch.h" 13#include "datebooksearch.h"
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
38void DatebookSearch::load() 54void DatebookSearch::load()
39{ 55{
40 _dates = new ODateBookAccess(); 56 _dates = new ODateBookAccess();
@@ -42,14 +58,35 @@ void DatebookSearch::load()
42} 58}
43 59
44int DatebookSearch::search() 60int 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
@@ -13,28 +13,32 @@
13#ifndef DATEBOOKSEARCH_H 13#ifndef DATEBOOKSEARCH_H
14#define DATEBOOKSEARCH_H 14#define DATEBOOKSEARCH_H
15 15
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
22*/ 23*/
23class DatebookSearch : public SearchGroup 24class 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();
33 virtual void insertItem( void* ); 35 virtual void insertItem( void* );
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
@@ -36,7 +36,8 @@ void DocLnkSearch::load()
36 _apps = new DocLnkSet(QPEApplication::documentDir()); 36 _apps = new DocLnkSet(QPEApplication::documentDir());
37} 37}
38 38
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
@@ -16,12 +16,13 @@
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 <qaction.h> 23#include <qaction.h>
23#include <qmessagebox.h> 24#include <qmessagebox.h>
24#include <qpopupmenu.h> 25#include <qpopupmenu.h>
25#include <qtoolbutton.h> 26#include <qtoolbutton.h>
26#include <qstring.h> 27#include <qstring.h>
27#include <qlabel.h> 28#include <qlabel.h>
@@ -81,29 +82,30 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) :
81 searches.append( new AppLnkSearch( resultsList, tr("applications") ) ); 82 searches.append( new AppLnkSearch( resultsList, tr("applications") ) );
82 searches.append( new DocLnkSearch( resultsList, tr("documents") ) ); 83 searches.append( new DocLnkSearch( resultsList, tr("documents") ) );
83 searches.append( new TodoSearch( resultsList, tr("todo") ) ); 84 searches.append( new TodoSearch( resultsList, tr("todo") ) );
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();
91 searchTimer = new QTimer(); 91 searchTimer = new QTimer();
92 92
93 connect(popupTimer, SIGNAL(timeout()), SLOT(showPopup())); 93 connect(popupTimer, SIGNAL(timeout()), SLOT(showPopup()));
94 connect(searchTimer, SIGNAL(timeout()), SLOT(searchStringChanged())); 94 connect(searchTimer, SIGNAL(timeout()), SLOT(searchStringChanged()));
95 connect(resultsList, SIGNAL(pressed(QListViewItem*)), SLOT(setCurrent(QListViewItem*))); 95 connect(resultsList, SIGNAL(pressed(QListViewItem*)), SLOT(setCurrent(QListViewItem*)));
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()
107{ 109{
108 QPEToolBar *toolBar = new QPEToolBar( this ); 110 QPEToolBar *toolBar = new QPEToolBar( this );
109 QPEToolBar *searchBar = new QPEToolBar(this); 111 QPEToolBar *searchBar = new QPEToolBar(this);
@@ -114,23 +116,37 @@ void MainWindow::makeMenu()
114 QPopupMenu *searchOptions = new QPopupMenu( cfgMenu ); 116 QPopupMenu *searchOptions = new QPopupMenu( cfgMenu );
115 117
116 setToolBarsMovable( false ); 118 setToolBarsMovable( false );
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
124 SearchAllAction = new QAction( tr("Search all"),QString::null, 0, this, 0 ); 137 SearchAllAction = new QAction( tr("Search all"),QString::null, 0, this, 0 );
125 SearchAllAction->setIconSet( Resource::loadIconSet( "find" ) ); 138 SearchAllAction->setIconSet( Resource::loadIconSet( "find" ) );
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 );
134 actionWildcards->addTo( searchOptions ); 150 actionWildcards->addTo( searchOptions );
135 151
136 //SEARCH BAR 152 //SEARCH BAR
@@ -148,12 +164,13 @@ void MainWindow::makeMenu()
148MainWindow::~MainWindow() 164MainWindow::~MainWindow()
149{ 165{
150 Config cfg( "osearch", Config::User ); 166 Config cfg( "osearch", Config::User );
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)
157{ 174{
158 if (!item) return; 175 if (!item) return;
159 _currentItem = (OListViewItem*)item; 176 _currentItem = (OListViewItem*)item;
@@ -179,59 +196,69 @@ void MainWindow::setCurrent(QListViewItem *item)
179 for (uint i = acts.count(); i < _buttonCount; i++){ 196 for (uint i = acts.count(); i < _buttonCount; i++){
180 qDebug("remove button %i of %i",i, _buttonCount); 197 qDebug("remove button %i of %i",i, _buttonCount);
181 button = buttonGroupActions->find( i ); 198 button = buttonGroupActions->find( i );
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*)
196{ 208{
197 popupTimer->stop(); 209 popupTimer->stop();
198} 210}
199 211
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 )
207{ 222{
208 searchTimer->stop(); 223 searchTimer->stop();
209 _searchString = key; 224 _searchString = key;
210 searchTimer->start( 300 ); 225 searchTimer->start( 300 );
211} 226}
212 227
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}
220 242
221void MainWindow::searchAll() 243void MainWindow::searchAll()
222{ 244{
223 for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ){ 245 for (SearchGroup *s = searches.first(); s != 0; s = searches.next() ){
224 s->doSearch(); 246 s->doSearch();
225 //resultsList->repaint(); 247 //resultsList->repaint();
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;
233 // ResultItem *res = dynamic_cast<ResultItem*>(item); 255 // ResultItem *res = dynamic_cast<ResultItem*>(item);
234 res->action(act); 256 res->action(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
@@ -48,12 +48,13 @@ public slots:
48 48
49protected slots: 49protected slots:
50 void slotAction(int); 50 void slotAction(int);
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;
57 QTextView *richEdit; 58 QTextView *richEdit;
58 OListViewItem *_currentItem; 59 OListViewItem *_currentItem;
59 QVBoxLayout *mainLayout; 60 QVBoxLayout *mainLayout;
@@ -65,12 +66,13 @@ private:
65 QString _searchString; 66 QString _searchString;
66 QList<SearchGroup> searches; 67 QList<SearchGroup> searches;
67 QHButtonGroup *buttonGroupActions; 68 QHButtonGroup *buttonGroupActions;
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};
74 76
75#endif 77#endif
76 78
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
@@ -25,6 +25,17 @@ OListViewItem::OListViewItem(QListView *parent, QString name)
25} 25}
26 26
27OListViewItem::~OListViewItem() 27OListViewItem::~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
@@ -21,9 +21,12 @@ public:
21 OListViewItem(OListViewItem *parent, QString name); 21 OListViewItem(OListViewItem *parent, QString name);
22 OListViewItem(QListView *parent, QString name); 22 OListViewItem(QListView *parent, QString name);
23 ~OListViewItem(); 23 ~OListViewItem();
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
@@ -10,17 +10,22 @@
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" 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{
24 _name = name; 29 _name = name;
25 loaded = false; 30 loaded = false;
26} 31}
@@ -46,42 +51,43 @@ void SearchGroup::expand()
46} 51}
47 52
48void SearchGroup::doSearch() 53void 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();
73 else new OListViewItem( this, "searching..."); 67 else new OListViewItem( this, "searching...");
74} 68}
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
@@ -13,39 +13,36 @@
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
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
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// 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};
50 47
51#endif 48#endif
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
@@ -11,29 +11,41 @@
11// 11//
12// 12//
13#include "todosearch.h" 13#include "todosearch.h"
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
37 49
38void TodoSearch::load() 50void TodoSearch::load()
39{ 51{
@@ -42,14 +54,27 @@ void TodoSearch::load()
42} 54}
43 55
44int TodoSearch::search() 56int 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
@@ -13,27 +13,31 @@
13#ifndef TODOSEARCH_H 13#ifndef TODOSEARCH_H
14#define TODOSEARCH_H 14#define TODOSEARCH_H
15 15
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
22*/ 23*/
23class TodoSearch : public SearchGroup 24class 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();
33 virtual void insertItem( void* ); 35 virtual void insertItem( void* );
34 36
35private: 37private:
36 OTodoAccess *_todos; 38 OTodoAccess *_todos;
39 QAction *actionShowCompleted;
40 QPopupMenu *_popupMenu;
37}; 41};
38 42
39#endif 43#endif