summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-08-07 17:37:12 (UTC)
committer zautrix <zautrix>2004-08-07 17:37:12 (UTC)
commit2219ddf2cb8022a24101e45ca439e65e95743388 (patch) (unidiff)
tree3e15d6b069a82901a5e032f641889b1870fc6ede
parent88b0d33b8b0b1f6ae320cfc863ca6a47fa8fec22 (diff)
downloadkdepimpi-2219ddf2cb8022a24101e45ca439e65e95743388.zip
kdepimpi-2219ddf2cb8022a24101e45ca439e65e95743388.tar.gz
kdepimpi-2219ddf2cb8022a24101e45ca439e65e95743388.tar.bz2
added gammu
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp42
-rw-r--r--korganizer/calendarview.h1
-rw-r--r--korganizer/mainwindow.cpp8
-rw-r--r--libkcal/libkcalE.pro2
-rw-r--r--libkcal/phoneformat.cpp1359
-rw-r--r--libkcal/phoneformat.h65
6 files changed, 1467 insertions, 10 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 689618d..a7f7010 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,3514 +1,3538 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Requires the Qt and KDE widget libraries, available at no cost at 4 Requires the Qt and KDE widget libraries, available at no cost at
5 http://www.troll.no and http://www.kde.org respectively 5 http://www.troll.no and http://www.kde.org respectively
6 6
7 Copyright (c) 1997, 1998, 1999 7 Copyright (c) 1997, 1998, 1999
8 Preston Brown (preston.brown@yale.edu) 8 Preston Brown (preston.brown@yale.edu)
9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) 9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl)
10 Ian Dawes (iadawes@globalserve.net) 10 Ian Dawes (iadawes@globalserve.net)
11 Laszlo Boloni (boloni@cs.purdue.edu) 11 Laszlo Boloni (boloni@cs.purdue.edu)
12 12
13 Copyright (c) 2000, 2001, 2002 13 Copyright (c) 2000, 2001, 2002
14 Cornelius Schumacher <schumacher@kde.org> 14 Cornelius Schumacher <schumacher@kde.org>
15 15
16 This program is free software; you can redistribute it and/or modify 16 This program is free software; you can redistribute it and/or modify
17 it under the terms of the GNU General Public License as published by 17 it under the terms of the GNU General Public License as published by
18 the Free Software Foundation; either version 2 of the License, or 18 the Free Software Foundation; either version 2 of the License, or
19 (at your option) any later version. 19 (at your option) any later version.
20 20
21 This program is distributed in the hope that it will be useful, 21 This program is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of 22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
24 GNU General Public License for more details. 24 GNU General Public License for more details.
25 25
26 You should have received a copy of the GNU General Public License 26 You should have received a copy of the GNU General Public License
27 along with this program; if not, write to the Free Software 27 along with this program; if not, write to the Free Software
28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29*/ 29*/
30 30
31#include <stdlib.h> 31#include <stdlib.h>
32 32
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qradiobutton.h> 34#include <qradiobutton.h>
35#include <qbuttongroup.h> 35#include <qbuttongroup.h>
36#include <qlayout.h> 36#include <qlayout.h>
37#include <qclipboard.h> 37#include <qclipboard.h>
38#include <qcursor.h> 38#include <qcursor.h>
39#include <qmessagebox.h> 39#include <qmessagebox.h>
40#include <qprogressbar.h> 40#include <qprogressbar.h>
41#include <qmultilineedit.h> 41#include <qmultilineedit.h>
42#include <qtimer.h> 42#include <qtimer.h>
43#include <qwidgetstack.h> 43#include <qwidgetstack.h>
44#include <qptrlist.h> 44#include <qptrlist.h>
45#include <qregexp.h> 45#include <qregexp.h>
46#include <qgroupbox.h> 46#include <qgroupbox.h>
47#include <qfile.h> 47#include <qfile.h>
48#include <qdir.h> 48#include <qdir.h>
49#ifndef KORG_NOSPLITTER 49#ifndef KORG_NOSPLITTER
50#include <qsplitter.h> 50#include <qsplitter.h>
51#endif 51#endif
52 52
53#include <kglobal.h> 53#include <kglobal.h>
54#include <kdebug.h> 54#include <kdebug.h>
55#include <kstandarddirs.h> 55#include <kstandarddirs.h>
56#include <kfiledialog.h> 56#include <kfiledialog.h>
57#include <kmessagebox.h> 57#include <kmessagebox.h>
58#include <knotifyclient.h> 58#include <knotifyclient.h>
59#include <kconfig.h> 59#include <kconfig.h>
60 60
61#include <libkdepim/ksyncprefsdialog.h> 61#include <libkdepim/ksyncprefsdialog.h>
62#include <krun.h> 62#include <krun.h>
63#include <kdirwatch.h> 63#include <kdirwatch.h>
64#include <libkdepim/kdatepicker.h> 64#include <libkdepim/kdatepicker.h>
65#include <libkdepim/ksyncprofile.h> 65#include <libkdepim/ksyncprofile.h>
66 66
67#include <libkcal/vcaldrag.h> 67#include <libkcal/vcaldrag.h>
68#include <libkcal/icaldrag.h> 68#include <libkcal/icaldrag.h>
69#include <libkcal/icalformat.h> 69#include <libkcal/icalformat.h>
70#include <libkcal/vcalformat.h> 70#include <libkcal/vcalformat.h>
71#include <libkcal/scheduler.h> 71#include <libkcal/scheduler.h>
72#include <libkcal/calendarlocal.h> 72#include <libkcal/calendarlocal.h>
73#include <libkcal/journal.h> 73#include <libkcal/journal.h>
74#include <libkcal/calfilter.h> 74#include <libkcal/calfilter.h>
75#include <libkcal/attendee.h> 75#include <libkcal/attendee.h>
76#include <libkcal/dndfactory.h> 76#include <libkcal/dndfactory.h>
77#include <libkcal/freebusy.h> 77#include <libkcal/freebusy.h>
78#include <libkcal/filestorage.h> 78#include <libkcal/filestorage.h>
79#include <libkcal/calendarresources.h> 79#include <libkcal/calendarresources.h>
80#include <libkcal/qtopiaformat.h> 80#include <libkcal/qtopiaformat.h>
81#include "../kalarmd/alarmdialog.h" 81#include "../kalarmd/alarmdialog.h"
82 82
83#ifndef DESKTOP_VERSION 83#ifndef DESKTOP_VERSION
84#include <libkcal/sharpformat.h> 84#include <libkcal/sharpformat.h>
85#endif 85#endif
86#include <libkcal/phoneformat.h>
86#ifndef KORG_NOMAIL 87#ifndef KORG_NOMAIL
87#include "komailclient.h" 88#include "komailclient.h"
88#endif 89#endif
89#ifndef KORG_NOPRINTER 90#ifndef KORG_NOPRINTER
90#include "calprinter.h" 91#include "calprinter.h"
91#endif 92#endif
92#ifndef KORG_NOPLUGINS 93#ifndef KORG_NOPLUGINS
93#include "kocore.h" 94#include "kocore.h"
94#endif 95#endif
95#include "koeventeditor.h" 96#include "koeventeditor.h"
96#include "kotodoeditor.h" 97#include "kotodoeditor.h"
97#include "koprefs.h" 98#include "koprefs.h"
98#include "koeventviewerdialog.h" 99#include "koeventviewerdialog.h"
99#include "publishdialog.h" 100#include "publishdialog.h"
100#include "kofilterview.h" 101#include "kofilterview.h"
101#include "koglobals.h" 102#include "koglobals.h"
102#include "koviewmanager.h" 103#include "koviewmanager.h"
103#include "koagendaview.h" 104#include "koagendaview.h"
104#include "kodialogmanager.h" 105#include "kodialogmanager.h"
105#include "outgoingdialog.h" 106#include "outgoingdialog.h"
106#include "incomingdialog.h" 107#include "incomingdialog.h"
107#include "statusdialog.h" 108#include "statusdialog.h"
108#include "kdatenavigator.h" 109#include "kdatenavigator.h"
109#include "kotodoview.h" 110#include "kotodoview.h"
110#include "datenavigator.h" 111#include "datenavigator.h"
111#include "resourceview.h" 112#include "resourceview.h"
112#include "navigatorbar.h" 113#include "navigatorbar.h"
113#include "searchdialog.h" 114#include "searchdialog.h"
114#include "mainwindow.h" 115#include "mainwindow.h"
115 116
116#include "calendarview.h" 117#include "calendarview.h"
117#ifndef DESKTOP_VERSION 118#ifndef DESKTOP_VERSION
118#include <qtopia/alarmserver.h> 119#include <qtopia/alarmserver.h>
119#endif 120#endif
120#ifndef _WIN32_ 121#ifndef _WIN32_
121#include <stdlib.h> 122#include <stdlib.h>
122#include <stdio.h> 123#include <stdio.h>
123#include <unistd.h> 124#include <unistd.h>
124#else 125#else
125#include <qprocess.h> 126#include <qprocess.h>
126#endif 127#endif
127using namespace KOrg; 128using namespace KOrg;
128using namespace KCal; 129using namespace KCal;
129extern int globalFlagBlockAgenda; 130extern int globalFlagBlockAgenda;
130extern int globalFlagBlockStartup; 131extern int globalFlagBlockStartup;
131 132
132 133
133 134
134class KOBeamPrefs : public QDialog 135class KOBeamPrefs : public QDialog
135{ 136{
136 public: 137 public:
137 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : 138 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) :
138 QDialog( parent, name, true ) 139 QDialog( parent, name, true )
139 { 140 {
140 setCaption( i18n("Beam Options") ); 141 setCaption( i18n("Beam Options") );
141 QVBoxLayout* lay = new QVBoxLayout( this ); 142 QVBoxLayout* lay = new QVBoxLayout( this );
142 lay->setSpacing( 3 ); 143 lay->setSpacing( 3 );
143 lay->setMargin( 3 ); 144 lay->setMargin( 3 );
144 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); 145 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this );
145 lay->addWidget( format ); 146 lay->addWidget( format );
146 format->setExclusive ( true ) ; 147 format->setExclusive ( true ) ;
147 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); 148 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this );
148 lay->addWidget( time ); time->setExclusive ( true ) ; 149 lay->addWidget( time ); time->setExclusive ( true ) ;
149 vcal = new QRadioButton(" vCalendar ", format ); 150 vcal = new QRadioButton(" vCalendar ", format );
150 ical = new QRadioButton(" iCalendar ", format ); 151 ical = new QRadioButton(" iCalendar ", format );
151 vcal->setChecked( true ); 152 vcal->setChecked( true );
152 tz = new QRadioButton(i18n(" With timezone "), time ); 153 tz = new QRadioButton(i18n(" With timezone "), time );
153 local = new QRadioButton(i18n(" Local time "), time ); 154 local = new QRadioButton(i18n(" Local time "), time );
154 tz->setChecked( true ); 155 tz->setChecked( true );
155 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); 156 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this );
156 lay->addWidget( ok ); 157 lay->addWidget( ok );
157 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 158 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
158 lay->addWidget( cancel ); 159 lay->addWidget( cancel );
159 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 160 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
160 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 161 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
161 resize( 200, 200 ); 162 resize( 200, 200 );
162 } 163 }
163 164
164 bool beamVcal() { return vcal->isChecked(); } 165 bool beamVcal() { return vcal->isChecked(); }
165 bool beamLocal() { return local->isChecked(); } 166 bool beamLocal() { return local->isChecked(); }
166private: 167private:
167 QRadioButton* vcal, *ical, *local, *tz; 168 QRadioButton* vcal, *ical, *local, *tz;
168}; 169};
169class KOCatPrefs : public QDialog 170class KOCatPrefs : public QDialog
170{ 171{
171 public: 172 public:
172 KOCatPrefs( QWidget *parent=0, const char *name=0 ) : 173 KOCatPrefs( QWidget *parent=0, const char *name=0 ) :
173 QDialog( parent, name, true ) 174 QDialog( parent, name, true )
174 { 175 {
175 setCaption( i18n("Manage new Categories") ); 176 setCaption( i18n("Manage new Categories") );
176 QVBoxLayout* lay = new QVBoxLayout( this ); 177 QVBoxLayout* lay = new QVBoxLayout( this );
177 lay->setSpacing( 3 ); 178 lay->setSpacing( 3 );
178 lay->setMargin( 3 ); 179 lay->setMargin( 3 );
179 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); 180 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this );
180 lay->addWidget( lab ); 181 lay->addWidget( lab );
181 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 182 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
182 lay->addWidget( format ); 183 lay->addWidget( format );
183 format->setExclusive ( true ) ; 184 format->setExclusive ( true ) ;
184 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 185 addCatBut = new QRadioButton(i18n("Add to category list"), format );
185 new QRadioButton(i18n("Remove from Events/Todos"), format ); 186 new QRadioButton(i18n("Remove from Events/Todos"), format );
186 addCatBut->setChecked( true ); 187 addCatBut->setChecked( true );
187 QPushButton * ok = new QPushButton( i18n("OK"), this ); 188 QPushButton * ok = new QPushButton( i18n("OK"), this );
188 lay->addWidget( ok ); 189 lay->addWidget( ok );
189 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 190 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
190 lay->addWidget( cancel ); 191 lay->addWidget( cancel );
191 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 192 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
192 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 193 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
193 resize( 200, 200 ); 194 resize( 200, 200 );
194 } 195 }
195 196
196 bool addCat() { return addCatBut->isChecked(); } 197 bool addCat() { return addCatBut->isChecked(); }
197private: 198private:
198 QRadioButton* addCatBut; 199 QRadioButton* addCatBut;
199}; 200};
200 201
201 202
202 203
203CalendarView::CalendarView( CalendarResources *calendar, 204CalendarView::CalendarView( CalendarResources *calendar,
204 QWidget *parent, const char *name ) 205 QWidget *parent, const char *name )
205 : CalendarViewBase( parent, name ), 206 : CalendarViewBase( parent, name ),
206 mCalendar( calendar ), 207 mCalendar( calendar ),
207 mResourceManager( calendar->resourceManager() ) 208 mResourceManager( calendar->resourceManager() )
208{ 209{
209 210
210 mEventEditor = 0; 211 mEventEditor = 0;
211 mTodoEditor = 0; 212 mTodoEditor = 0;
212 213
213 init(); 214 init();
214} 215}
215 216
216CalendarView::CalendarView( Calendar *calendar, 217CalendarView::CalendarView( Calendar *calendar,
217 QWidget *parent, const char *name ) 218 QWidget *parent, const char *name )
218 : CalendarViewBase( parent, name ), 219 : CalendarViewBase( parent, name ),
219 mCalendar( calendar ), 220 mCalendar( calendar ),
220 mResourceManager( 0 ) 221 mResourceManager( 0 )
221{ 222{
222 223
223 mEventEditor = 0; 224 mEventEditor = 0;
224 mTodoEditor = 0; 225 mTodoEditor = 0;
225 init();} 226 init();}
226 227
227void CalendarView::init() 228void CalendarView::init()
228{ 229{
229 beamDialog = new KOBeamPrefs(); 230 beamDialog = new KOBeamPrefs();
230 mDatePickerMode = 0; 231 mDatePickerMode = 0;
231 mCurrentSyncDevice = ""; 232 mCurrentSyncDevice = "";
232 writeLocale(); 233 writeLocale();
233 mViewManager = new KOViewManager( this ); 234 mViewManager = new KOViewManager( this );
234 mDialogManager = new KODialogManager( this ); 235 mDialogManager = new KODialogManager( this );
235 mEventViewerDialog = 0; 236 mEventViewerDialog = 0;
236 mModified = false; 237 mModified = false;
237 mReadOnly = false; 238 mReadOnly = false;
238 mSelectedIncidence = 0; 239 mSelectedIncidence = 0;
239 mCalPrinter = 0; 240 mCalPrinter = 0;
240 mFilters.setAutoDelete(true); 241 mFilters.setAutoDelete(true);
241 242
242 mCalendar->registerObserver( this ); 243 mCalendar->registerObserver( this );
243 // TODO: Make sure that view is updated, when calendar is changed. 244 // TODO: Make sure that view is updated, when calendar is changed.
244 245
245 mStorage = new FileStorage( mCalendar ); 246 mStorage = new FileStorage( mCalendar );
246 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 247 mNavigator = new DateNavigator( this, "datevav", mViewManager );
247 248
248 QBoxLayout *topLayout = (QBoxLayout*)layout(); 249 QBoxLayout *topLayout = (QBoxLayout*)layout();
249#ifndef KORG_NOSPLITTER 250#ifndef KORG_NOSPLITTER
250 // create the main layout frames. 251 // create the main layout frames.
251 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 252 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
252 topLayout->addWidget(mPanner); 253 topLayout->addWidget(mPanner);
253 254
254 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 255 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
255 "CalendarView::LeftFrame"); 256 "CalendarView::LeftFrame");
256 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 257 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
257 258
258 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, 259 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE,
259 "CalendarView::DateNavigator", QDate::currentDate() ); 260 "CalendarView::DateNavigator", QDate::currentDate() );
260 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 261 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
261 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 262 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
262 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 263 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
263 264
264#ifdef KORG_NORESOURCEVIEW 265#ifdef KORG_NORESOURCEVIEW
265 mResourceView = 0; 266 mResourceView = 0;
266#else 267#else
267 if ( mResourceManager ) { 268 if ( mResourceManager ) {
268 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 269 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
269 mResourceView->updateView(); 270 mResourceView->updateView();
270 connect( mResourceView, SIGNAL( resourcesChanged() ), 271 connect( mResourceView, SIGNAL( resourcesChanged() ),
271 SLOT( updateView() ) ); 272 SLOT( updateView() ) );
272 } else { 273 } else {
273 mResourceView = 0; 274 mResourceView = 0;
274 } 275 }
275#endif 276#endif
276 QWidget *rightBox = new QWidget( mPanner ); 277 QWidget *rightBox = new QWidget( mPanner );
277 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 278 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
278 279
279 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 280 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
280 rightLayout->addWidget( mNavigatorBar ); 281 rightLayout->addWidget( mNavigatorBar );
281 282
282 mRightFrame = new QWidgetStack( rightBox ); 283 mRightFrame = new QWidgetStack( rightBox );
283 rightLayout->addWidget( mRightFrame, 1 ); 284 rightLayout->addWidget( mRightFrame, 1 );
284 285
285 mLeftFrame = mLeftSplitter; 286 mLeftFrame = mLeftSplitter;
286#else 287#else
287 QWidget *mainBox = new QWidget( this ); 288 QWidget *mainBox = new QWidget( this );
288 QWidget *leftFrame = new QWidget( mainBox ); 289 QWidget *leftFrame = new QWidget( mainBox );
289 290
290 QBoxLayout * mainBoxLayout; 291 QBoxLayout * mainBoxLayout;
291 QBoxLayout * leftFrameLayout; 292 QBoxLayout * leftFrameLayout;
292 if ( KOPrefs::instance()->mVerticalScreen ) { 293 if ( KOPrefs::instance()->mVerticalScreen ) {
293 mainBoxLayout = new QVBoxLayout(mainBox); 294 mainBoxLayout = new QVBoxLayout(mainBox);
294 leftFrameLayout = new QHBoxLayout(leftFrame ); 295 leftFrameLayout = new QHBoxLayout(leftFrame );
295 } else { 296 } else {
296 mainBoxLayout = new QHBoxLayout(mainBox); 297 mainBoxLayout = new QHBoxLayout(mainBox);
297 leftFrameLayout = new QVBoxLayout(leftFrame ); 298 leftFrameLayout = new QVBoxLayout(leftFrame );
298 } 299 }
299 topLayout->addWidget( mainBox ); 300 topLayout->addWidget( mainBox );
300 mainBoxLayout->addWidget (leftFrame); 301 mainBoxLayout->addWidget (leftFrame);
301 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, 302 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE,
302 "CalendarView::DateNavigator", QDate::currentDate()); 303 "CalendarView::DateNavigator", QDate::currentDate());
303 // mDateNavigator->blockSignals( true ); 304 // mDateNavigator->blockSignals( true );
304 leftFrameLayout->addWidget( mDateNavigator ); 305 leftFrameLayout->addWidget( mDateNavigator );
305 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); 306 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView");
306 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolist"); 307 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolist");
307 308
308 if ( QApplication::desktop()->width() < 480 ) { 309 if ( QApplication::desktop()->width() < 480 ) {
309 leftFrameLayout->addWidget(mFilterView); 310 leftFrameLayout->addWidget(mFilterView);
310 leftFrameLayout->addWidget(mTodoList, 2 ); 311 leftFrameLayout->addWidget(mTodoList, 2 );
311 312
312 } else { 313 } else {
313 leftFrameLayout->addWidget(mTodoList,2 ); 314 leftFrameLayout->addWidget(mTodoList,2 );
314 leftFrameLayout->addWidget(mFilterView ); 315 leftFrameLayout->addWidget(mFilterView );
315 } 316 }
316 mFilterView->hide(); 317 mFilterView->hide();
317 QWidget *rightBox = new QWidget( mainBox ); 318 QWidget *rightBox = new QWidget( mainBox );
318 mainBoxLayout->addWidget ( rightBox, 10 ); 319 mainBoxLayout->addWidget ( rightBox, 10 );
319 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 320 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
320 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 321 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
321 mRightFrame = new QWidgetStack( rightBox ); 322 mRightFrame = new QWidgetStack( rightBox );
322 rightLayout->addWidget( mNavigatorBar ); 323 rightLayout->addWidget( mNavigatorBar );
323 rightLayout->addWidget( mRightFrame, 10 ); 324 rightLayout->addWidget( mRightFrame, 10 );
324 325
325 mLeftFrame = leftFrame; 326 mLeftFrame = leftFrame;
326 if ( KOPrefs::instance()->mVerticalScreen ) { 327 if ( KOPrefs::instance()->mVerticalScreen ) {
327 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 328 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
328 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 329 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
329 } else { 330 } else {
330 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 331 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
331 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 332 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
332 } 333 }
333 334
334 //qDebug("Calendarview Size %d %d ", width(), height()); 335 //qDebug("Calendarview Size %d %d ", width(), height());
335#endif 336#endif
336 337
337 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 338 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
338 SLOT( showDates( const KCal::DateList & ) ) ); 339 SLOT( showDates( const KCal::DateList & ) ) );
339 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 340 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
340 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 341 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
341 342
342 connect( mNavigatorBar, SIGNAL( goPrevYear() ), 343 connect( mNavigatorBar, SIGNAL( goPrevYear() ),
343 mNavigator, SLOT( selectPreviousYear() ) ); 344 mNavigator, SLOT( selectPreviousYear() ) );
344 connect( mNavigatorBar, SIGNAL( goNextYear() ), 345 connect( mNavigatorBar, SIGNAL( goNextYear() ),
345 mNavigator, SLOT( selectNextYear() ) ); 346 mNavigator, SLOT( selectNextYear() ) );
346 connect( mNavigatorBar, SIGNAL( goPrevMonth() ), 347 connect( mNavigatorBar, SIGNAL( goPrevMonth() ),
347 mNavigator, SLOT( selectPreviousMonth() ) ); 348 mNavigator, SLOT( selectPreviousMonth() ) );
348 connect( mNavigatorBar, SIGNAL( goNextMonth() ), 349 connect( mNavigatorBar, SIGNAL( goNextMonth() ),
349 mNavigator, SLOT( selectNextMonth() ) ); 350 mNavigator, SLOT( selectNextMonth() ) );
350 351
351 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 352 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
352 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); 353 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) );
353 354
354 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 355 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
355 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 356 mNavigator, SLOT( selectWeek( const QDate & ) ) );
356 357
357 connect( mDateNavigator, SIGNAL( goPrevYear() ), 358 connect( mDateNavigator, SIGNAL( goPrevYear() ),
358 mNavigator, SLOT( selectPreviousYear() ) ); 359 mNavigator, SLOT( selectPreviousYear() ) );
359 connect( mDateNavigator, SIGNAL( goNextYear() ), 360 connect( mDateNavigator, SIGNAL( goNextYear() ),
360 mNavigator, SLOT( selectNextYear() ) ); 361 mNavigator, SLOT( selectNextYear() ) );
361 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 362 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
362 mNavigator, SLOT( selectPreviousMonth() ) ); 363 mNavigator, SLOT( selectPreviousMonth() ) );
363 connect( mDateNavigator, SIGNAL( goNextMonth() ), 364 connect( mDateNavigator, SIGNAL( goNextMonth() ),
364 mNavigator, SLOT( selectNextMonth() ) ); 365 mNavigator, SLOT( selectNextMonth() ) );
365 366
366 connect( mDateNavigator, SIGNAL( goPrevious() ), 367 connect( mDateNavigator, SIGNAL( goPrevious() ),
367 mNavigator, SLOT( selectPrevious() ) ); 368 mNavigator, SLOT( selectPrevious() ) );
368 connect( mDateNavigator, SIGNAL( goNext() ), 369 connect( mDateNavigator, SIGNAL( goNext() ),
369 mNavigator, SLOT( selectNext() ) ); 370 mNavigator, SLOT( selectNext() ) );
370 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 371 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
371 mNavigator, SLOT( slotMonthSelect( int ) ) ); 372 mNavigator, SLOT( slotMonthSelect( int ) ) );
372 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), 373 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ),
373 mNavigator, SLOT( slotMonthSelect( int ) ) ); 374 mNavigator, SLOT( slotMonthSelect( int ) ) );
374 375
375 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 376 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
376 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 377 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
377 378
378 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), 379 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ),
379 SLOT( eventAdded( Event *) ) ); 380 SLOT( eventAdded( Event *) ) );
380 381
381 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 382 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
382 383
383 connect( this, SIGNAL( configChanged() ), 384 connect( this, SIGNAL( configChanged() ),
384 mDateNavigator, SLOT( updateConfig() ) ); 385 mDateNavigator, SLOT( updateConfig() ) );
385 386
386 connect( mTodoList, SIGNAL( newTodoSignal() ), 387 connect( mTodoList, SIGNAL( newTodoSignal() ),
387 SLOT( newTodo() ) ); 388 SLOT( newTodo() ) );
388 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 389 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
389 SLOT( newSubTodo( Todo * ) ) ); 390 SLOT( newSubTodo( Todo * ) ) );
390 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 391 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
391 SLOT( editTodo( Todo * ) ) ); 392 SLOT( editTodo( Todo * ) ) );
392 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 393 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
393 SLOT( showTodo( Todo *) ) ); 394 SLOT( showTodo( Todo *) ) );
394 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 395 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
395 SLOT( deleteTodo( Todo *) ) ); 396 SLOT( deleteTodo( Todo *) ) );
396 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 397 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
397 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 398 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
398 SLOT( purgeCompleted() ) ); 399 SLOT( purgeCompleted() ) );
399 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 400 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
400 SIGNAL( todoModified( Todo *, int ) ) ); 401 SIGNAL( todoModified( Todo *, int ) ) );
401 402
402 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 403 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
403 this, SLOT ( cloneIncidence( Incidence * ) ) ); 404 this, SLOT ( cloneIncidence( Incidence * ) ) );
404 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 405 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
405 this, SLOT (cancelIncidence( Incidence * ) ) ); 406 this, SLOT (cancelIncidence( Incidence * ) ) );
406 407
407 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 408 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
408 this, SLOT ( moveIncidence( Incidence * ) ) ); 409 this, SLOT ( moveIncidence( Incidence * ) ) );
409 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 410 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
410 this, SLOT ( beamIncidence( Incidence * ) ) ); 411 this, SLOT ( beamIncidence( Incidence * ) ) );
411 412
412 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 413 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
413 this, SLOT ( todo_unsub( Todo * ) ) ); 414 this, SLOT ( todo_unsub( Todo * ) ) );
414 415
415 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 416 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
416 SLOT( updateTodo( Todo *, int ) ) ); 417 SLOT( updateTodo( Todo *, int ) ) );
417 connect( this, SIGNAL( todoModified( Todo *, int )), this, 418 connect( this, SIGNAL( todoModified( Todo *, int )), this,
418 SLOT( changeTodoDisplay( Todo *, int ) ) ); 419 SLOT( changeTodoDisplay( Todo *, int ) ) );
419 420
420 421
421 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 422 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
422 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 423 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
423 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 424 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
424 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 425 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
425 426
426 427
427 428
428 429
429 430
430 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 431 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
431 SLOT(checkClipboard())); 432 SLOT(checkClipboard()));
432 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 433 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
433 SLOT( processTodoListSelection( Incidence * ) ) ); 434 SLOT( processTodoListSelection( Incidence * ) ) );
434 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 435 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
435 436
436 // kdDebug() << "CalendarView::CalendarView() done" << endl; 437 // kdDebug() << "CalendarView::CalendarView() done" << endl;
437 438
438 mDateFrame = new QVBox(0,0,WType_Popup); 439 mDateFrame = new QVBox(0,0,WType_Popup);
439 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 440 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
440 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 441 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
441 mDateFrame->setLineWidth(3); 442 mDateFrame->setLineWidth(3);
442 mDateFrame->hide(); 443 mDateFrame->hide();
443 mDateFrame->setCaption( i18n( "Pick a date to display")); 444 mDateFrame->setCaption( i18n( "Pick a date to display"));
444 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 445 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
445 446
446 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 447 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
447 448
448 mEventEditor = mDialogManager->getEventEditor(); 449 mEventEditor = mDialogManager->getEventEditor();
449 mTodoEditor = mDialogManager->getTodoEditor(); 450 mTodoEditor = mDialogManager->getTodoEditor();
450 451
451 mFlagEditDescription = false; 452 mFlagEditDescription = false;
452 453
453 mSuspendTimer = new QTimer( this ); 454 mSuspendTimer = new QTimer( this );
454 mAlarmTimer = new QTimer( this ); 455 mAlarmTimer = new QTimer( this );
455 mRecheckAlarmTimer = new QTimer( this ); 456 mRecheckAlarmTimer = new QTimer( this );
456 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 457 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
457 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 458 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
458 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 459 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
459 mAlarmDialog = new AlarmDialog( this ); 460 mAlarmDialog = new AlarmDialog( this );
460 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 461 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
461 mAlarmDialog->setServerNotification( false ); 462 mAlarmDialog->setServerNotification( false );
462 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 463 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
463} 464}
464 465
465 466
466CalendarView::~CalendarView() 467CalendarView::~CalendarView()
467{ 468{
468 // kdDebug() << "~CalendarView()" << endl; 469 // kdDebug() << "~CalendarView()" << endl;
469 //qDebug("CalendarView::~CalendarView() "); 470 //qDebug("CalendarView::~CalendarView() ");
470 delete mDialogManager; 471 delete mDialogManager;
471 delete mViewManager; 472 delete mViewManager;
472 delete mStorage; 473 delete mStorage;
473 delete mDateFrame ; 474 delete mDateFrame ;
474 delete beamDialog; 475 delete beamDialog;
475 //kdDebug() << "~CalendarView() done" << endl; 476 //kdDebug() << "~CalendarView() done" << endl;
476} 477}
477void CalendarView::timerAlarm() 478void CalendarView::timerAlarm()
478{ 479{
479 //qDebug("CalendarView::timerAlarm() "); 480 //qDebug("CalendarView::timerAlarm() ");
480 computeAlarm(mAlarmNotification ); 481 computeAlarm(mAlarmNotification );
481} 482}
482 483
483void CalendarView::suspendAlarm() 484void CalendarView::suspendAlarm()
484{ 485{
485 //qDebug(" CalendarView::suspendAlarm() "); 486 //qDebug(" CalendarView::suspendAlarm() ");
486 computeAlarm(mSuspendAlarmNotification ); 487 computeAlarm(mSuspendAlarmNotification );
487 488
488} 489}
489 490
490void CalendarView::startAlarm( QString mess , QString filename) 491void CalendarView::startAlarm( QString mess , QString filename)
491{ 492{
492 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 493 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
493 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); 494 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
494 495
495} 496}
496 497
497void CalendarView::checkNextTimerAlarm() 498void CalendarView::checkNextTimerAlarm()
498{ 499{
499 mCalendar->checkAlarmForIncidence( 0, true ); 500 mCalendar->checkAlarmForIncidence( 0, true );
500} 501}
501 502
502void CalendarView::computeAlarm( QString msg ) 503void CalendarView::computeAlarm( QString msg )
503{ 504{
504 505
505 QString mess = msg; 506 QString mess = msg;
506 QString mAlarmMessage = mess.mid( 9 ); 507 QString mAlarmMessage = mess.mid( 9 );
507 QString filename = MainWindow::resourcePath(); 508 QString filename = MainWindow::resourcePath();
508 filename += "koalarm.wav"; 509 filename += "koalarm.wav";
509 QString tempfilename; 510 QString tempfilename;
510 if ( mess.left( 13 ) == "suspend_alarm") { 511 if ( mess.left( 13 ) == "suspend_alarm") {
511 bool error = false; 512 bool error = false;
512 int len = mess.mid( 13 ).find("+++"); 513 int len = mess.mid( 13 ).find("+++");
513 if ( len < 2 ) 514 if ( len < 2 )
514 error = true; 515 error = true;
515 else { 516 else {
516 tempfilename = mess.mid( 13, len ); 517 tempfilename = mess.mid( 13, len );
517 if ( !QFile::exists( tempfilename ) ) 518 if ( !QFile::exists( tempfilename ) )
518 error = true; 519 error = true;
519 } 520 }
520 if ( ! error ) { 521 if ( ! error ) {
521 filename = tempfilename; 522 filename = tempfilename;
522 } 523 }
523 mAlarmMessage = mess.mid( 13+len+3 ); 524 mAlarmMessage = mess.mid( 13+len+3 );
524 //qDebug("suspend file %s ",tempfilename.latin1() ); 525 //qDebug("suspend file %s ",tempfilename.latin1() );
525 startAlarm( mAlarmMessage, filename); 526 startAlarm( mAlarmMessage, filename);
526 return; 527 return;
527 } 528 }
528 if ( mess.left( 11 ) == "timer_alarm") { 529 if ( mess.left( 11 ) == "timer_alarm") {
529 //mTimerTime = 0; 530 //mTimerTime = 0;
530 startAlarm( mess.mid( 11 ), filename ); 531 startAlarm( mess.mid( 11 ), filename );
531 return; 532 return;
532 } 533 }
533 if ( mess.left( 10 ) == "proc_alarm") { 534 if ( mess.left( 10 ) == "proc_alarm") {
534 bool error = false; 535 bool error = false;
535 int len = mess.mid( 10 ).find("+++"); 536 int len = mess.mid( 10 ).find("+++");
536 if ( len < 2 ) 537 if ( len < 2 )
537 error = true; 538 error = true;
538 else { 539 else {
539 tempfilename = mess.mid( 10, len ); 540 tempfilename = mess.mid( 10, len );
540 if ( !QFile::exists( tempfilename ) ) 541 if ( !QFile::exists( tempfilename ) )
541 error = true; 542 error = true;
542 } 543 }
543 if ( error ) { 544 if ( error ) {
544 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 545 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
545 mAlarmMessage += mess.mid( 10+len+3+9 ); 546 mAlarmMessage += mess.mid( 10+len+3+9 );
546 } else { 547 } else {
547 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 548 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
548 //qDebug("-----system command %s ",tempfilename.latin1() ); 549 //qDebug("-----system command %s ",tempfilename.latin1() );
549#ifndef _WIN32_ 550#ifndef _WIN32_
550 if ( vfork () == 0 ) { 551 if ( vfork () == 0 ) {
551 execl ( tempfilename.latin1(), 0 ); 552 execl ( tempfilename.latin1(), 0 );
552 return; 553 return;
553 } 554 }
554#else 555#else
555 QProcess* p = new QProcess(); 556 QProcess* p = new QProcess();
556 p->addArgument( tempfilename.latin1() ); 557 p->addArgument( tempfilename.latin1() );
557 p->start(); 558 p->start();
558 return; 559 return;
559#endif 560#endif
560 561
561 return; 562 return;
562 } 563 }
563 564
564 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 565 //qDebug("+++++++system command %s ",tempfilename.latin1() );
565 } 566 }
566 if ( mess.left( 11 ) == "audio_alarm") { 567 if ( mess.left( 11 ) == "audio_alarm") {
567 bool error = false; 568 bool error = false;
568 int len = mess.mid( 11 ).find("+++"); 569 int len = mess.mid( 11 ).find("+++");
569 if ( len < 2 ) 570 if ( len < 2 )
570 error = true; 571 error = true;
571 else { 572 else {
572 tempfilename = mess.mid( 11, len ); 573 tempfilename = mess.mid( 11, len );
573 if ( !QFile::exists( tempfilename ) ) 574 if ( !QFile::exists( tempfilename ) )
574 error = true; 575 error = true;
575 } 576 }
576 if ( ! error ) { 577 if ( ! error ) {
577 filename = tempfilename; 578 filename = tempfilename;
578 } 579 }
579 mAlarmMessage = mess.mid( 11+len+3+9 ); 580 mAlarmMessage = mess.mid( 11+len+3+9 );
580 //qDebug("audio file command %s ",tempfilename.latin1() ); 581 //qDebug("audio file command %s ",tempfilename.latin1() );
581 } 582 }
582 if ( mess.left( 9 ) == "cal_alarm") { 583 if ( mess.left( 9 ) == "cal_alarm") {
583 mAlarmMessage = mess.mid( 9 ) ; 584 mAlarmMessage = mess.mid( 9 ) ;
584 } 585 }
585 586
586 startAlarm( mAlarmMessage, filename ); 587 startAlarm( mAlarmMessage, filename );
587 588
588 589
589} 590}
590 591
591void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 592void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
592{ 593{
593 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 594 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
594 595
595 mSuspendAlarmNotification = noti; 596 mSuspendAlarmNotification = noti;
596 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 597 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
597 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 598 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
598 mSuspendTimer->start( ms , true ); 599 mSuspendTimer->start( ms , true );
599 600
600} 601}
601 602
602void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 603void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
603{ 604{
604 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 605 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
605 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 606 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
606#ifndef DESKTOP_VERSION 607#ifndef DESKTOP_VERSION
607 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); 608 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() );
608#endif 609#endif
609 return; 610 return;
610 } 611 }
611 int maxSec; 612 int maxSec;
612 //maxSec = 5; //testing only 613 //maxSec = 5; //testing only
613 maxSec = 86400+3600; // one day+1hour 614 maxSec = 86400+3600; // one day+1hour
614 mAlarmNotification = noti; 615 mAlarmNotification = noti;
615 int sec = QDateTime::currentDateTime().secsTo( qdt ); 616 int sec = QDateTime::currentDateTime().secsTo( qdt );
616 if ( sec > maxSec ) { 617 if ( sec > maxSec ) {
617 mRecheckAlarmTimer->start( maxSec * 1000 ); 618 mRecheckAlarmTimer->start( maxSec * 1000 );
618 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 619 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
619 return; 620 return;
620 } else { 621 } else {
621 mRecheckAlarmTimer->stop(); 622 mRecheckAlarmTimer->stop();
622 } 623 }
623 //qDebug("Alarm timer started with secs: %d ", sec); 624 //qDebug("Alarm timer started with secs: %d ", sec);
624 mAlarmTimer->start( sec *1000 , true ); 625 mAlarmTimer->start( sec *1000 , true );
625 626
626} 627}
627// called by mRecheckAlarmTimer to get next alarm 628// called by mRecheckAlarmTimer to get next alarm
628// we need this, because a QTimer has only a max range of 25 days 629// we need this, because a QTimer has only a max range of 25 days
629void CalendarView::recheckTimerAlarm() 630void CalendarView::recheckTimerAlarm()
630{ 631{
631 mAlarmTimer->stop(); 632 mAlarmTimer->stop();
632 mRecheckAlarmTimer->stop(); 633 mRecheckAlarmTimer->stop();
633 mCalendar->checkAlarmForIncidence( 0, true ); 634 mCalendar->checkAlarmForIncidence( 0, true );
634} 635}
635void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 636void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
636{ 637{
637 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 638 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
638 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 639 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
639#ifndef DESKTOP_VERSION 640#ifndef DESKTOP_VERSION
640 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 641 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
641#endif 642#endif
642 return; 643 return;
643 } 644 }
644 mAlarmTimer->stop(); 645 mAlarmTimer->stop();
645} 646}
646void CalendarView::selectWeekNum ( int num ) 647void CalendarView::selectWeekNum ( int num )
647{ 648{
648 dateNavigator()->selectWeek( num ); 649 dateNavigator()->selectWeek( num );
649 mViewManager->showWeekView(); 650 mViewManager->showWeekView();
650} 651}
651KOViewManager *CalendarView::viewManager() 652KOViewManager *CalendarView::viewManager()
652{ 653{
653 return mViewManager; 654 return mViewManager;
654} 655}
655 656
656KODialogManager *CalendarView::dialogManager() 657KODialogManager *CalendarView::dialogManager()
657{ 658{
658 return mDialogManager; 659 return mDialogManager;
659} 660}
660 661
661QDate CalendarView::startDate() 662QDate CalendarView::startDate()
662{ 663{
663 DateList dates = mNavigator->selectedDates(); 664 DateList dates = mNavigator->selectedDates();
664 665
665 return dates.first(); 666 return dates.first();
666} 667}
667 668
668QDate CalendarView::endDate() 669QDate CalendarView::endDate()
669{ 670{
670 DateList dates = mNavigator->selectedDates(); 671 DateList dates = mNavigator->selectedDates();
671 672
672 return dates.last(); 673 return dates.last();
673} 674}
674 675
675 676
676void CalendarView::createPrinter() 677void CalendarView::createPrinter()
677{ 678{
678#ifndef KORG_NOPRINTER 679#ifndef KORG_NOPRINTER
679 if (!mCalPrinter) { 680 if (!mCalPrinter) {
680 mCalPrinter = new CalPrinter(this, mCalendar); 681 mCalPrinter = new CalPrinter(this, mCalendar);
681 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 682 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
682 } 683 }
683#endif 684#endif
684} 685}
685 686
686void CalendarView::confSync() 687void CalendarView::confSync()
687{ 688{
688 static KSyncPrefsDialog* sp = 0; 689 static KSyncPrefsDialog* sp = 0;
689 if ( ! sp ) { 690 if ( ! sp ) {
690 sp = new KSyncPrefsDialog( this, "syncprefs", true ); 691 sp = new KSyncPrefsDialog( this, "syncprefs", true );
691 } 692 }
692 sp->usrReadConfig(); 693 sp->usrReadConfig();
693#ifndef DESKTOP_VERSION 694#ifndef DESKTOP_VERSION
694 sp->showMaximized(); 695 sp->showMaximized();
695#else 696#else
696 sp->show(); 697 sp->show();
697#endif 698#endif
698 sp->exec(); 699 sp->exec();
699 KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); 700 KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames();
700 KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); 701 KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName ();
701} 702}
702 703
703 704
704//KOPrefs::instance()->mWriteBackFile 705//KOPrefs::instance()->mWriteBackFile
705//KOPrefs::instance()->mWriteBackExistingOnly 706//KOPrefs::instance()->mWriteBackExistingOnly
706 707
707// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 708// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
708// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 709// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
709// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 710// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
710// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 711// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
711// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 712// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
712// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 713// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
713 714
714int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 715int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
715{ 716{
716 717
717 //void setZaurusId(int id); 718 //void setZaurusId(int id);
718 // int zaurusId() const; 719 // int zaurusId() const;
719 // void setZaurusUid(int id); 720 // void setZaurusUid(int id);
720 // int zaurusUid() const; 721 // int zaurusUid() const;
721 // void setZaurusStat(int id); 722 // void setZaurusStat(int id);
722 // int zaurusStat() const; 723 // int zaurusStat() const;
723 // 0 equal 724 // 0 equal
724 // 1 take local 725 // 1 take local
725 // 2 take remote 726 // 2 take remote
726 // 3 cancel 727 // 3 cancel
727 QDateTime lastSync = mLastCalendarSync; 728 QDateTime lastSync = mLastCalendarSync;
728 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 729 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
729 bool remCh, locCh; 730 bool remCh, locCh;
730 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 731 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
731 locCh = ( local->lastModified() > mLastCalendarSync ); 732 locCh = ( local->lastModified() > mLastCalendarSync );
732 //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() ); 733 //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() );
733 if ( !remCh && ! locCh ) { 734 if ( !remCh && ! locCh ) {
734 //qDebug("both not changed "); 735 //qDebug("both not changed ");
735 lastSync = local->lastModified().addDays(1); 736 lastSync = local->lastModified().addDays(1);
736 } else { 737 } else {
737 if ( locCh ) { 738 if ( locCh ) {
738 //qDebug("loc changed %d %d", local->zaurusStat(), local->revision() ); 739 //qDebug("loc changed %d %d", local->zaurusStat(), local->revision() );
739 lastSync = local->lastModified().addDays( -1 ); 740 lastSync = local->lastModified().addDays( -1 );
740 if ( !remCh ) 741 if ( !remCh )
741 remote->setLastModified( lastSync.addDays( -1 ) ); 742 remote->setLastModified( lastSync.addDays( -1 ) );
742 } else { 743 } else {
743 //qDebug(" not loc changed "); 744 //qDebug(" not loc changed ");
744 lastSync = local->lastModified().addDays( 1 ); 745 lastSync = local->lastModified().addDays( 1 );
745 if ( remCh ) 746 if ( remCh )
746 remote->setLastModified( lastSync.addDays( 1 ) ); 747 remote->setLastModified( lastSync.addDays( 1 ) );
747 748
748 } 749 }
749 } 750 }
750 full = true; 751 full = true;
751 if ( mode < SYNC_PREF_ASK ) 752 if ( mode < SYNC_PREF_ASK )
752 mode = SYNC_PREF_ASK; 753 mode = SYNC_PREF_ASK;
753 } else { 754 } else {
754 if ( local->lastModified() == remote->lastModified() ) 755 if ( local->lastModified() == remote->lastModified() )
755 if ( local->revision() == remote->revision() ) 756 if ( local->revision() == remote->revision() )
756 return 0; 757 return 0;
757 758
758 } 759 }
759 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 760 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
760 761
761 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); 762 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision());
762 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); 763 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() );
763 //full = true; //debug only 764 //full = true; //debug only
764 if ( full ) { 765 if ( full ) {
765 bool equ = false; 766 bool equ = false;
766 if ( local->type() == "Event" ) { 767 if ( local->type() == "Event" ) {
767 equ = (*((Event*) local) == *((Event*) remote)); 768 equ = (*((Event*) local) == *((Event*) remote));
768 } 769 }
769 else if ( local->type() =="Todo" ) 770 else if ( local->type() =="Todo" )
770 equ = (*((Todo*) local) == (*(Todo*) remote)); 771 equ = (*((Todo*) local) == (*(Todo*) remote));
771 else if ( local->type() =="Journal" ) 772 else if ( local->type() =="Journal" )
772 equ = (*((Journal*) local) == *((Journal*) remote)); 773 equ = (*((Journal*) local) == *((Journal*) remote));
773 if ( equ ) { 774 if ( equ ) {
774 //qDebug("equal "); 775 //qDebug("equal ");
775 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 776 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
776 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 777 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
777 } 778 }
778 if ( mode < SYNC_PREF_FORCE_LOCAL ) 779 if ( mode < SYNC_PREF_FORCE_LOCAL )
779 return 0; 780 return 0;
780 781
781 }//else //debug only 782 }//else //debug only
782 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 783 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
783 } 784 }
784 int result; 785 int result;
785 bool localIsNew; 786 bool localIsNew;
786 if ( full && mode < SYNC_PREF_NEWEST ) 787 if ( full && mode < SYNC_PREF_NEWEST )
787 mode = SYNC_PREF_ASK; 788 mode = SYNC_PREF_ASK;
788 789
789 switch( mode ) { 790 switch( mode ) {
790 case SYNC_PREF_LOCAL: 791 case SYNC_PREF_LOCAL:
791 if ( lastSync > remote->lastModified() ) 792 if ( lastSync > remote->lastModified() )
792 return 1; 793 return 1;
793 if ( lastSync > local->lastModified() ) 794 if ( lastSync > local->lastModified() )
794 return 2; 795 return 2;
795 return 1; 796 return 1;
796 break; 797 break;
797 case SYNC_PREF_REMOTE: 798 case SYNC_PREF_REMOTE:
798 if ( lastSync > remote->lastModified() ) 799 if ( lastSync > remote->lastModified() )
799 return 1; 800 return 1;
800 if ( lastSync > local->lastModified() ) 801 if ( lastSync > local->lastModified() )
801 return 2; 802 return 2;
802 return 2; 803 return 2;
803 break; 804 break;
804 case SYNC_PREF_NEWEST: 805 case SYNC_PREF_NEWEST:
805 if ( local->lastModified() > remote->lastModified() ) 806 if ( local->lastModified() > remote->lastModified() )
806 return 1; 807 return 1;
807 else 808 else
808 return 2; 809 return 2;
809 break; 810 break;
810 case SYNC_PREF_ASK: 811 case SYNC_PREF_ASK:
811 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); 812 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() );
812 if ( lastSync > remote->lastModified() ) 813 if ( lastSync > remote->lastModified() )
813 return 1; 814 return 1;
814 if ( lastSync > local->lastModified() ) 815 if ( lastSync > local->lastModified() )
815 return 2; 816 return 2;
816 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); 817 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() );
817 localIsNew = local->lastModified() > remote->lastModified(); 818 localIsNew = local->lastModified() > remote->lastModified();
818 if ( localIsNew ) 819 if ( localIsNew )
819 getEventViewerDialog()->setColorMode( 1 ); 820 getEventViewerDialog()->setColorMode( 1 );
820 else 821 else
821 getEventViewerDialog()->setColorMode( 2 ); 822 getEventViewerDialog()->setColorMode( 2 );
822 getEventViewerDialog()->setIncidence(local); 823 getEventViewerDialog()->setIncidence(local);
823 if ( localIsNew ) 824 if ( localIsNew )
824 getEventViewerDialog()->setColorMode( 2 ); 825 getEventViewerDialog()->setColorMode( 2 );
825 else 826 else
826 getEventViewerDialog()->setColorMode( 1 ); 827 getEventViewerDialog()->setColorMode( 1 );
827 getEventViewerDialog()->addIncidence(remote); 828 getEventViewerDialog()->addIncidence(remote);
828 getEventViewerDialog()->setColorMode( 0 ); 829 getEventViewerDialog()->setColorMode( 0 );
829 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 830 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
830 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 831 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
831 getEventViewerDialog()->showMe(); 832 getEventViewerDialog()->showMe();
832 result = getEventViewerDialog()->executeS( localIsNew ); 833 result = getEventViewerDialog()->executeS( localIsNew );
833 return result; 834 return result;
834 835
835 break; 836 break;
836 case SYNC_PREF_FORCE_LOCAL: 837 case SYNC_PREF_FORCE_LOCAL:
837 return 1; 838 return 1;
838 break; 839 break;
839 case SYNC_PREF_FORCE_REMOTE: 840 case SYNC_PREF_FORCE_REMOTE:
840 return 2; 841 return 2;
841 break; 842 break;
842 843
843 default: 844 default:
844 // SYNC_PREF_TAKE_BOTH not implemented 845 // SYNC_PREF_TAKE_BOTH not implemented
845 break; 846 break;
846 } 847 }
847 return 0; 848 return 0;
848} 849}
849Event* CalendarView::getLastSyncEvent() 850Event* CalendarView::getLastSyncEvent()
850{ 851{
851 Event* lse; 852 Event* lse;
852 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 853 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
853 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 854 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
854 if (!lse) { 855 if (!lse) {
855 lse = new Event(); 856 lse = new Event();
856 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 857 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
857 QString sum = ""; 858 QString sum = "";
858 if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 859 if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
859 sum = "E: "; 860 sum = "E: ";
860 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 861 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
861 lse->setDtStart( mLastCalendarSync ); 862 lse->setDtStart( mLastCalendarSync );
862 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 863 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
863 lse->setCategories( i18n("SyncEvent") ); 864 lse->setCategories( i18n("SyncEvent") );
864 lse->setReadOnly( true ); 865 lse->setReadOnly( true );
865 mCalendar->addEvent( lse ); 866 mCalendar->addEvent( lse );
866 } 867 }
867 868
868 return lse; 869 return lse;
869 870
870} 871}
871// probaly useless 872// probaly useless
872void CalendarView::setupExternSyncProfiles() 873void CalendarView::setupExternSyncProfiles()
873{ 874{
874 Event* lse; 875 Event* lse;
875 mExternLastSyncEvent.clear(); 876 mExternLastSyncEvent.clear();
876 int i; 877 int i;
877 for ( i = 0; i < KOPrefs::instance()->mExternSyncProfiles.count(); ++i ) { 878 for ( i = 0; i < KOPrefs::instance()->mExternSyncProfiles.count(); ++i ) {
878 lse = mCalendar->event( "last-syncEvent-"+ KOPrefs::instance()->mExternSyncProfiles[i] ); 879 lse = mCalendar->event( "last-syncEvent-"+ KOPrefs::instance()->mExternSyncProfiles[i] );
879 if ( lse ) 880 if ( lse )
880 mExternLastSyncEvent.append( lse ); 881 mExternLastSyncEvent.append( lse );
881 else 882 else
882 qDebug("Last Sync event not found for %s ", KOPrefs::instance()->mExternSyncProfiles[i].latin1()); 883 qDebug("Last Sync event not found for %s ", KOPrefs::instance()->mExternSyncProfiles[i].latin1());
883 } 884 }
884 885
885} 886}
886// we check, if the to delete event has a id for a profile 887// we check, if the to delete event has a id for a profile
887// if yes, we set this id in the profile to delete 888// if yes, we set this id in the profile to delete
888void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 889void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
889{ 890{
890 if ( lastSync.count() == 0 ) { 891 if ( lastSync.count() == 0 ) {
891 //qDebug(" lastSync.count() == 0"); 892 //qDebug(" lastSync.count() == 0");
892 return; 893 return;
893 } 894 }
894 if ( toDelete->type() == "Journal" ) 895 if ( toDelete->type() == "Journal" )
895 return; 896 return;
896 897
897 Event* eve = lastSync.first(); 898 Event* eve = lastSync.first();
898 899
899 while ( eve ) { 900 while ( eve ) {
900 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 901 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
901 if ( !id.isEmpty() ) { 902 if ( !id.isEmpty() ) {
902 QString des = eve->description(); 903 QString des = eve->description();
903 QString pref = "e"; 904 QString pref = "e";
904 if ( toDelete->type() == "Todo" ) 905 if ( toDelete->type() == "Todo" )
905 pref = "t"; 906 pref = "t";
906 des += pref+ id + ","; 907 des += pref+ id + ",";
907 eve->setReadOnly( false ); 908 eve->setReadOnly( false );
908 eve->setDescription( des ); 909 eve->setDescription( des );
909 //qDebug("setdes %s ", des.latin1()); 910 //qDebug("setdes %s ", des.latin1());
910 eve->setReadOnly( true ); 911 eve->setReadOnly( true );
911 } 912 }
912 eve = lastSync.next(); 913 eve = lastSync.next();
913 } 914 }
914 915
915} 916}
916void CalendarView::checkExternalId( Incidence * inc ) 917void CalendarView::checkExternalId( Incidence * inc )
917{ 918{
918 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 919 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
919 checkExternSyncEvent( lastSync, inc ); 920 checkExternSyncEvent( lastSync, inc );
920 921
921} 922}
922bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 923bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
923{ 924{
924 bool syncOK = true; 925 bool syncOK = true;
925 int addedEvent = 0; 926 int addedEvent = 0;
926 int addedEventR = 0; 927 int addedEventR = 0;
927 int deletedEventR = 0; 928 int deletedEventR = 0;
928 int deletedEventL = 0; 929 int deletedEventL = 0;
929 int changedLocal = 0; 930 int changedLocal = 0;
930 int changedRemote = 0; 931 int changedRemote = 0;
931 //QPtrList<Event> el = local->rawEvents(); 932 //QPtrList<Event> el = local->rawEvents();
932 Event* eventR; 933 Event* eventR;
933 QString uid; 934 QString uid;
934 int take; 935 int take;
935 Event* eventL; 936 Event* eventL;
936 Event* eventRSync; 937 Event* eventRSync;
937 Event* eventLSync; 938 Event* eventLSync;
938 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 939 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
939 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 940 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
940 bool fullDateRange = false; 941 bool fullDateRange = false;
941 mLastCalendarSync = QDateTime::currentDateTime(); 942 mLastCalendarSync = QDateTime::currentDateTime();
942 QDateTime modifiedCalendar = mLastCalendarSync;; 943 QDateTime modifiedCalendar = mLastCalendarSync;;
943 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 944 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
944 if ( eventR ) { 945 if ( eventR ) {
945 eventRSync = (Event*) eventR->clone(); 946 eventRSync = (Event*) eventR->clone();
946 remote->deleteEvent(eventR ); 947 remote->deleteEvent(eventR );
947 948
948 } else { 949 } else {
949 fullDateRange = true; 950 fullDateRange = true;
950 eventRSync = new Event(); 951 eventRSync = new Event();
951 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 952 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
952 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 953 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
953 eventRSync->setDtStart( mLastCalendarSync ); 954 eventRSync->setDtStart( mLastCalendarSync );
954 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 955 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
955 eventRSync->setCategories( i18n("SyncEvent") ); 956 eventRSync->setCategories( i18n("SyncEvent") );
956 } 957 }
957 eventLSync = getLastSyncEvent(); 958 eventLSync = getLastSyncEvent();
958 if ( eventLSync->dtStart() == mLastCalendarSync ) 959 if ( eventLSync->dtStart() == mLastCalendarSync )
959 fullDateRange = true; 960 fullDateRange = true;
960 961
961 if ( ! fullDateRange ) { 962 if ( ! fullDateRange ) {
962 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 963 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
963 964
964 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 965 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
965 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 966 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
966 fullDateRange = true; 967 fullDateRange = true;
967 } 968 }
968 } 969 }
969 if ( fullDateRange ) 970 if ( fullDateRange )
970 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 971 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
971 else 972 else
972 mLastCalendarSync = eventLSync->dtStart(); 973 mLastCalendarSync = eventLSync->dtStart();
973 // for resyncing if own file has changed 974 // for resyncing if own file has changed
974 if ( mCurrentSyncDevice == "deleteaftersync" ) { 975 if ( mCurrentSyncDevice == "deleteaftersync" ) {
975 mLastCalendarSync = loadedFileVersion; 976 mLastCalendarSync = loadedFileVersion;
976 qDebug("setting mLastCalendarSync "); 977 qDebug("setting mLastCalendarSync ");
977 } 978 }
978 //qDebug("*************************** "); 979 //qDebug("*************************** ");
979 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); 980 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() );
980 QPtrList<Incidence> er = remote->rawIncidences(); 981 QPtrList<Incidence> er = remote->rawIncidences();
981 Incidence* inR = er.first(); 982 Incidence* inR = er.first();
982 Incidence* inL; 983 Incidence* inL;
983 QProgressBar bar( er.count(),0 ); 984 QProgressBar bar( er.count(),0 );
984 bar.setCaption (i18n("Syncing - close to abort!") ); 985 bar.setCaption (i18n("Syncing - close to abort!") );
985 986
986 int w = 300; 987 int w = 300;
987 if ( QApplication::desktop()->width() < 320 ) 988 if ( QApplication::desktop()->width() < 320 )
988 w = 220; 989 w = 220;
989 int h = bar.sizeHint().height() ; 990 int h = bar.sizeHint().height() ;
990 int dw = QApplication::desktop()->width(); 991 int dw = QApplication::desktop()->width();
991 int dh = QApplication::desktop()->height(); 992 int dh = QApplication::desktop()->height();
992 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 993 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
993 bar.show(); 994 bar.show();
994 int modulo = (er.count()/10)+1; 995 int modulo = (er.count()/10)+1;
995 int incCounter = 0; 996 int incCounter = 0;
996 while ( inR ) { 997 while ( inR ) {
997 if ( ! bar.isVisible() ) 998 if ( ! bar.isVisible() )
998 return false; 999 return false;
999 if ( incCounter % modulo == 0 ) 1000 if ( incCounter % modulo == 0 )
1000 bar.setProgress( incCounter ); 1001 bar.setProgress( incCounter );
1001 ++incCounter; 1002 ++incCounter;
1002 uid = inR->uid(); 1003 uid = inR->uid();
1003 bool skipIncidence = false; 1004 bool skipIncidence = false;
1004 if ( uid.left(15) == QString("last-syncEvent-") ) 1005 if ( uid.left(15) == QString("last-syncEvent-") )
1005 skipIncidence = true; 1006 skipIncidence = true;
1006 1007
1007 qApp->processEvents(); 1008 qApp->processEvents();
1008 if ( !skipIncidence ) { 1009 if ( !skipIncidence ) {
1009 inL = local->incidence( uid ); 1010 inL = local->incidence( uid );
1010 if ( inL ) { // maybe conflict - same uid in both calendars 1011 if ( inL ) { // maybe conflict - same uid in both calendars
1011 int maxrev = inL->revision(); 1012 int maxrev = inL->revision();
1012 if ( maxrev < inR->revision() ) 1013 if ( maxrev < inR->revision() )
1013 maxrev = inR->revision(); 1014 maxrev = inR->revision();
1014 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1015 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1015 //qDebug("take %d %s ", take, inL->summary().latin1()); 1016 //qDebug("take %d %s ", take, inL->summary().latin1());
1016 if ( take == 3 ) 1017 if ( take == 3 )
1017 return false; 1018 return false;
1018 if ( take == 1 ) {// take local 1019 if ( take == 1 ) {// take local
1019 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1020 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1020 remote->deleteIncidence( inR ); 1021 remote->deleteIncidence( inR );
1021 if ( inL->revision() < maxrev ) 1022 if ( inL->revision() < maxrev )
1022 inL->setRevision( maxrev ); 1023 inL->setRevision( maxrev );
1023 remote->addIncidence( inL->clone() ); 1024 remote->addIncidence( inL->clone() );
1024 ++changedRemote; 1025 ++changedRemote;
1025 } else { 1026 } else {
1026 if ( inR->revision() < maxrev ) 1027 if ( inR->revision() < maxrev )
1027 inR->setRevision( maxrev ); 1028 inR->setRevision( maxrev );
1028 local->deleteIncidence( inL ); 1029 local->deleteIncidence( inL );
1029 local->addIncidence( inR->clone() ); 1030 local->addIncidence( inR->clone() );
1030 ++changedLocal; 1031 ++changedLocal;
1031 } 1032 }
1032 } 1033 }
1033 } else { // no conflict 1034 } else { // no conflict
1034 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1035 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1035 QString des = eventLSync->description(); 1036 QString des = eventLSync->description();
1036 QString pref = "e"; 1037 QString pref = "e";
1037 if ( inR->type() == "Todo" ) 1038 if ( inR->type() == "Todo" )
1038 pref = "t"; 1039 pref = "t";
1039 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1040 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1040 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1041 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1041 //remote->deleteIncidence( inR ); 1042 //remote->deleteIncidence( inR );
1042 ++deletedEventR; 1043 ++deletedEventR;
1043 } else { 1044 } else {
1044 inR->setLastModified( modifiedCalendar ); 1045 inR->setLastModified( modifiedCalendar );
1045 local->addIncidence( inR->clone() ); 1046 local->addIncidence( inR->clone() );
1046 ++addedEvent; 1047 ++addedEvent;
1047 } 1048 }
1048 } else { 1049 } else {
1049 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1050 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1050 inR->setLastModified( modifiedCalendar ); 1051 inR->setLastModified( modifiedCalendar );
1051 local->addIncidence( inR->clone() ); 1052 local->addIncidence( inR->clone() );
1052 ++addedEvent; 1053 ++addedEvent;
1053 } else { 1054 } else {
1054 checkExternSyncEvent(eventRSyncSharp, inR); 1055 checkExternSyncEvent(eventRSyncSharp, inR);
1055 remote->deleteIncidence( inR ); 1056 remote->deleteIncidence( inR );
1056 ++deletedEventR; 1057 ++deletedEventR;
1057 } 1058 }
1058 } 1059 }
1059 } 1060 }
1060 } 1061 }
1061 inR = er.next(); 1062 inR = er.next();
1062 } 1063 }
1063 QPtrList<Incidence> el = local->rawIncidences(); 1064 QPtrList<Incidence> el = local->rawIncidences();
1064 inL = el.first(); 1065 inL = el.first();
1065 modulo = (el.count()/10)+1; 1066 modulo = (el.count()/10)+1;
1066 bar.setCaption (i18n("Add / remove events") ); 1067 bar.setCaption (i18n("Add / remove events") );
1067 bar.setTotalSteps ( el.count() ) ; 1068 bar.setTotalSteps ( el.count() ) ;
1068 bar.show(); 1069 bar.show();
1069 incCounter = 0; 1070 incCounter = 0;
1070 1071
1071 while ( inL ) { 1072 while ( inL ) {
1072 1073
1073 qApp->processEvents(); 1074 qApp->processEvents();
1074 if ( ! bar.isVisible() ) 1075 if ( ! bar.isVisible() )
1075 return false; 1076 return false;
1076 if ( incCounter % modulo == 0 ) 1077 if ( incCounter % modulo == 0 )
1077 bar.setProgress( incCounter ); 1078 bar.setProgress( incCounter );
1078 ++incCounter; 1079 ++incCounter;
1079 uid = inL->uid(); 1080 uid = inL->uid();
1080 bool skipIncidence = false; 1081 bool skipIncidence = false;
1081 if ( uid.left(15) == QString("last-syncEvent-") ) 1082 if ( uid.left(15) == QString("last-syncEvent-") )
1082 skipIncidence = true; 1083 skipIncidence = true;
1083 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) 1084 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
1084 skipIncidence = true; 1085 skipIncidence = true;
1085 if ( !skipIncidence ) { 1086 if ( !skipIncidence ) {
1086 inR = remote->incidence( uid ); 1087 inR = remote->incidence( uid );
1087 if ( ! inR ) { 1088 if ( ! inR ) {
1088 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1089 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1089 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1090 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1090 local->deleteIncidence( inL ); 1091 local->deleteIncidence( inL );
1091 ++deletedEventL; 1092 ++deletedEventL;
1092 } else { 1093 } else {
1093 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { 1094 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
1094 inL->removeID(mCurrentSyncDevice ); 1095 inL->removeID(mCurrentSyncDevice );
1095 ++addedEventR; 1096 ++addedEventR;
1096 inL->setLastModified( modifiedCalendar ); 1097 inL->setLastModified( modifiedCalendar );
1097 remote->addIncidence( inL->clone() ); 1098 remote->addIncidence( inL->clone() );
1098 } 1099 }
1099 } 1100 }
1100 } else { 1101 } else {
1101 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1102 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1102 checkExternSyncEvent(eventLSyncSharp, inL); 1103 checkExternSyncEvent(eventLSyncSharp, inL);
1103 local->deleteIncidence( inL ); 1104 local->deleteIncidence( inL );
1104 ++deletedEventL; 1105 ++deletedEventL;
1105 } else { 1106 } else {
1106 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { 1107 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
1107 ++addedEventR; 1108 ++addedEventR;
1108 inL->setLastModified( modifiedCalendar ); 1109 inL->setLastModified( modifiedCalendar );
1109 remote->addIncidence( inL->clone() ); 1110 remote->addIncidence( inL->clone() );
1110 } 1111 }
1111 } 1112 }
1112 } 1113 }
1113 } 1114 }
1114 } 1115 }
1115 inL = el.next(); 1116 inL = el.next();
1116 } 1117 }
1117 1118
1118 bar.hide(); 1119 bar.hide();
1119 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1120 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1120 eventLSync->setReadOnly( false ); 1121 eventLSync->setReadOnly( false );
1121 eventLSync->setDtStart( mLastCalendarSync ); 1122 eventLSync->setDtStart( mLastCalendarSync );
1122 eventRSync->setDtStart( mLastCalendarSync ); 1123 eventRSync->setDtStart( mLastCalendarSync );
1123 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1124 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1124 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1125 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1125 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1126 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1126 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1127 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1127 eventLSync->setReadOnly( true ); 1128 eventLSync->setReadOnly( true );
1128 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 1129 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
1129 remote->addEvent( eventRSync ); 1130 remote->addEvent( eventRSync );
1130 QString mes; 1131 QString mes;
1131 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 ); 1132 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 );
1132 if ( KOPrefs::instance()->mShowSyncSummary ) { 1133 if ( KOPrefs::instance()->mShowSyncSummary ) {
1133 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); 1134 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") );
1134 } 1135 }
1135 qDebug( mes ); 1136 qDebug( mes );
1136 mCalendar->checkAlarmForIncidence( 0, true ); 1137 mCalendar->checkAlarmForIncidence( 0, true );
1137 return syncOK; 1138 return syncOK;
1138} 1139}
1139 1140
1140void CalendarView::setSyncDevice( QString s ) 1141void CalendarView::setSyncDevice( QString s )
1141{ 1142{
1142 mCurrentSyncDevice= s; 1143 mCurrentSyncDevice= s;
1143} 1144}
1144void CalendarView::setSyncName( QString s ) 1145void CalendarView::setSyncName( QString s )
1145{ 1146{
1146 mCurrentSyncName= s; 1147 mCurrentSyncName= s;
1147} 1148}
1148bool CalendarView::syncCalendar(QString filename, int mode) 1149bool CalendarView::syncCalendar(QString filename, int mode)
1149{ 1150{
1150 mGlobalSyncMode = SYNC_MODE_NORMAL; 1151 mGlobalSyncMode = SYNC_MODE_NORMAL;
1151 CalendarLocal* calendar = new CalendarLocal(); 1152 CalendarLocal* calendar = new CalendarLocal();
1152 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1153 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1153 FileStorage* storage = new FileStorage( calendar ); 1154 FileStorage* storage = new FileStorage( calendar );
1154 bool syncOK = false; 1155 bool syncOK = false;
1155 storage->setFileName( filename ); 1156 storage->setFileName( filename );
1156 // qDebug("loading ... "); 1157 // qDebug("loading ... ");
1157 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { 1158 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) {
1158 getEventViewerDialog()->setSyncMode( true ); 1159 getEventViewerDialog()->setSyncMode( true );
1159 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1160 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1160 getEventViewerDialog()->setSyncMode( false ); 1161 getEventViewerDialog()->setSyncMode( false );
1161 if ( syncOK ) { 1162 if ( syncOK ) {
1162 if ( KOPrefs::instance()->mWriteBackFile ) 1163 if ( KOPrefs::instance()->mWriteBackFile )
1163 { 1164 {
1164 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 1165 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
1165 storage->save(); 1166 storage->save();
1166 } 1167 }
1167 } 1168 }
1168 setModified( true ); 1169 setModified( true );
1169 } 1170 }
1170 delete storage; 1171 delete storage;
1171 delete calendar; 1172 delete calendar;
1172 if ( syncOK ) 1173 if ( syncOK )
1173 updateView(); 1174 updateView();
1174 return syncOK; 1175 return syncOK;
1175} 1176}
1176void CalendarView::syncPhone() 1177void CalendarView::syncPhone()
1177{ 1178{
1178 qDebug("CalendarView::syncPhone() "); 1179 syncExternal( 1 );
1179} 1180}
1180void CalendarView::syncSharp() 1181void CalendarView::syncExternal( int mode )
1181{ 1182{
1182#ifndef DESKTOP_VERSION 1183 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1183 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1184 //mCurrentSyncDevice = "sharp-DTM"; 1184 //mCurrentSyncDevice = "sharp-DTM";
1185 if ( KOPrefs::instance()->mAskForPreferences ) 1185 if ( KOPrefs::instance()->mAskForPreferences )
1186 edit_sync_options(); 1186 edit_sync_options();
1187 qApp->processEvents(); 1187 qApp->processEvents();
1188 CalendarLocal* calendar = new CalendarLocal(); 1188 CalendarLocal* calendar = new CalendarLocal();
1189 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1189 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1190 bool syncOK = false; 1190 bool syncOK = false;
1191 SharpFormat sharpFormat; 1191 boo loadSuccess = false;
1192 if ( sharpFormat.load( calendar, mCalendar ) ) { 1192 PhoneFormat* phoneFormat = 0;
1193#ifndef DESKTOP_VERSION
1194 SharpFormat* sharpFormat = 0;
1195 if ( mode == 0 ) { // sharp
1196 sharpFormat = new SharpFormat () ;
1197 loadSuccess = sharpFormat->load( calendar, mCalendar );
1198
1199 } else
1200#endif
1201 if ( mode == 1 ) { // phone
1202 phoneFormat = new PhoneFormat ();
1203 loadSuccess = phoneFormat->load( calendar, mCalendar );
1204
1205 } else
1206 return;
1207 if ( loadSuccess ) {
1193 getEventViewerDialog()->setSyncMode( true ); 1208 getEventViewerDialog()->setSyncMode( true );
1194 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); 1209 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
1195 getEventViewerDialog()->setSyncMode( false ); 1210 getEventViewerDialog()->setSyncMode( false );
1196 qApp->processEvents(); 1211 qApp->processEvents();
1197 if ( syncOK ) { 1212 if ( syncOK ) {
1198 if ( KOPrefs::instance()->mWriteBackFile ) 1213 if ( KOPrefs::instance()->mWriteBackFile )
1199 { 1214 {
1200 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1215 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1201 Incidence* inc = iL.first(); 1216 Incidence* inc = iL.first();
1202 /* obsolete 1217 /* obsolete
1203 while ( inc ) { 1218 while ( inc ) {
1204 inc->setZaurusStat( inc->revision () ); 1219 inc->setZaurusStat( inc->revision () );
1205 inc = iL.next(); 1220 inc = iL.next();
1206 } 1221 }
1207 */ 1222 */
1208 // pending: clean last sync event description 1223#ifndef DESKTOP_VERSION
1209 sharpFormat.save(calendar); 1224 if ( sharpFormat )
1225 sharpFormat->save(calendar);
1226#endif
1227 if ( phoneFormat )
1228 phoneFormat->save(calendar);
1210 iL = calendar->rawIncidences(); 1229 iL = calendar->rawIncidences();
1211 inc = iL.first(); 1230 inc = iL.first();
1212 Incidence* loc; 1231 Incidence* loc;
1213 while ( inc ) { 1232 while ( inc ) {
1214 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1233 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1215 loc = mCalendar->incidence(inc->uid() ); 1234 loc = mCalendar->incidence(inc->uid() );
1216 if ( loc ) { 1235 if ( loc ) {
1217 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1236 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1218 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1237 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1219 } 1238 }
1220 } 1239 }
1221 inc = iL.next(); 1240 inc = iL.next();
1222 } 1241 }
1223 Incidence* lse = getLastSyncEvent(); 1242 Incidence* lse = getLastSyncEvent();
1224 if ( lse ) { 1243 if ( lse ) {
1225 lse->setReadOnly( false ); 1244 lse->setReadOnly( false );
1226 lse->setDescription( "" ); 1245 lse->setDescription( "" );
1227 lse->setReadOnly( true ); 1246 lse->setReadOnly( true );
1228 } 1247 }
1229 } 1248 }
1230 } 1249 }
1231 setModified( true ); 1250 setModified( true );
1232 } else { 1251 } else {
1233 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1252 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1234 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1253 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1235 question, i18n("Ok")) ; 1254 question, i18n("Ok")) ;
1236 1255
1237 } 1256 }
1238 delete calendar; 1257 delete calendar;
1239 updateView(); 1258 updateView();
1240 return ;//syncOK; 1259 return ;//syncOK;
1241#endif 1260
1261}
1262void CalendarView::syncSharp()
1263{
1264 syncExternal( 0 );
1265
1242} 1266}
1243 1267
1244 1268
1245#include <kabc/stdaddressbook.h> 1269#include <kabc/stdaddressbook.h>
1246bool CalendarView::importBday() 1270bool CalendarView::importBday()
1247{ 1271{
1248 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1272 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1249 KABC::AddressBook::Iterator it; 1273 KABC::AddressBook::Iterator it;
1250 int count = 0; 1274 int count = 0;
1251 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1275 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1252 ++count; 1276 ++count;
1253 } 1277 }
1254 QProgressBar bar(count,0 ); 1278 QProgressBar bar(count,0 );
1255 int w = 300; 1279 int w = 300;
1256 if ( QApplication::desktop()->width() < 320 ) 1280 if ( QApplication::desktop()->width() < 320 )
1257 w = 220; 1281 w = 220;
1258 int h = bar.sizeHint().height() ; 1282 int h = bar.sizeHint().height() ;
1259 int dw = QApplication::desktop()->width(); 1283 int dw = QApplication::desktop()->width();
1260 int dh = QApplication::desktop()->height(); 1284 int dh = QApplication::desktop()->height();
1261 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1285 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1262 bar.show(); 1286 bar.show();
1263 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1287 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1264 qApp->processEvents(); 1288 qApp->processEvents();
1265 count = 0; 1289 count = 0;
1266 int addCount = 0; 1290 int addCount = 0;
1267 KCal::Attendee* a = 0; 1291 KCal::Attendee* a = 0;
1268 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1292 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1269 if ( ! bar.isVisible() ) 1293 if ( ! bar.isVisible() )
1270 return false; 1294 return false;
1271 bar.setProgress( count++ ); 1295 bar.setProgress( count++ );
1272 qApp->processEvents(); 1296 qApp->processEvents();
1273 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1297 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1274 if ( (*it).birthday().date().isValid() ){ 1298 if ( (*it).birthday().date().isValid() ){
1275 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1299 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1276 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1300 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1277 ++addCount; 1301 ++addCount;
1278 } 1302 }
1279 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1303 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1280 if ( anni.isValid() ){ 1304 if ( anni.isValid() ){
1281 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1305 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1282 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1306 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1283 ++addCount; 1307 ++addCount;
1284 } 1308 }
1285 } 1309 }
1286 updateView(); 1310 updateView();
1287 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1311 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1288 return true; 1312 return true;
1289} 1313}
1290 1314
1291bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1315bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1292{ 1316{
1293 //qDebug("addAnni "); 1317 //qDebug("addAnni ");
1294 Event * ev = new Event(); 1318 Event * ev = new Event();
1295 if ( a ) { 1319 if ( a ) {
1296 ev->addAttendee( a ); 1320 ev->addAttendee( a );
1297 } 1321 }
1298 QString kind; 1322 QString kind;
1299 if ( birthday ) 1323 if ( birthday )
1300 kind = i18n( "Birthday" ); 1324 kind = i18n( "Birthday" );
1301 else 1325 else
1302 kind = i18n( "Anniversary" ); 1326 kind = i18n( "Anniversary" );
1303 ev->setSummary( name + " - " + kind ); 1327 ev->setSummary( name + " - " + kind );
1304 ev->setOrganizer( "nobody@nowhere" ); 1328 ev->setOrganizer( "nobody@nowhere" );
1305 ev->setCategories( kind ); 1329 ev->setCategories( kind );
1306 ev->setDtStart( QDateTime(date) ); 1330 ev->setDtStart( QDateTime(date) );
1307 ev->setDtEnd( QDateTime(date) ); 1331 ev->setDtEnd( QDateTime(date) );
1308 ev->setFloats( true ); 1332 ev->setFloats( true );
1309 Recurrence * rec = ev->recurrence(); 1333 Recurrence * rec = ev->recurrence();
1310 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1334 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1311 rec->addYearlyNum( date.month() ); 1335 rec->addYearlyNum( date.month() );
1312 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1336 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1313 delete ev; 1337 delete ev;
1314 return false; 1338 return false;
1315 } 1339 }
1316 return true; 1340 return true;
1317 1341
1318} 1342}
1319bool CalendarView::importQtopia( const QString &categories, 1343bool CalendarView::importQtopia( const QString &categories,
1320 const QString &datebook, 1344 const QString &datebook,
1321 const QString &todolist ) 1345 const QString &todolist )
1322{ 1346{
1323 1347
1324 QtopiaFormat qtopiaFormat; 1348 QtopiaFormat qtopiaFormat;
1325 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1349 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1326 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1350 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1327 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1351 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1328 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1352 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1329 1353
1330 updateView(); 1354 updateView();
1331 return true; 1355 return true;
1332 1356
1333#if 0 1357#if 0
1334 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1358 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1335 mCurrentSyncDevice = "qtopia-XML"; 1359 mCurrentSyncDevice = "qtopia-XML";
1336 if ( KOPrefs::instance()->mAskForPreferences ) 1360 if ( KOPrefs::instance()->mAskForPreferences )
1337 edit_sync_options(); 1361 edit_sync_options();
1338 qApp->processEvents(); 1362 qApp->processEvents();
1339 CalendarLocal* calendar = new CalendarLocal(); 1363 CalendarLocal* calendar = new CalendarLocal();
1340 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1364 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1341 bool syncOK = false; 1365 bool syncOK = false;
1342 QtopiaFormat qtopiaFormat; 1366 QtopiaFormat qtopiaFormat;
1343 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1367 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1344 bool loadOk = true; 1368 bool loadOk = true;
1345 if ( !categories.isEmpty() ) 1369 if ( !categories.isEmpty() )
1346 loadOk = qtopiaFormat.load( calendar, categories ); 1370 loadOk = qtopiaFormat.load( calendar, categories );
1347 if ( loadOk && !datebook.isEmpty() ) 1371 if ( loadOk && !datebook.isEmpty() )
1348 loadOk = qtopiaFormat.load( calendar, datebook ); 1372 loadOk = qtopiaFormat.load( calendar, datebook );
1349 if ( loadOk && !todolist.isEmpty() ) 1373 if ( loadOk && !todolist.isEmpty() )
1350 loadOk = qtopiaFormat.load( calendar, todolist ); 1374 loadOk = qtopiaFormat.load( calendar, todolist );
1351 1375
1352 if ( loadOk ) { 1376 if ( loadOk ) {
1353 getEventViewerDialog()->setSyncMode( true ); 1377 getEventViewerDialog()->setSyncMode( true );
1354 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); 1378 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
1355 getEventViewerDialog()->setSyncMode( false ); 1379 getEventViewerDialog()->setSyncMode( false );
1356 qApp->processEvents(); 1380 qApp->processEvents();
1357 if ( syncOK ) { 1381 if ( syncOK ) {
1358 if ( KOPrefs::instance()->mWriteBackFile ) 1382 if ( KOPrefs::instance()->mWriteBackFile )
1359 { 1383 {
1360 // write back XML file 1384 // write back XML file
1361 1385
1362 } 1386 }
1363 setModified( true ); 1387 setModified( true );
1364 } 1388 }
1365 } else { 1389 } else {
1366 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1390 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1367 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1391 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1368 question, i18n("Ok")) ; 1392 question, i18n("Ok")) ;
1369 } 1393 }
1370 delete calendar; 1394 delete calendar;
1371 updateView(); 1395 updateView();
1372 return syncOK; 1396 return syncOK;
1373 1397
1374 1398
1375#endif 1399#endif
1376 1400
1377} 1401}
1378 1402
1379void CalendarView::setSyncEventsReadOnly() 1403void CalendarView::setSyncEventsReadOnly()
1380{ 1404{
1381 Event * ev; 1405 Event * ev;
1382 QPtrList<Event> eL = mCalendar->rawEvents(); 1406 QPtrList<Event> eL = mCalendar->rawEvents();
1383 ev = eL.first(); 1407 ev = eL.first();
1384 while ( ev ) { 1408 while ( ev ) {
1385 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1409 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1386 ev->setReadOnly( true ); 1410 ev->setReadOnly( true );
1387 ev = eL.next(); 1411 ev = eL.next();
1388 } 1412 }
1389} 1413}
1390bool CalendarView::openCalendar(QString filename, bool merge) 1414bool CalendarView::openCalendar(QString filename, bool merge)
1391{ 1415{
1392 1416
1393 if (filename.isEmpty()) { 1417 if (filename.isEmpty()) {
1394 return false; 1418 return false;
1395 } 1419 }
1396 1420
1397 if (!QFile::exists(filename)) { 1421 if (!QFile::exists(filename)) {
1398 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1422 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1399 return false; 1423 return false;
1400 } 1424 }
1401 1425
1402 globalFlagBlockAgenda = 1; 1426 globalFlagBlockAgenda = 1;
1403 if (!merge) mCalendar->close(); 1427 if (!merge) mCalendar->close();
1404 1428
1405 mStorage->setFileName( filename ); 1429 mStorage->setFileName( filename );
1406 1430
1407 if ( mStorage->load(KOPrefs::instance()->mUseQuicksave) ) { 1431 if ( mStorage->load(KOPrefs::instance()->mUseQuicksave) ) {
1408 if ( merge ) ;//setModified( true ); 1432 if ( merge ) ;//setModified( true );
1409 else { 1433 else {
1410 //setModified( true ); 1434 //setModified( true );
1411 mViewManager->setDocumentId( filename ); 1435 mViewManager->setDocumentId( filename );
1412 mDialogManager->setDocumentId( filename ); 1436 mDialogManager->setDocumentId( filename );
1413 mTodoList->setDocumentId( filename ); 1437 mTodoList->setDocumentId( filename );
1414 } 1438 }
1415 globalFlagBlockAgenda = 2; 1439 globalFlagBlockAgenda = 2;
1416 // if ( getLastSyncEvent() ) 1440 // if ( getLastSyncEvent() )
1417 // getLastSyncEvent()->setReadOnly( true ); 1441 // getLastSyncEvent()->setReadOnly( true );
1418 mCalendar->reInitAlarmSettings(); 1442 mCalendar->reInitAlarmSettings();
1419 setSyncEventsReadOnly(); 1443 setSyncEventsReadOnly();
1420 updateUnmanagedViews(); 1444 updateUnmanagedViews();
1421 updateView(); 1445 updateView();
1422 if ( filename != MainWindow::defaultFileName() ) 1446 if ( filename != MainWindow::defaultFileName() )
1423 saveCalendar( MainWindow::defaultFileName() ); 1447 saveCalendar( MainWindow::defaultFileName() );
1424 loadedFileVersion = QDateTime::currentDateTime(); 1448 loadedFileVersion = QDateTime::currentDateTime();
1425 return true; 1449 return true;
1426 } else { 1450 } else {
1427 // while failing to load, the calendar object could 1451 // while failing to load, the calendar object could
1428 // have become partially populated. Clear it out. 1452 // have become partially populated. Clear it out.
1429 if ( !merge ) mCalendar->close(); 1453 if ( !merge ) mCalendar->close();
1430 1454
1431 KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1455 KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1432 1456
1433 globalFlagBlockAgenda = 2; 1457 globalFlagBlockAgenda = 2;
1434 updateView(); 1458 updateView();
1435 } 1459 }
1436 return false; 1460 return false;
1437} 1461}
1438void CalendarView::setLoadedFileVersion(QDateTime dt) 1462void CalendarView::setLoadedFileVersion(QDateTime dt)
1439{ 1463{
1440 loadedFileVersion = dt; 1464 loadedFileVersion = dt;
1441} 1465}
1442bool CalendarView::checkFileChanged(QString fn) 1466bool CalendarView::checkFileChanged(QString fn)
1443{ 1467{
1444 QFileInfo finf ( fn ); 1468 QFileInfo finf ( fn );
1445 if ( !finf.exists() ) 1469 if ( !finf.exists() )
1446 return true; 1470 return true;
1447 QDateTime dt = finf.lastModified (); 1471 QDateTime dt = finf.lastModified ();
1448 if ( dt <= loadedFileVersion ) 1472 if ( dt <= loadedFileVersion )
1449 return false; 1473 return false;
1450 return true; 1474 return true;
1451 1475
1452} 1476}
1453bool CalendarView::checkFileVersion(QString fn) 1477bool CalendarView::checkFileVersion(QString fn)
1454{ 1478{
1455 QFileInfo finf ( fn ); 1479 QFileInfo finf ( fn );
1456 if ( !finf.exists() ) 1480 if ( !finf.exists() )
1457 return true; 1481 return true;
1458 QDateTime dt = finf.lastModified (); 1482 QDateTime dt = finf.lastModified ();
1459 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1483 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1460 //qDebug("file on disk version %s",dt.toString().latin1()); 1484 //qDebug("file on disk version %s",dt.toString().latin1());
1461 if ( dt <= loadedFileVersion ) 1485 if ( dt <= loadedFileVersion )
1462 return true; 1486 return true;
1463 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, false)) , 1487 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, false)) ,
1464 i18n("KO/Pi Warning"),i18n("Overwrite"), 1488 i18n("KO/Pi Warning"),i18n("Overwrite"),
1465 i18n("Sync+save")); 1489 i18n("Sync+save"));
1466 1490
1467 if ( km == KMessageBox::Cancel ) 1491 if ( km == KMessageBox::Cancel )
1468 return false; 1492 return false;
1469 if ( km == KMessageBox::Yes ) 1493 if ( km == KMessageBox::Yes )
1470 return true; 1494 return true;
1471 1495
1472 setSyncDevice("deleteaftersync" ); 1496 setSyncDevice("deleteaftersync" );
1473 KOPrefs::instance()->mAskForPreferences = true; 1497 KOPrefs::instance()->mAskForPreferences = true;
1474 KOPrefs::instance()->mSyncAlgoPrefs = 3; 1498 KOPrefs::instance()->mSyncAlgoPrefs = 3;
1475 KOPrefs::instance()->mWriteBackFile = false; 1499 KOPrefs::instance()->mWriteBackFile = false;
1476 KOPrefs::instance()->mWriteBackExistingOnly = false; 1500 KOPrefs::instance()->mWriteBackExistingOnly = false;
1477 KOPrefs::instance()->mShowSyncSummary = false; 1501 KOPrefs::instance()->mShowSyncSummary = false;
1478 syncCalendar( fn, 3 ); 1502 syncCalendar( fn, 3 );
1479 Event * e = getLastSyncEvent(); 1503 Event * e = getLastSyncEvent();
1480 mCalendar->deleteEvent ( e ); 1504 mCalendar->deleteEvent ( e );
1481 updateView(); 1505 updateView();
1482 return true; 1506 return true;
1483} 1507}
1484 1508
1485bool CalendarView::saveCalendar( QString filename ) 1509bool CalendarView::saveCalendar( QString filename )
1486{ 1510{
1487 1511
1488 // Store back all unsaved data into calendar object 1512 // Store back all unsaved data into calendar object
1489 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1513 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1490 if ( mViewManager->currentView() ) 1514 if ( mViewManager->currentView() )
1491 mViewManager->currentView()->flushView(); 1515 mViewManager->currentView()->flushView();
1492 1516
1493 //mStorage->setFileName( filename ); 1517 //mStorage->setFileName( filename );
1494 1518
1495 mStorage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 1519 mStorage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
1496 mStorage->setFileName( filename ); 1520 mStorage->setFileName( filename );
1497 bool success; 1521 bool success;
1498 success = mStorage->save(); 1522 success = mStorage->save();
1499 if ( !success ) { 1523 if ( !success ) {
1500 return false; 1524 return false;
1501 } 1525 }
1502 1526
1503 return true; 1527 return true;
1504} 1528}
1505 1529
1506void CalendarView::closeCalendar() 1530void CalendarView::closeCalendar()
1507{ 1531{
1508 1532
1509 // child windows no longer valid 1533 // child windows no longer valid
1510 emit closingDown(); 1534 emit closingDown();
1511 1535
1512 mCalendar->close(); 1536 mCalendar->close();
1513 setModified(false); 1537 setModified(false);
1514 updateView(); 1538 updateView();
1515} 1539}
1516 1540
1517void CalendarView::archiveCalendar() 1541void CalendarView::archiveCalendar()
1518{ 1542{
1519 mDialogManager->showArchiveDialog(); 1543 mDialogManager->showArchiveDialog();
1520} 1544}
1521 1545
1522 1546
1523void CalendarView::readSettings() 1547void CalendarView::readSettings()
1524{ 1548{
1525 1549
1526 1550
1527 // mViewManager->showAgendaView(); 1551 // mViewManager->showAgendaView();
1528 QString str; 1552 QString str;
1529 //qDebug("CalendarView::readSettings() "); 1553 //qDebug("CalendarView::readSettings() ");
1530 // read settings from the KConfig, supplying reasonable 1554 // read settings from the KConfig, supplying reasonable
1531 // defaults where none are to be found 1555 // defaults where none are to be found
1532 KConfig *config = KOGlobals::config(); 1556 KConfig *config = KOGlobals::config();
1533#ifndef KORG_NOSPLITTER 1557#ifndef KORG_NOSPLITTER
1534 config->setGroup("KOrganizer Geometry"); 1558 config->setGroup("KOrganizer Geometry");
1535 1559
1536 QValueList<int> sizes = config->readIntListEntry("Separator1"); 1560 QValueList<int> sizes = config->readIntListEntry("Separator1");
1537 if (sizes.count() != 2) { 1561 if (sizes.count() != 2) {
1538 sizes << mDateNavigator->minimumSizeHint().width(); 1562 sizes << mDateNavigator->minimumSizeHint().width();
1539 sizes << 300; 1563 sizes << 300;
1540 } 1564 }
1541 mPanner->setSizes(sizes); 1565 mPanner->setSizes(sizes);
1542 1566
1543 sizes = config->readIntListEntry("Separator2"); 1567 sizes = config->readIntListEntry("Separator2");
1544 if ( ( mResourceView && sizes.count() == 4 ) || 1568 if ( ( mResourceView && sizes.count() == 4 ) ||
1545 ( !mResourceView && sizes.count() == 3 ) ) { 1569 ( !mResourceView && sizes.count() == 3 ) ) {
1546 mLeftSplitter->setSizes(sizes); 1570 mLeftSplitter->setSizes(sizes);
1547 } 1571 }
1548#endif 1572#endif
1549 globalFlagBlockAgenda = 1; 1573 globalFlagBlockAgenda = 1;
1550 mViewManager->showAgendaView(); 1574 mViewManager->showAgendaView();
1551 //mViewManager->readSettings( config ); 1575 //mViewManager->readSettings( config );
1552 mTodoList->restoreLayout(config,QString("Todo Layout")); 1576 mTodoList->restoreLayout(config,QString("Todo Layout"));
1553 readFilterSettings(config); 1577 readFilterSettings(config);
1554 config->setGroup( "Views" ); 1578 config->setGroup( "Views" );
1555 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 1579 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
1556 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 1580 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
1557 else if ( dateCount == 7 ) mNavigator->selectWeek(); 1581 else if ( dateCount == 7 ) mNavigator->selectWeek();
1558 else mNavigator->selectDates( dateCount ); 1582 else mNavigator->selectDates( dateCount );
1559 // mViewManager->readSettings( config ); 1583 // mViewManager->readSettings( config );
1560 updateConfig(); 1584 updateConfig();
1561 globalFlagBlockAgenda = 2; 1585 globalFlagBlockAgenda = 2;
1562 mViewManager->readSettings( config ); 1586 mViewManager->readSettings( config );
1563#ifdef DESKTOP_VERSION 1587#ifdef DESKTOP_VERSION
1564 config->setGroup("WidgetLayout"); 1588 config->setGroup("WidgetLayout");
1565 QStringList list; 1589 QStringList list;
1566 list = config->readListEntry("MainLayout"); 1590 list = config->readListEntry("MainLayout");
1567 int x,y,w,h; 1591 int x,y,w,h;
1568 if ( ! list.isEmpty() ) { 1592 if ( ! list.isEmpty() ) {
1569 x = list[0].toInt(); 1593 x = list[0].toInt();
1570 y = list[1].toInt(); 1594 y = list[1].toInt();
1571 w = list[2].toInt(); 1595 w = list[2].toInt();
1572 h = list[3].toInt(); 1596 h = list[3].toInt();
1573 topLevelWidget()->setGeometry(x,y,w,h); 1597 topLevelWidget()->setGeometry(x,y,w,h);
1574 1598
1575 } else { 1599 } else {
1576 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 1600 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
1577 } 1601 }
1578 list = config->readListEntry("EditEventLayout"); 1602 list = config->readListEntry("EditEventLayout");
1579 if ( ! list.isEmpty() ) { 1603 if ( ! list.isEmpty() ) {
1580 x = list[0].toInt(); 1604 x = list[0].toInt();
1581 y = list[1].toInt(); 1605 y = list[1].toInt();
1582 w = list[2].toInt(); 1606 w = list[2].toInt();
1583 h = list[3].toInt(); 1607 h = list[3].toInt();
1584 mEventEditor->setGeometry(x,y,w,h); 1608 mEventEditor->setGeometry(x,y,w,h);
1585 1609
1586 } 1610 }
1587 list = config->readListEntry("EditTodoLayout"); 1611 list = config->readListEntry("EditTodoLayout");
1588 if ( ! list.isEmpty() ) { 1612 if ( ! list.isEmpty() ) {
1589 x = list[0].toInt(); 1613 x = list[0].toInt();
1590 y = list[1].toInt(); 1614 y = list[1].toInt();
1591 w = list[2].toInt(); 1615 w = list[2].toInt();
1592 h = list[3].toInt(); 1616 h = list[3].toInt();
1593 mTodoEditor->setGeometry(x,y,w,h); 1617 mTodoEditor->setGeometry(x,y,w,h);
1594 1618
1595 } 1619 }
1596 list = config->readListEntry("ViewerLayout"); 1620 list = config->readListEntry("ViewerLayout");
1597 if ( ! list.isEmpty() ) { 1621 if ( ! list.isEmpty() ) {
1598 x = list[0].toInt(); 1622 x = list[0].toInt();
1599 y = list[1].toInt(); 1623 y = list[1].toInt();
1600 w = list[2].toInt(); 1624 w = list[2].toInt();
1601 h = list[3].toInt(); 1625 h = list[3].toInt();
1602 getEventViewerDialog()->setGeometry(x,y,w,h); 1626 getEventViewerDialog()->setGeometry(x,y,w,h);
1603 } 1627 }
1604#endif 1628#endif
1605 1629
1606} 1630}
1607 1631
1608 1632
1609void CalendarView::writeSettings() 1633void CalendarView::writeSettings()
1610{ 1634{
1611 // kdDebug() << "CalendarView::writeSettings" << endl; 1635 // kdDebug() << "CalendarView::writeSettings" << endl;
1612 1636
1613 KConfig *config = KOGlobals::config(); 1637 KConfig *config = KOGlobals::config();
1614 1638
1615#ifndef KORG_NOSPLITTER 1639#ifndef KORG_NOSPLITTER
1616 config->setGroup("KOrganizer Geometry"); 1640 config->setGroup("KOrganizer Geometry");
1617 1641
1618 QValueList<int> list = mPanner->sizes(); 1642 QValueList<int> list = mPanner->sizes();
1619 config->writeEntry("Separator1",list); 1643 config->writeEntry("Separator1",list);
1620 1644
1621 list = mLeftSplitter->sizes(); 1645 list = mLeftSplitter->sizes();
1622 config->writeEntry("Separator2",list); 1646 config->writeEntry("Separator2",list);
1623#endif 1647#endif
1624 1648
1625 mViewManager->writeSettings( config ); 1649 mViewManager->writeSettings( config );
1626 mTodoList->saveLayout(config,QString("Todo Layout")); 1650 mTodoList->saveLayout(config,QString("Todo Layout"));
1627 mDialogManager->writeSettings( config ); 1651 mDialogManager->writeSettings( config );
1628 //KOPrefs::instance()->usrWriteConfig(); 1652 //KOPrefs::instance()->usrWriteConfig();
1629 KOPrefs::instance()->writeConfig(); 1653 KOPrefs::instance()->writeConfig();
1630 1654
1631 writeFilterSettings(config); 1655 writeFilterSettings(config);
1632 1656
1633 config->setGroup( "Views" ); 1657 config->setGroup( "Views" );
1634 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 1658 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
1635 1659
1636#ifdef DESKTOP_VERSION 1660#ifdef DESKTOP_VERSION
1637 config->setGroup("WidgetLayout"); 1661 config->setGroup("WidgetLayout");
1638 QStringList list ;//= config->readListEntry("MainLayout"); 1662 QStringList list ;//= config->readListEntry("MainLayout");
1639 int x,y,w,h; 1663 int x,y,w,h;
1640 QWidget* wid; 1664 QWidget* wid;
1641 wid = topLevelWidget(); 1665 wid = topLevelWidget();
1642 x = wid->geometry().x(); 1666 x = wid->geometry().x();
1643 y = wid->geometry().y(); 1667 y = wid->geometry().y();
1644 w = wid->width(); 1668 w = wid->width();
1645 h = wid->height(); 1669 h = wid->height();
1646 list.clear(); 1670 list.clear();
1647 list << QString::number( x ); 1671 list << QString::number( x );
1648 list << QString::number( y ); 1672 list << QString::number( y );
1649 list << QString::number( w ); 1673 list << QString::number( w );
1650 list << QString::number( h ); 1674 list << QString::number( h );
1651 config->writeEntry("MainLayout",list ); 1675 config->writeEntry("MainLayout",list );
1652 1676
1653 wid = mEventEditor; 1677 wid = mEventEditor;
1654 x = wid->geometry().x(); 1678 x = wid->geometry().x();
1655 y = wid->geometry().y(); 1679 y = wid->geometry().y();
1656 w = wid->width(); 1680 w = wid->width();
1657 h = wid->height(); 1681 h = wid->height();
1658 list.clear(); 1682 list.clear();
1659 list << QString::number( x ); 1683 list << QString::number( x );
1660 list << QString::number( y ); 1684 list << QString::number( y );
1661 list << QString::number( w ); 1685 list << QString::number( w );
1662 list << QString::number( h ); 1686 list << QString::number( h );
1663 config->writeEntry("EditEventLayout",list ); 1687 config->writeEntry("EditEventLayout",list );
1664 1688
1665 wid = mTodoEditor; 1689 wid = mTodoEditor;
1666 x = wid->geometry().x(); 1690 x = wid->geometry().x();
1667 y = wid->geometry().y(); 1691 y = wid->geometry().y();
1668 w = wid->width(); 1692 w = wid->width();
1669 h = wid->height(); 1693 h = wid->height();
1670 list.clear(); 1694 list.clear();
1671 list << QString::number( x ); 1695 list << QString::number( x );
1672 list << QString::number( y ); 1696 list << QString::number( y );
1673 list << QString::number( w ); 1697 list << QString::number( w );
1674 list << QString::number( h ); 1698 list << QString::number( h );
1675 config->writeEntry("EditTodoLayout",list ); 1699 config->writeEntry("EditTodoLayout",list );
1676 wid = getEventViewerDialog(); 1700 wid = getEventViewerDialog();
1677 x = wid->geometry().x(); 1701 x = wid->geometry().x();
1678 y = wid->geometry().y(); 1702 y = wid->geometry().y();
1679 w = wid->width(); 1703 w = wid->width();
1680 h = wid->height(); 1704 h = wid->height();
1681 list.clear(); 1705 list.clear();
1682 list << QString::number( x ); 1706 list << QString::number( x );
1683 list << QString::number( y ); 1707 list << QString::number( y );
1684 list << QString::number( w ); 1708 list << QString::number( w );
1685 list << QString::number( h ); 1709 list << QString::number( h );
1686 config->writeEntry("ViewerLayout",list ); 1710 config->writeEntry("ViewerLayout",list );
1687 wid = mDialogManager->getSearchDialog(); 1711 wid = mDialogManager->getSearchDialog();
1688 if ( wid ) { 1712 if ( wid ) {
1689 x = wid->geometry().x(); 1713 x = wid->geometry().x();
1690 y = wid->geometry().y(); 1714 y = wid->geometry().y();
1691 w = wid->width(); 1715 w = wid->width();
1692 h = wid->height(); 1716 h = wid->height();
1693 list.clear(); 1717 list.clear();
1694 list << QString::number( x ); 1718 list << QString::number( x );
1695 list << QString::number( y ); 1719 list << QString::number( y );
1696 list << QString::number( w ); 1720 list << QString::number( w );
1697 list << QString::number( h ); 1721 list << QString::number( h );
1698 config->writeEntry("SearchLayout",list ); 1722 config->writeEntry("SearchLayout",list );
1699 } 1723 }
1700#endif 1724#endif
1701 1725
1702 1726
1703 config->sync(); 1727 config->sync();
1704} 1728}
1705 1729
1706void CalendarView::readFilterSettings(KConfig *config) 1730void CalendarView::readFilterSettings(KConfig *config)
1707{ 1731{
1708 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 1732 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
1709 1733
1710 mFilters.clear(); 1734 mFilters.clear();
1711 1735
1712 config->setGroup("General"); 1736 config->setGroup("General");
1713 QStringList filterList = config->readListEntry("CalendarFilters"); 1737 QStringList filterList = config->readListEntry("CalendarFilters");
1714 1738
1715 QStringList::ConstIterator it = filterList.begin(); 1739 QStringList::ConstIterator it = filterList.begin();
1716 QStringList::ConstIterator end = filterList.end(); 1740 QStringList::ConstIterator end = filterList.end();
1717 while(it != end) { 1741 while(it != end) {
1718 // kdDebug() << " filter: " << (*it) << endl; 1742 // kdDebug() << " filter: " << (*it) << endl;
1719 1743
1720 CalFilter *filter; 1744 CalFilter *filter;
1721 filter = new CalFilter(*it); 1745 filter = new CalFilter(*it);
1722 config->setGroup("Filter_" + (*it)); 1746 config->setGroup("Filter_" + (*it));
1723 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 1747 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
1724 filter->setCriteria(config->readNumEntry("Criteria",0)); 1748 filter->setCriteria(config->readNumEntry("Criteria",0));
1725 filter->setCategoryList(config->readListEntry("CategoryList")); 1749 filter->setCategoryList(config->readListEntry("CategoryList"));
1726 mFilters.append(filter); 1750 mFilters.append(filter);
1727 1751
1728 ++it; 1752 ++it;
1729 } 1753 }
1730 1754
1731 if (mFilters.count() == 0) { 1755 if (mFilters.count() == 0) {
1732 CalFilter *filter = new CalFilter(i18n("Default")); 1756 CalFilter *filter = new CalFilter(i18n("Default"));
1733 mFilters.append(filter); 1757 mFilters.append(filter);
1734 } 1758 }
1735 mFilterView->updateFilters(); 1759 mFilterView->updateFilters();
1736 config->setGroup("FilterView"); 1760 config->setGroup("FilterView");
1737 1761
1738 mFilterView->blockSignals(true); 1762 mFilterView->blockSignals(true);
1739 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 1763 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
1740 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 1764 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
1741 mFilterView->blockSignals(false); 1765 mFilterView->blockSignals(false);
1742 // We do it manually to avoid it being done twice by the above calls 1766 // We do it manually to avoid it being done twice by the above calls
1743 updateFilter(); 1767 updateFilter();
1744} 1768}
1745 1769
1746void CalendarView::writeFilterSettings(KConfig *config) 1770void CalendarView::writeFilterSettings(KConfig *config)
1747{ 1771{
1748 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 1772 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
1749 1773
1750 QStringList filterList; 1774 QStringList filterList;
1751 1775
1752 CalFilter *filter = mFilters.first(); 1776 CalFilter *filter = mFilters.first();
1753 while(filter) { 1777 while(filter) {
1754 // kdDebug() << " fn: " << filter->name() << endl; 1778 // kdDebug() << " fn: " << filter->name() << endl;
1755 filterList << filter->name(); 1779 filterList << filter->name();
1756 config->setGroup("Filter_" + filter->name()); 1780 config->setGroup("Filter_" + filter->name());
1757 config->writeEntry("Criteria",filter->criteria()); 1781 config->writeEntry("Criteria",filter->criteria());
1758 config->writeEntry("CategoryList",filter->categoryList()); 1782 config->writeEntry("CategoryList",filter->categoryList());
1759 filter = mFilters.next(); 1783 filter = mFilters.next();
1760 } 1784 }
1761 config->setGroup("General"); 1785 config->setGroup("General");
1762 config->writeEntry("CalendarFilters",filterList); 1786 config->writeEntry("CalendarFilters",filterList);
1763 1787
1764 config->setGroup("FilterView"); 1788 config->setGroup("FilterView");
1765 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 1789 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
1766 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 1790 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
1767} 1791}
1768 1792
1769 1793
1770void CalendarView::goToday() 1794void CalendarView::goToday()
1771{ 1795{
1772 mNavigator->selectToday(); 1796 mNavigator->selectToday();
1773} 1797}
1774 1798
1775void CalendarView::goNext() 1799void CalendarView::goNext()
1776{ 1800{
1777 mNavigator->selectNext(); 1801 mNavigator->selectNext();
1778} 1802}
1779 1803
1780void CalendarView::goPrevious() 1804void CalendarView::goPrevious()
1781{ 1805{
1782 mNavigator->selectPrevious(); 1806 mNavigator->selectPrevious();
1783} 1807}
1784void CalendarView::goNextMonth() 1808void CalendarView::goNextMonth()
1785{ 1809{
1786 mNavigator->selectNextMonth(); 1810 mNavigator->selectNextMonth();
1787} 1811}
1788 1812
1789void CalendarView::goPreviousMonth() 1813void CalendarView::goPreviousMonth()
1790{ 1814{
1791 mNavigator->selectPreviousMonth(); 1815 mNavigator->selectPreviousMonth();
1792} 1816}
1793void CalendarView::writeLocale() 1817void CalendarView::writeLocale()
1794{ 1818{
1795 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); 1819 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime );
1796 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); 1820 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday );
1797 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); 1821 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate );
1798 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); 1822 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage );
1799 QString dummy = KOPrefs::instance()->mUserDateFormatLong; 1823 QString dummy = KOPrefs::instance()->mUserDateFormatLong;
1800 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 1824 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
1801 dummy = KOPrefs::instance()->mUserDateFormatShort; 1825 dummy = KOPrefs::instance()->mUserDateFormatShort;
1802 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 1826 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
1803 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, 1827 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving,
1804 KOPrefs::instance()->mDaylightsavingStart, 1828 KOPrefs::instance()->mDaylightsavingStart,
1805 KOPrefs::instance()->mDaylightsavingEnd ); 1829 KOPrefs::instance()->mDaylightsavingEnd );
1806 KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId ); 1830 KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId );
1807} 1831}
1808void CalendarView::updateConfig() 1832void CalendarView::updateConfig()
1809{ 1833{
1810 writeLocale(); 1834 writeLocale();
1811 if ( KOPrefs::instance()->mUseAppColors ) 1835 if ( KOPrefs::instance()->mUseAppColors )
1812 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 1836 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
1813 emit configChanged(); 1837 emit configChanged();
1814 mTodoList->updateConfig(); 1838 mTodoList->updateConfig();
1815 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 1839 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
1816 mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1840 mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1817 // To make the "fill window" configurations work 1841 // To make the "fill window" configurations work
1818 //mViewManager->raiseCurrentView(); 1842 //mViewManager->raiseCurrentView();
1819} 1843}
1820 1844
1821 1845
1822void CalendarView::eventChanged(Event *event) 1846void CalendarView::eventChanged(Event *event)
1823{ 1847{
1824 changeEventDisplay(event,KOGlobals::EVENTEDITED); 1848 changeEventDisplay(event,KOGlobals::EVENTEDITED);
1825 //updateUnmanagedViews(); 1849 //updateUnmanagedViews();
1826} 1850}
1827 1851
1828void CalendarView::eventAdded(Event *event) 1852void CalendarView::eventAdded(Event *event)
1829{ 1853{
1830 changeEventDisplay(event,KOGlobals::EVENTADDED); 1854 changeEventDisplay(event,KOGlobals::EVENTADDED);
1831} 1855}
1832 1856
1833void CalendarView::eventToBeDeleted(Event *) 1857void CalendarView::eventToBeDeleted(Event *)
1834{ 1858{
1835 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 1859 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
1836} 1860}
1837 1861
1838void CalendarView::eventDeleted() 1862void CalendarView::eventDeleted()
1839{ 1863{
1840 changeEventDisplay(0,KOGlobals::EVENTDELETED); 1864 changeEventDisplay(0,KOGlobals::EVENTDELETED);
1841} 1865}
1842void CalendarView::changeTodoDisplay(Todo *which, int action) 1866void CalendarView::changeTodoDisplay(Todo *which, int action)
1843{ 1867{
1844 changeIncidenceDisplay((Incidence *)which, action); 1868 changeIncidenceDisplay((Incidence *)which, action);
1845} 1869}
1846 1870
1847void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 1871void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
1848{ 1872{
1849 updateUnmanagedViews(); 1873 updateUnmanagedViews();
1850 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 1874 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
1851 if ( action == KOGlobals::EVENTDELETED ) { //delete 1875 if ( action == KOGlobals::EVENTDELETED ) { //delete
1852 mCalendar->checkAlarmForIncidence( 0, true ); 1876 mCalendar->checkAlarmForIncidence( 0, true );
1853 if ( mEventViewerDialog ) 1877 if ( mEventViewerDialog )
1854 mEventViewerDialog->hide(); 1878 mEventViewerDialog->hide();
1855 } 1879 }
1856 else 1880 else
1857 mCalendar->checkAlarmForIncidence( which , false ); 1881 mCalendar->checkAlarmForIncidence( which , false );
1858} 1882}
1859 1883
1860// most of the changeEventDisplays() right now just call the view's 1884// most of the changeEventDisplays() right now just call the view's
1861// total update mode, but they SHOULD be recoded to be more refresh-efficient. 1885// total update mode, but they SHOULD be recoded to be more refresh-efficient.
1862void CalendarView::changeEventDisplay(Event *which, int action) 1886void CalendarView::changeEventDisplay(Event *which, int action)
1863{ 1887{
1864 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 1888 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
1865 changeIncidenceDisplay((Incidence *)which, action); 1889 changeIncidenceDisplay((Incidence *)which, action);
1866 mDateNavigator->updateView(); 1890 mDateNavigator->updateView();
1867 //mDialogManager->updateSearchDialog(); 1891 //mDialogManager->updateSearchDialog();
1868 1892
1869 if (which) { 1893 if (which) {
1870 // If there is an event view visible update the display 1894 // If there is an event view visible update the display
1871 mViewManager->currentView()->changeEventDisplay(which,action); 1895 mViewManager->currentView()->changeEventDisplay(which,action);
1872 // TODO: check, if update needed 1896 // TODO: check, if update needed
1873 // if (which->getTodoStatus()) { 1897 // if (which->getTodoStatus()) {
1874 mTodoList->updateView(); 1898 mTodoList->updateView();
1875 // } 1899 // }
1876 } else { 1900 } else {
1877 mViewManager->currentView()->updateView(); 1901 mViewManager->currentView()->updateView();
1878 } 1902 }
1879} 1903}
1880 1904
1881 1905
1882void CalendarView::updateTodoViews() 1906void CalendarView::updateTodoViews()
1883{ 1907{
1884 1908
1885 mTodoList->updateView(); 1909 mTodoList->updateView();
1886 mViewManager->currentView()->updateView(); 1910 mViewManager->currentView()->updateView();
1887 1911
1888} 1912}
1889 1913
1890 1914
1891void CalendarView::updateView(const QDate &start, const QDate &end) 1915void CalendarView::updateView(const QDate &start, const QDate &end)
1892{ 1916{
1893 mTodoList->updateView(); 1917 mTodoList->updateView();
1894 mViewManager->updateView(start, end); 1918 mViewManager->updateView(start, end);
1895 //mDateNavigator->updateView(); 1919 //mDateNavigator->updateView();
1896} 1920}
1897 1921
1898void CalendarView::updateView() 1922void CalendarView::updateView()
1899{ 1923{
1900 DateList tmpList = mNavigator->selectedDates(); 1924 DateList tmpList = mNavigator->selectedDates();
1901 1925
1902 // We assume that the navigator only selects consecutive days. 1926 // We assume that the navigator only selects consecutive days.
1903 updateView( tmpList.first(), tmpList.last() ); 1927 updateView( tmpList.first(), tmpList.last() );
1904} 1928}
1905 1929
1906void CalendarView::updateUnmanagedViews() 1930void CalendarView::updateUnmanagedViews()
1907{ 1931{
1908 mDateNavigator->updateDayMatrix(); 1932 mDateNavigator->updateDayMatrix();
1909} 1933}
1910 1934
1911int CalendarView::msgItemDelete() 1935int CalendarView::msgItemDelete()
1912{ 1936{
1913 return KMessageBox::warningContinueCancel(this, 1937 return KMessageBox::warningContinueCancel(this,
1914 i18n("This item will be\npermanently deleted."), 1938 i18n("This item will be\npermanently deleted."),
1915 i18n("KO/Pi Confirmation"),i18n("Delete")); 1939 i18n("KO/Pi Confirmation"),i18n("Delete"));
1916} 1940}
1917 1941
1918 1942
1919void CalendarView::edit_cut() 1943void CalendarView::edit_cut()
1920{ 1944{
1921 Event *anEvent=0; 1945 Event *anEvent=0;
1922 1946
1923 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 1947 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
1924 1948
1925 if (mViewManager->currentView()->isEventView()) { 1949 if (mViewManager->currentView()->isEventView()) {
1926 if ( incidence && incidence->type() == "Event" ) { 1950 if ( incidence && incidence->type() == "Event" ) {
1927 anEvent = static_cast<Event *>(incidence); 1951 anEvent = static_cast<Event *>(incidence);
1928 } 1952 }
1929 } 1953 }
1930 1954
1931 if (!anEvent) { 1955 if (!anEvent) {
1932 KNotifyClient::beep(); 1956 KNotifyClient::beep();
1933 return; 1957 return;
1934 } 1958 }
1935 DndFactory factory( mCalendar ); 1959 DndFactory factory( mCalendar );
1936 factory.cutEvent(anEvent); 1960 factory.cutEvent(anEvent);
1937 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 1961 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
1938} 1962}
1939 1963
1940void CalendarView::edit_copy() 1964void CalendarView::edit_copy()
1941{ 1965{
1942 Event *anEvent=0; 1966 Event *anEvent=0;
1943 1967
1944 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 1968 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
1945 1969
1946 if (mViewManager->currentView()->isEventView()) { 1970 if (mViewManager->currentView()->isEventView()) {
1947 if ( incidence && incidence->type() == "Event" ) { 1971 if ( incidence && incidence->type() == "Event" ) {
1948 anEvent = static_cast<Event *>(incidence); 1972 anEvent = static_cast<Event *>(incidence);
1949 } 1973 }
1950 } 1974 }
1951 1975
1952 if (!anEvent) { 1976 if (!anEvent) {
1953 KNotifyClient::beep(); 1977 KNotifyClient::beep();
1954 return; 1978 return;
1955 } 1979 }
1956 DndFactory factory( mCalendar ); 1980 DndFactory factory( mCalendar );
1957 factory.copyEvent(anEvent); 1981 factory.copyEvent(anEvent);
1958} 1982}
1959 1983
1960void CalendarView::edit_paste() 1984void CalendarView::edit_paste()
1961{ 1985{
1962 QDate date = mNavigator->selectedDates().first(); 1986 QDate date = mNavigator->selectedDates().first();
1963 1987
1964 DndFactory factory( mCalendar ); 1988 DndFactory factory( mCalendar );
1965 Event *pastedEvent = factory.pasteEvent( date ); 1989 Event *pastedEvent = factory.pasteEvent( date );
1966 1990
1967 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 1991 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
1968} 1992}
1969 1993
1970void CalendarView::edit_options() 1994void CalendarView::edit_options()
1971{ 1995{
1972 mDialogManager->showOptionsDialog(); 1996 mDialogManager->showOptionsDialog();
1973 //writeSettings(); 1997 //writeSettings();
1974} 1998}
1975void CalendarView::edit_sync_options() 1999void CalendarView::edit_sync_options()
1976{ 2000{
1977 //mDialogManager->showSyncOptions(); 2001 //mDialogManager->showSyncOptions();
1978 //KOPrefs::instance()->mSyncAlgoPrefs 2002 //KOPrefs::instance()->mSyncAlgoPrefs
1979 QDialog dia( this, "dia", true ); 2003 QDialog dia( this, "dia", true );
1980 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); 2004 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice );
1981 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); 2005 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia);
1982 QVBoxLayout lay ( &dia ); 2006 QVBoxLayout lay ( &dia );
1983 lay.setSpacing( 2 ); 2007 lay.setSpacing( 2 );
1984 lay.setMargin( 3 ); 2008 lay.setMargin( 3 );
1985 lay.addWidget(&gr); 2009 lay.addWidget(&gr);
1986 QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); 2010 QRadioButton loc ( i18n("Take local entry on conflict"), &gr );
1987 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); 2011 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr );
1988 QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); 2012 QRadioButton newest( i18n("Take newest entry on conflict"), &gr );
1989 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); 2013 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr );
1990 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); 2014 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr );
1991 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); 2015 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr );
1992 //QRadioButton both( i18n("Take both on conflict"), &gr ); 2016 //QRadioButton both( i18n("Take both on conflict"), &gr );
1993 QPushButton pb ( "OK", &dia); 2017 QPushButton pb ( "OK", &dia);
1994 lay.addWidget( &pb ); 2018 lay.addWidget( &pb );
1995 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 2019 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
1996 switch ( KOPrefs::instance()->mSyncAlgoPrefs ) { 2020 switch ( KOPrefs::instance()->mSyncAlgoPrefs ) {
1997 case 0: 2021 case 0:
1998 loc.setChecked( true); 2022 loc.setChecked( true);
1999 break; 2023 break;
2000 case 1: 2024 case 1:
2001 rem.setChecked( true ); 2025 rem.setChecked( true );
2002 break; 2026 break;
2003 case 2: 2027 case 2:
2004 newest.setChecked( true); 2028 newest.setChecked( true);
2005 break; 2029 break;
2006 case 3: 2030 case 3:
2007 ask.setChecked( true); 2031 ask.setChecked( true);
2008 break; 2032 break;
2009 case 4: 2033 case 4:
2010 f_loc.setChecked( true); 2034 f_loc.setChecked( true);
2011 break; 2035 break;
2012 case 5: 2036 case 5:
2013 f_rem.setChecked( true); 2037 f_rem.setChecked( true);
2014 break; 2038 break;
2015 case 6: 2039 case 6:
2016 // both.setChecked( true); 2040 // both.setChecked( true);
2017 break; 2041 break;
2018 default: 2042 default:
2019 break; 2043 break;
2020 } 2044 }
2021 if ( dia.exec() ) { 2045 if ( dia.exec() ) {
2022 KOPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; 2046 KOPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ;
2023 } 2047 }
2024 2048
2025} 2049}
2026 2050
2027void CalendarView::slotSelectPickerDate( QDate d) 2051void CalendarView::slotSelectPickerDate( QDate d)
2028{ 2052{
2029 mDateFrame->hide(); 2053 mDateFrame->hide();
2030 if ( mDatePickerMode == 1 ) { 2054 if ( mDatePickerMode == 1 ) {
2031 mNavigator->slotDaySelect( d ); 2055 mNavigator->slotDaySelect( d );
2032 } else if ( mDatePickerMode == 2 ) { 2056 } else if ( mDatePickerMode == 2 ) {
2033 if ( mMoveIncidence->type() == "Todo" ) { 2057 if ( mMoveIncidence->type() == "Todo" ) {
2034 Todo * to = (Todo *) mMoveIncidence; 2058 Todo * to = (Todo *) mMoveIncidence;
2035 QTime tim; 2059 QTime tim;
2036 if ( to->hasDueDate() ) 2060 if ( to->hasDueDate() )
2037 tim = to->dtDue().time(); 2061 tim = to->dtDue().time();
2038 else { 2062 else {
2039 tim = QTime ( 0,0,0 ); 2063 tim = QTime ( 0,0,0 );
2040 to->setFloats( true ); 2064 to->setFloats( true );
2041 to->setHasDueDate( true ); 2065 to->setHasDueDate( true );
2042 } 2066 }
2043 QDateTime dt ( d,tim ); 2067 QDateTime dt ( d,tim );
2044 to->setDtDue( dt ); 2068 to->setDtDue( dt );
2045 todoChanged( to ); 2069 todoChanged( to );
2046 } else { 2070 } else {
2047 QTime tim = mMoveIncidence->dtStart().time(); 2071 QTime tim = mMoveIncidence->dtStart().time();
2048 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2072 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2049 QDateTime dt ( d,tim ); 2073 QDateTime dt ( d,tim );
2050 mMoveIncidence->setDtStart( dt ); 2074 mMoveIncidence->setDtStart( dt );
2051 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2075 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2052 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2076 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2053 } 2077 }
2054 2078
2055 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2079 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2056 } 2080 }
2057} 2081}
2058 2082
2059void CalendarView::removeCategories() 2083void CalendarView::removeCategories()
2060{ 2084{
2061 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2085 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2062 QStringList catList = KOPrefs::instance()->mCustomCategories; 2086 QStringList catList = KOPrefs::instance()->mCustomCategories;
2063 QStringList catIncList; 2087 QStringList catIncList;
2064 QStringList newCatList; 2088 QStringList newCatList;
2065 Incidence* inc = incList.first(); 2089 Incidence* inc = incList.first();
2066 int i; 2090 int i;
2067 int count = 0; 2091 int count = 0;
2068 while ( inc ) { 2092 while ( inc ) {
2069 newCatList.clear(); 2093 newCatList.clear();
2070 catIncList = inc->categories() ; 2094 catIncList = inc->categories() ;
2071 for( i = 0; i< catIncList.count(); ++i ) { 2095 for( i = 0; i< catIncList.count(); ++i ) {
2072 if ( catList.contains (catIncList[i])) 2096 if ( catList.contains (catIncList[i]))
2073 newCatList.append( catIncList[i] ); 2097 newCatList.append( catIncList[i] );
2074 } 2098 }
2075 newCatList.sort(); 2099 newCatList.sort();
2076 inc->setCategories( newCatList.join(",") ); 2100 inc->setCategories( newCatList.join(",") );
2077 inc = incList.next(); 2101 inc = incList.next();
2078 } 2102 }
2079} 2103}
2080 2104
2081int CalendarView::addCategories() 2105int CalendarView::addCategories()
2082{ 2106{
2083 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2107 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2084 QStringList catList = KOPrefs::instance()->mCustomCategories; 2108 QStringList catList = KOPrefs::instance()->mCustomCategories;
2085 QStringList catIncList; 2109 QStringList catIncList;
2086 Incidence* inc = incList.first(); 2110 Incidence* inc = incList.first();
2087 int i; 2111 int i;
2088 int count = 0; 2112 int count = 0;
2089 while ( inc ) { 2113 while ( inc ) {
2090 catIncList = inc->categories() ; 2114 catIncList = inc->categories() ;
2091 for( i = 0; i< catIncList.count(); ++i ) { 2115 for( i = 0; i< catIncList.count(); ++i ) {
2092 if ( !catList.contains (catIncList[i])) { 2116 if ( !catList.contains (catIncList[i])) {
2093 catList.append( catIncList[i] ); 2117 catList.append( catIncList[i] );
2094 //qDebug("add cat %s ", catIncList[i].latin1()); 2118 //qDebug("add cat %s ", catIncList[i].latin1());
2095 ++count; 2119 ++count;
2096 } 2120 }
2097 } 2121 }
2098 inc = incList.next(); 2122 inc = incList.next();
2099 } 2123 }
2100 catList.sort(); 2124 catList.sort();
2101 KOPrefs::instance()->mCustomCategories = catList; 2125 KOPrefs::instance()->mCustomCategories = catList;
2102 return count; 2126 return count;
2103} 2127}
2104 2128
2105void CalendarView::manageCategories() 2129void CalendarView::manageCategories()
2106{ 2130{
2107 KOCatPrefs* cp = new KOCatPrefs(); 2131 KOCatPrefs* cp = new KOCatPrefs();
2108 cp->show(); 2132 cp->show();
2109 int w =cp->sizeHint().width() ; 2133 int w =cp->sizeHint().width() ;
2110 int h = cp->sizeHint().height() ; 2134 int h = cp->sizeHint().height() ;
2111 int dw = QApplication::desktop()->width(); 2135 int dw = QApplication::desktop()->width();
2112 int dh = QApplication::desktop()->height(); 2136 int dh = QApplication::desktop()->height();
2113 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2137 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2114 if ( !cp->exec() ) { 2138 if ( !cp->exec() ) {
2115 delete cp; 2139 delete cp;
2116 return; 2140 return;
2117 } 2141 }
2118 int count = 0; 2142 int count = 0;
2119 if ( cp->addCat() ) { 2143 if ( cp->addCat() ) {
2120 count = addCategories(); 2144 count = addCategories();
2121 if ( count ) { 2145 if ( count ) {
2122 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2146 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2123 writeSettings(); 2147 writeSettings();
2124 } 2148 }
2125 } else { 2149 } else {
2126 removeCategories(); 2150 removeCategories();
2127 updateView(); 2151 updateView();
2128 } 2152 }
2129 delete cp; 2153 delete cp;
2130} 2154}
2131 2155
2132void CalendarView::beamIncidence(Incidence * Inc) 2156void CalendarView::beamIncidence(Incidence * Inc)
2133{ 2157{
2134 QPtrList<Incidence> delSel ; 2158 QPtrList<Incidence> delSel ;
2135 delSel.append(Inc); 2159 delSel.append(Inc);
2136 beamIncidenceList( delSel ); 2160 beamIncidenceList( delSel );
2137} 2161}
2138void CalendarView::beamCalendar() 2162void CalendarView::beamCalendar()
2139{ 2163{
2140 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2164 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2141 //qDebug("beamCalendar() "); 2165 //qDebug("beamCalendar() ");
2142 beamIncidenceList( delSel ); 2166 beamIncidenceList( delSel );
2143} 2167}
2144void CalendarView::beamFilteredCalendar() 2168void CalendarView::beamFilteredCalendar()
2145{ 2169{
2146 QPtrList<Incidence> delSel = mCalendar->incidences(); 2170 QPtrList<Incidence> delSel = mCalendar->incidences();
2147 //qDebug("beamFilteredCalendar() "); 2171 //qDebug("beamFilteredCalendar() ");
2148 beamIncidenceList( delSel ); 2172 beamIncidenceList( delSel );
2149} 2173}
2150void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2174void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2151{ 2175{
2152 if ( beamDialog->exec () == QDialog::Rejected ) 2176 if ( beamDialog->exec () == QDialog::Rejected )
2153 return; 2177 return;
2154 2178
2155 QString fn = "/tmp/kopibeamfile"; 2179 QString fn = "/tmp/kopibeamfile";
2156 QString mes; 2180 QString mes;
2157 bool createbup = true; 2181 bool createbup = true;
2158 if ( createbup ) { 2182 if ( createbup ) {
2159 QString description = "\n"; 2183 QString description = "\n";
2160 CalendarLocal* cal = new CalendarLocal(); 2184 CalendarLocal* cal = new CalendarLocal();
2161 if ( beamDialog->beamLocal() ) 2185 if ( beamDialog->beamLocal() )
2162 cal->setLocalTime(); 2186 cal->setLocalTime();
2163 else 2187 else
2164 cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 2188 cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
2165 Incidence *incidence = delSel.first(); 2189 Incidence *incidence = delSel.first();
2166 bool addText = false; 2190 bool addText = false;
2167 if ( delSel.count() < 10 ) 2191 if ( delSel.count() < 10 )
2168 addText = true; 2192 addText = true;
2169 else { 2193 else {
2170 description.sprintf(i18n(" %d items?"),delSel.count() ); 2194 description.sprintf(i18n(" %d items?"),delSel.count() );
2171 } 2195 }
2172 while ( incidence ) { 2196 while ( incidence ) {
2173 Incidence *in = incidence->clone(); 2197 Incidence *in = incidence->clone();
2174 if ( addText ) 2198 if ( addText )
2175 description += in->summary() + "\n"; 2199 description += in->summary() + "\n";
2176 cal->addIncidence( in ); 2200 cal->addIncidence( in );
2177 incidence = delSel.next(); 2201 incidence = delSel.next();
2178 } 2202 }
2179 if ( beamDialog->beamVcal() ) { 2203 if ( beamDialog->beamVcal() ) {
2180 fn += ".vcs"; 2204 fn += ".vcs";
2181 FileStorage storage( cal, fn, new VCalFormat ); 2205 FileStorage storage( cal, fn, new VCalFormat );
2182 storage.save(); 2206 storage.save();
2183 } else { 2207 } else {
2184 fn += ".ics"; 2208 fn += ".ics";
2185 FileStorage storage( cal, fn, new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 2209 FileStorage storage( cal, fn, new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
2186 storage.save(); 2210 storage.save();
2187 } 2211 }
2188 delete cal; 2212 delete cal;
2189 mes = i18n("KO/Pi: Ready for beaming"); 2213 mes = i18n("KO/Pi: Ready for beaming");
2190 setCaption(mes); 2214 setCaption(mes);
2191 2215
2192#ifndef DESKTOP_VERSION 2216#ifndef DESKTOP_VERSION
2193 Ir *ir = new Ir( this ); 2217 Ir *ir = new Ir( this );
2194 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 2218 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2195 ir->send( fn, description, "text/x-vCalendar" ); 2219 ir->send( fn, description, "text/x-vCalendar" );
2196#endif 2220#endif
2197 } 2221 }
2198} 2222}
2199void CalendarView::beamDone( Ir *ir ) 2223void CalendarView::beamDone( Ir *ir )
2200{ 2224{
2201#ifndef DESKTOP_VERSION 2225#ifndef DESKTOP_VERSION
2202 delete ir; 2226 delete ir;
2203#endif 2227#endif
2204} 2228}
2205 2229
2206void CalendarView::moveIncidence(Incidence * inc ) 2230void CalendarView::moveIncidence(Incidence * inc )
2207{ 2231{
2208 if ( !inc ) return; 2232 if ( !inc ) return;
2209 // qDebug("showDatePickerForIncidence( ) "); 2233 // qDebug("showDatePickerForIncidence( ) ");
2210 if ( mDateFrame->isVisible() ) 2234 if ( mDateFrame->isVisible() )
2211 mDateFrame->hide(); 2235 mDateFrame->hide();
2212 else { 2236 else {
2213 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; 2237 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ;
2214 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; 2238 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ;
2215 int dw = QApplication::desktop()->width(); 2239 int dw = QApplication::desktop()->width();
2216 int dh = QApplication::desktop()->height(); 2240 int dh = QApplication::desktop()->height();
2217 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2241 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2218 mDateFrame->show(); 2242 mDateFrame->show();
2219 } 2243 }
2220 mDatePickerMode = 2; 2244 mDatePickerMode = 2;
2221 mMoveIncidence = inc ; 2245 mMoveIncidence = inc ;
2222 QDate da; 2246 QDate da;
2223 if ( mMoveIncidence->type() == "Todo" ) { 2247 if ( mMoveIncidence->type() == "Todo" ) {
2224 Todo * to = (Todo *) mMoveIncidence; 2248 Todo * to = (Todo *) mMoveIncidence;
2225 if ( to->hasDueDate() ) 2249 if ( to->hasDueDate() )
2226 da = to->dtDue().date(); 2250 da = to->dtDue().date();
2227 else 2251 else
2228 da = QDate::currentDate(); 2252 da = QDate::currentDate();
2229 } else { 2253 } else {
2230 da = mMoveIncidence->dtStart().date(); 2254 da = mMoveIncidence->dtStart().date();
2231 } 2255 }
2232 mDatePicker->setDate( da ); 2256 mDatePicker->setDate( da );
2233} 2257}
2234void CalendarView::showDatePicker( ) 2258void CalendarView::showDatePicker( )
2235{ 2259{
2236 //qDebug("CalendarView::showDatePicker( ) "); 2260 //qDebug("CalendarView::showDatePicker( ) ");
2237 if ( mDateFrame->isVisible() ) 2261 if ( mDateFrame->isVisible() )
2238 mDateFrame->hide(); 2262 mDateFrame->hide();
2239 else { 2263 else {
2240 int w =mDatePicker->sizeHint().width() ; 2264 int w =mDatePicker->sizeHint().width() ;
2241 int h = mDatePicker->sizeHint().height() ; 2265 int h = mDatePicker->sizeHint().height() ;
2242 int dw = QApplication::desktop()->width(); 2266 int dw = QApplication::desktop()->width();
2243 int dh = QApplication::desktop()->height(); 2267 int dh = QApplication::desktop()->height();
2244 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2268 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2245 mDateFrame->show(); 2269 mDateFrame->show();
2246 } 2270 }
2247 mDatePickerMode = 1; 2271 mDatePickerMode = 1;
2248 mDatePicker->setDate( mNavigator->selectedDates().first() ); 2272 mDatePicker->setDate( mNavigator->selectedDates().first() );
2249} 2273}
2250 2274
2251void CalendarView::showEventEditor() 2275void CalendarView::showEventEditor()
2252{ 2276{
2253#ifdef DESKTOP_VERSION 2277#ifdef DESKTOP_VERSION
2254 mEventEditor->show(); 2278 mEventEditor->show();
2255#else 2279#else
2256 mEventEditor->showMaximized(); 2280 mEventEditor->showMaximized();
2257#endif 2281#endif
2258} 2282}
2259void CalendarView::showTodoEditor() 2283void CalendarView::showTodoEditor()
2260{ 2284{
2261#ifdef DESKTOP_VERSION 2285#ifdef DESKTOP_VERSION
2262 mTodoEditor->show(); 2286 mTodoEditor->show();
2263#else 2287#else
2264 mTodoEditor->showMaximized(); 2288 mTodoEditor->showMaximized();
2265#endif 2289#endif
2266} 2290}
2267void CalendarView::cancelIncidence(Incidence * inc ) 2291void CalendarView::cancelIncidence(Incidence * inc )
2268{ 2292{
2269 inc->setCancelled( ! inc->cancelled() ); 2293 inc->setCancelled( ! inc->cancelled() );
2270 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 2294 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
2271 updateView(); 2295 updateView();
2272} 2296}
2273void CalendarView::cloneIncidence(Incidence * orgInc ) 2297void CalendarView::cloneIncidence(Incidence * orgInc )
2274{ 2298{
2275 Incidence * newInc = orgInc->clone(); 2299 Incidence * newInc = orgInc->clone();
2276 newInc->recreate(); 2300 newInc->recreate();
2277 2301
2278 if ( newInc->type() == "Todo" ) { 2302 if ( newInc->type() == "Todo" ) {
2279 Todo* t = (Todo*) newInc; 2303 Todo* t = (Todo*) newInc;
2280 mTodoEditor->editTodo( t ); 2304 mTodoEditor->editTodo( t );
2281 showTodoEditor(); 2305 showTodoEditor();
2282 if ( mTodoEditor->exec() ) { 2306 if ( mTodoEditor->exec() ) {
2283 mCalendar->addTodo( t ); 2307 mCalendar->addTodo( t );
2284 updateView(); 2308 updateView();
2285 } else { 2309 } else {
2286 delete t; 2310 delete t;
2287 } 2311 }
2288 } 2312 }
2289 else { 2313 else {
2290 Event* e = (Event*) newInc; 2314 Event* e = (Event*) newInc;
2291 mEventEditor->editEvent( e ); 2315 mEventEditor->editEvent( e );
2292 showEventEditor(); 2316 showEventEditor();
2293 if ( mEventEditor->exec() ) { 2317 if ( mEventEditor->exec() ) {
2294 mCalendar->addEvent( e ); 2318 mCalendar->addEvent( e );
2295 updateView(); 2319 updateView();
2296 } else { 2320 } else {
2297 delete e; 2321 delete e;
2298 } 2322 }
2299 } 2323 }
2300} 2324}
2301 2325
2302void CalendarView::newEvent() 2326void CalendarView::newEvent()
2303{ 2327{
2304 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 2328 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
2305 KOAgendaView *aView = mViewManager->agendaView(); 2329 KOAgendaView *aView = mViewManager->agendaView();
2306 if (aView) { 2330 if (aView) {
2307 if (aView->selectionStart().isValid()) { 2331 if (aView->selectionStart().isValid()) {
2308 if (aView->selectedIsAllDay()) { 2332 if (aView->selectedIsAllDay()) {
2309 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 2333 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
2310 } else { 2334 } else {
2311 newEvent(aView->selectionStart(),aView->selectionEnd()); 2335 newEvent(aView->selectionStart(),aView->selectionEnd());
2312 } 2336 }
2313 return; 2337 return;
2314 } 2338 }
2315 } 2339 }
2316 2340
2317 QDate date = mNavigator->selectedDates().first(); 2341 QDate date = mNavigator->selectedDates().first();
2318 QDateTime current = QDateTime::currentDateTime(); 2342 QDateTime current = QDateTime::currentDateTime();
2319 if ( date <= current.date() ) { 2343 if ( date <= current.date() ) {
2320 int hour = current.time().hour() +1; 2344 int hour = current.time().hour() +1;
2321 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 2345 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
2322 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2346 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2323 } else 2347 } else
2324 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 2348 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
2325 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 2349 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
2326 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2350 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2327} 2351}
2328 2352
2329void CalendarView::newEvent(QDateTime fh) 2353void CalendarView::newEvent(QDateTime fh)
2330{ 2354{
2331 newEvent(fh, 2355 newEvent(fh,
2332 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 2356 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
2333} 2357}
2334 2358
2335void CalendarView::newEvent(QDate dt) 2359void CalendarView::newEvent(QDate dt)
2336{ 2360{
2337 newEvent(QDateTime(dt, QTime(0,0,0)), 2361 newEvent(QDateTime(dt, QTime(0,0,0)),
2338 QDateTime(dt, QTime(0,0,0)), true); 2362 QDateTime(dt, QTime(0,0,0)), true);
2339} 2363}
2340 2364
2341void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 2365void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
2342{ 2366{
2343 2367
2344 mEventEditor->newEvent(fromHint,toHint,allDay); 2368 mEventEditor->newEvent(fromHint,toHint,allDay);
2345 if ( mFilterView->filtersEnabled() ) { 2369 if ( mFilterView->filtersEnabled() ) {
2346 CalFilter *filter = mFilterView->selectedFilter(); 2370 CalFilter *filter = mFilterView->selectedFilter();
2347 if (filter && filter->showCategories()) { 2371 if (filter && filter->showCategories()) {
2348 mEventEditor->setCategories(filter->categoryList().join(",") ); 2372 mEventEditor->setCategories(filter->categoryList().join(",") );
2349 } 2373 }
2350 if ( filter ) 2374 if ( filter )
2351 mEventEditor->setSecrecy( filter->getSecrecy() ); 2375 mEventEditor->setSecrecy( filter->getSecrecy() );
2352 } 2376 }
2353 showEventEditor(); 2377 showEventEditor();
2354} 2378}
2355void CalendarView::todoAdded(Todo * t) 2379void CalendarView::todoAdded(Todo * t)
2356{ 2380{
2357 2381
2358 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 2382 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
2359 updateTodoViews(); 2383 updateTodoViews();
2360} 2384}
2361void CalendarView::todoChanged(Todo * t) 2385void CalendarView::todoChanged(Todo * t)
2362{ 2386{
2363 emit todoModified( t, 4 ); 2387 emit todoModified( t, 4 );
2364 // updateTodoViews(); 2388 // updateTodoViews();
2365} 2389}
2366void CalendarView::todoToBeDeleted(Todo *) 2390void CalendarView::todoToBeDeleted(Todo *)
2367{ 2391{
2368 //qDebug("todoToBeDeleted(Todo *) "); 2392 //qDebug("todoToBeDeleted(Todo *) ");
2369 updateTodoViews(); 2393 updateTodoViews();
2370} 2394}
2371void CalendarView::todoDeleted() 2395void CalendarView::todoDeleted()
2372{ 2396{
2373 //qDebug(" todoDeleted()"); 2397 //qDebug(" todoDeleted()");
2374 updateTodoViews(); 2398 updateTodoViews();
2375} 2399}
2376 2400
2377 2401
2378 2402
2379void CalendarView::newTodo() 2403void CalendarView::newTodo()
2380{ 2404{
2381 2405
2382 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); 2406 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true);
2383 if ( mFilterView->filtersEnabled() ) { 2407 if ( mFilterView->filtersEnabled() ) {
2384 CalFilter *filter = mFilterView->selectedFilter(); 2408 CalFilter *filter = mFilterView->selectedFilter();
2385 if (filter && filter->showCategories()) { 2409 if (filter && filter->showCategories()) {
2386 mTodoEditor->setCategories(filter->categoryList().join(",") ); 2410 mTodoEditor->setCategories(filter->categoryList().join(",") );
2387 } 2411 }
2388 if ( filter ) 2412 if ( filter )
2389 mTodoEditor->setSecrecy( filter->getSecrecy() ); 2413 mTodoEditor->setSecrecy( filter->getSecrecy() );
2390 } 2414 }
2391 showTodoEditor(); 2415 showTodoEditor();
2392} 2416}
2393 2417
2394void CalendarView::newSubTodo() 2418void CalendarView::newSubTodo()
2395{ 2419{
2396 Todo *todo = selectedTodo(); 2420 Todo *todo = selectedTodo();
2397 if ( todo ) newSubTodo( todo ); 2421 if ( todo ) newSubTodo( todo );
2398} 2422}
2399 2423
2400void CalendarView::newSubTodo(Todo *parentEvent) 2424void CalendarView::newSubTodo(Todo *parentEvent)
2401{ 2425{
2402 2426
2403 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); 2427 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true);
2404 showTodoEditor(); 2428 showTodoEditor();
2405} 2429}
2406 2430
2407void CalendarView::newFloatingEvent() 2431void CalendarView::newFloatingEvent()
2408{ 2432{
2409 DateList tmpList = mNavigator->selectedDates(); 2433 DateList tmpList = mNavigator->selectedDates();
2410 QDate date = tmpList.first(); 2434 QDate date = tmpList.first();
2411 2435
2412 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 2436 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
2413 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 2437 QDateTime( date, QTime( 12, 0, 0 ) ), true );
2414} 2438}
2415 2439
2416 2440
2417void CalendarView::editEvent( Event *event ) 2441void CalendarView::editEvent( Event *event )
2418{ 2442{
2419 2443
2420 if ( !event ) return; 2444 if ( !event ) return;
2421 if ( event->isReadOnly() ) { 2445 if ( event->isReadOnly() ) {
2422 showEvent( event ); 2446 showEvent( event );
2423 return; 2447 return;
2424 } 2448 }
2425 mEventEditor->editEvent( event , mFlagEditDescription); 2449 mEventEditor->editEvent( event , mFlagEditDescription);
2426 showEventEditor(); 2450 showEventEditor();
2427} 2451}
2428void CalendarView::editJournal( Journal *jour ) 2452void CalendarView::editJournal( Journal *jour )
2429{ 2453{
2430 if ( !jour ) return; 2454 if ( !jour ) return;
2431 mDialogManager->hideSearchDialog(); 2455 mDialogManager->hideSearchDialog();
2432 mViewManager->showJournalView(); 2456 mViewManager->showJournalView();
2433 mNavigator->slotDaySelect( jour->dtStart().date() ); 2457 mNavigator->slotDaySelect( jour->dtStart().date() );
2434} 2458}
2435void CalendarView::editTodo( Todo *todo ) 2459void CalendarView::editTodo( Todo *todo )
2436{ 2460{
2437 if ( !todo ) return; 2461 if ( !todo ) return;
2438 2462
2439 if ( todo->isReadOnly() ) { 2463 if ( todo->isReadOnly() ) {
2440 showTodo( todo ); 2464 showTodo( todo );
2441 return; 2465 return;
2442 } 2466 }
2443 mTodoEditor->editTodo( todo ,mFlagEditDescription); 2467 mTodoEditor->editTodo( todo ,mFlagEditDescription);
2444 showTodoEditor(); 2468 showTodoEditor();
2445 2469
2446} 2470}
2447 2471
2448KOEventViewerDialog* CalendarView::getEventViewerDialog() 2472KOEventViewerDialog* CalendarView::getEventViewerDialog()
2449{ 2473{
2450 if ( !mEventViewerDialog ) { 2474 if ( !mEventViewerDialog ) {
2451 mEventViewerDialog = new KOEventViewerDialog(this); 2475 mEventViewerDialog = new KOEventViewerDialog(this);
2452 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 2476 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
2453 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 2477 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
2454 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 2478 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
2455 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 2479 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
2456 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 2480 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
2457 viewManager(), SLOT( showAgendaView( bool ) ) ); 2481 viewManager(), SLOT( showAgendaView( bool ) ) );
2458 mEventViewerDialog->resize( 640, 480 ); 2482 mEventViewerDialog->resize( 640, 480 );
2459 2483
2460 } 2484 }
2461 return mEventViewerDialog; 2485 return mEventViewerDialog;
2462} 2486}
2463void CalendarView::showEvent(Event *event) 2487void CalendarView::showEvent(Event *event)
2464{ 2488{
2465 getEventViewerDialog()->setEvent(event); 2489 getEventViewerDialog()->setEvent(event);
2466 getEventViewerDialog()->showMe(); 2490 getEventViewerDialog()->showMe();
2467} 2491}
2468 2492
2469void CalendarView::showTodo(Todo *event) 2493void CalendarView::showTodo(Todo *event)
2470{ 2494{
2471 getEventViewerDialog()->setTodo(event); 2495 getEventViewerDialog()->setTodo(event);
2472 getEventViewerDialog()->showMe(); 2496 getEventViewerDialog()->showMe();
2473} 2497}
2474void CalendarView::showJournal( Journal *jour ) 2498void CalendarView::showJournal( Journal *jour )
2475{ 2499{
2476 getEventViewerDialog()->setJournal(jour); 2500 getEventViewerDialog()->setJournal(jour);
2477 getEventViewerDialog()->showMe(); 2501 getEventViewerDialog()->showMe();
2478 2502
2479} 2503}
2480// void CalendarView::todoModified (Todo *event, int changed) 2504// void CalendarView::todoModified (Todo *event, int changed)
2481// { 2505// {
2482// // if (mDialogList.find (event) != mDialogList.end ()) { 2506// // if (mDialogList.find (event) != mDialogList.end ()) {
2483// // kdDebug() << "Todo modified and open" << endl; 2507// // kdDebug() << "Todo modified and open" << endl;
2484// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 2508// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
2485// // temp->modified (changed); 2509// // temp->modified (changed);
2486 2510
2487// // } 2511// // }
2488 2512
2489// mViewManager->updateView(); 2513// mViewManager->updateView();
2490// } 2514// }
2491 2515
2492void CalendarView::appointment_show() 2516void CalendarView::appointment_show()
2493{ 2517{
2494 Event *anEvent = 0; 2518 Event *anEvent = 0;
2495 2519
2496 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2520 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2497 2521
2498 if (mViewManager->currentView()->isEventView()) { 2522 if (mViewManager->currentView()->isEventView()) {
2499 if ( incidence && incidence->type() == "Event" ) { 2523 if ( incidence && incidence->type() == "Event" ) {
2500 anEvent = static_cast<Event *>(incidence); 2524 anEvent = static_cast<Event *>(incidence);
2501 } 2525 }
2502 } 2526 }
2503 2527
2504 if (!anEvent) { 2528 if (!anEvent) {
2505 KNotifyClient::beep(); 2529 KNotifyClient::beep();
2506 return; 2530 return;
2507 } 2531 }
2508 2532
2509 showEvent(anEvent); 2533 showEvent(anEvent);
2510} 2534}
2511 2535
2512void CalendarView::appointment_edit() 2536void CalendarView::appointment_edit()
2513{ 2537{
2514 Event *anEvent = 0; 2538 Event *anEvent = 0;
2515 2539
2516 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2540 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2517 2541
2518 if (mViewManager->currentView()->isEventView()) { 2542 if (mViewManager->currentView()->isEventView()) {
2519 if ( incidence && incidence->type() == "Event" ) { 2543 if ( incidence && incidence->type() == "Event" ) {
2520 anEvent = static_cast<Event *>(incidence); 2544 anEvent = static_cast<Event *>(incidence);
2521 } 2545 }
2522 } 2546 }
2523 2547
2524 if (!anEvent) { 2548 if (!anEvent) {
2525 KNotifyClient::beep(); 2549 KNotifyClient::beep();
2526 return; 2550 return;
2527 } 2551 }
2528 2552
2529 editEvent(anEvent); 2553 editEvent(anEvent);
2530} 2554}
2531 2555
2532void CalendarView::appointment_delete() 2556void CalendarView::appointment_delete()
2533{ 2557{
2534 Event *anEvent = 0; 2558 Event *anEvent = 0;
2535 2559
2536 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2560 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2537 2561
2538 if (mViewManager->currentView()->isEventView()) { 2562 if (mViewManager->currentView()->isEventView()) {
2539 if ( incidence && incidence->type() == "Event" ) { 2563 if ( incidence && incidence->type() == "Event" ) {
2540 anEvent = static_cast<Event *>(incidence); 2564 anEvent = static_cast<Event *>(incidence);
2541 } 2565 }
2542 } 2566 }
2543 2567
2544 if (!anEvent) { 2568 if (!anEvent) {
2545 KNotifyClient::beep(); 2569 KNotifyClient::beep();
2546 return; 2570 return;
2547 } 2571 }
2548 2572
2549 deleteEvent(anEvent); 2573 deleteEvent(anEvent);
2550} 2574}
2551 2575
2552void CalendarView::todo_unsub(Todo *anTodo ) 2576void CalendarView::todo_unsub(Todo *anTodo )
2553{ 2577{
2554 // Todo *anTodo = selectedTodo(); 2578 // Todo *anTodo = selectedTodo();
2555 if (!anTodo) return; 2579 if (!anTodo) return;
2556 if (!anTodo->relatedTo()) return; 2580 if (!anTodo->relatedTo()) return;
2557 anTodo->relatedTo()->removeRelation(anTodo); 2581 anTodo->relatedTo()->removeRelation(anTodo);
2558 anTodo->setRelatedTo(0); 2582 anTodo->setRelatedTo(0);
2559 anTodo->updated(); 2583 anTodo->updated();
2560 anTodo->setRelatedToUid(""); 2584 anTodo->setRelatedToUid("");
2561 setModified(true); 2585 setModified(true);
2562 updateView(); 2586 updateView();
2563} 2587}
2564 2588
2565void CalendarView::deleteTodo(Todo *todo) 2589void CalendarView::deleteTodo(Todo *todo)
2566{ 2590{
2567 if (!todo) { 2591 if (!todo) {
2568 KNotifyClient::beep(); 2592 KNotifyClient::beep();
2569 return; 2593 return;
2570 } 2594 }
2571 if (KOPrefs::instance()->mConfirm) { 2595 if (KOPrefs::instance()->mConfirm) {
2572 switch (msgItemDelete()) { 2596 switch (msgItemDelete()) {
2573 case KMessageBox::Continue: // OK 2597 case KMessageBox::Continue: // OK
2574 if (!todo->relations().isEmpty()) { 2598 if (!todo->relations().isEmpty()) {
2575 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), 2599 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."),
2576 i18n("Delete To-Do")); 2600 i18n("Delete To-Do"));
2577 } else { 2601 } else {
2578 checkExternalId( todo ); 2602 checkExternalId( todo );
2579 calendar()->deleteTodo(todo); 2603 calendar()->deleteTodo(todo);
2580 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2604 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2581 updateView(); 2605 updateView();
2582 } 2606 }
2583 break; 2607 break;
2584 } // switch 2608 } // switch
2585 } else { 2609 } else {
2586 if (!todo->relations().isEmpty()) { 2610 if (!todo->relations().isEmpty()) {
2587 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), 2611 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."),
2588 i18n("Delete To-Do")); 2612 i18n("Delete To-Do"));
2589 } else { 2613 } else {
2590 checkExternalId( todo ); 2614 checkExternalId( todo );
2591 mCalendar->deleteTodo(todo); 2615 mCalendar->deleteTodo(todo);
2592 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2616 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2593 updateView(); 2617 updateView();
2594 } 2618 }
2595 } 2619 }
2596 emit updateSearchDialog(); 2620 emit updateSearchDialog();
2597} 2621}
2598void CalendarView::deleteJournal(Journal *jour) 2622void CalendarView::deleteJournal(Journal *jour)
2599{ 2623{
2600 if (!jour) { 2624 if (!jour) {
2601 KNotifyClient::beep(); 2625 KNotifyClient::beep();
2602 return; 2626 return;
2603 } 2627 }
2604 if (KOPrefs::instance()->mConfirm) { 2628 if (KOPrefs::instance()->mConfirm) {
2605 switch (msgItemDelete()) { 2629 switch (msgItemDelete()) {
2606 case KMessageBox::Continue: // OK 2630 case KMessageBox::Continue: // OK
2607 calendar()->deleteJournal(jour); 2631 calendar()->deleteJournal(jour);
2608 updateView(); 2632 updateView();
2609 break; 2633 break;
2610 } // switch 2634 } // switch
2611 } else { 2635 } else {
2612 calendar()->deleteJournal(jour);; 2636 calendar()->deleteJournal(jour);;
2613 updateView(); 2637 updateView();
2614 } 2638 }
2615 emit updateSearchDialog(); 2639 emit updateSearchDialog();
2616} 2640}
2617 2641
2618void CalendarView::deleteEvent(Event *anEvent) 2642void CalendarView::deleteEvent(Event *anEvent)
2619{ 2643{
2620 if (!anEvent) { 2644 if (!anEvent) {
2621 KNotifyClient::beep(); 2645 KNotifyClient::beep();
2622 return; 2646 return;
2623 } 2647 }
2624 2648
2625 if (anEvent->recurrence()->doesRecur()) { 2649 if (anEvent->recurrence()->doesRecur()) {
2626 QDate itemDate = mViewManager->currentSelectionDate(); 2650 QDate itemDate = mViewManager->currentSelectionDate();
2627 int km; 2651 int km;
2628 if (!itemDate.isValid()) { 2652 if (!itemDate.isValid()) {
2629 //kdDebug() << "Date Not Valid" << endl; 2653 //kdDebug() << "Date Not Valid" << endl;
2630 if (KOPrefs::instance()->mConfirm) { 2654 if (KOPrefs::instance()->mConfirm) {
2631 km = KMessageBox::warningContinueCancel(this,anEvent->summary() + 2655 km = KMessageBox::warningContinueCancel(this,anEvent->summary() +
2632 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), 2656 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"),
2633 i18n("KO/Pi Confirmation"),i18n("Delete All")); 2657 i18n("KO/Pi Confirmation"),i18n("Delete All"));
2634 if ( km == KMessageBox::Continue ) 2658 if ( km == KMessageBox::Continue )
2635 km = KMessageBox::No; // No = all below 2659 km = KMessageBox::No; // No = all below
2636 } else 2660 } else
2637 km = KMessageBox::No; 2661 km = KMessageBox::No;
2638 } else { 2662 } else {
2639 km = KMessageBox::warningYesNoCancel(this,anEvent->summary() + 2663 km = KMessageBox::warningYesNoCancel(this,anEvent->summary() +
2640 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ 2664 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+
2641 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), 2665 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"),
2642 i18n("KO/Pi Confirmation"),i18n("Current"), 2666 i18n("KO/Pi Confirmation"),i18n("Current"),
2643 i18n("All")); 2667 i18n("All"));
2644 } 2668 }
2645 switch(km) { 2669 switch(km) {
2646 2670
2647 case KMessageBox::No: // Continue // all 2671 case KMessageBox::No: // Continue // all
2648 //qDebug("KMessageBox::No "); 2672 //qDebug("KMessageBox::No ");
2649 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2673 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2650 schedule(Scheduler::Cancel,anEvent); 2674 schedule(Scheduler::Cancel,anEvent);
2651 2675
2652 checkExternalId( anEvent); 2676 checkExternalId( anEvent);
2653 mCalendar->deleteEvent(anEvent); 2677 mCalendar->deleteEvent(anEvent);
2654 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); 2678 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED);
2655 break; 2679 break;
2656 2680
2657 // Disabled because it does not work 2681 // Disabled because it does not work
2658 //#if 0 2682 //#if 0
2659 case KMessageBox::Yes: // just this one 2683 case KMessageBox::Yes: // just this one
2660 //QDate qd = mNavigator->selectedDates().first(); 2684 //QDate qd = mNavigator->selectedDates().first();
2661 //if (!qd.isValid()) { 2685 //if (!qd.isValid()) {
2662 // kdDebug() << "no date selected, or invalid date" << endl; 2686 // kdDebug() << "no date selected, or invalid date" << endl;
2663 // KNotifyClient::beep(); 2687 // KNotifyClient::beep();
2664 // return; 2688 // return;
2665 //} 2689 //}
2666 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); 2690 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1);
2667 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { 2691 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) {
2668 anEvent->addExDate(itemDate); 2692 anEvent->addExDate(itemDate);
2669 int duration = anEvent->recurrence()->duration(); 2693 int duration = anEvent->recurrence()->duration();
2670 if ( duration > 0 ) { 2694 if ( duration > 0 ) {
2671 anEvent->recurrence()->setDuration( duration - 1 ); 2695 anEvent->recurrence()->setDuration( duration - 1 );
2672 } 2696 }
2673 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); 2697 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED);
2674 } 2698 }
2675 break; 2699 break;
2676 //#endif 2700 //#endif
2677 } // switch 2701 } // switch
2678 } else { 2702 } else {
2679 if (KOPrefs::instance()->mConfirm) { 2703 if (KOPrefs::instance()->mConfirm) {
2680 switch (KMessageBox::warningContinueCancel(this,anEvent->summary() + 2704 switch (KMessageBox::warningContinueCancel(this,anEvent->summary() +
2681 i18n("\nAre you sure you want\nto delete this event?"), 2705 i18n("\nAre you sure you want\nto delete this event?"),
2682 i18n("KO/Pi Confirmation"),i18n("Delete"))) { 2706 i18n("KO/Pi Confirmation"),i18n("Delete"))) {
2683 case KMessageBox::Continue: // OK 2707 case KMessageBox::Continue: // OK
2684 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2708 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2685 schedule(Scheduler::Cancel,anEvent); 2709 schedule(Scheduler::Cancel,anEvent);
2686 checkExternalId( anEvent); 2710 checkExternalId( anEvent);
2687 mCalendar->deleteEvent(anEvent); 2711 mCalendar->deleteEvent(anEvent);
2688 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2712 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2689 break; 2713 break;
2690 } // switch 2714 } // switch
2691 } else { 2715 } else {
2692 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2716 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2693 schedule(Scheduler::Cancel,anEvent); 2717 schedule(Scheduler::Cancel,anEvent);
2694 checkExternalId( anEvent); 2718 checkExternalId( anEvent);
2695 mCalendar->deleteEvent(anEvent); 2719 mCalendar->deleteEvent(anEvent);
2696 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2720 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2697 } 2721 }
2698 } // if-else 2722 } // if-else
2699 emit updateSearchDialog(); 2723 emit updateSearchDialog();
2700} 2724}
2701 2725
2702bool CalendarView::deleteEvent(const QString &uid) 2726bool CalendarView::deleteEvent(const QString &uid)
2703{ 2727{
2704 Event *ev = mCalendar->event(uid); 2728 Event *ev = mCalendar->event(uid);
2705 if (ev) { 2729 if (ev) {
2706 deleteEvent(ev); 2730 deleteEvent(ev);
2707 return true; 2731 return true;
2708 } else { 2732 } else {
2709 return false; 2733 return false;
2710 } 2734 }
2711} 2735}
2712 2736
2713/*****************************************************************************/ 2737/*****************************************************************************/
2714 2738
2715void CalendarView::action_mail() 2739void CalendarView::action_mail()
2716{ 2740{
2717#ifndef KORG_NOMAIL 2741#ifndef KORG_NOMAIL
2718 KOMailClient mailClient; 2742 KOMailClient mailClient;
2719 2743
2720 Incidence *incidence = currentSelection(); 2744 Incidence *incidence = currentSelection();
2721 2745
2722 if (!incidence) { 2746 if (!incidence) {
2723 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 2747 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
2724 return; 2748 return;
2725 } 2749 }
2726 if(incidence->attendeeCount() == 0 ) { 2750 if(incidence->attendeeCount() == 0 ) {
2727 KMessageBox::sorry(this, 2751 KMessageBox::sorry(this,
2728 i18n("Can't generate mail:\nNo attendees defined.\n")); 2752 i18n("Can't generate mail:\nNo attendees defined.\n"));
2729 return; 2753 return;
2730 } 2754 }
2731 2755
2732 CalendarLocal cal_tmp; 2756 CalendarLocal cal_tmp;
2733 Event *event = 0; 2757 Event *event = 0;
2734 Event *ev = 0; 2758 Event *ev = 0;
2735 if ( incidence && incidence->type() == "Event" ) { 2759 if ( incidence && incidence->type() == "Event" ) {
2736 event = static_cast<Event *>(incidence); 2760 event = static_cast<Event *>(incidence);
2737 ev = new Event(*event); 2761 ev = new Event(*event);
2738 cal_tmp.addEvent(ev); 2762 cal_tmp.addEvent(ev);
2739 } 2763 }
2740 ICalFormat mForm( KOPrefs::instance()->mUseQuicksave); 2764 ICalFormat mForm( KOPrefs::instance()->mUseQuicksave);
2741 QString attachment = mForm.toString( &cal_tmp ); 2765 QString attachment = mForm.toString( &cal_tmp );
2742 if (ev) delete(ev); 2766 if (ev) delete(ev);
2743 2767
2744 mailClient.mailAttendees(currentSelection(), attachment); 2768 mailClient.mailAttendees(currentSelection(), attachment);
2745 2769
2746#endif 2770#endif
2747 2771
2748#if 0 2772#if 0
2749 Event *anEvent = 0; 2773 Event *anEvent = 0;
2750 if (mViewManager->currentView()->isEventView()) { 2774 if (mViewManager->currentView()->isEventView()) {
2751 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); 2775 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first());
2752 } 2776 }
2753 2777
2754 if (!anEvent) { 2778 if (!anEvent) {
2755 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 2779 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
2756 return; 2780 return;
2757 } 2781 }
2758 if(anEvent->attendeeCount() == 0 ) { 2782 if(anEvent->attendeeCount() == 0 ) {
2759 KMessageBox::sorry(this, 2783 KMessageBox::sorry(this,
2760 i18n("Can't generate mail:\nNo attendees defined.\n")); 2784 i18n("Can't generate mail:\nNo attendees defined.\n"));
2761 return; 2785 return;
2762 } 2786 }
2763 2787
2764 mailobject.emailEvent(anEvent); 2788 mailobject.emailEvent(anEvent);
2765#endif 2789#endif
2766} 2790}
2767 2791
2768 2792
2769void CalendarView::schedule_publish(Incidence *incidence) 2793void CalendarView::schedule_publish(Incidence *incidence)
2770{ 2794{
2771 Event *event = 0; 2795 Event *event = 0;
2772 Todo *todo = 0; 2796 Todo *todo = 0;
2773 2797
2774 if (incidence == 0) { 2798 if (incidence == 0) {
2775 incidence = mViewManager->currentView()->selectedIncidences().first(); 2799 incidence = mViewManager->currentView()->selectedIncidences().first();
2776 if (incidence == 0) { 2800 if (incidence == 0) {
2777 incidence = mTodoList->selectedIncidences().first(); 2801 incidence = mTodoList->selectedIncidences().first();
2778 } 2802 }
2779 } 2803 }
2780 if ( incidence && incidence->type() == "Event" ) { 2804 if ( incidence && incidence->type() == "Event" ) {
2781 event = static_cast<Event *>(incidence); 2805 event = static_cast<Event *>(incidence);
2782 } else { 2806 } else {
2783 if ( incidence && incidence->type() == "Todo" ) { 2807 if ( incidence && incidence->type() == "Todo" ) {
2784 todo = static_cast<Todo *>(incidence); 2808 todo = static_cast<Todo *>(incidence);
2785 } 2809 }
2786 } 2810 }
2787 2811
2788 if (!event && !todo) { 2812 if (!event && !todo) {
2789 KMessageBox::sorry(this,i18n("No event selected.")); 2813 KMessageBox::sorry(this,i18n("No event selected."));
2790 return; 2814 return;
2791 } 2815 }
2792 2816
2793 PublishDialog *publishdlg = new PublishDialog(); 2817 PublishDialog *publishdlg = new PublishDialog();
2794 if (incidence->attendeeCount()>0) { 2818 if (incidence->attendeeCount()>0) {
2795 QPtrList<Attendee> attendees = incidence->attendees(); 2819 QPtrList<Attendee> attendees = incidence->attendees();
2796 attendees.first(); 2820 attendees.first();
2797 while ( attendees.current()!=0 ) { 2821 while ( attendees.current()!=0 ) {
2798 publishdlg->addAttendee(attendees.current()); 2822 publishdlg->addAttendee(attendees.current());
2799 attendees.next(); 2823 attendees.next();
2800 } 2824 }
2801 } 2825 }
2802 bool send = true; 2826 bool send = true;
2803 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { 2827 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) {
2804 if ( publishdlg->exec() != QDialog::Accepted ) 2828 if ( publishdlg->exec() != QDialog::Accepted )
2805 send = false; 2829 send = false;
2806 } 2830 }
2807 if ( send ) { 2831 if ( send ) {
2808 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 2832 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
2809 if ( event ) { 2833 if ( event ) {
2810 Event *ev = new Event(*event); 2834 Event *ev = new Event(*event);
2811 ev->registerObserver(0); 2835 ev->registerObserver(0);
2812 ev->clearAttendees(); 2836 ev->clearAttendees();
2813 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 2837 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
2814 delete(ev); 2838 delete(ev);
2815 } 2839 }
2816 } else { 2840 } else {
2817 if ( todo ) { 2841 if ( todo ) {
2818 Todo *ev = new Todo(*todo); 2842 Todo *ev = new Todo(*todo);
2819 ev->registerObserver(0); 2843 ev->registerObserver(0);
2820 ev->clearAttendees(); 2844 ev->clearAttendees();
2821 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 2845 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
2822 delete(ev); 2846 delete(ev);
2823 } 2847 }
2824 } 2848 }
2825 } 2849 }
2826 } 2850 }
2827 delete publishdlg; 2851 delete publishdlg;
2828} 2852}
2829 2853
2830void CalendarView::schedule_request(Incidence *incidence) 2854void CalendarView::schedule_request(Incidence *incidence)
2831{ 2855{
2832 schedule(Scheduler::Request,incidence); 2856 schedule(Scheduler::Request,incidence);
2833} 2857}
2834 2858
2835void CalendarView::schedule_refresh(Incidence *incidence) 2859void CalendarView::schedule_refresh(Incidence *incidence)
2836{ 2860{
2837 schedule(Scheduler::Refresh,incidence); 2861 schedule(Scheduler::Refresh,incidence);
2838} 2862}
2839 2863
2840void CalendarView::schedule_cancel(Incidence *incidence) 2864void CalendarView::schedule_cancel(Incidence *incidence)
2841{ 2865{
2842 schedule(Scheduler::Cancel,incidence); 2866 schedule(Scheduler::Cancel,incidence);
2843} 2867}
2844 2868
2845void CalendarView::schedule_add(Incidence *incidence) 2869void CalendarView::schedule_add(Incidence *incidence)
2846{ 2870{
2847 schedule(Scheduler::Add,incidence); 2871 schedule(Scheduler::Add,incidence);
2848} 2872}
2849 2873
2850void CalendarView::schedule_reply(Incidence *incidence) 2874void CalendarView::schedule_reply(Incidence *incidence)
2851{ 2875{
2852 schedule(Scheduler::Reply,incidence); 2876 schedule(Scheduler::Reply,incidence);
2853} 2877}
2854 2878
2855void CalendarView::schedule_counter(Incidence *incidence) 2879void CalendarView::schedule_counter(Incidence *incidence)
2856{ 2880{
2857 schedule(Scheduler::Counter,incidence); 2881 schedule(Scheduler::Counter,incidence);
2858} 2882}
2859 2883
2860void CalendarView::schedule_declinecounter(Incidence *incidence) 2884void CalendarView::schedule_declinecounter(Incidence *incidence)
2861{ 2885{
2862 schedule(Scheduler::Declinecounter,incidence); 2886 schedule(Scheduler::Declinecounter,incidence);
2863} 2887}
2864 2888
2865void CalendarView::schedule_publish_freebusy(int daysToPublish) 2889void CalendarView::schedule_publish_freebusy(int daysToPublish)
2866{ 2890{
2867 QDateTime start = QDateTime::currentDateTime(); 2891 QDateTime start = QDateTime::currentDateTime();
2868 QDateTime end = start.addDays(daysToPublish); 2892 QDateTime end = start.addDays(daysToPublish);
2869 2893
2870 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); 2894 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end);
2871 freebusy->setOrganizer(KOPrefs::instance()->email()); 2895 freebusy->setOrganizer(KOPrefs::instance()->email());
2872 2896
2873 2897
2874 PublishDialog *publishdlg = new PublishDialog(); 2898 PublishDialog *publishdlg = new PublishDialog();
2875 if ( publishdlg->exec() == QDialog::Accepted ) { 2899 if ( publishdlg->exec() == QDialog::Accepted ) {
2876 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 2900 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
2877 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { 2901 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) {
2878 delete(freebusy); 2902 delete(freebusy);
2879 } 2903 }
2880 } 2904 }
2881 delete publishdlg; 2905 delete publishdlg;
2882} 2906}
2883 2907
2884void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) 2908void CalendarView::schedule(Scheduler::Method method, Incidence *incidence)
2885{ 2909{
2886 Event *event = 0; 2910 Event *event = 0;
2887 Todo *todo = 0; 2911 Todo *todo = 0;
2888 2912
2889 if (incidence == 0) { 2913 if (incidence == 0) {
2890 incidence = mViewManager->currentView()->selectedIncidences().first(); 2914 incidence = mViewManager->currentView()->selectedIncidences().first();
2891 if (incidence == 0) { 2915 if (incidence == 0) {
2892 incidence = mTodoList->selectedIncidences().first(); 2916 incidence = mTodoList->selectedIncidences().first();
2893 } 2917 }
2894 } 2918 }
2895 if ( incidence && incidence->type() == "Event" ) { 2919 if ( incidence && incidence->type() == "Event" ) {
2896 event = static_cast<Event *>(incidence); 2920 event = static_cast<Event *>(incidence);
2897 } 2921 }
2898 if ( incidence && incidence->type() == "Todo" ) { 2922 if ( incidence && incidence->type() == "Todo" ) {
2899 todo = static_cast<Todo *>(incidence); 2923 todo = static_cast<Todo *>(incidence);
2900 } 2924 }
2901 2925
2902 if (!event && !todo) { 2926 if (!event && !todo) {
2903 KMessageBox::sorry(this,i18n("No event selected.")); 2927 KMessageBox::sorry(this,i18n("No event selected."));
2904 return; 2928 return;
2905 } 2929 }
2906 2930
2907 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { 2931 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) {
2908 KMessageBox::sorry(this,i18n("The event has no attendees.")); 2932 KMessageBox::sorry(this,i18n("The event has no attendees."));
2909 return; 2933 return;
2910 } 2934 }
2911 2935
2912 Event *ev = 0; 2936 Event *ev = 0;
2913 if (event) ev = new Event(*event); 2937 if (event) ev = new Event(*event);
2914 Todo *to = 0; 2938 Todo *to = 0;
2915 if (todo) to = new Todo(*todo); 2939 if (todo) to = new Todo(*todo);
2916 2940
2917 if (method == Scheduler::Reply || method == Scheduler::Refresh) { 2941 if (method == Scheduler::Reply || method == Scheduler::Refresh) {
2918 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 2942 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
2919 if (!me) { 2943 if (!me) {
2920 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); 2944 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails."));
2921 return; 2945 return;
2922 } 2946 }
2923 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { 2947 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) {
2924 StatusDialog *statdlg = new StatusDialog(this); 2948 StatusDialog *statdlg = new StatusDialog(this);
2925 if (!statdlg->exec()==QDialog::Accepted) return; 2949 if (!statdlg->exec()==QDialog::Accepted) return;
2926 me->setStatus( statdlg->status() ); 2950 me->setStatus( statdlg->status() );
2927 delete(statdlg); 2951 delete(statdlg);
2928 } 2952 }
2929 Attendee *menew = new Attendee(*me); 2953 Attendee *menew = new Attendee(*me);
2930 if (ev) { 2954 if (ev) {
2931 ev->clearAttendees(); 2955 ev->clearAttendees();
2932 ev->addAttendee(menew,false); 2956 ev->addAttendee(menew,false);
2933 } else { 2957 } else {
2934 if (to) { 2958 if (to) {
2935 todo->clearAttendees(); 2959 todo->clearAttendees();
2936 todo->addAttendee(menew,false); 2960 todo->addAttendee(menew,false);
2937 } 2961 }
2938 } 2962 }
2939 } 2963 }
2940 2964
2941 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 2965 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
2942 if (ev) { 2966 if (ev) {
2943 if ( !dlg->addMessage(ev,method) ) delete(ev); 2967 if ( !dlg->addMessage(ev,method) ) delete(ev);
2944 } else { 2968 } else {
2945 if (to) { 2969 if (to) {
2946 if ( !dlg->addMessage(to,method) ) delete(to); 2970 if ( !dlg->addMessage(to,method) ) delete(to);
2947 } 2971 }
2948 } 2972 }
2949} 2973}
2950 2974
2951void CalendarView::openAddressbook() 2975void CalendarView::openAddressbook()
2952{ 2976{
2953 KRun::runCommand("kaddressbook"); 2977 KRun::runCommand("kaddressbook");
2954} 2978}
2955 2979
2956void CalendarView::setModified(bool modified) 2980void CalendarView::setModified(bool modified)
2957{ 2981{
2958 if ( modified ) 2982 if ( modified )
2959 emit signalmodified(); 2983 emit signalmodified();
2960 if (mModified != modified) { 2984 if (mModified != modified) {
2961 mModified = modified; 2985 mModified = modified;
2962 emit modifiedChanged(mModified); 2986 emit modifiedChanged(mModified);
2963 } 2987 }
2964} 2988}
2965 2989
2966bool CalendarView::isReadOnly() 2990bool CalendarView::isReadOnly()
2967{ 2991{
2968 return mReadOnly; 2992 return mReadOnly;
2969} 2993}
2970 2994
2971void CalendarView::setReadOnly(bool readOnly) 2995void CalendarView::setReadOnly(bool readOnly)
2972{ 2996{
2973 if (mReadOnly != readOnly) { 2997 if (mReadOnly != readOnly) {
2974 mReadOnly = readOnly; 2998 mReadOnly = readOnly;
2975 emit readOnlyChanged(mReadOnly); 2999 emit readOnlyChanged(mReadOnly);
2976 } 3000 }
2977} 3001}
2978 3002
2979bool CalendarView::isModified() 3003bool CalendarView::isModified()
2980{ 3004{
2981 return mModified; 3005 return mModified;
2982} 3006}
2983 3007
2984void CalendarView::printSetup() 3008void CalendarView::printSetup()
2985{ 3009{
2986#ifndef KORG_NOPRINTER 3010#ifndef KORG_NOPRINTER
2987 createPrinter(); 3011 createPrinter();
2988 3012
2989 mCalPrinter->setupPrinter(); 3013 mCalPrinter->setupPrinter();
2990#endif 3014#endif
2991} 3015}
2992 3016
2993void CalendarView::print() 3017void CalendarView::print()
2994{ 3018{
2995#ifndef KORG_NOPRINTER 3019#ifndef KORG_NOPRINTER
2996 createPrinter(); 3020 createPrinter();
2997 3021
2998 DateList tmpDateList = mNavigator->selectedDates(); 3022 DateList tmpDateList = mNavigator->selectedDates();
2999 mCalPrinter->print(CalPrinter::Month, 3023 mCalPrinter->print(CalPrinter::Month,
3000 tmpDateList.first(), tmpDateList.last()); 3024 tmpDateList.first(), tmpDateList.last());
3001#endif 3025#endif
3002} 3026}
3003 3027
3004void CalendarView::printPreview() 3028void CalendarView::printPreview()
3005{ 3029{
3006#ifndef KORG_NOPRINTER 3030#ifndef KORG_NOPRINTER
3007 kdDebug() << "CalendarView::printPreview()" << endl; 3031 kdDebug() << "CalendarView::printPreview()" << endl;
3008 3032
3009 createPrinter(); 3033 createPrinter();
3010 3034
3011 DateList tmpDateList = mNavigator->selectedDates(); 3035 DateList tmpDateList = mNavigator->selectedDates();
3012 3036
3013 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), 3037 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(),
3014 tmpDateList.last()); 3038 tmpDateList.last());
3015#endif 3039#endif
3016} 3040}
3017 3041
3018void CalendarView::exportICalendar() 3042void CalendarView::exportICalendar()
3019{ 3043{
3020 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); 3044 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this);
3021 3045
3022 // Force correct extension 3046 // Force correct extension
3023 if (filename.right(4) != ".ics") filename += ".ics"; 3047 if (filename.right(4) != ".ics") filename += ".ics";
3024 3048
3025 FileStorage storage( mCalendar, filename, new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 3049 FileStorage storage( mCalendar, filename, new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
3026 storage.save(); 3050 storage.save();
3027} 3051}
3028 3052
3029bool CalendarView::exportVCalendar( QString filename ) 3053bool CalendarView::exportVCalendar( QString filename )
3030{ 3054{
3031 if (mCalendar->journals().count() > 0) { 3055 if (mCalendar->journals().count() > 0) {
3032 int result = KMessageBox::warningContinueCancel(this, 3056 int result = KMessageBox::warningContinueCancel(this,
3033 i18n("The journal entries can not be\nexported to a vCalendar file."), 3057 i18n("The journal entries can not be\nexported to a vCalendar file."),
3034 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 3058 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
3035 true); 3059 true);
3036 if (result != KMessageBox::Continue) return false; 3060 if (result != KMessageBox::Continue) return false;
3037 } 3061 }
3038 3062
3039 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); 3063 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this);
3040 3064
3041 // Force correct extension 3065 // Force correct extension
3042 if (filename.right(4) != ".vcs") filename += ".vcs"; 3066 if (filename.right(4) != ".vcs") filename += ".vcs";
3043 3067
3044 FileStorage storage( mCalendar, filename, new VCalFormat ); 3068 FileStorage storage( mCalendar, filename, new VCalFormat );
3045 return storage.save(); 3069 return storage.save();
3046 3070
3047} 3071}
3048 3072
3049void CalendarView::eventUpdated(Incidence *) 3073void CalendarView::eventUpdated(Incidence *)
3050{ 3074{
3051 setModified(); 3075 setModified();
3052 // Don't call updateView here. The code, which has caused the update of the 3076 // Don't call updateView here. The code, which has caused the update of the
3053 // event is responsible for updating the view. 3077 // event is responsible for updating the view.
3054 // updateView(); 3078 // updateView();
3055} 3079}
3056 3080
3057void CalendarView::adaptNavigationUnits() 3081void CalendarView::adaptNavigationUnits()
3058{ 3082{
3059 if (mViewManager->currentView()->isEventView()) { 3083 if (mViewManager->currentView()->isEventView()) {
3060 int days = mViewManager->currentView()->currentDateCount(); 3084 int days = mViewManager->currentView()->currentDateCount();
3061 if (days == 1) { 3085 if (days == 1) {
3062 emit changeNavStringPrev(i18n("&Previous Day")); 3086 emit changeNavStringPrev(i18n("&Previous Day"));
3063 emit changeNavStringNext(i18n("&Next Day")); 3087 emit changeNavStringNext(i18n("&Next Day"));
3064 } else { 3088 } else {
3065 emit changeNavStringPrev(i18n("&Previous Week")); 3089 emit changeNavStringPrev(i18n("&Previous Week"));
3066 emit changeNavStringNext(i18n("&Next Week")); 3090 emit changeNavStringNext(i18n("&Next Week"));
3067 } 3091 }
3068 } 3092 }
3069} 3093}
3070 3094
3071void CalendarView::processMainViewSelection( Incidence *incidence ) 3095void CalendarView::processMainViewSelection( Incidence *incidence )
3072{ 3096{
3073 if ( incidence ) mTodoList->clearSelection(); 3097 if ( incidence ) mTodoList->clearSelection();
3074 processIncidenceSelection( incidence ); 3098 processIncidenceSelection( incidence );
3075} 3099}
3076 3100
3077void CalendarView::processTodoListSelection( Incidence *incidence ) 3101void CalendarView::processTodoListSelection( Incidence *incidence )
3078{ 3102{
3079 if ( incidence && mViewManager->currentView() ) { 3103 if ( incidence && mViewManager->currentView() ) {
3080 mViewManager->currentView()->clearSelection(); 3104 mViewManager->currentView()->clearSelection();
3081 } 3105 }
3082 processIncidenceSelection( incidence ); 3106 processIncidenceSelection( incidence );
3083} 3107}
3084 3108
3085void CalendarView::processIncidenceSelection( Incidence *incidence ) 3109void CalendarView::processIncidenceSelection( Incidence *incidence )
3086{ 3110{
3087 if ( incidence == mSelectedIncidence ) return; 3111 if ( incidence == mSelectedIncidence ) return;
3088 3112
3089 mSelectedIncidence = incidence; 3113 mSelectedIncidence = incidence;
3090 3114
3091 emit incidenceSelected( mSelectedIncidence ); 3115 emit incidenceSelected( mSelectedIncidence );
3092 3116
3093 if ( incidence && incidence->type() == "Event" ) { 3117 if ( incidence && incidence->type() == "Event" ) {
3094 Event *event = static_cast<Event *>( incidence ); 3118 Event *event = static_cast<Event *>( incidence );
3095 if ( event->organizer() == KOPrefs::instance()->email() ) { 3119 if ( event->organizer() == KOPrefs::instance()->email() ) {
3096 emit organizerEventsSelected( true ); 3120 emit organizerEventsSelected( true );
3097 } else { 3121 } else {
3098 emit organizerEventsSelected(false); 3122 emit organizerEventsSelected(false);
3099 } 3123 }
3100 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3124 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3101 KOPrefs::instance()->email() ) ) { 3125 KOPrefs::instance()->email() ) ) {
3102 emit groupEventsSelected( true ); 3126 emit groupEventsSelected( true );
3103 } else { 3127 } else {
3104 emit groupEventsSelected(false); 3128 emit groupEventsSelected(false);
3105 } 3129 }
3106 return; 3130 return;
3107 } else { 3131 } else {
3108 if ( incidence && incidence->type() == "Todo" ) { 3132 if ( incidence && incidence->type() == "Todo" ) {
3109 emit todoSelected( true ); 3133 emit todoSelected( true );
3110 Todo *event = static_cast<Todo *>( incidence ); 3134 Todo *event = static_cast<Todo *>( incidence );
3111 if ( event->organizer() == KOPrefs::instance()->email() ) { 3135 if ( event->organizer() == KOPrefs::instance()->email() ) {
3112 emit organizerEventsSelected( true ); 3136 emit organizerEventsSelected( true );
3113 } else { 3137 } else {
3114 emit organizerEventsSelected(false); 3138 emit organizerEventsSelected(false);
3115 } 3139 }
3116 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3140 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3117 KOPrefs::instance()->email() ) ) { 3141 KOPrefs::instance()->email() ) ) {
3118 emit groupEventsSelected( true ); 3142 emit groupEventsSelected( true );
3119 } else { 3143 } else {
3120 emit groupEventsSelected(false); 3144 emit groupEventsSelected(false);
3121 } 3145 }
3122 return; 3146 return;
3123 } else { 3147 } else {
3124 emit todoSelected( false ); 3148 emit todoSelected( false );
3125 emit organizerEventsSelected(false); 3149 emit organizerEventsSelected(false);
3126 emit groupEventsSelected(false); 3150 emit groupEventsSelected(false);
3127 } 3151 }
3128 return; 3152 return;
3129 } 3153 }
3130 3154
3131 /* if ( incidence && incidence->type() == "Todo" ) { 3155 /* if ( incidence && incidence->type() == "Todo" ) {
3132 emit todoSelected( true ); 3156 emit todoSelected( true );
3133 } else { 3157 } else {
3134 emit todoSelected( false ); 3158 emit todoSelected( false );
3135 }*/ 3159 }*/
3136} 3160}
3137 3161
3138 3162
3139void CalendarView::checkClipboard() 3163void CalendarView::checkClipboard()
3140{ 3164{
3141#ifndef KORG_NODND 3165#ifndef KORG_NODND
3142 if (ICalDrag::canDecode(QApplication::clipboard()->data())) { 3166 if (ICalDrag::canDecode(QApplication::clipboard()->data())) {
3143 emit pasteEnabled(true); 3167 emit pasteEnabled(true);
3144 } else { 3168 } else {
3145 emit pasteEnabled(false); 3169 emit pasteEnabled(false);
3146 } 3170 }
3147#endif 3171#endif
3148} 3172}
3149 3173
3150void CalendarView::showDates(const DateList &selectedDates) 3174void CalendarView::showDates(const DateList &selectedDates)
3151{ 3175{
3152 // kdDebug() << "CalendarView::selectDates()" << endl; 3176 // kdDebug() << "CalendarView::selectDates()" << endl;
3153 3177
3154 if ( mViewManager->currentView() ) { 3178 if ( mViewManager->currentView() ) {
3155 updateView( selectedDates.first(), selectedDates.last() ); 3179 updateView( selectedDates.first(), selectedDates.last() );
3156 } else { 3180 } else {
3157 mViewManager->showAgendaView(); 3181 mViewManager->showAgendaView();
3158 } 3182 }
3159 3183
3160 QString selDates; 3184 QString selDates;
3161 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); 3185 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true);
3162 if (selectedDates.first() < selectedDates.last() ) 3186 if (selectedDates.first() < selectedDates.last() )
3163 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); 3187 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true);
3164 topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); 3188 topLevelWidget()->setCaption( i18n("Dates: ") + selDates );
3165 3189
3166} 3190}
3167 3191
3168QPtrList<CalFilter> CalendarView::filters() 3192QPtrList<CalFilter> CalendarView::filters()
3169{ 3193{
3170 return mFilters; 3194 return mFilters;
3171 3195
3172} 3196}
3173void CalendarView::editFilters() 3197void CalendarView::editFilters()
3174{ 3198{
3175 // kdDebug() << "CalendarView::editFilters()" << endl; 3199 // kdDebug() << "CalendarView::editFilters()" << endl;
3176 3200
3177 CalFilter *filter = mFilters.first(); 3201 CalFilter *filter = mFilters.first();
3178 while(filter) { 3202 while(filter) {
3179 kdDebug() << " Filter: " << filter->name() << endl; 3203 kdDebug() << " Filter: " << filter->name() << endl;
3180 filter = mFilters.next(); 3204 filter = mFilters.next();
3181 } 3205 }
3182 3206
3183 mDialogManager->showFilterEditDialog(&mFilters); 3207 mDialogManager->showFilterEditDialog(&mFilters);
3184} 3208}
3185void CalendarView::toggleFilter() 3209void CalendarView::toggleFilter()
3186{ 3210{
3187 showFilter(! mFilterView->isVisible()); 3211 showFilter(! mFilterView->isVisible());
3188} 3212}
3189 3213
3190KOFilterView *CalendarView::filterView() 3214KOFilterView *CalendarView::filterView()
3191{ 3215{
3192 return mFilterView; 3216 return mFilterView;
3193} 3217}
3194void CalendarView::selectFilter( int fil ) 3218void CalendarView::selectFilter( int fil )
3195{ 3219{
3196 mFilterView->setSelectedFilter( fil ); 3220 mFilterView->setSelectedFilter( fil );
3197} 3221}
3198void CalendarView::showFilter(bool visible) 3222void CalendarView::showFilter(bool visible)
3199{ 3223{
3200 if (visible) mFilterView->show(); 3224 if (visible) mFilterView->show();
3201 else mFilterView->hide(); 3225 else mFilterView->hide();
3202} 3226}
3203void CalendarView::toggleFilerEnabled( ) 3227void CalendarView::toggleFilerEnabled( )
3204{ 3228{
3205 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); 3229 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() );
3206 if ( !mFilterView->filtersEnabled() ) 3230 if ( !mFilterView->filtersEnabled() )
3207 topLevelWidget()->setCaption( i18n("Filter disabled ") ); 3231 topLevelWidget()->setCaption( i18n("Filter disabled ") );
3208 3232
3209} 3233}
3210void CalendarView::updateFilter() 3234void CalendarView::updateFilter()
3211{ 3235{
3212 CalFilter *filter = mFilterView->selectedFilter(); 3236 CalFilter *filter = mFilterView->selectedFilter();
3213 if (filter) { 3237 if (filter) {
3214 if (mFilterView->filtersEnabled()) { 3238 if (mFilterView->filtersEnabled()) {
3215 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); 3239 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() );
3216 filter->setEnabled(true); 3240 filter->setEnabled(true);
3217 } 3241 }
3218 else filter->setEnabled(false); 3242 else filter->setEnabled(false);
3219 mCalendar->setFilter(filter); 3243 mCalendar->setFilter(filter);
3220 updateView(); 3244 updateView();
3221 } 3245 }
3222} 3246}
3223 3247
3224void CalendarView::filterEdited() 3248void CalendarView::filterEdited()
3225{ 3249{
3226 mFilterView->updateFilters(); 3250 mFilterView->updateFilters();
3227 updateFilter(); 3251 updateFilter();
3228 writeSettings(); 3252 writeSettings();
3229} 3253}
3230 3254
3231 3255
3232void CalendarView::takeOverEvent() 3256void CalendarView::takeOverEvent()
3233{ 3257{
3234 Incidence *incidence = currentSelection(); 3258 Incidence *incidence = currentSelection();
3235 3259
3236 if (!incidence) return; 3260 if (!incidence) return;
3237 3261
3238 incidence->setOrganizer(KOPrefs::instance()->email()); 3262 incidence->setOrganizer(KOPrefs::instance()->email());
3239 incidence->recreate(); 3263 incidence->recreate();
3240 incidence->setReadOnly(false); 3264 incidence->setReadOnly(false);
3241 3265
3242 updateView(); 3266 updateView();
3243} 3267}
3244 3268
3245void CalendarView::takeOverCalendar() 3269void CalendarView::takeOverCalendar()
3246{ 3270{
3247 // TODO: Create Calendar::allIncidences() function and use it here 3271 // TODO: Create Calendar::allIncidences() function and use it here
3248 3272
3249 QPtrList<Event> events = mCalendar->events(); 3273 QPtrList<Event> events = mCalendar->events();
3250 for(uint i=0; i<events.count(); ++i) { 3274 for(uint i=0; i<events.count(); ++i) {
3251 events.at(i)->setOrganizer(KOPrefs::instance()->email()); 3275 events.at(i)->setOrganizer(KOPrefs::instance()->email());
3252 events.at(i)->recreate(); 3276 events.at(i)->recreate();
3253 events.at(i)->setReadOnly(false); 3277 events.at(i)->setReadOnly(false);
3254 } 3278 }
3255 3279
3256 QPtrList<Todo> todos = mCalendar->todos(); 3280 QPtrList<Todo> todos = mCalendar->todos();
3257 for(uint i=0; i<todos.count(); ++i) { 3281 for(uint i=0; i<todos.count(); ++i) {
3258 todos.at(i)->setOrganizer(KOPrefs::instance()->email()); 3282 todos.at(i)->setOrganizer(KOPrefs::instance()->email());
3259 todos.at(i)->recreate(); 3283 todos.at(i)->recreate();
3260 todos.at(i)->setReadOnly(false); 3284 todos.at(i)->setReadOnly(false);
3261 } 3285 }
3262 3286
3263 QPtrList<Journal> journals = mCalendar->journals(); 3287 QPtrList<Journal> journals = mCalendar->journals();
3264 for(uint i=0; i<journals.count(); ++i) { 3288 for(uint i=0; i<journals.count(); ++i) {
3265 journals.at(i)->setOrganizer(KOPrefs::instance()->email()); 3289 journals.at(i)->setOrganizer(KOPrefs::instance()->email());
3266 journals.at(i)->recreate(); 3290 journals.at(i)->recreate();
3267 journals.at(i)->setReadOnly(false); 3291 journals.at(i)->setReadOnly(false);
3268 } 3292 }
3269 3293
3270 updateView(); 3294 updateView();
3271} 3295}
3272 3296
3273void CalendarView::showIntro() 3297void CalendarView::showIntro()
3274{ 3298{
3275 kdDebug() << "To be implemented." << endl; 3299 kdDebug() << "To be implemented." << endl;
3276} 3300}
3277 3301
3278QWidgetStack *CalendarView::viewStack() 3302QWidgetStack *CalendarView::viewStack()
3279{ 3303{
3280 return mRightFrame; 3304 return mRightFrame;
3281} 3305}
3282 3306
3283QWidget *CalendarView::leftFrame() 3307QWidget *CalendarView::leftFrame()
3284{ 3308{
3285 return mLeftFrame; 3309 return mLeftFrame;
3286} 3310}
3287 3311
3288DateNavigator *CalendarView::dateNavigator() 3312DateNavigator *CalendarView::dateNavigator()
3289{ 3313{
3290 return mNavigator; 3314 return mNavigator;
3291} 3315}
3292 3316
3293KDateNavigator* CalendarView::dateNavigatorWidget() 3317KDateNavigator* CalendarView::dateNavigatorWidget()
3294{ 3318{
3295 return mDateNavigator; 3319 return mDateNavigator;
3296} 3320}
3297void CalendarView::toggleDateNavigatorWidget() 3321void CalendarView::toggleDateNavigatorWidget()
3298{ 3322{
3299 if (mDateNavigator->isVisible()) 3323 if (mDateNavigator->isVisible())
3300 mDateNavigator->hide(); 3324 mDateNavigator->hide();
3301 else 3325 else
3302 mDateNavigator->show(); 3326 mDateNavigator->show();
3303} 3327}
3304void CalendarView::addView(KOrg::BaseView *view) 3328void CalendarView::addView(KOrg::BaseView *view)
3305{ 3329{
3306 mViewManager->addView(view); 3330 mViewManager->addView(view);
3307} 3331}
3308 3332
3309void CalendarView::showView(KOrg::BaseView *view) 3333void CalendarView::showView(KOrg::BaseView *view)
3310{ 3334{
3311 mViewManager->showView(view, mLeftFrame->isVisible()); 3335 mViewManager->showView(view, mLeftFrame->isVisible());
3312} 3336}
3313 3337
3314Incidence *CalendarView::currentSelection() 3338Incidence *CalendarView::currentSelection()
3315{ 3339{
3316 return mViewManager->currentSelection(); 3340 return mViewManager->currentSelection();
3317} 3341}
3318void CalendarView::toggleAllDaySize() 3342void CalendarView::toggleAllDaySize()
3319{ 3343{
3320 /* 3344 /*
3321 if ( KOPrefs::instance()->mAllDaySize > 47 ) 3345 if ( KOPrefs::instance()->mAllDaySize > 47 )
3322 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; 3346 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2;
3323 else 3347 else
3324 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; 3348 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2;
3325 */ 3349 */
3326 viewManager()->agendaView()->toggleAllDay(); 3350 viewManager()->agendaView()->toggleAllDay();
3327} 3351}
3328void CalendarView::toggleExpand() 3352void CalendarView::toggleExpand()
3329{ 3353{
3330 // if ( mLeftFrame->isHidden() ) { 3354 // if ( mLeftFrame->isHidden() ) {
3331 // mLeftFrame->show(); 3355 // mLeftFrame->show();
3332 // emit calendarViewExpanded( false ); 3356 // emit calendarViewExpanded( false );
3333 // } else { 3357 // } else {
3334 // mLeftFrame->hide(); 3358 // mLeftFrame->hide();
3335 // emit calendarViewExpanded( true ); 3359 // emit calendarViewExpanded( true );
3336 // } 3360 // }
3337 3361
3338 globalFlagBlockAgenda = 1; 3362 globalFlagBlockAgenda = 1;
3339 emit calendarViewExpanded( !mLeftFrame->isHidden() ); 3363 emit calendarViewExpanded( !mLeftFrame->isHidden() );
3340 globalFlagBlockAgenda = 5; 3364 globalFlagBlockAgenda = 5;
3341 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); 3365 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() );
3342 //mViewManager->showView( 0, true ); 3366 //mViewManager->showView( 0, true );
3343} 3367}
3344 3368
3345void CalendarView::calendarModified( bool modified, Calendar * ) 3369void CalendarView::calendarModified( bool modified, Calendar * )
3346{ 3370{
3347 setModified( modified ); 3371 setModified( modified );
3348} 3372}
3349 3373
3350Todo *CalendarView::selectedTodo() 3374Todo *CalendarView::selectedTodo()
3351{ 3375{
3352 Incidence *incidence = currentSelection(); 3376 Incidence *incidence = currentSelection();
3353 if ( incidence && incidence->type() == "Todo" ) { 3377 if ( incidence && incidence->type() == "Todo" ) {
3354 return static_cast<Todo *>( incidence ); 3378 return static_cast<Todo *>( incidence );
3355 } 3379 }
3356 3380
3357 incidence = mTodoList->selectedIncidences().first(); 3381 incidence = mTodoList->selectedIncidences().first();
3358 if ( incidence && incidence->type() == "Todo" ) { 3382 if ( incidence && incidence->type() == "Todo" ) {
3359 return static_cast<Todo *>( incidence ); 3383 return static_cast<Todo *>( incidence );
3360 } 3384 }
3361 3385
3362 return 0; 3386 return 0;
3363} 3387}
3364 3388
3365void CalendarView::dialogClosing(Incidence *in) 3389void CalendarView::dialogClosing(Incidence *in)
3366{ 3390{
3367 // mDialogList.remove(in); 3391 // mDialogList.remove(in);
3368} 3392}
3369 3393
3370void CalendarView::showIncidence() 3394void CalendarView::showIncidence()
3371{ 3395{
3372 Incidence *incidence = currentSelection(); 3396 Incidence *incidence = currentSelection();
3373 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3397 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3374 if ( incidence ) { 3398 if ( incidence ) {
3375 ShowIncidenceVisitor v; 3399 ShowIncidenceVisitor v;
3376 v.act( incidence, this ); 3400 v.act( incidence, this );
3377 } 3401 }
3378} 3402}
3379void CalendarView::editIncidenceDescription() 3403void CalendarView::editIncidenceDescription()
3380{ 3404{
3381 mFlagEditDescription = true; 3405 mFlagEditDescription = true;
3382 editIncidence(); 3406 editIncidence();
3383 mFlagEditDescription = false; 3407 mFlagEditDescription = false;
3384} 3408}
3385void CalendarView::editIncidence() 3409void CalendarView::editIncidence()
3386{ 3410{
3387 // qDebug("editIncidence() "); 3411 // qDebug("editIncidence() ");
3388 Incidence *incidence = currentSelection(); 3412 Incidence *incidence = currentSelection();
3389 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3413 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3390 if ( incidence ) { 3414 if ( incidence ) {
3391 EditIncidenceVisitor v; 3415 EditIncidenceVisitor v;
3392 v.act( incidence, this ); 3416 v.act( incidence, this );
3393 } 3417 }
3394} 3418}
3395 3419
3396void CalendarView::deleteIncidence() 3420void CalendarView::deleteIncidence()
3397{ 3421{
3398 Incidence *incidence = currentSelection(); 3422 Incidence *incidence = currentSelection();
3399 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3423 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3400 if ( incidence ) { 3424 if ( incidence ) {
3401 deleteIncidence(incidence); 3425 deleteIncidence(incidence);
3402 } 3426 }
3403} 3427}
3404 3428
3405void CalendarView::showIncidence(Incidence *incidence) 3429void CalendarView::showIncidence(Incidence *incidence)
3406{ 3430{
3407 if ( incidence ) { 3431 if ( incidence ) {
3408 ShowIncidenceVisitor v; 3432 ShowIncidenceVisitor v;
3409 v.act( incidence, this ); 3433 v.act( incidence, this );
3410 } 3434 }
3411} 3435}
3412 3436
3413void CalendarView::editIncidence(Incidence *incidence) 3437void CalendarView::editIncidence(Incidence *incidence)
3414{ 3438{
3415 if ( incidence ) { 3439 if ( incidence ) {
3416 3440
3417 EditIncidenceVisitor v; 3441 EditIncidenceVisitor v;
3418 v.act( incidence, this ); 3442 v.act( incidence, this );
3419 3443
3420 } 3444 }
3421} 3445}
3422 3446
3423void CalendarView::deleteIncidence(Incidence *incidence) 3447void CalendarView::deleteIncidence(Incidence *incidence)
3424{ 3448{
3425 //qDebug(" CalendarView::deleteIncidence "); 3449 //qDebug(" CalendarView::deleteIncidence ");
3426 if ( incidence ) { 3450 if ( incidence ) {
3427 DeleteIncidenceVisitor v; 3451 DeleteIncidenceVisitor v;
3428 v.act( incidence, this ); 3452 v.act( incidence, this );
3429 } 3453 }
3430} 3454}
3431 3455
3432 3456
3433void CalendarView::lookForOutgoingMessages() 3457void CalendarView::lookForOutgoingMessages()
3434{ 3458{
3435 OutgoingDialog *ogd = mDialogManager->outgoingDialog(); 3459 OutgoingDialog *ogd = mDialogManager->outgoingDialog();
3436 ogd->loadMessages(); 3460 ogd->loadMessages();
3437} 3461}
3438 3462
3439void CalendarView::lookForIncomingMessages() 3463void CalendarView::lookForIncomingMessages()
3440{ 3464{
3441 IncomingDialog *icd = mDialogManager->incomingDialog(); 3465 IncomingDialog *icd = mDialogManager->incomingDialog();
3442 icd->retrieve(); 3466 icd->retrieve();
3443} 3467}
3444 3468
3445bool CalendarView::removeCompletedSubTodos( Todo* t ) 3469bool CalendarView::removeCompletedSubTodos( Todo* t )
3446{ 3470{
3447 bool deleteTodo = true; 3471 bool deleteTodo = true;
3448 QPtrList<Incidence> subTodos; 3472 QPtrList<Incidence> subTodos;
3449 Incidence *aTodo; 3473 Incidence *aTodo;
3450 subTodos = t->relations(); 3474 subTodos = t->relations();
3451 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { 3475 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
3452 if (! removeCompletedSubTodos( (Todo*) aTodo )) 3476 if (! removeCompletedSubTodos( (Todo*) aTodo ))
3453 deleteTodo = false; 3477 deleteTodo = false;
3454 } 3478 }
3455 if ( deleteTodo ) { 3479 if ( deleteTodo ) {
3456 if ( t->isCompleted() ) { 3480 if ( t->isCompleted() ) {
3457 checkExternalId( t ); 3481 checkExternalId( t );
3458 mCalendar->deleteTodo( t ); 3482 mCalendar->deleteTodo( t );
3459 changeTodoDisplay( t,KOGlobals::EVENTDELETED ); 3483 changeTodoDisplay( t,KOGlobals::EVENTDELETED );
3460 } 3484 }
3461 else 3485 else
3462 deleteTodo = false; 3486 deleteTodo = false;
3463 } 3487 }
3464 return deleteTodo; 3488 return deleteTodo;
3465 3489
3466} 3490}
3467void CalendarView::purgeCompleted() 3491void CalendarView::purgeCompleted()
3468{ 3492{
3469 int result = KMessageBox::warningContinueCancel(this, 3493 int result = KMessageBox::warningContinueCancel(this,
3470 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); 3494 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge"));
3471 3495
3472 if (result == KMessageBox::Continue) { 3496 if (result == KMessageBox::Continue) {
3473 3497
3474 QPtrList<Todo> todoCal; 3498 QPtrList<Todo> todoCal;
3475 QPtrList<Todo> rootTodos; 3499 QPtrList<Todo> rootTodos;
3476 //QPtrList<Incidence> rel; 3500 //QPtrList<Incidence> rel;
3477 Todo *aTodo;//, *rTodo; 3501 Todo *aTodo;//, *rTodo;
3478 Incidence *rIncidence; 3502 Incidence *rIncidence;
3479 bool childDelete = false; 3503 bool childDelete = false;
3480 bool deletedOne = true; 3504 bool deletedOne = true;
3481 todoCal = calendar()->todos(); 3505 todoCal = calendar()->todos();
3482 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { 3506 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
3483 if ( !aTodo->relatedTo() ) 3507 if ( !aTodo->relatedTo() )
3484 rootTodos.append( aTodo ); 3508 rootTodos.append( aTodo );
3485 } 3509 }
3486 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { 3510 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) {
3487 removeCompletedSubTodos( aTodo ); 3511 removeCompletedSubTodos( aTodo );
3488 } 3512 }
3489 3513
3490 updateView(); 3514 updateView();
3491 } 3515 }
3492} 3516}
3493 3517
3494void CalendarView::slotCalendarChanged() 3518void CalendarView::slotCalendarChanged()
3495{ 3519{
3496 ; 3520 ;
3497} 3521}
3498 3522
3499NavigatorBar *CalendarView::navigatorBar() 3523NavigatorBar *CalendarView::navigatorBar()
3500{ 3524{
3501 return mNavigatorBar; 3525 return mNavigatorBar;
3502} 3526}
3503 3527
3504 3528
3505 3529
3506void CalendarView::keyPressEvent ( QKeyEvent *e) 3530void CalendarView::keyPressEvent ( QKeyEvent *e)
3507{ 3531{
3508 //qDebug(" alendarView::keyPressEvent "); 3532 //qDebug(" alendarView::keyPressEvent ");
3509 e->ignore(); 3533 e->ignore();
3510} 3534}
3511 3535
3512//#include "calendarview.moc" 3536//#include "calendarview.moc"
3513 3537
3514//#include "calendarviewbase.moc" 3538//#include "calendarviewbase.moc"
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index b2838db..a3315ad 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -1,589 +1,590 @@
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
45class QWidgetStack; 45class QWidgetStack;
46class QSplitter; 46class QSplitter;
47 47
48class CalPrinter; 48class CalPrinter;
49class KOFilterView; 49class KOFilterView;
50class KOViewManager; 50class KOViewManager;
51class KODialogManager; 51class KODialogManager;
52class KOTodoView; 52class KOTodoView;
53class KDateNavigator; 53class KDateNavigator;
54class DateNavigator; 54class DateNavigator;
55class KOIncidenceEditor; 55class KOIncidenceEditor;
56class KDatePicker; 56class KDatePicker;
57class ResourceView; 57class ResourceView;
58class NavigatorBar; 58class NavigatorBar;
59class KOEventEditor; 59class KOEventEditor;
60class KOTodoEditor ; 60class KOTodoEditor ;
61class KOEventViewerDialog; 61class KOEventViewerDialog;
62class KOBeamPrefs; 62class KOBeamPrefs;
63class KSyncProfile; 63class KSyncProfile;
64class AlarmDialog; 64class AlarmDialog;
65class KCal::Attendee; 65class KCal::Attendee;
66 66
67namespace KCal { class FileStorage; } 67namespace KCal { class FileStorage; }
68 68
69using namespace KCal; 69using namespace KCal;
70 70
71/** 71/**
72 This is the main calendar widget. It provides the different vies on t he 72 This is the main calendar widget. It provides the different vies on t he
73 calendar data as well as the date navigator. It also handles synchronisation 73 calendar data as well as the date navigator. It also handles synchronisation
74 of the different views and controls the different dialogs like preferences, 74 of the different views and controls the different dialogs like preferences,
75 event editor, search dialog etc. 75 event editor, search dialog etc.
76 76
77 @short main calendar view widget 77 @short main calendar view widget
78 @author Cornelius Schumacher 78 @author Cornelius Schumacher
79*/ 79*/
80class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer 80class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer
81{ 81{
82 Q_OBJECT 82 Q_OBJECT
83 public: 83 public:
84 /** 84 /**
85 Constructs a new calendar view widget. 85 Constructs a new calendar view widget.
86 86
87 @param calendar calendar document 87 @param calendar calendar document
88 @param parent parent window 88 @param parent parent window
89 @param name Qt internal widget object name 89 @param name Qt internal widget object name
90 */ 90 */
91 CalendarView( CalendarResources *calendar, QWidget *parent = 0, 91 CalendarView( CalendarResources *calendar, QWidget *parent = 0,
92 const char *name = 0 ); 92 const char *name = 0 );
93 CalendarView( Calendar *calendar, QWidget *parent = 0, 93 CalendarView( Calendar *calendar, QWidget *parent = 0,
94 const char *name = 0 ); 94 const char *name = 0 );
95 virtual ~CalendarView(); 95 virtual ~CalendarView();
96 96
97 Calendar *calendar() { return mCalendar; } 97 Calendar *calendar() { return mCalendar; }
98 98
99 KOViewManager *viewManager(); 99 KOViewManager *viewManager();
100 KODialogManager *dialogManager(); 100 KODialogManager *dialogManager();
101 101
102 QDate startDate(); 102 QDate startDate();
103 QDate endDate(); 103 QDate endDate();
104 104
105 QWidgetStack *viewStack(); 105 QWidgetStack *viewStack();
106 QWidget *leftFrame(); 106 QWidget *leftFrame();
107 NavigatorBar *navigatorBar(); 107 NavigatorBar *navigatorBar();
108 108
109 DateNavigator *dateNavigator(); 109 DateNavigator *dateNavigator();
110 KDateNavigator *dateNavigatorWidget(); 110 KDateNavigator *dateNavigatorWidget();
111 111
112 void addView(KOrg::BaseView *); 112 void addView(KOrg::BaseView *);
113 void showView(KOrg::BaseView *); 113 void showView(KOrg::BaseView *);
114 KOEventViewerDialog* getEventViewerDialog(); 114 KOEventViewerDialog* getEventViewerDialog();
115 Incidence *currentSelection(); 115 Incidence *currentSelection();
116 void setupExternSyncProfiles(); 116 void setupExternSyncProfiles();
117 117
118 signals: 118 signals:
119 /** This todo has been modified */ 119 /** This todo has been modified */
120 void todoModified(Todo *, int); 120 void todoModified(Todo *, int);
121 121
122 /** when change is made to options dialog, the topwidget will catch this 122 /** when change is made to options dialog, the topwidget will catch this
123 * and emit this signal which notifies all widgets which have registered 123 * and emit this signal which notifies all widgets which have registered
124 * for notification to update their settings. */ 124 * for notification to update their settings. */
125 void configChanged(); 125 void configChanged();
126 /** emitted when the topwidget is closing down, so that any attached 126 /** emitted when the topwidget is closing down, so that any attached
127 child windows can also close. */ 127 child windows can also close. */
128 void closingDown(); 128 void closingDown();
129 /** emitted right before we die */ 129 /** emitted right before we die */
130 void closed(QWidget *); 130 void closed(QWidget *);
131 131
132 /** Emitted when state of modified flag changes */ 132 /** Emitted when state of modified flag changes */
133 void modifiedChanged(bool); 133 void modifiedChanged(bool);
134 void signalmodified(); 134 void signalmodified();
135 135
136 /** Emitted when state of read-only flag changes */ 136 /** Emitted when state of read-only flag changes */
137 void readOnlyChanged(bool); 137 void readOnlyChanged(bool);
138 138
139 /** Emitted when the unit of navigation changes */ 139 /** Emitted when the unit of navigation changes */
140 void changeNavStringPrev(const QString &); 140 void changeNavStringPrev(const QString &);
141 void changeNavStringNext(const QString &); 141 void changeNavStringNext(const QString &);
142 142
143 /** Emitted when state of events selection has changed and user is organizer*/ 143 /** Emitted when state of events selection has changed and user is organizer*/
144 void organizerEventsSelected(bool); 144 void organizerEventsSelected(bool);
145 /** Emitted when state of events selection has changed and user is attendee*/ 145 /** Emitted when state of events selection has changed and user is attendee*/
146 void groupEventsSelected(bool); 146 void groupEventsSelected(bool);
147 /** 147 /**
148 Emitted when an incidence gets selected. If the selection is cleared the 148 Emitted when an incidence gets selected. If the selection is cleared the
149 signal is emitted with 0 as argument. 149 signal is emitted with 0 as argument.
150 */ 150 */
151 void incidenceSelected( Incidence * ); 151 void incidenceSelected( Incidence * );
152 /** Emitted, when a todoitem is selected or deselected. */ 152 /** Emitted, when a todoitem is selected or deselected. */
153 void todoSelected( bool ); 153 void todoSelected( bool );
154 154
155 /** 155 /**
156 Emitted, when clipboard content changes. Parameter indicates if paste 156 Emitted, when clipboard content changes. Parameter indicates if paste
157 is possible or not. 157 is possible or not.
158 */ 158 */
159 void pasteEnabled(bool); 159 void pasteEnabled(bool);
160 160
161 /** Emitted, when the number of incoming messages has changed. */ 161 /** Emitted, when the number of incoming messages has changed. */
162 void numIncomingChanged(int); 162 void numIncomingChanged(int);
163 163
164 /** Emitted, when the number of outgoing messages has changed. */ 164 /** Emitted, when the number of outgoing messages has changed. */
165 void numOutgoingChanged(int); 165 void numOutgoingChanged(int);
166 166
167 /** Send status message, which can e.g. be displayed in the status bar. */ 167 /** Send status message, which can e.g. be displayed in the status bar. */
168 void statusMessage(const QString &); 168 void statusMessage(const QString &);
169 169
170 void calendarViewExpanded( bool ); 170 void calendarViewExpanded( bool );
171 void updateSearchDialog(); 171 void updateSearchDialog();
172 172
173 173
174 public slots: 174 public slots:
175 void recheckTimerAlarm(); 175 void recheckTimerAlarm();
176 void checkNextTimerAlarm(); 176 void checkNextTimerAlarm();
177 void addAlarm(const QDateTime &qdt, const QString &noti ); 177 void addAlarm(const QDateTime &qdt, const QString &noti );
178 void addSuspendAlarm(const QDateTime &qdt, const QString &noti ); 178 void addSuspendAlarm(const QDateTime &qdt, const QString &noti );
179 void removeAlarm(const QDateTime &qdt, const QString &noti ); 179 void removeAlarm(const QDateTime &qdt, const QString &noti );
180 180
181 /** options dialog made a changed to the configuration. we catch this 181 /** options dialog made a changed to the configuration. we catch this
182 * and notify all widgets which need to update their configuration. */ 182 * and notify all widgets which need to update their configuration. */
183 void updateConfig(); 183 void updateConfig();
184 184
185 /** 185 /**
186 Load calendar from file \a filename. If \a merge is true, load 186 Load calendar from file \a filename. If \a merge is true, load
187 calendar into existing one, if it is false, clear calendar, before 187 calendar into existing one, if it is false, clear calendar, before
188 loading. Return true, if calendar could be successfully loaded. 188 loading. Return true, if calendar could be successfully loaded.
189 */ 189 */
190 bool openCalendar(QString filename, bool merge=false); 190 bool openCalendar(QString filename, bool merge=false);
191 bool syncCalendar(QString filename,int mode = 0 ); 191 bool syncCalendar(QString filename,int mode = 0 );
192 192
193 /** 193 /**
194 Save calendar data to file. Return true if calendar could be 194 Save calendar data to file. Return true if calendar could be
195 successfully saved. 195 successfully saved.
196 */ 196 */
197 bool saveCalendar(QString filename); 197 bool saveCalendar(QString filename);
198 198
199 /** 199 /**
200 Close calendar. Clear calendar data and reset views to display an empty 200 Close calendar. Clear calendar data and reset views to display an empty
201 calendar. 201 calendar.
202 */ 202 */
203 void closeCalendar(); 203 void closeCalendar();
204 204
205 /** Archive old events of calendar */ 205 /** Archive old events of calendar */
206 void archiveCalendar(); 206 void archiveCalendar();
207 207
208 void showIncidence(); 208 void showIncidence();
209 void editIncidence(); 209 void editIncidence();
210 void editIncidenceDescription(); 210 void editIncidenceDescription();
211 void deleteIncidence(); 211 void deleteIncidence();
212 212
213 /** create an editeventwin with supplied date/time, and if bool is true, 213 /** create an editeventwin with supplied date/time, and if bool is true,
214 * make the event take all day. */ 214 * make the event take all day. */
215 void newEvent(QDateTime, QDateTime, bool allDay = false); 215 void newEvent(QDateTime, QDateTime, bool allDay = false);
216 void newEvent(QDateTime fh); 216 void newEvent(QDateTime fh);
217 void newEvent(QDate dt); 217 void newEvent(QDate dt);
218 /** create new event without having a date hint. Takes current date as 218 /** create new event without having a date hint. Takes current date as
219 default hint. */ 219 default hint. */
220 void newEvent(); 220 void newEvent();
221 void newFloatingEvent(); 221 void newFloatingEvent();
222 222
223 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ 223 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/
224 void showIncidence(Incidence *); 224 void showIncidence(Incidence *);
225 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ 225 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/
226 void editIncidence(Incidence *); 226 void editIncidence(Incidence *);
227 /** Delete the supplied incidence. It calls the correct deleteXXX method*/ 227 /** Delete the supplied incidence. It calls the correct deleteXXX method*/
228 void deleteIncidence(Incidence *); 228 void deleteIncidence(Incidence *);
229 void cloneIncidence(Incidence *); 229 void cloneIncidence(Incidence *);
230 void cancelIncidence(Incidence *); 230 void cancelIncidence(Incidence *);
231 /** Create an editor for the supplied event. */ 231 /** Create an editor for the supplied event. */
232 void editEvent(Event *); 232 void editEvent(Event *);
233 /** Delete the supplied event. */ 233 /** Delete the supplied event. */
234 void deleteEvent(Event *); 234 void deleteEvent(Event *);
235 /** Delete the event with the given unique ID. Returns false, if event wasn't 235 /** Delete the event with the given unique ID. Returns false, if event wasn't
236 found. */ 236 found. */
237 bool deleteEvent(const QString &uid); 237 bool deleteEvent(const QString &uid);
238 /** Create a read-only viewer dialog for the supplied event. */ 238 /** Create a read-only viewer dialog for the supplied event. */
239 void showEvent(Event *); 239 void showEvent(Event *);
240 240
241 void editJournal(Journal *); 241 void editJournal(Journal *);
242 void showJournal(Journal *); 242 void showJournal(Journal *);
243 void deleteJournal(Journal *); 243 void deleteJournal(Journal *);
244 /** Create an editor dialog for a todo */ 244 /** Create an editor dialog for a todo */
245 void editTodo(Todo *); 245 void editTodo(Todo *);
246 /** Create a read-only viewer dialog for the supplied todo */ 246 /** Create a read-only viewer dialog for the supplied todo */
247 void showTodo(Todo *); 247 void showTodo(Todo *);
248 /** create new todo */ 248 /** create new todo */
249 void newTodo(); 249 void newTodo();
250 /** create new todo with a parent todo */ 250 /** create new todo with a parent todo */
251 void newSubTodo(); 251 void newSubTodo();
252 /** create new todo with a parent todo */ 252 /** create new todo with a parent todo */
253 void newSubTodo(Todo *); 253 void newSubTodo(Todo *);
254 /** Delete todo */ 254 /** Delete todo */
255 void deleteTodo(Todo *); 255 void deleteTodo(Todo *);
256 256
257 257
258 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is 258 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is
259 * emitted as result. */ 259 * emitted as result. */
260 void checkClipboard(); 260 void checkClipboard();
261 261
262 /** using the KConfig associated with the kapp variable, read in the 262 /** using the KConfig associated with the kapp variable, read in the
263 * settings from the config file. 263 * settings from the config file.
264 */ 264 */
265 void readSettings(); 265 void readSettings();
266 266
267 /** write current state to config file. */ 267 /** write current state to config file. */
268 void writeSettings(); 268 void writeSettings();
269 269
270 /** read settings for calendar filters */ 270 /** read settings for calendar filters */
271 void readFilterSettings(KConfig *config); 271 void readFilterSettings(KConfig *config);
272 272
273 /** write settings for calendar filters */ 273 /** write settings for calendar filters */
274 void writeFilterSettings(KConfig *config); 274 void writeFilterSettings(KConfig *config);
275 275
276 /** passes on the message that an event has changed to the currently 276 /** passes on the message that an event has changed to the currently
277 * activated view so that it can make appropriate display changes. */ 277 * activated view so that it can make appropriate display changes. */
278 void changeEventDisplay(Event *, int); 278 void changeEventDisplay(Event *, int);
279 void changeIncidenceDisplay(Incidence *, int); 279 void changeIncidenceDisplay(Incidence *, int);
280 void changeTodoDisplay(Todo *, int); 280 void changeTodoDisplay(Todo *, int);
281 281
282 void eventAdded(Event *); 282 void eventAdded(Event *);
283 void eventChanged(Event *); 283 void eventChanged(Event *);
284 void eventToBeDeleted(Event *); 284 void eventToBeDeleted(Event *);
285 void eventDeleted(); 285 void eventDeleted();
286 286
287 void todoAdded(Todo *); 287 void todoAdded(Todo *);
288 void todoChanged(Todo *); 288 void todoChanged(Todo *);
289 void todoToBeDeleted(Todo *); 289 void todoToBeDeleted(Todo *);
290 void todoDeleted(); 290 void todoDeleted();
291 291
292 void updateView(const QDate &start, const QDate &end); 292 void updateView(const QDate &start, const QDate &end);
293 void updateView(); 293 void updateView();
294 294
295 /** Full update of visible todo views */ 295 /** Full update of visible todo views */
296 void updateTodoViews(); 296 void updateTodoViews();
297 297
298 void updateUnmanagedViews(); 298 void updateUnmanagedViews();
299 299
300 /** cut the current appointment to the clipboard */ 300 /** cut the current appointment to the clipboard */
301 void edit_cut(); 301 void edit_cut();
302 302
303 /** copy the current appointment(s) to the clipboard */ 303 /** copy the current appointment(s) to the clipboard */
304 void edit_copy(); 304 void edit_copy();
305 305
306 /** paste the current vobject(s) in the clipboard buffer into calendar */ 306 /** paste the current vobject(s) in the clipboard buffer into calendar */
307 void edit_paste(); 307 void edit_paste();
308 308
309 /** edit viewing and configuration options. */ 309 /** edit viewing and configuration options. */
310 void edit_options(); 310 void edit_options();
311 void edit_sync_options(); 311 void edit_sync_options();
312 /** 312 /**
313 Functions for printing, previewing a print, and setting up printing 313 Functions for printing, previewing a print, and setting up printing
314 parameters. 314 parameters.
315 */ 315 */
316 void print(); 316 void print();
317 void printSetup(); 317 void printSetup();
318 void printPreview(); 318 void printPreview();
319 319
320 /** Export as iCalendar file */ 320 /** Export as iCalendar file */
321 void exportICalendar(); 321 void exportICalendar();
322 322
323 /** Export as vCalendar file */ 323 /** Export as vCalendar file */
324 bool exportVCalendar( QString fn); 324 bool exportVCalendar( QString fn);
325 325
326 /** pop up a dialog to show an existing appointment. */ 326 /** pop up a dialog to show an existing appointment. */
327 void appointment_show(); 327 void appointment_show();
328 /** 328 /**
329 * pop up an Appointment Dialog to edit an existing appointment.Get 329 * pop up an Appointment Dialog to edit an existing appointment.Get
330 * information on the appointment from the list of unique IDs that is 330 * information on the appointment from the list of unique IDs that is
331 * currently in the View, called currIds. 331 * currently in the View, called currIds.
332 */ 332 */
333 void appointment_edit(); 333 void appointment_edit();
334 /** 334 /**
335 * pop up dialog confirming deletion of currently selected event in the 335 * pop up dialog confirming deletion of currently selected event in the
336 * View. 336 * View.
337 */ 337 */
338 void appointment_delete(); 338 void appointment_delete();
339 339
340 /** mails the currently selected event to a particular user as a vCalendar 340 /** mails the currently selected event to a particular user as a vCalendar
341 attachment. */ 341 attachment. */
342 void action_mail(); 342 void action_mail();
343 343
344 /* frees a subtodo from it's relation */ 344 /* frees a subtodo from it's relation */
345 void todo_unsub( Todo * ); 345 void todo_unsub( Todo * );
346 346
347 /** Take ownership of selected event. */ 347 /** Take ownership of selected event. */
348 void takeOverEvent(); 348 void takeOverEvent();
349 349
350 /** Take ownership of all events in calendar. */ 350 /** Take ownership of all events in calendar. */
351 void takeOverCalendar(); 351 void takeOverCalendar();
352 352
353 /** query whether or not the calendar is "dirty". */ 353 /** query whether or not the calendar is "dirty". */
354 bool isModified(); 354 bool isModified();
355 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ 355 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */
356 void setModified(bool modified=true); 356 void setModified(bool modified=true);
357 357
358 /** query if the calendar is read-only. */ 358 /** query if the calendar is read-only. */
359 bool isReadOnly(); 359 bool isReadOnly();
360 /** set state of calendar to read-only */ 360 /** set state of calendar to read-only */
361 void setReadOnly(bool readOnly=true); 361 void setReadOnly(bool readOnly=true);
362 362
363 void eventUpdated(Incidence *); 363 void eventUpdated(Incidence *);
364 364
365 /* iTIP scheduling actions */ 365 /* iTIP scheduling actions */
366 void schedule_publish(Incidence *incidence = 0); 366 void schedule_publish(Incidence *incidence = 0);
367 void schedule_request(Incidence *incidence = 0); 367 void schedule_request(Incidence *incidence = 0);
368 void schedule_refresh(Incidence *incidence = 0); 368 void schedule_refresh(Incidence *incidence = 0);
369 void schedule_cancel(Incidence *incidence = 0); 369 void schedule_cancel(Incidence *incidence = 0);
370 void schedule_add(Incidence *incidence = 0); 370 void schedule_add(Incidence *incidence = 0);
371 void schedule_reply(Incidence *incidence = 0); 371 void schedule_reply(Incidence *incidence = 0);
372 void schedule_counter(Incidence *incidence = 0); 372 void schedule_counter(Incidence *incidence = 0);
373 void schedule_declinecounter(Incidence *incidence = 0); 373 void schedule_declinecounter(Incidence *incidence = 0);
374 void schedule_publish_freebusy(int daysToPublish = 30); 374 void schedule_publish_freebusy(int daysToPublish = 30);
375 375
376 void openAddressbook(); 376 void openAddressbook();
377 377
378 void editFilters(); 378 void editFilters();
379 void toggleFilerEnabled(); 379 void toggleFilerEnabled();
380 QPtrList<CalFilter> filters(); 380 QPtrList<CalFilter> filters();
381 void toggleFilter(); 381 void toggleFilter();
382 void showFilter(bool visible); 382 void showFilter(bool visible);
383 void updateFilter(); 383 void updateFilter();
384 void filterEdited(); 384 void filterEdited();
385 void selectFilter( int ); 385 void selectFilter( int );
386 KOFilterView *filterView(); 386 KOFilterView *filterView();
387 387
388 void showIntro(); 388 void showIntro();
389 389
390 /** Move the curdatepient view date to today */ 390 /** Move the curdatepient view date to today */
391 void goToday(); 391 void goToday();
392 392
393 /** Move to the next date(s) in the current view */ 393 /** Move to the next date(s) in the current view */
394 void goNext(); 394 void goNext();
395 395
396 /** Move to the previous date(s) in the current view */ 396 /** Move to the previous date(s) in the current view */
397 void goPrevious(); 397 void goPrevious();
398 /** Move to the next date(s) in the current view */ 398 /** Move to the next date(s) in the current view */
399 void goNextMonth(); 399 void goNextMonth();
400 400
401 /** Move to the previous date(s) in the current view */ 401 /** Move to the previous date(s) in the current view */
402 void goPreviousMonth(); 402 void goPreviousMonth();
403 403
404 void toggleExpand(); 404 void toggleExpand();
405 void toggleDateNavigatorWidget(); 405 void toggleDateNavigatorWidget();
406 void toggleAllDaySize(); 406 void toggleAllDaySize();
407 void dialogClosing(Incidence *); 407 void dialogClosing(Incidence *);
408 408
409 /** Look for new messages in the inbox */ 409 /** Look for new messages in the inbox */
410 void lookForIncomingMessages(); 410 void lookForIncomingMessages();
411 /** Look for new messages in the outbox */ 411 /** Look for new messages in the outbox */
412 void lookForOutgoingMessages(); 412 void lookForOutgoingMessages();
413 413
414 void processMainViewSelection( Incidence * ); 414 void processMainViewSelection( Incidence * );
415 void processTodoListSelection( Incidence * ); 415 void processTodoListSelection( Incidence * );
416 416
417 void processIncidenceSelection( Incidence * ); 417 void processIncidenceSelection( Incidence * );
418 418
419 void purgeCompleted(); 419 void purgeCompleted();
420 bool removeCompletedSubTodos( Todo* ); 420 bool removeCompletedSubTodos( Todo* );
421 void slotCalendarChanged(); 421 void slotCalendarChanged();
422 bool importBday(); 422 bool importBday();
423 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); 423 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday );
424 bool importQtopia( const QString &categoriesFile, 424 bool importQtopia( const QString &categoriesFile,
425 const QString &datebookFile, 425 const QString &datebookFile,
426 const QString &tasklistFile ); 426 const QString &tasklistFile );
427 void syncSharp( ); 427 void syncSharp( );
428 void syncPhone( ); 428 void syncPhone( );
429 void syncExternal( int mode );
429 void slotSelectPickerDate( QDate ) ; 430 void slotSelectPickerDate( QDate ) ;
430 void showDatePicker( ) ; 431 void showDatePicker( ) ;
431 void moveIncidence(Incidence *) ; 432 void moveIncidence(Incidence *) ;
432 void beamIncidence(Incidence *) ; 433 void beamIncidence(Incidence *) ;
433 void beamCalendar() ; 434 void beamCalendar() ;
434 void beamFilteredCalendar() ; 435 void beamFilteredCalendar() ;
435 void beamIncidenceList(QPtrList<Incidence>) ; 436 void beamIncidenceList(QPtrList<Incidence>) ;
436 void manageCategories(); 437 void manageCategories();
437 int addCategories(); 438 int addCategories();
438 void removeCategories(); 439 void removeCategories();
439 void setSyncDevice( QString ); 440 void setSyncDevice( QString );
440 void setSyncName( QString ); 441 void setSyncName( QString );
441 protected slots: 442 protected slots:
442 void timerAlarm(); 443 void timerAlarm();
443 void suspendAlarm(); 444 void suspendAlarm();
444 void beamDone( Ir *ir ); 445 void beamDone( Ir *ir );
445 /** Select a view or adapt the current view to display the specified dates. */ 446 /** Select a view or adapt the current view to display the specified dates. */
446 void showDates( const KCal::DateList & ); 447 void showDates( const KCal::DateList & );
447 void selectWeekNum ( int ); 448 void selectWeekNum ( int );
448 449
449 public: 450 public:
450 // show a standard warning 451 // show a standard warning
451 // returns KMsgBox::yesNoCancel() 452 // returns KMsgBox::yesNoCancel()
452 int msgCalModified(); 453 int msgCalModified();
453 void confSync(); 454 void confSync();
454 void setLoadedFileVersion(QDateTime); 455 void setLoadedFileVersion(QDateTime);
455 bool checkFileVersion(QString fn); 456 bool checkFileVersion(QString fn);
456 bool checkFileChanged(QString fn); 457 bool checkFileChanged(QString fn);
457 Event* getLastSyncEvent(); 458 Event* getLastSyncEvent();
458 /** Adapt navigation units correpsonding to step size of navigation of the 459 /** Adapt navigation units correpsonding to step size of navigation of the
459 * current view. 460 * current view.
460 */ 461 */
461 void adaptNavigationUnits(); 462 void adaptNavigationUnits();
462 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); 463 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode );
463 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); 464 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false );
464 //Attendee* getYourAttendee(Event *event); 465 //Attendee* getYourAttendee(Event *event);
465 protected: 466 protected:
466 void schedule(Scheduler::Method, Incidence *incidence = 0); 467 void schedule(Scheduler::Method, Incidence *incidence = 0);
467 468
468 // returns KMsgBox::OKCandel() 469 // returns KMsgBox::OKCandel()
469 int msgItemDelete(); 470 int msgItemDelete();
470 void showEventEditor(); 471 void showEventEditor();
471 void showTodoEditor(); 472 void showTodoEditor();
472 void writeLocale(); 473 void writeLocale();
473 Todo *selectedTodo(); 474 Todo *selectedTodo();
474 475
475 private: 476 private:
476 AlarmDialog * mAlarmDialog; 477 AlarmDialog * mAlarmDialog;
477 QString mAlarmNotification; 478 QString mAlarmNotification;
478 QString mSuspendAlarmNotification; 479 QString mSuspendAlarmNotification;
479 QTimer* mSuspendTimer; 480 QTimer* mSuspendTimer;
480 QTimer* mAlarmTimer; 481 QTimer* mAlarmTimer;
481 QTimer* mRecheckAlarmTimer; 482 QTimer* mRecheckAlarmTimer;
482 void computeAlarm( QString ); 483 void computeAlarm( QString );
483 void startAlarm( QString, QString ); 484 void startAlarm( QString, QString );
484 void setSyncEventsReadOnly(); 485 void setSyncEventsReadOnly();
485 486
486 QDateTime loadedFileVersion; 487 QDateTime loadedFileVersion;
487 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); 488 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete );
488 void checkExternalId( Incidence * inc ); 489 void checkExternalId( Incidence * inc );
489 int mGlobalSyncMode; 490 int mGlobalSyncMode;
490 QString mCurrentSyncDevice; 491 QString mCurrentSyncDevice;
491 QString mCurrentSyncName; 492 QString mCurrentSyncName;
492 KOBeamPrefs* beamDialog; 493 KOBeamPrefs* beamDialog;
493 void init(); 494 void init();
494 int mDatePickerMode; 495 int mDatePickerMode;
495 bool mFlagEditDescription; 496 bool mFlagEditDescription;
496 QDateTime mLastCalendarSync; 497 QDateTime mLastCalendarSync;
497 void createPrinter(); 498 void createPrinter();
498 499
499 void calendarModified( bool, Calendar * ); 500 void calendarModified( bool, Calendar * );
500 501
501 CalPrinter *mCalPrinter; 502 CalPrinter *mCalPrinter;
502 503
503 QSplitter *mPanner; 504 QSplitter *mPanner;
504 QSplitter *mLeftSplitter; 505 QSplitter *mLeftSplitter;
505 QWidget *mLeftFrame; 506 QWidget *mLeftFrame;
506 QWidgetStack *mRightFrame; 507 QWidgetStack *mRightFrame;
507 508
508 KDatePicker* mDatePicker; 509 KDatePicker* mDatePicker;
509 QVBox* mDateFrame; 510 QVBox* mDateFrame;
510 NavigatorBar *mNavigatorBar; 511 NavigatorBar *mNavigatorBar;
511 512
512 KDateNavigator *mDateNavigator; // widget showing small month view. 513 KDateNavigator *mDateNavigator; // widget showing small month view.
513 514
514 KOFilterView *mFilterView; 515 KOFilterView *mFilterView;
515 516
516 ResourceView *mResourceView; 517 ResourceView *mResourceView;
517 518
518 // calendar object for this viewing instance 519 // calendar object for this viewing instance
519 Calendar *mCalendar; 520 Calendar *mCalendar;
520 521
521 CalendarResourceManager *mResourceManager; 522 CalendarResourceManager *mResourceManager;
522 523
523 FileStorage *mStorage; 524 FileStorage *mStorage;
524 525
525 DateNavigator *mNavigator; 526 DateNavigator *mNavigator;
526 527
527 KOViewManager *mViewManager; 528 KOViewManager *mViewManager;
528 KODialogManager *mDialogManager; 529 KODialogManager *mDialogManager;
529 530
530 // Calendar filters 531 // Calendar filters
531 QPtrList<CalFilter> mFilters; 532 QPtrList<CalFilter> mFilters;
532 533
533 // various housekeeping variables. 534 // various housekeeping variables.
534 bool mModified; // flag indicating if calendar is modified 535 bool mModified; // flag indicating if calendar is modified
535 bool mReadOnly; // flag indicating if calendar is read-only 536 bool mReadOnly; // flag indicating if calendar is read-only
536 QDate mSaveSingleDate; 537 QDate mSaveSingleDate;
537 538
538 Incidence *mSelectedIncidence; 539 Incidence *mSelectedIncidence;
539 Incidence *mMoveIncidence; 540 Incidence *mMoveIncidence;
540 QPtrList<Event> mExternLastSyncEvent; 541 QPtrList<Event> mExternLastSyncEvent;
541 KOTodoView *mTodoList; 542 KOTodoView *mTodoList;
542 KOEventEditor * mEventEditor; 543 KOEventEditor * mEventEditor;
543 KOTodoEditor * mTodoEditor; 544 KOTodoEditor * mTodoEditor;
544 KOEventViewerDialog * mEventViewerDialog; 545 KOEventViewerDialog * mEventViewerDialog;
545 void keyPressEvent ( QKeyEvent *e) ; 546 void keyPressEvent ( QKeyEvent *e) ;
546 //QMap<Incidence*,KOIncidenceEditor*> mDialogList; 547 //QMap<Incidence*,KOIncidenceEditor*> mDialogList;
547}; 548};
548 549
549 550
550class CalendarViewVisitor : public Incidence::Visitor 551class CalendarViewVisitor : public Incidence::Visitor
551{ 552{
552 public: 553 public:
553 CalendarViewVisitor() : mView( 0 ) {} 554 CalendarViewVisitor() : mView( 0 ) {}
554 555
555 bool act( Incidence *incidence, CalendarView *view ) 556 bool act( Incidence *incidence, CalendarView *view )
556 { 557 {
557 mView = view; 558 mView = view;
558 return incidence->accept( *this ); 559 return incidence->accept( *this );
559 } 560 }
560 561
561 protected: 562 protected:
562 CalendarView *mView; 563 CalendarView *mView;
563}; 564};
564 565
565class ShowIncidenceVisitor : public CalendarViewVisitor 566class ShowIncidenceVisitor : public CalendarViewVisitor
566{ 567{
567 protected: 568 protected:
568 bool visit( Event *event ) { mView->showEvent( event ); return true; } 569 bool visit( Event *event ) { mView->showEvent( event ); return true; }
569 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } 570 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; }
570 bool visit( Journal * j ) { mView->showJournal( j );return true; } 571 bool visit( Journal * j ) { mView->showJournal( j );return true; }
571}; 572};
572 573
573class EditIncidenceVisitor : public CalendarViewVisitor 574class EditIncidenceVisitor : public CalendarViewVisitor
574{ 575{
575 protected: 576 protected:
576 bool visit( Event *event ) { mView->editEvent( event ); return true; } 577 bool visit( Event *event ) { mView->editEvent( event ); return true; }
577 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } 578 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; }
578 bool visit( Journal *j ) { mView->editJournal( j); return true; } 579 bool visit( Journal *j ) { mView->editJournal( j); return true; }
579}; 580};
580 581
581class DeleteIncidenceVisitor : public CalendarViewVisitor 582class DeleteIncidenceVisitor : public CalendarViewVisitor
582{ 583{
583 protected: 584 protected:
584 bool visit( Event *event ) { mView->deleteEvent( event ); return true; } 585 bool visit( Event *event ) { mView->deleteEvent( event ); return true; }
585 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } 586 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; }
586 bool visit( Journal * j) {mView->deleteJournal( j ); return true; } 587 bool visit( Journal * j) {mView->deleteJournal( j ); return true; }
587}; 588};
588 589
589#endif 590#endif
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 062c95f..cce182a 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1,2063 +1,2069 @@
1#include <stdlib.h> 1#include <stdlib.h>
2 2
3#include <qaction.h> 3#include <qaction.h>
4#include <qpopupmenu.h> 4#include <qpopupmenu.h>
5#include <qpainter.h> 5#include <qpainter.h>
6#include <qwhatsthis.h> 6#include <qwhatsthis.h>
7#include <qmessagebox.h> 7#include <qmessagebox.h>
8#include <qlineedit.h> 8#include <qlineedit.h>
9#include <qfile.h> 9#include <qfile.h>
10#include <qdir.h> 10#include <qdir.h>
11#include <qapp.h> 11#include <qapp.h>
12#include <qfileinfo.h> 12#include <qfileinfo.h>
13#include <qlabel.h> 13#include <qlabel.h>
14#include <qwmatrix.h> 14#include <qwmatrix.h>
15#include <qtextbrowser.h> 15#include <qtextbrowser.h>
16#include <qtextstream.h> 16#include <qtextstream.h>
17#ifndef DESKTOP_VERSION 17#ifndef DESKTOP_VERSION
18#include <qpe/global.h> 18#include <qpe/global.h>
19#include <qpe/qpemenubar.h> 19#include <qpe/qpemenubar.h>
20#include <qpe/qpetoolbar.h> 20#include <qpe/qpetoolbar.h>
21#include <qpe/resource.h> 21#include <qpe/resource.h>
22#include <qpe/qpeapplication.h> 22#include <qpe/qpeapplication.h>
23#include <qtopia/alarmserver.h> 23#include <qtopia/alarmserver.h>
24#include <qtopia/qcopenvelope_qws.h> 24#include <qtopia/qcopenvelope_qws.h>
25#else 25#else
26#include <qmenubar.h> 26#include <qmenubar.h>
27#include <qtoolbar.h> 27#include <qtoolbar.h>
28#include <qapplication.h> 28#include <qapplication.h>
29//#include <resource.h> 29//#include <resource.h>
30 30
31#endif 31#endif
32#include <libkcal/calendarlocal.h> 32#include <libkcal/calendarlocal.h>
33#include <libkcal/todo.h> 33#include <libkcal/todo.h>
34#include <libkdepim/ksyncprofile.h> 34#include <libkdepim/ksyncprofile.h>
35#include <libkdepim/kincidenceformatter.h> 35#include <libkdepim/kincidenceformatter.h>
36 36
37#include "calendarview.h" 37#include "calendarview.h"
38#include "koviewmanager.h" 38#include "koviewmanager.h"
39#include "datenavigator.h" 39#include "datenavigator.h"
40#include "koagendaview.h" 40#include "koagendaview.h"
41#include "koagenda.h" 41#include "koagenda.h"
42#include "kodialogmanager.h" 42#include "kodialogmanager.h"
43#include "kdialogbase.h" 43#include "kdialogbase.h"
44#include "kapplication.h" 44#include "kapplication.h"
45#include "kofilterview.h" 45#include "kofilterview.h"
46#include "kstandarddirs.h" 46#include "kstandarddirs.h"
47#include "koprefs.h" 47#include "koprefs.h"
48#include "kfiledialog.h" 48#include "kfiledialog.h"
49#include "koglobals.h" 49#include "koglobals.h"
50#include "kglobal.h" 50#include "kglobal.h"
51#include "klocale.h" 51#include "klocale.h"
52#include "kconfig.h" 52#include "kconfig.h"
53#include "simplealarmclient.h" 53#include "simplealarmclient.h"
54using namespace KCal; 54using namespace KCal;
55#ifndef _WIN32_ 55#ifndef _WIN32_
56#include <unistd.h> 56#include <unistd.h>
57#else 57#else
58#include "koimportoldialog.h" 58#include "koimportoldialog.h"
59#endif 59#endif
60#include "mainwindow.h" 60#include "mainwindow.h"
61 61
62int globalFlagBlockStartup; 62int globalFlagBlockStartup;
63MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : 63MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
64 QMainWindow( parent, name ) 64 QMainWindow( parent, name )
65{ 65{
66 66
67#ifdef DESKTOP_VERSION 67#ifdef DESKTOP_VERSION
68 setFont( QFont("Arial"), 14 ); 68 setFont( QFont("Arial"), 14 );
69#endif 69#endif
70 70
71 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; 71 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
72 QString confFile = locateLocal("config","korganizerrc"); 72 QString confFile = locateLocal("config","korganizerrc");
73 QFileInfo finf ( confFile ); 73 QFileInfo finf ( confFile );
74 bool showWarning = !finf.exists(); 74 bool showWarning = !finf.exists();
75 setIcon(SmallIcon( "ko24" ) ); 75 setIcon(SmallIcon( "ko24" ) );
76 mBlockAtStartup = true; 76 mBlockAtStartup = true;
77 mFlagKeyPressed = false; 77 mFlagKeyPressed = false;
78 setCaption("KOrganizer/Pi"); 78 setCaption("KOrganizer/Pi");
79 KOPrefs *p = KOPrefs::instance(); 79 KOPrefs *p = KOPrefs::instance();
80 // if ( QApplication::desktop()->height() > 480 ) { 80 // if ( QApplication::desktop()->height() > 480 ) {
81// if ( p->mHourSize == 4 ) 81// if ( p->mHourSize == 4 )
82// p->mHourSize = 6; 82// p->mHourSize = 6;
83// } 83// }
84 if ( p->mHourSize > 18 ) 84 if ( p->mHourSize > 18 )
85 p->mHourSize = 18; 85 p->mHourSize = 18;
86 QMainWindow::ToolBarDock tbd; 86 QMainWindow::ToolBarDock tbd;
87 if ( p->mToolBarHor ) { 87 if ( p->mToolBarHor ) {
88 if ( p->mToolBarUp ) 88 if ( p->mToolBarUp )
89 tbd = Bottom; 89 tbd = Bottom;
90 else 90 else
91 tbd = Top; 91 tbd = Top;
92 } 92 }
93 else { 93 else {
94 if ( p->mToolBarUp ) 94 if ( p->mToolBarUp )
95 tbd = Right; 95 tbd = Right;
96 else 96 else
97 tbd = Left; 97 tbd = Left;
98 } 98 }
99 if ( KOPrefs::instance()->mUseAppColors ) 99 if ( KOPrefs::instance()->mUseAppColors )
100 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 100 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
101 globalFlagBlockStartup = 1; 101 globalFlagBlockStartup = 1;
102 iconToolBar = new QPEToolBar( this ); 102 iconToolBar = new QPEToolBar( this );
103 addToolBar (iconToolBar , tbd ); 103 addToolBar (iconToolBar , tbd );
104 mBlockSaveFlag = false; 104 mBlockSaveFlag = false;
105 mCalendarModifiedFlag = false; 105 mCalendarModifiedFlag = false;
106 106
107 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); 107 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
108 splash->setAlignment ( AlignCenter ); 108 splash->setAlignment ( AlignCenter );
109 setCentralWidget( splash ); 109 setCentralWidget( splash );
110#ifndef DESKTOP_VERSION 110#ifndef DESKTOP_VERSION
111 showMaximized(); 111 showMaximized();
112#endif 112#endif
113 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); 113 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
114 setDefaultPreferences(); 114 setDefaultPreferences();
115 mCalendar = new CalendarLocal(); 115 mCalendar = new CalendarLocal();
116 mView = new CalendarView( mCalendar, this,"mCalendar " ); 116 mView = new CalendarView( mCalendar, this,"mCalendar " );
117 mView->hide(); 117 mView->hide();
118 //mView->resize(splash->size() ); 118 //mView->resize(splash->size() );
119 initActions(); 119 initActions();
120#ifndef DESKTOP_VERSION 120#ifndef DESKTOP_VERSION
121 iconToolBar->show(); 121 iconToolBar->show();
122 qApp->processEvents(); 122 qApp->processEvents();
123#endif 123#endif
124 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); 124 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
125 int vh = height() ; 125 int vh = height() ;
126 int vw = width(); 126 int vw = width();
127 //qDebug("Toolbar hei %d ",iconToolBar->height() ); 127 //qDebug("Toolbar hei %d ",iconToolBar->height() );
128 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 128 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
129 vh -= iconToolBar->height(); 129 vh -= iconToolBar->height();
130 } else { 130 } else {
131 vw -= iconToolBar->height(); 131 vw -= iconToolBar->height();
132 } 132 }
133 //mView->setMaximumSize( splash->size() ); 133 //mView->setMaximumSize( splash->size() );
134 //mView->resize( splash->size() ); 134 //mView->resize( splash->size() );
135 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 135 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
136 mView->readSettings(); 136 mView->readSettings();
137 bool oldOpened = false; 137 bool oldOpened = false;
138 bool newFile = false; 138 bool newFile = false;
139 if( !QFile::exists( defaultFileName() ) ) { 139 if( !QFile::exists( defaultFileName() ) ) {
140 QFileInfo finfo ( defaultFileName() ); 140 QFileInfo finfo ( defaultFileName() );
141 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); 141 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
142 qDebug("oldfile %s ", oldFile.latin1()); 142 qDebug("oldfile %s ", oldFile.latin1());
143 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"; 143 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";
144 finfo.setFile( oldFile ); 144 finfo.setFile( oldFile );
145 if (finfo.exists() ) { 145 if (finfo.exists() ) {
146 KMessageBox::information( this, message); 146 KMessageBox::information( this, message);
147 mView->openCalendar( oldFile ); 147 mView->openCalendar( oldFile );
148 qApp->processEvents(); 148 qApp->processEvents();
149 } else { 149 } else {
150 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); 150 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
151 finfo.setFile( oldFile ); 151 finfo.setFile( oldFile );
152 if (finfo.exists() ) { 152 if (finfo.exists() ) {
153 KMessageBox::information( this, message); 153 KMessageBox::information( this, message);
154 mView->openCalendar( oldFile ); 154 mView->openCalendar( oldFile );
155 qApp->processEvents(); 155 qApp->processEvents();
156 } 156 }
157 } 157 }
158 mView->saveCalendar( defaultFileName() ); 158 mView->saveCalendar( defaultFileName() );
159 newFile = true; 159 newFile = true;
160 } 160 }
161 161
162 QTime neededSaveTime = QDateTime::currentDateTime().time(); 162 QTime neededSaveTime = QDateTime::currentDateTime().time();
163 if ( ! oldOpened ) 163 if ( ! oldOpened )
164 mView->openCalendar( defaultFileName() ); 164 mView->openCalendar( defaultFileName() );
165 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 165 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
166 qDebug("KO: Calendar loading time: %d ms",msNeeded ); 166 qDebug("KO: Calendar loading time: %d ms",msNeeded );
167 167
168 if ( KOPrefs::instance()->mLanguageChanged ) { 168 if ( KOPrefs::instance()->mLanguageChanged ) {
169 KOPrefs::instance()->setCategoryDefaults(); 169 KOPrefs::instance()->setCategoryDefaults();
170 int count = mView->addCategories(); 170 int count = mView->addCategories();
171 KOPrefs::instance()->mLanguageChanged = false; 171 KOPrefs::instance()->mLanguageChanged = false;
172 } 172 }
173 processIncidenceSelection( 0 ); 173 processIncidenceSelection( 0 );
174 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), 174 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
175 SLOT( processIncidenceSelection( Incidence * ) ) ); 175 SLOT( processIncidenceSelection( Incidence * ) ) );
176 connect( mView, SIGNAL( modifiedChanged( bool ) ), 176 connect( mView, SIGNAL( modifiedChanged( bool ) ),
177 SLOT( slotModifiedChanged( bool ) ) ); 177 SLOT( slotModifiedChanged( bool ) ) );
178 178
179 179
180 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); 180 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
181 mView->setModified( false ); 181 mView->setModified( false );
182 mBlockAtStartup = false; 182 mBlockAtStartup = false;
183 mView->setModified( false ); 183 mView->setModified( false );
184 setCentralWidget( mView ); 184 setCentralWidget( mView );
185 globalFlagBlockStartup = 0; 185 globalFlagBlockStartup = 0;
186 mView->show(); 186 mView->show();
187 delete splash; 187 delete splash;
188 if ( newFile ) 188 if ( newFile )
189 mView->updateConfig(); 189 mView->updateConfig();
190 // qApp->processEvents(); 190 // qApp->processEvents();
191 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 191 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
192 fillSyncMenu(); 192 fillSyncMenu();
193 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); 193 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
194 if ( showWarning ) { 194 if ( showWarning ) {
195 KMessageBox::information( this, 195 KMessageBox::information( this,
196 "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"); 196 "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");
197 qApp->processEvents(); 197 qApp->processEvents();
198 mView->dialogManager()->showSyncOptions(); 198 mView->dialogManager()->showSyncOptions();
199 } 199 }
200} 200}
201MainWindow::~MainWindow() 201MainWindow::~MainWindow()
202{ 202{
203 //qDebug("MainWindow::~MainWindow() "); 203 //qDebug("MainWindow::~MainWindow() ");
204 //save toolbar location 204 //save toolbar location
205 205
206 delete mCalendar; 206 delete mCalendar;
207 delete KOPrefs::instance(); 207 delete KOPrefs::instance();
208 delete KIncidenceFormatter::instance(); 208 delete KIncidenceFormatter::instance();
209 209
210 210
211} 211}
212void MainWindow::closeEvent( QCloseEvent* ce ) 212void MainWindow::closeEvent( QCloseEvent* ce )
213{ 213{
214 214
215 215
216 216
217 if ( ! KOPrefs::instance()->mAskForQuit ) { 217 if ( ! KOPrefs::instance()->mAskForQuit ) {
218 saveOnClose(); 218 saveOnClose();
219 ce->accept(); 219 ce->accept();
220 return; 220 return;
221 221
222 } 222 }
223 223
224 switch( QMessageBox::information( this, "KO/Pi", 224 switch( QMessageBox::information( this, "KO/Pi",
225 i18n("Do you really want\nto close KO/Pi?"), 225 i18n("Do you really want\nto close KO/Pi?"),
226 i18n("Close"), i18n("No"), 226 i18n("Close"), i18n("No"),
227 0, 0 ) ) { 227 0, 0 ) ) {
228 case 0: 228 case 0:
229 saveOnClose(); 229 saveOnClose();
230 ce->accept(); 230 ce->accept();
231 break; 231 break;
232 case 1: 232 case 1:
233 ce->ignore(); 233 ce->ignore();
234 break; 234 break;
235 case 2: 235 case 2:
236 236
237 default: 237 default:
238 break; 238 break;
239 } 239 }
240 240
241 241
242} 242}
243 243
244void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) 244void MainWindow::recieve( const QCString& cmsg, const QByteArray& data )
245{ 245{
246 QDataStream stream( data, IO_ReadOnly ); 246 QDataStream stream( data, IO_ReadOnly );
247 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); 247 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" );
248 //QString datamess; 248 //QString datamess;
249 //qDebug("message "); 249 //qDebug("message ");
250 qDebug("KO: QCOP message received: %s ", cmsg.data() ); 250 qDebug("KO: QCOP message received: %s ", cmsg.data() );
251 if ( cmsg == "-writeFile" ) { 251 if ( cmsg == "-writeFile" ) {
252 // I made from the "-writeFile" an "-writeAlarm" 252 // I made from the "-writeFile" an "-writeAlarm"
253 mView->viewManager()->showWhatsNextView(); 253 mView->viewManager()->showWhatsNextView();
254 mCalendar->checkAlarmForIncidence( 0, true); 254 mCalendar->checkAlarmForIncidence( 0, true);
255 showMaximized(); 255 showMaximized();
256 raise(); 256 raise();
257 return; 257 return;
258 258
259 } 259 }
260 if ( cmsg == "-writeFileSilent" ) { 260 if ( cmsg == "-writeFileSilent" ) {
261 // I made from the "-writeFile" an "-writeAlarm" 261 // I made from the "-writeFile" an "-writeAlarm"
262 // mView->viewManager()->showWhatsNextView(); 262 // mView->viewManager()->showWhatsNextView();
263 mCalendar->checkAlarmForIncidence( 0, true); 263 mCalendar->checkAlarmForIncidence( 0, true);
264 //showMaximized(); 264 //showMaximized();
265 //raise(); 265 //raise();
266 hide(); 266 hide();
267 return; 267 return;
268 } 268 }
269 if ( cmsg == "-newCountdown" ) { 269 if ( cmsg == "-newCountdown" ) {
270 qDebug("newCountdown "); 270 qDebug("newCountdown ");
271 271
272 } 272 }
273 QString msg ; 273 QString msg ;
274 QString allmsg = cmsg; 274 QString allmsg = cmsg;
275 while ( allmsg.length() > 0 ) { 275 while ( allmsg.length() > 0 ) {
276 int nextC = allmsg.find( "-", 1 ); 276 int nextC = allmsg.find( "-", 1 );
277 if ( nextC == -1 ) { 277 if ( nextC == -1 ) {
278 msg = allmsg; 278 msg = allmsg;
279 allmsg = ""; 279 allmsg = "";
280 } else{ 280 } else{
281 msg = allmsg.left( nextC ); 281 msg = allmsg.left( nextC );
282 allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); 282 allmsg = allmsg.mid( nextC, allmsg.length()-nextC );
283 } 283 }
284 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); 284 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() );
285 if ( msg == "-newEvent" ) { 285 if ( msg == "-newEvent" ) {
286 mView->newEvent(); 286 mView->newEvent();
287 } 287 }
288 if ( msg == "-newTodo" ) { 288 if ( msg == "-newTodo" ) {
289 mView->newTodo(); 289 mView->newTodo();
290 290
291 } 291 }
292 if ( msg == "-showWN" ) { 292 if ( msg == "-showWN" ) {
293 mView->viewManager()->showWhatsNextView(); 293 mView->viewManager()->showWhatsNextView();
294 } 294 }
295 if ( msg == "-showTodo" ) { 295 if ( msg == "-showTodo" ) {
296 mView->viewManager()->showTodoView(); 296 mView->viewManager()->showTodoView();
297 } 297 }
298 if ( msg == "-showList" ) { 298 if ( msg == "-showList" ) {
299 mView->viewManager()->showListView(); 299 mView->viewManager()->showListView();
300 } 300 }
301 else if ( msg == "-showDay" ) { 301 else if ( msg == "-showDay" ) {
302 mView->viewManager()->showDayView(); 302 mView->viewManager()->showDayView();
303 } 303 }
304 else if ( msg == "-showWWeek" ) { 304 else if ( msg == "-showWWeek" ) {
305 mView->viewManager()->showWorkWeekView(); 305 mView->viewManager()->showWorkWeekView();
306 } 306 }
307 else if ( msg == "-ringSync" ) { 307 else if ( msg == "-ringSync" ) {
308 multiSync( false ); 308 multiSync( false );
309 } 309 }
310 else if ( msg == "-showWeek" ) { 310 else if ( msg == "-showWeek" ) {
311 mView->viewManager()->showWeekView(); 311 mView->viewManager()->showWeekView();
312 } 312 }
313 else if ( msg == "-showTodo" ) { 313 else if ( msg == "-showTodo" ) {
314 mView->viewManager()->showTodoView(); 314 mView->viewManager()->showTodoView();
315 } 315 }
316 else if ( msg == "-showJournal" ) { 316 else if ( msg == "-showJournal" ) {
317 mView->dateNavigator()->selectDates( 1 ); 317 mView->dateNavigator()->selectDates( 1 );
318 mView->dateNavigator()->selectToday(); 318 mView->dateNavigator()->selectToday();
319 mView->viewManager()->showJournalView(); 319 mView->viewManager()->showJournalView();
320 } 320 }
321 else if ( msg == "-showKO" ) { 321 else if ( msg == "-showKO" ) {
322 mView->viewManager()->showNextXView(); 322 mView->viewManager()->showNextXView();
323 } 323 }
324 else if ( msg == "-showWNext" || msg == "nextView()" ) { 324 else if ( msg == "-showWNext" || msg == "nextView()" ) {
325 mView->viewManager()->showWhatsNextView(); 325 mView->viewManager()->showWhatsNextView();
326 } 326 }
327 else if ( msg == "-showNextXView" ) { 327 else if ( msg == "-showNextXView" ) {
328 mView->viewManager()->showNextXView(); 328 mView->viewManager()->showNextXView();
329 } 329 }
330 330
331 331
332 } 332 }
333 333
334 showMaximized(); 334 showMaximized();
335 raise(); 335 raise();
336} 336}
337 337
338QPixmap MainWindow::loadPixmap( QString name ) 338QPixmap MainWindow::loadPixmap( QString name )
339{ 339{
340 return SmallIcon( name ); 340 return SmallIcon( name );
341 341
342} 342}
343void MainWindow::initActions() 343void MainWindow::initActions()
344{ 344{
345 //KOPrefs::instance()->mShowFullMenu 345 //KOPrefs::instance()->mShowFullMenu
346 iconToolBar->clear(); 346 iconToolBar->clear();
347 KOPrefs *p = KOPrefs::instance(); 347 KOPrefs *p = KOPrefs::instance();
348 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); 348 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar );
349 349
350 QPopupMenu *viewMenu = new QPopupMenu( this ); 350 QPopupMenu *viewMenu = new QPopupMenu( this );
351 QPopupMenu *actionMenu = new QPopupMenu( this ); 351 QPopupMenu *actionMenu = new QPopupMenu( this );
352 QPopupMenu *importMenu = new QPopupMenu( this ); 352 QPopupMenu *importMenu = new QPopupMenu( this );
353 selectFilterMenu = new QPopupMenu( this ); 353 selectFilterMenu = new QPopupMenu( this );
354 selectFilterMenu->setCheckable( true ); 354 selectFilterMenu->setCheckable( true );
355 syncMenu = new QPopupMenu( this ); 355 syncMenu = new QPopupMenu( this );
356 configureAgendaMenu = new QPopupMenu( this ); 356 configureAgendaMenu = new QPopupMenu( this );
357 configureToolBarMenu = new QPopupMenu( this ); 357 configureToolBarMenu = new QPopupMenu( this );
358 QPopupMenu *helpMenu = new QPopupMenu( this ); 358 QPopupMenu *helpMenu = new QPopupMenu( this );
359 if ( KOPrefs::instance()->mShowFullMenu ) { 359 if ( KOPrefs::instance()->mShowFullMenu ) {
360 QMenuBar *menuBar1; 360 QMenuBar *menuBar1;
361 menuBar1 = menuBar(); 361 menuBar1 = menuBar();
362 menuBar1->insertItem( i18n("File"), importMenu ); 362 menuBar1->insertItem( i18n("File"), importMenu );
363 menuBar1->insertItem( i18n("View"), viewMenu ); 363 menuBar1->insertItem( i18n("View"), viewMenu );
364 menuBar1->insertItem( i18n("Actions"), actionMenu ); 364 menuBar1->insertItem( i18n("Actions"), actionMenu );
365 menuBar1->insertItem( i18n("Synchronize"), syncMenu ); 365 menuBar1->insertItem( i18n("Synchronize"), syncMenu );
366 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 366 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu );
367 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); 367 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu );
368 menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); 368 menuBar1->insertItem( i18n("Filter"),selectFilterMenu );
369 menuBar1->insertItem( i18n("Help"), helpMenu ); 369 menuBar1->insertItem( i18n("Help"), helpMenu );
370 } else { 370 } else {
371 QPEMenuBar *menuBar1; 371 QPEMenuBar *menuBar1;
372 menuBar1 = new QPEMenuBar( iconToolBar ); 372 menuBar1 = new QPEMenuBar( iconToolBar );
373 QPopupMenu *menuBar = new QPopupMenu( this ); 373 QPopupMenu *menuBar = new QPopupMenu( this );
374 menuBar1->insertItem( i18n("ME"), menuBar); 374 menuBar1->insertItem( i18n("ME"), menuBar);
375 menuBar->insertItem( i18n("File"), importMenu ); 375 menuBar->insertItem( i18n("File"), importMenu );
376 menuBar->insertItem( i18n("View"), viewMenu ); 376 menuBar->insertItem( i18n("View"), viewMenu );
377 menuBar->insertItem( i18n("Actions"), actionMenu ); 377 menuBar->insertItem( i18n("Actions"), actionMenu );
378 menuBar->insertItem( i18n("Synchronize"), syncMenu ); 378 menuBar->insertItem( i18n("Synchronize"), syncMenu );
379 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 379 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu );
380 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); 380 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu );
381 menuBar->insertItem( i18n("Filter"),selectFilterMenu ); 381 menuBar->insertItem( i18n("Filter"),selectFilterMenu );
382 menuBar->insertItem( i18n("Help"), helpMenu ); 382 menuBar->insertItem( i18n("Help"), helpMenu );
383 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); 383 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() );
384 menuBar1->setMaximumSize( menuBar1->sizeHint( )); 384 menuBar1->setMaximumSize( menuBar1->sizeHint( ));
385 } 385 }
386 connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) ); 386 connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) );
387 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); 387 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
388 connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) ); 388 connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) );
389 389
390 // ****************** 390 // ******************
391 QAction *action; 391 QAction *action;
392 QIconSet icon; 392 QIconSet icon;
393 // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); 393 // QPopupMenu *configureMenu= new QPopupMenu( menuBar );
394 configureToolBarMenu->setCheckable( true ); 394 configureToolBarMenu->setCheckable( true );
395 395
396 QString pathString = ""; 396 QString pathString = "";
397 if ( !p->mToolBarMiniIcons ) { 397 if ( !p->mToolBarMiniIcons ) {
398 if ( QApplication::desktop()->width() < 480 ) 398 if ( QApplication::desktop()->width() < 480 )
399 pathString += "icons16/"; 399 pathString += "icons16/";
400 } else 400 } else
401 pathString += "iconsmini/"; 401 pathString += "iconsmini/";
402 configureAgendaMenu->setCheckable( true ); 402 configureAgendaMenu->setCheckable( true );
403 configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 ); 403 configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 );
404 configureAgendaMenu->insertSeparator(); 404 configureAgendaMenu->insertSeparator();
405 configureAgendaMenu->insertItem(i18n("Tiny"), 4 ); 405 configureAgendaMenu->insertItem(i18n("Tiny"), 4 );
406 configureAgendaMenu->insertItem(i18n("Small"), 6 ); 406 configureAgendaMenu->insertItem(i18n("Small"), 6 );
407 configureAgendaMenu->insertItem(i18n("Medium"), 8 ); 407 configureAgendaMenu->insertItem(i18n("Medium"), 8 );
408 configureAgendaMenu->insertItem(i18n("Normal"), 10 ); 408 configureAgendaMenu->insertItem(i18n("Normal"), 10 );
409 configureAgendaMenu->insertItem(i18n("Large"), 12 ); 409 configureAgendaMenu->insertItem(i18n("Large"), 12 );
410 configureAgendaMenu->insertItem(i18n("Big"), 14 ); 410 configureAgendaMenu->insertItem(i18n("Big"), 14 );
411 configureAgendaMenu->insertItem(i18n("Bigger"), 16 ); 411 configureAgendaMenu->insertItem(i18n("Bigger"), 16 );
412 configureAgendaMenu->insertItem(i18n("Biggest"), 18 ); 412 configureAgendaMenu->insertItem(i18n("Biggest"), 18 );
413 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); 413 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu );
414 414
415 icon = loadPixmap( pathString + "configure" ); 415 icon = loadPixmap( pathString + "configure" );
416 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); 416 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this );
417 action->addTo( actionMenu ); 417 action->addTo( actionMenu );
418 connect( action, SIGNAL( activated() ), 418 connect( action, SIGNAL( activated() ),
419 mView, SLOT( edit_options() ) ); 419 mView, SLOT( edit_options() ) );
420 actionMenu->insertSeparator(); 420 actionMenu->insertSeparator();
421 icon = loadPixmap( pathString + "newevent" ); 421 icon = loadPixmap( pathString + "newevent" );
422 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); 422 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 );
423 configureToolBarMenu->insertSeparator(); 423 configureToolBarMenu->insertSeparator();
424 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); 424 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 );
425 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); 425 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this );
426 ne_action->addTo( actionMenu ); 426 ne_action->addTo( actionMenu );
427 connect( ne_action, SIGNAL( activated() ), 427 connect( ne_action, SIGNAL( activated() ),
428 mView, SLOT( newEvent() ) ); 428 mView, SLOT( newEvent() ) );
429 icon = loadPixmap( pathString + "newtodo" ); 429 icon = loadPixmap( pathString + "newtodo" );
430 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); 430 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 );
431 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); 431 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this );
432 nt_action->addTo( actionMenu ); 432 nt_action->addTo( actionMenu );
433 connect( nt_action, SIGNAL( activated() ), 433 connect( nt_action, SIGNAL( activated() ),
434 mView, SLOT( newTodo() ) ); 434 mView, SLOT( newTodo() ) );
435 icon = loadPixmap( pathString + "navi" ); 435 icon = loadPixmap( pathString + "navi" );
436 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); 436 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this );
437 action->addTo( viewMenu ); 437 action->addTo( viewMenu );
438 connect( action, SIGNAL( activated() ), 438 connect( action, SIGNAL( activated() ),
439 mView, SLOT( toggleDateNavigatorWidget() ) ); 439 mView, SLOT( toggleDateNavigatorWidget() ) );
440 icon = loadPixmap( pathString + "filter" ); 440 icon = loadPixmap( pathString + "filter" );
441 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); 441 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this );
442 action->addTo( viewMenu ); 442 action->addTo( viewMenu );
443 connect( action, SIGNAL( activated() ), 443 connect( action, SIGNAL( activated() ),
444 mView, SLOT( toggleFilter() ) ); 444 mView, SLOT( toggleFilter() ) );
445 445
446 446
447 viewMenu->insertSeparator(); 447 viewMenu->insertSeparator();
448 icon = loadPixmap( pathString + "picker" ); 448 icon = loadPixmap( pathString + "picker" );
449 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); 449 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this );
450 action->addTo( viewMenu ); 450 action->addTo( viewMenu );
451 connect( action, SIGNAL( activated() ), 451 connect( action, SIGNAL( activated() ),
452 mView, SLOT( showDatePicker() ) ); 452 mView, SLOT( showDatePicker() ) );
453 action->addTo( iconToolBar ); 453 action->addTo( iconToolBar );
454 viewMenu->insertSeparator(); 454 viewMenu->insertSeparator();
455 icon = loadPixmap( pathString + "list" ); 455 icon = loadPixmap( pathString + "list" );
456 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); 456 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 );
457 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); 457 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this );
458 showlist_action->addTo( viewMenu ); 458 showlist_action->addTo( viewMenu );
459 connect( showlist_action, SIGNAL( activated() ), 459 connect( showlist_action, SIGNAL( activated() ),
460 mView->viewManager(), SLOT( showListView() ) ); 460 mView->viewManager(), SLOT( showListView() ) );
461 461
462 462
463 icon = loadPixmap( pathString + "day" ); 463 icon = loadPixmap( pathString + "day" );
464 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); 464 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 );
465 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); 465 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this );
466 day1_action->addTo( viewMenu ); 466 day1_action->addTo( viewMenu );
467 // action->addTo( toolBar ); 467 // action->addTo( toolBar );
468 connect( day1_action, SIGNAL( activated() ), 468 connect( day1_action, SIGNAL( activated() ),
469 mView->viewManager(), SLOT( showDayView() ) ); 469 mView->viewManager(), SLOT( showDayView() ) );
470 470
471 icon = loadPixmap( pathString + "workweek" ); 471 icon = loadPixmap( pathString + "workweek" );
472 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); 472 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 );
473 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); 473 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this );
474 day5_action->addTo( viewMenu ); 474 day5_action->addTo( viewMenu );
475 connect( day5_action, SIGNAL( activated() ), 475 connect( day5_action, SIGNAL( activated() ),
476 mView->viewManager(), SLOT( showWorkWeekView() ) ); 476 mView->viewManager(), SLOT( showWorkWeekView() ) );
477 477
478 icon = loadPixmap( pathString + "week" ); 478 icon = loadPixmap( pathString + "week" );
479 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); 479 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 );
480 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); 480 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this );
481 day7_action->addTo( viewMenu ); 481 day7_action->addTo( viewMenu );
482 connect( day7_action, SIGNAL( activated() ), 482 connect( day7_action, SIGNAL( activated() ),
483 mView->viewManager(), SLOT( showWeekView() ) ); 483 mView->viewManager(), SLOT( showWeekView() ) );
484 484
485 icon = loadPixmap( pathString + "month" ); 485 icon = loadPixmap( pathString + "month" );
486 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); 486 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 );
487 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); 487 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this );
488 month_action->addTo( viewMenu ); 488 month_action->addTo( viewMenu );
489 connect( month_action, SIGNAL( activated() ), 489 connect( month_action, SIGNAL( activated() ),
490 mView->viewManager(), SLOT( showMonthView() ) ); 490 mView->viewManager(), SLOT( showMonthView() ) );
491 491
492 icon = loadPixmap( pathString + "todo" ); 492 icon = loadPixmap( pathString + "todo" );
493 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); 493 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 );
494 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); 494 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this );
495 todoview_action->addTo( viewMenu ); 495 todoview_action->addTo( viewMenu );
496 connect( todoview_action, SIGNAL( activated() ), 496 connect( todoview_action, SIGNAL( activated() ),
497 mView->viewManager(), SLOT( showTodoView() ) ); 497 mView->viewManager(), SLOT( showTodoView() ) );
498 498
499 icon = loadPixmap( pathString + "journal" ); 499 icon = loadPixmap( pathString + "journal" );
500 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); 500 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 );
501 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); 501 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this );
502 viewjournal_action->addTo( viewMenu ); 502 viewjournal_action->addTo( viewMenu );
503 connect( viewjournal_action, SIGNAL( activated() ), 503 connect( viewjournal_action, SIGNAL( activated() ),
504 mView->viewManager(), SLOT( showJournalView() ) ); 504 mView->viewManager(), SLOT( showJournalView() ) );
505 505
506 icon = loadPixmap( pathString + "xdays" ); 506 icon = loadPixmap( pathString + "xdays" );
507 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 ); 507 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 );
508 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); 508 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this );
509 xdays_action->addTo( viewMenu ); 509 xdays_action->addTo( viewMenu );
510 connect( xdays_action, SIGNAL( activated() ), 510 connect( xdays_action, SIGNAL( activated() ),
511 mView->viewManager(), SLOT( showNextXView() ) ); 511 mView->viewManager(), SLOT( showNextXView() ) );
512 512
513 icon = loadPixmap( pathString + "whatsnext" ); 513 icon = loadPixmap( pathString + "whatsnext" );
514 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 ); 514 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 );
515 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); 515 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this );
516 whatsnext_action->addTo( viewMenu ); 516 whatsnext_action->addTo( viewMenu );
517 connect( whatsnext_action, SIGNAL( activated() ), 517 connect( whatsnext_action, SIGNAL( activated() ),
518 mView->viewManager(), SLOT( showWhatsNextView() ) ); 518 mView->viewManager(), SLOT( showWhatsNextView() ) );
519 519
520#if 0 520#if 0
521 action = new QAction( "view_timespan", "Time Span", 0, this ); 521 action = new QAction( "view_timespan", "Time Span", 0, this );
522 action->addTo( viewMenu ); 522 action->addTo( viewMenu );
523 connect( action, SIGNAL( activated() ), 523 connect( action, SIGNAL( activated() ),
524 mView->viewManager(), SLOT( showTimeSpanView() ) ); 524 mView->viewManager(), SLOT( showTimeSpanView() ) );
525#endif 525#endif
526 526
527 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, 527 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0,
528 this ); 528 this );
529 mNewSubTodoAction->addTo( actionMenu ); 529 mNewSubTodoAction->addTo( actionMenu );
530 connect( mNewSubTodoAction, SIGNAL( activated() ), 530 connect( mNewSubTodoAction, SIGNAL( activated() ),
531 mView, SLOT( newSubTodo() ) ); 531 mView, SLOT( newSubTodo() ) );
532 532
533 actionMenu->insertSeparator(); 533 actionMenu->insertSeparator();
534 534
535 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); 535 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this );
536 mShowAction->addTo( actionMenu ); 536 mShowAction->addTo( actionMenu );
537 connect( mShowAction, SIGNAL( activated() ), 537 connect( mShowAction, SIGNAL( activated() ),
538 mView, SLOT( showIncidence() ) ); 538 mView, SLOT( showIncidence() ) );
539 539
540 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); 540 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this );
541 mEditAction->addTo( actionMenu ); 541 mEditAction->addTo( actionMenu );
542 connect( mEditAction, SIGNAL( activated() ), 542 connect( mEditAction, SIGNAL( activated() ),
543 mView, SLOT( editIncidence() ) ); 543 mView, SLOT( editIncidence() ) );
544 544
545 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); 545 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this );
546 mDeleteAction->addTo( actionMenu ); 546 mDeleteAction->addTo( actionMenu );
547 connect( mDeleteAction, SIGNAL( activated() ), 547 connect( mDeleteAction, SIGNAL( activated() ),
548 mView, SLOT( deleteIncidence() ) ); 548 mView, SLOT( deleteIncidence() ) );
549 549
550 actionMenu->insertSeparator(); 550 actionMenu->insertSeparator();
551 551
552 action = new QAction( "purge_completed", i18n("Purge Completed"), 0, 552 action = new QAction( "purge_completed", i18n("Purge Completed"), 0,
553 this ); 553 this );
554 action->addTo( actionMenu ); 554 action->addTo( actionMenu );
555 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); 555 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) );
556 556
557 icon = loadPixmap( pathString + "search" ); 557 icon = loadPixmap( pathString + "search" );
558 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); 558 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this );
559 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4); 559 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4);
560 search_action->addTo( actionMenu ); 560 search_action->addTo( actionMenu );
561 connect( search_action, SIGNAL( activated() ), 561 connect( search_action, SIGNAL( activated() ),
562 mView->dialogManager(), SLOT( showSearchDialog() ) ); 562 mView->dialogManager(), SLOT( showSearchDialog() ) );
563 563
564 icon = loadPixmap( pathString + "today" ); 564 icon = loadPixmap( pathString + "today" );
565 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); 565 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130);
566 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); 566 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this );
567 today_action->addTo( actionMenu ); 567 today_action->addTo( actionMenu );
568 connect( today_action, SIGNAL( activated() ), 568 connect( today_action, SIGNAL( activated() ),
569 mView, SLOT( goToday() ) ); 569 mView, SLOT( goToday() ) );
570 570
571 if ( KOPrefs::instance()->mShowFullMenu ) { 571 if ( KOPrefs::instance()->mShowFullMenu ) {
572 actionMenu->insertSeparator(); 572 actionMenu->insertSeparator();
573 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); 573 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu );
574 574
575 } 575 }
576 // actionMenu->insertSeparator(); 576 // actionMenu->insertSeparator();
577 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, 577 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0,
578 this ); 578 this );
579 action->addTo( importMenu ); 579 action->addTo( importMenu );
580 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); 580 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) );
581 action = new QAction( "import_quick", i18n("Import last file"), 0, 581 action = new QAction( "import_quick", i18n("Import last file"), 0,
582 this ); 582 this );
583 action->addTo( importMenu ); 583 action->addTo( importMenu );
584 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); 584 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) );
585 importMenu->insertSeparator(); 585 importMenu->insertSeparator();
586 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, 586 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0,
587 this ); 587 this );
588 action->addTo( importMenu ); 588 action->addTo( importMenu );
589 connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); 589 connect( action, SIGNAL( activated() ), SLOT( importBday() ) );
590#ifndef DESKTOP_VERSION 590#ifndef DESKTOP_VERSION
591 importMenu->insertSeparator(); 591 importMenu->insertSeparator();
592 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, 592 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0,
593 this ); 593 this );
594 action->addTo( importMenu ); 594 action->addTo( importMenu );
595 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); 595 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) );
596#else 596#else
597#ifdef _WIN32_ 597#ifdef _WIN32_
598 importMenu->insertSeparator(); 598 importMenu->insertSeparator();
599 action = new QAction( "import_ol", i18n("Import from OL"), 0, 599 action = new QAction( "import_ol", i18n("Import from OL"), 0,
600 this ); 600 this );
601 action->addTo( importMenu ); 601 action->addTo( importMenu );
602 connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); 602 connect( action, SIGNAL( activated() ), SLOT( importOL() ) );
603#endif 603#endif
604#endif 604#endif
605 605
606 importMenu->insertSeparator(); 606 importMenu->insertSeparator();
607 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, 607 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0,
608 this ); 608 this );
609 action->addTo( importMenu ); 609 action->addTo( importMenu );
610 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); 610 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) );
611 611
612 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, 612 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0,
613 this ); 613 this );
614 action->addTo( importMenu ); 614 action->addTo( importMenu );
615 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); 615 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) );
616 616
617 importMenu->insertSeparator(); 617 importMenu->insertSeparator();
618 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, 618 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0,
619 this ); 619 this );
620 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); 620 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) );
621 importMenu->insertSeparator(); 621 importMenu->insertSeparator();
622 action = new QAction( "manage cat", i18n("Manage new categories..."), 0, 622 action = new QAction( "manage cat", i18n("Manage new categories..."), 0,
623 this ); 623 this );
624 action->addTo( importMenu ); 624 action->addTo( importMenu );
625 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); 625 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) );
626#ifndef DESKTOP_VERSION 626#ifndef DESKTOP_VERSION
627 importMenu->insertSeparator(); 627 importMenu->insertSeparator();
628 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, 628 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0,
629 this ); 629 this );
630 action->addTo( importMenu ); 630 action->addTo( importMenu );
631 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); 631 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) );
632 632
633 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, 633 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0,
634 this ); 634 this );
635 action->addTo( importMenu ); 635 action->addTo( importMenu );
636 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); 636 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) );
637#else 637#else
638 importMenu->insertSeparator(); 638 importMenu->insertSeparator();
639 icon = loadPixmap( pathString + "print" ); 639 icon = loadPixmap( pathString + "print" );
640 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); 640 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this );
641 action->addTo( importMenu ); 641 action->addTo( importMenu );
642 connect( action, SIGNAL( activated() ), 642 connect( action, SIGNAL( activated() ),
643 this, SLOT( printCal() ) ); 643 this, SLOT( printCal() ) );
644 644
645 icon = loadPixmap( pathString + "print" ); 645 icon = loadPixmap( pathString + "print" );
646 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); 646 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this );
647 action->addTo( importMenu ); 647 action->addTo( importMenu );
648 connect( action, SIGNAL( activated() ), 648 connect( action, SIGNAL( activated() ),
649 this, SLOT( printSel() ) ); 649 this, SLOT( printSel() ) );
650#endif 650#endif
651 importMenu->insertSeparator(); 651 importMenu->insertSeparator();
652 action = new QAction( "beam all", i18n("Save"), 0, 652 action = new QAction( "beam all", i18n("Save"), 0,
653 this ); 653 this );
654 action->addTo( importMenu ); 654 action->addTo( importMenu );
655 connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); 655 connect( action, SIGNAL( activated() ), this, SLOT( save() ) );
656 action = new QAction( "beam all", i18n("Exit (+save)"), 0, 656 action = new QAction( "beam all", i18n("Exit (+save)"), 0,
657 this ); 657 this );
658 action->addTo( importMenu ); 658 action->addTo( importMenu );
659 connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); 659 connect( action, SIGNAL( activated() ), this, SLOT( close() ) );
660 660
661 //menuBar->insertItem( "Configure",configureMenu ); 661 //menuBar->insertItem( "Configure",configureMenu );
662 //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); 662 //configureMenu->insertItem( "Toolbar",configureToolBarMenu );
663 icon = loadPixmap( "korganizer/korganizer" ); 663 icon = loadPixmap( "korganizer/korganizer" );
664 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); 664 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this );
665 action->addTo( helpMenu ); 665 action->addTo( helpMenu );
666 connect( action, SIGNAL( activated() ), 666 connect( action, SIGNAL( activated() ),
667 SLOT( keyBindings() ) ); 667 SLOT( keyBindings() ) );
668 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); 668 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this );
669 action->addTo( helpMenu ); 669 action->addTo( helpMenu );
670 connect( action, SIGNAL( activated() ), 670 connect( action, SIGNAL( activated() ),
671 SLOT( features() ) ); 671 SLOT( features() ) );
672 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); 672 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this );
673 action->addTo( helpMenu ); 673 action->addTo( helpMenu );
674 connect( action, SIGNAL( activated() ), 674 connect( action, SIGNAL( activated() ),
675 SLOT( aboutAutoSaving() ) ); 675 SLOT( aboutAutoSaving() ) );
676 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); 676 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this );
677 action->addTo( helpMenu ); 677 action->addTo( helpMenu );
678 connect( action, SIGNAL( activated() ), 678 connect( action, SIGNAL( activated() ),
679 SLOT( aboutKnownBugs() ) ); 679 SLOT( aboutKnownBugs() ) );
680 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); 680 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this );
681 action->addTo( helpMenu ); 681 action->addTo( helpMenu );
682 connect( action, SIGNAL( activated() ), 682 connect( action, SIGNAL( activated() ),
683 SLOT( usertrans() ) ); 683 SLOT( usertrans() ) );
684 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); 684 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this );
685 action->addTo( helpMenu ); 685 action->addTo( helpMenu );
686 connect( action, SIGNAL( activated() ), 686 connect( action, SIGNAL( activated() ),
687 SLOT( synchowto() ) ); 687 SLOT( synchowto() ) );
688 action = new QAction( "Whats New", i18n("What's new?"), 0,this ); 688 action = new QAction( "Whats New", i18n("What's new?"), 0,this );
689 action->addTo( helpMenu ); 689 action->addTo( helpMenu );
690 connect( action, SIGNAL( activated() ), 690 connect( action, SIGNAL( activated() ),
691 SLOT( whatsNew() ) ); 691 SLOT( whatsNew() ) );
692 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); 692 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this );
693 action->addTo( helpMenu ); 693 action->addTo( helpMenu );
694 connect( action, SIGNAL( activated() ), 694 connect( action, SIGNAL( activated() ),
695 SLOT( faq() ) ); 695 SLOT( faq() ) );
696 696
697 697
698 action = new QAction( "about", i18n("About..."), 0, this ); 698 action = new QAction( "about", i18n("About..."), 0, this );
699 action->addTo( helpMenu ); 699 action->addTo( helpMenu );
700 connect( action, SIGNAL( activated() ), 700 connect( action, SIGNAL( activated() ),
701 SLOT( about() ) ); 701 SLOT( about() ) );
702 action = new QAction( "licence", i18n("Licence..."), 0, this ); 702 action = new QAction( "licence", i18n("Licence..."), 0, this );
703 action->addTo( helpMenu ); 703 action->addTo( helpMenu );
704 connect( action, SIGNAL( activated() ), 704 connect( action, SIGNAL( activated() ),
705 SLOT( licence() ) ); 705 SLOT( licence() ) );
706 //menuBar->insertSeparator(); 706 //menuBar->insertSeparator();
707 707
708 // ****************************************************** 708 // ******************************************************
709 // menubar icons 709 // menubar icons
710 710
711 711
712 iconToolBar->setHorizontalStretchable (true ); 712 iconToolBar->setHorizontalStretchable (true );
713 //menuBar->insertItem( iconToolBar ); 713 //menuBar->insertItem( iconToolBar );
714 //xdays_action 714 //xdays_action
715 if (p-> mShowIconNewEvent) 715 if (p-> mShowIconNewEvent)
716 ne_action->addTo( iconToolBar ); 716 ne_action->addTo( iconToolBar );
717 if (p->mShowIconNewTodo ) 717 if (p->mShowIconNewTodo )
718 nt_action->addTo( iconToolBar ); 718 nt_action->addTo( iconToolBar );
719 if (p-> mShowIconSearch) 719 if (p-> mShowIconSearch)
720 search_action->addTo( iconToolBar ); 720 search_action->addTo( iconToolBar );
721 if (p-> mShowIconNext) 721 if (p-> mShowIconNext)
722 whatsnext_action->addTo( iconToolBar ); 722 whatsnext_action->addTo( iconToolBar );
723 if (p-> mShowIconNextDays) 723 if (p-> mShowIconNextDays)
724 xdays_action->addTo( iconToolBar ); 724 xdays_action->addTo( iconToolBar );
725 if (p-> mShowIconList) 725 if (p-> mShowIconList)
726 showlist_action->addTo( iconToolBar ); 726 showlist_action->addTo( iconToolBar );
727 if (p-> mShowIconDay1) 727 if (p-> mShowIconDay1)
728 day1_action->addTo( iconToolBar ); 728 day1_action->addTo( iconToolBar );
729 if (p-> mShowIconDay5) 729 if (p-> mShowIconDay5)
730 day5_action->addTo( iconToolBar ); 730 day5_action->addTo( iconToolBar );
731 if (p-> mShowIconDay7) 731 if (p-> mShowIconDay7)
732 day7_action->addTo( iconToolBar ); 732 day7_action->addTo( iconToolBar );
733 if (p-> mShowIconMonth) 733 if (p-> mShowIconMonth)
734 month_action->addTo( iconToolBar ); 734 month_action->addTo( iconToolBar );
735 if (p-> mShowIconTodoview) 735 if (p-> mShowIconTodoview)
736 todoview_action->addTo( iconToolBar ); 736 todoview_action->addTo( iconToolBar );
737 if (p-> mShowIconJournal) 737 if (p-> mShowIconJournal)
738 viewjournal_action->addTo( iconToolBar ); 738 viewjournal_action->addTo( iconToolBar );
739 icon = loadPixmap( pathString + "2leftarrowB" ); 739 icon = loadPixmap( pathString + "2leftarrowB" );
740 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); 740 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14);
741 if (p-> mShowIconBackFast) { 741 if (p-> mShowIconBackFast) {
742 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); 742 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this );
743 connect( action, SIGNAL( activated() ), 743 connect( action, SIGNAL( activated() ),
744 mView, SLOT( goPreviousMonth() ) ); 744 mView, SLOT( goPreviousMonth() ) );
745 action->addTo( iconToolBar ); 745 action->addTo( iconToolBar );
746 } 746 }
747 icon = loadPixmap( pathString + "1leftarrowB" ); 747 icon = loadPixmap( pathString + "1leftarrowB" );
748 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); 748 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15);
749 if (p-> mShowIconBack) { 749 if (p-> mShowIconBack) {
750 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); 750 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this );
751 connect( action, SIGNAL( activated() ), 751 connect( action, SIGNAL( activated() ),
752 mView, SLOT( goPrevious() ) ); 752 mView, SLOT( goPrevious() ) );
753 action->addTo( iconToolBar ); 753 action->addTo( iconToolBar );
754 } 754 }
755 if (p-> mShowIconToday) 755 if (p-> mShowIconToday)
756 today_action->addTo( iconToolBar ); 756 today_action->addTo( iconToolBar );
757 icon = loadPixmap( pathString + "1rightarrowB" ); 757 icon = loadPixmap( pathString + "1rightarrowB" );
758 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); 758 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220);
759 if (p-> mShowIconForward) { 759 if (p-> mShowIconForward) {
760 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); 760 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this );
761 connect( action, SIGNAL( activated() ), 761 connect( action, SIGNAL( activated() ),
762 mView, SLOT( goNext() ) ); 762 mView, SLOT( goNext() ) );
763 action->addTo( iconToolBar ); 763 action->addTo( iconToolBar );
764 } 764 }
765 icon = loadPixmap( pathString + "2rightarrowB" ); 765 icon = loadPixmap( pathString + "2rightarrowB" );
766 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); 766 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230);
767 if (p-> mShowIconForwardFast) { 767 if (p-> mShowIconForwardFast) {
768 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); 768 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this );
769 connect( action, SIGNAL( activated() ), 769 connect( action, SIGNAL( activated() ),
770 mView, SLOT( goNextMonth() ) ); 770 mView, SLOT( goNextMonth() ) );
771 action->addTo( iconToolBar ); 771 action->addTo( iconToolBar );
772 } 772 }
773 773
774 774
775 configureToolBarMenu->insertItem(i18n("What's This?"), 300); 775 configureToolBarMenu->insertItem(i18n("What's This?"), 300);
776 776
777 if (p-> mShowIconNewEvent) 777 if (p-> mShowIconNewEvent)
778 configureToolBarMenu->setItemChecked( 10, true ); 778 configureToolBarMenu->setItemChecked( 10, true );
779 if (p->mShowIconNewTodo ) 779 if (p->mShowIconNewTodo )
780 configureToolBarMenu->setItemChecked( 20, true ); 780 configureToolBarMenu->setItemChecked( 20, true );
781 if (p-> mShowIconSearch) 781 if (p-> mShowIconSearch)
782 configureToolBarMenu->setItemChecked( 120, true ); 782 configureToolBarMenu->setItemChecked( 120, true );
783 if (p-> mShowIconList) 783 if (p-> mShowIconList)
784 configureToolBarMenu->setItemChecked( 30, true ); 784 configureToolBarMenu->setItemChecked( 30, true );
785 if (p-> mShowIconDay1) 785 if (p-> mShowIconDay1)
786 configureToolBarMenu->setItemChecked( 40, true ); 786 configureToolBarMenu->setItemChecked( 40, true );
787 if (p-> mShowIconDay5) 787 if (p-> mShowIconDay5)
788 configureToolBarMenu->setItemChecked( 50, true ); 788 configureToolBarMenu->setItemChecked( 50, true );
789 if (p-> mShowIconDay7) 789 if (p-> mShowIconDay7)
790 configureToolBarMenu->setItemChecked( 60, true ); 790 configureToolBarMenu->setItemChecked( 60, true );
791 if (p-> mShowIconMonth) 791 if (p-> mShowIconMonth)
792 configureToolBarMenu->setItemChecked( 70, true ); 792 configureToolBarMenu->setItemChecked( 70, true );
793 if (p-> mShowIconTodoview) 793 if (p-> mShowIconTodoview)
794 configureToolBarMenu->setItemChecked( 80, true ); 794 configureToolBarMenu->setItemChecked( 80, true );
795 if (p-> mShowIconBackFast) 795 if (p-> mShowIconBackFast)
796 configureToolBarMenu->setItemChecked( 200, true ); 796 configureToolBarMenu->setItemChecked( 200, true );
797 if (p-> mShowIconBack) 797 if (p-> mShowIconBack)
798 configureToolBarMenu->setItemChecked( 210, true ); 798 configureToolBarMenu->setItemChecked( 210, true );
799 if (p-> mShowIconToday) 799 if (p-> mShowIconToday)
800 configureToolBarMenu->setItemChecked( 130, true ); 800 configureToolBarMenu->setItemChecked( 130, true );
801 if (p-> mShowIconForward) 801 if (p-> mShowIconForward)
802 configureToolBarMenu->setItemChecked( 220, true ); 802 configureToolBarMenu->setItemChecked( 220, true );
803 if (p-> mShowIconForwardFast) 803 if (p-> mShowIconForwardFast)
804 configureToolBarMenu->setItemChecked( 230, true ); 804 configureToolBarMenu->setItemChecked( 230, true );
805 if (p-> mShowIconNextDays) 805 if (p-> mShowIconNextDays)
806 configureToolBarMenu->setItemChecked( 100, true ); 806 configureToolBarMenu->setItemChecked( 100, true );
807 if (p-> mShowIconNext) 807 if (p-> mShowIconNext)
808 configureToolBarMenu->setItemChecked( 110, true ); 808 configureToolBarMenu->setItemChecked( 110, true );
809 if (p-> mShowIconJournal) 809 if (p-> mShowIconJournal)
810 configureToolBarMenu->setItemChecked( 90, true ); 810 configureToolBarMenu->setItemChecked( 90, true );
811 if (p-> mShowIconWhatsThis) 811 if (p-> mShowIconWhatsThis)
812 configureToolBarMenu->setItemChecked( 300, true ); 812 configureToolBarMenu->setItemChecked( 300, true );
813 813
814 QLabel* dummy = new QLabel( iconToolBar ); 814 QLabel* dummy = new QLabel( iconToolBar );
815 dummy->setBackgroundColor( iconToolBar->backgroundColor() ); 815 dummy->setBackgroundColor( iconToolBar->backgroundColor() );
816 if (!p-> mShowIconStretch) 816 if (!p-> mShowIconStretch)
817 iconToolBar->setStretchableWidget ( dummy ) ; 817 iconToolBar->setStretchableWidget ( dummy ) ;
818 else 818 else
819 configureToolBarMenu->setItemChecked( 5, true ); 819 configureToolBarMenu->setItemChecked( 5, true );
820 if (p-> mShowIconWhatsThis) 820 if (p-> mShowIconWhatsThis)
821 QWhatsThis::whatsThisButton ( iconToolBar ); 821 QWhatsThis::whatsThisButton ( iconToolBar );
822 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); 822 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) );
823 configureAgenda( p->mHourSize ); 823 configureAgenda( p->mHourSize );
824 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); 824 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) );
825} 825}
826void MainWindow::fillSyncMenu() 826void MainWindow::fillSyncMenu()
827{ 827{
828 syncMenu->clear(); 828 syncMenu->clear();
829 syncMenu->insertItem( i18n("Configure..."), 0 ); 829 syncMenu->insertItem( i18n("Configure..."), 0 );
830 syncMenu->insertSeparator(); 830 syncMenu->insertSeparator();
831 syncMenu->insertItem( i18n("Multiple sync"), 1 ); 831 syncMenu->insertItem( i18n("Multiple sync"), 1 );
832 syncMenu->insertSeparator(); 832 syncMenu->insertSeparator();
833 KConfig config ( locateLocal( "config","syncprofilesrc" ) ); 833 KConfig config ( locateLocal( "config","syncprofilesrc" ) );
834 config.setGroup("General"); 834 config.setGroup("General");
835 QStringList prof = config.readListEntry("SyncProfileNames"); 835 QStringList prof = config.readListEntry("SyncProfileNames");
836 KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); 836 KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined");
837 if ( prof.count() < 3 ) { 837 if ( prof.count() < 3 ) {
838 prof.clear(); 838 prof.clear();
839 prof << i18n("Sharp_DTM"); 839 prof << i18n("Sharp_DTM");
840 prof << i18n("Local_file"); 840 prof << i18n("Local_file");
841 prof << i18n("Last_file"); 841 prof << i18n("Last_file");
842 KSyncProfile* temp = new KSyncProfile (); 842 KSyncProfile* temp = new KSyncProfile ();
843 temp->setName( prof[0] ); 843 temp->setName( prof[0] );
844 temp->writeConfig(&config); 844 temp->writeConfig(&config);
845 temp->setName( prof[1] ); 845 temp->setName( prof[1] );
846 temp->writeConfig(&config); 846 temp->writeConfig(&config);
847 temp->setName( prof[2] ); 847 temp->setName( prof[2] );
848 temp->writeConfig(&config); 848 temp->writeConfig(&config);
849 config.setGroup("General"); 849 config.setGroup("General");
850 config.writeEntry("SyncProfileNames",prof); 850 config.writeEntry("SyncProfileNames",prof);
851 config.writeEntry("ExternSyncProfiles","Sharp_DTM"); 851 config.writeEntry("ExternSyncProfiles","Sharp_DTM");
852 config.sync(); 852 config.sync();
853 delete temp; 853 delete temp;
854 } 854 }
855 KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); 855 KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
856 KOPrefs::instance()->mSyncProfileNames = prof; 856 KOPrefs::instance()->mSyncProfileNames = prof;
857 int i; 857 int i;
858 for ( i = 0; i < prof.count(); ++i ) { 858 for ( i = 0; i < prof.count(); ++i ) {
859 859
860 syncMenu->insertItem( prof[i], 1000+i ); 860 syncMenu->insertItem( prof[i], 1000+i );
861 if ( i == 2 ) 861 if ( i == 2 )
862 syncMenu->insertSeparator(); 862 syncMenu->insertSeparator();
863 } 863 }
864 QDir app_dir; 864 QDir app_dir;
865 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { 865 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
866 syncMenu->setItemEnabled( false , 1000 ); 866 syncMenu->setItemEnabled( false , 1000 );
867 } 867 }
868 mView->setupExternSyncProfiles(); 868 mView->setupExternSyncProfiles();
869} 869}
870 870
871int MainWindow::ringSync() 871int MainWindow::ringSync()
872{ 872{
873 int syncedProfiles = 0; 873 int syncedProfiles = 0;
874 int i; 874 int i;
875 QTime timer; 875 QTime timer;
876 KConfig config ( locateLocal( "config","syncprofilesrc" ) ); 876 KConfig config ( locateLocal( "config","syncprofilesrc" ) );
877 QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames; 877 QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames;
878 KSyncProfile* temp = new KSyncProfile (); 878 KSyncProfile* temp = new KSyncProfile ();
879 KOPrefs::instance()->mAskForPreferences = false; 879 KOPrefs::instance()->mAskForPreferences = false;
880 for ( i = 0; i < syncProfileNames.count(); ++i ) { 880 for ( i = 0; i < syncProfileNames.count(); ++i ) {
881 mCurrentSyncProfile = i; 881 mCurrentSyncProfile = i;
882 temp->setName(syncProfileNames[mCurrentSyncProfile]); 882 temp->setName(syncProfileNames[mCurrentSyncProfile]);
883 temp->readConfig(&config); 883 temp->readConfig(&config);
884 if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) { 884 if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) {
885 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); 885 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
886 ++syncedProfiles; 886 ++syncedProfiles;
887 // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 887 // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
888 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 888 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
889 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 889 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
890 KOPrefs::instance()->mShowSyncSummary = false; 890 KOPrefs::instance()->mShowSyncSummary = false;
891 mView->setSyncDevice(syncProfileNames[i] ); 891 mView->setSyncDevice(syncProfileNames[i] );
892 mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); 892 mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
893 if ( i == 0 ) { 893 if ( i == 0 ) {
894 syncSharp(); 894 syncSharp();
895 } else { 895 } else {
896 if ( temp->getIsLocalFileSync() ) { 896 if ( temp->getIsLocalFileSync() ) {
897 if ( syncWithFile( temp->getRemoteFileName( ), true ) ) 897 if ( syncWithFile( temp->getRemoteFileName( ), true ) )
898 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); 898 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName();
899 } else { 899 } else {
900 if ( temp->getIsPhoneSync() ) { 900 if ( temp->getIsPhoneSync() ) {
901 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; 901 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ;
902 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); 902 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( );
903 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); 903 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( );
904 syncPhone(); 904 syncPhone();
905 } else 905 } else
906 syncRemote( temp, false ); 906 syncRemote( temp, false );
907 907
908 } 908 }
909 } 909 }
910 timer.start(); 910 timer.start();
911 setCaption(i18n("Multiple sync in progress ... please wait!") ); 911 setCaption(i18n("Multiple sync in progress ... please wait!") );
912 while ( timer.elapsed () < 2000 ) { 912 while ( timer.elapsed () < 2000 ) {
913 qApp->processEvents(); 913 qApp->processEvents();
914#ifndef _WIN32_ 914#ifndef _WIN32_
915 sleep (1); 915 sleep (1);
916#endif 916#endif
917 } 917 }
918 918
919 } 919 }
920 920
921 } 921 }
922 delete temp; 922 delete temp;
923 return syncedProfiles; 923 return syncedProfiles;
924} 924}
925 925
926void MainWindow::multiSync( bool askforPrefs ) 926void MainWindow::multiSync( bool askforPrefs )
927{ 927{
928 if (mBlockSaveFlag) 928 if (mBlockSaveFlag)
929 return; 929 return;
930 mBlockSaveFlag = true; 930 mBlockSaveFlag = true;
931 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 931 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
932 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 932 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
933 question, 933 question,
934 i18n("Yes"), i18n("No"), 934 i18n("Yes"), i18n("No"),
935 0, 0 ) != 0 ) { 935 0, 0 ) != 0 ) {
936 mBlockSaveFlag = false; 936 mBlockSaveFlag = false;
937 setCaption(i18n("Aborted! Nothing synced!")); 937 setCaption(i18n("Aborted! Nothing synced!"));
938 return; 938 return;
939 } 939 }
940 mView->setSyncDevice(i18n("Multiple profiles") ); 940 mView->setSyncDevice(i18n("Multiple profiles") );
941 KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs; 941 KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs;
942 if ( askforPrefs ) { 942 if ( askforPrefs ) {
943 mView->edit_sync_options(); 943 mView->edit_sync_options();
944 KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs; 944 KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs;
945 } 945 }
946 setCaption(i18n("Multiple sync started.") ); 946 setCaption(i18n("Multiple sync started.") );
947 qApp->processEvents(); 947 qApp->processEvents();
948 int num = ringSync() ; 948 int num = ringSync() ;
949 if ( num > 1 ) 949 if ( num > 1 )
950 ringSync(); 950 ringSync();
951 mBlockSaveFlag = false; 951 mBlockSaveFlag = false;
952 if ( num ) 952 if ( num )
953 save(); 953 save();
954 if ( num ) 954 if ( num )
955 setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); 955 setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) );
956 else 956 else
957 setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 957 setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
958 return; 958 return;
959} 959}
960void MainWindow::slotSyncMenu( int action ) 960void MainWindow::slotSyncMenu( int action )
961{ 961{
962 //qDebug("syncaction %d ", action); 962 //qDebug("syncaction %d ", action);
963 if ( action == 0 ) { 963 if ( action == 0 ) {
964 964
965 confSync(); 965 confSync();
966 966
967 return; 967 return;
968 } 968 }
969 if ( action == 1 ) { 969 if ( action == 1 ) {
970 multiSync( true ); 970 multiSync( true );
971 return; 971 return;
972 } 972 }
973 973
974 if (mBlockSaveFlag) 974 if (mBlockSaveFlag)
975 return; 975 return;
976 mBlockSaveFlag = true; 976 mBlockSaveFlag = true;
977 mCurrentSyncProfile = action - 1000 ; 977 mCurrentSyncProfile = action - 1000 ;
978 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); 978 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] );
979 mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); 979 mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
980 KConfig config ( locateLocal( "config","syncprofilesrc" ) ); 980 KConfig config ( locateLocal( "config","syncprofilesrc" ) );
981 KSyncProfile* temp = new KSyncProfile (); 981 KSyncProfile* temp = new KSyncProfile ();
982 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 982 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
983 temp->readConfig(&config); 983 temp->readConfig(&config);
984 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 984 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
985 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); 985 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs();
986 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 986 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
987 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 987 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
988 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); 988 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync();
989 if ( action == 1000 ) { 989 if ( action == 1000 ) {
990 syncSharp(); 990 syncSharp();
991 991
992 } else if ( action == 1001 ) { 992 } else if ( action == 1001 ) {
993 syncLocalFile(); 993 syncLocalFile();
994 994
995 } else if ( action == 1002 ) { 995 } else if ( action == 1002 ) {
996 quickSyncLocalFile(); 996 quickSyncLocalFile();
997 997
998 } else if ( action >= 1003 ) { 998 } else if ( action >= 1003 ) {
999 if ( temp->getIsLocalFileSync() ) { 999 if ( temp->getIsLocalFileSync() ) {
1000 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 1000 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
1001 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); 1001 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName();
1002 } else { 1002 } else {
1003 syncRemote( temp ); 1003 if ( temp->getIsPhoneSync() ) {
1004 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ;
1005 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( );
1006 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( );
1007 syncPhone();
1008 } else
1009 syncRemote( temp );
1004 1010
1005 } 1011 }
1006 } 1012 }
1007 delete temp; 1013 delete temp;
1008 mBlockSaveFlag = false; 1014 mBlockSaveFlag = false;
1009} 1015}
1010void MainWindow::setDefaultPreferences() 1016void MainWindow::setDefaultPreferences()
1011{ 1017{
1012 KOPrefs *p = KOPrefs::instance(); 1018 KOPrefs *p = KOPrefs::instance();
1013 1019
1014 p->mCompactDialogs = true; 1020 p->mCompactDialogs = true;
1015 p->mConfirm = true; 1021 p->mConfirm = true;
1016 // p->mEnableQuickTodo = false; 1022 // p->mEnableQuickTodo = false;
1017} 1023}
1018 1024
1019QString MainWindow::resourcePath() 1025QString MainWindow::resourcePath()
1020{ 1026{
1021 return KGlobal::iconLoader()->iconPath(); 1027 return KGlobal::iconLoader()->iconPath();
1022} 1028}
1023 1029
1024void MainWindow::displayText( QString text ,QString cap ) 1030void MainWindow::displayText( QString text ,QString cap )
1025{ 1031{
1026 QDialog dia( this, "name", true ); ; 1032 QDialog dia( this, "name", true ); ;
1027 dia.setCaption( cap ); 1033 dia.setCaption( cap );
1028 QVBoxLayout* lay = new QVBoxLayout( &dia ); 1034 QVBoxLayout* lay = new QVBoxLayout( &dia );
1029 lay->setSpacing( 3 ); 1035 lay->setSpacing( 3 );
1030 lay->setMargin( 3 ); 1036 lay->setMargin( 3 );
1031 QTextBrowser tb ( &dia ); 1037 QTextBrowser tb ( &dia );
1032 lay->addWidget( &tb ); 1038 lay->addWidget( &tb );
1033 tb.setText( text ); 1039 tb.setText( text );
1034#ifdef DESKTOP_VERSION 1040#ifdef DESKTOP_VERSION
1035 dia.resize( 640, 480); 1041 dia.resize( 640, 480);
1036#else 1042#else
1037 dia.showMaximized(); 1043 dia.showMaximized();
1038#endif 1044#endif
1039 dia.exec(); 1045 dia.exec();
1040} 1046}
1041void MainWindow::displayFile( QString fn, QString cap ) 1047void MainWindow::displayFile( QString fn, QString cap )
1042{ 1048{
1043 QString fileName = resourcePath() + fn; 1049 QString fileName = resourcePath() + fn;
1044 QString text; 1050 QString text;
1045 QFile file( fileName ); 1051 QFile file( fileName );
1046 if (!file.open( IO_ReadOnly ) ) { 1052 if (!file.open( IO_ReadOnly ) ) {
1047 return ; 1053 return ;
1048 1054
1049 } 1055 }
1050 QTextStream ts( &file ); 1056 QTextStream ts( &file );
1051 text = ts.read(); 1057 text = ts.read();
1052 file.close(); 1058 file.close();
1053 displayText( text, cap); 1059 displayText( text, cap);
1054} 1060}
1055void MainWindow::features() 1061void MainWindow::features()
1056{ 1062{
1057 1063
1058 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); 1064 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") );
1059} 1065}
1060 1066
1061void MainWindow::usertrans() 1067void MainWindow::usertrans()
1062{ 1068{
1063 1069
1064 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); 1070 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") );
1065} 1071}
1066void MainWindow::synchowto() 1072void MainWindow::synchowto()
1067{ 1073{
1068 1074
1069 displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") ); 1075 displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") );
1070} 1076}
1071void MainWindow::faq() 1077void MainWindow::faq()
1072{ 1078{
1073 displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); 1079 displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") );
1074 1080
1075} 1081}
1076void MainWindow::whatsNew() 1082void MainWindow::whatsNew()
1077{ 1083{
1078 displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") ); 1084 displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") );
1079 1085
1080} 1086}
1081void MainWindow::licence() 1087void MainWindow::licence()
1082{ 1088{
1083 KApplication::showLicence(); 1089 KApplication::showLicence();
1084 1090
1085} 1091}
1086void MainWindow::about() 1092void MainWindow::about()
1087{ 1093{
1088 QString version; 1094 QString version;
1089#include <../version> 1095#include <../version>
1090 QMessageBox::about( this, i18n("About KOrganizer/Pi"), 1096 QMessageBox::about( this, i18n("About KOrganizer/Pi"),
1091 i18n("KOrganizer/Platform-independent\n") + 1097 i18n("KOrganizer/Platform-independent\n") +
1092 "(KO/Pi) " + version + " - " + 1098 "(KO/Pi) " + version + " - " +
1093 1099
1094#ifdef DESKTOP_VERSION 1100#ifdef DESKTOP_VERSION
1095 i18n("Desktop Edition\n") + 1101 i18n("Desktop Edition\n") +
1096#else 1102#else
1097 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + 1103 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") +
1098#endif 1104#endif
1099 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") ); 1105 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") );
1100} 1106}
1101void MainWindow::keyBindings() 1107void MainWindow::keyBindings()
1102{ 1108{
1103 QString cap = i18n("Key bindings KOrganizer/Pi"); 1109 QString cap = i18n("Key bindings KOrganizer/Pi");
1104 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + 1110 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") +
1105 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ 1111 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+
1106 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + 1112 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") +
1107 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ 1113 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+
1108 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ 1114 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+
1109 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ 1115 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+
1110 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ 1116 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+
1111 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ 1117 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+
1112 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ 1118 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+
1113 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ 1119 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+
1114 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ 1120 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+
1115 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ 1121 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+
1116 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ 1122 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+
1117 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ 1123 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+
1118 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ 1124 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+
1119 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ 1125 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+
1120 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ 1126 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+
1121 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ 1127 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+
1122 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ 1128 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+
1123 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ 1129 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+
1124 i18n("<p><h3>In agenda view:</h3></p>\n") + 1130 i18n("<p><h3>In agenda view:</h3></p>\n") +
1125 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ 1131 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+
1126 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ 1132 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+
1127 i18n("<p><h3>In todo view:</h3></p>\n") + 1133 i18n("<p><h3>In todo view:</h3></p>\n") +
1128 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ 1134 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+
1129 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1135 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1130 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ 1136 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+
1131 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ 1137 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+
1132 i18n("<p><h3>In list view:</h3></p>\n") + 1138 i18n("<p><h3>In list view:</h3></p>\n") +
1133 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1139 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1134 i18n("<p><b>return</b>: Select item+one step down</p>\n")+ 1140 i18n("<p><b>return</b>: Select item+one step down</p>\n")+
1135 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ 1141 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+
1136 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ 1142 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+
1137 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ 1143 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+
1138 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ 1144 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+
1139 i18n("<p><h3>In event/todo viewer:</h3></p>\n") + 1145 i18n("<p><h3>In event/todo viewer:</h3></p>\n") +
1140 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ 1146 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+
1141 i18n("<p><b>A</b>: Show agenda view.</p>\n")+ 1147 i18n("<p><b>A</b>: Show agenda view.</p>\n")+
1142 i18n("<p><b>E</b>: Edit item</p>\n") + 1148 i18n("<p><b>E</b>: Edit item</p>\n") +
1143 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + 1149 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") +
1144 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + 1150 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") +
1145 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ 1151 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+
1146 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ 1152 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+
1147 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ 1153 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+
1148 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ 1154 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+
1149 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ 1155 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+
1150 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + 1156 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") +
1151 i18n("<p><b>White</b>: Item readonly</p>\n"); 1157 i18n("<p><b>White</b>: Item readonly</p>\n");
1152 displayText( text, cap); 1158 displayText( text, cap);
1153 1159
1154} 1160}
1155void MainWindow::aboutAutoSaving() 1161void MainWindow::aboutAutoSaving()
1156{ 1162{
1157 QMessageBox* msg; 1163 QMessageBox* msg;
1158 msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), 1164 msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"),
1159 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, 1165 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,
1160 QMessageBox::Ok, 1166 QMessageBox::Ok,
1161 QMessageBox::NoButton, 1167 QMessageBox::NoButton,
1162 QMessageBox::NoButton); 1168 QMessageBox::NoButton);
1163 msg->exec(); 1169 msg->exec();
1164 delete msg; 1170 delete msg;
1165 1171
1166 1172
1167} 1173}
1168void MainWindow::aboutKnownBugs() 1174void MainWindow::aboutKnownBugs()
1169{ 1175{
1170 QMessageBox* msg; 1176 QMessageBox* msg;
1171 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), 1177 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"),
1172 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")+ 1178 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")+
1173 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ 1179 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+
1174 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + 1180 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") +
1175 i18n("\nor report them in the bugtracker on\n") + 1181 i18n("\nor report them in the bugtracker on\n") +
1176 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), 1182 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"),
1177 QMessageBox::NoIcon, 1183 QMessageBox::NoIcon,
1178 QMessageBox::Ok, 1184 QMessageBox::Ok,
1179 QMessageBox::NoButton, 1185 QMessageBox::NoButton,
1180 QMessageBox::NoButton); 1186 QMessageBox::NoButton);
1181 msg->exec(); 1187 msg->exec();
1182 delete msg; 1188 delete msg;
1183 1189
1184} 1190}
1185 1191
1186QString MainWindow::defaultFileName() 1192QString MainWindow::defaultFileName()
1187{ 1193{
1188 return locateLocal( "data", "korganizer/mycalendar.ics" ); 1194 return locateLocal( "data", "korganizer/mycalendar.ics" );
1189} 1195}
1190 1196
1191void MainWindow::processIncidenceSelection( Incidence *incidence ) 1197void MainWindow::processIncidenceSelection( Incidence *incidence )
1192{ 1198{
1193 if ( !incidence ) { 1199 if ( !incidence ) {
1194 enableIncidenceActions( false ); 1200 enableIncidenceActions( false );
1195 1201
1196 mNewSubTodoAction->setEnabled( false ); 1202 mNewSubTodoAction->setEnabled( false );
1197 setCaptionToDates(); 1203 setCaptionToDates();
1198 return; 1204 return;
1199 1205
1200 } 1206 }
1201 1207
1202 //KGlobal::locale()->formatDateTime(nextA, true); 1208 //KGlobal::locale()->formatDateTime(nextA, true);
1203 QString startString = ""; 1209 QString startString = "";
1204 if ( incidence->type() != "Todo" ) { 1210 if ( incidence->type() != "Todo" ) {
1205 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { 1211 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) {
1206 if ( incidence->doesFloat() ) { 1212 if ( incidence->doesFloat() ) {
1207 startString += ": "+incidence->dtStartDateStr( true ); 1213 startString += ": "+incidence->dtStartDateStr( true );
1208 startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); 1214 startString += " --- "+((Event*)incidence)->dtEndDateStr( true );
1209 1215
1210 } else { 1216 } else {
1211 startString = ": "+incidence->dtStartStr(true); 1217 startString = ": "+incidence->dtStartStr(true);
1212 startString += " --- "+((Event*)incidence)->dtEndStr(true); 1218 startString += " --- "+((Event*)incidence)->dtEndStr(true);
1213 1219
1214 } 1220 }
1215 1221
1216 } else { 1222 } else {
1217 if ( incidence->dtStart().time() != incidence->dtEnd().time() ) 1223 if ( incidence->dtStart().time() != incidence->dtEnd().time() )
1218 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ 1224 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+
1219 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); 1225 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time());
1220 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); 1226 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true);
1221 } 1227 }
1222 1228
1223 } 1229 }
1224 else 1230 else
1225 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); 1231 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed");
1226 if ( !incidence->location().isEmpty() ) 1232 if ( !incidence->location().isEmpty() )
1227 startString += " (" +incidence->location()+")"; 1233 startString += " (" +incidence->location()+")";
1228 setCaption( incidence->summary()+startString); 1234 setCaption( incidence->summary()+startString);
1229 1235
1230 enableIncidenceActions( true ); 1236 enableIncidenceActions( true );
1231 1237
1232 if ( incidence->type() == "Event" ) { 1238 if ( incidence->type() == "Event" ) {
1233 mShowAction->setText( i18n("Show Event...") ); 1239 mShowAction->setText( i18n("Show Event...") );
1234 mEditAction->setText( i18n("Edit Event...") ); 1240 mEditAction->setText( i18n("Edit Event...") );
1235 mDeleteAction->setText( i18n("Delete Event...") ); 1241 mDeleteAction->setText( i18n("Delete Event...") );
1236 1242
1237 mNewSubTodoAction->setEnabled( false ); 1243 mNewSubTodoAction->setEnabled( false );
1238 } else if ( incidence->type() == "Todo" ) { 1244 } else if ( incidence->type() == "Todo" ) {
1239 mShowAction->setText( i18n("Show Todo...") ); 1245 mShowAction->setText( i18n("Show Todo...") );
1240 mEditAction->setText( i18n("Edit Todo...") ); 1246 mEditAction->setText( i18n("Edit Todo...") );
1241 mDeleteAction->setText( i18n("Delete Todo...") ); 1247 mDeleteAction->setText( i18n("Delete Todo...") );
1242 1248
1243 mNewSubTodoAction->setEnabled( true ); 1249 mNewSubTodoAction->setEnabled( true );
1244 } else { 1250 } else {
1245 mShowAction->setText( i18n("Show...") ); 1251 mShowAction->setText( i18n("Show...") );
1246 mShowAction->setText( i18n("Edit...") ); 1252 mShowAction->setText( i18n("Edit...") );
1247 mShowAction->setText( i18n("Delete...") ); 1253 mShowAction->setText( i18n("Delete...") );
1248 1254
1249 mNewSubTodoAction->setEnabled( false ); 1255 mNewSubTodoAction->setEnabled( false );
1250 } 1256 }
1251} 1257}
1252 1258
1253void MainWindow::enableIncidenceActions( bool enabled ) 1259void MainWindow::enableIncidenceActions( bool enabled )
1254{ 1260{
1255 mShowAction->setEnabled( enabled ); 1261 mShowAction->setEnabled( enabled );
1256 mEditAction->setEnabled( enabled ); 1262 mEditAction->setEnabled( enabled );
1257 mDeleteAction->setEnabled( enabled ); 1263 mDeleteAction->setEnabled( enabled );
1258} 1264}
1259 1265
1260void MainWindow::importOL() 1266void MainWindow::importOL()
1261{ 1267{
1262#ifdef _WIN32_ 1268#ifdef _WIN32_
1263 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); 1269 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this );
1264 id->exec(); 1270 id->exec();
1265 delete id; 1271 delete id;
1266 mView->updateView(); 1272 mView->updateView();
1267#endif 1273#endif
1268} 1274}
1269void MainWindow::importBday() 1275void MainWindow::importBday()
1270{ 1276{
1271 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1277 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1272 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), 1278 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"),
1273 i18n("Import!"), i18n("Cancel"), 0, 1279 i18n("Import!"), i18n("Cancel"), 0,
1274 0, 1 ); 1280 0, 1 );
1275 if ( result == 0 ) { 1281 if ( result == 0 ) {
1276 mView->importBday(); 1282 mView->importBday();
1277 1283
1278 } 1284 }
1279 1285
1280 1286
1281} 1287}
1282void MainWindow::importQtopia() 1288void MainWindow::importQtopia()
1283{ 1289{
1284#ifndef DESKTOP_VERSION 1290#ifndef DESKTOP_VERSION
1285 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1291 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1286 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"), 1292 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"),
1287 i18n("Import!"), i18n("Cancel"), 0, 1293 i18n("Import!"), i18n("Cancel"), 0,
1288 0, 1 ); 1294 0, 1 );
1289 if ( result == 0 ) { 1295 if ( result == 0 ) {
1290 QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); 1296 QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
1291 QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); 1297 QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
1292 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; 1298 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
1293 mView->importQtopia( categories, datebook, todolist ); 1299 mView->importQtopia( categories, datebook, todolist );
1294 } 1300 }
1295#else 1301#else
1296 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1302 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1297 i18n("Not supported \non desktop!\n"), 1303 i18n("Not supported \non desktop!\n"),
1298 i18n("Ok"), i18n("Cancel"), 0, 1304 i18n("Ok"), i18n("Cancel"), 0,
1299 0, 1 ); 1305 0, 1 );
1300 1306
1301#endif 1307#endif
1302} 1308}
1303 1309
1304void MainWindow::saveOnClose() 1310void MainWindow::saveOnClose()
1305{ 1311{
1306 KOPrefs *p = KOPrefs::instance(); 1312 KOPrefs *p = KOPrefs::instance();
1307 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); 1313 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
1308 p->mToolBarUp = iconToolBar->x() > width()/2 || 1314 p->mToolBarUp = iconToolBar->x() > width()/2 ||
1309 iconToolBar->y() > height()/2; 1315 iconToolBar->y() > height()/2;
1310 mView->writeSettings(); 1316 mView->writeSettings();
1311 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) 1317 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName()))
1312 save(); 1318 save();
1313} 1319}
1314void MainWindow::slotModifiedChanged( bool changed ) 1320void MainWindow::slotModifiedChanged( bool changed )
1315{ 1321{
1316 if ( mBlockAtStartup ) 1322 if ( mBlockAtStartup )
1317 return; 1323 return;
1318 int msec; 1324 int msec;
1319 // we store the changes after 1 minute, 1325 // we store the changes after 1 minute,
1320 // and for safety reasons after 10 minutes again 1326 // and for safety reasons after 10 minutes again
1321 if ( !mBlockSaveFlag ) 1327 if ( !mBlockSaveFlag )
1322 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1328 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1323 else 1329 else
1324 msec = 1000 * 600; 1330 msec = 1000 * 600;
1325 mSaveTimer.start( msec, true ); // 1 minute 1331 mSaveTimer.start( msec, true ); // 1 minute
1326 qDebug("KO: Saving File in %d secs!", msec/1000); 1332 qDebug("KO: Saving File in %d secs!", msec/1000);
1327 mCalendarModifiedFlag = true; 1333 mCalendarModifiedFlag = true;
1328} 1334}
1329#include <qfileinfo.h> 1335#include <qfileinfo.h>
1330void MainWindow::save() 1336void MainWindow::save()
1331{ 1337{
1332 if ( mBlockSaveFlag ) 1338 if ( mBlockSaveFlag )
1333 return; 1339 return;
1334 bool store = mBlockSaveFlag; 1340 bool store = mBlockSaveFlag;
1335 mBlockSaveFlag = true; 1341 mBlockSaveFlag = true;
1336 if ( mView->checkFileVersion( defaultFileName()) ) { 1342 if ( mView->checkFileVersion( defaultFileName()) ) {
1337 1343
1338 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1344 QTime neededSaveTime = QDateTime::currentDateTime().time();
1339 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1345 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1340 qDebug("KO: Start saving data to file!"); 1346 qDebug("KO: Start saving data to file!");
1341 mView->saveCalendar( defaultFileName() ); 1347 mView->saveCalendar( defaultFileName() );
1342 1348
1343 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 1349 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1344 mView->setLoadedFileVersion(QDateTime::currentDateTime()); 1350 mView->setLoadedFileVersion(QDateTime::currentDateTime());
1345 qDebug("KO: Needed %d ms for saving.",msNeeded ); 1351 qDebug("KO: Needed %d ms for saving.",msNeeded );
1346 QString savemes; 1352 QString savemes;
1347 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 1353 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
1348 setCaption(savemes); 1354 setCaption(savemes);
1349 } else 1355 } else
1350 setCaption(i18n("Saving cancelled!")); 1356 setCaption(i18n("Saving cancelled!"));
1351 mCalendarModifiedFlag = false; 1357 mCalendarModifiedFlag = false;
1352 mBlockSaveFlag = store; 1358 mBlockSaveFlag = store;
1353} 1359}
1354 1360
1355void MainWindow::keyReleaseEvent ( QKeyEvent * e) 1361void MainWindow::keyReleaseEvent ( QKeyEvent * e)
1356{ 1362{
1357 if ( !e->isAutoRepeat() ) { 1363 if ( !e->isAutoRepeat() ) {
1358 mFlagKeyPressed = false; 1364 mFlagKeyPressed = false;
1359 } 1365 }
1360} 1366}
1361void MainWindow::keyPressEvent ( QKeyEvent * e ) 1367void MainWindow::keyPressEvent ( QKeyEvent * e )
1362{ 1368{
1363 qApp->processEvents(); 1369 qApp->processEvents();
1364 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 1370 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1365 e->ignore(); 1371 e->ignore();
1366 // qDebug(" ignore %d",e->isAutoRepeat() ); 1372 // qDebug(" ignore %d",e->isAutoRepeat() );
1367 return; 1373 return;
1368 } 1374 }
1369 if (! e->isAutoRepeat() ) 1375 if (! e->isAutoRepeat() )
1370 mFlagKeyPressed = true; 1376 mFlagKeyPressed = true;
1371 KOPrefs *p = KOPrefs::instance(); 1377 KOPrefs *p = KOPrefs::instance();
1372 bool showSelectedDates = false; 1378 bool showSelectedDates = false;
1373 int size; 1379 int size;
1374 int pro = 0; 1380 int pro = 0;
1375 //qDebug("MainWindow::keyPressEvent "); 1381 //qDebug("MainWindow::keyPressEvent ");
1376 switch ( e->key() ) { 1382 switch ( e->key() ) {
1377 case Qt::Key_Right: 1383 case Qt::Key_Right:
1378 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1384 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1379 mView->goNextMonth(); 1385 mView->goNextMonth();
1380 else 1386 else
1381 mView->goNext(); 1387 mView->goNext();
1382 showSelectedDates = true; 1388 showSelectedDates = true;
1383 break; 1389 break;
1384 case Qt::Key_Left: 1390 case Qt::Key_Left:
1385 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1391 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1386 mView->goPreviousMonth(); 1392 mView->goPreviousMonth();
1387 else 1393 else
1388 mView->goPrevious(); 1394 mView->goPrevious();
1389 showSelectedDates = true; 1395 showSelectedDates = true;
1390 break; 1396 break;
1391 case Qt::Key_Down: 1397 case Qt::Key_Down:
1392 mView->viewManager()->agendaView()->scrollOneHourDown(); 1398 mView->viewManager()->agendaView()->scrollOneHourDown();
1393 break; 1399 break;
1394 case Qt::Key_Up: 1400 case Qt::Key_Up:
1395 mView->viewManager()->agendaView()->scrollOneHourUp(); 1401 mView->viewManager()->agendaView()->scrollOneHourUp();
1396 break; 1402 break;
1397 case Qt::Key_I: 1403 case Qt::Key_I:
1398 mView->showIncidence(); 1404 mView->showIncidence();
1399 break; 1405 break;
1400 case Qt::Key_Delete: 1406 case Qt::Key_Delete:
1401 case Qt::Key_Backspace: 1407 case Qt::Key_Backspace:
1402 mView->deleteIncidence(); 1408 mView->deleteIncidence();
1403 break; 1409 break;
1404 case Qt::Key_D: 1410 case Qt::Key_D:
1405 mView->viewManager()->showDayView(); 1411 mView->viewManager()->showDayView();
1406 showSelectedDates = true; 1412 showSelectedDates = true;
1407 break; 1413 break;
1408 case Qt::Key_O: 1414 case Qt::Key_O:
1409 mView->toggleFilerEnabled( ); 1415 mView->toggleFilerEnabled( );
1410 break; 1416 break;
1411 case Qt::Key_0: 1417 case Qt::Key_0:
1412 case Qt::Key_1: 1418 case Qt::Key_1:
1413 case Qt::Key_2: 1419 case Qt::Key_2:
1414 case Qt::Key_3: 1420 case Qt::Key_3:
1415 case Qt::Key_4: 1421 case Qt::Key_4:
1416 case Qt::Key_5: 1422 case Qt::Key_5:
1417 case Qt::Key_6: 1423 case Qt::Key_6:
1418 case Qt::Key_7: 1424 case Qt::Key_7:
1419 case Qt::Key_8: 1425 case Qt::Key_8:
1420 case Qt::Key_9: 1426 case Qt::Key_9:
1421 pro = e->key()-48; 1427 pro = e->key()-48;
1422 if ( pro == 0 ) 1428 if ( pro == 0 )
1423 pro = 10; 1429 pro = 10;
1424 if ( e->state() == Qt::ControlButton) 1430 if ( e->state() == Qt::ControlButton)
1425 pro += 10; 1431 pro += 10;
1426 break; 1432 break;
1427 case Qt::Key_M: 1433 case Qt::Key_M:
1428 mView->viewManager()->showMonthView(); 1434 mView->viewManager()->showMonthView();
1429 showSelectedDates = true; 1435 showSelectedDates = true;
1430 break; 1436 break;
1431 case Qt::Key_Insert: 1437 case Qt::Key_Insert:
1432 mView->newEvent(); 1438 mView->newEvent();
1433 break; 1439 break;
1434 case Qt::Key_S : 1440 case Qt::Key_S :
1435 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1441 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1436 mView->newSubTodo(); 1442 mView->newSubTodo();
1437 else 1443 else
1438 mView->dialogManager()->showSearchDialog(); 1444 mView->dialogManager()->showSearchDialog();
1439 break; 1445 break;
1440 case Qt::Key_Y : 1446 case Qt::Key_Y :
1441 case Qt::Key_Z : 1447 case Qt::Key_Z :
1442 mView->viewManager()->showWorkWeekView(); 1448 mView->viewManager()->showWorkWeekView();
1443 showSelectedDates = true; 1449 showSelectedDates = true;
1444 break; 1450 break;
1445 case Qt::Key_U : 1451 case Qt::Key_U :
1446 mView->viewManager()->showWeekView(); 1452 mView->viewManager()->showWeekView();
1447 showSelectedDates = true; 1453 showSelectedDates = true;
1448 break; 1454 break;
1449 case Qt::Key_H : 1455 case Qt::Key_H :
1450 keyBindings(); 1456 keyBindings();
1451 break; 1457 break;
1452 case Qt::Key_W: 1458 case Qt::Key_W:
1453 mView->viewManager()->showWhatsNextView(); 1459 mView->viewManager()->showWhatsNextView();
1454 break; 1460 break;
1455 case Qt::Key_L: 1461 case Qt::Key_L:
1456 mView->viewManager()->showListView(); 1462 mView->viewManager()->showListView();
1457 break; 1463 break;
1458 case Qt::Key_N: 1464 case Qt::Key_N:
1459 mView->viewManager()->showNextXView(); 1465 mView->viewManager()->showNextXView();
1460 showSelectedDates = true; 1466 showSelectedDates = true;
1461 break; 1467 break;
1462 case Qt::Key_V: 1468 case Qt::Key_V:
1463 mView->viewManager()->showTodoView(); 1469 mView->viewManager()->showTodoView();
1464 break; 1470 break;
1465 case Qt::Key_C: 1471 case Qt::Key_C:
1466 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); 1472 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() );
1467 break; 1473 break;
1468 case Qt::Key_P: 1474 case Qt::Key_P:
1469 mView->showDatePicker( ); 1475 mView->showDatePicker( );
1470 break; 1476 break;
1471 case Qt::Key_F: 1477 case Qt::Key_F:
1472 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1478 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1473 mView->editFilters(); 1479 mView->editFilters();
1474 else 1480 else
1475 mView->toggleFilter(); 1481 mView->toggleFilter();
1476 break; 1482 break;
1477 case Qt::Key_X: 1483 case Qt::Key_X:
1478 mView->toggleDateNavigatorWidget(); 1484 mView->toggleDateNavigatorWidget();
1479 break; 1485 break;
1480 case Qt::Key_Space: 1486 case Qt::Key_Space:
1481 mView->toggleExpand(); 1487 mView->toggleExpand();
1482 break; 1488 break;
1483 case Qt::Key_A: 1489 case Qt::Key_A:
1484 mView->toggleAllDaySize(); 1490 mView->toggleAllDaySize();
1485 break; 1491 break;
1486 case Qt::Key_T: 1492 case Qt::Key_T:
1487 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1493 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1488 mView->newTodo(); 1494 mView->newTodo();
1489 else { 1495 else {
1490 mView->goToday(); 1496 mView->goToday();
1491 showSelectedDates = true; 1497 showSelectedDates = true;
1492 } 1498 }
1493 break; 1499 break;
1494 case Qt::Key_J: 1500 case Qt::Key_J:
1495 mView->viewManager()->showJournalView(); 1501 mView->viewManager()->showJournalView();
1496 break; 1502 break;
1497 case Qt::Key_B: 1503 case Qt::Key_B:
1498 mView->editIncidenceDescription();; 1504 mView->editIncidenceDescription();;
1499 break; 1505 break;
1500 // case Qt::Key_Return: 1506 // case Qt::Key_Return:
1501 case Qt::Key_E: 1507 case Qt::Key_E:
1502 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1508 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1503 mView->newEvent(); 1509 mView->newEvent();
1504 else 1510 else
1505 mView->editIncidence(); 1511 mView->editIncidence();
1506 break; 1512 break;
1507 case Qt::Key_Plus: 1513 case Qt::Key_Plus:
1508 size = p->mHourSize +2; 1514 size = p->mHourSize +2;
1509 if ( size <= 18 ) 1515 if ( size <= 18 )
1510 configureAgenda( size ); 1516 configureAgenda( size );
1511 break; 1517 break;
1512 case Qt::Key_Minus: 1518 case Qt::Key_Minus:
1513 size = p->mHourSize - 2; 1519 size = p->mHourSize - 2;
1514 if ( size >= 4 ) 1520 if ( size >= 4 )
1515 configureAgenda( size ); 1521 configureAgenda( size );
1516 break; 1522 break;
1517 1523
1518 1524
1519 default: 1525 default:
1520 e->ignore(); 1526 e->ignore();
1521 } 1527 }
1522 if ( pro > 0 ) { 1528 if ( pro > 0 ) {
1523 mView->selectFilter( pro-1 ); 1529 mView->selectFilter( pro-1 );
1524 } 1530 }
1525 if ( showSelectedDates ) { 1531 if ( showSelectedDates ) {
1526 ;// setCaptionToDates(); 1532 ;// setCaptionToDates();
1527 } 1533 }
1528 1534
1529} 1535}
1530 1536
1531void MainWindow::fillFilterMenu() 1537void MainWindow::fillFilterMenu()
1532{ 1538{
1533 selectFilterMenu->clear(); 1539 selectFilterMenu->clear();
1534 bool disable = false; 1540 bool disable = false;
1535 if ( mView->filterView()->filtersEnabled() ) { 1541 if ( mView->filterView()->filtersEnabled() ) {
1536 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 ); 1542 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 );
1537 } 1543 }
1538 else { 1544 else {
1539 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 ); 1545 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 );
1540 disable = true; 1546 disable = true;
1541 } 1547 }
1542 selectFilterMenu->insertSeparator(); 1548 selectFilterMenu->insertSeparator();
1543 QPtrList<CalFilter> fili = mView->filters(); 1549 QPtrList<CalFilter> fili = mView->filters();
1544 CalFilter *curfilter = mView->filterView()->selectedFilter(); 1550 CalFilter *curfilter = mView->filterView()->selectedFilter();
1545 CalFilter *filter = fili.first(); 1551 CalFilter *filter = fili.first();
1546 int iii = 1; 1552 int iii = 1;
1547 while(filter) { 1553 while(filter) {
1548 selectFilterMenu->insertItem( filter->name(), iii ); 1554 selectFilterMenu->insertItem( filter->name(), iii );
1549 if ( filter == curfilter) 1555 if ( filter == curfilter)
1550 selectFilterMenu->setItemChecked( iii, true ); 1556 selectFilterMenu->setItemChecked( iii, true );
1551 if ( disable ) 1557 if ( disable )
1552 selectFilterMenu->setItemEnabled( iii, false ); 1558 selectFilterMenu->setItemEnabled( iii, false );
1553 filter = fili.next(); 1559 filter = fili.next();
1554 ++iii; 1560 ++iii;
1555 } 1561 }
1556} 1562}
1557void MainWindow::selectFilter( int fil ) 1563void MainWindow::selectFilter( int fil )
1558{ 1564{
1559 if ( fil == 0 ) { 1565 if ( fil == 0 ) {
1560 mView->toggleFilerEnabled( ); 1566 mView->toggleFilerEnabled( );
1561 } else { 1567 } else {
1562 mView->selectFilter( fil-1 ); 1568 mView->selectFilter( fil-1 );
1563 } 1569 }
1564} 1570}
1565void MainWindow::configureToolBar( int item ) 1571void MainWindow::configureToolBar( int item )
1566{ 1572{
1567 1573
1568 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); 1574 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) );
1569 KOPrefs *p = KOPrefs::instance(); 1575 KOPrefs *p = KOPrefs::instance();
1570 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); 1576 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 );
1571 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); 1577 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 );
1572 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); 1578 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 );
1573 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); 1579 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 );
1574 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); 1580 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 );
1575 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); 1581 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 );
1576 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); 1582 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 );
1577 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); 1583 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 );
1578 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); 1584 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 );
1579 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); 1585 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 );
1580 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); 1586 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 );
1581 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); 1587 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 );
1582 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); 1588 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 );
1583 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); 1589 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 );
1584 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); 1590 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 );
1585 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); 1591 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 );
1586 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); 1592 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 );
1587 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); 1593 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 );
1588 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); 1594 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 );
1589 // initActions(); 1595 // initActions();
1590} 1596}
1591 1597
1592void MainWindow::setCaptionToDates() 1598void MainWindow::setCaptionToDates()
1593{ 1599{
1594 QString selDates; 1600 QString selDates;
1595 selDates = KGlobal::locale()->formatDate(mView->startDate(), true); 1601 selDates = KGlobal::locale()->formatDate(mView->startDate(), true);
1596 if (mView->startDate() < mView->endDate() ) 1602 if (mView->startDate() < mView->endDate() )
1597 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); 1603 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true);
1598 setCaption( i18n("Dates: ") + selDates ); 1604 setCaption( i18n("Dates: ") + selDates );
1599 1605
1600} 1606}
1601// parameter item == 0: reinit 1607// parameter item == 0: reinit
1602void MainWindow::configureAgenda( int item ) 1608void MainWindow::configureAgenda( int item )
1603{ 1609{
1604 1610
1605 KOPrefs *p = KOPrefs::instance(); 1611 KOPrefs *p = KOPrefs::instance();
1606 1612
1607 int i; 1613 int i;
1608 if ( item == 1 ) { 1614 if ( item == 1 ) {
1609 mView->toggleAllDaySize(); 1615 mView->toggleAllDaySize();
1610 return; 1616 return;
1611 } 1617 }
1612 // do not allow 4 for widgets higher than 480 1618 // do not allow 4 for widgets higher than 480
1613 // if ( QApplication::desktop()->height() > 480 ) { 1619 // if ( QApplication::desktop()->height() > 480 ) {
1614// if ( item == 4 ) 1620// if ( item == 4 )
1615// item = 6; 1621// item = 6;
1616// } 1622// }
1617 for ( i = 4; i <= 18; i= i+2 ) 1623 for ( i = 4; i <= 18; i= i+2 )
1618 configureAgendaMenu->setItemChecked( i, false ); 1624 configureAgendaMenu->setItemChecked( i, false );
1619 configureAgendaMenu->setItemChecked( item, true ); 1625 configureAgendaMenu->setItemChecked( item, true );
1620 if ( p->mHourSize == item ) 1626 if ( p->mHourSize == item )
1621 return; 1627 return;
1622 p->mHourSize=item; 1628 p->mHourSize=item;
1623 mView->viewManager()->agendaView()->updateConfig(); 1629 mView->viewManager()->agendaView()->updateConfig();
1624} 1630}
1625 1631
1626void MainWindow::saveCalendar() 1632void MainWindow::saveCalendar()
1627{ 1633{
1628 QString fn = KOPrefs::instance()->mLastSaveFile; 1634 QString fn = KOPrefs::instance()->mLastSaveFile;
1629 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); 1635 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this );
1630 1636
1631 if ( fn == "" ) 1637 if ( fn == "" )
1632 return; 1638 return;
1633 QFileInfo info; 1639 QFileInfo info;
1634 info.setFile( fn ); 1640 info.setFile( fn );
1635 QString mes; 1641 QString mes;
1636 bool createbup = true; 1642 bool createbup = true;
1637 if ( info. exists() ) { 1643 if ( info. exists() ) {
1638 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; 1644 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ;
1639 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1645 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1640 i18n("Overwrite!"), i18n("Cancel"), 0, 1646 i18n("Overwrite!"), i18n("Cancel"), 0,
1641 0, 1 ); 1647 0, 1 );
1642 if ( result != 0 ) { 1648 if ( result != 0 ) {
1643 createbup = false; 1649 createbup = false;
1644 } 1650 }
1645 } 1651 }
1646 if ( createbup ) { 1652 if ( createbup ) {
1647 mView->saveCalendar( fn ); 1653 mView->saveCalendar( fn );
1648 mes = i18n("KO/Pi:Saved %1").arg(fn); 1654 mes = i18n("KO/Pi:Saved %1").arg(fn);
1649 KOPrefs::instance()->mLastSaveFile = fn; 1655 KOPrefs::instance()->mLastSaveFile = fn;
1650 setCaption(mes); 1656 setCaption(mes);
1651 } 1657 }
1652} 1658}
1653void MainWindow::loadCalendar() 1659void MainWindow::loadCalendar()
1654{ 1660{
1655 1661
1656 QString fn = KOPrefs::instance()->mLastLoadFile; 1662 QString fn = KOPrefs::instance()->mLastLoadFile;
1657 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); 1663 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this );
1658 1664
1659 if ( fn == "" ) 1665 if ( fn == "" )
1660 return; 1666 return;
1661 QFileInfo info; 1667 QFileInfo info;
1662 info.setFile( fn ); 1668 info.setFile( fn );
1663 QString mess; 1669 QString mess;
1664 bool loadbup = true; 1670 bool loadbup = true;
1665 if ( info. exists() ) { 1671 if ( info. exists() ) {
1666 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1672 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1667 int result = QMessageBox::warning( this, "KO/Pi: Warning!", 1673 int result = QMessageBox::warning( this, "KO/Pi: Warning!",
1668 mess, 1674 mess,
1669 i18n("Load!"), i18n("Cancel"), 0, 1675 i18n("Load!"), i18n("Cancel"), 0,
1670 0, 1 ); 1676 0, 1 );
1671 if ( result != 0 ) { 1677 if ( result != 0 ) {
1672 loadbup = false; 1678 loadbup = false;
1673 } 1679 }
1674 } else { 1680 } else {
1675 QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1681 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1676 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, 1682 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0,
1677 0, 1 ); 1683 0, 1 );
1678 1684
1679 return; 1685 return;
1680 } 1686 }
1681 if ( loadbup ) { 1687 if ( loadbup ) {
1682 mView->openCalendar( fn ); 1688 mView->openCalendar( fn );
1683 KOPrefs::instance()->mLastLoadFile = fn; 1689 KOPrefs::instance()->mLastLoadFile = fn;
1684 mess = i18n("KO/Pi:Loaded %1").arg(fn) ; 1690 mess = i18n("KO/Pi:Loaded %1").arg(fn) ;
1685 setCaption(mess); 1691 setCaption(mess);
1686 } 1692 }
1687 1693
1688} 1694}
1689void MainWindow::quickImportIcal() 1695void MainWindow::quickImportIcal()
1690{ 1696{
1691 importFile( KOPrefs::instance()->mLastImportFile, false ); 1697 importFile( KOPrefs::instance()->mLastImportFile, false );
1692} 1698}
1693void MainWindow::importFile( QString fn, bool quick ) 1699void MainWindow::importFile( QString fn, bool quick )
1694{ 1700{
1695 QFileInfo info; 1701 QFileInfo info;
1696 info.setFile( fn ); 1702 info.setFile( fn );
1697 QString mess; 1703 QString mess;
1698 bool loadbup = true; 1704 bool loadbup = true;
1699 if ( !info. exists() ) { 1705 if ( !info. exists() ) {
1700 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); 1706 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30));
1701 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1707 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1702 mess ); 1708 mess );
1703 return; 1709 return;
1704 } 1710 }
1705 int result = 0; 1711 int result = 0;
1706 if ( !quick ) { 1712 if ( !quick ) {
1707 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 )); 1713 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 ));
1708 result = QMessageBox::warning( this, "KO/Pi: Warning!", 1714 result = QMessageBox::warning( this, "KO/Pi: Warning!",
1709 mess, 1715 mess,
1710 "Import", "Cancel", 0, 1716 "Import", "Cancel", 0,
1711 0, 1 ); 1717 0, 1 );
1712 } 1718 }
1713 if ( result == 0 ) { 1719 if ( result == 0 ) {
1714 if ( mView->openCalendar( fn, true )) { 1720 if ( mView->openCalendar( fn, true )) {
1715 KOPrefs::instance()->mLastImportFile = fn; 1721 KOPrefs::instance()->mLastImportFile = fn;
1716 setCaption(i18n("Imported file successfully")); 1722 setCaption(i18n("Imported file successfully"));
1717 } else { 1723 } else {
1718 setCaption(i18n("Error importing file")); 1724 setCaption(i18n("Error importing file"));
1719 } 1725 }
1720 } 1726 }
1721} 1727}
1722 1728
1723void MainWindow::importIcal() 1729void MainWindow::importIcal()
1724{ 1730{
1725 1731
1726 QString fn =KOPrefs::instance()->mLastImportFile; 1732 QString fn =KOPrefs::instance()->mLastImportFile;
1727 1733
1728 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); 1734 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this );
1729 if ( fn == "" ) 1735 if ( fn == "" )
1730 return; 1736 return;
1731 importFile( fn, true ); 1737 importFile( fn, true );
1732 1738
1733} 1739}
1734 1740
1735void MainWindow::exportVCalendar() 1741void MainWindow::exportVCalendar()
1736{ 1742{
1737 QString fn = KOPrefs::instance()->mLastVcalFile; 1743 QString fn = KOPrefs::instance()->mLastVcalFile;
1738 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); 1744 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this );
1739 if ( fn == "" ) 1745 if ( fn == "" )
1740 return; 1746 return;
1741 QFileInfo info; 1747 QFileInfo info;
1742 info.setFile( fn ); 1748 info.setFile( fn );
1743 QString mes; 1749 QString mes;
1744 bool createbup = true; 1750 bool createbup = true;
1745 if ( info. exists() ) { 1751 if ( info. exists() ) {
1746 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 1752 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
1747 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1753 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1748 i18n("Overwrite!"), i18n("Cancel"), 0, 1754 i18n("Overwrite!"), i18n("Cancel"), 0,
1749 0, 1 ); 1755 0, 1 );
1750 if ( result != 0 ) { 1756 if ( result != 0 ) {
1751 createbup = false; 1757 createbup = false;
1752 } 1758 }
1753 } 1759 }
1754 if ( createbup ) { 1760 if ( createbup ) {
1755 if ( mView->exportVCalendar( fn ) ) { 1761 if ( mView->exportVCalendar( fn ) ) {
1756 KOPrefs::instance()->mLastVcalFile = fn; 1762 KOPrefs::instance()->mLastVcalFile = fn;
1757 if ( fn.length() > 20 ) 1763 if ( fn.length() > 20 )
1758 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; 1764 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ;
1759 else 1765 else
1760 mes = i18n("KO/Pi:Exported to %1").arg(fn ); 1766 mes = i18n("KO/Pi:Exported to %1").arg(fn );
1761 setCaption(mes); 1767 setCaption(mes);
1762 } 1768 }
1763 } 1769 }
1764 1770
1765} 1771}
1766#include <qpushbutton.h> 1772#include <qpushbutton.h>
1767QString MainWindow::getPassword( ) 1773QString MainWindow::getPassword( )
1768{ 1774{
1769 QString retfile = ""; 1775 QString retfile = "";
1770 QDialog dia ( this, "input-dialog", true ); 1776 QDialog dia ( this, "input-dialog", true );
1771 QLineEdit lab ( &dia ); 1777 QLineEdit lab ( &dia );
1772 lab.setEchoMode( QLineEdit::Password ); 1778 lab.setEchoMode( QLineEdit::Password );
1773 QVBoxLayout lay( &dia ); 1779 QVBoxLayout lay( &dia );
1774 lay.setMargin(7); 1780 lay.setMargin(7);
1775 lay.setSpacing(7); 1781 lay.setSpacing(7);
1776 lay.addWidget( &lab); 1782 lay.addWidget( &lab);
1777 dia.setFixedSize( 230,50 ); 1783 dia.setFixedSize( 230,50 );
1778 dia.setCaption( i18n("Enter password") ); 1784 dia.setCaption( i18n("Enter password") );
1779 QPushButton pb ( "OK", &dia); 1785 QPushButton pb ( "OK", &dia);
1780 lay.addWidget( &pb ); 1786 lay.addWidget( &pb );
1781 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 1787 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
1782 dia.show(); 1788 dia.show();
1783 int res = dia.exec(); 1789 int res = dia.exec();
1784 if ( res ) 1790 if ( res )
1785 retfile = lab.text(); 1791 retfile = lab.text();
1786 dia.hide(); 1792 dia.hide();
1787 qApp->processEvents(); 1793 qApp->processEvents();
1788 return retfile; 1794 return retfile;
1789 1795
1790} 1796}
1791 1797
1792void MainWindow::syncLocalFile() 1798void MainWindow::syncLocalFile()
1793{ 1799{
1794 1800
1795 QString fn =KOPrefs::instance()->mLastSyncedLocalFile; 1801 QString fn =KOPrefs::instance()->mLastSyncedLocalFile;
1796 1802
1797 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); 1803 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this );
1798 if ( fn == "" ) 1804 if ( fn == "" )
1799 return; 1805 return;
1800 //mView->setSyncDevice("local-file" ); 1806 //mView->setSyncDevice("local-file" );
1801 if ( syncWithFile( fn, false ) ) { 1807 if ( syncWithFile( fn, false ) ) {
1802 // Event* e = mView->getLastSyncEvent(); 1808 // Event* e = mView->getLastSyncEvent();
1803// e->setReadOnly( false ); 1809// e->setReadOnly( false );
1804// e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); 1810// e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile);
1805// e->setReadOnly( true ); 1811// e->setReadOnly( true );
1806 } 1812 }
1807 1813
1808} 1814}
1809 1815
1810bool MainWindow::syncWithFile( QString fn , bool quick ) 1816bool MainWindow::syncWithFile( QString fn , bool quick )
1811{ 1817{
1812 bool ret = false; 1818 bool ret = false;
1813 QFileInfo info; 1819 QFileInfo info;
1814 info.setFile( fn ); 1820 info.setFile( fn );
1815 QString mess; 1821 QString mess;
1816 bool loadbup = true; 1822 bool loadbup = true;
1817 if ( !info. exists() ) { 1823 if ( !info. exists() ) {
1818 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 1824 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
1819 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1825 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1820 mess ); 1826 mess );
1821 return ret; 1827 return ret;
1822 } 1828 }
1823 int result = 0; 1829 int result = 0;
1824 if ( !quick ) { 1830 if ( !quick ) {
1825 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1831 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1826 result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1832 result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1827 mess, 1833 mess,
1828 i18n("Sync"), i18n("Cancel"), 0, 1834 i18n("Sync"), i18n("Cancel"), 0,
1829 0, 1 ); 1835 0, 1 );
1830 if ( result ) 1836 if ( result )
1831 return false; 1837 return false;
1832 } 1838 }
1833 if ( KOPrefs::instance()->mAskForPreferences ) 1839 if ( KOPrefs::instance()->mAskForPreferences )
1834 mView->edit_sync_options(); 1840 mView->edit_sync_options();
1835 if ( result == 0 ) { 1841 if ( result == 0 ) {
1836 //qDebug("Now sycing ... "); 1842 //qDebug("Now sycing ... ");
1837 if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) ) 1843 if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) )
1838 setCaption( i18n("Synchronization successful") ); 1844 setCaption( i18n("Synchronization successful") );
1839 else 1845 else
1840 setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); 1846 setCaption( i18n("Sync cancelled or failed. Nothing synced.") );
1841 if ( ! quick ) 1847 if ( ! quick )
1842 KOPrefs::instance()->mLastSyncedLocalFile = fn; 1848 KOPrefs::instance()->mLastSyncedLocalFile = fn;
1843 slotModifiedChanged( true ); 1849 slotModifiedChanged( true );
1844 } 1850 }
1845 return ret; 1851 return ret;
1846} 1852}
1847void MainWindow::quickSyncLocalFile() 1853void MainWindow::quickSyncLocalFile()
1848{ 1854{
1849 //mView->setSyncDevice("local-file" ); 1855 //mView->setSyncDevice("local-file" );
1850 //qDebug("quickSyncLocalFile() "); 1856 //qDebug("quickSyncLocalFile() ");
1851 if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) { 1857 if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) {
1852 // Event* e = mView->getLastSyncEvent(); 1858 // Event* e = mView->getLastSyncEvent();
1853// e->setReadOnly( false ); 1859// e->setReadOnly( false );
1854// e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); 1860// e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile);
1855// e->setReadOnly( true ); 1861// e->setReadOnly( true );
1856 1862
1857 } 1863 }
1858} 1864}
1859 1865
1860void MainWindow::confSync() 1866void MainWindow::confSync()
1861{ 1867{
1862 mView->confSync(); 1868 mView->confSync();
1863 fillSyncMenu(); 1869 fillSyncMenu();
1864 //mView->writeSettings(); 1870 //mView->writeSettings();
1865 1871
1866 1872
1867} 1873}
1868void MainWindow::syncRemote( KSyncProfile* prof, bool ask) 1874void MainWindow::syncRemote( KSyncProfile* prof, bool ask)
1869{ 1875{
1870 QString question; 1876 QString question;
1871 if ( ask ) { 1877 if ( ask ) {
1872 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; 1878 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
1873 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 1879 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
1874 question, 1880 question,
1875 i18n("Yes"), i18n("No"), 1881 i18n("Yes"), i18n("No"),
1876 0, 0 ) != 0 ) 1882 0, 0 ) != 0 )
1877 return; 1883 return;
1878 } 1884 }
1879 QString command = prof->getPreSyncCommand(); 1885 QString command = prof->getPreSyncCommand();
1880 int fi; 1886 int fi;
1881 if ( (fi = command.find("$PWD$")) > 0 ) { 1887 if ( (fi = command.find("$PWD$")) > 0 ) {
1882 QString pwd = getPassword(); 1888 QString pwd = getPassword();
1883 command = command.left( fi )+ pwd + command.mid( fi+5 ); 1889 command = command.left( fi )+ pwd + command.mid( fi+5 );
1884 1890
1885 } 1891 }
1886 int maxlen = 30; 1892 int maxlen = 30;
1887 if ( QApplication::desktop()->width() > 320 ) 1893 if ( QApplication::desktop()->width() > 320 )
1888 maxlen += 25; 1894 maxlen += 25;
1889 setCaption ( i18n( "Copy remote file to local machine..." ) ); 1895 setCaption ( i18n( "Copy remote file to local machine..." ) );
1890 int fileSize = 0; 1896 int fileSize = 0;
1891 int result = system ( command ); 1897 int result = system ( command );
1892 // 0 : okay 1898 // 0 : okay
1893 // 256: no such file or dir 1899 // 256: no such file or dir
1894 // 1900 //
1895 qDebug("KO: Remote copy result(0 = okay): %d ",result ); 1901 qDebug("KO: Remote copy result(0 = okay): %d ",result );
1896 if ( result != 0 ) { 1902 if ( result != 0 ) {
1897 int len = maxlen; 1903 int len = maxlen;
1898 while ( len < command.length() ) { 1904 while ( len < command.length() ) {
1899 command.insert( len , "\n" ); 1905 command.insert( len , "\n" );
1900 len += maxlen +2; 1906 len += maxlen +2;
1901 } 1907 }
1902 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; 1908 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ;
1903 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), 1909 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
1904 question, 1910 question,
1905 i18n("Okay!")) ; 1911 i18n("Okay!")) ;
1906 setCaption ("KO/Pi"); 1912 setCaption ("KO/Pi");
1907 return; 1913 return;
1908 } 1914 }
1909 setCaption ( i18n( "Copying succeed." ) ); 1915 setCaption ( i18n( "Copying succeed." ) );
1910 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); 1916 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
1911 if ( syncWithFile( prof->getLocalTempFile(), true ) ) { 1917 if ( syncWithFile( prof->getLocalTempFile(), true ) ) {
1912// Event* e = mView->getLastSyncEvent(); 1918// Event* e = mView->getLastSyncEvent();
1913// e->setReadOnly( false ); 1919// e->setReadOnly( false );
1914// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 1920// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
1915// e->setReadOnly( true ); 1921// e->setReadOnly( true );
1916 if ( KOPrefs::instance()->mWriteBackFile ) { 1922 if ( KOPrefs::instance()->mWriteBackFile ) {
1917 command = prof->getPostSyncCommand(); 1923 command = prof->getPostSyncCommand();
1918 setCaption ( i18n( "Writing back file ..." ) ); 1924 setCaption ( i18n( "Writing back file ..." ) );
1919 result = system ( command ); 1925 result = system ( command );
1920 qDebug("KO: Writing back file result: %d ", result); 1926 qDebug("KO: Writing back file result: %d ", result);
1921 if ( result != 0 ) { 1927 if ( result != 0 ) {
1922 setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); 1928 setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
1923 return; 1929 return;
1924 } else { 1930 } else {
1925 setCaption ( i18n( "Syncronization sucessfully completed" ) ); 1931 setCaption ( i18n( "Syncronization sucessfully completed" ) );
1926 } 1932 }
1927 } 1933 }
1928 } 1934 }
1929 return; 1935 return;
1930} 1936}
1931void MainWindow::syncSSH() 1937void MainWindow::syncSSH()
1932{ 1938{
1933 // not used anymore 1939 // not used anymore
1934 QTime timer; 1940 QTime timer;
1935 timer.start(); 1941 timer.start();
1936 //qDebug("MainWindow::syncssh() "); 1942 //qDebug("MainWindow::syncssh() ");
1937 KOPrefs *p = KOPrefs::instance(); 1943 KOPrefs *p = KOPrefs::instance();
1938 QString localFile = p->mLocalTempFile; 1944 QString localFile = p->mLocalTempFile;
1939 QString remoteIP = p->mRemoteIP; 1945 QString remoteIP = p->mRemoteIP;
1940 QString remoteUser = p->mRemoteUser; 1946 QString remoteUser = p->mRemoteUser;
1941 QString remoteFile = p->mRemoteFile; 1947 QString remoteFile = p->mRemoteFile;
1942 if ( p->mUsePassWd && p->mRemotePassWd.length() > 0 ) 1948 if ( p->mUsePassWd && p->mRemotePassWd.length() > 0 )
1943 remoteUser += ":" + p->mRemotePassWd; 1949 remoteUser += ":" + p->mRemotePassWd;
1944 1950
1945 QString question = i18n("Do you really want\nto remote sync?\n \n") + 1951 QString question = i18n("Do you really want\nto remote sync?\n \n") +
1946 i18n("IP: " ) +remoteIP +"\n" + 1952 i18n("IP: " ) +remoteIP +"\n" +
1947 i18n("User: " ) + remoteUser +"\n" ; 1953 i18n("User: " ) + remoteUser +"\n" ;
1948 int maxlen = 30; 1954 int maxlen = 30;
1949 if ( QApplication::desktop()->width() > 320 ) 1955 if ( QApplication::desktop()->width() > 320 )
1950 maxlen += 25; 1956 maxlen += 25;
1951 if ( remoteFile.length() > maxlen ) 1957 if ( remoteFile.length() > maxlen )
1952 question += i18n("Remote file:\n..." ) + remoteFile.right(maxlen) +"\n"; 1958 question += i18n("Remote file:\n..." ) + remoteFile.right(maxlen) +"\n";
1953 else 1959 else
1954 question += i18n("Remote file:\n " ) + remoteFile +"\n"; 1960 question += i18n("Remote file:\n " ) + remoteFile +"\n";
1955 if ( localFile.length() > maxlen ) 1961 if ( localFile.length() > maxlen )
1956 question += i18n("Local temp file:\n..." ) + localFile.right(maxlen) +"\n"; 1962 question += i18n("Local temp file:\n..." ) + localFile.right(maxlen) +"\n";
1957 else 1963 else
1958 question += i18n("Local temp file:\n " ) + localFile +"\n"; 1964 question += i18n("Local temp file:\n " ) + localFile +"\n";
1959 1965
1960 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 1966 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
1961 question, 1967 question,
1962 i18n("Yes"), i18n("No"), 1968 i18n("Yes"), i18n("No"),
1963 0, 0 ) != 0 ) 1969 0, 0 ) != 0 )
1964 return; 1970 return;
1965 // if ( !p->mUsePassWd ) { 1971 // if ( !p->mUsePassWd ) {
1966 // QString pass = getPassword(); 1972 // QString pass = getPassword();
1967 // if ( pass.length() > 0 ) 1973 // if ( pass.length() > 0 )
1968 // remoteUser += ":" + pass; 1974 // remoteUser += ":" + pass;
1969 // } 1975 // }
1970 QString command = "scp " + remoteUser + "@" + remoteIP +":" + remoteFile +" " +localFile; 1976 QString command = "scp " + remoteUser + "@" + remoteIP +":" + remoteFile +" " +localFile;
1971 setCaption ( i18n( "Copy remote file to local machine..." ) ); 1977 setCaption ( i18n( "Copy remote file to local machine..." ) );
1972 int fileSize = 0; 1978 int fileSize = 0;
1973 int result = system ( command ); 1979 int result = system ( command );
1974 // 0 : okay 1980 // 0 : okay
1975 // 256: no such file or dir 1981 // 256: no such file or dir
1976 // 1982 //
1977 qDebug("KO: Remote copy result(0 = okay): %d ",result ); 1983 qDebug("KO: Remote copy result(0 = okay): %d ",result );
1978 if ( result != 0 ) { 1984 if ( result != 0 ) {
1979 int len = maxlen; 1985 int len = maxlen;
1980 while ( len < command.length() ) { 1986 while ( len < command.length() ) {
1981 command.insert( len , "\n" ); 1987 command.insert( len , "\n" );
1982 len += maxlen +2; 1988 len += maxlen +2;
1983 } 1989 }
1984 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; 1990 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ;
1985 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), 1991 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
1986 question, 1992 question,
1987 i18n("Okay!")) ; 1993 i18n("Okay!")) ;
1988 setCaption ("KO/Pi"); 1994 setCaption ("KO/Pi");
1989 return; 1995 return;
1990 } 1996 }
1991 1997
1992 1998
1993 setCaption ( i18n( "Copying succeed." ) ); 1999 setCaption ( i18n( "Copying succeed." ) );
1994 //mView->setSyncDevice("ssh-scp" ); 2000 //mView->setSyncDevice("ssh-scp" );
1995 if ( syncWithFile(localFile , true ) ) { 2001 if ( syncWithFile(localFile , true ) ) {
1996// Event* e = mView->getLastSyncEvent(); 2002// Event* e = mView->getLastSyncEvent();
1997// e->setReadOnly( false ); 2003// e->setReadOnly( false );
1998// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 2004// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
1999// e->setReadOnly( true ); 2005// e->setReadOnly( true );
2000 if ( KOPrefs::instance()->mWriteBackFile ) { 2006 if ( KOPrefs::instance()->mWriteBackFile ) {
2001 command = "scp " + localFile +" " +remoteUser + "@" + remoteIP +":" + remoteFile ; 2007 command = "scp " + localFile +" " +remoteUser + "@" + remoteIP +":" + remoteFile ;
2002 setCaption ( i18n( "Writing back file ..." ) ); 2008 setCaption ( i18n( "Writing back file ..." ) );
2003 result = system ( command ); 2009 result = system ( command );
2004 if ( result != 0 ) { 2010 if ( result != 0 ) {
2005 int len = maxlen; 2011 int len = maxlen;
2006 while ( len < command.length() ) { 2012 while ( len < command.length() ) {
2007 command.insert( len , "\n" ); 2013 command.insert( len , "\n" );
2008 len += maxlen +2; 2014 len += maxlen +2;
2009 } 2015 }
2010 question = i18n("Sorry, the copy back command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; 2016 question = i18n("Sorry, the copy back command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ;
2011 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), 2017 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
2012 question, 2018 question,
2013 i18n("Okay!")) ; 2019 i18n("Okay!")) ;
2014 setCaption ("KO/Pi"); 2020 setCaption ("KO/Pi");
2015 return; 2021 return;
2016 } else { 2022 } else {
2017 setCaption ( i18n( "Syncronization sucessfully completed" ) ); 2023 setCaption ( i18n( "Syncronization sucessfully completed" ) );
2018 } 2024 }
2019 } 2025 }
2020 } 2026 }
2021 return; 2027 return;
2022#if 0 2028#if 0
2023 system ("scp zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics /home/polo/Applications/korganizer/z_sync.ics"); 2029 system ("scp zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics /home/polo/Applications/korganizer/z_sync.ics");
2024 while ( timer.elapsed() < 5000 ) 2030 while ( timer.elapsed() < 5000 )
2025 qApp->processEvents(); 2031 qApp->processEvents();
2026 2032
2027 qDebug("MainWindow::merging) "); 2033 qDebug("MainWindow::merging) ");
2028 mView->syncCalendar( "/home/polo/Applications/korganizer/z_sync.ics", 0 ); 2034 mView->syncCalendar( "/home/polo/Applications/korganizer/z_sync.ics", 0 );
2029 while ( mBlockSaveFlag ) 2035 while ( mBlockSaveFlag )
2030 qApp->processEvents(); 2036 qApp->processEvents();
2031 save(); 2037 save();
2032 system ("scp /home/polo/Applications/korganizer/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics"); 2038 system ("scp /home/polo/Applications/korganizer/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics");
2033#endif 2039#endif
2034 2040
2035} 2041}
2036 2042
2037 2043
2038void MainWindow::syncSharp() 2044void MainWindow::syncSharp()
2039{ 2045{
2040 if ( mCalendarModifiedFlag ) 2046 if ( mCalendarModifiedFlag )
2041 save(); 2047 save();
2042 mView->syncSharp(); 2048 mView->syncSharp();
2043 slotModifiedChanged( true ); 2049 slotModifiedChanged( true );
2044 2050
2045} 2051}
2046void MainWindow::syncPhone() 2052void MainWindow::syncPhone()
2047{ 2053{
2048 if ( mCalendarModifiedFlag ) 2054 if ( mCalendarModifiedFlag )
2049 save(); 2055 save();
2050 mView->syncPhone(); 2056 mView->syncPhone();
2051 slotModifiedChanged( true ); 2057 slotModifiedChanged( true );
2052 2058
2053} 2059}
2054 2060
2055void MainWindow::printSel( ) 2061void MainWindow::printSel( )
2056{ 2062{
2057 mView->viewManager()->agendaView()->agenda()->printSelection(); 2063 mView->viewManager()->agendaView()->agenda()->printSelection();
2058} 2064}
2059 2065
2060void MainWindow::printCal() 2066void MainWindow::printCal()
2061{ 2067{
2062 mView->print();//mCp->showDialog(); 2068 mView->print();//mCp->showDialog();
2063} 2069}
diff --git a/libkcal/libkcalE.pro b/libkcal/libkcalE.pro
index 283a22d..f5be980 100644
--- a/libkcal/libkcalE.pro
+++ b/libkcal/libkcalE.pro
@@ -1,87 +1,89 @@
1 TEMPLATE= lib 1 TEMPLATE= lib
2 CONFIG += qt warn_on 2 CONFIG += qt warn_on
3 TARGET = microkcal 3 TARGET = microkcal
4 4
5INCLUDEPATH += ../microkde ../qtcompat versit ../microkde/kdecore $(QPEDIR)/include 5INCLUDEPATH += ../microkde ../qtcompat versit ../microkde/kdecore $(QPEDIR)/include
6INCLUDEPATH += ../libical/src/libical 6INCLUDEPATH += ../libical/src/libical
7INCLUDEPATH += ../libical/src/libicalss 7INCLUDEPATH += ../libical/src/libicalss
8OBJECTS_DIR = obj/$(PLATFORM) 8OBJECTS_DIR = obj/$(PLATFORM)
9MOC_DIR = moc/$(PLATFORM) 9MOC_DIR = moc/$(PLATFORM)
10DESTDIR = $(QPEDIR)/lib 10DESTDIR = $(QPEDIR)/lib
11LIBS += ../libical/lib/$(PLATFORM)/libical.a 11LIBS += ../libical/lib/$(PLATFORM)/libical.a
12LIBS += ../libical/lib/$(PLATFORM)/libicalss.a 12LIBS += ../libical/lib/$(PLATFORM)/libicalss.a
13 13
14INTERFACES = \ 14INTERFACES = \
15 15
16HEADERS = \ 16HEADERS = \
17 alarm.h \ 17 alarm.h \
18 attachment.h \ 18 attachment.h \
19 attendee.h \ 19 attendee.h \
20 calendar.h \ 20 calendar.h \
21 calendarlocal.h \ 21 calendarlocal.h \
22 calfilter.h \ 22 calfilter.h \
23 calformat.h \ 23 calformat.h \
24 calstorage.h \ 24 calstorage.h \
25 compat.h \ 25 compat.h \
26 customproperties.h \ 26 customproperties.h \
27 dummyscheduler.h \ 27 dummyscheduler.h \
28 duration.h \ 28 duration.h \
29 event.h \ 29 event.h \
30 exceptions.h \ 30 exceptions.h \
31 filestorage.h \ 31 filestorage.h \
32 freebusy.h \ 32 freebusy.h \
33 icaldrag.h \ 33 icaldrag.h \
34 icalformat.h \ 34 icalformat.h \
35 icalformatimpl.h \ 35 icalformatimpl.h \
36 imipscheduler.h \ 36 imipscheduler.h \
37 incidence.h \ 37 incidence.h \
38 incidencebase.h \ 38 incidencebase.h \
39 journal.h \ 39 journal.h \
40 period.h \ 40 period.h \
41 person.h \ 41 person.h \
42 qtopiaformat.h \ 42 qtopiaformat.h \
43 sharpformat.h \ 43 sharpformat.h \
44 phoneformat.h \
44 recurrence.h \ 45 recurrence.h \
45 scheduler.h \ 46 scheduler.h \
46 todo.h \ 47 todo.h \
47 vcaldrag.h \ 48 vcaldrag.h \
48 vcalformat.h \ 49 vcalformat.h \
49 versit/port.h \ 50 versit/port.h \
50 versit/vcc.h \ 51 versit/vcc.h \
51 versit/vobject.h \ 52 versit/vobject.h \
52 53
53SOURCES = \ 54SOURCES = \
54 alarm.cpp \ 55 alarm.cpp \
55 attachment.cpp \ 56 attachment.cpp \
56 attendee.cpp \ 57 attendee.cpp \
57 calendar.cpp \ 58 calendar.cpp \
58 calendarlocal.cpp \ 59 calendarlocal.cpp \
59 calfilter.cpp \ 60 calfilter.cpp \
60 calformat.cpp \ 61 calformat.cpp \
61 compat.cpp \ 62 compat.cpp \
62 customproperties.cpp \ 63 customproperties.cpp \
63 dummyscheduler.cpp \ 64 dummyscheduler.cpp \
64 duration.cpp \ 65 duration.cpp \
65 event.cpp \ 66 event.cpp \
66 exceptions.cpp \ 67 exceptions.cpp \
67 filestorage.cpp \ 68 filestorage.cpp \
68 freebusy.cpp \ 69 freebusy.cpp \
69 icaldrag.cpp \ 70 icaldrag.cpp \
70 icalformat.cpp \ 71 icalformat.cpp \
71 icalformatimpl.cpp \ 72 icalformatimpl.cpp \
72 imipscheduler.cpp \ 73 imipscheduler.cpp \
73 incidence.cpp \ 74 incidence.cpp \
74 incidencebase.cpp \ 75 incidencebase.cpp \
75 journal.cpp \ 76 journal.cpp \
76 period.cpp \ 77 period.cpp \
77 person.cpp \ 78 person.cpp \
78 qtopiaformat.cpp \ 79 qtopiaformat.cpp \
79 sharpformat.cpp \ 80 sharpformat.cpp \
81 phoneformat.cpp \
80 recurrence.cpp \ 82 recurrence.cpp \
81 scheduler.cpp \ 83 scheduler.cpp \
82 todo.cpp \ 84 todo.cpp \
83 vcaldrag.cpp \ 85 vcaldrag.cpp \
84 vcalformat.cpp \ 86 vcalformat.cpp \
85 versit/vcc.c \ 87 versit/vcc.c \
86 versit/vobject.c \ 88 versit/vobject.c \
87 89
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp
new file mode 100644
index 0000000..f78730d
--- a/dev/null
+++ b/libkcal/phoneformat.cpp
@@ -0,0 +1,1359 @@
1/*
2 This file is part of libkcal.
3
4 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA.
20*/
21
22#include <qdatetime.h>
23#include <qstring.h>
24#include <qapplication.h>
25#include <qptrlist.h>
26#include <qregexp.h>
27#include <qmessagebox.h>
28#include <qclipboard.h>
29#include <qfile.h>
30#include <qtextstream.h>
31#include <qtextcodec.h>
32#include <qxml.h>
33#include <qlabel.h>
34
35#include <kdebug.h>
36#include <klocale.h>
37#include <kglobal.h>
38
39#include "calendar.h"
40#include "alarm.h"
41#include "recurrence.h"
42#include "calendarlocal.h"
43
44#include "phoneformat.h"
45
46using namespace KCal;
47
48//CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY
49// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
50
51//ARSD silentalarm = 0
52// 11 RTYP 225 no /0 dialy/ 1 weekly/ 3 month by date/ 2 month by day(pos)/ yearly
53// 12 RFRQ
54// 13 RPOS pos = 4. monday in month
55// 14 RDYS days: 1 mon/ 2 tue .. 64 sun
56// 15 REND 0 = no end/ 1 = end
57// 16 REDT rec end dt
58//ALSD
59//ALED
60//MDAY
61
62class SharpParser : public QObject
63{
64 public:
65 SharpParser( Calendar *calendar ) : mCalendar( calendar ) {
66 oldCategories = 0;
67 }
68
69 bool startElement( Calendar *existingCalendar, const QStringList & attList, QString qName )
70 {
71 int i = 1;
72 bool skip = true;
73 int max = attList.count() -2;
74 while ( i < max ) {
75 if ( !attList[i].isEmpty() ) {
76 skip = false;
77 break;
78 }
79 ++i ;
80 }
81 if ( skip )
82 return false;
83 ulong cSum = SharpFormat::getCsum(attList );
84
85 if ( qName == "Event" ) {
86 Event *event;
87 event = existingCalendar->event( attList[0].toInt() );
88 if ( event )
89 event = (Event*)event->clone();
90 else
91 event = new Event;
92 event->setZaurusId( attList[0].toInt() );
93 event->setZaurusUid( cSum );
94 event->setZaurusStat( -2 );
95
96 event->setSummary( attList[2] );
97 event->setLocation( attList[3] );
98 event->setDescription( attList[4] );
99 if ( attList[7] == "1" ) {
100 event->setDtStart( QDateTime(fromString( attList[17]+"T000000", false ).date(),QTime(0,0,0 ) ));
101 event->setDtEnd( QDateTime(fromString( attList[18]+"T000000", false ).date(),QTime(0,0,0 )));
102 event->setFloats( true );
103 } else {
104 event->setFloats( false );
105 event->setDtStart( fromString( attList[5] ) );
106 event->setDtEnd( fromString( attList[6] ));
107 }
108
109 QString rtype = attList[11];
110 if ( rtype != "255" ) {
111 // qDebug("recurs ");
112 QDate startDate = event->dtStart().date();
113
114 QString freqStr = attList[12];
115 int freq = freqStr.toInt();
116
117 QString hasEndDateStr = attList[15] ;
118 bool hasEndDate = hasEndDateStr == "1";
119
120 QString endDateStr = attList[16];
121 QDate endDate = fromString( endDateStr ).date();
122
123 QString weekDaysStr = attList[14];
124 uint weekDaysNum = weekDaysStr.toInt();
125
126 QBitArray weekDays( 7 );
127 int i;
128 int bb = 1;
129 for( i = 1; i <= 7; ++i ) {
130 weekDays.setBit( i - 1, ( bb & weekDaysNum ));
131 bb = 2 << (i-1);
132 //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) );
133 }
134 // qDebug("next ");
135 QString posStr = attList[13];
136 int pos = posStr.toInt();
137 Recurrence *r = event->recurrence();
138
139 if ( rtype == "0" ) {
140 if ( hasEndDate ) r->setDaily( freq, endDate );
141 else r->setDaily( freq, -1 );
142 } else if ( rtype == "1" ) {
143 if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate );
144 else r->setWeekly( freq, weekDays, -1 );
145 } else if ( rtype == "3" ) {
146 if ( hasEndDate )
147 r->setMonthly( Recurrence::rMonthlyDay, freq, endDate );
148 else
149 r->setMonthly( Recurrence::rMonthlyDay, freq, -1 );
150 r->addMonthlyDay( startDate.day() );
151 } else if ( rtype == "2" ) {
152 if ( hasEndDate )
153 r->setMonthly( Recurrence::rMonthlyPos, freq, endDate );
154 else
155 r->setMonthly( Recurrence::rMonthlyPos, freq, -1 );
156 QBitArray days( 7 );
157 days.fill( false );
158 days.setBit( startDate.dayOfWeek() - 1 );
159 r->addMonthlyPos( pos, days );
160 } else if ( rtype == "4" ) {
161 if ( hasEndDate )
162 r->setYearly( Recurrence::rYearlyMonth, freq, endDate );
163 else
164 r->setYearly( Recurrence::rYearlyMonth, freq, -1 );
165 r->addYearlyNum( startDate.month() );
166 }
167 }
168
169 QString categoryList = attList[1] ;
170 event->setCategories( lookupCategories( categoryList ) );
171
172 // strange 0 semms to mean: alarm enabled
173 if ( attList[8] == "0" ) {
174 Alarm *alarm;
175 if ( event->alarms().count() > 0 )
176 alarm = event->alarms().first();
177 else {
178 alarm = new Alarm( event );
179 event->addAlarm( alarm );
180 }
181 alarm->setType( Alarm::Audio );
182 alarm->setEnabled( true );
183 int alarmOffset = attList[9].toInt();
184 alarm->setStartOffset( alarmOffset * -60 );
185 }
186
187 mCalendar->addEvent( event);
188 } else if ( qName == "Todo" ) {
189 Todo *todo;
190
191 todo = existingCalendar->todo( attList[0].toInt() );
192 if (todo )
193 todo = (Todo*)todo->clone();
194 else
195 todo = new Todo;
196
197//CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1
198// 0 1 2 3 4 5 6 7 8
199//1,,,,,1,4,Loch zumachen,""
200//3,Privat,20040317T000000,20040318T000000,20040319T000000,0,5,Call bbb,"notes123 bbb gggg ""bb "" "
201//2,"Familie,Freunde,Holiday",20040318T000000,20040324T000000,20040317T000000,1,2,tod2,notes
202
203 todo->setZaurusId( attList[0].toInt() );
204 todo->setZaurusUid( cSum );
205 todo->setZaurusStat( -2 );
206
207 todo->setSummary( attList[7] );
208 todo->setDescription( attList[8]);
209
210 int priority = attList[6].toInt();
211 if ( priority == 0 ) priority = 3;
212 todo->setPriority( priority );
213
214 QString categoryList = attList[1];
215 todo->setCategories( lookupCategories( categoryList ) );
216
217
218
219 QString hasDateStr = attList[3]; // due
220 if ( !hasDateStr.isEmpty() ) {
221 if ( hasDateStr.right(6) == "000000" ) {
222 todo->setDtDue( QDateTime(fromString( hasDateStr, false ).date(), QTime(0,0,0 )) );
223 todo->setFloats( true );
224 }
225 else {
226 todo->setDtDue( fromString( hasDateStr ) );
227 todo->setFloats( false );
228 }
229
230 todo->setHasDueDate( true );
231 }
232 hasDateStr = attList[2];//start
233 if ( !hasDateStr.isEmpty() ) {
234
235 todo->setDtStart( fromString( hasDateStr ) );
236 todo->setHasStartDate( true);
237 } else
238 todo->setHasStartDate( false );
239 hasDateStr = attList[4];//completed
240 if ( !hasDateStr.isEmpty() ) {
241 todo->setCompleted(fromString( hasDateStr ) );
242 }
243 QString completedStr = attList[5];
244 if ( completedStr == "0" )
245 todo->setCompleted( true );
246 else
247 todo->setCompleted( false );
248 mCalendar->addTodo( todo );
249
250 } else if ( qName == "Category" ) {
251 /*
252 QString id = attributes.value( "id" );
253 QString name = attributes.value( "name" );
254 setCategory( id, name );
255 */
256 }
257 //qDebug("end ");
258 return true;
259 }
260
261
262 void setCategoriesList ( QStringList * c )
263 {
264 oldCategories = c;
265 }
266
267 QDateTime fromString ( QString s, bool useTz = true ) {
268 QDateTime dt;
269 int y,m,t,h,min,sec;
270 y = s.mid(0,4).toInt();
271 m = s.mid(4,2).toInt();
272 t = s.mid(6,2).toInt();
273 h = s.mid(9,2).toInt();
274 min = s.mid(11,2).toInt();
275 sec = s.mid(13,2).toInt();
276 dt = QDateTime(QDate(y,m,t), QTime(h,min,sec));
277 int offset = KGlobal::locale()->localTimeOffset( dt );
278 if ( useTz )
279 dt = dt.addSecs ( offset*60);
280 return dt;
281
282 }
283 protected:
284 QDateTime toDateTime( const QString &value )
285 {
286 QDateTime dt;
287 dt.setTime_t( value.toUInt() );
288
289 return dt;
290 }
291
292 QStringList lookupCategories( const QString &categoryList )
293 {
294 QStringList categoryIds = QStringList::split( ";", categoryList );
295 QStringList categories;
296 QStringList::ConstIterator it;
297 for( it = categoryIds.begin(); it != categoryIds.end(); ++it ) {
298 QString cate = category( *it );
299 if ( oldCategories ) {
300 if ( ! oldCategories->contains( cate ) )
301 oldCategories->append( cate );
302 }
303 categories.append(cate );
304 }
305 return categories;
306 }
307
308 private:
309 Calendar *mCalendar;
310 QStringList * oldCategories;
311 static QString category( const QString &id )
312 {
313 QMap<QString,QString>::ConstIterator it = mCategoriesMap.find( id );
314 if ( it == mCategoriesMap.end() ) return id;
315 else return *it;
316 }
317
318 static void setCategory( const QString &id, const QString &name )
319 {
320 mCategoriesMap.insert( id, name );
321 }
322
323 static QMap<QString,QString> mCategoriesMap;
324};
325
326QMap<QString,QString> SharpParser::mCategoriesMap;
327
328SharpFormat::SharpFormat()
329{
330 mCategories = 0;
331}
332
333SharpFormat::~SharpFormat()
334{
335}
336ulong SharpFormat::getCsum( const QStringList & attList)
337{
338 int max = attList.count() -1;
339 ulong cSum = 0;
340 int j,k,i;
341 int add;
342 for ( i = 1; i < max ; ++i ) {
343 QString s = attList[i];
344 if ( ! s.isEmpty() ){
345 j = s.length();
346 for ( k = 0; k < j; ++k ) {
347 int mul = k +1;
348 add = s[k].unicode ();
349 if ( k < 16 )
350 mul = mul * mul;
351 add = add * mul *i*i*i;
352 cSum += add;
353 }
354 }
355 }
356 return cSum;
357
358}
359//extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum);
360#include <stdlib.h>
361#define DEBUGMODE false
362bool SharpFormat::load( Calendar *calendar, Calendar *existngCal )
363{
364
365 GSM_StateMachines;
366 qDebug(" load ");
367 s.opened = false;
368 s.msg = NULL;
369 s.ConfigNum = 0;
370 static char*cp;
371 static INI_Section *cfg = NULL;
372 cfg=GSM_FindGammuRC();
373 int i;
374 for (i = 0; i <= MAX_CONFIG_NUM; i++) {
375 if (cfg!=NULL) {
376 cp = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*)"gammucoding", false);
377 if (cp) di.coding = cp;
378
379 s.Config[i].Localize = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*) "gammuloc", false);
380 if (s.Config[i].Localize) {
381 s.msg=INI_ReadFile(s.Config[i].Localize, true);
382 } else {
383#if !defined(WIN32) && defined(LOCALE_PATH)
384 locale = setlocale(LC_MESSAGES, NULL);
385 if (locale != NULL) {
386 snprintf(locale_file, 200, "%s/gammu_%c%c.txt",
387 LOCALE_PATH,
388 tolower(locale[0]),
389 tolower(locale[1]));
390 s.msg = INI_ReadFile(locale_file, true);
391 }
392#endif
393 }
394 }
395
396 /* Wanted user specific configuration? */
397
398 if (!GSM_ReadConfig(cfg, &s.Config[i], i) && i != 0) break;
399
400 s.ConfigNum++;
401
402 /* We want to use only one file descriptor for global and state machine debug output */
403 s.Config[i].UseGlobalDebugFile = true;
404
405
406
407 /* We wanted to read just user specified configuration. */
408 {break;}
409 }
410
411
412
413
414 int error=GSM_InitConnection(&s,3);
415
416
417 qDebug(" init %d %d", error, ERR_NONE);
418 if ( error != ERR_NONE )
419 return false;
420 fromString2Cal( calendar, existngCal, &s, "Event" );
421
422
423 error=GSM_TerminateConnection(&s);
424
425
426#if 0
427
428 bool debug = DEBUGMODE;
429 //debug = true;
430 QString text;
431 QString codec = "utf8";
432 QLabel status ( i18n("Reading events ..."), 0 );
433
434 int w = status.sizeHint().width()+20 ;
435 if ( w < 200 ) w = 200;
436 int h = status.sizeHint().height()+20 ;
437 int dw = QApplication::desktop()->width();
438 int dh = QApplication::desktop()->height();
439 status.setCaption(i18n("Reading DTM Data") );
440 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
441 status.show();
442 status.raise();
443 qApp->processEvents();
444 QString fileName;
445 if ( ! debug ) {
446 fileName = "/tmp/kopitempout";
447 QString command ="db2file datebook -r -c "+ codec + " > " + fileName;
448 system ( command.latin1() );
449 } else {
450 fileName = "/tmp/events.txt";
451
452 }
453 QFile file( fileName );
454 if (!file.open( IO_ReadOnly ) ) {
455 return false;
456
457 }
458 QTextStream ts( &file );
459 ts.setCodec( QTextCodec::codecForName("utf8") );
460 text = ts.read();
461 file.close();
462 status.setText( i18n("Processing events ...") );
463 status.raise();
464 qApp->processEvents();
465 fromString2Cal( calendar, existngCal, text, "Event" );
466 status.setText( i18n("Reading todos ...") );
467 qApp->processEvents();
468 if ( ! debug ) {
469 fileName = "/tmp/kopitempout";
470 QString command = "db2file todo -r -c " + codec+ " > " + fileName;
471 system ( command.latin1() );
472 } else {
473 fileName = "/tmp/todo.txt";
474 }
475 file.setName( fileName );
476 if (!file.open( IO_ReadOnly ) ) {
477 return false;
478
479 }
480 ts.setDevice( &file );
481 text = ts.read();
482 file.close();
483
484 status.setText( i18n("Processing todos ...") );
485 status.raise();
486 qApp->processEvents();
487 fromString2Cal( calendar, existngCal, text, "Todo" );
488#endif
489 return true;
490}
491int SharpFormat::getNumFromRecord( QString answer, Incidence* inc )
492{
493 int retval = -1;
494 QStringList templist;
495 QString tempString;
496 int start = 0;
497 int len = answer.length();
498 int end = answer.find ("\n",start)+1;
499 bool ok = true;
500 start = end;
501 int ccc = 0;
502 while ( start > 0 ) {
503 templist.clear();
504 ok = true;
505 int loopCount = 0;
506 while ( ok ) {
507 ++loopCount;
508 if ( loopCount > 25 ) {
509 qDebug("KO: Error in while loop");
510 ok = false;
511 start = 0;
512 break;
513 }
514 if ( ok )
515 tempString = getPart( answer, ok, start );
516 if ( start >= len || start == 0 ) {
517 start = 0;
518 ok = false;
519 }
520 if ( tempString.right(1) =="\n" )
521 tempString = tempString.left( tempString.length()-1);
522
523 templist.append( tempString );
524 }
525 ++ccc;
526 if ( ccc == 2 && loopCount < 25 ) {
527 start = 0;
528 bool ok;
529 int newnum = templist[0].toInt( &ok );
530 if ( ok && newnum > 0) {
531 retval = newnum;
532 inc->setZaurusId( newnum );
533 inc->setZaurusUid( getCsum( templist ) );
534 inc->setZaurusStat( -4 );
535 }
536 }
537 }
538 //qDebug("getNumFromRecord returning : %d ", retval);
539 return retval;
540}
541bool SharpFormat::save( Calendar *calendar)
542{
543
544 QLabel status ( i18n("Processing/adding events ..."), 0 );
545 int w = status.sizeHint().width()+20 ;
546 if ( w < 200 ) w = 200;
547 int h = status.sizeHint().height()+20 ;
548 int dw = QApplication::desktop()->width();
549 int dh = QApplication::desktop()->height();
550 status.setCaption(i18n("Writing DTM Data") );
551 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
552 status.show();
553 status.raise();
554 qApp->processEvents();
555 bool debug = DEBUGMODE;
556 QString codec = "utf8";
557 QString answer;
558 QString ePrefix = "CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY\n";
559 QString tPrefix = "CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1\n";
560 QString command;
561 QPtrList<Event> er = calendar->rawEvents();
562 Event* ev = er.first();
563 QString fileName = "/tmp/kopitempout";
564 int i = 0;
565 QString changeString = ePrefix;
566 QString deleteString = ePrefix;
567 bool deleteEnt = false;
568 bool changeEnt = false;
569 QString message = i18n("Processing event # ");
570 int procCount = 0;
571 while ( ev ) {
572 //qDebug("i %d ", ++i);
573 if ( ev->zaurusStat() != -2 ) {
574 status.setText ( message + QString::number ( ++procCount ) );
575 qApp->processEvents();
576 QString eString = getEventString( ev );
577 if ( ev->zaurusStat() == -3 ) { // delete
578 // deleting empty strings does not work.
579 // we write first and x and then delete the record with the x
580 eString = eString.replace( QRegExp(",\"\""),",\"x\"" );
581 changeString += eString + "\n";
582 deleteString += eString + "\n";
583 deleteEnt = true;
584 changeEnt = true;
585 }
586 else if ( ev->zaurusId() == -1 ) { // add new
587 command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName;
588 system ( command.utf8() );
589 QFile file( fileName );
590 if (!file.open( IO_ReadOnly ) ) {
591 return false;
592
593 }
594 QTextStream ts( &file );
595 ts.setCodec( QTextCodec::codecForName("utf8") );
596 answer = ts.read();
597 file.close();
598 //qDebug("answer \n%s ", answer.latin1());
599 getNumFromRecord( answer, ev ) ;
600
601 }
602 else { // change existing
603 //qDebug("canging %d %d",ev->zaurusStat() ,ev->zaurusId() );
604 //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName;
605 changeString += eString + "\n";
606 changeEnt = true;
607
608 }
609 }
610 ev = er.next();
611 }
612 status.setText ( i18n("Changing events ...") );
613 qApp->processEvents();
614 //qDebug("changing... ");
615 if ( changeEnt ) {
616 QFile file( fileName );
617 if (!file.open( IO_WriteOnly ) ) {
618 return false;
619
620 }
621 QTextStream ts( &file );
622 ts.setCodec( QTextCodec::codecForName("utf8") );
623 ts << changeString ;
624 file.close();
625 command = "db2file datebook -w -g -c " + codec+ " < "+ fileName;
626 system ( command.latin1() );
627 //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1());
628
629 }
630 status.setText ( i18n("Deleting events ...") );
631 qApp->processEvents();
632 //qDebug("deleting... ");
633 if ( deleteEnt ) {
634 QFile file( fileName );
635 if (!file.open( IO_WriteOnly ) ) {
636 return false;
637
638 }
639 QTextStream ts( &file );
640 ts.setCodec( QTextCodec::codecForName("utf8") );
641 ts << deleteString;
642 file.close();
643 command = "db2file datebook -d -c " + codec+ " < "+ fileName;
644 system ( command.latin1() );
645 // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1());
646 }
647
648
649 changeString = tPrefix;
650 deleteString = tPrefix;
651 status.setText ( i18n("Processing todos ...") );
652 qApp->processEvents();
653 QPtrList<Todo> tl = calendar->rawTodos();
654 Todo* to = tl.first();
655 i = 0;
656 message = i18n("Processing todo # ");
657 procCount = 0;
658 while ( to ) {
659 if ( to->zaurusStat() != -2 ) {
660 status.setText ( message + QString::number ( ++procCount ) );
661 qApp->processEvents();
662 QString eString = getTodoString( to );
663 if ( to->zaurusStat() == -3 ) { // delete
664 // deleting empty strings does not work.
665 // we write first and x and then delete the record with the x
666 eString = eString.replace( QRegExp(",\"\""),",\"x\"" );
667 changeString += eString + "\n";
668 deleteString += eString + "\n";
669 deleteEnt = true;
670 changeEnt = true;
671 }
672 else if ( to->zaurusId() == -1 ) { // add new
673 command = "(echo \"" + tPrefix + eString + "\" ) | db2file todo -w -g -c " + codec+ " > "+ fileName;
674 system ( command.utf8() );
675 QFile file( fileName );
676 if (!file.open( IO_ReadOnly ) ) {
677 return false;
678
679 }
680 QTextStream ts( &file );
681 ts.setCodec( QTextCodec::codecForName("utf8") );
682 answer = ts.read();
683 file.close();
684 //qDebug("answer \n%s ", answer.latin1());
685 getNumFromRecord( answer, to ) ;
686
687 }
688 else { // change existing
689 //qDebug("canging %d %d",to->zaurusStat() ,to->zaurusId() );
690 //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName;
691 changeString += eString + "\n";
692 changeEnt = true;
693
694 }
695 }
696
697 to = tl.next();
698 }
699 status.setText ( i18n("Changing todos ...") );
700 qApp->processEvents();
701 //qDebug("changing... ");
702 if ( changeEnt ) {
703 QFile file( fileName );
704 if (!file.open( IO_WriteOnly ) ) {
705 return false;
706
707 }
708 QTextStream ts( &file );
709 ts.setCodec( QTextCodec::codecForName("utf8") );
710 ts << changeString ;
711 file.close();
712 command = "db2file todo -w -g -c " + codec+ " < "+ fileName;
713 system ( command.latin1() );
714 //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1());
715
716 }
717 status.setText ( i18n("Deleting todos ...") );
718 qApp->processEvents();
719 //qDebug("deleting... ");
720 if ( deleteEnt ) {
721 QFile file( fileName );
722 if (!file.open( IO_WriteOnly ) ) {
723 return false;
724
725 }
726 QTextStream ts( &file );
727 ts.setCodec( QTextCodec::codecForName("utf8") );
728 ts << deleteString;
729 file.close();
730 command = "db2file todo -d -c " + codec+ " < "+ fileName;
731 system ( command.latin1() );
732 // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1());
733 }
734
735 return true;
736}
737QString SharpFormat::dtToString( const QDateTime& dti, bool useTZ )
738{
739 QString datestr;
740 QString timestr;
741 int offset = KGlobal::locale()->localTimeOffset( dti );
742 QDateTime dt;
743 if (useTZ)
744 dt = dti.addSecs ( -(offset*60));
745 else
746 dt = dti;
747 if(dt.date().isValid()){
748 const QDate& date = dt.date();
749 datestr.sprintf("%04d%02d%02d",
750 date.year(), date.month(), date.day());
751 }
752 if(dt.time().isValid()){
753 const QTime& time = dt.time();
754 timestr.sprintf("T%02d%02d%02d",
755 time.hour(), time.minute(), time.second());
756 }
757 return datestr + timestr;
758}
759QString SharpFormat::getEventString( Event* event )
760{
761 QStringList list;
762 list.append( QString::number(event->zaurusId() ) );
763 list.append( event->categories().join(",") );
764 if ( !event->summary().isEmpty() )
765 list.append( event->summary() );
766 else
767 list.append("" );
768 if ( !event->location().isEmpty() )
769 list.append( event->location() );
770 else
771 list.append("" );
772 if ( !event->description().isEmpty() )
773 list.append( event->description() );
774 else
775 list.append( "" );
776 if ( event->doesFloat () ) {
777 list.append( dtToString( QDateTime(event->dtStart().date(), QTime(0,0,0)), false ));
778 list.append( dtToString( QDateTime(event->dtEnd().date(),QTime(23,59,59)), false )); //6
779 list.append( "1" );
780
781 }
782 else {
783 list.append( dtToString( event->dtStart()) );
784 list.append( dtToString( event->dtEnd()) ); //6
785 list.append( "0" );
786 }
787 bool noAlarm = true;
788 if ( event->alarms().count() > 0 ) {
789 Alarm * al = event->alarms().first();
790 if ( al->enabled() ) {
791 noAlarm = false;
792 list.append( "0" ); // yes, 0 == alarm
793 list.append( QString::number( al->startOffset().asSeconds()/(-60) ) );
794 if ( al->type() == Alarm::Audio )
795 list.append( "1" ); // type audio
796 else
797 list.append( "0" ); // type silent
798 }
799 }
800 if ( noAlarm ) {
801 list.append( "1" ); // yes, 1 == no alarm
802 list.append( "0" ); // no alarm offset
803 list.append( "1" ); // type
804 }
805 // next is: 11
806 // next is: 11-16 are recurrence
807 Recurrence* rec = event->recurrence();
808
809 bool writeEndDate = false;
810 switch ( rec->doesRecur() )
811 {
812 case Recurrence::rDaily: // 0
813 list.append( "0" );
814 list.append( QString::number( rec->frequency() ));//12
815 list.append( "0" );
816 list.append( "0" );
817 writeEndDate = true;
818 break;
819 case Recurrence::rWeekly:// 1
820 list.append( "1" );
821 list.append( QString::number( rec->frequency()) );//12
822 list.append( "0" );
823 {
824 int days = 0;
825 QBitArray weekDays = rec->days();
826 int i;
827 for( i = 1; i <= 7; ++i ) {
828 if ( weekDays[i-1] ) {
829 days += 1 << (i-1);
830 }
831 }
832 list.append( QString::number( days ) );
833 }
834 //pending weekdays
835 writeEndDate = true;
836
837 break;
838 case Recurrence::rMonthlyPos:// 2
839 list.append( "2" );
840 list.append( QString::number( rec->frequency()) );//12
841
842 writeEndDate = true;
843 {
844 int count = 1;
845 QPtrList<Recurrence::rMonthPos> rmp;
846 rmp = rec->monthPositions();
847 if ( rmp.first()->negative )
848 count = 5 - rmp.first()->rPos - 1;
849 else
850 count = rmp.first()->rPos - 1;
851 list.append( QString::number( count ) );
852
853 }
854
855 list.append( "0" );
856 break;
857 case Recurrence::rMonthlyDay:// 3
858 list.append( "3" );
859 list.append( QString::number( rec->frequency()) );//12
860 list.append( "0" );
861 list.append( "0" );
862 writeEndDate = true;
863 break;
864 case Recurrence::rYearlyMonth://4
865 list.append( "4" );
866 list.append( QString::number( rec->frequency()) );//12
867 list.append( "0" );
868 list.append( "0" );
869 writeEndDate = true;
870 break;
871
872 default:
873 list.append( "255" );
874 list.append( QString() );
875 list.append( "0" );
876 list.append( QString() );
877 list.append( "0" );
878 list.append( "20991231T000000" );
879 break;
880 }
881 if ( writeEndDate ) {
882
883 if ( rec->endDate().isValid() ) { // 15 + 16
884 list.append( "1" );
885 list.append( dtToString( rec->endDate()) );
886 } else {
887 list.append( "0" );
888 list.append( "20991231T000000" );
889 }
890
891 }
892 if ( event->doesFloat () ) {
893 list.append( dtToString( event->dtStart(), false ).left( 8 ));
894 list.append( dtToString( event->dtEnd(), false ).left( 8 )); //6
895
896 }
897 else {
898 list.append( QString() );
899 list.append( QString() );
900
901 }
902 if (event->dtStart().date() == event->dtEnd().date() )
903 list.append( "0" );
904 else
905 list.append( "1" );
906
907
908 for(QStringList::Iterator it=list.begin();
909 it!=list.end(); ++it){
910 QString& s = (*it);
911 s.replace(QRegExp("\""), "\"\"");
912 if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){
913 s.prepend('\"');
914 s.append('\"');
915 } else if(s.isEmpty() && !s.isNull()){
916 s = "\"\"";
917 }
918 }
919 return list.join(",");
920
921
922}
923QString SharpFormat::getTodoString( Todo* todo )
924{
925 QStringList list;
926 list.append( QString::number( todo->zaurusId() ) );
927 list.append( todo->categories().join(",") );
928
929 if ( todo->hasStartDate() ) {
930 list.append( dtToString( todo->dtStart()) );
931 } else
932 list.append( QString() );
933
934 if ( todo->hasDueDate() ) {
935 QTime tim;
936 if ( todo->doesFloat()) {
937 list.append( dtToString( QDateTime(todo->dtDue().date(),QTime( 0,0,0 )), false)) ;
938 } else {
939 list.append( dtToString(todo->dtDue() ) );
940 }
941 } else
942 list.append( QString() );
943
944 if ( todo->isCompleted() ) {
945 list.append( dtToString( todo->completed()) );
946 list.append( "0" ); // yes 0 == completed
947 } else {
948 list.append( dtToString( todo->completed()) );
949 list.append( "1" );
950 }
951 list.append( QString::number( todo->priority() ));
952 if( ! todo->summary().isEmpty() )
953 list.append( todo->summary() );
954 else
955 list.append( "" );
956 if (! todo->description().isEmpty() )
957 list.append( todo->description() );
958 else
959 list.append( "" );
960 for(QStringList::Iterator it=list.begin();
961 it!=list.end(); ++it){
962 QString& s = (*it);
963 s.replace(QRegExp("\""), "\"\"");
964 if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){
965 s.prepend('\"');
966 s.append('\"');
967 } else if(s.isEmpty() && !s.isNull()){
968 s = "\"\"";
969 }
970 }
971 return list.join(",");
972}
973QString SharpFormat::getPart( const QString & text, bool &ok, int &start )
974{
975 //qDebug("start %d ", start);
976
977 QString retval ="";
978 if ( text.at(start) == '"' ) {
979 if ( text.mid( start,2) == "\"\"" && !( text.mid( start+2,1) == "\"")) {
980 start = start +2;
981 if ( text.mid( start,1) == "," ) {
982 start += 1;
983 }
984 retval = "";
985 if ( text.mid( start,1) == "\n" ) {
986 start += 1;
987 ok = false;
988 }
989 return retval;
990 }
991 int hk = start+1;
992 hk = text.find ('"',hk);
993 while ( text.at(hk+1) == '"' )
994 hk = text.find ('"',hk+2);
995 retval = text.mid( start+1, hk-start-1);
996 start = hk+1;
997 retval.replace( QRegExp("\"\""), "\"");
998 if ( text.mid( start,1) == "," ) {
999 start += 1;
1000 }
1001 if ( text.mid( start,1) == "\n" ) {
1002 start += 1;
1003 ok = false;
1004 }
1005 //qDebug("retval***%s*** ",retval.latin1() );
1006 return retval;
1007
1008 } else {
1009 int nl = text.find ("\n",start);
1010 int kom = text.find (',',start);
1011 if ( kom < nl ) {
1012 // qDebug("kom < nl %d ", kom);
1013 retval = text.mid(start, kom-start);
1014 start = kom+1;
1015 return retval;
1016 } else {
1017 if ( nl == kom ) {
1018 // qDebug(" nl == kom ");
1019 start = 0;
1020 ok = false;
1021 return "0";
1022 }
1023 // qDebug(" nl < kom ", nl);
1024 retval = text.mid( start, nl-start);
1025 ok = false;
1026 start = nl+1;
1027 return retval;
1028 }
1029 }
1030}
1031bool SharpFormat::fromString( Calendar *calendar, const QString & text)
1032{
1033 return false;
1034}
1035 bool SharpFormat::fromString2Cal( Calendar *calendar,Calendar *existingCalendar, GSM_StateMachine*s, const QString & type)
1036{
1037 GSM_Phone_Functions*Phone;
1038
1039 GSM_CalendarEntrynote;
1040 GSM_CalendarEntry*Note;
1041 bool refresh= true;
1042
1043 Phone=s->Phone.Functions;
1044 bool gshutdown = false;
1045 SharpParser handler( calendar );
1046 //handler.setCategoriesList( mCategories );
1047 QStringList templist;
1048 QString tempString;
1049 int start = 0;
1050 int error;
1051 int ccc = 0;
1052 while (!gshutdown && ccc++ < 10 ) {
1053 QString CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY;
1054 templist.clear();
1055 qDebug("count %d ", ccc);
1056 error=Phone->GetNextCalendar(s,&note,refresh);
1057 if (error == ERR_EMPTY) break;
1058
1059 Note = &note;
1060//CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY
1061// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
1062
1063//ARSD silentalarm = 0
1064// 11 RTYP 225 no /0 dialy/ 1 weekly/ 3 month by date/ 2 month by day(pos)/ yearly
1065// 12 RFRQ
1066// 13 RPOS pos = 4. monday in month
1067// 14 RDYS days: 1 mon/ 2 tue .. 64 sun
1068// 15 REND 0 = no end/ 1 = end
1069// 16 REDT rec end dt
1070//ALSD
1071//ALED
1072//MDAY
1073
1074 CARDID = QString::number( Note->Location ); // 0
1075
1076
1077 int i_age = 0,i;
1078 GSM_DateTime Alarm,DateTime;
1079 GSM_DateTime* dtp;
1080 GSM_MemoryEntry entry;
1081 unsigned char *name;
1082
1083 bool repeating = false;
1084 int repeat_dayofweek = -1;
1085 int repeat_day = -1;
1086 int repeat_weekofmonth = -1;
1087 int repeat_month = -1;
1088 int repeat_frequency = -1;
1089 GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0};
1090 GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0};
1091
1092 Alarm.Year = 0;
1093
1094 repeating = false;
1095 repeat_dayofweek = -1;
1096 repeat_day = -1;
1097 repeat_weekofmonth = -1;
1098 repeat_month = -1;
1099 repeat_frequency = -1;
1100 repeat_startdate.Day= 0;
1101 repeat_stopdate.Day = 0;
1102
1103
1104 switch (Note->Type) {
1105 case GSM_CAL_REMINDER : CATEGORY = QString("Reminder"); break;
1106 case GSM_CAL_CALL : CATEGORY = QString("Call"); break;
1107 case GSM_CAL_MEETING : CATEGORY = QString("Meeting"); break;
1108 case GSM_CAL_BIRTHDAY : CATEGORY = QString("Birthday"); break;
1109 case GSM_CAL_MEMO : CATEGORY = QString("Memo"); break;
1110 case GSM_CAL_TRAVEL : CATEGORY = QString("Travel"); break;
1111 case GSM_CAL_VACATION : CATEGORY = QString("Vacation"); break;
1112 case GSM_CAL_ALARM : CATEGORY = QString("Alarm"); break;
1113 case GSM_CAL_DAILY_ALARM : CATEGORY = QString("Daily alarm"); break;
1114 case GSM_CAL_T_ATHL : CATEGORY = QString("Training/Athletism"); break;
1115 case GSM_CAL_T_BALL : CATEGORY = QString("Training/Ball Games"); break;
1116 case GSM_CAL_T_CYCL : CATEGORY = QString("Training/Cycling"); break;
1117 case GSM_CAL_T_BUDO : CATEGORY = QString("Training/Budo"); break;
1118 case GSM_CAL_T_DANC : CATEGORY = QString("Training/Dance"); break;
1119 case GSM_CAL_T_EXTR : CATEGORY = QString("Training/Extreme Sports"); break;
1120 case GSM_CAL_T_FOOT : CATEGORY = QString("Training/Football"); break;
1121 case GSM_CAL_T_GOLF : CATEGORY = QString("Training/Golf"); break;
1122 case GSM_CAL_T_GYM : CATEGORY = QString("Training/Gym"); break;
1123 case GSM_CAL_T_HORS : CATEGORY = QString("Training/Horse Races"); break;
1124 case GSM_CAL_T_HOCK : CATEGORY = QString("Training/Hockey"); break;
1125 case GSM_CAL_T_RACE : CATEGORY = QString("Training/Races"); break;
1126 case GSM_CAL_T_RUGB : CATEGORY = QString("Training/Rugby"); break;
1127 case GSM_CAL_T_SAIL : CATEGORY = QString("Training/Sailing"); break;
1128 case GSM_CAL_T_STRE : CATEGORY = QString("Training/Street Games"); break;
1129 case GSM_CAL_T_SWIM : CATEGORY = QString("Training/Swimming"); break;
1130 case GSM_CAL_T_TENN : CATEGORY = QString("Training/Tennis"); break;
1131 case GSM_CAL_T_TRAV : CATEGORY = QString("Training/Travels"); break;
1132 case GSM_CAL_T_WINT : CATEGORY = QString("Training/Winter Games"); break;
1133 default : CATEGORY = QString("");
1134 }
1135//CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY
1136// 0x 1x 2x 3x 4x 5x 6x 7x 8x 9x 10? 11 12 13 14 15 16 17x 18x 19?
1137
1138 MEM1 = "";
1139
1140#if 0
1141
1142 if ( attList[7] == "1" ) {
1143 event->setDtStart( QDateTime(fromString( attList[17]+"000000", false ).date(),QTime(0,0,0 ) ));
1144 event->setDtEnd( QDateTime(fromString( attList[18]+"000000", false ).date(),QTime(0,0,0 )));
1145 event->setFloats( true );
1146 } else {
1147 event->setFloats( false );
1148 event->setDtStart( fromString( attList[5] ) );
1149 event->setDtEnd( fromString( attList[6] ));
1150 }
1151
1152
1153
1154typedef struct {
1155 /**
1156 * The difference between local time and GMT in hours
1157 */
1158 int Timezone;
1159
1160 unsigned int Second;
1161 unsigned int Minute;
1162 unsigned int Hour;
1163
1164 unsigned int Day;
1165 /**
1166 * January = 1, February = 2, etc.
1167 */
1168 unsigned int Month;
1169 /**
1170 * Complete year number. Not 03, but 2003
1171 */
1172 unsigned int Year;
1173} GSM_DateTime;
1174
1175 if(dt.date().isValid()){
1176 const QDate& date = dt.date();
1177 datestr.sprintf("%04d%02d%02d",
1178 date.year(), date.month(), date.day());
1179 }
1180 if(dt.time().isValid()){
1181 const QTime& time = dt.time();
1182 timestr.sprintf("T%02d%02d%02d",
1183 time.hour(), time.minute(), time.second());
1184 }
1185 return datestr + timestr;
1186
1187
1188
1189
1190#endif
1191
1192
1193 ADAY = "0";
1194 ARON = "1"; // 1 == disabled
1195 ARMN = "0"; //alarm offset in minutes
1196
1197 for (i=0;i<Note->EntriesNum;i++) {
1198
1199 qDebug(" for ");
1200 switch (Note->Entries[i].EntryType) {
1201 case CAL_START_DATETIME:
1202 dtp = &Note->Entries[i].Date ;
1203
1204 qDebug("hour: %d ", dtp->Hour);
1205 if ( dtp->Hour == -1 ) {
1206 ADAY = "1";
1207 ALSD.sprintf("%04d%02d%02d",dtp->Year, dtp->Month, dtp->Day );
1208 TIM1.sprintf("%04d%02d%02dT000000",dtp->Year, dtp->Month, dtp->Day );
1209 } else {
1210 TIM1.sprintf("%04d%02d%02dT%02d%02d%02d",dtp->Year, dtp->Month, dtp->Day, dtp->Hour - dtp->Timezone, dtp->Minute, dtp->Second );
1211
1212 }
1213 ////printmsg("Start : %s\n",OSDateTime(Note->Entries[i].Date,false));
1214 //memcpy(&DateTime,&Note->Entries[i].Date,sizeof(GSM_DateTime));
1215 break;
1216 case CAL_END_DATETIME:
1217 dtp = &Note->Entries[i].Date ;
1218 qDebug("hour2: %d ", dtp->Hour);
1219 if ( dtp->Hour == -1 ) {
1220 ADAY = "1";
1221 ALED.sprintf("%04d%02d%02d",dtp->Year, dtp->Month, dtp->Day );
1222 TIM2.sprintf("%04d%02d%02dT000000",dtp->Year, dtp->Month, dtp->Day );
1223 } else {
1224 TIM2.sprintf("%04d%02d%02dT%02d%02d%02d",dtp->Year, dtp->Month, dtp->Day, dtp->Hour - dtp->Timezone, dtp->Minute, dtp->Second );
1225
1226 }
1227 //printmsg("Stop : %s\n",OSDateTime(Note->Entries[i].Date,false));
1228 //memcpy(&DateTime,&Note->Entries[i].Date,sizeof(GSM_DateTime));
1229 break;
1230 case CAL_ALARM_DATETIME:
1231 ARON = "0";
1232 dtp = &Note->Entries[i].Date ;
1233 ARMN.sprintf("%04d%02d%02dT%02d%02d%02d",dtp->Year, dtp->Month, dtp->Day, dtp->Hour - dtp->Timezone, dtp->Minute, dtp->Second );
1234 //printmsg("Tone alarm : %s\n",OSDateTime(Note->Entries[i].Date,false));
1235 memcpy(&Alarm,&Note->Entries[i].Date,sizeof(GSM_DateTime));
1236 break;
1237 case CAL_SILENT_ALARM_DATETIME:
1238 ARON = "0";
1239 dtp = &Note->Entries[i].Date ;
1240 ARMN.sprintf("%04d%02d%02dT%02d%02d%02d",dtp->Year, dtp->Month, dtp->Day, dtp->Hour - dtp->Timezone, dtp->Minute, dtp->Second );
1241 //printmsg("Silent alarm : %s\n",OSDateTime(Note->Entries[i].Date,false));
1242 //memcpy(&Alarm,&Note->Entries[i].Date,sizeof(GSM_DateTime));
1243 break;
1244 case CAL_RECURRANCE:
1245 //printmsg("Repeat : %d day%s\n",Note->Entries[i].Number/24,((Note->Entries[i].Number/24)>1) ? "s":"" );
1246 break;
1247 case CAL_TEXT:
1248 DSRP = QString ( (const char*) Note->Entries[i].Text );
1249 break;
1250 case CAL_LOCATION:
1251 PLCE = QString ((const char*) Note->Entries[i].Text );
1252 break;
1253 case CAL_PHONE:
1254 //printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text));
1255 break;
1256 case CAL_PRIVATE:
1257 //printmsg("Private : %s\n",Note->Entries[i].Number == 1 ? "Yes" : "No");
1258 break;
1259 case CAL_CONTACTID:
1260#if 0
1261 entry.Location = Note->Entries[i].Number;
1262 entry.MemoryType = MEM_ME;
1263 error=Phone->GetMemory(&s, &entry);
1264 if (error == ERR_NONE) {
1265 name = GSM_PhonebookGetEntryName(&entry);
1266 if (name != NULL) {
1267 //printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), Note->Entries[i].Number);
1268 } else {
1269 //printmsg("Contact ID : %d\n",Note->Entries[i].Number);
1270 }
1271 } else {
1272 //printmsg("Contact ID : %d\n",Note->Entries[i].Number);
1273 }
1274#endif
1275 break;
1276 case CAL_REPEAT_DAYOFWEEK:
1277 repeat_dayofweek = Note->Entries[i].Number;
1278 repeating = true;
1279 break;
1280 case CAL_REPEAT_DAY:
1281 repeat_day = Note->Entries[i].Number;
1282 repeating = true;
1283 break;
1284 case CAL_REPEAT_WEEKOFMONTH:
1285 repeat_weekofmonth = Note->Entries[i].Number;
1286 repeating = true;
1287 break;
1288 case CAL_REPEAT_MONTH:
1289 repeat_month = Note->Entries[i].Number;
1290 repeating = true;
1291 break;
1292 case CAL_REPEAT_FREQUENCY:
1293 repeat_frequency = Note->Entries[i].Number;
1294 repeating = true;
1295 break;
1296 case CAL_REPEAT_STARTDATE:
1297 repeat_startdate = Note->Entries[i].Date;
1298 repeating = true;
1299 break;
1300 case CAL_REPEAT_STOPDATE:
1301 repeat_stopdate = Note->Entries[i].Date;
1302 repeating = true;
1303 break;
1304 }
1305 }
1306
1307
1308
1309 if ( ARON == "0" ) {
1310 QDateTime start,alarm;
1311 start = handler.fromString( TIM1 );
1312 alarm = handler.fromString( ARMN );
1313 int min = alarm.secsTo ( start )/60;
1314 ARMN = QString::number ( min );
1315 }
1316
1317 templist.clear();
1318 templist << CARDID << CATEGORY << DSRP << PLCE << MEM1 << TIM1 << TIM2 << ADAY << ARON << ARMN << ARSD << RTYP << RFRQ << RPOS << RDYS << REND << REDT << ALSD << ALED << MDAY;
1319 handler.startElement( existingCalendar, templist, type );
1320 }
1321
1322
1323
1324#if 0
1325 // qDebug("test %s ", text.latin1());
1326 QStringList templist;
1327 QString tempString;
1328 int start = 0;
1329 int len = text.length();
1330 int end = text.find ("\n",start)+1;
1331 bool ok = true;
1332 start = end;
1333 SharpParser handler( calendar );
1334 handler.setCategoriesList( mCategories );
1335 while ( start > 0 ) {
1336 templist.clear();
1337 ok = true;
1338 while ( ok ) {
1339 tempString = getPart( text, ok, start );
1340 if ( start >= len || start == 0 ) {
1341 start = 0;
1342 ok = false;
1343 }
1344 if ( tempString.right(1) =="\n" )
1345 tempString = tempString.left( tempString.length()-1);
1346 //if ( ok )
1347 templist.append( tempString );
1348 //qDebug("%d ---%s---", templist.count(),tempString.latin1() );
1349 }
1350 handler.startElement( existingCalendar, templist, type );
1351 }
1352#endif
1353 return false;
1354}
1355
1356QString SharpFormat::toString( Calendar * )
1357{
1358 return QString::null;
1359}
diff --git a/libkcal/phoneformat.h b/libkcal/phoneformat.h
new file mode 100644
index 0000000..f4cb52c
--- a/dev/null
+++ b/libkcal/phoneformat.h
@@ -0,0 +1,65 @@
1/*
2 This file is part of libkcal.
3
4 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA.
20*/
21#ifndef SHARPFORMAT_H
22#define SHARPAFORMAT_H
23
24#include <qstring.h>
25
26#include "scheduler.h"
27
28#include "calformat.h"
29extern "C" {
30#include "gammu.h"
31}
32
33namespace KCal {
34
35/**
36 This class implements the calendar format used by Sharp.
37*/
38
39class SharpFormat : public QObject {
40 public:
41 /** Create new iCalendar format. */
42 SharpFormat();
43 virtual ~SharpFormat();
44
45 bool load( Calendar * ,Calendar *);
46 bool save( Calendar * );
47 void setCategoriesList ( QStringList * cat ){ mCategories = cat; }
48 bool fromString2Cal( Calendar *, Calendar *, GSM_StateMachine*s , const QString & );
49 bool fromString( Calendar *, const QString & );
50 QString toString( Calendar * );
51 static ulong getCsum( const QStringList & );
52
53 private:
54 QString getEventString( Event* );
55 QString getTodoString( Todo* );
56 QString dtToString( const QDateTime& dt, bool useTZ = true );
57
58 QStringList *mCategories;
59 int getNumFromRecord( QString answer,Incidence* inc ) ;
60 QString getPart( const QString & text, bool &ok, int &start );
61};
62
63}
64
65#endif