summaryrefslogtreecommitdiffabout
path: root/korganizer
Side-by-side diff
Diffstat (limited to 'korganizer') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/searchdialog.cpp111
-rw-r--r--korganizer/searchdialog.h7
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
@@ -29,9 +29,9 @@
#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>
@@ -66,16 +66,30 @@ SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent)
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()));
@@ -140,8 +154,35 @@ SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent)
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() ;
@@ -293,10 +334,12 @@ 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()) {
@@ -305,18 +348,28 @@ void SearchDialog::search(const QRegExp &re)
#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()) {
@@ -325,9 +378,14 @@ void SearchDialog::search(const QRegExp &re)
#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()) {
@@ -336,9 +394,15 @@ void SearchDialog::search(const QRegExp &re)
#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() ) {
@@ -351,9 +415,14 @@ void SearchDialog::search(const QRegExp &re)
#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()) {
@@ -362,19 +431,28 @@ void SearchDialog::search(const QRegExp &re)
#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()) {
@@ -383,8 +461,11 @@ void SearchDialog::search(const QRegExp &re)
#else
if (re.match(tod->summary()) != -1)
#endif
{
+ 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
{
+ 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
{
+ 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
{
+ if ( mSubItems->isChecked() )
+ mMatchedTodos.remove(tod);
+ else if (!mMatchedTodos.contains( tod ))
mMatchedTodos.append(tod);
break;
}
}
@@ -431,20 +521,26 @@ 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;
}
}
}
}
}
}
- 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()
@@ -454,8 +550,11 @@ void SearchDialog::search(const QRegExp &re)
#else
if (re.match(journ->description()) != -1)
#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
@@ -24,9 +24,9 @@
#ifndef SEARCHDIALOG_H
#define SEARCHDIALOG_H
#include <qregexp.h>
-
+#include <qradiobutton.h>
#include <kdialogbase.h>
#include <qvbox.h>
#include <libkcal/calendar.h>
@@ -60,8 +60,11 @@ class SearchDialog : public QVBox
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 *);
@@ -91,9 +94,9 @@ class SearchDialog : public QVBox
QCheckBox *mSearchTodo;
QCheckBox *mSearchJournal;
QCheckBox *mSearchAName;
QCheckBox *mSearchAEmail;
- QCheckBox *mAddItems;
+ QRadioButton *mAddItems, *mSubItems, *mRefineItems;
void keyPressEvent ( QKeyEvent *e) ;
};
#endif