-rw-r--r-- | korganizer/searchdialog.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/korganizer/searchdialog.cpp b/korganizer/searchdialog.cpp index 0713980..2390520 100644 --- a/korganizer/searchdialog.cpp +++ b/korganizer/searchdialog.cpp @@ -320,40 +320,44 @@ void SearchDialog::updateView() re.setPattern(st); if (re.isValid()) { search(re); } else { mMatchedEvents.clear(); mMatchedTodos.clear(); mMatchedJournals.clear(); } listView->setStartDate( mStartDate->date() ); listView->showEvents(mMatchedEvents); listView->addTodos(mMatchedTodos); listView->addJournals(mMatchedJournals); } void SearchDialog::search(const QRegExp &re) { - QPtrList<Event> events = mCalendar->events( mStartDate->date(), - mEndDate->date(), - false /*mInclusiveCheck->isChecked()*/ ); + QPtrList<Event> events; if ( !mAddItems->isChecked() && !mSubItems->isChecked() ) { if ( mRefineItems->isChecked() ) events = mMatchedEvents; mMatchedEvents.clear(); } if ( mSearchEvent->isChecked() ) { + if ( !mRefineItems->isChecked() ) + events = mCalendar->events( mStartDate->date(), + mEndDate->date(), + false /*mInclusiveCheck->isChecked()*/ ); + + Event *ev; for(ev=events.first();ev;ev=events.next()) { if (mSummaryCheck->isChecked()) { #if QT_VERSION >= 0x030000 if (re.search(ev->summary()) != -1) #else if (re.match(ev->summary()) != -1) #endif { if ( mSubItems->isChecked() ) mMatchedEvents.remove(ev); else { if ( !mMatchedEvents.contains( ev ) ) mMatchedEvents.append(ev); } continue; @@ -433,40 +437,41 @@ void SearchDialog::search(const QRegExp &re) if (re.match(a->email()) != -1) #endif { if ( mSubItems->isChecked() ) mMatchedEvents.remove(ev); else{ if ( !mMatchedEvents.contains( ev ) ) mMatchedEvents.append(ev); } break; } } } } } } - QPtrList<Todo> todos = mCalendar->todos( ); + QPtrList<Todo> todos; if ( !mAddItems->isChecked() && !mSubItems->isChecked() ) { if ( mRefineItems->isChecked() ) todos = mMatchedTodos ; mMatchedTodos.clear(); } if ( mSearchTodo->isChecked() ) { + if ( !mRefineItems->isChecked() ) todos = mCalendar->todos( ); Todo *tod; for(tod=todos.first();tod;tod=todos.next()) { if (mSummaryCheck->isChecked()) { #if QT_VERSION >= 0x030000 if (re.search(tod->summary()) != -1) #else if (re.match(tod->summary()) != -1) #endif { if ( mSubItems->isChecked() ) mMatchedTodos.remove(tod); else if (!mMatchedTodos.contains( tod )) mMatchedTodos.append(tod); continue; } } @@ -522,38 +527,39 @@ void SearchDialog::search(const QRegExp &re) #else if (re.match(a->email()) != -1) #endif { if ( mSubItems->isChecked() ) mMatchedTodos.remove(tod); else if (!mMatchedTodos.contains( tod )) mMatchedTodos.append(tod); break; } } } } } } - QPtrList<Journal> journals = mCalendar->journals( ); + QPtrList<Journal> journals; if ( !mAddItems->isChecked() && !mSubItems->isChecked() ) { if ( mRefineItems->isChecked() ) journals = mMatchedJournals ; mMatchedJournals.clear(); } if (mSearchJournal->isChecked() ) { + if ( ! mRefineItems->isChecked() ) journals = mCalendar->journals(); Journal* journ; for(journ=journals.first();journ;journ=journals.next()) { if ( journ->dtStart().date() <= mEndDate->date() &&journ->dtStart().date() >= mStartDate->date()) { #if QT_VERSION >= 0x030000 if (re.search(journ->description()) != -1) #else if (re.match(journ->description()) != -1) #endif { if ( mSubItems->isChecked() ) mMatchedJournals.remove(journ); else if (!mMatchedJournals.contains( journ )) mMatchedJournals.append(journ); continue; |