author | tille <tille> | 2003-05-15 13:55:07 (UTC) |
---|---|---|
committer | tille <tille> | 2003-05-15 13:55:07 (UTC) |
commit | 80e9fd1b08a3a7173ecf443b2830df4ca6e83ce6 (patch) (unidiff) | |
tree | 4245ef4caf67784b452b908a9528ae03f988bf4c /core/pim | |
parent | ded2a7a5715af1d1f6aab0b79ba90d8a815a9adc (diff) | |
download | opie-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
-rw-r--r-- | core/pim/osearch/applnksearch.cpp | 5 | ||||
-rw-r--r-- | core/pim/osearch/contactitem.cpp | 4 | ||||
-rw-r--r-- | core/pim/osearch/datebooksearch.cpp | 53 | ||||
-rw-r--r-- | core/pim/osearch/datebooksearch.h | 8 | ||||
-rw-r--r-- | core/pim/osearch/doclnksearch.cpp | 1 | ||||
-rw-r--r-- | core/pim/osearch/mainwindow.cpp | 45 | ||||
-rw-r--r-- | core/pim/osearch/mainwindow.h | 2 | ||||
-rw-r--r-- | core/pim/osearch/olistviewitem.cpp | 11 | ||||
-rw-r--r-- | core/pim/osearch/olistviewitem.h | 3 | ||||
-rw-r--r-- | core/pim/osearch/searchgroup.cpp | 50 | ||||
-rw-r--r-- | core/pim/osearch/searchgroup.h | 9 | ||||
-rw-r--r-- | core/pim/osearch/todosearch.cpp | 37 | ||||
-rw-r--r-- | core/pim/osearch/todosearch.h | 6 |
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 | |||
@@ -40,25 +40,24 @@ void AppLnkSearch::load() | |||
40 | } | 40 | } |
41 | 41 | ||
42 | int AppLnkSearch::search() | 42 | int 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 | ||
58 | void AppLnkSearch::insertItem( void *rec ) | 56 | void AppLnkSearch::insertItem( void *rec ) |
59 | { | 57 | { |
60 | new AppLnkItem( this, (AppLnk*)rec ); | 58 | new AppLnkItem( this, (AppLnk*)rec ); |
59 | _resultCount++; | ||
61 | } | 60 | } |
62 | 61 | ||
63 | void AppLnkSearch::setSearch(QRegExp re) | 62 | void AppLnkSearch::setSearch(QRegExp re) |
64 | { | 63 | { |
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 | |||
@@ -69,16 +69,16 @@ void ContactItem::setIcon() | |||
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: |
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 | |||
@@ -13,26 +13,42 @@ | |||
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 | ||
22 | DatebookSearch::DatebookSearch(QListView* parent, QString name) | 27 | DatebookSearch::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 | |||
32 | DatebookSearch::~DatebookSearch() | 40 | DatebookSearch::~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 | ||
38 | void DatebookSearch::load() | 54 | void DatebookSearch::load() |
@@ -44,12 +60,33 @@ void DatebookSearch::load() | |||
44 | int DatebookSearch::search() | 60 | 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 | ||
52 | void DatebookSearch::insertItem( void* ) | 68 | void 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 | ||
83 | QPopupMenu* 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 | |||
@@ -15,26 +15,30 @@ | |||
15 | 15 | ||
16 | #include "searchgroup.h" | 16 | #include "searchgroup.h" |
17 | 17 | ||
18 | class ODateBookAccess; | 18 | class ODateBookAccess; |
19 | class QAction; | ||
19 | 20 | ||
20 | /** | 21 | /** |
21 | @author Patrick S. Vogt | 22 | @author Patrick S. Vogt |
22 | */ | 23 | */ |
23 | class DatebookSearch : public SearchGroup | 24 | class DatebookSearch : public SearchGroup |
24 | { | 25 | { |
25 | public: | 26 | 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 | |||
30 | protected: | 32 | protected: |
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 | ||
35 | private: | 37 | private: |
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 | |||
@@ -38,5 +38,6 @@ void DocLnkSearch::load() | |||
38 | 38 | ||
39 | void DocLnkSearch::insertItem( void *rec ) | 39 | void 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 | |||
@@ -18,8 +18,9 @@ | |||
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> |
@@ -83,9 +84,8 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : | |||
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(); |
@@ -95,13 +95,15 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f ) : | |||
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 | ||
106 | void MainWindow::makeMenu() | 108 | void MainWindow::makeMenu() |
107 | { | 109 | { |
@@ -116,19 +118,33 @@ void MainWindow::makeMenu() | |||
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 ); |
@@ -150,8 +166,9 @@ MainWindow::~MainWindow() | |||
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 | ||
156 | void MainWindow::setCurrent(QListViewItem *item) | 173 | void MainWindow::setCurrent(QListViewItem *item) |
157 | { | 174 | { |
@@ -181,16 +198,11 @@ void MainWindow::setCurrent(QListViewItem *item) | |||
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 | ||
195 | void MainWindow::stopTimer(QListViewItem*) | 207 | void MainWindow::stopTimer(QListViewItem*) |
196 | { | 208 | { |
@@ -199,9 +211,12 @@ void MainWindow::stopTimer(QListViewItem*) | |||
199 | 211 | ||
200 | void MainWindow::showPopup() | 212 | void 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 | ||
206 | void MainWindow::setSearch( const QString &key ) | 221 | void MainWindow::setSearch( const QString &key ) |
207 | { | 222 | { |
@@ -212,9 +227,16 @@ void MainWindow::setSearch( const QString &key ) | |||
212 | 227 | ||
213 | void MainWindow::searchStringChanged() | 228 | void 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 | ||
@@ -225,13 +247,18 @@ void MainWindow::searchAll() | |||
225 | //resultsList->repaint(); | 247 | //resultsList->repaint(); |
226 | } | 248 | } |
227 | } | 249 | } |
228 | 250 | ||
229 | void MainWindow::slotAction( int act) | 251 | void 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 | ||
260 | void 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 | |||
@@ -50,8 +50,9 @@ protected 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 | ||
55 | private: | 56 | private: |
56 | OListView *resultsList; | 57 | OListView *resultsList; |
57 | QTextView *richEdit; | 58 | QTextView *richEdit; |
@@ -67,8 +68,9 @@ private: | |||
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 | ||
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 | |||
@@ -27,4 +27,15 @@ OListViewItem::OListViewItem(QListView *parent, QString name) | |||
27 | OListViewItem::~OListViewItem() | 27 | OListViewItem::~OListViewItem() |
28 | { | 28 | { |
29 | } | 29 | } |
30 | 30 | ||
31 | void 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 | |||
@@ -23,7 +23,10 @@ public: | |||
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 | |||
@@ -12,13 +12,18 @@ | |||
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 | ||
23 | static OWait *wait = 0; | ||
24 | #endif | ||
25 | |||
21 | SearchGroup::SearchGroup(QListView* parent, QString name) | 26 | SearchGroup::SearchGroup(QListView* parent, QString name) |
22 | : OListViewItem(parent, name) | 27 | : OListViewItem(parent, name) |
23 | { | 28 | { |
24 | _name = name; | 29 | _name = name; |
@@ -48,40 +53,41 @@ void SearchGroup::expand() | |||
48 | void SearchGroup::doSearch() | 53 | 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 | ||
57 | void 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 | |||
68 | void SearchGroup::setSearch(QRegExp re) | 61 | void 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 | ||
76 | int SearchGroup::realSearch() | 70 | 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 | } |
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 | |||
@@ -15,15 +15,15 @@ | |||
15 | 15 | ||
16 | #include "olistviewitem.h" | 16 | #include "olistviewitem.h" |
17 | 17 | ||
18 | class QRegExp; | 18 | class QRegExp; |
19 | class QPopupMenu; | ||
19 | 20 | ||
20 | /** | 21 | /** |
21 | @author Patrick S. Vogt | 22 | @author Patrick S. Vogt |
22 | */ | 23 | */ |
23 | class SearchGroup : public OListViewItem //, QObject | 24 | class SearchGroup : public OListViewItem |
24 | { | 25 | { |
25 | //Q_OBJECT | ||
26 | public: | 26 | public: |
27 | SearchGroup(QListView* parent, QString name); | 27 | SearchGroup(QListView* parent, QString name); |
28 | 28 | ||
29 | ~SearchGroup(); | 29 | ~SearchGroup(); |
@@ -32,19 +32,16 @@ public: | |||
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 | |||
39 | protected: | 36 | protected: |
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; | ||
47 | private: | 44 | private: |
48 | int realSearch(); | 45 | int realSearch(); |
49 | }; | 46 | }; |
50 | 47 | ||
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 | |||
@@ -13,25 +13,37 @@ | |||
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 | ||
21 | TodoSearch::TodoSearch(QListView* parent, QString name) | 24 | TodoSearch::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 | ||
32 | TodoSearch::~TodoSearch() | 39 | 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; |
35 | } | 47 | } |
36 | 48 | ||
37 | 49 | ||
@@ -44,12 +56,25 @@ void TodoSearch::load() | |||
44 | int TodoSearch::search() | 56 | 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 | ||
52 | void TodoSearch::insertItem( void* ) | 64 | void 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 | ||
73 | QPopupMenu* 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 | |||
@@ -15,25 +15,29 @@ | |||
15 | 15 | ||
16 | #include "searchgroup.h" | 16 | #include "searchgroup.h" |
17 | 17 | ||
18 | class OTodoAccess; | 18 | class OTodoAccess; |
19 | class QAction; | ||
19 | 20 | ||
20 | /** | 21 | /** |
21 | @author Patrick S. Vogt | 22 | @author Patrick S. Vogt |
22 | */ | 23 | */ |
23 | class TodoSearch : public SearchGroup | 24 | class TodoSearch : public SearchGroup |
24 | { | 25 | { |
25 | public: | 26 | 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 | |||
30 | protected: | 32 | protected: |
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 | ||
35 | private: | 37 | private: |
36 | OTodoAccess *_todos; | 38 | OTodoAccess *_todos; |
39 | QAction *actionShowCompleted; | ||
40 | QPopupMenu *_popupMenu; | ||
37 | }; | 41 | }; |
38 | 42 | ||
39 | #endif | 43 | #endif |