summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-07-02 19:46:27 (UTC)
committer zautrix <zautrix>2005-07-02 19:46:27 (UTC)
commitc69004813dce7402f56e7f90e172c8fb56e9cc55 (patch) (unidiff)
tree4de04efa28ebeefc6b53588c35fa5d2c1ab85e7f
parent1de3670209f954b71e679c6b3a83a1334b43f895 (diff)
downloadkdepimpi-c69004813dce7402f56e7f90e172c8fb56e9cc55.zip
kdepimpi-c69004813dce7402f56e7f90e172c8fb56e9cc55.tar.gz
kdepimpi-c69004813dce7402f56e7f90e172c8fb56e9cc55.tar.bz2
c f
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,619 +1,620 @@
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);
412 } 413 }
413 continue; 414 continue;
414 } 415 }
415 } 416 }
416 if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) { 417 if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) {
417 QPtrList<Attendee> tmpAList = ev->attendees(); 418 QPtrList<Attendee> tmpAList = ev->attendees();
418 Attendee *a; 419 Attendee *a;
419 for (a = tmpAList.first(); a; a = tmpAList.next()) { 420 for (a = tmpAList.first(); a; a = tmpAList.next()) {
420 if (mSearchAName->isChecked()) { 421 if (mSearchAName->isChecked()) {
421#if QT_VERSION >= 0x030000 422#if QT_VERSION >= 0x030000
422 if (re.search(a->name()) != -1) 423 if (re.search(a->name()) != -1)
423#else 424#else
424 if (re.match(a->name()) != -1) 425 if (re.match(a->name()) != -1)
425#endif 426#endif
426 { 427 {
427 if ( mSubItems->isChecked() ) 428 if ( mSubItems->isChecked() )
428 mMatchedEvents.remove(ev); 429 mMatchedEvents.remove(ev);
429 else{ 430 else{
430 if ( !mMatchedEvents.contains( ev ) ) 431 if ( !mMatchedEvents.contains( ev ) )
431 mMatchedEvents.append(ev); 432 mMatchedEvents.append(ev);
432 } 433 }
433 break; 434 break;
434 } 435 }
435 } 436 }
436 if (mSearchAEmail->isChecked()) { 437 if (mSearchAEmail->isChecked()) {
437#if QT_VERSION >= 0x030000 438#if QT_VERSION >= 0x030000
438 if (re.search(a->email()) != -1) 439 if (re.search(a->email()) != -1)
439#else 440#else
440 if (re.match(a->email()) != -1) 441 if (re.match(a->email()) != -1)
441#endif 442#endif
442 { 443 {
443 if ( mSubItems->isChecked() ) 444 if ( mSubItems->isChecked() )
444 mMatchedEvents.remove(ev); 445 mMatchedEvents.remove(ev);
445 else{ 446 else{
446 if ( !mMatchedEvents.contains( ev ) ) 447 if ( !mMatchedEvents.contains( ev ) )
447 mMatchedEvents.append(ev); 448 mMatchedEvents.append(ev);
448 } 449 }
449 break; 450 break;
450 } 451 }
451 } 452 }
452 } 453 }
453 } 454 }
454 } 455 }
455 } 456 }
456 QPtrList<Todo> todos; 457 QPtrList<Todo> todos;
457 458
458 if ( !mAddItems->isChecked() && !mSubItems->isChecked() ) { 459 if ( !mAddItems->isChecked() && !mSubItems->isChecked() ) {
459 if ( mRefineItems->isChecked() ) todos = mMatchedTodos ; 460 if ( mRefineItems->isChecked() ) todos = mMatchedTodos ;
460 mMatchedTodos.clear(); 461 mMatchedTodos.clear();
461 } 462 }
462 463
463 if ( mSearchTodo->isChecked() ) { 464 if ( mSearchTodo->isChecked() ) {
464 if ( !mRefineItems->isChecked() ) todos = mCalendar->todos( ); 465 if ( !mRefineItems->isChecked() ) todos = mCalendar->todos( );
465 Todo *tod; 466 Todo *tod;
466 for(tod=todos.first();tod;tod=todos.next()) { 467 for(tod=todos.first();tod;tod=todos.next()) {
467 if (mSummaryCheck->isChecked()) { 468 if (mSummaryCheck->isChecked()) {
468#if QT_VERSION >= 0x030000 469#if QT_VERSION >= 0x030000
469 if (re.search(tod->summary()) != -1) 470 if (re.search(tod->summary()) != -1)
470#else 471#else
471 if (re.match(tod->summary()) != -1) 472 if (re.match(tod->summary()) != -1)
472#endif 473#endif
473 { 474 {
474 if ( mSubItems->isChecked() ) 475 if ( mSubItems->isChecked() )
475 mMatchedTodos.remove(tod); 476 mMatchedTodos.remove(tod);
476 else if (!mMatchedTodos.contains( tod )) 477 else if (!mMatchedTodos.contains( tod ))
477 mMatchedTodos.append(tod); 478 mMatchedTodos.append(tod);
478 continue; 479 continue;
479 } 480 }
480 } 481 }
481 if (mDescriptionCheck->isChecked()) { 482 if (mDescriptionCheck->isChecked()) {
482#if QT_VERSION >= 0x030000 483#if QT_VERSION >= 0x030000
483 if (re.search(tod->description()) != -1) 484 if (re.search(tod->description()) != -1)
484#else 485#else
485 if (re.match(tod->description()) != -1) 486 if (re.match(tod->description()) != -1)
486#endif 487#endif
487 { 488 {
488 if ( mSubItems->isChecked() ) 489 if ( mSubItems->isChecked() )
489 mMatchedTodos.remove(tod); 490 mMatchedTodos.remove(tod);
490 else if (!mMatchedTodos.contains( tod )) 491 else if (!mMatchedTodos.contains( tod ))
491 mMatchedTodos.append(tod); 492 mMatchedTodos.append(tod);
492 continue; 493 continue;
493 } 494 }
494 } 495 }
495 if (mCategoryCheck->isChecked()) { 496 if (mCategoryCheck->isChecked()) {
496#if QT_VERSION >= 0x030000 497#if QT_VERSION >= 0x030000
497 if (re.search(tod->categoriesStr()) != -1) 498 if (re.search(tod->categoriesStr()) != -1)
498#else 499#else
499 if (re.match(tod->categoriesStr()) != -1) 500 if (re.match(tod->categoriesStr()) != -1)
500#endif 501#endif
501 { 502 {
502 if ( mSubItems->isChecked() ) 503 if ( mSubItems->isChecked() )
503 mMatchedTodos.remove(tod); 504 mMatchedTodos.remove(tod);
504 else if (!mMatchedTodos.contains( tod )) 505 else if (!mMatchedTodos.contains( tod ))
505 mMatchedTodos.append(tod); 506 mMatchedTodos.append(tod);
506 continue; 507 continue;
507 } 508 }
508 } 509 }
509 if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) { 510 if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) {
510 QPtrList<Attendee> tmpAList = tod->attendees(); 511 QPtrList<Attendee> tmpAList = tod->attendees();
511 Attendee *a; 512 Attendee *a;
512 for (a = tmpAList.first(); a; a = tmpAList.next()) { 513 for (a = tmpAList.first(); a; a = tmpAList.next()) {
513 if (mSearchAName->isChecked()) { 514 if (mSearchAName->isChecked()) {
514#if QT_VERSION >= 0x030000 515#if QT_VERSION >= 0x030000
515 if (re.search(a->name()) != -1) 516 if (re.search(a->name()) != -1)
516#else 517#else
517 if (re.match(a->name()) != -1) 518 if (re.match(a->name()) != -1)
518#endif 519#endif
519 { 520 {
520 if ( mSubItems->isChecked() ) 521 if ( mSubItems->isChecked() )
521 mMatchedTodos.remove(tod); 522 mMatchedTodos.remove(tod);
522 else if (!mMatchedTodos.contains( tod )) 523 else if (!mMatchedTodos.contains( tod ))
523 mMatchedTodos.append(tod); 524 mMatchedTodos.append(tod);
524 break; 525 break;
525 } 526 }
526 } 527 }
527 if (mSearchAEmail->isChecked()) { 528 if (mSearchAEmail->isChecked()) {
528#if QT_VERSION >= 0x030000 529#if QT_VERSION >= 0x030000
529 if (re.search(a->email()) != -1) 530 if (re.search(a->email()) != -1)
530#else 531#else
531 if (re.match(a->email()) != -1) 532 if (re.match(a->email()) != -1)
532#endif 533#endif
533 { 534 {
534 if ( mSubItems->isChecked() ) 535 if ( mSubItems->isChecked() )
535 mMatchedTodos.remove(tod); 536 mMatchedTodos.remove(tod);
536 else if (!mMatchedTodos.contains( tod )) 537 else if (!mMatchedTodos.contains( tod ))
537 mMatchedTodos.append(tod); 538 mMatchedTodos.append(tod);
538 break; 539 break;
539 } 540 }
540 } 541 }
541 } 542 }
542 } 543 }
543 } 544 }
544 } 545 }
545 546
546 QPtrList<Journal> journals; 547 QPtrList<Journal> journals;
547 if ( !mAddItems->isChecked() && !mSubItems->isChecked() ) { 548 if ( !mAddItems->isChecked() && !mSubItems->isChecked() ) {
548 if ( mRefineItems->isChecked() ) journals = mMatchedJournals ; 549 if ( mRefineItems->isChecked() ) journals = mMatchedJournals ;
549 mMatchedJournals.clear(); 550 mMatchedJournals.clear();
550 } 551 }
551 if (mSearchJournal->isChecked() ) { 552 if (mSearchJournal->isChecked() ) {
552 if ( ! mRefineItems->isChecked() ) journals = mCalendar->journals(); 553 if ( ! mRefineItems->isChecked() ) journals = mCalendar->journals();
553 Journal* journ; 554 Journal* journ;
554 555
555 for(journ=journals.first();journ;journ=journals.next()) { 556 for(journ=journals.first();journ;journ=journals.next()) {
556 if ( journ->dtStart().date() <= mEndDate->date() 557 if ( journ->dtStart().date() <= mEndDate->date()
557 &&journ->dtStart().date() >= mStartDate->date()) { 558 &&journ->dtStart().date() >= mStartDate->date()) {
558 if (mDescriptionCheck->isChecked()) { 559 if (mDescriptionCheck->isChecked()) {
559#if QT_VERSION >= 0x030000 560#if QT_VERSION >= 0x030000
560 if (re.search(journ->description()) != -1) 561 if (re.search(journ->description()) != -1)
561#else 562#else
562 if (re.match(journ->description()) != -1) 563 if (re.match(journ->description()) != -1)
563#endif 564#endif
564 { 565 {
565 if ( mSubItems->isChecked() ) 566 if ( mSubItems->isChecked() )
566 mMatchedJournals.remove(journ); 567 mMatchedJournals.remove(journ);
567 else if (!mMatchedJournals.contains( journ )) 568 else if (!mMatchedJournals.contains( journ ))
568 mMatchedJournals.append(journ); 569 mMatchedJournals.append(journ);
569 continue; 570 continue;
570 } 571 }
571 } 572 }
572 if (mSummaryCheck->isChecked()) { 573 if (mSummaryCheck->isChecked()) {
573#if QT_VERSION >= 0x030000 574#if QT_VERSION >= 0x030000
574 if (re.search(journ->summary()) != -1) 575 if (re.search(journ->summary()) != -1)
575#else 576#else
576 if (re.match(journ->summary()) != -1) 577 if (re.match(journ->summary()) != -1)
577#endif 578#endif
578 { 579 {
579 if ( mSubItems->isChecked() ) 580 if ( mSubItems->isChecked() )
580 mMatchedJournals.remove(journ); 581 mMatchedJournals.remove(journ);
581 else if (!mMatchedJournals.contains( journ )) 582 else if (!mMatchedJournals.contains( journ ))
582 mMatchedJournals.append(journ); 583 mMatchedJournals.append(journ);
583 continue; 584 continue;
584 } 585 }
585 } 586 }
586 } 587 }
587 } 588 }
588 } 589 }
589 if ( mMatchedEvents.count() + mMatchedJournals.count() + mMatchedTodos.count() < 1 ) { 590 if ( mMatchedEvents.count() + mMatchedJournals.count() + mMatchedTodos.count() < 1 ) {
590 qDebug("count %d ", mMatchedEvents.count() + mMatchedJournals.count() + mMatchedTodos.count() ); 591 qDebug("count %d ", mMatchedEvents.count() + mMatchedJournals.count() + mMatchedTodos.count() );
591 if ( mRefineItems->isChecked() ) 592 if ( mRefineItems->isChecked() )
592 mRefineItems->setChecked( false ); 593 mRefineItems->setChecked( false );
593 else if ( mSubItems->isChecked() ) 594 else if ( mSubItems->isChecked() )
594 mSubItems->setChecked( false ); 595 mSubItems->setChecked( false );
595 } 596 }
596} 597}
597 598
598void SearchDialog::keyPressEvent ( QKeyEvent *e) 599void SearchDialog::keyPressEvent ( QKeyEvent *e)
599{ 600{
600 switch ( e->key() ) { 601 switch ( e->key() ) {
601 case Qt::Key_Escape: 602 case Qt::Key_Escape:
602 close(); 603 close();
603 break; 604 break;
604 case Qt::Key_F: 605 case Qt::Key_F:
605 if ( e->state() == Qt::ControlButton ) { 606 if ( e->state() == Qt::ControlButton ) {
606 607
607 } 608 }
608 break; 609 break;
609 case Qt::Key_Return: 610 case Qt::Key_Return:
610 case Qt::Key_Enter: 611 case Qt::Key_Enter:
611 doSearch(); 612 doSearch();
612 break; 613 break;
613 614
614 default: 615 default:
615 e->ignore(); 616 e->ignore();
616 } 617 }
617} 618}
618 619
619//mMatchedJournals; 620//mMatchedJournals;