summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-04-06 14:17:54 (UTC)
committer zautrix <zautrix>2005-04-06 14:17:54 (UTC)
commit76e220bf1236ae6afa9d91f18f0cd9ced730cff0 (patch) (unidiff)
treeb34390ceb3f4d55aa5430c2cf0019c344d3293a3 /korganizer
parent03c5656deeec67eefcefb4faa1bfc9a9bc3254ef (diff)
downloadkdepimpi-76e220bf1236ae6afa9d91f18f0cd9ced730cff0.zip
kdepimpi-76e220bf1236ae6afa9d91f18f0cd9ced730cff0.tar.gz
kdepimpi-76e220bf1236ae6afa9d91f18f0cd9ced730cff0.tar.bz2
version and one focus fix
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 00ef145..8512a07 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,4142 +1,4142 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Requires the Qt and KDE widget libraries, available at no cost at 4 Requires the Qt and KDE widget libraries, available at no cost at
5 http://www.troll.no and http://www.kde.org respectively 5 http://www.troll.no and http://www.kde.org respectively
6 6
7 Copyright (c) 1997, 1998, 1999 7 Copyright (c) 1997, 1998, 1999
8 Preston Brown (preston.brown@yale.edu) 8 Preston Brown (preston.brown@yale.edu)
9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) 9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl)
10 Ian Dawes (iadawes@globalserve.net) 10 Ian Dawes (iadawes@globalserve.net)
11 Laszlo Boloni (boloni@cs.purdue.edu) 11 Laszlo Boloni (boloni@cs.purdue.edu)
12 12
13 Copyright (c) 2000, 2001, 2002 13 Copyright (c) 2000, 2001, 2002
14 Cornelius Schumacher <schumacher@kde.org> 14 Cornelius Schumacher <schumacher@kde.org>
15 15
16 This program is free software; you can redistribute it and/or modify 16 This program is free software; you can redistribute it and/or modify
17 it under the terms of the GNU General Public License as published by 17 it under the terms of the GNU General Public License as published by
18 the Free Software Foundation; either version 2 of the License, or 18 the Free Software Foundation; either version 2 of the License, or
19 (at your option) any later version. 19 (at your option) any later version.
20 20
21 This program is distributed in the hope that it will be useful, 21 This program is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of 22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
24 GNU General Public License for more details. 24 GNU General Public License for more details.
25 25
26 You should have received a copy of the GNU General Public License 26 You should have received a copy of the GNU General Public License
27 along with this program; if not, write to the Free Software 27 along with this program; if not, write to the Free Software
28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29*/ 29*/
30 30
31#include <stdlib.h> 31#include <stdlib.h>
32 32
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qradiobutton.h> 34#include <qradiobutton.h>
35#include <qbuttongroup.h> 35#include <qbuttongroup.h>
36#include <qlayout.h> 36#include <qlayout.h>
37#include <qclipboard.h> 37#include <qclipboard.h>
38#include <qcursor.h> 38#include <qcursor.h>
39#include <qmessagebox.h> 39#include <qmessagebox.h>
40#include <qprogressbar.h> 40#include <qprogressbar.h>
41#include <qmultilineedit.h> 41#include <qmultilineedit.h>
42#include <qtimer.h> 42#include <qtimer.h>
43#include <qwidgetstack.h> 43#include <qwidgetstack.h>
44#include <qptrlist.h> 44#include <qptrlist.h>
45#include <qregexp.h> 45#include <qregexp.h>
46#include <qgroupbox.h> 46#include <qgroupbox.h>
47#include <qfile.h> 47#include <qfile.h>
48#include <qdir.h> 48#include <qdir.h>
49#ifndef KORG_NOSPLITTER 49#ifndef KORG_NOSPLITTER
50#include <qsplitter.h> 50#include <qsplitter.h>
51#endif 51#endif
52 52
53#include <kglobal.h> 53#include <kglobal.h>
54#include <kdebug.h> 54#include <kdebug.h>
55#include <kstandarddirs.h> 55#include <kstandarddirs.h>
56#include <kfiledialog.h> 56#include <kfiledialog.h>
57#include <kmessagebox.h> 57#include <kmessagebox.h>
58#include <knotifyclient.h> 58#include <knotifyclient.h>
59#include <kconfig.h> 59#include <kconfig.h>
60 60
61#include <libkdepim/ksyncprefsdialog.h> 61#include <libkdepim/ksyncprefsdialog.h>
62#include <krun.h> 62#include <krun.h>
63#include <kdirwatch.h> 63#include <kdirwatch.h>
64#include <libkdepim/kdatepicker.h> 64#include <libkdepim/kdatepicker.h>
65#include <libkdepim/ksyncprofile.h> 65#include <libkdepim/ksyncprofile.h>
66#include <libkdepim/kpimglobalprefs.h> 66#include <libkdepim/kpimglobalprefs.h>
67 67
68#include <libkcal/vcaldrag.h> 68#include <libkcal/vcaldrag.h>
69#include <libkcal/icaldrag.h> 69#include <libkcal/icaldrag.h>
70#include <libkcal/icalformat.h> 70#include <libkcal/icalformat.h>
71#include <libkcal/vcalformat.h> 71#include <libkcal/vcalformat.h>
72#include <libkcal/scheduler.h> 72#include <libkcal/scheduler.h>
73#include <libkcal/calendarlocal.h> 73#include <libkcal/calendarlocal.h>
74#include <libkcal/journal.h> 74#include <libkcal/journal.h>
75#include <libkcal/calfilter.h> 75#include <libkcal/calfilter.h>
76#include <libkcal/attendee.h> 76#include <libkcal/attendee.h>
77#include <libkcal/dndfactory.h> 77#include <libkcal/dndfactory.h>
78#include <libkcal/freebusy.h> 78#include <libkcal/freebusy.h>
79#include <libkcal/filestorage.h> 79#include <libkcal/filestorage.h>
80#include <libkcal/calendarresources.h> 80#include <libkcal/calendarresources.h>
81#include <libkcal/qtopiaformat.h> 81#include <libkcal/qtopiaformat.h>
82#include "../kalarmd/alarmdialog.h" 82#include "../kalarmd/alarmdialog.h"
83 83
84#ifndef DESKTOP_VERSION 84#ifndef DESKTOP_VERSION
85#include <libkcal/sharpformat.h> 85#include <libkcal/sharpformat.h>
86#include <externalapphandler.h> 86#include <externalapphandler.h>
87#endif 87#endif
88#include <libkcal/phoneformat.h> 88#include <libkcal/phoneformat.h>
89#ifndef KORG_NOMAIL 89#ifndef KORG_NOMAIL
90#include "komailclient.h" 90#include "komailclient.h"
91#endif 91#endif
92#ifndef KORG_NOPRINTER 92#ifndef KORG_NOPRINTER
93#include "calprinter.h" 93#include "calprinter.h"
94#endif 94#endif
95#ifndef KORG_NOPLUGINS 95#ifndef KORG_NOPLUGINS
96#include "kocore.h" 96#include "kocore.h"
97#endif 97#endif
98#include "koeventeditor.h" 98#include "koeventeditor.h"
99#include "kotodoeditor.h" 99#include "kotodoeditor.h"
100#include "koprefs.h" 100#include "koprefs.h"
101#include "koeventviewerdialog.h" 101#include "koeventviewerdialog.h"
102#include "publishdialog.h" 102#include "publishdialog.h"
103#include "kofilterview.h" 103#include "kofilterview.h"
104#include "koglobals.h" 104#include "koglobals.h"
105#include "koviewmanager.h" 105#include "koviewmanager.h"
106#include "koagendaview.h" 106#include "koagendaview.h"
107#include "kodialogmanager.h" 107#include "kodialogmanager.h"
108#include "outgoingdialog.h" 108#include "outgoingdialog.h"
109#include "incomingdialog.h" 109#include "incomingdialog.h"
110#include "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 ( WheelFocus ); 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) mCalendar->close(); 1661 if (!merge) mCalendar->close();
1662 1662
1663 mStorage->setFileName( filename ); 1663 mStorage->setFileName( filename );
1664 1664
1665 if ( mStorage->load() ) { 1665 if ( mStorage->load() ) {
1666 if ( merge ) ;//setModified( true ); 1666 if ( merge ) ;//setModified( true );
1667 else { 1667 else {
1668 //setModified( true ); 1668 //setModified( true );
1669 mViewManager->setDocumentId( filename ); 1669 mViewManager->setDocumentId( filename );
1670 mDialogManager->setDocumentId( filename ); 1670 mDialogManager->setDocumentId( filename );
1671 mTodoList->setDocumentId( filename ); 1671 mTodoList->setDocumentId( filename );
1672 } 1672 }
1673 globalFlagBlockAgenda = 2; 1673 globalFlagBlockAgenda = 2;
1674 // if ( getLastSyncEvent() ) 1674 // if ( getLastSyncEvent() )
1675 // getLastSyncEvent()->setReadOnly( true ); 1675 // getLastSyncEvent()->setReadOnly( true );
1676 mCalendar->reInitAlarmSettings(); 1676 mCalendar->reInitAlarmSettings();
1677 setSyncEventsReadOnly(); 1677 setSyncEventsReadOnly();
1678 updateUnmanagedViews(); 1678 updateUnmanagedViews();
1679 updateView(); 1679 updateView();
1680 if ( filename != MainWindow::defaultFileName() ) { 1680 if ( filename != MainWindow::defaultFileName() ) {
1681 saveCalendar( MainWindow::defaultFileName() ); 1681 saveCalendar( MainWindow::defaultFileName() );
1682 } else { 1682 } else {
1683 QFileInfo finf ( MainWindow::defaultFileName()); 1683 QFileInfo finf ( MainWindow::defaultFileName());
1684 if ( finf.exists() ) { 1684 if ( finf.exists() ) {
1685 setLoadedFileVersion( finf.lastModified () ); 1685 setLoadedFileVersion( finf.lastModified () );
1686 } 1686 }
1687 } 1687 }
1688 return true; 1688 return true;
1689 } else { 1689 } else {
1690 // while failing to load, the calendar object could 1690 // while failing to load, the calendar object could
1691 // have become partially populated. Clear it out. 1691 // have become partially populated. Clear it out.
1692 if ( !merge ) { 1692 if ( !merge ) {
1693 mCalendar->close(); 1693 mCalendar->close();
1694 mViewManager->setDocumentId( filename ); 1694 mViewManager->setDocumentId( filename );
1695 mDialogManager->setDocumentId( filename ); 1695 mDialogManager->setDocumentId( filename );
1696 mTodoList->setDocumentId( filename ); 1696 mTodoList->setDocumentId( filename );
1697 } 1697 }
1698 1698
1699 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1699 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1700 1700
1701 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 1701 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
1702 globalFlagBlockAgenda = 2; 1702 globalFlagBlockAgenda = 2;
1703 mCalendar->reInitAlarmSettings(); 1703 mCalendar->reInitAlarmSettings();
1704 setSyncEventsReadOnly(); 1704 setSyncEventsReadOnly();
1705 updateUnmanagedViews(); 1705 updateUnmanagedViews();
1706 updateView(); 1706 updateView();
1707 } 1707 }
1708 return false; 1708 return false;
1709} 1709}
1710void CalendarView::showOpenError() 1710void CalendarView::showOpenError()
1711{ 1711{
1712 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 1712 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
1713} 1713}
1714void CalendarView::setLoadedFileVersion(QDateTime dt) 1714void CalendarView::setLoadedFileVersion(QDateTime dt)
1715{ 1715{
1716 loadedFileVersion = dt; 1716 loadedFileVersion = dt;
1717} 1717}
1718bool CalendarView::checkFileChanged(QString fn) 1718bool CalendarView::checkFileChanged(QString fn)
1719{ 1719{
1720 QFileInfo finf ( fn ); 1720 QFileInfo finf ( fn );
1721 if ( !finf.exists() ) 1721 if ( !finf.exists() )
1722 return true; 1722 return true;
1723 QDateTime dt = finf.lastModified (); 1723 QDateTime dt = finf.lastModified ();
1724 if ( dt <= loadedFileVersion ) 1724 if ( dt <= loadedFileVersion )
1725 return false; 1725 return false;
1726 return true; 1726 return true;
1727 1727
1728} 1728}
1729void CalendarView::watchSavedFile() 1729void CalendarView::watchSavedFile()
1730{ 1730{
1731 QFileInfo finf ( MainWindow::defaultFileName()); 1731 QFileInfo finf ( MainWindow::defaultFileName());
1732 if ( !finf.exists() ) 1732 if ( !finf.exists() )
1733 return; 1733 return;
1734 QDateTime dt = finf.lastModified (); 1734 QDateTime dt = finf.lastModified ();
1735 if ( dt < loadedFileVersion ) { 1735 if ( dt < loadedFileVersion ) {
1736 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 1736 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
1737 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 1737 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1738 return; 1738 return;
1739 } 1739 }
1740 loadedFileVersion = dt; 1740 loadedFileVersion = dt;
1741} 1741}
1742 1742
1743bool CalendarView::checkFileVersion(QString fn) 1743bool CalendarView::checkFileVersion(QString fn)
1744{ 1744{
1745 QFileInfo finf ( fn ); 1745 QFileInfo finf ( fn );
1746 if ( !finf.exists() ) 1746 if ( !finf.exists() )
1747 return true; 1747 return true;
1748 QDateTime dt = finf.lastModified (); 1748 QDateTime dt = finf.lastModified ();
1749 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1749 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1750 //qDebug("file on disk version %s",dt.toString().latin1()); 1750 //qDebug("file on disk version %s",dt.toString().latin1());
1751 if ( dt <= loadedFileVersion ) 1751 if ( dt <= loadedFileVersion )
1752 return true; 1752 return true;
1753 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)) , 1753 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)) ,
1754 i18n("KO/Pi Warning"),i18n("Overwrite"), 1754 i18n("KO/Pi Warning"),i18n("Overwrite"),
1755 i18n("Sync+save")); 1755 i18n("Sync+save"));
1756 1756
1757 if ( km == KMessageBox::Cancel ) 1757 if ( km == KMessageBox::Cancel )
1758 return false; 1758 return false;
1759 if ( km == KMessageBox::Yes ) 1759 if ( km == KMessageBox::Yes )
1760 return true; 1760 return true;
1761 1761
1762 setSyncDevice("deleteaftersync" ); 1762 setSyncDevice("deleteaftersync" );
1763 mSyncManager->mAskForPreferences = true; 1763 mSyncManager->mAskForPreferences = true;
1764 mSyncManager->mSyncAlgoPrefs = 3; 1764 mSyncManager->mSyncAlgoPrefs = 3;
1765 mSyncManager->mWriteBackFile = false; 1765 mSyncManager->mWriteBackFile = false;
1766 mSyncManager->mWriteBackExistingOnly = false; 1766 mSyncManager->mWriteBackExistingOnly = false;
1767 mSyncManager->mShowSyncSummary = false; 1767 mSyncManager->mShowSyncSummary = false;
1768 syncCalendar( fn, 3 ); 1768 syncCalendar( fn, 3 );
1769 Event * e = getLastSyncEvent(); 1769 Event * e = getLastSyncEvent();
1770 mCalendar->deleteEvent ( e ); 1770 mCalendar->deleteEvent ( e );
1771 updateView(); 1771 updateView();
1772 return true; 1772 return true;
1773} 1773}
1774 1774
1775bool CalendarView::saveCalendar( QString filename ) 1775bool CalendarView::saveCalendar( QString filename )
1776{ 1776{
1777 1777
1778 // Store back all unsaved data into calendar object 1778 // Store back all unsaved data into calendar object
1779 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1779 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1780 if ( mViewManager->currentView() ) 1780 if ( mViewManager->currentView() )
1781 mViewManager->currentView()->flushView(); 1781 mViewManager->currentView()->flushView();
1782 1782
1783 1783
1784 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 1784 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
1785 mStorage->setSaveFormat( new ICalFormat() ); 1785 mStorage->setSaveFormat( new ICalFormat() );
1786 mStorage->setFileName( filename ); 1786 mStorage->setFileName( filename );
1787 bool success; 1787 bool success;
1788 success = mStorage->save(); 1788 success = mStorage->save();
1789 if ( !success ) { 1789 if ( !success ) {
1790 return false; 1790 return false;
1791 } 1791 }
1792 if ( filename == MainWindow::defaultFileName() ) { 1792 if ( filename == MainWindow::defaultFileName() ) {
1793 setLoadedFileVersion( lfv ); 1793 setLoadedFileVersion( lfv );
1794 watchSavedFile(); 1794 watchSavedFile();
1795 } 1795 }
1796 return true; 1796 return true;
1797} 1797}
1798 1798
1799void CalendarView::closeCalendar() 1799void CalendarView::closeCalendar()
1800{ 1800{
1801 1801
1802 // child windows no longer valid 1802 // child windows no longer valid
1803 emit closingDown(); 1803 emit closingDown();
1804 1804
1805 mCalendar->close(); 1805 mCalendar->close();
1806 setModified(false); 1806 setModified(false);
1807 updateView(); 1807 updateView();
1808} 1808}
1809 1809
1810void CalendarView::archiveCalendar() 1810void CalendarView::archiveCalendar()
1811{ 1811{
1812 mDialogManager->showArchiveDialog(); 1812 mDialogManager->showArchiveDialog();
1813} 1813}
1814 1814
1815 1815
1816void CalendarView::readSettings() 1816void CalendarView::readSettings()
1817{ 1817{
1818 1818
1819 1819
1820 // mViewManager->showAgendaView(); 1820 // mViewManager->showAgendaView();
1821 QString str; 1821 QString str;
1822 //qDebug("CalendarView::readSettings() "); 1822 //qDebug("CalendarView::readSettings() ");
1823 // read settings from the KConfig, supplying reasonable 1823 // read settings from the KConfig, supplying reasonable
1824 // defaults where none are to be found 1824 // defaults where none are to be found
1825 KConfig *config = KOGlobals::config(); 1825 KConfig *config = KOGlobals::config();
1826#ifndef KORG_NOSPLITTER 1826#ifndef KORG_NOSPLITTER
1827 config->setGroup("KOrganizer Geometry"); 1827 config->setGroup("KOrganizer Geometry");
1828 1828
1829 QValueList<int> sizes = config->readIntListEntry("Separator1"); 1829 QValueList<int> sizes = config->readIntListEntry("Separator1");
1830 if (sizes.count() != 2) { 1830 if (sizes.count() != 2) {
1831 sizes << mDateNavigator->minimumSizeHint().width(); 1831 sizes << mDateNavigator->minimumSizeHint().width();
1832 sizes << 300; 1832 sizes << 300;
1833 } 1833 }
1834 mPanner->setSizes(sizes); 1834 mPanner->setSizes(sizes);
1835 1835
1836 sizes = config->readIntListEntry("Separator2"); 1836 sizes = config->readIntListEntry("Separator2");
1837 if ( ( mResourceView && sizes.count() == 4 ) || 1837 if ( ( mResourceView && sizes.count() == 4 ) ||
1838 ( !mResourceView && sizes.count() == 3 ) ) { 1838 ( !mResourceView && sizes.count() == 3 ) ) {
1839 mLeftSplitter->setSizes(sizes); 1839 mLeftSplitter->setSizes(sizes);
1840 } 1840 }
1841#endif 1841#endif
1842 globalFlagBlockAgenda = 1; 1842 globalFlagBlockAgenda = 1;
1843 mViewManager->showAgendaView(); 1843 mViewManager->showAgendaView();
1844 //mViewManager->readSettings( config ); 1844 //mViewManager->readSettings( config );
1845 mTodoList->restoreLayout(config,QString("Todo Layout")); 1845 mTodoList->restoreLayout(config,QString("Todo Layout"));
1846 readFilterSettings(config); 1846 readFilterSettings(config);
1847 1847
1848#ifdef DESKTOP_VERSION 1848#ifdef DESKTOP_VERSION
1849 config->setGroup("WidgetLayout"); 1849 config->setGroup("WidgetLayout");
1850 QStringList list; 1850 QStringList list;
1851 list = config->readListEntry("MainLayout"); 1851 list = config->readListEntry("MainLayout");
1852 int x,y,w,h; 1852 int x,y,w,h;
1853 if ( ! list.isEmpty() ) { 1853 if ( ! list.isEmpty() ) {
1854 x = list[0].toInt(); 1854 x = list[0].toInt();
1855 y = list[1].toInt(); 1855 y = list[1].toInt();
1856 w = list[2].toInt(); 1856 w = list[2].toInt();
1857 h = list[3].toInt(); 1857 h = list[3].toInt();
1858 KApplication::testCoords( &x,&y,&w,&h ); 1858 KApplication::testCoords( &x,&y,&w,&h );
1859 topLevelWidget()->setGeometry(x,y,w,h); 1859 topLevelWidget()->setGeometry(x,y,w,h);
1860 1860
1861 } else { 1861 } else {
1862 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 1862 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
1863 } 1863 }
1864 list = config->readListEntry("EditEventLayout"); 1864 list = config->readListEntry("EditEventLayout");
1865 if ( ! list.isEmpty() ) { 1865 if ( ! list.isEmpty() ) {
1866 x = list[0].toInt(); 1866 x = list[0].toInt();
1867 y = list[1].toInt(); 1867 y = list[1].toInt();
1868 w = list[2].toInt(); 1868 w = list[2].toInt();
1869 h = list[3].toInt(); 1869 h = list[3].toInt();
1870 KApplication::testCoords( &x,&y,&w,&h ); 1870 KApplication::testCoords( &x,&y,&w,&h );
1871 mEventEditor->setGeometry(x,y,w,h); 1871 mEventEditor->setGeometry(x,y,w,h);
1872 1872
1873 } 1873 }
1874 list = config->readListEntry("EditTodoLayout"); 1874 list = config->readListEntry("EditTodoLayout");
1875 if ( ! list.isEmpty() ) { 1875 if ( ! list.isEmpty() ) {
1876 x = list[0].toInt(); 1876 x = list[0].toInt();
1877 y = list[1].toInt(); 1877 y = list[1].toInt();
1878 w = list[2].toInt(); 1878 w = list[2].toInt();
1879 h = list[3].toInt(); 1879 h = list[3].toInt();
1880 KApplication::testCoords( &x,&y,&w,&h ); 1880 KApplication::testCoords( &x,&y,&w,&h );
1881 mTodoEditor->setGeometry(x,y,w,h); 1881 mTodoEditor->setGeometry(x,y,w,h);
1882 1882
1883 } 1883 }
1884 list = config->readListEntry("ViewerLayout"); 1884 list = config->readListEntry("ViewerLayout");
1885 if ( ! list.isEmpty() ) { 1885 if ( ! list.isEmpty() ) {
1886 x = list[0].toInt(); 1886 x = list[0].toInt();
1887 y = list[1].toInt(); 1887 y = list[1].toInt();
1888 w = list[2].toInt(); 1888 w = list[2].toInt();
1889 h = list[3].toInt(); 1889 h = list[3].toInt();
1890 KApplication::testCoords( &x,&y,&w,&h ); 1890 KApplication::testCoords( &x,&y,&w,&h );
1891 getEventViewerDialog()->setGeometry(x,y,w,h); 1891 getEventViewerDialog()->setGeometry(x,y,w,h);
1892 } 1892 }
1893#endif 1893#endif
1894 config->setGroup( "Views" ); 1894 config->setGroup( "Views" );
1895 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 1895 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
1896 1896
1897 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); 1897 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame");
1898 1898
1899 int resetval = 0; 1899 int resetval = 0;
1900 int maxVal = 0; 1900 int maxVal = 0;
1901 if (sizes.count() != 3) { 1901 if (sizes.count() != 3) {
1902 if ( KOPrefs::instance()->mVerticalScreen ) { 1902 if ( KOPrefs::instance()->mVerticalScreen ) {
1903 resetval = mDateNavigator->sizeHint().width()+2; 1903 resetval = mDateNavigator->sizeHint().width()+2;
1904 } else { 1904 } else {
1905 resetval = mDateNavigator->sizeHint().height()+2; 1905 resetval = mDateNavigator->sizeHint().height()+2;
1906 } 1906 }
1907 } 1907 }
1908 if ( resetval ) { 1908 if ( resetval ) {
1909 sizes.clear(); 1909 sizes.clear();
1910 if ( KOPrefs::instance()->mVerticalScreen ) { 1910 if ( KOPrefs::instance()->mVerticalScreen ) {
1911 maxVal = QApplication::desktop()->width() -10; 1911 maxVal = QApplication::desktop()->width() -10;
1912 } else { 1912 } else {
1913 maxVal = QApplication::desktop()->height()-10; 1913 maxVal = QApplication::desktop()->height()-10;
1914 } 1914 }
1915 sizes << resetval; 1915 sizes << resetval;
1916 if ( maxVal < resetval + resetval) 1916 if ( maxVal < resetval + resetval)
1917 resetval = maxVal - resetval; 1917 resetval = maxVal - resetval;
1918 sizes << resetval; 1918 sizes << resetval;
1919 sizes << 100; 1919 sizes << 100;
1920 } 1920 }
1921 mLeftFrame->setSizes(sizes); 1921 mLeftFrame->setSizes(sizes);
1922 sizes = config->readIntListEntry("Main Splitter Frame"); 1922 sizes = config->readIntListEntry("Main Splitter Frame");
1923 resetval = 0; 1923 resetval = 0;
1924 maxVal = 0; 1924 maxVal = 0;
1925 if (sizes.count() != 2) { 1925 if (sizes.count() != 2) {
1926 if ( !KOPrefs::instance()->mVerticalScreen ) { 1926 if ( !KOPrefs::instance()->mVerticalScreen ) {
1927 resetval = mDateNavigator->sizeHint().width()+2; 1927 resetval = mDateNavigator->sizeHint().width()+2;
1928 } else { 1928 } else {
1929 resetval = mDateNavigator->sizeHint().height()+2; 1929 resetval = mDateNavigator->sizeHint().height()+2;
1930 } 1930 }
1931 } 1931 }
1932 if ( resetval ) { 1932 if ( resetval ) {
1933 sizes.clear(); 1933 sizes.clear();
1934 if ( !KOPrefs::instance()->mVerticalScreen ) { 1934 if ( !KOPrefs::instance()->mVerticalScreen ) {
1935 maxVal = QApplication::desktop()->width() -10; 1935 maxVal = QApplication::desktop()->width() -10;
1936 } else { 1936 } else {
1937 maxVal = QApplication::desktop()->height()-10; 1937 maxVal = QApplication::desktop()->height()-10;
1938 } 1938 }
1939 sizes << resetval; 1939 sizes << resetval;
1940 if ( maxVal < resetval + resetval) 1940 if ( maxVal < resetval + resetval)
1941 resetval = maxVal - resetval; 1941 resetval = maxVal - resetval;
1942 sizes << resetval; 1942 sizes << resetval;
1943 } 1943 }
1944 mMainFrame->setSizes(sizes); 1944 mMainFrame->setSizes(sizes);
1945 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 1945 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
1946 else if ( dateCount == 7 ) mNavigator->selectWeek(); 1946 else if ( dateCount == 7 ) mNavigator->selectWeek();
1947 else mNavigator->selectDates( dateCount ); 1947 else mNavigator->selectDates( dateCount );
1948 // mViewManager->readSettings( config ); 1948 // mViewManager->readSettings( config );
1949 updateConfig(); 1949 updateConfig();
1950 globalFlagBlockAgenda = 2; 1950 globalFlagBlockAgenda = 2;
1951 mViewManager->readSettings( config ); 1951 mViewManager->readSettings( config );
1952 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); 1952 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) );
1953} 1953}
1954 1954
1955 1955
1956void CalendarView::writeSettings() 1956void CalendarView::writeSettings()
1957{ 1957{
1958 // kdDebug() << "CalendarView::writeSettings" << endl; 1958 // kdDebug() << "CalendarView::writeSettings" << endl;
1959 1959
1960 KConfig *config = KOGlobals::config(); 1960 KConfig *config = KOGlobals::config();
1961 1961
1962 mViewManager->writeSettings( config ); 1962 mViewManager->writeSettings( config );
1963 mTodoList->saveLayout(config,QString("Todo Layout")); 1963 mTodoList->saveLayout(config,QString("Todo Layout"));
1964 mDialogManager->writeSettings( config ); 1964 mDialogManager->writeSettings( config );
1965 //KOPrefs::instance()->usrWriteConfig(); 1965 //KOPrefs::instance()->usrWriteConfig();
1966 KOPrefs::instance()->writeConfig(); 1966 KOPrefs::instance()->writeConfig();
1967 1967
1968 writeFilterSettings(config); 1968 writeFilterSettings(config);
1969 1969
1970 config->setGroup( "Views" ); 1970 config->setGroup( "Views" );
1971 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 1971 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
1972 1972
1973 QValueList<int> listINT = mLeftFrame->sizes(); 1973 QValueList<int> listINT = mLeftFrame->sizes();
1974 config->writeEntry("Left Splitter Frame",listINT); 1974 config->writeEntry("Left Splitter Frame",listINT);
1975 QValueList<int> listINT2 = mMainFrame->sizes(); 1975 QValueList<int> listINT2 = mMainFrame->sizes();
1976 config->writeEntry("Main Splitter Frame",listINT2); 1976 config->writeEntry("Main Splitter Frame",listINT2);
1977#ifdef DESKTOP_VERSION 1977#ifdef DESKTOP_VERSION
1978 config->setGroup("WidgetLayout"); 1978 config->setGroup("WidgetLayout");
1979 QStringList list ;//= config->readListEntry("MainLayout"); 1979 QStringList list ;//= config->readListEntry("MainLayout");
1980 int x,y,w,h; 1980 int x,y,w,h;
1981 QWidget* wid; 1981 QWidget* wid;
1982 wid = topLevelWidget(); 1982 wid = topLevelWidget();
1983 x = wid->geometry().x(); 1983 x = wid->geometry().x();
1984 y = wid->geometry().y(); 1984 y = wid->geometry().y();
1985 w = wid->width(); 1985 w = wid->width();
1986 h = wid->height(); 1986 h = wid->height();
1987 list.clear(); 1987 list.clear();
1988 list << QString::number( x ); 1988 list << QString::number( x );
1989 list << QString::number( y ); 1989 list << QString::number( y );
1990 list << QString::number( w ); 1990 list << QString::number( w );
1991 list << QString::number( h ); 1991 list << QString::number( h );
1992 config->writeEntry("MainLayout",list ); 1992 config->writeEntry("MainLayout",list );
1993 1993
1994 wid = mEventEditor; 1994 wid = mEventEditor;
1995 x = wid->geometry().x(); 1995 x = wid->geometry().x();
1996 y = wid->geometry().y(); 1996 y = wid->geometry().y();
1997 w = wid->width(); 1997 w = wid->width();
1998 h = wid->height(); 1998 h = wid->height();
1999 list.clear(); 1999 list.clear();
2000 list << QString::number( x ); 2000 list << QString::number( x );
2001 list << QString::number( y ); 2001 list << QString::number( y );
2002 list << QString::number( w ); 2002 list << QString::number( w );
2003 list << QString::number( h ); 2003 list << QString::number( h );
2004 config->writeEntry("EditEventLayout",list ); 2004 config->writeEntry("EditEventLayout",list );
2005 2005
2006 wid = mTodoEditor; 2006 wid = mTodoEditor;
2007 x = wid->geometry().x(); 2007 x = wid->geometry().x();
2008 y = wid->geometry().y(); 2008 y = wid->geometry().y();
2009 w = wid->width(); 2009 w = wid->width();
2010 h = wid->height(); 2010 h = wid->height();
2011 list.clear(); 2011 list.clear();
2012 list << QString::number( x ); 2012 list << QString::number( x );
2013 list << QString::number( y ); 2013 list << QString::number( y );
2014 list << QString::number( w ); 2014 list << QString::number( w );
2015 list << QString::number( h ); 2015 list << QString::number( h );
2016 config->writeEntry("EditTodoLayout",list ); 2016 config->writeEntry("EditTodoLayout",list );
2017 wid = getEventViewerDialog(); 2017 wid = getEventViewerDialog();
2018 x = wid->geometry().x(); 2018 x = wid->geometry().x();
2019 y = wid->geometry().y(); 2019 y = wid->geometry().y();
2020 w = wid->width(); 2020 w = wid->width();
2021 h = wid->height(); 2021 h = wid->height();
2022 list.clear(); 2022 list.clear();
2023 list << QString::number( x ); 2023 list << QString::number( x );
2024 list << QString::number( y ); 2024 list << QString::number( y );
2025 list << QString::number( w ); 2025 list << QString::number( w );
2026 list << QString::number( h ); 2026 list << QString::number( h );
2027 config->writeEntry("ViewerLayout",list ); 2027 config->writeEntry("ViewerLayout",list );
2028 wid = mDialogManager->getSearchDialog(); 2028 wid = mDialogManager->getSearchDialog();
2029 if ( wid ) { 2029 if ( wid ) {
2030 x = wid->geometry().x(); 2030 x = wid->geometry().x();
2031 y = wid->geometry().y(); 2031 y = wid->geometry().y();
2032 w = wid->width(); 2032 w = wid->width();
2033 h = wid->height(); 2033 h = wid->height();
2034 list.clear(); 2034 list.clear();
2035 list << QString::number( x ); 2035 list << QString::number( x );
2036 list << QString::number( y ); 2036 list << QString::number( y );
2037 list << QString::number( w ); 2037 list << QString::number( w );
2038 list << QString::number( h ); 2038 list << QString::number( h );
2039 config->writeEntry("SearchLayout",list ); 2039 config->writeEntry("SearchLayout",list );
2040 } 2040 }
2041#endif 2041#endif
2042 2042
2043 2043
2044 config->sync(); 2044 config->sync();
2045} 2045}
2046 2046
2047void CalendarView::readFilterSettings(KConfig *config) 2047void CalendarView::readFilterSettings(KConfig *config)
2048{ 2048{
2049 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 2049 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
2050 2050
2051 mFilters.clear(); 2051 mFilters.clear();
2052 2052
2053 config->setGroup("General"); 2053 config->setGroup("General");
2054 QStringList filterList = config->readListEntry("CalendarFilters"); 2054 QStringList filterList = config->readListEntry("CalendarFilters");
2055 2055
2056 QStringList::ConstIterator it = filterList.begin(); 2056 QStringList::ConstIterator it = filterList.begin();
2057 QStringList::ConstIterator end = filterList.end(); 2057 QStringList::ConstIterator end = filterList.end();
2058 while(it != end) { 2058 while(it != end) {
2059 // kdDebug() << " filter: " << (*it) << endl; 2059 // kdDebug() << " filter: " << (*it) << endl;
2060 2060
2061 CalFilter *filter; 2061 CalFilter *filter;
2062 filter = new CalFilter(*it); 2062 filter = new CalFilter(*it);
2063 config->setGroup("Filter_" + (*it).utf8()); 2063 config->setGroup("Filter_" + (*it).utf8());
2064 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 2064 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
2065 filter->setCriteria(config->readNumEntry("Criteria",0)); 2065 filter->setCriteria(config->readNumEntry("Criteria",0));
2066 filter->setCategoryList(config->readListEntry("CategoryList")); 2066 filter->setCategoryList(config->readListEntry("CategoryList"));
2067 mFilters.append(filter); 2067 mFilters.append(filter);
2068 2068
2069 ++it; 2069 ++it;
2070 } 2070 }
2071 2071
2072 if (mFilters.count() == 0) { 2072 if (mFilters.count() == 0) {
2073 CalFilter *filter = new CalFilter(i18n("Default")); 2073 CalFilter *filter = new CalFilter(i18n("Default"));
2074 mFilters.append(filter); 2074 mFilters.append(filter);
2075 } 2075 }
2076 mFilterView->updateFilters(); 2076 mFilterView->updateFilters();
2077 config->setGroup("FilterView"); 2077 config->setGroup("FilterView");
2078 2078
2079 mFilterView->blockSignals(true); 2079 mFilterView->blockSignals(true);
2080 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 2080 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
2081 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 2081 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
2082 mFilterView->blockSignals(false); 2082 mFilterView->blockSignals(false);
2083 // We do it manually to avoid it being done twice by the above calls 2083 // We do it manually to avoid it being done twice by the above calls
2084 updateFilter(); 2084 updateFilter();
2085} 2085}
2086 2086
2087void CalendarView::writeFilterSettings(KConfig *config) 2087void CalendarView::writeFilterSettings(KConfig *config)
2088{ 2088{
2089 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 2089 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
2090 2090
2091 QStringList filterList; 2091 QStringList filterList;
2092 2092
2093 CalFilter *filter = mFilters.first(); 2093 CalFilter *filter = mFilters.first();
2094 while(filter) { 2094 while(filter) {
2095 // kdDebug() << " fn: " << filter->name() << endl; 2095 // kdDebug() << " fn: " << filter->name() << endl;
2096 filterList << filter->name(); 2096 filterList << filter->name();
2097 config->setGroup("Filter_" + filter->name().utf8()); 2097 config->setGroup("Filter_" + filter->name().utf8());
2098 config->writeEntry("Criteria",filter->criteria()); 2098 config->writeEntry("Criteria",filter->criteria());
2099 config->writeEntry("CategoryList",filter->categoryList()); 2099 config->writeEntry("CategoryList",filter->categoryList());
2100 filter = mFilters.next(); 2100 filter = mFilters.next();
2101 } 2101 }
2102 config->setGroup("General"); 2102 config->setGroup("General");
2103 config->writeEntry("CalendarFilters",filterList); 2103 config->writeEntry("CalendarFilters",filterList);
2104 2104
2105 config->setGroup("FilterView"); 2105 config->setGroup("FilterView");
2106 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 2106 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
2107 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 2107 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
2108} 2108}
2109 2109
2110 2110
2111void CalendarView::goToday() 2111void CalendarView::goToday()
2112{ 2112{
2113 if ( mViewManager->currentView()->isMonthView() ) 2113 if ( mViewManager->currentView()->isMonthView() )
2114 mNavigator->selectTodayMonth(); 2114 mNavigator->selectTodayMonth();
2115 else 2115 else
2116 mNavigator->selectToday(); 2116 mNavigator->selectToday();
2117} 2117}
2118 2118
2119void CalendarView::goNext() 2119void CalendarView::goNext()
2120{ 2120{
2121 mNavigator->selectNext(); 2121 mNavigator->selectNext();
2122} 2122}
2123 2123
2124void CalendarView::goPrevious() 2124void CalendarView::goPrevious()
2125{ 2125{
2126 mNavigator->selectPrevious(); 2126 mNavigator->selectPrevious();
2127} 2127}
2128void CalendarView::goNextMonth() 2128void CalendarView::goNextMonth()
2129{ 2129{
2130 mNavigator->selectNextMonth(); 2130 mNavigator->selectNextMonth();
2131} 2131}
2132 2132
2133void CalendarView::goPreviousMonth() 2133void CalendarView::goPreviousMonth()
2134{ 2134{
2135 mNavigator->selectPreviousMonth(); 2135 mNavigator->selectPreviousMonth();
2136} 2136}
2137void CalendarView::writeLocale() 2137void CalendarView::writeLocale()
2138{ 2138{
2139 //KPimGlobalPrefs::instance()->setGlobalConfig(); 2139 //KPimGlobalPrefs::instance()->setGlobalConfig();
2140#if 0 2140#if 0
2141 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); 2141 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime );
2142 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); 2142 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday );
2143 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); 2143 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate );
2144 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); 2144 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage );
2145 QString dummy = KOPrefs::instance()->mUserDateFormatLong; 2145 QString dummy = KOPrefs::instance()->mUserDateFormatLong;
2146 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 2146 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
2147 dummy = KOPrefs::instance()->mUserDateFormatShort; 2147 dummy = KOPrefs::instance()->mUserDateFormatShort;
2148 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 2148 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
2149 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, 2149 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving,
2150 KOPrefs::instance()->mDaylightsavingStart, 2150 KOPrefs::instance()->mDaylightsavingStart,
2151 KOPrefs::instance()->mDaylightsavingEnd ); 2151 KOPrefs::instance()->mDaylightsavingEnd );
2152 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); 2152 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId );
2153#endif 2153#endif
2154} 2154}
2155void CalendarView::updateConfig() 2155void CalendarView::updateConfig()
2156{ 2156{
2157 writeLocale(); 2157 writeLocale();
2158 if ( KOPrefs::instance()->mUseAppColors ) 2158 if ( KOPrefs::instance()->mUseAppColors )
2159 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 2159 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
2160 emit configChanged(); 2160 emit configChanged();
2161 mTodoList->updateConfig(); 2161 mTodoList->updateConfig();
2162 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 2162 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
2163 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2163 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2164 // To make the "fill window" configurations work 2164 // To make the "fill window" configurations work
2165 //mViewManager->raiseCurrentView(); 2165 //mViewManager->raiseCurrentView();
2166} 2166}
2167 2167
2168 2168
2169void CalendarView::eventChanged(Event *event) 2169void CalendarView::eventChanged(Event *event)
2170{ 2170{
2171 changeEventDisplay(event,KOGlobals::EVENTEDITED); 2171 changeEventDisplay(event,KOGlobals::EVENTEDITED);
2172 //updateUnmanagedViews(); 2172 //updateUnmanagedViews();
2173} 2173}
2174 2174
2175void CalendarView::eventAdded(Event *event) 2175void CalendarView::eventAdded(Event *event)
2176{ 2176{
2177 changeEventDisplay(event,KOGlobals::EVENTADDED); 2177 changeEventDisplay(event,KOGlobals::EVENTADDED);
2178} 2178}
2179 2179
2180void CalendarView::eventToBeDeleted(Event *) 2180void CalendarView::eventToBeDeleted(Event *)
2181{ 2181{
2182 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 2182 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
2183} 2183}
2184 2184
2185void CalendarView::eventDeleted() 2185void CalendarView::eventDeleted()
2186{ 2186{
2187 changeEventDisplay(0,KOGlobals::EVENTDELETED); 2187 changeEventDisplay(0,KOGlobals::EVENTDELETED);
2188} 2188}
2189void CalendarView::changeTodoDisplay(Todo *which, int action) 2189void CalendarView::changeTodoDisplay(Todo *which, int action)
2190{ 2190{
2191 changeIncidenceDisplay((Incidence *)which, action); 2191 changeIncidenceDisplay((Incidence *)which, action);
2192 mDateNavigator->updateView(); //LR 2192 mDateNavigator->updateView(); //LR
2193 //mDialogManager->updateSearchDialog(); 2193 //mDialogManager->updateSearchDialog();
2194 2194
2195 if (which) { 2195 if (which) {
2196 mViewManager->updateWNview(); 2196 mViewManager->updateWNview();
2197 //mTodoList->updateView(); 2197 //mTodoList->updateView();
2198 } 2198 }
2199 2199
2200} 2200}
2201 2201
2202void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 2202void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
2203{ 2203{
2204 updateUnmanagedViews(); 2204 updateUnmanagedViews();
2205 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 2205 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
2206 if ( action == KOGlobals::EVENTDELETED ) { //delete 2206 if ( action == KOGlobals::EVENTDELETED ) { //delete
2207 mCalendar->checkAlarmForIncidence( 0, true ); 2207 mCalendar->checkAlarmForIncidence( 0, true );
2208 if ( mEventViewerDialog ) 2208 if ( mEventViewerDialog )
2209 mEventViewerDialog->hide(); 2209 mEventViewerDialog->hide();
2210 } 2210 }
2211 else 2211 else
2212 mCalendar->checkAlarmForIncidence( which , false ); 2212 mCalendar->checkAlarmForIncidence( which , false );
2213} 2213}
2214 2214
2215// most of the changeEventDisplays() right now just call the view's 2215// most of the changeEventDisplays() right now just call the view's
2216// total update mode, but they SHOULD be recoded to be more refresh-efficient. 2216// total update mode, but they SHOULD be recoded to be more refresh-efficient.
2217void CalendarView::changeEventDisplay(Event *which, int action) 2217void CalendarView::changeEventDisplay(Event *which, int action)
2218{ 2218{
2219 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 2219 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
2220 changeIncidenceDisplay((Incidence *)which, action); 2220 changeIncidenceDisplay((Incidence *)which, action);
2221 mDateNavigator->updateView(); 2221 mDateNavigator->updateView();
2222 //mDialogManager->updateSearchDialog(); 2222 //mDialogManager->updateSearchDialog();
2223 2223
2224 if (which) { 2224 if (which) {
2225 // If there is an event view visible update the display 2225 // If there is an event view visible update the display
2226 mViewManager->currentView()->changeEventDisplay(which,action); 2226 mViewManager->currentView()->changeEventDisplay(which,action);
2227 // TODO: check, if update needed 2227 // TODO: check, if update needed
2228 // if (which->getTodoStatus()) { 2228 // if (which->getTodoStatus()) {
2229 mTodoList->updateView(); 2229 mTodoList->updateView();
2230 // } 2230 // }
2231 } else { 2231 } else {
2232 mViewManager->currentView()->updateView(); 2232 mViewManager->currentView()->updateView();
2233 } 2233 }
2234} 2234}
2235 2235
2236 2236
2237void CalendarView::updateTodoViews() 2237void CalendarView::updateTodoViews()
2238{ 2238{
2239 mTodoList->updateView(); 2239 mTodoList->updateView();
2240 mViewManager->currentView()->updateView(); 2240 mViewManager->currentView()->updateView();
2241 2241
2242} 2242}
2243 2243
2244 2244
2245void CalendarView::updateView(const QDate &start, const QDate &end) 2245void CalendarView::updateView(const QDate &start, const QDate &end)
2246{ 2246{
2247 mTodoList->updateView(); 2247 mTodoList->updateView();
2248 mViewManager->updateView(start, end); 2248 mViewManager->updateView(start, end);
2249 //mDateNavigator->updateView(); 2249 //mDateNavigator->updateView();
2250} 2250}
2251 2251
2252void CalendarView::updateView() 2252void CalendarView::updateView()
2253{ 2253{
2254 DateList tmpList = mNavigator->selectedDates(); 2254 DateList tmpList = mNavigator->selectedDates();
2255 2255
2256 if ( KOPrefs::instance()->mHideNonStartedTodos ) 2256 if ( KOPrefs::instance()->mHideNonStartedTodos )
2257 mTodoList->updateView(); 2257 mTodoList->updateView();
2258 // We assume that the navigator only selects consecutive days. 2258 // We assume that the navigator only selects consecutive days.
2259 updateView( tmpList.first(), tmpList.last() ); 2259 updateView( tmpList.first(), tmpList.last() );
2260} 2260}
2261 2261
2262void CalendarView::updateUnmanagedViews() 2262void CalendarView::updateUnmanagedViews()
2263{ 2263{
2264 mDateNavigator->updateDayMatrix(); 2264 mDateNavigator->updateDayMatrix();
2265} 2265}
2266 2266
2267int CalendarView::msgItemDelete(const QString name) 2267int CalendarView::msgItemDelete(const QString name)
2268{ 2268{
2269 return KMessageBox::warningContinueCancel(this,name +"\n\n"+ 2269 return KMessageBox::warningContinueCancel(this,name +"\n\n"+
2270 i18n("This item will be\npermanently deleted."), 2270 i18n("This item will be\npermanently deleted."),
2271 i18n("KO/Pi Confirmation"),i18n("Delete")); 2271 i18n("KO/Pi Confirmation"),i18n("Delete"));
2272} 2272}
2273 2273
2274 2274
2275void CalendarView::edit_cut() 2275void CalendarView::edit_cut()
2276{ 2276{
2277 Event *anEvent=0; 2277 Event *anEvent=0;
2278 2278
2279 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2279 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2280 2280
2281 if (mViewManager->currentView()->isEventView()) { 2281 if (mViewManager->currentView()->isEventView()) {
2282 if ( incidence && incidence->type() == "Event" ) { 2282 if ( incidence && incidence->type() == "Event" ) {
2283 anEvent = static_cast<Event *>(incidence); 2283 anEvent = static_cast<Event *>(incidence);
2284 } 2284 }
2285 } 2285 }
2286 2286
2287 if (!anEvent) { 2287 if (!anEvent) {
2288 KNotifyClient::beep(); 2288 KNotifyClient::beep();
2289 return; 2289 return;
2290 } 2290 }
2291 DndFactory factory( mCalendar ); 2291 DndFactory factory( mCalendar );
2292 factory.cutIncidence(anEvent); 2292 factory.cutIncidence(anEvent);
2293 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2293 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2294} 2294}
2295 2295
2296void CalendarView::edit_copy() 2296void CalendarView::edit_copy()
2297{ 2297{
2298 Event *anEvent=0; 2298 Event *anEvent=0;
2299 2299
2300 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2300 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2301 2301
2302 if (mViewManager->currentView()->isEventView()) { 2302 if (mViewManager->currentView()->isEventView()) {
2303 if ( incidence && incidence->type() == "Event" ) { 2303 if ( incidence && incidence->type() == "Event" ) {
2304 anEvent = static_cast<Event *>(incidence); 2304 anEvent = static_cast<Event *>(incidence);
2305 } 2305 }
2306 } 2306 }
2307 2307
2308 if (!anEvent) { 2308 if (!anEvent) {
2309 KNotifyClient::beep(); 2309 KNotifyClient::beep();
2310 return; 2310 return;
2311 } 2311 }
2312 DndFactory factory( mCalendar ); 2312 DndFactory factory( mCalendar );
2313 factory.copyIncidence(anEvent); 2313 factory.copyIncidence(anEvent);
2314} 2314}
2315 2315
2316void CalendarView::edit_paste() 2316void CalendarView::edit_paste()
2317{ 2317{
2318 QDate date = mNavigator->selectedDates().first(); 2318 QDate date = mNavigator->selectedDates().first();
2319 2319
2320 DndFactory factory( mCalendar ); 2320 DndFactory factory( mCalendar );
2321 Event *pastedEvent = (Event *)factory.pasteIncidence( date ); 2321 Event *pastedEvent = (Event *)factory.pasteIncidence( date );
2322 2322
2323 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 2323 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
2324} 2324}
2325 2325
2326void CalendarView::edit_options() 2326void CalendarView::edit_options()
2327{ 2327{
2328 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; 2328 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId;
2329 emit save(); 2329 emit save();
2330 emit saveStopTimer(); 2330 emit saveStopTimer();
2331 mDialogManager->showOptionsDialog(); 2331 mDialogManager->showOptionsDialog();
2332 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { 2332 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) {
2333 emit saveStopTimer(); 2333 emit saveStopTimer();
2334 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!"), 2334 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!"),
2335 i18n("Timezone settings"),i18n("Reload"))) { 2335 i18n("Timezone settings"),i18n("Reload"))) {
2336 qDebug("KO: TZ reload cancelled "); 2336 qDebug("KO: TZ reload cancelled ");
2337 return; 2337 return;
2338 } 2338 }
2339 qDebug("KO: Timezone change "); 2339 qDebug("KO: Timezone change ");
2340 openCalendar( MainWindow::defaultFileName() ); 2340 openCalendar( MainWindow::defaultFileName() );
2341 setModified(true); 2341 setModified(true);
2342 } 2342 }
2343 else 2343 else
2344 qDebug("KO: No tz change "); 2344 qDebug("KO: No tz change ");
2345 2345
2346} 2346}
2347 2347
2348 2348
2349void CalendarView::slotSelectPickerDate( QDate d) 2349void CalendarView::slotSelectPickerDate( QDate d)
2350{ 2350{
2351 mDateFrame->hide(); 2351 mDateFrame->hide();
2352 if ( mDatePickerMode == 1 ) { 2352 if ( mDatePickerMode == 1 ) {
2353 mNavigator->slotDaySelect( d ); 2353 mNavigator->slotDaySelect( d );
2354 } else if ( mDatePickerMode == 2 ) { 2354 } else if ( mDatePickerMode == 2 ) {
2355 if ( mMoveIncidence->type() == "Todo" ) { 2355 if ( mMoveIncidence->type() == "Todo" ) {
2356 Todo * to = (Todo *) mMoveIncidence; 2356 Todo * to = (Todo *) mMoveIncidence;
2357 QTime tim; 2357 QTime tim;
2358 int len = 0; 2358 int len = 0;
2359 if ( to->hasStartDate() && to->hasDueDate() ) 2359 if ( to->hasStartDate() && to->hasDueDate() )
2360 len = to->dtStart().secsTo( to->dtDue()); 2360 len = to->dtStart().secsTo( to->dtDue());
2361 if ( to->hasDueDate() ) 2361 if ( to->hasDueDate() )
2362 tim = to->dtDue().time(); 2362 tim = to->dtDue().time();
2363 else { 2363 else {
2364 tim = QTime ( 0,0,0 ); 2364 tim = QTime ( 0,0,0 );
2365 to->setFloats( true ); 2365 to->setFloats( true );
2366 to->setHasDueDate( true ); 2366 to->setHasDueDate( true );
2367 } 2367 }
2368 QDateTime dt ( d,tim ); 2368 QDateTime dt ( d,tim );
2369 to->setDtDue( dt ); 2369 to->setDtDue( dt );
2370 2370
2371 if ( to->hasStartDate() ) { 2371 if ( to->hasStartDate() ) {
2372 if ( len>0 ) 2372 if ( len>0 )
2373 to->setDtStart(to->dtDue().addSecs( -len )); 2373 to->setDtStart(to->dtDue().addSecs( -len ));
2374 else 2374 else
2375 if (to->dtStart() > to->dtDue() ) 2375 if (to->dtStart() > to->dtDue() )
2376 to->setDtStart(to->dtDue().addDays( -3 )); 2376 to->setDtStart(to->dtDue().addDays( -3 ));
2377 } 2377 }
2378 2378
2379 todoChanged( to ); 2379 todoChanged( to );
2380 } else { 2380 } else {
2381 if ( mMoveIncidence->doesRecur() ) { 2381 if ( mMoveIncidence->doesRecur() ) {
2382#if 0 2382#if 0
2383 // PENDING implement this 2383 // PENDING implement this
2384 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); 2384 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate );
2385 mCalendar()->addIncidence( newInc ); 2385 mCalendar()->addIncidence( newInc );
2386 if ( mMoveIncidence->type() == "Todo" ) 2386 if ( mMoveIncidence->type() == "Todo" )
2387 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); 2387 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED );
2388 else 2388 else
2389 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); 2389 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED);
2390 mMoveIncidence = newInc; 2390 mMoveIncidence = newInc;
2391 2391
2392#endif 2392#endif
2393 } 2393 }
2394 QTime tim = mMoveIncidence->dtStart().time(); 2394 QTime tim = mMoveIncidence->dtStart().time();
2395 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2395 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2396 QDateTime dt ( d,tim ); 2396 QDateTime dt ( d,tim );
2397 mMoveIncidence->setDtStart( dt ); 2397 mMoveIncidence->setDtStart( dt );
2398 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2398 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2399 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2399 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2400 } 2400 }
2401 2401
2402 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2402 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2403 } 2403 }
2404} 2404}
2405 2405
2406void CalendarView::removeCategories() 2406void CalendarView::removeCategories()
2407{ 2407{
2408 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2408 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2409 QStringList catList = KOPrefs::instance()->mCustomCategories; 2409 QStringList catList = KOPrefs::instance()->mCustomCategories;
2410 QStringList catIncList; 2410 QStringList catIncList;
2411 QStringList newCatList; 2411 QStringList newCatList;
2412 Incidence* inc = incList.first(); 2412 Incidence* inc = incList.first();
2413 int i; 2413 int i;
2414 int count = 0; 2414 int count = 0;
2415 while ( inc ) { 2415 while ( inc ) {
2416 newCatList.clear(); 2416 newCatList.clear();
2417 catIncList = inc->categories() ; 2417 catIncList = inc->categories() ;
2418 for( i = 0; i< catIncList.count(); ++i ) { 2418 for( i = 0; i< catIncList.count(); ++i ) {
2419 if ( catList.contains (catIncList[i])) 2419 if ( catList.contains (catIncList[i]))
2420 newCatList.append( catIncList[i] ); 2420 newCatList.append( catIncList[i] );
2421 } 2421 }
2422 newCatList.sort(); 2422 newCatList.sort();
2423 inc->setCategories( newCatList.join(",") ); 2423 inc->setCategories( newCatList.join(",") );
2424 inc = incList.next(); 2424 inc = incList.next();
2425 } 2425 }
2426} 2426}
2427 2427
2428int CalendarView::addCategories() 2428int CalendarView::addCategories()
2429{ 2429{
2430 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2430 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2431 QStringList catList = KOPrefs::instance()->mCustomCategories; 2431 QStringList catList = KOPrefs::instance()->mCustomCategories;
2432 QStringList catIncList; 2432 QStringList catIncList;
2433 Incidence* inc = incList.first(); 2433 Incidence* inc = incList.first();
2434 int i; 2434 int i;
2435 int count = 0; 2435 int count = 0;
2436 while ( inc ) { 2436 while ( inc ) {
2437 catIncList = inc->categories() ; 2437 catIncList = inc->categories() ;
2438 for( i = 0; i< catIncList.count(); ++i ) { 2438 for( i = 0; i< catIncList.count(); ++i ) {
2439 if ( !catList.contains (catIncList[i])) { 2439 if ( !catList.contains (catIncList[i])) {
2440 catList.append( catIncList[i] ); 2440 catList.append( catIncList[i] );
2441 //qDebug("add cat %s ", catIncList[i].latin1()); 2441 //qDebug("add cat %s ", catIncList[i].latin1());
2442 ++count; 2442 ++count;
2443 } 2443 }
2444 } 2444 }
2445 inc = incList.next(); 2445 inc = incList.next();
2446 } 2446 }
2447 catList.sort(); 2447 catList.sort();
2448 KOPrefs::instance()->mCustomCategories = catList; 2448 KOPrefs::instance()->mCustomCategories = catList;
2449 return count; 2449 return count;
2450} 2450}
2451 2451
2452void CalendarView::manageCategories() 2452void CalendarView::manageCategories()
2453{ 2453{
2454 KOCatPrefs* cp = new KOCatPrefs(); 2454 KOCatPrefs* cp = new KOCatPrefs();
2455 cp->show(); 2455 cp->show();
2456 int w =cp->sizeHint().width() ; 2456 int w =cp->sizeHint().width() ;
2457 int h = cp->sizeHint().height() ; 2457 int h = cp->sizeHint().height() ;
2458 int dw = QApplication::desktop()->width(); 2458 int dw = QApplication::desktop()->width();
2459 int dh = QApplication::desktop()->height(); 2459 int dh = QApplication::desktop()->height();
2460 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2460 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2461 if ( !cp->exec() ) { 2461 if ( !cp->exec() ) {
2462 delete cp; 2462 delete cp;
2463 return; 2463 return;
2464 } 2464 }
2465 int count = 0; 2465 int count = 0;
2466 if ( cp->addCat() ) { 2466 if ( cp->addCat() ) {
2467 count = addCategories(); 2467 count = addCategories();
2468 if ( count ) { 2468 if ( count ) {
2469 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2469 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2470 writeSettings(); 2470 writeSettings();
2471 } else 2471 } else
2472 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); 2472 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! "));
2473 } else { 2473 } else {
2474 removeCategories(); 2474 removeCategories();
2475 updateView(); 2475 updateView();
2476 } 2476 }
2477 delete cp; 2477 delete cp;
2478} 2478}
2479 2479
2480void CalendarView::beamIncidence(Incidence * Inc) 2480void CalendarView::beamIncidence(Incidence * Inc)
2481{ 2481{
2482 QPtrList<Incidence> delSel ; 2482 QPtrList<Incidence> delSel ;
2483 delSel.append(Inc); 2483 delSel.append(Inc);
2484 beamIncidenceList( delSel ); 2484 beamIncidenceList( delSel );
2485} 2485}
2486void CalendarView::beamCalendar() 2486void CalendarView::beamCalendar()
2487{ 2487{
2488 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2488 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2489 //qDebug("beamCalendar() "); 2489 //qDebug("beamCalendar() ");
2490 beamIncidenceList( delSel ); 2490 beamIncidenceList( delSel );
2491} 2491}
2492void CalendarView::beamFilteredCalendar() 2492void CalendarView::beamFilteredCalendar()
2493{ 2493{
2494 QPtrList<Incidence> delSel = mCalendar->incidences(); 2494 QPtrList<Incidence> delSel = mCalendar->incidences();
2495 //qDebug("beamFilteredCalendar() "); 2495 //qDebug("beamFilteredCalendar() ");
2496 beamIncidenceList( delSel ); 2496 beamIncidenceList( delSel );
2497} 2497}
2498void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2498void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2499{ 2499{
2500 if ( beamDialog->exec () == QDialog::Rejected ) 2500 if ( beamDialog->exec () == QDialog::Rejected )
2501 return; 2501 return;
2502#ifdef DESKTOP_VERSION 2502#ifdef DESKTOP_VERSION
2503 QString fn = locateLocal( "tmp", "kopibeamfile" ); 2503 QString fn = locateLocal( "tmp", "kopibeamfile" );
2504#else 2504#else
2505 QString fn = "/tmp/kopibeamfile"; 2505 QString fn = "/tmp/kopibeamfile";
2506#endif 2506#endif
2507 QString mes; 2507 QString mes;
2508 bool createbup = true; 2508 bool createbup = true;
2509 if ( createbup ) { 2509 if ( createbup ) {
2510 QString description = "\n"; 2510 QString description = "\n";
2511 CalendarLocal* cal = new CalendarLocal(); 2511 CalendarLocal* cal = new CalendarLocal();
2512 if ( beamDialog->beamLocal() ) 2512 if ( beamDialog->beamLocal() )
2513 cal->setLocalTime(); 2513 cal->setLocalTime();
2514 else 2514 else
2515 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2515 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2516 Incidence *incidence = delSel.first(); 2516 Incidence *incidence = delSel.first();
2517 bool addText = false; 2517 bool addText = false;
2518 if ( delSel.count() < 10 ) 2518 if ( delSel.count() < 10 )
2519 addText = true; 2519 addText = true;
2520 else { 2520 else {
2521 description.sprintf(i18n(" %d items?"),delSel.count() ); 2521 description.sprintf(i18n(" %d items?"),delSel.count() );
2522 } 2522 }
2523 while ( incidence ) { 2523 while ( incidence ) {
2524 Incidence *in = incidence->clone(); 2524 Incidence *in = incidence->clone();
2525 if ( ! in->summary().isEmpty() ) { 2525 if ( ! in->summary().isEmpty() ) {
2526 in->setDescription(""); 2526 in->setDescription("");
2527 } else { 2527 } else {
2528 in->setSummary( in->description().left(20)); 2528 in->setSummary( in->description().left(20));
2529 in->setDescription(""); 2529 in->setDescription("");
2530 } 2530 }
2531 if ( addText ) 2531 if ( addText )
2532 description += in->summary() + "\n"; 2532 description += in->summary() + "\n";
2533 cal->addIncidence( in ); 2533 cal->addIncidence( in );
2534 incidence = delSel.next(); 2534 incidence = delSel.next();
2535 } 2535 }
2536 if ( beamDialog->beamVcal() ) { 2536 if ( beamDialog->beamVcal() ) {
2537 fn += ".vcs"; 2537 fn += ".vcs";
2538 FileStorage storage( cal, fn, new VCalFormat ); 2538 FileStorage storage( cal, fn, new VCalFormat );
2539 storage.save(); 2539 storage.save();
2540 } else { 2540 } else {
2541 fn += ".ics"; 2541 fn += ".ics";
2542 FileStorage storage( cal, fn, new ICalFormat( ) ); 2542 FileStorage storage( cal, fn, new ICalFormat( ) );
2543 storage.save(); 2543 storage.save();
2544 } 2544 }
2545 delete cal; 2545 delete cal;
2546 mes = i18n("KO/Pi: Ready for beaming"); 2546 mes = i18n("KO/Pi: Ready for beaming");
2547 topLevelWidget()->setCaption(mes); 2547 topLevelWidget()->setCaption(mes);
2548 KApplication::convert2latin1( fn ); 2548 KApplication::convert2latin1( fn );
2549#ifndef DESKTOP_VERSION 2549#ifndef DESKTOP_VERSION
2550 Ir *ir = new Ir( this ); 2550 Ir *ir = new Ir( this );
2551 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 2551 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2552 ir->send( fn, description, "text/x-vCalendar" ); 2552 ir->send( fn, description, "text/x-vCalendar" );
2553#endif 2553#endif
2554 } 2554 }
2555} 2555}
2556void CalendarView::beamDone( Ir *ir ) 2556void CalendarView::beamDone( Ir *ir )
2557{ 2557{
2558#ifndef DESKTOP_VERSION 2558#ifndef DESKTOP_VERSION
2559 delete ir; 2559 delete ir;
2560#endif 2560#endif
2561 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); 2561 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") );
2562 topLevelWidget()->raise(); 2562 topLevelWidget()->raise();
2563} 2563}
2564 2564
2565void CalendarView::moveIncidence(Incidence * inc ) 2565void CalendarView::moveIncidence(Incidence * inc )
2566{ 2566{
2567 if ( !inc ) return; 2567 if ( !inc ) return;
2568 showDatePickerPopup(); 2568 showDatePickerPopup();
2569 mDatePickerMode = 2; 2569 mDatePickerMode = 2;
2570 mMoveIncidence = inc ; 2570 mMoveIncidence = inc ;
2571 QDate da; 2571 QDate da;
2572 if ( mMoveIncidence->type() == "Todo" ) { 2572 if ( mMoveIncidence->type() == "Todo" ) {
2573 Todo * to = (Todo *) mMoveIncidence; 2573 Todo * to = (Todo *) mMoveIncidence;
2574 if ( to->hasDueDate() ) 2574 if ( to->hasDueDate() )
2575 da = to->dtDue().date(); 2575 da = to->dtDue().date();
2576 else 2576 else
2577 da = QDate::currentDate(); 2577 da = QDate::currentDate();
2578 } else { 2578 } else {
2579 da = mMoveIncidence->dtStart().date(); 2579 da = mMoveIncidence->dtStart().date();
2580 } 2580 }
2581 //PENDING set date for recurring incidence to date of recurrence 2581 //PENDING set date for recurring incidence to date of recurrence
2582 //mMoveIncidenceOldDate; 2582 //mMoveIncidenceOldDate;
2583 mDatePicker->setDate( da ); 2583 mDatePicker->setDate( da );
2584} 2584}
2585void CalendarView::showDatePickerPopup() 2585void CalendarView::showDatePickerPopup()
2586{ 2586{
2587 if ( mDateFrame->isVisible() ) 2587 if ( mDateFrame->isVisible() )
2588 mDateFrame->hide(); 2588 mDateFrame->hide();
2589 else { 2589 else {
2590 int offX = 0, offY = 0; 2590 int offX = 0, offY = 0;
2591#ifdef DESKTOP_VERSION 2591#ifdef DESKTOP_VERSION
2592 int w =mDatePicker->sizeHint().width() ; 2592 int w =mDatePicker->sizeHint().width() ;
2593 int h = mDatePicker->sizeHint().height() ; 2593 int h = mDatePicker->sizeHint().height() ;
2594 int dw = topLevelWidget()->width(); 2594 int dw = topLevelWidget()->width();
2595 int dh = topLevelWidget()->height(); 2595 int dh = topLevelWidget()->height();
2596 offX = topLevelWidget()->x(); 2596 offX = topLevelWidget()->x();
2597 offY = topLevelWidget()->y(); 2597 offY = topLevelWidget()->y();
2598#else 2598#else
2599 int w =mDatePicker->sizeHint().width() ; 2599 int w =mDatePicker->sizeHint().width() ;
2600 int h = mDatePicker->sizeHint().height() ; 2600 int h = mDatePicker->sizeHint().height() ;
2601 int dw = QApplication::desktop()->width(); 2601 int dw = QApplication::desktop()->width();
2602 int dh = QApplication::desktop()->height(); 2602 int dh = QApplication::desktop()->height();
2603#endif 2603#endif
2604 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); 2604 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h );
2605 mDateFrame->show(); 2605 mDateFrame->show();
2606 } 2606 }
2607} 2607}
2608void CalendarView::showDatePicker( ) 2608void CalendarView::showDatePicker( )
2609{ 2609{
2610 showDatePickerPopup(); 2610 showDatePickerPopup();
2611 mDatePickerMode = 1; 2611 mDatePickerMode = 1;
2612 mDatePicker->setDate( mNavigator->selectedDates().first() ); 2612 mDatePicker->setDate( mNavigator->selectedDates().first() );
2613} 2613}
2614 2614
2615void CalendarView::showEventEditor() 2615void CalendarView::showEventEditor()
2616{ 2616{
2617#ifdef DESKTOP_VERSION 2617#ifdef DESKTOP_VERSION
2618 int x,y,w,h; 2618 int x,y,w,h;
2619 x = mEventEditor->geometry().x(); 2619 x = mEventEditor->geometry().x();
2620 y = mEventEditor->geometry().y(); 2620 y = mEventEditor->geometry().y();
2621 w = mEventEditor->width(); 2621 w = mEventEditor->width();
2622 h = mEventEditor->height(); 2622 h = mEventEditor->height();
2623 mEventEditor->show(); 2623 mEventEditor->show();
2624 mEventEditor->setGeometry(x,y,w,h); 2624 mEventEditor->setGeometry(x,y,w,h);
2625#else 2625#else
2626 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { 2626 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) {
2627 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2627 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2628 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); 2628 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() );
2629 qApp->processEvents(); 2629 qApp->processEvents();
2630 delete mEventEditor; 2630 delete mEventEditor;
2631 mEventEditor = mDialogManager->getEventEditor(); 2631 mEventEditor = mDialogManager->getEventEditor();
2632 topLevelWidget()->setCaption( i18n("") ); 2632 topLevelWidget()->setCaption( i18n("") );
2633 } 2633 }
2634 mEventEditor->showMaximized(); 2634 mEventEditor->showMaximized();
2635#endif 2635#endif
2636} 2636}
2637void CalendarView::showTodoEditor() 2637void CalendarView::showTodoEditor()
2638{ 2638{
2639#ifdef DESKTOP_VERSION 2639#ifdef DESKTOP_VERSION
2640 int x,y,w,h; 2640 int x,y,w,h;
2641 x = mTodoEditor->geometry().x(); 2641 x = mTodoEditor->geometry().x();
2642 y = mTodoEditor->geometry().y(); 2642 y = mTodoEditor->geometry().y();
2643 w = mTodoEditor->width(); 2643 w = mTodoEditor->width();
2644 h = mTodoEditor->height(); 2644 h = mTodoEditor->height();
2645 mTodoEditor->show(); 2645 mTodoEditor->show();
2646 mTodoEditor->setGeometry(x,y,w,h); 2646 mTodoEditor->setGeometry(x,y,w,h);
2647#else 2647#else
2648 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { 2648 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) {
2649 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2649 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2650 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); 2650 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() );
2651 qApp->processEvents(); 2651 qApp->processEvents();
2652 delete mTodoEditor; 2652 delete mTodoEditor;
2653 mTodoEditor = mDialogManager->getTodoEditor(); 2653 mTodoEditor = mDialogManager->getTodoEditor();
2654 topLevelWidget()->setCaption( i18n("") ); 2654 topLevelWidget()->setCaption( i18n("") );
2655 } 2655 }
2656 mTodoEditor->showMaximized(); 2656 mTodoEditor->showMaximized();
2657#endif 2657#endif
2658} 2658}
2659 2659
2660void CalendarView::cloneIncidence() 2660void CalendarView::cloneIncidence()
2661{ 2661{
2662 Incidence *incidence = currentSelection(); 2662 Incidence *incidence = currentSelection();
2663 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2663 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2664 if ( incidence ) { 2664 if ( incidence ) {
2665 cloneIncidence(incidence); 2665 cloneIncidence(incidence);
2666 } 2666 }
2667} 2667}
2668void CalendarView::moveIncidence() 2668void CalendarView::moveIncidence()
2669{ 2669{
2670 Incidence *incidence = currentSelection(); 2670 Incidence *incidence = currentSelection();
2671 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2671 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2672 if ( incidence ) { 2672 if ( incidence ) {
2673 moveIncidence(incidence); 2673 moveIncidence(incidence);
2674 } 2674 }
2675} 2675}
2676void CalendarView::beamIncidence() 2676void CalendarView::beamIncidence()
2677{ 2677{
2678 Incidence *incidence = currentSelection(); 2678 Incidence *incidence = currentSelection();
2679 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2679 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2680 if ( incidence ) { 2680 if ( incidence ) {
2681 beamIncidence(incidence); 2681 beamIncidence(incidence);
2682 } 2682 }
2683} 2683}
2684void CalendarView::toggleCancelIncidence() 2684void CalendarView::toggleCancelIncidence()
2685{ 2685{
2686 Incidence *incidence = currentSelection(); 2686 Incidence *incidence = currentSelection();
2687 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2687 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2688 if ( incidence ) { 2688 if ( incidence ) {
2689 cancelIncidence(incidence); 2689 cancelIncidence(incidence);
2690 } 2690 }
2691} 2691}
2692 2692
2693 2693
2694void CalendarView::cancelIncidence(Incidence * inc ) 2694void CalendarView::cancelIncidence(Incidence * inc )
2695{ 2695{
2696 inc->setCancelled( ! inc->cancelled() ); 2696 inc->setCancelled( ! inc->cancelled() );
2697 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 2697 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
2698 updateView(); 2698 updateView();
2699} 2699}
2700void CalendarView::cloneIncidence(Incidence * orgInc ) 2700void CalendarView::cloneIncidence(Incidence * orgInc )
2701{ 2701{
2702 Incidence * newInc = orgInc->clone(); 2702 Incidence * newInc = orgInc->clone();
2703 newInc->recreate(); 2703 newInc->recreate();
2704 2704
2705 if ( newInc->type() == "Todo" ) { 2705 if ( newInc->type() == "Todo" ) {
2706 Todo* t = (Todo*) newInc; 2706 Todo* t = (Todo*) newInc;
2707 showTodoEditor(); 2707 showTodoEditor();
2708 mTodoEditor->editTodo( t ); 2708 mTodoEditor->editTodo( t );
2709 if ( mTodoEditor->exec() ) { 2709 if ( mTodoEditor->exec() ) {
2710 mCalendar->addTodo( t ); 2710 mCalendar->addTodo( t );
2711 updateView(); 2711 updateView();
2712 } else { 2712 } else {
2713 delete t; 2713 delete t;
2714 } 2714 }
2715 } 2715 }
2716 else { 2716 else {
2717 Event* e = (Event*) newInc; 2717 Event* e = (Event*) newInc;
2718 showEventEditor(); 2718 showEventEditor();
2719 mEventEditor->editEvent( e ); 2719 mEventEditor->editEvent( e );
2720 if ( mEventEditor->exec() ) { 2720 if ( mEventEditor->exec() ) {
2721 mCalendar->addEvent( e ); 2721 mCalendar->addEvent( e );
2722 updateView(); 2722 updateView();
2723 } else { 2723 } else {
2724 delete e; 2724 delete e;
2725 } 2725 }
2726 } 2726 }
2727 setActiveWindow(); 2727 setActiveWindow();
2728} 2728}
2729 2729
2730void CalendarView::newEvent() 2730void CalendarView::newEvent()
2731{ 2731{
2732 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 2732 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
2733 KOAgendaView *aView = mViewManager->agendaView(); 2733 KOAgendaView *aView = mViewManager->agendaView();
2734 if (aView) { 2734 if (aView) {
2735 if (aView->selectionStart().isValid()) { 2735 if (aView->selectionStart().isValid()) {
2736 if (aView->selectedIsAllDay()) { 2736 if (aView->selectedIsAllDay()) {
2737 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 2737 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
2738 } else { 2738 } else {
2739 newEvent(aView->selectionStart(),aView->selectionEnd()); 2739 newEvent(aView->selectionStart(),aView->selectionEnd());
2740 } 2740 }
2741 return; 2741 return;
2742 } 2742 }
2743 } 2743 }
2744 2744
2745 QDate date = mNavigator->selectedDates().first(); 2745 QDate date = mNavigator->selectedDates().first();
2746 QDateTime current = QDateTime::currentDateTime(); 2746 QDateTime current = QDateTime::currentDateTime();
2747 if ( date <= current.date() ) { 2747 if ( date <= current.date() ) {
2748 int hour = current.time().hour() +1; 2748 int hour = current.time().hour() +1;
2749 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 2749 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
2750 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2750 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2751 } else 2751 } else
2752 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 2752 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
2753 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 2753 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
2754 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2754 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2755} 2755}
2756 2756
2757void CalendarView::newEvent(QDateTime fh) 2757void CalendarView::newEvent(QDateTime fh)
2758{ 2758{
2759 newEvent(fh, 2759 newEvent(fh,
2760 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 2760 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
2761} 2761}
2762 2762
2763void CalendarView::newEvent(QDate dt) 2763void CalendarView::newEvent(QDate dt)
2764{ 2764{
2765 newEvent(QDateTime(dt, QTime(0,0,0)), 2765 newEvent(QDateTime(dt, QTime(0,0,0)),
2766 QDateTime(dt, QTime(0,0,0)), true); 2766 QDateTime(dt, QTime(0,0,0)), true);
2767} 2767}
2768void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) 2768void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint)
2769{ 2769{
2770 newEvent(fromHint, toHint, false); 2770 newEvent(fromHint, toHint, false);
2771} 2771}
2772void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 2772void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
2773{ 2773{
2774 2774
2775 showEventEditor(); 2775 showEventEditor();
2776 mEventEditor->newEvent(fromHint,toHint,allDay); 2776 mEventEditor->newEvent(fromHint,toHint,allDay);
2777 if ( mFilterView->filtersEnabled() ) { 2777 if ( mFilterView->filtersEnabled() ) {
2778 CalFilter *filter = mFilterView->selectedFilter(); 2778 CalFilter *filter = mFilterView->selectedFilter();
2779 if (filter && filter->showCategories()) { 2779 if (filter && filter->showCategories()) {
2780 mEventEditor->setCategories(filter->categoryList().join(",") ); 2780 mEventEditor->setCategories(filter->categoryList().join(",") );
2781 } 2781 }
2782 if ( filter ) 2782 if ( filter )
2783 mEventEditor->setSecrecy( filter->getSecrecy() ); 2783 mEventEditor->setSecrecy( filter->getSecrecy() );
2784 } 2784 }
2785 mEventEditor->exec(); 2785 mEventEditor->exec();
2786 setActiveWindow(); 2786 setActiveWindow();
2787} 2787}
2788void CalendarView::todoAdded(Todo * t) 2788void CalendarView::todoAdded(Todo * t)
2789{ 2789{
2790 2790
2791 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 2791 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
2792 updateTodoViews(); 2792 updateTodoViews();
2793} 2793}
2794void CalendarView::todoChanged(Todo * t) 2794void CalendarView::todoChanged(Todo * t)
2795{ 2795{
2796 emit todoModified( t, 4 ); 2796 emit todoModified( t, 4 );
2797 // updateTodoViews(); 2797 // updateTodoViews();
2798} 2798}
2799void CalendarView::todoToBeDeleted(Todo *) 2799void CalendarView::todoToBeDeleted(Todo *)
2800{ 2800{
2801 //qDebug("todoToBeDeleted(Todo *) "); 2801 //qDebug("todoToBeDeleted(Todo *) ");
2802 updateTodoViews(); 2802 updateTodoViews();
2803} 2803}
2804void CalendarView::todoDeleted() 2804void CalendarView::todoDeleted()
2805{ 2805{
2806 //qDebug(" todoDeleted()"); 2806 //qDebug(" todoDeleted()");
2807 updateTodoViews(); 2807 updateTodoViews();
2808} 2808}
2809 2809
2810 2810
2811void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) 2811void CalendarView::newTodoDateTime( QDateTime dt, bool allday )
2812{ 2812{
2813 showTodoEditor(); 2813 showTodoEditor();
2814 mTodoEditor->newTodo(dt,0,allday); 2814 mTodoEditor->newTodo(dt,0,allday);
2815 if ( mFilterView->filtersEnabled() ) { 2815 if ( mFilterView->filtersEnabled() ) {
2816 CalFilter *filter = mFilterView->selectedFilter(); 2816 CalFilter *filter = mFilterView->selectedFilter();
2817 if (filter && filter->showCategories()) { 2817 if (filter && filter->showCategories()) {
2818 mTodoEditor->setCategories(filter->categoryList().join(",") ); 2818 mTodoEditor->setCategories(filter->categoryList().join(",") );
2819 } 2819 }
2820 if ( filter ) 2820 if ( filter )
2821 mTodoEditor->setSecrecy( filter->getSecrecy() ); 2821 mTodoEditor->setSecrecy( filter->getSecrecy() );
2822 } 2822 }
2823 mTodoEditor->exec(); 2823 mTodoEditor->exec();
2824 setActiveWindow(); 2824 setActiveWindow();
2825} 2825}
2826 2826
2827void CalendarView::newTodo() 2827void CalendarView::newTodo()
2828{ 2828{
2829 newTodoDateTime( QDateTime(),true ); 2829 newTodoDateTime( QDateTime(),true );
2830} 2830}
2831 2831
2832void CalendarView::newSubTodo() 2832void CalendarView::newSubTodo()
2833{ 2833{
2834 Todo *todo = selectedTodo(); 2834 Todo *todo = selectedTodo();
2835 if ( todo ) newSubTodo( todo ); 2835 if ( todo ) newSubTodo( todo );
2836} 2836}
2837 2837
2838void CalendarView::newSubTodo(Todo *parentEvent) 2838void CalendarView::newSubTodo(Todo *parentEvent)
2839{ 2839{
2840 2840
2841 showTodoEditor(); 2841 showTodoEditor();
2842 mTodoEditor->newTodo(QDateTime(),parentEvent,true); 2842 mTodoEditor->newTodo(QDateTime(),parentEvent,true);
2843 mTodoEditor->exec(); 2843 mTodoEditor->exec();
2844 setActiveWindow(); 2844 setActiveWindow();
2845} 2845}
2846 2846
2847void CalendarView::newFloatingEvent() 2847void CalendarView::newFloatingEvent()
2848{ 2848{
2849 DateList tmpList = mNavigator->selectedDates(); 2849 DateList tmpList = mNavigator->selectedDates();
2850 QDate date = tmpList.first(); 2850 QDate date = tmpList.first();
2851 2851
2852 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 2852 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
2853 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 2853 QDateTime( date, QTime( 12, 0, 0 ) ), true );
2854} 2854}
2855 2855
2856 2856
2857void CalendarView::editEvent( Event *event ) 2857void CalendarView::editEvent( Event *event )
2858{ 2858{
2859 2859
2860 if ( !event ) return; 2860 if ( !event ) return;
2861 if ( event->isReadOnly() ) { 2861 if ( event->isReadOnly() ) {
2862 showEvent( event ); 2862 showEvent( event );
2863 return; 2863 return;
2864 } 2864 }
2865 showEventEditor(); 2865 showEventEditor();
2866 mEventEditor->editEvent( event , mFlagEditDescription); 2866 mEventEditor->editEvent( event , mFlagEditDescription);
2867 mEventEditor->exec(); 2867 mEventEditor->exec();
2868 setActiveWindow(); 2868 setActiveWindow();
2869 2869
2870} 2870}
2871void CalendarView::editJournal( Journal *jour ) 2871void CalendarView::editJournal( Journal *jour )
2872{ 2872{
2873 if ( !jour ) return; 2873 if ( !jour ) return;
2874 mDialogManager->hideSearchDialog(); 2874 mDialogManager->hideSearchDialog();
2875 mViewManager->showJournalView(); 2875 mViewManager->showJournalView();
2876 mNavigator->slotDaySelect( jour->dtStart().date() ); 2876 mNavigator->slotDaySelect( jour->dtStart().date() );
2877} 2877}
2878void CalendarView::editTodo( Todo *todo ) 2878void CalendarView::editTodo( Todo *todo )
2879{ 2879{
2880 if ( !todo ) return; 2880 if ( !todo ) return;
2881 2881
2882 if ( todo->isReadOnly() ) { 2882 if ( todo->isReadOnly() ) {
2883 showTodo( todo ); 2883 showTodo( todo );
2884 return; 2884 return;
2885 } 2885 }
2886 showTodoEditor(); 2886 showTodoEditor();
2887 mTodoEditor->editTodo( todo ,mFlagEditDescription); 2887 mTodoEditor->editTodo( todo ,mFlagEditDescription);
2888 mTodoEditor->exec(); 2888 mTodoEditor->exec();
2889 setActiveWindow(); 2889 setActiveWindow();
2890 2890
2891} 2891}
2892 2892
2893KOEventViewerDialog* CalendarView::getEventViewerDialog() 2893KOEventViewerDialog* CalendarView::getEventViewerDialog()
2894{ 2894{
2895 if ( !mEventViewerDialog ) { 2895 if ( !mEventViewerDialog ) {
2896 mEventViewerDialog = new KOEventViewerDialog(0); 2896 mEventViewerDialog = new KOEventViewerDialog(0);
2897 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 2897 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
2898 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 2898 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
2899 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 2899 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
2900 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 2900 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
2901 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 2901 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
2902 viewManager(), SLOT( showAgendaView( bool ) ) ); 2902 viewManager(), SLOT( showAgendaView( bool ) ) );
2903 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), 2903 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()),
2904 this, SLOT( slotViewerClosed() ) ); 2904 this, SLOT( slotViewerClosed() ) );
2905 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), 2905 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ),
2906 this, SLOT( todoChanged(Todo *) ) ); 2906 this, SLOT( todoChanged(Todo *) ) );
2907 mEventViewerDialog->resize( 640, 480 ); 2907 mEventViewerDialog->resize( 640, 480 );
2908 2908
2909 } 2909 }
2910 return mEventViewerDialog; 2910 return mEventViewerDialog;
2911} 2911}
2912void CalendarView::showEvent(Event *event) 2912void CalendarView::showEvent(Event *event)
2913{ 2913{
2914 getEventViewerDialog()->setEvent(event); 2914 getEventViewerDialog()->setEvent(event);
2915 getEventViewerDialog()->showMe(); 2915 getEventViewerDialog()->showMe();
2916} 2916}
2917 2917
2918void CalendarView::showTodo(Todo *event) 2918void CalendarView::showTodo(Todo *event)
2919{ 2919{
2920 getEventViewerDialog()->setTodo(event); 2920 getEventViewerDialog()->setTodo(event);
2921 getEventViewerDialog()->showMe(); 2921 getEventViewerDialog()->showMe();
2922} 2922}
2923void CalendarView::showJournal( Journal *jour ) 2923void CalendarView::showJournal( Journal *jour )
2924{ 2924{
2925 getEventViewerDialog()->setJournal(jour); 2925 getEventViewerDialog()->setJournal(jour);
2926 getEventViewerDialog()->showMe(); 2926 getEventViewerDialog()->showMe();
2927 2927
2928} 2928}
2929// void CalendarView::todoModified (Todo *event, int changed) 2929// void CalendarView::todoModified (Todo *event, int changed)
2930// { 2930// {
2931// // if (mDialogList.find (event) != mDialogList.end ()) { 2931// // if (mDialogList.find (event) != mDialogList.end ()) {
2932// // kdDebug() << "Todo modified and open" << endl; 2932// // kdDebug() << "Todo modified and open" << endl;
2933// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 2933// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
2934// // temp->modified (changed); 2934// // temp->modified (changed);
2935 2935
2936// // } 2936// // }
2937 2937
2938// mViewManager->updateView(); 2938// mViewManager->updateView();
2939// } 2939// }
2940 2940
2941void CalendarView::appointment_show() 2941void CalendarView::appointment_show()
2942{ 2942{
2943 Event *anEvent = 0; 2943 Event *anEvent = 0;
2944 2944
2945 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2945 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2946 2946
2947 if (mViewManager->currentView()->isEventView()) { 2947 if (mViewManager->currentView()->isEventView()) {
2948 if ( incidence && incidence->type() == "Event" ) { 2948 if ( incidence && incidence->type() == "Event" ) {
2949 anEvent = static_cast<Event *>(incidence); 2949 anEvent = static_cast<Event *>(incidence);
2950 } 2950 }
2951 } 2951 }
2952 2952
2953 if (!anEvent) { 2953 if (!anEvent) {
2954 KNotifyClient::beep(); 2954 KNotifyClient::beep();
2955 return; 2955 return;
2956 } 2956 }
2957 2957
2958 showEvent(anEvent); 2958 showEvent(anEvent);
2959} 2959}
2960 2960
2961void CalendarView::appointment_edit() 2961void CalendarView::appointment_edit()
2962{ 2962{
2963 Event *anEvent = 0; 2963 Event *anEvent = 0;
2964 2964
2965 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2965 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2966 2966
2967 if (mViewManager->currentView()->isEventView()) { 2967 if (mViewManager->currentView()->isEventView()) {
2968 if ( incidence && incidence->type() == "Event" ) { 2968 if ( incidence && incidence->type() == "Event" ) {
2969 anEvent = static_cast<Event *>(incidence); 2969 anEvent = static_cast<Event *>(incidence);
2970 } 2970 }
2971 } 2971 }
2972 2972
2973 if (!anEvent) { 2973 if (!anEvent) {
2974 KNotifyClient::beep(); 2974 KNotifyClient::beep();
2975 return; 2975 return;
2976 } 2976 }
2977 2977
2978 editEvent(anEvent); 2978 editEvent(anEvent);
2979} 2979}
2980 2980
2981void CalendarView::appointment_delete() 2981void CalendarView::appointment_delete()
2982{ 2982{
2983 Event *anEvent = 0; 2983 Event *anEvent = 0;
2984 2984
2985 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2985 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2986 2986
2987 if (mViewManager->currentView()->isEventView()) { 2987 if (mViewManager->currentView()->isEventView()) {
2988 if ( incidence && incidence->type() == "Event" ) { 2988 if ( incidence && incidence->type() == "Event" ) {
2989 anEvent = static_cast<Event *>(incidence); 2989 anEvent = static_cast<Event *>(incidence);
2990 } 2990 }
2991 } 2991 }
2992 2992
2993 if (!anEvent) { 2993 if (!anEvent) {
2994 KNotifyClient::beep(); 2994 KNotifyClient::beep();
2995 return; 2995 return;
2996 } 2996 }
2997 2997
2998 deleteEvent(anEvent); 2998 deleteEvent(anEvent);
2999} 2999}
3000 3000
3001void CalendarView::todo_resub( Todo * parent, Todo * sub ) 3001void CalendarView::todo_resub( Todo * parent, Todo * sub )
3002{ 3002{
3003 if (!sub) return; 3003 if (!sub) return;
3004 if (!parent) return; 3004 if (!parent) return;
3005 if ( sub->relatedTo() ) 3005 if ( sub->relatedTo() )
3006 sub->relatedTo()->removeRelation(sub); 3006 sub->relatedTo()->removeRelation(sub);
3007 sub->setRelatedTo(parent); 3007 sub->setRelatedTo(parent);
3008 sub->setRelatedToUid(parent->uid()); 3008 sub->setRelatedToUid(parent->uid());
3009 parent->addRelation(sub); 3009 parent->addRelation(sub);
3010 sub->updated(); 3010 sub->updated();
3011 parent->updated(); 3011 parent->updated();
3012 setModified(true); 3012 setModified(true);
3013 updateView(); 3013 updateView();
3014} 3014}
3015void CalendarView::todo_unsub(Todo *anTodo ) 3015void CalendarView::todo_unsub(Todo *anTodo )
3016{ 3016{
3017 // Todo *anTodo = selectedTodo(); 3017 // Todo *anTodo = selectedTodo();
3018 if (!anTodo) return; 3018 if (!anTodo) return;
3019 if (!anTodo->relatedTo()) return; 3019 if (!anTodo->relatedTo()) return;
3020 anTodo->relatedTo()->removeRelation(anTodo); 3020 anTodo->relatedTo()->removeRelation(anTodo);
3021 anTodo->setRelatedTo(0); 3021 anTodo->setRelatedTo(0);
3022 anTodo->updated(); 3022 anTodo->updated();
3023 anTodo->setRelatedToUid(""); 3023 anTodo->setRelatedToUid("");
3024 setModified(true); 3024 setModified(true);
3025 updateView(); 3025 updateView();
3026} 3026}
3027 3027
3028void CalendarView::deleteTodo(Todo *todo) 3028void CalendarView::deleteTodo(Todo *todo)
3029{ 3029{
3030 if (!todo) { 3030 if (!todo) {
3031 KNotifyClient::beep(); 3031 KNotifyClient::beep();
3032 return; 3032 return;
3033 } 3033 }
3034 if (KOPrefs::instance()->mConfirm) { 3034 if (KOPrefs::instance()->mConfirm) {
3035 QString text = todo->summary().left(20); 3035 QString text = todo->summary().left(20);
3036 if (!todo->relations().isEmpty()) { 3036 if (!todo->relations().isEmpty()) {
3037 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); 3037 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!");
3038 3038
3039 } 3039 }
3040 switch (msgItemDelete(text)) { 3040 switch (msgItemDelete(text)) {
3041 case KMessageBox::Continue: // OK 3041 case KMessageBox::Continue: // OK
3042 bool deleteT = false; 3042 bool deleteT = false;
3043 if (!todo->relations().isEmpty()) { 3043 if (!todo->relations().isEmpty()) {
3044 deleteT = removeCompletedSubTodos( todo ); 3044 deleteT = removeCompletedSubTodos( todo );
3045 } 3045 }
3046 // deleteT == true: todo already deleted in removeCompletedSubTodos 3046 // deleteT == true: todo already deleted in removeCompletedSubTodos
3047 if ( !deleteT ) { 3047 if ( !deleteT ) {
3048 checkExternalId( todo ); 3048 checkExternalId( todo );
3049 calendar()->deleteTodo(todo); 3049 calendar()->deleteTodo(todo);
3050 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 3050 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
3051 updateView(); 3051 updateView();
3052 } 3052 }
3053 break; 3053 break;
3054 } // switch 3054 } // switch
3055 } else { 3055 } else {
3056 checkExternalId( todo ); 3056 checkExternalId( todo );
3057 mCalendar->deleteTodo(todo); 3057 mCalendar->deleteTodo(todo);
3058 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 3058 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
3059 updateView(); 3059 updateView();
3060 } 3060 }
3061 3061
3062 emit updateSearchDialog(); 3062 emit updateSearchDialog();
3063} 3063}
3064void CalendarView::deleteJournal(Journal *jour) 3064void CalendarView::deleteJournal(Journal *jour)
3065{ 3065{
3066 if (!jour) { 3066 if (!jour) {
3067 KNotifyClient::beep(); 3067 KNotifyClient::beep();
3068 return; 3068 return;
3069 } 3069 }
3070 if (KOPrefs::instance()->mConfirm) { 3070 if (KOPrefs::instance()->mConfirm) {
3071 switch (msgItemDelete( jour->description().left(20))) { 3071 switch (msgItemDelete( jour->description().left(20))) {
3072 case KMessageBox::Continue: // OK 3072 case KMessageBox::Continue: // OK
3073 calendar()->deleteJournal(jour); 3073 calendar()->deleteJournal(jour);
3074 updateView(); 3074 updateView();
3075 break; 3075 break;
3076 } // switch 3076 } // switch
3077 } else { 3077 } else {
3078 calendar()->deleteJournal(jour);; 3078 calendar()->deleteJournal(jour);;
3079 updateView(); 3079 updateView();
3080 } 3080 }
3081 emit updateSearchDialog(); 3081 emit updateSearchDialog();
3082} 3082}
3083 3083
3084void CalendarView::deleteEvent(Event *anEvent) 3084void CalendarView::deleteEvent(Event *anEvent)
3085{ 3085{
3086 if (!anEvent) { 3086 if (!anEvent) {
3087 KNotifyClient::beep(); 3087 KNotifyClient::beep();
3088 return; 3088 return;
3089 } 3089 }
3090 3090
3091 if (anEvent->recurrence()->doesRecur()) { 3091 if (anEvent->recurrence()->doesRecur()) {
3092 QDate itemDate = mViewManager->currentSelectionDate(); 3092 QDate itemDate = mViewManager->currentSelectionDate();
3093 int km; 3093 int km;
3094 if (!itemDate.isValid()) { 3094 if (!itemDate.isValid()) {
3095 //kdDebug() << "Date Not Valid" << endl; 3095 //kdDebug() << "Date Not Valid" << endl;
3096 if (KOPrefs::instance()->mConfirm) { 3096 if (KOPrefs::instance()->mConfirm) {
3097 km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + 3097 km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) +
3098 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), 3098 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"),
3099 i18n("KO/Pi Confirmation"),i18n("Delete All")); 3099 i18n("KO/Pi Confirmation"),i18n("Delete All"));
3100 if ( km == KMessageBox::Continue ) 3100 if ( km == KMessageBox::Continue )
3101 km = KMessageBox::No; // No = all below 3101 km = KMessageBox::No; // No = all below
3102 } else 3102 } else
3103 km = KMessageBox::No; 3103 km = KMessageBox::No;
3104 } else { 3104 } else {
3105 km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + 3105 km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) +
3106 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ 3106 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+
3107 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), 3107 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"),
3108 i18n("KO/Pi Confirmation"),i18n("Current"), 3108 i18n("KO/Pi Confirmation"),i18n("Current"),
3109 i18n("All")); 3109 i18n("All"));
3110 } 3110 }
3111 switch(km) { 3111 switch(km) {
3112 3112
3113 case KMessageBox::No: // Continue // all 3113 case KMessageBox::No: // Continue // all
3114 //qDebug("KMessageBox::No "); 3114 //qDebug("KMessageBox::No ");
3115 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3115 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3116 schedule(Scheduler::Cancel,anEvent); 3116 schedule(Scheduler::Cancel,anEvent);
3117 3117
3118 checkExternalId( anEvent); 3118 checkExternalId( anEvent);
3119 mCalendar->deleteEvent(anEvent); 3119 mCalendar->deleteEvent(anEvent);
3120 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); 3120 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED);
3121 break; 3121 break;
3122 3122
3123 // Disabled because it does not work 3123 // Disabled because it does not work
3124 //#if 0 3124 //#if 0
3125 case KMessageBox::Yes: // just this one 3125 case KMessageBox::Yes: // just this one
3126 //QDate qd = mNavigator->selectedDates().first(); 3126 //QDate qd = mNavigator->selectedDates().first();
3127 //if (!qd.isValid()) { 3127 //if (!qd.isValid()) {
3128 // kdDebug() << "no date selected, or invalid date" << endl; 3128 // kdDebug() << "no date selected, or invalid date" << endl;
3129 // KNotifyClient::beep(); 3129 // KNotifyClient::beep();
3130 // return; 3130 // return;
3131 //} 3131 //}
3132 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); 3132 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1);
3133 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { 3133 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) {
3134 anEvent->addExDate(itemDate); 3134 anEvent->addExDate(itemDate);
3135 int duration = anEvent->recurrence()->duration(); 3135 int duration = anEvent->recurrence()->duration();
3136 if ( duration > 0 ) { 3136 if ( duration > 0 ) {
3137 anEvent->recurrence()->setDuration( duration - 1 ); 3137 anEvent->recurrence()->setDuration( duration - 1 );
3138 } 3138 }
3139 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); 3139 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED);
3140 } 3140 }
3141 break; 3141 break;
3142 //#endif 3142 //#endif
3143 } // switch 3143 } // switch
3144 } else { 3144 } else {
3145 if (KOPrefs::instance()->mConfirm) { 3145 if (KOPrefs::instance()->mConfirm) {
3146 switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + 3146 switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) +
3147 i18n("\nAre you sure you want\nto delete this event?"), 3147 i18n("\nAre you sure you want\nto delete this event?"),
3148 i18n("KO/Pi Confirmation"),i18n("Delete"))) { 3148 i18n("KO/Pi Confirmation"),i18n("Delete"))) {
3149 case KMessageBox::Continue: // OK 3149 case KMessageBox::Continue: // OK
3150 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3150 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3151 schedule(Scheduler::Cancel,anEvent); 3151 schedule(Scheduler::Cancel,anEvent);
3152 checkExternalId( anEvent); 3152 checkExternalId( anEvent);
3153 mCalendar->deleteEvent(anEvent); 3153 mCalendar->deleteEvent(anEvent);
3154 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3154 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3155 break; 3155 break;
3156 } // switch 3156 } // switch
3157 } else { 3157 } else {
3158 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3158 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3159 schedule(Scheduler::Cancel,anEvent); 3159 schedule(Scheduler::Cancel,anEvent);
3160 checkExternalId( anEvent); 3160 checkExternalId( anEvent);
3161 mCalendar->deleteEvent(anEvent); 3161 mCalendar->deleteEvent(anEvent);
3162 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3162 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3163 } 3163 }
3164 } // if-else 3164 } // if-else
3165 emit updateSearchDialog(); 3165 emit updateSearchDialog();
3166} 3166}
3167 3167
3168bool CalendarView::deleteEvent(const QString &uid) 3168bool CalendarView::deleteEvent(const QString &uid)
3169{ 3169{
3170 Event *ev = mCalendar->event(uid); 3170 Event *ev = mCalendar->event(uid);
3171 if (ev) { 3171 if (ev) {
3172 deleteEvent(ev); 3172 deleteEvent(ev);
3173 return true; 3173 return true;
3174 } else { 3174 } else {
3175 return false; 3175 return false;
3176 } 3176 }
3177} 3177}
3178 3178
3179/*****************************************************************************/ 3179/*****************************************************************************/
3180 3180
3181void CalendarView::action_mail() 3181void CalendarView::action_mail()
3182{ 3182{
3183#ifndef KORG_NOMAIL 3183#ifndef KORG_NOMAIL
3184 KOMailClient mailClient; 3184 KOMailClient mailClient;
3185 3185
3186 Incidence *incidence = currentSelection(); 3186 Incidence *incidence = currentSelection();
3187 3187
3188 if (!incidence) { 3188 if (!incidence) {
3189 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3189 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3190 return; 3190 return;
3191 } 3191 }
3192 if(incidence->attendeeCount() == 0 ) { 3192 if(incidence->attendeeCount() == 0 ) {
3193 KMessageBox::sorry(this, 3193 KMessageBox::sorry(this,
3194 i18n("Can't generate mail:\nNo attendees defined.\n")); 3194 i18n("Can't generate mail:\nNo attendees defined.\n"));
3195 return; 3195 return;
3196 } 3196 }
3197 3197
3198 CalendarLocal cal_tmp; 3198 CalendarLocal cal_tmp;
3199 Event *event = 0; 3199 Event *event = 0;
3200 Event *ev = 0; 3200 Event *ev = 0;
3201 if ( incidence && incidence->type() == "Event" ) { 3201 if ( incidence && incidence->type() == "Event" ) {
3202 event = static_cast<Event *>(incidence); 3202 event = static_cast<Event *>(incidence);
3203 ev = new Event(*event); 3203 ev = new Event(*event);
3204 cal_tmp.addEvent(ev); 3204 cal_tmp.addEvent(ev);
3205 } 3205 }
3206 ICalFormat mForm(); 3206 ICalFormat mForm();
3207 QString attachment = mForm.toString( &cal_tmp ); 3207 QString attachment = mForm.toString( &cal_tmp );
3208 if (ev) delete(ev); 3208 if (ev) delete(ev);
3209 3209
3210 mailClient.mailAttendees(currentSelection(), attachment); 3210 mailClient.mailAttendees(currentSelection(), attachment);
3211 3211
3212#endif 3212#endif
3213 3213
3214#if 0 3214#if 0
3215 Event *anEvent = 0; 3215 Event *anEvent = 0;
3216 if (mViewManager->currentView()->isEventView()) { 3216 if (mViewManager->currentView()->isEventView()) {
3217 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); 3217 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first());
3218 } 3218 }
3219 3219
3220 if (!anEvent) { 3220 if (!anEvent) {
3221 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3221 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3222 return; 3222 return;
3223 } 3223 }
3224 if(anEvent->attendeeCount() == 0 ) { 3224 if(anEvent->attendeeCount() == 0 ) {
3225 KMessageBox::sorry(this, 3225 KMessageBox::sorry(this,
3226 i18n("Can't generate mail:\nNo attendees defined.\n")); 3226 i18n("Can't generate mail:\nNo attendees defined.\n"));
3227 return; 3227 return;
3228 } 3228 }
3229 3229
3230 mailobject.emailEvent(anEvent); 3230 mailobject.emailEvent(anEvent);
3231#endif 3231#endif
3232} 3232}
3233 3233
3234 3234
3235void CalendarView::schedule_publish(Incidence *incidence) 3235void CalendarView::schedule_publish(Incidence *incidence)
3236{ 3236{
3237 Event *event = 0; 3237 Event *event = 0;
3238 Todo *todo = 0; 3238 Todo *todo = 0;
3239 3239
3240 if (incidence == 0) { 3240 if (incidence == 0) {
3241 incidence = mViewManager->currentView()->selectedIncidences().first(); 3241 incidence = mViewManager->currentView()->selectedIncidences().first();
3242 if (incidence == 0) { 3242 if (incidence == 0) {
3243 incidence = mTodoList->selectedIncidences().first(); 3243 incidence = mTodoList->selectedIncidences().first();
3244 } 3244 }
3245 } 3245 }
3246 if ( incidence && incidence->type() == "Event" ) { 3246 if ( incidence && incidence->type() == "Event" ) {
3247 event = static_cast<Event *>(incidence); 3247 event = static_cast<Event *>(incidence);
3248 } else { 3248 } else {
3249 if ( incidence && incidence->type() == "Todo" ) { 3249 if ( incidence && incidence->type() == "Todo" ) {
3250 todo = static_cast<Todo *>(incidence); 3250 todo = static_cast<Todo *>(incidence);
3251 } 3251 }
3252 } 3252 }
3253 3253
3254 if (!event && !todo) { 3254 if (!event && !todo) {
3255 KMessageBox::sorry(this,i18n("No event selected.")); 3255 KMessageBox::sorry(this,i18n("No event selected."));
3256 return; 3256 return;
3257 } 3257 }
3258 3258
3259 PublishDialog *publishdlg = new PublishDialog(); 3259 PublishDialog *publishdlg = new PublishDialog();
3260 if (incidence->attendeeCount()>0) { 3260 if (incidence->attendeeCount()>0) {
3261 QPtrList<Attendee> attendees = incidence->attendees(); 3261 QPtrList<Attendee> attendees = incidence->attendees();
3262 attendees.first(); 3262 attendees.first();
3263 while ( attendees.current()!=0 ) { 3263 while ( attendees.current()!=0 ) {
3264 publishdlg->addAttendee(attendees.current()); 3264 publishdlg->addAttendee(attendees.current());
3265 attendees.next(); 3265 attendees.next();
3266 } 3266 }
3267 } 3267 }
3268 bool send = true; 3268 bool send = true;
3269 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { 3269 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) {
3270 if ( publishdlg->exec() != QDialog::Accepted ) 3270 if ( publishdlg->exec() != QDialog::Accepted )
3271 send = false; 3271 send = false;
3272 } 3272 }
3273 if ( send ) { 3273 if ( send ) {
3274 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3274 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3275 if ( event ) { 3275 if ( event ) {
3276 Event *ev = new Event(*event); 3276 Event *ev = new Event(*event);
3277 ev->registerObserver(0); 3277 ev->registerObserver(0);
3278 ev->clearAttendees(); 3278 ev->clearAttendees();
3279 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3279 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3280 delete(ev); 3280 delete(ev);
3281 } 3281 }
3282 } else { 3282 } else {
3283 if ( todo ) { 3283 if ( todo ) {
3284 Todo *ev = new Todo(*todo); 3284 Todo *ev = new Todo(*todo);
3285 ev->registerObserver(0); 3285 ev->registerObserver(0);
3286 ev->clearAttendees(); 3286 ev->clearAttendees();
3287 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3287 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3288 delete(ev); 3288 delete(ev);
3289 } 3289 }
3290 } 3290 }
3291 } 3291 }
3292 } 3292 }
3293 delete publishdlg; 3293 delete publishdlg;
3294} 3294}
3295 3295
3296void CalendarView::schedule_request(Incidence *incidence) 3296void CalendarView::schedule_request(Incidence *incidence)
3297{ 3297{
3298 schedule(Scheduler::Request,incidence); 3298 schedule(Scheduler::Request,incidence);
3299} 3299}
3300 3300
3301void CalendarView::schedule_refresh(Incidence *incidence) 3301void CalendarView::schedule_refresh(Incidence *incidence)
3302{ 3302{
3303 schedule(Scheduler::Refresh,incidence); 3303 schedule(Scheduler::Refresh,incidence);
3304} 3304}
3305 3305
3306void CalendarView::schedule_cancel(Incidence *incidence) 3306void CalendarView::schedule_cancel(Incidence *incidence)
3307{ 3307{
3308 schedule(Scheduler::Cancel,incidence); 3308 schedule(Scheduler::Cancel,incidence);
3309} 3309}
3310 3310
3311void CalendarView::schedule_add(Incidence *incidence) 3311void CalendarView::schedule_add(Incidence *incidence)
3312{ 3312{
3313 schedule(Scheduler::Add,incidence); 3313 schedule(Scheduler::Add,incidence);
3314} 3314}
3315 3315
3316void CalendarView::schedule_reply(Incidence *incidence) 3316void CalendarView::schedule_reply(Incidence *incidence)
3317{ 3317{
3318 schedule(Scheduler::Reply,incidence); 3318 schedule(Scheduler::Reply,incidence);
3319} 3319}
3320 3320
3321void CalendarView::schedule_counter(Incidence *incidence) 3321void CalendarView::schedule_counter(Incidence *incidence)
3322{ 3322{
3323 schedule(Scheduler::Counter,incidence); 3323 schedule(Scheduler::Counter,incidence);
3324} 3324}
3325 3325
3326void CalendarView::schedule_declinecounter(Incidence *incidence) 3326void CalendarView::schedule_declinecounter(Incidence *incidence)
3327{ 3327{
3328 schedule(Scheduler::Declinecounter,incidence); 3328 schedule(Scheduler::Declinecounter,incidence);
3329} 3329}
3330 3330
3331void CalendarView::schedule_publish_freebusy(int daysToPublish) 3331void CalendarView::schedule_publish_freebusy(int daysToPublish)
3332{ 3332{
3333 QDateTime start = QDateTime::currentDateTime(); 3333 QDateTime start = QDateTime::currentDateTime();
3334 QDateTime end = start.addDays(daysToPublish); 3334 QDateTime end = start.addDays(daysToPublish);
3335 3335
3336 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); 3336 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end);
3337 freebusy->setOrganizer(KOPrefs::instance()->email()); 3337 freebusy->setOrganizer(KOPrefs::instance()->email());
3338 3338
3339 3339
3340 PublishDialog *publishdlg = new PublishDialog(); 3340 PublishDialog *publishdlg = new PublishDialog();
3341 if ( publishdlg->exec() == QDialog::Accepted ) { 3341 if ( publishdlg->exec() == QDialog::Accepted ) {
3342 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3342 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3343 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { 3343 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) {
3344 delete(freebusy); 3344 delete(freebusy);
3345 } 3345 }
3346 } 3346 }
3347 delete publishdlg; 3347 delete publishdlg;
3348} 3348}
3349 3349
3350void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) 3350void CalendarView::schedule(Scheduler::Method method, Incidence *incidence)
3351{ 3351{
3352 Event *event = 0; 3352 Event *event = 0;
3353 Todo *todo = 0; 3353 Todo *todo = 0;
3354 3354
3355 if (incidence == 0) { 3355 if (incidence == 0) {
3356 incidence = mViewManager->currentView()->selectedIncidences().first(); 3356 incidence = mViewManager->currentView()->selectedIncidences().first();
3357 if (incidence == 0) { 3357 if (incidence == 0) {
3358 incidence = mTodoList->selectedIncidences().first(); 3358 incidence = mTodoList->selectedIncidences().first();
3359 } 3359 }
3360 } 3360 }
3361 if ( incidence && incidence->type() == "Event" ) { 3361 if ( incidence && incidence->type() == "Event" ) {
3362 event = static_cast<Event *>(incidence); 3362 event = static_cast<Event *>(incidence);
3363 } 3363 }
3364 if ( incidence && incidence->type() == "Todo" ) { 3364 if ( incidence && incidence->type() == "Todo" ) {
3365 todo = static_cast<Todo *>(incidence); 3365 todo = static_cast<Todo *>(incidence);
3366 } 3366 }
3367 3367
3368 if (!event && !todo) { 3368 if (!event && !todo) {
3369 KMessageBox::sorry(this,i18n("No event selected.")); 3369 KMessageBox::sorry(this,i18n("No event selected."));
3370 return; 3370 return;
3371 } 3371 }
3372 3372
3373 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { 3373 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) {
3374 KMessageBox::sorry(this,i18n("The event has no attendees.")); 3374 KMessageBox::sorry(this,i18n("The event has no attendees."));
3375 return; 3375 return;
3376 } 3376 }
3377 3377
3378 Event *ev = 0; 3378 Event *ev = 0;
3379 if (event) ev = new Event(*event); 3379 if (event) ev = new Event(*event);
3380 Todo *to = 0; 3380 Todo *to = 0;
3381 if (todo) to = new Todo(*todo); 3381 if (todo) to = new Todo(*todo);
3382 3382
3383 if (method == Scheduler::Reply || method == Scheduler::Refresh) { 3383 if (method == Scheduler::Reply || method == Scheduler::Refresh) {
3384 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 3384 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
3385 if (!me) { 3385 if (!me) {
3386 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); 3386 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails."));
3387 return; 3387 return;
3388 } 3388 }
3389 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { 3389 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) {
3390 StatusDialog *statdlg = new StatusDialog(this); 3390 StatusDialog *statdlg = new StatusDialog(this);
3391 if (!statdlg->exec()==QDialog::Accepted) return; 3391 if (!statdlg->exec()==QDialog::Accepted) return;
3392 me->setStatus( statdlg->status() ); 3392 me->setStatus( statdlg->status() );
3393 delete(statdlg); 3393 delete(statdlg);
3394 } 3394 }
3395 Attendee *menew = new Attendee(*me); 3395 Attendee *menew = new Attendee(*me);
3396 if (ev) { 3396 if (ev) {
3397 ev->clearAttendees(); 3397 ev->clearAttendees();
3398 ev->addAttendee(menew,false); 3398 ev->addAttendee(menew,false);
3399 } else { 3399 } else {
3400 if (to) { 3400 if (to) {
3401 todo->clearAttendees(); 3401 todo->clearAttendees();
3402 todo->addAttendee(menew,false); 3402 todo->addAttendee(menew,false);
3403 } 3403 }
3404 } 3404 }
3405 } 3405 }
3406 3406
3407 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3407 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3408 if (ev) { 3408 if (ev) {
3409 if ( !dlg->addMessage(ev,method) ) delete(ev); 3409 if ( !dlg->addMessage(ev,method) ) delete(ev);
3410 } else { 3410 } else {
3411 if (to) { 3411 if (to) {
3412 if ( !dlg->addMessage(to,method) ) delete(to); 3412 if ( !dlg->addMessage(to,method) ) delete(to);
3413 } 3413 }
3414 } 3414 }
3415} 3415}
3416 3416
3417void CalendarView::openAddressbook() 3417void CalendarView::openAddressbook()
3418{ 3418{
3419 KRun::runCommand("kaddressbook"); 3419 KRun::runCommand("kaddressbook");
3420} 3420}
3421 3421
3422void CalendarView::setModified(bool modified) 3422void CalendarView::setModified(bool modified)
3423{ 3423{
3424 if ( modified ) 3424 if ( modified )
3425 emit signalmodified(); 3425 emit signalmodified();
3426 if (mModified != modified) { 3426 if (mModified != modified) {
3427 mModified = modified; 3427 mModified = modified;
3428 emit modifiedChanged(mModified); 3428 emit modifiedChanged(mModified);
3429 } 3429 }
3430} 3430}
3431 3431
3432bool CalendarView::isReadOnly() 3432bool CalendarView::isReadOnly()
3433{ 3433{
3434 return mReadOnly; 3434 return mReadOnly;
3435} 3435}
3436 3436
3437void CalendarView::setReadOnly(bool readOnly) 3437void CalendarView::setReadOnly(bool readOnly)
3438{ 3438{
3439 if (mReadOnly != readOnly) { 3439 if (mReadOnly != readOnly) {
3440 mReadOnly = readOnly; 3440 mReadOnly = readOnly;
3441 emit readOnlyChanged(mReadOnly); 3441 emit readOnlyChanged(mReadOnly);
3442 } 3442 }
3443} 3443}
3444 3444
3445bool CalendarView::isModified() 3445bool CalendarView::isModified()
3446{ 3446{
3447 return mModified; 3447 return mModified;
3448} 3448}
3449void CalendarView::slotprintSelInc() 3449void CalendarView::slotprintSelInc()
3450{ 3450{
3451 if ( currentSelection() == 0 ) { 3451 if ( currentSelection() == 0 ) {
3452 KMessageBox::sorry(this,i18n("There is nothing selected!")); 3452 KMessageBox::sorry(this,i18n("There is nothing selected!"));
3453 return; 3453 return;
3454 } 3454 }
3455 showIncidence(); 3455 showIncidence();
3456 getEventViewerDialog()->print(); 3456 getEventViewerDialog()->print();
3457 3457
3458} 3458}
3459void CalendarView::printSetup() 3459void CalendarView::printSetup()
3460{ 3460{
3461#ifndef KORG_NOPRINTER 3461#ifndef KORG_NOPRINTER
3462 createPrinter(); 3462 createPrinter();
3463 3463
3464 mCalPrinter->setupPrinter(); 3464 mCalPrinter->setupPrinter();
3465#endif 3465#endif
3466} 3466}
3467 3467
3468void CalendarView::print() 3468void CalendarView::print()
3469{ 3469{
3470#ifndef KORG_NOPRINTER 3470#ifndef KORG_NOPRINTER
3471 createPrinter(); 3471 createPrinter();
3472 3472
3473 DateList tmpDateList = mNavigator->selectedDates(); 3473 DateList tmpDateList = mNavigator->selectedDates();
3474 mCalPrinter->print(CalPrinter::Month, 3474 mCalPrinter->print(CalPrinter::Month,
3475 tmpDateList.first(), tmpDateList.last()); 3475 tmpDateList.first(), tmpDateList.last());
3476#endif 3476#endif
3477} 3477}
3478 3478
3479void CalendarView::printPreview() 3479void CalendarView::printPreview()
3480{ 3480{
3481#ifndef KORG_NOPRINTER 3481#ifndef KORG_NOPRINTER
3482 kdDebug() << "CalendarView::printPreview()" << endl; 3482 kdDebug() << "CalendarView::printPreview()" << endl;
3483 3483
3484 createPrinter(); 3484 createPrinter();
3485 3485
3486 DateList tmpDateList = mNavigator->selectedDates(); 3486 DateList tmpDateList = mNavigator->selectedDates();
3487 3487
3488 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), 3488 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(),
3489 tmpDateList.last()); 3489 tmpDateList.last());
3490#endif 3490#endif
3491} 3491}
3492 3492
3493void CalendarView::exportICalendar() 3493void CalendarView::exportICalendar()
3494{ 3494{
3495 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); 3495 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this);
3496 3496
3497 // Force correct extension 3497 // Force correct extension
3498 if (filename.right(4) != ".ics") filename += ".ics"; 3498 if (filename.right(4) != ".ics") filename += ".ics";
3499 3499
3500 FileStorage storage( mCalendar, filename, new ICalFormat() ); 3500 FileStorage storage( mCalendar, filename, new ICalFormat() );
3501 storage.save(); 3501 storage.save();
3502} 3502}
3503 3503
3504bool CalendarView::exportVCalendar( QString filename ) 3504bool CalendarView::exportVCalendar( QString filename )
3505{ 3505{
3506 if (mCalendar->journals().count() > 0) { 3506 if (mCalendar->journals().count() > 0) {
3507 int result = KMessageBox::warningContinueCancel(this, 3507 int result = KMessageBox::warningContinueCancel(this,
3508 i18n("The journal entries can not be\nexported to a vCalendar file."), 3508 i18n("The journal entries can not be\nexported to a vCalendar file."),
3509 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 3509 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
3510 true); 3510 true);
3511 if (result != KMessageBox::Continue) return false; 3511 if (result != KMessageBox::Continue) return false;
3512 } 3512 }
3513 3513
3514 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); 3514 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this);
3515 3515
3516 // Force correct extension 3516 // Force correct extension
3517 if (filename.right(4) != ".vcs") filename += ".vcs"; 3517 if (filename.right(4) != ".vcs") filename += ".vcs";
3518 3518
3519 FileStorage storage( mCalendar, filename, new VCalFormat ); 3519 FileStorage storage( mCalendar, filename, new VCalFormat );
3520 return storage.save(); 3520 return storage.save();
3521 3521
3522} 3522}
3523 3523
3524void CalendarView::eventUpdated(Incidence *) 3524void CalendarView::eventUpdated(Incidence *)
3525{ 3525{
3526 setModified(); 3526 setModified();
3527 // Don't call updateView here. The code, which has caused the update of the 3527 // Don't call updateView here. The code, which has caused the update of the
3528 // event is responsible for updating the view. 3528 // event is responsible for updating the view.
3529 // updateView(); 3529 // updateView();
3530} 3530}
3531 3531
3532void CalendarView::adaptNavigationUnits() 3532void CalendarView::adaptNavigationUnits()
3533{ 3533{
3534 if (mViewManager->currentView()->isEventView()) { 3534 if (mViewManager->currentView()->isEventView()) {
3535 int days = mViewManager->currentView()->currentDateCount(); 3535 int days = mViewManager->currentView()->currentDateCount();
3536 if (days == 1) { 3536 if (days == 1) {
3537 emit changeNavStringPrev(i18n("&Previous Day")); 3537 emit changeNavStringPrev(i18n("&Previous Day"));
3538 emit changeNavStringNext(i18n("&Next Day")); 3538 emit changeNavStringNext(i18n("&Next Day"));
3539 } else { 3539 } else {
3540 emit changeNavStringPrev(i18n("&Previous Week")); 3540 emit changeNavStringPrev(i18n("&Previous Week"));
3541 emit changeNavStringNext(i18n("&Next Week")); 3541 emit changeNavStringNext(i18n("&Next Week"));
3542 } 3542 }
3543 } 3543 }
3544} 3544}
3545 3545
3546void CalendarView::processMainViewSelection( Incidence *incidence ) 3546void CalendarView::processMainViewSelection( Incidence *incidence )
3547{ 3547{
3548 if ( incidence ) mTodoList->clearSelection(); 3548 if ( incidence ) mTodoList->clearSelection();
3549 processIncidenceSelection( incidence ); 3549 processIncidenceSelection( incidence );
3550} 3550}
3551 3551
3552void CalendarView::processTodoListSelection( Incidence *incidence ) 3552void CalendarView::processTodoListSelection( Incidence *incidence )
3553{ 3553{
3554 if ( incidence && mViewManager->currentView() ) { 3554 if ( incidence && mViewManager->currentView() ) {
3555 mViewManager->currentView()->clearSelection(); 3555 mViewManager->currentView()->clearSelection();
3556 } 3556 }
3557 processIncidenceSelection( incidence ); 3557 processIncidenceSelection( incidence );
3558} 3558}
3559 3559
3560void CalendarView::processIncidenceSelection( Incidence *incidence ) 3560void CalendarView::processIncidenceSelection( Incidence *incidence )
3561{ 3561{
3562 if ( incidence == mSelectedIncidence ) return; 3562 if ( incidence == mSelectedIncidence ) return;
3563 3563
3564 mSelectedIncidence = incidence; 3564 mSelectedIncidence = incidence;
3565 3565
3566 emit incidenceSelected( mSelectedIncidence ); 3566 emit incidenceSelected( mSelectedIncidence );
3567 3567
3568 if ( incidence && incidence->type() == "Event" ) { 3568 if ( incidence && incidence->type() == "Event" ) {
3569 Event *event = static_cast<Event *>( incidence ); 3569 Event *event = static_cast<Event *>( incidence );
3570 if ( event->organizer() == KOPrefs::instance()->email() ) { 3570 if ( event->organizer() == KOPrefs::instance()->email() ) {
3571 emit organizerEventsSelected( true ); 3571 emit organizerEventsSelected( true );
3572 } else { 3572 } else {
3573 emit organizerEventsSelected(false); 3573 emit organizerEventsSelected(false);
3574 } 3574 }
3575 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3575 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3576 KOPrefs::instance()->email() ) ) { 3576 KOPrefs::instance()->email() ) ) {
3577 emit groupEventsSelected( true ); 3577 emit groupEventsSelected( true );
3578 } else { 3578 } else {
3579 emit groupEventsSelected(false); 3579 emit groupEventsSelected(false);
3580 } 3580 }
3581 return; 3581 return;
3582 } else { 3582 } else {
3583 if ( incidence && incidence->type() == "Todo" ) { 3583 if ( incidence && incidence->type() == "Todo" ) {
3584 emit todoSelected( true ); 3584 emit todoSelected( true );
3585 Todo *event = static_cast<Todo *>( incidence ); 3585 Todo *event = static_cast<Todo *>( incidence );
3586 if ( event->organizer() == KOPrefs::instance()->email() ) { 3586 if ( event->organizer() == KOPrefs::instance()->email() ) {
3587 emit organizerEventsSelected( true ); 3587 emit organizerEventsSelected( true );
3588 } else { 3588 } else {
3589 emit organizerEventsSelected(false); 3589 emit organizerEventsSelected(false);
3590 } 3590 }
3591 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3591 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3592 KOPrefs::instance()->email() ) ) { 3592 KOPrefs::instance()->email() ) ) {
3593 emit groupEventsSelected( true ); 3593 emit groupEventsSelected( true );
3594 } else { 3594 } else {
3595 emit groupEventsSelected(false); 3595 emit groupEventsSelected(false);
3596 } 3596 }
3597 return; 3597 return;
3598 } else { 3598 } else {
3599 emit todoSelected( false ); 3599 emit todoSelected( false );
3600 emit organizerEventsSelected(false); 3600 emit organizerEventsSelected(false);
3601 emit groupEventsSelected(false); 3601 emit groupEventsSelected(false);
3602 } 3602 }
3603 return; 3603 return;
3604 } 3604 }
3605 3605
3606 /* if ( incidence && incidence->type() == "Todo" ) { 3606 /* if ( incidence && incidence->type() == "Todo" ) {
3607 emit todoSelected( true ); 3607 emit todoSelected( true );
3608 } else { 3608 } else {
3609 emit todoSelected( false ); 3609 emit todoSelected( false );
3610 }*/ 3610 }*/
3611} 3611}
3612 3612
3613 3613
3614void CalendarView::checkClipboard() 3614void CalendarView::checkClipboard()
3615{ 3615{
3616#ifndef KORG_NODND 3616#ifndef KORG_NODND
3617 if (ICalDrag::canDecode(QApplication::clipboard()->data())) { 3617 if (ICalDrag::canDecode(QApplication::clipboard()->data())) {
3618 emit pasteEnabled(true); 3618 emit pasteEnabled(true);
3619 } else { 3619 } else {
3620 emit pasteEnabled(false); 3620 emit pasteEnabled(false);
3621 } 3621 }
3622#endif 3622#endif
3623} 3623}
3624 3624
3625void CalendarView::showDates(const DateList &selectedDates) 3625void CalendarView::showDates(const DateList &selectedDates)
3626{ 3626{
3627 // kdDebug() << "CalendarView::selectDates()" << endl; 3627 // kdDebug() << "CalendarView::selectDates()" << endl;
3628 3628
3629 3629
3630 if ( !mBlockShowDates ) { 3630 if ( !mBlockShowDates ) {
3631 if ( mViewManager->currentView() ) { 3631 if ( mViewManager->currentView() ) {
3632 updateView( selectedDates.first(), selectedDates.last() ); 3632 updateView( selectedDates.first(), selectedDates.last() );
3633 } else { 3633 } else {
3634 mViewManager->showAgendaView(); 3634 mViewManager->showAgendaView();
3635 } 3635 }
3636 } 3636 }
3637 3637
3638 QDate date = selectedDates.first(); 3638 QDate date = selectedDates.first();
3639 if ( ! date.isValid() ) { 3639 if ( ! date.isValid() ) {
3640 topLevelWidget()->setCaption(""); 3640 topLevelWidget()->setCaption("");
3641 return; 3641 return;
3642 } 3642 }
3643 3643
3644 QString selDates; 3644 QString selDates;
3645 selDates = KGlobal::locale()->formatDate( date, true); 3645 selDates = KGlobal::locale()->formatDate( date, true);
3646 if (selectedDates.first() < selectedDates.last() ) 3646 if (selectedDates.first() < selectedDates.last() )
3647 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); 3647 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true);
3648 else { 3648 else {
3649 QString addString; 3649 QString addString;
3650 if ( date == QDateTime::currentDateTime().date() ) 3650 if ( date == QDateTime::currentDateTime().date() )
3651 addString = i18n("Today"); 3651 addString = i18n("Today");
3652 else if ( date == QDateTime::currentDateTime().date().addDays(1) ) 3652 else if ( date == QDateTime::currentDateTime().date().addDays(1) )
3653 addString = i18n("Tomorrow"); 3653 addString = i18n("Tomorrow");
3654 else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) 3654 else if ( date == QDateTime::currentDateTime().date().addDays(-1) )
3655 addString = i18n("Yesterday"); 3655 addString = i18n("Yesterday");
3656 else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) 3656 else if ( date == QDateTime::currentDateTime().date().addDays(-2) )
3657 addString = i18n("Day before yesterday"); 3657 addString = i18n("Day before yesterday");
3658 else if ( date == QDateTime::currentDateTime().date().addDays(2) ) 3658 else if ( date == QDateTime::currentDateTime().date().addDays(2) )
3659 addString = i18n("Day after tomorrow"); 3659 addString = i18n("Day after tomorrow");
3660 if ( !addString.isEmpty() ) { 3660 if ( !addString.isEmpty() ) {
3661 topLevelWidget()->setCaption( addString+", " + selDates ); 3661 topLevelWidget()->setCaption( addString+", " + selDates );
3662 return; 3662 return;
3663 } 3663 }
3664 } 3664 }
3665 topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); 3665 topLevelWidget()->setCaption( i18n("Dates: ") + selDates );
3666 3666
3667} 3667}
3668 3668
3669QPtrList<CalFilter> CalendarView::filters() 3669QPtrList<CalFilter> CalendarView::filters()
3670{ 3670{
3671 return mFilters; 3671 return mFilters;
3672 3672
3673} 3673}
3674void CalendarView::editFilters() 3674void CalendarView::editFilters()
3675{ 3675{
3676 // kdDebug() << "CalendarView::editFilters()" << endl; 3676 // kdDebug() << "CalendarView::editFilters()" << endl;
3677 3677
3678 CalFilter *filter = mFilters.first(); 3678 CalFilter *filter = mFilters.first();
3679 while(filter) { 3679 while(filter) {
3680 kdDebug() << " Filter: " << filter->name() << endl; 3680 kdDebug() << " Filter: " << filter->name() << endl;
3681 filter = mFilters.next(); 3681 filter = mFilters.next();
3682 } 3682 }
3683 3683
3684 mDialogManager->showFilterEditDialog(&mFilters); 3684 mDialogManager->showFilterEditDialog(&mFilters);
3685} 3685}
3686void CalendarView::toggleFilter() 3686void CalendarView::toggleFilter()
3687{ 3687{
3688 showFilter(! mFilterView->isVisible()); 3688 showFilter(! mFilterView->isVisible());
3689} 3689}
3690 3690
3691KOFilterView *CalendarView::filterView() 3691KOFilterView *CalendarView::filterView()
3692{ 3692{
3693 return mFilterView; 3693 return mFilterView;
3694} 3694}
3695void CalendarView::selectFilter( int fil ) 3695void CalendarView::selectFilter( int fil )
3696{ 3696{
3697 mFilterView->setSelectedFilter( fil ); 3697 mFilterView->setSelectedFilter( fil );
3698} 3698}
3699void CalendarView::showFilter(bool visible) 3699void CalendarView::showFilter(bool visible)
3700{ 3700{
3701 if (visible) mFilterView->show(); 3701 if (visible) mFilterView->show();
3702 else mFilterView->hide(); 3702 else mFilterView->hide();
3703} 3703}
3704void CalendarView::toggleFilerEnabled( ) 3704void CalendarView::toggleFilerEnabled( )
3705{ 3705{
3706 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); 3706 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() );
3707 if ( !mFilterView->filtersEnabled() ) 3707 if ( !mFilterView->filtersEnabled() )
3708 topLevelWidget()->setCaption( i18n("Filter disabled ") ); 3708 topLevelWidget()->setCaption( i18n("Filter disabled ") );
3709 3709
3710} 3710}
3711void CalendarView::updateFilter() 3711void CalendarView::updateFilter()
3712{ 3712{
3713 CalFilter *filter = mFilterView->selectedFilter(); 3713 CalFilter *filter = mFilterView->selectedFilter();
3714 if (filter) { 3714 if (filter) {
3715 QString mess; 3715 QString mess;
3716 if (mFilterView->filtersEnabled()) { 3716 if (mFilterView->filtersEnabled()) {
3717 mess = i18n("Filter selected: ")+filter->name(); 3717 mess = i18n("Filter selected: ")+filter->name();
3718 filter->setEnabled(true); 3718 filter->setEnabled(true);
3719 } 3719 }
3720 else filter->setEnabled(false); 3720 else filter->setEnabled(false);
3721 mCalendar->setFilter(filter); 3721 mCalendar->setFilter(filter);
3722 updateView(); 3722 updateView();
3723 if ( !mess.isEmpty() ) 3723 if ( !mess.isEmpty() )
3724 topLevelWidget()->setCaption( mess ); 3724 topLevelWidget()->setCaption( mess );
3725 3725
3726 } 3726 }
3727} 3727}
3728 3728
3729void CalendarView::filterEdited() 3729void CalendarView::filterEdited()
3730{ 3730{
3731 mFilterView->updateFilters(); 3731 mFilterView->updateFilters();
3732 updateFilter(); 3732 updateFilter();
3733 writeSettings(); 3733 writeSettings();
3734} 3734}
3735 3735
3736 3736
3737void CalendarView::takeOverEvent() 3737void CalendarView::takeOverEvent()
3738{ 3738{
3739 Incidence *incidence = currentSelection(); 3739 Incidence *incidence = currentSelection();
3740 3740
3741 if (!incidence) return; 3741 if (!incidence) return;
3742 3742
3743 incidence->setOrganizer(KOPrefs::instance()->email()); 3743 incidence->setOrganizer(KOPrefs::instance()->email());
3744 incidence->recreate(); 3744 incidence->recreate();
3745 incidence->setReadOnly(false); 3745 incidence->setReadOnly(false);
3746 3746
3747 updateView(); 3747 updateView();
3748} 3748}
3749 3749
3750void CalendarView::takeOverCalendar() 3750void CalendarView::takeOverCalendar()
3751{ 3751{
3752 // TODO: Create Calendar::allIncidences() function and use it here 3752 // TODO: Create Calendar::allIncidences() function and use it here
3753 3753
3754 QPtrList<Event> events = mCalendar->events(); 3754 QPtrList<Event> events = mCalendar->events();
3755 for(uint i=0; i<events.count(); ++i) { 3755 for(uint i=0; i<events.count(); ++i) {
3756 events.at(i)->setOrganizer(KOPrefs::instance()->email()); 3756 events.at(i)->setOrganizer(KOPrefs::instance()->email());
3757 events.at(i)->recreate(); 3757 events.at(i)->recreate();
3758 events.at(i)->setReadOnly(false); 3758 events.at(i)->setReadOnly(false);
3759 } 3759 }
3760 3760
3761 QPtrList<Todo> todos = mCalendar->todos(); 3761 QPtrList<Todo> todos = mCalendar->todos();
3762 for(uint i=0; i<todos.count(); ++i) { 3762 for(uint i=0; i<todos.count(); ++i) {
3763 todos.at(i)->setOrganizer(KOPrefs::instance()->email()); 3763 todos.at(i)->setOrganizer(KOPrefs::instance()->email());
3764 todos.at(i)->recreate(); 3764 todos.at(i)->recreate();
3765 todos.at(i)->setReadOnly(false); 3765 todos.at(i)->setReadOnly(false);
3766 } 3766 }
3767 3767
3768 QPtrList<Journal> journals = mCalendar->journals(); 3768 QPtrList<Journal> journals = mCalendar->journals();
3769 for(uint i=0; i<journals.count(); ++i) { 3769 for(uint i=0; i<journals.count(); ++i) {
3770 journals.at(i)->setOrganizer(KOPrefs::instance()->email()); 3770 journals.at(i)->setOrganizer(KOPrefs::instance()->email());
3771 journals.at(i)->recreate(); 3771 journals.at(i)->recreate();
3772 journals.at(i)->setReadOnly(false); 3772 journals.at(i)->setReadOnly(false);
3773 } 3773 }
3774 3774
3775 updateView(); 3775 updateView();
3776} 3776}
3777 3777
3778void CalendarView::showIntro() 3778void CalendarView::showIntro()
3779{ 3779{
3780 kdDebug() << "To be implemented." << endl; 3780 kdDebug() << "To be implemented." << endl;
3781} 3781}
3782 3782
3783QWidgetStack *CalendarView::viewStack() 3783QWidgetStack *CalendarView::viewStack()
3784{ 3784{
3785 return mRightFrame; 3785 return mRightFrame;
3786} 3786}
3787 3787
3788QWidget *CalendarView::leftFrame() 3788QWidget *CalendarView::leftFrame()
3789{ 3789{
3790 return ( QWidget *)mLeftFrame; 3790 return ( QWidget *)mLeftFrame;
3791} 3791}
3792 3792
3793DateNavigator *CalendarView::dateNavigator() 3793DateNavigator *CalendarView::dateNavigator()
3794{ 3794{
3795 return mNavigator; 3795 return mNavigator;
3796} 3796}
3797 3797
3798KDateNavigator* CalendarView::dateNavigatorWidget() 3798KDateNavigator* CalendarView::dateNavigatorWidget()
3799{ 3799{
3800 return mDateNavigator->navigatorView(); 3800 return mDateNavigator->navigatorView();
3801} 3801}
3802void CalendarView::toggleDateNavigatorWidget() 3802void CalendarView::toggleDateNavigatorWidget()
3803{ 3803{
3804 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; 3804 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ;
3805 3805
3806 if (!KOPrefs::instance()->mShowDateNavigator ) 3806 if (!KOPrefs::instance()->mShowDateNavigator )
3807 mDateNavigator->hide(); 3807 mDateNavigator->hide();
3808 else 3808 else
3809 mDateNavigator->show(); 3809 mDateNavigator->show();
3810} 3810}
3811void CalendarView::addView(KOrg::BaseView *view) 3811void CalendarView::addView(KOrg::BaseView *view)
3812{ 3812{
3813 mViewManager->addView(view); 3813 mViewManager->addView(view);
3814} 3814}
3815 3815
3816void CalendarView::showView(KOrg::BaseView *view) 3816void CalendarView::showView(KOrg::BaseView *view)
3817{ 3817{
3818 mViewManager->showView(view, mLeftFrame->isVisible()); 3818 mViewManager->showView(view, mLeftFrame->isVisible());
3819} 3819}
3820 3820
3821Incidence *CalendarView::currentSelection() 3821Incidence *CalendarView::currentSelection()
3822{ 3822{
3823 return mViewManager->currentSelection(); 3823 return mViewManager->currentSelection();
3824} 3824}
3825void CalendarView::toggleAllDaySize() 3825void CalendarView::toggleAllDaySize()
3826{ 3826{
3827 /* 3827 /*
3828 if ( KOPrefs::instance()->mAllDaySize > 47 ) 3828 if ( KOPrefs::instance()->mAllDaySize > 47 )
3829 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; 3829 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2;
3830 else 3830 else
3831 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; 3831 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2;
3832 */ 3832 */
3833 viewManager()->agendaView()->toggleAllDay(); 3833 viewManager()->agendaView()->toggleAllDay();
3834} 3834}
3835void CalendarView::toggleExpand() 3835void CalendarView::toggleExpand()
3836{ 3836{
3837 // if ( mLeftFrame->isHidden() ) { 3837 // if ( mLeftFrame->isHidden() ) {
3838 // mLeftFrame->show(); 3838 // mLeftFrame->show();
3839 // emit calendarViewExpanded( false ); 3839 // emit calendarViewExpanded( false );
3840 // } else { 3840 // } else {
3841 // mLeftFrame->hide(); 3841 // mLeftFrame->hide();
3842 // emit calendarViewExpanded( true ); 3842 // emit calendarViewExpanded( true );
3843 // } 3843 // }
3844 //qDebug(" CalendarView::toggleExpand()"); 3844 //qDebug(" CalendarView::toggleExpand()");
3845 globalFlagBlockAgenda = 1; 3845 globalFlagBlockAgenda = 1;
3846 emit calendarViewExpanded( !mLeftFrame->isHidden() ); 3846 emit calendarViewExpanded( !mLeftFrame->isHidden() );
3847 globalFlagBlockAgenda = 5; 3847 globalFlagBlockAgenda = 5;
3848 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); 3848 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() );
3849 //mViewManager->showView( 0, true ); 3849 //mViewManager->showView( 0, true );
3850} 3850}
3851 3851
3852void CalendarView::calendarModified( bool modified, Calendar * ) 3852void CalendarView::calendarModified( bool modified, Calendar * )
3853{ 3853{
3854 setModified( modified ); 3854 setModified( modified );
3855} 3855}
3856 3856
3857Todo *CalendarView::selectedTodo() 3857Todo *CalendarView::selectedTodo()
3858{ 3858{
3859 Incidence *incidence = currentSelection(); 3859 Incidence *incidence = currentSelection();
3860 if ( incidence && incidence->type() == "Todo" ) { 3860 if ( incidence && incidence->type() == "Todo" ) {
3861 return static_cast<Todo *>( incidence ); 3861 return static_cast<Todo *>( incidence );
3862 } 3862 }
3863 3863
3864 incidence = mTodoList->selectedIncidences().first(); 3864 incidence = mTodoList->selectedIncidences().first();
3865 if ( incidence && incidence->type() == "Todo" ) { 3865 if ( incidence && incidence->type() == "Todo" ) {
3866 return static_cast<Todo *>( incidence ); 3866 return static_cast<Todo *>( incidence );
3867 } 3867 }
3868 3868
3869 return 0; 3869 return 0;
3870} 3870}
3871 3871
3872void CalendarView::dialogClosing(Incidence *in) 3872void CalendarView::dialogClosing(Incidence *in)
3873{ 3873{
3874 // mDialogList.remove(in); 3874 // mDialogList.remove(in);
3875} 3875}
3876 3876
3877void CalendarView::showIncidence() 3877void CalendarView::showIncidence()
3878{ 3878{
3879 mViewerCallerIsSearchDialog = false; 3879 mViewerCallerIsSearchDialog = false;
3880 Incidence *incidence = currentSelection(); 3880 Incidence *incidence = currentSelection();
3881 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3881 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3882 if ( incidence ) { 3882 if ( incidence ) {
3883 ShowIncidenceVisitor v; 3883 ShowIncidenceVisitor v;
3884 v.act( incidence, this ); 3884 v.act( incidence, this );
3885 } 3885 }
3886} 3886}
3887void CalendarView::editIncidenceDescription() 3887void CalendarView::editIncidenceDescription()
3888{ 3888{
3889 mFlagEditDescription = true; 3889 mFlagEditDescription = true;
3890 editIncidence(); 3890 editIncidence();
3891 mFlagEditDescription = false; 3891 mFlagEditDescription = false;
3892} 3892}
3893void CalendarView::editIncidence() 3893void CalendarView::editIncidence()
3894{ 3894{
3895 // qDebug("editIncidence() "); 3895 // qDebug("editIncidence() ");
3896 Incidence *incidence = currentSelection(); 3896 Incidence *incidence = currentSelection();
3897 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3897 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3898 if ( incidence ) { 3898 if ( incidence ) {
3899 EditIncidenceVisitor v; 3899 EditIncidenceVisitor v;
3900 v.act( incidence, this ); 3900 v.act( incidence, this );
3901 } 3901 }
3902} 3902}
3903 3903
3904void CalendarView::deleteIncidence() 3904void CalendarView::deleteIncidence()
3905{ 3905{
3906 Incidence *incidence = currentSelection(); 3906 Incidence *incidence = currentSelection();
3907 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3907 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3908 if ( incidence ) { 3908 if ( incidence ) {
3909 deleteIncidence(incidence); 3909 deleteIncidence(incidence);
3910 } 3910 }
3911} 3911}
3912 3912
3913void CalendarView::showIncidence(Incidence *incidence) 3913void CalendarView::showIncidence(Incidence *incidence)
3914{ 3914{
3915 mViewerCallerIsSearchDialog = false; 3915 mViewerCallerIsSearchDialog = false;
3916 //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); 3916 //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() );
3917 if ( sender() && mDialogManager->getSearchDialog() ) { 3917 if ( sender() && mDialogManager->getSearchDialog() ) {
3918 if ( sender () == mDialogManager->getSearchDialog()->listview() ) { 3918 if ( sender () == mDialogManager->getSearchDialog()->listview() ) {
3919 mViewerCallerIsSearchDialog = true; 3919 mViewerCallerIsSearchDialog = true;
3920 } 3920 }
3921 } 3921 }
3922 if ( incidence ) { 3922 if ( incidence ) {
3923 ShowIncidenceVisitor v; 3923 ShowIncidenceVisitor v;
3924 v.act( incidence, this ); 3924 v.act( incidence, this );
3925 } 3925 }
3926} 3926}
3927 3927
3928void CalendarView::editIncidence(Incidence *incidence) 3928void CalendarView::editIncidence(Incidence *incidence)
3929{ 3929{
3930 if ( incidence ) { 3930 if ( incidence ) {
3931 3931
3932 EditIncidenceVisitor v; 3932 EditIncidenceVisitor v;
3933 v.act( incidence, this ); 3933 v.act( incidence, this );
3934 3934
3935 } 3935 }
3936} 3936}
3937 3937
3938void CalendarView::deleteIncidence(Incidence *incidence) 3938void CalendarView::deleteIncidence(Incidence *incidence)
3939{ 3939{
3940 //qDebug(" CalendarView::deleteIncidence "); 3940 //qDebug(" CalendarView::deleteIncidence ");
3941 if ( incidence ) { 3941 if ( incidence ) {
3942 DeleteIncidenceVisitor v; 3942 DeleteIncidenceVisitor v;
3943 v.act( incidence, this ); 3943 v.act( incidence, this );
3944 } 3944 }
3945} 3945}
3946 3946
3947 3947
3948void CalendarView::lookForOutgoingMessages() 3948void CalendarView::lookForOutgoingMessages()
3949{ 3949{
3950 OutgoingDialog *ogd = mDialogManager->outgoingDialog(); 3950 OutgoingDialog *ogd = mDialogManager->outgoingDialog();
3951 ogd->loadMessages(); 3951 ogd->loadMessages();
3952} 3952}
3953 3953
3954void CalendarView::lookForIncomingMessages() 3954void CalendarView::lookForIncomingMessages()
3955{ 3955{
3956 IncomingDialog *icd = mDialogManager->incomingDialog(); 3956 IncomingDialog *icd = mDialogManager->incomingDialog();
3957 icd->retrieve(); 3957 icd->retrieve();
3958} 3958}
3959 3959
3960bool CalendarView::removeCompletedSubTodos( Todo* t ) 3960bool CalendarView::removeCompletedSubTodos( Todo* t )
3961{ 3961{
3962 bool deleteTodo = true; 3962 bool deleteTodo = true;
3963 QPtrList<Incidence> subTodos; 3963 QPtrList<Incidence> subTodos;
3964 Incidence *aTodo; 3964 Incidence *aTodo;
3965 subTodos = t->relations(); 3965 subTodos = t->relations();
3966 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { 3966 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
3967 if (! removeCompletedSubTodos( (Todo*) aTodo )) 3967 if (! removeCompletedSubTodos( (Todo*) aTodo ))
3968 deleteTodo = false; 3968 deleteTodo = false;
3969 } 3969 }
3970 if ( deleteTodo ) { 3970 if ( deleteTodo ) {
3971 if ( t->isCompleted() && !t->doesRecur()) { 3971 if ( t->isCompleted() && !t->doesRecur()) {
3972 checkExternalId( t ); 3972 checkExternalId( t );
3973 mCalendar->deleteTodo( t ); 3973 mCalendar->deleteTodo( t );
3974 changeTodoDisplay( t,KOGlobals::EVENTDELETED ); 3974 changeTodoDisplay( t,KOGlobals::EVENTDELETED );
3975 } 3975 }
3976 else 3976 else
3977 deleteTodo = false; 3977 deleteTodo = false;
3978 } 3978 }
3979 return deleteTodo; 3979 return deleteTodo;
3980 3980
3981} 3981}
3982void CalendarView::purgeCompleted() 3982void CalendarView::purgeCompleted()
3983{ 3983{
3984 int result = KMessageBox::warningContinueCancel(this, 3984 int result = KMessageBox::warningContinueCancel(this,
3985 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); 3985 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge"));
3986 3986
3987 if (result == KMessageBox::Continue) { 3987 if (result == KMessageBox::Continue) {
3988 3988
3989 QPtrList<Todo> todoCal; 3989 QPtrList<Todo> todoCal;
3990 QPtrList<Todo> rootTodos; 3990 QPtrList<Todo> rootTodos;
3991 //QPtrList<Incidence> rel; 3991 //QPtrList<Incidence> rel;
3992 Todo *aTodo;//, *rTodo; 3992 Todo *aTodo;//, *rTodo;
3993 Incidence *rIncidence; 3993 Incidence *rIncidence;
3994 bool childDelete = false; 3994 bool childDelete = false;
3995 bool deletedOne = true; 3995 bool deletedOne = true;
3996 todoCal = calendar()->todos(); 3996 todoCal = calendar()->todos();
3997 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { 3997 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
3998 if ( !aTodo->relatedTo() ) 3998 if ( !aTodo->relatedTo() )
3999 rootTodos.append( aTodo ); 3999 rootTodos.append( aTodo );
4000 } 4000 }
4001 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { 4001 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) {
4002 removeCompletedSubTodos( aTodo ); 4002 removeCompletedSubTodos( aTodo );
4003 } 4003 }
4004 4004
4005 updateView(); 4005 updateView();
4006 } 4006 }
4007} 4007}
4008 4008
4009void CalendarView::slotCalendarChanged() 4009void CalendarView::slotCalendarChanged()
4010{ 4010{
4011 ; 4011 ;
4012} 4012}
4013 4013
4014void CalendarView::keyPressEvent ( QKeyEvent *e) 4014void CalendarView::keyPressEvent ( QKeyEvent *e)
4015{ 4015{
4016 //qDebug(" alendarView::keyPressEvent "); 4016 //qDebug(" alendarView::keyPressEvent ");
4017 e->ignore(); 4017 e->ignore();
4018} 4018}
4019 4019
4020 4020
4021bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) 4021bool CalendarView::sync(KSyncManager* manager, QString filename, int mode)
4022{ 4022{
4023 // mSyncManager = manager; 4023 // mSyncManager = manager;
4024 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { 4024 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) {
4025 qDebug("KO: SyncKDE request detected!"); 4025 qDebug("KO: SyncKDE request detected!");
4026 } 4026 }
4027 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 4027 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
4028 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 4028 mCurrentSyncName = mSyncManager->getCurrentSyncName();
4029 return syncCalendar( filename, mode ); 4029 return syncCalendar( filename, mode );
4030} 4030}
4031bool CalendarView::syncExternal(KSyncManager* manager, QString resource) 4031bool CalendarView::syncExternal(KSyncManager* manager, QString resource)
4032{ 4032{
4033 //mSyncManager = manager; 4033 //mSyncManager = manager;
4034 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 4034 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
4035 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 4035 mCurrentSyncName = mSyncManager->getCurrentSyncName();
4036 if ( resource == "sharp" ) 4036 if ( resource == "sharp" )
4037 syncExternal( 0 ); 4037 syncExternal( 0 );
4038 if ( resource == "phone" ) 4038 if ( resource == "phone" )
4039 syncExternal( 1 ); 4039 syncExternal( 1 );
4040 // pending setmodified 4040 // pending setmodified
4041 return true; 4041 return true;
4042} 4042}
4043void CalendarView::setSyncManager(KSyncManager* manager) 4043void CalendarView::setSyncManager(KSyncManager* manager)
4044{ 4044{
4045 mSyncManager = manager; 4045 mSyncManager = manager;
4046} 4046}
4047 4047
4048void CalendarView::removeSyncInfo( QString syncProfile) 4048void CalendarView::removeSyncInfo( QString syncProfile)
4049{ 4049{
4050 qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); 4050 qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1());
4051 mCalendar->removeSyncInfo( syncProfile ); 4051 mCalendar->removeSyncInfo( syncProfile );
4052 4052
4053} 4053}
4054 4054
4055void CalendarView::undo_delete() 4055void CalendarView::undo_delete()
4056{ 4056{
4057 //qDebug("undo_delete() "); 4057 //qDebug("undo_delete() ");
4058 Incidence* undo = mCalendar->undoIncidence(); 4058 Incidence* undo = mCalendar->undoIncidence();
4059 if ( !undo ) { 4059 if ( !undo ) {
4060 KMessageBox::sorry(this,i18n("There is nothing to undo!"), 4060 KMessageBox::sorry(this,i18n("There is nothing to undo!"),
4061 i18n("KO/Pi")); 4061 i18n("KO/Pi"));
4062 return; 4062 return;
4063 } 4063 }
4064 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + 4064 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) +
4065 i18n("\nAre you sure you want\nto restore this?"), 4065 i18n("\nAre you sure you want\nto restore this?"),
4066 i18n("KO/Pi Confirmation"),i18n("Restore"))) { 4066 i18n("KO/Pi Confirmation"),i18n("Restore"))) {
4067 mCalendar->undoDeleteIncidence(); 4067 mCalendar->undoDeleteIncidence();
4068 updateView(); 4068 updateView();
4069 } 4069 }
4070} 4070}
4071 4071
4072void CalendarView::slotViewerClosed() 4072void CalendarView::slotViewerClosed()
4073{ 4073{
4074 QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); 4074 QTimer::singleShot( 50, this, SLOT ( resetFocus() ) );
4075} 4075}
4076 4076
4077void CalendarView::resetFocus() 4077void CalendarView::resetFocus()
4078{ 4078{
4079 if ( mViewerCallerIsSearchDialog ) { 4079 if ( mViewerCallerIsSearchDialog ) {
4080 if ( mDialogManager->getSearchDialog()->isVisible() ){ 4080 if ( mDialogManager->getSearchDialog()->isVisible() ){
4081 mDialogManager->getSearchDialog()->raise(); 4081 mDialogManager->getSearchDialog()->raise();
4082 mDialogManager->getSearchDialog()->setActiveWindow(); 4082 mDialogManager->getSearchDialog()->setActiveWindow();
4083 mDialogManager->getSearchDialog()->listview()->resetFocus(); 4083 mDialogManager->getSearchDialog()->listview()->resetFocus();
4084 } else 4084 } else
4085 mViewerCallerIsSearchDialog = false; 4085 mViewerCallerIsSearchDialog = false;
4086 } 4086 }
4087 if ( !mViewerCallerIsSearchDialog ) { 4087 if ( !mViewerCallerIsSearchDialog ) {
4088 //mViewManager->currentView()->setFocus(); 4088 //mViewManager->currentView()->setFocus();
4089 //qDebug("sssssssssssssssset focus "); 4089 //qDebug("sssssssssssssssset focus ");
4090 topLevelWidget()->raise(); 4090 topLevelWidget()->raise();
4091 setActiveWindow(); 4091 setActiveWindow();
4092 //setFocus(); 4092 //setFocus();
4093 } 4093 }
4094 mViewerCallerIsSearchDialog = false; 4094 mViewerCallerIsSearchDialog = false;
4095} 4095}
4096 4096
4097void CalendarView::showNextAlarms() 4097void CalendarView::showNextAlarms()
4098{ 4098{
4099 QString message; 4099 QString message;
4100 QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); 4100 QDateTime nextAl = mCalendar->nextAlarmEventDateTime();
4101 if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { 4101 if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) {
4102 QString sum = mCalendar->nextSummary(); 4102 QString sum = mCalendar->nextSummary();
4103 QDateTime nextA = mNextAlarmDateTime; 4103 QDateTime nextA = mNextAlarmDateTime;
4104 QDateTime cur = QDateTime::currentDateTime(); 4104 QDateTime cur = QDateTime::currentDateTime();
4105 int secs = cur.secsTo( nextA ); 4105 int secs = cur.secsTo( nextA );
4106 int min = secs /60; 4106 int min = secs /60;
4107 int hours = min /60; 4107 int hours = min /60;
4108 min = min % 60; 4108 min = min % 60;
4109 int days = hours /24; 4109 int days = hours /24;
4110 hours = hours % 24; 4110 hours = hours % 24;
4111 4111
4112 //message = i18n("The next alarm is in:\n"); 4112 //message = i18n("The next alarm is in:\n");
4113 if ( days > 1 ) 4113 if ( days > 1 )
4114 message += i18n("%1 days\n").arg( days ); 4114 message += i18n("%1 days\n").arg( days );
4115 else if ( days == 1 ) 4115 else if ( days == 1 )
4116 message += i18n("1 day\n"); 4116 message += i18n("1 day\n");
4117 if ( hours > 1 ) 4117 if ( hours > 1 )
4118 message += i18n("%1 hours\n").arg( hours ); 4118 message += i18n("%1 hours\n").arg( hours );
4119 else if ( hours == 1 ) 4119 else if ( hours == 1 )
4120 message += i18n("1 hour\n"); 4120 message += i18n("1 hour\n");
4121 if ( min > 1 ) 4121 if ( min > 1 )
4122 message += i18n("%1 minutes\n").arg( min ); 4122 message += i18n("%1 minutes\n").arg( min );
4123 else if ( min == 1 ) 4123 else if ( min == 1 )
4124 message += i18n("1 minute\n"); 4124 message += i18n("1 minute\n");
4125 if ( message.isEmpty() ) 4125 if ( message.isEmpty() )
4126 message = i18n("The next alarm is in\nless than one minute!"); 4126 message = i18n("The next alarm is in\nless than one minute!");
4127 else 4127 else
4128 message = i18n("The next alarm is in:\n") + message; 4128 message = i18n("The next alarm is in:\n") + message;
4129 message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; 4129 message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ;
4130 } else { 4130 } else {
4131 message = i18n("There is no next alarm."); 4131 message = i18n("There is no next alarm.");
4132 4132
4133 } 4133 }
4134#ifdef DESKTOP_VERSION 4134#ifdef DESKTOP_VERSION
4135 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 4135 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
4136 message += i18n("\nThe internal alarm notification is disabled!\n"); 4136 message += i18n("\nThe internal alarm notification is disabled!\n");
4137 message += i18n("Enable it in the settings menu, TAB alarm."); 4137 message += i18n("Enable it in the settings menu, TAB alarm.");
4138 } 4138 }
4139 4139
4140#endif 4140#endif
4141 KMessageBox::information( this, message); 4141 KMessageBox::information( this, message);
4142} 4142}