summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp70
1 files changed, 38 insertions, 32 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 685bb60..da1edea 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,3867 +1,3873 @@
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 beamDialog = new KOBeamPrefs(); 236 beamDialog = new KOBeamPrefs();
237 mDatePickerMode = 0; 237 mDatePickerMode = 0;
238 mCurrentSyncDevice = ""; 238 mCurrentSyncDevice = "";
239 writeLocale(); 239 writeLocale();
240 mViewManager = new KOViewManager( this ); 240 mViewManager = new KOViewManager( this );
241 mDialogManager = new KODialogManager( this ); 241 mDialogManager = new KODialogManager( this );
242 mEventViewerDialog = 0; 242 mEventViewerDialog = 0;
243 mModified = false; 243 mModified = false;
244 mReadOnly = false; 244 mReadOnly = false;
245 mSelectedIncidence = 0; 245 mSelectedIncidence = 0;
246 mCalPrinter = 0; 246 mCalPrinter = 0;
247 mFilters.setAutoDelete(true); 247 mFilters.setAutoDelete(true);
248 248
249 mCalendar->registerObserver( this ); 249 mCalendar->registerObserver( this );
250 // TODO: Make sure that view is updated, when calendar is changed. 250 // TODO: Make sure that view is updated, when calendar is changed.
251 251
252 mStorage = new FileStorage( mCalendar ); 252 mStorage = new FileStorage( mCalendar );
253 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 253 mNavigator = new DateNavigator( this, "datevav", mViewManager );
254 254
255 QBoxLayout *topLayout = (QBoxLayout*)layout(); 255 QBoxLayout *topLayout = (QBoxLayout*)layout();
256#ifndef KORG_NOSPLITTER 256#ifndef KORG_NOSPLITTER
257 // create the main layout frames. 257 // create the main layout frames.
258 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 258 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
259 topLayout->addWidget(mPanner); 259 topLayout->addWidget(mPanner);
260 260
261 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 261 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
262 "CalendarView::LeftFrame"); 262 "CalendarView::LeftFrame");
263 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 263 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
264 264
265 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, 265 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE,
266 "CalendarView::DateNavigator", QDate::currentDate() ); 266 "CalendarView::DateNavigator", QDate::currentDate() );
267 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 267 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
268 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 268 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
269 mTodoList->setNavigator( mNavigator ); 269 mTodoList->setNavigator( mNavigator );
270 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 270 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
271 271
272#ifdef KORG_NORESOURCEVIEW 272#ifdef KORG_NORESOURCEVIEW
273 mResourceView = 0; 273 mResourceView = 0;
274#else 274#else
275 if ( mResourceManager ) { 275 if ( mResourceManager ) {
276 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 276 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
277 mResourceView->updateView(); 277 mResourceView->updateView();
278 connect( mResourceView, SIGNAL( resourcesChanged() ), 278 connect( mResourceView, SIGNAL( resourcesChanged() ),
279 SLOT( updateView() ) ); 279 SLOT( updateView() ) );
280 } else { 280 } else {
281 mResourceView = 0; 281 mResourceView = 0;
282 } 282 }
283#endif 283#endif
284 QWidget *rightBox = new QWidget( mPanner ); 284 QWidget *rightBox = new QWidget( mPanner );
285 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 285 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
286 286
287 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 287 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
288 rightLayout->addWidget( mNavigatorBar ); 288 rightLayout->addWidget( mNavigatorBar );
289 289
290 mRightFrame = new QWidgetStack( rightBox ); 290 mRightFrame = new QWidgetStack( rightBox );
291 rightLayout->addWidget( mRightFrame, 1 ); 291 rightLayout->addWidget( mRightFrame, 1 );
292 292
293 mLeftFrame = mLeftSplitter; 293 mLeftFrame = mLeftSplitter;
294#else 294#else
295 QWidget *mainBox = new QWidget( this ); 295 QWidget *mainBox = new QWidget( this );
296 QWidget *leftFrame = new QWidget( mainBox ); 296 QWidget *leftFrame = new QWidget( mainBox );
297 297
298 QBoxLayout * mainBoxLayout; 298 QBoxLayout * mainBoxLayout;
299 QBoxLayout * leftFrameLayout; 299 QBoxLayout * leftFrameLayout;
300 if ( KOPrefs::instance()->mVerticalScreen ) { 300 if ( KOPrefs::instance()->mVerticalScreen ) {
301 mainBoxLayout = new QVBoxLayout(mainBox); 301 mainBoxLayout = new QVBoxLayout(mainBox);
302 leftFrameLayout = new QHBoxLayout(leftFrame ); 302 leftFrameLayout = new QHBoxLayout(leftFrame );
303 } else { 303 } else {
304 mainBoxLayout = new QHBoxLayout(mainBox); 304 mainBoxLayout = new QHBoxLayout(mainBox);
305 leftFrameLayout = new QVBoxLayout(leftFrame ); 305 leftFrameLayout = new QVBoxLayout(leftFrame );
306 } 306 }
307 topLayout->addWidget( mainBox ); 307 topLayout->addWidget( mainBox );
308 mainBoxLayout->addWidget (leftFrame); 308 mainBoxLayout->addWidget (leftFrame);
309 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, 309 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE,
310 "CalendarView::DateNavigator", QDate::currentDate()); 310 "CalendarView::DateNavigator", QDate::currentDate());
311 // mDateNavigator->blockSignals( true ); 311 // mDateNavigator->blockSignals( true );
312 leftFrameLayout->addWidget( mDateNavigator ); 312 leftFrameLayout->addWidget( mDateNavigator );
313 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); 313 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView");
314 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall"); 314 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall");
315 mTodoList->setNavigator( mNavigator ); 315 mTodoList->setNavigator( mNavigator );
316 316
317 if ( QApplication::desktop()->width() < 480 ) { 317 if ( QApplication::desktop()->width() < 480 ) {
318 leftFrameLayout->addWidget(mFilterView); 318 leftFrameLayout->addWidget(mFilterView);
319 leftFrameLayout->addWidget(mTodoList, 2 ); 319 leftFrameLayout->addWidget(mTodoList, 2 );
320 320
321 } else { 321 } else {
322 leftFrameLayout->addWidget(mTodoList,2 ); 322 leftFrameLayout->addWidget(mTodoList,2 );
323 leftFrameLayout->addWidget(mFilterView ); 323 leftFrameLayout->addWidget(mFilterView );
324 } 324 }
325 mFilterView->hide(); 325 mFilterView->hide();
326 QWidget *rightBox = new QWidget( mainBox ); 326 QWidget *rightBox = new QWidget( mainBox );
327 mainBoxLayout->addWidget ( rightBox, 10 ); 327 mainBoxLayout->addWidget ( rightBox, 10 );
328 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 328 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
329 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 329 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
330 mRightFrame = new QWidgetStack( rightBox ); 330 mRightFrame = new QWidgetStack( rightBox );
331 rightLayout->addWidget( mNavigatorBar ); 331 rightLayout->addWidget( mNavigatorBar );
332 rightLayout->addWidget( mRightFrame, 10 ); 332 rightLayout->addWidget( mRightFrame, 10 );
333 333
334 mLeftFrame = leftFrame; 334 mLeftFrame = leftFrame;
335 if ( KOPrefs::instance()->mVerticalScreen ) { 335 if ( KOPrefs::instance()->mVerticalScreen ) {
336 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 336 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
337 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 337 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
338 } else { 338 } else {
339 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 339 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
340 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 340 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
341 } 341 }
342 342
343 //qDebug("Calendarview Size %d %d ", width(), height()); 343 //qDebug("Calendarview Size %d %d ", width(), height());
344#endif 344#endif
345 345
346 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 346 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
347 SLOT( showDates( const KCal::DateList & ) ) ); 347 SLOT( showDates( const KCal::DateList & ) ) );
348 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 348 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
349 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 349 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
350 350
351 connect( mNavigatorBar, SIGNAL( goPrevYear() ), 351 connect( mNavigatorBar, SIGNAL( goPrevYear() ),
352 mNavigator, SLOT( selectPreviousYear() ) ); 352 mNavigator, SLOT( selectPreviousYear() ) );
353 connect( mNavigatorBar, SIGNAL( goNextYear() ), 353 connect( mNavigatorBar, SIGNAL( goNextYear() ),
354 mNavigator, SLOT( selectNextYear() ) ); 354 mNavigator, SLOT( selectNextYear() ) );
355 connect( mNavigatorBar, SIGNAL( goPrevMonth() ), 355 connect( mNavigatorBar, SIGNAL( goPrevMonth() ),
356 mNavigator, SLOT( selectPreviousMonth() ) ); 356 mNavigator, SLOT( selectPreviousMonth() ) );
357 connect( mNavigatorBar, SIGNAL( goNextMonth() ), 357 connect( mNavigatorBar, SIGNAL( goNextMonth() ),
358 mNavigator, SLOT( selectNextMonth() ) ); 358 mNavigator, SLOT( selectNextMonth() ) );
359 359
360 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 360 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
361 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); 361 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) );
362 362
363 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 363 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
364 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 364 mNavigator, SLOT( selectWeek( const QDate & ) ) );
365 365
366 connect( mDateNavigator, SIGNAL( goPrevYear() ), 366 connect( mDateNavigator, SIGNAL( goPrevYear() ),
367 mNavigator, SLOT( selectPreviousYear() ) ); 367 mNavigator, SLOT( selectPreviousYear() ) );
368 connect( mDateNavigator, SIGNAL( goNextYear() ), 368 connect( mDateNavigator, SIGNAL( goNextYear() ),
369 mNavigator, SLOT( selectNextYear() ) ); 369 mNavigator, SLOT( selectNextYear() ) );
370 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 370 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
371 mNavigator, SLOT( selectPreviousMonth() ) ); 371 mNavigator, SLOT( selectPreviousMonth() ) );
372 connect( mDateNavigator, SIGNAL( goNextMonth() ), 372 connect( mDateNavigator, SIGNAL( goNextMonth() ),
373 mNavigator, SLOT( selectNextMonth() ) ); 373 mNavigator, SLOT( selectNextMonth() ) );
374 374
375 connect( mDateNavigator, SIGNAL( goPrevious() ), 375 connect( mDateNavigator, SIGNAL( goPrevious() ),
376 mNavigator, SLOT( selectPrevious() ) ); 376 mNavigator, SLOT( selectPrevious() ) );
377 connect( mDateNavigator, SIGNAL( goNext() ), 377 connect( mDateNavigator, SIGNAL( goNext() ),
378 mNavigator, SLOT( selectNext() ) ); 378 mNavigator, SLOT( selectNext() ) );
379 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 379 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
380 mNavigator, SLOT( slotMonthSelect( int ) ) ); 380 mNavigator, SLOT( slotMonthSelect( int ) ) );
381 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), 381 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ),
382 mNavigator, SLOT( slotMonthSelect( int ) ) ); 382 mNavigator, SLOT( slotMonthSelect( int ) ) );
383 383
384 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 384 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
385 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 385 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
386 386
387 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), 387 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ),
388 SLOT( eventAdded( Event *) ) ); 388 SLOT( eventAdded( Event *) ) );
389 389
390 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 390 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
391 391
392 connect( this, SIGNAL( configChanged() ), 392 connect( this, SIGNAL( configChanged() ),
393 mDateNavigator, SLOT( updateConfig() ) ); 393 mDateNavigator, SLOT( updateConfig() ) );
394 394
395 connect( mTodoList, SIGNAL( newTodoSignal() ), 395 connect( mTodoList, SIGNAL( newTodoSignal() ),
396 SLOT( newTodo() ) ); 396 SLOT( newTodo() ) );
397 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 397 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
398 SLOT( newSubTodo( Todo * ) ) ); 398 SLOT( newSubTodo( Todo * ) ) );
399 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 399 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
400 SLOT( editTodo( Todo * ) ) ); 400 SLOT( editTodo( Todo * ) ) );
401 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 401 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
402 SLOT( showTodo( Todo *) ) ); 402 SLOT( showTodo( Todo *) ) );
403 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 403 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
404 SLOT( deleteTodo( Todo *) ) ); 404 SLOT( deleteTodo( Todo *) ) );
405 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 405 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
406 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 406 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
407 SLOT( purgeCompleted() ) ); 407 SLOT( purgeCompleted() ) );
408 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 408 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
409 SIGNAL( todoModified( Todo *, int ) ) ); 409 SIGNAL( todoModified( Todo *, int ) ) );
410 410
411 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 411 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
412 this, SLOT ( cloneIncidence( Incidence * ) ) ); 412 this, SLOT ( cloneIncidence( Incidence * ) ) );
413 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 413 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
414 this, SLOT (cancelIncidence( Incidence * ) ) ); 414 this, SLOT (cancelIncidence( Incidence * ) ) );
415 415
416 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 416 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
417 this, SLOT ( moveIncidence( Incidence * ) ) ); 417 this, SLOT ( moveIncidence( Incidence * ) ) );
418 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 418 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
419 this, SLOT ( beamIncidence( Incidence * ) ) ); 419 this, SLOT ( beamIncidence( Incidence * ) ) );
420 420
421 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 421 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
422 this, SLOT ( todo_unsub( Todo * ) ) ); 422 this, SLOT ( todo_unsub( Todo * ) ) );
423 423
424 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 424 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
425 this, SLOT ( todo_resub( Todo *,Todo * ) ) ); 425 this, SLOT ( todo_resub( Todo *,Todo * ) ) );
426 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 426 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
427 SLOT( updateTodo( Todo *, int ) ) ); 427 SLOT( updateTodo( Todo *, int ) ) );
428 connect( this, SIGNAL( todoModified( Todo *, int )), this, 428 connect( this, SIGNAL( todoModified( Todo *, int )), this,
429 SLOT( changeTodoDisplay( Todo *, int ) ) ); 429 SLOT( changeTodoDisplay( Todo *, int ) ) );
430 430
431 431
432 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 432 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
433 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 433 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
434 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 434 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
435 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 435 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
436 436
437 437
438 438
439 439
440 440
441 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 441 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
442 SLOT(checkClipboard())); 442 SLOT(checkClipboard()));
443 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 443 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
444 SLOT( processTodoListSelection( Incidence * ) ) ); 444 SLOT( processTodoListSelection( Incidence * ) ) );
445 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 445 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
446 446
447 // kdDebug() << "CalendarView::CalendarView() done" << endl; 447 // kdDebug() << "CalendarView::CalendarView() done" << endl;
448 448
449 mDateFrame = new QVBox(0,0,WType_Popup); 449 mDateFrame = new QVBox(0,0,WType_Popup);
450 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 450 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
451 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 451 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
452 mDateFrame->setLineWidth(3); 452 mDateFrame->setLineWidth(3);
453 mDateFrame->hide(); 453 mDateFrame->hide();
454 mDateFrame->setCaption( i18n( "Pick a date to display")); 454 mDateFrame->setCaption( i18n( "Pick a date to display"));
455 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 455 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
456 456
457 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 457 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
458 458
459 mEventEditor = mDialogManager->getEventEditor(); 459 mEventEditor = mDialogManager->getEventEditor();
460 mTodoEditor = mDialogManager->getTodoEditor(); 460 mTodoEditor = mDialogManager->getTodoEditor();
461 461
462 mFlagEditDescription = false; 462 mFlagEditDescription = false;
463 463
464 mSuspendTimer = new QTimer( this ); 464 mSuspendTimer = new QTimer( this );
465 mAlarmTimer = new QTimer( this ); 465 mAlarmTimer = new QTimer( this );
466 mRecheckAlarmTimer = new QTimer( this ); 466 mRecheckAlarmTimer = new QTimer( this );
467 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 467 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
468 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 468 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
469 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 469 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
470 mAlarmDialog = new AlarmDialog( this ); 470 mAlarmDialog = new AlarmDialog( this );
471 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 471 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
472 mAlarmDialog->setServerNotification( false ); 472 mAlarmDialog->setServerNotification( false );
473 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 473 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
474 474
475 475
476#ifndef DESKTOP_VERSION 476#ifndef DESKTOP_VERSION
477//US listen for arriving address resultsets 477//US listen for arriving address resultsets
478 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), 478 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)),
479 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 479 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
480#endif 480#endif
481 481
482} 482}
483 483
484 484
485CalendarView::~CalendarView() 485CalendarView::~CalendarView()
486{ 486{
487 // kdDebug() << "~CalendarView()" << endl; 487 // kdDebug() << "~CalendarView()" << endl;
488 //qDebug("CalendarView::~CalendarView() "); 488 //qDebug("CalendarView::~CalendarView() ");
489 delete mDialogManager; 489 delete mDialogManager;
490 delete mViewManager; 490 delete mViewManager;
491 delete mStorage; 491 delete mStorage;
492 delete mDateFrame ; 492 delete mDateFrame ;
493 delete beamDialog; 493 delete beamDialog;
494 //kdDebug() << "~CalendarView() done" << endl; 494 //kdDebug() << "~CalendarView() done" << endl;
495} 495}
496 496
497void CalendarView::showDay( QDate d ) 497void CalendarView::showDay( QDate d )
498{ 498{
499 dateNavigator()->selectDate( d ); 499 dateNavigator()->selectDate( d );
500 mViewManager->showWeekView(); 500 mViewManager->showWeekView();
501 dateNavigator()->selectDate( d ); 501 dateNavigator()->selectDate( d );
502} 502}
503void CalendarView::timerAlarm() 503void CalendarView::timerAlarm()
504{ 504{
505 //qDebug("CalendarView::timerAlarm() "); 505 //qDebug("CalendarView::timerAlarm() ");
506 computeAlarm(mAlarmNotification ); 506 computeAlarm(mAlarmNotification );
507} 507}
508 508
509void CalendarView::suspendAlarm() 509void CalendarView::suspendAlarm()
510{ 510{
511 //qDebug(" CalendarView::suspendAlarm() "); 511 //qDebug(" CalendarView::suspendAlarm() ");
512 computeAlarm(mSuspendAlarmNotification ); 512 computeAlarm(mSuspendAlarmNotification );
513 513
514} 514}
515 515
516void CalendarView::startAlarm( QString mess , QString filename) 516void CalendarView::startAlarm( QString mess , QString filename)
517{ 517{
518 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 518 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
519 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); 519 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
520 520
521} 521}
522 522
523void CalendarView::checkNextTimerAlarm() 523void CalendarView::checkNextTimerAlarm()
524{ 524{
525 mCalendar->checkAlarmForIncidence( 0, true ); 525 mCalendar->checkAlarmForIncidence( 0, true );
526} 526}
527 527
528void CalendarView::computeAlarm( QString msg ) 528void CalendarView::computeAlarm( QString msg )
529{ 529{
530 530
531 QString mess = msg; 531 QString mess = msg;
532 QString mAlarmMessage = mess.mid( 9 ); 532 QString mAlarmMessage = mess.mid( 9 );
533 QString filename = MainWindow::resourcePath(); 533 QString filename = MainWindow::resourcePath();
534 filename += "koalarm.wav"; 534 filename += "koalarm.wav";
535 QString tempfilename; 535 QString tempfilename;
536 if ( mess.left( 13 ) == "suspend_alarm") { 536 if ( mess.left( 13 ) == "suspend_alarm") {
537 bool error = false; 537 bool error = false;
538 int len = mess.mid( 13 ).find("+++"); 538 int len = mess.mid( 13 ).find("+++");
539 if ( len < 2 ) 539 if ( len < 2 )
540 error = true; 540 error = true;
541 else { 541 else {
542 tempfilename = mess.mid( 13, len ); 542 tempfilename = mess.mid( 13, len );
543 if ( !QFile::exists( tempfilename ) ) 543 if ( !QFile::exists( tempfilename ) )
544 error = true; 544 error = true;
545 } 545 }
546 if ( ! error ) { 546 if ( ! error ) {
547 filename = tempfilename; 547 filename = tempfilename;
548 } 548 }
549 mAlarmMessage = mess.mid( 13+len+3 ); 549 mAlarmMessage = mess.mid( 13+len+3 );
550 //qDebug("suspend file %s ",tempfilename.latin1() ); 550 //qDebug("suspend file %s ",tempfilename.latin1() );
551 startAlarm( mAlarmMessage, filename); 551 startAlarm( mAlarmMessage, filename);
552 return; 552 return;
553 } 553 }
554 if ( mess.left( 11 ) == "timer_alarm") { 554 if ( mess.left( 11 ) == "timer_alarm") {
555 //mTimerTime = 0; 555 //mTimerTime = 0;
556 startAlarm( mess.mid( 11 ), filename ); 556 startAlarm( mess.mid( 11 ), filename );
557 return; 557 return;
558 } 558 }
559 if ( mess.left( 10 ) == "proc_alarm") { 559 if ( mess.left( 10 ) == "proc_alarm") {
560 bool error = false; 560 bool error = false;
561 int len = mess.mid( 10 ).find("+++"); 561 int len = mess.mid( 10 ).find("+++");
562 if ( len < 2 ) 562 if ( len < 2 )
563 error = true; 563 error = true;
564 else { 564 else {
565 tempfilename = mess.mid( 10, len ); 565 tempfilename = mess.mid( 10, len );
566 if ( !QFile::exists( tempfilename ) ) 566 if ( !QFile::exists( tempfilename ) )
567 error = true; 567 error = true;
568 } 568 }
569 if ( error ) { 569 if ( error ) {
570 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 570 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
571 mAlarmMessage += mess.mid( 10+len+3+9 ); 571 mAlarmMessage += mess.mid( 10+len+3+9 );
572 } else { 572 } else {
573 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 573 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
574 //qDebug("-----system command %s ",tempfilename.latin1() ); 574 //qDebug("-----system command %s ",tempfilename.latin1() );
575#ifndef _WIN32_ 575#ifndef _WIN32_
576 if ( vfork () == 0 ) { 576 if ( vfork () == 0 ) {
577 execl ( tempfilename.latin1(), 0 ); 577 execl ( tempfilename.latin1(), 0 );
578 return; 578 return;
579 } 579 }
580#else 580#else
581 QProcess* p = new QProcess(); 581 QProcess* p = new QProcess();
582 p->addArgument( tempfilename.latin1() ); 582 p->addArgument( tempfilename.latin1() );
583 p->start(); 583 p->start();
584 return; 584 return;
585#endif 585#endif
586 586
587 return; 587 return;
588 } 588 }
589 589
590 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 590 //qDebug("+++++++system command %s ",tempfilename.latin1() );
591 } 591 }
592 if ( mess.left( 11 ) == "audio_alarm") { 592 if ( mess.left( 11 ) == "audio_alarm") {
593 bool error = false; 593 bool error = false;
594 int len = mess.mid( 11 ).find("+++"); 594 int len = mess.mid( 11 ).find("+++");
595 if ( len < 2 ) 595 if ( len < 2 )
596 error = true; 596 error = true;
597 else { 597 else {
598 tempfilename = mess.mid( 11, len ); 598 tempfilename = mess.mid( 11, len );
599 if ( !QFile::exists( tempfilename ) ) 599 if ( !QFile::exists( tempfilename ) )
600 error = true; 600 error = true;
601 } 601 }
602 if ( ! error ) { 602 if ( ! error ) {
603 filename = tempfilename; 603 filename = tempfilename;
604 } 604 }
605 mAlarmMessage = mess.mid( 11+len+3+9 ); 605 mAlarmMessage = mess.mid( 11+len+3+9 );
606 //qDebug("audio file command %s ",tempfilename.latin1() ); 606 //qDebug("audio file command %s ",tempfilename.latin1() );
607 } 607 }
608 if ( mess.left( 9 ) == "cal_alarm") { 608 if ( mess.left( 9 ) == "cal_alarm") {
609 mAlarmMessage = mess.mid( 9 ) ; 609 mAlarmMessage = mess.mid( 9 ) ;
610 } 610 }
611 611
612 startAlarm( mAlarmMessage, filename ); 612 startAlarm( mAlarmMessage, filename );
613 613
614 614
615} 615}
616 616
617void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 617void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
618{ 618{
619 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 619 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
620 620
621 mSuspendAlarmNotification = noti; 621 mSuspendAlarmNotification = noti;
622 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 622 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
623 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 623 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
624 mSuspendTimer->start( ms , true ); 624 mSuspendTimer->start( ms , true );
625 625
626} 626}
627 627
628void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 628void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
629{ 629{
630 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 630 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
631 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 631 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
632#ifndef DESKTOP_VERSION 632#ifndef DESKTOP_VERSION
633 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); 633 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() );
634#endif 634#endif
635 return; 635 return;
636 } 636 }
637 int maxSec; 637 int maxSec;
638 //maxSec = 5; //testing only 638 //maxSec = 5; //testing only
639 maxSec = 86400+3600; // one day+1hour 639 maxSec = 86400+3600; // one day+1hour
640 mAlarmNotification = noti; 640 mAlarmNotification = noti;
641 int sec = QDateTime::currentDateTime().secsTo( qdt ); 641 int sec = QDateTime::currentDateTime().secsTo( qdt );
642 if ( sec > maxSec ) { 642 if ( sec > maxSec ) {
643 mRecheckAlarmTimer->start( maxSec * 1000 ); 643 mRecheckAlarmTimer->start( maxSec * 1000 );
644 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 644 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
645 return; 645 return;
646 } else { 646 } else {
647 mRecheckAlarmTimer->stop(); 647 mRecheckAlarmTimer->stop();
648 } 648 }
649 //qDebug("Alarm timer started with secs: %d ", sec); 649 //qDebug("Alarm timer started with secs: %d ", sec);
650 mAlarmTimer->start( sec *1000 , true ); 650 mAlarmTimer->start( sec *1000 , true );
651 651
652} 652}
653// called by mRecheckAlarmTimer to get next alarm 653// called by mRecheckAlarmTimer to get next alarm
654// we need this, because a QTimer has only a max range of 25 days 654// we need this, because a QTimer has only a max range of 25 days
655void CalendarView::recheckTimerAlarm() 655void CalendarView::recheckTimerAlarm()
656{ 656{
657 mAlarmTimer->stop(); 657 mAlarmTimer->stop();
658 mRecheckAlarmTimer->stop(); 658 mRecheckAlarmTimer->stop();
659 mCalendar->checkAlarmForIncidence( 0, true ); 659 mCalendar->checkAlarmForIncidence( 0, true );
660} 660}
661void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 661void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
662{ 662{
663 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 663 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
664 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 664 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
665#ifndef DESKTOP_VERSION 665#ifndef DESKTOP_VERSION
666 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 666 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
667#endif 667#endif
668 return; 668 return;
669 } 669 }
670 mAlarmTimer->stop(); 670 mAlarmTimer->stop();
671} 671}
672void CalendarView::selectWeekNum ( int num ) 672void CalendarView::selectWeekNum ( int num )
673{ 673{
674 dateNavigator()->selectWeek( num ); 674 dateNavigator()->selectWeek( num );
675 mViewManager->showWeekView(); 675 mViewManager->showWeekView();
676} 676}
677KOViewManager *CalendarView::viewManager() 677KOViewManager *CalendarView::viewManager()
678{ 678{
679 return mViewManager; 679 return mViewManager;
680} 680}
681 681
682KODialogManager *CalendarView::dialogManager() 682KODialogManager *CalendarView::dialogManager()
683{ 683{
684 return mDialogManager; 684 return mDialogManager;
685} 685}
686 686
687QDate CalendarView::startDate() 687QDate CalendarView::startDate()
688{ 688{
689 DateList dates = mNavigator->selectedDates(); 689 DateList dates = mNavigator->selectedDates();
690 690
691 return dates.first(); 691 return dates.first();
692} 692}
693 693
694QDate CalendarView::endDate() 694QDate CalendarView::endDate()
695{ 695{
696 DateList dates = mNavigator->selectedDates(); 696 DateList dates = mNavigator->selectedDates();
697 697
698 return dates.last(); 698 return dates.last();
699} 699}
700 700
701 701
702void CalendarView::createPrinter() 702void CalendarView::createPrinter()
703{ 703{
704#ifndef KORG_NOPRINTER 704#ifndef KORG_NOPRINTER
705 if (!mCalPrinter) { 705 if (!mCalPrinter) {
706 mCalPrinter = new CalPrinter(this, mCalendar); 706 mCalPrinter = new CalPrinter(this, mCalendar);
707 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 707 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
708 } 708 }
709#endif 709#endif
710} 710}
711 711
712 712
713//KOPrefs::instance()->mWriteBackFile 713//KOPrefs::instance()->mWriteBackFile
714//KOPrefs::instance()->mWriteBackExistingOnly 714//KOPrefs::instance()->mWriteBackExistingOnly
715 715
716// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 716// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
717// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 717// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
718// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 718// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
719// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 719// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
720// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 720// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
721// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 721// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
722 722
723int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 723int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
724{ 724{
725 725
726 // 0 equal 726 // 0 equal
727 // 1 take local 727 // 1 take local
728 // 2 take remote 728 // 2 take remote
729 // 3 cancel 729 // 3 cancel
730 QDateTime lastSync = mLastCalendarSync; 730 QDateTime lastSync = mLastCalendarSync;
731 QDateTime localMod = local->lastModified(); 731 QDateTime localMod = local->lastModified();
732 QDateTime remoteMod = remote->lastModified(); 732 QDateTime remoteMod = remote->lastModified();
733 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 733 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
734 bool remCh, locCh; 734 bool remCh, locCh;
735 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 735 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
736 //if ( remCh ) 736 //if ( remCh )
737 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 737 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
738 locCh = ( localMod > mLastCalendarSync ); 738 locCh = ( localMod > mLastCalendarSync );
739 if ( !remCh && ! locCh ) { 739 if ( !remCh && ! locCh ) {
740 //qDebug("both not changed "); 740 //qDebug("both not changed ");
741 lastSync = localMod.addDays(1); 741 lastSync = localMod.addDays(1);
742 if ( mode <= SYNC_PREF_ASK ) 742 if ( mode <= SYNC_PREF_ASK )
743 return 0; 743 return 0;
744 } else { 744 } else {
745 if ( locCh ) { 745 if ( locCh ) {
746 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); 746 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1());
747 lastSync = localMod.addDays( -1 ); 747 lastSync = localMod.addDays( -1 );
748 if ( !remCh ) 748 if ( !remCh )
749 remoteMod = ( lastSync.addDays( -1 ) ); 749 remoteMod = ( lastSync.addDays( -1 ) );
750 } else { 750 } else {
751 //qDebug(" not loc changed "); 751 //qDebug(" not loc changed ");
752 lastSync = localMod.addDays( 1 ); 752 lastSync = localMod.addDays( 1 );
753 if ( remCh ) 753 if ( remCh )
754 remoteMod =( lastSync.addDays( 1 ) ); 754 remoteMod =( lastSync.addDays( 1 ) );
755 755
756 } 756 }
757 } 757 }
758 full = true; 758 full = true;
759 if ( mode < SYNC_PREF_ASK ) 759 if ( mode < SYNC_PREF_ASK )
760 mode = SYNC_PREF_ASK; 760 mode = SYNC_PREF_ASK;
761 } else { 761 } else {
762 if ( localMod == remoteMod ) 762 if ( localMod == remoteMod )
763 // if ( local->revision() == remote->revision() ) 763 // if ( local->revision() == remote->revision() )
764 return 0; 764 return 0;
765 765
766 } 766 }
767 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 767 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
768 768
769 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); 769 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision());
770 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); 770 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() );
771 //full = true; //debug only 771 //full = true; //debug only
772 if ( full ) { 772 if ( full ) {
773 bool equ = false; 773 bool equ = false;
774 if ( local->type() == "Event" ) { 774 if ( local->type() == "Event" ) {
775 equ = (*((Event*) local) == *((Event*) remote)); 775 equ = (*((Event*) local) == *((Event*) remote));
776 } 776 }
777 else if ( local->type() =="Todo" ) 777 else if ( local->type() =="Todo" )
778 equ = (*((Todo*) local) == (*(Todo*) remote)); 778 equ = (*((Todo*) local) == (*(Todo*) remote));
779 else if ( local->type() =="Journal" ) 779 else if ( local->type() =="Journal" )
780 equ = (*((Journal*) local) == *((Journal*) remote)); 780 equ = (*((Journal*) local) == *((Journal*) remote));
781 if ( equ ) { 781 if ( equ ) {
782 //qDebug("equal "); 782 //qDebug("equal ");
783 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 783 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
784 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 784 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
785 } 785 }
786 if ( mode < SYNC_PREF_FORCE_LOCAL ) 786 if ( mode < SYNC_PREF_FORCE_LOCAL )
787 return 0; 787 return 0;
788 788
789 }//else //debug only 789 }//else //debug only
790 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 790 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
791 } 791 }
792 int result; 792 int result;
793 bool localIsNew; 793 bool localIsNew;
794 //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() ); 794 //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() );
795 795
796 if ( full && mode < SYNC_PREF_NEWEST ) 796 if ( full && mode < SYNC_PREF_NEWEST )
797 mode = SYNC_PREF_ASK; 797 mode = SYNC_PREF_ASK;
798 798
799 switch( mode ) { 799 switch( mode ) {
800 case SYNC_PREF_LOCAL: 800 case SYNC_PREF_LOCAL:
801 if ( lastSync > remoteMod ) 801 if ( lastSync > remoteMod )
802 return 1; 802 return 1;
803 if ( lastSync > localMod ) 803 if ( lastSync > localMod )
804 return 2; 804 return 2;
805 return 1; 805 return 1;
806 break; 806 break;
807 case SYNC_PREF_REMOTE: 807 case SYNC_PREF_REMOTE:
808 if ( lastSync > remoteMod ) 808 if ( lastSync > remoteMod )
809 return 1; 809 return 1;
810 if ( lastSync > localMod ) 810 if ( lastSync > localMod )
811 return 2; 811 return 2;
812 return 2; 812 return 2;
813 break; 813 break;
814 case SYNC_PREF_NEWEST: 814 case SYNC_PREF_NEWEST:
815 if ( localMod > remoteMod ) 815 if ( localMod > remoteMod )
816 return 1; 816 return 1;
817 else 817 else
818 return 2; 818 return 2;
819 break; 819 break;
820 case SYNC_PREF_ASK: 820 case SYNC_PREF_ASK:
821 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 821 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
822 if ( lastSync > remoteMod ) 822 if ( lastSync > remoteMod )
823 return 1; 823 return 1;
824 if ( lastSync > localMod ) 824 if ( lastSync > localMod )
825 return 2; 825 return 2;
826 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 826 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
827 localIsNew = localMod >= remoteMod; 827 localIsNew = localMod >= remoteMod;
828 if ( localIsNew ) 828 if ( localIsNew )
829 getEventViewerDialog()->setColorMode( 1 ); 829 getEventViewerDialog()->setColorMode( 1 );
830 else 830 else
831 getEventViewerDialog()->setColorMode( 2 ); 831 getEventViewerDialog()->setColorMode( 2 );
832 getEventViewerDialog()->setIncidence(local); 832 getEventViewerDialog()->setIncidence(local);
833 if ( localIsNew ) 833 if ( localIsNew )
834 getEventViewerDialog()->setColorMode( 2 ); 834 getEventViewerDialog()->setColorMode( 2 );
835 else 835 else
836 getEventViewerDialog()->setColorMode( 1 ); 836 getEventViewerDialog()->setColorMode( 1 );
837 getEventViewerDialog()->addIncidence(remote); 837 getEventViewerDialog()->addIncidence(remote);
838 getEventViewerDialog()->setColorMode( 0 ); 838 getEventViewerDialog()->setColorMode( 0 );
839 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 839 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
840 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 840 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
841 getEventViewerDialog()->showMe(); 841 getEventViewerDialog()->showMe();
842 result = getEventViewerDialog()->executeS( localIsNew ); 842 result = getEventViewerDialog()->executeS( localIsNew );
843 return result; 843 return result;
844 844
845 break; 845 break;
846 case SYNC_PREF_FORCE_LOCAL: 846 case SYNC_PREF_FORCE_LOCAL:
847 return 1; 847 return 1;
848 break; 848 break;
849 case SYNC_PREF_FORCE_REMOTE: 849 case SYNC_PREF_FORCE_REMOTE:
850 return 2; 850 return 2;
851 break; 851 break;
852 852
853 default: 853 default:
854 // SYNC_PREF_TAKE_BOTH not implemented 854 // SYNC_PREF_TAKE_BOTH not implemented
855 break; 855 break;
856 } 856 }
857 return 0; 857 return 0;
858} 858}
859Event* CalendarView::getLastSyncEvent() 859Event* CalendarView::getLastSyncEvent()
860{ 860{
861 Event* lse; 861 Event* lse;
862 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 862 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
863 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 863 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
864 if (!lse) { 864 if (!lse) {
865 lse = new Event(); 865 lse = new Event();
866 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 866 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
867 QString sum = ""; 867 QString sum = "";
868 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 868 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
869 sum = "E: "; 869 sum = "E: ";
870 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 870 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
871 lse->setDtStart( mLastCalendarSync ); 871 lse->setDtStart( mLastCalendarSync );
872 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 872 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
873 lse->setCategories( i18n("SyncEvent") ); 873 lse->setCategories( i18n("SyncEvent") );
874 lse->setReadOnly( true ); 874 lse->setReadOnly( true );
875 mCalendar->addEvent( lse ); 875 mCalendar->addEvent( lse );
876 } 876 }
877 877
878 return lse; 878 return lse;
879 879
880} 880}
881 881
882// we check, if the to delete event has a id for a profile 882// we check, if the to delete event has a id for a profile
883// if yes, we set this id in the profile to delete 883// if yes, we set this id in the profile to delete
884void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 884void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
885{ 885{
886 if ( lastSync.count() == 0 ) { 886 if ( lastSync.count() == 0 ) {
887 //qDebug(" lastSync.count() == 0"); 887 //qDebug(" lastSync.count() == 0");
888 return; 888 return;
889 } 889 }
890 if ( toDelete->type() == "Journal" ) 890 if ( toDelete->type() == "Journal" )
891 return; 891 return;
892 892
893 Event* eve = lastSync.first(); 893 Event* eve = lastSync.first();
894 894
895 while ( eve ) { 895 while ( eve ) {
896 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 896 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
897 if ( !id.isEmpty() ) { 897 if ( !id.isEmpty() ) {
898 QString des = eve->description(); 898 QString des = eve->description();
899 QString pref = "e"; 899 QString pref = "e";
900 if ( toDelete->type() == "Todo" ) 900 if ( toDelete->type() == "Todo" )
901 pref = "t"; 901 pref = "t";
902 des += pref+ id + ","; 902 des += pref+ id + ",";
903 eve->setReadOnly( false ); 903 eve->setReadOnly( false );
904 eve->setDescription( des ); 904 eve->setDescription( des );
905 //qDebug("setdes %s ", des.latin1()); 905 //qDebug("setdes %s ", des.latin1());
906 eve->setReadOnly( true ); 906 eve->setReadOnly( true );
907 } 907 }
908 eve = lastSync.next(); 908 eve = lastSync.next();
909 } 909 }
910 910
911} 911}
912void CalendarView::checkExternalId( Incidence * inc ) 912void CalendarView::checkExternalId( Incidence * inc )
913{ 913{
914 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 914 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
915 checkExternSyncEvent( lastSync, inc ); 915 checkExternSyncEvent( lastSync, inc );
916 916
917} 917}
918bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 918bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
919{ 919{
920 bool syncOK = true; 920 bool syncOK = true;
921 int addedEvent = 0; 921 int addedEvent = 0;
922 int addedEventR = 0; 922 int addedEventR = 0;
923 int deletedEventR = 0; 923 int deletedEventR = 0;
924 int deletedEventL = 0; 924 int deletedEventL = 0;
925 int changedLocal = 0; 925 int changedLocal = 0;
926 int changedRemote = 0; 926 int changedRemote = 0;
927 int filteredIN = 0;
928 int filteredOUT = 0;
927 //QPtrList<Event> el = local->rawEvents(); 929 //QPtrList<Event> el = local->rawEvents();
928 Event* eventR; 930 Event* eventR;
929 QString uid; 931 QString uid;
930 int take; 932 int take;
931 Event* eventL; 933 Event* eventL;
932 Event* eventRSync; 934 Event* eventRSync;
933 Event* eventLSync; 935 Event* eventLSync;
934 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 936 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
935 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 937 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
936 bool fullDateRange = false; 938 bool fullDateRange = false;
937 local->resetTempSyncStat(); 939 local->resetTempSyncStat();
938 mLastCalendarSync = QDateTime::currentDateTime(); 940 mLastCalendarSync = QDateTime::currentDateTime();
939 if ( mSyncManager->syncWithDesktop() ) { 941 if ( mSyncManager->syncWithDesktop() ) {
940 remote->resetPilotStat(1); 942 remote->resetPilotStat(1);
941 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 943 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
942 mLastCalendarSync = KSyncManager::mRequestedSyncEvent; 944 mLastCalendarSync = KSyncManager::mRequestedSyncEvent;
943 qDebug("using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); 945 qDebug("using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() );
944 } else { 946 } else {
945 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 947 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
946 } 948 }
947 } 949 }
948 QDateTime modifiedCalendar = mLastCalendarSync; 950 QDateTime modifiedCalendar = mLastCalendarSync;
949 eventLSync = getLastSyncEvent(); 951 eventLSync = getLastSyncEvent();
950 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 952 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
951 if ( eventR ) { 953 if ( eventR ) {
952 eventRSync = (Event*) eventR->clone(); 954 eventRSync = (Event*) eventR->clone();
953 remote->deleteEvent(eventR ); 955 remote->deleteEvent(eventR );
954 956
955 } else { 957 } else {
956 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { 958 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) {
957 eventRSync = (Event*)eventLSync->clone(); 959 eventRSync = (Event*)eventLSync->clone();
958 } else { 960 } else {
959 fullDateRange = true; 961 fullDateRange = true;
960 eventRSync = new Event(); 962 eventRSync = new Event();
961 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 963 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
962 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 964 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
963 eventRSync->setDtStart( mLastCalendarSync ); 965 eventRSync->setDtStart( mLastCalendarSync );
964 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 966 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
965 eventRSync->setCategories( i18n("SyncEvent") ); 967 eventRSync->setCategories( i18n("SyncEvent") );
966 } 968 }
967 } 969 }
968 if ( eventLSync->dtStart() == mLastCalendarSync ) 970 if ( eventLSync->dtStart() == mLastCalendarSync )
969 fullDateRange = true; 971 fullDateRange = true;
970 972
971 if ( ! fullDateRange ) { 973 if ( ! fullDateRange ) {
972 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 974 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
973 975
974 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 976 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
975 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 977 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
976 fullDateRange = true; 978 fullDateRange = true;
977 } 979 }
978 } 980 }
979 if ( mSyncManager->syncWithDesktop() ) { 981 if ( mSyncManager->syncWithDesktop() ) {
980 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); 982 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync );
981 } 983 }
982 if ( fullDateRange ) 984 if ( fullDateRange )
983 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 985 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
984 else 986 else
985 mLastCalendarSync = eventLSync->dtStart(); 987 mLastCalendarSync = eventLSync->dtStart();
986 // for resyncing if own file has changed 988 // for resyncing if own file has changed
987 if ( mCurrentSyncDevice == "deleteaftersync" ) { 989 if ( mCurrentSyncDevice == "deleteaftersync" ) {
988 mLastCalendarSync = loadedFileVersion; 990 mLastCalendarSync = loadedFileVersion;
989 //qDebug("setting mLastCalendarSync "); 991 //qDebug("setting mLastCalendarSync ");
990 } 992 }
991 //qDebug("*************************** "); 993 //qDebug("*************************** ");
992 qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); 994 qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange);
993 QPtrList<Incidence> er = remote->rawIncidences(); 995 QPtrList<Incidence> er = remote->rawIncidences();
994 Incidence* inR = er.first(); 996 Incidence* inR = er.first();
995 Incidence* inL; 997 Incidence* inL;
996 QProgressBar bar( er.count(),0 ); 998 QProgressBar bar( er.count(),0 );
997 bar.setCaption (i18n("Syncing - close to abort!") ); 999 bar.setCaption (i18n("Syncing - close to abort!") );
998 1000
999 // ************** setting up filter ************* 1001 // ************** setting up filter *************
1000 CalFilter *filterIN = 0; 1002 CalFilter *filterIN = 0;
1001 CalFilter *filterOUT = 0; 1003 CalFilter *filterOUT = 0;
1002 CalFilter *filter = mFilters.first(); 1004 CalFilter *filter = mFilters.first();
1003 while(filter) { 1005 while(filter) {
1004 if ( filter->name() == mSyncManager->mFilterInCal ) 1006 if ( filter->name() == mSyncManager->mFilterInCal )
1005 filterIN = filter; 1007 filterIN = filter;
1006 if ( filter->name() == mSyncManager->mFilterOutCal ) 1008 if ( filter->name() == mSyncManager->mFilterOutCal )
1007 filterOUT = filter; 1009 filterOUT = filter;
1008 filter = mFilters.next(); 1010 filter = mFilters.next();
1009 } 1011 }
1010 int w = 300; 1012 int w = 300;
1011 if ( QApplication::desktop()->width() < 320 ) 1013 if ( QApplication::desktop()->width() < 320 )
1012 w = 220; 1014 w = 220;
1013 int h = bar.sizeHint().height() ; 1015 int h = bar.sizeHint().height() ;
1014 int dw = QApplication::desktop()->width(); 1016 int dw = QApplication::desktop()->width();
1015 int dh = QApplication::desktop()->height(); 1017 int dh = QApplication::desktop()->height();
1016 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1018 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1017 bar.show(); 1019 bar.show();
1018 int modulo = (er.count()/10)+1; 1020 int modulo = (er.count()/10)+1;
1019 int incCounter = 0; 1021 int incCounter = 0;
1020 while ( inR ) { 1022 while ( inR ) {
1021 if ( ! bar.isVisible() ) 1023 if ( ! bar.isVisible() )
1022 return false; 1024 return false;
1023 if ( incCounter % modulo == 0 ) 1025 if ( incCounter % modulo == 0 )
1024 bar.setProgress( incCounter ); 1026 bar.setProgress( incCounter );
1025 ++incCounter; 1027 ++incCounter;
1026 uid = inR->uid(); 1028 uid = inR->uid();
1027 bool skipIncidence = false; 1029 bool skipIncidence = false;
1028 if ( uid.left(15) == QString("last-syncEvent-") ) 1030 if ( uid.left(15) == QString("last-syncEvent-") )
1029 skipIncidence = true; 1031 skipIncidence = true;
1030 QString idS; 1032 QString idS;
1031 qApp->processEvents(); 1033 qApp->processEvents();
1032 if ( !skipIncidence ) { 1034 if ( !skipIncidence ) {
1033 inL = local->incidence( uid ); 1035 inL = local->incidence( uid );
1034 if ( inL ) { // maybe conflict - same uid in both calendars 1036 if ( inL ) { // maybe conflict - same uid in both calendars
1035 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1037 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1036 //qDebug("take %d %s ", take, inL->summary().latin1()); 1038 //qDebug("take %d %s ", take, inL->summary().latin1());
1037 if ( take == 3 ) 1039 if ( take == 3 )
1038 return false; 1040 return false;
1039 if ( take == 1 ) {// take local ********************** 1041 if ( take == 1 ) {// take local **********************
1040 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1042 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1041 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1043 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1042 else 1044 else
1043 idS = inR->IDStr(); 1045 idS = inR->IDStr();
1044 remote->deleteIncidence( inR ); 1046 remote->deleteIncidence( inR );
1045 inR = inL->clone(); 1047 inR = inL->clone();
1046 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1048 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1047 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1049 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1048 inR->setIDStr( idS ); 1050 inR->setIDStr( idS );
1049 remote->addIncidence( inR ); 1051 remote->addIncidence( inR );
1050 if ( mSyncManager->syncWithDesktop() ) 1052 if ( mSyncManager->syncWithDesktop() )
1051 inR->setPilotId( 2 ); 1053 inR->setPilotId( 2 );
1052 ++changedRemote; 1054 ++changedRemote;
1053 } else {// take remote ********************** 1055 } else {// take remote **********************
1054 idS = inL->IDStr(); 1056 idS = inL->IDStr();
1055 int pid = inL->pilotId(); 1057 int pid = inL->pilotId();
1056 local->deleteIncidence( inL ); 1058 local->deleteIncidence( inL );
1057 inL = inR->clone(); 1059 inL = inR->clone();
1058 if ( mSyncManager->syncWithDesktop() ) 1060 if ( mSyncManager->syncWithDesktop() )
1059 inL->setPilotId( pid ); 1061 inL->setPilotId( pid );
1060 inL->setIDStr( idS ); 1062 inL->setIDStr( idS );
1061 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1063 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1062 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1064 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1063 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1065 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1064 } 1066 }
1065 local->addIncidence( inL ); 1067 local->addIncidence( inL );
1066 ++changedLocal; 1068 ++changedLocal;
1067 } 1069 }
1068 } 1070 }
1069 } else { // no conflict ********** add or delete remote 1071 } else { // no conflict ********** add or delete remote
1070 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ 1072 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){
1071 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1073 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1072 QString des = eventLSync->description(); 1074 QString des = eventLSync->description();
1073 QString pref = "e"; 1075 QString pref = "e";
1074 if ( inR->type() == "Todo" ) 1076 if ( inR->type() == "Todo" )
1075 pref = "t"; 1077 pref = "t";
1076 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1078 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1077 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1079 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1078 //remote->deleteIncidence( inR ); 1080 //remote->deleteIncidence( inR );
1079 ++deletedEventR; 1081 ++deletedEventR;
1080 } else { 1082 } else {
1081 inR->setLastModified( modifiedCalendar ); 1083 inR->setLastModified( modifiedCalendar );
1082 inL = inR->clone(); 1084 inL = inR->clone();
1083 inL->setIDStr( ":" ); 1085 inL->setIDStr( ":" );
1084 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1086 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1085 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1087 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1086 local->addIncidence( inL ); 1088 local->addIncidence( inL );
1087 ++addedEvent; 1089 ++addedEvent;
1088 1090
1089 } 1091 }
1090 } else { 1092 } else {
1091 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1093 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1092 inR->setLastModified( modifiedCalendar ); 1094 inR->setLastModified( modifiedCalendar );
1093 inL = inR->clone(); 1095 inL = inR->clone();
1094 inL->setIDStr( ":" ); 1096 inL->setIDStr( ":" );
1095 local->addIncidence( inL ); 1097 local->addIncidence( inL );
1096 ++addedEvent; 1098 ++addedEvent;
1097 1099
1098 } else { 1100 } else {
1099 checkExternSyncEvent(eventRSyncSharp, inR); 1101 checkExternSyncEvent(eventRSyncSharp, inR);
1100 remote->deleteIncidence( inR ); 1102 remote->deleteIncidence( inR );
1101 ++deletedEventR; 1103 ++deletedEventR;
1102 } 1104 }
1103 } 1105 }
1106 } else {
1107 ++filteredIN;
1104 } 1108 }
1105 } 1109 }
1106 } 1110 }
1107 inR = er.next(); 1111 inR = er.next();
1108 } 1112 }
1109 QPtrList<Incidence> el = local->rawIncidences(); 1113 QPtrList<Incidence> el = local->rawIncidences();
1110 inL = el.first(); 1114 inL = el.first();
1111 modulo = (el.count()/10)+1; 1115 modulo = (el.count()/10)+1;
1112 bar.setCaption (i18n("Add / remove events") ); 1116 bar.setCaption (i18n("Add / remove events") );
1113 bar.setTotalSteps ( el.count() ) ; 1117 bar.setTotalSteps ( el.count() ) ;
1114 bar.show(); 1118 bar.show();
1115 incCounter = 0; 1119 incCounter = 0;
1116 1120
1117 while ( inL ) { 1121 while ( inL ) {
1118 1122
1119 qApp->processEvents(); 1123 qApp->processEvents();
1120 if ( ! bar.isVisible() ) 1124 if ( ! bar.isVisible() )
1121 return false; 1125 return false;
1122 if ( incCounter % modulo == 0 ) 1126 if ( incCounter % modulo == 0 )
1123 bar.setProgress( incCounter ); 1127 bar.setProgress( incCounter );
1124 ++incCounter; 1128 ++incCounter;
1125 uid = inL->uid(); 1129 uid = inL->uid();
1126 bool skipIncidence = false; 1130 bool skipIncidence = false;
1127 if ( uid.left(15) == QString("last-syncEvent-") ) 1131 if ( uid.left(15) == QString("last-syncEvent-") )
1128 skipIncidence = true; 1132 skipIncidence = true;
1129 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) 1133 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
1130 skipIncidence = true; 1134 skipIncidence = true;
1131 if ( filterOUT && ! filterOUT->filterCalendarItem( inL ) ){
1132 skipIncidence = true;
1133 }
1134 if ( !skipIncidence ) { 1135 if ( !skipIncidence ) {
1135 inR = remote->incidence( uid ); 1136 inR = remote->incidence( uid );
1136 if ( ! inR ) { // no conflict ********** add or delete local 1137 if ( ! inR ) {
1137 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1138 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){
1138 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1139 // no conflict ********** add or delete local
1139 checkExternSyncEvent(eventLSyncSharp, inL); 1140 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1140 local->deleteIncidence( inL ); 1141 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1141 ++deletedEventL; 1142 checkExternSyncEvent(eventLSyncSharp, inL);
1142 } else { 1143 local->deleteIncidence( inL );
1143 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1144 ++deletedEventL;
1144 inL->removeID(mCurrentSyncDevice ); 1145 } else {
1145 ++addedEventR; 1146 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1146 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1147 inL->removeID(mCurrentSyncDevice );
1147 inL->setLastModified( modifiedCalendar ); 1148 ++addedEventR;
1148 inR = inL->clone(); 1149 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1149 inR->setIDStr( ":" ); 1150 inL->setLastModified( modifiedCalendar );
1150 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1151 inR = inL->clone();
1151 remote->addIncidence( inR ); 1152 inR->setIDStr( ":" );
1153 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1154 remote->addIncidence( inR );
1155 }
1152 } 1156 }
1153 }
1154 } else {
1155 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1156 checkExternSyncEvent(eventLSyncSharp, inL);
1157 local->deleteIncidence( inL );
1158 ++deletedEventL;
1159 } else { 1157 } else {
1160 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1158 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1161 ++addedEventR; 1159 checkExternSyncEvent(eventLSyncSharp, inL);
1162 inL->setLastModified( modifiedCalendar ); 1160 local->deleteIncidence( inL );
1163 inR = inL->clone(); 1161 ++deletedEventL;
1164 inR->setIDStr( ":" ); 1162 } else {
1165 remote->addIncidence( inR ); 1163 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1164 ++addedEventR;
1165 inL->setLastModified( modifiedCalendar );
1166 inR = inL->clone();
1167 inR->setIDStr( ":" );
1168 remote->addIncidence( inR );
1169 }
1166 } 1170 }
1167 } 1171 }
1172 } else {
1173 ++filteredOUT;
1168 } 1174 }
1169 } 1175 }
1170 } 1176 }
1171 inL = el.next(); 1177 inL = el.next();
1172 } 1178 }
1173 int delFut = 0; 1179 int delFut = 0;
1174 int remRem = 0; 1180 int remRem = 0;
1175 if ( mSyncManager->mWriteBackInFuture ) { 1181 if ( mSyncManager->mWriteBackInFuture ) {
1176 er = remote->rawIncidences(); 1182 er = remote->rawIncidences();
1177 remRem = er.count(); 1183 remRem = er.count();
1178 inR = er.first(); 1184 inR = er.first();
1179 QDateTime dt; 1185 QDateTime dt;
1180 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); 1186 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) );
1181 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); 1187 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 );
1182 while ( inR ) { 1188 while ( inR ) {
1183 if ( inR->type() == "Todo" ) { 1189 if ( inR->type() == "Todo" ) {
1184 Todo * t = (Todo*)inR; 1190 Todo * t = (Todo*)inR;
1185 if ( t->hasDueDate() ) 1191 if ( t->hasDueDate() )
1186 dt = t->dtDue(); 1192 dt = t->dtDue();
1187 else 1193 else
1188 dt = cur.addSecs( 62 ); 1194 dt = cur.addSecs( 62 );
1189 } 1195 }
1190 else if (inR->type() == "Event" ) { 1196 else if (inR->type() == "Event" ) {
1191 bool ok; 1197 bool ok;
1192 dt = inR->getNextOccurence( cur, &ok ); 1198 dt = inR->getNextOccurence( cur, &ok );
1193 if ( !ok ) 1199 if ( !ok )
1194 dt = cur.addSecs( -62 ); 1200 dt = cur.addSecs( -62 );
1195 } 1201 }
1196 else 1202 else
1197 dt = inR->dtStart(); 1203 dt = inR->dtStart();
1198 if ( dt < cur || dt > end ) { 1204 if ( dt < cur || dt > end ) {
1199 remote->deleteIncidence( inR ); 1205 remote->deleteIncidence( inR );
1200 ++delFut; 1206 ++delFut;
1201 } 1207 }
1202 inR = er.next(); 1208 inR = er.next();
1203 } 1209 }
1204 } 1210 }
1205 bar.hide(); 1211 bar.hide();
1206 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1212 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1207 eventLSync->setReadOnly( false ); 1213 eventLSync->setReadOnly( false );
1208 eventLSync->setDtStart( mLastCalendarSync ); 1214 eventLSync->setDtStart( mLastCalendarSync );
1209 eventRSync->setDtStart( mLastCalendarSync ); 1215 eventRSync->setDtStart( mLastCalendarSync );
1210 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1216 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1211 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1217 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1212 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1218 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1213 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1219 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1214 eventLSync->setReadOnly( true ); 1220 eventLSync->setReadOnly( true );
1215 qDebug("********** %d %d ", mGlobalSyncMode == SYNC_MODE_NORMAL, mSyncManager->syncWithDesktop() ); 1221 qDebug("********** %d %d ", mGlobalSyncMode == SYNC_MODE_NORMAL, mSyncManager->syncWithDesktop() );
1216 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... 1222 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal...
1217 remote->addEvent( eventRSync ); 1223 remote->addEvent( eventRSync );
1218 else 1224 else
1219 delete eventRSync; 1225 delete eventRSync;
1220 QString mes; 1226 QString mes;
1221 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"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); 1227 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 );
1222 QString delmess; 1228 QString delmess;
1223 if ( delFut ) { 1229 if ( delFut ) {
1224 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); 1230 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);
1225 mes += delmess; 1231 mes += delmess;
1226 } 1232 }
1227 mes = i18n("Local calendar changed!\n") +mes; 1233 mes = i18n("Local calendar changed!\n") +mes;
1228 mCalendar->checkAlarmForIncidence( 0, true ); 1234 mCalendar->checkAlarmForIncidence( 0, true );
1229 qDebug( mes ); 1235 qDebug( mes );
1230 if ( mSyncManager->mShowSyncSummary ) { 1236 if ( mSyncManager->mShowSyncSummary ) {
1231 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 1237 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
1232 i18n("KO/Pi Synchronization"),i18n("Write back"))) { 1238 i18n("KO/Pi Synchronization"),i18n("Write back"))) {
1233 qDebug("cancelled "); 1239 qDebug("cancelled ");
1234 return false; 1240 return false;
1235 } 1241 }
1236 } 1242 }
1237 return syncOK; 1243 return syncOK;
1238} 1244}
1239 1245
1240void CalendarView::setSyncDevice( QString s ) 1246void CalendarView::setSyncDevice( QString s )
1241{ 1247{
1242 mCurrentSyncDevice= s; 1248 mCurrentSyncDevice= s;
1243} 1249}
1244void CalendarView::setSyncName( QString s ) 1250void CalendarView::setSyncName( QString s )
1245{ 1251{
1246 mCurrentSyncName= s; 1252 mCurrentSyncName= s;
1247} 1253}
1248bool CalendarView::syncCalendar(QString filename, int mode) 1254bool CalendarView::syncCalendar(QString filename, int mode)
1249{ 1255{
1250 //qDebug("syncCalendar %s ", filename.latin1()); 1256 //qDebug("syncCalendar %s ", filename.latin1());
1251 mGlobalSyncMode = SYNC_MODE_NORMAL; 1257 mGlobalSyncMode = SYNC_MODE_NORMAL;
1252 CalendarLocal* calendar = new CalendarLocal(); 1258 CalendarLocal* calendar = new CalendarLocal();
1253 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1259 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1254 FileStorage* storage = new FileStorage( calendar ); 1260 FileStorage* storage = new FileStorage( calendar );
1255 bool syncOK = false; 1261 bool syncOK = false;
1256 storage->setFileName( filename ); 1262 storage->setFileName( filename );
1257 // qDebug("loading ... "); 1263 // qDebug("loading ... ");
1258 if ( storage->load() ) { 1264 if ( storage->load() ) {
1259 getEventViewerDialog()->setSyncMode( true ); 1265 getEventViewerDialog()->setSyncMode( true );
1260 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1266 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1261 getEventViewerDialog()->setSyncMode( false ); 1267 getEventViewerDialog()->setSyncMode( false );
1262 if ( syncOK ) { 1268 if ( syncOK ) {
1263 if ( mSyncManager->mWriteBackFile ) 1269 if ( mSyncManager->mWriteBackFile )
1264 { 1270 {
1265 storage->setSaveFormat( new ICalFormat() ); 1271 storage->setSaveFormat( new ICalFormat() );
1266 storage->save(); 1272 storage->save();
1267 } 1273 }
1268 } 1274 }
1269 setModified( true ); 1275 setModified( true );
1270 } 1276 }
1271 delete storage; 1277 delete storage;
1272 delete calendar; 1278 delete calendar;
1273 if ( syncOK ) 1279 if ( syncOK )
1274 updateView(); 1280 updateView();
1275 return syncOK; 1281 return syncOK;
1276} 1282}
1277 1283
1278void CalendarView::syncExternal( int mode ) 1284void CalendarView::syncExternal( int mode )
1279{ 1285{
1280 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1286 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1281 1287
1282 qApp->processEvents(); 1288 qApp->processEvents();
1283 CalendarLocal* calendar = new CalendarLocal(); 1289 CalendarLocal* calendar = new CalendarLocal();
1284 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1290 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1285 bool syncOK = false; 1291 bool syncOK = false;
1286 bool loadSuccess = false; 1292 bool loadSuccess = false;
1287 PhoneFormat* phoneFormat = 0; 1293 PhoneFormat* phoneFormat = 0;
1288 emit tempDisableBR(true); 1294 emit tempDisableBR(true);
1289#ifndef DESKTOP_VERSION 1295#ifndef DESKTOP_VERSION
1290 SharpFormat* sharpFormat = 0; 1296 SharpFormat* sharpFormat = 0;
1291 if ( mode == 0 ) { // sharp 1297 if ( mode == 0 ) { // sharp
1292 sharpFormat = new SharpFormat () ; 1298 sharpFormat = new SharpFormat () ;
1293 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1299 loadSuccess = sharpFormat->load( calendar, mCalendar );
1294 1300
1295 } else 1301 } else
1296#endif 1302#endif
1297 if ( mode == 1 ) { // phone 1303 if ( mode == 1 ) { // phone
1298 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1304 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1299 mSyncManager->mPhoneDevice, 1305 mSyncManager->mPhoneDevice,
1300 mSyncManager->mPhoneConnection, 1306 mSyncManager->mPhoneConnection,
1301 mSyncManager->mPhoneModel); 1307 mSyncManager->mPhoneModel);
1302 loadSuccess = phoneFormat->load( calendar,mCalendar); 1308 loadSuccess = phoneFormat->load( calendar,mCalendar);
1303 1309
1304 } else { 1310 } else {
1305 emit tempDisableBR(false); 1311 emit tempDisableBR(false);
1306 return; 1312 return;
1307 } 1313 }
1308 if ( loadSuccess ) { 1314 if ( loadSuccess ) {
1309 getEventViewerDialog()->setSyncMode( true ); 1315 getEventViewerDialog()->setSyncMode( true );
1310 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1316 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1311 getEventViewerDialog()->setSyncMode( false ); 1317 getEventViewerDialog()->setSyncMode( false );
1312 qApp->processEvents(); 1318 qApp->processEvents();
1313 if ( syncOK ) { 1319 if ( syncOK ) {
1314 if ( mSyncManager->mWriteBackFile ) 1320 if ( mSyncManager->mWriteBackFile )
1315 { 1321 {
1316 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1322 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1317 Incidence* inc = iL.first(); 1323 Incidence* inc = iL.first();
1318 if ( phoneFormat ) { 1324 if ( phoneFormat ) {
1319 while ( inc ) { 1325 while ( inc ) {
1320 inc->removeID(mCurrentSyncDevice); 1326 inc->removeID(mCurrentSyncDevice);
1321 inc = iL.next(); 1327 inc = iL.next();
1322 } 1328 }
1323 } 1329 }
1324#ifndef DESKTOP_VERSION 1330#ifndef DESKTOP_VERSION
1325 if ( sharpFormat ) 1331 if ( sharpFormat )
1326 sharpFormat->save(calendar); 1332 sharpFormat->save(calendar);
1327#endif 1333#endif
1328 if ( phoneFormat ) 1334 if ( phoneFormat )
1329 phoneFormat->save(calendar); 1335 phoneFormat->save(calendar);
1330 iL = calendar->rawIncidences(); 1336 iL = calendar->rawIncidences();
1331 inc = iL.first(); 1337 inc = iL.first();
1332 Incidence* loc; 1338 Incidence* loc;
1333 while ( inc ) { 1339 while ( inc ) {
1334 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1340 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1335 loc = mCalendar->incidence(inc->uid() ); 1341 loc = mCalendar->incidence(inc->uid() );
1336 if ( loc ) { 1342 if ( loc ) {
1337 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1343 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1338 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1344 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1339 } 1345 }
1340 } 1346 }
1341 inc = iL.next(); 1347 inc = iL.next();
1342 } 1348 }
1343 Incidence* lse = getLastSyncEvent(); 1349 Incidence* lse = getLastSyncEvent();
1344 if ( lse ) { 1350 if ( lse ) {
1345 lse->setReadOnly( false ); 1351 lse->setReadOnly( false );
1346 lse->setDescription( "" ); 1352 lse->setDescription( "" );
1347 lse->setReadOnly( true ); 1353 lse->setReadOnly( true );
1348 } 1354 }
1349 } 1355 }
1350 } else { 1356 } else {
1351 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 1357 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
1352 } 1358 }
1353 setModified( true ); 1359 setModified( true );
1354 } else { 1360 } else {
1355 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1361 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1356 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1362 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1357 question, i18n("Ok")) ; 1363 question, i18n("Ok")) ;
1358 1364
1359 } 1365 }
1360 delete calendar; 1366 delete calendar;
1361 updateView(); 1367 updateView();
1362 emit tempDisableBR(false); 1368 emit tempDisableBR(false);
1363 return ;//syncOK; 1369 return ;//syncOK;
1364 1370
1365} 1371}
1366 1372
1367bool CalendarView::importBday() 1373bool CalendarView::importBday()
1368{ 1374{
1369#ifndef KORG_NOKABC 1375#ifndef KORG_NOKABC
1370 1376
1371#ifdef DESKTOP_VERSION 1377#ifdef DESKTOP_VERSION
1372 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1378 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1373 KABC::AddressBook::Iterator it; 1379 KABC::AddressBook::Iterator it;
1374 int count = 0; 1380 int count = 0;
1375 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1381 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1376 ++count; 1382 ++count;
1377 } 1383 }
1378 QProgressBar bar(count,0 ); 1384 QProgressBar bar(count,0 );
1379 int w = 300; 1385 int w = 300;
1380 if ( QApplication::desktop()->width() < 320 ) 1386 if ( QApplication::desktop()->width() < 320 )
1381 w = 220; 1387 w = 220;
1382 int h = bar.sizeHint().height() ; 1388 int h = bar.sizeHint().height() ;
1383 int dw = QApplication::desktop()->width(); 1389 int dw = QApplication::desktop()->width();
1384 int dh = QApplication::desktop()->height(); 1390 int dh = QApplication::desktop()->height();
1385 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1391 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1386 bar.show(); 1392 bar.show();
1387 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1393 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1388 qApp->processEvents(); 1394 qApp->processEvents();
1389 count = 0; 1395 count = 0;
1390 int addCount = 0; 1396 int addCount = 0;
1391 KCal::Attendee* a = 0; 1397 KCal::Attendee* a = 0;
1392 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1398 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1393 if ( ! bar.isVisible() ) 1399 if ( ! bar.isVisible() )
1394 return false; 1400 return false;
1395 bar.setProgress( count++ ); 1401 bar.setProgress( count++ );
1396 qApp->processEvents(); 1402 qApp->processEvents();
1397 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1403 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1398 if ( (*it).birthday().date().isValid() ){ 1404 if ( (*it).birthday().date().isValid() ){
1399 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1405 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1400 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1406 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1401 ++addCount; 1407 ++addCount;
1402 } 1408 }
1403 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1409 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1404 if ( anni.isValid() ){ 1410 if ( anni.isValid() ){
1405 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1411 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1406 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1412 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1407 ++addCount; 1413 ++addCount;
1408 } 1414 }
1409 } 1415 }
1410 updateView(); 1416 updateView();
1411 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1417 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1412#else //DESKTOP_VERSION 1418#else //DESKTOP_VERSION
1413 1419
1414 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 1420 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
1415 // the result should now arrive through method insertBirthdays 1421 // the result should now arrive through method insertBirthdays
1416 1422
1417#endif //DESKTOP_VERSION 1423#endif //DESKTOP_VERSION
1418 1424
1419#endif //KORG_NOKABC 1425#endif //KORG_NOKABC
1420 1426
1421 1427
1422 return true; 1428 return true;
1423} 1429}
1424 1430
1425// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI 1431// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
1426void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, 1432void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
1427 const QStringList& anniversaryList, const QStringList& realNameList, 1433 const QStringList& anniversaryList, const QStringList& realNameList,
1428 const QStringList& emailList, const QStringList& assembledNameList, 1434 const QStringList& emailList, const QStringList& assembledNameList,
1429 const QStringList& uidList) 1435 const QStringList& uidList)
1430{ 1436{
1431 qDebug("CalendarView::insertBirthdays"); 1437 qDebug("CalendarView::insertBirthdays");
1432 if (uid == this->name()) 1438 if (uid == this->name())
1433 { 1439 {
1434 int count = birthdayList.count(); 1440 int count = birthdayList.count();
1435 int addCount = 0; 1441 int addCount = 0;
1436 KCal::Attendee* a = 0; 1442 KCal::Attendee* a = 0;
1437 1443
1438 qDebug("CalView 1 %i", count); 1444 qDebug("CalView 1 %i", count);
1439 1445
1440 QProgressBar bar(count,0 ); 1446 QProgressBar bar(count,0 );
1441 int w = 300; 1447 int w = 300;
1442 if ( QApplication::desktop()->width() < 320 ) 1448 if ( QApplication::desktop()->width() < 320 )
1443 w = 220; 1449 w = 220;
1444 int h = bar.sizeHint().height() ; 1450 int h = bar.sizeHint().height() ;
1445 int dw = QApplication::desktop()->width(); 1451 int dw = QApplication::desktop()->width();
1446 int dh = QApplication::desktop()->height(); 1452 int dh = QApplication::desktop()->height();
1447 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1453 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1448 bar.show(); 1454 bar.show();
1449 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 1455 bar.setCaption (i18n("inserting birthdays - close to abort!") );
1450 qApp->processEvents(); 1456 qApp->processEvents();
1451 1457
1452 QDate birthday; 1458 QDate birthday;
1453 QDate anniversary; 1459 QDate anniversary;
1454 QString realName; 1460 QString realName;
1455 QString email; 1461 QString email;
1456 QString assembledName; 1462 QString assembledName;
1457 QString uid; 1463 QString uid;
1458 bool ok = true; 1464 bool ok = true;
1459 for ( int i = 0; i < count; i++) 1465 for ( int i = 0; i < count; i++)
1460 { 1466 {
1461 if ( ! bar.isVisible() ) 1467 if ( ! bar.isVisible() )
1462 return; 1468 return;
1463 bar.setProgress( i ); 1469 bar.setProgress( i );
1464 qApp->processEvents(); 1470 qApp->processEvents();
1465 1471
1466 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); 1472 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
1467 if (!ok) { 1473 if (!ok) {
1468 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); 1474 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
1469 } 1475 }
1470 1476
1471 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); 1477 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
1472 if (!ok) { 1478 if (!ok) {
1473 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); 1479 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
1474 } 1480 }
1475 realName = realNameList[i]; 1481 realName = realNameList[i];
1476 email = emailList[i]; 1482 email = emailList[i];
1477 assembledName = assembledNameList[i]; 1483 assembledName = assembledNameList[i];
1478 uid = uidList[i]; 1484 uid = uidList[i];
1479 //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() ); 1485 //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() );
1480 1486
1481 if ( birthday.isValid() ){ 1487 if ( birthday.isValid() ){
1482 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1488 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1483 KCal::Attendee::ReqParticipant,uid) ; 1489 KCal::Attendee::ReqParticipant,uid) ;
1484 if ( addAnniversary( birthday, assembledName, a, true ) ) 1490 if ( addAnniversary( birthday, assembledName, a, true ) )
1485 ++addCount; 1491 ++addCount;
1486 } 1492 }
1487 1493
1488 if ( anniversary.isValid() ){ 1494 if ( anniversary.isValid() ){
1489 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1495 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1490 KCal::Attendee::ReqParticipant,uid) ; 1496 KCal::Attendee::ReqParticipant,uid) ;
1491 if ( addAnniversary( anniversary, assembledName, a, false ) ) 1497 if ( addAnniversary( anniversary, assembledName, a, false ) )
1492 ++addCount; 1498 ++addCount;
1493 } 1499 }
1494 } 1500 }
1495 1501
1496 updateView(); 1502 updateView();
1497 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1503 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1498 1504
1499 } 1505 }
1500 1506
1501} 1507}
1502 1508
1503 1509
1504 1510
1505bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1511bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1506{ 1512{
1507 //qDebug("addAnni "); 1513 //qDebug("addAnni ");
1508 Event * ev = new Event(); 1514 Event * ev = new Event();
1509 if ( a ) { 1515 if ( a ) {
1510 ev->addAttendee( a ); 1516 ev->addAttendee( a );
1511 } 1517 }
1512 QString kind; 1518 QString kind;
1513 if ( birthday ) 1519 if ( birthday )
1514 kind = i18n( "Birthday" ); 1520 kind = i18n( "Birthday" );
1515 else 1521 else
1516 kind = i18n( "Anniversary" ); 1522 kind = i18n( "Anniversary" );
1517 ev->setSummary( name + " - " + kind ); 1523 ev->setSummary( name + " - " + kind );
1518 ev->setOrganizer(a->email()); 1524 ev->setOrganizer(a->email());
1519 ev->setCategories( kind ); 1525 ev->setCategories( kind );
1520 ev->setDtStart( QDateTime(date) ); 1526 ev->setDtStart( QDateTime(date) );
1521 ev->setDtEnd( QDateTime(date) ); 1527 ev->setDtEnd( QDateTime(date) );
1522 ev->setFloats( true ); 1528 ev->setFloats( true );
1523 Recurrence * rec = ev->recurrence(); 1529 Recurrence * rec = ev->recurrence();
1524 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1530 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1525 rec->addYearlyNum( date.month() ); 1531 rec->addYearlyNum( date.month() );
1526 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1532 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1527 delete ev; 1533 delete ev;
1528 return false; 1534 return false;
1529 } 1535 }
1530 return true; 1536 return true;
1531 1537
1532} 1538}
1533bool CalendarView::importQtopia( const QString &categories, 1539bool CalendarView::importQtopia( const QString &categories,
1534 const QString &datebook, 1540 const QString &datebook,
1535 const QString &todolist ) 1541 const QString &todolist )
1536{ 1542{
1537 1543
1538 QtopiaFormat qtopiaFormat; 1544 QtopiaFormat qtopiaFormat;
1539 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1545 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1540 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1546 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1541 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1547 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1542 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1548 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1543 1549
1544 updateView(); 1550 updateView();
1545 return true; 1551 return true;
1546 1552
1547#if 0 1553#if 0
1548 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1554 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1549 mCurrentSyncDevice = "qtopia-XML"; 1555 mCurrentSyncDevice = "qtopia-XML";
1550 if ( mSyncManager->mAskForPreferences ) 1556 if ( mSyncManager->mAskForPreferences )
1551 edit_sync_options(); 1557 edit_sync_options();
1552 qApp->processEvents(); 1558 qApp->processEvents();
1553 CalendarLocal* calendar = new CalendarLocal(); 1559 CalendarLocal* calendar = new CalendarLocal();
1554 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1560 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1555 bool syncOK = false; 1561 bool syncOK = false;
1556 QtopiaFormat qtopiaFormat; 1562 QtopiaFormat qtopiaFormat;
1557 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1563 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1558 bool loadOk = true; 1564 bool loadOk = true;
1559 if ( !categories.isEmpty() ) 1565 if ( !categories.isEmpty() )
1560 loadOk = qtopiaFormat.load( calendar, categories ); 1566 loadOk = qtopiaFormat.load( calendar, categories );
1561 if ( loadOk && !datebook.isEmpty() ) 1567 if ( loadOk && !datebook.isEmpty() )
1562 loadOk = qtopiaFormat.load( calendar, datebook ); 1568 loadOk = qtopiaFormat.load( calendar, datebook );
1563 if ( loadOk && !todolist.isEmpty() ) 1569 if ( loadOk && !todolist.isEmpty() )
1564 loadOk = qtopiaFormat.load( calendar, todolist ); 1570 loadOk = qtopiaFormat.load( calendar, todolist );
1565 1571
1566 if ( loadOk ) { 1572 if ( loadOk ) {
1567 getEventViewerDialog()->setSyncMode( true ); 1573 getEventViewerDialog()->setSyncMode( true );
1568 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1574 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1569 getEventViewerDialog()->setSyncMode( false ); 1575 getEventViewerDialog()->setSyncMode( false );
1570 qApp->processEvents(); 1576 qApp->processEvents();
1571 if ( syncOK ) { 1577 if ( syncOK ) {
1572 if ( mSyncManager->mWriteBackFile ) 1578 if ( mSyncManager->mWriteBackFile )
1573 { 1579 {
1574 // write back XML file 1580 // write back XML file
1575 1581
1576 } 1582 }
1577 setModified( true ); 1583 setModified( true );
1578 } 1584 }
1579 } else { 1585 } else {
1580 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1586 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1581 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1587 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1582 question, i18n("Ok")) ; 1588 question, i18n("Ok")) ;
1583 } 1589 }
1584 delete calendar; 1590 delete calendar;
1585 updateView(); 1591 updateView();
1586 return syncOK; 1592 return syncOK;
1587 1593
1588 1594
1589#endif 1595#endif
1590 1596
1591} 1597}
1592 1598
1593void CalendarView::setSyncEventsReadOnly() 1599void CalendarView::setSyncEventsReadOnly()
1594{ 1600{
1595 Event * ev; 1601 Event * ev;
1596 QPtrList<Event> eL = mCalendar->rawEvents(); 1602 QPtrList<Event> eL = mCalendar->rawEvents();
1597 ev = eL.first(); 1603 ev = eL.first();
1598 while ( ev ) { 1604 while ( ev ) {
1599 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1605 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1600 ev->setReadOnly( true ); 1606 ev->setReadOnly( true );
1601 ev = eL.next(); 1607 ev = eL.next();
1602 } 1608 }
1603} 1609}
1604bool CalendarView::openCalendar(QString filename, bool merge) 1610bool CalendarView::openCalendar(QString filename, bool merge)
1605{ 1611{
1606 1612
1607 if (filename.isEmpty()) { 1613 if (filename.isEmpty()) {
1608 return false; 1614 return false;
1609 } 1615 }
1610 1616
1611 if (!QFile::exists(filename)) { 1617 if (!QFile::exists(filename)) {
1612 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1618 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1613 return false; 1619 return false;
1614 } 1620 }
1615 1621
1616 globalFlagBlockAgenda = 1; 1622 globalFlagBlockAgenda = 1;
1617 if (!merge) mCalendar->close(); 1623 if (!merge) mCalendar->close();
1618 1624
1619 mStorage->setFileName( filename ); 1625 mStorage->setFileName( filename );
1620 1626
1621 if ( mStorage->load() ) { 1627 if ( mStorage->load() ) {
1622 if ( merge ) ;//setModified( true ); 1628 if ( merge ) ;//setModified( true );
1623 else { 1629 else {
1624 //setModified( true ); 1630 //setModified( true );
1625 mViewManager->setDocumentId( filename ); 1631 mViewManager->setDocumentId( filename );
1626 mDialogManager->setDocumentId( filename ); 1632 mDialogManager->setDocumentId( filename );
1627 mTodoList->setDocumentId( filename ); 1633 mTodoList->setDocumentId( filename );
1628 } 1634 }
1629 globalFlagBlockAgenda = 2; 1635 globalFlagBlockAgenda = 2;
1630 // if ( getLastSyncEvent() ) 1636 // if ( getLastSyncEvent() )
1631 // getLastSyncEvent()->setReadOnly( true ); 1637 // getLastSyncEvent()->setReadOnly( true );
1632 mCalendar->reInitAlarmSettings(); 1638 mCalendar->reInitAlarmSettings();
1633 setSyncEventsReadOnly(); 1639 setSyncEventsReadOnly();
1634 updateUnmanagedViews(); 1640 updateUnmanagedViews();
1635 updateView(); 1641 updateView();
1636 if ( filename != MainWindow::defaultFileName() ) { 1642 if ( filename != MainWindow::defaultFileName() ) {
1637 saveCalendar( MainWindow::defaultFileName() ); 1643 saveCalendar( MainWindow::defaultFileName() );
1638 } else { 1644 } else {
1639 QFileInfo finf ( MainWindow::defaultFileName()); 1645 QFileInfo finf ( MainWindow::defaultFileName());
1640 if ( finf.exists() ) { 1646 if ( finf.exists() ) {
1641 setLoadedFileVersion( finf.lastModified () ); 1647 setLoadedFileVersion( finf.lastModified () );
1642 } 1648 }
1643 } 1649 }
1644 return true; 1650 return true;
1645 } else { 1651 } else {
1646 // while failing to load, the calendar object could 1652 // while failing to load, the calendar object could
1647 // have become partially populated. Clear it out. 1653 // have become partially populated. Clear it out.
1648 if ( !merge ) { 1654 if ( !merge ) {
1649 mCalendar->close(); 1655 mCalendar->close();
1650 mViewManager->setDocumentId( filename ); 1656 mViewManager->setDocumentId( filename );
1651 mDialogManager->setDocumentId( filename ); 1657 mDialogManager->setDocumentId( filename );
1652 mTodoList->setDocumentId( filename ); 1658 mTodoList->setDocumentId( filename );
1653 } 1659 }
1654 1660
1655 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1661 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1656 1662
1657 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 1663 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
1658 globalFlagBlockAgenda = 2; 1664 globalFlagBlockAgenda = 2;
1659 mCalendar->reInitAlarmSettings(); 1665 mCalendar->reInitAlarmSettings();
1660 setSyncEventsReadOnly(); 1666 setSyncEventsReadOnly();
1661 updateUnmanagedViews(); 1667 updateUnmanagedViews();
1662 updateView(); 1668 updateView();
1663 } 1669 }
1664 return false; 1670 return false;
1665} 1671}
1666void CalendarView::showOpenError() 1672void CalendarView::showOpenError()
1667{ 1673{
1668 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 1674 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
1669} 1675}
1670void CalendarView::setLoadedFileVersion(QDateTime dt) 1676void CalendarView::setLoadedFileVersion(QDateTime dt)
1671{ 1677{
1672 loadedFileVersion = dt; 1678 loadedFileVersion = dt;
1673} 1679}
1674bool CalendarView::checkFileChanged(QString fn) 1680bool CalendarView::checkFileChanged(QString fn)
1675{ 1681{
1676 QFileInfo finf ( fn ); 1682 QFileInfo finf ( fn );
1677 if ( !finf.exists() ) 1683 if ( !finf.exists() )
1678 return true; 1684 return true;
1679 QDateTime dt = finf.lastModified (); 1685 QDateTime dt = finf.lastModified ();
1680 if ( dt <= loadedFileVersion ) 1686 if ( dt <= loadedFileVersion )
1681 return false; 1687 return false;
1682 return true; 1688 return true;
1683 1689
1684} 1690}
1685void CalendarView::watchSavedFile() 1691void CalendarView::watchSavedFile()
1686{ 1692{
1687 QFileInfo finf ( MainWindow::defaultFileName()); 1693 QFileInfo finf ( MainWindow::defaultFileName());
1688 if ( !finf.exists() ) 1694 if ( !finf.exists() )
1689 return; 1695 return;
1690 QDateTime dt = finf.lastModified (); 1696 QDateTime dt = finf.lastModified ();
1691 if ( dt < loadedFileVersion ) { 1697 if ( dt < loadedFileVersion ) {
1692 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 1698 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
1693 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 1699 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1694 return; 1700 return;
1695 } 1701 }
1696 loadedFileVersion = dt; 1702 loadedFileVersion = dt;
1697} 1703}
1698 1704
1699bool CalendarView::checkFileVersion(QString fn) 1705bool CalendarView::checkFileVersion(QString fn)
1700{ 1706{
1701 QFileInfo finf ( fn ); 1707 QFileInfo finf ( fn );
1702 if ( !finf.exists() ) 1708 if ( !finf.exists() )
1703 return true; 1709 return true;
1704 QDateTime dt = finf.lastModified (); 1710 QDateTime dt = finf.lastModified ();
1705 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1711 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1706 //qDebug("file on disk version %s",dt.toString().latin1()); 1712 //qDebug("file on disk version %s",dt.toString().latin1());
1707 if ( dt <= loadedFileVersion ) 1713 if ( dt <= loadedFileVersion )
1708 return true; 1714 return 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)) , 1715 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)) ,
1710 i18n("KO/Pi Warning"),i18n("Overwrite"), 1716 i18n("KO/Pi Warning"),i18n("Overwrite"),
1711 i18n("Sync+save")); 1717 i18n("Sync+save"));
1712 1718
1713 if ( km == KMessageBox::Cancel ) 1719 if ( km == KMessageBox::Cancel )
1714 return false; 1720 return false;
1715 if ( km == KMessageBox::Yes ) 1721 if ( km == KMessageBox::Yes )
1716 return true; 1722 return true;
1717 1723
1718 setSyncDevice("deleteaftersync" ); 1724 setSyncDevice("deleteaftersync" );
1719 mSyncManager->mAskForPreferences = true; 1725 mSyncManager->mAskForPreferences = true;
1720 mSyncManager->mSyncAlgoPrefs = 3; 1726 mSyncManager->mSyncAlgoPrefs = 3;
1721 mSyncManager->mWriteBackFile = false; 1727 mSyncManager->mWriteBackFile = false;
1722 mSyncManager->mWriteBackExistingOnly = false; 1728 mSyncManager->mWriteBackExistingOnly = false;
1723 mSyncManager->mShowSyncSummary = false; 1729 mSyncManager->mShowSyncSummary = false;
1724 syncCalendar( fn, 3 ); 1730 syncCalendar( fn, 3 );
1725 Event * e = getLastSyncEvent(); 1731 Event * e = getLastSyncEvent();
1726 mCalendar->deleteEvent ( e ); 1732 mCalendar->deleteEvent ( e );
1727 updateView(); 1733 updateView();
1728 return true; 1734 return true;
1729} 1735}
1730 1736
1731bool CalendarView::saveCalendar( QString filename ) 1737bool CalendarView::saveCalendar( QString filename )
1732{ 1738{
1733 1739
1734 // Store back all unsaved data into calendar object 1740 // Store back all unsaved data into calendar object
1735 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1741 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1736 if ( mViewManager->currentView() ) 1742 if ( mViewManager->currentView() )
1737 mViewManager->currentView()->flushView(); 1743 mViewManager->currentView()->flushView();
1738 1744
1739 1745
1740 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 1746 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
1741 mStorage->setSaveFormat( new ICalFormat() ); 1747 mStorage->setSaveFormat( new ICalFormat() );
1742 mStorage->setFileName( filename ); 1748 mStorage->setFileName( filename );
1743 bool success; 1749 bool success;
1744 success = mStorage->save(); 1750 success = mStorage->save();
1745 if ( !success ) { 1751 if ( !success ) {
1746 return false; 1752 return false;
1747 } 1753 }
1748 if ( filename == MainWindow::defaultFileName() ) { 1754 if ( filename == MainWindow::defaultFileName() ) {
1749 setLoadedFileVersion( lfv ); 1755 setLoadedFileVersion( lfv );
1750 watchSavedFile(); 1756 watchSavedFile();
1751 } 1757 }
1752 return true; 1758 return true;
1753} 1759}
1754 1760
1755void CalendarView::closeCalendar() 1761void CalendarView::closeCalendar()
1756{ 1762{
1757 1763
1758 // child windows no longer valid 1764 // child windows no longer valid
1759 emit closingDown(); 1765 emit closingDown();
1760 1766
1761 mCalendar->close(); 1767 mCalendar->close();
1762 setModified(false); 1768 setModified(false);
1763 updateView(); 1769 updateView();
1764} 1770}
1765 1771
1766void CalendarView::archiveCalendar() 1772void CalendarView::archiveCalendar()
1767{ 1773{
1768 mDialogManager->showArchiveDialog(); 1774 mDialogManager->showArchiveDialog();
1769} 1775}
1770 1776
1771 1777
1772void CalendarView::readSettings() 1778void CalendarView::readSettings()
1773{ 1779{
1774 1780
1775 1781
1776 // mViewManager->showAgendaView(); 1782 // mViewManager->showAgendaView();
1777 QString str; 1783 QString str;
1778 //qDebug("CalendarView::readSettings() "); 1784 //qDebug("CalendarView::readSettings() ");
1779 // read settings from the KConfig, supplying reasonable 1785 // read settings from the KConfig, supplying reasonable
1780 // defaults where none are to be found 1786 // defaults where none are to be found
1781 KConfig *config = KOGlobals::config(); 1787 KConfig *config = KOGlobals::config();
1782#ifndef KORG_NOSPLITTER 1788#ifndef KORG_NOSPLITTER
1783 config->setGroup("KOrganizer Geometry"); 1789 config->setGroup("KOrganizer Geometry");
1784 1790
1785 QValueList<int> sizes = config->readIntListEntry("Separator1"); 1791 QValueList<int> sizes = config->readIntListEntry("Separator1");
1786 if (sizes.count() != 2) { 1792 if (sizes.count() != 2) {
1787 sizes << mDateNavigator->minimumSizeHint().width(); 1793 sizes << mDateNavigator->minimumSizeHint().width();
1788 sizes << 300; 1794 sizes << 300;
1789 } 1795 }
1790 mPanner->setSizes(sizes); 1796 mPanner->setSizes(sizes);
1791 1797
1792 sizes = config->readIntListEntry("Separator2"); 1798 sizes = config->readIntListEntry("Separator2");
1793 if ( ( mResourceView && sizes.count() == 4 ) || 1799 if ( ( mResourceView && sizes.count() == 4 ) ||
1794 ( !mResourceView && sizes.count() == 3 ) ) { 1800 ( !mResourceView && sizes.count() == 3 ) ) {
1795 mLeftSplitter->setSizes(sizes); 1801 mLeftSplitter->setSizes(sizes);
1796 } 1802 }
1797#endif 1803#endif
1798 globalFlagBlockAgenda = 1; 1804 globalFlagBlockAgenda = 1;
1799 mViewManager->showAgendaView(); 1805 mViewManager->showAgendaView();
1800 //mViewManager->readSettings( config ); 1806 //mViewManager->readSettings( config );
1801 mTodoList->restoreLayout(config,QString("Todo Layout")); 1807 mTodoList->restoreLayout(config,QString("Todo Layout"));
1802 readFilterSettings(config); 1808 readFilterSettings(config);
1803 config->setGroup( "Views" ); 1809 config->setGroup( "Views" );
1804 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 1810 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
1805 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 1811 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
1806 else if ( dateCount == 7 ) mNavigator->selectWeek(); 1812 else if ( dateCount == 7 ) mNavigator->selectWeek();
1807 else mNavigator->selectDates( dateCount ); 1813 else mNavigator->selectDates( dateCount );
1808 // mViewManager->readSettings( config ); 1814 // mViewManager->readSettings( config );
1809 updateConfig(); 1815 updateConfig();
1810 globalFlagBlockAgenda = 2; 1816 globalFlagBlockAgenda = 2;
1811 mViewManager->readSettings( config ); 1817 mViewManager->readSettings( config );
1812#ifdef DESKTOP_VERSION 1818#ifdef DESKTOP_VERSION
1813 config->setGroup("WidgetLayout"); 1819 config->setGroup("WidgetLayout");
1814 QStringList list; 1820 QStringList list;
1815 list = config->readListEntry("MainLayout"); 1821 list = config->readListEntry("MainLayout");
1816 int x,y,w,h; 1822 int x,y,w,h;
1817 if ( ! list.isEmpty() ) { 1823 if ( ! list.isEmpty() ) {
1818 x = list[0].toInt(); 1824 x = list[0].toInt();
1819 y = list[1].toInt(); 1825 y = list[1].toInt();
1820 w = list[2].toInt(); 1826 w = list[2].toInt();
1821 h = list[3].toInt(); 1827 h = list[3].toInt();
1822 topLevelWidget()->setGeometry(x,y,w,h); 1828 topLevelWidget()->setGeometry(x,y,w,h);
1823 1829
1824 } else { 1830 } else {
1825 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 1831 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
1826 } 1832 }
1827 list = config->readListEntry("EditEventLayout"); 1833 list = config->readListEntry("EditEventLayout");
1828 if ( ! list.isEmpty() ) { 1834 if ( ! list.isEmpty() ) {
1829 x = list[0].toInt(); 1835 x = list[0].toInt();
1830 y = list[1].toInt(); 1836 y = list[1].toInt();
1831 w = list[2].toInt(); 1837 w = list[2].toInt();
1832 h = list[3].toInt(); 1838 h = list[3].toInt();
1833 mEventEditor->setGeometry(x,y,w,h); 1839 mEventEditor->setGeometry(x,y,w,h);
1834 1840
1835 } 1841 }
1836 list = config->readListEntry("EditTodoLayout"); 1842 list = config->readListEntry("EditTodoLayout");
1837 if ( ! list.isEmpty() ) { 1843 if ( ! list.isEmpty() ) {
1838 x = list[0].toInt(); 1844 x = list[0].toInt();
1839 y = list[1].toInt(); 1845 y = list[1].toInt();
1840 w = list[2].toInt(); 1846 w = list[2].toInt();
1841 h = list[3].toInt(); 1847 h = list[3].toInt();
1842 mTodoEditor->setGeometry(x,y,w,h); 1848 mTodoEditor->setGeometry(x,y,w,h);
1843 1849
1844 } 1850 }
1845 list = config->readListEntry("ViewerLayout"); 1851 list = config->readListEntry("ViewerLayout");
1846 if ( ! list.isEmpty() ) { 1852 if ( ! list.isEmpty() ) {
1847 x = list[0].toInt(); 1853 x = list[0].toInt();
1848 y = list[1].toInt(); 1854 y = list[1].toInt();
1849 w = list[2].toInt(); 1855 w = list[2].toInt();
1850 h = list[3].toInt(); 1856 h = list[3].toInt();
1851 getEventViewerDialog()->setGeometry(x,y,w,h); 1857 getEventViewerDialog()->setGeometry(x,y,w,h);
1852 } 1858 }
1853#endif 1859#endif
1854 1860
1855} 1861}
1856 1862
1857 1863
1858void CalendarView::writeSettings() 1864void CalendarView::writeSettings()
1859{ 1865{
1860 // kdDebug() << "CalendarView::writeSettings" << endl; 1866 // kdDebug() << "CalendarView::writeSettings" << endl;
1861 1867
1862 KConfig *config = KOGlobals::config(); 1868 KConfig *config = KOGlobals::config();
1863 1869
1864#ifndef KORG_NOSPLITTER 1870#ifndef KORG_NOSPLITTER
1865 config->setGroup("KOrganizer Geometry"); 1871 config->setGroup("KOrganizer Geometry");
1866 1872
1867 QValueList<int> list = mPanner->sizes(); 1873 QValueList<int> list = mPanner->sizes();
1868 config->writeEntry("Separator1",list); 1874 config->writeEntry("Separator1",list);
1869 1875
1870 list = mLeftSplitter->sizes(); 1876 list = mLeftSplitter->sizes();
1871 config->writeEntry("Separator2",list); 1877 config->writeEntry("Separator2",list);
1872#endif 1878#endif
1873 1879
1874 mViewManager->writeSettings( config ); 1880 mViewManager->writeSettings( config );
1875 mTodoList->saveLayout(config,QString("Todo Layout")); 1881 mTodoList->saveLayout(config,QString("Todo Layout"));
1876 mDialogManager->writeSettings( config ); 1882 mDialogManager->writeSettings( config );
1877 //KOPrefs::instance()->usrWriteConfig(); 1883 //KOPrefs::instance()->usrWriteConfig();
1878 KOPrefs::instance()->writeConfig(); 1884 KOPrefs::instance()->writeConfig();
1879 1885
1880 writeFilterSettings(config); 1886 writeFilterSettings(config);
1881 1887
1882 config->setGroup( "Views" ); 1888 config->setGroup( "Views" );
1883 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 1889 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
1884 1890
1885#ifdef DESKTOP_VERSION 1891#ifdef DESKTOP_VERSION
1886 config->setGroup("WidgetLayout"); 1892 config->setGroup("WidgetLayout");
1887 QStringList list ;//= config->readListEntry("MainLayout"); 1893 QStringList list ;//= config->readListEntry("MainLayout");
1888 int x,y,w,h; 1894 int x,y,w,h;
1889 QWidget* wid; 1895 QWidget* wid;
1890 wid = topLevelWidget(); 1896 wid = topLevelWidget();
1891 x = wid->geometry().x(); 1897 x = wid->geometry().x();
1892 y = wid->geometry().y(); 1898 y = wid->geometry().y();
1893 w = wid->width(); 1899 w = wid->width();
1894 h = wid->height(); 1900 h = wid->height();
1895 list.clear(); 1901 list.clear();
1896 list << QString::number( x ); 1902 list << QString::number( x );
1897 list << QString::number( y ); 1903 list << QString::number( y );
1898 list << QString::number( w ); 1904 list << QString::number( w );
1899 list << QString::number( h ); 1905 list << QString::number( h );
1900 config->writeEntry("MainLayout",list ); 1906 config->writeEntry("MainLayout",list );
1901 1907
1902 wid = mEventEditor; 1908 wid = mEventEditor;
1903 x = wid->geometry().x(); 1909 x = wid->geometry().x();
1904 y = wid->geometry().y(); 1910 y = wid->geometry().y();
1905 w = wid->width(); 1911 w = wid->width();
1906 h = wid->height(); 1912 h = wid->height();
1907 list.clear(); 1913 list.clear();
1908 list << QString::number( x ); 1914 list << QString::number( x );
1909 list << QString::number( y ); 1915 list << QString::number( y );
1910 list << QString::number( w ); 1916 list << QString::number( w );
1911 list << QString::number( h ); 1917 list << QString::number( h );
1912 config->writeEntry("EditEventLayout",list ); 1918 config->writeEntry("EditEventLayout",list );
1913 1919
1914 wid = mTodoEditor; 1920 wid = mTodoEditor;
1915 x = wid->geometry().x(); 1921 x = wid->geometry().x();
1916 y = wid->geometry().y(); 1922 y = wid->geometry().y();
1917 w = wid->width(); 1923 w = wid->width();
1918 h = wid->height(); 1924 h = wid->height();
1919 list.clear(); 1925 list.clear();
1920 list << QString::number( x ); 1926 list << QString::number( x );
1921 list << QString::number( y ); 1927 list << QString::number( y );
1922 list << QString::number( w ); 1928 list << QString::number( w );
1923 list << QString::number( h ); 1929 list << QString::number( h );
1924 config->writeEntry("EditTodoLayout",list ); 1930 config->writeEntry("EditTodoLayout",list );
1925 wid = getEventViewerDialog(); 1931 wid = getEventViewerDialog();
1926 x = wid->geometry().x(); 1932 x = wid->geometry().x();
1927 y = wid->geometry().y(); 1933 y = wid->geometry().y();
1928 w = wid->width(); 1934 w = wid->width();
1929 h = wid->height(); 1935 h = wid->height();
1930 list.clear(); 1936 list.clear();
1931 list << QString::number( x ); 1937 list << QString::number( x );
1932 list << QString::number( y ); 1938 list << QString::number( y );
1933 list << QString::number( w ); 1939 list << QString::number( w );
1934 list << QString::number( h ); 1940 list << QString::number( h );
1935 config->writeEntry("ViewerLayout",list ); 1941 config->writeEntry("ViewerLayout",list );
1936 wid = mDialogManager->getSearchDialog(); 1942 wid = mDialogManager->getSearchDialog();
1937 if ( wid ) { 1943 if ( wid ) {
1938 x = wid->geometry().x(); 1944 x = wid->geometry().x();
1939 y = wid->geometry().y(); 1945 y = wid->geometry().y();
1940 w = wid->width(); 1946 w = wid->width();
1941 h = wid->height(); 1947 h = wid->height();
1942 list.clear(); 1948 list.clear();
1943 list << QString::number( x ); 1949 list << QString::number( x );
1944 list << QString::number( y ); 1950 list << QString::number( y );
1945 list << QString::number( w ); 1951 list << QString::number( w );
1946 list << QString::number( h ); 1952 list << QString::number( h );
1947 config->writeEntry("SearchLayout",list ); 1953 config->writeEntry("SearchLayout",list );
1948 } 1954 }
1949#endif 1955#endif
1950 1956
1951 1957
1952 config->sync(); 1958 config->sync();
1953} 1959}
1954 1960
1955void CalendarView::readFilterSettings(KConfig *config) 1961void CalendarView::readFilterSettings(KConfig *config)
1956{ 1962{
1957 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 1963 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
1958 1964
1959 mFilters.clear(); 1965 mFilters.clear();
1960 1966
1961 config->setGroup("General"); 1967 config->setGroup("General");
1962 QStringList filterList = config->readListEntry("CalendarFilters"); 1968 QStringList filterList = config->readListEntry("CalendarFilters");
1963 1969
1964 QStringList::ConstIterator it = filterList.begin(); 1970 QStringList::ConstIterator it = filterList.begin();
1965 QStringList::ConstIterator end = filterList.end(); 1971 QStringList::ConstIterator end = filterList.end();
1966 while(it != end) { 1972 while(it != end) {
1967 // kdDebug() << " filter: " << (*it) << endl; 1973 // kdDebug() << " filter: " << (*it) << endl;
1968 1974
1969 CalFilter *filter; 1975 CalFilter *filter;
1970 filter = new CalFilter(*it); 1976 filter = new CalFilter(*it);
1971 config->setGroup("Filter_" + (*it)); 1977 config->setGroup("Filter_" + (*it));
1972 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 1978 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
1973 filter->setCriteria(config->readNumEntry("Criteria",0)); 1979 filter->setCriteria(config->readNumEntry("Criteria",0));
1974 filter->setCategoryList(config->readListEntry("CategoryList")); 1980 filter->setCategoryList(config->readListEntry("CategoryList"));
1975 mFilters.append(filter); 1981 mFilters.append(filter);
1976 1982
1977 ++it; 1983 ++it;
1978 } 1984 }
1979 1985
1980 if (mFilters.count() == 0) { 1986 if (mFilters.count() == 0) {
1981 CalFilter *filter = new CalFilter(i18n("Default")); 1987 CalFilter *filter = new CalFilter(i18n("Default"));
1982 mFilters.append(filter); 1988 mFilters.append(filter);
1983 } 1989 }
1984 mFilterView->updateFilters(); 1990 mFilterView->updateFilters();
1985 config->setGroup("FilterView"); 1991 config->setGroup("FilterView");
1986 1992
1987 mFilterView->blockSignals(true); 1993 mFilterView->blockSignals(true);
1988 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 1994 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
1989 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 1995 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
1990 mFilterView->blockSignals(false); 1996 mFilterView->blockSignals(false);
1991 // We do it manually to avoid it being done twice by the above calls 1997 // We do it manually to avoid it being done twice by the above calls
1992 updateFilter(); 1998 updateFilter();
1993} 1999}
1994 2000
1995void CalendarView::writeFilterSettings(KConfig *config) 2001void CalendarView::writeFilterSettings(KConfig *config)
1996{ 2002{
1997 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 2003 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
1998 2004
1999 QStringList filterList; 2005 QStringList filterList;
2000 2006
2001 CalFilter *filter = mFilters.first(); 2007 CalFilter *filter = mFilters.first();
2002 while(filter) { 2008 while(filter) {
2003 // kdDebug() << " fn: " << filter->name() << endl; 2009 // kdDebug() << " fn: " << filter->name() << endl;
2004 filterList << filter->name(); 2010 filterList << filter->name();
2005 config->setGroup("Filter_" + filter->name()); 2011 config->setGroup("Filter_" + filter->name());
2006 config->writeEntry("Criteria",filter->criteria()); 2012 config->writeEntry("Criteria",filter->criteria());
2007 config->writeEntry("CategoryList",filter->categoryList()); 2013 config->writeEntry("CategoryList",filter->categoryList());
2008 filter = mFilters.next(); 2014 filter = mFilters.next();
2009 } 2015 }
2010 config->setGroup("General"); 2016 config->setGroup("General");
2011 config->writeEntry("CalendarFilters",filterList); 2017 config->writeEntry("CalendarFilters",filterList);
2012 2018
2013 config->setGroup("FilterView"); 2019 config->setGroup("FilterView");
2014 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 2020 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
2015 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 2021 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
2016} 2022}
2017 2023
2018 2024
2019void CalendarView::goToday() 2025void CalendarView::goToday()
2020{ 2026{
2021 if ( mViewManager->currentView()->isMonthView() ) 2027 if ( mViewManager->currentView()->isMonthView() )
2022 mNavigator->selectTodayMonth(); 2028 mNavigator->selectTodayMonth();
2023 else 2029 else
2024 mNavigator->selectToday(); 2030 mNavigator->selectToday();
2025} 2031}
2026 2032
2027void CalendarView::goNext() 2033void CalendarView::goNext()
2028{ 2034{
2029 mNavigator->selectNext(); 2035 mNavigator->selectNext();
2030} 2036}
2031 2037
2032void CalendarView::goPrevious() 2038void CalendarView::goPrevious()
2033{ 2039{
2034 mNavigator->selectPrevious(); 2040 mNavigator->selectPrevious();
2035} 2041}
2036void CalendarView::goNextMonth() 2042void CalendarView::goNextMonth()
2037{ 2043{
2038 mNavigator->selectNextMonth(); 2044 mNavigator->selectNextMonth();
2039} 2045}
2040 2046
2041void CalendarView::goPreviousMonth() 2047void CalendarView::goPreviousMonth()
2042{ 2048{
2043 mNavigator->selectPreviousMonth(); 2049 mNavigator->selectPreviousMonth();
2044} 2050}
2045void CalendarView::writeLocale() 2051void CalendarView::writeLocale()
2046{ 2052{
2047 //KPimGlobalPrefs::instance()->setGlobalConfig(); 2053 //KPimGlobalPrefs::instance()->setGlobalConfig();
2048#if 0 2054#if 0
2049 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); 2055 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime );
2050 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); 2056 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday );
2051 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); 2057 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate );
2052 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); 2058 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage );
2053 QString dummy = KOPrefs::instance()->mUserDateFormatLong; 2059 QString dummy = KOPrefs::instance()->mUserDateFormatLong;
2054 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 2060 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
2055 dummy = KOPrefs::instance()->mUserDateFormatShort; 2061 dummy = KOPrefs::instance()->mUserDateFormatShort;
2056 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 2062 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
2057 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, 2063 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving,
2058 KOPrefs::instance()->mDaylightsavingStart, 2064 KOPrefs::instance()->mDaylightsavingStart,
2059 KOPrefs::instance()->mDaylightsavingEnd ); 2065 KOPrefs::instance()->mDaylightsavingEnd );
2060 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); 2066 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId );
2061#endif 2067#endif
2062} 2068}
2063void CalendarView::updateConfig() 2069void CalendarView::updateConfig()
2064{ 2070{
2065 writeLocale(); 2071 writeLocale();
2066 if ( KOPrefs::instance()->mUseAppColors ) 2072 if ( KOPrefs::instance()->mUseAppColors )
2067 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 2073 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
2068 emit configChanged(); 2074 emit configChanged();
2069 mTodoList->updateConfig(); 2075 mTodoList->updateConfig();
2070 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 2076 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
2071 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2077 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2072 // To make the "fill window" configurations work 2078 // To make the "fill window" configurations work
2073 //mViewManager->raiseCurrentView(); 2079 //mViewManager->raiseCurrentView();
2074} 2080}
2075 2081
2076 2082
2077void CalendarView::eventChanged(Event *event) 2083void CalendarView::eventChanged(Event *event)
2078{ 2084{
2079 changeEventDisplay(event,KOGlobals::EVENTEDITED); 2085 changeEventDisplay(event,KOGlobals::EVENTEDITED);
2080 //updateUnmanagedViews(); 2086 //updateUnmanagedViews();
2081} 2087}
2082 2088
2083void CalendarView::eventAdded(Event *event) 2089void CalendarView::eventAdded(Event *event)
2084{ 2090{
2085 changeEventDisplay(event,KOGlobals::EVENTADDED); 2091 changeEventDisplay(event,KOGlobals::EVENTADDED);
2086} 2092}
2087 2093
2088void CalendarView::eventToBeDeleted(Event *) 2094void CalendarView::eventToBeDeleted(Event *)
2089{ 2095{
2090 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 2096 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
2091} 2097}
2092 2098
2093void CalendarView::eventDeleted() 2099void CalendarView::eventDeleted()
2094{ 2100{
2095 changeEventDisplay(0,KOGlobals::EVENTDELETED); 2101 changeEventDisplay(0,KOGlobals::EVENTDELETED);
2096} 2102}
2097void CalendarView::changeTodoDisplay(Todo *which, int action) 2103void CalendarView::changeTodoDisplay(Todo *which, int action)
2098{ 2104{
2099 changeIncidenceDisplay((Incidence *)which, action); 2105 changeIncidenceDisplay((Incidence *)which, action);
2100 mDateNavigator->updateView(); //LR 2106 mDateNavigator->updateView(); //LR
2101 //mDialogManager->updateSearchDialog(); 2107 //mDialogManager->updateSearchDialog();
2102 2108
2103 if (which) { 2109 if (which) {
2104 mViewManager->updateWNview(); 2110 mViewManager->updateWNview();
2105 //mTodoList->updateView(); 2111 //mTodoList->updateView();
2106 } 2112 }
2107 2113
2108} 2114}
2109 2115
2110void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 2116void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
2111{ 2117{
2112 updateUnmanagedViews(); 2118 updateUnmanagedViews();
2113 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 2119 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
2114 if ( action == KOGlobals::EVENTDELETED ) { //delete 2120 if ( action == KOGlobals::EVENTDELETED ) { //delete
2115 mCalendar->checkAlarmForIncidence( 0, true ); 2121 mCalendar->checkAlarmForIncidence( 0, true );
2116 if ( mEventViewerDialog ) 2122 if ( mEventViewerDialog )
2117 mEventViewerDialog->hide(); 2123 mEventViewerDialog->hide();
2118 } 2124 }
2119 else 2125 else
2120 mCalendar->checkAlarmForIncidence( which , false ); 2126 mCalendar->checkAlarmForIncidence( which , false );
2121} 2127}
2122 2128
2123// most of the changeEventDisplays() right now just call the view's 2129// most of the changeEventDisplays() right now just call the view's
2124// total update mode, but they SHOULD be recoded to be more refresh-efficient. 2130// total update mode, but they SHOULD be recoded to be more refresh-efficient.
2125void CalendarView::changeEventDisplay(Event *which, int action) 2131void CalendarView::changeEventDisplay(Event *which, int action)
2126{ 2132{
2127 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 2133 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
2128 changeIncidenceDisplay((Incidence *)which, action); 2134 changeIncidenceDisplay((Incidence *)which, action);
2129 mDateNavigator->updateView(); 2135 mDateNavigator->updateView();
2130 //mDialogManager->updateSearchDialog(); 2136 //mDialogManager->updateSearchDialog();
2131 2137
2132 if (which) { 2138 if (which) {
2133 // If there is an event view visible update the display 2139 // If there is an event view visible update the display
2134 mViewManager->currentView()->changeEventDisplay(which,action); 2140 mViewManager->currentView()->changeEventDisplay(which,action);
2135 // TODO: check, if update needed 2141 // TODO: check, if update needed
2136 // if (which->getTodoStatus()) { 2142 // if (which->getTodoStatus()) {
2137 mTodoList->updateView(); 2143 mTodoList->updateView();
2138 // } 2144 // }
2139 } else { 2145 } else {
2140 mViewManager->currentView()->updateView(); 2146 mViewManager->currentView()->updateView();
2141 } 2147 }
2142} 2148}
2143 2149
2144 2150
2145void CalendarView::updateTodoViews() 2151void CalendarView::updateTodoViews()
2146{ 2152{
2147 2153
2148 mTodoList->updateView(); 2154 mTodoList->updateView();
2149 mViewManager->currentView()->updateView(); 2155 mViewManager->currentView()->updateView();
2150 2156
2151} 2157}
2152 2158
2153 2159
2154void CalendarView::updateView(const QDate &start, const QDate &end) 2160void CalendarView::updateView(const QDate &start, const QDate &end)
2155{ 2161{
2156 mTodoList->updateView(); 2162 mTodoList->updateView();
2157 mViewManager->updateView(start, end); 2163 mViewManager->updateView(start, end);
2158 //mDateNavigator->updateView(); 2164 //mDateNavigator->updateView();
2159} 2165}
2160 2166
2161void CalendarView::updateView() 2167void CalendarView::updateView()
2162{ 2168{
2163 DateList tmpList = mNavigator->selectedDates(); 2169 DateList tmpList = mNavigator->selectedDates();
2164 2170
2165 // We assume that the navigator only selects consecutive days. 2171 // We assume that the navigator only selects consecutive days.
2166 updateView( tmpList.first(), tmpList.last() ); 2172 updateView( tmpList.first(), tmpList.last() );
2167 if ( KOPrefs::instance()->mHideNonStartedTodos ) 2173 if ( KOPrefs::instance()->mHideNonStartedTodos )
2168 mTodoList->updateView(); 2174 mTodoList->updateView();
2169} 2175}
2170 2176
2171void CalendarView::updateUnmanagedViews() 2177void CalendarView::updateUnmanagedViews()
2172{ 2178{
2173 mDateNavigator->updateDayMatrix(); 2179 mDateNavigator->updateDayMatrix();
2174} 2180}
2175 2181
2176int CalendarView::msgItemDelete() 2182int CalendarView::msgItemDelete()
2177{ 2183{
2178 return KMessageBox::warningContinueCancel(this, 2184 return KMessageBox::warningContinueCancel(this,
2179 i18n("This item will be\npermanently deleted."), 2185 i18n("This item will be\npermanently deleted."),
2180 i18n("KO/Pi Confirmation"),i18n("Delete")); 2186 i18n("KO/Pi Confirmation"),i18n("Delete"));
2181} 2187}
2182 2188
2183 2189
2184void CalendarView::edit_cut() 2190void CalendarView::edit_cut()
2185{ 2191{
2186 Event *anEvent=0; 2192 Event *anEvent=0;
2187 2193
2188 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2194 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2189 2195
2190 if (mViewManager->currentView()->isEventView()) { 2196 if (mViewManager->currentView()->isEventView()) {
2191 if ( incidence && incidence->type() == "Event" ) { 2197 if ( incidence && incidence->type() == "Event" ) {
2192 anEvent = static_cast<Event *>(incidence); 2198 anEvent = static_cast<Event *>(incidence);
2193 } 2199 }
2194 } 2200 }
2195 2201
2196 if (!anEvent) { 2202 if (!anEvent) {
2197 KNotifyClient::beep(); 2203 KNotifyClient::beep();
2198 return; 2204 return;
2199 } 2205 }
2200 DndFactory factory( mCalendar ); 2206 DndFactory factory( mCalendar );
2201 factory.cutEvent(anEvent); 2207 factory.cutEvent(anEvent);
2202 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2208 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2203} 2209}
2204 2210
2205void CalendarView::edit_copy() 2211void CalendarView::edit_copy()
2206{ 2212{
2207 Event *anEvent=0; 2213 Event *anEvent=0;
2208 2214
2209 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2215 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2210 2216
2211 if (mViewManager->currentView()->isEventView()) { 2217 if (mViewManager->currentView()->isEventView()) {
2212 if ( incidence && incidence->type() == "Event" ) { 2218 if ( incidence && incidence->type() == "Event" ) {
2213 anEvent = static_cast<Event *>(incidence); 2219 anEvent = static_cast<Event *>(incidence);
2214 } 2220 }
2215 } 2221 }
2216 2222
2217 if (!anEvent) { 2223 if (!anEvent) {
2218 KNotifyClient::beep(); 2224 KNotifyClient::beep();
2219 return; 2225 return;
2220 } 2226 }
2221 DndFactory factory( mCalendar ); 2227 DndFactory factory( mCalendar );
2222 factory.copyEvent(anEvent); 2228 factory.copyEvent(anEvent);
2223} 2229}
2224 2230
2225void CalendarView::edit_paste() 2231void CalendarView::edit_paste()
2226{ 2232{
2227 QDate date = mNavigator->selectedDates().first(); 2233 QDate date = mNavigator->selectedDates().first();
2228 2234
2229 DndFactory factory( mCalendar ); 2235 DndFactory factory( mCalendar );
2230 Event *pastedEvent = factory.pasteEvent( date ); 2236 Event *pastedEvent = factory.pasteEvent( date );
2231 2237
2232 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 2238 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
2233} 2239}
2234 2240
2235void CalendarView::edit_options() 2241void CalendarView::edit_options()
2236{ 2242{
2237 mDialogManager->showOptionsDialog(); 2243 mDialogManager->showOptionsDialog();
2238 //writeSettings(); 2244 //writeSettings();
2239} 2245}
2240 2246
2241 2247
2242void CalendarView::slotSelectPickerDate( QDate d) 2248void CalendarView::slotSelectPickerDate( QDate d)
2243{ 2249{
2244 mDateFrame->hide(); 2250 mDateFrame->hide();
2245 if ( mDatePickerMode == 1 ) { 2251 if ( mDatePickerMode == 1 ) {
2246 mNavigator->slotDaySelect( d ); 2252 mNavigator->slotDaySelect( d );
2247 } else if ( mDatePickerMode == 2 ) { 2253 } else if ( mDatePickerMode == 2 ) {
2248 if ( mMoveIncidence->type() == "Todo" ) { 2254 if ( mMoveIncidence->type() == "Todo" ) {
2249 Todo * to = (Todo *) mMoveIncidence; 2255 Todo * to = (Todo *) mMoveIncidence;
2250 QTime tim; 2256 QTime tim;
2251 if ( to->hasDueDate() ) 2257 if ( to->hasDueDate() )
2252 tim = to->dtDue().time(); 2258 tim = to->dtDue().time();
2253 else { 2259 else {
2254 tim = QTime ( 0,0,0 ); 2260 tim = QTime ( 0,0,0 );
2255 to->setFloats( true ); 2261 to->setFloats( true );
2256 to->setHasDueDate( true ); 2262 to->setHasDueDate( true );
2257 } 2263 }
2258 QDateTime dt ( d,tim ); 2264 QDateTime dt ( d,tim );
2259 to->setDtDue( dt ); 2265 to->setDtDue( dt );
2260 todoChanged( to ); 2266 todoChanged( to );
2261 } else { 2267 } else {
2262 if ( mMoveIncidence->doesRecur() ) { 2268 if ( mMoveIncidence->doesRecur() ) {
2263#if 0 2269#if 0
2264 // PENDING implement this 2270 // PENDING implement this
2265 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); 2271 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate );
2266 mCalendar()->addIncidence( newInc ); 2272 mCalendar()->addIncidence( newInc );
2267 if ( mMoveIncidence->type() == "Todo" ) 2273 if ( mMoveIncidence->type() == "Todo" )
2268 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); 2274 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED );
2269 else 2275 else
2270 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); 2276 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED);
2271 mMoveIncidence = newInc; 2277 mMoveIncidence = newInc;
2272 2278
2273#endif 2279#endif
2274 } 2280 }
2275 QTime tim = mMoveIncidence->dtStart().time(); 2281 QTime tim = mMoveIncidence->dtStart().time();
2276 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2282 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2277 QDateTime dt ( d,tim ); 2283 QDateTime dt ( d,tim );
2278 mMoveIncidence->setDtStart( dt ); 2284 mMoveIncidence->setDtStart( dt );
2279 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2285 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2280 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2286 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2281 } 2287 }
2282 2288
2283 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2289 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2284 } 2290 }
2285} 2291}
2286 2292
2287void CalendarView::removeCategories() 2293void CalendarView::removeCategories()
2288{ 2294{
2289 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2295 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2290 QStringList catList = KOPrefs::instance()->mCustomCategories; 2296 QStringList catList = KOPrefs::instance()->mCustomCategories;
2291 QStringList catIncList; 2297 QStringList catIncList;
2292 QStringList newCatList; 2298 QStringList newCatList;
2293 Incidence* inc = incList.first(); 2299 Incidence* inc = incList.first();
2294 int i; 2300 int i;
2295 int count = 0; 2301 int count = 0;
2296 while ( inc ) { 2302 while ( inc ) {
2297 newCatList.clear(); 2303 newCatList.clear();
2298 catIncList = inc->categories() ; 2304 catIncList = inc->categories() ;
2299 for( i = 0; i< catIncList.count(); ++i ) { 2305 for( i = 0; i< catIncList.count(); ++i ) {
2300 if ( catList.contains (catIncList[i])) 2306 if ( catList.contains (catIncList[i]))
2301 newCatList.append( catIncList[i] ); 2307 newCatList.append( catIncList[i] );
2302 } 2308 }
2303 newCatList.sort(); 2309 newCatList.sort();
2304 inc->setCategories( newCatList.join(",") ); 2310 inc->setCategories( newCatList.join(",") );
2305 inc = incList.next(); 2311 inc = incList.next();
2306 } 2312 }
2307} 2313}
2308 2314
2309int CalendarView::addCategories() 2315int CalendarView::addCategories()
2310{ 2316{
2311 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2317 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2312 QStringList catList = KOPrefs::instance()->mCustomCategories; 2318 QStringList catList = KOPrefs::instance()->mCustomCategories;
2313 QStringList catIncList; 2319 QStringList catIncList;
2314 Incidence* inc = incList.first(); 2320 Incidence* inc = incList.first();
2315 int i; 2321 int i;
2316 int count = 0; 2322 int count = 0;
2317 while ( inc ) { 2323 while ( inc ) {
2318 catIncList = inc->categories() ; 2324 catIncList = inc->categories() ;
2319 for( i = 0; i< catIncList.count(); ++i ) { 2325 for( i = 0; i< catIncList.count(); ++i ) {
2320 if ( !catList.contains (catIncList[i])) { 2326 if ( !catList.contains (catIncList[i])) {
2321 catList.append( catIncList[i] ); 2327 catList.append( catIncList[i] );
2322 //qDebug("add cat %s ", catIncList[i].latin1()); 2328 //qDebug("add cat %s ", catIncList[i].latin1());
2323 ++count; 2329 ++count;
2324 } 2330 }
2325 } 2331 }
2326 inc = incList.next(); 2332 inc = incList.next();
2327 } 2333 }
2328 catList.sort(); 2334 catList.sort();
2329 KOPrefs::instance()->mCustomCategories = catList; 2335 KOPrefs::instance()->mCustomCategories = catList;
2330 return count; 2336 return count;
2331} 2337}
2332 2338
2333void CalendarView::manageCategories() 2339void CalendarView::manageCategories()
2334{ 2340{
2335 KOCatPrefs* cp = new KOCatPrefs(); 2341 KOCatPrefs* cp = new KOCatPrefs();
2336 cp->show(); 2342 cp->show();
2337 int w =cp->sizeHint().width() ; 2343 int w =cp->sizeHint().width() ;
2338 int h = cp->sizeHint().height() ; 2344 int h = cp->sizeHint().height() ;
2339 int dw = QApplication::desktop()->width(); 2345 int dw = QApplication::desktop()->width();
2340 int dh = QApplication::desktop()->height(); 2346 int dh = QApplication::desktop()->height();
2341 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2347 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2342 if ( !cp->exec() ) { 2348 if ( !cp->exec() ) {
2343 delete cp; 2349 delete cp;
2344 return; 2350 return;
2345 } 2351 }
2346 int count = 0; 2352 int count = 0;
2347 if ( cp->addCat() ) { 2353 if ( cp->addCat() ) {
2348 count = addCategories(); 2354 count = addCategories();
2349 if ( count ) { 2355 if ( count ) {
2350 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2356 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2351 writeSettings(); 2357 writeSettings();
2352 } else 2358 } else
2353 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); 2359 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! "));
2354 } else { 2360 } else {
2355 removeCategories(); 2361 removeCategories();
2356 updateView(); 2362 updateView();
2357 } 2363 }
2358 delete cp; 2364 delete cp;
2359} 2365}
2360 2366
2361void CalendarView::beamIncidence(Incidence * Inc) 2367void CalendarView::beamIncidence(Incidence * Inc)
2362{ 2368{
2363 QPtrList<Incidence> delSel ; 2369 QPtrList<Incidence> delSel ;
2364 delSel.append(Inc); 2370 delSel.append(Inc);
2365 beamIncidenceList( delSel ); 2371 beamIncidenceList( delSel );
2366} 2372}
2367void CalendarView::beamCalendar() 2373void CalendarView::beamCalendar()
2368{ 2374{
2369 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2375 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2370 //qDebug("beamCalendar() "); 2376 //qDebug("beamCalendar() ");
2371 beamIncidenceList( delSel ); 2377 beamIncidenceList( delSel );
2372} 2378}
2373void CalendarView::beamFilteredCalendar() 2379void CalendarView::beamFilteredCalendar()
2374{ 2380{
2375 QPtrList<Incidence> delSel = mCalendar->incidences(); 2381 QPtrList<Incidence> delSel = mCalendar->incidences();
2376 //qDebug("beamFilteredCalendar() "); 2382 //qDebug("beamFilteredCalendar() ");
2377 beamIncidenceList( delSel ); 2383 beamIncidenceList( delSel );
2378} 2384}
2379void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2385void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2380{ 2386{
2381 if ( beamDialog->exec () == QDialog::Rejected ) 2387 if ( beamDialog->exec () == QDialog::Rejected )
2382 return; 2388 return;
2383#ifdef DESKTOP_VERSION 2389#ifdef DESKTOP_VERSION
2384 QString fn = locateLocal( "tmp", "kopibeamfile" ); 2390 QString fn = locateLocal( "tmp", "kopibeamfile" );
2385#else 2391#else
2386 QString fn = "/tmp/kopibeamfile"; 2392 QString fn = "/tmp/kopibeamfile";
2387#endif 2393#endif
2388 QString mes; 2394 QString mes;
2389 bool createbup = true; 2395 bool createbup = true;
2390 if ( createbup ) { 2396 if ( createbup ) {
2391 QString description = "\n"; 2397 QString description = "\n";
2392 CalendarLocal* cal = new CalendarLocal(); 2398 CalendarLocal* cal = new CalendarLocal();
2393 if ( beamDialog->beamLocal() ) 2399 if ( beamDialog->beamLocal() )
2394 cal->setLocalTime(); 2400 cal->setLocalTime();
2395 else 2401 else
2396 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2402 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2397 Incidence *incidence = delSel.first(); 2403 Incidence *incidence = delSel.first();
2398 bool addText = false; 2404 bool addText = false;
2399 if ( delSel.count() < 10 ) 2405 if ( delSel.count() < 10 )
2400 addText = true; 2406 addText = true;
2401 else { 2407 else {
2402 description.sprintf(i18n(" %d items?"),delSel.count() ); 2408 description.sprintf(i18n(" %d items?"),delSel.count() );
2403 } 2409 }
2404 while ( incidence ) { 2410 while ( incidence ) {
2405 Incidence *in = incidence->clone(); 2411 Incidence *in = incidence->clone();
2406 if ( ! in->summary().isEmpty() ) { 2412 if ( ! in->summary().isEmpty() ) {
2407 in->setDescription(""); 2413 in->setDescription("");
2408 } else { 2414 } else {
2409 in->setSummary( in->description().left(20)); 2415 in->setSummary( in->description().left(20));
2410 in->setDescription(""); 2416 in->setDescription("");
2411 } 2417 }
2412 if ( addText ) 2418 if ( addText )
2413 description += in->summary() + "\n"; 2419 description += in->summary() + "\n";
2414 cal->addIncidence( in ); 2420 cal->addIncidence( in );
2415 incidence = delSel.next(); 2421 incidence = delSel.next();
2416 } 2422 }
2417 if ( beamDialog->beamVcal() ) { 2423 if ( beamDialog->beamVcal() ) {
2418 fn += ".vcs"; 2424 fn += ".vcs";
2419 FileStorage storage( cal, fn, new VCalFormat ); 2425 FileStorage storage( cal, fn, new VCalFormat );
2420 storage.save(); 2426 storage.save();
2421 } else { 2427 } else {
2422 fn += ".ics"; 2428 fn += ".ics";
2423 FileStorage storage( cal, fn, new ICalFormat( ) ); 2429 FileStorage storage( cal, fn, new ICalFormat( ) );
2424 storage.save(); 2430 storage.save();
2425 } 2431 }
2426 delete cal; 2432 delete cal;
2427 mes = i18n("KO/Pi: Ready for beaming"); 2433 mes = i18n("KO/Pi: Ready for beaming");
2428 topLevelWidget()->setCaption(mes); 2434 topLevelWidget()->setCaption(mes);
2429 KApplication::convert2latin1( fn ); 2435 KApplication::convert2latin1( fn );
2430#ifndef DESKTOP_VERSION 2436#ifndef DESKTOP_VERSION
2431 Ir *ir = new Ir( this ); 2437 Ir *ir = new Ir( this );
2432 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 2438 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2433 ir->send( fn, description, "text/x-vCalendar" ); 2439 ir->send( fn, description, "text/x-vCalendar" );
2434#endif 2440#endif
2435 } 2441 }
2436} 2442}
2437void CalendarView::beamDone( Ir *ir ) 2443void CalendarView::beamDone( Ir *ir )
2438{ 2444{
2439#ifndef DESKTOP_VERSION 2445#ifndef DESKTOP_VERSION
2440 delete ir; 2446 delete ir;
2441#endif 2447#endif
2442 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); 2448 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") );
2443 topLevelWidget()->raise(); 2449 topLevelWidget()->raise();
2444} 2450}
2445 2451
2446void CalendarView::moveIncidence(Incidence * inc ) 2452void CalendarView::moveIncidence(Incidence * inc )
2447{ 2453{
2448 if ( !inc ) return; 2454 if ( !inc ) return;
2449 // qDebug("showDatePickerForIncidence( ) "); 2455 // qDebug("showDatePickerForIncidence( ) ");
2450 if ( mDateFrame->isVisible() ) 2456 if ( mDateFrame->isVisible() )
2451 mDateFrame->hide(); 2457 mDateFrame->hide();
2452 else { 2458 else {
2453 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; 2459 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ;
2454 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; 2460 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ;
2455 int dw = QApplication::desktop()->width(); 2461 int dw = QApplication::desktop()->width();
2456 int dh = QApplication::desktop()->height(); 2462 int dh = QApplication::desktop()->height();
2457 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2463 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2458 mDateFrame->show(); 2464 mDateFrame->show();
2459 } 2465 }
2460 mDatePickerMode = 2; 2466 mDatePickerMode = 2;
2461 mMoveIncidence = inc ; 2467 mMoveIncidence = inc ;
2462 QDate da; 2468 QDate da;
2463 if ( mMoveIncidence->type() == "Todo" ) { 2469 if ( mMoveIncidence->type() == "Todo" ) {
2464 Todo * to = (Todo *) mMoveIncidence; 2470 Todo * to = (Todo *) mMoveIncidence;
2465 if ( to->hasDueDate() ) 2471 if ( to->hasDueDate() )
2466 da = to->dtDue().date(); 2472 da = to->dtDue().date();
2467 else 2473 else
2468 da = QDate::currentDate(); 2474 da = QDate::currentDate();
2469 } else { 2475 } else {
2470 da = mMoveIncidence->dtStart().date(); 2476 da = mMoveIncidence->dtStart().date();
2471 } 2477 }
2472 //PENDING set date for recurring incidence to date of recurrence 2478 //PENDING set date for recurring incidence to date of recurrence
2473 //mMoveIncidenceOldDate; 2479 //mMoveIncidenceOldDate;
2474 mDatePicker->setDate( da ); 2480 mDatePicker->setDate( da );
2475} 2481}
2476void CalendarView::showDatePicker( ) 2482void CalendarView::showDatePicker( )
2477{ 2483{
2478 //qDebug("CalendarView::showDatePicker( ) "); 2484 //qDebug("CalendarView::showDatePicker( ) ");
2479 if ( mDateFrame->isVisible() ) 2485 if ( mDateFrame->isVisible() )
2480 mDateFrame->hide(); 2486 mDateFrame->hide();
2481 else { 2487 else {
2482 int w =mDatePicker->sizeHint().width() ; 2488 int w =mDatePicker->sizeHint().width() ;
2483 int h = mDatePicker->sizeHint().height() ; 2489 int h = mDatePicker->sizeHint().height() ;
2484 int dw = QApplication::desktop()->width(); 2490 int dw = QApplication::desktop()->width();
2485 int dh = QApplication::desktop()->height(); 2491 int dh = QApplication::desktop()->height();
2486 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2492 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2487 mDateFrame->show(); 2493 mDateFrame->show();
2488 } 2494 }
2489 mDatePickerMode = 1; 2495 mDatePickerMode = 1;
2490 mDatePicker->setDate( mNavigator->selectedDates().first() ); 2496 mDatePicker->setDate( mNavigator->selectedDates().first() );
2491} 2497}
2492 2498
2493void CalendarView::showEventEditor() 2499void CalendarView::showEventEditor()
2494{ 2500{
2495#ifdef DESKTOP_VERSION 2501#ifdef DESKTOP_VERSION
2496 mEventEditor->show(); 2502 mEventEditor->show();
2497#else 2503#else
2498 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { 2504 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) {
2499 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2505 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2500 qDebug("CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); 2506 qDebug("CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() );
2501 delete mEventEditor; 2507 delete mEventEditor;
2502 mEventEditor = mDialogManager->getEventEditor(); 2508 mEventEditor = mDialogManager->getEventEditor();
2503 } 2509 }
2504 mEventEditor->showMaximized(); 2510 mEventEditor->showMaximized();
2505#endif 2511#endif
2506} 2512}
2507void CalendarView::showTodoEditor() 2513void CalendarView::showTodoEditor()
2508{ 2514{
2509#ifdef DESKTOP_VERSION 2515#ifdef DESKTOP_VERSION
2510 mTodoEditor->show(); 2516 mTodoEditor->show();
2511#else 2517#else
2512 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { 2518 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) {
2513 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2519 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2514 qDebug("CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); 2520 qDebug("CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() );
2515 delete mTodoEditor; 2521 delete mTodoEditor;
2516 mTodoEditor = mDialogManager->getTodoEditor(); 2522 mTodoEditor = mDialogManager->getTodoEditor();
2517 } 2523 }
2518 mTodoEditor->showMaximized(); 2524 mTodoEditor->showMaximized();
2519#endif 2525#endif
2520} 2526}
2521 2527
2522void CalendarView::cloneIncidence() 2528void CalendarView::cloneIncidence()
2523{ 2529{
2524 Incidence *incidence = currentSelection(); 2530 Incidence *incidence = currentSelection();
2525 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2531 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2526 if ( incidence ) { 2532 if ( incidence ) {
2527 cloneIncidence(incidence); 2533 cloneIncidence(incidence);
2528 } 2534 }
2529} 2535}
2530void CalendarView::moveIncidence() 2536void CalendarView::moveIncidence()
2531{ 2537{
2532 Incidence *incidence = currentSelection(); 2538 Incidence *incidence = currentSelection();
2533 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2539 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2534 if ( incidence ) { 2540 if ( incidence ) {
2535 moveIncidence(incidence); 2541 moveIncidence(incidence);
2536 } 2542 }
2537} 2543}
2538void CalendarView::beamIncidence() 2544void CalendarView::beamIncidence()
2539{ 2545{
2540 Incidence *incidence = currentSelection(); 2546 Incidence *incidence = currentSelection();
2541 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2547 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2542 if ( incidence ) { 2548 if ( incidence ) {
2543 beamIncidence(incidence); 2549 beamIncidence(incidence);
2544 } 2550 }
2545} 2551}
2546void CalendarView::toggleCancelIncidence() 2552void CalendarView::toggleCancelIncidence()
2547{ 2553{
2548 Incidence *incidence = currentSelection(); 2554 Incidence *incidence = currentSelection();
2549 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2555 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2550 if ( incidence ) { 2556 if ( incidence ) {
2551 cancelIncidence(incidence); 2557 cancelIncidence(incidence);
2552 } 2558 }
2553} 2559}
2554 2560
2555 2561
2556void CalendarView::cancelIncidence(Incidence * inc ) 2562void CalendarView::cancelIncidence(Incidence * inc )
2557{ 2563{
2558 inc->setCancelled( ! inc->cancelled() ); 2564 inc->setCancelled( ! inc->cancelled() );
2559 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 2565 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
2560 updateView(); 2566 updateView();
2561} 2567}
2562void CalendarView::cloneIncidence(Incidence * orgInc ) 2568void CalendarView::cloneIncidence(Incidence * orgInc )
2563{ 2569{
2564 Incidence * newInc = orgInc->clone(); 2570 Incidence * newInc = orgInc->clone();
2565 newInc->recreate(); 2571 newInc->recreate();
2566 2572
2567 if ( newInc->type() == "Todo" ) { 2573 if ( newInc->type() == "Todo" ) {
2568 Todo* t = (Todo*) newInc; 2574 Todo* t = (Todo*) newInc;
2569 showTodoEditor(); 2575 showTodoEditor();
2570 mTodoEditor->editTodo( t ); 2576 mTodoEditor->editTodo( t );
2571 if ( mTodoEditor->exec() ) { 2577 if ( mTodoEditor->exec() ) {
2572 mCalendar->addTodo( t ); 2578 mCalendar->addTodo( t );
2573 updateView(); 2579 updateView();
2574 } else { 2580 } else {
2575 delete t; 2581 delete t;
2576 } 2582 }
2577 } 2583 }
2578 else { 2584 else {
2579 Event* e = (Event*) newInc; 2585 Event* e = (Event*) newInc;
2580 showEventEditor(); 2586 showEventEditor();
2581 mEventEditor->editEvent( e ); 2587 mEventEditor->editEvent( e );
2582 if ( mEventEditor->exec() ) { 2588 if ( mEventEditor->exec() ) {
2583 mCalendar->addEvent( e ); 2589 mCalendar->addEvent( e );
2584 updateView(); 2590 updateView();
2585 } else { 2591 } else {
2586 delete e; 2592 delete e;
2587 } 2593 }
2588 } 2594 }
2589} 2595}
2590 2596
2591void CalendarView::newEvent() 2597void CalendarView::newEvent()
2592{ 2598{
2593 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 2599 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
2594 KOAgendaView *aView = mViewManager->agendaView(); 2600 KOAgendaView *aView = mViewManager->agendaView();
2595 if (aView) { 2601 if (aView) {
2596 if (aView->selectionStart().isValid()) { 2602 if (aView->selectionStart().isValid()) {
2597 if (aView->selectedIsAllDay()) { 2603 if (aView->selectedIsAllDay()) {
2598 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 2604 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
2599 } else { 2605 } else {
2600 newEvent(aView->selectionStart(),aView->selectionEnd()); 2606 newEvent(aView->selectionStart(),aView->selectionEnd());
2601 } 2607 }
2602 return; 2608 return;
2603 } 2609 }
2604 } 2610 }
2605 2611
2606 QDate date = mNavigator->selectedDates().first(); 2612 QDate date = mNavigator->selectedDates().first();
2607 QDateTime current = QDateTime::currentDateTime(); 2613 QDateTime current = QDateTime::currentDateTime();
2608 if ( date <= current.date() ) { 2614 if ( date <= current.date() ) {
2609 int hour = current.time().hour() +1; 2615 int hour = current.time().hour() +1;
2610 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 2616 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
2611 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2617 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2612 } else 2618 } else
2613 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 2619 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
2614 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 2620 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
2615 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2621 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2616} 2622}
2617 2623
2618void CalendarView::newEvent(QDateTime fh) 2624void CalendarView::newEvent(QDateTime fh)
2619{ 2625{
2620 newEvent(fh, 2626 newEvent(fh,
2621 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 2627 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
2622} 2628}
2623 2629
2624void CalendarView::newEvent(QDate dt) 2630void CalendarView::newEvent(QDate dt)
2625{ 2631{
2626 newEvent(QDateTime(dt, QTime(0,0,0)), 2632 newEvent(QDateTime(dt, QTime(0,0,0)),
2627 QDateTime(dt, QTime(0,0,0)), true); 2633 QDateTime(dt, QTime(0,0,0)), true);
2628} 2634}
2629 2635
2630void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 2636void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
2631{ 2637{
2632 2638
2633 showEventEditor(); 2639 showEventEditor();
2634 mEventEditor->newEvent(fromHint,toHint,allDay); 2640 mEventEditor->newEvent(fromHint,toHint,allDay);
2635 if ( mFilterView->filtersEnabled() ) { 2641 if ( mFilterView->filtersEnabled() ) {
2636 CalFilter *filter = mFilterView->selectedFilter(); 2642 CalFilter *filter = mFilterView->selectedFilter();
2637 if (filter && filter->showCategories()) { 2643 if (filter && filter->showCategories()) {
2638 mEventEditor->setCategories(filter->categoryList().join(",") ); 2644 mEventEditor->setCategories(filter->categoryList().join(",") );
2639 } 2645 }
2640 if ( filter ) 2646 if ( filter )
2641 mEventEditor->setSecrecy( filter->getSecrecy() ); 2647 mEventEditor->setSecrecy( filter->getSecrecy() );
2642 } 2648 }
2643} 2649}
2644void CalendarView::todoAdded(Todo * t) 2650void CalendarView::todoAdded(Todo * t)
2645{ 2651{
2646 2652
2647 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 2653 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
2648 updateTodoViews(); 2654 updateTodoViews();
2649} 2655}
2650void CalendarView::todoChanged(Todo * t) 2656void CalendarView::todoChanged(Todo * t)
2651{ 2657{
2652 emit todoModified( t, 4 ); 2658 emit todoModified( t, 4 );
2653 // updateTodoViews(); 2659 // updateTodoViews();
2654} 2660}
2655void CalendarView::todoToBeDeleted(Todo *) 2661void CalendarView::todoToBeDeleted(Todo *)
2656{ 2662{
2657 //qDebug("todoToBeDeleted(Todo *) "); 2663 //qDebug("todoToBeDeleted(Todo *) ");
2658 updateTodoViews(); 2664 updateTodoViews();
2659} 2665}
2660void CalendarView::todoDeleted() 2666void CalendarView::todoDeleted()
2661{ 2667{
2662 //qDebug(" todoDeleted()"); 2668 //qDebug(" todoDeleted()");
2663 updateTodoViews(); 2669 updateTodoViews();
2664} 2670}
2665 2671
2666 2672
2667 2673
2668void CalendarView::newTodo() 2674void CalendarView::newTodo()
2669{ 2675{
2670 2676
2671 showTodoEditor(); 2677 showTodoEditor();
2672 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); 2678 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true);
2673 if ( mFilterView->filtersEnabled() ) { 2679 if ( mFilterView->filtersEnabled() ) {
2674 CalFilter *filter = mFilterView->selectedFilter(); 2680 CalFilter *filter = mFilterView->selectedFilter();
2675 if (filter && filter->showCategories()) { 2681 if (filter && filter->showCategories()) {
2676 mTodoEditor->setCategories(filter->categoryList().join(",") ); 2682 mTodoEditor->setCategories(filter->categoryList().join(",") );
2677 } 2683 }
2678 if ( filter ) 2684 if ( filter )
2679 mTodoEditor->setSecrecy( filter->getSecrecy() ); 2685 mTodoEditor->setSecrecy( filter->getSecrecy() );
2680 } 2686 }
2681} 2687}
2682 2688
2683void CalendarView::newSubTodo() 2689void CalendarView::newSubTodo()
2684{ 2690{
2685 Todo *todo = selectedTodo(); 2691 Todo *todo = selectedTodo();
2686 if ( todo ) newSubTodo( todo ); 2692 if ( todo ) newSubTodo( todo );
2687} 2693}
2688 2694
2689void CalendarView::newSubTodo(Todo *parentEvent) 2695void CalendarView::newSubTodo(Todo *parentEvent)
2690{ 2696{
2691 2697
2692 showTodoEditor(); 2698 showTodoEditor();
2693 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); 2699 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true);
2694} 2700}
2695 2701
2696void CalendarView::newFloatingEvent() 2702void CalendarView::newFloatingEvent()
2697{ 2703{
2698 DateList tmpList = mNavigator->selectedDates(); 2704 DateList tmpList = mNavigator->selectedDates();
2699 QDate date = tmpList.first(); 2705 QDate date = tmpList.first();
2700 2706
2701 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 2707 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
2702 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 2708 QDateTime( date, QTime( 12, 0, 0 ) ), true );
2703} 2709}
2704 2710
2705 2711
2706void CalendarView::editEvent( Event *event ) 2712void CalendarView::editEvent( Event *event )
2707{ 2713{
2708 2714
2709 if ( !event ) return; 2715 if ( !event ) return;
2710 if ( event->isReadOnly() ) { 2716 if ( event->isReadOnly() ) {
2711 showEvent( event ); 2717 showEvent( event );
2712 return; 2718 return;
2713 } 2719 }
2714 showEventEditor(); 2720 showEventEditor();
2715 mEventEditor->editEvent( event , mFlagEditDescription); 2721 mEventEditor->editEvent( event , mFlagEditDescription);
2716} 2722}
2717void CalendarView::editJournal( Journal *jour ) 2723void CalendarView::editJournal( Journal *jour )
2718{ 2724{
2719 if ( !jour ) return; 2725 if ( !jour ) return;
2720 mDialogManager->hideSearchDialog(); 2726 mDialogManager->hideSearchDialog();
2721 mViewManager->showJournalView(); 2727 mViewManager->showJournalView();
2722 mNavigator->slotDaySelect( jour->dtStart().date() ); 2728 mNavigator->slotDaySelect( jour->dtStart().date() );
2723} 2729}
2724void CalendarView::editTodo( Todo *todo ) 2730void CalendarView::editTodo( Todo *todo )
2725{ 2731{
2726 if ( !todo ) return; 2732 if ( !todo ) return;
2727 2733
2728 if ( todo->isReadOnly() ) { 2734 if ( todo->isReadOnly() ) {
2729 showTodo( todo ); 2735 showTodo( todo );
2730 return; 2736 return;
2731 } 2737 }
2732 showTodoEditor(); 2738 showTodoEditor();
2733 mTodoEditor->editTodo( todo ,mFlagEditDescription); 2739 mTodoEditor->editTodo( todo ,mFlagEditDescription);
2734 2740
2735} 2741}
2736 2742
2737KOEventViewerDialog* CalendarView::getEventViewerDialog() 2743KOEventViewerDialog* CalendarView::getEventViewerDialog()
2738{ 2744{
2739 if ( !mEventViewerDialog ) { 2745 if ( !mEventViewerDialog ) {
2740 mEventViewerDialog = new KOEventViewerDialog(this); 2746 mEventViewerDialog = new KOEventViewerDialog(this);
2741 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 2747 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
2742 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 2748 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
2743 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 2749 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
2744 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 2750 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
2745 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 2751 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
2746 viewManager(), SLOT( showAgendaView( bool ) ) ); 2752 viewManager(), SLOT( showAgendaView( bool ) ) );
2747 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), 2753 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ),
2748 this, SLOT( todoChanged(Todo *) ) ); 2754 this, SLOT( todoChanged(Todo *) ) );
2749 mEventViewerDialog->resize( 640, 480 ); 2755 mEventViewerDialog->resize( 640, 480 );
2750 2756
2751 } 2757 }
2752 return mEventViewerDialog; 2758 return mEventViewerDialog;
2753} 2759}
2754void CalendarView::showEvent(Event *event) 2760void CalendarView::showEvent(Event *event)
2755{ 2761{
2756 getEventViewerDialog()->setEvent(event); 2762 getEventViewerDialog()->setEvent(event);
2757 getEventViewerDialog()->showMe(); 2763 getEventViewerDialog()->showMe();
2758} 2764}
2759 2765
2760void CalendarView::showTodo(Todo *event) 2766void CalendarView::showTodo(Todo *event)
2761{ 2767{
2762 getEventViewerDialog()->setTodo(event); 2768 getEventViewerDialog()->setTodo(event);
2763 getEventViewerDialog()->showMe(); 2769 getEventViewerDialog()->showMe();
2764} 2770}
2765void CalendarView::showJournal( Journal *jour ) 2771void CalendarView::showJournal( Journal *jour )
2766{ 2772{
2767 getEventViewerDialog()->setJournal(jour); 2773 getEventViewerDialog()->setJournal(jour);
2768 getEventViewerDialog()->showMe(); 2774 getEventViewerDialog()->showMe();
2769 2775
2770} 2776}
2771// void CalendarView::todoModified (Todo *event, int changed) 2777// void CalendarView::todoModified (Todo *event, int changed)
2772// { 2778// {
2773// // if (mDialogList.find (event) != mDialogList.end ()) { 2779// // if (mDialogList.find (event) != mDialogList.end ()) {
2774// // kdDebug() << "Todo modified and open" << endl; 2780// // kdDebug() << "Todo modified and open" << endl;
2775// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 2781// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
2776// // temp->modified (changed); 2782// // temp->modified (changed);
2777 2783
2778// // } 2784// // }
2779 2785
2780// mViewManager->updateView(); 2786// mViewManager->updateView();
2781// } 2787// }
2782 2788
2783void CalendarView::appointment_show() 2789void CalendarView::appointment_show()
2784{ 2790{
2785 Event *anEvent = 0; 2791 Event *anEvent = 0;
2786 2792
2787 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2793 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2788 2794
2789 if (mViewManager->currentView()->isEventView()) { 2795 if (mViewManager->currentView()->isEventView()) {
2790 if ( incidence && incidence->type() == "Event" ) { 2796 if ( incidence && incidence->type() == "Event" ) {
2791 anEvent = static_cast<Event *>(incidence); 2797 anEvent = static_cast<Event *>(incidence);
2792 } 2798 }
2793 } 2799 }
2794 2800
2795 if (!anEvent) { 2801 if (!anEvent) {
2796 KNotifyClient::beep(); 2802 KNotifyClient::beep();
2797 return; 2803 return;
2798 } 2804 }
2799 2805
2800 showEvent(anEvent); 2806 showEvent(anEvent);
2801} 2807}
2802 2808
2803void CalendarView::appointment_edit() 2809void CalendarView::appointment_edit()
2804{ 2810{
2805 Event *anEvent = 0; 2811 Event *anEvent = 0;
2806 2812
2807 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2813 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2808 2814
2809 if (mViewManager->currentView()->isEventView()) { 2815 if (mViewManager->currentView()->isEventView()) {
2810 if ( incidence && incidence->type() == "Event" ) { 2816 if ( incidence && incidence->type() == "Event" ) {
2811 anEvent = static_cast<Event *>(incidence); 2817 anEvent = static_cast<Event *>(incidence);
2812 } 2818 }
2813 } 2819 }
2814 2820
2815 if (!anEvent) { 2821 if (!anEvent) {
2816 KNotifyClient::beep(); 2822 KNotifyClient::beep();
2817 return; 2823 return;
2818 } 2824 }
2819 2825
2820 editEvent(anEvent); 2826 editEvent(anEvent);
2821} 2827}
2822 2828
2823void CalendarView::appointment_delete() 2829void CalendarView::appointment_delete()
2824{ 2830{
2825 Event *anEvent = 0; 2831 Event *anEvent = 0;
2826 2832
2827 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2833 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2828 2834
2829 if (mViewManager->currentView()->isEventView()) { 2835 if (mViewManager->currentView()->isEventView()) {
2830 if ( incidence && incidence->type() == "Event" ) { 2836 if ( incidence && incidence->type() == "Event" ) {
2831 anEvent = static_cast<Event *>(incidence); 2837 anEvent = static_cast<Event *>(incidence);
2832 } 2838 }
2833 } 2839 }
2834 2840
2835 if (!anEvent) { 2841 if (!anEvent) {
2836 KNotifyClient::beep(); 2842 KNotifyClient::beep();
2837 return; 2843 return;
2838 } 2844 }
2839 2845
2840 deleteEvent(anEvent); 2846 deleteEvent(anEvent);
2841} 2847}
2842 2848
2843void CalendarView::todo_resub( Todo * parent, Todo * sub ) 2849void CalendarView::todo_resub( Todo * parent, Todo * sub )
2844{ 2850{
2845 if (!sub) return; 2851 if (!sub) return;
2846 if (!parent) return; 2852 if (!parent) return;
2847 if ( sub->relatedTo() ) 2853 if ( sub->relatedTo() )
2848 sub->relatedTo()->removeRelation(sub); 2854 sub->relatedTo()->removeRelation(sub);
2849 sub->setRelatedTo(parent); 2855 sub->setRelatedTo(parent);
2850 sub->setRelatedToUid(parent->uid()); 2856 sub->setRelatedToUid(parent->uid());
2851 parent->addRelation(sub); 2857 parent->addRelation(sub);
2852 sub->updated(); 2858 sub->updated();
2853 parent->updated(); 2859 parent->updated();
2854 setModified(true); 2860 setModified(true);
2855 updateView(); 2861 updateView();
2856} 2862}
2857void CalendarView::todo_unsub(Todo *anTodo ) 2863void CalendarView::todo_unsub(Todo *anTodo )
2858{ 2864{
2859 // Todo *anTodo = selectedTodo(); 2865 // Todo *anTodo = selectedTodo();
2860 if (!anTodo) return; 2866 if (!anTodo) return;
2861 if (!anTodo->relatedTo()) return; 2867 if (!anTodo->relatedTo()) return;
2862 anTodo->relatedTo()->removeRelation(anTodo); 2868 anTodo->relatedTo()->removeRelation(anTodo);
2863 anTodo->setRelatedTo(0); 2869 anTodo->setRelatedTo(0);
2864 anTodo->updated(); 2870 anTodo->updated();
2865 anTodo->setRelatedToUid(""); 2871 anTodo->setRelatedToUid("");
2866 setModified(true); 2872 setModified(true);
2867 updateView(); 2873 updateView();
2868} 2874}
2869 2875
2870void CalendarView::deleteTodo(Todo *todo) 2876void CalendarView::deleteTodo(Todo *todo)
2871{ 2877{
2872 if (!todo) { 2878 if (!todo) {
2873 KNotifyClient::beep(); 2879 KNotifyClient::beep();
2874 return; 2880 return;
2875 } 2881 }
2876 if (KOPrefs::instance()->mConfirm) { 2882 if (KOPrefs::instance()->mConfirm) {
2877 switch (msgItemDelete()) { 2883 switch (msgItemDelete()) {
2878 case KMessageBox::Continue: // OK 2884 case KMessageBox::Continue: // OK
2879 if (!todo->relations().isEmpty()) { 2885 if (!todo->relations().isEmpty()) {
2880 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), 2886 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."),
2881 i18n("Delete To-Do")); 2887 i18n("Delete To-Do"));
2882 } else { 2888 } else {
2883 checkExternalId( todo ); 2889 checkExternalId( todo );
2884 calendar()->deleteTodo(todo); 2890 calendar()->deleteTodo(todo);
2885 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2891 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2886 updateView(); 2892 updateView();
2887 } 2893 }
2888 break; 2894 break;
2889 } // switch 2895 } // switch
2890 } else { 2896 } else {
2891 if (!todo->relations().isEmpty()) { 2897 if (!todo->relations().isEmpty()) {
2892 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), 2898 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."),
2893 i18n("Delete To-Do")); 2899 i18n("Delete To-Do"));
2894 } else { 2900 } else {
2895 checkExternalId( todo ); 2901 checkExternalId( todo );
2896 mCalendar->deleteTodo(todo); 2902 mCalendar->deleteTodo(todo);
2897 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2903 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2898 updateView(); 2904 updateView();
2899 } 2905 }
2900 } 2906 }
2901 emit updateSearchDialog(); 2907 emit updateSearchDialog();
2902} 2908}
2903void CalendarView::deleteJournal(Journal *jour) 2909void CalendarView::deleteJournal(Journal *jour)
2904{ 2910{
2905 if (!jour) { 2911 if (!jour) {
2906 KNotifyClient::beep(); 2912 KNotifyClient::beep();
2907 return; 2913 return;
2908 } 2914 }
2909 if (KOPrefs::instance()->mConfirm) { 2915 if (KOPrefs::instance()->mConfirm) {
2910 switch (msgItemDelete()) { 2916 switch (msgItemDelete()) {
2911 case KMessageBox::Continue: // OK 2917 case KMessageBox::Continue: // OK
2912 calendar()->deleteJournal(jour); 2918 calendar()->deleteJournal(jour);
2913 updateView(); 2919 updateView();
2914 break; 2920 break;
2915 } // switch 2921 } // switch
2916 } else { 2922 } else {
2917 calendar()->deleteJournal(jour);; 2923 calendar()->deleteJournal(jour);;
2918 updateView(); 2924 updateView();
2919 } 2925 }
2920 emit updateSearchDialog(); 2926 emit updateSearchDialog();
2921} 2927}
2922 2928
2923void CalendarView::deleteEvent(Event *anEvent) 2929void CalendarView::deleteEvent(Event *anEvent)
2924{ 2930{
2925 if (!anEvent) { 2931 if (!anEvent) {
2926 KNotifyClient::beep(); 2932 KNotifyClient::beep();
2927 return; 2933 return;
2928 } 2934 }
2929 2935
2930 if (anEvent->recurrence()->doesRecur()) { 2936 if (anEvent->recurrence()->doesRecur()) {
2931 QDate itemDate = mViewManager->currentSelectionDate(); 2937 QDate itemDate = mViewManager->currentSelectionDate();
2932 int km; 2938 int km;
2933 if (!itemDate.isValid()) { 2939 if (!itemDate.isValid()) {
2934 //kdDebug() << "Date Not Valid" << endl; 2940 //kdDebug() << "Date Not Valid" << endl;
2935 if (KOPrefs::instance()->mConfirm) { 2941 if (KOPrefs::instance()->mConfirm) {
2936 km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + 2942 km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) +
2937 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), 2943 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"),
2938 i18n("KO/Pi Confirmation"),i18n("Delete All")); 2944 i18n("KO/Pi Confirmation"),i18n("Delete All"));
2939 if ( km == KMessageBox::Continue ) 2945 if ( km == KMessageBox::Continue )
2940 km = KMessageBox::No; // No = all below 2946 km = KMessageBox::No; // No = all below
2941 } else 2947 } else
2942 km = KMessageBox::No; 2948 km = KMessageBox::No;
2943 } else { 2949 } else {
2944 km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + 2950 km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) +
2945 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ 2951 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+
2946 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), 2952 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"),
2947 i18n("KO/Pi Confirmation"),i18n("Current"), 2953 i18n("KO/Pi Confirmation"),i18n("Current"),
2948 i18n("All")); 2954 i18n("All"));
2949 } 2955 }
2950 switch(km) { 2956 switch(km) {
2951 2957
2952 case KMessageBox::No: // Continue // all 2958 case KMessageBox::No: // Continue // all
2953 //qDebug("KMessageBox::No "); 2959 //qDebug("KMessageBox::No ");
2954 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2960 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2955 schedule(Scheduler::Cancel,anEvent); 2961 schedule(Scheduler::Cancel,anEvent);
2956 2962
2957 checkExternalId( anEvent); 2963 checkExternalId( anEvent);
2958 mCalendar->deleteEvent(anEvent); 2964 mCalendar->deleteEvent(anEvent);
2959 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); 2965 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED);
2960 break; 2966 break;
2961 2967
2962 // Disabled because it does not work 2968 // Disabled because it does not work
2963 //#if 0 2969 //#if 0
2964 case KMessageBox::Yes: // just this one 2970 case KMessageBox::Yes: // just this one
2965 //QDate qd = mNavigator->selectedDates().first(); 2971 //QDate qd = mNavigator->selectedDates().first();
2966 //if (!qd.isValid()) { 2972 //if (!qd.isValid()) {
2967 // kdDebug() << "no date selected, or invalid date" << endl; 2973 // kdDebug() << "no date selected, or invalid date" << endl;
2968 // KNotifyClient::beep(); 2974 // KNotifyClient::beep();
2969 // return; 2975 // return;
2970 //} 2976 //}
2971 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); 2977 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1);
2972 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { 2978 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) {
2973 anEvent->addExDate(itemDate); 2979 anEvent->addExDate(itemDate);
2974 int duration = anEvent->recurrence()->duration(); 2980 int duration = anEvent->recurrence()->duration();
2975 if ( duration > 0 ) { 2981 if ( duration > 0 ) {
2976 anEvent->recurrence()->setDuration( duration - 1 ); 2982 anEvent->recurrence()->setDuration( duration - 1 );
2977 } 2983 }
2978 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); 2984 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED);
2979 } 2985 }
2980 break; 2986 break;
2981 //#endif 2987 //#endif
2982 } // switch 2988 } // switch
2983 } else { 2989 } else {
2984 if (KOPrefs::instance()->mConfirm) { 2990 if (KOPrefs::instance()->mConfirm) {
2985 switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + 2991 switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) +
2986 i18n("\nAre you sure you want\nto delete this event?"), 2992 i18n("\nAre you sure you want\nto delete this event?"),
2987 i18n("KO/Pi Confirmation"),i18n("Delete"))) { 2993 i18n("KO/Pi Confirmation"),i18n("Delete"))) {
2988 case KMessageBox::Continue: // OK 2994 case KMessageBox::Continue: // OK
2989 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2995 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2990 schedule(Scheduler::Cancel,anEvent); 2996 schedule(Scheduler::Cancel,anEvent);
2991 checkExternalId( anEvent); 2997 checkExternalId( anEvent);
2992 mCalendar->deleteEvent(anEvent); 2998 mCalendar->deleteEvent(anEvent);
2993 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2999 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2994 break; 3000 break;
2995 } // switch 3001 } // switch
2996 } else { 3002 } else {
2997 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3003 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2998 schedule(Scheduler::Cancel,anEvent); 3004 schedule(Scheduler::Cancel,anEvent);
2999 checkExternalId( anEvent); 3005 checkExternalId( anEvent);
3000 mCalendar->deleteEvent(anEvent); 3006 mCalendar->deleteEvent(anEvent);
3001 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3007 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3002 } 3008 }
3003 } // if-else 3009 } // if-else
3004 emit updateSearchDialog(); 3010 emit updateSearchDialog();
3005} 3011}
3006 3012
3007bool CalendarView::deleteEvent(const QString &uid) 3013bool CalendarView::deleteEvent(const QString &uid)
3008{ 3014{
3009 Event *ev = mCalendar->event(uid); 3015 Event *ev = mCalendar->event(uid);
3010 if (ev) { 3016 if (ev) {
3011 deleteEvent(ev); 3017 deleteEvent(ev);
3012 return true; 3018 return true;
3013 } else { 3019 } else {
3014 return false; 3020 return false;
3015 } 3021 }
3016} 3022}
3017 3023
3018/*****************************************************************************/ 3024/*****************************************************************************/
3019 3025
3020void CalendarView::action_mail() 3026void CalendarView::action_mail()
3021{ 3027{
3022#ifndef KORG_NOMAIL 3028#ifndef KORG_NOMAIL
3023 KOMailClient mailClient; 3029 KOMailClient mailClient;
3024 3030
3025 Incidence *incidence = currentSelection(); 3031 Incidence *incidence = currentSelection();
3026 3032
3027 if (!incidence) { 3033 if (!incidence) {
3028 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3034 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3029 return; 3035 return;
3030 } 3036 }
3031 if(incidence->attendeeCount() == 0 ) { 3037 if(incidence->attendeeCount() == 0 ) {
3032 KMessageBox::sorry(this, 3038 KMessageBox::sorry(this,
3033 i18n("Can't generate mail:\nNo attendees defined.\n")); 3039 i18n("Can't generate mail:\nNo attendees defined.\n"));
3034 return; 3040 return;
3035 } 3041 }
3036 3042
3037 CalendarLocal cal_tmp; 3043 CalendarLocal cal_tmp;
3038 Event *event = 0; 3044 Event *event = 0;
3039 Event *ev = 0; 3045 Event *ev = 0;
3040 if ( incidence && incidence->type() == "Event" ) { 3046 if ( incidence && incidence->type() == "Event" ) {
3041 event = static_cast<Event *>(incidence); 3047 event = static_cast<Event *>(incidence);
3042 ev = new Event(*event); 3048 ev = new Event(*event);
3043 cal_tmp.addEvent(ev); 3049 cal_tmp.addEvent(ev);
3044 } 3050 }
3045 ICalFormat mForm(); 3051 ICalFormat mForm();
3046 QString attachment = mForm.toString( &cal_tmp ); 3052 QString attachment = mForm.toString( &cal_tmp );
3047 if (ev) delete(ev); 3053 if (ev) delete(ev);
3048 3054
3049 mailClient.mailAttendees(currentSelection(), attachment); 3055 mailClient.mailAttendees(currentSelection(), attachment);
3050 3056
3051#endif 3057#endif
3052 3058
3053#if 0 3059#if 0
3054 Event *anEvent = 0; 3060 Event *anEvent = 0;
3055 if (mViewManager->currentView()->isEventView()) { 3061 if (mViewManager->currentView()->isEventView()) {
3056 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); 3062 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first());
3057 } 3063 }
3058 3064
3059 if (!anEvent) { 3065 if (!anEvent) {
3060 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3066 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3061 return; 3067 return;
3062 } 3068 }
3063 if(anEvent->attendeeCount() == 0 ) { 3069 if(anEvent->attendeeCount() == 0 ) {
3064 KMessageBox::sorry(this, 3070 KMessageBox::sorry(this,
3065 i18n("Can't generate mail:\nNo attendees defined.\n")); 3071 i18n("Can't generate mail:\nNo attendees defined.\n"));
3066 return; 3072 return;
3067 } 3073 }
3068 3074
3069 mailobject.emailEvent(anEvent); 3075 mailobject.emailEvent(anEvent);
3070#endif 3076#endif
3071} 3077}
3072 3078
3073 3079
3074void CalendarView::schedule_publish(Incidence *incidence) 3080void CalendarView::schedule_publish(Incidence *incidence)
3075{ 3081{
3076 Event *event = 0; 3082 Event *event = 0;
3077 Todo *todo = 0; 3083 Todo *todo = 0;
3078 3084
3079 if (incidence == 0) { 3085 if (incidence == 0) {
3080 incidence = mViewManager->currentView()->selectedIncidences().first(); 3086 incidence = mViewManager->currentView()->selectedIncidences().first();
3081 if (incidence == 0) { 3087 if (incidence == 0) {
3082 incidence = mTodoList->selectedIncidences().first(); 3088 incidence = mTodoList->selectedIncidences().first();
3083 } 3089 }
3084 } 3090 }
3085 if ( incidence && incidence->type() == "Event" ) { 3091 if ( incidence && incidence->type() == "Event" ) {
3086 event = static_cast<Event *>(incidence); 3092 event = static_cast<Event *>(incidence);
3087 } else { 3093 } else {
3088 if ( incidence && incidence->type() == "Todo" ) { 3094 if ( incidence && incidence->type() == "Todo" ) {
3089 todo = static_cast<Todo *>(incidence); 3095 todo = static_cast<Todo *>(incidence);
3090 } 3096 }
3091 } 3097 }
3092 3098
3093 if (!event && !todo) { 3099 if (!event && !todo) {
3094 KMessageBox::sorry(this,i18n("No event selected.")); 3100 KMessageBox::sorry(this,i18n("No event selected."));
3095 return; 3101 return;
3096 } 3102 }
3097 3103
3098 PublishDialog *publishdlg = new PublishDialog(); 3104 PublishDialog *publishdlg = new PublishDialog();
3099 if (incidence->attendeeCount()>0) { 3105 if (incidence->attendeeCount()>0) {
3100 QPtrList<Attendee> attendees = incidence->attendees(); 3106 QPtrList<Attendee> attendees = incidence->attendees();
3101 attendees.first(); 3107 attendees.first();
3102 while ( attendees.current()!=0 ) { 3108 while ( attendees.current()!=0 ) {
3103 publishdlg->addAttendee(attendees.current()); 3109 publishdlg->addAttendee(attendees.current());
3104 attendees.next(); 3110 attendees.next();
3105 } 3111 }
3106 } 3112 }
3107 bool send = true; 3113 bool send = true;
3108 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { 3114 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) {
3109 if ( publishdlg->exec() != QDialog::Accepted ) 3115 if ( publishdlg->exec() != QDialog::Accepted )
3110 send = false; 3116 send = false;
3111 } 3117 }
3112 if ( send ) { 3118 if ( send ) {
3113 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3119 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3114 if ( event ) { 3120 if ( event ) {
3115 Event *ev = new Event(*event); 3121 Event *ev = new Event(*event);
3116 ev->registerObserver(0); 3122 ev->registerObserver(0);
3117 ev->clearAttendees(); 3123 ev->clearAttendees();
3118 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3124 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3119 delete(ev); 3125 delete(ev);
3120 } 3126 }
3121 } else { 3127 } else {
3122 if ( todo ) { 3128 if ( todo ) {
3123 Todo *ev = new Todo(*todo); 3129 Todo *ev = new Todo(*todo);
3124 ev->registerObserver(0); 3130 ev->registerObserver(0);
3125 ev->clearAttendees(); 3131 ev->clearAttendees();
3126 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3132 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3127 delete(ev); 3133 delete(ev);
3128 } 3134 }
3129 } 3135 }
3130 } 3136 }
3131 } 3137 }
3132 delete publishdlg; 3138 delete publishdlg;
3133} 3139}
3134 3140
3135void CalendarView::schedule_request(Incidence *incidence) 3141void CalendarView::schedule_request(Incidence *incidence)
3136{ 3142{
3137 schedule(Scheduler::Request,incidence); 3143 schedule(Scheduler::Request,incidence);
3138} 3144}
3139 3145
3140void CalendarView::schedule_refresh(Incidence *incidence) 3146void CalendarView::schedule_refresh(Incidence *incidence)
3141{ 3147{
3142 schedule(Scheduler::Refresh,incidence); 3148 schedule(Scheduler::Refresh,incidence);
3143} 3149}
3144 3150
3145void CalendarView::schedule_cancel(Incidence *incidence) 3151void CalendarView::schedule_cancel(Incidence *incidence)
3146{ 3152{
3147 schedule(Scheduler::Cancel,incidence); 3153 schedule(Scheduler::Cancel,incidence);
3148} 3154}
3149 3155
3150void CalendarView::schedule_add(Incidence *incidence) 3156void CalendarView::schedule_add(Incidence *incidence)
3151{ 3157{
3152 schedule(Scheduler::Add,incidence); 3158 schedule(Scheduler::Add,incidence);
3153} 3159}
3154 3160
3155void CalendarView::schedule_reply(Incidence *incidence) 3161void CalendarView::schedule_reply(Incidence *incidence)
3156{ 3162{
3157 schedule(Scheduler::Reply,incidence); 3163 schedule(Scheduler::Reply,incidence);
3158} 3164}
3159 3165
3160void CalendarView::schedule_counter(Incidence *incidence) 3166void CalendarView::schedule_counter(Incidence *incidence)
3161{ 3167{
3162 schedule(Scheduler::Counter,incidence); 3168 schedule(Scheduler::Counter,incidence);
3163} 3169}
3164 3170
3165void CalendarView::schedule_declinecounter(Incidence *incidence) 3171void CalendarView::schedule_declinecounter(Incidence *incidence)
3166{ 3172{
3167 schedule(Scheduler::Declinecounter,incidence); 3173 schedule(Scheduler::Declinecounter,incidence);
3168} 3174}
3169 3175
3170void CalendarView::schedule_publish_freebusy(int daysToPublish) 3176void CalendarView::schedule_publish_freebusy(int daysToPublish)
3171{ 3177{
3172 QDateTime start = QDateTime::currentDateTime(); 3178 QDateTime start = QDateTime::currentDateTime();
3173 QDateTime end = start.addDays(daysToPublish); 3179 QDateTime end = start.addDays(daysToPublish);
3174 3180
3175 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); 3181 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end);
3176 freebusy->setOrganizer(KOPrefs::instance()->email()); 3182 freebusy->setOrganizer(KOPrefs::instance()->email());
3177 3183
3178 3184
3179 PublishDialog *publishdlg = new PublishDialog(); 3185 PublishDialog *publishdlg = new PublishDialog();
3180 if ( publishdlg->exec() == QDialog::Accepted ) { 3186 if ( publishdlg->exec() == QDialog::Accepted ) {
3181 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3187 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3182 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { 3188 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) {
3183 delete(freebusy); 3189 delete(freebusy);
3184 } 3190 }
3185 } 3191 }
3186 delete publishdlg; 3192 delete publishdlg;
3187} 3193}
3188 3194
3189void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) 3195void CalendarView::schedule(Scheduler::Method method, Incidence *incidence)
3190{ 3196{
3191 Event *event = 0; 3197 Event *event = 0;
3192 Todo *todo = 0; 3198 Todo *todo = 0;
3193 3199
3194 if (incidence == 0) { 3200 if (incidence == 0) {
3195 incidence = mViewManager->currentView()->selectedIncidences().first(); 3201 incidence = mViewManager->currentView()->selectedIncidences().first();
3196 if (incidence == 0) { 3202 if (incidence == 0) {
3197 incidence = mTodoList->selectedIncidences().first(); 3203 incidence = mTodoList->selectedIncidences().first();
3198 } 3204 }
3199 } 3205 }
3200 if ( incidence && incidence->type() == "Event" ) { 3206 if ( incidence && incidence->type() == "Event" ) {
3201 event = static_cast<Event *>(incidence); 3207 event = static_cast<Event *>(incidence);
3202 } 3208 }
3203 if ( incidence && incidence->type() == "Todo" ) { 3209 if ( incidence && incidence->type() == "Todo" ) {
3204 todo = static_cast<Todo *>(incidence); 3210 todo = static_cast<Todo *>(incidence);
3205 } 3211 }
3206 3212
3207 if (!event && !todo) { 3213 if (!event && !todo) {
3208 KMessageBox::sorry(this,i18n("No event selected.")); 3214 KMessageBox::sorry(this,i18n("No event selected."));
3209 return; 3215 return;
3210 } 3216 }
3211 3217
3212 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { 3218 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) {
3213 KMessageBox::sorry(this,i18n("The event has no attendees.")); 3219 KMessageBox::sorry(this,i18n("The event has no attendees."));
3214 return; 3220 return;
3215 } 3221 }
3216 3222
3217 Event *ev = 0; 3223 Event *ev = 0;
3218 if (event) ev = new Event(*event); 3224 if (event) ev = new Event(*event);
3219 Todo *to = 0; 3225 Todo *to = 0;
3220 if (todo) to = new Todo(*todo); 3226 if (todo) to = new Todo(*todo);
3221 3227
3222 if (method == Scheduler::Reply || method == Scheduler::Refresh) { 3228 if (method == Scheduler::Reply || method == Scheduler::Refresh) {
3223 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 3229 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
3224 if (!me) { 3230 if (!me) {
3225 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); 3231 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails."));
3226 return; 3232 return;
3227 } 3233 }
3228 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { 3234 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) {
3229 StatusDialog *statdlg = new StatusDialog(this); 3235 StatusDialog *statdlg = new StatusDialog(this);
3230 if (!statdlg->exec()==QDialog::Accepted) return; 3236 if (!statdlg->exec()==QDialog::Accepted) return;
3231 me->setStatus( statdlg->status() ); 3237 me->setStatus( statdlg->status() );
3232 delete(statdlg); 3238 delete(statdlg);
3233 } 3239 }
3234 Attendee *menew = new Attendee(*me); 3240 Attendee *menew = new Attendee(*me);
3235 if (ev) { 3241 if (ev) {
3236 ev->clearAttendees(); 3242 ev->clearAttendees();
3237 ev->addAttendee(menew,false); 3243 ev->addAttendee(menew,false);
3238 } else { 3244 } else {
3239 if (to) { 3245 if (to) {
3240 todo->clearAttendees(); 3246 todo->clearAttendees();
3241 todo->addAttendee(menew,false); 3247 todo->addAttendee(menew,false);
3242 } 3248 }
3243 } 3249 }
3244 } 3250 }
3245 3251
3246 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3252 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3247 if (ev) { 3253 if (ev) {
3248 if ( !dlg->addMessage(ev,method) ) delete(ev); 3254 if ( !dlg->addMessage(ev,method) ) delete(ev);
3249 } else { 3255 } else {
3250 if (to) { 3256 if (to) {
3251 if ( !dlg->addMessage(to,method) ) delete(to); 3257 if ( !dlg->addMessage(to,method) ) delete(to);
3252 } 3258 }
3253 } 3259 }
3254} 3260}
3255 3261
3256void CalendarView::openAddressbook() 3262void CalendarView::openAddressbook()
3257{ 3263{
3258 KRun::runCommand("kaddressbook"); 3264 KRun::runCommand("kaddressbook");
3259} 3265}
3260 3266
3261void CalendarView::setModified(bool modified) 3267void CalendarView::setModified(bool modified)
3262{ 3268{
3263 if ( modified ) 3269 if ( modified )
3264 emit signalmodified(); 3270 emit signalmodified();
3265 if (mModified != modified) { 3271 if (mModified != modified) {
3266 mModified = modified; 3272 mModified = modified;
3267 emit modifiedChanged(mModified); 3273 emit modifiedChanged(mModified);
3268 } 3274 }
3269} 3275}
3270 3276
3271bool CalendarView::isReadOnly() 3277bool CalendarView::isReadOnly()
3272{ 3278{
3273 return mReadOnly; 3279 return mReadOnly;
3274} 3280}
3275 3281
3276void CalendarView::setReadOnly(bool readOnly) 3282void CalendarView::setReadOnly(bool readOnly)
3277{ 3283{
3278 if (mReadOnly != readOnly) { 3284 if (mReadOnly != readOnly) {
3279 mReadOnly = readOnly; 3285 mReadOnly = readOnly;
3280 emit readOnlyChanged(mReadOnly); 3286 emit readOnlyChanged(mReadOnly);
3281 } 3287 }
3282} 3288}
3283 3289
3284bool CalendarView::isModified() 3290bool CalendarView::isModified()
3285{ 3291{
3286 return mModified; 3292 return mModified;
3287} 3293}
3288 3294
3289void CalendarView::printSetup() 3295void CalendarView::printSetup()
3290{ 3296{
3291#ifndef KORG_NOPRINTER 3297#ifndef KORG_NOPRINTER
3292 createPrinter(); 3298 createPrinter();
3293 3299
3294 mCalPrinter->setupPrinter(); 3300 mCalPrinter->setupPrinter();
3295#endif 3301#endif
3296} 3302}
3297 3303
3298void CalendarView::print() 3304void CalendarView::print()
3299{ 3305{
3300#ifndef KORG_NOPRINTER 3306#ifndef KORG_NOPRINTER
3301 createPrinter(); 3307 createPrinter();
3302 3308
3303 DateList tmpDateList = mNavigator->selectedDates(); 3309 DateList tmpDateList = mNavigator->selectedDates();
3304 mCalPrinter->print(CalPrinter::Month, 3310 mCalPrinter->print(CalPrinter::Month,
3305 tmpDateList.first(), tmpDateList.last()); 3311 tmpDateList.first(), tmpDateList.last());
3306#endif 3312#endif
3307} 3313}
3308 3314
3309void CalendarView::printPreview() 3315void CalendarView::printPreview()
3310{ 3316{
3311#ifndef KORG_NOPRINTER 3317#ifndef KORG_NOPRINTER
3312 kdDebug() << "CalendarView::printPreview()" << endl; 3318 kdDebug() << "CalendarView::printPreview()" << endl;
3313 3319
3314 createPrinter(); 3320 createPrinter();
3315 3321
3316 DateList tmpDateList = mNavigator->selectedDates(); 3322 DateList tmpDateList = mNavigator->selectedDates();
3317 3323
3318 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), 3324 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(),
3319 tmpDateList.last()); 3325 tmpDateList.last());
3320#endif 3326#endif
3321} 3327}
3322 3328
3323void CalendarView::exportICalendar() 3329void CalendarView::exportICalendar()
3324{ 3330{
3325 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); 3331 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this);
3326 3332
3327 // Force correct extension 3333 // Force correct extension
3328 if (filename.right(4) != ".ics") filename += ".ics"; 3334 if (filename.right(4) != ".ics") filename += ".ics";
3329 3335
3330 FileStorage storage( mCalendar, filename, new ICalFormat() ); 3336 FileStorage storage( mCalendar, filename, new ICalFormat() );
3331 storage.save(); 3337 storage.save();
3332} 3338}
3333 3339
3334bool CalendarView::exportVCalendar( QString filename ) 3340bool CalendarView::exportVCalendar( QString filename )
3335{ 3341{
3336 if (mCalendar->journals().count() > 0) { 3342 if (mCalendar->journals().count() > 0) {
3337 int result = KMessageBox::warningContinueCancel(this, 3343 int result = KMessageBox::warningContinueCancel(this,
3338 i18n("The journal entries can not be\nexported to a vCalendar file."), 3344 i18n("The journal entries can not be\nexported to a vCalendar file."),
3339 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 3345 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
3340 true); 3346 true);
3341 if (result != KMessageBox::Continue) return false; 3347 if (result != KMessageBox::Continue) return false;
3342 } 3348 }
3343 3349
3344 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); 3350 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this);
3345 3351
3346 // Force correct extension 3352 // Force correct extension
3347 if (filename.right(4) != ".vcs") filename += ".vcs"; 3353 if (filename.right(4) != ".vcs") filename += ".vcs";
3348 3354
3349 FileStorage storage( mCalendar, filename, new VCalFormat ); 3355 FileStorage storage( mCalendar, filename, new VCalFormat );
3350 return storage.save(); 3356 return storage.save();
3351 3357
3352} 3358}
3353 3359
3354void CalendarView::eventUpdated(Incidence *) 3360void CalendarView::eventUpdated(Incidence *)
3355{ 3361{
3356 setModified(); 3362 setModified();
3357 // Don't call updateView here. The code, which has caused the update of the 3363 // Don't call updateView here. The code, which has caused the update of the
3358 // event is responsible for updating the view. 3364 // event is responsible for updating the view.
3359 // updateView(); 3365 // updateView();
3360} 3366}
3361 3367
3362void CalendarView::adaptNavigationUnits() 3368void CalendarView::adaptNavigationUnits()
3363{ 3369{
3364 if (mViewManager->currentView()->isEventView()) { 3370 if (mViewManager->currentView()->isEventView()) {
3365 int days = mViewManager->currentView()->currentDateCount(); 3371 int days = mViewManager->currentView()->currentDateCount();
3366 if (days == 1) { 3372 if (days == 1) {
3367 emit changeNavStringPrev(i18n("&Previous Day")); 3373 emit changeNavStringPrev(i18n("&Previous Day"));
3368 emit changeNavStringNext(i18n("&Next Day")); 3374 emit changeNavStringNext(i18n("&Next Day"));
3369 } else { 3375 } else {
3370 emit changeNavStringPrev(i18n("&Previous Week")); 3376 emit changeNavStringPrev(i18n("&Previous Week"));
3371 emit changeNavStringNext(i18n("&Next Week")); 3377 emit changeNavStringNext(i18n("&Next Week"));
3372 } 3378 }
3373 } 3379 }
3374} 3380}
3375 3381
3376void CalendarView::processMainViewSelection( Incidence *incidence ) 3382void CalendarView::processMainViewSelection( Incidence *incidence )
3377{ 3383{
3378 if ( incidence ) mTodoList->clearSelection(); 3384 if ( incidence ) mTodoList->clearSelection();
3379 processIncidenceSelection( incidence ); 3385 processIncidenceSelection( incidence );
3380} 3386}
3381 3387
3382void CalendarView::processTodoListSelection( Incidence *incidence ) 3388void CalendarView::processTodoListSelection( Incidence *incidence )
3383{ 3389{
3384 if ( incidence && mViewManager->currentView() ) { 3390 if ( incidence && mViewManager->currentView() ) {
3385 mViewManager->currentView()->clearSelection(); 3391 mViewManager->currentView()->clearSelection();
3386 } 3392 }
3387 processIncidenceSelection( incidence ); 3393 processIncidenceSelection( incidence );
3388} 3394}
3389 3395
3390void CalendarView::processIncidenceSelection( Incidence *incidence ) 3396void CalendarView::processIncidenceSelection( Incidence *incidence )
3391{ 3397{
3392 if ( incidence == mSelectedIncidence ) return; 3398 if ( incidence == mSelectedIncidence ) return;
3393 3399
3394 mSelectedIncidence = incidence; 3400 mSelectedIncidence = incidence;
3395 3401
3396 emit incidenceSelected( mSelectedIncidence ); 3402 emit incidenceSelected( mSelectedIncidence );
3397 3403
3398 if ( incidence && incidence->type() == "Event" ) { 3404 if ( incidence && incidence->type() == "Event" ) {
3399 Event *event = static_cast<Event *>( incidence ); 3405 Event *event = static_cast<Event *>( incidence );
3400 if ( event->organizer() == KOPrefs::instance()->email() ) { 3406 if ( event->organizer() == KOPrefs::instance()->email() ) {
3401 emit organizerEventsSelected( true ); 3407 emit organizerEventsSelected( true );
3402 } else { 3408 } else {
3403 emit organizerEventsSelected(false); 3409 emit organizerEventsSelected(false);
3404 } 3410 }
3405 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3411 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3406 KOPrefs::instance()->email() ) ) { 3412 KOPrefs::instance()->email() ) ) {
3407 emit groupEventsSelected( true ); 3413 emit groupEventsSelected( true );
3408 } else { 3414 } else {
3409 emit groupEventsSelected(false); 3415 emit groupEventsSelected(false);
3410 } 3416 }
3411 return; 3417 return;
3412 } else { 3418 } else {
3413 if ( incidence && incidence->type() == "Todo" ) { 3419 if ( incidence && incidence->type() == "Todo" ) {
3414 emit todoSelected( true ); 3420 emit todoSelected( true );
3415 Todo *event = static_cast<Todo *>( incidence ); 3421 Todo *event = static_cast<Todo *>( incidence );
3416 if ( event->organizer() == KOPrefs::instance()->email() ) { 3422 if ( event->organizer() == KOPrefs::instance()->email() ) {
3417 emit organizerEventsSelected( true ); 3423 emit organizerEventsSelected( true );
3418 } else { 3424 } else {
3419 emit organizerEventsSelected(false); 3425 emit organizerEventsSelected(false);
3420 } 3426 }
3421 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3427 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3422 KOPrefs::instance()->email() ) ) { 3428 KOPrefs::instance()->email() ) ) {
3423 emit groupEventsSelected( true ); 3429 emit groupEventsSelected( true );
3424 } else { 3430 } else {
3425 emit groupEventsSelected(false); 3431 emit groupEventsSelected(false);
3426 } 3432 }
3427 return; 3433 return;
3428 } else { 3434 } else {
3429 emit todoSelected( false ); 3435 emit todoSelected( false );
3430 emit organizerEventsSelected(false); 3436 emit organizerEventsSelected(false);
3431 emit groupEventsSelected(false); 3437 emit groupEventsSelected(false);
3432 } 3438 }
3433 return; 3439 return;
3434 } 3440 }
3435 3441
3436 /* if ( incidence && incidence->type() == "Todo" ) { 3442 /* if ( incidence && incidence->type() == "Todo" ) {
3437 emit todoSelected( true ); 3443 emit todoSelected( true );
3438 } else { 3444 } else {
3439 emit todoSelected( false ); 3445 emit todoSelected( false );
3440 }*/ 3446 }*/
3441} 3447}
3442 3448
3443 3449
3444void CalendarView::checkClipboard() 3450void CalendarView::checkClipboard()
3445{ 3451{
3446#ifndef KORG_NODND 3452#ifndef KORG_NODND
3447 if (ICalDrag::canDecode(QApplication::clipboard()->data())) { 3453 if (ICalDrag::canDecode(QApplication::clipboard()->data())) {
3448 emit pasteEnabled(true); 3454 emit pasteEnabled(true);
3449 } else { 3455 } else {
3450 emit pasteEnabled(false); 3456 emit pasteEnabled(false);
3451 } 3457 }
3452#endif 3458#endif
3453} 3459}
3454 3460
3455void CalendarView::showDates(const DateList &selectedDates) 3461void CalendarView::showDates(const DateList &selectedDates)
3456{ 3462{
3457 // kdDebug() << "CalendarView::selectDates()" << endl; 3463 // kdDebug() << "CalendarView::selectDates()" << endl;
3458 3464
3459 if ( mViewManager->currentView() ) { 3465 if ( mViewManager->currentView() ) {
3460 updateView( selectedDates.first(), selectedDates.last() ); 3466 updateView( selectedDates.first(), selectedDates.last() );
3461 } else { 3467 } else {
3462 mViewManager->showAgendaView(); 3468 mViewManager->showAgendaView();
3463 } 3469 }
3464 3470
3465 QString selDates; 3471 QString selDates;
3466 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); 3472 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true);
3467 if (selectedDates.first() < selectedDates.last() ) 3473 if (selectedDates.first() < selectedDates.last() )
3468 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); 3474 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true);
3469 topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); 3475 topLevelWidget()->setCaption( i18n("Dates: ") + selDates );
3470 3476
3471} 3477}
3472 3478
3473QPtrList<CalFilter> CalendarView::filters() 3479QPtrList<CalFilter> CalendarView::filters()
3474{ 3480{
3475 return mFilters; 3481 return mFilters;
3476 3482
3477} 3483}
3478void CalendarView::editFilters() 3484void CalendarView::editFilters()
3479{ 3485{
3480 // kdDebug() << "CalendarView::editFilters()" << endl; 3486 // kdDebug() << "CalendarView::editFilters()" << endl;
3481 3487
3482 CalFilter *filter = mFilters.first(); 3488 CalFilter *filter = mFilters.first();
3483 while(filter) { 3489 while(filter) {
3484 kdDebug() << " Filter: " << filter->name() << endl; 3490 kdDebug() << " Filter: " << filter->name() << endl;
3485 filter = mFilters.next(); 3491 filter = mFilters.next();
3486 } 3492 }
3487 3493
3488 mDialogManager->showFilterEditDialog(&mFilters); 3494 mDialogManager->showFilterEditDialog(&mFilters);
3489} 3495}
3490void CalendarView::toggleFilter() 3496void CalendarView::toggleFilter()
3491{ 3497{
3492 showFilter(! mFilterView->isVisible()); 3498 showFilter(! mFilterView->isVisible());
3493} 3499}
3494 3500
3495KOFilterView *CalendarView::filterView() 3501KOFilterView *CalendarView::filterView()
3496{ 3502{
3497 return mFilterView; 3503 return mFilterView;
3498} 3504}
3499void CalendarView::selectFilter( int fil ) 3505void CalendarView::selectFilter( int fil )
3500{ 3506{
3501 mFilterView->setSelectedFilter( fil ); 3507 mFilterView->setSelectedFilter( fil );
3502} 3508}
3503void CalendarView::showFilter(bool visible) 3509void CalendarView::showFilter(bool visible)
3504{ 3510{
3505 if (visible) mFilterView->show(); 3511 if (visible) mFilterView->show();
3506 else mFilterView->hide(); 3512 else mFilterView->hide();
3507} 3513}
3508void CalendarView::toggleFilerEnabled( ) 3514void CalendarView::toggleFilerEnabled( )
3509{ 3515{
3510 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); 3516 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() );
3511 if ( !mFilterView->filtersEnabled() ) 3517 if ( !mFilterView->filtersEnabled() )
3512 topLevelWidget()->setCaption( i18n("Filter disabled ") ); 3518 topLevelWidget()->setCaption( i18n("Filter disabled ") );
3513 3519
3514} 3520}
3515void CalendarView::updateFilter() 3521void CalendarView::updateFilter()
3516{ 3522{
3517 CalFilter *filter = mFilterView->selectedFilter(); 3523 CalFilter *filter = mFilterView->selectedFilter();
3518 if (filter) { 3524 if (filter) {
3519 if (mFilterView->filtersEnabled()) { 3525 if (mFilterView->filtersEnabled()) {
3520 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); 3526 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() );
3521 filter->setEnabled(true); 3527 filter->setEnabled(true);
3522 } 3528 }
3523 else filter->setEnabled(false); 3529 else filter->setEnabled(false);
3524 mCalendar->setFilter(filter); 3530 mCalendar->setFilter(filter);
3525 updateView(); 3531 updateView();
3526 } 3532 }
3527} 3533}
3528 3534
3529void CalendarView::filterEdited() 3535void CalendarView::filterEdited()
3530{ 3536{
3531 mFilterView->updateFilters(); 3537 mFilterView->updateFilters();
3532 updateFilter(); 3538 updateFilter();
3533 writeSettings(); 3539 writeSettings();
3534} 3540}
3535 3541
3536 3542
3537void CalendarView::takeOverEvent() 3543void CalendarView::takeOverEvent()
3538{ 3544{
3539 Incidence *incidence = currentSelection(); 3545 Incidence *incidence = currentSelection();
3540 3546
3541 if (!incidence) return; 3547 if (!incidence) return;
3542 3548
3543 incidence->setOrganizer(KOPrefs::instance()->email()); 3549 incidence->setOrganizer(KOPrefs::instance()->email());
3544 incidence->recreate(); 3550 incidence->recreate();
3545 incidence->setReadOnly(false); 3551 incidence->setReadOnly(false);
3546 3552
3547 updateView(); 3553 updateView();
3548} 3554}
3549 3555
3550void CalendarView::takeOverCalendar() 3556void CalendarView::takeOverCalendar()
3551{ 3557{
3552 // TODO: Create Calendar::allIncidences() function and use it here 3558 // TODO: Create Calendar::allIncidences() function and use it here
3553 3559
3554 QPtrList<Event> events = mCalendar->events(); 3560 QPtrList<Event> events = mCalendar->events();
3555 for(uint i=0; i<events.count(); ++i) { 3561 for(uint i=0; i<events.count(); ++i) {
3556 events.at(i)->setOrganizer(KOPrefs::instance()->email()); 3562 events.at(i)->setOrganizer(KOPrefs::instance()->email());
3557 events.at(i)->recreate(); 3563 events.at(i)->recreate();
3558 events.at(i)->setReadOnly(false); 3564 events.at(i)->setReadOnly(false);
3559 } 3565 }
3560 3566
3561 QPtrList<Todo> todos = mCalendar->todos(); 3567 QPtrList<Todo> todos = mCalendar->todos();
3562 for(uint i=0; i<todos.count(); ++i) { 3568 for(uint i=0; i<todos.count(); ++i) {
3563 todos.at(i)->setOrganizer(KOPrefs::instance()->email()); 3569 todos.at(i)->setOrganizer(KOPrefs::instance()->email());
3564 todos.at(i)->recreate(); 3570 todos.at(i)->recreate();
3565 todos.at(i)->setReadOnly(false); 3571 todos.at(i)->setReadOnly(false);
3566 } 3572 }
3567 3573
3568 QPtrList<Journal> journals = mCalendar->journals(); 3574 QPtrList<Journal> journals = mCalendar->journals();
3569 for(uint i=0; i<journals.count(); ++i) { 3575 for(uint i=0; i<journals.count(); ++i) {
3570 journals.at(i)->setOrganizer(KOPrefs::instance()->email()); 3576 journals.at(i)->setOrganizer(KOPrefs::instance()->email());
3571 journals.at(i)->recreate(); 3577 journals.at(i)->recreate();
3572 journals.at(i)->setReadOnly(false); 3578 journals.at(i)->setReadOnly(false);
3573 } 3579 }
3574 3580
3575 updateView(); 3581 updateView();
3576} 3582}
3577 3583
3578void CalendarView::showIntro() 3584void CalendarView::showIntro()
3579{ 3585{
3580 kdDebug() << "To be implemented." << endl; 3586 kdDebug() << "To be implemented." << endl;
3581} 3587}
3582 3588
3583QWidgetStack *CalendarView::viewStack() 3589QWidgetStack *CalendarView::viewStack()
3584{ 3590{
3585 return mRightFrame; 3591 return mRightFrame;
3586} 3592}
3587 3593
3588QWidget *CalendarView::leftFrame() 3594QWidget *CalendarView::leftFrame()
3589{ 3595{
3590 return mLeftFrame; 3596 return mLeftFrame;
3591} 3597}
3592 3598
3593DateNavigator *CalendarView::dateNavigator() 3599DateNavigator *CalendarView::dateNavigator()
3594{ 3600{
3595 return mNavigator; 3601 return mNavigator;
3596} 3602}
3597 3603
3598KDateNavigator* CalendarView::dateNavigatorWidget() 3604KDateNavigator* CalendarView::dateNavigatorWidget()
3599{ 3605{
3600 return mDateNavigator; 3606 return mDateNavigator;
3601} 3607}
3602void CalendarView::toggleDateNavigatorWidget() 3608void CalendarView::toggleDateNavigatorWidget()
3603{ 3609{
3604 if (mDateNavigator->isVisible()) 3610 if (mDateNavigator->isVisible())
3605 mDateNavigator->hide(); 3611 mDateNavigator->hide();
3606 else 3612 else
3607 mDateNavigator->show(); 3613 mDateNavigator->show();
3608} 3614}
3609void CalendarView::addView(KOrg::BaseView *view) 3615void CalendarView::addView(KOrg::BaseView *view)
3610{ 3616{
3611 mViewManager->addView(view); 3617 mViewManager->addView(view);
3612} 3618}
3613 3619
3614void CalendarView::showView(KOrg::BaseView *view) 3620void CalendarView::showView(KOrg::BaseView *view)
3615{ 3621{
3616 mViewManager->showView(view, mLeftFrame->isVisible()); 3622 mViewManager->showView(view, mLeftFrame->isVisible());
3617} 3623}
3618 3624
3619Incidence *CalendarView::currentSelection() 3625Incidence *CalendarView::currentSelection()
3620{ 3626{
3621 return mViewManager->currentSelection(); 3627 return mViewManager->currentSelection();
3622} 3628}
3623void CalendarView::toggleAllDaySize() 3629void CalendarView::toggleAllDaySize()
3624{ 3630{
3625 /* 3631 /*
3626 if ( KOPrefs::instance()->mAllDaySize > 47 ) 3632 if ( KOPrefs::instance()->mAllDaySize > 47 )
3627 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; 3633 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2;
3628 else 3634 else
3629 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; 3635 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2;
3630 */ 3636 */
3631 viewManager()->agendaView()->toggleAllDay(); 3637 viewManager()->agendaView()->toggleAllDay();
3632} 3638}
3633void CalendarView::toggleExpand() 3639void CalendarView::toggleExpand()
3634{ 3640{
3635 // if ( mLeftFrame->isHidden() ) { 3641 // if ( mLeftFrame->isHidden() ) {
3636 // mLeftFrame->show(); 3642 // mLeftFrame->show();
3637 // emit calendarViewExpanded( false ); 3643 // emit calendarViewExpanded( false );
3638 // } else { 3644 // } else {
3639 // mLeftFrame->hide(); 3645 // mLeftFrame->hide();
3640 // emit calendarViewExpanded( true ); 3646 // emit calendarViewExpanded( true );
3641 // } 3647 // }
3642 3648
3643 globalFlagBlockAgenda = 1; 3649 globalFlagBlockAgenda = 1;
3644 emit calendarViewExpanded( !mLeftFrame->isHidden() ); 3650 emit calendarViewExpanded( !mLeftFrame->isHidden() );
3645 globalFlagBlockAgenda = 5; 3651 globalFlagBlockAgenda = 5;
3646 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); 3652 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() );
3647 //mViewManager->showView( 0, true ); 3653 //mViewManager->showView( 0, true );
3648} 3654}
3649 3655
3650void CalendarView::calendarModified( bool modified, Calendar * ) 3656void CalendarView::calendarModified( bool modified, Calendar * )
3651{ 3657{
3652 setModified( modified ); 3658 setModified( modified );
3653} 3659}
3654 3660
3655Todo *CalendarView::selectedTodo() 3661Todo *CalendarView::selectedTodo()
3656{ 3662{
3657 Incidence *incidence = currentSelection(); 3663 Incidence *incidence = currentSelection();
3658 if ( incidence && incidence->type() == "Todo" ) { 3664 if ( incidence && incidence->type() == "Todo" ) {
3659 return static_cast<Todo *>( incidence ); 3665 return static_cast<Todo *>( incidence );
3660 } 3666 }
3661 3667
3662 incidence = mTodoList->selectedIncidences().first(); 3668 incidence = mTodoList->selectedIncidences().first();
3663 if ( incidence && incidence->type() == "Todo" ) { 3669 if ( incidence && incidence->type() == "Todo" ) {
3664 return static_cast<Todo *>( incidence ); 3670 return static_cast<Todo *>( incidence );
3665 } 3671 }
3666 3672
3667 return 0; 3673 return 0;
3668} 3674}
3669 3675
3670void CalendarView::dialogClosing(Incidence *in) 3676void CalendarView::dialogClosing(Incidence *in)
3671{ 3677{
3672 // mDialogList.remove(in); 3678 // mDialogList.remove(in);
3673} 3679}
3674 3680
3675void CalendarView::showIncidence() 3681void CalendarView::showIncidence()
3676{ 3682{
3677 Incidence *incidence = currentSelection(); 3683 Incidence *incidence = currentSelection();
3678 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3684 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3679 if ( incidence ) { 3685 if ( incidence ) {
3680 ShowIncidenceVisitor v; 3686 ShowIncidenceVisitor v;
3681 v.act( incidence, this ); 3687 v.act( incidence, this );
3682 } 3688 }
3683} 3689}
3684void CalendarView::editIncidenceDescription() 3690void CalendarView::editIncidenceDescription()
3685{ 3691{
3686 mFlagEditDescription = true; 3692 mFlagEditDescription = true;
3687 editIncidence(); 3693 editIncidence();
3688 mFlagEditDescription = false; 3694 mFlagEditDescription = false;
3689} 3695}
3690void CalendarView::editIncidence() 3696void CalendarView::editIncidence()
3691{ 3697{
3692 // qDebug("editIncidence() "); 3698 // qDebug("editIncidence() ");
3693 Incidence *incidence = currentSelection(); 3699 Incidence *incidence = currentSelection();
3694 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3700 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3695 if ( incidence ) { 3701 if ( incidence ) {
3696 EditIncidenceVisitor v; 3702 EditIncidenceVisitor v;
3697 v.act( incidence, this ); 3703 v.act( incidence, this );
3698 } 3704 }
3699} 3705}
3700 3706
3701void CalendarView::deleteIncidence() 3707void CalendarView::deleteIncidence()
3702{ 3708{
3703 Incidence *incidence = currentSelection(); 3709 Incidence *incidence = currentSelection();
3704 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3710 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3705 if ( incidence ) { 3711 if ( incidence ) {
3706 deleteIncidence(incidence); 3712 deleteIncidence(incidence);
3707 } 3713 }
3708} 3714}
3709 3715
3710void CalendarView::showIncidence(Incidence *incidence) 3716void CalendarView::showIncidence(Incidence *incidence)
3711{ 3717{
3712 if ( incidence ) { 3718 if ( incidence ) {
3713 ShowIncidenceVisitor v; 3719 ShowIncidenceVisitor v;
3714 v.act( incidence, this ); 3720 v.act( incidence, this );
3715 } 3721 }
3716} 3722}
3717 3723
3718void CalendarView::editIncidence(Incidence *incidence) 3724void CalendarView::editIncidence(Incidence *incidence)
3719{ 3725{
3720 if ( incidence ) { 3726 if ( incidence ) {
3721 3727
3722 EditIncidenceVisitor v; 3728 EditIncidenceVisitor v;
3723 v.act( incidence, this ); 3729 v.act( incidence, this );
3724 3730
3725 } 3731 }
3726} 3732}
3727 3733
3728void CalendarView::deleteIncidence(Incidence *incidence) 3734void CalendarView::deleteIncidence(Incidence *incidence)
3729{ 3735{
3730 //qDebug(" CalendarView::deleteIncidence "); 3736 //qDebug(" CalendarView::deleteIncidence ");
3731 if ( incidence ) { 3737 if ( incidence ) {
3732 DeleteIncidenceVisitor v; 3738 DeleteIncidenceVisitor v;
3733 v.act( incidence, this ); 3739 v.act( incidence, this );
3734 } 3740 }
3735} 3741}
3736 3742
3737 3743
3738void CalendarView::lookForOutgoingMessages() 3744void CalendarView::lookForOutgoingMessages()
3739{ 3745{
3740 OutgoingDialog *ogd = mDialogManager->outgoingDialog(); 3746 OutgoingDialog *ogd = mDialogManager->outgoingDialog();
3741 ogd->loadMessages(); 3747 ogd->loadMessages();
3742} 3748}
3743 3749
3744void CalendarView::lookForIncomingMessages() 3750void CalendarView::lookForIncomingMessages()
3745{ 3751{
3746 IncomingDialog *icd = mDialogManager->incomingDialog(); 3752 IncomingDialog *icd = mDialogManager->incomingDialog();
3747 icd->retrieve(); 3753 icd->retrieve();
3748} 3754}
3749 3755
3750bool CalendarView::removeCompletedSubTodos( Todo* t ) 3756bool CalendarView::removeCompletedSubTodos( Todo* t )
3751{ 3757{
3752 bool deleteTodo = true; 3758 bool deleteTodo = true;
3753 QPtrList<Incidence> subTodos; 3759 QPtrList<Incidence> subTodos;
3754 Incidence *aTodo; 3760 Incidence *aTodo;
3755 subTodos = t->relations(); 3761 subTodos = t->relations();
3756 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { 3762 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
3757 if (! removeCompletedSubTodos( (Todo*) aTodo )) 3763 if (! removeCompletedSubTodos( (Todo*) aTodo ))
3758 deleteTodo = false; 3764 deleteTodo = false;
3759 } 3765 }
3760 if ( deleteTodo ) { 3766 if ( deleteTodo ) {
3761 if ( t->isCompleted() ) { 3767 if ( t->isCompleted() ) {
3762 checkExternalId( t ); 3768 checkExternalId( t );
3763 mCalendar->deleteTodo( t ); 3769 mCalendar->deleteTodo( t );
3764 changeTodoDisplay( t,KOGlobals::EVENTDELETED ); 3770 changeTodoDisplay( t,KOGlobals::EVENTDELETED );
3765 } 3771 }
3766 else 3772 else
3767 deleteTodo = false; 3773 deleteTodo = false;
3768 } 3774 }
3769 return deleteTodo; 3775 return deleteTodo;
3770 3776
3771} 3777}
3772void CalendarView::purgeCompleted() 3778void CalendarView::purgeCompleted()
3773{ 3779{
3774 int result = KMessageBox::warningContinueCancel(this, 3780 int result = KMessageBox::warningContinueCancel(this,
3775 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); 3781 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge"));
3776 3782
3777 if (result == KMessageBox::Continue) { 3783 if (result == KMessageBox::Continue) {
3778 3784
3779 QPtrList<Todo> todoCal; 3785 QPtrList<Todo> todoCal;
3780 QPtrList<Todo> rootTodos; 3786 QPtrList<Todo> rootTodos;
3781 //QPtrList<Incidence> rel; 3787 //QPtrList<Incidence> rel;
3782 Todo *aTodo;//, *rTodo; 3788 Todo *aTodo;//, *rTodo;
3783 Incidence *rIncidence; 3789 Incidence *rIncidence;
3784 bool childDelete = false; 3790 bool childDelete = false;
3785 bool deletedOne = true; 3791 bool deletedOne = true;
3786 todoCal = calendar()->todos(); 3792 todoCal = calendar()->todos();
3787 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { 3793 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
3788 if ( !aTodo->relatedTo() ) 3794 if ( !aTodo->relatedTo() )
3789 rootTodos.append( aTodo ); 3795 rootTodos.append( aTodo );
3790 } 3796 }
3791 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { 3797 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) {
3792 removeCompletedSubTodos( aTodo ); 3798 removeCompletedSubTodos( aTodo );
3793 } 3799 }
3794 3800
3795 updateView(); 3801 updateView();
3796 } 3802 }
3797} 3803}
3798 3804
3799void CalendarView::slotCalendarChanged() 3805void CalendarView::slotCalendarChanged()
3800{ 3806{
3801 ; 3807 ;
3802} 3808}
3803 3809
3804NavigatorBar *CalendarView::navigatorBar() 3810NavigatorBar *CalendarView::navigatorBar()
3805{ 3811{
3806 return mNavigatorBar; 3812 return mNavigatorBar;
3807} 3813}
3808 3814
3809 3815
3810 3816
3811void CalendarView::keyPressEvent ( QKeyEvent *e) 3817void CalendarView::keyPressEvent ( QKeyEvent *e)
3812{ 3818{
3813 //qDebug(" alendarView::keyPressEvent "); 3819 //qDebug(" alendarView::keyPressEvent ");
3814 e->ignore(); 3820 e->ignore();
3815} 3821}
3816 3822
3817 3823
3818bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) 3824bool CalendarView::sync(KSyncManager* manager, QString filename, int mode)
3819{ 3825{
3820 // mSyncManager = manager; 3826 // mSyncManager = manager;
3821 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { 3827 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) {
3822 qDebug("SyncKDE request detected!"); 3828 qDebug("SyncKDE request detected!");
3823 } 3829 }
3824 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 3830 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
3825 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 3831 mCurrentSyncName = mSyncManager->getCurrentSyncName();
3826 return syncCalendar( filename, mode ); 3832 return syncCalendar( filename, mode );
3827} 3833}
3828bool CalendarView::syncExternal(KSyncManager* manager, QString resource) 3834bool CalendarView::syncExternal(KSyncManager* manager, QString resource)
3829{ 3835{
3830 //mSyncManager = manager; 3836 //mSyncManager = manager;
3831 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 3837 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
3832 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 3838 mCurrentSyncName = mSyncManager->getCurrentSyncName();
3833 if ( resource == "sharp" ) 3839 if ( resource == "sharp" )
3834 syncExternal( 0 ); 3840 syncExternal( 0 );
3835 if ( resource == "phone" ) 3841 if ( resource == "phone" )
3836 syncExternal( 1 ); 3842 syncExternal( 1 );
3837 // pending setmodified 3843 // pending setmodified
3838 return true; 3844 return true;
3839} 3845}
3840void CalendarView::setSyncManager(KSyncManager* manager) 3846void CalendarView::setSyncManager(KSyncManager* manager)
3841{ 3847{
3842 mSyncManager = manager; 3848 mSyncManager = manager;
3843} 3849}
3844 3850
3845void CalendarView::removeSyncInfo( QString syncProfile) 3851void CalendarView::removeSyncInfo( QString syncProfile)
3846{ 3852{
3847 qDebug("removeSyncInfo for profile %s ", syncProfile.latin1()); 3853 qDebug("removeSyncInfo for profile %s ", syncProfile.latin1());
3848 mCalendar->removeSyncInfo( syncProfile ); 3854 mCalendar->removeSyncInfo( syncProfile );
3849 3855
3850} 3856}
3851 3857
3852void CalendarView::undo_delete() 3858void CalendarView::undo_delete()
3853{ 3859{
3854 //qDebug("undo_delete() "); 3860 //qDebug("undo_delete() ");
3855 Incidence* undo = mCalendar->undoIncidence(); 3861 Incidence* undo = mCalendar->undoIncidence();
3856 if ( !undo ) { 3862 if ( !undo ) {
3857 KMessageBox::sorry(this,i18n("There is nothing to undo!"), 3863 KMessageBox::sorry(this,i18n("There is nothing to undo!"),
3858 i18n("KO/Pi")); 3864 i18n("KO/Pi"));
3859 return; 3865 return;
3860 } 3866 }
3861 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + 3867 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) +
3862 i18n("\nAre you sure you want\nto restore this?"), 3868 i18n("\nAre you sure you want\nto restore this?"),
3863 i18n("KO/Pi Confirmation"),i18n("Restore"))) { 3869 i18n("KO/Pi Confirmation"),i18n("Restore"))) {
3864 mCalendar->undoDeleteIncidence(); 3870 mCalendar->undoDeleteIncidence();
3865 updateView(); 3871 updateView();
3866 } 3872 }
3867} 3873}