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