-rw-r--r-- | korganizer/searchdialog.cpp | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/korganizer/searchdialog.cpp b/korganizer/searchdialog.cpp index 59bf1a2..ef2fc1c 100644 --- a/korganizer/searchdialog.cpp +++ b/korganizer/searchdialog.cpp | |||
@@ -10,106 +10,111 @@ | |||
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | As a special exception, permission is given to link this program | 20 | As a special exception, permission is given to link this program |
21 | with any edition of Qt, and distribute the resulting executable, | 21 | with any edition of Qt, and distribute the resulting executable, |
22 | without including the source code for Qt in the source distribution. | 22 | without including the source code for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include <qlayout.h> | 25 | #include <qlayout.h> |
26 | #include <qcheckbox.h> | 26 | #include <qcheckbox.h> |
27 | #include <qgroupbox.h> | 27 | #include <qgroupbox.h> |
28 | #include <qlabel.h> | 28 | #include <qlabel.h> |
29 | #include <qlistview.h> | 29 | #include <qlistview.h> |
30 | #include <qwhatsthis.h> | 30 | #include <qwhatsthis.h> |
31 | #include <qlineedit.h> | 31 | #include <qlineedit.h> |
32 | #include <qpushbutton.h> | 32 | #include <qpushbutton.h> |
33 | 33 | ||
34 | #include <klocale.h> | 34 | #include <klocale.h> |
35 | #include <kmessagebox.h> | 35 | #include <kmessagebox.h> |
36 | 36 | ||
37 | #include <libkdepim/kdateedit.h> | 37 | #include <libkdepim/kdateedit.h> |
38 | 38 | ||
39 | #include "koglobals.h" | 39 | #include "koglobals.h" |
40 | #include "koprefs.h" | 40 | #include "koprefs.h" |
41 | #include "klineedit.h" | 41 | #include "klineedit.h" |
42 | 42 | ||
43 | #include "calendarview.h" | 43 | #include "calendarview.h" |
44 | #include "koviewmanager.h" | 44 | #include "koviewmanager.h" |
45 | #include "searchdialog.h" | 45 | #include "searchdialog.h" |
46 | 46 | ||
47 | SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent) | 47 | SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent) |
48 | : QVBox( 0 ) | 48 | : QVBox( 0 ) |
49 | 49 | ||
50 | { | 50 | { |
51 | mCalendar = calendar; | 51 | mCalendar = calendar; |
52 | QFrame *topFrame = new QFrame( this ) ;//plainPage(); | 52 | QFrame *topFrame = new QFrame( this ) ;//plainPage(); |
53 | QVBoxLayout *layout = new QVBoxLayout(topFrame,KDialog::marginHint(),KDialog::spacingHint()); | 53 | QVBoxLayout *layout = new QVBoxLayout(topFrame,KDialog::marginHint(),KDialog::spacingHint()); |
54 | 54 | ||
55 | // Search expression | 55 | // Search expression |
56 | QHBoxLayout *subLayout = new QHBoxLayout(); | 56 | QHBoxLayout *subLayout = new QHBoxLayout(); |
57 | layout->addLayout(subLayout); | 57 | layout->addLayout(subLayout); |
58 | /* | ||
58 | searchLabel = new QLabel(topFrame); | 59 | searchLabel = new QLabel(topFrame); |
59 | searchLabel->setText(i18n("Search for:")); | 60 | searchLabel->setText(i18n("Search for:")); |
60 | subLayout->addWidget(searchLabel); | 61 | subLayout->addWidget(searchLabel); |
61 | 62 | */ | |
62 | searchEdit = new KLineEdit(topFrame); | 63 | QPushButton *OkButton = new QPushButton( i18n("Search for:"), topFrame ); |
63 | subLayout->addWidget(searchEdit); | ||
64 | QPushButton *OkButton = new QPushButton( i18n("&Find"), topFrame ); | ||
65 | //OkButton->setDefault( true ); | 64 | //OkButton->setDefault( true ); |
66 | connect(OkButton,SIGNAL(clicked()),SLOT(doSearch())); | 65 | connect(OkButton,SIGNAL(clicked()),SLOT(doSearch())); |
67 | subLayout->addWidget(OkButton); | 66 | subLayout->addWidget(OkButton); |
67 | searchEdit = new KLineEdit(topFrame); | ||
68 | subLayout->addWidget(searchEdit); | ||
69 | |||
70 | mAddItems = new QCheckBox(i18n("Add items"),topFrame); | ||
71 | subLayout->addWidget(mAddItems); | ||
72 | |||
68 | searchEdit->setText("*"); // Find all events by default | 73 | searchEdit->setText("*"); // Find all events by default |
69 | searchEdit->setFocus(); | 74 | searchEdit->setFocus(); |
70 | connect(searchEdit, SIGNAL(textChanged ( const QString & )),this,SLOT(searchTextChanged( const QString & ))); | 75 | connect(searchEdit, SIGNAL(textChanged ( const QString & )),this,SLOT(searchTextChanged( const QString & ))); |
71 | connect(searchEdit, SIGNAL( returnPressed () ),this,SLOT(doSearch())); | 76 | connect(searchEdit, SIGNAL( returnPressed () ),this,SLOT(doSearch())); |
72 | // Subjects to search | 77 | // Subjects to search |
73 | // QGroupBox *subjectGroup = new QGroupBox(1,Vertical,i18n("Search In"), | 78 | // QGroupBox *subjectGroup = new QGroupBox(1,Vertical,i18n("Search In"), |
74 | // topFrame); | 79 | // topFrame); |
75 | 80 | ||
76 | QHBox *incidenceGroup = new QHBox( topFrame ); | 81 | QHBox *incidenceGroup = new QHBox( topFrame ); |
77 | layout->addWidget(incidenceGroup); | 82 | layout->addWidget(incidenceGroup); |
78 | 83 | ||
79 | mSearchEvent = new QCheckBox(i18n("Events"),incidenceGroup); | 84 | mSearchEvent = new QCheckBox(i18n("Events"),incidenceGroup); |
80 | //mSearchEvent->setChecked(true); | 85 | //mSearchEvent->setChecked(true); |
81 | mSearchTodo = new QCheckBox(i18n("Todos"),incidenceGroup); | 86 | mSearchTodo = new QCheckBox(i18n("Todos"),incidenceGroup); |
82 | mSearchJournal = new QCheckBox(i18n("Journals"),incidenceGroup); | 87 | mSearchJournal = new QCheckBox(i18n("Journals"),incidenceGroup); |
83 | 88 | ||
84 | QHBox *subjectGroup = new QHBox( topFrame ); | 89 | QHBox *subjectGroup = new QHBox( topFrame ); |
85 | layout->addWidget(subjectGroup); | 90 | layout->addWidget(subjectGroup); |
86 | 91 | ||
87 | mSummaryCheck = new QCheckBox(i18n("Summary/Loc."),subjectGroup); | 92 | mSummaryCheck = new QCheckBox(i18n("Summary/Loc."),subjectGroup); |
88 | mSummaryCheck->setChecked(true); | 93 | mSummaryCheck->setChecked(true); |
89 | mDescriptionCheck = new QCheckBox(i18n("Details"),subjectGroup); | 94 | mDescriptionCheck = new QCheckBox(i18n("Details"),subjectGroup); |
90 | mCategoryCheck = new QCheckBox(i18n("Categories"),subjectGroup); | 95 | mCategoryCheck = new QCheckBox(i18n("Categories"),subjectGroup); |
91 | 96 | ||
92 | QHBox *attendeeGroup = new QHBox( topFrame ); | 97 | QHBox *attendeeGroup = new QHBox( topFrame ); |
93 | layout->addWidget(attendeeGroup ); | 98 | layout->addWidget(attendeeGroup ); |
94 | new QLabel( i18n("Attendee:"),attendeeGroup ); | 99 | new QLabel( i18n("Attendee:"),attendeeGroup ); |
95 | mSearchAName = new QCheckBox(i18n("Name"),attendeeGroup ); | 100 | mSearchAName = new QCheckBox(i18n("Name"),attendeeGroup ); |
96 | mSearchAEmail = new QCheckBox(i18n("Email"), attendeeGroup ); | 101 | mSearchAEmail = new QCheckBox(i18n("Email"), attendeeGroup ); |
97 | // Date range | 102 | // Date range |
98 | // QGroupBox *rangeGroup = new QGroupBox(1,Horizontal,i18n("Date Range"), | 103 | // QGroupBox *rangeGroup = new QGroupBox(1,Horizontal,i18n("Date Range"), |
99 | // topFrame); | 104 | // topFrame); |
100 | // layout->addWidget(rangeGroup); | 105 | // layout->addWidget(rangeGroup); |
101 | 106 | ||
102 | QWidget *rangeWidget = new QWidget(topFrame); | 107 | QWidget *rangeWidget = new QWidget(topFrame); |
103 | QHBoxLayout *rangeLayout = new QHBoxLayout(rangeWidget,0,KDialog::spacingHint()); | 108 | QHBoxLayout *rangeLayout = new QHBoxLayout(rangeWidget,0,KDialog::spacingHint()); |
104 | rangeLayout->addWidget(new QLabel(i18n("From:"),rangeWidget)); | 109 | rangeLayout->addWidget(new QLabel(i18n("From:"),rangeWidget)); |
105 | mStartDate = new KDateEdit(rangeWidget); | 110 | mStartDate = new KDateEdit(rangeWidget); |
106 | rangeLayout->addWidget(mStartDate); | 111 | rangeLayout->addWidget(mStartDate); |
107 | rangeLayout->addWidget(new QLabel(i18n("To:"),rangeWidget)); | 112 | rangeLayout->addWidget(new QLabel(i18n("To:"),rangeWidget)); |
108 | mEndDate = new KDateEdit(rangeWidget); | 113 | mEndDate = new KDateEdit(rangeWidget); |
109 | mEndDate->setDate(QDate::currentDate().addDays(365)); | 114 | mEndDate->setDate(QDate::currentDate().addDays(365)); |
110 | rangeLayout->addWidget(mEndDate); | 115 | rangeLayout->addWidget(mEndDate); |
111 | QToolButton *wt = QWhatsThis::whatsThisButton ( rangeWidget ); | 116 | QToolButton *wt = QWhatsThis::whatsThisButton ( rangeWidget ); |
112 | rangeLayout->addWidget( (QWidget*)wt ); | 117 | rangeLayout->addWidget( (QWidget*)wt ); |
113 | layout->addWidget(rangeWidget); | 118 | layout->addWidget(rangeWidget); |
114 | // Results list view | 119 | // Results list view |
115 | listView = new KOListView(mCalendar,topFrame); | 120 | listView = new KOListView(mCalendar,topFrame); |
@@ -227,238 +232,240 @@ void SearchDialog::doSearch() | |||
227 | } | 232 | } |
228 | search(re); | 233 | search(re); |
229 | listView->setStartDate( mStartDate->date() ); | 234 | listView->setStartDate( mStartDate->date() ); |
230 | listView->showEvents(mMatchedEvents); | 235 | listView->showEvents(mMatchedEvents); |
231 | listView->addTodos(mMatchedTodos); | 236 | listView->addTodos(mMatchedTodos); |
232 | listView->addJournals(mMatchedJournals); | 237 | listView->addJournals(mMatchedJournals); |
233 | if (mMatchedEvents.count() + mMatchedJournals.count() + mMatchedTodos.count() == 0) { | 238 | if (mMatchedEvents.count() + mMatchedJournals.count() + mMatchedTodos.count() == 0) { |
234 | setCaption(i18n("No items found. Use '*' and '?' where needed.")); | 239 | setCaption(i18n("No items found. Use '*' and '?' where needed.")); |
235 | } else { | 240 | } else { |
236 | QString mess; | 241 | QString mess; |
237 | mess = mess.sprintf( i18n("%d item(s) found."), mMatchedEvents.count()+ mMatchedJournals.count() + mMatchedTodos.count() ); | 242 | mess = mess.sprintf( i18n("%d item(s) found."), mMatchedEvents.count()+ mMatchedJournals.count() + mMatchedTodos.count() ); |
238 | setCaption( i18n("KO/Pi Find: ") + mess); | 243 | setCaption( i18n("KO/Pi Find: ") + mess); |
239 | 244 | ||
240 | } | 245 | } |
241 | searchEdit->setFocus(); | 246 | searchEdit->setFocus(); |
242 | } | 247 | } |
243 | void SearchDialog::updateConfig() | 248 | void SearchDialog::updateConfig() |
244 | { | 249 | { |
245 | listView->updateConfig(); | 250 | listView->updateConfig(); |
246 | } | 251 | } |
247 | void SearchDialog::updateView() | 252 | void SearchDialog::updateView() |
248 | { | 253 | { |
249 | //qDebug("SearchDialog::updateView() %d ", isVisible()); | 254 | //qDebug("SearchDialog::updateView() %d ", isVisible()); |
250 | QRegExp re; | 255 | QRegExp re; |
251 | re.setWildcard(true); // most people understand these better. | 256 | re.setWildcard(true); // most people understand these better. |
252 | re.setCaseSensitive(false); | 257 | re.setCaseSensitive(false); |
253 | QString st = searchEdit->text(); | 258 | QString st = searchEdit->text(); |
254 | if ( st.right(1) != "*") | 259 | if ( st.right(1) != "*") |
255 | st += "*"; | 260 | st += "*"; |
256 | re.setPattern(st); | 261 | re.setPattern(st); |
257 | if (re.isValid()) { | 262 | if (re.isValid()) { |
258 | search(re); | 263 | search(re); |
259 | } else { | 264 | } else { |
260 | mMatchedEvents.clear(); | 265 | mMatchedEvents.clear(); |
261 | mMatchedTodos.clear(); | 266 | mMatchedTodos.clear(); |
262 | mMatchedJournals.clear(); | 267 | mMatchedJournals.clear(); |
263 | } | 268 | } |
264 | listView->setStartDate( mStartDate->date() ); | 269 | listView->setStartDate( mStartDate->date() ); |
265 | listView->showEvents(mMatchedEvents); | 270 | listView->showEvents(mMatchedEvents); |
266 | listView->addTodos(mMatchedTodos); | 271 | listView->addTodos(mMatchedTodos); |
267 | listView->addJournals(mMatchedJournals); | 272 | listView->addJournals(mMatchedJournals); |
268 | } | 273 | } |
269 | 274 | ||
270 | void SearchDialog::search(const QRegExp &re) | 275 | void SearchDialog::search(const QRegExp &re) |
271 | { | 276 | { |
272 | QPtrList<Event> events = mCalendar->events( mStartDate->date(), | 277 | QPtrList<Event> events = mCalendar->events( mStartDate->date(), |
273 | mEndDate->date(), | 278 | mEndDate->date(), |
274 | false /*mInclusiveCheck->isChecked()*/ ); | 279 | false /*mInclusiveCheck->isChecked()*/ ); |
275 | 280 | if ( !mAddItems->isChecked() ) | |
276 | mMatchedEvents.clear(); | 281 | mMatchedEvents.clear(); |
277 | if ( mSearchEvent->isChecked() ) { | 282 | if ( mSearchEvent->isChecked() ) { |
278 | Event *ev; | 283 | Event *ev; |
279 | for(ev=events.first();ev;ev=events.next()) { | 284 | for(ev=events.first();ev;ev=events.next()) { |
280 | if (mSummaryCheck->isChecked()) { | 285 | if (mSummaryCheck->isChecked()) { |
281 | #if QT_VERSION >= 0x030000 | 286 | #if QT_VERSION >= 0x030000 |
282 | if (re.search(ev->summary()) != -1) | 287 | if (re.search(ev->summary()) != -1) |
283 | #else | 288 | #else |
284 | if (re.match(ev->summary()) != -1) | 289 | if (re.match(ev->summary()) != -1) |
285 | #endif | 290 | #endif |
286 | { | 291 | { |
287 | mMatchedEvents.append(ev); | 292 | mMatchedEvents.append(ev); |
288 | continue; | 293 | continue; |
289 | } | 294 | } |
290 | #if QT_VERSION >= 0x030000 | 295 | #if QT_VERSION >= 0x030000 |
291 | if (re.search(ev->location()) != -1) | 296 | if (re.search(ev->location()) != -1) |
292 | #else | 297 | #else |
293 | if (re.match(ev->location()) != -1) | 298 | if (re.match(ev->location()) != -1) |
294 | #endif | 299 | #endif |
295 | { | 300 | { |
296 | mMatchedEvents.append(ev); | 301 | mMatchedEvents.append(ev); |
297 | continue; | 302 | continue; |
298 | } | 303 | } |
299 | } | 304 | } |
300 | if (mDescriptionCheck->isChecked()) { | 305 | if (mDescriptionCheck->isChecked()) { |
301 | #if QT_VERSION >= 0x030000 | 306 | #if QT_VERSION >= 0x030000 |
302 | if (re.search(ev->description()) != -1) | 307 | if (re.search(ev->description()) != -1) |
303 | #else | 308 | #else |
304 | if (re.match(ev->description()) != -1) | 309 | if (re.match(ev->description()) != -1) |
305 | #endif | 310 | #endif |
306 | { | 311 | { |
307 | mMatchedEvents.append(ev); | 312 | mMatchedEvents.append(ev); |
308 | continue; | 313 | continue; |
309 | } | 314 | } |
310 | } | 315 | } |
311 | if (mCategoryCheck->isChecked()) { | 316 | if (mCategoryCheck->isChecked()) { |
312 | #if QT_VERSION >= 0x030000 | 317 | #if QT_VERSION >= 0x030000 |
313 | if (re.search(ev->categoriesStr()) != -1) | 318 | if (re.search(ev->categoriesStr()) != -1) |
314 | #else | 319 | #else |
315 | if (re.match(ev->categoriesStr()) != -1) | 320 | if (re.match(ev->categoriesStr()) != -1) |
316 | #endif | 321 | #endif |
317 | { | 322 | { |
318 | mMatchedEvents.append(ev); | 323 | mMatchedEvents.append(ev); |
319 | continue; | 324 | continue; |
320 | } | 325 | } |
321 | } | 326 | } |
322 | if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) { | 327 | if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) { |
323 | QPtrList<Attendee> tmpAList = ev->attendees(); | 328 | QPtrList<Attendee> tmpAList = ev->attendees(); |
324 | Attendee *a; | 329 | Attendee *a; |
325 | for (a = tmpAList.first(); a; a = tmpAList.next()) { | 330 | for (a = tmpAList.first(); a; a = tmpAList.next()) { |
326 | if (mSearchAName->isChecked()) { | 331 | if (mSearchAName->isChecked()) { |
327 | #if QT_VERSION >= 0x030000 | 332 | #if QT_VERSION >= 0x030000 |
328 | if (re.search(a->name()) != -1) | 333 | if (re.search(a->name()) != -1) |
329 | #else | 334 | #else |
330 | if (re.match(a->name()) != -1) | 335 | if (re.match(a->name()) != -1) |
331 | #endif | 336 | #endif |
332 | { | 337 | { |
333 | mMatchedEvents.append(ev); | 338 | mMatchedEvents.append(ev); |
334 | break; | 339 | break; |
335 | } | 340 | } |
336 | } | 341 | } |
337 | if (mSearchAEmail->isChecked()) { | 342 | if (mSearchAEmail->isChecked()) { |
338 | #if QT_VERSION >= 0x030000 | 343 | #if QT_VERSION >= 0x030000 |
339 | if (re.search(a->email()) != -1) | 344 | if (re.search(a->email()) != -1) |
340 | #else | 345 | #else |
341 | if (re.match(a->email()) != -1) | 346 | if (re.match(a->email()) != -1) |
342 | #endif | 347 | #endif |
343 | { | 348 | { |
344 | mMatchedEvents.append(ev); | 349 | mMatchedEvents.append(ev); |
345 | break; | 350 | break; |
346 | } | 351 | } |
347 | } | 352 | } |
348 | } | 353 | } |
349 | } | 354 | } |
350 | } | 355 | } |
351 | } | 356 | } |
352 | QPtrList<Todo> todos = mCalendar->todos( ); | 357 | QPtrList<Todo> todos = mCalendar->todos( ); |
353 | mMatchedTodos.clear(); | 358 | if ( !mAddItems->isChecked() ) |
359 | mMatchedTodos.clear(); | ||
354 | if ( mSearchTodo->isChecked() ) { | 360 | if ( mSearchTodo->isChecked() ) { |
355 | Todo *tod; | 361 | Todo *tod; |
356 | for(tod=todos.first();tod;tod=todos.next()) { | 362 | for(tod=todos.first();tod;tod=todos.next()) { |
357 | if (mSummaryCheck->isChecked()) { | 363 | if (mSummaryCheck->isChecked()) { |
358 | #if QT_VERSION >= 0x030000 | 364 | #if QT_VERSION >= 0x030000 |
359 | if (re.search(tod->summary()) != -1) | 365 | if (re.search(tod->summary()) != -1) |
360 | #else | 366 | #else |
361 | if (re.match(tod->summary()) != -1) | 367 | if (re.match(tod->summary()) != -1) |
362 | #endif | 368 | #endif |
363 | { | 369 | { |
364 | mMatchedTodos.append(tod); | 370 | mMatchedTodos.append(tod); |
365 | continue; | 371 | continue; |
366 | } | 372 | } |
367 | } | 373 | } |
368 | if (mDescriptionCheck->isChecked()) { | 374 | if (mDescriptionCheck->isChecked()) { |
369 | #if QT_VERSION >= 0x030000 | 375 | #if QT_VERSION >= 0x030000 |
370 | if (re.search(tod->description()) != -1) | 376 | if (re.search(tod->description()) != -1) |
371 | #else | 377 | #else |
372 | if (re.match(tod->description()) != -1) | 378 | if (re.match(tod->description()) != -1) |
373 | #endif | 379 | #endif |
374 | { | 380 | { |
375 | mMatchedTodos.append(tod); | 381 | mMatchedTodos.append(tod); |
376 | continue; | 382 | continue; |
377 | } | 383 | } |
378 | } | 384 | } |
379 | if (mCategoryCheck->isChecked()) { | 385 | if (mCategoryCheck->isChecked()) { |
380 | #if QT_VERSION >= 0x030000 | 386 | #if QT_VERSION >= 0x030000 |
381 | if (re.search(tod->categoriesStr()) != -1) | 387 | if (re.search(tod->categoriesStr()) != -1) |
382 | #else | 388 | #else |
383 | if (re.match(tod->categoriesStr()) != -1) | 389 | if (re.match(tod->categoriesStr()) != -1) |
384 | #endif | 390 | #endif |
385 | { | 391 | { |
386 | mMatchedTodos.append(tod); | 392 | mMatchedTodos.append(tod); |
387 | continue; | 393 | continue; |
388 | } | 394 | } |
389 | } | 395 | } |
390 | if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) { | 396 | if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) { |
391 | QPtrList<Attendee> tmpAList = tod->attendees(); | 397 | QPtrList<Attendee> tmpAList = tod->attendees(); |
392 | Attendee *a; | 398 | Attendee *a; |
393 | for (a = tmpAList.first(); a; a = tmpAList.next()) { | 399 | for (a = tmpAList.first(); a; a = tmpAList.next()) { |
394 | if (mSearchAName->isChecked()) { | 400 | if (mSearchAName->isChecked()) { |
395 | #if QT_VERSION >= 0x030000 | 401 | #if QT_VERSION >= 0x030000 |
396 | if (re.search(a->name()) != -1) | 402 | if (re.search(a->name()) != -1) |
397 | #else | 403 | #else |
398 | if (re.match(a->name()) != -1) | 404 | if (re.match(a->name()) != -1) |
399 | #endif | 405 | #endif |
400 | { | 406 | { |
401 | mMatchedTodos.append(tod); | 407 | mMatchedTodos.append(tod); |
402 | break; | 408 | break; |
403 | } | 409 | } |
404 | } | 410 | } |
405 | if (mSearchAEmail->isChecked()) { | 411 | if (mSearchAEmail->isChecked()) { |
406 | #if QT_VERSION >= 0x030000 | 412 | #if QT_VERSION >= 0x030000 |
407 | if (re.search(a->email()) != -1) | 413 | if (re.search(a->email()) != -1) |
408 | #else | 414 | #else |
409 | if (re.match(a->email()) != -1) | 415 | if (re.match(a->email()) != -1) |
410 | #endif | 416 | #endif |
411 | { | 417 | { |
412 | mMatchedTodos.append(tod); | 418 | mMatchedTodos.append(tod); |
413 | break; | 419 | break; |
414 | } | 420 | } |
415 | } | 421 | } |
416 | } | 422 | } |
417 | } | 423 | } |
418 | } | 424 | } |
419 | } | 425 | } |
420 | mMatchedJournals.clear(); | 426 | if ( !mAddItems->isChecked() ) |
427 | mMatchedJournals.clear(); | ||
421 | if (mSearchJournal->isChecked() ) { | 428 | if (mSearchJournal->isChecked() ) { |
422 | QPtrList<Journal> journals = mCalendar->journals( ); | 429 | QPtrList<Journal> journals = mCalendar->journals( ); |
423 | Journal* journ; | 430 | Journal* journ; |
424 | 431 | ||
425 | for(journ=journals.first();journ;journ=journals.next()) { | 432 | for(journ=journals.first();journ;journ=journals.next()) { |
426 | if ( journ->dtStart().date() <= mEndDate->date() | 433 | if ( journ->dtStart().date() <= mEndDate->date() |
427 | &&journ->dtStart().date() >= mStartDate->date()) { | 434 | &&journ->dtStart().date() >= mStartDate->date()) { |
428 | #if QT_VERSION >= 0x030000 | 435 | #if QT_VERSION >= 0x030000 |
429 | if (re.search(journ->description()) != -1) | 436 | if (re.search(journ->description()) != -1) |
430 | #else | 437 | #else |
431 | if (re.match(journ->description()) != -1) | 438 | if (re.match(journ->description()) != -1) |
432 | #endif | 439 | #endif |
433 | { | 440 | { |
434 | mMatchedJournals.append(journ); | 441 | mMatchedJournals.append(journ); |
435 | continue; | 442 | continue; |
436 | } | 443 | } |
437 | } | 444 | } |
438 | } | 445 | } |
439 | } | 446 | } |
440 | 447 | ||
441 | } | 448 | } |
442 | 449 | ||
443 | void SearchDialog::keyPressEvent ( QKeyEvent *e) | 450 | void SearchDialog::keyPressEvent ( QKeyEvent *e) |
444 | { | 451 | { |
445 | switch ( e->key() ) { | 452 | switch ( e->key() ) { |
446 | case Qt::Key_Escape: | 453 | case Qt::Key_Escape: |
447 | close(); | 454 | close(); |
448 | break; | 455 | break; |
449 | case Qt::Key_F: | 456 | case Qt::Key_F: |
450 | if ( e->state() == Qt::ControlButton ) { | 457 | if ( e->state() == Qt::ControlButton ) { |
451 | 458 | ||
452 | } | 459 | } |
453 | break; | 460 | break; |
454 | case Qt::Key_Return: | 461 | case Qt::Key_Return: |
455 | case Qt::Key_Enter: | 462 | case Qt::Key_Enter: |
456 | doSearch(); | 463 | doSearch(); |
457 | break; | 464 | break; |
458 | 465 | ||
459 | default: | 466 | default: |
460 | e->ignore(); | 467 | e->ignore(); |
461 | } | 468 | } |
462 | } | 469 | } |
463 | 470 | ||
464 | //mMatchedJournals; | 471 | //mMatchedJournals; |