-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 | |||
@@ -46,34 +46,39 @@ | |||
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); |
@@ -263,26 +268,26 @@ void SearchDialog::updateView() | |||
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; |
@@ -340,26 +345,27 @@ void SearchDialog::search(const QRegExp &re) | |||
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; |
@@ -408,25 +414,26 @@ void SearchDialog::search(const QRegExp &re) | |||
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 |