summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index a9de65a..7c8316f 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,2766 +1,2767 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Requires the Qt and KDE widget libraries, available at no cost at 4 Requires the Qt and KDE widget libraries, available at no cost at
5 http://www.troll.no and http://www.kde.org respectively 5 http://www.troll.no and http://www.kde.org respectively
6 6
7 Copyright (c) 1997, 1998, 1999 7 Copyright (c) 1997, 1998, 1999
8 Preston Brown (preston.brown@yale.edu) 8 Preston Brown (preston.brown@yale.edu)
9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) 9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl)
10 Ian Dawes (iadawes@globalserve.net) 10 Ian Dawes (iadawes@globalserve.net)
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 <qbuttongroup.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 <qprogressbar.h>
41#include <qmultilineedit.h> 41#include <qmultilineedit.h>
42#include <qtimer.h> 42#include <qtimer.h>
43#include <qwidgetstack.h> 43#include <qwidgetstack.h>
44#include <qptrlist.h> 44#include <qptrlist.h>
45#include <qregexp.h> 45#include <qregexp.h>
46#include <qgroupbox.h> 46#include <qgroupbox.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#endif 51#endif
52 52
53#include <kglobal.h> 53#include <kglobal.h>
54#include <kdebug.h> 54#include <kdebug.h>
55#include <kstandarddirs.h> 55#include <kstandarddirs.h>
56#include <kfiledialog.h> 56#include <kfiledialog.h>
57#include <kmessagebox.h> 57#include <kmessagebox.h>
58#include <knotifyclient.h> 58#include <knotifyclient.h>
59#include <kconfig.h> 59#include <kconfig.h>
60 60
61#include <libkdepim/ksyncprefsdialog.h> 61#include <libkdepim/ksyncprefsdialog.h>
62#include <krun.h> 62#include <krun.h>
63#include <kdirwatch.h> 63#include <kdirwatch.h>
64#include <libkdepim/kdatepicker.h> 64#include <libkdepim/kdatepicker.h>
65#include <libkdepim/ksyncprofile.h> 65#include <libkdepim/ksyncprofile.h>
66#include <libkdepim/kpimglobalprefs.h> 66#include <libkdepim/kpimglobalprefs.h>
67 67
68#include <libkcal/vcaldrag.h> 68#include <libkcal/vcaldrag.h>
69#include <libkcal/icaldrag.h> 69#include <libkcal/icaldrag.h>
70#include <libkcal/icalformat.h> 70#include <libkcal/icalformat.h>
71#include <libkcal/vcalformat.h> 71#include <libkcal/vcalformat.h>
72#include <libkcal/scheduler.h> 72#include <libkcal/scheduler.h>
73#include <libkcal/calendarlocal.h> 73#include <libkcal/calendarlocal.h>
74#include <libkcal/journal.h> 74#include <libkcal/journal.h>
75#include <libkcal/calfilter.h> 75#include <libkcal/calfilter.h>
76#include <libkcal/attendee.h> 76#include <libkcal/attendee.h>
77#include <libkcal/dndfactory.h> 77#include <libkcal/dndfactory.h>
78#include <libkcal/freebusy.h> 78#include <libkcal/freebusy.h>
79#include <libkcal/filestorage.h> 79#include <libkcal/filestorage.h>
80#include <libkcal/calendarresources.h> 80#include <libkcal/calendarresources.h>
81#include <libkcal/qtopiaformat.h> 81#include <libkcal/qtopiaformat.h>
82#include "../kalarmd/alarmdialog.h" 82#include "../kalarmd/alarmdialog.h"
83 83
84#ifndef DESKTOP_VERSION 84#ifndef DESKTOP_VERSION
85#include <libkcal/sharpformat.h> 85#include <libkcal/sharpformat.h>
86#include <externalapphandler.h> 86#include <externalapphandler.h>
87#endif 87#endif
88#include <libkcal/phoneformat.h> 88#include <libkcal/phoneformat.h>
89#ifndef KORG_NOMAIL 89#ifndef KORG_NOMAIL
90#include "komailclient.h" 90#include "komailclient.h"
91#endif 91#endif
92#ifndef KORG_NOPRINTER 92#ifndef KORG_NOPRINTER
93#include "calprinter.h" 93#include "calprinter.h"
94#endif 94#endif
95#ifndef KORG_NOPLUGINS 95#ifndef KORG_NOPLUGINS
96#include "kocore.h" 96#include "kocore.h"
97#endif 97#endif
98#include "koeventeditor.h" 98#include "koeventeditor.h"
99#include "kotodoeditor.h" 99#include "kotodoeditor.h"
100#include "koprefs.h" 100#include "koprefs.h"
101#include "koeventviewerdialog.h" 101#include "koeventviewerdialog.h"
102#include "publishdialog.h" 102#include "publishdialog.h"
103#include "kofilterview.h" 103#include "kofilterview.h"
104#include "koglobals.h" 104#include "koglobals.h"
105#include "koviewmanager.h" 105#include "koviewmanager.h"
106#include "koagendaview.h" 106#include "koagendaview.h"
107#include "kodialogmanager.h" 107#include "kodialogmanager.h"
108#include "outgoingdialog.h" 108#include "outgoingdialog.h"
109#include "incomingdialog.h" 109#include "incomingdialog.h"
110#include "statusdialog.h" 110#include "statusdialog.h"
111#include "kdatenavigator.h" 111#include "kdatenavigator.h"
112#include "kotodoview.h" 112#include "kotodoview.h"
113#include "datenavigator.h" 113#include "datenavigator.h"
114#include "resourceview.h" 114#include "resourceview.h"
115#include "navigatorbar.h" 115#include "navigatorbar.h"
116#include "searchdialog.h" 116#include "searchdialog.h"
117#include "mainwindow.h" 117#include "mainwindow.h"
118 118
119#include "calendarview.h" 119#include "calendarview.h"
120#ifndef DESKTOP_VERSION 120#ifndef DESKTOP_VERSION
121#include <qtopia/alarmserver.h> 121#include <qtopia/alarmserver.h>
122#endif 122#endif
123#ifndef _WIN32_ 123#ifndef _WIN32_
124#include <stdlib.h> 124#include <stdlib.h>
125#include <stdio.h> 125#include <stdio.h>
126#include <unistd.h> 126#include <unistd.h>
127#else 127#else
128#include <qprocess.h> 128#include <qprocess.h>
129#endif 129#endif
130 130
131#ifdef DESKTOP_VERSION 131#ifdef DESKTOP_VERSION
132#include <kabc/stdaddressbook.h> 132#include <kabc/stdaddressbook.h>
133#endif 133#endif
134using namespace KOrg; 134using namespace KOrg;
135using namespace KCal; 135using namespace KCal;
136extern int globalFlagBlockAgenda; 136extern int globalFlagBlockAgenda;
137extern int globalFlagBlockStartup; 137extern int globalFlagBlockStartup;
138 138
139 139
140 140
141class KOBeamPrefs : public QDialog 141class KOBeamPrefs : public QDialog
142{ 142{
143 public: 143 public:
144 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : 144 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) :
145 QDialog( parent, name, true ) 145 QDialog( parent, name, true )
146 { 146 {
147 setCaption( i18n("Beam Options") ); 147 setCaption( i18n("Beam Options") );
148 QVBoxLayout* lay = new QVBoxLayout( this ); 148 QVBoxLayout* lay = new QVBoxLayout( this );
149 lay->setSpacing( 3 ); 149 lay->setSpacing( 3 );
150 lay->setMargin( 3 ); 150 lay->setMargin( 3 );
151 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); 151 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this );
152 lay->addWidget( format ); 152 lay->addWidget( format );
153 format->setExclusive ( true ) ; 153 format->setExclusive ( true ) ;
154 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); 154 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this );
155 lay->addWidget( time ); time->setExclusive ( true ) ; 155 lay->addWidget( time ); time->setExclusive ( true ) ;
156 vcal = new QRadioButton(" vCalendar ", format ); 156 vcal = new QRadioButton(" vCalendar ", format );
157 ical = new QRadioButton(" iCalendar ", format ); 157 ical = new QRadioButton(" iCalendar ", format );
158 vcal->setChecked( true ); 158 vcal->setChecked( true );
159 tz = new QRadioButton(i18n(" With timezone "), time ); 159 tz = new QRadioButton(i18n(" With timezone "), time );
160 local = new QRadioButton(i18n(" Local time "), time ); 160 local = new QRadioButton(i18n(" Local time "), time );
161 tz->setChecked( true ); 161 tz->setChecked( true );
162 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); 162 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this );
163 lay->addWidget( ok ); 163 lay->addWidget( ok );
164 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 164 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
165 lay->addWidget( cancel ); 165 lay->addWidget( cancel );
166 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 166 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
167 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 167 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
168 resize( 200, 200 ); 168 resize( 200, 200 );
169 } 169 }
170 170
171 bool beamVcal() { return vcal->isChecked(); } 171 bool beamVcal() { return vcal->isChecked(); }
172 bool beamLocal() { return local->isChecked(); } 172 bool beamLocal() { return local->isChecked(); }
173private: 173private:
174 QRadioButton* vcal, *ical, *local, *tz; 174 QRadioButton* vcal, *ical, *local, *tz;
175}; 175};
176class KOCatPrefs : public QDialog 176class KOCatPrefs : public QDialog
177{ 177{
178 public: 178 public:
179 KOCatPrefs( QWidget *parent=0, const char *name=0 ) : 179 KOCatPrefs( QWidget *parent=0, const char *name=0 ) :
180 QDialog( parent, name, true ) 180 QDialog( parent, name, true )
181 { 181 {
182 setCaption( i18n("Manage new Categories") ); 182 setCaption( i18n("Manage new Categories") );
183 QVBoxLayout* lay = new QVBoxLayout( this ); 183 QVBoxLayout* lay = new QVBoxLayout( this );
184 lay->setSpacing( 3 ); 184 lay->setSpacing( 3 );
185 lay->setMargin( 3 ); 185 lay->setMargin( 3 );
186 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); 186 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this );
187 lay->addWidget( lab ); 187 lay->addWidget( lab );
188 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 188 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
189 lay->addWidget( format ); 189 lay->addWidget( format );
190 format->setExclusive ( true ) ; 190 format->setExclusive ( true ) ;
191 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 191 addCatBut = new QRadioButton(i18n("Add to category list"), format );
192 new QRadioButton(i18n("Remove from Events/Todos"), format ); 192 new QRadioButton(i18n("Remove from Events/Todos"), format );
193 addCatBut->setChecked( true ); 193 addCatBut->setChecked( true );
194 QPushButton * ok = new QPushButton( i18n("OK"), this ); 194 QPushButton * ok = new QPushButton( i18n("OK"), this );
195 lay->addWidget( ok ); 195 lay->addWidget( ok );
196 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 196 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
197 lay->addWidget( cancel ); 197 lay->addWidget( cancel );
198 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 198 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
199 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 199 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
200 resize( 200, 200 ); 200 resize( 200, 200 );
201 } 201 }
202 202
203 bool addCat() { return addCatBut->isChecked(); } 203 bool addCat() { return addCatBut->isChecked(); }
204private: 204private:
205 QRadioButton* addCatBut; 205 QRadioButton* addCatBut;
206}; 206};
207 207
208 208
209 209
210CalendarView::CalendarView( CalendarResources *calendar, 210CalendarView::CalendarView( CalendarResources *calendar,
211 QWidget *parent, const char *name ) 211 QWidget *parent, const char *name )
212 : CalendarViewBase( parent, name ), 212 : CalendarViewBase( parent, name ),
213 mCalendar( calendar ), 213 mCalendar( calendar ),
214 mResourceManager( calendar->resourceManager() ) 214 mResourceManager( calendar->resourceManager() )
215{ 215{
216 216
217 mEventEditor = 0; 217 mEventEditor = 0;
218 mTodoEditor = 0; 218 mTodoEditor = 0;
219 219
220 init(); 220 init();
221} 221}
222 222
223CalendarView::CalendarView( Calendar *calendar, 223CalendarView::CalendarView( Calendar *calendar,
224 QWidget *parent, const char *name ) 224 QWidget *parent, const char *name )
225 : CalendarViewBase( parent, name ), 225 : CalendarViewBase( parent, name ),
226 mCalendar( calendar ), 226 mCalendar( calendar ),
227 mResourceManager( 0 ) 227 mResourceManager( 0 )
228{ 228{
229 229
230 mEventEditor = 0; 230 mEventEditor = 0;
231 mTodoEditor = 0; 231 mTodoEditor = 0;
232 init();} 232 init();}
233 233
234void CalendarView::init() 234void CalendarView::init()
235{ 235{
236 mBlockShowDates = false; 236 mBlockShowDates = false;
237 beamDialog = new KOBeamPrefs(); 237 beamDialog = new KOBeamPrefs();
238 mDatePickerMode = 0; 238 mDatePickerMode = 0;
239 mCurrentSyncDevice = ""; 239 mCurrentSyncDevice = "";
240 writeLocale(); 240 writeLocale();
241 mViewManager = new KOViewManager( this ); 241 mViewManager = new KOViewManager( this );
242 mDialogManager = new KODialogManager( this ); 242 mDialogManager = new KODialogManager( this );
243 mEventViewerDialog = 0; 243 mEventViewerDialog = 0;
244 mModified = false; 244 mModified = false;
245 mReadOnly = false; 245 mReadOnly = false;
246 mSelectedIncidence = 0; 246 mSelectedIncidence = 0;
247 mCalPrinter = 0; 247 mCalPrinter = 0;
248 mFilters.setAutoDelete(true); 248 mFilters.setAutoDelete(true);
249 249
250 mCalendar->registerObserver( this ); 250 mCalendar->registerObserver( this );
251 // TODO: Make sure that view is updated, when calendar is changed. 251 // TODO: Make sure that view is updated, when calendar is changed.
252 252
253 mStorage = new FileStorage( mCalendar ); 253 mStorage = new FileStorage( mCalendar );
254 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 254 mNavigator = new DateNavigator( this, "datevav", mViewManager );
255 255
256 QBoxLayout *topLayout = (QBoxLayout*)layout(); 256 QBoxLayout *topLayout = (QBoxLayout*)layout();
257#ifndef KORG_NOSPLITTER 257#ifndef KORG_NOSPLITTER
258 // create the main layout frames. 258 // create the main layout frames.
259 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 259 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
260 topLayout->addWidget(mPanner); 260 topLayout->addWidget(mPanner);
261 261
262 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 262 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
263 "CalendarView::LeftFrame"); 263 "CalendarView::LeftFrame");
264 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 264 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
265 265
266 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, 266 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE,
267 "CalendarView::DateNavigator", QDate::currentDate() ); 267 "CalendarView::DateNavigator", QDate::currentDate() );
268 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 268 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
269 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 269 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
270 mTodoList->setNavigator( mNavigator ); 270 mTodoList->setNavigator( mNavigator );
271 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 271 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
272 272
273#ifdef KORG_NORESOURCEVIEW 273#ifdef KORG_NORESOURCEVIEW
274 mResourceView = 0; 274 mResourceView = 0;
275#else 275#else
276 if ( mResourceManager ) { 276 if ( mResourceManager ) {
277 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 277 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
278 mResourceView->updateView(); 278 mResourceView->updateView();
279 connect( mResourceView, SIGNAL( resourcesChanged() ), 279 connect( mResourceView, SIGNAL( resourcesChanged() ),
280 SLOT( updateView() ) ); 280 SLOT( updateView() ) );
281 } else { 281 } else {
282 mResourceView = 0; 282 mResourceView = 0;
283 } 283 }
284#endif 284#endif
285 QWidget *rightBox = new QWidget( mPanner ); 285 QWidget *rightBox = new QWidget( mPanner );
286 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 286 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
287 287
288 mRightFrame = new QWidgetStack( rightBox ); 288 mRightFrame = new QWidgetStack( rightBox );
289 rightLayout->addWidget( mRightFrame, 1 ); 289 rightLayout->addWidget( mRightFrame, 1 );
290 290
291 mLeftFrame = mLeftSplitter; 291 mLeftFrame = mLeftSplitter;
292#else 292#else
293 QWidget *mainBox = new QWidget( this ); 293 QWidget *mainBox = new QWidget( this );
294 QWidget *leftFrame = new QWidget( mainBox ); 294 QWidget *leftFrame = new QWidget( mainBox );
295 295
296 QBoxLayout * mainBoxLayout; 296 QBoxLayout * mainBoxLayout;
297 QBoxLayout * leftFrameLayout; 297 QBoxLayout * leftFrameLayout;
298 if ( KOPrefs::instance()->mVerticalScreen ) { 298 if ( KOPrefs::instance()->mVerticalScreen ) {
299 mainBoxLayout = new QVBoxLayout(mainBox); 299 mainBoxLayout = new QVBoxLayout(mainBox);
300 leftFrameLayout = new QHBoxLayout(leftFrame ); 300 leftFrameLayout = new QHBoxLayout(leftFrame );
301 } else { 301 } else {
302 mainBoxLayout = new QHBoxLayout(mainBox); 302 mainBoxLayout = new QHBoxLayout(mainBox);
303 leftFrameLayout = new QVBoxLayout(leftFrame ); 303 leftFrameLayout = new QVBoxLayout(leftFrame );
304 } 304 }
305 topLayout->addWidget( mainBox ); 305 topLayout->addWidget( mainBox );
306 mainBoxLayout->addWidget (leftFrame); 306 mainBoxLayout->addWidget (leftFrame);
307 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, 307 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE,
308 "CalendarView::DateNavigator", QDate::currentDate()); 308 "CalendarView::DateNavigator", QDate::currentDate());
309 // mDateNavigator->blockSignals( true ); 309 // mDateNavigator->blockSignals( true );
310 leftFrameLayout->addWidget( mDateNavigator ); 310 leftFrameLayout->addWidget( mDateNavigator );
311 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); 311 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView");
312 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall"); 312 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall");
313 mTodoList->setNavigator( mNavigator ); 313 mTodoList->setNavigator( mNavigator );
314 314
315 if ( QApplication::desktop()->width() < 480 ) { 315 if ( QApplication::desktop()->width() < 480 ) {
316 leftFrameLayout->addWidget(mFilterView); 316 leftFrameLayout->addWidget(mFilterView);
317 leftFrameLayout->addWidget(mTodoList, 2 ); 317 leftFrameLayout->addWidget(mTodoList, 2 );
318 318
319 } else { 319 } else {
320 leftFrameLayout->addWidget(mTodoList,2 ); 320 leftFrameLayout->addWidget(mTodoList,2 );
321 leftFrameLayout->addWidget(mFilterView ); 321 leftFrameLayout->addWidget(mFilterView );
322 } 322 }
323 mFilterView->hide(); 323 mFilterView->hide();
324 QWidget *rightBox = new QWidget( mainBox ); 324 QWidget *rightBox = new QWidget( mainBox );
325 mainBoxLayout->addWidget ( rightBox, 10 ); 325 mainBoxLayout->addWidget ( rightBox, 10 );
326 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 326 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
327 mRightFrame = new QWidgetStack( rightBox ); 327 mRightFrame = new QWidgetStack( rightBox );
328 rightLayout->addWidget( mRightFrame, 10 ); 328 rightLayout->addWidget( mRightFrame, 10 );
329 329
330 mLeftFrame = leftFrame; 330 mLeftFrame = leftFrame;
331 if ( KOPrefs::instance()->mVerticalScreen ) { 331 if ( KOPrefs::instance()->mVerticalScreen ) {
332 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 332 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
333 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 333 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
334 } else { 334 } else {
335 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 335 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
336 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 336 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
337 } 337 }
338 if ( !KOPrefs::instance()->mShowDateNavigator) 338 if ( !KOPrefs::instance()->mShowDateNavigator)
339 mDateNavigator->hide(); 339 mDateNavigator->hide();
340 //qDebug("Calendarview Size %d %d ", width(), height()); 340 //qDebug("Calendarview Size %d %d ", width(), height());
341#endif 341#endif
342 342
343 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 343 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
344 SLOT( showDates( const KCal::DateList & ) ) ); 344 SLOT( showDates( const KCal::DateList & ) ) );
345 345
346 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 346 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
347 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 347 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
348 348
349 349
350 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 350 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
351 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 351 mNavigator, SLOT( selectWeek( const QDate & ) ) );
352 352
353 connect( mDateNavigator, SIGNAL( goPrevYear() ), 353 connect( mDateNavigator, SIGNAL( goPrevYear() ),
354 mNavigator, SLOT( selectPreviousYear() ) ); 354 mNavigator, SLOT( selectPreviousYear() ) );
355 connect( mDateNavigator, SIGNAL( goNextYear() ), 355 connect( mDateNavigator, SIGNAL( goNextYear() ),
356 mNavigator, SLOT( selectNextYear() ) ); 356 mNavigator, SLOT( selectNextYear() ) );
357 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 357 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
358 mNavigator, SLOT( selectPreviousMonth() ) ); 358 mNavigator, SLOT( selectPreviousMonth() ) );
359 connect( mDateNavigator, SIGNAL( goNextMonth() ), 359 connect( mDateNavigator, SIGNAL( goNextMonth() ),
360 mNavigator, SLOT( selectNextMonth() ) ); 360 mNavigator, SLOT( selectNextMonth() ) );
361 361
362 connect( mDateNavigator, SIGNAL( goPrevious() ), 362 connect( mDateNavigator, SIGNAL( goPrevious() ),
363 mNavigator, SLOT( selectPrevious() ) ); 363 mNavigator, SLOT( selectPrevious() ) );
364 connect( mDateNavigator, SIGNAL( goNext() ), 364 connect( mDateNavigator, SIGNAL( goNext() ),
365 mNavigator, SLOT( selectNext() ) ); 365 mNavigator, SLOT( selectNext() ) );
366 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 366 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
367 mNavigator, SLOT( slotMonthSelect( int ) ) ); 367 mNavigator, SLOT( slotMonthSelect( int ) ) );
368 368
369 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 369 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
370 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 370 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
371 371
372 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), 372 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ),
373 SLOT( eventAdded( Event *) ) ); 373 SLOT( eventAdded( Event *) ) );
374 374
375 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 375 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
376 376
377 connect( this, SIGNAL( configChanged() ), 377 connect( this, SIGNAL( configChanged() ),
378 mDateNavigator, SLOT( updateConfig() ) ); 378 mDateNavigator, SLOT( updateConfig() ) );
379 379
380 connect( mTodoList, SIGNAL( newTodoSignal() ), 380 connect( mTodoList, SIGNAL( newTodoSignal() ),
381 SLOT( newTodo() ) ); 381 SLOT( newTodo() ) );
382 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 382 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
383 SLOT( newSubTodo( Todo * ) ) ); 383 SLOT( newSubTodo( Todo * ) ) );
384 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 384 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
385 SLOT( editTodo( Todo * ) ) ); 385 SLOT( editTodo( Todo * ) ) );
386 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 386 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
387 SLOT( showTodo( Todo *) ) ); 387 SLOT( showTodo( Todo *) ) );
388 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 388 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
389 SLOT( deleteTodo( Todo *) ) ); 389 SLOT( deleteTodo( Todo *) ) );
390 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 390 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
391 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 391 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
392 SLOT( purgeCompleted() ) ); 392 SLOT( purgeCompleted() ) );
393 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 393 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
394 SIGNAL( todoModified( Todo *, int ) ) ); 394 SIGNAL( todoModified( Todo *, int ) ) );
395 395
396 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 396 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
397 this, SLOT ( cloneIncidence( Incidence * ) ) ); 397 this, SLOT ( cloneIncidence( Incidence * ) ) );
398 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 398 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
399 this, SLOT (cancelIncidence( Incidence * ) ) ); 399 this, SLOT (cancelIncidence( Incidence * ) ) );
400 400
401 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 401 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
402 this, SLOT ( moveIncidence( Incidence * ) ) ); 402 this, SLOT ( moveIncidence( Incidence * ) ) );
403 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 403 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
404 this, SLOT ( beamIncidence( Incidence * ) ) ); 404 this, SLOT ( beamIncidence( Incidence * ) ) );
405 405
406 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 406 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
407 this, SLOT ( todo_unsub( Todo * ) ) ); 407 this, SLOT ( todo_unsub( Todo * ) ) );
408 408
409 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 409 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
410 this, SLOT ( todo_resub( Todo *,Todo * ) ) ); 410 this, SLOT ( todo_resub( Todo *,Todo * ) ) );
411 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 411 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
412 SLOT( updateTodo( Todo *, int ) ) ); 412 SLOT( updateTodo( Todo *, int ) ) );
413 connect( this, SIGNAL( todoModified( Todo *, int )), this, 413 connect( this, SIGNAL( todoModified( Todo *, int )), this,
414 SLOT( changeTodoDisplay( Todo *, int ) ) ); 414 SLOT( changeTodoDisplay( Todo *, int ) ) );
415 415
416 416
417 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 417 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
418 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 418 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
419 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 419 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
420 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 420 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
421 421
422 422
423 423
424 424
425 425
426 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 426 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
427 SLOT(checkClipboard())); 427 SLOT(checkClipboard()));
428 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 428 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
429 SLOT( processTodoListSelection( Incidence * ) ) ); 429 SLOT( processTodoListSelection( Incidence * ) ) );
430 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 430 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
431 431
432 // kdDebug() << "CalendarView::CalendarView() done" << endl; 432 // kdDebug() << "CalendarView::CalendarView() done" << endl;
433 433
434 mDateFrame = new QVBox(0,0,WType_Popup); 434 mDateFrame = new QVBox(0,0,WType_Popup);
435 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 435 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
436 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 436 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
437 mDateFrame->setLineWidth(3); 437 mDateFrame->setLineWidth(3);
438 mDateFrame->hide(); 438 mDateFrame->hide();
439 mDateFrame->setCaption( i18n( "Pick a date to display")); 439 mDateFrame->setCaption( i18n( "Pick a date to display"));
440 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 440 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
441 441
442 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 442 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
443 443
444 mEventEditor = mDialogManager->getEventEditor(); 444 mEventEditor = mDialogManager->getEventEditor();
445 mTodoEditor = mDialogManager->getTodoEditor(); 445 mTodoEditor = mDialogManager->getTodoEditor();
446 446
447 mFlagEditDescription = false; 447 mFlagEditDescription = false;
448 448
449 mSuspendTimer = new QTimer( this ); 449 mSuspendTimer = new QTimer( this );
450 mAlarmTimer = new QTimer( this ); 450 mAlarmTimer = new QTimer( this );
451 mRecheckAlarmTimer = new QTimer( this ); 451 mRecheckAlarmTimer = new QTimer( this );
452 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 452 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
453 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 453 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
454 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 454 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
455 mAlarmDialog = new AlarmDialog( this ); 455 mAlarmDialog = new AlarmDialog( this );
456 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 456 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
457 mAlarmDialog->setServerNotification( false ); 457 mAlarmDialog->setServerNotification( false );
458 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 458 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
459 459
460 460
461#ifndef DESKTOP_VERSION 461#ifndef DESKTOP_VERSION
462//US listen for arriving address resultsets 462//US listen for arriving address resultsets
463 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), 463 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)),
464 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 464 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
465#endif 465#endif
466 466
467} 467}
468 468
469 469
470CalendarView::~CalendarView() 470CalendarView::~CalendarView()
471{ 471{
472 // kdDebug() << "~CalendarView()" << endl; 472 // kdDebug() << "~CalendarView()" << endl;
473 //qDebug("CalendarView::~CalendarView() "); 473 //qDebug("CalendarView::~CalendarView() ");
474 delete mDialogManager; 474 delete mDialogManager;
475 delete mViewManager; 475 delete mViewManager;
476 delete mStorage; 476 delete mStorage;
477 delete mDateFrame ; 477 delete mDateFrame ;
478 delete beamDialog; 478 delete beamDialog;
479 //kdDebug() << "~CalendarView() done" << endl; 479 //kdDebug() << "~CalendarView() done" << endl;
480} 480}
481 481
482void CalendarView::showDay( QDate d ) 482void CalendarView::showDay( QDate d )
483{ 483{
484 dateNavigator()->blockSignals( true ); 484 dateNavigator()->blockSignals( true );
485 dateNavigator()->selectDate( d ); 485 dateNavigator()->selectDate( d );
486 dateNavigator()->blockSignals( false ); 486 dateNavigator()->blockSignals( false );
487 mViewManager->showDayView(); 487 mViewManager->showDayView();
488 //dateNavigator()->selectDate( d ); 488 //dateNavigator()->selectDate( d );
489} 489}
490void CalendarView::timerAlarm() 490void CalendarView::timerAlarm()
491{ 491{
492 //qDebug("CalendarView::timerAlarm() "); 492 //qDebug("CalendarView::timerAlarm() ");
493 computeAlarm(mAlarmNotification ); 493 computeAlarm(mAlarmNotification );
494} 494}
495 495
496void CalendarView::suspendAlarm() 496void CalendarView::suspendAlarm()
497{ 497{
498 //qDebug(" CalendarView::suspendAlarm() "); 498 //qDebug(" CalendarView::suspendAlarm() ");
499 computeAlarm(mSuspendAlarmNotification ); 499 computeAlarm(mSuspendAlarmNotification );
500 500
501} 501}
502 502
503void CalendarView::startAlarm( QString mess , QString filename) 503void CalendarView::startAlarm( QString mess , QString filename)
504{ 504{
505 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 505 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
506 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); 506 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
507 507
508} 508}
509 509
510void CalendarView::checkNextTimerAlarm() 510void CalendarView::checkNextTimerAlarm()
511{ 511{
512 mCalendar->checkAlarmForIncidence( 0, true ); 512 mCalendar->checkAlarmForIncidence( 0, true );
513} 513}
514 514
515void CalendarView::computeAlarm( QString msg ) 515void CalendarView::computeAlarm( QString msg )
516{ 516{
517 517
518 QString mess = msg; 518 QString mess = msg;
519 QString mAlarmMessage = mess.mid( 9 ); 519 QString mAlarmMessage = mess.mid( 9 );
520 QString filename = MainWindow::resourcePath(); 520 QString filename = MainWindow::resourcePath();
521 filename += "koalarm.wav"; 521 filename += "koalarm.wav";
522 QString tempfilename; 522 QString tempfilename;
523 if ( mess.left( 13 ) == "suspend_alarm") { 523 if ( mess.left( 13 ) == "suspend_alarm") {
524 bool error = false; 524 bool error = false;
525 int len = mess.mid( 13 ).find("+++"); 525 int len = mess.mid( 13 ).find("+++");
526 if ( len < 2 ) 526 if ( len < 2 )
527 error = true; 527 error = true;
528 else { 528 else {
529 tempfilename = mess.mid( 13, len ); 529 tempfilename = mess.mid( 13, len );
530 if ( !QFile::exists( tempfilename ) ) 530 if ( !QFile::exists( tempfilename ) )
531 error = true; 531 error = true;
532 } 532 }
533 if ( ! error ) { 533 if ( ! error ) {
534 filename = tempfilename; 534 filename = tempfilename;
535 } 535 }
536 mAlarmMessage = mess.mid( 13+len+3 ); 536 mAlarmMessage = mess.mid( 13+len+3 );
537 //qDebug("suspend file %s ",tempfilename.latin1() ); 537 //qDebug("suspend file %s ",tempfilename.latin1() );
538 startAlarm( mAlarmMessage, filename); 538 startAlarm( mAlarmMessage, filename);
539 return; 539 return;
540 } 540 }
541 if ( mess.left( 11 ) == "timer_alarm") { 541 if ( mess.left( 11 ) == "timer_alarm") {
542 //mTimerTime = 0; 542 //mTimerTime = 0;
543 startAlarm( mess.mid( 11 ), filename ); 543 startAlarm( mess.mid( 11 ), filename );
544 return; 544 return;
545 } 545 }
546 if ( mess.left( 10 ) == "proc_alarm") { 546 if ( mess.left( 10 ) == "proc_alarm") {
547 bool error = false; 547 bool error = false;
548 int len = mess.mid( 10 ).find("+++"); 548 int len = mess.mid( 10 ).find("+++");
549 if ( len < 2 ) 549 if ( len < 2 )
550 error = true; 550 error = true;
551 else { 551 else {
552 tempfilename = mess.mid( 10, len ); 552 tempfilename = mess.mid( 10, len );
553 if ( !QFile::exists( tempfilename ) ) 553 if ( !QFile::exists( tempfilename ) )
554 error = true; 554 error = true;
555 } 555 }
556 if ( error ) { 556 if ( error ) {
557 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 557 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
558 mAlarmMessage += mess.mid( 10+len+3+9 ); 558 mAlarmMessage += mess.mid( 10+len+3+9 );
559 } else { 559 } else {
560 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 560 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
561 //qDebug("-----system command %s ",tempfilename.latin1() ); 561 //qDebug("-----system command %s ",tempfilename.latin1() );
562#ifndef _WIN32_ 562#ifndef _WIN32_
563 if ( vfork () == 0 ) { 563 if ( vfork () == 0 ) {
564 execl ( tempfilename.latin1(), 0 ); 564 execl ( tempfilename.latin1(), 0 );
565 return; 565 return;
566 } 566 }
567#else 567#else
568 QProcess* p = new QProcess(); 568 QProcess* p = new QProcess();
569 p->addArgument( tempfilename.latin1() ); 569 p->addArgument( tempfilename.latin1() );
570 p->start(); 570 p->start();
571 return; 571 return;
572#endif 572#endif
573 573
574 return; 574 return;
575 } 575 }
576 576
577 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 577 //qDebug("+++++++system command %s ",tempfilename.latin1() );
578 } 578 }
579 if ( mess.left( 11 ) == "audio_alarm") { 579 if ( mess.left( 11 ) == "audio_alarm") {
580 bool error = false; 580 bool error = false;
581 int len = mess.mid( 11 ).find("+++"); 581 int len = mess.mid( 11 ).find("+++");
582 if ( len < 2 ) 582 if ( len < 2 )
583 error = true; 583 error = true;
584 else { 584 else {
585 tempfilename = mess.mid( 11, len ); 585 tempfilename = mess.mid( 11, len );
586 if ( !QFile::exists( tempfilename ) ) 586 if ( !QFile::exists( tempfilename ) )
587 error = true; 587 error = true;
588 } 588 }
589 if ( ! error ) { 589 if ( ! error ) {
590 filename = tempfilename; 590 filename = tempfilename;
591 } 591 }
592 mAlarmMessage = mess.mid( 11+len+3+9 ); 592 mAlarmMessage = mess.mid( 11+len+3+9 );
593 //qDebug("audio file command %s ",tempfilename.latin1() ); 593 //qDebug("audio file command %s ",tempfilename.latin1() );
594 } 594 }
595 if ( mess.left( 9 ) == "cal_alarm") { 595 if ( mess.left( 9 ) == "cal_alarm") {
596 mAlarmMessage = mess.mid( 9 ) ; 596 mAlarmMessage = mess.mid( 9 ) ;
597 } 597 }
598 598
599 startAlarm( mAlarmMessage, filename ); 599 startAlarm( mAlarmMessage, filename );
600 600
601 601
602} 602}
603 603
604void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 604void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
605{ 605{
606 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 606 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
607 607
608 mSuspendAlarmNotification = noti; 608 mSuspendAlarmNotification = noti;
609 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 609 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
610 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 610 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
611 mSuspendTimer->start( ms , true ); 611 mSuspendTimer->start( ms , true );
612 612
613} 613}
614 614
615void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 615void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
616{ 616{
617 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 617 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
618 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 618 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
619#ifndef DESKTOP_VERSION 619#ifndef DESKTOP_VERSION
620 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); 620 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() );
621#endif 621#endif
622 return; 622 return;
623 } 623 }
624 int maxSec; 624 int maxSec;
625 //maxSec = 5; //testing only 625 //maxSec = 5; //testing only
626 maxSec = 86400+3600; // one day+1hour 626 maxSec = 86400+3600; // one day+1hour
627 mAlarmNotification = noti; 627 mAlarmNotification = noti;
628 int sec = QDateTime::currentDateTime().secsTo( qdt ); 628 int sec = QDateTime::currentDateTime().secsTo( qdt );
629 if ( sec > maxSec ) { 629 if ( sec > maxSec ) {
630 mRecheckAlarmTimer->start( maxSec * 1000 ); 630 mRecheckAlarmTimer->start( maxSec * 1000 );
631 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 631 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
632 return; 632 return;
633 } else { 633 } else {
634 mRecheckAlarmTimer->stop(); 634 mRecheckAlarmTimer->stop();
635 } 635 }
636 //qDebug("Alarm timer started with secs: %d ", sec); 636 //qDebug("Alarm timer started with secs: %d ", sec);
637 mAlarmTimer->start( sec *1000 , true ); 637 mAlarmTimer->start( sec *1000 , true );
638 638
639} 639}
640// called by mRecheckAlarmTimer to get next alarm 640// called by mRecheckAlarmTimer to get next alarm
641// we need this, because a QTimer has only a max range of 25 days 641// we need this, because a QTimer has only a max range of 25 days
642void CalendarView::recheckTimerAlarm() 642void CalendarView::recheckTimerAlarm()
643{ 643{
644 mAlarmTimer->stop(); 644 mAlarmTimer->stop();
645 mRecheckAlarmTimer->stop(); 645 mRecheckAlarmTimer->stop();
646 mCalendar->checkAlarmForIncidence( 0, true ); 646 mCalendar->checkAlarmForIncidence( 0, true );
647} 647}
648void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 648void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
649{ 649{
650 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 650 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
651 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 651 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
652#ifndef DESKTOP_VERSION 652#ifndef DESKTOP_VERSION
653 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 653 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
654#endif 654#endif
655 return; 655 return;
656 } 656 }
657 mAlarmTimer->stop(); 657 mAlarmTimer->stop();
658} 658}
659void CalendarView::selectWeekNum ( int num ) 659void CalendarView::selectWeekNum ( int num )
660{ 660{
661 dateNavigator()->blockSignals( true ); 661 dateNavigator()->blockSignals( true );
662 dateNavigator()->selectWeek( num ); 662 dateNavigator()->selectWeek( num );
663 dateNavigator()->blockSignals( false ); 663 dateNavigator()->blockSignals( false );
664 mViewManager->showWeekView(); 664 mViewManager->showWeekView();
665} 665}
666KOViewManager *CalendarView::viewManager() 666KOViewManager *CalendarView::viewManager()
667{ 667{
668 return mViewManager; 668 return mViewManager;
669} 669}
670 670
671KODialogManager *CalendarView::dialogManager() 671KODialogManager *CalendarView::dialogManager()
672{ 672{
673 return mDialogManager; 673 return mDialogManager;
674} 674}
675 675
676QDate CalendarView::startDate() 676QDate CalendarView::startDate()
677{ 677{
678 DateList dates = mNavigator->selectedDates(); 678 DateList dates = mNavigator->selectedDates();
679 679
680 return dates.first(); 680 return dates.first();
681} 681}
682 682
683QDate CalendarView::endDate() 683QDate CalendarView::endDate()
684{ 684{
685 DateList dates = mNavigator->selectedDates(); 685 DateList dates = mNavigator->selectedDates();
686 686
687 return dates.last(); 687 return dates.last();
688} 688}
689 689
690 690
691void CalendarView::createPrinter() 691void CalendarView::createPrinter()
692{ 692{
693#ifndef KORG_NOPRINTER 693#ifndef KORG_NOPRINTER
694 if (!mCalPrinter) { 694 if (!mCalPrinter) {
695 mCalPrinter = new CalPrinter(this, mCalendar); 695 mCalPrinter = new CalPrinter(this, mCalendar);
696 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 696 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
697 } 697 }
698#endif 698#endif
699} 699}
700 700
701 701
702//KOPrefs::instance()->mWriteBackFile 702//KOPrefs::instance()->mWriteBackFile
703//KOPrefs::instance()->mWriteBackExistingOnly 703//KOPrefs::instance()->mWriteBackExistingOnly
704 704
705// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 705// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
706// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 706// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
707// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 707// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
708// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 708// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
709// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 709// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
710// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 710// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
711 711
712int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 712int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
713{ 713{
714 714
715 // 0 equal 715 // 0 equal
716 // 1 take local 716 // 1 take local
717 // 2 take remote 717 // 2 take remote
718 // 3 cancel 718 // 3 cancel
719 QDateTime lastSync = mLastCalendarSync; 719 QDateTime lastSync = mLastCalendarSync;
720 QDateTime localMod = local->lastModified(); 720 QDateTime localMod = local->lastModified();
721 QDateTime remoteMod = remote->lastModified(); 721 QDateTime remoteMod = remote->lastModified();
722 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 722 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
723 bool remCh, locCh; 723 bool remCh, locCh;
724 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 724 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
725 //if ( remCh ) 725 //if ( remCh )
726 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 726 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
727 locCh = ( localMod > mLastCalendarSync ); 727 locCh = ( localMod > mLastCalendarSync );
728 if ( !remCh && ! locCh ) { 728 if ( !remCh && ! locCh ) {
729 //qDebug("both not changed "); 729 //qDebug("both not changed ");
730 lastSync = localMod.addDays(1); 730 lastSync = localMod.addDays(1);
731 if ( mode <= SYNC_PREF_ASK ) 731 if ( mode <= SYNC_PREF_ASK )
732 return 0; 732 return 0;
733 } else { 733 } else {
734 if ( locCh ) { 734 if ( locCh ) {
735 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); 735 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1());
736 lastSync = localMod.addDays( -1 ); 736 lastSync = localMod.addDays( -1 );
737 if ( !remCh ) 737 if ( !remCh )
738 remoteMod = ( lastSync.addDays( -1 ) ); 738 remoteMod = ( lastSync.addDays( -1 ) );
739 } else { 739 } else {
740 //qDebug(" not loc changed "); 740 //qDebug(" not loc changed ");
741 lastSync = localMod.addDays( 1 ); 741 lastSync = localMod.addDays( 1 );
742 if ( remCh ) 742 if ( remCh )
743 remoteMod =( lastSync.addDays( 1 ) ); 743 remoteMod =( lastSync.addDays( 1 ) );
744 744
745 } 745 }
746 } 746 }
747 full = true; 747 full = true;
748 if ( mode < SYNC_PREF_ASK ) 748 if ( mode < SYNC_PREF_ASK )
749 mode = SYNC_PREF_ASK; 749 mode = SYNC_PREF_ASK;
750 } else { 750 } else {
751 if ( localMod == remoteMod ) 751 if ( localMod == remoteMod )
752 // if ( local->revision() == remote->revision() ) 752 // if ( local->revision() == remote->revision() )
753 return 0; 753 return 0;
754 754
755 } 755 }
756 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 756 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
757 757
758 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); 758 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision());
759 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); 759 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() );
760 //full = true; //debug only 760 //full = true; //debug only
761 if ( full ) { 761 if ( full ) {
762 bool equ = false; 762 bool equ = false;
763 if ( local->type() == "Event" ) { 763 if ( local->type() == "Event" ) {
764 equ = (*((Event*) local) == *((Event*) remote)); 764 equ = (*((Event*) local) == *((Event*) remote));
765 } 765 }
766 else if ( local->type() =="Todo" ) 766 else if ( local->type() =="Todo" )
767 equ = (*((Todo*) local) == (*(Todo*) remote)); 767 equ = (*((Todo*) local) == (*(Todo*) remote));
768 else if ( local->type() =="Journal" ) 768 else if ( local->type() =="Journal" )
769 equ = (*((Journal*) local) == *((Journal*) remote)); 769 equ = (*((Journal*) local) == *((Journal*) remote));
770 if ( equ ) { 770 if ( equ ) {
771 //qDebug("equal "); 771 //qDebug("equal ");
772 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 772 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
773 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 773 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
774 } 774 }
775 if ( mode < SYNC_PREF_FORCE_LOCAL ) 775 if ( mode < SYNC_PREF_FORCE_LOCAL )
776 return 0; 776 return 0;
777 777
778 }//else //debug only 778 }//else //debug only
779 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 779 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
780 } 780 }
781 int result; 781 int result;
782 bool localIsNew; 782 bool localIsNew;
783 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); 783 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() );
784 784
785 if ( full && mode < SYNC_PREF_NEWEST ) 785 if ( full && mode < SYNC_PREF_NEWEST )
786 mode = SYNC_PREF_ASK; 786 mode = SYNC_PREF_ASK;
787 787
788 switch( mode ) { 788 switch( mode ) {
789 case SYNC_PREF_LOCAL: 789 case SYNC_PREF_LOCAL:
790 if ( lastSync > remoteMod ) 790 if ( lastSync > remoteMod )
791 return 1; 791 return 1;
792 if ( lastSync > localMod ) 792 if ( lastSync > localMod )
793 return 2; 793 return 2;
794 return 1; 794 return 1;
795 break; 795 break;
796 case SYNC_PREF_REMOTE: 796 case SYNC_PREF_REMOTE:
797 if ( lastSync > remoteMod ) 797 if ( lastSync > remoteMod )
798 return 1; 798 return 1;
799 if ( lastSync > localMod ) 799 if ( lastSync > localMod )
800 return 2; 800 return 2;
801 return 2; 801 return 2;
802 break; 802 break;
803 case SYNC_PREF_NEWEST: 803 case SYNC_PREF_NEWEST:
804 if ( localMod > remoteMod ) 804 if ( localMod > remoteMod )
805 return 1; 805 return 1;
806 else 806 else
807 return 2; 807 return 2;
808 break; 808 break;
809 case SYNC_PREF_ASK: 809 case SYNC_PREF_ASK:
810 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 810 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
811 if ( lastSync > remoteMod ) 811 if ( lastSync > remoteMod )
812 return 1; 812 return 1;
813 if ( lastSync > localMod ) 813 if ( lastSync > localMod )
814 return 2; 814 return 2;
815 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 815 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
816 localIsNew = localMod >= remoteMod; 816 localIsNew = localMod >= remoteMod;
817 if ( localIsNew ) 817 if ( localIsNew )
818 getEventViewerDialog()->setColorMode( 1 ); 818 getEventViewerDialog()->setColorMode( 1 );
819 else 819 else
820 getEventViewerDialog()->setColorMode( 2 ); 820 getEventViewerDialog()->setColorMode( 2 );
821 getEventViewerDialog()->setIncidence(local); 821 getEventViewerDialog()->setIncidence(local);
822 if ( localIsNew ) 822 if ( localIsNew )
823 getEventViewerDialog()->setColorMode( 2 ); 823 getEventViewerDialog()->setColorMode( 2 );
824 else 824 else
825 getEventViewerDialog()->setColorMode( 1 ); 825 getEventViewerDialog()->setColorMode( 1 );
826 getEventViewerDialog()->addIncidence(remote); 826 getEventViewerDialog()->addIncidence(remote);
827 getEventViewerDialog()->setColorMode( 0 ); 827 getEventViewerDialog()->setColorMode( 0 );
828 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 828 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
829 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 829 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
830 getEventViewerDialog()->showMe(); 830 getEventViewerDialog()->showMe();
831 result = getEventViewerDialog()->executeS( localIsNew ); 831 result = getEventViewerDialog()->executeS( localIsNew );
832 return result; 832 return result;
833 833
834 break; 834 break;
835 case SYNC_PREF_FORCE_LOCAL: 835 case SYNC_PREF_FORCE_LOCAL:
836 return 1; 836 return 1;
837 break; 837 break;
838 case SYNC_PREF_FORCE_REMOTE: 838 case SYNC_PREF_FORCE_REMOTE:
839 return 2; 839 return 2;
840 break; 840 break;
841 841
842 default: 842 default:
843 // SYNC_PREF_TAKE_BOTH not implemented 843 // SYNC_PREF_TAKE_BOTH not implemented
844 break; 844 break;
845 } 845 }
846 return 0; 846 return 0;
847} 847}
848Event* CalendarView::getLastSyncEvent() 848Event* CalendarView::getLastSyncEvent()
849{ 849{
850 Event* lse; 850 Event* lse;
851 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 851 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
852 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 852 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
853 if (!lse) { 853 if (!lse) {
854 lse = new Event(); 854 lse = new Event();
855 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 855 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
856 QString sum = ""; 856 QString sum = "";
857 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 857 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
858 sum = "E: "; 858 sum = "E: ";
859 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 859 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
860 lse->setDtStart( mLastCalendarSync ); 860 lse->setDtStart( mLastCalendarSync );
861 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 861 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
862 lse->setCategories( i18n("SyncEvent") ); 862 lse->setCategories( i18n("SyncEvent") );
863 lse->setReadOnly( true ); 863 lse->setReadOnly( true );
864 mCalendar->addEvent( lse ); 864 mCalendar->addEvent( lse );
865 } 865 }
866 866
867 return lse; 867 return lse;
868 868
869} 869}
870 870
871// we check, if the to delete event has a id for a profile 871// we check, if the to delete event has a id for a profile
872// if yes, we set this id in the profile to delete 872// if yes, we set this id in the profile to delete
873void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 873void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
874{ 874{
875 if ( lastSync.count() == 0 ) { 875 if ( lastSync.count() == 0 ) {
876 //qDebug(" lastSync.count() == 0"); 876 //qDebug(" lastSync.count() == 0");
877 return; 877 return;
878 } 878 }
879 if ( toDelete->type() == "Journal" ) 879 if ( toDelete->type() == "Journal" )
880 return; 880 return;
881 881
882 Event* eve = lastSync.first(); 882 Event* eve = lastSync.first();
883 883
884 while ( eve ) { 884 while ( eve ) {
885 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 885 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
886 if ( !id.isEmpty() ) { 886 if ( !id.isEmpty() ) {
887 QString des = eve->description(); 887 QString des = eve->description();
888 QString pref = "e"; 888 QString pref = "e";
889 if ( toDelete->type() == "Todo" ) 889 if ( toDelete->type() == "Todo" )
890 pref = "t"; 890 pref = "t";
891 des += pref+ id + ","; 891 des += pref+ id + ",";
892 eve->setReadOnly( false ); 892 eve->setReadOnly( false );
893 eve->setDescription( des ); 893 eve->setDescription( des );
894 //qDebug("setdes %s ", des.latin1()); 894 //qDebug("setdes %s ", des.latin1());
895 eve->setReadOnly( true ); 895 eve->setReadOnly( true );
896 } 896 }
897 eve = lastSync.next(); 897 eve = lastSync.next();
898 } 898 }
899 899
900} 900}
901void CalendarView::checkExternalId( Incidence * inc ) 901void CalendarView::checkExternalId( Incidence * inc )
902{ 902{
903 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 903 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
904 checkExternSyncEvent( lastSync, inc ); 904 checkExternSyncEvent( lastSync, inc );
905 905
906} 906}
907bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 907bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
908{ 908{
909 bool syncOK = true; 909 bool syncOK = true;
910 int addedEvent = 0; 910 int addedEvent = 0;
911 int addedEventR = 0; 911 int addedEventR = 0;
912 int deletedEventR = 0; 912 int deletedEventR = 0;
913 int deletedEventL = 0; 913 int deletedEventL = 0;
914 int changedLocal = 0; 914 int changedLocal = 0;
915 int changedRemote = 0; 915 int changedRemote = 0;
916 int filteredIN = 0; 916 int filteredIN = 0;
917 int filteredOUT = 0; 917 int filteredOUT = 0;
918 //QPtrList<Event> el = local->rawEvents(); 918 //QPtrList<Event> el = local->rawEvents();
919 Event* eventR; 919 Event* eventR;
920 QString uid; 920 QString uid;
921 int take; 921 int take;
922 Event* eventL; 922 Event* eventL;
923 Event* eventRSync; 923 Event* eventRSync;
924 Event* eventLSync; 924 Event* eventLSync;
925 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 925 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
926 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 926 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
927 bool fullDateRange = false; 927 bool fullDateRange = false;
928 local->resetTempSyncStat(); 928 local->resetTempSyncStat();
929 mLastCalendarSync = QDateTime::currentDateTime(); 929 mLastCalendarSync = QDateTime::currentDateTime();
930 if ( mSyncManager->syncWithDesktop() ) { 930 if ( mSyncManager->syncWithDesktop() ) {
931 remote->resetPilotStat(1); 931 remote->resetPilotStat(1);
932 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 932 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
933 mLastCalendarSync = KSyncManager::mRequestedSyncEvent; 933 mLastCalendarSync = KSyncManager::mRequestedSyncEvent;
934 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); 934 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() );
935 } else { 935 } else {
936 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 936 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
937 } 937 }
938 } 938 }
939 QDateTime modifiedCalendar = mLastCalendarSync; 939 QDateTime modifiedCalendar = mLastCalendarSync;
940 eventLSync = getLastSyncEvent(); 940 eventLSync = getLastSyncEvent();
941 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 941 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
942 if ( eventR ) { 942 if ( eventR ) {
943 eventRSync = (Event*) eventR->clone(); 943 eventRSync = (Event*) eventR->clone();
944 remote->deleteEvent(eventR ); 944 remote->deleteEvent(eventR );
945 945
946 } else { 946 } else {
947 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { 947 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) {
948 eventRSync = (Event*)eventLSync->clone(); 948 eventRSync = (Event*)eventLSync->clone();
949 } else { 949 } else {
950 fullDateRange = true; 950 fullDateRange = true;
951 eventRSync = new Event(); 951 eventRSync = new Event();
952 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 952 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
953 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 953 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
954 eventRSync->setDtStart( mLastCalendarSync ); 954 eventRSync->setDtStart( mLastCalendarSync );
955 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 955 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
956 eventRSync->setCategories( i18n("SyncEvent") ); 956 eventRSync->setCategories( i18n("SyncEvent") );
957 } 957 }
958 } 958 }
959 if ( eventLSync->dtStart() == mLastCalendarSync ) 959 if ( eventLSync->dtStart() == mLastCalendarSync )
960 fullDateRange = true; 960 fullDateRange = true;
961 961
962 if ( ! fullDateRange ) { 962 if ( ! fullDateRange ) {
963 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 963 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
964 964
965 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 965 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
966 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 966 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
967 fullDateRange = true; 967 fullDateRange = true;
968 } 968 }
969 } 969 }
970 if ( mSyncManager->syncWithDesktop() ) { 970 if ( mSyncManager->syncWithDesktop() ) {
971 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); 971 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync );
972 } 972 }
973 if ( fullDateRange ) 973 if ( fullDateRange )
974 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 974 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
975 else 975 else
976 mLastCalendarSync = eventLSync->dtStart(); 976 mLastCalendarSync = eventLSync->dtStart();
977 // for resyncing if own file has changed 977 // for resyncing if own file has changed
978 if ( mCurrentSyncDevice == "deleteaftersync" ) { 978 if ( mCurrentSyncDevice == "deleteaftersync" ) {
979 mLastCalendarSync = loadedFileVersion; 979 mLastCalendarSync = loadedFileVersion;
980 //qDebug("setting mLastCalendarSync "); 980 //qDebug("setting mLastCalendarSync ");
981 } 981 }
982 //qDebug("*************************** "); 982 //qDebug("*************************** ");
983 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); 983 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange);
984 QPtrList<Incidence> er = remote->rawIncidences(); 984 QPtrList<Incidence> er = remote->rawIncidences();
985 Incidence* inR = er.first(); 985 Incidence* inR = er.first();
986 Incidence* inL; 986 Incidence* inL;
987 QProgressBar bar( er.count(),0 ); 987 QProgressBar bar( er.count(),0 );
988 bar.setCaption (i18n("Syncing - close to abort!") ); 988 bar.setCaption (i18n("Syncing - close to abort!") );
989 989
990 // ************** setting up filter ************* 990 // ************** setting up filter *************
991 CalFilter *filterIN = 0; 991 CalFilter *filterIN = 0;
992 CalFilter *filterOUT = 0; 992 CalFilter *filterOUT = 0;
993 CalFilter *filter = mFilters.first(); 993 CalFilter *filter = mFilters.first();
994 while(filter) { 994 while(filter) {
995 if ( filter->name() == mSyncManager->mFilterInCal ) 995 if ( filter->name() == mSyncManager->mFilterInCal )
996 filterIN = filter; 996 filterIN = filter;
997 if ( filter->name() == mSyncManager->mFilterOutCal ) 997 if ( filter->name() == mSyncManager->mFilterOutCal )
998 filterOUT = filter; 998 filterOUT = filter;
999 filter = mFilters.next(); 999 filter = mFilters.next();
1000 } 1000 }
1001 int w = 300; 1001 int w = 300;
1002 if ( QApplication::desktop()->width() < 320 ) 1002 if ( QApplication::desktop()->width() < 320 )
1003 w = 220; 1003 w = 220;
1004 int h = bar.sizeHint().height() ; 1004 int h = bar.sizeHint().height() ;
1005 int dw = QApplication::desktop()->width(); 1005 int dw = QApplication::desktop()->width();
1006 int dh = QApplication::desktop()->height(); 1006 int dh = QApplication::desktop()->height();
1007 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1007 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1008 bar.show(); 1008 bar.show();
1009 int modulo = (er.count()/10)+1; 1009 int modulo = (er.count()/10)+1;
1010 int incCounter = 0; 1010 int incCounter = 0;
1011 while ( inR ) { 1011 while ( inR ) {
1012 if ( ! bar.isVisible() ) 1012 if ( ! bar.isVisible() )
1013 return false; 1013 return false;
1014 if ( incCounter % modulo == 0 ) 1014 if ( incCounter % modulo == 0 )
1015 bar.setProgress( incCounter ); 1015 bar.setProgress( incCounter );
1016 ++incCounter; 1016 ++incCounter;
1017 uid = inR->uid(); 1017 uid = inR->uid();
1018 bool skipIncidence = false; 1018 bool skipIncidence = false;
1019 if ( uid.left(15) == QString("last-syncEvent-") ) 1019 if ( uid.left(15) == QString("last-syncEvent-") )
1020 skipIncidence = true; 1020 skipIncidence = true;
1021 QString idS; 1021 QString idS;
1022 qApp->processEvents(); 1022 qApp->processEvents();
1023 if ( !skipIncidence ) { 1023 if ( !skipIncidence ) {
1024 inL = local->incidence( uid ); 1024 inL = local->incidence( uid );
1025 if ( inL ) { // maybe conflict - same uid in both calendars 1025 if ( inL ) { // maybe conflict - same uid in both calendars
1026 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1026 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1027 //qDebug("take %d %s ", take, inL->summary().latin1()); 1027 //qDebug("take %d %s ", take, inL->summary().latin1());
1028 if ( take == 3 ) 1028 if ( take == 3 )
1029 return false; 1029 return false;
1030 if ( take == 1 ) {// take local ********************** 1030 if ( take == 1 ) {// take local **********************
1031 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1031 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1032 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1032 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1033 else 1033 else
1034 idS = inR->IDStr(); 1034 idS = inR->IDStr();
1035 remote->deleteIncidence( inR ); 1035 remote->deleteIncidence( inR );
1036 inR = inL->clone(); 1036 inR = inL->clone();
1037 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1037 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1038 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1038 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1039 inR->setIDStr( idS ); 1039 inR->setIDStr( idS );
1040 remote->addIncidence( inR ); 1040 remote->addIncidence( inR );
1041 if ( mSyncManager->syncWithDesktop() ) 1041 if ( mSyncManager->syncWithDesktop() )
1042 inR->setPilotId( 2 ); 1042 inR->setPilotId( 2 );
1043 ++changedRemote; 1043 ++changedRemote;
1044 } else {// take remote ********************** 1044 } else {// take remote **********************
1045 idS = inL->IDStr(); 1045 idS = inL->IDStr();
1046 int pid = inL->pilotId(); 1046 int pid = inL->pilotId();
1047 local->deleteIncidence( inL ); 1047 local->deleteIncidence( inL );
1048 inL = inR->clone(); 1048 inL = inR->clone();
1049 if ( mSyncManager->syncWithDesktop() ) 1049 if ( mSyncManager->syncWithDesktop() )
1050 inL->setPilotId( pid ); 1050 inL->setPilotId( pid );
1051 inL->setIDStr( idS ); 1051 inL->setIDStr( idS );
1052 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1052 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1053 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1053 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1054 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1054 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1055 } 1055 }
1056 local->addIncidence( inL ); 1056 local->addIncidence( inL );
1057 ++changedLocal; 1057 ++changedLocal;
1058 } 1058 }
1059 } 1059 }
1060 } else { // no conflict ********** add or delete remote 1060 } else { // no conflict ********** add or delete remote
1061 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ 1061 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){
1062 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1062 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1063 QString des = eventLSync->description(); 1063 QString des = eventLSync->description();
1064 QString pref = "e"; 1064 QString pref = "e";
1065 if ( inR->type() == "Todo" ) 1065 if ( inR->type() == "Todo" )
1066 pref = "t"; 1066 pref = "t";
1067 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1067 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1068 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1068 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1069 //remote->deleteIncidence( inR ); 1069 //remote->deleteIncidence( inR );
1070 ++deletedEventR; 1070 ++deletedEventR;
1071 } else { 1071 } else {
1072 inR->setLastModified( modifiedCalendar ); 1072 inR->setLastModified( modifiedCalendar );
1073 inL = inR->clone(); 1073 inL = inR->clone();
1074 inL->setIDStr( ":" ); 1074 inL->setIDStr( ":" );
1075 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1075 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1076 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1076 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1077 local->addIncidence( inL ); 1077 local->addIncidence( inL );
1078 ++addedEvent; 1078 ++addedEvent;
1079 1079
1080 } 1080 }
1081 } else { 1081 } else {
1082 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1082 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1083 inR->setLastModified( modifiedCalendar ); 1083 inR->setLastModified( modifiedCalendar );
1084 inL = inR->clone(); 1084 inL = inR->clone();
1085 inL->setIDStr( ":" ); 1085 inL->setIDStr( ":" );
1086 local->addIncidence( inL ); 1086 local->addIncidence( inL );
1087 ++addedEvent; 1087 ++addedEvent;
1088 1088
1089 } else { 1089 } else {
1090 checkExternSyncEvent(eventRSyncSharp, inR); 1090 checkExternSyncEvent(eventRSyncSharp, inR);
1091 remote->deleteIncidence( inR ); 1091 remote->deleteIncidence( inR );
1092 ++deletedEventR; 1092 ++deletedEventR;
1093 } 1093 }
1094 } 1094 }
1095 } else { 1095 } else {
1096 ++filteredIN; 1096 ++filteredIN;
1097 } 1097 }
1098 } 1098 }
1099 } 1099 }
1100 inR = er.next(); 1100 inR = er.next();
1101 } 1101 }
1102 QPtrList<Incidence> el = local->rawIncidences(); 1102 QPtrList<Incidence> el = local->rawIncidences();
1103 inL = el.first(); 1103 inL = el.first();
1104 modulo = (el.count()/10)+1; 1104 modulo = (el.count()/10)+1;
1105 bar.setCaption (i18n("Add / remove events") ); 1105 bar.setCaption (i18n("Add / remove events") );
1106 bar.setTotalSteps ( el.count() ) ; 1106 bar.setTotalSteps ( el.count() ) ;
1107 bar.show(); 1107 bar.show();
1108 incCounter = 0; 1108 incCounter = 0;
1109 1109
1110 while ( inL ) { 1110 while ( inL ) {
1111 1111
1112 qApp->processEvents(); 1112 qApp->processEvents();
1113 if ( ! bar.isVisible() ) 1113 if ( ! bar.isVisible() )
1114 return false; 1114 return false;
1115 if ( incCounter % modulo == 0 ) 1115 if ( incCounter % modulo == 0 )
1116 bar.setProgress( incCounter ); 1116 bar.setProgress( incCounter );
1117 ++incCounter; 1117 ++incCounter;
1118 uid = inL->uid(); 1118 uid = inL->uid();
1119 bool skipIncidence = false; 1119 bool skipIncidence = false;
1120 if ( uid.left(15) == QString("last-syncEvent-") ) 1120 if ( uid.left(15) == QString("last-syncEvent-") )
1121 skipIncidence = true; 1121 skipIncidence = true;
1122 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) 1122 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
1123 skipIncidence = true; 1123 skipIncidence = true;
1124 if ( !skipIncidence ) { 1124 if ( !skipIncidence ) {
1125 inR = remote->incidence( uid ); 1125 inR = remote->incidence( uid );
1126 if ( ! inR ) { 1126 if ( ! inR ) {
1127 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ 1127 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){
1128 // no conflict ********** add or delete local 1128 // no conflict ********** add or delete local
1129 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1129 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1130 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1130 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1131 checkExternSyncEvent(eventLSyncSharp, inL); 1131 checkExternSyncEvent(eventLSyncSharp, inL);
1132 local->deleteIncidence( inL ); 1132 local->deleteIncidence( inL );
1133 ++deletedEventL; 1133 ++deletedEventL;
1134 } else { 1134 } else {
1135 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1135 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1136 inL->removeID(mCurrentSyncDevice ); 1136 inL->removeID(mCurrentSyncDevice );
1137 ++addedEventR; 1137 ++addedEventR;
1138 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1138 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1139 inL->setLastModified( modifiedCalendar ); 1139 inL->setLastModified( modifiedCalendar );
1140 inR = inL->clone(); 1140 inR = inL->clone();
1141 inR->setIDStr( ":" ); 1141 inR->setIDStr( ":" );
1142 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1142 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1143 remote->addIncidence( inR ); 1143 remote->addIncidence( inR );
1144 } 1144 }
1145 } 1145 }
1146 } else { 1146 } else {
1147 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1147 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1148 checkExternSyncEvent(eventLSyncSharp, inL); 1148 checkExternSyncEvent(eventLSyncSharp, inL);
1149 local->deleteIncidence( inL ); 1149 local->deleteIncidence( inL );
1150 ++deletedEventL; 1150 ++deletedEventL;
1151 } else { 1151 } else {
1152 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1152 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1153 ++addedEventR; 1153 ++addedEventR;
1154 inL->setLastModified( modifiedCalendar ); 1154 inL->setLastModified( modifiedCalendar );
1155 inR = inL->clone(); 1155 inR = inL->clone();
1156 inR->setIDStr( ":" ); 1156 inR->setIDStr( ":" );
1157 remote->addIncidence( inR ); 1157 remote->addIncidence( inR );
1158 } 1158 }
1159 } 1159 }
1160 } 1160 }
1161 } else { 1161 } else {
1162 ++filteredOUT; 1162 ++filteredOUT;
1163 } 1163 }
1164 } 1164 }
1165 } 1165 }
1166 inL = el.next(); 1166 inL = el.next();
1167 } 1167 }
1168 int delFut = 0; 1168 int delFut = 0;
1169 int remRem = 0; 1169 int remRem = 0;
1170 if ( mSyncManager->mWriteBackInFuture ) { 1170 if ( mSyncManager->mWriteBackInFuture ) {
1171 er = remote->rawIncidences(); 1171 er = remote->rawIncidences();
1172 remRem = er.count(); 1172 remRem = er.count();
1173 inR = er.first(); 1173 inR = er.first();
1174 QDateTime dt; 1174 QDateTime dt;
1175 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); 1175 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) );
1176 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); 1176 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 );
1177 while ( inR ) { 1177 while ( inR ) {
1178 if ( inR->type() == "Todo" ) { 1178 if ( inR->type() == "Todo" ) {
1179 Todo * t = (Todo*)inR; 1179 Todo * t = (Todo*)inR;
1180 if ( t->hasDueDate() ) 1180 if ( t->hasDueDate() )
1181 dt = t->dtDue(); 1181 dt = t->dtDue();
1182 else 1182 else
1183 dt = cur.addSecs( 62 ); 1183 dt = cur.addSecs( 62 );
1184 } 1184 }
1185 else if (inR->type() == "Event" ) { 1185 else if (inR->type() == "Event" ) {
1186 bool ok; 1186 bool ok;
1187 dt = inR->getNextOccurence( cur, &ok ); 1187 dt = inR->getNextOccurence( cur, &ok );
1188 if ( !ok ) 1188 if ( !ok )
1189 dt = cur.addSecs( -62 ); 1189 dt = cur.addSecs( -62 );
1190 } 1190 }
1191 else 1191 else
1192 dt = inR->dtStart(); 1192 dt = inR->dtStart();
1193 if ( dt < cur || dt > end ) { 1193 if ( dt < cur || dt > end ) {
1194 remote->deleteIncidence( inR ); 1194 remote->deleteIncidence( inR );
1195 ++delFut; 1195 ++delFut;
1196 } 1196 }
1197 inR = er.next(); 1197 inR = er.next();
1198 } 1198 }
1199 } 1199 }
1200 bar.hide(); 1200 bar.hide();
1201 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1201 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1202 eventLSync->setReadOnly( false ); 1202 eventLSync->setReadOnly( false );
1203 eventLSync->setDtStart( mLastCalendarSync ); 1203 eventLSync->setDtStart( mLastCalendarSync );
1204 eventRSync->setDtStart( mLastCalendarSync ); 1204 eventRSync->setDtStart( mLastCalendarSync );
1205 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1205 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1206 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1206 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1207 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1207 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1208 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1208 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1209 eventLSync->setReadOnly( true ); 1209 eventLSync->setReadOnly( true );
1210 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); 1210 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL );
1211 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... 1211 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal...
1212 remote->addEvent( eventRSync ); 1212 remote->addEvent( eventRSync );
1213 else 1213 else
1214 delete eventRSync; 1214 delete eventRSync;
1215 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); 1215 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() );
1216 QString mes; 1216 QString mes;
1217 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); 1217 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT );
1218 QString delmess; 1218 QString delmess;
1219 if ( delFut ) { 1219 if ( delFut ) {
1220 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); 1220 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut);
1221 mes += delmess; 1221 mes += delmess;
1222 } 1222 }
1223 mes = i18n("Local calendar changed!\n") +mes; 1223 mes = i18n("Local calendar changed!\n") +mes;
1224 mCalendar->checkAlarmForIncidence( 0, true ); 1224 mCalendar->checkAlarmForIncidence( 0, true );
1225 qDebug( mes ); 1225 qDebug( mes );
1226 if ( mSyncManager->mShowSyncSummary ) { 1226 if ( mSyncManager->mShowSyncSummary ) {
1227 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 1227 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
1228 i18n("KO/Pi Synchronization"),i18n("Write back"))) { 1228 i18n("KO/Pi Synchronization"),i18n("Write back"))) {
1229 qDebug("KO: WB cancelled "); 1229 qDebug("KO: WB cancelled ");
1230 return false; 1230 mSyncManager->mWriteBackFile = false;
1231 return syncOK;
1231 } 1232 }
1232 } 1233 }
1233 return syncOK; 1234 return syncOK;
1234} 1235}
1235 1236
1236void CalendarView::setSyncDevice( QString s ) 1237void CalendarView::setSyncDevice( QString s )
1237{ 1238{
1238 mCurrentSyncDevice= s; 1239 mCurrentSyncDevice= s;
1239} 1240}
1240void CalendarView::setSyncName( QString s ) 1241void CalendarView::setSyncName( QString s )
1241{ 1242{
1242 mCurrentSyncName= s; 1243 mCurrentSyncName= s;
1243} 1244}
1244bool CalendarView::syncCalendar(QString filename, int mode) 1245bool CalendarView::syncCalendar(QString filename, int mode)
1245{ 1246{
1246 //qDebug("syncCalendar %s ", filename.latin1()); 1247 //qDebug("syncCalendar %s ", filename.latin1());
1247 mGlobalSyncMode = SYNC_MODE_NORMAL; 1248 mGlobalSyncMode = SYNC_MODE_NORMAL;
1248 CalendarLocal* calendar = new CalendarLocal(); 1249 CalendarLocal* calendar = new CalendarLocal();
1249 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1250 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1250 FileStorage* storage = new FileStorage( calendar ); 1251 FileStorage* storage = new FileStorage( calendar );
1251 bool syncOK = false; 1252 bool syncOK = false;
1252 storage->setFileName( filename ); 1253 storage->setFileName( filename );
1253 // qDebug("loading ... "); 1254 // qDebug("loading ... ");
1254 if ( storage->load() ) { 1255 if ( storage->load() ) {
1255 getEventViewerDialog()->setSyncMode( true ); 1256 getEventViewerDialog()->setSyncMode( true );
1256 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1257 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1257 getEventViewerDialog()->setSyncMode( false ); 1258 getEventViewerDialog()->setSyncMode( false );
1258 if ( syncOK ) { 1259 if ( syncOK ) {
1259 if ( mSyncManager->mWriteBackFile ) 1260 if ( mSyncManager->mWriteBackFile )
1260 { 1261 {
1261 storage->setSaveFormat( new ICalFormat() ); 1262 storage->setSaveFormat( new ICalFormat() );
1262 storage->save(); 1263 storage->save();
1263 } 1264 }
1264 } 1265 }
1265 setModified( true ); 1266 setModified( true );
1266 } 1267 }
1267 delete storage; 1268 delete storage;
1268 delete calendar; 1269 delete calendar;
1269 if ( syncOK ) 1270 if ( syncOK )
1270 updateView(); 1271 updateView();
1271 return syncOK; 1272 return syncOK;
1272} 1273}
1273 1274
1274void CalendarView::syncExternal( int mode ) 1275void CalendarView::syncExternal( int mode )
1275{ 1276{
1276 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1277 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1277 1278
1278 qApp->processEvents(); 1279 qApp->processEvents();
1279 CalendarLocal* calendar = new CalendarLocal(); 1280 CalendarLocal* calendar = new CalendarLocal();
1280 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1281 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1281 bool syncOK = false; 1282 bool syncOK = false;
1282 bool loadSuccess = false; 1283 bool loadSuccess = false;
1283 PhoneFormat* phoneFormat = 0; 1284 PhoneFormat* phoneFormat = 0;
1284 emit tempDisableBR(true); 1285 emit tempDisableBR(true);
1285#ifndef DESKTOP_VERSION 1286#ifndef DESKTOP_VERSION
1286 SharpFormat* sharpFormat = 0; 1287 SharpFormat* sharpFormat = 0;
1287 if ( mode == 0 ) { // sharp 1288 if ( mode == 0 ) { // sharp
1288 sharpFormat = new SharpFormat () ; 1289 sharpFormat = new SharpFormat () ;
1289 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1290 loadSuccess = sharpFormat->load( calendar, mCalendar );
1290 1291
1291 } else 1292 } else
1292#endif 1293#endif
1293 if ( mode == 1 ) { // phone 1294 if ( mode == 1 ) { // phone
1294 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1295 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1295 mSyncManager->mPhoneDevice, 1296 mSyncManager->mPhoneDevice,
1296 mSyncManager->mPhoneConnection, 1297 mSyncManager->mPhoneConnection,
1297 mSyncManager->mPhoneModel); 1298 mSyncManager->mPhoneModel);
1298 loadSuccess = phoneFormat->load( calendar,mCalendar); 1299 loadSuccess = phoneFormat->load( calendar,mCalendar);
1299 1300
1300 } else { 1301 } else {
1301 emit tempDisableBR(false); 1302 emit tempDisableBR(false);
1302 return; 1303 return;
1303 } 1304 }
1304 if ( loadSuccess ) { 1305 if ( loadSuccess ) {
1305 getEventViewerDialog()->setSyncMode( true ); 1306 getEventViewerDialog()->setSyncMode( true );
1306 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1307 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1307 getEventViewerDialog()->setSyncMode( false ); 1308 getEventViewerDialog()->setSyncMode( false );
1308 qApp->processEvents(); 1309 qApp->processEvents();
1309 if ( syncOK ) { 1310 if ( syncOK ) {
1310 if ( mSyncManager->mWriteBackFile ) 1311 if ( mSyncManager->mWriteBackFile )
1311 { 1312 {
1312 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1313 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1313 Incidence* inc = iL.first(); 1314 Incidence* inc = iL.first();
1314 if ( phoneFormat ) { 1315 if ( phoneFormat ) {
1315 while ( inc ) { 1316 while ( inc ) {
1316 inc->removeID(mCurrentSyncDevice); 1317 inc->removeID(mCurrentSyncDevice);
1317 inc = iL.next(); 1318 inc = iL.next();
1318 } 1319 }
1319 } 1320 }
1320#ifndef DESKTOP_VERSION 1321#ifndef DESKTOP_VERSION
1321 if ( sharpFormat ) 1322 if ( sharpFormat )
1322 sharpFormat->save(calendar); 1323 sharpFormat->save(calendar);
1323#endif 1324#endif
1324 if ( phoneFormat ) 1325 if ( phoneFormat )
1325 phoneFormat->save(calendar); 1326 phoneFormat->save(calendar);
1326 iL = calendar->rawIncidences(); 1327 iL = calendar->rawIncidences();
1327 inc = iL.first(); 1328 inc = iL.first();
1328 Incidence* loc; 1329 Incidence* loc;
1329 while ( inc ) { 1330 while ( inc ) {
1330 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1331 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1331 loc = mCalendar->incidence(inc->uid() ); 1332 loc = mCalendar->incidence(inc->uid() );
1332 if ( loc ) { 1333 if ( loc ) {
1333 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1334 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1334 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1335 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1335 } 1336 }
1336 } 1337 }
1337 inc = iL.next(); 1338 inc = iL.next();
1338 } 1339 }
1339 Incidence* lse = getLastSyncEvent(); 1340 Incidence* lse = getLastSyncEvent();
1340 if ( lse ) { 1341 if ( lse ) {
1341 lse->setReadOnly( false ); 1342 lse->setReadOnly( false );
1342 lse->setDescription( "" ); 1343 lse->setDescription( "" );
1343 lse->setReadOnly( true ); 1344 lse->setReadOnly( true );
1344 } 1345 }
1345 } 1346 }
1346 } else { 1347 } else {
1347 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 1348 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
1348 } 1349 }
1349 setModified( true ); 1350 setModified( true );
1350 } else { 1351 } else {
1351 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1352 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1352 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1353 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1353 question, i18n("Ok")) ; 1354 question, i18n("Ok")) ;
1354 1355
1355 } 1356 }
1356 delete calendar; 1357 delete calendar;
1357 updateView(); 1358 updateView();
1358 emit tempDisableBR(false); 1359 emit tempDisableBR(false);
1359 return ;//syncOK; 1360 return ;//syncOK;
1360 1361
1361} 1362}
1362 1363
1363bool CalendarView::importBday() 1364bool CalendarView::importBday()
1364{ 1365{
1365#ifndef KORG_NOKABC 1366#ifndef KORG_NOKABC
1366 1367
1367#ifdef DESKTOP_VERSION 1368#ifdef DESKTOP_VERSION
1368 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1369 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1369 KABC::AddressBook::Iterator it; 1370 KABC::AddressBook::Iterator it;
1370 int count = 0; 1371 int count = 0;
1371 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1372 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1372 ++count; 1373 ++count;
1373 } 1374 }
1374 QProgressBar bar(count,0 ); 1375 QProgressBar bar(count,0 );
1375 int w = 300; 1376 int w = 300;
1376 if ( QApplication::desktop()->width() < 320 ) 1377 if ( QApplication::desktop()->width() < 320 )
1377 w = 220; 1378 w = 220;
1378 int h = bar.sizeHint().height() ; 1379 int h = bar.sizeHint().height() ;
1379 int dw = QApplication::desktop()->width(); 1380 int dw = QApplication::desktop()->width();
1380 int dh = QApplication::desktop()->height(); 1381 int dh = QApplication::desktop()->height();
1381 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1382 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1382 bar.show(); 1383 bar.show();
1383 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1384 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1384 qApp->processEvents(); 1385 qApp->processEvents();
1385 count = 0; 1386 count = 0;
1386 int addCount = 0; 1387 int addCount = 0;
1387 KCal::Attendee* a = 0; 1388 KCal::Attendee* a = 0;
1388 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1389 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1389 if ( ! bar.isVisible() ) 1390 if ( ! bar.isVisible() )
1390 return false; 1391 return false;
1391 bar.setProgress( count++ ); 1392 bar.setProgress( count++ );
1392 qApp->processEvents(); 1393 qApp->processEvents();
1393 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1394 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1394 if ( (*it).birthday().date().isValid() ){ 1395 if ( (*it).birthday().date().isValid() ){
1395 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1396 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1396 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1397 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1397 ++addCount; 1398 ++addCount;
1398 } 1399 }
1399 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1400 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1400 if ( anni.isValid() ){ 1401 if ( anni.isValid() ){
1401 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1402 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1402 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1403 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1403 ++addCount; 1404 ++addCount;
1404 } 1405 }
1405 } 1406 }
1406 updateView(); 1407 updateView();
1407 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1408 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1408#else //DESKTOP_VERSION 1409#else //DESKTOP_VERSION
1409 1410
1410 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 1411 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
1411 // the result should now arrive through method insertBirthdays 1412 // the result should now arrive through method insertBirthdays
1412 1413
1413#endif //DESKTOP_VERSION 1414#endif //DESKTOP_VERSION
1414 1415
1415#endif //KORG_NOKABC 1416#endif //KORG_NOKABC
1416 1417
1417 1418
1418 return true; 1419 return true;
1419} 1420}
1420 1421
1421// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI 1422// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
1422void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, 1423void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
1423 const QStringList& anniversaryList, const QStringList& realNameList, 1424 const QStringList& anniversaryList, const QStringList& realNameList,
1424 const QStringList& emailList, const QStringList& assembledNameList, 1425 const QStringList& emailList, const QStringList& assembledNameList,
1425 const QStringList& uidList) 1426 const QStringList& uidList)
1426{ 1427{
1427 //qDebug("KO::CalendarView::insertBirthdays"); 1428 //qDebug("KO::CalendarView::insertBirthdays");
1428 if (uid == this->name()) 1429 if (uid == this->name())
1429 { 1430 {
1430 int count = birthdayList.count(); 1431 int count = birthdayList.count();
1431 int addCount = 0; 1432 int addCount = 0;
1432 KCal::Attendee* a = 0; 1433 KCal::Attendee* a = 0;
1433 1434
1434 //qDebug("CalView 1 %i", count); 1435 //qDebug("CalView 1 %i", count);
1435 1436
1436 QProgressBar bar(count,0 ); 1437 QProgressBar bar(count,0 );
1437 int w = 300; 1438 int w = 300;
1438 if ( QApplication::desktop()->width() < 320 ) 1439 if ( QApplication::desktop()->width() < 320 )
1439 w = 220; 1440 w = 220;
1440 int h = bar.sizeHint().height() ; 1441 int h = bar.sizeHint().height() ;
1441 int dw = QApplication::desktop()->width(); 1442 int dw = QApplication::desktop()->width();
1442 int dh = QApplication::desktop()->height(); 1443 int dh = QApplication::desktop()->height();
1443 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1444 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1444 bar.show(); 1445 bar.show();
1445 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 1446 bar.setCaption (i18n("inserting birthdays - close to abort!") );
1446 qApp->processEvents(); 1447 qApp->processEvents();
1447 1448
1448 QDate birthday; 1449 QDate birthday;
1449 QDate anniversary; 1450 QDate anniversary;
1450 QString realName; 1451 QString realName;
1451 QString email; 1452 QString email;
1452 QString assembledName; 1453 QString assembledName;
1453 QString uid; 1454 QString uid;
1454 bool ok = true; 1455 bool ok = true;
1455 for ( int i = 0; i < count; i++) 1456 for ( int i = 0; i < count; i++)
1456 { 1457 {
1457 if ( ! bar.isVisible() ) 1458 if ( ! bar.isVisible() )
1458 return; 1459 return;
1459 bar.setProgress( i ); 1460 bar.setProgress( i );
1460 qApp->processEvents(); 1461 qApp->processEvents();
1461 1462
1462 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); 1463 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
1463 if (!ok) { 1464 if (!ok) {
1464 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); 1465 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
1465 } 1466 }
1466 1467
1467 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); 1468 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
1468 if (!ok) { 1469 if (!ok) {
1469 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); 1470 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
1470 } 1471 }
1471 realName = realNameList[i]; 1472 realName = realNameList[i];
1472 email = emailList[i]; 1473 email = emailList[i];
1473 assembledName = assembledNameList[i]; 1474 assembledName = assembledNameList[i];
1474 uid = uidList[i]; 1475 uid = uidList[i];
1475 //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); 1476 //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() );
1476 1477
1477 if ( birthday.isValid() ){ 1478 if ( birthday.isValid() ){
1478 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1479 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1479 KCal::Attendee::ReqParticipant,uid) ; 1480 KCal::Attendee::ReqParticipant,uid) ;
1480 if ( addAnniversary( birthday, assembledName, a, true ) ) 1481 if ( addAnniversary( birthday, assembledName, a, true ) )
1481 ++addCount; 1482 ++addCount;
1482 } 1483 }
1483 1484
1484 if ( anniversary.isValid() ){ 1485 if ( anniversary.isValid() ){
1485 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1486 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1486 KCal::Attendee::ReqParticipant,uid) ; 1487 KCal::Attendee::ReqParticipant,uid) ;
1487 if ( addAnniversary( anniversary, assembledName, a, false ) ) 1488 if ( addAnniversary( anniversary, assembledName, a, false ) )
1488 ++addCount; 1489 ++addCount;
1489 } 1490 }
1490 } 1491 }
1491 1492
1492 updateView(); 1493 updateView();
1493 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1494 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1494 1495
1495 } 1496 }
1496 1497
1497} 1498}
1498 1499
1499 1500
1500 1501
1501bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1502bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1502{ 1503{
1503 //qDebug("addAnni "); 1504 //qDebug("addAnni ");
1504 Event * ev = new Event(); 1505 Event * ev = new Event();
1505 ev->setOrganizer(KOPrefs::instance()->email()); 1506 ev->setOrganizer(KOPrefs::instance()->email());
1506 if ( a ) { 1507 if ( a ) {
1507 ev->addAttendee( a ); 1508 ev->addAttendee( a );
1508 } 1509 }
1509 QString kind; 1510 QString kind;
1510 if ( birthday ) { 1511 if ( birthday ) {
1511 kind = i18n( "Birthday" ); 1512 kind = i18n( "Birthday" );
1512 ev->setSummary( name + " (" + QString::number(date.year()) +")"); 1513 ev->setSummary( name + " (" + QString::number(date.year()) +")");
1513 } 1514 }
1514 else { 1515 else {
1515 kind = i18n( "Anniversary" ); 1516 kind = i18n( "Anniversary" );
1516 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); 1517 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind );
1517 } 1518 }
1518 ev->setCategories( kind ); 1519 ev->setCategories( kind );
1519 ev->setDtStart( QDateTime(date) ); 1520 ev->setDtStart( QDateTime(date) );
1520 ev->setDtEnd( QDateTime(date) ); 1521 ev->setDtEnd( QDateTime(date) );
1521 ev->setFloats( true ); 1522 ev->setFloats( true );
1522 Recurrence * rec = ev->recurrence(); 1523 Recurrence * rec = ev->recurrence();
1523 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1524 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1524 rec->addYearlyNum( date.month() ); 1525 rec->addYearlyNum( date.month() );
1525 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1526 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1526 delete ev; 1527 delete ev;
1527 return false; 1528 return false;
1528 } 1529 }
1529 return true; 1530 return true;
1530 1531
1531} 1532}
1532bool CalendarView::importQtopia( const QString &categories, 1533bool CalendarView::importQtopia( const QString &categories,
1533 const QString &datebook, 1534 const QString &datebook,
1534 const QString &todolist ) 1535 const QString &todolist )
1535{ 1536{
1536 1537
1537 QtopiaFormat qtopiaFormat; 1538 QtopiaFormat qtopiaFormat;
1538 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1539 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1539 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1540 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1540 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1541 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1541 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1542 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1542 1543
1543 updateView(); 1544 updateView();
1544 return true; 1545 return true;
1545 1546
1546#if 0 1547#if 0
1547 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1548 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1548 mCurrentSyncDevice = "qtopia-XML"; 1549 mCurrentSyncDevice = "qtopia-XML";
1549 if ( mSyncManager->mAskForPreferences ) 1550 if ( mSyncManager->mAskForPreferences )
1550 edit_sync_options(); 1551 edit_sync_options();
1551 qApp->processEvents(); 1552 qApp->processEvents();
1552 CalendarLocal* calendar = new CalendarLocal(); 1553 CalendarLocal* calendar = new CalendarLocal();
1553 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1554 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1554 bool syncOK = false; 1555 bool syncOK = false;
1555 QtopiaFormat qtopiaFormat; 1556 QtopiaFormat qtopiaFormat;
1556 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1557 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1557 bool loadOk = true; 1558 bool loadOk = true;
1558 if ( !categories.isEmpty() ) 1559 if ( !categories.isEmpty() )
1559 loadOk = qtopiaFormat.load( calendar, categories ); 1560 loadOk = qtopiaFormat.load( calendar, categories );
1560 if ( loadOk && !datebook.isEmpty() ) 1561 if ( loadOk && !datebook.isEmpty() )
1561 loadOk = qtopiaFormat.load( calendar, datebook ); 1562 loadOk = qtopiaFormat.load( calendar, datebook );
1562 if ( loadOk && !todolist.isEmpty() ) 1563 if ( loadOk && !todolist.isEmpty() )
1563 loadOk = qtopiaFormat.load( calendar, todolist ); 1564 loadOk = qtopiaFormat.load( calendar, todolist );
1564 1565
1565 if ( loadOk ) { 1566 if ( loadOk ) {
1566 getEventViewerDialog()->setSyncMode( true ); 1567 getEventViewerDialog()->setSyncMode( true );
1567 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1568 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1568 getEventViewerDialog()->setSyncMode( false ); 1569 getEventViewerDialog()->setSyncMode( false );
1569 qApp->processEvents(); 1570 qApp->processEvents();
1570 if ( syncOK ) { 1571 if ( syncOK ) {
1571 if ( mSyncManager->mWriteBackFile ) 1572 if ( mSyncManager->mWriteBackFile )
1572 { 1573 {
1573 // write back XML file 1574 // write back XML file
1574 1575
1575 } 1576 }
1576 setModified( true ); 1577 setModified( true );
1577 } 1578 }
1578 } else { 1579 } else {
1579 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1580 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1580 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1581 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1581 question, i18n("Ok")) ; 1582 question, i18n("Ok")) ;
1582 } 1583 }
1583 delete calendar; 1584 delete calendar;
1584 updateView(); 1585 updateView();
1585 return syncOK; 1586 return syncOK;
1586 1587
1587 1588
1588#endif 1589#endif
1589 1590
1590} 1591}
1591 1592
1592void CalendarView::setSyncEventsReadOnly() 1593void CalendarView::setSyncEventsReadOnly()
1593{ 1594{
1594 Event * ev; 1595 Event * ev;
1595 QPtrList<Event> eL = mCalendar->rawEvents(); 1596 QPtrList<Event> eL = mCalendar->rawEvents();
1596 ev = eL.first(); 1597 ev = eL.first();
1597 while ( ev ) { 1598 while ( ev ) {
1598 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1599 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1599 ev->setReadOnly( true ); 1600 ev->setReadOnly( true );
1600 ev = eL.next(); 1601 ev = eL.next();
1601 } 1602 }
1602} 1603}
1603bool CalendarView::openCalendar(QString filename, bool merge) 1604bool CalendarView::openCalendar(QString filename, bool merge)
1604{ 1605{
1605 1606
1606 if (filename.isEmpty()) { 1607 if (filename.isEmpty()) {
1607 return false; 1608 return false;
1608 } 1609 }
1609 1610
1610 if (!QFile::exists(filename)) { 1611 if (!QFile::exists(filename)) {
1611 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1612 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1612 return false; 1613 return false;
1613 } 1614 }
1614 1615
1615 globalFlagBlockAgenda = 1; 1616 globalFlagBlockAgenda = 1;
1616 if (!merge) mCalendar->close(); 1617 if (!merge) mCalendar->close();
1617 1618
1618 mStorage->setFileName( filename ); 1619 mStorage->setFileName( filename );
1619 1620
1620 if ( mStorage->load() ) { 1621 if ( mStorage->load() ) {
1621 if ( merge ) ;//setModified( true ); 1622 if ( merge ) ;//setModified( true );
1622 else { 1623 else {
1623 //setModified( true ); 1624 //setModified( true );
1624 mViewManager->setDocumentId( filename ); 1625 mViewManager->setDocumentId( filename );
1625 mDialogManager->setDocumentId( filename ); 1626 mDialogManager->setDocumentId( filename );
1626 mTodoList->setDocumentId( filename ); 1627 mTodoList->setDocumentId( filename );
1627 } 1628 }
1628 globalFlagBlockAgenda = 2; 1629 globalFlagBlockAgenda = 2;
1629 // if ( getLastSyncEvent() ) 1630 // if ( getLastSyncEvent() )
1630 // getLastSyncEvent()->setReadOnly( true ); 1631 // getLastSyncEvent()->setReadOnly( true );
1631 mCalendar->reInitAlarmSettings(); 1632 mCalendar->reInitAlarmSettings();
1632 setSyncEventsReadOnly(); 1633 setSyncEventsReadOnly();
1633 updateUnmanagedViews(); 1634 updateUnmanagedViews();
1634 updateView(); 1635 updateView();
1635 if ( filename != MainWindow::defaultFileName() ) { 1636 if ( filename != MainWindow::defaultFileName() ) {
1636 saveCalendar( MainWindow::defaultFileName() ); 1637 saveCalendar( MainWindow::defaultFileName() );
1637 } else { 1638 } else {
1638 QFileInfo finf ( MainWindow::defaultFileName()); 1639 QFileInfo finf ( MainWindow::defaultFileName());
1639 if ( finf.exists() ) { 1640 if ( finf.exists() ) {
1640 setLoadedFileVersion( finf.lastModified () ); 1641 setLoadedFileVersion( finf.lastModified () );
1641 } 1642 }
1642 } 1643 }
1643 return true; 1644 return true;
1644 } else { 1645 } else {
1645 // while failing to load, the calendar object could 1646 // while failing to load, the calendar object could
1646 // have become partially populated. Clear it out. 1647 // have become partially populated. Clear it out.
1647 if ( !merge ) { 1648 if ( !merge ) {
1648 mCalendar->close(); 1649 mCalendar->close();
1649 mViewManager->setDocumentId( filename ); 1650 mViewManager->setDocumentId( filename );
1650 mDialogManager->setDocumentId( filename ); 1651 mDialogManager->setDocumentId( filename );
1651 mTodoList->setDocumentId( filename ); 1652 mTodoList->setDocumentId( filename );
1652 } 1653 }
1653 1654
1654 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1655 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1655 1656
1656 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 1657 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
1657 globalFlagBlockAgenda = 2; 1658 globalFlagBlockAgenda = 2;
1658 mCalendar->reInitAlarmSettings(); 1659 mCalendar->reInitAlarmSettings();
1659 setSyncEventsReadOnly(); 1660 setSyncEventsReadOnly();
1660 updateUnmanagedViews(); 1661 updateUnmanagedViews();
1661 updateView(); 1662 updateView();
1662 } 1663 }
1663 return false; 1664 return false;
1664} 1665}
1665void CalendarView::showOpenError() 1666void CalendarView::showOpenError()
1666{ 1667{
1667 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 1668 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
1668} 1669}
1669void CalendarView::setLoadedFileVersion(QDateTime dt) 1670void CalendarView::setLoadedFileVersion(QDateTime dt)
1670{ 1671{
1671 loadedFileVersion = dt; 1672 loadedFileVersion = dt;
1672} 1673}
1673bool CalendarView::checkFileChanged(QString fn) 1674bool CalendarView::checkFileChanged(QString fn)
1674{ 1675{
1675 QFileInfo finf ( fn ); 1676 QFileInfo finf ( fn );
1676 if ( !finf.exists() ) 1677 if ( !finf.exists() )
1677 return true; 1678 return true;
1678 QDateTime dt = finf.lastModified (); 1679 QDateTime dt = finf.lastModified ();
1679 if ( dt <= loadedFileVersion ) 1680 if ( dt <= loadedFileVersion )
1680 return false; 1681 return false;
1681 return true; 1682 return true;
1682 1683
1683} 1684}
1684void CalendarView::watchSavedFile() 1685void CalendarView::watchSavedFile()
1685{ 1686{
1686 QFileInfo finf ( MainWindow::defaultFileName()); 1687 QFileInfo finf ( MainWindow::defaultFileName());
1687 if ( !finf.exists() ) 1688 if ( !finf.exists() )
1688 return; 1689 return;
1689 QDateTime dt = finf.lastModified (); 1690 QDateTime dt = finf.lastModified ();
1690 if ( dt < loadedFileVersion ) { 1691 if ( dt < loadedFileVersion ) {
1691 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 1692 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
1692 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 1693 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1693 return; 1694 return;
1694 } 1695 }
1695 loadedFileVersion = dt; 1696 loadedFileVersion = dt;
1696} 1697}
1697 1698
1698bool CalendarView::checkFileVersion(QString fn) 1699bool CalendarView::checkFileVersion(QString fn)
1699{ 1700{
1700 QFileInfo finf ( fn ); 1701 QFileInfo finf ( fn );
1701 if ( !finf.exists() ) 1702 if ( !finf.exists() )
1702 return true; 1703 return true;
1703 QDateTime dt = finf.lastModified (); 1704 QDateTime dt = finf.lastModified ();
1704 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1705 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1705 //qDebug("file on disk version %s",dt.toString().latin1()); 1706 //qDebug("file on disk version %s",dt.toString().latin1());
1706 if ( dt <= loadedFileVersion ) 1707 if ( dt <= loadedFileVersion )
1707 return true; 1708 return true;
1708 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , 1709 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) ,
1709 i18n("KO/Pi Warning"),i18n("Overwrite"), 1710 i18n("KO/Pi Warning"),i18n("Overwrite"),
1710 i18n("Sync+save")); 1711 i18n("Sync+save"));
1711 1712
1712 if ( km == KMessageBox::Cancel ) 1713 if ( km == KMessageBox::Cancel )
1713 return false; 1714 return false;
1714 if ( km == KMessageBox::Yes ) 1715 if ( km == KMessageBox::Yes )
1715 return true; 1716 return true;
1716 1717
1717 setSyncDevice("deleteaftersync" ); 1718 setSyncDevice("deleteaftersync" );
1718 mSyncManager->mAskForPreferences = true; 1719 mSyncManager->mAskForPreferences = true;
1719 mSyncManager->mSyncAlgoPrefs = 3; 1720 mSyncManager->mSyncAlgoPrefs = 3;
1720 mSyncManager->mWriteBackFile = false; 1721 mSyncManager->mWriteBackFile = false;
1721 mSyncManager->mWriteBackExistingOnly = false; 1722 mSyncManager->mWriteBackExistingOnly = false;
1722 mSyncManager->mShowSyncSummary = false; 1723 mSyncManager->mShowSyncSummary = false;
1723 syncCalendar( fn, 3 ); 1724 syncCalendar( fn, 3 );
1724 Event * e = getLastSyncEvent(); 1725 Event * e = getLastSyncEvent();
1725 mCalendar->deleteEvent ( e ); 1726 mCalendar->deleteEvent ( e );
1726 updateView(); 1727 updateView();
1727 return true; 1728 return true;
1728} 1729}
1729 1730
1730bool CalendarView::saveCalendar( QString filename ) 1731bool CalendarView::saveCalendar( QString filename )
1731{ 1732{
1732 1733
1733 // Store back all unsaved data into calendar object 1734 // Store back all unsaved data into calendar object
1734 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1735 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1735 if ( mViewManager->currentView() ) 1736 if ( mViewManager->currentView() )
1736 mViewManager->currentView()->flushView(); 1737 mViewManager->currentView()->flushView();
1737 1738
1738 1739
1739 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 1740 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
1740 mStorage->setSaveFormat( new ICalFormat() ); 1741 mStorage->setSaveFormat( new ICalFormat() );
1741 mStorage->setFileName( filename ); 1742 mStorage->setFileName( filename );
1742 bool success; 1743 bool success;
1743 success = mStorage->save(); 1744 success = mStorage->save();
1744 if ( !success ) { 1745 if ( !success ) {
1745 return false; 1746 return false;
1746 } 1747 }
1747 if ( filename == MainWindow::defaultFileName() ) { 1748 if ( filename == MainWindow::defaultFileName() ) {
1748 setLoadedFileVersion( lfv ); 1749 setLoadedFileVersion( lfv );
1749 watchSavedFile(); 1750 watchSavedFile();
1750 } 1751 }
1751 return true; 1752 return true;
1752} 1753}
1753 1754
1754void CalendarView::closeCalendar() 1755void CalendarView::closeCalendar()
1755{ 1756{
1756 1757
1757 // child windows no longer valid 1758 // child windows no longer valid
1758 emit closingDown(); 1759 emit closingDown();
1759 1760
1760 mCalendar->close(); 1761 mCalendar->close();
1761 setModified(false); 1762 setModified(false);
1762 updateView(); 1763 updateView();
1763} 1764}
1764 1765
1765void CalendarView::archiveCalendar() 1766void CalendarView::archiveCalendar()
1766{ 1767{
1767 mDialogManager->showArchiveDialog(); 1768 mDialogManager->showArchiveDialog();
1768} 1769}
1769 1770
1770 1771
1771void CalendarView::readSettings() 1772void CalendarView::readSettings()
1772{ 1773{
1773 1774
1774 1775
1775 // mViewManager->showAgendaView(); 1776 // mViewManager->showAgendaView();
1776 QString str; 1777 QString str;
1777 //qDebug("CalendarView::readSettings() "); 1778 //qDebug("CalendarView::readSettings() ");
1778 // read settings from the KConfig, supplying reasonable 1779 // read settings from the KConfig, supplying reasonable
1779 // defaults where none are to be found 1780 // defaults where none are to be found
1780 KConfig *config = KOGlobals::config(); 1781 KConfig *config = KOGlobals::config();
1781#ifndef KORG_NOSPLITTER 1782#ifndef KORG_NOSPLITTER
1782 config->setGroup("KOrganizer Geometry"); 1783 config->setGroup("KOrganizer Geometry");
1783 1784
1784 QValueList<int> sizes = config->readIntListEntry("Separator1"); 1785 QValueList<int> sizes = config->readIntListEntry("Separator1");
1785 if (sizes.count() != 2) { 1786 if (sizes.count() != 2) {
1786 sizes << mDateNavigator->minimumSizeHint().width(); 1787 sizes << mDateNavigator->minimumSizeHint().width();
1787 sizes << 300; 1788 sizes << 300;
1788 } 1789 }
1789 mPanner->setSizes(sizes); 1790 mPanner->setSizes(sizes);
1790 1791
1791 sizes = config->readIntListEntry("Separator2"); 1792 sizes = config->readIntListEntry("Separator2");
1792 if ( ( mResourceView && sizes.count() == 4 ) || 1793 if ( ( mResourceView && sizes.count() == 4 ) ||
1793 ( !mResourceView && sizes.count() == 3 ) ) { 1794 ( !mResourceView && sizes.count() == 3 ) ) {
1794 mLeftSplitter->setSizes(sizes); 1795 mLeftSplitter->setSizes(sizes);
1795 } 1796 }
1796#endif 1797#endif
1797 globalFlagBlockAgenda = 1; 1798 globalFlagBlockAgenda = 1;
1798 mViewManager->showAgendaView(); 1799 mViewManager->showAgendaView();
1799 //mViewManager->readSettings( config ); 1800 //mViewManager->readSettings( config );
1800 mTodoList->restoreLayout(config,QString("Todo Layout")); 1801 mTodoList->restoreLayout(config,QString("Todo Layout"));
1801 readFilterSettings(config); 1802 readFilterSettings(config);
1802 config->setGroup( "Views" ); 1803 config->setGroup( "Views" );
1803 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 1804 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
1804 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 1805 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
1805 else if ( dateCount == 7 ) mNavigator->selectWeek(); 1806 else if ( dateCount == 7 ) mNavigator->selectWeek();
1806 else mNavigator->selectDates( dateCount ); 1807 else mNavigator->selectDates( dateCount );
1807 // mViewManager->readSettings( config ); 1808 // mViewManager->readSettings( config );
1808 updateConfig(); 1809 updateConfig();
1809 globalFlagBlockAgenda = 2; 1810 globalFlagBlockAgenda = 2;
1810 mViewManager->readSettings( config ); 1811 mViewManager->readSettings( config );
1811#ifdef DESKTOP_VERSION 1812#ifdef DESKTOP_VERSION
1812 config->setGroup("WidgetLayout"); 1813 config->setGroup("WidgetLayout");
1813 QStringList list; 1814 QStringList list;
1814 list = config->readListEntry("MainLayout"); 1815 list = config->readListEntry("MainLayout");
1815 int x,y,w,h; 1816 int x,y,w,h;
1816 if ( ! list.isEmpty() ) { 1817 if ( ! list.isEmpty() ) {
1817 x = list[0].toInt(); 1818 x = list[0].toInt();
1818 y = list[1].toInt(); 1819 y = list[1].toInt();
1819 w = list[2].toInt(); 1820 w = list[2].toInt();
1820 h = list[3].toInt(); 1821 h = list[3].toInt();
1821 topLevelWidget()->setGeometry(x,y,w,h); 1822 topLevelWidget()->setGeometry(x,y,w,h);
1822 1823
1823 } else { 1824 } else {
1824 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 1825 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
1825 } 1826 }
1826 list = config->readListEntry("EditEventLayout"); 1827 list = config->readListEntry("EditEventLayout");
1827 if ( ! list.isEmpty() ) { 1828 if ( ! list.isEmpty() ) {
1828 x = list[0].toInt(); 1829 x = list[0].toInt();
1829 y = list[1].toInt(); 1830 y = list[1].toInt();
1830 w = list[2].toInt(); 1831 w = list[2].toInt();
1831 h = list[3].toInt(); 1832 h = list[3].toInt();
1832 mEventEditor->setGeometry(x,y,w,h); 1833 mEventEditor->setGeometry(x,y,w,h);
1833 1834
1834 } 1835 }
1835 list = config->readListEntry("EditTodoLayout"); 1836 list = config->readListEntry("EditTodoLayout");
1836 if ( ! list.isEmpty() ) { 1837 if ( ! list.isEmpty() ) {
1837 x = list[0].toInt(); 1838 x = list[0].toInt();
1838 y = list[1].toInt(); 1839 y = list[1].toInt();
1839 w = list[2].toInt(); 1840 w = list[2].toInt();
1840 h = list[3].toInt(); 1841 h = list[3].toInt();
1841 mTodoEditor->setGeometry(x,y,w,h); 1842 mTodoEditor->setGeometry(x,y,w,h);
1842 1843
1843 } 1844 }
1844 list = config->readListEntry("ViewerLayout"); 1845 list = config->readListEntry("ViewerLayout");
1845 if ( ! list.isEmpty() ) { 1846 if ( ! list.isEmpty() ) {
1846 x = list[0].toInt(); 1847 x = list[0].toInt();
1847 y = list[1].toInt(); 1848 y = list[1].toInt();
1848 w = list[2].toInt(); 1849 w = list[2].toInt();
1849 h = list[3].toInt(); 1850 h = list[3].toInt();
1850 getEventViewerDialog()->setGeometry(x,y,w,h); 1851 getEventViewerDialog()->setGeometry(x,y,w,h);
1851 } 1852 }
1852#endif 1853#endif
1853 1854
1854} 1855}
1855 1856
1856 1857
1857void CalendarView::writeSettings() 1858void CalendarView::writeSettings()
1858{ 1859{
1859 // kdDebug() << "CalendarView::writeSettings" << endl; 1860 // kdDebug() << "CalendarView::writeSettings" << endl;
1860 1861
1861 KConfig *config = KOGlobals::config(); 1862 KConfig *config = KOGlobals::config();
1862 1863
1863#ifndef KORG_NOSPLITTER 1864#ifndef KORG_NOSPLITTER
1864 config->setGroup("KOrganizer Geometry"); 1865 config->setGroup("KOrganizer Geometry");
1865 1866
1866 QValueList<int> list = mPanner->sizes(); 1867 QValueList<int> list = mPanner->sizes();
1867 config->writeEntry("Separator1",list); 1868 config->writeEntry("Separator1",list);
1868 1869
1869 list = mLeftSplitter->sizes(); 1870 list = mLeftSplitter->sizes();
1870 config->writeEntry("Separator2",list); 1871 config->writeEntry("Separator2",list);
1871#endif 1872#endif
1872 1873
1873 mViewManager->writeSettings( config ); 1874 mViewManager->writeSettings( config );
1874 mTodoList->saveLayout(config,QString("Todo Layout")); 1875 mTodoList->saveLayout(config,QString("Todo Layout"));
1875 mDialogManager->writeSettings( config ); 1876 mDialogManager->writeSettings( config );
1876 //KOPrefs::instance()->usrWriteConfig(); 1877 //KOPrefs::instance()->usrWriteConfig();
1877 KOPrefs::instance()->writeConfig(); 1878 KOPrefs::instance()->writeConfig();
1878 1879
1879 writeFilterSettings(config); 1880 writeFilterSettings(config);
1880 1881
1881 config->setGroup( "Views" ); 1882 config->setGroup( "Views" );
1882 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 1883 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
1883 1884
1884#ifdef DESKTOP_VERSION 1885#ifdef DESKTOP_VERSION
1885 config->setGroup("WidgetLayout"); 1886 config->setGroup("WidgetLayout");
1886 QStringList list ;//= config->readListEntry("MainLayout"); 1887 QStringList list ;//= config->readListEntry("MainLayout");
1887 int x,y,w,h; 1888 int x,y,w,h;
1888 QWidget* wid; 1889 QWidget* wid;
1889 wid = topLevelWidget(); 1890 wid = topLevelWidget();
1890 x = wid->geometry().x(); 1891 x = wid->geometry().x();
1891 y = wid->geometry().y(); 1892 y = wid->geometry().y();
1892 w = wid->width(); 1893 w = wid->width();
1893 h = wid->height(); 1894 h = wid->height();
1894 list.clear(); 1895 list.clear();
1895 list << QString::number( x ); 1896 list << QString::number( x );
1896 list << QString::number( y ); 1897 list << QString::number( y );
1897 list << QString::number( w ); 1898 list << QString::number( w );
1898 list << QString::number( h ); 1899 list << QString::number( h );
1899 config->writeEntry("MainLayout",list ); 1900 config->writeEntry("MainLayout",list );
1900 1901
1901 wid = mEventEditor; 1902 wid = mEventEditor;
1902 x = wid->geometry().x(); 1903 x = wid->geometry().x();
1903 y = wid->geometry().y(); 1904 y = wid->geometry().y();
1904 w = wid->width(); 1905 w = wid->width();
1905 h = wid->height(); 1906 h = wid->height();
1906 list.clear(); 1907 list.clear();
1907 list << QString::number( x ); 1908 list << QString::number( x );
1908 list << QString::number( y ); 1909 list << QString::number( y );
1909 list << QString::number( w ); 1910 list << QString::number( w );
1910 list << QString::number( h ); 1911 list << QString::number( h );
1911 config->writeEntry("EditEventLayout",list ); 1912 config->writeEntry("EditEventLayout",list );
1912 1913
1913 wid = mTodoEditor; 1914 wid = mTodoEditor;
1914 x = wid->geometry().x(); 1915 x = wid->geometry().x();
1915 y = wid->geometry().y(); 1916 y = wid->geometry().y();
1916 w = wid->width(); 1917 w = wid->width();
1917 h = wid->height(); 1918 h = wid->height();
1918 list.clear(); 1919 list.clear();
1919 list << QString::number( x ); 1920 list << QString::number( x );
1920 list << QString::number( y ); 1921 list << QString::number( y );
1921 list << QString::number( w ); 1922 list << QString::number( w );
1922 list << QString::number( h ); 1923 list << QString::number( h );
1923 config->writeEntry("EditTodoLayout",list ); 1924 config->writeEntry("EditTodoLayout",list );
1924 wid = getEventViewerDialog(); 1925 wid = getEventViewerDialog();
1925 x = wid->geometry().x(); 1926 x = wid->geometry().x();
1926 y = wid->geometry().y(); 1927 y = wid->geometry().y();
1927 w = wid->width(); 1928 w = wid->width();
1928 h = wid->height(); 1929 h = wid->height();
1929 list.clear(); 1930 list.clear();
1930 list << QString::number( x ); 1931 list << QString::number( x );
1931 list << QString::number( y ); 1932 list << QString::number( y );
1932 list << QString::number( w ); 1933 list << QString::number( w );
1933 list << QString::number( h ); 1934 list << QString::number( h );
1934 config->writeEntry("ViewerLayout",list ); 1935 config->writeEntry("ViewerLayout",list );
1935 wid = mDialogManager->getSearchDialog(); 1936 wid = mDialogManager->getSearchDialog();
1936 if ( wid ) { 1937 if ( wid ) {
1937 x = wid->geometry().x(); 1938 x = wid->geometry().x();
1938 y = wid->geometry().y(); 1939 y = wid->geometry().y();
1939 w = wid->width(); 1940 w = wid->width();
1940 h = wid->height(); 1941 h = wid->height();
1941 list.clear(); 1942 list.clear();
1942 list << QString::number( x ); 1943 list << QString::number( x );
1943 list << QString::number( y ); 1944 list << QString::number( y );
1944 list << QString::number( w ); 1945 list << QString::number( w );
1945 list << QString::number( h ); 1946 list << QString::number( h );
1946 config->writeEntry("SearchLayout",list ); 1947 config->writeEntry("SearchLayout",list );
1947 } 1948 }
1948#endif 1949#endif
1949 1950
1950 1951
1951 config->sync(); 1952 config->sync();
1952} 1953}
1953 1954
1954void CalendarView::readFilterSettings(KConfig *config) 1955void CalendarView::readFilterSettings(KConfig *config)
1955{ 1956{
1956 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 1957 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
1957 1958
1958 mFilters.clear(); 1959 mFilters.clear();
1959 1960
1960 config->setGroup("General"); 1961 config->setGroup("General");
1961 QStringList filterList = config->readListEntry("CalendarFilters"); 1962 QStringList filterList = config->readListEntry("CalendarFilters");
1962 1963
1963 QStringList::ConstIterator it = filterList.begin(); 1964 QStringList::ConstIterator it = filterList.begin();
1964 QStringList::ConstIterator end = filterList.end(); 1965 QStringList::ConstIterator end = filterList.end();
1965 while(it != end) { 1966 while(it != end) {
1966 // kdDebug() << " filter: " << (*it) << endl; 1967 // kdDebug() << " filter: " << (*it) << endl;
1967 1968
1968 CalFilter *filter; 1969 CalFilter *filter;
1969 filter = new CalFilter(*it); 1970 filter = new CalFilter(*it);
1970 config->setGroup("Filter_" + (*it)); 1971 config->setGroup("Filter_" + (*it));
1971 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 1972 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
1972 filter->setCriteria(config->readNumEntry("Criteria",0)); 1973 filter->setCriteria(config->readNumEntry("Criteria",0));
1973 filter->setCategoryList(config->readListEntry("CategoryList")); 1974 filter->setCategoryList(config->readListEntry("CategoryList"));
1974 mFilters.append(filter); 1975 mFilters.append(filter);
1975 1976
1976 ++it; 1977 ++it;
1977 } 1978 }
1978 1979
1979 if (mFilters.count() == 0) { 1980 if (mFilters.count() == 0) {
1980 CalFilter *filter = new CalFilter(i18n("Default")); 1981 CalFilter *filter = new CalFilter(i18n("Default"));
1981 mFilters.append(filter); 1982 mFilters.append(filter);
1982 } 1983 }
1983 mFilterView->updateFilters(); 1984 mFilterView->updateFilters();
1984 config->setGroup("FilterView"); 1985 config->setGroup("FilterView");
1985 1986
1986 mFilterView->blockSignals(true); 1987 mFilterView->blockSignals(true);
1987 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 1988 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
1988 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 1989 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
1989 mFilterView->blockSignals(false); 1990 mFilterView->blockSignals(false);
1990 // We do it manually to avoid it being done twice by the above calls 1991 // We do it manually to avoid it being done twice by the above calls
1991 updateFilter(); 1992 updateFilter();
1992} 1993}
1993 1994
1994void CalendarView::writeFilterSettings(KConfig *config) 1995void CalendarView::writeFilterSettings(KConfig *config)
1995{ 1996{
1996 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 1997 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
1997 1998
1998 QStringList filterList; 1999 QStringList filterList;
1999 2000
2000 CalFilter *filter = mFilters.first(); 2001 CalFilter *filter = mFilters.first();
2001 while(filter) { 2002 while(filter) {
2002 // kdDebug() << " fn: " << filter->name() << endl; 2003 // kdDebug() << " fn: " << filter->name() << endl;
2003 filterList << filter->name(); 2004 filterList << filter->name();
2004 config->setGroup("Filter_" + filter->name()); 2005 config->setGroup("Filter_" + filter->name());
2005 config->writeEntry("Criteria",filter->criteria()); 2006 config->writeEntry("Criteria",filter->criteria());
2006 config->writeEntry("CategoryList",filter->categoryList()); 2007 config->writeEntry("CategoryList",filter->categoryList());
2007 filter = mFilters.next(); 2008 filter = mFilters.next();
2008 } 2009 }
2009 config->setGroup("General"); 2010 config->setGroup("General");
2010 config->writeEntry("CalendarFilters",filterList); 2011 config->writeEntry("CalendarFilters",filterList);
2011 2012
2012 config->setGroup("FilterView"); 2013 config->setGroup("FilterView");
2013 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 2014 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
2014 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 2015 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
2015} 2016}
2016 2017
2017 2018
2018void CalendarView::goToday() 2019void CalendarView::goToday()
2019{ 2020{
2020 if ( mViewManager->currentView()->isMonthView() ) 2021 if ( mViewManager->currentView()->isMonthView() )
2021 mNavigator->selectTodayMonth(); 2022 mNavigator->selectTodayMonth();
2022 else 2023 else
2023 mNavigator->selectToday(); 2024 mNavigator->selectToday();
2024} 2025}
2025 2026
2026void CalendarView::goNext() 2027void CalendarView::goNext()
2027{ 2028{
2028 mNavigator->selectNext(); 2029 mNavigator->selectNext();
2029} 2030}
2030 2031
2031void CalendarView::goPrevious() 2032void CalendarView::goPrevious()
2032{ 2033{
2033 mNavigator->selectPrevious(); 2034 mNavigator->selectPrevious();
2034} 2035}
2035void CalendarView::goNextMonth() 2036void CalendarView::goNextMonth()
2036{ 2037{
2037 mNavigator->selectNextMonth(); 2038 mNavigator->selectNextMonth();
2038} 2039}
2039 2040
2040void CalendarView::goPreviousMonth() 2041void CalendarView::goPreviousMonth()
2041{ 2042{
2042 mNavigator->selectPreviousMonth(); 2043 mNavigator->selectPreviousMonth();
2043} 2044}
2044void CalendarView::writeLocale() 2045void CalendarView::writeLocale()
2045{ 2046{
2046 //KPimGlobalPrefs::instance()->setGlobalConfig(); 2047 //KPimGlobalPrefs::instance()->setGlobalConfig();
2047#if 0 2048#if 0
2048 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); 2049 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime );
2049 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); 2050 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday );
2050 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); 2051 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate );
2051 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); 2052 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage );
2052 QString dummy = KOPrefs::instance()->mUserDateFormatLong; 2053 QString dummy = KOPrefs::instance()->mUserDateFormatLong;
2053 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 2054 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
2054 dummy = KOPrefs::instance()->mUserDateFormatShort; 2055 dummy = KOPrefs::instance()->mUserDateFormatShort;
2055 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 2056 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
2056 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, 2057 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving,
2057 KOPrefs::instance()->mDaylightsavingStart, 2058 KOPrefs::instance()->mDaylightsavingStart,
2058 KOPrefs::instance()->mDaylightsavingEnd ); 2059 KOPrefs::instance()->mDaylightsavingEnd );
2059 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); 2060 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId );
2060#endif 2061#endif
2061} 2062}
2062void CalendarView::updateConfig() 2063void CalendarView::updateConfig()
2063{ 2064{
2064 writeLocale(); 2065 writeLocale();
2065 if ( KOPrefs::instance()->mUseAppColors ) 2066 if ( KOPrefs::instance()->mUseAppColors )
2066 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 2067 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
2067 emit configChanged(); 2068 emit configChanged();
2068 mTodoList->updateConfig(); 2069 mTodoList->updateConfig();
2069 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 2070 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
2070 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2071 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2071 // To make the "fill window" configurations work 2072 // To make the "fill window" configurations work
2072 //mViewManager->raiseCurrentView(); 2073 //mViewManager->raiseCurrentView();
2073} 2074}
2074 2075
2075 2076
2076void CalendarView::eventChanged(Event *event) 2077void CalendarView::eventChanged(Event *event)
2077{ 2078{
2078 changeEventDisplay(event,KOGlobals::EVENTEDITED); 2079 changeEventDisplay(event,KOGlobals::EVENTEDITED);
2079 //updateUnmanagedViews(); 2080 //updateUnmanagedViews();
2080} 2081}
2081 2082
2082void CalendarView::eventAdded(Event *event) 2083void CalendarView::eventAdded(Event *event)
2083{ 2084{
2084 changeEventDisplay(event,KOGlobals::EVENTADDED); 2085 changeEventDisplay(event,KOGlobals::EVENTADDED);
2085} 2086}
2086 2087
2087void CalendarView::eventToBeDeleted(Event *) 2088void CalendarView::eventToBeDeleted(Event *)
2088{ 2089{
2089 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 2090 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
2090} 2091}
2091 2092
2092void CalendarView::eventDeleted() 2093void CalendarView::eventDeleted()
2093{ 2094{
2094 changeEventDisplay(0,KOGlobals::EVENTDELETED); 2095 changeEventDisplay(0,KOGlobals::EVENTDELETED);
2095} 2096}
2096void CalendarView::changeTodoDisplay(Todo *which, int action) 2097void CalendarView::changeTodoDisplay(Todo *which, int action)
2097{ 2098{
2098 changeIncidenceDisplay((Incidence *)which, action); 2099 changeIncidenceDisplay((Incidence *)which, action);
2099 mDateNavigator->updateView(); //LR 2100 mDateNavigator->updateView(); //LR
2100 //mDialogManager->updateSearchDialog(); 2101 //mDialogManager->updateSearchDialog();
2101 2102
2102 if (which) { 2103 if (which) {
2103 mViewManager->updateWNview(); 2104 mViewManager->updateWNview();
2104 //mTodoList->updateView(); 2105 //mTodoList->updateView();
2105 } 2106 }
2106 2107
2107} 2108}
2108 2109
2109void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 2110void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
2110{ 2111{
2111 updateUnmanagedViews(); 2112 updateUnmanagedViews();
2112 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 2113 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
2113 if ( action == KOGlobals::EVENTDELETED ) { //delete 2114 if ( action == KOGlobals::EVENTDELETED ) { //delete
2114 mCalendar->checkAlarmForIncidence( 0, true ); 2115 mCalendar->checkAlarmForIncidence( 0, true );
2115 if ( mEventViewerDialog ) 2116 if ( mEventViewerDialog )
2116 mEventViewerDialog->hide(); 2117 mEventViewerDialog->hide();
2117 } 2118 }
2118 else 2119 else
2119 mCalendar->checkAlarmForIncidence( which , false ); 2120 mCalendar->checkAlarmForIncidence( which , false );
2120} 2121}
2121 2122
2122// most of the changeEventDisplays() right now just call the view's 2123// most of the changeEventDisplays() right now just call the view's
2123// total update mode, but they SHOULD be recoded to be more refresh-efficient. 2124// total update mode, but they SHOULD be recoded to be more refresh-efficient.
2124void CalendarView::changeEventDisplay(Event *which, int action) 2125void CalendarView::changeEventDisplay(Event *which, int action)
2125{ 2126{
2126 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 2127 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
2127 changeIncidenceDisplay((Incidence *)which, action); 2128 changeIncidenceDisplay((Incidence *)which, action);
2128 mDateNavigator->updateView(); 2129 mDateNavigator->updateView();
2129 //mDialogManager->updateSearchDialog(); 2130 //mDialogManager->updateSearchDialog();
2130 2131
2131 if (which) { 2132 if (which) {
2132 // If there is an event view visible update the display 2133 // If there is an event view visible update the display
2133 mViewManager->currentView()->changeEventDisplay(which,action); 2134 mViewManager->currentView()->changeEventDisplay(which,action);
2134 // TODO: check, if update needed 2135 // TODO: check, if update needed
2135 // if (which->getTodoStatus()) { 2136 // if (which->getTodoStatus()) {
2136 mTodoList->updateView(); 2137 mTodoList->updateView();
2137 // } 2138 // }
2138 } else { 2139 } else {
2139 mViewManager->currentView()->updateView(); 2140 mViewManager->currentView()->updateView();
2140 } 2141 }
2141} 2142}
2142 2143
2143 2144
2144void CalendarView::updateTodoViews() 2145void CalendarView::updateTodoViews()
2145{ 2146{
2146 mTodoList->updateView(); 2147 mTodoList->updateView();
2147 mViewManager->currentView()->updateView(); 2148 mViewManager->currentView()->updateView();
2148 2149
2149} 2150}
2150 2151
2151 2152
2152void CalendarView::updateView(const QDate &start, const QDate &end) 2153void CalendarView::updateView(const QDate &start, const QDate &end)
2153{ 2154{
2154 mTodoList->updateView(); 2155 mTodoList->updateView();
2155 mViewManager->updateView(start, end); 2156 mViewManager->updateView(start, end);
2156 //mDateNavigator->updateView(); 2157 //mDateNavigator->updateView();
2157} 2158}
2158 2159
2159void CalendarView::updateView() 2160void CalendarView::updateView()
2160{ 2161{
2161 DateList tmpList = mNavigator->selectedDates(); 2162 DateList tmpList = mNavigator->selectedDates();
2162 2163
2163 if ( KOPrefs::instance()->mHideNonStartedTodos ) 2164 if ( KOPrefs::instance()->mHideNonStartedTodos )
2164 mTodoList->updateView(); 2165 mTodoList->updateView();
2165 // We assume that the navigator only selects consecutive days. 2166 // We assume that the navigator only selects consecutive days.
2166 updateView( tmpList.first(), tmpList.last() ); 2167 updateView( tmpList.first(), tmpList.last() );
2167} 2168}
2168 2169
2169void CalendarView::updateUnmanagedViews() 2170void CalendarView::updateUnmanagedViews()
2170{ 2171{
2171 mDateNavigator->updateDayMatrix(); 2172 mDateNavigator->updateDayMatrix();
2172} 2173}
2173 2174
2174int CalendarView::msgItemDelete(const QString name) 2175int CalendarView::msgItemDelete(const QString name)
2175{ 2176{
2176 return KMessageBox::warningContinueCancel(this,name +"\n\n"+ 2177 return KMessageBox::warningContinueCancel(this,name +"\n\n"+
2177 i18n("This item will be\npermanently deleted."), 2178 i18n("This item will be\npermanently deleted."),
2178 i18n("KO/Pi Confirmation"),i18n("Delete")); 2179 i18n("KO/Pi Confirmation"),i18n("Delete"));
2179} 2180}
2180 2181
2181 2182
2182void CalendarView::edit_cut() 2183void CalendarView::edit_cut()
2183{ 2184{
2184 Event *anEvent=0; 2185 Event *anEvent=0;
2185 2186
2186 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2187 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2187 2188
2188 if (mViewManager->currentView()->isEventView()) { 2189 if (mViewManager->currentView()->isEventView()) {
2189 if ( incidence && incidence->type() == "Event" ) { 2190 if ( incidence && incidence->type() == "Event" ) {
2190 anEvent = static_cast<Event *>(incidence); 2191 anEvent = static_cast<Event *>(incidence);
2191 } 2192 }
2192 } 2193 }
2193 2194
2194 if (!anEvent) { 2195 if (!anEvent) {
2195 KNotifyClient::beep(); 2196 KNotifyClient::beep();
2196 return; 2197 return;
2197 } 2198 }
2198 DndFactory factory( mCalendar ); 2199 DndFactory factory( mCalendar );
2199 factory.cutIncidence(anEvent); 2200 factory.cutIncidence(anEvent);
2200 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2201 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2201} 2202}
2202 2203
2203void CalendarView::edit_copy() 2204void CalendarView::edit_copy()
2204{ 2205{
2205 Event *anEvent=0; 2206 Event *anEvent=0;
2206 2207
2207 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2208 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2208 2209
2209 if (mViewManager->currentView()->isEventView()) { 2210 if (mViewManager->currentView()->isEventView()) {
2210 if ( incidence && incidence->type() == "Event" ) { 2211 if ( incidence && incidence->type() == "Event" ) {
2211 anEvent = static_cast<Event *>(incidence); 2212 anEvent = static_cast<Event *>(incidence);
2212 } 2213 }
2213 } 2214 }
2214 2215
2215 if (!anEvent) { 2216 if (!anEvent) {
2216 KNotifyClient::beep(); 2217 KNotifyClient::beep();
2217 return; 2218 return;
2218 } 2219 }
2219 DndFactory factory( mCalendar ); 2220 DndFactory factory( mCalendar );
2220 factory.copyIncidence(anEvent); 2221 factory.copyIncidence(anEvent);
2221} 2222}
2222 2223
2223void CalendarView::edit_paste() 2224void CalendarView::edit_paste()
2224{ 2225{
2225 QDate date = mNavigator->selectedDates().first(); 2226 QDate date = mNavigator->selectedDates().first();
2226 2227
2227 DndFactory factory( mCalendar ); 2228 DndFactory factory( mCalendar );
2228 Event *pastedEvent = (Event *)factory.pasteIncidence( date ); 2229 Event *pastedEvent = (Event *)factory.pasteIncidence( date );
2229 2230
2230 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 2231 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
2231} 2232}
2232 2233
2233void CalendarView::edit_options() 2234void CalendarView::edit_options()
2234{ 2235{
2235 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; 2236 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId;
2236 emit save(); 2237 emit save();
2237 emit saveStopTimer(); 2238 emit saveStopTimer();
2238 mDialogManager->showOptionsDialog(); 2239 mDialogManager->showOptionsDialog();
2239 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { 2240 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) {
2240 emit saveStopTimer(); 2241 emit saveStopTimer();
2241 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), 2242 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"),
2242 i18n("Timezone settings"),i18n("Reload"))) { 2243 i18n("Timezone settings"),i18n("Reload"))) {
2243 qDebug("KO: TZ reload cancelled "); 2244 qDebug("KO: TZ reload cancelled ");
2244 return; 2245 return;
2245 } 2246 }
2246 qDebug("KO: Timezone change "); 2247 qDebug("KO: Timezone change ");
2247 openCalendar( MainWindow::defaultFileName() ); 2248 openCalendar( MainWindow::defaultFileName() );
2248 setModified(true); 2249 setModified(true);
2249 } 2250 }
2250 else 2251 else
2251 qDebug("KO: No tz change "); 2252 qDebug("KO: No tz change ");
2252 2253
2253} 2254}
2254 2255
2255 2256
2256void CalendarView::slotSelectPickerDate( QDate d) 2257void CalendarView::slotSelectPickerDate( QDate d)
2257{ 2258{
2258 mDateFrame->hide(); 2259 mDateFrame->hide();
2259 if ( mDatePickerMode == 1 ) { 2260 if ( mDatePickerMode == 1 ) {
2260 mNavigator->slotDaySelect( d ); 2261 mNavigator->slotDaySelect( d );
2261 } else if ( mDatePickerMode == 2 ) { 2262 } else if ( mDatePickerMode == 2 ) {
2262 if ( mMoveIncidence->type() == "Todo" ) { 2263 if ( mMoveIncidence->type() == "Todo" ) {
2263 Todo * to = (Todo *) mMoveIncidence; 2264 Todo * to = (Todo *) mMoveIncidence;
2264 QTime tim; 2265 QTime tim;
2265 if ( to->hasDueDate() ) 2266 if ( to->hasDueDate() )
2266 tim = to->dtDue().time(); 2267 tim = to->dtDue().time();
2267 else { 2268 else {
2268 tim = QTime ( 0,0,0 ); 2269 tim = QTime ( 0,0,0 );
2269 to->setFloats( true ); 2270 to->setFloats( true );
2270 to->setHasDueDate( true ); 2271 to->setHasDueDate( true );
2271 } 2272 }
2272 QDateTime dt ( d,tim ); 2273 QDateTime dt ( d,tim );
2273 to->setDtDue( dt ); 2274 to->setDtDue( dt );
2274 todoChanged( to ); 2275 todoChanged( to );
2275 } else { 2276 } else {
2276 if ( mMoveIncidence->doesRecur() ) { 2277 if ( mMoveIncidence->doesRecur() ) {
2277#if 0 2278#if 0
2278 // PENDING implement this 2279 // PENDING implement this
2279 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); 2280 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate );
2280 mCalendar()->addIncidence( newInc ); 2281 mCalendar()->addIncidence( newInc );
2281 if ( mMoveIncidence->type() == "Todo" ) 2282 if ( mMoveIncidence->type() == "Todo" )
2282 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); 2283 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED );
2283 else 2284 else
2284 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); 2285 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED);
2285 mMoveIncidence = newInc; 2286 mMoveIncidence = newInc;
2286 2287
2287#endif 2288#endif
2288 } 2289 }
2289 QTime tim = mMoveIncidence->dtStart().time(); 2290 QTime tim = mMoveIncidence->dtStart().time();
2290 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2291 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2291 QDateTime dt ( d,tim ); 2292 QDateTime dt ( d,tim );
2292 mMoveIncidence->setDtStart( dt ); 2293 mMoveIncidence->setDtStart( dt );
2293 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2294 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2294 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2295 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2295 } 2296 }
2296 2297
2297 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2298 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2298 } 2299 }
2299} 2300}
2300 2301
2301void CalendarView::removeCategories() 2302void CalendarView::removeCategories()
2302{ 2303{
2303 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2304 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2304 QStringList catList = KOPrefs::instance()->mCustomCategories; 2305 QStringList catList = KOPrefs::instance()->mCustomCategories;
2305 QStringList catIncList; 2306 QStringList catIncList;
2306 QStringList newCatList; 2307 QStringList newCatList;
2307 Incidence* inc = incList.first(); 2308 Incidence* inc = incList.first();
2308 int i; 2309 int i;
2309 int count = 0; 2310 int count = 0;
2310 while ( inc ) { 2311 while ( inc ) {
2311 newCatList.clear(); 2312 newCatList.clear();
2312 catIncList = inc->categories() ; 2313 catIncList = inc->categories() ;
2313 for( i = 0; i< catIncList.count(); ++i ) { 2314 for( i = 0; i< catIncList.count(); ++i ) {
2314 if ( catList.contains (catIncList[i])) 2315 if ( catList.contains (catIncList[i]))
2315 newCatList.append( catIncList[i] ); 2316 newCatList.append( catIncList[i] );
2316 } 2317 }
2317 newCatList.sort(); 2318 newCatList.sort();
2318 inc->setCategories( newCatList.join(",") ); 2319 inc->setCategories( newCatList.join(",") );
2319 inc = incList.next(); 2320 inc = incList.next();
2320 } 2321 }
2321} 2322}
2322 2323
2323int CalendarView::addCategories() 2324int CalendarView::addCategories()
2324{ 2325{
2325 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2326 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2326 QStringList catList = KOPrefs::instance()->mCustomCategories; 2327 QStringList catList = KOPrefs::instance()->mCustomCategories;
2327 QStringList catIncList; 2328 QStringList catIncList;
2328 Incidence* inc = incList.first(); 2329 Incidence* inc = incList.first();
2329 int i; 2330 int i;
2330 int count = 0; 2331 int count = 0;
2331 while ( inc ) { 2332 while ( inc ) {
2332 catIncList = inc->categories() ; 2333 catIncList = inc->categories() ;
2333 for( i = 0; i< catIncList.count(); ++i ) { 2334 for( i = 0; i< catIncList.count(); ++i ) {
2334 if ( !catList.contains (catIncList[i])) { 2335 if ( !catList.contains (catIncList[i])) {
2335 catList.append( catIncList[i] ); 2336 catList.append( catIncList[i] );
2336 //qDebug("add cat %s ", catIncList[i].latin1()); 2337 //qDebug("add cat %s ", catIncList[i].latin1());
2337 ++count; 2338 ++count;
2338 } 2339 }
2339 } 2340 }
2340 inc = incList.next(); 2341 inc = incList.next();
2341 } 2342 }
2342 catList.sort(); 2343 catList.sort();
2343 KOPrefs::instance()->mCustomCategories = catList; 2344 KOPrefs::instance()->mCustomCategories = catList;
2344 return count; 2345 return count;
2345} 2346}
2346 2347
2347void CalendarView::manageCategories() 2348void CalendarView::manageCategories()
2348{ 2349{
2349 KOCatPrefs* cp = new KOCatPrefs(); 2350 KOCatPrefs* cp = new KOCatPrefs();
2350 cp->show(); 2351 cp->show();
2351 int w =cp->sizeHint().width() ; 2352 int w =cp->sizeHint().width() ;
2352 int h = cp->sizeHint().height() ; 2353 int h = cp->sizeHint().height() ;
2353 int dw = QApplication::desktop()->width(); 2354 int dw = QApplication::desktop()->width();
2354 int dh = QApplication::desktop()->height(); 2355 int dh = QApplication::desktop()->height();
2355 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2356 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2356 if ( !cp->exec() ) { 2357 if ( !cp->exec() ) {
2357 delete cp; 2358 delete cp;
2358 return; 2359 return;
2359 } 2360 }
2360 int count = 0; 2361 int count = 0;
2361 if ( cp->addCat() ) { 2362 if ( cp->addCat() ) {
2362 count = addCategories(); 2363 count = addCategories();
2363 if ( count ) { 2364 if ( count ) {
2364 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2365 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2365 writeSettings(); 2366 writeSettings();
2366 } else 2367 } else
2367 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); 2368 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! "));
2368 } else { 2369 } else {
2369 removeCategories(); 2370 removeCategories();
2370 updateView(); 2371 updateView();
2371 } 2372 }
2372 delete cp; 2373 delete cp;
2373} 2374}
2374 2375
2375void CalendarView::beamIncidence(Incidence * Inc) 2376void CalendarView::beamIncidence(Incidence * Inc)
2376{ 2377{
2377 QPtrList<Incidence> delSel ; 2378 QPtrList<Incidence> delSel ;
2378 delSel.append(Inc); 2379 delSel.append(Inc);
2379 beamIncidenceList( delSel ); 2380 beamIncidenceList( delSel );
2380} 2381}
2381void CalendarView::beamCalendar() 2382void CalendarView::beamCalendar()
2382{ 2383{
2383 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2384 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2384 //qDebug("beamCalendar() "); 2385 //qDebug("beamCalendar() ");
2385 beamIncidenceList( delSel ); 2386 beamIncidenceList( delSel );
2386} 2387}
2387void CalendarView::beamFilteredCalendar() 2388void CalendarView::beamFilteredCalendar()
2388{ 2389{
2389 QPtrList<Incidence> delSel = mCalendar->incidences(); 2390 QPtrList<Incidence> delSel = mCalendar->incidences();
2390 //qDebug("beamFilteredCalendar() "); 2391 //qDebug("beamFilteredCalendar() ");
2391 beamIncidenceList( delSel ); 2392 beamIncidenceList( delSel );
2392} 2393}
2393void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2394void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2394{ 2395{
2395 if ( beamDialog->exec () == QDialog::Rejected ) 2396 if ( beamDialog->exec () == QDialog::Rejected )
2396 return; 2397 return;
2397#ifdef DESKTOP_VERSION 2398#ifdef DESKTOP_VERSION
2398 QString fn = locateLocal( "tmp", "kopibeamfile" ); 2399 QString fn = locateLocal( "tmp", "kopibeamfile" );
2399#else 2400#else
2400 QString fn = "/tmp/kopibeamfile"; 2401 QString fn = "/tmp/kopibeamfile";
2401#endif 2402#endif
2402 QString mes; 2403 QString mes;
2403 bool createbup = true; 2404 bool createbup = true;
2404 if ( createbup ) { 2405 if ( createbup ) {
2405 QString description = "\n"; 2406 QString description = "\n";
2406 CalendarLocal* cal = new CalendarLocal(); 2407 CalendarLocal* cal = new CalendarLocal();
2407 if ( beamDialog->beamLocal() ) 2408 if ( beamDialog->beamLocal() )
2408 cal->setLocalTime(); 2409 cal->setLocalTime();
2409 else 2410 else
2410 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2411 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2411 Incidence *incidence = delSel.first(); 2412 Incidence *incidence = delSel.first();
2412 bool addText = false; 2413 bool addText = false;
2413 if ( delSel.count() < 10 ) 2414 if ( delSel.count() < 10 )
2414 addText = true; 2415 addText = true;
2415 else { 2416 else {
2416 description.sprintf(i18n(" %d items?"),delSel.count() ); 2417 description.sprintf(i18n(" %d items?"),delSel.count() );
2417 } 2418 }
2418 while ( incidence ) { 2419 while ( incidence ) {
2419 Incidence *in = incidence->clone(); 2420 Incidence *in = incidence->clone();
2420 if ( ! in->summary().isEmpty() ) { 2421 if ( ! in->summary().isEmpty() ) {
2421 in->setDescription(""); 2422 in->setDescription("");
2422 } else { 2423 } else {
2423 in->setSummary( in->description().left(20)); 2424 in->setSummary( in->description().left(20));
2424 in->setDescription(""); 2425 in->setDescription("");
2425 } 2426 }
2426 if ( addText ) 2427 if ( addText )
2427 description += in->summary() + "\n"; 2428 description += in->summary() + "\n";
2428 cal->addIncidence( in ); 2429 cal->addIncidence( in );
2429 incidence = delSel.next(); 2430 incidence = delSel.next();
2430 } 2431 }
2431 if ( beamDialog->beamVcal() ) { 2432 if ( beamDialog->beamVcal() ) {
2432 fn += ".vcs"; 2433 fn += ".vcs";
2433 FileStorage storage( cal, fn, new VCalFormat ); 2434 FileStorage storage( cal, fn, new VCalFormat );
2434 storage.save(); 2435 storage.save();
2435 } else { 2436 } else {
2436 fn += ".ics"; 2437 fn += ".ics";
2437 FileStorage storage( cal, fn, new ICalFormat( ) ); 2438 FileStorage storage( cal, fn, new ICalFormat( ) );
2438 storage.save(); 2439 storage.save();
2439 } 2440 }
2440 delete cal; 2441 delete cal;
2441 mes = i18n("KO/Pi: Ready for beaming"); 2442 mes = i18n("KO/Pi: Ready for beaming");
2442 topLevelWidget()->setCaption(mes); 2443 topLevelWidget()->setCaption(mes);
2443 KApplication::convert2latin1( fn ); 2444 KApplication::convert2latin1( fn );
2444#ifndef DESKTOP_VERSION 2445#ifndef DESKTOP_VERSION
2445 Ir *ir = new Ir( this ); 2446 Ir *ir = new Ir( this );
2446 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 2447 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2447 ir->send( fn, description, "text/x-vCalendar" ); 2448 ir->send( fn, description, "text/x-vCalendar" );
2448#endif 2449#endif
2449 } 2450 }
2450} 2451}
2451void CalendarView::beamDone( Ir *ir ) 2452void CalendarView::beamDone( Ir *ir )
2452{ 2453{
2453#ifndef DESKTOP_VERSION 2454#ifndef DESKTOP_VERSION
2454 delete ir; 2455 delete ir;
2455#endif 2456#endif
2456 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); 2457 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") );
2457 topLevelWidget()->raise(); 2458 topLevelWidget()->raise();
2458} 2459}
2459 2460
2460void CalendarView::moveIncidence(Incidence * inc ) 2461void CalendarView::moveIncidence(Incidence * inc )
2461{ 2462{
2462 if ( !inc ) return; 2463 if ( !inc ) return;
2463 showDatePickerPopup(); 2464 showDatePickerPopup();
2464 mDatePickerMode = 2; 2465 mDatePickerMode = 2;
2465 mMoveIncidence = inc ; 2466 mMoveIncidence = inc ;
2466 QDate da; 2467 QDate da;
2467 if ( mMoveIncidence->type() == "Todo" ) { 2468 if ( mMoveIncidence->type() == "Todo" ) {
2468 Todo * to = (Todo *) mMoveIncidence; 2469 Todo * to = (Todo *) mMoveIncidence;
2469 if ( to->hasDueDate() ) 2470 if ( to->hasDueDate() )
2470 da = to->dtDue().date(); 2471 da = to->dtDue().date();
2471 else 2472 else
2472 da = QDate::currentDate(); 2473 da = QDate::currentDate();
2473 } else { 2474 } else {
2474 da = mMoveIncidence->dtStart().date(); 2475 da = mMoveIncidence->dtStart().date();
2475 } 2476 }
2476 //PENDING set date for recurring incidence to date of recurrence 2477 //PENDING set date for recurring incidence to date of recurrence
2477 //mMoveIncidenceOldDate; 2478 //mMoveIncidenceOldDate;
2478 mDatePicker->setDate( da ); 2479 mDatePicker->setDate( da );
2479} 2480}
2480void CalendarView::showDatePickerPopup() 2481void CalendarView::showDatePickerPopup()
2481{ 2482{
2482 if ( mDateFrame->isVisible() ) 2483 if ( mDateFrame->isVisible() )
2483 mDateFrame->hide(); 2484 mDateFrame->hide();
2484 else { 2485 else {
2485 int offX = 0, offY = 0; 2486 int offX = 0, offY = 0;
2486#ifdef DESKTOP_VERSION 2487#ifdef DESKTOP_VERSION
2487 int w =mDatePicker->sizeHint().width() ; 2488 int w =mDatePicker->sizeHint().width() ;
2488 int h = mDatePicker->sizeHint().height() ; 2489 int h = mDatePicker->sizeHint().height() ;
2489 int dw = topLevelWidget()->width(); 2490 int dw = topLevelWidget()->width();
2490 int dh = topLevelWidget()->height(); 2491 int dh = topLevelWidget()->height();
2491 offX = topLevelWidget()->x(); 2492 offX = topLevelWidget()->x();
2492 offY = topLevelWidget()->y(); 2493 offY = topLevelWidget()->y();
2493#else 2494#else
2494 int w =mDatePicker->sizeHint().width() ; 2495 int w =mDatePicker->sizeHint().width() ;
2495 int h = mDatePicker->sizeHint().height() ; 2496 int h = mDatePicker->sizeHint().height() ;
2496 int dw = QApplication::desktop()->width(); 2497 int dw = QApplication::desktop()->width();
2497 int dh = QApplication::desktop()->height(); 2498 int dh = QApplication::desktop()->height();
2498#endif 2499#endif
2499 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); 2500 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h );
2500 mDateFrame->show(); 2501 mDateFrame->show();
2501 } 2502 }
2502} 2503}
2503void CalendarView::showDatePicker( ) 2504void CalendarView::showDatePicker( )
2504{ 2505{
2505 showDatePickerPopup(); 2506 showDatePickerPopup();
2506 mDatePickerMode = 1; 2507 mDatePickerMode = 1;
2507 mDatePicker->setDate( mNavigator->selectedDates().first() ); 2508 mDatePicker->setDate( mNavigator->selectedDates().first() );
2508} 2509}
2509 2510
2510void CalendarView::showEventEditor() 2511void CalendarView::showEventEditor()
2511{ 2512{
2512#ifdef DESKTOP_VERSION 2513#ifdef DESKTOP_VERSION
2513 mEventEditor->show(); 2514 mEventEditor->show();
2514#else 2515#else
2515 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { 2516 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) {
2516 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2517 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2517 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); 2518 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() );
2518 qApp->processEvents(); 2519 qApp->processEvents();
2519 delete mEventEditor; 2520 delete mEventEditor;
2520 mEventEditor = mDialogManager->getEventEditor(); 2521 mEventEditor = mDialogManager->getEventEditor();
2521 topLevelWidget()->setCaption( i18n("") ); 2522 topLevelWidget()->setCaption( i18n("") );
2522 } 2523 }
2523 mEventEditor->showMaximized(); 2524 mEventEditor->showMaximized();
2524#endif 2525#endif
2525} 2526}
2526void CalendarView::showTodoEditor() 2527void CalendarView::showTodoEditor()
2527{ 2528{
2528#ifdef DESKTOP_VERSION 2529#ifdef DESKTOP_VERSION
2529 mTodoEditor->show(); 2530 mTodoEditor->show();
2530#else 2531#else
2531 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { 2532 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) {
2532 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2533 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2533 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); 2534 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() );
2534 qApp->processEvents(); 2535 qApp->processEvents();
2535 delete mTodoEditor; 2536 delete mTodoEditor;
2536 mTodoEditor = mDialogManager->getTodoEditor(); 2537 mTodoEditor = mDialogManager->getTodoEditor();
2537 topLevelWidget()->setCaption( i18n("") ); 2538 topLevelWidget()->setCaption( i18n("") );
2538 } 2539 }
2539 mTodoEditor->showMaximized(); 2540 mTodoEditor->showMaximized();
2540#endif 2541#endif
2541} 2542}
2542 2543
2543void CalendarView::cloneIncidence() 2544void CalendarView::cloneIncidence()
2544{ 2545{
2545 Incidence *incidence = currentSelection(); 2546 Incidence *incidence = currentSelection();
2546 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2547 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2547 if ( incidence ) { 2548 if ( incidence ) {
2548 cloneIncidence(incidence); 2549 cloneIncidence(incidence);
2549 } 2550 }
2550} 2551}
2551void CalendarView::moveIncidence() 2552void CalendarView::moveIncidence()
2552{ 2553{
2553 Incidence *incidence = currentSelection(); 2554 Incidence *incidence = currentSelection();
2554 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2555 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2555 if ( incidence ) { 2556 if ( incidence ) {
2556 moveIncidence(incidence); 2557 moveIncidence(incidence);
2557 } 2558 }
2558} 2559}
2559void CalendarView::beamIncidence() 2560void CalendarView::beamIncidence()
2560{ 2561{
2561 Incidence *incidence = currentSelection(); 2562 Incidence *incidence = currentSelection();
2562 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2563 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2563 if ( incidence ) { 2564 if ( incidence ) {
2564 beamIncidence(incidence); 2565 beamIncidence(incidence);
2565 } 2566 }
2566} 2567}
2567void CalendarView::toggleCancelIncidence() 2568void CalendarView::toggleCancelIncidence()
2568{ 2569{
2569 Incidence *incidence = currentSelection(); 2570 Incidence *incidence = currentSelection();
2570 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2571 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2571 if ( incidence ) { 2572 if ( incidence ) {
2572 cancelIncidence(incidence); 2573 cancelIncidence(incidence);
2573 } 2574 }
2574} 2575}
2575 2576
2576 2577
2577void CalendarView::cancelIncidence(Incidence * inc ) 2578void CalendarView::cancelIncidence(Incidence * inc )
2578{ 2579{
2579 inc->setCancelled( ! inc->cancelled() ); 2580 inc->setCancelled( ! inc->cancelled() );
2580 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 2581 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
2581 updateView(); 2582 updateView();
2582} 2583}
2583void CalendarView::cloneIncidence(Incidence * orgInc ) 2584void CalendarView::cloneIncidence(Incidence * orgInc )
2584{ 2585{
2585 Incidence * newInc = orgInc->clone(); 2586 Incidence * newInc = orgInc->clone();
2586 newInc->recreate(); 2587 newInc->recreate();
2587 2588
2588 if ( newInc->type() == "Todo" ) { 2589 if ( newInc->type() == "Todo" ) {
2589 Todo* t = (Todo*) newInc; 2590 Todo* t = (Todo*) newInc;
2590 showTodoEditor(); 2591 showTodoEditor();
2591 mTodoEditor->editTodo( t ); 2592 mTodoEditor->editTodo( t );
2592 if ( mTodoEditor->exec() ) { 2593 if ( mTodoEditor->exec() ) {
2593 mCalendar->addTodo( t ); 2594 mCalendar->addTodo( t );
2594 updateView(); 2595 updateView();
2595 } else { 2596 } else {
2596 delete t; 2597 delete t;
2597 } 2598 }
2598 } 2599 }
2599 else { 2600 else {
2600 Event* e = (Event*) newInc; 2601 Event* e = (Event*) newInc;
2601 showEventEditor(); 2602 showEventEditor();
2602 mEventEditor->editEvent( e ); 2603 mEventEditor->editEvent( e );
2603 if ( mEventEditor->exec() ) { 2604 if ( mEventEditor->exec() ) {
2604 mCalendar->addEvent( e ); 2605 mCalendar->addEvent( e );
2605 updateView(); 2606 updateView();
2606 } else { 2607 } else {
2607 delete e; 2608 delete e;
2608 } 2609 }
2609 } 2610 }
2610} 2611}
2611 2612
2612void CalendarView::newEvent() 2613void CalendarView::newEvent()
2613{ 2614{
2614 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 2615 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
2615 KOAgendaView *aView = mViewManager->agendaView(); 2616 KOAgendaView *aView = mViewManager->agendaView();
2616 if (aView) { 2617 if (aView) {
2617 if (aView->selectionStart().isValid()) { 2618 if (aView->selectionStart().isValid()) {
2618 if (aView->selectedIsAllDay()) { 2619 if (aView->selectedIsAllDay()) {
2619 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 2620 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
2620 } else { 2621 } else {
2621 newEvent(aView->selectionStart(),aView->selectionEnd()); 2622 newEvent(aView->selectionStart(),aView->selectionEnd());
2622 } 2623 }
2623 return; 2624 return;
2624 } 2625 }
2625 } 2626 }
2626 2627
2627 QDate date = mNavigator->selectedDates().first(); 2628 QDate date = mNavigator->selectedDates().first();
2628 QDateTime current = QDateTime::currentDateTime(); 2629 QDateTime current = QDateTime::currentDateTime();
2629 if ( date <= current.date() ) { 2630 if ( date <= current.date() ) {
2630 int hour = current.time().hour() +1; 2631 int hour = current.time().hour() +1;
2631 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 2632 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
2632 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2633 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2633 } else 2634 } else
2634 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 2635 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
2635 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 2636 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
2636 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2637 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2637} 2638}
2638 2639
2639void CalendarView::newEvent(QDateTime fh) 2640void CalendarView::newEvent(QDateTime fh)
2640{ 2641{
2641 newEvent(fh, 2642 newEvent(fh,
2642 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 2643 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
2643} 2644}
2644 2645
2645void CalendarView::newEvent(QDate dt) 2646void CalendarView::newEvent(QDate dt)
2646{ 2647{
2647 newEvent(QDateTime(dt, QTime(0,0,0)), 2648 newEvent(QDateTime(dt, QTime(0,0,0)),
2648 QDateTime(dt, QTime(0,0,0)), true); 2649 QDateTime(dt, QTime(0,0,0)), true);
2649} 2650}
2650void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) 2651void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint)
2651{ 2652{
2652 newEvent(fromHint, toHint, false); 2653 newEvent(fromHint, toHint, false);
2653} 2654}
2654void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 2655void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
2655{ 2656{
2656 2657
2657 showEventEditor(); 2658 showEventEditor();
2658 mEventEditor->newEvent(fromHint,toHint,allDay); 2659 mEventEditor->newEvent(fromHint,toHint,allDay);
2659 if ( mFilterView->filtersEnabled() ) { 2660 if ( mFilterView->filtersEnabled() ) {
2660 CalFilter *filter = mFilterView->selectedFilter(); 2661 CalFilter *filter = mFilterView->selectedFilter();
2661 if (filter && filter->showCategories()) { 2662 if (filter && filter->showCategories()) {
2662 mEventEditor->setCategories(filter->categoryList().join(",") ); 2663 mEventEditor->setCategories(filter->categoryList().join(",") );
2663 } 2664 }
2664 if ( filter ) 2665 if ( filter )
2665 mEventEditor->setSecrecy( filter->getSecrecy() ); 2666 mEventEditor->setSecrecy( filter->getSecrecy() );
2666 } 2667 }
2667} 2668}
2668void CalendarView::todoAdded(Todo * t) 2669void CalendarView::todoAdded(Todo * t)
2669{ 2670{
2670 2671
2671 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 2672 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
2672 updateTodoViews(); 2673 updateTodoViews();
2673} 2674}
2674void CalendarView::todoChanged(Todo * t) 2675void CalendarView::todoChanged(Todo * t)
2675{ 2676{
2676 emit todoModified( t, 4 ); 2677 emit todoModified( t, 4 );
2677 // updateTodoViews(); 2678 // updateTodoViews();
2678} 2679}
2679void CalendarView::todoToBeDeleted(Todo *) 2680void CalendarView::todoToBeDeleted(Todo *)
2680{ 2681{
2681 //qDebug("todoToBeDeleted(Todo *) "); 2682 //qDebug("todoToBeDeleted(Todo *) ");
2682 updateTodoViews(); 2683 updateTodoViews();
2683} 2684}
2684void CalendarView::todoDeleted() 2685void CalendarView::todoDeleted()
2685{ 2686{
2686 //qDebug(" todoDeleted()"); 2687 //qDebug(" todoDeleted()");
2687 updateTodoViews(); 2688 updateTodoViews();
2688} 2689}
2689 2690
2690 2691
2691void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) 2692void CalendarView::newTodoDateTime( QDateTime dt, bool allday )
2692{ 2693{
2693 showTodoEditor(); 2694 showTodoEditor();
2694 mTodoEditor->newTodo(dt,0,allday); 2695 mTodoEditor->newTodo(dt,0,allday);
2695 if ( mFilterView->filtersEnabled() ) { 2696 if ( mFilterView->filtersEnabled() ) {
2696 CalFilter *filter = mFilterView->selectedFilter(); 2697 CalFilter *filter = mFilterView->selectedFilter();
2697 if (filter && filter->showCategories()) { 2698 if (filter && filter->showCategories()) {
2698 mTodoEditor->setCategories(filter->categoryList().join(",") ); 2699 mTodoEditor->setCategories(filter->categoryList().join(",") );
2699 } 2700 }
2700 if ( filter ) 2701 if ( filter )
2701 mTodoEditor->setSecrecy( filter->getSecrecy() ); 2702 mTodoEditor->setSecrecy( filter->getSecrecy() );
2702 } 2703 }
2703} 2704}
2704 2705
2705void CalendarView::newTodo() 2706void CalendarView::newTodo()
2706{ 2707{
2707 newTodoDateTime( QDateTime(),true ); 2708 newTodoDateTime( QDateTime(),true );
2708} 2709}
2709 2710
2710void CalendarView::newSubTodo() 2711void CalendarView::newSubTodo()
2711{ 2712{
2712 Todo *todo = selectedTodo(); 2713 Todo *todo = selectedTodo();
2713 if ( todo ) newSubTodo( todo ); 2714 if ( todo ) newSubTodo( todo );
2714} 2715}
2715 2716
2716void CalendarView::newSubTodo(Todo *parentEvent) 2717void CalendarView::newSubTodo(Todo *parentEvent)
2717{ 2718{
2718 2719
2719 showTodoEditor(); 2720 showTodoEditor();
2720 mTodoEditor->newTodo(QDateTime(),parentEvent,true); 2721 mTodoEditor->newTodo(QDateTime(),parentEvent,true);
2721} 2722}
2722 2723
2723void CalendarView::newFloatingEvent() 2724void CalendarView::newFloatingEvent()
2724{ 2725{
2725 DateList tmpList = mNavigator->selectedDates(); 2726 DateList tmpList = mNavigator->selectedDates();
2726 QDate date = tmpList.first(); 2727 QDate date = tmpList.first();
2727 2728
2728 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 2729 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
2729 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 2730 QDateTime( date, QTime( 12, 0, 0 ) ), true );
2730} 2731}
2731 2732
2732 2733
2733void CalendarView::editEvent( Event *event ) 2734void CalendarView::editEvent( Event *event )
2734{ 2735{
2735 2736
2736 if ( !event ) return; 2737 if ( !event ) return;
2737 if ( event->isReadOnly() ) { 2738 if ( event->isReadOnly() ) {
2738 showEvent( event ); 2739 showEvent( event );
2739 return; 2740 return;
2740 } 2741 }
2741 showEventEditor(); 2742 showEventEditor();
2742 mEventEditor->editEvent( event , mFlagEditDescription); 2743 mEventEditor->editEvent( event , mFlagEditDescription);
2743} 2744}
2744void CalendarView::editJournal( Journal *jour ) 2745void CalendarView::editJournal( Journal *jour )
2745{ 2746{
2746 if ( !jour ) return; 2747 if ( !jour ) return;
2747 mDialogManager->hideSearchDialog(); 2748 mDialogManager->hideSearchDialog();
2748 mViewManager->showJournalView(); 2749 mViewManager->showJournalView();
2749 mNavigator->slotDaySelect( jour->dtStart().date() ); 2750 mNavigator->slotDaySelect( jour->dtStart().date() );
2750} 2751}
2751void CalendarView::editTodo( Todo *todo ) 2752void CalendarView::editTodo( Todo *todo )
2752{ 2753{
2753 if ( !todo ) return; 2754 if ( !todo ) return;
2754 2755
2755 if ( todo->isReadOnly() ) { 2756 if ( todo->isReadOnly() ) {
2756 showTodo( todo ); 2757 showTodo( todo );
2757 return; 2758 return;
2758 } 2759 }
2759 showTodoEditor(); 2760 showTodoEditor();
2760 mTodoEditor->editTodo( todo ,mFlagEditDescription); 2761 mTodoEditor->editTodo( todo ,mFlagEditDescription);
2761 2762
2762} 2763}
2763 2764
2764KOEventViewerDialog* CalendarView::getEventViewerDialog() 2765KOEventViewerDialog* CalendarView::getEventViewerDialog()
2765{ 2766{
2766 if ( !mEventViewerDialog ) { 2767 if ( !mEventViewerDialog ) {