author | zautrix <zautrix> | 2005-06-16 19:28:39 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-16 19:28:39 (UTC) |
commit | b297e71bd6276ee9370917cb6765d73db7b61de9 (patch) (side-by-side diff) | |
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 | 111 | ||||
-rw-r--r-- | korganizer/searchdialog.h | 7 |
3 files changed, 114 insertions, 8 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 @@ -1406,23 +1406,27 @@ { "<b>Name of new calendar:</b>","<b>Name des Kalenders:</b>" }, { "<b>Local ical (*.ics) file:</b>","<b>Lokale ical (*.ics) Datei:</b>" }, { "Sorry, the calendar name is empty!","Sorry, der Kalendername ist leer!" }, { "Sorry, the file name is empty!","Sorry, der Dateiname ist leer!" }, { "Error loading calendar file\n%1.","Fehler beim Laden der Kalenderdatei\n%1." }, { "The calendar <b>%1</b> is not loaded! Loading of file <b>%2</b> failed! <b>Try again to load the calendar?</b>","Der Kalender <b>%1</b> ist nicht geladen! Das Laden der Datei <b>%2</b> schlug fehl! <b>Soll erneut versucht werden den Kalender zu laden?</b>" }, { "Global application font for all apps:","Globale Schriftart:" }, { "Application Font","Applikationsschriftart" }, { "Kx/Pi","Kx/Pi" }, { "Backup","Backup" }, { "KDE-Pim Global Settings","KDE-Pim Globale Einstellungen" }, { "Sorry, the calendar name \n%1\nalready exists!\nPlease choose another name!","Sorry, der Kalendername \n%1\nist schon in Benutzung!\nBitte wählen Sie einen anderen!" }, { "Sorry, the file \n%1\nis already loaded!\nPlease choose another file!","Sorry, die Datei \n%1\nist schon geladen!\nBitte wählen Sie eine andere!" }, { "Choose Color","Wähle Farbe" }, { " OK "," OK " }, { " Cancel "," Abbrechen " }, +{ "Matching items will be added to list","Passende werden zur Liste hinzugefügt" }, +{ "Matching items will be removed from list","Passende werden von der Liste entfernt" }, +{ "Search on displayed list only","Suche auf der dargestellten Liste" }, +{ "List will be cleared before search","Liste wird vor der Suche gelöscht" }, { "","" }, { "","" }, { "","" }, { "","" }, { "","" }, { "","" }, { "","" },
\ No newline at end of file diff --git a/korganizer/searchdialog.cpp b/korganizer/searchdialog.cpp index 7b3b543..bba49f0 100644 --- a/korganizer/searchdialog.cpp +++ b/korganizer/searchdialog.cpp @@ -17,33 +17,33 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ #include <qlayout.h> #include <qcheckbox.h> #include <qgroupbox.h> #include <qlabel.h> #include <qlistview.h> #include <qwhatsthis.h> #include <qlineedit.h> #include <qpushbutton.h> - +#include <qhbuttongroup.h> #include <klocale.h> #include <kmessagebox.h> #include <libkdepim/kdateedit.h> #include "koglobals.h" #include "koprefs.h" #include "klineedit.h" #include "calendarview.h" #include "koviewmanager.h" #include "searchdialog.h" SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent) : QVBox( 0 ) @@ -54,40 +54,54 @@ SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent) // Search expression QHBoxLayout *subLayout = new QHBoxLayout(); layout->addLayout(subLayout); /* searchLabel = new QLabel(topFrame); searchLabel->setText(i18n("Search for:")); subLayout->addWidget(searchLabel); */ QPushButton *OkButton = new QPushButton( i18n("Search for:"), topFrame ); //OkButton->setDefault( true ); connect(OkButton,SIGNAL(clicked()),SLOT(doSearch())); subLayout->addWidget(OkButton); searchEdit = new KLineEdit(topFrame); 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 ); 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 & ))); connect(searchEdit, SIGNAL( returnPressed () ),this,SLOT(doSearch())); // Subjects to search // QGroupBox *subjectGroup = new QGroupBox(1,Vertical,i18n("Search In"), // topFrame); incidenceGroup = new QHBox( topFrame ); layout->addWidget(incidenceGroup); mSearchEvent = new QCheckBox(i18n("Events"),incidenceGroup); //mSearchEvent->setChecked(true); mSearchTodo = new QCheckBox(i18n("Todos"),incidenceGroup); mSearchJournal = new QCheckBox(i18n("Journals"),incidenceGroup); @@ -128,32 +142,59 @@ SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent) //listView->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Expanding) ); //listView->setMaximumHeight( 50 ); listView->readSettings(KOGlobals::config(),"SearchListView Layout"); connect(searchEdit,SIGNAL(scrollDOWN()),SLOT(setFocusToList())); setCaption( i18n("KO/Pi Find: ")); #ifdef DESKTOP_VERSION OkButton = new QPushButton( i18n("Close"), this ); connect(OkButton,SIGNAL(clicked()),SLOT(hide())); #endif } 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() ) { incidenceGroup->hide() ; subjectGroup->hide() ; attendeeGroup->hide() ; } else { incidenceGroup->show() ; subjectGroup->show() ; attendeeGroup->show() ; } } void SearchDialog::raiseAndSelect() { static int currentState = 0; @@ -281,193 +322,251 @@ void SearchDialog::updateView() } 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()*/ ); - 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()) { 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; } #if QT_VERSION >= 0x030000 if (re.search(ev->location()) != -1) #else if (re.match(ev->location()) != -1) #endif { + if ( mSubItems->isChecked() ) + mMatchedEvents.remove(ev); + else{ + if ( !mMatchedEvents.contains( ev ) ) mMatchedEvents.append(ev); + } continue; } } if (mDescriptionCheck->isChecked()) { #if QT_VERSION >= 0x030000 if (re.search(ev->description()) != -1) #else if (re.match(ev->description()) != -1) #endif { + if ( mSubItems->isChecked() ) + mMatchedEvents.remove(ev); + else{ + if ( !mMatchedEvents.contains( ev ) ) mMatchedEvents.append(ev); + } continue; } } if (mCategoryCheck->isChecked()) { #if QT_VERSION >= 0x030000 if (re.search(ev->categoriesStr()) != -1) #else if (re.match(ev->categoriesStr()) != -1) #endif { + + if ( mSubItems->isChecked() ) + mMatchedEvents.remove(ev); + else{ + if ( !mMatchedEvents.contains( ev ) ) 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 >= 0x030000 if (re.search(a->name()) != -1) #else if (re.match(a->name()) != -1) #endif { + if ( mSubItems->isChecked() ) + mMatchedEvents.remove(ev); + else{ + if ( !mMatchedEvents.contains( ev ) ) mMatchedEvents.append(ev); + } break; } } if (mSearchAEmail->isChecked()) { #if QT_VERSION >= 0x030000 if (re.search(a->email()) != -1) #else 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( ); - 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()) { 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; } } if (mDescriptionCheck->isChecked()) { #if QT_VERSION >= 0x030000 if (re.search(tod->description()) != -1) #else if (re.match(tod->description()) != -1) #endif { + if ( mSubItems->isChecked() ) + mMatchedTodos.remove(tod); + else if (!mMatchedTodos.contains( tod )) mMatchedTodos.append(tod); continue; } } if (mCategoryCheck->isChecked()) { #if QT_VERSION >= 0x030000 if (re.search(tod->categoriesStr()) != -1) #else if (re.match(tod->categoriesStr()) != -1) #endif { + if ( mSubItems->isChecked() ) + mMatchedTodos.remove(tod); + else if (!mMatchedTodos.contains( tod )) 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 >= 0x030000 if (re.search(a->name()) != -1) #else if (re.match(a->name()) != -1) #endif { + if ( mSubItems->isChecked() ) + mMatchedTodos.remove(tod); + else if (!mMatchedTodos.contains( tod )) mMatchedTodos.append(tod); break; } } if (mSearchAEmail->isChecked()) { #if QT_VERSION >= 0x030000 if (re.search(a->email()) != -1) #else if (re.match(a->email()) != -1) #endif { + if ( mSubItems->isChecked() ) + mMatchedTodos.remove(tod); + else if (!mMatchedTodos.contains( tod )) mMatchedTodos.append(tod); break; } } } } } } - 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; 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; } } } } } void SearchDialog::keyPressEvent ( QKeyEvent *e) { switch ( e->key() ) { case Qt::Key_Escape: close(); break; case Qt::Key_F: diff --git a/korganizer/searchdialog.h b/korganizer/searchdialog.h index b345b98..945ff65 100644 --- a/korganizer/searchdialog.h +++ b/korganizer/searchdialog.h @@ -12,33 +12,33 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ #ifndef SEARCHDIALOG_H #define SEARCHDIALOG_H #include <qregexp.h> - +#include <qradiobutton.h> #include <kdialogbase.h> #include <qvbox.h> #include <libkcal/calendar.h> #include "kolistview.h" class KDateEdit; class QCheckBox; class QLineEdit; class KLineEdit; class QLabel; class CalendarView; using namespace KCal; class SearchDialog : public QVBox @@ -48,52 +48,55 @@ class SearchDialog : public QVBox SearchDialog(Calendar *calendar,CalendarView *parent=0); virtual ~SearchDialog(); KOListView *listview(){ return listView;} void updateView(); void raiseAndSelect(); public slots: void changeEventDisplay(Event *, int) { updateView(); } void updateConfig(); void updateList(); protected slots: void setFocusToList(); void accept(); void doSearch(); void searchTextChanged( const QString &_text ); void toggleCheckboxes(); + void slot_add( bool ); + void slot_sub( bool ); + void slot_refine( bool ); signals: void showEventSignal(Event *); void editEventSignal(Event *); void deleteEventSignal(Event *); private: QHBox *incidenceGroup ,*subjectGroup ,*attendeeGroup; void search(const QRegExp &); Calendar *mCalendar; QPtrList<Event> mMatchedEvents; QPtrList<Todo> mMatchedTodos; QPtrList<Journal> mMatchedJournals; QLabel *searchLabel; KLineEdit *searchEdit; KOListView *listView; KDateEdit *mStartDate; KDateEdit *mEndDate; QCheckBox *mSummaryCheck; QCheckBox *mDescriptionCheck; QCheckBox *mCategoryCheck; QCheckBox *mSearchEvent; QCheckBox *mSearchTodo; QCheckBox *mSearchJournal; QCheckBox *mSearchAName; QCheckBox *mSearchAEmail; - QCheckBox *mAddItems; + QRadioButton *mAddItems, *mSubItems, *mRefineItems; void keyPressEvent ( QKeyEvent *e) ; }; #endif |