-rw-r--r-- | korganizer/searchdialog.cpp | 111 | ||||
-rw-r--r-- | korganizer/searchdialog.h | 7 |
2 files changed, 110 insertions, 8 deletions
diff --git a/korganizer/searchdialog.cpp b/korganizer/searchdialog.cpp index 7b3b543..bba49f0 100644 --- a/korganizer/searchdialog.cpp +++ b/korganizer/searchdialog.cpp @@ -31,5 +31,5 @@ #include <qlineedit.h> #include <qpushbutton.h> - +#include <qhbuttongroup.h> #include <klocale.h> #include <kmessagebox.h> @@ -68,6 +68,19 @@ SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent) subLayout->addWidget(searchEdit); - mAddItems = new QCheckBox(i18n("Add items"),topFrame); + mAddItems = new QRadioButton( "+ ", topFrame ); + mSubItems = new QRadioButton( "- ", topFrame ); + mRefineItems = new QRadioButton( "< ", topFrame ); subLayout->addWidget(mAddItems); + subLayout->addWidget( mSubItems ); + subLayout->addWidget( mRefineItems ); + QFont fo ( mAddItems->font() ); + fo.setBold( true ); + fo.setPointSize( fo.pointSize() + 2 ); + mAddItems->setFont( fo ); + mSubItems->setFont( fo ); + mRefineItems->setFont( fo ); + connect( mAddItems , SIGNAL( toggled ( bool ) ),this,SLOT(slot_add( bool ))); + connect( mSubItems , SIGNAL( toggled ( bool ) ),this,SLOT(slot_sub( bool ))); + connect( mRefineItems , SIGNAL( toggled ( bool ) ),this,SLOT(slot_refine( bool ))); QPushButton *togButton = new QPushButton( "", topFrame ); @@ -76,4 +89,5 @@ SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent) togButton->setPixmap(SmallIcon("1updownarrow")); togButton->setMinimumWidth( togButton->sizeHint().height() ); + searchEdit->setText("*"); // Find all events by default searchEdit->setFocus(); @@ -142,4 +156,31 @@ SearchDialog::~SearchDialog() } +void SearchDialog::slot_add( bool b ) +{ + if ( b ) { + if ( mSubItems->isOn() ) mSubItems->toggle(); + if ( mRefineItems->isOn() ) mRefineItems->toggle(); + setCaption( i18n("Matching items will be added to list")); + } else + setCaption( i18n("List will be cleared before search")); +} +void SearchDialog::slot_sub( bool b) +{ + if ( b ) { + if ( mRefineItems->isOn() ) mRefineItems->toggle(); + if ( mAddItems->isOn() ) mAddItems->toggle(); + setCaption( i18n("Matching items will be removed from list")); + } else + setCaption( i18n("List will be cleared before search")); +} +void SearchDialog::slot_refine( bool b) +{ + if ( b ) { + if ( mSubItems->isOn() ) mSubItems->toggle(); + if ( mAddItems->isOn() ) mAddItems->toggle(); + setCaption( i18n("Search on displayed list only")); + } else + setCaption( i18n("List will be cleared before search")); +} void SearchDialog::toggleCheckboxes() { @@ -295,6 +336,8 @@ void SearchDialog::search(const QRegExp &re) mEndDate->date(), false /*mInclusiveCheck->isChecked()*/ ); - if ( !mAddItems->isChecked() ) + if ( !mAddItems->isChecked() && !mSubItems->isChecked() ) { + if ( mRefineItems->isChecked() ) events = mMatchedEvents; mMatchedEvents.clear(); + } if ( mSearchEvent->isChecked() ) { Event *ev; @@ -307,5 +350,10 @@ void SearchDialog::search(const QRegExp &re) #endif { + if ( mSubItems->isChecked() ) + mMatchedEvents.remove(ev); + else { + if ( !mMatchedEvents.contains( ev ) ) mMatchedEvents.append(ev); + } continue; } @@ -316,5 +364,10 @@ void SearchDialog::search(const QRegExp &re) #endif { + if ( mSubItems->isChecked() ) + mMatchedEvents.remove(ev); + else{ + if ( !mMatchedEvents.contains( ev ) ) mMatchedEvents.append(ev); + } continue; } @@ -327,5 +380,10 @@ void SearchDialog::search(const QRegExp &re) #endif { + if ( mSubItems->isChecked() ) + mMatchedEvents.remove(ev); + else{ + if ( !mMatchedEvents.contains( ev ) ) mMatchedEvents.append(ev); + } continue; } @@ -338,5 +396,11 @@ void SearchDialog::search(const QRegExp &re) #endif { + + if ( mSubItems->isChecked() ) + mMatchedEvents.remove(ev); + else{ + if ( !mMatchedEvents.contains( ev ) ) mMatchedEvents.append(ev); + } continue; } @@ -353,5 +417,10 @@ void SearchDialog::search(const QRegExp &re) #endif { + if ( mSubItems->isChecked() ) + mMatchedEvents.remove(ev); + else{ + if ( !mMatchedEvents.contains( ev ) ) mMatchedEvents.append(ev); + } break; } @@ -364,5 +433,10 @@ void SearchDialog::search(const QRegExp &re) #endif { + if ( mSubItems->isChecked() ) + mMatchedEvents.remove(ev); + else{ + if ( !mMatchedEvents.contains( ev ) ) mMatchedEvents.append(ev); + } break; } @@ -373,6 +447,10 @@ void SearchDialog::search(const QRegExp &re) } QPtrList<Todo> todos = mCalendar->todos( ); - if ( !mAddItems->isChecked() ) + + if ( !mAddItems->isChecked() && !mSubItems->isChecked() ) { + if ( mRefineItems->isChecked() ) todos = mMatchedTodos ; mMatchedTodos.clear(); + } + if ( mSearchTodo->isChecked() ) { Todo *tod; @@ -385,4 +463,7 @@ void SearchDialog::search(const QRegExp &re) #endif { + if ( mSubItems->isChecked() ) + mMatchedTodos.remove(tod); + else if (!mMatchedTodos.contains( tod )) mMatchedTodos.append(tod); continue; @@ -396,4 +477,7 @@ void SearchDialog::search(const QRegExp &re) #endif { + if ( mSubItems->isChecked() ) + mMatchedTodos.remove(tod); + else if (!mMatchedTodos.contains( tod )) mMatchedTodos.append(tod); continue; @@ -407,4 +491,7 @@ void SearchDialog::search(const QRegExp &re) #endif { + if ( mSubItems->isChecked() ) + mMatchedTodos.remove(tod); + else if (!mMatchedTodos.contains( tod )) mMatchedTodos.append(tod); continue; @@ -422,4 +509,7 @@ void SearchDialog::search(const QRegExp &re) #endif { + if ( mSubItems->isChecked() ) + mMatchedTodos.remove(tod); + else if (!mMatchedTodos.contains( tod )) mMatchedTodos.append(tod); break; @@ -433,4 +523,7 @@ void SearchDialog::search(const QRegExp &re) #endif { + if ( mSubItems->isChecked() ) + mMatchedTodos.remove(tod); + else if (!mMatchedTodos.contains( tod )) mMatchedTodos.append(tod); break; @@ -441,8 +534,11 @@ void SearchDialog::search(const QRegExp &re) } } - if ( !mAddItems->isChecked() ) + + QPtrList<Journal> journals = mCalendar->journals( ); + if ( !mAddItems->isChecked() && !mSubItems->isChecked() ) { + if ( mRefineItems->isChecked() ) journals = mMatchedJournals ; mMatchedJournals.clear(); + } if (mSearchJournal->isChecked() ) { - QPtrList<Journal> journals = mCalendar->journals( ); Journal* journ; @@ -456,4 +552,7 @@ void SearchDialog::search(const QRegExp &re) #endif { + if ( mSubItems->isChecked() ) + mMatchedJournals.remove(journ); + else if (!mMatchedJournals.contains( journ )) mMatchedJournals.append(journ); continue; diff --git a/korganizer/searchdialog.h b/korganizer/searchdialog.h index b345b98..945ff65 100644 --- a/korganizer/searchdialog.h +++ b/korganizer/searchdialog.h @@ -26,5 +26,5 @@ #include <qregexp.h> - +#include <qradiobutton.h> #include <kdialogbase.h> #include <qvbox.h> @@ -62,4 +62,7 @@ class SearchDialog : public QVBox void searchTextChanged( const QString &_text ); void toggleCheckboxes(); + void slot_add( bool ); + void slot_sub( bool ); + void slot_refine( bool ); signals: @@ -93,5 +96,5 @@ class SearchDialog : public QVBox QCheckBox *mSearchAName; QCheckBox *mSearchAEmail; - QCheckBox *mAddItems; + QRadioButton *mAddItems, *mSubItems, *mRefineItems; void keyPressEvent ( QKeyEvent *e) ; }; |