summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-08 13:31:08 (UTC)
committer zautrix <zautrix>2004-10-08 13:31:08 (UTC)
commitec5bc1b8c708b55884f1e03861204123de097129 (patch) (unidiff)
tree0c5c8a341fd69ed9b45a22a42b9445da8b56a5e8
parent38e390e51967b34d53e19bd275efd1760572cdfb (diff)
downloadkdepimpi-ec5bc1b8c708b55884f1e03861204123de097129.zip
kdepimpi-ec5bc1b8c708b55884f1e03861204123de097129.tar.gz
kdepimpi-ec5bc1b8c708b55884f1e03861204123de097129.tar.bz2
cleanup
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp38
-rw-r--r--korganizer/calendarview.h4
-rw-r--r--korganizer/mainwindow.cpp4
3 files changed, 13 insertions, 33 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 04051a2..0c35bb3 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,3734 +1,3722 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Requires the Qt and KDE widget libraries, available at no cost at 4 Requires the Qt and KDE widget libraries, available at no cost at
5 http://www.troll.no and http://www.kde.org respectively 5 http://www.troll.no and http://www.kde.org respectively
6 6
7 Copyright (c) 1997, 1998, 1999 7 Copyright (c) 1997, 1998, 1999
8 Preston Brown (preston.brown@yale.edu) 8 Preston Brown (preston.brown@yale.edu)
9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) 9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl)
10 Ian Dawes (iadawes@globalserve.net) 10 Ian Dawes (iadawes@globalserve.net)
11 Laszlo Boloni (boloni@cs.purdue.edu) 11 Laszlo Boloni (boloni@cs.purdue.edu)
12 12
13 Copyright (c) 2000, 2001, 2002 13 Copyright (c) 2000, 2001, 2002
14 Cornelius Schumacher <schumacher@kde.org> 14 Cornelius Schumacher <schumacher@kde.org>
15 15
16 This program is free software; you can redistribute it and/or modify 16 This program is free software; you can redistribute it and/or modify
17 it under the terms of the GNU General Public License as published by 17 it under the terms of the GNU General Public License as published by
18 the Free Software Foundation; either version 2 of the License, or 18 the Free Software Foundation; either version 2 of the License, or
19 (at your option) any later version. 19 (at your option) any later version.
20 20
21 This program is distributed in the hope that it will be useful, 21 This program is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of 22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
24 GNU General Public License for more details. 24 GNU General Public License for more details.
25 25
26 You should have received a copy of the GNU General Public License 26 You should have received a copy of the GNU General Public License
27 along with this program; if not, write to the Free Software 27 along with this program; if not, write to the Free Software
28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29*/ 29*/
30 30
31#include <stdlib.h> 31#include <stdlib.h>
32 32
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qradiobutton.h> 34#include <qradiobutton.h>
35#include <qbuttongroup.h> 35#include <qbuttongroup.h>
36#include <qlayout.h> 36#include <qlayout.h>
37#include <qclipboard.h> 37#include <qclipboard.h>
38#include <qcursor.h> 38#include <qcursor.h>
39#include <qmessagebox.h> 39#include <qmessagebox.h>
40#include <qprogressbar.h> 40#include <qprogressbar.h>
41#include <qmultilineedit.h> 41#include <qmultilineedit.h>
42#include <qtimer.h> 42#include <qtimer.h>
43#include <qwidgetstack.h> 43#include <qwidgetstack.h>
44#include <qptrlist.h> 44#include <qptrlist.h>
45#include <qregexp.h> 45#include <qregexp.h>
46#include <qgroupbox.h> 46#include <qgroupbox.h>
47#include <qfile.h> 47#include <qfile.h>
48#include <qdir.h> 48#include <qdir.h>
49#ifndef KORG_NOSPLITTER 49#ifndef KORG_NOSPLITTER
50#include <qsplitter.h> 50#include <qsplitter.h>
51#endif 51#endif
52 52
53#include <kglobal.h> 53#include <kglobal.h>
54#include <kdebug.h> 54#include <kdebug.h>
55#include <kstandarddirs.h> 55#include <kstandarddirs.h>
56#include <kfiledialog.h> 56#include <kfiledialog.h>
57#include <kmessagebox.h> 57#include <kmessagebox.h>
58#include <knotifyclient.h> 58#include <knotifyclient.h>
59#include <kconfig.h> 59#include <kconfig.h>
60 60
61#include <libkdepim/ksyncprefsdialog.h> 61#include <libkdepim/ksyncprefsdialog.h>
62#include <krun.h> 62#include <krun.h>
63#include <kdirwatch.h> 63#include <kdirwatch.h>
64#include <libkdepim/kdatepicker.h> 64#include <libkdepim/kdatepicker.h>
65#include <libkdepim/ksyncprofile.h> 65#include <libkdepim/ksyncprofile.h>
66#include <libkdepim/kpimglobalprefs.h> 66#include <libkdepim/kpimglobalprefs.h>
67 67
68#include <libkcal/vcaldrag.h> 68#include <libkcal/vcaldrag.h>
69#include <libkcal/icaldrag.h> 69#include <libkcal/icaldrag.h>
70#include <libkcal/icalformat.h> 70#include <libkcal/icalformat.h>
71#include <libkcal/vcalformat.h> 71#include <libkcal/vcalformat.h>
72#include <libkcal/scheduler.h> 72#include <libkcal/scheduler.h>
73#include <libkcal/calendarlocal.h> 73#include <libkcal/calendarlocal.h>
74#include <libkcal/journal.h> 74#include <libkcal/journal.h>
75#include <libkcal/calfilter.h> 75#include <libkcal/calfilter.h>
76#include <libkcal/attendee.h> 76#include <libkcal/attendee.h>
77#include <libkcal/dndfactory.h> 77#include <libkcal/dndfactory.h>
78#include <libkcal/freebusy.h> 78#include <libkcal/freebusy.h>
79#include <libkcal/filestorage.h> 79#include <libkcal/filestorage.h>
80#include <libkcal/calendarresources.h> 80#include <libkcal/calendarresources.h>
81#include <libkcal/qtopiaformat.h> 81#include <libkcal/qtopiaformat.h>
82#include "../kalarmd/alarmdialog.h" 82#include "../kalarmd/alarmdialog.h"
83 83
84#ifndef DESKTOP_VERSION 84#ifndef DESKTOP_VERSION
85#include <libkcal/sharpformat.h> 85#include <libkcal/sharpformat.h>
86#include <externalapphandler.h> 86#include <externalapphandler.h>
87#endif 87#endif
88#include <libkcal/phoneformat.h> 88#include <libkcal/phoneformat.h>
89#ifndef KORG_NOMAIL 89#ifndef KORG_NOMAIL
90#include "komailclient.h" 90#include "komailclient.h"
91#endif 91#endif
92#ifndef KORG_NOPRINTER 92#ifndef KORG_NOPRINTER
93#include "calprinter.h" 93#include "calprinter.h"
94#endif 94#endif
95#ifndef KORG_NOPLUGINS 95#ifndef KORG_NOPLUGINS
96#include "kocore.h" 96#include "kocore.h"
97#endif 97#endif
98#include "koeventeditor.h" 98#include "koeventeditor.h"
99#include "kotodoeditor.h" 99#include "kotodoeditor.h"
100#include "koprefs.h" 100#include "koprefs.h"
101#include "koeventviewerdialog.h" 101#include "koeventviewerdialog.h"
102#include "publishdialog.h" 102#include "publishdialog.h"
103#include "kofilterview.h" 103#include "kofilterview.h"
104#include "koglobals.h" 104#include "koglobals.h"
105#include "koviewmanager.h" 105#include "koviewmanager.h"
106#include "koagendaview.h" 106#include "koagendaview.h"
107#include "kodialogmanager.h" 107#include "kodialogmanager.h"
108#include "outgoingdialog.h" 108#include "outgoingdialog.h"
109#include "incomingdialog.h" 109#include "incomingdialog.h"
110#include "statusdialog.h" 110#include "statusdialog.h"
111#include "kdatenavigator.h" 111#include "kdatenavigator.h"
112#include "kotodoview.h" 112#include "kotodoview.h"
113#include "datenavigator.h" 113#include "datenavigator.h"
114#include "resourceview.h" 114#include "resourceview.h"
115#include "navigatorbar.h" 115#include "navigatorbar.h"
116#include "searchdialog.h" 116#include "searchdialog.h"
117#include "mainwindow.h" 117#include "mainwindow.h"
118 118
119#include "calendarview.h" 119#include "calendarview.h"
120#ifndef DESKTOP_VERSION 120#ifndef DESKTOP_VERSION
121#include <qtopia/alarmserver.h> 121#include <qtopia/alarmserver.h>
122#endif 122#endif
123#ifndef _WIN32_ 123#ifndef _WIN32_
124#include <stdlib.h> 124#include <stdlib.h>
125#include <stdio.h> 125#include <stdio.h>
126#include <unistd.h> 126#include <unistd.h>
127#else 127#else
128#include <qprocess.h> 128#include <qprocess.h>
129#endif 129#endif
130 130
131#ifdef DESKTOP_VERSION 131#ifdef DESKTOP_VERSION
132#include <kabc/stdaddressbook.h> 132#include <kabc/stdaddressbook.h>
133#endif 133#endif
134using namespace KOrg; 134using namespace KOrg;
135using namespace KCal; 135using namespace KCal;
136extern int globalFlagBlockAgenda; 136extern int globalFlagBlockAgenda;
137extern int globalFlagBlockStartup; 137extern int globalFlagBlockStartup;
138 138
139 139
140 140
141class KOBeamPrefs : public QDialog 141class KOBeamPrefs : public QDialog
142{ 142{
143 public: 143 public:
144 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : 144 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) :
145 QDialog( parent, name, true ) 145 QDialog( parent, name, true )
146 { 146 {
147 setCaption( i18n("Beam Options") ); 147 setCaption( i18n("Beam Options") );
148 QVBoxLayout* lay = new QVBoxLayout( this ); 148 QVBoxLayout* lay = new QVBoxLayout( this );
149 lay->setSpacing( 3 ); 149 lay->setSpacing( 3 );
150 lay->setMargin( 3 ); 150 lay->setMargin( 3 );
151 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); 151 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this );
152 lay->addWidget( format ); 152 lay->addWidget( format );
153 format->setExclusive ( true ) ; 153 format->setExclusive ( true ) ;
154 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); 154 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this );
155 lay->addWidget( time ); time->setExclusive ( true ) ; 155 lay->addWidget( time ); time->setExclusive ( true ) ;
156 vcal = new QRadioButton(" vCalendar ", format ); 156 vcal = new QRadioButton(" vCalendar ", format );
157 ical = new QRadioButton(" iCalendar ", format ); 157 ical = new QRadioButton(" iCalendar ", format );
158 vcal->setChecked( true ); 158 vcal->setChecked( true );
159 tz = new QRadioButton(i18n(" With timezone "), time ); 159 tz = new QRadioButton(i18n(" With timezone "), time );
160 local = new QRadioButton(i18n(" Local time "), time ); 160 local = new QRadioButton(i18n(" Local time "), time );
161 tz->setChecked( true ); 161 tz->setChecked( true );
162 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); 162 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this );
163 lay->addWidget( ok ); 163 lay->addWidget( ok );
164 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 164 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
165 lay->addWidget( cancel ); 165 lay->addWidget( cancel );
166 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 166 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
167 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 167 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
168 resize( 200, 200 ); 168 resize( 200, 200 );
169 } 169 }
170 170
171 bool beamVcal() { return vcal->isChecked(); } 171 bool beamVcal() { return vcal->isChecked(); }
172 bool beamLocal() { return local->isChecked(); } 172 bool beamLocal() { return local->isChecked(); }
173private: 173private:
174 QRadioButton* vcal, *ical, *local, *tz; 174 QRadioButton* vcal, *ical, *local, *tz;
175}; 175};
176class KOCatPrefs : public QDialog 176class KOCatPrefs : public QDialog
177{ 177{
178 public: 178 public:
179 KOCatPrefs( QWidget *parent=0, const char *name=0 ) : 179 KOCatPrefs( QWidget *parent=0, const char *name=0 ) :
180 QDialog( parent, name, true ) 180 QDialog( parent, name, true )
181 { 181 {
182 setCaption( i18n("Manage new Categories") ); 182 setCaption( i18n("Manage new Categories") );
183 QVBoxLayout* lay = new QVBoxLayout( this ); 183 QVBoxLayout* lay = new QVBoxLayout( this );
184 lay->setSpacing( 3 ); 184 lay->setSpacing( 3 );
185 lay->setMargin( 3 ); 185 lay->setMargin( 3 );
186 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); 186 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this );
187 lay->addWidget( lab ); 187 lay->addWidget( lab );
188 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 188 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
189 lay->addWidget( format ); 189 lay->addWidget( format );
190 format->setExclusive ( true ) ; 190 format->setExclusive ( true ) ;
191 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 191 addCatBut = new QRadioButton(i18n("Add to category list"), format );
192 new QRadioButton(i18n("Remove from Events/Todos"), format ); 192 new QRadioButton(i18n("Remove from Events/Todos"), format );
193 addCatBut->setChecked( true ); 193 addCatBut->setChecked( true );
194 QPushButton * ok = new QPushButton( i18n("OK"), this ); 194 QPushButton * ok = new QPushButton( i18n("OK"), this );
195 lay->addWidget( ok ); 195 lay->addWidget( ok );
196 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 196 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
197 lay->addWidget( cancel ); 197 lay->addWidget( cancel );
198 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 198 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
199 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 199 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
200 resize( 200, 200 ); 200 resize( 200, 200 );
201 } 201 }
202 202
203 bool addCat() { return addCatBut->isChecked(); } 203 bool addCat() { return addCatBut->isChecked(); }
204private: 204private:
205 QRadioButton* addCatBut; 205 QRadioButton* addCatBut;
206}; 206};
207 207
208 208
209 209
210CalendarView::CalendarView( CalendarResources *calendar, 210CalendarView::CalendarView( CalendarResources *calendar,
211 QWidget *parent, const char *name ) 211 QWidget *parent, const char *name )
212 : CalendarViewBase( parent, name ), 212 : CalendarViewBase( parent, name ),
213 mCalendar( calendar ), 213 mCalendar( calendar ),
214 mResourceManager( calendar->resourceManager() ) 214 mResourceManager( calendar->resourceManager() )
215{ 215{
216 216
217 mEventEditor = 0; 217 mEventEditor = 0;
218 mTodoEditor = 0; 218 mTodoEditor = 0;
219 219
220 init(); 220 init();
221} 221}
222 222
223CalendarView::CalendarView( Calendar *calendar, 223CalendarView::CalendarView( Calendar *calendar,
224 QWidget *parent, const char *name ) 224 QWidget *parent, const char *name )
225 : CalendarViewBase( parent, name ), 225 : CalendarViewBase( parent, name ),
226 mCalendar( calendar ), 226 mCalendar( calendar ),
227 mResourceManager( 0 ) 227 mResourceManager( 0 )
228{ 228{
229 229
230 mEventEditor = 0; 230 mEventEditor = 0;
231 mTodoEditor = 0; 231 mTodoEditor = 0;
232 init();} 232 init();}
233 233
234void CalendarView::init() 234void CalendarView::init()
235{ 235{
236 beamDialog = new KOBeamPrefs(); 236 beamDialog = new KOBeamPrefs();
237 mDatePickerMode = 0; 237 mDatePickerMode = 0;
238 mCurrentSyncDevice = ""; 238 mCurrentSyncDevice = "";
239 writeLocale(); 239 writeLocale();
240 mViewManager = new KOViewManager( this ); 240 mViewManager = new KOViewManager( this );
241 mDialogManager = new KODialogManager( this ); 241 mDialogManager = new KODialogManager( this );
242 mEventViewerDialog = 0; 242 mEventViewerDialog = 0;
243 mModified = false; 243 mModified = false;
244 mReadOnly = false; 244 mReadOnly = false;
245 mSelectedIncidence = 0; 245 mSelectedIncidence = 0;
246 mCalPrinter = 0; 246 mCalPrinter = 0;
247 mFilters.setAutoDelete(true); 247 mFilters.setAutoDelete(true);
248 248
249 mCalendar->registerObserver( this ); 249 mCalendar->registerObserver( this );
250 // TODO: Make sure that view is updated, when calendar is changed. 250 // TODO: Make sure that view is updated, when calendar is changed.
251 251
252 mStorage = new FileStorage( mCalendar ); 252 mStorage = new FileStorage( mCalendar );
253 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 253 mNavigator = new DateNavigator( this, "datevav", mViewManager );
254 254
255 QBoxLayout *topLayout = (QBoxLayout*)layout(); 255 QBoxLayout *topLayout = (QBoxLayout*)layout();
256#ifndef KORG_NOSPLITTER 256#ifndef KORG_NOSPLITTER
257 // create the main layout frames. 257 // create the main layout frames.
258 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 258 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
259 topLayout->addWidget(mPanner); 259 topLayout->addWidget(mPanner);
260 260
261 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 261 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
262 "CalendarView::LeftFrame"); 262 "CalendarView::LeftFrame");
263 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 263 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
264 264
265 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, 265 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE,
266 "CalendarView::DateNavigator", QDate::currentDate() ); 266 "CalendarView::DateNavigator", QDate::currentDate() );
267 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 267 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
268 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 268 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
269 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 269 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
270 270
271#ifdef KORG_NORESOURCEVIEW 271#ifdef KORG_NORESOURCEVIEW
272 mResourceView = 0; 272 mResourceView = 0;
273#else 273#else
274 if ( mResourceManager ) { 274 if ( mResourceManager ) {
275 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 275 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
276 mResourceView->updateView(); 276 mResourceView->updateView();
277 connect( mResourceView, SIGNAL( resourcesChanged() ), 277 connect( mResourceView, SIGNAL( resourcesChanged() ),
278 SLOT( updateView() ) ); 278 SLOT( updateView() ) );
279 } else { 279 } else {
280 mResourceView = 0; 280 mResourceView = 0;
281 } 281 }
282#endif 282#endif
283 QWidget *rightBox = new QWidget( mPanner ); 283 QWidget *rightBox = new QWidget( mPanner );
284 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 284 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
285 285
286 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 286 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
287 rightLayout->addWidget( mNavigatorBar ); 287 rightLayout->addWidget( mNavigatorBar );
288 288
289 mRightFrame = new QWidgetStack( rightBox ); 289 mRightFrame = new QWidgetStack( rightBox );
290 rightLayout->addWidget( mRightFrame, 1 ); 290 rightLayout->addWidget( mRightFrame, 1 );
291 291
292 mLeftFrame = mLeftSplitter; 292 mLeftFrame = mLeftSplitter;
293#else 293#else
294 QWidget *mainBox = new QWidget( this ); 294 QWidget *mainBox = new QWidget( this );
295 QWidget *leftFrame = new QWidget( mainBox ); 295 QWidget *leftFrame = new QWidget( mainBox );
296 296
297 QBoxLayout * mainBoxLayout; 297 QBoxLayout * mainBoxLayout;
298 QBoxLayout * leftFrameLayout; 298 QBoxLayout * leftFrameLayout;
299 if ( KOPrefs::instance()->mVerticalScreen ) { 299 if ( KOPrefs::instance()->mVerticalScreen ) {
300 mainBoxLayout = new QVBoxLayout(mainBox); 300 mainBoxLayout = new QVBoxLayout(mainBox);
301 leftFrameLayout = new QHBoxLayout(leftFrame ); 301 leftFrameLayout = new QHBoxLayout(leftFrame );
302 } else { 302 } else {
303 mainBoxLayout = new QHBoxLayout(mainBox); 303 mainBoxLayout = new QHBoxLayout(mainBox);
304 leftFrameLayout = new QVBoxLayout(leftFrame ); 304 leftFrameLayout = new QVBoxLayout(leftFrame );
305 } 305 }
306 topLayout->addWidget( mainBox ); 306 topLayout->addWidget( mainBox );
307 mainBoxLayout->addWidget (leftFrame); 307 mainBoxLayout->addWidget (leftFrame);
308 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, 308 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE,
309 "CalendarView::DateNavigator", QDate::currentDate()); 309 "CalendarView::DateNavigator", QDate::currentDate());
310 // mDateNavigator->blockSignals( true ); 310 // mDateNavigator->blockSignals( true );
311 leftFrameLayout->addWidget( mDateNavigator ); 311 leftFrameLayout->addWidget( mDateNavigator );
312 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); 312 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView");
313 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolist"); 313 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolist");
314 314
315 if ( QApplication::desktop()->width() < 480 ) { 315 if ( QApplication::desktop()->width() < 480 ) {
316 leftFrameLayout->addWidget(mFilterView); 316 leftFrameLayout->addWidget(mFilterView);
317 leftFrameLayout->addWidget(mTodoList, 2 ); 317 leftFrameLayout->addWidget(mTodoList, 2 );
318 318
319 } else { 319 } else {
320 leftFrameLayout->addWidget(mTodoList,2 ); 320 leftFrameLayout->addWidget(mTodoList,2 );
321 leftFrameLayout->addWidget(mFilterView ); 321 leftFrameLayout->addWidget(mFilterView );
322 } 322 }
323 mFilterView->hide(); 323 mFilterView->hide();
324 QWidget *rightBox = new QWidget( mainBox ); 324 QWidget *rightBox = new QWidget( mainBox );
325 mainBoxLayout->addWidget ( rightBox, 10 ); 325 mainBoxLayout->addWidget ( rightBox, 10 );
326 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 326 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
327 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 327 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
328 mRightFrame = new QWidgetStack( rightBox ); 328 mRightFrame = new QWidgetStack( rightBox );
329 rightLayout->addWidget( mNavigatorBar ); 329 rightLayout->addWidget( mNavigatorBar );
330 rightLayout->addWidget( mRightFrame, 10 ); 330 rightLayout->addWidget( mRightFrame, 10 );
331 331
332 mLeftFrame = leftFrame; 332 mLeftFrame = leftFrame;
333 if ( KOPrefs::instance()->mVerticalScreen ) { 333 if ( KOPrefs::instance()->mVerticalScreen ) {
334 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 334 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
335 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 335 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
336 } else { 336 } else {
337 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 337 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
338 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 338 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
339 } 339 }
340 340
341 //qDebug("Calendarview Size %d %d ", width(), height()); 341 //qDebug("Calendarview Size %d %d ", width(), height());
342#endif 342#endif
343 343
344 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 344 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
345 SLOT( showDates( const KCal::DateList & ) ) ); 345 SLOT( showDates( const KCal::DateList & ) ) );
346 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 346 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
347 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 347 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
348 348
349 connect( mNavigatorBar, SIGNAL( goPrevYear() ), 349 connect( mNavigatorBar, SIGNAL( goPrevYear() ),
350 mNavigator, SLOT( selectPreviousYear() ) ); 350 mNavigator, SLOT( selectPreviousYear() ) );
351 connect( mNavigatorBar, SIGNAL( goNextYear() ), 351 connect( mNavigatorBar, SIGNAL( goNextYear() ),
352 mNavigator, SLOT( selectNextYear() ) ); 352 mNavigator, SLOT( selectNextYear() ) );
353 connect( mNavigatorBar, SIGNAL( goPrevMonth() ), 353 connect( mNavigatorBar, SIGNAL( goPrevMonth() ),
354 mNavigator, SLOT( selectPreviousMonth() ) ); 354 mNavigator, SLOT( selectPreviousMonth() ) );
355 connect( mNavigatorBar, SIGNAL( goNextMonth() ), 355 connect( mNavigatorBar, SIGNAL( goNextMonth() ),
356 mNavigator, SLOT( selectNextMonth() ) ); 356 mNavigator, SLOT( selectNextMonth() ) );
357 357
358 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 358 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
359 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); 359 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) );
360 360
361 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 361 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
362 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 362 mNavigator, SLOT( selectWeek( const QDate & ) ) );
363 363
364 connect( mDateNavigator, SIGNAL( goPrevYear() ), 364 connect( mDateNavigator, SIGNAL( goPrevYear() ),
365 mNavigator, SLOT( selectPreviousYear() ) ); 365 mNavigator, SLOT( selectPreviousYear() ) );
366 connect( mDateNavigator, SIGNAL( goNextYear() ), 366 connect( mDateNavigator, SIGNAL( goNextYear() ),
367 mNavigator, SLOT( selectNextYear() ) ); 367 mNavigator, SLOT( selectNextYear() ) );
368 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 368 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
369 mNavigator, SLOT( selectPreviousMonth() ) ); 369 mNavigator, SLOT( selectPreviousMonth() ) );
370 connect( mDateNavigator, SIGNAL( goNextMonth() ), 370 connect( mDateNavigator, SIGNAL( goNextMonth() ),
371 mNavigator, SLOT( selectNextMonth() ) ); 371 mNavigator, SLOT( selectNextMonth() ) );
372 372
373 connect( mDateNavigator, SIGNAL( goPrevious() ), 373 connect( mDateNavigator, SIGNAL( goPrevious() ),
374 mNavigator, SLOT( selectPrevious() ) ); 374 mNavigator, SLOT( selectPrevious() ) );
375 connect( mDateNavigator, SIGNAL( goNext() ), 375 connect( mDateNavigator, SIGNAL( goNext() ),
376 mNavigator, SLOT( selectNext() ) ); 376 mNavigator, SLOT( selectNext() ) );
377 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 377 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
378 mNavigator, SLOT( slotMonthSelect( int ) ) ); 378 mNavigator, SLOT( slotMonthSelect( int ) ) );
379 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), 379 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ),
380 mNavigator, SLOT( slotMonthSelect( int ) ) ); 380 mNavigator, SLOT( slotMonthSelect( int ) ) );
381 381
382 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 382 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
383 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 383 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
384 384
385 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), 385 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ),
386 SLOT( eventAdded( Event *) ) ); 386 SLOT( eventAdded( Event *) ) );
387 387
388 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 388 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
389 389
390 connect( this, SIGNAL( configChanged() ), 390 connect( this, SIGNAL( configChanged() ),
391 mDateNavigator, SLOT( updateConfig() ) ); 391 mDateNavigator, SLOT( updateConfig() ) );
392 392
393 connect( mTodoList, SIGNAL( newTodoSignal() ), 393 connect( mTodoList, SIGNAL( newTodoSignal() ),
394 SLOT( newTodo() ) ); 394 SLOT( newTodo() ) );
395 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 395 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
396 SLOT( newSubTodo( Todo * ) ) ); 396 SLOT( newSubTodo( Todo * ) ) );
397 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 397 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
398 SLOT( editTodo( Todo * ) ) ); 398 SLOT( editTodo( Todo * ) ) );
399 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 399 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
400 SLOT( showTodo( Todo *) ) ); 400 SLOT( showTodo( Todo *) ) );
401 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 401 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
402 SLOT( deleteTodo( Todo *) ) ); 402 SLOT( deleteTodo( Todo *) ) );
403 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 403 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
404 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 404 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
405 SLOT( purgeCompleted() ) ); 405 SLOT( purgeCompleted() ) );
406 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 406 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
407 SIGNAL( todoModified( Todo *, int ) ) ); 407 SIGNAL( todoModified( Todo *, int ) ) );
408 408
409 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 409 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
410 this, SLOT ( cloneIncidence( Incidence * ) ) ); 410 this, SLOT ( cloneIncidence( Incidence * ) ) );
411 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 411 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
412 this, SLOT (cancelIncidence( Incidence * ) ) ); 412 this, SLOT (cancelIncidence( Incidence * ) ) );
413 413
414 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 414 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
415 this, SLOT ( moveIncidence( Incidence * ) ) ); 415 this, SLOT ( moveIncidence( Incidence * ) ) );
416 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 416 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
417 this, SLOT ( beamIncidence( Incidence * ) ) ); 417 this, SLOT ( beamIncidence( Incidence * ) ) );
418 418
419 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 419 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
420 this, SLOT ( todo_unsub( Todo * ) ) ); 420 this, SLOT ( todo_unsub( Todo * ) ) );
421 421
422 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 422 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
423 SLOT( updateTodo( Todo *, int ) ) ); 423 SLOT( updateTodo( Todo *, int ) ) );
424 connect( this, SIGNAL( todoModified( Todo *, int )), this, 424 connect( this, SIGNAL( todoModified( Todo *, int )), this,
425 SLOT( changeTodoDisplay( Todo *, int ) ) ); 425 SLOT( changeTodoDisplay( Todo *, int ) ) );
426 426
427 427
428 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 428 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
429 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 429 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
430 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 430 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
431 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 431 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
432 432
433 433
434 434
435 435
436 436
437 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 437 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
438 SLOT(checkClipboard())); 438 SLOT(checkClipboard()));
439 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 439 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
440 SLOT( processTodoListSelection( Incidence * ) ) ); 440 SLOT( processTodoListSelection( Incidence * ) ) );
441 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 441 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
442 442
443 // kdDebug() << "CalendarView::CalendarView() done" << endl; 443 // kdDebug() << "CalendarView::CalendarView() done" << endl;
444 444
445 mDateFrame = new QVBox(0,0,WType_Popup); 445 mDateFrame = new QVBox(0,0,WType_Popup);
446 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 446 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
447 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 447 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
448 mDateFrame->setLineWidth(3); 448 mDateFrame->setLineWidth(3);
449 mDateFrame->hide(); 449 mDateFrame->hide();
450 mDateFrame->setCaption( i18n( "Pick a date to display")); 450 mDateFrame->setCaption( i18n( "Pick a date to display"));
451 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 451 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
452 452
453 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 453 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
454 454
455 mEventEditor = mDialogManager->getEventEditor(); 455 mEventEditor = mDialogManager->getEventEditor();
456 mTodoEditor = mDialogManager->getTodoEditor(); 456 mTodoEditor = mDialogManager->getTodoEditor();
457 457
458 mFlagEditDescription = false; 458 mFlagEditDescription = false;
459 459
460 mSuspendTimer = new QTimer( this ); 460 mSuspendTimer = new QTimer( this );
461 mAlarmTimer = new QTimer( this ); 461 mAlarmTimer = new QTimer( this );
462 mRecheckAlarmTimer = new QTimer( this ); 462 mRecheckAlarmTimer = new QTimer( this );
463 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 463 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
464 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 464 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
465 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 465 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
466 mAlarmDialog = new AlarmDialog( this ); 466 mAlarmDialog = new AlarmDialog( this );
467 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 467 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
468 mAlarmDialog->setServerNotification( false ); 468 mAlarmDialog->setServerNotification( false );
469 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 469 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
470 470
471 471
472#ifndef DESKTOP_VERSION 472#ifndef DESKTOP_VERSION
473//US listen for arriving address resultsets 473//US listen for arriving address resultsets
474 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), 474 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)),
475 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 475 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
476#endif 476#endif
477 477
478} 478}
479 479
480 480
481CalendarView::~CalendarView() 481CalendarView::~CalendarView()
482{ 482{
483 // kdDebug() << "~CalendarView()" << endl; 483 // kdDebug() << "~CalendarView()" << endl;
484 //qDebug("CalendarView::~CalendarView() "); 484 //qDebug("CalendarView::~CalendarView() ");
485 delete mDialogManager; 485 delete mDialogManager;
486 delete mViewManager; 486 delete mViewManager;
487 delete mStorage; 487 delete mStorage;
488 delete mDateFrame ; 488 delete mDateFrame ;
489 delete beamDialog; 489 delete beamDialog;
490 //kdDebug() << "~CalendarView() done" << endl; 490 //kdDebug() << "~CalendarView() done" << endl;
491} 491}
492void CalendarView::timerAlarm() 492void CalendarView::timerAlarm()
493{ 493{
494 //qDebug("CalendarView::timerAlarm() "); 494 //qDebug("CalendarView::timerAlarm() ");
495 computeAlarm(mAlarmNotification ); 495 computeAlarm(mAlarmNotification );
496} 496}
497 497
498void CalendarView::suspendAlarm() 498void CalendarView::suspendAlarm()
499{ 499{
500 //qDebug(" CalendarView::suspendAlarm() "); 500 //qDebug(" CalendarView::suspendAlarm() ");
501 computeAlarm(mSuspendAlarmNotification ); 501 computeAlarm(mSuspendAlarmNotification );
502 502
503} 503}
504 504
505void CalendarView::startAlarm( QString mess , QString filename) 505void CalendarView::startAlarm( QString mess , QString filename)
506{ 506{
507 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 507 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
508 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); 508 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
509 509
510} 510}
511 511
512void CalendarView::checkNextTimerAlarm() 512void CalendarView::checkNextTimerAlarm()
513{ 513{
514 mCalendar->checkAlarmForIncidence( 0, true ); 514 mCalendar->checkAlarmForIncidence( 0, true );
515} 515}
516 516
517void CalendarView::computeAlarm( QString msg ) 517void CalendarView::computeAlarm( QString msg )
518{ 518{
519 519
520 QString mess = msg; 520 QString mess = msg;
521 QString mAlarmMessage = mess.mid( 9 ); 521 QString mAlarmMessage = mess.mid( 9 );
522 QString filename = MainWindow::resourcePath(); 522 QString filename = MainWindow::resourcePath();
523 filename += "koalarm.wav"; 523 filename += "koalarm.wav";
524 QString tempfilename; 524 QString tempfilename;
525 if ( mess.left( 13 ) == "suspend_alarm") { 525 if ( mess.left( 13 ) == "suspend_alarm") {
526 bool error = false; 526 bool error = false;
527 int len = mess.mid( 13 ).find("+++"); 527 int len = mess.mid( 13 ).find("+++");
528 if ( len < 2 ) 528 if ( len < 2 )
529 error = true; 529 error = true;
530 else { 530 else {
531 tempfilename = mess.mid( 13, len ); 531 tempfilename = mess.mid( 13, len );
532 if ( !QFile::exists( tempfilename ) ) 532 if ( !QFile::exists( tempfilename ) )
533 error = true; 533 error = true;
534 } 534 }
535 if ( ! error ) { 535 if ( ! error ) {
536 filename = tempfilename; 536 filename = tempfilename;
537 } 537 }
538 mAlarmMessage = mess.mid( 13+len+3 ); 538 mAlarmMessage = mess.mid( 13+len+3 );
539 //qDebug("suspend file %s ",tempfilename.latin1() ); 539 //qDebug("suspend file %s ",tempfilename.latin1() );
540 startAlarm( mAlarmMessage, filename); 540 startAlarm( mAlarmMessage, filename);
541 return; 541 return;
542 } 542 }
543 if ( mess.left( 11 ) == "timer_alarm") { 543 if ( mess.left( 11 ) == "timer_alarm") {
544 //mTimerTime = 0; 544 //mTimerTime = 0;
545 startAlarm( mess.mid( 11 ), filename ); 545 startAlarm( mess.mid( 11 ), filename );
546 return; 546 return;
547 } 547 }
548 if ( mess.left( 10 ) == "proc_alarm") { 548 if ( mess.left( 10 ) == "proc_alarm") {
549 bool error = false; 549 bool error = false;
550 int len = mess.mid( 10 ).find("+++"); 550 int len = mess.mid( 10 ).find("+++");
551 if ( len < 2 ) 551 if ( len < 2 )
552 error = true; 552 error = true;
553 else { 553 else {
554 tempfilename = mess.mid( 10, len ); 554 tempfilename = mess.mid( 10, len );
555 if ( !QFile::exists( tempfilename ) ) 555 if ( !QFile::exists( tempfilename ) )
556 error = true; 556 error = true;
557 } 557 }
558 if ( error ) { 558 if ( error ) {
559 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 559 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
560 mAlarmMessage += mess.mid( 10+len+3+9 ); 560 mAlarmMessage += mess.mid( 10+len+3+9 );
561 } else { 561 } else {
562 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 562 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
563 //qDebug("-----system command %s ",tempfilename.latin1() ); 563 //qDebug("-----system command %s ",tempfilename.latin1() );
564#ifndef _WIN32_ 564#ifndef _WIN32_
565 if ( vfork () == 0 ) { 565 if ( vfork () == 0 ) {
566 execl ( tempfilename.latin1(), 0 ); 566 execl ( tempfilename.latin1(), 0 );
567 return; 567 return;
568 } 568 }
569#else 569#else
570 QProcess* p = new QProcess(); 570 QProcess* p = new QProcess();
571 p->addArgument( tempfilename.latin1() ); 571 p->addArgument( tempfilename.latin1() );
572 p->start(); 572 p->start();
573 return; 573 return;
574#endif 574#endif
575 575
576 return; 576 return;
577 } 577 }
578 578
579 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 579 //qDebug("+++++++system command %s ",tempfilename.latin1() );
580 } 580 }
581 if ( mess.left( 11 ) == "audio_alarm") { 581 if ( mess.left( 11 ) == "audio_alarm") {
582 bool error = false; 582 bool error = false;
583 int len = mess.mid( 11 ).find("+++"); 583 int len = mess.mid( 11 ).find("+++");
584 if ( len < 2 ) 584 if ( len < 2 )
585 error = true; 585 error = true;
586 else { 586 else {
587 tempfilename = mess.mid( 11, len ); 587 tempfilename = mess.mid( 11, len );
588 if ( !QFile::exists( tempfilename ) ) 588 if ( !QFile::exists( tempfilename ) )
589 error = true; 589 error = true;
590 } 590 }
591 if ( ! error ) { 591 if ( ! error ) {
592 filename = tempfilename; 592 filename = tempfilename;
593 } 593 }
594 mAlarmMessage = mess.mid( 11+len+3+9 ); 594 mAlarmMessage = mess.mid( 11+len+3+9 );
595 //qDebug("audio file command %s ",tempfilename.latin1() ); 595 //qDebug("audio file command %s ",tempfilename.latin1() );
596 } 596 }
597 if ( mess.left( 9 ) == "cal_alarm") { 597 if ( mess.left( 9 ) == "cal_alarm") {
598 mAlarmMessage = mess.mid( 9 ) ; 598 mAlarmMessage = mess.mid( 9 ) ;
599 } 599 }
600 600
601 startAlarm( mAlarmMessage, filename ); 601 startAlarm( mAlarmMessage, filename );
602 602
603 603
604} 604}
605 605
606void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 606void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
607{ 607{
608 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 608 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
609 609
610 mSuspendAlarmNotification = noti; 610 mSuspendAlarmNotification = noti;
611 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 611 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
612 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 612 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
613 mSuspendTimer->start( ms , true ); 613 mSuspendTimer->start( ms , true );
614 614
615} 615}
616 616
617void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 617void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
618{ 618{
619 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 619 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
620 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 620 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
621#ifndef DESKTOP_VERSION 621#ifndef DESKTOP_VERSION
622 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); 622 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() );
623#endif 623#endif
624 return; 624 return;
625 } 625 }
626 int maxSec; 626 int maxSec;
627 //maxSec = 5; //testing only 627 //maxSec = 5; //testing only
628 maxSec = 86400+3600; // one day+1hour 628 maxSec = 86400+3600; // one day+1hour
629 mAlarmNotification = noti; 629 mAlarmNotification = noti;
630 int sec = QDateTime::currentDateTime().secsTo( qdt ); 630 int sec = QDateTime::currentDateTime().secsTo( qdt );
631 if ( sec > maxSec ) { 631 if ( sec > maxSec ) {
632 mRecheckAlarmTimer->start( maxSec * 1000 ); 632 mRecheckAlarmTimer->start( maxSec * 1000 );
633 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 633 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
634 return; 634 return;
635 } else { 635 } else {
636 mRecheckAlarmTimer->stop(); 636 mRecheckAlarmTimer->stop();
637 } 637 }
638 //qDebug("Alarm timer started with secs: %d ", sec); 638 //qDebug("Alarm timer started with secs: %d ", sec);
639 mAlarmTimer->start( sec *1000 , true ); 639 mAlarmTimer->start( sec *1000 , true );
640 640
641} 641}
642// called by mRecheckAlarmTimer to get next alarm 642// called by mRecheckAlarmTimer to get next alarm
643// we need this, because a QTimer has only a max range of 25 days 643// we need this, because a QTimer has only a max range of 25 days
644void CalendarView::recheckTimerAlarm() 644void CalendarView::recheckTimerAlarm()
645{ 645{
646 mAlarmTimer->stop(); 646 mAlarmTimer->stop();
647 mRecheckAlarmTimer->stop(); 647 mRecheckAlarmTimer->stop();
648 mCalendar->checkAlarmForIncidence( 0, true ); 648 mCalendar->checkAlarmForIncidence( 0, true );
649} 649}
650void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 650void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
651{ 651{
652 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 652 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
653 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 653 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
654#ifndef DESKTOP_VERSION 654#ifndef DESKTOP_VERSION
655 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 655 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
656#endif 656#endif
657 return; 657 return;
658 } 658 }
659 mAlarmTimer->stop(); 659 mAlarmTimer->stop();
660} 660}
661void CalendarView::selectWeekNum ( int num ) 661void CalendarView::selectWeekNum ( int num )
662{ 662{
663 dateNavigator()->selectWeek( num ); 663 dateNavigator()->selectWeek( num );
664 mViewManager->showWeekView(); 664 mViewManager->showWeekView();
665} 665}
666KOViewManager *CalendarView::viewManager() 666KOViewManager *CalendarView::viewManager()
667{ 667{
668 return mViewManager; 668 return mViewManager;
669} 669}
670 670
671KODialogManager *CalendarView::dialogManager() 671KODialogManager *CalendarView::dialogManager()
672{ 672{
673 return mDialogManager; 673 return mDialogManager;
674} 674}
675 675
676QDate CalendarView::startDate() 676QDate CalendarView::startDate()
677{ 677{
678 DateList dates = mNavigator->selectedDates(); 678 DateList dates = mNavigator->selectedDates();
679 679
680 return dates.first(); 680 return dates.first();
681} 681}
682 682
683QDate CalendarView::endDate() 683QDate CalendarView::endDate()
684{ 684{
685 DateList dates = mNavigator->selectedDates(); 685 DateList dates = mNavigator->selectedDates();
686 686
687 return dates.last(); 687 return dates.last();
688} 688}
689 689
690 690
691void CalendarView::createPrinter() 691void CalendarView::createPrinter()
692{ 692{
693#ifndef KORG_NOPRINTER 693#ifndef KORG_NOPRINTER
694 if (!mCalPrinter) { 694 if (!mCalPrinter) {
695 mCalPrinter = new CalPrinter(this, mCalendar); 695 mCalPrinter = new CalPrinter(this, mCalendar);
696 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 696 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
697 } 697 }
698#endif 698#endif
699} 699}
700 700
701void CalendarView::confSync()
702{
703 //DELETE
704}
705
706 701
707//KOPrefs::instance()->mWriteBackFile 702//KOPrefs::instance()->mWriteBackFile
708//KOPrefs::instance()->mWriteBackExistingOnly 703//KOPrefs::instance()->mWriteBackExistingOnly
709 704
710// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 705// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
711// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 706// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
712// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 707// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
713// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 708// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
714// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 709// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
715// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 710// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
716 711
717int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 712int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
718{ 713{
719 714
720 //void setZaurusId(int id); 715 //void setZaurusId(int id);
721 // int zaurusId() const; 716 // int zaurusId() const;
722 // void setZaurusUid(int id); 717 // void setZaurusUid(int id);
723 // int zaurusUid() const; 718 // int zaurusUid() const;
724 // void setZaurusStat(int id); 719 // void setZaurusStat(int id);
725 // int zaurusStat() const; 720 // int zaurusStat() const;
726 // 0 equal 721 // 0 equal
727 // 1 take local 722 // 1 take local
728 // 2 take remote 723 // 2 take remote
729 // 3 cancel 724 // 3 cancel
730 QDateTime lastSync = mLastCalendarSync; 725 QDateTime lastSync = mLastCalendarSync;
731 QDateTime localMod = local->lastModified(); 726 QDateTime localMod = local->lastModified();
732 QDateTime remoteMod = remote->lastModified(); 727 QDateTime remoteMod = remote->lastModified();
733 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 728 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
734 bool remCh, locCh; 729 bool remCh, locCh;
735 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 730 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
736 //if ( remCh ) 731 //if ( remCh )
737 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 732 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
738 locCh = ( localMod > mLastCalendarSync ); 733 locCh = ( localMod > mLastCalendarSync );
739 if ( !remCh && ! locCh ) { 734 if ( !remCh && ! locCh ) {
740 //qDebug("both not changed "); 735 //qDebug("both not changed ");
741 lastSync = localMod.addDays(1); 736 lastSync = localMod.addDays(1);
742 if ( mode <= SYNC_PREF_ASK ) 737 if ( mode <= SYNC_PREF_ASK )
743 return 0; 738 return 0;
744 } else { 739 } else {
745 if ( locCh ) { 740 if ( locCh ) {
746 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); 741 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1());
747 lastSync = localMod.addDays( -1 ); 742 lastSync = localMod.addDays( -1 );
748 if ( !remCh ) 743 if ( !remCh )
749 remoteMod = ( lastSync.addDays( -1 ) ); 744 remoteMod = ( lastSync.addDays( -1 ) );
750 } else { 745 } else {
751 //qDebug(" not loc changed "); 746 //qDebug(" not loc changed ");
752 lastSync = localMod.addDays( 1 ); 747 lastSync = localMod.addDays( 1 );
753 if ( remCh ) 748 if ( remCh )
754 remoteMod =( lastSync.addDays( 1 ) ); 749 remoteMod =( lastSync.addDays( 1 ) );
755 750
756 } 751 }
757 } 752 }
758 full = true; 753 full = true;
759 if ( mode < SYNC_PREF_ASK ) 754 if ( mode < SYNC_PREF_ASK )
760 mode = SYNC_PREF_ASK; 755 mode = SYNC_PREF_ASK;
761 } else { 756 } else {
762 if ( localMod == remoteMod ) 757 if ( localMod == remoteMod )
763 if ( local->revision() == remote->revision() ) 758 if ( local->revision() == remote->revision() )
764 return 0; 759 return 0;
765 760
766 } 761 }
767 // 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() );
768 763
769 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); 764 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision());
770 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); 765 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() );
771 //full = true; //debug only 766 //full = true; //debug only
772 if ( full ) { 767 if ( full ) {
773 bool equ = false; 768 bool equ = false;
774 if ( local->type() == "Event" ) { 769 if ( local->type() == "Event" ) {
775 equ = (*((Event*) local) == *((Event*) remote)); 770 equ = (*((Event*) local) == *((Event*) remote));
776 } 771 }
777 else if ( local->type() =="Todo" ) 772 else if ( local->type() =="Todo" )
778 equ = (*((Todo*) local) == (*(Todo*) remote)); 773 equ = (*((Todo*) local) == (*(Todo*) remote));
779 else if ( local->type() =="Journal" ) 774 else if ( local->type() =="Journal" )
780 equ = (*((Journal*) local) == *((Journal*) remote)); 775 equ = (*((Journal*) local) == *((Journal*) remote));
781 if ( equ ) { 776 if ( equ ) {
782 //qDebug("equal "); 777 //qDebug("equal ");
783 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 778 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
784 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 779 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
785 } 780 }
786 if ( mode < SYNC_PREF_FORCE_LOCAL ) 781 if ( mode < SYNC_PREF_FORCE_LOCAL )
787 return 0; 782 return 0;
788 783
789 }//else //debug only 784 }//else //debug only
790 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 785 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
791 } 786 }
792 int result; 787 int result;
793 bool localIsNew; 788 bool localIsNew;
794 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); 789 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() );
795 790
796 if ( full && mode < SYNC_PREF_NEWEST ) 791 if ( full && mode < SYNC_PREF_NEWEST )
797 mode = SYNC_PREF_ASK; 792 mode = SYNC_PREF_ASK;
798 793
799 switch( mode ) { 794 switch( mode ) {
800 case SYNC_PREF_LOCAL: 795 case SYNC_PREF_LOCAL:
801 if ( lastSync > remoteMod ) 796 if ( lastSync > remoteMod )
802 return 1; 797 return 1;
803 if ( lastSync > localMod ) 798 if ( lastSync > localMod )
804 return 2; 799 return 2;
805 return 1; 800 return 1;
806 break; 801 break;
807 case SYNC_PREF_REMOTE: 802 case SYNC_PREF_REMOTE:
808 if ( lastSync > remoteMod ) 803 if ( lastSync > remoteMod )
809 return 1; 804 return 1;
810 if ( lastSync > localMod ) 805 if ( lastSync > localMod )
811 return 2; 806 return 2;
812 return 2; 807 return 2;
813 break; 808 break;
814 case SYNC_PREF_NEWEST: 809 case SYNC_PREF_NEWEST:
815 if ( localMod > remoteMod ) 810 if ( localMod > remoteMod )
816 return 1; 811 return 1;
817 else 812 else
818 return 2; 813 return 2;
819 break; 814 break;
820 case SYNC_PREF_ASK: 815 case SYNC_PREF_ASK:
821 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 816 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
822 if ( lastSync > remoteMod ) 817 if ( lastSync > remoteMod )
823 return 1; 818 return 1;
824 if ( lastSync > localMod ) 819 if ( lastSync > localMod )
825 return 2; 820 return 2;
826 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 821 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
827 localIsNew = localMod >= remoteMod; 822 localIsNew = localMod >= remoteMod;
828 if ( localIsNew ) 823 if ( localIsNew )
829 getEventViewerDialog()->setColorMode( 1 ); 824 getEventViewerDialog()->setColorMode( 1 );
830 else 825 else
831 getEventViewerDialog()->setColorMode( 2 ); 826 getEventViewerDialog()->setColorMode( 2 );
832 getEventViewerDialog()->setIncidence(local); 827 getEventViewerDialog()->setIncidence(local);
833 if ( localIsNew ) 828 if ( localIsNew )
834 getEventViewerDialog()->setColorMode( 2 ); 829 getEventViewerDialog()->setColorMode( 2 );
835 else 830 else
836 getEventViewerDialog()->setColorMode( 1 ); 831 getEventViewerDialog()->setColorMode( 1 );
837 getEventViewerDialog()->addIncidence(remote); 832 getEventViewerDialog()->addIncidence(remote);
838 getEventViewerDialog()->setColorMode( 0 ); 833 getEventViewerDialog()->setColorMode( 0 );
839 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 834 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
840 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 835 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
841 getEventViewerDialog()->showMe(); 836 getEventViewerDialog()->showMe();
842 result = getEventViewerDialog()->executeS( localIsNew ); 837 result = getEventViewerDialog()->executeS( localIsNew );
843 return result; 838 return result;
844 839
845 break; 840 break;
846 case SYNC_PREF_FORCE_LOCAL: 841 case SYNC_PREF_FORCE_LOCAL:
847 return 1; 842 return 1;
848 break; 843 break;
849 case SYNC_PREF_FORCE_REMOTE: 844 case SYNC_PREF_FORCE_REMOTE:
850 return 2; 845 return 2;
851 break; 846 break;
852 847
853 default: 848 default:
854 // SYNC_PREF_TAKE_BOTH not implemented 849 // SYNC_PREF_TAKE_BOTH not implemented
855 break; 850 break;
856 } 851 }
857 return 0; 852 return 0;
858} 853}
859Event* CalendarView::getLastSyncEvent() 854Event* CalendarView::getLastSyncEvent()
860{ 855{
861 Event* lse; 856 Event* lse;
862 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 857 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
863 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 858 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
864 if (!lse) { 859 if (!lse) {
865 lse = new Event(); 860 lse = new Event();
866 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 861 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
867 QString sum = ""; 862 QString sum = "";
868 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 863 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
869 sum = "E: "; 864 sum = "E: ";
870 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 865 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
871 lse->setDtStart( mLastCalendarSync ); 866 lse->setDtStart( mLastCalendarSync );
872 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 867 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
873 lse->setCategories( i18n("SyncEvent") ); 868 lse->setCategories( i18n("SyncEvent") );
874 lse->setReadOnly( true ); 869 lse->setReadOnly( true );
875 mCalendar->addEvent( lse ); 870 mCalendar->addEvent( lse );
876 } 871 }
877 872
878 return lse; 873 return lse;
879 874
880} 875}
881 876
882// we check, if the to delete event has a id for a profile 877// we check, if the to delete event has a id for a profile
883// if yes, we set this id in the profile to delete 878// if yes, we set this id in the profile to delete
884void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 879void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
885{ 880{
886 if ( lastSync.count() == 0 ) { 881 if ( lastSync.count() == 0 ) {
887 //qDebug(" lastSync.count() == 0"); 882 //qDebug(" lastSync.count() == 0");
888 return; 883 return;
889 } 884 }
890 if ( toDelete->type() == "Journal" ) 885 if ( toDelete->type() == "Journal" )
891 return; 886 return;
892 887
893 Event* eve = lastSync.first(); 888 Event* eve = lastSync.first();
894 889
895 while ( eve ) { 890 while ( eve ) {
896 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 891 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
897 if ( !id.isEmpty() ) { 892 if ( !id.isEmpty() ) {
898 QString des = eve->description(); 893 QString des = eve->description();
899 QString pref = "e"; 894 QString pref = "e";
900 if ( toDelete->type() == "Todo" ) 895 if ( toDelete->type() == "Todo" )
901 pref = "t"; 896 pref = "t";
902 des += pref+ id + ","; 897 des += pref+ id + ",";
903 eve->setReadOnly( false ); 898 eve->setReadOnly( false );
904 eve->setDescription( des ); 899 eve->setDescription( des );
905 //qDebug("setdes %s ", des.latin1()); 900 //qDebug("setdes %s ", des.latin1());
906 eve->setReadOnly( true ); 901 eve->setReadOnly( true );
907 } 902 }
908 eve = lastSync.next(); 903 eve = lastSync.next();
909 } 904 }
910 905
911} 906}
912void CalendarView::checkExternalId( Incidence * inc ) 907void CalendarView::checkExternalId( Incidence * inc )
913{ 908{
914 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 909 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
915 checkExternSyncEvent( lastSync, inc ); 910 checkExternSyncEvent( lastSync, inc );
916 911
917} 912}
918bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 913bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
919{ 914{
920 bool syncOK = true; 915 bool syncOK = true;
921 int addedEvent = 0; 916 int addedEvent = 0;
922 int addedEventR = 0; 917 int addedEventR = 0;
923 int deletedEventR = 0; 918 int deletedEventR = 0;
924 int deletedEventL = 0; 919 int deletedEventL = 0;
925 int changedLocal = 0; 920 int changedLocal = 0;
926 int changedRemote = 0; 921 int changedRemote = 0;
927 //QPtrList<Event> el = local->rawEvents(); 922 //QPtrList<Event> el = local->rawEvents();
928 Event* eventR; 923 Event* eventR;
929 QString uid; 924 QString uid;
930 int take; 925 int take;
931 Event* eventL; 926 Event* eventL;
932 Event* eventRSync; 927 Event* eventRSync;
933 Event* eventLSync; 928 Event* eventLSync;
934 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 929 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
935 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 930 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
936 bool fullDateRange = false; 931 bool fullDateRange = false;
937 local->resetTempSyncStat(); 932 local->resetTempSyncStat();
938 mLastCalendarSync = QDateTime::currentDateTime(); 933 mLastCalendarSync = QDateTime::currentDateTime();
939 QDateTime modifiedCalendar = mLastCalendarSync;; 934 QDateTime modifiedCalendar = mLastCalendarSync;;
940 eventLSync = getLastSyncEvent(); 935 eventLSync = getLastSyncEvent();
941 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 936 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
942 if ( eventR ) { 937 if ( eventR ) {
943 eventRSync = (Event*) eventR->clone(); 938 eventRSync = (Event*) eventR->clone();
944 remote->deleteEvent(eventR ); 939 remote->deleteEvent(eventR );
945 940
946 } else { 941 } else {
947 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 942 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
948 eventRSync = (Event*)eventLSync->clone(); 943 eventRSync = (Event*)eventLSync->clone();
949 } else { 944 } else {
950 fullDateRange = true; 945 fullDateRange = true;
951 eventRSync = new Event(); 946 eventRSync = new Event();
952 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 947 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
953 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 948 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
954 eventRSync->setDtStart( mLastCalendarSync ); 949 eventRSync->setDtStart( mLastCalendarSync );
955 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 950 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
956 eventRSync->setCategories( i18n("SyncEvent") ); 951 eventRSync->setCategories( i18n("SyncEvent") );
957 } 952 }
958 } 953 }
959 if ( eventLSync->dtStart() == mLastCalendarSync ) 954 if ( eventLSync->dtStart() == mLastCalendarSync )
960 fullDateRange = true; 955 fullDateRange = true;
961 956
962 if ( ! fullDateRange ) { 957 if ( ! fullDateRange ) {
963 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 958 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
964 959
965 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 960 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
966 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 961 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
967 fullDateRange = true; 962 fullDateRange = true;
968 } 963 }
969 } 964 }
970 if ( fullDateRange ) 965 if ( fullDateRange )
971 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 966 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
972 else 967 else
973 mLastCalendarSync = eventLSync->dtStart(); 968 mLastCalendarSync = eventLSync->dtStart();
974 // for resyncing if own file has changed 969 // for resyncing if own file has changed
975 if ( mCurrentSyncDevice == "deleteaftersync" ) { 970 if ( mCurrentSyncDevice == "deleteaftersync" ) {
976 mLastCalendarSync = loadedFileVersion; 971 mLastCalendarSync = loadedFileVersion;
977 qDebug("setting mLastCalendarSync "); 972 qDebug("setting mLastCalendarSync ");
978 } 973 }
979 //qDebug("*************************** "); 974 //qDebug("*************************** ");
980 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); 975 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() );
981 QPtrList<Incidence> er = remote->rawIncidences(); 976 QPtrList<Incidence> er = remote->rawIncidences();
982 Incidence* inR = er.first(); 977 Incidence* inR = er.first();
983 Incidence* inL; 978 Incidence* inL;
984 QProgressBar bar( er.count(),0 ); 979 QProgressBar bar( er.count(),0 );
985 bar.setCaption (i18n("Syncing - close to abort!") ); 980 bar.setCaption (i18n("Syncing - close to abort!") );
986 981
987 int w = 300; 982 int w = 300;
988 if ( QApplication::desktop()->width() < 320 ) 983 if ( QApplication::desktop()->width() < 320 )
989 w = 220; 984 w = 220;
990 int h = bar.sizeHint().height() ; 985 int h = bar.sizeHint().height() ;
991 int dw = QApplication::desktop()->width(); 986 int dw = QApplication::desktop()->width();
992 int dh = QApplication::desktop()->height(); 987 int dh = QApplication::desktop()->height();
993 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 988 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
994 bar.show(); 989 bar.show();
995 int modulo = (er.count()/10)+1; 990 int modulo = (er.count()/10)+1;
996 int incCounter = 0; 991 int incCounter = 0;
997 while ( inR ) { 992 while ( inR ) {
998 if ( ! bar.isVisible() ) 993 if ( ! bar.isVisible() )
999 return false; 994 return false;
1000 if ( incCounter % modulo == 0 ) 995 if ( incCounter % modulo == 0 )
1001 bar.setProgress( incCounter ); 996 bar.setProgress( incCounter );
1002 ++incCounter; 997 ++incCounter;
1003 uid = inR->uid(); 998 uid = inR->uid();
1004 bool skipIncidence = false; 999 bool skipIncidence = false;
1005 if ( uid.left(15) == QString("last-syncEvent-") ) 1000 if ( uid.left(15) == QString("last-syncEvent-") )
1006 skipIncidence = true; 1001 skipIncidence = true;
1007 QString idS; 1002 QString idS;
1008 qApp->processEvents(); 1003 qApp->processEvents();
1009 if ( !skipIncidence ) { 1004 if ( !skipIncidence ) {
1010 inL = local->incidence( uid ); 1005 inL = local->incidence( uid );
1011 if ( inL ) { // maybe conflict - same uid in both calendars 1006 if ( inL ) { // maybe conflict - same uid in both calendars
1012 int maxrev = inL->revision(); 1007 int maxrev = inL->revision();
1013 if ( maxrev < inR->revision() ) 1008 if ( maxrev < inR->revision() )
1014 maxrev = inR->revision(); 1009 maxrev = inR->revision();
1015 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1010 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1016 //qDebug("take %d %s ", take, inL->summary().latin1()); 1011 //qDebug("take %d %s ", take, inL->summary().latin1());
1017 if ( take == 3 ) 1012 if ( take == 3 )
1018 return false; 1013 return false;
1019 if ( take == 1 ) {// take local 1014 if ( take == 1 ) {// take local
1020 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1015 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1021 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1016 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1022 else 1017 else
1023 idS = inR->IDStr(); 1018 idS = inR->IDStr();
1024 remote->deleteIncidence( inR ); 1019 remote->deleteIncidence( inR );
1025 if ( inL->revision() < maxrev ) 1020 if ( inL->revision() < maxrev )
1026 inL->setRevision( maxrev ); 1021 inL->setRevision( maxrev );
1027 inR = inL->clone(); 1022 inR = inL->clone();
1028 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1023 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1029 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1024 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1030 inR->setIDStr( idS ); 1025 inR->setIDStr( idS );
1031 remote->addIncidence( inR ); 1026 remote->addIncidence( inR );
1032 ++changedRemote; 1027 ++changedRemote;
1033 } else { 1028 } else {
1034 if ( inR->revision() < maxrev ) 1029 if ( inR->revision() < maxrev )
1035 inR->setRevision( maxrev ); 1030 inR->setRevision( maxrev );
1036 idS = inL->IDStr(); 1031 idS = inL->IDStr();
1037 local->deleteIncidence( inL ); 1032 local->deleteIncidence( inL );
1038 inL = inR->clone(); 1033 inL = inR->clone();
1039 inL->setIDStr( idS ); 1034 inL->setIDStr( idS );
1040 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1035 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1041 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1036 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1042 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1037 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1043 } 1038 }
1044 local->addIncidence( inL ); 1039 local->addIncidence( inL );
1045 ++changedLocal; 1040 ++changedLocal;
1046 } 1041 }
1047 } 1042 }
1048 } else { // no conflict 1043 } else { // no conflict
1049 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1044 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1050 QString des = eventLSync->description(); 1045 QString des = eventLSync->description();
1051 QString pref = "e"; 1046 QString pref = "e";
1052 if ( inR->type() == "Todo" ) 1047 if ( inR->type() == "Todo" )
1053 pref = "t"; 1048 pref = "t";
1054 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
1055 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1050 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1056 //remote->deleteIncidence( inR ); 1051 //remote->deleteIncidence( inR );
1057 ++deletedEventR; 1052 ++deletedEventR;
1058 } else { 1053 } else {
1059 inR->setLastModified( modifiedCalendar ); 1054 inR->setLastModified( modifiedCalendar );
1060 inL = inR->clone(); 1055 inL = inR->clone();
1061 local->addIncidence( inL ); 1056 local->addIncidence( inL );
1062 ++addedEvent; 1057 ++addedEvent;
1063 } 1058 }
1064 } else { 1059 } else {
1065 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1060 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1066 inR->setLastModified( modifiedCalendar ); 1061 inR->setLastModified( modifiedCalendar );
1067 local->addIncidence( inR->clone() ); 1062 local->addIncidence( inR->clone() );
1068 ++addedEvent; 1063 ++addedEvent;
1069 } else { 1064 } else {
1070 checkExternSyncEvent(eventRSyncSharp, inR); 1065 checkExternSyncEvent(eventRSyncSharp, inR);
1071 remote->deleteIncidence( inR ); 1066 remote->deleteIncidence( inR );
1072 ++deletedEventR; 1067 ++deletedEventR;
1073 } 1068 }
1074 } 1069 }
1075 } 1070 }
1076 } 1071 }
1077 inR = er.next(); 1072 inR = er.next();
1078 } 1073 }
1079 QPtrList<Incidence> el = local->rawIncidences(); 1074 QPtrList<Incidence> el = local->rawIncidences();
1080 inL = el.first(); 1075 inL = el.first();
1081 modulo = (el.count()/10)+1; 1076 modulo = (el.count()/10)+1;
1082 bar.setCaption (i18n("Add / remove events") ); 1077 bar.setCaption (i18n("Add / remove events") );
1083 bar.setTotalSteps ( el.count() ) ; 1078 bar.setTotalSteps ( el.count() ) ;
1084 bar.show(); 1079 bar.show();
1085 incCounter = 0; 1080 incCounter = 0;
1086 1081
1087 while ( inL ) { 1082 while ( inL ) {
1088 1083
1089 qApp->processEvents(); 1084 qApp->processEvents();
1090 if ( ! bar.isVisible() ) 1085 if ( ! bar.isVisible() )
1091 return false; 1086 return false;
1092 if ( incCounter % modulo == 0 ) 1087 if ( incCounter % modulo == 0 )
1093 bar.setProgress( incCounter ); 1088 bar.setProgress( incCounter );
1094 ++incCounter; 1089 ++incCounter;
1095 uid = inL->uid(); 1090 uid = inL->uid();
1096 bool skipIncidence = false; 1091 bool skipIncidence = false;
1097 if ( uid.left(15) == QString("last-syncEvent-") ) 1092 if ( uid.left(15) == QString("last-syncEvent-") )
1098 skipIncidence = true; 1093 skipIncidence = true;
1099 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) 1094 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
1100 skipIncidence = true; 1095 skipIncidence = true;
1101 if ( !skipIncidence ) { 1096 if ( !skipIncidence ) {
1102 inR = remote->incidence( uid ); 1097 inR = remote->incidence( uid );
1103 if ( ! inR ) { 1098 if ( ! inR ) {
1104 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1099 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1105 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1100 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1106 checkExternSyncEvent(eventLSyncSharp, inL); 1101 checkExternSyncEvent(eventLSyncSharp, inL);
1107 local->deleteIncidence( inL ); 1102 local->deleteIncidence( inL );
1108 ++deletedEventL; 1103 ++deletedEventL;
1109 } else { 1104 } else {
1110 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1105 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1111 inL->removeID(mCurrentSyncDevice ); 1106 inL->removeID(mCurrentSyncDevice );
1112 ++addedEventR; 1107 ++addedEventR;
1113 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1108 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1114 inL->setLastModified( modifiedCalendar ); 1109 inL->setLastModified( modifiedCalendar );
1115 inR = inL->clone(); 1110 inR = inL->clone();
1116 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1111 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1117 remote->addIncidence( inR ); 1112 remote->addIncidence( inR );
1118 } 1113 }
1119 } 1114 }
1120 } else { 1115 } else {
1121 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1116 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1122 checkExternSyncEvent(eventLSyncSharp, inL); 1117 checkExternSyncEvent(eventLSyncSharp, inL);
1123 local->deleteIncidence( inL ); 1118 local->deleteIncidence( inL );
1124 ++deletedEventL; 1119 ++deletedEventL;
1125 } else { 1120 } else {
1126 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1121 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1127 ++addedEventR; 1122 ++addedEventR;
1128 inL->setLastModified( modifiedCalendar ); 1123 inL->setLastModified( modifiedCalendar );
1129 remote->addIncidence( inL->clone() ); 1124 remote->addIncidence( inL->clone() );
1130 } 1125 }
1131 } 1126 }
1132 } 1127 }
1133 } 1128 }
1134 } 1129 }
1135 inL = el.next(); 1130 inL = el.next();
1136 } 1131 }
1137 int delFut = 0; 1132 int delFut = 0;
1138 if ( mSyncManager->mWriteBackInFuture ) { 1133 if ( mSyncManager->mWriteBackInFuture ) {
1139 er = remote->rawIncidences(); 1134 er = remote->rawIncidences();
1140 inR = er.first(); 1135 inR = er.first();
1141 QDateTime dt; 1136 QDateTime dt;
1142 QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); 1137 QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
1143 QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 ); 1138 QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 );
1144 while ( inR ) { 1139 while ( inR ) {
1145 if ( inR->type() == "Todo" ) { 1140 if ( inR->type() == "Todo" ) {
1146 Todo * t = (Todo*)inR; 1141 Todo * t = (Todo*)inR;
1147 if ( t->hasDueDate() ) 1142 if ( t->hasDueDate() )
1148 dt = t->dtDue(); 1143 dt = t->dtDue();
1149 else 1144 else
1150 dt = cur.addSecs( 62 ); 1145 dt = cur.addSecs( 62 );
1151 } 1146 }
1152 else if (inR->type() == "Event" ) { 1147 else if (inR->type() == "Event" ) {
1153 bool ok; 1148 bool ok;
1154 dt = inR->getNextOccurence( cur, &ok ); 1149 dt = inR->getNextOccurence( cur, &ok );
1155 if ( !ok ) 1150 if ( !ok )
1156 dt = cur.addSecs( -62 ); 1151 dt = cur.addSecs( -62 );
1157 } 1152 }
1158 else 1153 else
1159 dt = inR->dtStart(); 1154 dt = inR->dtStart();
1160 if ( dt < cur || dt > end ) { 1155 if ( dt < cur || dt > end ) {
1161 remote->deleteIncidence( inR ); 1156 remote->deleteIncidence( inR );
1162 ++delFut; 1157 ++delFut;
1163 } 1158 }
1164 inR = er.next(); 1159 inR = er.next();
1165 } 1160 }
1166 } 1161 }
1167 bar.hide(); 1162 bar.hide();
1168 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1163 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1169 eventLSync->setReadOnly( false ); 1164 eventLSync->setReadOnly( false );
1170 eventLSync->setDtStart( mLastCalendarSync ); 1165 eventLSync->setDtStart( mLastCalendarSync );
1171 eventRSync->setDtStart( mLastCalendarSync ); 1166 eventRSync->setDtStart( mLastCalendarSync );
1172 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1167 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1173 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1168 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1174 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1169 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1175 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1170 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1176 eventLSync->setReadOnly( true ); 1171 eventLSync->setReadOnly( true );
1177 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 1172 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
1178 remote->addEvent( eventRSync ); 1173 remote->addEvent( eventRSync );
1179 QString mes; 1174 QString mes;
1180 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 ); 1175 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 );
1181 QString delmess; 1176 QString delmess;
1182 if ( delFut ) { 1177 if ( delFut ) {
1183 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\n"),delFut, mSyncManager->mWriteBackInFuture ); 1178 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\n"),delFut, mSyncManager->mWriteBackInFuture );
1184 mes += delmess; 1179 mes += delmess;
1185 } 1180 }
1186 if ( mSyncManager->mShowSyncSummary ) { 1181 if ( mSyncManager->mShowSyncSummary ) {
1187 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); 1182 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") );
1188 } 1183 }
1189 qDebug( mes ); 1184 qDebug( mes );
1190 mCalendar->checkAlarmForIncidence( 0, true ); 1185 mCalendar->checkAlarmForIncidence( 0, true );
1191 return syncOK; 1186 return syncOK;
1192} 1187}
1193 1188
1194void CalendarView::setSyncDevice( QString s ) 1189void CalendarView::setSyncDevice( QString s )
1195{ 1190{
1196 mCurrentSyncDevice= s; 1191 mCurrentSyncDevice= s;
1197} 1192}
1198void CalendarView::setSyncName( QString s ) 1193void CalendarView::setSyncName( QString s )
1199{ 1194{
1200 mCurrentSyncName= s; 1195 mCurrentSyncName= s;
1201} 1196}
1202bool CalendarView::syncCalendar(QString filename, int mode) 1197bool CalendarView::syncCalendar(QString filename, int mode)
1203{ 1198{
1199 //qDebug("syncCalendar %s ", filename.latin1());
1204 mGlobalSyncMode = SYNC_MODE_NORMAL; 1200 mGlobalSyncMode = SYNC_MODE_NORMAL;
1205 CalendarLocal* calendar = new CalendarLocal(); 1201 CalendarLocal* calendar = new CalendarLocal();
1206 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1202 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1207 FileStorage* storage = new FileStorage( calendar ); 1203 FileStorage* storage = new FileStorage( calendar );
1208 bool syncOK = false; 1204 bool syncOK = false;
1209 storage->setFileName( filename ); 1205 storage->setFileName( filename );
1210 // qDebug("loading ... "); 1206 // qDebug("loading ... ");
1211 if ( storage->load() ) { 1207 if ( storage->load() ) {
1212 getEventViewerDialog()->setSyncMode( true ); 1208 getEventViewerDialog()->setSyncMode( true );
1213 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1209 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1214 getEventViewerDialog()->setSyncMode( false ); 1210 getEventViewerDialog()->setSyncMode( false );
1215 if ( syncOK ) { 1211 if ( syncOK ) {
1216 if ( mSyncManager->mWriteBackFile ) 1212 if ( mSyncManager->mWriteBackFile )
1217 { 1213 {
1218 storage->setSaveFormat( new ICalFormat() ); 1214 storage->setSaveFormat( new ICalFormat() );
1219 storage->save(); 1215 storage->save();
1220 } 1216 }
1221 } 1217 }
1222 setModified( true ); 1218 setModified( true );
1223 } 1219 }
1224 delete storage; 1220 delete storage;
1225 delete calendar; 1221 delete calendar;
1226 if ( syncOK ) 1222 if ( syncOK )
1227 updateView(); 1223 updateView();
1228 return syncOK; 1224 return syncOK;
1229} 1225}
1230void CalendarView::syncPhone() 1226
1231{
1232 //DELETE
1233}
1234void CalendarView::syncExternal( int mode ) 1227void CalendarView::syncExternal( int mode )
1235{ 1228{
1236 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1229 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1237 1230
1238 qApp->processEvents(); 1231 qApp->processEvents();
1239 CalendarLocal* calendar = new CalendarLocal(); 1232 CalendarLocal* calendar = new CalendarLocal();
1240 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1233 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1241 bool syncOK = false; 1234 bool syncOK = false;
1242 bool loadSuccess = false; 1235 bool loadSuccess = false;
1243 PhoneFormat* phoneFormat = 0; 1236 PhoneFormat* phoneFormat = 0;
1244#ifndef DESKTOP_VERSION 1237#ifndef DESKTOP_VERSION
1245 SharpFormat* sharpFormat = 0; 1238 SharpFormat* sharpFormat = 0;
1246 if ( mode == 0 ) { // sharp 1239 if ( mode == 0 ) { // sharp
1247 sharpFormat = new SharpFormat () ; 1240 sharpFormat = new SharpFormat () ;
1248 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1241 loadSuccess = sharpFormat->load( calendar, mCalendar );
1249 1242
1250 } else 1243 } else
1251#endif 1244#endif
1252 if ( mode == 1 ) { // phone 1245 if ( mode == 1 ) { // phone
1253 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1246 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1254 mSyncManager->mPhoneDevice, 1247 mSyncManager->mPhoneDevice,
1255 mSyncManager->mPhoneConnection, 1248 mSyncManager->mPhoneConnection,
1256 mSyncManager->mPhoneModel); 1249 mSyncManager->mPhoneModel);
1257 loadSuccess = phoneFormat->load( calendar,mCalendar); 1250 loadSuccess = phoneFormat->load( calendar,mCalendar);
1258 1251
1259 } else 1252 } else
1260 return; 1253 return;
1261 if ( loadSuccess ) { 1254 if ( loadSuccess ) {
1262 getEventViewerDialog()->setSyncMode( true ); 1255 getEventViewerDialog()->setSyncMode( true );
1263 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1256 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1264 getEventViewerDialog()->setSyncMode( false ); 1257 getEventViewerDialog()->setSyncMode( false );
1265 qApp->processEvents(); 1258 qApp->processEvents();
1266 if ( syncOK ) { 1259 if ( syncOK ) {
1267 if ( mSyncManager->mWriteBackFile ) 1260 if ( mSyncManager->mWriteBackFile )
1268 { 1261 {
1269 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1262 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1270 Incidence* inc = iL.first(); 1263 Incidence* inc = iL.first();
1271 if ( phoneFormat ) { 1264 if ( phoneFormat ) {
1272 while ( inc ) { 1265 while ( inc ) {
1273 inc->removeID(mCurrentSyncDevice); 1266 inc->removeID(mCurrentSyncDevice);
1274 inc = iL.next(); 1267 inc = iL.next();
1275 } 1268 }
1276 } 1269 }
1277#ifndef DESKTOP_VERSION 1270#ifndef DESKTOP_VERSION
1278 if ( sharpFormat ) 1271 if ( sharpFormat )
1279 sharpFormat->save(calendar); 1272 sharpFormat->save(calendar);
1280#endif 1273#endif
1281 if ( phoneFormat ) 1274 if ( phoneFormat )
1282 phoneFormat->save(calendar); 1275 phoneFormat->save(calendar);
1283 iL = calendar->rawIncidences(); 1276 iL = calendar->rawIncidences();
1284 inc = iL.first(); 1277 inc = iL.first();
1285 Incidence* loc; 1278 Incidence* loc;
1286 while ( inc ) { 1279 while ( inc ) {
1287 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1280 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1288 loc = mCalendar->incidence(inc->uid() ); 1281 loc = mCalendar->incidence(inc->uid() );
1289 if ( loc ) { 1282 if ( loc ) {
1290 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1283 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1291 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1284 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1292 } 1285 }
1293 } 1286 }
1294 inc = iL.next(); 1287 inc = iL.next();
1295 } 1288 }
1296 Incidence* lse = getLastSyncEvent(); 1289 Incidence* lse = getLastSyncEvent();
1297 if ( lse ) { 1290 if ( lse ) {
1298 lse->setReadOnly( false ); 1291 lse->setReadOnly( false );
1299 lse->setDescription( "" ); 1292 lse->setDescription( "" );
1300 lse->setReadOnly( true ); 1293 lse->setReadOnly( true );
1301 } 1294 }
1302 } 1295 }
1303 } 1296 }
1304 setModified( true ); 1297 setModified( true );
1305 } else { 1298 } else {
1306 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1299 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1307 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1300 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1308 question, i18n("Ok")) ; 1301 question, i18n("Ok")) ;
1309 1302
1310 } 1303 }
1311 delete calendar; 1304 delete calendar;
1312 updateView(); 1305 updateView();
1313 return ;//syncOK; 1306 return ;//syncOK;
1314 1307
1315} 1308}
1316void CalendarView::syncSharp()
1317{
1318 //DELETE
1319
1320}
1321
1322 1309
1323bool CalendarView::importBday() 1310bool CalendarView::importBday()
1324{ 1311{
1325#ifndef KORG_NOKABC 1312#ifndef KORG_NOKABC
1326 1313
1327#ifdef DESKTOP_VERSION 1314#ifdef DESKTOP_VERSION
1328 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1315 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1329 KABC::AddressBook::Iterator it; 1316 KABC::AddressBook::Iterator it;
1330 int count = 0; 1317 int count = 0;
1331 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1318 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1332 ++count; 1319 ++count;
1333 } 1320 }
1334 QProgressBar bar(count,0 ); 1321 QProgressBar bar(count,0 );
1335 int w = 300; 1322 int w = 300;
1336 if ( QApplication::desktop()->width() < 320 ) 1323 if ( QApplication::desktop()->width() < 320 )
1337 w = 220; 1324 w = 220;
1338 int h = bar.sizeHint().height() ; 1325 int h = bar.sizeHint().height() ;
1339 int dw = QApplication::desktop()->width(); 1326 int dw = QApplication::desktop()->width();
1340 int dh = QApplication::desktop()->height(); 1327 int dh = QApplication::desktop()->height();
1341 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1328 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1342 bar.show(); 1329 bar.show();
1343 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1330 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1344 qApp->processEvents(); 1331 qApp->processEvents();
1345 count = 0; 1332 count = 0;
1346 int addCount = 0; 1333 int addCount = 0;
1347 KCal::Attendee* a = 0; 1334 KCal::Attendee* a = 0;
1348 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1335 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1349 if ( ! bar.isVisible() ) 1336 if ( ! bar.isVisible() )
1350 return false; 1337 return false;
1351 bar.setProgress( count++ ); 1338 bar.setProgress( count++ );
1352 qApp->processEvents(); 1339 qApp->processEvents();
1353 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1340 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1354 if ( (*it).birthday().date().isValid() ){ 1341 if ( (*it).birthday().date().isValid() ){
1355 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1342 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1356 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1343 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1357 ++addCount; 1344 ++addCount;
1358 } 1345 }
1359 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1346 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1360 if ( anni.isValid() ){ 1347 if ( anni.isValid() ){
1361 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1348 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1362 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1349 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1363 ++addCount; 1350 ++addCount;
1364 } 1351 }
1365 } 1352 }
1366 updateView(); 1353 updateView();
1367 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1354 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1368#else //DESKTOP_VERSION 1355#else //DESKTOP_VERSION
1369 1356
1370 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 1357 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
1371 // the result should now arrive through method insertBirthdays 1358 // the result should now arrive through method insertBirthdays
1372 1359
1373#endif //DESKTOP_VERSION 1360#endif //DESKTOP_VERSION
1374 1361
1375#endif //KORG_NOKABC 1362#endif //KORG_NOKABC
1376 1363
1377 1364
1378 return true; 1365 return true;
1379} 1366}
1380 1367
1381// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI 1368// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
1382void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, 1369void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
1383 const QStringList& anniversaryList, const QStringList& realNameList, 1370 const QStringList& anniversaryList, const QStringList& realNameList,
1384 const QStringList& emailList, const QStringList& assembledNameList, 1371 const QStringList& emailList, const QStringList& assembledNameList,
1385 const QStringList& uidList) 1372 const QStringList& uidList)
1386{ 1373{
1387 qDebug("CalendarView::insertBirthdays"); 1374 qDebug("CalendarView::insertBirthdays");
1388 if (uid == this->name()) 1375 if (uid == this->name())
1389 { 1376 {
1390 int count = birthdayList.count(); 1377 int count = birthdayList.count();
1391 int addCount = 0; 1378 int addCount = 0;
1392 KCal::Attendee* a = 0; 1379 KCal::Attendee* a = 0;
1393 1380
1394 qDebug("CalView 1 %i", count); 1381 qDebug("CalView 1 %i", count);
1395 1382
1396 QProgressBar bar(count,0 ); 1383 QProgressBar bar(count,0 );
1397 int w = 300; 1384 int w = 300;
1398 if ( QApplication::desktop()->width() < 320 ) 1385 if ( QApplication::desktop()->width() < 320 )
1399 w = 220; 1386 w = 220;
1400 int h = bar.sizeHint().height() ; 1387 int h = bar.sizeHint().height() ;
1401 int dw = QApplication::desktop()->width(); 1388 int dw = QApplication::desktop()->width();
1402 int dh = QApplication::desktop()->height(); 1389 int dh = QApplication::desktop()->height();
1403 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1390 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1404 bar.show(); 1391 bar.show();
1405 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 1392 bar.setCaption (i18n("inserting birthdays - close to abort!") );
1406 qApp->processEvents(); 1393 qApp->processEvents();
1407 1394
1408 QDate birthday; 1395 QDate birthday;
1409 QDate anniversary; 1396 QDate anniversary;
1410 QString realName; 1397 QString realName;
1411 QString email; 1398 QString email;
1412 QString assembledName; 1399 QString assembledName;
1413 QString uid; 1400 QString uid;
1414 bool ok = true; 1401 bool ok = true;
1415 for ( int i = 0; i < count; i++) 1402 for ( int i = 0; i < count; i++)
1416 { 1403 {
1417 if ( ! bar.isVisible() ) 1404 if ( ! bar.isVisible() )
1418 return; 1405 return;
1419 bar.setProgress( i ); 1406 bar.setProgress( i );
1420 qApp->processEvents(); 1407 qApp->processEvents();
1421 1408
1422 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); 1409 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
1423 if (!ok) { 1410 if (!ok) {
1424 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); 1411 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
1425 } 1412 }
1426 1413
1427 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); 1414 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
1428 if (!ok) { 1415 if (!ok) {
1429 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); 1416 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
1430 } 1417 }
1431 realName = realNameList[i]; 1418 realName = realNameList[i];
1432 email = emailList[i]; 1419 email = emailList[i];
1433 assembledName = assembledNameList[i]; 1420 assembledName = assembledNameList[i];
1434 uid = uidList[i]; 1421 uid = uidList[i];
1435 //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); 1422 //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() );
1436 1423
1437 if ( birthday.isValid() ){ 1424 if ( birthday.isValid() ){
1438 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1425 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1439 KCal::Attendee::ReqParticipant,uid) ; 1426 KCal::Attendee::ReqParticipant,uid) ;
1440 if ( addAnniversary( birthday, assembledName, a, true ) ) 1427 if ( addAnniversary( birthday, assembledName, a, true ) )
1441 ++addCount; 1428 ++addCount;
1442 } 1429 }
1443 1430
1444 if ( anniversary.isValid() ){ 1431 if ( anniversary.isValid() ){
1445 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1432 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1446 KCal::Attendee::ReqParticipant,uid) ; 1433 KCal::Attendee::ReqParticipant,uid) ;
1447 if ( addAnniversary( anniversary, assembledName, a, false ) ) 1434 if ( addAnniversary( anniversary, assembledName, a, false ) )
1448 ++addCount; 1435 ++addCount;
1449 } 1436 }
1450 } 1437 }
1451 1438
1452 updateView(); 1439 updateView();
1453 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1440 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1454 1441
1455 } 1442 }
1456 1443
1457} 1444}
1458 1445
1459 1446
1460 1447
1461bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1448bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1462{ 1449{
1463 //qDebug("addAnni "); 1450 //qDebug("addAnni ");
1464 Event * ev = new Event(); 1451 Event * ev = new Event();
1465 if ( a ) { 1452 if ( a ) {
1466 ev->addAttendee( a ); 1453 ev->addAttendee( a );
1467 } 1454 }
1468 QString kind; 1455 QString kind;
1469 if ( birthday ) 1456 if ( birthday )
1470 kind = i18n( "Birthday" ); 1457 kind = i18n( "Birthday" );
1471 else 1458 else
1472 kind = i18n( "Anniversary" ); 1459 kind = i18n( "Anniversary" );
1473 ev->setSummary( name + " - " + kind ); 1460 ev->setSummary( name + " - " + kind );
1474 ev->setOrganizer( "nobody@nowhere" ); 1461 ev->setOrganizer( "nobody@nowhere" );
1475 ev->setCategories( kind ); 1462 ev->setCategories( kind );
1476 ev->setDtStart( QDateTime(date) ); 1463 ev->setDtStart( QDateTime(date) );
1477 ev->setDtEnd( QDateTime(date) ); 1464 ev->setDtEnd( QDateTime(date) );
1478 ev->setFloats( true ); 1465 ev->setFloats( true );
1479 Recurrence * rec = ev->recurrence(); 1466 Recurrence * rec = ev->recurrence();
1480 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1467 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1481 rec->addYearlyNum( date.month() ); 1468 rec->addYearlyNum( date.month() );
1482 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1469 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1483 delete ev; 1470 delete ev;
1484 return false; 1471 return false;
1485 } 1472 }
1486 return true; 1473 return true;
1487 1474
1488} 1475}
1489bool CalendarView::importQtopia( const QString &categories, 1476bool CalendarView::importQtopia( const QString &categories,
1490 const QString &datebook, 1477 const QString &datebook,
1491 const QString &todolist ) 1478 const QString &todolist )
1492{ 1479{
1493 1480
1494 QtopiaFormat qtopiaFormat; 1481 QtopiaFormat qtopiaFormat;
1495 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1482 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1496 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1483 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1497 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1484 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1498 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1485 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1499 1486
1500 updateView(); 1487 updateView();
1501 return true; 1488 return true;
1502 1489
1503#if 0 1490#if 0
1504 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1491 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1505 mCurrentSyncDevice = "qtopia-XML"; 1492 mCurrentSyncDevice = "qtopia-XML";
1506 if ( mSyncManager->mAskForPreferences ) 1493 if ( mSyncManager->mAskForPreferences )
1507 edit_sync_options(); 1494 edit_sync_options();
1508 qApp->processEvents(); 1495 qApp->processEvents();
1509 CalendarLocal* calendar = new CalendarLocal(); 1496 CalendarLocal* calendar = new CalendarLocal();
1510 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1497 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1511 bool syncOK = false; 1498 bool syncOK = false;
1512 QtopiaFormat qtopiaFormat; 1499 QtopiaFormat qtopiaFormat;
1513 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1500 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1514 bool loadOk = true; 1501 bool loadOk = true;
1515 if ( !categories.isEmpty() ) 1502 if ( !categories.isEmpty() )
1516 loadOk = qtopiaFormat.load( calendar, categories ); 1503 loadOk = qtopiaFormat.load( calendar, categories );
1517 if ( loadOk && !datebook.isEmpty() ) 1504 if ( loadOk && !datebook.isEmpty() )
1518 loadOk = qtopiaFormat.load( calendar, datebook ); 1505 loadOk = qtopiaFormat.load( calendar, datebook );
1519 if ( loadOk && !todolist.isEmpty() ) 1506 if ( loadOk && !todolist.isEmpty() )
1520 loadOk = qtopiaFormat.load( calendar, todolist ); 1507 loadOk = qtopiaFormat.load( calendar, todolist );
1521 1508
1522 if ( loadOk ) { 1509 if ( loadOk ) {
1523 getEventViewerDialog()->setSyncMode( true ); 1510 getEventViewerDialog()->setSyncMode( true );
1524 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1511 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1525 getEventViewerDialog()->setSyncMode( false ); 1512 getEventViewerDialog()->setSyncMode( false );
1526 qApp->processEvents(); 1513 qApp->processEvents();
1527 if ( syncOK ) { 1514 if ( syncOK ) {
1528 if ( mSyncManager->mWriteBackFile ) 1515 if ( mSyncManager->mWriteBackFile )
1529 { 1516 {
1530 // write back XML file 1517 // write back XML file
1531 1518
1532 } 1519 }
1533 setModified( true ); 1520 setModified( true );
1534 } 1521 }
1535 } else { 1522 } else {
1536 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1523 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1537 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1524 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1538 question, i18n("Ok")) ; 1525 question, i18n("Ok")) ;
1539 } 1526 }
1540 delete calendar; 1527 delete calendar;
1541 updateView(); 1528 updateView();
1542 return syncOK; 1529 return syncOK;
1543 1530
1544 1531
1545#endif 1532#endif
1546 1533
1547} 1534}
1548 1535
1549void CalendarView::setSyncEventsReadOnly() 1536void CalendarView::setSyncEventsReadOnly()
1550{ 1537{
1551 Event * ev; 1538 Event * ev;
1552 QPtrList<Event> eL = mCalendar->rawEvents(); 1539 QPtrList<Event> eL = mCalendar->rawEvents();
1553 ev = eL.first(); 1540 ev = eL.first();
1554 while ( ev ) { 1541 while ( ev ) {
1555 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1542 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1556 ev->setReadOnly( true ); 1543 ev->setReadOnly( true );
1557 ev = eL.next(); 1544 ev = eL.next();
1558 } 1545 }
1559} 1546}
1560bool CalendarView::openCalendar(QString filename, bool merge) 1547bool CalendarView::openCalendar(QString filename, bool merge)
1561{ 1548{
1562 1549
1563 if (filename.isEmpty()) { 1550 if (filename.isEmpty()) {
1564 return false; 1551 return false;
1565 } 1552 }
1566 1553
1567 if (!QFile::exists(filename)) { 1554 if (!QFile::exists(filename)) {
1568 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1555 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1569 return false; 1556 return false;
1570 } 1557 }
1571 1558
1572 globalFlagBlockAgenda = 1; 1559 globalFlagBlockAgenda = 1;
1573 if (!merge) mCalendar->close(); 1560 if (!merge) mCalendar->close();
1574 1561
1575 mStorage->setFileName( filename ); 1562 mStorage->setFileName( filename );
1576 1563
1577 if ( mStorage->load() ) { 1564 if ( mStorage->load() ) {
1578 if ( merge ) ;//setModified( true ); 1565 if ( merge ) ;//setModified( true );
1579 else { 1566 else {
1580 //setModified( true ); 1567 //setModified( true );
1581 mViewManager->setDocumentId( filename ); 1568 mViewManager->setDocumentId( filename );
1582 mDialogManager->setDocumentId( filename ); 1569 mDialogManager->setDocumentId( filename );
1583 mTodoList->setDocumentId( filename ); 1570 mTodoList->setDocumentId( filename );
1584 } 1571 }
1585 globalFlagBlockAgenda = 2; 1572 globalFlagBlockAgenda = 2;
1586 // if ( getLastSyncEvent() ) 1573 // if ( getLastSyncEvent() )
1587 // getLastSyncEvent()->setReadOnly( true ); 1574 // getLastSyncEvent()->setReadOnly( true );
1588 mCalendar->reInitAlarmSettings(); 1575 mCalendar->reInitAlarmSettings();
1589 setSyncEventsReadOnly(); 1576 setSyncEventsReadOnly();
1590 updateUnmanagedViews(); 1577 updateUnmanagedViews();
1591 updateView(); 1578 updateView();
1592 setLoadedFileVersion( QDateTime::currentDateTime().addSecs( -1 ));
1593 if ( filename != MainWindow::defaultFileName() ) { 1579 if ( filename != MainWindow::defaultFileName() ) {
1594 saveCalendar( MainWindow::defaultFileName() ); 1580 saveCalendar( MainWindow::defaultFileName() );
1595 watchSavedFile(); 1581 } else {
1582 QFileInfo finf ( MainWindow::defaultFileName());
1583 if ( finf.exists() ) {
1584 setLoadedFileVersion( finf.lastModified () );
1585 }
1596 } 1586 }
1597 return true; 1587 return true;
1598 } else { 1588 } else {
1599 // while failing to load, the calendar object could 1589 // while failing to load, the calendar object could
1600 // have become partially populated. Clear it out. 1590 // have become partially populated. Clear it out.
1601 if ( !merge ) { 1591 if ( !merge ) {
1602 mCalendar->close(); 1592 mCalendar->close();
1603 mViewManager->setDocumentId( filename ); 1593 mViewManager->setDocumentId( filename );
1604 mDialogManager->setDocumentId( filename ); 1594 mDialogManager->setDocumentId( filename );
1605 mTodoList->setDocumentId( filename ); 1595 mTodoList->setDocumentId( filename );
1606 } 1596 }
1607 1597
1608 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1598 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1609 1599
1610 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 1600 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
1611 globalFlagBlockAgenda = 2; 1601 globalFlagBlockAgenda = 2;
1612 mCalendar->reInitAlarmSettings(); 1602 mCalendar->reInitAlarmSettings();
1613 setSyncEventsReadOnly(); 1603 setSyncEventsReadOnly();
1614 updateUnmanagedViews(); 1604 updateUnmanagedViews();
1615 updateView(); 1605 updateView();
1616 } 1606 }
1617 return false; 1607 return false;
1618} 1608}
1619void CalendarView::showOpenError() 1609void CalendarView::showOpenError()
1620{ 1610{
1621 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 1611 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
1622} 1612}
1623void CalendarView::setLoadedFileVersion(QDateTime dt) 1613void CalendarView::setLoadedFileVersion(QDateTime dt)
1624{ 1614{
1625 loadedFileVersion = dt; 1615 loadedFileVersion = dt;
1626} 1616}
1627bool CalendarView::checkFileChanged(QString fn) 1617bool CalendarView::checkFileChanged(QString fn)
1628{ 1618{
1629 QFileInfo finf ( fn ); 1619 QFileInfo finf ( fn );
1630 if ( !finf.exists() ) 1620 if ( !finf.exists() )
1631 return true; 1621 return true;
1632 QDateTime dt = finf.lastModified (); 1622 QDateTime dt = finf.lastModified ();
1633 if ( dt <= loadedFileVersion ) 1623 if ( dt <= loadedFileVersion )
1634 return false; 1624 return false;
1635 return true; 1625 return true;
1636 1626
1637} 1627}
1638void CalendarView::watchSavedFile() 1628void CalendarView::watchSavedFile()
1639{ 1629{
1640 QFileInfo finf ( MainWindow::defaultFileName()); 1630 QFileInfo finf ( MainWindow::defaultFileName());
1641 if ( !finf.exists() ) 1631 if ( !finf.exists() )
1642 return; 1632 return;
1643 QDateTime dt = finf.lastModified (); 1633 QDateTime dt = finf.lastModified ();
1644 if ( dt < loadedFileVersion ) { 1634 if ( dt < loadedFileVersion ) {
1645 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 1635 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
1646 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 1636 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1647 return; 1637 return;
1648 } 1638 }
1649 loadedFileVersion = dt; 1639 loadedFileVersion = dt;
1650} 1640}
1651 1641
1652bool CalendarView::checkFileVersion(QString fn) 1642bool CalendarView::checkFileVersion(QString fn)
1653{ 1643{
1654 QFileInfo finf ( fn ); 1644 QFileInfo finf ( fn );
1655 if ( !finf.exists() ) 1645 if ( !finf.exists() )
1656 return true; 1646 return true;
1657 QDateTime dt = finf.lastModified (); 1647 QDateTime dt = finf.lastModified ();
1658 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1648 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1659 //qDebug("file on disk version %s",dt.toString().latin1()); 1649 //qDebug("file on disk version %s",dt.toString().latin1());
1660 if ( dt <= loadedFileVersion ) 1650 if ( dt <= loadedFileVersion )
1661 return true; 1651 return true;
1662 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , 1652 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) ,
1663 i18n("KO/Pi Warning"),i18n("Overwrite"), 1653 i18n("KO/Pi Warning"),i18n("Overwrite"),
1664 i18n("Sync+save")); 1654 i18n("Sync+save"));
1665 1655
1666 if ( km == KMessageBox::Cancel ) 1656 if ( km == KMessageBox::Cancel )
1667 return false; 1657 return false;
1668 if ( km == KMessageBox::Yes ) 1658 if ( km == KMessageBox::Yes )
1669 return true; 1659 return true;
1670 1660
1671 setSyncDevice("deleteaftersync" ); 1661 setSyncDevice("deleteaftersync" );
1672 mSyncManager->mAskForPreferences = true; 1662 mSyncManager->mAskForPreferences = true;
1673 mSyncManager->mSyncAlgoPrefs = 3; 1663 mSyncManager->mSyncAlgoPrefs = 3;
1674 mSyncManager->mWriteBackFile = false; 1664 mSyncManager->mWriteBackFile = false;
1675 mSyncManager->mWriteBackExistingOnly = false; 1665 mSyncManager->mWriteBackExistingOnly = false;
1676 mSyncManager->mShowSyncSummary = false; 1666 mSyncManager->mShowSyncSummary = false;
1677 syncCalendar( fn, 3 ); 1667 syncCalendar( fn, 3 );
1678 Event * e = getLastSyncEvent(); 1668 Event * e = getLastSyncEvent();
1679 mCalendar->deleteEvent ( e ); 1669 mCalendar->deleteEvent ( e );
1680 updateView(); 1670 updateView();
1681 return true; 1671 return true;
1682} 1672}
1683 1673
1684bool CalendarView::saveCalendar( QString filename ) 1674bool CalendarView::saveCalendar( QString filename )
1685{ 1675{
1686 1676
1687 // Store back all unsaved data into calendar object 1677 // Store back all unsaved data into calendar object
1688 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1678 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1689 if ( mViewManager->currentView() ) 1679 if ( mViewManager->currentView() )
1690 mViewManager->currentView()->flushView(); 1680 mViewManager->currentView()->flushView();
1691 1681
1692 //mStorage->setFileName( filename ); 1682
1693 1683 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
1694 mStorage->setSaveFormat( new ICalFormat() ); 1684 mStorage->setSaveFormat( new ICalFormat() );
1695 mStorage->setFileName( filename ); 1685 mStorage->setFileName( filename );
1696 bool success; 1686 bool success;
1697 success = mStorage->save(); 1687 success = mStorage->save();
1698 if ( !success ) { 1688 if ( !success ) {
1699 return false; 1689 return false;
1700 } 1690 }
1701 1691 if ( filename == MainWindow::defaultFileName() ) {
1692 setLoadedFileVersion( lfv );
1693 watchSavedFile();
1694 }
1702 return true; 1695 return true;
1703} 1696}
1704 1697
1705void CalendarView::closeCalendar() 1698void CalendarView::closeCalendar()
1706{ 1699{
1707 1700
1708 // child windows no longer valid 1701 // child windows no longer valid
1709 emit closingDown(); 1702 emit closingDown();
1710 1703
1711 mCalendar->close(); 1704 mCalendar->close();
1712 setModified(false); 1705 setModified(false);
1713 updateView(); 1706 updateView();
1714} 1707}
1715 1708
1716void CalendarView::archiveCalendar() 1709void CalendarView::archiveCalendar()
1717{ 1710{
1718 mDialogManager->showArchiveDialog(); 1711 mDialogManager->showArchiveDialog();
1719} 1712}
1720 1713
1721 1714
1722void CalendarView::readSettings() 1715void CalendarView::readSettings()
1723{ 1716{
1724 1717
1725 1718
1726 // mViewManager->showAgendaView(); 1719 // mViewManager->showAgendaView();
1727 QString str; 1720 QString str;
1728 //qDebug("CalendarView::readSettings() "); 1721 //qDebug("CalendarView::readSettings() ");
1729 // read settings from the KConfig, supplying reasonable 1722 // read settings from the KConfig, supplying reasonable
1730 // defaults where none are to be found 1723 // defaults where none are to be found
1731 KConfig *config = KOGlobals::config(); 1724 KConfig *config = KOGlobals::config();
1732#ifndef KORG_NOSPLITTER 1725#ifndef KORG_NOSPLITTER
1733 config->setGroup("KOrganizer Geometry"); 1726 config->setGroup("KOrganizer Geometry");
1734 1727
1735 QValueList<int> sizes = config->readIntListEntry("Separator1"); 1728 QValueList<int> sizes = config->readIntListEntry("Separator1");
1736 if (sizes.count() != 2) { 1729 if (sizes.count() != 2) {
1737 sizes << mDateNavigator->minimumSizeHint().width(); 1730 sizes << mDateNavigator->minimumSizeHint().width();
1738 sizes << 300; 1731 sizes << 300;
1739 } 1732 }
1740 mPanner->setSizes(sizes); 1733 mPanner->setSizes(sizes);
1741 1734
1742 sizes = config->readIntListEntry("Separator2"); 1735 sizes = config->readIntListEntry("Separator2");
1743 if ( ( mResourceView && sizes.count() == 4 ) || 1736 if ( ( mResourceView && sizes.count() == 4 ) ||
1744 ( !mResourceView && sizes.count() == 3 ) ) { 1737 ( !mResourceView && sizes.count() == 3 ) ) {
1745 mLeftSplitter->setSizes(sizes); 1738 mLeftSplitter->setSizes(sizes);
1746 } 1739 }
1747#endif 1740#endif
1748 globalFlagBlockAgenda = 1; 1741 globalFlagBlockAgenda = 1;
1749 mViewManager->showAgendaView(); 1742 mViewManager->showAgendaView();
1750 //mViewManager->readSettings( config ); 1743 //mViewManager->readSettings( config );
1751 mTodoList->restoreLayout(config,QString("Todo Layout")); 1744 mTodoList->restoreLayout(config,QString("Todo Layout"));
1752 readFilterSettings(config); 1745 readFilterSettings(config);
1753 config->setGroup( "Views" ); 1746 config->setGroup( "Views" );
1754 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 1747 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
1755 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 1748 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
1756 else if ( dateCount == 7 ) mNavigator->selectWeek(); 1749 else if ( dateCount == 7 ) mNavigator->selectWeek();
1757 else mNavigator->selectDates( dateCount ); 1750 else mNavigator->selectDates( dateCount );
1758 // mViewManager->readSettings( config ); 1751 // mViewManager->readSettings( config );
1759 updateConfig(); 1752 updateConfig();
1760 globalFlagBlockAgenda = 2; 1753 globalFlagBlockAgenda = 2;
1761 mViewManager->readSettings( config ); 1754 mViewManager->readSettings( config );
1762#ifdef DESKTOP_VERSION 1755#ifdef DESKTOP_VERSION
1763 config->setGroup("WidgetLayout"); 1756 config->setGroup("WidgetLayout");
1764 QStringList list; 1757 QStringList list;
1765 list = config->readListEntry("MainLayout"); 1758 list = config->readListEntry("MainLayout");
1766 int x,y,w,h; 1759 int x,y,w,h;
1767 if ( ! list.isEmpty() ) { 1760 if ( ! list.isEmpty() ) {
1768 x = list[0].toInt(); 1761 x = list[0].toInt();
1769 y = list[1].toInt(); 1762 y = list[1].toInt();
1770 w = list[2].toInt(); 1763 w = list[2].toInt();
1771 h = list[3].toInt(); 1764 h = list[3].toInt();
1772 topLevelWidget()->setGeometry(x,y,w,h); 1765 topLevelWidget()->setGeometry(x,y,w,h);
1773 1766
1774 } else { 1767 } else {
1775 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 1768 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
1776 } 1769 }
1777 list = config->readListEntry("EditEventLayout"); 1770 list = config->readListEntry("EditEventLayout");
1778 if ( ! list.isEmpty() ) { 1771 if ( ! list.isEmpty() ) {
1779 x = list[0].toInt(); 1772 x = list[0].toInt();
1780 y = list[1].toInt(); 1773 y = list[1].toInt();
1781 w = list[2].toInt(); 1774 w = list[2].toInt();
1782 h = list[3].toInt(); 1775 h = list[3].toInt();
1783 mEventEditor->setGeometry(x,y,w,h); 1776 mEventEditor->setGeometry(x,y,w,h);
1784 1777
1785 } 1778 }
1786 list = config->readListEntry("EditTodoLayout"); 1779 list = config->readListEntry("EditTodoLayout");
1787 if ( ! list.isEmpty() ) { 1780 if ( ! list.isEmpty() ) {
1788 x = list[0].toInt(); 1781 x = list[0].toInt();
1789 y = list[1].toInt(); 1782 y = list[1].toInt();
1790 w = list[2].toInt(); 1783 w = list[2].toInt();
1791 h = list[3].toInt(); 1784 h = list[3].toInt();
1792 mTodoEditor->setGeometry(x,y,w,h); 1785 mTodoEditor->setGeometry(x,y,w,h);
1793 1786
1794 } 1787 }
1795 list = config->readListEntry("ViewerLayout"); 1788 list = config->readListEntry("ViewerLayout");
1796 if ( ! list.isEmpty() ) { 1789 if ( ! list.isEmpty() ) {
1797 x = list[0].toInt(); 1790 x = list[0].toInt();
1798 y = list[1].toInt(); 1791 y = list[1].toInt();
1799 w = list[2].toInt(); 1792 w = list[2].toInt();
1800 h = list[3].toInt(); 1793 h = list[3].toInt();
1801 getEventViewerDialog()->setGeometry(x,y,w,h); 1794 getEventViewerDialog()->setGeometry(x,y,w,h);
1802 } 1795 }
1803#endif 1796#endif
1804 1797
1805} 1798}
1806 1799
1807 1800
1808void CalendarView::writeSettings() 1801void CalendarView::writeSettings()
1809{ 1802{
1810 // kdDebug() << "CalendarView::writeSettings" << endl; 1803 // kdDebug() << "CalendarView::writeSettings" << endl;
1811 1804
1812 KConfig *config = KOGlobals::config(); 1805 KConfig *config = KOGlobals::config();
1813 1806
1814#ifndef KORG_NOSPLITTER 1807#ifndef KORG_NOSPLITTER
1815 config->setGroup("KOrganizer Geometry"); 1808 config->setGroup("KOrganizer Geometry");
1816 1809
1817 QValueList<int> list = mPanner->sizes(); 1810 QValueList<int> list = mPanner->sizes();
1818 config->writeEntry("Separator1",list); 1811 config->writeEntry("Separator1",list);
1819 1812
1820 list = mLeftSplitter->sizes(); 1813 list = mLeftSplitter->sizes();
1821 config->writeEntry("Separator2",list); 1814 config->writeEntry("Separator2",list);
1822#endif 1815#endif
1823 1816
1824 mViewManager->writeSettings( config ); 1817 mViewManager->writeSettings( config );
1825 mTodoList->saveLayout(config,QString("Todo Layout")); 1818 mTodoList->saveLayout(config,QString("Todo Layout"));
1826 mDialogManager->writeSettings( config ); 1819 mDialogManager->writeSettings( config );
1827 //KOPrefs::instance()->usrWriteConfig(); 1820 //KOPrefs::instance()->usrWriteConfig();
1828 KOPrefs::instance()->writeConfig(); 1821 KOPrefs::instance()->writeConfig();
1829 1822
1830 writeFilterSettings(config); 1823 writeFilterSettings(config);
1831 1824
1832 config->setGroup( "Views" ); 1825 config->setGroup( "Views" );
1833 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 1826 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
1834 1827
1835#ifdef DESKTOP_VERSION 1828#ifdef DESKTOP_VERSION
1836 config->setGroup("WidgetLayout"); 1829 config->setGroup("WidgetLayout");
1837 QStringList list ;//= config->readListEntry("MainLayout"); 1830 QStringList list ;//= config->readListEntry("MainLayout");
1838 int x,y,w,h; 1831 int x,y,w,h;
1839 QWidget* wid; 1832 QWidget* wid;
1840 wid = topLevelWidget(); 1833 wid = topLevelWidget();
1841 x = wid->geometry().x(); 1834 x = wid->geometry().x();
1842 y = wid->geometry().y(); 1835 y = wid->geometry().y();
1843 w = wid->width(); 1836 w = wid->width();
1844 h = wid->height(); 1837 h = wid->height();
1845 list.clear(); 1838 list.clear();
1846 list << QString::number( x ); 1839 list << QString::number( x );
1847 list << QString::number( y ); 1840 list << QString::number( y );
1848 list << QString::number( w ); 1841 list << QString::number( w );
1849 list << QString::number( h ); 1842 list << QString::number( h );
1850 config->writeEntry("MainLayout",list ); 1843 config->writeEntry("MainLayout",list );
1851 1844
1852 wid = mEventEditor; 1845 wid = mEventEditor;
1853 x = wid->geometry().x(); 1846 x = wid->geometry().x();
1854 y = wid->geometry().y(); 1847 y = wid->geometry().y();
1855 w = wid->width(); 1848 w = wid->width();
1856 h = wid->height(); 1849 h = wid->height();
1857 list.clear(); 1850 list.clear();
1858 list << QString::number( x ); 1851 list << QString::number( x );
1859 list << QString::number( y ); 1852 list << QString::number( y );
1860 list << QString::number( w ); 1853 list << QString::number( w );
1861 list << QString::number( h ); 1854 list << QString::number( h );
1862 config->writeEntry("EditEventLayout",list ); 1855 config->writeEntry("EditEventLayout",list );
1863 1856
1864 wid = mTodoEditor; 1857 wid = mTodoEditor;
1865 x = wid->geometry().x(); 1858 x = wid->geometry().x();
1866 y = wid->geometry().y(); 1859 y = wid->geometry().y();
1867 w = wid->width(); 1860 w = wid->width();
1868 h = wid->height(); 1861 h = wid->height();
1869 list.clear(); 1862 list.clear();
1870 list << QString::number( x ); 1863 list << QString::number( x );
1871 list << QString::number( y ); 1864 list << QString::number( y );
1872 list << QString::number( w ); 1865 list << QString::number( w );
1873 list << QString::number( h ); 1866 list << QString::number( h );
1874 config->writeEntry("EditTodoLayout",list ); 1867 config->writeEntry("EditTodoLayout",list );
1875 wid = getEventViewerDialog(); 1868 wid = getEventViewerDialog();
1876 x = wid->geometry().x(); 1869 x = wid->geometry().x();
1877 y = wid->geometry().y(); 1870 y = wid->geometry().y();
1878 w = wid->width(); 1871 w = wid->width();
1879 h = wid->height(); 1872 h = wid->height();
1880 list.clear(); 1873 list.clear();
1881 list << QString::number( x ); 1874 list << QString::number( x );
1882 list << QString::number( y ); 1875 list << QString::number( y );
1883 list << QString::number( w ); 1876 list << QString::number( w );
1884 list << QString::number( h ); 1877 list << QString::number( h );
1885 config->writeEntry("ViewerLayout",list ); 1878 config->writeEntry("ViewerLayout",list );
1886 wid = mDialogManager->getSearchDialog(); 1879 wid = mDialogManager->getSearchDialog();
1887 if ( wid ) { 1880 if ( wid ) {
1888 x = wid->geometry().x(); 1881 x = wid->geometry().x();
1889 y = wid->geometry().y(); 1882 y = wid->geometry().y();
1890 w = wid->width(); 1883 w = wid->width();
1891 h = wid->height(); 1884 h = wid->height();
1892 list.clear(); 1885 list.clear();
1893 list << QString::number( x ); 1886 list << QString::number( x );
1894 list << QString::number( y ); 1887 list << QString::number( y );
1895 list << QString::number( w ); 1888 list << QString::number( w );
1896 list << QString::number( h ); 1889 list << QString::number( h );
1897 config->writeEntry("SearchLayout",list ); 1890 config->writeEntry("SearchLayout",list );
1898 } 1891 }
1899#endif 1892#endif
1900 1893
1901 1894
1902 config->sync(); 1895 config->sync();
1903} 1896}
1904 1897
1905void CalendarView::readFilterSettings(KConfig *config) 1898void CalendarView::readFilterSettings(KConfig *config)
1906{ 1899{
1907 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 1900 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
1908 1901
1909 mFilters.clear(); 1902 mFilters.clear();
1910 1903
1911 config->setGroup("General"); 1904 config->setGroup("General");
1912 QStringList filterList = config->readListEntry("CalendarFilters"); 1905 QStringList filterList = config->readListEntry("CalendarFilters");
1913 1906
1914 QStringList::ConstIterator it = filterList.begin(); 1907 QStringList::ConstIterator it = filterList.begin();
1915 QStringList::ConstIterator end = filterList.end(); 1908 QStringList::ConstIterator end = filterList.end();
1916 while(it != end) { 1909 while(it != end) {
1917 // kdDebug() << " filter: " << (*it) << endl; 1910 // kdDebug() << " filter: " << (*it) << endl;
1918 1911
1919 CalFilter *filter; 1912 CalFilter *filter;
1920 filter = new CalFilter(*it); 1913 filter = new CalFilter(*it);
1921 config->setGroup("Filter_" + (*it)); 1914 config->setGroup("Filter_" + (*it));
1922 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 1915 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
1923 filter->setCriteria(config->readNumEntry("Criteria",0)); 1916 filter->setCriteria(config->readNumEntry("Criteria",0));
1924 filter->setCategoryList(config->readListEntry("CategoryList")); 1917 filter->setCategoryList(config->readListEntry("CategoryList"));
1925 mFilters.append(filter); 1918 mFilters.append(filter);
1926 1919
1927 ++it; 1920 ++it;
1928 } 1921 }
1929 1922
1930 if (mFilters.count() == 0) { 1923 if (mFilters.count() == 0) {
1931 CalFilter *filter = new CalFilter(i18n("Default")); 1924 CalFilter *filter = new CalFilter(i18n("Default"));
1932 mFilters.append(filter); 1925 mFilters.append(filter);
1933 } 1926 }
1934 mFilterView->updateFilters(); 1927 mFilterView->updateFilters();
1935 config->setGroup("FilterView"); 1928 config->setGroup("FilterView");
1936 1929
1937 mFilterView->blockSignals(true); 1930 mFilterView->blockSignals(true);
1938 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 1931 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
1939 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 1932 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
1940 mFilterView->blockSignals(false); 1933 mFilterView->blockSignals(false);
1941 // We do it manually to avoid it being done twice by the above calls 1934 // We do it manually to avoid it being done twice by the above calls
1942 updateFilter(); 1935 updateFilter();
1943} 1936}
1944 1937
1945void CalendarView::writeFilterSettings(KConfig *config) 1938void CalendarView::writeFilterSettings(KConfig *config)
1946{ 1939{
1947 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 1940 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
1948 1941
1949 QStringList filterList; 1942 QStringList filterList;
1950 1943
1951 CalFilter *filter = mFilters.first(); 1944 CalFilter *filter = mFilters.first();
1952 while(filter) { 1945 while(filter) {
1953 // kdDebug() << " fn: " << filter->name() << endl; 1946 // kdDebug() << " fn: " << filter->name() << endl;
1954 filterList << filter->name(); 1947 filterList << filter->name();
1955 config->setGroup("Filter_" + filter->name()); 1948 config->setGroup("Filter_" + filter->name());
1956 config->writeEntry("Criteria",filter->criteria()); 1949 config->writeEntry("Criteria",filter->criteria());
1957 config->writeEntry("CategoryList",filter->categoryList()); 1950 config->writeEntry("CategoryList",filter->categoryList());
1958 filter = mFilters.next(); 1951 filter = mFilters.next();
1959 } 1952 }
1960 config->setGroup("General"); 1953 config->setGroup("General");
1961 config->writeEntry("CalendarFilters",filterList); 1954 config->writeEntry("CalendarFilters",filterList);
1962 1955
1963 config->setGroup("FilterView"); 1956 config->setGroup("FilterView");
1964 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 1957 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
1965 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 1958 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
1966} 1959}
1967 1960
1968 1961
1969void CalendarView::goToday() 1962void CalendarView::goToday()
1970{ 1963{
1971 mNavigator->selectToday(); 1964 mNavigator->selectToday();
1972} 1965}
1973 1966
1974void CalendarView::goNext() 1967void CalendarView::goNext()
1975{ 1968{
1976 mNavigator->selectNext(); 1969 mNavigator->selectNext();
1977} 1970}
1978 1971
1979void CalendarView::goPrevious() 1972void CalendarView::goPrevious()
1980{ 1973{
1981 mNavigator->selectPrevious(); 1974 mNavigator->selectPrevious();
1982} 1975}
1983void CalendarView::goNextMonth() 1976void CalendarView::goNextMonth()
1984{ 1977{
1985 mNavigator->selectNextMonth(); 1978 mNavigator->selectNextMonth();
1986} 1979}
1987 1980
1988void CalendarView::goPreviousMonth() 1981void CalendarView::goPreviousMonth()
1989{ 1982{
1990 mNavigator->selectPreviousMonth(); 1983 mNavigator->selectPreviousMonth();
1991} 1984}
1992void CalendarView::writeLocale() 1985void CalendarView::writeLocale()
1993{ 1986{
1994 //KPimGlobalPrefs::instance()->setGlobalConfig(); 1987 //KPimGlobalPrefs::instance()->setGlobalConfig();
1995#if 0 1988#if 0
1996 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); 1989 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime );
1997 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); 1990 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday );
1998 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); 1991 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate );
1999 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); 1992 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage );
2000 QString dummy = KOPrefs::instance()->mUserDateFormatLong; 1993 QString dummy = KOPrefs::instance()->mUserDateFormatLong;
2001 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 1994 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
2002 dummy = KOPrefs::instance()->mUserDateFormatShort; 1995 dummy = KOPrefs::instance()->mUserDateFormatShort;
2003 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 1996 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
2004 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, 1997 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving,
2005 KOPrefs::instance()->mDaylightsavingStart, 1998 KOPrefs::instance()->mDaylightsavingStart,
2006 KOPrefs::instance()->mDaylightsavingEnd ); 1999 KOPrefs::instance()->mDaylightsavingEnd );
2007 KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId ); 2000 KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId );
2008#endif 2001#endif
2009} 2002}
2010void CalendarView::updateConfig() 2003void CalendarView::updateConfig()
2011{ 2004{
2012 writeLocale(); 2005 writeLocale();
2013 if ( KOPrefs::instance()->mUseAppColors ) 2006 if ( KOPrefs::instance()->mUseAppColors )
2014 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 2007 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
2015 emit configChanged(); 2008 emit configChanged();
2016 mTodoList->updateConfig(); 2009 mTodoList->updateConfig();
2017 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 2010 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
2018 mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 2011 mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
2019 // To make the "fill window" configurations work 2012 // To make the "fill window" configurations work
2020 //mViewManager->raiseCurrentView(); 2013 //mViewManager->raiseCurrentView();
2021} 2014}
2022 2015
2023 2016
2024void CalendarView::eventChanged(Event *event) 2017void CalendarView::eventChanged(Event *event)
2025{ 2018{
2026 changeEventDisplay(event,KOGlobals::EVENTEDITED); 2019 changeEventDisplay(event,KOGlobals::EVENTEDITED);
2027 //updateUnmanagedViews(); 2020 //updateUnmanagedViews();
2028} 2021}
2029 2022
2030void CalendarView::eventAdded(Event *event) 2023void CalendarView::eventAdded(Event *event)
2031{ 2024{
2032 changeEventDisplay(event,KOGlobals::EVENTADDED); 2025 changeEventDisplay(event,KOGlobals::EVENTADDED);
2033} 2026}
2034 2027
2035void CalendarView::eventToBeDeleted(Event *) 2028void CalendarView::eventToBeDeleted(Event *)
2036{ 2029{
2037 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 2030 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
2038} 2031}
2039 2032
2040void CalendarView::eventDeleted() 2033void CalendarView::eventDeleted()
2041{ 2034{
2042 changeEventDisplay(0,KOGlobals::EVENTDELETED); 2035 changeEventDisplay(0,KOGlobals::EVENTDELETED);
2043} 2036}
2044void CalendarView::changeTodoDisplay(Todo *which, int action) 2037void CalendarView::changeTodoDisplay(Todo *which, int action)
2045{ 2038{
2046 changeIncidenceDisplay((Incidence *)which, action); 2039 changeIncidenceDisplay((Incidence *)which, action);
2047 mDateNavigator->updateView(); //LR 2040 mDateNavigator->updateView(); //LR
2048 //mDialogManager->updateSearchDialog(); 2041 //mDialogManager->updateSearchDialog();
2049 2042
2050 if (which) { 2043 if (which) {
2051 mViewManager->updateWNview(); 2044 mViewManager->updateWNview();
2052 //mTodoList->updateView(); 2045 //mTodoList->updateView();
2053 } 2046 }
2054 2047
2055} 2048}
2056 2049
2057void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 2050void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
2058{ 2051{
2059 updateUnmanagedViews(); 2052 updateUnmanagedViews();
2060 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 2053 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
2061 if ( action == KOGlobals::EVENTDELETED ) { //delete 2054 if ( action == KOGlobals::EVENTDELETED ) { //delete
2062 mCalendar->checkAlarmForIncidence( 0, true ); 2055 mCalendar->checkAlarmForIncidence( 0, true );
2063 if ( mEventViewerDialog ) 2056 if ( mEventViewerDialog )
2064 mEventViewerDialog->hide(); 2057 mEventViewerDialog->hide();
2065 } 2058 }
2066 else 2059 else
2067 mCalendar->checkAlarmForIncidence( which , false ); 2060 mCalendar->checkAlarmForIncidence( which , false );
2068} 2061}
2069 2062
2070// most of the changeEventDisplays() right now just call the view's 2063// most of the changeEventDisplays() right now just call the view's
2071// total update mode, but they SHOULD be recoded to be more refresh-efficient. 2064// total update mode, but they SHOULD be recoded to be more refresh-efficient.
2072void CalendarView::changeEventDisplay(Event *which, int action) 2065void CalendarView::changeEventDisplay(Event *which, int action)
2073{ 2066{
2074 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 2067 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
2075 changeIncidenceDisplay((Incidence *)which, action); 2068 changeIncidenceDisplay((Incidence *)which, action);
2076 mDateNavigator->updateView(); 2069 mDateNavigator->updateView();
2077 //mDialogManager->updateSearchDialog(); 2070 //mDialogManager->updateSearchDialog();
2078 2071
2079 if (which) { 2072 if (which) {
2080 // If there is an event view visible update the display 2073 // If there is an event view visible update the display
2081 mViewManager->currentView()->changeEventDisplay(which,action); 2074 mViewManager->currentView()->changeEventDisplay(which,action);
2082 // TODO: check, if update needed 2075 // TODO: check, if update needed
2083 // if (which->getTodoStatus()) { 2076 // if (which->getTodoStatus()) {
2084 mTodoList->updateView(); 2077 mTodoList->updateView();
2085 // } 2078 // }
2086 } else { 2079 } else {
2087 mViewManager->currentView()->updateView(); 2080 mViewManager->currentView()->updateView();
2088 } 2081 }
2089} 2082}
2090 2083
2091 2084
2092void CalendarView::updateTodoViews() 2085void CalendarView::updateTodoViews()
2093{ 2086{
2094 2087
2095 mTodoList->updateView(); 2088 mTodoList->updateView();
2096 mViewManager->currentView()->updateView(); 2089 mViewManager->currentView()->updateView();
2097 2090
2098} 2091}
2099 2092
2100 2093
2101void CalendarView::updateView(const QDate &start, const QDate &end) 2094void CalendarView::updateView(const QDate &start, const QDate &end)
2102{ 2095{
2103 mTodoList->updateView(); 2096 mTodoList->updateView();
2104 mViewManager->updateView(start, end); 2097 mViewManager->updateView(start, end);
2105 //mDateNavigator->updateView(); 2098 //mDateNavigator->updateView();
2106} 2099}
2107 2100
2108void CalendarView::updateView() 2101void CalendarView::updateView()
2109{ 2102{
2110 DateList tmpList = mNavigator->selectedDates(); 2103 DateList tmpList = mNavigator->selectedDates();
2111 2104
2112 // We assume that the navigator only selects consecutive days. 2105 // We assume that the navigator only selects consecutive days.
2113 updateView( tmpList.first(), tmpList.last() ); 2106 updateView( tmpList.first(), tmpList.last() );
2114} 2107}
2115 2108
2116void CalendarView::updateUnmanagedViews() 2109void CalendarView::updateUnmanagedViews()
2117{ 2110{
2118 mDateNavigator->updateDayMatrix(); 2111 mDateNavigator->updateDayMatrix();
2119} 2112}
2120 2113
2121int CalendarView::msgItemDelete() 2114int CalendarView::msgItemDelete()
2122{ 2115{
2123 return KMessageBox::warningContinueCancel(this, 2116 return KMessageBox::warningContinueCancel(this,
2124 i18n("This item will be\npermanently deleted."), 2117 i18n("This item will be\npermanently deleted."),
2125 i18n("KO/Pi Confirmation"),i18n("Delete")); 2118 i18n("KO/Pi Confirmation"),i18n("Delete"));
2126} 2119}
2127 2120
2128 2121
2129void CalendarView::edit_cut() 2122void CalendarView::edit_cut()
2130{ 2123{
2131 Event *anEvent=0; 2124 Event *anEvent=0;
2132 2125
2133 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2126 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2134 2127
2135 if (mViewManager->currentView()->isEventView()) { 2128 if (mViewManager->currentView()->isEventView()) {
2136 if ( incidence && incidence->type() == "Event" ) { 2129 if ( incidence && incidence->type() == "Event" ) {
2137 anEvent = static_cast<Event *>(incidence); 2130 anEvent = static_cast<Event *>(incidence);
2138 } 2131 }
2139 } 2132 }
2140 2133
2141 if (!anEvent) { 2134 if (!anEvent) {
2142 KNotifyClient::beep(); 2135 KNotifyClient::beep();
2143 return; 2136 return;
2144 } 2137 }
2145 DndFactory factory( mCalendar ); 2138 DndFactory factory( mCalendar );
2146 factory.cutEvent(anEvent); 2139 factory.cutEvent(anEvent);
2147 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2140 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2148} 2141}
2149 2142
2150void CalendarView::edit_copy() 2143void CalendarView::edit_copy()
2151{ 2144{
2152 Event *anEvent=0; 2145 Event *anEvent=0;
2153 2146
2154 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2147 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2155 2148
2156 if (mViewManager->currentView()->isEventView()) { 2149 if (mViewManager->currentView()->isEventView()) {
2157 if ( incidence && incidence->type() == "Event" ) { 2150 if ( incidence && incidence->type() == "Event" ) {
2158 anEvent = static_cast<Event *>(incidence); 2151 anEvent = static_cast<Event *>(incidence);
2159 } 2152 }
2160 } 2153 }
2161 2154
2162 if (!anEvent) { 2155 if (!anEvent) {
2163 KNotifyClient::beep(); 2156 KNotifyClient::beep();
2164 return; 2157 return;
2165 } 2158 }
2166 DndFactory factory( mCalendar ); 2159 DndFactory factory( mCalendar );
2167 factory.copyEvent(anEvent); 2160 factory.copyEvent(anEvent);
2168} 2161}
2169 2162
2170void CalendarView::edit_paste() 2163void CalendarView::edit_paste()
2171{ 2164{
2172 QDate date = mNavigator->selectedDates().first(); 2165 QDate date = mNavigator->selectedDates().first();
2173 2166
2174 DndFactory factory( mCalendar ); 2167 DndFactory factory( mCalendar );
2175 Event *pastedEvent = factory.pasteEvent( date ); 2168 Event *pastedEvent = factory.pasteEvent( date );
2176 2169
2177 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 2170 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
2178} 2171}
2179 2172
2180void CalendarView::edit_options() 2173void CalendarView::edit_options()
2181{ 2174{
2182 mDialogManager->showOptionsDialog(); 2175 mDialogManager->showOptionsDialog();
2183 //writeSettings(); 2176 //writeSettings();
2184} 2177}
2185void CalendarView::edit_sync_options()
2186{
2187 // DELETE
2188
2189}
2190 2178
2191void CalendarView::slotSelectPickerDate( QDate d) 2179void CalendarView::slotSelectPickerDate( QDate d)
2192{ 2180{
2193 mDateFrame->hide(); 2181 mDateFrame->hide();
2194 if ( mDatePickerMode == 1 ) { 2182 if ( mDatePickerMode == 1 ) {
2195 mNavigator->slotDaySelect( d ); 2183 mNavigator->slotDaySelect( d );
2196 } else if ( mDatePickerMode == 2 ) { 2184 } else if ( mDatePickerMode == 2 ) {
2197 if ( mMoveIncidence->type() == "Todo" ) { 2185 if ( mMoveIncidence->type() == "Todo" ) {
2198 Todo * to = (Todo *) mMoveIncidence; 2186 Todo * to = (Todo *) mMoveIncidence;
2199 QTime tim; 2187 QTime tim;
2200 if ( to->hasDueDate() ) 2188 if ( to->hasDueDate() )
2201 tim = to->dtDue().time(); 2189 tim = to->dtDue().time();
2202 else { 2190 else {
2203 tim = QTime ( 0,0,0 ); 2191 tim = QTime ( 0,0,0 );
2204 to->setFloats( true ); 2192 to->setFloats( true );
2205 to->setHasDueDate( true ); 2193 to->setHasDueDate( true );
2206 } 2194 }
2207 QDateTime dt ( d,tim ); 2195 QDateTime dt ( d,tim );
2208 to->setDtDue( dt ); 2196 to->setDtDue( dt );
2209 todoChanged( to ); 2197 todoChanged( to );
2210 } else { 2198 } else {
2211 QTime tim = mMoveIncidence->dtStart().time(); 2199 QTime tim = mMoveIncidence->dtStart().time();
2212 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2200 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2213 QDateTime dt ( d,tim ); 2201 QDateTime dt ( d,tim );
2214 mMoveIncidence->setDtStart( dt ); 2202 mMoveIncidence->setDtStart( dt );
2215 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2203 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2216 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2204 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2217 } 2205 }
2218 2206
2219 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2207 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2220 } 2208 }
2221} 2209}
2222 2210
2223void CalendarView::removeCategories() 2211void CalendarView::removeCategories()
2224{ 2212{
2225 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2213 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2226 QStringList catList = KOPrefs::instance()->mCustomCategories; 2214 QStringList catList = KOPrefs::instance()->mCustomCategories;
2227 QStringList catIncList; 2215 QStringList catIncList;
2228 QStringList newCatList; 2216 QStringList newCatList;
2229 Incidence* inc = incList.first(); 2217 Incidence* inc = incList.first();
2230 int i; 2218 int i;
2231 int count = 0; 2219 int count = 0;
2232 while ( inc ) { 2220 while ( inc ) {
2233 newCatList.clear(); 2221 newCatList.clear();
2234 catIncList = inc->categories() ; 2222 catIncList = inc->categories() ;
2235 for( i = 0; i< catIncList.count(); ++i ) { 2223 for( i = 0; i< catIncList.count(); ++i ) {
2236 if ( catList.contains (catIncList[i])) 2224 if ( catList.contains (catIncList[i]))
2237 newCatList.append( catIncList[i] ); 2225 newCatList.append( catIncList[i] );
2238 } 2226 }
2239 newCatList.sort(); 2227 newCatList.sort();
2240 inc->setCategories( newCatList.join(",") ); 2228 inc->setCategories( newCatList.join(",") );
2241 inc = incList.next(); 2229 inc = incList.next();
2242 } 2230 }
2243} 2231}
2244 2232
2245int CalendarView::addCategories() 2233int CalendarView::addCategories()
2246{ 2234{
2247 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2235 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2248 QStringList catList = KOPrefs::instance()->mCustomCategories; 2236 QStringList catList = KOPrefs::instance()->mCustomCategories;
2249 QStringList catIncList; 2237 QStringList catIncList;
2250 Incidence* inc = incList.first(); 2238 Incidence* inc = incList.first();
2251 int i; 2239 int i;
2252 int count = 0; 2240 int count = 0;
2253 while ( inc ) { 2241 while ( inc ) {
2254 catIncList = inc->categories() ; 2242 catIncList = inc->categories() ;
2255 for( i = 0; i< catIncList.count(); ++i ) { 2243 for( i = 0; i< catIncList.count(); ++i ) {
2256 if ( !catList.contains (catIncList[i])) { 2244 if ( !catList.contains (catIncList[i])) {
2257 catList.append( catIncList[i] ); 2245 catList.append( catIncList[i] );
2258 //qDebug("add cat %s ", catIncList[i].latin1()); 2246 //qDebug("add cat %s ", catIncList[i].latin1());
2259 ++count; 2247 ++count;
2260 } 2248 }
2261 } 2249 }
2262 inc = incList.next(); 2250 inc = incList.next();
2263 } 2251 }
2264 catList.sort(); 2252 catList.sort();
2265 KOPrefs::instance()->mCustomCategories = catList; 2253 KOPrefs::instance()->mCustomCategories = catList;
2266 return count; 2254 return count;
2267} 2255}
2268 2256
2269void CalendarView::manageCategories() 2257void CalendarView::manageCategories()
2270{ 2258{
2271 KOCatPrefs* cp = new KOCatPrefs(); 2259 KOCatPrefs* cp = new KOCatPrefs();
2272 cp->show(); 2260 cp->show();
2273 int w =cp->sizeHint().width() ; 2261 int w =cp->sizeHint().width() ;
2274 int h = cp->sizeHint().height() ; 2262 int h = cp->sizeHint().height() ;
2275 int dw = QApplication::desktop()->width(); 2263 int dw = QApplication::desktop()->width();
2276 int dh = QApplication::desktop()->height(); 2264 int dh = QApplication::desktop()->height();
2277 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2265 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2278 if ( !cp->exec() ) { 2266 if ( !cp->exec() ) {
2279 delete cp; 2267 delete cp;
2280 return; 2268 return;
2281 } 2269 }
2282 int count = 0; 2270 int count = 0;
2283 if ( cp->addCat() ) { 2271 if ( cp->addCat() ) {
2284 count = addCategories(); 2272 count = addCategories();
2285 if ( count ) { 2273 if ( count ) {
2286 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2274 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2287 writeSettings(); 2275 writeSettings();
2288 } 2276 }
2289 } else { 2277 } else {
2290 removeCategories(); 2278 removeCategories();
2291 updateView(); 2279 updateView();
2292 } 2280 }
2293 delete cp; 2281 delete cp;
2294} 2282}
2295 2283
2296void CalendarView::beamIncidence(Incidence * Inc) 2284void CalendarView::beamIncidence(Incidence * Inc)
2297{ 2285{
2298 QPtrList<Incidence> delSel ; 2286 QPtrList<Incidence> delSel ;
2299 delSel.append(Inc); 2287 delSel.append(Inc);
2300 beamIncidenceList( delSel ); 2288 beamIncidenceList( delSel );
2301} 2289}
2302void CalendarView::beamCalendar() 2290void CalendarView::beamCalendar()
2303{ 2291{
2304 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2292 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2305 //qDebug("beamCalendar() "); 2293 //qDebug("beamCalendar() ");
2306 beamIncidenceList( delSel ); 2294 beamIncidenceList( delSel );
2307} 2295}
2308void CalendarView::beamFilteredCalendar() 2296void CalendarView::beamFilteredCalendar()
2309{ 2297{
2310 QPtrList<Incidence> delSel = mCalendar->incidences(); 2298 QPtrList<Incidence> delSel = mCalendar->incidences();
2311 //qDebug("beamFilteredCalendar() "); 2299 //qDebug("beamFilteredCalendar() ");
2312 beamIncidenceList( delSel ); 2300 beamIncidenceList( delSel );
2313} 2301}
2314void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2302void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2315{ 2303{
2316 if ( beamDialog->exec () == QDialog::Rejected ) 2304 if ( beamDialog->exec () == QDialog::Rejected )
2317 return; 2305 return;
2318 2306
2319 QString fn = "/tmp/kopibeamfile"; 2307 QString fn = "/tmp/kopibeamfile";
2320 QString mes; 2308 QString mes;
2321 bool createbup = true; 2309 bool createbup = true;
2322 if ( createbup ) { 2310 if ( createbup ) {
2323 QString description = "\n"; 2311 QString description = "\n";
2324 CalendarLocal* cal = new CalendarLocal(); 2312 CalendarLocal* cal = new CalendarLocal();
2325 if ( beamDialog->beamLocal() ) 2313 if ( beamDialog->beamLocal() )
2326 cal->setLocalTime(); 2314 cal->setLocalTime();
2327 else 2315 else
2328 cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 2316 cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
2329 Incidence *incidence = delSel.first(); 2317 Incidence *incidence = delSel.first();
2330 bool addText = false; 2318 bool addText = false;
2331 if ( delSel.count() < 10 ) 2319 if ( delSel.count() < 10 )
2332 addText = true; 2320 addText = true;
2333 else { 2321 else {
2334 description.sprintf(i18n(" %d items?"),delSel.count() ); 2322 description.sprintf(i18n(" %d items?"),delSel.count() );
2335 } 2323 }
2336 while ( incidence ) { 2324 while ( incidence ) {
2337 Incidence *in = incidence->clone(); 2325 Incidence *in = incidence->clone();
2338 if ( addText ) 2326 if ( addText )
2339 description += in->summary() + "\n"; 2327 description += in->summary() + "\n";
2340 cal->addIncidence( in ); 2328 cal->addIncidence( in );
2341 incidence = delSel.next(); 2329 incidence = delSel.next();
2342 } 2330 }
2343 if ( beamDialog->beamVcal() ) { 2331 if ( beamDialog->beamVcal() ) {
2344 fn += ".vcs"; 2332 fn += ".vcs";
2345 FileStorage storage( cal, fn, new VCalFormat ); 2333 FileStorage storage( cal, fn, new VCalFormat );
2346 storage.save(); 2334 storage.save();
2347 } else { 2335 } else {
2348 fn += ".ics"; 2336 fn += ".ics";
2349 FileStorage storage( cal, fn, new ICalFormat( ) ); 2337 FileStorage storage( cal, fn, new ICalFormat( ) );
2350 storage.save(); 2338 storage.save();
2351 } 2339 }
2352 delete cal; 2340 delete cal;
2353 mes = i18n("KO/Pi: Ready for beaming"); 2341 mes = i18n("KO/Pi: Ready for beaming");
2354 setCaption(mes); 2342 setCaption(mes);
2355 2343
2356#ifndef DESKTOP_VERSION 2344#ifndef DESKTOP_VERSION
2357 Ir *ir = new Ir( this ); 2345 Ir *ir = new Ir( this );
2358 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 2346 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2359 ir->send( fn, description, "text/x-vCalendar" ); 2347 ir->send( fn, description, "text/x-vCalendar" );
2360#endif 2348#endif
2361 } 2349 }
2362} 2350}
2363void CalendarView::beamDone( Ir *ir ) 2351void CalendarView::beamDone( Ir *ir )
2364{ 2352{
2365#ifndef DESKTOP_VERSION 2353#ifndef DESKTOP_VERSION
2366 delete ir; 2354 delete ir;
2367#endif 2355#endif
2368} 2356}
2369 2357
2370void CalendarView::moveIncidence(Incidence * inc ) 2358void CalendarView::moveIncidence(Incidence * inc )
2371{ 2359{
2372 if ( !inc ) return; 2360 if ( !inc ) return;
2373 // qDebug("showDatePickerForIncidence( ) "); 2361 // qDebug("showDatePickerForIncidence( ) ");
2374 if ( mDateFrame->isVisible() ) 2362 if ( mDateFrame->isVisible() )
2375 mDateFrame->hide(); 2363 mDateFrame->hide();
2376 else { 2364 else {
2377 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; 2365 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ;
2378 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; 2366 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ;
2379 int dw = QApplication::desktop()->width(); 2367 int dw = QApplication::desktop()->width();
2380 int dh = QApplication::desktop()->height(); 2368 int dh = QApplication::desktop()->height();
2381 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2369 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2382 mDateFrame->show(); 2370 mDateFrame->show();
2383 } 2371 }
2384 mDatePickerMode = 2; 2372 mDatePickerMode = 2;
2385 mMoveIncidence = inc ; 2373 mMoveIncidence = inc ;
2386 QDate da; 2374 QDate da;
2387 if ( mMoveIncidence->type() == "Todo" ) { 2375 if ( mMoveIncidence->type() == "Todo" ) {
2388 Todo * to = (Todo *) mMoveIncidence; 2376 Todo * to = (Todo *) mMoveIncidence;
2389 if ( to->hasDueDate() ) 2377 if ( to->hasDueDate() )
2390 da = to->dtDue().date(); 2378 da = to->dtDue().date();
2391 else 2379 else
2392 da = QDate::currentDate(); 2380 da = QDate::currentDate();
2393 } else { 2381 } else {
2394 da = mMoveIncidence->dtStart().date(); 2382 da = mMoveIncidence->dtStart().date();
2395 } 2383 }
2396 mDatePicker->setDate( da ); 2384 mDatePicker->setDate( da );
2397} 2385}
2398void CalendarView::showDatePicker( ) 2386void CalendarView::showDatePicker( )
2399{ 2387{
2400 //qDebug("CalendarView::showDatePicker( ) "); 2388 //qDebug("CalendarView::showDatePicker( ) ");
2401 if ( mDateFrame->isVisible() ) 2389 if ( mDateFrame->isVisible() )
2402 mDateFrame->hide(); 2390 mDateFrame->hide();
2403 else { 2391 else {
2404 int w =mDatePicker->sizeHint().width() ; 2392 int w =mDatePicker->sizeHint().width() ;
2405 int h = mDatePicker->sizeHint().height() ; 2393 int h = mDatePicker->sizeHint().height() ;
2406 int dw = QApplication::desktop()->width(); 2394 int dw = QApplication::desktop()->width();
2407 int dh = QApplication::desktop()->height(); 2395 int dh = QApplication::desktop()->height();
2408 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2396 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2409 mDateFrame->show(); 2397 mDateFrame->show();
2410 } 2398 }
2411 mDatePickerMode = 1; 2399 mDatePickerMode = 1;
2412 mDatePicker->setDate( mNavigator->selectedDates().first() ); 2400 mDatePicker->setDate( mNavigator->selectedDates().first() );
2413} 2401}
2414 2402
2415void CalendarView::showEventEditor() 2403void CalendarView::showEventEditor()
2416{ 2404{
2417#ifdef DESKTOP_VERSION 2405#ifdef DESKTOP_VERSION
2418 mEventEditor->show(); 2406 mEventEditor->show();
2419#else 2407#else
2420 mEventEditor->showMaximized(); 2408 mEventEditor->showMaximized();
2421#endif 2409#endif
2422} 2410}
2423void CalendarView::showTodoEditor() 2411void CalendarView::showTodoEditor()
2424{ 2412{
2425#ifdef DESKTOP_VERSION 2413#ifdef DESKTOP_VERSION
2426 mTodoEditor->show(); 2414 mTodoEditor->show();
2427#else 2415#else
2428 mTodoEditor->showMaximized(); 2416 mTodoEditor->showMaximized();
2429#endif 2417#endif
2430} 2418}
2431 2419
2432void CalendarView::cloneIncidence() 2420void CalendarView::cloneIncidence()
2433{ 2421{
2434 Incidence *incidence = currentSelection(); 2422 Incidence *incidence = currentSelection();
2435 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2423 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2436 if ( incidence ) { 2424 if ( incidence ) {
2437 cloneIncidence(incidence); 2425 cloneIncidence(incidence);
2438 } 2426 }
2439} 2427}
2440void CalendarView::moveIncidence() 2428void CalendarView::moveIncidence()
2441{ 2429{
2442 Incidence *incidence = currentSelection(); 2430 Incidence *incidence = currentSelection();
2443 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2431 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2444 if ( incidence ) { 2432 if ( incidence ) {
2445 moveIncidence(incidence); 2433 moveIncidence(incidence);
2446 } 2434 }
2447} 2435}
2448void CalendarView::beamIncidence() 2436void CalendarView::beamIncidence()
2449{ 2437{
2450 Incidence *incidence = currentSelection(); 2438 Incidence *incidence = currentSelection();
2451 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2439 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2452 if ( incidence ) { 2440 if ( incidence ) {
2453 beamIncidence(incidence); 2441 beamIncidence(incidence);
2454 } 2442 }
2455} 2443}
2456void CalendarView::toggleCancelIncidence() 2444void CalendarView::toggleCancelIncidence()
2457{ 2445{
2458 Incidence *incidence = currentSelection(); 2446 Incidence *incidence = currentSelection();
2459 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2447 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2460 if ( incidence ) { 2448 if ( incidence ) {
2461 cancelIncidence(incidence); 2449 cancelIncidence(incidence);
2462 } 2450 }
2463} 2451}
2464 2452
2465 2453
2466void CalendarView::cancelIncidence(Incidence * inc ) 2454void CalendarView::cancelIncidence(Incidence * inc )
2467{ 2455{
2468 inc->setCancelled( ! inc->cancelled() ); 2456 inc->setCancelled( ! inc->cancelled() );
2469 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 2457 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
2470 updateView(); 2458 updateView();
2471} 2459}
2472void CalendarView::cloneIncidence(Incidence * orgInc ) 2460void CalendarView::cloneIncidence(Incidence * orgInc )
2473{ 2461{
2474 Incidence * newInc = orgInc->clone(); 2462 Incidence * newInc = orgInc->clone();
2475 newInc->recreate(); 2463 newInc->recreate();
2476 2464
2477 if ( newInc->type() == "Todo" ) { 2465 if ( newInc->type() == "Todo" ) {
2478 Todo* t = (Todo*) newInc; 2466 Todo* t = (Todo*) newInc;
2479 mTodoEditor->editTodo( t ); 2467 mTodoEditor->editTodo( t );
2480 showTodoEditor(); 2468 showTodoEditor();
2481 if ( mTodoEditor->exec() ) { 2469 if ( mTodoEditor->exec() ) {
2482 mCalendar->addTodo( t ); 2470 mCalendar->addTodo( t );
2483 updateView(); 2471 updateView();
2484 } else { 2472 } else {
2485 delete t; 2473 delete t;
2486 } 2474 }
2487 } 2475 }
2488 else { 2476 else {
2489 Event* e = (Event*) newInc; 2477 Event* e = (Event*) newInc;
2490 mEventEditor->editEvent( e ); 2478 mEventEditor->editEvent( e );
2491 showEventEditor(); 2479 showEventEditor();
2492 if ( mEventEditor->exec() ) { 2480 if ( mEventEditor->exec() ) {
2493 mCalendar->addEvent( e ); 2481 mCalendar->addEvent( e );
2494 updateView(); 2482 updateView();
2495 } else { 2483 } else {
2496 delete e; 2484 delete e;
2497 } 2485 }
2498 } 2486 }
2499} 2487}
2500 2488
2501void CalendarView::newEvent() 2489void CalendarView::newEvent()
2502{ 2490{
2503 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 2491 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
2504 KOAgendaView *aView = mViewManager->agendaView(); 2492 KOAgendaView *aView = mViewManager->agendaView();
2505 if (aView) { 2493 if (aView) {
2506 if (aView->selectionStart().isValid()) { 2494 if (aView->selectionStart().isValid()) {
2507 if (aView->selectedIsAllDay()) { 2495 if (aView->selectedIsAllDay()) {
2508 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 2496 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
2509 } else { 2497 } else {
2510 newEvent(aView->selectionStart(),aView->selectionEnd()); 2498 newEvent(aView->selectionStart(),aView->selectionEnd());
2511 } 2499 }
2512 return; 2500 return;
2513 } 2501 }
2514 } 2502 }
2515 2503
2516 QDate date = mNavigator->selectedDates().first(); 2504 QDate date = mNavigator->selectedDates().first();
2517 QDateTime current = QDateTime::currentDateTime(); 2505 QDateTime current = QDateTime::currentDateTime();
2518 if ( date <= current.date() ) { 2506 if ( date <= current.date() ) {
2519 int hour = current.time().hour() +1; 2507 int hour = current.time().hour() +1;
2520 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 2508 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
2521 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2509 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2522 } else 2510 } else
2523 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 2511 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
2524 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 2512 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
2525 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2513 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2526} 2514}
2527 2515
2528void CalendarView::newEvent(QDateTime fh) 2516void CalendarView::newEvent(QDateTime fh)
2529{ 2517{
2530 newEvent(fh, 2518 newEvent(fh,
2531 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 2519 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
2532} 2520}
2533 2521
2534void CalendarView::newEvent(QDate dt) 2522void CalendarView::newEvent(QDate dt)
2535{ 2523{
2536 newEvent(QDateTime(dt, QTime(0,0,0)), 2524 newEvent(QDateTime(dt, QTime(0,0,0)),
2537 QDateTime(dt, QTime(0,0,0)), true); 2525 QDateTime(dt, QTime(0,0,0)), true);
2538} 2526}
2539 2527
2540void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 2528void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
2541{ 2529{
2542 2530
2543 mEventEditor->newEvent(fromHint,toHint,allDay); 2531 mEventEditor->newEvent(fromHint,toHint,allDay);
2544 if ( mFilterView->filtersEnabled() ) { 2532 if ( mFilterView->filtersEnabled() ) {
2545 CalFilter *filter = mFilterView->selectedFilter(); 2533 CalFilter *filter = mFilterView->selectedFilter();
2546 if (filter && filter->showCategories()) { 2534 if (filter && filter->showCategories()) {
2547 mEventEditor->setCategories(filter->categoryList().join(",") ); 2535 mEventEditor->setCategories(filter->categoryList().join(",") );
2548 } 2536 }
2549 if ( filter ) 2537 if ( filter )
2550 mEventEditor->setSecrecy( filter->getSecrecy() ); 2538 mEventEditor->setSecrecy( filter->getSecrecy() );
2551 } 2539 }
2552 showEventEditor(); 2540 showEventEditor();
2553} 2541}
2554void CalendarView::todoAdded(Todo * t) 2542void CalendarView::todoAdded(Todo * t)
2555{ 2543{
2556 2544
2557 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 2545 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
2558 updateTodoViews(); 2546 updateTodoViews();
2559} 2547}
2560void CalendarView::todoChanged(Todo * t) 2548void CalendarView::todoChanged(Todo * t)
2561{ 2549{
2562 emit todoModified( t, 4 ); 2550 emit todoModified( t, 4 );
2563 // updateTodoViews(); 2551 // updateTodoViews();
2564} 2552}
2565void CalendarView::todoToBeDeleted(Todo *) 2553void CalendarView::todoToBeDeleted(Todo *)
2566{ 2554{
2567 //qDebug("todoToBeDeleted(Todo *) "); 2555 //qDebug("todoToBeDeleted(Todo *) ");
2568 updateTodoViews(); 2556 updateTodoViews();
2569} 2557}
2570void CalendarView::todoDeleted() 2558void CalendarView::todoDeleted()
2571{ 2559{
2572 //qDebug(" todoDeleted()"); 2560 //qDebug(" todoDeleted()");
2573 updateTodoViews(); 2561 updateTodoViews();
2574} 2562}
2575 2563
2576 2564
2577 2565
2578void CalendarView::newTodo() 2566void CalendarView::newTodo()
2579{ 2567{
2580 2568
2581 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); 2569 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true);
2582 if ( mFilterView->filtersEnabled() ) { 2570 if ( mFilterView->filtersEnabled() ) {
2583 CalFilter *filter = mFilterView->selectedFilter(); 2571 CalFilter *filter = mFilterView->selectedFilter();
2584 if (filter && filter->showCategories()) { 2572 if (filter && filter->showCategories()) {
2585 mTodoEditor->setCategories(filter->categoryList().join(",") ); 2573 mTodoEditor->setCategories(filter->categoryList().join(",") );
2586 } 2574 }
2587 if ( filter ) 2575 if ( filter )
2588 mTodoEditor->setSecrecy( filter->getSecrecy() ); 2576 mTodoEditor->setSecrecy( filter->getSecrecy() );
2589 } 2577 }
2590 showTodoEditor(); 2578 showTodoEditor();
2591} 2579}
2592 2580
2593void CalendarView::newSubTodo() 2581void CalendarView::newSubTodo()
2594{ 2582{
2595 Todo *todo = selectedTodo(); 2583 Todo *todo = selectedTodo();
2596 if ( todo ) newSubTodo( todo ); 2584 if ( todo ) newSubTodo( todo );
2597} 2585}
2598 2586
2599void CalendarView::newSubTodo(Todo *parentEvent) 2587void CalendarView::newSubTodo(Todo *parentEvent)
2600{ 2588{
2601 2589
2602 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); 2590 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true);
2603 showTodoEditor(); 2591 showTodoEditor();
2604} 2592}
2605 2593
2606void CalendarView::newFloatingEvent() 2594void CalendarView::newFloatingEvent()
2607{ 2595{
2608 DateList tmpList = mNavigator->selectedDates(); 2596 DateList tmpList = mNavigator->selectedDates();
2609 QDate date = tmpList.first(); 2597 QDate date = tmpList.first();
2610 2598
2611 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 2599 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
2612 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 2600 QDateTime( date, QTime( 12, 0, 0 ) ), true );
2613} 2601}
2614 2602
2615 2603
2616void CalendarView::editEvent( Event *event ) 2604void CalendarView::editEvent( Event *event )
2617{ 2605{
2618 2606
2619 if ( !event ) return; 2607 if ( !event ) return;
2620 if ( event->isReadOnly() ) { 2608 if ( event->isReadOnly() ) {
2621 showEvent( event ); 2609 showEvent( event );
2622 return; 2610 return;
2623 } 2611 }
2624 mEventEditor->editEvent( event , mFlagEditDescription); 2612 mEventEditor->editEvent( event , mFlagEditDescription);
2625 showEventEditor(); 2613 showEventEditor();
2626} 2614}
2627void CalendarView::editJournal( Journal *jour ) 2615void CalendarView::editJournal( Journal *jour )
2628{ 2616{
2629 if ( !jour ) return; 2617 if ( !jour ) return;
2630 mDialogManager->hideSearchDialog(); 2618 mDialogManager->hideSearchDialog();
2631 mViewManager->showJournalView(); 2619 mViewManager->showJournalView();
2632 mNavigator->slotDaySelect( jour->dtStart().date() ); 2620 mNavigator->slotDaySelect( jour->dtStart().date() );
2633} 2621}
2634void CalendarView::editTodo( Todo *todo ) 2622void CalendarView::editTodo( Todo *todo )
2635{ 2623{
2636 if ( !todo ) return; 2624 if ( !todo ) return;
2637 2625
2638 if ( todo->isReadOnly() ) { 2626 if ( todo->isReadOnly() ) {
2639 showTodo( todo ); 2627 showTodo( todo );
2640 return; 2628 return;
2641 } 2629 }
2642 mTodoEditor->editTodo( todo ,mFlagEditDescription); 2630 mTodoEditor->editTodo( todo ,mFlagEditDescription);
2643 showTodoEditor(); 2631 showTodoEditor();
2644 2632
2645} 2633}
2646 2634
2647KOEventViewerDialog* CalendarView::getEventViewerDialog() 2635KOEventViewerDialog* CalendarView::getEventViewerDialog()
2648{ 2636{
2649 if ( !mEventViewerDialog ) { 2637 if ( !mEventViewerDialog ) {
2650 mEventViewerDialog = new KOEventViewerDialog(this); 2638 mEventViewerDialog = new KOEventViewerDialog(this);
2651 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 2639 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
2652 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 2640 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
2653 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 2641 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
2654 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 2642 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
2655 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 2643 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
2656 viewManager(), SLOT( showAgendaView( bool ) ) ); 2644 viewManager(), SLOT( showAgendaView( bool ) ) );
2657 mEventViewerDialog->resize( 640, 480 ); 2645 mEventViewerDialog->resize( 640, 480 );
2658 2646
2659 } 2647 }
2660 return mEventViewerDialog; 2648 return mEventViewerDialog;
2661} 2649}
2662void CalendarView::showEvent(Event *event) 2650void CalendarView::showEvent(Event *event)
2663{ 2651{
2664 getEventViewerDialog()->setEvent(event); 2652 getEventViewerDialog()->setEvent(event);
2665 getEventViewerDialog()->showMe(); 2653 getEventViewerDialog()->showMe();
2666} 2654}
2667 2655
2668void CalendarView::showTodo(Todo *event) 2656void CalendarView::showTodo(Todo *event)
2669{ 2657{
2670 getEventViewerDialog()->setTodo(event); 2658 getEventViewerDialog()->setTodo(event);
2671 getEventViewerDialog()->showMe(); 2659 getEventViewerDialog()->showMe();
2672} 2660}
2673void CalendarView::showJournal( Journal *jour ) 2661void CalendarView::showJournal( Journal *jour )
2674{ 2662{
2675 getEventViewerDialog()->setJournal(jour); 2663 getEventViewerDialog()->setJournal(jour);
2676 getEventViewerDialog()->showMe(); 2664 getEventViewerDialog()->showMe();
2677 2665
2678} 2666}
2679// void CalendarView::todoModified (Todo *event, int changed) 2667// void CalendarView::todoModified (Todo *event, int changed)
2680// { 2668// {
2681// // if (mDialogList.find (event) != mDialogList.end ()) { 2669// // if (mDialogList.find (event) != mDialogList.end ()) {
2682// // kdDebug() << "Todo modified and open" << endl; 2670// // kdDebug() << "Todo modified and open" << endl;
2683// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 2671// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
2684// // temp->modified (changed); 2672// // temp->modified (changed);
2685 2673
2686// // } 2674// // }
2687 2675
2688// mViewManager->updateView(); 2676// mViewManager->updateView();
2689// } 2677// }
2690 2678
2691void CalendarView::appointment_show() 2679void CalendarView::appointment_show()
2692{ 2680{
2693 Event *anEvent = 0; 2681 Event *anEvent = 0;
2694 2682
2695 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2683 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2696 2684
2697 if (mViewManager->currentView()->isEventView()) { 2685 if (mViewManager->currentView()->isEventView()) {
2698 if ( incidence && incidence->type() == "Event" ) { 2686 if ( incidence && incidence->type() == "Event" ) {
2699 anEvent = static_cast<Event *>(incidence); 2687 anEvent = static_cast<Event *>(incidence);
2700 } 2688 }
2701 } 2689 }
2702 2690
2703 if (!anEvent) { 2691 if (!anEvent) {
2704 KNotifyClient::beep(); 2692 KNotifyClient::beep();
2705 return; 2693 return;
2706 } 2694 }
2707 2695
2708 showEvent(anEvent); 2696 showEvent(anEvent);
2709} 2697}
2710 2698
2711void CalendarView::appointment_edit() 2699void CalendarView::appointment_edit()
2712{ 2700{
2713 Event *anEvent = 0; 2701 Event *anEvent = 0;
2714 2702
2715 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2703 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2716 2704
2717 if (mViewManager->currentView()->isEventView()) { 2705 if (mViewManager->currentView()->isEventView()) {
2718 if ( incidence && incidence->type() == "Event" ) { 2706 if ( incidence && incidence->type() == "Event" ) {
2719 anEvent = static_cast<Event *>(incidence); 2707 anEvent = static_cast<Event *>(incidence);
2720 } 2708 }
2721 } 2709 }
2722 2710
2723 if (!anEvent) { 2711 if (!anEvent) {
2724 KNotifyClient::beep(); 2712 KNotifyClient::beep();
2725 return; 2713 return;
2726 } 2714 }
2727 2715
2728 editEvent(anEvent); 2716 editEvent(anEvent);
2729} 2717}
2730 2718
2731void CalendarView::appointment_delete() 2719void CalendarView::appointment_delete()
2732{ 2720{
2733 Event *anEvent = 0; 2721 Event *anEvent = 0;
2734 2722
2735 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2723 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2736 2724
2737 if (mViewManager->currentView()->isEventView()) { 2725 if (mViewManager->currentView()->isEventView()) {
2738 if ( incidence && incidence->type() == "Event" ) { 2726 if ( incidence && incidence->type() == "Event" ) {
2739 anEvent = static_cast<Event *>(incidence); 2727 anEvent = static_cast<Event *>(incidence);
2740 } 2728 }
2741 } 2729 }
2742 2730
2743 if (!anEvent) { 2731 if (!anEvent) {
2744 KNotifyClient::beep(); 2732 KNotifyClient::beep();
2745 return; 2733 return;
2746 } 2734 }
2747 2735
2748 deleteEvent(anEvent); 2736 deleteEvent(anEvent);
2749} 2737}
2750 2738
2751void CalendarView::todo_unsub(Todo *anTodo ) 2739void CalendarView::todo_unsub(Todo *anTodo )
2752{ 2740{
2753 // Todo *anTodo = selectedTodo(); 2741 // Todo *anTodo = selectedTodo();
2754 if (!anTodo) return; 2742 if (!anTodo) return;
2755 if (!anTodo->relatedTo()) return; 2743 if (!anTodo->relatedTo()) return;
2756 anTodo->relatedTo()->removeRelation(anTodo); 2744 anTodo->relatedTo()->removeRelation(anTodo);
2757 anTodo->setRelatedTo(0); 2745 anTodo->setRelatedTo(0);
2758 anTodo->updated(); 2746 anTodo->updated();
2759 anTodo->setRelatedToUid(""); 2747 anTodo->setRelatedToUid("");
2760 setModified(true); 2748 setModified(true);
2761 updateView(); 2749 updateView();
2762} 2750}
2763 2751
2764void CalendarView::deleteTodo(Todo *todo) 2752void CalendarView::deleteTodo(Todo *todo)
2765{ 2753{
2766 if (!todo) { 2754 if (!todo) {
2767 KNotifyClient::beep(); 2755 KNotifyClient::beep();
2768 return; 2756 return;
2769 } 2757 }
2770 if (KOPrefs::instance()->mConfirm) { 2758 if (KOPrefs::instance()->mConfirm) {
2771 switch (msgItemDelete()) { 2759 switch (msgItemDelete()) {
2772 case KMessageBox::Continue: // OK 2760 case KMessageBox::Continue: // OK
2773 if (!todo->relations().isEmpty()) { 2761 if (!todo->relations().isEmpty()) {
2774 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), 2762 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."),
2775 i18n("Delete To-Do")); 2763 i18n("Delete To-Do"));
2776 } else { 2764 } else {
2777 checkExternalId( todo ); 2765 checkExternalId( todo );
2778 calendar()->deleteTodo(todo); 2766 calendar()->deleteTodo(todo);
2779 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2767 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2780 updateView(); 2768 updateView();
2781 } 2769 }
2782 break; 2770 break;
2783 } // switch 2771 } // switch
2784 } else { 2772 } else {
2785 if (!todo->relations().isEmpty()) { 2773 if (!todo->relations().isEmpty()) {
2786 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), 2774 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."),
2787 i18n("Delete To-Do")); 2775 i18n("Delete To-Do"));
2788 } else { 2776 } else {
2789 checkExternalId( todo ); 2777 checkExternalId( todo );
2790 mCalendar->deleteTodo(todo); 2778 mCalendar->deleteTodo(todo);
2791 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2779 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2792 updateView(); 2780 updateView();
2793 } 2781 }
2794 } 2782 }
2795 emit updateSearchDialog(); 2783 emit updateSearchDialog();
2796} 2784}
2797void CalendarView::deleteJournal(Journal *jour) 2785void CalendarView::deleteJournal(Journal *jour)
2798{ 2786{
2799 if (!jour) { 2787 if (!jour) {
2800 KNotifyClient::beep(); 2788 KNotifyClient::beep();
2801 return; 2789 return;
2802 } 2790 }
2803 if (KOPrefs::instance()->mConfirm) { 2791 if (KOPrefs::instance()->mConfirm) {
2804 switch (msgItemDelete()) { 2792 switch (msgItemDelete()) {
2805 case KMessageBox::Continue: // OK 2793 case KMessageBox::Continue: // OK
2806 calendar()->deleteJournal(jour); 2794 calendar()->deleteJournal(jour);
2807 updateView(); 2795 updateView();
2808 break; 2796 break;
2809 } // switch 2797 } // switch
2810 } else { 2798 } else {
2811 calendar()->deleteJournal(jour);; 2799 calendar()->deleteJournal(jour);;
2812 updateView(); 2800 updateView();
2813 } 2801 }
2814 emit updateSearchDialog(); 2802 emit updateSearchDialog();
2815} 2803}
2816 2804
2817void CalendarView::deleteEvent(Event *anEvent) 2805void CalendarView::deleteEvent(Event *anEvent)
2818{ 2806{
2819 if (!anEvent) { 2807 if (!anEvent) {
2820 KNotifyClient::beep(); 2808 KNotifyClient::beep();
2821 return; 2809 return;
2822 } 2810 }
2823 2811
2824 if (anEvent->recurrence()->doesRecur()) { 2812 if (anEvent->recurrence()->doesRecur()) {
2825 QDate itemDate = mViewManager->currentSelectionDate(); 2813 QDate itemDate = mViewManager->currentSelectionDate();
2826 int km; 2814 int km;
2827 if (!itemDate.isValid()) { 2815 if (!itemDate.isValid()) {
2828 //kdDebug() << "Date Not Valid" << endl; 2816 //kdDebug() << "Date Not Valid" << endl;
2829 if (KOPrefs::instance()->mConfirm) { 2817 if (KOPrefs::instance()->mConfirm) {
2830 km = KMessageBox::warningContinueCancel(this,anEvent->summary() + 2818 km = KMessageBox::warningContinueCancel(this,anEvent->summary() +
2831 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), 2819 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"),
2832 i18n("KO/Pi Confirmation"),i18n("Delete All")); 2820 i18n("KO/Pi Confirmation"),i18n("Delete All"));
2833 if ( km == KMessageBox::Continue ) 2821 if ( km == KMessageBox::Continue )
2834 km = KMessageBox::No; // No = all below 2822 km = KMessageBox::No; // No = all below
2835 } else 2823 } else
2836 km = KMessageBox::No; 2824 km = KMessageBox::No;
2837 } else { 2825 } else {
2838 km = KMessageBox::warningYesNoCancel(this,anEvent->summary() + 2826 km = KMessageBox::warningYesNoCancel(this,anEvent->summary() +
2839 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ 2827 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+
2840 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), 2828 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"),
2841 i18n("KO/Pi Confirmation"),i18n("Current"), 2829 i18n("KO/Pi Confirmation"),i18n("Current"),
2842 i18n("All")); 2830 i18n("All"));
2843 } 2831 }
2844 switch(km) { 2832 switch(km) {
2845 2833
2846 case KMessageBox::No: // Continue // all 2834 case KMessageBox::No: // Continue // all
2847 //qDebug("KMessageBox::No "); 2835 //qDebug("KMessageBox::No ");
2848 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2836 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2849 schedule(Scheduler::Cancel,anEvent); 2837 schedule(Scheduler::Cancel,anEvent);
2850 2838
2851 checkExternalId( anEvent); 2839 checkExternalId( anEvent);
2852 mCalendar->deleteEvent(anEvent); 2840 mCalendar->deleteEvent(anEvent);
2853 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); 2841 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED);
2854 break; 2842 break;
2855 2843
2856 // Disabled because it does not work 2844 // Disabled because it does not work
2857 //#if 0 2845 //#if 0
2858 case KMessageBox::Yes: // just this one 2846 case KMessageBox::Yes: // just this one
2859 //QDate qd = mNavigator->selectedDates().first(); 2847 //QDate qd = mNavigator->selectedDates().first();
2860 //if (!qd.isValid()) { 2848 //if (!qd.isValid()) {
2861 // kdDebug() << "no date selected, or invalid date" << endl; 2849 // kdDebug() << "no date selected, or invalid date" << endl;
2862 // KNotifyClient::beep(); 2850 // KNotifyClient::beep();
2863 // return; 2851 // return;
2864 //} 2852 //}
2865 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); 2853 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1);
2866 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { 2854 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) {
2867 anEvent->addExDate(itemDate); 2855 anEvent->addExDate(itemDate);
2868 int duration = anEvent->recurrence()->duration(); 2856 int duration = anEvent->recurrence()->duration();
2869 if ( duration > 0 ) { 2857 if ( duration > 0 ) {
2870 anEvent->recurrence()->setDuration( duration - 1 ); 2858 anEvent->recurrence()->setDuration( duration - 1 );
2871 } 2859 }
2872 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); 2860 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED);
2873 } 2861 }
2874 break; 2862 break;
2875 //#endif 2863 //#endif
2876 } // switch 2864 } // switch
2877 } else { 2865 } else {
2878 if (KOPrefs::instance()->mConfirm) { 2866 if (KOPrefs::instance()->mConfirm) {
2879 switch (KMessageBox::warningContinueCancel(this,anEvent->summary() + 2867 switch (KMessageBox::warningContinueCancel(this,anEvent->summary() +
2880 i18n("\nAre you sure you want\nto delete this event?"), 2868 i18n("\nAre you sure you want\nto delete this event?"),
2881 i18n("KO/Pi Confirmation"),i18n("Delete"))) { 2869 i18n("KO/Pi Confirmation"),i18n("Delete"))) {
2882 case KMessageBox::Continue: // OK 2870 case KMessageBox::Continue: // OK
2883 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2871 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2884 schedule(Scheduler::Cancel,anEvent); 2872 schedule(Scheduler::Cancel,anEvent);
2885 checkExternalId( anEvent); 2873 checkExternalId( anEvent);
2886 mCalendar->deleteEvent(anEvent); 2874 mCalendar->deleteEvent(anEvent);
2887 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2875 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2888 break; 2876 break;
2889 } // switch 2877 } // switch
2890 } else { 2878 } else {
2891 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2879 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2892 schedule(Scheduler::Cancel,anEvent); 2880 schedule(Scheduler::Cancel,anEvent);
2893 checkExternalId( anEvent); 2881 checkExternalId( anEvent);
2894 mCalendar->deleteEvent(anEvent); 2882 mCalendar->deleteEvent(anEvent);
2895 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2883 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2896 } 2884 }
2897 } // if-else 2885 } // if-else
2898 emit updateSearchDialog(); 2886 emit updateSearchDialog();
2899} 2887}
2900 2888
2901bool CalendarView::deleteEvent(const QString &uid) 2889bool CalendarView::deleteEvent(const QString &uid)
2902{ 2890{
2903 Event *ev = mCalendar->event(uid); 2891 Event *ev = mCalendar->event(uid);
2904 if (ev) { 2892 if (ev) {
2905 deleteEvent(ev); 2893 deleteEvent(ev);
2906 return true; 2894 return true;
2907 } else { 2895 } else {
2908 return false; 2896 return false;
2909 } 2897 }
2910} 2898}
2911 2899
2912/*****************************************************************************/ 2900/*****************************************************************************/
2913 2901
2914void CalendarView::action_mail() 2902void CalendarView::action_mail()
2915{ 2903{
2916#ifndef KORG_NOMAIL 2904#ifndef KORG_NOMAIL
2917 KOMailClient mailClient; 2905 KOMailClient mailClient;
2918 2906
2919 Incidence *incidence = currentSelection(); 2907 Incidence *incidence = currentSelection();
2920 2908
2921 if (!incidence) { 2909 if (!incidence) {
2922 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 2910 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
2923 return; 2911 return;
2924 } 2912 }
2925 if(incidence->attendeeCount() == 0 ) { 2913 if(incidence->attendeeCount() == 0 ) {
2926 KMessageBox::sorry(this, 2914 KMessageBox::sorry(this,
2927 i18n("Can't generate mail:\nNo attendees defined.\n")); 2915 i18n("Can't generate mail:\nNo attendees defined.\n"));
2928 return; 2916 return;
2929 } 2917 }
2930 2918
2931 CalendarLocal cal_tmp; 2919 CalendarLocal cal_tmp;
2932 Event *event = 0; 2920 Event *event = 0;
2933 Event *ev = 0; 2921 Event *ev = 0;
2934 if ( incidence && incidence->type() == "Event" ) { 2922 if ( incidence && incidence->type() == "Event" ) {
2935 event = static_cast<Event *>(incidence); 2923 event = static_cast<Event *>(incidence);
2936 ev = new Event(*event); 2924 ev = new Event(*event);
2937 cal_tmp.addEvent(ev); 2925 cal_tmp.addEvent(ev);
2938 } 2926 }
2939 ICalFormat mForm(); 2927 ICalFormat mForm();
2940 QString attachment = mForm.toString( &cal_tmp ); 2928 QString attachment = mForm.toString( &cal_tmp );
2941 if (ev) delete(ev); 2929 if (ev) delete(ev);
2942 2930
2943 mailClient.mailAttendees(currentSelection(), attachment); 2931 mailClient.mailAttendees(currentSelection(), attachment);
2944 2932
2945#endif 2933#endif
2946 2934
2947#if 0 2935#if 0
2948 Event *anEvent = 0; 2936 Event *anEvent = 0;
2949 if (mViewManager->currentView()->isEventView()) { 2937 if (mViewManager->currentView()->isEventView()) {
2950 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); 2938 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first());
2951 } 2939 }
2952 2940
2953 if (!anEvent) { 2941 if (!anEvent) {
2954 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 2942 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
2955 return; 2943 return;
2956 } 2944 }
2957 if(anEvent->attendeeCount() == 0 ) { 2945 if(anEvent->attendeeCount() == 0 ) {
2958 KMessageBox::sorry(this, 2946 KMessageBox::sorry(this,
2959 i18n("Can't generate mail:\nNo attendees defined.\n")); 2947 i18n("Can't generate mail:\nNo attendees defined.\n"));
2960 return; 2948 return;
2961 } 2949 }
2962 2950
2963 mailobject.emailEvent(anEvent); 2951 mailobject.emailEvent(anEvent);
2964#endif 2952#endif
2965} 2953}
2966 2954
2967 2955
2968void CalendarView::schedule_publish(Incidence *incidence) 2956void CalendarView::schedule_publish(Incidence *incidence)
2969{ 2957{
2970 Event *event = 0; 2958 Event *event = 0;
2971 Todo *todo = 0; 2959 Todo *todo = 0;
2972 2960
2973 if (incidence == 0) { 2961 if (incidence == 0) {
2974 incidence = mViewManager->currentView()->selectedIncidences().first(); 2962 incidence = mViewManager->currentView()->selectedIncidences().first();
2975 if (incidence == 0) { 2963 if (incidence == 0) {
2976 incidence = mTodoList->selectedIncidences().first(); 2964 incidence = mTodoList->selectedIncidences().first();
2977 } 2965 }
2978 } 2966 }
2979 if ( incidence && incidence->type() == "Event" ) { 2967 if ( incidence && incidence->type() == "Event" ) {
2980 event = static_cast<Event *>(incidence); 2968 event = static_cast<Event *>(incidence);
2981 } else { 2969 } else {
2982 if ( incidence && incidence->type() == "Todo" ) { 2970 if ( incidence && incidence->type() == "Todo" ) {
2983 todo = static_cast<Todo *>(incidence); 2971 todo = static_cast<Todo *>(incidence);
2984 } 2972 }
2985 } 2973 }
2986 2974
2987 if (!event && !todo) { 2975 if (!event && !todo) {
2988 KMessageBox::sorry(this,i18n("No event selected.")); 2976 KMessageBox::sorry(this,i18n("No event selected."));
2989 return; 2977 return;
2990 } 2978 }
2991 2979
2992 PublishDialog *publishdlg = new PublishDialog(); 2980 PublishDialog *publishdlg = new PublishDialog();
2993 if (incidence->attendeeCount()>0) { 2981 if (incidence->attendeeCount()>0) {
2994 QPtrList<Attendee> attendees = incidence->attendees(); 2982 QPtrList<Attendee> attendees = incidence->attendees();
2995 attendees.first(); 2983 attendees.first();
2996 while ( attendees.current()!=0 ) { 2984 while ( attendees.current()!=0 ) {
2997 publishdlg->addAttendee(attendees.current()); 2985 publishdlg->addAttendee(attendees.current());
2998 attendees.next(); 2986 attendees.next();
2999 } 2987 }
3000 } 2988 }
3001 bool send = true; 2989 bool send = true;
3002 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { 2990 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) {
3003 if ( publishdlg->exec() != QDialog::Accepted ) 2991 if ( publishdlg->exec() != QDialog::Accepted )
3004 send = false; 2992 send = false;
3005 } 2993 }
3006 if ( send ) { 2994 if ( send ) {
3007 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 2995 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3008 if ( event ) { 2996 if ( event ) {
3009 Event *ev = new Event(*event); 2997 Event *ev = new Event(*event);
3010 ev->registerObserver(0); 2998 ev->registerObserver(0);
3011 ev->clearAttendees(); 2999 ev->clearAttendees();
3012 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3000 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3013 delete(ev); 3001 delete(ev);
3014 } 3002 }
3015 } else { 3003 } else {
3016 if ( todo ) { 3004 if ( todo ) {
3017 Todo *ev = new Todo(*todo); 3005 Todo *ev = new Todo(*todo);
3018 ev->registerObserver(0); 3006 ev->registerObserver(0);
3019 ev->clearAttendees(); 3007 ev->clearAttendees();
3020 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3008 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3021 delete(ev); 3009 delete(ev);
3022 } 3010 }
3023 } 3011 }
3024 } 3012 }
3025 } 3013 }
3026 delete publishdlg; 3014 delete publishdlg;
3027} 3015}
3028 3016
3029void CalendarView::schedule_request(Incidence *incidence) 3017void CalendarView::schedule_request(Incidence *incidence)
3030{ 3018{
3031 schedule(Scheduler::Request,incidence); 3019 schedule(Scheduler::Request,incidence);
3032} 3020}
3033 3021
3034void CalendarView::schedule_refresh(Incidence *incidence) 3022void CalendarView::schedule_refresh(Incidence *incidence)
3035{ 3023{
3036 schedule(Scheduler::Refresh,incidence); 3024 schedule(Scheduler::Refresh,incidence);
3037} 3025}
3038 3026
3039void CalendarView::schedule_cancel(Incidence *incidence) 3027void CalendarView::schedule_cancel(Incidence *incidence)
3040{ 3028{
3041 schedule(Scheduler::Cancel,incidence); 3029 schedule(Scheduler::Cancel,incidence);
3042} 3030}
3043 3031
3044void CalendarView::schedule_add(Incidence *incidence) 3032void CalendarView::schedule_add(Incidence *incidence)
3045{ 3033{
3046 schedule(Scheduler::Add,incidence); 3034 schedule(Scheduler::Add,incidence);
3047} 3035}
3048 3036
3049void CalendarView::schedule_reply(Incidence *incidence) 3037void CalendarView::schedule_reply(Incidence *incidence)
3050{ 3038{
3051 schedule(Scheduler::Reply,incidence); 3039 schedule(Scheduler::Reply,incidence);
3052} 3040}
3053 3041
3054void CalendarView::schedule_counter(Incidence *incidence) 3042void CalendarView::schedule_counter(Incidence *incidence)
3055{ 3043{
3056 schedule(Scheduler::Counter,incidence); 3044 schedule(Scheduler::Counter,incidence);
3057} 3045}
3058 3046
3059void CalendarView::schedule_declinecounter(Incidence *incidence) 3047void CalendarView::schedule_declinecounter(Incidence *incidence)
3060{ 3048{
3061 schedule(Scheduler::Declinecounter,incidence); 3049 schedule(Scheduler::Declinecounter,incidence);
3062} 3050}
3063 3051
3064void CalendarView::schedule_publish_freebusy(int daysToPublish) 3052void CalendarView::schedule_publish_freebusy(int daysToPublish)
3065{ 3053{
3066 QDateTime start = QDateTime::currentDateTime(); 3054 QDateTime start = QDateTime::currentDateTime();
3067 QDateTime end = start.addDays(daysToPublish); 3055 QDateTime end = start.addDays(daysToPublish);
3068 3056
3069 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); 3057 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end);
3070 freebusy->setOrganizer(KOPrefs::instance()->email()); 3058 freebusy->setOrganizer(KOPrefs::instance()->email());
3071 3059
3072 3060
3073 PublishDialog *publishdlg = new PublishDialog(); 3061 PublishDialog *publishdlg = new PublishDialog();
3074 if ( publishdlg->exec() == QDialog::Accepted ) { 3062 if ( publishdlg->exec() == QDialog::Accepted ) {
3075 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3063 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3076 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { 3064 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) {
3077 delete(freebusy); 3065 delete(freebusy);
3078 } 3066 }
3079 } 3067 }
3080 delete publishdlg; 3068 delete publishdlg;
3081} 3069}
3082 3070
3083void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) 3071void CalendarView::schedule(Scheduler::Method method, Incidence *incidence)
3084{ 3072{
3085 Event *event = 0; 3073 Event *event = 0;
3086 Todo *todo = 0; 3074 Todo *todo = 0;
3087 3075
3088 if (incidence == 0) { 3076 if (incidence == 0) {
3089 incidence = mViewManager->currentView()->selectedIncidences().first(); 3077 incidence = mViewManager->currentView()->selectedIncidences().first();
3090 if (incidence == 0) { 3078 if (incidence == 0) {
3091 incidence = mTodoList->selectedIncidences().first(); 3079 incidence = mTodoList->selectedIncidences().first();
3092 } 3080 }
3093 } 3081 }
3094 if ( incidence && incidence->type() == "Event" ) { 3082 if ( incidence && incidence->type() == "Event" ) {
3095 event = static_cast<Event *>(incidence); 3083 event = static_cast<Event *>(incidence);
3096 } 3084 }
3097 if ( incidence && incidence->type() == "Todo" ) { 3085 if ( incidence && incidence->type() == "Todo" ) {
3098 todo = static_cast<Todo *>(incidence); 3086 todo = static_cast<Todo *>(incidence);
3099 } 3087 }
3100 3088
3101 if (!event && !todo) { 3089 if (!event && !todo) {
3102 KMessageBox::sorry(this,i18n("No event selected.")); 3090 KMessageBox::sorry(this,i18n("No event selected."));
3103 return; 3091 return;
3104 } 3092 }
3105 3093
3106 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { 3094 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) {
3107 KMessageBox::sorry(this,i18n("The event has no attendees.")); 3095 KMessageBox::sorry(this,i18n("The event has no attendees."));
3108 return; 3096 return;
3109 } 3097 }
3110 3098
3111 Event *ev = 0; 3099 Event *ev = 0;
3112 if (event) ev = new Event(*event); 3100 if (event) ev = new Event(*event);
3113 Todo *to = 0; 3101 Todo *to = 0;
3114 if (todo) to = new Todo(*todo); 3102 if (todo) to = new Todo(*todo);
3115 3103
3116 if (method == Scheduler::Reply || method == Scheduler::Refresh) { 3104 if (method == Scheduler::Reply || method == Scheduler::Refresh) {
3117 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 3105 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
3118 if (!me) { 3106 if (!me) {
3119 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); 3107 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails."));
3120 return; 3108 return;
3121 } 3109 }
3122 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { 3110 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) {
3123 StatusDialog *statdlg = new StatusDialog(this); 3111 StatusDialog *statdlg = new StatusDialog(this);
3124 if (!statdlg->exec()==QDialog::Accepted) return; 3112 if (!statdlg->exec()==QDialog::Accepted) return;
3125 me->setStatus( statdlg->status() ); 3113 me->setStatus( statdlg->status() );
3126 delete(statdlg); 3114 delete(statdlg);
3127 } 3115 }
3128 Attendee *menew = new Attendee(*me); 3116 Attendee *menew = new Attendee(*me);
3129 if (ev) { 3117 if (ev) {
3130 ev->clearAttendees(); 3118 ev->clearAttendees();
3131 ev->addAttendee(menew,false); 3119 ev->addAttendee(menew,false);
3132 } else { 3120 } else {
3133 if (to) { 3121 if (to) {
3134 todo->clearAttendees(); 3122 todo->clearAttendees();
3135 todo->addAttendee(menew,false); 3123 todo->addAttendee(menew,false);
3136 } 3124 }
3137 } 3125 }
3138 } 3126 }
3139 3127
3140 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3128 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3141 if (ev) { 3129 if (ev) {
3142 if ( !dlg->addMessage(ev,method) ) delete(ev); 3130 if ( !dlg->addMessage(ev,method) ) delete(ev);
3143 } else { 3131 } else {
3144 if (to) { 3132 if (to) {
3145 if ( !dlg->addMessage(to,method) ) delete(to); 3133 if ( !dlg->addMessage(to,method) ) delete(to);
3146 } 3134 }
3147 } 3135 }
3148} 3136}
3149 3137
3150void CalendarView::openAddressbook() 3138void CalendarView::openAddressbook()
3151{ 3139{
3152 KRun::runCommand("kaddressbook"); 3140 KRun::runCommand("kaddressbook");
3153} 3141}
3154 3142
3155void CalendarView::setModified(bool modified) 3143void CalendarView::setModified(bool modified)
3156{ 3144{
3157 if ( modified ) 3145 if ( modified )
3158 emit signalmodified(); 3146 emit signalmodified();
3159 if (mModified != modified) { 3147 if (mModified != modified) {
3160 mModified = modified; 3148 mModified = modified;
3161 emit modifiedChanged(mModified); 3149 emit modifiedChanged(mModified);
3162 } 3150 }
3163} 3151}
3164 3152
3165bool CalendarView::isReadOnly() 3153bool CalendarView::isReadOnly()
3166{ 3154{
3167 return mReadOnly; 3155 return mReadOnly;
3168} 3156}
3169 3157
3170void CalendarView::setReadOnly(bool readOnly) 3158void CalendarView::setReadOnly(bool readOnly)
3171{ 3159{
3172 if (mReadOnly != readOnly) { 3160 if (mReadOnly != readOnly) {
3173 mReadOnly = readOnly; 3161 mReadOnly = readOnly;
3174 emit readOnlyChanged(mReadOnly); 3162 emit readOnlyChanged(mReadOnly);
3175 } 3163 }
3176} 3164}
3177 3165
3178bool CalendarView::isModified() 3166bool CalendarView::isModified()
3179{ 3167{
3180 return mModified; 3168 return mModified;
3181} 3169}
3182 3170
3183void CalendarView::printSetup() 3171void CalendarView::printSetup()
3184{ 3172{
3185#ifndef KORG_NOPRINTER 3173#ifndef KORG_NOPRINTER
3186 createPrinter(); 3174 createPrinter();
3187 3175
3188 mCalPrinter->setupPrinter(); 3176 mCalPrinter->setupPrinter();
3189#endif 3177#endif
3190} 3178}
3191 3179
3192void CalendarView::print() 3180void CalendarView::print()
3193{ 3181{
3194#ifndef KORG_NOPRINTER 3182#ifndef KORG_NOPRINTER
3195 createPrinter(); 3183 createPrinter();
3196 3184
3197 DateList tmpDateList = mNavigator->selectedDates(); 3185 DateList tmpDateList = mNavigator->selectedDates();
3198 mCalPrinter->print(CalPrinter::Month, 3186 mCalPrinter->print(CalPrinter::Month,
3199 tmpDateList.first(), tmpDateList.last()); 3187 tmpDateList.first(), tmpDateList.last());
3200#endif 3188#endif
3201} 3189}
3202 3190
3203void CalendarView::printPreview() 3191void CalendarView::printPreview()
3204{ 3192{
3205#ifndef KORG_NOPRINTER 3193#ifndef KORG_NOPRINTER
3206 kdDebug() << "CalendarView::printPreview()" << endl; 3194 kdDebug() << "CalendarView::printPreview()" << endl;
3207 3195
3208 createPrinter(); 3196 createPrinter();
3209 3197
3210 DateList tmpDateList = mNavigator->selectedDates(); 3198 DateList tmpDateList = mNavigator->selectedDates();
3211 3199
3212 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), 3200 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(),
3213 tmpDateList.last()); 3201 tmpDateList.last());
3214#endif 3202#endif
3215} 3203}
3216 3204
3217void CalendarView::exportICalendar() 3205void CalendarView::exportICalendar()
3218{ 3206{
3219 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); 3207 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this);
3220 3208
3221 // Force correct extension 3209 // Force correct extension
3222 if (filename.right(4) != ".ics") filename += ".ics"; 3210 if (filename.right(4) != ".ics") filename += ".ics";
3223 3211
3224 FileStorage storage( mCalendar, filename, new ICalFormat() ); 3212 FileStorage storage( mCalendar, filename, new ICalFormat() );
3225 storage.save(); 3213 storage.save();
3226} 3214}
3227 3215
3228bool CalendarView::exportVCalendar( QString filename ) 3216bool CalendarView::exportVCalendar( QString filename )
3229{ 3217{
3230 if (mCalendar->journals().count() > 0) { 3218 if (mCalendar->journals().count() > 0) {
3231 int result = KMessageBox::warningContinueCancel(this, 3219 int result = KMessageBox::warningContinueCancel(this,
3232 i18n("The journal entries can not be\nexported to a vCalendar file."), 3220 i18n("The journal entries can not be\nexported to a vCalendar file."),
3233 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 3221 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
3234 true); 3222 true);
3235 if (result != KMessageBox::Continue) return false; 3223 if (result != KMessageBox::Continue) return false;
3236 } 3224 }
3237 3225
3238 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); 3226 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this);
3239 3227
3240 // Force correct extension 3228 // Force correct extension
3241 if (filename.right(4) != ".vcs") filename += ".vcs"; 3229 if (filename.right(4) != ".vcs") filename += ".vcs";
3242 3230
3243 FileStorage storage( mCalendar, filename, new VCalFormat ); 3231 FileStorage storage( mCalendar, filename, new VCalFormat );
3244 return storage.save(); 3232 return storage.save();
3245 3233
3246} 3234}
3247 3235
3248void CalendarView::eventUpdated(Incidence *) 3236void CalendarView::eventUpdated(Incidence *)
3249{ 3237{
3250 setModified(); 3238 setModified();
3251 // Don't call updateView here. The code, which has caused the update of the 3239 // Don't call updateView here. The code, which has caused the update of the
3252 // event is responsible for updating the view. 3240 // event is responsible for updating the view.
3253 // updateView(); 3241 // updateView();
3254} 3242}
3255 3243
3256void CalendarView::adaptNavigationUnits() 3244void CalendarView::adaptNavigationUnits()
3257{ 3245{
3258 if (mViewManager->currentView()->isEventView()) { 3246 if (mViewManager->currentView()->isEventView()) {
3259 int days = mViewManager->currentView()->currentDateCount(); 3247 int days = mViewManager->currentView()->currentDateCount();
3260 if (days == 1) { 3248 if (days == 1) {
3261 emit changeNavStringPrev(i18n("&Previous Day")); 3249 emit changeNavStringPrev(i18n("&Previous Day"));
3262 emit changeNavStringNext(i18n("&Next Day")); 3250 emit changeNavStringNext(i18n("&Next Day"));
3263 } else { 3251 } else {
3264 emit changeNavStringPrev(i18n("&Previous Week")); 3252 emit changeNavStringPrev(i18n("&Previous Week"));
3265 emit changeNavStringNext(i18n("&Next Week")); 3253 emit changeNavStringNext(i18n("&Next Week"));
3266 } 3254 }
3267 } 3255 }
3268} 3256}
3269 3257
3270void CalendarView::processMainViewSelection( Incidence *incidence ) 3258void CalendarView::processMainViewSelection( Incidence *incidence )
3271{ 3259{
3272 if ( incidence ) mTodoList->clearSelection(); 3260 if ( incidence ) mTodoList->clearSelection();
3273 processIncidenceSelection( incidence ); 3261 processIncidenceSelection( incidence );
3274} 3262}
3275 3263
3276void CalendarView::processTodoListSelection( Incidence *incidence ) 3264void CalendarView::processTodoListSelection( Incidence *incidence )
3277{ 3265{
3278 if ( incidence && mViewManager->currentView() ) { 3266 if ( incidence && mViewManager->currentView() ) {
3279 mViewManager->currentView()->clearSelection(); 3267 mViewManager->currentView()->clearSelection();
3280 } 3268 }
3281 processIncidenceSelection( incidence ); 3269 processIncidenceSelection( incidence );
3282} 3270}
3283 3271
3284void CalendarView::processIncidenceSelection( Incidence *incidence ) 3272void CalendarView::processIncidenceSelection( Incidence *incidence )
3285{ 3273{
3286 if ( incidence == mSelectedIncidence ) return; 3274 if ( incidence == mSelectedIncidence ) return;
3287 3275
3288 mSelectedIncidence = incidence; 3276 mSelectedIncidence = incidence;
3289 3277
3290 emit incidenceSelected( mSelectedIncidence ); 3278 emit incidenceSelected( mSelectedIncidence );
3291 3279
3292 if ( incidence && incidence->type() == "Event" ) { 3280 if ( incidence && incidence->type() == "Event" ) {
3293 Event *event = static_cast<Event *>( incidence ); 3281 Event *event = static_cast<Event *>( incidence );
3294 if ( event->organizer() == KOPrefs::instance()->email() ) { 3282 if ( event->organizer() == KOPrefs::instance()->email() ) {
3295 emit organizerEventsSelected( true ); 3283 emit organizerEventsSelected( true );
3296 } else { 3284 } else {
3297 emit organizerEventsSelected(false); 3285 emit organizerEventsSelected(false);
3298 } 3286 }
3299 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3287 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3300 KOPrefs::instance()->email() ) ) { 3288 KOPrefs::instance()->email() ) ) {
3301 emit groupEventsSelected( true ); 3289 emit groupEventsSelected( true );
3302 } else { 3290 } else {
3303 emit groupEventsSelected(false); 3291 emit groupEventsSelected(false);
3304 } 3292 }
3305 return; 3293 return;
3306 } else { 3294 } else {
3307 if ( incidence && incidence->type() == "Todo" ) { 3295 if ( incidence && incidence->type() == "Todo" ) {
3308 emit todoSelected( true ); 3296 emit todoSelected( true );
3309 Todo *event = static_cast<Todo *>( incidence ); 3297 Todo *event = static_cast<Todo *>( incidence );
3310 if ( event->organizer() == KOPrefs::instance()->email() ) { 3298 if ( event->organizer() == KOPrefs::instance()->email() ) {
3311 emit organizerEventsSelected( true ); 3299 emit organizerEventsSelected( true );
3312 } else { 3300 } else {
3313 emit organizerEventsSelected(false); 3301 emit organizerEventsSelected(false);
3314 } 3302 }
3315 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3303 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3316 KOPrefs::instance()->email() ) ) { 3304 KOPrefs::instance()->email() ) ) {
3317 emit groupEventsSelected( true ); 3305 emit groupEventsSelected( true );
3318 } else { 3306 } else {
3319 emit groupEventsSelected(false); 3307 emit groupEventsSelected(false);
3320 } 3308 }
3321 return; 3309 return;
3322 } else { 3310 } else {
3323 emit todoSelected( false ); 3311 emit todoSelected( false );
3324 emit organizerEventsSelected(false); 3312 emit organizerEventsSelected(false);
3325 emit groupEventsSelected(false); 3313 emit groupEventsSelected(false);
3326 } 3314 }
3327 return; 3315 return;
3328 } 3316 }
3329 3317
3330 /* if ( incidence && incidence->type() == "Todo" ) { 3318 /* if ( incidence && incidence->type() == "Todo" ) {
3331 emit todoSelected( true ); 3319 emit todoSelected( true );
3332 } else { 3320 } else {
3333 emit todoSelected( false ); 3321 emit todoSelected( false );
3334 }*/ 3322 }*/
3335} 3323}
3336 3324
3337 3325
3338void CalendarView::checkClipboard() 3326void CalendarView::checkClipboard()
3339{ 3327{
3340#ifndef KORG_NODND 3328#ifndef KORG_NODND
3341 if (ICalDrag::canDecode(QApplication::clipboard()->data())) { 3329 if (ICalDrag::canDecode(QApplication::clipboard()->data())) {
3342 emit pasteEnabled(true); 3330 emit pasteEnabled(true);
3343 } else { 3331 } else {
3344 emit pasteEnabled(false); 3332 emit pasteEnabled(false);
3345 } 3333 }
3346#endif 3334#endif
3347} 3335}
3348 3336
3349void CalendarView::showDates(const DateList &selectedDates) 3337void CalendarView::showDates(const DateList &selectedDates)
3350{ 3338{
3351 // kdDebug() << "CalendarView::selectDates()" << endl; 3339 // kdDebug() << "CalendarView::selectDates()" << endl;
3352 3340
3353 if ( mViewManager->currentView() ) { 3341 if ( mViewManager->currentView() ) {
3354 updateView( selectedDates.first(), selectedDates.last() ); 3342 updateView( selectedDates.first(), selectedDates.last() );
3355 } else { 3343 } else {
3356 mViewManager->showAgendaView(); 3344 mViewManager->showAgendaView();
3357 } 3345 }
3358 3346
3359 QString selDates; 3347 QString selDates;
3360 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); 3348 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true);
3361 if (selectedDates.first() < selectedDates.last() ) 3349 if (selectedDates.first() < selectedDates.last() )
3362 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); 3350 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true);
3363 topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); 3351 topLevelWidget()->setCaption( i18n("Dates: ") + selDates );
3364 3352
3365} 3353}
3366 3354
3367QPtrList<CalFilter> CalendarView::filters() 3355QPtrList<CalFilter> CalendarView::filters()
3368{ 3356{
3369 return mFilters; 3357 return mFilters;
3370 3358
3371} 3359}
3372void CalendarView::editFilters() 3360void CalendarView::editFilters()
3373{ 3361{
3374 // kdDebug() << "CalendarView::editFilters()" << endl; 3362 // kdDebug() << "CalendarView::editFilters()" << endl;
3375 3363
3376 CalFilter *filter = mFilters.first(); 3364 CalFilter *filter = mFilters.first();
3377 while(filter) { 3365 while(filter) {
3378 kdDebug() << " Filter: " << filter->name() << endl; 3366 kdDebug() << " Filter: " << filter->name() << endl;
3379 filter = mFilters.next(); 3367 filter = mFilters.next();
3380 } 3368 }
3381 3369
3382 mDialogManager->showFilterEditDialog(&mFilters); 3370 mDialogManager->showFilterEditDialog(&mFilters);
3383} 3371}
3384void CalendarView::toggleFilter() 3372void CalendarView::toggleFilter()
3385{ 3373{
3386 showFilter(! mFilterView->isVisible()); 3374 showFilter(! mFilterView->isVisible());
3387} 3375}
3388 3376
3389KOFilterView *CalendarView::filterView() 3377KOFilterView *CalendarView::filterView()
3390{ 3378{
3391 return mFilterView; 3379 return mFilterView;
3392} 3380}
3393void CalendarView::selectFilter( int fil ) 3381void CalendarView::selectFilter( int fil )
3394{ 3382{
3395 mFilterView->setSelectedFilter( fil ); 3383 mFilterView->setSelectedFilter( fil );
3396} 3384}
3397void CalendarView::showFilter(bool visible) 3385void CalendarView::showFilter(bool visible)
3398{ 3386{
3399 if (visible) mFilterView->show(); 3387 if (visible) mFilterView->show();
3400 else mFilterView->hide(); 3388 else mFilterView->hide();
3401} 3389}
3402void CalendarView::toggleFilerEnabled( ) 3390void CalendarView::toggleFilerEnabled( )
3403{ 3391{
3404 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); 3392 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() );
3405 if ( !mFilterView->filtersEnabled() ) 3393 if ( !mFilterView->filtersEnabled() )
3406 topLevelWidget()->setCaption( i18n("Filter disabled ") ); 3394 topLevelWidget()->setCaption( i18n("Filter disabled ") );
3407 3395
3408} 3396}
3409void CalendarView::updateFilter() 3397void CalendarView::updateFilter()
3410{ 3398{
3411 CalFilter *filter = mFilterView->selectedFilter(); 3399 CalFilter *filter = mFilterView->selectedFilter();
3412 if (filter) { 3400 if (filter) {
3413 if (mFilterView->filtersEnabled()) { 3401 if (mFilterView->filtersEnabled()) {
3414 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); 3402 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() );
3415 filter->setEnabled(true); 3403 filter->setEnabled(true);
3416 } 3404 }
3417 else filter->setEnabled(false); 3405 else filter->setEnabled(false);
3418 mCalendar->setFilter(filter); 3406 mCalendar->setFilter(filter);
3419 updateView(); 3407 updateView();
3420 } 3408 }
3421} 3409}
3422 3410
3423void CalendarView::filterEdited() 3411void CalendarView::filterEdited()
3424{ 3412{
3425 mFilterView->updateFilters(); 3413 mFilterView->updateFilters();
3426 updateFilter(); 3414 updateFilter();
3427 writeSettings(); 3415 writeSettings();
3428} 3416}
3429 3417
3430 3418
3431void CalendarView::takeOverEvent() 3419void CalendarView::takeOverEvent()
3432{ 3420{
3433 Incidence *incidence = currentSelection(); 3421 Incidence *incidence = currentSelection();
3434 3422
3435 if (!incidence) return; 3423 if (!incidence) return;
3436 3424
3437 incidence->setOrganizer(KOPrefs::instance()->email()); 3425 incidence->setOrganizer(KOPrefs::instance()->email());
3438 incidence->recreate(); 3426 incidence->recreate();
3439 incidence->setReadOnly(false); 3427 incidence->setReadOnly(false);
3440 3428
3441 updateView(); 3429 updateView();
3442} 3430}
3443 3431
3444void CalendarView::takeOverCalendar() 3432void CalendarView::takeOverCalendar()
3445{ 3433{
3446 // TODO: Create Calendar::allIncidences() function and use it here 3434 // TODO: Create Calendar::allIncidences() function and use it here
3447 3435
3448 QPtrList<Event> events = mCalendar->events(); 3436 QPtrList<Event> events = mCalendar->events();
3449 for(uint i=0; i<events.count(); ++i) { 3437 for(uint i=0; i<events.count(); ++i) {
3450 events.at(i)->setOrganizer(KOPrefs::instance()->email()); 3438 events.at(i)->setOrganizer(KOPrefs::instance()->email());
3451 events.at(i)->recreate(); 3439 events.at(i)->recreate();
3452 events.at(i)->setReadOnly(false); 3440 events.at(i)->setReadOnly(false);
3453 } 3441 }
3454 3442
3455 QPtrList<Todo> todos = mCalendar->todos(); 3443 QPtrList<Todo> todos = mCalendar->todos();
3456 for(uint i=0; i<todos.count(); ++i) { 3444 for(uint i=0; i<todos.count(); ++i) {
3457 todos.at(i)->setOrganizer(KOPrefs::instance()->email()); 3445 todos.at(i)->setOrganizer(KOPrefs::instance()->email());
3458 todos.at(i)->recreate(); 3446 todos.at(i)->recreate();
3459 todos.at(i)->setReadOnly(false); 3447 todos.at(i)->setReadOnly(false);
3460 } 3448 }
3461 3449
3462 QPtrList<Journal> journals = mCalendar->journals(); 3450 QPtrList<Journal> journals = mCalendar->journals();
3463 for(uint i=0; i<journals.count(); ++i) { 3451 for(uint i=0; i<journals.count(); ++i) {
3464 journals.at(i)->setOrganizer(KOPrefs::instance()->email()); 3452 journals.at(i)->setOrganizer(KOPrefs::instance()->email());
3465 journals.at(i)->recreate(); 3453 journals.at(i)->recreate();
3466 journals.at(i)->setReadOnly(false); 3454 journals.at(i)->setReadOnly(false);
3467 } 3455 }
3468 3456
3469 updateView(); 3457 updateView();
3470} 3458}
3471 3459
3472void CalendarView::showIntro() 3460void CalendarView::showIntro()
3473{ 3461{
3474 kdDebug() << "To be implemented." << endl; 3462 kdDebug() << "To be implemented." << endl;
3475} 3463}
3476 3464
3477QWidgetStack *CalendarView::viewStack() 3465QWidgetStack *CalendarView::viewStack()
3478{ 3466{
3479 return mRightFrame; 3467 return mRightFrame;
3480} 3468}
3481 3469
3482QWidget *CalendarView::leftFrame() 3470QWidget *CalendarView::leftFrame()
3483{ 3471{
3484 return mLeftFrame; 3472 return mLeftFrame;
3485} 3473}
3486 3474
3487DateNavigator *CalendarView::dateNavigator() 3475DateNavigator *CalendarView::dateNavigator()
3488{ 3476{
3489 return mNavigator; 3477 return mNavigator;
3490} 3478}
3491 3479
3492KDateNavigator* CalendarView::dateNavigatorWidget() 3480KDateNavigator* CalendarView::dateNavigatorWidget()
3493{ 3481{
3494 return mDateNavigator; 3482 return mDateNavigator;
3495} 3483}
3496void CalendarView::toggleDateNavigatorWidget() 3484void CalendarView::toggleDateNavigatorWidget()
3497{ 3485{
3498 if (mDateNavigator->isVisible()) 3486 if (mDateNavigator->isVisible())
3499 mDateNavigator->hide(); 3487 mDateNavigator->hide();
3500 else 3488 else
3501 mDateNavigator->show(); 3489 mDateNavigator->show();
3502} 3490}
3503void CalendarView::addView(KOrg::BaseView *view) 3491void CalendarView::addView(KOrg::BaseView *view)
3504{ 3492{
3505 mViewManager->addView(view); 3493 mViewManager->addView(view);
3506} 3494}
3507 3495
3508void CalendarView::showView(KOrg::BaseView *view) 3496void CalendarView::showView(KOrg::BaseView *view)
3509{ 3497{
3510 mViewManager->showView(view, mLeftFrame->isVisible()); 3498 mViewManager->showView(view, mLeftFrame->isVisible());
3511} 3499}
3512 3500
3513Incidence *CalendarView::currentSelection() 3501Incidence *CalendarView::currentSelection()
3514{ 3502{
3515 return mViewManager->currentSelection(); 3503 return mViewManager->currentSelection();
3516} 3504}
3517void CalendarView::toggleAllDaySize() 3505void CalendarView::toggleAllDaySize()
3518{ 3506{
3519 /* 3507 /*
3520 if ( KOPrefs::instance()->mAllDaySize > 47 ) 3508 if ( KOPrefs::instance()->mAllDaySize > 47 )
3521 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; 3509 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2;
3522 else 3510 else
3523 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; 3511 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2;
3524 */ 3512 */
3525 viewManager()->agendaView()->toggleAllDay(); 3513 viewManager()->agendaView()->toggleAllDay();
3526} 3514}
3527void CalendarView::toggleExpand() 3515void CalendarView::toggleExpand()
3528{ 3516{
3529 // if ( mLeftFrame->isHidden() ) { 3517 // if ( mLeftFrame->isHidden() ) {
3530 // mLeftFrame->show(); 3518 // mLeftFrame->show();
3531 // emit calendarViewExpanded( false ); 3519 // emit calendarViewExpanded( false );
3532 // } else { 3520 // } else {
3533 // mLeftFrame->hide(); 3521 // mLeftFrame->hide();
3534 // emit calendarViewExpanded( true ); 3522 // emit calendarViewExpanded( true );
3535 // } 3523 // }
3536 3524
3537 globalFlagBlockAgenda = 1; 3525 globalFlagBlockAgenda = 1;
3538 emit calendarViewExpanded( !mLeftFrame->isHidden() ); 3526 emit calendarViewExpanded( !mLeftFrame->isHidden() );
3539 globalFlagBlockAgenda = 5; 3527 globalFlagBlockAgenda = 5;
3540 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); 3528 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() );
3541 //mViewManager->showView( 0, true ); 3529 //mViewManager->showView( 0, true );
3542} 3530}
3543 3531
3544void CalendarView::calendarModified( bool modified, Calendar * ) 3532void CalendarView::calendarModified( bool modified, Calendar * )
3545{ 3533{
3546 setModified( modified ); 3534 setModified( modified );
3547} 3535}
3548 3536
3549Todo *CalendarView::selectedTodo() 3537Todo *CalendarView::selectedTodo()
3550{ 3538{
3551 Incidence *incidence = currentSelection(); 3539 Incidence *incidence = currentSelection();
3552 if ( incidence && incidence->type() == "Todo" ) { 3540 if ( incidence && incidence->type() == "Todo" ) {
3553 return static_cast<Todo *>( incidence ); 3541 return static_cast<Todo *>( incidence );
3554 } 3542 }
3555 3543
3556 incidence = mTodoList->selectedIncidences().first(); 3544 incidence = mTodoList->selectedIncidences().first();
3557 if ( incidence && incidence->type() == "Todo" ) { 3545 if ( incidence && incidence->type() == "Todo" ) {
3558 return static_cast<Todo *>( incidence ); 3546 return static_cast<Todo *>( incidence );
3559 } 3547 }
3560 3548
3561 return 0; 3549 return 0;
3562} 3550}
3563 3551
3564void CalendarView::dialogClosing(Incidence *in) 3552void CalendarView::dialogClosing(Incidence *in)
3565{ 3553{
3566 // mDialogList.remove(in); 3554 // mDialogList.remove(in);
3567} 3555}
3568 3556
3569void CalendarView::showIncidence() 3557void CalendarView::showIncidence()
3570{ 3558{
3571 Incidence *incidence = currentSelection(); 3559 Incidence *incidence = currentSelection();
3572 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3560 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3573 if ( incidence ) { 3561 if ( incidence ) {
3574 ShowIncidenceVisitor v; 3562 ShowIncidenceVisitor v;
3575 v.act( incidence, this ); 3563 v.act( incidence, this );
3576 } 3564 }
3577} 3565}
3578void CalendarView::editIncidenceDescription() 3566void CalendarView::editIncidenceDescription()
3579{ 3567{
3580 mFlagEditDescription = true; 3568 mFlagEditDescription = true;
3581 editIncidence(); 3569 editIncidence();
3582 mFlagEditDescription = false; 3570 mFlagEditDescription = false;
3583} 3571}
3584void CalendarView::editIncidence() 3572void CalendarView::editIncidence()
3585{ 3573{
3586 // qDebug("editIncidence() "); 3574 // qDebug("editIncidence() ");
3587 Incidence *incidence = currentSelection(); 3575 Incidence *incidence = currentSelection();
3588 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3576 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3589 if ( incidence ) { 3577 if ( incidence ) {
3590 EditIncidenceVisitor v; 3578 EditIncidenceVisitor v;
3591 v.act( incidence, this ); 3579 v.act( incidence, this );
3592 } 3580 }
3593} 3581}
3594 3582
3595void CalendarView::deleteIncidence() 3583void CalendarView::deleteIncidence()
3596{ 3584{
3597 Incidence *incidence = currentSelection(); 3585 Incidence *incidence = currentSelection();
3598 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3586 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3599 if ( incidence ) { 3587 if ( incidence ) {
3600 deleteIncidence(incidence); 3588 deleteIncidence(incidence);
3601 } 3589 }
3602} 3590}
3603 3591
3604void CalendarView::showIncidence(Incidence *incidence) 3592void CalendarView::showIncidence(Incidence *incidence)
3605{ 3593{
3606 if ( incidence ) { 3594 if ( incidence ) {
3607 ShowIncidenceVisitor v; 3595 ShowIncidenceVisitor v;
3608 v.act( incidence, this ); 3596 v.act( incidence, this );
3609 } 3597 }
3610} 3598}
3611 3599
3612void CalendarView::editIncidence(Incidence *incidence) 3600void CalendarView::editIncidence(Incidence *incidence)
3613{ 3601{
3614 if ( incidence ) { 3602 if ( incidence ) {
3615 3603
3616 EditIncidenceVisitor v; 3604 EditIncidenceVisitor v;
3617 v.act( incidence, this ); 3605 v.act( incidence, this );
3618 3606
3619 } 3607 }
3620} 3608}
3621 3609
3622void CalendarView::deleteIncidence(Incidence *incidence) 3610void CalendarView::deleteIncidence(Incidence *incidence)
3623{ 3611{
3624 //qDebug(" CalendarView::deleteIncidence "); 3612 //qDebug(" CalendarView::deleteIncidence ");
3625 if ( incidence ) { 3613 if ( incidence ) {
3626 DeleteIncidenceVisitor v; 3614 DeleteIncidenceVisitor v;
3627 v.act( incidence, this ); 3615 v.act( incidence, this );
3628 } 3616 }
3629} 3617}
3630 3618
3631 3619
3632void CalendarView::lookForOutgoingMessages() 3620void CalendarView::lookForOutgoingMessages()
3633{ 3621{
3634 OutgoingDialog *ogd = mDialogManager->outgoingDialog(); 3622 OutgoingDialog *ogd = mDialogManager->outgoingDialog();
3635 ogd->loadMessages(); 3623 ogd->loadMessages();
3636} 3624}
3637 3625
3638void CalendarView::lookForIncomingMessages() 3626void CalendarView::lookForIncomingMessages()
3639{ 3627{
3640 IncomingDialog *icd = mDialogManager->incomingDialog(); 3628 IncomingDialog *icd = mDialogManager->incomingDialog();
3641 icd->retrieve(); 3629 icd->retrieve();
3642} 3630}
3643 3631
3644bool CalendarView::removeCompletedSubTodos( Todo* t ) 3632bool CalendarView::removeCompletedSubTodos( Todo* t )
3645{ 3633{
3646 bool deleteTodo = true; 3634 bool deleteTodo = true;
3647 QPtrList<Incidence> subTodos; 3635 QPtrList<Incidence> subTodos;
3648 Incidence *aTodo; 3636 Incidence *aTodo;
3649 subTodos = t->relations(); 3637 subTodos = t->relations();
3650 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { 3638 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
3651 if (! removeCompletedSubTodos( (Todo*) aTodo )) 3639 if (! removeCompletedSubTodos( (Todo*) aTodo ))
3652 deleteTodo = false; 3640 deleteTodo = false;
3653 } 3641 }
3654 if ( deleteTodo ) { 3642 if ( deleteTodo ) {
3655 if ( t->isCompleted() ) { 3643 if ( t->isCompleted() ) {
3656 checkExternalId( t ); 3644 checkExternalId( t );
3657 mCalendar->deleteTodo( t ); 3645 mCalendar->deleteTodo( t );
3658 changeTodoDisplay( t,KOGlobals::EVENTDELETED ); 3646 changeTodoDisplay( t,KOGlobals::EVENTDELETED );
3659 } 3647 }
3660 else 3648 else
3661 deleteTodo = false; 3649 deleteTodo = false;
3662 } 3650 }
3663 return deleteTodo; 3651 return deleteTodo;
3664 3652
3665} 3653}
3666void CalendarView::purgeCompleted() 3654void CalendarView::purgeCompleted()
3667{ 3655{
3668 int result = KMessageBox::warningContinueCancel(this, 3656 int result = KMessageBox::warningContinueCancel(this,
3669 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); 3657 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge"));
3670 3658
3671 if (result == KMessageBox::Continue) { 3659 if (result == KMessageBox::Continue) {
3672 3660
3673 QPtrList<Todo> todoCal; 3661 QPtrList<Todo> todoCal;
3674 QPtrList<Todo> rootTodos; 3662 QPtrList<Todo> rootTodos;
3675 //QPtrList<Incidence> rel; 3663 //QPtrList<Incidence> rel;
3676 Todo *aTodo;//, *rTodo; 3664 Todo *aTodo;//, *rTodo;
3677 Incidence *rIncidence; 3665 Incidence *rIncidence;
3678 bool childDelete = false; 3666 bool childDelete = false;
3679 bool deletedOne = true; 3667 bool deletedOne = true;
3680 todoCal = calendar()->todos(); 3668 todoCal = calendar()->todos();
3681 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { 3669 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
3682 if ( !aTodo->relatedTo() ) 3670 if ( !aTodo->relatedTo() )
3683 rootTodos.append( aTodo ); 3671 rootTodos.append( aTodo );
3684 } 3672 }
3685 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { 3673 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) {
3686 removeCompletedSubTodos( aTodo ); 3674 removeCompletedSubTodos( aTodo );
3687 } 3675 }
3688 3676
3689 updateView(); 3677 updateView();
3690 } 3678 }
3691} 3679}
3692 3680
3693void CalendarView::slotCalendarChanged() 3681void CalendarView::slotCalendarChanged()
3694{ 3682{
3695 ; 3683 ;
3696} 3684}
3697 3685
3698NavigatorBar *CalendarView::navigatorBar() 3686NavigatorBar *CalendarView::navigatorBar()
3699{ 3687{
3700 return mNavigatorBar; 3688 return mNavigatorBar;
3701} 3689}
3702 3690
3703 3691
3704 3692
3705void CalendarView::keyPressEvent ( QKeyEvent *e) 3693void CalendarView::keyPressEvent ( QKeyEvent *e)
3706{ 3694{
3707 //qDebug(" alendarView::keyPressEvent "); 3695 //qDebug(" alendarView::keyPressEvent ");
3708 e->ignore(); 3696 e->ignore();
3709} 3697}
3710 3698
3711 3699
3712bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) 3700bool CalendarView::sync(KSyncManager* manager, QString filename, int mode)
3713{ 3701{
3714 // mSyncManager = manager; 3702 // mSyncManager = manager;
3715 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 3703 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
3716 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 3704 mCurrentSyncName = mSyncManager->getCurrentSyncName();
3717 return syncCalendar( filename, mode ); 3705 return syncCalendar( filename, mode );
3718} 3706}
3719bool CalendarView::syncExternal(KSyncManager* manager, QString resource) 3707bool CalendarView::syncExternal(KSyncManager* manager, QString resource)
3720{ 3708{
3721 //mSyncManager = manager; 3709 //mSyncManager = manager;
3722 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 3710 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
3723 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 3711 mCurrentSyncName = mSyncManager->getCurrentSyncName();
3724 if ( resource == "sharp" ) 3712 if ( resource == "sharp" )
3725 syncExternal( 0 ); 3713 syncExternal( 0 );
3726 if ( resource == "phone" ) 3714 if ( resource == "phone" )
3727 syncExternal( 1 ); 3715 syncExternal( 1 );
3728 // pending setmodified 3716 // pending setmodified
3729 return true; 3717 return true;
3730} 3718}
3731void CalendarView::setSyncManager(KSyncManager* manager) 3719void CalendarView::setSyncManager(KSyncManager* manager)
3732{ 3720{
3733 mSyncManager = manager; 3721 mSyncManager = manager;
3734} 3722}
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index 751b8d9..660cce7 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -1,606 +1,602 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000, 2001 3 Copyright (c) 2000, 2001
4 Cornelius Schumacher <schumacher@kde.org> 4 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program 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 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24#ifndef CALENDARVIEW_H 24#ifndef CALENDARVIEW_H
25#define CALENDARVIEW_H 25#define CALENDARVIEW_H
26 26
27#include <qframe.h> 27#include <qframe.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#include <qwidget.h> 29#include <qwidget.h>
30#include <qptrlist.h> 30#include <qptrlist.h>
31#include <qvbox.h> 31#include <qvbox.h>
32#include <qmap.h> 32#include <qmap.h>
33#ifndef DESKTOP_VERSION 33#ifndef DESKTOP_VERSION
34#include <qtopia/ir.h> 34#include <qtopia/ir.h>
35#else 35#else
36#define Ir char 36#define Ir char
37#endif 37#endif
38#include <libkcal/calendar.h> 38#include <libkcal/calendar.h>
39#include <libkcal/scheduler.h> 39#include <libkcal/scheduler.h>
40#include <libkcal/calendarresources.h> 40#include <libkcal/calendarresources.h>
41#include <libkcal/resourcecalendar.h> 41#include <libkcal/resourcecalendar.h>
42 42
43#include <korganizer/calendarviewbase.h> 43#include <korganizer/calendarviewbase.h>
44 44
45#include <ksyncmanager.h> 45#include <ksyncmanager.h>
46 46
47class QWidgetStack; 47class QWidgetStack;
48class QSplitter; 48class QSplitter;
49 49
50class CalPrinter; 50class CalPrinter;
51class KOFilterView; 51class KOFilterView;
52class KOViewManager; 52class KOViewManager;
53class KODialogManager; 53class KODialogManager;
54class KOTodoView; 54class KOTodoView;
55class KDateNavigator; 55class KDateNavigator;
56class DateNavigator; 56class DateNavigator;
57class KOIncidenceEditor; 57class KOIncidenceEditor;
58class KDatePicker; 58class KDatePicker;
59class ResourceView; 59class ResourceView;
60class NavigatorBar; 60class NavigatorBar;
61class KOEventEditor; 61class KOEventEditor;
62class KOTodoEditor ; 62class KOTodoEditor ;
63class KOEventViewerDialog; 63class KOEventViewerDialog;
64class KOBeamPrefs; 64class KOBeamPrefs;
65class KSyncProfile; 65class KSyncProfile;
66class AlarmDialog; 66class AlarmDialog;
67class KCal::Attendee; 67class KCal::Attendee;
68 68
69namespace KCal { class FileStorage; } 69namespace KCal { class FileStorage; }
70 70
71using namespace KCal; 71using namespace KCal;
72 72
73/** 73/**
74 This is the main calendar widget. It provides the different vies on t he 74 This is the main calendar widget. It provides the different vies on t he
75 calendar data as well as the date navigator. It also handles synchronisation 75 calendar data as well as the date navigator. It also handles synchronisation
76 of the different views and controls the different dialogs like preferences, 76 of the different views and controls the different dialogs like preferences,
77 event editor, search dialog etc. 77 event editor, search dialog etc.
78 78
79 @short main calendar view widget 79 @short main calendar view widget
80 @author Cornelius Schumacher 80 @author Cornelius Schumacher
81*/ 81*/
82class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface 82class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface
83{ 83{
84 Q_OBJECT 84 Q_OBJECT
85 public: 85 public:
86 /** 86 /**
87 Constructs a new calendar view widget. 87 Constructs a new calendar view widget.
88 88
89 @param calendar calendar document 89 @param calendar calendar document
90 @param parent parent window 90 @param parent parent window
91 @param name Qt internal widget object name 91 @param name Qt internal widget object name
92 */ 92 */
93 CalendarView( CalendarResources *calendar, QWidget *parent = 0, 93 CalendarView( CalendarResources *calendar, QWidget *parent = 0,
94 const char *name = 0 ); 94 const char *name = 0 );
95 CalendarView( Calendar *calendar, QWidget *parent = 0, 95 CalendarView( Calendar *calendar, QWidget *parent = 0,
96 const char *name = 0 ); 96 const char *name = 0 );
97 virtual ~CalendarView(); 97 virtual ~CalendarView();
98 98
99 Calendar *calendar() { return mCalendar; } 99 Calendar *calendar() { return mCalendar; }
100 100
101 KOViewManager *viewManager(); 101 KOViewManager *viewManager();
102 KODialogManager *dialogManager(); 102 KODialogManager *dialogManager();
103 103
104 QDate startDate(); 104 QDate startDate();
105 QDate endDate(); 105 QDate endDate();
106 106
107 QWidgetStack *viewStack(); 107 QWidgetStack *viewStack();
108 QWidget *leftFrame(); 108 QWidget *leftFrame();
109 NavigatorBar *navigatorBar(); 109 NavigatorBar *navigatorBar();
110 110
111 DateNavigator *dateNavigator(); 111 DateNavigator *dateNavigator();
112 KDateNavigator *dateNavigatorWidget(); 112 KDateNavigator *dateNavigatorWidget();
113 113
114 void addView(KOrg::BaseView *); 114 void addView(KOrg::BaseView *);
115 void showView(KOrg::BaseView *); 115 void showView(KOrg::BaseView *);
116 KOEventViewerDialog* getEventViewerDialog(); 116 KOEventViewerDialog* getEventViewerDialog();
117 Incidence *currentSelection(); 117 Incidence *currentSelection();
118 118
119 signals: 119 signals:
120 /** This todo has been modified */ 120 /** This todo has been modified */
121 void todoModified(Todo *, int); 121 void todoModified(Todo *, int);
122 122
123 /** when change is made to options dialog, the topwidget will catch this 123 /** when change is made to options dialog, the topwidget will catch this
124 * and emit this signal which notifies all widgets which have registered 124 * and emit this signal which notifies all widgets which have registered
125 * for notification to update their settings. */ 125 * for notification to update their settings. */
126 void configChanged(); 126 void configChanged();
127 /** emitted when the topwidget is closing down, so that any attached 127 /** emitted when the topwidget is closing down, so that any attached
128 child windows can also close. */ 128 child windows can also close. */
129 void closingDown(); 129 void closingDown();
130 /** emitted right before we die */ 130 /** emitted right before we die */
131 void closed(QWidget *); 131 void closed(QWidget *);
132 132
133 /** Emitted when state of modified flag changes */ 133 /** Emitted when state of modified flag changes */
134 void modifiedChanged(bool); 134 void modifiedChanged(bool);
135 void signalmodified(); 135 void signalmodified();
136 136
137 /** Emitted when state of read-only flag changes */ 137 /** Emitted when state of read-only flag changes */
138 void readOnlyChanged(bool); 138 void readOnlyChanged(bool);
139 139
140 /** Emitted when the unit of navigation changes */ 140 /** Emitted when the unit of navigation changes */
141 void changeNavStringPrev(const QString &); 141 void changeNavStringPrev(const QString &);
142 void changeNavStringNext(const QString &); 142 void changeNavStringNext(const QString &);
143 143
144 /** Emitted when state of events selection has changed and user is organizer*/ 144 /** Emitted when state of events selection has changed and user is organizer*/
145 void organizerEventsSelected(bool); 145 void organizerEventsSelected(bool);
146 /** Emitted when state of events selection has changed and user is attendee*/ 146 /** Emitted when state of events selection has changed and user is attendee*/
147 void groupEventsSelected(bool); 147 void groupEventsSelected(bool);
148 /** 148 /**
149 Emitted when an incidence gets selected. If the selection is cleared the 149 Emitted when an incidence gets selected. If the selection is cleared the
150 signal is emitted with 0 as argument. 150 signal is emitted with 0 as argument.
151 */ 151 */
152 void incidenceSelected( Incidence * ); 152 void incidenceSelected( Incidence * );
153 /** Emitted, when a todoitem is selected or deselected. */ 153 /** Emitted, when a todoitem is selected or deselected. */
154 void todoSelected( bool ); 154 void todoSelected( bool );
155 155
156 /** 156 /**
157 Emitted, when clipboard content changes. Parameter indicates if paste 157 Emitted, when clipboard content changes. Parameter indicates if paste
158 is possible or not. 158 is possible or not.
159 */ 159 */
160 void pasteEnabled(bool); 160 void pasteEnabled(bool);
161 161
162 /** Emitted, when the number of incoming messages has changed. */ 162 /** Emitted, when the number of incoming messages has changed. */
163 void numIncomingChanged(int); 163 void numIncomingChanged(int);
164 164
165 /** Emitted, when the number of outgoing messages has changed. */ 165 /** Emitted, when the number of outgoing messages has changed. */
166 void numOutgoingChanged(int); 166 void numOutgoingChanged(int);
167 167
168 /** Send status message, which can e.g. be displayed in the status bar. */ 168 /** Send status message, which can e.g. be displayed in the status bar. */
169 void statusMessage(const QString &); 169 void statusMessage(const QString &);
170 170
171 void calendarViewExpanded( bool ); 171 void calendarViewExpanded( bool );
172 void updateSearchDialog(); 172 void updateSearchDialog();
173 173
174 174
175 public slots: 175 public slots:
176 void showOpenError(); 176 void showOpenError();
177 void watchSavedFile(); 177 void watchSavedFile();
178 void recheckTimerAlarm(); 178 void recheckTimerAlarm();
179 void checkNextTimerAlarm(); 179 void checkNextTimerAlarm();
180 void addAlarm(const QDateTime &qdt, const QString &noti ); 180 void addAlarm(const QDateTime &qdt, const QString &noti );
181 void addSuspendAlarm(const QDateTime &qdt, const QString &noti ); 181 void addSuspendAlarm(const QDateTime &qdt, const QString &noti );
182 void removeAlarm(const QDateTime &qdt, const QString &noti ); 182 void removeAlarm(const QDateTime &qdt, const QString &noti );
183 183
184 /** options dialog made a changed to the configuration. we catch this 184 /** options dialog made a changed to the configuration. we catch this
185 * and notify all widgets which need to update their configuration. */ 185 * and notify all widgets which need to update their configuration. */
186 void updateConfig(); 186 void updateConfig();
187 187
188 void insertBirthdays(const QString& uid, const QStringList& birthdayList, 188 void insertBirthdays(const QString& uid, const QStringList& birthdayList,
189 const QStringList& anniversaryList, const QStringList& realNameList, 189 const QStringList& anniversaryList, const QStringList& realNameList,
190 const QStringList& emailList, const QStringList& assembledNameList, 190 const QStringList& emailList, const QStringList& assembledNameList,
191 const QStringList& uidList); 191 const QStringList& uidList);
192 192
193 /** 193 /**
194 Load calendar from file \a filename. If \a merge is true, load 194 Load calendar from file \a filename. If \a merge is true, load
195 calendar into existing one, if it is false, clear calendar, before 195 calendar into existing one, if it is false, clear calendar, before
196 loading. Return true, if calendar could be successfully loaded. 196 loading. Return true, if calendar could be successfully loaded.
197 */ 197 */
198 bool openCalendar(QString filename, bool merge=false); 198 bool openCalendar(QString filename, bool merge=false);
199 bool syncCalendar(QString filename,int mode = 0 ); 199 bool syncCalendar(QString filename,int mode = 0 );
200 200
201 /** 201 /**
202 Save calendar data to file. Return true if calendar could be 202 Save calendar data to file. Return true if calendar could be
203 successfully saved. 203 successfully saved.
204 */ 204 */
205 bool saveCalendar(QString filename); 205 bool saveCalendar(QString filename);
206 206
207 /** 207 /**
208 Close calendar. Clear calendar data and reset views to display an empty 208 Close calendar. Clear calendar data and reset views to display an empty
209 calendar. 209 calendar.
210 */ 210 */
211 void closeCalendar(); 211 void closeCalendar();
212 212
213 /** Archive old events of calendar */ 213 /** Archive old events of calendar */
214 void archiveCalendar(); 214 void archiveCalendar();
215 215
216 void showIncidence(); 216 void showIncidence();
217 void editIncidence(); 217 void editIncidence();
218 void editIncidenceDescription(); 218 void editIncidenceDescription();
219 void deleteIncidence(); 219 void deleteIncidence();
220 void cloneIncidence(); 220 void cloneIncidence();
221 void moveIncidence(); 221 void moveIncidence();
222 void beamIncidence(); 222 void beamIncidence();
223 void toggleCancelIncidence(); 223 void toggleCancelIncidence();
224 224
225 /** create an editeventwin with supplied date/time, and if bool is true, 225 /** create an editeventwin with supplied date/time, and if bool is true,
226 * make the event take all day. */ 226 * make the event take all day. */
227 void newEvent(QDateTime, QDateTime, bool allDay = false); 227 void newEvent(QDateTime, QDateTime, bool allDay = false);
228 void newEvent(QDateTime fh); 228 void newEvent(QDateTime fh);
229 void newEvent(QDate dt); 229 void newEvent(QDate dt);
230 /** create new event without having a date hint. Takes current date as 230 /** create new event without having a date hint. Takes current date as
231 default hint. */ 231 default hint. */
232 void newEvent(); 232 void newEvent();
233 void newFloatingEvent(); 233 void newFloatingEvent();
234 234
235 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ 235 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/
236 void showIncidence(Incidence *); 236 void showIncidence(Incidence *);
237 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ 237 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/
238 void editIncidence(Incidence *); 238 void editIncidence(Incidence *);
239 /** Delete the supplied incidence. It calls the correct deleteXXX method*/ 239 /** Delete the supplied incidence. It calls the correct deleteXXX method*/
240 void deleteIncidence(Incidence *); 240 void deleteIncidence(Incidence *);
241 void cloneIncidence(Incidence *); 241 void cloneIncidence(Incidence *);
242 void cancelIncidence(Incidence *); 242 void cancelIncidence(Incidence *);
243 /** Create an editor for the supplied event. */ 243 /** Create an editor for the supplied event. */
244 void editEvent(Event *); 244 void editEvent(Event *);
245 /** Delete the supplied event. */ 245 /** Delete the supplied event. */
246 void deleteEvent(Event *); 246 void deleteEvent(Event *);
247 /** Delete the event with the given unique ID. Returns false, if event wasn't 247 /** Delete the event with the given unique ID. Returns false, if event wasn't
248 found. */ 248 found. */
249 bool deleteEvent(const QString &uid); 249 bool deleteEvent(const QString &uid);
250 /** Create a read-only viewer dialog for the supplied event. */ 250 /** Create a read-only viewer dialog for the supplied event. */
251 void showEvent(Event *); 251 void showEvent(Event *);
252 252
253 void editJournal(Journal *); 253 void editJournal(Journal *);
254 void showJournal(Journal *); 254 void showJournal(Journal *);
255 void deleteJournal(Journal *); 255 void deleteJournal(Journal *);
256 /** Create an editor dialog for a todo */ 256 /** Create an editor dialog for a todo */
257 void editTodo(Todo *); 257 void editTodo(Todo *);
258 /** Create a read-only viewer dialog for the supplied todo */ 258 /** Create a read-only viewer dialog for the supplied todo */
259 void showTodo(Todo *); 259 void showTodo(Todo *);
260 /** create new todo */ 260 /** create new todo */
261 void newTodo(); 261 void newTodo();
262 /** create new todo with a parent todo */ 262 /** create new todo with a parent todo */
263 void newSubTodo(); 263 void newSubTodo();
264 /** create new todo with a parent todo */ 264 /** create new todo with a parent todo */
265 void newSubTodo(Todo *); 265 void newSubTodo(Todo *);
266 /** Delete todo */ 266 /** Delete todo */
267 void deleteTodo(Todo *); 267 void deleteTodo(Todo *);
268 268
269 269
270 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is 270 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is
271 * emitted as result. */ 271 * emitted as result. */
272 void checkClipboard(); 272 void checkClipboard();
273 273
274 /** using the KConfig associated with the kapp variable, read in the 274 /** using the KConfig associated with the kapp variable, read in the
275 * settings from the config file. 275 * settings from the config file.
276 */ 276 */
277 void readSettings(); 277 void readSettings();
278 278
279 /** write current state to config file. */ 279 /** write current state to config file. */
280 void writeSettings(); 280 void writeSettings();
281 281
282 /** read settings for calendar filters */ 282 /** read settings for calendar filters */
283 void readFilterSettings(KConfig *config); 283 void readFilterSettings(KConfig *config);
284 284
285 /** write settings for calendar filters */ 285 /** write settings for calendar filters */
286 void writeFilterSettings(KConfig *config); 286 void writeFilterSettings(KConfig *config);
287 287
288 /** passes on the message that an event has changed to the currently 288 /** passes on the message that an event has changed to the currently
289 * activated view so that it can make appropriate display changes. */ 289 * activated view so that it can make appropriate display changes. */
290 void changeEventDisplay(Event *, int); 290 void changeEventDisplay(Event *, int);
291 void changeIncidenceDisplay(Incidence *, int); 291 void changeIncidenceDisplay(Incidence *, int);
292 void changeTodoDisplay(Todo *, int); 292 void changeTodoDisplay(Todo *, int);
293 293
294 void eventAdded(Event *); 294 void eventAdded(Event *);
295 void eventChanged(Event *); 295 void eventChanged(Event *);
296 void eventToBeDeleted(Event *); 296 void eventToBeDeleted(Event *);
297 void eventDeleted(); 297 void eventDeleted();
298 298
299 void todoAdded(Todo *); 299 void todoAdded(Todo *);
300 void todoChanged(Todo *); 300 void todoChanged(Todo *);
301 void todoToBeDeleted(Todo *); 301 void todoToBeDeleted(Todo *);
302 void todoDeleted(); 302 void todoDeleted();
303 303
304 void updateView(const QDate &start, const QDate &end); 304 void updateView(const QDate &start, const QDate &end);
305 void updateView(); 305 void updateView();
306 306
307 /** Full update of visible todo views */ 307 /** Full update of visible todo views */
308 void updateTodoViews(); 308 void updateTodoViews();
309 309
310 void updateUnmanagedViews(); 310 void updateUnmanagedViews();
311 311
312 /** cut the current appointment to the clipboard */ 312 /** cut the current appointment to the clipboard */
313 void edit_cut(); 313 void edit_cut();
314 314
315 /** copy the current appointment(s) to the clipboard */ 315 /** copy the current appointment(s) to the clipboard */
316 void edit_copy(); 316 void edit_copy();
317 317
318 /** paste the current vobject(s) in the clipboard buffer into calendar */ 318 /** paste the current vobject(s) in the clipboard buffer into calendar */
319 void edit_paste(); 319 void edit_paste();
320 320
321 /** edit viewing and configuration options. */ 321 /** edit viewing and configuration options. */
322 void edit_options(); 322 void edit_options();
323 void edit_sync_options();
324 /** 323 /**
325 Functions for printing, previewing a print, and setting up printing 324 Functions for printing, previewing a print, and setting up printing
326 parameters. 325 parameters.
327 */ 326 */
328 void print(); 327 void print();
329 void printSetup(); 328 void printSetup();
330 void printPreview(); 329 void printPreview();
331 330
332 /** Export as iCalendar file */ 331 /** Export as iCalendar file */
333 void exportICalendar(); 332 void exportICalendar();
334 333
335 /** Export as vCalendar file */ 334 /** Export as vCalendar file */
336 bool exportVCalendar( QString fn); 335 bool exportVCalendar( QString fn);
337 336
338 /** pop up a dialog to show an existing appointment. */ 337 /** pop up a dialog to show an existing appointment. */
339 void appointment_show(); 338 void appointment_show();
340 /** 339 /**
341 * pop up an Appointment Dialog to edit an existing appointment.Get 340 * pop up an Appointment Dialog to edit an existing appointment.Get
342 * information on the appointment from the list of unique IDs that is 341 * information on the appointment from the list of unique IDs that is
343 * currently in the View, called currIds. 342 * currently in the View, called currIds.
344 */ 343 */
345 void appointment_edit(); 344 void appointment_edit();
346 /** 345 /**
347 * pop up dialog confirming deletion of currently selected event in the 346 * pop up dialog confirming deletion of currently selected event in the
348 * View. 347 * View.
349 */ 348 */
350 void appointment_delete(); 349 void appointment_delete();
351 350
352 /** mails the currently selected event to a particular user as a vCalendar 351 /** mails the currently selected event to a particular user as a vCalendar
353 attachment. */ 352 attachment. */
354 void action_mail(); 353 void action_mail();
355 354
356 /* frees a subtodo from it's relation */ 355 /* frees a subtodo from it's relation */
357 void todo_unsub( Todo * ); 356 void todo_unsub( Todo * );
358 357
359 /** Take ownership of selected event. */ 358 /** Take ownership of selected event. */
360 void takeOverEvent(); 359 void takeOverEvent();
361 360
362 /** Take ownership of all events in calendar. */ 361 /** Take ownership of all events in calendar. */
363 void takeOverCalendar(); 362 void takeOverCalendar();
364 363
365 /** query whether or not the calendar is "dirty". */ 364 /** query whether or not the calendar is "dirty". */
366 bool isModified(); 365 bool isModified();
367 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ 366 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */
368 void setModified(bool modified=true); 367 void setModified(bool modified=true);
369 368
370 /** query if the calendar is read-only. */ 369 /** query if the calendar is read-only. */
371 bool isReadOnly(); 370 bool isReadOnly();
372 /** set state of calendar to read-only */ 371 /** set state of calendar to read-only */
373 void setReadOnly(bool readOnly=true); 372 void setReadOnly(bool readOnly=true);
374 373
375 void eventUpdated(Incidence *); 374 void eventUpdated(Incidence *);
376 375
377 /* iTIP scheduling actions */ 376 /* iTIP scheduling actions */
378 void schedule_publish(Incidence *incidence = 0); 377 void schedule_publish(Incidence *incidence = 0);
379 void schedule_request(Incidence *incidence = 0); 378 void schedule_request(Incidence *incidence = 0);
380 void schedule_refresh(Incidence *incidence = 0); 379 void schedule_refresh(Incidence *incidence = 0);
381 void schedule_cancel(Incidence *incidence = 0); 380 void schedule_cancel(Incidence *incidence = 0);
382 void schedule_add(Incidence *incidence = 0); 381 void schedule_add(Incidence *incidence = 0);
383 void schedule_reply(Incidence *incidence = 0); 382 void schedule_reply(Incidence *incidence = 0);
384 void schedule_counter(Incidence *incidence = 0); 383 void schedule_counter(Incidence *incidence = 0);
385 void schedule_declinecounter(Incidence *incidence = 0); 384 void schedule_declinecounter(Incidence *incidence = 0);
386 void schedule_publish_freebusy(int daysToPublish = 30); 385 void schedule_publish_freebusy(int daysToPublish = 30);
387 386
388 void openAddressbook(); 387 void openAddressbook();
389 388
390 void editFilters(); 389 void editFilters();
391 void toggleFilerEnabled(); 390 void toggleFilerEnabled();
392 QPtrList<CalFilter> filters(); 391 QPtrList<CalFilter> filters();
393 void toggleFilter(); 392 void toggleFilter();
394 void showFilter(bool visible); 393 void showFilter(bool visible);
395 void updateFilter(); 394 void updateFilter();
396 void filterEdited(); 395 void filterEdited();
397 void selectFilter( int ); 396 void selectFilter( int );
398 KOFilterView *filterView(); 397 KOFilterView *filterView();
399 398
400 void showIntro(); 399 void showIntro();
401 400
402 /** Move the curdatepient view date to today */ 401 /** Move the curdatepient view date to today */
403 void goToday(); 402 void goToday();
404 403
405 /** Move to the next date(s) in the current view */ 404 /** Move to the next date(s) in the current view */
406 void goNext(); 405 void goNext();
407 406
408 /** Move to the previous date(s) in the current view */ 407 /** Move to the previous date(s) in the current view */
409 void goPrevious(); 408 void goPrevious();
410 /** Move to the next date(s) in the current view */ 409 /** Move to the next date(s) in the current view */
411 void goNextMonth(); 410 void goNextMonth();
412 411
413 /** Move to the previous date(s) in the current view */ 412 /** Move to the previous date(s) in the current view */
414 void goPreviousMonth(); 413 void goPreviousMonth();
415 414
416 void toggleExpand(); 415 void toggleExpand();
417 void toggleDateNavigatorWidget(); 416 void toggleDateNavigatorWidget();
418 void toggleAllDaySize(); 417 void toggleAllDaySize();
419 void dialogClosing(Incidence *); 418 void dialogClosing(Incidence *);
420 419
421 /** Look for new messages in the inbox */ 420 /** Look for new messages in the inbox */
422 void lookForIncomingMessages(); 421 void lookForIncomingMessages();
423 /** Look for new messages in the outbox */ 422 /** Look for new messages in the outbox */
424 void lookForOutgoingMessages(); 423 void lookForOutgoingMessages();
425 424
426 void processMainViewSelection( Incidence * ); 425 void processMainViewSelection( Incidence * );
427 void processTodoListSelection( Incidence * ); 426 void processTodoListSelection( Incidence * );
428 427
429 void processIncidenceSelection( Incidence * ); 428 void processIncidenceSelection( Incidence * );
430 429
431 void purgeCompleted(); 430 void purgeCompleted();
432 bool removeCompletedSubTodos( Todo* ); 431 bool removeCompletedSubTodos( Todo* );
433 void slotCalendarChanged(); 432 void slotCalendarChanged();
434 bool importBday(); 433 bool importBday();
435 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); 434 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday );
436 bool importQtopia( const QString &categoriesFile, 435 bool importQtopia( const QString &categoriesFile,
437 const QString &datebookFile, 436 const QString &datebookFile,
438 const QString &tasklistFile ); 437 const QString &tasklistFile );
439 void syncSharp( );
440 void syncPhone( );
441 void syncExternal( int mode ); 438 void syncExternal( int mode );
442 void slotSelectPickerDate( QDate ) ; 439 void slotSelectPickerDate( QDate ) ;
443 void showDatePicker( ) ; 440 void showDatePicker( ) ;
444 void moveIncidence(Incidence *) ; 441 void moveIncidence(Incidence *) ;
445 void beamIncidence(Incidence *) ; 442 void beamIncidence(Incidence *) ;
446 void beamCalendar() ; 443 void beamCalendar() ;
447 void beamFilteredCalendar() ; 444 void beamFilteredCalendar() ;
448 void beamIncidenceList(QPtrList<Incidence>) ; 445 void beamIncidenceList(QPtrList<Incidence>) ;
449 void manageCategories(); 446 void manageCategories();
450 int addCategories(); 447 int addCategories();
451 void removeCategories(); 448 void removeCategories();
452 void setSyncDevice( QString ); 449 void setSyncDevice( QString );
453 void setSyncName( QString ); 450 void setSyncName( QString );
454 protected slots: 451 protected slots:
455 void timerAlarm(); 452 void timerAlarm();
456 void suspendAlarm(); 453 void suspendAlarm();
457 void beamDone( Ir *ir ); 454 void beamDone( Ir *ir );
458 /** Select a view or adapt the current view to display the specified dates. */ 455 /** Select a view or adapt the current view to display the specified dates. */
459 void showDates( const KCal::DateList & ); 456 void showDates( const KCal::DateList & );
460 void selectWeekNum ( int ); 457 void selectWeekNum ( int );
461 458
462 public: 459 public:
463 // show a standard warning 460 // show a standard warning
464 // returns KMsgBox::yesNoCancel() 461 // returns KMsgBox::yesNoCancel()
465 int msgCalModified(); 462 int msgCalModified();
466 virtual bool sync(KSyncManager* manager, QString filename, int mode); 463 virtual bool sync(KSyncManager* manager, QString filename, int mode);
467 464
468 virtual bool syncExternal(KSyncManager* manager, QString resource); 465 virtual bool syncExternal(KSyncManager* manager, QString resource);
469 void confSync();
470 void setSyncManager(KSyncManager* manager); 466 void setSyncManager(KSyncManager* manager);
471 void setLoadedFileVersion(QDateTime); 467 void setLoadedFileVersion(QDateTime);
472 bool checkFileVersion(QString fn); 468 bool checkFileVersion(QString fn);
473 bool checkFileChanged(QString fn); 469 bool checkFileChanged(QString fn);
474 Event* getLastSyncEvent(); 470 Event* getLastSyncEvent();
475 /** Adapt navigation units correpsonding to step size of navigation of the 471 /** Adapt navigation units correpsonding to step size of navigation of the
476 * current view. 472 * current view.
477 */ 473 */
478 void adaptNavigationUnits(); 474 void adaptNavigationUnits();
479 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); 475 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode );
480 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); 476 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false );
481 //Attendee* getYourAttendee(Event *event); 477 //Attendee* getYourAttendee(Event *event);
482 protected: 478 protected:
483 void schedule(Scheduler::Method, Incidence *incidence = 0); 479 void schedule(Scheduler::Method, Incidence *incidence = 0);
484 480
485 // returns KMsgBox::OKCandel() 481 // returns KMsgBox::OKCandel()
486 int msgItemDelete(); 482 int msgItemDelete();
487 void showEventEditor(); 483 void showEventEditor();
488 void showTodoEditor(); 484 void showTodoEditor();
489 void writeLocale(); 485 void writeLocale();
490 Todo *selectedTodo(); 486 Todo *selectedTodo();
491 487
492 private: 488 private:
493 KSyncManager* mSyncManager; 489 KSyncManager* mSyncManager;
494 AlarmDialog * mAlarmDialog; 490 AlarmDialog * mAlarmDialog;
495 QString mAlarmNotification; 491 QString mAlarmNotification;
496 QString mSuspendAlarmNotification; 492 QString mSuspendAlarmNotification;
497 QTimer* mSuspendTimer; 493 QTimer* mSuspendTimer;
498 QTimer* mAlarmTimer; 494 QTimer* mAlarmTimer;
499 QTimer* mRecheckAlarmTimer; 495 QTimer* mRecheckAlarmTimer;
500 void computeAlarm( QString ); 496 void computeAlarm( QString );
501 void startAlarm( QString, QString ); 497 void startAlarm( QString, QString );
502 void setSyncEventsReadOnly(); 498 void setSyncEventsReadOnly();
503 499
504 QDateTime loadedFileVersion; 500 QDateTime loadedFileVersion;
505 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); 501 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete );
506 void checkExternalId( Incidence * inc ); 502 void checkExternalId( Incidence * inc );
507 int mGlobalSyncMode; 503 int mGlobalSyncMode;
508 QString mCurrentSyncDevice; 504 QString mCurrentSyncDevice;
509 QString mCurrentSyncName; 505 QString mCurrentSyncName;
510 KOBeamPrefs* beamDialog; 506 KOBeamPrefs* beamDialog;
511 void init(); 507 void init();
512 int mDatePickerMode; 508 int mDatePickerMode;
513 bool mFlagEditDescription; 509 bool mFlagEditDescription;
514 QDateTime mLastCalendarSync; 510 QDateTime mLastCalendarSync;
515 void createPrinter(); 511 void createPrinter();
516 512
517 void calendarModified( bool, Calendar * ); 513 void calendarModified( bool, Calendar * );
518 514
519 CalPrinter *mCalPrinter; 515 CalPrinter *mCalPrinter;
520 516
521 QSplitter *mPanner; 517 QSplitter *mPanner;
522 QSplitter *mLeftSplitter; 518 QSplitter *mLeftSplitter;
523 QWidget *mLeftFrame; 519 QWidget *mLeftFrame;
524 QWidgetStack *mRightFrame; 520 QWidgetStack *mRightFrame;
525 521
526 KDatePicker* mDatePicker; 522 KDatePicker* mDatePicker;
527 QVBox* mDateFrame; 523 QVBox* mDateFrame;
528 NavigatorBar *mNavigatorBar; 524 NavigatorBar *mNavigatorBar;
529 525
530 KDateNavigator *mDateNavigator; // widget showing small month view. 526 KDateNavigator *mDateNavigator; // widget showing small month view.
531 527
532 KOFilterView *mFilterView; 528 KOFilterView *mFilterView;
533 529
534 ResourceView *mResourceView; 530 ResourceView *mResourceView;
535 531
536 // calendar object for this viewing instance 532 // calendar object for this viewing instance
537 Calendar *mCalendar; 533 Calendar *mCalendar;
538 534
539 CalendarResourceManager *mResourceManager; 535 CalendarResourceManager *mResourceManager;
540 536
541 FileStorage *mStorage; 537 FileStorage *mStorage;
542 538
543 DateNavigator *mNavigator; 539 DateNavigator *mNavigator;
544 540
545 KOViewManager *mViewManager; 541 KOViewManager *mViewManager;
546 KODialogManager *mDialogManager; 542 KODialogManager *mDialogManager;
547 543
548 // Calendar filters 544 // Calendar filters
549 QPtrList<CalFilter> mFilters; 545 QPtrList<CalFilter> mFilters;
550 546
551 // various housekeeping variables. 547 // various housekeeping variables.
552 bool mModified; // flag indicating if calendar is modified 548 bool mModified; // flag indicating if calendar is modified
553 bool mReadOnly; // flag indicating if calendar is read-only 549 bool mReadOnly; // flag indicating if calendar is read-only
554 QDate mSaveSingleDate; 550 QDate mSaveSingleDate;
555 551
556 Incidence *mSelectedIncidence; 552 Incidence *mSelectedIncidence;
557 Incidence *mMoveIncidence; 553 Incidence *mMoveIncidence;
558 KOTodoView *mTodoList; 554 KOTodoView *mTodoList;
559 KOEventEditor * mEventEditor; 555 KOEventEditor * mEventEditor;
560 KOTodoEditor * mTodoEditor; 556 KOTodoEditor * mTodoEditor;
561 KOEventViewerDialog * mEventViewerDialog; 557 KOEventViewerDialog * mEventViewerDialog;
562 void keyPressEvent ( QKeyEvent *e) ; 558 void keyPressEvent ( QKeyEvent *e) ;
563 //QMap<Incidence*,KOIncidenceEditor*> mDialogList; 559 //QMap<Incidence*,KOIncidenceEditor*> mDialogList;
564}; 560};
565 561
566 562
567class CalendarViewVisitor : public Incidence::Visitor 563class CalendarViewVisitor : public Incidence::Visitor
568{ 564{
569 public: 565 public:
570 CalendarViewVisitor() : mView( 0 ) {} 566 CalendarViewVisitor() : mView( 0 ) {}
571 567
572 bool act( Incidence *incidence, CalendarView *view ) 568 bool act( Incidence *incidence, CalendarView *view )
573 { 569 {
574 mView = view; 570 mView = view;
575 return incidence->accept( *this ); 571 return incidence->accept( *this );
576 } 572 }
577 573
578 protected: 574 protected:
579 CalendarView *mView; 575 CalendarView *mView;
580}; 576};
581 577
582class ShowIncidenceVisitor : public CalendarViewVisitor 578class ShowIncidenceVisitor : public CalendarViewVisitor
583{ 579{
584 protected: 580 protected:
585 bool visit( Event *event ) { mView->showEvent( event ); return true; } 581 bool visit( Event *event ) { mView->showEvent( event ); return true; }
586 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } 582 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; }
587 bool visit( Journal * j ) { mView->showJournal( j );return true; } 583 bool visit( Journal * j ) { mView->showJournal( j );return true; }
588}; 584};
589 585
590class EditIncidenceVisitor : public CalendarViewVisitor 586class EditIncidenceVisitor : public CalendarViewVisitor
591{ 587{
592 protected: 588 protected:
593 bool visit( Event *event ) { mView->editEvent( event ); return true; } 589 bool visit( Event *event ) { mView->editEvent( event ); return true; }
594 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } 590 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; }
595 bool visit( Journal *j ) { mView->editJournal( j); return true; } 591 bool visit( Journal *j ) { mView->editJournal( j); return true; }
596}; 592};
597 593
598class DeleteIncidenceVisitor : public CalendarViewVisitor 594class DeleteIncidenceVisitor : public CalendarViewVisitor
599{ 595{
600 protected: 596 protected:
601 bool visit( Event *event ) { mView->deleteEvent( event ); return true; } 597 bool visit( Event *event ) { mView->deleteEvent( event ); return true; }
602 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } 598 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; }
603 bool visit( Journal * j) {mView->deleteJournal( j ); return true; } 599 bool visit( Journal * j) {mView->deleteJournal( j ); return true; }
604}; 600};
605 601
606#endif 602#endif
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index c7ce8cb..2d17986 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1,1839 +1,1835 @@
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 <qpushbutton.h> 7#include <qpushbutton.h>
8#include <qmessagebox.h> 8#include <qmessagebox.h>
9#include <qlineedit.h> 9#include <qlineedit.h>
10#include <qtextcodec.h> 10#include <qtextcodec.h>
11#include <qfile.h> 11#include <qfile.h>
12#include <qdir.h> 12#include <qdir.h>
13#include <qapp.h> 13#include <qapp.h>
14#include <qfileinfo.h> 14#include <qfileinfo.h>
15#include <qlabel.h> 15#include <qlabel.h>
16#include <qspinbox.h> 16#include <qspinbox.h>
17#include <qcheckbox.h> 17#include <qcheckbox.h>
18#include <qmap.h> 18#include <qmap.h>
19#include <qwmatrix.h> 19#include <qwmatrix.h>
20#include <qtextbrowser.h> 20#include <qtextbrowser.h>
21#include <qtextstream.h> 21#include <qtextstream.h>
22#ifndef DESKTOP_VERSION 22#ifndef DESKTOP_VERSION
23#include <qpe/global.h> 23#include <qpe/global.h>
24#include <qpe/qpemenubar.h> 24#include <qpe/qpemenubar.h>
25#include <qpe/qpetoolbar.h> 25#include <qpe/qpetoolbar.h>
26#include <qpe/resource.h> 26#include <qpe/resource.h>
27#include <qpe/qpeapplication.h> 27#include <qpe/qpeapplication.h>
28#include <qtopia/alarmserver.h> 28#include <qtopia/alarmserver.h>
29#include <qtopia/qcopenvelope_qws.h> 29#include <qtopia/qcopenvelope_qws.h>
30#include <unistd.h> // for sleep 30#include <unistd.h> // for sleep
31#else 31#else
32#include <qmenubar.h> 32#include <qmenubar.h>
33#include <qtoolbar.h> 33#include <qtoolbar.h>
34#include <qapplication.h> 34#include <qapplication.h>
35//#include <resource.h> 35//#include <resource.h>
36 36
37#endif 37#endif
38#include <libkcal/calendarlocal.h> 38#include <libkcal/calendarlocal.h>
39#include <libkcal/todo.h> 39#include <libkcal/todo.h>
40#include <libkcal/phoneformat.h> 40#include <libkcal/phoneformat.h>
41#include <libkdepim/ksyncprofile.h> 41#include <libkdepim/ksyncprofile.h>
42#include <libkdepim/phoneaccess.h> 42#include <libkdepim/phoneaccess.h>
43#include <libkcal/kincidenceformatter.h> 43#include <libkcal/kincidenceformatter.h>
44#include <libkdepim/kpimglobalprefs.h> 44#include <libkdepim/kpimglobalprefs.h>
45 45
46#include "calendarview.h" 46#include "calendarview.h"
47#include "koviewmanager.h" 47#include "koviewmanager.h"
48#include "datenavigator.h" 48#include "datenavigator.h"
49#include "koagendaview.h" 49#include "koagendaview.h"
50#include "koagenda.h" 50#include "koagenda.h"
51#include "kodialogmanager.h" 51#include "kodialogmanager.h"
52#include "kdialogbase.h" 52#include "kdialogbase.h"
53#include "kapplication.h" 53#include "kapplication.h"
54#include "kofilterview.h" 54#include "kofilterview.h"
55#include "kstandarddirs.h" 55#include "kstandarddirs.h"
56#include "koprefs.h" 56#include "koprefs.h"
57#include "kfiledialog.h" 57#include "kfiledialog.h"
58#include "koglobals.h" 58#include "koglobals.h"
59#include "kglobal.h" 59#include "kglobal.h"
60#include "klocale.h" 60#include "klocale.h"
61#include "kconfig.h" 61#include "kconfig.h"
62#include "simplealarmclient.h" 62#include "simplealarmclient.h"
63#include "externalapphandler.h" 63#include "externalapphandler.h"
64 64
65using namespace KCal; 65using namespace KCal;
66#ifndef _WIN32_ 66#ifndef _WIN32_
67#include <unistd.h> 67#include <unistd.h>
68#else 68#else
69#include "koimportoldialog.h" 69#include "koimportoldialog.h"
70#endif 70#endif
71#include "mainwindow.h" 71#include "mainwindow.h"
72 72
73class KOex2phonePrefs : public QDialog 73class KOex2phonePrefs : public QDialog
74{ 74{
75 public: 75 public:
76 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 76 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
77 QDialog( parent, name, true ) 77 QDialog( parent, name, true )
78 { 78 {
79 setCaption( i18n("Export to phone options") ); 79 setCaption( i18n("Export to phone options") );
80 QVBoxLayout* lay = new QVBoxLayout( this ); 80 QVBoxLayout* lay = new QVBoxLayout( this );
81 lay->setSpacing( 3 ); 81 lay->setSpacing( 3 );
82 lay->setMargin( 3 ); 82 lay->setMargin( 3 );
83 QLabel *lab; 83 QLabel *lab;
84 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 84 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
85 lab->setAlignment (AlignHCenter ); 85 lab->setAlignment (AlignHCenter );
86 QHBox* temphb; 86 QHBox* temphb;
87 temphb = new QHBox( this ); 87 temphb = new QHBox( this );
88 new QLabel( i18n("I/O device: "), temphb ); 88 new QLabel( i18n("I/O device: "), temphb );
89 mPhoneDevice = new QLineEdit( temphb); 89 mPhoneDevice = new QLineEdit( temphb);
90 lay->addWidget( temphb ); 90 lay->addWidget( temphb );
91 temphb = new QHBox( this ); 91 temphb = new QHBox( this );
92 new QLabel( i18n("Connection: "), temphb ); 92 new QLabel( i18n("Connection: "), temphb );
93 mPhoneConnection = new QLineEdit( temphb); 93 mPhoneConnection = new QLineEdit( temphb);
94 lay->addWidget( temphb ); 94 lay->addWidget( temphb );
95 temphb = new QHBox( this ); 95 temphb = new QHBox( this );
96 new QLabel( i18n("Model(opt.): "), temphb ); 96 new QLabel( i18n("Model(opt.): "), temphb );
97 mPhoneModel = new QLineEdit( temphb); 97 mPhoneModel = new QLineEdit( temphb);
98 lay->addWidget( temphb ); 98 lay->addWidget( temphb );
99 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); 99 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this );
100 mWriteBackFuture->setChecked( true ); 100 mWriteBackFuture->setChecked( true );
101 lay->addWidget( mWriteBackFuture ); 101 lay->addWidget( mWriteBackFuture );
102 temphb = new QHBox( this ); 102 temphb = new QHBox( this );
103 new QLabel( i18n("Max. weeks in future: ") , temphb ); 103 new QLabel( i18n("Max. weeks in future: ") , temphb );
104 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); 104 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb);
105 mWriteBackFutureWeeks->setValue( 8 ); 105 mWriteBackFutureWeeks->setValue( 8 );
106 lay->addWidget( temphb ); 106 lay->addWidget( temphb );
107 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); 107 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) );
108 lab->setAlignment (AlignHCenter ); 108 lab->setAlignment (AlignHCenter );
109 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 109 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
110 lay->addWidget( ok ); 110 lay->addWidget( ok );
111 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 111 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
112 lay->addWidget( cancel ); 112 lay->addWidget( cancel );
113 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 113 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
114 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 114 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
115 resize( 220, 240 ); 115 resize( 220, 240 );
116 116
117 } 117 }
118 118
119public: 119public:
120 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 120 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
121 QCheckBox* mWriteBackFuture; 121 QCheckBox* mWriteBackFuture;
122 QSpinBox* mWriteBackFutureWeeks; 122 QSpinBox* mWriteBackFutureWeeks;
123}; 123};
124 124
125int globalFlagBlockStartup; 125int globalFlagBlockStartup;
126MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : 126MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
127 QMainWindow( parent, name ) 127 QMainWindow( parent, name )
128{ 128{
129 129
130#ifdef DESKTOP_VERSION 130#ifdef DESKTOP_VERSION
131 setFont( QFont("Arial"), 14 ); 131 setFont( QFont("Arial"), 14 );
132#endif 132#endif
133 mServerSocket = 0; 133 mServerSocket = 0;
134 mClosed = false; 134 mClosed = false;
135 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; 135 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
136 QString confFile = locateLocal("config","korganizerrc"); 136 QString confFile = locateLocal("config","korganizerrc");
137 QFileInfo finf ( confFile ); 137 QFileInfo finf ( confFile );
138 bool showWarning = !finf.exists(); 138 bool showWarning = !finf.exists();
139 setIcon(SmallIcon( "ko24" ) ); 139 setIcon(SmallIcon( "ko24" ) );
140 mBlockAtStartup = true; 140 mBlockAtStartup = true;
141 mFlagKeyPressed = false; 141 mFlagKeyPressed = false;
142 setCaption("KOrganizer/Pi"); 142 setCaption("KOrganizer/Pi");
143 KOPrefs *p = KOPrefs::instance(); 143 KOPrefs *p = KOPrefs::instance();
144 KPimGlobalPrefs::instance()->setGlobalConfig(); 144 KPimGlobalPrefs::instance()->setGlobalConfig();
145 if ( p->mHourSize > 18 ) 145 if ( p->mHourSize > 18 )
146 p->mHourSize = 18; 146 p->mHourSize = 18;
147 QMainWindow::ToolBarDock tbd; 147 QMainWindow::ToolBarDock tbd;
148 if ( p->mToolBarHor ) { 148 if ( p->mToolBarHor ) {
149 if ( p->mToolBarUp ) 149 if ( p->mToolBarUp )
150 tbd = Bottom; 150 tbd = Bottom;
151 else 151 else
152 tbd = Top; 152 tbd = Top;
153 } 153 }
154 else { 154 else {
155 if ( p->mToolBarUp ) 155 if ( p->mToolBarUp )
156 tbd = Right; 156 tbd = Right;
157 else 157 else
158 tbd = Left; 158 tbd = Left;
159 } 159 }
160 if ( KOPrefs::instance()->mUseAppColors ) 160 if ( KOPrefs::instance()->mUseAppColors )
161 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 161 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
162 globalFlagBlockStartup = 1; 162 globalFlagBlockStartup = 1;
163 iconToolBar = new QPEToolBar( this ); 163 iconToolBar = new QPEToolBar( this );
164 addToolBar (iconToolBar , tbd ); 164 addToolBar (iconToolBar , tbd );
165 mCalendarModifiedFlag = false; 165 mCalendarModifiedFlag = false;
166 166
167 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); 167 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
168 splash->setAlignment ( AlignCenter ); 168 splash->setAlignment ( AlignCenter );
169 setCentralWidget( splash ); 169 setCentralWidget( splash );
170#ifndef DESKTOP_VERSION 170#ifndef DESKTOP_VERSION
171 showMaximized(); 171 showMaximized();
172#endif 172#endif
173 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); 173 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
174 setDefaultPreferences(); 174 setDefaultPreferences();
175 mCalendar = new CalendarLocal(); 175 mCalendar = new CalendarLocal();
176 mView = new CalendarView( mCalendar, this,"mCalendar " ); 176 mView = new CalendarView( mCalendar, this,"mCalendar " );
177 mView->hide(); 177 mView->hide();
178 //mView->resize(splash->size() ); 178 //mView->resize(splash->size() );
179 initActions(); 179 initActions();
180 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); 180 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu);
181 mSyncManager->setBlockSave(false); 181 mSyncManager->setBlockSave(false);
182 mView->setSyncManager(mSyncManager); 182 mView->setSyncManager(mSyncManager);
183#ifndef DESKTOP_VERSION 183#ifndef DESKTOP_VERSION
184 iconToolBar->show(); 184 iconToolBar->show();
185 qApp->processEvents(); 185 qApp->processEvents();
186#endif 186#endif
187 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); 187 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
188 int vh = height() ; 188 int vh = height() ;
189 int vw = width(); 189 int vw = width();
190 //qDebug("Toolbar hei %d ",iconToolBar->height() ); 190 //qDebug("Toolbar hei %d ",iconToolBar->height() );
191 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 191 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
192 vh -= iconToolBar->height(); 192 vh -= iconToolBar->height();
193 } else { 193 } else {
194 vw -= iconToolBar->height(); 194 vw -= iconToolBar->height();
195 } 195 }
196 //mView->setMaximumSize( splash->size() ); 196 //mView->setMaximumSize( splash->size() );
197 //mView->resize( splash->size() ); 197 //mView->resize( splash->size() );
198 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 198 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
199 mView->readSettings(); 199 mView->readSettings();
200 bool newFile = false; 200 bool newFile = false;
201 if( !QFile::exists( defaultFileName() ) ) { 201 if( !QFile::exists( defaultFileName() ) ) {
202 QFileInfo finfo ( defaultFileName() ); 202 QFileInfo finfo ( defaultFileName() );
203 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); 203 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
204 qDebug("oldfile %s ", oldFile.latin1()); 204 qDebug("oldfile %s ", oldFile.latin1());
205 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"; 205 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";
206 finfo.setFile( oldFile ); 206 finfo.setFile( oldFile );
207 if (finfo.exists() ) { 207 if (finfo.exists() ) {
208 KMessageBox::information( this, message); 208 KMessageBox::information( this, message);
209 mView->openCalendar( oldFile ); 209 mView->openCalendar( oldFile );
210 qApp->processEvents(); 210 qApp->processEvents();
211 } else { 211 } else {
212 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); 212 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
213 finfo.setFile( oldFile ); 213 finfo.setFile( oldFile );
214 if (finfo.exists() ) { 214 if (finfo.exists() ) {
215 KMessageBox::information( this, message); 215 KMessageBox::information( this, message);
216 mView->openCalendar( oldFile ); 216 mView->openCalendar( oldFile );
217 qApp->processEvents(); 217 qApp->processEvents();
218 } 218 }
219 } 219 }
220 mView->saveCalendar( defaultFileName() ); 220 mView->saveCalendar( defaultFileName() );
221 newFile = true; 221 newFile = true;
222 } 222 }
223 223
224 QTime neededSaveTime = QDateTime::currentDateTime().time(); 224 QTime neededSaveTime = QDateTime::currentDateTime().time();
225 mView->openCalendar( defaultFileName() ); 225 mView->openCalendar( defaultFileName() );
226 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 226 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
227 qDebug("KO: Calendar loading time: %d ms",msNeeded ); 227 qDebug("KO: Calendar loading time: %d ms",msNeeded );
228 228
229 if ( KOPrefs::instance()->mLanguageChanged ) { 229 if ( KOPrefs::instance()->mLanguageChanged ) {
230 KOPrefs::instance()->setCategoryDefaults(); 230 KOPrefs::instance()->setCategoryDefaults();
231 int count = mView->addCategories(); 231 int count = mView->addCategories();
232 KOPrefs::instance()->mLanguageChanged = false; 232 KOPrefs::instance()->mLanguageChanged = false;
233 } 233 }
234 processIncidenceSelection( 0 ); 234 processIncidenceSelection( 0 );
235 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), 235 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
236 SLOT( processIncidenceSelection( Incidence * ) ) ); 236 SLOT( processIncidenceSelection( Incidence * ) ) );
237 connect( mView, SIGNAL( modifiedChanged( bool ) ), 237 connect( mView, SIGNAL( modifiedChanged( bool ) ),
238 SLOT( slotModifiedChanged( bool ) ) ); 238 SLOT( slotModifiedChanged( bool ) ) );
239 239
240 240
241 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); 241 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
242 mView->setModified( false ); 242 mView->setModified( false );
243 mBlockAtStartup = false; 243 mBlockAtStartup = false;
244 mView->setModified( false ); 244 mView->setModified( false );
245 setCentralWidget( mView ); 245 setCentralWidget( mView );
246 globalFlagBlockStartup = 0; 246 globalFlagBlockStartup = 0;
247 mView->show(); 247 mView->show();
248 delete splash; 248 delete splash;
249 if ( newFile ) 249 if ( newFile )
250 mView->updateConfig(); 250 mView->updateConfig();
251 // qApp->processEvents(); 251 // qApp->processEvents();
252 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 252 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
253 //fillSyncMenu(); 253 //fillSyncMenu();
254 254
255 255
256 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); 256 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) );
257 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 257 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
258 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 258 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
259 mSyncManager->setDefaultFileName( defaultFileName()); 259 mSyncManager->setDefaultFileName( defaultFileName());
260 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); 260 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) );
261 mSyncManager->fillSyncMenu(); 261 mSyncManager->fillSyncMenu();
262 262
263 263
264 264
265 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); 265 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
266 if ( showWarning ) { 266 if ( showWarning ) {
267 KMessageBox::information( this, 267 KMessageBox::information( this,
268 "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"); 268 "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");
269 qApp->processEvents(); 269 qApp->processEvents();
270 mView->dialogManager()->showSyncOptions(); 270 mView->dialogManager()->showSyncOptions();
271 } 271 }
272 272
273 //US listen for result adressed from Ka/Pi 273 //US listen for result adressed from Ka/Pi
274#ifndef DESKTOP_VERSION 274#ifndef DESKTOP_VERSION
275 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 275 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
276#endif 276#endif
277} 277}
278MainWindow::~MainWindow() 278MainWindow::~MainWindow()
279{ 279{
280 //qDebug("MainWindow::~MainWindow() "); 280 //qDebug("MainWindow::~MainWindow() ");
281 //save toolbar location 281 //save toolbar location
282 delete mServerSocket; 282 delete mServerSocket;
283 delete mCalendar; 283 delete mCalendar;
284 delete KOPrefs::instance(); 284 delete KOPrefs::instance();
285 delete KIncidenceFormatter::instance(); 285 delete KIncidenceFormatter::instance();
286 286
287 287
288} 288}
289void MainWindow::showMaximized () 289void MainWindow::showMaximized ()
290{ 290{
291#ifndef DESKTOP_VERSION 291#ifndef DESKTOP_VERSION
292 if ( ! globalFlagBlockStartup ) 292 if ( ! globalFlagBlockStartup )
293 if ( mClosed ) 293 if ( mClosed )
294 mView->goToday(); 294 mView->goToday();
295#endif 295#endif
296 QWidget::showMaximized () ; 296 QWidget::showMaximized () ;
297 mClosed = false; 297 mClosed = false;
298} 298}
299void MainWindow::closeEvent( QCloseEvent* ce ) 299void MainWindow::closeEvent( QCloseEvent* ce )
300{ 300{
301 301
302 302
303 303
304 if ( ! KOPrefs::instance()->mAskForQuit ) { 304 if ( ! KOPrefs::instance()->mAskForQuit ) {
305 saveOnClose(); 305 saveOnClose();
306 mClosed = true; 306 mClosed = true;
307 ce->accept(); 307 ce->accept();
308 return; 308 return;
309 309
310 } 310 }
311 311
312 switch( QMessageBox::information( this, "KO/Pi", 312 switch( QMessageBox::information( this, "KO/Pi",
313 i18n("Do you really want\nto close KO/Pi?"), 313 i18n("Do you really want\nto close KO/Pi?"),
314 i18n("Close"), i18n("No"), 314 i18n("Close"), i18n("No"),
315 0, 0 ) ) { 315 0, 0 ) ) {
316 case 0: 316 case 0:
317 saveOnClose(); 317 saveOnClose();
318 mClosed = true; 318 mClosed = true;
319 ce->accept(); 319 ce->accept();
320 break; 320 break;
321 case 1: 321 case 1:
322 ce->ignore(); 322 ce->ignore();
323 break; 323 break;
324 case 2: 324 case 2:
325 325
326 default: 326 default:
327 break; 327 break;
328 } 328 }
329 329
330 330
331} 331}
332 332
333void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) 333void MainWindow::recieve( const QCString& cmsg, const QByteArray& data )
334{ 334{
335 QDataStream stream( data, IO_ReadOnly ); 335 QDataStream stream( data, IO_ReadOnly );
336 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); 336 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" );
337 //QString datamess; 337 //QString datamess;
338 //qDebug("message "); 338 //qDebug("message ");
339 qDebug("KO: QCOP message received: %s ", cmsg.data() ); 339 qDebug("KO: QCOP message received: %s ", cmsg.data() );
340 340
341 if ( cmsg == "-writeFile" ) { 341 if ( cmsg == "-writeFile" ) {
342 // I made from the "-writeFile" an "-writeAlarm" 342 // I made from the "-writeFile" an "-writeAlarm"
343 mView->viewManager()->showWhatsNextView(); 343 mView->viewManager()->showWhatsNextView();
344 mCalendar->checkAlarmForIncidence( 0, true); 344 mCalendar->checkAlarmForIncidence( 0, true);
345 showMaximized(); 345 showMaximized();
346 raise(); 346 raise();
347 return; 347 return;
348 } 348 }
349 349
350 if ( cmsg == "-writeFile" ) { 350 if ( cmsg == "-writeFile" ) {
351 // I made from the "-writeFile" an "-writeAlarm" 351 // I made from the "-writeFile" an "-writeAlarm"
352 mView->viewManager()->showWhatsNextView(); 352 mView->viewManager()->showWhatsNextView();
353 mCalendar->checkAlarmForIncidence( 0, true); 353 mCalendar->checkAlarmForIncidence( 0, true);
354 showMaximized(); 354 showMaximized();
355 raise(); 355 raise();
356 return; 356 return;
357 357
358 } 358 }
359 if ( cmsg == "-writeFileSilent" ) { 359 if ( cmsg == "-writeFileSilent" ) {
360 // I made from the "-writeFile" an "-writeAlarm" 360 // I made from the "-writeFile" an "-writeAlarm"
361 // mView->viewManager()->showWhatsNextView(); 361 // mView->viewManager()->showWhatsNextView();
362 mCalendar->checkAlarmForIncidence( 0, true); 362 mCalendar->checkAlarmForIncidence( 0, true);
363 //showMaximized(); 363 //showMaximized();
364 //raise(); 364 //raise();
365 hide(); 365 hide();
366 return; 366 return;
367 } 367 }
368 if ( cmsg == "-newCountdown" ) { 368 if ( cmsg == "-newCountdown" ) {
369 qDebug("newCountdown "); 369 qDebug("newCountdown ");
370 370
371 } 371 }
372 QString msg ; 372 QString msg ;
373 QString allmsg = cmsg; 373 QString allmsg = cmsg;
374 while ( allmsg.length() > 0 ) { 374 while ( allmsg.length() > 0 ) {
375 int nextC = allmsg.find( "-", 1 ); 375 int nextC = allmsg.find( "-", 1 );
376 if ( nextC == -1 ) { 376 if ( nextC == -1 ) {
377 msg = allmsg; 377 msg = allmsg;
378 allmsg = ""; 378 allmsg = "";
379 } else{ 379 } else{
380 msg = allmsg.left( nextC ); 380 msg = allmsg.left( nextC );
381 allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); 381 allmsg = allmsg.mid( nextC, allmsg.length()-nextC );
382 } 382 }
383 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); 383 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() );
384 if ( msg == "-newEvent" ) { 384 if ( msg == "-newEvent" ) {
385 mView->newEvent(); 385 mView->newEvent();
386 } 386 }
387 if ( msg == "-newTodo" ) { 387 if ( msg == "-newTodo" ) {
388 mView->newTodo(); 388 mView->newTodo();
389 389
390 } 390 }
391 if ( msg == "-showWN" ) { 391 if ( msg == "-showWN" ) {
392 mView->viewManager()->showWhatsNextView(); 392 mView->viewManager()->showWhatsNextView();
393 } 393 }
394 if ( msg == "-showTodo" ) { 394 if ( msg == "-showTodo" ) {
395 mView->viewManager()->showTodoView(); 395 mView->viewManager()->showTodoView();
396 } 396 }
397 if ( msg == "-showList" ) { 397 if ( msg == "-showList" ) {
398 mView->viewManager()->showListView(); 398 mView->viewManager()->showListView();
399 } 399 }
400 else if ( msg == "-showDay" ) { 400 else if ( msg == "-showDay" ) {
401 mView->viewManager()->showDayView(); 401 mView->viewManager()->showDayView();
402 } 402 }
403 else if ( msg == "-showWWeek" ) { 403 else if ( msg == "-showWWeek" ) {
404 mView->viewManager()->showWorkWeekView(); 404 mView->viewManager()->showWorkWeekView();
405 } 405 }
406 else if ( msg == "-ringSync" ) { 406 else if ( msg == "-ringSync" ) {
407 mSyncManager->multiSync( false ); 407 mSyncManager->multiSync( false );
408 } 408 }
409 else if ( msg == "-showWeek" ) { 409 else if ( msg == "-showWeek" ) {
410 mView->viewManager()->showWeekView(); 410 mView->viewManager()->showWeekView();
411 } 411 }
412 else if ( msg == "-showTodo" ) { 412 else if ( msg == "-showTodo" ) {
413 mView->viewManager()->showTodoView(); 413 mView->viewManager()->showTodoView();
414 } 414 }
415 else if ( msg == "-showJournal" ) { 415 else if ( msg == "-showJournal" ) {
416 mView->dateNavigator()->selectDates( 1 ); 416 mView->dateNavigator()->selectDates( 1 );
417 mView->dateNavigator()->selectToday(); 417 mView->dateNavigator()->selectToday();
418 mView->viewManager()->showJournalView(); 418 mView->viewManager()->showJournalView();
419 } 419 }
420 else if ( msg == "-showKO" ) { 420 else if ( msg == "-showKO" ) {
421 mView->viewManager()->showNextXView(); 421 mView->viewManager()->showNextXView();
422 } 422 }
423 else if ( msg == "-showWNext" || msg == "nextView()" ) { 423 else if ( msg == "-showWNext" || msg == "nextView()" ) {
424 mView->viewManager()->showWhatsNextView(); 424 mView->viewManager()->showWhatsNextView();
425 } 425 }
426 else if ( msg == "-showNextXView" ) { 426 else if ( msg == "-showNextXView" ) {
427 mView->viewManager()->showNextXView(); 427 mView->viewManager()->showNextXView();
428 } 428 }
429 429
430 430
431 } 431 }
432 432
433 showMaximized(); 433 showMaximized();
434 raise(); 434 raise();
435} 435}
436 436
437QPixmap MainWindow::loadPixmap( QString name ) 437QPixmap MainWindow::loadPixmap( QString name )
438{ 438{
439 return SmallIcon( name ); 439 return SmallIcon( name );
440 440
441} 441}
442void MainWindow::initActions() 442void MainWindow::initActions()
443{ 443{
444 //KOPrefs::instance()->mShowFullMenu 444 //KOPrefs::instance()->mShowFullMenu
445 iconToolBar->clear(); 445 iconToolBar->clear();
446 KOPrefs *p = KOPrefs::instance(); 446 KOPrefs *p = KOPrefs::instance();
447 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); 447 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar );
448 448
449 QPopupMenu *viewMenu = new QPopupMenu( this ); 449 QPopupMenu *viewMenu = new QPopupMenu( this );
450 QPopupMenu *actionMenu = new QPopupMenu( this ); 450 QPopupMenu *actionMenu = new QPopupMenu( this );
451 QPopupMenu *importMenu = new QPopupMenu( this ); 451 QPopupMenu *importMenu = new QPopupMenu( this );
452 selectFilterMenu = new QPopupMenu( this ); 452 selectFilterMenu = new QPopupMenu( this );
453 selectFilterMenu->setCheckable( true ); 453 selectFilterMenu->setCheckable( true );
454 syncMenu = new QPopupMenu( this ); 454 syncMenu = new QPopupMenu( this );
455 configureAgendaMenu = new QPopupMenu( this ); 455 configureAgendaMenu = new QPopupMenu( this );
456 configureToolBarMenu = new QPopupMenu( this ); 456 configureToolBarMenu = new QPopupMenu( this );
457 QPopupMenu *helpMenu = new QPopupMenu( this ); 457 QPopupMenu *helpMenu = new QPopupMenu( this );
458 if ( KOPrefs::instance()->mShowFullMenu ) { 458 if ( KOPrefs::instance()->mShowFullMenu ) {
459 QMenuBar *menuBar1; 459 QMenuBar *menuBar1;
460 menuBar1 = menuBar(); 460 menuBar1 = menuBar();
461 menuBar1->insertItem( i18n("File"), importMenu ); 461 menuBar1->insertItem( i18n("File"), importMenu );
462 menuBar1->insertItem( i18n("View"), viewMenu ); 462 menuBar1->insertItem( i18n("View"), viewMenu );
463 menuBar1->insertItem( i18n("Actions"), actionMenu ); 463 menuBar1->insertItem( i18n("Actions"), actionMenu );
464 menuBar1->insertItem( i18n("Synchronize"), syncMenu ); 464 menuBar1->insertItem( i18n("Synchronize"), syncMenu );
465 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 465 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu );
466 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); 466 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu );
467 menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); 467 menuBar1->insertItem( i18n("Filter"),selectFilterMenu );
468 menuBar1->insertItem( i18n("Help"), helpMenu ); 468 menuBar1->insertItem( i18n("Help"), helpMenu );
469 } else { 469 } else {
470 QPEMenuBar *menuBar1; 470 QPEMenuBar *menuBar1;
471 menuBar1 = new QPEMenuBar( iconToolBar ); 471 menuBar1 = new QPEMenuBar( iconToolBar );
472 QPopupMenu *menuBar = new QPopupMenu( this ); 472 QPopupMenu *menuBar = new QPopupMenu( this );
473 menuBar1->insertItem( i18n("ME"), menuBar); 473 menuBar1->insertItem( i18n("ME"), menuBar);
474 menuBar->insertItem( i18n("File"), importMenu ); 474 menuBar->insertItem( i18n("File"), importMenu );
475 menuBar->insertItem( i18n("View"), viewMenu ); 475 menuBar->insertItem( i18n("View"), viewMenu );
476 menuBar->insertItem( i18n("Actions"), actionMenu ); 476 menuBar->insertItem( i18n("Actions"), actionMenu );
477 menuBar->insertItem( i18n("Synchronize"), syncMenu ); 477 menuBar->insertItem( i18n("Synchronize"), syncMenu );
478 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 478 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu );
479 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); 479 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu );
480 menuBar->insertItem( i18n("Filter"),selectFilterMenu ); 480 menuBar->insertItem( i18n("Filter"),selectFilterMenu );
481 menuBar->insertItem( i18n("Help"), helpMenu ); 481 menuBar->insertItem( i18n("Help"), helpMenu );
482 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); 482 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() );
483 menuBar1->setMaximumSize( menuBar1->sizeHint( )); 483 menuBar1->setMaximumSize( menuBar1->sizeHint( ));
484 } 484 }
485 connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) ); 485 connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) );
486 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); 486 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
487 connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) ); 487 connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) );
488 488
489 // ****************** 489 // ******************
490 QAction *action; 490 QAction *action;
491 QIconSet icon; 491 QIconSet icon;
492 // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); 492 // QPopupMenu *configureMenu= new QPopupMenu( menuBar );
493 configureToolBarMenu->setCheckable( true ); 493 configureToolBarMenu->setCheckable( true );
494 494
495 QString pathString = ""; 495 QString pathString = "";
496 if ( !p->mToolBarMiniIcons ) { 496 if ( !p->mToolBarMiniIcons ) {
497 if ( QApplication::desktop()->width() < 480 ) 497 if ( QApplication::desktop()->width() < 480 )
498 pathString += "icons16/"; 498 pathString += "icons16/";
499 } else 499 } else
500 pathString += "iconsmini/"; 500 pathString += "iconsmini/";
501 configureAgendaMenu->setCheckable( true ); 501 configureAgendaMenu->setCheckable( true );
502 configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 ); 502 configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 );
503 configureAgendaMenu->insertSeparator(); 503 configureAgendaMenu->insertSeparator();
504 configureAgendaMenu->insertItem(i18n("Tiny"), 4 ); 504 configureAgendaMenu->insertItem(i18n("Tiny"), 4 );
505 configureAgendaMenu->insertItem(i18n("Small"), 6 ); 505 configureAgendaMenu->insertItem(i18n("Small"), 6 );
506 configureAgendaMenu->insertItem(i18n("Medium"), 8 ); 506 configureAgendaMenu->insertItem(i18n("Medium"), 8 );
507 configureAgendaMenu->insertItem(i18n("Normal"), 10 ); 507 configureAgendaMenu->insertItem(i18n("Normal"), 10 );
508 configureAgendaMenu->insertItem(i18n("Large"), 12 ); 508 configureAgendaMenu->insertItem(i18n("Large"), 12 );
509 configureAgendaMenu->insertItem(i18n("Big"), 14 ); 509 configureAgendaMenu->insertItem(i18n("Big"), 14 );
510 configureAgendaMenu->insertItem(i18n("Bigger"), 16 ); 510 configureAgendaMenu->insertItem(i18n("Bigger"), 16 );
511 configureAgendaMenu->insertItem(i18n("Biggest"), 18 ); 511 configureAgendaMenu->insertItem(i18n("Biggest"), 18 );
512 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); 512 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu );
513 513
514 icon = loadPixmap( pathString + "configure" ); 514 icon = loadPixmap( pathString + "configure" );
515 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); 515 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this );
516 action->addTo( actionMenu ); 516 action->addTo( actionMenu );
517 connect( action, SIGNAL( activated() ), 517 connect( action, SIGNAL( activated() ),
518 mView, SLOT( edit_options() ) ); 518 mView, SLOT( edit_options() ) );
519 actionMenu->insertSeparator(); 519 actionMenu->insertSeparator();
520 icon = loadPixmap( pathString + "newevent" ); 520 icon = loadPixmap( pathString + "newevent" );
521 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); 521 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 );
522 configureToolBarMenu->insertSeparator(); 522 configureToolBarMenu->insertSeparator();
523 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); 523 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 );
524 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); 524 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this );
525 ne_action->addTo( actionMenu ); 525 ne_action->addTo( actionMenu );
526 connect( ne_action, SIGNAL( activated() ), 526 connect( ne_action, SIGNAL( activated() ),
527 mView, SLOT( newEvent() ) ); 527 mView, SLOT( newEvent() ) );
528 icon = loadPixmap( pathString + "newtodo" ); 528 icon = loadPixmap( pathString + "newtodo" );
529 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); 529 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 );
530 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); 530 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this );
531 nt_action->addTo( actionMenu ); 531 nt_action->addTo( actionMenu );
532 connect( nt_action, SIGNAL( activated() ), 532 connect( nt_action, SIGNAL( activated() ),
533 mView, SLOT( newTodo() ) ); 533 mView, SLOT( newTodo() ) );
534 icon = loadPixmap( pathString + "navi" ); 534 icon = loadPixmap( pathString + "navi" );
535 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); 535 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this );
536 action->addTo( viewMenu ); 536 action->addTo( viewMenu );
537 connect( action, SIGNAL( activated() ), 537 connect( action, SIGNAL( activated() ),
538 mView, SLOT( toggleDateNavigatorWidget() ) ); 538 mView, SLOT( toggleDateNavigatorWidget() ) );
539 icon = loadPixmap( pathString + "filter" ); 539 icon = loadPixmap( pathString + "filter" );
540 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); 540 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this );
541 action->addTo( viewMenu ); 541 action->addTo( viewMenu );
542 connect( action, SIGNAL( activated() ), 542 connect( action, SIGNAL( activated() ),
543 mView, SLOT( toggleFilter() ) ); 543 mView, SLOT( toggleFilter() ) );
544 544
545 545
546 viewMenu->insertSeparator(); 546 viewMenu->insertSeparator();
547 icon = loadPixmap( pathString + "picker" ); 547 icon = loadPixmap( pathString + "picker" );
548 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); 548 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this );
549 action->addTo( viewMenu ); 549 action->addTo( viewMenu );
550 connect( action, SIGNAL( activated() ), 550 connect( action, SIGNAL( activated() ),
551 mView, SLOT( showDatePicker() ) ); 551 mView, SLOT( showDatePicker() ) );
552 action->addTo( iconToolBar ); 552 action->addTo( iconToolBar );
553 viewMenu->insertSeparator(); 553 viewMenu->insertSeparator();
554 icon = loadPixmap( pathString + "list" ); 554 icon = loadPixmap( pathString + "list" );
555 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); 555 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 );
556 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); 556 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this );
557 showlist_action->addTo( viewMenu ); 557 showlist_action->addTo( viewMenu );
558 connect( showlist_action, SIGNAL( activated() ), 558 connect( showlist_action, SIGNAL( activated() ),
559 mView->viewManager(), SLOT( showListView() ) ); 559 mView->viewManager(), SLOT( showListView() ) );
560 560
561 561
562 icon = loadPixmap( pathString + "day" ); 562 icon = loadPixmap( pathString + "day" );
563 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); 563 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 );
564 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); 564 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this );
565 day1_action->addTo( viewMenu ); 565 day1_action->addTo( viewMenu );
566 // action->addTo( toolBar ); 566 // action->addTo( toolBar );
567 connect( day1_action, SIGNAL( activated() ), 567 connect( day1_action, SIGNAL( activated() ),
568 mView->viewManager(), SLOT( showDayView() ) ); 568 mView->viewManager(), SLOT( showDayView() ) );
569 569
570 icon = loadPixmap( pathString + "workweek" ); 570 icon = loadPixmap( pathString + "workweek" );
571 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); 571 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 );
572 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); 572 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this );
573 day5_action->addTo( viewMenu ); 573 day5_action->addTo( viewMenu );
574 connect( day5_action, SIGNAL( activated() ), 574 connect( day5_action, SIGNAL( activated() ),
575 mView->viewManager(), SLOT( showWorkWeekView() ) ); 575 mView->viewManager(), SLOT( showWorkWeekView() ) );
576 576
577 icon = loadPixmap( pathString + "week" ); 577 icon = loadPixmap( pathString + "week" );
578 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); 578 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 );
579 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); 579 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this );
580 day7_action->addTo( viewMenu ); 580 day7_action->addTo( viewMenu );
581 connect( day7_action, SIGNAL( activated() ), 581 connect( day7_action, SIGNAL( activated() ),
582 mView->viewManager(), SLOT( showWeekView() ) ); 582 mView->viewManager(), SLOT( showWeekView() ) );
583 583
584 icon = loadPixmap( pathString + "month" ); 584 icon = loadPixmap( pathString + "month" );
585 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); 585 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 );
586 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); 586 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this );
587 month_action->addTo( viewMenu ); 587 month_action->addTo( viewMenu );
588 connect( month_action, SIGNAL( activated() ), 588 connect( month_action, SIGNAL( activated() ),
589 mView->viewManager(), SLOT( showMonthView() ) ); 589 mView->viewManager(), SLOT( showMonthView() ) );
590 590
591 icon = loadPixmap( pathString + "todo" ); 591 icon = loadPixmap( pathString + "todo" );
592 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); 592 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 );
593 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); 593 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this );
594 todoview_action->addTo( viewMenu ); 594 todoview_action->addTo( viewMenu );
595 connect( todoview_action, SIGNAL( activated() ), 595 connect( todoview_action, SIGNAL( activated() ),
596 mView->viewManager(), SLOT( showTodoView() ) ); 596 mView->viewManager(), SLOT( showTodoView() ) );
597 597
598 icon = loadPixmap( pathString + "journal" ); 598 icon = loadPixmap( pathString + "journal" );
599 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); 599 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 );
600 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); 600 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this );
601 viewjournal_action->addTo( viewMenu ); 601 viewjournal_action->addTo( viewMenu );
602 connect( viewjournal_action, SIGNAL( activated() ), 602 connect( viewjournal_action, SIGNAL( activated() ),
603 mView->viewManager(), SLOT( showJournalView() ) ); 603 mView->viewManager(), SLOT( showJournalView() ) );
604 604
605 icon = loadPixmap( pathString + "xdays" ); 605 icon = loadPixmap( pathString + "xdays" );
606 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 ); 606 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 );
607 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); 607 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this );
608 xdays_action->addTo( viewMenu ); 608 xdays_action->addTo( viewMenu );
609 connect( xdays_action, SIGNAL( activated() ), 609 connect( xdays_action, SIGNAL( activated() ),
610 mView->viewManager(), SLOT( showNextXView() ) ); 610 mView->viewManager(), SLOT( showNextXView() ) );
611 611
612 icon = loadPixmap( pathString + "whatsnext" ); 612 icon = loadPixmap( pathString + "whatsnext" );
613 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 ); 613 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 );
614 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); 614 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this );
615 whatsnext_action->addTo( viewMenu ); 615 whatsnext_action->addTo( viewMenu );
616 connect( whatsnext_action, SIGNAL( activated() ), 616 connect( whatsnext_action, SIGNAL( activated() ),
617 mView->viewManager(), SLOT( showWhatsNextView() ) ); 617 mView->viewManager(), SLOT( showWhatsNextView() ) );
618 618
619#if 0 619#if 0
620 action = new QAction( "view_timespan", "Time Span", 0, this ); 620 action = new QAction( "view_timespan", "Time Span", 0, this );
621 action->addTo( viewMenu ); 621 action->addTo( viewMenu );
622 connect( action, SIGNAL( activated() ), 622 connect( action, SIGNAL( activated() ),
623 mView->viewManager(), SLOT( showTimeSpanView() ) ); 623 mView->viewManager(), SLOT( showTimeSpanView() ) );
624#endif 624#endif
625 625
626 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, 626 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0,
627 this ); 627 this );
628 mNewSubTodoAction->addTo( actionMenu ); 628 mNewSubTodoAction->addTo( actionMenu );
629 connect( mNewSubTodoAction, SIGNAL( activated() ), 629 connect( mNewSubTodoAction, SIGNAL( activated() ),
630 mView, SLOT( newSubTodo() ) ); 630 mView, SLOT( newSubTodo() ) );
631 631
632 actionMenu->insertSeparator(); 632 actionMenu->insertSeparator();
633 633
634 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); 634 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this );
635 mShowAction->addTo( actionMenu ); 635 mShowAction->addTo( actionMenu );
636 connect( mShowAction, SIGNAL( activated() ), 636 connect( mShowAction, SIGNAL( activated() ),
637 mView, SLOT( showIncidence() ) ); 637 mView, SLOT( showIncidence() ) );
638 638
639 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); 639 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this );
640 mEditAction->addTo( actionMenu ); 640 mEditAction->addTo( actionMenu );
641 connect( mEditAction, SIGNAL( activated() ), 641 connect( mEditAction, SIGNAL( activated() ),
642 mView, SLOT( editIncidence() ) ); 642 mView, SLOT( editIncidence() ) );
643 643
644 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); 644 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this );
645 mDeleteAction->addTo( actionMenu ); 645 mDeleteAction->addTo( actionMenu );
646 connect( mDeleteAction, SIGNAL( activated() ), 646 connect( mDeleteAction, SIGNAL( activated() ),
647 mView, SLOT( deleteIncidence() ) ); 647 mView, SLOT( deleteIncidence() ) );
648 648
649 649
650 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); 650 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this );
651 mCloneAction->addTo( actionMenu ); 651 mCloneAction->addTo( actionMenu );
652 connect( mCloneAction, SIGNAL( activated() ), 652 connect( mCloneAction, SIGNAL( activated() ),
653 mView, SLOT( cloneIncidence() ) ); 653 mView, SLOT( cloneIncidence() ) );
654 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); 654 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this );
655 mMoveAction->addTo( actionMenu ); 655 mMoveAction->addTo( actionMenu );
656 connect( mMoveAction, SIGNAL( activated() ), 656 connect( mMoveAction, SIGNAL( activated() ),
657 mView, SLOT( moveIncidence() ) ); 657 mView, SLOT( moveIncidence() ) );
658 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); 658 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this );
659 mBeamAction->addTo( actionMenu ); 659 mBeamAction->addTo( actionMenu );
660 connect( mBeamAction, SIGNAL( activated() ), 660 connect( mBeamAction, SIGNAL( activated() ),
661 mView, SLOT( beamIncidence() ) ); 661 mView, SLOT( beamIncidence() ) );
662 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); 662 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this );
663 mCancelAction->addTo( actionMenu ); 663 mCancelAction->addTo( actionMenu );
664 connect( mCancelAction, SIGNAL( activated() ), 664 connect( mCancelAction, SIGNAL( activated() ),
665 mView, SLOT( toggleCancelIncidence() ) ); 665 mView, SLOT( toggleCancelIncidence() ) );
666 666
667 actionMenu->insertSeparator(); 667 actionMenu->insertSeparator();
668 668
669 action = new QAction( "purge_completed", i18n("Purge Completed"), 0, 669 action = new QAction( "purge_completed", i18n("Purge Completed"), 0,
670 this ); 670 this );
671 action->addTo( actionMenu ); 671 action->addTo( actionMenu );
672 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); 672 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) );
673 673
674 icon = loadPixmap( pathString + "search" ); 674 icon = loadPixmap( pathString + "search" );
675 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); 675 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this );
676 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4); 676 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4);
677 search_action->addTo( actionMenu ); 677 search_action->addTo( actionMenu );
678 connect( search_action, SIGNAL( activated() ), 678 connect( search_action, SIGNAL( activated() ),
679 mView->dialogManager(), SLOT( showSearchDialog() ) ); 679 mView->dialogManager(), SLOT( showSearchDialog() ) );
680 680
681 icon = loadPixmap( pathString + "today" ); 681 icon = loadPixmap( pathString + "today" );
682 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); 682 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130);
683 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); 683 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this );
684 today_action->addTo( actionMenu ); 684 today_action->addTo( actionMenu );
685 connect( today_action, SIGNAL( activated() ), 685 connect( today_action, SIGNAL( activated() ),
686 mView, SLOT( goToday() ) ); 686 mView, SLOT( goToday() ) );
687 687
688 if ( KOPrefs::instance()->mShowFullMenu ) { 688 if ( KOPrefs::instance()->mShowFullMenu ) {
689 actionMenu->insertSeparator(); 689 actionMenu->insertSeparator();
690 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); 690 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu );
691 691
692 } 692 }
693 // actionMenu->insertSeparator(); 693 // actionMenu->insertSeparator();
694 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, 694 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0,
695 this ); 695 this );
696 action->addTo( importMenu ); 696 action->addTo( importMenu );
697 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); 697 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) );
698 action = new QAction( "import_quick", i18n("Import last file"), 0, 698 action = new QAction( "import_quick", i18n("Import last file"), 0,
699 this ); 699 this );
700 action->addTo( importMenu ); 700 action->addTo( importMenu );
701 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); 701 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) );
702 importMenu->insertSeparator(); 702 importMenu->insertSeparator();
703 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, 703 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0,
704 this ); 704 this );
705 action->addTo( importMenu ); 705 action->addTo( importMenu );
706 connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); 706 connect( action, SIGNAL( activated() ), SLOT( importBday() ) );
707#ifndef DESKTOP_VERSION 707#ifndef DESKTOP_VERSION
708 importMenu->insertSeparator(); 708 importMenu->insertSeparator();
709 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, 709 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0,
710 this ); 710 this );
711 action->addTo( importMenu ); 711 action->addTo( importMenu );
712 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); 712 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) );
713#else 713#else
714#ifdef _WIN32_ 714#ifdef _WIN32_
715 importMenu->insertSeparator(); 715 importMenu->insertSeparator();
716 action = new QAction( "import_ol", i18n("Import from OL"), 0, 716 action = new QAction( "import_ol", i18n("Import from OL"), 0,
717 this ); 717 this );
718 action->addTo( importMenu ); 718 action->addTo( importMenu );
719 connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); 719 connect( action, SIGNAL( activated() ), SLOT( importOL() ) );
720#endif 720#endif
721#endif 721#endif
722 722
723 importMenu->insertSeparator(); 723 importMenu->insertSeparator();
724 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, 724 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0,
725 this ); 725 this );
726 action->addTo( importMenu ); 726 action->addTo( importMenu );
727 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); 727 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) );
728 728
729 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, 729 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0,
730 this ); 730 this );
731 action->addTo( importMenu ); 731 action->addTo( importMenu );
732 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); 732 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) );
733 733
734 importMenu->insertSeparator(); 734 importMenu->insertSeparator();
735 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, 735 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0,
736 this ); 736 this );
737 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); 737 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) );
738 738
739 739
740 //LR 740 //LR
741 QPopupMenu *ex2phone = new QPopupMenu( this ); 741 QPopupMenu *ex2phone = new QPopupMenu( this );
742 ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 742 ex2phone->insertItem(i18n("Complete calendar..."), 1 );
743 ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 743 ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
744 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); 744 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) );
745 importMenu->insertItem( i18n("Export to phone"), ex2phone ); 745 importMenu->insertItem( i18n("Export to phone"), ex2phone );
746 746
747 importMenu->insertSeparator(); 747 importMenu->insertSeparator();
748 action = new QAction( "manage cat", i18n("Manage new categories..."), 0, 748 action = new QAction( "manage cat", i18n("Manage new categories..."), 0,
749 this ); 749 this );
750 action->addTo( importMenu ); 750 action->addTo( importMenu );
751 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); 751 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) );
752#ifndef DESKTOP_VERSION 752#ifndef DESKTOP_VERSION
753 importMenu->insertSeparator(); 753 importMenu->insertSeparator();
754 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, 754 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0,
755 this ); 755 this );
756 action->addTo( importMenu ); 756 action->addTo( importMenu );
757 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); 757 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) );
758 758
759 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, 759 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0,
760 this ); 760 this );
761 action->addTo( importMenu ); 761 action->addTo( importMenu );
762 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); 762 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) );
763#else 763#else
764 importMenu->insertSeparator(); 764 importMenu->insertSeparator();
765 icon = loadPixmap( pathString + "print" ); 765 icon = loadPixmap( pathString + "print" );
766 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); 766 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this );
767 action->addTo( importMenu ); 767 action->addTo( importMenu );
768 connect( action, SIGNAL( activated() ), 768 connect( action, SIGNAL( activated() ),
769 this, SLOT( printCal() ) ); 769 this, SLOT( printCal() ) );
770 770
771 icon = loadPixmap( pathString + "print" ); 771 icon = loadPixmap( pathString + "print" );
772 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); 772 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this );
773 action->addTo( importMenu ); 773 action->addTo( importMenu );
774 connect( action, SIGNAL( activated() ), 774 connect( action, SIGNAL( activated() ),
775 this, SLOT( printSel() ) ); 775 this, SLOT( printSel() ) );
776#endif 776#endif
777 importMenu->insertSeparator(); 777 importMenu->insertSeparator();
778 action = new QAction( "beam all", i18n("Save"), 0, 778 action = new QAction( "beam all", i18n("Save"), 0,
779 this ); 779 this );
780 action->addTo( importMenu ); 780 action->addTo( importMenu );
781 connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); 781 connect( action, SIGNAL( activated() ), this, SLOT( save() ) );
782 action = new QAction( "beam all", i18n("Exit (+save)"), 0, 782 action = new QAction( "beam all", i18n("Exit (+save)"), 0,
783 this ); 783 this );
784 action->addTo( importMenu ); 784 action->addTo( importMenu );
785 connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); 785 connect( action, SIGNAL( activated() ), this, SLOT( close() ) );
786 786
787 //menuBar->insertItem( "Configure",configureMenu ); 787 //menuBar->insertItem( "Configure",configureMenu );
788 //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); 788 //configureMenu->insertItem( "Toolbar",configureToolBarMenu );
789 icon = loadPixmap( "korganizer/korganizer" ); 789 icon = loadPixmap( "korganizer/korganizer" );
790 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); 790 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this );
791 action->addTo( helpMenu ); 791 action->addTo( helpMenu );
792 connect( action, SIGNAL( activated() ), 792 connect( action, SIGNAL( activated() ),
793 SLOT( keyBindings() ) ); 793 SLOT( keyBindings() ) );
794 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); 794 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this );
795 action->addTo( helpMenu ); 795 action->addTo( helpMenu );
796 connect( action, SIGNAL( activated() ), 796 connect( action, SIGNAL( activated() ),
797 SLOT( features() ) ); 797 SLOT( features() ) );
798 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); 798 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this );
799 action->addTo( helpMenu ); 799 action->addTo( helpMenu );
800 connect( action, SIGNAL( activated() ), 800 connect( action, SIGNAL( activated() ),
801 SLOT( aboutAutoSaving() ) ); 801 SLOT( aboutAutoSaving() ) );
802 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); 802 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this );
803 action->addTo( helpMenu ); 803 action->addTo( helpMenu );
804 connect( action, SIGNAL( activated() ), 804 connect( action, SIGNAL( activated() ),
805 SLOT( aboutKnownBugs() ) ); 805 SLOT( aboutKnownBugs() ) );
806 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); 806 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this );
807 action->addTo( helpMenu ); 807 action->addTo( helpMenu );
808 connect( action, SIGNAL( activated() ), 808 connect( action, SIGNAL( activated() ),
809 SLOT( usertrans() ) ); 809 SLOT( usertrans() ) );
810 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); 810 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this );
811 action->addTo( helpMenu ); 811 action->addTo( helpMenu );
812 connect( action, SIGNAL( activated() ), 812 connect( action, SIGNAL( activated() ),
813 SLOT( synchowto() ) ); 813 SLOT( synchowto() ) );
814 action = new QAction( "Whats New", i18n("What's new?"), 0,this ); 814 action = new QAction( "Whats New", i18n("What's new?"), 0,this );
815 action->addTo( helpMenu ); 815 action->addTo( helpMenu );
816 connect( action, SIGNAL( activated() ), 816 connect( action, SIGNAL( activated() ),
817 SLOT( whatsNew() ) ); 817 SLOT( whatsNew() ) );
818 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); 818 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this );
819 action->addTo( helpMenu ); 819 action->addTo( helpMenu );
820 connect( action, SIGNAL( activated() ), 820 connect( action, SIGNAL( activated() ),
821 SLOT( faq() ) ); 821 SLOT( faq() ) );
822 822
823 823
824 action = new QAction( "about", i18n("About..."), 0, this ); 824 action = new QAction( "about", i18n("About..."), 0, this );
825 action->addTo( helpMenu ); 825 action->addTo( helpMenu );
826 connect( action, SIGNAL( activated() ), 826 connect( action, SIGNAL( activated() ),
827 SLOT( about() ) ); 827 SLOT( about() ) );
828 action = new QAction( "licence", i18n("Licence..."), 0, this ); 828 action = new QAction( "licence", i18n("Licence..."), 0, this );
829 action->addTo( helpMenu ); 829 action->addTo( helpMenu );
830 connect( action, SIGNAL( activated() ), 830 connect( action, SIGNAL( activated() ),
831 SLOT( licence() ) ); 831 SLOT( licence() ) );
832 //menuBar->insertSeparator(); 832 //menuBar->insertSeparator();
833 833
834 // ****************************************************** 834 // ******************************************************
835 // menubar icons 835 // menubar icons
836 836
837 837
838 iconToolBar->setHorizontalStretchable (true ); 838 iconToolBar->setHorizontalStretchable (true );
839 //menuBar->insertItem( iconToolBar ); 839 //menuBar->insertItem( iconToolBar );
840 //xdays_action 840 //xdays_action
841 if (p-> mShowIconNewEvent) 841 if (p-> mShowIconNewEvent)
842 ne_action->addTo( iconToolBar ); 842 ne_action->addTo( iconToolBar );
843 if (p->mShowIconNewTodo ) 843 if (p->mShowIconNewTodo )
844 nt_action->addTo( iconToolBar ); 844 nt_action->addTo( iconToolBar );
845 if (p-> mShowIconSearch) 845 if (p-> mShowIconSearch)
846 search_action->addTo( iconToolBar ); 846 search_action->addTo( iconToolBar );
847 if (p-> mShowIconNext) 847 if (p-> mShowIconNext)
848 whatsnext_action->addTo( iconToolBar ); 848 whatsnext_action->addTo( iconToolBar );
849 if (p-> mShowIconNextDays) 849 if (p-> mShowIconNextDays)
850 xdays_action->addTo( iconToolBar ); 850 xdays_action->addTo( iconToolBar );
851 if (p-> mShowIconList) 851 if (p-> mShowIconList)
852 showlist_action->addTo( iconToolBar ); 852 showlist_action->addTo( iconToolBar );
853 if (p-> mShowIconDay1) 853 if (p-> mShowIconDay1)
854 day1_action->addTo( iconToolBar ); 854 day1_action->addTo( iconToolBar );
855 if (p-> mShowIconDay5) 855 if (p-> mShowIconDay5)
856 day5_action->addTo( iconToolBar ); 856 day5_action->addTo( iconToolBar );
857 if (p-> mShowIconDay7) 857 if (p-> mShowIconDay7)
858 day7_action->addTo( iconToolBar ); 858 day7_action->addTo( iconToolBar );
859 if (p-> mShowIconMonth) 859 if (p-> mShowIconMonth)
860 month_action->addTo( iconToolBar ); 860 month_action->addTo( iconToolBar );
861 if (p-> mShowIconTodoview) 861 if (p-> mShowIconTodoview)
862 todoview_action->addTo( iconToolBar ); 862 todoview_action->addTo( iconToolBar );
863 if (p-> mShowIconJournal) 863 if (p-> mShowIconJournal)
864 viewjournal_action->addTo( iconToolBar ); 864 viewjournal_action->addTo( iconToolBar );
865 icon = loadPixmap( pathString + "2leftarrowB" ); 865 icon = loadPixmap( pathString + "2leftarrowB" );
866 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); 866 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14);
867 if (p-> mShowIconBackFast) { 867 if (p-> mShowIconBackFast) {
868 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); 868 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this );
869 connect( action, SIGNAL( activated() ), 869 connect( action, SIGNAL( activated() ),
870 mView, SLOT( goPreviousMonth() ) ); 870 mView, SLOT( goPreviousMonth() ) );
871 action->addTo( iconToolBar ); 871 action->addTo( iconToolBar );
872 } 872 }
873 icon = loadPixmap( pathString + "1leftarrowB" ); 873 icon = loadPixmap( pathString + "1leftarrowB" );
874 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); 874 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15);
875 if (p-> mShowIconBack) { 875 if (p-> mShowIconBack) {
876 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); 876 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this );
877 connect( action, SIGNAL( activated() ), 877 connect( action, SIGNAL( activated() ),
878 mView, SLOT( goPrevious() ) ); 878 mView, SLOT( goPrevious() ) );
879 action->addTo( iconToolBar ); 879 action->addTo( iconToolBar );
880 } 880 }
881 if (p-> mShowIconToday) 881 if (p-> mShowIconToday)
882 today_action->addTo( iconToolBar ); 882 today_action->addTo( iconToolBar );
883 icon = loadPixmap( pathString + "1rightarrowB" ); 883 icon = loadPixmap( pathString + "1rightarrowB" );
884 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); 884 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220);
885 if (p-> mShowIconForward) { 885 if (p-> mShowIconForward) {
886 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); 886 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this );
887 connect( action, SIGNAL( activated() ), 887 connect( action, SIGNAL( activated() ),
888 mView, SLOT( goNext() ) ); 888 mView, SLOT( goNext() ) );
889 action->addTo( iconToolBar ); 889 action->addTo( iconToolBar );
890 } 890 }
891 icon = loadPixmap( pathString + "2rightarrowB" ); 891 icon = loadPixmap( pathString + "2rightarrowB" );
892 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); 892 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230);
893 if (p-> mShowIconForwardFast) { 893 if (p-> mShowIconForwardFast) {
894 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); 894 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this );
895 connect( action, SIGNAL( activated() ), 895 connect( action, SIGNAL( activated() ),
896 mView, SLOT( goNextMonth() ) ); 896 mView, SLOT( goNextMonth() ) );
897 action->addTo( iconToolBar ); 897 action->addTo( iconToolBar );
898 } 898 }
899 899
900 900
901 configureToolBarMenu->insertItem(i18n("What's This?"), 300); 901 configureToolBarMenu->insertItem(i18n("What's This?"), 300);
902 902
903 if (p-> mShowIconNewEvent) 903 if (p-> mShowIconNewEvent)
904 configureToolBarMenu->setItemChecked( 10, true ); 904 configureToolBarMenu->setItemChecked( 10, true );
905 if (p->mShowIconNewTodo ) 905 if (p->mShowIconNewTodo )
906 configureToolBarMenu->setItemChecked( 20, true ); 906 configureToolBarMenu->setItemChecked( 20, true );
907 if (p-> mShowIconSearch) 907 if (p-> mShowIconSearch)
908 configureToolBarMenu->setItemChecked( 120, true ); 908 configureToolBarMenu->setItemChecked( 120, true );
909 if (p-> mShowIconList) 909 if (p-> mShowIconList)
910 configureToolBarMenu->setItemChecked( 30, true ); 910 configureToolBarMenu->setItemChecked( 30, true );
911 if (p-> mShowIconDay1) 911 if (p-> mShowIconDay1)
912 configureToolBarMenu->setItemChecked( 40, true ); 912 configureToolBarMenu->setItemChecked( 40, true );
913 if (p-> mShowIconDay5) 913 if (p-> mShowIconDay5)
914 configureToolBarMenu->setItemChecked( 50, true ); 914 configureToolBarMenu->setItemChecked( 50, true );
915 if (p-> mShowIconDay7) 915 if (p-> mShowIconDay7)
916 configureToolBarMenu->setItemChecked( 60, true ); 916 configureToolBarMenu->setItemChecked( 60, true );
917 if (p-> mShowIconMonth) 917 if (p-> mShowIconMonth)
918 configureToolBarMenu->setItemChecked( 70, true ); 918 configureToolBarMenu->setItemChecked( 70, true );
919 if (p-> mShowIconTodoview) 919 if (p-> mShowIconTodoview)
920 configureToolBarMenu->setItemChecked( 80, true ); 920 configureToolBarMenu->setItemChecked( 80, true );
921 if (p-> mShowIconBackFast) 921 if (p-> mShowIconBackFast)
922 configureToolBarMenu->setItemChecked( 200, true ); 922 configureToolBarMenu->setItemChecked( 200, true );
923 if (p-> mShowIconBack) 923 if (p-> mShowIconBack)
924 configureToolBarMenu->setItemChecked( 210, true ); 924 configureToolBarMenu->setItemChecked( 210, true );
925 if (p-> mShowIconToday) 925 if (p-> mShowIconToday)
926 configureToolBarMenu->setItemChecked( 130, true ); 926 configureToolBarMenu->setItemChecked( 130, true );
927 if (p-> mShowIconForward) 927 if (p-> mShowIconForward)
928 configureToolBarMenu->setItemChecked( 220, true ); 928 configureToolBarMenu->setItemChecked( 220, true );
929 if (p-> mShowIconForwardFast) 929 if (p-> mShowIconForwardFast)
930 configureToolBarMenu->setItemChecked( 230, true ); 930 configureToolBarMenu->setItemChecked( 230, true );
931 if (p-> mShowIconNextDays) 931 if (p-> mShowIconNextDays)
932 configureToolBarMenu->setItemChecked( 100, true ); 932 configureToolBarMenu->setItemChecked( 100, true );
933 if (p-> mShowIconNext) 933 if (p-> mShowIconNext)
934 configureToolBarMenu->setItemChecked( 110, true ); 934 configureToolBarMenu->setItemChecked( 110, true );
935 if (p-> mShowIconJournal) 935 if (p-> mShowIconJournal)
936 configureToolBarMenu->setItemChecked( 90, true ); 936 configureToolBarMenu->setItemChecked( 90, true );
937 if (p-> mShowIconWhatsThis) 937 if (p-> mShowIconWhatsThis)
938 configureToolBarMenu->setItemChecked( 300, true ); 938 configureToolBarMenu->setItemChecked( 300, true );
939 939
940 QLabel* dummy = new QLabel( iconToolBar ); 940 QLabel* dummy = new QLabel( iconToolBar );
941 dummy->setBackgroundColor( iconToolBar->backgroundColor() ); 941 dummy->setBackgroundColor( iconToolBar->backgroundColor() );
942 if (!p-> mShowIconStretch) 942 if (!p-> mShowIconStretch)
943 iconToolBar->setStretchableWidget ( dummy ) ; 943 iconToolBar->setStretchableWidget ( dummy ) ;
944 else 944 else
945 configureToolBarMenu->setItemChecked( 5, true ); 945 configureToolBarMenu->setItemChecked( 5, true );
946 if (p-> mShowIconWhatsThis) 946 if (p-> mShowIconWhatsThis)
947 QWhatsThis::whatsThisButton ( iconToolBar ); 947 QWhatsThis::whatsThisButton ( iconToolBar );
948 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); 948 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) );
949 configureAgenda( p->mHourSize ); 949 configureAgenda( p->mHourSize );
950 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); 950 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) );
951} 951}
952 952
953void MainWindow::exportToPhone( int mode ) 953void MainWindow::exportToPhone( int mode )
954{ 954{
955 955
956 //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 956 //ex2phone->insertItem(i18n("Complete calendar..."), 1 );
957 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 957 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
958 KOex2phonePrefs ex2phone; 958 KOex2phonePrefs ex2phone;
959 959
960 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 960 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
961 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 961 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
962 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 962 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
963 if ( mode == 1 ) 963 if ( mode == 1 )
964 ex2phone.setCaption(i18n("Export complete calendar")); 964 ex2phone.setCaption(i18n("Export complete calendar"));
965 if ( mode == 2 ) 965 if ( mode == 2 )
966 ex2phone.setCaption(i18n("Export filtered calendar")); 966 ex2phone.setCaption(i18n("Export filtered calendar"));
967 967
968 if ( !ex2phone.exec() ) { 968 if ( !ex2phone.exec() ) {
969 return; 969 return;
970 } 970 }
971 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 971 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
972 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 972 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
973 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 973 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
974 974
975 int inFuture = 0; 975 int inFuture = 0;
976 if ( ex2phone.mWriteBackFuture->isChecked() ) 976 if ( ex2phone.mWriteBackFuture->isChecked() )
977 inFuture = ex2phone.mWriteBackFutureWeeks->value(); 977 inFuture = ex2phone.mWriteBackFutureWeeks->value();
978 QPtrList<Incidence> delSel; 978 QPtrList<Incidence> delSel;
979 if ( mode == 1 ) 979 if ( mode == 1 )
980 delSel = mCalendar->rawIncidences(); 980 delSel = mCalendar->rawIncidences();
981 if ( mode == 2 ) 981 if ( mode == 2 )
982 delSel = mCalendar->incidences(); 982 delSel = mCalendar->incidences();
983 CalendarLocal* cal = new CalendarLocal(); 983 CalendarLocal* cal = new CalendarLocal();
984 cal->setLocalTime(); 984 cal->setLocalTime();
985 Incidence *incidence = delSel.first(); 985 Incidence *incidence = delSel.first();
986 QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); 986 QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
987 QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); 987 QDateTime end = cur.addDays( ( inFuture +1 ) *7 );
988 while ( incidence ) { 988 while ( incidence ) {
989 if ( incidence->type() != "Journal" ) { 989 if ( incidence->type() != "Journal" ) {
990 bool add = true; 990 bool add = true;
991 if ( inFuture ) { 991 if ( inFuture ) {
992 QDateTime dt; 992 QDateTime dt;
993 if ( incidence->type() == "Todo" ) { 993 if ( incidence->type() == "Todo" ) {
994 Todo * t = (Todo*)incidence; 994 Todo * t = (Todo*)incidence;
995 if ( t->hasDueDate() ) 995 if ( t->hasDueDate() )
996 dt = t->dtDue(); 996 dt = t->dtDue();
997 else 997 else
998 dt = cur.addSecs( 62 ); 998 dt = cur.addSecs( 62 );
999 } 999 }
1000 else { 1000 else {
1001 bool ok; 1001 bool ok;
1002 dt = incidence->getNextOccurence( cur, &ok ); 1002 dt = incidence->getNextOccurence( cur, &ok );
1003 if ( !ok ) 1003 if ( !ok )
1004 dt = cur.addSecs( -62 ); 1004 dt = cur.addSecs( -62 );
1005 } 1005 }
1006 if ( dt < cur || dt > end ) { 1006 if ( dt < cur || dt > end ) {
1007 add = false; 1007 add = false;
1008 } 1008 }
1009 } 1009 }
1010 if ( add ) { 1010 if ( add ) {
1011 Incidence *in = incidence->clone(); 1011 Incidence *in = incidence->clone();
1012 cal->addIncidence( in ); 1012 cal->addIncidence( in );
1013 } 1013 }
1014 } 1014 }
1015 incidence = delSel.next(); 1015 incidence = delSel.next();
1016 } 1016 }
1017 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 1017 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
1018 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 1018 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
1019 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1019 KPimGlobalPrefs::instance()->mEx2PhoneModel );
1020 1020
1021 setCaption( i18n("Writing to phone...")); 1021 setCaption( i18n("Writing to phone..."));
1022 if ( PhoneFormat::writeToPhone( cal ) ) 1022 if ( PhoneFormat::writeToPhone( cal ) )
1023 setCaption( i18n("Export to phone successful!")); 1023 setCaption( i18n("Export to phone successful!"));
1024 else 1024 else
1025 setCaption( i18n("Error exporting to phone!")); 1025 setCaption( i18n("Error exporting to phone!"));
1026 delete cal; 1026 delete cal;
1027} 1027}
1028 1028
1029 1029
1030void MainWindow::setDefaultPreferences() 1030void MainWindow::setDefaultPreferences()
1031{ 1031{
1032 KOPrefs *p = KOPrefs::instance(); 1032 KOPrefs *p = KOPrefs::instance();
1033 1033
1034 p->mCompactDialogs = true; 1034 p->mCompactDialogs = true;
1035 p->mConfirm = true; 1035 p->mConfirm = true;
1036 // p->mEnableQuickTodo = false; 1036 // p->mEnableQuickTodo = false;
1037 1037
1038} 1038}
1039 1039
1040QString MainWindow::resourcePath() 1040QString MainWindow::resourcePath()
1041{ 1041{
1042 return KGlobal::iconLoader()->iconPath(); 1042 return KGlobal::iconLoader()->iconPath();
1043} 1043}
1044 1044
1045void MainWindow::displayText( QString text ,QString cap ) 1045void MainWindow::displayText( QString text ,QString cap )
1046{ 1046{
1047 QDialog dia( this, "name", true ); ; 1047 QDialog dia( this, "name", true ); ;
1048 dia.setCaption( cap ); 1048 dia.setCaption( cap );
1049 QVBoxLayout* lay = new QVBoxLayout( &dia ); 1049 QVBoxLayout* lay = new QVBoxLayout( &dia );
1050 lay->setSpacing( 3 ); 1050 lay->setSpacing( 3 );
1051 lay->setMargin( 3 ); 1051 lay->setMargin( 3 );
1052 QTextBrowser tb ( &dia ); 1052 QTextBrowser tb ( &dia );
1053 lay->addWidget( &tb ); 1053 lay->addWidget( &tb );
1054 tb.setText( text ); 1054 tb.setText( text );
1055#ifdef DESKTOP_VERSION 1055#ifdef DESKTOP_VERSION
1056 dia.resize( 640, 480); 1056 dia.resize( 640, 480);
1057#else 1057#else
1058 dia.showMaximized(); 1058 dia.showMaximized();
1059#endif 1059#endif
1060 dia.exec(); 1060 dia.exec();
1061} 1061}
1062void MainWindow::displayFile( QString fn, QString cap ) 1062void MainWindow::displayFile( QString fn, QString cap )
1063{ 1063{
1064 QString fileName = resourcePath() + fn; 1064 QString fileName = resourcePath() + fn;
1065 QString text; 1065 QString text;
1066 QFile file( fileName ); 1066 QFile file( fileName );
1067 if (!file.open( IO_ReadOnly ) ) { 1067 if (!file.open( IO_ReadOnly ) ) {
1068 return ; 1068 return ;
1069 1069
1070 } 1070 }
1071 QTextStream ts( &file ); 1071 QTextStream ts( &file );
1072 text = ts.read(); 1072 text = ts.read();
1073 file.close(); 1073 file.close();
1074 displayText( text, cap); 1074 displayText( text, cap);
1075} 1075}
1076void MainWindow::features() 1076void MainWindow::features()
1077{ 1077{
1078 1078
1079 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); 1079 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") );
1080} 1080}
1081 1081
1082void MainWindow::usertrans() 1082void MainWindow::usertrans()
1083{ 1083{
1084 1084
1085 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); 1085 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") );
1086} 1086}
1087 1087
1088void MainWindow::synchowto() 1088void MainWindow::synchowto()
1089{ 1089{
1090#if 0 1090#if 0
1091 QPtrList<Incidence> er = mCalendar->rawIncidences(); 1091 QPtrList<Incidence> er = mCalendar->rawIncidences();
1092 Incidence* inR = er.first(); 1092 Incidence* inR = er.first();
1093 VCalFormat vf; 1093 VCalFormat vf;
1094 QString strout; 1094 QString strout;
1095 while ( inR ) { 1095 while ( inR ) {
1096 if ( inR->type() == "Todo" ) 1096 if ( inR->type() == "Todo" )
1097 strout = vf.todoToString( (Todo *) inR ); 1097 strout = vf.todoToString( (Todo *) inR );
1098 if ( inR->type() == "Event" ) 1098 if ( inR->type() == "Event" )
1099 strout = vf.eventToString( (Event *) inR ); 1099 strout = vf.eventToString( (Event *) inR );
1100 qDebug("incidence: \n%s\n ente\n\n",strout.latin1() ); 1100 qDebug("incidence: \n%s\n ente\n\n",strout.latin1() );
1101 inR = er.next(); 1101 inR = er.next();
1102 } 1102 }
1103#endif 1103#endif
1104 displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") ); 1104 displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") );
1105} 1105}
1106void MainWindow::faq() 1106void MainWindow::faq()
1107{ 1107{
1108 displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); 1108 displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") );
1109 1109
1110} 1110}
1111void MainWindow::whatsNew() 1111void MainWindow::whatsNew()
1112{ 1112{
1113 displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") ); 1113 displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") );
1114 1114
1115} 1115}
1116void MainWindow::licence() 1116void MainWindow::licence()
1117{ 1117{
1118 KApplication::showLicence(); 1118 KApplication::showLicence();
1119 1119
1120} 1120}
1121void MainWindow::about() 1121void MainWindow::about()
1122{ 1122{
1123 QString version; 1123 QString version;
1124#include <../version> 1124#include <../version>
1125 QMessageBox::about( this, i18n("About KOrganizer/Pi"), 1125 QMessageBox::about( this, i18n("About KOrganizer/Pi"),
1126 i18n("KOrganizer/Platform-independent\n") + 1126 i18n("KOrganizer/Platform-independent\n") +
1127 "(KO/Pi) " + version + " - " + 1127 "(KO/Pi) " + version + " - " +
1128 1128
1129#ifdef DESKTOP_VERSION 1129#ifdef DESKTOP_VERSION
1130 i18n("Desktop Edition\n") + 1130 i18n("Desktop Edition\n") +
1131#else 1131#else
1132 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + 1132 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") +
1133#endif 1133#endif
1134 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") ); 1134 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") );
1135} 1135}
1136void MainWindow::keyBindings() 1136void MainWindow::keyBindings()
1137{ 1137{
1138 QString cap = i18n("Key bindings KOrganizer/Pi"); 1138 QString cap = i18n("Key bindings KOrganizer/Pi");
1139 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + 1139 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") +
1140 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ 1140 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+
1141 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + 1141 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") +
1142 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ 1142 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+
1143 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ 1143 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+
1144 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ 1144 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+
1145 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ 1145 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+
1146 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ 1146 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+
1147 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ 1147 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+
1148 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ 1148 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+
1149 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ 1149 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+
1150 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ 1150 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+
1151 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ 1151 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+
1152 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ 1152 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+
1153 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ 1153 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+
1154 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ 1154 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+
1155 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ 1155 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+
1156 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ 1156 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+
1157 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ 1157 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+
1158 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ 1158 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+
1159 i18n("<p><h3>In agenda view:</h3></p>\n") + 1159 i18n("<p><h3>In agenda view:</h3></p>\n") +
1160 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ 1160 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+
1161 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ 1161 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+
1162 i18n("<p><h3>In todo view:</h3></p>\n") + 1162 i18n("<p><h3>In todo view:</h3></p>\n") +
1163 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ 1163 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+
1164 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1164 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1165 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ 1165 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+
1166 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ 1166 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+
1167 i18n("<p><h3>In list view:</h3></p>\n") + 1167 i18n("<p><h3>In list view:</h3></p>\n") +
1168 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1168 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1169 i18n("<p><b>return</b>: Select item+one step down</p>\n")+ 1169 i18n("<p><b>return</b>: Select item+one step down</p>\n")+
1170 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ 1170 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+
1171 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ 1171 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+
1172 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ 1172 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+
1173 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ 1173 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+
1174 i18n("<p><h3>In event/todo viewer:</h3></p>\n") + 1174 i18n("<p><h3>In event/todo viewer:</h3></p>\n") +
1175 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ 1175 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+
1176 i18n("<p><b>A</b>: Show agenda view.</p>\n")+ 1176 i18n("<p><b>A</b>: Show agenda view.</p>\n")+
1177 i18n("<p><b>E</b>: Edit item</p>\n") + 1177 i18n("<p><b>E</b>: Edit item</p>\n") +
1178 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + 1178 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") +
1179 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + 1179 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") +
1180 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ 1180 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+
1181 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ 1181 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+
1182 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ 1182 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+
1183 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ 1183 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+
1184 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ 1184 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+
1185 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + 1185 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") +
1186 i18n("<p><b>White</b>: Item readonly</p>\n"); 1186 i18n("<p><b>White</b>: Item readonly</p>\n");
1187 displayText( text, cap); 1187 displayText( text, cap);
1188 1188
1189} 1189}
1190void MainWindow::aboutAutoSaving() 1190void MainWindow::aboutAutoSaving()
1191{ 1191{
1192 QMessageBox* msg; 1192 QMessageBox* msg;
1193 msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), 1193 msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"),
1194 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, 1194 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,
1195 QMessageBox::Ok, 1195 QMessageBox::Ok,
1196 QMessageBox::NoButton, 1196 QMessageBox::NoButton,
1197 QMessageBox::NoButton); 1197 QMessageBox::NoButton);
1198 msg->exec(); 1198 msg->exec();
1199 delete msg; 1199 delete msg;
1200 1200
1201 1201
1202} 1202}
1203void MainWindow::aboutKnownBugs() 1203void MainWindow::aboutKnownBugs()
1204{ 1204{
1205 QMessageBox* msg; 1205 QMessageBox* msg;
1206 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), 1206 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"),
1207 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")+ 1207 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")+
1208 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ 1208 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+
1209 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + 1209 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") +
1210 i18n("\nor report them in the bugtracker on\n") + 1210 i18n("\nor report them in the bugtracker on\n") +
1211 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), 1211 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"),
1212 QMessageBox::NoIcon, 1212 QMessageBox::NoIcon,
1213 QMessageBox::Ok, 1213 QMessageBox::Ok,
1214 QMessageBox::NoButton, 1214 QMessageBox::NoButton,
1215 QMessageBox::NoButton); 1215 QMessageBox::NoButton);
1216 msg->exec(); 1216 msg->exec();
1217 delete msg; 1217 delete msg;
1218 1218
1219} 1219}
1220 1220
1221QString MainWindow::defaultFileName() 1221QString MainWindow::defaultFileName()
1222{ 1222{
1223 return locateLocal( "data", "korganizer/mycalendar.ics" ); 1223 return locateLocal( "data", "korganizer/mycalendar.ics" );
1224} 1224}
1225QString MainWindow::syncFileName() 1225QString MainWindow::syncFileName()
1226{ 1226{
1227#ifdef _WIN32_ 1227#ifdef _WIN32_
1228 return locateLocal( "tmp", "synccalendar.ics" ); 1228 return locateLocal( "tmp", "synccalendar.ics" );
1229#else 1229#else
1230 return QString( "/tmp/kopitempfile.ics" ); 1230 return QString( "/tmp/kopitempfile.ics" );
1231#endif 1231#endif
1232} 1232}
1233 1233
1234void MainWindow::processIncidenceSelection( Incidence *incidence ) 1234void MainWindow::processIncidenceSelection( Incidence *incidence )
1235{ 1235{
1236 if ( !incidence ) { 1236 if ( !incidence ) {
1237 enableIncidenceActions( false ); 1237 enableIncidenceActions( false );
1238 1238
1239 mNewSubTodoAction->setEnabled( false ); 1239 mNewSubTodoAction->setEnabled( false );
1240 setCaptionToDates(); 1240 setCaptionToDates();
1241 return; 1241 return;
1242 1242
1243 } 1243 }
1244 1244
1245 //KGlobal::locale()->formatDateTime(nextA, true); 1245 //KGlobal::locale()->formatDateTime(nextA, true);
1246 QString startString = ""; 1246 QString startString = "";
1247 if ( incidence->type() != "Todo" ) { 1247 if ( incidence->type() != "Todo" ) {
1248 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { 1248 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) {
1249 if ( incidence->doesFloat() ) { 1249 if ( incidence->doesFloat() ) {
1250 startString += ": "+incidence->dtStartDateStr( true ); 1250 startString += ": "+incidence->dtStartDateStr( true );
1251 startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); 1251 startString += " --- "+((Event*)incidence)->dtEndDateStr( true );
1252 1252
1253 } else { 1253 } else {
1254 startString = ": "+incidence->dtStartStr(true); 1254 startString = ": "+incidence->dtStartStr(true);
1255 startString += " --- "+((Event*)incidence)->dtEndStr(true); 1255 startString += " --- "+((Event*)incidence)->dtEndStr(true);
1256 1256
1257 } 1257 }
1258 1258
1259 } else { 1259 } else {
1260 if ( incidence->dtStart().time() != incidence->dtEnd().time() ) 1260 if ( incidence->dtStart().time() != incidence->dtEnd().time() )
1261 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ 1261 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+
1262 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); 1262 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time());
1263 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); 1263 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true);
1264 } 1264 }
1265 1265
1266 } 1266 }
1267 else 1267 else
1268 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); 1268 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed");
1269 if ( !incidence->location().isEmpty() ) 1269 if ( !incidence->location().isEmpty() )
1270 startString += " (" +incidence->location()+")"; 1270 startString += " (" +incidence->location()+")";
1271 setCaption( incidence->summary()+startString); 1271 setCaption( incidence->summary()+startString);
1272 1272
1273 enableIncidenceActions( true ); 1273 enableIncidenceActions( true );
1274 1274
1275 if ( incidence->type() == "Event" ) { 1275 if ( incidence->type() == "Event" ) {
1276 mShowAction->setText( i18n("Show Event...") ); 1276 mShowAction->setText( i18n("Show Event...") );
1277 mEditAction->setText( i18n("Edit Event...") ); 1277 mEditAction->setText( i18n("Edit Event...") );
1278 mDeleteAction->setText( i18n("Delete Event...") ); 1278 mDeleteAction->setText( i18n("Delete Event...") );
1279 1279
1280 mNewSubTodoAction->setEnabled( false ); 1280 mNewSubTodoAction->setEnabled( false );
1281 } else if ( incidence->type() == "Todo" ) { 1281 } else if ( incidence->type() == "Todo" ) {
1282 mShowAction->setText( i18n("Show Todo...") ); 1282 mShowAction->setText( i18n("Show Todo...") );
1283 mEditAction->setText( i18n("Edit Todo...") ); 1283 mEditAction->setText( i18n("Edit Todo...") );
1284 mDeleteAction->setText( i18n("Delete Todo...") ); 1284 mDeleteAction->setText( i18n("Delete Todo...") );
1285 1285
1286 mNewSubTodoAction->setEnabled( true ); 1286 mNewSubTodoAction->setEnabled( true );
1287 } else { 1287 } else {
1288 mShowAction->setText( i18n("Show...") ); 1288 mShowAction->setText( i18n("Show...") );
1289 mShowAction->setText( i18n("Edit...") ); 1289 mShowAction->setText( i18n("Edit...") );
1290 mShowAction->setText( i18n("Delete...") ); 1290 mShowAction->setText( i18n("Delete...") );
1291 1291
1292 mNewSubTodoAction->setEnabled( false ); 1292 mNewSubTodoAction->setEnabled( false );
1293 } 1293 }
1294} 1294}
1295 1295
1296void MainWindow::enableIncidenceActions( bool enabled ) 1296void MainWindow::enableIncidenceActions( bool enabled )
1297{ 1297{
1298 mShowAction->setEnabled( enabled ); 1298 mShowAction->setEnabled( enabled );
1299 mEditAction->setEnabled( enabled ); 1299 mEditAction->setEnabled( enabled );
1300 mDeleteAction->setEnabled( enabled ); 1300 mDeleteAction->setEnabled( enabled );
1301 1301
1302 mCloneAction->setEnabled( enabled ); 1302 mCloneAction->setEnabled( enabled );
1303 mMoveAction->setEnabled( enabled ); 1303 mMoveAction->setEnabled( enabled );
1304 mBeamAction->setEnabled( enabled ); 1304 mBeamAction->setEnabled( enabled );
1305 mCancelAction->setEnabled( enabled ); 1305 mCancelAction->setEnabled( enabled );
1306} 1306}
1307 1307
1308void MainWindow::importOL() 1308void MainWindow::importOL()
1309{ 1309{
1310#ifdef _WIN32_ 1310#ifdef _WIN32_
1311 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); 1311 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this );
1312 id->exec(); 1312 id->exec();
1313 delete id; 1313 delete id;
1314 mView->updateView(); 1314 mView->updateView();
1315#endif 1315#endif
1316} 1316}
1317void MainWindow::importBday() 1317void MainWindow::importBday()
1318{ 1318{
1319 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1319 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1320 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), 1320 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"),
1321 i18n("Import!"), i18n("Cancel"), 0, 1321 i18n("Import!"), i18n("Cancel"), 0,
1322 0, 1 ); 1322 0, 1 );
1323 if ( result == 0 ) { 1323 if ( result == 0 ) {
1324 mView->importBday(); 1324 mView->importBday();
1325 1325
1326 } 1326 }
1327 1327
1328 1328
1329} 1329}
1330void MainWindow::importQtopia() 1330void MainWindow::importQtopia()
1331{ 1331{
1332#ifndef DESKTOP_VERSION 1332#ifndef DESKTOP_VERSION
1333 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1333 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1334 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"), 1334 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"),
1335 i18n("Import!"), i18n("Cancel"), 0, 1335 i18n("Import!"), i18n("Cancel"), 0,
1336 0, 1 ); 1336 0, 1 );
1337 if ( result == 0 ) { 1337 if ( result == 0 ) {
1338 QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); 1338 QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
1339 QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); 1339 QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
1340 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; 1340 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
1341 mView->importQtopia( categories, datebook, todolist ); 1341 mView->importQtopia( categories, datebook, todolist );
1342 } 1342 }
1343#else 1343#else
1344 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1344 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1345 i18n("Not supported \non desktop!\n"), 1345 i18n("Not supported \non desktop!\n"),
1346 i18n("Ok"), i18n("Cancel"), 0, 1346 i18n("Ok"), i18n("Cancel"), 0,
1347 0, 1 ); 1347 0, 1 );
1348 1348
1349#endif 1349#endif
1350} 1350}
1351 1351
1352void MainWindow::saveOnClose() 1352void MainWindow::saveOnClose()
1353{ 1353{
1354 KOPrefs *p = KOPrefs::instance(); 1354 KOPrefs *p = KOPrefs::instance();
1355 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); 1355 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
1356 p->mToolBarUp = iconToolBar->x() > width()/2 || 1356 p->mToolBarUp = iconToolBar->x() > width()/2 ||
1357 iconToolBar->y() > height()/2; 1357 iconToolBar->y() > height()/2;
1358 mView->writeSettings(); 1358 mView->writeSettings();
1359 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) 1359 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName()))
1360 save(); 1360 save();
1361} 1361}
1362void MainWindow::slotModifiedChanged( bool changed ) 1362void MainWindow::slotModifiedChanged( bool changed )
1363{ 1363{
1364 if ( mBlockAtStartup ) 1364 if ( mBlockAtStartup )
1365 return; 1365 return;
1366 int msec; 1366 int msec;
1367 // we store the changes after 1 minute, 1367 // we store the changes after 1 minute,
1368 // and for safety reasons after 10 minutes again 1368 // and for safety reasons after 10 minutes again
1369 if ( !mSyncManager->blockSave() ) 1369 if ( !mSyncManager->blockSave() )
1370 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1370 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1371 else 1371 else
1372 msec = 1000 * 600; 1372 msec = 1000 * 600;
1373 mSaveTimer.start( msec, true ); // 1 minute 1373 mSaveTimer.start( msec, true ); // 1 minute
1374 qDebug("KO: Saving File in %d secs!", msec/1000); 1374 qDebug("KO: Saving File in %d secs!", msec/1000);
1375 mCalendarModifiedFlag = true; 1375 mCalendarModifiedFlag = true;
1376} 1376}
1377void MainWindow::save() 1377void MainWindow::save()
1378{ 1378{
1379 if ( mSyncManager->blockSave() ) 1379 if ( mSyncManager->blockSave() )
1380 return; 1380 return;
1381 mSyncManager->setBlockSave(true); 1381 mSyncManager->setBlockSave(true);
1382 if ( mView->checkFileVersion( defaultFileName()) ) { 1382 if ( mView->checkFileVersion( defaultFileName()) ) {
1383 1383
1384 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1384 QTime neededSaveTime = QDateTime::currentDateTime().time();
1385 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1385 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1386 qDebug("KO: Start saving data to file!"); 1386 qDebug("KO: Start saving data to file!");
1387 mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1388 mView->saveCalendar( defaultFileName() ); 1387 mView->saveCalendar( defaultFileName() );
1389 1388
1390 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 1389 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1391 mView->watchSavedFile();
1392 qDebug("KO: Needed %d ms for saving.",msNeeded ); 1390 qDebug("KO: Needed %d ms for saving.",msNeeded );
1393 QString savemes; 1391 QString savemes;
1394 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 1392 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
1395 setCaption(savemes); 1393 setCaption(savemes);
1396 } else 1394 } else
1397 setCaption(i18n("Saving cancelled!")); 1395 setCaption(i18n("Saving cancelled!"));
1398 mCalendarModifiedFlag = false; 1396 mCalendarModifiedFlag = false;
1399 mSyncManager->setBlockSave( false ); 1397 mSyncManager->setBlockSave( false );
1400} 1398}
1401 1399
1402void MainWindow::keyReleaseEvent ( QKeyEvent * e) 1400void MainWindow::keyReleaseEvent ( QKeyEvent * e)
1403{ 1401{
1404 if ( !e->isAutoRepeat() ) { 1402 if ( !e->isAutoRepeat() ) {
1405 mFlagKeyPressed = false; 1403 mFlagKeyPressed = false;
1406 } 1404 }
1407} 1405}
1408void MainWindow::keyPressEvent ( QKeyEvent * e ) 1406void MainWindow::keyPressEvent ( QKeyEvent * e )
1409{ 1407{
1410 qApp->processEvents(); 1408 qApp->processEvents();
1411 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 1409 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1412 e->ignore(); 1410 e->ignore();
1413 // qDebug(" ignore %d",e->isAutoRepeat() ); 1411 // qDebug(" ignore %d",e->isAutoRepeat() );
1414 return; 1412 return;
1415 } 1413 }
1416 if (! e->isAutoRepeat() ) 1414 if (! e->isAutoRepeat() )
1417 mFlagKeyPressed = true; 1415 mFlagKeyPressed = true;
1418 KOPrefs *p = KOPrefs::instance(); 1416 KOPrefs *p = KOPrefs::instance();
1419 bool showSelectedDates = false; 1417 bool showSelectedDates = false;
1420 int size; 1418 int size;
1421 int pro = 0; 1419 int pro = 0;
1422 //qDebug("MainWindow::keyPressEvent "); 1420 //qDebug("MainWindow::keyPressEvent ");
1423 switch ( e->key() ) { 1421 switch ( e->key() ) {
1424 case Qt::Key_Right: 1422 case Qt::Key_Right:
1425 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1423 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1426 mView->goNextMonth(); 1424 mView->goNextMonth();
1427 else 1425 else
1428 mView->goNext(); 1426 mView->goNext();
1429 showSelectedDates = true; 1427 showSelectedDates = true;
1430 break; 1428 break;
1431 case Qt::Key_Left: 1429 case Qt::Key_Left:
1432 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1430 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1433 mView->goPreviousMonth(); 1431 mView->goPreviousMonth();
1434 else 1432 else
1435 mView->goPrevious(); 1433 mView->goPrevious();
1436 showSelectedDates = true; 1434 showSelectedDates = true;
1437 break; 1435 break;
1438 case Qt::Key_Down: 1436 case Qt::Key_Down:
1439 mView->viewManager()->agendaView()->scrollOneHourDown(); 1437 mView->viewManager()->agendaView()->scrollOneHourDown();
1440 break; 1438 break;
1441 case Qt::Key_Up: 1439 case Qt::Key_Up:
1442 mView->viewManager()->agendaView()->scrollOneHourUp(); 1440 mView->viewManager()->agendaView()->scrollOneHourUp();
1443 break; 1441 break;
1444 case Qt::Key_I: 1442 case Qt::Key_I:
1445 mView->showIncidence(); 1443 mView->showIncidence();
1446 break; 1444 break;
1447 case Qt::Key_Delete: 1445 case Qt::Key_Delete:
1448 case Qt::Key_Backspace: 1446 case Qt::Key_Backspace:
1449 mView->deleteIncidence(); 1447 mView->deleteIncidence();
1450 break; 1448 break;
1451 case Qt::Key_D: 1449 case Qt::Key_D:
1452 mView->viewManager()->showDayView(); 1450 mView->viewManager()->showDayView();
1453 showSelectedDates = true; 1451 showSelectedDates = true;
1454 break; 1452 break;
1455 case Qt::Key_O: 1453 case Qt::Key_O:
1456 mView->toggleFilerEnabled( ); 1454 mView->toggleFilerEnabled( );
1457 break; 1455 break;
1458 case Qt::Key_0: 1456 case Qt::Key_0:
1459 case Qt::Key_1: 1457 case Qt::Key_1:
1460 case Qt::Key_2: 1458 case Qt::Key_2:
1461 case Qt::Key_3: 1459 case Qt::Key_3:
1462 case Qt::Key_4: 1460 case Qt::Key_4:
1463 case Qt::Key_5: 1461 case Qt::Key_5:
1464 case Qt::Key_6: 1462 case Qt::Key_6:
1465 case Qt::Key_7: 1463 case Qt::Key_7:
1466 case Qt::Key_8: 1464 case Qt::Key_8:
1467 case Qt::Key_9: 1465 case Qt::Key_9:
1468 pro = e->key()-48; 1466 pro = e->key()-48;
1469 if ( pro == 0 ) 1467 if ( pro == 0 )
1470 pro = 10; 1468 pro = 10;
1471 if ( e->state() == Qt::ControlButton) 1469 if ( e->state() == Qt::ControlButton)
1472 pro += 10; 1470 pro += 10;
1473 break; 1471 break;
1474 case Qt::Key_M: 1472 case Qt::Key_M:
1475 mView->viewManager()->showMonthView(); 1473 mView->viewManager()->showMonthView();
1476 showSelectedDates = true; 1474 showSelectedDates = true;
1477 break; 1475 break;
1478 case Qt::Key_Insert: 1476 case Qt::Key_Insert:
1479 mView->newEvent(); 1477 mView->newEvent();
1480 break; 1478 break;
1481 case Qt::Key_S : 1479 case Qt::Key_S :
1482 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1480 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1483 mView->newSubTodo(); 1481 mView->newSubTodo();
1484 else 1482 else
1485 mView->dialogManager()->showSearchDialog(); 1483 mView->dialogManager()->showSearchDialog();
1486 break; 1484 break;
1487 case Qt::Key_Y : 1485 case Qt::Key_Y :
1488 case Qt::Key_Z : 1486 case Qt::Key_Z :
1489 mView->viewManager()->showWorkWeekView(); 1487 mView->viewManager()->showWorkWeekView();
1490 showSelectedDates = true; 1488 showSelectedDates = true;
1491 break; 1489 break;
1492 case Qt::Key_U : 1490 case Qt::Key_U :
1493 mView->viewManager()->showWeekView(); 1491 mView->viewManager()->showWeekView();
1494 showSelectedDates = true; 1492 showSelectedDates = true;
1495 break; 1493 break;
1496 case Qt::Key_H : 1494 case Qt::Key_H :
1497 keyBindings(); 1495 keyBindings();
1498 break; 1496 break;
1499 case Qt::Key_W: 1497 case Qt::Key_W:
1500 mView->viewManager()->showWhatsNextView(); 1498 mView->viewManager()->showWhatsNextView();
1501 break; 1499 break;
1502 case Qt::Key_L: 1500 case Qt::Key_L:
1503 mView->viewManager()->showListView(); 1501 mView->viewManager()->showListView();
1504 break; 1502 break;
1505 case Qt::Key_N: 1503 case Qt::Key_N:
1506 mView->viewManager()->showNextXView(); 1504 mView->viewManager()->showNextXView();
1507 showSelectedDates = true; 1505 showSelectedDates = true;
1508 break; 1506 break;
1509 case Qt::Key_V: 1507 case Qt::Key_V:
1510 mView->viewManager()->showTodoView(); 1508 mView->viewManager()->showTodoView();
1511 break; 1509 break;
1512 case Qt::Key_C: 1510 case Qt::Key_C:
1513 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); 1511 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() );
1514 break; 1512 break;
1515 case Qt::Key_P: 1513 case Qt::Key_P:
1516 mView->showDatePicker( ); 1514 mView->showDatePicker( );
1517 break; 1515 break;
1518 case Qt::Key_F: 1516 case Qt::Key_F:
1519 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1517 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1520 mView->editFilters(); 1518 mView->editFilters();
1521 else 1519 else
1522 mView->toggleFilter(); 1520 mView->toggleFilter();
1523 break; 1521 break;
1524 case Qt::Key_X: 1522 case Qt::Key_X:
1525 mView->toggleDateNavigatorWidget(); 1523 mView->toggleDateNavigatorWidget();
1526 break; 1524 break;
1527 case Qt::Key_Space: 1525 case Qt::Key_Space:
1528 mView->toggleExpand(); 1526 mView->toggleExpand();
1529 break; 1527 break;
1530 case Qt::Key_A: 1528 case Qt::Key_A:
1531 mView->toggleAllDaySize(); 1529 mView->toggleAllDaySize();
1532 break; 1530 break;
1533 case Qt::Key_T: 1531 case Qt::Key_T:
1534 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1532 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1535 mView->newTodo(); 1533 mView->newTodo();
1536 else { 1534 else {
1537 mView->goToday(); 1535 mView->goToday();
1538 showSelectedDates = true; 1536 showSelectedDates = true;
1539 } 1537 }
1540 break; 1538 break;
1541 case Qt::Key_J: 1539 case Qt::Key_J:
1542 mView->viewManager()->showJournalView(); 1540 mView->viewManager()->showJournalView();
1543 break; 1541 break;
1544 case Qt::Key_B: 1542 case Qt::Key_B:
1545 mView->editIncidenceDescription();; 1543 mView->editIncidenceDescription();;
1546 break; 1544 break;
1547 // case Qt::Key_Return: 1545 // case Qt::Key_Return:
1548 case Qt::Key_E: 1546 case Qt::Key_E:
1549 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1547 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1550 mView->newEvent(); 1548 mView->newEvent();
1551 else 1549 else
1552 mView->editIncidence(); 1550 mView->editIncidence();
1553 break; 1551 break;
1554 case Qt::Key_Plus: 1552 case Qt::Key_Plus:
1555 size = p->mHourSize +2; 1553 size = p->mHourSize +2;
1556 if ( size <= 18 ) 1554 if ( size <= 18 )
1557 configureAgenda( size ); 1555 configureAgenda( size );
1558 break; 1556 break;
1559 case Qt::Key_Minus: 1557 case Qt::Key_Minus:
1560 size = p->mHourSize - 2; 1558 size = p->mHourSize - 2;
1561 if ( size >= 4 ) 1559 if ( size >= 4 )
1562 configureAgenda( size ); 1560 configureAgenda( size );
1563 break; 1561 break;
1564 1562
1565 1563
1566 default: 1564 default:
1567 e->ignore(); 1565 e->ignore();
1568 } 1566 }
1569 if ( pro > 0 ) { 1567 if ( pro > 0 ) {
1570 mView->selectFilter( pro-1 ); 1568 mView->selectFilter( pro-1 );
1571 } 1569 }
1572 if ( showSelectedDates ) { 1570 if ( showSelectedDates ) {
1573 ;// setCaptionToDates(); 1571 ;// setCaptionToDates();
1574 } 1572 }
1575 1573
1576} 1574}
1577 1575
1578void MainWindow::fillFilterMenu() 1576void MainWindow::fillFilterMenu()
1579{ 1577{
1580 selectFilterMenu->clear(); 1578 selectFilterMenu->clear();
1581 bool disable = false; 1579 bool disable = false;
1582 if ( mView->filterView()->filtersEnabled() ) { 1580 if ( mView->filterView()->filtersEnabled() ) {
1583 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 ); 1581 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 );
1584 } 1582 }
1585 else { 1583 else {
1586 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 ); 1584 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 );
1587 disable = true; 1585 disable = true;
1588 } 1586 }
1589 selectFilterMenu->insertSeparator(); 1587 selectFilterMenu->insertSeparator();
1590 QPtrList<CalFilter> fili = mView->filters(); 1588 QPtrList<CalFilter> fili = mView->filters();
1591 CalFilter *curfilter = mView->filterView()->selectedFilter(); 1589 CalFilter *curfilter = mView->filterView()->selectedFilter();
1592 CalFilter *filter = fili.first(); 1590 CalFilter *filter = fili.first();
1593 int iii = 1; 1591 int iii = 1;
1594 while(filter) { 1592 while(filter) {
1595 selectFilterMenu->insertItem( filter->name(), iii ); 1593 selectFilterMenu->insertItem( filter->name(), iii );
1596 if ( filter == curfilter) 1594 if ( filter == curfilter)
1597 selectFilterMenu->setItemChecked( iii, true ); 1595 selectFilterMenu->setItemChecked( iii, true );
1598 if ( disable ) 1596 if ( disable )
1599 selectFilterMenu->setItemEnabled( iii, false ); 1597 selectFilterMenu->setItemEnabled( iii, false );
1600 filter = fili.next(); 1598 filter = fili.next();
1601 ++iii; 1599 ++iii;
1602 } 1600 }
1603} 1601}
1604void MainWindow::selectFilter( int fil ) 1602void MainWindow::selectFilter( int fil )
1605{ 1603{
1606 if ( fil == 0 ) { 1604 if ( fil == 0 ) {
1607 mView->toggleFilerEnabled( ); 1605 mView->toggleFilerEnabled( );
1608 } else { 1606 } else {
1609 mView->selectFilter( fil-1 ); 1607 mView->selectFilter( fil-1 );
1610 } 1608 }
1611} 1609}
1612void MainWindow::configureToolBar( int item ) 1610void MainWindow::configureToolBar( int item )
1613{ 1611{
1614 1612
1615 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); 1613 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) );
1616 KOPrefs *p = KOPrefs::instance(); 1614 KOPrefs *p = KOPrefs::instance();
1617 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); 1615 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 );
1618 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); 1616 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 );
1619 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); 1617 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 );
1620 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); 1618 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 );
1621 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); 1619 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 );
1622 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); 1620 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 );
1623 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); 1621 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 );
1624 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); 1622 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 );
1625 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); 1623 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 );
1626 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); 1624 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 );
1627 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); 1625 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 );
1628 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); 1626 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 );
1629 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); 1627 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 );
1630 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); 1628 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 );
1631 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); 1629 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 );
1632 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); 1630 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 );
1633 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); 1631 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 );
1634 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); 1632 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 );
1635 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); 1633 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 );
1636 // initActions(); 1634 // initActions();
1637} 1635}
1638 1636
1639void MainWindow::setCaptionToDates() 1637void MainWindow::setCaptionToDates()
1640{ 1638{
1641 QString selDates; 1639 QString selDates;
1642 selDates = KGlobal::locale()->formatDate(mView->startDate(), true); 1640 selDates = KGlobal::locale()->formatDate(mView->startDate(), true);
1643 if (mView->startDate() < mView->endDate() ) 1641 if (mView->startDate() < mView->endDate() )
1644 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); 1642 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true);
1645 setCaption( i18n("Dates: ") + selDates ); 1643 setCaption( i18n("Dates: ") + selDates );
1646 1644
1647} 1645}
1648// parameter item == 0: reinit 1646// parameter item == 0: reinit
1649void MainWindow::configureAgenda( int item ) 1647void MainWindow::configureAgenda( int item )
1650{ 1648{
1651 1649
1652 KOPrefs *p = KOPrefs::instance(); 1650 KOPrefs *p = KOPrefs::instance();
1653 1651
1654 int i; 1652 int i;
1655 if ( item == 1 ) { 1653 if ( item == 1 ) {
1656 mView->toggleAllDaySize(); 1654 mView->toggleAllDaySize();
1657 return; 1655 return;
1658 } 1656 }
1659 // do not allow 4 for widgets higher than 480 1657 // do not allow 4 for widgets higher than 480
1660 // if ( QApplication::desktop()->height() > 480 ) { 1658 // if ( QApplication::desktop()->height() > 480 ) {
1661// if ( item == 4 ) 1659// if ( item == 4 )
1662// item = 6; 1660// item = 6;
1663// } 1661// }
1664 for ( i = 4; i <= 18; i= i+2 ) 1662 for ( i = 4; i <= 18; i= i+2 )
1665 configureAgendaMenu->setItemChecked( i, false ); 1663 configureAgendaMenu->setItemChecked( i, false );
1666 configureAgendaMenu->setItemChecked( item, true ); 1664 configureAgendaMenu->setItemChecked( item, true );
1667 if ( p->mHourSize == item ) 1665 if ( p->mHourSize == item )
1668 return; 1666 return;
1669 p->mHourSize=item; 1667 p->mHourSize=item;
1670 mView->viewManager()->agendaView()->updateConfig(); 1668 mView->viewManager()->agendaView()->updateConfig();
1671} 1669}
1672 1670
1673void MainWindow::saveCalendar() 1671void MainWindow::saveCalendar()
1674{ 1672{
1675 QString fn = KOPrefs::instance()->mLastSaveFile; 1673 QString fn = KOPrefs::instance()->mLastSaveFile;
1676 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); 1674 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this );
1677 1675
1678 if ( fn == "" ) 1676 if ( fn == "" )
1679 return; 1677 return;
1680 QFileInfo info; 1678 QFileInfo info;
1681 info.setFile( fn ); 1679 info.setFile( fn );
1682 QString mes; 1680 QString mes;
1683 bool createbup = true; 1681 bool createbup = true;
1684 if ( info. exists() ) { 1682 if ( info. exists() ) {
1685 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; 1683 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ;
1686 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1684 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1687 i18n("Overwrite!"), i18n("Cancel"), 0, 1685 i18n("Overwrite!"), i18n("Cancel"), 0,
1688 0, 1 ); 1686 0, 1 );
1689 if ( result != 0 ) { 1687 if ( result != 0 ) {
1690 createbup = false; 1688 createbup = false;
1691 } 1689 }
1692 } 1690 }
1693 if ( createbup ) { 1691 if ( createbup ) {
1694 mView->saveCalendar( fn ); 1692 mView->saveCalendar( fn );
1695 mes = i18n("KO/Pi:Saved %1").arg(fn); 1693 mes = i18n("KO/Pi:Saved %1").arg(fn);
1696 KOPrefs::instance()->mLastSaveFile = fn; 1694 KOPrefs::instance()->mLastSaveFile = fn;
1697 setCaption(mes); 1695 setCaption(mes);
1698 } 1696 }
1699} 1697}
1700void MainWindow::loadCalendar() 1698void MainWindow::loadCalendar()
1701{ 1699{
1702 1700
1703 QString fn = KOPrefs::instance()->mLastLoadFile; 1701 QString fn = KOPrefs::instance()->mLastLoadFile;
1704 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); 1702 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this );
1705 1703
1706 if ( fn == "" ) 1704 if ( fn == "" )
1707 return; 1705 return;
1708 QFileInfo info; 1706 QFileInfo info;
1709 info.setFile( fn ); 1707 info.setFile( fn );
1710 QString mess; 1708 QString mess;
1711 bool loadbup = true; 1709 bool loadbup = true;
1712 if ( info. exists() ) { 1710 if ( info. exists() ) {
1713 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1711 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1714 int result = QMessageBox::warning( this, "KO/Pi: Warning!", 1712 int result = QMessageBox::warning( this, "KO/Pi: Warning!",
1715 mess, 1713 mess,
1716 i18n("Load!"), i18n("Cancel"), 0, 1714 i18n("Load!"), i18n("Cancel"), 0,
1717 0, 1 ); 1715 0, 1 );
1718 if ( result != 0 ) { 1716 if ( result != 0 ) {
1719 loadbup = false; 1717 loadbup = false;
1720 } 1718 }
1721 } else { 1719 } else {
1722 QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1720 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1723 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, 1721 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0,
1724 0, 1 ); 1722 0, 1 );
1725 1723
1726 return; 1724 return;
1727 } 1725 }
1728 if ( loadbup ) { 1726 if ( loadbup ) {
1729 mView->openCalendar( fn ); 1727 mView->openCalendar( fn );
1730 KOPrefs::instance()->mLastLoadFile = fn; 1728 KOPrefs::instance()->mLastLoadFile = fn;
1731 mess = i18n("KO/Pi:Loaded %1").arg(fn) ; 1729 mess = i18n("KO/Pi:Loaded %1").arg(fn) ;
1732 setCaption(mess); 1730 setCaption(mess);
1733 } 1731 }
1734 1732
1735} 1733}
1736void MainWindow::quickImportIcal() 1734void MainWindow::quickImportIcal()
1737{ 1735{
1738 importFile( KOPrefs::instance()->mLastImportFile, false ); 1736 importFile( KOPrefs::instance()->mLastImportFile, false );
1739} 1737}
1740void MainWindow::importFile( QString fn, bool quick ) 1738void MainWindow::importFile( QString fn, bool quick )
1741{ 1739{
1742 QFileInfo info; 1740 QFileInfo info;
1743 info.setFile( fn ); 1741 info.setFile( fn );
1744 QString mess; 1742 QString mess;
1745 bool loadbup = true; 1743 bool loadbup = true;
1746 if ( !info. exists() ) { 1744 if ( !info. exists() ) {
1747 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); 1745 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30));
1748 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1746 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1749 mess ); 1747 mess );
1750 return; 1748 return;
1751 } 1749 }
1752 int result = 0; 1750 int result = 0;
1753 if ( !quick ) { 1751 if ( !quick ) {
1754 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 )); 1752 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 ));
1755 result = QMessageBox::warning( this, "KO/Pi: Warning!", 1753 result = QMessageBox::warning( this, "KO/Pi: Warning!",
1756 mess, 1754 mess,
1757 "Import", "Cancel", 0, 1755 "Import", "Cancel", 0,
1758 0, 1 ); 1756 0, 1 );
1759 } 1757 }
1760 if ( result == 0 ) { 1758 if ( result == 0 ) {
1761 if ( mView->openCalendar( fn, true )) { 1759 if ( mView->openCalendar( fn, true )) {
1762 KOPrefs::instance()->mLastImportFile = fn; 1760 KOPrefs::instance()->mLastImportFile = fn;
1763 setCaption(i18n("Imported file successfully")); 1761 setCaption(i18n("Imported file successfully"));
1764 } else { 1762 } else {
1765 setCaption(i18n("Error importing file")); 1763 setCaption(i18n("Error importing file"));
1766 } 1764 }
1767 } 1765 }
1768} 1766}
1769 1767
1770void MainWindow::importIcal() 1768void MainWindow::importIcal()
1771{ 1769{
1772 1770
1773 QString fn =KOPrefs::instance()->mLastImportFile; 1771 QString fn =KOPrefs::instance()->mLastImportFile;
1774 1772
1775 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); 1773 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this );
1776 if ( fn == "" ) 1774 if ( fn == "" )
1777 return; 1775 return;
1778 importFile( fn, true ); 1776 importFile( fn, true );
1779 1777
1780} 1778}
1781 1779
1782void MainWindow::exportVCalendar() 1780void MainWindow::exportVCalendar()
1783{ 1781{
1784 QString fn = KOPrefs::instance()->mLastVcalFile; 1782 QString fn = KOPrefs::instance()->mLastVcalFile;
1785 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); 1783 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this );
1786 if ( fn == "" ) 1784 if ( fn == "" )
1787 return; 1785 return;
1788 QFileInfo info; 1786 QFileInfo info;
1789 info.setFile( fn ); 1787 info.setFile( fn );
1790 QString mes; 1788 QString mes;
1791 bool createbup = true; 1789 bool createbup = true;
1792 if ( info. exists() ) { 1790 if ( info. exists() ) {
1793 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 1791 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
1794 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1792 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1795 i18n("Overwrite!"), i18n("Cancel"), 0, 1793 i18n("Overwrite!"), i18n("Cancel"), 0,
1796 0, 1 ); 1794 0, 1 );
1797 if ( result != 0 ) { 1795 if ( result != 0 ) {
1798 createbup = false; 1796 createbup = false;
1799 } 1797 }
1800 } 1798 }
1801 if ( createbup ) { 1799 if ( createbup ) {
1802 if ( mView->exportVCalendar( fn ) ) { 1800 if ( mView->exportVCalendar( fn ) ) {
1803 KOPrefs::instance()->mLastVcalFile = fn; 1801 KOPrefs::instance()->mLastVcalFile = fn;
1804 if ( fn.length() > 20 ) 1802 if ( fn.length() > 20 )
1805 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; 1803 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ;
1806 else 1804 else
1807 mes = i18n("KO/Pi:Exported to %1").arg(fn ); 1805 mes = i18n("KO/Pi:Exported to %1").arg(fn );
1808 setCaption(mes); 1806 setCaption(mes);
1809 } 1807 }
1810 } 1808 }
1811 1809
1812} 1810}
1813 1811
1814void MainWindow::syncFileRequest() 1812void MainWindow::syncFileRequest()
1815{ 1813{
1816 save(); 1814 save();
1817} 1815}
1818void MainWindow::getFile( bool success ) 1816void MainWindow::getFile( bool success )
1819{ 1817{
1820 if ( ! success ) { 1818 if ( ! success ) {
1821 setCaption( i18n("Error receiving file. Nothing changed!") ); 1819 setCaption( i18n("Error receiving file. Nothing changed!") );
1822 return; 1820 return;
1823 } 1821 }
1824 mView->watchSavedFile();
1825 mView->openCalendar( defaultFileName() ); 1822 mView->openCalendar( defaultFileName() );
1826 setCaption( i18n("Pi-Sync successful!") ); 1823 setCaption( i18n("Pi-Sync successful!") );
1827
1828} 1824}
1829 1825
1830void MainWindow::printSel( ) 1826void MainWindow::printSel( )
1831{ 1827{
1832 mView->viewManager()->agendaView()->agenda()->printSelection(); 1828 mView->viewManager()->agendaView()->agenda()->printSelection();
1833} 1829}
1834 1830
1835void MainWindow::printCal() 1831void MainWindow::printCal()
1836{ 1832{
1837 mView->print();//mCp->showDialog(); 1833 mView->print();//mCp->showDialog();
1838} 1834}
1839 1835