summaryrefslogtreecommitdiffabout
path: root/korganizer/calendarview.cpp
Unidiff
Diffstat (limited to 'korganizer/calendarview.cpp') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/calendarview.cpp148
1 files changed, 77 insertions, 71 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 8385bcc..c1a2f76 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -11,64 +11,70 @@
11 Laszlo Boloni (boloni@cs.purdue.edu) 11 Laszlo Boloni (boloni@cs.purdue.edu)
12 12
13 Copyright (c) 2000, 2001, 2002 13 Copyright (c) 2000, 2001, 2002
14 Cornelius Schumacher <schumacher@kde.org> 14 Cornelius Schumacher <schumacher@kde.org>
15 15
16 This program is free software; you can redistribute it and/or modify 16 This program is free software; you can redistribute it and/or modify
17 it under the terms of the GNU General Public License as published by 17 it under the terms of the GNU General Public License as published by
18 the Free Software Foundation; either version 2 of the License, or 18 the Free Software Foundation; either version 2 of the License, or
19 (at your option) any later version. 19 (at your option) any later version.
20 20
21 This program is distributed in the hope that it will be useful, 21 This program is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of 22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
24 GNU General Public License for more details. 24 GNU General Public License for more details.
25 25
26 You should have received a copy of the GNU General Public License 26 You should have received a copy of the GNU General Public License
27 along with this program; if not, write to the Free Software 27 along with this program; if not, write to the Free Software
28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29*/ 29*/
30 30
31#include <stdlib.h> 31#include <stdlib.h>
32 32
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qradiobutton.h> 34#include <qradiobutton.h>
35#include <qbuttongroup.h> 35#include <q3buttongroup.h>
36#include <qlayout.h> 36#include <qlayout.h>
37#include <qclipboard.h> 37#include <qclipboard.h>
38#include <qcursor.h> 38#include <qcursor.h>
39#include <qmessagebox.h> 39#include <qmessagebox.h>
40#include <qprogressbar.h> 40#include <q3progressbar.h>
41#include <qmultilineedit.h> 41#include <q3multilineedit.h>
42#include <qtimer.h> 42#include <qtimer.h>
43#include <qwidgetstack.h> 43#include <q3widgetstack.h>
44#include <qptrlist.h> 44#include <q3ptrlist.h>
45#include <qregexp.h> 45#include <qregexp.h>
46#include <qgroupbox.h> 46#include <q3groupbox.h>
47#include <qfile.h> 47#include <qfile.h>
48#include <qdir.h> 48#include <qdir.h>
49#ifndef KORG_NOSPLITTER 49#ifndef KORG_NOSPLITTER
50#include <qsplitter.h> 50#include <qsplitter.h>
51//Added by qt3to4:
52#include <Q3VBoxLayout>
53#include <QKeyEvent>
54#include <Q3Frame>
55#include <QLabel>
56#include <Q3ValueList>
51#endif 57#endif
52 58
53#include <kglobal.h> 59#include <kglobal.h>
54#include <kdebug.h> 60#include <kdebug.h>
55#include <kstandarddirs.h> 61#include <kstandarddirs.h>
56#include <kfiledialog.h> 62#include <kfiledialog.h>
57#include <kmessagebox.h> 63#include <kmessagebox.h>
58#include <knotifyclient.h> 64#include <knotifyclient.h>
59#include <kconfig.h> 65#include <kconfig.h>
60 66
61#include <libkdepim/ksyncprefsdialog.h> 67#include <libkdepim/ksyncprefsdialog.h>
62#include <krun.h> 68#include <krun.h>
63#include <kdirwatch.h> 69#include <kdirwatch.h>
64#include <libkdepim/kdatepicker.h> 70#include <libkdepim/kdatepicker.h>
65#include <libkdepim/ksyncprofile.h> 71#include <libkdepim/ksyncprofile.h>
66#include <libkdepim/kpimglobalprefs.h> 72#include <libkdepim/kpimglobalprefs.h>
67 73
68#include <libkcal/vcaldrag.h> 74#include <libkcal/vcaldrag.h>
69#include <libkcal/icaldrag.h> 75#include <libkcal/icaldrag.h>
70#include <libkcal/icalformat.h> 76#include <libkcal/icalformat.h>
71#include <libkcal/vcalformat.h> 77#include <libkcal/vcalformat.h>
72#include <libkcal/scheduler.h> 78#include <libkcal/scheduler.h>
73#include <libkcal/calendarlocal.h> 79#include <libkcal/calendarlocal.h>
74#include <libkcal/journal.h> 80#include <libkcal/journal.h>
@@ -107,61 +113,61 @@
107#include "koagenda.h" 113#include "koagenda.h"
108#include "kodialogmanager.h" 114#include "kodialogmanager.h"
109#include "outgoingdialog.h" 115#include "outgoingdialog.h"
110#include "incomingdialog.h" 116#include "incomingdialog.h"
111#include "datenavigatorcontainer.h" 117#include "datenavigatorcontainer.h"
112#include "statusdialog.h" 118#include "statusdialog.h"
113#include "kdatenavigator.h" 119#include "kdatenavigator.h"
114#include "kotodoview.h" 120#include "kotodoview.h"
115#include "datenavigator.h" 121#include "datenavigator.h"
116#include "resourceview.h" 122#include "resourceview.h"
117#include "navigatorbar.h" 123#include "navigatorbar.h"
118#include "searchdialog.h" 124#include "searchdialog.h"
119#include "mainwindow.h" 125#include "mainwindow.h"
120#include "categoryeditdialog.h" 126#include "categoryeditdialog.h"
121 127
122#include "calendarview.h" 128#include "calendarview.h"
123#ifndef DESKTOP_VERSION 129#ifndef DESKTOP_VERSION
124#include <qtopia/alarmserver.h> 130#include <qtopia/alarmserver.h>
125#endif 131#endif
126#ifndef _WIN32_ 132#ifndef _WIN32_
127#include <stdlib.h> 133#include <stdlib.h>
128#include <stdio.h> 134#include <stdio.h>
129#include <unistd.h> 135#include <unistd.h>
130#else 136#else
131#include <qprocess.h> 137#include <q3process.h>
132#endif 138#endif
133 139
134#ifdef DESKTOP_VERSION 140#ifdef DESKTOP_VERSION
135#include <kabc/stdaddressbook.h> 141#include <kabc/stdaddressbook.h>
136#endif 142#endif
137using namespace KOrg; 143using namespace KOrg;
138using namespace KCal; 144using namespace KCal;
139extern int globalFlagBlockAgenda; 145extern int globalFlagBlockAgenda;
140extern int globalFlagBlockStartup; 146extern int globalFlagBlockStartup;
141 147
142 148
143MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) 149MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, Q3PtrList<Incidence> alarms,QDateTime start ) : Q3TextBrowser(parent)
144 150
145{ 151{
146 mAlarms = alarms; 152 mAlarms = alarms;
147 viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); 153 viewport()->setBackgroundColor( QColor( 255, 255, 255 ) );
148 QString mText = "<table width=\"100%\">\n"; 154 QString mText = "<table width=\"100%\">\n";
149 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; 155 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>";
150#ifdef DESKTOP_VERSION 156#ifdef DESKTOP_VERSION
151 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; 157 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>";
152#else 158#else
153 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; 159 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>";
154#endif 160#endif
155 // mText += "<img src=\""; 161 // mText += "<img src=\"";
156 // mText += ipath; 162 // mText += ipath;
157 // mText += "\">"; 163 // mText += "\">";
158 //mEventDate = QDate::currentDate(); 164 //mEventDate = QDate::currentDate();
159#ifdef DESKTOP_VERSION 165#ifdef DESKTOP_VERSION
160 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; 166 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>";
161#else 167#else
162 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; 168 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>";
163#endif 169#endif
164 //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; 170 //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>";
165 171
166 Incidence * inc = getNextInc( start ); 172 Incidence * inc = getNextInc( start );
167 int time = 0; 173 int time = 0;
@@ -256,89 +262,89 @@ void MissedAlarmTextBrowser::setSource(const QString & n)
256#ifdef DESKTOP_VERSION 262#ifdef DESKTOP_VERSION
257 emit showIncidence(n.mid(8)); 263 emit showIncidence(n.mid(8));
258#else 264#else
259 emit showIncidence(n.mid(6)); 265 emit showIncidence(n.mid(6));
260#endif 266#endif
261 return; 267 return;
262 } else if (n.startsWith("todo:")) { 268 } else if (n.startsWith("todo:")) {
263#ifdef DESKTOP_VERSION 269#ifdef DESKTOP_VERSION
264 emit showIncidence(n.mid(7)); 270 emit showIncidence(n.mid(7));
265#else 271#else
266 emit showIncidence(n.mid(5)); 272 emit showIncidence(n.mid(5));
267#endif 273#endif
268 return; 274 return;
269 } 275 }
270} 276}
271 277
272 278
273class KOBeamPrefs : public QDialog 279class KOBeamPrefs : public QDialog
274{ 280{
275 public: 281 public:
276 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : 282 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) :
277 QDialog( parent, name, true ) 283 QDialog( parent, name, true )
278 { 284 {
279 setCaption( i18n("Beam Options") ); 285 setCaption( i18n("Beam Options") );
280 QVBoxLayout* lay = new QVBoxLayout( this ); 286 Q3VBoxLayout* lay = new Q3VBoxLayout( this );
281 lay->setSpacing( 3 ); 287 lay->setSpacing( 3 );
282 lay->setMargin( 3 ); 288 lay->setMargin( 3 );
283 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); 289 Q3ButtonGroup* format = new Q3ButtonGroup( 1, Qt::Horizontal, i18n("File format"), this );
284 lay->addWidget( format ); 290 lay->addWidget( format );
285 format->setExclusive ( true ) ; 291 format->setExclusive ( true ) ;
286 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); 292 Q3ButtonGroup* time = new Q3ButtonGroup(1, Qt::Horizontal, i18n("Time format"), this );
287 lay->addWidget( time ); time->setExclusive ( true ) ; 293 lay->addWidget( time ); time->setExclusive ( true ) ;
288 vcal = new QRadioButton(" vCalendar ", format ); 294 vcal = new QRadioButton(" vCalendar ", format );
289 ical = new QRadioButton(" iCalendar ", format ); 295 ical = new QRadioButton(" iCalendar ", format );
290 vcal->setChecked( true ); 296 vcal->setChecked( true );
291 tz = new QRadioButton(i18n(" With timezone "), time ); 297 tz = new QRadioButton(i18n(" With timezone "), time );
292 local = new QRadioButton(i18n(" Local time "), time ); 298 local = new QRadioButton(i18n(" Local time "), time );
293 tz->setChecked( true ); 299 tz->setChecked( true );
294 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); 300 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this );
295 lay->addWidget( ok ); 301 lay->addWidget( ok );
296 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 302 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
297 lay->addWidget( cancel ); 303 lay->addWidget( cancel );
298 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 304 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
299 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 305 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
300 resize( 200, 200 ); 306 resize( 200, 200 );
301 } 307 }
302 308
303 bool beamVcal() { return vcal->isChecked(); } 309 bool beamVcal() { return vcal->isChecked(); }
304 bool beamLocal() { return local->isChecked(); } 310 bool beamLocal() { return local->isChecked(); }
305private: 311private:
306 QRadioButton* vcal, *ical, *local, *tz; 312 QRadioButton* vcal, *ical, *local, *tz;
307}; 313};
308class KOCatPrefs : public QDialog 314class KOCatPrefs : public QDialog
309{ 315{
310 public: 316 public:
311 KOCatPrefs( QWidget *parent=0, const char *name=0 ) : 317 KOCatPrefs( QWidget *parent=0, const char *name=0 ) :
312 QDialog( parent, name, true ) 318 QDialog( parent, name, true )
313 { 319 {
314 setCaption( i18n("Manage new Categories") ); 320 setCaption( i18n("Manage new Categories") );
315 QVBoxLayout* lay = new QVBoxLayout( this ); 321 Q3VBoxLayout* lay = new Q3VBoxLayout( this );
316 lay->setSpacing( 3 ); 322 lay->setSpacing( 3 );
317 lay->setMargin( 3 ); 323 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 ); 324 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 ); 325 lay->addWidget( lab );
320 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 326 Q3ButtonGroup* format = new Q3ButtonGroup( 1, Qt::Horizontal, i18n("New categories not in list:"), this );
321 lay->addWidget( format ); 327 lay->addWidget( format );
322 format->setExclusive ( true ) ; 328 format->setExclusive ( true ) ;
323 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 329 addCatBut = new QRadioButton(i18n("Add to category list"), format );
324 new QRadioButton(i18n("Remove from Events/Todos"), format ); 330 new QRadioButton(i18n("Remove from Events/Todos"), format );
325 addCatBut->setChecked( true ); 331 addCatBut->setChecked( true );
326 QPushButton * ok = new QPushButton( i18n("Change category list now!"), this ); 332 QPushButton * ok = new QPushButton( i18n("Change category list now!"), this );
327 lay->addWidget( ok ); 333 lay->addWidget( ok );
328 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 334 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
329 lay->addWidget( cancel ); 335 lay->addWidget( cancel );
330 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 336 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
331 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 337 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
332 resize( 200, 200 ); 338 resize( 200, 200 );
333 } 339 }
334 340
335 bool addCat() { return addCatBut->isChecked(); } 341 bool addCat() { return addCatBut->isChecked(); }
336private: 342private:
337 QRadioButton* addCatBut; 343 QRadioButton* addCatBut;
338}; 344};
339 345
340 346
341 347
342CalendarView::CalendarView( CalendarResources *calendar, 348CalendarView::CalendarView( CalendarResources *calendar,
343 QWidget *parent, const char *name ) 349 QWidget *parent, const char *name )
344 : CalendarViewBase( parent, name ), 350 : CalendarViewBase( parent, name ),
@@ -352,178 +358,178 @@ CalendarView::CalendarView( CalendarResources *calendar,
352 init(); 358 init();
353} 359}
354 360
355CalendarView::CalendarView( Calendar *calendar, 361CalendarView::CalendarView( Calendar *calendar,
356 QWidget *parent, const char *name ) 362 QWidget *parent, const char *name )
357 : CalendarViewBase( parent, name ), 363 : CalendarViewBase( parent, name ),
358 mCalendar( calendar ), 364 mCalendar( calendar ),
359 mResourceManager( 0 ) 365 mResourceManager( 0 )
360{ 366{
361 367
362 mEventEditor = 0; 368 mEventEditor = 0;
363 mTodoEditor = 0; 369 mTodoEditor = 0;
364 init(); 370 init();
365} 371}
366 372
367void CalendarView::init() 373void CalendarView::init()
368{ 374{
369 mMultiResourceSync = false; 375 mMultiResourceSync = false;
370 flag_blockConflict = false; 376 flag_blockConflict = false;
371 flag_blockScrollBar = false; 377 flag_blockScrollBar = false;
372 flag_checkFileFirsttime = true; 378 flag_checkFileFirsttime = true;
373 flag_clearallviewsEventDisplay = false; 379 flag_clearallviewsEventDisplay = false;
374 flag_clearallviewsupdateView = false; 380 flag_clearallviewsupdateView = false;
375 mNextAlarmDateTime = QDateTime::currentDateTime(); 381 mNextAlarmDateTime = QDateTime::currentDateTime();
376 setFocusPolicy (NoFocus ); 382 setFocusPolicy (Qt::NoFocus );
377 mViewerCallerIsSearchDialog = false; 383 mViewerCallerIsSearchDialog = false;
378 mBlockShowDates = false; 384 mBlockShowDates = false;
379 mConflictingEvent = 0; 385 mConflictingEvent = 0;
380 mDatePickerMode = 0; 386 mDatePickerMode = 0;
381 mCurrentSyncDevice = ""; 387 mCurrentSyncDevice = "";
382 mViewManager = new KOViewManager( this ); 388 mViewManager = new KOViewManager( this );
383 mDialogManager = new KODialogManager( this ); 389 mDialogManager = new KODialogManager( this );
384 mEventViewerDialog = 0; 390 mEventViewerDialog = 0;
385 mModified = false; 391 mModified = false;
386 mReadOnly = false; 392 mReadOnly = false;
387 mSelectedIncidence = 0; 393 mSelectedIncidence = 0;
388 mCalPrinter = 0; 394 mCalPrinter = 0;
389 mFilters.setAutoDelete(true); 395 mFilters.setAutoDelete(true);
390 396
391 mCalendar->registerObserver( this ); 397 mCalendar->registerObserver( this );
392 // TODO: Make sure that view is updated, when calendar is changed. 398 // TODO: Make sure that view is updated, when calendar is changed.
393 399
394 mStorage = new FileStorage( mCalendar ); 400 mStorage = new FileStorage( mCalendar );
395 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 401 mNavigator = new DateNavigator( this, "datevav", mViewManager );
396 402
397 QBoxLayout *topLayout = (QBoxLayout*)layout(); 403 Q3BoxLayout *topLayout = (Q3BoxLayout*)layout();
398#ifndef KORG_NOSPLITTER 404#ifndef KORG_NOSPLITTER
399 // create the main layout frames. 405 // create the main layout frames.
400 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 406 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
401 topLayout->addWidget(mPanner); 407 topLayout->addWidget(mPanner);
402 408
403 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 409 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
404 "CalendarView::LeftFrame"); 410 "CalendarView::LeftFrame");
405 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 411 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
406 412
407 mDateNavigator = new DateNavigatorContainer( mLeftSplitter, 413 mDateNavigator = new DateNavigatorContainer( mLeftSplitter,
408 "CalendarView::DateNavigator" ); 414 "CalendarView::DateNavigator" );
409 415
410 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 416 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
411 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 417 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
412 mTodoList->setNavigator( mNavigator ); 418 mTodoList->setNavigator( mNavigator );
413 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 419 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
414 420
415#ifdef KORG_NORESOURCEVIEW 421#ifdef KORG_NORESOURCEVIEW
416 mResourceView = 0; 422 mResourceView = 0;
417#else 423#else
418 if ( mResourceManager ) { 424 if ( mResourceManager ) {
419 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 425 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
420 mResourceView->updateView(); 426 mResourceView->updateView();
421 connect( mResourceView, SIGNAL( resourcesChanged() ), 427 connect( mResourceView, SIGNAL( resourcesChanged() ),
422 SLOT( updateView() ) ); 428 SLOT( updateView() ) );
423 } else { 429 } else {
424 mResourceView = 0; 430 mResourceView = 0;
425 } 431 }
426#endif 432#endif
427 QWidget *rightBox = new QWidget( mPanner ); 433 QWidget *rightBox = new QWidget( mPanner );
428 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 434 Q3BoxLayout *rightLayout = new Q3VBoxLayout( rightBox );
429 435
430 mRightFrame = new QWidgetStack( rightBox ); 436 mRightFrame = new Q3WidgetStack( rightBox );
431 rightLayout->addWidget( mRightFrame, 1 ); 437 rightLayout->addWidget( mRightFrame, 1 );
432 438
433 mLeftFrame = mLeftSplitter; 439 mLeftFrame = mLeftSplitter;
434#else 440#else
435 //QWidget *mainBox = new QWidget( this ); 441 //QWidget *mainBox = new QWidget( this );
436 //QWidget *leftFrame = new QWidget( mainBox ); 442 //QWidget *leftFrame = new QWidget( mainBox );
437 //QBoxLayout * mainBoxLayout; 443 //QBoxLayout * mainBoxLayout;
438 if ( KOPrefs::instance()->mVerticalScreen ) { 444 if ( KOPrefs::instance()->mVerticalScreen ) {
439 //mainBoxLayout = new QVBoxLayout(mainBox); 445 //mainBoxLayout = new QVBoxLayout(mainBox);
440 //leftFrameLayout = new QHBoxLayout(leftFrame ); 446 //leftFrameLayout = new QHBoxLayout(leftFrame );
441 mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); 447 mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this );
442 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 448 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
443 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; 449 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);;
444 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 450 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
445 } else { 451 } else {
446 //mainBoxLayout = new QHBoxLayout(mainBox); 452 //mainBoxLayout = new QHBoxLayout(mainBox);
447 //leftFrameLayout = new QVBoxLayout(leftFrame ); 453 //leftFrameLayout = new QVBoxLayout(leftFrame );
448 mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 454 mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
449 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); 455 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left);
450 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); 456 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame);
451 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 457 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
452 } 458 }
453 mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); 459 mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) );
454 //QBoxLayout * leftFrameLayout; 460 //QBoxLayout * leftFrameLayout;
455 topLayout->addWidget( mMainFrame ); 461 topLayout->addWidget( mMainFrame );
456#ifdef DESKTOP_VERSION 462#ifdef DESKTOP_VERSION
457 mDateScrollBar = new QScrollBar ( 1, 365, 1,30, 200,QScrollBar::Horizontal, this ); 463 mDateScrollBar = new QScrollBar ( 1, 365, 1,30, 200,Qt::Horizontal, this );
458 topLayout->addWidget( mDateScrollBar ); 464 topLayout->addWidget( mDateScrollBar );
459 connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) ); 465 connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) );
460 if ( QApplication::desktop()->width() < 800 ) 466 if ( QApplication::desktop()->width() < 800 )
461 mDateScrollBar->hide(); 467 mDateScrollBar->hide();
462#endif 468#endif
463 //mainBoxLayout->addWidget (mLeftFrame); 469 //mainBoxLayout->addWidget (mLeftFrame);
464 mDateNavigator = new DateNavigatorContainer( mLeftFrame, 470 mDateNavigator = new DateNavigatorContainer( mLeftFrame,
465 "CalendarView::DateNavigator" ); 471 "CalendarView::DateNavigator" );
466#if 0 472#if 0
467 // FIXME 473 // FIXME
468 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, 474 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE,
469 "CalendarView::DateNavigator", QDate::currentDate()); 475 "CalendarView::DateNavigator", QDate::currentDate());
470#endif 476#endif
471 // mDateNavigator->blockSignals( true ); 477 // mDateNavigator->blockSignals( true );
472 //leftFrameLayout->addWidget( mDateNavigator ); 478 //leftFrameLayout->addWidget( mDateNavigator );
473 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); 479 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall");
474 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); 480 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView");
475 mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); 481 mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView");
476 connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); 482 connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) );
477 connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); 483 connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) );
478 connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) ); 484 connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),this, SLOT( setCalReadOnly(int,bool)) );
479 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); 485 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) );
480 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); 486 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) );
481 connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); 487 connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) );
482 connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); 488 connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) );
483 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); 489 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) );
484 connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() )); 490 connect( mCalEditView, SIGNAL( checkCalendar() ),this, SLOT( checkFiles() ));
485 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); 491 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) );
486 connect( mCalEditView, SIGNAL( requestCalendarInfo( int ) ),this, SLOT( displayCalendarInfo( int ) ) ); 492 connect( mCalEditView, SIGNAL( requestCalendarInfo( int ) ),this, SLOT( displayCalendarInfo( int ) ) );
487 493
488 494
489 mTodoList->setNavigator( mNavigator ); 495 mTodoList->setNavigator( mNavigator );
490#if 0 496#if 0
491 if ( QApplication::desktop()->width() < 480 ) { 497 if ( QApplication::desktop()->width() < 480 ) {
492 leftFrameLayout->addWidget(mFilterView); 498 leftFrameLayout->addWidget(mFilterView);
493 leftFrameLayout->addWidget(mTodoList, 2 ); 499 leftFrameLayout->addWidget(mTodoList, 2 );
494 500
495 } else { 501 } else {
496 leftFrameLayout->addWidget(mTodoList,2 ); 502 leftFrameLayout->addWidget(mTodoList,2 );
497 leftFrameLayout->addWidget(mFilterView ); 503 leftFrameLayout->addWidget(mFilterView );
498 } 504 }
499#endif 505#endif
500 mFilterView->hide(); 506 mFilterView->hide();
501 mCalEditView->hide(); 507 mCalEditView->hide();
502 QWidget *rightBox = new QWidget( mMainFrame ); 508 QWidget *rightBox = new QWidget( mMainFrame );
503 //mainBoxLayout->addWidget ( rightBox, 10 ); 509 //mainBoxLayout->addWidget ( rightBox, 10 );
504 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 510 Q3BoxLayout *rightLayout = new Q3VBoxLayout( rightBox );
505 mRightFrame = new QWidgetStack( rightBox ); 511 mRightFrame = new Q3WidgetStack( rightBox );
506 rightLayout->addWidget( mRightFrame, 10 ); 512 rightLayout->addWidget( mRightFrame, 10 );
507 513
508 //mLeftFrame = (QWidget *)leftFrame; 514 //mLeftFrame = (QWidget *)leftFrame;
509 if ( KOPrefs::instance()->mVerticalScreen ) { 515 if ( KOPrefs::instance()->mVerticalScreen ) {
510 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); 516 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() );
511 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); 517 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() );
512 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 518 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
513 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 519 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
514 } else { 520 } else {
515 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); 521 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() );
516 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 522 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
517 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 523 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
518 } 524 }
519 if ( !KOPrefs::instance()->mShowDateNavigator) 525 if ( !KOPrefs::instance()->mShowDateNavigator)
520 mDateNavigator->hide(); 526 mDateNavigator->hide();
521 //qDebug("Calendarview Size %d %d ", width(), height()); 527 //qDebug("Calendarview Size %d %d ", width(), height());
522#endif 528#endif
523 529
524 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 530 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
525 SLOT( showDates( const KCal::DateList & ) ) ); 531 SLOT( showDates( const KCal::DateList & ) ) );
526 532
527 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 533 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
528 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 534 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
529 535
@@ -595,51 +601,51 @@ void CalendarView::init()
595 this, SLOT ( todo_resub( Todo *,Todo * ) ) ); 601 this, SLOT ( todo_resub( Todo *,Todo * ) ) );
596 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 602 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
597 SLOT( updateTodo( Todo *, int ) ) ); 603 SLOT( updateTodo( Todo *, int ) ) );
598 connect( this, SIGNAL( todoModified( Todo *, int )), this, 604 connect( this, SIGNAL( todoModified( Todo *, int )), this,
599 SLOT( changeTodoDisplay( Todo *, int ) ) ); 605 SLOT( changeTodoDisplay( Todo *, int ) ) );
600 606
601 607
602 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 608 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
603 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 609 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
604 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 610 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
605 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 611 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
606 612
607 613
608 614
609 615
610 616
611 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 617 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
612 SLOT(checkClipboard())); 618 SLOT(checkClipboard()));
613 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 619 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
614 SLOT( processTodoListSelection( Incidence * ) ) ); 620 SLOT( processTodoListSelection( Incidence * ) ) );
615 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 621 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
616 622
617 // kdDebug() << "CalendarView::CalendarView() done" << endl; 623 // kdDebug() << "CalendarView::CalendarView() done" << endl;
618 624
619 mDateFrame = new QVBox(0,0,WType_Popup); 625 mDateFrame = new Q3VBox(0,0,Qt::WType_Popup);
620 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 626 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
621 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 627 mDateFrame->setFrameStyle( Q3Frame::WinPanel |Q3Frame::Raised );
622 mDateFrame->setLineWidth(3); 628 mDateFrame->setLineWidth(3);
623 mDateFrame->hide(); 629 mDateFrame->hide();
624 mDateFrame->setCaption( i18n( "Pick a date to display")); 630 mDateFrame->setCaption( i18n( "Pick a date to display"));
625 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 631 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
626 632
627 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 633 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
628 634
629 mEventEditor = mDialogManager->getEventEditor(); 635 mEventEditor = mDialogManager->getEventEditor();
630 mTodoEditor = mDialogManager->getTodoEditor(); 636 mTodoEditor = mDialogManager->getTodoEditor();
631 637
632 mFlagEditDescription = false; 638 mFlagEditDescription = false;
633 639
634 mSuspendTimer = new QTimer( this ); 640 mSuspendTimer = new QTimer( this );
635 mAlarmTimer = new QTimer( this ); 641 mAlarmTimer = new QTimer( this );
636 mRecheckAlarmTimer = new QTimer( this ); 642 mRecheckAlarmTimer = new QTimer( this );
637 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 643 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
638 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 644 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
639 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 645 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
640 mAlarmDialog = new AlarmDialog( this ); 646 mAlarmDialog = new AlarmDialog( this );
641 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 647 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
642 mAlarmDialog->setServerNotification( false ); 648 mAlarmDialog->setServerNotification( false );
643 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 649 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
644 650
645 651
@@ -648,65 +654,65 @@ void CalendarView::init()
648 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), 654 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)),
649 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 655 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
650#endif 656#endif
651 mDateNavigator->setCalendar( mCalendar ); 657 mDateNavigator->setCalendar( mCalendar );
652} 658}
653 659
654 660
655CalendarView::~CalendarView() 661CalendarView::~CalendarView()
656{ 662{
657 // kdDebug() << "~CalendarView()" << endl; 663 // kdDebug() << "~CalendarView()" << endl;
658 //qDebug("CalendarView::~CalendarView() "); 664 //qDebug("CalendarView::~CalendarView() ");
659 delete mDialogManager; 665 delete mDialogManager;
660 delete mViewManager; 666 delete mViewManager;
661 delete mStorage; 667 delete mStorage;
662 delete mDateFrame ; 668 delete mDateFrame ;
663 delete mEventViewerDialog; 669 delete mEventViewerDialog;
664 //kdDebug() << "~CalendarView() done" << endl; 670 //kdDebug() << "~CalendarView() done" << endl;
665} 671}
666 672
667 673
668void CalendarView::nextConflict( bool all, bool allday ) 674void CalendarView::nextConflict( bool all, bool allday )
669{ 675{
670 if ( flag_blockConflict ) return; 676 if ( flag_blockConflict ) return;
671 flag_blockConflict = true; 677 flag_blockConflict = true;
672 QPtrList<Event> testlist = mCalendar->events(); 678 Q3PtrList<Event> testlist = mCalendar->events();
673 Event * test = testlist.first(); 679 Event * test = testlist.first();
674 while ( test ) { 680 while ( test ) {
675 test->setTagged( false ); 681 test->setTagged( false );
676 test = testlist.next(); 682 test = testlist.next();
677 } 683 }
678 QTime st ( 0,0,0); 684 QTime st ( 0,0,0);
679 if ( mViewManager->currentView() == mViewManager->agendaView() ) 685 if ( mViewManager->currentView() == mViewManager->agendaView() )
680 st = mViewManager->agendaView()->agenda()->getEndTime(); 686 st = mViewManager->agendaView()->agenda()->getEndTime();
681 //qDebug("time %s ", st.toString().latin1()); 687 //qDebug("time %s ", st.toString().latin1());
682 QDateTime startDT = QDateTime (mNavigator->selectedDates().first(),st); 688 QDateTime startDT = QDateTime (mNavigator->selectedDates().first(),st);
683 QDateTime conflict; 689 QDateTime conflict;
684 QDateTime retVal; 690 QDateTime retVal;
685 bool found = false; 691 bool found = false;
686 Event * cE = 0; 692 Event * cE = 0;
687 Event * cE2 = 0; 693 Event * cE2 = 0;
688 QPtrList<Event> testlist2 = testlist; 694 Q3PtrList<Event> testlist2 = testlist;
689 test = testlist.first(); 695 test = testlist.first();
690 bool skip = false; 696 bool skip = false;
691 topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); 697 topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") );
692 //QTime tm; 698 //QTime tm;
693 //tm.start(); 699 //tm.start();
694 while ( test ) { 700 while ( test ) {
695 qApp->processEvents(); 701 qApp->processEvents();
696 skip = false; 702 skip = false;
697 if ( !all ) skip = ( allday != test->doesFloat() ); 703 if ( !all ) skip = ( allday != test->doesFloat() );
698 if ( !skip ) { 704 if ( !skip ) {
699 if ( found ) 705 if ( found )
700 skip = !test->matchTime( &startDT, &conflict ); 706 skip = !test->matchTime( &startDT, &conflict );
701 else 707 else
702 skip = !test->matchTime( &startDT, 0 ); 708 skip = !test->matchTime( &startDT, 0 );
703 } 709 }
704 if ( !skip ) { 710 if ( !skip ) {
705 Event * test2 = testlist2.first(); 711 Event * test2 = testlist2.first();
706 while ( test2 ) { 712 while ( test2 ) {
707 skip = test2->isTagged(); 713 skip = test2->isTagged();
708 if ( !skip && !all ) skip = ( allday != test2->doesFloat() ); 714 if ( !skip && !all ) skip = ( allday != test2->doesFloat() );
709 if ( !skip ) { 715 if ( !skip ) {
710 if ( found ) 716 if ( found )
711 skip = !test2->matchTime( &startDT, &conflict ); 717 skip = !test2->matchTime( &startDT, &conflict );
712 else 718 else
@@ -814,102 +820,102 @@ void CalendarView::scrollBarValue(int val )
814} 820}
815void CalendarView::updateView(const QDate &start, const QDate &end) 821void CalendarView::updateView(const QDate &start, const QDate &end)
816{ 822{
817#ifdef DESKTOP_VERSION 823#ifdef DESKTOP_VERSION
818 if ( ! mDateScrollBar->draggingSlider () ) { 824 if ( ! mDateScrollBar->draggingSlider () ) {
819 int dof = start.dayOfYear(); 825 int dof = start.dayOfYear();
820 //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() ); 826 //qDebug("dof %d day %d val %d ", dof, start.dayOfYear(),mDateScrollBar->value() );
821 if ( dof != mDateScrollBar->value() ) { 827 if ( dof != mDateScrollBar->value() ) {
822 mDateScrollBar->blockSignals( true ); 828 mDateScrollBar->blockSignals( true );
823 mDateScrollBar->setValue( start.dayOfYear()); 829 mDateScrollBar->setValue( start.dayOfYear());
824 mDateScrollBar->blockSignals( false ); 830 mDateScrollBar->blockSignals( false );
825 } 831 }
826 } 832 }
827#endif 833#endif
828 mTodoList->updateView(); 834 mTodoList->updateView();
829 mViewManager->updateView(start, end); 835 mViewManager->updateView(start, end);
830 //mDateNavigator->updateView(); 836 //mDateNavigator->updateView();
831} 837}
832 838
833 839
834 840
835void CalendarView::checkFiles() 841void CalendarView::checkFiles()
836{ 842{
837 QString message; 843 QString message;
838 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 844 Q3PtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
839 KopiCalendarFile * cal = calendars.first(); 845 KopiCalendarFile * cal = calendars.first();
840 while ( cal ) { 846 while ( cal ) {
841 if ( cal->mErrorOnLoad ) { 847 if ( cal->mErrorOnLoad ) {
842 message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n"; 848 message += cal->mName +"\n"+KGlobal::formatMessage ( "(" +i18n( "Filepath: ")+ cal->mFileName+")" ,0 )+"\n";
843 } 849 }
844 cal = calendars.next(); 850 cal = calendars.next();
845 } 851 }
846 if ( !message.isEmpty() ) { 852 if ( !message.isEmpty() ) {
847 message = KGlobal::formatMessage( i18n("Calendar(s) not loaded:"),0 )+"\n" + message +KGlobal::formatMessage(i18n("You can try to reload the calendar in the Resource View!"),0); 853 message = KGlobal::formatMessage( i18n("Calendar(s) not loaded:"),0 )+"\n" + message +KGlobal::formatMessage(i18n("You can try to reload the calendar in the Resource View!"),0);
848 KMessageBox::error(this,message, i18n("Loading of calendar(s) failed")); 854 KMessageBox::error(this,message, i18n("Loading of calendar(s) failed"));
849 } 855 }
850 if ( flag_checkFileFirsttime ) { 856 if ( flag_checkFileFirsttime ) {
851 flag_checkFileFirsttime = false; 857 flag_checkFileFirsttime = false;
852 QTimer::singleShot( 2000, this, SLOT ( checkAlarms() )); 858 QTimer::singleShot( 2000, this, SLOT ( checkAlarms() ));
853 } 859 }
854} 860}
855void CalendarView::checkAlarms() 861void CalendarView::checkAlarms()
856{ 862{
857 KConfig *config = KOGlobals::config(); 863 KConfig *config = KOGlobals::config();
858 config->setGroup( "AppRun" ); 864 config->setGroup( "AppRun" );
859 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); 865 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) );
860 int daysto = dt.daysTo( QDate::currentDate() ); 866 int daysto = dt.daysTo( (QDateTime)QDate::currentDate() );
861 int days = config->readNumEntry( "LatestProgramStopDays" , daysto); 867 int days = config->readNumEntry( "LatestProgramStopDays" , daysto);
862 dt = dt.addDays( days ); 868 dt = dt.addDays( days );
863 int secto = dt.secsTo( QDateTime::currentDateTime() ); 869 int secto = dt.secsTo( QDateTime::currentDateTime() );
864 int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; 870 int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30;
865 //qDebug("KO: Reading program stop %d ", secs); 871 //qDebug("KO: Reading program stop %d ", secs);
866 //secs -= ( 3600 * 24*3 ); // debug only 872 //secs -= ( 3600 * 24*3 ); // debug only
867 QDateTime latest = dt.addSecs ( secs ); 873 QDateTime latest = dt.addSecs ( secs );
868 qDebug("KO: Last termination on %s ", latest.toString().latin1()); 874 qDebug("KO: Last termination on %s ", latest.toString().latin1());
869 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); 875 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() );
870 QPtrList<Incidence> el = mCalendar->rawIncidences(); 876 Q3PtrList<Incidence> el = mCalendar->rawIncidences();
871 QPtrList<Incidence> al; 877 Q3PtrList<Incidence> al;
872 Incidence* inL = el.first(); 878 Incidence* inL = el.first();
873 QDateTime cur = QDateTime::currentDateTime().addSecs(-59); 879 QDateTime cur = QDateTime::currentDateTime().addSecs(-59);
874 qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); 880 qDebug("KO: Checking alarm until %s ", cur.toString().latin1());
875 while ( inL ) { 881 while ( inL ) {
876 bool ok = false; 882 bool ok = false;
877 int offset = 0; 883 int offset = 0;
878 QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; 884 QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ;
879 if ( ok ) { 885 if ( ok ) {
880 //qDebug("OK %s",next.toString().latin1()); 886 //qDebug("OK %s",next.toString().latin1());
881 if ( next < cur ) { 887 if ( next < cur ) {
882 al.append( inL ); 888 al.append( inL );
883 //qDebug("found missed alarm: %s ", inL->summary().latin1() ); 889 //qDebug("found missed alarm: %s ", inL->summary().latin1() );
884 } 890 }
885 } 891 }
886 inL = el.next(); 892 inL = el.next();
887 } 893 }
888 if ( al.count() ) { 894 if ( al.count() ) {
889 QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); 895 QDialog* dia = new QDialog( this, "huhu", false, Qt::WDestructiveClose | Qt::WStyle_StaysOnTop );
890 dia->setCaption( i18n("KO/Pi: Missing alarms!") ); 896 dia->setCaption( i18n("KO/Pi: Missing alarms!") );
891 QVBoxLayout* lay = new QVBoxLayout( dia ); 897 Q3VBoxLayout* lay = new Q3VBoxLayout( dia );
892 lay->setSpacing( 0 ); 898 lay->setSpacing( 0 );
893 lay->setMargin( 0 ); 899 lay->setMargin( 0 );
894 MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); 900 MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest );
895 connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); 901 connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) ));
896 lay->addWidget( matb ); 902 lay->addWidget( matb );
897 if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { 903 if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) {
898 int wid = 210; 904 int wid = 210;
899 int x = QApplication::desktop()->width() - wid - 7; 905 int x = QApplication::desktop()->width() - wid - 7;
900 int y = QApplication::desktop()->height() - wid - 70; 906 int y = QApplication::desktop()->height() - wid - 70;
901 dia->setGeometry ( x,y,wid,wid); 907 dia->setGeometry ( x,y,wid,wid);
902 } else { 908 } else {
903 int si = 220; 909 int si = 220;
904 if ( QApplication::desktop()->width() > 470 ) 910 if ( QApplication::desktop()->width() > 470 )
905 si = 400; 911 si = 400;
906 dia->resize(si,si/2); 912 dia->resize(si,si/2);
907 } 913 }
908 dia->setBackgroundColor( QColor( 255, 255, 255 ) ); 914 dia->setBackgroundColor( QColor( 255, 255, 255 ) );
909 dia->show(); 915 dia->show();
910 916
911 } 917 }
912#if 0 918#if 0
913 // for creating timetracker test data 919 // for creating timetracker test data
914 qDebug("CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCc "); 920 qDebug("CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCc ");
915 Todo * nt; 921 Todo * nt;
@@ -1195,49 +1201,49 @@ void CalendarView::computeAlarm( QString msg )
1195 return; 1201 return;
1196 } 1202 }
1197 if ( mess.left( 10 ) == "proc_alarm") { 1203 if ( mess.left( 10 ) == "proc_alarm") {
1198 bool error = false; 1204 bool error = false;
1199 int len = mess.mid( 10 ).find("+++"); 1205 int len = mess.mid( 10 ).find("+++");
1200 if ( len < 2 ) 1206 if ( len < 2 )
1201 error = true; 1207 error = true;
1202 else { 1208 else {
1203 tempfilename = mess.mid( 10, len ); 1209 tempfilename = mess.mid( 10, len );
1204 if ( !QFile::exists( tempfilename ) ) 1210 if ( !QFile::exists( tempfilename ) )
1205 error = true; 1211 error = true;
1206 } 1212 }
1207 if ( error ) { 1213 if ( error ) {
1208 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 1214 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
1209 mAlarmMessage += mess.mid( 10+len+3+9 ); 1215 mAlarmMessage += mess.mid( 10+len+3+9 );
1210 } else { 1216 } else {
1211 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 1217 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
1212 //qDebug("-----system command %s ",tempfilename.latin1() ); 1218 //qDebug("-----system command %s ",tempfilename.latin1() );
1213#ifndef _WIN32_ 1219#ifndef _WIN32_
1214 if ( vfork () == 0 ) { 1220 if ( vfork () == 0 ) {
1215 execl ( tempfilename.latin1(), 0 ); 1221 execl ( tempfilename.latin1(), 0 );
1216 return; 1222 return;
1217 } 1223 }
1218#else 1224#else
1219 QProcess* p = new QProcess(); 1225 Q3Process* p = new Q3Process();
1220 p->addArgument( tempfilename.latin1() ); 1226 p->addArgument( tempfilename.latin1() );
1221 p->start(); 1227 p->start();
1222 return; 1228 return;
1223#endif 1229#endif
1224 1230
1225 return; 1231 return;
1226 } 1232 }
1227 1233
1228 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 1234 //qDebug("+++++++system command %s ",tempfilename.latin1() );
1229 } 1235 }
1230 if ( mess.left( 11 ) == "audio_alarm") { 1236 if ( mess.left( 11 ) == "audio_alarm") {
1231 bool error = false; 1237 bool error = false;
1232 int len = mess.mid( 11 ).find("+++"); 1238 int len = mess.mid( 11 ).find("+++");
1233 if ( len < 2 ) 1239 if ( len < 2 )
1234 error = true; 1240 error = true;
1235 else { 1241 else {
1236 tempfilename = mess.mid( 11, len ); 1242 tempfilename = mess.mid( 11, len );
1237 if ( !QFile::exists( tempfilename ) ) 1243 if ( !QFile::exists( tempfilename ) )
1238 error = true; 1244 error = true;
1239 } 1245 }
1240 if ( ! error ) { 1246 if ( ! error ) {
1241 filename = tempfilename; 1247 filename = tempfilename;
1242 } 1248 }
1243 mAlarmMessage = mess.mid( 11+len+3+9 ); 1249 mAlarmMessage = mess.mid( 11+len+3+9 );
@@ -1245,80 +1251,80 @@ void CalendarView::computeAlarm( QString msg )
1245 } 1251 }
1246 if ( mess.left( 9 ) == "cal_alarm") { 1252 if ( mess.left( 9 ) == "cal_alarm") {
1247 mAlarmMessage = mess.mid( 9 ) ; 1253 mAlarmMessage = mess.mid( 9 ) ;
1248 } 1254 }
1249 1255
1250 startAlarm( mAlarmMessage, filename ); 1256 startAlarm( mAlarmMessage, filename );
1251 1257
1252 1258
1253} 1259}
1254 1260
1255void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 1261void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
1256{ 1262{
1257 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 1263 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
1258 1264
1259 mSuspendAlarmNotification = noti; 1265 mSuspendAlarmNotification = noti;
1260 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 1266 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
1261 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 1267 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
1262 mSuspendTimer->start( ms , true ); 1268 mSuspendTimer->start( ms , true );
1263#ifdef DESKTOP_VERSION 1269#ifdef DESKTOP_VERSION
1264 if ( QApplication::desktop()->width() < 1024 ) { 1270 if ( QApplication::desktop()->width() < 1024 ) {
1265 QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti; 1271 QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti;
1266 //qDebug("nextsuspendalarm = \n%s ",mess.latin1() ); 1272 //qDebug("nextsuspendalarm = \n%s ",mess.latin1() );
1267 QString fn = QDir::homeDirPath() + "/.kopi_suspend_alarm"; 1273 QString fn = QDir::homeDirPath() + "/.kopi_suspend_alarm";
1268 QFile file( fn ); 1274 QFile file( fn );
1269 if (!file.open( IO_WriteOnly ) ) { 1275 if (!file.open( QIODevice::WriteOnly ) ) {
1270 qDebug("KO: Error writing next suspend alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1()); 1276 qDebug("KO: Error writing next suspend alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1());
1271 } else { 1277 } else {
1272 QTextStream ts( &file ); 1278 Q3TextStream ts( &file );
1273 ts << mess; 1279 ts << mess;
1274 file.close(); 1280 file.close();
1275 } 1281 }
1276 } 1282 }
1277#endif 1283#endif
1278 1284
1279} 1285}
1280 1286
1281void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 1287void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
1282{ 1288{
1283 mNextAlarmDateTime = qdt; 1289 mNextAlarmDateTime = qdt;
1284 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 1290 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
1285 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 1291 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
1286#ifndef DESKTOP_VERSION 1292#ifndef DESKTOP_VERSION
1287 AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); 1293 AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() );
1288#endif 1294#endif
1289 return; 1295 return;
1290 } 1296 }
1291#ifdef DESKTOP_VERSION 1297#ifdef DESKTOP_VERSION
1292 if ( QApplication::desktop()->width() < 1024 ) { 1298 if ( QApplication::desktop()->width() < 1024 ) {
1293 QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti; 1299 QString mess = qdt.toString( "yyyy-MM-dd hh:mm:ss" ) + "\n" + noti;
1294 //qDebug("nextalarm = \n%s ",mess.latin1() ); 1300 //qDebug("nextalarm = \n%s ",mess.latin1() );
1295 QString fn = QDir::homeDirPath() + "/.kopi_next_alarm"; 1301 QString fn = QDir::homeDirPath() + "/.kopi_next_alarm";
1296 QFile file( fn ); 1302 QFile file( fn );
1297 if (!file.open( IO_WriteOnly ) ) { 1303 if (!file.open( QIODevice::WriteOnly ) ) {
1298 qDebug("KO: Error writing next alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1()); 1304 qDebug("KO: Error writing next alarm file %s\nContent: \n%s ", fn.latin1(), mess.latin1());
1299 } else { 1305 } else {
1300 QTextStream ts( &file ); 1306 Q3TextStream ts( &file );
1301 ts << mess; 1307 ts << mess;
1302 file.close(); 1308 file.close();
1303 } 1309 }
1304 } 1310 }
1305#endif 1311#endif
1306 int maxSec; 1312 int maxSec;
1307 //maxSec = 5; //testing only 1313 //maxSec = 5; //testing only
1308 maxSec = 86400+3600; // one day+1hour 1314 maxSec = 86400+3600; // one day+1hour
1309 mAlarmNotification = noti; 1315 mAlarmNotification = noti;
1310 int sec = QDateTime::currentDateTime().secsTo( qdt ); 1316 int sec = QDateTime::currentDateTime().secsTo( qdt );
1311 if ( sec > maxSec ) { 1317 if ( sec > maxSec ) {
1312 mRecheckAlarmTimer->start( maxSec * 1000 ); 1318 mRecheckAlarmTimer->start( maxSec * 1000 );
1313 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 1319 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
1314 return; 1320 return;
1315 } else { 1321 } else {
1316 mRecheckAlarmTimer->stop(); 1322 mRecheckAlarmTimer->stop();
1317 } 1323 }
1318 //qDebug("Alarm timer started with secs: %d ", sec); 1324 //qDebug("Alarm timer started with secs: %d ", sec);
1319 mAlarmTimer->start( sec * 1000 , true ); 1325 mAlarmTimer->start( sec * 1000 , true );
1320 1326
1321} 1327}
1322// called by mRecheckAlarmTimer to get next alarm 1328// called by mRecheckAlarmTimer to get next alarm
1323// we need this, because a QTimer has only a max range of 25 days 1329// we need this, because a QTimer has only a max range of 25 days
1324void CalendarView::recheckTimerAlarm() 1330void CalendarView::recheckTimerAlarm()
@@ -1549,104 +1555,104 @@ Event* CalendarView::getLastSyncEvent()
1549 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 1555 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
1550 if (!lse) { 1556 if (!lse) {
1551 qDebug("KO: New last Syncevent created for local: %s",mCurrentSyncDevice.latin1() ); 1557 qDebug("KO: New last Syncevent created for local: %s",mCurrentSyncDevice.latin1() );
1552 lse = new Event(); 1558 lse = new Event();
1553 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 1559 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
1554 QString sum = ""; 1560 QString sum = "";
1555 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 1561 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
1556 sum = "E: "; 1562 sum = "E: ";
1557 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 1563 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
1558 lse->setDtStart( mLastCalendarSync ); 1564 lse->setDtStart( mLastCalendarSync );
1559 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 1565 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
1560 lse->setCategories( i18n("SyncEvent") ); 1566 lse->setCategories( i18n("SyncEvent") );
1561 lse->setReadOnly( true ); 1567 lse->setReadOnly( true );
1562 lse->setCalID( 1 ); 1568 lse->setCalID( 1 );
1563 mCalendar->addEvent( lse ); 1569 mCalendar->addEvent( lse );
1564 } else 1570 } else
1565 qDebug("KO: Last Syncevent on local found"); 1571 qDebug("KO: Last Syncevent on local found");
1566 1572
1567 return lse; 1573 return lse;
1568 1574
1569} 1575}
1570 1576
1571// we check, if the to delete event has a id for a profile 1577// we check, if the to delete event has a id for a profile
1572// if yes, we set this id in the profile to delete 1578// if yes, we set this id in the profile to delete
1573void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 1579void CalendarView::checkExternSyncEvent( Q3PtrList<Event> lastSync , Incidence* toDelete )
1574{ 1580{
1575 if ( lastSync.count() == 0 ) { 1581 if ( lastSync.count() == 0 ) {
1576 //qDebug(" lastSync.count() == 0"); 1582 //qDebug(" lastSync.count() == 0");
1577 return; 1583 return;
1578 } 1584 }
1579 if ( toDelete->typeID() == journalID ) 1585 if ( toDelete->typeID() == journalID )
1580 return; 1586 return;
1581 1587
1582 Event* eve = lastSync.first(); 1588 Event* eve = lastSync.first();
1583 1589
1584 while ( eve ) { 1590 while ( eve ) {
1585 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 1591 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
1586 if ( !id.isEmpty() ) { 1592 if ( !id.isEmpty() ) {
1587 QString des = eve->description(); 1593 QString des = eve->description();
1588 QString pref = "e"; 1594 QString pref = "e";
1589 if ( toDelete->typeID() == todoID ) 1595 if ( toDelete->typeID() == todoID )
1590 pref = "t"; 1596 pref = "t";
1591 des += pref+ id + ","; 1597 des += pref+ id + ",";
1592 eve->setReadOnly( false ); 1598 eve->setReadOnly( false );
1593 eve->setDescription( des ); 1599 eve->setDescription( des );
1594 //qDebug("setdes %s ", des.latin1()); 1600 //qDebug("setdes %s ", des.latin1());
1595 eve->setReadOnly( true ); 1601 eve->setReadOnly( true );
1596 } 1602 }
1597 eve = lastSync.next(); 1603 eve = lastSync.next();
1598 } 1604 }
1599 1605
1600} 1606}
1601void CalendarView::checkExternalId( Incidence * inc ) 1607void CalendarView::checkExternalId( Incidence * inc )
1602{ 1608{
1603 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 1609 Q3PtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
1604 checkExternSyncEvent( lastSync, inc ); 1610 checkExternSyncEvent( lastSync, inc );
1605 1611
1606} 1612}
1607// SSSSSSSSSSSSSSSSSSSSSS 1613// SSSSSSSSSSSSSSSSSSSSSS
1608bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 1614bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
1609{ 1615{
1610 1616
1611 bool syncOK = true; 1617 bool syncOK = true;
1612 int addedEvent = 0; 1618 int addedEvent = 0;
1613 int addedEventR = 0; 1619 int addedEventR = 0;
1614 int deletedEventR = 0; 1620 int deletedEventR = 0;
1615 int deletedEventL = 0; 1621 int deletedEventL = 0;
1616 int changedLocal = 0; 1622 int changedLocal = 0;
1617 int changedRemote = 0; 1623 int changedRemote = 0;
1618 int filteredIN = 0; 1624 int filteredIN = 0;
1619 int filteredOUT = 0; 1625 int filteredOUT = 0;
1620 //QPtrList<Event> el = local->rawEvents(); 1626 //QPtrList<Event> el = local->rawEvents();
1621 Event* eventR; 1627 Event* eventR;
1622 QString uid; 1628 QString uid;
1623 int take; 1629 int take;
1624 Event* eventRSync; 1630 Event* eventRSync;
1625 Event* eventLSync; 1631 Event* eventLSync;
1626 clearAllViews(); 1632 clearAllViews();
1627 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 1633 Q3PtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
1628 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 1634 Q3PtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
1629 bool fullDateRange = false; 1635 bool fullDateRange = false;
1630 local->resetTempSyncStat(); 1636 local->resetTempSyncStat();
1631 mLastCalendarSync = QDateTime::currentDateTime(); 1637 mLastCalendarSync = QDateTime::currentDateTime();
1632 if ( mSyncManager->syncWithDesktop() ) { 1638 if ( mSyncManager->syncWithDesktop() ) {
1633 remote->resetPilotStat(1); 1639 remote->resetPilotStat(1);
1634 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 1640 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
1635 mLastCalendarSync = KSyncManager::mRequestedSyncEvent; 1641 mLastCalendarSync = KSyncManager::mRequestedSyncEvent;
1636 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); 1642 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() );
1637 } else { 1643 } else {
1638 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 1644 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
1639 } 1645 }
1640 } 1646 }
1641 QDateTime modifiedCalendar = mLastCalendarSync; 1647 QDateTime modifiedCalendar = mLastCalendarSync;
1642 eventLSync = getLastSyncEvent(); 1648 eventLSync = getLastSyncEvent();
1643 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 1649 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
1644 if ( eventR ) { 1650 if ( eventR ) {
1645 qDebug("KO: Last-syncEvent on remote found "); 1651 qDebug("KO: Last-syncEvent on remote found ");
1646 eventRSync = (Event*) eventR->clone(); 1652 eventRSync = (Event*) eventR->clone();
1647 remote->deleteEvent(eventR ); 1653 remote->deleteEvent(eventR );
1648 1654
1649 } else { 1655 } else {
1650 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { 1656 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) {
1651 eventRSync = (Event*)eventLSync->clone(); 1657 eventRSync = (Event*)eventLSync->clone();
1652 } else { 1658 } else {
@@ -1663,52 +1669,52 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
1663 fullDateRange = true; 1669 fullDateRange = true;
1664 1670
1665 if ( ! fullDateRange ) { 1671 if ( ! fullDateRange ) {
1666 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 1672 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
1667 1673
1668 qDebug("KO: Sync: Set fulldate to true! Local: %s --- Remote: %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 1674 qDebug("KO: Sync: Set fulldate to true! Local: %s --- Remote: %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
1669 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 1675 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
1670 fullDateRange = true; 1676 fullDateRange = true;
1671 } 1677 }
1672 } 1678 }
1673 if ( mSyncManager->syncWithDesktop() ) { 1679 if ( mSyncManager->syncWithDesktop() ) {
1674 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); 1680 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync );
1675 } 1681 }
1676 if ( fullDateRange ) 1682 if ( fullDateRange )
1677 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 1683 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
1678 else 1684 else
1679 mLastCalendarSync = eventLSync->dtStart(); 1685 mLastCalendarSync = eventLSync->dtStart();
1680 // for resyncing if own file has changed 1686 // for resyncing if own file has changed
1681 if ( mCurrentSyncDevice == "deleteaftersync" ) { 1687 if ( mCurrentSyncDevice == "deleteaftersync" ) {
1682 mLastCalendarSync = loadedFileVersion; 1688 mLastCalendarSync = loadedFileVersion;
1683 //qDebug("setting mLastCalendarSync "); 1689 //qDebug("setting mLastCalendarSync ");
1684 } 1690 }
1685 //qDebug("*************************** "); 1691 //qDebug("*************************** ");
1686 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); 1692 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange);
1687 QPtrList<Incidence> er = remote->rawIncidences(); 1693 Q3PtrList<Incidence> er = remote->rawIncidences();
1688 Incidence* inR = er.first(); 1694 Incidence* inR = er.first();
1689 Incidence* inL; 1695 Incidence* inL;
1690 QProgressBar bar( er.count(),0 ); 1696 Q3ProgressBar bar( er.count(),0 );
1691 bar.setCaption (i18n("Syncing - close to abort!") ); 1697 bar.setCaption (i18n("Syncing - close to abort!") );
1692 1698
1693 // ************** setting up filter ************* 1699 // ************** setting up filter *************
1694 CalFilter *filterIN = 0; 1700 CalFilter *filterIN = 0;
1695 CalFilter *filterOUT = 0; 1701 CalFilter *filterOUT = 0;
1696 CalFilter *filter = mFilters.first(); 1702 CalFilter *filter = mFilters.first();
1697 while(filter) { 1703 while(filter) {
1698 if ( filter->name() == mSyncManager->mFilterInCal ) 1704 if ( filter->name() == mSyncManager->mFilterInCal )
1699 filterIN = filter; 1705 filterIN = filter;
1700 if ( filter->name() == mSyncManager->mFilterOutCal ) 1706 if ( filter->name() == mSyncManager->mFilterOutCal )
1701 filterOUT = filter; 1707 filterOUT = filter;
1702 filter = mFilters.next(); 1708 filter = mFilters.next();
1703 } 1709 }
1704 int w = 300; 1710 int w = 300;
1705 if ( QApplication::desktop()->width() < 320 ) 1711 if ( QApplication::desktop()->width() < 320 )
1706 w = 220; 1712 w = 220;
1707 int h = bar.sizeHint().height() ; 1713 int h = bar.sizeHint().height() ;
1708 int dw = QApplication::desktop()->width(); 1714 int dw = QApplication::desktop()->width();
1709 int dh = QApplication::desktop()->height(); 1715 int dh = QApplication::desktop()->height();
1710 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1716 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1711 bar.show(); 1717 bar.show();
1712 int modulo = (er.count()/10)+1; 1718 int modulo = (er.count()/10)+1;
1713 int incCounter = 0; 1719 int incCounter = 0;
1714 while ( inR ) { 1720 while ( inR ) {
@@ -1810,49 +1816,49 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
1810 1816
1811 } 1817 }
1812 } else { 1818 } else {
1813 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1819 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1814 inR->setLastModified( modifiedCalendar ); 1820 inR->setLastModified( modifiedCalendar );
1815 inL = inR->clone(); 1821 inL = inR->clone();
1816 inL->setIDStr( ":" ); 1822 inL->setIDStr( ":" );
1817 inL->setCalID_block( 0 );// add to default cal 1823 inL->setCalID_block( 0 );// add to default cal
1818 local->addIncidence( inL ); 1824 local->addIncidence( inL );
1819 ++addedEvent; 1825 ++addedEvent;
1820 1826
1821 } else { 1827 } else {
1822 checkExternSyncEvent(eventRSyncSharp, inR); 1828 checkExternSyncEvent(eventRSyncSharp, inR);
1823 remote->deleteIncidence( inR ); 1829 remote->deleteIncidence( inR );
1824 ++deletedEventR; 1830 ++deletedEventR;
1825 } 1831 }
1826 } 1832 }
1827 } else { 1833 } else {
1828 ++filteredIN; 1834 ++filteredIN;
1829 } 1835 }
1830 } 1836 }
1831 } 1837 }
1832 inR = er.next(); 1838 inR = er.next();
1833 } 1839 }
1834 QPtrList<Incidence> el = local->rawIncidences(); 1840 Q3PtrList<Incidence> el = local->rawIncidences();
1835 inL = el.first(); 1841 inL = el.first();
1836 modulo = (el.count()/10)+1; 1842 modulo = (el.count()/10)+1;
1837 bar.setCaption (i18n("Add / remove events") ); 1843 bar.setCaption (i18n("Add / remove events") );
1838 bar.setTotalSteps ( el.count() ) ; 1844 bar.setTotalSteps ( el.count() ) ;
1839 bar.show(); 1845 bar.show();
1840 incCounter = 0; 1846 incCounter = 0;
1841 1847
1842 while ( inL ) { 1848 while ( inL ) {
1843 1849
1844 qApp->processEvents(); 1850 qApp->processEvents();
1845 if ( ! bar.isVisible() ) 1851 if ( ! bar.isVisible() )
1846 return false; 1852 return false;
1847 if ( incCounter % modulo == 0 ) 1853 if ( incCounter % modulo == 0 )
1848 bar.setProgress( incCounter ); 1854 bar.setProgress( incCounter );
1849 ++incCounter; 1855 ++incCounter;
1850 uid = inL->uid(); 1856 uid = inL->uid();
1851 bool skipIncidence = false; 1857 bool skipIncidence = false;
1852 if ( uid.left(15) == QString("last-syncEvent-") ) 1858 if ( uid.left(15) == QString("last-syncEvent-") )
1853 skipIncidence = true; 1859 skipIncidence = true;
1854 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) 1860 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID )
1855 skipIncidence = true; 1861 skipIncidence = true;
1856 if ( !skipIncidence ) { 1862 if ( !skipIncidence ) {
1857 inR = remote->incidenceForUid( uid , true, true ); 1863 inR = remote->incidenceForUid( uid , true, true );
1858 if ( ! inR ) { 1864 if ( ! inR ) {
@@ -2027,49 +2033,49 @@ void CalendarView::syncExternal( int mode )
2027 sharpFormat = new SharpFormat () ; 2033 sharpFormat = new SharpFormat () ;
2028 loadSuccess = sharpFormat->load( calendar, mCalendar ); 2034 loadSuccess = sharpFormat->load( calendar, mCalendar );
2029 2035
2030 } else 2036 } else
2031#endif 2037#endif
2032 if ( mode == 1 ) { // phone 2038 if ( mode == 1 ) { // phone
2033 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 2039 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
2034 mSyncManager->mPhoneDevice, 2040 mSyncManager->mPhoneDevice,
2035 mSyncManager->mPhoneConnection, 2041 mSyncManager->mPhoneConnection,
2036 mSyncManager->mPhoneModel); 2042 mSyncManager->mPhoneModel);
2037 loadSuccess = phoneFormat->load( calendar,mCalendar); 2043 loadSuccess = phoneFormat->load( calendar,mCalendar);
2038 2044
2039 } else { 2045 } else {
2040 emit tempDisableBR(false); 2046 emit tempDisableBR(false);
2041 return; 2047 return;
2042 } 2048 }
2043 if ( loadSuccess ) { 2049 if ( loadSuccess ) {
2044 getEventViewerDialog()->setSyncMode( true ); 2050 getEventViewerDialog()->setSyncMode( true );
2045 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 2051 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
2046 getEventViewerDialog()->setSyncMode( false ); 2052 getEventViewerDialog()->setSyncMode( false );
2047 qApp->processEvents(); 2053 qApp->processEvents();
2048 if ( syncOK ) { 2054 if ( syncOK ) {
2049 if ( mSyncManager->mWriteBackFile ) 2055 if ( mSyncManager->mWriteBackFile )
2050 { 2056 {
2051 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 2057 Q3PtrList<Incidence> iL = mCalendar->rawIncidences();
2052 Incidence* inc = iL.first(); 2058 Incidence* inc = iL.first();
2053 if ( phoneFormat ) { 2059 if ( phoneFormat ) {
2054 while ( inc ) { 2060 while ( inc ) {
2055 inc->removeID(mCurrentSyncDevice); 2061 inc->removeID(mCurrentSyncDevice);
2056 inc = iL.next(); 2062 inc = iL.next();
2057 } 2063 }
2058 } 2064 }
2059#ifndef DESKTOP_VERSION 2065#ifndef DESKTOP_VERSION
2060 if ( sharpFormat ) 2066 if ( sharpFormat )
2061 sharpFormat->save(calendar); 2067 sharpFormat->save(calendar);
2062#endif 2068#endif
2063 if ( phoneFormat ) 2069 if ( phoneFormat )
2064 phoneFormat->save(calendar); 2070 phoneFormat->save(calendar);
2065 iL = calendar->rawIncidences(); 2071 iL = calendar->rawIncidences();
2066 inc = iL.first(); 2072 inc = iL.first();
2067 Incidence* loc; 2073 Incidence* loc;
2068 while ( inc ) { 2074 while ( inc ) {
2069 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 2075 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
2070 loc = mCalendar->incidence(inc->uid() ); 2076 loc = mCalendar->incidence(inc->uid() );
2071 if ( loc ) { 2077 if ( loc ) {
2072 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 2078 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
2073 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 2079 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
2074 } 2080 }
2075 } 2081 }
@@ -2094,49 +2100,49 @@ void CalendarView::syncExternal( int mode )
2094 } 2100 }
2095 delete calendar; 2101 delete calendar;
2096 updateView(); 2102 updateView();
2097 emit tempDisableBR(false); 2103 emit tempDisableBR(false);
2098 return ;//syncOK; 2104 return ;//syncOK;
2099 2105
2100} 2106}
2101 2107
2102bool CalendarView::importBday() 2108bool CalendarView::importBday()
2103{ 2109{
2104#ifndef KORG_NOKABC 2110#ifndef KORG_NOKABC
2105 2111
2106#ifdef DESKTOP_VERSION 2112#ifdef DESKTOP_VERSION
2107 int curCal = mCalendar->defaultCalendar(); 2113 int curCal = mCalendar->defaultCalendar();
2108 int bd = mCalEditView->getBirtdayID(); 2114 int bd = mCalEditView->getBirtdayID();
2109 if ( bd == 0 ) 2115 if ( bd == 0 )
2110 return false; 2116 return false;
2111 mCalendar->setDefaultCalendar( bd ); 2117 mCalendar->setDefaultCalendar( bd );
2112 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 2118 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
2113 KABC::AddressBook::Iterator it; 2119 KABC::AddressBook::Iterator it;
2114 int count = 0; 2120 int count = 0;
2115 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 2121 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
2116 ++count; 2122 ++count;
2117 } 2123 }
2118 QProgressBar bar(count,0 ); 2124 Q3ProgressBar bar(count,0 );
2119 int w = 300; 2125 int w = 300;
2120 if ( QApplication::desktop()->width() < 320 ) 2126 if ( QApplication::desktop()->width() < 320 )
2121 w = 220; 2127 w = 220;
2122 int h = bar.sizeHint().height() ; 2128 int h = bar.sizeHint().height() ;
2123 int dw = QApplication::desktop()->width(); 2129 int dw = QApplication::desktop()->width();
2124 int dh = QApplication::desktop()->height(); 2130 int dh = QApplication::desktop()->height();
2125 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2131 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2126 bar.show(); 2132 bar.show();
2127 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 2133 bar.setCaption (i18n("Reading addressbook - close to abort!") );
2128 qApp->processEvents(); 2134 qApp->processEvents();
2129 count = 0; 2135 count = 0;
2130 int addCount = 0; 2136 int addCount = 0;
2131 KCal::Attendee* a = 0; 2137 KCal::Attendee* a = 0;
2132 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 2138 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
2133 if ( ! bar.isVisible() ) 2139 if ( ! bar.isVisible() )
2134 return false; 2140 return false;
2135 bar.setProgress( count++ ); 2141 bar.setProgress( count++ );
2136 qApp->processEvents(); 2142 qApp->processEvents();
2137 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 2143 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
2138 if ( (*it).birthday().date().isValid() ){ 2144 if ( (*it).birthday().date().isValid() ){
2139 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 2145 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
2140 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 2146 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
2141 ++addCount; 2147 ++addCount;
2142 } 2148 }
@@ -2165,49 +2171,49 @@ bool CalendarView::importBday()
2165 2171
2166// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI 2172// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
2167void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, 2173void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
2168 const QStringList& anniversaryList, const QStringList& realNameList, 2174 const QStringList& anniversaryList, const QStringList& realNameList,
2169 const QStringList& emailList, const QStringList& assembledNameList, 2175 const QStringList& emailList, const QStringList& assembledNameList,
2170 const QStringList& uidList) 2176 const QStringList& uidList)
2171{ 2177{
2172 2178
2173 //qDebug("KO::CalendarView::insertBirthdays"); 2179 //qDebug("KO::CalendarView::insertBirthdays");
2174 if (uid == this->name()) 2180 if (uid == this->name())
2175 { 2181 {
2176 int curCal = mCalendar->defaultCalendar(); 2182 int curCal = mCalendar->defaultCalendar();
2177 int bd = mCalEditView->getBirtdayID(); 2183 int bd = mCalEditView->getBirtdayID();
2178 if ( bd == 0 ) 2184 if ( bd == 0 )
2179 return; 2185 return;
2180 mCalendar->setDefaultCalendar( bd ); 2186 mCalendar->setDefaultCalendar( bd );
2181 2187
2182 2188
2183 int count = birthdayList.count(); 2189 int count = birthdayList.count();
2184 int addCount = 0; 2190 int addCount = 0;
2185 KCal::Attendee* a = 0; 2191 KCal::Attendee* a = 0;
2186 2192
2187 //qDebug("CalView 1 %i", count); 2193 //qDebug("CalView 1 %i", count);
2188 2194
2189 QProgressBar bar(count,0 ); 2195 Q3ProgressBar bar(count,0 );
2190 int w = 300; 2196 int w = 300;
2191 if ( QApplication::desktop()->width() < 320 ) 2197 if ( QApplication::desktop()->width() < 320 )
2192 w = 220; 2198 w = 220;
2193 int h = bar.sizeHint().height() ; 2199 int h = bar.sizeHint().height() ;
2194 int dw = QApplication::desktop()->width(); 2200 int dw = QApplication::desktop()->width();
2195 int dh = QApplication::desktop()->height(); 2201 int dh = QApplication::desktop()->height();
2196 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2202 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2197 bar.show(); 2203 bar.show();
2198 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 2204 bar.setCaption (i18n("inserting birthdays - close to abort!") );
2199 qApp->processEvents(); 2205 qApp->processEvents();
2200 2206
2201 QDate birthday; 2207 QDate birthday;
2202 QDate anniversary; 2208 QDate anniversary;
2203 QString realName; 2209 QString realName;
2204 QString email; 2210 QString email;
2205 QString assembledName; 2211 QString assembledName;
2206 QString uid; 2212 QString uid;
2207 bool ok = true; 2213 bool ok = true;
2208 for ( int i = 0; i < count; i++) 2214 for ( int i = 0; i < count; i++)
2209 { 2215 {
2210 if ( ! bar.isVisible() ) 2216 if ( ! bar.isVisible() )
2211 return; 2217 return;
2212 bar.setProgress( i ); 2218 bar.setProgress( i );
2213 qApp->processEvents(); 2219 qApp->processEvents();
@@ -2329,63 +2335,63 @@ bool CalendarView::importQtopia( const QString &categories,
2329 } 2335 }
2330 setModified( true ); 2336 setModified( true );
2331 } 2337 }
2332 } else { 2338 } else {
2333 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 2339 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
2334 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 2340 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
2335 question, i18n("Ok")) ; 2341 question, i18n("Ok")) ;
2336 } 2342 }
2337 delete calendar; 2343 delete calendar;
2338 updateView(); 2344 updateView();
2339 return syncOK; 2345 return syncOK;
2340 2346
2341 2347
2342#endif 2348#endif
2343 2349
2344} 2350}
2345 2351
2346void CalendarView::setSyncEventsReadOnly() 2352void CalendarView::setSyncEventsReadOnly()
2347{ 2353{
2348 mCalendar->setSyncEventsReadOnly(); 2354 mCalendar->setSyncEventsReadOnly();
2349} 2355}
2350 2356
2351bool CalendarView::loadCalendars() 2357bool CalendarView::loadCalendars()
2352{ 2358{
2353 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2359 Q3PtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2354 KopiCalendarFile * cal = calendars.first(); 2360 KopiCalendarFile * cal = calendars.first();
2355 mCalendar->setDefaultCalendar( 1 ); 2361 mCalendar->setDefaultCalendar( 1 );
2356 openCalendar( MainWindow::defaultFileName(), false ); 2362 openCalendar( MainWindow::defaultFileName(), false );
2357 cal = calendars.next(); 2363 cal = calendars.next();
2358 while ( cal ) { 2364 while ( cal ) {
2359 addCalendar( cal ); 2365 addCalendar( cal );
2360 cal = calendars.next(); 2366 cal = calendars.next();
2361 } 2367 }
2362 restoreCalendarSettings(); 2368 restoreCalendarSettings();
2363 return true; 2369 return true;
2364} 2370}
2365bool CalendarView::restoreCalendarSettings() 2371bool CalendarView::restoreCalendarSettings()
2366{ 2372{
2367 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2373 Q3PtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2368 KopiCalendarFile * cal = calendars.first(); 2374 KopiCalendarFile * cal = calendars.first();
2369 while ( cal ) { 2375 while ( cal ) {
2370 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); 2376 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled );
2371 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); 2377 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled );
2372 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); 2378 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly );
2373 if ( cal->isStandard ) 2379 if ( cal->isStandard )
2374 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2380 mCalendar->setDefaultCalendar( cal->mCalNumber );
2375 cal = calendars.next(); 2381 cal = calendars.next();
2376 } 2382 }
2377 setSyncEventsReadOnly(); 2383 setSyncEventsReadOnly();
2378 mCalendar->reInitAlarmSettings(); 2384 mCalendar->reInitAlarmSettings();
2379 updateUnmanagedViews(); 2385 updateUnmanagedViews();
2380 updateView(); 2386 updateView();
2381 return true; 2387 return true;
2382} 2388}
2383void CalendarView::addCalendarId( int id ) 2389void CalendarView::addCalendarId( int id )
2384{ 2390{
2385 KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); 2391 KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id );
2386 if ( cal ) 2392 if ( cal )
2387 addCalendar( cal ); 2393 addCalendar( cal );
2388} 2394}
2389bool CalendarView::addCalendar( KopiCalendarFile * cal ) 2395bool CalendarView::addCalendar( KopiCalendarFile * cal )
2390{ 2396{
2391 cal->mErrorOnLoad = false; 2397 cal->mErrorOnLoad = false;
@@ -2508,49 +2514,49 @@ bool CalendarView::checkFileChanged(QString fn)
2508 QFileInfo finf ( fn ); 2514 QFileInfo finf ( fn );
2509 if ( !finf.exists() ) 2515 if ( !finf.exists() )
2510 return true; 2516 return true;
2511 QDateTime dt = finf.lastModified (); 2517 QDateTime dt = finf.lastModified ();
2512 if ( dt <= loadedFileVersion ) 2518 if ( dt <= loadedFileVersion )
2513 return false; 2519 return false;
2514 return true; 2520 return true;
2515 2521
2516} 2522}
2517void CalendarView::watchSavedFile() 2523void CalendarView::watchSavedFile()
2518{ 2524{
2519 QFileInfo finf ( MainWindow::defaultFileName()); 2525 QFileInfo finf ( MainWindow::defaultFileName());
2520 if ( !finf.exists() ) 2526 if ( !finf.exists() )
2521 return; 2527 return;
2522 QDateTime dt = finf.lastModified (); 2528 QDateTime dt = finf.lastModified ();
2523 if ( dt < loadedFileVersion ) { 2529 if ( dt < loadedFileVersion ) {
2524 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 2530 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
2525 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 2531 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
2526 return; 2532 return;
2527 } 2533 }
2528 loadedFileVersion = dt; 2534 loadedFileVersion = dt;
2529} 2535}
2530bool CalendarView::checkAllFileVersions() 2536bool CalendarView::checkAllFileVersions()
2531{ 2537{
2532 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2538 Q3PtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2533 KopiCalendarFile * cal = calendars.first(); 2539 KopiCalendarFile * cal = calendars.first();
2534 mCalendar->setDefaultCalendar( 1 ); 2540 mCalendar->setDefaultCalendar( 1 );
2535 mCalendar->setDefaultCalendarEnabledOnly(); 2541 mCalendar->setDefaultCalendarEnabledOnly();
2536 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2542 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2537 if ( !checkFileVersion(MainWindow::defaultFileName())) { 2543 if ( !checkFileVersion(MainWindow::defaultFileName())) {
2538 restoreCalendarSettings(); 2544 restoreCalendarSettings();
2539 return false; 2545 return false;
2540 } 2546 }
2541 } 2547 }
2542 cal = calendars.next(); 2548 cal = calendars.next();
2543 QDateTime storeTemp = loadedFileVersion; 2549 QDateTime storeTemp = loadedFileVersion;
2544 while ( cal ) { 2550 while ( cal ) {
2545 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2551 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2546 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2552 mCalendar->setDefaultCalendar( cal->mCalNumber );
2547 mCalendar->setDefaultCalendarEnabledOnly(); 2553 mCalendar->setDefaultCalendarEnabledOnly();
2548 loadedFileVersion = cal->mLoadDt.addSecs( 15 ); 2554 loadedFileVersion = cal->mLoadDt.addSecs( 15 );
2549 if ( !checkFileVersion(cal->mFileName )) { 2555 if ( !checkFileVersion(cal->mFileName )) {
2550 loadedFileVersion = storeTemp; 2556 loadedFileVersion = storeTemp;
2551 restoreCalendarSettings(); 2557 restoreCalendarSettings();
2552 return false; 2558 return false;
2553 } 2559 }
2554 } 2560 }
2555 cal = calendars.next(); 2561 cal = calendars.next();
2556 } 2562 }
@@ -2570,49 +2576,49 @@ bool CalendarView::checkFileVersion(QString fn)
2570 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\non disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(KGlobal::formatMessage(fn,0)).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , 2576 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file\n%1\non disk has changed!\nFile size: %2 bytes.\nLast modified: %3\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg(KGlobal::formatMessage(fn,0)).arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) ,
2571 i18n("KO/Pi Warning"),i18n("Overwrite"), 2577 i18n("KO/Pi Warning"),i18n("Overwrite"),
2572 i18n("Sync+save")); 2578 i18n("Sync+save"));
2573 2579
2574 if ( km == KMessageBox::Cancel ) 2580 if ( km == KMessageBox::Cancel )
2575 return false; 2581 return false;
2576 if ( km == KMessageBox::Yes ) 2582 if ( km == KMessageBox::Yes )
2577 return true; 2583 return true;
2578 2584
2579 setSyncDevice("deleteaftersync" ); 2585 setSyncDevice("deleteaftersync" );
2580 mSyncManager->mAskForPreferences = true; 2586 mSyncManager->mAskForPreferences = true;
2581 mSyncManager->mSyncAlgoPrefs = 3; 2587 mSyncManager->mSyncAlgoPrefs = 3;
2582 mSyncManager->mWriteBackFile = false; 2588 mSyncManager->mWriteBackFile = false;
2583 mSyncManager->mWriteBackExistingOnly = false; 2589 mSyncManager->mWriteBackExistingOnly = false;
2584 mSyncManager->mShowSyncSummary = false; 2590 mSyncManager->mShowSyncSummary = false;
2585 mMultiResourceSync = false; 2591 mMultiResourceSync = false;
2586 syncCalendar( fn, 3 ); 2592 syncCalendar( fn, 3 );
2587 Event * e = getLastSyncEvent(); 2593 Event * e = getLastSyncEvent();
2588 if ( e ) 2594 if ( e )
2589 mCalendar->deleteEvent( e ); 2595 mCalendar->deleteEvent( e );
2590 return true; 2596 return true;
2591} 2597}
2592bool CalendarView::saveCalendars() 2598bool CalendarView::saveCalendars()
2593{ 2599{
2594 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 2600 Q3PtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
2595 KopiCalendarFile * cal = calendars.first(); 2601 KopiCalendarFile * cal = calendars.first();
2596 mCalendar->setDefaultCalendar( 1 ); 2602 mCalendar->setDefaultCalendar( 1 );
2597 mCalendar->setDefaultCalendarEnabledOnly(); 2603 mCalendar->setDefaultCalendarEnabledOnly();
2598 QString saveError; 2604 QString saveError;
2599 if ( !saveCalendar( MainWindow::defaultFileName() ) ) 2605 if ( !saveCalendar( MainWindow::defaultFileName() ) )
2600 saveError = cal->mName +"\n"; 2606 saveError = cal->mName +"\n";
2601 cal = calendars.next(); 2607 cal = calendars.next();
2602 while ( cal ) { 2608 while ( cal ) {
2603 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) { 2609 if ( !cal->isReadOnly && !cal->mErrorOnLoad ) {
2604 mCalendar->setDefaultCalendar( cal->mCalNumber ); 2610 mCalendar->setDefaultCalendar( cal->mCalNumber );
2605 mCalendar->setDefaultCalendarEnabledOnly(); 2611 mCalendar->setDefaultCalendarEnabledOnly();
2606 if ( saveCalendar( cal->mFileName ) ) 2612 if ( saveCalendar( cal->mFileName ) )
2607 cal->mLoadDt = QDateTime::currentDateTime(); 2613 cal->mLoadDt = QDateTime::currentDateTime();
2608 else 2614 else
2609 saveError += cal->mName + "\n"; 2615 saveError += cal->mName + "\n";
2610 } 2616 }
2611 cal = calendars.next(); 2617 cal = calendars.next();
2612 } 2618 }
2613 restoreCalendarSettings(); 2619 restoreCalendarSettings();
2614 //saveError = "test error"; 2620 //saveError = "test error";
2615 if ( !saveError.isEmpty() ) { 2621 if ( !saveError.isEmpty() ) {
2616 saveError = KGlobal::formatMessage( i18n("Calendar(s) not saved:"),0 )+"\n" + saveError; 2622 saveError = KGlobal::formatMessage( i18n("Calendar(s) not saved:"),0 )+"\n" + saveError;
2617 KMessageBox::error(this, saveError, i18n("Error saving data")); 2623 KMessageBox::error(this, saveError, i18n("Error saving data"));
2618 return false; 2624 return false;
@@ -2674,49 +2680,49 @@ void CalendarView::closeCalendar()
2674 mCalendar->close(); 2680 mCalendar->close();
2675 setModified(false); 2681 setModified(false);
2676 updateView(); 2682 updateView();
2677} 2683}
2678 2684
2679void CalendarView::archiveCalendar() 2685void CalendarView::archiveCalendar()
2680{ 2686{
2681 mDialogManager->showArchiveDialog(); 2687 mDialogManager->showArchiveDialog();
2682} 2688}
2683 2689
2684 2690
2685void CalendarView::readSettings() 2691void CalendarView::readSettings()
2686{ 2692{
2687 2693
2688 2694
2689 // mViewManager->showAgendaView(); 2695 // mViewManager->showAgendaView();
2690 QString str; 2696 QString str;
2691 //qDebug("CalendarView::readSettings() "); 2697 //qDebug("CalendarView::readSettings() ");
2692 // read settings from the KConfig, supplying reasonable 2698 // read settings from the KConfig, supplying reasonable
2693 // defaults where none are to be found 2699 // defaults where none are to be found
2694 KConfig *config = KOGlobals::config(); 2700 KConfig *config = KOGlobals::config();
2695#ifndef KORG_NOSPLITTER 2701#ifndef KORG_NOSPLITTER
2696 config->setGroup("KOrganizer Geometry"); 2702 config->setGroup("KOrganizer Geometry");
2697 2703
2698 QValueList<int> sizes = config->readIntListEntry("Separator1"); 2704 Q3ValueList<int> sizes = config->readIntListEntry("Separator1");
2699 if (sizes.count() != 2) { 2705 if (sizes.count() != 2) {
2700 sizes << mDateNavigator->minimumSizeHint().width(); 2706 sizes << mDateNavigator->minimumSizeHint().width();
2701 sizes << 300; 2707 sizes << 300;
2702 } 2708 }
2703 mPanner->setSizes(sizes); 2709 mPanner->setSizes(sizes);
2704 2710
2705 sizes = config->readIntListEntry("Separator2"); 2711 sizes = config->readIntListEntry("Separator2");
2706 if ( ( mResourceView && sizes.count() == 4 ) || 2712 if ( ( mResourceView && sizes.count() == 4 ) ||
2707 ( !mResourceView && sizes.count() == 3 ) ) { 2713 ( !mResourceView && sizes.count() == 3 ) ) {
2708 mLeftSplitter->setSizes(sizes); 2714 mLeftSplitter->setSizes(sizes);
2709 } 2715 }
2710#endif 2716#endif
2711 globalFlagBlockAgenda = 1; 2717 globalFlagBlockAgenda = 1;
2712 mViewManager->showAgendaView(); 2718 mViewManager->showAgendaView();
2713 //mViewManager->readSettings( config ); 2719 //mViewManager->readSettings( config );
2714 mTodoList->restoreLayout(config,QString("Todo Layout")); 2720 mTodoList->restoreLayout(config,QString("Todo Layout"));
2715 readFilterSettings(config); 2721 readFilterSettings(config);
2716 2722
2717#ifdef DESKTOP_VERSION 2723#ifdef DESKTOP_VERSION
2718 config->setGroup("WidgetLayout"); 2724 config->setGroup("WidgetLayout");
2719 QStringList list; 2725 QStringList list;
2720 list = config->readListEntry("MainLayout"); 2726 list = config->readListEntry("MainLayout");
2721 int x,y,w,h; 2727 int x,y,w,h;
2722 if ( ! list.isEmpty() ) { 2728 if ( ! list.isEmpty() ) {
@@ -2742,49 +2748,49 @@ void CalendarView::readSettings()
2742 } 2748 }
2743 list = config->readListEntry("EditTodoLayout"); 2749 list = config->readListEntry("EditTodoLayout");
2744 if ( ! list.isEmpty() ) { 2750 if ( ! list.isEmpty() ) {
2745 x = list[0].toInt(); 2751 x = list[0].toInt();
2746 y = list[1].toInt(); 2752 y = list[1].toInt();
2747 w = list[2].toInt(); 2753 w = list[2].toInt();
2748 h = list[3].toInt(); 2754 h = list[3].toInt();
2749 KApplication::testCoords( &x,&y,&w,&h ); 2755 KApplication::testCoords( &x,&y,&w,&h );
2750 mTodoEditor->setGeometry(x,y,w,h); 2756 mTodoEditor->setGeometry(x,y,w,h);
2751 2757
2752 } 2758 }
2753 list = config->readListEntry("ViewerLayout"); 2759 list = config->readListEntry("ViewerLayout");
2754 if ( ! list.isEmpty() ) { 2760 if ( ! list.isEmpty() ) {
2755 x = list[0].toInt(); 2761 x = list[0].toInt();
2756 y = list[1].toInt(); 2762 y = list[1].toInt();
2757 w = list[2].toInt(); 2763 w = list[2].toInt();
2758 h = list[3].toInt(); 2764 h = list[3].toInt();
2759 KApplication::testCoords( &x,&y,&w,&h ); 2765 KApplication::testCoords( &x,&y,&w,&h );
2760 getEventViewerDialog()->setGeometry(x,y,w,h); 2766 getEventViewerDialog()->setGeometry(x,y,w,h);
2761 } 2767 }
2762#endif 2768#endif
2763 config->setGroup( "Views" ); 2769 config->setGroup( "Views" );
2764 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 2770 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
2765 2771
2766 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); 2772 Q3ValueList<int> sizes = config->readIntListEntry("Left Splitter Frame");
2767 2773
2768 int resetval = 0; 2774 int resetval = 0;
2769 int maxVal = 0; 2775 int maxVal = 0;
2770 if (sizes.count() != 3) { 2776 if (sizes.count() != 3) {
2771 if ( KOPrefs::instance()->mVerticalScreen ) { 2777 if ( KOPrefs::instance()->mVerticalScreen ) {
2772 resetval = mDateNavigator->sizeHint().width()+2; 2778 resetval = mDateNavigator->sizeHint().width()+2;
2773 } else { 2779 } else {
2774 resetval = mDateNavigator->sizeHint().height()+2; 2780 resetval = mDateNavigator->sizeHint().height()+2;
2775 } 2781 }
2776 } 2782 }
2777 if ( resetval ) { 2783 if ( resetval ) {
2778 sizes.clear(); 2784 sizes.clear();
2779 if ( KOPrefs::instance()->mVerticalScreen ) { 2785 if ( KOPrefs::instance()->mVerticalScreen ) {
2780 maxVal = QApplication::desktop()->width() -10; 2786 maxVal = QApplication::desktop()->width() -10;
2781 } else { 2787 } else {
2782 maxVal = QApplication::desktop()->height()-10; 2788 maxVal = QApplication::desktop()->height()-10;
2783 } 2789 }
2784 sizes << resetval; 2790 sizes << resetval;
2785 if ( maxVal < resetval + resetval) 2791 if ( maxVal < resetval + resetval)
2786 resetval = maxVal - resetval; 2792 resetval = maxVal - resetval;
2787 sizes << resetval; 2793 sizes << resetval;
2788 sizes << 100; 2794 sizes << 100;
2789 } 2795 }
2790 mLeftFrame->setSizes(sizes); 2796 mLeftFrame->setSizes(sizes);
@@ -2821,78 +2827,78 @@ void CalendarView::readSettings()
2821 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); 2827 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) );
2822} 2828}
2823 2829
2824void CalendarView::checkSuspendAlarm() 2830void CalendarView::checkSuspendAlarm()
2825{ 2831{
2826 if ( mSuspendTimer->isActive() ) { 2832 if ( mSuspendTimer->isActive() ) {
2827 KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm")); 2833 KMessageBox::information( this, i18n("<b>WARNING:</b> There is a pending suspended alarm!"), i18n("Pending Suspend Alarm"));
2828 } 2834 }
2829} 2835}
2830void CalendarView::writeSettings() 2836void CalendarView::writeSettings()
2831{ 2837{
2832 // kdDebug() << "CalendarView::writeSettings" << endl; 2838 // kdDebug() << "CalendarView::writeSettings" << endl;
2833 2839
2834 KConfig *config = KOGlobals::config(); 2840 KConfig *config = KOGlobals::config();
2835 2841
2836 mViewManager->writeSettings( config ); 2842 mViewManager->writeSettings( config );
2837 mTodoList->saveLayout(config,QString("Todo Layout")); 2843 mTodoList->saveLayout(config,QString("Todo Layout"));
2838 mDialogManager->writeSettings( config ); 2844 mDialogManager->writeSettings( config );
2839 //KOPrefs::instance()->usrWriteConfig(); 2845 //KOPrefs::instance()->usrWriteConfig();
2840 KOPrefs::instance()->writeConfig(); 2846 KOPrefs::instance()->writeConfig();
2841 2847
2842 writeFilterSettings(config); 2848 writeFilterSettings(config);
2843 config->setGroup( "AppRun" ); 2849 config->setGroup( "AppRun" );
2844 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); 2850 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) );
2845 int days = dt.daysTo( QDate::currentDate() ); 2851 int days = dt.daysTo( (QDateTime)QDate::currentDate() );
2846 dt = dt.addDays( days ); 2852 dt = dt.addDays( days );
2847 int secs = dt.secsTo( QDateTime::currentDateTime() ); 2853 int secs = dt.secsTo( QDateTime::currentDateTime() );
2848 config->writeEntry( "LatestProgramStopDays", days ); 2854 config->writeEntry( "LatestProgramStopDays", days );
2849 config->writeEntry( "LatestProgramStopSecs", secs ); 2855 config->writeEntry( "LatestProgramStopSecs", secs );
2850 //qDebug("KO: Writing stop time: %d ", secs); 2856 //qDebug("KO: Writing stop time: %d ", secs);
2851 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); 2857 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() );
2852 //QDateTime latest = dt.addSecs ( secs ); 2858 //QDateTime latest = dt.addSecs ( secs );
2853 //qDebug("KO: Termination on %s ", latest.toString().latin1()); 2859 //qDebug("KO: Termination on %s ", latest.toString().latin1());
2854 config->setGroup( "Views" ); 2860 config->setGroup( "Views" );
2855 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 2861 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
2856 2862
2857#if 0 2863#if 0
2858 qDebug("********************* "); 2864 qDebug("********************* ");
2859 qDebug("Testcode secsto "); 2865 qDebug("Testcode secsto ");
2860 QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) ); 2866 QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) );
2861 QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) ); 2867 QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) );
2862 int secsto = dt_nodaylight.secsTo( dt_daylight ); 2868 int secsto = dt_nodaylight.secsTo( dt_daylight );
2863 QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto ); 2869 QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto );
2864 qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() ); 2870 qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() );
2865 qDebug("dt daylight %s ",dt_daylight.toString().latin1() ); 2871 qDebug("dt daylight %s ",dt_daylight.toString().latin1() );
2866 qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() ); 2872 qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() );
2867 qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600); 2873 qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600);
2868 qDebug("********************* testcode end"); 2874 qDebug("********************* testcode end");
2869 2875
2870#endif 2876#endif
2871 2877
2872 QValueList<int> listINT = mLeftFrame->sizes(); 2878 Q3ValueList<int> listINT = mLeftFrame->sizes();
2873 config->writeEntry("Left Splitter Frame",listINT); 2879 config->writeEntry("Left Splitter Frame",listINT);
2874 QValueList<int> listINT2 = mMainFrame->sizes(); 2880 Q3ValueList<int> listINT2 = mMainFrame->sizes();
2875 config->writeEntry("Main Splitter Frame",listINT2); 2881 config->writeEntry("Main Splitter Frame",listINT2);
2876#ifdef DESKTOP_VERSION 2882#ifdef DESKTOP_VERSION
2877 config->setGroup("WidgetLayout"); 2883 config->setGroup("WidgetLayout");
2878 QStringList list ;//= config->readListEntry("MainLayout"); 2884 QStringList list ;//= config->readListEntry("MainLayout");
2879 int x,y,w,h; 2885 int x,y,w,h;
2880 QWidget* wid; 2886 QWidget* wid;
2881 wid = topLevelWidget(); 2887 wid = topLevelWidget();
2882 x = wid->geometry().x(); 2888 x = wid->geometry().x();
2883 y = wid->geometry().y(); 2889 y = wid->geometry().y();
2884 w = wid->width(); 2890 w = wid->width();
2885 h = wid->height(); 2891 h = wid->height();
2886 list.clear(); 2892 list.clear();
2887 list << QString::number( x ); 2893 list << QString::number( x );
2888 list << QString::number( y ); 2894 list << QString::number( y );
2889 list << QString::number( w ); 2895 list << QString::number( w );
2890 list << QString::number( h ); 2896 list << QString::number( h );
2891 config->writeEntry("MainLayout",list ); 2897 config->writeEntry("MainLayout",list );
2892 2898
2893 wid = mEventEditor; 2899 wid = mEventEditor;
2894 x = wid->geometry().x(); 2900 x = wid->geometry().x();
2895 y = wid->geometry().y(); 2901 y = wid->geometry().y();
2896 w = wid->width(); 2902 w = wid->width();
2897 h = wid->height(); 2903 h = wid->height();
2898 list.clear(); 2904 list.clear();
@@ -3145,49 +3151,49 @@ void CalendarView::checkConflictForEvent()
3145 if (!KOPrefs::instance()->mConfirm) 3151 if (!KOPrefs::instance()->mConfirm)
3146 return; 3152 return;
3147 if ( ! mConflictingEvent ) return; 3153 if ( ! mConflictingEvent ) return;
3148 Event * conflictingEvent = mConflictingEvent; 3154 Event * conflictingEvent = mConflictingEvent;
3149 mConflictingEvent = 0; 3155 mConflictingEvent = 0;
3150 QDateTime current = QDateTime::currentDateTime(); 3156 QDateTime current = QDateTime::currentDateTime();
3151 if ( ! conflictingEvent->matchTime( &current, 0 ) ) { 3157 if ( ! conflictingEvent->matchTime( &current, 0 ) ) {
3152 return; 3158 return;
3153 } 3159 }
3154 CalFilter *filterIN = 0; 3160 CalFilter *filterIN = 0;
3155 CalFilter *filterALL = 0; 3161 CalFilter *filterALL = 0;
3156 CalFilter *filter = mFilters.first(); 3162 CalFilter *filter = mFilters.first();
3157 while(filter) { 3163 while(filter) {
3158 if ( filter->name() == KOPrefs::instance()->mFilterConflictEditItem) 3164 if ( filter->name() == KOPrefs::instance()->mFilterConflictEditItem)
3159 filterIN = filter; 3165 filterIN = filter;
3160 if ( filter->name() == KOPrefs::instance()->mFilterConflictAllItem ) 3166 if ( filter->name() == KOPrefs::instance()->mFilterConflictAllItem )
3161 filterALL = filter; 3167 filterALL = filter;
3162 filter = mFilters.next(); 3168 filter = mFilters.next();
3163 } 3169 }
3164 if ( filterIN ) { 3170 if ( filterIN ) {
3165 if ( !filterIN->filterCalendarItem( conflictingEvent ) ) { 3171 if ( !filterIN->filterCalendarItem( conflictingEvent ) ) {
3166 return; 3172 return;
3167 } 3173 }
3168 } 3174 }
3169 QPtrList<Event> testlist = mCalendar->events(); 3175 Q3PtrList<Event> testlist = mCalendar->events();
3170 Event * test = testlist.first(); 3176 Event * test = testlist.first();
3171 QDateTime conflict; 3177 QDateTime conflict;
3172 QDateTime retVal; 3178 QDateTime retVal;
3173 bool found = false; 3179 bool found = false;
3174 Event * cE = 0; 3180 Event * cE = 0;
3175 bool chAD = KOPrefs::instance()->mCheckConflictsAllDayAllDay; 3181 bool chAD = KOPrefs::instance()->mCheckConflictsAllDayAllDay;
3176 bool chNad = KOPrefs::instance()->mCheckConflictsAllDayNonAD; 3182 bool chNad = KOPrefs::instance()->mCheckConflictsAllDayNonAD;
3177 if ( !conflictingEvent->doesFloat() ) { 3183 if ( !conflictingEvent->doesFloat() ) {
3178 chAD = KOPrefs::instance()->mCheckConflictsNonADAllDay; 3184 chAD = KOPrefs::instance()->mCheckConflictsNonADAllDay;
3179 chNad = KOPrefs::instance()->mCheckConflictsNonADNonAD; 3185 chNad = KOPrefs::instance()->mCheckConflictsNonADNonAD;
3180 } 3186 }
3181 topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") ); 3187 topLevelWidget()->setCaption( i18n("Checking conflicts ... please wait") );
3182 while ( test ) { 3188 while ( test ) {
3183 qApp->processEvents(); 3189 qApp->processEvents();
3184 bool skip = ( test->doesFloat() && !chAD ) || ( !test->doesFloat() && !chNad ); 3190 bool skip = ( test->doesFloat() && !chAD ) || ( !test->doesFloat() && !chNad );
3185 3191
3186 if ( !skip ) { 3192 if ( !skip ) {
3187 if ( !KOPrefs::instance()->mIncludeFree && test->transparency() == KCal::Event::Transparent ) 3193 if ( !KOPrefs::instance()->mIncludeFree && test->transparency() == KCal::Event::Transparent )
3188 skip = true; 3194 skip = true;
3189 } 3195 }
3190 if ( !skip ) { 3196 if ( !skip ) {
3191 if ( filterALL ) { 3197 if ( filterALL ) {
3192 if ( !filterALL->filterCalendarItem( test ) ) { 3198 if ( !filterALL->filterCalendarItem( test ) ) {
3193 skip = true; 3199 skip = true;
@@ -3407,70 +3413,70 @@ void CalendarView::slotSelectPickerDate( QDate d)
3407 else 3413 else
3408 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); 3414 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED);
3409 mMoveIncidence = newInc; 3415 mMoveIncidence = newInc;
3410 3416
3411#endif 3417#endif
3412 } 3418 }
3413 QTime tim = mMoveIncidence->dtStart().time(); 3419 QTime tim = mMoveIncidence->dtStart().time();
3414 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 3420 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
3415 QDateTime dt ( d,tim ); 3421 QDateTime dt ( d,tim );
3416 mMoveIncidence->setDtStart( dt ); 3422 mMoveIncidence->setDtStart( dt );
3417 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 3423 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
3418 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 3424 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
3419 } else if ( mMoveIncidence->typeID() == journalID ) { 3425 } else if ( mMoveIncidence->typeID() == journalID ) {
3420 QTime tim = mMoveIncidence->dtStart().time(); 3426 QTime tim = mMoveIncidence->dtStart().time();
3421 QDateTime dt ( d,tim ); 3427 QDateTime dt ( d,tim );
3422 mMoveIncidence->setDtStart( dt ); 3428 mMoveIncidence->setDtStart( dt );
3423 updateView(); 3429 updateView();
3424 } 3430 }
3425 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 3431 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
3426 } 3432 }
3427} 3433}
3428 3434
3429void CalendarView::removeCategories() 3435void CalendarView::removeCategories()
3430{ 3436{
3431 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 3437 Q3PtrList<Incidence> incList = mCalendar->rawIncidences();
3432 QStringList catList = KOPrefs::instance()->mCustomCategories; 3438 QStringList catList = KOPrefs::instance()->mCustomCategories;
3433 QStringList catIncList; 3439 QStringList catIncList;
3434 QStringList newCatList; 3440 QStringList newCatList;
3435 Incidence* inc = incList.first(); 3441 Incidence* inc = incList.first();
3436 uint i; 3442 uint i;
3437 while ( inc ) { 3443 while ( inc ) {
3438 newCatList.clear(); 3444 newCatList.clear();
3439 catIncList = inc->categories() ; 3445 catIncList = inc->categories() ;
3440 for( i = 0; i< catIncList.count(); ++i ) { 3446 for( i = 0; i< catIncList.count(); ++i ) {
3441 if ( catList.contains (catIncList[i])) 3447 if ( catList.contains (catIncList[i]))
3442 newCatList.append( catIncList[i] ); 3448 newCatList.append( catIncList[i] );
3443 } 3449 }
3444 newCatList.sort(); 3450 newCatList.sort();
3445 inc->setCategories( newCatList.join(",") ); 3451 inc->setCategories( newCatList.join(",") );
3446 inc = incList.next(); 3452 inc = incList.next();
3447 } 3453 }
3448} 3454}
3449 3455
3450int CalendarView::addCategories() 3456int CalendarView::addCategories()
3451{ 3457{
3452 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 3458 Q3PtrList<Incidence> incList = mCalendar->rawIncidences();
3453 QStringList catList = KOPrefs::instance()->mCustomCategories; 3459 QStringList catList = KOPrefs::instance()->mCustomCategories;
3454 QStringList catIncList; 3460 QStringList catIncList;
3455 Incidence* inc = incList.first(); 3461 Incidence* inc = incList.first();
3456 uint i; 3462 uint i;
3457 int count = 0; 3463 int count = 0;
3458 while ( inc ) { 3464 while ( inc ) {
3459 catIncList = inc->categories() ; 3465 catIncList = inc->categories() ;
3460 for( i = 0; i< catIncList.count(); ++i ) { 3466 for( i = 0; i< catIncList.count(); ++i ) {
3461 if ( !catList.contains (catIncList[i])) { 3467 if ( !catList.contains (catIncList[i])) {
3462 catList.append( catIncList[i] ); 3468 catList.append( catIncList[i] );
3463 //qDebug("add cat %s ", catIncList[i].latin1()); 3469 //qDebug("add cat %s ", catIncList[i].latin1());
3464 ++count; 3470 ++count;
3465 } 3471 }
3466 } 3472 }
3467 inc = incList.next(); 3473 inc = incList.next();
3468 } 3474 }
3469 catList.sort(); 3475 catList.sort();
3470 KOPrefs::instance()->mCustomCategories = catList; 3476 KOPrefs::instance()->mCustomCategories = catList;
3471 return count; 3477 return count;
3472} 3478}
3473 3479
3474void CalendarView::editCategories() 3480void CalendarView::editCategories()
3475{ 3481{
3476 qDebug("CalendarView::editCategories() "); 3482 qDebug("CalendarView::editCategories() ");
@@ -3486,65 +3492,65 @@ void CalendarView::manageCategories()
3486 int dw = QApplication::desktop()->width(); 3492 int dw = QApplication::desktop()->width();
3487 int dh = QApplication::desktop()->height(); 3493 int dh = QApplication::desktop()->height();
3488 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 3494 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
3489 if ( !cp->exec() ) { 3495 if ( !cp->exec() ) {
3490 delete cp; 3496 delete cp;
3491 return; 3497 return;
3492 } 3498 }
3493 int count = 0; 3499 int count = 0;
3494 if ( cp->addCat() ) { 3500 if ( cp->addCat() ) {
3495 count = addCategories(); 3501 count = addCategories();
3496 if ( count ) { 3502 if ( count ) {
3497 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 3503 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
3498 writeSettings(); 3504 writeSettings();
3499 } else 3505 } else
3500 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); 3506 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! "));
3501 } else { 3507 } else {
3502 removeCategories(); 3508 removeCategories();
3503 updateView(); 3509 updateView();
3504 } 3510 }
3505 delete cp; 3511 delete cp;
3506} 3512}
3507 3513
3508void CalendarView::beamIncidence(Incidence * Inc) 3514void CalendarView::beamIncidence(Incidence * Inc)
3509{ 3515{
3510 QPtrList<Incidence> delSel ; 3516 Q3PtrList<Incidence> delSel ;
3511 delSel.append(Inc); 3517 delSel.append(Inc);
3512 beamIncidenceList( delSel ); 3518 beamIncidenceList( delSel );
3513} 3519}
3514void CalendarView::beamCalendar() 3520void CalendarView::beamCalendar()
3515{ 3521{
3516 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 3522 Q3PtrList<Incidence> delSel = mCalendar->rawIncidences();
3517 //qDebug("beamCalendar() "); 3523 //qDebug("beamCalendar() ");
3518 beamIncidenceList( delSel ); 3524 beamIncidenceList( delSel );
3519} 3525}
3520void CalendarView::beamFilteredCalendar() 3526void CalendarView::beamFilteredCalendar()
3521{ 3527{
3522 QPtrList<Incidence> delSel = mCalendar->incidences(); 3528 Q3PtrList<Incidence> delSel = mCalendar->incidences();
3523 //qDebug("beamFilteredCalendar() "); 3529 //qDebug("beamFilteredCalendar() ");
3524 beamIncidenceList( delSel ); 3530 beamIncidenceList( delSel );
3525} 3531}
3526void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 3532void CalendarView::beamIncidenceList(Q3PtrList<Incidence> delSel )
3527{ 3533{
3528 3534
3529 KOBeamPrefs beamDialog; 3535 KOBeamPrefs beamDialog;
3530 if ( beamDialog.exec () == QDialog::Rejected ) 3536 if ( beamDialog.exec () == QDialog::Rejected )
3531 return; 3537 return;
3532#ifdef DESKTOP_VERSION 3538#ifdef DESKTOP_VERSION
3533 QString fn = locateLocal( "tmp", "kopibeamfile" ); 3539 QString fn = locateLocal( "tmp", "kopibeamfile" );
3534#else 3540#else
3535 QString fn = "/tmp/kopibeamfile"; 3541 QString fn = "/tmp/kopibeamfile";
3536#endif 3542#endif
3537 QString mes; 3543 QString mes;
3538 bool createbup = true; 3544 bool createbup = true;
3539 if ( createbup ) { 3545 if ( createbup ) {
3540 QString description = "\n"; 3546 QString description = "\n";
3541 CalendarLocal* cal = new CalendarLocal(); 3547 CalendarLocal* cal = new CalendarLocal();
3542 if ( beamDialog.beamLocal() ) 3548 if ( beamDialog.beamLocal() )
3543 cal->setLocalTime(); 3549 cal->setLocalTime();
3544 else 3550 else
3545 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 3551 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
3546 Incidence *incidence = delSel.first(); 3552 Incidence *incidence = delSel.first();
3547 bool addText = false; 3553 bool addText = false;
3548 if ( delSel.count() < 10 ) 3554 if ( delSel.count() < 10 )
3549 addText = true; 3555 addText = true;
3550 else { 3556 else {
@@ -4294,49 +4300,49 @@ void CalendarView::schedule_publish(Incidence *incidence)
4294 Event *event = 0; 4300 Event *event = 0;
4295 Todo *todo = 0; 4301 Todo *todo = 0;
4296 4302
4297 if (incidence == 0) { 4303 if (incidence == 0) {
4298 incidence = mViewManager->currentView()->selectedIncidences().first(); 4304 incidence = mViewManager->currentView()->selectedIncidences().first();
4299 if (incidence == 0) { 4305 if (incidence == 0) {
4300 incidence = mTodoList->selectedIncidences().first(); 4306 incidence = mTodoList->selectedIncidences().first();
4301 } 4307 }
4302 } 4308 }
4303 if ( incidence && incidence->typeID() == eventID ) { 4309 if ( incidence && incidence->typeID() == eventID ) {
4304 event = static_cast<Event *>(incidence); 4310 event = static_cast<Event *>(incidence);
4305 } else { 4311 } else {
4306 if ( incidence && incidence->typeID() == todoID ) { 4312 if ( incidence && incidence->typeID() == todoID ) {
4307 todo = static_cast<Todo *>(incidence); 4313 todo = static_cast<Todo *>(incidence);
4308 } 4314 }
4309 } 4315 }
4310 4316
4311 if (!event && !todo) { 4317 if (!event && !todo) {
4312 KMessageBox::sorry(this,i18n("No event selected.")); 4318 KMessageBox::sorry(this,i18n("No event selected."));
4313 return; 4319 return;
4314 } 4320 }
4315 4321
4316 PublishDialog *publishdlg = new PublishDialog(); 4322 PublishDialog *publishdlg = new PublishDialog();
4317 if (incidence->attendeeCount()>0) { 4323 if (incidence->attendeeCount()>0) {
4318 QPtrList<Attendee> attendees = incidence->attendees(); 4324 Q3PtrList<Attendee> attendees = incidence->attendees();
4319 attendees.first(); 4325 attendees.first();
4320 while ( attendees.current()!=0 ) { 4326 while ( attendees.current()!=0 ) {
4321 publishdlg->addAttendee(attendees.current()); 4327 publishdlg->addAttendee(attendees.current());
4322 attendees.next(); 4328 attendees.next();
4323 } 4329 }
4324 } 4330 }
4325 bool send = true; 4331 bool send = true;
4326 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { 4332 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) {
4327 if ( publishdlg->exec() != QDialog::Accepted ) 4333 if ( publishdlg->exec() != QDialog::Accepted )
4328 send = false; 4334 send = false;
4329 } 4335 }
4330 if ( send ) { 4336 if ( send ) {
4331 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 4337 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
4332 if ( event ) { 4338 if ( event ) {
4333 Event *ev = new Event(*event); 4339 Event *ev = new Event(*event);
4334 ev->registerObserver(0); 4340 ev->registerObserver(0);
4335 ev->clearAttendees(); 4341 ev->clearAttendees();
4336 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 4342 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
4337 delete(ev); 4343 delete(ev);
4338 } 4344 }
4339 } else { 4345 } else {
4340 if ( todo ) { 4346 if ( todo ) {
4341 Todo *ev = new Todo(*todo); 4347 Todo *ev = new Todo(*todo);
4342 ev->registerObserver(0); 4348 ev->registerObserver(0);
@@ -4703,90 +4709,90 @@ void CalendarView::showDates(const DateList &selectedDates)
4703 selDates = KGlobal::locale()->formatDate( date, true); 4709 selDates = KGlobal::locale()->formatDate( date, true);
4704 if (selectedDates.first() < selectedDates.last() ) 4710 if (selectedDates.first() < selectedDates.last() )
4705 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); 4711 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true);
4706 else { 4712 else {
4707 QString addString; 4713 QString addString;
4708 if ( date == QDateTime::currentDateTime().date() ) 4714 if ( date == QDateTime::currentDateTime().date() )
4709 addString = i18n("Today"); 4715 addString = i18n("Today");
4710 else if ( date == QDateTime::currentDateTime().date().addDays(1) ) 4716 else if ( date == QDateTime::currentDateTime().date().addDays(1) )
4711 addString = i18n("Tomorrow"); 4717 addString = i18n("Tomorrow");
4712 else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) 4718 else if ( date == QDateTime::currentDateTime().date().addDays(-1) )
4713 addString = i18n("Yesterday"); 4719 addString = i18n("Yesterday");
4714 else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) 4720 else if ( date == QDateTime::currentDateTime().date().addDays(-2) )
4715 addString = i18n("Day before yesterday"); 4721 addString = i18n("Day before yesterday");
4716 else if ( date == QDateTime::currentDateTime().date().addDays(2) ) 4722 else if ( date == QDateTime::currentDateTime().date().addDays(2) )
4717 addString = i18n("Day after tomorrow"); 4723 addString = i18n("Day after tomorrow");
4718 if ( !addString.isEmpty() ) { 4724 if ( !addString.isEmpty() ) {
4719 topLevelWidget()->setCaption( addString+", " + selDates ); 4725 topLevelWidget()->setCaption( addString+", " + selDates );
4720 return; 4726 return;
4721 } 4727 }
4722 } 4728 }
4723 topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); 4729 topLevelWidget()->setCaption( i18n("Dates: ") + selDates );
4724 4730
4725} 4731}
4726 4732
4727QPtrList<CalFilter> CalendarView::filters() 4733Q3PtrList<CalFilter> CalendarView::filters()
4728{ 4734{
4729 return mFilters; 4735 return mFilters;
4730 4736
4731} 4737}
4732void CalendarView::editFilters() 4738void CalendarView::editFilters()
4733{ 4739{
4734 // kdDebug() << "CalendarView::editFilters()" << endl; 4740 // kdDebug() << "CalendarView::editFilters()" << endl;
4735 4741
4736 CalFilter *filter = mFilters.first(); 4742 CalFilter *filter = mFilters.first();
4737 while(filter) { 4743 while(filter) {
4738 filter = mFilters.next(); 4744 filter = mFilters.next();
4739 } 4745 }
4740 4746
4741 mDialogManager->showFilterEditDialog(&mFilters); 4747 mDialogManager->showFilterEditDialog(&mFilters);
4742 updateFilter(); 4748 updateFilter();
4743} 4749}
4744void CalendarView::toggleFilter() 4750void CalendarView::toggleFilter()
4745{ 4751{
4746 if ( mLeftFrame->isHidden() ) { 4752 if ( mLeftFrame->isHidden() ) {
4747 toggleExpand(); 4753 toggleExpand();
4748 showFilter( true ); 4754 showFilter( true );
4749 } else 4755 } else
4750 showFilter(! mCalEditView->isVisible()); 4756 showFilter(! mCalEditView->isVisible());
4751} 4757}
4752 4758
4753KOFilterView *CalendarView::filterView() 4759KOFilterView *CalendarView::filterView()
4754{ 4760{
4755 return mFilterView; 4761 return mFilterView;
4756} 4762}
4757void CalendarView::selectFilter( int fil ) 4763void CalendarView::selectFilter( int fil )
4758{ 4764{
4759 mFilterView->setSelectedFilter( fil ); 4765 mFilterView->setSelectedFilter( fil );
4760 updateUnmanagedViews(); 4766 updateUnmanagedViews();
4761} 4767}
4762void CalendarView::showFilter(bool visible) 4768void CalendarView::showFilter(bool visible)
4763{ 4769{
4764#if 1 4770#if 1
4765 if (visible) { 4771 if (visible) {
4766 mCalEditView->readConfig(); 4772 mCalEditView->readConfig();
4767 mCalEditView->show(); 4773 mCalEditView->show();
4768 QValueList<int> sizes; 4774 Q3ValueList<int> sizes;
4769 sizes = mLeftFrame->sizes(); 4775 sizes = mLeftFrame->sizes();
4770 if ( sizes.count() == 4 && sizes[3] < 20 ) { 4776 if ( sizes.count() == 4 && sizes[3] < 20 ) {
4771 sizes.clear(); 4777 sizes.clear();
4772 sizes << 100; 4778 sizes << 100;
4773 sizes << 0; 4779 sizes << 0;
4774 sizes << 0; 4780 sizes << 0;
4775 sizes << 100; 4781 sizes << 100;
4776 mLeftFrame->setSizes(sizes); 4782 mLeftFrame->setSizes(sizes);
4777 } 4783 }
4778#if 0 4784#if 0
4779 sizes = mLeftFrame->sizes(); 4785 sizes = mLeftFrame->sizes();
4780 int ccc = 0; 4786 int ccc = 0;
4781 while ( ccc < sizes.count()) { 4787 while ( ccc < sizes.count()) {
4782 qDebug("size %d %d ", ccc, sizes[ccc]); 4788 qDebug("size %d %d ", ccc, sizes[ccc]);
4783 ++ccc; 4789 ++ccc;
4784 } 4790 }
4785#endif 4791#endif
4786 4792
4787 } 4793 }
4788 else { 4794 else {
4789 mCalEditView->hide(); 4795 mCalEditView->hide();
4790 } 4796 }
4791#else 4797#else
4792 if (visible) mFilterView->show(); 4798 if (visible) mFilterView->show();
@@ -4825,78 +4831,78 @@ void CalendarView::filterEdited()
4825 mFilterView->updateFilters(); 4831 mFilterView->updateFilters();
4826 updateFilter(); 4832 updateFilter();
4827 writeSettings(); 4833 writeSettings();
4828} 4834}
4829 4835
4830 4836
4831void CalendarView::takeOverEvent() 4837void CalendarView::takeOverEvent()
4832{ 4838{
4833 Incidence *incidence = currentSelection(); 4839 Incidence *incidence = currentSelection();
4834 4840
4835 if (!incidence) return; 4841 if (!incidence) return;
4836 4842
4837 incidence->setOrganizer(KOPrefs::instance()->email()); 4843 incidence->setOrganizer(KOPrefs::instance()->email());
4838 incidence->recreate(); 4844 incidence->recreate();
4839 incidence->setReadOnly(false); 4845 incidence->setReadOnly(false);
4840 4846
4841 updateView(); 4847 updateView();
4842} 4848}
4843 4849
4844void CalendarView::takeOverCalendar() 4850void CalendarView::takeOverCalendar()
4845{ 4851{
4846 // TODO: Create Calendar::allIncidences() function and use it here 4852 // TODO: Create Calendar::allIncidences() function and use it here
4847 4853
4848 clearAllViews(); 4854 clearAllViews();
4849 QPtrList<Event> events = mCalendar->events(); 4855 Q3PtrList<Event> events = mCalendar->events();
4850 for(uint i=0; i<events.count(); ++i) { 4856 for(uint i=0; i<events.count(); ++i) {
4851 events.at(i)->setOrganizer(KOPrefs::instance()->email()); 4857 events.at(i)->setOrganizer(KOPrefs::instance()->email());
4852 events.at(i)->recreate(); 4858 events.at(i)->recreate();
4853 events.at(i)->setReadOnly(false); 4859 events.at(i)->setReadOnly(false);
4854 } 4860 }
4855 4861
4856 QPtrList<Todo> todos = mCalendar->todos(); 4862 Q3PtrList<Todo> todos = mCalendar->todos();
4857 for(uint i=0; i<todos.count(); ++i) { 4863 for(uint i=0; i<todos.count(); ++i) {
4858 todos.at(i)->setOrganizer(KOPrefs::instance()->email()); 4864 todos.at(i)->setOrganizer(KOPrefs::instance()->email());
4859 todos.at(i)->recreate(); 4865 todos.at(i)->recreate();
4860 todos.at(i)->setReadOnly(false); 4866 todos.at(i)->setReadOnly(false);
4861 } 4867 }
4862 4868
4863 QPtrList<Journal> journals = mCalendar->journals(); 4869 Q3PtrList<Journal> journals = mCalendar->journals();
4864 for(uint i=0; i<journals.count(); ++i) { 4870 for(uint i=0; i<journals.count(); ++i) {
4865 journals.at(i)->setOrganizer(KOPrefs::instance()->email()); 4871 journals.at(i)->setOrganizer(KOPrefs::instance()->email());
4866 journals.at(i)->recreate(); 4872 journals.at(i)->recreate();
4867 journals.at(i)->setReadOnly(false); 4873 journals.at(i)->setReadOnly(false);
4868 } 4874 }
4869 4875
4870 updateView(); 4876 updateView();
4871} 4877}
4872 4878
4873void CalendarView::showIntro() 4879void CalendarView::showIntro()
4874{ 4880{
4875 kdDebug() << "To be implemented." << endl; 4881 kdDebug() << "To be implemented." << endl;
4876} 4882}
4877 4883
4878QWidgetStack *CalendarView::viewStack() 4884Q3WidgetStack *CalendarView::viewStack()
4879{ 4885{
4880 return mRightFrame; 4886 return mRightFrame;
4881} 4887}
4882 4888
4883QWidget *CalendarView::leftFrame() 4889QWidget *CalendarView::leftFrame()
4884{ 4890{
4885 return ( QWidget *)mLeftFrame; 4891 return ( QWidget *)mLeftFrame;
4886} 4892}
4887 4893
4888DateNavigator *CalendarView::dateNavigator() 4894DateNavigator *CalendarView::dateNavigator()
4889{ 4895{
4890 return mNavigator; 4896 return mNavigator;
4891} 4897}
4892 4898
4893KDateNavigator* CalendarView::dateNavigatorWidget() 4899KDateNavigator* CalendarView::dateNavigatorWidget()
4894{ 4900{
4895 return mDateNavigator->navigatorView(); 4901 return mDateNavigator->navigatorView();
4896} 4902}
4897void CalendarView::toggleDateNavigatorWidget() 4903void CalendarView::toggleDateNavigatorWidget()
4898{ 4904{
4899 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; 4905 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ;
4900 4906
4901 if (!KOPrefs::instance()->mShowDateNavigator ) 4907 if (!KOPrefs::instance()->mShowDateNavigator )
4902 mDateNavigator->hide(); 4908 mDateNavigator->hide();
@@ -5039,76 +5045,76 @@ void CalendarView::deleteIncidence(Incidence *incidence)
5039 return; 5045 return;
5040 } 5046 }
5041 if ( incidence ) { 5047 if ( incidence ) {
5042 DeleteIncidenceVisitor v; 5048 DeleteIncidenceVisitor v;
5043 v.act( incidence, this ); 5049 v.act( incidence, this );
5044 } 5050 }
5045} 5051}
5046 5052
5047 5053
5048void CalendarView::lookForOutgoingMessages() 5054void CalendarView::lookForOutgoingMessages()
5049{ 5055{
5050 OutgoingDialog *ogd = mDialogManager->outgoingDialog(); 5056 OutgoingDialog *ogd = mDialogManager->outgoingDialog();
5051 ogd->loadMessages(); 5057 ogd->loadMessages();
5052} 5058}
5053 5059
5054void CalendarView::lookForIncomingMessages() 5060void CalendarView::lookForIncomingMessages()
5055{ 5061{
5056 IncomingDialog *icd = mDialogManager->incomingDialog(); 5062 IncomingDialog *icd = mDialogManager->incomingDialog();
5057 icd->retrieve(); 5063 icd->retrieve();
5058} 5064}
5059 5065
5060bool CalendarView::removeCompletedSubTodos( Todo* t ) 5066bool CalendarView::removeCompletedSubTodos( Todo* t )
5061{ 5067{
5062 bool deleteTodo = true; 5068 bool deleteTodo = true;
5063 QPtrList<Incidence> subTodos; 5069 Q3PtrList<Incidence> subTodos;
5064 Incidence *aTodo; 5070 Incidence *aTodo;
5065 subTodos = t->relations(); 5071 subTodos = t->relations();
5066 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { 5072 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
5067 if (! removeCompletedSubTodos( (Todo*) aTodo )) 5073 if (! removeCompletedSubTodos( (Todo*) aTodo ))
5068 deleteTodo = false; 5074 deleteTodo = false;
5069 } 5075 }
5070 if ( deleteTodo ) { 5076 if ( deleteTodo ) {
5071 if ( t->isCompleted() && !t->doesRecur()) { 5077 if ( t->isCompleted() && !t->doesRecur()) {
5072 checkExternalId( t ); 5078 checkExternalId( t );
5073 mCalendar->deleteTodo( t ); 5079 mCalendar->deleteTodo( t );
5074 changeTodoDisplay( t,KOGlobals::EVENTDELETED ); 5080 changeTodoDisplay( t,KOGlobals::EVENTDELETED );
5075 } 5081 }
5076 else 5082 else
5077 deleteTodo = false; 5083 deleteTodo = false;
5078 } 5084 }
5079 return deleteTodo; 5085 return deleteTodo;
5080 5086
5081} 5087}
5082void CalendarView::purgeCompleted() 5088void CalendarView::purgeCompleted()
5083{ 5089{
5084 int result = KMessageBox::warningContinueCancel(this, 5090 int result = KMessageBox::warningContinueCancel(this,
5085 i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge")); 5091 i18n("Delete all completed todos?\n(Completed recurring todos\nwill not be deleted!)"),i18n("Purge Todos"),i18n("Purge"));
5086 5092
5087 if (result == KMessageBox::Continue) { 5093 if (result == KMessageBox::Continue) {
5088 5094
5089 QPtrList<Todo> todoCal; 5095 Q3PtrList<Todo> todoCal;
5090 QPtrList<Todo> rootTodos; 5096 Q3PtrList<Todo> rootTodos;
5091 //QPtrList<Incidence> rel; 5097 //QPtrList<Incidence> rel;
5092 Todo *aTodo; 5098 Todo *aTodo;
5093 todoCal = calendar()->todos(); 5099 todoCal = calendar()->todos();
5094 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { 5100 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
5095 if ( !aTodo->relatedTo() ) 5101 if ( !aTodo->relatedTo() )
5096 rootTodos.append( aTodo ); 5102 rootTodos.append( aTodo );
5097 } 5103 }
5098 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { 5104 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) {
5099 removeCompletedSubTodos( aTodo ); 5105 removeCompletedSubTodos( aTodo );
5100 } 5106 }
5101 5107
5102 updateView(); 5108 updateView();
5103 } 5109 }
5104} 5110}
5105 5111
5106void CalendarView::slotCalendarChanged() 5112void CalendarView::slotCalendarChanged()
5107{ 5113{
5108 ; 5114 ;
5109} 5115}
5110 5116
5111void CalendarView::keyPressEvent ( QKeyEvent *e) 5117void CalendarView::keyPressEvent ( QKeyEvent *e)
5112{ 5118{
5113 //qDebug("CalendarView::keyPressEvent "); 5119 //qDebug("CalendarView::keyPressEvent ");
5114 e->ignore(); 5120 e->ignore();