author | zautrix <zautrix> | 2005-06-16 19:28:39 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-16 19:28:39 (UTC) |
commit | b297e71bd6276ee9370917cb6765d73db7b61de9 (patch) (unidiff) | |
tree | 74240a9792ad8807b8838b43f89d0303db585538 | |
parent | be2913be979c0d7c41e8a8721b552d14cb7ecd39 (diff) | |
download | kdepimpi-b297e71bd6276ee9370917cb6765d73db7b61de9.zip kdepimpi-b297e71bd6276ee9370917cb6765d73db7b61de9.tar.gz kdepimpi-b297e71bd6276ee9370917cb6765d73db7b61de9.tar.bz2 |
search fixes
-rw-r--r-- | bin/kdepim/korganizer/germantranslation.txt | 4 | ||||
-rw-r--r-- | korganizer/searchdialog.cpp | 155 | ||||
-rw-r--r-- | korganizer/searchdialog.h | 7 |
3 files changed, 136 insertions, 30 deletions
diff --git a/bin/kdepim/korganizer/germantranslation.txt b/bin/kdepim/korganizer/germantranslation.txt index 03d1882..5a9f2a2 100644 --- a/bin/kdepim/korganizer/germantranslation.txt +++ b/bin/kdepim/korganizer/germantranslation.txt | |||
@@ -1419,6 +1419,10 @@ | |||
1419 | { "Choose Color","Wähle Farbe" }, | 1419 | { "Choose Color","Wähle Farbe" }, |
1420 | { " OK "," OK " }, | 1420 | { " OK "," OK " }, |
1421 | { " Cancel "," Abbrechen " }, | 1421 | { " Cancel "," Abbrechen " }, |
1422 | { "Matching items will be added to list","Passende werden zur Liste hinzugefügt" }, | ||
1423 | { "Matching items will be removed from list","Passende werden von der Liste entfernt" }, | ||
1424 | { "Search on displayed list only","Suche auf der dargestellten Liste" }, | ||
1425 | { "List will be cleared before search","Liste wird vor der Suche gelöscht" }, | ||
1422 | { "","" }, | 1426 | { "","" }, |
1423 | { "","" }, | 1427 | { "","" }, |
1424 | { "","" }, | 1428 | { "","" }, |
diff --git a/korganizer/searchdialog.cpp b/korganizer/searchdialog.cpp index 7b3b543..bba49f0 100644 --- a/korganizer/searchdialog.cpp +++ b/korganizer/searchdialog.cpp | |||
@@ -30,7 +30,7 @@ | |||
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 | #include <qhbuttongroup.h> | |
34 | #include <klocale.h> | 34 | #include <klocale.h> |
35 | #include <kmessagebox.h> | 35 | #include <kmessagebox.h> |
36 | 36 | ||
@@ -67,14 +67,28 @@ SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent) | |||
67 | searchEdit = new KLineEdit(topFrame); | 67 | searchEdit = new KLineEdit(topFrame); |
68 | subLayout->addWidget(searchEdit); | 68 | subLayout->addWidget(searchEdit); |
69 | 69 | ||
70 | mAddItems = new QCheckBox(i18n("Add items"),topFrame); | 70 | mAddItems = new QRadioButton( "+ ", topFrame ); |
71 | subLayout->addWidget(mAddItems); | 71 | mSubItems = new QRadioButton( "- ", topFrame ); |
72 | mRefineItems = new QRadioButton( "< ", topFrame ); | ||
73 | subLayout->addWidget( mAddItems ); | ||
74 | subLayout->addWidget( mSubItems ); | ||
75 | subLayout->addWidget( mRefineItems ); | ||
76 | QFont fo ( mAddItems->font() ); | ||
77 | fo.setBold( true ); | ||
78 | fo.setPointSize( fo.pointSize() + 2 ); | ||
79 | mAddItems->setFont( fo ); | ||
80 | mSubItems->setFont( fo ); | ||
81 | mRefineItems->setFont( fo ); | ||
82 | connect( mAddItems , SIGNAL( toggled ( bool ) ),this,SLOT(slot_add( bool ))); | ||
83 | connect( mSubItems , SIGNAL( toggled ( bool ) ),this,SLOT(slot_sub( bool ))); | ||
84 | connect( mRefineItems , SIGNAL( toggled ( bool ) ),this,SLOT(slot_refine( bool ))); | ||
72 | 85 | ||
73 | QPushButton *togButton = new QPushButton( "", topFrame ); | 86 | QPushButton *togButton = new QPushButton( "", topFrame ); |
74 | subLayout->addWidget(togButton); | 87 | subLayout->addWidget(togButton); |
75 | connect(togButton,SIGNAL(clicked()),SLOT(toggleCheckboxes())); | 88 | connect(togButton,SIGNAL(clicked()),SLOT(toggleCheckboxes())); |
76 | togButton->setPixmap(SmallIcon("1updownarrow")); | 89 | togButton->setPixmap(SmallIcon("1updownarrow")); |
77 | togButton->setMinimumWidth( togButton->sizeHint().height() ); | 90 | togButton->setMinimumWidth( togButton->sizeHint().height() ); |
91 | |||
78 | searchEdit->setText("*"); // Find all events by default | 92 | searchEdit->setText("*"); // Find all events by default |
79 | searchEdit->setFocus(); | 93 | searchEdit->setFocus(); |
80 | connect(searchEdit, SIGNAL(textChanged ( const QString & )),this,SLOT(searchTextChanged( const QString & ))); | 94 | connect(searchEdit, SIGNAL(textChanged ( const QString & )),this,SLOT(searchTextChanged( const QString & ))); |
@@ -141,6 +155,33 @@ SearchDialog::~SearchDialog() | |||
141 | { | 155 | { |
142 | 156 | ||
143 | } | 157 | } |
158 | void SearchDialog::slot_add( bool b ) | ||
159 | { | ||
160 | if ( b ) { | ||
161 | if ( mSubItems->isOn() ) mSubItems->toggle(); | ||
162 | if ( mRefineItems->isOn() ) mRefineItems->toggle(); | ||
163 | setCaption( i18n("Matching items will be added to list")); | ||
164 | } else | ||
165 | setCaption( i18n("List will be cleared before search")); | ||
166 | } | ||
167 | void SearchDialog::slot_sub( bool b) | ||
168 | { | ||
169 | if ( b ) { | ||
170 | if ( mRefineItems->isOn() ) mRefineItems->toggle(); | ||
171 | if ( mAddItems->isOn() ) mAddItems->toggle(); | ||
172 | setCaption( i18n("Matching items will be removed from list")); | ||
173 | } else | ||
174 | setCaption( i18n("List will be cleared before search")); | ||
175 | } | ||
176 | void SearchDialog::slot_refine( bool b) | ||
177 | { | ||
178 | if ( b ) { | ||
179 | if ( mSubItems->isOn() ) mSubItems->toggle(); | ||
180 | if ( mAddItems->isOn() ) mAddItems->toggle(); | ||
181 | setCaption( i18n("Search on displayed list only")); | ||
182 | } else | ||
183 | setCaption( i18n("List will be cleared before search")); | ||
184 | } | ||
144 | void SearchDialog::toggleCheckboxes() | 185 | void SearchDialog::toggleCheckboxes() |
145 | { | 186 | { |
146 | if ( incidenceGroup->isVisible() ) { | 187 | if ( incidenceGroup->isVisible() ) { |
@@ -294,8 +335,10 @@ void SearchDialog::search(const QRegExp &re) | |||
294 | QPtrList<Event> events = mCalendar->events( mStartDate->date(), | 335 | QPtrList<Event> events = mCalendar->events( mStartDate->date(), |
295 | mEndDate->date(), | 336 | mEndDate->date(), |
296 | false /*mInclusiveCheck->isChecked()*/ ); | 337 | false /*mInclusiveCheck->isChecked()*/ ); |
297 | if ( !mAddItems->isChecked() ) | 338 | if ( !mAddItems->isChecked() && !mSubItems->isChecked() ) { |
339 | if ( mRefineItems->isChecked() ) events = mMatchedEvents; | ||
298 | mMatchedEvents.clear(); | 340 | mMatchedEvents.clear(); |
341 | } | ||
299 | if ( mSearchEvent->isChecked() ) { | 342 | if ( mSearchEvent->isChecked() ) { |
300 | Event *ev; | 343 | Event *ev; |
301 | for(ev=events.first();ev;ev=events.next()) { | 344 | for(ev=events.first();ev;ev=events.next()) { |
@@ -305,8 +348,13 @@ void SearchDialog::search(const QRegExp &re) | |||
305 | #else | 348 | #else |
306 | if (re.match(ev->summary()) != -1) | 349 | if (re.match(ev->summary()) != -1) |
307 | #endif | 350 | #endif |
308 | { | 351 | { |
309 | mMatchedEvents.append(ev); | 352 | if ( mSubItems->isChecked() ) |
353 | mMatchedEvents.remove(ev); | ||
354 | else { | ||
355 | if ( !mMatchedEvents.contains( ev ) ) | ||
356 | mMatchedEvents.append(ev); | ||
357 | } | ||
310 | continue; | 358 | continue; |
311 | } | 359 | } |
312 | #if QT_VERSION >= 0x030000 | 360 | #if QT_VERSION >= 0x030000 |
@@ -314,8 +362,13 @@ void SearchDialog::search(const QRegExp &re) | |||
314 | #else | 362 | #else |
315 | if (re.match(ev->location()) != -1) | 363 | if (re.match(ev->location()) != -1) |
316 | #endif | 364 | #endif |
317 | { | 365 | { |
318 | mMatchedEvents.append(ev); | 366 | if ( mSubItems->isChecked() ) |
367 | mMatchedEvents.remove(ev); | ||
368 | else{ | ||
369 | if ( !mMatchedEvents.contains( ev ) ) | ||
370 | mMatchedEvents.append(ev); | ||
371 | } | ||
319 | continue; | 372 | continue; |
320 | } | 373 | } |
321 | } | 374 | } |
@@ -325,8 +378,13 @@ void SearchDialog::search(const QRegExp &re) | |||
325 | #else | 378 | #else |
326 | if (re.match(ev->description()) != -1) | 379 | if (re.match(ev->description()) != -1) |
327 | #endif | 380 | #endif |
328 | { | 381 | { |
329 | mMatchedEvents.append(ev); | 382 | if ( mSubItems->isChecked() ) |
383 | mMatchedEvents.remove(ev); | ||
384 | else{ | ||
385 | if ( !mMatchedEvents.contains( ev ) ) | ||
386 | mMatchedEvents.append(ev); | ||
387 | } | ||
330 | continue; | 388 | continue; |
331 | } | 389 | } |
332 | } | 390 | } |
@@ -337,7 +395,13 @@ void SearchDialog::search(const QRegExp &re) | |||
337 | if (re.match(ev->categoriesStr()) != -1) | 395 | if (re.match(ev->categoriesStr()) != -1) |
338 | #endif | 396 | #endif |
339 | { | 397 | { |
340 | mMatchedEvents.append(ev); | 398 | |
399 | if ( mSubItems->isChecked() ) | ||
400 | mMatchedEvents.remove(ev); | ||
401 | else{ | ||
402 | if ( !mMatchedEvents.contains( ev ) ) | ||
403 | mMatchedEvents.append(ev); | ||
404 | } | ||
341 | continue; | 405 | continue; |
342 | } | 406 | } |
343 | } | 407 | } |
@@ -351,8 +415,13 @@ void SearchDialog::search(const QRegExp &re) | |||
351 | #else | 415 | #else |
352 | if (re.match(a->name()) != -1) | 416 | if (re.match(a->name()) != -1) |
353 | #endif | 417 | #endif |
354 | { | 418 | { |
355 | mMatchedEvents.append(ev); | 419 | if ( mSubItems->isChecked() ) |
420 | mMatchedEvents.remove(ev); | ||
421 | else{ | ||
422 | if ( !mMatchedEvents.contains( ev ) ) | ||
423 | mMatchedEvents.append(ev); | ||
424 | } | ||
356 | break; | 425 | break; |
357 | } | 426 | } |
358 | } | 427 | } |
@@ -362,8 +431,13 @@ void SearchDialog::search(const QRegExp &re) | |||
362 | #else | 431 | #else |
363 | if (re.match(a->email()) != -1) | 432 | if (re.match(a->email()) != -1) |
364 | #endif | 433 | #endif |
365 | { | 434 | { |
366 | mMatchedEvents.append(ev); | 435 | if ( mSubItems->isChecked() ) |
436 | mMatchedEvents.remove(ev); | ||
437 | else{ | ||
438 | if ( !mMatchedEvents.contains( ev ) ) | ||
439 | mMatchedEvents.append(ev); | ||
440 | } | ||
367 | break; | 441 | break; |
368 | } | 442 | } |
369 | } | 443 | } |
@@ -372,8 +446,12 @@ void SearchDialog::search(const QRegExp &re) | |||
372 | } | 446 | } |
373 | } | 447 | } |
374 | QPtrList<Todo> todos = mCalendar->todos( ); | 448 | QPtrList<Todo> todos = mCalendar->todos( ); |
375 | if ( !mAddItems->isChecked() ) | 449 | |
450 | if ( !mAddItems->isChecked() && !mSubItems->isChecked() ) { | ||
451 | if ( mRefineItems->isChecked() ) todos = mMatchedTodos ; | ||
376 | mMatchedTodos.clear(); | 452 | mMatchedTodos.clear(); |
453 | } | ||
454 | |||
377 | if ( mSearchTodo->isChecked() ) { | 455 | if ( mSearchTodo->isChecked() ) { |
378 | Todo *tod; | 456 | Todo *tod; |
379 | for(tod=todos.first();tod;tod=todos.next()) { | 457 | for(tod=todos.first();tod;tod=todos.next()) { |
@@ -383,8 +461,11 @@ void SearchDialog::search(const QRegExp &re) | |||
383 | #else | 461 | #else |
384 | if (re.match(tod->summary()) != -1) | 462 | if (re.match(tod->summary()) != -1) |
385 | #endif | 463 | #endif |
386 | { | 464 | { |
387 | mMatchedTodos.append(tod); | 465 | if ( mSubItems->isChecked() ) |
466 | mMatchedTodos.remove(tod); | ||
467 | else if (!mMatchedTodos.contains( tod )) | ||
468 | mMatchedTodos.append(tod); | ||
388 | continue; | 469 | continue; |
389 | } | 470 | } |
390 | } | 471 | } |
@@ -394,8 +475,11 @@ void SearchDialog::search(const QRegExp &re) | |||
394 | #else | 475 | #else |
395 | if (re.match(tod->description()) != -1) | 476 | if (re.match(tod->description()) != -1) |
396 | #endif | 477 | #endif |
397 | { | 478 | { |
398 | mMatchedTodos.append(tod); | 479 | if ( mSubItems->isChecked() ) |
480 | mMatchedTodos.remove(tod); | ||
481 | else if (!mMatchedTodos.contains( tod )) | ||
482 | mMatchedTodos.append(tod); | ||
399 | continue; | 483 | continue; |
400 | } | 484 | } |
401 | } | 485 | } |
@@ -405,8 +489,11 @@ void SearchDialog::search(const QRegExp &re) | |||
405 | #else | 489 | #else |
406 | if (re.match(tod->categoriesStr()) != -1) | 490 | if (re.match(tod->categoriesStr()) != -1) |
407 | #endif | 491 | #endif |
408 | { | 492 | { |
409 | mMatchedTodos.append(tod); | 493 | if ( mSubItems->isChecked() ) |
494 | mMatchedTodos.remove(tod); | ||
495 | else if (!mMatchedTodos.contains( tod )) | ||
496 | mMatchedTodos.append(tod); | ||
410 | continue; | 497 | continue; |
411 | } | 498 | } |
412 | } | 499 | } |
@@ -420,8 +507,11 @@ void SearchDialog::search(const QRegExp &re) | |||
420 | #else | 507 | #else |
421 | if (re.match(a->name()) != -1) | 508 | if (re.match(a->name()) != -1) |
422 | #endif | 509 | #endif |
423 | { | 510 | { |
424 | mMatchedTodos.append(tod); | 511 | if ( mSubItems->isChecked() ) |
512 | mMatchedTodos.remove(tod); | ||
513 | else if (!mMatchedTodos.contains( tod )) | ||
514 | mMatchedTodos.append(tod); | ||
425 | break; | 515 | break; |
426 | } | 516 | } |
427 | } | 517 | } |
@@ -432,7 +522,10 @@ void SearchDialog::search(const QRegExp &re) | |||
432 | if (re.match(a->email()) != -1) | 522 | if (re.match(a->email()) != -1) |
433 | #endif | 523 | #endif |
434 | { | 524 | { |
435 | mMatchedTodos.append(tod); | 525 | if ( mSubItems->isChecked() ) |
526 | mMatchedTodos.remove(tod); | ||
527 | else if (!mMatchedTodos.contains( tod )) | ||
528 | mMatchedTodos.append(tod); | ||
436 | break; | 529 | break; |
437 | } | 530 | } |
438 | } | 531 | } |
@@ -440,10 +533,13 @@ void SearchDialog::search(const QRegExp &re) | |||
440 | } | 533 | } |
441 | } | 534 | } |
442 | } | 535 | } |
443 | if ( !mAddItems->isChecked() ) | 536 | |
537 | QPtrList<Journal> journals = mCalendar->journals( ); | ||
538 | if ( !mAddItems->isChecked() && !mSubItems->isChecked() ) { | ||
539 | if ( mRefineItems->isChecked() ) journals = mMatchedJournals ; | ||
444 | mMatchedJournals.clear(); | 540 | mMatchedJournals.clear(); |
541 | } | ||
445 | if (mSearchJournal->isChecked() ) { | 542 | if (mSearchJournal->isChecked() ) { |
446 | QPtrList<Journal> journals = mCalendar->journals( ); | ||
447 | Journal* journ; | 543 | Journal* journ; |
448 | 544 | ||
449 | for(journ=journals.first();journ;journ=journals.next()) { | 545 | for(journ=journals.first();journ;journ=journals.next()) { |
@@ -455,7 +551,10 @@ void SearchDialog::search(const QRegExp &re) | |||
455 | if (re.match(journ->description()) != -1) | 551 | if (re.match(journ->description()) != -1) |
456 | #endif | 552 | #endif |
457 | { | 553 | { |
458 | mMatchedJournals.append(journ); | 554 | if ( mSubItems->isChecked() ) |
555 | mMatchedJournals.remove(journ); | ||
556 | else if (!mMatchedJournals.contains( journ )) | ||
557 | mMatchedJournals.append(journ); | ||
459 | continue; | 558 | continue; |
460 | } | 559 | } |
461 | } | 560 | } |
diff --git a/korganizer/searchdialog.h b/korganizer/searchdialog.h index b345b98..945ff65 100644 --- a/korganizer/searchdialog.h +++ b/korganizer/searchdialog.h | |||
@@ -25,7 +25,7 @@ | |||
25 | #define SEARCHDIALOG_H | 25 | #define SEARCHDIALOG_H |
26 | 26 | ||
27 | #include <qregexp.h> | 27 | #include <qregexp.h> |
28 | 28 | #include <qradiobutton.h> | |
29 | #include <kdialogbase.h> | 29 | #include <kdialogbase.h> |
30 | #include <qvbox.h> | 30 | #include <qvbox.h> |
31 | 31 | ||
@@ -61,6 +61,9 @@ class SearchDialog : public QVBox | |||
61 | void doSearch(); | 61 | void doSearch(); |
62 | void searchTextChanged( const QString &_text ); | 62 | void searchTextChanged( const QString &_text ); |
63 | void toggleCheckboxes(); | 63 | void toggleCheckboxes(); |
64 | void slot_add( bool ); | ||
65 | void slot_sub( bool ); | ||
66 | void slot_refine( bool ); | ||
64 | 67 | ||
65 | signals: | 68 | signals: |
66 | void showEventSignal(Event *); | 69 | void showEventSignal(Event *); |
@@ -92,7 +95,7 @@ class SearchDialog : public QVBox | |||
92 | QCheckBox *mSearchJournal; | 95 | QCheckBox *mSearchJournal; |
93 | QCheckBox *mSearchAName; | 96 | QCheckBox *mSearchAName; |
94 | QCheckBox *mSearchAEmail; | 97 | QCheckBox *mSearchAEmail; |
95 | QCheckBox *mAddItems; | 98 | QRadioButton *mAddItems, *mSubItems, *mRefineItems; |
96 | void keyPressEvent ( QKeyEvent *e) ; | 99 | void keyPressEvent ( QKeyEvent *e) ; |
97 | }; | 100 | }; |
98 | 101 | ||