summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kolistview.cpp21
-rw-r--r--korganizer/kotodoviewitem.cpp14
-rw-r--r--libkcal/incidence.cpp13
-rw-r--r--libkcal/incidence.h2
-rw-r--r--libkcal/incidencebase.cpp13
-rw-r--r--libkcal/incidencebase.h2
6 files changed, 40 insertions, 25 deletions
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp
index b236c2d..4fc1194 100644
--- a/korganizer/kolistview.cpp
+++ b/korganizer/kolistview.cpp
@@ -48,308 +48,301 @@
48#include <libkcal/icalformat.h> 48#include <libkcal/icalformat.h>
49#include <libkcal/vcalformat.h> 49#include <libkcal/vcalformat.h>
50#include <libkcal/recurrence.h> 50#include <libkcal/recurrence.h>
51#include <libkcal/filestorage.h> 51#include <libkcal/filestorage.h>
52#include <libkdepim/categoryselectdialog.h> 52#include <libkdepim/categoryselectdialog.h>
53#include <libkcal/kincidenceformatter.h> 53#include <libkcal/kincidenceformatter.h>
54#ifndef DESKTOP_VERSION 54#ifndef DESKTOP_VERSION
55#include <qpe/qpeapplication.h> 55#include <qpe/qpeapplication.h>
56#else 56#else
57#include <qapplication.h> 57#include <qapplication.h>
58#endif 58#endif
59 59
60#ifndef KORG_NOPRINTER 60#ifndef KORG_NOPRINTER
61#include "calprinter.h" 61#include "calprinter.h"
62#endif 62#endif
63#include "koglobals.h" 63#include "koglobals.h"
64#include "koprefs.h" 64#include "koprefs.h"
65#include "kfiledialog.h" 65#include "kfiledialog.h"
66 66
67#include "kolistview.h" 67#include "kolistview.h"
68#include "koeventviewer.h" 68#include "koeventviewer.h"
69 69
70extern QPixmap* sgListViewCompletedPix[6]; 70extern QPixmap* sgListViewCompletedPix[6];
71extern QPixmap* sgListViewJournalPix; 71extern QPixmap* sgListViewJournalPix;
72 72
73class KOListViewWhatsThis :public QWhatsThis 73class KOListViewWhatsThis :public QWhatsThis
74{ 74{
75public: 75public:
76 KOListViewWhatsThis( QWidget *wid, KOListView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; 76 KOListViewWhatsThis( QWidget *wid, KOListView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { };
77 77
78protected: 78protected:
79 virtual QString text( const QPoint& p) 79 virtual QString text( const QPoint& p)
80 { 80 {
81 return _view->getWhatsThisText(p) ; 81 return _view->getWhatsThisText(p) ;
82 } 82 }
83private: 83private:
84 QWidget* _wid; 84 QWidget* _wid;
85 KOListView * _view; 85 KOListView * _view;
86}; 86};
87 87
88 88
89ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date ) 89ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date )
90{ 90{
91 mItem = item; 91 mItem = item;
92 mDate = date; 92 mDate = date;
93} 93}
94 94
95ListItemVisitor::~ListItemVisitor() 95ListItemVisitor::~ListItemVisitor()
96{ 96{
97} 97}
98 98
99bool ListItemVisitor::visit(Event *e) 99bool ListItemVisitor::visit(Event *e)
100{ 100{
101 bool ok = false; 101 bool ok = false;
102 QString start, end; 102 QString start, end;
103 QDate ds, de; 103 QDate ds, de;
104 if ( e->doesRecur() ) { 104 if ( e->doesRecur() ) {
105 ds = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date(); 105 ds = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date();
106 if ( ok ) { 106 if ( ok ) {
107 int days = e->dtStart().date().daysTo(e->dtEnd().date() ); 107 int days = e->dtStart().date().daysTo(e->dtEnd().date() );
108 start = KGlobal::locale()->formatDate(ds,true); 108 start = KGlobal::locale()->formatDate(ds,true);
109 de = ds.addDays( days); 109 de = ds.addDays( days);
110 end = KGlobal::locale()->formatDate(de,true); 110 end = KGlobal::locale()->formatDate(de,true);
111 } 111 }
112 112
113 } 113 }
114 if ( ! ok ) { 114 if ( ! ok ) {
115 start =e->dtStartDateStr(); 115 start =e->dtStartDateStr();
116 end = e->dtEndDateStr(); 116 end = e->dtEndDateStr();
117 ds = e->dtStart().date(); 117 ds = e->dtStart().date();
118 de = e->dtEnd().date(); 118 de = e->dtEnd().date();
119 } 119 }
120 mItem->setText(0,e->summary()); 120 mItem->setText(0,e->summary());
121 mItem->setText(1,start); 121 mItem->setText(1,start);
122 if ( e->doesFloat() ) 122 if ( e->doesFloat() )
123 mItem->setText(2,"---"); 123 mItem->setText(2,"---");
124 else 124 else
125 mItem->setText(2,e->dtStartTimeStr()); 125 mItem->setText(2,e->dtStartTimeStr());
126 mItem->setText(3,end); 126 mItem->setText(3,end);
127 if ( e->doesFloat() ) 127 if ( e->doesFloat() )
128 mItem->setText(4,"---"); 128 mItem->setText(4,"---");
129 else 129 else
130 mItem->setText(4,e->dtEndTimeStr()); 130 mItem->setText(4,e->dtEndTimeStr());
131 mItem->setText(5, e->durationText()); 131 mItem->setText(5, e->durationText());
132 if ( e->isAlarmEnabled() ) { 132 if ( e->isAlarmEnabled() ) {
133 mItem->setText(6,e->alarms().first()->offsetText() ); 133 mItem->setText(6,e->alarms().first()->offsetText() );
134 } else { 134 } else {
135 mItem->setText(6, i18n("No")); 135 mItem->setText(6, i18n("No"));
136 } 136 }
137 mItem->setText(7, e->recurrenceText()); 137 mItem->setText(7, e->recurrenceText());
138 if( ! e->doesRecur() ) 138 if( ! e->doesRecur() )
139 mItem->setSortKey( 7, "-" ); 139 mItem->setSortKey( 7, "-" );
140 mItem->setText(8, e->cancelled() ? i18n("Yes") : i18n("No")); 140 mItem->setText(8, e->cancelled() ? i18n("Yes") : i18n("No"));
141 mItem->setText(9,e->categoriesStr()); 141 mItem->setText(9,e->categoriesStr());
142 mItem->setText(10, KOPrefs::instance()->calName( e->calID() )); 142 mItem->setText(10, KOPrefs::instance()->calName( e->calID() ));
143 mItem->setText(11, KGlobal::locale()->formatDateTime( e->lastModified(), true, true )); 143 mItem->setText(11, KGlobal::locale()->formatDateTime( e->lastModified(), true, true ));
144 mItem->setSortKey(11,e->lastModifiedSortKey());
144 145
145 QString key; 146 QString key;
146 QDate d = e->lastModified().date(); 147 QTime t;
147 QTime t = e->lastModified().time();
148 key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute(),t.second() );
149 mItem->setSortKey(12,key);
150 t = e->doesFloat() ? QTime(0,0) : e->dtStart().time(); 148 t = e->doesFloat() ? QTime(0,0) : e->dtStart().time();
151 key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute()); 149 key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute());
152 mItem->setSortKey(1,key); 150 mItem->setSortKey(1,key);
153 151
154 t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time(); 152 t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time();
155 key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute()); 153 key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute());
156 mItem->setSortKey(3,key); 154 mItem->setSortKey(3,key);
157 return true; 155 return true;
158} 156}
159 157
160bool ListItemVisitor::visit(Todo *t) 158bool ListItemVisitor::visit(Todo *t)
161{ 159{
162 mItem->setText(0,t->summary()); 160 mItem->setText(0,t->summary());
163 if ( t->isCompleted() ) { 161 if ( t->isCompleted() ) {
164 mItem->setSortKey(0,"99"+ t->summary().left(10)); 162 mItem->setSortKey(0,"99"+ t->summary().left(10));
165 } else 163 } else
166 mItem->setSortKey(0,QString::number( t->percentComplete()+1 )+ t->summary().left(10)); 164 mItem->setSortKey(0,QString::number( t->percentComplete()+1 )+ t->summary().left(10));
167 mItem->setPixmap( 0, *(sgListViewCompletedPix[t->percentComplete()/20])); 165 mItem->setPixmap( 0, *(sgListViewCompletedPix[t->percentComplete()/20]));
168 if (t->hasStartDate()) { 166 if (t->hasStartDate()) {
169 mItem->setText(1,t->dtStartDateStr()); 167 mItem->setText(1,t->dtStartDateStr());
170 if (t->doesFloat()) { 168 if (t->doesFloat()) {
171 mItem->setText(2,"---"); 169 mItem->setText(2,"---");
172 } else { 170 } else {
173 mItem->setText(2,t->dtStartTimeStr()); 171 mItem->setText(2,t->dtStartTimeStr());
174 } 172 }
175 } else { 173 } else {
176 mItem->setText(1,"---"); 174 mItem->setText(1,"---");
177 mItem->setText(2,"---"); 175 mItem->setText(2,"---");
178 } 176 }
179 if ( t->isAlarmEnabled() ) { 177 if ( t->isAlarmEnabled() ) {
180 mItem->setText(6,t->alarms().first()->offsetText() ); 178 mItem->setText(6,t->alarms().first()->offsetText() );
181 } else { 179 } else {
182 mItem->setText(6, i18n("No")); 180 mItem->setText(6, i18n("No"));
183 } 181 }
184 mItem->setText(7, t->recurrenceText()); 182 mItem->setText(7, t->recurrenceText());
185 if( ! t->doesRecur() ) 183 if( ! t->doesRecur() )
186 mItem->setSortKey( 7, "-" ); 184 mItem->setSortKey( 7, "-" );
187 if (t->hasDueDate()) { 185 if (t->hasDueDate()) {
188 mItem->setText(3,t->dtDueDateStr()); 186 mItem->setText(3,t->dtDueDateStr());
189 if (t->doesFloat()) { 187 if (t->doesFloat()) {
190 mItem->setText(4,"---"); 188 mItem->setText(4,"---");
191 } else { 189 } else {
192 mItem->setText(4,t->dtDueTimeStr()); 190 mItem->setText(4,t->dtDueTimeStr());
193 } 191 }
194 } else { 192 } else {
195 mItem->setText(3,"---"); 193 mItem->setText(3,"---");
196 mItem->setText(4,"---"); 194 mItem->setText(4,"---");
197 } 195 }
198 mItem->setText(5, t->durationText()); 196 mItem->setText(5, t->durationText());
199 mItem->setText(8, t->cancelled() ? i18n("Yes") : i18n("No")); 197 mItem->setText(8, t->cancelled() ? i18n("Yes") : i18n("No"));
200 mItem->setText(9,t->categoriesStr()); 198 mItem->setText(9,t->categoriesStr());
201 mItem->setText(10, KOPrefs::instance()->calName( t->calID() )); 199 mItem->setText(10, KOPrefs::instance()->calName( t->calID() ));
202 mItem->setText(11, KGlobal::locale()->formatDateTime( t->lastModified(), true, true )); 200 mItem->setText(11, KGlobal::locale()->formatDateTime( t->lastModified(), true, true ));
201 mItem->setSortKey(11,t->lastModifiedSortKey());
203 QString key; 202 QString key;
204 QDate d = t->lastModified().date(); 203 QDate d;
205 QTime tm = t->lastModified().time(); 204 QTime tm;
206 key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute(),tm.second() );
207 mItem->setSortKey(11,key);
208 if (t->hasDueDate()) { 205 if (t->hasDueDate()) {
209 d = t->dtDue().date(); 206 d = t->dtDue().date();
210 tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time(); 207 tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time();
211 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); 208 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute());
212 mItem->setSortKey(3,key); 209 mItem->setSortKey(3,key);
213 } 210 }
214 if ( t->hasStartDate() ) { 211 if ( t->hasStartDate() ) {
215 d = t->dtStart().date(); 212 d = t->dtStart().date();
216 tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time(); 213 tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time();
217 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); 214 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute());
218 mItem->setSortKey(1,key); 215 mItem->setSortKey(1,key);
219 } 216 }
220 return true; 217 return true;
221} 218}
222 219
223bool ListItemVisitor::visit(Journal * j) 220bool ListItemVisitor::visit(Journal * j)
224{ 221{
225 222
226 QString des; 223 QString des;
227 mItem->setPixmap( 0, *sgListViewJournalPix); 224 mItem->setPixmap( 0, *sgListViewJournalPix);
228 if ( !j->summary().isEmpty() ) { 225 if ( !j->summary().isEmpty() ) {
229 des = j->summary(); 226 des = j->summary();
230 } else { 227 } else {
231 des = j->description().left(30); 228 des = j->description().left(30);
232 des = des.simplifyWhiteSpace (); 229 des = des.simplifyWhiteSpace ();
233 des.replace (QRegExp ("\\n"),"" ); 230 des.replace (QRegExp ("\\n"),"" );
234 des.replace (QRegExp ("\\r"),"" ); 231 des.replace (QRegExp ("\\r"),"" );
235 } 232 }
236 mItem->setText(0,des.left(25)); 233 mItem->setText(0,des.left(25));
237 mItem->setSortKey(0,"0"+ des.left(25)); 234 mItem->setSortKey(0,"0"+ des.left(25));
238 mItem->setText(1,j->dtStartDateStr()); 235 mItem->setText(1,j->dtStartDateStr());
239 mItem->setText(2,"---"); 236 mItem->setText(2,"---");
240 mItem->setText(3,"---"); 237 mItem->setText(3,"---");
241 mItem->setText(4,"---"); 238 mItem->setText(4,"---");
242 mItem->setText(5,"---"); 239 mItem->setText(5,"---");
243 mItem->setText(6,"---"); 240 mItem->setText(6,"---");
244 mItem->setText(7,"---"); 241 mItem->setText(7,"---");
245 mItem->setText(8,"---"); 242 mItem->setText(8,"---");
246 mItem->setText(9,j->categoriesStr()); 243 mItem->setText(9,j->categoriesStr());
247 mItem->setText(10, KOPrefs::instance()->calName( j->calID() )); 244 mItem->setText(10, KOPrefs::instance()->calName( j->calID() ));
248 mItem->setText(11, KGlobal::locale()->formatDateTime( j->lastModified(), true, true )); 245 mItem->setText(11, KGlobal::locale()->formatDateTime( j->lastModified(), true, true ));
246 mItem->setSortKey(11,j->lastModifiedSortKey());
249 247
250 QString key; 248 QString key;
251 QDate d = j->lastModified().date(); 249 QDate d;
252 QTime tm = j->lastModified().time();
253 key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute(),tm.second() );
254 mItem->setSortKey(12,key);
255 d = j->dtStart().date(); 250 d = j->dtStart().date();
256 key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 251 key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
257 mItem->setSortKey(1,key); 252 mItem->setSortKey(1,key);
258 mItem->setSortKey(7,key);
259
260 return true; 253 return true;
261} 254}
262 255
263KOListView::KOListView(Calendar *calendar, QWidget *parent, 256KOListView::KOListView(Calendar *calendar, QWidget *parent,
264 const char *name) 257 const char *name)
265 : KOEventView(calendar, parent, name) 258 : KOEventView(calendar, parent, name)
266{ 259{
267 260
268 mActiveItem = 0; 261 mActiveItem = 0;
269 mForceShowCompletedTodos = false; 262 mForceShowCompletedTodos = false;
270 mListView = new KOListViewListView(this); 263 mListView = new KOListViewListView(this);
271 mListView->addColumn(i18n("Summary")); 264 mListView->addColumn(i18n("Summary"));
272 mListView->addColumn(i18n("Start Date")); 265 mListView->addColumn(i18n("Start Date"));
273 mListView->addColumn(i18n("Start Time")); 266 mListView->addColumn(i18n("Start Time"));
274 mListView->addColumn(i18n("End/Due Date")); 267 mListView->addColumn(i18n("End/Due Date"));
275 mListView->addColumn(i18n("End/Due Time")); 268 mListView->addColumn(i18n("End/Due Time"));
276 mListView->addColumn(i18n("Duration")); 269 mListView->addColumn(i18n("Duration"));
277 mListView->addColumn(i18n("Alarm")); // alarm set? 270 mListView->addColumn(i18n("Alarm")); // alarm set?
278 mListView->addColumn(i18n("Recurs")); // recurs? 271 mListView->addColumn(i18n("Recurs")); // recurs?
279 mListView->addColumn(i18n("Cancelled")); 272 mListView->addColumn(i18n("Cancelled"));
280 mListView->addColumn(i18n("Categories")); 273 mListView->addColumn(i18n("Categories"));
281 mListView->addColumn(i18n("Calendar")); 274 mListView->addColumn(i18n("Calendar"));
282 mListView->addColumn(i18n("Last Modified")); 275 mListView->addColumn(i18n("Last Modified"));
283 276
284 mListView->setColumnAlignment(0,AlignLeft); 277 mListView->setColumnAlignment(0,AlignLeft);
285 mListView->setColumnAlignment(1,AlignLeft); 278 mListView->setColumnAlignment(1,AlignLeft);
286 mListView->setColumnAlignment(2,AlignHCenter); 279 mListView->setColumnAlignment(2,AlignHCenter);
287 mListView->setColumnAlignment(3,AlignLeft); 280 mListView->setColumnAlignment(3,AlignLeft);
288 mListView->setColumnAlignment(4,AlignHCenter); 281 mListView->setColumnAlignment(4,AlignHCenter);
289 mListView->setColumnAlignment(5,AlignLeft); 282 mListView->setColumnAlignment(5,AlignLeft);
290 mListView->setColumnAlignment(6,AlignLeft); 283 mListView->setColumnAlignment(6,AlignLeft);
291 mListView->setColumnAlignment(7,AlignLeft); 284 mListView->setColumnAlignment(7,AlignLeft);
292 mListView->setColumnAlignment(8,AlignLeft); 285 mListView->setColumnAlignment(8,AlignLeft);
293 mListView->setColumnAlignment(9,AlignLeft); 286 mListView->setColumnAlignment(9,AlignLeft);
294 mListView->setColumnAlignment(10,AlignLeft); 287 mListView->setColumnAlignment(10,AlignLeft);
295 mListView->setColumnAlignment(11,AlignLeft); 288 mListView->setColumnAlignment(11,AlignLeft);
296 mKOListViewWhatsThis = new KOListViewWhatsThis(mListView->viewport(),this); 289 mKOListViewWhatsThis = new KOListViewWhatsThis(mListView->viewport(),this);
297 290
298 int iii = 0; 291 int iii = 0;
299 for ( iii = 0; iii< 12 ; ++iii ) 292 for ( iii = 0; iii< 12 ; ++iii )
300 mListView->setColumnWidthMode( iii, QListView::Manual ); 293 mListView->setColumnWidthMode( iii, QListView::Manual );
301 294
302 QBoxLayout *layoutTop = new QVBoxLayout(this); 295 QBoxLayout *layoutTop = new QVBoxLayout(this);
303 layoutTop->addWidget(mListView); 296 layoutTop->addWidget(mListView);
304 mListView->setFont ( KOPrefs::instance()->mListViewFont ); 297 mListView->setFont ( KOPrefs::instance()->mListViewFont );
305 mPopupMenu = eventPopup(); 298 mPopupMenu = eventPopup();
306 QPopupMenu* selPopup = new QPopupMenu ( this ); 299 QPopupMenu* selPopup = new QPopupMenu ( this );
307 mPopupMenu->insertSeparator(); 300 mPopupMenu->insertSeparator();
308 301
309 selPopup->insertItem(i18n("All"),this, 302 selPopup->insertItem(i18n("All"),this,
310 SLOT(allSelection())); 303 SLOT(allSelection()));
311 selPopup->insertItem(i18n("None"),this, 304 selPopup->insertItem(i18n("None"),this,
312 SLOT(clearSelection())); 305 SLOT(clearSelection()));
313 selPopup->insertItem(i18n("Delete selected..."),this, 306 selPopup->insertItem(i18n("Delete selected..."),this,
314 SLOT(deleteAll())); 307 SLOT(deleteAll()));
315 mPopupMenu->insertItem(i18n("Selection"), selPopup ); 308 mPopupMenu->insertItem(i18n("Selection"), selPopup );
316 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 309 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
317 i18n("Hide all selected"),this, 310 i18n("Hide all selected"),this,
318 SLOT(hideAll()),true); 311 SLOT(hideAll()),true);
319 312
320 selPopup->insertSeparator(); 313 selPopup->insertSeparator();
321 QPopupMenu * exportPO = new QPopupMenu ( this ); 314 QPopupMenu * exportPO = new QPopupMenu ( this );
322 selPopup->insertItem( i18n("Export"), exportPO ); 315 selPopup->insertItem( i18n("Export"), exportPO );
323#ifdef DESKTOP_VERSION 316#ifdef DESKTOP_VERSION
324 mPopupMenu->insertSeparator(); 317 mPopupMenu->insertSeparator();
325 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 318 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
326 i18n("Print complete list..."),this, 319 i18n("Print complete list..."),this,
327 SLOT(printList()),true); 320 SLOT(printList()),true);
328#endif 321#endif
329 mCalPopup = new QPopupMenu ( this ); 322 mCalPopup = new QPopupMenu ( this );
330 selPopup->insertItem( i18n("Set Calendar"), mCalPopup ); 323 selPopup->insertItem( i18n("Set Calendar"), mCalPopup );
331 324
332 selPopup->insertItem(i18n("Set categories")+"...",this, 325 selPopup->insertItem(i18n("Set categories")+"...",this,
333 SLOT(setCat()) ); 326 SLOT(setCat()) );
334 selPopup->insertItem( i18n("Set alarm..."),this, 327 selPopup->insertItem( i18n("Set alarm..."),this,
335 SLOT(setAlarm())); 328 SLOT(setAlarm()));
336#if 0 329#if 0
337 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 330 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
338 i18n("Set categories")+"...",this, 331 i18n("Set categories")+"...",this,
339 SLOT(setCat()),true); 332 SLOT(setCat()),true);
340 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 333 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
341 i18n("Set alarm..."),this, 334 i18n("Set alarm..."),this,
342 SLOT(setAlarm()),true); 335 SLOT(setAlarm()),true);
343#endif 336#endif
344 QObject::connect(mCalPopup,SIGNAL(aboutToShow()),this, 337 QObject::connect(mCalPopup,SIGNAL(aboutToShow()),this,
345 SLOT( populateCalPopup() )); 338 SLOT( populateCalPopup() ));
346 QObject::connect(mCalPopup,SIGNAL(activated( int )),this, 339 QObject::connect(mCalPopup,SIGNAL(activated( int )),this,
347 SLOT( setCalendar( int ) )); 340 SLOT( setCalendar( int ) ));
348 QObject::connect(mPopupMenu,SIGNAL(categoryChanged( Incidence * )),this, 341 QObject::connect(mPopupMenu,SIGNAL(categoryChanged( Incidence * )),this,
349 SLOT( catChanged( Incidence * ) )); 342 SLOT( catChanged( Incidence * ) ));
350 exportPO->insertItem( i18n("As iCal (ics) file..."),this, 343 exportPO->insertItem( i18n("As iCal (ics) file..."),this,
351 SLOT(saveToFile())); 344 SLOT(saveToFile()));
352 exportPO->insertItem( i18n("As vCal (vcs) file..."),this, 345 exportPO->insertItem( i18n("As vCal (vcs) file..."),this,
353 SLOT(saveToFileVCS())); 346 SLOT(saveToFileVCS()));
354 exportPO->insertItem( i18n("Journal/Details..."),this, 347 exportPO->insertItem( i18n("Journal/Details..."),this,
355 SLOT(saveDescriptionToFile())); 348 SLOT(saveDescriptionToFile()));
diff --git a/korganizer/kotodoviewitem.cpp b/korganizer/kotodoviewitem.cpp
index bdef94c..848e9e7 100644
--- a/korganizer/kotodoviewitem.cpp
+++ b/korganizer/kotodoviewitem.cpp
@@ -26,245 +26,239 @@
26#include "kotodoviewitem.h" 26#include "kotodoviewitem.h"
27#include "kotodoview.h" 27#include "kotodoview.h"
28#include "koprefs.h" 28#include "koprefs.h"
29 29
30KOTodoViewItem::KOTodoViewItem( QListView *parent, Todo *todo, KOTodoView *kotodo) 30KOTodoViewItem::KOTodoViewItem( QListView *parent, Todo *todo, KOTodoView *kotodo)
31 : QCheckListItem( parent , "", CheckBox ), mTodo( todo ), mTodoView( kotodo ) 31 : QCheckListItem( parent , "", CheckBox ), mTodo( todo ), mTodoView( kotodo )
32{ 32{
33 construct(); 33 construct();
34} 34}
35 35
36KOTodoViewItem::KOTodoViewItem( KOTodoViewItem *parent, Todo *todo, KOTodoView *kotodo ) 36KOTodoViewItem::KOTodoViewItem( KOTodoViewItem *parent, Todo *todo, KOTodoView *kotodo )
37 : QCheckListItem( parent, "", CheckBox ), mTodo( todo ), mTodoView( kotodo ) 37 : QCheckListItem( parent, "", CheckBox ), mTodo( todo ), mTodoView( kotodo )
38{ 38{
39 construct(); 39 construct();
40} 40}
41 41
42QString KOTodoViewItem::key(int column,bool) const 42QString KOTodoViewItem::key(int column,bool) const
43{ 43{
44 QMap<int,QString>::ConstIterator it = mKeyMap.find(column); 44 QMap<int,QString>::ConstIterator it = mKeyMap.find(column);
45 if (it == mKeyMap.end()) { 45 if (it == mKeyMap.end()) {
46 return text(column).lower(); 46 return text(column).lower();
47 } else { 47 } else {
48 return *it; 48 return *it;
49 } 49 }
50} 50}
51 51
52void KOTodoViewItem:: setup() 52void KOTodoViewItem:: setup()
53{ 53{
54 54
55 int h = 20; 55 int h = 20;
56 if ( listView () ) { 56 if ( listView () ) {
57 QFontMetrics fm ( listView ()->font () ); 57 QFontMetrics fm ( listView ()->font () );
58 h = fm.height(); 58 h = fm.height();
59 } 59 }
60 setHeight( h ); 60 setHeight( h );
61 61
62} 62}
63void KOTodoViewItem::setSortKey(int column,const QString &key) 63void KOTodoViewItem::setSortKey(int column,const QString &key)
64{ 64{
65 mKeyMap.insert(column,key); 65 mKeyMap.insert(column,key);
66} 66}
67 67
68#if QT_VERSION >= 0x030000 68#if QT_VERSION >= 0x030000
69void KOTodoViewItem::paintBranches(QPainter *p,const QColorGroup & cg,int w, 69void KOTodoViewItem::paintBranches(QPainter *p,const QColorGroup & cg,int w,
70 int y,int h) 70 int y,int h)
71{ 71{
72 QListViewItem::paintBranches(p,cg,w,y,h); 72 QListViewItem::paintBranches(p,cg,w,y,h);
73} 73}
74#else 74#else
75#endif 75#endif
76 76
77void KOTodoViewItem::construct() 77void KOTodoViewItem::construct()
78{ 78{
79 // qDebug("KOTodoViewItem::construct() "); 79 // qDebug("KOTodoViewItem::construct() ");
80 m_init = true; 80 m_init = true;
81 QString keyd = "=="; 81 QString keyd = "==";
82 QString keyt = "=="; 82 QString keyt = "==";
83 QString skeyd = "=="; 83 QString skeyd = "==";
84 QString skeyt = "=="; 84 QString skeyt = "==";
85 85
86 setOn(mTodo->isCompleted()); 86 setOn(mTodo->isCompleted());
87 setText(0,mTodo->summary()); 87 setText(0,mTodo->summary());
88 setText(1,QString::number(mTodo->priority())); 88 setText(1,QString::number(mTodo->priority()));
89 setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); 89 setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete())));
90 if (mTodo->percentComplete()<100) { 90 if (mTodo->percentComplete()<100) {
91 if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); 91 if (mTodo->isCompleted()) setSortKey(2,QString::number(999));
92 else setSortKey(2,QString::number(mTodo->percentComplete())); 92 else setSortKey(2,QString::number(mTodo->percentComplete()));
93 } 93 }
94 else { 94 else {
95 if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); 95 if (mTodo->isCompleted()) setSortKey(2,QString::number(999));
96 else setSortKey(2,QString::number(99)); 96 else setSortKey(2,QString::number(99));
97 } 97 }
98 if (mTodo->hasDueDate()) { 98 if (mTodo->hasDueDate()) {
99 setText(3, mTodo->dtDueDateStr()); 99 setText(3, mTodo->dtDueDateStr());
100 QDate d = mTodo->dtDue().date(); 100 QDate d = mTodo->dtDue().date();
101 keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 101 keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
102 // setSortKey(3,keyd); 102 // setSortKey(3,keyd);
103 if (mTodo->doesFloat()) { 103 if (mTodo->doesFloat()) {
104 setText(4,""); 104 setText(4,"");
105 } 105 }
106 else { 106 else {
107 setText(4,mTodo->dtDueTimeStr()); 107 setText(4,mTodo->dtDueTimeStr());
108 QTime t = mTodo->dtDue().time(); 108 QTime t = mTodo->dtDue().time();
109 keyt.sprintf("%02d%02d",t.hour(),t.minute()); 109 keyt.sprintf("%02d%02d",t.hour(),t.minute());
110 //setSortKey(4,keyt); 110 //setSortKey(4,keyt);
111 } 111 }
112 } else { 112 } else {
113 setText(3,""); 113 setText(3,"");
114 setText(4,""); 114 setText(4,"");
115 } 115 }
116 setSortKey(3,keyd); 116 setSortKey(3,keyd);
117 setSortKey(4,keyt); 117 setSortKey(4,keyt);
118 118
119 if (mTodo->isCompleted()) setSortKey(1,"6" + QString::number(mTodo->priority())+keyd+keyt); 119 if (mTodo->isCompleted()) setSortKey(1,"6" + QString::number(mTodo->priority())+keyd+keyt);
120 else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); 120 else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt);
121 121
122
123
124 keyd = ""; 122 keyd = "";
125 keyt = ""; 123 keyt = "";
126 124
127 if (mTodo->isRunning() ) { 125 if (mTodo->isRunning() ) {
128 QDate d = mTodo->runStart().date(); 126 QDate d = mTodo->runStart().date();
129 QTime t = mTodo->runStart().time(); 127 QTime t = mTodo->runStart().time();
130 skeyt.sprintf("%02d%02d",t.hour(),t.minute()); 128 skeyt.sprintf("%02d%02d",t.hour(),t.minute());
131 skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 129 skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
132 keyd = KGlobal::locale()->formatDate( d , true); 130 keyd = KGlobal::locale()->formatDate( d , true);
133 keyt = KGlobal::locale()->formatTime( t ); 131 keyt = KGlobal::locale()->formatTime( t );
134 132
135 } else { 133 } else {
136 134
137 if (mTodo->hasStartDate()) { 135 if (mTodo->hasStartDate()) {
138 keyd = mTodo->dtStartDateStr(); 136 keyd = mTodo->dtStartDateStr();
139 QDate d = mTodo->dtStart().date(); 137 QDate d = mTodo->dtStart().date();
140 skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 138 skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
141 139
142 if ( !mTodo->doesFloat()) { 140 if ( !mTodo->doesFloat()) {
143 keyt = mTodo->dtStartTimeStr(); 141 keyt = mTodo->dtStartTimeStr();
144 QTime t = mTodo->dtStart().time(); 142 QTime t = mTodo->dtStart().time();
145 skeyt.sprintf("%02d%02d",t.hour(),t.minute()); 143 skeyt.sprintf("%02d%02d",t.hour(),t.minute());
146 144
147 } 145 }
148 146
149 } 147 }
150 } 148 }
151 setText(5,keyd); 149 setText(5,keyd);
152 setText(6,keyt); 150 setText(6,keyt);
153 setSortKey(5,skeyd); 151 setSortKey(5,skeyd);
154 setSortKey(6,skeyt); 152 setSortKey(6,skeyt);
155 153
156 //setText(7,mTodo->cancelled() ? i18n("Yes") : i18n("No")); 154 //setText(7,mTodo->cancelled() ? i18n("Yes") : i18n("No"));
157 setText(7,mTodo->categoriesStr()); 155 setText(7,mTodo->categoriesStr());
158 setText(8,KOPrefs::instance()->calName( mTodo->calID())); 156 setText(8,KOPrefs::instance()->calName( mTodo->calID()));
159 setText(9, KGlobal::locale()->formatDateTime( mTodo->lastModified(), true, true )); 157 setText(9, KGlobal::locale()->formatDateTime( mTodo->lastModified(), true, true ));
160 setText(10, KGlobal::locale()->formatDateTime( mTodo->created(), true, true )); 158 setText(10, KGlobal::locale()->formatDateTime( mTodo->created(), true, true ));
161 setText(11, KGlobal::locale()->formatDateTime( mTodo->lastModifiedSub(), true, true )); 159 setText(11, KGlobal::locale()->formatDateTime( mTodo->lastModifiedSub(), true, true ));
162 QString key; 160 QString key;
163 QDate d = mTodo->lastModified().date(); 161 QDate d;
164 QTime t = mTodo->lastModified().time(); 162 QTime t;
165 key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute(),t.second() ); 163 setSortKey(9,mTodo->lastModifiedSortKey());
166 setSortKey(9,key);
167 d = mTodo->created().date(); 164 d = mTodo->created().date();
168 t = mTodo->created().time(); 165 t = mTodo->created().time();
169 key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute(),t.second() ); 166 key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute(),t.second() );
170 setSortKey(10,key); 167 setSortKey(10,key);
171 d = mTodo->lastModifiedSub().date(); 168 setSortKey(11,mTodo->lastModifiedSubSortKey());
172 t = mTodo->lastModifiedSub().time();
173 key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute(),t.second() );
174 setSortKey(11,key);
175 169
176#if 0 170#if 0
177 // Find sort id in description. It's the text behind the last '#' character 171 // Find sort id in description. It's the text behind the last '#' character
178 // found in the description. White spaces are removed from beginning and end 172 // found in the description. White spaces are removed from beginning and end
179 // of sort id. 173 // of sort id.
180 int pos = mTodo->description().findRev('#'); 174 int pos = mTodo->description().findRev('#');
181 if (pos < 0) { 175 if (pos < 0) {
182 setText(6,""); 176 setText(6,"");
183 } else { 177 } else {
184 QString str = mTodo->description().mid(pos+1); 178 QString str = mTodo->description().mid(pos+1);
185 str.stripWhiteSpace(); 179 str.stripWhiteSpace();
186 setText(6,str); 180 setText(6,str);
187 } 181 }
188#endif 182#endif
189 183
190 m_known = false; 184 m_known = false;
191 m_init = false; 185 m_init = false;
192 186
193 setMyPixmap(); 187 setMyPixmap();
194 188
195} 189}
196void KOTodoViewItem::setMyPixmap() 190void KOTodoViewItem::setMyPixmap()
197{ 191{
198 int size = 5; 192 int size = 5;
199 QPixmap pixi = QPixmap( 1, 1 ); 193 QPixmap pixi = QPixmap( 1, 1 );
200 // if ( !mTodo->isCompleted() && mTodo->hasDueDate() && mTodo->dtDue() < QDateTime::currentDateTime() ) { 194 // if ( !mTodo->isCompleted() && mTodo->hasDueDate() && mTodo->dtDue() < QDateTime::currentDateTime() ) {
201// pixi = SmallIcon("redcross16"); 195// pixi = SmallIcon("redcross16");
202// } else { 196// } else {
203 QPainter p; 197 QPainter p;
204 198
205 int pixSize = 0; 199 int pixSize = 0;
206 QPixmap pPix = QPixmap( size, size ); 200 QPixmap pPix = QPixmap( size, size );
207 if ( mTodo->description().length() > 0 ) { 201 if ( mTodo->description().length() > 0 ) {
208 pixi.resize(size, pixSize+size); 202 pixi.resize(size, pixSize+size);
209 pPix.fill( Qt::darkGreen ); 203 pPix.fill( Qt::darkGreen );
210 p.begin( &pixi ); 204 p.begin( &pixi );
211 p. drawPixmap ( 0, pixSize, pPix); 205 p. drawPixmap ( 0, pixSize, pPix);
212 p.end(); 206 p.end();
213 pixSize += size; 207 pixSize += size;
214 } 208 }
215 if ( mTodo->isAlarmEnabled() && mTodo->alarmEnabled()) { 209 if ( mTodo->isAlarmEnabled() && mTodo->alarmEnabled()) {
216 pixi.resize(size, pixSize+size); 210 pixi.resize(size, pixSize+size);
217 pPix.fill( Qt::red ); 211 pPix.fill( Qt::red );
218 p.begin( &pixi ); 212 p.begin( &pixi );
219 p. drawPixmap ( 0, pixSize, pPix); 213 p. drawPixmap ( 0, pixSize, pPix);
220 p.end(); 214 p.end();
221 pixSize += size; 215 pixSize += size;
222 } 216 }
223 if ( mTodo->doesRecur() ) { 217 if ( mTodo->doesRecur() ) {
224 pixi.resize(size, pixSize+size); 218 pixi.resize(size, pixSize+size);
225 pPix.fill( Qt::blue ); 219 pPix.fill( Qt::blue );
226 p.begin( &pixi ); 220 p.begin( &pixi );
227 p. drawPixmap ( 0, pixSize, pPix); 221 p. drawPixmap ( 0, pixSize, pPix);
228 p.end(); 222 p.end();
229 pixSize += size; 223 pixSize += size;
230 } 224 }
231 // } 225 // }
232 if ( pixi.width() > 1 ) { 226 if ( pixi.width() > 1 ) {
233 setPixmap ( 0,pixi ) ; 227 setPixmap ( 0,pixi ) ;
234 } else { 228 } else {
235 setPixmap ( 0,QPixmap() ) ; 229 setPixmap ( 0,QPixmap() ) ;
236 } 230 }
237} 231}
238void KOTodoViewItem::stateChange(bool state) 232void KOTodoViewItem::stateChange(bool state)
239{ 233{
240 // qDebug("KOTodoViewItem::stateChange %d ", state); 234 // qDebug("KOTodoViewItem::stateChange %d ", state);
241 // do not change setting on startup 235 // do not change setting on startup
242 if ( m_init ) return; 236 if ( m_init ) return;
243 if (isOn()!=state) { 237 if (isOn()!=state) {
244 setOn(state); 238 setOn(state);
245 //qDebug("SETON "); 239 //qDebug("SETON ");
246 return; 240 return;
247 } 241 }
248 if ( mTodo->isCompleted() == state ) { 242 if ( mTodo->isCompleted() == state ) {
249 //qDebug("STATECHANGE:nothing to do "); 243 //qDebug("STATECHANGE:nothing to do ");
250 return; 244 return;
251 } 245 }
252 QString keyd = "=="; 246 QString keyd = "==";
253 QString keyt = "=="; 247 QString keyt = "==";
254 //qDebug("KOTodoViewItem::stateChange %s ", text(0).latin1()); 248 //qDebug("KOTodoViewItem::stateChange %s ", text(0).latin1());
255 if ( mTodo->doesRecur() ){ 249 if ( mTodo->doesRecur() ){
256 QDateTime start = mTodo->dtStart(); 250 QDateTime start = mTodo->dtStart();
257 mTodo->setCompleted(state); 251 mTodo->setCompleted(state);
258 if ( start != mTodo->dtStart() ) { 252 if ( start != mTodo->dtStart() ) {
259 if ( state && !mTodo->isCompleted() ) { 253 if ( state && !mTodo->isCompleted() ) {
260 setOn( false ); 254 setOn( false );
261 state = false; 255 state = false;
262 } 256 }
263 } 257 }
264 } else 258 } else
265 mTodo->setCompleted(state); 259 mTodo->setCompleted(state);
266 260
267 if (state) mTodo->setCompleted(QDateTime::currentDateTime()); 261 if (state) mTodo->setCompleted(QDateTime::currentDateTime());
268 262
269 if (mTodo->hasDueDate()) { 263 if (mTodo->hasDueDate()) {
270 setText(3, mTodo->dtDueDateStr()); 264 setText(3, mTodo->dtDueDateStr());
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp
index 39c14f5..fe9f854 100644
--- a/libkcal/incidence.cpp
+++ b/libkcal/incidence.cpp
@@ -249,205 +249,218 @@ bool KCal::operator==( const Incidence& i1, const Incidence& i2 )
249 return false; 249 return false;
250 } 250 }
251 if ( i1.mRecurrence != 0 && i2.mRecurrence != 0 ) { 251 if ( i1.mRecurrence != 0 && i2.mRecurrence != 0 ) {
252 if (!( *i1.mRecurrence == *i2.mRecurrence) ) { 252 if (!( *i1.mRecurrence == *i2.mRecurrence) ) {
253 //qDebug("recurrence is NOT equal "); 253 //qDebug("recurrence is NOT equal ");
254 return false; 254 return false;
255 } 255 }
256 } else { 256 } else {
257 // one ( or both ) recurrence is 0 257 // one ( or both ) recurrence is 0
258 if ( i1.mRecurrence == 0 ) { 258 if ( i1.mRecurrence == 0 ) {
259 if ( i2.mRecurrence != 0 && i2.mRecurrence->doesRecur() != Recurrence::rNone ) 259 if ( i2.mRecurrence != 0 && i2.mRecurrence->doesRecur() != Recurrence::rNone )
260 return false; 260 return false;
261 } else { 261 } else {
262 // i1.mRecurrence != 0 262 // i1.mRecurrence != 0
263 // i2.mRecurrence == 0 263 // i2.mRecurrence == 0
264 if ( i1.mRecurrence->doesRecur() != Recurrence::rNone ) 264 if ( i1.mRecurrence->doesRecur() != Recurrence::rNone )
265 return false; 265 return false;
266 } 266 }
267 } 267 }
268 268
269 return 269 return
270 // i1.created() == i2.created() && 270 // i1.created() == i2.created() &&
271 stringCompare( i1.description(), i2.description() ) && 271 stringCompare( i1.description(), i2.description() ) &&
272 stringCompare( i1.summary(), i2.summary() ) && 272 stringCompare( i1.summary(), i2.summary() ) &&
273 i1.categories() == i2.categories() && 273 i1.categories() == i2.categories() &&
274 // no need to compare mRelatedTo 274 // no need to compare mRelatedTo
275 stringCompare( i1.relatedToUid(), i2.relatedToUid() ) && 275 stringCompare( i1.relatedToUid(), i2.relatedToUid() ) &&
276 // i1.relations() == i2.relations() && 276 // i1.relations() == i2.relations() &&
277 i1.exDates() == i2.exDates() && 277 i1.exDates() == i2.exDates() &&
278 i1.attachments() == i2.attachments() && 278 i1.attachments() == i2.attachments() &&
279 i1.resources() == i2.resources() && 279 i1.resources() == i2.resources() &&
280 i1.secrecy() == i2.secrecy() && 280 i1.secrecy() == i2.secrecy() &&
281 i1.priority() == i2.priority() && 281 i1.priority() == i2.priority() &&
282 i1.cancelled() == i2.cancelled() && 282 i1.cancelled() == i2.cancelled() &&
283 stringCompare( i1.location(), i2.location() ); 283 stringCompare( i1.location(), i2.location() );
284} 284}
285 285
286Incidence* Incidence::recreateCloneException( QDate d ) 286Incidence* Incidence::recreateCloneException( QDate d )
287{ 287{
288 Incidence* newInc = clone(); 288 Incidence* newInc = clone();
289 newInc->recreate(); 289 newInc->recreate();
290 if ( doesRecur() ) { 290 if ( doesRecur() ) {
291 addExDate( d ); 291 addExDate( d );
292 newInc->recurrence()->unsetRecurs(); 292 newInc->recurrence()->unsetRecurs();
293 if ( typeID() == eventID ) { 293 if ( typeID() == eventID ) {
294 int len = dtStart().secsTo( ((Event*)this)->dtEnd()); 294 int len = dtStart().secsTo( ((Event*)this)->dtEnd());
295 QTime tim = dtStart().time(); 295 QTime tim = dtStart().time();
296 newInc->setDtStart( QDateTime(d, tim) ); 296 newInc->setDtStart( QDateTime(d, tim) );
297 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); 297 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) );
298 } else { 298 } else {
299 int len = dtStart().secsTo( ((Todo*)this)->dtDue()); 299 int len = dtStart().secsTo( ((Todo*)this)->dtDue());
300 QTime tim = ((Todo*)this)->dtDue().time(); 300 QTime tim = ((Todo*)this)->dtDue().time();
301 ((Todo*)newInc)->setDtDue( QDateTime(d, tim) ); 301 ((Todo*)newInc)->setDtDue( QDateTime(d, tim) );
302 ((Todo*)newInc)->setDtStart( ((Todo*)newInc)->dtDue().addSecs( -len ) ); 302 ((Todo*)newInc)->setDtStart( ((Todo*)newInc)->dtDue().addSecs( -len ) );
303 ((Todo*)this)->setRecurDates(); 303 ((Todo*)this)->setRecurDates();
304 } 304 }
305 newInc->setExDates( DateList () ); 305 newInc->setExDates( DateList () );
306 } 306 }
307 return newInc; 307 return newInc;
308} 308}
309 309
310void Incidence::recreate() 310void Incidence::recreate()
311{ 311{
312 setCreated(QDateTime::currentDateTime()); 312 setCreated(QDateTime::currentDateTime());
313 313
314 setUid(CalFormat::createUniqueId()); 314 setUid(CalFormat::createUniqueId());
315 315
316 setRevision(0); 316 setRevision(0);
317 setIDStr( ":" ); 317 setIDStr( ":" );
318 setLastModified(QDateTime::currentDateTime()); 318 setLastModified(QDateTime::currentDateTime());
319} 319}
320void Incidence::cloneRelations( Incidence * newInc ) 320void Incidence::cloneRelations( Incidence * newInc )
321{ 321{
322 // newInc is already a clone of this incidence 322 // newInc is already a clone of this incidence
323 Incidence * inc; 323 Incidence * inc;
324 Incidence * cloneInc; 324 Incidence * cloneInc;
325 QPtrList<Incidence> Relations = relations(); 325 QPtrList<Incidence> Relations = relations();
326 for (inc=Relations.first();inc;inc=Relations.next()) { 326 for (inc=Relations.first();inc;inc=Relations.next()) {
327 cloneInc = inc->clone(); 327 cloneInc = inc->clone();
328 cloneInc->recreate(); 328 cloneInc->recreate();
329 cloneInc->setRelatedTo( newInc ); 329 cloneInc->setRelatedTo( newInc );
330 inc->cloneRelations( cloneInc ); 330 inc->cloneRelations( cloneInc );
331 } 331 }
332} 332}
333void Incidence::setReadOnly( bool readOnly ) 333void Incidence::setReadOnly( bool readOnly )
334{ 334{
335 IncidenceBase::setReadOnly( readOnly ); 335 IncidenceBase::setReadOnly( readOnly );
336 if ( mRecurrence ) 336 if ( mRecurrence )
337 mRecurrence->setRecurReadOnly( readOnly); 337 mRecurrence->setRecurReadOnly( readOnly);
338} 338}
339void Incidence::setLastModifiedSubInvalid() 339void Incidence::setLastModifiedSubInvalid()
340{ 340{
341 mLastModifiedSub = QDateTime(); 341 mLastModifiedSub = QDateTime();
342 if ( mRelatedTo ) 342 if ( mRelatedTo )
343 mRelatedTo->setLastModifiedSubInvalid(); 343 mRelatedTo->setLastModifiedSubInvalid();
344} 344}
345QString Incidence::lastModifiedSubSortKey() const
346{
347 if ( mLastModifiedSubSortKey.isEmpty() )
348 return lastModifiedSortKey();
349 return mLastModifiedSubSortKey;
350}
345QDateTime Incidence::lastModifiedSub() 351QDateTime Incidence::lastModifiedSub()
346{ 352{
347 if ( !mRelations.count() ) 353 if ( !mRelations.count() )
348 return lastModified(); 354 return lastModified();
349 if ( mLastModifiedSub.isValid() ) 355 if ( mLastModifiedSub.isValid() )
350 return mLastModifiedSub; 356 return mLastModifiedSub;
351 mLastModifiedSub = lastModified(); 357 mLastModifiedSub = lastModified();
352 Incidence * inc; 358 Incidence * inc;
353 QPtrList<Incidence> Relations = relations(); 359 QPtrList<Incidence> Relations = relations();
354 for (inc=Relations.first();inc;inc=Relations.next()) { 360 for (inc=Relations.first();inc;inc=Relations.next()) {
355 if ( inc->lastModifiedSub() > mLastModifiedSub ) 361 if ( inc->lastModifiedSub() > mLastModifiedSub )
356 mLastModifiedSub = inc->lastModifiedSub(); 362 mLastModifiedSub = inc->lastModifiedSub();
357 } 363 }
364 mLastModifiedSubSortKey.sprintf("%04d%02d%02d%02d%02d%02d",
365 mLastModifiedSub.date().year(),
366 mLastModifiedSub.date().month(),
367 mLastModifiedSub.date().day(),
368 mLastModifiedSub.time().hour(),
369 mLastModifiedSub.time().minute(),
370 mLastModifiedSub.time().second() );
358 return mLastModifiedSub; 371 return mLastModifiedSub;
359} 372}
360void Incidence::setCreated(QDateTime created) 373void Incidence::setCreated(QDateTime created)
361{ 374{
362 if (mReadOnly) return; 375 if (mReadOnly) return;
363 mCreated = getEvenTime(created); 376 mCreated = getEvenTime(created);
364} 377}
365 378
366QDateTime Incidence::created() const 379QDateTime Incidence::created() const
367{ 380{
368 return mCreated; 381 return mCreated;
369} 382}
370 383
371void Incidence::setRevision(int rev) 384void Incidence::setRevision(int rev)
372{ 385{
373 if (mReadOnly) return; 386 if (mReadOnly) return;
374 mRevision = rev; 387 mRevision = rev;
375 388
376 updated(); 389 updated();
377} 390}
378 391
379int Incidence::revision() const 392int Incidence::revision() const
380{ 393{
381 return mRevision; 394 return mRevision;
382} 395}
383 396
384void Incidence::setDtStart(const QDateTime &dtStart) 397void Incidence::setDtStart(const QDateTime &dtStart)
385{ 398{
386 399
387 QDateTime dt = getEvenTime(dtStart); 400 QDateTime dt = getEvenTime(dtStart);
388 401
389 if ( mRecurrence ) 402 if ( mRecurrence )
390 mRecurrence->setRecurStart( dt); 403 mRecurrence->setRecurStart( dt);
391 IncidenceBase::setDtStart( dt ); 404 IncidenceBase::setDtStart( dt );
392} 405}
393 406
394void Incidence::setDescription(const QString &description) 407void Incidence::setDescription(const QString &description)
395{ 408{
396 if (mReadOnly) return; 409 if (mReadOnly) return;
397 mDescription = description; 410 mDescription = description;
398 updated(); 411 updated();
399} 412}
400 413
401QString Incidence::description() const 414QString Incidence::description() const
402{ 415{
403 return mDescription; 416 return mDescription;
404} 417}
405 418
406 419
407void Incidence::setSummary(const QString &summary) 420void Incidence::setSummary(const QString &summary)
408{ 421{
409 if (mReadOnly) return; 422 if (mReadOnly) return;
410 mSummary = summary; 423 mSummary = summary;
411 updated(); 424 updated();
412} 425}
413 426
414QString Incidence::summary() const 427QString Incidence::summary() const
415{ 428{
416 return mSummary; 429 return mSummary;
417} 430}
418void Incidence::checkCategories() 431void Incidence::checkCategories()
419{ 432{
420 mHoliday = mCategories.contains("Holiday") || mCategories.contains(i18n("Holiday")); 433 mHoliday = mCategories.contains("Holiday") || mCategories.contains(i18n("Holiday"));
421 mBirthday = mCategories.contains("Birthday") || mCategories.contains(i18n("Birthday")); 434 mBirthday = mCategories.contains("Birthday") || mCategories.contains(i18n("Birthday"));
422 mAnniversary = mCategories.contains("Anniversary") || mCategories.contains(i18n("Anniversary")); 435 mAnniversary = mCategories.contains("Anniversary") || mCategories.contains(i18n("Anniversary"));
423} 436}
424 437
425void Incidence::addCategories(const QStringList &categories, bool addToRelations ) //addToRelations = false 438void Incidence::addCategories(const QStringList &categories, bool addToRelations ) //addToRelations = false
426{ 439{
427 if (mReadOnly) return; 440 if (mReadOnly) return;
428 int i; 441 int i;
429 for( i = 0; i < categories.count(); ++i ) { 442 for( i = 0; i < categories.count(); ++i ) {
430 if ( !mCategories.contains (categories[i])) 443 if ( !mCategories.contains (categories[i]))
431 mCategories.append( categories[i] ); 444 mCategories.append( categories[i] );
432 } 445 }
433 checkCategories(); 446 checkCategories();
434 updated(); 447 updated();
435 if ( addToRelations ) { 448 if ( addToRelations ) {
436 Incidence * inc; 449 Incidence * inc;
437 QPtrList<Incidence> Relations = relations(); 450 QPtrList<Incidence> Relations = relations();
438 for (inc=Relations.first();inc;inc=Relations.next()) { 451 for (inc=Relations.first();inc;inc=Relations.next()) {
439 inc->addCategories( categories, true ); 452 inc->addCategories( categories, true );
440 } 453 }
441 } 454 }
442} 455}
443 456
444void Incidence::setCategories(const QStringList &categories, bool setForRelations ) //setForRelations = false 457void Incidence::setCategories(const QStringList &categories, bool setForRelations ) //setForRelations = false
445{ 458{
446 if (mReadOnly) return; 459 if (mReadOnly) return;
447 mCategories = categories; 460 mCategories = categories;
448 checkCategories(); 461 checkCategories();
449 updated(); 462 updated();
450 if ( setForRelations ) { 463 if ( setForRelations ) {
451 Incidence * inc; 464 Incidence * inc;
452 QPtrList<Incidence> Relations = relations(); 465 QPtrList<Incidence> Relations = relations();
453 for (inc=Relations.first();inc;inc=Relations.next()) { 466 for (inc=Relations.first();inc;inc=Relations.next()) {
diff --git a/libkcal/incidence.h b/libkcal/incidence.h
index eef9e64..dc49640 100644
--- a/libkcal/incidence.h
+++ b/libkcal/incidence.h
@@ -186,139 +186,141 @@ class Incidence : public IncidenceBase
186 DateList exDates() const; 186 DateList exDates() const;
187 /** sets the list of dates which are exceptions to the recurrence rule */ 187 /** sets the list of dates which are exceptions to the recurrence rule */
188 void setExDates(const DateList &_exDates); 188 void setExDates(const DateList &_exDates);
189 void setExDates(const char *dates); 189 void setExDates(const char *dates);
190 /** Add a date to the list of exceptions of the recurrence rule. */ 190 /** Add a date to the list of exceptions of the recurrence rule. */
191 void addExDate(const QDate &date); 191 void addExDate(const QDate &date);
192 192
193 /** returns true if there is an exception for this date in the recurrence 193 /** returns true if there is an exception for this date in the recurrence
194 rule set, or false otherwise. */ 194 rule set, or false otherwise. */
195 bool isException(const QDate &qd) const; 195 bool isException(const QDate &qd) const;
196 196
197 /** add attachment to this event */ 197 /** add attachment to this event */
198 void addAttachment(Attachment *attachment); 198 void addAttachment(Attachment *attachment);
199 /** remove and delete a specific attachment */ 199 /** remove and delete a specific attachment */
200 void deleteAttachment(Attachment *attachment); 200 void deleteAttachment(Attachment *attachment);
201 /** remove and delete all attachments with this mime type */ 201 /** remove and delete all attachments with this mime type */
202 void deleteAttachments(const QString& mime); 202 void deleteAttachments(const QString& mime);
203 /** return list of all associated attachments */ 203 /** return list of all associated attachments */
204 QPtrList<Attachment> attachments() const; 204 QPtrList<Attachment> attachments() const;
205 /** find a list of attachments with this mime type */ 205 /** find a list of attachments with this mime type */
206 QPtrList<Attachment> attachments(const QString& mime) const; 206 QPtrList<Attachment> attachments(const QString& mime) const;
207 207
208 /** sets the event's status the value specified. See the enumeration 208 /** sets the event's status the value specified. See the enumeration
209 * above for possible values. */ 209 * above for possible values. */
210 void setSecrecy(int); 210 void setSecrecy(int);
211 /** return the event's secrecy. */ 211 /** return the event's secrecy. */
212 int secrecy() const; 212 int secrecy() const;
213 /** return the event's secrecy in string format. */ 213 /** return the event's secrecy in string format. */
214 QString secrecyStr() const; 214 QString secrecyStr() const;
215 /** return list of all availbale secrecy classes */ 215 /** return list of all availbale secrecy classes */
216 static QStringList secrecyList(); 216 static QStringList secrecyList();
217 /** return human-readable name of secrecy class */ 217 /** return human-readable name of secrecy class */
218 static QString secrecyName(int); 218 static QString secrecyName(int);
219 219
220 /** returns TRUE if the date specified is one on which the event will 220 /** returns TRUE if the date specified is one on which the event will
221 * recur. */ 221 * recur. */
222 bool recursOn(const QDate &qd) const; 222 bool recursOn(const QDate &qd) const;
223 223
224 // VEVENT and VTODO, but not VJOURNAL (move to EventBase class?): 224 // VEVENT and VTODO, but not VJOURNAL (move to EventBase class?):
225 225
226 /** set resources used, such as Office, Car, etc. */ 226 /** set resources used, such as Office, Car, etc. */
227 void setResources(const QStringList &resources); 227 void setResources(const QStringList &resources);
228 /** return list of current resources */ 228 /** return list of current resources */
229 QStringList resources() const; 229 QStringList resources() const;
230 230
231 /** set the event's priority, 0 is undefined, 1 highest (decreasing order) */ 231 /** set the event's priority, 0 is undefined, 1 highest (decreasing order) */
232 void setPriority(int priority); 232 void setPriority(int priority);
233 /** get the event's priority */ 233 /** get the event's priority */
234 int priority() const; 234 int priority() const;
235 235
236 /** All alarms that are associated with this incidence */ 236 /** All alarms that are associated with this incidence */
237 QPtrList<Alarm> alarms() const; 237 QPtrList<Alarm> alarms() const;
238 /** Create a new alarm which is associated with this incidence */ 238 /** Create a new alarm which is associated with this incidence */
239 Alarm* newAlarm(); 239 Alarm* newAlarm();
240 /** Add an alarm which is associated with this incidence */ 240 /** Add an alarm which is associated with this incidence */
241 void addAlarm(Alarm*); 241 void addAlarm(Alarm*);
242 /** Remove an alarm that is associated with this incidence */ 242 /** Remove an alarm that is associated with this incidence */
243 void removeAlarm(Alarm*); 243 void removeAlarm(Alarm*);
244 /** Remove all alarms that are associated with this incidence */ 244 /** Remove all alarms that are associated with this incidence */
245 void clearAlarms(); 245 void clearAlarms();
246 /** return whether any alarm associated with this incidence is enabled */ 246 /** return whether any alarm associated with this incidence is enabled */
247 bool isAlarmEnabled() const; 247 bool isAlarmEnabled() const;
248 248
249 /** 249 /**
250 Return the recurrence rule associated with this incidence. If there is 250 Return the recurrence rule associated with this incidence. If there is
251 none, returns an appropriate (non-0) object. 251 none, returns an appropriate (non-0) object.
252 */ 252 */
253 Recurrence *recurrence(); 253 Recurrence *recurrence();
254 void setRecurrence(Recurrence * r); 254 void setRecurrence(Recurrence * r);
255 /** 255 /**
256 Forward to Recurrence::doesRecur(). 256 Forward to Recurrence::doesRecur().
257 */ 257 */
258 ushort doesRecur() const; 258 ushort doesRecur() const;
259 259
260 /** set the event's/todo's location. Do _not_ use it with journal */ 260 /** set the event's/todo's location. Do _not_ use it with journal */
261 void setLocation(const QString &location); 261 void setLocation(const QString &location);
262 /** return the event's/todo's location. Do _not_ use it with journal */ 262 /** return the event's/todo's location. Do _not_ use it with journal */
263 QString location() const; 263 QString location() const;
264 /** returns TRUE or FALSE depending on whether the todo has a start date */ 264 /** returns TRUE or FALSE depending on whether the todo has a start date */
265 bool hasStartDate() const; 265 bool hasStartDate() const;
266 /** sets the event's hasStartDate value. */ 266 /** sets the event's hasStartDate value. */
267 void setHasStartDate(bool f); 267 void setHasStartDate(bool f);
268 QDateTime getNextOccurence( const QDateTime& dt, bool* yes ) const; 268 QDateTime getNextOccurence( const QDateTime& dt, bool* yes ) const;
269 bool cancelled() const; 269 bool cancelled() const;
270 void setCancelled( bool b ); 270 void setCancelled( bool b );
271 271
272 bool hasRecurrenceID() const; 272 bool hasRecurrenceID() const;
273 void setHasRecurrenceID( bool b ); 273 void setHasRecurrenceID( bool b );
274 274
275 void setRecurrenceID(QDateTime); 275 void setRecurrenceID(QDateTime);
276 QDateTime recurrenceID () const; 276 QDateTime recurrenceID () const;
277 QDateTime dtStart() const; 277 QDateTime dtStart() const;
278 bool isHoliday() const; 278 bool isHoliday() const;
279 bool isBirthday() const; 279 bool isBirthday() const;
280 bool isAnniversary() const; 280 bool isAnniversary() const;
281 QDateTime lastModifiedSub(); 281 QDateTime lastModifiedSub();
282 QString lastModifiedSubSortKey() const;
282 QString recurrenceText() const; 283 QString recurrenceText() const;
283 void setLastModifiedSubInvalid(); 284 void setLastModifiedSubInvalid();
284 285
285 virtual QString durationText(); 286 virtual QString durationText();
286 QString durationText4Time( int secs ); 287 QString durationText4Time( int secs );
287 Recurrence *mRecurrence; 288 Recurrence *mRecurrence;
288protected: 289protected:
289 QPtrList<Alarm> mAlarms; 290 QPtrList<Alarm> mAlarms;
290 QPtrList<Incidence> mRelations; 291 QPtrList<Incidence> mRelations;
291 QDateTime mRecurrenceID; 292 QDateTime mRecurrenceID;
292 bool mHasRecurrenceID; 293 bool mHasRecurrenceID;
293 private: 294 private:
294 void checkCategories(); 295 void checkCategories();
296 QString mLastModifiedSubSortKey;
295 bool mHoliday, mBirthday, mAnniversary; 297 bool mHoliday, mBirthday, mAnniversary;
296 int mRevision; 298 int mRevision;
297 bool mCancelled; 299 bool mCancelled;
298 300
299 // base components of jounal, event and todo 301 // base components of jounal, event and todo
300 QDateTime mCreated; 302 QDateTime mCreated;
301 QDateTime mLastModifiedSub; 303 QDateTime mLastModifiedSub;
302 QString mDescription; 304 QString mDescription;
303 QString mSummary; 305 QString mSummary;
304 QStringList mCategories; 306 QStringList mCategories;
305 Incidence *mRelatedTo; 307 Incidence *mRelatedTo;
306 QString mRelatedToUid; 308 QString mRelatedToUid;
307 DateList mExDates; 309 DateList mExDates;
308 QPtrList<Attachment> mAttachments; 310 QPtrList<Attachment> mAttachments;
309 QStringList mResources; 311 QStringList mResources;
310 bool mHasStartDate; // if todo has associated start date 312 bool mHasStartDate; // if todo has associated start date
311 313
312 int mSecrecy; 314 int mSecrecy;
313 int mPriority; // 1 = highest, 2 = less, etc. 315 int mPriority; // 1 = highest, 2 = less, etc.
314 316
315 //QPtrList<Alarm> mAlarms; 317 //QPtrList<Alarm> mAlarms;
316 318
317 QString mLocation; 319 QString mLocation;
318}; 320};
319 321
320bool operator==( const Incidence&, const Incidence& ); 322bool operator==( const Incidence&, const Incidence& );
321 323
322} 324}
323 325
324#endif 326#endif
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp
index 022dead..cfef973 100644
--- a/libkcal/incidencebase.cpp
+++ b/libkcal/incidencebase.cpp
@@ -100,203 +100,214 @@ bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 )
100 //qDebug("Attendee not equal "); 100 //qDebug("Attendee not equal ");
101 return false; 101 return false;
102 } 102 }
103 a1 = i1.attendees().next(); 103 a1 = i1.attendees().next();
104 a2 = i2.attendees().next(); 104 a2 = i2.attendees().next();
105 } 105 }
106 } 106 }
107 //if ( i1.dtStart() != i2.dtStart() ) 107 //if ( i1.dtStart() != i2.dtStart() )
108 // return false; 108 // return false;
109#if 0 109#if 0
110 qDebug("1 %d ",i1.doesFloat() == i2.doesFloat() ); 110 qDebug("1 %d ",i1.doesFloat() == i2.doesFloat() );
111 qDebug("1 %d ",i1.duration() == i2.duration() ); 111 qDebug("1 %d ",i1.duration() == i2.duration() );
112 qDebug("3 %d ",i1.hasDuration() == i2.hasDuration() ); 112 qDebug("3 %d ",i1.hasDuration() == i2.hasDuration() );
113 qDebug("1 %d ",i1.pilotId() == i2.pilotId() ); 113 qDebug("1 %d ",i1.pilotId() == i2.pilotId() );
114 qDebug("1 %d %d %d",i1.syncStatus() == i2.syncStatus() , i1.syncStatus(),i2.syncStatus() ); 114 qDebug("1 %d %d %d",i1.syncStatus() == i2.syncStatus() , i1.syncStatus(),i2.syncStatus() );
115 qDebug("6 %d ",i1.organizer() == i2.organizer() ); 115 qDebug("6 %d ",i1.organizer() == i2.organizer() );
116 116
117#endif 117#endif
118 if ( i1.hasDuration() == i2.hasDuration() ) { 118 if ( i1.hasDuration() == i2.hasDuration() ) {
119 if ( i1.hasDuration() ) { 119 if ( i1.hasDuration() ) {
120 if ( i1.duration() != i2.duration() ) 120 if ( i1.duration() != i2.duration() )
121 return false; 121 return false;
122 } 122 }
123 } else { 123 } else {
124 return false; 124 return false;
125 } 125 }
126 126
127 return ( i1.organizer() == i2.organizer() && 127 return ( i1.organizer() == i2.organizer() &&
128 // i1.uid() == i2.uid() && 128 // i1.uid() == i2.uid() &&
129 // Don't compare lastModified, otherwise the operator is not 129 // Don't compare lastModified, otherwise the operator is not
130 // of much use. We are not comparing for identity, after all. 130 // of much use. We are not comparing for identity, after all.
131 i1.doesFloat() == i2.doesFloat() && 131 i1.doesFloat() == i2.doesFloat() &&
132 i1.pilotId() == i2.pilotId() );// && i1.syncStatus() == i2.syncStatus() ); 132 i1.pilotId() == i2.pilotId() );// && i1.syncStatus() == i2.syncStatus() );
133 // no need to compare mObserver 133 // no need to compare mObserver
134} 134}
135 135
136 136
137QDateTime IncidenceBase::getEvenTime( QDateTime dt ) 137QDateTime IncidenceBase::getEvenTime( QDateTime dt )
138{ 138{
139 QTime t = dt.time(); 139 QTime t = dt.time();
140 dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 140 dt.setTime( QTime (t.hour (), t.minute (), t.second () ) );
141 return dt; 141 return dt;
142} 142}
143 143
144bool IncidenceBase::isTagged() const 144bool IncidenceBase::isTagged() const
145{ 145{
146 return mIsTagged; 146 return mIsTagged;
147} 147}
148void IncidenceBase::setTagged( bool b) 148void IncidenceBase::setTagged( bool b)
149{ 149{
150 mIsTagged = b; 150 mIsTagged = b;
151} 151}
152void IncidenceBase::setCalID( int id ) 152void IncidenceBase::setCalID( int id )
153{ 153{
154 if ( mCalID > 0 ) { 154 if ( mCalID > 0 ) {
155 blockLastModified = true; 155 blockLastModified = true;
156 updated(); 156 updated();
157 blockLastModified = false; 157 blockLastModified = false;
158 } 158 }
159 mCalID = id; 159 mCalID = id;
160} 160}
161int IncidenceBase::calID() const 161int IncidenceBase::calID() const
162{ 162{
163 return mCalID; 163 return mCalID;
164} 164}
165void IncidenceBase::setCalEnabled( bool b ) 165void IncidenceBase::setCalEnabled( bool b )
166{ 166{
167 mCalEnabled = b; 167 mCalEnabled = b;
168} 168}
169bool IncidenceBase::calEnabled() const 169bool IncidenceBase::calEnabled() const
170{ 170{
171 return mCalEnabled; 171 return mCalEnabled;
172} 172}
173 173
174void IncidenceBase::setAlarmEnabled( bool b ) 174void IncidenceBase::setAlarmEnabled( bool b )
175{ 175{
176 mAlarmEnabled = b; 176 mAlarmEnabled = b;
177} 177}
178bool IncidenceBase::alarmEnabled() const 178bool IncidenceBase::alarmEnabled() const
179{ 179{
180 return mAlarmEnabled; 180 return mAlarmEnabled;
181} 181}
182 182
183 183
184void IncidenceBase::setUid(const QString &uid) 184void IncidenceBase::setUid(const QString &uid)
185{ 185{
186 mUid = uid; 186 mUid = uid;
187 updated(); 187 updated();
188} 188}
189 189
190QString IncidenceBase::uid() const 190QString IncidenceBase::uid() const
191{ 191{
192 return mUid; 192 return mUid;
193} 193}
194void IncidenceBase::setLastModifiedSubInvalid() 194void IncidenceBase::setLastModifiedSubInvalid()
195{ 195{
196 196 // virtual method
197} 197}
198void IncidenceBase::setLastModified(const QDateTime &lm) 198void IncidenceBase::setLastModified(const QDateTime &lm)
199{ 199{
200 if ( blockLastModified ) return; 200 if ( blockLastModified ) return;
201 // DON'T! updated() because we call this from 201 // DON'T! updated() because we call this from
202 // Calendar::updateEvent(). 202 // Calendar::updateEvent().
203 mLastModified = getEvenTime(lm); 203 mLastModified = getEvenTime(lm);
204 mLastModifiedKey.sprintf("%04d%02d%02d%02d%02d%02d",
205 mLastModified.date().year(),
206 mLastModified.date().month(),
207 mLastModified.date().day(),
208 mLastModified.time().hour(),
209 mLastModified.time().minute(),
210 mLastModified.time().second() );
204 setLastModifiedSubInvalid(); 211 setLastModifiedSubInvalid();
205 //qDebug("IncidenceBase::setLastModified %s ",lm.toString().latin1()); 212 //qDebug("IncidenceBase::setLastModified %s ",lm.toString().latin1());
206} 213}
214QString IncidenceBase::lastModifiedSortKey() const
215{
216 return mLastModifiedKey;
217}
207 218
208QDateTime IncidenceBase::lastModified() const 219QDateTime IncidenceBase::lastModified() const
209{ 220{
210 return mLastModified; 221 return mLastModified;
211} 222}
212 223
213void IncidenceBase::setOrganizer(const QString &o) 224void IncidenceBase::setOrganizer(const QString &o)
214{ 225{
215 // we don't check for readonly here, because it is 226 // we don't check for readonly here, because it is
216 // possible that by setting the organizer we are changing 227 // possible that by setting the organizer we are changing
217 // the event's readonly status... 228 // the event's readonly status...
218 mOrganizer = o; 229 mOrganizer = o;
219 if (mOrganizer.left(7).upper() == "MAILTO:") 230 if (mOrganizer.left(7).upper() == "MAILTO:")
220 mOrganizer = mOrganizer.remove(0,7); 231 mOrganizer = mOrganizer.remove(0,7);
221 232
222 updated(); 233 updated();
223} 234}
224 235
225QString IncidenceBase::organizer() const 236QString IncidenceBase::organizer() const
226{ 237{
227 return mOrganizer; 238 return mOrganizer;
228} 239}
229 240
230void IncidenceBase::setReadOnly( bool readOnly ) 241void IncidenceBase::setReadOnly( bool readOnly )
231{ 242{
232 mReadOnly = readOnly; 243 mReadOnly = readOnly;
233} 244}
234 245
235void IncidenceBase::setDtStart(const QDateTime &dtStart) 246void IncidenceBase::setDtStart(const QDateTime &dtStart)
236{ 247{
237// if (mReadOnly) return; 248// if (mReadOnly) return;
238 mDtStart = getEvenTime(dtStart); 249 mDtStart = getEvenTime(dtStart);
239 updated(); 250 updated();
240} 251}
241 252
242 253
243QDateTime IncidenceBase::dtStart() const 254QDateTime IncidenceBase::dtStart() const
244{ 255{
245 return mDtStart; 256 return mDtStart;
246} 257}
247 258
248QString IncidenceBase::dtStartTimeStr() const 259QString IncidenceBase::dtStartTimeStr() const
249{ 260{
250 return KGlobal::locale()->formatTime(dtStart().time()); 261 return KGlobal::locale()->formatTime(dtStart().time());
251} 262}
252 263
253QString IncidenceBase::dtStartDateStr(bool shortfmt) const 264QString IncidenceBase::dtStartDateStr(bool shortfmt) const
254{ 265{
255 return KGlobal::locale()->formatDate(dtStart().date(),shortfmt); 266 return KGlobal::locale()->formatDate(dtStart().date(),shortfmt);
256} 267}
257 268
258QString IncidenceBase::dtStartStr(bool shortfmt) const 269QString IncidenceBase::dtStartStr(bool shortfmt) const
259{ 270{
260 if ( doesFloat() ) 271 if ( doesFloat() )
261 return KGlobal::locale()->formatDate(dtStart().date(),shortfmt); 272 return KGlobal::locale()->formatDate(dtStart().date(),shortfmt);
262 return KGlobal::locale()->formatDateTime(dtStart(), shortfmt); 273 return KGlobal::locale()->formatDateTime(dtStart(), shortfmt);
263} 274}
264 275
265 276
266bool IncidenceBase::doesFloat() const 277bool IncidenceBase::doesFloat() const
267{ 278{
268 return mFloats; 279 return mFloats;
269} 280}
270 281
271void IncidenceBase::setFloats(bool f) 282void IncidenceBase::setFloats(bool f)
272{ 283{
273 if (mReadOnly) return; 284 if (mReadOnly) return;
274 mFloats = f; 285 mFloats = f;
275 updated(); 286 updated();
276} 287}
277 288
278 289
279bool IncidenceBase::addAttendee(Attendee *a, bool doupdate) 290bool IncidenceBase::addAttendee(Attendee *a, bool doupdate)
280{ 291{
281 if (mReadOnly) return false; 292 if (mReadOnly) return false;
282 if (a->name().left(7).upper() == "MAILTO:") 293 if (a->name().left(7).upper() == "MAILTO:")
283 a->setName(a->name().remove(0,7)); 294 a->setName(a->name().remove(0,7));
284 295
285 QPtrListIterator<Attendee> qli(mAttendees); 296 QPtrListIterator<Attendee> qli(mAttendees);
286 297
287 qli.toFirst(); 298 qli.toFirst();
288 while (qli) { 299 while (qli) {
289 if (*qli.current() == *a) 300 if (*qli.current() == *a)
290 return false; 301 return false;
291 ++qli; 302 ++qli;
292 } 303 }
293 mAttendees.append(a); 304 mAttendees.append(a);
294 if (doupdate) updated(); 305 if (doupdate) updated();
295 return true; 306 return true;
296} 307}
297 308
298#if 0 309#if 0
299void IncidenceBase::removeAttendee(Attendee *a) 310void IncidenceBase::removeAttendee(Attendee *a)
300{ 311{
301 if (mReadOnly) return; 312 if (mReadOnly) return;
302 mAttendees.removeRef(a); 313 mAttendees.removeRef(a);
diff --git a/libkcal/incidencebase.h b/libkcal/incidencebase.h
index 665c1f6..444d4c4 100644
--- a/libkcal/incidencebase.h
+++ b/libkcal/incidencebase.h
@@ -1,187 +1,189 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20#ifndef KCAL_INCIDENCEBASE_H 20#ifndef KCAL_INCIDENCEBASE_H
21#define KCAL_INCIDENCEBASE_H 21#define KCAL_INCIDENCEBASE_H
22// 22//
23// Incidence - base class of calendaring components 23// Incidence - base class of calendaring components
24// 24//
25 25
26#include <qdatetime.h> 26#include <qdatetime.h>
27#include <qstringlist.h> 27#include <qstringlist.h>
28#include <qvaluelist.h> 28#include <qvaluelist.h>
29#include <qptrlist.h> 29#include <qptrlist.h>
30 30
31#include "customproperties.h" 31#include "customproperties.h"
32#include "attendee.h" 32#include "attendee.h"
33 33
34namespace KCal { 34namespace KCal {
35 35
36typedef QValueList<QDate> DateList; 36typedef QValueList<QDate> DateList;
37 enum IncTypeID { eventID,todoID,journalID,freebusyID }; 37 enum IncTypeID { eventID,todoID,journalID,freebusyID };
38 38
39/** 39/**
40 This class provides the base class common to all calendar components. 40 This class provides the base class common to all calendar components.
41*/ 41*/
42class IncidenceBase : public CustomProperties 42class IncidenceBase : public CustomProperties
43{ 43{
44 public: 44 public:
45 class Observer { 45 class Observer {
46 public: 46 public:
47 virtual void incidenceUpdated( IncidenceBase * ) = 0; 47 virtual void incidenceUpdated( IncidenceBase * ) = 0;
48 }; 48 };
49 49
50 IncidenceBase(); 50 IncidenceBase();
51 IncidenceBase(const IncidenceBase &); 51 IncidenceBase(const IncidenceBase &);
52 virtual ~IncidenceBase(); 52 virtual ~IncidenceBase();
53 53
54 virtual QCString type() const = 0; 54 virtual QCString type() const = 0;
55 virtual IncTypeID typeID() const = 0; 55 virtual IncTypeID typeID() const = 0;
56 56
57 /** Set the unique id for the event */ 57 /** Set the unique id for the event */
58 void setUid(const QString &); 58 void setUid(const QString &);
59 /** Return the unique id for the event */ 59 /** Return the unique id for the event */
60 QString uid() const; 60 QString uid() const;
61 61
62 /** Sets the time the incidence was last modified. */ 62 /** Sets the time the incidence was last modified. */
63 void setLastModified(const QDateTime &lm); 63 void setLastModified(const QDateTime &lm);
64 /** Return the time the incidence was last modified. */ 64 /** Return the time the incidence was last modified. */
65 QDateTime lastModified() const; 65 QDateTime lastModified() const;
66 QString lastModifiedSortKey() const;
66 67
67 /** sets the organizer for the event */ 68 /** sets the organizer for the event */
68 void setOrganizer(const QString &o); 69 void setOrganizer(const QString &o);
69 QString organizer() const; 70 QString organizer() const;
70 71
71 /** Set readonly status. */ 72 /** Set readonly status. */
72 virtual void setReadOnly( bool ); 73 virtual void setReadOnly( bool );
73 /** Return if the object is read-only. */ 74 /** Return if the object is read-only. */
74 bool isReadOnly() const { return mReadOnly; } 75 bool isReadOnly() const { return mReadOnly; }
75 76
76 /** for setting the event's starting date/time with a QDateTime. */ 77 /** for setting the event's starting date/time with a QDateTime. */
77 virtual void setDtStart(const QDateTime &dtStart); 78 virtual void setDtStart(const QDateTime &dtStart);
78 /** returns an event's starting date/time as a QDateTime. */ 79 /** returns an event's starting date/time as a QDateTime. */
79 virtual QDateTime dtStart() const; 80 virtual QDateTime dtStart() const;
80 /** returns an event's starting time as a string formatted according to the 81 /** returns an event's starting time as a string formatted according to the
81 users locale settings */ 82 users locale settings */
82 QString dtStartTimeStr() const; 83 QString dtStartTimeStr() const;
83 /** returns an event's starting date as a string formatted according to the 84 /** returns an event's starting date as a string formatted according to the
84 users locale settings */ 85 users locale settings */
85 QString dtStartDateStr(bool shortfmt=true) const; 86 QString dtStartDateStr(bool shortfmt=true) const;
86 /** returns an event's starting date and time as a string formatted according 87 /** returns an event's starting date and time as a string formatted according
87 to the users locale settings */ 88 to the users locale settings */
88 QString dtStartStr(bool shortfmt=true) const; 89 QString dtStartStr(bool shortfmt=true) const;
89 90
90 virtual void setDuration(int seconds); 91 virtual void setDuration(int seconds);
91 int duration() const; 92 int duration() const;
92 void setHasDuration(bool); 93 void setHasDuration(bool);
93 bool hasDuration() const; 94 bool hasDuration() const;
94 95
95 /** Return true or false depending on whether the incidence "floats," 96 /** Return true or false depending on whether the incidence "floats,"
96 * i.e. has a date but no time attached to it. */ 97 * i.e. has a date but no time attached to it. */
97 bool doesFloat() const; 98 bool doesFloat() const;
98 /** Set whether the incidence floats, i.e. has a date but no time attached to it. */ 99 /** Set whether the incidence floats, i.e. has a date but no time attached to it. */
99 void setFloats(bool f); 100 void setFloats(bool f);
100 101
101 /** 102 /**
102 Add Attendee to this incidence. IncidenceBase takes ownership of the 103 Add Attendee to this incidence. IncidenceBase takes ownership of the
103 Attendee object. 104 Attendee object.
104 */ 105 */
105 bool addAttendee(Attendee *a, bool doupdate=true ); 106 bool addAttendee(Attendee *a, bool doupdate=true );
106// void removeAttendee(Attendee *a); 107// void removeAttendee(Attendee *a);
107// void removeAttendee(const char *n); 108// void removeAttendee(const char *n);
108 /** Remove all Attendees. */ 109 /** Remove all Attendees. */
109 void clearAttendees(); 110 void clearAttendees();
110 /** Return list of attendees. */ 111 /** Return list of attendees. */
111 QPtrList<Attendee> attendees() const { return mAttendees; }; 112 QPtrList<Attendee> attendees() const { return mAttendees; };
112 /** Return number of attendees. */ 113 /** Return number of attendees. */
113 int attendeeCount() const { return mAttendees.count(); }; 114 int attendeeCount() const { return mAttendees.count(); };
114 /** Return the Attendee with this email */ 115 /** Return the Attendee with this email */
115 Attendee* attendeeByMail(const QString &); 116 Attendee* attendeeByMail(const QString &);
116 /** Return first Attendee with one of this emails */ 117 /** Return first Attendee with one of this emails */
117 Attendee* attendeeByMails(const QStringList &, const QString& email = QString::null); 118 Attendee* attendeeByMails(const QStringList &, const QString& email = QString::null);
118 119
119 /** pilot syncronization states */ 120 /** pilot syncronization states */
120 enum { SYNCNONE = 0, SYNCMOD = 1, SYNCDEL = 3 }; 121 enum { SYNCNONE = 0, SYNCMOD = 1, SYNCDEL = 3 };
121 /** Set synchronisation satus. */ 122 /** Set synchronisation satus. */
122 void setSyncStatus(int stat); 123 void setSyncStatus(int stat);
123 /** Return synchronisation status. */ 124 /** Return synchronisation status. */
124 int syncStatus() const; 125 int syncStatus() const;
125 126
126 /** Set Pilot Id. */ 127 /** Set Pilot Id. */
127 void setPilotId(int id); 128 void setPilotId(int id);
128 /** Return Pilot Id. */ 129 /** Return Pilot Id. */
129 int pilotId() const; 130 int pilotId() const;
130 131
131 void setTempSyncStat(int id); 132 void setTempSyncStat(int id);
132 int tempSyncStat() const; 133 int tempSyncStat() const;
133 void setIDStr( const QString & ); 134 void setIDStr( const QString & );
134 QString IDStr() const; 135 QString IDStr() const;
135 void setID( const QString &, const QString & ); 136 void setID( const QString &, const QString & );
136 QString getID( const QString & ); 137 QString getID( const QString & );
137 void setCsum( const QString &, const QString & ); 138 void setCsum( const QString &, const QString & );
138 QString getCsum( const QString & ); 139 QString getCsum( const QString & );
139 void removeID(const QString &); 140 void removeID(const QString &);
140 141
141 void registerObserver( Observer * ); 142 void registerObserver( Observer * );
142 void unRegisterObserver( Observer * ); 143 void unRegisterObserver( Observer * );
143 void updated(); 144 void updated();
144 void setCalID( int id ); 145 void setCalID( int id );
145 int calID() const; 146 int calID() const;
146 void setCalEnabled( bool ); 147 void setCalEnabled( bool );
147 bool calEnabled() const; 148 bool calEnabled() const;
148 void setAlarmEnabled( bool ); 149 void setAlarmEnabled( bool );
149 bool alarmEnabled() const; 150 bool alarmEnabled() const;
150 bool isTagged() const; 151 bool isTagged() const;
151 void setTagged( bool ); 152 void setTagged( bool );
152 virtual void setLastModifiedSubInvalid(); 153 virtual void setLastModifiedSubInvalid();
153 protected: 154 protected:
154 bool blockLastModified; 155 bool blockLastModified;
155 bool mIsTagged; 156 bool mIsTagged;
156 QDateTime mDtStart; 157 QDateTime mDtStart;
157 bool mReadOnly; 158 bool mReadOnly;
158 QDateTime getEvenTime( QDateTime ); 159 QDateTime getEvenTime( QDateTime );
159 160
160 private: 161 private:
161 // base components 162 // base components
162 QString mOrganizer; 163 QString mOrganizer;
164 QString mLastModifiedKey;
163 QString mUid; 165 QString mUid;
164 int mCalID; 166 int mCalID;
165 bool mCalEnabled; 167 bool mCalEnabled;
166 bool mAlarmEnabled; 168 bool mAlarmEnabled;
167 QDateTime mLastModified; 169 QDateTime mLastModified;
168 QPtrList<Attendee> mAttendees; 170 QPtrList<Attendee> mAttendees;
169 171
170 bool mFloats; 172 bool mFloats;
171 173
172 int mDuration; 174 int mDuration;
173 bool mHasDuration; 175 bool mHasDuration;
174 QString mExternalId; 176 QString mExternalId;
175 int mTempSyncStat; 177 int mTempSyncStat;
176 178
177 // PILOT SYNCHRONIZATION STUFF 179 // PILOT SYNCHRONIZATION STUFF
178 int mPilotId; // unique id for pilot sync 180 int mPilotId; // unique id for pilot sync
179 int mSyncStatus; // status (for sync) 181 int mSyncStatus; // status (for sync)
180 182
181 QPtrList<Observer> mObservers; 183 QPtrList<Observer> mObservers;
182}; 184};
183 185
184bool operator==( const IncidenceBase&, const IncidenceBase& ); 186bool operator==( const IncidenceBase&, const IncidenceBase& );
185} 187}
186 188
187#endif 189#endif