summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-07-09 23:58:28 (UTC)
committer zautrix <zautrix>2005-07-09 23:58:28 (UTC)
commit2aabde6c21d6dc4f9de8cf3ac17b98053961cc6b (patch) (unidiff)
treee57782981707d6932940d0489fc942bfeab40dd6 /korganizer
parent47370b5d0dea0f29bb929ba13cf45186095c762d (diff)
downloadkdepimpi-2aabde6c21d6dc4f9de8cf3ac17b98053961cc6b.zip
kdepimpi-2aabde6c21d6dc4f9de8cf3ac17b98053961cc6b.tar.gz
kdepimpi-2aabde6c21d6dc4f9de8cf3ac17b98053961cc6b.tar.bz2
fixxx
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp6
-rw-r--r--korganizer/kotodoview.cpp24
-rw-r--r--korganizer/kotodoviewitem.cpp66
3 files changed, 76 insertions, 20 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 7044e90..f9685e9 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -178,385 +178,385 @@ MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Inciden
178 tempText += "href=\"todo:"; 178 tempText += "href=\"todo:";
179 } 179 }
180 tempText += inc->uid() + "\">"; 180 tempText += inc->uid() + "\">";
181 if ( inc->typeID() == todoID ) 181 if ( inc->typeID() == todoID )
182 tempText += i18n("Todo: "); 182 tempText += i18n("Todo: ");
183 if ( inc->summary().length() > 0 ) 183 if ( inc->summary().length() > 0 )
184 tempText += inc->summary(); 184 tempText += inc->summary();
185 else 185 else
186 tempText += i18n("-no summary-"); 186 tempText += i18n("-no summary-");
187 QString timestr; 187 QString timestr;
188 if (!inc->doesFloat()) 188 if (!inc->doesFloat())
189 timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; 189 timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": ";
190 else 190 else
191 timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; 191 timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": ";
192 if ( dt.date() < QDate::currentDate() && time == 0 ) { 192 if ( dt.date() < QDate::currentDate() && time == 0 ) {
193 mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; 193 mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>";
194 mText += "<table>"; 194 mText += "<table>";
195 time = 1; 195 time = 1;
196 } 196 }
197 if ( dt.date() == QDate::currentDate() && time <= 1 ) { 197 if ( dt.date() == QDate::currentDate() && time <= 1 ) {
198 if ( time > 0 ) 198 if ( time > 0 )
199 mText +="</table>"; 199 mText +="</table>";
200 mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; 200 mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>";
201 mText += "<table>"; 201 mText += "<table>";
202 time = 2; 202 time = 2;
203 203
204 } 204 }
205 if ( dt.date() > QDate::currentDate() && time <= 2 ) { 205 if ( dt.date() > QDate::currentDate() && time <= 2 ) {
206 if ( time > 0 ) 206 if ( time > 0 )
207 mText +="</table>"; 207 mText +="</table>";
208 mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; 208 mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>";
209 mText += "<table>"; 209 mText += "<table>";
210 time = 3; 210 time = 3;
211 } 211 }
212 mText +="<tr><td><b>"; 212 mText +="<tr><td><b>";
213 mText += timestr; 213 mText += timestr;
214 mText += "</b></td><td>"; 214 mText += "</b></td><td>";
215 mText += tempText; 215 mText += tempText;
216 mText += "</td></tr>\n"; 216 mText += "</td></tr>\n";
217 inc = getNextInc( start ); 217 inc = getNextInc( start );
218 } 218 }
219 mText +="</table>"; 219 mText +="</table>";
220 setText( mText ); 220 setText( mText );
221} 221}
222 222
223MissedAlarmTextBrowser::~MissedAlarmTextBrowser() 223MissedAlarmTextBrowser::~MissedAlarmTextBrowser()
224{ 224{
225 //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); 225 //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() ");
226} 226}
227Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) 227Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start )
228{ 228{
229 QDateTime dt ; 229 QDateTime dt ;
230 Incidence * retInc; 230 Incidence * retInc;
231 Incidence * inc = mAlarms.first(); 231 Incidence * inc = mAlarms.first();
232 if ( inc == 0 ) 232 if ( inc == 0 )
233 return 0; 233 return 0;
234 bool ok; 234 bool ok;
235 dt = inc->getNextOccurence( start, &ok ); 235 dt = inc->getNextOccurence( start, &ok );
236 if ( ! ok ) return 0; 236 if ( ! ok ) return 0;
237 QDateTime dtn ; 237 QDateTime dtn ;
238 retInc = inc; 238 retInc = inc;
239 inc = mAlarms.next(); 239 inc = mAlarms.next();
240 while ( inc ) { 240 while ( inc ) {
241 dtn = inc->getNextOccurence( start, &ok ); 241 dtn = inc->getNextOccurence( start, &ok );
242 if ( ! ok ) return 0; 242 if ( ! ok ) return 0;
243 if ( dtn < dt ) { 243 if ( dtn < dt ) {
244 dt = dtn; 244 dt = dtn;
245 retInc = inc; 245 retInc = inc;
246 } 246 }
247 inc = mAlarms.next(); 247 inc = mAlarms.next();
248 } 248 }
249 mAlarms.remove( retInc ); 249 mAlarms.remove( retInc );
250 return retInc; 250 return retInc;
251 251
252} 252}
253void MissedAlarmTextBrowser::setSource(const QString & n) 253void MissedAlarmTextBrowser::setSource(const QString & n)
254{ 254{
255 if (n.startsWith("event:")) { 255 if (n.startsWith("event:")) {
256#ifdef DESKTOP_VERSION 256#ifdef DESKTOP_VERSION
257 emit showIncidence(n.mid(8)); 257 emit showIncidence(n.mid(8));
258#else 258#else
259 emit showIncidence(n.mid(6)); 259 emit showIncidence(n.mid(6));
260#endif 260#endif
261 return; 261 return;
262 } else if (n.startsWith("todo:")) { 262 } else if (n.startsWith("todo:")) {
263#ifdef DESKTOP_VERSION 263#ifdef DESKTOP_VERSION
264 emit showIncidence(n.mid(7)); 264 emit showIncidence(n.mid(7));
265#else 265#else
266 emit showIncidence(n.mid(5)); 266 emit showIncidence(n.mid(5));
267#endif 267#endif
268 return; 268 return;
269 } 269 }
270} 270}
271 271
272 272
273class KOBeamPrefs : public QDialog 273class KOBeamPrefs : public QDialog
274{ 274{
275 public: 275 public:
276 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : 276 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) :
277 QDialog( parent, name, true ) 277 QDialog( parent, name, true )
278 { 278 {
279 setCaption( i18n("Beam Options") ); 279 setCaption( i18n("Beam Options") );
280 QVBoxLayout* lay = new QVBoxLayout( this ); 280 QVBoxLayout* lay = new QVBoxLayout( this );
281 lay->setSpacing( 3 ); 281 lay->setSpacing( 3 );
282 lay->setMargin( 3 ); 282 lay->setMargin( 3 );
283 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); 283 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this );
284 lay->addWidget( format ); 284 lay->addWidget( format );
285 format->setExclusive ( true ) ; 285 format->setExclusive ( true ) ;
286 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); 286 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this );
287 lay->addWidget( time ); time->setExclusive ( true ) ; 287 lay->addWidget( time ); time->setExclusive ( true ) ;
288 vcal = new QRadioButton(" vCalendar ", format ); 288 vcal = new QRadioButton(" vCalendar ", format );
289 ical = new QRadioButton(" iCalendar ", format ); 289 ical = new QRadioButton(" iCalendar ", format );
290 vcal->setChecked( true ); 290 vcal->setChecked( true );
291 tz = new QRadioButton(i18n(" With timezone "), time ); 291 tz = new QRadioButton(i18n(" With timezone "), time );
292 local = new QRadioButton(i18n(" Local time "), time ); 292 local = new QRadioButton(i18n(" Local time "), time );
293 tz->setChecked( true ); 293 tz->setChecked( true );
294 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); 294 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this );
295 lay->addWidget( ok ); 295 lay->addWidget( ok );
296 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 296 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
297 lay->addWidget( cancel ); 297 lay->addWidget( cancel );
298 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 298 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
299 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 299 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
300 resize( 200, 200 ); 300 resize( 200, 200 );
301 } 301 }
302 302
303 bool beamVcal() { return vcal->isChecked(); } 303 bool beamVcal() { return vcal->isChecked(); }
304 bool beamLocal() { return local->isChecked(); } 304 bool beamLocal() { return local->isChecked(); }
305private: 305private:
306 QRadioButton* vcal, *ical, *local, *tz; 306 QRadioButton* vcal, *ical, *local, *tz;
307}; 307};
308class KOCatPrefs : public QDialog 308class KOCatPrefs : public QDialog
309{ 309{
310 public: 310 public:
311 KOCatPrefs( QWidget *parent=0, const char *name=0 ) : 311 KOCatPrefs( QWidget *parent=0, const char *name=0 ) :
312 QDialog( parent, name, true ) 312 QDialog( parent, name, true )
313 { 313 {
314 setCaption( i18n("Manage new Categories") ); 314 setCaption( i18n("Manage new Categories") );
315 QVBoxLayout* lay = new QVBoxLayout( this ); 315 QVBoxLayout* lay = new QVBoxLayout( this );
316 lay->setSpacing( 3 ); 316 lay->setSpacing( 3 );
317 lay->setMargin( 3 ); 317 lay->setMargin( 3 );
318 QLabel * lab = new QLabel( i18n("After importing/loading/syncing there may be new categories in events or todos which are not added automatically to the category list. Please choose what to do <b>now</b>:"), this ); 318 QLabel * lab = new QLabel( i18n("After importing/loading/syncing there may be new categories in events or todos which are not added automatically to the category list. Please choose what to do <b>now</b>:"), this );
319 lay->addWidget( lab ); 319 lay->addWidget( lab );
320 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 320 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
321 lay->addWidget( format ); 321 lay->addWidget( format );
322 format->setExclusive ( true ) ; 322 format->setExclusive ( true ) ;
323 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 323 addCatBut = new QRadioButton(i18n("Add to category list"), format );
324 new QRadioButton(i18n("Remove from Events/Todos"), format ); 324 new QRadioButton(i18n("Remove from Events/Todos"), format );
325 addCatBut->setChecked( true ); 325 addCatBut->setChecked( true );
326 QPushButton * ok = new QPushButton( i18n("Change category list now!"), this ); 326 QPushButton * ok = new QPushButton( i18n("Change category list now!"), this );
327 lay->addWidget( ok ); 327 lay->addWidget( ok );
328 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 328 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
329 lay->addWidget( cancel ); 329 lay->addWidget( cancel );
330 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 330 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
331 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 331 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
332 resize( 200, 200 ); 332 resize( 200, 200 );
333 } 333 }
334 334
335 bool addCat() { return addCatBut->isChecked(); } 335 bool addCat() { return addCatBut->isChecked(); }
336private: 336private:
337 QRadioButton* addCatBut; 337 QRadioButton* addCatBut;
338}; 338};
339 339
340 340
341 341
342CalendarView::CalendarView( CalendarResources *calendar, 342CalendarView::CalendarView( CalendarResources *calendar,
343 QWidget *parent, const char *name ) 343 QWidget *parent, const char *name )
344 : CalendarViewBase( parent, name ), 344 : CalendarViewBase( parent, name ),
345 mCalendar( calendar ), 345 mCalendar( calendar ),
346 mResourceManager( calendar->resourceManager() ) 346 mResourceManager( calendar->resourceManager() )
347{ 347{
348 348
349 mEventEditor = 0; 349 mEventEditor = 0;
350 mTodoEditor = 0; 350 mTodoEditor = 0;
351 351
352 init(); 352 init();
353} 353}
354 354
355CalendarView::CalendarView( Calendar *calendar, 355CalendarView::CalendarView( Calendar *calendar,
356 QWidget *parent, const char *name ) 356 QWidget *parent, const char *name )
357 : CalendarViewBase( parent, name ), 357 : CalendarViewBase( parent, name ),
358 mCalendar( calendar ), 358 mCalendar( calendar ),
359 mResourceManager( 0 ) 359 mResourceManager( 0 )
360{ 360{
361 361
362 mEventEditor = 0; 362 mEventEditor = 0;
363 mTodoEditor = 0; 363 mTodoEditor = 0;
364 init(); 364 init();
365} 365}
366 366
367void CalendarView::init() 367void CalendarView::init()
368{ 368{
369 mNextAlarmDateTime = QDateTime::currentDateTime(); 369 mNextAlarmDateTime = QDateTime::currentDateTime();
370 setFocusPolicy ( NoFocus ); 370 //setFocusPolicy ( NoFocus );
371 mViewerCallerIsSearchDialog = false; 371 mViewerCallerIsSearchDialog = false;
372 mBlockShowDates = false; 372 mBlockShowDates = false;
373 373
374 mDatePickerMode = 0; 374 mDatePickerMode = 0;
375 mCurrentSyncDevice = ""; 375 mCurrentSyncDevice = "";
376 mViewManager = new KOViewManager( this ); 376 mViewManager = new KOViewManager( this );
377 mDialogManager = new KODialogManager( this ); 377 mDialogManager = new KODialogManager( this );
378 mEventViewerDialog = 0; 378 mEventViewerDialog = 0;
379 mModified = false; 379 mModified = false;
380 mReadOnly = false; 380 mReadOnly = false;
381 mSelectedIncidence = 0; 381 mSelectedIncidence = 0;
382 mCalPrinter = 0; 382 mCalPrinter = 0;
383 mFilters.setAutoDelete(true); 383 mFilters.setAutoDelete(true);
384 384
385 mCalendar->registerObserver( this ); 385 mCalendar->registerObserver( this );
386 // TODO: Make sure that view is updated, when calendar is changed. 386 // TODO: Make sure that view is updated, when calendar is changed.
387 387
388 mStorage = new FileStorage( mCalendar ); 388 mStorage = new FileStorage( mCalendar );
389 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 389 mNavigator = new DateNavigator( this, "datevav", mViewManager );
390 390
391 QBoxLayout *topLayout = (QBoxLayout*)layout(); 391 QBoxLayout *topLayout = (QBoxLayout*)layout();
392#ifndef KORG_NOSPLITTER 392#ifndef KORG_NOSPLITTER
393 // create the main layout frames. 393 // create the main layout frames.
394 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 394 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
395 topLayout->addWidget(mPanner); 395 topLayout->addWidget(mPanner);
396 396
397 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 397 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
398 "CalendarView::LeftFrame"); 398 "CalendarView::LeftFrame");
399 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 399 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
400 400
401 mDateNavigator = new DateNavigatorContainer( mLeftSplitter, 401 mDateNavigator = new DateNavigatorContainer( mLeftSplitter,
402 "CalendarView::DateNavigator" ); 402 "CalendarView::DateNavigator" );
403 403
404 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 404 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
405 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 405 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
406 mTodoList->setNavigator( mNavigator ); 406 mTodoList->setNavigator( mNavigator );
407 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 407 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
408 408
409#ifdef KORG_NORESOURCEVIEW 409#ifdef KORG_NORESOURCEVIEW
410 mResourceView = 0; 410 mResourceView = 0;
411#else 411#else
412 if ( mResourceManager ) { 412 if ( mResourceManager ) {
413 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 413 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
414 mResourceView->updateView(); 414 mResourceView->updateView();
415 connect( mResourceView, SIGNAL( resourcesChanged() ), 415 connect( mResourceView, SIGNAL( resourcesChanged() ),
416 SLOT( updateView() ) ); 416 SLOT( updateView() ) );
417 } else { 417 } else {
418 mResourceView = 0; 418 mResourceView = 0;
419 } 419 }
420#endif 420#endif
421 QWidget *rightBox = new QWidget( mPanner ); 421 QWidget *rightBox = new QWidget( mPanner );
422 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 422 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
423 423
424 mRightFrame = new QWidgetStack( rightBox ); 424 mRightFrame = new QWidgetStack( rightBox );
425 rightLayout->addWidget( mRightFrame, 1 ); 425 rightLayout->addWidget( mRightFrame, 1 );
426 426
427 mLeftFrame = mLeftSplitter; 427 mLeftFrame = mLeftSplitter;
428#else 428#else
429 //QWidget *mainBox = new QWidget( this ); 429 //QWidget *mainBox = new QWidget( this );
430 //QWidget *leftFrame = new QWidget( mainBox ); 430 //QWidget *leftFrame = new QWidget( mainBox );
431 //QBoxLayout * mainBoxLayout; 431 //QBoxLayout * mainBoxLayout;
432 if ( KOPrefs::instance()->mVerticalScreen ) { 432 if ( KOPrefs::instance()->mVerticalScreen ) {
433 //mainBoxLayout = new QVBoxLayout(mainBox); 433 //mainBoxLayout = new QVBoxLayout(mainBox);
434 //leftFrameLayout = new QHBoxLayout(leftFrame ); 434 //leftFrameLayout = new QHBoxLayout(leftFrame );
435 mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); 435 mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this );
436 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 436 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
437 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; 437 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);;
438 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 438 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
439 } else { 439 } else {
440 //mainBoxLayout = new QHBoxLayout(mainBox); 440 //mainBoxLayout = new QHBoxLayout(mainBox);
441 //leftFrameLayout = new QVBoxLayout(leftFrame ); 441 //leftFrameLayout = new QVBoxLayout(leftFrame );
442 mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 442 mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
443 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); 443 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left);
444 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); 444 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame);
445 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 445 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
446 } 446 }
447 mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); 447 mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) );
448 //QBoxLayout * leftFrameLayout; 448 //QBoxLayout * leftFrameLayout;
449 topLayout->addWidget( mMainFrame ); 449 topLayout->addWidget( mMainFrame );
450#ifdef DESKTOP_VERSION 450#ifdef DESKTOP_VERSION
451 mDateScrollBar = new QScrollBar ( 1, 365, 1,30, 200,QScrollBar::Horizontal, this ); 451 mDateScrollBar = new QScrollBar ( 1, 365, 1,30, 200,QScrollBar::Horizontal, this );
452 topLayout->addWidget( mDateScrollBar ); 452 topLayout->addWidget( mDateScrollBar );
453 connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) ); 453 connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) );
454 if ( QApplication::desktop()->width() < 800 ) 454 if ( QApplication::desktop()->width() < 800 )
455 mDateScrollBar->hide(); 455 mDateScrollBar->hide();
456#endif 456#endif
457 //mainBoxLayout->addWidget (mLeftFrame); 457 //mainBoxLayout->addWidget (mLeftFrame);
458 mDateNavigator = new DateNavigatorContainer( mLeftFrame, 458 mDateNavigator = new DateNavigatorContainer( mLeftFrame,
459 "CalendarView::DateNavigator" ); 459 "CalendarView::DateNavigator" );
460#if 0 460#if 0
461 // FIXME 461 // FIXME
462 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, 462 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE,
463 "CalendarView::DateNavigator", QDate::currentDate()); 463 "CalendarView::DateNavigator", QDate::currentDate());
464#endif 464#endif
465 // mDateNavigator->blockSignals( true ); 465 // mDateNavigator->blockSignals( true );
466 //leftFrameLayout->addWidget( mDateNavigator ); 466 //leftFrameLayout->addWidget( mDateNavigator );
467 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); 467 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall");
468 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); 468 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView");
469 mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); 469 mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView");
470 connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); 470 connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) );
471 connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); 471 connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) );
472 connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) ); 472 connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) );
473 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); 473 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) );
474 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); 474 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) );
475 connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); 475 connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) );
476 connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); 476 connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) );
477 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); 477 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) );
478 connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() )); 478 connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() ));
479 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); 479 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) );
480 480
481 mTodoList->setNavigator( mNavigator ); 481 mTodoList->setNavigator( mNavigator );
482#if 0 482#if 0
483 if ( QApplication::desktop()->width() < 480 ) { 483 if ( QApplication::desktop()->width() < 480 ) {
484 leftFrameLayout->addWidget(mFilterView); 484 leftFrameLayout->addWidget(mFilterView);
485 leftFrameLayout->addWidget(mTodoList, 2 ); 485 leftFrameLayout->addWidget(mTodoList, 2 );
486 486
487 } else { 487 } else {
488 leftFrameLayout->addWidget(mTodoList,2 ); 488 leftFrameLayout->addWidget(mTodoList,2 );
489 leftFrameLayout->addWidget(mFilterView ); 489 leftFrameLayout->addWidget(mFilterView );
490 } 490 }
491#endif 491#endif
492 mFilterView->hide(); 492 mFilterView->hide();
493 mCalEditView->hide(); 493 mCalEditView->hide();
494 QWidget *rightBox = new QWidget( mMainFrame ); 494 QWidget *rightBox = new QWidget( mMainFrame );
495 //mainBoxLayout->addWidget ( rightBox, 10 ); 495 //mainBoxLayout->addWidget ( rightBox, 10 );
496 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 496 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
497 mRightFrame = new QWidgetStack( rightBox ); 497 mRightFrame = new QWidgetStack( rightBox );
498 rightLayout->addWidget( mRightFrame, 10 ); 498 rightLayout->addWidget( mRightFrame, 10 );
499 499
500 //mLeftFrame = (QWidget *)leftFrame; 500 //mLeftFrame = (QWidget *)leftFrame;
501 if ( KOPrefs::instance()->mVerticalScreen ) { 501 if ( KOPrefs::instance()->mVerticalScreen ) {
502 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); 502 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() );
503 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); 503 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() );
504 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 504 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
505 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 505 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
506 } else { 506 } else {
507 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); 507 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() );
508 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 508 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
509 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 509 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
510 } 510 }
511 if ( !KOPrefs::instance()->mShowDateNavigator) 511 if ( !KOPrefs::instance()->mShowDateNavigator)
512 mDateNavigator->hide(); 512 mDateNavigator->hide();
513 //qDebug("Calendarview Size %d %d ", width(), height()); 513 //qDebug("Calendarview Size %d %d ", width(), height());
514#endif 514#endif
515 515
516 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 516 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
517 SLOT( showDates( const KCal::DateList & ) ) ); 517 SLOT( showDates( const KCal::DateList & ) ) );
518 518
519 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 519 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
520 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 520 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
521 521
522 522
523 523
524 connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), 524 connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ),
525 mViewManager, SLOT( showMonth( const QDate & ) ) ); 525 mViewManager, SLOT( showMonth( const QDate & ) ) );
526 526
527 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 527 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
528 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 528 mNavigator, SLOT( selectWeek( const QDate & ) ) );
529 529
530 connect( mDateNavigator, SIGNAL( goPrevYear() ), 530 connect( mDateNavigator, SIGNAL( goPrevYear() ),
531 mNavigator, SLOT( selectPreviousYear() ) ); 531 mNavigator, SLOT( selectPreviousYear() ) );
532 connect( mDateNavigator, SIGNAL( goNextYear() ), 532 connect( mDateNavigator, SIGNAL( goNextYear() ),
533 mNavigator, SLOT( selectNextYear() ) ); 533 mNavigator, SLOT( selectNextYear() ) );
534 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 534 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
535 mNavigator, SLOT( selectPreviousMonth() ) ); 535 mNavigator, SLOT( selectPreviousMonth() ) );
536 connect( mDateNavigator, SIGNAL( goNextMonth() ), 536 connect( mDateNavigator, SIGNAL( goNextMonth() ),
537 mNavigator, SLOT( selectNextMonth() ) ); 537 mNavigator, SLOT( selectNextMonth() ) );
538 538
539 connect( mDateNavigator, SIGNAL( goPrevious() ), 539 connect( mDateNavigator, SIGNAL( goPrevious() ),
540 mNavigator, SLOT( selectPrevious() ) ); 540 mNavigator, SLOT( selectPrevious() ) );
541 connect( mDateNavigator, SIGNAL( goNext() ), 541 connect( mDateNavigator, SIGNAL( goNext() ),
542 mNavigator, SLOT( selectNext() ) ); 542 mNavigator, SLOT( selectNext() ) );
543 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 543 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
544 mNavigator, SLOT( slotMonthSelect( int ) ) ); 544 mNavigator, SLOT( slotMonthSelect( int ) ) );
545 545
546 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 546 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
547 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 547 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
548#if 0 548#if 0
549 connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), 549 connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ),
550 SLOT( incidenceAdded( Incidence *) ) ); 550 SLOT( incidenceAdded( Incidence *) ) );
551#endif 551#endif
552 // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 552 // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
553 553
554 connect( this, SIGNAL( configChanged() ), 554 connect( this, SIGNAL( configChanged() ),
555 mDateNavigator, SLOT( updateConfig() ) ); 555 mDateNavigator, SLOT( updateConfig() ) );
556 556
557 connect( mTodoList, SIGNAL( newTodoSignal() ), 557 connect( mTodoList, SIGNAL( newTodoSignal() ),
558 SLOT( newTodo() ) ); 558 SLOT( newTodo() ) );
559 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 559 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
560 SLOT( newSubTodo( Todo * ) ) ); 560 SLOT( newSubTodo( Todo * ) ) );
561 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 561 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
562 SLOT( editTodo( Todo * ) ) ); 562 SLOT( editTodo( Todo * ) ) );
@@ -4498,323 +4498,323 @@ void CalendarView::toggleAllDaySize()
4498{ 4498{
4499 /* 4499 /*
4500 if ( KOPrefs::instance()->mAllDaySize > 47 ) 4500 if ( KOPrefs::instance()->mAllDaySize > 47 )
4501 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; 4501 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2;
4502 else 4502 else
4503 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; 4503 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2;
4504 */ 4504 */
4505 viewManager()->agendaView()->toggleAllDay(); 4505 viewManager()->agendaView()->toggleAllDay();
4506} 4506}
4507void CalendarView::toggleExpand() 4507void CalendarView::toggleExpand()
4508{ 4508{
4509 // if ( mLeftFrame->isHidden() ) { 4509 // if ( mLeftFrame->isHidden() ) {
4510 // mLeftFrame->show(); 4510 // mLeftFrame->show();
4511 // emit calendarViewExpanded( false ); 4511 // emit calendarViewExpanded( false );
4512 // } else { 4512 // } else {
4513 // mLeftFrame->hide(); 4513 // mLeftFrame->hide();
4514 // emit calendarViewExpanded( true ); 4514 // emit calendarViewExpanded( true );
4515 // } 4515 // }
4516 //qDebug(" CalendarView::toggleExpand()"); 4516 //qDebug(" CalendarView::toggleExpand()");
4517 globalFlagBlockAgenda = 1; 4517 globalFlagBlockAgenda = 1;
4518 emit calendarViewExpanded( !mLeftFrame->isHidden() ); 4518 emit calendarViewExpanded( !mLeftFrame->isHidden() );
4519 globalFlagBlockAgenda = 5; 4519 globalFlagBlockAgenda = 5;
4520 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); 4520 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() );
4521 //mViewManager->showView( 0, true ); 4521 //mViewManager->showView( 0, true );
4522} 4522}
4523 4523
4524void CalendarView::calendarModified( bool modified, Calendar * ) 4524void CalendarView::calendarModified( bool modified, Calendar * )
4525{ 4525{
4526 setModified( modified ); 4526 setModified( modified );
4527} 4527}
4528 4528
4529Todo *CalendarView::selectedTodo() 4529Todo *CalendarView::selectedTodo()
4530{ 4530{
4531 Incidence *incidence = currentSelection(); 4531 Incidence *incidence = currentSelection();
4532 if ( incidence && incidence->typeID() == todoID ) { 4532 if ( incidence && incidence->typeID() == todoID ) {
4533 return static_cast<Todo *>( incidence ); 4533 return static_cast<Todo *>( incidence );
4534 } 4534 }
4535 4535
4536 incidence = mTodoList->selectedIncidences().first(); 4536 incidence = mTodoList->selectedIncidences().first();
4537 if ( incidence && incidence->typeID() == todoID ) { 4537 if ( incidence && incidence->typeID() == todoID ) {
4538 return static_cast<Todo *>( incidence ); 4538 return static_cast<Todo *>( incidence );
4539 } 4539 }
4540 4540
4541 return 0; 4541 return 0;
4542} 4542}
4543 4543
4544void CalendarView::showIncidence() 4544void CalendarView::showIncidence()
4545{ 4545{
4546 mViewerCallerIsSearchDialog = false; 4546 mViewerCallerIsSearchDialog = false;
4547 Incidence *incidence = currentSelection(); 4547 Incidence *incidence = currentSelection();
4548 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 4548 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
4549 if ( incidence ) { 4549 if ( incidence ) {
4550 ShowIncidenceVisitor v; 4550 ShowIncidenceVisitor v;
4551 v.act( incidence, this ); 4551 v.act( incidence, this );
4552 } 4552 }
4553} 4553}
4554void CalendarView::editIncidenceDescription() 4554void CalendarView::editIncidenceDescription()
4555{ 4555{
4556 mFlagEditDescription = true; 4556 mFlagEditDescription = true;
4557 editIncidence(); 4557 editIncidence();
4558 mFlagEditDescription = false; 4558 mFlagEditDescription = false;
4559} 4559}
4560void CalendarView::editIncidence() 4560void CalendarView::editIncidence()
4561{ 4561{
4562 // qDebug("editIncidence() "); 4562 // qDebug("editIncidence() ");
4563 Incidence *incidence = currentSelection(); 4563 Incidence *incidence = currentSelection();
4564 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 4564 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
4565 if ( incidence ) { 4565 if ( incidence ) {
4566 EditIncidenceVisitor v; 4566 EditIncidenceVisitor v;
4567 v.act( incidence, this ); 4567 v.act( incidence, this );
4568 } 4568 }
4569} 4569}
4570 4570
4571void CalendarView::deleteIncidence() 4571void CalendarView::deleteIncidence()
4572{ 4572{
4573 Incidence *incidence = currentSelection(); 4573 Incidence *incidence = currentSelection();
4574 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 4574 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
4575 if ( incidence ) { 4575 if ( incidence ) {
4576 deleteIncidence(incidence); 4576 deleteIncidence(incidence);
4577 } 4577 }
4578} 4578}
4579void CalendarView::showIncidence(QString uid) 4579void CalendarView::showIncidence(QString uid)
4580{ 4580{
4581 Incidence *inc = mCalendar->incidence( uid ); 4581 Incidence *inc = mCalendar->incidence( uid );
4582 if ( inc ) 4582 if ( inc )
4583 showIncidence( inc ); 4583 showIncidence( inc );
4584} 4584}
4585void CalendarView::showIncidence(Incidence *incidence) 4585void CalendarView::showIncidence(Incidence *incidence)
4586{ 4586{
4587 mViewerCallerIsSearchDialog = false; 4587 mViewerCallerIsSearchDialog = false;
4588 //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); 4588 //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() );
4589 if ( sender() && mDialogManager->getSearchDialog() ) { 4589 if ( sender() && mDialogManager->getSearchDialog() ) {
4590 if ( sender () == mDialogManager->getSearchDialog()->listview() ) { 4590 if ( sender () == mDialogManager->getSearchDialog()->listview() ) {
4591 mViewerCallerIsSearchDialog = true; 4591 mViewerCallerIsSearchDialog = true;
4592 } 4592 }
4593 } 4593 }
4594 if ( incidence ) { 4594 if ( incidence ) {
4595 ShowIncidenceVisitor v; 4595 ShowIncidenceVisitor v;
4596 v.act( incidence, this ); 4596 v.act( incidence, this );
4597 } 4597 }
4598} 4598}
4599 4599
4600void CalendarView::editIncidence(Incidence *incidence) 4600void CalendarView::editIncidence(Incidence *incidence)
4601{ 4601{
4602 if ( incidence ) { 4602 if ( incidence ) {
4603 4603
4604 EditIncidenceVisitor v; 4604 EditIncidenceVisitor v;
4605 v.act( incidence, this ); 4605 v.act( incidence, this );
4606 4606
4607 } 4607 }
4608} 4608}
4609 4609
4610void CalendarView::deleteIncidence(Incidence *incidence) 4610void CalendarView::deleteIncidence(Incidence *incidence)
4611{ 4611{
4612 //qDebug(" CalendarView::deleteIncidence "); 4612 //qDebug(" CalendarView::deleteIncidence ");
4613 if ( incidence == 0 ) { 4613 if ( incidence == 0 ) {
4614 updateView(); 4614 updateView();
4615 emit updateSearchDialog(); 4615 emit updateSearchDialog();
4616 return; 4616 return;
4617 } 4617 }
4618 if ( incidence ) { 4618 if ( incidence ) {
4619 DeleteIncidenceVisitor v; 4619 DeleteIncidenceVisitor v;
4620 v.act( incidence, this ); 4620 v.act( incidence, this );
4621 } 4621 }
4622} 4622}
4623 4623
4624 4624
4625void CalendarView::lookForOutgoingMessages() 4625void CalendarView::lookForOutgoingMessages()
4626{ 4626{
4627 OutgoingDialog *ogd = mDialogManager->outgoingDialog(); 4627 OutgoingDialog *ogd = mDialogManager->outgoingDialog();
4628 ogd->loadMessages(); 4628 ogd->loadMessages();
4629} 4629}
4630 4630
4631void CalendarView::lookForIncomingMessages() 4631void CalendarView::lookForIncomingMessages()
4632{ 4632{
4633 IncomingDialog *icd = mDialogManager->incomingDialog(); 4633 IncomingDialog *icd = mDialogManager->incomingDialog();
4634 icd->retrieve(); 4634 icd->retrieve();
4635} 4635}
4636 4636
4637bool CalendarView::removeCompletedSubTodos( Todo* t ) 4637bool CalendarView::removeCompletedSubTodos( Todo* t )
4638{ 4638{
4639 bool deleteTodo = true; 4639 bool deleteTodo = true;
4640 QPtrList<Incidence> subTodos; 4640 QPtrList<Incidence> subTodos;
4641 Incidence *aTodo; 4641 Incidence *aTodo;
4642 subTodos = t->relations(); 4642 subTodos = t->relations();
4643 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { 4643 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
4644 if (! removeCompletedSubTodos( (Todo*) aTodo )) 4644 if (! removeCompletedSubTodos( (Todo*) aTodo ))
4645 deleteTodo = false; 4645 deleteTodo = false;
4646 } 4646 }
4647 if ( deleteTodo ) { 4647 if ( deleteTodo ) {
4648 if ( t->isCompleted() && !t->doesRecur()) { 4648 if ( t->isCompleted() && !t->doesRecur()) {
4649 checkExternalId( t ); 4649 checkExternalId( t );
4650 mCalendar->deleteTodo( t ); 4650 mCalendar->deleteTodo( t );
4651 changeTodoDisplay( t,KOGlobals::EVENTDELETED ); 4651 changeTodoDisplay( t,KOGlobals::EVENTDELETED );
4652 } 4652 }
4653 else 4653 else
4654 deleteTodo = false; 4654 deleteTodo = false;
4655 } 4655 }
4656 return deleteTodo; 4656 return deleteTodo;
4657 4657
4658} 4658}
4659void CalendarView::purgeCompleted() 4659void CalendarView::purgeCompleted()
4660{ 4660{
4661 int result = KMessageBox::warningContinueCancel(this, 4661 int result = KMessageBox::warningContinueCancel(this,
4662 i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); 4662 i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge"));
4663 4663
4664 if (result == KMessageBox::Continue) { 4664 if (result == KMessageBox::Continue) {
4665 4665
4666 QPtrList<Todo> todoCal; 4666 QPtrList<Todo> todoCal;
4667 QPtrList<Todo> rootTodos; 4667 QPtrList<Todo> rootTodos;
4668 //QPtrList<Incidence> rel; 4668 //QPtrList<Incidence> rel;
4669 Todo *aTodo; 4669 Todo *aTodo;
4670 todoCal = calendar()->todos(); 4670 todoCal = calendar()->todos();
4671 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { 4671 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
4672 if ( !aTodo->relatedTo() ) 4672 if ( !aTodo->relatedTo() )
4673 rootTodos.append( aTodo ); 4673 rootTodos.append( aTodo );
4674 } 4674 }
4675 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { 4675 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) {
4676 removeCompletedSubTodos( aTodo ); 4676 removeCompletedSubTodos( aTodo );
4677 } 4677 }
4678 4678
4679 updateView(); 4679 updateView();
4680 } 4680 }
4681} 4681}
4682 4682
4683void CalendarView::slotCalendarChanged() 4683void CalendarView::slotCalendarChanged()
4684{ 4684{
4685 ; 4685 ;
4686} 4686}
4687 4687
4688void CalendarView::keyPressEvent ( QKeyEvent *e) 4688void CalendarView::keyPressEvent ( QKeyEvent *e)
4689{ 4689{
4690 //qDebug(" alendarView::keyPressEvent "); 4690 //qDebug("CalendarView::keyPressEvent ");
4691 e->ignore(); 4691 e->ignore();
4692} 4692}
4693 4693
4694 4694
4695bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) 4695bool CalendarView::sync(KSyncManager* manager, QString filename, int mode)
4696{ 4696{
4697 4697
4698 if ( manager != mSyncManager) 4698 if ( manager != mSyncManager)
4699 qDebug("KO: Internal error-1. SyncManager mismatch "); 4699 qDebug("KO: Internal error-1. SyncManager mismatch ");
4700 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { 4700 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) {
4701 qDebug("KO: SyncKDE request detected!"); 4701 qDebug("KO: SyncKDE request detected!");
4702 } 4702 }
4703 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 4703 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
4704 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 4704 mCurrentSyncName = mSyncManager->getCurrentSyncName();
4705 return syncCalendar( filename, mode ); 4705 return syncCalendar( filename, mode );
4706} 4706}
4707bool CalendarView::syncExternal(KSyncManager* manager, QString resource) 4707bool CalendarView::syncExternal(KSyncManager* manager, QString resource)
4708{ 4708{
4709 //mSyncManager = manager; 4709 //mSyncManager = manager;
4710 if ( manager != mSyncManager) 4710 if ( manager != mSyncManager)
4711 qDebug("KO: Internal error-2. SyncManager mismatch "); 4711 qDebug("KO: Internal error-2. SyncManager mismatch ");
4712 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 4712 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
4713 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 4713 mCurrentSyncName = mSyncManager->getCurrentSyncName();
4714 if ( resource == "sharp" ) 4714 if ( resource == "sharp" )
4715 syncExternal( 0 ); 4715 syncExternal( 0 );
4716 if ( resource == "phone" ) 4716 if ( resource == "phone" )
4717 syncExternal( 1 ); 4717 syncExternal( 1 );
4718 // pending setmodified 4718 // pending setmodified
4719 return true; 4719 return true;
4720} 4720}
4721void CalendarView::setSyncManager(KSyncManager* manager) 4721void CalendarView::setSyncManager(KSyncManager* manager)
4722{ 4722{
4723 mSyncManager = manager; 4723 mSyncManager = manager;
4724} 4724}
4725 4725
4726void CalendarView::removeSyncInfo( QString syncProfile) 4726void CalendarView::removeSyncInfo( QString syncProfile)
4727{ 4727{
4728 qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); 4728 qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1());
4729 mCalendar->removeSyncInfo( syncProfile ); 4729 mCalendar->removeSyncInfo( syncProfile );
4730 4730
4731} 4731}
4732 4732
4733void CalendarView::undo_delete() 4733void CalendarView::undo_delete()
4734{ 4734{
4735 //qDebug("undo_delete() "); 4735 //qDebug("undo_delete() ");
4736 Incidence* undo = mCalendar->undoIncidence(); 4736 Incidence* undo = mCalendar->undoIncidence();
4737 if ( !undo ) { 4737 if ( !undo ) {
4738 KMessageBox::sorry(this,i18n("There is nothing to undo!"), 4738 KMessageBox::sorry(this,i18n("There is nothing to undo!"),
4739 i18n("KO/Pi")); 4739 i18n("KO/Pi"));
4740 return; 4740 return;
4741 } 4741 }
4742 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( undo->summary(),0 ) + 4742 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( undo->summary(),0 ) +
4743 i18n("\nAre you sure you want\nto restore this?"), 4743 i18n("\nAre you sure you want\nto restore this?"),
4744 i18n("KO/Pi Confirmation"),i18n("Restore"))) { 4744 i18n("KO/Pi Confirmation"),i18n("Restore"))) {
4745 mCalendar->undoDeleteIncidence(); 4745 mCalendar->undoDeleteIncidence();
4746 updateView(); 4746 updateView();
4747 } 4747 }
4748} 4748}
4749 4749
4750void CalendarView::slotViewerClosed() 4750void CalendarView::slotViewerClosed()
4751{ 4751{
4752 QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); 4752 QTimer::singleShot( 50, this, SLOT ( resetFocus() ) );
4753} 4753}
4754 4754
4755void CalendarView::resetFocus() 4755void CalendarView::resetFocus()
4756{ 4756{
4757 if ( mViewerCallerIsSearchDialog ) { 4757 if ( mViewerCallerIsSearchDialog ) {
4758 if ( mDialogManager->getSearchDialog()->isVisible() ){ 4758 if ( mDialogManager->getSearchDialog()->isVisible() ){
4759 mDialogManager->getSearchDialog()->raise(); 4759 mDialogManager->getSearchDialog()->raise();
4760 mDialogManager->getSearchDialog()->setActiveWindow(); 4760 mDialogManager->getSearchDialog()->setActiveWindow();
4761 mDialogManager->getSearchDialog()->listview()->resetFocus(); 4761 mDialogManager->getSearchDialog()->listview()->resetFocus();
4762 } else 4762 } else
4763 mViewerCallerIsSearchDialog = false; 4763 mViewerCallerIsSearchDialog = false;
4764 } 4764 }
4765 if ( !mViewerCallerIsSearchDialog ) { 4765 if ( !mViewerCallerIsSearchDialog ) {
4766 //mViewManager->currentView()->setFocus(); 4766 //mViewManager->currentView()->setFocus();
4767 //qDebug("sssssssssssssssset focus "); 4767 //qDebug("sssssssssssssssset focus ");
4768 topLevelWidget()->raise(); 4768 topLevelWidget()->raise();
4769 setActiveWindow(); 4769 setActiveWindow();
4770 //setFocus(); 4770 //setFocus();
4771 } 4771 }
4772 mViewerCallerIsSearchDialog = false; 4772 mViewerCallerIsSearchDialog = false;
4773} 4773}
4774 4774
4775void CalendarView::showNextAlarms() 4775void CalendarView::showNextAlarms()
4776{ 4776{
4777 QString message; 4777 QString message;
4778 QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); 4778 QDateTime nextAl = mCalendar->nextAlarmEventDateTime();
4779 if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { 4779 if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) {
4780 QString sum = mCalendar->nextSummary(); 4780 QString sum = mCalendar->nextSummary();
4781 QDateTime nextA = mNextAlarmDateTime; 4781 QDateTime nextA = mNextAlarmDateTime;
4782 QDateTime cur = QDateTime::currentDateTime(); 4782 QDateTime cur = QDateTime::currentDateTime();
4783 int secs = cur.secsTo( nextA ); 4783 int secs = cur.secsTo( nextA );
4784 int min = secs /60; 4784 int min = secs /60;
4785 int hours = min /60; 4785 int hours = min /60;
4786 min = min % 60; 4786 min = min % 60;
4787 int days = hours /24; 4787 int days = hours /24;
4788 hours = hours % 24; 4788 hours = hours % 24;
4789 4789
4790 //message = i18n("The next alarm is in:\n"); 4790 //message = i18n("The next alarm is in:\n");
4791 if ( days > 1 ) 4791 if ( days > 1 )
4792 message += i18n("%1 days\n").arg( days ); 4792 message += i18n("%1 days\n").arg( days );
4793 else if ( days == 1 ) 4793 else if ( days == 1 )
4794 message += i18n("1 day\n"); 4794 message += i18n("1 day\n");
4795 if ( hours > 1 ) 4795 if ( hours > 1 )
4796 message += i18n("%1 hours\n").arg( hours ); 4796 message += i18n("%1 hours\n").arg( hours );
4797 else if ( hours == 1 ) 4797 else if ( hours == 1 )
4798 message += i18n("1 hour\n"); 4798 message += i18n("1 hour\n");
4799 if ( min > 1 ) 4799 if ( min > 1 )
4800 message += i18n("%1 minutes\n").arg( min ); 4800 message += i18n("%1 minutes\n").arg( min );
4801 else if ( min == 1 ) 4801 else if ( min == 1 )
4802 message += i18n("1 minute\n"); 4802 message += i18n("1 minute\n");
4803 if ( message.isEmpty() ) 4803 if ( message.isEmpty() )
4804 message = i18n("The next alarm is in\nless than one minute!"); 4804 message = i18n("The next alarm is in\nless than one minute!");
4805 else 4805 else
4806 message = i18n("The next alarm is in:\n") + message; 4806 message = i18n("The next alarm is in:\n") + message;
4807 message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; 4807 message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ;
4808 } else { 4808 } else {
4809 message = i18n("There is no next alarm."); 4809 message = i18n("There is no next alarm.");
4810 4810
4811 } 4811 }
4812#ifdef DESKTOP_VERSION 4812#ifdef DESKTOP_VERSION
4813 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 4813 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
4814 message += i18n("\nThe internal alarm notification is disabled!\n"); 4814 message += i18n("\nThe internal alarm notification is disabled!\n");
4815 message += i18n("Enable it in the settings menu, TAB alarm."); 4815 message += i18n("Enable it in the settings menu, TAB alarm.");
4816 } 4816 }
4817 4817
4818#endif 4818#endif
4819 KMessageBox::information( this, message); 4819 KMessageBox::information( this, message);
4820} 4820}
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index add1819..94f35e6 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -243,541 +243,547 @@ void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *)
243void KOTodoListView::contentsDropEvent(QDropEvent *e) 243void KOTodoListView::contentsDropEvent(QDropEvent *e)
244{ 244{
245#ifndef KORG_NODND 245#ifndef KORG_NODND
246// kdDebug() << "KOTodoListView::contentsDropEvent" << endl; 246// kdDebug() << "KOTodoListView::contentsDropEvent" << endl;
247 247
248 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && 248 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
249 !QTextDrag::canDecode( e ) ) { 249 !QTextDrag::canDecode( e ) ) {
250 e->ignore(); 250 e->ignore();
251 return; 251 return;
252 } 252 }
253 253
254 DndFactory factory( mCalendar ); 254 DndFactory factory( mCalendar );
255 Todo *todo = factory.createDropTodo(e); 255 Todo *todo = factory.createDropTodo(e);
256 256
257 if (todo) { 257 if (todo) {
258 e->acceptAction(); 258 e->acceptAction();
259 259
260 KOTodoViewItem *destination = 260 KOTodoViewItem *destination =
261 (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); 261 (KOTodoViewItem *)itemAt(contentsToViewport(e->pos()));
262 Todo *destinationEvent = 0; 262 Todo *destinationEvent = 0;
263 if (destination) destinationEvent = destination->todo(); 263 if (destination) destinationEvent = destination->todo();
264 264
265 Todo *existingTodo = mCalendar->todo(todo->uid()); 265 Todo *existingTodo = mCalendar->todo(todo->uid());
266 266
267 if(existingTodo) { 267 if(existingTodo) {
268 Incidence *to = destinationEvent; 268 Incidence *to = destinationEvent;
269 while(to) { 269 while(to) {
270 if (to->uid() == todo->uid()) { 270 if (to->uid() == todo->uid()) {
271 KMessageBox::sorry(this, 271 KMessageBox::sorry(this,
272 i18n("Cannot move Todo to itself\nor a child of itself"), 272 i18n("Cannot move Todo to itself\nor a child of itself"),
273 i18n("Drop Todo")); 273 i18n("Drop Todo"));
274 delete todo; 274 delete todo;
275 return; 275 return;
276 } 276 }
277 to = to->relatedTo(); 277 to = to->relatedTo();
278 } 278 }
279 internalDrop = true; 279 internalDrop = true;
280 if ( destinationEvent ) 280 if ( destinationEvent )
281 reparentTodoSignal( destinationEvent, existingTodo ); 281 reparentTodoSignal( destinationEvent, existingTodo );
282 else 282 else
283 unparentTodoSignal(existingTodo); 283 unparentTodoSignal(existingTodo);
284 delete todo; 284 delete todo;
285 } else { 285 } else {
286 mCalendar->addTodo(todo); 286 mCalendar->addTodo(todo);
287 emit todoDropped(todo, KOGlobals::EVENTADDED); 287 emit todoDropped(todo, KOGlobals::EVENTADDED);
288 if ( destinationEvent ) 288 if ( destinationEvent )
289 reparentTodoSignal( destinationEvent, todo ); 289 reparentTodoSignal( destinationEvent, todo );
290 } 290 }
291 } 291 }
292 else { 292 else {
293 QString text; 293 QString text;
294 if (QTextDrag::decode(e,text)) { 294 if (QTextDrag::decode(e,text)) {
295 //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); 295 //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) );
296 KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); 296 KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) ));
297 qDebug("Dropped : " + text); 297 qDebug("Dropped : " + text);
298 QStringList emails = QStringList::split(",",text); 298 QStringList emails = QStringList::split(",",text);
299 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { 299 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) {
300 int pos = (*it).find("<"); 300 int pos = (*it).find("<");
301 QString name = (*it).left(pos); 301 QString name = (*it).left(pos);
302 QString email = (*it).mid(pos); 302 QString email = (*it).mid(pos);
303 if (!email.isEmpty() && todoi) { 303 if (!email.isEmpty() && todoi) {
304 todoi->todo()->addAttendee(new Attendee(name,email)); 304 todoi->todo()->addAttendee(new Attendee(name,email));
305 } 305 }
306 } 306 }
307 } 307 }
308 else { 308 else {
309 qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); 309 qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable ");
310 e->ignore(); 310 e->ignore();
311 } 311 }
312 } 312 }
313#endif 313#endif
314} 314}
315void KOTodoListView::wheelEvent (QWheelEvent *e) 315void KOTodoListView::wheelEvent (QWheelEvent *e)
316{ 316{
317 QListView::wheelEvent (e); 317 QListView::wheelEvent (e);
318} 318}
319 319
320void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) 320void KOTodoListView::contentsMousePressEvent(QMouseEvent* e)
321{ 321{
322 322
323 QPoint p(contentsToViewport(e->pos())); 323 QPoint p(contentsToViewport(e->pos()));
324 QListViewItem *i = itemAt(p); 324 QListViewItem *i = itemAt(p);
325 bool rootClicked = true; 325 bool rootClicked = true;
326 if (i) { 326 if (i) {
327 // if the user clicked into the root decoration of the item, don't 327 // if the user clicked into the root decoration of the item, don't
328 // try to start a drag! 328 // try to start a drag!
329 int X = p.x(); 329 int X = p.x();
330 //qDebug("%d %d %d", X, header()->sectionPos(0), treeStepSize() ); 330 //qDebug("%d %d %d", X, header()->sectionPos(0), treeStepSize() );
331 if (X > header()->sectionPos(0) + 331 if (X > header()->sectionPos(0) +
332 treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + 332 treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) +
333 itemMargin() +i->height()|| 333 itemMargin() +i->height()||
334 X < header()->sectionPos(0)) { 334 X < header()->sectionPos(0)) {
335 rootClicked = false; 335 rootClicked = false;
336 } 336 }
337 } else { 337 } else {
338 rootClicked = false; 338 rootClicked = false;
339 } 339 }
340#ifndef KORG_NODND 340#ifndef KORG_NODND
341 mMousePressed = false; 341 mMousePressed = false;
342 if (! rootClicked && !( e->button() == RightButton) ) { 342 if (! rootClicked && !( e->button() == RightButton) ) {
343 mPressPos = e->pos(); 343 mPressPos = e->pos();
344 mMousePressed = true; 344 mMousePressed = true;
345 } else { 345 } else {
346 mMousePressed = false; 346 mMousePressed = false;
347 } 347 }
348#endif 348#endif
349 //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked); 349 //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked);
350#ifndef DESKTOP_VERSION 350#ifndef DESKTOP_VERSION
351 if (!( e->button() == RightButton && rootClicked) ) 351 if (!( e->button() == RightButton && rootClicked) )
352 QListView::contentsMousePressEvent(e); 352 QListView::contentsMousePressEvent(e);
353#else 353#else
354 QListView::contentsMousePressEvent(e); 354 QListView::contentsMousePressEvent(e);
355#endif 355#endif
356} 356}
357void KOTodoListView::paintEvent(QPaintEvent* e) 357void KOTodoListView::paintEvent(QPaintEvent* e)
358{ 358{
359 emit paintNeeded(); 359 emit paintNeeded();
360 QListView::paintEvent( e); 360 QListView::paintEvent( e);
361} 361}
362void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) 362void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e)
363{ 363{
364 364
365#ifndef KORG_NODND 365#ifndef KORG_NODND
366 //QListView::contentsMouseMoveEvent(e); 366 //QListView::contentsMouseMoveEvent(e);
367 if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > 367 if (mMousePressed && (mPressPos - e->pos()).manhattanLength() >
368 QApplication::startDragDistance()*3) { 368 QApplication::startDragDistance()*3) {
369 mMousePressed = false; 369 mMousePressed = false;
370 QListViewItem *item = itemAt(contentsToViewport(mPressPos)); 370 QListViewItem *item = itemAt(contentsToViewport(mPressPos));
371 if (item) { 371 if (item) {
372 DndFactory factory( mCalendar ); 372 DndFactory factory( mCalendar );
373 ICalDrag *vd = factory.createDrag( 373 ICalDrag *vd = factory.createDrag(
374 ((KOTodoViewItem *)item)->todo(),viewport()); 374 ((KOTodoViewItem *)item)->todo(),viewport());
375 internalDrop = false; 375 internalDrop = false;
376 // we cannot do any senseful here, because the DnD is still broken in Qt 376 // we cannot do any senseful here, because the DnD is still broken in Qt
377 if (vd->drag()) { 377 if (vd->drag()) {
378 if ( !internalDrop ) { 378 if ( !internalDrop ) {
379 //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); 379 //emit deleteTodo( ((KOTodoViewItem *)item)->todo() );
380 qDebug("Dnd: External move: Delete drag source "); 380 qDebug("Dnd: External move: Delete drag source ");
381 } else 381 } else
382 qDebug("Dnd: Internal move "); 382 qDebug("Dnd: Internal move ");
383 383
384 } else { 384 } else {
385 if ( !internalDrop ) { 385 if ( !internalDrop ) {
386 qDebug("Dnd: External Copy"); 386 qDebug("Dnd: External Copy");
387 } else 387 } else
388 qDebug("DnD: Internal copy: Copy pending"); 388 qDebug("DnD: Internal copy: Copy pending");
389 } 389 }
390 } 390 }
391 } 391 }
392#endif 392#endif
393} 393}
394void KOTodoListView::keyReleaseEvent ( QKeyEvent *e ) 394void KOTodoListView::keyReleaseEvent ( QKeyEvent *e )
395{ 395{
396 if ( !e->isAutoRepeat() ) { 396 if ( !e->isAutoRepeat() ) {
397 mFlagKeyPressed = false; 397 mFlagKeyPressed = false;
398 } 398 }
399} 399}
400 400
401 401
402void KOTodoListView::keyPressEvent ( QKeyEvent * e ) 402void KOTodoListView::keyPressEvent ( QKeyEvent * e )
403{ 403{
404 qApp->processEvents(); 404 qApp->processEvents();
405 if ( !isVisible() ) { 405 if ( !isVisible() ) {
406 e->ignore(); 406 e->ignore();
407 return; 407 return;
408 } 408 }
409 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 409 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
410 e->ignore(); 410 e->ignore();
411 // qDebug(" ignore %d",e->isAutoRepeat() ); 411 // qDebug(" ignore %d",e->isAutoRepeat() );
412 return; 412 return;
413 } 413 }
414 if (! e->isAutoRepeat() ) 414 if (! e->isAutoRepeat() )
415 mFlagKeyPressed = true; 415 mFlagKeyPressed = true;
416 QListViewItem* cn; 416 QListViewItem* cn;
417 if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { 417 if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) {
418 cn = currentItem(); 418 cn = currentItem();
419 if ( cn ) { 419 if ( cn ) {
420 KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); 420 KOTodoViewItem* ci = (KOTodoViewItem*)( cn );
421 if ( ci ){ 421 if ( ci ){
422 if ( e->state() == ShiftButton ) 422 if ( e->state() == ShiftButton )
423 ci->setOn( false ); 423 ci->setOn( false );
424 else 424 else
425 ci->setOn( true ); 425 ci->setOn( true );
426 cn = cn->itemBelow(); 426 cn = cn->itemBelow();
427 if ( cn ) { 427 if ( cn ) {
428 setCurrentItem ( cn ); 428 setCurrentItem ( cn );
429 ensureItemVisible ( cn ); 429 ensureItemVisible ( cn );
430 } 430 }
431 431
432 } 432 }
433 } 433 }
434 434
435 e->accept();
435 return; 436 return;
436 } 437 }
437 438
438 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { 439 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) {
439 switch ( e->key() ) { 440 switch ( e->key() ) {
440 case Qt::Key_Down: 441 case Qt::Key_Down:
441 case Qt::Key_Up: 442 case Qt::Key_Up:
442 QListView::keyPressEvent ( e ); 443 QListView::keyPressEvent ( e );
444 e->accept();
443 break; 445 break;
444 case Qt::Key_Left: 446 case Qt::Key_Left:
445 case Qt::Key_Right: 447 case Qt::Key_Right:
446 QListView::keyPressEvent ( e ); 448 QListView::keyPressEvent ( e );
447 e->accept(); 449 e->accept();
448 return; 450 return;
449 break; 451 break;
450 default: 452 default:
451 e->ignore(); 453 e->ignore();
452 break; 454 break;
453 } 455 }
454 return; 456 return;
455 } 457 }
456 e->ignore(); 458 e->ignore();
457} 459}
458void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) 460void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e)
459{ 461{
460 QListView::contentsMouseReleaseEvent(e); 462 QListView::contentsMouseReleaseEvent(e);
461 mMousePressed = false; 463 mMousePressed = false;
462} 464}
463 465
464void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) 466void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e)
465{ 467{
466 if (!e) return; 468 if (!e) return;
467 469
468 QPoint vp = contentsToViewport(e->pos()); 470 QPoint vp = contentsToViewport(e->pos());
469 471
470 QListViewItem *item = itemAt(vp); 472 QListViewItem *item = itemAt(vp);
471 473
472 emit double_Clicked(item); 474 emit double_Clicked(item);
473 if (!item) return; 475 if (!item) return;
474 476
475 emit doubleClicked(item,vp,0); 477 emit doubleClicked(item,vp,0);
476} 478}
477 479
478///////////////////////////////////////////////////////////////////////////// 480/////////////////////////////////////////////////////////////////////////////
479 481
480KOQuickTodo::KOQuickTodo(QWidget *parent) : 482KOQuickTodo::KOQuickTodo(QWidget *parent) :
481 QLineEdit(parent) 483 QLineEdit(parent)
482{ 484{
483 setText(i18n("Click to add new Todo")); 485 setText(i18n("Click to add new Todo"));
484} 486}
485 487
486void KOQuickTodo::focusInEvent(QFocusEvent *ev) 488void KOQuickTodo::focusInEvent(QFocusEvent *ev)
487{ 489{
488 if ( text()==i18n("Click to add new Todo") ) 490 if ( text()==i18n("Click to add new Todo") )
489 setText(""); 491 setText("");
490 QLineEdit::focusInEvent(ev); 492 QLineEdit::focusInEvent(ev);
491} 493}
492 494
493void KOQuickTodo::focusOutEvent(QFocusEvent *ev) 495void KOQuickTodo::focusOutEvent(QFocusEvent *ev)
494{ 496{
495 setText(i18n("Click to add new Todo")); 497 setText(i18n("Click to add new Todo"));
496 QLineEdit::focusOutEvent(ev); 498 QLineEdit::focusOutEvent(ev);
497} 499}
498 500
499///////////////////////////////////////////////////////////////////////////// 501/////////////////////////////////////////////////////////////////////////////
500 502
501KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : 503KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) :
502 KOrg::BaseView(calendar,parent,name) 504 KOrg::BaseView(calendar,parent,name)
503{ 505{
504 mCategoryPopupMenu = 0; 506 mCategoryPopupMenu = 0;
505 mPendingUpdateBeforeRepaint = false; 507 mPendingUpdateBeforeRepaint = false;
506 isFlatDisplay = false; 508 isFlatDisplay = false;
507 mNavigator = 0; 509 mNavigator = 0;
508 QBoxLayout *topLayout = new QVBoxLayout(this); 510 QBoxLayout *topLayout = new QVBoxLayout(this);
509 mName = QString ( name ); 511 mName = QString ( name );
510 mBlockUpdate = false; 512 mBlockUpdate = false;
511 mQuickBar = new QWidget( this ); 513 mQuickBar = new QWidget( this );
512 topLayout->addWidget(mQuickBar); 514 topLayout->addWidget(mQuickBar);
513 515
514 mQuickAdd = new KOQuickTodo(mQuickBar); 516 mQuickAdd = new KOQuickTodo(mQuickBar);
515 QBoxLayout *quickLayout = new QHBoxLayout(mQuickBar); 517 QBoxLayout *quickLayout = new QHBoxLayout(mQuickBar);
516 quickLayout->addWidget( mQuickAdd ); 518 quickLayout->addWidget( mQuickAdd );
519 mNewSubBut = new QPushButton( "sub",mQuickBar );
520 QPushButton * s_done = new QPushButton( "D",mQuickBar );
521 QPushButton * s_run = new QPushButton( "R",mQuickBar );
522 QPushButton * allopen = new QPushButton( "O",mQuickBar );
523 QPushButton * allclose = new QPushButton( "C",mQuickBar );
517 QPushButton * flat = new QPushButton( "F",mQuickBar ); 524 QPushButton * flat = new QPushButton( "F",mQuickBar );
525
518 int fixwid = flat->sizeHint().height(); 526 int fixwid = flat->sizeHint().height();
519 if ( QApplication::desktop()->width() >= 800 ) 527 if ( QApplication::desktop()->width() >= 800 )
520 fixwid *= 2; 528 fixwid *= 2;
521 flat->setFixedWidth( fixwid ); 529 flat->setFixedWidth( fixwid );
522 connect ( flat, SIGNAL ( clicked()), SLOT ( setAllFlat())); 530 connect ( flat, SIGNAL ( clicked()), SLOT ( setAllFlat()));
523 QPushButton * allopen = new QPushButton( "O",mQuickBar );
524 allopen->setFixedWidth( fixwid ); 531 allopen->setFixedWidth( fixwid );
525 connect ( allopen, SIGNAL ( clicked()), SLOT ( setAllOpen())); 532 connect ( allopen, SIGNAL ( clicked()), SLOT ( setAllOpen()));
526 QPushButton * allclose = new QPushButton( "C",mQuickBar );
527 allclose->setFixedWidth( fixwid ); 533 allclose->setFixedWidth( fixwid );
528 connect ( allclose, SIGNAL ( clicked()), SLOT ( setAllClose())); 534 connect ( allclose, SIGNAL ( clicked()), SLOT ( setAllClose()));
529 QPushButton * s_done = new QPushButton( "D",mQuickBar );
530 s_done->setPixmap( SmallIcon("greenhook16")); 535 s_done->setPixmap( SmallIcon("greenhook16"));
531 s_done->setFixedWidth( fixwid ); 536 s_done->setFixedWidth( fixwid );
532 s_done->setFixedHeight( flat->sizeHint().height() ); 537 s_done->setFixedHeight( flat->sizeHint().height() );
533 connect ( s_done, SIGNAL ( clicked()), SLOT ( toggleCompleted())); 538 connect ( s_done, SIGNAL ( clicked()), SLOT ( toggleCompleted()));
534 QPushButton * s_run = new QPushButton( "R",mQuickBar );
535 s_run->setPixmap( SmallIcon("ko16old")); 539 s_run->setPixmap( SmallIcon("ko16old"));
536 s_run->setFixedWidth( fixwid ); 540 s_run->setFixedWidth( fixwid );
537 s_run->setFixedHeight( flat->sizeHint().height() ); 541 s_run->setFixedHeight( flat->sizeHint().height() );
538 connect ( s_run, SIGNAL ( clicked()), SLOT ( toggleRunning())); 542 connect ( s_run, SIGNAL ( clicked()), SLOT ( toggleRunning()));
539 543
540 mNewSubBut = new QPushButton( "sub",mQuickBar );
541 mNewSubBut->setFixedWidth( fixwid*3/2 ); 544 mNewSubBut->setFixedWidth( fixwid*3/2 );
542 connect ( mNewSubBut, SIGNAL ( clicked()), SLOT ( newSubTodo())); 545 connect ( mNewSubBut, SIGNAL ( clicked()), SLOT ( newSubTodo()));
543 mNewSubBut->setEnabled( false ); 546 mNewSubBut->setEnabled( false );
544 quickLayout->addWidget( mNewSubBut ); 547 quickLayout->addWidget( mNewSubBut );
545 quickLayout->addWidget( s_done ); 548 quickLayout->addWidget( s_done );
546 quickLayout->addWidget( s_run ); 549 quickLayout->addWidget( s_run );
547 550
548 quickLayout->addWidget( allopen ); 551 quickLayout->addWidget( allopen );
549 quickLayout->addWidget( allclose ); 552 quickLayout->addWidget( allclose );
550 quickLayout->addWidget( flat ); 553 quickLayout->addWidget( flat );
551 554
552 if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickBar->hide(); 555 if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickBar->hide();
553 556
554 mTodoListView = new KOTodoListView(calendar,this, name ); 557 mTodoListView = new KOTodoListView(calendar,this, name );
555 topLayout->addWidget(mTodoListView); 558 topLayout->addWidget(mTodoListView);
556 //mTodoListView->header()->setMaximumHeight(30); 559 //mTodoListView->header()->setMaximumHeight(30);
557 mTodoListView->setRootIsDecorated(true); 560 mTodoListView->setRootIsDecorated(true);
558 mTodoListView->setAllColumnsShowFocus(true); 561 mTodoListView->setAllColumnsShowFocus(true);
559 562
560 mTodoListView->setShowSortIndicator(true); 563 mTodoListView->setShowSortIndicator(true);
561 564
562 mTodoListView->addColumn(i18n("Todo")); 565 mTodoListView->addColumn(i18n("Todo"));
563 mTodoListView->addColumn(i18n("Prio")); 566 mTodoListView->addColumn(i18n("Prio"));
564 mTodoListView->setColumnAlignment(1,AlignHCenter); 567 mTodoListView->setColumnAlignment(1,AlignHCenter);
565 mTodoListView->addColumn(i18n("Complete")); 568 mTodoListView->addColumn(i18n("Complete"));
566 mTodoListView->setColumnAlignment(2,AlignCenter); 569 mTodoListView->setColumnAlignment(2,AlignCenter);
567 570
568 mTodoListView->addColumn(i18n("Due Date")); 571 mTodoListView->addColumn(i18n("Due Date"));
569 mTodoListView->setColumnAlignment(3,AlignLeft); 572 mTodoListView->setColumnAlignment(3,AlignLeft);
570 mTodoListView->addColumn(i18n("Due Time")); 573 mTodoListView->addColumn(i18n("Due Time"));
571 mTodoListView->setColumnAlignment(4,AlignHCenter); 574 mTodoListView->setColumnAlignment(4,AlignHCenter);
572 575
573 mTodoListView->addColumn(i18n("Start Date")); 576 mTodoListView->addColumn(i18n("Start Date"));
574 mTodoListView->setColumnAlignment(5,AlignLeft); 577 mTodoListView->setColumnAlignment(5,AlignLeft);
575 mTodoListView->addColumn(i18n("Start Time")); 578 mTodoListView->addColumn(i18n("Start Time"));
576 mTodoListView->setColumnAlignment(6,AlignHCenter); 579 mTodoListView->setColumnAlignment(6,AlignHCenter);
577 580
578 mTodoListView->addColumn(i18n("Cancelled")); 581 //mTodoListView->addColumn(i18n("Cancelled"));
579 mTodoListView->addColumn(i18n("Categories")); 582 mTodoListView->addColumn(i18n("Categories"));
580 mTodoListView->addColumn(i18n("Calendar")); 583 mTodoListView->addColumn(i18n("Calendar"));
584 mTodoListView->addColumn(i18n("Last Modified"));
585 mTodoListView->addColumn(i18n("Created"));
586 mTodoListView->addColumn(i18n("Last Modified Sub"));
581#if 0 587#if 0
582 mTodoListView->addColumn(i18n("Sort Id")); 588 mTodoListView->addColumn(i18n("Sort Id"));
583 mTodoListView->setColumnAlignment(4,AlignHCenter); 589 mTodoListView->setColumnAlignment(4,AlignHCenter);
584#endif 590#endif
585 591
586 mTodoListView->setMinimumHeight( 60 ); 592 mTodoListView->setMinimumHeight( 60 );
587 mTodoListView->setItemsRenameable( true ); 593 mTodoListView->setItemsRenameable( true );
588 mTodoListView->setRenameable( 0 ); 594 mTodoListView->setRenameable( 0 );
589 mTodoListView->setColumnWidth( 0, 120 ); 595 mTodoListView->setColumnWidth( 0, 120 );
590 int iii = 0; 596 int iii = 0;
591 for ( iii = 0; iii< 10 ; ++iii ) 597 for ( iii = 0; iii< 12 ; ++iii )
592 mTodoListView->setColumnWidthMode( iii, QListView::Manual ); 598 mTodoListView->setColumnWidthMode( iii, QListView::Manual );
593 599
594 600
595 mKOTodoViewWhatsThis = new KOTodoViewWhatsThis(mTodoListView->viewport(),this); 601 mKOTodoViewWhatsThis = new KOTodoViewWhatsThis(mTodoListView->viewport(),this);
596 602
597 mPriorityPopupMenu = new QPopupMenu(this); 603 mPriorityPopupMenu = new QPopupMenu(this);
598 for (int i = 1; i <= 5; i++) { 604 for (int i = 1; i <= 5; i++) {
599 QString label = QString ("%1").arg (i); 605 QString label = QString ("%1").arg (i);
600 mPriority[mPriorityPopupMenu->insertItem (label)] = i; 606 mPriority[mPriorityPopupMenu->insertItem (label)] = i;
601 } 607 }
602 connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); 608 connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int)));
603 609
604 mPercentageCompletedPopupMenu = new QPopupMenu(this); 610 mPercentageCompletedPopupMenu = new QPopupMenu(this);
605 for (int i = 0; i <= 100; i+=20) { 611 for (int i = 0; i <= 100; i+=20) {
606 QString label = QString ("%1 %").arg (i); 612 QString label = QString ("%1 %").arg (i);
607 mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; 613 mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i;
608 } 614 }
609 connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); 615 connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int)));
610 616
611 617
612 mCategoryPopupMenu = new QPopupMenu (this); 618 mCategoryPopupMenu = new QPopupMenu (this);
613 mCategoryPopupMenu->setCheckable (true); 619 mCategoryPopupMenu->setCheckable (true);
614 connect (mCategoryPopupMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); 620 connect (mCategoryPopupMenu, SIGNAL (activated (int)), SLOT (changedCategories (int)));
615 connect (mCategoryPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCategories ())); 621 connect (mCategoryPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCategories ()));
616 622
617 mCalPopupMenu = new QPopupMenu (this); 623 mCalPopupMenu = new QPopupMenu (this);
618 mCalPopupMenu->setCheckable (true); 624 mCalPopupMenu->setCheckable (true);
619 connect (mCalPopupMenu, SIGNAL (activated (int)), SLOT (changedCal (int))); 625 connect (mCalPopupMenu, SIGNAL (activated (int)), SLOT (changedCal (int)));
620 connect (mCalPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCal ())); 626 connect (mCalPopupMenu, SIGNAL (aboutToShow ()), SLOT (fillCal ()));
621 627
622 628
623 629
624 630
625 mItemPopupMenu = new QPopupMenu(this); 631 mItemPopupMenu = new QPopupMenu(this);
626 mItemPopupMenu->insertItem(i18n("Show"), this, 632 mItemPopupMenu->insertItem(i18n("Show"), this,
627 SLOT (showTodo())); 633 SLOT (showTodo()));
628 mItemPopupMenu->insertItem(i18n("Edit..."), this, 634 mItemPopupMenu->insertItem(i18n("Edit..."), this,
629 SLOT (editTodo())); 635 SLOT (editTodo()));
630 mItemPopupMenu->insertItem( i18n("Delete..."), this, 636 mItemPopupMenu->insertItem( i18n("Delete..."), this,
631 SLOT (deleteTodo())); 637 SLOT (deleteTodo()));
632 mItemPopupMenu->insertItem( i18n("Clone..."), this, 638 mItemPopupMenu->insertItem( i18n("Clone..."), this,
633 SLOT (cloneTodo())); 639 SLOT (cloneTodo()));
634 mItemPopupMenu->insertItem( i18n("Move..."), this, 640 mItemPopupMenu->insertItem( i18n("Move..."), this,
635 SLOT (moveTodo())); 641 SLOT (moveTodo()));
636#ifndef DESKTOP_VERSION 642#ifndef DESKTOP_VERSION
637 mItemPopupMenu->insertItem( i18n("Beam..."), this, 643 mItemPopupMenu->insertItem( i18n("Beam..."), this,
638 SLOT (beamTodo())); 644 SLOT (beamTodo()));
639#endif 645#endif
640 mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, 646 mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this,
641 SLOT (cancelTodo())); 647 SLOT (cancelTodo()));
642 mItemPopupMenu->insertItem( i18n("Categories"), mCategoryPopupMenu); 648 mItemPopupMenu->insertItem( i18n("Categories"), mCategoryPopupMenu);
643 mItemPopupMenu->insertItem( i18n("Calendar"), mCalPopupMenu); 649 mItemPopupMenu->insertItem( i18n("Calendar"), mCalPopupMenu);
644 mItemPopupMenu->insertSeparator(); 650 mItemPopupMenu->insertSeparator();
645 mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this, 651 mItemPopupMenu->insertItem( i18n("Start/Stop todo..."), this,
646 SLOT (toggleRunningItem())); 652 SLOT (toggleRunningItem()));
647 mItemPopupMenu->insertSeparator(); 653 mItemPopupMenu->insertSeparator();
648 /* 654 /*
649 mItemPopupMenu->insertItem( i18n("New Todo..."), this, 655 mItemPopupMenu->insertItem( i18n("New Todo..."), this,
650 SLOT (newTodo())); 656 SLOT (newTodo()));
651 */ 657 */
652 mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, 658 mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this,
653 SLOT (newSubTodo())); 659 SLOT (newSubTodo()));
654 mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, 660 mItemPopupMenu->insertItem(i18n("Unparent Todo"), this,
655 SLOT (unparentTodo()),0,21); 661 SLOT (unparentTodo()),0,21);
656 mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, 662 mItemPopupMenu->insertItem(i18n("Reparent Todo"), this,
657 SLOT (reparentTodo()),0,22); 663 SLOT (reparentTodo()),0,22);
658 mItemPopupMenu->insertSeparator(); 664 mItemPopupMenu->insertSeparator();
659#if 0 665#if 0
660 mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed..."), 666 mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed..."),
661 this, SLOT( purgeCompleted() ) ); 667 this, SLOT( purgeCompleted() ) );
662 mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), 668 mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"),
663 this, SLOT( toggleCompleted() ),0, 33 ); 669 this, SLOT( toggleCompleted() ),0, 33 );
664 mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), 670 mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"),
665 this, SLOT( toggleQuickTodo() ),0, 34 ); 671 this, SLOT( toggleQuickTodo() ),0, 34 );
666 mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), 672 mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"),
667 this, SLOT( toggleRunning() ),0, 35 ); 673 this, SLOT( toggleRunning() ),0, 35 );
668 674
669#endif 675#endif
670 mPopupMenu = new QPopupMenu(this); 676 mPopupMenu = new QPopupMenu(this);
671 mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, 677 mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this,
672 SLOT (newTodo()),0,1); 678 SLOT (newTodo()),0,1);
673 mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed..."), 679 mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed..."),
674 this, SLOT(purgeCompleted()),0,2); 680 this, SLOT(purgeCompleted()),0,2);
675 mPopupMenu->insertItem(i18n("Show Completed"), 681 mPopupMenu->insertItem(i18n("Show Completed"),
676 this, SLOT( toggleCompleted() ),0,3 ); 682 this, SLOT( toggleCompleted() ),0,3 );
677 mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), 683 mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"),
678 this, SLOT( toggleRunning() ),0,5 ); 684 this, SLOT( toggleRunning() ),0,5 );
679 mPopupMenu->insertItem(i18n(" set all open","Display all opened"), 685 mPopupMenu->insertItem(i18n(" set all open","Display all opened"),
680 this, SLOT( setAllOpen() ),0,6 ); 686 this, SLOT( setAllOpen() ),0,6 );
681 mPopupMenu->insertItem(i18n(" set all close","Display all closed"), 687 mPopupMenu->insertItem(i18n(" set all close","Display all closed"),
682 this, SLOT( setAllClose() ),0,7 ); 688 this, SLOT( setAllClose() ),0,7 );
683 mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), 689 mPopupMenu->insertItem(i18n(" set all flat","Display all flat"),
684 this, SLOT( setAllFlat() ),0,8 ); 690 this, SLOT( setAllFlat() ),0,8 );
685 mPopupMenu->insertSeparator(); 691 mPopupMenu->insertSeparator();
686 mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), 692 mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"),
687 this, SLOT( toggleQuickTodo() ),0,4 ); 693 this, SLOT( toggleQuickTodo() ),0,4 );
688 mDocPrefs = new DocPrefs( name ); 694 mDocPrefs = new DocPrefs( name );
689 695
690 mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); 696 mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu );
691 mPopupMenu->setCheckable( true ); 697 mPopupMenu->setCheckable( true );
692 mItemPopupMenu->setCheckable( true ); 698 mItemPopupMenu->setCheckable( true );
693 699
694 700
695 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); 701 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo );
696 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); 702 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo );
697 703
698 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); 704 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo);
699 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); 705 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo );
700 706
701 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); 707 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos);
702 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); 708 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos );
703 709
704 710
705 // Double clicking conflicts with opening/closing the subtree 711 // Double clicking conflicts with opening/closing the subtree
706 connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), 712 connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ),
707 SLOT( editItem( QListViewItem *) ) ); 713 SLOT( editItem( QListViewItem *) ) );
708 /* 714 /*
709 connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, 715 connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *,
710 const QPoint &,int ) ), 716 const QPoint &,int ) ),
711 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); 717 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) );
712 */ 718 */
713 connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, 719 connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *,
714 const QPoint &,int ) ), 720 const QPoint &,int ) ),
715 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); 721 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) );
716 connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), 722 connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ),
717 SLOT( itemClicked( QListViewItem * ) ) ); 723 SLOT( itemClicked( QListViewItem * ) ) );
718 connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), 724 connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ),
719 SLOT( itemDoubleClicked( QListViewItem * ) ) ); 725 SLOT( itemDoubleClicked( QListViewItem * ) ) );
720 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), 726 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ),
721 SLOT( updateView() ) ); 727 SLOT( updateView() ) );
722 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), 728 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ),
723 SLOT( todoModified(Todo *, int) ) ); 729 SLOT( todoModified(Todo *, int) ) );
724 connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), 730 connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ),
725 SLOT( itemStateChanged( QListViewItem * ) ) ); 731 SLOT( itemStateChanged( QListViewItem * ) ) );
726 connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), 732 connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ),
727 SLOT( itemStateChanged( QListViewItem * ) ) ); 733 SLOT( itemStateChanged( QListViewItem * ) ) );
728 connect( mTodoListView, SIGNAL( paintNeeded() ), 734 connect( mTodoListView, SIGNAL( paintNeeded() ),
729 SLOT( paintNeeded()) ); 735 SLOT( paintNeeded()) );
730 736
731#if 0 737#if 0
732 connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), 738 connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)),
733 SLOT(selectionChanged(QListViewItem *))); 739 SLOT(selectionChanged(QListViewItem *)));
734 connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), 740 connect(mTodoListView,SIGNAL(clicked(QListViewItem *)),
735 SLOT(selectionChanged(QListViewItem *))); 741 SLOT(selectionChanged(QListViewItem *)));
736 connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), 742 connect(mTodoListView,SIGNAL(pressed(QListViewItem *)),
737 SLOT(selectionChanged(QListViewItem *))); 743 SLOT(selectionChanged(QListViewItem *)));
738#endif 744#endif
739 745
740 connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); 746 connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) ));
741 connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); 747 connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) ));
742 connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); 748 connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) ));
743 749
744 connect( mTodoListView, SIGNAL(selectionChanged() ), 750 connect( mTodoListView, SIGNAL(selectionChanged() ),
745 SLOT( processSelectionChange() ) ); 751 SLOT( processSelectionChange() ) );
746 connect( mQuickAdd, SIGNAL( returnPressed () ), 752 connect( mQuickAdd, SIGNAL( returnPressed () ),
747 SLOT( addQuickTodo() ) ); 753 SLOT( addQuickTodo() ) );
748 754
749} 755}
750 756
751KOTodoView::~KOTodoView() 757KOTodoView::~KOTodoView()
752{ 758{
753 759
754#if QT_VERSION >= 0x030000 760#if QT_VERSION >= 0x030000
755 761
756#else 762#else
757 delete mKOTodoViewWhatsThis; 763 delete mKOTodoViewWhatsThis;
758#endif 764#endif
759 765
760 delete mDocPrefs; 766 delete mDocPrefs;
761} 767}
762QString KOTodoView::getWhatsThisText(QPoint p) 768QString KOTodoView::getWhatsThisText(QPoint p)
763{ 769{
764 KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p ); 770 KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p );
765 if ( item ) 771 if ( item )
766 return KIncidenceFormatter::instance()->getFormattedText( item->todo(), 772 return KIncidenceFormatter::instance()->getFormattedText( item->todo(),
767 KOPrefs::instance()->mWTshowDetails, 773 KOPrefs::instance()->mWTshowDetails,
768 KOPrefs::instance()->mWTshowCreated, 774 KOPrefs::instance()->mWTshowCreated,
769 KOPrefs::instance()->mWTshowChanged); 775 KOPrefs::instance()->mWTshowChanged);
770 return i18n("That is the todo view" ); 776 return i18n("That is the todo view" );
771 777
772} 778}
773 779
774void KOTodoView::jumpToDate () 780void KOTodoView::jumpToDate ()
775{ 781{
776 // if (mActiveItem) { 782 // if (mActiveItem) {
777// mActiveItem->todo()); 783// mActiveItem->todo());
778// if ( mActiveItem->todo()->hasDueDate() ) 784// if ( mActiveItem->todo()->hasDueDate() )
779// emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); 785// emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() );
780} 786}
781void KOTodoView::paintNeeded() 787void KOTodoView::paintNeeded()
782{ 788{
783 if ( mPendingUpdateBeforeRepaint ) { 789 if ( mPendingUpdateBeforeRepaint ) {
@@ -1414,298 +1420,298 @@ void KOTodoView::itemStateChanged( QListViewItem *item )
1414 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 1420 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
1415 1421
1416// kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; 1422// kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl;
1417 1423
1418 if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); 1424 if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() );
1419} 1425}
1420 1426
1421void KOTodoView::saveLayout(KConfig *config, const QString &group) const 1427void KOTodoView::saveLayout(KConfig *config, const QString &group) const
1422{ 1428{
1423 mTodoListView->saveLayout(config,group); 1429 mTodoListView->saveLayout(config,group);
1424} 1430}
1425 1431
1426void KOTodoView::restoreLayout(KConfig *config, const QString &group) 1432void KOTodoView::restoreLayout(KConfig *config, const QString &group)
1427{ 1433{
1428 mTodoListView->restoreLayout(config,group); 1434 mTodoListView->restoreLayout(config,group);
1429} 1435}
1430 1436
1431void KOTodoView::processSelectionChange() 1437void KOTodoView::processSelectionChange()
1432{ 1438{
1433// kdDebug() << "KOTodoView::processSelectionChange()" << endl; 1439// kdDebug() << "KOTodoView::processSelectionChange()" << endl;
1434 1440
1435 KOTodoViewItem *item = 1441 KOTodoViewItem *item =
1436 static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); 1442 static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() );
1437 1443
1438 if ( !item ) { 1444 if ( !item ) {
1439 emit incidenceSelected( 0 ); 1445 emit incidenceSelected( 0 );
1440 mNewSubBut->setEnabled( false ); 1446 mNewSubBut->setEnabled( false );
1441 } else { 1447 } else {
1442 emit incidenceSelected( item->todo() ); 1448 emit incidenceSelected( item->todo() );
1443 mNewSubBut->setEnabled( true ); 1449 mNewSubBut->setEnabled( true );
1444 } 1450 }
1445} 1451}
1446 1452
1447void KOTodoView::modified(bool b) 1453void KOTodoView::modified(bool b)
1448{ 1454{
1449 emit isModified(b); 1455 emit isModified(b);
1450} 1456}
1451void KOTodoView::setTodoModified( Todo* todo ) 1457void KOTodoView::setTodoModified( Todo* todo )
1452{ 1458{
1453 todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); 1459 todoModified( todo, KOGlobals::UNKNOWN_MODIFIED );
1454} 1460}
1455void KOTodoView::clearSelection() 1461void KOTodoView::clearSelection()
1456{ 1462{
1457 mTodoListView->selectAll( false ); 1463 mTodoListView->selectAll( false );
1458} 1464}
1459void KOTodoView::setAllOpen() 1465void KOTodoView::setAllOpen()
1460{ 1466{
1461 if ( isFlatDisplay ) { 1467 if ( isFlatDisplay ) {
1462 isFlatDisplay = false; 1468 isFlatDisplay = false;
1463 mPopupMenu->setItemChecked( 8,false ); 1469 mPopupMenu->setItemChecked( 8,false );
1464 updateView(); 1470 updateView();
1465 } else { 1471 } else {
1466 storeCurrentItem(); 1472 storeCurrentItem();
1467 } 1473 }
1468 setOpen(mTodoListView->firstChild(), true); 1474 setOpen(mTodoListView->firstChild(), true);
1469 resetCurrentItem(); 1475 resetCurrentItem();
1470} 1476}
1471void KOTodoView::setAllClose() 1477void KOTodoView::setAllClose()
1472{ 1478{
1473 if ( isFlatDisplay ) { 1479 if ( isFlatDisplay ) {
1474 isFlatDisplay = false; 1480 isFlatDisplay = false;
1475 mPopupMenu->setItemChecked( 8,false ); 1481 mPopupMenu->setItemChecked( 8,false );
1476 updateView(); 1482 updateView();
1477 } else { 1483 } else {
1478 storeCurrentItem(); 1484 storeCurrentItem();
1479 } 1485 }
1480 setOpen(mTodoListView->firstChild(), false); 1486 setOpen(mTodoListView->firstChild(), false);
1481 resetCurrentItem(); 1487 resetCurrentItem();
1482} 1488}
1483void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) 1489void KOTodoView::setOpen( QListViewItem* item, bool setOpenI)
1484{ 1490{
1485 1491
1486 while ( item ) { 1492 while ( item ) {
1487 setOpen( item->firstChild(), setOpenI ); 1493 setOpen( item->firstChild(), setOpenI );
1488 item->setOpen( setOpenI ); 1494 item->setOpen( setOpenI );
1489 item = item->nextSibling(); 1495 item = item->nextSibling();
1490 } 1496 }
1491} 1497}
1492 1498
1493void KOTodoView::displayAllFlat() 1499void KOTodoView::displayAllFlat()
1494{ 1500{
1495 storeCurrentItem(); 1501 storeCurrentItem();
1496 pendingSubtodo = 0; 1502 pendingSubtodo = 0;
1497 if ( mBlockUpdate ) { 1503 if ( mBlockUpdate ) {
1498 return; 1504 return;
1499 } 1505 }
1500 mPopupMenu->setItemChecked( 8,true ); 1506 mPopupMenu->setItemChecked( 8,true );
1501 isFlatDisplay = true; 1507 isFlatDisplay = true;
1502 QPtrList<Todo> todoList = calendar()->todos(); 1508 QPtrList<Todo> todoList = calendar()->todos();
1503 mTodoMap.clear(); 1509 mTodoMap.clear();
1504 mTodoListView->clear(); 1510 mTodoListView->clear();
1505 Todo *todo; 1511 Todo *todo;
1506 for(todo = todoList.first(); todo; todo = todoList.next()) { 1512 for(todo = todoList.first(); todo; todo = todoList.next()) {
1507 if ( checkTodo( todo ) ) { 1513 if ( checkTodo( todo ) ) {
1508 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); 1514 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this);
1509 mTodoMap.insert(todo,todoItem); 1515 mTodoMap.insert(todo,todoItem);
1510 } 1516 }
1511 } 1517 }
1512 resetCurrentItem(); 1518 resetCurrentItem();
1513} 1519}
1514 1520
1515void KOTodoView::setAllFlat() 1521void KOTodoView::setAllFlat()
1516{ 1522{
1517 if ( isFlatDisplay ) { 1523 if ( isFlatDisplay ) {
1518 isFlatDisplay = false; 1524 isFlatDisplay = false;
1519 mPopupMenu->setItemChecked( 8,false ); 1525 mPopupMenu->setItemChecked( 8,false );
1520 updateView(); 1526 updateView();
1521 return; 1527 return;
1522 } 1528 }
1523 displayAllFlat(); 1529 displayAllFlat();
1524} 1530}
1525 1531
1526void KOTodoView::purgeCompleted() 1532void KOTodoView::purgeCompleted()
1527{ 1533{
1528 emit purgeCompletedSignal(); 1534 emit purgeCompletedSignal();
1529 1535
1530} 1536}
1531void KOTodoView::toggleQuickTodo() 1537void KOTodoView::toggleQuickTodo()
1532{ 1538{
1533 if ( mQuickBar->isVisible() ) { 1539 if ( mQuickBar->isVisible() ) {
1534 mQuickBar->hide(); 1540 mQuickBar->hide();
1535 KOPrefs::instance()->mEnableQuickTodo = false; 1541 KOPrefs::instance()->mEnableQuickTodo = false;
1536 } 1542 }
1537 else { 1543 else {
1538 mQuickBar->show(); 1544 mQuickBar->show();
1539 KOPrefs::instance()->mEnableQuickTodo = true; 1545 KOPrefs::instance()->mEnableQuickTodo = true;
1540 } 1546 }
1541 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); 1547 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo);
1542 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); 1548 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo );
1543} 1549}
1544 1550
1545void KOTodoView::toggleRunning() 1551void KOTodoView::toggleRunning()
1546{ 1552{
1547 KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; 1553 KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos;
1548 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); 1554 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos);
1549 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); 1555 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos );
1550 updateView(); 1556 updateView();
1551 if ( KOPrefs::instance()->mHideNonStartedTodos ) 1557 if ( KOPrefs::instance()->mHideNonStartedTodos )
1552 topLevelWidget()->setCaption(i18n("Hide not Running")); 1558 topLevelWidget()->setCaption(i18n("Hide not Running"));
1553 else 1559 else
1554 topLevelWidget()->setCaption(i18n("Show not Running")); 1560 topLevelWidget()->setCaption(i18n("Show not Running"));
1555} 1561}
1556 1562
1557void KOTodoView::toggleCompleted() 1563void KOTodoView::toggleCompleted()
1558{ 1564{
1559 KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; 1565 KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo;
1560 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); 1566 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo );
1561 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); 1567 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo );
1562 updateView(); 1568 updateView();
1563 if ( KOPrefs::instance()->mShowCompletedTodo ) 1569 if ( KOPrefs::instance()->mShowCompletedTodo )
1564 topLevelWidget()->setCaption(i18n("Show Completed")); 1570 topLevelWidget()->setCaption(i18n("Show Completed"));
1565 else 1571 else
1566 topLevelWidget()->setCaption(i18n("Hide Completed")); 1572 topLevelWidget()->setCaption(i18n("Hide Completed"));
1567} 1573}
1568 1574
1569void KOTodoView::addQuickTodo() 1575void KOTodoView::addQuickTodo()
1570{ 1576{
1571 addQuickTodoPar( 0 ); 1577 addQuickTodoPar( 0 );
1572} 1578}
1573void KOTodoView::addQuickTodoPar( Todo * parentTodo) 1579void KOTodoView::addQuickTodoPar( Todo * parentTodo)
1574{ 1580{
1575 Todo *todo = new Todo(); 1581 Todo *todo = new Todo();
1576 todo->setSummary(mQuickAdd->text()); 1582 todo->setSummary(mQuickAdd->text());
1577 todo->setOrganizer(KOPrefs::instance()->email()); 1583 todo->setOrganizer(KOPrefs::instance()->email());
1578 if ( parentTodo ) { 1584 if ( parentTodo ) {
1579 todo->setRelatedTo(parentTodo); 1585 todo->setRelatedTo(parentTodo);
1580 1586
1581 todo->setCategories (parentTodo->categoriesStr ()); 1587 todo->setCategories (parentTodo->categoriesStr ());
1582 todo->setSecrecy (parentTodo->secrecy ()); 1588 todo->setSecrecy (parentTodo->secrecy ());
1583 if ( parentTodo->priority() < 3 ) 1589 if ( parentTodo->priority() < 3 )
1584 todo->setPriority( parentTodo->priority() ); 1590 todo->setPriority( parentTodo->priority() );
1585 todo->setCalID( parentTodo->calID() ); 1591 todo->setCalID( parentTodo->calID() );
1586 } else { 1592 } else {
1587 CalFilter * cf = mCalendar->filter(); 1593 CalFilter * cf = mCalendar->filter();
1588 if ( cf ) { 1594 if ( cf ) {
1589 if ( cf->isEnabled()&& cf->showCategories()) { 1595 if ( cf->isEnabled()&& cf->showCategories()) {
1590 todo->setCategories(cf->categoryList()); 1596 todo->setCategories(cf->categoryList());
1591 } 1597 }
1592 if ( cf->isEnabled() ) 1598 if ( cf->isEnabled() )
1593 todo->setSecrecy( cf->getSecrecy()); 1599 todo->setSecrecy( cf->getSecrecy());
1594 } 1600 }
1595 } 1601 }
1596 mCalendar->addTodo(todo); 1602 mCalendar->addTodo(todo);
1597 mQuickAdd->setText(""); 1603 mQuickAdd->setText("");
1598 todoModified (todo, KOGlobals::EVENTADDED ); 1604 todoModified (todo, KOGlobals::EVENTADDED );
1599 updateView(); 1605 updateView();
1600 1606
1601} 1607}
1602void KOTodoView::keyPressEvent ( QKeyEvent * e ) 1608void KOTodoView::keyPressEvent ( QKeyEvent * e )
1603{ 1609{
1604 // e->ignore(); 1610 // e->ignore();
1605 //return; 1611 //return;
1606 //qDebug("KOTodoView::keyPressEvent ");
1607 if ( !isVisible() ) { 1612 if ( !isVisible() ) {
1608 e->ignore(); 1613 e->ignore();
1609 return; 1614 return;
1610 } 1615 }
1611 switch ( e->key() ) { 1616 switch ( e->key() ) {
1612 case Qt::Key_Down: 1617 case Qt::Key_Down:
1613 case Qt::Key_Up: 1618 case Qt::Key_Up:
1614 QWidget::keyPressEvent ( e ); 1619 // KOrg::BaseView::keyPressEvent ( e );
1620 e->ignore();
1615 break; 1621 break;
1616 1622
1617 case Qt::Key_Q: 1623 case Qt::Key_Q:
1618 1624
1619 1625
1620 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) { 1626 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) {
1621 e->ignore(); 1627 e->ignore();
1622 break; 1628 break;
1623 } 1629 }
1624 toggleQuickTodo(); 1630 toggleQuickTodo();
1625 break; 1631 break;
1626 case Qt::Key_U: 1632 case Qt::Key_U:
1627 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { 1633 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) {
1628 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1634 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1629 unparentTodo(); 1635 unparentTodo();
1630 e->accept(); 1636 e->accept();
1631 } else 1637 } else
1632 e->ignore(); 1638 e->ignore();
1633 break; 1639 break;
1634 case Qt::Key_S: 1640 case Qt::Key_S:
1635 if ( e->state() == Qt::ControlButton ) { 1641 if ( e->state() == Qt::ControlButton ) {
1636 e->ignore(); 1642 e->ignore();
1637 break; 1643 break;
1638 } 1644 }
1639 if ( e->state() == Qt::ShiftButton ) { 1645 if ( e->state() == Qt::ShiftButton ) {
1640 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1646 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1641 reparentTodo(); 1647 reparentTodo();
1642 e->accept(); 1648 e->accept();
1643 } else 1649 } else
1644 e->ignore(); 1650 e->ignore();
1645 break; 1651 break;
1646 case Qt::Key_P: 1652 case Qt::Key_P:
1647 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { 1653 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) {
1648 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1654 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1649 if ( pendingSubtodo ) 1655 if ( pendingSubtodo )
1650 itemClicked(mActiveItem); 1656 itemClicked(mActiveItem);
1651 e->accept(); 1657 e->accept();
1652 } else 1658 } else
1653 e->ignore(); 1659 e->ignore();
1654 break; 1660 break;
1655 case Qt::Key_Escape: 1661 case Qt::Key_Escape:
1656 if ( pendingSubtodo ) { 1662 if ( pendingSubtodo ) {
1657 itemClicked(0); 1663 itemClicked(0);
1658 e->accept(); 1664 e->accept();
1659 } else 1665 } else
1660 e->ignore(); 1666 e->ignore();
1661 break; 1667 break;
1662 default: 1668 default:
1663 e->ignore(); 1669 e->ignore();
1664 } 1670 }
1665 1671
1666 if ( true ) { 1672 if ( true ) {
1667 if ( e->key() == Qt::Key_I ) { 1673 if ( e->key() == Qt::Key_I ) {
1668 KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); 1674 KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem();
1669 if ( cn ) { 1675 if ( cn ) {
1670 mActiveItem = cn; 1676 mActiveItem = cn;
1671 KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); 1677 KOTodoViewItem* ci = (KOTodoViewItem*)( cn );
1672 if ( ci ){ 1678 if ( ci ){
1673 showTodo(); 1679 showTodo();
1674 cn = (KOTodoViewItem*)cn->itemBelow(); 1680 cn = (KOTodoViewItem*)cn->itemBelow();
1675 if ( cn ) { 1681 if ( cn ) {
1676 mTodoListView->setCurrentItem ( cn ); 1682 mTodoListView->setCurrentItem ( cn );
1677 mTodoListView->ensureItemVisible ( cn ); 1683 mTodoListView->ensureItemVisible ( cn );
1678 } 1684 }
1679 1685
1680 } 1686 }
1681 } 1687 }
1682 e->accept(); 1688 e->accept();
1683 1689
1684 } 1690 }
1685 1691
1686 } 1692 }
1687 1693
1688} 1694}
1689void KOTodoView::updateTodo( Todo * t, int type ) 1695void KOTodoView::updateTodo( Todo * t, int type )
1690{ 1696{
1691 if ( mBlockUpdate) 1697 if ( mBlockUpdate)
1692 return; 1698 return;
1693 1699
1694 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; 1700 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator;
1695 itemIterator = mTodoMap.find(t); 1701 itemIterator = mTodoMap.find(t);
1696 if (itemIterator != mTodoMap.end()) { 1702 if (itemIterator != mTodoMap.end()) {
1697 (*itemIterator)->construct(); 1703 (*itemIterator)->construct();
1698 } else { 1704 } else {
1699 if ( type == KOGlobals::EVENTADDED ) { 1705 if ( type == KOGlobals::EVENTADDED ) {
1700 insertTodoItem( t ); 1706 insertTodoItem( t );
1701 } 1707 }
1702 } 1708 }
1703 1709
1704} 1710}
1705 1711
1706void KOTodoView::todoModified(Todo * t , int p ) 1712void KOTodoView::todoModified(Todo * t , int p )
1707{ 1713{
1708 mBlockUpdate = true; 1714 mBlockUpdate = true;
1709 emit todoModifiedSignal ( t, p ); 1715 emit todoModifiedSignal ( t, p );
1710 mBlockUpdate = false; 1716 mBlockUpdate = false;
1711} 1717}
diff --git a/korganizer/kotodoviewitem.cpp b/korganizer/kotodoviewitem.cpp
index 0cf6e4c..bdef94c 100644
--- a/korganizer/kotodoviewitem.cpp
+++ b/korganizer/kotodoviewitem.cpp
@@ -1,526 +1,576 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program 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 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#include <klocale.h> 20#include <klocale.h>
21#include <kdebug.h> 21#include <kdebug.h>
22#include <qapp.h> 22#include <qapp.h>
23#include <kglobal.h> 23#include <kglobal.h>
24 24
25#include <kiconloader.h> 25#include <kiconloader.h>
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 122
123 123
124 keyd = ""; 124 keyd = "";
125 keyt = ""; 125 keyt = "";
126 126
127 if (mTodo->isRunning() ) { 127 if (mTodo->isRunning() ) {
128 QDate d = mTodo->runStart().date(); 128 QDate d = mTodo->runStart().date();
129 QTime t = mTodo->runStart().time(); 129 QTime t = mTodo->runStart().time();
130 skeyt.sprintf("%02d%02d",t.hour(),t.minute()); 130 skeyt.sprintf("%02d%02d",t.hour(),t.minute());
131 skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 131 skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
132 keyd = KGlobal::locale()->formatDate( d , true); 132 keyd = KGlobal::locale()->formatDate( d , true);
133 keyt = KGlobal::locale()->formatTime( t ); 133 keyt = KGlobal::locale()->formatTime( t );
134 134
135 } else { 135 } else {
136 136
137 if (mTodo->hasStartDate()) { 137 if (mTodo->hasStartDate()) {
138 keyd = mTodo->dtStartDateStr(); 138 keyd = mTodo->dtStartDateStr();
139 QDate d = mTodo->dtStart().date(); 139 QDate d = mTodo->dtStart().date();
140 skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 140 skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
141 141
142 if ( !mTodo->doesFloat()) { 142 if ( !mTodo->doesFloat()) {
143 keyt = mTodo->dtStartTimeStr(); 143 keyt = mTodo->dtStartTimeStr();
144 QTime t = mTodo->dtStart().time(); 144 QTime t = mTodo->dtStart().time();
145 skeyt.sprintf("%02d%02d",t.hour(),t.minute()); 145 skeyt.sprintf("%02d%02d",t.hour(),t.minute());
146 146
147 } 147 }
148 148
149 } 149 }
150 } 150 }
151 setText(5,keyd); 151 setText(5,keyd);
152 setText(6,keyt); 152 setText(6,keyt);
153 setSortKey(5,skeyd); 153 setSortKey(5,skeyd);
154 setSortKey(6,skeyt); 154 setSortKey(6,skeyt);
155 155
156 setText(7,mTodo->cancelled() ? i18n("Yes") : i18n("No")); 156 //setText(7,mTodo->cancelled() ? i18n("Yes") : i18n("No"));
157 setText(8,mTodo->categoriesStr()); 157 setText(7,mTodo->categoriesStr());
158 setText(9,KOPrefs::instance()->calName( mTodo->calID())); 158 setText(8,KOPrefs::instance()->calName( mTodo->calID()));
159 159 setText(9, KGlobal::locale()->formatDateTime( mTodo->lastModified(), true, true ));
160 setText(10, KGlobal::locale()->formatDateTime( mTodo->created(), true, true ));
161 setText(11, KGlobal::locale()->formatDateTime( mTodo->lastModifiedSub(), true, true ));
162 QString key;
163 QDate d = mTodo->lastModified().date();
164 QTime t = mTodo->lastModified().time();
165 key.sprintf("%04d%02d%02d%02d%02d%02d",d.year(),d.month(),d.day(),t.hour(),t.minute(),t.second() );
166 setSortKey(9,key);
167 d = mTodo->created().date();
168 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() );
170 setSortKey(10,key);
171 d = mTodo->lastModifiedSub().date();
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
160#if 0 176#if 0
161 // Find sort id in description. It's the text behind the last '#' character 177 // Find sort id in description. It's the text behind the last '#' character
162 // found in the description. White spaces are removed from beginning and end 178 // found in the description. White spaces are removed from beginning and end
163 // of sort id. 179 // of sort id.
164 int pos = mTodo->description().findRev('#'); 180 int pos = mTodo->description().findRev('#');
165 if (pos < 0) { 181 if (pos < 0) {
166 setText(6,""); 182 setText(6,"");
167 } else { 183 } else {
168 QString str = mTodo->description().mid(pos+1); 184 QString str = mTodo->description().mid(pos+1);
169 str.stripWhiteSpace(); 185 str.stripWhiteSpace();
170 setText(6,str); 186 setText(6,str);
171 } 187 }
172#endif 188#endif
173 189
174 m_known = false; 190 m_known = false;
175 m_init = false; 191 m_init = false;
176 192
177 setMyPixmap(); 193 setMyPixmap();
178 194
179} 195}
180void KOTodoViewItem::setMyPixmap() 196void KOTodoViewItem::setMyPixmap()
181{ 197{
182 int size = 5; 198 int size = 5;
183 QPixmap pixi = QPixmap( 1, 1 ); 199 QPixmap pixi = QPixmap( 1, 1 );
184 // if ( !mTodo->isCompleted() && mTodo->hasDueDate() && mTodo->dtDue() < QDateTime::currentDateTime() ) { 200 // if ( !mTodo->isCompleted() && mTodo->hasDueDate() && mTodo->dtDue() < QDateTime::currentDateTime() ) {
185// pixi = SmallIcon("redcross16"); 201// pixi = SmallIcon("redcross16");
186// } else { 202// } else {
187 QPainter p; 203 QPainter p;
188 204
189 int pixSize = 0; 205 int pixSize = 0;
190 QPixmap pPix = QPixmap( size, size ); 206 QPixmap pPix = QPixmap( size, size );
191 if ( mTodo->description().length() > 0 ) { 207 if ( mTodo->description().length() > 0 ) {
192 pixi.resize(size, pixSize+size); 208 pixi.resize(size, pixSize+size);
193 pPix.fill( Qt::darkGreen ); 209 pPix.fill( Qt::darkGreen );
194 p.begin( &pixi ); 210 p.begin( &pixi );
195 p. drawPixmap ( 0, pixSize, pPix); 211 p. drawPixmap ( 0, pixSize, pPix);
196 p.end(); 212 p.end();
197 pixSize += size; 213 pixSize += size;
198 } 214 }
199 if ( mTodo->isAlarmEnabled() && mTodo->alarmEnabled()) { 215 if ( mTodo->isAlarmEnabled() && mTodo->alarmEnabled()) {
200 pixi.resize(size, pixSize+size); 216 pixi.resize(size, pixSize+size);
201 pPix.fill( Qt::red ); 217 pPix.fill( Qt::red );
202 p.begin( &pixi ); 218 p.begin( &pixi );
203 p. drawPixmap ( 0, pixSize, pPix); 219 p. drawPixmap ( 0, pixSize, pPix);
204 p.end(); 220 p.end();
205 pixSize += size; 221 pixSize += size;
206 } 222 }
207 if ( mTodo->doesRecur() ) { 223 if ( mTodo->doesRecur() ) {
208 pixi.resize(size, pixSize+size); 224 pixi.resize(size, pixSize+size);
209 pPix.fill( Qt::blue ); 225 pPix.fill( Qt::blue );
210 p.begin( &pixi ); 226 p.begin( &pixi );
211 p. drawPixmap ( 0, pixSize, pPix); 227 p. drawPixmap ( 0, pixSize, pPix);
212 p.end(); 228 p.end();
213 pixSize += size; 229 pixSize += size;
214 } 230 }
215 // } 231 // }
216 if ( pixi.width() > 1 ) { 232 if ( pixi.width() > 1 ) {
217 setPixmap ( 0,pixi ) ; 233 setPixmap ( 0,pixi ) ;
218 } else { 234 } else {
219 setPixmap ( 0,QPixmap() ) ; 235 setPixmap ( 0,QPixmap() ) ;
220 } 236 }
221} 237}
222void KOTodoViewItem::stateChange(bool state) 238void KOTodoViewItem::stateChange(bool state)
223{ 239{
224 // qDebug("KOTodoViewItem::stateChange %d ", state); 240 // qDebug("KOTodoViewItem::stateChange %d ", state);
225 // do not change setting on startup 241 // do not change setting on startup
226 if ( m_init ) return; 242 if ( m_init ) return;
227 if (isOn()!=state) { 243 if (isOn()!=state) {
228 setOn(state); 244 setOn(state);
229 //qDebug("SETON "); 245 //qDebug("SETON ");
230 return; 246 return;
231 } 247 }
232 if ( mTodo->isCompleted() == state ) { 248 if ( mTodo->isCompleted() == state ) {
233 //qDebug("STATECHANGE:nothing to do "); 249 //qDebug("STATECHANGE:nothing to do ");
234 return; 250 return;
235 } 251 }
236 QString keyd = "=="; 252 QString keyd = "==";
237 QString keyt = "=="; 253 QString keyt = "==";
238 //qDebug("KOTodoViewItem::stateChange %s ", text(0).latin1()); 254 //qDebug("KOTodoViewItem::stateChange %s ", text(0).latin1());
239 if ( mTodo->doesRecur() ){ 255 if ( mTodo->doesRecur() ){
240 QDateTime start = mTodo->dtStart(); 256 QDateTime start = mTodo->dtStart();
241 mTodo->setCompleted(state); 257 mTodo->setCompleted(state);
242 if ( start != mTodo->dtStart() ) { 258 if ( start != mTodo->dtStart() ) {
243 if ( state && !mTodo->isCompleted() ) { 259 if ( state && !mTodo->isCompleted() ) {
244 setOn( false ); 260 setOn( false );
245 state = false; 261 state = false;
246 } 262 }
247 } 263 }
248 } else 264 } else
249 mTodo->setCompleted(state); 265 mTodo->setCompleted(state);
250 266
251 if (state) mTodo->setCompleted(QDateTime::currentDateTime()); 267 if (state) mTodo->setCompleted(QDateTime::currentDateTime());
252 268
253 if (mTodo->hasDueDate()) { 269 if (mTodo->hasDueDate()) {
254 setText(3, mTodo->dtDueDateStr()); 270 setText(3, mTodo->dtDueDateStr());
255 QDate d = mTodo->dtDue().date(); 271 QDate d = mTodo->dtDue().date();
256 keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 272 keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
257 setSortKey(3,keyd); 273 setSortKey(3,keyd);
258 if (mTodo->doesFloat()) { 274 if (mTodo->doesFloat()) {
259 setText(4,""); 275 setText(4,"");
260 } 276 }
261 else { 277 else {
262 setText(4,mTodo->dtDueTimeStr()); 278 setText(4,mTodo->dtDueTimeStr());
263 QTime t = mTodo->dtDue().time(); 279 QTime t = mTodo->dtDue().time();
264 keyt.sprintf("%02d%02d",t.hour(),t.minute()); 280 keyt.sprintf("%02d%02d",t.hour(),t.minute());
265 setSortKey(4,keyt); 281 setSortKey(4,keyt);
266 } 282 }
267 } 283 }
268 if (mTodo->hasStartDate()) { 284 if (mTodo->hasStartDate()) {
269 QString skeyt = "=="; 285 QString skeyt = "==";
270 QString skeyd = "=="; 286 QString skeyd = "==";
271 setText(5, mTodo->dtStartDateStr()); 287 setText(5, mTodo->dtStartDateStr());
272 QDate d = mTodo->dtStart().date(); 288 QDate d = mTodo->dtStart().date();
273 skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 289 skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
274 290
275 if (mTodo->doesFloat()) { 291 if (mTodo->doesFloat()) {
276 setText(6,""); 292 setText(6,"");
277 } 293 }
278 else { 294 else {
279 setText(6,mTodo->dtStartTimeStr()); 295 setText(6,mTodo->dtStartTimeStr());
280 QTime t = mTodo->dtStart().time(); 296 QTime t = mTodo->dtStart().time();
281 skeyt.sprintf("%02d%02d",t.hour(),t.minute()); 297 skeyt.sprintf("%02d%02d",t.hour(),t.minute());
282 298
283 } 299 }
284 setSortKey(5,skeyd); 300 setSortKey(5,skeyd);
285 setSortKey(6,skeyt); 301 setSortKey(6,skeyt);
286 } 302 }
287 if (mTodo->isCompleted()) setSortKey(1,QString::number(9)+keyd+keyt); 303 if (mTodo->isCompleted()) setSortKey(1,QString::number(9)+keyd+keyt);
288 else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); 304 else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt);
289 305
290 setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); 306 setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete())));
291 if (mTodo->percentComplete()<100) { 307 if (mTodo->percentComplete()<100) {
292 if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); 308 if (mTodo->isCompleted()) setSortKey(2,QString::number(999));
293 else setSortKey(2,QString::number(mTodo->percentComplete())); 309 else setSortKey(2,QString::number(mTodo->percentComplete()));
294 } 310 }
295 else { 311 else {
296 if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); 312 if (mTodo->isCompleted()) setSortKey(2,QString::number(999));
297 else setSortKey(2,QString::number(99)); 313 else setSortKey(2,QString::number(99));
298 } 314 }
299 if ( state ) { 315 if ( state ) {
300 QListViewItem * myChild = firstChild(); 316 QListViewItem * myChild = firstChild();
301 KOTodoViewItem *item; 317 KOTodoViewItem *item;
302 while( myChild ) { 318 while( myChild ) {
303 //qDebug("stateCH "); 319 //qDebug("stateCH ");
304 item = static_cast<KOTodoViewItem*>(myChild); 320 item = static_cast<KOTodoViewItem*>(myChild);
305 item->stateChange(state); 321 item->stateChange(state);
306 myChild = myChild->nextSibling(); 322 myChild = myChild->nextSibling();
307 } 323 }
308 } else { 324 } else {
309 QListViewItem * myChild = parent(); 325 QListViewItem * myChild = parent();
310 if ( myChild ) 326 if ( myChild )
311 (static_cast<KOTodoViewItem*>(myChild))->stateChange(state); 327 (static_cast<KOTodoViewItem*>(myChild))->stateChange(state);
312 } 328 }
313 mTodoView->modified(true); 329 mTodoView->modified(true);
314 setMyPixmap(); 330 setMyPixmap();
315 mTodoView->setTodoModified( mTodo ); 331 mTodoView->setTodoModified( mTodo );
316} 332}
317 333
318bool KOTodoViewItem::isAlternate() 334bool KOTodoViewItem::isAlternate()
319{ 335{
320 336#if 0
337 //if ( m_known ) return m_odd;
338 //qDebug("test ");
339 KOTodoViewItem *item = static_cast<KOTodoViewItem *>(itemAbove());
340 if ( item ) {
341 m_known = item->m_known;
342 if ( m_known ) {
343 m_odd = !item->m_odd ;
344 return m_odd;
345 }
346 } else {
347 item = static_cast<KOTodoViewItem *>(itemBelow());
348 if ( item ) {
349 m_known = item->m_known;
350 if ( m_known ) {
351 m_odd = !item->m_odd ;
352 return m_odd;
353 }
354 }
355 }
321 KOTodoListView *lv = static_cast<KOTodoListView *>(listView()); 356 KOTodoListView *lv = static_cast<KOTodoListView *>(listView());
322 if (lv && lv->alternateBackground().isValid()) 357 item = static_cast<KOTodoViewItem *>(lv->firstChild());
358 bool previous = true;
359 qDebug("WHILE ");
360 while ( item ) {
361 item->m_odd = !previous;
362 item->m_known = true;
363 previous = !previous;
364 item = static_cast<KOTodoViewItem *>(item->itemBelow());
365 }
366 return m_odd;
367
368#else
369
370 //KOTodoListView *lv = static_cast<KOTodoListView *>(listView());
371 //if (lv && lv->alternateBackground().isValid())
323 { 372 {
324 KOTodoViewItem *above = 0; 373 KOTodoViewItem *above = static_cast<KOTodoViewItem *>(itemAbove());
325 above = static_cast<KOTodoViewItem *>(itemAbove());
326 m_known = above ? above->m_known : true; 374 m_known = above ? above->m_known : true;
327 if (m_known) 375 if (m_known)
328 { 376 {
329 m_odd = above ? !above->m_odd : false; 377 m_odd = above ? !above->m_odd : false;
330 } 378 }
331 else 379 else
332 { 380 {
333 KOTodoViewItem *item; 381 KOTodoViewItem *item;
334 bool previous = true; 382 bool previous = true;
335 if (QListViewItem::parent()) 383 if (QListViewItem::parent())
336 { 384 {
337 item = static_cast<KOTodoViewItem *>(QListViewItem::parent()); 385 item = static_cast<KOTodoViewItem *>(QListViewItem::parent());
338 if (item) 386 if (item)
339 previous = item->m_odd; 387 previous = item->m_odd;
340 item = static_cast<KOTodoViewItem *>(QListViewItem::parent()->firstChild()); 388 item = static_cast<KOTodoViewItem *>(QListViewItem::parent()->firstChild());
341 } 389 }
342 else 390 else
343 { 391 {
392 KOTodoListView *lv = static_cast<KOTodoListView *>(listView());
344 item = static_cast<KOTodoViewItem *>(lv->firstChild()); 393 item = static_cast<KOTodoViewItem *>(lv->firstChild());
345 } 394 }
346 395
347 while(item) 396 while(item)
348 { 397 {
349 item->m_odd = previous = !previous; 398 item->m_odd = previous = !previous;
350 item->m_known = true; 399 item->m_known = true;
351 item = static_cast<KOTodoViewItem *>(item->nextSibling()); 400 item = static_cast<KOTodoViewItem *>(item->nextSibling());
352 } 401 }
353 } 402 }
354 return m_odd; 403 return m_odd;
355 } 404 }
356 return false; 405 return false;
406#endif
357} 407}
358 408
359void KOTodoViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) 409void KOTodoViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment)
360{ 410{
361 QColorGroup _cg = cg; 411 QColorGroup _cg = cg;
362 QColorGroup::ColorRole role; 412 QColorGroup::ColorRole role;
363 if ( KOPrefs::instance()->mTodoViewUsesForegroundColor && !mTodo->isRunning()) 413 if ( KOPrefs::instance()->mTodoViewUsesForegroundColor && !mTodo->isRunning())
364 role = QColorGroup::Text; 414 role = QColorGroup::Text;
365 else 415 else
366 role = QColorGroup::Base; 416 role = QColorGroup::Base;
367 //#ifndef KORG_NOLVALTERNATION 417 //#ifndef KORG_NOLVALTERNATION
368 if (isAlternate()) 418 if (isAlternate())
369 _cg.setColor(QColorGroup::Base, static_cast< KOTodoListView* >(listView())->alternateBackground()); 419 _cg.setColor(QColorGroup::Base, static_cast< KOTodoListView* >(listView())->alternateBackground());
370 bool setColor = KOPrefs::instance()->mTodoViewUsesCatColors; 420 bool setColor = KOPrefs::instance()->mTodoViewUsesCatColors;
371 QColor colorToSet; 421 QColor colorToSet;
372 if ( column == 0 && mTodo->calID() > 1 ) { 422 if ( column == 0 && mTodo->calID() > 1 ) {
373 setColor = true; 423 setColor = true;
374 colorToSet = KOPrefs::instance()->defaultColor( mTodo->calID() ); 424 colorToSet = KOPrefs::instance()->defaultColor( mTodo->calID() );
375 } else if ( setColor ) { 425 } else if ( setColor ) {
376 QStringList categories = mTodo->categories(); 426 QStringList categories = mTodo->categories();
377 QString cat = categories.first(); 427 QString cat = categories.first();
378 if ( !cat.isEmpty()) { 428 if ( !cat.isEmpty()) {
379 colorToSet = *(KOPrefs::instance()->categoryColor(cat) ); 429 colorToSet = *(KOPrefs::instance()->categoryColor(cat) );
380 } else 430 } else
381 setColor = false; 431 setColor = false;
382 } 432 }
383 bool openMode = !isOpen(); 433 bool openMode = !isOpen();
384 // maybe we are in flat-display-mode 434 // maybe we are in flat-display-mode
385 if ( !firstChild() ) 435 if ( !firstChild() )
386 openMode = false; 436 openMode = false;
387 bool colorRunning = mTodo->isRunning(); 437 bool colorRunning = mTodo->isRunning();
388 if ( ! colorRunning && openMode ) 438 if ( ! colorRunning && openMode )
389 colorRunning = mTodo->hasRunningSub(); 439 colorRunning = mTodo->hasRunningSub();
390 if ( colorRunning ) { 440 if ( colorRunning ) {
391 setColor = true; 441 setColor = true;
392 colorToSet = KOPrefs::instance()->mTodoRunColor; 442 colorToSet = KOPrefs::instance()->mTodoRunColor;
393 } else { 443 } else {
394 int odue = mTodo->hasDueSubTodo( openMode ); 444 int odue = mTodo->hasDueSubTodo( openMode );
395 if (odue == 2) { 445 if (odue == 2) {
396 colorToSet = KOPrefs::instance()->mTodoOverdueColor; 446 colorToSet = KOPrefs::instance()->mTodoOverdueColor;
397 setColor = true; 447 setColor = true;
398 } else if ( odue == 1 ) { 448 } else if ( odue == 1 ) {
399 colorToSet = KOPrefs::instance()->mTodoDueTodayColor; 449 colorToSet = KOPrefs::instance()->mTodoDueTodayColor;
400 setColor = true; 450 setColor = true;
401 } 451 }
402 } 452 }
403 453
404 454
405 if ( setColor ) { 455 if ( setColor ) {
406 _cg.setColor(role,colorToSet ); 456 _cg.setColor(role,colorToSet );
407 if ( role == QColorGroup::Base) { 457 if ( role == QColorGroup::Base) {
408 int rgb = colorToSet.red(); 458 int rgb = colorToSet.red();
409 rgb += colorToSet.blue()/2; 459 rgb += colorToSet.blue()/2;
410 rgb += colorToSet.green(); 460 rgb += colorToSet.green();
411 if ( rgb < 200 ) 461 if ( rgb < 200 )
412 _cg.setColor(QColorGroup::Text,Qt::white ); 462 _cg.setColor(QColorGroup::Text,Qt::white );
413 } 463 }
414 } 464 }
415 //#endif 465 //#endif
416 if ( column > 0 ){ 466 if ( column > 0 ){
417 if ( column == 2 && !KOPrefs::instance()->mTodoViewShowsPercentage ) { 467 if ( column == 2 && !KOPrefs::instance()->mTodoViewShowsPercentage ) {
418 p->save(); 468 p->save();
419 int progress = (int)(( (width-6)*mTodo->percentComplete())/100.0 + 0.5); 469 int progress = (int)(( (width-6)*mTodo->percentComplete())/100.0 + 0.5);
420 470
421 p->fillRect( 0, 0, width, height(), _cg.base() ); // background 471 p->fillRect( 0, 0, width, height(), _cg.base() ); // background
422 // p->setPen(Qt::black ); //border 472 // p->setPen(Qt::black ); //border
423 // p->setBrush( KOPrefs::instance()->mHighlightColorKGlobalSettings::baseColor() ); //filling 473 // p->setBrush( KOPrefs::instance()->mHighlightColorKGlobalSettings::baseColor() ); //filling
424 QColor fc = KOPrefs::instance()->mHighlightColor; 474 QColor fc = KOPrefs::instance()->mHighlightColor;
425 if ( mTodo->percentComplete() == 100 ) 475 if ( mTodo->percentComplete() == 100 )
426 fc = darkGreen; 476 fc = darkGreen;
427 p->drawRect( 2, 2, width-4, height()-4); 477 p->drawRect( 2, 2, width-4, height()-4);
428 p->fillRect( 3, 3, progress, height()-6, 478 p->fillRect( 3, 3, progress, height()-6,
429 fc ); 479 fc );
430 p->restore(); 480 p->restore();
431 } else { 481 } else {
432 QCheckListItem::paintCell(p, _cg, column, width, alignment); 482 QCheckListItem::paintCell(p, _cg, column, width, alignment);
433 } 483 }
434 return; 484 return;
435 } 485 }
436 486
437 int align = alignment; 487 int align = alignment;
438 488
439 if ( !p ) 489 if ( !p )
440 return; 490 return;
441 491
442 p->fillRect( 0, 0, width, height(), _cg.brush( QColorGroup::Base ) ); 492 p->fillRect( 0, 0, width, height(), _cg.brush( QColorGroup::Base ) );
443 493
444 QListView *lv = listView(); 494 QListView *lv = listView();
445 if ( !lv ) 495 if ( !lv )
446 return; 496 return;
447 int marg = 2;//lv->itemMargin(); 497 int marg = 2;//lv->itemMargin();
448 int r = 0; 498 int r = 0;
449 QCheckListItem::Type myType = QCheckListItem::CheckBox; 499 QCheckListItem::Type myType = QCheckListItem::CheckBox;
450 int BoxSize = 20; 500 int BoxSize = 20;
451 int boxOffset = 2; 501 int boxOffset = 2;
452 int xOffset = 2; 502 int xOffset = 2;
453 if (qApp->desktop()->width() < 300 ) { 503 if (qApp->desktop()->width() < 300 ) {
454 BoxSize = 14; 504 BoxSize = 14;
455 boxOffset = -1; 505 boxOffset = -1;
456 xOffset = 1; 506 xOffset = 1;
457 // marg = 0; 507 // marg = 0;
458 } 508 }
459 if ( height() < BoxSize ) { 509 if ( height() < BoxSize ) {
460 boxOffset = boxOffset - ((BoxSize - height())/2) ; 510 boxOffset = boxOffset - ((BoxSize - height())/2) ;
461 // qDebug("boxOffset %d height %d", boxOffset, height() ); 511 // qDebug("boxOffset %d height %d", boxOffset, height() );
462 BoxSize = height(); 512 BoxSize = height();
463 513
464 } 514 }
465 //bool winStyle = lv->style() == WindowsStyle; 515 //bool winStyle = lv->style() == WindowsStyle;
466 516
467 int lineStart = 5; 517 int lineStart = 5;
468 if ( myType == Controller ) { 518 if ( myType == Controller ) {
469 if ( !pixmap( 0 ) ) 519 if ( !pixmap( 0 ) )
470 r += BoxSize + 4; 520 r += BoxSize + 4;
471 } else { 521 } else {
472 ASSERT( lv ); //### 522 ASSERT( lv ); //###
473 //QFontMetrics fm( lv->font() ); 523 //QFontMetrics fm( lv->font() );
474 //int d = fm.height(); 524 //int d = fm.height();
475 int x = 0; 525 int x = 0;
476 int y = (height() - BoxSize) / 2; 526 int y = (height() - BoxSize) / 2;
477 //p->setPen( QPen( _cg.text(), winStyle ? 2 : 1 ) ); 527 //p->setPen( QPen( _cg.text(), winStyle ? 2 : 1 ) );
478 if ( myType == CheckBox ) { 528 if ( myType == CheckBox ) {
479 if ( isEnabled() ) 529 if ( isEnabled() )
480 p->setPen( QPen( _cg.text(), 1 ) ); 530 p->setPen( QPen( _cg.text(), 1 ) );
481 else 531 else
482 p->setPen( QPen( listView()->palette().color( QPalette::Disabled, QColorGroup::Text ), 1 ) ); 532 p->setPen( QPen( listView()->palette().color( QPalette::Disabled, QColorGroup::Text ), 1 ) );
483 p->drawRect( x+marg, y+2, BoxSize-4, BoxSize-4 ); 533 p->drawRect( x+marg, y+2, BoxSize-4, BoxSize-4 );
484 lineStart = x+marg; 534 lineStart = x+marg;
485 ///////////////////// 535 /////////////////////
486 x++; 536 x++;
487 y++; 537 y++;
488 if ( isOn() ) { 538 if ( isOn() ) {
489 QPointArray a( 7*2 ); 539 QPointArray a( 7*2 );
490 int i, xx, yy; 540 int i, xx, yy;
491 xx = x+xOffset+marg+(boxOffset/2); 541 xx = x+xOffset+marg+(boxOffset/2);
492 yy = y+5+boxOffset; 542 yy = y+5+boxOffset;
493 for ( i=0; i<3; i++ ) { 543 for ( i=0; i<3; i++ ) {
494 a.setPoint( 2*i, xx, yy ); 544 a.setPoint( 2*i, xx, yy );
495 a.setPoint( 2*i+1, xx, yy+2 ); 545 a.setPoint( 2*i+1, xx, yy+2 );
496 // qDebug(" "); 546 // qDebug(" ");
497 xx++; yy++; 547 xx++; yy++;
498 } 548 }
499 yy -= 2; 549 yy -= 2;
500 for ( i=3; i<7; i++ ) { 550 for ( i=3; i<7; i++ ) {
501 a.setPoint( 2*i, xx, yy ); 551 a.setPoint( 2*i, xx, yy );
502 a.setPoint( 2*i+1, xx, yy+2 ); 552 a.setPoint( 2*i+1, xx, yy+2 );
503 xx++; yy--; 553 xx++; yy--;
504 } 554 }
505 p->setPen( darkGreen ); 555 p->setPen( darkGreen );
506 p->drawLineSegments( a ); 556 p->drawLineSegments( a );
507 } 557 }
508 //////////////////////// 558 ////////////////////////
509 } 559 }
510 r += BoxSize + 4; 560 r += BoxSize + 4;
511 } 561 }
512 562
513 p->translate( r, 0 ); 563 p->translate( r, 0 );
514 p->setPen( QPen( _cg.text() ) ); 564 p->setPen( QPen( _cg.text() ) );
515 QListViewItem::paintCell( p, _cg, column, width - r, align ); 565 QListViewItem::paintCell( p, _cg, column, width - r, align );
516 if ( mTodo->cancelled () ) { 566 if ( mTodo->cancelled () ) {
517 p->setPen( black ); 567 p->setPen( black );
518 QRect br = p->boundingRect( 1,1,1,1,0,mTodo->summary() ); 568 QRect br = p->boundingRect( 1,1,1,1,0,mTodo->summary() );
519 int wid = br.width() +lineStart; 569 int wid = br.width() +lineStart;
520 if ( wid > width-3 ) 570 if ( wid > width-3 )
521 wid = width-3; 571 wid = width-3;
522 p->drawLine( lineStart, height()/2+1, wid, height()/2+1 ); 572 p->drawLine( lineStart, height()/2+1, wid, height()/2+1 );
523 573
524 } 574 }
525 575
526} 576}