summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2004-10-17 16:06:42 (UTC)
committer zautrix <zautrix>2004-10-17 16:06:42 (UTC)
commitd92f58ffa1937af8a4240b9d235da15f5f352769 (patch) (unidiff)
tree48768599988f33c7f20017a76d05e919fa77ac51 /korganizer
parent711c4c06a7d1a52b97fd24efa3586543f46cc6d7 (diff)
downloadkdepimpi-d92f58ffa1937af8a4240b9d235da15f5f352769.zip
kdepimpi-d92f58ffa1937af8a4240b9d235da15f5f352769.tar.gz
kdepimpi-d92f58ffa1937af8a4240b9d235da15f5f352769.tar.bz2
KDE sync fixes
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 1f8ad5b..f727cd4 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,2052 +1,2060 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Requires the Qt and KDE widget libraries, available at no cost at 4 Requires the Qt and KDE widget libraries, available at no cost at
5 http://www.troll.no and http://www.kde.org respectively 5 http://www.troll.no and http://www.kde.org respectively
6 6
7 Copyright (c) 1997, 1998, 1999 7 Copyright (c) 1997, 1998, 1999
8 Preston Brown (preston.brown@yale.edu) 8 Preston Brown (preston.brown@yale.edu)
9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) 9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl)
10 Ian Dawes (iadawes@globalserve.net) 10 Ian Dawes (iadawes@globalserve.net)
11 Laszlo Boloni (boloni@cs.purdue.edu) 11 Laszlo Boloni (boloni@cs.purdue.edu)
12 12
13 Copyright (c) 2000, 2001, 2002 13 Copyright (c) 2000, 2001, 2002
14 Cornelius Schumacher <schumacher@kde.org> 14 Cornelius Schumacher <schumacher@kde.org>
15 15
16 This program is free software; you can redistribute it and/or modify 16 This program is free software; you can redistribute it and/or modify
17 it under the terms of the GNU General Public License as published by 17 it under the terms of the GNU General Public License as published by
18 the Free Software Foundation; either version 2 of the License, or 18 the Free Software Foundation; either version 2 of the License, or
19 (at your option) any later version. 19 (at your option) any later version.
20 20
21 This program is distributed in the hope that it will be useful, 21 This program is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of 22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
24 GNU General Public License for more details. 24 GNU General Public License for more details.
25 25
26 You should have received a copy of the GNU General Public License 26 You should have received a copy of the GNU General Public License
27 along with this program; if not, write to the Free Software 27 along with this program; if not, write to the Free Software
28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29*/ 29*/
30 30
31#include <stdlib.h> 31#include <stdlib.h>
32 32
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qradiobutton.h> 34#include <qradiobutton.h>
35#include <qbuttongroup.h> 35#include <qbuttongroup.h>
36#include <qlayout.h> 36#include <qlayout.h>
37#include <qclipboard.h> 37#include <qclipboard.h>
38#include <qcursor.h> 38#include <qcursor.h>
39#include <qmessagebox.h> 39#include <qmessagebox.h>
40#include <qprogressbar.h> 40#include <qprogressbar.h>
41#include <qmultilineedit.h> 41#include <qmultilineedit.h>
42#include <qtimer.h> 42#include <qtimer.h>
43#include <qwidgetstack.h> 43#include <qwidgetstack.h>
44#include <qptrlist.h> 44#include <qptrlist.h>
45#include <qregexp.h> 45#include <qregexp.h>
46#include <qgroupbox.h> 46#include <qgroupbox.h>
47#include <qfile.h> 47#include <qfile.h>
48#include <qdir.h> 48#include <qdir.h>
49#ifndef KORG_NOSPLITTER 49#ifndef KORG_NOSPLITTER
50#include <qsplitter.h> 50#include <qsplitter.h>
51#endif 51#endif
52 52
53#include <kglobal.h> 53#include <kglobal.h>
54#include <kdebug.h> 54#include <kdebug.h>
55#include <kstandarddirs.h> 55#include <kstandarddirs.h>
56#include <kfiledialog.h> 56#include <kfiledialog.h>
57#include <kmessagebox.h> 57#include <kmessagebox.h>
58#include <knotifyclient.h> 58#include <knotifyclient.h>
59#include <kconfig.h> 59#include <kconfig.h>
60 60
61#include <libkdepim/ksyncprefsdialog.h> 61#include <libkdepim/ksyncprefsdialog.h>
62#include <krun.h> 62#include <krun.h>
63#include <kdirwatch.h> 63#include <kdirwatch.h>
64#include <libkdepim/kdatepicker.h> 64#include <libkdepim/kdatepicker.h>
65#include <libkdepim/ksyncprofile.h> 65#include <libkdepim/ksyncprofile.h>
66#include <libkdepim/kpimglobalprefs.h> 66#include <libkdepim/kpimglobalprefs.h>
67 67
68#include <libkcal/vcaldrag.h> 68#include <libkcal/vcaldrag.h>
69#include <libkcal/icaldrag.h> 69#include <libkcal/icaldrag.h>
70#include <libkcal/icalformat.h> 70#include <libkcal/icalformat.h>
71#include <libkcal/vcalformat.h> 71#include <libkcal/vcalformat.h>
72#include <libkcal/scheduler.h> 72#include <libkcal/scheduler.h>
73#include <libkcal/calendarlocal.h> 73#include <libkcal/calendarlocal.h>
74#include <libkcal/journal.h> 74#include <libkcal/journal.h>
75#include <libkcal/calfilter.h> 75#include <libkcal/calfilter.h>
76#include <libkcal/attendee.h> 76#include <libkcal/attendee.h>
77#include <libkcal/dndfactory.h> 77#include <libkcal/dndfactory.h>
78#include <libkcal/freebusy.h> 78#include <libkcal/freebusy.h>
79#include <libkcal/filestorage.h> 79#include <libkcal/filestorage.h>
80#include <libkcal/calendarresources.h> 80#include <libkcal/calendarresources.h>
81#include <libkcal/qtopiaformat.h> 81#include <libkcal/qtopiaformat.h>
82#include "../kalarmd/alarmdialog.h" 82#include "../kalarmd/alarmdialog.h"
83 83
84#ifndef DESKTOP_VERSION 84#ifndef DESKTOP_VERSION
85#include <libkcal/sharpformat.h> 85#include <libkcal/sharpformat.h>
86#include <externalapphandler.h> 86#include <externalapphandler.h>
87#endif 87#endif
88#include <libkcal/phoneformat.h> 88#include <libkcal/phoneformat.h>
89#ifndef KORG_NOMAIL 89#ifndef KORG_NOMAIL
90#include "komailclient.h" 90#include "komailclient.h"
91#endif 91#endif
92#ifndef KORG_NOPRINTER 92#ifndef KORG_NOPRINTER
93#include "calprinter.h" 93#include "calprinter.h"
94#endif 94#endif
95#ifndef KORG_NOPLUGINS 95#ifndef KORG_NOPLUGINS
96#include "kocore.h" 96#include "kocore.h"
97#endif 97#endif
98#include "koeventeditor.h" 98#include "koeventeditor.h"
99#include "kotodoeditor.h" 99#include "kotodoeditor.h"
100#include "koprefs.h" 100#include "koprefs.h"
101#include "koeventviewerdialog.h" 101#include "koeventviewerdialog.h"
102#include "publishdialog.h" 102#include "publishdialog.h"
103#include "kofilterview.h" 103#include "kofilterview.h"
104#include "koglobals.h" 104#include "koglobals.h"
105#include "koviewmanager.h" 105#include "koviewmanager.h"
106#include "koagendaview.h" 106#include "koagendaview.h"
107#include "kodialogmanager.h" 107#include "kodialogmanager.h"
108#include "outgoingdialog.h" 108#include "outgoingdialog.h"
109#include "incomingdialog.h" 109#include "incomingdialog.h"
110#include "statusdialog.h" 110#include "statusdialog.h"
111#include "kdatenavigator.h" 111#include "kdatenavigator.h"
112#include "kotodoview.h" 112#include "kotodoview.h"
113#include "datenavigator.h" 113#include "datenavigator.h"
114#include "resourceview.h" 114#include "resourceview.h"
115#include "navigatorbar.h" 115#include "navigatorbar.h"
116#include "searchdialog.h" 116#include "searchdialog.h"
117#include "mainwindow.h" 117#include "mainwindow.h"
118 118
119#include "calendarview.h" 119#include "calendarview.h"
120#ifndef DESKTOP_VERSION 120#ifndef DESKTOP_VERSION
121#include <qtopia/alarmserver.h> 121#include <qtopia/alarmserver.h>
122#endif 122#endif
123#ifndef _WIN32_ 123#ifndef _WIN32_
124#include <stdlib.h> 124#include <stdlib.h>
125#include <stdio.h> 125#include <stdio.h>
126#include <unistd.h> 126#include <unistd.h>
127#else 127#else
128#include <qprocess.h> 128#include <qprocess.h>
129#endif 129#endif
130 130
131#ifdef DESKTOP_VERSION 131#ifdef DESKTOP_VERSION
132#include <kabc/stdaddressbook.h> 132#include <kabc/stdaddressbook.h>
133#endif 133#endif
134using namespace KOrg; 134using namespace KOrg;
135using namespace KCal; 135using namespace KCal;
136extern int globalFlagBlockAgenda; 136extern int globalFlagBlockAgenda;
137extern int globalFlagBlockStartup; 137extern int globalFlagBlockStartup;
138 138
139 139
140 140
141class KOBeamPrefs : public QDialog 141class KOBeamPrefs : public QDialog
142{ 142{
143 public: 143 public:
144 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : 144 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) :
145 QDialog( parent, name, true ) 145 QDialog( parent, name, true )
146 { 146 {
147 setCaption( i18n("Beam Options") ); 147 setCaption( i18n("Beam Options") );
148 QVBoxLayout* lay = new QVBoxLayout( this ); 148 QVBoxLayout* lay = new QVBoxLayout( this );
149 lay->setSpacing( 3 ); 149 lay->setSpacing( 3 );
150 lay->setMargin( 3 ); 150 lay->setMargin( 3 );
151 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); 151 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this );
152 lay->addWidget( format ); 152 lay->addWidget( format );
153 format->setExclusive ( true ) ; 153 format->setExclusive ( true ) ;
154 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); 154 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this );
155 lay->addWidget( time ); time->setExclusive ( true ) ; 155 lay->addWidget( time ); time->setExclusive ( true ) ;
156 vcal = new QRadioButton(" vCalendar ", format ); 156 vcal = new QRadioButton(" vCalendar ", format );
157 ical = new QRadioButton(" iCalendar ", format ); 157 ical = new QRadioButton(" iCalendar ", format );
158 vcal->setChecked( true ); 158 vcal->setChecked( true );
159 tz = new QRadioButton(i18n(" With timezone "), time ); 159 tz = new QRadioButton(i18n(" With timezone "), time );
160 local = new QRadioButton(i18n(" Local time "), time ); 160 local = new QRadioButton(i18n(" Local time "), time );
161 tz->setChecked( true ); 161 tz->setChecked( true );
162 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); 162 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this );
163 lay->addWidget( ok ); 163 lay->addWidget( ok );
164 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 164 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
165 lay->addWidget( cancel ); 165 lay->addWidget( cancel );
166 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 166 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
167 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 167 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
168 resize( 200, 200 ); 168 resize( 200, 200 );
169 } 169 }
170 170
171 bool beamVcal() { return vcal->isChecked(); } 171 bool beamVcal() { return vcal->isChecked(); }
172 bool beamLocal() { return local->isChecked(); } 172 bool beamLocal() { return local->isChecked(); }
173private: 173private:
174 QRadioButton* vcal, *ical, *local, *tz; 174 QRadioButton* vcal, *ical, *local, *tz;
175}; 175};
176class KOCatPrefs : public QDialog 176class KOCatPrefs : public QDialog
177{ 177{
178 public: 178 public:
179 KOCatPrefs( QWidget *parent=0, const char *name=0 ) : 179 KOCatPrefs( QWidget *parent=0, const char *name=0 ) :
180 QDialog( parent, name, true ) 180 QDialog( parent, name, true )
181 { 181 {
182 setCaption( i18n("Manage new Categories") ); 182 setCaption( i18n("Manage new Categories") );
183 QVBoxLayout* lay = new QVBoxLayout( this ); 183 QVBoxLayout* lay = new QVBoxLayout( this );
184 lay->setSpacing( 3 ); 184 lay->setSpacing( 3 );
185 lay->setMargin( 3 ); 185 lay->setMargin( 3 );
186 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); 186 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this );
187 lay->addWidget( lab ); 187 lay->addWidget( lab );
188 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 188 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
189 lay->addWidget( format ); 189 lay->addWidget( format );
190 format->setExclusive ( true ) ; 190 format->setExclusive ( true ) ;
191 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 191 addCatBut = new QRadioButton(i18n("Add to category list"), format );
192 new QRadioButton(i18n("Remove from Events/Todos"), format ); 192 new QRadioButton(i18n("Remove from Events/Todos"), format );
193 addCatBut->setChecked( true ); 193 addCatBut->setChecked( true );
194 QPushButton * ok = new QPushButton( i18n("OK"), this ); 194 QPushButton * ok = new QPushButton( i18n("OK"), this );
195 lay->addWidget( ok ); 195 lay->addWidget( ok );
196 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 196 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
197 lay->addWidget( cancel ); 197 lay->addWidget( cancel );
198 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 198 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
199 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 199 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
200 resize( 200, 200 ); 200 resize( 200, 200 );
201 } 201 }
202 202
203 bool addCat() { return addCatBut->isChecked(); } 203 bool addCat() { return addCatBut->isChecked(); }
204private: 204private:
205 QRadioButton* addCatBut; 205 QRadioButton* addCatBut;
206}; 206};
207 207
208 208
209 209
210CalendarView::CalendarView( CalendarResources *calendar, 210CalendarView::CalendarView( CalendarResources *calendar,
211 QWidget *parent, const char *name ) 211 QWidget *parent, const char *name )
212 : CalendarViewBase( parent, name ), 212 : CalendarViewBase( parent, name ),
213 mCalendar( calendar ), 213 mCalendar( calendar ),
214 mResourceManager( calendar->resourceManager() ) 214 mResourceManager( calendar->resourceManager() )
215{ 215{
216 216
217 mEventEditor = 0; 217 mEventEditor = 0;
218 mTodoEditor = 0; 218 mTodoEditor = 0;
219 219
220 init(); 220 init();
221} 221}
222 222
223CalendarView::CalendarView( Calendar *calendar, 223CalendarView::CalendarView( Calendar *calendar,
224 QWidget *parent, const char *name ) 224 QWidget *parent, const char *name )
225 : CalendarViewBase( parent, name ), 225 : CalendarViewBase( parent, name ),
226 mCalendar( calendar ), 226 mCalendar( calendar ),
227 mResourceManager( 0 ) 227 mResourceManager( 0 )
228{ 228{
229 229
230 mEventEditor = 0; 230 mEventEditor = 0;
231 mTodoEditor = 0; 231 mTodoEditor = 0;
232 init();} 232 init();}
233 233
234void CalendarView::init() 234void CalendarView::init()
235{ 235{
236 beamDialog = new KOBeamPrefs(); 236 beamDialog = new KOBeamPrefs();
237 mDatePickerMode = 0; 237 mDatePickerMode = 0;
238 mCurrentSyncDevice = ""; 238 mCurrentSyncDevice = "";
239 writeLocale(); 239 writeLocale();
240 mViewManager = new KOViewManager( this ); 240 mViewManager = new KOViewManager( this );
241 mDialogManager = new KODialogManager( this ); 241 mDialogManager = new KODialogManager( this );
242 mEventViewerDialog = 0; 242 mEventViewerDialog = 0;
243 mModified = false; 243 mModified = false;
244 mReadOnly = false; 244 mReadOnly = false;
245 mSelectedIncidence = 0; 245 mSelectedIncidence = 0;
246 mCalPrinter = 0; 246 mCalPrinter = 0;
247 mFilters.setAutoDelete(true); 247 mFilters.setAutoDelete(true);
248 248
249 mCalendar->registerObserver( this ); 249 mCalendar->registerObserver( this );
250 // TODO: Make sure that view is updated, when calendar is changed. 250 // TODO: Make sure that view is updated, when calendar is changed.
251 251
252 mStorage = new FileStorage( mCalendar ); 252 mStorage = new FileStorage( mCalendar );
253 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 253 mNavigator = new DateNavigator( this, "datevav", mViewManager );
254 254
255 QBoxLayout *topLayout = (QBoxLayout*)layout(); 255 QBoxLayout *topLayout = (QBoxLayout*)layout();
256#ifndef KORG_NOSPLITTER 256#ifndef KORG_NOSPLITTER
257 // create the main layout frames. 257 // create the main layout frames.
258 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 258 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
259 topLayout->addWidget(mPanner); 259 topLayout->addWidget(mPanner);
260 260
261 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 261 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
262 "CalendarView::LeftFrame"); 262 "CalendarView::LeftFrame");
263 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 263 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
264 264
265 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, 265 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE,
266 "CalendarView::DateNavigator", QDate::currentDate() ); 266 "CalendarView::DateNavigator", QDate::currentDate() );
267 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 267 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
268 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 268 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
269 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 269 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
270 270
271#ifdef KORG_NORESOURCEVIEW 271#ifdef KORG_NORESOURCEVIEW
272 mResourceView = 0; 272 mResourceView = 0;
273#else 273#else
274 if ( mResourceManager ) { 274 if ( mResourceManager ) {
275 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 275 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
276 mResourceView->updateView(); 276 mResourceView->updateView();
277 connect( mResourceView, SIGNAL( resourcesChanged() ), 277 connect( mResourceView, SIGNAL( resourcesChanged() ),
278 SLOT( updateView() ) ); 278 SLOT( updateView() ) );
279 } else { 279 } else {
280 mResourceView = 0; 280 mResourceView = 0;
281 } 281 }
282#endif 282#endif
283 QWidget *rightBox = new QWidget( mPanner ); 283 QWidget *rightBox = new QWidget( mPanner );
284 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 284 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
285 285
286 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 286 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
287 rightLayout->addWidget( mNavigatorBar ); 287 rightLayout->addWidget( mNavigatorBar );
288 288
289 mRightFrame = new QWidgetStack( rightBox ); 289 mRightFrame = new QWidgetStack( rightBox );
290 rightLayout->addWidget( mRightFrame, 1 ); 290 rightLayout->addWidget( mRightFrame, 1 );
291 291
292 mLeftFrame = mLeftSplitter; 292 mLeftFrame = mLeftSplitter;
293#else 293#else
294 QWidget *mainBox = new QWidget( this ); 294 QWidget *mainBox = new QWidget( this );
295 QWidget *leftFrame = new QWidget( mainBox ); 295 QWidget *leftFrame = new QWidget( mainBox );
296 296
297 QBoxLayout * mainBoxLayout; 297 QBoxLayout * mainBoxLayout;
298 QBoxLayout * leftFrameLayout; 298 QBoxLayout * leftFrameLayout;
299 if ( KOPrefs::instance()->mVerticalScreen ) { 299 if ( KOPrefs::instance()->mVerticalScreen ) {
300 mainBoxLayout = new QVBoxLayout(mainBox); 300 mainBoxLayout = new QVBoxLayout(mainBox);
301 leftFrameLayout = new QHBoxLayout(leftFrame ); 301 leftFrameLayout = new QHBoxLayout(leftFrame );
302 } else { 302 } else {
303 mainBoxLayout = new QHBoxLayout(mainBox); 303 mainBoxLayout = new QHBoxLayout(mainBox);
304 leftFrameLayout = new QVBoxLayout(leftFrame ); 304 leftFrameLayout = new QVBoxLayout(leftFrame );
305 } 305 }
306 topLayout->addWidget( mainBox ); 306 topLayout->addWidget( mainBox );
307 mainBoxLayout->addWidget (leftFrame); 307 mainBoxLayout->addWidget (leftFrame);
308 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, 308 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE,
309 "CalendarView::DateNavigator", QDate::currentDate()); 309 "CalendarView::DateNavigator", QDate::currentDate());
310 // mDateNavigator->blockSignals( true ); 310 // mDateNavigator->blockSignals( true );
311 leftFrameLayout->addWidget( mDateNavigator ); 311 leftFrameLayout->addWidget( mDateNavigator );
312 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); 312 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView");
313 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall"); 313 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall");
314 314
315 if ( QApplication::desktop()->width() < 480 ) { 315 if ( QApplication::desktop()->width() < 480 ) {
316 leftFrameLayout->addWidget(mFilterView); 316 leftFrameLayout->addWidget(mFilterView);
317 leftFrameLayout->addWidget(mTodoList, 2 ); 317 leftFrameLayout->addWidget(mTodoList, 2 );
318 318
319 } else { 319 } else {
320 leftFrameLayout->addWidget(mTodoList,2 ); 320 leftFrameLayout->addWidget(mTodoList,2 );
321 leftFrameLayout->addWidget(mFilterView ); 321 leftFrameLayout->addWidget(mFilterView );
322 } 322 }
323 mFilterView->hide(); 323 mFilterView->hide();
324 QWidget *rightBox = new QWidget( mainBox ); 324 QWidget *rightBox = new QWidget( mainBox );
325 mainBoxLayout->addWidget ( rightBox, 10 ); 325 mainBoxLayout->addWidget ( rightBox, 10 );
326 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 326 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
327 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 327 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
328 mRightFrame = new QWidgetStack( rightBox ); 328 mRightFrame = new QWidgetStack( rightBox );
329 rightLayout->addWidget( mNavigatorBar ); 329 rightLayout->addWidget( mNavigatorBar );
330 rightLayout->addWidget( mRightFrame, 10 ); 330 rightLayout->addWidget( mRightFrame, 10 );
331 331
332 mLeftFrame = leftFrame; 332 mLeftFrame = leftFrame;
333 if ( KOPrefs::instance()->mVerticalScreen ) { 333 if ( KOPrefs::instance()->mVerticalScreen ) {
334 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 334 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
335 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 335 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
336 } else { 336 } else {
337 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 337 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
338 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 338 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
339 } 339 }
340 340
341 //qDebug("Calendarview Size %d %d ", width(), height()); 341 //qDebug("Calendarview Size %d %d ", width(), height());
342#endif 342#endif
343 343
344 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 344 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
345 SLOT( showDates( const KCal::DateList & ) ) ); 345 SLOT( showDates( const KCal::DateList & ) ) );
346 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 346 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
347 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 347 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
348 348
349 connect( mNavigatorBar, SIGNAL( goPrevYear() ), 349 connect( mNavigatorBar, SIGNAL( goPrevYear() ),
350 mNavigator, SLOT( selectPreviousYear() ) ); 350 mNavigator, SLOT( selectPreviousYear() ) );
351 connect( mNavigatorBar, SIGNAL( goNextYear() ), 351 connect( mNavigatorBar, SIGNAL( goNextYear() ),
352 mNavigator, SLOT( selectNextYear() ) ); 352 mNavigator, SLOT( selectNextYear() ) );
353 connect( mNavigatorBar, SIGNAL( goPrevMonth() ), 353 connect( mNavigatorBar, SIGNAL( goPrevMonth() ),
354 mNavigator, SLOT( selectPreviousMonth() ) ); 354 mNavigator, SLOT( selectPreviousMonth() ) );
355 connect( mNavigatorBar, SIGNAL( goNextMonth() ), 355 connect( mNavigatorBar, SIGNAL( goNextMonth() ),
356 mNavigator, SLOT( selectNextMonth() ) ); 356 mNavigator, SLOT( selectNextMonth() ) );
357 357
358 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 358 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
359 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); 359 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) );
360 360
361 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 361 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
362 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 362 mNavigator, SLOT( selectWeek( const QDate & ) ) );
363 363
364 connect( mDateNavigator, SIGNAL( goPrevYear() ), 364 connect( mDateNavigator, SIGNAL( goPrevYear() ),
365 mNavigator, SLOT( selectPreviousYear() ) ); 365 mNavigator, SLOT( selectPreviousYear() ) );
366 connect( mDateNavigator, SIGNAL( goNextYear() ), 366 connect( mDateNavigator, SIGNAL( goNextYear() ),
367 mNavigator, SLOT( selectNextYear() ) ); 367 mNavigator, SLOT( selectNextYear() ) );
368 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 368 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
369 mNavigator, SLOT( selectPreviousMonth() ) ); 369 mNavigator, SLOT( selectPreviousMonth() ) );
370 connect( mDateNavigator, SIGNAL( goNextMonth() ), 370 connect( mDateNavigator, SIGNAL( goNextMonth() ),
371 mNavigator, SLOT( selectNextMonth() ) ); 371 mNavigator, SLOT( selectNextMonth() ) );
372 372
373 connect( mDateNavigator, SIGNAL( goPrevious() ), 373 connect( mDateNavigator, SIGNAL( goPrevious() ),
374 mNavigator, SLOT( selectPrevious() ) ); 374 mNavigator, SLOT( selectPrevious() ) );
375 connect( mDateNavigator, SIGNAL( goNext() ), 375 connect( mDateNavigator, SIGNAL( goNext() ),
376 mNavigator, SLOT( selectNext() ) ); 376 mNavigator, SLOT( selectNext() ) );
377 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 377 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
378 mNavigator, SLOT( slotMonthSelect( int ) ) ); 378 mNavigator, SLOT( slotMonthSelect( int ) ) );
379 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), 379 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ),
380 mNavigator, SLOT( slotMonthSelect( int ) ) ); 380 mNavigator, SLOT( slotMonthSelect( int ) ) );
381 381
382 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 382 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
383 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 383 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
384 384
385 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), 385 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ),
386 SLOT( eventAdded( Event *) ) ); 386 SLOT( eventAdded( Event *) ) );
387 387
388 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 388 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
389 389
390 connect( this, SIGNAL( configChanged() ), 390 connect( this, SIGNAL( configChanged() ),
391 mDateNavigator, SLOT( updateConfig() ) ); 391 mDateNavigator, SLOT( updateConfig() ) );
392 392
393 connect( mTodoList, SIGNAL( newTodoSignal() ), 393 connect( mTodoList, SIGNAL( newTodoSignal() ),
394 SLOT( newTodo() ) ); 394 SLOT( newTodo() ) );
395 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 395 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
396 SLOT( newSubTodo( Todo * ) ) ); 396 SLOT( newSubTodo( Todo * ) ) );
397 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 397 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
398 SLOT( editTodo( Todo * ) ) ); 398 SLOT( editTodo( Todo * ) ) );
399 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 399 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
400 SLOT( showTodo( Todo *) ) ); 400 SLOT( showTodo( Todo *) ) );
401 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 401 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
402 SLOT( deleteTodo( Todo *) ) ); 402 SLOT( deleteTodo( Todo *) ) );
403 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 403 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
404 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 404 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
405 SLOT( purgeCompleted() ) ); 405 SLOT( purgeCompleted() ) );
406 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 406 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
407 SIGNAL( todoModified( Todo *, int ) ) ); 407 SIGNAL( todoModified( Todo *, int ) ) );
408 408
409 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 409 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
410 this, SLOT ( cloneIncidence( Incidence * ) ) ); 410 this, SLOT ( cloneIncidence( Incidence * ) ) );
411 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 411 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
412 this, SLOT (cancelIncidence( Incidence * ) ) ); 412 this, SLOT (cancelIncidence( Incidence * ) ) );
413 413
414 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 414 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
415 this, SLOT ( moveIncidence( Incidence * ) ) ); 415 this, SLOT ( moveIncidence( Incidence * ) ) );
416 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 416 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
417 this, SLOT ( beamIncidence( Incidence * ) ) ); 417 this, SLOT ( beamIncidence( Incidence * ) ) );
418 418
419 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 419 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
420 this, SLOT ( todo_unsub( Todo * ) ) ); 420 this, SLOT ( todo_unsub( Todo * ) ) );
421 421
422 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 422 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
423 this, SLOT ( todo_resub( Todo *,Todo * ) ) ); 423 this, SLOT ( todo_resub( Todo *,Todo * ) ) );
424 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 424 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
425 SLOT( updateTodo( Todo *, int ) ) ); 425 SLOT( updateTodo( Todo *, int ) ) );
426 connect( this, SIGNAL( todoModified( Todo *, int )), this, 426 connect( this, SIGNAL( todoModified( Todo *, int )), this,
427 SLOT( changeTodoDisplay( Todo *, int ) ) ); 427 SLOT( changeTodoDisplay( Todo *, int ) ) );
428 428
429 429
430 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 430 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
431 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 431 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
432 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 432 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
433 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 433 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
434 434
435 435
436 436
437 437
438 438
439 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 439 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
440 SLOT(checkClipboard())); 440 SLOT(checkClipboard()));
441 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 441 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
442 SLOT( processTodoListSelection( Incidence * ) ) ); 442 SLOT( processTodoListSelection( Incidence * ) ) );
443 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 443 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
444 444
445 // kdDebug() << "CalendarView::CalendarView() done" << endl; 445 // kdDebug() << "CalendarView::CalendarView() done" << endl;
446 446
447 mDateFrame = new QVBox(0,0,WType_Popup); 447 mDateFrame = new QVBox(0,0,WType_Popup);
448 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 448 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
449 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 449 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
450 mDateFrame->setLineWidth(3); 450 mDateFrame->setLineWidth(3);
451 mDateFrame->hide(); 451 mDateFrame->hide();
452 mDateFrame->setCaption( i18n( "Pick a date to display")); 452 mDateFrame->setCaption( i18n( "Pick a date to display"));
453 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 453 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
454 454
455 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 455 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
456 456
457 mEventEditor = mDialogManager->getEventEditor(); 457 mEventEditor = mDialogManager->getEventEditor();
458 mTodoEditor = mDialogManager->getTodoEditor(); 458 mTodoEditor = mDialogManager->getTodoEditor();
459 459
460 mFlagEditDescription = false; 460 mFlagEditDescription = false;
461 461
462 mSuspendTimer = new QTimer( this ); 462 mSuspendTimer = new QTimer( this );
463 mAlarmTimer = new QTimer( this ); 463 mAlarmTimer = new QTimer( this );
464 mRecheckAlarmTimer = new QTimer( this ); 464 mRecheckAlarmTimer = new QTimer( this );
465 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 465 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
466 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 466 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
467 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 467 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
468 mAlarmDialog = new AlarmDialog( this ); 468 mAlarmDialog = new AlarmDialog( this );
469 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 469 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
470 mAlarmDialog->setServerNotification( false ); 470 mAlarmDialog->setServerNotification( false );
471 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 471 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
472 472
473 473
474#ifndef DESKTOP_VERSION 474#ifndef DESKTOP_VERSION
475//US listen for arriving address resultsets 475//US listen for arriving address resultsets
476 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), 476 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)),
477 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 477 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
478#endif 478#endif
479 479
480} 480}
481 481
482 482
483CalendarView::~CalendarView() 483CalendarView::~CalendarView()
484{ 484{
485 // kdDebug() << "~CalendarView()" << endl; 485 // kdDebug() << "~CalendarView()" << endl;
486 //qDebug("CalendarView::~CalendarView() "); 486 //qDebug("CalendarView::~CalendarView() ");
487 delete mDialogManager; 487 delete mDialogManager;
488 delete mViewManager; 488 delete mViewManager;
489 delete mStorage; 489 delete mStorage;
490 delete mDateFrame ; 490 delete mDateFrame ;
491 delete beamDialog; 491 delete beamDialog;
492 //kdDebug() << "~CalendarView() done" << endl; 492 //kdDebug() << "~CalendarView() done" << endl;
493} 493}
494void CalendarView::timerAlarm() 494void CalendarView::timerAlarm()
495{ 495{
496 //qDebug("CalendarView::timerAlarm() "); 496 //qDebug("CalendarView::timerAlarm() ");
497 computeAlarm(mAlarmNotification ); 497 computeAlarm(mAlarmNotification );
498} 498}
499 499
500void CalendarView::suspendAlarm() 500void CalendarView::suspendAlarm()
501{ 501{
502 //qDebug(" CalendarView::suspendAlarm() "); 502 //qDebug(" CalendarView::suspendAlarm() ");
503 computeAlarm(mSuspendAlarmNotification ); 503 computeAlarm(mSuspendAlarmNotification );
504 504
505} 505}
506 506
507void CalendarView::startAlarm( QString mess , QString filename) 507void CalendarView::startAlarm( QString mess , QString filename)
508{ 508{
509 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 509 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
510 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); 510 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
511 511
512} 512}
513 513
514void CalendarView::checkNextTimerAlarm() 514void CalendarView::checkNextTimerAlarm()
515{ 515{
516 mCalendar->checkAlarmForIncidence( 0, true ); 516 mCalendar->checkAlarmForIncidence( 0, true );
517} 517}
518 518
519void CalendarView::computeAlarm( QString msg ) 519void CalendarView::computeAlarm( QString msg )
520{ 520{
521 521
522 QString mess = msg; 522 QString mess = msg;
523 QString mAlarmMessage = mess.mid( 9 ); 523 QString mAlarmMessage = mess.mid( 9 );
524 QString filename = MainWindow::resourcePath(); 524 QString filename = MainWindow::resourcePath();
525 filename += "koalarm.wav"; 525 filename += "koalarm.wav";
526 QString tempfilename; 526 QString tempfilename;
527 if ( mess.left( 13 ) == "suspend_alarm") { 527 if ( mess.left( 13 ) == "suspend_alarm") {
528 bool error = false; 528 bool error = false;
529 int len = mess.mid( 13 ).find("+++"); 529 int len = mess.mid( 13 ).find("+++");
530 if ( len < 2 ) 530 if ( len < 2 )
531 error = true; 531 error = true;
532 else { 532 else {
533 tempfilename = mess.mid( 13, len ); 533 tempfilename = mess.mid( 13, len );
534 if ( !QFile::exists( tempfilename ) ) 534 if ( !QFile::exists( tempfilename ) )
535 error = true; 535 error = true;
536 } 536 }
537 if ( ! error ) { 537 if ( ! error ) {
538 filename = tempfilename; 538 filename = tempfilename;
539 } 539 }
540 mAlarmMessage = mess.mid( 13+len+3 ); 540 mAlarmMessage = mess.mid( 13+len+3 );
541 //qDebug("suspend file %s ",tempfilename.latin1() ); 541 //qDebug("suspend file %s ",tempfilename.latin1() );
542 startAlarm( mAlarmMessage, filename); 542 startAlarm( mAlarmMessage, filename);
543 return; 543 return;
544 } 544 }
545 if ( mess.left( 11 ) == "timer_alarm") { 545 if ( mess.left( 11 ) == "timer_alarm") {
546 //mTimerTime = 0; 546 //mTimerTime = 0;
547 startAlarm( mess.mid( 11 ), filename ); 547 startAlarm( mess.mid( 11 ), filename );
548 return; 548 return;
549 } 549 }
550 if ( mess.left( 10 ) == "proc_alarm") { 550 if ( mess.left( 10 ) == "proc_alarm") {
551 bool error = false; 551 bool error = false;
552 int len = mess.mid( 10 ).find("+++"); 552 int len = mess.mid( 10 ).find("+++");
553 if ( len < 2 ) 553 if ( len < 2 )
554 error = true; 554 error = true;
555 else { 555 else {
556 tempfilename = mess.mid( 10, len ); 556 tempfilename = mess.mid( 10, len );
557 if ( !QFile::exists( tempfilename ) ) 557 if ( !QFile::exists( tempfilename ) )
558 error = true; 558 error = true;
559 } 559 }
560 if ( error ) { 560 if ( error ) {
561 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 561 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
562 mAlarmMessage += mess.mid( 10+len+3+9 ); 562 mAlarmMessage += mess.mid( 10+len+3+9 );
563 } else { 563 } else {
564 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 564 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
565 //qDebug("-----system command %s ",tempfilename.latin1() ); 565 //qDebug("-----system command %s ",tempfilename.latin1() );
566#ifndef _WIN32_ 566#ifndef _WIN32_
567 if ( vfork () == 0 ) { 567 if ( vfork () == 0 ) {
568 execl ( tempfilename.latin1(), 0 ); 568 execl ( tempfilename.latin1(), 0 );
569 return; 569 return;
570 } 570 }
571#else 571#else
572 QProcess* p = new QProcess(); 572 QProcess* p = new QProcess();
573 p->addArgument( tempfilename.latin1() ); 573 p->addArgument( tempfilename.latin1() );
574 p->start(); 574 p->start();
575 return; 575 return;
576#endif 576#endif
577 577
578 return; 578 return;
579 } 579 }
580 580
581 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 581 //qDebug("+++++++system command %s ",tempfilename.latin1() );
582 } 582 }
583 if ( mess.left( 11 ) == "audio_alarm") { 583 if ( mess.left( 11 ) == "audio_alarm") {
584 bool error = false; 584 bool error = false;
585 int len = mess.mid( 11 ).find("+++"); 585 int len = mess.mid( 11 ).find("+++");
586 if ( len < 2 ) 586 if ( len < 2 )
587 error = true; 587 error = true;
588 else { 588 else {
589 tempfilename = mess.mid( 11, len ); 589 tempfilename = mess.mid( 11, len );
590 if ( !QFile::exists( tempfilename ) ) 590 if ( !QFile::exists( tempfilename ) )
591 error = true; 591 error = true;
592 } 592 }
593 if ( ! error ) { 593 if ( ! error ) {
594 filename = tempfilename; 594 filename = tempfilename;
595 } 595 }
596 mAlarmMessage = mess.mid( 11+len+3+9 ); 596 mAlarmMessage = mess.mid( 11+len+3+9 );
597 //qDebug("audio file command %s ",tempfilename.latin1() ); 597 //qDebug("audio file command %s ",tempfilename.latin1() );
598 } 598 }
599 if ( mess.left( 9 ) == "cal_alarm") { 599 if ( mess.left( 9 ) == "cal_alarm") {
600 mAlarmMessage = mess.mid( 9 ) ; 600 mAlarmMessage = mess.mid( 9 ) ;
601 } 601 }
602 602
603 startAlarm( mAlarmMessage, filename ); 603 startAlarm( mAlarmMessage, filename );
604 604
605 605
606} 606}
607 607
608void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 608void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
609{ 609{
610 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 610 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
611 611
612 mSuspendAlarmNotification = noti; 612 mSuspendAlarmNotification = noti;
613 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 613 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
614 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 614 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
615 mSuspendTimer->start( ms , true ); 615 mSuspendTimer->start( ms , true );
616 616
617} 617}
618 618
619void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 619void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
620{ 620{
621 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 621 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
622 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 622 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
623#ifndef DESKTOP_VERSION 623#ifndef DESKTOP_VERSION
624 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); 624 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() );
625#endif 625#endif
626 return; 626 return;
627 } 627 }
628 int maxSec; 628 int maxSec;
629 //maxSec = 5; //testing only 629 //maxSec = 5; //testing only
630 maxSec = 86400+3600; // one day+1hour 630 maxSec = 86400+3600; // one day+1hour
631 mAlarmNotification = noti; 631 mAlarmNotification = noti;
632 int sec = QDateTime::currentDateTime().secsTo( qdt ); 632 int sec = QDateTime::currentDateTime().secsTo( qdt );
633 if ( sec > maxSec ) { 633 if ( sec > maxSec ) {
634 mRecheckAlarmTimer->start( maxSec * 1000 ); 634 mRecheckAlarmTimer->start( maxSec * 1000 );
635 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 635 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
636 return; 636 return;
637 } else { 637 } else {
638 mRecheckAlarmTimer->stop(); 638 mRecheckAlarmTimer->stop();
639 } 639 }
640 //qDebug("Alarm timer started with secs: %d ", sec); 640 //qDebug("Alarm timer started with secs: %d ", sec);
641 mAlarmTimer->start( sec *1000 , true ); 641 mAlarmTimer->start( sec *1000 , true );
642 642
643} 643}
644// called by mRecheckAlarmTimer to get next alarm 644// called by mRecheckAlarmTimer to get next alarm
645// we need this, because a QTimer has only a max range of 25 days 645// we need this, because a QTimer has only a max range of 25 days
646void CalendarView::recheckTimerAlarm() 646void CalendarView::recheckTimerAlarm()
647{ 647{
648 mAlarmTimer->stop(); 648 mAlarmTimer->stop();
649 mRecheckAlarmTimer->stop(); 649 mRecheckAlarmTimer->stop();
650 mCalendar->checkAlarmForIncidence( 0, true ); 650 mCalendar->checkAlarmForIncidence( 0, true );
651} 651}
652void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 652void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
653{ 653{
654 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 654 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
655 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 655 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
656#ifndef DESKTOP_VERSION 656#ifndef DESKTOP_VERSION
657 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 657 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
658#endif 658#endif
659 return; 659 return;
660 } 660 }
661 mAlarmTimer->stop(); 661 mAlarmTimer->stop();
662} 662}
663void CalendarView::selectWeekNum ( int num ) 663void CalendarView::selectWeekNum ( int num )
664{ 664{
665 dateNavigator()->selectWeek( num ); 665 dateNavigator()->selectWeek( num );
666 mViewManager->showWeekView(); 666 mViewManager->showWeekView();
667} 667}
668KOViewManager *CalendarView::viewManager() 668KOViewManager *CalendarView::viewManager()
669{ 669{
670 return mViewManager; 670 return mViewManager;
671} 671}
672 672
673KODialogManager *CalendarView::dialogManager() 673KODialogManager *CalendarView::dialogManager()
674{ 674{
675 return mDialogManager; 675 return mDialogManager;
676} 676}
677 677
678QDate CalendarView::startDate() 678QDate CalendarView::startDate()
679{ 679{
680 DateList dates = mNavigator->selectedDates(); 680 DateList dates = mNavigator->selectedDates();
681 681
682 return dates.first(); 682 return dates.first();
683} 683}
684 684
685QDate CalendarView::endDate() 685QDate CalendarView::endDate()
686{ 686{
687 DateList dates = mNavigator->selectedDates(); 687 DateList dates = mNavigator->selectedDates();
688 688
689 return dates.last(); 689 return dates.last();
690} 690}
691 691
692 692
693void CalendarView::createPrinter() 693void CalendarView::createPrinter()
694{ 694{
695#ifndef KORG_NOPRINTER 695#ifndef KORG_NOPRINTER
696 if (!mCalPrinter) { 696 if (!mCalPrinter) {
697 mCalPrinter = new CalPrinter(this, mCalendar); 697 mCalPrinter = new CalPrinter(this, mCalendar);
698 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 698 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
699 } 699 }
700#endif 700#endif
701} 701}
702 702
703 703
704//KOPrefs::instance()->mWriteBackFile 704//KOPrefs::instance()->mWriteBackFile
705//KOPrefs::instance()->mWriteBackExistingOnly 705//KOPrefs::instance()->mWriteBackExistingOnly
706 706
707// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 707// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
708// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 708// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
709// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 709// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
710// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 710// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
711// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 711// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
712// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 712// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
713 713
714int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 714int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
715{ 715{
716 716
717 //void setZaurusId(int id); 717 //void setZaurusId(int id);
718 // int zaurusId() const; 718 // int zaurusId() const;
719 // void setZaurusUid(int id); 719 // void setZaurusUid(int id);
720 // int zaurusUid() const; 720 // int zaurusUid() const;
721 // void setZaurusStat(int id); 721 // void setZaurusStat(int id);
722 // int zaurusStat() const; 722 // int zaurusStat() const;
723 // 0 equal 723 // 0 equal
724 // 1 take local 724 // 1 take local
725 // 2 take remote 725 // 2 take remote
726 // 3 cancel 726 // 3 cancel
727 QDateTime lastSync = mLastCalendarSync; 727 QDateTime lastSync = mLastCalendarSync;
728 QDateTime localMod = local->lastModified(); 728 QDateTime localMod = local->lastModified();
729 QDateTime remoteMod = remote->lastModified(); 729 QDateTime remoteMod = remote->lastModified();
730 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 730 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
731 bool remCh, locCh; 731 bool remCh, locCh;
732 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 732 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
733 //if ( remCh ) 733 //if ( remCh )
734 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 734 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
735 locCh = ( localMod > mLastCalendarSync ); 735 locCh = ( localMod > mLastCalendarSync );
736 if ( !remCh && ! locCh ) { 736 if ( !remCh && ! locCh ) {
737 //qDebug("both not changed "); 737 //qDebug("both not changed ");
738 lastSync = localMod.addDays(1); 738 lastSync = localMod.addDays(1);
739 if ( mode <= SYNC_PREF_ASK ) 739 if ( mode <= SYNC_PREF_ASK )
740 return 0; 740 return 0;
741 } else { 741 } else {
742 if ( locCh ) { 742 if ( locCh ) {
743 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); 743 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1());
744 lastSync = localMod.addDays( -1 ); 744 lastSync = localMod.addDays( -1 );
745 if ( !remCh ) 745 if ( !remCh )
746 remoteMod = ( lastSync.addDays( -1 ) ); 746 remoteMod = ( lastSync.addDays( -1 ) );
747 } else { 747 } else {
748 //qDebug(" not loc changed "); 748 //qDebug(" not loc changed ");
749 lastSync = localMod.addDays( 1 ); 749 lastSync = localMod.addDays( 1 );
750 if ( remCh ) 750 if ( remCh )
751 remoteMod =( lastSync.addDays( 1 ) ); 751 remoteMod =( lastSync.addDays( 1 ) );
752 752
753 } 753 }
754 } 754 }
755 full = true; 755 full = true;
756 if ( mode < SYNC_PREF_ASK ) 756 if ( mode < SYNC_PREF_ASK )
757 mode = SYNC_PREF_ASK; 757 mode = SYNC_PREF_ASK;
758 } else { 758 } else {
759 if ( localMod == remoteMod ) 759 if ( localMod == remoteMod )
760 if ( local->revision() == remote->revision() ) 760 if ( local->revision() == remote->revision() )
761 return 0; 761 return 0;
762 762
763 } 763 }
764 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 764 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
765 765
766 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); 766 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision());
767 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); 767 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() );
768 //full = true; //debug only 768 //full = true; //debug only
769 if ( full ) { 769 if ( full ) {
770 bool equ = false; 770 bool equ = false;
771 if ( local->type() == "Event" ) { 771 if ( local->type() == "Event" ) {
772 equ = (*((Event*) local) == *((Event*) remote)); 772 equ = (*((Event*) local) == *((Event*) remote));
773 } 773 }
774 else if ( local->type() =="Todo" ) 774 else if ( local->type() =="Todo" )
775 equ = (*((Todo*) local) == (*(Todo*) remote)); 775 equ = (*((Todo*) local) == (*(Todo*) remote));
776 else if ( local->type() =="Journal" ) 776 else if ( local->type() =="Journal" )
777 equ = (*((Journal*) local) == *((Journal*) remote)); 777 equ = (*((Journal*) local) == *((Journal*) remote));
778 if ( equ ) { 778 if ( equ ) {
779 //qDebug("equal "); 779 //qDebug("equal ");
780 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 780 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
781 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 781 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
782 } 782 }
783 if ( mode < SYNC_PREF_FORCE_LOCAL ) 783 if ( mode < SYNC_PREF_FORCE_LOCAL )
784 return 0; 784 return 0;
785 785
786 }//else //debug only 786 }//else //debug only
787 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 787 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
788 } 788 }
789 int result; 789 int result;
790 bool localIsNew; 790 bool localIsNew;
791 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); 791 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() );
792 792
793 if ( full && mode < SYNC_PREF_NEWEST ) 793 if ( full && mode < SYNC_PREF_NEWEST )
794 mode = SYNC_PREF_ASK; 794 mode = SYNC_PREF_ASK;
795 795
796 switch( mode ) { 796 switch( mode ) {
797 case SYNC_PREF_LOCAL: 797 case SYNC_PREF_LOCAL:
798 if ( lastSync > remoteMod ) 798 if ( lastSync > remoteMod )
799 return 1; 799 return 1;
800 if ( lastSync > localMod ) 800 if ( lastSync > localMod )
801 return 2; 801 return 2;
802 return 1; 802 return 1;
803 break; 803 break;
804 case SYNC_PREF_REMOTE: 804 case SYNC_PREF_REMOTE:
805 if ( lastSync > remoteMod ) 805 if ( lastSync > remoteMod )
806 return 1; 806 return 1;
807 if ( lastSync > localMod ) 807 if ( lastSync > localMod )
808 return 2; 808 return 2;
809 return 2; 809 return 2;
810 break; 810 break;
811 case SYNC_PREF_NEWEST: 811 case SYNC_PREF_NEWEST:
812 if ( localMod > remoteMod ) 812 if ( localMod > remoteMod )
813 return 1; 813 return 1;
814 else 814 else
815 return 2; 815 return 2;
816 break; 816 break;
817 case SYNC_PREF_ASK: 817 case SYNC_PREF_ASK:
818 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 818 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
819 if ( lastSync > remoteMod ) 819 if ( lastSync > remoteMod )
820 return 1; 820 return 1;
821 if ( lastSync > localMod ) 821 if ( lastSync > localMod )
822 return 2; 822 return 2;
823 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 823 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
824 localIsNew = localMod >= remoteMod; 824 localIsNew = localMod >= remoteMod;
825 if ( localIsNew ) 825 if ( localIsNew )
826 getEventViewerDialog()->setColorMode( 1 ); 826 getEventViewerDialog()->setColorMode( 1 );
827 else 827 else
828 getEventViewerDialog()->setColorMode( 2 ); 828 getEventViewerDialog()->setColorMode( 2 );
829 getEventViewerDialog()->setIncidence(local); 829 getEventViewerDialog()->setIncidence(local);
830 if ( localIsNew ) 830 if ( localIsNew )
831 getEventViewerDialog()->setColorMode( 2 ); 831 getEventViewerDialog()->setColorMode( 2 );
832 else 832 else
833 getEventViewerDialog()->setColorMode( 1 ); 833 getEventViewerDialog()->setColorMode( 1 );
834 getEventViewerDialog()->addIncidence(remote); 834 getEventViewerDialog()->addIncidence(remote);
835 getEventViewerDialog()->setColorMode( 0 ); 835 getEventViewerDialog()->setColorMode( 0 );
836 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 836 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
837 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 837 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
838 getEventViewerDialog()->showMe(); 838 getEventViewerDialog()->showMe();
839 result = getEventViewerDialog()->executeS( localIsNew ); 839 result = getEventViewerDialog()->executeS( localIsNew );
840 return result; 840 return result;
841 841
842 break; 842 break;
843 case SYNC_PREF_FORCE_LOCAL: 843 case SYNC_PREF_FORCE_LOCAL:
844 return 1; 844 return 1;
845 break; 845 break;
846 case SYNC_PREF_FORCE_REMOTE: 846 case SYNC_PREF_FORCE_REMOTE:
847 return 2; 847 return 2;
848 break; 848 break;
849 849
850 default: 850 default:
851 // SYNC_PREF_TAKE_BOTH not implemented 851 // SYNC_PREF_TAKE_BOTH not implemented
852 break; 852 break;
853 } 853 }
854 return 0; 854 return 0;
855} 855}
856Event* CalendarView::getLastSyncEvent() 856Event* CalendarView::getLastSyncEvent()
857{ 857{
858 Event* lse; 858 Event* lse;
859 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 859 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
860 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 860 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
861 if (!lse) { 861 if (!lse) {
862 lse = new Event(); 862 lse = new Event();
863 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 863 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
864 QString sum = ""; 864 QString sum = "";
865 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 865 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
866 sum = "E: "; 866 sum = "E: ";
867 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 867 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
868 lse->setDtStart( mLastCalendarSync ); 868 lse->setDtStart( mLastCalendarSync );
869 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 869 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
870 lse->setCategories( i18n("SyncEvent") ); 870 lse->setCategories( i18n("SyncEvent") );
871 lse->setReadOnly( true ); 871 lse->setReadOnly( true );
872 mCalendar->addEvent( lse ); 872 mCalendar->addEvent( lse );
873 } 873 }
874 874
875 return lse; 875 return lse;
876 876
877} 877}
878 878
879// we check, if the to delete event has a id for a profile 879// we check, if the to delete event has a id for a profile
880// if yes, we set this id in the profile to delete 880// if yes, we set this id in the profile to delete
881void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 881void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
882{ 882{
883 if ( lastSync.count() == 0 ) { 883 if ( lastSync.count() == 0 ) {
884 //qDebug(" lastSync.count() == 0"); 884 //qDebug(" lastSync.count() == 0");
885 return; 885 return;
886 } 886 }
887 if ( toDelete->type() == "Journal" ) 887 if ( toDelete->type() == "Journal" )
888 return; 888 return;
889 889
890 Event* eve = lastSync.first(); 890 Event* eve = lastSync.first();
891 891
892 while ( eve ) { 892 while ( eve ) {
893 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 893 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
894 if ( !id.isEmpty() ) { 894 if ( !id.isEmpty() ) {
895 QString des = eve->description(); 895 QString des = eve->description();
896 QString pref = "e"; 896 QString pref = "e";
897 if ( toDelete->type() == "Todo" ) 897 if ( toDelete->type() == "Todo" )
898 pref = "t"; 898 pref = "t";
899 des += pref+ id + ","; 899 des += pref+ id + ",";
900 eve->setReadOnly( false ); 900 eve->setReadOnly( false );
901 eve->setDescription( des ); 901 eve->setDescription( des );
902 //qDebug("setdes %s ", des.latin1()); 902 //qDebug("setdes %s ", des.latin1());
903 eve->setReadOnly( true ); 903 eve->setReadOnly( true );
904 } 904 }
905 eve = lastSync.next(); 905 eve = lastSync.next();
906 } 906 }
907 907
908} 908}
909void CalendarView::checkExternalId( Incidence * inc ) 909void CalendarView::checkExternalId( Incidence * inc )
910{ 910{
911 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 911 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
912 checkExternSyncEvent( lastSync, inc ); 912 checkExternSyncEvent( lastSync, inc );
913 913
914} 914}
915bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 915bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
916{ 916{
917 bool syncOK = true; 917 bool syncOK = true;
918 int addedEvent = 0; 918 int addedEvent = 0;
919 int addedEventR = 0; 919 int addedEventR = 0;
920 int deletedEventR = 0; 920 int deletedEventR = 0;
921 int deletedEventL = 0; 921 int deletedEventL = 0;
922 int changedLocal = 0; 922 int changedLocal = 0;
923 int changedRemote = 0; 923 int changedRemote = 0;
924 //QPtrList<Event> el = local->rawEvents(); 924 //QPtrList<Event> el = local->rawEvents();
925 Event* eventR; 925 Event* eventR;
926 QString uid; 926 QString uid;
927 int take; 927 int take;
928 Event* eventL; 928 Event* eventL;
929 Event* eventRSync; 929 Event* eventRSync;
930 Event* eventLSync; 930 Event* eventLSync;
931 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 931 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
932 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 932 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
933 bool fullDateRange = false; 933 bool fullDateRange = false;
934 local->resetTempSyncStat(); 934 local->resetTempSyncStat();
935#ifdef DESKTOP_VERSION
936 //Needed for KDE - OL sync
937 local->resetPilotStat();
938 remote->resetPilotStat();
939#endif
935 mLastCalendarSync = QDateTime::currentDateTime(); 940 mLastCalendarSync = QDateTime::currentDateTime();
936 QDateTime modifiedCalendar = mLastCalendarSync;; 941 QDateTime modifiedCalendar = mLastCalendarSync;;
937 eventLSync = getLastSyncEvent(); 942 eventLSync = getLastSyncEvent();
938 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 943 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
939 if ( eventR ) { 944 if ( eventR ) {
940 eventRSync = (Event*) eventR->clone(); 945 eventRSync = (Event*) eventR->clone();
941 remote->deleteEvent(eventR ); 946 remote->deleteEvent(eventR );
942 947
943 } else { 948 } else {
944 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 949 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
945 eventRSync = (Event*)eventLSync->clone(); 950 eventRSync = (Event*)eventLSync->clone();
946 } else { 951 } else {
947 fullDateRange = true; 952 fullDateRange = true;
948 eventRSync = new Event(); 953 eventRSync = new Event();
949 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 954 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
950 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 955 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
951 eventRSync->setDtStart( mLastCalendarSync ); 956 eventRSync->setDtStart( mLastCalendarSync );
952 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 957 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
953 eventRSync->setCategories( i18n("SyncEvent") ); 958 eventRSync->setCategories( i18n("SyncEvent") );
954 } 959 }
955 } 960 }
956 if ( eventLSync->dtStart() == mLastCalendarSync ) 961 if ( eventLSync->dtStart() == mLastCalendarSync )
957 fullDateRange = true; 962 fullDateRange = true;
958 963
959 if ( ! fullDateRange ) { 964 if ( ! fullDateRange ) {
960 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 965 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
961 966
962 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 967 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
963 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 968 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
964 fullDateRange = true; 969 fullDateRange = true;
965 } 970 }
966 } 971 }
967 if ( fullDateRange ) 972 if ( fullDateRange )
968 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 973 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
969 else 974 else
970 mLastCalendarSync = eventLSync->dtStart(); 975 mLastCalendarSync = eventLSync->dtStart();
971 // for resyncing if own file has changed 976 // for resyncing if own file has changed
972 if ( mCurrentSyncDevice == "deleteaftersync" ) { 977 if ( mCurrentSyncDevice == "deleteaftersync" ) {
973 mLastCalendarSync = loadedFileVersion; 978 mLastCalendarSync = loadedFileVersion;
974 qDebug("setting mLastCalendarSync "); 979 qDebug("setting mLastCalendarSync ");
975 } 980 }
976 //qDebug("*************************** "); 981 //qDebug("*************************** ");
977 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); 982 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() );
978 QPtrList<Incidence> er = remote->rawIncidences(); 983 QPtrList<Incidence> er = remote->rawIncidences();
979 Incidence* inR = er.first(); 984 Incidence* inR = er.first();
980 Incidence* inL; 985 Incidence* inL;
981 QProgressBar bar( er.count(),0 ); 986 QProgressBar bar( er.count(),0 );
982 bar.setCaption (i18n("Syncing - close to abort!") ); 987 bar.setCaption (i18n("Syncing - close to abort!") );
983 988
984 int w = 300; 989 int w = 300;
985 if ( QApplication::desktop()->width() < 320 ) 990 if ( QApplication::desktop()->width() < 320 )
986 w = 220; 991 w = 220;
987 int h = bar.sizeHint().height() ; 992 int h = bar.sizeHint().height() ;
988 int dw = QApplication::desktop()->width(); 993 int dw = QApplication::desktop()->width();
989 int dh = QApplication::desktop()->height(); 994 int dh = QApplication::desktop()->height();
990 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 995 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
991 bar.show(); 996 bar.show();
992 int modulo = (er.count()/10)+1; 997 int modulo = (er.count()/10)+1;
993 int incCounter = 0; 998 int incCounter = 0;
994 while ( inR ) { 999 while ( inR ) {
995 if ( ! bar.isVisible() ) 1000 if ( ! bar.isVisible() )
996 return false; 1001 return false;
997 if ( incCounter % modulo == 0 ) 1002 if ( incCounter % modulo == 0 )
998 bar.setProgress( incCounter ); 1003 bar.setProgress( incCounter );
999 ++incCounter; 1004 ++incCounter;
1000 uid = inR->uid(); 1005 uid = inR->uid();
1001 bool skipIncidence = false; 1006 bool skipIncidence = false;
1002 if ( uid.left(15) == QString("last-syncEvent-") ) 1007 if ( uid.left(15) == QString("last-syncEvent-") )
1003 skipIncidence = true; 1008 skipIncidence = true;
1004 QString idS; 1009 QString idS;
1005 qApp->processEvents(); 1010 qApp->processEvents();
1006 if ( !skipIncidence ) { 1011 if ( !skipIncidence ) {
1007 inL = local->incidence( uid ); 1012 inL = local->incidence( uid );
1008 if ( inL ) { // maybe conflict - same uid in both calendars 1013 if ( inL ) { // maybe conflict - same uid in both calendars
1009 int maxrev = inL->revision(); 1014 int maxrev = inL->revision();
1010 if ( maxrev < inR->revision() ) 1015 if ( maxrev < inR->revision() )
1011 maxrev = inR->revision(); 1016 maxrev = inR->revision();
1012 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1017 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1013 //qDebug("take %d %s ", take, inL->summary().latin1()); 1018 //qDebug("take %d %s ", take, inL->summary().latin1());
1014 if ( take == 3 ) 1019 if ( take == 3 )
1015 return false; 1020 return false;
1016 if ( take == 1 ) {// take local 1021 if ( take == 1 ) {// take local
1017 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1022 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1018 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1023 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1019 else 1024 else
1020 idS = inR->IDStr(); 1025 idS = inR->IDStr();
1021 remote->deleteIncidence( inR ); 1026 remote->deleteIncidence( inR );
1022 if ( inL->revision() < maxrev ) 1027 if ( inL->revision() < maxrev )
1023 inL->setRevision( maxrev ); 1028 inL->setRevision( maxrev );
1024 inR = inL->clone(); 1029 inR = inL->clone();
1025 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1030 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1026 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1031 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1027 inR->setIDStr( idS ); 1032 inR->setIDStr( idS );
1028 remote->addIncidence( inR ); 1033 remote->addIncidence( inR );
1034#ifdef DESKTOP_VERSION
1035 inR->setPilotId( 1 );
1036#endif
1029 ++changedRemote; 1037 ++changedRemote;
1030 } else { 1038 } else {
1031 if ( inR->revision() < maxrev ) 1039 if ( inR->revision() < maxrev )
1032 inR->setRevision( maxrev ); 1040 inR->setRevision( maxrev );
1033 idS = inL->IDStr(); 1041 idS = inL->IDStr();
1034 local->deleteIncidence( inL ); 1042 local->deleteIncidence( inL );
1035 inL = inR->clone(); 1043 inL = inR->clone();
1036 inL->setIDStr( idS ); 1044 inL->setIDStr( idS );
1037 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1045 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1038 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1046 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1039 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1047 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1040 } 1048 }
1041 local->addIncidence( inL ); 1049 local->addIncidence( inL );
1042 ++changedLocal; 1050 ++changedLocal;
1043 } 1051 }
1044 } 1052 }
1045 } else { // no conflict 1053 } else { // no conflict
1046 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1054 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1047 QString des = eventLSync->description(); 1055 QString des = eventLSync->description();
1048 QString pref = "e"; 1056 QString pref = "e";
1049 if ( inR->type() == "Todo" ) 1057 if ( inR->type() == "Todo" )
1050 pref = "t"; 1058 pref = "t";
1051 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1059 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1052 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1060 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1053 //remote->deleteIncidence( inR ); 1061 //remote->deleteIncidence( inR );
1054 ++deletedEventR; 1062 ++deletedEventR;
1055 } else { 1063 } else {
1056 inR->setLastModified( modifiedCalendar ); 1064 inR->setLastModified( modifiedCalendar );
1057 inL = inR->clone(); 1065 inL = inR->clone();
1058 local->addIncidence( inL ); 1066 local->addIncidence( inL );
1059 ++addedEvent; 1067 ++addedEvent;
1060 } 1068 }
1061 } else { 1069 } else {
1062 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1070 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1063 inR->setLastModified( modifiedCalendar ); 1071 inR->setLastModified( modifiedCalendar );
1064 local->addIncidence( inR->clone() ); 1072 local->addIncidence( inR->clone() );
1065 ++addedEvent; 1073 ++addedEvent;
1066 } else { 1074 } else {
1067 checkExternSyncEvent(eventRSyncSharp, inR); 1075 checkExternSyncEvent(eventRSyncSharp, inR);
1068 remote->deleteIncidence( inR ); 1076 remote->deleteIncidence( inR );
1069 ++deletedEventR; 1077 ++deletedEventR;
1070 } 1078 }
1071 } 1079 }
1072 } 1080 }
1073 } 1081 }
1074 inR = er.next(); 1082 inR = er.next();
1075 } 1083 }
1076 QPtrList<Incidence> el = local->rawIncidences(); 1084 QPtrList<Incidence> el = local->rawIncidences();
1077 inL = el.first(); 1085 inL = el.first();
1078 modulo = (el.count()/10)+1; 1086 modulo = (el.count()/10)+1;
1079 bar.setCaption (i18n("Add / remove events") ); 1087 bar.setCaption (i18n("Add / remove events") );
1080 bar.setTotalSteps ( el.count() ) ; 1088 bar.setTotalSteps ( el.count() ) ;
1081 bar.show(); 1089 bar.show();
1082 incCounter = 0; 1090 incCounter = 0;
1083 1091
1084 while ( inL ) { 1092 while ( inL ) {
1085 1093
1086 qApp->processEvents(); 1094 qApp->processEvents();
1087 if ( ! bar.isVisible() ) 1095 if ( ! bar.isVisible() )
1088 return false; 1096 return false;
1089 if ( incCounter % modulo == 0 ) 1097 if ( incCounter % modulo == 0 )
1090 bar.setProgress( incCounter ); 1098 bar.setProgress( incCounter );
1091 ++incCounter; 1099 ++incCounter;
1092 uid = inL->uid(); 1100 uid = inL->uid();
1093 bool skipIncidence = false; 1101 bool skipIncidence = false;
1094 if ( uid.left(15) == QString("last-syncEvent-") ) 1102 if ( uid.left(15) == QString("last-syncEvent-") )
1095 skipIncidence = true; 1103 skipIncidence = true;
1096 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) 1104 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
1097 skipIncidence = true; 1105 skipIncidence = true;
1098 if ( !skipIncidence ) { 1106 if ( !skipIncidence ) {
1099 inR = remote->incidence( uid ); 1107 inR = remote->incidence( uid );
1100 if ( ! inR ) { 1108 if ( ! inR ) {
1101 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1109 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1102 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1110 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1103 checkExternSyncEvent(eventLSyncSharp, inL); 1111 checkExternSyncEvent(eventLSyncSharp, inL);
1104 local->deleteIncidence( inL ); 1112 local->deleteIncidence( inL );
1105 ++deletedEventL; 1113 ++deletedEventL;
1106 } else { 1114 } else {
1107 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1115 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1108 inL->removeID(mCurrentSyncDevice ); 1116 inL->removeID(mCurrentSyncDevice );
1109 ++addedEventR; 1117 ++addedEventR;
1110 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1118 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1111 inL->setLastModified( modifiedCalendar ); 1119 inL->setLastModified( modifiedCalendar );
1112 inR = inL->clone(); 1120 inR = inL->clone();
1113 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1121 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1114 remote->addIncidence( inR ); 1122 remote->addIncidence( inR );
1115 } 1123 }
1116 } 1124 }
1117 } else { 1125 } else {
1118 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1126 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1119 checkExternSyncEvent(eventLSyncSharp, inL); 1127 checkExternSyncEvent(eventLSyncSharp, inL);
1120 local->deleteIncidence( inL ); 1128 local->deleteIncidence( inL );
1121 ++deletedEventL; 1129 ++deletedEventL;
1122 } else { 1130 } else {
1123 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1131 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1124 ++addedEventR; 1132 ++addedEventR;
1125 inL->setLastModified( modifiedCalendar ); 1133 inL->setLastModified( modifiedCalendar );
1126 remote->addIncidence( inL->clone() ); 1134 remote->addIncidence( inL->clone() );
1127 } 1135 }
1128 } 1136 }
1129 } 1137 }
1130 } 1138 }
1131 } 1139 }
1132 inL = el.next(); 1140 inL = el.next();
1133 } 1141 }
1134 int delFut = 0; 1142 int delFut = 0;
1135 int remRem = 0; 1143 int remRem = 0;
1136 if ( mSyncManager->mWriteBackInFuture ) { 1144 if ( mSyncManager->mWriteBackInFuture ) {
1137 er = remote->rawIncidences(); 1145 er = remote->rawIncidences();
1138 remRem = er.count(); 1146 remRem = er.count();
1139 inR = er.first(); 1147 inR = er.first();
1140 QDateTime dt; 1148 QDateTime dt;
1141 QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); 1149 QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
1142 QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 ); 1150 QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 );
1143 while ( inR ) { 1151 while ( inR ) {
1144 if ( inR->type() == "Todo" ) { 1152 if ( inR->type() == "Todo" ) {
1145 Todo * t = (Todo*)inR; 1153 Todo * t = (Todo*)inR;
1146 if ( t->hasDueDate() ) 1154 if ( t->hasDueDate() )
1147 dt = t->dtDue(); 1155 dt = t->dtDue();
1148 else 1156 else
1149 dt = cur.addSecs( 62 ); 1157 dt = cur.addSecs( 62 );
1150 } 1158 }
1151 else if (inR->type() == "Event" ) { 1159 else if (inR->type() == "Event" ) {
1152 bool ok; 1160 bool ok;
1153 dt = inR->getNextOccurence( cur, &ok ); 1161 dt = inR->getNextOccurence( cur, &ok );
1154 if ( !ok ) 1162 if ( !ok )
1155 dt = cur.addSecs( -62 ); 1163 dt = cur.addSecs( -62 );
1156 } 1164 }
1157 else 1165 else
1158 dt = inR->dtStart(); 1166 dt = inR->dtStart();
1159 if ( dt < cur || dt > end ) { 1167 if ( dt < cur || dt > end ) {
1160 remote->deleteIncidence( inR ); 1168 remote->deleteIncidence( inR );
1161 ++delFut; 1169 ++delFut;
1162 } 1170 }
1163 inR = er.next(); 1171 inR = er.next();
1164 } 1172 }
1165 } 1173 }
1166 bar.hide(); 1174 bar.hide();
1167 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1175 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1168 eventLSync->setReadOnly( false ); 1176 eventLSync->setReadOnly( false );
1169 eventLSync->setDtStart( mLastCalendarSync ); 1177 eventLSync->setDtStart( mLastCalendarSync );
1170 eventRSync->setDtStart( mLastCalendarSync ); 1178 eventRSync->setDtStart( mLastCalendarSync );
1171 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1179 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1172 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1180 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1173 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1181 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1174 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1182 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1175 eventLSync->setReadOnly( true ); 1183 eventLSync->setReadOnly( true );
1176 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 1184 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
1177 remote->addEvent( eventRSync ); 1185 remote->addEvent( eventRSync );
1178 QString mes; 1186 QString mes;
1179 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); 1187 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR );
1180 QString delmess; 1188 QString delmess;
1181 if ( delFut ) { 1189 if ( delFut ) {
1182 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInFuture, remRem-delFut); 1190 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInFuture, remRem-delFut);
1183 mes += delmess; 1191 mes += delmess;
1184 } 1192 }
1185 if ( mSyncManager->mShowSyncSummary ) { 1193 if ( mSyncManager->mShowSyncSummary ) {
1186 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); 1194 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") );
1187 } 1195 }
1188 qDebug( mes ); 1196 qDebug( mes );
1189 mCalendar->checkAlarmForIncidence( 0, true ); 1197 mCalendar->checkAlarmForIncidence( 0, true );
1190 return syncOK; 1198 return syncOK;
1191} 1199}
1192 1200
1193void CalendarView::setSyncDevice( QString s ) 1201void CalendarView::setSyncDevice( QString s )
1194{ 1202{
1195 mCurrentSyncDevice= s; 1203 mCurrentSyncDevice= s;
1196} 1204}
1197void CalendarView::setSyncName( QString s ) 1205void CalendarView::setSyncName( QString s )
1198{ 1206{
1199 mCurrentSyncName= s; 1207 mCurrentSyncName= s;
1200} 1208}
1201bool CalendarView::syncCalendar(QString filename, int mode) 1209bool CalendarView::syncCalendar(QString filename, int mode)
1202{ 1210{
1203 //qDebug("syncCalendar %s ", filename.latin1()); 1211 //qDebug("syncCalendar %s ", filename.latin1());
1204 mGlobalSyncMode = SYNC_MODE_NORMAL; 1212 mGlobalSyncMode = SYNC_MODE_NORMAL;
1205 CalendarLocal* calendar = new CalendarLocal(); 1213 CalendarLocal* calendar = new CalendarLocal();
1206 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1214 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1207 FileStorage* storage = new FileStorage( calendar ); 1215 FileStorage* storage = new FileStorage( calendar );
1208 bool syncOK = false; 1216 bool syncOK = false;
1209 storage->setFileName( filename ); 1217 storage->setFileName( filename );
1210 // qDebug("loading ... "); 1218 // qDebug("loading ... ");
1211 if ( storage->load() ) { 1219 if ( storage->load() ) {
1212 getEventViewerDialog()->setSyncMode( true ); 1220 getEventViewerDialog()->setSyncMode( true );
1213 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1221 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1214 getEventViewerDialog()->setSyncMode( false ); 1222 getEventViewerDialog()->setSyncMode( false );
1215 if ( syncOK ) { 1223 if ( syncOK ) {
1216 if ( mSyncManager->mWriteBackFile ) 1224 if ( mSyncManager->mWriteBackFile )
1217 { 1225 {
1218 storage->setSaveFormat( new ICalFormat() ); 1226 storage->setSaveFormat( new ICalFormat() );
1219 storage->save(); 1227 storage->save();
1220 } 1228 }
1221 } 1229 }
1222 setModified( true ); 1230 setModified( true );
1223 } 1231 }
1224 delete storage; 1232 delete storage;
1225 delete calendar; 1233 delete calendar;
1226 if ( syncOK ) 1234 if ( syncOK )
1227 updateView(); 1235 updateView();
1228 return syncOK; 1236 return syncOK;
1229} 1237}
1230 1238
1231void CalendarView::syncExternal( int mode ) 1239void CalendarView::syncExternal( int mode )
1232{ 1240{
1233 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1241 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1234 1242
1235 qApp->processEvents(); 1243 qApp->processEvents();
1236 CalendarLocal* calendar = new CalendarLocal(); 1244 CalendarLocal* calendar = new CalendarLocal();
1237 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1245 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1238 bool syncOK = false; 1246 bool syncOK = false;
1239 bool loadSuccess = false; 1247 bool loadSuccess = false;
1240 PhoneFormat* phoneFormat = 0; 1248 PhoneFormat* phoneFormat = 0;
1241#ifndef DESKTOP_VERSION 1249#ifndef DESKTOP_VERSION
1242 SharpFormat* sharpFormat = 0; 1250 SharpFormat* sharpFormat = 0;
1243 if ( mode == 0 ) { // sharp 1251 if ( mode == 0 ) { // sharp
1244 sharpFormat = new SharpFormat () ; 1252 sharpFormat = new SharpFormat () ;
1245 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1253 loadSuccess = sharpFormat->load( calendar, mCalendar );
1246 1254
1247 } else 1255 } else
1248#endif 1256#endif
1249 if ( mode == 1 ) { // phone 1257 if ( mode == 1 ) { // phone
1250 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1258 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1251 mSyncManager->mPhoneDevice, 1259 mSyncManager->mPhoneDevice,
1252 mSyncManager->mPhoneConnection, 1260 mSyncManager->mPhoneConnection,
1253 mSyncManager->mPhoneModel); 1261 mSyncManager->mPhoneModel);
1254 loadSuccess = phoneFormat->load( calendar,mCalendar); 1262 loadSuccess = phoneFormat->load( calendar,mCalendar);
1255 1263
1256 } else 1264 } else
1257 return; 1265 return;
1258 if ( loadSuccess ) { 1266 if ( loadSuccess ) {
1259 getEventViewerDialog()->setSyncMode( true ); 1267 getEventViewerDialog()->setSyncMode( true );
1260 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1268 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1261 getEventViewerDialog()->setSyncMode( false ); 1269 getEventViewerDialog()->setSyncMode( false );
1262 qApp->processEvents(); 1270 qApp->processEvents();
1263 if ( syncOK ) { 1271 if ( syncOK ) {
1264 if ( mSyncManager->mWriteBackFile ) 1272 if ( mSyncManager->mWriteBackFile )
1265 { 1273 {
1266 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1274 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1267 Incidence* inc = iL.first(); 1275 Incidence* inc = iL.first();
1268 if ( phoneFormat ) { 1276 if ( phoneFormat ) {
1269 while ( inc ) { 1277 while ( inc ) {
1270 inc->removeID(mCurrentSyncDevice); 1278 inc->removeID(mCurrentSyncDevice);
1271 inc = iL.next(); 1279 inc = iL.next();
1272 } 1280 }
1273 } 1281 }
1274#ifndef DESKTOP_VERSION 1282#ifndef DESKTOP_VERSION
1275 if ( sharpFormat ) 1283 if ( sharpFormat )
1276 sharpFormat->save(calendar); 1284 sharpFormat->save(calendar);
1277#endif 1285#endif
1278 if ( phoneFormat ) 1286 if ( phoneFormat )
1279 phoneFormat->save(calendar); 1287 phoneFormat->save(calendar);
1280 iL = calendar->rawIncidences(); 1288 iL = calendar->rawIncidences();
1281 inc = iL.first(); 1289 inc = iL.first();
1282 Incidence* loc; 1290 Incidence* loc;
1283 while ( inc ) { 1291 while ( inc ) {
1284 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1292 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1285 loc = mCalendar->incidence(inc->uid() ); 1293 loc = mCalendar->incidence(inc->uid() );
1286 if ( loc ) { 1294 if ( loc ) {
1287 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1295 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1288 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1296 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1289 } 1297 }
1290 } 1298 }
1291 inc = iL.next(); 1299 inc = iL.next();
1292 } 1300 }
1293 Incidence* lse = getLastSyncEvent(); 1301 Incidence* lse = getLastSyncEvent();
1294 if ( lse ) { 1302 if ( lse ) {
1295 lse->setReadOnly( false ); 1303 lse->setReadOnly( false );
1296 lse->setDescription( "" ); 1304 lse->setDescription( "" );
1297 lse->setReadOnly( true ); 1305 lse->setReadOnly( true );
1298 } 1306 }
1299 } 1307 }
1300 } 1308 }
1301 setModified( true ); 1309 setModified( true );
1302 } else { 1310 } else {
1303 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1311 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1304 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1312 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1305 question, i18n("Ok")) ; 1313 question, i18n("Ok")) ;
1306 1314
1307 } 1315 }
1308 delete calendar; 1316 delete calendar;
1309 updateView(); 1317 updateView();
1310 return ;//syncOK; 1318 return ;//syncOK;
1311 1319
1312} 1320}
1313 1321
1314bool CalendarView::importBday() 1322bool CalendarView::importBday()
1315{ 1323{
1316#ifndef KORG_NOKABC 1324#ifndef KORG_NOKABC
1317 1325
1318#ifdef DESKTOP_VERSION 1326#ifdef DESKTOP_VERSION
1319 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1327 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1320 KABC::AddressBook::Iterator it; 1328 KABC::AddressBook::Iterator it;
1321 int count = 0; 1329 int count = 0;
1322 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1330 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1323 ++count; 1331 ++count;
1324 } 1332 }
1325 QProgressBar bar(count,0 ); 1333 QProgressBar bar(count,0 );
1326 int w = 300; 1334 int w = 300;
1327 if ( QApplication::desktop()->width() < 320 ) 1335 if ( QApplication::desktop()->width() < 320 )
1328 w = 220; 1336 w = 220;
1329 int h = bar.sizeHint().height() ; 1337 int h = bar.sizeHint().height() ;
1330 int dw = QApplication::desktop()->width(); 1338 int dw = QApplication::desktop()->width();
1331 int dh = QApplication::desktop()->height(); 1339 int dh = QApplication::desktop()->height();
1332 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1340 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1333 bar.show(); 1341 bar.show();
1334 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1342 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1335 qApp->processEvents(); 1343 qApp->processEvents();
1336 count = 0; 1344 count = 0;
1337 int addCount = 0; 1345 int addCount = 0;
1338 KCal::Attendee* a = 0; 1346 KCal::Attendee* a = 0;
1339 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1347 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1340 if ( ! bar.isVisible() ) 1348 if ( ! bar.isVisible() )
1341 return false; 1349 return false;
1342 bar.setProgress( count++ ); 1350 bar.setProgress( count++ );
1343 qApp->processEvents(); 1351 qApp->processEvents();
1344 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1352 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1345 if ( (*it).birthday().date().isValid() ){ 1353 if ( (*it).birthday().date().isValid() ){
1346 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1354 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1347 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1355 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1348 ++addCount; 1356 ++addCount;
1349 } 1357 }
1350 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1358 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1351 if ( anni.isValid() ){ 1359 if ( anni.isValid() ){
1352 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1360 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1353 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1361 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1354 ++addCount; 1362 ++addCount;
1355 } 1363 }
1356 } 1364 }
1357 updateView(); 1365 updateView();
1358 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1366 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1359#else //DESKTOP_VERSION 1367#else //DESKTOP_VERSION
1360 1368
1361 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 1369 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
1362 // the result should now arrive through method insertBirthdays 1370 // the result should now arrive through method insertBirthdays
1363 1371
1364#endif //DESKTOP_VERSION 1372#endif //DESKTOP_VERSION
1365 1373
1366#endif //KORG_NOKABC 1374#endif //KORG_NOKABC
1367 1375
1368 1376
1369 return true; 1377 return true;
1370} 1378}
1371 1379
1372// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI 1380// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
1373void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, 1381void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
1374 const QStringList& anniversaryList, const QStringList& realNameList, 1382 const QStringList& anniversaryList, const QStringList& realNameList,
1375 const QStringList& emailList, const QStringList& assembledNameList, 1383 const QStringList& emailList, const QStringList& assembledNameList,
1376 const QStringList& uidList) 1384 const QStringList& uidList)
1377{ 1385{
1378 qDebug("CalendarView::insertBirthdays"); 1386 qDebug("CalendarView::insertBirthdays");
1379 if (uid == this->name()) 1387 if (uid == this->name())
1380 { 1388 {
1381 int count = birthdayList.count(); 1389 int count = birthdayList.count();
1382 int addCount = 0; 1390 int addCount = 0;
1383 KCal::Attendee* a = 0; 1391 KCal::Attendee* a = 0;
1384 1392
1385 qDebug("CalView 1 %i", count); 1393 qDebug("CalView 1 %i", count);
1386 1394
1387 QProgressBar bar(count,0 ); 1395 QProgressBar bar(count,0 );
1388 int w = 300; 1396 int w = 300;
1389 if ( QApplication::desktop()->width() < 320 ) 1397 if ( QApplication::desktop()->width() < 320 )
1390 w = 220; 1398 w = 220;
1391 int h = bar.sizeHint().height() ; 1399 int h = bar.sizeHint().height() ;
1392 int dw = QApplication::desktop()->width(); 1400 int dw = QApplication::desktop()->width();
1393 int dh = QApplication::desktop()->height(); 1401 int dh = QApplication::desktop()->height();
1394 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1402 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1395 bar.show(); 1403 bar.show();
1396 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 1404 bar.setCaption (i18n("inserting birthdays - close to abort!") );
1397 qApp->processEvents(); 1405 qApp->processEvents();
1398 1406
1399 QDate birthday; 1407 QDate birthday;
1400 QDate anniversary; 1408 QDate anniversary;
1401 QString realName; 1409 QString realName;
1402 QString email; 1410 QString email;
1403 QString assembledName; 1411 QString assembledName;
1404 QString uid; 1412 QString uid;
1405 bool ok = true; 1413 bool ok = true;
1406 for ( int i = 0; i < count; i++) 1414 for ( int i = 0; i < count; i++)
1407 { 1415 {
1408 if ( ! bar.isVisible() ) 1416 if ( ! bar.isVisible() )
1409 return; 1417 return;
1410 bar.setProgress( i ); 1418 bar.setProgress( i );
1411 qApp->processEvents(); 1419 qApp->processEvents();
1412 1420
1413 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); 1421 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
1414 if (!ok) { 1422 if (!ok) {
1415 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); 1423 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
1416 } 1424 }
1417 1425
1418 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); 1426 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
1419 if (!ok) { 1427 if (!ok) {
1420 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); 1428 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
1421 } 1429 }
1422 realName = realNameList[i]; 1430 realName = realNameList[i];
1423 email = emailList[i]; 1431 email = emailList[i];
1424 assembledName = assembledNameList[i]; 1432 assembledName = assembledNameList[i];
1425 uid = uidList[i]; 1433 uid = uidList[i];
1426 //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() ); 1434 //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() );
1427 1435
1428 if ( birthday.isValid() ){ 1436 if ( birthday.isValid() ){
1429 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1437 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1430 KCal::Attendee::ReqParticipant,uid) ; 1438 KCal::Attendee::ReqParticipant,uid) ;
1431 if ( addAnniversary( birthday, assembledName, a, true ) ) 1439 if ( addAnniversary( birthday, assembledName, a, true ) )
1432 ++addCount; 1440 ++addCount;
1433 } 1441 }
1434 1442
1435 if ( anniversary.isValid() ){ 1443 if ( anniversary.isValid() ){
1436 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1444 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1437 KCal::Attendee::ReqParticipant,uid) ; 1445 KCal::Attendee::ReqParticipant,uid) ;
1438 if ( addAnniversary( anniversary, assembledName, a, false ) ) 1446 if ( addAnniversary( anniversary, assembledName, a, false ) )
1439 ++addCount; 1447 ++addCount;
1440 } 1448 }
1441 } 1449 }
1442 1450
1443 updateView(); 1451 updateView();
1444 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1452 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1445 1453
1446 } 1454 }
1447 1455
1448} 1456}
1449 1457
1450 1458
1451 1459
1452bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1460bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1453{ 1461{
1454 //qDebug("addAnni "); 1462 //qDebug("addAnni ");
1455 Event * ev = new Event(); 1463 Event * ev = new Event();
1456 if ( a ) { 1464 if ( a ) {
1457 ev->addAttendee( a ); 1465 ev->addAttendee( a );
1458 } 1466 }
1459 QString kind; 1467 QString kind;
1460 if ( birthday ) 1468 if ( birthday )
1461 kind = i18n( "Birthday" ); 1469 kind = i18n( "Birthday" );
1462 else 1470 else
1463 kind = i18n( "Anniversary" ); 1471 kind = i18n( "Anniversary" );
1464 ev->setSummary( name + " - " + kind ); 1472 ev->setSummary( name + " - " + kind );
1465 ev->setOrganizer( "nobody@nowhere" ); 1473 ev->setOrganizer( "nobody@nowhere" );
1466 ev->setCategories( kind ); 1474 ev->setCategories( kind );
1467 ev->setDtStart( QDateTime(date) ); 1475 ev->setDtStart( QDateTime(date) );
1468 ev->setDtEnd( QDateTime(date) ); 1476 ev->setDtEnd( QDateTime(date) );
1469 ev->setFloats( true ); 1477 ev->setFloats( true );
1470 Recurrence * rec = ev->recurrence(); 1478 Recurrence * rec = ev->recurrence();
1471 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1479 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1472 rec->addYearlyNum( date.month() ); 1480 rec->addYearlyNum( date.month() );
1473 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1481 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1474 delete ev; 1482 delete ev;
1475 return false; 1483 return false;
1476 } 1484 }
1477 return true; 1485 return true;
1478 1486
1479} 1487}
1480bool CalendarView::importQtopia( const QString &categories, 1488bool CalendarView::importQtopia( const QString &categories,
1481 const QString &datebook, 1489 const QString &datebook,
1482 const QString &todolist ) 1490 const QString &todolist )
1483{ 1491{
1484 1492
1485 QtopiaFormat qtopiaFormat; 1493 QtopiaFormat qtopiaFormat;
1486 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1494 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1487 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1495 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1488 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1496 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1489 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1497 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1490 1498
1491 updateView(); 1499 updateView();
1492 return true; 1500 return true;
1493 1501
1494#if 0 1502#if 0
1495 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1503 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1496 mCurrentSyncDevice = "qtopia-XML"; 1504 mCurrentSyncDevice = "qtopia-XML";
1497 if ( mSyncManager->mAskForPreferences ) 1505 if ( mSyncManager->mAskForPreferences )
1498 edit_sync_options(); 1506 edit_sync_options();
1499 qApp->processEvents(); 1507 qApp->processEvents();
1500 CalendarLocal* calendar = new CalendarLocal(); 1508 CalendarLocal* calendar = new CalendarLocal();
1501 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1509 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1502 bool syncOK = false; 1510 bool syncOK = false;
1503 QtopiaFormat qtopiaFormat; 1511 QtopiaFormat qtopiaFormat;
1504 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1512 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1505 bool loadOk = true; 1513 bool loadOk = true;
1506 if ( !categories.isEmpty() ) 1514 if ( !categories.isEmpty() )
1507 loadOk = qtopiaFormat.load( calendar, categories ); 1515 loadOk = qtopiaFormat.load( calendar, categories );
1508 if ( loadOk && !datebook.isEmpty() ) 1516 if ( loadOk && !datebook.isEmpty() )
1509 loadOk = qtopiaFormat.load( calendar, datebook ); 1517 loadOk = qtopiaFormat.load( calendar, datebook );
1510 if ( loadOk && !todolist.isEmpty() ) 1518 if ( loadOk && !todolist.isEmpty() )
1511 loadOk = qtopiaFormat.load( calendar, todolist ); 1519 loadOk = qtopiaFormat.load( calendar, todolist );
1512 1520
1513 if ( loadOk ) { 1521 if ( loadOk ) {
1514 getEventViewerDialog()->setSyncMode( true ); 1522 getEventViewerDialog()->setSyncMode( true );
1515 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1523 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1516 getEventViewerDialog()->setSyncMode( false ); 1524 getEventViewerDialog()->setSyncMode( false );
1517 qApp->processEvents(); 1525 qApp->processEvents();
1518 if ( syncOK ) { 1526 if ( syncOK ) {
1519 if ( mSyncManager->mWriteBackFile ) 1527 if ( mSyncManager->mWriteBackFile )
1520 { 1528 {
1521 // write back XML file 1529 // write back XML file
1522 1530
1523 } 1531 }
1524 setModified( true ); 1532 setModified( true );
1525 } 1533 }
1526 } else { 1534 } else {
1527 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1535 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1528 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1536 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1529 question, i18n("Ok")) ; 1537 question, i18n("Ok")) ;
1530 } 1538 }
1531 delete calendar; 1539 delete calendar;
1532 updateView(); 1540 updateView();
1533 return syncOK; 1541 return syncOK;
1534 1542
1535 1543
1536#endif 1544#endif
1537 1545
1538} 1546}
1539 1547
1540void CalendarView::setSyncEventsReadOnly() 1548void CalendarView::setSyncEventsReadOnly()
1541{ 1549{
1542 Event * ev; 1550 Event * ev;
1543 QPtrList<Event> eL = mCalendar->rawEvents(); 1551 QPtrList<Event> eL = mCalendar->rawEvents();
1544 ev = eL.first(); 1552 ev = eL.first();
1545 while ( ev ) { 1553 while ( ev ) {
1546 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1554 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1547 ev->setReadOnly( true ); 1555 ev->setReadOnly( true );
1548 ev = eL.next(); 1556 ev = eL.next();
1549 } 1557 }
1550} 1558}
1551bool CalendarView::openCalendar(QString filename, bool merge) 1559bool CalendarView::openCalendar(QString filename, bool merge)
1552{ 1560{
1553 1561
1554 if (filename.isEmpty()) { 1562 if (filename.isEmpty()) {
1555 return false; 1563 return false;
1556 } 1564 }
1557 1565
1558 if (!QFile::exists(filename)) { 1566 if (!QFile::exists(filename)) {
1559 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1567 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1560 return false; 1568 return false;
1561 } 1569 }
1562 1570
1563 globalFlagBlockAgenda = 1; 1571 globalFlagBlockAgenda = 1;
1564 if (!merge) mCalendar->close(); 1572 if (!merge) mCalendar->close();
1565 1573
1566 mStorage->setFileName( filename ); 1574 mStorage->setFileName( filename );
1567 1575
1568 if ( mStorage->load() ) { 1576 if ( mStorage->load() ) {
1569 if ( merge ) ;//setModified( true ); 1577 if ( merge ) ;//setModified( true );
1570 else { 1578 else {
1571 //setModified( true ); 1579 //setModified( true );
1572 mViewManager->setDocumentId( filename ); 1580 mViewManager->setDocumentId( filename );
1573 mDialogManager->setDocumentId( filename ); 1581 mDialogManager->setDocumentId( filename );
1574 mTodoList->setDocumentId( filename ); 1582 mTodoList->setDocumentId( filename );
1575 } 1583 }
1576 globalFlagBlockAgenda = 2; 1584 globalFlagBlockAgenda = 2;
1577 // if ( getLastSyncEvent() ) 1585 // if ( getLastSyncEvent() )
1578 // getLastSyncEvent()->setReadOnly( true ); 1586 // getLastSyncEvent()->setReadOnly( true );
1579 mCalendar->reInitAlarmSettings(); 1587 mCalendar->reInitAlarmSettings();
1580 setSyncEventsReadOnly(); 1588 setSyncEventsReadOnly();
1581 updateUnmanagedViews(); 1589 updateUnmanagedViews();
1582 updateView(); 1590 updateView();
1583 if ( filename != MainWindow::defaultFileName() ) { 1591 if ( filename != MainWindow::defaultFileName() ) {
1584 saveCalendar( MainWindow::defaultFileName() ); 1592 saveCalendar( MainWindow::defaultFileName() );
1585 } else { 1593 } else {
1586 QFileInfo finf ( MainWindow::defaultFileName()); 1594 QFileInfo finf ( MainWindow::defaultFileName());
1587 if ( finf.exists() ) { 1595 if ( finf.exists() ) {
1588 setLoadedFileVersion( finf.lastModified () ); 1596 setLoadedFileVersion( finf.lastModified () );
1589 } 1597 }
1590 } 1598 }
1591 return true; 1599 return true;
1592 } else { 1600 } else {
1593 // while failing to load, the calendar object could 1601 // while failing to load, the calendar object could
1594 // have become partially populated. Clear it out. 1602 // have become partially populated. Clear it out.
1595 if ( !merge ) { 1603 if ( !merge ) {
1596 mCalendar->close(); 1604 mCalendar->close();
1597 mViewManager->setDocumentId( filename ); 1605 mViewManager->setDocumentId( filename );
1598 mDialogManager->setDocumentId( filename ); 1606 mDialogManager->setDocumentId( filename );
1599 mTodoList->setDocumentId( filename ); 1607 mTodoList->setDocumentId( filename );
1600 } 1608 }
1601 1609
1602 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1610 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1603 1611
1604 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 1612 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
1605 globalFlagBlockAgenda = 2; 1613 globalFlagBlockAgenda = 2;
1606 mCalendar->reInitAlarmSettings(); 1614 mCalendar->reInitAlarmSettings();
1607 setSyncEventsReadOnly(); 1615 setSyncEventsReadOnly();
1608 updateUnmanagedViews(); 1616 updateUnmanagedViews();
1609 updateView(); 1617 updateView();
1610 } 1618 }
1611 return false; 1619 return false;
1612} 1620}
1613void CalendarView::showOpenError() 1621void CalendarView::showOpenError()
1614{ 1622{
1615 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 1623 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
1616} 1624}
1617void CalendarView::setLoadedFileVersion(QDateTime dt) 1625void CalendarView::setLoadedFileVersion(QDateTime dt)
1618{ 1626{
1619 loadedFileVersion = dt; 1627 loadedFileVersion = dt;
1620} 1628}
1621bool CalendarView::checkFileChanged(QString fn) 1629bool CalendarView::checkFileChanged(QString fn)
1622{ 1630{
1623 QFileInfo finf ( fn ); 1631 QFileInfo finf ( fn );
1624 if ( !finf.exists() ) 1632 if ( !finf.exists() )
1625 return true; 1633 return true;
1626 QDateTime dt = finf.lastModified (); 1634 QDateTime dt = finf.lastModified ();
1627 if ( dt <= loadedFileVersion ) 1635 if ( dt <= loadedFileVersion )
1628 return false; 1636 return false;
1629 return true; 1637 return true;
1630 1638
1631} 1639}
1632void CalendarView::watchSavedFile() 1640void CalendarView::watchSavedFile()
1633{ 1641{
1634 QFileInfo finf ( MainWindow::defaultFileName()); 1642 QFileInfo finf ( MainWindow::defaultFileName());
1635 if ( !finf.exists() ) 1643 if ( !finf.exists() )
1636 return; 1644 return;
1637 QDateTime dt = finf.lastModified (); 1645 QDateTime dt = finf.lastModified ();
1638 if ( dt < loadedFileVersion ) { 1646 if ( dt < loadedFileVersion ) {
1639 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 1647 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
1640 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 1648 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1641 return; 1649 return;
1642 } 1650 }
1643 loadedFileVersion = dt; 1651 loadedFileVersion = dt;
1644} 1652}
1645 1653
1646bool CalendarView::checkFileVersion(QString fn) 1654bool CalendarView::checkFileVersion(QString fn)
1647{ 1655{
1648 QFileInfo finf ( fn ); 1656 QFileInfo finf ( fn );
1649 if ( !finf.exists() ) 1657 if ( !finf.exists() )
1650 return true; 1658 return true;
1651 QDateTime dt = finf.lastModified (); 1659 QDateTime dt = finf.lastModified ();
1652 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1660 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1653 //qDebug("file on disk version %s",dt.toString().latin1()); 1661 //qDebug("file on disk version %s",dt.toString().latin1());
1654 if ( dt <= loadedFileVersion ) 1662 if ( dt <= loadedFileVersion )
1655 return true; 1663 return true;
1656 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)) , 1664 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)) ,
1657 i18n("KO/Pi Warning"),i18n("Overwrite"), 1665 i18n("KO/Pi Warning"),i18n("Overwrite"),
1658 i18n("Sync+save")); 1666 i18n("Sync+save"));
1659 1667
1660 if ( km == KMessageBox::Cancel ) 1668 if ( km == KMessageBox::Cancel )
1661 return false; 1669 return false;
1662 if ( km == KMessageBox::Yes ) 1670 if ( km == KMessageBox::Yes )
1663 return true; 1671 return true;
1664 1672
1665 setSyncDevice("deleteaftersync" ); 1673 setSyncDevice("deleteaftersync" );
1666 mSyncManager->mAskForPreferences = true; 1674 mSyncManager->mAskForPreferences = true;
1667 mSyncManager->mSyncAlgoPrefs = 3; 1675 mSyncManager->mSyncAlgoPrefs = 3;
1668 mSyncManager->mWriteBackFile = false; 1676 mSyncManager->mWriteBackFile = false;
1669 mSyncManager->mWriteBackExistingOnly = false; 1677 mSyncManager->mWriteBackExistingOnly = false;
1670 mSyncManager->mShowSyncSummary = false; 1678 mSyncManager->mShowSyncSummary = false;
1671 syncCalendar( fn, 3 ); 1679 syncCalendar( fn, 3 );
1672 Event * e = getLastSyncEvent(); 1680 Event * e = getLastSyncEvent();
1673 mCalendar->deleteEvent ( e ); 1681 mCalendar->deleteEvent ( e );
1674 updateView(); 1682 updateView();
1675 return true; 1683 return true;
1676} 1684}
1677 1685
1678bool CalendarView::saveCalendar( QString filename ) 1686bool CalendarView::saveCalendar( QString filename )
1679{ 1687{
1680 1688
1681 // Store back all unsaved data into calendar object 1689 // Store back all unsaved data into calendar object
1682 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1690 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1683 if ( mViewManager->currentView() ) 1691 if ( mViewManager->currentView() )
1684 mViewManager->currentView()->flushView(); 1692 mViewManager->currentView()->flushView();
1685 1693
1686 1694
1687 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 1695 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
1688 mStorage->setSaveFormat( new ICalFormat() ); 1696 mStorage->setSaveFormat( new ICalFormat() );
1689 mStorage->setFileName( filename ); 1697 mStorage->setFileName( filename );
1690 bool success; 1698 bool success;
1691 success = mStorage->save(); 1699 success = mStorage->save();
1692 if ( !success ) { 1700 if ( !success ) {
1693 return false; 1701 return false;
1694 } 1702 }
1695 if ( filename == MainWindow::defaultFileName() ) { 1703 if ( filename == MainWindow::defaultFileName() ) {
1696 setLoadedFileVersion( lfv ); 1704 setLoadedFileVersion( lfv );
1697 watchSavedFile(); 1705 watchSavedFile();
1698 } 1706 }
1699 return true; 1707 return true;
1700} 1708}
1701 1709
1702void CalendarView::closeCalendar() 1710void CalendarView::closeCalendar()
1703{ 1711{
1704 1712
1705 // child windows no longer valid 1713 // child windows no longer valid
1706 emit closingDown(); 1714 emit closingDown();
1707 1715
1708 mCalendar->close(); 1716 mCalendar->close();
1709 setModified(false); 1717 setModified(false);
1710 updateView(); 1718 updateView();
1711} 1719}
1712 1720
1713void CalendarView::archiveCalendar() 1721void CalendarView::archiveCalendar()
1714{ 1722{
1715 mDialogManager->showArchiveDialog(); 1723 mDialogManager->showArchiveDialog();
1716} 1724}
1717 1725
1718 1726
1719void CalendarView::readSettings() 1727void CalendarView::readSettings()
1720{ 1728{
1721 1729
1722 1730
1723 // mViewManager->showAgendaView(); 1731 // mViewManager->showAgendaView();
1724 QString str; 1732 QString str;
1725 //qDebug("CalendarView::readSettings() "); 1733 //qDebug("CalendarView::readSettings() ");
1726 // read settings from the KConfig, supplying reasonable 1734 // read settings from the KConfig, supplying reasonable
1727 // defaults where none are to be found 1735 // defaults where none are to be found
1728 KConfig *config = KOGlobals::config(); 1736 KConfig *config = KOGlobals::config();
1729#ifndef KORG_NOSPLITTER 1737#ifndef KORG_NOSPLITTER
1730 config->setGroup("KOrganizer Geometry"); 1738 config->setGroup("KOrganizer Geometry");
1731 1739
1732 QValueList<int> sizes = config->readIntListEntry("Separator1"); 1740 QValueList<int> sizes = config->readIntListEntry("Separator1");
1733 if (sizes.count() != 2) { 1741 if (sizes.count() != 2) {
1734 sizes << mDateNavigator->minimumSizeHint().width(); 1742 sizes << mDateNavigator->minimumSizeHint().width();
1735 sizes << 300; 1743 sizes << 300;
1736 } 1744 }
1737 mPanner->setSizes(sizes); 1745 mPanner->setSizes(sizes);
1738 1746
1739 sizes = config->readIntListEntry("Separator2"); 1747 sizes = config->readIntListEntry("Separator2");
1740 if ( ( mResourceView && sizes.count() == 4 ) || 1748 if ( ( mResourceView && sizes.count() == 4 ) ||
1741 ( !mResourceView && sizes.count() == 3 ) ) { 1749 ( !mResourceView && sizes.count() == 3 ) ) {
1742 mLeftSplitter->setSizes(sizes); 1750 mLeftSplitter->setSizes(sizes);
1743 } 1751 }
1744#endif 1752#endif
1745 globalFlagBlockAgenda = 1; 1753 globalFlagBlockAgenda = 1;
1746 mViewManager->showAgendaView(); 1754 mViewManager->showAgendaView();
1747 //mViewManager->readSettings( config ); 1755 //mViewManager->readSettings( config );
1748 mTodoList->restoreLayout(config,QString("Todo Layout")); 1756 mTodoList->restoreLayout(config,QString("Todo Layout"));
1749 readFilterSettings(config); 1757 readFilterSettings(config);
1750 config->setGroup( "Views" ); 1758 config->setGroup( "Views" );
1751 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 1759 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
1752 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 1760 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
1753 else if ( dateCount == 7 ) mNavigator->selectWeek(); 1761 else if ( dateCount == 7 ) mNavigator->selectWeek();
1754 else mNavigator->selectDates( dateCount ); 1762 else mNavigator->selectDates( dateCount );
1755 // mViewManager->readSettings( config ); 1763 // mViewManager->readSettings( config );
1756 updateConfig(); 1764 updateConfig();
1757 globalFlagBlockAgenda = 2; 1765 globalFlagBlockAgenda = 2;
1758 mViewManager->readSettings( config ); 1766 mViewManager->readSettings( config );
1759#ifdef DESKTOP_VERSION 1767#ifdef DESKTOP_VERSION
1760 config->setGroup("WidgetLayout"); 1768 config->setGroup("WidgetLayout");
1761 QStringList list; 1769 QStringList list;
1762 list = config->readListEntry("MainLayout"); 1770 list = config->readListEntry("MainLayout");
1763 int x,y,w,h; 1771 int x,y,w,h;
1764 if ( ! list.isEmpty() ) { 1772 if ( ! list.isEmpty() ) {
1765 x = list[0].toInt(); 1773 x = list[0].toInt();
1766 y = list[1].toInt(); 1774 y = list[1].toInt();
1767 w = list[2].toInt(); 1775 w = list[2].toInt();
1768 h = list[3].toInt(); 1776 h = list[3].toInt();
1769 topLevelWidget()->setGeometry(x,y,w,h); 1777 topLevelWidget()->setGeometry(x,y,w,h);
1770 1778
1771 } else { 1779 } else {
1772 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 1780 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
1773 } 1781 }
1774 list = config->readListEntry("EditEventLayout"); 1782 list = config->readListEntry("EditEventLayout");
1775 if ( ! list.isEmpty() ) { 1783 if ( ! list.isEmpty() ) {
1776 x = list[0].toInt(); 1784 x = list[0].toInt();
1777 y = list[1].toInt(); 1785 y = list[1].toInt();
1778 w = list[2].toInt(); 1786 w = list[2].toInt();
1779 h = list[3].toInt(); 1787 h = list[3].toInt();
1780 mEventEditor->setGeometry(x,y,w,h); 1788 mEventEditor->setGeometry(x,y,w,h);
1781 1789
1782 } 1790 }
1783 list = config->readListEntry("EditTodoLayout"); 1791 list = config->readListEntry("EditTodoLayout");
1784 if ( ! list.isEmpty() ) { 1792 if ( ! list.isEmpty() ) {
1785 x = list[0].toInt(); 1793 x = list[0].toInt();
1786 y = list[1].toInt(); 1794 y = list[1].toInt();
1787 w = list[2].toInt(); 1795 w = list[2].toInt();
1788 h = list[3].toInt(); 1796 h = list[3].toInt();
1789 mTodoEditor->setGeometry(x,y,w,h); 1797 mTodoEditor->setGeometry(x,y,w,h);
1790 1798
1791 } 1799 }
1792 list = config->readListEntry("ViewerLayout"); 1800 list = config->readListEntry("ViewerLayout");
1793 if ( ! list.isEmpty() ) { 1801 if ( ! list.isEmpty() ) {
1794 x = list[0].toInt(); 1802 x = list[0].toInt();
1795 y = list[1].toInt(); 1803 y = list[1].toInt();
1796 w = list[2].toInt(); 1804 w = list[2].toInt();
1797 h = list[3].toInt(); 1805 h = list[3].toInt();
1798 getEventViewerDialog()->setGeometry(x,y,w,h); 1806 getEventViewerDialog()->setGeometry(x,y,w,h);
1799 } 1807 }
1800#endif 1808#endif
1801 1809
1802} 1810}
1803 1811
1804 1812
1805void CalendarView::writeSettings() 1813void CalendarView::writeSettings()
1806{ 1814{
1807 // kdDebug() << "CalendarView::writeSettings" << endl; 1815 // kdDebug() << "CalendarView::writeSettings" << endl;
1808 1816
1809 KConfig *config = KOGlobals::config(); 1817 KConfig *config = KOGlobals::config();
1810 1818
1811#ifndef KORG_NOSPLITTER 1819#ifndef KORG_NOSPLITTER
1812 config->setGroup("KOrganizer Geometry"); 1820 config->setGroup("KOrganizer Geometry");
1813 1821
1814 QValueList<int> list = mPanner->sizes(); 1822 QValueList<int> list = mPanner->sizes();
1815 config->writeEntry("Separator1",list); 1823 config->writeEntry("Separator1",list);
1816 1824
1817 list = mLeftSplitter->sizes(); 1825 list = mLeftSplitter->sizes();
1818 config->writeEntry("Separator2",list); 1826 config->writeEntry("Separator2",list);
1819#endif 1827#endif
1820 1828
1821 mViewManager->writeSettings( config ); 1829 mViewManager->writeSettings( config );
1822 mTodoList->saveLayout(config,QString("Todo Layout")); 1830 mTodoList->saveLayout(config,QString("Todo Layout"));
1823 mDialogManager->writeSettings( config ); 1831 mDialogManager->writeSettings( config );
1824 //KOPrefs::instance()->usrWriteConfig(); 1832 //KOPrefs::instance()->usrWriteConfig();
1825 KOPrefs::instance()->writeConfig(); 1833 KOPrefs::instance()->writeConfig();
1826 1834
1827 writeFilterSettings(config); 1835 writeFilterSettings(config);
1828 1836
1829 config->setGroup( "Views" ); 1837 config->setGroup( "Views" );
1830 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 1838 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
1831 1839
1832#ifdef DESKTOP_VERSION 1840#ifdef DESKTOP_VERSION
1833 config->setGroup("WidgetLayout"); 1841 config->setGroup("WidgetLayout");
1834 QStringList list ;//= config->readListEntry("MainLayout"); 1842 QStringList list ;//= config->readListEntry("MainLayout");
1835 int x,y,w,h; 1843 int x,y,w,h;
1836 QWidget* wid; 1844 QWidget* wid;
1837 wid = topLevelWidget(); 1845 wid = topLevelWidget();
1838 x = wid->geometry().x(); 1846 x = wid->geometry().x();
1839 y = wid->geometry().y(); 1847 y = wid->geometry().y();
1840 w = wid->width(); 1848 w = wid->width();
1841 h = wid->height(); 1849 h = wid->height();
1842 list.clear(); 1850 list.clear();
1843 list << QString::number( x ); 1851 list << QString::number( x );
1844 list << QString::number( y ); 1852 list << QString::number( y );
1845 list << QString::number( w ); 1853 list << QString::number( w );
1846 list << QString::number( h ); 1854 list << QString::number( h );
1847 config->writeEntry("MainLayout",list ); 1855 config->writeEntry("MainLayout",list );
1848 1856
1849 wid = mEventEditor; 1857 wid = mEventEditor;
1850 x = wid->geometry().x(); 1858 x = wid->geometry().x();
1851 y = wid->geometry().y(); 1859 y = wid->geometry().y();
1852 w = wid->width(); 1860 w = wid->width();
1853 h = wid->height(); 1861 h = wid->height();
1854 list.clear(); 1862 list.clear();
1855 list << QString::number( x ); 1863 list << QString::number( x );
1856 list << QString::number( y ); 1864 list << QString::number( y );
1857 list << QString::number( w ); 1865 list << QString::number( w );
1858 list << QString::number( h ); 1866 list << QString::number( h );
1859 config->writeEntry("EditEventLayout",list ); 1867 config->writeEntry("EditEventLayout",list );
1860 1868
1861 wid = mTodoEditor; 1869 wid = mTodoEditor;
1862 x = wid->geometry().x(); 1870 x = wid->geometry().x();
1863 y = wid->geometry().y(); 1871 y = wid->geometry().y();
1864 w = wid->width(); 1872 w = wid->width();
1865 h = wid->height(); 1873 h = wid->height();
1866 list.clear(); 1874 list.clear();
1867 list << QString::number( x ); 1875 list << QString::number( x );
1868 list << QString::number( y ); 1876 list << QString::number( y );
1869 list << QString::number( w ); 1877 list << QString::number( w );
1870 list << QString::number( h ); 1878 list << QString::number( h );
1871 config->writeEntry("EditTodoLayout",list ); 1879 config->writeEntry("EditTodoLayout",list );
1872 wid = getEventViewerDialog(); 1880 wid = getEventViewerDialog();
1873 x = wid->geometry().x(); 1881 x = wid->geometry().x();
1874 y = wid->geometry().y(); 1882 y = wid->geometry().y();
1875 w = wid->width(); 1883 w = wid->width();
1876 h = wid->height(); 1884 h = wid->height();
1877 list.clear(); 1885 list.clear();
1878 list << QString::number( x ); 1886 list << QString::number( x );
1879 list << QString::number( y ); 1887 list << QString::number( y );
1880 list << QString::number( w ); 1888 list << QString::number( w );
1881 list << QString::number( h ); 1889 list << QString::number( h );
1882 config->writeEntry("ViewerLayout",list ); 1890 config->writeEntry("ViewerLayout",list );
1883 wid = mDialogManager->getSearchDialog(); 1891 wid = mDialogManager->getSearchDialog();
1884 if ( wid ) { 1892 if ( wid ) {
1885 x = wid->geometry().x(); 1893 x = wid->geometry().x();
1886 y = wid->geometry().y(); 1894 y = wid->geometry().y();
1887 w = wid->width(); 1895 w = wid->width();
1888 h = wid->height(); 1896 h = wid->height();
1889 list.clear(); 1897 list.clear();
1890 list << QString::number( x ); 1898 list << QString::number( x );
1891 list << QString::number( y ); 1899 list << QString::number( y );
1892 list << QString::number( w ); 1900 list << QString::number( w );
1893 list << QString::number( h ); 1901 list << QString::number( h );
1894 config->writeEntry("SearchLayout",list ); 1902 config->writeEntry("SearchLayout",list );
1895 } 1903 }
1896#endif 1904#endif
1897 1905
1898 1906
1899 config->sync(); 1907 config->sync();
1900} 1908}
1901 1909
1902void CalendarView::readFilterSettings(KConfig *config) 1910void CalendarView::readFilterSettings(KConfig *config)
1903{ 1911{
1904 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 1912 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
1905 1913
1906 mFilters.clear(); 1914 mFilters.clear();
1907 1915
1908 config->setGroup("General"); 1916 config->setGroup("General");
1909 QStringList filterList = config->readListEntry("CalendarFilters"); 1917 QStringList filterList = config->readListEntry("CalendarFilters");
1910 1918
1911 QStringList::ConstIterator it = filterList.begin(); 1919 QStringList::ConstIterator it = filterList.begin();
1912 QStringList::ConstIterator end = filterList.end(); 1920 QStringList::ConstIterator end = filterList.end();
1913 while(it != end) { 1921 while(it != end) {
1914 // kdDebug() << " filter: " << (*it) << endl; 1922 // kdDebug() << " filter: " << (*it) << endl;
1915 1923
1916 CalFilter *filter; 1924 CalFilter *filter;
1917 filter = new CalFilter(*it); 1925 filter = new CalFilter(*it);
1918 config->setGroup("Filter_" + (*it)); 1926 config->setGroup("Filter_" + (*it));
1919 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 1927 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
1920 filter->setCriteria(config->readNumEntry("Criteria",0)); 1928 filter->setCriteria(config->readNumEntry("Criteria",0));
1921 filter->setCategoryList(config->readListEntry("CategoryList")); 1929 filter->setCategoryList(config->readListEntry("CategoryList"));
1922 mFilters.append(filter); 1930 mFilters.append(filter);
1923 1931
1924 ++it; 1932 ++it;
1925 } 1933 }
1926 1934
1927 if (mFilters.count() == 0) { 1935 if (mFilters.count() == 0) {
1928 CalFilter *filter = new CalFilter(i18n("Default")); 1936 CalFilter *filter = new CalFilter(i18n("Default"));
1929 mFilters.append(filter); 1937 mFilters.append(filter);
1930 } 1938 }
1931 mFilterView->updateFilters(); 1939 mFilterView->updateFilters();
1932 config->setGroup("FilterView"); 1940 config->setGroup("FilterView");
1933 1941
1934 mFilterView->blockSignals(true); 1942 mFilterView->blockSignals(true);
1935 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 1943 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
1936 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 1944 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
1937 mFilterView->blockSignals(false); 1945 mFilterView->blockSignals(false);
1938 // We do it manually to avoid it being done twice by the above calls 1946 // We do it manually to avoid it being done twice by the above calls
1939 updateFilter(); 1947 updateFilter();
1940} 1948}
1941 1949
1942void CalendarView::writeFilterSettings(KConfig *config) 1950void CalendarView::writeFilterSettings(KConfig *config)
1943{ 1951{
1944 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 1952 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
1945 1953
1946 QStringList filterList; 1954 QStringList filterList;
1947 1955
1948 CalFilter *filter = mFilters.first(); 1956 CalFilter *filter = mFilters.first();
1949 while(filter) { 1957 while(filter) {
1950 // kdDebug() << " fn: " << filter->name() << endl; 1958 // kdDebug() << " fn: " << filter->name() << endl;
1951 filterList << filter->name(); 1959 filterList << filter->name();
1952 config->setGroup("Filter_" + filter->name()); 1960 config->setGroup("Filter_" + filter->name());
1953 config->writeEntry("Criteria",filter->criteria()); 1961 config->writeEntry("Criteria",filter->criteria());
1954 config->writeEntry("CategoryList",filter->categoryList()); 1962 config->writeEntry("CategoryList",filter->categoryList());
1955 filter = mFilters.next(); 1963 filter = mFilters.next();
1956 } 1964 }
1957 config->setGroup("General"); 1965 config->setGroup("General");
1958 config->writeEntry("CalendarFilters",filterList); 1966 config->writeEntry("CalendarFilters",filterList);
1959 1967
1960 config->setGroup("FilterView"); 1968 config->setGroup("FilterView");
1961 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 1969 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
1962 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 1970 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
1963} 1971}
1964 1972
1965 1973
1966void CalendarView::goToday() 1974void CalendarView::goToday()
1967{ 1975{
1968 mNavigator->selectToday(); 1976 mNavigator->selectToday();
1969} 1977}
1970 1978
1971void CalendarView::goNext() 1979void CalendarView::goNext()
1972{ 1980{
1973 mNavigator->selectNext(); 1981 mNavigator->selectNext();
1974} 1982}
1975 1983
1976void CalendarView::goPrevious() 1984void CalendarView::goPrevious()
1977{ 1985{
1978 mNavigator->selectPrevious(); 1986 mNavigator->selectPrevious();
1979} 1987}
1980void CalendarView::goNextMonth() 1988void CalendarView::goNextMonth()
1981{ 1989{
1982 mNavigator->selectNextMonth(); 1990 mNavigator->selectNextMonth();
1983} 1991}
1984 1992
1985void CalendarView::goPreviousMonth() 1993void CalendarView::goPreviousMonth()
1986{ 1994{
1987 mNavigator->selectPreviousMonth(); 1995 mNavigator->selectPreviousMonth();
1988} 1996}
1989void CalendarView::writeLocale() 1997void CalendarView::writeLocale()
1990{ 1998{
1991 //KPimGlobalPrefs::instance()->setGlobalConfig(); 1999 //KPimGlobalPrefs::instance()->setGlobalConfig();
1992#if 0 2000#if 0
1993 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); 2001 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime );
1994 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); 2002 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday );
1995 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); 2003 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate );
1996 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); 2004 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage );
1997 QString dummy = KOPrefs::instance()->mUserDateFormatLong; 2005 QString dummy = KOPrefs::instance()->mUserDateFormatLong;
1998 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 2006 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
1999 dummy = KOPrefs::instance()->mUserDateFormatShort; 2007 dummy = KOPrefs::instance()->mUserDateFormatShort;
2000 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 2008 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
2001 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, 2009 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving,
2002 KOPrefs::instance()->mDaylightsavingStart, 2010 KOPrefs::instance()->mDaylightsavingStart,
2003 KOPrefs::instance()->mDaylightsavingEnd ); 2011 KOPrefs::instance()->mDaylightsavingEnd );
2004 KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId ); 2012 KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId );
2005#endif 2013#endif
2006} 2014}
2007void CalendarView::updateConfig() 2015void CalendarView::updateConfig()
2008{ 2016{
2009 writeLocale(); 2017 writeLocale();
2010 if ( KOPrefs::instance()->mUseAppColors ) 2018 if ( KOPrefs::instance()->mUseAppColors )
2011 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 2019 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
2012 emit configChanged(); 2020 emit configChanged();
2013 mTodoList->updateConfig(); 2021 mTodoList->updateConfig();
2014 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 2022 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
2015 mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 2023 mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
2016 // To make the "fill window" configurations work 2024 // To make the "fill window" configurations work
2017 //mViewManager->raiseCurrentView(); 2025 //mViewManager->raiseCurrentView();
2018} 2026}
2019 2027
2020 2028
2021void CalendarView::eventChanged(Event *event) 2029void CalendarView::eventChanged(Event *event)
2022{ 2030{
2023 changeEventDisplay(event,KOGlobals::EVENTEDITED); 2031 changeEventDisplay(event,KOGlobals::EVENTEDITED);
2024 //updateUnmanagedViews(); 2032 //updateUnmanagedViews();
2025} 2033}
2026 2034
2027void CalendarView::eventAdded(Event *event) 2035void CalendarView::eventAdded(Event *event)
2028{ 2036{
2029 changeEventDisplay(event,KOGlobals::EVENTADDED); 2037 changeEventDisplay(event,KOGlobals::EVENTADDED);
2030} 2038}
2031 2039
2032void CalendarView::eventToBeDeleted(Event *) 2040void CalendarView::eventToBeDeleted(Event *)
2033{ 2041{
2034 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 2042 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
2035} 2043}
2036 2044
2037void CalendarView::eventDeleted() 2045void CalendarView::eventDeleted()
2038{ 2046{
2039 changeEventDisplay(0,KOGlobals::EVENTDELETED); 2047 changeEventDisplay(0,KOGlobals::EVENTDELETED);
2040} 2048}
2041void CalendarView::changeTodoDisplay(Todo *which, int action) 2049void CalendarView::changeTodoDisplay(Todo *which, int action)
2042{ 2050{
2043 changeIncidenceDisplay((Incidence *)which, action); 2051 changeIncidenceDisplay((Incidence *)which, action);
2044 mDateNavigator->updateView(); //LR 2052 mDateNavigator->updateView(); //LR
2045 //mDialogManager->updateSearchDialog(); 2053 //mDialogManager->updateSearchDialog();
2046 2054
2047 if (which) { 2055 if (which) {
2048 mViewManager->updateWNview(); 2056 mViewManager->updateWNview();
2049 //mTodoList->updateView(); 2057 //mTodoList->updateView();
2050 } 2058 }
2051 2059
2052} 2060}