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