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
@@ -43,3 +43,2 @@ int AppLnkSearch::search()
43{ 43{
44 int count = 0;
45 QList<AppLnk> appList = _apps->children(); 44 QList<AppLnk> appList = _apps->children();
@@ -49,3 +48,2 @@ int AppLnkSearch::search()
49 || (_search.match(app->exec()) != -1) ) { 48 || (_search.match(app->exec()) != -1) ) {
50 count++;
51 insertItem( app ); 49 insertItem( app );
@@ -54,3 +52,3 @@ int AppLnkSearch::search()
54 } 52 }
55 return count; 53 return _resultCount;
56} 54}
@@ -60,2 +58,3 @@ void AppLnkSearch::insertItem( void *rec )
60 new AppLnkItem( this, (AppLnk*)rec ); 58 new AppLnkItem( this, (AppLnk*)rec );
59 _resultCount++;
61} 60}
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
@@ -72,3 +72,3 @@ void ContactItem::setIcon()
72 case Qtopia::FileAs: 72 case Qtopia::FileAs:
73 icon = Resource::loadPixmap( "addressbook/identity" ); 73 icon = Resource::loadPixmap( "osearch/identity" );
74 break; 74 break;
@@ -79,3 +79,3 @@ void ContactItem::setIcon()
79 case Qtopia::HomeCountry: 79 case Qtopia::HomeCountry:
80 icon = Resource::loadPixmap( "addressbook/addresshome" ); 80 icon = Resource::loadPixmap( "osearch/addresshome" );
81 break; 81 break;
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
@@ -16,20 +16,36 @@
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}
@@ -47,9 +63,30 @@ int DatebookSearch::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
@@ -18,2 +18,3 @@
18class ODateBookAccess; 18class ODateBookAccess;
19class QAction;
19 20
@@ -26,5 +27,6 @@ public:
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:
@@ -36,3 +38,5 @@ private:
36 ODateBookAccess *_dates; 38 ODateBookAccess *_dates;
37 39 QAction *actionShowPastEvents;
40 QAction *actionSearchInDates;
41 QPopupMenu *_popupMenu;
38}; 42};
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
@@ -41,2 +41,3 @@ void DocLnkSearch::insertItem( void *rec )
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
@@ -21,2 +21,3 @@
21#include <qpe/config.h> 21#include <qpe/config.h>
22#include <qpe/global.h>
22#include <qaction.h> 23#include <qaction.h>
@@ -86,3 +87,2 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) :
86 87
87 makeMenu();
88 setCentralWidget( mainFrame ); 88 setCentralWidget( mainFrame );
@@ -98,2 +98,3 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) :
98 98
99 makeMenu();
99 100
@@ -103,2 +104,3 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) :
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}
@@ -119,3 +121,14 @@ void MainWindow::makeMenu()
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
@@ -128,4 +141,7 @@ void MainWindow::makeMenu()
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 );
@@ -153,2 +169,3 @@ MainWindow::~MainWindow()
153 cfg.writeEntry( "wildcards", actionWildcards->isOn() ); 169 cfg.writeEntry( "wildcards", actionWildcards->isOn() );
170 //cfg.writeEntry( "whole_words_only", actionWholeWordsOnly->isOn() );
154} 171}
@@ -184,10 +201,5 @@ void MainWindow::setCurrent(QListViewItem *item)
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}
@@ -202,3 +214,6 @@ void MainWindow::showPopup()
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}
@@ -215,3 +230,10 @@ void MainWindow::searchStringChanged()
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() )
@@ -228,3 +250,3 @@ void MainWindow::searchAll()
228 250
229void MainWindow::slotAction( int act) 251void MainWindow::slotAction( int act )
230{ 252{
@@ -237 +259,6 @@ void MainWindow::slotAction( int act)
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
@@ -53,2 +53,3 @@ protected slots:
53 void searchStringChanged(); 53 void searchStringChanged();
54 void optionChanged(int);
54 55
@@ -70,2 +71,3 @@ private:
70 QAction *actionWildcards; 71 QAction *actionWildcards;
72 //QAction *actionWholeWordsOnly;
71 uint _buttonCount; 73 uint _buttonCount;
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
@@ -30 +30,12 @@ OListViewItem::~OListViewItem()
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
@@ -26,2 +26,5 @@ public:
26 virtual int rtti() { return Raw;} 26 virtual int rtti() { return Raw;}
27 virtual QPopupMenu* popupMenu() { return 0;};
28 void clearList();
29
27}; 30};
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
@@ -15,4 +15,4 @@
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
@@ -20,2 +20,7 @@
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)
@@ -51,4 +56,3 @@ void SearchGroup::doSearch()
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();
@@ -56,15 +60,5 @@ void SearchGroup::doSearch()
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() );
@@ -77,10 +71,22 @@ int 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}
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
@@ -18,2 +18,3 @@
18class QRegExp; 18class QRegExp;
19class QPopupMenu;
19 20
@@ -22,5 +23,4 @@ class QRegExp;
22*/ 23*/
23class SearchGroup : public OListViewItem //, QObject 24class SearchGroup : public OListViewItem
24{ 25{
25//Q_OBJECT
26public: 26public:
@@ -35,5 +35,2 @@ public:
35 35
36// signals:
37 // isSearching(QString);
38
39protected: 36protected:
@@ -43,5 +40,5 @@ protected:
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:
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
@@ -16,4 +16,7 @@
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"
@@ -21,5 +24,4 @@
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());
@@ -28,2 +30,7 @@ TodoSearch::TodoSearch(QListView* parent, QString name)
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}
@@ -33,2 +40,7 @@ TodoSearch::~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;
@@ -47,9 +59,22 @@ int TodoSearch::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
@@ -18,2 +18,3 @@
18class OTodoAccess; 18class OTodoAccess;
19class QAction;
19 20
@@ -26,5 +27,6 @@ public:
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:
@@ -36,2 +38,4 @@ private:
36 OTodoAccess *_todos; 38 OTodoAccess *_todos;
39 QAction *actionShowCompleted;
40 QPopupMenu *_popupMenu;
37}; 41};