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