summaryrefslogtreecommitdiffabout
path: root/korganizer/searchdialog.cpp
Unidiff
Diffstat (limited to 'korganizer/searchdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/searchdialog.cpp72
1 files changed, 38 insertions, 34 deletions
diff --git a/korganizer/searchdialog.cpp b/korganizer/searchdialog.cpp
index 3fd9740..aa1b244 100644
--- a/korganizer/searchdialog.cpp
+++ b/korganizer/searchdialog.cpp
@@ -17,67 +17,69 @@
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 <qwhatsthis.h>
29#include <qlineedit.h> 30#include <qlineedit.h>
30#include <qpushbutton.h> 31#include <qpushbutton.h>
31 32
32#include <klocale.h> 33#include <klocale.h>
33#include <kmessagebox.h> 34#include <kmessagebox.h>
34 35
35#include <libkdepim/kdateedit.h> 36#include <libkdepim/kdateedit.h>
36 37
37#include "koglobals.h" 38#include "koglobals.h"
38#include "koprefs.h" 39#include "koprefs.h"
39 40
40#include "calendarview.h" 41#include "calendarview.h"
41#include "koviewmanager.h" 42#include "koviewmanager.h"
42#include "searchdialog.h" 43#include "searchdialog.h"
43 44
44SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent) 45SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent)
45 : KDialogBase(Plain,i18n("KO/Pi Find "),User1|Close,User1,parent,0,false,false, 46 : QVBox( 0 )
46 i18n("&Find")) 47
47{ 48{
48 mCalendar = calendar; 49 mCalendar = calendar;
49 QFrame *topFrame = plainPage(); 50 QFrame *topFrame = new QFrame( this ) ;//plainPage();
50 QVBoxLayout *layout = new QVBoxLayout(topFrame,0,spacingHint()); 51 QVBoxLayout *layout = new QVBoxLayout(topFrame,KDialog::marginHint(),KDialog::spacingHint());
51 52
52 // Search expression 53 // Search expression
53 QHBoxLayout *subLayout = new QHBoxLayout(); 54 QHBoxLayout *subLayout = new QHBoxLayout();
54 layout->addLayout(subLayout); 55 layout->addLayout(subLayout);
55
56 searchLabel = new QLabel(topFrame); 56 searchLabel = new QLabel(topFrame);
57 searchLabel->setText(i18n("Search for:")); 57 searchLabel->setText(i18n("Search for:"));
58 subLayout->addWidget(searchLabel); 58 subLayout->addWidget(searchLabel);
59 59
60 searchEdit = new QLineEdit(topFrame); 60 searchEdit = new QLineEdit(topFrame);
61 subLayout->addWidget(searchEdit); 61 subLayout->addWidget(searchEdit);
62 QPushButton *OkButton = new QPushButton( i18n("&Find"), topFrame );
63 //OkButton->setDefault( true );
64 connect(OkButton,SIGNAL(clicked()),SLOT(doSearch()));
65 subLayout->addWidget(OkButton);
62 searchEdit->setText("*"); // Find all events by default 66 searchEdit->setText("*"); // Find all events by default
63 searchEdit->setFocus(); 67 searchEdit->setFocus();
64 connect(searchEdit, SIGNAL(textChanged ( const QString & )),this,SLOT(searchTextChanged( const QString & ))); 68 connect(searchEdit, SIGNAL(textChanged ( const QString & )),this,SLOT(searchTextChanged( const QString & )));
65 connect(searchEdit, SIGNAL( returnPressed () ),this,SLOT(doSearch())); 69 connect(searchEdit, SIGNAL( returnPressed () ),this,SLOT(doSearch()));
66 // Subjects to search 70 // Subjects to search
67 // QGroupBox *subjectGroup = new QGroupBox(1,Vertical,i18n("Search In"), 71 // QGroupBox *subjectGroup = new QGroupBox(1,Vertical,i18n("Search In"),
68 // topFrame); 72 // topFrame);
69 73
70
71
72 QHBox *incidenceGroup = new QHBox( topFrame ); 74 QHBox *incidenceGroup = new QHBox( topFrame );
73 layout->addWidget(incidenceGroup); 75 layout->addWidget(incidenceGroup);
74 76
75 mSearchEvent = new QCheckBox(i18n("Events"),incidenceGroup); 77 mSearchEvent = new QCheckBox(i18n("Events"),incidenceGroup);
76 mSearchEvent->setChecked(true); 78 mSearchEvent->setChecked(true);
77 mSearchTodo = new QCheckBox(i18n("Todos"),incidenceGroup); 79 mSearchTodo = new QCheckBox(i18n("Todos"),incidenceGroup);
78 mSearchJournal = new QCheckBox(i18n("Journals"),incidenceGroup); 80 mSearchJournal = new QCheckBox(i18n("Journals"),incidenceGroup);
79 81
80 QHBox *subjectGroup = new QHBox( topFrame ); 82 QHBox *subjectGroup = new QHBox( topFrame );
81 layout->addWidget(subjectGroup); 83 layout->addWidget(subjectGroup);
82 84
83 mSummaryCheck = new QCheckBox(i18n("Summary/Loc."),subjectGroup); 85 mSummaryCheck = new QCheckBox(i18n("Summary/Loc."),subjectGroup);
@@ -87,60 +89,45 @@ SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent)
87 89
88 QHBox *attendeeGroup = new QHBox( topFrame ); 90 QHBox *attendeeGroup = new QHBox( topFrame );
89 layout->addWidget(attendeeGroup ); 91 layout->addWidget(attendeeGroup );
90 new QLabel( i18n("Attendee:"),attendeeGroup ); 92 new QLabel( i18n("Attendee:"),attendeeGroup );
91 mSearchAName = new QCheckBox(i18n("Name"),attendeeGroup ); 93 mSearchAName = new QCheckBox(i18n("Name"),attendeeGroup );
92 mSearchAEmail = new QCheckBox(i18n("Email"), attendeeGroup ); 94 mSearchAEmail = new QCheckBox(i18n("Email"), attendeeGroup );
93 // Date range 95 // Date range
94 // QGroupBox *rangeGroup = new QGroupBox(1,Horizontal,i18n("Date Range"), 96 // QGroupBox *rangeGroup = new QGroupBox(1,Horizontal,i18n("Date Range"),
95 // topFrame); 97 // topFrame);
96 // layout->addWidget(rangeGroup); 98 // layout->addWidget(rangeGroup);
97 99
98 QWidget *rangeWidget = new QWidget(topFrame); 100 QWidget *rangeWidget = new QWidget(topFrame);
99 QHBoxLayout *rangeLayout = new QHBoxLayout(rangeWidget,0,spacingHint()); 101 QHBoxLayout *rangeLayout = new QHBoxLayout(rangeWidget,0,KDialog::spacingHint());
100
101 rangeLayout->addWidget(new QLabel(i18n("From:"),rangeWidget)); 102 rangeLayout->addWidget(new QLabel(i18n("From:"),rangeWidget));
102 mStartDate = new KDateEdit(rangeWidget); 103 mStartDate = new KDateEdit(rangeWidget);
103 rangeLayout->addWidget(mStartDate); 104 rangeLayout->addWidget(mStartDate);
104 rangeLayout->addWidget(new QLabel(i18n("To:"),rangeWidget)); 105 rangeLayout->addWidget(new QLabel(i18n("To:"),rangeWidget));
105 mEndDate = new KDateEdit(rangeWidget); 106 mEndDate = new KDateEdit(rangeWidget);
106 mEndDate->setDate(QDate::currentDate().addDays(365)); 107 mEndDate->setDate(QDate::currentDate().addDays(365));
107 rangeLayout->addWidget(mEndDate); 108 rangeLayout->addWidget(mEndDate);
108 109 QToolButton *wt = QWhatsThis::whatsThisButton ( rangeWidget );
109 // mInclusiveCheck = new QCheckBox(i18n("Events have to be completely included"), topFrame); 110 rangeLayout->addWidget( (QWidget*)wt );
110 //mInclusiveCheck->setChecked(false);
111 layout->addWidget(rangeWidget); 111 layout->addWidget(rangeWidget);
112 //layout->addWidget(mInclusiveCheck);
113 // Subjects to search
114
115
116 // Results list view 112 // Results list view
117 listView = new KOListView(mCalendar,topFrame); 113 listView = new KOListView(mCalendar,topFrame);
118 //listView->showDates();
119
120
121 layout->addWidget(listView); 114 layout->addWidget(listView);
122 115
123 // if ( KOPrefs::instance()->mCompactDialogs ) {
124 // KOGlobals::fitDialogToScreen( this, true );
125 // }
126
127 listView->readSettings(KOGlobals::config(),"SearchListView Layout"); 116 listView->readSettings(KOGlobals::config(),"SearchListView Layout");
128 connect(this,SIGNAL(user1Clicked()),SLOT(doSearch()));
129 QPushButton *CloseButton = findButton( Close );
130 //connect(CloseButton,SIGNAL(clicked()),listView, SLOT(clear()));
131 117
132#ifndef DESKTOP_VERSION 118 setCaption( i18n("KO/Pi Find: "));
133 setCaption(i18n("Click OK to search ->")); 119#ifdef DESKTOP_VERSION
134 hideButtons(); 120 OkButton = new QPushButton( i18n("Close"), this );
121 connect(OkButton,SIGNAL(clicked()),SLOT(hide()));
135#endif 122#endif
136} 123}
137 124
138SearchDialog::~SearchDialog() 125SearchDialog::~SearchDialog()
139{ 126{
140 127
141} 128}
142void SearchDialog::accept() 129void SearchDialog::accept()
143{ 130{
144 doSearch(); 131 doSearch();
145} 132}
146void SearchDialog::updateList() 133void SearchDialog::updateList()
@@ -149,25 +136,27 @@ void SearchDialog::updateList()
149 if ( isVisible() ) { 136 if ( isVisible() ) {
150 updateView(); 137 updateView();
151 //qDebug("SearchDialog::updated "); 138 //qDebug("SearchDialog::updated ");
152 } 139 }
153 else { 140 else {
154 listView->clear(); 141 listView->clear();
155 //qDebug("SearchDialog::cleared "); 142 //qDebug("SearchDialog::cleared ");
156 143
157 } 144 }
158} 145}
159void SearchDialog::searchTextChanged( const QString &_text ) 146void SearchDialog::searchTextChanged( const QString &_text )
160{ 147{
148#if 0
161 enableButton( KDialogBase::User1, !_text.isEmpty() ); 149 enableButton( KDialogBase::User1, !_text.isEmpty() );
150#endif
162} 151}
163 152
164void SearchDialog::doSearch() 153void SearchDialog::doSearch()
165{ 154{
166 QRegExp re; 155 QRegExp re;
167 156
168 re.setWildcard(true); // most people understand these better. 157 re.setWildcard(true); // most people understand these better.
169 re.setCaseSensitive(false); 158 re.setCaseSensitive(false);
170 re.setPattern(searchEdit->text()); 159 re.setPattern(searchEdit->text());
171 if (!re.isValid() ) { 160 if (!re.isValid() ) {
172 KMessageBox::sorry(this, 161 KMessageBox::sorry(this,
173 i18n("Invalid search expression,\ncannot perform " 162 i18n("Invalid search expression,\ncannot perform "
@@ -381,21 +370,36 @@ void SearchDialog::search(const QRegExp &re)
381#else 370#else
382 if (re.match(journ->description()) != -1) 371 if (re.match(journ->description()) != -1)
383#endif 372#endif
384 { 373 {
385 mMatchedJournals.append(journ); 374 mMatchedJournals.append(journ);
386 continue; 375 continue;
387 } 376 }
388 } 377 }
389 } 378 }
390 } 379 }
391 380
392} 381}
393/* 382
394void SearchDialog::keyPressEvent ( QKeyEvent *e) 383void SearchDialog::keyPressEvent ( QKeyEvent *e)
395{ 384{
396 385 switch ( e->key() ) {
397 e->ignore(); 386 case Qt::Key_Escape:
398 387 hide();
388 break;
389 case Qt::Key_F:
390 if ( e->state() == Qt::ControlButton ) {
391 qDebug("full ");
392
393 }
394 break;
395 case Qt::Key_Return:
396 case Qt::Key_Enter:
397 doSearch();
398 break;
399
400 default:
401 e->ignore();
402 }
399} 403}
400*/ 404
401//mMatchedJournals; 405//mMatchedJournals;