summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-04-17 17:29:12 (UTC)
committer zautrix <zautrix>2005-04-17 17:29:12 (UTC)
commite3e76014e70643b0828f30f5c5277e212495d37c (patch) (unidiff)
tree6c1b65d08bbecf7f5d83db636cebe3425b1521e8
parent70b45fe97813c4fd336b7ca8fdedab13f9c2e039 (diff)
downloadkdepimpi-e3e76014e70643b0828f30f5c5277e212495d37c.zip
kdepimpi-e3e76014e70643b0828f30f5c5277e212495d37c.tar.gz
kdepimpi-e3e76014e70643b0828f30f5c5277e212495d37c.tar.bz2
fixes
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,1257 +1,1260 @@
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 );
360} 362}
361void KOListView::setAlarm() 363void KOListView::setAlarm()
362{ 364{
363 KOAlarmPrefs kap( this); 365 KOAlarmPrefs kap( this);
364 if ( !kap.exec() ) 366 if ( !kap.exec() )
365 return; 367 return;
366 368
367 369
368 QStringList itemList; 370 QStringList itemList;
369 QPtrList<KOListViewItem> sel ; 371 QPtrList<KOListViewItem> sel ;
370 QListViewItem *qitem = mListView->firstChild (); 372 QListViewItem *qitem = mListView->firstChild ();
371 while ( qitem ) { 373 while ( qitem ) {
372 if ( qitem->isSelected() ) { 374 if ( qitem->isSelected() ) {
373 Incidence* inc = ((KOListViewItem *) qitem)->data(); 375 Incidence* inc = ((KOListViewItem *) qitem)->data();
374 if ( inc->type() != "Journal" ) { 376 if ( inc->type() != "Journal" ) {
375 if ( inc->type() == "Todo" ) { 377 if ( inc->type() == "Todo" ) {
376 if ( ((Todo*)inc)->hasDueDate() ) 378 if ( ((Todo*)inc)->hasDueDate() )
377 sel.append(((KOListViewItem *)qitem)); 379 sel.append(((KOListViewItem *)qitem));
378 } else 380 } else
379 sel.append(((KOListViewItem *)qitem)); 381 sel.append(((KOListViewItem *)qitem));
380 } 382 }
381 } 383 }
382 qitem = qitem->nextSibling(); 384 qitem = qitem->nextSibling();
383 } 385 }
384 int count = 0; 386 int count = 0;
385 KOListViewItem * item, *temp; 387 KOListViewItem * item, *temp;
386 item = sel.first(); 388 item = sel.first();
387 Incidence* inc; 389 Incidence* inc;
388 while ( item ) { 390 while ( item ) {
389 inc = item->data(); 391 inc = item->data();
390 ++count; 392 ++count;
391 if (kap.mAlarmButton->isChecked()) { 393 if (kap.mAlarmButton->isChecked()) {
392 if (inc->alarms().count() == 0) 394 if (inc->alarms().count() == 0)
393 inc->newAlarm(); 395 inc->newAlarm();
394 QPtrList<Alarm> alarms = inc->alarms(); 396 QPtrList<Alarm> alarms = inc->alarms();
395 Alarm *alarm; 397 Alarm *alarm;
396 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { 398 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) {
397 alarm->setEnabled(true); 399 alarm->setEnabled(true);
398 int j = kap.mAlarmTimeEdit->value()* -60; 400 int j = kap.mAlarmTimeEdit->value()* -60;
399 if (kap.mAlarmIncrCombo->currentItem() == 1) 401 if (kap.mAlarmIncrCombo->currentItem() == 1)
400 j = j * 60; 402 j = j * 60;
401 else if (kap.mAlarmIncrCombo->currentItem() == 2) 403 else if (kap.mAlarmIncrCombo->currentItem() == 2)
402 j = j * (60 * 24); 404 j = j * (60 * 24);
403 alarm->setStartOffset( j ); 405 alarm->setStartOffset( j );
404 406
405 if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) { 407 if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) {
406 alarm->setProcedureAlarm(kap.mAlarmProgram); 408 alarm->setProcedureAlarm(kap.mAlarmProgram);
407 } 409 }
408 else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn()) 410 else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn())
409 alarm->setAudioAlarm(kap.mAlarmSound); 411 alarm->setAudioAlarm(kap.mAlarmSound);
410 else 412 else
411 alarm->setType(Alarm::Invalid); 413 alarm->setType(Alarm::Invalid);
412 //alarm->setAudioAlarm("default"); 414 //alarm->setAudioAlarm("default");
413 // TODO: Deal with multiple alarms 415 // TODO: Deal with multiple alarms
414 break; // For now, stop after the first alarm 416 break; // For now, stop after the first alarm
415 } 417 }
416 } else { 418 } else {
417 Alarm* alarm = inc->alarms().first(); 419 Alarm* alarm = inc->alarms().first();
418 if ( alarm ) { 420 if ( alarm ) {
419 alarm->setEnabled(false); 421 alarm->setEnabled(false);
420 alarm->setType(Alarm::Invalid); 422 alarm->setType(Alarm::Invalid);
421 } 423 }
422 } 424 }
423 temp = item; 425 temp = item;
424 item = sel.next(); 426 item = sel.next();
425 mUidDict.remove( inc->uid() ); 427 mUidDict.remove( inc->uid() );
426 delete temp;; 428 delete temp;;
427 addIncidence( inc ); 429 addIncidence( inc );
428 } 430 }
429 topLevelWidget()->setCaption( i18n("Canged alarm for %1 items").arg( count ) ); 431 topLevelWidget()->setCaption( i18n("Canged alarm for %1 items").arg( count ) );
430 qDebug("KO: Set alarm for %d items", count); 432 qDebug("KO: Set alarm for %d items", count);
431 calendar()->reInitAlarmSettings(); 433 calendar()->reInitAlarmSettings();
432 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); 434 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
433} 435}
434void KOListView::setCategories( bool removeOld ) 436void KOListView::setCategories( bool removeOld )
435{ 437{
436 438
437 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); 439 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 );
438 if (! csd->exec()) { 440 if (! csd->exec()) {
439 delete csd; 441 delete csd;
440 return; 442 return;
441 } 443 }
442 QStringList catList = csd->selectedCategories(); 444 QStringList catList = csd->selectedCategories();
443 delete csd; 445 delete csd;
444 // if ( catList.count() == 0 ) 446 // if ( catList.count() == 0 )
445 // return; 447 // return;
446 catList.sort(); 448 catList.sort();
447 QString categoriesStr = catList.join(","); 449 QString categoriesStr = catList.join(",");
448 int i; 450 int i;
449 QStringList itemList; 451 QStringList itemList;
450 QPtrList<KOListViewItem> sel ; 452 QPtrList<KOListViewItem> sel ;
451 QListViewItem *qitem = mListView->firstChild (); 453 QListViewItem *qitem = mListView->firstChild ();
452 while ( qitem ) { 454 while ( qitem ) {
453 if ( qitem->isSelected() ) { 455 if ( qitem->isSelected() ) {
454 sel.append(((KOListViewItem *)qitem)); 456 sel.append(((KOListViewItem *)qitem));
455 } 457 }
456 qitem = qitem->nextSibling(); 458 qitem = qitem->nextSibling();
457 } 459 }
458 KOListViewItem * item, *temp; 460 KOListViewItem * item, *temp;
459 item = sel.first(); 461 item = sel.first();
460 Incidence* inc; 462 Incidence* inc;
461 while ( item ) { 463 while ( item ) {
462 inc = item->data(); 464 inc = item->data();
463 if ( removeOld ) { 465 if ( removeOld ) {
464 inc->setCategories( categoriesStr ); 466 inc->setCategories( categoriesStr );
465 } else { 467 } else {
466 itemList = QStringList::split (",", inc->categoriesStr() ); 468 itemList = QStringList::split (",", inc->categoriesStr() );
467 for( i = 0; i< catList.count(); ++i ) { 469 for( i = 0; i< catList.count(); ++i ) {
468 if ( !itemList.contains (catList[i])) 470 if ( !itemList.contains (catList[i]))
469 itemList.append( catList[i] ); 471 itemList.append( catList[i] );
470 } 472 }
471 itemList.sort(); 473 itemList.sort();
472 inc->setCategories( itemList.join(",") ); 474 inc->setCategories( itemList.join(",") );
473 } 475 }
474 temp = item; 476 temp = item;
475 item = sel.next(); 477 item = sel.next();
476 mUidDict.remove( inc->uid() ); 478 mUidDict.remove( inc->uid() );
477 delete temp;; 479 delete temp;;
478 addIncidence( inc ); 480 addIncidence( inc );
479 } 481 }
480 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); 482 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
481} 483}
482 484
483void KOListView::beamSelected() 485void KOListView::beamSelected()
484{ 486{
485 int icount = 0; 487 int icount = 0;
486 QPtrList<Incidence> delSel ; 488 QPtrList<Incidence> delSel ;
487 QListViewItem *item = mListView->firstChild (); 489 QListViewItem *item = mListView->firstChild ();
488 while ( item ) { 490 while ( item ) {
489 if ( item->isSelected() ) { 491 if ( item->isSelected() ) {
490 delSel.append(((KOListViewItem *)item)->data()); 492 delSel.append(((KOListViewItem *)item)->data());
491 ++icount; 493 ++icount;
492 } 494 }
493 495
494 item = item->nextSibling(); 496 item = item->nextSibling();
495 } 497 }
496 if ( icount ) { 498 if ( icount ) {
497 emit beamIncidenceList( delSel ); 499 emit beamIncidenceList( delSel );
498 return; 500 return;
499 QString fn ; 501 QString fn ;
500 fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs"; 502 fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs";
501 QString mes; 503 QString mes;
502 bool createbup = true; 504 bool createbup = true;
503 if ( createbup ) { 505 if ( createbup ) {
504 QString description = "\n"; 506 QString description = "\n";
505 CalendarLocal* cal = new CalendarLocal(); 507 CalendarLocal* cal = new CalendarLocal();
506 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 508 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
507 Incidence *incidence = delSel.first(); 509 Incidence *incidence = delSel.first();
508 while ( incidence ) { 510 while ( incidence ) {
509 Incidence *in = incidence->clone(); 511 Incidence *in = incidence->clone();
510 description += in->summary() + "\n"; 512 description += in->summary() + "\n";
511 cal->addIncidence( in ); 513 cal->addIncidence( in );
512 incidence = delSel.next(); 514 incidence = delSel.next();
513 } 515 }
514 FileStorage storage( cal, fn, new VCalFormat ); 516 FileStorage storage( cal, fn, new VCalFormat );
515 storage.save(); 517 storage.save();
516 delete cal; 518 delete cal;
517 mes = i18n("KO/Pi: Ready for beaming"); 519 mes = i18n("KO/Pi: Ready for beaming");
518 topLevelWidget()->setCaption(mes); 520 topLevelWidget()->setCaption(mes);
519 521
520#ifndef DESKTOP_VERSION 522#ifndef DESKTOP_VERSION
521 Ir *ir = new Ir( this ); 523 Ir *ir = new Ir( this );
522 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 524 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
523 ir->send( fn, description, "text/x-vCalendar" ); 525 ir->send( fn, description, "text/x-vCalendar" );
524#endif 526#endif
525 } 527 }
526 } 528 }
527} 529}
528void KOListView::beamDone( Ir *ir ) 530void KOListView::beamDone( Ir *ir )
529{ 531{
530#ifndef DESKTOP_VERSION 532#ifndef DESKTOP_VERSION
531 delete ir; 533 delete ir;
532#endif 534#endif
533 topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done")); 535 topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done"));
534} 536}
535 537
536void KOListView::saveDescriptionToFile() 538void KOListView::saveDescriptionToFile()
537{ 539{
538 540
539 int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), 541 int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"),
540 i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), 542 i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."),
541 i18n("Continue"), i18n("Cancel"), 0, 543 i18n("Continue"), i18n("Cancel"), 0,
542 0, 1 ); 544 0, 1 );
543 if ( result != 0 ) { 545 if ( result != 0 ) {
544 return; 546 return;
545 } 547 }
546 int icount = 0; 548 int icount = 0;
547 QPtrList<Incidence> delSel ; 549 QPtrList<Incidence> delSel ;
548 QListViewItem *item = mListView->firstChild (); 550 QListViewItem *item = mListView->firstChild ();
549 while ( item ) { 551 while ( item ) {
550 if ( item->isSelected() ) { 552 if ( item->isSelected() ) {
551 delSel.append(((KOListViewItem *)item)->data()); 553 delSel.append(((KOListViewItem *)item)->data());
552 ++icount; 554 ++icount;
553 } 555 }
554 556
555 item = item->nextSibling(); 557 item = item->nextSibling();
556 } 558 }
557 if ( icount ) { 559 if ( icount ) {
558 QString fn = KOPrefs::instance()->mLastSaveFile; 560 QString fn = KOPrefs::instance()->mLastSaveFile;
559 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); 561 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this );
560 562
561 if ( fn == "" ) 563 if ( fn == "" )
562 return; 564 return;
563 QFileInfo info; 565 QFileInfo info;
564 info.setFile( fn ); 566 info.setFile( fn );
565 QString mes; 567 QString mes;
566 bool createbup = true; 568 bool createbup = true;
567 if ( info. exists() ) { 569 if ( info. exists() ) {
568 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 570 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
569 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 571 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
570 i18n("Overwrite!"), i18n("Cancel"), 0, 572 i18n("Overwrite!"), i18n("Cancel"), 0,
571 0, 1 ); 573 0, 1 );
572 if ( result != 0 ) { 574 if ( result != 0 ) {
573 createbup = false; 575 createbup = false;
574 } 576 }
575 } 577 }
576 if ( createbup ) { 578 if ( createbup ) {
577 QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") + 579 QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") +
578 KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false); 580 KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false);
579 Incidence *incidence = delSel.first(); 581 Incidence *incidence = delSel.first();
580 icount = 0; 582 icount = 0;
581 while ( incidence ) { 583 while ( incidence ) {
582 if ( incidence->type() == "Journal" ) { 584 if ( incidence->type() == "Journal" ) {
583 text += "\n************************************\n"; 585 text += "\n************************************\n";
584 text += i18n("Journal from: ") +incidence->dtStartDateStr( false ); 586 text += i18n("Journal from: ") +incidence->dtStartDateStr( false );
585 text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); 587 text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false);
586 text +="\n" + i18n("Description: ") + "\n"+ incidence->description(); 588 text +="\n" + i18n("Description: ") + "\n"+ incidence->description();
587 ++icount; 589 ++icount;
588 590
589 } else { 591 } else {
590 if ( !incidence->description().isEmpty() ) { 592 if ( !incidence->description().isEmpty() ) {
591 text += "\n************************************\n"; 593 text += "\n************************************\n";
592 if ( incidence->type() == "Todo" ) 594 if ( incidence->type() == "Todo" )
593 text += i18n("To-Do: "); 595 text += i18n("To-Do: ");
594 text += incidence->summary(); 596 text += incidence->summary();
595 if ( incidence->hasStartDate() ) 597 if ( incidence->hasStartDate() )
596 text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false ); 598 text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false );
597 text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); 599 text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false);
598 if ( !incidence->location().isEmpty() ) 600 if ( !incidence->location().isEmpty() )
599 text += "\n" +i18n("Location: ") + incidence->location(); 601 text += "\n" +i18n("Location: ") + incidence->location();
600 text += "\n" + i18n("Description: ") + "\n" + incidence->description(); 602 text += "\n" + i18n("Description: ") + "\n" + incidence->description();
601 ++icount; 603 ++icount;
602 604
603 } 605 }
604 } 606 }
605 incidence = delSel.next(); 607 incidence = delSel.next();
606 } 608 }
607 QFile file( fn ); 609 QFile file( fn );
608 if (!file.open( IO_WriteOnly ) ) { 610 if (!file.open( IO_WriteOnly ) ) {
609 topLevelWidget()->setCaption(i18n("File open error - nothing saved!") ); 611 topLevelWidget()->setCaption(i18n("File open error - nothing saved!") );
610 return; 612 return;
611 } 613 }
612 QTextStream ts( &file ); 614 QTextStream ts( &file );
613 ts << text; 615 ts << text;
614 file.close(); 616 file.close();
615 //qDebug("%s ", text.latin1()); 617 //qDebug("%s ", text.latin1());
616 mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount ); 618 mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount );
617 KOPrefs::instance()->mLastSaveFile = fn; 619 KOPrefs::instance()->mLastSaveFile = fn;
618 topLevelWidget()->setCaption(mes); 620 topLevelWidget()->setCaption(mes);
619 } 621 }
620 } 622 }
621} 623}
622void KOListView::saveToFileVCS() 624void KOListView::saveToFileVCS()
623{ 625{
624 writeToFile( false ); 626 writeToFile( false );
625} 627}
626void KOListView::saveToFile() 628void KOListView::saveToFile()
627{ 629{
628 writeToFile( true ); 630 writeToFile( true );
629} 631}
630void KOListView::writeToFile( bool iCal ) 632void KOListView::writeToFile( bool iCal )
631{ 633{
632 634
633 int icount = 0; 635 int icount = 0;
634 QPtrList<Incidence> delSel ; 636 QPtrList<Incidence> delSel ;
635 QListViewItem *item = mListView->firstChild (); 637 QListViewItem *item = mListView->firstChild ();
636 bool journal = iCal; // warn only for vCal 638 bool journal = iCal; // warn only for vCal
637 while ( item ) { 639 while ( item ) {
638 if ( item->isSelected() ) { 640 if ( item->isSelected() ) {
639 if ( !journal ) 641 if ( !journal )
640 if ( ((KOListViewItem *)item)->data()->type() == "Journal") 642 if ( ((KOListViewItem *)item)->data()->type() == "Journal")
641 journal = true; 643 journal = true;
642 delSel.append(((KOListViewItem *)item)->data()); 644 delSel.append(((KOListViewItem *)item)->data());
643 ++icount; 645 ++icount;
644 } 646 }
645 647
646 item = item->nextSibling(); 648 item = item->nextSibling();
647 } 649 }
648 if ( !iCal && journal ) { 650 if ( !iCal && journal ) {
649 int result = KMessageBox::warningContinueCancel(this, 651 int result = KMessageBox::warningContinueCancel(this,
650 i18n("The journal entries can not be\nexported to a vCalendar file."), 652 i18n("The journal entries can not be\nexported to a vCalendar file."),
651 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 653 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
652 true); 654 true);
653 if (result != KMessageBox::Continue) return; 655 if (result != KMessageBox::Continue) return;
654 } 656 }
655 if ( icount ) { 657 if ( icount ) {
656 QString fn = KOPrefs::instance()->mLastSaveFile; 658 QString fn = KOPrefs::instance()->mLastSaveFile;
657 QString extension; 659 QString extension;
658 if ( iCal ) { 660 if ( iCal ) {
659 if ( fn.right( 4 ).lower() == ".vcs" ) { 661 if ( fn.right( 4 ).lower() == ".vcs" ) {
660 fn = fn.left( fn.length() -3) + "ics"; 662 fn = fn.left( fn.length() -3) + "ics";
661 } 663 }
662 } else { 664 } else {
663 if ( fn.right( 4 ).lower() == ".ics" ) { 665 if ( fn.right( 4 ).lower() == ".ics" ) {
664 fn = fn.left( fn.length() -3) + "vcs"; 666 fn = fn.left( fn.length() -3) + "vcs";
665 } 667 }
666 } 668 }
667 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); 669 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this );
668 670
669 if ( fn == "" ) 671 if ( fn == "" )
670 return; 672 return;
671 QFileInfo info; 673 QFileInfo info;
672 info.setFile( fn ); 674 info.setFile( fn );
673 QString mes; 675 QString mes;
674 bool createbup = true; 676 bool createbup = true;
675 if ( info. exists() ) { 677 if ( info. exists() ) {
676 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 678 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
677 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 679 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
678 i18n("Overwrite!"), i18n("Cancel"), 0, 680 i18n("Overwrite!"), i18n("Cancel"), 0,
679 0, 1 ); 681 0, 1 );
680 if ( result != 0 ) { 682 if ( result != 0 ) {
681 createbup = false; 683 createbup = false;
682 } 684 }
683 } 685 }
684 if ( createbup ) { 686 if ( createbup ) {
685 CalendarLocal cal; 687 CalendarLocal cal;
686 cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 688 cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
687 Incidence *incidence = delSel.first(); 689 Incidence *incidence = delSel.first();
688 while ( incidence ) { 690 while ( incidence ) {
689 cal.addIncidence( incidence->clone() ); 691 cal.addIncidence( incidence->clone() );
690 incidence = delSel.next(); 692 incidence = delSel.next();
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;
1117 while ( jump && cn->itemAbove ()) { 1120 while ( jump && cn->itemAbove ()) {
1118 cn = cn->itemAbove (); 1121 cn = cn->itemAbove ();
1119 --jump; 1122 --jump;
1120 } 1123 }
1121 setCurrentItem ( cn ); 1124 setCurrentItem ( cn );
1122 ensureItemVisible ( cn ); 1125 ensureItemVisible ( cn );
1123 } else 1126 } else
1124 QListView::keyPressEvent ( e ) ; 1127 QListView::keyPressEvent ( e ) ;
1125 e->accept(); 1128 e->accept();
1126 break; 1129 break;
1127 case Qt::Key_I: { 1130 case Qt::Key_I: {
1128 QListViewItem* cn; 1131 QListViewItem* cn;
1129 cn = currentItem(); 1132 cn = currentItem();
1130 if ( cn ) { 1133 if ( cn ) {
1131 KOListViewItem* ci = (KOListViewItem*)( cn ); 1134 KOListViewItem* ci = (KOListViewItem*)( cn );
1132 if ( ci ){ 1135 if ( ci ){
1133 //emit showIncidence( ci->data()); 1136 //emit showIncidence( ci->data());
1134 cn = cn->nextSibling(); 1137 cn = cn->nextSibling();
1135 if ( cn ) { 1138 if ( cn ) {
1136 setCurrentItem ( cn ); 1139 setCurrentItem ( cn );
1137 ensureItemVisible ( cn ); 1140 ensureItemVisible ( cn );
1138 } 1141 }
1139 emit showIncidence( ci->data()); 1142 emit showIncidence( ci->data());
1140 } 1143 }
1141 } 1144 }
1142 e->accept(); 1145 e->accept();
1143 } 1146 }
1144 break; 1147 break;
1145 case Qt::Key_Return: 1148 case Qt::Key_Return:
1146 case Qt::Key_Enter: 1149 case Qt::Key_Enter:
1147 { 1150 {
1148 QListViewItem* cn; 1151 QListViewItem* cn;
1149 cn = currentItem(); 1152 cn = currentItem();
1150 if ( cn ) { 1153 if ( cn ) {
1151 KOListViewItem* ci = (KOListViewItem*)( cn ); 1154 KOListViewItem* ci = (KOListViewItem*)( cn );
1152 if ( ci ){ 1155 if ( ci ){
1153 if ( e->state() == ShiftButton ) 1156 if ( e->state() == ShiftButton )
1154 ci->setSelected( false ); 1157 ci->setSelected( false );
1155 else 1158 else
1156 ci->setSelected( true ); 1159 ci->setSelected( true );
1157 cn = cn->nextSibling(); 1160 cn = cn->nextSibling();
1158 if ( cn ) { 1161 if ( cn ) {
1159 setCurrentItem ( cn ); 1162 setCurrentItem ( cn );
1160 ensureItemVisible ( cn ); 1163 ensureItemVisible ( cn );
1161 } 1164 }
1162 } 1165 }
1163 } 1166 }
1164 e->accept(); 1167 e->accept();
1165 } 1168 }
1166 break; 1169 break;
1167 default: 1170 default:
1168 e->ignore(); 1171 e->ignore();
1169 } 1172 }
1170} 1173}
1171KOListViewListView::KOListViewListView(KOListView * lv ) 1174KOListViewListView::KOListViewListView(KOListView * lv )
1172 : KListView( lv, "kolistlistview", false ) 1175 : KListView( lv, "kolistlistview", false )
1173{ 1176{
1174 mPopupTimer = new QTimer(this); 1177 mPopupTimer = new QTimer(this);
1175 connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); 1178 connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu()));
1176#ifndef DESKTOP_VERSION 1179#ifndef DESKTOP_VERSION
1177 //QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); 1180 //QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold );
1178#endif 1181#endif
1179 setSelectionMode( QListView::Multi ); 1182 setSelectionMode( QListView::Multi );
1180 setMultiSelection( true); 1183 setMultiSelection( true);
1181} 1184}
1182void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e) 1185void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e)
1183{ 1186{
1184 if (!e) return; 1187 if (!e) return;
1185 QPoint vp = contentsToViewport(e->pos()); 1188 QPoint vp = contentsToViewport(e->pos());
1186 QListViewItem *item = itemAt(vp); 1189 QListViewItem *item = itemAt(vp);
1187 if (!item) { 1190 if (!item) {
1188 emit newEvent(); 1191 emit newEvent();
1189 return; 1192 return;
1190 } 1193 }
1191 KListView::contentsMouseDoubleClickEvent(e); 1194 KListView::contentsMouseDoubleClickEvent(e);
1192} 1195}
1193#if 0 1196#if 0
1194void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) 1197void KOListViewListView::contentsMousePressEvent(QMouseEvent *e)
1195{ 1198{
1196 //qDebug("contentsMousePressEvent++++ "); 1199 //qDebug("contentsMousePressEvent++++ ");
1197 KListView::contentsMousePressEvent( e ); 1200 KListView::contentsMousePressEvent( e );
1198 if ( e->button() == RightButton ) { 1201 if ( e->button() == RightButton ) {
1199 QListViewItem* ci = currentItem(); 1202 QListViewItem* ci = currentItem();
1200 clearSelection () ; 1203 clearSelection () ;
1201 if ( ci ) 1204 if ( ci )
1202 ci->setSelected( true ); 1205 ci->setSelected( true );
1203 } 1206 }
1204} 1207}
1205void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) 1208void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e)
1206{ 1209{
1207 KListView::contentsMouseReleaseEvent(e); 1210 KListView::contentsMouseReleaseEvent(e);
1208} 1211}
1209void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) 1212void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e)
1210{ 1213{
1211 KListView::contentsMouseMoveEvent(e); 1214 KListView::contentsMouseMoveEvent(e);
1212} 1215}
1213#endif 1216#endif
1214void KOListViewListView::popupMenu() 1217void KOListViewListView::popupMenu()
1215{ 1218{
1216 mPopupTimer->stop(); 1219 mPopupTimer->stop();
1217 QMouseEvent* e = new QMouseEvent( QEvent::MouseButtonPress, mEventPos ,mEventGlobalPos, RightButton , RightButton ); 1220 QMouseEvent* e = new QMouseEvent( QEvent::MouseButtonPress, mEventPos ,mEventGlobalPos, RightButton , RightButton );
1218 QApplication::postEvent( this->viewport(), e ); 1221 QApplication::postEvent( this->viewport(), e );
1219 1222
1220} 1223}
1221void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) 1224void KOListViewListView::contentsMousePressEvent(QMouseEvent *e)
1222{ 1225{
1223 //qDebug("contentsMousePressEvent++++ %d %d", e->pos().y(), e->globalPos().y()); 1226 //qDebug("contentsMousePressEvent++++ %d %d", e->pos().y(), e->globalPos().y());
1224 mYMousePos = mapToGlobal( (e->pos())).y(); 1227 mYMousePos = mapToGlobal( (e->pos())).y();
1225 if ( e->button() == LeftButton ) { 1228 if ( e->button() == LeftButton ) {
1226 mPopupTimer->start( 600 ); 1229 mPopupTimer->start( 600 );
1227 mEventPos = contentsToViewport(e->pos()); 1230 mEventPos = contentsToViewport(e->pos());
1228 mEventGlobalPos = e->globalPos(); 1231 mEventGlobalPos = e->globalPos();
1229 } 1232 }
1230 KListView::contentsMousePressEvent( e ); 1233 KListView::contentsMousePressEvent( e );
1231 if ( e->button() == RightButton ) { 1234 if ( e->button() == RightButton ) {
1232 QListViewItem* ci = currentItem(); 1235 QListViewItem* ci = currentItem();
1233 //clearSelection(); 1236 //clearSelection();
1234 if ( ci ) 1237 if ( ci )
1235 ci->setSelected( true ); 1238 ci->setSelected( true );
1236 } 1239 }
1237} 1240}
1238void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) 1241void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e)
1239{ 1242{
1240 mPopupTimer->stop(); 1243 mPopupTimer->stop();
1241 KListView::contentsMouseReleaseEvent(e); 1244 KListView::contentsMouseReleaseEvent(e);
1242} 1245}
1243void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) 1246void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e)
1244{ 1247{
1245 // qDebug("contentsMouseMoveEv....... "); 1248 // qDebug("contentsMouseMoveEv....... ");
1246 // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() ); 1249 // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() );
1247 int diff = mYMousePos - mapToGlobal( (e->pos())).y(); 1250 int diff = mYMousePos - mapToGlobal( (e->pos())).y();
1248 if ( diff < 0 ) diff = -diff; 1251 if ( diff < 0 ) diff = -diff;
1249 if ( diff > 15 ) 1252 if ( diff > 15 )
1250 mPopupTimer->stop(); 1253 mPopupTimer->stop();
1251 else { 1254 else {
1252 mEventPos = contentsToViewport(e->pos()); 1255 mEventPos = contentsToViewport(e->pos());
1253 mEventGlobalPos = e->globalPos(); 1256 mEventGlobalPos = e->globalPos();
1254 } 1257 }
1255 KListView::contentsMouseMoveEvent(e); 1258 KListView::contentsMouseMoveEvent(e);
1256} 1259}
1257 1260
diff --git a/korganizer/searchdialog.cpp b/korganizer/searchdialog.cpp
index de65b53..007d1f3 100644
--- a/korganizer/searchdialog.cpp
+++ b/korganizer/searchdialog.cpp
@@ -1,465 +1,462 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 1998 Preston Brown 3 Copyright (c) 1998 Preston Brown
4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24 24
25#include <qlayout.h> 25#include <qlayout.h>
26#include <qcheckbox.h> 26#include <qcheckbox.h>
27#include <qgroupbox.h> 27#include <qgroupbox.h>
28#include <qlabel.h> 28#include <qlabel.h>
29#include <qlistview.h> 29#include <qlistview.h>
30#include <qwhatsthis.h> 30#include <qwhatsthis.h>
31#include <qlineedit.h> 31#include <qlineedit.h>
32#include <qpushbutton.h> 32#include <qpushbutton.h>
33 33
34#include <klocale.h> 34#include <klocale.h>
35#include <kmessagebox.h> 35#include <kmessagebox.h>
36 36
37#include <libkdepim/kdateedit.h> 37#include <libkdepim/kdateedit.h>
38 38
39#include "koglobals.h" 39#include "koglobals.h"
40#include "koprefs.h" 40#include "koprefs.h"
41#include "klineedit.h" 41#include "klineedit.h"
42 42
43#include "calendarview.h" 43#include "calendarview.h"
44#include "koviewmanager.h" 44#include "koviewmanager.h"
45#include "searchdialog.h" 45#include "searchdialog.h"
46 46
47SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent) 47SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent)
48 : QVBox( 0 ) 48 : QVBox( 0 )
49 49
50{ 50{
51 mCalendar = calendar; 51 mCalendar = calendar;
52 QFrame *topFrame = new QFrame( this ) ;//plainPage(); 52 QFrame *topFrame = new QFrame( this ) ;//plainPage();
53 QVBoxLayout *layout = new QVBoxLayout(topFrame,KDialog::marginHint(),KDialog::spacingHint()); 53 QVBoxLayout *layout = new QVBoxLayout(topFrame,KDialog::marginHint(),KDialog::spacingHint());
54 54
55 // Search expression 55 // Search expression
56 QHBoxLayout *subLayout = new QHBoxLayout(); 56 QHBoxLayout *subLayout = new QHBoxLayout();
57 layout->addLayout(subLayout); 57 layout->addLayout(subLayout);
58 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
426 for(journ=journals.first();journ;journ=journals.next()) { 423 for(journ=journals.first();journ;journ=journals.next()) {
427 if ( journ->dtStart().date() <= mEndDate->date() 424 if ( journ->dtStart().date() <= mEndDate->date()
428 &&journ->dtStart().date() >= mStartDate->date()) { 425 &&journ->dtStart().date() >= mStartDate->date()) {
429#if QT_VERSION >= 0x030000 426#if QT_VERSION >= 0x030000
430 if (re.search(journ->description()) != -1) 427 if (re.search(journ->description()) != -1)
431#else 428#else
432 if (re.match(journ->description()) != -1) 429 if (re.match(journ->description()) != -1)
433#endif 430#endif
434 { 431 {
435 mMatchedJournals.append(journ); 432 mMatchedJournals.append(journ);
436 continue; 433 continue;
437 } 434 }
438 } 435 }
439 } 436 }
440 } 437 }
441 438
442} 439}
443 440
444void SearchDialog::keyPressEvent ( QKeyEvent *e) 441void SearchDialog::keyPressEvent ( QKeyEvent *e)
445{ 442{
446 switch ( e->key() ) { 443 switch ( e->key() ) {
447 case Qt::Key_Escape: 444 case Qt::Key_Escape:
448 close(); 445 close();
449 break; 446 break;
450 case Qt::Key_F: 447 case Qt::Key_F:
451 if ( e->state() == Qt::ControlButton ) { 448 if ( e->state() == Qt::ControlButton ) {
452 449
453 } 450 }
454 break; 451 break;
455 case Qt::Key_Return: 452 case Qt::Key_Return:
456 case Qt::Key_Enter: 453 case Qt::Key_Enter:
457 doSearch(); 454 doSearch();
458 break; 455 break;
459 456
460 default: 457 default:
461 e->ignore(); 458 e->ignore();
462 } 459 }
463} 460}
464 461
465//mMatchedJournals; 462//mMatchedJournals;
diff --git a/libkcal/alarm.cpp b/libkcal/alarm.cpp
index d8f15b5..6de1566 100644
--- a/libkcal/alarm.cpp
+++ b/libkcal/alarm.cpp
@@ -1,481 +1,481 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 1998 Preston Brown 3 Copyright (c) 1998 Preston Brown
4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library 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 GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22#include <kdebug.h> 22#include <kdebug.h>
23#include <klocale.h> 23#include <klocale.h>
24 24
25#include "incidence.h" 25#include "incidence.h"
26#include "todo.h" 26#include "todo.h"
27 27
28#include "alarm.h" 28#include "alarm.h"
29 29
30using namespace KCal; 30using namespace KCal;
31#include <qwidget.h> 31#include <qwidget.h>
32Alarm::Alarm(Incidence *parent) 32Alarm::Alarm(Incidence *parent)
33 : mParent(parent), 33 : mParent(parent),
34 mType(Audio), 34 mType(Audio),
35 mDescription(""), // to make operator==() not fail 35 mDescription(""), // to make operator==() not fail
36 mFile(""), // to make operator==() not fail 36 mFile(""), // to make operator==() not fail
37 mMailSubject(""), // to make operator==() not fail 37 mMailSubject(""), // to make operator==() not fail
38 mAlarmSnoozeTime(5), 38 mAlarmSnoozeTime(5),
39 mAlarmRepeatCount(0), 39 mAlarmRepeatCount(0),
40 mEndOffset(false), 40 mEndOffset(false),
41 mHasTime(false), 41 mHasTime(false),
42 mAlarmEnabled(false) 42 mAlarmEnabled(false)
43{ 43{
44 44
45} 45}
46 46
47Alarm::~Alarm() 47Alarm::~Alarm()
48{ 48{
49} 49}
50 50
51bool Alarm::operator==( const Alarm& rhs ) const 51bool Alarm::operator==( const Alarm& rhs ) const
52{ 52{
53 53
54 if ( mType != rhs.mType || 54 if ( mType != rhs.mType ||
55 mAlarmSnoozeTime != rhs.mAlarmSnoozeTime || 55 mAlarmSnoozeTime != rhs.mAlarmSnoozeTime ||
56 mAlarmRepeatCount != rhs.mAlarmRepeatCount || 56 mAlarmRepeatCount != rhs.mAlarmRepeatCount ||
57 mAlarmEnabled != rhs.mAlarmEnabled || 57 mAlarmEnabled != rhs.mAlarmEnabled ||
58 mHasTime != rhs.mHasTime) 58 mHasTime != rhs.mHasTime)
59 return false; 59 return false;
60 60
61#if 0 61#if 0
62 if ( mType != rhs.mType ) { 62 if ( mType != rhs.mType ) {
63 63
64 qDebug("aaa1 "); 64 qDebug("aaa1 ");
65 return false; 65 return false;
66 } 66 }
67 67
68 if ( mAlarmSnoozeTime != rhs.mAlarmSnoozeTime ) { 68 if ( mAlarmSnoozeTime != rhs.mAlarmSnoozeTime ) {
69 69
70 qDebug("aaa2 "); 70 qDebug("aaa2 ");
71 return false; 71 return false;
72 } 72 }
73 73
74 74
75 if ( mAlarmRepeatCount != rhs.mAlarmRepeatCount ) { 75 if ( mAlarmRepeatCount != rhs.mAlarmRepeatCount ) {
76 76
77 qDebug("aaa3 "); 77 qDebug("aaa3 ");
78 return false; 78 return false;
79 } 79 }
80 80
81 if ( mAlarmEnabled != rhs.mAlarmEnabled ) { 81 if ( mAlarmEnabled != rhs.mAlarmEnabled ) {
82 82
83 qDebug("aaa4 "); 83 qDebug("aaa4 ");
84 return false; 84 return false;
85 } 85 }
86 86
87 if ( mHasTime != rhs.mHasTime ) { 87 if ( mHasTime != rhs.mHasTime ) {
88 88
89 qDebug("aaa5 "); 89 qDebug("aaa5 ");
90 return false; 90 return false;
91 } 91 }
92#endif 92#endif
93 93
94 94
95 if (mHasTime) { 95 if (mHasTime) {
96 if (mAlarmTime != rhs.mAlarmTime) 96 if (mAlarmTime != rhs.mAlarmTime)
97 return false; 97 return false;
98 } else { 98 } else {
99 if (mOffset != rhs.mOffset || 99 if (mOffset != rhs.mOffset ||
100 mEndOffset != rhs.mEndOffset) 100 mEndOffset != rhs.mEndOffset)
101 return false; 101 return false;
102 } 102 }
103 switch (mType) { 103 switch (mType) {
104 case Display: 104 case Display:
105 return mDescription == rhs.mDescription; 105 return mDescription == rhs.mDescription;
106 106
107 case Email: 107 case Email:
108 return mDescription == rhs.mDescription && 108 return mDescription == rhs.mDescription &&
109 mMailAttachFiles == rhs.mMailAttachFiles && 109 mMailAttachFiles == rhs.mMailAttachFiles &&
110 mMailAddresses == rhs.mMailAddresses && 110 mMailAddresses == rhs.mMailAddresses &&
111 mMailSubject == rhs.mMailSubject; 111 mMailSubject == rhs.mMailSubject;
112 112
113 case Procedure: 113 case Procedure:
114 return mFile == rhs.mFile && 114 return mFile == rhs.mFile &&
115 mDescription == rhs.mDescription; 115 mDescription == rhs.mDescription;
116 116
117 case Audio: 117 case Audio:
118 return mFile == rhs.mFile; 118 return mFile == rhs.mFile;
119 119
120 case Invalid: 120 case Invalid:
121 break; 121 break;
122 } 122 }
123 return false; 123 return false;
124} 124}
125 125
126void Alarm::setType(Alarm::Type type) 126void Alarm::setType(Alarm::Type type)
127{ 127{
128 if (type == mType) 128 if (type == mType)
129 return; 129 return;
130 130
131 switch (type) { 131 switch (type) {
132 case Display: 132 case Display:
133 mDescription = ""; 133 mDescription = "";
134 break; 134 break;
135 case Procedure: 135 case Procedure:
136 mFile = mDescription = ""; 136 mFile = mDescription = "";
137 break; 137 break;
138 case Audio: 138 case Audio:
139 mFile = ""; 139 mFile = "";
140 break; 140 break;
141 case Email: 141 case Email:
142 mMailSubject = mDescription = ""; 142 mMailSubject = mDescription = "";
143 mMailAddresses.clear(); 143 mMailAddresses.clear();
144 mMailAttachFiles.clear(); 144 mMailAttachFiles.clear();
145 break; 145 break;
146 case Invalid: 146 case Invalid:
147 break; 147 break;
148 default: 148 default:
149 return; 149 return;
150 } 150 }
151 mType = type; 151 mType = type;
152 mParent->updated(); 152 mParent->updated();
153} 153}
154 154
155Alarm::Type Alarm::type() const 155Alarm::Type Alarm::type() const
156{ 156{
157 return mType; 157 return mType;
158} 158}
159 159
160void Alarm::setAudioAlarm(const QString &audioFile) 160void Alarm::setAudioAlarm(const QString &audioFile)
161{ 161{
162 mType = Audio; 162 mType = Audio;
163 mFile = audioFile; 163 mFile = audioFile;
164 mParent->updated(); 164 mParent->updated();
165} 165}
166 166
167void Alarm::setAudioFile(const QString &audioFile) 167void Alarm::setAudioFile(const QString &audioFile)
168{ 168{
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
@@ -1,422 +1,422 @@
1#include "kincidenceformatter.h" 1#include "kincidenceformatter.h"
2#include <kstaticdeleter.h> 2#include <kstaticdeleter.h>
3#include <kglobal.h> 3#include <kglobal.h>
4#include <klocale.h> 4#include <klocale.h>
5#ifdef DEKTOP_VERSION 5#ifdef DEKTOP_VERSION
6#include <kabc/stdaddressbook.h> 6#include <kabc/stdaddressbook.h>
7#define size count 7#define size count
8#endif 8#endif
9 9
10KIncidenceFormatter* KIncidenceFormatter::mInstance = 0; 10KIncidenceFormatter* KIncidenceFormatter::mInstance = 0;
11static KStaticDeleter<KIncidenceFormatter> insd; 11static KStaticDeleter<KIncidenceFormatter> insd;
12 12
13QString KIncidenceFormatter::getFormattedText( Incidence * inc, bool details, bool created , bool modified ) 13QString KIncidenceFormatter::getFormattedText( Incidence * inc, bool details, bool created , bool modified )
14{ 14{
15// #ifndef QT_NO_INPUTDIALOG 15// #ifndef QT_NO_INPUTDIALOG
16// return QInputDialog::getItem( caption, label, items, current, editable ); 16// return QInputDialog::getItem( caption, label, items, current, editable );
17// #else 17// #else
18// return QString::null; 18// return QString::null;
19// #endif 19// #endif
20 mDetails = details; 20 mDetails = details;
21 mCreated = created ; 21 mCreated = created ;
22 mModified = modified; 22 mModified = modified;
23 mText = ""; 23 mText = "";
24 if ( inc->type() == "Event" ) 24 if ( inc->type() == "Event" )
25 setEvent((Event *) inc ); 25 setEvent((Event *) inc );
26 else if ( inc->type() == "Todo" ) 26 else if ( inc->type() == "Todo" )
27 setTodo((Todo *) inc ); 27 setTodo((Todo *) inc );
28 return mText; 28 return mText;
29} 29}
30 30
31KIncidenceFormatter* KIncidenceFormatter::instance() 31KIncidenceFormatter* KIncidenceFormatter::instance()
32{ 32{
33 if (!mInstance) { 33 if (!mInstance) {
34 mInstance = insd.setObject(new KIncidenceFormatter()); 34 mInstance = insd.setObject(new KIncidenceFormatter());
35 } 35 }
36 return mInstance; 36 return mInstance;
37} 37}
38KIncidenceFormatter::~KIncidenceFormatter() 38KIncidenceFormatter::~KIncidenceFormatter()
39{ 39{
40 if (mInstance == this) 40 if (mInstance == this)
41 mInstance = insd.setObject(0); 41 mInstance = insd.setObject(0);
42 //qDebug("KIncidenceFormatter::~KIncidenceFormatter "); 42 //qDebug("KIncidenceFormatter::~KIncidenceFormatter ");
43} 43}
44KIncidenceFormatter::KIncidenceFormatter() 44KIncidenceFormatter::KIncidenceFormatter()
45{ 45{
46 mColorMode = 0; 46 mColorMode = 0;
47} 47}
48void KIncidenceFormatter::setEvent(Event *event) 48void KIncidenceFormatter::setEvent(Event *event)
49{ 49{
50 int mode = 0; 50 int mode = 0;
51 mCurrentIncidence = event; 51 mCurrentIncidence = event;
52 bool shortDate = true; 52 bool shortDate = true;
53 if ( mode == 0 ) { 53 if ( mode == 0 ) {
54 addTag("h3",deTag(event->summary())); 54 addTag("h3",deTag(event->summary()));
55 } 55 }
56 else { 56 else {
57 if ( mColorMode == 1 ) { 57 if ( mColorMode == 1 ) {
58 mText +="<font color=\"#00A000\">"; 58 mText +="<font color=\"#00A000\">";
59 } 59 }
60 if ( mColorMode == 2 ) { 60 if ( mColorMode == 2 ) {
61 mText +="<font color=\"#C00000\">"; 61 mText +="<font color=\"#C00000\">";
62 } 62 }
63 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; 63 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>";
64 if ( mode == 1 ) { 64 if ( mode == 1 ) {
65 addTag("h2",i18n( "Local: " ) +deTag(event->summary())); 65 addTag("h2",i18n( "Local: " ) +deTag(event->summary()));
66 } else { 66 } else {
67 addTag("h2",i18n( "Remote: " ) +deTag(event->summary())); 67 addTag("h2",i18n( "Remote: " ) +deTag(event->summary()));
68 } 68 }
69 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); 69 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
70 if ( mColorMode ) 70 if ( mColorMode )
71 mText += "</font>"; 71 mText += "</font>";
72 } 72 }
73 if (event->cancelled ()) { 73 if (event->cancelled ()) {
74 mText +="<font color=\"#B00000\">"; 74 mText +="<font color=\"#B00000\">";
75 addTag("i",i18n("This event has been cancelled!")); 75 addTag("i",i18n("This event has been cancelled!"));
76 mText.append("<br>"); 76 mText.append("<br>");
77 mText += "</font>"; 77 mText += "</font>";
78 } 78 }
79 if (event->doesFloat()) { 79 if (event->doesFloat()) {
80 if (event->isMultiDay()) { 80 if (event->isMultiDay()) {
81 mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") 81 mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>")
82 .arg(event->dtStartDateStr(shortDate)) 82 .arg(event->dtStartDateStr(shortDate))
83 .arg(event->dtEndDateStr(shortDate))); 83 .arg(event->dtEndDateStr(shortDate)));
84 } else { 84 } else {
85 mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); 85 mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate )));
86 } 86 }
87 } else { 87 } else {
88 if (event->isMultiDay()) { 88 if (event->isMultiDay()) {
89 mText.append(i18n("<p><b>From:</b> %1</p> ") 89 mText.append(i18n("<p><b>From:</b> %1</p> ")
90 .arg(event->dtStartStr( shortDate))); 90 .arg(event->dtStartStr( shortDate)));
91 mText.append(i18n("<p><b>To:</b> %1</p>") 91 mText.append(i18n("<p><b>To:</b> %1</p>")
92 .arg(event->dtEndStr(shortDate))); 92 .arg(event->dtEndStr(shortDate)));
93 } else { 93 } else {
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}