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