-rw-r--r-- | korganizer/searchdialog.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/korganizer/searchdialog.cpp b/korganizer/searchdialog.cpp index 72ee1d2..39966b5 100644 --- a/korganizer/searchdialog.cpp +++ b/korganizer/searchdialog.cpp @@ -109,289 +109,289 @@ SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent) // mInclusiveCheck = new QCheckBox(i18n("Events have to be completely included"), topFrame); //mInclusiveCheck->setChecked(false); layout->addWidget(rangeWidget); //layout->addWidget(mInclusiveCheck); // Subjects to search // Results list view listView = new KOListView(mCalendar,topFrame); //listView->showDates(); layout->addWidget(listView); // if ( KOPrefs::instance()->mCompactDialogs ) { // KOGlobals::fitDialogToScreen( this, true ); // } listView->readSettings(KOGlobals::config(),"SearchListView Layout"); connect(this,SIGNAL(user1Clicked()),SLOT(doSearch())); QPushButton *CloseButton = findButton( Close ); //connect(CloseButton,SIGNAL(clicked()),listView, SLOT(clear())); #ifndef DESKTOP_VERSION setCaption(i18n("Click OK to search ->")); hideButtons(); #endif } SearchDialog::~SearchDialog() { } void SearchDialog::accept() { doSearch(); } void SearchDialog::updateList() { //listView->updateList(); if ( isVisible() ) { updateView(); //qDebug("SearchDialog::updated "); } else { listView->clear(); //qDebug("SearchDialog::cleared "); } } void SearchDialog::searchTextChanged( const QString &_text ) { enableButton( KDialogBase::User1, !_text.isEmpty() ); } void SearchDialog::doSearch() { QRegExp re; re.setWildcard(true); // most people understand these better. re.setCaseSensitive(false); re.setPattern(searchEdit->text()); if (!re.isValid() ) { KMessageBox::sorry(this, i18n("Invalid search expression,\ncannot perform " "the search.\nPlease enter a search expression\n" "using the wildcard characters\n '*' and '?'" "where needed.")); return; } search(re); listView->setStartDate( mStartDate->date() ); listView->showEvents(mMatchedEvents); listView->addTodos(mMatchedTodos); listView->addJournals(mMatchedJournals); if (mMatchedEvents.count() + mMatchedJournals.count() + mMatchedTodos.count() == 0) { KMessageBox::information(this, i18n("No event/todo were found matching\nyour search expression.\nUse the wildcard characters\n ' * ' and ' ? ' where needed.")); #ifndef DESKTOP_VERSION setCaption(i18n("Click OK to search ->")); #else setCaption(i18n("KO/Pi Find ")); #endif } else { QString mess; mess = mess.sprintf( i18n("%d item(s) found."), mMatchedEvents.count()+ mMatchedJournals.count() + mMatchedTodos.count() ); setCaption( i18n("KO/Pi Find: ") + mess); } } void SearchDialog::updateConfig() { listView->updateConfig(); } void SearchDialog::updateView() { QRegExp re; re.setWildcard(true); // most people understand these better. re.setCaseSensitive(false); re.setPattern(searchEdit->text()); 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()*/ ); mMatchedEvents.clear(); if ( mSearchEvent->isChecked() ) { Event *ev; for(ev=events.first();ev;ev=events.next()) { if (mSummaryCheck->isChecked()) { -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 if (re.search(ev->summary()) != -1) #else if (re.match(ev->summary()) != -1) #endif { mMatchedEvents.append(ev); continue; } } if (mDescriptionCheck->isChecked()) { -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 if (re.search(ev->description()) != -1) #else if (re.match(ev->description()) != -1) #endif { mMatchedEvents.append(ev); continue; } } if (mCategoryCheck->isChecked()) { -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 if (re.search(ev->categoriesStr()) != -1) #else if (re.match(ev->categoriesStr()) != -1) #endif { mMatchedEvents.append(ev); continue; } } if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) { QPtrList<Attendee> tmpAList = ev->attendees(); Attendee *a; for (a = tmpAList.first(); a; a = tmpAList.next()) { if (mSearchAName->isChecked()) { -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 if (re.search(a->name()) != -1) #else if (re.match(a->name()) != -1) #endif { mMatchedEvents.append(ev); break; } } if (mSearchAEmail->isChecked()) { -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 if (re.search(a->email()) != -1) #else if (re.match(a->email()) != -1) #endif { mMatchedEvents.append(ev); break; } } } } } } QPtrList<Todo> todos = mCalendar->todos( ); mMatchedTodos.clear(); if ( mSearchTodo->isChecked() ) { Todo *tod; for(tod=todos.first();tod;tod=todos.next()) { if (mSummaryCheck->isChecked()) { -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 if (re.search(tod->summary()) != -1) #else if (re.match(tod->summary()) != -1) #endif { mMatchedTodos.append(tod); continue; } } if (mDescriptionCheck->isChecked()) { -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 if (re.search(tod->description()) != -1) #else if (re.match(tod->description()) != -1) #endif { mMatchedTodos.append(tod); continue; } } if (mCategoryCheck->isChecked()) { -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 if (re.search(tod->categoriesStr()) != -1) #else if (re.match(tod->categoriesStr()) != -1) #endif { mMatchedTodos.append(tod); continue; } } if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) { QPtrList<Attendee> tmpAList = tod->attendees(); Attendee *a; for (a = tmpAList.first(); a; a = tmpAList.next()) { if (mSearchAName->isChecked()) { -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 if (re.search(a->name()) != -1) #else if (re.match(a->name()) != -1) #endif { mMatchedTodos.append(tod); break; } } if (mSearchAEmail->isChecked()) { -#if QT_VERSION >= 300 +#if QT_VERSION >= 0x030000 if (re.search(a->email()) != -1) #else if (re.match(a->email()) != -1) #endif { mMatchedTodos.append(tod); break; } } } } } } mMatchedJournals.clear(); if (mSearchJournal->isChecked() ) { QPtrList<Journal> 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 >= 300 +#if QT_VERSION >= 0x030000 if (re.search(journ->description()) != -1) #else if (re.match(journ->description()) != -1) #endif { mMatchedJournals.append(journ); continue; } } } } } /* void SearchDialog::keyPressEvent ( QKeyEvent *e) { e->ignore(); } */ //mMatchedJournals; |