summaryrefslogtreecommitdiffabout
path: root/korganizer/searchdialog.cpp
Unidiff
Diffstat (limited to 'korganizer/searchdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/searchdialog.cpp43
1 files changed, 25 insertions, 18 deletions
diff --git a/korganizer/searchdialog.cpp b/korganizer/searchdialog.cpp
index 9cfdc35..105b844 100644
--- a/korganizer/searchdialog.cpp
+++ b/korganizer/searchdialog.cpp
@@ -15,55 +15,62 @@
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 <q3groupbox.h>
28#include <qapplication.h> 28#include <qapplication.h>
29#include <QDesktopWidget>
29#include <qlabel.h> 30#include <qlabel.h>
30#include <qlistview.h> 31#include <q3listview.h>
31#include <qwhatsthis.h> 32#include <q3whatsthis.h>
32#include <qlineedit.h> 33#include <qlineedit.h>
33#include <qpushbutton.h> 34#include <qpushbutton.h>
34#include <qhbuttongroup.h> 35//#include <qhbuttongroup.h>
36//Added by qt3to4:
37#include <Q3HBoxLayout>
38#include <Q3Frame>
39#include <Q3PtrList>
40#include <QKeyEvent>
41#include <Q3VBoxLayout>
35#include <klocale.h> 42#include <klocale.h>
36#include <kmessagebox.h> 43#include <kmessagebox.h>
37 44
38#include <libkdepim/kdateedit.h> 45#include <libkdepim/kdateedit.h>
39 46
40#include "koglobals.h" 47#include "koglobals.h"
41#include "koprefs.h" 48#include "koprefs.h"
42#include "klineedit.h" 49#include "klineedit.h"
43 50
44#include "calendarview.h" 51#include "calendarview.h"
45#include "koviewmanager.h" 52#include "koviewmanager.h"
46#include "searchdialog.h" 53#include "searchdialog.h"
47 54
48SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent) 55SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent)
49 : QVBox( 0 ) 56 : Q3VBox( 0 )
50 57
51{ 58{
52 mCalendar = calendar; 59 mCalendar = calendar;
53 QFrame *topFrame = new QFrame( this ) ;//plainPage(); 60 Q3Frame *topFrame = new Q3Frame( this ) ;//plainPage();
54 QVBoxLayout *layout = new QVBoxLayout(topFrame,KDialog::marginHint(),KDialog::spacingHint()); 61 Q3VBoxLayout *layout = new Q3VBoxLayout(topFrame,KDialog::marginHint(),KDialog::spacingHint());
55 62
56 // Search expression 63 // Search expression
57 QHBoxLayout *subLayout = new QHBoxLayout(); 64 Q3HBoxLayout *subLayout = new Q3HBoxLayout();
58 layout->addLayout(subLayout); 65 layout->addLayout(subLayout);
59 /* 66 /*
60 searchLabel = new QLabel(topFrame); 67 searchLabel = new QLabel(topFrame);
61 searchLabel->setText(i18n("Search for:")); 68 searchLabel->setText(i18n("Search for:"));
62 subLayout->addWidget(searchLabel); 69 subLayout->addWidget(searchLabel);
63 */ 70 */
64 QPushButton *OkButton = new QPushButton( i18n("Search for:"), topFrame ); 71 QPushButton *OkButton = new QPushButton( i18n("Search for:"), topFrame );
65 //OkButton->setDefault( true ); 72 //OkButton->setDefault( true );
66 connect(OkButton,SIGNAL(clicked()),SLOT(doSearch())); 73 connect(OkButton,SIGNAL(clicked()),SLOT(doSearch()));
67 subLayout->addWidget(OkButton); 74 subLayout->addWidget(OkButton);
68 searchEdit = new KLineEdit(topFrame); 75 searchEdit = new KLineEdit(topFrame);
69 subLayout->addWidget(searchEdit); 76 subLayout->addWidget(searchEdit);
@@ -89,62 +96,62 @@ SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent)
89 connect(togButton,SIGNAL(clicked()),SLOT(toggleCheckboxes())); 96 connect(togButton,SIGNAL(clicked()),SLOT(toggleCheckboxes()));
90 togButton->setPixmap(SmallIcon("1updownarrow")); 97 togButton->setPixmap(SmallIcon("1updownarrow"));
91 togButton->setMinimumWidth( togButton->sizeHint().height() ); 98 togButton->setMinimumWidth( togButton->sizeHint().height() );
92 99
93 searchEdit->setText("*"); // Find all events by default 100 searchEdit->setText("*"); // Find all events by default
94 searchEdit->setFocus(); 101 searchEdit->setFocus();
95 connect(searchEdit, SIGNAL(textChanged ( const QString & )),this,SLOT(searchTextChanged( const QString & ))); 102 connect(searchEdit, SIGNAL(textChanged ( const QString & )),this,SLOT(searchTextChanged( const QString & )));
96 connect(searchEdit, SIGNAL( returnPressed () ),this,SLOT(doSearch())); 103 connect(searchEdit, SIGNAL( returnPressed () ),this,SLOT(doSearch()));
97 // Subjects to search 104 // Subjects to search
98 // QGroupBox *subjectGroup = new QGroupBox(1,Vertical,i18n("Search In"), 105 // QGroupBox *subjectGroup = new QGroupBox(1,Vertical,i18n("Search In"),
99 // topFrame); 106 // topFrame);
100 107
101 incidenceGroup = new QHBox( topFrame ); 108 incidenceGroup = new Q3HBox( topFrame );
102 layout->addWidget(incidenceGroup); 109 layout->addWidget(incidenceGroup);
103 110
104 mSearchEvent = new QCheckBox(i18n("Events"),incidenceGroup); 111 mSearchEvent = new QCheckBox(i18n("Events"),incidenceGroup);
105 //mSearchEvent->setChecked(true); 112 //mSearchEvent->setChecked(true);
106 mSearchTodo = new QCheckBox(i18n("Todos"),incidenceGroup); 113 mSearchTodo = new QCheckBox(i18n("Todos"),incidenceGroup);
107 mSearchJournal = new QCheckBox(i18n("Journals"),incidenceGroup); 114 mSearchJournal = new QCheckBox(i18n("Journals"),incidenceGroup);
108 115
109 subjectGroup = new QHBox( topFrame ); 116 subjectGroup = new Q3HBox( topFrame );
110 layout->addWidget(subjectGroup); 117 layout->addWidget(subjectGroup);
111 118
112 mSummaryCheck = new QCheckBox(i18n("Summary/Loc."),subjectGroup); 119 mSummaryCheck = new QCheckBox(i18n("Summary/Loc."),subjectGroup);
113 mSummaryCheck->setChecked(true); 120 mSummaryCheck->setChecked(true);
114 mDescriptionCheck = new QCheckBox(i18n("Details"),subjectGroup); 121 mDescriptionCheck = new QCheckBox(i18n("Details"),subjectGroup);
115 mCategoryCheck = new QCheckBox(i18n("Categories"),subjectGroup); 122 mCategoryCheck = new QCheckBox(i18n("Categories"),subjectGroup);
116 123
117 attendeeGroup = new QHBox( topFrame ); 124 attendeeGroup = new Q3HBox( topFrame );
118 layout->addWidget(attendeeGroup ); 125 layout->addWidget(attendeeGroup );
119 new QLabel( i18n("Attendee:"),attendeeGroup ); 126 new QLabel( i18n("Attendee:"),attendeeGroup );
120 mSearchAName = new QCheckBox(i18n("Name"),attendeeGroup ); 127 mSearchAName = new QCheckBox(i18n("Name"),attendeeGroup );
121 mSearchAEmail = new QCheckBox(i18n("Email"), attendeeGroup ); 128 mSearchAEmail = new QCheckBox(i18n("Email"), attendeeGroup );
122 // Date range 129 // Date range
123 // QGroupBox *rangeGroup = new QGroupBox(1,Horizontal,i18n("Date Range"), 130 // QGroupBox *rangeGroup = new QGroupBox(1,Horizontal,i18n("Date Range"),
124 // topFrame); 131 // topFrame);
125 // layout->addWidget(rangeGroup); 132 // layout->addWidget(rangeGroup);
126 133
127 QWidget *rangeWidget = new QWidget(topFrame); 134 QWidget *rangeWidget = new QWidget(topFrame);
128 int space = KDialog::spacingHint(); 135 int space = KDialog::spacingHint();
129 if ( QApplication::desktop()->width() <= 240 ) space = 1; 136 if ( QApplication::desktop()->width() <= 240 ) space = 1;
130 QHBoxLayout *rangeLayout = new QHBoxLayout(rangeWidget,0,space); 137 Q3HBoxLayout *rangeLayout = new Q3HBoxLayout(rangeWidget,0,space);
131 rangeLayout->addWidget(new QLabel(i18n("From:"),rangeWidget)); 138 rangeLayout->addWidget(new QLabel(i18n("From:"),rangeWidget));
132 mStartDate = new KDateEdit(rangeWidget); 139 mStartDate = new KDateEdit(rangeWidget);
133 rangeLayout->addWidget(mStartDate); 140 rangeLayout->addWidget(mStartDate);
134 rangeLayout->addWidget(new QLabel(i18n("To:"),rangeWidget)); 141 rangeLayout->addWidget(new QLabel(i18n("To:"),rangeWidget));
135 mEndDate = new KDateEdit(rangeWidget); 142 mEndDate = new KDateEdit(rangeWidget);
136 mEndDate->setDate(QDate::currentDate().addDays(365)); 143 mEndDate->setDate(QDate::currentDate().addDays(365));
137 rangeLayout->addWidget(mEndDate); 144 rangeLayout->addWidget(mEndDate);
138 QToolButton *wt = QWhatsThis::whatsThisButton ( rangeWidget ); 145 QToolButton *wt = Q3WhatsThis::whatsThisButton ( rangeWidget );
139 rangeLayout->addWidget( (QWidget*)wt ); 146 rangeLayout->addWidget( (QWidget*)wt );
140 layout->addWidget(rangeWidget); 147 layout->addWidget(rangeWidget);
141 // Results list view 148 // Results list view
142 listView = new KOListView(mCalendar,topFrame); 149 listView = new KOListView(mCalendar,topFrame);
143 layout->addWidget(listView); 150 layout->addWidget(listView);
144 listView->showCompletedTodos(); 151 listView->showCompletedTodos();
145 //layout->setStretchFactor( listView, 333 ); 152 //layout->setStretchFactor( listView, 333 );
146 //listView->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Expanding) ); 153 //listView->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Expanding) );
147 //listView->setMaximumHeight( 50 ); 154 //listView->setMaximumHeight( 50 );
148 listView->readSettings(KOGlobals::config(),"SearchListView Layout"); 155 listView->readSettings(KOGlobals::config(),"SearchListView Layout");
149 connect(searchEdit,SIGNAL(scrollDOWN()),SLOT(setFocusToList())); 156 connect(searchEdit,SIGNAL(scrollDOWN()),SLOT(setFocusToList()));
150 157
@@ -332,25 +339,25 @@ void SearchDialog::updateView()
332 mMatchedJournals.clear(); 339 mMatchedJournals.clear();
333 if (re.isValid()) { 340 if (re.isValid()) {
334 search(re); 341 search(re);
335 } 342 }
336 listView->setStartDate( mStartDate->date() ); 343 listView->setStartDate( mStartDate->date() );
337 listView->showEvents(mMatchedEvents); 344 listView->showEvents(mMatchedEvents);
338 listView->addTodos(mMatchedTodos); 345 listView->addTodos(mMatchedTodos);
339 listView->addJournals(mMatchedJournals); 346 listView->addJournals(mMatchedJournals);
340} 347}
341 348
342void SearchDialog::search(const QRegExp &re) 349void SearchDialog::search(const QRegExp &re)
343{ 350{
344 QPtrList<Event> events; 351 Q3PtrList<Event> events;
345 if ( !mAddItems->isChecked() && !mSubItems->isChecked() ) { 352 if ( !mAddItems->isChecked() && !mSubItems->isChecked() ) {
346 if ( mRefineItems->isChecked() ) events = mMatchedEvents; 353 if ( mRefineItems->isChecked() ) events = mMatchedEvents;
347 mMatchedEvents.clear(); 354 mMatchedEvents.clear();
348 } 355 }
349 if ( mSearchEvent->isChecked() ) { 356 if ( mSearchEvent->isChecked() ) {
350 if ( !mRefineItems->isChecked() ) 357 if ( !mRefineItems->isChecked() )
351 events = mCalendar->events( mStartDate->date(), 358 events = mCalendar->events( mStartDate->date(),
352 mEndDate->date(), 359 mEndDate->date(),
353 false /*mInclusiveCheck->isChecked()*/ ); 360 false /*mInclusiveCheck->isChecked()*/ );
354 361
355 362
356 Event *ev; 363 Event *ev;
@@ -410,25 +417,25 @@ void SearchDialog::search(const QRegExp &re)
410 { 417 {
411 418
412 if ( mSubItems->isChecked() ) 419 if ( mSubItems->isChecked() )
413 mMatchedEvents.remove(ev); 420 mMatchedEvents.remove(ev);
414 else{ 421 else{
415 if ( !mMatchedEvents.contains( ev ) ) 422 if ( !mMatchedEvents.contains( ev ) )
416 mMatchedEvents.append(ev); 423 mMatchedEvents.append(ev);
417 } 424 }
418 continue; 425 continue;
419 } 426 }
420 } 427 }
421 if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) { 428 if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) {
422 QPtrList<Attendee> tmpAList = ev->attendees(); 429 Q3PtrList<Attendee> tmpAList = ev->attendees();
423 Attendee *a; 430 Attendee *a;
424 for (a = tmpAList.first(); a; a = tmpAList.next()) { 431 for (a = tmpAList.first(); a; a = tmpAList.next()) {
425 if (mSearchAName->isChecked()) { 432 if (mSearchAName->isChecked()) {
426#if QT_VERSION >= 0x030000 433#if QT_VERSION >= 0x030000
427 if (re.search(a->name()) != -1) 434 if (re.search(a->name()) != -1)
428#else 435#else
429 if (re.match(a->name()) != -1) 436 if (re.match(a->name()) != -1)
430#endif 437#endif
431 { 438 {
432 if ( mSubItems->isChecked() ) 439 if ( mSubItems->isChecked() )
433 mMatchedEvents.remove(ev); 440 mMatchedEvents.remove(ev);
434 else{ 441 else{
@@ -449,25 +456,25 @@ void SearchDialog::search(const QRegExp &re)
449 mMatchedEvents.remove(ev); 456 mMatchedEvents.remove(ev);
450 else{ 457 else{
451 if ( !mMatchedEvents.contains( ev ) ) 458 if ( !mMatchedEvents.contains( ev ) )
452 mMatchedEvents.append(ev); 459 mMatchedEvents.append(ev);
453 } 460 }
454 break; 461 break;
455 } 462 }
456 } 463 }
457 } 464 }
458 } 465 }
459 } 466 }
460 } 467 }
461 QPtrList<Todo> todos; 468 Q3PtrList<Todo> todos;
462 469
463 if ( !mAddItems->isChecked() && !mSubItems->isChecked() ) { 470 if ( !mAddItems->isChecked() && !mSubItems->isChecked() ) {
464 if ( mRefineItems->isChecked() ) todos = mMatchedTodos ; 471 if ( mRefineItems->isChecked() ) todos = mMatchedTodos ;
465 mMatchedTodos.clear(); 472 mMatchedTodos.clear();
466 } 473 }
467 474
468 if ( mSearchTodo->isChecked() ) { 475 if ( mSearchTodo->isChecked() ) {
469 if ( !mRefineItems->isChecked() ) todos = mCalendar->todos( ); 476 if ( !mRefineItems->isChecked() ) todos = mCalendar->todos( );
470 Todo *tod; 477 Todo *tod;
471 for(tod=todos.first();tod;tod=todos.next()) { 478 for(tod=todos.first();tod;tod=todos.next()) {
472 if (mSummaryCheck->isChecked()) { 479 if (mSummaryCheck->isChecked()) {
473#if QT_VERSION >= 0x030000 480#if QT_VERSION >= 0x030000
@@ -503,25 +510,25 @@ void SearchDialog::search(const QRegExp &re)
503#else 510#else
504 if (re.match(tod->categoriesStr()) != -1) 511 if (re.match(tod->categoriesStr()) != -1)
505#endif 512#endif
506 { 513 {
507 if ( mSubItems->isChecked() ) 514 if ( mSubItems->isChecked() )
508 mMatchedTodos.remove(tod); 515 mMatchedTodos.remove(tod);
509 else if (!mMatchedTodos.contains( tod )) 516 else if (!mMatchedTodos.contains( tod ))
510 mMatchedTodos.append(tod); 517 mMatchedTodos.append(tod);
511 continue; 518 continue;
512 } 519 }
513 } 520 }
514 if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) { 521 if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) {
515 QPtrList<Attendee> tmpAList = tod->attendees(); 522 Q3PtrList<Attendee> tmpAList = tod->attendees();
516 Attendee *a; 523 Attendee *a;
517 for (a = tmpAList.first(); a; a = tmpAList.next()) { 524 for (a = tmpAList.first(); a; a = tmpAList.next()) {
518 if (mSearchAName->isChecked()) { 525 if (mSearchAName->isChecked()) {
519#if QT_VERSION >= 0x030000 526#if QT_VERSION >= 0x030000
520 if (re.search(a->name()) != -1) 527 if (re.search(a->name()) != -1)
521#else 528#else
522 if (re.match(a->name()) != -1) 529 if (re.match(a->name()) != -1)
523#endif 530#endif
524 { 531 {
525 if ( mSubItems->isChecked() ) 532 if ( mSubItems->isChecked() )
526 mMatchedTodos.remove(tod); 533 mMatchedTodos.remove(tod);
527 else if (!mMatchedTodos.contains( tod )) 534 else if (!mMatchedTodos.contains( tod ))
@@ -539,25 +546,25 @@ void SearchDialog::search(const QRegExp &re)
539 if ( mSubItems->isChecked() ) 546 if ( mSubItems->isChecked() )
540 mMatchedTodos.remove(tod); 547 mMatchedTodos.remove(tod);
541 else if (!mMatchedTodos.contains( tod )) 548 else if (!mMatchedTodos.contains( tod ))
542 mMatchedTodos.append(tod); 549 mMatchedTodos.append(tod);
543 break; 550 break;
544 } 551 }
545 } 552 }
546 } 553 }
547 } 554 }
548 } 555 }
549 } 556 }
550 557
551 QPtrList<Journal> journals; 558 Q3PtrList<Journal> journals;
552 if ( !mAddItems->isChecked() && !mSubItems->isChecked() ) { 559 if ( !mAddItems->isChecked() && !mSubItems->isChecked() ) {
553 if ( mRefineItems->isChecked() ) journals = mMatchedJournals ; 560 if ( mRefineItems->isChecked() ) journals = mMatchedJournals ;
554 mMatchedJournals.clear(); 561 mMatchedJournals.clear();
555 } 562 }
556 if (mSearchJournal->isChecked() ) { 563 if (mSearchJournal->isChecked() ) {
557 if ( ! mRefineItems->isChecked() ) journals = mCalendar->journals(); 564 if ( ! mRefineItems->isChecked() ) journals = mCalendar->journals();
558 Journal* journ; 565 Journal* journ;
559 566
560 for(journ=journals.first();journ;journ=journals.next()) { 567 for(journ=journals.first();journ;journ=journals.next()) {
561 if ( journ->dtStart().date() <= mEndDate->date() 568 if ( journ->dtStart().date() <= mEndDate->date()
562 &&journ->dtStart().date() >= mStartDate->date()) { 569 &&journ->dtStart().date() >= mStartDate->date()) {
563 if (mDescriptionCheck->isChecked()) { 570 if (mDescriptionCheck->isChecked()) {