summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kolistview.cpp13
-rw-r--r--korganizer/searchdialog.cpp3
-rw-r--r--libkcal/alarm.cpp2
-rw-r--r--libkcal/kincidenceformatter.cpp2
4 files changed, 10 insertions, 10 deletions
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp
index e1b393d..a1bf9ff 100644
--- a/korganizer/kolistview.cpp
+++ b/korganizer/kolistview.cpp
@@ -1,359 +1,361 @@
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 37
38#include <klocale.h> 38#include <klocale.h>
39#include <kdebug.h> 39#include <kdebug.h>
40#include <kiconloader.h> 40#include <kiconloader.h>
41#include <kglobal.h> 41#include <kglobal.h>
42 42
43#include <libkdepim/kpimglobalprefs.h> 43#include <libkdepim/kpimglobalprefs.h>
44#include <libkcal/calendar.h> 44#include <libkcal/calendar.h>
45#include <libkcal/calendarlocal.h> 45#include <libkcal/calendarlocal.h>
46#include <libkcal/icalformat.h> 46#include <libkcal/icalformat.h>
47#include <libkcal/vcalformat.h> 47#include <libkcal/vcalformat.h>
48#include <libkcal/recurrence.h> 48#include <libkcal/recurrence.h>
49#include <libkcal/filestorage.h> 49#include <libkcal/filestorage.h>
50#include <libkdepim/categoryselectdialog.h> 50#include <libkdepim/categoryselectdialog.h>
51#include <libkcal/kincidenceformatter.h> 51#include <libkcal/kincidenceformatter.h>
52#ifndef DESKTOP_VERSION 52#ifndef DESKTOP_VERSION
53#include <qpe/qpeapplication.h> 53#include <qpe/qpeapplication.h>
54#else 54#else
55#include <qapplication.h> 55#include <qapplication.h>
56#endif 56#endif
57 57
58#ifndef KORG_NOPRINTER 58#ifndef KORG_NOPRINTER
59#include "calprinter.h" 59#include "calprinter.h"
60#endif 60#endif
61#include "koglobals.h" 61#include "koglobals.h"
62#include "koprefs.h" 62#include "koprefs.h"
63#include "kfiledialog.h" 63#include "kfiledialog.h"
64 64
65#include "kolistview.h" 65#include "kolistview.h"
66 66
67 67
68 68
69 69
70class KOListViewWhatsThis :public QWhatsThis 70class KOListViewWhatsThis :public QWhatsThis
71{ 71{
72public: 72public:
73 KOListViewWhatsThis( QWidget *wid, KOListView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; 73 KOListViewWhatsThis( QWidget *wid, KOListView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { };
74 74
75protected: 75protected:
76 virtual QString text( const QPoint& p) 76 virtual QString text( const QPoint& p)
77 { 77 {
78 return _view->getWhatsThisText(p) ; 78 return _view->getWhatsThisText(p) ;
79 } 79 }
80private: 80private:
81 QWidget* _wid; 81 QWidget* _wid;
82 KOListView * _view; 82 KOListView * _view;
83}; 83};
84 84
85 85
86ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date ) 86ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date )
87{ 87{
88 mItem = item; 88 mItem = item;
89 mDate = date; 89 mDate = date;
90} 90}
91 91
92ListItemVisitor::~ListItemVisitor() 92ListItemVisitor::~ListItemVisitor()
93{ 93{
94} 94}
95 95
96bool ListItemVisitor::visit(Event *e) 96bool ListItemVisitor::visit(Event *e)
97{ 97{
98
99 bool ok = false; 98 bool ok = false;
100 QString start, end; 99 QString start, end;
101 QDate ds, de; 100 QDate ds, de;
102 if ( e->doesRecur() ) { 101 if ( e->doesRecur() ) {
103 ds = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date(); 102 ds = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date();
104 if ( ok ) { 103 if ( ok ) {
105 int days = e->dtStart().date().daysTo(e->dtEnd().date() ); 104 int days = e->dtStart().date().daysTo(e->dtEnd().date() );
106 start = KGlobal::locale()->formatDate(ds,true); 105 start = KGlobal::locale()->formatDate(ds,true);
107 de = ds.addDays( days); 106 de = ds.addDays( days);
108 end = KGlobal::locale()->formatDate(de,true); 107 end = KGlobal::locale()->formatDate(de,true);
109 } 108 }
110 109
111 } 110 }
112 if ( ! ok ) { 111 if ( ! ok ) {
113 start =e->dtStartDateStr(); 112 start =e->dtStartDateStr();
114 end = e->dtEndDateStr(); 113 end = e->dtEndDateStr();
115 ds = e->dtStart().date(); 114 ds = e->dtStart().date();
116 de = e->dtEnd().date(); 115 de = e->dtEnd().date();
117 } 116 }
118 mItem->setText(0,e->summary()); 117 mItem->setText(0,e->summary());
119 mItem->setText(1,start); 118 mItem->setText(1,start);
120 mItem->setText(2,e->dtStartTimeStr()); 119 mItem->setText(2,e->dtStartTimeStr());
121 mItem->setText(3,end); 120 mItem->setText(3,end);
122 mItem->setText(4,e->dtEndTimeStr()); 121 mItem->setText(4,e->dtEndTimeStr());
123 if ( e->isAlarmEnabled() ) { 122 if ( e->isAlarmEnabled() ) {
124 mItem->setText(5,e->alarms().first()->offsetText() ); 123 mItem->setText(5,e->alarms().first()->offsetText() );
125 } else { 124 } else {
126 mItem->setText(5, i18n("No")); 125 mItem->setText(5, i18n("No"));
127 } 126 }
128 mItem->setText(6, e->recurrence()->recurrenceText()); 127 mItem->setText(6, e->recurrence()->recurrenceText());
128 if( ! e->doesRecur() )
129 mItem->setSortKey( 6, "-" );
129 mItem->setText(7,"---"); 130 mItem->setText(7,"---");
130 mItem->setText(8,"---"); 131 mItem->setText(8,"---");
131 mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No")); 132 mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No"));
132 mItem->setText(10,e->categoriesStr()); 133 mItem->setText(10,e->categoriesStr());
133 134
134 QString key; 135 QString key;
135 QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time(); 136 QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time();
136 key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute()); 137 key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute());
137 mItem->setSortKey(1,key); 138 mItem->setSortKey(1,key);
138 139
139 t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time(); 140 t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time();
140 key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute()); 141 key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute());
141 mItem->setSortKey(3,key); 142 mItem->setSortKey(3,key);
142
143 return true; 143 return true;
144} 144}
145 145
146bool ListItemVisitor::visit(Todo *t) 146bool ListItemVisitor::visit(Todo *t)
147{ 147{
148 mItem->setText(0,i18n("Todo: %1").arg(t->summary())); 148 mItem->setText(0,i18n("Todo: %1").arg(t->summary()));
149 if (t->hasStartDate()) { 149 if (t->hasStartDate()) {
150 mItem->setText(1,t->dtStartDateStr()); 150 mItem->setText(1,t->dtStartDateStr());
151 if (t->doesFloat()) { 151 if (t->doesFloat()) {
152 mItem->setText(2,"---"); 152 mItem->setText(2,"---");
153 } else { 153 } else {
154 mItem->setText(2,t->dtStartTimeStr()); 154 mItem->setText(2,t->dtStartTimeStr());
155 } 155 }
156 } else { 156 } else {
157 mItem->setText(1,"---"); 157 mItem->setText(1,"---");
158 mItem->setText(2,"---"); 158 mItem->setText(2,"---");
159 } 159 }
160 mItem->setText(3,"---"); 160 mItem->setText(3,"---");
161 mItem->setText(4,"---"); 161 mItem->setText(4,"---");
162 if ( t->isAlarmEnabled() ) { 162 if ( t->isAlarmEnabled() ) {
163 mItem->setText(5,t->alarms().first()->offsetText() ); 163 mItem->setText(5,t->alarms().first()->offsetText() );
164 } else { 164 } else {
165 mItem->setText(5, i18n("No")); 165 mItem->setText(5, i18n("No"));
166 } 166 }
167 mItem->setText(6, t->recurrence()->recurrenceText()); 167 mItem->setText(6, t->recurrence()->recurrenceText());
168 if( ! t->doesRecur() )
169 mItem->setSortKey( 6, "-" );
168 if (t->hasDueDate()) { 170 if (t->hasDueDate()) {
169 mItem->setText(7,t->dtDueDateStr()); 171 mItem->setText(7,t->dtDueDateStr());
170 if (t->doesFloat()) { 172 if (t->doesFloat()) {
171 mItem->setText(8,"---"); 173 mItem->setText(8,"---");
172 } else { 174 } else {
173 mItem->setText(8,t->dtDueTimeStr()); 175 mItem->setText(8,t->dtDueTimeStr());
174 } 176 }
175 } else { 177 } else {
176 mItem->setText(7,"---"); 178 mItem->setText(7,"---");
177 mItem->setText(8,"---"); 179 mItem->setText(8,"---");
178 } 180 }
179 mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No")); 181 mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No"));
180 mItem->setText(10,t->categoriesStr()); 182 mItem->setText(10,t->categoriesStr());
181 183
182 QString key; 184 QString key;
183 QDate d; 185 QDate d;
184 if (t->hasDueDate()) { 186 if (t->hasDueDate()) {
185 d = t->dtDue().date(); 187 d = t->dtDue().date();
186 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time(); 188 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time();
187 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); 189 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute());
188 mItem->setSortKey(7,key); 190 mItem->setSortKey(7,key);
189 } 191 }
190 if ( t->hasStartDate() ) { 192 if ( t->hasStartDate() ) {
191 d = t->dtStart().date(); 193 d = t->dtStart().date();
192 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time(); 194 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time();
193 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); 195 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute());
194 mItem->setSortKey(1,key); 196 mItem->setSortKey(1,key);
195 } 197 }
196 return true; 198 return true;
197} 199}
198 200
199bool ListItemVisitor::visit(Journal * j) 201bool ListItemVisitor::visit(Journal * j)
200{ 202{
201 QString des = j->description().left(30); 203 QString des = j->description().left(30);
202 des = des.simplifyWhiteSpace (); 204 des = des.simplifyWhiteSpace ();
203 des.replace (QRegExp ("\\n"),"" ); 205 des.replace (QRegExp ("\\n"),"" );
204 des.replace (QRegExp ("\\r"),"" ); 206 des.replace (QRegExp ("\\r"),"" );
205 mItem->setText(0,i18n("Journal: ")+des.left(25)); 207 mItem->setText(0,i18n("Journal: ")+des.left(25));
206 mItem->setText(1,j->dtStartDateStr()); 208 mItem->setText(1,j->dtStartDateStr());
207 mItem->setText(2,"---"); 209 mItem->setText(2,"---");
208 mItem->setText(3,"---"); 210 mItem->setText(3,"---");
209 mItem->setText(4,"---"); 211 mItem->setText(4,"---");
210 mItem->setText(5,"---"); 212 mItem->setText(5,"---");
211 mItem->setText(6,"---"); 213 mItem->setText(6,"---");
212 mItem->setText(7,j->dtStartDateStr()); 214 mItem->setText(7,j->dtStartDateStr());
213 mItem->setText(8,"---"); 215 mItem->setText(8,"---");
214 mItem->setText(9,"---"); 216 mItem->setText(9,"---");
215 mItem->setText(10,i18n("Last Modified: ")+ KGlobal::locale()->formatDateTime( j->lastModified() , true) ); 217 mItem->setText(10,i18n("Last Modified: ")+ KGlobal::locale()->formatDateTime( j->lastModified() , true) );
216 218
217 QString key; 219 QString key;
218 QDate d = j->dtStart().date(); 220 QDate d = j->dtStart().date();
219 key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 221 key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
220 mItem->setSortKey(1,key); 222 mItem->setSortKey(1,key);
221 mItem->setSortKey(7,key); 223 mItem->setSortKey(7,key);
222 224
223 return true; 225 return true;
224} 226}
225 227
226KOListView::KOListView(Calendar *calendar, QWidget *parent, 228KOListView::KOListView(Calendar *calendar, QWidget *parent,
227 const char *name) 229 const char *name)
228 : KOEventView(calendar, parent, name) 230 : KOEventView(calendar, parent, name)
229{ 231{
230 mActiveItem = 0; 232 mActiveItem = 0;
231 mListView = new KOListViewListView(this); 233 mListView = new KOListViewListView(this);
232 mListView->addColumn(i18n("Summary")); 234 mListView->addColumn(i18n("Summary"));
233 mListView->addColumn(i18n("Start Date")); 235 mListView->addColumn(i18n("Start Date"));
234 mListView->addColumn(i18n("Start Time")); 236 mListView->addColumn(i18n("Start Time"));
235 mListView->addColumn(i18n("End Date")); 237 mListView->addColumn(i18n("End Date"));
236 mListView->addColumn(i18n("End Time")); 238 mListView->addColumn(i18n("End Time"));
237 mListView->addColumn(i18n("Alarm")); // alarm set? 239 mListView->addColumn(i18n("Alarm")); // alarm set?
238 mListView->addColumn(i18n("Recurs")); // recurs? 240 mListView->addColumn(i18n("Recurs")); // recurs?
239 mListView->addColumn(i18n("Due Date")); 241 mListView->addColumn(i18n("Due Date"));
240 mListView->addColumn(i18n("Due Time")); 242 mListView->addColumn(i18n("Due Time"));
241 mListView->addColumn(i18n("Cancelled")); 243 mListView->addColumn(i18n("Cancelled"));
242 mListView->addColumn(i18n("Categories")); 244 mListView->addColumn(i18n("Categories"));
243 245
244 mListView->setColumnAlignment(0,AlignLeft); 246 mListView->setColumnAlignment(0,AlignLeft);
245 mListView->setColumnAlignment(1,AlignLeft); 247 mListView->setColumnAlignment(1,AlignLeft);
246 mListView->setColumnAlignment(2,AlignHCenter); 248 mListView->setColumnAlignment(2,AlignHCenter);
247 mListView->setColumnAlignment(3,AlignLeft); 249 mListView->setColumnAlignment(3,AlignLeft);
248 mListView->setColumnAlignment(4,AlignHCenter); 250 mListView->setColumnAlignment(4,AlignHCenter);
249 mListView->setColumnAlignment(5,AlignLeft); 251 mListView->setColumnAlignment(5,AlignLeft);
250 mListView->setColumnAlignment(6,AlignLeft); 252 mListView->setColumnAlignment(6,AlignLeft);
251 mListView->setColumnAlignment(7,AlignLeft); 253 mListView->setColumnAlignment(7,AlignLeft);
252 mListView->setColumnAlignment(8,AlignLeft); 254 mListView->setColumnAlignment(8,AlignLeft);
253 mListView->setColumnAlignment(9,AlignLeft); 255 mListView->setColumnAlignment(9,AlignLeft);
254 mListView->setColumnAlignment(10,AlignLeft); 256 mListView->setColumnAlignment(10,AlignLeft);
255 mListView->setColumnWidthMode(10, QListView::Manual); 257 mListView->setColumnWidthMode(10, QListView::Manual);
256 new KOListViewWhatsThis(mListView->viewport(),this); 258 new KOListViewWhatsThis(mListView->viewport(),this);
257 259
258 int iii = 0; 260 int iii = 0;
259 for ( iii = 0; iii< 10 ; ++iii ) 261 for ( iii = 0; iii< 10 ; ++iii )
260 mListView->setColumnWidthMode( iii, QListView::Manual ); 262 mListView->setColumnWidthMode( iii, QListView::Manual );
261 263
262 QBoxLayout *layoutTop = new QVBoxLayout(this); 264 QBoxLayout *layoutTop = new QVBoxLayout(this);
263 layoutTop->addWidget(mListView); 265 layoutTop->addWidget(mListView);
264 mListView->setFont ( KOPrefs::instance()->mListViewFont ); 266 mListView->setFont ( KOPrefs::instance()->mListViewFont );
265 mPopupMenu = eventPopup(); 267 mPopupMenu = eventPopup();
266 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 268 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
267 i18n("Select all"),this, 269 i18n("Select all"),this,
268 SLOT(allSelection()),true); 270 SLOT(allSelection()),true);
269 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 271 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
270 i18n("Deselect all"),this, 272 i18n("Deselect all"),this,
271 SLOT(clearSelection()),true); 273 SLOT(clearSelection()),true);
272 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 274 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
273 i18n("Delete all selected"),this, 275 i18n("Delete all selected"),this,
274 SLOT(deleteAll()),true); 276 SLOT(deleteAll()),true);
275 mPopupMenu->insertSeparator(); 277 mPopupMenu->insertSeparator();
276 QPopupMenu * exportPO = new QPopupMenu ( this ); 278 QPopupMenu * exportPO = new QPopupMenu ( this );
277 mPopupMenu->insertItem( i18n("Export selected"), exportPO ); 279 mPopupMenu->insertItem( i18n("Export selected"), exportPO );
278 exportPO->insertItem( i18n("As iCal (ics) file..."),this, 280 exportPO->insertItem( i18n("As iCal (ics) file..."),this,
279 SLOT(saveToFile())); 281 SLOT(saveToFile()));
280 exportPO->insertItem( i18n("As vCal (vcs) file..."),this, 282 exportPO->insertItem( i18n("As vCal (vcs) file..."),this,
281 SLOT(saveToFileVCS())); 283 SLOT(saveToFileVCS()));
282 exportPO->insertItem( i18n("Journal/Details..."),this, 284 exportPO->insertItem( i18n("Journal/Details..."),this,
283 SLOT(saveDescriptionToFile())); 285 SLOT(saveDescriptionToFile()));
284 // mPopupMenu->insertSeparator(); 286 // mPopupMenu->insertSeparator();
285 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 287 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
286 i18n("Add Categ. to selected..."),this, 288 i18n("Add Categ. to selected..."),this,
287 SLOT(addCat()),true); 289 SLOT(addCat()),true);
288 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 290 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
289 i18n("Set Categ. for selected..."),this, 291 i18n("Set Categ. for selected..."),this,
290 SLOT(setCat()),true); 292 SLOT(setCat()),true);
291 //mPopupMenu->insertSeparator(); 293 //mPopupMenu->insertSeparator();
292 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 294 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
293 i18n("Set alarm for selected..."),this, 295 i18n("Set alarm for selected..."),this,
294 SLOT(setAlarm()),true); 296 SLOT(setAlarm()),true);
295 297
296 298
297#ifndef DESKTOP_VERSION 299#ifndef DESKTOP_VERSION
298 mPopupMenu->insertSeparator(); 300 mPopupMenu->insertSeparator();
299 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 301 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
300 i18n("Beam selected via IR"),this, 302 i18n("Beam selected via IR"),this,
301 SLOT(beamSelected()),true); 303 SLOT(beamSelected()),true);
302#endif 304#endif
303 /* 305 /*
304 mPopupMenu = new QPopupMenu; 306 mPopupMenu = new QPopupMenu;
305 mPopupMenu->insertItem(i18n("Edit Event"), this, 307 mPopupMenu->insertItem(i18n("Edit Event"), this,
306 SLOT (editEvent())); 308 SLOT (editEvent()));
307 mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, 309 mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this,
308 SLOT (deleteEvent())); 310 SLOT (deleteEvent()));
309 mPopupMenu->insertSeparator(); 311 mPopupMenu->insertSeparator();
310 mPopupMenu->insertItem(i18n("Show Dates"), this, 312 mPopupMenu->insertItem(i18n("Show Dates"), this,
311 SLOT(showDates())); 313 SLOT(showDates()));
312 mPopupMenu->insertItem(i18n("Hide Dates"), this, 314 mPopupMenu->insertItem(i18n("Hide Dates"), this,
313 SLOT(hideDates())); 315 SLOT(hideDates()));
314 */ 316 */
315 QObject::connect(mListView,SIGNAL( newEvent()), 317 QObject::connect(mListView,SIGNAL( newEvent()),
316 this,SIGNAL(signalNewEvent())); 318 this,SIGNAL(signalNewEvent()));
317 QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), 319 QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)),
318 this,SLOT(defaultItemAction(QListViewItem *))); 320 this,SLOT(defaultItemAction(QListViewItem *)));
319 QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *, 321 QObject::connect(mListView,SIGNAL(rightButtonPressed( QListViewItem *,
320 const QPoint &, int )), 322 const QPoint &, int )),
321 this,SLOT(popupMenu(QListViewItem *,const QPoint &,int))); 323 this,SLOT(popupMenu(QListViewItem *,const QPoint &,int)));
322 QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)), 324 QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)),
323 SLOT(processSelectionChange(QListViewItem *))); 325 SLOT(processSelectionChange(QListViewItem *)));
324 QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)), 326 QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)),
325 SIGNAL(showIncidenceSignal(Incidence *)) ); 327 SIGNAL(showIncidenceSignal(Incidence *)) );
326 328
327 readSettings(KOGlobals::config(),"KOListView Layout"); 329 readSettings(KOGlobals::config(),"KOListView Layout");
328} 330}
329 331
330KOListView::~KOListView() 332KOListView::~KOListView()
331{ 333{
332 delete mPopupMenu; 334 delete mPopupMenu;
333} 335}
334 336
335QString KOListView::getWhatsThisText(QPoint p) 337QString KOListView::getWhatsThisText(QPoint p)
336{ 338{
337 KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p ); 339 KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p );
338 if ( item ) 340 if ( item )
339 return KIncidenceFormatter::instance()->getFormattedText( item->data(), 341 return KIncidenceFormatter::instance()->getFormattedText( item->data(),
340 KOPrefs::instance()->mWTshowDetails, 342 KOPrefs::instance()->mWTshowDetails,
341 KOPrefs::instance()->mWTshowCreated, 343 KOPrefs::instance()->mWTshowCreated,
342 KOPrefs::instance()->mWTshowChanged); 344 KOPrefs::instance()->mWTshowChanged);
343 return i18n("That is the list view" ); 345 return i18n("That is the list view" );
344 346
345} 347}
346 348
347void KOListView::updateList() 349void KOListView::updateList()
348{ 350{
349 // qDebug(" KOListView::updateList() "); 351 // qDebug(" KOListView::updateList() ");
350 352
351} 353}
352 354
353void KOListView::addCat( ) 355void KOListView::addCat( )
354{ 356{
355 setCategories( false ); 357 setCategories( false );
356} 358}
357void KOListView::setCat() 359void KOListView::setCat()
358{ 360{
359 setCategories( true ); 361 setCategories( true );
@@ -691,426 +693,427 @@ void KOListView::writeToFile( bool iCal )
691 } 693 }
692 if ( iCal ) { 694 if ( iCal ) {
693 ICalFormat format; 695 ICalFormat format;
694 format.save( &cal, fn ); 696 format.save( &cal, fn );
695 } else { 697 } else {
696 698
697 VCalFormat format; 699 VCalFormat format;
698 format.save( &cal, fn ); 700 format.save( &cal, fn );
699 } 701 }
700 mes = i18n("KO/Pi:Saved %1").arg(fn ); 702 mes = i18n("KO/Pi:Saved %1").arg(fn );
701 KOPrefs::instance()->mLastSaveFile = fn; 703 KOPrefs::instance()->mLastSaveFile = fn;
702 topLevelWidget()->setCaption(mes); 704 topLevelWidget()->setCaption(mes);
703 } 705 }
704 } 706 }
705 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); 707 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
706} 708}
707void KOListView::deleteAll() 709void KOListView::deleteAll()
708{ 710{
709 int icount = 0; 711 int icount = 0;
710 QPtrList<Incidence> delSel ; 712 QPtrList<Incidence> delSel ;
711 QListViewItem *item = mListView->firstChild (); 713 QListViewItem *item = mListView->firstChild ();
712 while ( item ) { 714 while ( item ) {
713 if ( item->isSelected() ) { 715 if ( item->isSelected() ) {
714 delSel.append(((KOListViewItem *)item)->data()); 716 delSel.append(((KOListViewItem *)item)->data());
715 ++icount; 717 ++icount;
716 } 718 }
717 719
718 item = item->nextSibling(); 720 item = item->nextSibling();
719 } 721 }
720 if ( icount ) { 722 if ( icount ) {
721 Incidence *incidence = delSel.first(); 723 Incidence *incidence = delSel.first();
722 Incidence *toDelete; 724 Incidence *toDelete;
723 KOPrefs *p = KOPrefs::instance(); 725 KOPrefs *p = KOPrefs::instance();
724 bool confirm = p->mConfirm; 726 bool confirm = p->mConfirm;
725 QString mess; 727 QString mess;
726 mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount ); 728 mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount );
727 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")) ) { 729 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")) ) {
728 p->mConfirm = false; 730 p->mConfirm = false;
729 int delCounter = 0; 731 int delCounter = 0;
730 QDialog dia ( this, "p-dialog", true ); 732 QDialog dia ( this, "p-dialog", true );
731 QLabel lab (i18n("Close dialog to abort deletion!"), &dia ); 733 QLabel lab (i18n("Close dialog to abort deletion!"), &dia );
732 QVBoxLayout lay( &dia ); 734 QVBoxLayout lay( &dia );
733 lay.setMargin(7); 735 lay.setMargin(7);
734 lay.setSpacing(7); 736 lay.setSpacing(7);
735 lay.addWidget( &lab); 737 lay.addWidget( &lab);
736 QProgressBar bar( icount, &dia ); 738 QProgressBar bar( icount, &dia );
737 lay.addWidget( &bar); 739 lay.addWidget( &bar);
738 int w = 220; 740 int w = 220;
739 int h = 50; 741 int h = 50;
740 int dw = QApplication::desktop()->width(); 742 int dw = QApplication::desktop()->width();
741 int dh = QApplication::desktop()->height(); 743 int dh = QApplication::desktop()->height();
742 dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 744 dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
743 //dia.resize( 240,50 ); 745 //dia.resize( 240,50 );
744 dia.show(); 746 dia.show();
745 747
746 while ( incidence ) { 748 while ( incidence ) {
747 bar.setProgress( delCounter ); 749 bar.setProgress( delCounter );
748 mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter ); 750 mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter );
749 dia.setCaption( mess ); 751 dia.setCaption( mess );
750 qApp->processEvents(); 752 qApp->processEvents();
751 toDelete = (incidence); 753 toDelete = (incidence);
752 incidence = delSel.next(); 754 incidence = delSel.next();
753 emit deleteIncidenceSignal(toDelete ); 755 emit deleteIncidenceSignal(toDelete );
754 if ( dia.result() != 0 ) 756 if ( dia.result() != 0 )
755 break; 757 break;
756 758
757 } 759 }
758 mess = mess.sprintf( i18n("%d items remaining in list."), count() ); 760 mess = mess.sprintf( i18n("%d items remaining in list."), count() );
759 topLevelWidget ()->setCaption( mess ); 761 topLevelWidget ()->setCaption( mess );
760 p->mConfirm = confirm; 762 p->mConfirm = confirm;
761 } 763 }
762 } 764 }
763 765
764 766
765} 767}
766int KOListView::maxDatesHint() 768int KOListView::maxDatesHint()
767{ 769{
768 return 0; 770 return 0;
769} 771}
770 772
771int KOListView::currentDateCount() 773int KOListView::currentDateCount()
772{ 774{
773 return 0; 775 return 0;
774} 776}
775 777
776QPtrList<Incidence> KOListView::selectedIncidences() 778QPtrList<Incidence> KOListView::selectedIncidences()
777{ 779{
778 QPtrList<Incidence> eventList; 780 QPtrList<Incidence> eventList;
779 QListViewItem *item = mListView->firstChild (); 781 QListViewItem *item = mListView->firstChild ();
780 while ( item ) { 782 while ( item ) {
781 if ( item->isSelected() ) { 783 if ( item->isSelected() ) {
782 eventList.append(((KOListViewItem *)item)->data()); 784 eventList.append(((KOListViewItem *)item)->data());
783 } 785 }
784 786
785 item = item->nextSibling(); 787 item = item->nextSibling();
786 } 788 }
787 789
788 // // QListViewItem *item = mListView->selectedItem(); 790 // // QListViewItem *item = mListView->selectedItem();
789 //if (item) eventList.append(((KOListViewItem *)item)->data()); 791 //if (item) eventList.append(((KOListViewItem *)item)->data());
790 792
791 return eventList; 793 return eventList;
792} 794}
793 795
794DateList KOListView::selectedDates() 796DateList KOListView::selectedDates()
795{ 797{
796 DateList eventList; 798 DateList eventList;
797 return eventList; 799 return eventList;
798} 800}
799 801
800void KOListView::showDates(bool show) 802void KOListView::showDates(bool show)
801{ 803{
802 // Shouldn't we set it to a value greater 0? When showDates is called with 804 // Shouldn't we set it to a value greater 0? When showDates is called with
803 // show == true at first, then the columnwidths are set to zero. 805 // show == true at first, then the columnwidths are set to zero.
804 static int oldColWidth1 = 0; 806 static int oldColWidth1 = 0;
805 static int oldColWidth3 = 0; 807 static int oldColWidth3 = 0;
806 808
807 if (!show) { 809 if (!show) {
808 oldColWidth1 = mListView->columnWidth(1); 810 oldColWidth1 = mListView->columnWidth(1);
809 oldColWidth3 = mListView->columnWidth(3); 811 oldColWidth3 = mListView->columnWidth(3);
810 mListView->setColumnWidth(1, 0); 812 mListView->setColumnWidth(1, 0);
811 mListView->setColumnWidth(3, 0); 813 mListView->setColumnWidth(3, 0);
812 } else { 814 } else {
813 mListView->setColumnWidth(1, oldColWidth1); 815 mListView->setColumnWidth(1, oldColWidth1);
814 mListView->setColumnWidth(3, oldColWidth3); 816 mListView->setColumnWidth(3, oldColWidth3);
815 } 817 }
816 mListView->repaint(); 818 mListView->repaint();
817} 819}
818 820
819void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd, 821void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd,
820 const QDate &td) 822 const QDate &td)
821{ 823{
822#ifndef KORG_NOPRINTER 824#ifndef KORG_NOPRINTER
823 calPrinter->preview(CalPrinter::Day, fd, td); 825 calPrinter->preview(CalPrinter::Day, fd, td);
824#endif 826#endif
825} 827}
826 828
827void KOListView::showDates() 829void KOListView::showDates()
828{ 830{
829 showDates(true); 831 showDates(true);
830} 832}
831 833
832void KOListView::hideDates() 834void KOListView::hideDates()
833{ 835{
834 showDates(false); 836 showDates(false);
835} 837}
836 838
837void KOListView::resetFocus() 839void KOListView::resetFocus()
838{ 840{
839 topLevelWidget()->setActiveWindow(); 841 topLevelWidget()->setActiveWindow();
840 topLevelWidget()->raise(); 842 topLevelWidget()->raise();
841 mListView->setFocus(); 843 mListView->setFocus();
842} 844}
843void KOListView::updateView() 845void KOListView::updateView()
844{ 846{
845 mListView->setFocus(); 847 mListView->setFocus();
846 if ( mListView->firstChild () ) 848 if ( mListView->firstChild () )
847 mListView->setCurrentItem( mListView->firstChild () ); 849 mListView->setCurrentItem( mListView->firstChild () );
848} 850}
849void KOListView::updateConfig() 851void KOListView::updateConfig()
850{ 852{
851 853
852 mListView->setFont ( KOPrefs::instance()->mListViewFont ); 854 mListView->setFont ( KOPrefs::instance()->mListViewFont );
853 updateView(); 855 updateView();
854 856
855} 857}
856void KOListView::setStartDate(const QDate &start) 858void KOListView::setStartDate(const QDate &start)
857{ 859{
858 mStartDate = start; 860 mStartDate = start;
859} 861}
860 862
861void KOListView::showDates(const QDate &start, const QDate &end) 863void KOListView::showDates(const QDate &start, const QDate &end)
862{ 864{
863 clear(); 865 clear();
864 mStartDate = start; 866 mStartDate = start;
865 QDate date = start; 867 QDate date = start;
866 QPtrList<Journal> j_list; 868 QPtrList<Journal> j_list;
867 while( date <= end ) { 869 while( date <= end ) {
868 addEvents(calendar()->events(date)); 870 addEvents(calendar()->events(date));
869 addTodos(calendar()->todos(date)); 871 addTodos(calendar()->todos(date));
870 Journal* jo = calendar()->journal(date); 872 Journal* jo = calendar()->journal(date);
871 if ( jo ) 873 if ( jo )
872 j_list.append( jo ); 874 j_list.append( jo );
873 date = date.addDays( 1 ); 875 date = date.addDays( 1 );
874 } 876 }
875 addJournals(j_list); 877 addJournals(j_list);
876 emit incidenceSelected( 0 ); 878 emit incidenceSelected( 0 );
877 updateView(); 879 updateView();
878 880
879} 881}
880 882
881void KOListView::addEvents(QPtrList<Event> eventList) 883void KOListView::addEvents(QPtrList<Event> eventList)
882{ 884{
885
883 Event *ev; 886 Event *ev;
884 for(ev = eventList.first(); ev; ev = eventList.next()) { 887 for(ev = eventList.first(); ev; ev = eventList.next()) {
885 addIncidence(ev); 888 addIncidence(ev);
886 } 889 }
887 if ( !mListView->currentItem() ){ 890 if ( !mListView->currentItem() ){
888 updateView(); 891 updateView();
889 } 892 }
890} 893}
891 894
892void KOListView::addTodos(QPtrList<Todo> eventList) 895void KOListView::addTodos(QPtrList<Todo> eventList)
893{ 896{
894 Todo *ev; 897 Todo *ev;
895 for(ev = eventList.first(); ev; ev = eventList.next()) { 898 for(ev = eventList.first(); ev; ev = eventList.next()) {
896 addIncidence(ev); 899 addIncidence(ev);
897 } 900 }
898 if ( !mListView->currentItem() ){ 901 if ( !mListView->currentItem() ){
899 updateView(); 902 updateView();
900 } 903 }
901} 904}
902void KOListView::addJournals(QPtrList<Journal> eventList) 905void KOListView::addJournals(QPtrList<Journal> eventList)
903{ 906{
904 Journal *ev; 907 Journal *ev;
905 for(ev = eventList.first(); ev; ev = eventList.next()) { 908 for(ev = eventList.first(); ev; ev = eventList.next()) {
906 addIncidence(ev); 909 addIncidence(ev);
907 } 910 }
908 if ( !mListView->currentItem() ){ 911 if ( !mListView->currentItem() ){
909 updateView(); 912 updateView();
910 } 913 }
911} 914}
912 915
913void KOListView::addIncidence(Incidence *incidence) 916void KOListView::addIncidence(Incidence *incidence)
914{ 917{
915 if ( mUidDict.find( incidence->uid() ) ) return; 918 if ( mUidDict.find( incidence->uid() ) ) return;
916 919
917 // mListView->setFont ( KOPrefs::instance()->mListViewFont ); 920 // mListView->setFont ( KOPrefs::instance()->mListViewFont );
918 mUidDict.insert( incidence->uid(), incidence ); 921 mUidDict.insert( incidence->uid(), incidence );
919
920 KOListViewItem *item = new KOListViewItem( incidence, mListView ); 922 KOListViewItem *item = new KOListViewItem( incidence, mListView );
921 ListItemVisitor v(item, mStartDate ); 923 ListItemVisitor v(item, mStartDate );
922 if (incidence->accept(v)) return; 924 if (incidence->accept(v)) {
925 return;
926 }
923 else delete item; 927 else delete item;
924 //qDebug("delete item ");
925} 928}
926 929
927void KOListView::showEvents(QPtrList<Event> eventList) 930void KOListView::showEvents(QPtrList<Event> eventList)
928{ 931{
929 clear(); 932 clear();
930 933
931 addEvents(eventList); 934 addEvents(eventList);
932 935
933 // After new creation of list view no events are selected. 936 // After new creation of list view no events are selected.
934 emit incidenceSelected( 0 ); 937 emit incidenceSelected( 0 );
935} 938}
936int KOListView::count() 939int KOListView::count()
937{ 940{
938 return mListView->childCount(); 941 return mListView->childCount();
939} 942}
940 943
941void KOListView::changeEventDisplay(Event *event, int action) 944void KOListView::changeEventDisplay(Event *event, int action)
942{ 945{
943 KOListViewItem *item; 946 KOListViewItem *item;
944 947
945 switch(action) { 948 switch(action) {
946 case KOGlobals::EVENTADDED: 949 case KOGlobals::EVENTADDED:
947 addIncidence( event ); 950 addIncidence( event );
948 break; 951 break;
949 case KOGlobals::EVENTEDITED: 952 case KOGlobals::EVENTEDITED:
950 item = getItemForEvent(event); 953 item = getItemForEvent(event);
951 if (item) { 954 if (item) {
952 mUidDict.remove( event->uid() ); 955 mUidDict.remove( event->uid() );
953 delete item; 956 delete item;
954 addIncidence( event ); 957 addIncidence( event );
955 } 958 }
956 break; 959 break;
957 case KOGlobals::EVENTDELETED: 960 case KOGlobals::EVENTDELETED:
958 item = getItemForEvent(event); 961 item = getItemForEvent(event);
959 if (item) { 962 if (item) {
960 mUidDict.remove( event->uid() ); 963 mUidDict.remove( event->uid() );
961 delete item; 964 delete item;
962 } 965 }
963 break; 966 break;
964 default: 967 default:
965 ; 968 ;
966 } 969 }
967} 970}
968 971
969KOListViewItem *KOListView::getItemForEvent(Event *event) 972KOListViewItem *KOListView::getItemForEvent(Event *event)
970{ 973{
971 KOListViewItem *item = (KOListViewItem *)mListView->firstChild(); 974 KOListViewItem *item = (KOListViewItem *)mListView->firstChild();
972 while (item) { 975 while (item) {
973 if (item->data() == event) return item; 976 if (item->data() == event) return item;
974 item = (KOListViewItem *)item->nextSibling(); 977 item = (KOListViewItem *)item->nextSibling();
975 } 978 }
976 return 0; 979 return 0;
977} 980}
978 981
979void KOListView::defaultItemAction(QListViewItem *i) 982void KOListView::defaultItemAction(QListViewItem *i)
980{ 983{
981 KOListViewItem *item = static_cast<KOListViewItem *>( i ); 984 KOListViewItem *item = static_cast<KOListViewItem *>( i );
982 if ( item ) defaultAction( item->data() ); 985 if ( item ) defaultAction( item->data() );
983 986
984} 987}
985 988
986void KOListView::popupMenu(QListViewItem *item,const QPoint &,int) 989void KOListView::popupMenu(QListViewItem *item,const QPoint &,int)
987{ 990{
988 mActiveItem = (KOListViewItem *)item; 991 mActiveItem = (KOListViewItem *)item;
989 if (mActiveItem) { 992 if (mActiveItem) {
990 Incidence *incidence = mActiveItem->data(); 993 Incidence *incidence = mActiveItem->data();
991 mPopupMenu->showIncidencePopup(incidence); 994 mPopupMenu->showIncidencePopup(incidence);
992 995
993 /* 996 /*
994 if ( incidence && incidence->type() == "Event" ) { 997 if ( incidence && incidence->type() == "Event" ) {
995 Event *event = static_cast<Event *>( incidence ); 998 Event *event = static_cast<Event *>( incidence );
996 mPopupMenu->showEventPopup(event); 999 mPopupMenu->showEventPopup(event);
997 } 1000 }
998 */ 1001 */
999 } 1002 }
1000} 1003}
1001 1004
1002void KOListView::readSettings(KConfig *config, QString setting) 1005void KOListView::readSettings(KConfig *config, QString setting)
1003{ 1006{
1004 // qDebug("KOListView::readSettings "); 1007 // qDebug("KOListView::readSettings ");
1005 mListView->restoreLayout(config,setting); 1008 mListView->restoreLayout(config,setting);
1006} 1009}
1007 1010
1008void KOListView::writeSettings(KConfig *config, QString setting) 1011void KOListView::writeSettings(KConfig *config, QString setting)
1009{ 1012{
1010 // qDebug("KOListView::writeSettings "); 1013 // qDebug("KOListView::writeSettings ");
1011 mListView->saveLayout(config, setting); 1014 mListView->saveLayout(config, setting);
1012} 1015}
1013 1016
1014void KOListView::processSelectionChange(QListViewItem *) 1017void KOListView::processSelectionChange(QListViewItem *)
1015{ 1018{
1016 1019
1017 KOListViewItem *item = 1020 KOListViewItem *item =
1018 static_cast<KOListViewItem *>( mListView->currentItem() ); 1021 static_cast<KOListViewItem *>( mListView->currentItem() );
1019 1022
1020 if ( !item ) { 1023 if ( !item ) {
1021 emit incidenceSelected( 0 ); 1024 emit incidenceSelected( 0 );
1022 } else { 1025 } else {
1023 emit incidenceSelected( item->data() ); 1026 emit incidenceSelected( item->data() );
1024 } 1027 }
1025} 1028}
1026 1029
1027void KOListView::clearSelection() 1030void KOListView::clearSelection()
1028{ 1031{
1029 mListView->selectAll( false ); 1032 mListView->selectAll( false );
1030} 1033}
1031void KOListView::allSelection() 1034void KOListView::allSelection()
1032{ 1035{
1033 mListView->selectAll( true ); 1036 mListView->selectAll( true );
1034} 1037}
1035 1038
1036void KOListView::clear() 1039void KOListView::clear()
1037{ 1040{
1038 mListView->clear(); 1041 mListView->clear();
1039 mUidDict.clear(); 1042 mUidDict.clear();
1040} 1043}
1041 1044
1042Incidence* KOListView::currentItem() 1045Incidence* KOListView::currentItem()
1043{ 1046{
1044 if ( mListView->currentItem() ) 1047 if ( mListView->currentItem() )
1045 return ((KOListViewItem*) mListView->currentItem())->data(); 1048 return ((KOListViewItem*) mListView->currentItem())->data();
1046 return 0; 1049 return 0;
1047} 1050}
1048void KOListView::keyPressEvent ( QKeyEvent *e) 1051void KOListView::keyPressEvent ( QKeyEvent *e)
1049{ 1052{
1050 1053
1051 if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) { 1054 if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) {
1052 deleteAll(); 1055 deleteAll();
1053 return; 1056 return;
1054 } 1057 }
1055 1058
1056 e->ignore(); 1059 e->ignore();
1057} 1060}
1058void KOListViewListView::keyPressEvent ( QKeyEvent *e) 1061void KOListViewListView::keyPressEvent ( QKeyEvent *e)
1059{ 1062{
1060 1063
1061 switch ( e->key() ) { 1064 switch ( e->key() ) {
1062 case Qt::Key_Down: 1065 case Qt::Key_Down:
1063 if ( e->state() == ShiftButton ) { 1066 if ( e->state() == ShiftButton ) {
1064 QListViewItem* cn = currentItem(); 1067 QListViewItem* cn = currentItem();
1065 if ( !cn ) 1068 if ( !cn )
1066 cn = firstChild(); 1069 cn = firstChild();
1067 if ( !cn ) 1070 if ( !cn )
1068 return; 1071 return;
1069 while ( cn->nextSibling() ) 1072 while ( cn->nextSibling() )
1070 cn = cn->nextSibling(); 1073 cn = cn->nextSibling();
1071 setCurrentItem ( cn ); 1074 setCurrentItem ( cn );
1072 ensureItemVisible ( cn ); 1075 ensureItemVisible ( cn );
1073 1076
1074 e->accept(); 1077 e->accept();
1075 return; 1078 return;
1076 } 1079 }
1077 if ( e->state() == ControlButton ) { 1080 if ( e->state() == ControlButton ) {
1078 int count = childCount (); 1081 int count = childCount ();
1079 int jump = count / 5; 1082 int jump = count / 5;
1080 QListViewItem* cn; 1083 QListViewItem* cn;
1081 cn = currentItem(); 1084 cn = currentItem();
1082 if ( ! cn ) 1085 if ( ! cn )
1083 return; 1086 return;
1084 if ( jump == 0 ) 1087 if ( jump == 0 )
1085 jump = 1; 1088 jump = 1;
1086 while ( jump && cn->nextSibling() ) { 1089 while ( jump && cn->nextSibling() ) {
1087 cn = cn->nextSibling(); 1090 cn = cn->nextSibling();
1088 --jump; 1091 --jump;
1089 } 1092 }
1090 setCurrentItem ( cn ); 1093 setCurrentItem ( cn );
1091 ensureItemVisible ( cn ); 1094 ensureItemVisible ( cn );
1092 1095
1093 } else 1096 } else
1094 QListView::keyPressEvent ( e ) ; 1097 QListView::keyPressEvent ( e ) ;
1095 e->accept(); 1098 e->accept();
1096 break; 1099 break;
1097 1100
1098 case Qt::Key_Up: 1101 case Qt::Key_Up:
1099 if ( e->state() == ShiftButton ) { 1102 if ( e->state() == ShiftButton ) {
1100 QListViewItem* cn = firstChild(); 1103 QListViewItem* cn = firstChild();
1101 if ( cn ) { 1104 if ( cn ) {
1102 setCurrentItem ( cn ); 1105 setCurrentItem ( cn );
1103 ensureItemVisible ( cn ); 1106 ensureItemVisible ( cn );
1104 } 1107 }
1105 e->accept(); 1108 e->accept();
1106 return; 1109 return;
1107 } 1110 }
1108 if ( e->state() == ControlButton ) { 1111 if ( e->state() == ControlButton ) {
1109 int count = childCount (); 1112 int count = childCount ();
1110 int jump = count / 5; 1113 int jump = count / 5;
1111 QListViewItem* cn; 1114 QListViewItem* cn;
1112 cn = currentItem(); 1115 cn = currentItem();
1113 if ( ! cn ) 1116 if ( ! cn )
1114 return; 1117 return;
1115 if ( jump == 0 ) 1118 if ( jump == 0 )
1116 jump = 1; 1119 jump = 1;
diff --git a/korganizer/searchdialog.cpp b/korganizer/searchdialog.cpp
index de65b53..007d1f3 100644
--- a/korganizer/searchdialog.cpp
+++ b/korganizer/searchdialog.cpp
@@ -34,392 +34,389 @@
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 searchLabel = new QLabel(topFrame); 58 searchLabel = new QLabel(topFrame);
59 searchLabel->setText(i18n("Search for:")); 59 searchLabel->setText(i18n("Search for:"));
60 subLayout->addWidget(searchLabel); 60 subLayout->addWidget(searchLabel);
61 61
62 searchEdit = new KLineEdit(topFrame); 62 searchEdit = new KLineEdit(topFrame);
63 subLayout->addWidget(searchEdit); 63 subLayout->addWidget(searchEdit);
64 QPushButton *OkButton = new QPushButton( i18n("&Find"), topFrame ); 64 QPushButton *OkButton = new QPushButton( i18n("&Find"), topFrame );
65 //OkButton->setDefault( true ); 65 //OkButton->setDefault( true );
66 connect(OkButton,SIGNAL(clicked()),SLOT(doSearch())); 66 connect(OkButton,SIGNAL(clicked()),SLOT(doSearch()));
67 subLayout->addWidget(OkButton); 67 subLayout->addWidget(OkButton);
68 searchEdit->setText("*"); // Find all events by default 68 searchEdit->setText("*"); // Find all events by default
69 searchEdit->setFocus(); 69 searchEdit->setFocus();
70 connect(searchEdit, SIGNAL(textChanged ( const QString & )),this,SLOT(searchTextChanged( const QString & ))); 70 connect(searchEdit, SIGNAL(textChanged ( const QString & )),this,SLOT(searchTextChanged( const QString & )));
71 connect(searchEdit, SIGNAL( returnPressed () ),this,SLOT(doSearch())); 71 connect(searchEdit, SIGNAL( returnPressed () ),this,SLOT(doSearch()));
72 // Subjects to search 72 // Subjects to search
73 // QGroupBox *subjectGroup = new QGroupBox(1,Vertical,i18n("Search In"), 73 // QGroupBox *subjectGroup = new QGroupBox(1,Vertical,i18n("Search In"),
74 // topFrame); 74 // topFrame);
75 75
76 QHBox *incidenceGroup = new QHBox( topFrame ); 76 QHBox *incidenceGroup = new QHBox( topFrame );
77 layout->addWidget(incidenceGroup); 77 layout->addWidget(incidenceGroup);
78 78
79 mSearchEvent = new QCheckBox(i18n("Events"),incidenceGroup); 79 mSearchEvent = new QCheckBox(i18n("Events"),incidenceGroup);
80 //mSearchEvent->setChecked(true); 80 //mSearchEvent->setChecked(true);
81 mSearchTodo = new QCheckBox(i18n("Todos"),incidenceGroup); 81 mSearchTodo = new QCheckBox(i18n("Todos"),incidenceGroup);
82 mSearchJournal = new QCheckBox(i18n("Journals"),incidenceGroup); 82 mSearchJournal = new QCheckBox(i18n("Journals"),incidenceGroup);
83 83
84 QHBox *subjectGroup = new QHBox( topFrame ); 84 QHBox *subjectGroup = new QHBox( topFrame );
85 layout->addWidget(subjectGroup); 85 layout->addWidget(subjectGroup);
86 86
87 mSummaryCheck = new QCheckBox(i18n("Summary/Loc."),subjectGroup); 87 mSummaryCheck = new QCheckBox(i18n("Summary/Loc."),subjectGroup);
88 mSummaryCheck->setChecked(true); 88 mSummaryCheck->setChecked(true);
89 mDescriptionCheck = new QCheckBox(i18n("Details"),subjectGroup); 89 mDescriptionCheck = new QCheckBox(i18n("Details"),subjectGroup);
90 mCategoryCheck = new QCheckBox(i18n("Categories"),subjectGroup); 90 mCategoryCheck = new QCheckBox(i18n("Categories"),subjectGroup);
91 91
92 QHBox *attendeeGroup = new QHBox( topFrame ); 92 QHBox *attendeeGroup = new QHBox( topFrame );
93 layout->addWidget(attendeeGroup ); 93 layout->addWidget(attendeeGroup );
94 new QLabel( i18n("Attendee:"),attendeeGroup ); 94 new QLabel( i18n("Attendee:"),attendeeGroup );
95 mSearchAName = new QCheckBox(i18n("Name"),attendeeGroup ); 95 mSearchAName = new QCheckBox(i18n("Name"),attendeeGroup );
96 mSearchAEmail = new QCheckBox(i18n("Email"), attendeeGroup ); 96 mSearchAEmail = new QCheckBox(i18n("Email"), attendeeGroup );
97 // Date range 97 // Date range
98 // QGroupBox *rangeGroup = new QGroupBox(1,Horizontal,i18n("Date Range"), 98 // QGroupBox *rangeGroup = new QGroupBox(1,Horizontal,i18n("Date Range"),
99 // topFrame); 99 // topFrame);
100 // layout->addWidget(rangeGroup); 100 // layout->addWidget(rangeGroup);
101 101
102 QWidget *rangeWidget = new QWidget(topFrame); 102 QWidget *rangeWidget = new QWidget(topFrame);
103 QHBoxLayout *rangeLayout = new QHBoxLayout(rangeWidget,0,KDialog::spacingHint()); 103 QHBoxLayout *rangeLayout = new QHBoxLayout(rangeWidget,0,KDialog::spacingHint());
104 rangeLayout->addWidget(new QLabel(i18n("From:"),rangeWidget)); 104 rangeLayout->addWidget(new QLabel(i18n("From:"),rangeWidget));
105 mStartDate = new KDateEdit(rangeWidget); 105 mStartDate = new KDateEdit(rangeWidget);
106 rangeLayout->addWidget(mStartDate); 106 rangeLayout->addWidget(mStartDate);
107 rangeLayout->addWidget(new QLabel(i18n("To:"),rangeWidget)); 107 rangeLayout->addWidget(new QLabel(i18n("To:"),rangeWidget));
108 mEndDate = new KDateEdit(rangeWidget); 108 mEndDate = new KDateEdit(rangeWidget);
109 mEndDate->setDate(QDate::currentDate().addDays(365)); 109 mEndDate->setDate(QDate::currentDate().addDays(365));
110 rangeLayout->addWidget(mEndDate); 110 rangeLayout->addWidget(mEndDate);
111 QToolButton *wt = QWhatsThis::whatsThisButton ( rangeWidget ); 111 QToolButton *wt = QWhatsThis::whatsThisButton ( rangeWidget );
112 rangeLayout->addWidget( (QWidget*)wt ); 112 rangeLayout->addWidget( (QWidget*)wt );
113 layout->addWidget(rangeWidget); 113 layout->addWidget(rangeWidget);
114 // Results list view 114 // Results list view
115 listView = new KOListView(mCalendar,topFrame); 115 listView = new KOListView(mCalendar,topFrame);
116 layout->addWidget(listView); 116 layout->addWidget(listView);
117 117
118 listView->readSettings(KOGlobals::config(),"SearchListView Layout"); 118 listView->readSettings(KOGlobals::config(),"SearchListView Layout");
119 connect(searchEdit,SIGNAL(scrollDOWN()),SLOT(setFocusToList())); 119 connect(searchEdit,SIGNAL(scrollDOWN()),SLOT(setFocusToList()));
120 120
121 setCaption( i18n("KO/Pi Find: ")); 121 setCaption( i18n("KO/Pi Find: "));
122#ifdef DESKTOP_VERSION 122#ifdef DESKTOP_VERSION
123 OkButton = new QPushButton( i18n("Close"), this ); 123 OkButton = new QPushButton( i18n("Close"), this );
124 connect(OkButton,SIGNAL(clicked()),SLOT(hide())); 124 connect(OkButton,SIGNAL(clicked()),SLOT(hide()));
125#endif 125#endif
126} 126}
127 127
128SearchDialog::~SearchDialog() 128SearchDialog::~SearchDialog()
129{ 129{
130 130
131} 131}
132void SearchDialog::raiseAndSelect() 132void SearchDialog::raiseAndSelect()
133{ 133{
134 134
135 static int currentState = 0; 135 static int currentState = 0;
136 136
137 if ( !mSearchJournal->isChecked() && !mSearchTodo->isChecked() && !mSearchEvent->isChecked() ) 137 if ( !mSearchJournal->isChecked() && !mSearchTodo->isChecked() && !mSearchEvent->isChecked() )
138 currentState = 0; 138 currentState = 0;
139 int newState = 0; 139 int newState = 0;
140 if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) { 140 if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) {
141 newState = VIEW_J_VIEW; 141 newState = VIEW_J_VIEW;
142 } 142 }
143 else if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) { 143 else if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) {
144 newState = VIEW_T_VIEW; 144 newState = VIEW_T_VIEW;
145 } 145 }
146 else { 146 else {
147 newState = VIEW_A_VIEW; 147 newState = VIEW_A_VIEW;
148 } 148 }
149 if ( newState != currentState ) { 149 if ( newState != currentState ) {
150 if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) { 150 if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) {
151 if ( ! mSearchJournal->isChecked() ) { 151 if ( ! mSearchJournal->isChecked() ) {
152 mSearchJournal->setChecked( true ); 152 mSearchJournal->setChecked( true );
153 mSearchTodo->setChecked( false ); 153 mSearchTodo->setChecked( false );
154 mSearchEvent->setChecked( false ); 154 mSearchEvent->setChecked( false );
155 } 155 }
156 } 156 }
157 else if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) { 157 else if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) {
158 if ( ! mSearchTodo->isChecked() ) { 158 if ( ! mSearchTodo->isChecked() ) {
159 mSearchTodo->setChecked( true ); 159 mSearchTodo->setChecked( true );
160 mSearchJournal->setChecked( false ); 160 mSearchJournal->setChecked( false );
161 mSearchEvent->setChecked( false ); 161 mSearchEvent->setChecked( false );
162 } 162 }
163 } 163 }
164 else { 164 else {
165 if ( ! mSearchEvent->isChecked() ) { 165 if ( ! mSearchEvent->isChecked() ) {
166 mSearchEvent->setChecked( true ); 166 mSearchEvent->setChecked( true );
167 mSearchJournal->setChecked( false ); 167 mSearchJournal->setChecked( false );
168 mSearchTodo->setChecked( false ); 168 mSearchTodo->setChecked( false );
169 } 169 }
170 } 170 }
171 } 171 }
172 currentState = newState; 172 currentState = newState;
173 raise(); 173 raise();
174} 174}
175void SearchDialog::setFocusToList() 175void SearchDialog::setFocusToList()
176{ 176{
177 listView->resetFocus(); 177 listView->resetFocus();
178} 178}
179void SearchDialog::accept() 179void SearchDialog::accept()
180{ 180{
181 doSearch(); 181 doSearch();
182} 182}
183void SearchDialog::updateList() 183void SearchDialog::updateList()
184{ 184{
185 //listView->updateList(); 185 //listView->updateList();
186 if ( isVisible() ) { 186 if ( isVisible() ) {
187 updateView(); 187 updateView();
188 //qDebug("SearchDialog::updated "); 188 //qDebug("SearchDialog::updated ");
189 } 189 }
190 else { 190 else {
191 listView->clear(); 191 listView->clear();
192 //qDebug("SearchDialog::cleared "); 192 //qDebug("SearchDialog::cleared ");
193 193
194 } 194 }
195} 195}
196void SearchDialog::searchTextChanged( const QString &_text ) 196void SearchDialog::searchTextChanged( const QString &_text )
197{ 197{
198#if 0 198#if 0
199 enableButton( KDialogBase::User1, !_text.isEmpty() ); 199 enableButton( KDialogBase::User1, !_text.isEmpty() );
200#endif 200#endif
201} 201}
202 202
203void SearchDialog::doSearch() 203void SearchDialog::doSearch()
204{ 204{
205 QRegExp re; 205 QRegExp re;
206 206
207 re.setWildcard(true); // most people understand these better. 207 re.setWildcard(true); // most people understand these better.
208 re.setCaseSensitive(false); 208 re.setCaseSensitive(false);
209 QString st = searchEdit->text(); 209 QString st = searchEdit->text();
210 if ( st.right(1) != "*") 210 if ( st.right(1) != "*")
211 st += "*"; 211 st += "*";
212 re.setPattern(st); 212 re.setPattern(st);
213 if (!mSearchEvent->isChecked() && !mSearchTodo->isChecked() && !mSearchJournal->isChecked() ) { 213 if (!mSearchEvent->isChecked() && !mSearchTodo->isChecked() && !mSearchJournal->isChecked() ) {
214 KMessageBox::sorry(this, 214 KMessageBox::sorry(this,
215 i18n("Please select at least one\nof the types to search for:\n\nEvents\nTodos\nJournals")); 215 i18n("Please select at least one\nof the types to search for:\n\nEvents\nTodos\nJournals"));
216 return; 216 return;
217 } 217 }
218 if (!re.isValid() ) { 218 if (!re.isValid() ) {
219 KMessageBox::sorry(this, 219 KMessageBox::sorry(this,
220 i18n("Invalid search expression,\ncannot perform " 220 i18n("Invalid search expression,\ncannot perform "
221 "the search.\nPlease enter a search expression\n" 221 "the search.\nPlease enter a search expression\n"
222 "using the wildcard characters\n '*' and '?'" 222 "using the wildcard characters\n '*' and '?'"
223 "where needed.")); 223 "where needed."));
224 return; 224 return;
225 } 225 }
226
227 search(re); 226 search(re);
228
229 listView->setStartDate( mStartDate->date() ); 227 listView->setStartDate( mStartDate->date() );
230 listView->showEvents(mMatchedEvents); 228 listView->showEvents(mMatchedEvents);
231 listView->addTodos(mMatchedTodos); 229 listView->addTodos(mMatchedTodos);
232 listView->addJournals(mMatchedJournals); 230 listView->addJournals(mMatchedJournals);
233
234 if (mMatchedEvents.count() + mMatchedJournals.count() + mMatchedTodos.count() == 0) { 231 if (mMatchedEvents.count() + mMatchedJournals.count() + mMatchedTodos.count() == 0) {
235 setCaption(i18n("No items found. Use '*' and '?' where needed.")); 232 setCaption(i18n("No items found. Use '*' and '?' where needed."));
236 } else { 233 } else {
237 QString mess; 234 QString mess;
238 mess = mess.sprintf( i18n("%d item(s) found."), mMatchedEvents.count()+ mMatchedJournals.count() + mMatchedTodos.count() ); 235 mess = mess.sprintf( i18n("%d item(s) found."), mMatchedEvents.count()+ mMatchedJournals.count() + mMatchedTodos.count() );
239 setCaption( i18n("KO/Pi Find: ") + mess); 236 setCaption( i18n("KO/Pi Find: ") + mess);
240 237
241 } 238 }
242 searchEdit->setFocus(); 239 searchEdit->setFocus();
243} 240}
244void SearchDialog::updateConfig() 241void SearchDialog::updateConfig()
245{ 242{
246 listView->updateConfig(); 243 listView->updateConfig();
247} 244}
248void SearchDialog::updateView() 245void SearchDialog::updateView()
249{ 246{
250 //qDebug("SearchDialog::updateView() %d ", isVisible()); 247 //qDebug("SearchDialog::updateView() %d ", isVisible());
251 QRegExp re; 248 QRegExp re;
252 re.setWildcard(true); // most people understand these better. 249 re.setWildcard(true); // most people understand these better.
253 re.setCaseSensitive(false); 250 re.setCaseSensitive(false);
254 QString st = searchEdit->text(); 251 QString st = searchEdit->text();
255 if ( st.right(1) != "*") 252 if ( st.right(1) != "*")
256 st += "*"; 253 st += "*";
257 re.setPattern(st); 254 re.setPattern(st);
258 if (re.isValid()) { 255 if (re.isValid()) {
259 search(re); 256 search(re);
260 } else { 257 } else {
261 mMatchedEvents.clear(); 258 mMatchedEvents.clear();
262 mMatchedTodos.clear(); 259 mMatchedTodos.clear();
263 mMatchedJournals.clear(); 260 mMatchedJournals.clear();
264 } 261 }
265 listView->setStartDate( mStartDate->date() ); 262 listView->setStartDate( mStartDate->date() );
266 listView->showEvents(mMatchedEvents); 263 listView->showEvents(mMatchedEvents);
267 listView->addTodos(mMatchedTodos); 264 listView->addTodos(mMatchedTodos);
268 listView->addJournals(mMatchedJournals); 265 listView->addJournals(mMatchedJournals);
269} 266}
270 267
271void SearchDialog::search(const QRegExp &re) 268void SearchDialog::search(const QRegExp &re)
272{ 269{
273 QPtrList<Event> events = mCalendar->events( mStartDate->date(), 270 QPtrList<Event> events = mCalendar->events( mStartDate->date(),
274 mEndDate->date(), 271 mEndDate->date(),
275 false /*mInclusiveCheck->isChecked()*/ ); 272 false /*mInclusiveCheck->isChecked()*/ );
276 273
277 mMatchedEvents.clear(); 274 mMatchedEvents.clear();
278 if ( mSearchEvent->isChecked() ) { 275 if ( mSearchEvent->isChecked() ) {
279 Event *ev; 276 Event *ev;
280 for(ev=events.first();ev;ev=events.next()) { 277 for(ev=events.first();ev;ev=events.next()) {
281 if (mSummaryCheck->isChecked()) { 278 if (mSummaryCheck->isChecked()) {
282#if QT_VERSION >= 0x030000 279#if QT_VERSION >= 0x030000
283 if (re.search(ev->summary()) != -1) 280 if (re.search(ev->summary()) != -1)
284#else 281#else
285 if (re.match(ev->summary()) != -1) 282 if (re.match(ev->summary()) != -1)
286#endif 283#endif
287 { 284 {
288 mMatchedEvents.append(ev); 285 mMatchedEvents.append(ev);
289 continue; 286 continue;
290 } 287 }
291#if QT_VERSION >= 0x030000 288#if QT_VERSION >= 0x030000
292 if (re.search(ev->location()) != -1) 289 if (re.search(ev->location()) != -1)
293#else 290#else
294 if (re.match(ev->location()) != -1) 291 if (re.match(ev->location()) != -1)
295#endif 292#endif
296 { 293 {
297 mMatchedEvents.append(ev); 294 mMatchedEvents.append(ev);
298 continue; 295 continue;
299 } 296 }
300 } 297 }
301 if (mDescriptionCheck->isChecked()) { 298 if (mDescriptionCheck->isChecked()) {
302#if QT_VERSION >= 0x030000 299#if QT_VERSION >= 0x030000
303 if (re.search(ev->description()) != -1) 300 if (re.search(ev->description()) != -1)
304#else 301#else
305 if (re.match(ev->description()) != -1) 302 if (re.match(ev->description()) != -1)
306#endif 303#endif
307 { 304 {
308 mMatchedEvents.append(ev); 305 mMatchedEvents.append(ev);
309 continue; 306 continue;
310 } 307 }
311 } 308 }
312 if (mCategoryCheck->isChecked()) { 309 if (mCategoryCheck->isChecked()) {
313#if QT_VERSION >= 0x030000 310#if QT_VERSION >= 0x030000
314 if (re.search(ev->categoriesStr()) != -1) 311 if (re.search(ev->categoriesStr()) != -1)
315#else 312#else
316 if (re.match(ev->categoriesStr()) != -1) 313 if (re.match(ev->categoriesStr()) != -1)
317#endif 314#endif
318 { 315 {
319 mMatchedEvents.append(ev); 316 mMatchedEvents.append(ev);
320 continue; 317 continue;
321 } 318 }
322 } 319 }
323 if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) { 320 if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) {
324 QPtrList<Attendee> tmpAList = ev->attendees(); 321 QPtrList<Attendee> tmpAList = ev->attendees();
325 Attendee *a; 322 Attendee *a;
326 for (a = tmpAList.first(); a; a = tmpAList.next()) { 323 for (a = tmpAList.first(); a; a = tmpAList.next()) {
327 if (mSearchAName->isChecked()) { 324 if (mSearchAName->isChecked()) {
328#if QT_VERSION >= 0x030000 325#if QT_VERSION >= 0x030000
329 if (re.search(a->name()) != -1) 326 if (re.search(a->name()) != -1)
330#else 327#else
331 if (re.match(a->name()) != -1) 328 if (re.match(a->name()) != -1)
332#endif 329#endif
333 { 330 {
334 mMatchedEvents.append(ev); 331 mMatchedEvents.append(ev);
335 break; 332 break;
336 } 333 }
337 } 334 }
338 if (mSearchAEmail->isChecked()) { 335 if (mSearchAEmail->isChecked()) {
339#if QT_VERSION >= 0x030000 336#if QT_VERSION >= 0x030000
340 if (re.search(a->email()) != -1) 337 if (re.search(a->email()) != -1)
341#else 338#else
342 if (re.match(a->email()) != -1) 339 if (re.match(a->email()) != -1)
343#endif 340#endif
344 { 341 {
345 mMatchedEvents.append(ev); 342 mMatchedEvents.append(ev);
346 break; 343 break;
347 } 344 }
348 } 345 }
349 } 346 }
350 } 347 }
351 } 348 }
352 } 349 }
353 QPtrList<Todo> todos = mCalendar->todos( ); 350 QPtrList<Todo> todos = mCalendar->todos( );
354 mMatchedTodos.clear(); 351 mMatchedTodos.clear();
355 if ( mSearchTodo->isChecked() ) { 352 if ( mSearchTodo->isChecked() ) {
356 Todo *tod; 353 Todo *tod;
357 for(tod=todos.first();tod;tod=todos.next()) { 354 for(tod=todos.first();tod;tod=todos.next()) {
358 if (mSummaryCheck->isChecked()) { 355 if (mSummaryCheck->isChecked()) {
359#if QT_VERSION >= 0x030000 356#if QT_VERSION >= 0x030000
360 if (re.search(tod->summary()) != -1) 357 if (re.search(tod->summary()) != -1)
361#else 358#else
362 if (re.match(tod->summary()) != -1) 359 if (re.match(tod->summary()) != -1)
363#endif 360#endif
364 { 361 {
365 mMatchedTodos.append(tod); 362 mMatchedTodos.append(tod);
366 continue; 363 continue;
367 } 364 }
368 } 365 }
369 if (mDescriptionCheck->isChecked()) { 366 if (mDescriptionCheck->isChecked()) {
370#if QT_VERSION >= 0x030000 367#if QT_VERSION >= 0x030000
371 if (re.search(tod->description()) != -1) 368 if (re.search(tod->description()) != -1)
372#else 369#else
373 if (re.match(tod->description()) != -1) 370 if (re.match(tod->description()) != -1)
374#endif 371#endif
375 { 372 {
376 mMatchedTodos.append(tod); 373 mMatchedTodos.append(tod);
377 continue; 374 continue;
378 } 375 }
379 } 376 }
380 if (mCategoryCheck->isChecked()) { 377 if (mCategoryCheck->isChecked()) {
381#if QT_VERSION >= 0x030000 378#if QT_VERSION >= 0x030000
382 if (re.search(tod->categoriesStr()) != -1) 379 if (re.search(tod->categoriesStr()) != -1)
383#else 380#else
384 if (re.match(tod->categoriesStr()) != -1) 381 if (re.match(tod->categoriesStr()) != -1)
385#endif 382#endif
386 { 383 {
387 mMatchedTodos.append(tod); 384 mMatchedTodos.append(tod);
388 continue; 385 continue;
389 } 386 }
390 } 387 }
391 if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) { 388 if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) {
392 QPtrList<Attendee> tmpAList = tod->attendees(); 389 QPtrList<Attendee> tmpAList = tod->attendees();
393 Attendee *a; 390 Attendee *a;
394 for (a = tmpAList.first(); a; a = tmpAList.next()) { 391 for (a = tmpAList.first(); a; a = tmpAList.next()) {
395 if (mSearchAName->isChecked()) { 392 if (mSearchAName->isChecked()) {
396#if QT_VERSION >= 0x030000 393#if QT_VERSION >= 0x030000
397 if (re.search(a->name()) != -1) 394 if (re.search(a->name()) != -1)
398#else 395#else
399 if (re.match(a->name()) != -1) 396 if (re.match(a->name()) != -1)
400#endif 397#endif
401 { 398 {
402 mMatchedTodos.append(tod); 399 mMatchedTodos.append(tod);
403 break; 400 break;
404 } 401 }
405 } 402 }
406 if (mSearchAEmail->isChecked()) { 403 if (mSearchAEmail->isChecked()) {
407#if QT_VERSION >= 0x030000 404#if QT_VERSION >= 0x030000
408 if (re.search(a->email()) != -1) 405 if (re.search(a->email()) != -1)
409#else 406#else
410 if (re.match(a->email()) != -1) 407 if (re.match(a->email()) != -1)
411#endif 408#endif
412 { 409 {
413 mMatchedTodos.append(tod); 410 mMatchedTodos.append(tod);
414 break; 411 break;
415 } 412 }
416 } 413 }
417 } 414 }
418 } 415 }
419 } 416 }
420 } 417 }
421 mMatchedJournals.clear(); 418 mMatchedJournals.clear();
422 if (mSearchJournal->isChecked() ) { 419 if (mSearchJournal->isChecked() ) {
423 QPtrList<Journal> journals = mCalendar->journals( ); 420 QPtrList<Journal> journals = mCalendar->journals( );
424 Journal* journ; 421 Journal* journ;
425 422
diff --git a/libkcal/alarm.cpp b/libkcal/alarm.cpp
index d8f15b5..6de1566 100644
--- a/libkcal/alarm.cpp
+++ b/libkcal/alarm.cpp
@@ -169,313 +169,313 @@ void Alarm::setAudioFile(const QString &audioFile)
169 if (mType == Audio) { 169 if (mType == Audio) {
170 mFile = audioFile; 170 mFile = audioFile;
171 mParent->updated(); 171 mParent->updated();
172 } 172 }
173} 173}
174 174
175QString Alarm::audioFile() const 175QString Alarm::audioFile() const
176{ 176{
177 return (mType == Audio) ? mFile : QString::null; 177 return (mType == Audio) ? mFile : QString::null;
178} 178}
179 179
180void Alarm::setProcedureAlarm(const QString &programFile, const QString &arguments) 180void Alarm::setProcedureAlarm(const QString &programFile, const QString &arguments)
181{ 181{
182 mType = Procedure; 182 mType = Procedure;
183 mFile = programFile; 183 mFile = programFile;
184 mDescription = arguments; 184 mDescription = arguments;
185 mParent->updated(); 185 mParent->updated();
186} 186}
187 187
188void Alarm::setProgramFile(const QString &programFile) 188void Alarm::setProgramFile(const QString &programFile)
189{ 189{
190 if (mType == Procedure) { 190 if (mType == Procedure) {
191 mFile = programFile; 191 mFile = programFile;
192 mParent->updated(); 192 mParent->updated();
193 } 193 }
194} 194}
195 195
196QString Alarm::programFile() const 196QString Alarm::programFile() const
197{ 197{
198 return (mType == Procedure) ? mFile : QString::null; 198 return (mType == Procedure) ? mFile : QString::null;
199} 199}
200 200
201void Alarm::setProgramArguments(const QString &arguments) 201void Alarm::setProgramArguments(const QString &arguments)
202{ 202{
203 if (mType == Procedure) { 203 if (mType == Procedure) {
204 mDescription = arguments; 204 mDescription = arguments;
205 mParent->updated(); 205 mParent->updated();
206 } 206 }
207} 207}
208 208
209QString Alarm::programArguments() const 209QString Alarm::programArguments() const
210{ 210{
211 return (mType == Procedure) ? mDescription : QString::null; 211 return (mType == Procedure) ? mDescription : QString::null;
212} 212}
213 213
214void Alarm::setEmailAlarm(const QString &subject, const QString &text, 214void Alarm::setEmailAlarm(const QString &subject, const QString &text,
215 const QValueList<Person> &addressees, const QStringList &attachments) 215 const QValueList<Person> &addressees, const QStringList &attachments)
216{ 216{
217 mType = Email; 217 mType = Email;
218 mMailSubject = subject; 218 mMailSubject = subject;
219 mDescription = text; 219 mDescription = text;
220 mMailAddresses = addressees; 220 mMailAddresses = addressees;
221 mMailAttachFiles = attachments; 221 mMailAttachFiles = attachments;
222 mParent->updated(); 222 mParent->updated();
223} 223}
224 224
225void Alarm::setMailAddress(const Person &mailAddress) 225void Alarm::setMailAddress(const Person &mailAddress)
226{ 226{
227 if (mType == Email) { 227 if (mType == Email) {
228 mMailAddresses.clear(); 228 mMailAddresses.clear();
229 mMailAddresses += mailAddress; 229 mMailAddresses += mailAddress;
230 mParent->updated(); 230 mParent->updated();
231 } 231 }
232} 232}
233 233
234void Alarm::setMailAddresses(const QValueList<Person> &mailAddresses) 234void Alarm::setMailAddresses(const QValueList<Person> &mailAddresses)
235{ 235{
236 if (mType == Email) { 236 if (mType == Email) {
237 mMailAddresses = mailAddresses; 237 mMailAddresses = mailAddresses;
238 mParent->updated(); 238 mParent->updated();
239 } 239 }
240} 240}
241 241
242void Alarm::addMailAddress(const Person &mailAddress) 242void Alarm::addMailAddress(const Person &mailAddress)
243{ 243{
244 if (mType == Email) { 244 if (mType == Email) {
245 mMailAddresses += mailAddress; 245 mMailAddresses += mailAddress;
246 mParent->updated(); 246 mParent->updated();
247 } 247 }
248} 248}
249 249
250QValueList<Person> Alarm::mailAddresses() const 250QValueList<Person> Alarm::mailAddresses() const
251{ 251{
252 return (mType == Email) ? mMailAddresses : QValueList<Person>(); 252 return (mType == Email) ? mMailAddresses : QValueList<Person>();
253} 253}
254 254
255void Alarm::setMailSubject(const QString &mailAlarmSubject) 255void Alarm::setMailSubject(const QString &mailAlarmSubject)
256{ 256{
257 if (mType == Email) { 257 if (mType == Email) {
258 mMailSubject = mailAlarmSubject; 258 mMailSubject = mailAlarmSubject;
259 mParent->updated(); 259 mParent->updated();
260 } 260 }
261} 261}
262 262
263QString Alarm::mailSubject() const 263QString Alarm::mailSubject() const
264{ 264{
265 return (mType == Email) ? mMailSubject : QString::null; 265 return (mType == Email) ? mMailSubject : QString::null;
266} 266}
267 267
268void Alarm::setMailAttachment(const QString &mailAttachFile) 268void Alarm::setMailAttachment(const QString &mailAttachFile)
269{ 269{
270 if (mType == Email) { 270 if (mType == Email) {
271 mMailAttachFiles.clear(); 271 mMailAttachFiles.clear();
272 mMailAttachFiles += mailAttachFile; 272 mMailAttachFiles += mailAttachFile;
273 mParent->updated(); 273 mParent->updated();
274 } 274 }
275} 275}
276 276
277void Alarm::setMailAttachments(const QStringList &mailAttachFiles) 277void Alarm::setMailAttachments(const QStringList &mailAttachFiles)
278{ 278{
279 if (mType == Email) { 279 if (mType == Email) {
280 mMailAttachFiles = mailAttachFiles; 280 mMailAttachFiles = mailAttachFiles;
281 mParent->updated(); 281 mParent->updated();
282 } 282 }
283} 283}
284 284
285void Alarm::addMailAttachment(const QString &mailAttachFile) 285void Alarm::addMailAttachment(const QString &mailAttachFile)
286{ 286{
287 if (mType == Email) { 287 if (mType == Email) {
288 mMailAttachFiles += mailAttachFile; 288 mMailAttachFiles += mailAttachFile;
289 mParent->updated(); 289 mParent->updated();
290 } 290 }
291} 291}
292 292
293QStringList Alarm::mailAttachments() const 293QStringList Alarm::mailAttachments() const
294{ 294{
295 return (mType == Email) ? mMailAttachFiles : QStringList(); 295 return (mType == Email) ? mMailAttachFiles : QStringList();
296} 296}
297 297
298void Alarm::setMailText(const QString &text) 298void Alarm::setMailText(const QString &text)
299{ 299{
300 if (mType == Email) { 300 if (mType == Email) {
301 mDescription = text; 301 mDescription = text;
302 mParent->updated(); 302 mParent->updated();
303 } 303 }
304} 304}
305 305
306QString Alarm::mailText() const 306QString Alarm::mailText() const
307{ 307{
308 return (mType == Email) ? mDescription : QString::null; 308 return (mType == Email) ? mDescription : QString::null;
309} 309}
310 310
311void Alarm::setDisplayAlarm(const QString &text) 311void Alarm::setDisplayAlarm(const QString &text)
312{ 312{
313 mType = Display; 313 mType = Display;
314 mDescription = text; 314 mDescription = text;
315 mParent->updated(); 315 mParent->updated();
316} 316}
317 317
318void Alarm::setText(const QString &text) 318void Alarm::setText(const QString &text)
319{ 319{
320 if (mType == Display) { 320 if (mType == Display) {
321 mDescription = text; 321 mDescription = text;
322 mParent->updated(); 322 mParent->updated();
323 } 323 }
324} 324}
325 325
326QString Alarm::text() const 326QString Alarm::text() const
327{ 327{
328 return (mType == Display) ? mDescription : QString::null; 328 return (mType == Display) ? mDescription : QString::null;
329} 329}
330 330
331void Alarm::setTime(const QDateTime &alarmTime) 331void Alarm::setTime(const QDateTime &alarmTime)
332{ 332{
333 mAlarmTime = alarmTime; 333 mAlarmTime = alarmTime;
334 mHasTime = true; 334 mHasTime = true;
335 335
336 mParent->updated(); 336 mParent->updated();
337} 337}
338int Alarm::offset() 338int Alarm::offset()
339{ 339{
340 if ( hasTime() ) { 340 if ( hasTime() ) {
341 if (mParent->type()=="Todo") { 341 if (mParent->type()=="Todo") {
342 Todo *t = static_cast<Todo*>(mParent); 342 Todo *t = static_cast<Todo*>(mParent);
343 return t->dtDue().secsTo( mAlarmTime ) ; 343 return t->dtDue().secsTo( mAlarmTime ) ;
344 } else 344 } else
345 return mParent->dtStart().secsTo( mAlarmTime ) ; 345 return mParent->dtStart().secsTo( mAlarmTime ) ;
346 } 346 }
347 else 347 else
348 { 348 {
349 return mOffset.asSeconds(); 349 return mOffset.asSeconds();
350 } 350 }
351 351
352} 352}
353QString Alarm::offsetText() 353QString Alarm::offsetText()
354{ 354{
355 int min = -offset()/60; 355 int min = -offset()/60;
356 int hours = min /60; 356 int hours = min /60;
357 min = min % 60; 357 min = min % 60;
358 int days = hours /24; 358 int days = hours /24;
359 hours = hours % 24; 359 hours = hours % 24;
360 QString message; 360 QString message;
361 qDebug("%d %d %d ", days, hours, min ); 361 //qDebug("%d %d %d ", days, hours, min );
362 if ( days > 0 ) 362 if ( days > 0 )
363 message += i18n("%1d").arg( days ); 363 message += i18n("%1d").arg( days );
364 if ( hours > 0 ) { 364 if ( hours > 0 ) {
365 if ( !message.isEmpty() ) message += "/"; 365 if ( !message.isEmpty() ) message += "/";
366 message += i18n("%1h").arg( hours ); 366 message += i18n("%1h").arg( hours );
367 } 367 }
368 if ( min > 0 ) { 368 if ( min > 0 ) {
369 if ( !message.isEmpty() ) message += "/"; 369 if ( !message.isEmpty() ) message += "/";
370 message += i18n("%1min").arg( min ); 370 message += i18n("%1min").arg( min );
371 } 371 }
372 if ( message.isEmpty() ) 372 if ( message.isEmpty() )
373 message = i18n("%1min").arg( 0 ); 373 message = i18n("%1min").arg( 0 );
374 return message; 374 return message;
375} 375}
376 376
377 377
378QDateTime Alarm::time() const 378QDateTime Alarm::time() const
379{ 379{
380 if ( hasTime() ) 380 if ( hasTime() )
381 return mAlarmTime; 381 return mAlarmTime;
382 else 382 else
383 { 383 {
384 if (mParent->type()=="Todo") { 384 if (mParent->type()=="Todo") {
385 Todo *t = static_cast<Todo*>(mParent); 385 Todo *t = static_cast<Todo*>(mParent);
386 return mOffset.end( t->dtDue() ); 386 return mOffset.end( t->dtDue() );
387 } else if (mEndOffset) { 387 } else if (mEndOffset) {
388 return mOffset.end( mParent->dtEnd() ); 388 return mOffset.end( mParent->dtEnd() );
389 } else { 389 } else {
390 return mOffset.end( mParent->dtStart() ); 390 return mOffset.end( mParent->dtStart() );
391 } 391 }
392 } 392 }
393} 393}
394 394
395bool Alarm::hasTime() const 395bool Alarm::hasTime() const
396{ 396{
397 return mHasTime; 397 return mHasTime;
398} 398}
399 399
400void Alarm::setSnoozeTime(int alarmSnoozeTime) 400void Alarm::setSnoozeTime(int alarmSnoozeTime)
401{ 401{
402 mAlarmSnoozeTime = alarmSnoozeTime; 402 mAlarmSnoozeTime = alarmSnoozeTime;
403 mParent->updated(); 403 mParent->updated();
404} 404}
405 405
406int Alarm::snoozeTime() const 406int Alarm::snoozeTime() const
407{ 407{
408 return mAlarmSnoozeTime; 408 return mAlarmSnoozeTime;
409} 409}
410 410
411void Alarm::setRepeatCount(int alarmRepeatCount) 411void Alarm::setRepeatCount(int alarmRepeatCount)
412{ 412{
413 kdDebug(5800) << "Alarm::setRepeatCount(): " << alarmRepeatCount << endl; 413 kdDebug(5800) << "Alarm::setRepeatCount(): " << alarmRepeatCount << endl;
414 414
415 mAlarmRepeatCount = alarmRepeatCount; 415 mAlarmRepeatCount = alarmRepeatCount;
416 mParent->updated(); 416 mParent->updated();
417} 417}
418 418
419int Alarm::repeatCount() const 419int Alarm::repeatCount() const
420{ 420{
421 kdDebug(5800) << "Alarm::repeatCount(): " << mAlarmRepeatCount << endl; 421 kdDebug(5800) << "Alarm::repeatCount(): " << mAlarmRepeatCount << endl;
422 return mAlarmRepeatCount; 422 return mAlarmRepeatCount;
423} 423}
424 424
425void Alarm::toggleAlarm() 425void Alarm::toggleAlarm()
426{ 426{
427 mAlarmEnabled = !mAlarmEnabled; 427 mAlarmEnabled = !mAlarmEnabled;
428 mParent->updated(); 428 mParent->updated();
429} 429}
430 430
431void Alarm::setEnabled(bool enable) 431void Alarm::setEnabled(bool enable)
432{ 432{
433 mAlarmEnabled = enable; 433 mAlarmEnabled = enable;
434 mParent->updated(); 434 mParent->updated();
435} 435}
436 436
437bool Alarm::enabled() const 437bool Alarm::enabled() const
438{ 438{
439 return mAlarmEnabled; 439 return mAlarmEnabled;
440} 440}
441 441
442void Alarm::setStartOffset( const Duration &offset ) 442void Alarm::setStartOffset( const Duration &offset )
443{ 443{
444 mOffset = offset; 444 mOffset = offset;
445 mEndOffset = false; 445 mEndOffset = false;
446 mHasTime = false; 446 mHasTime = false;
447 mParent->updated(); 447 mParent->updated();
448} 448}
449 449
450Duration Alarm::startOffset() const 450Duration Alarm::startOffset() const
451{ 451{
452 return (mHasTime || mEndOffset) ? 0 : mOffset; 452 return (mHasTime || mEndOffset) ? 0 : mOffset;
453} 453}
454 454
455bool Alarm::hasStartOffset() const 455bool Alarm::hasStartOffset() const
456{ 456{
457 return !mHasTime && !mEndOffset; 457 return !mHasTime && !mEndOffset;
458} 458}
459 459
460bool Alarm::hasEndOffset() const 460bool Alarm::hasEndOffset() const
461{ 461{
462 return !mHasTime && mEndOffset; 462 return !mHasTime && mEndOffset;
463} 463}
464 464
465void Alarm::setEndOffset( const Duration &offset ) 465void Alarm::setEndOffset( const Duration &offset )
466{ 466{
467 mOffset = offset; 467 mOffset = offset;
468 mEndOffset = true; 468 mEndOffset = true;
469 mHasTime = false; 469 mHasTime = false;
470 mParent->updated(); 470 mParent->updated();
471} 471}
472 472
473Duration Alarm::endOffset() const 473Duration Alarm::endOffset() const
474{ 474{
475 return (mHasTime || !mEndOffset) ? 0 : mOffset; 475 return (mHasTime || !mEndOffset) ? 0 : mOffset;
476} 476}
477 477
478void Alarm::setParent( Incidence *parent ) 478void Alarm::setParent( Incidence *parent )
479{ 479{
480 mParent = parent; 480 mParent = parent;
481} 481}
diff --git a/libkcal/kincidenceformatter.cpp b/libkcal/kincidenceformatter.cpp
index 8ae5b46..7d61b7f 100644
--- a/libkcal/kincidenceformatter.cpp
+++ b/libkcal/kincidenceformatter.cpp
@@ -94,329 +94,329 @@ void KIncidenceFormatter::setEvent(Event *event)
94 mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") 94 mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>")
95 .arg(event->dtStartTimeStr()) 95 .arg(event->dtStartTimeStr())
96 .arg(event->dtEndTimeStr())); 96 .arg(event->dtEndTimeStr()));
97 mText.append(i18n("<p><b>On:</b> %1</p> ") 97 mText.append(i18n("<p><b>On:</b> %1</p> ")
98 .arg(event->dtStartDateStr( shortDate ))); 98 .arg(event->dtStartDateStr( shortDate )));
99 } 99 }
100 } 100 }
101 if (!event->location().isEmpty()) { 101 if (!event->location().isEmpty()) {
102 addTag("b",i18n("Location: ")); 102 addTag("b",i18n("Location: "));
103 mText.append(deTag(event->location())+"<br>"); 103 mText.append(deTag(event->location())+"<br>");
104 } 104 }
105 105
106 if (event->recurrence()->doesRecur()) { 106 if (event->recurrence()->doesRecur()) {
107 107
108 QString recurText = event->recurrence()->recurrenceText(); 108 QString recurText = event->recurrence()->recurrenceText();
109 addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); 109 addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>");
110 110
111 bool ok; 111 bool ok;
112 QDate start = QDate::currentDate(); 112 QDate start = QDate::currentDate();
113 QDateTime next; 113 QDateTime next;
114 next = event->getNextOccurence( QDateTime::currentDateTime() , &ok ); 114 next = event->getNextOccurence( QDateTime::currentDateTime() , &ok );
115 if ( ok ) { 115 if ( ok ) {
116 addTag("p",i18n("<b>Next recurrence is on:</b>") ); 116 addTag("p",i18n("<b>Next recurrence is on:</b>") );
117 addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate )); 117 addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate ));
118 118
119 } else { 119 } else {
120 bool last; 120 bool last;
121 QDate nextd; 121 QDate nextd;
122 nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last ); 122 nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last );
123 if ( last ) { 123 if ( last ) {
124 addTag("p",i18n("<b>Last recurrence was on:</b>") ); 124 addTag("p",i18n("<b>Last recurrence was on:</b>") );
125 addTag("p", KGlobal::locale()->formatDate( nextd, shortDate )); 125 addTag("p", KGlobal::locale()->formatDate( nextd, shortDate ));
126 } 126 }
127 } 127 }
128 } 128 }
129 129
130 130
131 if (event->isAlarmEnabled()) { 131 if (event->isAlarmEnabled()) {
132 Alarm *alarm =event->alarms().first() ; 132 Alarm *alarm =event->alarms().first() ;
133 QDateTime t = alarm->time(); 133 QDateTime t = alarm->time();
134 QString s =i18n("( %1 before )").arg( alarm->offsetText() ); 134 QString s =i18n("( %1 before )").arg( alarm->offsetText() );
135 addTag("p",i18n("<b>Alarm on: </b>") + s + ": "+KGlobal::locale()->formatDateTime( t, shortDate )); 135 addTag("p",i18n("<b>Alarm on: </b>") + s + ": "+KGlobal::locale()->formatDateTime( t, shortDate ));
136 //addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); 136 //addTag("p", KGlobal::locale()->formatDateTime( t, shortDate ));
137 //addTag("p",s); 137 //addTag("p",s);
138 } 138 }
139 139
140 140
141 141
142 addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); 142 addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() );
143 // mText.append(event->secrecyStr()+"<br>"); 143 // mText.append(event->secrecyStr()+"<br>");
144 formatCategories(event); 144 formatCategories(event);
145 145
146 formatReadOnly(event); 146 formatReadOnly(event);
147 formatAttendees(event); 147 formatAttendees(event);
148 148
149 if ( mCreated ) { 149 if ( mCreated ) {
150#ifdef DESKTOP_VERSION 150#ifdef DESKTOP_VERSION
151 addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate )); 151 addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate ));
152#else 152#else
153 addTag("p",i18n("<b>Created: ") +" </b>"); 153 addTag("p",i18n("<b>Created: ") +" </b>");
154 addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); 154 addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate ));
155#endif 155#endif
156 156
157 } 157 }
158 if ( mModified ) { 158 if ( mModified ) {
159#ifdef DESKTOP_VERSION 159#ifdef DESKTOP_VERSION
160 addTag("p",i18n("<b>Last modified: ") +" </b>"+KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); 160 addTag("p",i18n("<b>Last modified: ") +" </b>"+KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ));
161#else 161#else
162 addTag("p",i18n("<b>Last modified: ") +" </b>"); 162 addTag("p",i18n("<b>Last modified: ") +" </b>");
163 addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); 163 addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ));
164#endif 164#endif
165 165
166 } 166 }
167 if ( mDetails ) { 167 if ( mDetails ) {
168 if (!event->description().isEmpty()) { 168 if (!event->description().isEmpty()) {
169 addTag("p",i18n("<b>Details: </b>")); 169 addTag("p",i18n("<b>Details: </b>"));
170 addTag("p",deTag(event->description())); 170 addTag("p",deTag(event->description()));
171 } 171 }
172 } 172 }
173 173
174} 174}
175 175
176void KIncidenceFormatter::setTodo(Todo *event ) 176void KIncidenceFormatter::setTodo(Todo *event )
177{ 177{
178 int mode = 0; 178 int mode = 0;
179 mCurrentIncidence = event; 179 mCurrentIncidence = event;
180 bool shortDate = true; 180 bool shortDate = true;
181 if (mode == 0 ) 181 if (mode == 0 )
182 addTag("h3",deTag(event->summary())); 182 addTag("h3",deTag(event->summary()));
183 else { 183 else {
184 if ( mColorMode == 1 ) { 184 if ( mColorMode == 1 ) {
185 mText +="<font color=\"#00A000\">"; 185 mText +="<font color=\"#00A000\">";
186 } 186 }
187 if ( mColorMode == 2 ) { 187 if ( mColorMode == 2 ) {
188 mText +="<font color=\"#B00000\">"; 188 mText +="<font color=\"#B00000\">";
189 } 189 }
190 if ( mode == 1 ) { 190 if ( mode == 1 ) {
191 addTag("h2",i18n( "Local: " ) +deTag(event->summary())); 191 addTag("h2",i18n( "Local: " ) +deTag(event->summary()));
192 } else { 192 } else {
193 addTag("h2",i18n( "Remote: " ) +deTag(event->summary())); 193 addTag("h2",i18n( "Remote: " ) +deTag(event->summary()));
194 } 194 }
195 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); 195 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
196 if ( mColorMode ) 196 if ( mColorMode )
197 mText += "</font>"; 197 mText += "</font>";
198 } 198 }
199 if ( event->percentComplete() == 100 && event->hasCompletedDate() ) { 199 if ( event->percentComplete() == 100 && event->hasCompletedDate() ) {
200 mText +="<font color=\"#B00000\">"; 200 mText +="<font color=\"#B00000\">";
201 addTag("i", i18n("<p><i>Completed on %1</i></p>").arg( event->completedStr(shortDate) ) ); 201 addTag("i", i18n("<p><i>Completed on %1</i></p>").arg( event->completedStr(shortDate) ) );
202 mText += "</font>"; 202 mText += "</font>";
203 } else { 203 } else {
204 mText.append(i18n("<p><i>%1 % completed</i></p>") 204 mText.append(i18n("<p><i>%1 % completed</i></p>")
205 .arg(event->percentComplete())); 205 .arg(event->percentComplete()));
206 } 206 }
207 if (event->cancelled ()) { 207 if (event->cancelled ()) {
208 mText +="<font color=\"#B00000\">"; 208 mText +="<font color=\"#B00000\">";
209 addTag("i",i18n("This todo has been cancelled!")); 209 addTag("i",i18n("This todo has been cancelled!"));
210 mText.append("<br>"); 210 mText.append("<br>");
211 mText += "</font>"; 211 mText += "</font>";
212 } 212 }
213 213
214 214
215 if (event->recurrence()->doesRecur()) { 215 if (event->recurrence()->doesRecur()) {
216 216
217 QString recurText = event->recurrence()->recurrenceText(); 217 QString recurText = event->recurrence()->recurrenceText();
218 addTag("p","<em>" + i18n("This is a %1 recurring todo.").arg(recurText ) + "</em>"); 218 addTag("p","<em>" + i18n("This is a %1 recurring todo.").arg(recurText ) + "</em>");
219 } 219 }
220 220
221 if (event->hasStartDate()) { 221 if (event->hasStartDate()) {
222 mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(shortDate))); 222 mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(shortDate)));
223 } 223 }
224 224
225 225
226 if (event->hasDueDate()) { 226 if (event->hasDueDate()) {
227 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(shortDate))); 227 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(shortDate)));
228 } 228 }
229 229
230 if (!event->location().isEmpty()) { 230 if (!event->location().isEmpty()) {
231 addTag("b",i18n("Location: ")); 231 addTag("b",i18n("Location: "));
232 mText.append(deTag(event->location())+"<br>"); 232 mText.append(deTag(event->location())+"<br>");
233 } 233 }
234 234
235 mText.append(i18n("<p><b>Priority:</b> %2</p>") 235 mText.append(i18n("<p><b>Priority:</b> %2</p>")
236 .arg(QString::number(event->priority()))); 236 .arg(QString::number(event->priority())));
237 237
238 if (event->isAlarmEnabled()) { 238 if (event->isAlarmEnabled()) {
239 Alarm *alarm =event->alarms().first() ; 239 Alarm *alarm =event->alarms().first() ;
240 QDateTime t = alarm->time(); 240 QDateTime t = alarm->time();
241 QString s =i18n("( %1 before )").arg( alarm->offsetText() ); 241 QString s =i18n("( %1 before )").arg( alarm->offsetText() );
242 addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); 242 addTag("p",i18n("<b>Alarm on: ") + s +" </b>");
243 addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); 243 addTag("p", KGlobal::locale()->formatDateTime( t, shortDate ));
244 //addTag("p",s); 244 //addTag("p",s);
245 } 245 }
246 246
247 addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); 247 addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() );
248 formatCategories(event); 248 formatCategories(event);
249 249
250 formatReadOnly(event); 250 formatReadOnly(event);
251 formatAttendees(event); 251 formatAttendees(event);
252 if ( mCreated ) { 252 if ( mCreated ) {
253#ifdef DESKTOP_VERSION 253#ifdef DESKTOP_VERSION
254 addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate )); 254 addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate ));
255#else 255#else
256 addTag("p",i18n("<b>Created: ") +" </b>"); 256 addTag("p",i18n("<b>Created: ") +" </b>");
257 addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); 257 addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate ));
258#endif 258#endif
259 259
260 } 260 }
261 if ( mModified ) { 261 if ( mModified ) {
262#ifdef DESKTOP_VERSION 262#ifdef DESKTOP_VERSION
263 addTag("p",i18n("<b>Last modified: ") +" </b>"+KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); 263 addTag("p",i18n("<b>Last modified: ") +" </b>"+KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ));
264#else 264#else
265 addTag("p",i18n("<b>Last modified: ") +" </b>"); 265 addTag("p",i18n("<b>Last modified: ") +" </b>");
266 addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); 266 addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ));
267#endif 267#endif
268 268
269 } 269 }
270 if ( mDetails ) { 270 if ( mDetails ) {
271 if (!event->description().isEmpty()) { 271 if (!event->description().isEmpty()) {
272 addTag("p",i18n("<b>Details: </b>")); 272 addTag("p",i18n("<b>Details: </b>"));
273 addTag("p",deTag(event->description())); 273 addTag("p",deTag(event->description()));
274 } 274 }
275 } 275 }
276} 276}
277 277
278void KIncidenceFormatter::setJournal(Journal* ) 278void KIncidenceFormatter::setJournal(Journal* )
279{ 279{
280 280
281} 281}
282 282
283void KIncidenceFormatter::formatCategories(Incidence *event) 283void KIncidenceFormatter::formatCategories(Incidence *event)
284{ 284{
285 if (!event->categoriesStr().isEmpty()) { 285 if (!event->categoriesStr().isEmpty()) {
286 addTag("p",i18n("<b>Categories: </b>")+event->categoriesStr() ); 286 addTag("p",i18n("<b>Categories: </b>")+event->categoriesStrWithSpace() );
287 //mText.append(event->categoriesStr()); 287 //mText.append(event->categoriesStr());
288 } 288 }
289} 289}
290void KIncidenceFormatter::addTag(const QString & tag,const QString & text) 290void KIncidenceFormatter::addTag(const QString & tag,const QString & text)
291{ 291{
292 int number=text.contains("\n"); 292 int number=text.contains("\n");
293 QString str = "<" + tag + ">"; 293 QString str = "<" + tag + ">";
294 QString tmpText=text; 294 QString tmpText=text;
295 QString tmpStr=str; 295 QString tmpStr=str;
296 if(number !=-1) 296 if(number !=-1)
297 { 297 {
298 if (number > 0) { 298 if (number > 0) {
299 int pos=0; 299 int pos=0;
300 QString tmp; 300 QString tmp;
301 for(int i=0;i<=number;i++) { 301 for(int i=0;i<=number;i++) {
302 pos=tmpText.find("\n"); 302 pos=tmpText.find("\n");
303 tmp=tmpText.left(pos); 303 tmp=tmpText.left(pos);
304 tmpText=tmpText.right(tmpText.length()-pos-1); 304 tmpText=tmpText.right(tmpText.length()-pos-1);
305 tmpStr+=tmp+"<br>"; 305 tmpStr+=tmp+"<br>";
306 } 306 }
307 } 307 }
308 else tmpStr += tmpText; 308 else tmpStr += tmpText;
309 tmpStr+="</" + tag + ">"; 309 tmpStr+="</" + tag + ">";
310 mText.append(tmpStr); 310 mText.append(tmpStr);
311 } 311 }
312 else 312 else
313 { 313 {
314 str += text + "</" + tag + ">"; 314 str += text + "</" + tag + ">";
315 mText.append(str); 315 mText.append(str);
316 } 316 }
317} 317}
318 318
319void KIncidenceFormatter::formatAttendees(Incidence *event) 319void KIncidenceFormatter::formatAttendees(Incidence *event)
320{ 320{
321 QPtrList<Attendee> attendees = event->attendees(); 321 QPtrList<Attendee> attendees = event->attendees();
322 if (attendees.count()) { 322 if (attendees.count()) {
323 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); 323 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small);
324 QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); 324 QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small);
325 addTag("h3",i18n("Organizer")); 325 addTag("h3",i18n("Organizer"));
326 mText.append("<ul><li>"); 326 mText.append("<ul><li>");
327#if 0 327#if 0
328 //ndef KORG_NOKABC 328 //ndef KORG_NOKABC
329 329
330 KABC::AddressBook *add_book = KABC::StdAddressBook::self(); 330 KABC::AddressBook *add_book = KABC::StdAddressBook::self();
331 KABC::Addressee::List addressList; 331 KABC::Addressee::List addressList;
332 addressList = add_book->findByEmail(event->organizer()); 332 addressList = add_book->findByEmail(event->organizer());
333 KABC::Addressee o = addressList.first(); 333 KABC::Addressee o = addressList.first();
334 if (!o.isEmpty() && addressList.size()<2) { 334 if (!o.isEmpty() && addressList.size()<2) {
335 mText += "<a href=\"uid:" + o.uid() + "\">"; 335 mText += "<a href=\"uid:" + o.uid() + "\">";
336 mText += o.formattedName(); 336 mText += o.formattedName();
337 mText += "</a>\n"; 337 mText += "</a>\n";
338 } else { 338 } else {
339 mText.append(event->organizer()); 339 mText.append(event->organizer());
340 } 340 }
341#else 341#else
342 mText.append(event->organizer()); 342 mText.append(event->organizer());
343#endif 343#endif
344 if (iconPath) { 344 if (iconPath) {
345 mText += " <a href=\"mailto:" + event->organizer() + "\">"; 345 mText += " <a href=\"mailto:" + event->organizer() + "\">";
346 mText += "<IMG src=\"" + iconPath + "\">"; 346 mText += "<IMG src=\"" + iconPath + "\">";
347 mText += "</a>\n"; 347 mText += "</a>\n";
348 } 348 }
349 mText.append("</li></ul>"); 349 mText.append("</li></ul>");
350 350
351 addTag("h3",i18n("Attendees")); 351 addTag("h3",i18n("Attendees"));
352 Attendee *a; 352 Attendee *a;
353 mText.append("<ul>"); 353 mText.append("<ul>");
354 for(a=attendees.first();a;a=attendees.next()) { 354 for(a=attendees.first();a;a=attendees.next()) {
355#if 0 355#if 0
356//ndef KORG_NOKABC 356//ndef KORG_NOKABC
357 if (a->name().isEmpty()) { 357 if (a->name().isEmpty()) {
358 addressList = add_book->findByEmail(a->email()); 358 addressList = add_book->findByEmail(a->email());
359 KABC::Addressee o = addressList.first(); 359 KABC::Addressee o = addressList.first();
360 if (!o.isEmpty() && addressList.size()<2) { 360 if (!o.isEmpty() && addressList.size()<2) {
361 mText += "<a href=\"uid:" + o.uid() + "\">"; 361 mText += "<a href=\"uid:" + o.uid() + "\">";
362 mText += o.formattedName(); 362 mText += o.formattedName();
363 mText += "</a>\n"; 363 mText += "</a>\n";
364 } else { 364 } else {
365 mText += "<li>"; 365 mText += "<li>";
366 mText.append(a->email()); 366 mText.append(a->email());
367 mText += "\n"; 367 mText += "\n";
368 } 368 }
369 } else { 369 } else {
370 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 370 mText += "<li><a href=\"uid:" + a->uid() + "\">";
371 if (!a->name().isEmpty()) mText += a->name(); 371 if (!a->name().isEmpty()) mText += a->name();
372 else mText += a->email(); 372 else mText += a->email();
373 mText += "</a>\n"; 373 mText += "</a>\n";
374 } 374 }
375#else 375#else
376 //qDebug("nokabc "); 376 //qDebug("nokabc ");
377 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 377 mText += "<li><a href=\"uid:" + a->uid() + "\">";
378 if (!a->name().isEmpty()) mText += a->name(); 378 if (!a->name().isEmpty()) mText += a->name();
379 else mText += a->email(); 379 else mText += a->email();
380 mText += "</a>\n"; 380 mText += "</a>\n";
381#endif 381#endif
382 382
383 if (!a->email().isEmpty()) { 383 if (!a->email().isEmpty()) {
384 if (iconPath) { 384 if (iconPath) {
385 mText += "<a href=\"mailto:" + a->name() +" "+ "<" + a->email() + ">" + "\">"; 385 mText += "<a href=\"mailto:" + a->name() +" "+ "<" + a->email() + ">" + "\">";
386 if ( a->RSVP() ) 386 if ( a->RSVP() )
387 mText += "<IMG src=\"" + iconPath + "\">"; 387 mText += "<IMG src=\"" + iconPath + "\">";
388 else 388 else
389 mText += "<IMG src=\"" + NOiconPath + "\">"; 389 mText += "<IMG src=\"" + NOiconPath + "\">";
390 mText += "</a>\n"; 390 mText += "</a>\n";
391 } 391 }
392 } 392 }
393 if (a->status() != Attendee::NeedsAction ) 393 if (a->status() != Attendee::NeedsAction )
394 mText +="[" + a->statusStr() + "] "; 394 mText +="[" + a->statusStr() + "] ";
395 if (a->role() == Attendee::Chair ) 395 if (a->role() == Attendee::Chair )
396 mText +="(" + a->roleStr().left(1) + ".)"; 396 mText +="(" + a->roleStr().left(1) + ".)";
397 } 397 }
398 mText.append("</li></ul>"); 398 mText.append("</li></ul>");
399 } 399 }
400} 400}
401 401
402void KIncidenceFormatter::formatReadOnly(Incidence *event) 402void KIncidenceFormatter::formatReadOnly(Incidence *event)
403{ 403{
404 if (event->isReadOnly()) { 404 if (event->isReadOnly()) {
405 addTag("p","<em>(" + i18n("read-only") + ")</em>"); 405 addTag("p","<em>(" + i18n("read-only") + ")</em>");
406 } 406 }
407} 407}
408QString KIncidenceFormatter::deTag(QString text) 408QString KIncidenceFormatter::deTag(QString text)
409{ 409{
410#if QT_VERSION >= 0x030000 410#if QT_VERSION >= 0x030000
411 text.replace( '<' , "&lt;" ); 411 text.replace( '<' , "&lt;" );
412 text.replace( '>' , "&gt;" ); 412 text.replace( '>' , "&gt;" );
413#else 413#else
414 if ( text.find ('<') >= 0 ) { 414 if ( text.find ('<') >= 0 ) {
415 text.replace( QRegExp("<") , "&lt;" ); 415 text.replace( QRegExp("<") , "&lt;" );
416 } 416 }
417 if ( text.find ('>') >= 0 ) { 417 if ( text.find ('>') >= 0 ) {
418 text.replace( QRegExp(">") , "&gt;" ); 418 text.replace( QRegExp(">") , "&gt;" );
419 } 419 }
420#endif 420#endif
421 return text; 421 return text;
422} 422}