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