summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/searchdialog.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/korganizer/searchdialog.cpp b/korganizer/searchdialog.cpp
index efe8774..2e32ac2 100644
--- a/korganizer/searchdialog.cpp
+++ b/korganizer/searchdialog.cpp
@@ -1,411 +1,412 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 1998 Preston Brown 3 Copyright (c) 1998 Preston Brown
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 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 <qapplication.h>
28#include <qlabel.h> 29#include <qlabel.h>
29#include <qlistview.h> 30#include <qlistview.h>
30#include <qwhatsthis.h> 31#include <qwhatsthis.h>
31#include <qlineedit.h> 32#include <qlineedit.h>
32#include <qpushbutton.h> 33#include <qpushbutton.h>
33#include <qhbuttongroup.h> 34#include <qhbuttongroup.h>
34#include <klocale.h> 35#include <klocale.h>
35#include <kmessagebox.h> 36#include <kmessagebox.h>
36 37
37#include <libkdepim/kdateedit.h> 38#include <libkdepim/kdateedit.h>
38 39
39#include "koglobals.h" 40#include "koglobals.h"
40#include "koprefs.h" 41#include "koprefs.h"
41#include "klineedit.h" 42#include "klineedit.h"
42 43
43#include "calendarview.h" 44#include "calendarview.h"
44#include "koviewmanager.h" 45#include "koviewmanager.h"
45#include "searchdialog.h" 46#include "searchdialog.h"
46 47
47SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent) 48SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent)
48 : QVBox( 0 ) 49 : QVBox( 0 )
49 50
50{ 51{
51 mCalendar = calendar; 52 mCalendar = calendar;
52 QFrame *topFrame = new QFrame( this ) ;//plainPage(); 53 QFrame *topFrame = new QFrame( this ) ;//plainPage();
53 QVBoxLayout *layout = new QVBoxLayout(topFrame,KDialog::marginHint(),KDialog::spacingHint()); 54 QVBoxLayout *layout = new QVBoxLayout(topFrame,KDialog::marginHint(),KDialog::spacingHint());
54 55
55 // Search expression 56 // Search expression
56 QHBoxLayout *subLayout = new QHBoxLayout(); 57 QHBoxLayout *subLayout = new QHBoxLayout();
57 layout->addLayout(subLayout); 58 layout->addLayout(subLayout);
58 /* 59 /*
59 searchLabel = new QLabel(topFrame); 60 searchLabel = new QLabel(topFrame);
60 searchLabel->setText(i18n("Search for:")); 61 searchLabel->setText(i18n("Search for:"));
61 subLayout->addWidget(searchLabel); 62 subLayout->addWidget(searchLabel);
62 */ 63 */
63 QPushButton *OkButton = new QPushButton( i18n("Search for:"), topFrame ); 64 QPushButton *OkButton = new QPushButton( i18n("Search for:"), topFrame );
64 //OkButton->setDefault( true ); 65 //OkButton->setDefault( true );
65 connect(OkButton,SIGNAL(clicked()),SLOT(doSearch())); 66 connect(OkButton,SIGNAL(clicked()),SLOT(doSearch()));
66 subLayout->addWidget(OkButton); 67 subLayout->addWidget(OkButton);
67 searchEdit = new KLineEdit(topFrame); 68 searchEdit = new KLineEdit(topFrame);
68 subLayout->addWidget(searchEdit); 69 subLayout->addWidget(searchEdit);
69 70
70 mAddItems = new QRadioButton( "+ ", topFrame ); 71 mAddItems = new QRadioButton( "+ ", topFrame );
71 mSubItems = new QRadioButton( "- ", topFrame ); 72 mSubItems = new QRadioButton( "- ", topFrame );
72 mRefineItems = new QRadioButton( "< ", topFrame ); 73 mRefineItems = new QRadioButton( "< ", topFrame );
73 subLayout->addWidget( mAddItems ); 74 subLayout->addWidget( mAddItems );
74 subLayout->addWidget( mSubItems ); 75 subLayout->addWidget( mSubItems );
75 subLayout->addWidget( mRefineItems ); 76 subLayout->addWidget( mRefineItems );
76 QFont fo ( mAddItems->font() ); 77 QFont fo ( mAddItems->font() );
77 fo.setBold( true ); 78 fo.setBold( true );
78 fo.setPointSize( fo.pointSize() + 2 ); 79 fo.setPointSize( fo.pointSize() + 2 );
79 mAddItems->setFont( fo ); 80 mAddItems->setFont( fo );
80 mSubItems->setFont( fo ); 81 mSubItems->setFont( fo );
81 mRefineItems->setFont( fo ); 82 mRefineItems->setFont( fo );
82 connect( mAddItems , SIGNAL( toggled ( bool ) ),this,SLOT(slot_add( bool ))); 83 connect( mAddItems , SIGNAL( toggled ( bool ) ),this,SLOT(slot_add( bool )));
83 connect( mSubItems , SIGNAL( toggled ( bool ) ),this,SLOT(slot_sub( bool ))); 84 connect( mSubItems , SIGNAL( toggled ( bool ) ),this,SLOT(slot_sub( bool )));
84 connect( mRefineItems , SIGNAL( toggled ( bool ) ),this,SLOT(slot_refine( bool ))); 85 connect( mRefineItems , SIGNAL( toggled ( bool ) ),this,SLOT(slot_refine( bool )));
85 86
86 QPushButton *togButton = new QPushButton( "", topFrame ); 87 QPushButton *togButton = new QPushButton( "", topFrame );
87 subLayout->addWidget(togButton); 88 subLayout->addWidget(togButton);
88 connect(togButton,SIGNAL(clicked()),SLOT(toggleCheckboxes())); 89 connect(togButton,SIGNAL(clicked()),SLOT(toggleCheckboxes()));
89 togButton->setPixmap(SmallIcon("1updownarrow")); 90 togButton->setPixmap(SmallIcon("1updownarrow"));
90 togButton->setMinimumWidth( togButton->sizeHint().height() ); 91 togButton->setMinimumWidth( togButton->sizeHint().height() );
91 92
92 searchEdit->setText("*"); // Find all events by default 93 searchEdit->setText("*"); // Find all events by default
93 searchEdit->setFocus(); 94 searchEdit->setFocus();
94 connect(searchEdit, SIGNAL(textChanged ( const QString & )),this,SLOT(searchTextChanged( const QString & ))); 95 connect(searchEdit, SIGNAL(textChanged ( const QString & )),this,SLOT(searchTextChanged( const QString & )));
95 connect(searchEdit, SIGNAL( returnPressed () ),this,SLOT(doSearch())); 96 connect(searchEdit, SIGNAL( returnPressed () ),this,SLOT(doSearch()));
96 // Subjects to search 97 // Subjects to search
97 // QGroupBox *subjectGroup = new QGroupBox(1,Vertical,i18n("Search In"), 98 // QGroupBox *subjectGroup = new QGroupBox(1,Vertical,i18n("Search In"),
98 // topFrame); 99 // topFrame);
99 100
100 incidenceGroup = new QHBox( topFrame ); 101 incidenceGroup = new QHBox( topFrame );
101 layout->addWidget(incidenceGroup); 102 layout->addWidget(incidenceGroup);
102 103
103 mSearchEvent = new QCheckBox(i18n("Events"),incidenceGroup); 104 mSearchEvent = new QCheckBox(i18n("Events"),incidenceGroup);
104 //mSearchEvent->setChecked(true); 105 //mSearchEvent->setChecked(true);
105 mSearchTodo = new QCheckBox(i18n("Todos"),incidenceGroup); 106 mSearchTodo = new QCheckBox(i18n("Todos"),incidenceGroup);
106 mSearchJournal = new QCheckBox(i18n("Journals"),incidenceGroup); 107 mSearchJournal = new QCheckBox(i18n("Journals"),incidenceGroup);
107 108
108 subjectGroup = new QHBox( topFrame ); 109 subjectGroup = new QHBox( topFrame );
109 layout->addWidget(subjectGroup); 110 layout->addWidget(subjectGroup);
110 111
111 mSummaryCheck = new QCheckBox(i18n("Summary/Loc."),subjectGroup); 112 mSummaryCheck = new QCheckBox(i18n("Summary/Loc."),subjectGroup);
112 mSummaryCheck->setChecked(true); 113 mSummaryCheck->setChecked(true);
113 mDescriptionCheck = new QCheckBox(i18n("Details"),subjectGroup); 114 mDescriptionCheck = new QCheckBox(i18n("Details"),subjectGroup);
114 mCategoryCheck = new QCheckBox(i18n("Categories"),subjectGroup); 115 mCategoryCheck = new QCheckBox(i18n("Categories"),subjectGroup);
115 116
116 attendeeGroup = new QHBox( topFrame ); 117 attendeeGroup = new QHBox( topFrame );
117 layout->addWidget(attendeeGroup ); 118 layout->addWidget(attendeeGroup );
118 new QLabel( i18n("Attendee:"),attendeeGroup ); 119 new QLabel( i18n("Attendee:"),attendeeGroup );
119 mSearchAName = new QCheckBox(i18n("Name"),attendeeGroup ); 120 mSearchAName = new QCheckBox(i18n("Name"),attendeeGroup );
120 mSearchAEmail = new QCheckBox(i18n("Email"), attendeeGroup ); 121 mSearchAEmail = new QCheckBox(i18n("Email"), attendeeGroup );
121 // Date range 122 // Date range
122 // QGroupBox *rangeGroup = new QGroupBox(1,Horizontal,i18n("Date Range"), 123 // QGroupBox *rangeGroup = new QGroupBox(1,Horizontal,i18n("Date Range"),
123 // topFrame); 124 // topFrame);
124 // layout->addWidget(rangeGroup); 125 // layout->addWidget(rangeGroup);
125 126
126 QWidget *rangeWidget = new QWidget(topFrame); 127 QWidget *rangeWidget = new QWidget(topFrame);
127 int space = KDialog::spacingHint(); 128 int space = KDialog::spacingHint();
128 if ( QApplication::desktop()->width() <= 240 ) space = 1; 129 if ( QApplication::desktop()->width() <= 240 ) space = 1;
129 QHBoxLayout *rangeLayout = new QHBoxLayout(rangeWidget,0,space); 130 QHBoxLayout *rangeLayout = new QHBoxLayout(rangeWidget,0,space);
130 rangeLayout->addWidget(new QLabel(i18n("From:"),rangeWidget)); 131 rangeLayout->addWidget(new QLabel(i18n("From:"),rangeWidget));
131 mStartDate = new KDateEdit(rangeWidget); 132 mStartDate = new KDateEdit(rangeWidget);
132 rangeLayout->addWidget(mStartDate); 133 rangeLayout->addWidget(mStartDate);
133 rangeLayout->addWidget(new QLabel(i18n("To:"),rangeWidget)); 134 rangeLayout->addWidget(new QLabel(i18n("To:"),rangeWidget));
134 mEndDate = new KDateEdit(rangeWidget); 135 mEndDate = new KDateEdit(rangeWidget);
135 mEndDate->setDate(QDate::currentDate().addDays(365)); 136 mEndDate->setDate(QDate::currentDate().addDays(365));
136 rangeLayout->addWidget(mEndDate); 137 rangeLayout->addWidget(mEndDate);
137 QToolButton *wt = QWhatsThis::whatsThisButton ( rangeWidget ); 138 QToolButton *wt = QWhatsThis::whatsThisButton ( rangeWidget );
138 rangeLayout->addWidget( (QWidget*)wt ); 139 rangeLayout->addWidget( (QWidget*)wt );
139 layout->addWidget(rangeWidget); 140 layout->addWidget(rangeWidget);
140 // Results list view 141 // Results list view
141 listView = new KOListView(mCalendar,topFrame); 142 listView = new KOListView(mCalendar,topFrame);
142 layout->addWidget(listView); 143 layout->addWidget(listView);
143 listView->showCompletedTodos(); 144 listView->showCompletedTodos();
144 //layout->setStretchFactor( listView, 333 ); 145 //layout->setStretchFactor( listView, 333 );
145 //listView->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Expanding) ); 146 //listView->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Expanding) );
146 //listView->setMaximumHeight( 50 ); 147 //listView->setMaximumHeight( 50 );
147 listView->readSettings(KOGlobals::config(),"SearchListView Layout"); 148 listView->readSettings(KOGlobals::config(),"SearchListView Layout");
148 connect(searchEdit,SIGNAL(scrollDOWN()),SLOT(setFocusToList())); 149 connect(searchEdit,SIGNAL(scrollDOWN()),SLOT(setFocusToList()));
149 150
150 setCaption( i18n("KO/Pi Find: ")); 151 setCaption( i18n("KO/Pi Find: "));
151#ifdef DESKTOP_VERSION 152#ifdef DESKTOP_VERSION
152 OkButton = new QPushButton( i18n("Close"), this ); 153 OkButton = new QPushButton( i18n("Close"), this );
153 connect(OkButton,SIGNAL(clicked()),SLOT(hide())); 154 connect(OkButton,SIGNAL(clicked()),SLOT(hide()));
154#endif 155#endif
155} 156}
156 157
157SearchDialog::~SearchDialog() 158SearchDialog::~SearchDialog()
158{ 159{
159 160
160} 161}
161void SearchDialog::slot_add( bool b ) 162void SearchDialog::slot_add( bool b )
162{ 163{
163 if ( b ) { 164 if ( b ) {
164 if ( mSubItems->isOn() ) mSubItems->toggle(); 165 if ( mSubItems->isOn() ) mSubItems->toggle();
165 if ( mRefineItems->isOn() ) mRefineItems->toggle(); 166 if ( mRefineItems->isOn() ) mRefineItems->toggle();
166 setCaption( i18n("Matching items will be added to list")); 167 setCaption( i18n("Matching items will be added to list"));
167 } else 168 } else
168 setCaption( i18n("List will be cleared before search")); 169 setCaption( i18n("List will be cleared before search"));
169} 170}
170void SearchDialog::slot_sub( bool b) 171void SearchDialog::slot_sub( bool b)
171{ 172{
172 if ( b ) { 173 if ( b ) {
173 if ( mRefineItems->isOn() ) mRefineItems->toggle(); 174 if ( mRefineItems->isOn() ) mRefineItems->toggle();
174 if ( mAddItems->isOn() ) mAddItems->toggle(); 175 if ( mAddItems->isOn() ) mAddItems->toggle();
175 setCaption( i18n("Matching items will be removed from list")); 176 setCaption( i18n("Matching items will be removed from list"));
176 } else 177 } else
177 setCaption( i18n("List will be cleared before search")); 178 setCaption( i18n("List will be cleared before search"));
178} 179}
179void SearchDialog::slot_refine( bool b) 180void SearchDialog::slot_refine( bool b)
180{ 181{
181 if ( b ) { 182 if ( b ) {
182 if ( mSubItems->isOn() ) mSubItems->toggle(); 183 if ( mSubItems->isOn() ) mSubItems->toggle();
183 if ( mAddItems->isOn() ) mAddItems->toggle(); 184 if ( mAddItems->isOn() ) mAddItems->toggle();
184 setCaption( i18n("Search on displayed list only")); 185 setCaption( i18n("Search on displayed list only"));
185 } else 186 } else
186 setCaption( i18n("List will be cleared before search")); 187 setCaption( i18n("List will be cleared before search"));
187} 188}
188void SearchDialog::toggleCheckboxes() 189void SearchDialog::toggleCheckboxes()
189{ 190{
190 if ( incidenceGroup->isVisible() ) { 191 if ( incidenceGroup->isVisible() ) {
191 incidenceGroup->hide() ; 192 incidenceGroup->hide() ;
192 subjectGroup->hide() ; 193 subjectGroup->hide() ;
193 attendeeGroup->hide() ; 194 attendeeGroup->hide() ;
194 } else { 195 } else {
195 incidenceGroup->show() ; 196 incidenceGroup->show() ;
196 subjectGroup->show() ; 197 subjectGroup->show() ;
197 attendeeGroup->show() ; 198 attendeeGroup->show() ;
198 } 199 }
199} 200}
200void SearchDialog::raiseAndSelect() 201void SearchDialog::raiseAndSelect()
201{ 202{
202 203
203 static int currentState = 0; 204 static int currentState = 0;
204 205
205 if ( !mSearchJournal->isChecked() && !mSearchTodo->isChecked() && !mSearchEvent->isChecked() ) 206 if ( !mSearchJournal->isChecked() && !mSearchTodo->isChecked() && !mSearchEvent->isChecked() )
206 currentState = 0; 207 currentState = 0;
207 int newState = 0; 208 int newState = 0;
208 if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) { 209 if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) {
209 newState = VIEW_J_VIEW; 210 newState = VIEW_J_VIEW;
210 } 211 }
211 else if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) { 212 else if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) {
212 newState = VIEW_T_VIEW; 213 newState = VIEW_T_VIEW;
213 } 214 }
214 else { 215 else {
215 newState = VIEW_A_VIEW; 216 newState = VIEW_A_VIEW;
216 } 217 }
217 if ( newState != currentState ) { 218 if ( newState != currentState ) {
218 if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) { 219 if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) {
219 if ( ! mSearchJournal->isChecked() ) { 220 if ( ! mSearchJournal->isChecked() ) {
220 mSearchJournal->setChecked( true ); 221 mSearchJournal->setChecked( true );
221 mSearchTodo->setChecked( false ); 222 mSearchTodo->setChecked( false );
222 mSearchEvent->setChecked( false ); 223 mSearchEvent->setChecked( false );
223 mSummaryCheck->setChecked( true ); 224 mSummaryCheck->setChecked( true );
224 mDescriptionCheck->setChecked( true ); 225 mDescriptionCheck->setChecked( true );
225 226
226 } 227 }
227 } 228 }
228 else if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) { 229 else if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) {
229 if ( ! mSearchTodo->isChecked() ) { 230 if ( ! mSearchTodo->isChecked() ) {
230 mSearchTodo->setChecked( true ); 231 mSearchTodo->setChecked( true );
231 mSearchJournal->setChecked( false ); 232 mSearchJournal->setChecked( false );
232 mSearchEvent->setChecked( false ); 233 mSearchEvent->setChecked( false );
233 } 234 }
234 } 235 }
235 else { 236 else {
236 if ( ! mSearchEvent->isChecked() ) { 237 if ( ! mSearchEvent->isChecked() ) {
237 mSearchEvent->setChecked( true ); 238 mSearchEvent->setChecked( true );
238 mSearchJournal->setChecked( false ); 239 mSearchJournal->setChecked( false );
239 mSearchTodo->setChecked( false ); 240 mSearchTodo->setChecked( false );
240 } 241 }
241 } 242 }
242 } 243 }
243 currentState = newState; 244 currentState = newState;
244 raise(); 245 raise();
245} 246}
246void SearchDialog::setFocusToList() 247void SearchDialog::setFocusToList()
247{ 248{
248 listView->resetFocus(); 249 listView->resetFocus();
249} 250}
250void SearchDialog::accept() 251void SearchDialog::accept()
251{ 252{
252 doSearch(); 253 doSearch();
253} 254}
254void SearchDialog::updateList() 255void SearchDialog::updateList()
255{ 256{
256 //listView->updateList(); 257 //listView->updateList();
257 if ( isVisible() ) { 258 if ( isVisible() ) {
258 updateView(); 259 updateView();
259 //qDebug("SearchDialog::updated "); 260 //qDebug("SearchDialog::updated ");
260 } 261 }
261 else { 262 else {
262 listView->clear(); 263 listView->clear();
263 //qDebug("SearchDialog::cleared "); 264 //qDebug("SearchDialog::cleared ");
264 265
265 } 266 }
266} 267}
267void SearchDialog::searchTextChanged( const QString &_text ) 268void SearchDialog::searchTextChanged( const QString &_text )
268{ 269{
269#if 0 270#if 0
270 enableButton( KDialogBase::User1, !_text.isEmpty() ); 271 enableButton( KDialogBase::User1, !_text.isEmpty() );
271#endif 272#endif
272} 273}
273 274
274void SearchDialog::doSearch() 275void SearchDialog::doSearch()
275{ 276{
276 QRegExp re; 277 QRegExp re;
277 re.setWildcard(true); // most people understand these better. 278 re.setWildcard(true); // most people understand these better.
278 re.setCaseSensitive(false); 279 re.setCaseSensitive(false);
279 QString st = searchEdit->text(); 280 QString st = searchEdit->text();
280 if ( st.right(1) != "*") 281 if ( st.right(1) != "*")
281 st += "*"; 282 st += "*";
282 re.setPattern(st); 283 re.setPattern(st);
283 if (!mSearchEvent->isChecked() && !mSearchTodo->isChecked() && !mSearchJournal->isChecked() ) { 284 if (!mSearchEvent->isChecked() && !mSearchTodo->isChecked() && !mSearchJournal->isChecked() ) {
284 KMessageBox::sorry(this, 285 KMessageBox::sorry(this,
285 i18n("Please select at least one\nof the types to search for:\n\nEvents\nTodos\nJournals")); 286 i18n("Please select at least one\nof the types to search for:\n\nEvents\nTodos\nJournals"));
286 return; 287 return;
287 } 288 }
288 if (!re.isValid() ) { 289 if (!re.isValid() ) {
289 KMessageBox::sorry(this, 290 KMessageBox::sorry(this,
290 i18n("Invalid search expression,\ncannot perform " 291 i18n("Invalid search expression,\ncannot perform "
291 "the search.\nPlease enter a search expression\n" 292 "the search.\nPlease enter a search expression\n"
292 "using the wildcard characters\n '*' and '?'" 293 "using the wildcard characters\n '*' and '?'"
293 "where needed.")); 294 "where needed."));
294 return; 295 return;
295 } 296 }
296 search(re); 297 search(re);
297 listView->setStartDate( mStartDate->date() ); 298 listView->setStartDate( mStartDate->date() );
298 listView->showEvents(mMatchedEvents); 299 listView->showEvents(mMatchedEvents);
299 listView->addTodos(mMatchedTodos); 300 listView->addTodos(mMatchedTodos);
300 listView->addJournals(mMatchedJournals); 301 listView->addJournals(mMatchedJournals);
301 if (mMatchedEvents.count() + mMatchedJournals.count() + mMatchedTodos.count() == 0) { 302 if (mMatchedEvents.count() + mMatchedJournals.count() + mMatchedTodos.count() == 0) {
302 setCaption(i18n("No items found. Use '*' and '?' where needed.")); 303 setCaption(i18n("No items found. Use '*' and '?' where needed."));
303 } else { 304 } else {
304 QString mess; 305 QString mess;
305 mess = mess.sprintf( i18n("%d item(s) found."), mMatchedEvents.count()+ mMatchedJournals.count() + mMatchedTodos.count() ); 306 mess = mess.sprintf( i18n("%d item(s) found."), mMatchedEvents.count()+ mMatchedJournals.count() + mMatchedTodos.count() );
306 setCaption( i18n("KO/Pi Find: ") + mess); 307 setCaption( i18n("KO/Pi Find: ") + mess);
307 308
308 } 309 }
309 searchEdit->setFocus(); 310 searchEdit->setFocus();
310} 311}
311void SearchDialog::updateConfig() 312void SearchDialog::updateConfig()
312{ 313{
313 listView->updateConfig(); 314 listView->updateConfig();
314} 315}
315void SearchDialog::updateView() 316void SearchDialog::updateView()
316{ 317{
317 //qDebug("SearchDialog::updateView() %d ", isVisible()); 318 //qDebug("SearchDialog::updateView() %d ", isVisible());
318 QRegExp re; 319 QRegExp re;
319 re.setWildcard(true); // most people understand these better. 320 re.setWildcard(true); // most people understand these better.
320 re.setCaseSensitive(false); 321 re.setCaseSensitive(false);
321 QString st = searchEdit->text(); 322 QString st = searchEdit->text();
322 if ( st.right(1) != "*") 323 if ( st.right(1) != "*")
323 st += "*"; 324 st += "*";
324 re.setPattern(st); 325 re.setPattern(st);
325 mMatchedEvents.clear(); 326 mMatchedEvents.clear();
326 mMatchedTodos.clear(); 327 mMatchedTodos.clear();
327 mMatchedJournals.clear(); 328 mMatchedJournals.clear();
328 if (re.isValid()) { 329 if (re.isValid()) {
329 search(re); 330 search(re);
330 } 331 }
331 listView->setStartDate( mStartDate->date() ); 332 listView->setStartDate( mStartDate->date() );
332 listView->showEvents(mMatchedEvents); 333 listView->showEvents(mMatchedEvents);
333 listView->addTodos(mMatchedTodos); 334 listView->addTodos(mMatchedTodos);
334 listView->addJournals(mMatchedJournals); 335 listView->addJournals(mMatchedJournals);
335} 336}
336 337
337void SearchDialog::search(const QRegExp &re) 338void SearchDialog::search(const QRegExp &re)
338{ 339{
339 QPtrList<Event> events; 340 QPtrList<Event> events;
340 if ( !mAddItems->isChecked() && !mSubItems->isChecked() ) { 341 if ( !mAddItems->isChecked() && !mSubItems->isChecked() ) {
341 if ( mRefineItems->isChecked() ) events = mMatchedEvents; 342 if ( mRefineItems->isChecked() ) events = mMatchedEvents;
342 mMatchedEvents.clear(); 343 mMatchedEvents.clear();
343 } 344 }
344 if ( mSearchEvent->isChecked() ) { 345 if ( mSearchEvent->isChecked() ) {
345 if ( !mRefineItems->isChecked() ) 346 if ( !mRefineItems->isChecked() )
346 events = mCalendar->events( mStartDate->date(), 347 events = mCalendar->events( mStartDate->date(),
347 mEndDate->date(), 348 mEndDate->date(),
348 false /*mInclusiveCheck->isChecked()*/ ); 349 false /*mInclusiveCheck->isChecked()*/ );
349 350
350 351
351 Event *ev; 352 Event *ev;
352 for(ev=events.first();ev;ev=events.next()) { 353 for(ev=events.first();ev;ev=events.next()) {
353 if (mSummaryCheck->isChecked()) { 354 if (mSummaryCheck->isChecked()) {
354#if QT_VERSION >= 0x030000 355#if QT_VERSION >= 0x030000
355 if (re.search(ev->summary()) != -1) 356 if (re.search(ev->summary()) != -1)
356#else 357#else
357 if (re.match(ev->summary()) != -1) 358 if (re.match(ev->summary()) != -1)
358#endif 359#endif
359 { 360 {
360 if ( mSubItems->isChecked() ) 361 if ( mSubItems->isChecked() )
361 mMatchedEvents.remove(ev); 362 mMatchedEvents.remove(ev);
362 else { 363 else {
363 if ( !mMatchedEvents.contains( ev ) ) 364 if ( !mMatchedEvents.contains( ev ) )
364 mMatchedEvents.append(ev); 365 mMatchedEvents.append(ev);
365 } 366 }
366 continue; 367 continue;
367 } 368 }
368#if QT_VERSION >= 0x030000 369#if QT_VERSION >= 0x030000
369 if (re.search(ev->location()) != -1) 370 if (re.search(ev->location()) != -1)
370#else 371#else
371 if (re.match(ev->location()) != -1) 372 if (re.match(ev->location()) != -1)
372#endif 373#endif
373 { 374 {
374 if ( mSubItems->isChecked() ) 375 if ( mSubItems->isChecked() )
375 mMatchedEvents.remove(ev); 376 mMatchedEvents.remove(ev);
376 else{ 377 else{
377 if ( !mMatchedEvents.contains( ev ) ) 378 if ( !mMatchedEvents.contains( ev ) )
378 mMatchedEvents.append(ev); 379 mMatchedEvents.append(ev);
379 } 380 }
380 continue; 381 continue;
381 } 382 }
382 } 383 }
383 if (mDescriptionCheck->isChecked()) { 384 if (mDescriptionCheck->isChecked()) {
384#if QT_VERSION >= 0x030000 385#if QT_VERSION >= 0x030000
385 if (re.search(ev->description()) != -1) 386 if (re.search(ev->description()) != -1)
386#else 387#else
387 if (re.match(ev->description()) != -1) 388 if (re.match(ev->description()) != -1)
388#endif 389#endif
389 { 390 {
390 if ( mSubItems->isChecked() ) 391 if ( mSubItems->isChecked() )
391 mMatchedEvents.remove(ev); 392 mMatchedEvents.remove(ev);
392 else{ 393 else{
393 if ( !mMatchedEvents.contains( ev ) ) 394 if ( !mMatchedEvents.contains( ev ) )
394 mMatchedEvents.append(ev); 395 mMatchedEvents.append(ev);
395 } 396 }
396 continue; 397 continue;
397 } 398 }
398 } 399 }
399 if (mCategoryCheck->isChecked()) { 400 if (mCategoryCheck->isChecked()) {
400#if QT_VERSION >= 0x030000 401#if QT_VERSION >= 0x030000
401 if (re.search(ev->categoriesStr()) != -1) 402 if (re.search(ev->categoriesStr()) != -1)
402#else 403#else
403 if (re.match(ev->categoriesStr()) != -1) 404 if (re.match(ev->categoriesStr()) != -1)
404#endif 405#endif
405 { 406 {
406 407
407 if ( mSubItems->isChecked() ) 408 if ( mSubItems->isChecked() )
408 mMatchedEvents.remove(ev); 409 mMatchedEvents.remove(ev);
409 else{ 410 else{
410 if ( !mMatchedEvents.contains( ev ) ) 411 if ( !mMatchedEvents.contains( ev ) )
411 mMatchedEvents.append(ev); 412 mMatchedEvents.append(ev);