summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp53
-rw-r--r--korganizer/koprefs.h1
-rw-r--r--korganizer/mainwindow.cpp6
-rw-r--r--libkcal/phoneformat.cpp15
4 files changed, 55 insertions, 20 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index db07713..cfd9290 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,3550 +1,3577 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Requires the Qt and KDE widget libraries, available at no cost at 4 Requires the Qt and KDE widget libraries, available at no cost at
5 http://www.troll.no and http://www.kde.org respectively 5 http://www.troll.no and http://www.kde.org respectively
6 6
7 Copyright (c) 1997, 1998, 1999 7 Copyright (c) 1997, 1998, 1999
8 Preston Brown (preston.brown@yale.edu) 8 Preston Brown (preston.brown@yale.edu)
9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) 9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl)
10 Ian Dawes (iadawes@globalserve.net) 10 Ian Dawes (iadawes@globalserve.net)
11 Laszlo Boloni (boloni@cs.purdue.edu) 11 Laszlo Boloni (boloni@cs.purdue.edu)
12 12
13 Copyright (c) 2000, 2001, 2002 13 Copyright (c) 2000, 2001, 2002
14 Cornelius Schumacher <schumacher@kde.org> 14 Cornelius Schumacher <schumacher@kde.org>
15 15
16 This program is free software; you can redistribute it and/or modify 16 This program is free software; you can redistribute it and/or modify
17 it under the terms of the GNU General Public License as published by 17 it under the terms of the GNU General Public License as published by
18 the Free Software Foundation; either version 2 of the License, or 18 the Free Software Foundation; either version 2 of the License, or
19 (at your option) any later version. 19 (at your option) any later version.
20 20
21 This program is distributed in the hope that it will be useful, 21 This program is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of 22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
24 GNU General Public License for more details. 24 GNU General Public License for more details.
25 25
26 You should have received a copy of the GNU General Public License 26 You should have received a copy of the GNU General Public License
27 along with this program; if not, write to the Free Software 27 along with this program; if not, write to the Free Software
28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29*/ 29*/
30 30
31#include <stdlib.h> 31#include <stdlib.h>
32 32
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qradiobutton.h> 34#include <qradiobutton.h>
35#include <qbuttongroup.h> 35#include <qbuttongroup.h>
36#include <qlayout.h> 36#include <qlayout.h>
37#include <qclipboard.h> 37#include <qclipboard.h>
38#include <qcursor.h> 38#include <qcursor.h>
39#include <qmessagebox.h> 39#include <qmessagebox.h>
40#include <qprogressbar.h> 40#include <qprogressbar.h>
41#include <qmultilineedit.h> 41#include <qmultilineedit.h>
42#include <qtimer.h> 42#include <qtimer.h>
43#include <qwidgetstack.h> 43#include <qwidgetstack.h>
44#include <qptrlist.h> 44#include <qptrlist.h>
45#include <qregexp.h> 45#include <qregexp.h>
46#include <qgroupbox.h> 46#include <qgroupbox.h>
47#include <qfile.h> 47#include <qfile.h>
48#include <qdir.h> 48#include <qdir.h>
49#ifndef KORG_NOSPLITTER 49#ifndef KORG_NOSPLITTER
50#include <qsplitter.h> 50#include <qsplitter.h>
51#endif 51#endif
52 52
53#include <kglobal.h> 53#include <kglobal.h>
54#include <kdebug.h> 54#include <kdebug.h>
55#include <kstandarddirs.h> 55#include <kstandarddirs.h>
56#include <kfiledialog.h> 56#include <kfiledialog.h>
57#include <kmessagebox.h> 57#include <kmessagebox.h>
58#include <knotifyclient.h> 58#include <knotifyclient.h>
59#include <kconfig.h> 59#include <kconfig.h>
60 60
61#include <libkdepim/ksyncprefsdialog.h> 61#include <libkdepim/ksyncprefsdialog.h>
62#include <krun.h> 62#include <krun.h>
63#include <kdirwatch.h> 63#include <kdirwatch.h>
64#include <libkdepim/kdatepicker.h> 64#include <libkdepim/kdatepicker.h>
65#include <libkdepim/ksyncprofile.h> 65#include <libkdepim/ksyncprofile.h>
66 66
67#include <libkcal/vcaldrag.h> 67#include <libkcal/vcaldrag.h>
68#include <libkcal/icaldrag.h> 68#include <libkcal/icaldrag.h>
69#include <libkcal/icalformat.h> 69#include <libkcal/icalformat.h>
70#include <libkcal/vcalformat.h> 70#include <libkcal/vcalformat.h>
71#include <libkcal/scheduler.h> 71#include <libkcal/scheduler.h>
72#include <libkcal/calendarlocal.h> 72#include <libkcal/calendarlocal.h>
73#include <libkcal/journal.h> 73#include <libkcal/journal.h>
74#include <libkcal/calfilter.h> 74#include <libkcal/calfilter.h>
75#include <libkcal/attendee.h> 75#include <libkcal/attendee.h>
76#include <libkcal/dndfactory.h> 76#include <libkcal/dndfactory.h>
77#include <libkcal/freebusy.h> 77#include <libkcal/freebusy.h>
78#include <libkcal/filestorage.h> 78#include <libkcal/filestorage.h>
79#include <libkcal/calendarresources.h> 79#include <libkcal/calendarresources.h>
80#include <libkcal/qtopiaformat.h> 80#include <libkcal/qtopiaformat.h>
81#include "../kalarmd/alarmdialog.h" 81#include "../kalarmd/alarmdialog.h"
82 82
83#ifndef DESKTOP_VERSION 83#ifndef DESKTOP_VERSION
84#include <libkcal/sharpformat.h> 84#include <libkcal/sharpformat.h>
85#endif 85#endif
86#include <libkcal/phoneformat.h> 86#include <libkcal/phoneformat.h>
87#ifndef KORG_NOMAIL 87#ifndef KORG_NOMAIL
88#include "komailclient.h" 88#include "komailclient.h"
89#endif 89#endif
90#ifndef KORG_NOPRINTER 90#ifndef KORG_NOPRINTER
91#include "calprinter.h" 91#include "calprinter.h"
92#endif 92#endif
93#ifndef KORG_NOPLUGINS 93#ifndef KORG_NOPLUGINS
94#include "kocore.h" 94#include "kocore.h"
95#endif 95#endif
96#include "koeventeditor.h" 96#include "koeventeditor.h"
97#include "kotodoeditor.h" 97#include "kotodoeditor.h"
98#include "koprefs.h" 98#include "koprefs.h"
99#include "koeventviewerdialog.h" 99#include "koeventviewerdialog.h"
100#include "publishdialog.h" 100#include "publishdialog.h"
101#include "kofilterview.h" 101#include "kofilterview.h"
102#include "koglobals.h" 102#include "koglobals.h"
103#include "koviewmanager.h" 103#include "koviewmanager.h"
104#include "koagendaview.h" 104#include "koagendaview.h"
105#include "kodialogmanager.h" 105#include "kodialogmanager.h"
106#include "outgoingdialog.h" 106#include "outgoingdialog.h"
107#include "incomingdialog.h" 107#include "incomingdialog.h"
108#include "statusdialog.h" 108#include "statusdialog.h"
109#include "kdatenavigator.h" 109#include "kdatenavigator.h"
110#include "kotodoview.h" 110#include "kotodoview.h"
111#include "datenavigator.h" 111#include "datenavigator.h"
112#include "resourceview.h" 112#include "resourceview.h"
113#include "navigatorbar.h" 113#include "navigatorbar.h"
114#include "searchdialog.h" 114#include "searchdialog.h"
115#include "mainwindow.h" 115#include "mainwindow.h"
116 116
117#include "calendarview.h" 117#include "calendarview.h"
118#ifndef DESKTOP_VERSION 118#ifndef DESKTOP_VERSION
119#include <qtopia/alarmserver.h> 119#include <qtopia/alarmserver.h>
120#endif 120#endif
121#ifndef _WIN32_ 121#ifndef _WIN32_
122#include <stdlib.h> 122#include <stdlib.h>
123#include <stdio.h> 123#include <stdio.h>
124#include <unistd.h> 124#include <unistd.h>
125#else 125#else
126#include <qprocess.h> 126#include <qprocess.h>
127#endif 127#endif
128using namespace KOrg; 128using namespace KOrg;
129using namespace KCal; 129using namespace KCal;
130extern int globalFlagBlockAgenda; 130extern int globalFlagBlockAgenda;
131extern int globalFlagBlockStartup; 131extern int globalFlagBlockStartup;
132 132
133 133
134 134
135class KOBeamPrefs : public QDialog 135class KOBeamPrefs : public QDialog
136{ 136{
137 public: 137 public:
138 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : 138 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) :
139 QDialog( parent, name, true ) 139 QDialog( parent, name, true )
140 { 140 {
141 setCaption( i18n("Beam Options") ); 141 setCaption( i18n("Beam Options") );
142 QVBoxLayout* lay = new QVBoxLayout( this ); 142 QVBoxLayout* lay = new QVBoxLayout( this );
143 lay->setSpacing( 3 ); 143 lay->setSpacing( 3 );
144 lay->setMargin( 3 ); 144 lay->setMargin( 3 );
145 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); 145 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this );
146 lay->addWidget( format ); 146 lay->addWidget( format );
147 format->setExclusive ( true ) ; 147 format->setExclusive ( true ) ;
148 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); 148 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this );
149 lay->addWidget( time ); time->setExclusive ( true ) ; 149 lay->addWidget( time ); time->setExclusive ( true ) ;
150 vcal = new QRadioButton(" vCalendar ", format ); 150 vcal = new QRadioButton(" vCalendar ", format );
151 ical = new QRadioButton(" iCalendar ", format ); 151 ical = new QRadioButton(" iCalendar ", format );
152 vcal->setChecked( true ); 152 vcal->setChecked( true );
153 tz = new QRadioButton(i18n(" With timezone "), time ); 153 tz = new QRadioButton(i18n(" With timezone "), time );
154 local = new QRadioButton(i18n(" Local time "), time ); 154 local = new QRadioButton(i18n(" Local time "), time );
155 tz->setChecked( true ); 155 tz->setChecked( true );
156 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); 156 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this );
157 lay->addWidget( ok ); 157 lay->addWidget( ok );
158 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 158 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
159 lay->addWidget( cancel ); 159 lay->addWidget( cancel );
160 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 160 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
161 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 161 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
162 resize( 200, 200 ); 162 resize( 200, 200 );
163 } 163 }
164 164
165 bool beamVcal() { return vcal->isChecked(); } 165 bool beamVcal() { return vcal->isChecked(); }
166 bool beamLocal() { return local->isChecked(); } 166 bool beamLocal() { return local->isChecked(); }
167private: 167private:
168 QRadioButton* vcal, *ical, *local, *tz; 168 QRadioButton* vcal, *ical, *local, *tz;
169}; 169};
170class KOCatPrefs : public QDialog 170class KOCatPrefs : public QDialog
171{ 171{
172 public: 172 public:
173 KOCatPrefs( QWidget *parent=0, const char *name=0 ) : 173 KOCatPrefs( QWidget *parent=0, const char *name=0 ) :
174 QDialog( parent, name, true ) 174 QDialog( parent, name, true )
175 { 175 {
176 setCaption( i18n("Manage new Categories") ); 176 setCaption( i18n("Manage new Categories") );
177 QVBoxLayout* lay = new QVBoxLayout( this ); 177 QVBoxLayout* lay = new QVBoxLayout( this );
178 lay->setSpacing( 3 ); 178 lay->setSpacing( 3 );
179 lay->setMargin( 3 ); 179 lay->setMargin( 3 );
180 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); 180 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this );
181 lay->addWidget( lab ); 181 lay->addWidget( lab );
182 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 182 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
183 lay->addWidget( format ); 183 lay->addWidget( format );
184 format->setExclusive ( true ) ; 184 format->setExclusive ( true ) ;
185 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 185 addCatBut = new QRadioButton(i18n("Add to category list"), format );
186 new QRadioButton(i18n("Remove from Events/Todos"), format ); 186 new QRadioButton(i18n("Remove from Events/Todos"), format );
187 addCatBut->setChecked( true ); 187 addCatBut->setChecked( true );
188 QPushButton * ok = new QPushButton( i18n("OK"), this ); 188 QPushButton * ok = new QPushButton( i18n("OK"), this );
189 lay->addWidget( ok ); 189 lay->addWidget( ok );
190 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 190 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
191 lay->addWidget( cancel ); 191 lay->addWidget( cancel );
192 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 192 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
193 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 193 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
194 resize( 200, 200 ); 194 resize( 200, 200 );
195 } 195 }
196 196
197 bool addCat() { return addCatBut->isChecked(); } 197 bool addCat() { return addCatBut->isChecked(); }
198private: 198private:
199 QRadioButton* addCatBut; 199 QRadioButton* addCatBut;
200}; 200};
201 201
202 202
203 203
204CalendarView::CalendarView( CalendarResources *calendar, 204CalendarView::CalendarView( CalendarResources *calendar,
205 QWidget *parent, const char *name ) 205 QWidget *parent, const char *name )
206 : CalendarViewBase( parent, name ), 206 : CalendarViewBase( parent, name ),
207 mCalendar( calendar ), 207 mCalendar( calendar ),
208 mResourceManager( calendar->resourceManager() ) 208 mResourceManager( calendar->resourceManager() )
209{ 209{
210 210
211 mEventEditor = 0; 211 mEventEditor = 0;
212 mTodoEditor = 0; 212 mTodoEditor = 0;
213 213
214 init(); 214 init();
215} 215}
216 216
217CalendarView::CalendarView( Calendar *calendar, 217CalendarView::CalendarView( Calendar *calendar,
218 QWidget *parent, const char *name ) 218 QWidget *parent, const char *name )
219 : CalendarViewBase( parent, name ), 219 : CalendarViewBase( parent, name ),
220 mCalendar( calendar ), 220 mCalendar( calendar ),
221 mResourceManager( 0 ) 221 mResourceManager( 0 )
222{ 222{
223 223
224 mEventEditor = 0; 224 mEventEditor = 0;
225 mTodoEditor = 0; 225 mTodoEditor = 0;
226 init();} 226 init();}
227 227
228void CalendarView::init() 228void CalendarView::init()
229{ 229{
230 beamDialog = new KOBeamPrefs(); 230 beamDialog = new KOBeamPrefs();
231 mDatePickerMode = 0; 231 mDatePickerMode = 0;
232 mCurrentSyncDevice = ""; 232 mCurrentSyncDevice = "";
233 writeLocale(); 233 writeLocale();
234 mViewManager = new KOViewManager( this ); 234 mViewManager = new KOViewManager( this );
235 mDialogManager = new KODialogManager( this ); 235 mDialogManager = new KODialogManager( this );
236 mEventViewerDialog = 0; 236 mEventViewerDialog = 0;
237 mModified = false; 237 mModified = false;
238 mReadOnly = false; 238 mReadOnly = false;
239 mSelectedIncidence = 0; 239 mSelectedIncidence = 0;
240 mCalPrinter = 0; 240 mCalPrinter = 0;
241 mFilters.setAutoDelete(true); 241 mFilters.setAutoDelete(true);
242 242
243 mCalendar->registerObserver( this ); 243 mCalendar->registerObserver( this );
244 // TODO: Make sure that view is updated, when calendar is changed. 244 // TODO: Make sure that view is updated, when calendar is changed.
245 245
246 mStorage = new FileStorage( mCalendar ); 246 mStorage = new FileStorage( mCalendar );
247 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 247 mNavigator = new DateNavigator( this, "datevav", mViewManager );
248 248
249 QBoxLayout *topLayout = (QBoxLayout*)layout(); 249 QBoxLayout *topLayout = (QBoxLayout*)layout();
250#ifndef KORG_NOSPLITTER 250#ifndef KORG_NOSPLITTER
251 // create the main layout frames. 251 // create the main layout frames.
252 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 252 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
253 topLayout->addWidget(mPanner); 253 topLayout->addWidget(mPanner);
254 254
255 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 255 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
256 "CalendarView::LeftFrame"); 256 "CalendarView::LeftFrame");
257 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 257 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
258 258
259 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, 259 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE,
260 "CalendarView::DateNavigator", QDate::currentDate() ); 260 "CalendarView::DateNavigator", QDate::currentDate() );
261 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 261 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
262 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 262 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
263 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 263 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
264 264
265#ifdef KORG_NORESOURCEVIEW 265#ifdef KORG_NORESOURCEVIEW
266 mResourceView = 0; 266 mResourceView = 0;
267#else 267#else
268 if ( mResourceManager ) { 268 if ( mResourceManager ) {
269 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 269 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
270 mResourceView->updateView(); 270 mResourceView->updateView();
271 connect( mResourceView, SIGNAL( resourcesChanged() ), 271 connect( mResourceView, SIGNAL( resourcesChanged() ),
272 SLOT( updateView() ) ); 272 SLOT( updateView() ) );
273 } else { 273 } else {
274 mResourceView = 0; 274 mResourceView = 0;
275 } 275 }
276#endif 276#endif
277 QWidget *rightBox = new QWidget( mPanner ); 277 QWidget *rightBox = new QWidget( mPanner );
278 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 278 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
279 279
280 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 280 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
281 rightLayout->addWidget( mNavigatorBar ); 281 rightLayout->addWidget( mNavigatorBar );
282 282
283 mRightFrame = new QWidgetStack( rightBox ); 283 mRightFrame = new QWidgetStack( rightBox );
284 rightLayout->addWidget( mRightFrame, 1 ); 284 rightLayout->addWidget( mRightFrame, 1 );
285 285
286 mLeftFrame = mLeftSplitter; 286 mLeftFrame = mLeftSplitter;
287#else 287#else
288 QWidget *mainBox = new QWidget( this ); 288 QWidget *mainBox = new QWidget( this );
289 QWidget *leftFrame = new QWidget( mainBox ); 289 QWidget *leftFrame = new QWidget( mainBox );
290 290
291 QBoxLayout * mainBoxLayout; 291 QBoxLayout * mainBoxLayout;
292 QBoxLayout * leftFrameLayout; 292 QBoxLayout * leftFrameLayout;
293 if ( KOPrefs::instance()->mVerticalScreen ) { 293 if ( KOPrefs::instance()->mVerticalScreen ) {
294 mainBoxLayout = new QVBoxLayout(mainBox); 294 mainBoxLayout = new QVBoxLayout(mainBox);
295 leftFrameLayout = new QHBoxLayout(leftFrame ); 295 leftFrameLayout = new QHBoxLayout(leftFrame );
296 } else { 296 } else {
297 mainBoxLayout = new QHBoxLayout(mainBox); 297 mainBoxLayout = new QHBoxLayout(mainBox);
298 leftFrameLayout = new QVBoxLayout(leftFrame ); 298 leftFrameLayout = new QVBoxLayout(leftFrame );
299 } 299 }
300 topLayout->addWidget( mainBox ); 300 topLayout->addWidget( mainBox );
301 mainBoxLayout->addWidget (leftFrame); 301 mainBoxLayout->addWidget (leftFrame);
302 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, 302 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE,
303 "CalendarView::DateNavigator", QDate::currentDate()); 303 "CalendarView::DateNavigator", QDate::currentDate());
304 // mDateNavigator->blockSignals( true ); 304 // mDateNavigator->blockSignals( true );
305 leftFrameLayout->addWidget( mDateNavigator ); 305 leftFrameLayout->addWidget( mDateNavigator );
306 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); 306 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView");
307 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolist"); 307 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolist");
308 308
309 if ( QApplication::desktop()->width() < 480 ) { 309 if ( QApplication::desktop()->width() < 480 ) {
310 leftFrameLayout->addWidget(mFilterView); 310 leftFrameLayout->addWidget(mFilterView);
311 leftFrameLayout->addWidget(mTodoList, 2 ); 311 leftFrameLayout->addWidget(mTodoList, 2 );
312 312
313 } else { 313 } else {
314 leftFrameLayout->addWidget(mTodoList,2 ); 314 leftFrameLayout->addWidget(mTodoList,2 );
315 leftFrameLayout->addWidget(mFilterView ); 315 leftFrameLayout->addWidget(mFilterView );
316 } 316 }
317 mFilterView->hide(); 317 mFilterView->hide();
318 QWidget *rightBox = new QWidget( mainBox ); 318 QWidget *rightBox = new QWidget( mainBox );
319 mainBoxLayout->addWidget ( rightBox, 10 ); 319 mainBoxLayout->addWidget ( rightBox, 10 );
320 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 320 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
321 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 321 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
322 mRightFrame = new QWidgetStack( rightBox ); 322 mRightFrame = new QWidgetStack( rightBox );
323 rightLayout->addWidget( mNavigatorBar ); 323 rightLayout->addWidget( mNavigatorBar );
324 rightLayout->addWidget( mRightFrame, 10 ); 324 rightLayout->addWidget( mRightFrame, 10 );
325 325
326 mLeftFrame = leftFrame; 326 mLeftFrame = leftFrame;
327 if ( KOPrefs::instance()->mVerticalScreen ) { 327 if ( KOPrefs::instance()->mVerticalScreen ) {
328 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 328 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
329 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 329 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
330 } else { 330 } else {
331 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 331 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
332 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 332 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
333 } 333 }
334 334
335 //qDebug("Calendarview Size %d %d ", width(), height()); 335 //qDebug("Calendarview Size %d %d ", width(), height());
336#endif 336#endif
337 337
338 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 338 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
339 SLOT( showDates( const KCal::DateList & ) ) ); 339 SLOT( showDates( const KCal::DateList & ) ) );
340 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 340 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
341 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 341 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
342 342
343 connect( mNavigatorBar, SIGNAL( goPrevYear() ), 343 connect( mNavigatorBar, SIGNAL( goPrevYear() ),
344 mNavigator, SLOT( selectPreviousYear() ) ); 344 mNavigator, SLOT( selectPreviousYear() ) );
345 connect( mNavigatorBar, SIGNAL( goNextYear() ), 345 connect( mNavigatorBar, SIGNAL( goNextYear() ),
346 mNavigator, SLOT( selectNextYear() ) ); 346 mNavigator, SLOT( selectNextYear() ) );
347 connect( mNavigatorBar, SIGNAL( goPrevMonth() ), 347 connect( mNavigatorBar, SIGNAL( goPrevMonth() ),
348 mNavigator, SLOT( selectPreviousMonth() ) ); 348 mNavigator, SLOT( selectPreviousMonth() ) );
349 connect( mNavigatorBar, SIGNAL( goNextMonth() ), 349 connect( mNavigatorBar, SIGNAL( goNextMonth() ),
350 mNavigator, SLOT( selectNextMonth() ) ); 350 mNavigator, SLOT( selectNextMonth() ) );
351 351
352 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 352 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
353 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); 353 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) );
354 354
355 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 355 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
356 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 356 mNavigator, SLOT( selectWeek( const QDate & ) ) );
357 357
358 connect( mDateNavigator, SIGNAL( goPrevYear() ), 358 connect( mDateNavigator, SIGNAL( goPrevYear() ),
359 mNavigator, SLOT( selectPreviousYear() ) ); 359 mNavigator, SLOT( selectPreviousYear() ) );
360 connect( mDateNavigator, SIGNAL( goNextYear() ), 360 connect( mDateNavigator, SIGNAL( goNextYear() ),
361 mNavigator, SLOT( selectNextYear() ) ); 361 mNavigator, SLOT( selectNextYear() ) );
362 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 362 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
363 mNavigator, SLOT( selectPreviousMonth() ) ); 363 mNavigator, SLOT( selectPreviousMonth() ) );
364 connect( mDateNavigator, SIGNAL( goNextMonth() ), 364 connect( mDateNavigator, SIGNAL( goNextMonth() ),
365 mNavigator, SLOT( selectNextMonth() ) ); 365 mNavigator, SLOT( selectNextMonth() ) );
366 366
367 connect( mDateNavigator, SIGNAL( goPrevious() ), 367 connect( mDateNavigator, SIGNAL( goPrevious() ),
368 mNavigator, SLOT( selectPrevious() ) ); 368 mNavigator, SLOT( selectPrevious() ) );
369 connect( mDateNavigator, SIGNAL( goNext() ), 369 connect( mDateNavigator, SIGNAL( goNext() ),
370 mNavigator, SLOT( selectNext() ) ); 370 mNavigator, SLOT( selectNext() ) );
371 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 371 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
372 mNavigator, SLOT( slotMonthSelect( int ) ) ); 372 mNavigator, SLOT( slotMonthSelect( int ) ) );
373 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), 373 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ),
374 mNavigator, SLOT( slotMonthSelect( int ) ) ); 374 mNavigator, SLOT( slotMonthSelect( int ) ) );
375 375
376 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 376 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
377 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 377 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
378 378
379 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), 379 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ),
380 SLOT( eventAdded( Event *) ) ); 380 SLOT( eventAdded( Event *) ) );
381 381
382 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 382 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
383 383
384 connect( this, SIGNAL( configChanged() ), 384 connect( this, SIGNAL( configChanged() ),
385 mDateNavigator, SLOT( updateConfig() ) ); 385 mDateNavigator, SLOT( updateConfig() ) );
386 386
387 connect( mTodoList, SIGNAL( newTodoSignal() ), 387 connect( mTodoList, SIGNAL( newTodoSignal() ),
388 SLOT( newTodo() ) ); 388 SLOT( newTodo() ) );
389 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 389 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
390 SLOT( newSubTodo( Todo * ) ) ); 390 SLOT( newSubTodo( Todo * ) ) );
391 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 391 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
392 SLOT( editTodo( Todo * ) ) ); 392 SLOT( editTodo( Todo * ) ) );
393 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 393 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
394 SLOT( showTodo( Todo *) ) ); 394 SLOT( showTodo( Todo *) ) );
395 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 395 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
396 SLOT( deleteTodo( Todo *) ) ); 396 SLOT( deleteTodo( Todo *) ) );
397 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 397 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
398 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 398 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
399 SLOT( purgeCompleted() ) ); 399 SLOT( purgeCompleted() ) );
400 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 400 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
401 SIGNAL( todoModified( Todo *, int ) ) ); 401 SIGNAL( todoModified( Todo *, int ) ) );
402 402
403 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 403 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
404 this, SLOT ( cloneIncidence( Incidence * ) ) ); 404 this, SLOT ( cloneIncidence( Incidence * ) ) );
405 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 405 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
406 this, SLOT (cancelIncidence( Incidence * ) ) ); 406 this, SLOT (cancelIncidence( Incidence * ) ) );
407 407
408 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 408 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
409 this, SLOT ( moveIncidence( Incidence * ) ) ); 409 this, SLOT ( moveIncidence( Incidence * ) ) );
410 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 410 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
411 this, SLOT ( beamIncidence( Incidence * ) ) ); 411 this, SLOT ( beamIncidence( Incidence * ) ) );
412 412
413 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 413 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
414 this, SLOT ( todo_unsub( Todo * ) ) ); 414 this, SLOT ( todo_unsub( Todo * ) ) );
415 415
416 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 416 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
417 SLOT( updateTodo( Todo *, int ) ) ); 417 SLOT( updateTodo( Todo *, int ) ) );
418 connect( this, SIGNAL( todoModified( Todo *, int )), this, 418 connect( this, SIGNAL( todoModified( Todo *, int )), this,
419 SLOT( changeTodoDisplay( Todo *, int ) ) ); 419 SLOT( changeTodoDisplay( Todo *, int ) ) );
420 420
421 421
422 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 422 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
423 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 423 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
424 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 424 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
425 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 425 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
426 426
427 427
428 428
429 429
430 430
431 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 431 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
432 SLOT(checkClipboard())); 432 SLOT(checkClipboard()));
433 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 433 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
434 SLOT( processTodoListSelection( Incidence * ) ) ); 434 SLOT( processTodoListSelection( Incidence * ) ) );
435 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 435 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
436 436
437 // kdDebug() << "CalendarView::CalendarView() done" << endl; 437 // kdDebug() << "CalendarView::CalendarView() done" << endl;
438 438
439 mDateFrame = new QVBox(0,0,WType_Popup); 439 mDateFrame = new QVBox(0,0,WType_Popup);
440 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 440 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
441 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 441 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
442 mDateFrame->setLineWidth(3); 442 mDateFrame->setLineWidth(3);
443 mDateFrame->hide(); 443 mDateFrame->hide();
444 mDateFrame->setCaption( i18n( "Pick a date to display")); 444 mDateFrame->setCaption( i18n( "Pick a date to display"));
445 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 445 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
446 446
447 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 447 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
448 448
449 mEventEditor = mDialogManager->getEventEditor(); 449 mEventEditor = mDialogManager->getEventEditor();
450 mTodoEditor = mDialogManager->getTodoEditor(); 450 mTodoEditor = mDialogManager->getTodoEditor();
451 451
452 mFlagEditDescription = false; 452 mFlagEditDescription = false;
453 453
454 mSuspendTimer = new QTimer( this ); 454 mSuspendTimer = new QTimer( this );
455 mAlarmTimer = new QTimer( this ); 455 mAlarmTimer = new QTimer( this );
456 mRecheckAlarmTimer = new QTimer( this ); 456 mRecheckAlarmTimer = new QTimer( this );
457 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 457 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
458 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 458 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
459 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 459 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
460 mAlarmDialog = new AlarmDialog( this ); 460 mAlarmDialog = new AlarmDialog( this );
461 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 461 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
462 mAlarmDialog->setServerNotification( false ); 462 mAlarmDialog->setServerNotification( false );
463 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 463 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
464} 464}
465 465
466 466
467CalendarView::~CalendarView() 467CalendarView::~CalendarView()
468{ 468{
469 // kdDebug() << "~CalendarView()" << endl; 469 // kdDebug() << "~CalendarView()" << endl;
470 //qDebug("CalendarView::~CalendarView() "); 470 //qDebug("CalendarView::~CalendarView() ");
471 delete mDialogManager; 471 delete mDialogManager;
472 delete mViewManager; 472 delete mViewManager;
473 delete mStorage; 473 delete mStorage;
474 delete mDateFrame ; 474 delete mDateFrame ;
475 delete beamDialog; 475 delete beamDialog;
476 //kdDebug() << "~CalendarView() done" << endl; 476 //kdDebug() << "~CalendarView() done" << endl;
477} 477}
478void CalendarView::timerAlarm() 478void CalendarView::timerAlarm()
479{ 479{
480 //qDebug("CalendarView::timerAlarm() "); 480 //qDebug("CalendarView::timerAlarm() ");
481 computeAlarm(mAlarmNotification ); 481 computeAlarm(mAlarmNotification );
482} 482}
483 483
484void CalendarView::suspendAlarm() 484void CalendarView::suspendAlarm()
485{ 485{
486 //qDebug(" CalendarView::suspendAlarm() "); 486 //qDebug(" CalendarView::suspendAlarm() ");
487 computeAlarm(mSuspendAlarmNotification ); 487 computeAlarm(mSuspendAlarmNotification );
488 488
489} 489}
490 490
491void CalendarView::startAlarm( QString mess , QString filename) 491void CalendarView::startAlarm( QString mess , QString filename)
492{ 492{
493 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 493 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
494 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); 494 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
495 495
496} 496}
497 497
498void CalendarView::checkNextTimerAlarm() 498void CalendarView::checkNextTimerAlarm()
499{ 499{
500 mCalendar->checkAlarmForIncidence( 0, true ); 500 mCalendar->checkAlarmForIncidence( 0, true );
501} 501}
502 502
503void CalendarView::computeAlarm( QString msg ) 503void CalendarView::computeAlarm( QString msg )
504{ 504{
505 505
506 QString mess = msg; 506 QString mess = msg;
507 QString mAlarmMessage = mess.mid( 9 ); 507 QString mAlarmMessage = mess.mid( 9 );
508 QString filename = MainWindow::resourcePath(); 508 QString filename = MainWindow::resourcePath();
509 filename += "koalarm.wav"; 509 filename += "koalarm.wav";
510 QString tempfilename; 510 QString tempfilename;
511 if ( mess.left( 13 ) == "suspend_alarm") { 511 if ( mess.left( 13 ) == "suspend_alarm") {
512 bool error = false; 512 bool error = false;
513 int len = mess.mid( 13 ).find("+++"); 513 int len = mess.mid( 13 ).find("+++");
514 if ( len < 2 ) 514 if ( len < 2 )
515 error = true; 515 error = true;
516 else { 516 else {
517 tempfilename = mess.mid( 13, len ); 517 tempfilename = mess.mid( 13, len );
518 if ( !QFile::exists( tempfilename ) ) 518 if ( !QFile::exists( tempfilename ) )
519 error = true; 519 error = true;
520 } 520 }
521 if ( ! error ) { 521 if ( ! error ) {
522 filename = tempfilename; 522 filename = tempfilename;
523 } 523 }
524 mAlarmMessage = mess.mid( 13+len+3 ); 524 mAlarmMessage = mess.mid( 13+len+3 );
525 //qDebug("suspend file %s ",tempfilename.latin1() ); 525 //qDebug("suspend file %s ",tempfilename.latin1() );
526 startAlarm( mAlarmMessage, filename); 526 startAlarm( mAlarmMessage, filename);
527 return; 527 return;
528 } 528 }
529 if ( mess.left( 11 ) == "timer_alarm") { 529 if ( mess.left( 11 ) == "timer_alarm") {
530 //mTimerTime = 0; 530 //mTimerTime = 0;
531 startAlarm( mess.mid( 11 ), filename ); 531 startAlarm( mess.mid( 11 ), filename );
532 return; 532 return;
533 } 533 }
534 if ( mess.left( 10 ) == "proc_alarm") { 534 if ( mess.left( 10 ) == "proc_alarm") {
535 bool error = false; 535 bool error = false;
536 int len = mess.mid( 10 ).find("+++"); 536 int len = mess.mid( 10 ).find("+++");
537 if ( len < 2 ) 537 if ( len < 2 )
538 error = true; 538 error = true;
539 else { 539 else {
540 tempfilename = mess.mid( 10, len ); 540 tempfilename = mess.mid( 10, len );
541 if ( !QFile::exists( tempfilename ) ) 541 if ( !QFile::exists( tempfilename ) )
542 error = true; 542 error = true;
543 } 543 }
544 if ( error ) { 544 if ( error ) {
545 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 545 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
546 mAlarmMessage += mess.mid( 10+len+3+9 ); 546 mAlarmMessage += mess.mid( 10+len+3+9 );
547 } else { 547 } else {
548 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 548 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
549 //qDebug("-----system command %s ",tempfilename.latin1() ); 549 //qDebug("-----system command %s ",tempfilename.latin1() );
550#ifndef _WIN32_ 550#ifndef _WIN32_
551 if ( vfork () == 0 ) { 551 if ( vfork () == 0 ) {
552 execl ( tempfilename.latin1(), 0 ); 552 execl ( tempfilename.latin1(), 0 );
553 return; 553 return;
554 } 554 }
555#else 555#else
556 QProcess* p = new QProcess(); 556 QProcess* p = new QProcess();
557 p->addArgument( tempfilename.latin1() ); 557 p->addArgument( tempfilename.latin1() );
558 p->start(); 558 p->start();
559 return; 559 return;
560#endif 560#endif
561 561
562 return; 562 return;
563 } 563 }
564 564
565 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 565 //qDebug("+++++++system command %s ",tempfilename.latin1() );
566 } 566 }
567 if ( mess.left( 11 ) == "audio_alarm") { 567 if ( mess.left( 11 ) == "audio_alarm") {
568 bool error = false; 568 bool error = false;
569 int len = mess.mid( 11 ).find("+++"); 569 int len = mess.mid( 11 ).find("+++");
570 if ( len < 2 ) 570 if ( len < 2 )
571 error = true; 571 error = true;
572 else { 572 else {
573 tempfilename = mess.mid( 11, len ); 573 tempfilename = mess.mid( 11, len );
574 if ( !QFile::exists( tempfilename ) ) 574 if ( !QFile::exists( tempfilename ) )
575 error = true; 575 error = true;
576 } 576 }
577 if ( ! error ) { 577 if ( ! error ) {
578 filename = tempfilename; 578 filename = tempfilename;
579 } 579 }
580 mAlarmMessage = mess.mid( 11+len+3+9 ); 580 mAlarmMessage = mess.mid( 11+len+3+9 );
581 //qDebug("audio file command %s ",tempfilename.latin1() ); 581 //qDebug("audio file command %s ",tempfilename.latin1() );
582 } 582 }
583 if ( mess.left( 9 ) == "cal_alarm") { 583 if ( mess.left( 9 ) == "cal_alarm") {
584 mAlarmMessage = mess.mid( 9 ) ; 584 mAlarmMessage = mess.mid( 9 ) ;
585 } 585 }
586 586
587 startAlarm( mAlarmMessage, filename ); 587 startAlarm( mAlarmMessage, filename );
588 588
589 589
590} 590}
591 591
592void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 592void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
593{ 593{
594 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 594 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
595 595
596 mSuspendAlarmNotification = noti; 596 mSuspendAlarmNotification = noti;
597 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 597 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
598 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 598 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
599 mSuspendTimer->start( ms , true ); 599 mSuspendTimer->start( ms , true );
600 600
601} 601}
602 602
603void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 603void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
604{ 604{
605 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 605 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
606 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 606 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
607#ifndef DESKTOP_VERSION 607#ifndef DESKTOP_VERSION
608 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); 608 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() );
609#endif 609#endif
610 return; 610 return;
611 } 611 }
612 int maxSec; 612 int maxSec;
613 //maxSec = 5; //testing only 613 //maxSec = 5; //testing only
614 maxSec = 86400+3600; // one day+1hour 614 maxSec = 86400+3600; // one day+1hour
615 mAlarmNotification = noti; 615 mAlarmNotification = noti;
616 int sec = QDateTime::currentDateTime().secsTo( qdt ); 616 int sec = QDateTime::currentDateTime().secsTo( qdt );
617 if ( sec > maxSec ) { 617 if ( sec > maxSec ) {
618 mRecheckAlarmTimer->start( maxSec * 1000 ); 618 mRecheckAlarmTimer->start( maxSec * 1000 );
619 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 619 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
620 return; 620 return;
621 } else { 621 } else {
622 mRecheckAlarmTimer->stop(); 622 mRecheckAlarmTimer->stop();
623 } 623 }
624 //qDebug("Alarm timer started with secs: %d ", sec); 624 //qDebug("Alarm timer started with secs: %d ", sec);
625 mAlarmTimer->start( sec *1000 , true ); 625 mAlarmTimer->start( sec *1000 , true );
626 626
627} 627}
628// called by mRecheckAlarmTimer to get next alarm 628// called by mRecheckAlarmTimer to get next alarm
629// we need this, because a QTimer has only a max range of 25 days 629// we need this, because a QTimer has only a max range of 25 days
630void CalendarView::recheckTimerAlarm() 630void CalendarView::recheckTimerAlarm()
631{ 631{
632 mAlarmTimer->stop(); 632 mAlarmTimer->stop();
633 mRecheckAlarmTimer->stop(); 633 mRecheckAlarmTimer->stop();
634 mCalendar->checkAlarmForIncidence( 0, true ); 634 mCalendar->checkAlarmForIncidence( 0, true );
635} 635}
636void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 636void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
637{ 637{
638 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 638 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
639 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 639 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
640#ifndef DESKTOP_VERSION 640#ifndef DESKTOP_VERSION
641 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 641 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
642#endif 642#endif
643 return; 643 return;
644 } 644 }
645 mAlarmTimer->stop(); 645 mAlarmTimer->stop();
646} 646}
647void CalendarView::selectWeekNum ( int num ) 647void CalendarView::selectWeekNum ( int num )
648{ 648{
649 dateNavigator()->selectWeek( num ); 649 dateNavigator()->selectWeek( num );
650 mViewManager->showWeekView(); 650 mViewManager->showWeekView();
651} 651}
652KOViewManager *CalendarView::viewManager() 652KOViewManager *CalendarView::viewManager()
653{ 653{
654 return mViewManager; 654 return mViewManager;
655} 655}
656 656
657KODialogManager *CalendarView::dialogManager() 657KODialogManager *CalendarView::dialogManager()
658{ 658{
659 return mDialogManager; 659 return mDialogManager;
660} 660}
661 661
662QDate CalendarView::startDate() 662QDate CalendarView::startDate()
663{ 663{
664 DateList dates = mNavigator->selectedDates(); 664 DateList dates = mNavigator->selectedDates();
665 665
666 return dates.first(); 666 return dates.first();
667} 667}
668 668
669QDate CalendarView::endDate() 669QDate CalendarView::endDate()
670{ 670{
671 DateList dates = mNavigator->selectedDates(); 671 DateList dates = mNavigator->selectedDates();
672 672
673 return dates.last(); 673 return dates.last();
674} 674}
675 675
676 676
677void CalendarView::createPrinter() 677void CalendarView::createPrinter()
678{ 678{
679#ifndef KORG_NOPRINTER 679#ifndef KORG_NOPRINTER
680 if (!mCalPrinter) { 680 if (!mCalPrinter) {
681 mCalPrinter = new CalPrinter(this, mCalendar); 681 mCalPrinter = new CalPrinter(this, mCalendar);
682 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 682 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
683 } 683 }
684#endif 684#endif
685} 685}
686 686
687void CalendarView::confSync() 687void CalendarView::confSync()
688{ 688{
689 static KSyncPrefsDialog* sp = 0; 689 static KSyncPrefsDialog* sp = 0;
690 if ( ! sp ) { 690 if ( ! sp ) {
691 sp = new KSyncPrefsDialog( this, "syncprefs", true ); 691 sp = new KSyncPrefsDialog( this, "syncprefs", true );
692 } 692 }
693 sp->usrReadConfig(); 693 sp->usrReadConfig();
694#ifndef DESKTOP_VERSION 694#ifndef DESKTOP_VERSION
695 sp->showMaximized(); 695 sp->showMaximized();
696#else 696#else
697 sp->show(); 697 sp->show();
698#endif 698#endif
699 sp->exec(); 699 sp->exec();
700 KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); 700 KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames();
701 KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); 701 KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName ();
702} 702}
703 703
704 704
705//KOPrefs::instance()->mWriteBackFile 705//KOPrefs::instance()->mWriteBackFile
706//KOPrefs::instance()->mWriteBackExistingOnly 706//KOPrefs::instance()->mWriteBackExistingOnly
707 707
708// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 708// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
709// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 709// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
710// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 710// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
711// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 711// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
712// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 712// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
713// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 713// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
714 714
715int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 715int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
716{ 716{
717 717
718 //void setZaurusId(int id); 718 //void setZaurusId(int id);
719 // int zaurusId() const; 719 // int zaurusId() const;
720 // void setZaurusUid(int id); 720 // void setZaurusUid(int id);
721 // int zaurusUid() const; 721 // int zaurusUid() const;
722 // void setZaurusStat(int id); 722 // void setZaurusStat(int id);
723 // int zaurusStat() const; 723 // int zaurusStat() const;
724 // 0 equal 724 // 0 equal
725 // 1 take local 725 // 1 take local
726 // 2 take remote 726 // 2 take remote
727 // 3 cancel 727 // 3 cancel
728 QDateTime lastSync = mLastCalendarSync; 728 QDateTime lastSync = mLastCalendarSync;
729 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 729 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
730 bool remCh, locCh; 730 bool remCh, locCh;
731 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 731 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
732 if ( remCh )
733 qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
732 locCh = ( local->lastModified() > mLastCalendarSync ); 734 locCh = ( local->lastModified() > mLastCalendarSync );
733 //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() ); 735 //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() );
734 if ( !remCh && ! locCh ) { 736 if ( !remCh && ! locCh ) {
735 //qDebug("both not changed "); 737 qDebug("both not changed ");
736 lastSync = local->lastModified().addDays(1); 738 lastSync = local->lastModified().addDays(1);
737 } else { 739 } else {
738 if ( locCh ) { 740 if ( locCh ) {
739 //qDebug("loc changed %d %d", local->zaurusStat(), local->revision() ); 741 qDebug("loc changed %d", local->revision() );
740 lastSync = local->lastModified().addDays( -1 ); 742 lastSync = local->lastModified().addDays( -1 );
741 if ( !remCh ) 743 if ( !remCh )
742 remote->setLastModified( lastSync.addDays( -1 ) ); 744 remote->setLastModified( lastSync.addDays( -1 ) );
743 } else { 745 } else {
744 //qDebug(" not loc changed "); 746 qDebug(" not loc changed ");
745 lastSync = local->lastModified().addDays( 1 ); 747 lastSync = local->lastModified().addDays( 1 );
746 if ( remCh ) 748 if ( remCh )
747 remote->setLastModified( lastSync.addDays( 1 ) ); 749 remote->setLastModified( lastSync.addDays( 1 ) );
748 750
749 } 751 }
750 } 752 }
751 full = true; 753 full = true;
752 if ( mode < SYNC_PREF_ASK ) 754 if ( mode < SYNC_PREF_ASK )
753 mode = SYNC_PREF_ASK; 755 mode = SYNC_PREF_ASK;
754 } else { 756 } else {
755 if ( local->lastModified() == remote->lastModified() ) 757 if ( local->lastModified() == remote->lastModified() )
756 if ( local->revision() == remote->revision() ) 758 if ( local->revision() == remote->revision() )
757 return 0; 759 return 0;
758 760
759 } 761 }
760 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 762 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
761 763
762 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); 764 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision());
763 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); 765 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() );
764 //full = true; //debug only 766 //full = true; //debug only
765 if ( full ) { 767 if ( full ) {
766 bool equ = false; 768 bool equ = false;
767 if ( local->type() == "Event" ) { 769 if ( local->type() == "Event" ) {
768 equ = (*((Event*) local) == *((Event*) remote)); 770 equ = (*((Event*) local) == *((Event*) remote));
769 } 771 }
770 else if ( local->type() =="Todo" ) 772 else if ( local->type() =="Todo" )
771 equ = (*((Todo*) local) == (*(Todo*) remote)); 773 equ = (*((Todo*) local) == (*(Todo*) remote));
772 else if ( local->type() =="Journal" ) 774 else if ( local->type() =="Journal" )
773 equ = (*((Journal*) local) == *((Journal*) remote)); 775 equ = (*((Journal*) local) == *((Journal*) remote));
774 if ( equ ) { 776 if ( equ ) {
775 //qDebug("equal "); 777 //qDebug("equal ");
776 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 778 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
777 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 779 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
778 } 780 }
779 if ( mode < SYNC_PREF_FORCE_LOCAL ) 781 if ( mode < SYNC_PREF_FORCE_LOCAL )
780 return 0; 782 return 0;
781 783
782 }//else //debug only 784 }//else //debug only
783 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 785 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
784 } 786 }
785 int result; 787 int result;
786 bool localIsNew; 788 bool localIsNew;
789 qDebug("mLastCalendarSync %s lastsync %s --- local %s remote %s ",mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , local->lastModified().toString().latin1() , remote->lastModified().toString().latin1() );
790
787 if ( full && mode < SYNC_PREF_NEWEST ) 791 if ( full && mode < SYNC_PREF_NEWEST )
788 mode = SYNC_PREF_ASK; 792 mode = SYNC_PREF_ASK;
789 793
790 switch( mode ) { 794 switch( mode ) {
791 case SYNC_PREF_LOCAL: 795 case SYNC_PREF_LOCAL:
792 if ( lastSync > remote->lastModified() ) 796 if ( lastSync > remote->lastModified() )
793 return 1; 797 return 1;
794 if ( lastSync > local->lastModified() ) 798 if ( lastSync > local->lastModified() )
795 return 2; 799 return 2;
796 return 1; 800 return 1;
797 break; 801 break;
798 case SYNC_PREF_REMOTE: 802 case SYNC_PREF_REMOTE:
799 if ( lastSync > remote->lastModified() ) 803 if ( lastSync > remote->lastModified() )
800 return 1; 804 return 1;
801 if ( lastSync > local->lastModified() ) 805 if ( lastSync > local->lastModified() )
802 return 2; 806 return 2;
803 return 2; 807 return 2;
804 break; 808 break;
805 case SYNC_PREF_NEWEST: 809 case SYNC_PREF_NEWEST:
806 if ( local->lastModified() > remote->lastModified() ) 810 if ( local->lastModified() > remote->lastModified() )
807 return 1; 811 return 1;
808 else 812 else
809 return 2; 813 return 2;
810 break; 814 break;
811 case SYNC_PREF_ASK: 815 case SYNC_PREF_ASK:
812 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); 816 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() );
813 if ( lastSync > remote->lastModified() ) 817 if ( lastSync > remote->lastModified() )
814 return 1; 818 return 1;
815 if ( lastSync > local->lastModified() ) 819 if ( lastSync > local->lastModified() )
816 return 2; 820 return 2;
817 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); 821 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() );
818 localIsNew = local->lastModified() > remote->lastModified(); 822 localIsNew = local->lastModified() >= remote->lastModified();
819 if ( localIsNew ) 823 if ( localIsNew )
820 getEventViewerDialog()->setColorMode( 1 ); 824 getEventViewerDialog()->setColorMode( 1 );
821 else 825 else
822 getEventViewerDialog()->setColorMode( 2 ); 826 getEventViewerDialog()->setColorMode( 2 );
823 getEventViewerDialog()->setIncidence(local); 827 getEventViewerDialog()->setIncidence(local);
824 if ( localIsNew ) 828 if ( localIsNew )
825 getEventViewerDialog()->setColorMode( 2 ); 829 getEventViewerDialog()->setColorMode( 2 );
826 else 830 else
827 getEventViewerDialog()->setColorMode( 1 ); 831 getEventViewerDialog()->setColorMode( 1 );
828 getEventViewerDialog()->addIncidence(remote); 832 getEventViewerDialog()->addIncidence(remote);
829 getEventViewerDialog()->setColorMode( 0 ); 833 getEventViewerDialog()->setColorMode( 0 );
830 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 834 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
831 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 835 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
832 getEventViewerDialog()->showMe(); 836 getEventViewerDialog()->showMe();
833 result = getEventViewerDialog()->executeS( localIsNew ); 837 result = getEventViewerDialog()->executeS( localIsNew );
834 return result; 838 return result;
835 839
836 break; 840 break;
837 case SYNC_PREF_FORCE_LOCAL: 841 case SYNC_PREF_FORCE_LOCAL:
838 return 1; 842 return 1;
839 break; 843 break;
840 case SYNC_PREF_FORCE_REMOTE: 844 case SYNC_PREF_FORCE_REMOTE:
841 return 2; 845 return 2;
842 break; 846 break;
843 847
844 default: 848 default:
845 // SYNC_PREF_TAKE_BOTH not implemented 849 // SYNC_PREF_TAKE_BOTH not implemented
846 break; 850 break;
847 } 851 }
848 return 0; 852 return 0;
849} 853}
850Event* CalendarView::getLastSyncEvent() 854Event* CalendarView::getLastSyncEvent()
851{ 855{
852 Event* lse; 856 Event* lse;
853 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 857 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
854 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 858 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
855 if (!lse) { 859 if (!lse) {
856 lse = new Event(); 860 lse = new Event();
857 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 861 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
858 QString sum = ""; 862 QString sum = "";
859 if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 863 if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
860 sum = "E: "; 864 sum = "E: ";
861 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 865 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
862 lse->setDtStart( mLastCalendarSync ); 866 lse->setDtStart( mLastCalendarSync );
863 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 867 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
864 lse->setCategories( i18n("SyncEvent") ); 868 lse->setCategories( i18n("SyncEvent") );
865 lse->setReadOnly( true ); 869 lse->setReadOnly( true );
866 mCalendar->addEvent( lse ); 870 mCalendar->addEvent( lse );
867 } 871 }
868 872
869 return lse; 873 return lse;
870 874
871} 875}
872// probaly useless 876// probaly useless
873void CalendarView::setupExternSyncProfiles() 877void CalendarView::setupExternSyncProfiles()
874{ 878{
875 Event* lse; 879 Event* lse;
876 mExternLastSyncEvent.clear(); 880 mExternLastSyncEvent.clear();
877 int i; 881 int i;
878 for ( i = 0; i < KOPrefs::instance()->mExternSyncProfiles.count(); ++i ) { 882 for ( i = 0; i < KOPrefs::instance()->mExternSyncProfiles.count(); ++i ) {
879 lse = mCalendar->event( "last-syncEvent-"+ KOPrefs::instance()->mExternSyncProfiles[i] ); 883 lse = mCalendar->event( "last-syncEvent-"+ KOPrefs::instance()->mExternSyncProfiles[i] );
880 if ( lse ) 884 if ( lse )
881 mExternLastSyncEvent.append( lse ); 885 mExternLastSyncEvent.append( lse );
882 else 886 else
883 qDebug("Last Sync event not found for %s ", KOPrefs::instance()->mExternSyncProfiles[i].latin1()); 887 qDebug("Last Sync event not found for %s ", KOPrefs::instance()->mExternSyncProfiles[i].latin1());
884 } 888 }
885 889
886} 890}
887// we check, if the to delete event has a id for a profile 891// we check, if the to delete event has a id for a profile
888// if yes, we set this id in the profile to delete 892// if yes, we set this id in the profile to delete
889void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 893void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
890{ 894{
891 if ( lastSync.count() == 0 ) { 895 if ( lastSync.count() == 0 ) {
892 //qDebug(" lastSync.count() == 0"); 896 //qDebug(" lastSync.count() == 0");
893 return; 897 return;
894 } 898 }
895 if ( toDelete->type() == "Journal" ) 899 if ( toDelete->type() == "Journal" )
896 return; 900 return;
897 901
898 Event* eve = lastSync.first(); 902 Event* eve = lastSync.first();
899 903
900 while ( eve ) { 904 while ( eve ) {
901 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 905 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
902 if ( !id.isEmpty() ) { 906 if ( !id.isEmpty() ) {
903 QString des = eve->description(); 907 QString des = eve->description();
904 QString pref = "e"; 908 QString pref = "e";
905 if ( toDelete->type() == "Todo" ) 909 if ( toDelete->type() == "Todo" )
906 pref = "t"; 910 pref = "t";
907 des += pref+ id + ","; 911 des += pref+ id + ",";
908 eve->setReadOnly( false ); 912 eve->setReadOnly( false );
909 eve->setDescription( des ); 913 eve->setDescription( des );
910 //qDebug("setdes %s ", des.latin1()); 914 //qDebug("setdes %s ", des.latin1());
911 eve->setReadOnly( true ); 915 eve->setReadOnly( true );
912 } 916 }
913 eve = lastSync.next(); 917 eve = lastSync.next();
914 } 918 }
915 919
916} 920}
917void CalendarView::checkExternalId( Incidence * inc ) 921void CalendarView::checkExternalId( Incidence * inc )
918{ 922{
919 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 923 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
920 checkExternSyncEvent( lastSync, inc ); 924 checkExternSyncEvent( lastSync, inc );
921 925
922} 926}
923bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 927bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
924{ 928{
925 bool syncOK = true; 929 bool syncOK = true;
926 int addedEvent = 0; 930 int addedEvent = 0;
927 int addedEventR = 0; 931 int addedEventR = 0;
928 int deletedEventR = 0; 932 int deletedEventR = 0;
929 int deletedEventL = 0; 933 int deletedEventL = 0;
930 int changedLocal = 0; 934 int changedLocal = 0;
931 int changedRemote = 0; 935 int changedRemote = 0;
932 //QPtrList<Event> el = local->rawEvents(); 936 //QPtrList<Event> el = local->rawEvents();
933 Event* eventR; 937 Event* eventR;
934 QString uid; 938 QString uid;
935 int take; 939 int take;
936 Event* eventL; 940 Event* eventL;
937 Event* eventRSync; 941 Event* eventRSync;
938 Event* eventLSync; 942 Event* eventLSync;
939 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 943 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
940 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 944 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
941 bool fullDateRange = false; 945 bool fullDateRange = false;
942 local->resetTempSyncStat(); 946 local->resetTempSyncStat();
943 mLastCalendarSync = QDateTime::currentDateTime(); 947 mLastCalendarSync = QDateTime::currentDateTime();
944 QDateTime modifiedCalendar = mLastCalendarSync;; 948 QDateTime modifiedCalendar = mLastCalendarSync;;
949 eventLSync = getLastSyncEvent();
945 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 950 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
946 if ( eventR ) { 951 if ( eventR ) {
947 eventRSync = (Event*) eventR->clone(); 952 eventRSync = (Event*) eventR->clone();
948 remote->deleteEvent(eventR ); 953 remote->deleteEvent(eventR );
949 954
950 } else { 955 } else {
951 fullDateRange = true; 956 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
952 eventRSync = new Event(); 957 eventRSync = (Event*)eventLSync->clone();
953 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 958 } else {
954 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 959 fullDateRange = true;
955 eventRSync->setDtStart( mLastCalendarSync ); 960 eventRSync = new Event();
956 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 961 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
957 eventRSync->setCategories( i18n("SyncEvent") ); 962 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
963 eventRSync->setDtStart( mLastCalendarSync );
964 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
965 eventRSync->setCategories( i18n("SyncEvent") );
966 }
958 } 967 }
959 eventLSync = getLastSyncEvent();
960 if ( eventLSync->dtStart() == mLastCalendarSync ) 968 if ( eventLSync->dtStart() == mLastCalendarSync )
961 fullDateRange = true; 969 fullDateRange = true;
962 970
963 if ( ! fullDateRange ) { 971 if ( ! fullDateRange ) {
964 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 972 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
965 973
966 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 974 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
967 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 975 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
968 fullDateRange = true; 976 fullDateRange = true;
969 } 977 }
970 } 978 }
971 if ( fullDateRange ) 979 if ( fullDateRange )
972 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 980 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
973 else 981 else
974 mLastCalendarSync = eventLSync->dtStart(); 982 mLastCalendarSync = eventLSync->dtStart();
975 // for resyncing if own file has changed 983 // for resyncing if own file has changed
976 if ( mCurrentSyncDevice == "deleteaftersync" ) { 984 if ( mCurrentSyncDevice == "deleteaftersync" ) {
977 mLastCalendarSync = loadedFileVersion; 985 mLastCalendarSync = loadedFileVersion;
978 qDebug("setting mLastCalendarSync "); 986 qDebug("setting mLastCalendarSync ");
979 } 987 }
980 //qDebug("*************************** "); 988 //qDebug("*************************** ");
981 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); 989 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() );
982 QPtrList<Incidence> er = remote->rawIncidences(); 990 QPtrList<Incidence> er = remote->rawIncidences();
983 Incidence* inR = er.first(); 991 Incidence* inR = er.first();
984 Incidence* inL; 992 Incidence* inL;
985 QProgressBar bar( er.count(),0 ); 993 QProgressBar bar( er.count(),0 );
986 bar.setCaption (i18n("Syncing - close to abort!") ); 994 bar.setCaption (i18n("Syncing - close to abort!") );
987 995
988 int w = 300; 996 int w = 300;
989 if ( QApplication::desktop()->width() < 320 ) 997 if ( QApplication::desktop()->width() < 320 )
990 w = 220; 998 w = 220;
991 int h = bar.sizeHint().height() ; 999 int h = bar.sizeHint().height() ;
992 int dw = QApplication::desktop()->width(); 1000 int dw = QApplication::desktop()->width();
993 int dh = QApplication::desktop()->height(); 1001 int dh = QApplication::desktop()->height();
994 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1002 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
995 bar.show(); 1003 bar.show();
996 int modulo = (er.count()/10)+1; 1004 int modulo = (er.count()/10)+1;
997 int incCounter = 0; 1005 int incCounter = 0;
998 while ( inR ) { 1006 while ( inR ) {
999 if ( ! bar.isVisible() ) 1007 if ( ! bar.isVisible() )
1000 return false; 1008 return false;
1001 if ( incCounter % modulo == 0 ) 1009 if ( incCounter % modulo == 0 )
1002 bar.setProgress( incCounter ); 1010 bar.setProgress( incCounter );
1003 ++incCounter; 1011 ++incCounter;
1004 uid = inR->uid(); 1012 uid = inR->uid();
1005 bool skipIncidence = false; 1013 bool skipIncidence = false;
1006 if ( uid.left(15) == QString("last-syncEvent-") ) 1014 if ( uid.left(15) == QString("last-syncEvent-") )
1007 skipIncidence = true; 1015 skipIncidence = true;
1008 1016
1009 qApp->processEvents(); 1017 qApp->processEvents();
1010 if ( !skipIncidence ) { 1018 if ( !skipIncidence ) {
1011 inL = local->incidence( uid ); 1019 inL = local->incidence( uid );
1012 if ( inL ) { // maybe conflict - same uid in both calendars 1020 if ( inL ) { // maybe conflict - same uid in both calendars
1013 int maxrev = inL->revision(); 1021 int maxrev = inL->revision();
1014 if ( maxrev < inR->revision() ) 1022 if ( maxrev < inR->revision() )
1015 maxrev = inR->revision(); 1023 maxrev = inR->revision();
1016 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1024 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1017 //qDebug("take %d %s ", take, inL->summary().latin1()); 1025 //qDebug("take %d %s ", take, inL->summary().latin1());
1018 if ( take == 3 ) 1026 if ( take == 3 )
1019 return false; 1027 return false;
1020 if ( take == 1 ) {// take local 1028 if ( take == 1 ) {// take local
1021 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1029 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1022 remote->deleteIncidence( inR ); 1030 remote->deleteIncidence( inR );
1023 if ( inL->revision() < maxrev ) 1031 if ( inL->revision() < maxrev )
1024 inL->setRevision( maxrev ); 1032 inL->setRevision( maxrev );
1025 remote->addIncidence( inL->clone() ); 1033 remote->addIncidence( inL->clone() );
1026 ++changedRemote; 1034 ++changedRemote;
1027 } else { 1035 } else {
1028 if ( inR->revision() < maxrev ) 1036 if ( inR->revision() < maxrev )
1029 inR->setRevision( maxrev ); 1037 inR->setRevision( maxrev );
1030 local->deleteIncidence( inL ); 1038 local->deleteIncidence( inL );
1031 local->addIncidence( inR->clone() ); 1039 local->addIncidence( inR->clone() );
1032 ++changedLocal; 1040 ++changedLocal;
1033 } 1041 }
1034 } 1042 }
1035 } else { // no conflict 1043 } else { // no conflict
1036 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1044 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1037 QString des = eventLSync->description(); 1045 QString des = eventLSync->description();
1038 QString pref = "e"; 1046 QString pref = "e";
1039 if ( inR->type() == "Todo" ) 1047 if ( inR->type() == "Todo" )
1040 pref = "t"; 1048 pref = "t";
1041 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1049 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1042 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1050 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1043 //remote->deleteIncidence( inR ); 1051 //remote->deleteIncidence( inR );
1044 ++deletedEventR; 1052 ++deletedEventR;
1045 } else { 1053 } else {
1046 inR->setLastModified( modifiedCalendar ); 1054 inR->setLastModified( modifiedCalendar );
1047 local->addIncidence( inR->clone() ); 1055 local->addIncidence( inR->clone() );
1048 ++addedEvent; 1056 ++addedEvent;
1049 } 1057 }
1050 } else { 1058 } else {
1051 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1059 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1052 inR->setLastModified( modifiedCalendar ); 1060 inR->setLastModified( modifiedCalendar );
1053 local->addIncidence( inR->clone() ); 1061 local->addIncidence( inR->clone() );
1054 ++addedEvent; 1062 ++addedEvent;
1055 } else { 1063 } else {
1056 checkExternSyncEvent(eventRSyncSharp, inR); 1064 checkExternSyncEvent(eventRSyncSharp, inR);
1057 remote->deleteIncidence( inR ); 1065 remote->deleteIncidence( inR );
1058 ++deletedEventR; 1066 ++deletedEventR;
1059 } 1067 }
1060 } 1068 }
1061 } 1069 }
1062 } 1070 }
1063 inR = er.next(); 1071 inR = er.next();
1064 } 1072 }
1065 QPtrList<Incidence> el = local->rawIncidences(); 1073 QPtrList<Incidence> el = local->rawIncidences();
1066 inL = el.first(); 1074 inL = el.first();
1067 modulo = (el.count()/10)+1; 1075 modulo = (el.count()/10)+1;
1068 bar.setCaption (i18n("Add / remove events") ); 1076 bar.setCaption (i18n("Add / remove events") );
1069 bar.setTotalSteps ( el.count() ) ; 1077 bar.setTotalSteps ( el.count() ) ;
1070 bar.show(); 1078 bar.show();
1071 incCounter = 0; 1079 incCounter = 0;
1072 1080
1073 while ( inL ) { 1081 while ( inL ) {
1074 1082
1075 qApp->processEvents(); 1083 qApp->processEvents();
1076 if ( ! bar.isVisible() ) 1084 if ( ! bar.isVisible() )
1077 return false; 1085 return false;
1078 if ( incCounter % modulo == 0 ) 1086 if ( incCounter % modulo == 0 )
1079 bar.setProgress( incCounter ); 1087 bar.setProgress( incCounter );
1080 ++incCounter; 1088 ++incCounter;
1081 uid = inL->uid(); 1089 uid = inL->uid();
1082 bool skipIncidence = false; 1090 bool skipIncidence = false;
1083 if ( uid.left(15) == QString("last-syncEvent-") ) 1091 if ( uid.left(15) == QString("last-syncEvent-") )
1084 skipIncidence = true; 1092 skipIncidence = true;
1085 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) 1093 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
1086 skipIncidence = true; 1094 skipIncidence = true;
1087 if ( !skipIncidence ) { 1095 if ( !skipIncidence ) {
1088 inR = remote->incidence( uid ); 1096 inR = remote->incidence( uid );
1089 if ( ! inR ) { 1097 if ( ! inR ) {
1090 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1098 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1091 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1099 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1092 local->deleteIncidence( inL ); 1100 local->deleteIncidence( inL );
1093 ++deletedEventL; 1101 ++deletedEventL;
1094 } else { 1102 } else {
1095 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { 1103 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
1096 inL->removeID(mCurrentSyncDevice ); 1104 inL->removeID(mCurrentSyncDevice );
1097 ++addedEventR; 1105 ++addedEventR;
1098 inL->setLastModified( modifiedCalendar ); 1106 inL->setLastModified( modifiedCalendar );
1099 remote->addIncidence( inL->clone() ); 1107 remote->addIncidence( inL->clone() );
1100 } 1108 }
1101 } 1109 }
1102 } else { 1110 } else {
1103 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1111 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1104 checkExternSyncEvent(eventLSyncSharp, inL); 1112 checkExternSyncEvent(eventLSyncSharp, inL);
1105 local->deleteIncidence( inL ); 1113 local->deleteIncidence( inL );
1106 ++deletedEventL; 1114 ++deletedEventL;
1107 } else { 1115 } else {
1108 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { 1116 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
1109 ++addedEventR; 1117 ++addedEventR;
1110 inL->setLastModified( modifiedCalendar ); 1118 inL->setLastModified( modifiedCalendar );
1111 remote->addIncidence( inL->clone() ); 1119 remote->addIncidence( inL->clone() );
1112 } 1120 }
1113 } 1121 }
1114 } 1122 }
1115 } 1123 }
1116 } 1124 }
1117 inL = el.next(); 1125 inL = el.next();
1118 } 1126 }
1119 1127 if ( KOPrefs::instance()->mWriteBackInFuture ) {
1128 er = remote->rawIncidences();
1129 inR = er.first();
1130 QDateTime dt;
1131 QDateTime cur = QDateTime::currentDateTime();
1132 QDateTime end = cur.addSecs( KOPrefs::instance()->mWriteBackInFuture * 3600 *24 *7 );
1133 while ( inR ) {
1134 if ( inR->type() == "Todo" ) {
1135 Todo * t = (Todo*)inR;
1136 if ( t->hasDueDate() )
1137 dt = t->dtDue();
1138 else
1139 dt = cur.addSecs( 62 );
1140 }
1141 else dt = inR->dtStart();
1142 if ( dt < cur || dt > end )
1143 remote->deleteIncidence( inR );
1144 inR = er.next();
1145 }
1146 }
1120 bar.hide(); 1147 bar.hide();
1121 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1148 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1122 eventLSync->setReadOnly( false ); 1149 eventLSync->setReadOnly( false );
1123 eventLSync->setDtStart( mLastCalendarSync ); 1150 eventLSync->setDtStart( mLastCalendarSync );
1124 eventRSync->setDtStart( mLastCalendarSync ); 1151 eventRSync->setDtStart( mLastCalendarSync );
1125 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1152 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1126 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1153 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1127 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1154 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1128 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1155 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1129 eventLSync->setReadOnly( true ); 1156 eventLSync->setReadOnly( true );
1130 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 1157 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
1131 remote->addEvent( eventRSync ); 1158 remote->addEvent( eventRSync );
1132 QString mes; 1159 QString mes;
1133 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 ); 1160 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 );
1134 if ( KOPrefs::instance()->mShowSyncSummary ) { 1161 if ( KOPrefs::instance()->mShowSyncSummary ) {
1135 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); 1162 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") );
1136 } 1163 }
1137 qDebug( mes ); 1164 qDebug( mes );
1138 mCalendar->checkAlarmForIncidence( 0, true ); 1165 mCalendar->checkAlarmForIncidence( 0, true );
1139 return syncOK; 1166 return syncOK;
1140} 1167}
1141 1168
1142void CalendarView::setSyncDevice( QString s ) 1169void CalendarView::setSyncDevice( QString s )
1143{ 1170{
1144 mCurrentSyncDevice= s; 1171 mCurrentSyncDevice= s;
1145} 1172}
1146void CalendarView::setSyncName( QString s ) 1173void CalendarView::setSyncName( QString s )
1147{ 1174{
1148 mCurrentSyncName= s; 1175 mCurrentSyncName= s;
1149} 1176}
1150bool CalendarView::syncCalendar(QString filename, int mode) 1177bool CalendarView::syncCalendar(QString filename, int mode)
1151{ 1178{
1152 mGlobalSyncMode = SYNC_MODE_NORMAL; 1179 mGlobalSyncMode = SYNC_MODE_NORMAL;
1153 CalendarLocal* calendar = new CalendarLocal(); 1180 CalendarLocal* calendar = new CalendarLocal();
1154 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1181 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1155 FileStorage* storage = new FileStorage( calendar ); 1182 FileStorage* storage = new FileStorage( calendar );
1156 bool syncOK = false; 1183 bool syncOK = false;
1157 storage->setFileName( filename ); 1184 storage->setFileName( filename );
1158 // qDebug("loading ... "); 1185 // qDebug("loading ... ");
1159 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { 1186 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) {
1160 getEventViewerDialog()->setSyncMode( true ); 1187 getEventViewerDialog()->setSyncMode( true );
1161 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1188 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1162 getEventViewerDialog()->setSyncMode( false ); 1189 getEventViewerDialog()->setSyncMode( false );
1163 if ( syncOK ) { 1190 if ( syncOK ) {
1164 if ( KOPrefs::instance()->mWriteBackFile ) 1191 if ( KOPrefs::instance()->mWriteBackFile )
1165 { 1192 {
1166 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 1193 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
1167 storage->save(); 1194 storage->save();
1168 } 1195 }
1169 } 1196 }
1170 setModified( true ); 1197 setModified( true );
1171 } 1198 }
1172 delete storage; 1199 delete storage;
1173 delete calendar; 1200 delete calendar;
1174 if ( syncOK ) 1201 if ( syncOK )
1175 updateView(); 1202 updateView();
1176 return syncOK; 1203 return syncOK;
1177} 1204}
1178void CalendarView::syncPhone() 1205void CalendarView::syncPhone()
1179{ 1206{
1180 syncExternal( 1 ); 1207 syncExternal( 1 );
1181} 1208}
1182void CalendarView::syncExternal( int mode ) 1209void CalendarView::syncExternal( int mode )
1183{ 1210{
1184 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1211 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1185 //mCurrentSyncDevice = "sharp-DTM"; 1212 //mCurrentSyncDevice = "sharp-DTM";
1186 if ( KOPrefs::instance()->mAskForPreferences ) 1213 if ( KOPrefs::instance()->mAskForPreferences )
1187 edit_sync_options(); 1214 edit_sync_options();
1188 qApp->processEvents(); 1215 qApp->processEvents();
1189 CalendarLocal* calendar = new CalendarLocal(); 1216 CalendarLocal* calendar = new CalendarLocal();
1190 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1217 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1191 bool syncOK = false; 1218 bool syncOK = false;
1192 bool loadSuccess = false; 1219 bool loadSuccess = false;
1193 PhoneFormat* phoneFormat = 0; 1220 PhoneFormat* phoneFormat = 0;
1194#ifndef DESKTOP_VERSION 1221#ifndef DESKTOP_VERSION
1195 SharpFormat* sharpFormat = 0; 1222 SharpFormat* sharpFormat = 0;
1196 if ( mode == 0 ) { // sharp 1223 if ( mode == 0 ) { // sharp
1197 sharpFormat = new SharpFormat () ; 1224 sharpFormat = new SharpFormat () ;
1198 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1225 loadSuccess = sharpFormat->load( calendar, mCalendar );
1199 1226
1200 } else 1227 } else
1201#endif 1228#endif
1202 if ( mode == 1 ) { // phone 1229 if ( mode == 1 ) { // phone
1203 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1230 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1204 KOPrefs::instance()->mPhoneDevice, 1231 KOPrefs::instance()->mPhoneDevice,
1205 KOPrefs::instance()->mPhoneConnection, 1232 KOPrefs::instance()->mPhoneConnection,
1206 KOPrefs::instance()->mPhoneModel); 1233 KOPrefs::instance()->mPhoneModel);
1207 loadSuccess = phoneFormat->load( calendar,mCalendar); 1234 loadSuccess = phoneFormat->load( calendar,mCalendar);
1208 1235
1209 } else 1236 } else
1210 return; 1237 return;
1211 if ( loadSuccess ) { 1238 if ( loadSuccess ) {
1212 getEventViewerDialog()->setSyncMode( true ); 1239 getEventViewerDialog()->setSyncMode( true );
1213 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); 1240 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
1214 getEventViewerDialog()->setSyncMode( false ); 1241 getEventViewerDialog()->setSyncMode( false );
1215 qApp->processEvents(); 1242 qApp->processEvents();
1216 if ( syncOK ) { 1243 if ( syncOK ) {
1217 if ( KOPrefs::instance()->mWriteBackFile ) 1244 if ( KOPrefs::instance()->mWriteBackFile )
1218 { 1245 {
1219 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1246 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1220 Incidence* inc = iL.first(); 1247 Incidence* inc = iL.first();
1221 /* obsolete 1248 /* obsolete
1222 while ( inc ) { 1249 while ( inc ) {
1223 inc->setZaurusStat( inc->revision () ); 1250 inc->setZaurusStat( inc->revision () );
1224 inc = iL.next(); 1251 inc = iL.next();
1225 } 1252 }
1226 */ 1253 */
1227#ifndef DESKTOP_VERSION 1254#ifndef DESKTOP_VERSION
1228 if ( sharpFormat ) 1255 if ( sharpFormat )
1229 sharpFormat->save(calendar); 1256 sharpFormat->save(calendar);
1230#endif 1257#endif
1231 if ( phoneFormat ) 1258 if ( phoneFormat )
1232 phoneFormat->save(calendar); 1259 phoneFormat->save(calendar);
1233 iL = calendar->rawIncidences(); 1260 iL = calendar->rawIncidences();
1234 inc = iL.first(); 1261 inc = iL.first();
1235 Incidence* loc; 1262 Incidence* loc;
1236 while ( inc ) { 1263 while ( inc ) {
1237 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1264 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1238 loc = mCalendar->incidence(inc->uid() ); 1265 loc = mCalendar->incidence(inc->uid() );
1239 if ( loc ) { 1266 if ( loc ) {
1240 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1267 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1241 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1268 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1242 } 1269 }
1243 } 1270 }
1244 inc = iL.next(); 1271 inc = iL.next();
1245 } 1272 }
1246 Incidence* lse = getLastSyncEvent(); 1273 Incidence* lse = getLastSyncEvent();
1247 if ( lse ) { 1274 if ( lse ) {
1248 lse->setReadOnly( false ); 1275 lse->setReadOnly( false );
1249 lse->setDescription( "" ); 1276 lse->setDescription( "" );
1250 lse->setReadOnly( true ); 1277 lse->setReadOnly( true );
1251 } 1278 }
1252 } 1279 }
1253 } 1280 }
1254 setModified( true ); 1281 setModified( true );
1255 } else { 1282 } else {
1256 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1283 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1257 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1284 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1258 question, i18n("Ok")) ; 1285 question, i18n("Ok")) ;
1259 1286
1260 } 1287 }
1261 delete calendar; 1288 delete calendar;
1262 updateView(); 1289 updateView();
1263 return ;//syncOK; 1290 return ;//syncOK;
1264 1291
1265} 1292}
1266void CalendarView::syncSharp() 1293void CalendarView::syncSharp()
1267{ 1294{
1268 syncExternal( 0 ); 1295 syncExternal( 0 );
1269 1296
1270} 1297}
1271 1298
1272 1299
1273#include <kabc/stdaddressbook.h> 1300#include <kabc/stdaddressbook.h>
1274bool CalendarView::importBday() 1301bool CalendarView::importBday()
1275{ 1302{
1276 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1303 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1277 KABC::AddressBook::Iterator it; 1304 KABC::AddressBook::Iterator it;
1278 int count = 0; 1305 int count = 0;
1279 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1306 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1280 ++count; 1307 ++count;
1281 } 1308 }
1282 QProgressBar bar(count,0 ); 1309 QProgressBar bar(count,0 );
1283 int w = 300; 1310 int w = 300;
1284 if ( QApplication::desktop()->width() < 320 ) 1311 if ( QApplication::desktop()->width() < 320 )
1285 w = 220; 1312 w = 220;
1286 int h = bar.sizeHint().height() ; 1313 int h = bar.sizeHint().height() ;
1287 int dw = QApplication::desktop()->width(); 1314 int dw = QApplication::desktop()->width();
1288 int dh = QApplication::desktop()->height(); 1315 int dh = QApplication::desktop()->height();
1289 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1316 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1290 bar.show(); 1317 bar.show();
1291 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1318 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1292 qApp->processEvents(); 1319 qApp->processEvents();
1293 count = 0; 1320 count = 0;
1294 int addCount = 0; 1321 int addCount = 0;
1295 KCal::Attendee* a = 0; 1322 KCal::Attendee* a = 0;
1296 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1323 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1297 if ( ! bar.isVisible() ) 1324 if ( ! bar.isVisible() )
1298 return false; 1325 return false;
1299 bar.setProgress( count++ ); 1326 bar.setProgress( count++ );
1300 qApp->processEvents(); 1327 qApp->processEvents();
1301 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1328 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1302 if ( (*it).birthday().date().isValid() ){ 1329 if ( (*it).birthday().date().isValid() ){
1303 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1330 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1304 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1331 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1305 ++addCount; 1332 ++addCount;
1306 } 1333 }
1307 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1334 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1308 if ( anni.isValid() ){ 1335 if ( anni.isValid() ){
1309 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1336 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1310 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1337 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1311 ++addCount; 1338 ++addCount;
1312 } 1339 }
1313 } 1340 }
1314 updateView(); 1341 updateView();
1315 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1342 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1316 return true; 1343 return true;
1317} 1344}
1318 1345
1319bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1346bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1320{ 1347{
1321 //qDebug("addAnni "); 1348 //qDebug("addAnni ");
1322 Event * ev = new Event(); 1349 Event * ev = new Event();
1323 if ( a ) { 1350 if ( a ) {
1324 ev->addAttendee( a ); 1351 ev->addAttendee( a );
1325 } 1352 }
1326 QString kind; 1353 QString kind;
1327 if ( birthday ) 1354 if ( birthday )
1328 kind = i18n( "Birthday" ); 1355 kind = i18n( "Birthday" );
1329 else 1356 else
1330 kind = i18n( "Anniversary" ); 1357 kind = i18n( "Anniversary" );
1331 ev->setSummary( name + " - " + kind ); 1358 ev->setSummary( name + " - " + kind );
1332 ev->setOrganizer( "nobody@nowhere" ); 1359 ev->setOrganizer( "nobody@nowhere" );
1333 ev->setCategories( kind ); 1360 ev->setCategories( kind );
1334 ev->setDtStart( QDateTime(date) ); 1361 ev->setDtStart( QDateTime(date) );
1335 ev->setDtEnd( QDateTime(date) ); 1362 ev->setDtEnd( QDateTime(date) );
1336 ev->setFloats( true ); 1363 ev->setFloats( true );
1337 Recurrence * rec = ev->recurrence(); 1364 Recurrence * rec = ev->recurrence();
1338 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1365 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1339 rec->addYearlyNum( date.month() ); 1366 rec->addYearlyNum( date.month() );
1340 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1367 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1341 delete ev; 1368 delete ev;
1342 return false; 1369 return false;
1343 } 1370 }
1344 return true; 1371 return true;
1345 1372
1346} 1373}
1347bool CalendarView::importQtopia( const QString &categories, 1374bool CalendarView::importQtopia( const QString &categories,
1348 const QString &datebook, 1375 const QString &datebook,
1349 const QString &todolist ) 1376 const QString &todolist )
1350{ 1377{
1351 1378
1352 QtopiaFormat qtopiaFormat; 1379 QtopiaFormat qtopiaFormat;
1353 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1380 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1354 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1381 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1355 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1382 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1356 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1383 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1357 1384
1358 updateView(); 1385 updateView();
1359 return true; 1386 return true;
1360 1387
1361#if 0 1388#if 0
1362 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1389 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1363 mCurrentSyncDevice = "qtopia-XML"; 1390 mCurrentSyncDevice = "qtopia-XML";
1364 if ( KOPrefs::instance()->mAskForPreferences ) 1391 if ( KOPrefs::instance()->mAskForPreferences )
1365 edit_sync_options(); 1392 edit_sync_options();
1366 qApp->processEvents(); 1393 qApp->processEvents();
1367 CalendarLocal* calendar = new CalendarLocal(); 1394 CalendarLocal* calendar = new CalendarLocal();
1368 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1395 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1369 bool syncOK = false; 1396 bool syncOK = false;
1370 QtopiaFormat qtopiaFormat; 1397 QtopiaFormat qtopiaFormat;
1371 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1398 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1372 bool loadOk = true; 1399 bool loadOk = true;
1373 if ( !categories.isEmpty() ) 1400 if ( !categories.isEmpty() )
1374 loadOk = qtopiaFormat.load( calendar, categories ); 1401 loadOk = qtopiaFormat.load( calendar, categories );
1375 if ( loadOk && !datebook.isEmpty() ) 1402 if ( loadOk && !datebook.isEmpty() )
1376 loadOk = qtopiaFormat.load( calendar, datebook ); 1403 loadOk = qtopiaFormat.load( calendar, datebook );
1377 if ( loadOk && !todolist.isEmpty() ) 1404 if ( loadOk && !todolist.isEmpty() )
1378 loadOk = qtopiaFormat.load( calendar, todolist ); 1405 loadOk = qtopiaFormat.load( calendar, todolist );
1379 1406
1380 if ( loadOk ) { 1407 if ( loadOk ) {
1381 getEventViewerDialog()->setSyncMode( true ); 1408 getEventViewerDialog()->setSyncMode( true );
1382 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); 1409 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
1383 getEventViewerDialog()->setSyncMode( false ); 1410 getEventViewerDialog()->setSyncMode( false );
1384 qApp->processEvents(); 1411 qApp->processEvents();
1385 if ( syncOK ) { 1412 if ( syncOK ) {
1386 if ( KOPrefs::instance()->mWriteBackFile ) 1413 if ( KOPrefs::instance()->mWriteBackFile )
1387 { 1414 {
1388 // write back XML file 1415 // write back XML file
1389 1416
1390 } 1417 }
1391 setModified( true ); 1418 setModified( true );
1392 } 1419 }
1393 } else { 1420 } else {
1394 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1421 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1395 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1422 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1396 question, i18n("Ok")) ; 1423 question, i18n("Ok")) ;
1397 } 1424 }
1398 delete calendar; 1425 delete calendar;
1399 updateView(); 1426 updateView();
1400 return syncOK; 1427 return syncOK;
1401 1428
1402 1429
1403#endif 1430#endif
1404 1431
1405} 1432}
1406 1433
1407void CalendarView::setSyncEventsReadOnly() 1434void CalendarView::setSyncEventsReadOnly()
1408{ 1435{
1409 Event * ev; 1436 Event * ev;
1410 QPtrList<Event> eL = mCalendar->rawEvents(); 1437 QPtrList<Event> eL = mCalendar->rawEvents();
1411 ev = eL.first(); 1438 ev = eL.first();
1412 while ( ev ) { 1439 while ( ev ) {
1413 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1440 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1414 ev->setReadOnly( true ); 1441 ev->setReadOnly( true );
1415 ev = eL.next(); 1442 ev = eL.next();
1416 } 1443 }
1417} 1444}
1418bool CalendarView::openCalendar(QString filename, bool merge) 1445bool CalendarView::openCalendar(QString filename, bool merge)
1419{ 1446{
1420 1447
1421 if (filename.isEmpty()) { 1448 if (filename.isEmpty()) {
1422 return false; 1449 return false;
1423 } 1450 }
1424 1451
1425 if (!QFile::exists(filename)) { 1452 if (!QFile::exists(filename)) {
1426 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1453 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1427 return false; 1454 return false;
1428 } 1455 }
1429 1456
1430 globalFlagBlockAgenda = 1; 1457 globalFlagBlockAgenda = 1;
1431 if (!merge) mCalendar->close(); 1458 if (!merge) mCalendar->close();
1432 1459
1433 mStorage->setFileName( filename ); 1460 mStorage->setFileName( filename );
1434 1461
1435 if ( mStorage->load(KOPrefs::instance()->mUseQuicksave) ) { 1462 if ( mStorage->load(KOPrefs::instance()->mUseQuicksave) ) {
1436 if ( merge ) ;//setModified( true ); 1463 if ( merge ) ;//setModified( true );
1437 else { 1464 else {
1438 //setModified( true ); 1465 //setModified( true );
1439 mViewManager->setDocumentId( filename ); 1466 mViewManager->setDocumentId( filename );
1440 mDialogManager->setDocumentId( filename ); 1467 mDialogManager->setDocumentId( filename );
1441 mTodoList->setDocumentId( filename ); 1468 mTodoList->setDocumentId( filename );
1442 } 1469 }
1443 globalFlagBlockAgenda = 2; 1470 globalFlagBlockAgenda = 2;
1444 // if ( getLastSyncEvent() ) 1471 // if ( getLastSyncEvent() )
1445 // getLastSyncEvent()->setReadOnly( true ); 1472 // getLastSyncEvent()->setReadOnly( true );
1446 mCalendar->reInitAlarmSettings(); 1473 mCalendar->reInitAlarmSettings();
1447 setSyncEventsReadOnly(); 1474 setSyncEventsReadOnly();
1448 updateUnmanagedViews(); 1475 updateUnmanagedViews();
1449 updateView(); 1476 updateView();
1450 if ( filename != MainWindow::defaultFileName() ) 1477 if ( filename != MainWindow::defaultFileName() )
1451 saveCalendar( MainWindow::defaultFileName() ); 1478 saveCalendar( MainWindow::defaultFileName() );
1452 loadedFileVersion = QDateTime::currentDateTime(); 1479 loadedFileVersion = QDateTime::currentDateTime();
1453 return true; 1480 return true;
1454 } else { 1481 } else {
1455 // while failing to load, the calendar object could 1482 // while failing to load, the calendar object could
1456 // have become partially populated. Clear it out. 1483 // have become partially populated. Clear it out.
1457 if ( !merge ) mCalendar->close(); 1484 if ( !merge ) mCalendar->close();
1458 1485
1459 KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1486 KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1460 1487
1461 globalFlagBlockAgenda = 2; 1488 globalFlagBlockAgenda = 2;
1462 updateView(); 1489 updateView();
1463 } 1490 }
1464 return false; 1491 return false;
1465} 1492}
1466void CalendarView::setLoadedFileVersion(QDateTime dt) 1493void CalendarView::setLoadedFileVersion(QDateTime dt)
1467{ 1494{
1468 loadedFileVersion = dt; 1495 loadedFileVersion = dt;
1469} 1496}
1470bool CalendarView::checkFileChanged(QString fn) 1497bool CalendarView::checkFileChanged(QString fn)
1471{ 1498{
1472 QFileInfo finf ( fn ); 1499 QFileInfo finf ( fn );
1473 if ( !finf.exists() ) 1500 if ( !finf.exists() )
1474 return true; 1501 return true;
1475 QDateTime dt = finf.lastModified (); 1502 QDateTime dt = finf.lastModified ();
1476 if ( dt <= loadedFileVersion ) 1503 if ( dt <= loadedFileVersion )
1477 return false; 1504 return false;
1478 return true; 1505 return true;
1479 1506
1480} 1507}
1481bool CalendarView::checkFileVersion(QString fn) 1508bool CalendarView::checkFileVersion(QString fn)
1482{ 1509{
1483 QFileInfo finf ( fn ); 1510 QFileInfo finf ( fn );
1484 if ( !finf.exists() ) 1511 if ( !finf.exists() )
1485 return true; 1512 return true;
1486 QDateTime dt = finf.lastModified (); 1513 QDateTime dt = finf.lastModified ();
1487 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1514 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1488 //qDebug("file on disk version %s",dt.toString().latin1()); 1515 //qDebug("file on disk version %s",dt.toString().latin1());
1489 if ( dt <= loadedFileVersion ) 1516 if ( dt <= loadedFileVersion )
1490 return true; 1517 return true;
1491 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, false)) , 1518 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, false)) ,
1492 i18n("KO/Pi Warning"),i18n("Overwrite"), 1519 i18n("KO/Pi Warning"),i18n("Overwrite"),
1493 i18n("Sync+save")); 1520 i18n("Sync+save"));
1494 1521
1495 if ( km == KMessageBox::Cancel ) 1522 if ( km == KMessageBox::Cancel )
1496 return false; 1523 return false;
1497 if ( km == KMessageBox::Yes ) 1524 if ( km == KMessageBox::Yes )
1498 return true; 1525 return true;
1499 1526
1500 setSyncDevice("deleteaftersync" ); 1527 setSyncDevice("deleteaftersync" );
1501 KOPrefs::instance()->mAskForPreferences = true; 1528 KOPrefs::instance()->mAskForPreferences = true;
1502 KOPrefs::instance()->mSyncAlgoPrefs = 3; 1529 KOPrefs::instance()->mSyncAlgoPrefs = 3;
1503 KOPrefs::instance()->mWriteBackFile = false; 1530 KOPrefs::instance()->mWriteBackFile = false;
1504 KOPrefs::instance()->mWriteBackExistingOnly = false; 1531 KOPrefs::instance()->mWriteBackExistingOnly = false;
1505 KOPrefs::instance()->mShowSyncSummary = false; 1532 KOPrefs::instance()->mShowSyncSummary = false;
1506 syncCalendar( fn, 3 ); 1533 syncCalendar( fn, 3 );
1507 Event * e = getLastSyncEvent(); 1534 Event * e = getLastSyncEvent();
1508 mCalendar->deleteEvent ( e ); 1535 mCalendar->deleteEvent ( e );
1509 updateView(); 1536 updateView();
1510 return true; 1537 return true;
1511} 1538}
1512 1539
1513bool CalendarView::saveCalendar( QString filename ) 1540bool CalendarView::saveCalendar( QString filename )
1514{ 1541{
1515 1542
1516 // Store back all unsaved data into calendar object 1543 // Store back all unsaved data into calendar object
1517 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1544 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1518 if ( mViewManager->currentView() ) 1545 if ( mViewManager->currentView() )
1519 mViewManager->currentView()->flushView(); 1546 mViewManager->currentView()->flushView();
1520 1547
1521 //mStorage->setFileName( filename ); 1548 //mStorage->setFileName( filename );
1522 1549
1523 mStorage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 1550 mStorage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
1524 mStorage->setFileName( filename ); 1551 mStorage->setFileName( filename );
1525 bool success; 1552 bool success;
1526 success = mStorage->save(); 1553 success = mStorage->save();
1527 if ( !success ) { 1554 if ( !success ) {
1528 return false; 1555 return false;
1529 } 1556 }
1530 1557
1531 return true; 1558 return true;
1532} 1559}
1533 1560
1534void CalendarView::closeCalendar() 1561void CalendarView::closeCalendar()
1535{ 1562{
1536 1563
1537 // child windows no longer valid 1564 // child windows no longer valid
1538 emit closingDown(); 1565 emit closingDown();
1539 1566
1540 mCalendar->close(); 1567 mCalendar->close();
1541 setModified(false); 1568 setModified(false);
1542 updateView(); 1569 updateView();
1543} 1570}
1544 1571
1545void CalendarView::archiveCalendar() 1572void CalendarView::archiveCalendar()
1546{ 1573{
1547 mDialogManager->showArchiveDialog(); 1574 mDialogManager->showArchiveDialog();
1548} 1575}
1549 1576
1550 1577
1551void CalendarView::readSettings() 1578void CalendarView::readSettings()
1552{ 1579{
1553 1580
1554 1581
1555 // mViewManager->showAgendaView(); 1582 // mViewManager->showAgendaView();
1556 QString str; 1583 QString str;
1557 //qDebug("CalendarView::readSettings() "); 1584 //qDebug("CalendarView::readSettings() ");
1558 // read settings from the KConfig, supplying reasonable 1585 // read settings from the KConfig, supplying reasonable
1559 // defaults where none are to be found 1586 // defaults where none are to be found
1560 KConfig *config = KOGlobals::config(); 1587 KConfig *config = KOGlobals::config();
1561#ifndef KORG_NOSPLITTER 1588#ifndef KORG_NOSPLITTER
1562 config->setGroup("KOrganizer Geometry"); 1589 config->setGroup("KOrganizer Geometry");
1563 1590
1564 QValueList<int> sizes = config->readIntListEntry("Separator1"); 1591 QValueList<int> sizes = config->readIntListEntry("Separator1");
1565 if (sizes.count() != 2) { 1592 if (sizes.count() != 2) {
1566 sizes << mDateNavigator->minimumSizeHint().width(); 1593 sizes << mDateNavigator->minimumSizeHint().width();
1567 sizes << 300; 1594 sizes << 300;
1568 } 1595 }
1569 mPanner->setSizes(sizes); 1596 mPanner->setSizes(sizes);
1570 1597
1571 sizes = config->readIntListEntry("Separator2"); 1598 sizes = config->readIntListEntry("Separator2");
1572 if ( ( mResourceView && sizes.count() == 4 ) || 1599 if ( ( mResourceView && sizes.count() == 4 ) ||
1573 ( !mResourceView && sizes.count() == 3 ) ) { 1600 ( !mResourceView && sizes.count() == 3 ) ) {
1574 mLeftSplitter->setSizes(sizes); 1601 mLeftSplitter->setSizes(sizes);
1575 } 1602 }
1576#endif 1603#endif
1577 globalFlagBlockAgenda = 1; 1604 globalFlagBlockAgenda = 1;
1578 mViewManager->showAgendaView(); 1605 mViewManager->showAgendaView();
1579 //mViewManager->readSettings( config ); 1606 //mViewManager->readSettings( config );
1580 mTodoList->restoreLayout(config,QString("Todo Layout")); 1607 mTodoList->restoreLayout(config,QString("Todo Layout"));
1581 readFilterSettings(config); 1608 readFilterSettings(config);
1582 config->setGroup( "Views" ); 1609 config->setGroup( "Views" );
1583 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 1610 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
1584 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 1611 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
1585 else if ( dateCount == 7 ) mNavigator->selectWeek(); 1612 else if ( dateCount == 7 ) mNavigator->selectWeek();
1586 else mNavigator->selectDates( dateCount ); 1613 else mNavigator->selectDates( dateCount );
1587 // mViewManager->readSettings( config ); 1614 // mViewManager->readSettings( config );
1588 updateConfig(); 1615 updateConfig();
1589 globalFlagBlockAgenda = 2; 1616 globalFlagBlockAgenda = 2;
1590 mViewManager->readSettings( config ); 1617 mViewManager->readSettings( config );
1591#ifdef DESKTOP_VERSION 1618#ifdef DESKTOP_VERSION
1592 config->setGroup("WidgetLayout"); 1619 config->setGroup("WidgetLayout");
1593 QStringList list; 1620 QStringList list;
1594 list = config->readListEntry("MainLayout"); 1621 list = config->readListEntry("MainLayout");
1595 int x,y,w,h; 1622 int x,y,w,h;
1596 if ( ! list.isEmpty() ) { 1623 if ( ! list.isEmpty() ) {
1597 x = list[0].toInt(); 1624 x = list[0].toInt();
1598 y = list[1].toInt(); 1625 y = list[1].toInt();
1599 w = list[2].toInt(); 1626 w = list[2].toInt();
1600 h = list[3].toInt(); 1627 h = list[3].toInt();
1601 topLevelWidget()->setGeometry(x,y,w,h); 1628 topLevelWidget()->setGeometry(x,y,w,h);
1602 1629
1603 } else { 1630 } else {
1604 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 1631 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
1605 } 1632 }
1606 list = config->readListEntry("EditEventLayout"); 1633 list = config->readListEntry("EditEventLayout");
1607 if ( ! list.isEmpty() ) { 1634 if ( ! list.isEmpty() ) {
1608 x = list[0].toInt(); 1635 x = list[0].toInt();
1609 y = list[1].toInt(); 1636 y = list[1].toInt();
1610 w = list[2].toInt(); 1637 w = list[2].toInt();
1611 h = list[3].toInt(); 1638 h = list[3].toInt();
1612 mEventEditor->setGeometry(x,y,w,h); 1639 mEventEditor->setGeometry(x,y,w,h);
1613 1640
1614 } 1641 }
1615 list = config->readListEntry("EditTodoLayout"); 1642 list = config->readListEntry("EditTodoLayout");
1616 if ( ! list.isEmpty() ) { 1643 if ( ! list.isEmpty() ) {
1617 x = list[0].toInt(); 1644 x = list[0].toInt();
1618 y = list[1].toInt(); 1645 y = list[1].toInt();
1619 w = list[2].toInt(); 1646 w = list[2].toInt();
1620 h = list[3].toInt(); 1647 h = list[3].toInt();
1621 mTodoEditor->setGeometry(x,y,w,h); 1648 mTodoEditor->setGeometry(x,y,w,h);
1622 1649
1623 } 1650 }
1624 list = config->readListEntry("ViewerLayout"); 1651 list = config->readListEntry("ViewerLayout");
1625 if ( ! list.isEmpty() ) { 1652 if ( ! list.isEmpty() ) {
1626 x = list[0].toInt(); 1653 x = list[0].toInt();
1627 y = list[1].toInt(); 1654 y = list[1].toInt();
1628 w = list[2].toInt(); 1655 w = list[2].toInt();
1629 h = list[3].toInt(); 1656 h = list[3].toInt();
1630 getEventViewerDialog()->setGeometry(x,y,w,h); 1657 getEventViewerDialog()->setGeometry(x,y,w,h);
1631 } 1658 }
1632#endif 1659#endif
1633 1660
1634} 1661}
1635 1662
1636 1663
1637void CalendarView::writeSettings() 1664void CalendarView::writeSettings()
1638{ 1665{
1639 // kdDebug() << "CalendarView::writeSettings" << endl; 1666 // kdDebug() << "CalendarView::writeSettings" << endl;
1640 1667
1641 KConfig *config = KOGlobals::config(); 1668 KConfig *config = KOGlobals::config();
1642 1669
1643#ifndef KORG_NOSPLITTER 1670#ifndef KORG_NOSPLITTER
1644 config->setGroup("KOrganizer Geometry"); 1671 config->setGroup("KOrganizer Geometry");
1645 1672
1646 QValueList<int> list = mPanner->sizes(); 1673 QValueList<int> list = mPanner->sizes();
1647 config->writeEntry("Separator1",list); 1674 config->writeEntry("Separator1",list);
1648 1675
1649 list = mLeftSplitter->sizes(); 1676 list = mLeftSplitter->sizes();
1650 config->writeEntry("Separator2",list); 1677 config->writeEntry("Separator2",list);
1651#endif 1678#endif
1652 1679
1653 mViewManager->writeSettings( config ); 1680 mViewManager->writeSettings( config );
1654 mTodoList->saveLayout(config,QString("Todo Layout")); 1681 mTodoList->saveLayout(config,QString("Todo Layout"));
1655 mDialogManager->writeSettings( config ); 1682 mDialogManager->writeSettings( config );
1656 //KOPrefs::instance()->usrWriteConfig(); 1683 //KOPrefs::instance()->usrWriteConfig();
1657 KOPrefs::instance()->writeConfig(); 1684 KOPrefs::instance()->writeConfig();
1658 1685
1659 writeFilterSettings(config); 1686 writeFilterSettings(config);
1660 1687
1661 config->setGroup( "Views" ); 1688 config->setGroup( "Views" );
1662 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 1689 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
1663 1690
1664#ifdef DESKTOP_VERSION 1691#ifdef DESKTOP_VERSION
1665 config->setGroup("WidgetLayout"); 1692 config->setGroup("WidgetLayout");
1666 QStringList list ;//= config->readListEntry("MainLayout"); 1693 QStringList list ;//= config->readListEntry("MainLayout");
1667 int x,y,w,h; 1694 int x,y,w,h;
1668 QWidget* wid; 1695 QWidget* wid;
1669 wid = topLevelWidget(); 1696 wid = topLevelWidget();
1670 x = wid->geometry().x(); 1697 x = wid->geometry().x();
1671 y = wid->geometry().y(); 1698 y = wid->geometry().y();
1672 w = wid->width(); 1699 w = wid->width();
1673 h = wid->height(); 1700 h = wid->height();
1674 list.clear(); 1701 list.clear();
1675 list << QString::number( x ); 1702 list << QString::number( x );
1676 list << QString::number( y ); 1703 list << QString::number( y );
1677 list << QString::number( w ); 1704 list << QString::number( w );
1678 list << QString::number( h ); 1705 list << QString::number( h );
1679 config->writeEntry("MainLayout",list ); 1706 config->writeEntry("MainLayout",list );
1680 1707
1681 wid = mEventEditor; 1708 wid = mEventEditor;
1682 x = wid->geometry().x(); 1709 x = wid->geometry().x();
1683 y = wid->geometry().y(); 1710 y = wid->geometry().y();
1684 w = wid->width(); 1711 w = wid->width();
1685 h = wid->height(); 1712 h = wid->height();
1686 list.clear(); 1713 list.clear();
1687 list << QString::number( x ); 1714 list << QString::number( x );
1688 list << QString::number( y ); 1715 list << QString::number( y );
1689 list << QString::number( w ); 1716 list << QString::number( w );
1690 list << QString::number( h ); 1717 list << QString::number( h );
1691 config->writeEntry("EditEventLayout",list ); 1718 config->writeEntry("EditEventLayout",list );
1692 1719
1693 wid = mTodoEditor; 1720 wid = mTodoEditor;
1694 x = wid->geometry().x(); 1721 x = wid->geometry().x();
1695 y = wid->geometry().y(); 1722 y = wid->geometry().y();
1696 w = wid->width(); 1723 w = wid->width();
1697 h = wid->height(); 1724 h = wid->height();
1698 list.clear(); 1725 list.clear();
1699 list << QString::number( x ); 1726 list << QString::number( x );
1700 list << QString::number( y ); 1727 list << QString::number( y );
1701 list << QString::number( w ); 1728 list << QString::number( w );
1702 list << QString::number( h ); 1729 list << QString::number( h );
1703 config->writeEntry("EditTodoLayout",list ); 1730 config->writeEntry("EditTodoLayout",list );
1704 wid = getEventViewerDialog(); 1731 wid = getEventViewerDialog();
1705 x = wid->geometry().x(); 1732 x = wid->geometry().x();
1706 y = wid->geometry().y(); 1733 y = wid->geometry().y();
1707 w = wid->width(); 1734 w = wid->width();
1708 h = wid->height(); 1735 h = wid->height();
1709 list.clear(); 1736 list.clear();
1710 list << QString::number( x ); 1737 list << QString::number( x );
1711 list << QString::number( y ); 1738 list << QString::number( y );
1712 list << QString::number( w ); 1739 list << QString::number( w );
1713 list << QString::number( h ); 1740 list << QString::number( h );
1714 config->writeEntry("ViewerLayout",list ); 1741 config->writeEntry("ViewerLayout",list );
1715 wid = mDialogManager->getSearchDialog(); 1742 wid = mDialogManager->getSearchDialog();
1716 if ( wid ) { 1743 if ( wid ) {
1717 x = wid->geometry().x(); 1744 x = wid->geometry().x();
1718 y = wid->geometry().y(); 1745 y = wid->geometry().y();
1719 w = wid->width(); 1746 w = wid->width();
1720 h = wid->height(); 1747 h = wid->height();
1721 list.clear(); 1748 list.clear();
1722 list << QString::number( x ); 1749 list << QString::number( x );
1723 list << QString::number( y ); 1750 list << QString::number( y );
1724 list << QString::number( w ); 1751 list << QString::number( w );
1725 list << QString::number( h ); 1752 list << QString::number( h );
1726 config->writeEntry("SearchLayout",list ); 1753 config->writeEntry("SearchLayout",list );
1727 } 1754 }
1728#endif 1755#endif
1729 1756
1730 1757
1731 config->sync(); 1758 config->sync();
1732} 1759}
1733 1760
1734void CalendarView::readFilterSettings(KConfig *config) 1761void CalendarView::readFilterSettings(KConfig *config)
1735{ 1762{
1736 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 1763 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
1737 1764
1738 mFilters.clear(); 1765 mFilters.clear();
1739 1766
1740 config->setGroup("General"); 1767 config->setGroup("General");
1741 QStringList filterList = config->readListEntry("CalendarFilters"); 1768 QStringList filterList = config->readListEntry("CalendarFilters");
1742 1769
1743 QStringList::ConstIterator it = filterList.begin(); 1770 QStringList::ConstIterator it = filterList.begin();
1744 QStringList::ConstIterator end = filterList.end(); 1771 QStringList::ConstIterator end = filterList.end();
1745 while(it != end) { 1772 while(it != end) {
1746 // kdDebug() << " filter: " << (*it) << endl; 1773 // kdDebug() << " filter: " << (*it) << endl;
1747 1774
1748 CalFilter *filter; 1775 CalFilter *filter;
1749 filter = new CalFilter(*it); 1776 filter = new CalFilter(*it);
1750 config->setGroup("Filter_" + (*it)); 1777 config->setGroup("Filter_" + (*it));
1751 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 1778 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
1752 filter->setCriteria(config->readNumEntry("Criteria",0)); 1779 filter->setCriteria(config->readNumEntry("Criteria",0));
1753 filter->setCategoryList(config->readListEntry("CategoryList")); 1780 filter->setCategoryList(config->readListEntry("CategoryList"));
1754 mFilters.append(filter); 1781 mFilters.append(filter);
1755 1782
1756 ++it; 1783 ++it;
1757 } 1784 }
1758 1785
1759 if (mFilters.count() == 0) { 1786 if (mFilters.count() == 0) {
1760 CalFilter *filter = new CalFilter(i18n("Default")); 1787 CalFilter *filter = new CalFilter(i18n("Default"));
1761 mFilters.append(filter); 1788 mFilters.append(filter);
1762 } 1789 }
1763 mFilterView->updateFilters(); 1790 mFilterView->updateFilters();
1764 config->setGroup("FilterView"); 1791 config->setGroup("FilterView");
1765 1792
1766 mFilterView->blockSignals(true); 1793 mFilterView->blockSignals(true);
1767 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 1794 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
1768 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 1795 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
1769 mFilterView->blockSignals(false); 1796 mFilterView->blockSignals(false);
1770 // We do it manually to avoid it being done twice by the above calls 1797 // We do it manually to avoid it being done twice by the above calls
1771 updateFilter(); 1798 updateFilter();
1772} 1799}
1773 1800
1774void CalendarView::writeFilterSettings(KConfig *config) 1801void CalendarView::writeFilterSettings(KConfig *config)
1775{ 1802{
1776 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 1803 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
1777 1804
1778 QStringList filterList; 1805 QStringList filterList;
1779 1806
1780 CalFilter *filter = mFilters.first(); 1807 CalFilter *filter = mFilters.first();
1781 while(filter) { 1808 while(filter) {
1782 // kdDebug() << " fn: " << filter->name() << endl; 1809 // kdDebug() << " fn: " << filter->name() << endl;
1783 filterList << filter->name(); 1810 filterList << filter->name();
1784 config->setGroup("Filter_" + filter->name()); 1811 config->setGroup("Filter_" + filter->name());
1785 config->writeEntry("Criteria",filter->criteria()); 1812 config->writeEntry("Criteria",filter->criteria());
1786 config->writeEntry("CategoryList",filter->categoryList()); 1813 config->writeEntry("CategoryList",filter->categoryList());
1787 filter = mFilters.next(); 1814 filter = mFilters.next();
1788 } 1815 }
1789 config->setGroup("General"); 1816 config->setGroup("General");
1790 config->writeEntry("CalendarFilters",filterList); 1817 config->writeEntry("CalendarFilters",filterList);
1791 1818
1792 config->setGroup("FilterView"); 1819 config->setGroup("FilterView");
1793 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 1820 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
1794 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 1821 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
1795} 1822}
1796 1823
1797 1824
1798void CalendarView::goToday() 1825void CalendarView::goToday()
1799{ 1826{
1800 mNavigator->selectToday(); 1827 mNavigator->selectToday();
1801} 1828}
1802 1829
1803void CalendarView::goNext() 1830void CalendarView::goNext()
1804{ 1831{
1805 mNavigator->selectNext(); 1832 mNavigator->selectNext();
1806} 1833}
1807 1834
1808void CalendarView::goPrevious() 1835void CalendarView::goPrevious()
1809{ 1836{
1810 mNavigator->selectPrevious(); 1837 mNavigator->selectPrevious();
1811} 1838}
1812void CalendarView::goNextMonth() 1839void CalendarView::goNextMonth()
1813{ 1840{
1814 mNavigator->selectNextMonth(); 1841 mNavigator->selectNextMonth();
1815} 1842}
1816 1843
1817void CalendarView::goPreviousMonth() 1844void CalendarView::goPreviousMonth()
1818{ 1845{
1819 mNavigator->selectPreviousMonth(); 1846 mNavigator->selectPreviousMonth();
1820} 1847}
1821void CalendarView::writeLocale() 1848void CalendarView::writeLocale()
1822{ 1849{
1823 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); 1850 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime );
1824 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); 1851 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday );
1825 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); 1852 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate );
1826 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); 1853 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage );
1827 QString dummy = KOPrefs::instance()->mUserDateFormatLong; 1854 QString dummy = KOPrefs::instance()->mUserDateFormatLong;
1828 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 1855 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
1829 dummy = KOPrefs::instance()->mUserDateFormatShort; 1856 dummy = KOPrefs::instance()->mUserDateFormatShort;
1830 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 1857 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
1831 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, 1858 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving,
1832 KOPrefs::instance()->mDaylightsavingStart, 1859 KOPrefs::instance()->mDaylightsavingStart,
1833 KOPrefs::instance()->mDaylightsavingEnd ); 1860 KOPrefs::instance()->mDaylightsavingEnd );
1834 KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId ); 1861 KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId );
1835} 1862}
1836void CalendarView::updateConfig() 1863void CalendarView::updateConfig()
1837{ 1864{
1838 writeLocale(); 1865 writeLocale();
1839 if ( KOPrefs::instance()->mUseAppColors ) 1866 if ( KOPrefs::instance()->mUseAppColors )
1840 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 1867 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
1841 emit configChanged(); 1868 emit configChanged();
1842 mTodoList->updateConfig(); 1869 mTodoList->updateConfig();
1843 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 1870 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
1844 mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1871 mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1845 // To make the "fill window" configurations work 1872 // To make the "fill window" configurations work
1846 //mViewManager->raiseCurrentView(); 1873 //mViewManager->raiseCurrentView();
1847} 1874}
1848 1875
1849 1876
1850void CalendarView::eventChanged(Event *event) 1877void CalendarView::eventChanged(Event *event)
1851{ 1878{
1852 changeEventDisplay(event,KOGlobals::EVENTEDITED); 1879 changeEventDisplay(event,KOGlobals::EVENTEDITED);
1853 //updateUnmanagedViews(); 1880 //updateUnmanagedViews();
1854} 1881}
1855 1882
1856void CalendarView::eventAdded(Event *event) 1883void CalendarView::eventAdded(Event *event)
1857{ 1884{
1858 changeEventDisplay(event,KOGlobals::EVENTADDED); 1885 changeEventDisplay(event,KOGlobals::EVENTADDED);
1859} 1886}
1860 1887
1861void CalendarView::eventToBeDeleted(Event *) 1888void CalendarView::eventToBeDeleted(Event *)
1862{ 1889{
1863 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 1890 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
1864} 1891}
1865 1892
1866void CalendarView::eventDeleted() 1893void CalendarView::eventDeleted()
1867{ 1894{
1868 changeEventDisplay(0,KOGlobals::EVENTDELETED); 1895 changeEventDisplay(0,KOGlobals::EVENTDELETED);
1869} 1896}
1870void CalendarView::changeTodoDisplay(Todo *which, int action) 1897void CalendarView::changeTodoDisplay(Todo *which, int action)
1871{ 1898{
1872 changeIncidenceDisplay((Incidence *)which, action); 1899 changeIncidenceDisplay((Incidence *)which, action);
1873 mDateNavigator->updateView(); 1900 mDateNavigator->updateView();
1874 //mDialogManager->updateSearchDialog(); 1901 //mDialogManager->updateSearchDialog();
1875 1902
1876 if (which) { 1903 if (which) {
1877 mViewManager->currentView()->updateView(); 1904 mViewManager->currentView()->updateView();
1878 //mTodoList->updateView(); 1905 //mTodoList->updateView();
1879 } 1906 }
1880 1907
1881} 1908}
1882 1909
1883void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 1910void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
1884{ 1911{
1885 updateUnmanagedViews(); 1912 updateUnmanagedViews();
1886 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 1913 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
1887 if ( action == KOGlobals::EVENTDELETED ) { //delete 1914 if ( action == KOGlobals::EVENTDELETED ) { //delete
1888 mCalendar->checkAlarmForIncidence( 0, true ); 1915 mCalendar->checkAlarmForIncidence( 0, true );
1889 if ( mEventViewerDialog ) 1916 if ( mEventViewerDialog )
1890 mEventViewerDialog->hide(); 1917 mEventViewerDialog->hide();
1891 } 1918 }
1892 else 1919 else
1893 mCalendar->checkAlarmForIncidence( which , false ); 1920 mCalendar->checkAlarmForIncidence( which , false );
1894} 1921}
1895 1922
1896// most of the changeEventDisplays() right now just call the view's 1923// most of the changeEventDisplays() right now just call the view's
1897// total update mode, but they SHOULD be recoded to be more refresh-efficient. 1924// total update mode, but they SHOULD be recoded to be more refresh-efficient.
1898void CalendarView::changeEventDisplay(Event *which, int action) 1925void CalendarView::changeEventDisplay(Event *which, int action)
1899{ 1926{
1900 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 1927 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
1901 changeIncidenceDisplay((Incidence *)which, action); 1928 changeIncidenceDisplay((Incidence *)which, action);
1902 mDateNavigator->updateView(); 1929 mDateNavigator->updateView();
1903 //mDialogManager->updateSearchDialog(); 1930 //mDialogManager->updateSearchDialog();
1904 1931
1905 if (which) { 1932 if (which) {
1906 // If there is an event view visible update the display 1933 // If there is an event view visible update the display
1907 mViewManager->currentView()->changeEventDisplay(which,action); 1934 mViewManager->currentView()->changeEventDisplay(which,action);
1908 // TODO: check, if update needed 1935 // TODO: check, if update needed
1909 // if (which->getTodoStatus()) { 1936 // if (which->getTodoStatus()) {
1910 mTodoList->updateView(); 1937 mTodoList->updateView();
1911 // } 1938 // }
1912 } else { 1939 } else {
1913 mViewManager->currentView()->updateView(); 1940 mViewManager->currentView()->updateView();
1914 } 1941 }
1915} 1942}
1916 1943
1917 1944
1918void CalendarView::updateTodoViews() 1945void CalendarView::updateTodoViews()
1919{ 1946{
1920 1947
1921 mTodoList->updateView(); 1948 mTodoList->updateView();
1922 mViewManager->currentView()->updateView(); 1949 mViewManager->currentView()->updateView();
1923 1950
1924} 1951}
1925 1952
1926 1953
1927void CalendarView::updateView(const QDate &start, const QDate &end) 1954void CalendarView::updateView(const QDate &start, const QDate &end)
1928{ 1955{
1929 mTodoList->updateView(); 1956 mTodoList->updateView();
1930 mViewManager->updateView(start, end); 1957 mViewManager->updateView(start, end);
1931 //mDateNavigator->updateView(); 1958 //mDateNavigator->updateView();
1932} 1959}
1933 1960
1934void CalendarView::updateView() 1961void CalendarView::updateView()
1935{ 1962{
1936 DateList tmpList = mNavigator->selectedDates(); 1963 DateList tmpList = mNavigator->selectedDates();
1937 1964
1938 // We assume that the navigator only selects consecutive days. 1965 // We assume that the navigator only selects consecutive days.
1939 updateView( tmpList.first(), tmpList.last() ); 1966 updateView( tmpList.first(), tmpList.last() );
1940} 1967}
1941 1968
1942void CalendarView::updateUnmanagedViews() 1969void CalendarView::updateUnmanagedViews()
1943{ 1970{
1944 mDateNavigator->updateDayMatrix(); 1971 mDateNavigator->updateDayMatrix();
1945} 1972}
1946 1973
1947int CalendarView::msgItemDelete() 1974int CalendarView::msgItemDelete()
1948{ 1975{
1949 return KMessageBox::warningContinueCancel(this, 1976 return KMessageBox::warningContinueCancel(this,
1950 i18n("This item will be\npermanently deleted."), 1977 i18n("This item will be\npermanently deleted."),
1951 i18n("KO/Pi Confirmation"),i18n("Delete")); 1978 i18n("KO/Pi Confirmation"),i18n("Delete"));
1952} 1979}
1953 1980
1954 1981
1955void CalendarView::edit_cut() 1982void CalendarView::edit_cut()
1956{ 1983{
1957 Event *anEvent=0; 1984 Event *anEvent=0;
1958 1985
1959 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 1986 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
1960 1987
1961 if (mViewManager->currentView()->isEventView()) { 1988 if (mViewManager->currentView()->isEventView()) {
1962 if ( incidence && incidence->type() == "Event" ) { 1989 if ( incidence && incidence->type() == "Event" ) {
1963 anEvent = static_cast<Event *>(incidence); 1990 anEvent = static_cast<Event *>(incidence);
1964 } 1991 }
1965 } 1992 }
1966 1993
1967 if (!anEvent) { 1994 if (!anEvent) {
1968 KNotifyClient::beep(); 1995 KNotifyClient::beep();
1969 return; 1996 return;
1970 } 1997 }
1971 DndFactory factory( mCalendar ); 1998 DndFactory factory( mCalendar );
1972 factory.cutEvent(anEvent); 1999 factory.cutEvent(anEvent);
1973 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2000 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
1974} 2001}
1975 2002
1976void CalendarView::edit_copy() 2003void CalendarView::edit_copy()
1977{ 2004{
1978 Event *anEvent=0; 2005 Event *anEvent=0;
1979 2006
1980 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2007 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
1981 2008
1982 if (mViewManager->currentView()->isEventView()) { 2009 if (mViewManager->currentView()->isEventView()) {
1983 if ( incidence && incidence->type() == "Event" ) { 2010 if ( incidence && incidence->type() == "Event" ) {
1984 anEvent = static_cast<Event *>(incidence); 2011 anEvent = static_cast<Event *>(incidence);
1985 } 2012 }
1986 } 2013 }
1987 2014
1988 if (!anEvent) { 2015 if (!anEvent) {
1989 KNotifyClient::beep(); 2016 KNotifyClient::beep();
1990 return; 2017 return;
1991 } 2018 }
1992 DndFactory factory( mCalendar ); 2019 DndFactory factory( mCalendar );
1993 factory.copyEvent(anEvent); 2020 factory.copyEvent(anEvent);
1994} 2021}
1995 2022
1996void CalendarView::edit_paste() 2023void CalendarView::edit_paste()
1997{ 2024{
1998 QDate date = mNavigator->selectedDates().first(); 2025 QDate date = mNavigator->selectedDates().first();
1999 2026
2000 DndFactory factory( mCalendar ); 2027 DndFactory factory( mCalendar );
2001 Event *pastedEvent = factory.pasteEvent( date ); 2028 Event *pastedEvent = factory.pasteEvent( date );
2002 2029
2003 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 2030 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
2004} 2031}
2005 2032
2006void CalendarView::edit_options() 2033void CalendarView::edit_options()
2007{ 2034{
2008 mDialogManager->showOptionsDialog(); 2035 mDialogManager->showOptionsDialog();
2009 //writeSettings(); 2036 //writeSettings();
2010} 2037}
2011void CalendarView::edit_sync_options() 2038void CalendarView::edit_sync_options()
2012{ 2039{
2013 //mDialogManager->showSyncOptions(); 2040 //mDialogManager->showSyncOptions();
2014 //KOPrefs::instance()->mSyncAlgoPrefs 2041 //KOPrefs::instance()->mSyncAlgoPrefs
2015 QDialog dia( this, "dia", true ); 2042 QDialog dia( this, "dia", true );
2016 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); 2043 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice );
2017 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); 2044 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia);
2018 QVBoxLayout lay ( &dia ); 2045 QVBoxLayout lay ( &dia );
2019 lay.setSpacing( 2 ); 2046 lay.setSpacing( 2 );
2020 lay.setMargin( 3 ); 2047 lay.setMargin( 3 );
2021 lay.addWidget(&gr); 2048 lay.addWidget(&gr);
2022 QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); 2049 QRadioButton loc ( i18n("Take local entry on conflict"), &gr );
2023 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); 2050 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr );
2024 QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); 2051 QRadioButton newest( i18n("Take newest entry on conflict"), &gr );
2025 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); 2052 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr );
2026 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); 2053 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr );
2027 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); 2054 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr );
2028 //QRadioButton both( i18n("Take both on conflict"), &gr ); 2055 //QRadioButton both( i18n("Take both on conflict"), &gr );
2029 QPushButton pb ( "OK", &dia); 2056 QPushButton pb ( "OK", &dia);
2030 lay.addWidget( &pb ); 2057 lay.addWidget( &pb );
2031 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 2058 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
2032 switch ( KOPrefs::instance()->mSyncAlgoPrefs ) { 2059 switch ( KOPrefs::instance()->mSyncAlgoPrefs ) {
2033 case 0: 2060 case 0:
2034 loc.setChecked( true); 2061 loc.setChecked( true);
2035 break; 2062 break;
2036 case 1: 2063 case 1:
2037 rem.setChecked( true ); 2064 rem.setChecked( true );
2038 break; 2065 break;
2039 case 2: 2066 case 2:
2040 newest.setChecked( true); 2067 newest.setChecked( true);
2041 break; 2068 break;
2042 case 3: 2069 case 3:
2043 ask.setChecked( true); 2070 ask.setChecked( true);
2044 break; 2071 break;
2045 case 4: 2072 case 4:
2046 f_loc.setChecked( true); 2073 f_loc.setChecked( true);
2047 break; 2074 break;
2048 case 5: 2075 case 5:
2049 f_rem.setChecked( true); 2076 f_rem.setChecked( true);
2050 break; 2077 break;
2051 case 6: 2078 case 6:
2052 // both.setChecked( true); 2079 // both.setChecked( true);
2053 break; 2080 break;
2054 default: 2081 default:
2055 break; 2082 break;
2056 } 2083 }
2057 if ( dia.exec() ) { 2084 if ( dia.exec() ) {
2058 KOPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; 2085 KOPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ;
2059 } 2086 }
2060 2087
2061} 2088}
2062 2089
2063void CalendarView::slotSelectPickerDate( QDate d) 2090void CalendarView::slotSelectPickerDate( QDate d)
2064{ 2091{
2065 mDateFrame->hide(); 2092 mDateFrame->hide();
2066 if ( mDatePickerMode == 1 ) { 2093 if ( mDatePickerMode == 1 ) {
2067 mNavigator->slotDaySelect( d ); 2094 mNavigator->slotDaySelect( d );
2068 } else if ( mDatePickerMode == 2 ) { 2095 } else if ( mDatePickerMode == 2 ) {
2069 if ( mMoveIncidence->type() == "Todo" ) { 2096 if ( mMoveIncidence->type() == "Todo" ) {
2070 Todo * to = (Todo *) mMoveIncidence; 2097 Todo * to = (Todo *) mMoveIncidence;
2071 QTime tim; 2098 QTime tim;
2072 if ( to->hasDueDate() ) 2099 if ( to->hasDueDate() )
2073 tim = to->dtDue().time(); 2100 tim = to->dtDue().time();
2074 else { 2101 else {
2075 tim = QTime ( 0,0,0 ); 2102 tim = QTime ( 0,0,0 );
2076 to->setFloats( true ); 2103 to->setFloats( true );
2077 to->setHasDueDate( true ); 2104 to->setHasDueDate( true );
2078 } 2105 }
2079 QDateTime dt ( d,tim ); 2106 QDateTime dt ( d,tim );
2080 to->setDtDue( dt ); 2107 to->setDtDue( dt );
2081 todoChanged( to ); 2108 todoChanged( to );
2082 } else { 2109 } else {
2083 QTime tim = mMoveIncidence->dtStart().time(); 2110 QTime tim = mMoveIncidence->dtStart().time();
2084 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2111 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2085 QDateTime dt ( d,tim ); 2112 QDateTime dt ( d,tim );
2086 mMoveIncidence->setDtStart( dt ); 2113 mMoveIncidence->setDtStart( dt );
2087 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2114 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2088 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2115 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2089 } 2116 }
2090 2117
2091 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2118 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2092 } 2119 }
2093} 2120}
2094 2121
2095void CalendarView::removeCategories() 2122void CalendarView::removeCategories()
2096{ 2123{
2097 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2124 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2098 QStringList catList = KOPrefs::instance()->mCustomCategories; 2125 QStringList catList = KOPrefs::instance()->mCustomCategories;
2099 QStringList catIncList; 2126 QStringList catIncList;
2100 QStringList newCatList; 2127 QStringList newCatList;
2101 Incidence* inc = incList.first(); 2128 Incidence* inc = incList.first();
2102 int i; 2129 int i;
2103 int count = 0; 2130 int count = 0;
2104 while ( inc ) { 2131 while ( inc ) {
2105 newCatList.clear(); 2132 newCatList.clear();
2106 catIncList = inc->categories() ; 2133 catIncList = inc->categories() ;
2107 for( i = 0; i< catIncList.count(); ++i ) { 2134 for( i = 0; i< catIncList.count(); ++i ) {
2108 if ( catList.contains (catIncList[i])) 2135 if ( catList.contains (catIncList[i]))
2109 newCatList.append( catIncList[i] ); 2136 newCatList.append( catIncList[i] );
2110 } 2137 }
2111 newCatList.sort(); 2138 newCatList.sort();
2112 inc->setCategories( newCatList.join(",") ); 2139 inc->setCategories( newCatList.join(",") );
2113 inc = incList.next(); 2140 inc = incList.next();
2114 } 2141 }
2115} 2142}
2116 2143
2117int CalendarView::addCategories() 2144int CalendarView::addCategories()
2118{ 2145{
2119 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2146 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2120 QStringList catList = KOPrefs::instance()->mCustomCategories; 2147 QStringList catList = KOPrefs::instance()->mCustomCategories;
2121 QStringList catIncList; 2148 QStringList catIncList;
2122 Incidence* inc = incList.first(); 2149 Incidence* inc = incList.first();
2123 int i; 2150 int i;
2124 int count = 0; 2151 int count = 0;
2125 while ( inc ) { 2152 while ( inc ) {
2126 catIncList = inc->categories() ; 2153 catIncList = inc->categories() ;
2127 for( i = 0; i< catIncList.count(); ++i ) { 2154 for( i = 0; i< catIncList.count(); ++i ) {
2128 if ( !catList.contains (catIncList[i])) { 2155 if ( !catList.contains (catIncList[i])) {
2129 catList.append( catIncList[i] ); 2156 catList.append( catIncList[i] );
2130 //qDebug("add cat %s ", catIncList[i].latin1()); 2157 //qDebug("add cat %s ", catIncList[i].latin1());
2131 ++count; 2158 ++count;
2132 } 2159 }
2133 } 2160 }
2134 inc = incList.next(); 2161 inc = incList.next();
2135 } 2162 }
2136 catList.sort(); 2163 catList.sort();
2137 KOPrefs::instance()->mCustomCategories = catList; 2164 KOPrefs::instance()->mCustomCategories = catList;
2138 return count; 2165 return count;
2139} 2166}
2140 2167
2141void CalendarView::manageCategories() 2168void CalendarView::manageCategories()
2142{ 2169{
2143 KOCatPrefs* cp = new KOCatPrefs(); 2170 KOCatPrefs* cp = new KOCatPrefs();
2144 cp->show(); 2171 cp->show();
2145 int w =cp->sizeHint().width() ; 2172 int w =cp->sizeHint().width() ;
2146 int h = cp->sizeHint().height() ; 2173 int h = cp->sizeHint().height() ;
2147 int dw = QApplication::desktop()->width(); 2174 int dw = QApplication::desktop()->width();
2148 int dh = QApplication::desktop()->height(); 2175 int dh = QApplication::desktop()->height();
2149 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2176 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2150 if ( !cp->exec() ) { 2177 if ( !cp->exec() ) {
2151 delete cp; 2178 delete cp;
2152 return; 2179 return;
2153 } 2180 }
2154 int count = 0; 2181 int count = 0;
2155 if ( cp->addCat() ) { 2182 if ( cp->addCat() ) {
2156 count = addCategories(); 2183 count = addCategories();
2157 if ( count ) { 2184 if ( count ) {
2158 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2185 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2159 writeSettings(); 2186 writeSettings();
2160 } 2187 }
2161 } else { 2188 } else {
2162 removeCategories(); 2189 removeCategories();
2163 updateView(); 2190 updateView();
2164 } 2191 }
2165 delete cp; 2192 delete cp;
2166} 2193}
2167 2194
2168void CalendarView::beamIncidence(Incidence * Inc) 2195void CalendarView::beamIncidence(Incidence * Inc)
2169{ 2196{
2170 QPtrList<Incidence> delSel ; 2197 QPtrList<Incidence> delSel ;
2171 delSel.append(Inc); 2198 delSel.append(Inc);
2172 beamIncidenceList( delSel ); 2199 beamIncidenceList( delSel );
2173} 2200}
2174void CalendarView::beamCalendar() 2201void CalendarView::beamCalendar()
2175{ 2202{
2176 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2203 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2177 //qDebug("beamCalendar() "); 2204 //qDebug("beamCalendar() ");
2178 beamIncidenceList( delSel ); 2205 beamIncidenceList( delSel );
2179} 2206}
2180void CalendarView::beamFilteredCalendar() 2207void CalendarView::beamFilteredCalendar()
2181{ 2208{
2182 QPtrList<Incidence> delSel = mCalendar->incidences(); 2209 QPtrList<Incidence> delSel = mCalendar->incidences();
2183 //qDebug("beamFilteredCalendar() "); 2210 //qDebug("beamFilteredCalendar() ");
2184 beamIncidenceList( delSel ); 2211 beamIncidenceList( delSel );
2185} 2212}
2186void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2213void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2187{ 2214{
2188 if ( beamDialog->exec () == QDialog::Rejected ) 2215 if ( beamDialog->exec () == QDialog::Rejected )
2189 return; 2216 return;
2190 2217
2191 QString fn = "/tmp/kopibeamfile"; 2218 QString fn = "/tmp/kopibeamfile";
2192 QString mes; 2219 QString mes;
2193 bool createbup = true; 2220 bool createbup = true;
2194 if ( createbup ) { 2221 if ( createbup ) {
2195 QString description = "\n"; 2222 QString description = "\n";
2196 CalendarLocal* cal = new CalendarLocal(); 2223 CalendarLocal* cal = new CalendarLocal();
2197 if ( beamDialog->beamLocal() ) 2224 if ( beamDialog->beamLocal() )
2198 cal->setLocalTime(); 2225 cal->setLocalTime();
2199 else 2226 else
2200 cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 2227 cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
2201 Incidence *incidence = delSel.first(); 2228 Incidence *incidence = delSel.first();
2202 bool addText = false; 2229 bool addText = false;
2203 if ( delSel.count() < 10 ) 2230 if ( delSel.count() < 10 )
2204 addText = true; 2231 addText = true;
2205 else { 2232 else {
2206 description.sprintf(i18n(" %d items?"),delSel.count() ); 2233 description.sprintf(i18n(" %d items?"),delSel.count() );
2207 } 2234 }
2208 while ( incidence ) { 2235 while ( incidence ) {
2209 Incidence *in = incidence->clone(); 2236 Incidence *in = incidence->clone();
2210 if ( addText ) 2237 if ( addText )
2211 description += in->summary() + "\n"; 2238 description += in->summary() + "\n";
2212 cal->addIncidence( in ); 2239 cal->addIncidence( in );
2213 incidence = delSel.next(); 2240 incidence = delSel.next();
2214 } 2241 }
2215 if ( beamDialog->beamVcal() ) { 2242 if ( beamDialog->beamVcal() ) {
2216 fn += ".vcs"; 2243 fn += ".vcs";
2217 FileStorage storage( cal, fn, new VCalFormat ); 2244 FileStorage storage( cal, fn, new VCalFormat );
2218 storage.save(); 2245 storage.save();
2219 } else { 2246 } else {
2220 fn += ".ics"; 2247 fn += ".ics";
2221 FileStorage storage( cal, fn, new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 2248 FileStorage storage( cal, fn, new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
2222 storage.save(); 2249 storage.save();
2223 } 2250 }
2224 delete cal; 2251 delete cal;
2225 mes = i18n("KO/Pi: Ready for beaming"); 2252 mes = i18n("KO/Pi: Ready for beaming");
2226 setCaption(mes); 2253 setCaption(mes);
2227 2254
2228#ifndef DESKTOP_VERSION 2255#ifndef DESKTOP_VERSION
2229 Ir *ir = new Ir( this ); 2256 Ir *ir = new Ir( this );
2230 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 2257 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2231 ir->send( fn, description, "text/x-vCalendar" ); 2258 ir->send( fn, description, "text/x-vCalendar" );
2232#endif 2259#endif
2233 } 2260 }
2234} 2261}
2235void CalendarView::beamDone( Ir *ir ) 2262void CalendarView::beamDone( Ir *ir )
2236{ 2263{
2237#ifndef DESKTOP_VERSION 2264#ifndef DESKTOP_VERSION
2238 delete ir; 2265 delete ir;
2239#endif 2266#endif
2240} 2267}
2241 2268
2242void CalendarView::moveIncidence(Incidence * inc ) 2269void CalendarView::moveIncidence(Incidence * inc )
2243{ 2270{
2244 if ( !inc ) return; 2271 if ( !inc ) return;
2245 // qDebug("showDatePickerForIncidence( ) "); 2272 // qDebug("showDatePickerForIncidence( ) ");
2246 if ( mDateFrame->isVisible() ) 2273 if ( mDateFrame->isVisible() )
2247 mDateFrame->hide(); 2274 mDateFrame->hide();
2248 else { 2275 else {
2249 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; 2276 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ;
2250 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; 2277 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ;
2251 int dw = QApplication::desktop()->width(); 2278 int dw = QApplication::desktop()->width();
2252 int dh = QApplication::desktop()->height(); 2279 int dh = QApplication::desktop()->height();
2253 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2280 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2254 mDateFrame->show(); 2281 mDateFrame->show();
2255 } 2282 }
2256 mDatePickerMode = 2; 2283 mDatePickerMode = 2;
2257 mMoveIncidence = inc ; 2284 mMoveIncidence = inc ;
2258 QDate da; 2285 QDate da;
2259 if ( mMoveIncidence->type() == "Todo" ) { 2286 if ( mMoveIncidence->type() == "Todo" ) {
2260 Todo * to = (Todo *) mMoveIncidence; 2287 Todo * to = (Todo *) mMoveIncidence;
2261 if ( to->hasDueDate() ) 2288 if ( to->hasDueDate() )
2262 da = to->dtDue().date(); 2289 da = to->dtDue().date();
2263 else 2290 else
2264 da = QDate::currentDate(); 2291 da = QDate::currentDate();
2265 } else { 2292 } else {
2266 da = mMoveIncidence->dtStart().date(); 2293 da = mMoveIncidence->dtStart().date();
2267 } 2294 }
2268 mDatePicker->setDate( da ); 2295 mDatePicker->setDate( da );
2269} 2296}
2270void CalendarView::showDatePicker( ) 2297void CalendarView::showDatePicker( )
2271{ 2298{
2272 //qDebug("CalendarView::showDatePicker( ) "); 2299 //qDebug("CalendarView::showDatePicker( ) ");
2273 if ( mDateFrame->isVisible() ) 2300 if ( mDateFrame->isVisible() )
2274 mDateFrame->hide(); 2301 mDateFrame->hide();
2275 else { 2302 else {
2276 int w =mDatePicker->sizeHint().width() ; 2303 int w =mDatePicker->sizeHint().width() ;
2277 int h = mDatePicker->sizeHint().height() ; 2304 int h = mDatePicker->sizeHint().height() ;
2278 int dw = QApplication::desktop()->width(); 2305 int dw = QApplication::desktop()->width();
2279 int dh = QApplication::desktop()->height(); 2306 int dh = QApplication::desktop()->height();
2280 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2307 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2281 mDateFrame->show(); 2308 mDateFrame->show();
2282 } 2309 }
2283 mDatePickerMode = 1; 2310 mDatePickerMode = 1;
2284 mDatePicker->setDate( mNavigator->selectedDates().first() ); 2311 mDatePicker->setDate( mNavigator->selectedDates().first() );
2285} 2312}
2286 2313
2287void CalendarView::showEventEditor() 2314void CalendarView::showEventEditor()
2288{ 2315{
2289#ifdef DESKTOP_VERSION 2316#ifdef DESKTOP_VERSION
2290 mEventEditor->show(); 2317 mEventEditor->show();
2291#else 2318#else
2292 mEventEditor->showMaximized(); 2319 mEventEditor->showMaximized();
2293#endif 2320#endif
2294} 2321}
2295void CalendarView::showTodoEditor() 2322void CalendarView::showTodoEditor()
2296{ 2323{
2297#ifdef DESKTOP_VERSION 2324#ifdef DESKTOP_VERSION
2298 mTodoEditor->show(); 2325 mTodoEditor->show();
2299#else 2326#else
2300 mTodoEditor->showMaximized(); 2327 mTodoEditor->showMaximized();
2301#endif 2328#endif
2302} 2329}
2303void CalendarView::cancelIncidence(Incidence * inc ) 2330void CalendarView::cancelIncidence(Incidence * inc )
2304{ 2331{
2305 inc->setCancelled( ! inc->cancelled() ); 2332 inc->setCancelled( ! inc->cancelled() );
2306 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 2333 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
2307 updateView(); 2334 updateView();
2308} 2335}
2309void CalendarView::cloneIncidence(Incidence * orgInc ) 2336void CalendarView::cloneIncidence(Incidence * orgInc )
2310{ 2337{
2311 Incidence * newInc = orgInc->clone(); 2338 Incidence * newInc = orgInc->clone();
2312 newInc->recreate(); 2339 newInc->recreate();
2313 2340
2314 if ( newInc->type() == "Todo" ) { 2341 if ( newInc->type() == "Todo" ) {
2315 Todo* t = (Todo*) newInc; 2342 Todo* t = (Todo*) newInc;
2316 mTodoEditor->editTodo( t ); 2343 mTodoEditor->editTodo( t );
2317 showTodoEditor(); 2344 showTodoEditor();
2318 if ( mTodoEditor->exec() ) { 2345 if ( mTodoEditor->exec() ) {
2319 mCalendar->addTodo( t ); 2346 mCalendar->addTodo( t );
2320 updateView(); 2347 updateView();
2321 } else { 2348 } else {
2322 delete t; 2349 delete t;
2323 } 2350 }
2324 } 2351 }
2325 else { 2352 else {
2326 Event* e = (Event*) newInc; 2353 Event* e = (Event*) newInc;
2327 mEventEditor->editEvent( e ); 2354 mEventEditor->editEvent( e );
2328 showEventEditor(); 2355 showEventEditor();
2329 if ( mEventEditor->exec() ) { 2356 if ( mEventEditor->exec() ) {
2330 mCalendar->addEvent( e ); 2357 mCalendar->addEvent( e );
2331 updateView(); 2358 updateView();
2332 } else { 2359 } else {
2333 delete e; 2360 delete e;
2334 } 2361 }
2335 } 2362 }
2336} 2363}
2337 2364
2338void CalendarView::newEvent() 2365void CalendarView::newEvent()
2339{ 2366{
2340 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 2367 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
2341 KOAgendaView *aView = mViewManager->agendaView(); 2368 KOAgendaView *aView = mViewManager->agendaView();
2342 if (aView) { 2369 if (aView) {
2343 if (aView->selectionStart().isValid()) { 2370 if (aView->selectionStart().isValid()) {
2344 if (aView->selectedIsAllDay()) { 2371 if (aView->selectedIsAllDay()) {
2345 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 2372 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
2346 } else { 2373 } else {
2347 newEvent(aView->selectionStart(),aView->selectionEnd()); 2374 newEvent(aView->selectionStart(),aView->selectionEnd());
2348 } 2375 }
2349 return; 2376 return;
2350 } 2377 }
2351 } 2378 }
2352 2379
2353 QDate date = mNavigator->selectedDates().first(); 2380 QDate date = mNavigator->selectedDates().first();
2354 QDateTime current = QDateTime::currentDateTime(); 2381 QDateTime current = QDateTime::currentDateTime();
2355 if ( date <= current.date() ) { 2382 if ( date <= current.date() ) {
2356 int hour = current.time().hour() +1; 2383 int hour = current.time().hour() +1;
2357 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 2384 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
2358 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2385 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2359 } else 2386 } else
2360 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 2387 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
2361 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 2388 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
2362 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2389 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2363} 2390}
2364 2391
2365void CalendarView::newEvent(QDateTime fh) 2392void CalendarView::newEvent(QDateTime fh)
2366{ 2393{
2367 newEvent(fh, 2394 newEvent(fh,
2368 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 2395 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
2369} 2396}
2370 2397
2371void CalendarView::newEvent(QDate dt) 2398void CalendarView::newEvent(QDate dt)
2372{ 2399{
2373 newEvent(QDateTime(dt, QTime(0,0,0)), 2400 newEvent(QDateTime(dt, QTime(0,0,0)),
2374 QDateTime(dt, QTime(0,0,0)), true); 2401 QDateTime(dt, QTime(0,0,0)), true);
2375} 2402}
2376 2403
2377void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 2404void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
2378{ 2405{
2379 2406
2380 mEventEditor->newEvent(fromHint,toHint,allDay); 2407 mEventEditor->newEvent(fromHint,toHint,allDay);
2381 if ( mFilterView->filtersEnabled() ) { 2408 if ( mFilterView->filtersEnabled() ) {
2382 CalFilter *filter = mFilterView->selectedFilter(); 2409 CalFilter *filter = mFilterView->selectedFilter();
2383 if (filter && filter->showCategories()) { 2410 if (filter && filter->showCategories()) {
2384 mEventEditor->setCategories(filter->categoryList().join(",") ); 2411 mEventEditor->setCategories(filter->categoryList().join(",") );
2385 } 2412 }
2386 if ( filter ) 2413 if ( filter )
2387 mEventEditor->setSecrecy( filter->getSecrecy() ); 2414 mEventEditor->setSecrecy( filter->getSecrecy() );
2388 } 2415 }
2389 showEventEditor(); 2416 showEventEditor();
2390} 2417}
2391void CalendarView::todoAdded(Todo * t) 2418void CalendarView::todoAdded(Todo * t)
2392{ 2419{
2393 2420
2394 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 2421 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
2395 updateTodoViews(); 2422 updateTodoViews();
2396} 2423}
2397void CalendarView::todoChanged(Todo * t) 2424void CalendarView::todoChanged(Todo * t)
2398{ 2425{
2399 emit todoModified( t, 4 ); 2426 emit todoModified( t, 4 );
2400 // updateTodoViews(); 2427 // updateTodoViews();
2401} 2428}
2402void CalendarView::todoToBeDeleted(Todo *) 2429void CalendarView::todoToBeDeleted(Todo *)
2403{ 2430{
2404 //qDebug("todoToBeDeleted(Todo *) "); 2431 //qDebug("todoToBeDeleted(Todo *) ");
2405 updateTodoViews(); 2432 updateTodoViews();
2406} 2433}
2407void CalendarView::todoDeleted() 2434void CalendarView::todoDeleted()
2408{ 2435{
2409 //qDebug(" todoDeleted()"); 2436 //qDebug(" todoDeleted()");
2410 updateTodoViews(); 2437 updateTodoViews();
2411} 2438}
2412 2439
2413 2440
2414 2441
2415void CalendarView::newTodo() 2442void CalendarView::newTodo()
2416{ 2443{
2417 2444
2418 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); 2445 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true);
2419 if ( mFilterView->filtersEnabled() ) { 2446 if ( mFilterView->filtersEnabled() ) {
2420 CalFilter *filter = mFilterView->selectedFilter(); 2447 CalFilter *filter = mFilterView->selectedFilter();
2421 if (filter && filter->showCategories()) { 2448 if (filter && filter->showCategories()) {
2422 mTodoEditor->setCategories(filter->categoryList().join(",") ); 2449 mTodoEditor->setCategories(filter->categoryList().join(",") );
2423 } 2450 }
2424 if ( filter ) 2451 if ( filter )
2425 mTodoEditor->setSecrecy( filter->getSecrecy() ); 2452 mTodoEditor->setSecrecy( filter->getSecrecy() );
2426 } 2453 }
2427 showTodoEditor(); 2454 showTodoEditor();
2428} 2455}
2429 2456
2430void CalendarView::newSubTodo() 2457void CalendarView::newSubTodo()
2431{ 2458{
2432 Todo *todo = selectedTodo(); 2459 Todo *todo = selectedTodo();
2433 if ( todo ) newSubTodo( todo ); 2460 if ( todo ) newSubTodo( todo );
2434} 2461}
2435 2462
2436void CalendarView::newSubTodo(Todo *parentEvent) 2463void CalendarView::newSubTodo(Todo *parentEvent)
2437{ 2464{
2438 2465
2439 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); 2466 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true);
2440 showTodoEditor(); 2467 showTodoEditor();
2441} 2468}
2442 2469
2443void CalendarView::newFloatingEvent() 2470void CalendarView::newFloatingEvent()
2444{ 2471{
2445 DateList tmpList = mNavigator->selectedDates(); 2472 DateList tmpList = mNavigator->selectedDates();
2446 QDate date = tmpList.first(); 2473 QDate date = tmpList.first();
2447 2474
2448 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 2475 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
2449 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 2476 QDateTime( date, QTime( 12, 0, 0 ) ), true );
2450} 2477}
2451 2478
2452 2479
2453void CalendarView::editEvent( Event *event ) 2480void CalendarView::editEvent( Event *event )
2454{ 2481{
2455 2482
2456 if ( !event ) return; 2483 if ( !event ) return;
2457 if ( event->isReadOnly() ) { 2484 if ( event->isReadOnly() ) {
2458 showEvent( event ); 2485 showEvent( event );
2459 return; 2486 return;
2460 } 2487 }
2461 mEventEditor->editEvent( event , mFlagEditDescription); 2488 mEventEditor->editEvent( event , mFlagEditDescription);
2462 showEventEditor(); 2489 showEventEditor();
2463} 2490}
2464void CalendarView::editJournal( Journal *jour ) 2491void CalendarView::editJournal( Journal *jour )
2465{ 2492{
2466 if ( !jour ) return; 2493 if ( !jour ) return;
2467 mDialogManager->hideSearchDialog(); 2494 mDialogManager->hideSearchDialog();
2468 mViewManager->showJournalView(); 2495 mViewManager->showJournalView();
2469 mNavigator->slotDaySelect( jour->dtStart().date() ); 2496 mNavigator->slotDaySelect( jour->dtStart().date() );
2470} 2497}
2471void CalendarView::editTodo( Todo *todo ) 2498void CalendarView::editTodo( Todo *todo )
2472{ 2499{
2473 if ( !todo ) return; 2500 if ( !todo ) return;
2474 2501
2475 if ( todo->isReadOnly() ) { 2502 if ( todo->isReadOnly() ) {
2476 showTodo( todo ); 2503 showTodo( todo );
2477 return; 2504 return;
2478 } 2505 }
2479 mTodoEditor->editTodo( todo ,mFlagEditDescription); 2506 mTodoEditor->editTodo( todo ,mFlagEditDescription);
2480 showTodoEditor(); 2507 showTodoEditor();
2481 2508
2482} 2509}
2483 2510
2484KOEventViewerDialog* CalendarView::getEventViewerDialog() 2511KOEventViewerDialog* CalendarView::getEventViewerDialog()
2485{ 2512{
2486 if ( !mEventViewerDialog ) { 2513 if ( !mEventViewerDialog ) {
2487 mEventViewerDialog = new KOEventViewerDialog(this); 2514 mEventViewerDialog = new KOEventViewerDialog(this);
2488 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 2515 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
2489 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 2516 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
2490 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 2517 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
2491 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 2518 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
2492 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 2519 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
2493 viewManager(), SLOT( showAgendaView( bool ) ) ); 2520 viewManager(), SLOT( showAgendaView( bool ) ) );
2494 mEventViewerDialog->resize( 640, 480 ); 2521 mEventViewerDialog->resize( 640, 480 );
2495 2522
2496 } 2523 }
2497 return mEventViewerDialog; 2524 return mEventViewerDialog;
2498} 2525}
2499void CalendarView::showEvent(Event *event) 2526void CalendarView::showEvent(Event *event)
2500{ 2527{
2501 getEventViewerDialog()->setEvent(event); 2528 getEventViewerDialog()->setEvent(event);
2502 getEventViewerDialog()->showMe(); 2529 getEventViewerDialog()->showMe();
2503} 2530}
2504 2531
2505void CalendarView::showTodo(Todo *event) 2532void CalendarView::showTodo(Todo *event)
2506{ 2533{
2507 getEventViewerDialog()->setTodo(event); 2534 getEventViewerDialog()->setTodo(event);
2508 getEventViewerDialog()->showMe(); 2535 getEventViewerDialog()->showMe();
2509} 2536}
2510void CalendarView::showJournal( Journal *jour ) 2537void CalendarView::showJournal( Journal *jour )
2511{ 2538{
2512 getEventViewerDialog()->setJournal(jour); 2539 getEventViewerDialog()->setJournal(jour);
2513 getEventViewerDialog()->showMe(); 2540 getEventViewerDialog()->showMe();
2514 2541
2515} 2542}
2516// void CalendarView::todoModified (Todo *event, int changed) 2543// void CalendarView::todoModified (Todo *event, int changed)
2517// { 2544// {
2518// // if (mDialogList.find (event) != mDialogList.end ()) { 2545// // if (mDialogList.find (event) != mDialogList.end ()) {
2519// // kdDebug() << "Todo modified and open" << endl; 2546// // kdDebug() << "Todo modified and open" << endl;
2520// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 2547// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
2521// // temp->modified (changed); 2548// // temp->modified (changed);
2522 2549
2523// // } 2550// // }
2524 2551
2525// mViewManager->updateView(); 2552// mViewManager->updateView();
2526// } 2553// }
2527 2554
2528void CalendarView::appointment_show() 2555void CalendarView::appointment_show()
2529{ 2556{
2530 Event *anEvent = 0; 2557 Event *anEvent = 0;
2531 2558
2532 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2559 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2533 2560
2534 if (mViewManager->currentView()->isEventView()) { 2561 if (mViewManager->currentView()->isEventView()) {
2535 if ( incidence && incidence->type() == "Event" ) { 2562 if ( incidence && incidence->type() == "Event" ) {
2536 anEvent = static_cast<Event *>(incidence); 2563 anEvent = static_cast<Event *>(incidence);
2537 } 2564 }
2538 } 2565 }
2539 2566
2540 if (!anEvent) { 2567 if (!anEvent) {
2541 KNotifyClient::beep(); 2568 KNotifyClient::beep();
2542 return; 2569 return;
2543 } 2570 }
2544 2571
2545 showEvent(anEvent); 2572 showEvent(anEvent);
2546} 2573}
2547 2574
2548void CalendarView::appointment_edit() 2575void CalendarView::appointment_edit()
2549{ 2576{
2550 Event *anEvent = 0; 2577 Event *anEvent = 0;
2551 2578
2552 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2579 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2553 2580
2554 if (mViewManager->currentView()->isEventView()) { 2581 if (mViewManager->currentView()->isEventView()) {
2555 if ( incidence && incidence->type() == "Event" ) { 2582 if ( incidence && incidence->type() == "Event" ) {
2556 anEvent = static_cast<Event *>(incidence); 2583 anEvent = static_cast<Event *>(incidence);
2557 } 2584 }
2558 } 2585 }
2559 2586
2560 if (!anEvent) { 2587 if (!anEvent) {
2561 KNotifyClient::beep(); 2588 KNotifyClient::beep();
2562 return; 2589 return;
2563 } 2590 }
2564 2591
2565 editEvent(anEvent); 2592 editEvent(anEvent);
2566} 2593}
2567 2594
2568void CalendarView::appointment_delete() 2595void CalendarView::appointment_delete()
2569{ 2596{
2570 Event *anEvent = 0; 2597 Event *anEvent = 0;
2571 2598
2572 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2599 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2573 2600
2574 if (mViewManager->currentView()->isEventView()) { 2601 if (mViewManager->currentView()->isEventView()) {
2575 if ( incidence && incidence->type() == "Event" ) { 2602 if ( incidence && incidence->type() == "Event" ) {
2576 anEvent = static_cast<Event *>(incidence); 2603 anEvent = static_cast<Event *>(incidence);
2577 } 2604 }
2578 } 2605 }
2579 2606
2580 if (!anEvent) { 2607 if (!anEvent) {
2581 KNotifyClient::beep(); 2608 KNotifyClient::beep();
2582 return; 2609 return;
2583 } 2610 }
2584 2611
2585 deleteEvent(anEvent); 2612 deleteEvent(anEvent);
2586} 2613}
2587 2614
2588void CalendarView::todo_unsub(Todo *anTodo ) 2615void CalendarView::todo_unsub(Todo *anTodo )
2589{ 2616{
2590 // Todo *anTodo = selectedTodo(); 2617 // Todo *anTodo = selectedTodo();
2591 if (!anTodo) return; 2618 if (!anTodo) return;
2592 if (!anTodo->relatedTo()) return; 2619 if (!anTodo->relatedTo()) return;
2593 anTodo->relatedTo()->removeRelation(anTodo); 2620 anTodo->relatedTo()->removeRelation(anTodo);
2594 anTodo->setRelatedTo(0); 2621 anTodo->setRelatedTo(0);
2595 anTodo->updated(); 2622 anTodo->updated();
2596 anTodo->setRelatedToUid(""); 2623 anTodo->setRelatedToUid("");
2597 setModified(true); 2624 setModified(true);
2598 updateView(); 2625 updateView();
2599} 2626}
2600 2627
2601void CalendarView::deleteTodo(Todo *todo) 2628void CalendarView::deleteTodo(Todo *todo)
2602{ 2629{
2603 if (!todo) { 2630 if (!todo) {
2604 KNotifyClient::beep(); 2631 KNotifyClient::beep();
2605 return; 2632 return;
2606 } 2633 }
2607 if (KOPrefs::instance()->mConfirm) { 2634 if (KOPrefs::instance()->mConfirm) {
2608 switch (msgItemDelete()) { 2635 switch (msgItemDelete()) {
2609 case KMessageBox::Continue: // OK 2636 case KMessageBox::Continue: // OK
2610 if (!todo->relations().isEmpty()) { 2637 if (!todo->relations().isEmpty()) {
2611 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), 2638 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."),
2612 i18n("Delete To-Do")); 2639 i18n("Delete To-Do"));
2613 } else { 2640 } else {
2614 checkExternalId( todo ); 2641 checkExternalId( todo );
2615 calendar()->deleteTodo(todo); 2642 calendar()->deleteTodo(todo);
2616 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2643 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2617 updateView(); 2644 updateView();
2618 } 2645 }
2619 break; 2646 break;
2620 } // switch 2647 } // switch
2621 } else { 2648 } else {
2622 if (!todo->relations().isEmpty()) { 2649 if (!todo->relations().isEmpty()) {
2623 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), 2650 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."),
2624 i18n("Delete To-Do")); 2651 i18n("Delete To-Do"));
2625 } else { 2652 } else {
2626 checkExternalId( todo ); 2653 checkExternalId( todo );
2627 mCalendar->deleteTodo(todo); 2654 mCalendar->deleteTodo(todo);
2628 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2655 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2629 updateView(); 2656 updateView();
2630 } 2657 }
2631 } 2658 }
2632 emit updateSearchDialog(); 2659 emit updateSearchDialog();
2633} 2660}
2634void CalendarView::deleteJournal(Journal *jour) 2661void CalendarView::deleteJournal(Journal *jour)
2635{ 2662{
2636 if (!jour) { 2663 if (!jour) {
2637 KNotifyClient::beep(); 2664 KNotifyClient::beep();
2638 return; 2665 return;
2639 } 2666 }
2640 if (KOPrefs::instance()->mConfirm) { 2667 if (KOPrefs::instance()->mConfirm) {
2641 switch (msgItemDelete()) { 2668 switch (msgItemDelete()) {
2642 case KMessageBox::Continue: // OK 2669 case KMessageBox::Continue: // OK
2643 calendar()->deleteJournal(jour); 2670 calendar()->deleteJournal(jour);
2644 updateView(); 2671 updateView();
2645 break; 2672 break;
2646 } // switch 2673 } // switch
2647 } else { 2674 } else {
2648 calendar()->deleteJournal(jour);; 2675 calendar()->deleteJournal(jour);;
2649 updateView(); 2676 updateView();
2650 } 2677 }
2651 emit updateSearchDialog(); 2678 emit updateSearchDialog();
2652} 2679}
2653 2680
2654void CalendarView::deleteEvent(Event *anEvent) 2681void CalendarView::deleteEvent(Event *anEvent)
2655{ 2682{
2656 if (!anEvent) { 2683 if (!anEvent) {
2657 KNotifyClient::beep(); 2684 KNotifyClient::beep();
2658 return; 2685 return;
2659 } 2686 }
2660 2687
2661 if (anEvent->recurrence()->doesRecur()) { 2688 if (anEvent->recurrence()->doesRecur()) {
2662 QDate itemDate = mViewManager->currentSelectionDate(); 2689 QDate itemDate = mViewManager->currentSelectionDate();
2663 int km; 2690 int km;
2664 if (!itemDate.isValid()) { 2691 if (!itemDate.isValid()) {
2665 //kdDebug() << "Date Not Valid" << endl; 2692 //kdDebug() << "Date Not Valid" << endl;
2666 if (KOPrefs::instance()->mConfirm) { 2693 if (KOPrefs::instance()->mConfirm) {
2667 km = KMessageBox::warningContinueCancel(this,anEvent->summary() + 2694 km = KMessageBox::warningContinueCancel(this,anEvent->summary() +
2668 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), 2695 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"),
2669 i18n("KO/Pi Confirmation"),i18n("Delete All")); 2696 i18n("KO/Pi Confirmation"),i18n("Delete All"));
2670 if ( km == KMessageBox::Continue ) 2697 if ( km == KMessageBox::Continue )
2671 km = KMessageBox::No; // No = all below 2698 km = KMessageBox::No; // No = all below
2672 } else 2699 } else
2673 km = KMessageBox::No; 2700 km = KMessageBox::No;
2674 } else { 2701 } else {
2675 km = KMessageBox::warningYesNoCancel(this,anEvent->summary() + 2702 km = KMessageBox::warningYesNoCancel(this,anEvent->summary() +
2676 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ 2703 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+
2677 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), 2704 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"),
2678 i18n("KO/Pi Confirmation"),i18n("Current"), 2705 i18n("KO/Pi Confirmation"),i18n("Current"),
2679 i18n("All")); 2706 i18n("All"));
2680 } 2707 }
2681 switch(km) { 2708 switch(km) {
2682 2709
2683 case KMessageBox::No: // Continue // all 2710 case KMessageBox::No: // Continue // all
2684 //qDebug("KMessageBox::No "); 2711 //qDebug("KMessageBox::No ");
2685 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2712 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2686 schedule(Scheduler::Cancel,anEvent); 2713 schedule(Scheduler::Cancel,anEvent);
2687 2714
2688 checkExternalId( anEvent); 2715 checkExternalId( anEvent);
2689 mCalendar->deleteEvent(anEvent); 2716 mCalendar->deleteEvent(anEvent);
2690 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); 2717 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED);
2691 break; 2718 break;
2692 2719
2693 // Disabled because it does not work 2720 // Disabled because it does not work
2694 //#if 0 2721 //#if 0
2695 case KMessageBox::Yes: // just this one 2722 case KMessageBox::Yes: // just this one
2696 //QDate qd = mNavigator->selectedDates().first(); 2723 //QDate qd = mNavigator->selectedDates().first();
2697 //if (!qd.isValid()) { 2724 //if (!qd.isValid()) {
2698 // kdDebug() << "no date selected, or invalid date" << endl; 2725 // kdDebug() << "no date selected, or invalid date" << endl;
2699 // KNotifyClient::beep(); 2726 // KNotifyClient::beep();
2700 // return; 2727 // return;
2701 //} 2728 //}
2702 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); 2729 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1);
2703 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { 2730 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) {
2704 anEvent->addExDate(itemDate); 2731 anEvent->addExDate(itemDate);
2705 int duration = anEvent->recurrence()->duration(); 2732 int duration = anEvent->recurrence()->duration();
2706 if ( duration > 0 ) { 2733 if ( duration > 0 ) {
2707 anEvent->recurrence()->setDuration( duration - 1 ); 2734 anEvent->recurrence()->setDuration( duration - 1 );
2708 } 2735 }
2709 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); 2736 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED);
2710 } 2737 }
2711 break; 2738 break;
2712 //#endif 2739 //#endif
2713 } // switch 2740 } // switch
2714 } else { 2741 } else {
2715 if (KOPrefs::instance()->mConfirm) { 2742 if (KOPrefs::instance()->mConfirm) {
2716 switch (KMessageBox::warningContinueCancel(this,anEvent->summary() + 2743 switch (KMessageBox::warningContinueCancel(this,anEvent->summary() +
2717 i18n("\nAre you sure you want\nto delete this event?"), 2744 i18n("\nAre you sure you want\nto delete this event?"),
2718 i18n("KO/Pi Confirmation"),i18n("Delete"))) { 2745 i18n("KO/Pi Confirmation"),i18n("Delete"))) {
2719 case KMessageBox::Continue: // OK 2746 case KMessageBox::Continue: // OK
2720 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2747 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2721 schedule(Scheduler::Cancel,anEvent); 2748 schedule(Scheduler::Cancel,anEvent);
2722 checkExternalId( anEvent); 2749 checkExternalId( anEvent);
2723 mCalendar->deleteEvent(anEvent); 2750 mCalendar->deleteEvent(anEvent);
2724 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2751 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2725 break; 2752 break;
2726 } // switch 2753 } // switch
2727 } else { 2754 } else {
2728 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2755 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2729 schedule(Scheduler::Cancel,anEvent); 2756 schedule(Scheduler::Cancel,anEvent);
2730 checkExternalId( anEvent); 2757 checkExternalId( anEvent);
2731 mCalendar->deleteEvent(anEvent); 2758 mCalendar->deleteEvent(anEvent);
2732 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2759 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2733 } 2760 }
2734 } // if-else 2761 } // if-else
2735 emit updateSearchDialog(); 2762 emit updateSearchDialog();
2736} 2763}
2737 2764
2738bool CalendarView::deleteEvent(const QString &uid) 2765bool CalendarView::deleteEvent(const QString &uid)
2739{ 2766{
2740 Event *ev = mCalendar->event(uid); 2767 Event *ev = mCalendar->event(uid);
2741 if (ev) { 2768 if (ev) {
2742 deleteEvent(ev); 2769 deleteEvent(ev);
2743 return true; 2770 return true;
2744 } else { 2771 } else {
2745 return false; 2772 return false;
2746 } 2773 }
2747} 2774}
2748 2775
2749/*****************************************************************************/ 2776/*****************************************************************************/
2750 2777
2751void CalendarView::action_mail() 2778void CalendarView::action_mail()
2752{ 2779{
2753#ifndef KORG_NOMAIL 2780#ifndef KORG_NOMAIL
2754 KOMailClient mailClient; 2781 KOMailClient mailClient;
2755 2782
2756 Incidence *incidence = currentSelection(); 2783 Incidence *incidence = currentSelection();
2757 2784
2758 if (!incidence) { 2785 if (!incidence) {
2759 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 2786 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
2760 return; 2787 return;
2761 } 2788 }
2762 if(incidence->attendeeCount() == 0 ) { 2789 if(incidence->attendeeCount() == 0 ) {
2763 KMessageBox::sorry(this, 2790 KMessageBox::sorry(this,
2764 i18n("Can't generate mail:\nNo attendees defined.\n")); 2791 i18n("Can't generate mail:\nNo attendees defined.\n"));
2765 return; 2792 return;
2766 } 2793 }
2767 2794
2768 CalendarLocal cal_tmp; 2795 CalendarLocal cal_tmp;
2769 Event *event = 0; 2796 Event *event = 0;
2770 Event *ev = 0; 2797 Event *ev = 0;
2771 if ( incidence && incidence->type() == "Event" ) { 2798 if ( incidence && incidence->type() == "Event" ) {
2772 event = static_cast<Event *>(incidence); 2799 event = static_cast<Event *>(incidence);
2773 ev = new Event(*event); 2800 ev = new Event(*event);
2774 cal_tmp.addEvent(ev); 2801 cal_tmp.addEvent(ev);
2775 } 2802 }
2776 ICalFormat mForm( KOPrefs::instance()->mUseQuicksave); 2803 ICalFormat mForm( KOPrefs::instance()->mUseQuicksave);
2777 QString attachment = mForm.toString( &cal_tmp ); 2804 QString attachment = mForm.toString( &cal_tmp );
2778 if (ev) delete(ev); 2805 if (ev) delete(ev);
2779 2806
2780 mailClient.mailAttendees(currentSelection(), attachment); 2807 mailClient.mailAttendees(currentSelection(), attachment);
2781 2808
2782#endif 2809#endif
2783 2810
2784#if 0 2811#if 0
2785 Event *anEvent = 0; 2812 Event *anEvent = 0;
2786 if (mViewManager->currentView()->isEventView()) { 2813 if (mViewManager->currentView()->isEventView()) {
2787 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); 2814 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first());
2788 } 2815 }
2789 2816
2790 if (!anEvent) { 2817 if (!anEvent) {
2791 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 2818 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
2792 return; 2819 return;
2793 } 2820 }
2794 if(anEvent->attendeeCount() == 0 ) { 2821 if(anEvent->attendeeCount() == 0 ) {
2795 KMessageBox::sorry(this, 2822 KMessageBox::sorry(this,
2796 i18n("Can't generate mail:\nNo attendees defined.\n")); 2823 i18n("Can't generate mail:\nNo attendees defined.\n"));
2797 return; 2824 return;
2798 } 2825 }
2799 2826
2800 mailobject.emailEvent(anEvent); 2827 mailobject.emailEvent(anEvent);
2801#endif 2828#endif
2802} 2829}
2803 2830
2804 2831
2805void CalendarView::schedule_publish(Incidence *incidence) 2832void CalendarView::schedule_publish(Incidence *incidence)
2806{ 2833{
2807 Event *event = 0; 2834 Event *event = 0;
2808 Todo *todo = 0; 2835 Todo *todo = 0;
2809 2836
2810 if (incidence == 0) { 2837 if (incidence == 0) {
2811 incidence = mViewManager->currentView()->selectedIncidences().first(); 2838 incidence = mViewManager->currentView()->selectedIncidences().first();
2812 if (incidence == 0) { 2839 if (incidence == 0) {
2813 incidence = mTodoList->selectedIncidences().first(); 2840 incidence = mTodoList->selectedIncidences().first();
2814 } 2841 }
2815 } 2842 }
2816 if ( incidence && incidence->type() == "Event" ) { 2843 if ( incidence && incidence->type() == "Event" ) {
2817 event = static_cast<Event *>(incidence); 2844 event = static_cast<Event *>(incidence);
2818 } else { 2845 } else {
2819 if ( incidence && incidence->type() == "Todo" ) { 2846 if ( incidence && incidence->type() == "Todo" ) {
2820 todo = static_cast<Todo *>(incidence); 2847 todo = static_cast<Todo *>(incidence);
2821 } 2848 }
2822 } 2849 }
2823 2850
2824 if (!event && !todo) { 2851 if (!event && !todo) {
2825 KMessageBox::sorry(this,i18n("No event selected.")); 2852 KMessageBox::sorry(this,i18n("No event selected."));
2826 return; 2853 return;
2827 } 2854 }
2828 2855
2829 PublishDialog *publishdlg = new PublishDialog(); 2856 PublishDialog *publishdlg = new PublishDialog();
2830 if (incidence->attendeeCount()>0) { 2857 if (incidence->attendeeCount()>0) {
2831 QPtrList<Attendee> attendees = incidence->attendees(); 2858 QPtrList<Attendee> attendees = incidence->attendees();
2832 attendees.first(); 2859 attendees.first();
2833 while ( attendees.current()!=0 ) { 2860 while ( attendees.current()!=0 ) {
2834 publishdlg->addAttendee(attendees.current()); 2861 publishdlg->addAttendee(attendees.current());
2835 attendees.next(); 2862 attendees.next();
2836 } 2863 }
2837 } 2864 }
2838 bool send = true; 2865 bool send = true;
2839 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { 2866 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) {
2840 if ( publishdlg->exec() != QDialog::Accepted ) 2867 if ( publishdlg->exec() != QDialog::Accepted )
2841 send = false; 2868 send = false;
2842 } 2869 }
2843 if ( send ) { 2870 if ( send ) {
2844 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 2871 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
2845 if ( event ) { 2872 if ( event ) {
2846 Event *ev = new Event(*event); 2873 Event *ev = new Event(*event);
2847 ev->registerObserver(0); 2874 ev->registerObserver(0);
2848 ev->clearAttendees(); 2875 ev->clearAttendees();
2849 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 2876 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
2850 delete(ev); 2877 delete(ev);
2851 } 2878 }
2852 } else { 2879 } else {
2853 if ( todo ) { 2880 if ( todo ) {
2854 Todo *ev = new Todo(*todo); 2881 Todo *ev = new Todo(*todo);
2855 ev->registerObserver(0); 2882 ev->registerObserver(0);
2856 ev->clearAttendees(); 2883 ev->clearAttendees();
2857 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 2884 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
2858 delete(ev); 2885 delete(ev);
2859 } 2886 }
2860 } 2887 }
2861 } 2888 }
2862 } 2889 }
2863 delete publishdlg; 2890 delete publishdlg;
2864} 2891}
2865 2892
2866void CalendarView::schedule_request(Incidence *incidence) 2893void CalendarView::schedule_request(Incidence *incidence)
2867{ 2894{
2868 schedule(Scheduler::Request,incidence); 2895 schedule(Scheduler::Request,incidence);
2869} 2896}
2870 2897
2871void CalendarView::schedule_refresh(Incidence *incidence) 2898void CalendarView::schedule_refresh(Incidence *incidence)
2872{ 2899{
2873 schedule(Scheduler::Refresh,incidence); 2900 schedule(Scheduler::Refresh,incidence);
2874} 2901}
2875 2902
2876void CalendarView::schedule_cancel(Incidence *incidence) 2903void CalendarView::schedule_cancel(Incidence *incidence)
2877{ 2904{
2878 schedule(Scheduler::Cancel,incidence); 2905 schedule(Scheduler::Cancel,incidence);
2879} 2906}
2880 2907
2881void CalendarView::schedule_add(Incidence *incidence) 2908void CalendarView::schedule_add(Incidence *incidence)
2882{ 2909{
2883 schedule(Scheduler::Add,incidence); 2910 schedule(Scheduler::Add,incidence);
2884} 2911}
2885 2912
2886void CalendarView::schedule_reply(Incidence *incidence) 2913void CalendarView::schedule_reply(Incidence *incidence)
2887{ 2914{
2888 schedule(Scheduler::Reply,incidence); 2915 schedule(Scheduler::Reply,incidence);
2889} 2916}
2890 2917
2891void CalendarView::schedule_counter(Incidence *incidence) 2918void CalendarView::schedule_counter(Incidence *incidence)
2892{ 2919{
2893 schedule(Scheduler::Counter,incidence); 2920 schedule(Scheduler::Counter,incidence);
2894} 2921}
2895 2922
2896void CalendarView::schedule_declinecounter(Incidence *incidence) 2923void CalendarView::schedule_declinecounter(Incidence *incidence)
2897{ 2924{
2898 schedule(Scheduler::Declinecounter,incidence); 2925 schedule(Scheduler::Declinecounter,incidence);
2899} 2926}
2900 2927
2901void CalendarView::schedule_publish_freebusy(int daysToPublish) 2928void CalendarView::schedule_publish_freebusy(int daysToPublish)
2902{ 2929{
2903 QDateTime start = QDateTime::currentDateTime(); 2930 QDateTime start = QDateTime::currentDateTime();
2904 QDateTime end = start.addDays(daysToPublish); 2931 QDateTime end = start.addDays(daysToPublish);
2905 2932
2906 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); 2933 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end);
2907 freebusy->setOrganizer(KOPrefs::instance()->email()); 2934 freebusy->setOrganizer(KOPrefs::instance()->email());
2908 2935
2909 2936
2910 PublishDialog *publishdlg = new PublishDialog(); 2937 PublishDialog *publishdlg = new PublishDialog();
2911 if ( publishdlg->exec() == QDialog::Accepted ) { 2938 if ( publishdlg->exec() == QDialog::Accepted ) {
2912 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 2939 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
2913 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { 2940 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) {
2914 delete(freebusy); 2941 delete(freebusy);
2915 } 2942 }
2916 } 2943 }
2917 delete publishdlg; 2944 delete publishdlg;
2918} 2945}
2919 2946
2920void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) 2947void CalendarView::schedule(Scheduler::Method method, Incidence *incidence)
2921{ 2948{
2922 Event *event = 0; 2949 Event *event = 0;
2923 Todo *todo = 0; 2950 Todo *todo = 0;
2924 2951
2925 if (incidence == 0) { 2952 if (incidence == 0) {
2926 incidence = mViewManager->currentView()->selectedIncidences().first(); 2953 incidence = mViewManager->currentView()->selectedIncidences().first();
2927 if (incidence == 0) { 2954 if (incidence == 0) {
2928 incidence = mTodoList->selectedIncidences().first(); 2955 incidence = mTodoList->selectedIncidences().first();
2929 } 2956 }
2930 } 2957 }
2931 if ( incidence && incidence->type() == "Event" ) { 2958 if ( incidence && incidence->type() == "Event" ) {
2932 event = static_cast<Event *>(incidence); 2959 event = static_cast<Event *>(incidence);
2933 } 2960 }
2934 if ( incidence && incidence->type() == "Todo" ) { 2961 if ( incidence && incidence->type() == "Todo" ) {
2935 todo = static_cast<Todo *>(incidence); 2962 todo = static_cast<Todo *>(incidence);
2936 } 2963 }
2937 2964
2938 if (!event && !todo) { 2965 if (!event && !todo) {
2939 KMessageBox::sorry(this,i18n("No event selected.")); 2966 KMessageBox::sorry(this,i18n("No event selected."));
2940 return; 2967 return;
2941 } 2968 }
2942 2969
2943 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { 2970 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) {
2944 KMessageBox::sorry(this,i18n("The event has no attendees.")); 2971 KMessageBox::sorry(this,i18n("The event has no attendees."));
2945 return; 2972 return;
2946 } 2973 }
2947 2974
2948 Event *ev = 0; 2975 Event *ev = 0;
2949 if (event) ev = new Event(*event); 2976 if (event) ev = new Event(*event);
2950 Todo *to = 0; 2977 Todo *to = 0;
2951 if (todo) to = new Todo(*todo); 2978 if (todo) to = new Todo(*todo);
2952 2979
2953 if (method == Scheduler::Reply || method == Scheduler::Refresh) { 2980 if (method == Scheduler::Reply || method == Scheduler::Refresh) {
2954 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 2981 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
2955 if (!me) { 2982 if (!me) {
2956 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); 2983 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails."));
2957 return; 2984 return;
2958 } 2985 }
2959 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { 2986 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) {
2960 StatusDialog *statdlg = new StatusDialog(this); 2987 StatusDialog *statdlg = new StatusDialog(this);
2961 if (!statdlg->exec()==QDialog::Accepted) return; 2988 if (!statdlg->exec()==QDialog::Accepted) return;
2962 me->setStatus( statdlg->status() ); 2989 me->setStatus( statdlg->status() );
2963 delete(statdlg); 2990 delete(statdlg);
2964 } 2991 }
2965 Attendee *menew = new Attendee(*me); 2992 Attendee *menew = new Attendee(*me);
2966 if (ev) { 2993 if (ev) {
2967 ev->clearAttendees(); 2994 ev->clearAttendees();
2968 ev->addAttendee(menew,false); 2995 ev->addAttendee(menew,false);
2969 } else { 2996 } else {
2970 if (to) { 2997 if (to) {
2971 todo->clearAttendees(); 2998 todo->clearAttendees();
2972 todo->addAttendee(menew,false); 2999 todo->addAttendee(menew,false);
2973 } 3000 }
2974 } 3001 }
2975 } 3002 }
2976 3003
2977 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3004 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
2978 if (ev) { 3005 if (ev) {
2979 if ( !dlg->addMessage(ev,method) ) delete(ev); 3006 if ( !dlg->addMessage(ev,method) ) delete(ev);
2980 } else { 3007 } else {
2981 if (to) { 3008 if (to) {
2982 if ( !dlg->addMessage(to,method) ) delete(to); 3009 if ( !dlg->addMessage(to,method) ) delete(to);
2983 } 3010 }
2984 } 3011 }
2985} 3012}
2986 3013
2987void CalendarView::openAddressbook() 3014void CalendarView::openAddressbook()
2988{ 3015{
2989 KRun::runCommand("kaddressbook"); 3016 KRun::runCommand("kaddressbook");
2990} 3017}
2991 3018
2992void CalendarView::setModified(bool modified) 3019void CalendarView::setModified(bool modified)
2993{ 3020{
2994 if ( modified ) 3021 if ( modified )
2995 emit signalmodified(); 3022 emit signalmodified();
2996 if (mModified != modified) { 3023 if (mModified != modified) {
2997 mModified = modified; 3024 mModified = modified;
2998 emit modifiedChanged(mModified); 3025 emit modifiedChanged(mModified);
2999 } 3026 }
3000} 3027}
3001 3028
3002bool CalendarView::isReadOnly() 3029bool CalendarView::isReadOnly()
3003{ 3030{
3004 return mReadOnly; 3031 return mReadOnly;
3005} 3032}
3006 3033
3007void CalendarView::setReadOnly(bool readOnly) 3034void CalendarView::setReadOnly(bool readOnly)
3008{ 3035{
3009 if (mReadOnly != readOnly) { 3036 if (mReadOnly != readOnly) {
3010 mReadOnly = readOnly; 3037 mReadOnly = readOnly;
3011 emit readOnlyChanged(mReadOnly); 3038 emit readOnlyChanged(mReadOnly);
3012 } 3039 }
3013} 3040}
3014 3041
3015bool CalendarView::isModified() 3042bool CalendarView::isModified()
3016{ 3043{
3017 return mModified; 3044 return mModified;
3018} 3045}
3019 3046
3020void CalendarView::printSetup() 3047void CalendarView::printSetup()
3021{ 3048{
3022#ifndef KORG_NOPRINTER 3049#ifndef KORG_NOPRINTER
3023 createPrinter(); 3050 createPrinter();
3024 3051
3025 mCalPrinter->setupPrinter(); 3052 mCalPrinter->setupPrinter();
3026#endif 3053#endif
3027} 3054}
3028 3055
3029void CalendarView::print() 3056void CalendarView::print()
3030{ 3057{
3031#ifndef KORG_NOPRINTER 3058#ifndef KORG_NOPRINTER
3032 createPrinter(); 3059 createPrinter();
3033 3060
3034 DateList tmpDateList = mNavigator->selectedDates(); 3061 DateList tmpDateList = mNavigator->selectedDates();
3035 mCalPrinter->print(CalPrinter::Month, 3062 mCalPrinter->print(CalPrinter::Month,
3036 tmpDateList.first(), tmpDateList.last()); 3063 tmpDateList.first(), tmpDateList.last());
3037#endif 3064#endif
3038} 3065}
3039 3066
3040void CalendarView::printPreview() 3067void CalendarView::printPreview()
3041{ 3068{
3042#ifndef KORG_NOPRINTER 3069#ifndef KORG_NOPRINTER
3043 kdDebug() << "CalendarView::printPreview()" << endl; 3070 kdDebug() << "CalendarView::printPreview()" << endl;
3044 3071
3045 createPrinter(); 3072 createPrinter();
3046 3073
3047 DateList tmpDateList = mNavigator->selectedDates(); 3074 DateList tmpDateList = mNavigator->selectedDates();
3048 3075
3049 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), 3076 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(),
3050 tmpDateList.last()); 3077 tmpDateList.last());
3051#endif 3078#endif
3052} 3079}
3053 3080
3054void CalendarView::exportICalendar() 3081void CalendarView::exportICalendar()
3055{ 3082{
3056 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); 3083 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this);
3057 3084
3058 // Force correct extension 3085 // Force correct extension
3059 if (filename.right(4) != ".ics") filename += ".ics"; 3086 if (filename.right(4) != ".ics") filename += ".ics";
3060 3087
3061 FileStorage storage( mCalendar, filename, new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 3088 FileStorage storage( mCalendar, filename, new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
3062 storage.save(); 3089 storage.save();
3063} 3090}
3064 3091
3065bool CalendarView::exportVCalendar( QString filename ) 3092bool CalendarView::exportVCalendar( QString filename )
3066{ 3093{
3067 if (mCalendar->journals().count() > 0) { 3094 if (mCalendar->journals().count() > 0) {
3068 int result = KMessageBox::warningContinueCancel(this, 3095 int result = KMessageBox::warningContinueCancel(this,
3069 i18n("The journal entries can not be\nexported to a vCalendar file."), 3096 i18n("The journal entries can not be\nexported to a vCalendar file."),
3070 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 3097 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
3071 true); 3098 true);
3072 if (result != KMessageBox::Continue) return false; 3099 if (result != KMessageBox::Continue) return false;
3073 } 3100 }
3074 3101
3075 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); 3102 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this);
3076 3103
3077 // Force correct extension 3104 // Force correct extension
3078 if (filename.right(4) != ".vcs") filename += ".vcs"; 3105 if (filename.right(4) != ".vcs") filename += ".vcs";
3079 3106
3080 FileStorage storage( mCalendar, filename, new VCalFormat ); 3107 FileStorage storage( mCalendar, filename, new VCalFormat );
3081 return storage.save(); 3108 return storage.save();
3082 3109
3083} 3110}
3084 3111
3085void CalendarView::eventUpdated(Incidence *) 3112void CalendarView::eventUpdated(Incidence *)
3086{ 3113{
3087 setModified(); 3114 setModified();
3088 // Don't call updateView here. The code, which has caused the update of the 3115 // Don't call updateView here. The code, which has caused the update of the
3089 // event is responsible for updating the view. 3116 // event is responsible for updating the view.
3090 // updateView(); 3117 // updateView();
3091} 3118}
3092 3119
3093void CalendarView::adaptNavigationUnits() 3120void CalendarView::adaptNavigationUnits()
3094{ 3121{
3095 if (mViewManager->currentView()->isEventView()) { 3122 if (mViewManager->currentView()->isEventView()) {
3096 int days = mViewManager->currentView()->currentDateCount(); 3123 int days = mViewManager->currentView()->currentDateCount();
3097 if (days == 1) { 3124 if (days == 1) {
3098 emit changeNavStringPrev(i18n("&Previous Day")); 3125 emit changeNavStringPrev(i18n("&Previous Day"));
3099 emit changeNavStringNext(i18n("&Next Day")); 3126 emit changeNavStringNext(i18n("&Next Day"));
3100 } else { 3127 } else {
3101 emit changeNavStringPrev(i18n("&Previous Week")); 3128 emit changeNavStringPrev(i18n("&Previous Week"));
3102 emit changeNavStringNext(i18n("&Next Week")); 3129 emit changeNavStringNext(i18n("&Next Week"));
3103 } 3130 }
3104 } 3131 }
3105} 3132}
3106 3133
3107void CalendarView::processMainViewSelection( Incidence *incidence ) 3134void CalendarView::processMainViewSelection( Incidence *incidence )
3108{ 3135{
3109 if ( incidence ) mTodoList->clearSelection(); 3136 if ( incidence ) mTodoList->clearSelection();
3110 processIncidenceSelection( incidence ); 3137 processIncidenceSelection( incidence );
3111} 3138}
3112 3139
3113void CalendarView::processTodoListSelection( Incidence *incidence ) 3140void CalendarView::processTodoListSelection( Incidence *incidence )
3114{ 3141{
3115 if ( incidence && mViewManager->currentView() ) { 3142 if ( incidence && mViewManager->currentView() ) {
3116 mViewManager->currentView()->clearSelection(); 3143 mViewManager->currentView()->clearSelection();
3117 } 3144 }
3118 processIncidenceSelection( incidence ); 3145 processIncidenceSelection( incidence );
3119} 3146}
3120 3147
3121void CalendarView::processIncidenceSelection( Incidence *incidence ) 3148void CalendarView::processIncidenceSelection( Incidence *incidence )
3122{ 3149{
3123 if ( incidence == mSelectedIncidence ) return; 3150 if ( incidence == mSelectedIncidence ) return;
3124 3151
3125 mSelectedIncidence = incidence; 3152 mSelectedIncidence = incidence;
3126 3153
3127 emit incidenceSelected( mSelectedIncidence ); 3154 emit incidenceSelected( mSelectedIncidence );
3128 3155
3129 if ( incidence && incidence->type() == "Event" ) { 3156 if ( incidence && incidence->type() == "Event" ) {
3130 Event *event = static_cast<Event *>( incidence ); 3157 Event *event = static_cast<Event *>( incidence );
3131 if ( event->organizer() == KOPrefs::instance()->email() ) { 3158 if ( event->organizer() == KOPrefs::instance()->email() ) {
3132 emit organizerEventsSelected( true ); 3159 emit organizerEventsSelected( true );
3133 } else { 3160 } else {
3134 emit organizerEventsSelected(false); 3161 emit organizerEventsSelected(false);
3135 } 3162 }
3136 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3163 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3137 KOPrefs::instance()->email() ) ) { 3164 KOPrefs::instance()->email() ) ) {
3138 emit groupEventsSelected( true ); 3165 emit groupEventsSelected( true );
3139 } else { 3166 } else {
3140 emit groupEventsSelected(false); 3167 emit groupEventsSelected(false);
3141 } 3168 }
3142 return; 3169 return;
3143 } else { 3170 } else {
3144 if ( incidence && incidence->type() == "Todo" ) { 3171 if ( incidence && incidence->type() == "Todo" ) {
3145 emit todoSelected( true ); 3172 emit todoSelected( true );
3146 Todo *event = static_cast<Todo *>( incidence ); 3173 Todo *event = static_cast<Todo *>( incidence );
3147 if ( event->organizer() == KOPrefs::instance()->email() ) { 3174 if ( event->organizer() == KOPrefs::instance()->email() ) {
3148 emit organizerEventsSelected( true ); 3175 emit organizerEventsSelected( true );
3149 } else { 3176 } else {
3150 emit organizerEventsSelected(false); 3177 emit organizerEventsSelected(false);
3151 } 3178 }
3152 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3179 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3153 KOPrefs::instance()->email() ) ) { 3180 KOPrefs::instance()->email() ) ) {
3154 emit groupEventsSelected( true ); 3181 emit groupEventsSelected( true );
3155 } else { 3182 } else {
3156 emit groupEventsSelected(false); 3183 emit groupEventsSelected(false);
3157 } 3184 }
3158 return; 3185 return;
3159 } else { 3186 } else {
3160 emit todoSelected( false ); 3187 emit todoSelected( false );
3161 emit organizerEventsSelected(false); 3188 emit organizerEventsSelected(false);
3162 emit groupEventsSelected(false); 3189 emit groupEventsSelected(false);
3163 } 3190 }
3164 return; 3191 return;
3165 } 3192 }
3166 3193
3167 /* if ( incidence && incidence->type() == "Todo" ) { 3194 /* if ( incidence && incidence->type() == "Todo" ) {
3168 emit todoSelected( true ); 3195 emit todoSelected( true );
3169 } else { 3196 } else {
3170 emit todoSelected( false ); 3197 emit todoSelected( false );
3171 }*/ 3198 }*/
3172} 3199}
3173 3200
3174 3201
3175void CalendarView::checkClipboard() 3202void CalendarView::checkClipboard()
3176{ 3203{
3177#ifndef KORG_NODND 3204#ifndef KORG_NODND
3178 if (ICalDrag::canDecode(QApplication::clipboard()->data())) { 3205 if (ICalDrag::canDecode(QApplication::clipboard()->data())) {
3179 emit pasteEnabled(true); 3206 emit pasteEnabled(true);
3180 } else { 3207 } else {
3181 emit pasteEnabled(false); 3208 emit pasteEnabled(false);
3182 } 3209 }
3183#endif 3210#endif
3184} 3211}
3185 3212
3186void CalendarView::showDates(const DateList &selectedDates) 3213void CalendarView::showDates(const DateList &selectedDates)
3187{ 3214{
3188 // kdDebug() << "CalendarView::selectDates()" << endl; 3215 // kdDebug() << "CalendarView::selectDates()" << endl;
3189 3216
3190 if ( mViewManager->currentView() ) { 3217 if ( mViewManager->currentView() ) {
3191 updateView( selectedDates.first(), selectedDates.last() ); 3218 updateView( selectedDates.first(), selectedDates.last() );
3192 } else { 3219 } else {
3193 mViewManager->showAgendaView(); 3220 mViewManager->showAgendaView();
3194 } 3221 }
3195 3222
3196 QString selDates; 3223 QString selDates;
3197 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); 3224 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true);
3198 if (selectedDates.first() < selectedDates.last() ) 3225 if (selectedDates.first() < selectedDates.last() )
3199 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); 3226 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true);
3200 topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); 3227 topLevelWidget()->setCaption( i18n("Dates: ") + selDates );
3201 3228
3202} 3229}
3203 3230
3204QPtrList<CalFilter> CalendarView::filters() 3231QPtrList<CalFilter> CalendarView::filters()
3205{ 3232{
3206 return mFilters; 3233 return mFilters;
3207 3234
3208} 3235}
3209void CalendarView::editFilters() 3236void CalendarView::editFilters()
3210{ 3237{
3211 // kdDebug() << "CalendarView::editFilters()" << endl; 3238 // kdDebug() << "CalendarView::editFilters()" << endl;
3212 3239
3213 CalFilter *filter = mFilters.first(); 3240 CalFilter *filter = mFilters.first();
3214 while(filter) { 3241 while(filter) {
3215 kdDebug() << " Filter: " << filter->name() << endl; 3242 kdDebug() << " Filter: " << filter->name() << endl;
3216 filter = mFilters.next(); 3243 filter = mFilters.next();
3217 } 3244 }
3218 3245
3219 mDialogManager->showFilterEditDialog(&mFilters); 3246 mDialogManager->showFilterEditDialog(&mFilters);
3220} 3247}
3221void CalendarView::toggleFilter() 3248void CalendarView::toggleFilter()
3222{ 3249{
3223 showFilter(! mFilterView->isVisible()); 3250 showFilter(! mFilterView->isVisible());
3224} 3251}
3225 3252
3226KOFilterView *CalendarView::filterView() 3253KOFilterView *CalendarView::filterView()
3227{ 3254{
3228 return mFilterView; 3255 return mFilterView;
3229} 3256}
3230void CalendarView::selectFilter( int fil ) 3257void CalendarView::selectFilter( int fil )
3231{ 3258{
3232 mFilterView->setSelectedFilter( fil ); 3259 mFilterView->setSelectedFilter( fil );
3233} 3260}
3234void CalendarView::showFilter(bool visible) 3261void CalendarView::showFilter(bool visible)
3235{ 3262{
3236 if (visible) mFilterView->show(); 3263 if (visible) mFilterView->show();
3237 else mFilterView->hide(); 3264 else mFilterView->hide();
3238} 3265}
3239void CalendarView::toggleFilerEnabled( ) 3266void CalendarView::toggleFilerEnabled( )
3240{ 3267{
3241 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); 3268 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() );
3242 if ( !mFilterView->filtersEnabled() ) 3269 if ( !mFilterView->filtersEnabled() )
3243 topLevelWidget()->setCaption( i18n("Filter disabled ") ); 3270 topLevelWidget()->setCaption( i18n("Filter disabled ") );
3244 3271
3245} 3272}
3246void CalendarView::updateFilter() 3273void CalendarView::updateFilter()
3247{ 3274{
3248 CalFilter *filter = mFilterView->selectedFilter(); 3275 CalFilter *filter = mFilterView->selectedFilter();
3249 if (filter) { 3276 if (filter) {
3250 if (mFilterView->filtersEnabled()) { 3277 if (mFilterView->filtersEnabled()) {
3251 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); 3278 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() );
3252 filter->setEnabled(true); 3279 filter->setEnabled(true);
3253 } 3280 }
3254 else filter->setEnabled(false); 3281 else filter->setEnabled(false);
3255 mCalendar->setFilter(filter); 3282 mCalendar->setFilter(filter);
3256 updateView(); 3283 updateView();
3257 } 3284 }
3258} 3285}
3259 3286
3260void CalendarView::filterEdited() 3287void CalendarView::filterEdited()
3261{ 3288{
3262 mFilterView->updateFilters(); 3289 mFilterView->updateFilters();
3263 updateFilter(); 3290 updateFilter();
3264 writeSettings(); 3291 writeSettings();
3265} 3292}
3266 3293
3267 3294
3268void CalendarView::takeOverEvent() 3295void CalendarView::takeOverEvent()
3269{ 3296{
3270 Incidence *incidence = currentSelection(); 3297 Incidence *incidence = currentSelection();
3271 3298
3272 if (!incidence) return; 3299 if (!incidence) return;
3273 3300
3274 incidence->setOrganizer(KOPrefs::instance()->email()); 3301 incidence->setOrganizer(KOPrefs::instance()->email());
3275 incidence->recreate(); 3302 incidence->recreate();
3276 incidence->setReadOnly(false); 3303 incidence->setReadOnly(false);
3277 3304
3278 updateView(); 3305 updateView();
3279} 3306}
3280 3307
3281void CalendarView::takeOverCalendar() 3308void CalendarView::takeOverCalendar()
3282{ 3309{
3283 // TODO: Create Calendar::allIncidences() function and use it here 3310 // TODO: Create Calendar::allIncidences() function and use it here
3284 3311
3285 QPtrList<Event> events = mCalendar->events(); 3312 QPtrList<Event> events = mCalendar->events();
3286 for(uint i=0; i<events.count(); ++i) { 3313 for(uint i=0; i<events.count(); ++i) {
3287 events.at(i)->setOrganizer(KOPrefs::instance()->email()); 3314 events.at(i)->setOrganizer(KOPrefs::instance()->email());
3288 events.at(i)->recreate(); 3315 events.at(i)->recreate();
3289 events.at(i)->setReadOnly(false); 3316 events.at(i)->setReadOnly(false);
3290 } 3317 }
3291 3318
3292 QPtrList<Todo> todos = mCalendar->todos(); 3319 QPtrList<Todo> todos = mCalendar->todos();
3293 for(uint i=0; i<todos.count(); ++i) { 3320 for(uint i=0; i<todos.count(); ++i) {
3294 todos.at(i)->setOrganizer(KOPrefs::instance()->email()); 3321 todos.at(i)->setOrganizer(KOPrefs::instance()->email());
3295 todos.at(i)->recreate(); 3322 todos.at(i)->recreate();
3296 todos.at(i)->setReadOnly(false); 3323 todos.at(i)->setReadOnly(false);
3297 } 3324 }
3298 3325
3299 QPtrList<Journal> journals = mCalendar->journals(); 3326 QPtrList<Journal> journals = mCalendar->journals();
3300 for(uint i=0; i<journals.count(); ++i) { 3327 for(uint i=0; i<journals.count(); ++i) {
3301 journals.at(i)->setOrganizer(KOPrefs::instance()->email()); 3328 journals.at(i)->setOrganizer(KOPrefs::instance()->email());
3302 journals.at(i)->recreate(); 3329 journals.at(i)->recreate();
3303 journals.at(i)->setReadOnly(false); 3330 journals.at(i)->setReadOnly(false);
3304 } 3331 }
3305 3332
3306 updateView(); 3333 updateView();
3307} 3334}
3308 3335
3309void CalendarView::showIntro() 3336void CalendarView::showIntro()
3310{ 3337{
3311 kdDebug() << "To be implemented." << endl; 3338 kdDebug() << "To be implemented." << endl;
3312} 3339}
3313 3340
3314QWidgetStack *CalendarView::viewStack() 3341QWidgetStack *CalendarView::viewStack()
3315{ 3342{
3316 return mRightFrame; 3343 return mRightFrame;
3317} 3344}
3318 3345
3319QWidget *CalendarView::leftFrame() 3346QWidget *CalendarView::leftFrame()
3320{ 3347{
3321 return mLeftFrame; 3348 return mLeftFrame;
3322} 3349}
3323 3350
3324DateNavigator *CalendarView::dateNavigator() 3351DateNavigator *CalendarView::dateNavigator()
3325{ 3352{
3326 return mNavigator; 3353 return mNavigator;
3327} 3354}
3328 3355
3329KDateNavigator* CalendarView::dateNavigatorWidget() 3356KDateNavigator* CalendarView::dateNavigatorWidget()
3330{ 3357{
3331 return mDateNavigator; 3358 return mDateNavigator;
3332} 3359}
3333void CalendarView::toggleDateNavigatorWidget() 3360void CalendarView::toggleDateNavigatorWidget()
3334{ 3361{
3335 if (mDateNavigator->isVisible()) 3362 if (mDateNavigator->isVisible())
3336 mDateNavigator->hide(); 3363 mDateNavigator->hide();
3337 else 3364 else
3338 mDateNavigator->show(); 3365 mDateNavigator->show();
3339} 3366}
3340void CalendarView::addView(KOrg::BaseView *view) 3367void CalendarView::addView(KOrg::BaseView *view)
3341{ 3368{
3342 mViewManager->addView(view); 3369 mViewManager->addView(view);
3343} 3370}
3344 3371
3345void CalendarView::showView(KOrg::BaseView *view) 3372void CalendarView::showView(KOrg::BaseView *view)
3346{ 3373{
3347 mViewManager->showView(view, mLeftFrame->isVisible()); 3374 mViewManager->showView(view, mLeftFrame->isVisible());
3348} 3375}
3349 3376
3350Incidence *CalendarView::currentSelection() 3377Incidence *CalendarView::currentSelection()
3351{ 3378{
3352 return mViewManager->currentSelection(); 3379 return mViewManager->currentSelection();
3353} 3380}
3354void CalendarView::toggleAllDaySize() 3381void CalendarView::toggleAllDaySize()
3355{ 3382{
3356 /* 3383 /*
3357 if ( KOPrefs::instance()->mAllDaySize > 47 ) 3384 if ( KOPrefs::instance()->mAllDaySize > 47 )
3358 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; 3385 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2;
3359 else 3386 else
3360 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; 3387 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2;
3361 */ 3388 */
3362 viewManager()->agendaView()->toggleAllDay(); 3389 viewManager()->agendaView()->toggleAllDay();
3363} 3390}
3364void CalendarView::toggleExpand() 3391void CalendarView::toggleExpand()
3365{ 3392{
3366 // if ( mLeftFrame->isHidden() ) { 3393 // if ( mLeftFrame->isHidden() ) {
3367 // mLeftFrame->show(); 3394 // mLeftFrame->show();
3368 // emit calendarViewExpanded( false ); 3395 // emit calendarViewExpanded( false );
3369 // } else { 3396 // } else {
3370 // mLeftFrame->hide(); 3397 // mLeftFrame->hide();
3371 // emit calendarViewExpanded( true ); 3398 // emit calendarViewExpanded( true );
3372 // } 3399 // }
3373 3400
3374 globalFlagBlockAgenda = 1; 3401 globalFlagBlockAgenda = 1;
3375 emit calendarViewExpanded( !mLeftFrame->isHidden() ); 3402 emit calendarViewExpanded( !mLeftFrame->isHidden() );
3376 globalFlagBlockAgenda = 5; 3403 globalFlagBlockAgenda = 5;
3377 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); 3404 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() );
3378 //mViewManager->showView( 0, true ); 3405 //mViewManager->showView( 0, true );
3379} 3406}
3380 3407
3381void CalendarView::calendarModified( bool modified, Calendar * ) 3408void CalendarView::calendarModified( bool modified, Calendar * )
3382{ 3409{
3383 setModified( modified ); 3410 setModified( modified );
3384} 3411}
3385 3412
3386Todo *CalendarView::selectedTodo() 3413Todo *CalendarView::selectedTodo()
3387{ 3414{
3388 Incidence *incidence = currentSelection(); 3415 Incidence *incidence = currentSelection();
3389 if ( incidence && incidence->type() == "Todo" ) { 3416 if ( incidence && incidence->type() == "Todo" ) {
3390 return static_cast<Todo *>( incidence ); 3417 return static_cast<Todo *>( incidence );
3391 } 3418 }
3392 3419
3393 incidence = mTodoList->selectedIncidences().first(); 3420 incidence = mTodoList->selectedIncidences().first();
3394 if ( incidence && incidence->type() == "Todo" ) { 3421 if ( incidence && incidence->type() == "Todo" ) {
3395 return static_cast<Todo *>( incidence ); 3422 return static_cast<Todo *>( incidence );
3396 } 3423 }
3397 3424
3398 return 0; 3425 return 0;
3399} 3426}
3400 3427
3401void CalendarView::dialogClosing(Incidence *in) 3428void CalendarView::dialogClosing(Incidence *in)
3402{ 3429{
3403 // mDialogList.remove(in); 3430 // mDialogList.remove(in);
3404} 3431}
3405 3432
3406void CalendarView::showIncidence() 3433void CalendarView::showIncidence()
3407{ 3434{
3408 Incidence *incidence = currentSelection(); 3435 Incidence *incidence = currentSelection();
3409 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3436 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3410 if ( incidence ) { 3437 if ( incidence ) {
3411 ShowIncidenceVisitor v; 3438 ShowIncidenceVisitor v;
3412 v.act( incidence, this ); 3439 v.act( incidence, this );
3413 } 3440 }
3414} 3441}
3415void CalendarView::editIncidenceDescription() 3442void CalendarView::editIncidenceDescription()
3416{ 3443{
3417 mFlagEditDescription = true; 3444 mFlagEditDescription = true;
3418 editIncidence(); 3445 editIncidence();
3419 mFlagEditDescription = false; 3446 mFlagEditDescription = false;
3420} 3447}
3421void CalendarView::editIncidence() 3448void CalendarView::editIncidence()
3422{ 3449{
3423 // qDebug("editIncidence() "); 3450 // qDebug("editIncidence() ");
3424 Incidence *incidence = currentSelection(); 3451 Incidence *incidence = currentSelection();
3425 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3452 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3426 if ( incidence ) { 3453 if ( incidence ) {
3427 EditIncidenceVisitor v; 3454 EditIncidenceVisitor v;
3428 v.act( incidence, this ); 3455 v.act( incidence, this );
3429 } 3456 }
3430} 3457}
3431 3458
3432void CalendarView::deleteIncidence() 3459void CalendarView::deleteIncidence()
3433{ 3460{
3434 Incidence *incidence = currentSelection(); 3461 Incidence *incidence = currentSelection();
3435 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3462 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3436 if ( incidence ) { 3463 if ( incidence ) {
3437 deleteIncidence(incidence); 3464 deleteIncidence(incidence);
3438 } 3465 }
3439} 3466}
3440 3467
3441void CalendarView::showIncidence(Incidence *incidence) 3468void CalendarView::showIncidence(Incidence *incidence)
3442{ 3469{
3443 if ( incidence ) { 3470 if ( incidence ) {
3444 ShowIncidenceVisitor v; 3471 ShowIncidenceVisitor v;
3445 v.act( incidence, this ); 3472 v.act( incidence, this );
3446 } 3473 }
3447} 3474}
3448 3475
3449void CalendarView::editIncidence(Incidence *incidence) 3476void CalendarView::editIncidence(Incidence *incidence)
3450{ 3477{
3451 if ( incidence ) { 3478 if ( incidence ) {
3452 3479
3453 EditIncidenceVisitor v; 3480 EditIncidenceVisitor v;
3454 v.act( incidence, this ); 3481 v.act( incidence, this );
3455 3482
3456 } 3483 }
3457} 3484}
3458 3485
3459void CalendarView::deleteIncidence(Incidence *incidence) 3486void CalendarView::deleteIncidence(Incidence *incidence)
3460{ 3487{
3461 //qDebug(" CalendarView::deleteIncidence "); 3488 //qDebug(" CalendarView::deleteIncidence ");
3462 if ( incidence ) { 3489 if ( incidence ) {
3463 DeleteIncidenceVisitor v; 3490 DeleteIncidenceVisitor v;
3464 v.act( incidence, this ); 3491 v.act( incidence, this );
3465 } 3492 }
3466} 3493}
3467 3494
3468 3495
3469void CalendarView::lookForOutgoingMessages() 3496void CalendarView::lookForOutgoingMessages()
3470{ 3497{
3471 OutgoingDialog *ogd = mDialogManager->outgoingDialog(); 3498 OutgoingDialog *ogd = mDialogManager->outgoingDialog();
3472 ogd->loadMessages(); 3499 ogd->loadMessages();
3473} 3500}
3474 3501
3475void CalendarView::lookForIncomingMessages() 3502void CalendarView::lookForIncomingMessages()
3476{ 3503{
3477 IncomingDialog *icd = mDialogManager->incomingDialog(); 3504 IncomingDialog *icd = mDialogManager->incomingDialog();
3478 icd->retrieve(); 3505 icd->retrieve();
3479} 3506}
3480 3507
3481bool CalendarView::removeCompletedSubTodos( Todo* t ) 3508bool CalendarView::removeCompletedSubTodos( Todo* t )
3482{ 3509{
3483 bool deleteTodo = true; 3510 bool deleteTodo = true;
3484 QPtrList<Incidence> subTodos; 3511 QPtrList<Incidence> subTodos;
3485 Incidence *aTodo; 3512 Incidence *aTodo;
3486 subTodos = t->relations(); 3513 subTodos = t->relations();
3487 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { 3514 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
3488 if (! removeCompletedSubTodos( (Todo*) aTodo )) 3515 if (! removeCompletedSubTodos( (Todo*) aTodo ))
3489 deleteTodo = false; 3516 deleteTodo = false;
3490 } 3517 }
3491 if ( deleteTodo ) { 3518 if ( deleteTodo ) {
3492 if ( t->isCompleted() ) { 3519 if ( t->isCompleted() ) {
3493 checkExternalId( t ); 3520 checkExternalId( t );
3494 mCalendar->deleteTodo( t ); 3521 mCalendar->deleteTodo( t );
3495 changeTodoDisplay( t,KOGlobals::EVENTDELETED ); 3522 changeTodoDisplay( t,KOGlobals::EVENTDELETED );
3496 } 3523 }
3497 else 3524 else
3498 deleteTodo = false; 3525 deleteTodo = false;
3499 } 3526 }
3500 return deleteTodo; 3527 return deleteTodo;
3501 3528
3502} 3529}
3503void CalendarView::purgeCompleted() 3530void CalendarView::purgeCompleted()
3504{ 3531{
3505 int result = KMessageBox::warningContinueCancel(this, 3532 int result = KMessageBox::warningContinueCancel(this,
3506 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); 3533 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge"));
3507 3534
3508 if (result == KMessageBox::Continue) { 3535 if (result == KMessageBox::Continue) {
3509 3536
3510 QPtrList<Todo> todoCal; 3537 QPtrList<Todo> todoCal;
3511 QPtrList<Todo> rootTodos; 3538 QPtrList<Todo> rootTodos;
3512 //QPtrList<Incidence> rel; 3539 //QPtrList<Incidence> rel;
3513 Todo *aTodo;//, *rTodo; 3540 Todo *aTodo;//, *rTodo;
3514 Incidence *rIncidence; 3541 Incidence *rIncidence;
3515 bool childDelete = false; 3542 bool childDelete = false;
3516 bool deletedOne = true; 3543 bool deletedOne = true;
3517 todoCal = calendar()->todos(); 3544 todoCal = calendar()->todos();
3518 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { 3545 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
3519 if ( !aTodo->relatedTo() ) 3546 if ( !aTodo->relatedTo() )
3520 rootTodos.append( aTodo ); 3547 rootTodos.append( aTodo );
3521 } 3548 }
3522 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { 3549 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) {
3523 removeCompletedSubTodos( aTodo ); 3550 removeCompletedSubTodos( aTodo );
3524 } 3551 }
3525 3552
3526 updateView(); 3553 updateView();
3527 } 3554 }
3528} 3555}
3529 3556
3530void CalendarView::slotCalendarChanged() 3557void CalendarView::slotCalendarChanged()
3531{ 3558{
3532 ; 3559 ;
3533} 3560}
3534 3561
3535NavigatorBar *CalendarView::navigatorBar() 3562NavigatorBar *CalendarView::navigatorBar()
3536{ 3563{
3537 return mNavigatorBar; 3564 return mNavigatorBar;
3538} 3565}
3539 3566
3540 3567
3541 3568
3542void CalendarView::keyPressEvent ( QKeyEvent *e) 3569void CalendarView::keyPressEvent ( QKeyEvent *e)
3543{ 3570{
3544 //qDebug(" alendarView::keyPressEvent "); 3571 //qDebug(" alendarView::keyPressEvent ");
3545 e->ignore(); 3572 e->ignore();
3546} 3573}
3547 3574
3548//#include "calendarview.moc" 3575//#include "calendarview.moc"
3549 3576
3550//#include "calendarviewbase.moc" 3577//#include "calendarviewbase.moc"
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h
index 446fe2e..a9ac52f 100644
--- a/korganizer/koprefs.h
+++ b/korganizer/koprefs.h
@@ -1,303 +1,304 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23#ifndef KOPREFS_H 23#ifndef KOPREFS_H
24#define KOPREFS_H 24#define KOPREFS_H
25 25
26#include <qdict.h> 26#include <qdict.h>
27 27
28#include <libkdepim/kpimprefs.h> 28#include <libkdepim/kpimprefs.h>
29 29
30class KConfig; 30class KConfig;
31class QFont; 31class QFont;
32class QColor; 32class QColor;
33class QStringList; 33class QStringList;
34 34
35class KOPrefs : public KPimPrefs 35class KOPrefs : public KPimPrefs
36{ 36{
37 public: 37 public:
38 enum { FormatVCalendar, FormatICalendar }; 38 enum { FormatVCalendar, FormatICalendar };
39 enum { MailClientKMail, MailClientSendmail }; 39 enum { MailClientKMail, MailClientSendmail };
40 enum { IMIPDummy, IMIPKMail }; 40 enum { IMIPDummy, IMIPKMail };
41 enum { IMIPOutbox, IMIPdirectsend }; 41 enum { IMIPOutbox, IMIPdirectsend };
42 enum { neverAuto, addressbookAuto, selectedAuto }; 42 enum { neverAuto, addressbookAuto, selectedAuto };
43 enum { standardDestination, askDestination }; 43 enum { standardDestination, askDestination };
44 44
45 virtual ~KOPrefs(); 45 virtual ~KOPrefs();
46 46
47 /** Get instance of KOPrefs. It is made sure that there is only one 47 /** Get instance of KOPrefs. It is made sure that there is only one
48 instance. */ 48 instance. */
49 static KOPrefs *instance(); 49 static KOPrefs *instance();
50 50
51 /** Set preferences to default values */ 51 /** Set preferences to default values */
52 void usrSetDefaults(); 52 void usrSetDefaults();
53 53
54 /** Read preferences from config file */ 54 /** Read preferences from config file */
55 void usrReadConfig(); 55 void usrReadConfig();
56 56
57 /** Write preferences to config file */ 57 /** Write preferences to config file */
58 void usrWriteConfig(); 58 void usrWriteConfig();
59 void setCategoryDefaults(); 59 void setCategoryDefaults();
60 60
61 protected: 61 protected:
62 void setTimeZoneIdDefault(); 62 void setTimeZoneIdDefault();
63 63
64 /** Fill empty mail fields with default values. */ 64 /** Fill empty mail fields with default values. */
65 void fillMailDefaults(); 65 void fillMailDefaults();
66 66
67 private: 67 private:
68 /** Constructor disabled for public. Use instance() to create a KOPrefs 68 /** Constructor disabled for public. Use instance() to create a KOPrefs
69 object. */ 69 object. */
70 KOPrefs(); 70 KOPrefs();
71 71
72 static KOPrefs *mInstance; 72 static KOPrefs *mInstance;
73 QDict<QString> *mLocaleDict; 73 QDict<QString> *mLocaleDict;
74 QStringList getDefaultList(); 74 QStringList getDefaultList();
75 public: 75 public:
76 // preferences data 76 // preferences data
77 KConfig* getConfig(); 77 KConfig* getConfig();
78 void setFullName(const QString &); 78 void setFullName(const QString &);
79 QString fullName(); 79 QString fullName();
80 void setEmail(const QString &); 80 void setEmail(const QString &);
81 QString email(); 81 QString email();
82 82
83 QString mAdditional; 83 QString mAdditional;
84 84
85 bool mEmailControlCenter; 85 bool mEmailControlCenter;
86 86
87 bool mBcc; 87 bool mBcc;
88 bool mAutoSave; 88 bool mAutoSave;
89 int mAutoSaveInterval; 89 int mAutoSaveInterval;
90 bool mConfirm; 90 bool mConfirm;
91 91
92 bool mEnableGroupScheduling; 92 bool mEnableGroupScheduling;
93 bool mEnableProjectView; 93 bool mEnableProjectView;
94 94
95 int mDefaultFormat; 95 int mDefaultFormat;
96 int mMailClient; 96 int mMailClient;
97 97
98 QString mTimeZone; 98 QString mTimeZone;
99 QString mTimeZoneId; 99 QString mTimeZoneId;
100 //QString mTimeZoneName; // e.g. +00:04:00 Indian/Mauritius 100 //QString mTimeZoneName; // e.g. +00:04:00 Indian/Mauritius
101 //int mTimeZoneOffset; // e.g. -240 min 101 //int mTimeZoneOffset; // e.g. -240 min
102 bool mUseDaylightsaving; 102 bool mUseDaylightsaving;
103 int mDaylightsavingStart; 103 int mDaylightsavingStart;
104 int mDaylightsavingEnd; 104 int mDaylightsavingEnd;
105 int mStartTime; 105 int mStartTime;
106 int mDefaultDuration; 106 int mDefaultDuration;
107 int mAlarmTime; 107 int mAlarmTime;
108 int mDaylightSavings; 108 int mDaylightSavings;
109 109
110 int mWorkingHoursStart; 110 int mWorkingHoursStart;
111 int mWorkingHoursEnd; 111 int mWorkingHoursEnd;
112 bool mExcludeHolidays; 112 bool mExcludeHolidays;
113 bool mExcludeSaturdays; 113 bool mExcludeSaturdays;
114 bool mMarcusBainsShowSeconds; 114 bool mMarcusBainsShowSeconds;
115 115
116 QFont mTimeBarFont; 116 QFont mTimeBarFont;
117 QFont mMonthViewFont; 117 QFont mMonthViewFont;
118 QFont mAgendaViewFont; 118 QFont mAgendaViewFont;
119 QFont mMarcusBainsFont; 119 QFont mMarcusBainsFont;
120 QFont mTimeLabelsFont; 120 QFont mTimeLabelsFont;
121 QFont mTodoViewFont; 121 QFont mTodoViewFont;
122 QFont mListViewFont; 122 QFont mListViewFont;
123 QFont mDateNavigatorFont; 123 QFont mDateNavigatorFont;
124 QFont mEditBoxFont; 124 QFont mEditBoxFont;
125 QFont mJornalViewFont; 125 QFont mJornalViewFont;
126 QFont mWhatsNextFont; 126 QFont mWhatsNextFont;
127 QFont mEventViewFont; 127 QFont mEventViewFont;
128 128
129 129
130 130
131 131
132 QColor mHolidayColor; 132 QColor mHolidayColor;
133 QColor mHighlightColor; 133 QColor mHighlightColor;
134 QColor mEventColor; 134 QColor mEventColor;
135 QColor mAgendaBgColor; 135 QColor mAgendaBgColor;
136 QColor mWorkingHoursColor; 136 QColor mWorkingHoursColor;
137 QColor mTodoDueTodayColor; 137 QColor mTodoDueTodayColor;
138 QColor mTodoOverdueColor; 138 QColor mTodoOverdueColor;
139 QColor mMonthViewEvenColor; 139 QColor mMonthViewEvenColor;
140 QColor mMonthViewOddColor; 140 QColor mMonthViewOddColor;
141 QColor mMonthViewHolidayColor; 141 QColor mMonthViewHolidayColor;
142 bool mMonthViewUsesDayColors; 142 bool mMonthViewUsesDayColors;
143 bool mMonthViewSatSunTog; 143 bool mMonthViewSatSunTog;
144 QColor mAppColor1; 144 QColor mAppColor1;
145 QColor mAppColor2; 145 QColor mAppColor2;
146 bool mUseAppColors; 146 bool mUseAppColors;
147 147
148 int mDayBegins; 148 int mDayBegins;
149 int mHourSize; 149 int mHourSize;
150 int mAllDaySize; 150 int mAllDaySize;
151 bool mShowFullMenu; 151 bool mShowFullMenu;
152 bool mDailyRecur; 152 bool mDailyRecur;
153 bool mWeeklyRecur; 153 bool mWeeklyRecur;
154 bool mMonthDailyRecur; 154 bool mMonthDailyRecur;
155 bool mMonthWeeklyRecur; 155 bool mMonthWeeklyRecur;
156 bool mMonthShowIcons; 156 bool mMonthShowIcons;
157 bool mMonthShowShort; 157 bool mMonthShowShort;
158 bool mEnableToolTips; 158 bool mEnableToolTips;
159 bool mEnableMonthScroll; 159 bool mEnableMonthScroll;
160 bool mFullViewMonth; 160 bool mFullViewMonth;
161 bool mMonthViewUsesCategoryColor; 161 bool mMonthViewUsesCategoryColor;
162 bool mFullViewTodo; 162 bool mFullViewTodo;
163 bool mShowCompletedTodo; 163 bool mShowCompletedTodo;
164 bool mMarcusBainsEnabled; 164 bool mMarcusBainsEnabled;
165 int mNextXDays; 165 int mNextXDays;
166 int mWhatsNextDays; 166 int mWhatsNextDays;
167 int mWhatsNextPrios; 167 int mWhatsNextPrios;
168 bool mEnableQuickTodo; 168 bool mEnableQuickTodo;
169 bool mLanguageChanged; 169 bool mLanguageChanged;
170 170
171 bool mCompactDialogs; 171 bool mCompactDialogs;
172 bool mVerticalScreen; 172 bool mVerticalScreen;
173 173
174 bool mShowIconNewTodo; 174 bool mShowIconNewTodo;
175 bool mShowIconNewEvent; 175 bool mShowIconNewEvent;
176 bool mShowIconSearch; 176 bool mShowIconSearch;
177 bool mShowIconList; 177 bool mShowIconList;
178 bool mShowIconDay1; 178 bool mShowIconDay1;
179 bool mShowIconDay5; 179 bool mShowIconDay5;
180 bool mShowIconDay7; 180 bool mShowIconDay7;
181 bool mShowIconMonth; 181 bool mShowIconMonth;
182 bool mShowIconTodoview; 182 bool mShowIconTodoview;
183 bool mShowIconBackFast; 183 bool mShowIconBackFast;
184 bool mShowIconBack; 184 bool mShowIconBack;
185 bool mShowIconToday; 185 bool mShowIconToday;
186 bool mShowIconForward; 186 bool mShowIconForward;
187 bool mShowIconForwardFast; 187 bool mShowIconForwardFast;
188 bool mShowIconWhatsThis; 188 bool mShowIconWhatsThis;
189 bool mShowIconNextDays; 189 bool mShowIconNextDays;
190 bool mShowIconNext; 190 bool mShowIconNext;
191 bool mShowIconJournal; 191 bool mShowIconJournal;
192 192
193 bool mShowIconStretch; 193 bool mShowIconStretch;
194 194
195 bool mToolBarHor; 195 bool mToolBarHor;
196 bool mToolBarUp; 196 bool mToolBarUp;
197 bool mToolBarMiniIcons; 197 bool mToolBarMiniIcons;
198 198
199 bool mAskForQuit; 199 bool mAskForQuit;
200 bool mUsePassWd; 200 bool mUsePassWd;
201 bool mWriteBackFile; 201 bool mWriteBackFile;
202 int mWriteBackInFuture;
202 bool mAskForPreferences; 203 bool mAskForPreferences;
203 bool mShowSyncSummary; 204 bool mShowSyncSummary;
204 bool mShowSyncEvents; 205 bool mShowSyncEvents;
205 bool mShowTodoInAgenda; 206 bool mShowTodoInAgenda;
206 bool mWriteBackExistingOnly; 207 bool mWriteBackExistingOnly;
207 208
208 QString mRemoteIP; 209 QString mRemoteIP;
209 QString mRemoteUser; 210 QString mRemoteUser;
210 QString mRemotePassWd; 211 QString mRemotePassWd;
211 QString mRemoteFile; 212 QString mRemoteFile;
212 QString mLocalTempFile; 213 QString mLocalTempFile;
213 QString mPhoneDevice; 214 QString mPhoneDevice;
214 QString mPhoneConnection; 215 QString mPhoneConnection;
215 QString mPhoneModel; 216 QString mPhoneModel;
216 217
217 int mLastSyncTime; 218 int mLastSyncTime;
218 int mSyncAlgoPrefs; 219 int mSyncAlgoPrefs;
219 int mRingSyncAlgoPrefs; 220 int mRingSyncAlgoPrefs;
220 QStringList mSyncProfileNames; 221 QStringList mSyncProfileNames;
221 QStringList mExternSyncProfiles; 222 QStringList mExternSyncProfiles;
222 QString mLocalMachineName; 223 QString mLocalMachineName;
223 void setCategoryColor(QString cat,const QColor & color); 224 void setCategoryColor(QString cat,const QColor & color);
224 QColor *categoryColor(QString cat); 225 QColor *categoryColor(QString cat);
225 226
226 QString mArchiveFile; 227 QString mArchiveFile;
227 QString mHtmlExportFile; 228 QString mHtmlExportFile;
228 bool mHtmlWithSave; 229 bool mHtmlWithSave;
229 230
230 QStringList mSelectedPlugins; 231 QStringList mSelectedPlugins;
231 232
232 QString mLastImportFile; 233 QString mLastImportFile;
233 QString mLastVcalFile; 234 QString mLastVcalFile;
234 QString mLastSaveFile; 235 QString mLastSaveFile;
235 QString mLastLoadFile; 236 QString mLastLoadFile;
236 QString mLastSyncedLocalFile; 237 QString mLastSyncedLocalFile;
237 238
238 239
239 QString mDefaultAlarmFile; 240 QString mDefaultAlarmFile;
240 int mIMIPScheduler; 241 int mIMIPScheduler;
241 int mIMIPSend; 242 int mIMIPSend;
242 QStringList mAdditionalMails; 243 QStringList mAdditionalMails;
243 int mIMIPAutoRefresh; 244 int mIMIPAutoRefresh;
244 int mIMIPAutoInsertReply; 245 int mIMIPAutoInsertReply;
245 int mIMIPAutoInsertRequest; 246 int mIMIPAutoInsertRequest;
246 int mIMIPAutoFreeBusy; 247 int mIMIPAutoFreeBusy;
247 int mIMIPAutoFreeBusyReply; 248 int mIMIPAutoFreeBusyReply;
248 249
249 QStringList mTodoTemplates; 250 QStringList mTodoTemplates;
250 QStringList mEventTemplates; 251 QStringList mEventTemplates;
251 252
252 int mDestination; 253 int mDestination;
253 254
254 255
255 bool mEditOnDoubleClick; 256 bool mEditOnDoubleClick;
256 bool mViewChangeHoldFullscreen; 257 bool mViewChangeHoldFullscreen;
257 bool mViewChangeHoldNonFullscreen; 258 bool mViewChangeHoldNonFullscreen;
258 bool mCenterOnCurrentTime; 259 bool mCenterOnCurrentTime;
259 bool mSetTimeToDayStartAt; 260 bool mSetTimeToDayStartAt;
260 bool mHighlightCurrentDay; 261 bool mHighlightCurrentDay;
261 bool mUseHighlightLightColor; 262 bool mUseHighlightLightColor;
262 bool mListViewMonthTimespan; 263 bool mListViewMonthTimespan;
263 bool mWNViewShowsParents; 264 bool mWNViewShowsParents;
264 bool mWNViewShowLocation; 265 bool mWNViewShowLocation;
265 bool mTodoViewShowsPercentage; 266 bool mTodoViewShowsPercentage;
266 bool mTodoViewUsesCatColors; 267 bool mTodoViewUsesCatColors;
267 bool mTodoViewUsesSmallFont; 268 bool mTodoViewUsesSmallFont;
268 bool mTodoViewUsesForegroundColor; 269 bool mTodoViewUsesForegroundColor;
269 bool mMonthViewUsesForegroundColor; 270 bool mMonthViewUsesForegroundColor;
270 271
271 bool mHightlightDateTimeEdit; 272 bool mHightlightDateTimeEdit;
272 int mPreferredLanguage; 273 int mPreferredLanguage;
273 bool mUseQuicksave; 274 bool mUseQuicksave;
274 int mPreferredTime; 275 int mPreferredTime;
275 int mPreferredDate; 276 int mPreferredDate;
276 bool mWeekStartsOnSunday; 277 bool mWeekStartsOnSunday;
277 bool mShortDateInViewer; 278 bool mShortDateInViewer;
278 QString mUserDateFormatLong; 279 QString mUserDateFormatLong;
279 QString mUserDateFormatShort; 280 QString mUserDateFormatShort;
280 281
281 QStringList mLocationDefaults; 282 QStringList mLocationDefaults;
282 QStringList mEventSummaryUser; 283 QStringList mEventSummaryUser;
283 QStringList mTodoSummaryUser; 284 QStringList mTodoSummaryUser;
284 285
285 bool mUseInternalAlarmNotification; 286 bool mUseInternalAlarmNotification;
286 int mAlarmPlayBeeps; 287 int mAlarmPlayBeeps;
287 int mAlarmSuspendTime; 288 int mAlarmSuspendTime;
288 int mAlarmSuspendCount; 289 int mAlarmSuspendCount;
289 int mAlarmBeepInterval; 290 int mAlarmBeepInterval;
290 291
291 private: 292 private:
292 QDict<QColor> mCategoryColors; 293 QDict<QColor> mCategoryColors;
293 QColor mDefaultCategoryColor; 294 QColor mDefaultCategoryColor;
294 295
295 QFont mDefaultTimeBarFont; 296 QFont mDefaultTimeBarFont;
296 QFont mDefaultViewFont; 297 QFont mDefaultViewFont;
297 QFont mDefaultMonthViewFont; 298 QFont mDefaultMonthViewFont;
298 299
299 QString mName; 300 QString mName;
300 QString mEmail; 301 QString mEmail;
301}; 302};
302 303
303#endif 304#endif
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index d8aa43a..aa30b52 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1,2117 +1,2123 @@
1#include <stdlib.h> 1#include <stdlib.h>
2 2
3#include <qaction.h> 3#include <qaction.h>
4#include <qpopupmenu.h> 4#include <qpopupmenu.h>
5#include <qpainter.h> 5#include <qpainter.h>
6#include <qwhatsthis.h> 6#include <qwhatsthis.h>
7#include <qmessagebox.h> 7#include <qmessagebox.h>
8#include <qlineedit.h> 8#include <qlineedit.h>
9#include <qfile.h> 9#include <qfile.h>
10#include <qdir.h> 10#include <qdir.h>
11#include <qapp.h> 11#include <qapp.h>
12#include <qfileinfo.h> 12#include <qfileinfo.h>
13#include <qlabel.h> 13#include <qlabel.h>
14#include <qmap.h> 14#include <qmap.h>
15#include <qwmatrix.h> 15#include <qwmatrix.h>
16#include <qtextbrowser.h> 16#include <qtextbrowser.h>
17#include <qtextstream.h> 17#include <qtextstream.h>
18#ifndef DESKTOP_VERSION 18#ifndef DESKTOP_VERSION
19#include <qpe/global.h> 19#include <qpe/global.h>
20#include <qpe/qpemenubar.h> 20#include <qpe/qpemenubar.h>
21#include <qpe/qpetoolbar.h> 21#include <qpe/qpetoolbar.h>
22#include <qpe/resource.h> 22#include <qpe/resource.h>
23#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
24#include <qtopia/alarmserver.h> 24#include <qtopia/alarmserver.h>
25#include <qtopia/qcopenvelope_qws.h> 25#include <qtopia/qcopenvelope_qws.h>
26#else 26#else
27#include <qmenubar.h> 27#include <qmenubar.h>
28#include <qtoolbar.h> 28#include <qtoolbar.h>
29#include <qapplication.h> 29#include <qapplication.h>
30//#include <resource.h> 30//#include <resource.h>
31 31
32#endif 32#endif
33#include <libkcal/calendarlocal.h> 33#include <libkcal/calendarlocal.h>
34#include <libkcal/todo.h> 34#include <libkcal/todo.h>
35#include <libkdepim/ksyncprofile.h> 35#include <libkdepim/ksyncprofile.h>
36#include <libkdepim/kincidenceformatter.h> 36#include <libkdepim/kincidenceformatter.h>
37 37
38#include "calendarview.h" 38#include "calendarview.h"
39#include "koviewmanager.h" 39#include "koviewmanager.h"
40#include "datenavigator.h" 40#include "datenavigator.h"
41#include "koagendaview.h" 41#include "koagendaview.h"
42#include "koagenda.h" 42#include "koagenda.h"
43#include "kodialogmanager.h" 43#include "kodialogmanager.h"
44#include "kdialogbase.h" 44#include "kdialogbase.h"
45#include "kapplication.h" 45#include "kapplication.h"
46#include "kofilterview.h" 46#include "kofilterview.h"
47#include "kstandarddirs.h" 47#include "kstandarddirs.h"
48#include "koprefs.h" 48#include "koprefs.h"
49#include "kfiledialog.h" 49#include "kfiledialog.h"
50#include "koglobals.h" 50#include "koglobals.h"
51#include "kglobal.h" 51#include "kglobal.h"
52#include "klocale.h" 52#include "klocale.h"
53#include "kconfig.h" 53#include "kconfig.h"
54#include "simplealarmclient.h" 54#include "simplealarmclient.h"
55#include "externalapphandler.h" 55#include "externalapphandler.h"
56 56
57using namespace KCal; 57using namespace KCal;
58#ifndef _WIN32_ 58#ifndef _WIN32_
59#include <unistd.h> 59#include <unistd.h>
60#else 60#else
61#include "koimportoldialog.h" 61#include "koimportoldialog.h"
62#endif 62#endif
63#include "mainwindow.h" 63#include "mainwindow.h"
64 64
65int globalFlagBlockStartup; 65int globalFlagBlockStartup;
66MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : 66MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
67 QMainWindow( parent, name ) 67 QMainWindow( parent, name )
68{ 68{
69 69
70#ifdef DESKTOP_VERSION 70#ifdef DESKTOP_VERSION
71 setFont( QFont("Arial"), 14 ); 71 setFont( QFont("Arial"), 14 );
72#endif 72#endif
73 73
74 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; 74 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
75 QString confFile = locateLocal("config","korganizerrc"); 75 QString confFile = locateLocal("config","korganizerrc");
76 QFileInfo finf ( confFile ); 76 QFileInfo finf ( confFile );
77 bool showWarning = !finf.exists(); 77 bool showWarning = !finf.exists();
78 setIcon(SmallIcon( "ko24" ) ); 78 setIcon(SmallIcon( "ko24" ) );
79 mBlockAtStartup = true; 79 mBlockAtStartup = true;
80 mFlagKeyPressed = false; 80 mFlagKeyPressed = false;
81 setCaption("KOrganizer/Pi"); 81 setCaption("KOrganizer/Pi");
82 KOPrefs *p = KOPrefs::instance(); 82 KOPrefs *p = KOPrefs::instance();
83 // if ( QApplication::desktop()->height() > 480 ) { 83 // if ( QApplication::desktop()->height() > 480 ) {
84// if ( p->mHourSize == 4 ) 84// if ( p->mHourSize == 4 )
85// p->mHourSize = 6; 85// p->mHourSize = 6;
86// } 86// }
87 if ( p->mHourSize > 18 ) 87 if ( p->mHourSize > 18 )
88 p->mHourSize = 18; 88 p->mHourSize = 18;
89 QMainWindow::ToolBarDock tbd; 89 QMainWindow::ToolBarDock tbd;
90 if ( p->mToolBarHor ) { 90 if ( p->mToolBarHor ) {
91 if ( p->mToolBarUp ) 91 if ( p->mToolBarUp )
92 tbd = Bottom; 92 tbd = Bottom;
93 else 93 else
94 tbd = Top; 94 tbd = Top;
95 } 95 }
96 else { 96 else {
97 if ( p->mToolBarUp ) 97 if ( p->mToolBarUp )
98 tbd = Right; 98 tbd = Right;
99 else 99 else
100 tbd = Left; 100 tbd = Left;
101 } 101 }
102 if ( KOPrefs::instance()->mUseAppColors ) 102 if ( KOPrefs::instance()->mUseAppColors )
103 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 103 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
104 globalFlagBlockStartup = 1; 104 globalFlagBlockStartup = 1;
105 iconToolBar = new QPEToolBar( this ); 105 iconToolBar = new QPEToolBar( this );
106 addToolBar (iconToolBar , tbd ); 106 addToolBar (iconToolBar , tbd );
107 mBlockSaveFlag = false; 107 mBlockSaveFlag = false;
108 mCalendarModifiedFlag = false; 108 mCalendarModifiedFlag = false;
109 109
110 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); 110 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
111 splash->setAlignment ( AlignCenter ); 111 splash->setAlignment ( AlignCenter );
112 setCentralWidget( splash ); 112 setCentralWidget( splash );
113#ifndef DESKTOP_VERSION 113#ifndef DESKTOP_VERSION
114 showMaximized(); 114 showMaximized();
115#endif 115#endif
116 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); 116 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
117 setDefaultPreferences(); 117 setDefaultPreferences();
118 mCalendar = new CalendarLocal(); 118 mCalendar = new CalendarLocal();
119 mView = new CalendarView( mCalendar, this,"mCalendar " ); 119 mView = new CalendarView( mCalendar, this,"mCalendar " );
120 mView->hide(); 120 mView->hide();
121 //mView->resize(splash->size() ); 121 //mView->resize(splash->size() );
122 initActions(); 122 initActions();
123#ifndef DESKTOP_VERSION 123#ifndef DESKTOP_VERSION
124 iconToolBar->show(); 124 iconToolBar->show();
125 qApp->processEvents(); 125 qApp->processEvents();
126#endif 126#endif
127 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); 127 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
128 int vh = height() ; 128 int vh = height() ;
129 int vw = width(); 129 int vw = width();
130 //qDebug("Toolbar hei %d ",iconToolBar->height() ); 130 //qDebug("Toolbar hei %d ",iconToolBar->height() );
131 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 131 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
132 vh -= iconToolBar->height(); 132 vh -= iconToolBar->height();
133 } else { 133 } else {
134 vw -= iconToolBar->height(); 134 vw -= iconToolBar->height();
135 } 135 }
136 //mView->setMaximumSize( splash->size() ); 136 //mView->setMaximumSize( splash->size() );
137 //mView->resize( splash->size() ); 137 //mView->resize( splash->size() );
138 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 138 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
139 mView->readSettings(); 139 mView->readSettings();
140 bool oldOpened = false; 140 bool oldOpened = false;
141 bool newFile = false; 141 bool newFile = false;
142 if( !QFile::exists( defaultFileName() ) ) { 142 if( !QFile::exists( defaultFileName() ) ) {
143 QFileInfo finfo ( defaultFileName() ); 143 QFileInfo finfo ( defaultFileName() );
144 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); 144 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
145 qDebug("oldfile %s ", oldFile.latin1()); 145 qDebug("oldfile %s ", oldFile.latin1());
146 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; 146 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n";
147 finfo.setFile( oldFile ); 147 finfo.setFile( oldFile );
148 if (finfo.exists() ) { 148 if (finfo.exists() ) {
149 KMessageBox::information( this, message); 149 KMessageBox::information( this, message);
150 mView->openCalendar( oldFile ); 150 mView->openCalendar( oldFile );
151 qApp->processEvents(); 151 qApp->processEvents();
152 } else { 152 } else {
153 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); 153 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
154 finfo.setFile( oldFile ); 154 finfo.setFile( oldFile );
155 if (finfo.exists() ) { 155 if (finfo.exists() ) {
156 KMessageBox::information( this, message); 156 KMessageBox::information( this, message);
157 mView->openCalendar( oldFile ); 157 mView->openCalendar( oldFile );
158 qApp->processEvents(); 158 qApp->processEvents();
159 } 159 }
160 } 160 }
161 mView->saveCalendar( defaultFileName() ); 161 mView->saveCalendar( defaultFileName() );
162 newFile = true; 162 newFile = true;
163 } 163 }
164 164
165 QTime neededSaveTime = QDateTime::currentDateTime().time(); 165 QTime neededSaveTime = QDateTime::currentDateTime().time();
166 if ( ! oldOpened ) 166 if ( ! oldOpened )
167 mView->openCalendar( defaultFileName() ); 167 mView->openCalendar( defaultFileName() );
168 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 168 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
169 qDebug("KO: Calendar loading time: %d ms",msNeeded ); 169 qDebug("KO: Calendar loading time: %d ms",msNeeded );
170 170
171 if ( KOPrefs::instance()->mLanguageChanged ) { 171 if ( KOPrefs::instance()->mLanguageChanged ) {
172 KOPrefs::instance()->setCategoryDefaults(); 172 KOPrefs::instance()->setCategoryDefaults();
173 int count = mView->addCategories(); 173 int count = mView->addCategories();
174 KOPrefs::instance()->mLanguageChanged = false; 174 KOPrefs::instance()->mLanguageChanged = false;
175 } 175 }
176 processIncidenceSelection( 0 ); 176 processIncidenceSelection( 0 );
177 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), 177 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
178 SLOT( processIncidenceSelection( Incidence * ) ) ); 178 SLOT( processIncidenceSelection( Incidence * ) ) );
179 connect( mView, SIGNAL( modifiedChanged( bool ) ), 179 connect( mView, SIGNAL( modifiedChanged( bool ) ),
180 SLOT( slotModifiedChanged( bool ) ) ); 180 SLOT( slotModifiedChanged( bool ) ) );
181 181
182 182
183 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); 183 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
184 mView->setModified( false ); 184 mView->setModified( false );
185 mBlockAtStartup = false; 185 mBlockAtStartup = false;
186 mView->setModified( false ); 186 mView->setModified( false );
187 setCentralWidget( mView ); 187 setCentralWidget( mView );
188 globalFlagBlockStartup = 0; 188 globalFlagBlockStartup = 0;
189 mView->show(); 189 mView->show();
190 delete splash; 190 delete splash;
191 if ( newFile ) 191 if ( newFile )
192 mView->updateConfig(); 192 mView->updateConfig();
193 // qApp->processEvents(); 193 // qApp->processEvents();
194 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 194 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
195 fillSyncMenu(); 195 fillSyncMenu();
196 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); 196 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
197 if ( showWarning ) { 197 if ( showWarning ) {
198 KMessageBox::information( this, 198 KMessageBox::information( this,
199 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); 199 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information");
200 qApp->processEvents(); 200 qApp->processEvents();
201 mView->dialogManager()->showSyncOptions(); 201 mView->dialogManager()->showSyncOptions();
202 } 202 }
203 203
204 //US listen for result adressed from Ka/Pi 204 //US listen for result adressed from Ka/Pi
205#ifndef DESKTOP_VERSION 205#ifndef DESKTOP_VERSION
206 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 206 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
207#endif 207#endif
208} 208}
209MainWindow::~MainWindow() 209MainWindow::~MainWindow()
210{ 210{
211 //qDebug("MainWindow::~MainWindow() "); 211 //qDebug("MainWindow::~MainWindow() ");
212 //save toolbar location 212 //save toolbar location
213 213
214 delete mCalendar; 214 delete mCalendar;
215 delete KOPrefs::instance(); 215 delete KOPrefs::instance();
216 delete KIncidenceFormatter::instance(); 216 delete KIncidenceFormatter::instance();
217 217
218 218
219} 219}
220void MainWindow::showMaximized () 220void MainWindow::showMaximized ()
221{ 221{
222#ifndef DESKTOP_VERSION 222#ifndef DESKTOP_VERSION
223 if ( ! globalFlagBlockStartup ) 223 if ( ! globalFlagBlockStartup )
224 mView->goToday(); 224 mView->goToday();
225#endif 225#endif
226 QWidget::showMaximized () ; 226 QWidget::showMaximized () ;
227} 227}
228void MainWindow::closeEvent( QCloseEvent* ce ) 228void MainWindow::closeEvent( QCloseEvent* ce )
229{ 229{
230 230
231 231
232 232
233 if ( ! KOPrefs::instance()->mAskForQuit ) { 233 if ( ! KOPrefs::instance()->mAskForQuit ) {
234 saveOnClose(); 234 saveOnClose();
235 ce->accept(); 235 ce->accept();
236 return; 236 return;
237 237
238 } 238 }
239 239
240 switch( QMessageBox::information( this, "KO/Pi", 240 switch( QMessageBox::information( this, "KO/Pi",
241 i18n("Do you really want\nto close KO/Pi?"), 241 i18n("Do you really want\nto close KO/Pi?"),
242 i18n("Close"), i18n("No"), 242 i18n("Close"), i18n("No"),
243 0, 0 ) ) { 243 0, 0 ) ) {
244 case 0: 244 case 0:
245 saveOnClose(); 245 saveOnClose();
246 ce->accept(); 246 ce->accept();
247 break; 247 break;
248 case 1: 248 case 1:
249 ce->ignore(); 249 ce->ignore();
250 break; 250 break;
251 case 2: 251 case 2:
252 252
253 default: 253 default:
254 break; 254 break;
255 } 255 }
256 256
257 257
258} 258}
259 259
260void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) 260void MainWindow::recieve( const QCString& cmsg, const QByteArray& data )
261{ 261{
262 QDataStream stream( data, IO_ReadOnly ); 262 QDataStream stream( data, IO_ReadOnly );
263 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); 263 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" );
264 //QString datamess; 264 //QString datamess;
265 //qDebug("message "); 265 //qDebug("message ");
266 qDebug("KO: QCOP message received: %s ", cmsg.data() ); 266 qDebug("KO: QCOP message received: %s ", cmsg.data() );
267 267
268 if ( cmsg == "-writeFile" ) { 268 if ( cmsg == "-writeFile" ) {
269 // I made from the "-writeFile" an "-writeAlarm" 269 // I made from the "-writeFile" an "-writeAlarm"
270 mView->viewManager()->showWhatsNextView(); 270 mView->viewManager()->showWhatsNextView();
271 mCalendar->checkAlarmForIncidence( 0, true); 271 mCalendar->checkAlarmForIncidence( 0, true);
272 showMaximized(); 272 showMaximized();
273 raise(); 273 raise();
274 return; 274 return;
275 } 275 }
276 276
277 if ( cmsg == "-writeFile" ) { 277 if ( cmsg == "-writeFile" ) {
278 // I made from the "-writeFile" an "-writeAlarm" 278 // I made from the "-writeFile" an "-writeAlarm"
279 mView->viewManager()->showWhatsNextView(); 279 mView->viewManager()->showWhatsNextView();
280 mCalendar->checkAlarmForIncidence( 0, true); 280 mCalendar->checkAlarmForIncidence( 0, true);
281 showMaximized(); 281 showMaximized();
282 raise(); 282 raise();
283 return; 283 return;
284 284
285 } 285 }
286 if ( cmsg == "-writeFileSilent" ) { 286 if ( cmsg == "-writeFileSilent" ) {
287 // I made from the "-writeFile" an "-writeAlarm" 287 // I made from the "-writeFile" an "-writeAlarm"
288 // mView->viewManager()->showWhatsNextView(); 288 // mView->viewManager()->showWhatsNextView();
289 mCalendar->checkAlarmForIncidence( 0, true); 289 mCalendar->checkAlarmForIncidence( 0, true);
290 //showMaximized(); 290 //showMaximized();
291 //raise(); 291 //raise();
292 hide(); 292 hide();
293 return; 293 return;
294 } 294 }
295 if ( cmsg == "-newCountdown" ) { 295 if ( cmsg == "-newCountdown" ) {
296 qDebug("newCountdown "); 296 qDebug("newCountdown ");
297 297
298 } 298 }
299 QString msg ; 299 QString msg ;
300 QString allmsg = cmsg; 300 QString allmsg = cmsg;
301 while ( allmsg.length() > 0 ) { 301 while ( allmsg.length() > 0 ) {
302 int nextC = allmsg.find( "-", 1 ); 302 int nextC = allmsg.find( "-", 1 );
303 if ( nextC == -1 ) { 303 if ( nextC == -1 ) {
304 msg = allmsg; 304 msg = allmsg;
305 allmsg = ""; 305 allmsg = "";
306 } else{ 306 } else{
307 msg = allmsg.left( nextC ); 307 msg = allmsg.left( nextC );
308 allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); 308 allmsg = allmsg.mid( nextC, allmsg.length()-nextC );
309 } 309 }
310 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); 310 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() );
311 if ( msg == "-newEvent" ) { 311 if ( msg == "-newEvent" ) {
312 mView->newEvent(); 312 mView->newEvent();
313 } 313 }
314 if ( msg == "-newTodo" ) { 314 if ( msg == "-newTodo" ) {
315 mView->newTodo(); 315 mView->newTodo();
316 316
317 } 317 }
318 if ( msg == "-showWN" ) { 318 if ( msg == "-showWN" ) {
319 mView->viewManager()->showWhatsNextView(); 319 mView->viewManager()->showWhatsNextView();
320 } 320 }
321 if ( msg == "-showTodo" ) { 321 if ( msg == "-showTodo" ) {
322 mView->viewManager()->showTodoView(); 322 mView->viewManager()->showTodoView();
323 } 323 }
324 if ( msg == "-showList" ) { 324 if ( msg == "-showList" ) {
325 mView->viewManager()->showListView(); 325 mView->viewManager()->showListView();
326 } 326 }
327 else if ( msg == "-showDay" ) { 327 else if ( msg == "-showDay" ) {
328 mView->viewManager()->showDayView(); 328 mView->viewManager()->showDayView();
329 } 329 }
330 else if ( msg == "-showWWeek" ) { 330 else if ( msg == "-showWWeek" ) {
331 mView->viewManager()->showWorkWeekView(); 331 mView->viewManager()->showWorkWeekView();
332 } 332 }
333 else if ( msg == "-ringSync" ) { 333 else if ( msg == "-ringSync" ) {
334 multiSync( false ); 334 multiSync( false );
335 } 335 }
336 else if ( msg == "-showWeek" ) { 336 else if ( msg == "-showWeek" ) {
337 mView->viewManager()->showWeekView(); 337 mView->viewManager()->showWeekView();
338 } 338 }
339 else if ( msg == "-showTodo" ) { 339 else if ( msg == "-showTodo" ) {
340 mView->viewManager()->showTodoView(); 340 mView->viewManager()->showTodoView();
341 } 341 }
342 else if ( msg == "-showJournal" ) { 342 else if ( msg == "-showJournal" ) {
343 mView->dateNavigator()->selectDates( 1 ); 343 mView->dateNavigator()->selectDates( 1 );
344 mView->dateNavigator()->selectToday(); 344 mView->dateNavigator()->selectToday();
345 mView->viewManager()->showJournalView(); 345 mView->viewManager()->showJournalView();
346 } 346 }
347 else if ( msg == "-showKO" ) { 347 else if ( msg == "-showKO" ) {
348 mView->viewManager()->showNextXView(); 348 mView->viewManager()->showNextXView();
349 } 349 }
350 else if ( msg == "-showWNext" || msg == "nextView()" ) { 350 else if ( msg == "-showWNext" || msg == "nextView()" ) {
351 mView->viewManager()->showWhatsNextView(); 351 mView->viewManager()->showWhatsNextView();
352 } 352 }
353 else if ( msg == "-showNextXView" ) { 353 else if ( msg == "-showNextXView" ) {
354 mView->viewManager()->showNextXView(); 354 mView->viewManager()->showNextXView();
355 } 355 }
356 356
357 357
358 } 358 }
359 359
360 showMaximized(); 360 showMaximized();
361 raise(); 361 raise();
362} 362}
363 363
364QPixmap MainWindow::loadPixmap( QString name ) 364QPixmap MainWindow::loadPixmap( QString name )
365{ 365{
366 return SmallIcon( name ); 366 return SmallIcon( name );
367 367
368} 368}
369void MainWindow::initActions() 369void MainWindow::initActions()
370{ 370{
371 //KOPrefs::instance()->mShowFullMenu 371 //KOPrefs::instance()->mShowFullMenu
372 iconToolBar->clear(); 372 iconToolBar->clear();
373 KOPrefs *p = KOPrefs::instance(); 373 KOPrefs *p = KOPrefs::instance();
374 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); 374 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar );
375 375
376 QPopupMenu *viewMenu = new QPopupMenu( this ); 376 QPopupMenu *viewMenu = new QPopupMenu( this );
377 QPopupMenu *actionMenu = new QPopupMenu( this ); 377 QPopupMenu *actionMenu = new QPopupMenu( this );
378 QPopupMenu *importMenu = new QPopupMenu( this ); 378 QPopupMenu *importMenu = new QPopupMenu( this );
379 selectFilterMenu = new QPopupMenu( this ); 379 selectFilterMenu = new QPopupMenu( this );
380 selectFilterMenu->setCheckable( true ); 380 selectFilterMenu->setCheckable( true );
381 syncMenu = new QPopupMenu( this ); 381 syncMenu = new QPopupMenu( this );
382 configureAgendaMenu = new QPopupMenu( this ); 382 configureAgendaMenu = new QPopupMenu( this );
383 configureToolBarMenu = new QPopupMenu( this ); 383 configureToolBarMenu = new QPopupMenu( this );
384 QPopupMenu *helpMenu = new QPopupMenu( this ); 384 QPopupMenu *helpMenu = new QPopupMenu( this );
385 if ( KOPrefs::instance()->mShowFullMenu ) { 385 if ( KOPrefs::instance()->mShowFullMenu ) {
386 QMenuBar *menuBar1; 386 QMenuBar *menuBar1;
387 menuBar1 = menuBar(); 387 menuBar1 = menuBar();
388 menuBar1->insertItem( i18n("File"), importMenu ); 388 menuBar1->insertItem( i18n("File"), importMenu );
389 menuBar1->insertItem( i18n("View"), viewMenu ); 389 menuBar1->insertItem( i18n("View"), viewMenu );
390 menuBar1->insertItem( i18n("Actions"), actionMenu ); 390 menuBar1->insertItem( i18n("Actions"), actionMenu );
391 menuBar1->insertItem( i18n("Synchronize"), syncMenu ); 391 menuBar1->insertItem( i18n("Synchronize"), syncMenu );
392 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 392 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu );
393 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); 393 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu );
394 menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); 394 menuBar1->insertItem( i18n("Filter"),selectFilterMenu );
395 menuBar1->insertItem( i18n("Help"), helpMenu ); 395 menuBar1->insertItem( i18n("Help"), helpMenu );
396 } else { 396 } else {
397 QPEMenuBar *menuBar1; 397 QPEMenuBar *menuBar1;
398 menuBar1 = new QPEMenuBar( iconToolBar ); 398 menuBar1 = new QPEMenuBar( iconToolBar );
399 QPopupMenu *menuBar = new QPopupMenu( this ); 399 QPopupMenu *menuBar = new QPopupMenu( this );
400 menuBar1->insertItem( i18n("ME"), menuBar); 400 menuBar1->insertItem( i18n("ME"), menuBar);
401 menuBar->insertItem( i18n("File"), importMenu ); 401 menuBar->insertItem( i18n("File"), importMenu );
402 menuBar->insertItem( i18n("View"), viewMenu ); 402 menuBar->insertItem( i18n("View"), viewMenu );
403 menuBar->insertItem( i18n("Actions"), actionMenu ); 403 menuBar->insertItem( i18n("Actions"), actionMenu );
404 menuBar->insertItem( i18n("Synchronize"), syncMenu ); 404 menuBar->insertItem( i18n("Synchronize"), syncMenu );
405 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 405 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu );
406 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); 406 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu );
407 menuBar->insertItem( i18n("Filter"),selectFilterMenu ); 407 menuBar->insertItem( i18n("Filter"),selectFilterMenu );
408 menuBar->insertItem( i18n("Help"), helpMenu ); 408 menuBar->insertItem( i18n("Help"), helpMenu );
409 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); 409 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() );
410 menuBar1->setMaximumSize( menuBar1->sizeHint( )); 410 menuBar1->setMaximumSize( menuBar1->sizeHint( ));
411 } 411 }
412 connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) ); 412 connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) );
413 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); 413 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
414 connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) ); 414 connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) );
415 415
416 // ****************** 416 // ******************
417 QAction *action; 417 QAction *action;
418 QIconSet icon; 418 QIconSet icon;
419 // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); 419 // QPopupMenu *configureMenu= new QPopupMenu( menuBar );
420 configureToolBarMenu->setCheckable( true ); 420 configureToolBarMenu->setCheckable( true );
421 421
422 QString pathString = ""; 422 QString pathString = "";
423 if ( !p->mToolBarMiniIcons ) { 423 if ( !p->mToolBarMiniIcons ) {
424 if ( QApplication::desktop()->width() < 480 ) 424 if ( QApplication::desktop()->width() < 480 )
425 pathString += "icons16/"; 425 pathString += "icons16/";
426 } else 426 } else
427 pathString += "iconsmini/"; 427 pathString += "iconsmini/";
428 configureAgendaMenu->setCheckable( true ); 428 configureAgendaMenu->setCheckable( true );
429 configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 ); 429 configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 );
430 configureAgendaMenu->insertSeparator(); 430 configureAgendaMenu->insertSeparator();
431 configureAgendaMenu->insertItem(i18n("Tiny"), 4 ); 431 configureAgendaMenu->insertItem(i18n("Tiny"), 4 );
432 configureAgendaMenu->insertItem(i18n("Small"), 6 ); 432 configureAgendaMenu->insertItem(i18n("Small"), 6 );
433 configureAgendaMenu->insertItem(i18n("Medium"), 8 ); 433 configureAgendaMenu->insertItem(i18n("Medium"), 8 );
434 configureAgendaMenu->insertItem(i18n("Normal"), 10 ); 434 configureAgendaMenu->insertItem(i18n("Normal"), 10 );
435 configureAgendaMenu->insertItem(i18n("Large"), 12 ); 435 configureAgendaMenu->insertItem(i18n("Large"), 12 );
436 configureAgendaMenu->insertItem(i18n("Big"), 14 ); 436 configureAgendaMenu->insertItem(i18n("Big"), 14 );
437 configureAgendaMenu->insertItem(i18n("Bigger"), 16 ); 437 configureAgendaMenu->insertItem(i18n("Bigger"), 16 );
438 configureAgendaMenu->insertItem(i18n("Biggest"), 18 ); 438 configureAgendaMenu->insertItem(i18n("Biggest"), 18 );
439 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); 439 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu );
440 440
441 icon = loadPixmap( pathString + "configure" ); 441 icon = loadPixmap( pathString + "configure" );
442 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); 442 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this );
443 action->addTo( actionMenu ); 443 action->addTo( actionMenu );
444 connect( action, SIGNAL( activated() ), 444 connect( action, SIGNAL( activated() ),
445 mView, SLOT( edit_options() ) ); 445 mView, SLOT( edit_options() ) );
446 actionMenu->insertSeparator(); 446 actionMenu->insertSeparator();
447 icon = loadPixmap( pathString + "newevent" ); 447 icon = loadPixmap( pathString + "newevent" );
448 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); 448 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 );
449 configureToolBarMenu->insertSeparator(); 449 configureToolBarMenu->insertSeparator();
450 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); 450 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 );
451 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); 451 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this );
452 ne_action->addTo( actionMenu ); 452 ne_action->addTo( actionMenu );
453 connect( ne_action, SIGNAL( activated() ), 453 connect( ne_action, SIGNAL( activated() ),
454 mView, SLOT( newEvent() ) ); 454 mView, SLOT( newEvent() ) );
455 icon = loadPixmap( pathString + "newtodo" ); 455 icon = loadPixmap( pathString + "newtodo" );
456 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); 456 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 );
457 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); 457 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this );
458 nt_action->addTo( actionMenu ); 458 nt_action->addTo( actionMenu );
459 connect( nt_action, SIGNAL( activated() ), 459 connect( nt_action, SIGNAL( activated() ),
460 mView, SLOT( newTodo() ) ); 460 mView, SLOT( newTodo() ) );
461 icon = loadPixmap( pathString + "navi" ); 461 icon = loadPixmap( pathString + "navi" );
462 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); 462 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this );
463 action->addTo( viewMenu ); 463 action->addTo( viewMenu );
464 connect( action, SIGNAL( activated() ), 464 connect( action, SIGNAL( activated() ),
465 mView, SLOT( toggleDateNavigatorWidget() ) ); 465 mView, SLOT( toggleDateNavigatorWidget() ) );
466 icon = loadPixmap( pathString + "filter" ); 466 icon = loadPixmap( pathString + "filter" );
467 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); 467 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this );
468 action->addTo( viewMenu ); 468 action->addTo( viewMenu );
469 connect( action, SIGNAL( activated() ), 469 connect( action, SIGNAL( activated() ),
470 mView, SLOT( toggleFilter() ) ); 470 mView, SLOT( toggleFilter() ) );
471 471
472 472
473 viewMenu->insertSeparator(); 473 viewMenu->insertSeparator();
474 icon = loadPixmap( pathString + "picker" ); 474 icon = loadPixmap( pathString + "picker" );
475 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); 475 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this );
476 action->addTo( viewMenu ); 476 action->addTo( viewMenu );
477 connect( action, SIGNAL( activated() ), 477 connect( action, SIGNAL( activated() ),
478 mView, SLOT( showDatePicker() ) ); 478 mView, SLOT( showDatePicker() ) );
479 action->addTo( iconToolBar ); 479 action->addTo( iconToolBar );
480 viewMenu->insertSeparator(); 480 viewMenu->insertSeparator();
481 icon = loadPixmap( pathString + "list" ); 481 icon = loadPixmap( pathString + "list" );
482 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); 482 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 );
483 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); 483 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this );
484 showlist_action->addTo( viewMenu ); 484 showlist_action->addTo( viewMenu );
485 connect( showlist_action, SIGNAL( activated() ), 485 connect( showlist_action, SIGNAL( activated() ),
486 mView->viewManager(), SLOT( showListView() ) ); 486 mView->viewManager(), SLOT( showListView() ) );
487 487
488 488
489 icon = loadPixmap( pathString + "day" ); 489 icon = loadPixmap( pathString + "day" );
490 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); 490 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 );
491 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); 491 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this );
492 day1_action->addTo( viewMenu ); 492 day1_action->addTo( viewMenu );
493 // action->addTo( toolBar ); 493 // action->addTo( toolBar );
494 connect( day1_action, SIGNAL( activated() ), 494 connect( day1_action, SIGNAL( activated() ),
495 mView->viewManager(), SLOT( showDayView() ) ); 495 mView->viewManager(), SLOT( showDayView() ) );
496 496
497 icon = loadPixmap( pathString + "workweek" ); 497 icon = loadPixmap( pathString + "workweek" );
498 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); 498 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 );
499 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); 499 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this );
500 day5_action->addTo( viewMenu ); 500 day5_action->addTo( viewMenu );
501 connect( day5_action, SIGNAL( activated() ), 501 connect( day5_action, SIGNAL( activated() ),
502 mView->viewManager(), SLOT( showWorkWeekView() ) ); 502 mView->viewManager(), SLOT( showWorkWeekView() ) );
503 503
504 icon = loadPixmap( pathString + "week" ); 504 icon = loadPixmap( pathString + "week" );
505 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); 505 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 );
506 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); 506 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this );
507 day7_action->addTo( viewMenu ); 507 day7_action->addTo( viewMenu );
508 connect( day7_action, SIGNAL( activated() ), 508 connect( day7_action, SIGNAL( activated() ),
509 mView->viewManager(), SLOT( showWeekView() ) ); 509 mView->viewManager(), SLOT( showWeekView() ) );
510 510
511 icon = loadPixmap( pathString + "month" ); 511 icon = loadPixmap( pathString + "month" );
512 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); 512 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 );
513 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); 513 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this );
514 month_action->addTo( viewMenu ); 514 month_action->addTo( viewMenu );
515 connect( month_action, SIGNAL( activated() ), 515 connect( month_action, SIGNAL( activated() ),
516 mView->viewManager(), SLOT( showMonthView() ) ); 516 mView->viewManager(), SLOT( showMonthView() ) );
517 517
518 icon = loadPixmap( pathString + "todo" ); 518 icon = loadPixmap( pathString + "todo" );
519 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); 519 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 );
520 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); 520 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this );
521 todoview_action->addTo( viewMenu ); 521 todoview_action->addTo( viewMenu );
522 connect( todoview_action, SIGNAL( activated() ), 522 connect( todoview_action, SIGNAL( activated() ),
523 mView->viewManager(), SLOT( showTodoView() ) ); 523 mView->viewManager(), SLOT( showTodoView() ) );
524 524
525 icon = loadPixmap( pathString + "journal" ); 525 icon = loadPixmap( pathString + "journal" );
526 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); 526 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 );
527 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); 527 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this );
528 viewjournal_action->addTo( viewMenu ); 528 viewjournal_action->addTo( viewMenu );
529 connect( viewjournal_action, SIGNAL( activated() ), 529 connect( viewjournal_action, SIGNAL( activated() ),
530 mView->viewManager(), SLOT( showJournalView() ) ); 530 mView->viewManager(), SLOT( showJournalView() ) );
531 531
532 icon = loadPixmap( pathString + "xdays" ); 532 icon = loadPixmap( pathString + "xdays" );
533 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 ); 533 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 );
534 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); 534 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this );
535 xdays_action->addTo( viewMenu ); 535 xdays_action->addTo( viewMenu );
536 connect( xdays_action, SIGNAL( activated() ), 536 connect( xdays_action, SIGNAL( activated() ),
537 mView->viewManager(), SLOT( showNextXView() ) ); 537 mView->viewManager(), SLOT( showNextXView() ) );
538 538
539 icon = loadPixmap( pathString + "whatsnext" ); 539 icon = loadPixmap( pathString + "whatsnext" );
540 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 ); 540 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 );
541 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); 541 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this );
542 whatsnext_action->addTo( viewMenu ); 542 whatsnext_action->addTo( viewMenu );
543 connect( whatsnext_action, SIGNAL( activated() ), 543 connect( whatsnext_action, SIGNAL( activated() ),
544 mView->viewManager(), SLOT( showWhatsNextView() ) ); 544 mView->viewManager(), SLOT( showWhatsNextView() ) );
545 545
546#if 0 546#if 0
547 action = new QAction( "view_timespan", "Time Span", 0, this ); 547 action = new QAction( "view_timespan", "Time Span", 0, this );
548 action->addTo( viewMenu ); 548 action->addTo( viewMenu );
549 connect( action, SIGNAL( activated() ), 549 connect( action, SIGNAL( activated() ),
550 mView->viewManager(), SLOT( showTimeSpanView() ) ); 550 mView->viewManager(), SLOT( showTimeSpanView() ) );
551#endif 551#endif
552 552
553 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, 553 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0,
554 this ); 554 this );
555 mNewSubTodoAction->addTo( actionMenu ); 555 mNewSubTodoAction->addTo( actionMenu );
556 connect( mNewSubTodoAction, SIGNAL( activated() ), 556 connect( mNewSubTodoAction, SIGNAL( activated() ),
557 mView, SLOT( newSubTodo() ) ); 557 mView, SLOT( newSubTodo() ) );
558 558
559 actionMenu->insertSeparator(); 559 actionMenu->insertSeparator();
560 560
561 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); 561 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this );
562 mShowAction->addTo( actionMenu ); 562 mShowAction->addTo( actionMenu );
563 connect( mShowAction, SIGNAL( activated() ), 563 connect( mShowAction, SIGNAL( activated() ),
564 mView, SLOT( showIncidence() ) ); 564 mView, SLOT( showIncidence() ) );
565 565
566 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); 566 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this );
567 mEditAction->addTo( actionMenu ); 567 mEditAction->addTo( actionMenu );
568 connect( mEditAction, SIGNAL( activated() ), 568 connect( mEditAction, SIGNAL( activated() ),
569 mView, SLOT( editIncidence() ) ); 569 mView, SLOT( editIncidence() ) );
570 570
571 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); 571 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this );
572 mDeleteAction->addTo( actionMenu ); 572 mDeleteAction->addTo( actionMenu );
573 connect( mDeleteAction, SIGNAL( activated() ), 573 connect( mDeleteAction, SIGNAL( activated() ),
574 mView, SLOT( deleteIncidence() ) ); 574 mView, SLOT( deleteIncidence() ) );
575 575
576 actionMenu->insertSeparator(); 576 actionMenu->insertSeparator();
577 577
578 action = new QAction( "purge_completed", i18n("Purge Completed"), 0, 578 action = new QAction( "purge_completed", i18n("Purge Completed"), 0,
579 this ); 579 this );
580 action->addTo( actionMenu ); 580 action->addTo( actionMenu );
581 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); 581 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) );
582 582
583 icon = loadPixmap( pathString + "search" ); 583 icon = loadPixmap( pathString + "search" );
584 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); 584 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this );
585 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4); 585 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4);
586 search_action->addTo( actionMenu ); 586 search_action->addTo( actionMenu );
587 connect( search_action, SIGNAL( activated() ), 587 connect( search_action, SIGNAL( activated() ),
588 mView->dialogManager(), SLOT( showSearchDialog() ) ); 588 mView->dialogManager(), SLOT( showSearchDialog() ) );
589 589
590 icon = loadPixmap( pathString + "today" ); 590 icon = loadPixmap( pathString + "today" );
591 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); 591 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130);
592 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); 592 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this );
593 today_action->addTo( actionMenu ); 593 today_action->addTo( actionMenu );
594 connect( today_action, SIGNAL( activated() ), 594 connect( today_action, SIGNAL( activated() ),
595 mView, SLOT( goToday() ) ); 595 mView, SLOT( goToday() ) );
596 596
597 if ( KOPrefs::instance()->mShowFullMenu ) { 597 if ( KOPrefs::instance()->mShowFullMenu ) {
598 actionMenu->insertSeparator(); 598 actionMenu->insertSeparator();
599 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); 599 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu );
600 600
601 } 601 }
602 // actionMenu->insertSeparator(); 602 // actionMenu->insertSeparator();
603 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, 603 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0,
604 this ); 604 this );
605 action->addTo( importMenu ); 605 action->addTo( importMenu );
606 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); 606 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) );
607 action = new QAction( "import_quick", i18n("Import last file"), 0, 607 action = new QAction( "import_quick", i18n("Import last file"), 0,
608 this ); 608 this );
609 action->addTo( importMenu ); 609 action->addTo( importMenu );
610 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); 610 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) );
611 importMenu->insertSeparator(); 611 importMenu->insertSeparator();
612 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, 612 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0,
613 this ); 613 this );
614 action->addTo( importMenu ); 614 action->addTo( importMenu );
615 connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); 615 connect( action, SIGNAL( activated() ), SLOT( importBday() ) );
616#ifndef DESKTOP_VERSION 616#ifndef DESKTOP_VERSION
617 importMenu->insertSeparator(); 617 importMenu->insertSeparator();
618 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, 618 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0,
619 this ); 619 this );
620 action->addTo( importMenu ); 620 action->addTo( importMenu );
621 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); 621 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) );
622#else 622#else
623#ifdef _WIN32_ 623#ifdef _WIN32_
624 importMenu->insertSeparator(); 624 importMenu->insertSeparator();
625 action = new QAction( "import_ol", i18n("Import from OL"), 0, 625 action = new QAction( "import_ol", i18n("Import from OL"), 0,
626 this ); 626 this );
627 action->addTo( importMenu ); 627 action->addTo( importMenu );
628 connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); 628 connect( action, SIGNAL( activated() ), SLOT( importOL() ) );
629#endif 629#endif
630#endif 630#endif
631 631
632 importMenu->insertSeparator(); 632 importMenu->insertSeparator();
633 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, 633 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0,
634 this ); 634 this );
635 action->addTo( importMenu ); 635 action->addTo( importMenu );
636 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); 636 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) );
637 637
638 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, 638 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0,
639 this ); 639 this );
640 action->addTo( importMenu ); 640 action->addTo( importMenu );
641 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); 641 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) );
642 642
643 importMenu->insertSeparator(); 643 importMenu->insertSeparator();
644 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, 644 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0,
645 this ); 645 this );
646 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); 646 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) );
647 importMenu->insertSeparator(); 647 importMenu->insertSeparator();
648 action = new QAction( "manage cat", i18n("Manage new categories..."), 0, 648 action = new QAction( "manage cat", i18n("Manage new categories..."), 0,
649 this ); 649 this );
650 action->addTo( importMenu ); 650 action->addTo( importMenu );
651 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); 651 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) );
652#ifndef DESKTOP_VERSION 652#ifndef DESKTOP_VERSION
653 importMenu->insertSeparator(); 653 importMenu->insertSeparator();
654 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, 654 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0,
655 this ); 655 this );
656 action->addTo( importMenu ); 656 action->addTo( importMenu );
657 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); 657 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) );
658 658
659 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, 659 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0,
660 this ); 660 this );
661 action->addTo( importMenu ); 661 action->addTo( importMenu );
662 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); 662 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) );
663#else 663#else
664 importMenu->insertSeparator(); 664 importMenu->insertSeparator();
665 icon = loadPixmap( pathString + "print" ); 665 icon = loadPixmap( pathString + "print" );
666 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); 666 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this );
667 action->addTo( importMenu ); 667 action->addTo( importMenu );
668 connect( action, SIGNAL( activated() ), 668 connect( action, SIGNAL( activated() ),
669 this, SLOT( printCal() ) ); 669 this, SLOT( printCal() ) );
670 670
671 icon = loadPixmap( pathString + "print" ); 671 icon = loadPixmap( pathString + "print" );
672 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); 672 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this );
673 action->addTo( importMenu ); 673 action->addTo( importMenu );
674 connect( action, SIGNAL( activated() ), 674 connect( action, SIGNAL( activated() ),
675 this, SLOT( printSel() ) ); 675 this, SLOT( printSel() ) );
676#endif 676#endif
677 importMenu->insertSeparator(); 677 importMenu->insertSeparator();
678 action = new QAction( "beam all", i18n("Save"), 0, 678 action = new QAction( "beam all", i18n("Save"), 0,
679 this ); 679 this );
680 action->addTo( importMenu ); 680 action->addTo( importMenu );
681 connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); 681 connect( action, SIGNAL( activated() ), this, SLOT( save() ) );
682 action = new QAction( "beam all", i18n("Exit (+save)"), 0, 682 action = new QAction( "beam all", i18n("Exit (+save)"), 0,
683 this ); 683 this );
684 action->addTo( importMenu ); 684 action->addTo( importMenu );
685 connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); 685 connect( action, SIGNAL( activated() ), this, SLOT( close() ) );
686 686
687 //menuBar->insertItem( "Configure",configureMenu ); 687 //menuBar->insertItem( "Configure",configureMenu );
688 //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); 688 //configureMenu->insertItem( "Toolbar",configureToolBarMenu );
689 icon = loadPixmap( "korganizer/korganizer" ); 689 icon = loadPixmap( "korganizer/korganizer" );
690 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); 690 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this );
691 action->addTo( helpMenu ); 691 action->addTo( helpMenu );
692 connect( action, SIGNAL( activated() ), 692 connect( action, SIGNAL( activated() ),
693 SLOT( keyBindings() ) ); 693 SLOT( keyBindings() ) );
694 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); 694 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this );
695 action->addTo( helpMenu ); 695 action->addTo( helpMenu );
696 connect( action, SIGNAL( activated() ), 696 connect( action, SIGNAL( activated() ),
697 SLOT( features() ) ); 697 SLOT( features() ) );
698 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); 698 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this );
699 action->addTo( helpMenu ); 699 action->addTo( helpMenu );
700 connect( action, SIGNAL( activated() ), 700 connect( action, SIGNAL( activated() ),
701 SLOT( aboutAutoSaving() ) ); 701 SLOT( aboutAutoSaving() ) );
702 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); 702 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this );
703 action->addTo( helpMenu ); 703 action->addTo( helpMenu );
704 connect( action, SIGNAL( activated() ), 704 connect( action, SIGNAL( activated() ),
705 SLOT( aboutKnownBugs() ) ); 705 SLOT( aboutKnownBugs() ) );
706 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); 706 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this );
707 action->addTo( helpMenu ); 707 action->addTo( helpMenu );
708 connect( action, SIGNAL( activated() ), 708 connect( action, SIGNAL( activated() ),
709 SLOT( usertrans() ) ); 709 SLOT( usertrans() ) );
710 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); 710 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this );
711 action->addTo( helpMenu ); 711 action->addTo( helpMenu );
712 connect( action, SIGNAL( activated() ), 712 connect( action, SIGNAL( activated() ),
713 SLOT( synchowto() ) ); 713 SLOT( synchowto() ) );
714 action = new QAction( "Whats New", i18n("What's new?"), 0,this ); 714 action = new QAction( "Whats New", i18n("What's new?"), 0,this );
715 action->addTo( helpMenu ); 715 action->addTo( helpMenu );
716 connect( action, SIGNAL( activated() ), 716 connect( action, SIGNAL( activated() ),
717 SLOT( whatsNew() ) ); 717 SLOT( whatsNew() ) );
718 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); 718 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this );
719 action->addTo( helpMenu ); 719 action->addTo( helpMenu );
720 connect( action, SIGNAL( activated() ), 720 connect( action, SIGNAL( activated() ),
721 SLOT( faq() ) ); 721 SLOT( faq() ) );
722 722
723 723
724 action = new QAction( "about", i18n("About..."), 0, this ); 724 action = new QAction( "about", i18n("About..."), 0, this );
725 action->addTo( helpMenu ); 725 action->addTo( helpMenu );
726 connect( action, SIGNAL( activated() ), 726 connect( action, SIGNAL( activated() ),
727 SLOT( about() ) ); 727 SLOT( about() ) );
728 action = new QAction( "licence", i18n("Licence..."), 0, this ); 728 action = new QAction( "licence", i18n("Licence..."), 0, this );
729 action->addTo( helpMenu ); 729 action->addTo( helpMenu );
730 connect( action, SIGNAL( activated() ), 730 connect( action, SIGNAL( activated() ),
731 SLOT( licence() ) ); 731 SLOT( licence() ) );
732 //menuBar->insertSeparator(); 732 //menuBar->insertSeparator();
733 733
734 // ****************************************************** 734 // ******************************************************
735 // menubar icons 735 // menubar icons
736 736
737 737
738 iconToolBar->setHorizontalStretchable (true ); 738 iconToolBar->setHorizontalStretchable (true );
739 //menuBar->insertItem( iconToolBar ); 739 //menuBar->insertItem( iconToolBar );
740 //xdays_action 740 //xdays_action
741 if (p-> mShowIconNewEvent) 741 if (p-> mShowIconNewEvent)
742 ne_action->addTo( iconToolBar ); 742 ne_action->addTo( iconToolBar );
743 if (p->mShowIconNewTodo ) 743 if (p->mShowIconNewTodo )
744 nt_action->addTo( iconToolBar ); 744 nt_action->addTo( iconToolBar );
745 if (p-> mShowIconSearch) 745 if (p-> mShowIconSearch)
746 search_action->addTo( iconToolBar ); 746 search_action->addTo( iconToolBar );
747 if (p-> mShowIconNext) 747 if (p-> mShowIconNext)
748 whatsnext_action->addTo( iconToolBar ); 748 whatsnext_action->addTo( iconToolBar );
749 if (p-> mShowIconNextDays) 749 if (p-> mShowIconNextDays)
750 xdays_action->addTo( iconToolBar ); 750 xdays_action->addTo( iconToolBar );
751 if (p-> mShowIconList) 751 if (p-> mShowIconList)
752 showlist_action->addTo( iconToolBar ); 752 showlist_action->addTo( iconToolBar );
753 if (p-> mShowIconDay1) 753 if (p-> mShowIconDay1)
754 day1_action->addTo( iconToolBar ); 754 day1_action->addTo( iconToolBar );
755 if (p-> mShowIconDay5) 755 if (p-> mShowIconDay5)
756 day5_action->addTo( iconToolBar ); 756 day5_action->addTo( iconToolBar );
757 if (p-> mShowIconDay7) 757 if (p-> mShowIconDay7)
758 day7_action->addTo( iconToolBar ); 758 day7_action->addTo( iconToolBar );
759 if (p-> mShowIconMonth) 759 if (p-> mShowIconMonth)
760 month_action->addTo( iconToolBar ); 760 month_action->addTo( iconToolBar );
761 if (p-> mShowIconTodoview) 761 if (p-> mShowIconTodoview)
762 todoview_action->addTo( iconToolBar ); 762 todoview_action->addTo( iconToolBar );
763 if (p-> mShowIconJournal) 763 if (p-> mShowIconJournal)
764 viewjournal_action->addTo( iconToolBar ); 764 viewjournal_action->addTo( iconToolBar );
765 icon = loadPixmap( pathString + "2leftarrowB" ); 765 icon = loadPixmap( pathString + "2leftarrowB" );
766 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); 766 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14);
767 if (p-> mShowIconBackFast) { 767 if (p-> mShowIconBackFast) {
768 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); 768 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this );
769 connect( action, SIGNAL( activated() ), 769 connect( action, SIGNAL( activated() ),
770 mView, SLOT( goPreviousMonth() ) ); 770 mView, SLOT( goPreviousMonth() ) );
771 action->addTo( iconToolBar ); 771 action->addTo( iconToolBar );
772 } 772 }
773 icon = loadPixmap( pathString + "1leftarrowB" ); 773 icon = loadPixmap( pathString + "1leftarrowB" );
774 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); 774 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15);
775 if (p-> mShowIconBack) { 775 if (p-> mShowIconBack) {
776 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); 776 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this );
777 connect( action, SIGNAL( activated() ), 777 connect( action, SIGNAL( activated() ),
778 mView, SLOT( goPrevious() ) ); 778 mView, SLOT( goPrevious() ) );
779 action->addTo( iconToolBar ); 779 action->addTo( iconToolBar );
780 } 780 }
781 if (p-> mShowIconToday) 781 if (p-> mShowIconToday)
782 today_action->addTo( iconToolBar ); 782 today_action->addTo( iconToolBar );
783 icon = loadPixmap( pathString + "1rightarrowB" ); 783 icon = loadPixmap( pathString + "1rightarrowB" );
784 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); 784 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220);
785 if (p-> mShowIconForward) { 785 if (p-> mShowIconForward) {
786 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); 786 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this );
787 connect( action, SIGNAL( activated() ), 787 connect( action, SIGNAL( activated() ),
788 mView, SLOT( goNext() ) ); 788 mView, SLOT( goNext() ) );
789 action->addTo( iconToolBar ); 789 action->addTo( iconToolBar );
790 } 790 }
791 icon = loadPixmap( pathString + "2rightarrowB" ); 791 icon = loadPixmap( pathString + "2rightarrowB" );
792 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); 792 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230);
793 if (p-> mShowIconForwardFast) { 793 if (p-> mShowIconForwardFast) {
794 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); 794 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this );
795 connect( action, SIGNAL( activated() ), 795 connect( action, SIGNAL( activated() ),
796 mView, SLOT( goNextMonth() ) ); 796 mView, SLOT( goNextMonth() ) );
797 action->addTo( iconToolBar ); 797 action->addTo( iconToolBar );
798 } 798 }
799 799
800 800
801 configureToolBarMenu->insertItem(i18n("What's This?"), 300); 801 configureToolBarMenu->insertItem(i18n("What's This?"), 300);
802 802
803 if (p-> mShowIconNewEvent) 803 if (p-> mShowIconNewEvent)
804 configureToolBarMenu->setItemChecked( 10, true ); 804 configureToolBarMenu->setItemChecked( 10, true );
805 if (p->mShowIconNewTodo ) 805 if (p->mShowIconNewTodo )
806 configureToolBarMenu->setItemChecked( 20, true ); 806 configureToolBarMenu->setItemChecked( 20, true );
807 if (p-> mShowIconSearch) 807 if (p-> mShowIconSearch)
808 configureToolBarMenu->setItemChecked( 120, true ); 808 configureToolBarMenu->setItemChecked( 120, true );
809 if (p-> mShowIconList) 809 if (p-> mShowIconList)
810 configureToolBarMenu->setItemChecked( 30, true ); 810 configureToolBarMenu->setItemChecked( 30, true );
811 if (p-> mShowIconDay1) 811 if (p-> mShowIconDay1)
812 configureToolBarMenu->setItemChecked( 40, true ); 812 configureToolBarMenu->setItemChecked( 40, true );
813 if (p-> mShowIconDay5) 813 if (p-> mShowIconDay5)
814 configureToolBarMenu->setItemChecked( 50, true ); 814 configureToolBarMenu->setItemChecked( 50, true );
815 if (p-> mShowIconDay7) 815 if (p-> mShowIconDay7)
816 configureToolBarMenu->setItemChecked( 60, true ); 816 configureToolBarMenu->setItemChecked( 60, true );
817 if (p-> mShowIconMonth) 817 if (p-> mShowIconMonth)
818 configureToolBarMenu->setItemChecked( 70, true ); 818 configureToolBarMenu->setItemChecked( 70, true );
819 if (p-> mShowIconTodoview) 819 if (p-> mShowIconTodoview)
820 configureToolBarMenu->setItemChecked( 80, true ); 820 configureToolBarMenu->setItemChecked( 80, true );
821 if (p-> mShowIconBackFast) 821 if (p-> mShowIconBackFast)
822 configureToolBarMenu->setItemChecked( 200, true ); 822 configureToolBarMenu->setItemChecked( 200, true );
823 if (p-> mShowIconBack) 823 if (p-> mShowIconBack)
824 configureToolBarMenu->setItemChecked( 210, true ); 824 configureToolBarMenu->setItemChecked( 210, true );
825 if (p-> mShowIconToday) 825 if (p-> mShowIconToday)
826 configureToolBarMenu->setItemChecked( 130, true ); 826 configureToolBarMenu->setItemChecked( 130, true );
827 if (p-> mShowIconForward) 827 if (p-> mShowIconForward)
828 configureToolBarMenu->setItemChecked( 220, true ); 828 configureToolBarMenu->setItemChecked( 220, true );
829 if (p-> mShowIconForwardFast) 829 if (p-> mShowIconForwardFast)
830 configureToolBarMenu->setItemChecked( 230, true ); 830 configureToolBarMenu->setItemChecked( 230, true );
831 if (p-> mShowIconNextDays) 831 if (p-> mShowIconNextDays)
832 configureToolBarMenu->setItemChecked( 100, true ); 832 configureToolBarMenu->setItemChecked( 100, true );
833 if (p-> mShowIconNext) 833 if (p-> mShowIconNext)
834 configureToolBarMenu->setItemChecked( 110, true ); 834 configureToolBarMenu->setItemChecked( 110, true );
835 if (p-> mShowIconJournal) 835 if (p-> mShowIconJournal)
836 configureToolBarMenu->setItemChecked( 90, true ); 836 configureToolBarMenu->setItemChecked( 90, true );
837 if (p-> mShowIconWhatsThis) 837 if (p-> mShowIconWhatsThis)
838 configureToolBarMenu->setItemChecked( 300, true ); 838 configureToolBarMenu->setItemChecked( 300, true );
839 839
840 QLabel* dummy = new QLabel( iconToolBar ); 840 QLabel* dummy = new QLabel( iconToolBar );
841 dummy->setBackgroundColor( iconToolBar->backgroundColor() ); 841 dummy->setBackgroundColor( iconToolBar->backgroundColor() );
842 if (!p-> mShowIconStretch) 842 if (!p-> mShowIconStretch)
843 iconToolBar->setStretchableWidget ( dummy ) ; 843 iconToolBar->setStretchableWidget ( dummy ) ;
844 else 844 else
845 configureToolBarMenu->setItemChecked( 5, true ); 845 configureToolBarMenu->setItemChecked( 5, true );
846 if (p-> mShowIconWhatsThis) 846 if (p-> mShowIconWhatsThis)
847 QWhatsThis::whatsThisButton ( iconToolBar ); 847 QWhatsThis::whatsThisButton ( iconToolBar );
848 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); 848 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) );
849 configureAgenda( p->mHourSize ); 849 configureAgenda( p->mHourSize );
850 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); 850 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) );
851} 851}
852void MainWindow::fillSyncMenu() 852void MainWindow::fillSyncMenu()
853{ 853{
854 if ( syncMenu->count() ) 854 if ( syncMenu->count() )
855 syncMenu->clear(); 855 syncMenu->clear();
856 syncMenu->insertItem( i18n("Configure..."), 0 ); 856 syncMenu->insertItem( i18n("Configure..."), 0 );
857 syncMenu->insertSeparator(); 857 syncMenu->insertSeparator();
858 syncMenu->insertItem( i18n("Multiple sync"), 1 ); 858 syncMenu->insertItem( i18n("Multiple sync"), 1 );
859 syncMenu->insertSeparator(); 859 syncMenu->insertSeparator();
860 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 860 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
861 config.setGroup("General"); 861 config.setGroup("General");
862 QStringList prof = config.readListEntry("SyncProfileNames"); 862 QStringList prof = config.readListEntry("SyncProfileNames");
863 KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); 863 KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined");
864 if ( prof.count() < 3 ) { 864 if ( prof.count() < 3 ) {
865 prof.clear(); 865 prof.clear();
866 prof << i18n("Sharp_DTM"); 866 prof << i18n("Sharp_DTM");
867 prof << i18n("Local_file"); 867 prof << i18n("Local_file");
868 prof << i18n("Last_file"); 868 prof << i18n("Last_file");
869 KSyncProfile* temp = new KSyncProfile (); 869 KSyncProfile* temp = new KSyncProfile ();
870 temp->setName( prof[0] ); 870 temp->setName( prof[0] );
871 temp->writeConfig(&config); 871 temp->writeConfig(&config);
872 temp->setName( prof[1] ); 872 temp->setName( prof[1] );
873 temp->writeConfig(&config); 873 temp->writeConfig(&config);
874 temp->setName( prof[2] ); 874 temp->setName( prof[2] );
875 temp->writeConfig(&config); 875 temp->writeConfig(&config);
876 config.setGroup("General"); 876 config.setGroup("General");
877 config.writeEntry("SyncProfileNames",prof); 877 config.writeEntry("SyncProfileNames",prof);
878 config.writeEntry("ExternSyncProfiles","Sharp_DTM"); 878 config.writeEntry("ExternSyncProfiles","Sharp_DTM");
879 config.sync(); 879 config.sync();
880 delete temp; 880 delete temp;
881 } 881 }
882 KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); 882 KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
883 KOPrefs::instance()->mSyncProfileNames = prof; 883 KOPrefs::instance()->mSyncProfileNames = prof;
884 int i; 884 int i;
885 for ( i = 0; i < prof.count(); ++i ) { 885 for ( i = 0; i < prof.count(); ++i ) {
886 886
887 syncMenu->insertItem( prof[i], 1000+i ); 887 syncMenu->insertItem( prof[i], 1000+i );
888 if ( i == 2 ) 888 if ( i == 2 )
889 syncMenu->insertSeparator(); 889 syncMenu->insertSeparator();
890 } 890 }
891 QDir app_dir; 891 QDir app_dir;
892 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { 892 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
893 syncMenu->setItemEnabled( false , 1000 ); 893 syncMenu->setItemEnabled( false , 1000 );
894 } 894 }
895 mView->setupExternSyncProfiles(); 895 mView->setupExternSyncProfiles();
896} 896}
897 897
898int MainWindow::ringSync() 898int MainWindow::ringSync()
899{ 899{
900 int syncedProfiles = 0; 900 int syncedProfiles = 0;
901 int i; 901 int i;
902 QTime timer; 902 QTime timer;
903 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 903 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
904 QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames; 904 QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames;
905 KSyncProfile* temp = new KSyncProfile (); 905 KSyncProfile* temp = new KSyncProfile ();
906 KOPrefs::instance()->mAskForPreferences = false; 906 KOPrefs::instance()->mAskForPreferences = false;
907 for ( i = 0; i < syncProfileNames.count(); ++i ) { 907 for ( i = 0; i < syncProfileNames.count(); ++i ) {
908 mCurrentSyncProfile = i; 908 mCurrentSyncProfile = i;
909 temp->setName(syncProfileNames[mCurrentSyncProfile]); 909 temp->setName(syncProfileNames[mCurrentSyncProfile]);
910 temp->readConfig(&config); 910 temp->readConfig(&config);
911 if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) { 911 if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) {
912 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); 912 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
913 ++syncedProfiles; 913 ++syncedProfiles;
914 // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 914 // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
915 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 915 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
916 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 916 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
917 KOPrefs::instance()->mWriteBackInFuture = 0;
918 if ( temp->getWriteBackFuture() )
919 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
917 KOPrefs::instance()->mShowSyncSummary = false; 920 KOPrefs::instance()->mShowSyncSummary = false;
918 mView->setSyncDevice(syncProfileNames[i] ); 921 mView->setSyncDevice(syncProfileNames[i] );
919 mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); 922 mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
920 if ( i == 0 ) { 923 if ( i == 0 ) {
921 syncSharp(); 924 syncSharp();
922 } else { 925 } else {
923 if ( temp->getIsLocalFileSync() ) { 926 if ( temp->getIsLocalFileSync() ) {
924 if ( syncWithFile( temp->getRemoteFileName( ), true ) ) 927 if ( syncWithFile( temp->getRemoteFileName( ), true ) )
925 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); 928 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName();
926 } else { 929 } else {
927 if ( temp->getIsPhoneSync() ) { 930 if ( temp->getIsPhoneSync() ) {
928 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; 931 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ;
929 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); 932 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( );
930 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); 933 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( );
931 syncPhone(); 934 syncPhone();
932 } else 935 } else
933 syncRemote( temp, false ); 936 syncRemote( temp, false );
934 937
935 } 938 }
936 } 939 }
937 timer.start(); 940 timer.start();
938 setCaption(i18n("Multiple sync in progress ... please wait!") ); 941 setCaption(i18n("Multiple sync in progress ... please wait!") );
939 while ( timer.elapsed () < 2000 ) { 942 while ( timer.elapsed () < 2000 ) {
940 qApp->processEvents(); 943 qApp->processEvents();
941#ifndef _WIN32_ 944#ifndef _WIN32_
942 sleep (1); 945 sleep (1);
943#endif 946#endif
944 } 947 }
945 948
946 } 949 }
947 950
948 } 951 }
949 delete temp; 952 delete temp;
950 return syncedProfiles; 953 return syncedProfiles;
951} 954}
952 955
953void MainWindow::multiSync( bool askforPrefs ) 956void MainWindow::multiSync( bool askforPrefs )
954{ 957{
955 if (mBlockSaveFlag) 958 if (mBlockSaveFlag)
956 return; 959 return;
957 mBlockSaveFlag = true; 960 mBlockSaveFlag = true;
958 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 961 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
959 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 962 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
960 question, 963 question,
961 i18n("Yes"), i18n("No"), 964 i18n("Yes"), i18n("No"),
962 0, 0 ) != 0 ) { 965 0, 0 ) != 0 ) {
963 mBlockSaveFlag = false; 966 mBlockSaveFlag = false;
964 setCaption(i18n("Aborted! Nothing synced!")); 967 setCaption(i18n("Aborted! Nothing synced!"));
965 return; 968 return;
966 } 969 }
967 mView->setSyncDevice(i18n("Multiple profiles") ); 970 mView->setSyncDevice(i18n("Multiple profiles") );
968 KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs; 971 KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs;
969 if ( askforPrefs ) { 972 if ( askforPrefs ) {
970 mView->edit_sync_options(); 973 mView->edit_sync_options();
971 KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs; 974 KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs;
972 } 975 }
973 setCaption(i18n("Multiple sync started.") ); 976 setCaption(i18n("Multiple sync started.") );
974 qApp->processEvents(); 977 qApp->processEvents();
975 int num = ringSync() ; 978 int num = ringSync() ;
976 if ( num > 1 ) 979 if ( num > 1 )
977 ringSync(); 980 ringSync();
978 mBlockSaveFlag = false; 981 mBlockSaveFlag = false;
979 if ( num ) 982 if ( num )
980 save(); 983 save();
981 if ( num ) 984 if ( num )
982 setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); 985 setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) );
983 else 986 else
984 setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 987 setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
985 return; 988 return;
986} 989}
987void MainWindow::slotSyncMenu( int action ) 990void MainWindow::slotSyncMenu( int action )
988{ 991{
989 //qDebug("syncaction %d ", action); 992 //qDebug("syncaction %d ", action);
990 if ( action == 0 ) { 993 if ( action == 0 ) {
991 994
992 // seems to be a Qt2 event handling bug 995 // seems to be a Qt2 event handling bug
993 // syncmenu.clear causes a segfault at first time 996 // syncmenu.clear causes a segfault at first time
994 // when we call it after the main event loop, it is ok 997 // when we call it after the main event loop, it is ok
995 // same behaviour when calling OM/Pi via QCOP for the first time 998 // same behaviour when calling OM/Pi via QCOP for the first time
996 QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); 999 QTimer::singleShot ( 1, this, SLOT ( confSync() ) );
997 //confSync(); 1000 //confSync();
998 1001
999 return; 1002 return;
1000 } 1003 }
1001 if ( action == 1 ) { 1004 if ( action == 1 ) {
1002 multiSync( true ); 1005 multiSync( true );
1003 return; 1006 return;
1004 } 1007 }
1005 1008
1006 if (mBlockSaveFlag) 1009 if (mBlockSaveFlag)
1007 return; 1010 return;
1008 mBlockSaveFlag = true; 1011 mBlockSaveFlag = true;
1009 mCurrentSyncProfile = action - 1000 ; 1012 mCurrentSyncProfile = action - 1000 ;
1010 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); 1013 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] );
1011 mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); 1014 mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
1012 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 1015 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
1013 KSyncProfile* temp = new KSyncProfile (); 1016 KSyncProfile* temp = new KSyncProfile ();
1014 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 1017 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
1015 temp->readConfig(&config); 1018 temp->readConfig(&config);
1016 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 1019 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
1017 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); 1020 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs();
1018 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 1021 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
1019 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 1022 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
1023 KOPrefs::instance()->mWriteBackInFuture = 0;
1024 if ( temp->getWriteBackFuture() )
1025 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
1020 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); 1026 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync();
1021 if ( action == 1000 ) { 1027 if ( action == 1000 ) {
1022 syncSharp(); 1028 syncSharp();
1023 1029
1024 } else if ( action == 1001 ) { 1030 } else if ( action == 1001 ) {
1025 syncLocalFile(); 1031 syncLocalFile();
1026 1032
1027 } else if ( action == 1002 ) { 1033 } else if ( action == 1002 ) {
1028 quickSyncLocalFile(); 1034 quickSyncLocalFile();
1029 1035
1030 } else if ( action >= 1003 ) { 1036 } else if ( action >= 1003 ) {
1031 if ( temp->getIsLocalFileSync() ) { 1037 if ( temp->getIsLocalFileSync() ) {
1032 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 1038 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
1033 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); 1039 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName();
1034 } else { 1040 } else {
1035 if ( temp->getIsPhoneSync() ) { 1041 if ( temp->getIsPhoneSync() ) {
1036 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; 1042 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ;
1037 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); 1043 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( );
1038 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); 1044 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( );
1039 syncPhone(); 1045 syncPhone();
1040 } else 1046 } else
1041 syncRemote( temp ); 1047 syncRemote( temp );
1042 1048
1043 } 1049 }
1044 } 1050 }
1045 delete temp; 1051 delete temp;
1046 mBlockSaveFlag = false; 1052 mBlockSaveFlag = false;
1047} 1053}
1048void MainWindow::setDefaultPreferences() 1054void MainWindow::setDefaultPreferences()
1049{ 1055{
1050 KOPrefs *p = KOPrefs::instance(); 1056 KOPrefs *p = KOPrefs::instance();
1051 1057
1052 p->mCompactDialogs = true; 1058 p->mCompactDialogs = true;
1053 p->mConfirm = true; 1059 p->mConfirm = true;
1054 // p->mEnableQuickTodo = false; 1060 // p->mEnableQuickTodo = false;
1055} 1061}
1056 1062
1057QString MainWindow::resourcePath() 1063QString MainWindow::resourcePath()
1058{ 1064{
1059 return KGlobal::iconLoader()->iconPath(); 1065 return KGlobal::iconLoader()->iconPath();
1060} 1066}
1061 1067
1062void MainWindow::displayText( QString text ,QString cap ) 1068void MainWindow::displayText( QString text ,QString cap )
1063{ 1069{
1064 QDialog dia( this, "name", true ); ; 1070 QDialog dia( this, "name", true ); ;
1065 dia.setCaption( cap ); 1071 dia.setCaption( cap );
1066 QVBoxLayout* lay = new QVBoxLayout( &dia ); 1072 QVBoxLayout* lay = new QVBoxLayout( &dia );
1067 lay->setSpacing( 3 ); 1073 lay->setSpacing( 3 );
1068 lay->setMargin( 3 ); 1074 lay->setMargin( 3 );
1069 QTextBrowser tb ( &dia ); 1075 QTextBrowser tb ( &dia );
1070 lay->addWidget( &tb ); 1076 lay->addWidget( &tb );
1071 tb.setText( text ); 1077 tb.setText( text );
1072#ifdef DESKTOP_VERSION 1078#ifdef DESKTOP_VERSION
1073 dia.resize( 640, 480); 1079 dia.resize( 640, 480);
1074#else 1080#else
1075 dia.showMaximized(); 1081 dia.showMaximized();
1076#endif 1082#endif
1077 dia.exec(); 1083 dia.exec();
1078} 1084}
1079void MainWindow::displayFile( QString fn, QString cap ) 1085void MainWindow::displayFile( QString fn, QString cap )
1080{ 1086{
1081 QString fileName = resourcePath() + fn; 1087 QString fileName = resourcePath() + fn;
1082 QString text; 1088 QString text;
1083 QFile file( fileName ); 1089 QFile file( fileName );
1084 if (!file.open( IO_ReadOnly ) ) { 1090 if (!file.open( IO_ReadOnly ) ) {
1085 return ; 1091 return ;
1086 1092
1087 } 1093 }
1088 QTextStream ts( &file ); 1094 QTextStream ts( &file );
1089 text = ts.read(); 1095 text = ts.read();
1090 file.close(); 1096 file.close();
1091 displayText( text, cap); 1097 displayText( text, cap);
1092} 1098}
1093void MainWindow::features() 1099void MainWindow::features()
1094{ 1100{
1095 1101
1096 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); 1102 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") );
1097} 1103}
1098 1104
1099void MainWindow::usertrans() 1105void MainWindow::usertrans()
1100{ 1106{
1101 1107
1102 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); 1108 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") );
1103} 1109}
1104#if 0 1110#if 0
1105#include <libkcal/vcalformat.h> 1111#include <libkcal/vcalformat.h>
1106#include <libkcal/event.h> 1112#include <libkcal/event.h>
1107#include <libkcal/todo.h> 1113#include <libkcal/todo.h>
1108#include <libkcal/incidence.h> 1114#include <libkcal/incidence.h>
1109#endif 1115#endif
1110void MainWindow::synchowto() 1116void MainWindow::synchowto()
1111{ 1117{
1112#if 0 1118#if 0
1113 QPtrList<Incidence> er = mCalendar->rawIncidences(); 1119 QPtrList<Incidence> er = mCalendar->rawIncidences();
1114 Incidence* inR = er.first(); 1120 Incidence* inR = er.first();
1115 VCalFormat vf; 1121 VCalFormat vf;
1116 QString strout; 1122 QString strout;
1117 while ( inR ) { 1123 while ( inR ) {
1118 if ( inR->type() == "Todo" ) 1124 if ( inR->type() == "Todo" )
1119 strout = vf.todoToString( (Todo *) inR ); 1125 strout = vf.todoToString( (Todo *) inR );
1120 if ( inR->type() == "Event" ) 1126 if ( inR->type() == "Event" )
1121 strout = vf.eventToString( (Event *) inR ); 1127 strout = vf.eventToString( (Event *) inR );
1122 qDebug("incidence: \n%s\n ente\n\n",strout.latin1() ); 1128 qDebug("incidence: \n%s\n ente\n\n",strout.latin1() );
1123 inR = er.next(); 1129 inR = er.next();
1124 } 1130 }
1125#endif 1131#endif
1126 displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") ); 1132 displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") );
1127} 1133}
1128void MainWindow::faq() 1134void MainWindow::faq()
1129{ 1135{
1130 displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); 1136 displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") );
1131 1137
1132} 1138}
1133void MainWindow::whatsNew() 1139void MainWindow::whatsNew()
1134{ 1140{
1135 displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") ); 1141 displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") );
1136 1142
1137} 1143}
1138void MainWindow::licence() 1144void MainWindow::licence()
1139{ 1145{
1140 KApplication::showLicence(); 1146 KApplication::showLicence();
1141 1147
1142} 1148}
1143void MainWindow::about() 1149void MainWindow::about()
1144{ 1150{
1145 QString version; 1151 QString version;
1146#include <../version> 1152#include <../version>
1147 QMessageBox::about( this, i18n("About KOrganizer/Pi"), 1153 QMessageBox::about( this, i18n("About KOrganizer/Pi"),
1148 i18n("KOrganizer/Platform-independent\n") + 1154 i18n("KOrganizer/Platform-independent\n") +
1149 "(KO/Pi) " + version + " - " + 1155 "(KO/Pi) " + version + " - " +
1150 1156
1151#ifdef DESKTOP_VERSION 1157#ifdef DESKTOP_VERSION
1152 i18n("Desktop Edition\n") + 1158 i18n("Desktop Edition\n") +
1153#else 1159#else
1154 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + 1160 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") +
1155#endif 1161#endif
1156 i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") ); 1162 i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") );
1157} 1163}
1158void MainWindow::keyBindings() 1164void MainWindow::keyBindings()
1159{ 1165{
1160 QString cap = i18n("Key bindings KOrganizer/Pi"); 1166 QString cap = i18n("Key bindings KOrganizer/Pi");
1161 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + 1167 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") +
1162 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ 1168 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+
1163 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + 1169 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") +
1164 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ 1170 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+
1165 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ 1171 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+
1166 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ 1172 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+
1167 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ 1173 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+
1168 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ 1174 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+
1169 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ 1175 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+
1170 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ 1176 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+
1171 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ 1177 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+
1172 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ 1178 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+
1173 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ 1179 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+
1174 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ 1180 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+
1175 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ 1181 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+
1176 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ 1182 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+
1177 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ 1183 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+
1178 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ 1184 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+
1179 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ 1185 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+
1180 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ 1186 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+
1181 i18n("<p><h3>In agenda view:</h3></p>\n") + 1187 i18n("<p><h3>In agenda view:</h3></p>\n") +
1182 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ 1188 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+
1183 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ 1189 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+
1184 i18n("<p><h3>In todo view:</h3></p>\n") + 1190 i18n("<p><h3>In todo view:</h3></p>\n") +
1185 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ 1191 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+
1186 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1192 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1187 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ 1193 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+
1188 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ 1194 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+
1189 i18n("<p><h3>In list view:</h3></p>\n") + 1195 i18n("<p><h3>In list view:</h3></p>\n") +
1190 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1196 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1191 i18n("<p><b>return</b>: Select item+one step down</p>\n")+ 1197 i18n("<p><b>return</b>: Select item+one step down</p>\n")+
1192 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ 1198 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+
1193 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ 1199 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+
1194 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ 1200 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+
1195 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ 1201 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+
1196 i18n("<p><h3>In event/todo viewer:</h3></p>\n") + 1202 i18n("<p><h3>In event/todo viewer:</h3></p>\n") +
1197 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ 1203 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+
1198 i18n("<p><b>A</b>: Show agenda view.</p>\n")+ 1204 i18n("<p><b>A</b>: Show agenda view.</p>\n")+
1199 i18n("<p><b>E</b>: Edit item</p>\n") + 1205 i18n("<p><b>E</b>: Edit item</p>\n") +
1200 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + 1206 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") +
1201 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + 1207 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") +
1202 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ 1208 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+
1203 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ 1209 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+
1204 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ 1210 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+
1205 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ 1211 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+
1206 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ 1212 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+
1207 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + 1213 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") +
1208 i18n("<p><b>White</b>: Item readonly</p>\n"); 1214 i18n("<p><b>White</b>: Item readonly</p>\n");
1209 displayText( text, cap); 1215 displayText( text, cap);
1210 1216
1211} 1217}
1212void MainWindow::aboutAutoSaving() 1218void MainWindow::aboutAutoSaving()
1213{ 1219{
1214 QMessageBox* msg; 1220 QMessageBox* msg;
1215 msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), 1221 msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"),
1216 i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configureable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"), QMessageBox::NoIcon, 1222 i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configureable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"), QMessageBox::NoIcon,
1217 QMessageBox::Ok, 1223 QMessageBox::Ok,
1218 QMessageBox::NoButton, 1224 QMessageBox::NoButton,
1219 QMessageBox::NoButton); 1225 QMessageBox::NoButton);
1220 msg->exec(); 1226 msg->exec();
1221 delete msg; 1227 delete msg;
1222 1228
1223 1229
1224} 1230}
1225void MainWindow::aboutKnownBugs() 1231void MainWindow::aboutKnownBugs()
1226{ 1232{
1227 QMessageBox* msg; 1233 QMessageBox* msg;
1228 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), 1234 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"),
1229 i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ 1235 i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+
1230 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ 1236 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+
1231 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + 1237 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") +
1232 i18n("\nor report them in the bugtracker on\n") + 1238 i18n("\nor report them in the bugtracker on\n") +
1233 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), 1239 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"),
1234 QMessageBox::NoIcon, 1240 QMessageBox::NoIcon,
1235 QMessageBox::Ok, 1241 QMessageBox::Ok,
1236 QMessageBox::NoButton, 1242 QMessageBox::NoButton,
1237 QMessageBox::NoButton); 1243 QMessageBox::NoButton);
1238 msg->exec(); 1244 msg->exec();
1239 delete msg; 1245 delete msg;
1240 1246
1241} 1247}
1242 1248
1243QString MainWindow::defaultFileName() 1249QString MainWindow::defaultFileName()
1244{ 1250{
1245 return locateLocal( "data", "korganizer/mycalendar.ics" ); 1251 return locateLocal( "data", "korganizer/mycalendar.ics" );
1246} 1252}
1247 1253
1248void MainWindow::processIncidenceSelection( Incidence *incidence ) 1254void MainWindow::processIncidenceSelection( Incidence *incidence )
1249{ 1255{
1250 if ( !incidence ) { 1256 if ( !incidence ) {
1251 enableIncidenceActions( false ); 1257 enableIncidenceActions( false );
1252 1258
1253 mNewSubTodoAction->setEnabled( false ); 1259 mNewSubTodoAction->setEnabled( false );
1254 setCaptionToDates(); 1260 setCaptionToDates();
1255 return; 1261 return;
1256 1262
1257 } 1263 }
1258 1264
1259 //KGlobal::locale()->formatDateTime(nextA, true); 1265 //KGlobal::locale()->formatDateTime(nextA, true);
1260 QString startString = ""; 1266 QString startString = "";
1261 if ( incidence->type() != "Todo" ) { 1267 if ( incidence->type() != "Todo" ) {
1262 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { 1268 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) {
1263 if ( incidence->doesFloat() ) { 1269 if ( incidence->doesFloat() ) {
1264 startString += ": "+incidence->dtStartDateStr( true ); 1270 startString += ": "+incidence->dtStartDateStr( true );
1265 startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); 1271 startString += " --- "+((Event*)incidence)->dtEndDateStr( true );
1266 1272
1267 } else { 1273 } else {
1268 startString = ": "+incidence->dtStartStr(true); 1274 startString = ": "+incidence->dtStartStr(true);
1269 startString += " --- "+((Event*)incidence)->dtEndStr(true); 1275 startString += " --- "+((Event*)incidence)->dtEndStr(true);
1270 1276
1271 } 1277 }
1272 1278
1273 } else { 1279 } else {
1274 if ( incidence->dtStart().time() != incidence->dtEnd().time() ) 1280 if ( incidence->dtStart().time() != incidence->dtEnd().time() )
1275 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ 1281 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+
1276 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); 1282 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time());
1277 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); 1283 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true);
1278 } 1284 }
1279 1285
1280 } 1286 }
1281 else 1287 else
1282 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); 1288 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed");
1283 if ( !incidence->location().isEmpty() ) 1289 if ( !incidence->location().isEmpty() )
1284 startString += " (" +incidence->location()+")"; 1290 startString += " (" +incidence->location()+")";
1285 setCaption( incidence->summary()+startString); 1291 setCaption( incidence->summary()+startString);
1286 1292
1287 enableIncidenceActions( true ); 1293 enableIncidenceActions( true );
1288 1294
1289 if ( incidence->type() == "Event" ) { 1295 if ( incidence->type() == "Event" ) {
1290 mShowAction->setText( i18n("Show Event...") ); 1296 mShowAction->setText( i18n("Show Event...") );
1291 mEditAction->setText( i18n("Edit Event...") ); 1297 mEditAction->setText( i18n("Edit Event...") );
1292 mDeleteAction->setText( i18n("Delete Event...") ); 1298 mDeleteAction->setText( i18n("Delete Event...") );
1293 1299
1294 mNewSubTodoAction->setEnabled( false ); 1300 mNewSubTodoAction->setEnabled( false );
1295 } else if ( incidence->type() == "Todo" ) { 1301 } else if ( incidence->type() == "Todo" ) {
1296 mShowAction->setText( i18n("Show Todo...") ); 1302 mShowAction->setText( i18n("Show Todo...") );
1297 mEditAction->setText( i18n("Edit Todo...") ); 1303 mEditAction->setText( i18n("Edit Todo...") );
1298 mDeleteAction->setText( i18n("Delete Todo...") ); 1304 mDeleteAction->setText( i18n("Delete Todo...") );
1299 1305
1300 mNewSubTodoAction->setEnabled( true ); 1306 mNewSubTodoAction->setEnabled( true );
1301 } else { 1307 } else {
1302 mShowAction->setText( i18n("Show...") ); 1308 mShowAction->setText( i18n("Show...") );
1303 mShowAction->setText( i18n("Edit...") ); 1309 mShowAction->setText( i18n("Edit...") );
1304 mShowAction->setText( i18n("Delete...") ); 1310 mShowAction->setText( i18n("Delete...") );
1305 1311
1306 mNewSubTodoAction->setEnabled( false ); 1312 mNewSubTodoAction->setEnabled( false );
1307 } 1313 }
1308} 1314}
1309 1315
1310void MainWindow::enableIncidenceActions( bool enabled ) 1316void MainWindow::enableIncidenceActions( bool enabled )
1311{ 1317{
1312 mShowAction->setEnabled( enabled ); 1318 mShowAction->setEnabled( enabled );
1313 mEditAction->setEnabled( enabled ); 1319 mEditAction->setEnabled( enabled );
1314 mDeleteAction->setEnabled( enabled ); 1320 mDeleteAction->setEnabled( enabled );
1315} 1321}
1316 1322
1317void MainWindow::importOL() 1323void MainWindow::importOL()
1318{ 1324{
1319#ifdef _WIN32_ 1325#ifdef _WIN32_
1320 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); 1326 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this );
1321 id->exec(); 1327 id->exec();
1322 delete id; 1328 delete id;
1323 mView->updateView(); 1329 mView->updateView();
1324#endif 1330#endif
1325} 1331}
1326void MainWindow::importBday() 1332void MainWindow::importBday()
1327{ 1333{
1328 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1334 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1329 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), 1335 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"),
1330 i18n("Import!"), i18n("Cancel"), 0, 1336 i18n("Import!"), i18n("Cancel"), 0,
1331 0, 1 ); 1337 0, 1 );
1332 if ( result == 0 ) { 1338 if ( result == 0 ) {
1333 mView->importBday(); 1339 mView->importBday();
1334 1340
1335 } 1341 }
1336 1342
1337 1343
1338} 1344}
1339void MainWindow::importQtopia() 1345void MainWindow::importQtopia()
1340{ 1346{
1341#ifndef DESKTOP_VERSION 1347#ifndef DESKTOP_VERSION
1342 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1348 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1343 i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"), 1349 i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"),
1344 i18n("Import!"), i18n("Cancel"), 0, 1350 i18n("Import!"), i18n("Cancel"), 0,
1345 0, 1 ); 1351 0, 1 );
1346 if ( result == 0 ) { 1352 if ( result == 0 ) {
1347 QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); 1353 QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
1348 QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); 1354 QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
1349 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; 1355 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
1350 mView->importQtopia( categories, datebook, todolist ); 1356 mView->importQtopia( categories, datebook, todolist );
1351 } 1357 }
1352#else 1358#else
1353 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1359 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1354 i18n("Not supported \non desktop!\n"), 1360 i18n("Not supported \non desktop!\n"),
1355 i18n("Ok"), i18n("Cancel"), 0, 1361 i18n("Ok"), i18n("Cancel"), 0,
1356 0, 1 ); 1362 0, 1 );
1357 1363
1358#endif 1364#endif
1359} 1365}
1360 1366
1361void MainWindow::saveOnClose() 1367void MainWindow::saveOnClose()
1362{ 1368{
1363 KOPrefs *p = KOPrefs::instance(); 1369 KOPrefs *p = KOPrefs::instance();
1364 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); 1370 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
1365 p->mToolBarUp = iconToolBar->x() > width()/2 || 1371 p->mToolBarUp = iconToolBar->x() > width()/2 ||
1366 iconToolBar->y() > height()/2; 1372 iconToolBar->y() > height()/2;
1367 mView->writeSettings(); 1373 mView->writeSettings();
1368 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) 1374 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName()))
1369 save(); 1375 save();
1370} 1376}
1371void MainWindow::slotModifiedChanged( bool changed ) 1377void MainWindow::slotModifiedChanged( bool changed )
1372{ 1378{
1373 if ( mBlockAtStartup ) 1379 if ( mBlockAtStartup )
1374 return; 1380 return;
1375 int msec; 1381 int msec;
1376 // we store the changes after 1 minute, 1382 // we store the changes after 1 minute,
1377 // and for safety reasons after 10 minutes again 1383 // and for safety reasons after 10 minutes again
1378 if ( !mBlockSaveFlag ) 1384 if ( !mBlockSaveFlag )
1379 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1385 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1380 else 1386 else
1381 msec = 1000 * 600; 1387 msec = 1000 * 600;
1382 mSaveTimer.start( msec, true ); // 1 minute 1388 mSaveTimer.start( msec, true ); // 1 minute
1383 qDebug("KO: Saving File in %d secs!", msec/1000); 1389 qDebug("KO: Saving File in %d secs!", msec/1000);
1384 mCalendarModifiedFlag = true; 1390 mCalendarModifiedFlag = true;
1385} 1391}
1386#include <qfileinfo.h> 1392#include <qfileinfo.h>
1387void MainWindow::save() 1393void MainWindow::save()
1388{ 1394{
1389 if ( mBlockSaveFlag ) 1395 if ( mBlockSaveFlag )
1390 return; 1396 return;
1391 bool store = mBlockSaveFlag; 1397 bool store = mBlockSaveFlag;
1392 mBlockSaveFlag = true; 1398 mBlockSaveFlag = true;
1393 if ( mView->checkFileVersion( defaultFileName()) ) { 1399 if ( mView->checkFileVersion( defaultFileName()) ) {
1394 1400
1395 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1401 QTime neededSaveTime = QDateTime::currentDateTime().time();
1396 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1402 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1397 qDebug("KO: Start saving data to file!"); 1403 qDebug("KO: Start saving data to file!");
1398 mView->saveCalendar( defaultFileName() ); 1404 mView->saveCalendar( defaultFileName() );
1399 1405
1400 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 1406 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1401 mView->setLoadedFileVersion(QDateTime::currentDateTime()); 1407 mView->setLoadedFileVersion(QDateTime::currentDateTime());
1402 qDebug("KO: Needed %d ms for saving.",msNeeded ); 1408 qDebug("KO: Needed %d ms for saving.",msNeeded );
1403 QString savemes; 1409 QString savemes;
1404 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 1410 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
1405 setCaption(savemes); 1411 setCaption(savemes);
1406 } else 1412 } else
1407 setCaption(i18n("Saving cancelled!")); 1413 setCaption(i18n("Saving cancelled!"));
1408 mCalendarModifiedFlag = false; 1414 mCalendarModifiedFlag = false;
1409 mBlockSaveFlag = store; 1415 mBlockSaveFlag = store;
1410} 1416}
1411 1417
1412void MainWindow::keyReleaseEvent ( QKeyEvent * e) 1418void MainWindow::keyReleaseEvent ( QKeyEvent * e)
1413{ 1419{
1414 if ( !e->isAutoRepeat() ) { 1420 if ( !e->isAutoRepeat() ) {
1415 mFlagKeyPressed = false; 1421 mFlagKeyPressed = false;
1416 } 1422 }
1417} 1423}
1418void MainWindow::keyPressEvent ( QKeyEvent * e ) 1424void MainWindow::keyPressEvent ( QKeyEvent * e )
1419{ 1425{
1420 qApp->processEvents(); 1426 qApp->processEvents();
1421 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 1427 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1422 e->ignore(); 1428 e->ignore();
1423 // qDebug(" ignore %d",e->isAutoRepeat() ); 1429 // qDebug(" ignore %d",e->isAutoRepeat() );
1424 return; 1430 return;
1425 } 1431 }
1426 if (! e->isAutoRepeat() ) 1432 if (! e->isAutoRepeat() )
1427 mFlagKeyPressed = true; 1433 mFlagKeyPressed = true;
1428 KOPrefs *p = KOPrefs::instance(); 1434 KOPrefs *p = KOPrefs::instance();
1429 bool showSelectedDates = false; 1435 bool showSelectedDates = false;
1430 int size; 1436 int size;
1431 int pro = 0; 1437 int pro = 0;
1432 //qDebug("MainWindow::keyPressEvent "); 1438 //qDebug("MainWindow::keyPressEvent ");
1433 switch ( e->key() ) { 1439 switch ( e->key() ) {
1434 case Qt::Key_Right: 1440 case Qt::Key_Right:
1435 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1441 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1436 mView->goNextMonth(); 1442 mView->goNextMonth();
1437 else 1443 else
1438 mView->goNext(); 1444 mView->goNext();
1439 showSelectedDates = true; 1445 showSelectedDates = true;
1440 break; 1446 break;
1441 case Qt::Key_Left: 1447 case Qt::Key_Left:
1442 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1448 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1443 mView->goPreviousMonth(); 1449 mView->goPreviousMonth();
1444 else 1450 else
1445 mView->goPrevious(); 1451 mView->goPrevious();
1446 showSelectedDates = true; 1452 showSelectedDates = true;
1447 break; 1453 break;
1448 case Qt::Key_Down: 1454 case Qt::Key_Down:
1449 mView->viewManager()->agendaView()->scrollOneHourDown(); 1455 mView->viewManager()->agendaView()->scrollOneHourDown();
1450 break; 1456 break;
1451 case Qt::Key_Up: 1457 case Qt::Key_Up:
1452 mView->viewManager()->agendaView()->scrollOneHourUp(); 1458 mView->viewManager()->agendaView()->scrollOneHourUp();
1453 break; 1459 break;
1454 case Qt::Key_I: 1460 case Qt::Key_I:
1455 mView->showIncidence(); 1461 mView->showIncidence();
1456 break; 1462 break;
1457 case Qt::Key_Delete: 1463 case Qt::Key_Delete:
1458 case Qt::Key_Backspace: 1464 case Qt::Key_Backspace:
1459 mView->deleteIncidence(); 1465 mView->deleteIncidence();
1460 break; 1466 break;
1461 case Qt::Key_D: 1467 case Qt::Key_D:
1462 mView->viewManager()->showDayView(); 1468 mView->viewManager()->showDayView();
1463 showSelectedDates = true; 1469 showSelectedDates = true;
1464 break; 1470 break;
1465 case Qt::Key_O: 1471 case Qt::Key_O:
1466 mView->toggleFilerEnabled( ); 1472 mView->toggleFilerEnabled( );
1467 break; 1473 break;
1468 case Qt::Key_0: 1474 case Qt::Key_0:
1469 case Qt::Key_1: 1475 case Qt::Key_1:
1470 case Qt::Key_2: 1476 case Qt::Key_2:
1471 case Qt::Key_3: 1477 case Qt::Key_3:
1472 case Qt::Key_4: 1478 case Qt::Key_4:
1473 case Qt::Key_5: 1479 case Qt::Key_5:
1474 case Qt::Key_6: 1480 case Qt::Key_6:
1475 case Qt::Key_7: 1481 case Qt::Key_7:
1476 case Qt::Key_8: 1482 case Qt::Key_8:
1477 case Qt::Key_9: 1483 case Qt::Key_9:
1478 pro = e->key()-48; 1484 pro = e->key()-48;
1479 if ( pro == 0 ) 1485 if ( pro == 0 )
1480 pro = 10; 1486 pro = 10;
1481 if ( e->state() == Qt::ControlButton) 1487 if ( e->state() == Qt::ControlButton)
1482 pro += 10; 1488 pro += 10;
1483 break; 1489 break;
1484 case Qt::Key_M: 1490 case Qt::Key_M:
1485 mView->viewManager()->showMonthView(); 1491 mView->viewManager()->showMonthView();
1486 showSelectedDates = true; 1492 showSelectedDates = true;
1487 break; 1493 break;
1488 case Qt::Key_Insert: 1494 case Qt::Key_Insert:
1489 mView->newEvent(); 1495 mView->newEvent();
1490 break; 1496 break;
1491 case Qt::Key_S : 1497 case Qt::Key_S :
1492 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1498 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1493 mView->newSubTodo(); 1499 mView->newSubTodo();
1494 else 1500 else
1495 mView->dialogManager()->showSearchDialog(); 1501 mView->dialogManager()->showSearchDialog();
1496 break; 1502 break;
1497 case Qt::Key_Y : 1503 case Qt::Key_Y :
1498 case Qt::Key_Z : 1504 case Qt::Key_Z :
1499 mView->viewManager()->showWorkWeekView(); 1505 mView->viewManager()->showWorkWeekView();
1500 showSelectedDates = true; 1506 showSelectedDates = true;
1501 break; 1507 break;
1502 case Qt::Key_U : 1508 case Qt::Key_U :
1503 mView->viewManager()->showWeekView(); 1509 mView->viewManager()->showWeekView();
1504 showSelectedDates = true; 1510 showSelectedDates = true;
1505 break; 1511 break;
1506 case Qt::Key_H : 1512 case Qt::Key_H :
1507 keyBindings(); 1513 keyBindings();
1508 break; 1514 break;
1509 case Qt::Key_W: 1515 case Qt::Key_W:
1510 mView->viewManager()->showWhatsNextView(); 1516 mView->viewManager()->showWhatsNextView();
1511 break; 1517 break;
1512 case Qt::Key_L: 1518 case Qt::Key_L:
1513 mView->viewManager()->showListView(); 1519 mView->viewManager()->showListView();
1514 break; 1520 break;
1515 case Qt::Key_N: 1521 case Qt::Key_N:
1516 mView->viewManager()->showNextXView(); 1522 mView->viewManager()->showNextXView();
1517 showSelectedDates = true; 1523 showSelectedDates = true;
1518 break; 1524 break;
1519 case Qt::Key_V: 1525 case Qt::Key_V:
1520 mView->viewManager()->showTodoView(); 1526 mView->viewManager()->showTodoView();
1521 break; 1527 break;
1522 case Qt::Key_C: 1528 case Qt::Key_C:
1523 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); 1529 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() );
1524 break; 1530 break;
1525 case Qt::Key_P: 1531 case Qt::Key_P:
1526 mView->showDatePicker( ); 1532 mView->showDatePicker( );
1527 break; 1533 break;
1528 case Qt::Key_F: 1534 case Qt::Key_F:
1529 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1535 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1530 mView->editFilters(); 1536 mView->editFilters();
1531 else 1537 else
1532 mView->toggleFilter(); 1538 mView->toggleFilter();
1533 break; 1539 break;
1534 case Qt::Key_X: 1540 case Qt::Key_X:
1535 mView->toggleDateNavigatorWidget(); 1541 mView->toggleDateNavigatorWidget();
1536 break; 1542 break;
1537 case Qt::Key_Space: 1543 case Qt::Key_Space:
1538 mView->toggleExpand(); 1544 mView->toggleExpand();
1539 break; 1545 break;
1540 case Qt::Key_A: 1546 case Qt::Key_A:
1541 mView->toggleAllDaySize(); 1547 mView->toggleAllDaySize();
1542 break; 1548 break;
1543 case Qt::Key_T: 1549 case Qt::Key_T:
1544 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1550 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1545 mView->newTodo(); 1551 mView->newTodo();
1546 else { 1552 else {
1547 mView->goToday(); 1553 mView->goToday();
1548 showSelectedDates = true; 1554 showSelectedDates = true;
1549 } 1555 }
1550 break; 1556 break;
1551 case Qt::Key_J: 1557 case Qt::Key_J:
1552 mView->viewManager()->showJournalView(); 1558 mView->viewManager()->showJournalView();
1553 break; 1559 break;
1554 case Qt::Key_B: 1560 case Qt::Key_B:
1555 mView->editIncidenceDescription();; 1561 mView->editIncidenceDescription();;
1556 break; 1562 break;
1557 // case Qt::Key_Return: 1563 // case Qt::Key_Return:
1558 case Qt::Key_E: 1564 case Qt::Key_E:
1559 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1565 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1560 mView->newEvent(); 1566 mView->newEvent();
1561 else 1567 else
1562 mView->editIncidence(); 1568 mView->editIncidence();
1563 break; 1569 break;
1564 case Qt::Key_Plus: 1570 case Qt::Key_Plus:
1565 size = p->mHourSize +2; 1571 size = p->mHourSize +2;
1566 if ( size <= 18 ) 1572 if ( size <= 18 )
1567 configureAgenda( size ); 1573 configureAgenda( size );
1568 break; 1574 break;
1569 case Qt::Key_Minus: 1575 case Qt::Key_Minus:
1570 size = p->mHourSize - 2; 1576 size = p->mHourSize - 2;
1571 if ( size >= 4 ) 1577 if ( size >= 4 )
1572 configureAgenda( size ); 1578 configureAgenda( size );
1573 break; 1579 break;
1574 1580
1575 1581
1576 default: 1582 default:
1577 e->ignore(); 1583 e->ignore();
1578 } 1584 }
1579 if ( pro > 0 ) { 1585 if ( pro > 0 ) {
1580 mView->selectFilter( pro-1 ); 1586 mView->selectFilter( pro-1 );
1581 } 1587 }
1582 if ( showSelectedDates ) { 1588 if ( showSelectedDates ) {
1583 ;// setCaptionToDates(); 1589 ;// setCaptionToDates();
1584 } 1590 }
1585 1591
1586} 1592}
1587 1593
1588void MainWindow::fillFilterMenu() 1594void MainWindow::fillFilterMenu()
1589{ 1595{
1590 selectFilterMenu->clear(); 1596 selectFilterMenu->clear();
1591 bool disable = false; 1597 bool disable = false;
1592 if ( mView->filterView()->filtersEnabled() ) { 1598 if ( mView->filterView()->filtersEnabled() ) {
1593 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 ); 1599 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 );
1594 } 1600 }
1595 else { 1601 else {
1596 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 ); 1602 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 );
1597 disable = true; 1603 disable = true;
1598 } 1604 }
1599 selectFilterMenu->insertSeparator(); 1605 selectFilterMenu->insertSeparator();
1600 QPtrList<CalFilter> fili = mView->filters(); 1606 QPtrList<CalFilter> fili = mView->filters();
1601 CalFilter *curfilter = mView->filterView()->selectedFilter(); 1607 CalFilter *curfilter = mView->filterView()->selectedFilter();
1602 CalFilter *filter = fili.first(); 1608 CalFilter *filter = fili.first();
1603 int iii = 1; 1609 int iii = 1;
1604 while(filter) { 1610 while(filter) {
1605 selectFilterMenu->insertItem( filter->name(), iii ); 1611 selectFilterMenu->insertItem( filter->name(), iii );
1606 if ( filter == curfilter) 1612 if ( filter == curfilter)
1607 selectFilterMenu->setItemChecked( iii, true ); 1613 selectFilterMenu->setItemChecked( iii, true );
1608 if ( disable ) 1614 if ( disable )
1609 selectFilterMenu->setItemEnabled( iii, false ); 1615 selectFilterMenu->setItemEnabled( iii, false );
1610 filter = fili.next(); 1616 filter = fili.next();
1611 ++iii; 1617 ++iii;
1612 } 1618 }
1613} 1619}
1614void MainWindow::selectFilter( int fil ) 1620void MainWindow::selectFilter( int fil )
1615{ 1621{
1616 if ( fil == 0 ) { 1622 if ( fil == 0 ) {
1617 mView->toggleFilerEnabled( ); 1623 mView->toggleFilerEnabled( );
1618 } else { 1624 } else {
1619 mView->selectFilter( fil-1 ); 1625 mView->selectFilter( fil-1 );
1620 } 1626 }
1621} 1627}
1622void MainWindow::configureToolBar( int item ) 1628void MainWindow::configureToolBar( int item )
1623{ 1629{
1624 1630
1625 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); 1631 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) );
1626 KOPrefs *p = KOPrefs::instance(); 1632 KOPrefs *p = KOPrefs::instance();
1627 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); 1633 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 );
1628 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); 1634 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 );
1629 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); 1635 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 );
1630 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); 1636 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 );
1631 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); 1637 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 );
1632 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); 1638 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 );
1633 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); 1639 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 );
1634 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); 1640 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 );
1635 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); 1641 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 );
1636 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); 1642 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 );
1637 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); 1643 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 );
1638 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); 1644 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 );
1639 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); 1645 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 );
1640 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); 1646 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 );
1641 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); 1647 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 );
1642 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); 1648 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 );
1643 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); 1649 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 );
1644 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); 1650 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 );
1645 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); 1651 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 );
1646 // initActions(); 1652 // initActions();
1647} 1653}
1648 1654
1649void MainWindow::setCaptionToDates() 1655void MainWindow::setCaptionToDates()
1650{ 1656{
1651 QString selDates; 1657 QString selDates;
1652 selDates = KGlobal::locale()->formatDate(mView->startDate(), true); 1658 selDates = KGlobal::locale()->formatDate(mView->startDate(), true);
1653 if (mView->startDate() < mView->endDate() ) 1659 if (mView->startDate() < mView->endDate() )
1654 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); 1660 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true);
1655 setCaption( i18n("Dates: ") + selDates ); 1661 setCaption( i18n("Dates: ") + selDates );
1656 1662
1657} 1663}
1658// parameter item == 0: reinit 1664// parameter item == 0: reinit
1659void MainWindow::configureAgenda( int item ) 1665void MainWindow::configureAgenda( int item )
1660{ 1666{
1661 1667
1662 KOPrefs *p = KOPrefs::instance(); 1668 KOPrefs *p = KOPrefs::instance();
1663 1669
1664 int i; 1670 int i;
1665 if ( item == 1 ) { 1671 if ( item == 1 ) {
1666 mView->toggleAllDaySize(); 1672 mView->toggleAllDaySize();
1667 return; 1673 return;
1668 } 1674 }
1669 // do not allow 4 for widgets higher than 480 1675 // do not allow 4 for widgets higher than 480
1670 // if ( QApplication::desktop()->height() > 480 ) { 1676 // if ( QApplication::desktop()->height() > 480 ) {
1671// if ( item == 4 ) 1677// if ( item == 4 )
1672// item = 6; 1678// item = 6;
1673// } 1679// }
1674 for ( i = 4; i <= 18; i= i+2 ) 1680 for ( i = 4; i <= 18; i= i+2 )
1675 configureAgendaMenu->setItemChecked( i, false ); 1681 configureAgendaMenu->setItemChecked( i, false );
1676 configureAgendaMenu->setItemChecked( item, true ); 1682 configureAgendaMenu->setItemChecked( item, true );
1677 if ( p->mHourSize == item ) 1683 if ( p->mHourSize == item )
1678 return; 1684 return;
1679 p->mHourSize=item; 1685 p->mHourSize=item;
1680 mView->viewManager()->agendaView()->updateConfig(); 1686 mView->viewManager()->agendaView()->updateConfig();
1681} 1687}
1682 1688
1683void MainWindow::saveCalendar() 1689void MainWindow::saveCalendar()
1684{ 1690{
1685 QString fn = KOPrefs::instance()->mLastSaveFile; 1691 QString fn = KOPrefs::instance()->mLastSaveFile;
1686 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); 1692 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this );
1687 1693
1688 if ( fn == "" ) 1694 if ( fn == "" )
1689 return; 1695 return;
1690 QFileInfo info; 1696 QFileInfo info;
1691 info.setFile( fn ); 1697 info.setFile( fn );
1692 QString mes; 1698 QString mes;
1693 bool createbup = true; 1699 bool createbup = true;
1694 if ( info. exists() ) { 1700 if ( info. exists() ) {
1695 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; 1701 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ;
1696 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1702 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1697 i18n("Overwrite!"), i18n("Cancel"), 0, 1703 i18n("Overwrite!"), i18n("Cancel"), 0,
1698 0, 1 ); 1704 0, 1 );
1699 if ( result != 0 ) { 1705 if ( result != 0 ) {
1700 createbup = false; 1706 createbup = false;
1701 } 1707 }
1702 } 1708 }
1703 if ( createbup ) { 1709 if ( createbup ) {
1704 mView->saveCalendar( fn ); 1710 mView->saveCalendar( fn );
1705 mes = i18n("KO/Pi:Saved %1").arg(fn); 1711 mes = i18n("KO/Pi:Saved %1").arg(fn);
1706 KOPrefs::instance()->mLastSaveFile = fn; 1712 KOPrefs::instance()->mLastSaveFile = fn;
1707 setCaption(mes); 1713 setCaption(mes);
1708 } 1714 }
1709} 1715}
1710void MainWindow::loadCalendar() 1716void MainWindow::loadCalendar()
1711{ 1717{
1712 1718
1713 QString fn = KOPrefs::instance()->mLastLoadFile; 1719 QString fn = KOPrefs::instance()->mLastLoadFile;
1714 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); 1720 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this );
1715 1721
1716 if ( fn == "" ) 1722 if ( fn == "" )
1717 return; 1723 return;
1718 QFileInfo info; 1724 QFileInfo info;
1719 info.setFile( fn ); 1725 info.setFile( fn );
1720 QString mess; 1726 QString mess;
1721 bool loadbup = true; 1727 bool loadbup = true;
1722 if ( info. exists() ) { 1728 if ( info. exists() ) {
1723 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1729 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1724 int result = QMessageBox::warning( this, "KO/Pi: Warning!", 1730 int result = QMessageBox::warning( this, "KO/Pi: Warning!",
1725 mess, 1731 mess,
1726 i18n("Load!"), i18n("Cancel"), 0, 1732 i18n("Load!"), i18n("Cancel"), 0,
1727 0, 1 ); 1733 0, 1 );
1728 if ( result != 0 ) { 1734 if ( result != 0 ) {
1729 loadbup = false; 1735 loadbup = false;
1730 } 1736 }
1731 } else { 1737 } else {
1732 QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1738 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1733 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, 1739 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0,
1734 0, 1 ); 1740 0, 1 );
1735 1741
1736 return; 1742 return;
1737 } 1743 }
1738 if ( loadbup ) { 1744 if ( loadbup ) {
1739 mView->openCalendar( fn ); 1745 mView->openCalendar( fn );
1740 KOPrefs::instance()->mLastLoadFile = fn; 1746 KOPrefs::instance()->mLastLoadFile = fn;
1741 mess = i18n("KO/Pi:Loaded %1").arg(fn) ; 1747 mess = i18n("KO/Pi:Loaded %1").arg(fn) ;
1742 setCaption(mess); 1748 setCaption(mess);
1743 } 1749 }
1744 1750
1745} 1751}
1746void MainWindow::quickImportIcal() 1752void MainWindow::quickImportIcal()
1747{ 1753{
1748 importFile( KOPrefs::instance()->mLastImportFile, false ); 1754 importFile( KOPrefs::instance()->mLastImportFile, false );
1749} 1755}
1750void MainWindow::importFile( QString fn, bool quick ) 1756void MainWindow::importFile( QString fn, bool quick )
1751{ 1757{
1752 QFileInfo info; 1758 QFileInfo info;
1753 info.setFile( fn ); 1759 info.setFile( fn );
1754 QString mess; 1760 QString mess;
1755 bool loadbup = true; 1761 bool loadbup = true;
1756 if ( !info. exists() ) { 1762 if ( !info. exists() ) {
1757 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); 1763 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30));
1758 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1764 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1759 mess ); 1765 mess );
1760 return; 1766 return;
1761 } 1767 }
1762 int result = 0; 1768 int result = 0;
1763 if ( !quick ) { 1769 if ( !quick ) {
1764 mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1770 mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1765 result = QMessageBox::warning( this, "KO/Pi: Warning!", 1771 result = QMessageBox::warning( this, "KO/Pi: Warning!",
1766 mess, 1772 mess,
1767 "Import", "Cancel", 0, 1773 "Import", "Cancel", 0,
1768 0, 1 ); 1774 0, 1 );
1769 } 1775 }
1770 if ( result == 0 ) { 1776 if ( result == 0 ) {
1771 if ( mView->openCalendar( fn, true )) { 1777 if ( mView->openCalendar( fn, true )) {
1772 KOPrefs::instance()->mLastImportFile = fn; 1778 KOPrefs::instance()->mLastImportFile = fn;
1773 setCaption(i18n("Imported file successfully")); 1779 setCaption(i18n("Imported file successfully"));
1774 } else { 1780 } else {
1775 setCaption(i18n("Error importing file")); 1781 setCaption(i18n("Error importing file"));
1776 } 1782 }
1777 } 1783 }
1778} 1784}
1779 1785
1780void MainWindow::importIcal() 1786void MainWindow::importIcal()
1781{ 1787{
1782 1788
1783 QString fn =KOPrefs::instance()->mLastImportFile; 1789 QString fn =KOPrefs::instance()->mLastImportFile;
1784 1790
1785 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); 1791 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this );
1786 if ( fn == "" ) 1792 if ( fn == "" )
1787 return; 1793 return;
1788 importFile( fn, true ); 1794 importFile( fn, true );
1789 1795
1790} 1796}
1791 1797
1792void MainWindow::exportVCalendar() 1798void MainWindow::exportVCalendar()
1793{ 1799{
1794 QString fn = KOPrefs::instance()->mLastVcalFile; 1800 QString fn = KOPrefs::instance()->mLastVcalFile;
1795 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); 1801 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this );
1796 if ( fn == "" ) 1802 if ( fn == "" )
1797 return; 1803 return;
1798 QFileInfo info; 1804 QFileInfo info;
1799 info.setFile( fn ); 1805 info.setFile( fn );
1800 QString mes; 1806 QString mes;
1801 bool createbup = true; 1807 bool createbup = true;
1802 if ( info. exists() ) { 1808 if ( info. exists() ) {
1803 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 1809 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
1804 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1810 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1805 i18n("Overwrite!"), i18n("Cancel"), 0, 1811 i18n("Overwrite!"), i18n("Cancel"), 0,
1806 0, 1 ); 1812 0, 1 );
1807 if ( result != 0 ) { 1813 if ( result != 0 ) {
1808 createbup = false; 1814 createbup = false;
1809 } 1815 }
1810 } 1816 }
1811 if ( createbup ) { 1817 if ( createbup ) {
1812 if ( mView->exportVCalendar( fn ) ) { 1818 if ( mView->exportVCalendar( fn ) ) {
1813 KOPrefs::instance()->mLastVcalFile = fn; 1819 KOPrefs::instance()->mLastVcalFile = fn;
1814 if ( fn.length() > 20 ) 1820 if ( fn.length() > 20 )
1815 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; 1821 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ;
1816 else 1822 else
1817 mes = i18n("KO/Pi:Exported to %1").arg(fn ); 1823 mes = i18n("KO/Pi:Exported to %1").arg(fn );
1818 setCaption(mes); 1824 setCaption(mes);
1819 } 1825 }
1820 } 1826 }
1821 1827
1822} 1828}
1823#include <qpushbutton.h> 1829#include <qpushbutton.h>
1824QString MainWindow::getPassword( ) 1830QString MainWindow::getPassword( )
1825{ 1831{
1826 QString retfile = ""; 1832 QString retfile = "";
1827 QDialog dia ( this, "input-dialog", true ); 1833 QDialog dia ( this, "input-dialog", true );
1828 QLineEdit lab ( &dia ); 1834 QLineEdit lab ( &dia );
1829 lab.setEchoMode( QLineEdit::Password ); 1835 lab.setEchoMode( QLineEdit::Password );
1830 QVBoxLayout lay( &dia ); 1836 QVBoxLayout lay( &dia );
1831 lay.setMargin(7); 1837 lay.setMargin(7);
1832 lay.setSpacing(7); 1838 lay.setSpacing(7);
1833 lay.addWidget( &lab); 1839 lay.addWidget( &lab);
1834 dia.setFixedSize( 230,50 ); 1840 dia.setFixedSize( 230,50 );
1835 dia.setCaption( i18n("Enter password") ); 1841 dia.setCaption( i18n("Enter password") );
1836 QPushButton pb ( "OK", &dia); 1842 QPushButton pb ( "OK", &dia);
1837 lay.addWidget( &pb ); 1843 lay.addWidget( &pb );
1838 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 1844 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
1839 dia.show(); 1845 dia.show();
1840 int res = dia.exec(); 1846 int res = dia.exec();
1841 if ( res ) 1847 if ( res )
1842 retfile = lab.text(); 1848 retfile = lab.text();
1843 dia.hide(); 1849 dia.hide();
1844 qApp->processEvents(); 1850 qApp->processEvents();
1845 return retfile; 1851 return retfile;
1846 1852
1847} 1853}
1848 1854
1849void MainWindow::syncLocalFile() 1855void MainWindow::syncLocalFile()
1850{ 1856{
1851 1857
1852 QString fn =KOPrefs::instance()->mLastSyncedLocalFile; 1858 QString fn =KOPrefs::instance()->mLastSyncedLocalFile;
1853 1859
1854 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); 1860 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this );
1855 if ( fn == "" ) 1861 if ( fn == "" )
1856 return; 1862 return;
1857 //mView->setSyncDevice("local-file" ); 1863 //mView->setSyncDevice("local-file" );
1858 if ( syncWithFile( fn, false ) ) { 1864 if ( syncWithFile( fn, false ) ) {
1859 // Event* e = mView->getLastSyncEvent(); 1865 // Event* e = mView->getLastSyncEvent();
1860// e->setReadOnly( false ); 1866// e->setReadOnly( false );
1861// e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); 1867// e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile);
1862// e->setReadOnly( true ); 1868// e->setReadOnly( true );
1863 } 1869 }
1864 1870
1865} 1871}
1866 1872
1867bool MainWindow::syncWithFile( QString fn , bool quick ) 1873bool MainWindow::syncWithFile( QString fn , bool quick )
1868{ 1874{
1869 bool ret = false; 1875 bool ret = false;
1870 QFileInfo info; 1876 QFileInfo info;
1871 info.setFile( fn ); 1877 info.setFile( fn );
1872 QString mess; 1878 QString mess;
1873 bool loadbup = true; 1879 bool loadbup = true;
1874 if ( !info. exists() ) { 1880 if ( !info. exists() ) {
1875 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 1881 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
1876 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1882 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1877 mess ); 1883 mess );
1878 return ret; 1884 return ret;
1879 } 1885 }
1880 int result = 0; 1886 int result = 0;
1881 if ( !quick ) { 1887 if ( !quick ) {
1882 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1888 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1883 result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1889 result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1884 mess, 1890 mess,
1885 i18n("Sync"), i18n("Cancel"), 0, 1891 i18n("Sync"), i18n("Cancel"), 0,
1886 0, 1 ); 1892 0, 1 );
1887 if ( result ) 1893 if ( result )
1888 return false; 1894 return false;
1889 } 1895 }
1890 if ( KOPrefs::instance()->mAskForPreferences ) 1896 if ( KOPrefs::instance()->mAskForPreferences )
1891 mView->edit_sync_options(); 1897 mView->edit_sync_options();
1892 if ( result == 0 ) { 1898 if ( result == 0 ) {
1893 //qDebug("Now sycing ... "); 1899 //qDebug("Now sycing ... ");
1894 if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) ) 1900 if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) )
1895 setCaption( i18n("Synchronization successful") ); 1901 setCaption( i18n("Synchronization successful") );
1896 else 1902 else
1897 setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); 1903 setCaption( i18n("Sync cancelled or failed. Nothing synced.") );
1898 if ( ! quick ) 1904 if ( ! quick )
1899 KOPrefs::instance()->mLastSyncedLocalFile = fn; 1905 KOPrefs::instance()->mLastSyncedLocalFile = fn;
1900 slotModifiedChanged( true ); 1906 slotModifiedChanged( true );
1901 } 1907 }
1902 return ret; 1908 return ret;
1903} 1909}
1904void MainWindow::quickSyncLocalFile() 1910void MainWindow::quickSyncLocalFile()
1905{ 1911{
1906 //mView->setSyncDevice("local-file" ); 1912 //mView->setSyncDevice("local-file" );
1907 //qDebug("quickSyncLocalFile() "); 1913 //qDebug("quickSyncLocalFile() ");
1908 if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) { 1914 if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) {
1909 // Event* e = mView->getLastSyncEvent(); 1915 // Event* e = mView->getLastSyncEvent();
1910// e->setReadOnly( false ); 1916// e->setReadOnly( false );
1911// e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); 1917// e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile);
1912// e->setReadOnly( true ); 1918// e->setReadOnly( true );
1913 1919
1914 } 1920 }
1915} 1921}
1916 1922
1917void MainWindow::confSync() 1923void MainWindow::confSync()
1918{ 1924{
1919 mView->confSync(); 1925 mView->confSync();
1920 fillSyncMenu(); 1926 fillSyncMenu();
1921} 1927}
1922void MainWindow::syncRemote( KSyncProfile* prof, bool ask) 1928void MainWindow::syncRemote( KSyncProfile* prof, bool ask)
1923{ 1929{
1924 QString question; 1930 QString question;
1925 if ( ask ) { 1931 if ( ask ) {
1926 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; 1932 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
1927 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 1933 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
1928 question, 1934 question,
1929 i18n("Yes"), i18n("No"), 1935 i18n("Yes"), i18n("No"),
1930 0, 0 ) != 0 ) 1936 0, 0 ) != 0 )
1931 return; 1937 return;
1932 } 1938 }
1933 QString command = prof->getPreSyncCommand(); 1939 QString command = prof->getPreSyncCommand();
1934 int fi; 1940 int fi;
1935 if ( (fi = command.find("$PWD$")) > 0 ) { 1941 if ( (fi = command.find("$PWD$")) > 0 ) {
1936 QString pwd = getPassword(); 1942 QString pwd = getPassword();
1937 command = command.left( fi )+ pwd + command.mid( fi+5 ); 1943 command = command.left( fi )+ pwd + command.mid( fi+5 );
1938 1944
1939 } 1945 }
1940 int maxlen = 30; 1946 int maxlen = 30;
1941 if ( QApplication::desktop()->width() > 320 ) 1947 if ( QApplication::desktop()->width() > 320 )
1942 maxlen += 25; 1948 maxlen += 25;
1943 setCaption ( i18n( "Copy remote file to local machine..." ) ); 1949 setCaption ( i18n( "Copy remote file to local machine..." ) );
1944 int fileSize = 0; 1950 int fileSize = 0;
1945 int result = system ( command ); 1951 int result = system ( command );
1946 // 0 : okay 1952 // 0 : okay
1947 // 256: no such file or dir 1953 // 256: no such file or dir
1948 // 1954 //
1949 qDebug("KO: Remote copy result(0 = okay): %d ",result ); 1955 qDebug("KO: Remote copy result(0 = okay): %d ",result );
1950 if ( result != 0 ) { 1956 if ( result != 0 ) {
1951 int len = maxlen; 1957 int len = maxlen;
1952 while ( len < command.length() ) { 1958 while ( len < command.length() ) {
1953 command.insert( len , "\n" ); 1959 command.insert( len , "\n" );
1954 len += maxlen +2; 1960 len += maxlen +2;
1955 } 1961 }
1956 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; 1962 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ;
1957 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), 1963 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
1958 question, 1964 question,
1959 i18n("Okay!")) ; 1965 i18n("Okay!")) ;
1960 setCaption ("KO/Pi"); 1966 setCaption ("KO/Pi");
1961 return; 1967 return;
1962 } 1968 }
1963 setCaption ( i18n( "Copying succeed." ) ); 1969 setCaption ( i18n( "Copying succeed." ) );
1964 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); 1970 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
1965 if ( syncWithFile( prof->getLocalTempFile(), true ) ) { 1971 if ( syncWithFile( prof->getLocalTempFile(), true ) ) {
1966// Event* e = mView->getLastSyncEvent(); 1972// Event* e = mView->getLastSyncEvent();
1967// e->setReadOnly( false ); 1973// e->setReadOnly( false );
1968// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 1974// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
1969// e->setReadOnly( true ); 1975// e->setReadOnly( true );
1970 if ( KOPrefs::instance()->mWriteBackFile ) { 1976 if ( KOPrefs::instance()->mWriteBackFile ) {
1971 command = prof->getPostSyncCommand(); 1977 command = prof->getPostSyncCommand();
1972 setCaption ( i18n( "Writing back file ..." ) ); 1978 setCaption ( i18n( "Writing back file ..." ) );
1973 result = system ( command ); 1979 result = system ( command );
1974 qDebug("KO: Writing back file result: %d ", result); 1980 qDebug("KO: Writing back file result: %d ", result);
1975 if ( result != 0 ) { 1981 if ( result != 0 ) {
1976 setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); 1982 setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
1977 return; 1983 return;
1978 } else { 1984 } else {
1979 setCaption ( i18n( "Syncronization sucessfully completed" ) ); 1985 setCaption ( i18n( "Syncronization sucessfully completed" ) );
1980 } 1986 }
1981 } 1987 }
1982 } 1988 }
1983 return; 1989 return;
1984} 1990}
1985void MainWindow::syncSSH() 1991void MainWindow::syncSSH()
1986{ 1992{
1987 // not used anymore 1993 // not used anymore
1988 QTime timer; 1994 QTime timer;
1989 timer.start(); 1995 timer.start();
1990 //qDebug("MainWindow::syncssh() "); 1996 //qDebug("MainWindow::syncssh() ");
1991 KOPrefs *p = KOPrefs::instance(); 1997 KOPrefs *p = KOPrefs::instance();
1992 QString localFile = p->mLocalTempFile; 1998 QString localFile = p->mLocalTempFile;
1993 QString remoteIP = p->mRemoteIP; 1999 QString remoteIP = p->mRemoteIP;
1994 QString remoteUser = p->mRemoteUser; 2000 QString remoteUser = p->mRemoteUser;
1995 QString remoteFile = p->mRemoteFile; 2001 QString remoteFile = p->mRemoteFile;
1996 if ( p->mUsePassWd && p->mRemotePassWd.length() > 0 ) 2002 if ( p->mUsePassWd && p->mRemotePassWd.length() > 0 )
1997 remoteUser += ":" + p->mRemotePassWd; 2003 remoteUser += ":" + p->mRemotePassWd;
1998 2004
1999 QString question = i18n("Do you really want\nto remote sync?\n \n") + 2005 QString question = i18n("Do you really want\nto remote sync?\n \n") +
2000 i18n("IP: " ) +remoteIP +"\n" + 2006 i18n("IP: " ) +remoteIP +"\n" +
2001 i18n("User: " ) + remoteUser +"\n" ; 2007 i18n("User: " ) + remoteUser +"\n" ;
2002 int maxlen = 30; 2008 int maxlen = 30;
2003 if ( QApplication::desktop()->width() > 320 ) 2009 if ( QApplication::desktop()->width() > 320 )
2004 maxlen += 25; 2010 maxlen += 25;
2005 if ( remoteFile.length() > maxlen ) 2011 if ( remoteFile.length() > maxlen )
2006 question += i18n("Remote file:\n..." ) + remoteFile.right(maxlen) +"\n"; 2012 question += i18n("Remote file:\n..." ) + remoteFile.right(maxlen) +"\n";
2007 else 2013 else
2008 question += i18n("Remote file:\n " ) + remoteFile +"\n"; 2014 question += i18n("Remote file:\n " ) + remoteFile +"\n";
2009 if ( localFile.length() > maxlen ) 2015 if ( localFile.length() > maxlen )
2010 question += i18n("Local temp file:\n..." ) + localFile.right(maxlen) +"\n"; 2016 question += i18n("Local temp file:\n..." ) + localFile.right(maxlen) +"\n";
2011 else 2017 else
2012 question += i18n("Local temp file:\n " ) + localFile +"\n"; 2018 question += i18n("Local temp file:\n " ) + localFile +"\n";
2013 2019
2014 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 2020 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
2015 question, 2021 question,
2016 i18n("Yes"), i18n("No"), 2022 i18n("Yes"), i18n("No"),
2017 0, 0 ) != 0 ) 2023 0, 0 ) != 0 )
2018 return; 2024 return;
2019 // if ( !p->mUsePassWd ) { 2025 // if ( !p->mUsePassWd ) {
2020 // QString pass = getPassword(); 2026 // QString pass = getPassword();
2021 // if ( pass.length() > 0 ) 2027 // if ( pass.length() > 0 )
2022 // remoteUser += ":" + pass; 2028 // remoteUser += ":" + pass;
2023 // } 2029 // }
2024 QString command = "scp " + remoteUser + "@" + remoteIP +":" + remoteFile +" " +localFile; 2030 QString command = "scp " + remoteUser + "@" + remoteIP +":" + remoteFile +" " +localFile;
2025 setCaption ( i18n( "Copy remote file to local machine..." ) ); 2031 setCaption ( i18n( "Copy remote file to local machine..." ) );
2026 int fileSize = 0; 2032 int fileSize = 0;
2027 int result = system ( command ); 2033 int result = system ( command );
2028 // 0 : okay 2034 // 0 : okay
2029 // 256: no such file or dir 2035 // 256: no such file or dir
2030 // 2036 //
2031 qDebug("KO: Remote copy result(0 = okay): %d ",result ); 2037 qDebug("KO: Remote copy result(0 = okay): %d ",result );
2032 if ( result != 0 ) { 2038 if ( result != 0 ) {
2033 int len = maxlen; 2039 int len = maxlen;
2034 while ( len < command.length() ) { 2040 while ( len < command.length() ) {
2035 command.insert( len , "\n" ); 2041 command.insert( len , "\n" );
2036 len += maxlen +2; 2042 len += maxlen +2;
2037 } 2043 }
2038 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; 2044 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ;
2039 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), 2045 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
2040 question, 2046 question,
2041 i18n("Okay!")) ; 2047 i18n("Okay!")) ;
2042 setCaption ("KO/Pi"); 2048 setCaption ("KO/Pi");
2043 return; 2049 return;
2044 } 2050 }
2045 2051
2046 2052
2047 setCaption ( i18n( "Copying succeed." ) ); 2053 setCaption ( i18n( "Copying succeed." ) );
2048 //mView->setSyncDevice("ssh-scp" ); 2054 //mView->setSyncDevice("ssh-scp" );
2049 if ( syncWithFile(localFile , true ) ) { 2055 if ( syncWithFile(localFile , true ) ) {
2050// Event* e = mView->getLastSyncEvent(); 2056// Event* e = mView->getLastSyncEvent();
2051// e->setReadOnly( false ); 2057// e->setReadOnly( false );
2052// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 2058// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
2053// e->setReadOnly( true ); 2059// e->setReadOnly( true );
2054 if ( KOPrefs::instance()->mWriteBackFile ) { 2060 if ( KOPrefs::instance()->mWriteBackFile ) {
2055 command = "scp " + localFile +" " +remoteUser + "@" + remoteIP +":" + remoteFile ; 2061 command = "scp " + localFile +" " +remoteUser + "@" + remoteIP +":" + remoteFile ;
2056 setCaption ( i18n( "Writing back file ..." ) ); 2062 setCaption ( i18n( "Writing back file ..." ) );
2057 result = system ( command ); 2063 result = system ( command );
2058 if ( result != 0 ) { 2064 if ( result != 0 ) {
2059 int len = maxlen; 2065 int len = maxlen;
2060 while ( len < command.length() ) { 2066 while ( len < command.length() ) {
2061 command.insert( len , "\n" ); 2067 command.insert( len , "\n" );
2062 len += maxlen +2; 2068 len += maxlen +2;
2063 } 2069 }
2064 question = i18n("Sorry, the copy back command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; 2070 question = i18n("Sorry, the copy back command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ;
2065 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), 2071 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
2066 question, 2072 question,
2067 i18n("Okay!")) ; 2073 i18n("Okay!")) ;
2068 setCaption ("KO/Pi"); 2074 setCaption ("KO/Pi");
2069 return; 2075 return;
2070 } else { 2076 } else {
2071 setCaption ( i18n( "Syncronization sucessfully completed" ) ); 2077 setCaption ( i18n( "Syncronization sucessfully completed" ) );
2072 } 2078 }
2073 } 2079 }
2074 } 2080 }
2075 return; 2081 return;
2076#if 0 2082#if 0
2077 system ("scp zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics /home/polo/Applications/korganizer/z_sync.ics"); 2083 system ("scp zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics /home/polo/Applications/korganizer/z_sync.ics");
2078 while ( timer.elapsed() < 5000 ) 2084 while ( timer.elapsed() < 5000 )
2079 qApp->processEvents(); 2085 qApp->processEvents();
2080 2086
2081 qDebug("MainWindow::merging) "); 2087 qDebug("MainWindow::merging) ");
2082 mView->syncCalendar( "/home/polo/Applications/korganizer/z_sync.ics", 0 ); 2088 mView->syncCalendar( "/home/polo/Applications/korganizer/z_sync.ics", 0 );
2083 while ( mBlockSaveFlag ) 2089 while ( mBlockSaveFlag )
2084 qApp->processEvents(); 2090 qApp->processEvents();
2085 save(); 2091 save();
2086 system ("scp /home/polo/Applications/korganizer/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics"); 2092 system ("scp /home/polo/Applications/korganizer/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics");
2087#endif 2093#endif
2088 2094
2089} 2095}
2090 2096
2091 2097
2092void MainWindow::syncSharp() 2098void MainWindow::syncSharp()
2093{ 2099{
2094 if ( mCalendarModifiedFlag ) 2100 if ( mCalendarModifiedFlag )
2095 save(); 2101 save();
2096 mView->syncSharp(); 2102 mView->syncSharp();
2097 slotModifiedChanged( true ); 2103 slotModifiedChanged( true );
2098 2104
2099} 2105}
2100void MainWindow::syncPhone() 2106void MainWindow::syncPhone()
2101{ 2107{
2102 if ( mCalendarModifiedFlag ) 2108 if ( mCalendarModifiedFlag )
2103 save(); 2109 save();
2104 mView->syncPhone(); 2110 mView->syncPhone();
2105 slotModifiedChanged( true ); 2111 slotModifiedChanged( true );
2106 2112
2107} 2113}
2108 2114
2109void MainWindow::printSel( ) 2115void MainWindow::printSel( )
2110{ 2116{
2111 mView->viewManager()->agendaView()->agenda()->printSelection(); 2117 mView->viewManager()->agendaView()->agenda()->printSelection();
2112} 2118}
2113 2119
2114void MainWindow::printCal() 2120void MainWindow::printCal()
2115{ 2121{
2116 mView->print();//mCp->showDialog(); 2122 mView->print();//mCp->showDialog();
2117} 2123}
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp
index ef69bce..6d0da5c 100644
--- a/libkcal/phoneformat.cpp
+++ b/libkcal/phoneformat.cpp
@@ -1,636 +1,637 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 3
4 Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> 4 Copyright (c) 2004 Lutz Rogowski <rogowski@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#include <kmessagebox.h> 38#include <kmessagebox.h>
39 39
40#include "calendar.h" 40#include "calendar.h"
41#include "alarm.h" 41#include "alarm.h"
42#include "recurrence.h" 42#include "recurrence.h"
43#include "calendarlocal.h" 43#include "calendarlocal.h"
44 44
45#include "phoneformat.h" 45#include "phoneformat.h"
46#include "syncdefines.h" 46#include "syncdefines.h"
47 47
48using namespace KCal; 48using namespace KCal;
49class PhoneParser : public QObject 49class PhoneParser : public QObject
50{ 50{
51public: 51public:
52 PhoneParser( ) { 52 PhoneParser( ) {
53 ; 53 ;
54 } 54 }
55 55
56 static QString dtToString( const QDateTime& dti, bool useTZ = false ) 56 static QString dtToString( const QDateTime& dti, bool useTZ = false )
57 { 57 {
58 QString datestr; 58 QString datestr;
59 QString timestr; 59 QString timestr;
60 int offset = KGlobal::locale()->localTimeOffset( dti ); 60 int offset = KGlobal::locale()->localTimeOffset( dti );
61 QDateTime dt; 61 QDateTime dt;
62 if (useTZ) 62 if (useTZ)
63 dt = dti.addSecs ( -(offset*60)); 63 dt = dti.addSecs ( -(offset*60));
64 else 64 else
65 dt = dti; 65 dt = dti;
66 if(dt.date().isValid()){ 66 if(dt.date().isValid()){
67 const QDate& date = dt.date(); 67 const QDate& date = dt.date();
68 datestr.sprintf("%04d%02d%02d", 68 datestr.sprintf("%04d%02d%02d",
69 date.year(), date.month(), date.day()); 69 date.year(), date.month(), date.day());
70 } 70 }
71 if(dt.time().isValid()){ 71 if(dt.time().isValid()){
72 const QTime& time = dt.time(); 72 const QTime& time = dt.time();
73 timestr.sprintf("T%02d%02d%02d", 73 timestr.sprintf("T%02d%02d%02d",
74 time.hour(), time.minute(), time.second()); 74 time.hour(), time.minute(), time.second());
75 } 75 }
76 return datestr + timestr; 76 return datestr + timestr;
77 } 77 }
78 78
79 79
80}; 80};
81 81
82 82
83 83
84PhoneFormat::PhoneFormat(QString profileName, QString device,QString connection, QString model ) 84PhoneFormat::PhoneFormat(QString profileName, QString device,QString connection, QString model )
85{ 85{
86 mProfileName = profileName; 86 mProfileName = profileName;
87 mDevice = device; 87 mDevice = device;
88 mConnection = connection; 88 mConnection = connection;
89 mModel = model; 89 mModel = model;
90} 90}
91 91
92PhoneFormat::~PhoneFormat() 92PhoneFormat::~PhoneFormat()
93{ 93{
94} 94}
95#if 0 95#if 0
96int PhoneFormat::initDevice(GSM_StateMachine *s) 96int PhoneFormat::initDevice(GSM_StateMachine *s)
97{ 97{
98 GSM_ReadConfig(NULL, &s->Config[0], 0); 98 GSM_ReadConfig(NULL, &s->Config[0], 0);
99 s->ConfigNum = 1; 99 s->ConfigNum = 1;
100 GSM_Config *cfg = &s->Config[0]; 100 GSM_Config *cfg = &s->Config[0];
101 if ( ! mConnection.isEmpty() ) { 101 if ( ! mConnection.isEmpty() ) {
102 cfg->Connection = strdup(mConnection.latin1()); 102 cfg->Connection = strdup(mConnection.latin1());
103 cfg->DefaultConnection = false; 103 cfg->DefaultConnection = false;
104 qDebug("Connection set %s ", cfg->Connection ); 104 qDebug("Connection set %s ", cfg->Connection );
105 105
106 } 106 }
107 if ( ! mDevice.isEmpty() ) { 107 if ( ! mDevice.isEmpty() ) {
108 cfg->Device = strdup(mDevice.latin1()); 108 cfg->Device = strdup(mDevice.latin1());
109 cfg->DefaultDevice = false; 109 cfg->DefaultDevice = false;
110 qDebug("Device set %s ", cfg->Device); 110 qDebug("Device set %s ", cfg->Device);
111 111
112 } 112 }
113 if ( ! mModel.isEmpty() ) { 113 if ( ! mModel.isEmpty() ) {
114 strcpy(cfg->Model,mModel.latin1() ); 114 strcpy(cfg->Model,mModel.latin1() );
115 cfg->DefaultModel = false; 115 cfg->DefaultModel = false;
116 qDebug("Model set %s ",cfg->Model ); 116 qDebug("Model set %s ",cfg->Model );
117 } 117 }
118 int error=GSM_InitConnection(s,3); 118 int error=GSM_InitConnection(s,3);
119 return error; 119 return error;
120} 120}
121#endif 121#endif
122ulong PhoneFormat::getCsumTodo( Todo* todo ) 122ulong PhoneFormat::getCsumTodo( Todo* todo )
123{ 123{
124 QStringList attList; 124 QStringList attList;
125 if ( todo->hasDueDate() ) 125 if ( todo->hasDueDate() )
126 attList << PhoneParser::dtToString ( todo->dtDue() ); 126 attList << PhoneParser::dtToString ( todo->dtDue() );
127 attList << todo->summary(); 127 attList << todo->summary();
128 QString completedString = "no"; 128 QString completedString = "no";
129 if ( todo->isCompleted() ) 129 if ( todo->isCompleted() )
130 completedString = "yes"; 130 completedString = "yes";
131 attList << completedString; 131 attList << completedString;
132 int prio = todo->priority(); 132 int prio = todo->priority();
133 if( prio == 2 ) prio = 1; 133 if( prio == 2 ) prio = 1;
134 if (prio == 4 ) prio = 5 ; 134 if (prio == 4 ) prio = 5 ;
135 attList << QString::number( prio ); 135 attList << QString::number( prio );
136 QString alarmString = "na"; 136 QString alarmString = "na";
137 Alarm *alarm; 137 Alarm *alarm;
138 if ( todo->alarms().count() > 0 ) { 138 if ( todo->alarms().count() > 0 ) {
139 alarm = todo->alarms().first(); 139 alarm = todo->alarms().first();
140 if ( alarm->enabled() ) { 140 if ( alarm->enabled() ) {
141 alarmString = QString::number(alarm->startOffset().asSeconds() ); 141 alarmString = QString::number(alarm->startOffset().asSeconds() );
142 } 142 }
143 } 143 }
144 attList << alarmString; 144 attList << alarmString;
145 attList << todo->categoriesStr(); 145 attList << todo->categoriesStr();
146 attList << todo->secrecyStr(); 146 attList << todo->secrecyStr();
147 return PhoneFormat::getCsum(attList ); 147 return PhoneFormat::getCsum(attList );
148 148
149} 149}
150ulong PhoneFormat::getCsumEvent( Event* event ) 150ulong PhoneFormat::getCsumEvent( Event* event )
151{ 151{
152 QStringList attList; 152 QStringList attList;
153 attList << PhoneParser::dtToString ( event->dtStart() ); 153 attList << PhoneParser::dtToString ( event->dtStart() );
154 attList << PhoneParser::dtToString ( event->dtEnd() ); 154 attList << PhoneParser::dtToString ( event->dtEnd() );
155 attList << event->summary(); 155 attList << event->summary();
156 attList << event->location(); 156 attList << event->location();
157 QString alarmString = "na"; 157 QString alarmString = "na";
158 Alarm *alarm; 158 Alarm *alarm;
159 if ( event->alarms().count() > 0 ) { 159 if ( event->alarms().count() > 0 ) {
160 alarm = event->alarms().first(); 160 alarm = event->alarms().first();
161 if ( alarm->enabled() ) { 161 if ( alarm->enabled() ) {
162 alarmString = QString::number( alarm->startOffset().asSeconds() ); 162 alarmString = QString::number( alarm->startOffset().asSeconds() );
163 } 163 }
164 } 164 }
165 attList << alarmString; 165 attList << alarmString;
166 Recurrence* rec = event->recurrence(); 166 Recurrence* rec = event->recurrence();
167 QStringList list; 167 QStringList list;
168 bool writeEndDate = false; 168 bool writeEndDate = false;
169 switch ( rec->doesRecur() ) 169 switch ( rec->doesRecur() )
170 { 170 {
171 case Recurrence::rDaily: // 0 171 case Recurrence::rDaily: // 0
172 list.append( "0" ); 172 list.append( "0" );
173 list.append( QString::number( rec->frequency() ));//12 173 list.append( QString::number( rec->frequency() ));//12
174 list.append( "0" ); 174 list.append( "0" );
175 list.append( "0" ); 175 list.append( "0" );
176 writeEndDate = true; 176 writeEndDate = true;
177 break; 177 break;
178 case Recurrence::rWeekly:// 1 178 case Recurrence::rWeekly:// 1
179 list.append( "1" ); 179 list.append( "1" );
180 list.append( QString::number( rec->frequency()) );//12 180 list.append( QString::number( rec->frequency()) );//12
181 list.append( "0" ); 181 list.append( "0" );
182 { 182 {
183 int days = 0; 183 int days = 0;
184 QBitArray weekDays = rec->days(); 184 QBitArray weekDays = rec->days();
185 int i; 185 int i;
186 for( i = 1; i <= 7; ++i ) { 186 for( i = 1; i <= 7; ++i ) {
187 if ( weekDays[i-1] ) { 187 if ( weekDays[i-1] ) {
188 days += 1 << (i-1); 188 days += 1 << (i-1);
189 } 189 }
190 } 190 }
191 list.append( QString::number( days ) ); 191 list.append( QString::number( days ) );
192 } 192 }
193 //pending weekdays 193 //pending weekdays
194 writeEndDate = true; 194 writeEndDate = true;
195 195
196 break; 196 break;
197 case Recurrence::rMonthlyPos:// 2 197 case Recurrence::rMonthlyPos:// 2
198 list.append( "2" ); 198 list.append( "2" );
199 list.append( QString::number( rec->frequency()) );//12 199 list.append( QString::number( rec->frequency()) );//12
200 200
201 writeEndDate = true; 201 writeEndDate = true;
202 { 202 {
203 int count = 1; 203 int count = 1;
204 QPtrList<Recurrence::rMonthPos> rmp; 204 QPtrList<Recurrence::rMonthPos> rmp;
205 rmp = rec->monthPositions(); 205 rmp = rec->monthPositions();
206 if ( rmp.first()->negative ) 206 if ( rmp.first()->negative )
207 count = 5 - rmp.first()->rPos - 1; 207 count = 5 - rmp.first()->rPos - 1;
208 else 208 else
209 count = rmp.first()->rPos - 1; 209 count = rmp.first()->rPos - 1;
210 list.append( QString::number( count ) ); 210 list.append( QString::number( count ) );
211 211
212 } 212 }
213 213
214 list.append( "0" ); 214 list.append( "0" );
215 break; 215 break;
216 case Recurrence::rMonthlyDay:// 3 216 case Recurrence::rMonthlyDay:// 3
217 list.append( "3" ); 217 list.append( "3" );
218 list.append( QString::number( rec->frequency()) );//12 218 list.append( QString::number( rec->frequency()) );//12
219 list.append( "0" ); 219 list.append( "0" );
220 list.append( "0" ); 220 list.append( "0" );
221 writeEndDate = true; 221 writeEndDate = true;
222 break; 222 break;
223 case Recurrence::rYearlyMonth://4 223 case Recurrence::rYearlyMonth://4
224 list.append( "4" ); 224 list.append( "4" );
225 list.append( QString::number( rec->frequency()) );//12 225 list.append( QString::number( rec->frequency()) );//12
226 list.append( "0" ); 226 list.append( "0" );
227 list.append( "0" ); 227 list.append( "0" );
228 writeEndDate = true; 228 writeEndDate = true;
229 break; 229 break;
230 230
231 default: 231 default:
232 list.append( "255" ); 232 list.append( "255" );
233 list.append( QString() ); 233 list.append( QString() );
234 list.append( "0" ); 234 list.append( "0" );
235 list.append( QString() ); 235 list.append( QString() );
236 list.append( "0" ); 236 list.append( "0" );
237 list.append( "20991231T000000" ); 237 list.append( "20991231T000000" );
238 break; 238 break;
239 } 239 }
240 if ( writeEndDate ) { 240 if ( writeEndDate ) {
241 241
242 if ( rec->endDate().isValid() ) { // 15 + 16 242 if ( rec->endDate().isValid() ) { // 15 + 16
243 list.append( "1" ); 243 list.append( "1" );
244 list.append( PhoneParser::dtToString( rec->endDate()) ); 244 list.append( PhoneParser::dtToString( rec->endDate()) );
245 } else { 245 } else {
246 list.append( "0" ); 246 list.append( "0" );
247 list.append( "20991231T000000" ); 247 list.append( "20991231T000000" );
248 } 248 }
249 249
250 } 250 }
251 attList << list.join(""); 251 attList << list.join("");
252 attList << event->categoriesStr(); 252 attList << event->categoriesStr();
253 //qDebug("csum cat %s", event->categoriesStr().latin1()); 253 //qDebug("csum cat %s", event->categoriesStr().latin1());
254 254
255 attList << event->secrecyStr(); 255 attList << event->secrecyStr();
256 return PhoneFormat::getCsum(attList ); 256 return PhoneFormat::getCsum(attList );
257} 257}
258ulong PhoneFormat::getCsum( const QStringList & attList) 258ulong PhoneFormat::getCsum( const QStringList & attList)
259{ 259{
260 int max = attList.count(); 260 int max = attList.count();
261 ulong cSum = 0; 261 ulong cSum = 0;
262 int j,k,i; 262 int j,k,i;
263 int add; 263 int add;
264 for ( i = 0; i < max ; ++i ) { 264 for ( i = 0; i < max ; ++i ) {
265 QString s = attList[i]; 265 QString s = attList[i];
266 if ( ! s.isEmpty() ){ 266 if ( ! s.isEmpty() ){
267 j = s.length(); 267 j = s.length();
268 for ( k = 0; k < j; ++k ) { 268 for ( k = 0; k < j; ++k ) {
269 int mul = k +1; 269 int mul = k +1;
270 add = s[k].unicode (); 270 add = s[k].unicode ();
271 if ( k < 16 ) 271 if ( k < 16 )
272 mul = mul * mul; 272 mul = mul * mul;
273 int ii = i+1; 273 int ii = i+1;
274 add = add * mul *ii*ii*ii; 274 add = add * mul *ii*ii*ii;
275 cSum += add; 275 cSum += add;
276 } 276 }
277 } 277 }
278 if ( i == 0 )
279 qDebug("csum: i == 0 %d ", cSum);
280 278
281 } 279 }
282 QString dump = attList.join(","); 280 QString dump = attList.join(",");
283 qDebug("csum: %d %s", cSum,dump.latin1()); 281 qDebug("csum: %d %s", cSum,dump.latin1());
284 282
285 return cSum; 283 return cSum;
286 284
287} 285}
288//extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum); 286//extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum);
289#include <stdlib.h> 287#include <stdlib.h>
290#define DEBUGMODE false 288#define DEBUGMODE false
291bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) 289bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal)
292{ 290{
293 291
294 QString fileName; 292 QString fileName;
295#ifdef _WIN32_ 293#ifdef _WIN32_
296 fileName = locateLocal("data", "korganizer") + "\\tempfile.vcs"; 294 fileName = locateLocal("data", "korganizer") + "\\tempfile.vcs";
297#else 295#else
298 fileName = "/tmp/kdepimtemp.vcs"; 296 fileName = "/tmp/kdepimtemp.vcs";
299#endif 297#endif
300 QString command ="./kammu --backup " + fileName + " -yes" ; 298 QString command ="./kammu --backup " + fileName + " -yes" ;
301 int ret = system ( command.latin1() ); 299 int ret = system ( command.latin1() );
302 if ( ret != 0 ) { 300 if ( ret != 0 ) {
303 qDebug("Error::command returned %d", ret); 301 qDebug("Error::command returned %d", ret);
304 return false; 302 return false;
305 } 303 }
306 qDebug("Command returned %d", ret); 304 qDebug("Command returned %d", ret);
307 VCalFormat vfload; 305 VCalFormat vfload;
308 vfload.setLocalTime ( true ); 306 vfload.setLocalTime ( true );
309 qDebug("loading file ..."); 307 qDebug("loading file ...");
310 308
311 if ( ! vfload.load( calendar, fileName ) ) 309 if ( ! vfload.load( calendar, fileName ) )
312 return false; 310 return false;
313 QPtrList<Event> er = calendar->rawEvents(); 311 QPtrList<Event> er = calendar->rawEvents();
314 Event* ev = er.first(); 312 Event* ev = er.first();
315 qDebug("reading events... "); 313 qDebug("reading events... ");
316 while ( ev ) { 314 while ( ev ) {
317 QStringList cat = ev->categories(); 315 QStringList cat = ev->categories();
318 if ( cat.contains( "MeetingDEF" )) { 316 if ( cat.contains( "MeetingDEF" )) {
319 ev->setCategories( QStringList() ); 317 ev->setCategories( QStringList() );
320 } 318 }
321 int id = ev->pilotId(); 319 int id = ev->pilotId();
322 Event *event; 320 Event *event;
323 event = existingCal->event( mProfileName ,QString::number( id ) ); 321 event = existingCal->event( mProfileName ,QString::number( id ) );
324 if ( event ) { 322 if ( event ) {
325 event = (Event*)event->clone(); 323 event = (Event*)event->clone();
326 copyEvent( event, ev ); 324 copyEvent( event, ev );
327 calendar->deleteEvent( ev ); 325 calendar->deleteEvent( ev );
328 calendar->addEvent( event); 326 calendar->addEvent( event);
329 } 327 }
330 else 328 else
331 event = ev; 329 event = ev;
332 uint cSum; 330 uint cSum;
333 cSum = PhoneFormat::getCsumEvent( event ); 331 cSum = PhoneFormat::getCsumEvent( event );
334 event->setCsum( mProfileName, QString::number( cSum )); 332 event->setCsum( mProfileName, QString::number( cSum ));
335 event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); 333 event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
336 event->setID( mProfileName,QString::number( id ) ); 334 event->setID( mProfileName,QString::number( id ) );
337 ev = er.next(); 335 ev = er.next();
338 } 336 }
339 { 337 {
340 qDebug("reading todos... "); 338 qDebug("reading todos... ");
341 QPtrList<Todo> tr = calendar->rawTodos(); 339 QPtrList<Todo> tr = calendar->rawTodos();
342 Todo* ev = tr.first(); 340 Todo* ev = tr.first();
343 while ( ev ) { 341 while ( ev ) {
344 342
345 QStringList cat = ev->categories(); 343 QStringList cat = ev->categories();
346 if ( cat.contains( "MeetingDEF" )) { 344 if ( cat.contains( "MeetingDEF" )) {
347 ev->setCategories( QStringList() ); 345 ev->setCategories( QStringList() );
348 } 346 }
349 int id = ev->pilotId(); 347 int id = ev->pilotId();
350 Todo *event; 348 Todo *event;
351 event = existingCal->todo( mProfileName ,QString::number( id ) ); 349 event = existingCal->todo( mProfileName ,QString::number( id ) );
352 if ( event ) { 350 if ( event ) {
353 qDebug("copy todo %s ", event->summary().latin1()); 351 qDebug("copy todo %s ", event->summary().latin1());
354 352
355 event = (Todo*)event->clone(); 353 event = (Todo*)event->clone();
356 copyTodo( event, ev ); 354 copyTodo( event, ev );
357 calendar->deleteTodo( ev ); 355 calendar->deleteTodo( ev );
358 calendar->addTodo( event); 356 calendar->addTodo( event);
359 } 357 }
360 else 358 else
361 event = ev; 359 event = ev;
362 uint cSum; 360 uint cSum;
363 cSum = PhoneFormat::getCsumTodo( event ); 361 cSum = PhoneFormat::getCsumTodo( event );
364 event->setCsum( mProfileName, QString::number( cSum )); 362 event->setCsum( mProfileName, QString::number( cSum ));
365 event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); 363 event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
366 event->setID( mProfileName,QString::number( id ) ); 364 event->setID( mProfileName,QString::number( id ) );
367 ev = tr.next(); 365 ev = tr.next();
368 } 366 }
369 } 367 }
370 return true; 368 return true;
371} 369}
372void PhoneFormat::copyEvent( Event* to, Event* from ) 370void PhoneFormat::copyEvent( Event* to, Event* from )
373{ 371{
374 if ( from->dtStart().isValid() ) 372 if ( from->dtStart().isValid() )
375 to->setDtStart( from->dtStart() ); 373 to->setDtStart( from->dtStart() );
376 if ( from->dtEnd().isValid() ) 374 if ( from->dtEnd().isValid() )
377 to->setDtEnd( from->dtEnd() ); 375 to->setDtEnd( from->dtEnd() );
378 if ( !from->location().isEmpty() ) 376 if ( !from->location().isEmpty() )
379 to->setLocation( from->location() ); 377 to->setLocation( from->location() );
380 if ( !from->description().isEmpty() ) 378 if ( !from->description().isEmpty() )
381 to->setDescription( from->description() ); 379 to->setDescription( from->description() );
382 if ( !from->summary().isEmpty() ) 380 if ( !from->summary().isEmpty() )
383 to->setSummary( from->summary() ); 381 to->setSummary( from->summary() );
384 382
385 QPtrListIterator<Alarm> it( from->alarms() ); 383 QPtrListIterator<Alarm> it( from->alarms() );
386 if ( it.current() ) 384 if ( it.current() )
387 to->clearAlarms(); 385 to->clearAlarms();
388 const Alarm *a; 386 const Alarm *a;
389 while( (a = it.current()) ) { 387 while( (a = it.current()) ) {
390 Alarm *b = new Alarm( *a ); 388 Alarm *b = new Alarm( *a );
391 b->setParent( to ); 389 b->setParent( to );
392 to->addAlarm( b ); 390 to->addAlarm( b );
393 ++it; 391 ++it;
394 } 392 }
395 QStringList cat = to->categories(); 393 QStringList cat = to->categories();
396 QStringList catFrom = from->categories(); 394 QStringList catFrom = from->categories();
397 QString nCat; 395 QString nCat;
398 int iii; 396 int iii;
399 for ( iii = 0; iii < catFrom.count();++iii ) { 397 for ( iii = 0; iii < catFrom.count();++iii ) {
400 nCat = catFrom[iii]; 398 nCat = catFrom[iii];
401 if ( !nCat.isEmpty() ) 399 if ( !nCat.isEmpty() )
402 if ( !cat.contains( nCat )) { 400 if ( !cat.contains( nCat )) {
403 cat << nCat; 401 cat << nCat;
404 } 402 }
405 } 403 }
406 to->setCategories( cat ); 404 to->setCategories( cat );
407 Recurrence * r = new Recurrence( *from->recurrence(),to); 405 Recurrence * r = new Recurrence( *from->recurrence(),to);
408 to->setRecurrence( r ) ; 406 to->setRecurrence( r ) ;
409 407
410 408
411} 409}
412void PhoneFormat::copyTodo( Todo* to, Todo* from ) 410void PhoneFormat::copyTodo( Todo* to, Todo* from )
413{ 411{
414 if ( from->dtStart().isValid() ) 412 if ( from->dtStart().isValid() )
415 to->setDtStart( from->dtStart() ); 413 to->setDtStart( from->dtStart() );
416 if ( from->dtDue().isValid() ) 414 if ( from->dtDue().isValid() )
417 to->setDtDue( from->dtDue() ); 415 to->setDtDue( from->dtDue() );
418 if ( !from->location().isEmpty() ) 416 if ( !from->location().isEmpty() )
419 to->setLocation( from->location() ); 417 to->setLocation( from->location() );
420 if ( !from->description().isEmpty() ) 418 if ( !from->description().isEmpty() )
421 to->setDescription( from->description() ); 419 to->setDescription( from->description() );
422 if ( !from->summary().isEmpty() ) 420 if ( !from->summary().isEmpty() )
423 to->setSummary( from->summary() ); 421 to->setSummary( from->summary() );
424 422
425 QPtrListIterator<Alarm> it( from->alarms() ); 423 QPtrListIterator<Alarm> it( from->alarms() );
426 if ( it.current() ) 424 if ( it.current() )
427 to->clearAlarms(); 425 to->clearAlarms();
428 const Alarm *a; 426 const Alarm *a;
429 while( (a = it.current()) ) { 427 while( (a = it.current()) ) {
430 Alarm *b = new Alarm( *a ); 428 Alarm *b = new Alarm( *a );
431 b->setParent( to ); 429 b->setParent( to );
432 to->addAlarm( b ); 430 to->addAlarm( b );
433 ++it; 431 ++it;
434 } 432 }
435 QStringList cat = to->categories(); 433 QStringList cat = to->categories();
436 QStringList catFrom = from->categories(); 434 QStringList catFrom = from->categories();
437 QString nCat; 435 QString nCat;
438 int iii; 436 int iii;
439 for ( iii = 0; iii < catFrom.count();++iii ) { 437 for ( iii = 0; iii < catFrom.count();++iii ) {
440 nCat = catFrom[iii]; 438 nCat = catFrom[iii];
441 if ( !nCat.isEmpty() ) 439 if ( !nCat.isEmpty() )
442 if ( !cat.contains( nCat )) { 440 if ( !cat.contains( nCat )) {
443 cat << nCat; 441 cat << nCat;
444 } 442 }
445 } 443 }
446 to->setCategories( cat ); 444 to->setCategories( cat );
447 if ( from->isCompleted() ) { 445 if ( from->isCompleted() ) {
448 to->setCompleted( true ); 446 to->setCompleted( true );
449 if( from->completed().isValid() ) 447 if( from->completed().isValid() )
450 to->setCompleted( from->completed() ); 448 to->setCompleted( from->completed() );
451 } else { 449 } else {
452 // set percentcomplete only, if to->isCompleted() 450 // set percentcomplete only, if to->isCompleted()
453 if ( to->isCompleted() ) 451 if ( to->isCompleted() )
454 to->setPercentComplete(from->percentComplete()); 452 to->setPercentComplete(from->percentComplete());
455 } 453 }
456 if( to->priority() == 2 && from->priority() == 1 ) 454 if( to->priority() == 2 && from->priority() == 1 )
457 ; //skip 455 ; //skip
458 else if (to->priority() == 4 && from->priority() == 5 ) 456 else if (to->priority() == 4 && from->priority() == 5 )
459 ; 457 ;
460 else 458 else
461 to->setPriority(from->priority()); 459 to->setPriority(from->priority());
462 460
463} 461}
464#include <qcstring.h> 462#include <qcstring.h>
465 463
466void PhoneFormat::afterSave( Incidence* inc) 464void PhoneFormat::afterSave( Incidence* inc)
467{ 465{
468 uint csum; 466 uint csum;
469 inc->removeID( mProfileName ); 467 inc->removeID( mProfileName );
470#if 0
471 if ( inc->type() == "Event") 468 if ( inc->type() == "Event")
472 csum = PhoneFormat::getCsumEvent( (Event*) inc ); 469 csum = PhoneFormat::getCsumEvent( (Event*) inc );
473 else 470 else
474 csum = PhoneFormat::getCsumTodo( (Todo*) inc ); 471 csum = PhoneFormat::getCsumTodo( (Todo*) inc );
475 inc->setCsum( mProfileName, QString::number( csum )); 472 inc->setCsum( mProfileName, QString::number( csum ));
476#endif 473
477 inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); 474 inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
478 475
479} 476}
480bool PhoneFormat::save( Calendar *calendar) 477bool PhoneFormat::save( Calendar *calendar)
481{ 478{
482 QLabel status ( i18n(" Opening device ..."), 0 ); 479 QLabel status ( i18n(" Opening device ..."), 0 );
483 int w = status.sizeHint().width()+20 ; 480 int w = status.sizeHint().width()+20 ;
484 if ( w < 200 ) w = 230; 481 if ( w < 200 ) w = 230;
485 int h = status.sizeHint().height()+20 ; 482 int h = status.sizeHint().height()+20 ;
486 int dw = QApplication::desktop()->width(); 483 int dw = QApplication::desktop()->width();
487 int dh = QApplication::desktop()->height(); 484 int dh = QApplication::desktop()->height();
488 status.setCaption(i18n("Writing to phone...") ); 485 status.setCaption(i18n("Writing to phone...") );
489 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 486 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
490 status.show(); 487 status.show();
491 status.raise(); 488 status.raise();
492 qApp->processEvents(); 489 qApp->processEvents();
493 QString message; 490 QString message;
494#ifdef _WIN32_ 491#ifdef _WIN32_
495 QString fileName = locateLocal("data", "korganizer") + "\\tempfile.vcs"; 492 QString fileName = locateLocal("data", "korganizer") + "\\tempfile.vcs";
496#else 493#else
497 QString fileName = "/tmp/kdepimtemp.vcs"; 494 QString fileName = "/tmp/kdepimtemp.vcs";
498#endif 495#endif
499 496
500 // 1 remove events which should be deleted 497 // 1 remove events which should be deleted
501 QPtrList<Event> er = calendar->rawEvents(); 498 QPtrList<Event> er = calendar->rawEvents();
502 Event* ev = er.first(); 499 Event* ev = er.first();
503 while ( ev ) { 500 while ( ev ) {
504 if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { 501 if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) {
505 calendar->deleteEvent( ev ); 502 calendar->deleteEvent( ev );
506 } else { 503 } else {
507 504
508 } 505 }
509 ev = er.next(); 506 ev = er.next();
510 } 507 }
511 // 2 remove todos which should be deleted 508 // 2 remove todos which should be deleted
512 QPtrList<Todo> tl = calendar->rawTodos(); 509 QPtrList<Todo> tl = calendar->rawTodos();
513 Todo* to = tl.first(); 510 Todo* to = tl.first();
514 while ( to ) { 511 while ( to ) {
515 if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { 512 if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) {
516 calendar->deleteTodo( to ); 513 calendar->deleteTodo( to );
517 } 514 } else {
515 if ( to->isCompleted()) {
516 calendar->deleteTodo( to );
517 }
518 }
518 to = tl.next(); 519 to = tl.next();
519 } 520 }
520 // 3 save file 521 // 3 save file
521 VCalFormat vfsave; 522 VCalFormat vfsave;
522 vfsave.setLocalTime ( true ); 523 vfsave.setLocalTime ( true );
523 if ( ! vfsave.save( calendar, fileName ) ) 524 if ( ! vfsave.save( calendar, fileName ) )
524 return false; 525 return false;
525 // 4 call kammu 526 // 4 call kammu
526 QString command ="./kammu --restore " + fileName ; 527 QString command ="./kammu --restore " + fileName ;
527 int ret; 528 int ret;
528 while ( (ret = system ( command.latin1())) != 0 ) { 529 while ( (ret = system ( command.latin1())) != 0 ) {
529 qDebug("Error S::command returned %d. asking users", ret); 530 qDebug("Error S::command returned %d. asking users", ret);
530 int retval = KMessageBox::warningContinueCancel(0, 531 int retval = KMessageBox::warningContinueCancel(0,
531 i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KO/Pi phone sync"),i18n("Retry"),i18n("Cancel")); 532 i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KO/Pi phone sync"),i18n("Retry"),i18n("Cancel"));
532 if ( retval != KMessageBox::Continue ) 533 if ( retval != KMessageBox::Continue )
533 return false; 534 return false;
534 } 535 }
535 if ( ret != 0 ) { 536 if ( ret != 0 ) {
536 qDebug("Error S::command returned %d", ret); 537 qDebug("Error S::command returned %d", ret);
537 return false; 538 return false;
538 } 539 }
539 // 5 reread data 540 // 5 reread data
540 message = i18n(" Rereading all data ... "); 541 message = i18n(" Rereading all data ... ");
541 status.setText ( message ); 542 status.setText ( message );
542 qApp->processEvents(); 543 qApp->processEvents();
543 CalendarLocal* calendarTemp = new CalendarLocal(); 544 CalendarLocal* calendarTemp = new CalendarLocal();
544 calendarTemp->setTimeZoneId( calendar->timeZoneId()); 545 calendarTemp->setTimeZoneId( calendar->timeZoneId());
545 if ( ! load( calendarTemp,calendar) ){ 546 if ( ! load( calendarTemp,calendar) ){
546 qDebug("error reloading calendar "); 547 qDebug("error reloading calendar ");
547 delete calendarTemp; 548 delete calendarTemp;
548 return false; 549 return false;
549 } 550 }
550 // 6 compare data 551 // 6 compare data
551 552
552//algo 6 compare event 553//algo 6 compare event
553 er = calendar->rawEvents(); 554 er = calendar->rawEvents();
554 ev = er.first(); 555 ev = er.first();
555 message = i18n(" Comparing event # "); 556 message = i18n(" Comparing event # ");
556 QPtrList<Event> er1 = calendarTemp->rawEvents(); 557 QPtrList<Event> er1 = calendarTemp->rawEvents();
557 Event* ev1; 558 Event* ev1;
558 int procCount = 0; 559 int procCount = 0;
559 while ( ev ) { 560 while ( ev ) {
560 //qDebug("event new ID %s",ev->summary().latin1()); 561 //qDebug("event new ID %s",ev->summary().latin1());
561 status.setText ( message + QString::number ( ++procCount ) ); 562 status.setText ( message + QString::number ( ++procCount ) );
562 qApp->processEvents(); 563 qApp->processEvents();
563 uint csum; 564 uint csum;
564 csum = PhoneFormat::getCsumEvent( ev ); 565 csum = PhoneFormat::getCsumEvent( ev );
565 QString cSum = QString::number( csum ); 566 QString cSum = QString::number( csum );
566 ev->setCsum( mProfileName, cSum ); 567 //ev->setCsum( mProfileName, cSum );
567 //qDebug("Event cSum %s ", cSum.latin1()); 568 //qDebug("Event cSum %s ", cSum.latin1());
568 ev1 = er1.first(); 569 ev1 = er1.first();
569 while ( ev1 ) { 570 while ( ev1 ) {
570 if ( ev1->getCsum( mProfileName ) == cSum ) { 571 if ( ev1->getCsum( mProfileName ) == cSum ) {
571 er1.remove( ev1 ); 572 er1.remove( ev1 );
572 afterSave( ev ); 573 afterSave( ev );
573 ev->setID(mProfileName, ev1->getID(mProfileName) ); 574 ev->setID(mProfileName, ev1->getID(mProfileName) );
574 //qDebug("Event found on phone for %s ", ev->summary().latin1()); 575 //qDebug("Event found on phone for %s ", ev->summary().latin1());
575 576
576 break; 577 break;
577 } 578 }
578 ev1 = er1.next(); 579 ev1 = er1.next();
579 } 580 }
580 if ( ! ev1 ) { 581 if ( ! ev1 ) {
581 ev->removeID(mProfileName); 582 ev->removeID(mProfileName);
582 qDebug("ERROR: No event found on phone for %s ", ev->summary().latin1()); 583 qDebug("ERROR: No event found on phone for %s ", ev->summary().latin1());
583 } 584 }
584 585
585 586
586 ev = er.next(); 587 ev = er.next();
587 } 588 }
588 //algo 6 compare todo 589 //algo 6 compare todo
589 tl = calendar->rawTodos(); 590 tl = calendar->rawTodos();
590 to = tl.first(); 591 to = tl.first();
591 procCount = 0; 592 procCount = 0;
592 QPtrList<Todo> tl1 = calendarTemp->rawTodos(); 593 QPtrList<Todo> tl1 = calendarTemp->rawTodos();
593 Todo* to1 ; 594 Todo* to1 ;
594 message = i18n(" Comparing todo # "); 595 message = i18n(" Comparing todo # ");
595 while ( to ) { 596 while ( to ) {
596 qDebug("todo2 %d ", procCount); 597 qDebug("todo2 %d ", procCount);
597 status.setText ( message + QString::number ( ++procCount ) ); 598 status.setText ( message + QString::number ( ++procCount ) );
598 qApp->processEvents(); 599 qApp->processEvents();
599 uint csum; 600 uint csum;
600 csum = PhoneFormat::getCsumTodo( to ); 601 csum = PhoneFormat::getCsumTodo( to );
601 QString cSum = QString::number( csum ); 602 QString cSum = QString::number( csum );
602 to->setCsum( mProfileName, cSum ); 603 //to->setCsum( mProfileName, cSum );
603 qDebug("Todo cSum %s ", cSum.latin1()); 604 qDebug("Todo cSum %s ", cSum.latin1());
604 Todo* to1 = tl1.first(); 605 Todo* to1 = tl1.first();
605 while ( to1 ) { 606 while ( to1 ) {
606 if ( to1->getCsum( mProfileName ) == cSum ) { 607 if ( to1->getCsum( mProfileName ) == cSum ) {
607 tl1.remove( to1 ); 608 tl1.remove( to1 );
608 afterSave( to ); 609 afterSave( to );
609 to->setID(mProfileName, to1->getID(mProfileName) ); 610 to->setID(mProfileName, to1->getID(mProfileName) );
610 break; 611 break;
611 } 612 }
612 to1 = tl1.next(); 613 to1 = tl1.next();
613 } 614 }
614 if ( ! to1 ) { 615 if ( ! to1 ) {
615 to->removeID(mProfileName); 616 to->removeID(mProfileName);
616 qDebug("ERROR: No todo found on phone for %s ", to->summary().latin1()); 617 qDebug("ERROR: No todo found on phone for %s ", to->summary().latin1());
617 } 618 }
618 619
619 to = tl.next(); 620 to = tl.next();
620 } 621 }
621 delete calendarTemp; 622 delete calendarTemp;
622 return true; 623 return true;
623 624
624 625
625 626
626} 627}
627 628
628 629
629QString PhoneFormat::toString( Calendar * ) 630QString PhoneFormat::toString( Calendar * )
630{ 631{
631 return QString::null; 632 return QString::null;
632} 633}
633bool PhoneFormat::fromString( Calendar *calendar, const QString & text) 634bool PhoneFormat::fromString( Calendar *calendar, const QString & text)
634{ 635{
635 return false; 636 return false;
636} 637}