summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/searchdialog.cpp155
-rw-r--r--korganizer/searchdialog.h7
2 files changed, 132 insertions, 30 deletions
diff --git a/korganizer/searchdialog.cpp b/korganizer/searchdialog.cpp
index 7b3b543..bba49f0 100644
--- a/korganizer/searchdialog.cpp
+++ b/korganizer/searchdialog.cpp
@@ -9,93 +9,107 @@
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24 24
25#include <qlayout.h> 25#include <qlayout.h>
26#include <qcheckbox.h> 26#include <qcheckbox.h>
27#include <qgroupbox.h> 27#include <qgroupbox.h>
28#include <qlabel.h> 28#include <qlabel.h>
29#include <qlistview.h> 29#include <qlistview.h>
30#include <qwhatsthis.h> 30#include <qwhatsthis.h>
31#include <qlineedit.h> 31#include <qlineedit.h>
32#include <qpushbutton.h> 32#include <qpushbutton.h>
33 33#include <qhbuttongroup.h>
34#include <klocale.h> 34#include <klocale.h>
35#include <kmessagebox.h> 35#include <kmessagebox.h>
36 36
37#include <libkdepim/kdateedit.h> 37#include <libkdepim/kdateedit.h>
38 38
39#include "koglobals.h" 39#include "koglobals.h"
40#include "koprefs.h" 40#include "koprefs.h"
41#include "klineedit.h" 41#include "klineedit.h"
42 42
43#include "calendarview.h" 43#include "calendarview.h"
44#include "koviewmanager.h" 44#include "koviewmanager.h"
45#include "searchdialog.h" 45#include "searchdialog.h"
46 46
47SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent) 47SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent)
48 : QVBox( 0 ) 48 : QVBox( 0 )
49 49
50{ 50{
51 mCalendar = calendar; 51 mCalendar = calendar;
52 QFrame *topFrame = new QFrame( this ) ;//plainPage(); 52 QFrame *topFrame = new QFrame( this ) ;//plainPage();
53 QVBoxLayout *layout = new QVBoxLayout(topFrame,KDialog::marginHint(),KDialog::spacingHint()); 53 QVBoxLayout *layout = new QVBoxLayout(topFrame,KDialog::marginHint(),KDialog::spacingHint());
54 54
55 // Search expression 55 // Search expression
56 QHBoxLayout *subLayout = new QHBoxLayout(); 56 QHBoxLayout *subLayout = new QHBoxLayout();
57 layout->addLayout(subLayout); 57 layout->addLayout(subLayout);
58 /* 58 /*
59 searchLabel = new QLabel(topFrame); 59 searchLabel = new QLabel(topFrame);
60 searchLabel->setText(i18n("Search for:")); 60 searchLabel->setText(i18n("Search for:"));
61 subLayout->addWidget(searchLabel); 61 subLayout->addWidget(searchLabel);
62 */ 62 */
63 QPushButton *OkButton = new QPushButton( i18n("Search for:"), topFrame ); 63 QPushButton *OkButton = new QPushButton( i18n("Search for:"), topFrame );
64 //OkButton->setDefault( true ); 64 //OkButton->setDefault( true );
65 connect(OkButton,SIGNAL(clicked()),SLOT(doSearch())); 65 connect(OkButton,SIGNAL(clicked()),SLOT(doSearch()));
66 subLayout->addWidget(OkButton); 66 subLayout->addWidget(OkButton);
67 searchEdit = new KLineEdit(topFrame); 67 searchEdit = new KLineEdit(topFrame);
68 subLayout->addWidget(searchEdit); 68 subLayout->addWidget(searchEdit);
69 69
70 mAddItems = new QCheckBox(i18n("Add items"),topFrame); 70 mAddItems = new QRadioButton( "+ ", topFrame );
71 subLayout->addWidget(mAddItems); 71 mSubItems = new QRadioButton( "- ", topFrame );
72 mRefineItems = new QRadioButton( "< ", topFrame );
73 subLayout->addWidget( mAddItems );
74 subLayout->addWidget( mSubItems );
75 subLayout->addWidget( mRefineItems );
76 QFont fo ( mAddItems->font() );
77 fo.setBold( true );
78 fo.setPointSize( fo.pointSize() + 2 );
79 mAddItems->setFont( fo );
80 mSubItems->setFont( fo );
81 mRefineItems->setFont( fo );
82 connect( mAddItems , SIGNAL( toggled ( bool ) ),this,SLOT(slot_add( bool )));
83 connect( mSubItems , SIGNAL( toggled ( bool ) ),this,SLOT(slot_sub( bool )));
84 connect( mRefineItems , SIGNAL( toggled ( bool ) ),this,SLOT(slot_refine( bool )));
72 85
73 QPushButton *togButton = new QPushButton( "", topFrame ); 86 QPushButton *togButton = new QPushButton( "", topFrame );
74 subLayout->addWidget(togButton); 87 subLayout->addWidget(togButton);
75 connect(togButton,SIGNAL(clicked()),SLOT(toggleCheckboxes())); 88 connect(togButton,SIGNAL(clicked()),SLOT(toggleCheckboxes()));
76 togButton->setPixmap(SmallIcon("1updownarrow")); 89 togButton->setPixmap(SmallIcon("1updownarrow"));
77 togButton->setMinimumWidth( togButton->sizeHint().height() ); 90 togButton->setMinimumWidth( togButton->sizeHint().height() );
91
78 searchEdit->setText("*"); // Find all events by default 92 searchEdit->setText("*"); // Find all events by default
79 searchEdit->setFocus(); 93 searchEdit->setFocus();
80 connect(searchEdit, SIGNAL(textChanged ( const QString & )),this,SLOT(searchTextChanged( const QString & ))); 94 connect(searchEdit, SIGNAL(textChanged ( const QString & )),this,SLOT(searchTextChanged( const QString & )));
81 connect(searchEdit, SIGNAL( returnPressed () ),this,SLOT(doSearch())); 95 connect(searchEdit, SIGNAL( returnPressed () ),this,SLOT(doSearch()));
82 // Subjects to search 96 // Subjects to search
83 // QGroupBox *subjectGroup = new QGroupBox(1,Vertical,i18n("Search In"), 97 // QGroupBox *subjectGroup = new QGroupBox(1,Vertical,i18n("Search In"),
84 // topFrame); 98 // topFrame);
85 99
86 incidenceGroup = new QHBox( topFrame ); 100 incidenceGroup = new QHBox( topFrame );
87 layout->addWidget(incidenceGroup); 101 layout->addWidget(incidenceGroup);
88 102
89 mSearchEvent = new QCheckBox(i18n("Events"),incidenceGroup); 103 mSearchEvent = new QCheckBox(i18n("Events"),incidenceGroup);
90 //mSearchEvent->setChecked(true); 104 //mSearchEvent->setChecked(true);
91 mSearchTodo = new QCheckBox(i18n("Todos"),incidenceGroup); 105 mSearchTodo = new QCheckBox(i18n("Todos"),incidenceGroup);
92 mSearchJournal = new QCheckBox(i18n("Journals"),incidenceGroup); 106 mSearchJournal = new QCheckBox(i18n("Journals"),incidenceGroup);
93 107
94 subjectGroup = new QHBox( topFrame ); 108 subjectGroup = new QHBox( topFrame );
95 layout->addWidget(subjectGroup); 109 layout->addWidget(subjectGroup);
96 110
97 mSummaryCheck = new QCheckBox(i18n("Summary/Loc."),subjectGroup); 111 mSummaryCheck = new QCheckBox(i18n("Summary/Loc."),subjectGroup);
98 mSummaryCheck->setChecked(true); 112 mSummaryCheck->setChecked(true);
99 mDescriptionCheck = new QCheckBox(i18n("Details"),subjectGroup); 113 mDescriptionCheck = new QCheckBox(i18n("Details"),subjectGroup);
100 mCategoryCheck = new QCheckBox(i18n("Categories"),subjectGroup); 114 mCategoryCheck = new QCheckBox(i18n("Categories"),subjectGroup);
101 115
@@ -120,48 +134,75 @@ SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent)
120 rangeLayout->addWidget(mEndDate); 134 rangeLayout->addWidget(mEndDate);
121 QToolButton *wt = QWhatsThis::whatsThisButton ( rangeWidget ); 135 QToolButton *wt = QWhatsThis::whatsThisButton ( rangeWidget );
122 rangeLayout->addWidget( (QWidget*)wt ); 136 rangeLayout->addWidget( (QWidget*)wt );
123 layout->addWidget(rangeWidget); 137 layout->addWidget(rangeWidget);
124 // Results list view 138 // Results list view
125 listView = new KOListView(mCalendar,topFrame); 139 listView = new KOListView(mCalendar,topFrame);
126 layout->addWidget(listView); 140 layout->addWidget(listView);
127 //layout->setStretchFactor( listView, 333 ); 141 //layout->setStretchFactor( listView, 333 );
128 //listView->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Expanding) ); 142 //listView->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Expanding) );
129 //listView->setMaximumHeight( 50 ); 143 //listView->setMaximumHeight( 50 );
130 listView->readSettings(KOGlobals::config(),"SearchListView Layout"); 144 listView->readSettings(KOGlobals::config(),"SearchListView Layout");
131 connect(searchEdit,SIGNAL(scrollDOWN()),SLOT(setFocusToList())); 145 connect(searchEdit,SIGNAL(scrollDOWN()),SLOT(setFocusToList()));
132 146
133 setCaption( i18n("KO/Pi Find: ")); 147 setCaption( i18n("KO/Pi Find: "));
134#ifdef DESKTOP_VERSION 148#ifdef DESKTOP_VERSION
135 OkButton = new QPushButton( i18n("Close"), this ); 149 OkButton = new QPushButton( i18n("Close"), this );
136 connect(OkButton,SIGNAL(clicked()),SLOT(hide())); 150 connect(OkButton,SIGNAL(clicked()),SLOT(hide()));
137#endif 151#endif
138} 152}
139 153
140SearchDialog::~SearchDialog() 154SearchDialog::~SearchDialog()
141{ 155{
142 156
143} 157}
158void SearchDialog::slot_add( bool b )
159{
160 if ( b ) {
161 if ( mSubItems->isOn() ) mSubItems->toggle();
162 if ( mRefineItems->isOn() ) mRefineItems->toggle();
163 setCaption( i18n("Matching items will be added to list"));
164 } else
165 setCaption( i18n("List will be cleared before search"));
166}
167void SearchDialog::slot_sub( bool b)
168{
169 if ( b ) {
170 if ( mRefineItems->isOn() ) mRefineItems->toggle();
171 if ( mAddItems->isOn() ) mAddItems->toggle();
172 setCaption( i18n("Matching items will be removed from list"));
173 } else
174 setCaption( i18n("List will be cleared before search"));
175}
176void SearchDialog::slot_refine( bool b)
177{
178 if ( b ) {
179 if ( mSubItems->isOn() ) mSubItems->toggle();
180 if ( mAddItems->isOn() ) mAddItems->toggle();
181 setCaption( i18n("Search on displayed list only"));
182 } else
183 setCaption( i18n("List will be cleared before search"));
184}
144void SearchDialog::toggleCheckboxes() 185void SearchDialog::toggleCheckboxes()
145{ 186{
146 if ( incidenceGroup->isVisible() ) { 187 if ( incidenceGroup->isVisible() ) {
147 incidenceGroup->hide() ; 188 incidenceGroup->hide() ;
148 subjectGroup->hide() ; 189 subjectGroup->hide() ;
149 attendeeGroup->hide() ; 190 attendeeGroup->hide() ;
150 } else { 191 } else {
151 incidenceGroup->show() ; 192 incidenceGroup->show() ;
152 subjectGroup->show() ; 193 subjectGroup->show() ;
153 attendeeGroup->show() ; 194 attendeeGroup->show() ;
154 } 195 }
155} 196}
156void SearchDialog::raiseAndSelect() 197void SearchDialog::raiseAndSelect()
157{ 198{
158 199
159 static int currentState = 0; 200 static int currentState = 0;
160 201
161 if ( !mSearchJournal->isChecked() && !mSearchTodo->isChecked() && !mSearchEvent->isChecked() ) 202 if ( !mSearchJournal->isChecked() && !mSearchTodo->isChecked() && !mSearchEvent->isChecked() )
162 currentState = 0; 203 currentState = 0;
163 int newState = 0; 204 int newState = 0;
164 if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) { 205 if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) {
165 newState = VIEW_J_VIEW; 206 newState = VIEW_J_VIEW;
166 } 207 }
167 else if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) { 208 else if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) {
@@ -273,210 +314,268 @@ void SearchDialog::updateView()
273 re.setWildcard(true); // most people understand these better. 314 re.setWildcard(true); // most people understand these better.
274 re.setCaseSensitive(false); 315 re.setCaseSensitive(false);
275 QString st = searchEdit->text(); 316 QString st = searchEdit->text();
276 if ( st.right(1) != "*") 317 if ( st.right(1) != "*")
277 st += "*"; 318 st += "*";
278 re.setPattern(st); 319 re.setPattern(st);
279 if (re.isValid()) { 320 if (re.isValid()) {
280 search(re); 321 search(re);
281 } else { 322 } else {
282 mMatchedEvents.clear(); 323 mMatchedEvents.clear();
283 mMatchedTodos.clear(); 324 mMatchedTodos.clear();
284 mMatchedJournals.clear(); 325 mMatchedJournals.clear();
285 } 326 }
286 listView->setStartDate( mStartDate->date() ); 327 listView->setStartDate( mStartDate->date() );
287 listView->showEvents(mMatchedEvents); 328 listView->showEvents(mMatchedEvents);
288 listView->addTodos(mMatchedTodos); 329 listView->addTodos(mMatchedTodos);
289 listView->addJournals(mMatchedJournals); 330 listView->addJournals(mMatchedJournals);
290} 331}
291 332
292void SearchDialog::search(const QRegExp &re) 333void SearchDialog::search(const QRegExp &re)
293{ 334{
294 QPtrList<Event> events = mCalendar->events( mStartDate->date(), 335 QPtrList<Event> events = mCalendar->events( mStartDate->date(),
295 mEndDate->date(), 336 mEndDate->date(),
296 false /*mInclusiveCheck->isChecked()*/ ); 337 false /*mInclusiveCheck->isChecked()*/ );
297 if ( !mAddItems->isChecked() ) 338 if ( !mAddItems->isChecked() && !mSubItems->isChecked() ) {
339 if ( mRefineItems->isChecked() ) events = mMatchedEvents;
298 mMatchedEvents.clear(); 340 mMatchedEvents.clear();
341 }
299 if ( mSearchEvent->isChecked() ) { 342 if ( mSearchEvent->isChecked() ) {
300 Event *ev; 343 Event *ev;
301 for(ev=events.first();ev;ev=events.next()) { 344 for(ev=events.first();ev;ev=events.next()) {
302 if (mSummaryCheck->isChecked()) { 345 if (mSummaryCheck->isChecked()) {
303#if QT_VERSION >= 0x030000 346#if QT_VERSION >= 0x030000
304 if (re.search(ev->summary()) != -1) 347 if (re.search(ev->summary()) != -1)
305#else 348#else
306 if (re.match(ev->summary()) != -1) 349 if (re.match(ev->summary()) != -1)
307#endif 350#endif
308 { 351 {
309 mMatchedEvents.append(ev); 352 if ( mSubItems->isChecked() )
353 mMatchedEvents.remove(ev);
354 else {
355 if ( !mMatchedEvents.contains( ev ) )
356 mMatchedEvents.append(ev);
357 }
310 continue; 358 continue;
311 } 359 }
312#if QT_VERSION >= 0x030000 360#if QT_VERSION >= 0x030000
313 if (re.search(ev->location()) != -1) 361 if (re.search(ev->location()) != -1)
314#else 362#else
315 if (re.match(ev->location()) != -1) 363 if (re.match(ev->location()) != -1)
316#endif 364#endif
317 { 365 {
318 mMatchedEvents.append(ev); 366 if ( mSubItems->isChecked() )
367 mMatchedEvents.remove(ev);
368 else{
369 if ( !mMatchedEvents.contains( ev ) )
370 mMatchedEvents.append(ev);
371 }
319 continue; 372 continue;
320 } 373 }
321 } 374 }
322 if (mDescriptionCheck->isChecked()) { 375 if (mDescriptionCheck->isChecked()) {
323#if QT_VERSION >= 0x030000 376#if QT_VERSION >= 0x030000
324 if (re.search(ev->description()) != -1) 377 if (re.search(ev->description()) != -1)
325#else 378#else
326 if (re.match(ev->description()) != -1) 379 if (re.match(ev->description()) != -1)
327#endif 380#endif
328 { 381 {
329 mMatchedEvents.append(ev); 382 if ( mSubItems->isChecked() )
383 mMatchedEvents.remove(ev);
384 else{
385 if ( !mMatchedEvents.contains( ev ) )
386 mMatchedEvents.append(ev);
387 }
330 continue; 388 continue;
331 } 389 }
332 } 390 }
333 if (mCategoryCheck->isChecked()) { 391 if (mCategoryCheck->isChecked()) {
334#if QT_VERSION >= 0x030000 392#if QT_VERSION >= 0x030000
335 if (re.search(ev->categoriesStr()) != -1) 393 if (re.search(ev->categoriesStr()) != -1)
336#else 394#else
337 if (re.match(ev->categoriesStr()) != -1) 395 if (re.match(ev->categoriesStr()) != -1)
338#endif 396#endif
339 { 397 {
340 mMatchedEvents.append(ev); 398
399 if ( mSubItems->isChecked() )
400 mMatchedEvents.remove(ev);
401 else{
402 if ( !mMatchedEvents.contains( ev ) )
403 mMatchedEvents.append(ev);
404 }
341 continue; 405 continue;
342 } 406 }
343 } 407 }
344 if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) { 408 if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) {
345 QPtrList<Attendee> tmpAList = ev->attendees(); 409 QPtrList<Attendee> tmpAList = ev->attendees();
346 Attendee *a; 410 Attendee *a;
347 for (a = tmpAList.first(); a; a = tmpAList.next()) { 411 for (a = tmpAList.first(); a; a = tmpAList.next()) {
348 if (mSearchAName->isChecked()) { 412 if (mSearchAName->isChecked()) {
349#if QT_VERSION >= 0x030000 413#if QT_VERSION >= 0x030000
350 if (re.search(a->name()) != -1) 414 if (re.search(a->name()) != -1)
351#else 415#else
352 if (re.match(a->name()) != -1) 416 if (re.match(a->name()) != -1)
353#endif 417#endif
354 { 418 {
355 mMatchedEvents.append(ev); 419 if ( mSubItems->isChecked() )
420 mMatchedEvents.remove(ev);
421 else{
422 if ( !mMatchedEvents.contains( ev ) )
423 mMatchedEvents.append(ev);
424 }
356 break; 425 break;
357 } 426 }
358 } 427 }
359 if (mSearchAEmail->isChecked()) { 428 if (mSearchAEmail->isChecked()) {
360#if QT_VERSION >= 0x030000 429#if QT_VERSION >= 0x030000
361 if (re.search(a->email()) != -1) 430 if (re.search(a->email()) != -1)
362#else 431#else
363 if (re.match(a->email()) != -1) 432 if (re.match(a->email()) != -1)
364#endif 433#endif
365 { 434 {
366 mMatchedEvents.append(ev); 435 if ( mSubItems->isChecked() )
436 mMatchedEvents.remove(ev);
437 else{
438 if ( !mMatchedEvents.contains( ev ) )
439 mMatchedEvents.append(ev);
440 }
367 break; 441 break;
368 } 442 }
369 } 443 }
370 } 444 }
371 } 445 }
372 } 446 }
373 } 447 }
374 QPtrList<Todo> todos = mCalendar->todos( ); 448 QPtrList<Todo> todos = mCalendar->todos( );
375 if ( !mAddItems->isChecked() ) 449
450 if ( !mAddItems->isChecked() && !mSubItems->isChecked() ) {
451 if ( mRefineItems->isChecked() ) todos = mMatchedTodos ;
376 mMatchedTodos.clear(); 452 mMatchedTodos.clear();
453 }
454
377 if ( mSearchTodo->isChecked() ) { 455 if ( mSearchTodo->isChecked() ) {
378 Todo *tod; 456 Todo *tod;
379 for(tod=todos.first();tod;tod=todos.next()) { 457 for(tod=todos.first();tod;tod=todos.next()) {
380 if (mSummaryCheck->isChecked()) { 458 if (mSummaryCheck->isChecked()) {
381#if QT_VERSION >= 0x030000 459#if QT_VERSION >= 0x030000
382 if (re.search(tod->summary()) != -1) 460 if (re.search(tod->summary()) != -1)
383#else 461#else
384 if (re.match(tod->summary()) != -1) 462 if (re.match(tod->summary()) != -1)
385#endif 463#endif
386 { 464 {
387 mMatchedTodos.append(tod); 465 if ( mSubItems->isChecked() )
466 mMatchedTodos.remove(tod);
467 else if (!mMatchedTodos.contains( tod ))
468 mMatchedTodos.append(tod);
388 continue; 469 continue;
389 } 470 }
390 } 471 }
391 if (mDescriptionCheck->isChecked()) { 472 if (mDescriptionCheck->isChecked()) {
392#if QT_VERSION >= 0x030000 473#if QT_VERSION >= 0x030000
393 if (re.search(tod->description()) != -1) 474 if (re.search(tod->description()) != -1)
394#else 475#else
395 if (re.match(tod->description()) != -1) 476 if (re.match(tod->description()) != -1)
396#endif 477#endif
397 { 478 {
398 mMatchedTodos.append(tod); 479 if ( mSubItems->isChecked() )
480 mMatchedTodos.remove(tod);
481 else if (!mMatchedTodos.contains( tod ))
482 mMatchedTodos.append(tod);
399 continue; 483 continue;
400 } 484 }
401 } 485 }
402 if (mCategoryCheck->isChecked()) { 486 if (mCategoryCheck->isChecked()) {
403#if QT_VERSION >= 0x030000 487#if QT_VERSION >= 0x030000
404 if (re.search(tod->categoriesStr()) != -1) 488 if (re.search(tod->categoriesStr()) != -1)
405#else 489#else
406 if (re.match(tod->categoriesStr()) != -1) 490 if (re.match(tod->categoriesStr()) != -1)
407#endif 491#endif
408 { 492 {
409 mMatchedTodos.append(tod); 493 if ( mSubItems->isChecked() )
494 mMatchedTodos.remove(tod);
495 else if (!mMatchedTodos.contains( tod ))
496 mMatchedTodos.append(tod);
410 continue; 497 continue;
411 } 498 }
412 } 499 }
413 if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) { 500 if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) {
414 QPtrList<Attendee> tmpAList = tod->attendees(); 501 QPtrList<Attendee> tmpAList = tod->attendees();
415 Attendee *a; 502 Attendee *a;
416 for (a = tmpAList.first(); a; a = tmpAList.next()) { 503 for (a = tmpAList.first(); a; a = tmpAList.next()) {
417 if (mSearchAName->isChecked()) { 504 if (mSearchAName->isChecked()) {
418#if QT_VERSION >= 0x030000 505#if QT_VERSION >= 0x030000
419 if (re.search(a->name()) != -1) 506 if (re.search(a->name()) != -1)
420#else 507#else
421 if (re.match(a->name()) != -1) 508 if (re.match(a->name()) != -1)
422#endif 509#endif
423 { 510 {
424 mMatchedTodos.append(tod); 511 if ( mSubItems->isChecked() )
512 mMatchedTodos.remove(tod);
513 else if (!mMatchedTodos.contains( tod ))
514 mMatchedTodos.append(tod);
425 break; 515 break;
426 } 516 }
427 } 517 }
428 if (mSearchAEmail->isChecked()) { 518 if (mSearchAEmail->isChecked()) {
429#if QT_VERSION >= 0x030000 519#if QT_VERSION >= 0x030000
430 if (re.search(a->email()) != -1) 520 if (re.search(a->email()) != -1)
431#else 521#else
432 if (re.match(a->email()) != -1) 522 if (re.match(a->email()) != -1)
433#endif 523#endif
434 { 524 {
435 mMatchedTodos.append(tod); 525 if ( mSubItems->isChecked() )
526 mMatchedTodos.remove(tod);
527 else if (!mMatchedTodos.contains( tod ))
528 mMatchedTodos.append(tod);
436 break; 529 break;
437 } 530 }
438 } 531 }
439 } 532 }
440 } 533 }
441 } 534 }
442 } 535 }
443 if ( !mAddItems->isChecked() ) 536
537 QPtrList<Journal> journals = mCalendar->journals( );
538 if ( !mAddItems->isChecked() && !mSubItems->isChecked() ) {
539 if ( mRefineItems->isChecked() ) journals = mMatchedJournals ;
444 mMatchedJournals.clear(); 540 mMatchedJournals.clear();
541 }
445 if (mSearchJournal->isChecked() ) { 542 if (mSearchJournal->isChecked() ) {
446 QPtrList<Journal> journals = mCalendar->journals( );
447 Journal* journ; 543 Journal* journ;
448 544
449 for(journ=journals.first();journ;journ=journals.next()) { 545 for(journ=journals.first();journ;journ=journals.next()) {
450 if ( journ->dtStart().date() <= mEndDate->date() 546 if ( journ->dtStart().date() <= mEndDate->date()
451 &&journ->dtStart().date() >= mStartDate->date()) { 547 &&journ->dtStart().date() >= mStartDate->date()) {
452#if QT_VERSION >= 0x030000 548#if QT_VERSION >= 0x030000
453 if (re.search(journ->description()) != -1) 549 if (re.search(journ->description()) != -1)
454#else 550#else
455 if (re.match(journ->description()) != -1) 551 if (re.match(journ->description()) != -1)
456#endif 552#endif
457 { 553 {
458 mMatchedJournals.append(journ); 554 if ( mSubItems->isChecked() )
555 mMatchedJournals.remove(journ);
556 else if (!mMatchedJournals.contains( journ ))
557 mMatchedJournals.append(journ);
459 continue; 558 continue;
460 } 559 }
461 } 560 }
462 } 561 }
463 } 562 }
464 563
465} 564}
466 565
467void SearchDialog::keyPressEvent ( QKeyEvent *e) 566void SearchDialog::keyPressEvent ( QKeyEvent *e)
468{ 567{
469 switch ( e->key() ) { 568 switch ( e->key() ) {
470 case Qt::Key_Escape: 569 case Qt::Key_Escape:
471 close(); 570 close();
472 break; 571 break;
473 case Qt::Key_F: 572 case Qt::Key_F:
474 if ( e->state() == Qt::ControlButton ) { 573 if ( e->state() == Qt::ControlButton ) {
475 574
476 } 575 }
477 break; 576 break;
478 case Qt::Key_Return: 577 case Qt::Key_Return:
479 case Qt::Key_Enter: 578 case Qt::Key_Enter:
480 doSearch(); 579 doSearch();
481 break; 580 break;
482 581
diff --git a/korganizer/searchdialog.h b/korganizer/searchdialog.h
index b345b98..945ff65 100644
--- a/korganizer/searchdialog.h
+++ b/korganizer/searchdialog.h
@@ -4,96 +4,99 @@
4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24#ifndef SEARCHDIALOG_H 24#ifndef SEARCHDIALOG_H
25#define SEARCHDIALOG_H 25#define SEARCHDIALOG_H
26 26
27#include <qregexp.h> 27#include <qregexp.h>
28 28#include <qradiobutton.h>
29#include <kdialogbase.h> 29#include <kdialogbase.h>
30#include <qvbox.h> 30#include <qvbox.h>
31 31
32#include <libkcal/calendar.h> 32#include <libkcal/calendar.h>
33 33
34#include "kolistview.h" 34#include "kolistview.h"
35 35
36class KDateEdit; 36class KDateEdit;
37class QCheckBox; 37class QCheckBox;
38class QLineEdit; 38class QLineEdit;
39class KLineEdit; 39class KLineEdit;
40class QLabel; 40class QLabel;
41class CalendarView; 41class CalendarView;
42 42
43using namespace KCal; 43using namespace KCal;
44class SearchDialog : public QVBox 44class SearchDialog : public QVBox
45{ 45{
46 Q_OBJECT 46 Q_OBJECT
47 public: 47 public:
48 SearchDialog(Calendar *calendar,CalendarView *parent=0); 48 SearchDialog(Calendar *calendar,CalendarView *parent=0);
49 virtual ~SearchDialog(); 49 virtual ~SearchDialog();
50 KOListView *listview(){ return listView;} 50 KOListView *listview(){ return listView;}
51 void updateView(); 51 void updateView();
52 void raiseAndSelect(); 52 void raiseAndSelect();
53 53
54 public slots: 54 public slots:
55 void changeEventDisplay(Event *, int) { updateView(); } 55 void changeEventDisplay(Event *, int) { updateView(); }
56 void updateConfig(); 56 void updateConfig();
57 void updateList(); 57 void updateList();
58 protected slots: 58 protected slots:
59 void setFocusToList(); 59 void setFocusToList();
60 void accept(); 60 void accept();
61 void doSearch(); 61 void doSearch();
62 void searchTextChanged( const QString &_text ); 62 void searchTextChanged( const QString &_text );
63 void toggleCheckboxes(); 63 void toggleCheckboxes();
64 void slot_add( bool );
65 void slot_sub( bool );
66 void slot_refine( bool );
64 67
65 signals: 68 signals:
66 void showEventSignal(Event *); 69 void showEventSignal(Event *);
67 void editEventSignal(Event *); 70 void editEventSignal(Event *);
68 void deleteEventSignal(Event *); 71 void deleteEventSignal(Event *);
69 72
70 private: 73 private:
71 74
72 QHBox *incidenceGroup ,*subjectGroup ,*attendeeGroup; 75 QHBox *incidenceGroup ,*subjectGroup ,*attendeeGroup;
73 void search(const QRegExp &); 76 void search(const QRegExp &);
74 77
75 Calendar *mCalendar; 78 Calendar *mCalendar;
76 79
77 QPtrList<Event> mMatchedEvents; 80 QPtrList<Event> mMatchedEvents;
78 QPtrList<Todo> mMatchedTodos; 81 QPtrList<Todo> mMatchedTodos;
79 QPtrList<Journal> mMatchedJournals; 82 QPtrList<Journal> mMatchedJournals;
80 83
81 QLabel *searchLabel; 84 QLabel *searchLabel;
82 KLineEdit *searchEdit; 85 KLineEdit *searchEdit;
83 KOListView *listView; 86 KOListView *listView;
84 87
85 KDateEdit *mStartDate; 88 KDateEdit *mStartDate;
86 KDateEdit *mEndDate; 89 KDateEdit *mEndDate;
87 QCheckBox *mSummaryCheck; 90 QCheckBox *mSummaryCheck;
88 QCheckBox *mDescriptionCheck; 91 QCheckBox *mDescriptionCheck;
89 QCheckBox *mCategoryCheck; 92 QCheckBox *mCategoryCheck;
90 QCheckBox *mSearchEvent; 93 QCheckBox *mSearchEvent;
91 QCheckBox *mSearchTodo; 94 QCheckBox *mSearchTodo;
92 QCheckBox *mSearchJournal; 95 QCheckBox *mSearchJournal;
93 QCheckBox *mSearchAName; 96 QCheckBox *mSearchAName;
94 QCheckBox *mSearchAEmail; 97 QCheckBox *mSearchAEmail;
95 QCheckBox *mAddItems; 98 QRadioButton *mAddItems, *mSubItems, *mRefineItems;
96 void keyPressEvent ( QKeyEvent *e) ; 99 void keyPressEvent ( QKeyEvent *e) ;
97}; 100};
98 101
99#endif 102#endif