summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kolistview.cpp21
-rw-r--r--korganizer/kotodoviewitem.cpp14
2 files changed, 11 insertions, 24 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());