summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kolistview.cpp35
-rw-r--r--korganizer/searchdialog.cpp25
-rw-r--r--korganizer/searchdialog.h1
3 files changed, 48 insertions, 13 deletions
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp
index be51694..5797d1b 100644
--- a/korganizer/kolistview.cpp
+++ b/korganizer/kolistview.cpp
@@ -1,1371 +1,1398 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 1999 Preston Brown 3 Copyright (c) 1999 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 <qlistview.h> 25#include <qlistview.h>
26#include <qlayout.h> 26#include <qlayout.h>
27#include <qlabel.h> 27#include <qlabel.h>
28#include <qpopupmenu.h> 28#include <qpopupmenu.h>
29#include <qprogressbar.h> 29#include <qprogressbar.h>
30#include <qfileinfo.h> 30#include <qfileinfo.h>
31#include <qmessagebox.h> 31#include <qmessagebox.h>
32#include <qdialog.h> 32#include <qdialog.h>
33#include <qtextstream.h> 33#include <qtextstream.h>
34#include <qdir.h> 34#include <qdir.h>
35#include <qwhatsthis.h> 35#include <qwhatsthis.h>
36#include <qregexp.h> 36#include <qregexp.h>
37#include <qpainter.h> 37#include <qpainter.h>
38#include <qpaintdevicemetrics.h> 38#include <qpaintdevicemetrics.h>
39 39
40#include <klocale.h> 40#include <klocale.h>
41#include <kdebug.h> 41#include <kdebug.h>
42#include <kiconloader.h> 42#include <kiconloader.h>
43#include <kglobal.h> 43#include <kglobal.h>
44 44
45#include <libkdepim/kpimglobalprefs.h> 45#include <libkdepim/kpimglobalprefs.h>
46#include <libkcal/calendar.h> 46#include <libkcal/calendar.h>
47#include <libkcal/calendarlocal.h> 47#include <libkcal/calendarlocal.h>
48#include <libkcal/icalformat.h> 48#include <libkcal/icalformat.h>
49#include <libkcal/vcalformat.h> 49#include <libkcal/vcalformat.h>
50#include <libkcal/recurrence.h> 50#include <libkcal/recurrence.h>
51#include <libkcal/filestorage.h> 51#include <libkcal/filestorage.h>
52#include <libkdepim/categoryselectdialog.h> 52#include <libkdepim/categoryselectdialog.h>
53#include <libkcal/kincidenceformatter.h> 53#include <libkcal/kincidenceformatter.h>
54#ifndef DESKTOP_VERSION 54#ifndef DESKTOP_VERSION
55#include <qpe/qpeapplication.h> 55#include <qpe/qpeapplication.h>
56#else 56#else
57#include <qapplication.h> 57#include <qapplication.h>
58#endif 58#endif
59 59
60#ifndef KORG_NOPRINTER 60#ifndef KORG_NOPRINTER
61#include "calprinter.h" 61#include "calprinter.h"
62#endif 62#endif
63#include "koglobals.h" 63#include "koglobals.h"
64#include "koprefs.h" 64#include "koprefs.h"
65#include "kfiledialog.h" 65#include "kfiledialog.h"
66 66
67#include "kolistview.h" 67#include "kolistview.h"
68#include "koeventviewer.h" 68#include "koeventviewer.h"
69 69
70 70
71 71
72 72
73class KOListViewWhatsThis :public QWhatsThis 73class KOListViewWhatsThis :public QWhatsThis
74{ 74{
75public: 75public:
76 KOListViewWhatsThis( QWidget *wid, KOListView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; 76 KOListViewWhatsThis( QWidget *wid, KOListView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { };
77 77
78protected: 78protected:
79 virtual QString text( const QPoint& p) 79 virtual QString text( const QPoint& p)
80 { 80 {
81 return _view->getWhatsThisText(p) ; 81 return _view->getWhatsThisText(p) ;
82 } 82 }
83private: 83private:
84 QWidget* _wid; 84 QWidget* _wid;
85 KOListView * _view; 85 KOListView * _view;
86}; 86};
87 87
88 88
89ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date ) 89ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date )
90{ 90{
91 mItem = item; 91 mItem = item;
92 mDate = date; 92 mDate = date;
93} 93}
94 94
95ListItemVisitor::~ListItemVisitor() 95ListItemVisitor::~ListItemVisitor()
96{ 96{
97} 97}
98 98
99bool ListItemVisitor::visit(Event *e) 99bool ListItemVisitor::visit(Event *e)
100{ 100{
101 bool ok = false; 101 bool ok = false;
102 QString start, end; 102 QString start, end;
103 QDate ds, de; 103 QDate ds, de;
104 if ( e->doesRecur() ) { 104 if ( e->doesRecur() ) {
105 ds = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date(); 105 ds = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date();
106 if ( ok ) { 106 if ( ok ) {
107 int days = e->dtStart().date().daysTo(e->dtEnd().date() ); 107 int days = e->dtStart().date().daysTo(e->dtEnd().date() );
108 start = KGlobal::locale()->formatDate(ds,true); 108 start = KGlobal::locale()->formatDate(ds,true);
109 de = ds.addDays( days); 109 de = ds.addDays( days);
110 end = KGlobal::locale()->formatDate(de,true); 110 end = KGlobal::locale()->formatDate(de,true);
111 } 111 }
112 112
113 } 113 }
114 if ( ! ok ) { 114 if ( ! ok ) {
115 start =e->dtStartDateStr(); 115 start =e->dtStartDateStr();
116 end = e->dtEndDateStr(); 116 end = e->dtEndDateStr();
117 ds = e->dtStart().date(); 117 ds = e->dtStart().date();
118 de = e->dtEnd().date(); 118 de = e->dtEnd().date();
119 } 119 }
120 mItem->setText(0,e->summary()); 120 mItem->setText(0,e->summary());
121 mItem->setText(1,start); 121 mItem->setText(1,start);
122 if ( e->doesFloat() ) 122 if ( e->doesFloat() )
123 mItem->setText(2,"---"); 123 mItem->setText(2,"---");
124 else 124 else
125 mItem->setText(2,e->dtStartTimeStr()); 125 mItem->setText(2,e->dtStartTimeStr());
126 mItem->setText(3,end); 126 mItem->setText(3,end);
127 if ( e->doesFloat() ) 127 if ( e->doesFloat() )
128 mItem->setText(4,"---"); 128 mItem->setText(4,"---");
129 else 129 else
130 mItem->setText(4,e->dtEndTimeStr()); 130 mItem->setText(4,e->dtEndTimeStr());
131 if ( e->isAlarmEnabled() ) { 131 if ( e->isAlarmEnabled() ) {
132 mItem->setText(5,e->alarms().first()->offsetText() ); 132 mItem->setText(5,e->alarms().first()->offsetText() );
133 } else { 133 } else {
134 mItem->setText(5, i18n("No")); 134 mItem->setText(5, i18n("No"));
135 } 135 }
136 mItem->setText(6, e->recurrence()->recurrenceText()); 136 mItem->setText(6, e->recurrence()->recurrenceText());
137 if( ! e->doesRecur() ) 137 if( ! e->doesRecur() )
138 mItem->setSortKey( 6, "-" ); 138 mItem->setSortKey( 6, "-" );
139 mItem->setText(7,"---"); 139 mItem->setText(7,"---");
140 mItem->setText(8,"---"); 140 mItem->setText(8,"---");
141 mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No")); 141 mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No"));
142 mItem->setText(10,e->categoriesStr()); 142 mItem->setText(10,e->categoriesStr());
143 143
144 QString key; 144 QString key;
145 QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time(); 145 QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time();
146 key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute()); 146 key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute());
147 mItem->setSortKey(1,key); 147 mItem->setSortKey(1,key);
148 148
149 t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time(); 149 t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time();
150 key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute()); 150 key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute());
151 mItem->setSortKey(3,key); 151 mItem->setSortKey(3,key);
152 return true; 152 return true;
153} 153}
154 154
155bool ListItemVisitor::visit(Todo *t) 155bool ListItemVisitor::visit(Todo *t)
156{ 156{
157 mItem->setText(0,i18n("Todo: %1").arg(t->summary())); 157 mItem->setText(0,i18n("Todo: %1").arg(t->summary()));
158 if (t->hasStartDate()) { 158 if (t->hasStartDate()) {
159 mItem->setText(1,t->dtStartDateStr()); 159 mItem->setText(1,t->dtStartDateStr());
160 if (t->doesFloat()) { 160 if (t->doesFloat()) {
161 mItem->setText(2,"---"); 161 mItem->setText(2,"---");
162 } else { 162 } else {
163 mItem->setText(2,t->dtStartTimeStr()); 163 mItem->setText(2,t->dtStartTimeStr());
164 } 164 }
165 } else { 165 } else {
166 mItem->setText(1,"---"); 166 mItem->setText(1,"---");
167 mItem->setText(2,"---"); 167 mItem->setText(2,"---");
168 } 168 }
169 mItem->setText(3,"---"); 169 mItem->setText(3,"---");
170 mItem->setText(4,"---"); 170 mItem->setText(4,"---");
171 if ( t->isAlarmEnabled() ) { 171 if ( t->isAlarmEnabled() ) {
172 mItem->setText(5,t->alarms().first()->offsetText() ); 172 mItem->setText(5,t->alarms().first()->offsetText() );
173 } else { 173 } else {
174 mItem->setText(5, i18n("No")); 174 mItem->setText(5, i18n("No"));
175 } 175 }
176 mItem->setText(6, t->recurrence()->recurrenceText()); 176 mItem->setText(6, t->recurrence()->recurrenceText());
177 if( ! t->doesRecur() ) 177 if( ! t->doesRecur() )
178 mItem->setSortKey( 6, "-" ); 178 mItem->setSortKey( 6, "-" );
179 if (t->hasDueDate()) { 179 if (t->hasDueDate()) {
180 mItem->setText(7,t->dtDueDateStr()); 180 mItem->setText(7,t->dtDueDateStr());
181 if (t->doesFloat()) { 181 if (t->doesFloat()) {
182 mItem->setText(8,"---"); 182 mItem->setText(8,"---");
183 } else { 183 } else {
184 mItem->setText(8,t->dtDueTimeStr()); 184 mItem->setText(8,t->dtDueTimeStr());
185 } 185 }
186 } else { 186 } else {
187 mItem->setText(7,"---"); 187 mItem->setText(7,"---");
188 mItem->setText(8,"---"); 188 mItem->setText(8,"---");
189 } 189 }
190 mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No")); 190 mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No"));
191 mItem->setText(10,t->categoriesStr()); 191 mItem->setText(10,t->categoriesStr());
192 192
193 QString key; 193 QString key;
194 QDate d; 194 QDate d;
195 if (t->hasDueDate()) { 195 if (t->hasDueDate()) {
196 d = t->dtDue().date(); 196 d = t->dtDue().date();
197 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time(); 197 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time();
198 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); 198 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute());
199 mItem->setSortKey(7,key); 199 mItem->setSortKey(7,key);
200 } 200 }
201 if ( t->hasStartDate() ) { 201 if ( t->hasStartDate() ) {
202 d = t->dtStart().date(); 202 d = t->dtStart().date();
203 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time(); 203 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time();
204 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); 204 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute());
205 mItem->setSortKey(1,key); 205 mItem->setSortKey(1,key);
206 } 206 }
207 return true; 207 return true;
208} 208}
209 209
210bool ListItemVisitor::visit(Journal * j) 210bool ListItemVisitor::visit(Journal * j)
211{ 211{
212 QString des = j->description().left(30); 212 QString des = j->description().left(30);
213 des = des.simplifyWhiteSpace (); 213 des = des.simplifyWhiteSpace ();
214 des.replace (QRegExp ("\\n"),"" ); 214 des.replace (QRegExp ("\\n"),"" );
215 des.replace (QRegExp ("\\r"),"" ); 215 des.replace (QRegExp ("\\r"),"" );
216 mItem->setText(0,i18n("Journal: ")+des.left(25)); 216 mItem->setText(0,i18n("Journal: ")+des.left(25));
217 mItem->setText(1,j->dtStartDateStr()); 217 mItem->setText(1,j->dtStartDateStr());
218 mItem->setText(2,"---"); 218 mItem->setText(2,"---");
219 mItem->setText(3,"---"); 219 mItem->setText(3,"---");
220 mItem->setText(4,"---"); 220 mItem->setText(4,"---");
221 mItem->setText(5,"---"); 221 mItem->setText(5,"---");
222 mItem->setText(6,"---"); 222 mItem->setText(6,"---");
223 mItem->setText(7,j->dtStartDateStr()); 223 mItem->setText(7,j->dtStartDateStr());
224 mItem->setText(8,"---"); 224 mItem->setText(8,"---");
225 mItem->setText(9,"---"); 225 mItem->setText(9,"---");
226 mItem->setText(10,i18n("Last Modified: ")+ KGlobal::locale()->formatDateTime( j->lastModified() , true) ); 226 mItem->setText(10,i18n("Last Modified: ")+ KGlobal::locale()->formatDateTime( j->lastModified() , true) );
227 227
228 QString key; 228 QString key;
229 QDate d = j->dtStart().date(); 229 QDate d = j->dtStart().date();
230 key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 230 key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
231 mItem->setSortKey(1,key); 231 mItem->setSortKey(1,key);
232 mItem->setSortKey(7,key); 232 mItem->setSortKey(7,key);
233 233
234 return true; 234 return true;
235} 235}
236 236
237KOListView::KOListView(Calendar *calendar, QWidget *parent, 237KOListView::KOListView(Calendar *calendar, QWidget *parent,
238 const char *name) 238 const char *name)
239 : KOEventView(calendar, parent, name) 239 : KOEventView(calendar, parent, name)
240{ 240{
241 mActiveItem = 0; 241 mActiveItem = 0;
242 mListView = new KOListViewListView(this); 242 mListView = new KOListViewListView(this);
243 mListView->addColumn(i18n("Summary")); 243 mListView->addColumn(i18n("Summary"));
244 mListView->addColumn(i18n("Start Date")); 244 mListView->addColumn(i18n("Start Date"));
245 mListView->addColumn(i18n("Start Time")); 245 mListView->addColumn(i18n("Start Time"));
246 mListView->addColumn(i18n("End Date")); 246 mListView->addColumn(i18n("End Date"));
247 mListView->addColumn(i18n("End Time")); 247 mListView->addColumn(i18n("End Time"));
248 mListView->addColumn(i18n("Alarm")); // alarm set? 248 mListView->addColumn(i18n("Alarm")); // alarm set?
249 mListView->addColumn(i18n("Recurs")); // recurs? 249 mListView->addColumn(i18n("Recurs")); // recurs?
250 mListView->addColumn(i18n("Due Date")); 250 mListView->addColumn(i18n("Due Date"));
251 mListView->addColumn(i18n("Due Time")); 251 mListView->addColumn(i18n("Due Time"));
252 mListView->addColumn(i18n("Cancelled")); 252 mListView->addColumn(i18n("Cancelled"));
253 mListView->addColumn(i18n("Categories")); 253 mListView->addColumn(i18n("Categories"));
254 254
255 mListView->setColumnAlignment(0,AlignLeft); 255 mListView->setColumnAlignment(0,AlignLeft);
256 mListView->setColumnAlignment(1,AlignLeft); 256 mListView->setColumnAlignment(1,AlignLeft);
257 mListView->setColumnAlignment(2,AlignHCenter); 257 mListView->setColumnAlignment(2,AlignHCenter);
258 mListView->setColumnAlignment(3,AlignLeft); 258 mListView->setColumnAlignment(3,AlignLeft);
259 mListView->setColumnAlignment(4,AlignHCenter); 259 mListView->setColumnAlignment(4,AlignHCenter);
260 mListView->setColumnAlignment(5,AlignLeft); 260 mListView->setColumnAlignment(5,AlignLeft);
261 mListView->setColumnAlignment(6,AlignLeft); 261 mListView->setColumnAlignment(6,AlignLeft);
262 mListView->setColumnAlignment(7,AlignLeft); 262 mListView->setColumnAlignment(7,AlignLeft);
263 mListView->setColumnAlignment(8,AlignLeft); 263 mListView->setColumnAlignment(8,AlignLeft);
264 mListView->setColumnAlignment(9,AlignLeft); 264 mListView->setColumnAlignment(9,AlignLeft);
265 mListView->setColumnAlignment(10,AlignLeft); 265 mListView->setColumnAlignment(10,AlignLeft);
266 mListView->setColumnWidthMode(10, QListView::Manual); 266 mListView->setColumnWidthMode(10, QListView::Manual);
267 mKOListViewWhatsThis = new KOListViewWhatsThis(mListView->viewport(),this); 267 mKOListViewWhatsThis = new KOListViewWhatsThis(mListView->viewport(),this);
268 268
269 int iii = 0; 269 int iii = 0;
270 for ( iii = 0; iii< 10 ; ++iii ) 270 for ( iii = 0; iii< 10 ; ++iii )
271 mListView->setColumnWidthMode( iii, QListView::Manual ); 271 mListView->setColumnWidthMode( iii, QListView::Manual );
272 272
273 QBoxLayout *layoutTop = new QVBoxLayout(this); 273 QBoxLayout *layoutTop = new QVBoxLayout(this);
274 layoutTop->addWidget(mListView); 274 layoutTop->addWidget(mListView);
275 mListView->setFont ( KOPrefs::instance()->mListViewFont ); 275 mListView->setFont ( KOPrefs::instance()->mListViewFont );
276 mPopupMenu = eventPopup(); 276 mPopupMenu = eventPopup();
277 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 277 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
278 i18n("Select all"),this, 278 i18n("Select all"),this,
279 SLOT(allSelection()),true); 279 SLOT(allSelection()),true);
280 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 280 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
281 i18n("Deselect all"),this, 281 i18n("Deselect all"),this,
282 SLOT(clearSelection()),true); 282 SLOT(clearSelection()),true);
283 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 283 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
284 i18n("Delete all selected"),this, 284 i18n("Delete all selected"),this,
285 SLOT(deleteAll()),true); 285 SLOT(deleteAll()),true);
286#ifdef DESKTOP_VERSION 286
287 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 287 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
288 i18n("Hide all selected"),this, 288 i18n("Hide all selected"),this,
289 SLOT(hideAll()),true); 289 SLOT(hideAll()),true);
290#endif 290
291 mPopupMenu->insertSeparator(); 291 mPopupMenu->insertSeparator();
292#ifdef DESKTOP_VERSION 292#ifdef DESKTOP_VERSION
293 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 293 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
294 i18n("Print complete list"),this, 294 i18n("Print complete list"),this,
295 SLOT(printList()),true); 295 SLOT(printList()),true);
296 mPopupMenu->insertSeparator(); 296 mPopupMenu->insertSeparator();
297#endif 297#endif
298 QPopupMenu * exportPO = new QPopupMenu ( this ); 298 QPopupMenu * exportPO = new QPopupMenu ( this );
299 mPopupMenu->insertItem( i18n("Export selected"), exportPO ); 299 mPopupMenu->insertItem( i18n("Export selected"), exportPO );
300 exportPO->insertItem( i18n("As iCal (ics) file..."),this, 300 exportPO->insertItem( i18n("As iCal (ics) file..."),this,
301 SLOT(saveToFile())); 301 SLOT(saveToFile()));
302 exportPO->insertItem( i18n("As vCal (vcs) file..."),this, 302 exportPO->insertItem( i18n("As vCal (vcs) file..."),this,
303 SLOT(saveToFileVCS())); 303 SLOT(saveToFileVCS()));
304 exportPO->insertItem( i18n("Journal/Details..."),this, 304 exportPO->insertItem( i18n("Journal/Details..."),this,
305 SLOT(saveDescriptionToFile())); 305 SLOT(saveDescriptionToFile()));
306 // mPopupMenu->insertSeparator(); 306 // mPopupMenu->insertSeparator();
307 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 307 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
308 i18n("Add Categ. to selected..."),this, 308 i18n("Add Categ. to selected..."),this,
309 SLOT(addCat()),true); 309 SLOT(addCat()),true);
310 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 310 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
311 i18n("Set Categ. for selected..."),this, 311 i18n("Set Categ. for selected..."),this,
312 SLOT(setCat()),true); 312 SLOT(setCat()),true);
313 //mPopupMenu->insertSeparator(); 313 //mPopupMenu->insertSeparator();
314 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 314 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
315 i18n("Set alarm for selected..."),this, 315 i18n("Set alarm for selected..."),this,
316 SLOT(setAlarm()),true); 316 SLOT(setAlarm()),true);
317 317
318 318
319#ifndef DESKTOP_VERSION 319#ifndef DESKTOP_VERSION
320 mPopupMenu->insertSeparator(); 320 mPopupMenu->insertSeparator();
321 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 321 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
322 i18n("Beam selected via IR"),this, 322 i18n("Beam selected via IR"),this,
323 SLOT(beamSelected()),true); 323 SLOT(beamSelected()),true);
324#endif 324#endif
325 /* 325 /*
326 mPopupMenu = new QPopupMenu; 326 mPopupMenu = new QPopupMenu;
327 mPopupMenu->insertItem(i18n("Edit Event"), this, 327 mPopupMenu->insertItem(i18n("Edit Event"), this,
328 SLOT (editEvent())); 328 SLOT (editEvent()));
329 mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, 329 mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this,
330 SLOT (deleteEvent())); 330 SLOT (deleteEvent()));
331 mPopupMenu->insertSeparator(); 331 mPopupMenu->insertSeparator();
332 mPopupMenu->insertItem(i18n("Show Dates"), this, 332 mPopupMenu->insertItem(i18n("Show Dates"), this,
333 SLOT(showDates())); 333 SLOT(showDates()));
334 mPopupMenu->insertItem(i18n("Hide Dates"), this, 334 mPopupMenu->insertItem(i18n("Hide Dates"), this,
335 SLOT(hideDates())); 335 SLOT(hideDates()));
336 */ 336 */
337 QObject::connect(mListView,SIGNAL( newEvent()), 337 QObject::connect(mListView,SIGNAL( newEvent()),
338 this,SIGNAL(signalNewEvent())); 338 this,SIGNAL(signalNewEvent()));
339 QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), 339 QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)),
340 this,SLOT(defaultItemAction(QListViewItem *))); 340 this,SLOT(defaultItemAction(QListViewItem *)));
341 QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *, 341 QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *,
342 const QPoint &, int )), 342 const QPoint &, int )),
343 this,SLOT(popupMenu(QListViewItem *,const QPoint &,int))); 343 this,SLOT(popupMenu(QListViewItem *,const QPoint &,int)));
344 QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)), 344 QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)),
345 SLOT(processSelectionChange(QListViewItem *))); 345 SLOT(processSelectionChange(QListViewItem *)));
346 QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)), 346 QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)),
347 SIGNAL(showIncidenceSignal(Incidence *)) ); 347 SIGNAL(showIncidenceSignal(Incidence *)) );
348 348
349 readSettings(KOGlobals::config(),"KOListView Layout"); 349 readSettings(KOGlobals::config(),"KOListView Layout");
350} 350}
351 351
352KOListView::~KOListView() 352KOListView::~KOListView()
353{ 353{
354 delete mPopupMenu; 354 delete mPopupMenu;
355#if QT_VERSION >= 0x030000 355#if QT_VERSION >= 0x030000
356 356
357#else 357#else
358 delete mKOListViewWhatsThis; 358 delete mKOListViewWhatsThis;
359#endif 359#endif
360} 360}
361 361
362QString KOListView::getWhatsThisText(QPoint p) 362QString KOListView::getWhatsThisText(QPoint p)
363{ 363{
364 KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p ); 364 KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p );
365 if ( item ) 365 if ( item )
366 return KIncidenceFormatter::instance()->getFormattedText( item->data(), 366 return KIncidenceFormatter::instance()->getFormattedText( item->data(),
367 KOPrefs::instance()->mWTshowDetails, 367 KOPrefs::instance()->mWTshowDetails,
368 KOPrefs::instance()->mWTshowCreated, 368 KOPrefs::instance()->mWTshowCreated,
369 KOPrefs::instance()->mWTshowChanged); 369 KOPrefs::instance()->mWTshowChanged);
370 return i18n("That is the list view" ); 370 return i18n("That is the list view" );
371 371
372} 372}
373 373
374void KOListView::updateList() 374void KOListView::updateList()
375{ 375{
376 // qDebug(" KOListView::updateList() "); 376 // qDebug(" KOListView::updateList() ");
377 377
378} 378}
379 379
380void KOListView::clearList() 380void KOListView::clearList()
381{ 381{
382 clear (); 382 clear ();
383} 383}
384void KOListView::addCat( ) 384void KOListView::addCat( )
385{ 385{
386 setCategories( false ); 386 setCategories( false );
387} 387}
388void KOListView::setCat() 388void KOListView::setCat()
389{ 389{
390 setCategories( true ); 390 setCategories( true );
391} 391}
392void KOListView::setAlarm() 392void KOListView::setAlarm()
393{ 393{
394 KOAlarmPrefs kap( this); 394 KOAlarmPrefs kap( this);
395 if ( !kap.exec() ) 395 if ( !kap.exec() )
396 return; 396 return;
397 QStringList itemList; 397 QStringList itemList;
398 QPtrList<KOListViewItem> sel ; 398 QPtrList<KOListViewItem> sel ;
399 QListViewItem *qitem = mListView->firstChild (); 399 QListViewItem *qitem = mListView->firstChild ();
400 while ( qitem ) { 400 while ( qitem ) {
401 if ( qitem->isSelected() ) { 401 if ( qitem->isSelected() ) {
402 Incidence* inc = ((KOListViewItem *) qitem)->data(); 402 Incidence* inc = ((KOListViewItem *) qitem)->data();
403 if ( inc->typeID() != journalID ) { 403 if ( inc->typeID() != journalID ) {
404 if ( inc->typeID() == todoID ) { 404 if ( inc->typeID() == todoID ) {
405 if ( ((Todo*)inc)->hasDueDate() ) 405 if ( ((Todo*)inc)->hasDueDate() )
406 sel.append(((KOListViewItem *)qitem)); 406 sel.append(((KOListViewItem *)qitem));
407 } else 407 } else
408 sel.append(((KOListViewItem *)qitem)); 408 sel.append(((KOListViewItem *)qitem));
409 } 409 }
410 } 410 }
411 qitem = qitem->nextSibling(); 411 qitem = qitem->nextSibling();
412 } 412 }
413 int count = 0; 413 int count = 0;
414 KOListViewItem * item, *temp; 414 KOListViewItem * item, *temp;
415 item = sel.first(); 415 item = sel.first();
416 Incidence* inc; 416 Incidence* inc;
417 while ( item ) { 417 while ( item ) {
418 inc = item->data(); 418 inc = item->data();
419 ++count; 419 ++count;
420 if (kap.mAlarmButton->isChecked()) { 420 if (kap.mAlarmButton->isChecked()) {
421 if (inc->alarms().count() == 0) 421 if (inc->alarms().count() == 0)
422 inc->newAlarm(); 422 inc->newAlarm();
423 QPtrList<Alarm> alarms = inc->alarms(); 423 QPtrList<Alarm> alarms = inc->alarms();
424 Alarm *alarm; 424 Alarm *alarm;
425 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { 425 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) {
426 alarm->setEnabled(true); 426 alarm->setEnabled(true);
427 int j = kap.mAlarmTimeEdit->value()* -60; 427 int j = kap.mAlarmTimeEdit->value()* -60;
428 if (kap.mAlarmIncrCombo->currentItem() == 1) 428 if (kap.mAlarmIncrCombo->currentItem() == 1)
429 j = j * 60; 429 j = j * 60;
430 else if (kap.mAlarmIncrCombo->currentItem() == 2) 430 else if (kap.mAlarmIncrCombo->currentItem() == 2)
431 j = j * (60 * 24); 431 j = j * (60 * 24);
432 alarm->setStartOffset( j ); 432 alarm->setStartOffset( j );
433 433
434 if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) { 434 if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) {
435 alarm->setProcedureAlarm(kap.mAlarmProgram); 435 alarm->setProcedureAlarm(kap.mAlarmProgram);
436 } 436 }
437 else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn()) 437 else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn())
438 alarm->setAudioAlarm(kap.mAlarmSound); 438 alarm->setAudioAlarm(kap.mAlarmSound);
439 else 439 else
440 alarm->setType(Alarm::Invalid); 440 alarm->setType(Alarm::Invalid);
441 //alarm->setAudioAlarm("default"); 441 //alarm->setAudioAlarm("default");
442 // TODO: Deal with multiple alarms 442 // TODO: Deal with multiple alarms
443 break; // For now, stop after the first alarm 443 break; // For now, stop after the first alarm
444 } 444 }
445 } else { 445 } else {
446 Alarm* alarm = inc->alarms().first(); 446 Alarm* alarm = inc->alarms().first();
447 if ( alarm ) { 447 if ( alarm ) {
448 alarm->setEnabled(false); 448 alarm->setEnabled(false);
449 alarm->setType(Alarm::Invalid); 449 alarm->setType(Alarm::Invalid);
450 } 450 }
451 } 451 }
452 ListItemVisitor v(item, mStartDate ); 452 ListItemVisitor v(item, mStartDate );
453 inc->accept(v); 453 inc->accept(v);
454 item = sel.next(); 454 item = sel.next();
455 } 455 }
456 topLevelWidget()->setCaption( i18n("Changed alarm for %1 items").arg( count ) ); 456 topLevelWidget()->setCaption( i18n("Changed alarm for %1 items").arg( count ) );
457 qDebug("KO: Set alarm for %d items", count); 457 qDebug("KO: Set alarm for %d items", count);
458 calendar()->reInitAlarmSettings(); 458 calendar()->reInitAlarmSettings();
459 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); 459 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
460} 460}
461void KOListView::setCategories( bool removeOld ) 461void KOListView::setCategories( bool removeOld )
462{ 462{
463 463
464 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); 464 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 );
465 csd->setColorEnabled(); 465 csd->setColorEnabled();
466 if (! csd->exec()) { 466 if (! csd->exec()) {
467 delete csd; 467 delete csd;
468 return; 468 return;
469 } 469 }
470 QStringList catList = csd->selectedCategories(); 470 QStringList catList = csd->selectedCategories();
471 delete csd; 471 delete csd;
472 // if ( catList.count() == 0 ) 472 // if ( catList.count() == 0 )
473 // return; 473 // return;
474 //catList.sort(); 474 //catList.sort();
475 QString categoriesStr = catList.join(","); 475 QString categoriesStr = catList.join(",");
476 int i; 476 int i;
477 QStringList itemList; 477 QStringList itemList;
478 QPtrList<KOListViewItem> sel ; 478 QPtrList<KOListViewItem> sel ;
479 QListViewItem *qitem = mListView->firstChild (); 479 QListViewItem *qitem = mListView->firstChild ();
480 while ( qitem ) { 480 while ( qitem ) {
481 if ( qitem->isSelected() ) { 481 if ( qitem->isSelected() ) {
482 sel.append(((KOListViewItem *)qitem)); 482 sel.append(((KOListViewItem *)qitem));
483 } 483 }
484 qitem = qitem->nextSibling(); 484 qitem = qitem->nextSibling();
485 } 485 }
486 KOListViewItem * item, *temp; 486 KOListViewItem * item, *temp;
487 item = sel.first(); 487 item = sel.first();
488 if( item ) { 488 if( item ) {
489 Incidence* inc = item->data() ; 489 Incidence* inc = item->data() ;
490 bool setSub = false; 490 bool setSub = false;
491 if( inc->typeID() == todoID && sel.count() == 1 && inc->relations().count() > 0 ) { 491 if( inc->typeID() == todoID && sel.count() == 1 && inc->relations().count() > 0 ) {
492 int result = KMessageBox::warningYesNoCancel(this, 492 int result = KMessageBox::warningYesNoCancel(this,
493 i18n("The todo\n%1\nhas subtodos!\nDo you want to set\nthe categories for\nall subtodos as well?").arg( inc->summary().left ( 25 ) ), 493 i18n("The todo\n%1\nhas subtodos!\nDo you want to set\nthe categories for\nall subtodos as well?").arg( inc->summary().left ( 25 ) ),
494 i18n("Todo has subtodos"), 494 i18n("Todo has subtodos"),
495 i18n("Yes"), 495 i18n("Yes"),
496 i18n("No")); 496 i18n("No"));
497 if (result == KMessageBox::Cancel) item = 0; 497 if (result == KMessageBox::Cancel) item = 0;
498 if (result == KMessageBox::Yes) setSub = true; 498 if (result == KMessageBox::Yes) setSub = true;
499 } 499 }
500 while ( item ) { 500 while ( item ) {
501 inc = item->data(); 501 inc = item->data();
502 if ( removeOld ) { 502 if ( removeOld ) {
503 inc->setCategories( catList, setSub ); 503 inc->setCategories( catList, setSub );
504 } else { 504 } else {
505 inc->addCategories( catList, setSub ); 505 inc->addCategories( catList, setSub );
506 } 506 }
507 ListItemVisitor v(item, mStartDate ); 507 ListItemVisitor v(item, mStartDate );
508 inc->accept(v); 508 inc->accept(v);
509 item = sel.next(); 509 item = sel.next();
510 } 510 }
511 } 511 }
512 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); 512 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
513} 513}
514 514
515void KOListView::beamSelected() 515void KOListView::beamSelected()
516{ 516{
517 int icount = 0; 517 int icount = 0;
518 QPtrList<Incidence> delSel ; 518 QPtrList<Incidence> delSel ;
519 QListViewItem *item = mListView->firstChild (); 519 QListViewItem *item = mListView->firstChild ();
520 while ( item ) { 520 while ( item ) {
521 if ( item->isSelected() ) { 521 if ( item->isSelected() ) {
522 delSel.append(((KOListViewItem *)item)->data()); 522 delSel.append(((KOListViewItem *)item)->data());
523 ++icount; 523 ++icount;
524 } 524 }
525 525
526 item = item->nextSibling(); 526 item = item->nextSibling();
527 } 527 }
528 if ( icount ) { 528 if ( icount ) {
529 emit beamIncidenceList( delSel ); 529 emit beamIncidenceList( delSel );
530 return; 530 return;
531 QString fn ; 531 QString fn ;
532 fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs"; 532 fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs";
533 QString mes; 533 QString mes;
534 bool createbup = true; 534 bool createbup = true;
535 if ( createbup ) { 535 if ( createbup ) {
536 QString description = "\n"; 536 QString description = "\n";
537 CalendarLocal* cal = new CalendarLocal(); 537 CalendarLocal* cal = new CalendarLocal();
538 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 538 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
539 Incidence *incidence = delSel.first(); 539 Incidence *incidence = delSel.first();
540 while ( incidence ) { 540 while ( incidence ) {
541 Incidence *in = incidence->clone(); 541 Incidence *in = incidence->clone();
542 description += in->summary() + "\n"; 542 description += in->summary() + "\n";
543 cal->addIncidence( in ); 543 cal->addIncidence( in );
544 incidence = delSel.next(); 544 incidence = delSel.next();
545 } 545 }
546 FileStorage storage( cal, fn, new VCalFormat ); 546 FileStorage storage( cal, fn, new VCalFormat );
547 storage.save(); 547 storage.save();
548 delete cal; 548 delete cal;
549 mes = i18n("KO/Pi: Ready for beaming"); 549 mes = i18n("KO/Pi: Ready for beaming");
550 topLevelWidget()->setCaption(mes); 550 topLevelWidget()->setCaption(mes);
551 551
552#ifndef DESKTOP_VERSION 552#ifndef DESKTOP_VERSION
553 Ir *ir = new Ir( this ); 553 Ir *ir = new Ir( this );
554 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 554 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
555 ir->send( fn, description, "text/x-vCalendar" ); 555 ir->send( fn, description, "text/x-vCalendar" );
556#endif 556#endif
557 } 557 }
558 } 558 }
559} 559}
560void KOListView::beamDone( Ir *ir ) 560void KOListView::beamDone( Ir *ir )
561{ 561{
562#ifndef DESKTOP_VERSION 562#ifndef DESKTOP_VERSION
563 delete ir; 563 delete ir;
564#endif 564#endif
565 topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done")); 565 topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done"));
566} 566}
567 567
568void KOListView::saveDescriptionToFile() 568void KOListView::saveDescriptionToFile()
569{ 569{
570 570
571 int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), 571 int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"),
572 i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), 572 i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."),
573 i18n("Continue"), i18n("Cancel"), 0, 573 i18n("Continue"), i18n("Cancel"), 0,
574 0, 1 ); 574 0, 1 );
575 if ( result != 0 ) { 575 if ( result != 0 ) {
576 return; 576 return;
577 } 577 }
578 int icount = 0; 578 int icount = 0;
579 QPtrList<Incidence> delSel ; 579 QPtrList<Incidence> delSel ;
580 QListViewItem *item = mListView->firstChild (); 580 QListViewItem *item = mListView->firstChild ();
581 while ( item ) { 581 while ( item ) {
582 if ( item->isSelected() ) { 582 if ( item->isSelected() ) {
583 delSel.append(((KOListViewItem *)item)->data()); 583 delSel.append(((KOListViewItem *)item)->data());
584 ++icount; 584 ++icount;
585 } 585 }
586 586
587 item = item->nextSibling(); 587 item = item->nextSibling();
588 } 588 }
589 if ( icount ) { 589 if ( icount ) {
590 QString fn = KOPrefs::instance()->mLastSaveFile; 590 QString fn = KOPrefs::instance()->mLastSaveFile;
591 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); 591 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this );
592 592
593 if ( fn == "" ) 593 if ( fn == "" )
594 return; 594 return;
595 QFileInfo info; 595 QFileInfo info;
596 info.setFile( fn ); 596 info.setFile( fn );
597 QString mes; 597 QString mes;
598 bool createbup = true; 598 bool createbup = true;
599 if ( info. exists() ) { 599 if ( info. exists() ) {
600 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 600 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
601 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 601 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
602 i18n("Overwrite!"), i18n("Cancel"), 0, 602 i18n("Overwrite!"), i18n("Cancel"), 0,
603 0, 1 ); 603 0, 1 );
604 if ( result != 0 ) { 604 if ( result != 0 ) {
605 createbup = false; 605 createbup = false;
606 } 606 }
607 } 607 }
608 if ( createbup ) { 608 if ( createbup ) {
609 QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") + 609 QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") +
610 KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false); 610 KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false);
611 Incidence *incidence = delSel.first(); 611 Incidence *incidence = delSel.first();
612 icount = 0; 612 icount = 0;
613 while ( incidence ) { 613 while ( incidence ) {
614 if ( incidence->typeID() == journalID ) { 614 if ( incidence->typeID() == journalID ) {
615 text += "\n************************************\n"; 615 text += "\n************************************\n";
616 text += i18n("Journal from: ") +incidence->dtStartDateStr( false ); 616 text += i18n("Journal from: ") +incidence->dtStartDateStr( false );
617 text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); 617 text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false);
618 text +="\n" + i18n("Description: ") + "\n"+ incidence->description(); 618 text +="\n" + i18n("Description: ") + "\n"+ incidence->description();
619 ++icount; 619 ++icount;
620 620
621 } else { 621 } else {
622 if ( !incidence->description().isEmpty() ) { 622 if ( !incidence->description().isEmpty() ) {
623 text += "\n************************************\n"; 623 text += "\n************************************\n";
624 if ( incidence->typeID() == todoID ) 624 if ( incidence->typeID() == todoID )
625 text += i18n("To-Do: "); 625 text += i18n("To-Do: ");
626 text += incidence->summary(); 626 text += incidence->summary();
627 if ( incidence->hasStartDate() ) 627 if ( incidence->hasStartDate() )
628 text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false ); 628 text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false );
629 text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); 629 text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false);
630 if ( !incidence->location().isEmpty() ) 630 if ( !incidence->location().isEmpty() )
631 text += "\n" +i18n("Location: ") + incidence->location(); 631 text += "\n" +i18n("Location: ") + incidence->location();
632 text += "\n" + i18n("Description: ") + "\n" + incidence->description(); 632 text += "\n" + i18n("Description: ") + "\n" + incidence->description();
633 ++icount; 633 ++icount;
634 634
635 } 635 }
636 } 636 }
637 incidence = delSel.next(); 637 incidence = delSel.next();
638 } 638 }
639 QFile file( fn ); 639 QFile file( fn );
640 if (!file.open( IO_WriteOnly ) ) { 640 if (!file.open( IO_WriteOnly ) ) {
641 topLevelWidget()->setCaption(i18n("File open error - nothing saved!") ); 641 topLevelWidget()->setCaption(i18n("File open error - nothing saved!") );
642 return; 642 return;
643 } 643 }
644 QTextStream ts( &file ); 644 QTextStream ts( &file );
645 ts << text; 645 ts << text;
646 file.close(); 646 file.close();
647 //qDebug("%s ", text.latin1()); 647 //qDebug("%s ", text.latin1());
648 mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount ); 648 mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount );
649 KOPrefs::instance()->mLastSaveFile = fn; 649 KOPrefs::instance()->mLastSaveFile = fn;
650 topLevelWidget()->setCaption(mes); 650 topLevelWidget()->setCaption(mes);
651 } 651 }
652 } 652 }
653} 653}
654void KOListView::saveToFileVCS() 654void KOListView::saveToFileVCS()
655{ 655{
656 writeToFile( false ); 656 writeToFile( false );
657} 657}
658void KOListView::saveToFile() 658void KOListView::saveToFile()
659{ 659{
660 writeToFile( true ); 660 writeToFile( true );
661} 661}
662void KOListView::writeToFile( bool iCal ) 662void KOListView::writeToFile( bool iCal )
663{ 663{
664 664
665 int icount = 0; 665 int icount = 0;
666 QPtrList<Incidence> delSel ; 666 QPtrList<Incidence> delSel ;
667 QListViewItem *item = mListView->firstChild (); 667 QListViewItem *item = mListView->firstChild ();
668 bool journal = iCal; // warn only for vCal 668 bool journal = iCal; // warn only for vCal
669 bool addSubTodos = false;
670 bool askSubTodos = true;
669 while ( item ) { 671 while ( item ) {
670 if ( item->isSelected() ) { 672 if ( item->isSelected() ) {
671 if ( !journal ) 673 if ( !journal )
672 if ( ((KOListViewItem *)item)->data()->typeID() == journalID ) 674 if ( ((KOListViewItem *)item)->data()->typeID() == journalID )
673 journal = true; 675 journal = true;
674 delSel.append(((KOListViewItem *)item)->data()); 676 Incidence* inc = ((KOListViewItem *)item)->data();
677 if ( addSubTodos ) {
678 if ( delSel.findRef( inc ) == -1 )
679 delSel.append( inc );
680 } else
681 delSel.append(inc);
682 if ( inc->typeID() == todoID ) {
683 Todo * todo = (Todo*) inc;
684 if ( todo->relations().count() ) {
685 if ( askSubTodos ) {
686 int result = KMessageBox::warningYesNoCancel(this,
687 i18n("A selected todo has subtodos!\nDo you want to export\nall subtodos of all\nselected todos as well?"),
688 i18n("Todo has subtodos"),
689 i18n("Yes"),
690 i18n("No"));
691 if ( result == KMessageBox::Cancel ) {
692 return;
693 }
694 if (result == KMessageBox::Yes)
695 addSubTodos = true;
696 askSubTodos = false;
697 }
698 if ( addSubTodos ) {
699 inc->addRelationsToList( &delSel );
700 }
701 }
702 }
675 ++icount; 703 ++icount;
676 } 704 }
677
678 item = item->nextSibling(); 705 item = item->nextSibling();
679 } 706 }
680 if ( !iCal && journal ) { 707 if ( !iCal && journal ) {
681 int result = KMessageBox::warningContinueCancel(this, 708 int result = KMessageBox::warningContinueCancel(this,
682 i18n("The journal entries can not be\nexported to a vCalendar file."), 709 i18n("The journal entries can not be\nexported to a vCalendar file."),
683 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 710 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
684 true); 711 true);
685 if (result != KMessageBox::Continue) return; 712 if (result != KMessageBox::Continue) return;
686 } 713 }
687 if ( icount ) { 714 if ( icount ) {
688 QString fn = KOPrefs::instance()->mLastSaveFile; 715 QString fn = KOPrefs::instance()->mLastSaveFile;
689 QString extension; 716 QString extension;
690 if ( iCal ) { 717 if ( iCal ) {
691 if ( fn.right( 4 ).lower() == ".vcs" ) { 718 if ( fn.right( 4 ).lower() == ".vcs" ) {
692 fn = fn.left( fn.length() -3) + "ics"; 719 fn = fn.left( fn.length() -3) + "ics";
693 } 720 }
694 } else { 721 } else {
695 if ( fn.right( 4 ).lower() == ".ics" ) { 722 if ( fn.right( 4 ).lower() == ".ics" ) {
696 fn = fn.left( fn.length() -3) + "vcs"; 723 fn = fn.left( fn.length() -3) + "vcs";
697 } 724 }
698 } 725 }
699 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); 726 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this );
700 727
701 if ( fn == "" ) 728 if ( fn == "" )
702 return; 729 return;
703 QFileInfo info; 730 QFileInfo info;
704 info.setFile( fn ); 731 info.setFile( fn );
705 QString mes; 732 QString mes;
706 bool createbup = true; 733 bool createbup = true;
707 if ( info. exists() ) { 734 if ( info. exists() ) {
708 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 735 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
709 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 736 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
710 i18n("Overwrite!"), i18n("Cancel"), 0, 737 i18n("Overwrite!"), i18n("Cancel"), 0,
711 0, 1 ); 738 0, 1 );
712 if ( result != 0 ) { 739 if ( result != 0 ) {
713 createbup = false; 740 createbup = false;
714 } 741 }
715 } 742 }
716 if ( createbup ) { 743 if ( createbup ) {
717 CalendarLocal cal; 744 CalendarLocal cal;
718 cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 745 cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
719 Incidence *incidence = delSel.first(); 746 Incidence *incidence = delSel.first();
720 while ( incidence ) { 747 while ( incidence ) {
721 cal.addIncidence( incidence->clone() ); 748 cal.addIncidence( incidence->clone() );
722 incidence = delSel.next(); 749 incidence = delSel.next();
723 } 750 }
724 if ( iCal ) { 751 if ( iCal ) {
725 ICalFormat format; 752 ICalFormat format;
726 format.save( &cal, fn ); 753 format.save( &cal, fn );
727 } else { 754 } else {
728 755
729 VCalFormat format; 756 VCalFormat format;
730 format.save( &cal, fn ); 757 format.save( &cal, fn );
731 } 758 }
732 mes = i18n("KO/Pi:Saved %1").arg(fn ); 759 mes = i18n("KO/Pi:Saved %1").arg(fn );
733 KOPrefs::instance()->mLastSaveFile = fn; 760 KOPrefs::instance()->mLastSaveFile = fn;
734 topLevelWidget()->setCaption(mes); 761 topLevelWidget()->setCaption(mes);
735 } 762 }
736 } 763 }
737 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); 764 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
738} 765}
739void KOListView::hideAll() 766void KOListView::hideAll()
740{ 767{
741 QPtrList<QListViewItem> delSel ; 768 QPtrList<QListViewItem> delSel ;
742 QListViewItem *item = mListView->firstChild (); 769 QListViewItem *item = mListView->firstChild ();
743 while ( item ) { 770 while ( item ) {
744 if ( item->isSelected() ) { 771 if ( item->isSelected() ) {
745 delSel.append(item); 772 delSel.append(item);
746 } 773 }
747 item = item->nextSibling(); 774 item = item->nextSibling();
748 } 775 }
749 item = delSel.first() ; 776 item = delSel.first() ;
750 while ( item ) { 777 while ( item ) {
751 QListViewItem * del = item; 778 QListViewItem * del = item;
752 item = delSel.next(); 779 item = delSel.next();
753 delete del; 780 delete del;
754 } 781 }
755} 782}
756void KOListView::printList() 783void KOListView::printList()
757{ 784{
758 mListView->printList(); 785 mListView->printList();
759} 786}
760void KOListView::deleteAll() 787void KOListView::deleteAll()
761{ 788{
762 int icount = 0; 789 int icount = 0;
763 QPtrList<Incidence> delSel ; 790 QPtrList<Incidence> delSel ;
764 QListViewItem *item = mListView->firstChild (); 791 QListViewItem *item = mListView->firstChild ();
765 while ( item ) { 792 while ( item ) {
766 if ( item->isSelected() ) { 793 if ( item->isSelected() ) {
767 delSel.append(((KOListViewItem *)item)->data()); 794 delSel.append(((KOListViewItem *)item)->data());
768 ++icount; 795 ++icount;
769 } 796 }
770 797
771 item = item->nextSibling(); 798 item = item->nextSibling();
772 } 799 }
773 if ( icount ) { 800 if ( icount ) {
774 Incidence *incidence = delSel.first(); 801 Incidence *incidence = delSel.first();
775 Incidence *toDelete; 802 Incidence *toDelete;
776 KOPrefs *p = KOPrefs::instance(); 803 KOPrefs *p = KOPrefs::instance();
777 bool confirm = p->mConfirm; 804 bool confirm = p->mConfirm;
778 QString mess; 805 QString mess;
779 mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount ); 806 mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount );
780 if ( KMessageBox::Continue == KMessageBox::warningContinueCancel(this, mess + i18n("All selected items will be\npermanently deleted.\n(Deleting items will take\nsome time on a PDA)\n"), i18n("KO/Pi Confirmation"),i18n("Delete")) ) { 807 if ( KMessageBox::Continue == KMessageBox::warningContinueCancel(this, mess + i18n("All selected items will be\npermanently deleted.\n(Deleting items will take\nsome time on a PDA)\n"), i18n("KO/Pi Confirmation"),i18n("Delete")) ) {
781 p->mConfirm = false; 808 p->mConfirm = false;
782 int delCounter = 0; 809 int delCounter = 0;
783 QDialog dia ( this, "p-dialog", true ); 810 QDialog dia ( this, "p-dialog", true );
784 QLabel lab (i18n("Close dialog to abort deletion!"), &dia ); 811 QLabel lab (i18n("Close dialog to abort deletion!"), &dia );
785 QVBoxLayout lay( &dia ); 812 QVBoxLayout lay( &dia );
786 lay.setMargin(7); 813 lay.setMargin(7);
787 lay.setSpacing(7); 814 lay.setSpacing(7);
788 lay.addWidget( &lab); 815 lay.addWidget( &lab);
789 QProgressBar bar( icount, &dia ); 816 QProgressBar bar( icount, &dia );
790 lay.addWidget( &bar); 817 lay.addWidget( &bar);
791 int w = 220; 818 int w = 220;
792 int h = 50; 819 int h = 50;
793 int dw = QApplication::desktop()->width(); 820 int dw = QApplication::desktop()->width();
794 int dh = QApplication::desktop()->height(); 821 int dh = QApplication::desktop()->height();
795 dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 822 dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
796 //dia.resize( 240,50 ); 823 //dia.resize( 240,50 );
797 dia.show(); 824 dia.show();
798 825
799 while ( incidence ) { 826 while ( incidence ) {
800 bar.setProgress( delCounter ); 827 bar.setProgress( delCounter );
801 mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter ); 828 mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter );
802 dia.setCaption( mess ); 829 dia.setCaption( mess );
803 qApp->processEvents(); 830 qApp->processEvents();
804 toDelete = (incidence); 831 toDelete = (incidence);
805 incidence = delSel.next(); 832 incidence = delSel.next();
806 emit deleteIncidenceSignal(toDelete ); 833 emit deleteIncidenceSignal(toDelete );
807 if ( dia.result() != 0 ) 834 if ( dia.result() != 0 )
808 break; 835 break;
809 836
810 } 837 }
811 mess = mess.sprintf( i18n("%d items remaining in list."), count() ); 838 mess = mess.sprintf( i18n("%d items remaining in list."), count() );
812 topLevelWidget ()->setCaption( mess ); 839 topLevelWidget ()->setCaption( mess );
813 p->mConfirm = confirm; 840 p->mConfirm = confirm;
814 } 841 }
815 } 842 }
816 843
817 844
818} 845}
819int KOListView::maxDatesHint() 846int KOListView::maxDatesHint()
820{ 847{
821 return 0; 848 return 0;
822} 849}
823 850
824int KOListView::currentDateCount() 851int KOListView::currentDateCount()
825{ 852{
826 return 0; 853 return 0;
827} 854}
828 855
829QPtrList<Incidence> KOListView::selectedIncidences() 856QPtrList<Incidence> KOListView::selectedIncidences()
830{ 857{
831 QPtrList<Incidence> eventList; 858 QPtrList<Incidence> eventList;
832 QListViewItem *item = mListView->firstChild (); 859 QListViewItem *item = mListView->firstChild ();
833 while ( item ) { 860 while ( item ) {
834 if ( item->isSelected() ) { 861 if ( item->isSelected() ) {
835 eventList.append(((KOListViewItem *)item)->data()); 862 eventList.append(((KOListViewItem *)item)->data());
836 } 863 }
837 864
838 item = item->nextSibling(); 865 item = item->nextSibling();
839 } 866 }
840 867
841 // // QListViewItem *item = mListView->selectedItem(); 868 // // QListViewItem *item = mListView->selectedItem();
842 //if (item) eventList.append(((KOListViewItem *)item)->data()); 869 //if (item) eventList.append(((KOListViewItem *)item)->data());
843 870
844 return eventList; 871 return eventList;
845} 872}
846 873
847DateList KOListView::selectedDates() 874DateList KOListView::selectedDates()
848{ 875{
849 DateList eventList; 876 DateList eventList;
850 return eventList; 877 return eventList;
851} 878}
852 879
853void KOListView::showDates(bool show) 880void KOListView::showDates(bool show)
854{ 881{
855 // Shouldn't we set it to a value greater 0? When showDates is called with 882 // Shouldn't we set it to a value greater 0? When showDates is called with
856 // show == true at first, then the columnwidths are set to zero. 883 // show == true at first, then the columnwidths are set to zero.
857 static int oldColWidth1 = 0; 884 static int oldColWidth1 = 0;
858 static int oldColWidth3 = 0; 885 static int oldColWidth3 = 0;
859 886
860 if (!show) { 887 if (!show) {
861 oldColWidth1 = mListView->columnWidth(1); 888 oldColWidth1 = mListView->columnWidth(1);
862 oldColWidth3 = mListView->columnWidth(3); 889 oldColWidth3 = mListView->columnWidth(3);
863 mListView->setColumnWidth(1, 0); 890 mListView->setColumnWidth(1, 0);
864 mListView->setColumnWidth(3, 0); 891 mListView->setColumnWidth(3, 0);
865 } else { 892 } else {
866 mListView->setColumnWidth(1, oldColWidth1); 893 mListView->setColumnWidth(1, oldColWidth1);
867 mListView->setColumnWidth(3, oldColWidth3); 894 mListView->setColumnWidth(3, oldColWidth3);
868 } 895 }
869 mListView->repaint(); 896 mListView->repaint();
870} 897}
871 898
872void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd, 899void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd,
873 const QDate &td) 900 const QDate &td)
874{ 901{
875#ifndef KORG_NOPRINTER 902#ifndef KORG_NOPRINTER
876 calPrinter->preview(CalPrinter::Day, fd, td); 903 calPrinter->preview(CalPrinter::Day, fd, td);
877#endif 904#endif
878} 905}
879 906
880void KOListView::showDates() 907void KOListView::showDates()
881{ 908{
882 showDates(true); 909 showDates(true);
883} 910}
884 911
885void KOListView::hideDates() 912void KOListView::hideDates()
886{ 913{
887 showDates(false); 914 showDates(false);
888} 915}
889 916
890void KOListView::resetFocus() 917void KOListView::resetFocus()
891{ 918{
892 topLevelWidget()->setActiveWindow(); 919 topLevelWidget()->setActiveWindow();
893 topLevelWidget()->raise(); 920 topLevelWidget()->raise();
894 mListView->setFocus(); 921 mListView->setFocus();
895} 922}
896void KOListView::updateView() 923void KOListView::updateView()
897{ 924{
898 mListView->setFocus(); 925 mListView->setFocus();
899 if ( mListView->firstChild () ) 926 if ( mListView->firstChild () )
900 mListView->setCurrentItem( mListView->firstChild () ); 927 mListView->setCurrentItem( mListView->firstChild () );
901} 928}
902void KOListView::updateConfig() 929void KOListView::updateConfig()
903{ 930{
904 931
905 mListView->setFont ( KOPrefs::instance()->mListViewFont ); 932 mListView->setFont ( KOPrefs::instance()->mListViewFont );
906 updateView(); 933 updateView();
907 934
908} 935}
909void KOListView::setStartDate(const QDate &start) 936void KOListView::setStartDate(const QDate &start)
910{ 937{
911 mStartDate = start; 938 mStartDate = start;
912} 939}
913 940
914void KOListView::showDates(const QDate &start, const QDate &end) 941void KOListView::showDates(const QDate &start, const QDate &end)
915{ 942{
916 clear(); 943 clear();
917 mStartDate = start; 944 mStartDate = start;
918 QDate date = start; 945 QDate date = start;
919 QPtrList<Journal> j_list; 946 QPtrList<Journal> j_list;
920 while( date <= end ) { 947 while( date <= end ) {
921 addEvents(calendar()->events(date)); 948 addEvents(calendar()->events(date));
922 addTodos(calendar()->todos(date)); 949 addTodos(calendar()->todos(date));
923 Journal* jo = calendar()->journal(date); 950 Journal* jo = calendar()->journal(date);
924 if ( jo ) 951 if ( jo )
925 j_list.append( jo ); 952 j_list.append( jo );
926 date = date.addDays( 1 ); 953 date = date.addDays( 1 );
927 } 954 }
928 addJournals(j_list); 955 addJournals(j_list);
929 emit incidenceSelected( 0 ); 956 emit incidenceSelected( 0 );
930 updateView(); 957 updateView();
931 958
932} 959}
933 960
934void KOListView::addEvents(QPtrList<Event> eventList) 961void KOListView::addEvents(QPtrList<Event> eventList)
935{ 962{
936 963
937 Event *ev; 964 Event *ev;
938 for(ev = eventList.first(); ev; ev = eventList.next()) { 965 for(ev = eventList.first(); ev; ev = eventList.next()) {
939 addIncidence(ev); 966 addIncidence(ev);
940 } 967 }
941 if ( !mListView->currentItem() ){ 968 if ( !mListView->currentItem() ){
942 updateView(); 969 updateView();
943 } 970 }
944} 971}
945 972
946void KOListView::addTodos(QPtrList<Todo> eventList) 973void KOListView::addTodos(QPtrList<Todo> eventList)
947{ 974{
948 Todo *ev; 975 Todo *ev;
949 for(ev = eventList.first(); ev; ev = eventList.next()) { 976 for(ev = eventList.first(); ev; ev = eventList.next()) {
950 addIncidence(ev); 977 addIncidence(ev);
951 } 978 }
952 if ( !mListView->currentItem() ){ 979 if ( !mListView->currentItem() ){
953 updateView(); 980 updateView();
954 } 981 }
955} 982}
956void KOListView::addJournals(QPtrList<Journal> eventList) 983void KOListView::addJournals(QPtrList<Journal> eventList)
957{ 984{
958 Journal *ev; 985 Journal *ev;
959 for(ev = eventList.first(); ev; ev = eventList.next()) { 986 for(ev = eventList.first(); ev; ev = eventList.next()) {
960 addIncidence(ev); 987 addIncidence(ev);
961 } 988 }
962 if ( !mListView->currentItem() ){ 989 if ( !mListView->currentItem() ){
963 updateView(); 990 updateView();
964 } 991 }
965} 992}
966 993
967void KOListView::addIncidence(Incidence *incidence) 994void KOListView::addIncidence(Incidence *incidence)
968{ 995{
969 if ( mUidDict.find( incidence->uid() ) ) return; 996 if ( mUidDict.find( incidence->uid() ) ) return;
970 997
971 // mListView->setFont ( KOPrefs::instance()->mListViewFont ); 998 // mListView->setFont ( KOPrefs::instance()->mListViewFont );
972 mUidDict.insert( incidence->uid(), incidence ); 999 mUidDict.insert( incidence->uid(), incidence );
973 KOListViewItem *item = new KOListViewItem( incidence, mListView ); 1000 KOListViewItem *item = new KOListViewItem( incidence, mListView );
974 ListItemVisitor v(item, mStartDate ); 1001 ListItemVisitor v(item, mStartDate );
975 if (incidence->accept(v)) { 1002 if (incidence->accept(v)) {
976 return; 1003 return;
977 } 1004 }
978 else delete item; 1005 else delete item;
979} 1006}
980 1007
981void KOListView::showEvents(QPtrList<Event> eventList) 1008void KOListView::showEvents(QPtrList<Event> eventList)
982{ 1009{
983 clear(); 1010 clear();
984 1011
985 addEvents(eventList); 1012 addEvents(eventList);
986 1013
987 // After new creation of list view no events are selected. 1014 // After new creation of list view no events are selected.
988 emit incidenceSelected( 0 ); 1015 emit incidenceSelected( 0 );
989} 1016}
990int KOListView::count() 1017int KOListView::count()
991{ 1018{
992 return mListView->childCount(); 1019 return mListView->childCount();
993} 1020}
994 1021
995void KOListView::changeEventDisplay(Event *event, int action) 1022void KOListView::changeEventDisplay(Event *event, int action)
996{ 1023{
997 KOListViewItem *item; 1024 KOListViewItem *item;
998 1025
999 switch(action) { 1026 switch(action) {
1000 case KOGlobals::EVENTADDED: 1027 case KOGlobals::EVENTADDED:
1001 addIncidence( event ); 1028 addIncidence( event );
1002 break; 1029 break;
1003 case KOGlobals::EVENTEDITED: 1030 case KOGlobals::EVENTEDITED:
1004 item = getItemForEvent(event); 1031 item = getItemForEvent(event);
1005 if (item) { 1032 if (item) {
1006 mUidDict.remove( event->uid() ); 1033 mUidDict.remove( event->uid() );
1007 delete item; 1034 delete item;
1008 addIncidence( event ); 1035 addIncidence( event );
1009 } 1036 }
1010 break; 1037 break;
1011 case KOGlobals::EVENTDELETED: 1038 case KOGlobals::EVENTDELETED:
1012 item = getItemForEvent(event); 1039 item = getItemForEvent(event);
1013 if (item) { 1040 if (item) {
1014 mUidDict.remove( event->uid() ); 1041 mUidDict.remove( event->uid() );
1015 delete item; 1042 delete item;
1016 } 1043 }
1017 break; 1044 break;
1018 default: 1045 default:
1019 ; 1046 ;
1020 } 1047 }
1021} 1048}
1022 1049
1023KOListViewItem *KOListView::getItemForEvent(Event *event) 1050KOListViewItem *KOListView::getItemForEvent(Event *event)
1024{ 1051{
1025 KOListViewItem *item = (KOListViewItem *)mListView->firstChild(); 1052 KOListViewItem *item = (KOListViewItem *)mListView->firstChild();
1026 while (item) { 1053 while (item) {
1027 if (item->data() == event) return item; 1054 if (item->data() == event) return item;
1028 item = (KOListViewItem *)item->nextSibling(); 1055 item = (KOListViewItem *)item->nextSibling();
1029 } 1056 }
1030 return 0; 1057 return 0;
1031} 1058}
1032 1059
1033void KOListView::defaultItemAction(QListViewItem *i) 1060void KOListView::defaultItemAction(QListViewItem *i)
1034{ 1061{
1035 KOListViewItem *item = static_cast<KOListViewItem *>( i ); 1062 KOListViewItem *item = static_cast<KOListViewItem *>( i );
1036 if ( item ) defaultAction( item->data() ); 1063 if ( item ) defaultAction( item->data() );
1037 1064
1038} 1065}
1039 1066
1040void KOListView::popupMenu(QListViewItem *item,const QPoint &,int) 1067void KOListView::popupMenu(QListViewItem *item,const QPoint &,int)
1041{ 1068{
1042 mActiveItem = (KOListViewItem *)item; 1069 mActiveItem = (KOListViewItem *)item;
1043 if (mActiveItem) { 1070 if (mActiveItem) {
1044 Incidence *incidence = mActiveItem->data(); 1071 Incidence *incidence = mActiveItem->data();
1045 mPopupMenu->enableDefault( !mListView->hasMultiSelection( item ) ); 1072 mPopupMenu->enableDefault( !mListView->hasMultiSelection( item ) );
1046 mPopupMenu->showIncidencePopup(incidence); 1073 mPopupMenu->showIncidencePopup(incidence);
1047 1074
1048 /* 1075 /*
1049 if ( incidence && incidence->type() == "Event" ) { 1076 if ( incidence && incidence->type() == "Event" ) {
1050 Event *event = static_cast<Event *>( incidence ); 1077 Event *event = static_cast<Event *>( incidence );
1051 mPopupMenu->showEventPopup(event); 1078 mPopupMenu->showEventPopup(event);
1052 } 1079 }
1053 */ 1080 */
1054 } 1081 }
1055} 1082}
1056 1083
1057void KOListView::readSettings(KConfig *config, QString setting) 1084void KOListView::readSettings(KConfig *config, QString setting)
1058{ 1085{
1059 // qDebug("KOListView::readSettings "); 1086 // qDebug("KOListView::readSettings ");
1060 mListView->restoreLayout(config,setting); 1087 mListView->restoreLayout(config,setting);
1061} 1088}
1062 1089
1063void KOListView::writeSettings(KConfig *config, QString setting) 1090void KOListView::writeSettings(KConfig *config, QString setting)
1064{ 1091{
1065 // qDebug("KOListView::writeSettings "); 1092 // qDebug("KOListView::writeSettings ");
1066 mListView->saveLayout(config, setting); 1093 mListView->saveLayout(config, setting);
1067} 1094}
1068 1095
1069void KOListView::processSelectionChange(QListViewItem *) 1096void KOListView::processSelectionChange(QListViewItem *)
1070{ 1097{
1071 1098
1072 KOListViewItem *item = 1099 KOListViewItem *item =
1073 static_cast<KOListViewItem *>( mListView->currentItem() ); 1100 static_cast<KOListViewItem *>( mListView->currentItem() );
1074 1101
1075 if ( !item ) { 1102 if ( !item ) {
1076 emit incidenceSelected( 0 ); 1103 emit incidenceSelected( 0 );
1077 } else { 1104 } else {
1078 emit incidenceSelected( item->data() ); 1105 emit incidenceSelected( item->data() );
1079 } 1106 }
1080} 1107}
1081 1108
1082void KOListView::clearSelection() 1109void KOListView::clearSelection()
1083{ 1110{
1084 mListView->selectAll( false ); 1111 mListView->selectAll( false );
1085} 1112}
1086void KOListView::allSelection() 1113void KOListView::allSelection()
1087{ 1114{
1088 mListView->selectAll( true ); 1115 mListView->selectAll( true );
1089} 1116}
1090 1117
1091void KOListView::clear() 1118void KOListView::clear()
1092{ 1119{
1093 mListView->clear(); 1120 mListView->clear();
1094 mUidDict.clear(); 1121 mUidDict.clear();
1095} 1122}
1096 1123
1097Incidence* KOListView::currentItem() 1124Incidence* KOListView::currentItem()
1098{ 1125{
1099 if ( mListView->currentItem() ) 1126 if ( mListView->currentItem() )
1100 return ((KOListViewItem*) mListView->currentItem())->data(); 1127 return ((KOListViewItem*) mListView->currentItem())->data();
1101 return 0; 1128 return 0;
1102} 1129}
1103void KOListView::keyPressEvent ( QKeyEvent *e) 1130void KOListView::keyPressEvent ( QKeyEvent *e)
1104{ 1131{
1105 1132
1106 if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) { 1133 if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) {
1107 deleteAll(); 1134 deleteAll();
1108 return; 1135 return;
1109 } 1136 }
1110 1137
1111 e->ignore(); 1138 e->ignore();
1112} 1139}
1113void KOListViewListView::keyPressEvent ( QKeyEvent *e) 1140void KOListViewListView::keyPressEvent ( QKeyEvent *e)
1114{ 1141{
1115 1142
1116 switch ( e->key() ) { 1143 switch ( e->key() ) {
1117 case Qt::Key_Down: 1144 case Qt::Key_Down:
1118 if ( e->state() == ShiftButton ) { 1145 if ( e->state() == ShiftButton ) {
1119 QListViewItem* cn = currentItem(); 1146 QListViewItem* cn = currentItem();
1120 if ( !cn ) 1147 if ( !cn )
1121 cn = firstChild(); 1148 cn = firstChild();
1122 if ( !cn ) 1149 if ( !cn )
1123 return; 1150 return;
1124 while ( cn->nextSibling() ) 1151 while ( cn->nextSibling() )
1125 cn = cn->nextSibling(); 1152 cn = cn->nextSibling();
1126 setCurrentItem ( cn ); 1153 setCurrentItem ( cn );
1127 ensureItemVisible ( cn ); 1154 ensureItemVisible ( cn );
1128 1155
1129 e->accept(); 1156 e->accept();
1130 return; 1157 return;
1131 } 1158 }
1132 if ( e->state() == ControlButton ) { 1159 if ( e->state() == ControlButton ) {
1133 int count = childCount (); 1160 int count = childCount ();
1134 int jump = count / 5; 1161 int jump = count / 5;
1135 QListViewItem* cn; 1162 QListViewItem* cn;
1136 cn = currentItem(); 1163 cn = currentItem();
1137 if ( ! cn ) 1164 if ( ! cn )
1138 return; 1165 return;
1139 if ( jump == 0 ) 1166 if ( jump == 0 )
1140 jump = 1; 1167 jump = 1;
1141 while ( jump && cn->nextSibling() ) { 1168 while ( jump && cn->nextSibling() ) {
1142 cn = cn->nextSibling(); 1169 cn = cn->nextSibling();
1143 --jump; 1170 --jump;
1144 } 1171 }
1145 setCurrentItem ( cn ); 1172 setCurrentItem ( cn );
1146 ensureItemVisible ( cn ); 1173 ensureItemVisible ( cn );
1147 1174
1148 } else 1175 } else
1149 QListView::keyPressEvent ( e ) ; 1176 QListView::keyPressEvent ( e ) ;
1150 e->accept(); 1177 e->accept();
1151 break; 1178 break;
1152 1179
1153 case Qt::Key_Up: 1180 case Qt::Key_Up:
1154 if ( e->state() == ShiftButton ) { 1181 if ( e->state() == ShiftButton ) {
1155 QListViewItem* cn = firstChild(); 1182 QListViewItem* cn = firstChild();
1156 if ( cn ) { 1183 if ( cn ) {
1157 setCurrentItem ( cn ); 1184 setCurrentItem ( cn );
1158 ensureItemVisible ( cn ); 1185 ensureItemVisible ( cn );
1159 } 1186 }
1160 e->accept(); 1187 e->accept();
1161 return; 1188 return;
1162 } 1189 }
1163 if ( e->state() == ControlButton ) { 1190 if ( e->state() == ControlButton ) {
1164 int count = childCount (); 1191 int count = childCount ();
1165 int jump = count / 5; 1192 int jump = count / 5;
1166 QListViewItem* cn; 1193 QListViewItem* cn;
1167 cn = currentItem(); 1194 cn = currentItem();
1168 if ( ! cn ) 1195 if ( ! cn )
1169 return; 1196 return;
1170 if ( jump == 0 ) 1197 if ( jump == 0 )
1171 jump = 1; 1198 jump = 1;
1172 while ( jump && cn->itemAbove ()) { 1199 while ( jump && cn->itemAbove ()) {
1173 cn = cn->itemAbove (); 1200 cn = cn->itemAbove ();
1174 --jump; 1201 --jump;
1175 } 1202 }
1176 setCurrentItem ( cn ); 1203 setCurrentItem ( cn );
1177 ensureItemVisible ( cn ); 1204 ensureItemVisible ( cn );
1178 } else 1205 } else
1179 QListView::keyPressEvent ( e ) ; 1206 QListView::keyPressEvent ( e ) ;
1180 e->accept(); 1207 e->accept();
1181 break; 1208 break;
1182 case Qt::Key_I: { 1209 case Qt::Key_I: {
1183 QListViewItem* cn; 1210 QListViewItem* cn;
1184 cn = currentItem(); 1211 cn = currentItem();
1185 if ( cn ) { 1212 if ( cn ) {
1186 KOListViewItem* ci = (KOListViewItem*)( cn ); 1213 KOListViewItem* ci = (KOListViewItem*)( cn );
1187 if ( ci ){ 1214 if ( ci ){
1188 //emit showIncidence( ci->data()); 1215 //emit showIncidence( ci->data());
1189 cn = cn->nextSibling(); 1216 cn = cn->nextSibling();
1190 if ( cn ) { 1217 if ( cn ) {
1191 setCurrentItem ( cn ); 1218 setCurrentItem ( cn );
1192 ensureItemVisible ( cn ); 1219 ensureItemVisible ( cn );
1193 } 1220 }
1194 emit showIncidence( ci->data()); 1221 emit showIncidence( ci->data());
1195 } 1222 }
1196 } 1223 }
1197 e->accept(); 1224 e->accept();
1198 } 1225 }
1199 break; 1226 break;
1200 case Qt::Key_Return: 1227 case Qt::Key_Return:
1201 case Qt::Key_Enter: 1228 case Qt::Key_Enter:
1202 { 1229 {
1203 QListViewItem* cn; 1230 QListViewItem* cn;
1204 cn = currentItem(); 1231 cn = currentItem();
1205 if ( cn ) { 1232 if ( cn ) {
1206 KOListViewItem* ci = (KOListViewItem*)( cn ); 1233 KOListViewItem* ci = (KOListViewItem*)( cn );
1207 if ( ci ){ 1234 if ( ci ){
1208 if ( e->state() == ShiftButton ) 1235 if ( e->state() == ShiftButton )
1209 ci->setSelected( false ); 1236 ci->setSelected( false );
1210 else 1237 else
1211 ci->setSelected( true ); 1238 ci->setSelected( true );
1212 cn = cn->nextSibling(); 1239 cn = cn->nextSibling();
1213 if ( cn ) { 1240 if ( cn ) {
1214 setCurrentItem ( cn ); 1241 setCurrentItem ( cn );
1215 ensureItemVisible ( cn ); 1242 ensureItemVisible ( cn );
1216 } 1243 }
1217 } 1244 }
1218 } 1245 }
1219 e->accept(); 1246 e->accept();
1220 } 1247 }
1221 break; 1248 break;
1222 default: 1249 default:
1223 e->ignore(); 1250 e->ignore();
1224 } 1251 }
1225} 1252}
1226KOListViewListView::KOListViewListView(KOListView * lv ) 1253KOListViewListView::KOListViewListView(KOListView * lv )
1227 : KListView( lv, "kolistlistview", false ) 1254 : KListView( lv, "kolistlistview", false )
1228{ 1255{
1229 mYMousePos = 0; 1256 mYMousePos = 0;
1230 mPopupTimer = new QTimer(this); 1257 mPopupTimer = new QTimer(this);
1231 connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); 1258 connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu()));
1232#ifndef DESKTOP_VERSION 1259#ifndef DESKTOP_VERSION
1233 //QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); 1260 //QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold );
1234#endif 1261#endif
1235 setSelectionMode( QListView::Multi ); 1262 setSelectionMode( QListView::Multi );
1236 setMultiSelection( true); 1263 setMultiSelection( true);
1237} 1264}
1238bool KOListViewListView::hasMultiSelection(QListViewItem* item) 1265bool KOListViewListView::hasMultiSelection(QListViewItem* item)
1239{ 1266{
1240 int selCount = 0; 1267 int selCount = 0;
1241 QListViewItem *qitem = firstChild (); 1268 QListViewItem *qitem = firstChild ();
1242 while ( qitem ) { 1269 while ( qitem ) {
1243 if ( qitem->isSelected() && item != qitem ) 1270 if ( qitem->isSelected() && item != qitem )
1244 return true; 1271 return true;
1245 qitem = qitem->nextSibling(); 1272 qitem = qitem->nextSibling();
1246 } 1273 }
1247 return false; 1274 return false;
1248} 1275}
1249void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e) 1276void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e)
1250{ 1277{
1251 if (!e) return; 1278 if (!e) return;
1252 QPoint vp = contentsToViewport(e->pos()); 1279 QPoint vp = contentsToViewport(e->pos());
1253 QListViewItem *item = itemAt(vp); 1280 QListViewItem *item = itemAt(vp);
1254 if (!item) { 1281 if (!item) {
1255 emit newEvent(); 1282 emit newEvent();
1256 return; 1283 return;
1257 } 1284 }
1258 KListView::contentsMouseDoubleClickEvent(e); 1285 KListView::contentsMouseDoubleClickEvent(e);
1259} 1286}
1260#if 0 1287#if 0
1261void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) 1288void KOListViewListView::contentsMousePressEvent(QMouseEvent *e)
1262{ 1289{
1263 //qDebug("contentsMousePressEvent++++ "); 1290 //qDebug("contentsMousePressEvent++++ ");
1264 KListView::contentsMousePressEvent( e ); 1291 KListView::contentsMousePressEvent( e );
1265 if ( e->button() == RightButton ) { 1292 if ( e->button() == RightButton ) {
1266 QListViewItem* ci = currentItem(); 1293 QListViewItem* ci = currentItem();
1267 clearSelection () ; 1294 clearSelection () ;
1268 if ( ci ) 1295 if ( ci )
1269 ci->setSelected( true ); 1296 ci->setSelected( true );
1270 } 1297 }
1271} 1298}
1272void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) 1299void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e)
1273{ 1300{
1274 KListView::contentsMouseReleaseEvent(e); 1301 KListView::contentsMouseReleaseEvent(e);
1275} 1302}
1276void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) 1303void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e)
1277{ 1304{
1278 KListView::contentsMouseMoveEvent(e); 1305 KListView::contentsMouseMoveEvent(e);
1279} 1306}
1280#endif 1307#endif
1281void KOListViewListView::popupMenu() 1308void KOListViewListView::popupMenu()
1282{ 1309{
1283 mPopupTimer->stop(); 1310 mPopupTimer->stop();
1284 QMouseEvent* e = new QMouseEvent( QEvent::MouseButtonPress, mEventPos ,mEventGlobalPos, RightButton , RightButton ); 1311 QMouseEvent* e = new QMouseEvent( QEvent::MouseButtonPress, mEventPos ,mEventGlobalPos, RightButton , RightButton );
1285 QApplication::postEvent( this->viewport(), e ); 1312 QApplication::postEvent( this->viewport(), e );
1286 1313
1287} 1314}
1288void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) 1315void KOListViewListView::contentsMousePressEvent(QMouseEvent *e)
1289{ 1316{
1290 //qDebug("contentsMousePressEvent++++ %d %d", e->pos().y(), e->globalPos().y()); 1317 //qDebug("contentsMousePressEvent++++ %d %d", e->pos().y(), e->globalPos().y());
1291 mYMousePos = mapToGlobal( (e->pos())).y(); 1318 mYMousePos = mapToGlobal( (e->pos())).y();
1292 if ( e->button() == LeftButton ) { 1319 if ( e->button() == LeftButton ) {
1293 mPopupTimer->start( 600 ); 1320 mPopupTimer->start( 600 );
1294 mEventPos = contentsToViewport(e->pos()); 1321 mEventPos = contentsToViewport(e->pos());
1295 mEventGlobalPos = e->globalPos(); 1322 mEventGlobalPos = e->globalPos();
1296 } 1323 }
1297 KListView::contentsMousePressEvent( e ); 1324 KListView::contentsMousePressEvent( e );
1298 if ( e->button() == RightButton ) { 1325 if ( e->button() == RightButton ) {
1299 QListViewItem* ci = currentItem(); 1326 QListViewItem* ci = currentItem();
1300 //clearSelection(); 1327 //clearSelection();
1301 if ( ci ) 1328 if ( ci )
1302 ci->setSelected( true ); 1329 ci->setSelected( true );
1303 } 1330 }
1304} 1331}
1305void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) 1332void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e)
1306{ 1333{
1307 mPopupTimer->stop(); 1334 mPopupTimer->stop();
1308 KListView::contentsMouseReleaseEvent(e); 1335 KListView::contentsMouseReleaseEvent(e);
1309} 1336}
1310void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) 1337void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e)
1311{ 1338{
1312 // qDebug("contentsMouseMoveEv....... "); 1339 // qDebug("contentsMouseMoveEv....... ");
1313 // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() ); 1340 // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() );
1314 int diff = mYMousePos - mapToGlobal( (e->pos())).y(); 1341 int diff = mYMousePos - mapToGlobal( (e->pos())).y();
1315 if ( diff < 0 ) diff = -diff; 1342 if ( diff < 0 ) diff = -diff;
1316 if ( diff > 15 ) 1343 if ( diff > 15 )
1317 mPopupTimer->stop(); 1344 mPopupTimer->stop();
1318 else { 1345 else {
1319 mEventPos = contentsToViewport(e->pos()); 1346 mEventPos = contentsToViewport(e->pos());
1320 mEventGlobalPos = e->globalPos(); 1347 mEventGlobalPos = e->globalPos();
1321 } 1348 }
1322 KListView::contentsMouseMoveEvent(e); 1349 KListView::contentsMouseMoveEvent(e);
1323} 1350}
1324 1351
1325#define protected public 1352#define protected public
1326#include <qheader.h> 1353#include <qheader.h>
1327#undef protected 1354#undef protected
1328void KOListViewListView::printList() 1355void KOListViewListView::printList()
1329{ 1356{
1330#ifdef DESKTOP_VERSION 1357#ifdef DESKTOP_VERSION
1331 KOPrintPrefs pp ( this ); 1358 KOPrintPrefs pp ( this );
1332 if (!pp.exec() ) 1359 if (!pp.exec() )
1333 return; 1360 return;
1334 int scaleval = pp.printMode() ; 1361 int scaleval = pp.printMode() ;
1335 1362
1336 QPrinter printer; 1363 QPrinter printer;
1337 if (!printer.setup() ) 1364 if (!printer.setup() )
1338 return; 1365 return;
1339 clearSelection (); 1366 clearSelection ();
1340 QPainter p; 1367 QPainter p;
1341 p.begin ( &printer ); 1368 p.begin ( &printer );
1342 QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer ); 1369 QPaintDeviceMetrics m = QPaintDeviceMetrics ( &printer );
1343 float dx, dy; 1370 float dx, dy;
1344 int wid = (m.width() * 9)/10; 1371 int wid = (m.width() * 9)/10;
1345 dx = (float) wid/(float)contentsWidth (); 1372 dx = (float) wid/(float)contentsWidth ();
1346 dy = (float)(m.height()) / (float)contentsHeight (); 1373 dy = (float)(m.height()) / (float)contentsHeight ();
1347 float scale; 1374 float scale;
1348 // scale to fit the width or height of the paper 1375 // scale to fit the width or height of the paper
1349 if ( dx < dy ) 1376 if ( dx < dy )
1350 scale = dx; 1377 scale = dx;
1351 else 1378 else
1352 scale = dy; 1379 scale = dy;
1353 1380
1354 p.translate( m.width()/10,m.width()/10 ); 1381 p.translate( m.width()/10,m.width()/10 );
1355 if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) { 1382 if ( scaleval == 2 || scaleval == 1 && scale < 1.0 ) {
1356 p.scale( scale, scale ); 1383 p.scale( scale, scale );
1357 } 1384 }
1358 1385
1359 int cou = header()->count(); 1386 int cou = header()->count();
1360 int iii; 1387 int iii;
1361 QRect rect ( 0,0,0, header()->height()); 1388 QRect rect ( 0,0,0, header()->height());
1362 for ( iii = 0; iii < cou; ++iii ) { 1389 for ( iii = 0; iii < cou; ++iii ) {
1363 rect.setLeft ( header()->sectionPos( iii ) ); 1390 rect.setLeft ( header()->sectionPos( iii ) );
1364 rect.setRight ( header()->sectionPos( iii ) + header()->sectionSize (iii)); 1391 rect.setRight ( header()->sectionPos( iii ) + header()->sectionSize (iii));
1365 header()->paintSection ( & p, header()->mapToIndex (iii), rect ); 1392 header()->paintSection ( & p, header()->mapToIndex (iii), rect );
1366 } 1393 }
1367 p.translate( 0, header()->height()); 1394 p.translate( 0, header()->height());
1368 drawContentsOffset ( &p, 0,0, 0,0, contentsWidth (), contentsHeight () ); 1395 drawContentsOffset ( &p, 0,0, 0,0, contentsWidth (), contentsHeight () );
1369 p.end(); 1396 p.end();
1370#endif 1397#endif
1371} 1398}
diff --git a/korganizer/searchdialog.cpp b/korganizer/searchdialog.cpp
index 59bf1a2..ef2fc1c 100644
--- a/korganizer/searchdialog.cpp
+++ b/korganizer/searchdialog.cpp
@@ -1,464 +1,471 @@
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 <qlabel.h> 28#include <qlabel.h>
29#include <qlistview.h> 29#include <qlistview.h>
30#include <qwhatsthis.h> 30#include <qwhatsthis.h>
31#include <qlineedit.h> 31#include <qlineedit.h>
32#include <qpushbutton.h> 32#include <qpushbutton.h>
33 33
34#include <klocale.h> 34#include <klocale.h>
35#include <kmessagebox.h> 35#include <kmessagebox.h>
36 36
37#include <libkdepim/kdateedit.h> 37#include <libkdepim/kdateedit.h>
38 38
39#include "koglobals.h" 39#include "koglobals.h"
40#include "koprefs.h" 40#include "koprefs.h"
41#include "klineedit.h" 41#include "klineedit.h"
42 42
43#include "calendarview.h" 43#include "calendarview.h"
44#include "koviewmanager.h" 44#include "koviewmanager.h"
45#include "searchdialog.h" 45#include "searchdialog.h"
46 46
47SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent) 47SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent)
48 : QVBox( 0 ) 48 : QVBox( 0 )
49 49
50{ 50{
51 mCalendar = calendar; 51 mCalendar = calendar;
52 QFrame *topFrame = new QFrame( this ) ;//plainPage(); 52 QFrame *topFrame = new QFrame( this ) ;//plainPage();
53 QVBoxLayout *layout = new QVBoxLayout(topFrame,KDialog::marginHint(),KDialog::spacingHint()); 53 QVBoxLayout *layout = new QVBoxLayout(topFrame,KDialog::marginHint(),KDialog::spacingHint());
54 54
55 // Search expression 55 // Search expression
56 QHBoxLayout *subLayout = new QHBoxLayout(); 56 QHBoxLayout *subLayout = new QHBoxLayout();
57 layout->addLayout(subLayout); 57 layout->addLayout(subLayout);
58 /*
58 searchLabel = new QLabel(topFrame); 59 searchLabel = new QLabel(topFrame);
59 searchLabel->setText(i18n("Search for:")); 60 searchLabel->setText(i18n("Search for:"));
60 subLayout->addWidget(searchLabel); 61 subLayout->addWidget(searchLabel);
61 62 */
62 searchEdit = new KLineEdit(topFrame); 63 QPushButton *OkButton = new QPushButton( i18n("Search for:"), topFrame );
63 subLayout->addWidget(searchEdit);
64 QPushButton *OkButton = new QPushButton( i18n("&Find"), topFrame );
65 //OkButton->setDefault( true ); 64 //OkButton->setDefault( true );
66 connect(OkButton,SIGNAL(clicked()),SLOT(doSearch())); 65 connect(OkButton,SIGNAL(clicked()),SLOT(doSearch()));
67 subLayout->addWidget(OkButton); 66 subLayout->addWidget(OkButton);
67 searchEdit = new KLineEdit(topFrame);
68 subLayout->addWidget(searchEdit);
69
70 mAddItems = new QCheckBox(i18n("Add items"),topFrame);
71 subLayout->addWidget(mAddItems);
72
68 searchEdit->setText("*"); // Find all events by default 73 searchEdit->setText("*"); // Find all events by default
69 searchEdit->setFocus(); 74 searchEdit->setFocus();
70 connect(searchEdit, SIGNAL(textChanged ( const QString & )),this,SLOT(searchTextChanged( const QString & ))); 75 connect(searchEdit, SIGNAL(textChanged ( const QString & )),this,SLOT(searchTextChanged( const QString & )));
71 connect(searchEdit, SIGNAL( returnPressed () ),this,SLOT(doSearch())); 76 connect(searchEdit, SIGNAL( returnPressed () ),this,SLOT(doSearch()));
72 // Subjects to search 77 // Subjects to search
73 // QGroupBox *subjectGroup = new QGroupBox(1,Vertical,i18n("Search In"), 78 // QGroupBox *subjectGroup = new QGroupBox(1,Vertical,i18n("Search In"),
74 // topFrame); 79 // topFrame);
75 80
76 QHBox *incidenceGroup = new QHBox( topFrame ); 81 QHBox *incidenceGroup = new QHBox( topFrame );
77 layout->addWidget(incidenceGroup); 82 layout->addWidget(incidenceGroup);
78 83
79 mSearchEvent = new QCheckBox(i18n("Events"),incidenceGroup); 84 mSearchEvent = new QCheckBox(i18n("Events"),incidenceGroup);
80 //mSearchEvent->setChecked(true); 85 //mSearchEvent->setChecked(true);
81 mSearchTodo = new QCheckBox(i18n("Todos"),incidenceGroup); 86 mSearchTodo = new QCheckBox(i18n("Todos"),incidenceGroup);
82 mSearchJournal = new QCheckBox(i18n("Journals"),incidenceGroup); 87 mSearchJournal = new QCheckBox(i18n("Journals"),incidenceGroup);
83 88
84 QHBox *subjectGroup = new QHBox( topFrame ); 89 QHBox *subjectGroup = new QHBox( topFrame );
85 layout->addWidget(subjectGroup); 90 layout->addWidget(subjectGroup);
86 91
87 mSummaryCheck = new QCheckBox(i18n("Summary/Loc."),subjectGroup); 92 mSummaryCheck = new QCheckBox(i18n("Summary/Loc."),subjectGroup);
88 mSummaryCheck->setChecked(true); 93 mSummaryCheck->setChecked(true);
89 mDescriptionCheck = new QCheckBox(i18n("Details"),subjectGroup); 94 mDescriptionCheck = new QCheckBox(i18n("Details"),subjectGroup);
90 mCategoryCheck = new QCheckBox(i18n("Categories"),subjectGroup); 95 mCategoryCheck = new QCheckBox(i18n("Categories"),subjectGroup);
91 96
92 QHBox *attendeeGroup = new QHBox( topFrame ); 97 QHBox *attendeeGroup = new QHBox( topFrame );
93 layout->addWidget(attendeeGroup ); 98 layout->addWidget(attendeeGroup );
94 new QLabel( i18n("Attendee:"),attendeeGroup ); 99 new QLabel( i18n("Attendee:"),attendeeGroup );
95 mSearchAName = new QCheckBox(i18n("Name"),attendeeGroup ); 100 mSearchAName = new QCheckBox(i18n("Name"),attendeeGroup );
96 mSearchAEmail = new QCheckBox(i18n("Email"), attendeeGroup ); 101 mSearchAEmail = new QCheckBox(i18n("Email"), attendeeGroup );
97 // Date range 102 // Date range
98 // QGroupBox *rangeGroup = new QGroupBox(1,Horizontal,i18n("Date Range"), 103 // QGroupBox *rangeGroup = new QGroupBox(1,Horizontal,i18n("Date Range"),
99 // topFrame); 104 // topFrame);
100 // layout->addWidget(rangeGroup); 105 // layout->addWidget(rangeGroup);
101 106
102 QWidget *rangeWidget = new QWidget(topFrame); 107 QWidget *rangeWidget = new QWidget(topFrame);
103 QHBoxLayout *rangeLayout = new QHBoxLayout(rangeWidget,0,KDialog::spacingHint()); 108 QHBoxLayout *rangeLayout = new QHBoxLayout(rangeWidget,0,KDialog::spacingHint());
104 rangeLayout->addWidget(new QLabel(i18n("From:"),rangeWidget)); 109 rangeLayout->addWidget(new QLabel(i18n("From:"),rangeWidget));
105 mStartDate = new KDateEdit(rangeWidget); 110 mStartDate = new KDateEdit(rangeWidget);
106 rangeLayout->addWidget(mStartDate); 111 rangeLayout->addWidget(mStartDate);
107 rangeLayout->addWidget(new QLabel(i18n("To:"),rangeWidget)); 112 rangeLayout->addWidget(new QLabel(i18n("To:"),rangeWidget));
108 mEndDate = new KDateEdit(rangeWidget); 113 mEndDate = new KDateEdit(rangeWidget);
109 mEndDate->setDate(QDate::currentDate().addDays(365)); 114 mEndDate->setDate(QDate::currentDate().addDays(365));
110 rangeLayout->addWidget(mEndDate); 115 rangeLayout->addWidget(mEndDate);
111 QToolButton *wt = QWhatsThis::whatsThisButton ( rangeWidget ); 116 QToolButton *wt = QWhatsThis::whatsThisButton ( rangeWidget );
112 rangeLayout->addWidget( (QWidget*)wt ); 117 rangeLayout->addWidget( (QWidget*)wt );
113 layout->addWidget(rangeWidget); 118 layout->addWidget(rangeWidget);
114 // Results list view 119 // Results list view
115 listView = new KOListView(mCalendar,topFrame); 120 listView = new KOListView(mCalendar,topFrame);
116 layout->addWidget(listView); 121 layout->addWidget(listView);
117 //layout->setStretchFactor( listView, 333 ); 122 //layout->setStretchFactor( listView, 333 );
118 //listView->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Expanding) ); 123 //listView->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Expanding) );
119 //listView->setMaximumHeight( 50 ); 124 //listView->setMaximumHeight( 50 );
120 listView->readSettings(KOGlobals::config(),"SearchListView Layout"); 125 listView->readSettings(KOGlobals::config(),"SearchListView Layout");
121 connect(searchEdit,SIGNAL(scrollDOWN()),SLOT(setFocusToList())); 126 connect(searchEdit,SIGNAL(scrollDOWN()),SLOT(setFocusToList()));
122 127
123 setCaption( i18n("KO/Pi Find: ")); 128 setCaption( i18n("KO/Pi Find: "));
124#ifdef DESKTOP_VERSION 129#ifdef DESKTOP_VERSION
125 OkButton = new QPushButton( i18n("Close"), this ); 130 OkButton = new QPushButton( i18n("Close"), this );
126 connect(OkButton,SIGNAL(clicked()),SLOT(hide())); 131 connect(OkButton,SIGNAL(clicked()),SLOT(hide()));
127#endif 132#endif
128} 133}
129 134
130SearchDialog::~SearchDialog() 135SearchDialog::~SearchDialog()
131{ 136{
132 137
133} 138}
134void SearchDialog::raiseAndSelect() 139void SearchDialog::raiseAndSelect()
135{ 140{
136 141
137 static int currentState = 0; 142 static int currentState = 0;
138 143
139 if ( !mSearchJournal->isChecked() && !mSearchTodo->isChecked() && !mSearchEvent->isChecked() ) 144 if ( !mSearchJournal->isChecked() && !mSearchTodo->isChecked() && !mSearchEvent->isChecked() )
140 currentState = 0; 145 currentState = 0;
141 int newState = 0; 146 int newState = 0;
142 if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) { 147 if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) {
143 newState = VIEW_J_VIEW; 148 newState = VIEW_J_VIEW;
144 } 149 }
145 else if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) { 150 else if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) {
146 newState = VIEW_T_VIEW; 151 newState = VIEW_T_VIEW;
147 } 152 }
148 else { 153 else {
149 newState = VIEW_A_VIEW; 154 newState = VIEW_A_VIEW;
150 } 155 }
151 if ( newState != currentState ) { 156 if ( newState != currentState ) {
152 if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) { 157 if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) {
153 if ( ! mSearchJournal->isChecked() ) { 158 if ( ! mSearchJournal->isChecked() ) {
154 mSearchJournal->setChecked( true ); 159 mSearchJournal->setChecked( true );
155 mSearchTodo->setChecked( false ); 160 mSearchTodo->setChecked( false );
156 mSearchEvent->setChecked( false ); 161 mSearchEvent->setChecked( false );
157 } 162 }
158 } 163 }
159 else if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) { 164 else if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) {
160 if ( ! mSearchTodo->isChecked() ) { 165 if ( ! mSearchTodo->isChecked() ) {
161 mSearchTodo->setChecked( true ); 166 mSearchTodo->setChecked( true );
162 mSearchJournal->setChecked( false ); 167 mSearchJournal->setChecked( false );
163 mSearchEvent->setChecked( false ); 168 mSearchEvent->setChecked( false );
164 } 169 }
165 } 170 }
166 else { 171 else {
167 if ( ! mSearchEvent->isChecked() ) { 172 if ( ! mSearchEvent->isChecked() ) {
168 mSearchEvent->setChecked( true ); 173 mSearchEvent->setChecked( true );
169 mSearchJournal->setChecked( false ); 174 mSearchJournal->setChecked( false );
170 mSearchTodo->setChecked( false ); 175 mSearchTodo->setChecked( false );
171 } 176 }
172 } 177 }
173 } 178 }
174 currentState = newState; 179 currentState = newState;
175 raise(); 180 raise();
176} 181}
177void SearchDialog::setFocusToList() 182void SearchDialog::setFocusToList()
178{ 183{
179 listView->resetFocus(); 184 listView->resetFocus();
180} 185}
181void SearchDialog::accept() 186void SearchDialog::accept()
182{ 187{
183 doSearch(); 188 doSearch();
184} 189}
185void SearchDialog::updateList() 190void SearchDialog::updateList()
186{ 191{
187 //listView->updateList(); 192 //listView->updateList();
188 if ( isVisible() ) { 193 if ( isVisible() ) {
189 updateView(); 194 updateView();
190 //qDebug("SearchDialog::updated "); 195 //qDebug("SearchDialog::updated ");
191 } 196 }
192 else { 197 else {
193 listView->clear(); 198 listView->clear();
194 //qDebug("SearchDialog::cleared "); 199 //qDebug("SearchDialog::cleared ");
195 200
196 } 201 }
197} 202}
198void SearchDialog::searchTextChanged( const QString &_text ) 203void SearchDialog::searchTextChanged( const QString &_text )
199{ 204{
200#if 0 205#if 0
201 enableButton( KDialogBase::User1, !_text.isEmpty() ); 206 enableButton( KDialogBase::User1, !_text.isEmpty() );
202#endif 207#endif
203} 208}
204 209
205void SearchDialog::doSearch() 210void SearchDialog::doSearch()
206{ 211{
207 QRegExp re; 212 QRegExp re;
208 213
209 re.setWildcard(true); // most people understand these better. 214 re.setWildcard(true); // most people understand these better.
210 re.setCaseSensitive(false); 215 re.setCaseSensitive(false);
211 QString st = searchEdit->text(); 216 QString st = searchEdit->text();
212 if ( st.right(1) != "*") 217 if ( st.right(1) != "*")
213 st += "*"; 218 st += "*";
214 re.setPattern(st); 219 re.setPattern(st);
215 if (!mSearchEvent->isChecked() && !mSearchTodo->isChecked() && !mSearchJournal->isChecked() ) { 220 if (!mSearchEvent->isChecked() && !mSearchTodo->isChecked() && !mSearchJournal->isChecked() ) {
216 KMessageBox::sorry(this, 221 KMessageBox::sorry(this,
217 i18n("Please select at least one\nof the types to search for:\n\nEvents\nTodos\nJournals")); 222 i18n("Please select at least one\nof the types to search for:\n\nEvents\nTodos\nJournals"));
218 return; 223 return;
219 } 224 }
220 if (!re.isValid() ) { 225 if (!re.isValid() ) {
221 KMessageBox::sorry(this, 226 KMessageBox::sorry(this,
222 i18n("Invalid search expression,\ncannot perform " 227 i18n("Invalid search expression,\ncannot perform "
223 "the search.\nPlease enter a search expression\n" 228 "the search.\nPlease enter a search expression\n"
224 "using the wildcard characters\n '*' and '?'" 229 "using the wildcard characters\n '*' and '?'"
225 "where needed.")); 230 "where needed."));
226 return; 231 return;
227 } 232 }
228 search(re); 233 search(re);
229 listView->setStartDate( mStartDate->date() ); 234 listView->setStartDate( mStartDate->date() );
230 listView->showEvents(mMatchedEvents); 235 listView->showEvents(mMatchedEvents);
231 listView->addTodos(mMatchedTodos); 236 listView->addTodos(mMatchedTodos);
232 listView->addJournals(mMatchedJournals); 237 listView->addJournals(mMatchedJournals);
233 if (mMatchedEvents.count() + mMatchedJournals.count() + mMatchedTodos.count() == 0) { 238 if (mMatchedEvents.count() + mMatchedJournals.count() + mMatchedTodos.count() == 0) {
234 setCaption(i18n("No items found. Use '*' and '?' where needed.")); 239 setCaption(i18n("No items found. Use '*' and '?' where needed."));
235 } else { 240 } else {
236 QString mess; 241 QString mess;
237 mess = mess.sprintf( i18n("%d item(s) found."), mMatchedEvents.count()+ mMatchedJournals.count() + mMatchedTodos.count() ); 242 mess = mess.sprintf( i18n("%d item(s) found."), mMatchedEvents.count()+ mMatchedJournals.count() + mMatchedTodos.count() );
238 setCaption( i18n("KO/Pi Find: ") + mess); 243 setCaption( i18n("KO/Pi Find: ") + mess);
239 244
240 } 245 }
241 searchEdit->setFocus(); 246 searchEdit->setFocus();
242} 247}
243void SearchDialog::updateConfig() 248void SearchDialog::updateConfig()
244{ 249{
245 listView->updateConfig(); 250 listView->updateConfig();
246} 251}
247void SearchDialog::updateView() 252void SearchDialog::updateView()
248{ 253{
249 //qDebug("SearchDialog::updateView() %d ", isVisible()); 254 //qDebug("SearchDialog::updateView() %d ", isVisible());
250 QRegExp re; 255 QRegExp re;
251 re.setWildcard(true); // most people understand these better. 256 re.setWildcard(true); // most people understand these better.
252 re.setCaseSensitive(false); 257 re.setCaseSensitive(false);
253 QString st = searchEdit->text(); 258 QString st = searchEdit->text();
254 if ( st.right(1) != "*") 259 if ( st.right(1) != "*")
255 st += "*"; 260 st += "*";
256 re.setPattern(st); 261 re.setPattern(st);
257 if (re.isValid()) { 262 if (re.isValid()) {
258 search(re); 263 search(re);
259 } else { 264 } else {
260 mMatchedEvents.clear(); 265 mMatchedEvents.clear();
261 mMatchedTodos.clear(); 266 mMatchedTodos.clear();
262 mMatchedJournals.clear(); 267 mMatchedJournals.clear();
263 } 268 }
264 listView->setStartDate( mStartDate->date() ); 269 listView->setStartDate( mStartDate->date() );
265 listView->showEvents(mMatchedEvents); 270 listView->showEvents(mMatchedEvents);
266 listView->addTodos(mMatchedTodos); 271 listView->addTodos(mMatchedTodos);
267 listView->addJournals(mMatchedJournals); 272 listView->addJournals(mMatchedJournals);
268} 273}
269 274
270void SearchDialog::search(const QRegExp &re) 275void SearchDialog::search(const QRegExp &re)
271{ 276{
272 QPtrList<Event> events = mCalendar->events( mStartDate->date(), 277 QPtrList<Event> events = mCalendar->events( mStartDate->date(),
273 mEndDate->date(), 278 mEndDate->date(),
274 false /*mInclusiveCheck->isChecked()*/ ); 279 false /*mInclusiveCheck->isChecked()*/ );
275 280 if ( !mAddItems->isChecked() )
276 mMatchedEvents.clear(); 281 mMatchedEvents.clear();
277 if ( mSearchEvent->isChecked() ) { 282 if ( mSearchEvent->isChecked() ) {
278 Event *ev; 283 Event *ev;
279 for(ev=events.first();ev;ev=events.next()) { 284 for(ev=events.first();ev;ev=events.next()) {
280 if (mSummaryCheck->isChecked()) { 285 if (mSummaryCheck->isChecked()) {
281#if QT_VERSION >= 0x030000 286#if QT_VERSION >= 0x030000
282 if (re.search(ev->summary()) != -1) 287 if (re.search(ev->summary()) != -1)
283#else 288#else
284 if (re.match(ev->summary()) != -1) 289 if (re.match(ev->summary()) != -1)
285#endif 290#endif
286 { 291 {
287 mMatchedEvents.append(ev); 292 mMatchedEvents.append(ev);
288 continue; 293 continue;
289 } 294 }
290#if QT_VERSION >= 0x030000 295#if QT_VERSION >= 0x030000
291 if (re.search(ev->location()) != -1) 296 if (re.search(ev->location()) != -1)
292#else 297#else
293 if (re.match(ev->location()) != -1) 298 if (re.match(ev->location()) != -1)
294#endif 299#endif
295 { 300 {
296 mMatchedEvents.append(ev); 301 mMatchedEvents.append(ev);
297 continue; 302 continue;
298 } 303 }
299 } 304 }
300 if (mDescriptionCheck->isChecked()) { 305 if (mDescriptionCheck->isChecked()) {
301#if QT_VERSION >= 0x030000 306#if QT_VERSION >= 0x030000
302 if (re.search(ev->description()) != -1) 307 if (re.search(ev->description()) != -1)
303#else 308#else
304 if (re.match(ev->description()) != -1) 309 if (re.match(ev->description()) != -1)
305#endif 310#endif
306 { 311 {
307 mMatchedEvents.append(ev); 312 mMatchedEvents.append(ev);
308 continue; 313 continue;
309 } 314 }
310 } 315 }
311 if (mCategoryCheck->isChecked()) { 316 if (mCategoryCheck->isChecked()) {
312#if QT_VERSION >= 0x030000 317#if QT_VERSION >= 0x030000
313 if (re.search(ev->categoriesStr()) != -1) 318 if (re.search(ev->categoriesStr()) != -1)
314#else 319#else
315 if (re.match(ev->categoriesStr()) != -1) 320 if (re.match(ev->categoriesStr()) != -1)
316#endif 321#endif
317 { 322 {
318 mMatchedEvents.append(ev); 323 mMatchedEvents.append(ev);
319 continue; 324 continue;
320 } 325 }
321 } 326 }
322 if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) { 327 if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) {
323 QPtrList<Attendee> tmpAList = ev->attendees(); 328 QPtrList<Attendee> tmpAList = ev->attendees();
324 Attendee *a; 329 Attendee *a;
325 for (a = tmpAList.first(); a; a = tmpAList.next()) { 330 for (a = tmpAList.first(); a; a = tmpAList.next()) {
326 if (mSearchAName->isChecked()) { 331 if (mSearchAName->isChecked()) {
327#if QT_VERSION >= 0x030000 332#if QT_VERSION >= 0x030000
328 if (re.search(a->name()) != -1) 333 if (re.search(a->name()) != -1)
329#else 334#else
330 if (re.match(a->name()) != -1) 335 if (re.match(a->name()) != -1)
331#endif 336#endif
332 { 337 {
333 mMatchedEvents.append(ev); 338 mMatchedEvents.append(ev);
334 break; 339 break;
335 } 340 }
336 } 341 }
337 if (mSearchAEmail->isChecked()) { 342 if (mSearchAEmail->isChecked()) {
338#if QT_VERSION >= 0x030000 343#if QT_VERSION >= 0x030000
339 if (re.search(a->email()) != -1) 344 if (re.search(a->email()) != -1)
340#else 345#else
341 if (re.match(a->email()) != -1) 346 if (re.match(a->email()) != -1)
342#endif 347#endif
343 { 348 {
344 mMatchedEvents.append(ev); 349 mMatchedEvents.append(ev);
345 break; 350 break;
346 } 351 }
347 } 352 }
348 } 353 }
349 } 354 }
350 } 355 }
351 } 356 }
352 QPtrList<Todo> todos = mCalendar->todos( ); 357 QPtrList<Todo> todos = mCalendar->todos( );
353 mMatchedTodos.clear(); 358 if ( !mAddItems->isChecked() )
359 mMatchedTodos.clear();
354 if ( mSearchTodo->isChecked() ) { 360 if ( mSearchTodo->isChecked() ) {
355 Todo *tod; 361 Todo *tod;
356 for(tod=todos.first();tod;tod=todos.next()) { 362 for(tod=todos.first();tod;tod=todos.next()) {
357 if (mSummaryCheck->isChecked()) { 363 if (mSummaryCheck->isChecked()) {
358#if QT_VERSION >= 0x030000 364#if QT_VERSION >= 0x030000
359 if (re.search(tod->summary()) != -1) 365 if (re.search(tod->summary()) != -1)
360#else 366#else
361 if (re.match(tod->summary()) != -1) 367 if (re.match(tod->summary()) != -1)
362#endif 368#endif
363 { 369 {
364 mMatchedTodos.append(tod); 370 mMatchedTodos.append(tod);
365 continue; 371 continue;
366 } 372 }
367 } 373 }
368 if (mDescriptionCheck->isChecked()) { 374 if (mDescriptionCheck->isChecked()) {
369#if QT_VERSION >= 0x030000 375#if QT_VERSION >= 0x030000
370 if (re.search(tod->description()) != -1) 376 if (re.search(tod->description()) != -1)
371#else 377#else
372 if (re.match(tod->description()) != -1) 378 if (re.match(tod->description()) != -1)
373#endif 379#endif
374 { 380 {
375 mMatchedTodos.append(tod); 381 mMatchedTodos.append(tod);
376 continue; 382 continue;
377 } 383 }
378 } 384 }
379 if (mCategoryCheck->isChecked()) { 385 if (mCategoryCheck->isChecked()) {
380#if QT_VERSION >= 0x030000 386#if QT_VERSION >= 0x030000
381 if (re.search(tod->categoriesStr()) != -1) 387 if (re.search(tod->categoriesStr()) != -1)
382#else 388#else
383 if (re.match(tod->categoriesStr()) != -1) 389 if (re.match(tod->categoriesStr()) != -1)
384#endif 390#endif
385 { 391 {
386 mMatchedTodos.append(tod); 392 mMatchedTodos.append(tod);
387 continue; 393 continue;
388 } 394 }
389 } 395 }
390 if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) { 396 if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) {
391 QPtrList<Attendee> tmpAList = tod->attendees(); 397 QPtrList<Attendee> tmpAList = tod->attendees();
392 Attendee *a; 398 Attendee *a;
393 for (a = tmpAList.first(); a; a = tmpAList.next()) { 399 for (a = tmpAList.first(); a; a = tmpAList.next()) {
394 if (mSearchAName->isChecked()) { 400 if (mSearchAName->isChecked()) {
395#if QT_VERSION >= 0x030000 401#if QT_VERSION >= 0x030000
396 if (re.search(a->name()) != -1) 402 if (re.search(a->name()) != -1)
397#else 403#else
398 if (re.match(a->name()) != -1) 404 if (re.match(a->name()) != -1)
399#endif 405#endif
400 { 406 {
401 mMatchedTodos.append(tod); 407 mMatchedTodos.append(tod);
402 break; 408 break;
403 } 409 }
404 } 410 }
405 if (mSearchAEmail->isChecked()) { 411 if (mSearchAEmail->isChecked()) {
406#if QT_VERSION >= 0x030000 412#if QT_VERSION >= 0x030000
407 if (re.search(a->email()) != -1) 413 if (re.search(a->email()) != -1)
408#else 414#else
409 if (re.match(a->email()) != -1) 415 if (re.match(a->email()) != -1)
410#endif 416#endif
411 { 417 {
412 mMatchedTodos.append(tod); 418 mMatchedTodos.append(tod);
413 break; 419 break;
414 } 420 }
415 } 421 }
416 } 422 }
417 } 423 }
418 } 424 }
419 } 425 }
420 mMatchedJournals.clear(); 426 if ( !mAddItems->isChecked() )
427 mMatchedJournals.clear();
421 if (mSearchJournal->isChecked() ) { 428 if (mSearchJournal->isChecked() ) {
422 QPtrList<Journal> journals = mCalendar->journals( ); 429 QPtrList<Journal> journals = mCalendar->journals( );
423 Journal* journ; 430 Journal* journ;
424 431
425 for(journ=journals.first();journ;journ=journals.next()) { 432 for(journ=journals.first();journ;journ=journals.next()) {
426 if ( journ->dtStart().date() <= mEndDate->date() 433 if ( journ->dtStart().date() <= mEndDate->date()
427 &&journ->dtStart().date() >= mStartDate->date()) { 434 &&journ->dtStart().date() >= mStartDate->date()) {
428#if QT_VERSION >= 0x030000 435#if QT_VERSION >= 0x030000
429 if (re.search(journ->description()) != -1) 436 if (re.search(journ->description()) != -1)
430#else 437#else
431 if (re.match(journ->description()) != -1) 438 if (re.match(journ->description()) != -1)
432#endif 439#endif
433 { 440 {
434 mMatchedJournals.append(journ); 441 mMatchedJournals.append(journ);
435 continue; 442 continue;
436 } 443 }
437 } 444 }
438 } 445 }
439 } 446 }
440 447
441} 448}
442 449
443void SearchDialog::keyPressEvent ( QKeyEvent *e) 450void SearchDialog::keyPressEvent ( QKeyEvent *e)
444{ 451{
445 switch ( e->key() ) { 452 switch ( e->key() ) {
446 case Qt::Key_Escape: 453 case Qt::Key_Escape:
447 close(); 454 close();
448 break; 455 break;
449 case Qt::Key_F: 456 case Qt::Key_F:
450 if ( e->state() == Qt::ControlButton ) { 457 if ( e->state() == Qt::ControlButton ) {
451 458
452 } 459 }
453 break; 460 break;
454 case Qt::Key_Return: 461 case Qt::Key_Return:
455 case Qt::Key_Enter: 462 case Qt::Key_Enter:
456 doSearch(); 463 doSearch();
457 break; 464 break;
458 465
459 default: 466 default:
460 e->ignore(); 467 e->ignore();
461 } 468 }
462} 469}
463 470
464//mMatchedJournals; 471//mMatchedJournals;
diff --git a/korganizer/searchdialog.h b/korganizer/searchdialog.h
index 4559d20..11ad2f0 100644
--- a/korganizer/searchdialog.h
+++ b/korganizer/searchdialog.h
@@ -1,95 +1,96 @@
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#ifndef SEARCHDIALOG_H 24#ifndef SEARCHDIALOG_H
25#define SEARCHDIALOG_H 25#define SEARCHDIALOG_H
26 26
27#include <qregexp.h> 27#include <qregexp.h>
28 28
29#include <kdialogbase.h> 29#include <kdialogbase.h>
30#include <qvbox.h> 30#include <qvbox.h>
31 31
32#include <libkcal/calendar.h> 32#include <libkcal/calendar.h>
33 33
34#include "kolistview.h" 34#include "kolistview.h"
35 35
36class KDateEdit; 36class KDateEdit;
37class QCheckBox; 37class QCheckBox;
38class QLineEdit; 38class QLineEdit;
39class KLineEdit; 39class KLineEdit;
40class QLabel; 40class QLabel;
41class CalendarView; 41class CalendarView;
42 42
43using namespace KCal; 43using namespace KCal;
44class SearchDialog : public QVBox 44class SearchDialog : public QVBox
45{ 45{
46 Q_OBJECT 46 Q_OBJECT
47 public: 47 public:
48 SearchDialog(Calendar *calendar,CalendarView *parent=0); 48 SearchDialog(Calendar *calendar,CalendarView *parent=0);
49 virtual ~SearchDialog(); 49 virtual ~SearchDialog();
50 KOListView *listview(){ return listView;} 50 KOListView *listview(){ return listView;}
51 void updateView(); 51 void updateView();
52 void raiseAndSelect(); 52 void raiseAndSelect();
53 53
54 public slots: 54 public slots:
55 void changeEventDisplay(Event *, int) { updateView(); } 55 void changeEventDisplay(Event *, int) { updateView(); }
56 void updateConfig(); 56 void updateConfig();
57 void updateList(); 57 void updateList();
58 protected slots: 58 protected slots:
59 void setFocusToList(); 59 void setFocusToList();
60 void accept(); 60 void accept();
61 void doSearch(); 61 void doSearch();
62 void searchTextChanged( const QString &_text ); 62 void searchTextChanged( const QString &_text );
63 63
64 signals: 64 signals:
65 void showEventSignal(Event *); 65 void showEventSignal(Event *);
66 void editEventSignal(Event *); 66 void editEventSignal(Event *);
67 void deleteEventSignal(Event *); 67 void deleteEventSignal(Event *);
68 68
69 private: 69 private:
70 void search(const QRegExp &); 70 void search(const QRegExp &);
71 71
72 Calendar *mCalendar; 72 Calendar *mCalendar;
73 73
74 QPtrList<Event> mMatchedEvents; 74 QPtrList<Event> mMatchedEvents;
75 QPtrList<Todo> mMatchedTodos; 75 QPtrList<Todo> mMatchedTodos;
76 QPtrList<Journal> mMatchedJournals; 76 QPtrList<Journal> mMatchedJournals;
77 77
78 QLabel *searchLabel; 78 QLabel *searchLabel;
79 KLineEdit *searchEdit; 79 KLineEdit *searchEdit;
80 KOListView *listView; 80 KOListView *listView;
81 81
82 KDateEdit *mStartDate; 82 KDateEdit *mStartDate;
83 KDateEdit *mEndDate; 83 KDateEdit *mEndDate;
84 QCheckBox *mSummaryCheck; 84 QCheckBox *mSummaryCheck;
85 QCheckBox *mDescriptionCheck; 85 QCheckBox *mDescriptionCheck;
86 QCheckBox *mCategoryCheck; 86 QCheckBox *mCategoryCheck;
87 QCheckBox *mSearchEvent; 87 QCheckBox *mSearchEvent;
88 QCheckBox *mSearchTodo; 88 QCheckBox *mSearchTodo;
89 QCheckBox *mSearchJournal; 89 QCheckBox *mSearchJournal;
90 QCheckBox *mSearchAName; 90 QCheckBox *mSearchAName;
91 QCheckBox *mSearchAEmail; 91 QCheckBox *mSearchAEmail;
92 QCheckBox *mAddItems;
92 void keyPressEvent ( QKeyEvent *e) ; 93 void keyPressEvent ( QKeyEvent *e) ;
93}; 94};
94 95
95#endif 96#endif