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