summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2004-08-07 21:04:24 (UTC)
committer zautrix <zautrix>2004-08-07 21:04:24 (UTC)
commita9c3191a42084b6631dededef1709fa67eb2c048 (patch) (unidiff)
tree9950e3c8fc54c2994a4a50417008921bfdc58889 /korganizer
parent809e502f4b6e84524c10fa963e2d17564e6b1af9 (diff)
downloadkdepimpi-a9c3191a42084b6631dededef1709fa67eb2c048.zip
kdepimpi-a9c3191a42084b6631dededef1709fa67eb2c048.tar.gz
kdepimpi-a9c3191a42084b6631dededef1709fa67eb2c048.tar.bz2
more phone sync
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index b307649..d6ead37 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,3538 +1,3543 @@
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 locCh = ( local->lastModified() > mLastCalendarSync ); 732 locCh = ( local->lastModified() > mLastCalendarSync );
733 //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() ); 733 //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() );
734 if ( !remCh && ! locCh ) { 734 if ( !remCh && ! locCh ) {
735 //qDebug("both not changed "); 735 //qDebug("both not changed ");
736 lastSync = local->lastModified().addDays(1); 736 lastSync = local->lastModified().addDays(1);
737 } else { 737 } else {
738 if ( locCh ) { 738 if ( locCh ) {
739 //qDebug("loc changed %d %d", local->zaurusStat(), local->revision() ); 739 //qDebug("loc changed %d %d", local->zaurusStat(), local->revision() );
740 lastSync = local->lastModified().addDays( -1 ); 740 lastSync = local->lastModified().addDays( -1 );
741 if ( !remCh ) 741 if ( !remCh )
742 remote->setLastModified( lastSync.addDays( -1 ) ); 742 remote->setLastModified( lastSync.addDays( -1 ) );
743 } else { 743 } else {
744 //qDebug(" not loc changed "); 744 //qDebug(" not loc changed ");
745 lastSync = local->lastModified().addDays( 1 ); 745 lastSync = local->lastModified().addDays( 1 );
746 if ( remCh ) 746 if ( remCh )
747 remote->setLastModified( lastSync.addDays( 1 ) ); 747 remote->setLastModified( lastSync.addDays( 1 ) );
748 748
749 } 749 }
750 } 750 }
751 full = true; 751 full = true;
752 if ( mode < SYNC_PREF_ASK ) 752 if ( mode < SYNC_PREF_ASK )
753 mode = SYNC_PREF_ASK; 753 mode = SYNC_PREF_ASK;
754 } else { 754 } else {
755 if ( local->lastModified() == remote->lastModified() ) 755 if ( local->lastModified() == remote->lastModified() )
756 if ( local->revision() == remote->revision() ) 756 if ( local->revision() == remote->revision() )
757 return 0; 757 return 0;
758 758
759 } 759 }
760 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 760 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
761 761
762 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); 762 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision());
763 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); 763 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() );
764 //full = true; //debug only 764 //full = true; //debug only
765 if ( full ) { 765 if ( full ) {
766 bool equ = false; 766 bool equ = false;
767 if ( local->type() == "Event" ) { 767 if ( local->type() == "Event" ) {
768 equ = (*((Event*) local) == *((Event*) remote)); 768 equ = (*((Event*) local) == *((Event*) remote));
769 } 769 }
770 else if ( local->type() =="Todo" ) 770 else if ( local->type() =="Todo" )
771 equ = (*((Todo*) local) == (*(Todo*) remote)); 771 equ = (*((Todo*) local) == (*(Todo*) remote));
772 else if ( local->type() =="Journal" ) 772 else if ( local->type() =="Journal" )
773 equ = (*((Journal*) local) == *((Journal*) remote)); 773 equ = (*((Journal*) local) == *((Journal*) remote));
774 if ( equ ) { 774 if ( equ ) {
775 //qDebug("equal "); 775 //qDebug("equal ");
776 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 776 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
777 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 777 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
778 } 778 }
779 if ( mode < SYNC_PREF_FORCE_LOCAL ) 779 if ( mode < SYNC_PREF_FORCE_LOCAL )
780 return 0; 780 return 0;
781 781
782 }//else //debug only 782 }//else //debug only
783 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 783 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
784 } 784 }
785 int result; 785 int result;
786 bool localIsNew; 786 bool localIsNew;
787 if ( full && mode < SYNC_PREF_NEWEST ) 787 if ( full && mode < SYNC_PREF_NEWEST )
788 mode = SYNC_PREF_ASK; 788 mode = SYNC_PREF_ASK;
789 789
790 switch( mode ) { 790 switch( mode ) {
791 case SYNC_PREF_LOCAL: 791 case SYNC_PREF_LOCAL:
792 if ( lastSync > remote->lastModified() ) 792 if ( lastSync > remote->lastModified() )
793 return 1; 793 return 1;
794 if ( lastSync > local->lastModified() ) 794 if ( lastSync > local->lastModified() )
795 return 2; 795 return 2;
796 return 1; 796 return 1;
797 break; 797 break;
798 case SYNC_PREF_REMOTE: 798 case SYNC_PREF_REMOTE:
799 if ( lastSync > remote->lastModified() ) 799 if ( lastSync > remote->lastModified() )
800 return 1; 800 return 1;
801 if ( lastSync > local->lastModified() ) 801 if ( lastSync > local->lastModified() )
802 return 2; 802 return 2;
803 return 2; 803 return 2;
804 break; 804 break;
805 case SYNC_PREF_NEWEST: 805 case SYNC_PREF_NEWEST:
806 if ( local->lastModified() > remote->lastModified() ) 806 if ( local->lastModified() > remote->lastModified() )
807 return 1; 807 return 1;
808 else 808 else
809 return 2; 809 return 2;
810 break; 810 break;
811 case SYNC_PREF_ASK: 811 case SYNC_PREF_ASK:
812 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); 812 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() );
813 if ( lastSync > remote->lastModified() ) 813 if ( lastSync > remote->lastModified() )
814 return 1; 814 return 1;
815 if ( lastSync > local->lastModified() ) 815 if ( lastSync > local->lastModified() )
816 return 2; 816 return 2;
817 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); 817 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() );
818 localIsNew = local->lastModified() > remote->lastModified(); 818 localIsNew = local->lastModified() > remote->lastModified();
819 if ( localIsNew ) 819 if ( localIsNew )
820 getEventViewerDialog()->setColorMode( 1 ); 820 getEventViewerDialog()->setColorMode( 1 );
821 else 821 else
822 getEventViewerDialog()->setColorMode( 2 ); 822 getEventViewerDialog()->setColorMode( 2 );
823 getEventViewerDialog()->setIncidence(local); 823 getEventViewerDialog()->setIncidence(local);
824 if ( localIsNew ) 824 if ( localIsNew )
825 getEventViewerDialog()->setColorMode( 2 ); 825 getEventViewerDialog()->setColorMode( 2 );
826 else 826 else
827 getEventViewerDialog()->setColorMode( 1 ); 827 getEventViewerDialog()->setColorMode( 1 );
828 getEventViewerDialog()->addIncidence(remote); 828 getEventViewerDialog()->addIncidence(remote);
829 getEventViewerDialog()->setColorMode( 0 ); 829 getEventViewerDialog()->setColorMode( 0 );
830 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 830 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
831 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 831 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
832 getEventViewerDialog()->showMe(); 832 getEventViewerDialog()->showMe();
833 result = getEventViewerDialog()->executeS( localIsNew ); 833 result = getEventViewerDialog()->executeS( localIsNew );
834 return result; 834 return result;
835 835
836 break; 836 break;
837 case SYNC_PREF_FORCE_LOCAL: 837 case SYNC_PREF_FORCE_LOCAL:
838 return 1; 838 return 1;
839 break; 839 break;
840 case SYNC_PREF_FORCE_REMOTE: 840 case SYNC_PREF_FORCE_REMOTE:
841 return 2; 841 return 2;
842 break; 842 break;
843 843
844 default: 844 default:
845 // SYNC_PREF_TAKE_BOTH not implemented 845 // SYNC_PREF_TAKE_BOTH not implemented
846 break; 846 break;
847 } 847 }
848 return 0; 848 return 0;
849} 849}
850Event* CalendarView::getLastSyncEvent() 850Event* CalendarView::getLastSyncEvent()
851{ 851{
852 Event* lse; 852 Event* lse;
853 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 853 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
854 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 854 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
855 if (!lse) { 855 if (!lse) {
856 lse = new Event(); 856 lse = new Event();
857 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 857 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
858 QString sum = ""; 858 QString sum = "";
859 if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 859 if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
860 sum = "E: "; 860 sum = "E: ";
861 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 861 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
862 lse->setDtStart( mLastCalendarSync ); 862 lse->setDtStart( mLastCalendarSync );
863 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 863 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
864 lse->setCategories( i18n("SyncEvent") ); 864 lse->setCategories( i18n("SyncEvent") );
865 lse->setReadOnly( true ); 865 lse->setReadOnly( true );
866 mCalendar->addEvent( lse ); 866 mCalendar->addEvent( lse );
867 } 867 }
868 868
869 return lse; 869 return lse;
870 870
871} 871}
872// probaly useless 872// probaly useless
873void CalendarView::setupExternSyncProfiles() 873void CalendarView::setupExternSyncProfiles()
874{ 874{
875 Event* lse; 875 Event* lse;
876 mExternLastSyncEvent.clear(); 876 mExternLastSyncEvent.clear();
877 int i; 877 int i;
878 for ( i = 0; i < KOPrefs::instance()->mExternSyncProfiles.count(); ++i ) { 878 for ( i = 0; i < KOPrefs::instance()->mExternSyncProfiles.count(); ++i ) {
879 lse = mCalendar->event( "last-syncEvent-"+ KOPrefs::instance()->mExternSyncProfiles[i] ); 879 lse = mCalendar->event( "last-syncEvent-"+ KOPrefs::instance()->mExternSyncProfiles[i] );
880 if ( lse ) 880 if ( lse )
881 mExternLastSyncEvent.append( lse ); 881 mExternLastSyncEvent.append( lse );
882 else 882 else
883 qDebug("Last Sync event not found for %s ", KOPrefs::instance()->mExternSyncProfiles[i].latin1()); 883 qDebug("Last Sync event not found for %s ", KOPrefs::instance()->mExternSyncProfiles[i].latin1());
884 } 884 }
885 885
886} 886}
887// we check, if the to delete event has a id for a profile 887// we check, if the to delete event has a id for a profile
888// if yes, we set this id in the profile to delete 888// if yes, we set this id in the profile to delete
889void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 889void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
890{ 890{
891 if ( lastSync.count() == 0 ) { 891 if ( lastSync.count() == 0 ) {
892 //qDebug(" lastSync.count() == 0"); 892 //qDebug(" lastSync.count() == 0");
893 return; 893 return;
894 } 894 }
895 if ( toDelete->type() == "Journal" ) 895 if ( toDelete->type() == "Journal" )
896 return; 896 return;
897 897
898 Event* eve = lastSync.first(); 898 Event* eve = lastSync.first();
899 899
900 while ( eve ) { 900 while ( eve ) {
901 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 901 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
902 if ( !id.isEmpty() ) { 902 if ( !id.isEmpty() ) {
903 QString des = eve->description(); 903 QString des = eve->description();
904 QString pref = "e"; 904 QString pref = "e";
905 if ( toDelete->type() == "Todo" ) 905 if ( toDelete->type() == "Todo" )
906 pref = "t"; 906 pref = "t";
907 des += pref+ id + ","; 907 des += pref+ id + ",";
908 eve->setReadOnly( false ); 908 eve->setReadOnly( false );
909 eve->setDescription( des ); 909 eve->setDescription( des );
910 //qDebug("setdes %s ", des.latin1()); 910 //qDebug("setdes %s ", des.latin1());
911 eve->setReadOnly( true ); 911 eve->setReadOnly( true );
912 } 912 }
913 eve = lastSync.next(); 913 eve = lastSync.next();
914 } 914 }
915 915
916} 916}
917void CalendarView::checkExternalId( Incidence * inc ) 917void CalendarView::checkExternalId( Incidence * inc )
918{ 918{
919 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 919 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
920 checkExternSyncEvent( lastSync, inc ); 920 checkExternSyncEvent( lastSync, inc );
921 921
922} 922}
923bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 923bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
924{ 924{
925 bool syncOK = true; 925 bool syncOK = true;
926 int addedEvent = 0; 926 int addedEvent = 0;
927 int addedEventR = 0; 927 int addedEventR = 0;
928 int deletedEventR = 0; 928 int deletedEventR = 0;
929 int deletedEventL = 0; 929 int deletedEventL = 0;
930 int changedLocal = 0; 930 int changedLocal = 0;
931 int changedRemote = 0; 931 int changedRemote = 0;
932 //QPtrList<Event> el = local->rawEvents(); 932 //QPtrList<Event> el = local->rawEvents();
933 Event* eventR; 933 Event* eventR;
934 QString uid; 934 QString uid;
935 int take; 935 int take;
936 Event* eventL; 936 Event* eventL;
937 Event* eventRSync; 937 Event* eventRSync;
938 Event* eventLSync; 938 Event* eventLSync;
939 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 939 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
940 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 940 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
941 bool fullDateRange = false; 941 bool fullDateRange = false;
942 mLastCalendarSync = QDateTime::currentDateTime(); 942 mLastCalendarSync = QDateTime::currentDateTime();
943 QDateTime modifiedCalendar = mLastCalendarSync;; 943 QDateTime modifiedCalendar = mLastCalendarSync;;
944 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 944 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
945 if ( eventR ) { 945 if ( eventR ) {
946 eventRSync = (Event*) eventR->clone(); 946 eventRSync = (Event*) eventR->clone();
947 remote->deleteEvent(eventR ); 947 remote->deleteEvent(eventR );
948 948
949 } else { 949 } else {
950 fullDateRange = true; 950 fullDateRange = true;
951 eventRSync = new Event(); 951 eventRSync = new Event();
952 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 952 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
953 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 953 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
954 eventRSync->setDtStart( mLastCalendarSync ); 954 eventRSync->setDtStart( mLastCalendarSync );
955 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 955 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
956 eventRSync->setCategories( i18n("SyncEvent") ); 956 eventRSync->setCategories( i18n("SyncEvent") );
957 } 957 }
958 eventLSync = getLastSyncEvent(); 958 eventLSync = getLastSyncEvent();
959 if ( eventLSync->dtStart() == mLastCalendarSync ) 959 if ( eventLSync->dtStart() == mLastCalendarSync )
960 fullDateRange = true; 960 fullDateRange = true;
961 961
962 if ( ! fullDateRange ) { 962 if ( ! fullDateRange ) {
963 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 963 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
964 964
965 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 965 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
966 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 966 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
967 fullDateRange = true; 967 fullDateRange = true;
968 } 968 }
969 } 969 }
970 if ( fullDateRange ) 970 if ( fullDateRange )
971 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 971 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
972 else 972 else
973 mLastCalendarSync = eventLSync->dtStart(); 973 mLastCalendarSync = eventLSync->dtStart();
974 // for resyncing if own file has changed 974 // for resyncing if own file has changed
975 if ( mCurrentSyncDevice == "deleteaftersync" ) { 975 if ( mCurrentSyncDevice == "deleteaftersync" ) {
976 mLastCalendarSync = loadedFileVersion; 976 mLastCalendarSync = loadedFileVersion;
977 qDebug("setting mLastCalendarSync "); 977 qDebug("setting mLastCalendarSync ");
978 } 978 }
979 //qDebug("*************************** "); 979 //qDebug("*************************** ");
980 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); 980 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() );
981 QPtrList<Incidence> er = remote->rawIncidences(); 981 QPtrList<Incidence> er = remote->rawIncidences();
982 Incidence* inR = er.first(); 982 Incidence* inR = er.first();
983 Incidence* inL; 983 Incidence* inL;
984 QProgressBar bar( er.count(),0 ); 984 QProgressBar bar( er.count(),0 );
985 bar.setCaption (i18n("Syncing - close to abort!") ); 985 bar.setCaption (i18n("Syncing - close to abort!") );
986 986
987 int w = 300; 987 int w = 300;
988 if ( QApplication::desktop()->width() < 320 ) 988 if ( QApplication::desktop()->width() < 320 )
989 w = 220; 989 w = 220;
990 int h = bar.sizeHint().height() ; 990 int h = bar.sizeHint().height() ;
991 int dw = QApplication::desktop()->width(); 991 int dw = QApplication::desktop()->width();
992 int dh = QApplication::desktop()->height(); 992 int dh = QApplication::desktop()->height();
993 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 993 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
994 bar.show(); 994 bar.show();
995 int modulo = (er.count()/10)+1; 995 int modulo = (er.count()/10)+1;
996 int incCounter = 0; 996 int incCounter = 0;
997 while ( inR ) { 997 while ( inR ) {
998 if ( ! bar.isVisible() ) 998 if ( ! bar.isVisible() )
999 return false; 999 return false;
1000 if ( incCounter % modulo == 0 ) 1000 if ( incCounter % modulo == 0 )
1001 bar.setProgress( incCounter ); 1001 bar.setProgress( incCounter );
1002 ++incCounter; 1002 ++incCounter;
1003 uid = inR->uid(); 1003 uid = inR->uid();
1004 bool skipIncidence = false; 1004 bool skipIncidence = false;
1005 if ( uid.left(15) == QString("last-syncEvent-") ) 1005 if ( uid.left(15) == QString("last-syncEvent-") )
1006 skipIncidence = true; 1006 skipIncidence = true;
1007 1007
1008 qApp->processEvents(); 1008 qApp->processEvents();
1009 if ( !skipIncidence ) { 1009 if ( !skipIncidence ) {
1010 inL = local->incidence( uid ); 1010 inL = local->incidence( uid );
1011 if ( inL ) { // maybe conflict - same uid in both calendars 1011 if ( inL ) { // maybe conflict - same uid in both calendars
1012 int maxrev = inL->revision(); 1012 int maxrev = inL->revision();
1013 if ( maxrev < inR->revision() ) 1013 if ( maxrev < inR->revision() )
1014 maxrev = inR->revision(); 1014 maxrev = inR->revision();
1015 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1015 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1016 //qDebug("take %d %s ", take, inL->summary().latin1()); 1016 //qDebug("take %d %s ", take, inL->summary().latin1());
1017 if ( take == 3 ) 1017 if ( take == 3 )
1018 return false; 1018 return false;
1019 if ( take == 1 ) {// take local 1019 if ( take == 1 ) {// take local
1020 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1020 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1021 remote->deleteIncidence( inR ); 1021 remote->deleteIncidence( inR );
1022 if ( inL->revision() < maxrev ) 1022 if ( inL->revision() < maxrev )
1023 inL->setRevision( maxrev ); 1023 inL->setRevision( maxrev );
1024 remote->addIncidence( inL->clone() ); 1024 remote->addIncidence( inL->clone() );
1025 ++changedRemote; 1025 ++changedRemote;
1026 } else { 1026 } else {
1027 if ( inR->revision() < maxrev ) 1027 if ( inR->revision() < maxrev )
1028 inR->setRevision( maxrev ); 1028 inR->setRevision( maxrev );
1029 local->deleteIncidence( inL ); 1029 local->deleteIncidence( inL );
1030 local->addIncidence( inR->clone() ); 1030 local->addIncidence( inR->clone() );
1031 ++changedLocal; 1031 ++changedLocal;
1032 } 1032 }
1033 } 1033 }
1034 } else { // no conflict 1034 } else { // no conflict
1035 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1035 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1036 QString des = eventLSync->description(); 1036 QString des = eventLSync->description();
1037 QString pref = "e"; 1037 QString pref = "e";
1038 if ( inR->type() == "Todo" ) 1038 if ( inR->type() == "Todo" )
1039 pref = "t"; 1039 pref = "t";
1040 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1040 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1041 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1041 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1042 //remote->deleteIncidence( inR ); 1042 //remote->deleteIncidence( inR );
1043 ++deletedEventR; 1043 ++deletedEventR;
1044 } else { 1044 } else {
1045 inR->setLastModified( modifiedCalendar ); 1045 inR->setLastModified( modifiedCalendar );
1046 local->addIncidence( inR->clone() ); 1046 local->addIncidence( inR->clone() );
1047 ++addedEvent; 1047 ++addedEvent;
1048 } 1048 }
1049 } else { 1049 } else {
1050 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1050 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1051 inR->setLastModified( modifiedCalendar ); 1051 inR->setLastModified( modifiedCalendar );
1052 local->addIncidence( inR->clone() ); 1052 local->addIncidence( inR->clone() );
1053 ++addedEvent; 1053 ++addedEvent;
1054 } else { 1054 } else {
1055 checkExternSyncEvent(eventRSyncSharp, inR); 1055 checkExternSyncEvent(eventRSyncSharp, inR);
1056 remote->deleteIncidence( inR ); 1056 remote->deleteIncidence( inR );
1057 ++deletedEventR; 1057 ++deletedEventR;
1058 } 1058 }
1059 } 1059 }
1060 } 1060 }
1061 } 1061 }
1062 inR = er.next(); 1062 inR = er.next();
1063 } 1063 }
1064 QPtrList<Incidence> el = local->rawIncidences(); 1064 QPtrList<Incidence> el = local->rawIncidences();
1065 inL = el.first(); 1065 inL = el.first();
1066 modulo = (el.count()/10)+1; 1066 modulo = (el.count()/10)+1;
1067 bar.setCaption (i18n("Add / remove events") ); 1067 bar.setCaption (i18n("Add / remove events") );
1068 bar.setTotalSteps ( el.count() ) ; 1068 bar.setTotalSteps ( el.count() ) ;
1069 bar.show(); 1069 bar.show();
1070 incCounter = 0; 1070 incCounter = 0;
1071 1071
1072 while ( inL ) { 1072 while ( inL ) {
1073 1073
1074 qApp->processEvents(); 1074 qApp->processEvents();
1075 if ( ! bar.isVisible() ) 1075 if ( ! bar.isVisible() )
1076 return false; 1076 return false;
1077 if ( incCounter % modulo == 0 ) 1077 if ( incCounter % modulo == 0 )
1078 bar.setProgress( incCounter ); 1078 bar.setProgress( incCounter );
1079 ++incCounter; 1079 ++incCounter;
1080 uid = inL->uid(); 1080 uid = inL->uid();
1081 bool skipIncidence = false; 1081 bool skipIncidence = false;
1082 if ( uid.left(15) == QString("last-syncEvent-") ) 1082 if ( uid.left(15) == QString("last-syncEvent-") )
1083 skipIncidence = true; 1083 skipIncidence = true;
1084 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) 1084 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
1085 skipIncidence = true; 1085 skipIncidence = true;
1086 if ( !skipIncidence ) { 1086 if ( !skipIncidence ) {
1087 inR = remote->incidence( uid ); 1087 inR = remote->incidence( uid );
1088 if ( ! inR ) { 1088 if ( ! inR ) {
1089 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1089 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1090 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1090 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1091 local->deleteIncidence( inL ); 1091 local->deleteIncidence( inL );
1092 ++deletedEventL; 1092 ++deletedEventL;
1093 } else { 1093 } else {
1094 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { 1094 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
1095 inL->removeID(mCurrentSyncDevice ); 1095 inL->removeID(mCurrentSyncDevice );
1096 ++addedEventR; 1096 ++addedEventR;
1097 inL->setLastModified( modifiedCalendar ); 1097 inL->setLastModified( modifiedCalendar );
1098 remote->addIncidence( inL->clone() ); 1098 remote->addIncidence( inL->clone() );
1099 } 1099 }
1100 } 1100 }
1101 } else { 1101 } else {
1102 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1102 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1103 checkExternSyncEvent(eventLSyncSharp, inL); 1103 checkExternSyncEvent(eventLSyncSharp, inL);
1104 local->deleteIncidence( inL ); 1104 local->deleteIncidence( inL );
1105 ++deletedEventL; 1105 ++deletedEventL;
1106 } else { 1106 } else {
1107 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { 1107 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
1108 ++addedEventR; 1108 ++addedEventR;
1109 inL->setLastModified( modifiedCalendar ); 1109 inL->setLastModified( modifiedCalendar );
1110 remote->addIncidence( inL->clone() ); 1110 remote->addIncidence( inL->clone() );
1111 } 1111 }
1112 } 1112 }
1113 } 1113 }
1114 } 1114 }
1115 } 1115 }
1116 inL = el.next(); 1116 inL = el.next();
1117 } 1117 }
1118 1118
1119 bar.hide(); 1119 bar.hide();
1120 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1120 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1121 eventLSync->setReadOnly( false ); 1121 eventLSync->setReadOnly( false );
1122 eventLSync->setDtStart( mLastCalendarSync ); 1122 eventLSync->setDtStart( mLastCalendarSync );
1123 eventRSync->setDtStart( mLastCalendarSync ); 1123 eventRSync->setDtStart( mLastCalendarSync );
1124 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1124 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1125 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1125 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1126 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1126 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1127 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1127 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1128 eventLSync->setReadOnly( true ); 1128 eventLSync->setReadOnly( true );
1129 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 1129 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
1130 remote->addEvent( eventRSync ); 1130 remote->addEvent( eventRSync );
1131 QString mes; 1131 QString mes;
1132 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 ); 1132 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 );
1133 if ( KOPrefs::instance()->mShowSyncSummary ) { 1133 if ( KOPrefs::instance()->mShowSyncSummary ) {
1134 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); 1134 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") );
1135 } 1135 }
1136 qDebug( mes ); 1136 qDebug( mes );
1137 mCalendar->checkAlarmForIncidence( 0, true ); 1137 mCalendar->checkAlarmForIncidence( 0, true );
1138 return syncOK; 1138 return syncOK;
1139} 1139}
1140 1140
1141void CalendarView::setSyncDevice( QString s ) 1141void CalendarView::setSyncDevice( QString s )
1142{ 1142{
1143 mCurrentSyncDevice= s; 1143 mCurrentSyncDevice= s;
1144} 1144}
1145void CalendarView::setSyncName( QString s ) 1145void CalendarView::setSyncName( QString s )
1146{ 1146{
1147 mCurrentSyncName= s; 1147 mCurrentSyncName= s;
1148} 1148}
1149bool CalendarView::syncCalendar(QString filename, int mode) 1149bool CalendarView::syncCalendar(QString filename, int mode)
1150{ 1150{
1151 mGlobalSyncMode = SYNC_MODE_NORMAL; 1151 mGlobalSyncMode = SYNC_MODE_NORMAL;
1152 CalendarLocal* calendar = new CalendarLocal(); 1152 CalendarLocal* calendar = new CalendarLocal();
1153 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1153 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1154 FileStorage* storage = new FileStorage( calendar ); 1154 FileStorage* storage = new FileStorage( calendar );
1155 bool syncOK = false; 1155 bool syncOK = false;
1156 storage->setFileName( filename ); 1156 storage->setFileName( filename );
1157 // qDebug("loading ... "); 1157 // qDebug("loading ... ");
1158 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { 1158 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) {
1159 getEventViewerDialog()->setSyncMode( true ); 1159 getEventViewerDialog()->setSyncMode( true );
1160 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1160 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1161 getEventViewerDialog()->setSyncMode( false ); 1161 getEventViewerDialog()->setSyncMode( false );
1162 if ( syncOK ) { 1162 if ( syncOK ) {
1163 if ( KOPrefs::instance()->mWriteBackFile ) 1163 if ( KOPrefs::instance()->mWriteBackFile )
1164 { 1164 {
1165 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 1165 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
1166 storage->save(); 1166 storage->save();
1167 } 1167 }
1168 } 1168 }
1169 setModified( true ); 1169 setModified( true );
1170 } 1170 }
1171 delete storage; 1171 delete storage;
1172 delete calendar; 1172 delete calendar;
1173 if ( syncOK ) 1173 if ( syncOK )
1174 updateView(); 1174 updateView();
1175 return syncOK; 1175 return syncOK;
1176} 1176}
1177void CalendarView::syncPhone() 1177void CalendarView::syncPhone()
1178{ 1178{
1179 syncExternal( 1 ); 1179 syncExternal( 1 );
1180} 1180}
1181void CalendarView::syncExternal( int mode ) 1181void CalendarView::syncExternal( int mode )
1182{ 1182{
1183 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1183 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1184 //mCurrentSyncDevice = "sharp-DTM"; 1184 //mCurrentSyncDevice = "sharp-DTM";
1185 if ( KOPrefs::instance()->mAskForPreferences ) 1185 if ( KOPrefs::instance()->mAskForPreferences )
1186 edit_sync_options(); 1186 edit_sync_options();
1187 qApp->processEvents(); 1187 qApp->processEvents();
1188 CalendarLocal* calendar = new CalendarLocal(); 1188 CalendarLocal* calendar = new CalendarLocal();
1189 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1189 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1190 bool syncOK = false; 1190 bool syncOK = false;
1191 bool loadSuccess = false; 1191 bool loadSuccess = false;
1192 PhoneFormat* phoneFormat = 0; 1192 PhoneFormat* phoneFormat = 0;
1193#ifndef DESKTOP_VERSION 1193#ifndef DESKTOP_VERSION
1194 SharpFormat* sharpFormat = 0; 1194 SharpFormat* sharpFormat = 0;
1195 if ( mode == 0 ) { // sharp 1195 if ( mode == 0 ) { // sharp
1196 sharpFormat = new SharpFormat () ; 1196 sharpFormat = new SharpFormat () ;
1197 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1197 loadSuccess = sharpFormat->load( calendar, mCalendar );
1198 1198
1199 } else 1199 } else
1200#endif 1200#endif
1201 if ( mode == 1 ) { // phone 1201 if ( mode == 1 ) { // phone
1202 phoneFormat = new PhoneFormat (); 1202 phoneFormat = new PhoneFormat ();
1203 loadSuccess = phoneFormat->load( calendar, mCalendar ); 1203 loadSuccess = phoneFormat->load( calendar,
1204 mCalendar,
1205 mCurrentSyncDevice,
1206 KOPrefs::instance()->mPhoneDevice,
1207 KOPrefs::instance()->mPhoneConnection,
1208 KOPrefs::instance()->mPhoneModel);
1204 1209
1205 } else 1210 } else
1206 return; 1211 return;
1207 if ( loadSuccess ) { 1212 if ( loadSuccess ) {
1208 getEventViewerDialog()->setSyncMode( true ); 1213 getEventViewerDialog()->setSyncMode( true );
1209 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); 1214 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
1210 getEventViewerDialog()->setSyncMode( false ); 1215 getEventViewerDialog()->setSyncMode( false );
1211 qApp->processEvents(); 1216 qApp->processEvents();
1212 if ( syncOK ) { 1217 if ( syncOK ) {
1213 if ( KOPrefs::instance()->mWriteBackFile ) 1218 if ( KOPrefs::instance()->mWriteBackFile )
1214 { 1219 {
1215 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1220 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1216 Incidence* inc = iL.first(); 1221 Incidence* inc = iL.first();
1217 /* obsolete 1222 /* obsolete
1218 while ( inc ) { 1223 while ( inc ) {
1219 inc->setZaurusStat( inc->revision () ); 1224 inc->setZaurusStat( inc->revision () );
1220 inc = iL.next(); 1225 inc = iL.next();
1221 } 1226 }
1222 */ 1227 */
1223#ifndef DESKTOP_VERSION 1228#ifndef DESKTOP_VERSION
1224 if ( sharpFormat ) 1229 if ( sharpFormat )
1225 sharpFormat->save(calendar); 1230 sharpFormat->save(calendar);
1226#endif 1231#endif
1227 if ( phoneFormat ) 1232 if ( phoneFormat )
1228 phoneFormat->save(calendar); 1233 phoneFormat->save(calendar);
1229 iL = calendar->rawIncidences(); 1234 iL = calendar->rawIncidences();
1230 inc = iL.first(); 1235 inc = iL.first();
1231 Incidence* loc; 1236 Incidence* loc;
1232 while ( inc ) { 1237 while ( inc ) {
1233 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1238 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1234 loc = mCalendar->incidence(inc->uid() ); 1239 loc = mCalendar->incidence(inc->uid() );
1235 if ( loc ) { 1240 if ( loc ) {
1236 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1241 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1237 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1242 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1238 } 1243 }
1239 } 1244 }
1240 inc = iL.next(); 1245 inc = iL.next();
1241 } 1246 }
1242 Incidence* lse = getLastSyncEvent(); 1247 Incidence* lse = getLastSyncEvent();
1243 if ( lse ) { 1248 if ( lse ) {
1244 lse->setReadOnly( false ); 1249 lse->setReadOnly( false );
1245 lse->setDescription( "" ); 1250 lse->setDescription( "" );
1246 lse->setReadOnly( true ); 1251 lse->setReadOnly( true );
1247 } 1252 }
1248 } 1253 }
1249 } 1254 }
1250 setModified( true ); 1255 setModified( true );
1251 } else { 1256 } else {
1252 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1257 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1253 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1258 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1254 question, i18n("Ok")) ; 1259 question, i18n("Ok")) ;
1255 1260
1256 } 1261 }
1257 delete calendar; 1262 delete calendar;
1258 updateView(); 1263 updateView();
1259 return ;//syncOK; 1264 return ;//syncOK;
1260 1265
1261} 1266}
1262void CalendarView::syncSharp() 1267void CalendarView::syncSharp()
1263{ 1268{
1264 syncExternal( 0 ); 1269 syncExternal( 0 );
1265 1270
1266} 1271}
1267 1272
1268 1273
1269#include <kabc/stdaddressbook.h> 1274#include <kabc/stdaddressbook.h>
1270bool CalendarView::importBday() 1275bool CalendarView::importBday()
1271{ 1276{
1272 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1277 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1273 KABC::AddressBook::Iterator it; 1278 KABC::AddressBook::Iterator it;
1274 int count = 0; 1279 int count = 0;
1275 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1280 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1276 ++count; 1281 ++count;
1277 } 1282 }
1278 QProgressBar bar(count,0 ); 1283 QProgressBar bar(count,0 );
1279 int w = 300; 1284 int w = 300;
1280 if ( QApplication::desktop()->width() < 320 ) 1285 if ( QApplication::desktop()->width() < 320 )
1281 w = 220; 1286 w = 220;
1282 int h = bar.sizeHint().height() ; 1287 int h = bar.sizeHint().height() ;
1283 int dw = QApplication::desktop()->width(); 1288 int dw = QApplication::desktop()->width();
1284 int dh = QApplication::desktop()->height(); 1289 int dh = QApplication::desktop()->height();
1285 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1290 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1286 bar.show(); 1291 bar.show();
1287 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1292 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1288 qApp->processEvents(); 1293 qApp->processEvents();
1289 count = 0; 1294 count = 0;
1290 int addCount = 0; 1295 int addCount = 0;
1291 KCal::Attendee* a = 0; 1296 KCal::Attendee* a = 0;
1292 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1297 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1293 if ( ! bar.isVisible() ) 1298 if ( ! bar.isVisible() )
1294 return false; 1299 return false;
1295 bar.setProgress( count++ ); 1300 bar.setProgress( count++ );
1296 qApp->processEvents(); 1301 qApp->processEvents();
1297 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1302 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1298 if ( (*it).birthday().date().isValid() ){ 1303 if ( (*it).birthday().date().isValid() ){
1299 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1304 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1300 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1305 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1301 ++addCount; 1306 ++addCount;
1302 } 1307 }
1303 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1308 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1304 if ( anni.isValid() ){ 1309 if ( anni.isValid() ){
1305 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1310 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1306 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1311 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1307 ++addCount; 1312 ++addCount;
1308 } 1313 }
1309 } 1314 }
1310 updateView(); 1315 updateView();
1311 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1316 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1312 return true; 1317 return true;
1313} 1318}
1314 1319
1315bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1320bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1316{ 1321{
1317 //qDebug("addAnni "); 1322 //qDebug("addAnni ");
1318 Event * ev = new Event(); 1323 Event * ev = new Event();
1319 if ( a ) { 1324 if ( a ) {
1320 ev->addAttendee( a ); 1325 ev->addAttendee( a );
1321 } 1326 }
1322 QString kind; 1327 QString kind;
1323 if ( birthday ) 1328 if ( birthday )
1324 kind = i18n( "Birthday" ); 1329 kind = i18n( "Birthday" );
1325 else 1330 else
1326 kind = i18n( "Anniversary" ); 1331 kind = i18n( "Anniversary" );
1327 ev->setSummary( name + " - " + kind ); 1332 ev->setSummary( name + " - " + kind );
1328 ev->setOrganizer( "nobody@nowhere" ); 1333 ev->setOrganizer( "nobody@nowhere" );
1329 ev->setCategories( kind ); 1334 ev->setCategories( kind );
1330 ev->setDtStart( QDateTime(date) ); 1335 ev->setDtStart( QDateTime(date) );
1331 ev->setDtEnd( QDateTime(date) ); 1336 ev->setDtEnd( QDateTime(date) );
1332 ev->setFloats( true ); 1337 ev->setFloats( true );
1333 Recurrence * rec = ev->recurrence(); 1338 Recurrence * rec = ev->recurrence();
1334 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1339 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1335 rec->addYearlyNum( date.month() ); 1340 rec->addYearlyNum( date.month() );
1336 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1341 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1337 delete ev; 1342 delete ev;
1338 return false; 1343 return false;
1339 } 1344 }
1340 return true; 1345 return true;
1341 1346
1342} 1347}
1343bool CalendarView::importQtopia( const QString &categories, 1348bool CalendarView::importQtopia( const QString &categories,
1344 const QString &datebook, 1349 const QString &datebook,
1345 const QString &todolist ) 1350 const QString &todolist )
1346{ 1351{
1347 1352
1348 QtopiaFormat qtopiaFormat; 1353 QtopiaFormat qtopiaFormat;
1349 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1354 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1350 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1355 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1351 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1356 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1352 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1357 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1353 1358
1354 updateView(); 1359 updateView();
1355 return true; 1360 return true;
1356 1361
1357#if 0 1362#if 0
1358 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1363 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1359 mCurrentSyncDevice = "qtopia-XML"; 1364 mCurrentSyncDevice = "qtopia-XML";
1360 if ( KOPrefs::instance()->mAskForPreferences ) 1365 if ( KOPrefs::instance()->mAskForPreferences )
1361 edit_sync_options(); 1366 edit_sync_options();
1362 qApp->processEvents(); 1367 qApp->processEvents();
1363 CalendarLocal* calendar = new CalendarLocal(); 1368 CalendarLocal* calendar = new CalendarLocal();
1364 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1369 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1365 bool syncOK = false; 1370 bool syncOK = false;
1366 QtopiaFormat qtopiaFormat; 1371 QtopiaFormat qtopiaFormat;
1367 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1372 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1368 bool loadOk = true; 1373 bool loadOk = true;
1369 if ( !categories.isEmpty() ) 1374 if ( !categories.isEmpty() )
1370 loadOk = qtopiaFormat.load( calendar, categories ); 1375 loadOk = qtopiaFormat.load( calendar, categories );
1371 if ( loadOk && !datebook.isEmpty() ) 1376 if ( loadOk && !datebook.isEmpty() )
1372 loadOk = qtopiaFormat.load( calendar, datebook ); 1377 loadOk = qtopiaFormat.load( calendar, datebook );
1373 if ( loadOk && !todolist.isEmpty() ) 1378 if ( loadOk && !todolist.isEmpty() )
1374 loadOk = qtopiaFormat.load( calendar, todolist ); 1379 loadOk = qtopiaFormat.load( calendar, todolist );
1375 1380
1376 if ( loadOk ) { 1381 if ( loadOk ) {
1377 getEventViewerDialog()->setSyncMode( true ); 1382 getEventViewerDialog()->setSyncMode( true );
1378 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); 1383 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
1379 getEventViewerDialog()->setSyncMode( false ); 1384 getEventViewerDialog()->setSyncMode( false );
1380 qApp->processEvents(); 1385 qApp->processEvents();
1381 if ( syncOK ) { 1386 if ( syncOK ) {
1382 if ( KOPrefs::instance()->mWriteBackFile ) 1387 if ( KOPrefs::instance()->mWriteBackFile )
1383 { 1388 {
1384 // write back XML file 1389 // write back XML file
1385 1390
1386 } 1391 }
1387 setModified( true ); 1392 setModified( true );
1388 } 1393 }
1389 } else { 1394 } else {
1390 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1395 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1391 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1396 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1392 question, i18n("Ok")) ; 1397 question, i18n("Ok")) ;
1393 } 1398 }
1394 delete calendar; 1399 delete calendar;
1395 updateView(); 1400 updateView();
1396 return syncOK; 1401 return syncOK;
1397 1402
1398 1403
1399#endif 1404#endif
1400 1405
1401} 1406}
1402 1407
1403void CalendarView::setSyncEventsReadOnly() 1408void CalendarView::setSyncEventsReadOnly()
1404{ 1409{
1405 Event * ev; 1410 Event * ev;
1406 QPtrList<Event> eL = mCalendar->rawEvents(); 1411 QPtrList<Event> eL = mCalendar->rawEvents();
1407 ev = eL.first(); 1412 ev = eL.first();
1408 while ( ev ) { 1413 while ( ev ) {
1409 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1414 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1410 ev->setReadOnly( true ); 1415 ev->setReadOnly( true );
1411 ev = eL.next(); 1416 ev = eL.next();
1412 } 1417 }
1413} 1418}
1414bool CalendarView::openCalendar(QString filename, bool merge) 1419bool CalendarView::openCalendar(QString filename, bool merge)
1415{ 1420{
1416 1421
1417 if (filename.isEmpty()) { 1422 if (filename.isEmpty()) {
1418 return false; 1423 return false;
1419 } 1424 }
1420 1425
1421 if (!QFile::exists(filename)) { 1426 if (!QFile::exists(filename)) {
1422 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1427 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1423 return false; 1428 return false;
1424 } 1429 }
1425 1430
1426 globalFlagBlockAgenda = 1; 1431 globalFlagBlockAgenda = 1;
1427 if (!merge) mCalendar->close(); 1432 if (!merge) mCalendar->close();
1428 1433
1429 mStorage->setFileName( filename ); 1434 mStorage->setFileName( filename );
1430 1435
1431 if ( mStorage->load(KOPrefs::instance()->mUseQuicksave) ) { 1436 if ( mStorage->load(KOPrefs::instance()->mUseQuicksave) ) {
1432 if ( merge ) ;//setModified( true ); 1437 if ( merge ) ;//setModified( true );
1433 else { 1438 else {
1434 //setModified( true ); 1439 //setModified( true );
1435 mViewManager->setDocumentId( filename ); 1440 mViewManager->setDocumentId( filename );
1436 mDialogManager->setDocumentId( filename ); 1441 mDialogManager->setDocumentId( filename );
1437 mTodoList->setDocumentId( filename ); 1442 mTodoList->setDocumentId( filename );
1438 } 1443 }
1439 globalFlagBlockAgenda = 2; 1444 globalFlagBlockAgenda = 2;
1440 // if ( getLastSyncEvent() ) 1445 // if ( getLastSyncEvent() )
1441 // getLastSyncEvent()->setReadOnly( true ); 1446 // getLastSyncEvent()->setReadOnly( true );
1442 mCalendar->reInitAlarmSettings(); 1447 mCalendar->reInitAlarmSettings();
1443 setSyncEventsReadOnly(); 1448 setSyncEventsReadOnly();
1444 updateUnmanagedViews(); 1449 updateUnmanagedViews();
1445 updateView(); 1450 updateView();
1446 if ( filename != MainWindow::defaultFileName() ) 1451 if ( filename != MainWindow::defaultFileName() )
1447 saveCalendar( MainWindow::defaultFileName() ); 1452 saveCalendar( MainWindow::defaultFileName() );
1448 loadedFileVersion = QDateTime::currentDateTime(); 1453 loadedFileVersion = QDateTime::currentDateTime();
1449 return true; 1454 return true;
1450 } else { 1455 } else {
1451 // while failing to load, the calendar object could 1456 // while failing to load, the calendar object could
1452 // have become partially populated. Clear it out. 1457 // have become partially populated. Clear it out.
1453 if ( !merge ) mCalendar->close(); 1458 if ( !merge ) mCalendar->close();
1454 1459
1455 KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1460 KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1456 1461
1457 globalFlagBlockAgenda = 2; 1462 globalFlagBlockAgenda = 2;
1458 updateView(); 1463 updateView();
1459 } 1464 }
1460 return false; 1465 return false;
1461} 1466}
1462void CalendarView::setLoadedFileVersion(QDateTime dt) 1467void CalendarView::setLoadedFileVersion(QDateTime dt)
1463{ 1468{
1464 loadedFileVersion = dt; 1469 loadedFileVersion = dt;
1465} 1470}
1466bool CalendarView::checkFileChanged(QString fn) 1471bool CalendarView::checkFileChanged(QString fn)
1467{ 1472{
1468 QFileInfo finf ( fn ); 1473 QFileInfo finf ( fn );
1469 if ( !finf.exists() ) 1474 if ( !finf.exists() )
1470 return true; 1475 return true;
1471 QDateTime dt = finf.lastModified (); 1476 QDateTime dt = finf.lastModified ();
1472 if ( dt <= loadedFileVersion ) 1477 if ( dt <= loadedFileVersion )
1473 return false; 1478 return false;
1474 return true; 1479 return true;
1475 1480
1476} 1481}
1477bool CalendarView::checkFileVersion(QString fn) 1482bool CalendarView::checkFileVersion(QString fn)
1478{ 1483{
1479 QFileInfo finf ( fn ); 1484 QFileInfo finf ( fn );
1480 if ( !finf.exists() ) 1485 if ( !finf.exists() )
1481 return true; 1486 return true;
1482 QDateTime dt = finf.lastModified (); 1487 QDateTime dt = finf.lastModified ();
1483 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1488 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1484 //qDebug("file on disk version %s",dt.toString().latin1()); 1489 //qDebug("file on disk version %s",dt.toString().latin1());
1485 if ( dt <= loadedFileVersion ) 1490 if ( dt <= loadedFileVersion )
1486 return true; 1491 return true;
1487 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)) , 1492 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)) ,
1488 i18n("KO/Pi Warning"),i18n("Overwrite"), 1493 i18n("KO/Pi Warning"),i18n("Overwrite"),
1489 i18n("Sync+save")); 1494 i18n("Sync+save"));
1490 1495
1491 if ( km == KMessageBox::Cancel ) 1496 if ( km == KMessageBox::Cancel )
1492 return false; 1497 return false;
1493 if ( km == KMessageBox::Yes ) 1498 if ( km == KMessageBox::Yes )
1494 return true; 1499 return true;
1495 1500
1496 setSyncDevice("deleteaftersync" ); 1501 setSyncDevice("deleteaftersync" );
1497 KOPrefs::instance()->mAskForPreferences = true; 1502 KOPrefs::instance()->mAskForPreferences = true;
1498 KOPrefs::instance()->mSyncAlgoPrefs = 3; 1503 KOPrefs::instance()->mSyncAlgoPrefs = 3;
1499 KOPrefs::instance()->mWriteBackFile = false; 1504 KOPrefs::instance()->mWriteBackFile = false;
1500 KOPrefs::instance()->mWriteBackExistingOnly = false; 1505 KOPrefs::instance()->mWriteBackExistingOnly = false;
1501 KOPrefs::instance()->mShowSyncSummary = false; 1506 KOPrefs::instance()->mShowSyncSummary = false;
1502 syncCalendar( fn, 3 ); 1507 syncCalendar( fn, 3 );
1503 Event * e = getLastSyncEvent(); 1508 Event * e = getLastSyncEvent();
1504 mCalendar->deleteEvent ( e ); 1509 mCalendar->deleteEvent ( e );
1505 updateView(); 1510 updateView();
1506 return true; 1511 return true;
1507} 1512}
1508 1513
1509bool CalendarView::saveCalendar( QString filename ) 1514bool CalendarView::saveCalendar( QString filename )
1510{ 1515{
1511 1516
1512 // Store back all unsaved data into calendar object 1517 // Store back all unsaved data into calendar object
1513 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1518 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1514 if ( mViewManager->currentView() ) 1519 if ( mViewManager->currentView() )
1515 mViewManager->currentView()->flushView(); 1520 mViewManager->currentView()->flushView();
1516 1521
1517 //mStorage->setFileName( filename ); 1522 //mStorage->setFileName( filename );
1518 1523
1519 mStorage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 1524 mStorage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
1520 mStorage->setFileName( filename ); 1525 mStorage->setFileName( filename );
1521 bool success; 1526 bool success;
1522 success = mStorage->save(); 1527 success = mStorage->save();
1523 if ( !success ) { 1528 if ( !success ) {
1524 return false; 1529 return false;
1525 } 1530 }
1526 1531
1527 return true; 1532 return true;
1528} 1533}
1529 1534
1530void CalendarView::closeCalendar() 1535void CalendarView::closeCalendar()
1531{ 1536{
1532 1537
1533 // child windows no longer valid 1538 // child windows no longer valid
1534 emit closingDown(); 1539 emit closingDown();
1535 1540
1536 mCalendar->close(); 1541 mCalendar->close();
1537 setModified(false); 1542 setModified(false);
1538 updateView(); 1543 updateView();
1539} 1544}
1540 1545
1541void CalendarView::archiveCalendar() 1546void CalendarView::archiveCalendar()
1542{ 1547{
1543 mDialogManager->showArchiveDialog(); 1548 mDialogManager->showArchiveDialog();
1544} 1549}
1545 1550
1546 1551
1547void CalendarView::readSettings() 1552void CalendarView::readSettings()
1548{ 1553{
1549 1554
1550 1555
1551 // mViewManager->showAgendaView(); 1556 // mViewManager->showAgendaView();
1552 QString str; 1557 QString str;
1553 //qDebug("CalendarView::readSettings() "); 1558 //qDebug("CalendarView::readSettings() ");
1554 // read settings from the KConfig, supplying reasonable 1559 // read settings from the KConfig, supplying reasonable
1555 // defaults where none are to be found 1560 // defaults where none are to be found
1556 KConfig *config = KOGlobals::config(); 1561 KConfig *config = KOGlobals::config();
1557#ifndef KORG_NOSPLITTER 1562#ifndef KORG_NOSPLITTER
1558 config->setGroup("KOrganizer Geometry"); 1563 config->setGroup("KOrganizer Geometry");
1559 1564
1560 QValueList<int> sizes = config->readIntListEntry("Separator1"); 1565 QValueList<int> sizes = config->readIntListEntry("Separator1");
1561 if (sizes.count() != 2) { 1566 if (sizes.count() != 2) {
1562 sizes << mDateNavigator->minimumSizeHint().width(); 1567 sizes << mDateNavigator->minimumSizeHint().width();
1563 sizes << 300; 1568 sizes << 300;
1564 } 1569 }
1565 mPanner->setSizes(sizes); 1570 mPanner->setSizes(sizes);
1566 1571
1567 sizes = config->readIntListEntry("Separator2"); 1572 sizes = config->readIntListEntry("Separator2");
1568 if ( ( mResourceView && sizes.count() == 4 ) || 1573 if ( ( mResourceView && sizes.count() == 4 ) ||
1569 ( !mResourceView && sizes.count() == 3 ) ) { 1574 ( !mResourceView && sizes.count() == 3 ) ) {
1570 mLeftSplitter->setSizes(sizes); 1575 mLeftSplitter->setSizes(sizes);
1571 } 1576 }
1572#endif 1577#endif
1573 globalFlagBlockAgenda = 1; 1578 globalFlagBlockAgenda = 1;
1574 mViewManager->showAgendaView(); 1579 mViewManager->showAgendaView();
1575 //mViewManager->readSettings( config ); 1580 //mViewManager->readSettings( config );
1576 mTodoList->restoreLayout(config,QString("Todo Layout")); 1581 mTodoList->restoreLayout(config,QString("Todo Layout"));
1577 readFilterSettings(config); 1582 readFilterSettings(config);
1578 config->setGroup( "Views" ); 1583 config->setGroup( "Views" );
1579 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 1584 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
1580 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 1585 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
1581 else if ( dateCount == 7 ) mNavigator->selectWeek(); 1586 else if ( dateCount == 7 ) mNavigator->selectWeek();
1582 else mNavigator->selectDates( dateCount ); 1587 else mNavigator->selectDates( dateCount );
1583 // mViewManager->readSettings( config ); 1588 // mViewManager->readSettings( config );
1584 updateConfig(); 1589 updateConfig();
1585 globalFlagBlockAgenda = 2; 1590 globalFlagBlockAgenda = 2;
1586 mViewManager->readSettings( config ); 1591 mViewManager->readSettings( config );
1587#ifdef DESKTOP_VERSION 1592#ifdef DESKTOP_VERSION
1588 config->setGroup("WidgetLayout"); 1593 config->setGroup("WidgetLayout");
1589 QStringList list; 1594 QStringList list;
1590 list = config->readListEntry("MainLayout"); 1595 list = config->readListEntry("MainLayout");
1591 int x,y,w,h; 1596 int x,y,w,h;
1592 if ( ! list.isEmpty() ) { 1597 if ( ! list.isEmpty() ) {
1593 x = list[0].toInt(); 1598 x = list[0].toInt();
1594 y = list[1].toInt(); 1599 y = list[1].toInt();
1595 w = list[2].toInt(); 1600 w = list[2].toInt();
1596 h = list[3].toInt(); 1601 h = list[3].toInt();
1597 topLevelWidget()->setGeometry(x,y,w,h); 1602 topLevelWidget()->setGeometry(x,y,w,h);
1598 1603
1599 } else { 1604 } else {
1600 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 1605 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
1601 } 1606 }
1602 list = config->readListEntry("EditEventLayout"); 1607 list = config->readListEntry("EditEventLayout");
1603 if ( ! list.isEmpty() ) { 1608 if ( ! list.isEmpty() ) {
1604 x = list[0].toInt(); 1609 x = list[0].toInt();
1605 y = list[1].toInt(); 1610 y = list[1].toInt();
1606 w = list[2].toInt(); 1611 w = list[2].toInt();
1607 h = list[3].toInt(); 1612 h = list[3].toInt();
1608 mEventEditor->setGeometry(x,y,w,h); 1613 mEventEditor->setGeometry(x,y,w,h);
1609 1614
1610 } 1615 }
1611 list = config->readListEntry("EditTodoLayout"); 1616 list = config->readListEntry("EditTodoLayout");
1612 if ( ! list.isEmpty() ) { 1617 if ( ! list.isEmpty() ) {
1613 x = list[0].toInt(); 1618 x = list[0].toInt();
1614 y = list[1].toInt(); 1619 y = list[1].toInt();
1615 w = list[2].toInt(); 1620 w = list[2].toInt();
1616 h = list[3].toInt(); 1621 h = list[3].toInt();
1617 mTodoEditor->setGeometry(x,y,w,h); 1622 mTodoEditor->setGeometry(x,y,w,h);
1618 1623
1619 } 1624 }
1620 list = config->readListEntry("ViewerLayout"); 1625 list = config->readListEntry("ViewerLayout");
1621 if ( ! list.isEmpty() ) { 1626 if ( ! list.isEmpty() ) {
1622 x = list[0].toInt(); 1627 x = list[0].toInt();
1623 y = list[1].toInt(); 1628 y = list[1].toInt();
1624 w = list[2].toInt(); 1629 w = list[2].toInt();
1625 h = list[3].toInt(); 1630 h = list[3].toInt();
1626 getEventViewerDialog()->setGeometry(x,y,w,h); 1631 getEventViewerDialog()->setGeometry(x,y,w,h);
1627 } 1632 }
1628#endif 1633#endif
1629 1634
1630} 1635}
1631 1636
1632 1637
1633void CalendarView::writeSettings() 1638void CalendarView::writeSettings()
1634{ 1639{
1635 // kdDebug() << "CalendarView::writeSettings" << endl; 1640 // kdDebug() << "CalendarView::writeSettings" << endl;
1636 1641
1637 KConfig *config = KOGlobals::config(); 1642 KConfig *config = KOGlobals::config();
1638 1643
1639#ifndef KORG_NOSPLITTER 1644#ifndef KORG_NOSPLITTER
1640 config->setGroup("KOrganizer Geometry"); 1645 config->setGroup("KOrganizer Geometry");
1641 1646
1642 QValueList<int> list = mPanner->sizes(); 1647 QValueList<int> list = mPanner->sizes();
1643 config->writeEntry("Separator1",list); 1648 config->writeEntry("Separator1",list);
1644 1649
1645 list = mLeftSplitter->sizes(); 1650 list = mLeftSplitter->sizes();
1646 config->writeEntry("Separator2",list); 1651 config->writeEntry("Separator2",list);
1647#endif 1652#endif
1648 1653
1649 mViewManager->writeSettings( config ); 1654 mViewManager->writeSettings( config );
1650 mTodoList->saveLayout(config,QString("Todo Layout")); 1655 mTodoList->saveLayout(config,QString("Todo Layout"));
1651 mDialogManager->writeSettings( config ); 1656 mDialogManager->writeSettings( config );
1652 //KOPrefs::instance()->usrWriteConfig(); 1657 //KOPrefs::instance()->usrWriteConfig();
1653 KOPrefs::instance()->writeConfig(); 1658 KOPrefs::instance()->writeConfig();
1654 1659
1655 writeFilterSettings(config); 1660 writeFilterSettings(config);
1656 1661
1657 config->setGroup( "Views" ); 1662 config->setGroup( "Views" );
1658 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 1663 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
1659 1664
1660#ifdef DESKTOP_VERSION 1665#ifdef DESKTOP_VERSION
1661 config->setGroup("WidgetLayout"); 1666 config->setGroup("WidgetLayout");
1662 QStringList list ;//= config->readListEntry("MainLayout"); 1667 QStringList list ;//= config->readListEntry("MainLayout");
1663 int x,y,w,h; 1668 int x,y,w,h;
1664 QWidget* wid; 1669 QWidget* wid;
1665 wid = topLevelWidget(); 1670 wid = topLevelWidget();
1666 x = wid->geometry().x(); 1671 x = wid->geometry().x();
1667 y = wid->geometry().y(); 1672 y = wid->geometry().y();
1668 w = wid->width(); 1673 w = wid->width();
1669 h = wid->height(); 1674 h = wid->height();
1670 list.clear(); 1675 list.clear();
1671 list << QString::number( x ); 1676 list << QString::number( x );
1672 list << QString::number( y ); 1677 list << QString::number( y );
1673 list << QString::number( w ); 1678 list << QString::number( w );
1674 list << QString::number( h ); 1679 list << QString::number( h );
1675 config->writeEntry("MainLayout",list ); 1680 config->writeEntry("MainLayout",list );
1676 1681
1677 wid = mEventEditor; 1682 wid = mEventEditor;
1678 x = wid->geometry().x(); 1683 x = wid->geometry().x();
1679 y = wid->geometry().y(); 1684 y = wid->geometry().y();
1680 w = wid->width(); 1685 w = wid->width();
1681 h = wid->height(); 1686 h = wid->height();
1682 list.clear(); 1687 list.clear();
1683 list << QString::number( x ); 1688 list << QString::number( x );
1684 list << QString::number( y ); 1689 list << QString::number( y );
1685 list << QString::number( w ); 1690 list << QString::number( w );
1686 list << QString::number( h ); 1691 list << QString::number( h );
1687 config->writeEntry("EditEventLayout",list ); 1692 config->writeEntry("EditEventLayout",list );
1688 1693
1689 wid = mTodoEditor; 1694 wid = mTodoEditor;
1690 x = wid->geometry().x(); 1695 x = wid->geometry().x();
1691 y = wid->geometry().y(); 1696 y = wid->geometry().y();
1692 w = wid->width(); 1697 w = wid->width();
1693 h = wid->height(); 1698 h = wid->height();
1694 list.clear(); 1699 list.clear();
1695 list << QString::number( x ); 1700 list << QString::number( x );
1696 list << QString::number( y ); 1701 list << QString::number( y );
1697 list << QString::number( w ); 1702 list << QString::number( w );
1698 list << QString::number( h ); 1703 list << QString::number( h );
1699 config->writeEntry("EditTodoLayout",list ); 1704 config->writeEntry("EditTodoLayout",list );
1700 wid = getEventViewerDialog(); 1705 wid = getEventViewerDialog();
1701 x = wid->geometry().x(); 1706 x = wid->geometry().x();
1702 y = wid->geometry().y(); 1707 y = wid->geometry().y();
1703 w = wid->width(); 1708 w = wid->width();
1704 h = wid->height(); 1709 h = wid->height();
1705 list.clear(); 1710 list.clear();
1706 list << QString::number( x ); 1711 list << QString::number( x );
1707 list << QString::number( y ); 1712 list << QString::number( y );
1708 list << QString::number( w ); 1713 list << QString::number( w );
1709 list << QString::number( h ); 1714 list << QString::number( h );
1710 config->writeEntry("ViewerLayout",list ); 1715 config->writeEntry("ViewerLayout",list );
1711 wid = mDialogManager->getSearchDialog(); 1716 wid = mDialogManager->getSearchDialog();
1712 if ( wid ) { 1717 if ( wid ) {
1713 x = wid->geometry().x(); 1718 x = wid->geometry().x();
1714 y = wid->geometry().y(); 1719 y = wid->geometry().y();
1715 w = wid->width(); 1720 w = wid->width();
1716 h = wid->height(); 1721 h = wid->height();
1717 list.clear(); 1722 list.clear();
1718 list << QString::number( x ); 1723 list << QString::number( x );
1719 list << QString::number( y ); 1724 list << QString::number( y );
1720 list << QString::number( w ); 1725 list << QString::number( w );
1721 list << QString::number( h ); 1726 list << QString::number( h );
1722 config->writeEntry("SearchLayout",list ); 1727 config->writeEntry("SearchLayout",list );
1723 } 1728 }
1724#endif 1729#endif
1725 1730
1726 1731
1727 config->sync(); 1732 config->sync();
1728} 1733}
1729 1734
1730void CalendarView::readFilterSettings(KConfig *config) 1735void CalendarView::readFilterSettings(KConfig *config)
1731{ 1736{
1732 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 1737 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
1733 1738
1734 mFilters.clear(); 1739 mFilters.clear();
1735 1740
1736 config->setGroup("General"); 1741 config->setGroup("General");
1737 QStringList filterList = config->readListEntry("CalendarFilters"); 1742 QStringList filterList = config->readListEntry("CalendarFilters");
1738 1743
1739 QStringList::ConstIterator it = filterList.begin(); 1744 QStringList::ConstIterator it = filterList.begin();
1740 QStringList::ConstIterator end = filterList.end(); 1745 QStringList::ConstIterator end = filterList.end();
1741 while(it != end) { 1746 while(it != end) {
1742 // kdDebug() << " filter: " << (*it) << endl; 1747 // kdDebug() << " filter: " << (*it) << endl;
1743 1748
1744 CalFilter *filter; 1749 CalFilter *filter;
1745 filter = new CalFilter(*it); 1750 filter = new CalFilter(*it);
1746 config->setGroup("Filter_" + (*it)); 1751 config->setGroup("Filter_" + (*it));
1747 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 1752 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
1748 filter->setCriteria(config->readNumEntry("Criteria",0)); 1753 filter->setCriteria(config->readNumEntry("Criteria",0));
1749 filter->setCategoryList(config->readListEntry("CategoryList")); 1754 filter->setCategoryList(config->readListEntry("CategoryList"));
1750 mFilters.append(filter); 1755 mFilters.append(filter);
1751 1756
1752 ++it; 1757 ++it;
1753 } 1758 }
1754 1759
1755 if (mFilters.count() == 0) { 1760 if (mFilters.count() == 0) {
1756 CalFilter *filter = new CalFilter(i18n("Default")); 1761 CalFilter *filter = new CalFilter(i18n("Default"));
1757 mFilters.append(filter); 1762 mFilters.append(filter);
1758 } 1763 }
1759 mFilterView->updateFilters(); 1764 mFilterView->updateFilters();
1760 config->setGroup("FilterView"); 1765 config->setGroup("FilterView");
1761 1766
1762 mFilterView->blockSignals(true); 1767 mFilterView->blockSignals(true);
1763 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 1768 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
1764 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 1769 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
1765 mFilterView->blockSignals(false); 1770 mFilterView->blockSignals(false);
1766 // We do it manually to avoid it being done twice by the above calls 1771 // We do it manually to avoid it being done twice by the above calls
1767 updateFilter(); 1772 updateFilter();
1768} 1773}
1769 1774
1770void CalendarView::writeFilterSettings(KConfig *config) 1775void CalendarView::writeFilterSettings(KConfig *config)
1771{ 1776{
1772 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 1777 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
1773 1778
1774 QStringList filterList; 1779 QStringList filterList;
1775 1780
1776 CalFilter *filter = mFilters.first(); 1781 CalFilter *filter = mFilters.first();
1777 while(filter) { 1782 while(filter) {
1778 // kdDebug() << " fn: " << filter->name() << endl; 1783 // kdDebug() << " fn: " << filter->name() << endl;
1779 filterList << filter->name(); 1784 filterList << filter->name();
1780 config->setGroup("Filter_" + filter->name()); 1785 config->setGroup("Filter_" + filter->name());
1781 config->writeEntry("Criteria",filter->criteria()); 1786 config->writeEntry("Criteria",filter->criteria());
1782 config->writeEntry("CategoryList",filter->categoryList()); 1787 config->writeEntry("CategoryList",filter->categoryList());
1783 filter = mFilters.next(); 1788 filter = mFilters.next();
1784 } 1789 }
1785 config->setGroup("General"); 1790 config->setGroup("General");
1786 config->writeEntry("CalendarFilters",filterList); 1791 config->writeEntry("CalendarFilters",filterList);
1787 1792
1788 config->setGroup("FilterView"); 1793 config->setGroup("FilterView");
1789 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 1794 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
1790 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 1795 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
1791} 1796}
1792 1797
1793 1798
1794void CalendarView::goToday() 1799void CalendarView::goToday()
1795{ 1800{
1796 mNavigator->selectToday(); 1801 mNavigator->selectToday();
1797} 1802}
1798 1803
1799void CalendarView::goNext() 1804void CalendarView::goNext()
1800{ 1805{
1801 mNavigator->selectNext(); 1806 mNavigator->selectNext();
1802} 1807}
1803 1808
1804void CalendarView::goPrevious() 1809void CalendarView::goPrevious()
1805{ 1810{
1806 mNavigator->selectPrevious(); 1811 mNavigator->selectPrevious();
1807} 1812}
1808void CalendarView::goNextMonth() 1813void CalendarView::goNextMonth()
1809{ 1814{
1810 mNavigator->selectNextMonth(); 1815 mNavigator->selectNextMonth();
1811} 1816}
1812 1817
1813void CalendarView::goPreviousMonth() 1818void CalendarView::goPreviousMonth()
1814{ 1819{
1815 mNavigator->selectPreviousMonth(); 1820 mNavigator->selectPreviousMonth();
1816} 1821}
1817void CalendarView::writeLocale() 1822void CalendarView::writeLocale()
1818{ 1823{
1819 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); 1824 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime );
1820 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); 1825 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday );
1821 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); 1826 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate );
1822 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); 1827 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage );
1823 QString dummy = KOPrefs::instance()->mUserDateFormatLong; 1828 QString dummy = KOPrefs::instance()->mUserDateFormatLong;
1824 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 1829 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
1825 dummy = KOPrefs::instance()->mUserDateFormatShort; 1830 dummy = KOPrefs::instance()->mUserDateFormatShort;
1826 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 1831 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
1827 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, 1832 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving,
1828 KOPrefs::instance()->mDaylightsavingStart, 1833 KOPrefs::instance()->mDaylightsavingStart,
1829 KOPrefs::instance()->mDaylightsavingEnd ); 1834 KOPrefs::instance()->mDaylightsavingEnd );
1830 KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId ); 1835 KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId );
1831} 1836}
1832void CalendarView::updateConfig() 1837void CalendarView::updateConfig()
1833{ 1838{
1834 writeLocale(); 1839 writeLocale();
1835 if ( KOPrefs::instance()->mUseAppColors ) 1840 if ( KOPrefs::instance()->mUseAppColors )
1836 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 1841 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
1837 emit configChanged(); 1842 emit configChanged();
1838 mTodoList->updateConfig(); 1843 mTodoList->updateConfig();
1839 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 1844 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
1840 mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1845 mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1841 // To make the "fill window" configurations work 1846 // To make the "fill window" configurations work
1842 //mViewManager->raiseCurrentView(); 1847 //mViewManager->raiseCurrentView();
1843} 1848}
1844 1849
1845 1850
1846void CalendarView::eventChanged(Event *event) 1851void CalendarView::eventChanged(Event *event)
1847{ 1852{
1848 changeEventDisplay(event,KOGlobals::EVENTEDITED); 1853 changeEventDisplay(event,KOGlobals::EVENTEDITED);
1849 //updateUnmanagedViews(); 1854 //updateUnmanagedViews();
1850} 1855}
1851 1856
1852void CalendarView::eventAdded(Event *event) 1857void CalendarView::eventAdded(Event *event)
1853{ 1858{
1854 changeEventDisplay(event,KOGlobals::EVENTADDED); 1859 changeEventDisplay(event,KOGlobals::EVENTADDED);
1855} 1860}
1856 1861
1857void CalendarView::eventToBeDeleted(Event *) 1862void CalendarView::eventToBeDeleted(Event *)
1858{ 1863{
1859 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 1864 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
1860} 1865}
1861 1866
1862void CalendarView::eventDeleted() 1867void CalendarView::eventDeleted()
1863{ 1868{
1864 changeEventDisplay(0,KOGlobals::EVENTDELETED); 1869 changeEventDisplay(0,KOGlobals::EVENTDELETED);
1865} 1870}
1866void CalendarView::changeTodoDisplay(Todo *which, int action) 1871void CalendarView::changeTodoDisplay(Todo *which, int action)
1867{ 1872{
1868 changeIncidenceDisplay((Incidence *)which, action); 1873 changeIncidenceDisplay((Incidence *)which, action);
1869} 1874}
1870 1875
1871void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 1876void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
1872{ 1877{
1873 updateUnmanagedViews(); 1878 updateUnmanagedViews();
1874 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 1879 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
1875 if ( action == KOGlobals::EVENTDELETED ) { //delete 1880 if ( action == KOGlobals::EVENTDELETED ) { //delete
1876 mCalendar->checkAlarmForIncidence( 0, true ); 1881 mCalendar->checkAlarmForIncidence( 0, true );
1877 if ( mEventViewerDialog ) 1882 if ( mEventViewerDialog )
1878 mEventViewerDialog->hide(); 1883 mEventViewerDialog->hide();
1879 } 1884 }
1880 else 1885 else
1881 mCalendar->checkAlarmForIncidence( which , false ); 1886 mCalendar->checkAlarmForIncidence( which , false );
1882} 1887}
1883 1888
1884// most of the changeEventDisplays() right now just call the view's 1889// most of the changeEventDisplays() right now just call the view's
1885// total update mode, but they SHOULD be recoded to be more refresh-efficient. 1890// total update mode, but they SHOULD be recoded to be more refresh-efficient.
1886void CalendarView::changeEventDisplay(Event *which, int action) 1891void CalendarView::changeEventDisplay(Event *which, int action)
1887{ 1892{
1888 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 1893 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
1889 changeIncidenceDisplay((Incidence *)which, action); 1894 changeIncidenceDisplay((Incidence *)which, action);
1890 mDateNavigator->updateView(); 1895 mDateNavigator->updateView();
1891 //mDialogManager->updateSearchDialog(); 1896 //mDialogManager->updateSearchDialog();
1892 1897
1893 if (which) { 1898 if (which) {
1894 // If there is an event view visible update the display 1899 // If there is an event view visible update the display
1895 mViewManager->currentView()->changeEventDisplay(which,action); 1900 mViewManager->currentView()->changeEventDisplay(which,action);
1896 // TODO: check, if update needed 1901 // TODO: check, if update needed
1897 // if (which->getTodoStatus()) { 1902 // if (which->getTodoStatus()) {
1898 mTodoList->updateView(); 1903 mTodoList->updateView();
1899 // } 1904 // }
1900 } else { 1905 } else {
1901 mViewManager->currentView()->updateView(); 1906 mViewManager->currentView()->updateView();
1902 } 1907 }
1903} 1908}
1904 1909
1905 1910
1906void CalendarView::updateTodoViews() 1911void CalendarView::updateTodoViews()
1907{ 1912{
1908 1913
1909 mTodoList->updateView(); 1914 mTodoList->updateView();
1910 mViewManager->currentView()->updateView(); 1915 mViewManager->currentView()->updateView();
1911 1916
1912} 1917}
1913 1918
1914 1919
1915void CalendarView::updateView(const QDate &start, const QDate &end) 1920void CalendarView::updateView(const QDate &start, const QDate &end)
1916{ 1921{
1917 mTodoList->updateView(); 1922 mTodoList->updateView();
1918 mViewManager->updateView(start, end); 1923 mViewManager->updateView(start, end);
1919 //mDateNavigator->updateView(); 1924 //mDateNavigator->updateView();
1920} 1925}
1921 1926
1922void CalendarView::updateView() 1927void CalendarView::updateView()
1923{ 1928{
1924 DateList tmpList = mNavigator->selectedDates(); 1929 DateList tmpList = mNavigator->selectedDates();
1925 1930
1926 // We assume that the navigator only selects consecutive days. 1931 // We assume that the navigator only selects consecutive days.
1927 updateView( tmpList.first(), tmpList.last() ); 1932 updateView( tmpList.first(), tmpList.last() );
1928} 1933}
1929 1934
1930void CalendarView::updateUnmanagedViews() 1935void CalendarView::updateUnmanagedViews()
1931{ 1936{
1932 mDateNavigator->updateDayMatrix(); 1937 mDateNavigator->updateDayMatrix();
1933} 1938}
1934 1939
1935int CalendarView::msgItemDelete() 1940int CalendarView::msgItemDelete()
1936{ 1941{
1937 return KMessageBox::warningContinueCancel(this, 1942 return KMessageBox::warningContinueCancel(this,
1938 i18n("This item will be\npermanently deleted."), 1943 i18n("This item will be\npermanently deleted."),
1939 i18n("KO/Pi Confirmation"),i18n("Delete")); 1944 i18n("KO/Pi Confirmation"),i18n("Delete"));
1940} 1945}
1941 1946
1942 1947
1943void CalendarView::edit_cut() 1948void CalendarView::edit_cut()
1944{ 1949{
1945 Event *anEvent=0; 1950 Event *anEvent=0;
1946 1951
1947 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 1952 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
1948 1953
1949 if (mViewManager->currentView()->isEventView()) { 1954 if (mViewManager->currentView()->isEventView()) {
1950 if ( incidence && incidence->type() == "Event" ) { 1955 if ( incidence && incidence->type() == "Event" ) {
1951 anEvent = static_cast<Event *>(incidence); 1956 anEvent = static_cast<Event *>(incidence);
1952 } 1957 }
1953 } 1958 }
1954 1959
1955 if (!anEvent) { 1960 if (!anEvent) {
1956 KNotifyClient::beep(); 1961 KNotifyClient::beep();
1957 return; 1962 return;
1958 } 1963 }
1959 DndFactory factory( mCalendar ); 1964 DndFactory factory( mCalendar );
1960 factory.cutEvent(anEvent); 1965 factory.cutEvent(anEvent);
1961 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 1966 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
1962} 1967}
1963 1968
1964void CalendarView::edit_copy() 1969void CalendarView::edit_copy()
1965{ 1970{
1966 Event *anEvent=0; 1971 Event *anEvent=0;
1967 1972
1968 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 1973 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
1969 1974
1970 if (mViewManager->currentView()->isEventView()) { 1975 if (mViewManager->currentView()->isEventView()) {
1971 if ( incidence && incidence->type() == "Event" ) { 1976 if ( incidence && incidence->type() == "Event" ) {
1972 anEvent = static_cast<Event *>(incidence); 1977 anEvent = static_cast<Event *>(incidence);
1973 } 1978 }
1974 } 1979 }
1975 1980
1976 if (!anEvent) { 1981 if (!anEvent) {
1977 KNotifyClient::beep(); 1982 KNotifyClient::beep();
1978 return; 1983 return;
1979 } 1984 }
1980 DndFactory factory( mCalendar ); 1985 DndFactory factory( mCalendar );
1981 factory.copyEvent(anEvent); 1986 factory.copyEvent(anEvent);
1982} 1987}
1983 1988
1984void CalendarView::edit_paste() 1989void CalendarView::edit_paste()
1985{ 1990{
1986 QDate date = mNavigator->selectedDates().first(); 1991 QDate date = mNavigator->selectedDates().first();
1987 1992
1988 DndFactory factory( mCalendar ); 1993 DndFactory factory( mCalendar );
1989 Event *pastedEvent = factory.pasteEvent( date ); 1994 Event *pastedEvent = factory.pasteEvent( date );
1990 1995
1991 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 1996 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
1992} 1997}
1993 1998
1994void CalendarView::edit_options() 1999void CalendarView::edit_options()
1995{ 2000{
1996 mDialogManager->showOptionsDialog(); 2001 mDialogManager->showOptionsDialog();
1997 //writeSettings(); 2002 //writeSettings();
1998} 2003}
1999void CalendarView::edit_sync_options() 2004void CalendarView::edit_sync_options()
2000{ 2005{
2001 //mDialogManager->showSyncOptions(); 2006 //mDialogManager->showSyncOptions();
2002 //KOPrefs::instance()->mSyncAlgoPrefs 2007 //KOPrefs::instance()->mSyncAlgoPrefs
2003 QDialog dia( this, "dia", true ); 2008 QDialog dia( this, "dia", true );
2004 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); 2009 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice );
2005 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); 2010 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia);
2006 QVBoxLayout lay ( &dia ); 2011 QVBoxLayout lay ( &dia );
2007 lay.setSpacing( 2 ); 2012 lay.setSpacing( 2 );
2008 lay.setMargin( 3 ); 2013 lay.setMargin( 3 );
2009 lay.addWidget(&gr); 2014 lay.addWidget(&gr);
2010 QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); 2015 QRadioButton loc ( i18n("Take local entry on conflict"), &gr );
2011 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); 2016 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr );
2012 QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); 2017 QRadioButton newest( i18n("Take newest entry on conflict"), &gr );
2013 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); 2018 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr );
2014 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); 2019 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr );
2015 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); 2020 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr );
2016 //QRadioButton both( i18n("Take both on conflict"), &gr ); 2021 //QRadioButton both( i18n("Take both on conflict"), &gr );
2017 QPushButton pb ( "OK", &dia); 2022 QPushButton pb ( "OK", &dia);
2018 lay.addWidget( &pb ); 2023 lay.addWidget( &pb );
2019 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 2024 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
2020 switch ( KOPrefs::instance()->mSyncAlgoPrefs ) { 2025 switch ( KOPrefs::instance()->mSyncAlgoPrefs ) {
2021 case 0: 2026 case 0:
2022 loc.setChecked( true); 2027 loc.setChecked( true);
2023 break; 2028 break;
2024 case 1: 2029 case 1:
2025 rem.setChecked( true ); 2030 rem.setChecked( true );
2026 break; 2031 break;
2027 case 2: 2032 case 2:
2028 newest.setChecked( true); 2033 newest.setChecked( true);
2029 break; 2034 break;
2030 case 3: 2035 case 3:
2031 ask.setChecked( true); 2036 ask.setChecked( true);
2032 break; 2037 break;
2033 case 4: 2038 case 4:
2034 f_loc.setChecked( true); 2039 f_loc.setChecked( true);
2035 break; 2040 break;
2036 case 5: 2041 case 5:
2037 f_rem.setChecked( true); 2042 f_rem.setChecked( true);
2038 break; 2043 break;
2039 case 6: 2044 case 6:
2040 // both.setChecked( true); 2045 // both.setChecked( true);
2041 break; 2046 break;
2042 default: 2047 default:
2043 break; 2048 break;
2044 } 2049 }
2045 if ( dia.exec() ) { 2050 if ( dia.exec() ) {
2046 KOPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; 2051 KOPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ;
2047 } 2052 }
2048 2053
2049} 2054}
2050 2055
2051void CalendarView::slotSelectPickerDate( QDate d) 2056void CalendarView::slotSelectPickerDate( QDate d)
2052{ 2057{
2053 mDateFrame->hide(); 2058 mDateFrame->hide();
2054 if ( mDatePickerMode == 1 ) { 2059 if ( mDatePickerMode == 1 ) {
2055 mNavigator->slotDaySelect( d ); 2060 mNavigator->slotDaySelect( d );
2056 } else if ( mDatePickerMode == 2 ) { 2061 } else if ( mDatePickerMode == 2 ) {
2057 if ( mMoveIncidence->type() == "Todo" ) { 2062 if ( mMoveIncidence->type() == "Todo" ) {
2058 Todo * to = (Todo *) mMoveIncidence; 2063 Todo * to = (Todo *) mMoveIncidence;
2059 QTime tim; 2064 QTime tim;
2060 if ( to->hasDueDate() ) 2065 if ( to->hasDueDate() )
2061 tim = to->dtDue().time(); 2066 tim = to->dtDue().time();
2062 else { 2067 else {
2063 tim = QTime ( 0,0,0 ); 2068 tim = QTime ( 0,0,0 );
2064 to->setFloats( true ); 2069 to->setFloats( true );
2065 to->setHasDueDate( true ); 2070 to->setHasDueDate( true );
2066 } 2071 }
2067 QDateTime dt ( d,tim ); 2072 QDateTime dt ( d,tim );
2068 to->setDtDue( dt ); 2073 to->setDtDue( dt );
2069 todoChanged( to ); 2074 todoChanged( to );
2070 } else { 2075 } else {
2071 QTime tim = mMoveIncidence->dtStart().time(); 2076 QTime tim = mMoveIncidence->dtStart().time();
2072 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2077 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2073 QDateTime dt ( d,tim ); 2078 QDateTime dt ( d,tim );
2074 mMoveIncidence->setDtStart( dt ); 2079 mMoveIncidence->setDtStart( dt );
2075 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2080 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2076 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2081 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2077 } 2082 }
2078 2083
2079 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2084 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2080 } 2085 }
2081} 2086}
2082 2087
2083void CalendarView::removeCategories() 2088void CalendarView::removeCategories()
2084{ 2089{
2085 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2090 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2086 QStringList catList = KOPrefs::instance()->mCustomCategories; 2091 QStringList catList = KOPrefs::instance()->mCustomCategories;
2087 QStringList catIncList; 2092 QStringList catIncList;
2088 QStringList newCatList; 2093 QStringList newCatList;
2089 Incidence* inc = incList.first(); 2094 Incidence* inc = incList.first();
2090 int i; 2095 int i;
2091 int count = 0; 2096 int count = 0;
2092 while ( inc ) { 2097 while ( inc ) {
2093 newCatList.clear(); 2098 newCatList.clear();
2094 catIncList = inc->categories() ; 2099 catIncList = inc->categories() ;
2095 for( i = 0; i< catIncList.count(); ++i ) { 2100 for( i = 0; i< catIncList.count(); ++i ) {
2096 if ( catList.contains (catIncList[i])) 2101 if ( catList.contains (catIncList[i]))
2097 newCatList.append( catIncList[i] ); 2102 newCatList.append( catIncList[i] );
2098 } 2103 }
2099 newCatList.sort(); 2104 newCatList.sort();
2100 inc->setCategories( newCatList.join(",") ); 2105 inc->setCategories( newCatList.join(",") );
2101 inc = incList.next(); 2106 inc = incList.next();
2102 } 2107 }
2103} 2108}
2104 2109
2105int CalendarView::addCategories() 2110int CalendarView::addCategories()
2106{ 2111{
2107 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2112 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2108 QStringList catList = KOPrefs::instance()->mCustomCategories; 2113 QStringList catList = KOPrefs::instance()->mCustomCategories;
2109 QStringList catIncList; 2114 QStringList catIncList;
2110 Incidence* inc = incList.first(); 2115 Incidence* inc = incList.first();
2111 int i; 2116 int i;
2112 int count = 0; 2117 int count = 0;
2113 while ( inc ) { 2118 while ( inc ) {
2114 catIncList = inc->categories() ; 2119 catIncList = inc->categories() ;
2115 for( i = 0; i< catIncList.count(); ++i ) { 2120 for( i = 0; i< catIncList.count(); ++i ) {
2116 if ( !catList.contains (catIncList[i])) { 2121 if ( !catList.contains (catIncList[i])) {
2117 catList.append( catIncList[i] ); 2122 catList.append( catIncList[i] );
2118 //qDebug("add cat %s ", catIncList[i].latin1()); 2123 //qDebug("add cat %s ", catIncList[i].latin1());
2119 ++count; 2124 ++count;
2120 } 2125 }
2121 } 2126 }
2122 inc = incList.next(); 2127 inc = incList.next();
2123 } 2128 }
2124 catList.sort(); 2129 catList.sort();
2125 KOPrefs::instance()->mCustomCategories = catList; 2130 KOPrefs::instance()->mCustomCategories = catList;
2126 return count; 2131 return count;
2127} 2132}
2128 2133
2129void CalendarView::manageCategories() 2134void CalendarView::manageCategories()
2130{ 2135{
2131 KOCatPrefs* cp = new KOCatPrefs(); 2136 KOCatPrefs* cp = new KOCatPrefs();
2132 cp->show(); 2137 cp->show();
2133 int w =cp->sizeHint().width() ; 2138 int w =cp->sizeHint().width() ;
2134 int h = cp->sizeHint().height() ; 2139 int h = cp->sizeHint().height() ;
2135 int dw = QApplication::desktop()->width(); 2140 int dw = QApplication::desktop()->width();
2136 int dh = QApplication::desktop()->height(); 2141 int dh = QApplication::desktop()->height();
2137 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2142 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2138 if ( !cp->exec() ) { 2143 if ( !cp->exec() ) {
2139 delete cp; 2144 delete cp;
2140 return; 2145 return;
2141 } 2146 }
2142 int count = 0; 2147 int count = 0;
2143 if ( cp->addCat() ) { 2148 if ( cp->addCat() ) {
2144 count = addCategories(); 2149 count = addCategories();
2145 if ( count ) { 2150 if ( count ) {
2146 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2151 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2147 writeSettings(); 2152 writeSettings();
2148 } 2153 }
2149 } else { 2154 } else {
2150 removeCategories(); 2155 removeCategories();
2151 updateView(); 2156 updateView();
2152 } 2157 }
2153 delete cp; 2158 delete cp;
2154} 2159}
2155 2160
2156void CalendarView::beamIncidence(Incidence * Inc) 2161void CalendarView::beamIncidence(Incidence * Inc)
2157{ 2162{
2158 QPtrList<Incidence> delSel ; 2163 QPtrList<Incidence> delSel ;
2159 delSel.append(Inc); 2164 delSel.append(Inc);
2160 beamIncidenceList( delSel ); 2165 beamIncidenceList( delSel );
2161} 2166}
2162void CalendarView::beamCalendar() 2167void CalendarView::beamCalendar()
2163{ 2168{
2164 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2169 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2165 //qDebug("beamCalendar() "); 2170 //qDebug("beamCalendar() ");
2166 beamIncidenceList( delSel ); 2171 beamIncidenceList( delSel );
2167} 2172}
2168void CalendarView::beamFilteredCalendar() 2173void CalendarView::beamFilteredCalendar()
2169{ 2174{
2170 QPtrList<Incidence> delSel = mCalendar->incidences(); 2175 QPtrList<Incidence> delSel = mCalendar->incidences();
2171 //qDebug("beamFilteredCalendar() "); 2176 //qDebug("beamFilteredCalendar() ");
2172 beamIncidenceList( delSel ); 2177 beamIncidenceList( delSel );
2173} 2178}
2174void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2179void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2175{ 2180{
2176 if ( beamDialog->exec () == QDialog::Rejected ) 2181 if ( beamDialog->exec () == QDialog::Rejected )
2177 return; 2182 return;
2178 2183
2179 QString fn = "/tmp/kopibeamfile"; 2184 QString fn = "/tmp/kopibeamfile";
2180 QString mes; 2185 QString mes;
2181 bool createbup = true; 2186 bool createbup = true;
2182 if ( createbup ) { 2187 if ( createbup ) {
2183 QString description = "\n"; 2188 QString description = "\n";
2184 CalendarLocal* cal = new CalendarLocal(); 2189 CalendarLocal* cal = new CalendarLocal();
2185 if ( beamDialog->beamLocal() ) 2190 if ( beamDialog->beamLocal() )
2186 cal->setLocalTime(); 2191 cal->setLocalTime();
2187 else 2192 else
2188 cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 2193 cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
2189 Incidence *incidence = delSel.first(); 2194 Incidence *incidence = delSel.first();
2190 bool addText = false; 2195 bool addText = false;
2191 if ( delSel.count() < 10 ) 2196 if ( delSel.count() < 10 )
2192 addText = true; 2197 addText = true;
2193 else { 2198 else {
2194 description.sprintf(i18n(" %d items?"),delSel.count() ); 2199 description.sprintf(i18n(" %d items?"),delSel.count() );
2195 } 2200 }
2196 while ( incidence ) { 2201 while ( incidence ) {
2197 Incidence *in = incidence->clone(); 2202 Incidence *in = incidence->clone();
2198 if ( addText ) 2203 if ( addText )
2199 description += in->summary() + "\n"; 2204 description += in->summary() + "\n";
2200 cal->addIncidence( in ); 2205 cal->addIncidence( in );
2201 incidence = delSel.next(); 2206 incidence = delSel.next();
2202 } 2207 }
2203 if ( beamDialog->beamVcal() ) { 2208 if ( beamDialog->beamVcal() ) {
2204 fn += ".vcs"; 2209 fn += ".vcs";
2205 FileStorage storage( cal, fn, new VCalFormat ); 2210 FileStorage storage( cal, fn, new VCalFormat );
2206 storage.save(); 2211 storage.save();
2207 } else { 2212 } else {
2208 fn += ".ics"; 2213 fn += ".ics";
2209 FileStorage storage( cal, fn, new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 2214 FileStorage storage( cal, fn, new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
2210 storage.save(); 2215 storage.save();
2211 } 2216 }
2212 delete cal; 2217 delete cal;
2213 mes = i18n("KO/Pi: Ready for beaming"); 2218 mes = i18n("KO/Pi: Ready for beaming");
2214 setCaption(mes); 2219 setCaption(mes);
2215 2220
2216#ifndef DESKTOP_VERSION 2221#ifndef DESKTOP_VERSION
2217 Ir *ir = new Ir( this ); 2222 Ir *ir = new Ir( this );
2218 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 2223 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2219 ir->send( fn, description, "text/x-vCalendar" ); 2224 ir->send( fn, description, "text/x-vCalendar" );
2220#endif 2225#endif
2221 } 2226 }
2222} 2227}
2223void CalendarView::beamDone( Ir *ir ) 2228void CalendarView::beamDone( Ir *ir )
2224{ 2229{
2225#ifndef DESKTOP_VERSION 2230#ifndef DESKTOP_VERSION
2226 delete ir; 2231 delete ir;
2227#endif 2232#endif
2228} 2233}
2229 2234
2230void CalendarView::moveIncidence(Incidence * inc ) 2235void CalendarView::moveIncidence(Incidence * inc )
2231{ 2236{
2232 if ( !inc ) return; 2237 if ( !inc ) return;
2233 // qDebug("showDatePickerForIncidence( ) "); 2238 // qDebug("showDatePickerForIncidence( ) ");
2234 if ( mDateFrame->isVisible() ) 2239 if ( mDateFrame->isVisible() )
2235 mDateFrame->hide(); 2240 mDateFrame->hide();
2236 else { 2241 else {
2237 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; 2242 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ;
2238 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; 2243 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ;
2239 int dw = QApplication::desktop()->width(); 2244 int dw = QApplication::desktop()->width();
2240 int dh = QApplication::desktop()->height(); 2245 int dh = QApplication::desktop()->height();
2241 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2246 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2242 mDateFrame->show(); 2247 mDateFrame->show();
2243 } 2248 }
2244 mDatePickerMode = 2; 2249 mDatePickerMode = 2;
2245 mMoveIncidence = inc ; 2250 mMoveIncidence = inc ;
2246 QDate da; 2251 QDate da;
2247 if ( mMoveIncidence->type() == "Todo" ) { 2252 if ( mMoveIncidence->type() == "Todo" ) {
2248 Todo * to = (Todo *) mMoveIncidence; 2253 Todo * to = (Todo *) mMoveIncidence;
2249 if ( to->hasDueDate() ) 2254 if ( to->hasDueDate() )
2250 da = to->dtDue().date(); 2255 da = to->dtDue().date();
2251 else 2256 else
2252 da = QDate::currentDate(); 2257 da = QDate::currentDate();
2253 } else { 2258 } else {
2254 da = mMoveIncidence->dtStart().date(); 2259 da = mMoveIncidence->dtStart().date();
2255 } 2260 }
2256 mDatePicker->setDate( da ); 2261 mDatePicker->setDate( da );
2257} 2262}
2258void CalendarView::showDatePicker( ) 2263void CalendarView::showDatePicker( )
2259{ 2264{
2260 //qDebug("CalendarView::showDatePicker( ) "); 2265 //qDebug("CalendarView::showDatePicker( ) ");
2261 if ( mDateFrame->isVisible() ) 2266 if ( mDateFrame->isVisible() )
2262 mDateFrame->hide(); 2267 mDateFrame->hide();
2263 else { 2268 else {
2264 int w =mDatePicker->sizeHint().width() ; 2269 int w =mDatePicker->sizeHint().width() ;
2265 int h = mDatePicker->sizeHint().height() ; 2270 int h = mDatePicker->sizeHint().height() ;
2266 int dw = QApplication::desktop()->width(); 2271 int dw = QApplication::desktop()->width();
2267 int dh = QApplication::desktop()->height(); 2272 int dh = QApplication::desktop()->height();
2268 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2273 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2269 mDateFrame->show(); 2274 mDateFrame->show();
2270 } 2275 }
2271 mDatePickerMode = 1; 2276 mDatePickerMode = 1;
2272 mDatePicker->setDate( mNavigator->selectedDates().first() ); 2277 mDatePicker->setDate( mNavigator->selectedDates().first() );
2273} 2278}
2274 2279
2275void CalendarView::showEventEditor() 2280void CalendarView::showEventEditor()
2276{ 2281{
2277#ifdef DESKTOP_VERSION 2282#ifdef DESKTOP_VERSION
2278 mEventEditor->show(); 2283 mEventEditor->show();
2279#else 2284#else
2280 mEventEditor->showMaximized(); 2285 mEventEditor->showMaximized();
2281#endif 2286#endif
2282} 2287}
2283void CalendarView::showTodoEditor() 2288void CalendarView::showTodoEditor()
2284{ 2289{
2285#ifdef DESKTOP_VERSION 2290#ifdef DESKTOP_VERSION
2286 mTodoEditor->show(); 2291 mTodoEditor->show();
2287#else 2292#else
2288 mTodoEditor->showMaximized(); 2293 mTodoEditor->showMaximized();
2289#endif 2294#endif
2290} 2295}
2291void CalendarView::cancelIncidence(Incidence * inc ) 2296void CalendarView::cancelIncidence(Incidence * inc )
2292{ 2297{
2293 inc->setCancelled( ! inc->cancelled() ); 2298 inc->setCancelled( ! inc->cancelled() );
2294 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 2299 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
2295 updateView(); 2300 updateView();
2296} 2301}
2297void CalendarView::cloneIncidence(Incidence * orgInc ) 2302void CalendarView::cloneIncidence(Incidence * orgInc )
2298{ 2303{
2299 Incidence * newInc = orgInc->clone(); 2304 Incidence * newInc = orgInc->clone();
2300 newInc->recreate(); 2305 newInc->recreate();
2301 2306
2302 if ( newInc->type() == "Todo" ) { 2307 if ( newInc->type() == "Todo" ) {
2303 Todo* t = (Todo*) newInc; 2308 Todo* t = (Todo*) newInc;
2304 mTodoEditor->editTodo( t ); 2309 mTodoEditor->editTodo( t );
2305 showTodoEditor(); 2310 showTodoEditor();
2306 if ( mTodoEditor->exec() ) { 2311 if ( mTodoEditor->exec() ) {
2307 mCalendar->addTodo( t ); 2312 mCalendar->addTodo( t );
2308 updateView(); 2313 updateView();
2309 } else { 2314 } else {
2310 delete t; 2315 delete t;
2311 } 2316 }
2312 } 2317 }
2313 else { 2318 else {
2314 Event* e = (Event*) newInc; 2319 Event* e = (Event*) newInc;
2315 mEventEditor->editEvent( e ); 2320 mEventEditor->editEvent( e );
2316 showEventEditor(); 2321 showEventEditor();
2317 if ( mEventEditor->exec() ) { 2322 if ( mEventEditor->exec() ) {
2318 mCalendar->addEvent( e ); 2323 mCalendar->addEvent( e );
2319 updateView(); 2324 updateView();
2320 } else { 2325 } else {
2321 delete e; 2326 delete e;
2322 } 2327 }
2323 } 2328 }
2324} 2329}
2325 2330
2326void CalendarView::newEvent() 2331void CalendarView::newEvent()
2327{ 2332{
2328 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 2333 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
2329 KOAgendaView *aView = mViewManager->agendaView(); 2334 KOAgendaView *aView = mViewManager->agendaView();
2330 if (aView) { 2335 if (aView) {
2331 if (aView->selectionStart().isValid()) { 2336 if (aView->selectionStart().isValid()) {
2332 if (aView->selectedIsAllDay()) { 2337 if (aView->selectedIsAllDay()) {
2333 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 2338 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
2334 } else { 2339 } else {
2335 newEvent(aView->selectionStart(),aView->selectionEnd()); 2340 newEvent(aView->selectionStart(),aView->selectionEnd());
2336 } 2341 }
2337 return; 2342 return;
2338 } 2343 }
2339 } 2344 }
2340 2345
2341 QDate date = mNavigator->selectedDates().first(); 2346 QDate date = mNavigator->selectedDates().first();
2342 QDateTime current = QDateTime::currentDateTime(); 2347 QDateTime current = QDateTime::currentDateTime();
2343 if ( date <= current.date() ) { 2348 if ( date <= current.date() ) {
2344 int hour = current.time().hour() +1; 2349 int hour = current.time().hour() +1;
2345 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 2350 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
2346 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2351 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2347 } else 2352 } else
2348 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 2353 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
2349 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 2354 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
2350 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2355 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2351} 2356}
2352 2357
2353void CalendarView::newEvent(QDateTime fh) 2358void CalendarView::newEvent(QDateTime fh)
2354{ 2359{
2355 newEvent(fh, 2360 newEvent(fh,
2356 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 2361 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
2357} 2362}
2358 2363
2359void CalendarView::newEvent(QDate dt) 2364void CalendarView::newEvent(QDate dt)
2360{ 2365{
2361 newEvent(QDateTime(dt, QTime(0,0,0)), 2366 newEvent(QDateTime(dt, QTime(0,0,0)),
2362 QDateTime(dt, QTime(0,0,0)), true); 2367 QDateTime(dt, QTime(0,0,0)), true);
2363} 2368}
2364 2369
2365void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 2370void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
2366{ 2371{
2367 2372
2368 mEventEditor->newEvent(fromHint,toHint,allDay); 2373 mEventEditor->newEvent(fromHint,toHint,allDay);
2369 if ( mFilterView->filtersEnabled() ) { 2374 if ( mFilterView->filtersEnabled() ) {
2370 CalFilter *filter = mFilterView->selectedFilter(); 2375 CalFilter *filter = mFilterView->selectedFilter();
2371 if (filter && filter->showCategories()) { 2376 if (filter && filter->showCategories()) {
2372 mEventEditor->setCategories(filter->categoryList().join(",") ); 2377 mEventEditor->setCategories(filter->categoryList().join(",") );
2373 } 2378 }
2374 if ( filter ) 2379 if ( filter )
2375 mEventEditor->setSecrecy( filter->getSecrecy() ); 2380 mEventEditor->setSecrecy( filter->getSecrecy() );
2376 } 2381 }
2377 showEventEditor(); 2382 showEventEditor();
2378} 2383}
2379void CalendarView::todoAdded(Todo * t) 2384void CalendarView::todoAdded(Todo * t)
2380{ 2385{
2381 2386
2382 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 2387 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
2383 updateTodoViews(); 2388 updateTodoViews();
2384} 2389}
2385void CalendarView::todoChanged(Todo * t) 2390void CalendarView::todoChanged(Todo * t)
2386{ 2391{
2387 emit todoModified( t, 4 ); 2392 emit todoModified( t, 4 );
2388 // updateTodoViews(); 2393 // updateTodoViews();
2389} 2394}
2390void CalendarView::todoToBeDeleted(Todo *) 2395void CalendarView::todoToBeDeleted(Todo *)
2391{ 2396{
2392 //qDebug("todoToBeDeleted(Todo *) "); 2397 //qDebug("todoToBeDeleted(Todo *) ");
2393 updateTodoViews(); 2398 updateTodoViews();
2394} 2399}
2395void CalendarView::todoDeleted() 2400void CalendarView::todoDeleted()
2396{ 2401{
2397 //qDebug(" todoDeleted()"); 2402 //qDebug(" todoDeleted()");
2398 updateTodoViews(); 2403 updateTodoViews();
2399} 2404}
2400 2405
2401 2406
2402 2407
2403void CalendarView::newTodo() 2408void CalendarView::newTodo()
2404{ 2409{
2405 2410
2406 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); 2411 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true);
2407 if ( mFilterView->filtersEnabled() ) { 2412 if ( mFilterView->filtersEnabled() ) {
2408 CalFilter *filter = mFilterView->selectedFilter(); 2413 CalFilter *filter = mFilterView->selectedFilter();
2409 if (filter && filter->showCategories()) { 2414 if (filter && filter->showCategories()) {
2410 mTodoEditor->setCategories(filter->categoryList().join(",") ); 2415 mTodoEditor->setCategories(filter->categoryList().join(",") );
2411 } 2416 }
2412 if ( filter ) 2417 if ( filter )
2413 mTodoEditor->setSecrecy( filter->getSecrecy() ); 2418 mTodoEditor->setSecrecy( filter->getSecrecy() );
2414 } 2419 }
2415 showTodoEditor(); 2420 showTodoEditor();
2416} 2421}
2417 2422
2418void CalendarView::newSubTodo() 2423void CalendarView::newSubTodo()
2419{ 2424{
2420 Todo *todo = selectedTodo(); 2425 Todo *todo = selectedTodo();
2421 if ( todo ) newSubTodo( todo ); 2426 if ( todo ) newSubTodo( todo );
2422} 2427}
2423 2428
2424void CalendarView::newSubTodo(Todo *parentEvent) 2429void CalendarView::newSubTodo(Todo *parentEvent)
2425{ 2430{
2426 2431
2427 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); 2432 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true);
2428 showTodoEditor(); 2433 showTodoEditor();
2429} 2434}
2430 2435
2431void CalendarView::newFloatingEvent() 2436void CalendarView::newFloatingEvent()
2432{ 2437{
2433 DateList tmpList = mNavigator->selectedDates(); 2438 DateList tmpList = mNavigator->selectedDates();
2434 QDate date = tmpList.first(); 2439 QDate date = tmpList.first();
2435 2440
2436 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 2441 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
2437 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 2442 QDateTime( date, QTime( 12, 0, 0 ) ), true );
2438} 2443}
2439 2444
2440 2445
2441void CalendarView::editEvent( Event *event ) 2446void CalendarView::editEvent( Event *event )
2442{ 2447{
2443 2448
2444 if ( !event ) return; 2449 if ( !event ) return;
2445 if ( event->isReadOnly() ) { 2450 if ( event->isReadOnly() ) {
2446 showEvent( event ); 2451 showEvent( event );
2447 return; 2452 return;
2448 } 2453 }
2449 mEventEditor->editEvent( event , mFlagEditDescription); 2454 mEventEditor->editEvent( event , mFlagEditDescription);
2450 showEventEditor(); 2455 showEventEditor();
2451} 2456}
2452void CalendarView::editJournal( Journal *jour ) 2457void CalendarView::editJournal( Journal *jour )
2453{ 2458{
2454 if ( !jour ) return; 2459 if ( !jour ) return;
2455 mDialogManager->hideSearchDialog(); 2460 mDialogManager->hideSearchDialog();
2456 mViewManager->showJournalView(); 2461 mViewManager->showJournalView();
2457 mNavigator->slotDaySelect( jour->dtStart().date() ); 2462 mNavigator->slotDaySelect( jour->dtStart().date() );
2458} 2463}
2459void CalendarView::editTodo( Todo *todo ) 2464void CalendarView::editTodo( Todo *todo )
2460{ 2465{
2461 if ( !todo ) return; 2466 if ( !todo ) return;
2462 2467
2463 if ( todo->isReadOnly() ) { 2468 if ( todo->isReadOnly() ) {
2464 showTodo( todo ); 2469 showTodo( todo );
2465 return; 2470 return;
2466 } 2471 }
2467 mTodoEditor->editTodo( todo ,mFlagEditDescription); 2472 mTodoEditor->editTodo( todo ,mFlagEditDescription);
2468 showTodoEditor(); 2473 showTodoEditor();
2469 2474
2470} 2475}
2471 2476
2472KOEventViewerDialog* CalendarView::getEventViewerDialog() 2477KOEventViewerDialog* CalendarView::getEventViewerDialog()
2473{ 2478{
2474 if ( !mEventViewerDialog ) { 2479 if ( !mEventViewerDialog ) {
2475 mEventViewerDialog = new KOEventViewerDialog(this); 2480 mEventViewerDialog = new KOEventViewerDialog(this);
2476 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 2481 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
2477 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 2482 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
2478 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 2483 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
2479 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 2484 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
2480 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 2485 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
2481 viewManager(), SLOT( showAgendaView( bool ) ) ); 2486 viewManager(), SLOT( showAgendaView( bool ) ) );
2482 mEventViewerDialog->resize( 640, 480 ); 2487 mEventViewerDialog->resize( 640, 480 );
2483 2488
2484 } 2489 }
2485 return mEventViewerDialog; 2490 return mEventViewerDialog;
2486} 2491}
2487void CalendarView::showEvent(Event *event) 2492void CalendarView::showEvent(Event *event)
2488{ 2493{
2489 getEventViewerDialog()->setEvent(event); 2494 getEventViewerDialog()->setEvent(event);
2490 getEventViewerDialog()->showMe(); 2495 getEventViewerDialog()->showMe();
2491} 2496}
2492 2497
2493void CalendarView::showTodo(Todo *event) 2498void CalendarView::showTodo(Todo *event)
2494{ 2499{
2495 getEventViewerDialog()->setTodo(event); 2500 getEventViewerDialog()->setTodo(event);
2496 getEventViewerDialog()->showMe(); 2501 getEventViewerDialog()->showMe();
2497} 2502}
2498void CalendarView::showJournal( Journal *jour ) 2503void CalendarView::showJournal( Journal *jour )
2499{ 2504{
2500 getEventViewerDialog()->setJournal(jour); 2505 getEventViewerDialog()->setJournal(jour);
2501 getEventViewerDialog()->showMe(); 2506 getEventViewerDialog()->showMe();
2502 2507
2503} 2508}
2504// void CalendarView::todoModified (Todo *event, int changed) 2509// void CalendarView::todoModified (Todo *event, int changed)
2505// { 2510// {
2506// // if (mDialogList.find (event) != mDialogList.end ()) { 2511// // if (mDialogList.find (event) != mDialogList.end ()) {
2507// // kdDebug() << "Todo modified and open" << endl; 2512// // kdDebug() << "Todo modified and open" << endl;
2508// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 2513// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
2509// // temp->modified (changed); 2514// // temp->modified (changed);
2510 2515
2511// // } 2516// // }
2512 2517
2513// mViewManager->updateView(); 2518// mViewManager->updateView();
2514// } 2519// }
2515 2520
2516void CalendarView::appointment_show() 2521void CalendarView::appointment_show()
2517{ 2522{
2518 Event *anEvent = 0; 2523 Event *anEvent = 0;
2519 2524
2520 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2525 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2521 2526
2522 if (mViewManager->currentView()->isEventView()) { 2527 if (mViewManager->currentView()->isEventView()) {
2523 if ( incidence && incidence->type() == "Event" ) { 2528 if ( incidence && incidence->type() == "Event" ) {
2524 anEvent = static_cast<Event *>(incidence); 2529 anEvent = static_cast<Event *>(incidence);
2525 } 2530 }
2526 } 2531 }
2527 2532
2528 if (!anEvent) { 2533 if (!anEvent) {
2529 KNotifyClient::beep(); 2534 KNotifyClient::beep();
2530 return; 2535 return;
2531 } 2536 }
2532 2537
2533 showEvent(anEvent); 2538 showEvent(anEvent);
2534} 2539}
2535 2540
2536void CalendarView::appointment_edit() 2541void CalendarView::appointment_edit()
2537{ 2542{
2538 Event *anEvent = 0; 2543 Event *anEvent = 0;
2539 2544
2540 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2545 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2541 2546
2542 if (mViewManager->currentView()->isEventView()) { 2547 if (mViewManager->currentView()->isEventView()) {
2543 if ( incidence && incidence->type() == "Event" ) { 2548 if ( incidence && incidence->type() == "Event" ) {
2544 anEvent = static_cast<Event *>(incidence); 2549 anEvent = static_cast<Event *>(incidence);
2545 } 2550 }
2546 } 2551 }
2547 2552
2548 if (!anEvent) { 2553 if (!anEvent) {
2549 KNotifyClient::beep(); 2554 KNotifyClient::beep();
2550 return; 2555 return;
2551 } 2556 }
2552 2557
2553 editEvent(anEvent); 2558 editEvent(anEvent);
2554} 2559}
2555 2560
2556void CalendarView::appointment_delete() 2561void CalendarView::appointment_delete()
2557{ 2562{
2558 Event *anEvent = 0; 2563 Event *anEvent = 0;
2559 2564
2560 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2565 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2561 2566
2562 if (mViewManager->currentView()->isEventView()) { 2567 if (mViewManager->currentView()->isEventView()) {
2563 if ( incidence && incidence->type() == "Event" ) { 2568 if ( incidence && incidence->type() == "Event" ) {
2564 anEvent = static_cast<Event *>(incidence); 2569 anEvent = static_cast<Event *>(incidence);
2565 } 2570 }
2566 } 2571 }
2567 2572
2568 if (!anEvent) { 2573 if (!anEvent) {
2569 KNotifyClient::beep(); 2574 KNotifyClient::beep();
2570 return; 2575 return;
2571 } 2576 }
2572 2577
2573 deleteEvent(anEvent); 2578 deleteEvent(anEvent);
2574} 2579}
2575 2580
2576void CalendarView::todo_unsub(Todo *anTodo ) 2581void CalendarView::todo_unsub(Todo *anTodo )
2577{ 2582{
2578 // Todo *anTodo = selectedTodo(); 2583 // Todo *anTodo = selectedTodo();
2579 if (!anTodo) return; 2584 if (!anTodo) return;
2580 if (!anTodo->relatedTo()) return; 2585 if (!anTodo->relatedTo()) return;
2581 anTodo->relatedTo()->removeRelation(anTodo); 2586 anTodo->relatedTo()->removeRelation(anTodo);
2582 anTodo->setRelatedTo(0); 2587 anTodo->setRelatedTo(0);
2583 anTodo->updated(); 2588 anTodo->updated();
2584 anTodo->setRelatedToUid(""); 2589 anTodo->setRelatedToUid("");
2585 setModified(true); 2590 setModified(true);
2586 updateView(); 2591 updateView();
2587} 2592}
2588 2593
2589void CalendarView::deleteTodo(Todo *todo) 2594void CalendarView::deleteTodo(Todo *todo)
2590{ 2595{
2591 if (!todo) { 2596 if (!todo) {
2592 KNotifyClient::beep(); 2597 KNotifyClient::beep();
2593 return; 2598 return;
2594 } 2599 }
2595 if (KOPrefs::instance()->mConfirm) { 2600 if (KOPrefs::instance()->mConfirm) {
2596 switch (msgItemDelete()) { 2601 switch (msgItemDelete()) {
2597 case KMessageBox::Continue: // OK 2602 case KMessageBox::Continue: // OK
2598 if (!todo->relations().isEmpty()) { 2603 if (!todo->relations().isEmpty()) {
2599 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), 2604 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."),
2600 i18n("Delete To-Do")); 2605 i18n("Delete To-Do"));
2601 } else { 2606 } else {
2602 checkExternalId( todo ); 2607 checkExternalId( todo );
2603 calendar()->deleteTodo(todo); 2608 calendar()->deleteTodo(todo);
2604 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2609 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2605 updateView(); 2610 updateView();
2606 } 2611 }
2607 break; 2612 break;
2608 } // switch 2613 } // switch
2609 } else { 2614 } else {
2610 if (!todo->relations().isEmpty()) { 2615 if (!todo->relations().isEmpty()) {
2611 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), 2616 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."),
2612 i18n("Delete To-Do")); 2617 i18n("Delete To-Do"));
2613 } else { 2618 } else {
2614 checkExternalId( todo ); 2619 checkExternalId( todo );
2615 mCalendar->deleteTodo(todo); 2620 mCalendar->deleteTodo(todo);
2616 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2621 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2617 updateView(); 2622 updateView();
2618 } 2623 }
2619 } 2624 }
2620 emit updateSearchDialog(); 2625 emit updateSearchDialog();
2621} 2626}
2622void CalendarView::deleteJournal(Journal *jour) 2627void CalendarView::deleteJournal(Journal *jour)
2623{ 2628{
2624 if (!jour) { 2629 if (!jour) {
2625 KNotifyClient::beep(); 2630 KNotifyClient::beep();
2626 return; 2631 return;
2627 } 2632 }
2628 if (KOPrefs::instance()->mConfirm) { 2633 if (KOPrefs::instance()->mConfirm) {
2629 switch (msgItemDelete()) { 2634 switch (msgItemDelete()) {
2630 case KMessageBox::Continue: // OK 2635 case KMessageBox::Continue: // OK
2631 calendar()->deleteJournal(jour); 2636 calendar()->deleteJournal(jour);
2632 updateView(); 2637 updateView();
2633 break; 2638 break;
2634 } // switch 2639 } // switch
2635 } else { 2640 } else {
2636 calendar()->deleteJournal(jour);; 2641 calendar()->deleteJournal(jour);;
2637 updateView(); 2642 updateView();
2638 } 2643 }
2639 emit updateSearchDialog(); 2644 emit updateSearchDialog();
2640} 2645}
2641 2646
2642void CalendarView::deleteEvent(Event *anEvent) 2647void CalendarView::deleteEvent(Event *anEvent)
2643{ 2648{
2644 if (!anEvent) { 2649 if (!anEvent) {
2645 KNotifyClient::beep(); 2650 KNotifyClient::beep();
2646 return; 2651 return;
2647 } 2652 }
2648 2653
2649 if (anEvent->recurrence()->doesRecur()) { 2654 if (anEvent->recurrence()->doesRecur()) {
2650 QDate itemDate = mViewManager->currentSelectionDate(); 2655 QDate itemDate = mViewManager->currentSelectionDate();
2651 int km; 2656 int km;
2652 if (!itemDate.isValid()) { 2657 if (!itemDate.isValid()) {
2653 //kdDebug() << "Date Not Valid" << endl; 2658 //kdDebug() << "Date Not Valid" << endl;
2654 if (KOPrefs::instance()->mConfirm) { 2659 if (KOPrefs::instance()->mConfirm) {
2655 km = KMessageBox::warningContinueCancel(this,anEvent->summary() + 2660 km = KMessageBox::warningContinueCancel(this,anEvent->summary() +
2656 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), 2661 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"),
2657 i18n("KO/Pi Confirmation"),i18n("Delete All")); 2662 i18n("KO/Pi Confirmation"),i18n("Delete All"));
2658 if ( km == KMessageBox::Continue ) 2663 if ( km == KMessageBox::Continue )
2659 km = KMessageBox::No; // No = all below 2664 km = KMessageBox::No; // No = all below
2660 } else 2665 } else
2661 km = KMessageBox::No; 2666 km = KMessageBox::No;
2662 } else { 2667 } else {
2663 km = KMessageBox::warningYesNoCancel(this,anEvent->summary() + 2668 km = KMessageBox::warningYesNoCancel(this,anEvent->summary() +
2664 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ 2669 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+
2665 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), 2670 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"),
2666 i18n("KO/Pi Confirmation"),i18n("Current"), 2671 i18n("KO/Pi Confirmation"),i18n("Current"),
2667 i18n("All")); 2672 i18n("All"));
2668 } 2673 }
2669 switch(km) { 2674 switch(km) {
2670 2675
2671 case KMessageBox::No: // Continue // all 2676 case KMessageBox::No: // Continue // all
2672 //qDebug("KMessageBox::No "); 2677 //qDebug("KMessageBox::No ");
2673 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2678 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2674 schedule(Scheduler::Cancel,anEvent); 2679 schedule(Scheduler::Cancel,anEvent);
2675 2680
2676 checkExternalId( anEvent); 2681 checkExternalId( anEvent);
2677 mCalendar->deleteEvent(anEvent); 2682 mCalendar->deleteEvent(anEvent);
2678 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); 2683 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED);
2679 break; 2684 break;
2680 2685
2681 // Disabled because it does not work 2686 // Disabled because it does not work
2682 //#if 0 2687 //#if 0
2683 case KMessageBox::Yes: // just this one 2688 case KMessageBox::Yes: // just this one
2684 //QDate qd = mNavigator->selectedDates().first(); 2689 //QDate qd = mNavigator->selectedDates().first();
2685 //if (!qd.isValid()) { 2690 //if (!qd.isValid()) {
2686 // kdDebug() << "no date selected, or invalid date" << endl; 2691 // kdDebug() << "no date selected, or invalid date" << endl;
2687 // KNotifyClient::beep(); 2692 // KNotifyClient::beep();
2688 // return; 2693 // return;
2689 //} 2694 //}
2690 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); 2695 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1);
2691 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { 2696 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) {
2692 anEvent->addExDate(itemDate); 2697 anEvent->addExDate(itemDate);
2693 int duration = anEvent->recurrence()->duration(); 2698 int duration = anEvent->recurrence()->duration();
2694 if ( duration > 0 ) { 2699 if ( duration > 0 ) {
2695 anEvent->recurrence()->setDuration( duration - 1 ); 2700 anEvent->recurrence()->setDuration( duration - 1 );
2696 } 2701 }
2697 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); 2702 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED);
2698 } 2703 }
2699 break; 2704 break;
2700 //#endif 2705 //#endif
2701 } // switch 2706 } // switch
2702 } else { 2707 } else {
2703 if (KOPrefs::instance()->mConfirm) { 2708 if (KOPrefs::instance()->mConfirm) {
2704 switch (KMessageBox::warningContinueCancel(this,anEvent->summary() + 2709 switch (KMessageBox::warningContinueCancel(this,anEvent->summary() +
2705 i18n("\nAre you sure you want\nto delete this event?"), 2710 i18n("\nAre you sure you want\nto delete this event?"),
2706 i18n("KO/Pi Confirmation"),i18n("Delete"))) { 2711 i18n("KO/Pi Confirmation"),i18n("Delete"))) {
2707 case KMessageBox::Continue: // OK 2712 case KMessageBox::Continue: // OK
2708 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2713 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2709 schedule(Scheduler::Cancel,anEvent); 2714 schedule(Scheduler::Cancel,anEvent);
2710 checkExternalId( anEvent); 2715 checkExternalId( anEvent);
2711 mCalendar->deleteEvent(anEvent); 2716 mCalendar->deleteEvent(anEvent);
2712 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2717 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2713 break; 2718 break;
2714 } // switch 2719 } // switch
2715 } else { 2720 } else {
2716 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2721 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2717 schedule(Scheduler::Cancel,anEvent); 2722 schedule(Scheduler::Cancel,anEvent);
2718 checkExternalId( anEvent); 2723 checkExternalId( anEvent);
2719 mCalendar->deleteEvent(anEvent); 2724 mCalendar->deleteEvent(anEvent);
2720 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2725 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2721 } 2726 }
2722 } // if-else 2727 } // if-else
2723 emit updateSearchDialog(); 2728 emit updateSearchDialog();
2724} 2729}
2725 2730
2726bool CalendarView::deleteEvent(const QString &uid) 2731bool CalendarView::deleteEvent(const QString &uid)
2727{ 2732{
2728 Event *ev = mCalendar->event(uid); 2733 Event *ev = mCalendar->event(uid);
2729 if (ev) { 2734 if (ev) {
2730 deleteEvent(ev); 2735 deleteEvent(ev);
2731 return true; 2736 return true;
2732 } else { 2737 } else {
2733 return false; 2738 return false;
2734 } 2739 }
2735} 2740}
2736 2741
2737/*****************************************************************************/ 2742/*****************************************************************************/
2738 2743
2739void CalendarView::action_mail() 2744void CalendarView::action_mail()
2740{ 2745{
2741#ifndef KORG_NOMAIL 2746#ifndef KORG_NOMAIL
2742 KOMailClient mailClient; 2747 KOMailClient mailClient;
2743 2748
2744 Incidence *incidence = currentSelection(); 2749 Incidence *incidence = currentSelection();
2745 2750
2746 if (!incidence) { 2751 if (!incidence) {
2747 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 2752 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
2748 return; 2753 return;
2749 } 2754 }
2750 if(incidence->attendeeCount() == 0 ) { 2755 if(incidence->attendeeCount() == 0 ) {
2751 KMessageBox::sorry(this, 2756 KMessageBox::sorry(this,
2752 i18n("Can't generate mail:\nNo attendees defined.\n")); 2757 i18n("Can't generate mail:\nNo attendees defined.\n"));
2753 return; 2758 return;
2754 } 2759 }
2755 2760
2756 CalendarLocal cal_tmp; 2761 CalendarLocal cal_tmp;
2757 Event *event = 0; 2762 Event *event = 0;
2758 Event *ev = 0; 2763 Event *ev = 0;
2759 if ( incidence && incidence->type() == "Event" ) { 2764 if ( incidence && incidence->type() == "Event" ) {
2760 event = static_cast<Event *>(incidence); 2765 event = static_cast<Event *>(incidence);
2761 ev = new Event(*event); 2766 ev = new Event(*event);
2762 cal_tmp.addEvent(ev); 2767 cal_tmp.addEvent(ev);
2763 } 2768 }
2764 ICalFormat mForm( KOPrefs::instance()->mUseQuicksave); 2769 ICalFormat mForm( KOPrefs::instance()->mUseQuicksave);
2765 QString attachment = mForm.toString( &cal_tmp ); 2770 QString attachment = mForm.toString( &cal_tmp );
2766 if (ev) delete(ev); 2771 if (ev) delete(ev);
2767 2772
2768 mailClient.mailAttendees(currentSelection(), attachment); 2773 mailClient.mailAttendees(currentSelection(), attachment);
2769 2774
2770#endif 2775#endif
2771 2776
2772#if 0 2777#if 0
2773 Event *anEvent = 0; 2778 Event *anEvent = 0;
2774 if (mViewManager->currentView()->isEventView()) { 2779 if (mViewManager->currentView()->isEventView()) {
2775 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); 2780 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first());
2776 } 2781 }
2777 2782
2778 if (!anEvent) { 2783 if (!anEvent) {
2779 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 2784 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
2780 return; 2785 return;
2781 } 2786 }
2782 if(anEvent->attendeeCount() == 0 ) { 2787 if(anEvent->attendeeCount() == 0 ) {
2783 KMessageBox::sorry(this, 2788 KMessageBox::sorry(this,
2784 i18n("Can't generate mail:\nNo attendees defined.\n")); 2789 i18n("Can't generate mail:\nNo attendees defined.\n"));
2785 return; 2790 return;
2786 } 2791 }
2787 2792
2788 mailobject.emailEvent(anEvent); 2793 mailobject.emailEvent(anEvent);
2789#endif 2794#endif
2790} 2795}
2791 2796
2792 2797
2793void CalendarView::schedule_publish(Incidence *incidence) 2798void CalendarView::schedule_publish(Incidence *incidence)
2794{ 2799{
2795 Event *event = 0; 2800 Event *event = 0;
2796 Todo *todo = 0; 2801 Todo *todo = 0;
2797 2802
2798 if (incidence == 0) { 2803 if (incidence == 0) {
2799 incidence = mViewManager->currentView()->selectedIncidences().first(); 2804 incidence = mViewManager->currentView()->selectedIncidences().first();
2800 if (incidence == 0) { 2805 if (incidence == 0) {
2801 incidence = mTodoList->selectedIncidences().first(); 2806 incidence = mTodoList->selectedIncidences().first();
2802 } 2807 }
2803 } 2808 }
2804 if ( incidence && incidence->type() == "Event" ) { 2809 if ( incidence && incidence->type() == "Event" ) {
2805 event = static_cast<Event *>(incidence); 2810 event = static_cast<Event *>(incidence);
2806 } else { 2811 } else {
2807 if ( incidence && incidence->type() == "Todo" ) { 2812 if ( incidence && incidence->type() == "Todo" ) {
2808 todo = static_cast<Todo *>(incidence); 2813 todo = static_cast<Todo *>(incidence);
2809 } 2814 }
2810 } 2815 }
2811 2816
2812 if (!event && !todo) { 2817 if (!event && !todo) {
2813 KMessageBox::sorry(this,i18n("No event selected.")); 2818 KMessageBox::sorry(this,i18n("No event selected."));
2814 return; 2819 return;
2815 } 2820 }
2816 2821
2817 PublishDialog *publishdlg = new PublishDialog(); 2822 PublishDialog *publishdlg = new PublishDialog();
2818 if (incidence->attendeeCount()>0) { 2823 if (incidence->attendeeCount()>0) {
2819 QPtrList<Attendee> attendees = incidence->attendees(); 2824 QPtrList<Attendee> attendees = incidence->attendees();
2820 attendees.first(); 2825 attendees.first();
2821 while ( attendees.current()!=0 ) { 2826 while ( attendees.current()!=0 ) {
2822 publishdlg->addAttendee(attendees.current()); 2827 publishdlg->addAttendee(attendees.current());
2823 attendees.next(); 2828 attendees.next();
2824 } 2829 }
2825 } 2830 }
2826 bool send = true; 2831 bool send = true;
2827 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { 2832 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) {
2828 if ( publishdlg->exec() != QDialog::Accepted ) 2833 if ( publishdlg->exec() != QDialog::Accepted )
2829 send = false; 2834 send = false;
2830 } 2835 }
2831 if ( send ) { 2836 if ( send ) {
2832 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 2837 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
2833 if ( event ) { 2838 if ( event ) {
2834 Event *ev = new Event(*event); 2839 Event *ev = new Event(*event);
2835 ev->registerObserver(0); 2840 ev->registerObserver(0);
2836 ev->clearAttendees(); 2841 ev->clearAttendees();
2837 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 2842 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
2838 delete(ev); 2843 delete(ev);
2839 } 2844 }
2840 } else { 2845 } else {
2841 if ( todo ) { 2846 if ( todo ) {
2842 Todo *ev = new Todo(*todo); 2847 Todo *ev = new Todo(*todo);
2843 ev->registerObserver(0); 2848 ev->registerObserver(0);
2844 ev->clearAttendees(); 2849 ev->clearAttendees();
2845 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 2850 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
2846 delete(ev); 2851 delete(ev);
2847 } 2852 }
2848 } 2853 }
2849 } 2854 }
2850 } 2855 }
2851 delete publishdlg; 2856 delete publishdlg;
2852} 2857}
2853 2858
2854void CalendarView::schedule_request(Incidence *incidence) 2859void CalendarView::schedule_request(Incidence *incidence)
2855{ 2860{
2856 schedule(Scheduler::Request,incidence); 2861 schedule(Scheduler::Request,incidence);
2857} 2862}
2858 2863
2859void CalendarView::schedule_refresh(Incidence *incidence) 2864void CalendarView::schedule_refresh(Incidence *incidence)
2860{ 2865{
2861 schedule(Scheduler::Refresh,incidence); 2866 schedule(Scheduler::Refresh,incidence);
2862} 2867}
2863 2868
2864void CalendarView::schedule_cancel(Incidence *incidence) 2869void CalendarView::schedule_cancel(Incidence *incidence)
2865{ 2870{
2866 schedule(Scheduler::Cancel,incidence); 2871 schedule(Scheduler::Cancel,incidence);
2867} 2872}
2868 2873
2869void CalendarView::schedule_add(Incidence *incidence) 2874void CalendarView::schedule_add(Incidence *incidence)
2870{ 2875{
2871 schedule(Scheduler::Add,incidence); 2876 schedule(Scheduler::Add,incidence);
2872} 2877}
2873 2878
2874void CalendarView::schedule_reply(Incidence *incidence) 2879void CalendarView::schedule_reply(Incidence *incidence)
2875{ 2880{
2876 schedule(Scheduler::Reply,incidence); 2881 schedule(Scheduler::Reply,incidence);
2877} 2882}
2878 2883
2879void CalendarView::schedule_counter(Incidence *incidence) 2884void CalendarView::schedule_counter(Incidence *incidence)
2880{ 2885{
2881 schedule(Scheduler::Counter,incidence); 2886 schedule(Scheduler::Counter,incidence);
2882} 2887}
2883 2888
2884void CalendarView::schedule_declinecounter(Incidence *incidence) 2889void CalendarView::schedule_declinecounter(Incidence *incidence)
2885{ 2890{
2886 schedule(Scheduler::Declinecounter,incidence); 2891 schedule(Scheduler::Declinecounter,incidence);
2887} 2892}
2888 2893
2889void CalendarView::schedule_publish_freebusy(int daysToPublish) 2894void CalendarView::schedule_publish_freebusy(int daysToPublish)
2890{ 2895{
2891 QDateTime start = QDateTime::currentDateTime(); 2896 QDateTime start = QDateTime::currentDateTime();
2892 QDateTime end = start.addDays(daysToPublish); 2897 QDateTime end = start.addDays(daysToPublish);
2893 2898
2894 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); 2899 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end);
2895 freebusy->setOrganizer(KOPrefs::instance()->email()); 2900 freebusy->setOrganizer(KOPrefs::instance()->email());
2896 2901
2897 2902
2898 PublishDialog *publishdlg = new PublishDialog(); 2903 PublishDialog *publishdlg = new PublishDialog();
2899 if ( publishdlg->exec() == QDialog::Accepted ) { 2904 if ( publishdlg->exec() == QDialog::Accepted ) {
2900 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 2905 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
2901 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { 2906 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) {
2902 delete(freebusy); 2907 delete(freebusy);
2903 } 2908 }
2904 } 2909 }
2905 delete publishdlg; 2910 delete publishdlg;
2906} 2911}
2907 2912
2908void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) 2913void CalendarView::schedule(Scheduler::Method method, Incidence *incidence)
2909{ 2914{
2910 Event *event = 0; 2915 Event *event = 0;
2911 Todo *todo = 0; 2916 Todo *todo = 0;
2912 2917
2913 if (incidence == 0) { 2918 if (incidence == 0) {
2914 incidence = mViewManager->currentView()->selectedIncidences().first(); 2919 incidence = mViewManager->currentView()->selectedIncidences().first();
2915 if (incidence == 0) { 2920 if (incidence == 0) {
2916 incidence = mTodoList->selectedIncidences().first(); 2921 incidence = mTodoList->selectedIncidences().first();
2917 } 2922 }
2918 } 2923 }
2919 if ( incidence && incidence->type() == "Event" ) { 2924 if ( incidence && incidence->type() == "Event" ) {
2920 event = static_cast<Event *>(incidence); 2925 event = static_cast<Event *>(incidence);
2921 } 2926 }
2922 if ( incidence && incidence->type() == "Todo" ) { 2927 if ( incidence && incidence->type() == "Todo" ) {
2923 todo = static_cast<Todo *>(incidence); 2928 todo = static_cast<Todo *>(incidence);
2924 } 2929 }
2925 2930
2926 if (!event && !todo) { 2931 if (!event && !todo) {
2927 KMessageBox::sorry(this,i18n("No event selected.")); 2932 KMessageBox::sorry(this,i18n("No event selected."));
2928 return; 2933 return;
2929 } 2934 }
2930 2935
2931 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { 2936 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) {
2932 KMessageBox::sorry(this,i18n("The event has no attendees.")); 2937 KMessageBox::sorry(this,i18n("The event has no attendees."));
2933 return; 2938 return;
2934 } 2939 }
2935 2940
2936 Event *ev = 0; 2941 Event *ev = 0;
2937 if (event) ev = new Event(*event); 2942 if (event) ev = new Event(*event);
2938 Todo *to = 0; 2943 Todo *to = 0;
2939 if (todo) to = new Todo(*todo); 2944 if (todo) to = new Todo(*todo);
2940 2945
2941 if (method == Scheduler::Reply || method == Scheduler::Refresh) { 2946 if (method == Scheduler::Reply || method == Scheduler::Refresh) {
2942 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 2947 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
2943 if (!me) { 2948 if (!me) {
2944 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); 2949 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails."));
2945 return; 2950 return;
2946 } 2951 }
2947 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { 2952 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) {
2948 StatusDialog *statdlg = new StatusDialog(this); 2953 StatusDialog *statdlg = new StatusDialog(this);
2949 if (!statdlg->exec()==QDialog::Accepted) return; 2954 if (!statdlg->exec()==QDialog::Accepted) return;
2950 me->setStatus( statdlg->status() ); 2955 me->setStatus( statdlg->status() );
2951 delete(statdlg); 2956 delete(statdlg);
2952 } 2957 }
2953 Attendee *menew = new Attendee(*me); 2958 Attendee *menew = new Attendee(*me);
2954 if (ev) { 2959 if (ev) {
2955 ev->clearAttendees(); 2960 ev->clearAttendees();
2956 ev->addAttendee(menew,false); 2961 ev->addAttendee(menew,false);
2957 } else { 2962 } else {
2958 if (to) { 2963 if (to) {
2959 todo->clearAttendees(); 2964 todo->clearAttendees();
2960 todo->addAttendee(menew,false); 2965 todo->addAttendee(menew,false);
2961 } 2966 }
2962 } 2967 }
2963 } 2968 }
2964 2969
2965 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 2970 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
2966 if (ev) { 2971 if (ev) {
2967 if ( !dlg->addMessage(ev,method) ) delete(ev); 2972 if ( !dlg->addMessage(ev,method) ) delete(ev);
2968 } else { 2973 } else {
2969 if (to) { 2974 if (to) {
2970 if ( !dlg->addMessage(to,method) ) delete(to); 2975 if ( !dlg->addMessage(to,method) ) delete(to);
2971 } 2976 }
2972 } 2977 }
2973} 2978}
2974 2979
2975void CalendarView::openAddressbook() 2980void CalendarView::openAddressbook()
2976{ 2981{
2977 KRun::runCommand("kaddressbook"); 2982 KRun::runCommand("kaddressbook");
2978} 2983}
2979 2984
2980void CalendarView::setModified(bool modified) 2985void CalendarView::setModified(bool modified)
2981{ 2986{
2982 if ( modified ) 2987 if ( modified )
2983 emit signalmodified(); 2988 emit signalmodified();
2984 if (mModified != modified) { 2989 if (mModified != modified) {
2985 mModified = modified; 2990 mModified = modified;
2986 emit modifiedChanged(mModified); 2991 emit modifiedChanged(mModified);
2987 } 2992 }
2988} 2993}
2989 2994
2990bool CalendarView::isReadOnly() 2995bool CalendarView::isReadOnly()
2991{ 2996{
2992 return mReadOnly; 2997 return mReadOnly;
2993} 2998}
2994 2999
2995void CalendarView::setReadOnly(bool readOnly) 3000void CalendarView::setReadOnly(bool readOnly)
2996{ 3001{
2997 if (mReadOnly != readOnly) { 3002 if (mReadOnly != readOnly) {
2998 mReadOnly = readOnly; 3003 mReadOnly = readOnly;
2999 emit readOnlyChanged(mReadOnly); 3004 emit readOnlyChanged(mReadOnly);
3000 } 3005 }
3001} 3006}
3002 3007
3003bool CalendarView::isModified() 3008bool CalendarView::isModified()
3004{ 3009{
3005 return mModified; 3010 return mModified;
3006} 3011}
3007 3012
3008void CalendarView::printSetup() 3013void CalendarView::printSetup()
3009{ 3014{
3010#ifndef KORG_NOPRINTER 3015#ifndef KORG_NOPRINTER
3011 createPrinter(); 3016 createPrinter();
3012 3017
3013 mCalPrinter->setupPrinter(); 3018 mCalPrinter->setupPrinter();
3014#endif 3019#endif
3015} 3020}
3016 3021
3017void CalendarView::print() 3022void CalendarView::print()
3018{ 3023{
3019#ifndef KORG_NOPRINTER 3024#ifndef KORG_NOPRINTER
3020 createPrinter(); 3025 createPrinter();
3021 3026
3022 DateList tmpDateList = mNavigator->selectedDates(); 3027 DateList tmpDateList = mNavigator->selectedDates();
3023 mCalPrinter->print(CalPrinter::Month, 3028 mCalPrinter->print(CalPrinter::Month,
3024 tmpDateList.first(), tmpDateList.last()); 3029 tmpDateList.first(), tmpDateList.last());
3025#endif 3030#endif
3026} 3031}
3027 3032
3028void CalendarView::printPreview() 3033void CalendarView::printPreview()
3029{ 3034{
3030#ifndef KORG_NOPRINTER 3035#ifndef KORG_NOPRINTER
3031 kdDebug() << "CalendarView::printPreview()" << endl; 3036 kdDebug() << "CalendarView::printPreview()" << endl;
3032 3037
3033 createPrinter(); 3038 createPrinter();
3034 3039
3035 DateList tmpDateList = mNavigator->selectedDates(); 3040 DateList tmpDateList = mNavigator->selectedDates();
3036 3041
3037 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), 3042 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(),
3038 tmpDateList.last()); 3043 tmpDateList.last());
3039#endif 3044#endif
3040} 3045}
3041 3046
3042void CalendarView::exportICalendar() 3047void CalendarView::exportICalendar()
3043{ 3048{
3044 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); 3049 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this);
3045 3050
3046 // Force correct extension 3051 // Force correct extension
3047 if (filename.right(4) != ".ics") filename += ".ics"; 3052 if (filename.right(4) != ".ics") filename += ".ics";
3048 3053
3049 FileStorage storage( mCalendar, filename, new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 3054 FileStorage storage( mCalendar, filename, new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
3050 storage.save(); 3055 storage.save();
3051} 3056}
3052 3057
3053bool CalendarView::exportVCalendar( QString filename ) 3058bool CalendarView::exportVCalendar( QString filename )
3054{ 3059{
3055 if (mCalendar->journals().count() > 0) { 3060 if (mCalendar->journals().count() > 0) {
3056 int result = KMessageBox::warningContinueCancel(this, 3061 int result = KMessageBox::warningContinueCancel(this,
3057 i18n("The journal entries can not be\nexported to a vCalendar file."), 3062 i18n("The journal entries can not be\nexported to a vCalendar file."),
3058 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 3063 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
3059 true); 3064 true);
3060 if (result != KMessageBox::Continue) return false; 3065 if (result != KMessageBox::Continue) return false;
3061 } 3066 }
3062 3067
3063 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); 3068 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this);
3064 3069
3065 // Force correct extension 3070 // Force correct extension
3066 if (filename.right(4) != ".vcs") filename += ".vcs"; 3071 if (filename.right(4) != ".vcs") filename += ".vcs";
3067 3072
3068 FileStorage storage( mCalendar, filename, new VCalFormat ); 3073 FileStorage storage( mCalendar, filename, new VCalFormat );
3069 return storage.save(); 3074 return storage.save();
3070 3075
3071} 3076}
3072 3077
3073void CalendarView::eventUpdated(Incidence *) 3078void CalendarView::eventUpdated(Incidence *)
3074{ 3079{
3075 setModified(); 3080 setModified();
3076 // Don't call updateView here. The code, which has caused the update of the 3081 // Don't call updateView here. The code, which has caused the update of the
3077 // event is responsible for updating the view. 3082 // event is responsible for updating the view.
3078 // updateView(); 3083 // updateView();
3079} 3084}
3080 3085
3081void CalendarView::adaptNavigationUnits() 3086void CalendarView::adaptNavigationUnits()
3082{ 3087{
3083 if (mViewManager->currentView()->isEventView()) { 3088 if (mViewManager->currentView()->isEventView()) {
3084 int days = mViewManager->currentView()->currentDateCount(); 3089 int days = mViewManager->currentView()->currentDateCount();
3085 if (days == 1) { 3090 if (days == 1) {
3086 emit changeNavStringPrev(i18n("&Previous Day")); 3091 emit changeNavStringPrev(i18n("&Previous Day"));
3087 emit changeNavStringNext(i18n("&Next Day")); 3092 emit changeNavStringNext(i18n("&Next Day"));
3088 } else { 3093 } else {
3089 emit changeNavStringPrev(i18n("&Previous Week")); 3094 emit changeNavStringPrev(i18n("&Previous Week"));
3090 emit changeNavStringNext(i18n("&Next Week")); 3095 emit changeNavStringNext(i18n("&Next Week"));
3091 } 3096 }
3092 } 3097 }
3093} 3098}
3094 3099
3095void CalendarView::processMainViewSelection( Incidence *incidence ) 3100void CalendarView::processMainViewSelection( Incidence *incidence )
3096{ 3101{
3097 if ( incidence ) mTodoList->clearSelection(); 3102 if ( incidence ) mTodoList->clearSelection();
3098 processIncidenceSelection( incidence ); 3103 processIncidenceSelection( incidence );
3099} 3104}
3100 3105
3101void CalendarView::processTodoListSelection( Incidence *incidence ) 3106void CalendarView::processTodoListSelection( Incidence *incidence )
3102{ 3107{
3103 if ( incidence && mViewManager->currentView() ) { 3108 if ( incidence && mViewManager->currentView() ) {
3104 mViewManager->currentView()->clearSelection(); 3109 mViewManager->currentView()->clearSelection();
3105 } 3110 }
3106 processIncidenceSelection( incidence ); 3111 processIncidenceSelection( incidence );
3107} 3112}
3108 3113
3109void CalendarView::processIncidenceSelection( Incidence *incidence ) 3114void CalendarView::processIncidenceSelection( Incidence *incidence )
3110{ 3115{
3111 if ( incidence == mSelectedIncidence ) return; 3116 if ( incidence == mSelectedIncidence ) return;
3112 3117
3113 mSelectedIncidence = incidence; 3118 mSelectedIncidence = incidence;
3114 3119
3115 emit incidenceSelected( mSelectedIncidence ); 3120 emit incidenceSelected( mSelectedIncidence );
3116 3121
3117 if ( incidence && incidence->type() == "Event" ) { 3122 if ( incidence && incidence->type() == "Event" ) {
3118 Event *event = static_cast<Event *>( incidence ); 3123 Event *event = static_cast<Event *>( incidence );
3119 if ( event->organizer() == KOPrefs::instance()->email() ) { 3124 if ( event->organizer() == KOPrefs::instance()->email() ) {
3120 emit organizerEventsSelected( true ); 3125 emit organizerEventsSelected( true );
3121 } else { 3126 } else {
3122 emit organizerEventsSelected(false); 3127 emit organizerEventsSelected(false);
3123 } 3128 }
3124 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3129 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3125 KOPrefs::instance()->email() ) ) { 3130 KOPrefs::instance()->email() ) ) {
3126 emit groupEventsSelected( true ); 3131 emit groupEventsSelected( true );
3127 } else { 3132 } else {
3128 emit groupEventsSelected(false); 3133 emit groupEventsSelected(false);
3129 } 3134 }
3130 return; 3135 return;
3131 } else { 3136 } else {
3132 if ( incidence && incidence->type() == "Todo" ) { 3137 if ( incidence && incidence->type() == "Todo" ) {
3133 emit todoSelected( true ); 3138 emit todoSelected( true );
3134 Todo *event = static_cast<Todo *>( incidence ); 3139 Todo *event = static_cast<Todo *>( incidence );
3135 if ( event->organizer() == KOPrefs::instance()->email() ) { 3140 if ( event->organizer() == KOPrefs::instance()->email() ) {
3136 emit organizerEventsSelected( true ); 3141 emit organizerEventsSelected( true );
3137 } else { 3142 } else {
3138 emit organizerEventsSelected(false); 3143 emit organizerEventsSelected(false);
3139 } 3144 }
3140 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3145 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3141 KOPrefs::instance()->email() ) ) { 3146 KOPrefs::instance()->email() ) ) {
3142 emit groupEventsSelected( true ); 3147 emit groupEventsSelected( true );
3143 } else { 3148 } else {
3144 emit groupEventsSelected(false); 3149 emit groupEventsSelected(false);
3145 } 3150 }
3146 return; 3151 return;
3147 } else { 3152 } else {
3148 emit todoSelected( false ); 3153 emit todoSelected( false );
3149 emit organizerEventsSelected(false); 3154 emit organizerEventsSelected(false);
3150 emit groupEventsSelected(false); 3155 emit groupEventsSelected(false);
3151 } 3156 }
3152 return; 3157 return;
3153 } 3158 }
3154 3159
3155 /* if ( incidence && incidence->type() == "Todo" ) { 3160 /* if ( incidence && incidence->type() == "Todo" ) {
3156 emit todoSelected( true ); 3161 emit todoSelected( true );
3157 } else { 3162 } else {
3158 emit todoSelected( false ); 3163 emit todoSelected( false );
3159 }*/ 3164 }*/
3160} 3165}
3161 3166
3162 3167
3163void CalendarView::checkClipboard() 3168void CalendarView::checkClipboard()
3164{ 3169{
3165#ifndef KORG_NODND 3170#ifndef KORG_NODND
3166 if (ICalDrag::canDecode(QApplication::clipboard()->data())) { 3171 if (ICalDrag::canDecode(QApplication::clipboard()->data())) {
3167 emit pasteEnabled(true); 3172 emit pasteEnabled(true);
3168 } else { 3173 } else {
3169 emit pasteEnabled(false); 3174 emit pasteEnabled(false);
3170 } 3175 }
3171#endif 3176#endif
3172} 3177}
3173 3178
3174void CalendarView::showDates(const DateList &selectedDates) 3179void CalendarView::showDates(const DateList &selectedDates)
3175{ 3180{
3176 // kdDebug() << "CalendarView::selectDates()" << endl; 3181 // kdDebug() << "CalendarView::selectDates()" << endl;
3177 3182
3178 if ( mViewManager->currentView() ) { 3183 if ( mViewManager->currentView() ) {
3179 updateView( selectedDates.first(), selectedDates.last() ); 3184 updateView( selectedDates.first(), selectedDates.last() );
3180 } else { 3185 } else {
3181 mViewManager->showAgendaView(); 3186 mViewManager->showAgendaView();
3182 } 3187 }
3183 3188
3184 QString selDates; 3189 QString selDates;
3185 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); 3190 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true);
3186 if (selectedDates.first() < selectedDates.last() ) 3191 if (selectedDates.first() < selectedDates.last() )
3187 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); 3192 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true);
3188 topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); 3193 topLevelWidget()->setCaption( i18n("Dates: ") + selDates );
3189 3194
3190} 3195}
3191 3196
3192QPtrList<CalFilter> CalendarView::filters() 3197QPtrList<CalFilter> CalendarView::filters()
3193{ 3198{
3194 return mFilters; 3199 return mFilters;
3195 3200
3196} 3201}
3197void CalendarView::editFilters() 3202void CalendarView::editFilters()
3198{ 3203{
3199 // kdDebug() << "CalendarView::editFilters()" << endl; 3204 // kdDebug() << "CalendarView::editFilters()" << endl;
3200 3205
3201 CalFilter *filter = mFilters.first(); 3206 CalFilter *filter = mFilters.first();
3202 while(filter) { 3207 while(filter) {
3203 kdDebug() << " Filter: " << filter->name() << endl; 3208 kdDebug() << " Filter: " << filter->name() << endl;
3204 filter = mFilters.next(); 3209 filter = mFilters.next();
3205 } 3210 }
3206 3211
3207 mDialogManager->showFilterEditDialog(&mFilters); 3212 mDialogManager->showFilterEditDialog(&mFilters);
3208} 3213}
3209void CalendarView::toggleFilter() 3214void CalendarView::toggleFilter()
3210{ 3215{
3211 showFilter(! mFilterView->isVisible()); 3216 showFilter(! mFilterView->isVisible());
3212} 3217}
3213 3218
3214KOFilterView *CalendarView::filterView() 3219KOFilterView *CalendarView::filterView()
3215{ 3220{
3216 return mFilterView; 3221 return mFilterView;
3217} 3222}
3218void CalendarView::selectFilter( int fil ) 3223void CalendarView::selectFilter( int fil )
3219{ 3224{
3220 mFilterView->setSelectedFilter( fil ); 3225 mFilterView->setSelectedFilter( fil );
3221} 3226}
3222void CalendarView::showFilter(bool visible) 3227void CalendarView::showFilter(bool visible)
3223{ 3228{
3224 if (visible) mFilterView->show(); 3229 if (visible) mFilterView->show();
3225 else mFilterView->hide(); 3230 else mFilterView->hide();
3226} 3231}
3227void CalendarView::toggleFilerEnabled( ) 3232void CalendarView::toggleFilerEnabled( )
3228{ 3233{
3229 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); 3234 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() );
3230 if ( !mFilterView->filtersEnabled() ) 3235 if ( !mFilterView->filtersEnabled() )
3231 topLevelWidget()->setCaption( i18n("Filter disabled ") ); 3236 topLevelWidget()->setCaption( i18n("Filter disabled ") );
3232 3237
3233} 3238}
3234void CalendarView::updateFilter() 3239void CalendarView::updateFilter()
3235{ 3240{
3236 CalFilter *filter = mFilterView->selectedFilter(); 3241 CalFilter *filter = mFilterView->selectedFilter();
3237 if (filter) { 3242 if (filter) {
3238 if (mFilterView->filtersEnabled()) { 3243 if (mFilterView->filtersEnabled()) {
3239 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); 3244 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() );
3240 filter->setEnabled(true); 3245 filter->setEnabled(true);
3241 } 3246 }
3242 else filter->setEnabled(false); 3247 else filter->setEnabled(false);
3243 mCalendar->setFilter(filter); 3248 mCalendar->setFilter(filter);
3244 updateView(); 3249 updateView();
3245 } 3250 }
3246} 3251}
3247 3252
3248void CalendarView::filterEdited() 3253void CalendarView::filterEdited()
3249{ 3254{
3250 mFilterView->updateFilters(); 3255 mFilterView->updateFilters();
3251 updateFilter(); 3256 updateFilter();
3252 writeSettings(); 3257 writeSettings();
3253} 3258}
3254 3259
3255 3260
3256void CalendarView::takeOverEvent() 3261void CalendarView::takeOverEvent()
3257{ 3262{
3258 Incidence *incidence = currentSelection(); 3263 Incidence *incidence = currentSelection();
3259 3264
3260 if (!incidence) return; 3265 if (!incidence) return;
3261 3266
3262 incidence->setOrganizer(KOPrefs::instance()->email()); 3267 incidence->setOrganizer(KOPrefs::instance()->email());
3263 incidence->recreate(); 3268 incidence->recreate();
3264 incidence->setReadOnly(false); 3269 incidence->setReadOnly(false);
3265 3270
3266 updateView(); 3271 updateView();
3267} 3272}
3268 3273
3269void CalendarView::takeOverCalendar() 3274void CalendarView::takeOverCalendar()
3270{ 3275{
3271 // TODO: Create Calendar::allIncidences() function and use it here 3276 // TODO: Create Calendar::allIncidences() function and use it here
3272 3277
3273 QPtrList<Event> events = mCalendar->events(); 3278 QPtrList<Event> events = mCalendar->events();
3274 for(uint i=0; i<events.count(); ++i) { 3279 for(uint i=0; i<events.count(); ++i) {
3275 events.at(i)->setOrganizer(KOPrefs::instance()->email()); 3280 events.at(i)->setOrganizer(KOPrefs::instance()->email());
3276 events.at(i)->recreate(); 3281 events.at(i)->recreate();
3277 events.at(i)->setReadOnly(false); 3282 events.at(i)->setReadOnly(false);
3278 } 3283 }
3279 3284
3280 QPtrList<Todo> todos = mCalendar->todos(); 3285 QPtrList<Todo> todos = mCalendar->todos();
3281 for(uint i=0; i<todos.count(); ++i) { 3286 for(uint i=0; i<todos.count(); ++i) {
3282 todos.at(i)->setOrganizer(KOPrefs::instance()->email()); 3287 todos.at(i)->setOrganizer(KOPrefs::instance()->email());
3283 todos.at(i)->recreate(); 3288 todos.at(i)->recreate();
3284 todos.at(i)->setReadOnly(false); 3289 todos.at(i)->setReadOnly(false);
3285 } 3290 }
3286 3291
3287 QPtrList<Journal> journals = mCalendar->journals(); 3292 QPtrList<Journal> journals = mCalendar->journals();
3288 for(uint i=0; i<journals.count(); ++i) { 3293 for(uint i=0; i<journals.count(); ++i) {
3289 journals.at(i)->setOrganizer(KOPrefs::instance()->email()); 3294 journals.at(i)->setOrganizer(KOPrefs::instance()->email());
3290 journals.at(i)->recreate(); 3295 journals.at(i)->recreate();
3291 journals.at(i)->setReadOnly(false); 3296 journals.at(i)->setReadOnly(false);
3292 } 3297 }
3293 3298
3294 updateView(); 3299 updateView();
3295} 3300}
3296 3301
3297void CalendarView::showIntro() 3302void CalendarView::showIntro()
3298{ 3303{
3299 kdDebug() << "To be implemented." << endl; 3304 kdDebug() << "To be implemented." << endl;
3300} 3305}
3301 3306
3302QWidgetStack *CalendarView::viewStack() 3307QWidgetStack *CalendarView::viewStack()
3303{ 3308{
3304 return mRightFrame; 3309 return mRightFrame;
3305} 3310}
3306 3311
3307QWidget *CalendarView::leftFrame() 3312QWidget *CalendarView::leftFrame()
3308{ 3313{
3309 return mLeftFrame; 3314 return mLeftFrame;
3310} 3315}
3311 3316
3312DateNavigator *CalendarView::dateNavigator() 3317DateNavigator *CalendarView::dateNavigator()
3313{ 3318{
3314 return mNavigator; 3319 return mNavigator;
3315} 3320}
3316 3321
3317KDateNavigator* CalendarView::dateNavigatorWidget() 3322KDateNavigator* CalendarView::dateNavigatorWidget()
3318{ 3323{
3319 return mDateNavigator; 3324 return mDateNavigator;
3320} 3325}
3321void CalendarView::toggleDateNavigatorWidget() 3326void CalendarView::toggleDateNavigatorWidget()
3322{ 3327{
3323 if (mDateNavigator->isVisible()) 3328 if (mDateNavigator->isVisible())
3324 mDateNavigator->hide(); 3329 mDateNavigator->hide();
3325 else 3330 else
3326 mDateNavigator->show(); 3331 mDateNavigator->show();
3327} 3332}
3328void CalendarView::addView(KOrg::BaseView *view) 3333void CalendarView::addView(KOrg::BaseView *view)
3329{ 3334{
3330 mViewManager->addView(view); 3335 mViewManager->addView(view);
3331} 3336}
3332 3337
3333void CalendarView::showView(KOrg::BaseView *view) 3338void CalendarView::showView(KOrg::BaseView *view)
3334{ 3339{
3335 mViewManager->showView(view, mLeftFrame->isVisible()); 3340 mViewManager->showView(view, mLeftFrame->isVisible());
3336} 3341}
3337 3342
3338Incidence *CalendarView::currentSelection() 3343Incidence *CalendarView::currentSelection()
3339{ 3344{
3340 return mViewManager->currentSelection(); 3345 return mViewManager->currentSelection();
3341} 3346}
3342void CalendarView::toggleAllDaySize() 3347void CalendarView::toggleAllDaySize()
3343{ 3348{
3344 /* 3349 /*
3345 if ( KOPrefs::instance()->mAllDaySize > 47 ) 3350 if ( KOPrefs::instance()->mAllDaySize > 47 )
3346 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; 3351 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2;
3347 else 3352 else
3348 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; 3353 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2;
3349 */ 3354 */
3350 viewManager()->agendaView()->toggleAllDay(); 3355 viewManager()->agendaView()->toggleAllDay();
3351} 3356}
3352void CalendarView::toggleExpand() 3357void CalendarView::toggleExpand()
3353{ 3358{
3354 // if ( mLeftFrame->isHidden() ) { 3359 // if ( mLeftFrame->isHidden() ) {
3355 // mLeftFrame->show(); 3360 // mLeftFrame->show();
3356 // emit calendarViewExpanded( false ); 3361 // emit calendarViewExpanded( false );
3357 // } else { 3362 // } else {
3358 // mLeftFrame->hide(); 3363 // mLeftFrame->hide();
3359 // emit calendarViewExpanded( true ); 3364 // emit calendarViewExpanded( true );
3360 // } 3365 // }
3361 3366
3362 globalFlagBlockAgenda = 1; 3367 globalFlagBlockAgenda = 1;
3363 emit calendarViewExpanded( !mLeftFrame->isHidden() ); 3368 emit calendarViewExpanded( !mLeftFrame->isHidden() );
3364 globalFlagBlockAgenda = 5; 3369 globalFlagBlockAgenda = 5;
3365 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); 3370 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() );
3366 //mViewManager->showView( 0, true ); 3371 //mViewManager->showView( 0, true );
3367} 3372}
3368 3373
3369void CalendarView::calendarModified( bool modified, Calendar * ) 3374void CalendarView::calendarModified( bool modified, Calendar * )
3370{ 3375{
3371 setModified( modified ); 3376 setModified( modified );
3372} 3377}
3373 3378
3374Todo *CalendarView::selectedTodo() 3379Todo *CalendarView::selectedTodo()
3375{ 3380{
3376 Incidence *incidence = currentSelection(); 3381 Incidence *incidence = currentSelection();
3377 if ( incidence && incidence->type() == "Todo" ) { 3382 if ( incidence && incidence->type() == "Todo" ) {
3378 return static_cast<Todo *>( incidence ); 3383 return static_cast<Todo *>( incidence );
3379 } 3384 }
3380 3385
3381 incidence = mTodoList->selectedIncidences().first(); 3386 incidence = mTodoList->selectedIncidences().first();
3382 if ( incidence && incidence->type() == "Todo" ) { 3387 if ( incidence && incidence->type() == "Todo" ) {
3383 return static_cast<Todo *>( incidence ); 3388 return static_cast<Todo *>( incidence );
3384 } 3389 }
3385 3390
3386 return 0; 3391 return 0;
3387} 3392}
3388 3393
3389void CalendarView::dialogClosing(Incidence *in) 3394void CalendarView::dialogClosing(Incidence *in)
3390{ 3395{
3391 // mDialogList.remove(in); 3396 // mDialogList.remove(in);
3392} 3397}
3393 3398
3394void CalendarView::showIncidence() 3399void CalendarView::showIncidence()
3395{ 3400{
3396 Incidence *incidence = currentSelection(); 3401 Incidence *incidence = currentSelection();
3397 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3402 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3398 if ( incidence ) { 3403 if ( incidence ) {
3399 ShowIncidenceVisitor v; 3404 ShowIncidenceVisitor v;
3400 v.act( incidence, this ); 3405 v.act( incidence, this );
3401 } 3406 }
3402} 3407}
3403void CalendarView::editIncidenceDescription() 3408void CalendarView::editIncidenceDescription()
3404{ 3409{
3405 mFlagEditDescription = true; 3410 mFlagEditDescription = true;
3406 editIncidence(); 3411 editIncidence();
3407 mFlagEditDescription = false; 3412 mFlagEditDescription = false;
3408} 3413}
3409void CalendarView::editIncidence() 3414void CalendarView::editIncidence()
3410{ 3415{
3411 // qDebug("editIncidence() "); 3416 // qDebug("editIncidence() ");
3412 Incidence *incidence = currentSelection(); 3417 Incidence *incidence = currentSelection();
3413 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3418 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3414 if ( incidence ) { 3419 if ( incidence ) {
3415 EditIncidenceVisitor v; 3420 EditIncidenceVisitor v;
3416 v.act( incidence, this ); 3421 v.act( incidence, this );
3417 } 3422 }
3418} 3423}
3419 3424
3420void CalendarView::deleteIncidence() 3425void CalendarView::deleteIncidence()
3421{ 3426{
3422 Incidence *incidence = currentSelection(); 3427 Incidence *incidence = currentSelection();
3423 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3428 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3424 if ( incidence ) { 3429 if ( incidence ) {
3425 deleteIncidence(incidence); 3430 deleteIncidence(incidence);
3426 } 3431 }
3427} 3432}
3428 3433
3429void CalendarView::showIncidence(Incidence *incidence) 3434void CalendarView::showIncidence(Incidence *incidence)
3430{ 3435{
3431 if ( incidence ) { 3436 if ( incidence ) {
3432 ShowIncidenceVisitor v; 3437 ShowIncidenceVisitor v;
3433 v.act( incidence, this ); 3438 v.act( incidence, this );
3434 } 3439 }
3435} 3440}
3436 3441
3437void CalendarView::editIncidence(Incidence *incidence) 3442void CalendarView::editIncidence(Incidence *incidence)
3438{ 3443{
3439 if ( incidence ) { 3444 if ( incidence ) {
3440 3445
3441 EditIncidenceVisitor v; 3446 EditIncidenceVisitor v;
3442 v.act( incidence, this ); 3447 v.act( incidence, this );
3443 3448
3444 } 3449 }
3445} 3450}
3446 3451
3447void CalendarView::deleteIncidence(Incidence *incidence) 3452void CalendarView::deleteIncidence(Incidence *incidence)
3448{ 3453{
3449 //qDebug(" CalendarView::deleteIncidence "); 3454 //qDebug(" CalendarView::deleteIncidence ");
3450 if ( incidence ) { 3455 if ( incidence ) {
3451 DeleteIncidenceVisitor v; 3456 DeleteIncidenceVisitor v;
3452 v.act( incidence, this ); 3457 v.act( incidence, this );
3453 } 3458 }
3454} 3459}
3455 3460
3456 3461
3457void CalendarView::lookForOutgoingMessages() 3462void CalendarView::lookForOutgoingMessages()
3458{ 3463{
3459 OutgoingDialog *ogd = mDialogManager->outgoingDialog(); 3464 OutgoingDialog *ogd = mDialogManager->outgoingDialog();
3460 ogd->loadMessages(); 3465 ogd->loadMessages();
3461} 3466}
3462 3467
3463void CalendarView::lookForIncomingMessages() 3468void CalendarView::lookForIncomingMessages()
3464{ 3469{
3465 IncomingDialog *icd = mDialogManager->incomingDialog(); 3470 IncomingDialog *icd = mDialogManager->incomingDialog();
3466 icd->retrieve(); 3471 icd->retrieve();
3467} 3472}
3468 3473
3469bool CalendarView::removeCompletedSubTodos( Todo* t ) 3474bool CalendarView::removeCompletedSubTodos( Todo* t )
3470{ 3475{
3471 bool deleteTodo = true; 3476 bool deleteTodo = true;
3472 QPtrList<Incidence> subTodos; 3477 QPtrList<Incidence> subTodos;
3473 Incidence *aTodo; 3478 Incidence *aTodo;
3474 subTodos = t->relations(); 3479 subTodos = t->relations();
3475 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { 3480 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
3476 if (! removeCompletedSubTodos( (Todo*) aTodo )) 3481 if (! removeCompletedSubTodos( (Todo*) aTodo ))
3477 deleteTodo = false; 3482 deleteTodo = false;
3478 } 3483 }
3479 if ( deleteTodo ) { 3484 if ( deleteTodo ) {
3480 if ( t->isCompleted() ) { 3485 if ( t->isCompleted() ) {
3481 checkExternalId( t ); 3486 checkExternalId( t );
3482 mCalendar->deleteTodo( t ); 3487 mCalendar->deleteTodo( t );
3483 changeTodoDisplay( t,KOGlobals::EVENTDELETED ); 3488 changeTodoDisplay( t,KOGlobals::EVENTDELETED );
3484 } 3489 }
3485 else 3490 else
3486 deleteTodo = false; 3491 deleteTodo = false;
3487 } 3492 }
3488 return deleteTodo; 3493 return deleteTodo;
3489 3494
3490} 3495}
3491void CalendarView::purgeCompleted() 3496void CalendarView::purgeCompleted()
3492{ 3497{
3493 int result = KMessageBox::warningContinueCancel(this, 3498 int result = KMessageBox::warningContinueCancel(this,
3494 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); 3499 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge"));
3495 3500
3496 if (result == KMessageBox::Continue) { 3501 if (result == KMessageBox::Continue) {
3497 3502
3498 QPtrList<Todo> todoCal; 3503 QPtrList<Todo> todoCal;
3499 QPtrList<Todo> rootTodos; 3504 QPtrList<Todo> rootTodos;
3500 //QPtrList<Incidence> rel; 3505 //QPtrList<Incidence> rel;
3501 Todo *aTodo;//, *rTodo; 3506 Todo *aTodo;//, *rTodo;
3502 Incidence *rIncidence; 3507 Incidence *rIncidence;
3503 bool childDelete = false; 3508 bool childDelete = false;
3504 bool deletedOne = true; 3509 bool deletedOne = true;
3505 todoCal = calendar()->todos(); 3510 todoCal = calendar()->todos();
3506 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { 3511 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
3507 if ( !aTodo->relatedTo() ) 3512 if ( !aTodo->relatedTo() )
3508 rootTodos.append( aTodo ); 3513 rootTodos.append( aTodo );
3509 } 3514 }
3510 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { 3515 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) {
3511 removeCompletedSubTodos( aTodo ); 3516 removeCompletedSubTodos( aTodo );
3512 } 3517 }
3513 3518
3514 updateView(); 3519 updateView();
3515 } 3520 }
3516} 3521}
3517 3522
3518void CalendarView::slotCalendarChanged() 3523void CalendarView::slotCalendarChanged()
3519{ 3524{
3520 ; 3525 ;
3521} 3526}
3522 3527
3523NavigatorBar *CalendarView::navigatorBar() 3528NavigatorBar *CalendarView::navigatorBar()
3524{ 3529{
3525 return mNavigatorBar; 3530 return mNavigatorBar;
3526} 3531}
3527 3532
3528 3533
3529 3534
3530void CalendarView::keyPressEvent ( QKeyEvent *e) 3535void CalendarView::keyPressEvent ( QKeyEvent *e)
3531{ 3536{
3532 //qDebug(" alendarView::keyPressEvent "); 3537 //qDebug(" alendarView::keyPressEvent ");
3533 e->ignore(); 3538 e->ignore();
3534} 3539}
3535 3540
3536//#include "calendarview.moc" 3541//#include "calendarview.moc"
3537 3542
3538//#include "calendarviewbase.moc" 3543//#include "calendarviewbase.moc"