From b297e71bd6276ee9370917cb6765d73db7b61de9 Mon Sep 17 00:00:00 2001 From: zautrix Date: Thu, 16 Jun 2005 19:28:39 +0000 Subject: search fixes --- (limited to 'korganizer/searchdialog.cpp') 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 @@ #include #include #include - +#include #include #include @@ -67,14 +67,28 @@ SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent) searchEdit = new KLineEdit(topFrame); subLayout->addWidget(searchEdit); - mAddItems = new QCheckBox(i18n("Add items"),topFrame); - subLayout->addWidget(mAddItems); + 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 ); subLayout->addWidget(togButton); connect(togButton,SIGNAL(clicked()),SLOT(toggleCheckboxes())); togButton->setPixmap(SmallIcon("1updownarrow")); togButton->setMinimumWidth( togButton->sizeHint().height() ); + searchEdit->setText("*"); // Find all events by default searchEdit->setFocus(); connect(searchEdit, SIGNAL(textChanged ( const QString & )),this,SLOT(searchTextChanged( const QString & ))); @@ -141,6 +155,33 @@ 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() { if ( incidenceGroup->isVisible() ) { @@ -294,8 +335,10 @@ void SearchDialog::search(const QRegExp &re) QPtrList events = mCalendar->events( mStartDate->date(), 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; for(ev=events.first();ev;ev=events.next()) { @@ -305,8 +348,13 @@ void SearchDialog::search(const QRegExp &re) #else if (re.match(ev->summary()) != -1) #endif - { - mMatchedEvents.append(ev); + { + if ( mSubItems->isChecked() ) + mMatchedEvents.remove(ev); + else { + if ( !mMatchedEvents.contains( ev ) ) + mMatchedEvents.append(ev); + } continue; } #if QT_VERSION >= 0x030000 @@ -314,8 +362,13 @@ void SearchDialog::search(const QRegExp &re) #else if (re.match(ev->location()) != -1) #endif - { - mMatchedEvents.append(ev); + { + if ( mSubItems->isChecked() ) + mMatchedEvents.remove(ev); + else{ + if ( !mMatchedEvents.contains( ev ) ) + mMatchedEvents.append(ev); + } continue; } } @@ -325,8 +378,13 @@ void SearchDialog::search(const QRegExp &re) #else if (re.match(ev->description()) != -1) #endif - { - mMatchedEvents.append(ev); + { + if ( mSubItems->isChecked() ) + mMatchedEvents.remove(ev); + else{ + if ( !mMatchedEvents.contains( ev ) ) + mMatchedEvents.append(ev); + } continue; } } @@ -337,7 +395,13 @@ void SearchDialog::search(const QRegExp &re) if (re.match(ev->categoriesStr()) != -1) #endif { - mMatchedEvents.append(ev); + + if ( mSubItems->isChecked() ) + mMatchedEvents.remove(ev); + else{ + if ( !mMatchedEvents.contains( ev ) ) + mMatchedEvents.append(ev); + } continue; } } @@ -351,8 +415,13 @@ void SearchDialog::search(const QRegExp &re) #else if (re.match(a->name()) != -1) #endif - { - mMatchedEvents.append(ev); + { + if ( mSubItems->isChecked() ) + mMatchedEvents.remove(ev); + else{ + if ( !mMatchedEvents.contains( ev ) ) + mMatchedEvents.append(ev); + } break; } } @@ -362,8 +431,13 @@ void SearchDialog::search(const QRegExp &re) #else if (re.match(a->email()) != -1) #endif - { - mMatchedEvents.append(ev); + { + if ( mSubItems->isChecked() ) + mMatchedEvents.remove(ev); + else{ + if ( !mMatchedEvents.contains( ev ) ) + mMatchedEvents.append(ev); + } break; } } @@ -372,8 +446,12 @@ void SearchDialog::search(const QRegExp &re) } } QPtrList todos = mCalendar->todos( ); - if ( !mAddItems->isChecked() ) + + if ( !mAddItems->isChecked() && !mSubItems->isChecked() ) { + if ( mRefineItems->isChecked() ) todos = mMatchedTodos ; mMatchedTodos.clear(); + } + if ( mSearchTodo->isChecked() ) { Todo *tod; for(tod=todos.first();tod;tod=todos.next()) { @@ -383,8 +461,11 @@ void SearchDialog::search(const QRegExp &re) #else if (re.match(tod->summary()) != -1) #endif - { - mMatchedTodos.append(tod); + { + if ( mSubItems->isChecked() ) + mMatchedTodos.remove(tod); + else if (!mMatchedTodos.contains( tod )) + mMatchedTodos.append(tod); continue; } } @@ -394,8 +475,11 @@ void SearchDialog::search(const QRegExp &re) #else if (re.match(tod->description()) != -1) #endif - { - mMatchedTodos.append(tod); + { + if ( mSubItems->isChecked() ) + mMatchedTodos.remove(tod); + else if (!mMatchedTodos.contains( tod )) + mMatchedTodos.append(tod); continue; } } @@ -405,8 +489,11 @@ void SearchDialog::search(const QRegExp &re) #else if (re.match(tod->categoriesStr()) != -1) #endif - { - mMatchedTodos.append(tod); + { + if ( mSubItems->isChecked() ) + mMatchedTodos.remove(tod); + else if (!mMatchedTodos.contains( tod )) + mMatchedTodos.append(tod); continue; } } @@ -420,8 +507,11 @@ void SearchDialog::search(const QRegExp &re) #else if (re.match(a->name()) != -1) #endif - { - mMatchedTodos.append(tod); + { + if ( mSubItems->isChecked() ) + mMatchedTodos.remove(tod); + else if (!mMatchedTodos.contains( tod )) + mMatchedTodos.append(tod); break; } } @@ -432,7 +522,10 @@ void SearchDialog::search(const QRegExp &re) if (re.match(a->email()) != -1) #endif { - mMatchedTodos.append(tod); + if ( mSubItems->isChecked() ) + mMatchedTodos.remove(tod); + else if (!mMatchedTodos.contains( tod )) + mMatchedTodos.append(tod); break; } } @@ -440,10 +533,13 @@ void SearchDialog::search(const QRegExp &re) } } } - if ( !mAddItems->isChecked() ) + + QPtrList journals = mCalendar->journals( ); + if ( !mAddItems->isChecked() && !mSubItems->isChecked() ) { + if ( mRefineItems->isChecked() ) journals = mMatchedJournals ; mMatchedJournals.clear(); + } if (mSearchJournal->isChecked() ) { - QPtrList journals = mCalendar->journals( ); Journal* journ; for(journ=journals.first();journ;journ=journals.next()) { @@ -455,7 +551,10 @@ void SearchDialog::search(const QRegExp &re) if (re.match(journ->description()) != -1) #endif { - mMatchedJournals.append(journ); + if ( mSubItems->isChecked() ) + mMatchedJournals.remove(journ); + else if (!mMatchedJournals.contains( journ )) + mMatchedJournals.append(journ); continue; } } -- cgit v0.9.0.2