summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-09-22 06:39:51 (UTC)
committer zautrix <zautrix>2004-09-22 06:39:51 (UTC)
commitc640aaff31f298b4aff7a61cbdfa9c8a95269479 (patch) (unidiff)
tree3fe1c1d16c63d03e7b1faec540df30b7a8e5c506
parentbbeffa56ee51d30b84bcadaf22234b8227958f31 (diff)
downloadkdepimpi-c640aaff31f298b4aff7a61cbdfa9c8a95269479.zip
kdepimpi-c640aaff31f298b4aff7a61cbdfa9c8a95269479.tar.gz
kdepimpi-c640aaff31f298b4aff7a61cbdfa9c8a95269479.tar.bz2
modified file warning fix
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp17
-rw-r--r--korganizer/calendarview.h1
-rw-r--r--korganizer/mainwindow.cpp3
3 files changed, 18 insertions, 3 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 3635cfa..eaea040 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,3620 +1,3633 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Requires the Qt and KDE widget libraries, available at no cost at 4 Requires the Qt and KDE widget libraries, available at no cost at
5 http://www.troll.no and http://www.kde.org respectively 5 http://www.troll.no and http://www.kde.org respectively
6 6
7 Copyright (c) 1997, 1998, 1999 7 Copyright (c) 1997, 1998, 1999
8 Preston Brown (preston.brown@yale.edu) 8 Preston Brown (preston.brown@yale.edu)
9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) 9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl)
10 Ian Dawes (iadawes@globalserve.net) 10 Ian Dawes (iadawes@globalserve.net)
11 Laszlo Boloni (boloni@cs.purdue.edu) 11 Laszlo Boloni (boloni@cs.purdue.edu)
12 12
13 Copyright (c) 2000, 2001, 2002 13 Copyright (c) 2000, 2001, 2002
14 Cornelius Schumacher <schumacher@kde.org> 14 Cornelius Schumacher <schumacher@kde.org>
15 15
16 This program is free software; you can redistribute it and/or modify 16 This program is free software; you can redistribute it and/or modify
17 it under the terms of the GNU General Public License as published by 17 it under the terms of the GNU General Public License as published by
18 the Free Software Foundation; either version 2 of the License, or 18 the Free Software Foundation; either version 2 of the License, or
19 (at your option) any later version. 19 (at your option) any later version.
20 20
21 This program is distributed in the hope that it will be useful, 21 This program is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of 22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
24 GNU General Public License for more details. 24 GNU General Public License for more details.
25 25
26 You should have received a copy of the GNU General Public License 26 You should have received a copy of the GNU General Public License
27 along with this program; if not, write to the Free Software 27 along with this program; if not, write to the Free Software
28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29*/ 29*/
30 30
31#include <stdlib.h> 31#include <stdlib.h>
32 32
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qradiobutton.h> 34#include <qradiobutton.h>
35#include <qbuttongroup.h> 35#include <qbuttongroup.h>
36#include <qlayout.h> 36#include <qlayout.h>
37#include <qclipboard.h> 37#include <qclipboard.h>
38#include <qcursor.h> 38#include <qcursor.h>
39#include <qmessagebox.h> 39#include <qmessagebox.h>
40#include <qprogressbar.h> 40#include <qprogressbar.h>
41#include <qmultilineedit.h> 41#include <qmultilineedit.h>
42#include <qtimer.h> 42#include <qtimer.h>
43#include <qwidgetstack.h> 43#include <qwidgetstack.h>
44#include <qptrlist.h> 44#include <qptrlist.h>
45#include <qregexp.h> 45#include <qregexp.h>
46#include <qgroupbox.h> 46#include <qgroupbox.h>
47#include <qfile.h> 47#include <qfile.h>
48#include <qdir.h> 48#include <qdir.h>
49#ifndef KORG_NOSPLITTER 49#ifndef KORG_NOSPLITTER
50#include <qsplitter.h> 50#include <qsplitter.h>
51#endif 51#endif
52 52
53#include <kglobal.h> 53#include <kglobal.h>
54#include <kdebug.h> 54#include <kdebug.h>
55#include <kstandarddirs.h> 55#include <kstandarddirs.h>
56#include <kfiledialog.h> 56#include <kfiledialog.h>
57#include <kmessagebox.h> 57#include <kmessagebox.h>
58#include <knotifyclient.h> 58#include <knotifyclient.h>
59#include <kconfig.h> 59#include <kconfig.h>
60 60
61#include <libkdepim/ksyncprefsdialog.h> 61#include <libkdepim/ksyncprefsdialog.h>
62#include <krun.h> 62#include <krun.h>
63#include <kdirwatch.h> 63#include <kdirwatch.h>
64#include <libkdepim/kdatepicker.h> 64#include <libkdepim/kdatepicker.h>
65#include <libkdepim/ksyncprofile.h> 65#include <libkdepim/ksyncprofile.h>
66#include <libkdepim/kpimglobalprefs.h> 66#include <libkdepim/kpimglobalprefs.h>
67 67
68#include <libkcal/vcaldrag.h> 68#include <libkcal/vcaldrag.h>
69#include <libkcal/icaldrag.h> 69#include <libkcal/icaldrag.h>
70#include <libkcal/icalformat.h> 70#include <libkcal/icalformat.h>
71#include <libkcal/vcalformat.h> 71#include <libkcal/vcalformat.h>
72#include <libkcal/scheduler.h> 72#include <libkcal/scheduler.h>
73#include <libkcal/calendarlocal.h> 73#include <libkcal/calendarlocal.h>
74#include <libkcal/journal.h> 74#include <libkcal/journal.h>
75#include <libkcal/calfilter.h> 75#include <libkcal/calfilter.h>
76#include <libkcal/attendee.h> 76#include <libkcal/attendee.h>
77#include <libkcal/dndfactory.h> 77#include <libkcal/dndfactory.h>
78#include <libkcal/freebusy.h> 78#include <libkcal/freebusy.h>
79#include <libkcal/filestorage.h> 79#include <libkcal/filestorage.h>
80#include <libkcal/calendarresources.h> 80#include <libkcal/calendarresources.h>
81#include <libkcal/qtopiaformat.h> 81#include <libkcal/qtopiaformat.h>
82#include "../kalarmd/alarmdialog.h" 82#include "../kalarmd/alarmdialog.h"
83 83
84#ifndef DESKTOP_VERSION 84#ifndef DESKTOP_VERSION
85#include <libkcal/sharpformat.h> 85#include <libkcal/sharpformat.h>
86#endif 86#endif
87#include <libkcal/phoneformat.h> 87#include <libkcal/phoneformat.h>
88#ifndef KORG_NOMAIL 88#ifndef KORG_NOMAIL
89#include "komailclient.h" 89#include "komailclient.h"
90#endif 90#endif
91#ifndef KORG_NOPRINTER 91#ifndef KORG_NOPRINTER
92#include "calprinter.h" 92#include "calprinter.h"
93#endif 93#endif
94#ifndef KORG_NOPLUGINS 94#ifndef KORG_NOPLUGINS
95#include "kocore.h" 95#include "kocore.h"
96#endif 96#endif
97#include "koeventeditor.h" 97#include "koeventeditor.h"
98#include "kotodoeditor.h" 98#include "kotodoeditor.h"
99#include "koprefs.h" 99#include "koprefs.h"
100#include "koeventviewerdialog.h" 100#include "koeventviewerdialog.h"
101#include "publishdialog.h" 101#include "publishdialog.h"
102#include "kofilterview.h" 102#include "kofilterview.h"
103#include "koglobals.h" 103#include "koglobals.h"
104#include "koviewmanager.h" 104#include "koviewmanager.h"
105#include "koagendaview.h" 105#include "koagendaview.h"
106#include "kodialogmanager.h" 106#include "kodialogmanager.h"
107#include "outgoingdialog.h" 107#include "outgoingdialog.h"
108#include "incomingdialog.h" 108#include "incomingdialog.h"
109#include "statusdialog.h" 109#include "statusdialog.h"
110#include "kdatenavigator.h" 110#include "kdatenavigator.h"
111#include "kotodoview.h" 111#include "kotodoview.h"
112#include "datenavigator.h" 112#include "datenavigator.h"
113#include "resourceview.h" 113#include "resourceview.h"
114#include "navigatorbar.h" 114#include "navigatorbar.h"
115#include "searchdialog.h" 115#include "searchdialog.h"
116#include "mainwindow.h" 116#include "mainwindow.h"
117 117
118#include "calendarview.h" 118#include "calendarview.h"
119#ifndef DESKTOP_VERSION 119#ifndef DESKTOP_VERSION
120#include <qtopia/alarmserver.h> 120#include <qtopia/alarmserver.h>
121#endif 121#endif
122#ifndef _WIN32_ 122#ifndef _WIN32_
123#include <stdlib.h> 123#include <stdlib.h>
124#include <stdio.h> 124#include <stdio.h>
125#include <unistd.h> 125#include <unistd.h>
126#else 126#else
127#include <qprocess.h> 127#include <qprocess.h>
128#endif 128#endif
129using namespace KOrg; 129using namespace KOrg;
130using namespace KCal; 130using namespace KCal;
131extern int globalFlagBlockAgenda; 131extern int globalFlagBlockAgenda;
132extern int globalFlagBlockStartup; 132extern int globalFlagBlockStartup;
133 133
134 134
135 135
136class KOBeamPrefs : public QDialog 136class KOBeamPrefs : public QDialog
137{ 137{
138 public: 138 public:
139 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : 139 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) :
140 QDialog( parent, name, true ) 140 QDialog( parent, name, true )
141 { 141 {
142 setCaption( i18n("Beam Options") ); 142 setCaption( i18n("Beam Options") );
143 QVBoxLayout* lay = new QVBoxLayout( this ); 143 QVBoxLayout* lay = new QVBoxLayout( this );
144 lay->setSpacing( 3 ); 144 lay->setSpacing( 3 );
145 lay->setMargin( 3 ); 145 lay->setMargin( 3 );
146 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); 146 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this );
147 lay->addWidget( format ); 147 lay->addWidget( format );
148 format->setExclusive ( true ) ; 148 format->setExclusive ( true ) ;
149 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); 149 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this );
150 lay->addWidget( time ); time->setExclusive ( true ) ; 150 lay->addWidget( time ); time->setExclusive ( true ) ;
151 vcal = new QRadioButton(" vCalendar ", format ); 151 vcal = new QRadioButton(" vCalendar ", format );
152 ical = new QRadioButton(" iCalendar ", format ); 152 ical = new QRadioButton(" iCalendar ", format );
153 vcal->setChecked( true ); 153 vcal->setChecked( true );
154 tz = new QRadioButton(i18n(" With timezone "), time ); 154 tz = new QRadioButton(i18n(" With timezone "), time );
155 local = new QRadioButton(i18n(" Local time "), time ); 155 local = new QRadioButton(i18n(" Local time "), time );
156 tz->setChecked( true ); 156 tz->setChecked( true );
157 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); 157 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this );
158 lay->addWidget( ok ); 158 lay->addWidget( ok );
159 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 159 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
160 lay->addWidget( cancel ); 160 lay->addWidget( cancel );
161 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 161 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
162 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 162 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
163 resize( 200, 200 ); 163 resize( 200, 200 );
164 } 164 }
165 165
166 bool beamVcal() { return vcal->isChecked(); } 166 bool beamVcal() { return vcal->isChecked(); }
167 bool beamLocal() { return local->isChecked(); } 167 bool beamLocal() { return local->isChecked(); }
168private: 168private:
169 QRadioButton* vcal, *ical, *local, *tz; 169 QRadioButton* vcal, *ical, *local, *tz;
170}; 170};
171class KOCatPrefs : public QDialog 171class KOCatPrefs : public QDialog
172{ 172{
173 public: 173 public:
174 KOCatPrefs( QWidget *parent=0, const char *name=0 ) : 174 KOCatPrefs( QWidget *parent=0, const char *name=0 ) :
175 QDialog( parent, name, true ) 175 QDialog( parent, name, true )
176 { 176 {
177 setCaption( i18n("Manage new Categories") ); 177 setCaption( i18n("Manage new Categories") );
178 QVBoxLayout* lay = new QVBoxLayout( this ); 178 QVBoxLayout* lay = new QVBoxLayout( this );
179 lay->setSpacing( 3 ); 179 lay->setSpacing( 3 );
180 lay->setMargin( 3 ); 180 lay->setMargin( 3 );
181 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); 181 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 );
182 lay->addWidget( lab ); 182 lay->addWidget( lab );
183 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 183 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
184 lay->addWidget( format ); 184 lay->addWidget( format );
185 format->setExclusive ( true ) ; 185 format->setExclusive ( true ) ;
186 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 186 addCatBut = new QRadioButton(i18n("Add to category list"), format );
187 new QRadioButton(i18n("Remove from Events/Todos"), format ); 187 new QRadioButton(i18n("Remove from Events/Todos"), format );
188 addCatBut->setChecked( true ); 188 addCatBut->setChecked( true );
189 QPushButton * ok = new QPushButton( i18n("OK"), this ); 189 QPushButton * ok = new QPushButton( i18n("OK"), this );
190 lay->addWidget( ok ); 190 lay->addWidget( ok );
191 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 191 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
192 lay->addWidget( cancel ); 192 lay->addWidget( cancel );
193 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 193 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
194 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 194 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
195 resize( 200, 200 ); 195 resize( 200, 200 );
196 } 196 }
197 197
198 bool addCat() { return addCatBut->isChecked(); } 198 bool addCat() { return addCatBut->isChecked(); }
199private: 199private:
200 QRadioButton* addCatBut; 200 QRadioButton* addCatBut;
201}; 201};
202 202
203 203
204 204
205CalendarView::CalendarView( CalendarResources *calendar, 205CalendarView::CalendarView( CalendarResources *calendar,
206 QWidget *parent, const char *name ) 206 QWidget *parent, const char *name )
207 : CalendarViewBase( parent, name ), 207 : CalendarViewBase( parent, name ),
208 mCalendar( calendar ), 208 mCalendar( calendar ),
209 mResourceManager( calendar->resourceManager() ) 209 mResourceManager( calendar->resourceManager() )
210{ 210{
211 211
212 mEventEditor = 0; 212 mEventEditor = 0;
213 mTodoEditor = 0; 213 mTodoEditor = 0;
214 214
215 init(); 215 init();
216} 216}
217 217
218CalendarView::CalendarView( Calendar *calendar, 218CalendarView::CalendarView( Calendar *calendar,
219 QWidget *parent, const char *name ) 219 QWidget *parent, const char *name )
220 : CalendarViewBase( parent, name ), 220 : CalendarViewBase( parent, name ),
221 mCalendar( calendar ), 221 mCalendar( calendar ),
222 mResourceManager( 0 ) 222 mResourceManager( 0 )
223{ 223{
224 224
225 mEventEditor = 0; 225 mEventEditor = 0;
226 mTodoEditor = 0; 226 mTodoEditor = 0;
227 init();} 227 init();}
228 228
229void CalendarView::init() 229void CalendarView::init()
230{ 230{
231 beamDialog = new KOBeamPrefs(); 231 beamDialog = new KOBeamPrefs();
232 mDatePickerMode = 0; 232 mDatePickerMode = 0;
233 mCurrentSyncDevice = ""; 233 mCurrentSyncDevice = "";
234 writeLocale(); 234 writeLocale();
235 mViewManager = new KOViewManager( this ); 235 mViewManager = new KOViewManager( this );
236 mDialogManager = new KODialogManager( this ); 236 mDialogManager = new KODialogManager( this );
237 mEventViewerDialog = 0; 237 mEventViewerDialog = 0;
238 mModified = false; 238 mModified = false;
239 mReadOnly = false; 239 mReadOnly = false;
240 mSelectedIncidence = 0; 240 mSelectedIncidence = 0;
241 mCalPrinter = 0; 241 mCalPrinter = 0;
242 mFilters.setAutoDelete(true); 242 mFilters.setAutoDelete(true);
243 243
244 mCalendar->registerObserver( this ); 244 mCalendar->registerObserver( this );
245 // TODO: Make sure that view is updated, when calendar is changed. 245 // TODO: Make sure that view is updated, when calendar is changed.
246 246
247 mStorage = new FileStorage( mCalendar ); 247 mStorage = new FileStorage( mCalendar );
248 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 248 mNavigator = new DateNavigator( this, "datevav", mViewManager );
249 249
250 QBoxLayout *topLayout = (QBoxLayout*)layout(); 250 QBoxLayout *topLayout = (QBoxLayout*)layout();
251#ifndef KORG_NOSPLITTER 251#ifndef KORG_NOSPLITTER
252 // create the main layout frames. 252 // create the main layout frames.
253 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 253 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
254 topLayout->addWidget(mPanner); 254 topLayout->addWidget(mPanner);
255 255
256 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 256 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
257 "CalendarView::LeftFrame"); 257 "CalendarView::LeftFrame");
258 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 258 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
259 259
260 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, 260 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE,
261 "CalendarView::DateNavigator", QDate::currentDate() ); 261 "CalendarView::DateNavigator", QDate::currentDate() );
262 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 262 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
263 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 263 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
264 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 264 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
265 265
266#ifdef KORG_NORESOURCEVIEW 266#ifdef KORG_NORESOURCEVIEW
267 mResourceView = 0; 267 mResourceView = 0;
268#else 268#else
269 if ( mResourceManager ) { 269 if ( mResourceManager ) {
270 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 270 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
271 mResourceView->updateView(); 271 mResourceView->updateView();
272 connect( mResourceView, SIGNAL( resourcesChanged() ), 272 connect( mResourceView, SIGNAL( resourcesChanged() ),
273 SLOT( updateView() ) ); 273 SLOT( updateView() ) );
274 } else { 274 } else {
275 mResourceView = 0; 275 mResourceView = 0;
276 } 276 }
277#endif 277#endif
278 QWidget *rightBox = new QWidget( mPanner ); 278 QWidget *rightBox = new QWidget( mPanner );
279 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 279 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
280 280
281 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 281 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
282 rightLayout->addWidget( mNavigatorBar ); 282 rightLayout->addWidget( mNavigatorBar );
283 283
284 mRightFrame = new QWidgetStack( rightBox ); 284 mRightFrame = new QWidgetStack( rightBox );
285 rightLayout->addWidget( mRightFrame, 1 ); 285 rightLayout->addWidget( mRightFrame, 1 );
286 286
287 mLeftFrame = mLeftSplitter; 287 mLeftFrame = mLeftSplitter;
288#else 288#else
289 QWidget *mainBox = new QWidget( this ); 289 QWidget *mainBox = new QWidget( this );
290 QWidget *leftFrame = new QWidget( mainBox ); 290 QWidget *leftFrame = new QWidget( mainBox );
291 291
292 QBoxLayout * mainBoxLayout; 292 QBoxLayout * mainBoxLayout;
293 QBoxLayout * leftFrameLayout; 293 QBoxLayout * leftFrameLayout;
294 if ( KOPrefs::instance()->mVerticalScreen ) { 294 if ( KOPrefs::instance()->mVerticalScreen ) {
295 mainBoxLayout = new QVBoxLayout(mainBox); 295 mainBoxLayout = new QVBoxLayout(mainBox);
296 leftFrameLayout = new QHBoxLayout(leftFrame ); 296 leftFrameLayout = new QHBoxLayout(leftFrame );
297 } else { 297 } else {
298 mainBoxLayout = new QHBoxLayout(mainBox); 298 mainBoxLayout = new QHBoxLayout(mainBox);
299 leftFrameLayout = new QVBoxLayout(leftFrame ); 299 leftFrameLayout = new QVBoxLayout(leftFrame );
300 } 300 }
301 topLayout->addWidget( mainBox ); 301 topLayout->addWidget( mainBox );
302 mainBoxLayout->addWidget (leftFrame); 302 mainBoxLayout->addWidget (leftFrame);
303 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, 303 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE,
304 "CalendarView::DateNavigator", QDate::currentDate()); 304 "CalendarView::DateNavigator", QDate::currentDate());
305 // mDateNavigator->blockSignals( true ); 305 // mDateNavigator->blockSignals( true );
306 leftFrameLayout->addWidget( mDateNavigator ); 306 leftFrameLayout->addWidget( mDateNavigator );
307 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); 307 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView");
308 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolist"); 308 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolist");
309 309
310 if ( QApplication::desktop()->width() < 480 ) { 310 if ( QApplication::desktop()->width() < 480 ) {
311 leftFrameLayout->addWidget(mFilterView); 311 leftFrameLayout->addWidget(mFilterView);
312 leftFrameLayout->addWidget(mTodoList, 2 ); 312 leftFrameLayout->addWidget(mTodoList, 2 );
313 313
314 } else { 314 } else {
315 leftFrameLayout->addWidget(mTodoList,2 ); 315 leftFrameLayout->addWidget(mTodoList,2 );
316 leftFrameLayout->addWidget(mFilterView ); 316 leftFrameLayout->addWidget(mFilterView );
317 } 317 }
318 mFilterView->hide(); 318 mFilterView->hide();
319 QWidget *rightBox = new QWidget( mainBox ); 319 QWidget *rightBox = new QWidget( mainBox );
320 mainBoxLayout->addWidget ( rightBox, 10 ); 320 mainBoxLayout->addWidget ( rightBox, 10 );
321 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 321 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
322 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 322 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
323 mRightFrame = new QWidgetStack( rightBox ); 323 mRightFrame = new QWidgetStack( rightBox );
324 rightLayout->addWidget( mNavigatorBar ); 324 rightLayout->addWidget( mNavigatorBar );
325 rightLayout->addWidget( mRightFrame, 10 ); 325 rightLayout->addWidget( mRightFrame, 10 );
326 326
327 mLeftFrame = leftFrame; 327 mLeftFrame = leftFrame;
328 if ( KOPrefs::instance()->mVerticalScreen ) { 328 if ( KOPrefs::instance()->mVerticalScreen ) {
329 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 329 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
330 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 330 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
331 } else { 331 } else {
332 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 332 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
333 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 333 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
334 } 334 }
335 335
336 //qDebug("Calendarview Size %d %d ", width(), height()); 336 //qDebug("Calendarview Size %d %d ", width(), height());
337#endif 337#endif
338 338
339 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 339 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
340 SLOT( showDates( const KCal::DateList & ) ) ); 340 SLOT( showDates( const KCal::DateList & ) ) );
341 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 341 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
342 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 342 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
343 343
344 connect( mNavigatorBar, SIGNAL( goPrevYear() ), 344 connect( mNavigatorBar, SIGNAL( goPrevYear() ),
345 mNavigator, SLOT( selectPreviousYear() ) ); 345 mNavigator, SLOT( selectPreviousYear() ) );
346 connect( mNavigatorBar, SIGNAL( goNextYear() ), 346 connect( mNavigatorBar, SIGNAL( goNextYear() ),
347 mNavigator, SLOT( selectNextYear() ) ); 347 mNavigator, SLOT( selectNextYear() ) );
348 connect( mNavigatorBar, SIGNAL( goPrevMonth() ), 348 connect( mNavigatorBar, SIGNAL( goPrevMonth() ),
349 mNavigator, SLOT( selectPreviousMonth() ) ); 349 mNavigator, SLOT( selectPreviousMonth() ) );
350 connect( mNavigatorBar, SIGNAL( goNextMonth() ), 350 connect( mNavigatorBar, SIGNAL( goNextMonth() ),
351 mNavigator, SLOT( selectNextMonth() ) ); 351 mNavigator, SLOT( selectNextMonth() ) );
352 352
353 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 353 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
354 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); 354 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) );
355 355
356 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 356 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
357 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 357 mNavigator, SLOT( selectWeek( const QDate & ) ) );
358 358
359 connect( mDateNavigator, SIGNAL( goPrevYear() ), 359 connect( mDateNavigator, SIGNAL( goPrevYear() ),
360 mNavigator, SLOT( selectPreviousYear() ) ); 360 mNavigator, SLOT( selectPreviousYear() ) );
361 connect( mDateNavigator, SIGNAL( goNextYear() ), 361 connect( mDateNavigator, SIGNAL( goNextYear() ),
362 mNavigator, SLOT( selectNextYear() ) ); 362 mNavigator, SLOT( selectNextYear() ) );
363 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 363 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
364 mNavigator, SLOT( selectPreviousMonth() ) ); 364 mNavigator, SLOT( selectPreviousMonth() ) );
365 connect( mDateNavigator, SIGNAL( goNextMonth() ), 365 connect( mDateNavigator, SIGNAL( goNextMonth() ),
366 mNavigator, SLOT( selectNextMonth() ) ); 366 mNavigator, SLOT( selectNextMonth() ) );
367 367
368 connect( mDateNavigator, SIGNAL( goPrevious() ), 368 connect( mDateNavigator, SIGNAL( goPrevious() ),
369 mNavigator, SLOT( selectPrevious() ) ); 369 mNavigator, SLOT( selectPrevious() ) );
370 connect( mDateNavigator, SIGNAL( goNext() ), 370 connect( mDateNavigator, SIGNAL( goNext() ),
371 mNavigator, SLOT( selectNext() ) ); 371 mNavigator, SLOT( selectNext() ) );
372 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 372 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
373 mNavigator, SLOT( slotMonthSelect( int ) ) ); 373 mNavigator, SLOT( slotMonthSelect( int ) ) );
374 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), 374 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ),
375 mNavigator, SLOT( slotMonthSelect( int ) ) ); 375 mNavigator, SLOT( slotMonthSelect( int ) ) );
376 376
377 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 377 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
378 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 378 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
379 379
380 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), 380 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ),
381 SLOT( eventAdded( Event *) ) ); 381 SLOT( eventAdded( Event *) ) );
382 382
383 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 383 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
384 384
385 connect( this, SIGNAL( configChanged() ), 385 connect( this, SIGNAL( configChanged() ),
386 mDateNavigator, SLOT( updateConfig() ) ); 386 mDateNavigator, SLOT( updateConfig() ) );
387 387
388 connect( mTodoList, SIGNAL( newTodoSignal() ), 388 connect( mTodoList, SIGNAL( newTodoSignal() ),
389 SLOT( newTodo() ) ); 389 SLOT( newTodo() ) );
390 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 390 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
391 SLOT( newSubTodo( Todo * ) ) ); 391 SLOT( newSubTodo( Todo * ) ) );
392 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 392 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
393 SLOT( editTodo( Todo * ) ) ); 393 SLOT( editTodo( Todo * ) ) );
394 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 394 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
395 SLOT( showTodo( Todo *) ) ); 395 SLOT( showTodo( Todo *) ) );
396 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 396 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
397 SLOT( deleteTodo( Todo *) ) ); 397 SLOT( deleteTodo( Todo *) ) );
398 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 398 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
399 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 399 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
400 SLOT( purgeCompleted() ) ); 400 SLOT( purgeCompleted() ) );
401 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 401 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
402 SIGNAL( todoModified( Todo *, int ) ) ); 402 SIGNAL( todoModified( Todo *, int ) ) );
403 403
404 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 404 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
405 this, SLOT ( cloneIncidence( Incidence * ) ) ); 405 this, SLOT ( cloneIncidence( Incidence * ) ) );
406 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 406 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
407 this, SLOT (cancelIncidence( Incidence * ) ) ); 407 this, SLOT (cancelIncidence( Incidence * ) ) );
408 408
409 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 409 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
410 this, SLOT ( moveIncidence( Incidence * ) ) ); 410 this, SLOT ( moveIncidence( Incidence * ) ) );
411 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 411 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
412 this, SLOT ( beamIncidence( Incidence * ) ) ); 412 this, SLOT ( beamIncidence( Incidence * ) ) );
413 413
414 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 414 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
415 this, SLOT ( todo_unsub( Todo * ) ) ); 415 this, SLOT ( todo_unsub( Todo * ) ) );
416 416
417 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 417 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
418 SLOT( updateTodo( Todo *, int ) ) ); 418 SLOT( updateTodo( Todo *, int ) ) );
419 connect( this, SIGNAL( todoModified( Todo *, int )), this, 419 connect( this, SIGNAL( todoModified( Todo *, int )), this,
420 SLOT( changeTodoDisplay( Todo *, int ) ) ); 420 SLOT( changeTodoDisplay( Todo *, int ) ) );
421 421
422 422
423 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 423 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
424 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 424 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
425 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 425 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
426 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 426 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
427 427
428 428
429 429
430 430
431 431
432 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 432 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
433 SLOT(checkClipboard())); 433 SLOT(checkClipboard()));
434 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 434 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
435 SLOT( processTodoListSelection( Incidence * ) ) ); 435 SLOT( processTodoListSelection( Incidence * ) ) );
436 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 436 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
437 437
438 // kdDebug() << "CalendarView::CalendarView() done" << endl; 438 // kdDebug() << "CalendarView::CalendarView() done" << endl;
439 439
440 mDateFrame = new QVBox(0,0,WType_Popup); 440 mDateFrame = new QVBox(0,0,WType_Popup);
441 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 441 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
442 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 442 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
443 mDateFrame->setLineWidth(3); 443 mDateFrame->setLineWidth(3);
444 mDateFrame->hide(); 444 mDateFrame->hide();
445 mDateFrame->setCaption( i18n( "Pick a date to display")); 445 mDateFrame->setCaption( i18n( "Pick a date to display"));
446 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 446 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
447 447
448 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 448 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
449 449
450 mEventEditor = mDialogManager->getEventEditor(); 450 mEventEditor = mDialogManager->getEventEditor();
451 mTodoEditor = mDialogManager->getTodoEditor(); 451 mTodoEditor = mDialogManager->getTodoEditor();
452 452
453 mFlagEditDescription = false; 453 mFlagEditDescription = false;
454 454
455 mSuspendTimer = new QTimer( this ); 455 mSuspendTimer = new QTimer( this );
456 mAlarmTimer = new QTimer( this ); 456 mAlarmTimer = new QTimer( this );
457 mRecheckAlarmTimer = new QTimer( this ); 457 mRecheckAlarmTimer = new QTimer( this );
458 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 458 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
459 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 459 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
460 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 460 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
461 mAlarmDialog = new AlarmDialog( this ); 461 mAlarmDialog = new AlarmDialog( this );
462 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 462 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
463 mAlarmDialog->setServerNotification( false ); 463 mAlarmDialog->setServerNotification( false );
464 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 464 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
465} 465}
466 466
467 467
468CalendarView::~CalendarView() 468CalendarView::~CalendarView()
469{ 469{
470 // kdDebug() << "~CalendarView()" << endl; 470 // kdDebug() << "~CalendarView()" << endl;
471 //qDebug("CalendarView::~CalendarView() "); 471 //qDebug("CalendarView::~CalendarView() ");
472 delete mDialogManager; 472 delete mDialogManager;
473 delete mViewManager; 473 delete mViewManager;
474 delete mStorage; 474 delete mStorage;
475 delete mDateFrame ; 475 delete mDateFrame ;
476 delete beamDialog; 476 delete beamDialog;
477 //kdDebug() << "~CalendarView() done" << endl; 477 //kdDebug() << "~CalendarView() done" << endl;
478} 478}
479void CalendarView::timerAlarm() 479void CalendarView::timerAlarm()
480{ 480{
481 //qDebug("CalendarView::timerAlarm() "); 481 //qDebug("CalendarView::timerAlarm() ");
482 computeAlarm(mAlarmNotification ); 482 computeAlarm(mAlarmNotification );
483} 483}
484 484
485void CalendarView::suspendAlarm() 485void CalendarView::suspendAlarm()
486{ 486{
487 //qDebug(" CalendarView::suspendAlarm() "); 487 //qDebug(" CalendarView::suspendAlarm() ");
488 computeAlarm(mSuspendAlarmNotification ); 488 computeAlarm(mSuspendAlarmNotification );
489 489
490} 490}
491 491
492void CalendarView::startAlarm( QString mess , QString filename) 492void CalendarView::startAlarm( QString mess , QString filename)
493{ 493{
494 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 494 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
495 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); 495 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
496 496
497} 497}
498 498
499void CalendarView::checkNextTimerAlarm() 499void CalendarView::checkNextTimerAlarm()
500{ 500{
501 mCalendar->checkAlarmForIncidence( 0, true ); 501 mCalendar->checkAlarmForIncidence( 0, true );
502} 502}
503 503
504void CalendarView::computeAlarm( QString msg ) 504void CalendarView::computeAlarm( QString msg )
505{ 505{
506 506
507 QString mess = msg; 507 QString mess = msg;
508 QString mAlarmMessage = mess.mid( 9 ); 508 QString mAlarmMessage = mess.mid( 9 );
509 QString filename = MainWindow::resourcePath(); 509 QString filename = MainWindow::resourcePath();
510 filename += "koalarm.wav"; 510 filename += "koalarm.wav";
511 QString tempfilename; 511 QString tempfilename;
512 if ( mess.left( 13 ) == "suspend_alarm") { 512 if ( mess.left( 13 ) == "suspend_alarm") {
513 bool error = false; 513 bool error = false;
514 int len = mess.mid( 13 ).find("+++"); 514 int len = mess.mid( 13 ).find("+++");
515 if ( len < 2 ) 515 if ( len < 2 )
516 error = true; 516 error = true;
517 else { 517 else {
518 tempfilename = mess.mid( 13, len ); 518 tempfilename = mess.mid( 13, len );
519 if ( !QFile::exists( tempfilename ) ) 519 if ( !QFile::exists( tempfilename ) )
520 error = true; 520 error = true;
521 } 521 }
522 if ( ! error ) { 522 if ( ! error ) {
523 filename = tempfilename; 523 filename = tempfilename;
524 } 524 }
525 mAlarmMessage = mess.mid( 13+len+3 ); 525 mAlarmMessage = mess.mid( 13+len+3 );
526 //qDebug("suspend file %s ",tempfilename.latin1() ); 526 //qDebug("suspend file %s ",tempfilename.latin1() );
527 startAlarm( mAlarmMessage, filename); 527 startAlarm( mAlarmMessage, filename);
528 return; 528 return;
529 } 529 }
530 if ( mess.left( 11 ) == "timer_alarm") { 530 if ( mess.left( 11 ) == "timer_alarm") {
531 //mTimerTime = 0; 531 //mTimerTime = 0;
532 startAlarm( mess.mid( 11 ), filename ); 532 startAlarm( mess.mid( 11 ), filename );
533 return; 533 return;
534 } 534 }
535 if ( mess.left( 10 ) == "proc_alarm") { 535 if ( mess.left( 10 ) == "proc_alarm") {
536 bool error = false; 536 bool error = false;
537 int len = mess.mid( 10 ).find("+++"); 537 int len = mess.mid( 10 ).find("+++");
538 if ( len < 2 ) 538 if ( len < 2 )
539 error = true; 539 error = true;
540 else { 540 else {
541 tempfilename = mess.mid( 10, len ); 541 tempfilename = mess.mid( 10, len );
542 if ( !QFile::exists( tempfilename ) ) 542 if ( !QFile::exists( tempfilename ) )
543 error = true; 543 error = true;
544 } 544 }
545 if ( error ) { 545 if ( error ) {
546 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 546 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
547 mAlarmMessage += mess.mid( 10+len+3+9 ); 547 mAlarmMessage += mess.mid( 10+len+3+9 );
548 } else { 548 } else {
549 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 549 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
550 //qDebug("-----system command %s ",tempfilename.latin1() ); 550 //qDebug("-----system command %s ",tempfilename.latin1() );
551#ifndef _WIN32_ 551#ifndef _WIN32_
552 if ( vfork () == 0 ) { 552 if ( vfork () == 0 ) {
553 execl ( tempfilename.latin1(), 0 ); 553 execl ( tempfilename.latin1(), 0 );
554 return; 554 return;
555 } 555 }
556#else 556#else
557 QProcess* p = new QProcess(); 557 QProcess* p = new QProcess();
558 p->addArgument( tempfilename.latin1() ); 558 p->addArgument( tempfilename.latin1() );
559 p->start(); 559 p->start();
560 return; 560 return;
561#endif 561#endif
562 562
563 return; 563 return;
564 } 564 }
565 565
566 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 566 //qDebug("+++++++system command %s ",tempfilename.latin1() );
567 } 567 }
568 if ( mess.left( 11 ) == "audio_alarm") { 568 if ( mess.left( 11 ) == "audio_alarm") {
569 bool error = false; 569 bool error = false;
570 int len = mess.mid( 11 ).find("+++"); 570 int len = mess.mid( 11 ).find("+++");
571 if ( len < 2 ) 571 if ( len < 2 )
572 error = true; 572 error = true;
573 else { 573 else {
574 tempfilename = mess.mid( 11, len ); 574 tempfilename = mess.mid( 11, len );
575 if ( !QFile::exists( tempfilename ) ) 575 if ( !QFile::exists( tempfilename ) )
576 error = true; 576 error = true;
577 } 577 }
578 if ( ! error ) { 578 if ( ! error ) {
579 filename = tempfilename; 579 filename = tempfilename;
580 } 580 }
581 mAlarmMessage = mess.mid( 11+len+3+9 ); 581 mAlarmMessage = mess.mid( 11+len+3+9 );
582 //qDebug("audio file command %s ",tempfilename.latin1() ); 582 //qDebug("audio file command %s ",tempfilename.latin1() );
583 } 583 }
584 if ( mess.left( 9 ) == "cal_alarm") { 584 if ( mess.left( 9 ) == "cal_alarm") {
585 mAlarmMessage = mess.mid( 9 ) ; 585 mAlarmMessage = mess.mid( 9 ) ;
586 } 586 }
587 587
588 startAlarm( mAlarmMessage, filename ); 588 startAlarm( mAlarmMessage, filename );
589 589
590 590
591} 591}
592 592
593void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 593void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
594{ 594{
595 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 595 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
596 596
597 mSuspendAlarmNotification = noti; 597 mSuspendAlarmNotification = noti;
598 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 598 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
599 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 599 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
600 mSuspendTimer->start( ms , true ); 600 mSuspendTimer->start( ms , true );
601 601
602} 602}
603 603
604void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 604void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
605{ 605{
606 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 606 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
607 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 607 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
608#ifndef DESKTOP_VERSION 608#ifndef DESKTOP_VERSION
609 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); 609 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() );
610#endif 610#endif
611 return; 611 return;
612 } 612 }
613 int maxSec; 613 int maxSec;
614 //maxSec = 5; //testing only 614 //maxSec = 5; //testing only
615 maxSec = 86400+3600; // one day+1hour 615 maxSec = 86400+3600; // one day+1hour
616 mAlarmNotification = noti; 616 mAlarmNotification = noti;
617 int sec = QDateTime::currentDateTime().secsTo( qdt ); 617 int sec = QDateTime::currentDateTime().secsTo( qdt );
618 if ( sec > maxSec ) { 618 if ( sec > maxSec ) {
619 mRecheckAlarmTimer->start( maxSec * 1000 ); 619 mRecheckAlarmTimer->start( maxSec * 1000 );
620 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 620 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
621 return; 621 return;
622 } else { 622 } else {
623 mRecheckAlarmTimer->stop(); 623 mRecheckAlarmTimer->stop();
624 } 624 }
625 //qDebug("Alarm timer started with secs: %d ", sec); 625 //qDebug("Alarm timer started with secs: %d ", sec);
626 mAlarmTimer->start( sec *1000 , true ); 626 mAlarmTimer->start( sec *1000 , true );
627 627
628} 628}
629// called by mRecheckAlarmTimer to get next alarm 629// called by mRecheckAlarmTimer to get next alarm
630// we need this, because a QTimer has only a max range of 25 days 630// we need this, because a QTimer has only a max range of 25 days
631void CalendarView::recheckTimerAlarm() 631void CalendarView::recheckTimerAlarm()
632{ 632{
633 mAlarmTimer->stop(); 633 mAlarmTimer->stop();
634 mRecheckAlarmTimer->stop(); 634 mRecheckAlarmTimer->stop();
635 mCalendar->checkAlarmForIncidence( 0, true ); 635 mCalendar->checkAlarmForIncidence( 0, true );
636} 636}
637void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 637void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
638{ 638{
639 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 639 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
640 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 640 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
641#ifndef DESKTOP_VERSION 641#ifndef DESKTOP_VERSION
642 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 642 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
643#endif 643#endif
644 return; 644 return;
645 } 645 }
646 mAlarmTimer->stop(); 646 mAlarmTimer->stop();
647} 647}
648void CalendarView::selectWeekNum ( int num ) 648void CalendarView::selectWeekNum ( int num )
649{ 649{
650 dateNavigator()->selectWeek( num ); 650 dateNavigator()->selectWeek( num );
651 mViewManager->showWeekView(); 651 mViewManager->showWeekView();
652} 652}
653KOViewManager *CalendarView::viewManager() 653KOViewManager *CalendarView::viewManager()
654{ 654{
655 return mViewManager; 655 return mViewManager;
656} 656}
657 657
658KODialogManager *CalendarView::dialogManager() 658KODialogManager *CalendarView::dialogManager()
659{ 659{
660 return mDialogManager; 660 return mDialogManager;
661} 661}
662 662
663QDate CalendarView::startDate() 663QDate CalendarView::startDate()
664{ 664{
665 DateList dates = mNavigator->selectedDates(); 665 DateList dates = mNavigator->selectedDates();
666 666
667 return dates.first(); 667 return dates.first();
668} 668}
669 669
670QDate CalendarView::endDate() 670QDate CalendarView::endDate()
671{ 671{
672 DateList dates = mNavigator->selectedDates(); 672 DateList dates = mNavigator->selectedDates();
673 673
674 return dates.last(); 674 return dates.last();
675} 675}
676 676
677 677
678void CalendarView::createPrinter() 678void CalendarView::createPrinter()
679{ 679{
680#ifndef KORG_NOPRINTER 680#ifndef KORG_NOPRINTER
681 if (!mCalPrinter) { 681 if (!mCalPrinter) {
682 mCalPrinter = new CalPrinter(this, mCalendar); 682 mCalPrinter = new CalPrinter(this, mCalendar);
683 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 683 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
684 } 684 }
685#endif 685#endif
686} 686}
687 687
688void CalendarView::confSync() 688void CalendarView::confSync()
689{ 689{
690 static KSyncPrefsDialog* sp = 0; 690 static KSyncPrefsDialog* sp = 0;
691 if ( ! sp ) { 691 if ( ! sp ) {
692 sp = new KSyncPrefsDialog( this, "syncprefs", true ); 692 sp = new KSyncPrefsDialog( this, "syncprefs", true );
693 } 693 }
694 sp->usrReadConfig(); 694 sp->usrReadConfig();
695#ifndef DESKTOP_VERSION 695#ifndef DESKTOP_VERSION
696 sp->showMaximized(); 696 sp->showMaximized();
697#else 697#else
698 sp->show(); 698 sp->show();
699#endif 699#endif
700 sp->exec(); 700 sp->exec();
701 KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); 701 KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames();
702 KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); 702 KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName ();
703} 703}
704 704
705 705
706//KOPrefs::instance()->mWriteBackFile 706//KOPrefs::instance()->mWriteBackFile
707//KOPrefs::instance()->mWriteBackExistingOnly 707//KOPrefs::instance()->mWriteBackExistingOnly
708 708
709// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 709// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
710// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 710// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
711// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 711// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
712// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 712// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
713// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 713// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
714// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 714// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
715 715
716int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 716int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
717{ 717{
718 718
719 //void setZaurusId(int id); 719 //void setZaurusId(int id);
720 // int zaurusId() const; 720 // int zaurusId() const;
721 // void setZaurusUid(int id); 721 // void setZaurusUid(int id);
722 // int zaurusUid() const; 722 // int zaurusUid() const;
723 // void setZaurusStat(int id); 723 // void setZaurusStat(int id);
724 // int zaurusStat() const; 724 // int zaurusStat() const;
725 // 0 equal 725 // 0 equal
726 // 1 take local 726 // 1 take local
727 // 2 take remote 727 // 2 take remote
728 // 3 cancel 728 // 3 cancel
729 QDateTime lastSync = mLastCalendarSync; 729 QDateTime lastSync = mLastCalendarSync;
730 QDateTime localMod = local->lastModified(); 730 QDateTime localMod = local->lastModified();
731 QDateTime remoteMod = remote->lastModified(); 731 QDateTime remoteMod = remote->lastModified();
732 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 732 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
733 bool remCh, locCh; 733 bool remCh, locCh;
734 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 734 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
735 //if ( remCh ) 735 //if ( remCh )
736 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 736 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
737 locCh = ( localMod > mLastCalendarSync ); 737 locCh = ( localMod > mLastCalendarSync );
738 if ( !remCh && ! locCh ) { 738 if ( !remCh && ! locCh ) {
739 //qDebug("both not changed "); 739 //qDebug("both not changed ");
740 lastSync = localMod.addDays(1); 740 lastSync = localMod.addDays(1);
741 if ( mode <= SYNC_PREF_ASK ) 741 if ( mode <= SYNC_PREF_ASK )
742 return 0; 742 return 0;
743 } else { 743 } else {
744 if ( locCh ) { 744 if ( locCh ) {
745 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); 745 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1());
746 lastSync = localMod.addDays( -1 ); 746 lastSync = localMod.addDays( -1 );
747 if ( !remCh ) 747 if ( !remCh )
748 remoteMod = ( lastSync.addDays( -1 ) ); 748 remoteMod = ( lastSync.addDays( -1 ) );
749 } else { 749 } else {
750 //qDebug(" not loc changed "); 750 //qDebug(" not loc changed ");
751 lastSync = localMod.addDays( 1 ); 751 lastSync = localMod.addDays( 1 );
752 if ( remCh ) 752 if ( remCh )
753 remoteMod =( lastSync.addDays( 1 ) ); 753 remoteMod =( lastSync.addDays( 1 ) );
754 754
755 } 755 }
756 } 756 }
757 full = true; 757 full = true;
758 if ( mode < SYNC_PREF_ASK ) 758 if ( mode < SYNC_PREF_ASK )
759 mode = SYNC_PREF_ASK; 759 mode = SYNC_PREF_ASK;
760 } else { 760 } else {
761 if ( localMod == remoteMod ) 761 if ( localMod == remoteMod )
762 if ( local->revision() == remote->revision() ) 762 if ( local->revision() == remote->revision() )
763 return 0; 763 return 0;
764 764
765 } 765 }
766 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 766 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
767 767
768 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); 768 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision());
769 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); 769 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() );
770 //full = true; //debug only 770 //full = true; //debug only
771 if ( full ) { 771 if ( full ) {
772 bool equ = false; 772 bool equ = false;
773 if ( local->type() == "Event" ) { 773 if ( local->type() == "Event" ) {
774 equ = (*((Event*) local) == *((Event*) remote)); 774 equ = (*((Event*) local) == *((Event*) remote));
775 } 775 }
776 else if ( local->type() =="Todo" ) 776 else if ( local->type() =="Todo" )
777 equ = (*((Todo*) local) == (*(Todo*) remote)); 777 equ = (*((Todo*) local) == (*(Todo*) remote));
778 else if ( local->type() =="Journal" ) 778 else if ( local->type() =="Journal" )
779 equ = (*((Journal*) local) == *((Journal*) remote)); 779 equ = (*((Journal*) local) == *((Journal*) remote));
780 if ( equ ) { 780 if ( equ ) {
781 //qDebug("equal "); 781 //qDebug("equal ");
782 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 782 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
783 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 783 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
784 } 784 }
785 if ( mode < SYNC_PREF_FORCE_LOCAL ) 785 if ( mode < SYNC_PREF_FORCE_LOCAL )
786 return 0; 786 return 0;
787 787
788 }//else //debug only 788 }//else //debug only
789 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 789 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
790 } 790 }
791 int result; 791 int result;
792 bool localIsNew; 792 bool localIsNew;
793 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); 793 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() );
794 794
795 if ( full && mode < SYNC_PREF_NEWEST ) 795 if ( full && mode < SYNC_PREF_NEWEST )
796 mode = SYNC_PREF_ASK; 796 mode = SYNC_PREF_ASK;
797 797
798 switch( mode ) { 798 switch( mode ) {
799 case SYNC_PREF_LOCAL: 799 case SYNC_PREF_LOCAL:
800 if ( lastSync > remoteMod ) 800 if ( lastSync > remoteMod )
801 return 1; 801 return 1;
802 if ( lastSync > localMod ) 802 if ( lastSync > localMod )
803 return 2; 803 return 2;
804 return 1; 804 return 1;
805 break; 805 break;
806 case SYNC_PREF_REMOTE: 806 case SYNC_PREF_REMOTE:
807 if ( lastSync > remoteMod ) 807 if ( lastSync > remoteMod )
808 return 1; 808 return 1;
809 if ( lastSync > localMod ) 809 if ( lastSync > localMod )
810 return 2; 810 return 2;
811 return 2; 811 return 2;
812 break; 812 break;
813 case SYNC_PREF_NEWEST: 813 case SYNC_PREF_NEWEST:
814 if ( localMod > remoteMod ) 814 if ( localMod > remoteMod )
815 return 1; 815 return 1;
816 else 816 else
817 return 2; 817 return 2;
818 break; 818 break;
819 case SYNC_PREF_ASK: 819 case SYNC_PREF_ASK:
820 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 820 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
821 if ( lastSync > remoteMod ) 821 if ( lastSync > remoteMod )
822 return 1; 822 return 1;
823 if ( lastSync > localMod ) 823 if ( lastSync > localMod )
824 return 2; 824 return 2;
825 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 825 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
826 localIsNew = localMod >= remoteMod; 826 localIsNew = localMod >= remoteMod;
827 if ( localIsNew ) 827 if ( localIsNew )
828 getEventViewerDialog()->setColorMode( 1 ); 828 getEventViewerDialog()->setColorMode( 1 );
829 else 829 else
830 getEventViewerDialog()->setColorMode( 2 ); 830 getEventViewerDialog()->setColorMode( 2 );
831 getEventViewerDialog()->setIncidence(local); 831 getEventViewerDialog()->setIncidence(local);
832 if ( localIsNew ) 832 if ( localIsNew )
833 getEventViewerDialog()->setColorMode( 2 ); 833 getEventViewerDialog()->setColorMode( 2 );
834 else 834 else
835 getEventViewerDialog()->setColorMode( 1 ); 835 getEventViewerDialog()->setColorMode( 1 );
836 getEventViewerDialog()->addIncidence(remote); 836 getEventViewerDialog()->addIncidence(remote);
837 getEventViewerDialog()->setColorMode( 0 ); 837 getEventViewerDialog()->setColorMode( 0 );
838 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 838 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
839 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 839 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
840 getEventViewerDialog()->showMe(); 840 getEventViewerDialog()->showMe();
841 result = getEventViewerDialog()->executeS( localIsNew ); 841 result = getEventViewerDialog()->executeS( localIsNew );
842 return result; 842 return result;
843 843
844 break; 844 break;
845 case SYNC_PREF_FORCE_LOCAL: 845 case SYNC_PREF_FORCE_LOCAL:
846 return 1; 846 return 1;
847 break; 847 break;
848 case SYNC_PREF_FORCE_REMOTE: 848 case SYNC_PREF_FORCE_REMOTE:
849 return 2; 849 return 2;
850 break; 850 break;
851 851
852 default: 852 default:
853 // SYNC_PREF_TAKE_BOTH not implemented 853 // SYNC_PREF_TAKE_BOTH not implemented
854 break; 854 break;
855 } 855 }
856 return 0; 856 return 0;
857} 857}
858Event* CalendarView::getLastSyncEvent() 858Event* CalendarView::getLastSyncEvent()
859{ 859{
860 Event* lse; 860 Event* lse;
861 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 861 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
862 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 862 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
863 if (!lse) { 863 if (!lse) {
864 lse = new Event(); 864 lse = new Event();
865 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 865 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
866 QString sum = ""; 866 QString sum = "";
867 if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 867 if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
868 sum = "E: "; 868 sum = "E: ";
869 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 869 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
870 lse->setDtStart( mLastCalendarSync ); 870 lse->setDtStart( mLastCalendarSync );
871 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 871 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
872 lse->setCategories( i18n("SyncEvent") ); 872 lse->setCategories( i18n("SyncEvent") );
873 lse->setReadOnly( true ); 873 lse->setReadOnly( true );
874 mCalendar->addEvent( lse ); 874 mCalendar->addEvent( lse );
875 } 875 }
876 876
877 return lse; 877 return lse;
878 878
879} 879}
880// probaly useless 880// probaly useless
881void CalendarView::setupExternSyncProfiles() 881void CalendarView::setupExternSyncProfiles()
882{ 882{
883 Event* lse; 883 Event* lse;
884 mExternLastSyncEvent.clear(); 884 mExternLastSyncEvent.clear();
885 int i; 885 int i;
886 for ( i = 0; i < KOPrefs::instance()->mExternSyncProfiles.count(); ++i ) { 886 for ( i = 0; i < KOPrefs::instance()->mExternSyncProfiles.count(); ++i ) {
887 lse = mCalendar->event( "last-syncEvent-"+ KOPrefs::instance()->mExternSyncProfiles[i] ); 887 lse = mCalendar->event( "last-syncEvent-"+ KOPrefs::instance()->mExternSyncProfiles[i] );
888 if ( lse ) 888 if ( lse )
889 mExternLastSyncEvent.append( lse ); 889 mExternLastSyncEvent.append( lse );
890 else 890 else
891 qDebug("Last Sync event not found for %s ", KOPrefs::instance()->mExternSyncProfiles[i].latin1()); 891 qDebug("Last Sync event not found for %s ", KOPrefs::instance()->mExternSyncProfiles[i].latin1());
892 } 892 }
893 893
894} 894}
895// we check, if the to delete event has a id for a profile 895// we check, if the to delete event has a id for a profile
896// if yes, we set this id in the profile to delete 896// if yes, we set this id in the profile to delete
897void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 897void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
898{ 898{
899 if ( lastSync.count() == 0 ) { 899 if ( lastSync.count() == 0 ) {
900 //qDebug(" lastSync.count() == 0"); 900 //qDebug(" lastSync.count() == 0");
901 return; 901 return;
902 } 902 }
903 if ( toDelete->type() == "Journal" ) 903 if ( toDelete->type() == "Journal" )
904 return; 904 return;
905 905
906 Event* eve = lastSync.first(); 906 Event* eve = lastSync.first();
907 907
908 while ( eve ) { 908 while ( eve ) {
909 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 909 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
910 if ( !id.isEmpty() ) { 910 if ( !id.isEmpty() ) {
911 QString des = eve->description(); 911 QString des = eve->description();
912 QString pref = "e"; 912 QString pref = "e";
913 if ( toDelete->type() == "Todo" ) 913 if ( toDelete->type() == "Todo" )
914 pref = "t"; 914 pref = "t";
915 des += pref+ id + ","; 915 des += pref+ id + ",";
916 eve->setReadOnly( false ); 916 eve->setReadOnly( false );
917 eve->setDescription( des ); 917 eve->setDescription( des );
918 //qDebug("setdes %s ", des.latin1()); 918 //qDebug("setdes %s ", des.latin1());
919 eve->setReadOnly( true ); 919 eve->setReadOnly( true );
920 } 920 }
921 eve = lastSync.next(); 921 eve = lastSync.next();
922 } 922 }
923 923
924} 924}
925void CalendarView::checkExternalId( Incidence * inc ) 925void CalendarView::checkExternalId( Incidence * inc )
926{ 926{
927 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 927 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
928 checkExternSyncEvent( lastSync, inc ); 928 checkExternSyncEvent( lastSync, inc );
929 929
930} 930}
931bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 931bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
932{ 932{
933 bool syncOK = true; 933 bool syncOK = true;
934 int addedEvent = 0; 934 int addedEvent = 0;
935 int addedEventR = 0; 935 int addedEventR = 0;
936 int deletedEventR = 0; 936 int deletedEventR = 0;
937 int deletedEventL = 0; 937 int deletedEventL = 0;
938 int changedLocal = 0; 938 int changedLocal = 0;
939 int changedRemote = 0; 939 int changedRemote = 0;
940 //QPtrList<Event> el = local->rawEvents(); 940 //QPtrList<Event> el = local->rawEvents();
941 Event* eventR; 941 Event* eventR;
942 QString uid; 942 QString uid;
943 int take; 943 int take;
944 Event* eventL; 944 Event* eventL;
945 Event* eventRSync; 945 Event* eventRSync;
946 Event* eventLSync; 946 Event* eventLSync;
947 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 947 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
948 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 948 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
949 bool fullDateRange = false; 949 bool fullDateRange = false;
950 local->resetTempSyncStat(); 950 local->resetTempSyncStat();
951 mLastCalendarSync = QDateTime::currentDateTime(); 951 mLastCalendarSync = QDateTime::currentDateTime();
952 QDateTime modifiedCalendar = mLastCalendarSync;; 952 QDateTime modifiedCalendar = mLastCalendarSync;;
953 eventLSync = getLastSyncEvent(); 953 eventLSync = getLastSyncEvent();
954 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 954 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
955 if ( eventR ) { 955 if ( eventR ) {
956 eventRSync = (Event*) eventR->clone(); 956 eventRSync = (Event*) eventR->clone();
957 remote->deleteEvent(eventR ); 957 remote->deleteEvent(eventR );
958 958
959 } else { 959 } else {
960 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 960 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
961 eventRSync = (Event*)eventLSync->clone(); 961 eventRSync = (Event*)eventLSync->clone();
962 } else { 962 } else {
963 fullDateRange = true; 963 fullDateRange = true;
964 eventRSync = new Event(); 964 eventRSync = new Event();
965 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 965 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
966 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 966 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
967 eventRSync->setDtStart( mLastCalendarSync ); 967 eventRSync->setDtStart( mLastCalendarSync );
968 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 968 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
969 eventRSync->setCategories( i18n("SyncEvent") ); 969 eventRSync->setCategories( i18n("SyncEvent") );
970 } 970 }
971 } 971 }
972 if ( eventLSync->dtStart() == mLastCalendarSync ) 972 if ( eventLSync->dtStart() == mLastCalendarSync )
973 fullDateRange = true; 973 fullDateRange = true;
974 974
975 if ( ! fullDateRange ) { 975 if ( ! fullDateRange ) {
976 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 976 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
977 977
978 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 978 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
979 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 979 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
980 fullDateRange = true; 980 fullDateRange = true;
981 } 981 }
982 } 982 }
983 if ( fullDateRange ) 983 if ( fullDateRange )
984 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 984 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
985 else 985 else
986 mLastCalendarSync = eventLSync->dtStart(); 986 mLastCalendarSync = eventLSync->dtStart();
987 // for resyncing if own file has changed 987 // for resyncing if own file has changed
988 if ( mCurrentSyncDevice == "deleteaftersync" ) { 988 if ( mCurrentSyncDevice == "deleteaftersync" ) {
989 mLastCalendarSync = loadedFileVersion; 989 mLastCalendarSync = loadedFileVersion;
990 qDebug("setting mLastCalendarSync "); 990 qDebug("setting mLastCalendarSync ");
991 } 991 }
992 //qDebug("*************************** "); 992 //qDebug("*************************** ");
993 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); 993 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() );
994 QPtrList<Incidence> er = remote->rawIncidences(); 994 QPtrList<Incidence> er = remote->rawIncidences();
995 Incidence* inR = er.first(); 995 Incidence* inR = er.first();
996 Incidence* inL; 996 Incidence* inL;
997 QProgressBar bar( er.count(),0 ); 997 QProgressBar bar( er.count(),0 );
998 bar.setCaption (i18n("Syncing - close to abort!") ); 998 bar.setCaption (i18n("Syncing - close to abort!") );
999 999
1000 int w = 300; 1000 int w = 300;
1001 if ( QApplication::desktop()->width() < 320 ) 1001 if ( QApplication::desktop()->width() < 320 )
1002 w = 220; 1002 w = 220;
1003 int h = bar.sizeHint().height() ; 1003 int h = bar.sizeHint().height() ;
1004 int dw = QApplication::desktop()->width(); 1004 int dw = QApplication::desktop()->width();
1005 int dh = QApplication::desktop()->height(); 1005 int dh = QApplication::desktop()->height();
1006 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1006 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1007 bar.show(); 1007 bar.show();
1008 int modulo = (er.count()/10)+1; 1008 int modulo = (er.count()/10)+1;
1009 int incCounter = 0; 1009 int incCounter = 0;
1010 while ( inR ) { 1010 while ( inR ) {
1011 if ( ! bar.isVisible() ) 1011 if ( ! bar.isVisible() )
1012 return false; 1012 return false;
1013 if ( incCounter % modulo == 0 ) 1013 if ( incCounter % modulo == 0 )
1014 bar.setProgress( incCounter ); 1014 bar.setProgress( incCounter );
1015 ++incCounter; 1015 ++incCounter;
1016 uid = inR->uid(); 1016 uid = inR->uid();
1017 bool skipIncidence = false; 1017 bool skipIncidence = false;
1018 if ( uid.left(15) == QString("last-syncEvent-") ) 1018 if ( uid.left(15) == QString("last-syncEvent-") )
1019 skipIncidence = true; 1019 skipIncidence = true;
1020 QString idS; 1020 QString idS;
1021 qApp->processEvents(); 1021 qApp->processEvents();
1022 if ( !skipIncidence ) { 1022 if ( !skipIncidence ) {
1023 inL = local->incidence( uid ); 1023 inL = local->incidence( uid );
1024 if ( inL ) { // maybe conflict - same uid in both calendars 1024 if ( inL ) { // maybe conflict - same uid in both calendars
1025 int maxrev = inL->revision(); 1025 int maxrev = inL->revision();
1026 if ( maxrev < inR->revision() ) 1026 if ( maxrev < inR->revision() )
1027 maxrev = inR->revision(); 1027 maxrev = inR->revision();
1028 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1028 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1029 //qDebug("take %d %s ", take, inL->summary().latin1()); 1029 //qDebug("take %d %s ", take, inL->summary().latin1());
1030 if ( take == 3 ) 1030 if ( take == 3 )
1031 return false; 1031 return false;
1032 if ( take == 1 ) {// take local 1032 if ( take == 1 ) {// take local
1033 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1033 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1034 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1034 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1035 else 1035 else
1036 idS = inR->IDStr(); 1036 idS = inR->IDStr();
1037 remote->deleteIncidence( inR ); 1037 remote->deleteIncidence( inR );
1038 if ( inL->revision() < maxrev ) 1038 if ( inL->revision() < maxrev )
1039 inL->setRevision( maxrev ); 1039 inL->setRevision( maxrev );
1040 inR = inL->clone(); 1040 inR = inL->clone();
1041 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1041 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1042 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1042 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1043 inR->setIDStr( idS ); 1043 inR->setIDStr( idS );
1044 remote->addIncidence( inR ); 1044 remote->addIncidence( inR );
1045 ++changedRemote; 1045 ++changedRemote;
1046 } else { 1046 } else {
1047 if ( inR->revision() < maxrev ) 1047 if ( inR->revision() < maxrev )
1048 inR->setRevision( maxrev ); 1048 inR->setRevision( maxrev );
1049 idS = inL->IDStr(); 1049 idS = inL->IDStr();
1050 local->deleteIncidence( inL ); 1050 local->deleteIncidence( inL );
1051 inL = inR->clone(); 1051 inL = inR->clone();
1052 inL->setIDStr( idS ); 1052 inL->setIDStr( idS );
1053 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1053 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1054 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1054 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1055 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1055 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1056 } 1056 }
1057 local->addIncidence( inL ); 1057 local->addIncidence( inL );
1058 ++changedLocal; 1058 ++changedLocal;
1059 } 1059 }
1060 } 1060 }
1061 } else { // no conflict 1061 } else { // no conflict
1062 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1062 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1063 QString des = eventLSync->description(); 1063 QString des = eventLSync->description();
1064 QString pref = "e"; 1064 QString pref = "e";
1065 if ( inR->type() == "Todo" ) 1065 if ( inR->type() == "Todo" )
1066 pref = "t"; 1066 pref = "t";
1067 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1067 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1068 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1068 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1069 //remote->deleteIncidence( inR ); 1069 //remote->deleteIncidence( inR );
1070 ++deletedEventR; 1070 ++deletedEventR;
1071 } else { 1071 } else {
1072 inR->setLastModified( modifiedCalendar ); 1072 inR->setLastModified( modifiedCalendar );
1073 inL = inR->clone(); 1073 inL = inR->clone();
1074 local->addIncidence( inL ); 1074 local->addIncidence( inL );
1075 ++addedEvent; 1075 ++addedEvent;
1076 } 1076 }
1077 } else { 1077 } else {
1078 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1078 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1079 inR->setLastModified( modifiedCalendar ); 1079 inR->setLastModified( modifiedCalendar );
1080 local->addIncidence( inR->clone() ); 1080 local->addIncidence( inR->clone() );
1081 ++addedEvent; 1081 ++addedEvent;
1082 } else { 1082 } else {
1083 checkExternSyncEvent(eventRSyncSharp, inR); 1083 checkExternSyncEvent(eventRSyncSharp, inR);
1084 remote->deleteIncidence( inR ); 1084 remote->deleteIncidence( inR );
1085 ++deletedEventR; 1085 ++deletedEventR;
1086 } 1086 }
1087 } 1087 }
1088 } 1088 }
1089 } 1089 }
1090 inR = er.next(); 1090 inR = er.next();
1091 } 1091 }
1092 QPtrList<Incidence> el = local->rawIncidences(); 1092 QPtrList<Incidence> el = local->rawIncidences();
1093 inL = el.first(); 1093 inL = el.first();
1094 modulo = (el.count()/10)+1; 1094 modulo = (el.count()/10)+1;
1095 bar.setCaption (i18n("Add / remove events") ); 1095 bar.setCaption (i18n("Add / remove events") );
1096 bar.setTotalSteps ( el.count() ) ; 1096 bar.setTotalSteps ( el.count() ) ;
1097 bar.show(); 1097 bar.show();
1098 incCounter = 0; 1098 incCounter = 0;
1099 1099
1100 while ( inL ) { 1100 while ( inL ) {
1101 1101
1102 qApp->processEvents(); 1102 qApp->processEvents();
1103 if ( ! bar.isVisible() ) 1103 if ( ! bar.isVisible() )
1104 return false; 1104 return false;
1105 if ( incCounter % modulo == 0 ) 1105 if ( incCounter % modulo == 0 )
1106 bar.setProgress( incCounter ); 1106 bar.setProgress( incCounter );
1107 ++incCounter; 1107 ++incCounter;
1108 uid = inL->uid(); 1108 uid = inL->uid();
1109 bool skipIncidence = false; 1109 bool skipIncidence = false;
1110 if ( uid.left(15) == QString("last-syncEvent-") ) 1110 if ( uid.left(15) == QString("last-syncEvent-") )
1111 skipIncidence = true; 1111 skipIncidence = true;
1112 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) 1112 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
1113 skipIncidence = true; 1113 skipIncidence = true;
1114 if ( !skipIncidence ) { 1114 if ( !skipIncidence ) {
1115 inR = remote->incidence( uid ); 1115 inR = remote->incidence( uid );
1116 if ( ! inR ) { 1116 if ( ! inR ) {
1117 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1117 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1118 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1118 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1119 checkExternSyncEvent(eventLSyncSharp, inL); 1119 checkExternSyncEvent(eventLSyncSharp, inL);
1120 local->deleteIncidence( inL ); 1120 local->deleteIncidence( inL );
1121 ++deletedEventL; 1121 ++deletedEventL;
1122 } else { 1122 } else {
1123 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { 1123 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
1124 inL->removeID(mCurrentSyncDevice ); 1124 inL->removeID(mCurrentSyncDevice );
1125 ++addedEventR; 1125 ++addedEventR;
1126 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1126 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1127 inL->setLastModified( modifiedCalendar ); 1127 inL->setLastModified( modifiedCalendar );
1128 inR = inL->clone(); 1128 inR = inL->clone();
1129 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1129 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1130 remote->addIncidence( inR ); 1130 remote->addIncidence( inR );
1131 } 1131 }
1132 } 1132 }
1133 } else { 1133 } else {
1134 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1134 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1135 checkExternSyncEvent(eventLSyncSharp, inL); 1135 checkExternSyncEvent(eventLSyncSharp, inL);
1136 local->deleteIncidence( inL ); 1136 local->deleteIncidence( inL );
1137 ++deletedEventL; 1137 ++deletedEventL;
1138 } else { 1138 } else {
1139 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { 1139 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
1140 ++addedEventR; 1140 ++addedEventR;
1141 inL->setLastModified( modifiedCalendar ); 1141 inL->setLastModified( modifiedCalendar );
1142 remote->addIncidence( inL->clone() ); 1142 remote->addIncidence( inL->clone() );
1143 } 1143 }
1144 } 1144 }
1145 } 1145 }
1146 } 1146 }
1147 } 1147 }
1148 inL = el.next(); 1148 inL = el.next();
1149 } 1149 }
1150 int delFut = 0; 1150 int delFut = 0;
1151 if ( KOPrefs::instance()->mWriteBackInFuture ) { 1151 if ( KOPrefs::instance()->mWriteBackInFuture ) {
1152 er = remote->rawIncidences(); 1152 er = remote->rawIncidences();
1153 inR = er.first(); 1153 inR = er.first();
1154 QDateTime dt; 1154 QDateTime dt;
1155 QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); 1155 QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
1156 QDateTime end = cur.addDays( (KOPrefs::instance()->mWriteBackInFuture +1 ) *7 ); 1156 QDateTime end = cur.addDays( (KOPrefs::instance()->mWriteBackInFuture +1 ) *7 );
1157 while ( inR ) { 1157 while ( inR ) {
1158 if ( inR->type() == "Todo" ) { 1158 if ( inR->type() == "Todo" ) {
1159 Todo * t = (Todo*)inR; 1159 Todo * t = (Todo*)inR;
1160 if ( t->hasDueDate() ) 1160 if ( t->hasDueDate() )
1161 dt = t->dtDue(); 1161 dt = t->dtDue();
1162 else 1162 else
1163 dt = cur.addSecs( 62 ); 1163 dt = cur.addSecs( 62 );
1164 } 1164 }
1165 else if (inR->type() == "Event" ) { 1165 else if (inR->type() == "Event" ) {
1166 bool ok; 1166 bool ok;
1167 dt = inR->getNextOccurence( cur, &ok ); 1167 dt = inR->getNextOccurence( cur, &ok );
1168 if ( !ok ) 1168 if ( !ok )
1169 dt = cur.addSecs( -62 ); 1169 dt = cur.addSecs( -62 );
1170 } 1170 }
1171 else 1171 else
1172 dt = inR->dtStart(); 1172 dt = inR->dtStart();
1173 if ( dt < cur || dt > end ) { 1173 if ( dt < cur || dt > end ) {
1174 remote->deleteIncidence( inR ); 1174 remote->deleteIncidence( inR );
1175 ++delFut; 1175 ++delFut;
1176 } 1176 }
1177 inR = er.next(); 1177 inR = er.next();
1178 } 1178 }
1179 } 1179 }
1180 bar.hide(); 1180 bar.hide();
1181 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1181 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1182 eventLSync->setReadOnly( false ); 1182 eventLSync->setReadOnly( false );
1183 eventLSync->setDtStart( mLastCalendarSync ); 1183 eventLSync->setDtStart( mLastCalendarSync );
1184 eventRSync->setDtStart( mLastCalendarSync ); 1184 eventRSync->setDtStart( mLastCalendarSync );
1185 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1185 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1186 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1186 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1187 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1187 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1188 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1188 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1189 eventLSync->setReadOnly( true ); 1189 eventLSync->setReadOnly( true );
1190 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 1190 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
1191 remote->addEvent( eventRSync ); 1191 remote->addEvent( eventRSync );
1192 QString mes; 1192 QString mes;
1193 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 ); 1193 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR );
1194 QString delmess; 1194 QString delmess;
1195 if ( delFut ) { 1195 if ( delFut ) {
1196 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\n"),delFut, KOPrefs::instance()->mWriteBackInFuture ); 1196 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\n"),delFut, KOPrefs::instance()->mWriteBackInFuture );
1197 mes += delmess; 1197 mes += delmess;
1198 } 1198 }
1199 if ( KOPrefs::instance()->mShowSyncSummary ) { 1199 if ( KOPrefs::instance()->mShowSyncSummary ) {
1200 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); 1200 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") );
1201 } 1201 }
1202 qDebug( mes ); 1202 qDebug( mes );
1203 mCalendar->checkAlarmForIncidence( 0, true ); 1203 mCalendar->checkAlarmForIncidence( 0, true );
1204 return syncOK; 1204 return syncOK;
1205} 1205}
1206 1206
1207void CalendarView::setSyncDevice( QString s ) 1207void CalendarView::setSyncDevice( QString s )
1208{ 1208{
1209 mCurrentSyncDevice= s; 1209 mCurrentSyncDevice= s;
1210} 1210}
1211void CalendarView::setSyncName( QString s ) 1211void CalendarView::setSyncName( QString s )
1212{ 1212{
1213 mCurrentSyncName= s; 1213 mCurrentSyncName= s;
1214} 1214}
1215bool CalendarView::syncCalendar(QString filename, int mode) 1215bool CalendarView::syncCalendar(QString filename, int mode)
1216{ 1216{
1217 mGlobalSyncMode = SYNC_MODE_NORMAL; 1217 mGlobalSyncMode = SYNC_MODE_NORMAL;
1218 CalendarLocal* calendar = new CalendarLocal(); 1218 CalendarLocal* calendar = new CalendarLocal();
1219 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1219 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1220 FileStorage* storage = new FileStorage( calendar ); 1220 FileStorage* storage = new FileStorage( calendar );
1221 bool syncOK = false; 1221 bool syncOK = false;
1222 storage->setFileName( filename ); 1222 storage->setFileName( filename );
1223 // qDebug("loading ... "); 1223 // qDebug("loading ... ");
1224 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { 1224 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) {
1225 getEventViewerDialog()->setSyncMode( true ); 1225 getEventViewerDialog()->setSyncMode( true );
1226 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1226 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1227 getEventViewerDialog()->setSyncMode( false ); 1227 getEventViewerDialog()->setSyncMode( false );
1228 if ( syncOK ) { 1228 if ( syncOK ) {
1229 if ( KOPrefs::instance()->mWriteBackFile ) 1229 if ( KOPrefs::instance()->mWriteBackFile )
1230 { 1230 {
1231 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 1231 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
1232 storage->save(); 1232 storage->save();
1233 } 1233 }
1234 } 1234 }
1235 setModified( true ); 1235 setModified( true );
1236 } 1236 }
1237 delete storage; 1237 delete storage;
1238 delete calendar; 1238 delete calendar;
1239 if ( syncOK ) 1239 if ( syncOK )
1240 updateView(); 1240 updateView();
1241 return syncOK; 1241 return syncOK;
1242} 1242}
1243void CalendarView::syncPhone() 1243void CalendarView::syncPhone()
1244{ 1244{
1245 syncExternal( 1 ); 1245 syncExternal( 1 );
1246} 1246}
1247void CalendarView::syncExternal( int mode ) 1247void CalendarView::syncExternal( int mode )
1248{ 1248{
1249 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1249 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1250 //mCurrentSyncDevice = "sharp-DTM"; 1250 //mCurrentSyncDevice = "sharp-DTM";
1251 if ( KOPrefs::instance()->mAskForPreferences ) 1251 if ( KOPrefs::instance()->mAskForPreferences )
1252 edit_sync_options(); 1252 edit_sync_options();
1253 qApp->processEvents(); 1253 qApp->processEvents();
1254 CalendarLocal* calendar = new CalendarLocal(); 1254 CalendarLocal* calendar = new CalendarLocal();
1255 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1255 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1256 bool syncOK = false; 1256 bool syncOK = false;
1257 bool loadSuccess = false; 1257 bool loadSuccess = false;
1258 PhoneFormat* phoneFormat = 0; 1258 PhoneFormat* phoneFormat = 0;
1259#ifndef DESKTOP_VERSION 1259#ifndef DESKTOP_VERSION
1260 SharpFormat* sharpFormat = 0; 1260 SharpFormat* sharpFormat = 0;
1261 if ( mode == 0 ) { // sharp 1261 if ( mode == 0 ) { // sharp
1262 sharpFormat = new SharpFormat () ; 1262 sharpFormat = new SharpFormat () ;
1263 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1263 loadSuccess = sharpFormat->load( calendar, mCalendar );
1264 1264
1265 } else 1265 } else
1266#endif 1266#endif
1267 if ( mode == 1 ) { // phone 1267 if ( mode == 1 ) { // phone
1268 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1268 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1269 KOPrefs::instance()->mPhoneDevice, 1269 KOPrefs::instance()->mPhoneDevice,
1270 KOPrefs::instance()->mPhoneConnection, 1270 KOPrefs::instance()->mPhoneConnection,
1271 KOPrefs::instance()->mPhoneModel); 1271 KOPrefs::instance()->mPhoneModel);
1272 loadSuccess = phoneFormat->load( calendar,mCalendar); 1272 loadSuccess = phoneFormat->load( calendar,mCalendar);
1273 1273
1274 } else 1274 } else
1275 return; 1275 return;
1276 if ( loadSuccess ) { 1276 if ( loadSuccess ) {
1277 getEventViewerDialog()->setSyncMode( true ); 1277 getEventViewerDialog()->setSyncMode( true );
1278 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); 1278 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
1279 getEventViewerDialog()->setSyncMode( false ); 1279 getEventViewerDialog()->setSyncMode( false );
1280 qApp->processEvents(); 1280 qApp->processEvents();
1281 if ( syncOK ) { 1281 if ( syncOK ) {
1282 if ( KOPrefs::instance()->mWriteBackFile ) 1282 if ( KOPrefs::instance()->mWriteBackFile )
1283 { 1283 {
1284 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1284 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1285 Incidence* inc = iL.first(); 1285 Incidence* inc = iL.first();
1286 if ( phoneFormat ) { 1286 if ( phoneFormat ) {
1287 while ( inc ) { 1287 while ( inc ) {
1288 inc->removeID(mCurrentSyncDevice); 1288 inc->removeID(mCurrentSyncDevice);
1289 inc = iL.next(); 1289 inc = iL.next();
1290 } 1290 }
1291 } 1291 }
1292#ifndef DESKTOP_VERSION 1292#ifndef DESKTOP_VERSION
1293 if ( sharpFormat ) 1293 if ( sharpFormat )
1294 sharpFormat->save(calendar); 1294 sharpFormat->save(calendar);
1295#endif 1295#endif
1296 if ( phoneFormat ) 1296 if ( phoneFormat )
1297 phoneFormat->save(calendar); 1297 phoneFormat->save(calendar);
1298 iL = calendar->rawIncidences(); 1298 iL = calendar->rawIncidences();
1299 inc = iL.first(); 1299 inc = iL.first();
1300 Incidence* loc; 1300 Incidence* loc;
1301 while ( inc ) { 1301 while ( inc ) {
1302 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1302 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1303 loc = mCalendar->incidence(inc->uid() ); 1303 loc = mCalendar->incidence(inc->uid() );
1304 if ( loc ) { 1304 if ( loc ) {
1305 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1305 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1306 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1306 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1307 } 1307 }
1308 } 1308 }
1309 inc = iL.next(); 1309 inc = iL.next();
1310 } 1310 }
1311 Incidence* lse = getLastSyncEvent(); 1311 Incidence* lse = getLastSyncEvent();
1312 if ( lse ) { 1312 if ( lse ) {
1313 lse->setReadOnly( false ); 1313 lse->setReadOnly( false );
1314 lse->setDescription( "" ); 1314 lse->setDescription( "" );
1315 lse->setReadOnly( true ); 1315 lse->setReadOnly( true );
1316 } 1316 }
1317 } 1317 }
1318 } 1318 }
1319 setModified( true ); 1319 setModified( true );
1320 } else { 1320 } else {
1321 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1321 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1322 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1322 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1323 question, i18n("Ok")) ; 1323 question, i18n("Ok")) ;
1324 1324
1325 } 1325 }
1326 delete calendar; 1326 delete calendar;
1327 updateView(); 1327 updateView();
1328 return ;//syncOK; 1328 return ;//syncOK;
1329 1329
1330} 1330}
1331void CalendarView::syncSharp() 1331void CalendarView::syncSharp()
1332{ 1332{
1333 syncExternal( 0 ); 1333 syncExternal( 0 );
1334 1334
1335} 1335}
1336 1336
1337 1337
1338//#include <kabc/stdaddressbook.h> 1338//#include <kabc/stdaddressbook.h>
1339bool CalendarView::importBday() 1339bool CalendarView::importBday()
1340{ 1340{
1341#if 0 1341#if 0
1342 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1342 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1343 KABC::AddressBook::Iterator it; 1343 KABC::AddressBook::Iterator it;
1344 int count = 0; 1344 int count = 0;
1345 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1345 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1346 ++count; 1346 ++count;
1347 } 1347 }
1348 QProgressBar bar(count,0 ); 1348 QProgressBar bar(count,0 );
1349 int w = 300; 1349 int w = 300;
1350 if ( QApplication::desktop()->width() < 320 ) 1350 if ( QApplication::desktop()->width() < 320 )
1351 w = 220; 1351 w = 220;
1352 int h = bar.sizeHint().height() ; 1352 int h = bar.sizeHint().height() ;
1353 int dw = QApplication::desktop()->width(); 1353 int dw = QApplication::desktop()->width();
1354 int dh = QApplication::desktop()->height(); 1354 int dh = QApplication::desktop()->height();
1355 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1355 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1356 bar.show(); 1356 bar.show();
1357 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1357 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1358 qApp->processEvents(); 1358 qApp->processEvents();
1359 count = 0; 1359 count = 0;
1360 int addCount = 0; 1360 int addCount = 0;
1361 KCal::Attendee* a = 0; 1361 KCal::Attendee* a = 0;
1362 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1362 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1363 if ( ! bar.isVisible() ) 1363 if ( ! bar.isVisible() )
1364 return false; 1364 return false;
1365 bar.setProgress( count++ ); 1365 bar.setProgress( count++ );
1366 qApp->processEvents(); 1366 qApp->processEvents();
1367 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1367 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1368 if ( (*it).birthday().date().isValid() ){ 1368 if ( (*it).birthday().date().isValid() ){
1369 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1369 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1370 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1370 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1371 ++addCount; 1371 ++addCount;
1372 } 1372 }
1373 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1373 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1374 if ( anni.isValid() ){ 1374 if ( anni.isValid() ){
1375 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1375 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1376 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1376 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1377 ++addCount; 1377 ++addCount;
1378 } 1378 }
1379 } 1379 }
1380 updateView(); 1380 updateView();
1381 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1381 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1382#endif 1382#endif
1383 return true; 1383 return true;
1384} 1384}
1385 1385
1386bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1386bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1387{ 1387{
1388 //qDebug("addAnni "); 1388 //qDebug("addAnni ");
1389 Event * ev = new Event(); 1389 Event * ev = new Event();
1390 if ( a ) { 1390 if ( a ) {
1391 ev->addAttendee( a ); 1391 ev->addAttendee( a );
1392 } 1392 }
1393 QString kind; 1393 QString kind;
1394 if ( birthday ) 1394 if ( birthday )
1395 kind = i18n( "Birthday" ); 1395 kind = i18n( "Birthday" );
1396 else 1396 else
1397 kind = i18n( "Anniversary" ); 1397 kind = i18n( "Anniversary" );
1398 ev->setSummary( name + " - " + kind ); 1398 ev->setSummary( name + " - " + kind );
1399 ev->setOrganizer( "nobody@nowhere" ); 1399 ev->setOrganizer( "nobody@nowhere" );
1400 ev->setCategories( kind ); 1400 ev->setCategories( kind );
1401 ev->setDtStart( QDateTime(date) ); 1401 ev->setDtStart( QDateTime(date) );
1402 ev->setDtEnd( QDateTime(date) ); 1402 ev->setDtEnd( QDateTime(date) );
1403 ev->setFloats( true ); 1403 ev->setFloats( true );
1404 Recurrence * rec = ev->recurrence(); 1404 Recurrence * rec = ev->recurrence();
1405 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1405 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1406 rec->addYearlyNum( date.month() ); 1406 rec->addYearlyNum( date.month() );
1407 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1407 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1408 delete ev; 1408 delete ev;
1409 return false; 1409 return false;
1410 } 1410 }
1411 return true; 1411 return true;
1412 1412
1413} 1413}
1414bool CalendarView::importQtopia( const QString &categories, 1414bool CalendarView::importQtopia( const QString &categories,
1415 const QString &datebook, 1415 const QString &datebook,
1416 const QString &todolist ) 1416 const QString &todolist )
1417{ 1417{
1418 1418
1419 QtopiaFormat qtopiaFormat; 1419 QtopiaFormat qtopiaFormat;
1420 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1420 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1421 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1421 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1422 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1422 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1423 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1423 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1424 1424
1425 updateView(); 1425 updateView();
1426 return true; 1426 return true;
1427 1427
1428#if 0 1428#if 0
1429 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1429 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1430 mCurrentSyncDevice = "qtopia-XML"; 1430 mCurrentSyncDevice = "qtopia-XML";
1431 if ( KOPrefs::instance()->mAskForPreferences ) 1431 if ( KOPrefs::instance()->mAskForPreferences )
1432 edit_sync_options(); 1432 edit_sync_options();
1433 qApp->processEvents(); 1433 qApp->processEvents();
1434 CalendarLocal* calendar = new CalendarLocal(); 1434 CalendarLocal* calendar = new CalendarLocal();
1435 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1435 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1436 bool syncOK = false; 1436 bool syncOK = false;
1437 QtopiaFormat qtopiaFormat; 1437 QtopiaFormat qtopiaFormat;
1438 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1438 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1439 bool loadOk = true; 1439 bool loadOk = true;
1440 if ( !categories.isEmpty() ) 1440 if ( !categories.isEmpty() )
1441 loadOk = qtopiaFormat.load( calendar, categories ); 1441 loadOk = qtopiaFormat.load( calendar, categories );
1442 if ( loadOk && !datebook.isEmpty() ) 1442 if ( loadOk && !datebook.isEmpty() )
1443 loadOk = qtopiaFormat.load( calendar, datebook ); 1443 loadOk = qtopiaFormat.load( calendar, datebook );
1444 if ( loadOk && !todolist.isEmpty() ) 1444 if ( loadOk && !todolist.isEmpty() )
1445 loadOk = qtopiaFormat.load( calendar, todolist ); 1445 loadOk = qtopiaFormat.load( calendar, todolist );
1446 1446
1447 if ( loadOk ) { 1447 if ( loadOk ) {
1448 getEventViewerDialog()->setSyncMode( true ); 1448 getEventViewerDialog()->setSyncMode( true );
1449 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); 1449 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
1450 getEventViewerDialog()->setSyncMode( false ); 1450 getEventViewerDialog()->setSyncMode( false );
1451 qApp->processEvents(); 1451 qApp->processEvents();
1452 if ( syncOK ) { 1452 if ( syncOK ) {
1453 if ( KOPrefs::instance()->mWriteBackFile ) 1453 if ( KOPrefs::instance()->mWriteBackFile )
1454 { 1454 {
1455 // write back XML file 1455 // write back XML file
1456 1456
1457 } 1457 }
1458 setModified( true ); 1458 setModified( true );
1459 } 1459 }
1460 } else { 1460 } else {
1461 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1461 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1462 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1462 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1463 question, i18n("Ok")) ; 1463 question, i18n("Ok")) ;
1464 } 1464 }
1465 delete calendar; 1465 delete calendar;
1466 updateView(); 1466 updateView();
1467 return syncOK; 1467 return syncOK;
1468 1468
1469 1469
1470#endif 1470#endif
1471 1471
1472} 1472}
1473 1473
1474void CalendarView::setSyncEventsReadOnly() 1474void CalendarView::setSyncEventsReadOnly()
1475{ 1475{
1476 Event * ev; 1476 Event * ev;
1477 QPtrList<Event> eL = mCalendar->rawEvents(); 1477 QPtrList<Event> eL = mCalendar->rawEvents();
1478 ev = eL.first(); 1478 ev = eL.first();
1479 while ( ev ) { 1479 while ( ev ) {
1480 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1480 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1481 ev->setReadOnly( true ); 1481 ev->setReadOnly( true );
1482 ev = eL.next(); 1482 ev = eL.next();
1483 } 1483 }
1484} 1484}
1485bool CalendarView::openCalendar(QString filename, bool merge) 1485bool CalendarView::openCalendar(QString filename, bool merge)
1486{ 1486{
1487 1487
1488 if (filename.isEmpty()) { 1488 if (filename.isEmpty()) {
1489 return false; 1489 return false;
1490 } 1490 }
1491 1491
1492 if (!QFile::exists(filename)) { 1492 if (!QFile::exists(filename)) {
1493 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1493 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1494 return false; 1494 return false;
1495 } 1495 }
1496 1496
1497 globalFlagBlockAgenda = 1; 1497 globalFlagBlockAgenda = 1;
1498 if (!merge) mCalendar->close(); 1498 if (!merge) mCalendar->close();
1499 1499
1500 mStorage->setFileName( filename ); 1500 mStorage->setFileName( filename );
1501 1501
1502 if ( mStorage->load(KOPrefs::instance()->mUseQuicksave) ) { 1502 if ( mStorage->load(KOPrefs::instance()->mUseQuicksave) ) {
1503 if ( merge ) ;//setModified( true ); 1503 if ( merge ) ;//setModified( true );
1504 else { 1504 else {
1505 //setModified( true ); 1505 //setModified( true );
1506 mViewManager->setDocumentId( filename ); 1506 mViewManager->setDocumentId( filename );
1507 mDialogManager->setDocumentId( filename ); 1507 mDialogManager->setDocumentId( filename );
1508 mTodoList->setDocumentId( filename ); 1508 mTodoList->setDocumentId( filename );
1509 } 1509 }
1510 globalFlagBlockAgenda = 2; 1510 globalFlagBlockAgenda = 2;
1511 // if ( getLastSyncEvent() ) 1511 // if ( getLastSyncEvent() )
1512 // getLastSyncEvent()->setReadOnly( true ); 1512 // getLastSyncEvent()->setReadOnly( true );
1513 mCalendar->reInitAlarmSettings(); 1513 mCalendar->reInitAlarmSettings();
1514 setSyncEventsReadOnly(); 1514 setSyncEventsReadOnly();
1515 updateUnmanagedViews(); 1515 updateUnmanagedViews();
1516 updateView(); 1516 updateView();
1517 if ( filename != MainWindow::defaultFileName() ) 1517 if ( filename != MainWindow::defaultFileName() )
1518 saveCalendar( MainWindow::defaultFileName() ); 1518 saveCalendar( MainWindow::defaultFileName() );
1519 loadedFileVersion = QDateTime::currentDateTime(); 1519 loadedFileVersion = QDateTime::currentDateTime();
1520 return true; 1520 return true;
1521 } else { 1521 } else {
1522 // while failing to load, the calendar object could 1522 // while failing to load, the calendar object could
1523 // have become partially populated. Clear it out. 1523 // have become partially populated. Clear it out.
1524 if ( !merge ) mCalendar->close(); 1524 if ( !merge ) mCalendar->close();
1525 1525
1526 KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1526 KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1527 1527
1528 globalFlagBlockAgenda = 2; 1528 globalFlagBlockAgenda = 2;
1529 updateView(); 1529 updateView();
1530 } 1530 }
1531 return false; 1531 return false;
1532} 1532}
1533void CalendarView::setLoadedFileVersion(QDateTime dt) 1533void CalendarView::setLoadedFileVersion(QDateTime dt)
1534{ 1534{
1535 loadedFileVersion = dt; 1535 loadedFileVersion = dt;
1536} 1536}
1537bool CalendarView::checkFileChanged(QString fn) 1537bool CalendarView::checkFileChanged(QString fn)
1538{ 1538{
1539 QFileInfo finf ( fn ); 1539 QFileInfo finf ( fn );
1540 if ( !finf.exists() ) 1540 if ( !finf.exists() )
1541 return true; 1541 return true;
1542 QDateTime dt = finf.lastModified (); 1542 QDateTime dt = finf.lastModified ();
1543 if ( dt <= loadedFileVersion ) 1543 if ( dt <= loadedFileVersion )
1544 return false; 1544 return false;
1545 return true; 1545 return true;
1546 1546
1547} 1547}
1548void CalendarView::watchSavedFile()
1549{
1550 QFileInfo finf ( MainWindow::defaultFileName());
1551 if ( !finf.exists() )
1552 return;
1553 QDateTime dt = finf.lastModified ();
1554 if ( dt < loadedFileVersion ) {
1555 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1556 return;
1557 }
1558 loadedFileVersion = dt;
1559}
1560
1548bool CalendarView::checkFileVersion(QString fn) 1561bool CalendarView::checkFileVersion(QString fn)
1549{ 1562{
1550 QFileInfo finf ( fn ); 1563 QFileInfo finf ( fn );
1551 if ( !finf.exists() ) 1564 if ( !finf.exists() )
1552 return true; 1565 return true;
1553 QDateTime dt = finf.lastModified (); 1566 QDateTime dt = finf.lastModified ();
1554 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1567 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1555 //qDebug("file on disk version %s",dt.toString().latin1()); 1568 //qDebug("file on disk version %s",dt.toString().latin1());
1556 if ( dt <= loadedFileVersion ) 1569 if ( dt <= loadedFileVersion )
1557 return true; 1570 return true;
1558 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)) , 1571 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) ,
1559 i18n("KO/Pi Warning"),i18n("Overwrite"), 1572 i18n("KO/Pi Warning"),i18n("Overwrite"),
1560 i18n("Sync+save")); 1573 i18n("Sync+save"));
1561 1574
1562 if ( km == KMessageBox::Cancel ) 1575 if ( km == KMessageBox::Cancel )
1563 return false; 1576 return false;
1564 if ( km == KMessageBox::Yes ) 1577 if ( km == KMessageBox::Yes )
1565 return true; 1578 return true;
1566 1579
1567 setSyncDevice("deleteaftersync" ); 1580 setSyncDevice("deleteaftersync" );
1568 KOPrefs::instance()->mAskForPreferences = true; 1581 KOPrefs::instance()->mAskForPreferences = true;
1569 KOPrefs::instance()->mSyncAlgoPrefs = 3; 1582 KOPrefs::instance()->mSyncAlgoPrefs = 3;
1570 KOPrefs::instance()->mWriteBackFile = false; 1583 KOPrefs::instance()->mWriteBackFile = false;
1571 KOPrefs::instance()->mWriteBackExistingOnly = false; 1584 KOPrefs::instance()->mWriteBackExistingOnly = false;
1572 KOPrefs::instance()->mShowSyncSummary = false; 1585 KOPrefs::instance()->mShowSyncSummary = false;
1573 syncCalendar( fn, 3 ); 1586 syncCalendar( fn, 3 );
1574 Event * e = getLastSyncEvent(); 1587 Event * e = getLastSyncEvent();
1575 mCalendar->deleteEvent ( e ); 1588 mCalendar->deleteEvent ( e );
1576 updateView(); 1589 updateView();
1577 return true; 1590 return true;
1578} 1591}
1579 1592
1580bool CalendarView::saveCalendar( QString filename ) 1593bool CalendarView::saveCalendar( QString filename )
1581{ 1594{
1582 1595
1583 // Store back all unsaved data into calendar object 1596 // Store back all unsaved data into calendar object
1584 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1597 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1585 if ( mViewManager->currentView() ) 1598 if ( mViewManager->currentView() )
1586 mViewManager->currentView()->flushView(); 1599 mViewManager->currentView()->flushView();
1587 1600
1588 //mStorage->setFileName( filename ); 1601 //mStorage->setFileName( filename );
1589 1602
1590 mStorage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 1603 mStorage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
1591 mStorage->setFileName( filename ); 1604 mStorage->setFileName( filename );
1592 bool success; 1605 bool success;
1593 success = mStorage->save(); 1606 success = mStorage->save();
1594 if ( !success ) { 1607 if ( !success ) {
1595 return false; 1608 return false;
1596 } 1609 }
1597 1610
1598 return true; 1611 return true;
1599} 1612}
1600 1613
1601void CalendarView::closeCalendar() 1614void CalendarView::closeCalendar()
1602{ 1615{
1603 1616
1604 // child windows no longer valid 1617 // child windows no longer valid
1605 emit closingDown(); 1618 emit closingDown();
1606 1619
1607 mCalendar->close(); 1620 mCalendar->close();
1608 setModified(false); 1621 setModified(false);
1609 updateView(); 1622 updateView();
1610} 1623}
1611 1624
1612void CalendarView::archiveCalendar() 1625void CalendarView::archiveCalendar()
1613{ 1626{
1614 mDialogManager->showArchiveDialog(); 1627 mDialogManager->showArchiveDialog();
1615} 1628}
1616 1629
1617 1630
1618void CalendarView::readSettings() 1631void CalendarView::readSettings()
1619{ 1632{
1620 1633
1621 1634
1622 // mViewManager->showAgendaView(); 1635 // mViewManager->showAgendaView();
1623 QString str; 1636 QString str;
1624 //qDebug("CalendarView::readSettings() "); 1637 //qDebug("CalendarView::readSettings() ");
1625 // read settings from the KConfig, supplying reasonable 1638 // read settings from the KConfig, supplying reasonable
1626 // defaults where none are to be found 1639 // defaults where none are to be found
1627 KConfig *config = KOGlobals::config(); 1640 KConfig *config = KOGlobals::config();
1628#ifndef KORG_NOSPLITTER 1641#ifndef KORG_NOSPLITTER
1629 config->setGroup("KOrganizer Geometry"); 1642 config->setGroup("KOrganizer Geometry");
1630 1643
1631 QValueList<int> sizes = config->readIntListEntry("Separator1"); 1644 QValueList<int> sizes = config->readIntListEntry("Separator1");
1632 if (sizes.count() != 2) { 1645 if (sizes.count() != 2) {
1633 sizes << mDateNavigator->minimumSizeHint().width(); 1646 sizes << mDateNavigator->minimumSizeHint().width();
1634 sizes << 300; 1647 sizes << 300;
1635 } 1648 }
1636 mPanner->setSizes(sizes); 1649 mPanner->setSizes(sizes);
1637 1650
1638 sizes = config->readIntListEntry("Separator2"); 1651 sizes = config->readIntListEntry("Separator2");
1639 if ( ( mResourceView && sizes.count() == 4 ) || 1652 if ( ( mResourceView && sizes.count() == 4 ) ||
1640 ( !mResourceView && sizes.count() == 3 ) ) { 1653 ( !mResourceView && sizes.count() == 3 ) ) {
1641 mLeftSplitter->setSizes(sizes); 1654 mLeftSplitter->setSizes(sizes);
1642 } 1655 }
1643#endif 1656#endif
1644 globalFlagBlockAgenda = 1; 1657 globalFlagBlockAgenda = 1;
1645 mViewManager->showAgendaView(); 1658 mViewManager->showAgendaView();
1646 //mViewManager->readSettings( config ); 1659 //mViewManager->readSettings( config );
1647 mTodoList->restoreLayout(config,QString("Todo Layout")); 1660 mTodoList->restoreLayout(config,QString("Todo Layout"));
1648 readFilterSettings(config); 1661 readFilterSettings(config);
1649 config->setGroup( "Views" ); 1662 config->setGroup( "Views" );
1650 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 1663 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
1651 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 1664 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
1652 else if ( dateCount == 7 ) mNavigator->selectWeek(); 1665 else if ( dateCount == 7 ) mNavigator->selectWeek();
1653 else mNavigator->selectDates( dateCount ); 1666 else mNavigator->selectDates( dateCount );
1654 // mViewManager->readSettings( config ); 1667 // mViewManager->readSettings( config );
1655 updateConfig(); 1668 updateConfig();
1656 globalFlagBlockAgenda = 2; 1669 globalFlagBlockAgenda = 2;
1657 mViewManager->readSettings( config ); 1670 mViewManager->readSettings( config );
1658#ifdef DESKTOP_VERSION 1671#ifdef DESKTOP_VERSION
1659 config->setGroup("WidgetLayout"); 1672 config->setGroup("WidgetLayout");
1660 QStringList list; 1673 QStringList list;
1661 list = config->readListEntry("MainLayout"); 1674 list = config->readListEntry("MainLayout");
1662 int x,y,w,h; 1675 int x,y,w,h;
1663 if ( ! list.isEmpty() ) { 1676 if ( ! list.isEmpty() ) {
1664 x = list[0].toInt(); 1677 x = list[0].toInt();
1665 y = list[1].toInt(); 1678 y = list[1].toInt();
1666 w = list[2].toInt(); 1679 w = list[2].toInt();
1667 h = list[3].toInt(); 1680 h = list[3].toInt();
1668 topLevelWidget()->setGeometry(x,y,w,h); 1681 topLevelWidget()->setGeometry(x,y,w,h);
1669 1682
1670 } else { 1683 } else {
1671 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 1684 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
1672 } 1685 }
1673 list = config->readListEntry("EditEventLayout"); 1686 list = config->readListEntry("EditEventLayout");
1674 if ( ! list.isEmpty() ) { 1687 if ( ! list.isEmpty() ) {
1675 x = list[0].toInt(); 1688 x = list[0].toInt();
1676 y = list[1].toInt(); 1689 y = list[1].toInt();
1677 w = list[2].toInt(); 1690 w = list[2].toInt();
1678 h = list[3].toInt(); 1691 h = list[3].toInt();
1679 mEventEditor->setGeometry(x,y,w,h); 1692 mEventEditor->setGeometry(x,y,w,h);
1680 1693
1681 } 1694 }
1682 list = config->readListEntry("EditTodoLayout"); 1695 list = config->readListEntry("EditTodoLayout");
1683 if ( ! list.isEmpty() ) { 1696 if ( ! list.isEmpty() ) {
1684 x = list[0].toInt(); 1697 x = list[0].toInt();
1685 y = list[1].toInt(); 1698 y = list[1].toInt();
1686 w = list[2].toInt(); 1699 w = list[2].toInt();
1687 h = list[3].toInt(); 1700 h = list[3].toInt();
1688 mTodoEditor->setGeometry(x,y,w,h); 1701 mTodoEditor->setGeometry(x,y,w,h);
1689 1702
1690 } 1703 }
1691 list = config->readListEntry("ViewerLayout"); 1704 list = config->readListEntry("ViewerLayout");
1692 if ( ! list.isEmpty() ) { 1705 if ( ! list.isEmpty() ) {
1693 x = list[0].toInt(); 1706 x = list[0].toInt();
1694 y = list[1].toInt(); 1707 y = list[1].toInt();
1695 w = list[2].toInt(); 1708 w = list[2].toInt();
1696 h = list[3].toInt(); 1709 h = list[3].toInt();
1697 getEventViewerDialog()->setGeometry(x,y,w,h); 1710 getEventViewerDialog()->setGeometry(x,y,w,h);
1698 } 1711 }
1699#endif 1712#endif
1700 1713
1701} 1714}
1702 1715
1703 1716
1704void CalendarView::writeSettings() 1717void CalendarView::writeSettings()
1705{ 1718{
1706 // kdDebug() << "CalendarView::writeSettings" << endl; 1719 // kdDebug() << "CalendarView::writeSettings" << endl;
1707 1720
1708 KConfig *config = KOGlobals::config(); 1721 KConfig *config = KOGlobals::config();
1709 1722
1710#ifndef KORG_NOSPLITTER 1723#ifndef KORG_NOSPLITTER
1711 config->setGroup("KOrganizer Geometry"); 1724 config->setGroup("KOrganizer Geometry");
1712 1725
1713 QValueList<int> list = mPanner->sizes(); 1726 QValueList<int> list = mPanner->sizes();
1714 config->writeEntry("Separator1",list); 1727 config->writeEntry("Separator1",list);
1715 1728
1716 list = mLeftSplitter->sizes(); 1729 list = mLeftSplitter->sizes();
1717 config->writeEntry("Separator2",list); 1730 config->writeEntry("Separator2",list);
1718#endif 1731#endif
1719 1732
1720 mViewManager->writeSettings( config ); 1733 mViewManager->writeSettings( config );
1721 mTodoList->saveLayout(config,QString("Todo Layout")); 1734 mTodoList->saveLayout(config,QString("Todo Layout"));
1722 mDialogManager->writeSettings( config ); 1735 mDialogManager->writeSettings( config );
1723 //KOPrefs::instance()->usrWriteConfig(); 1736 //KOPrefs::instance()->usrWriteConfig();
1724 KOPrefs::instance()->writeConfig(); 1737 KOPrefs::instance()->writeConfig();
1725 1738
1726 writeFilterSettings(config); 1739 writeFilterSettings(config);
1727 1740
1728 config->setGroup( "Views" ); 1741 config->setGroup( "Views" );
1729 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 1742 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
1730 1743
1731#ifdef DESKTOP_VERSION 1744#ifdef DESKTOP_VERSION
1732 config->setGroup("WidgetLayout"); 1745 config->setGroup("WidgetLayout");
1733 QStringList list ;//= config->readListEntry("MainLayout"); 1746 QStringList list ;//= config->readListEntry("MainLayout");
1734 int x,y,w,h; 1747 int x,y,w,h;
1735 QWidget* wid; 1748 QWidget* wid;
1736 wid = topLevelWidget(); 1749 wid = topLevelWidget();
1737 x = wid->geometry().x(); 1750 x = wid->geometry().x();
1738 y = wid->geometry().y(); 1751 y = wid->geometry().y();
1739 w = wid->width(); 1752 w = wid->width();
1740 h = wid->height(); 1753 h = wid->height();
1741 list.clear(); 1754 list.clear();
1742 list << QString::number( x ); 1755 list << QString::number( x );
1743 list << QString::number( y ); 1756 list << QString::number( y );
1744 list << QString::number( w ); 1757 list << QString::number( w );
1745 list << QString::number( h ); 1758 list << QString::number( h );
1746 config->writeEntry("MainLayout",list ); 1759 config->writeEntry("MainLayout",list );
1747 1760
1748 wid = mEventEditor; 1761 wid = mEventEditor;
1749 x = wid->geometry().x(); 1762 x = wid->geometry().x();
1750 y = wid->geometry().y(); 1763 y = wid->geometry().y();
1751 w = wid->width(); 1764 w = wid->width();
1752 h = wid->height(); 1765 h = wid->height();
1753 list.clear(); 1766 list.clear();
1754 list << QString::number( x ); 1767 list << QString::number( x );
1755 list << QString::number( y ); 1768 list << QString::number( y );
1756 list << QString::number( w ); 1769 list << QString::number( w );
1757 list << QString::number( h ); 1770 list << QString::number( h );
1758 config->writeEntry("EditEventLayout",list ); 1771 config->writeEntry("EditEventLayout",list );
1759 1772
1760 wid = mTodoEditor; 1773 wid = mTodoEditor;
1761 x = wid->geometry().x(); 1774 x = wid->geometry().x();
1762 y = wid->geometry().y(); 1775 y = wid->geometry().y();
1763 w = wid->width(); 1776 w = wid->width();
1764 h = wid->height(); 1777 h = wid->height();
1765 list.clear(); 1778 list.clear();
1766 list << QString::number( x ); 1779 list << QString::number( x );
1767 list << QString::number( y ); 1780 list << QString::number( y );
1768 list << QString::number( w ); 1781 list << QString::number( w );
1769 list << QString::number( h ); 1782 list << QString::number( h );
1770 config->writeEntry("EditTodoLayout",list ); 1783 config->writeEntry("EditTodoLayout",list );
1771 wid = getEventViewerDialog(); 1784 wid = getEventViewerDialog();
1772 x = wid->geometry().x(); 1785 x = wid->geometry().x();
1773 y = wid->geometry().y(); 1786 y = wid->geometry().y();
1774 w = wid->width(); 1787 w = wid->width();
1775 h = wid->height(); 1788 h = wid->height();
1776 list.clear(); 1789 list.clear();
1777 list << QString::number( x ); 1790 list << QString::number( x );
1778 list << QString::number( y ); 1791 list << QString::number( y );
1779 list << QString::number( w ); 1792 list << QString::number( w );
1780 list << QString::number( h ); 1793 list << QString::number( h );
1781 config->writeEntry("ViewerLayout",list ); 1794 config->writeEntry("ViewerLayout",list );
1782 wid = mDialogManager->getSearchDialog(); 1795 wid = mDialogManager->getSearchDialog();
1783 if ( wid ) { 1796 if ( wid ) {
1784 x = wid->geometry().x(); 1797 x = wid->geometry().x();
1785 y = wid->geometry().y(); 1798 y = wid->geometry().y();
1786 w = wid->width(); 1799 w = wid->width();
1787 h = wid->height(); 1800 h = wid->height();
1788 list.clear(); 1801 list.clear();
1789 list << QString::number( x ); 1802 list << QString::number( x );
1790 list << QString::number( y ); 1803 list << QString::number( y );
1791 list << QString::number( w ); 1804 list << QString::number( w );
1792 list << QString::number( h ); 1805 list << QString::number( h );
1793 config->writeEntry("SearchLayout",list ); 1806 config->writeEntry("SearchLayout",list );
1794 } 1807 }
1795#endif 1808#endif
1796 1809
1797 1810
1798 config->sync(); 1811 config->sync();
1799} 1812}
1800 1813
1801void CalendarView::readFilterSettings(KConfig *config) 1814void CalendarView::readFilterSettings(KConfig *config)
1802{ 1815{
1803 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 1816 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
1804 1817
1805 mFilters.clear(); 1818 mFilters.clear();
1806 1819
1807 config->setGroup("General"); 1820 config->setGroup("General");
1808 QStringList filterList = config->readListEntry("CalendarFilters"); 1821 QStringList filterList = config->readListEntry("CalendarFilters");
1809 1822
1810 QStringList::ConstIterator it = filterList.begin(); 1823 QStringList::ConstIterator it = filterList.begin();
1811 QStringList::ConstIterator end = filterList.end(); 1824 QStringList::ConstIterator end = filterList.end();
1812 while(it != end) { 1825 while(it != end) {
1813 // kdDebug() << " filter: " << (*it) << endl; 1826 // kdDebug() << " filter: " << (*it) << endl;
1814 1827
1815 CalFilter *filter; 1828 CalFilter *filter;
1816 filter = new CalFilter(*it); 1829 filter = new CalFilter(*it);
1817 config->setGroup("Filter_" + (*it)); 1830 config->setGroup("Filter_" + (*it));
1818 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 1831 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
1819 filter->setCriteria(config->readNumEntry("Criteria",0)); 1832 filter->setCriteria(config->readNumEntry("Criteria",0));
1820 filter->setCategoryList(config->readListEntry("CategoryList")); 1833 filter->setCategoryList(config->readListEntry("CategoryList"));
1821 mFilters.append(filter); 1834 mFilters.append(filter);
1822 1835
1823 ++it; 1836 ++it;
1824 } 1837 }
1825 1838
1826 if (mFilters.count() == 0) { 1839 if (mFilters.count() == 0) {
1827 CalFilter *filter = new CalFilter(i18n("Default")); 1840 CalFilter *filter = new CalFilter(i18n("Default"));
1828 mFilters.append(filter); 1841 mFilters.append(filter);
1829 } 1842 }
1830 mFilterView->updateFilters(); 1843 mFilterView->updateFilters();
1831 config->setGroup("FilterView"); 1844 config->setGroup("FilterView");
1832 1845
1833 mFilterView->blockSignals(true); 1846 mFilterView->blockSignals(true);
1834 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 1847 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
1835 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 1848 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
1836 mFilterView->blockSignals(false); 1849 mFilterView->blockSignals(false);
1837 // We do it manually to avoid it being done twice by the above calls 1850 // We do it manually to avoid it being done twice by the above calls
1838 updateFilter(); 1851 updateFilter();
1839} 1852}
1840 1853
1841void CalendarView::writeFilterSettings(KConfig *config) 1854void CalendarView::writeFilterSettings(KConfig *config)
1842{ 1855{
1843 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 1856 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
1844 1857
1845 QStringList filterList; 1858 QStringList filterList;
1846 1859
1847 CalFilter *filter = mFilters.first(); 1860 CalFilter *filter = mFilters.first();
1848 while(filter) { 1861 while(filter) {
1849 // kdDebug() << " fn: " << filter->name() << endl; 1862 // kdDebug() << " fn: " << filter->name() << endl;
1850 filterList << filter->name(); 1863 filterList << filter->name();
1851 config->setGroup("Filter_" + filter->name()); 1864 config->setGroup("Filter_" + filter->name());
1852 config->writeEntry("Criteria",filter->criteria()); 1865 config->writeEntry("Criteria",filter->criteria());
1853 config->writeEntry("CategoryList",filter->categoryList()); 1866 config->writeEntry("CategoryList",filter->categoryList());
1854 filter = mFilters.next(); 1867 filter = mFilters.next();
1855 } 1868 }
1856 config->setGroup("General"); 1869 config->setGroup("General");
1857 config->writeEntry("CalendarFilters",filterList); 1870 config->writeEntry("CalendarFilters",filterList);
1858 1871
1859 config->setGroup("FilterView"); 1872 config->setGroup("FilterView");
1860 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 1873 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
1861 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 1874 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
1862} 1875}
1863 1876
1864 1877
1865void CalendarView::goToday() 1878void CalendarView::goToday()
1866{ 1879{
1867 mNavigator->selectToday(); 1880 mNavigator->selectToday();
1868} 1881}
1869 1882
1870void CalendarView::goNext() 1883void CalendarView::goNext()
1871{ 1884{
1872 mNavigator->selectNext(); 1885 mNavigator->selectNext();
1873} 1886}
1874 1887
1875void CalendarView::goPrevious() 1888void CalendarView::goPrevious()
1876{ 1889{
1877 mNavigator->selectPrevious(); 1890 mNavigator->selectPrevious();
1878} 1891}
1879void CalendarView::goNextMonth() 1892void CalendarView::goNextMonth()
1880{ 1893{
1881 mNavigator->selectNextMonth(); 1894 mNavigator->selectNextMonth();
1882} 1895}
1883 1896
1884void CalendarView::goPreviousMonth() 1897void CalendarView::goPreviousMonth()
1885{ 1898{
1886 mNavigator->selectPreviousMonth(); 1899 mNavigator->selectPreviousMonth();
1887} 1900}
1888void CalendarView::writeLocale() 1901void CalendarView::writeLocale()
1889{ 1902{
1890 //KPimGlobalPrefs::instance()->setGlobalConfig(); 1903 //KPimGlobalPrefs::instance()->setGlobalConfig();
1891#if 0 1904#if 0
1892 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); 1905 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime );
1893 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); 1906 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday );
1894 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); 1907 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate );
1895 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); 1908 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage );
1896 QString dummy = KOPrefs::instance()->mUserDateFormatLong; 1909 QString dummy = KOPrefs::instance()->mUserDateFormatLong;
1897 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 1910 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
1898 dummy = KOPrefs::instance()->mUserDateFormatShort; 1911 dummy = KOPrefs::instance()->mUserDateFormatShort;
1899 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 1912 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
1900 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, 1913 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving,
1901 KOPrefs::instance()->mDaylightsavingStart, 1914 KOPrefs::instance()->mDaylightsavingStart,
1902 KOPrefs::instance()->mDaylightsavingEnd ); 1915 KOPrefs::instance()->mDaylightsavingEnd );
1903 KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId ); 1916 KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId );
1904#endif 1917#endif
1905} 1918}
1906void CalendarView::updateConfig() 1919void CalendarView::updateConfig()
1907{ 1920{
1908 writeLocale(); 1921 writeLocale();
1909 if ( KOPrefs::instance()->mUseAppColors ) 1922 if ( KOPrefs::instance()->mUseAppColors )
1910 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 1923 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
1911 emit configChanged(); 1924 emit configChanged();
1912 mTodoList->updateConfig(); 1925 mTodoList->updateConfig();
1913 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 1926 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
1914 mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1927 mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1915 // To make the "fill window" configurations work 1928 // To make the "fill window" configurations work
1916 //mViewManager->raiseCurrentView(); 1929 //mViewManager->raiseCurrentView();
1917} 1930}
1918 1931
1919 1932
1920void CalendarView::eventChanged(Event *event) 1933void CalendarView::eventChanged(Event *event)
1921{ 1934{
1922 changeEventDisplay(event,KOGlobals::EVENTEDITED); 1935 changeEventDisplay(event,KOGlobals::EVENTEDITED);
1923 //updateUnmanagedViews(); 1936 //updateUnmanagedViews();
1924} 1937}
1925 1938
1926void CalendarView::eventAdded(Event *event) 1939void CalendarView::eventAdded(Event *event)
1927{ 1940{
1928 changeEventDisplay(event,KOGlobals::EVENTADDED); 1941 changeEventDisplay(event,KOGlobals::EVENTADDED);
1929} 1942}
1930 1943
1931void CalendarView::eventToBeDeleted(Event *) 1944void CalendarView::eventToBeDeleted(Event *)
1932{ 1945{
1933 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 1946 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
1934} 1947}
1935 1948
1936void CalendarView::eventDeleted() 1949void CalendarView::eventDeleted()
1937{ 1950{
1938 changeEventDisplay(0,KOGlobals::EVENTDELETED); 1951 changeEventDisplay(0,KOGlobals::EVENTDELETED);
1939} 1952}
1940void CalendarView::changeTodoDisplay(Todo *which, int action) 1953void CalendarView::changeTodoDisplay(Todo *which, int action)
1941{ 1954{
1942 changeIncidenceDisplay((Incidence *)which, action); 1955 changeIncidenceDisplay((Incidence *)which, action);
1943 mDateNavigator->updateView(); //LR 1956 mDateNavigator->updateView(); //LR
1944 //mDialogManager->updateSearchDialog(); 1957 //mDialogManager->updateSearchDialog();
1945 1958
1946 if (which) { 1959 if (which) {
1947 mViewManager->updateWNview(); 1960 mViewManager->updateWNview();
1948 //mTodoList->updateView(); 1961 //mTodoList->updateView();
1949 } 1962 }
1950 1963
1951} 1964}
1952 1965
1953void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 1966void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
1954{ 1967{
1955 updateUnmanagedViews(); 1968 updateUnmanagedViews();
1956 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 1969 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
1957 if ( action == KOGlobals::EVENTDELETED ) { //delete 1970 if ( action == KOGlobals::EVENTDELETED ) { //delete
1958 mCalendar->checkAlarmForIncidence( 0, true ); 1971 mCalendar->checkAlarmForIncidence( 0, true );
1959 if ( mEventViewerDialog ) 1972 if ( mEventViewerDialog )
1960 mEventViewerDialog->hide(); 1973 mEventViewerDialog->hide();
1961 } 1974 }
1962 else 1975 else
1963 mCalendar->checkAlarmForIncidence( which , false ); 1976 mCalendar->checkAlarmForIncidence( which , false );
1964} 1977}
1965 1978
1966// most of the changeEventDisplays() right now just call the view's 1979// most of the changeEventDisplays() right now just call the view's
1967// total update mode, but they SHOULD be recoded to be more refresh-efficient. 1980// total update mode, but they SHOULD be recoded to be more refresh-efficient.
1968void CalendarView::changeEventDisplay(Event *which, int action) 1981void CalendarView::changeEventDisplay(Event *which, int action)
1969{ 1982{
1970 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 1983 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
1971 changeIncidenceDisplay((Incidence *)which, action); 1984 changeIncidenceDisplay((Incidence *)which, action);
1972 mDateNavigator->updateView(); 1985 mDateNavigator->updateView();
1973 //mDialogManager->updateSearchDialog(); 1986 //mDialogManager->updateSearchDialog();
1974 1987
1975 if (which) { 1988 if (which) {
1976 // If there is an event view visible update the display 1989 // If there is an event view visible update the display
1977 mViewManager->currentView()->changeEventDisplay(which,action); 1990 mViewManager->currentView()->changeEventDisplay(which,action);
1978 // TODO: check, if update needed 1991 // TODO: check, if update needed
1979 // if (which->getTodoStatus()) { 1992 // if (which->getTodoStatus()) {
1980 mTodoList->updateView(); 1993 mTodoList->updateView();
1981 // } 1994 // }
1982 } else { 1995 } else {
1983 mViewManager->currentView()->updateView(); 1996 mViewManager->currentView()->updateView();
1984 } 1997 }
1985} 1998}
1986 1999
1987 2000
1988void CalendarView::updateTodoViews() 2001void CalendarView::updateTodoViews()
1989{ 2002{
1990 2003
1991 mTodoList->updateView(); 2004 mTodoList->updateView();
1992 mViewManager->currentView()->updateView(); 2005 mViewManager->currentView()->updateView();
1993 2006
1994} 2007}
1995 2008
1996 2009
1997void CalendarView::updateView(const QDate &start, const QDate &end) 2010void CalendarView::updateView(const QDate &start, const QDate &end)
1998{ 2011{
1999 mTodoList->updateView(); 2012 mTodoList->updateView();
2000 mViewManager->updateView(start, end); 2013 mViewManager->updateView(start, end);
2001 //mDateNavigator->updateView(); 2014 //mDateNavigator->updateView();
2002} 2015}
2003 2016
2004void CalendarView::updateView() 2017void CalendarView::updateView()
2005{ 2018{
2006 DateList tmpList = mNavigator->selectedDates(); 2019 DateList tmpList = mNavigator->selectedDates();
2007 2020
2008 // We assume that the navigator only selects consecutive days. 2021 // We assume that the navigator only selects consecutive days.
2009 updateView( tmpList.first(), tmpList.last() ); 2022 updateView( tmpList.first(), tmpList.last() );
2010} 2023}
2011 2024
2012void CalendarView::updateUnmanagedViews() 2025void CalendarView::updateUnmanagedViews()
2013{ 2026{
2014 mDateNavigator->updateDayMatrix(); 2027 mDateNavigator->updateDayMatrix();
2015} 2028}
2016 2029
2017int CalendarView::msgItemDelete() 2030int CalendarView::msgItemDelete()
2018{ 2031{
2019 return KMessageBox::warningContinueCancel(this, 2032 return KMessageBox::warningContinueCancel(this,
2020 i18n("This item will be\npermanently deleted."), 2033 i18n("This item will be\npermanently deleted."),
2021 i18n("KO/Pi Confirmation"),i18n("Delete")); 2034 i18n("KO/Pi Confirmation"),i18n("Delete"));
2022} 2035}
2023 2036
2024 2037
2025void CalendarView::edit_cut() 2038void CalendarView::edit_cut()
2026{ 2039{
2027 Event *anEvent=0; 2040 Event *anEvent=0;
2028 2041
2029 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2042 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2030 2043
2031 if (mViewManager->currentView()->isEventView()) { 2044 if (mViewManager->currentView()->isEventView()) {
2032 if ( incidence && incidence->type() == "Event" ) { 2045 if ( incidence && incidence->type() == "Event" ) {
2033 anEvent = static_cast<Event *>(incidence); 2046 anEvent = static_cast<Event *>(incidence);
2034 } 2047 }
2035 } 2048 }
2036 2049
2037 if (!anEvent) { 2050 if (!anEvent) {
2038 KNotifyClient::beep(); 2051 KNotifyClient::beep();
2039 return; 2052 return;
2040 } 2053 }
2041 DndFactory factory( mCalendar ); 2054 DndFactory factory( mCalendar );
2042 factory.cutEvent(anEvent); 2055 factory.cutEvent(anEvent);
2043 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2056 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2044} 2057}
2045 2058
2046void CalendarView::edit_copy() 2059void CalendarView::edit_copy()
2047{ 2060{
2048 Event *anEvent=0; 2061 Event *anEvent=0;
2049 2062
2050 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2063 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2051 2064
2052 if (mViewManager->currentView()->isEventView()) { 2065 if (mViewManager->currentView()->isEventView()) {
2053 if ( incidence && incidence->type() == "Event" ) { 2066 if ( incidence && incidence->type() == "Event" ) {
2054 anEvent = static_cast<Event *>(incidence); 2067 anEvent = static_cast<Event *>(incidence);
2055 } 2068 }
2056 } 2069 }
2057 2070
2058 if (!anEvent) { 2071 if (!anEvent) {
2059 KNotifyClient::beep(); 2072 KNotifyClient::beep();
2060 return; 2073 return;
2061 } 2074 }
2062 DndFactory factory( mCalendar ); 2075 DndFactory factory( mCalendar );
2063 factory.copyEvent(anEvent); 2076 factory.copyEvent(anEvent);
2064} 2077}
2065 2078
2066void CalendarView::edit_paste() 2079void CalendarView::edit_paste()
2067{ 2080{
2068 QDate date = mNavigator->selectedDates().first(); 2081 QDate date = mNavigator->selectedDates().first();
2069 2082
2070 DndFactory factory( mCalendar ); 2083 DndFactory factory( mCalendar );
2071 Event *pastedEvent = factory.pasteEvent( date ); 2084 Event *pastedEvent = factory.pasteEvent( date );
2072 2085
2073 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 2086 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
2074} 2087}
2075 2088
2076void CalendarView::edit_options() 2089void CalendarView::edit_options()
2077{ 2090{
2078 mDialogManager->showOptionsDialog(); 2091 mDialogManager->showOptionsDialog();
2079 //writeSettings(); 2092 //writeSettings();
2080} 2093}
2081void CalendarView::edit_sync_options() 2094void CalendarView::edit_sync_options()
2082{ 2095{
2083 //mDialogManager->showSyncOptions(); 2096 //mDialogManager->showSyncOptions();
2084 //KOPrefs::instance()->mSyncAlgoPrefs 2097 //KOPrefs::instance()->mSyncAlgoPrefs
2085 QDialog dia( this, "dia", true ); 2098 QDialog dia( this, "dia", true );
2086 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); 2099 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice );
2087 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); 2100 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia);
2088 QVBoxLayout lay ( &dia ); 2101 QVBoxLayout lay ( &dia );
2089 lay.setSpacing( 2 ); 2102 lay.setSpacing( 2 );
2090 lay.setMargin( 3 ); 2103 lay.setMargin( 3 );
2091 lay.addWidget(&gr); 2104 lay.addWidget(&gr);
2092 QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); 2105 QRadioButton loc ( i18n("Take local entry on conflict"), &gr );
2093 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); 2106 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr );
2094 QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); 2107 QRadioButton newest( i18n("Take newest entry on conflict"), &gr );
2095 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); 2108 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr );
2096 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); 2109 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr );
2097 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); 2110 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr );
2098 //QRadioButton both( i18n("Take both on conflict"), &gr ); 2111 //QRadioButton both( i18n("Take both on conflict"), &gr );
2099 QPushButton pb ( "OK", &dia); 2112 QPushButton pb ( "OK", &dia);
2100 lay.addWidget( &pb ); 2113 lay.addWidget( &pb );
2101 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 2114 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
2102 switch ( KOPrefs::instance()->mSyncAlgoPrefs ) { 2115 switch ( KOPrefs::instance()->mSyncAlgoPrefs ) {
2103 case 0: 2116 case 0:
2104 loc.setChecked( true); 2117 loc.setChecked( true);
2105 break; 2118 break;
2106 case 1: 2119 case 1:
2107 rem.setChecked( true ); 2120 rem.setChecked( true );
2108 break; 2121 break;
2109 case 2: 2122 case 2:
2110 newest.setChecked( true); 2123 newest.setChecked( true);
2111 break; 2124 break;
2112 case 3: 2125 case 3:
2113 ask.setChecked( true); 2126 ask.setChecked( true);
2114 break; 2127 break;
2115 case 4: 2128 case 4:
2116 f_loc.setChecked( true); 2129 f_loc.setChecked( true);
2117 break; 2130 break;
2118 case 5: 2131 case 5:
2119 f_rem.setChecked( true); 2132 f_rem.setChecked( true);
2120 break; 2133 break;
2121 case 6: 2134 case 6:
2122 // both.setChecked( true); 2135 // both.setChecked( true);
2123 break; 2136 break;
2124 default: 2137 default:
2125 break; 2138 break;
2126 } 2139 }
2127 if ( dia.exec() ) { 2140 if ( dia.exec() ) {
2128 KOPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; 2141 KOPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ;
2129 } 2142 }
2130 2143
2131} 2144}
2132 2145
2133void CalendarView::slotSelectPickerDate( QDate d) 2146void CalendarView::slotSelectPickerDate( QDate d)
2134{ 2147{
2135 mDateFrame->hide(); 2148 mDateFrame->hide();
2136 if ( mDatePickerMode == 1 ) { 2149 if ( mDatePickerMode == 1 ) {
2137 mNavigator->slotDaySelect( d ); 2150 mNavigator->slotDaySelect( d );
2138 } else if ( mDatePickerMode == 2 ) { 2151 } else if ( mDatePickerMode == 2 ) {
2139 if ( mMoveIncidence->type() == "Todo" ) { 2152 if ( mMoveIncidence->type() == "Todo" ) {
2140 Todo * to = (Todo *) mMoveIncidence; 2153 Todo * to = (Todo *) mMoveIncidence;
2141 QTime tim; 2154 QTime tim;
2142 if ( to->hasDueDate() ) 2155 if ( to->hasDueDate() )
2143 tim = to->dtDue().time(); 2156 tim = to->dtDue().time();
2144 else { 2157 else {
2145 tim = QTime ( 0,0,0 ); 2158 tim = QTime ( 0,0,0 );
2146 to->setFloats( true ); 2159 to->setFloats( true );
2147 to->setHasDueDate( true ); 2160 to->setHasDueDate( true );
2148 } 2161 }
2149 QDateTime dt ( d,tim ); 2162 QDateTime dt ( d,tim );
2150 to->setDtDue( dt ); 2163 to->setDtDue( dt );
2151 todoChanged( to ); 2164 todoChanged( to );
2152 } else { 2165 } else {
2153 QTime tim = mMoveIncidence->dtStart().time(); 2166 QTime tim = mMoveIncidence->dtStart().time();
2154 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2167 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2155 QDateTime dt ( d,tim ); 2168 QDateTime dt ( d,tim );
2156 mMoveIncidence->setDtStart( dt ); 2169 mMoveIncidence->setDtStart( dt );
2157 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2170 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2158 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2171 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2159 } 2172 }
2160 2173
2161 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2174 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2162 } 2175 }
2163} 2176}
2164 2177
2165void CalendarView::removeCategories() 2178void CalendarView::removeCategories()
2166{ 2179{
2167 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2180 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2168 QStringList catList = KOPrefs::instance()->mCustomCategories; 2181 QStringList catList = KOPrefs::instance()->mCustomCategories;
2169 QStringList catIncList; 2182 QStringList catIncList;
2170 QStringList newCatList; 2183 QStringList newCatList;
2171 Incidence* inc = incList.first(); 2184 Incidence* inc = incList.first();
2172 int i; 2185 int i;
2173 int count = 0; 2186 int count = 0;
2174 while ( inc ) { 2187 while ( inc ) {
2175 newCatList.clear(); 2188 newCatList.clear();
2176 catIncList = inc->categories() ; 2189 catIncList = inc->categories() ;
2177 for( i = 0; i< catIncList.count(); ++i ) { 2190 for( i = 0; i< catIncList.count(); ++i ) {
2178 if ( catList.contains (catIncList[i])) 2191 if ( catList.contains (catIncList[i]))
2179 newCatList.append( catIncList[i] ); 2192 newCatList.append( catIncList[i] );
2180 } 2193 }
2181 newCatList.sort(); 2194 newCatList.sort();
2182 inc->setCategories( newCatList.join(",") ); 2195 inc->setCategories( newCatList.join(",") );
2183 inc = incList.next(); 2196 inc = incList.next();
2184 } 2197 }
2185} 2198}
2186 2199
2187int CalendarView::addCategories() 2200int CalendarView::addCategories()
2188{ 2201{
2189 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2202 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2190 QStringList catList = KOPrefs::instance()->mCustomCategories; 2203 QStringList catList = KOPrefs::instance()->mCustomCategories;
2191 QStringList catIncList; 2204 QStringList catIncList;
2192 Incidence* inc = incList.first(); 2205 Incidence* inc = incList.first();
2193 int i; 2206 int i;
2194 int count = 0; 2207 int count = 0;
2195 while ( inc ) { 2208 while ( inc ) {
2196 catIncList = inc->categories() ; 2209 catIncList = inc->categories() ;
2197 for( i = 0; i< catIncList.count(); ++i ) { 2210 for( i = 0; i< catIncList.count(); ++i ) {
2198 if ( !catList.contains (catIncList[i])) { 2211 if ( !catList.contains (catIncList[i])) {
2199 catList.append( catIncList[i] ); 2212 catList.append( catIncList[i] );
2200 //qDebug("add cat %s ", catIncList[i].latin1()); 2213 //qDebug("add cat %s ", catIncList[i].latin1());
2201 ++count; 2214 ++count;
2202 } 2215 }
2203 } 2216 }
2204 inc = incList.next(); 2217 inc = incList.next();
2205 } 2218 }
2206 catList.sort(); 2219 catList.sort();
2207 KOPrefs::instance()->mCustomCategories = catList; 2220 KOPrefs::instance()->mCustomCategories = catList;
2208 return count; 2221 return count;
2209} 2222}
2210 2223
2211void CalendarView::manageCategories() 2224void CalendarView::manageCategories()
2212{ 2225{
2213 KOCatPrefs* cp = new KOCatPrefs(); 2226 KOCatPrefs* cp = new KOCatPrefs();
2214 cp->show(); 2227 cp->show();
2215 int w =cp->sizeHint().width() ; 2228 int w =cp->sizeHint().width() ;
2216 int h = cp->sizeHint().height() ; 2229 int h = cp->sizeHint().height() ;
2217 int dw = QApplication::desktop()->width(); 2230 int dw = QApplication::desktop()->width();
2218 int dh = QApplication::desktop()->height(); 2231 int dh = QApplication::desktop()->height();
2219 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2232 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2220 if ( !cp->exec() ) { 2233 if ( !cp->exec() ) {
2221 delete cp; 2234 delete cp;
2222 return; 2235 return;
2223 } 2236 }
2224 int count = 0; 2237 int count = 0;
2225 if ( cp->addCat() ) { 2238 if ( cp->addCat() ) {
2226 count = addCategories(); 2239 count = addCategories();
2227 if ( count ) { 2240 if ( count ) {
2228 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2241 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2229 writeSettings(); 2242 writeSettings();
2230 } 2243 }
2231 } else { 2244 } else {
2232 removeCategories(); 2245 removeCategories();
2233 updateView(); 2246 updateView();
2234 } 2247 }
2235 delete cp; 2248 delete cp;
2236} 2249}
2237 2250
2238void CalendarView::beamIncidence(Incidence * Inc) 2251void CalendarView::beamIncidence(Incidence * Inc)
2239{ 2252{
2240 QPtrList<Incidence> delSel ; 2253 QPtrList<Incidence> delSel ;
2241 delSel.append(Inc); 2254 delSel.append(Inc);
2242 beamIncidenceList( delSel ); 2255 beamIncidenceList( delSel );
2243} 2256}
2244void CalendarView::beamCalendar() 2257void CalendarView::beamCalendar()
2245{ 2258{
2246 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2259 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2247 //qDebug("beamCalendar() "); 2260 //qDebug("beamCalendar() ");
2248 beamIncidenceList( delSel ); 2261 beamIncidenceList( delSel );
2249} 2262}
2250void CalendarView::beamFilteredCalendar() 2263void CalendarView::beamFilteredCalendar()
2251{ 2264{
2252 QPtrList<Incidence> delSel = mCalendar->incidences(); 2265 QPtrList<Incidence> delSel = mCalendar->incidences();
2253 //qDebug("beamFilteredCalendar() "); 2266 //qDebug("beamFilteredCalendar() ");
2254 beamIncidenceList( delSel ); 2267 beamIncidenceList( delSel );
2255} 2268}
2256void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2269void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2257{ 2270{
2258 if ( beamDialog->exec () == QDialog::Rejected ) 2271 if ( beamDialog->exec () == QDialog::Rejected )
2259 return; 2272 return;
2260 2273
2261 QString fn = "/tmp/kopibeamfile"; 2274 QString fn = "/tmp/kopibeamfile";
2262 QString mes; 2275 QString mes;
2263 bool createbup = true; 2276 bool createbup = true;
2264 if ( createbup ) { 2277 if ( createbup ) {
2265 QString description = "\n"; 2278 QString description = "\n";
2266 CalendarLocal* cal = new CalendarLocal(); 2279 CalendarLocal* cal = new CalendarLocal();
2267 if ( beamDialog->beamLocal() ) 2280 if ( beamDialog->beamLocal() )
2268 cal->setLocalTime(); 2281 cal->setLocalTime();
2269 else 2282 else
2270 cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 2283 cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
2271 Incidence *incidence = delSel.first(); 2284 Incidence *incidence = delSel.first();
2272 bool addText = false; 2285 bool addText = false;
2273 if ( delSel.count() < 10 ) 2286 if ( delSel.count() < 10 )
2274 addText = true; 2287 addText = true;
2275 else { 2288 else {
2276 description.sprintf(i18n(" %d items?"),delSel.count() ); 2289 description.sprintf(i18n(" %d items?"),delSel.count() );
2277 } 2290 }
2278 while ( incidence ) { 2291 while ( incidence ) {
2279 Incidence *in = incidence->clone(); 2292 Incidence *in = incidence->clone();
2280 if ( addText ) 2293 if ( addText )
2281 description += in->summary() + "\n"; 2294 description += in->summary() + "\n";
2282 cal->addIncidence( in ); 2295 cal->addIncidence( in );
2283 incidence = delSel.next(); 2296 incidence = delSel.next();
2284 } 2297 }
2285 if ( beamDialog->beamVcal() ) { 2298 if ( beamDialog->beamVcal() ) {
2286 fn += ".vcs"; 2299 fn += ".vcs";
2287 FileStorage storage( cal, fn, new VCalFormat ); 2300 FileStorage storage( cal, fn, new VCalFormat );
2288 storage.save(); 2301 storage.save();
2289 } else { 2302 } else {
2290 fn += ".ics"; 2303 fn += ".ics";
2291 FileStorage storage( cal, fn, new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 2304 FileStorage storage( cal, fn, new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
2292 storage.save(); 2305 storage.save();
2293 } 2306 }
2294 delete cal; 2307 delete cal;
2295 mes = i18n("KO/Pi: Ready for beaming"); 2308 mes = i18n("KO/Pi: Ready for beaming");
2296 setCaption(mes); 2309 setCaption(mes);
2297 2310
2298#ifndef DESKTOP_VERSION 2311#ifndef DESKTOP_VERSION
2299 Ir *ir = new Ir( this ); 2312 Ir *ir = new Ir( this );
2300 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 2313 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2301 ir->send( fn, description, "text/x-vCalendar" ); 2314 ir->send( fn, description, "text/x-vCalendar" );
2302#endif 2315#endif
2303 } 2316 }
2304} 2317}
2305void CalendarView::beamDone( Ir *ir ) 2318void CalendarView::beamDone( Ir *ir )
2306{ 2319{
2307#ifndef DESKTOP_VERSION 2320#ifndef DESKTOP_VERSION
2308 delete ir; 2321 delete ir;
2309#endif 2322#endif
2310} 2323}
2311 2324
2312void CalendarView::moveIncidence(Incidence * inc ) 2325void CalendarView::moveIncidence(Incidence * inc )
2313{ 2326{
2314 if ( !inc ) return; 2327 if ( !inc ) return;
2315 // qDebug("showDatePickerForIncidence( ) "); 2328 // qDebug("showDatePickerForIncidence( ) ");
2316 if ( mDateFrame->isVisible() ) 2329 if ( mDateFrame->isVisible() )
2317 mDateFrame->hide(); 2330 mDateFrame->hide();
2318 else { 2331 else {
2319 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; 2332 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ;
2320 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; 2333 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ;
2321 int dw = QApplication::desktop()->width(); 2334 int dw = QApplication::desktop()->width();
2322 int dh = QApplication::desktop()->height(); 2335 int dh = QApplication::desktop()->height();
2323 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2336 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2324 mDateFrame->show(); 2337 mDateFrame->show();
2325 } 2338 }
2326 mDatePickerMode = 2; 2339 mDatePickerMode = 2;
2327 mMoveIncidence = inc ; 2340 mMoveIncidence = inc ;
2328 QDate da; 2341 QDate da;
2329 if ( mMoveIncidence->type() == "Todo" ) { 2342 if ( mMoveIncidence->type() == "Todo" ) {
2330 Todo * to = (Todo *) mMoveIncidence; 2343 Todo * to = (Todo *) mMoveIncidence;
2331 if ( to->hasDueDate() ) 2344 if ( to->hasDueDate() )
2332 da = to->dtDue().date(); 2345 da = to->dtDue().date();
2333 else 2346 else
2334 da = QDate::currentDate(); 2347 da = QDate::currentDate();
2335 } else { 2348 } else {
2336 da = mMoveIncidence->dtStart().date(); 2349 da = mMoveIncidence->dtStart().date();
2337 } 2350 }
2338 mDatePicker->setDate( da ); 2351 mDatePicker->setDate( da );
2339} 2352}
2340void CalendarView::showDatePicker( ) 2353void CalendarView::showDatePicker( )
2341{ 2354{
2342 //qDebug("CalendarView::showDatePicker( ) "); 2355 //qDebug("CalendarView::showDatePicker( ) ");
2343 if ( mDateFrame->isVisible() ) 2356 if ( mDateFrame->isVisible() )
2344 mDateFrame->hide(); 2357 mDateFrame->hide();
2345 else { 2358 else {
2346 int w =mDatePicker->sizeHint().width() ; 2359 int w =mDatePicker->sizeHint().width() ;
2347 int h = mDatePicker->sizeHint().height() ; 2360 int h = mDatePicker->sizeHint().height() ;
2348 int dw = QApplication::desktop()->width(); 2361 int dw = QApplication::desktop()->width();
2349 int dh = QApplication::desktop()->height(); 2362 int dh = QApplication::desktop()->height();
2350 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2363 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2351 mDateFrame->show(); 2364 mDateFrame->show();
2352 } 2365 }
2353 mDatePickerMode = 1; 2366 mDatePickerMode = 1;
2354 mDatePicker->setDate( mNavigator->selectedDates().first() ); 2367 mDatePicker->setDate( mNavigator->selectedDates().first() );
2355} 2368}
2356 2369
2357void CalendarView::showEventEditor() 2370void CalendarView::showEventEditor()
2358{ 2371{
2359#ifdef DESKTOP_VERSION 2372#ifdef DESKTOP_VERSION
2360 mEventEditor->show(); 2373 mEventEditor->show();
2361#else 2374#else
2362 mEventEditor->showMaximized(); 2375 mEventEditor->showMaximized();
2363#endif 2376#endif
2364} 2377}
2365void CalendarView::showTodoEditor() 2378void CalendarView::showTodoEditor()
2366{ 2379{
2367#ifdef DESKTOP_VERSION 2380#ifdef DESKTOP_VERSION
2368 mTodoEditor->show(); 2381 mTodoEditor->show();
2369#else 2382#else
2370 mTodoEditor->showMaximized(); 2383 mTodoEditor->showMaximized();
2371#endif 2384#endif
2372} 2385}
2373void CalendarView::cancelIncidence(Incidence * inc ) 2386void CalendarView::cancelIncidence(Incidence * inc )
2374{ 2387{
2375 inc->setCancelled( ! inc->cancelled() ); 2388 inc->setCancelled( ! inc->cancelled() );
2376 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 2389 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
2377 updateView(); 2390 updateView();
2378} 2391}
2379void CalendarView::cloneIncidence(Incidence * orgInc ) 2392void CalendarView::cloneIncidence(Incidence * orgInc )
2380{ 2393{
2381 Incidence * newInc = orgInc->clone(); 2394 Incidence * newInc = orgInc->clone();
2382 newInc->recreate(); 2395 newInc->recreate();
2383 2396
2384 if ( newInc->type() == "Todo" ) { 2397 if ( newInc->type() == "Todo" ) {
2385 Todo* t = (Todo*) newInc; 2398 Todo* t = (Todo*) newInc;
2386 mTodoEditor->editTodo( t ); 2399 mTodoEditor->editTodo( t );
2387 showTodoEditor(); 2400 showTodoEditor();
2388 if ( mTodoEditor->exec() ) { 2401 if ( mTodoEditor->exec() ) {
2389 mCalendar->addTodo( t ); 2402 mCalendar->addTodo( t );
2390 updateView(); 2403 updateView();
2391 } else { 2404 } else {
2392 delete t; 2405 delete t;
2393 } 2406 }
2394 } 2407 }
2395 else { 2408 else {
2396 Event* e = (Event*) newInc; 2409 Event* e = (Event*) newInc;
2397 mEventEditor->editEvent( e ); 2410 mEventEditor->editEvent( e );
2398 showEventEditor(); 2411 showEventEditor();
2399 if ( mEventEditor->exec() ) { 2412 if ( mEventEditor->exec() ) {
2400 mCalendar->addEvent( e ); 2413 mCalendar->addEvent( e );
2401 updateView(); 2414 updateView();
2402 } else { 2415 } else {
2403 delete e; 2416 delete e;
2404 } 2417 }
2405 } 2418 }
2406} 2419}
2407 2420
2408void CalendarView::newEvent() 2421void CalendarView::newEvent()
2409{ 2422{
2410 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 2423 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
2411 KOAgendaView *aView = mViewManager->agendaView(); 2424 KOAgendaView *aView = mViewManager->agendaView();
2412 if (aView) { 2425 if (aView) {
2413 if (aView->selectionStart().isValid()) { 2426 if (aView->selectionStart().isValid()) {
2414 if (aView->selectedIsAllDay()) { 2427 if (aView->selectedIsAllDay()) {
2415 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 2428 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
2416 } else { 2429 } else {
2417 newEvent(aView->selectionStart(),aView->selectionEnd()); 2430 newEvent(aView->selectionStart(),aView->selectionEnd());
2418 } 2431 }
2419 return; 2432 return;
2420 } 2433 }
2421 } 2434 }
2422 2435
2423 QDate date = mNavigator->selectedDates().first(); 2436 QDate date = mNavigator->selectedDates().first();
2424 QDateTime current = QDateTime::currentDateTime(); 2437 QDateTime current = QDateTime::currentDateTime();
2425 if ( date <= current.date() ) { 2438 if ( date <= current.date() ) {
2426 int hour = current.time().hour() +1; 2439 int hour = current.time().hour() +1;
2427 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 2440 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
2428 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2441 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2429 } else 2442 } else
2430 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 2443 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
2431 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 2444 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
2432 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2445 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2433} 2446}
2434 2447
2435void CalendarView::newEvent(QDateTime fh) 2448void CalendarView::newEvent(QDateTime fh)
2436{ 2449{
2437 newEvent(fh, 2450 newEvent(fh,
2438 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 2451 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
2439} 2452}
2440 2453
2441void CalendarView::newEvent(QDate dt) 2454void CalendarView::newEvent(QDate dt)
2442{ 2455{
2443 newEvent(QDateTime(dt, QTime(0,0,0)), 2456 newEvent(QDateTime(dt, QTime(0,0,0)),
2444 QDateTime(dt, QTime(0,0,0)), true); 2457 QDateTime(dt, QTime(0,0,0)), true);
2445} 2458}
2446 2459
2447void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 2460void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
2448{ 2461{
2449 2462
2450 mEventEditor->newEvent(fromHint,toHint,allDay); 2463 mEventEditor->newEvent(fromHint,toHint,allDay);
2451 if ( mFilterView->filtersEnabled() ) { 2464 if ( mFilterView->filtersEnabled() ) {
2452 CalFilter *filter = mFilterView->selectedFilter(); 2465 CalFilter *filter = mFilterView->selectedFilter();
2453 if (filter && filter->showCategories()) { 2466 if (filter && filter->showCategories()) {
2454 mEventEditor->setCategories(filter->categoryList().join(",") ); 2467 mEventEditor->setCategories(filter->categoryList().join(",") );
2455 } 2468 }
2456 if ( filter ) 2469 if ( filter )
2457 mEventEditor->setSecrecy( filter->getSecrecy() ); 2470 mEventEditor->setSecrecy( filter->getSecrecy() );
2458 } 2471 }
2459 showEventEditor(); 2472 showEventEditor();
2460} 2473}
2461void CalendarView::todoAdded(Todo * t) 2474void CalendarView::todoAdded(Todo * t)
2462{ 2475{
2463 2476
2464 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 2477 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
2465 updateTodoViews(); 2478 updateTodoViews();
2466} 2479}
2467void CalendarView::todoChanged(Todo * t) 2480void CalendarView::todoChanged(Todo * t)
2468{ 2481{
2469 emit todoModified( t, 4 ); 2482 emit todoModified( t, 4 );
2470 // updateTodoViews(); 2483 // updateTodoViews();
2471} 2484}
2472void CalendarView::todoToBeDeleted(Todo *) 2485void CalendarView::todoToBeDeleted(Todo *)
2473{ 2486{
2474 //qDebug("todoToBeDeleted(Todo *) "); 2487 //qDebug("todoToBeDeleted(Todo *) ");
2475 updateTodoViews(); 2488 updateTodoViews();
2476} 2489}
2477void CalendarView::todoDeleted() 2490void CalendarView::todoDeleted()
2478{ 2491{
2479 //qDebug(" todoDeleted()"); 2492 //qDebug(" todoDeleted()");
2480 updateTodoViews(); 2493 updateTodoViews();
2481} 2494}
2482 2495
2483 2496
2484 2497
2485void CalendarView::newTodo() 2498void CalendarView::newTodo()
2486{ 2499{
2487 2500
2488 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); 2501 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true);
2489 if ( mFilterView->filtersEnabled() ) { 2502 if ( mFilterView->filtersEnabled() ) {
2490 CalFilter *filter = mFilterView->selectedFilter(); 2503 CalFilter *filter = mFilterView->selectedFilter();
2491 if (filter && filter->showCategories()) { 2504 if (filter && filter->showCategories()) {
2492 mTodoEditor->setCategories(filter->categoryList().join(",") ); 2505 mTodoEditor->setCategories(filter->categoryList().join(",") );
2493 } 2506 }
2494 if ( filter ) 2507 if ( filter )
2495 mTodoEditor->setSecrecy( filter->getSecrecy() ); 2508 mTodoEditor->setSecrecy( filter->getSecrecy() );
2496 } 2509 }
2497 showTodoEditor(); 2510 showTodoEditor();
2498} 2511}
2499 2512
2500void CalendarView::newSubTodo() 2513void CalendarView::newSubTodo()
2501{ 2514{
2502 Todo *todo = selectedTodo(); 2515 Todo *todo = selectedTodo();
2503 if ( todo ) newSubTodo( todo ); 2516 if ( todo ) newSubTodo( todo );
2504} 2517}
2505 2518
2506void CalendarView::newSubTodo(Todo *parentEvent) 2519void CalendarView::newSubTodo(Todo *parentEvent)
2507{ 2520{
2508 2521
2509 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); 2522 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true);
2510 showTodoEditor(); 2523 showTodoEditor();
2511} 2524}
2512 2525
2513void CalendarView::newFloatingEvent() 2526void CalendarView::newFloatingEvent()
2514{ 2527{
2515 DateList tmpList = mNavigator->selectedDates(); 2528 DateList tmpList = mNavigator->selectedDates();
2516 QDate date = tmpList.first(); 2529 QDate date = tmpList.first();
2517 2530
2518 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 2531 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
2519 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 2532 QDateTime( date, QTime( 12, 0, 0 ) ), true );
2520} 2533}
2521 2534
2522 2535
2523void CalendarView::editEvent( Event *event ) 2536void CalendarView::editEvent( Event *event )
2524{ 2537{
2525 2538
2526 if ( !event ) return; 2539 if ( !event ) return;
2527 if ( event->isReadOnly() ) { 2540 if ( event->isReadOnly() ) {
2528 showEvent( event ); 2541 showEvent( event );
2529 return; 2542 return;
2530 } 2543 }
2531 mEventEditor->editEvent( event , mFlagEditDescription); 2544 mEventEditor->editEvent( event , mFlagEditDescription);
2532 showEventEditor(); 2545 showEventEditor();
2533} 2546}
2534void CalendarView::editJournal( Journal *jour ) 2547void CalendarView::editJournal( Journal *jour )
2535{ 2548{
2536 if ( !jour ) return; 2549 if ( !jour ) return;
2537 mDialogManager->hideSearchDialog(); 2550 mDialogManager->hideSearchDialog();
2538 mViewManager->showJournalView(); 2551 mViewManager->showJournalView();
2539 mNavigator->slotDaySelect( jour->dtStart().date() ); 2552 mNavigator->slotDaySelect( jour->dtStart().date() );
2540} 2553}
2541void CalendarView::editTodo( Todo *todo ) 2554void CalendarView::editTodo( Todo *todo )
2542{ 2555{
2543 if ( !todo ) return; 2556 if ( !todo ) return;
2544 2557
2545 if ( todo->isReadOnly() ) { 2558 if ( todo->isReadOnly() ) {
2546 showTodo( todo ); 2559 showTodo( todo );
2547 return; 2560 return;
2548 } 2561 }
2549 mTodoEditor->editTodo( todo ,mFlagEditDescription); 2562 mTodoEditor->editTodo( todo ,mFlagEditDescription);
2550 showTodoEditor(); 2563 showTodoEditor();
2551 2564
2552} 2565}
2553 2566
2554KOEventViewerDialog* CalendarView::getEventViewerDialog() 2567KOEventViewerDialog* CalendarView::getEventViewerDialog()
2555{ 2568{
2556 if ( !mEventViewerDialog ) { 2569 if ( !mEventViewerDialog ) {
2557 mEventViewerDialog = new KOEventViewerDialog(this); 2570 mEventViewerDialog = new KOEventViewerDialog(this);
2558 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 2571 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
2559 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 2572 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
2560 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 2573 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
2561 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 2574 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
2562 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 2575 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
2563 viewManager(), SLOT( showAgendaView( bool ) ) ); 2576 viewManager(), SLOT( showAgendaView( bool ) ) );
2564 mEventViewerDialog->resize( 640, 480 ); 2577 mEventViewerDialog->resize( 640, 480 );
2565 2578
2566 } 2579 }
2567 return mEventViewerDialog; 2580 return mEventViewerDialog;
2568} 2581}
2569void CalendarView::showEvent(Event *event) 2582void CalendarView::showEvent(Event *event)
2570{ 2583{
2571 getEventViewerDialog()->setEvent(event); 2584 getEventViewerDialog()->setEvent(event);
2572 getEventViewerDialog()->showMe(); 2585 getEventViewerDialog()->showMe();
2573} 2586}
2574 2587
2575void CalendarView::showTodo(Todo *event) 2588void CalendarView::showTodo(Todo *event)
2576{ 2589{
2577 getEventViewerDialog()->setTodo(event); 2590 getEventViewerDialog()->setTodo(event);
2578 getEventViewerDialog()->showMe(); 2591 getEventViewerDialog()->showMe();
2579} 2592}
2580void CalendarView::showJournal( Journal *jour ) 2593void CalendarView::showJournal( Journal *jour )
2581{ 2594{
2582 getEventViewerDialog()->setJournal(jour); 2595 getEventViewerDialog()->setJournal(jour);
2583 getEventViewerDialog()->showMe(); 2596 getEventViewerDialog()->showMe();
2584 2597
2585} 2598}
2586// void CalendarView::todoModified (Todo *event, int changed) 2599// void CalendarView::todoModified (Todo *event, int changed)
2587// { 2600// {
2588// // if (mDialogList.find (event) != mDialogList.end ()) { 2601// // if (mDialogList.find (event) != mDialogList.end ()) {
2589// // kdDebug() << "Todo modified and open" << endl; 2602// // kdDebug() << "Todo modified and open" << endl;
2590// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 2603// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
2591// // temp->modified (changed); 2604// // temp->modified (changed);
2592 2605
2593// // } 2606// // }
2594 2607
2595// mViewManager->updateView(); 2608// mViewManager->updateView();
2596// } 2609// }
2597 2610
2598void CalendarView::appointment_show() 2611void CalendarView::appointment_show()
2599{ 2612{
2600 Event *anEvent = 0; 2613 Event *anEvent = 0;
2601 2614
2602 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2615 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2603 2616
2604 if (mViewManager->currentView()->isEventView()) { 2617 if (mViewManager->currentView()->isEventView()) {
2605 if ( incidence && incidence->type() == "Event" ) { 2618 if ( incidence && incidence->type() == "Event" ) {
2606 anEvent = static_cast<Event *>(incidence); 2619 anEvent = static_cast<Event *>(incidence);
2607 } 2620 }
2608 } 2621 }
2609 2622
2610 if (!anEvent) { 2623 if (!anEvent) {
2611 KNotifyClient::beep(); 2624 KNotifyClient::beep();
2612 return; 2625 return;
2613 } 2626 }
2614 2627
2615 showEvent(anEvent); 2628 showEvent(anEvent);
2616} 2629}
2617 2630
2618void CalendarView::appointment_edit() 2631void CalendarView::appointment_edit()
2619{ 2632{
2620 Event *anEvent = 0; 2633 Event *anEvent = 0;
2621 2634
2622 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2635 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2623 2636
2624 if (mViewManager->currentView()->isEventView()) { 2637 if (mViewManager->currentView()->isEventView()) {
2625 if ( incidence && incidence->type() == "Event" ) { 2638 if ( incidence && incidence->type() == "Event" ) {
2626 anEvent = static_cast<Event *>(incidence); 2639 anEvent = static_cast<Event *>(incidence);
2627 } 2640 }
2628 } 2641 }
2629 2642
2630 if (!anEvent) { 2643 if (!anEvent) {
2631 KNotifyClient::beep(); 2644 KNotifyClient::beep();
2632 return; 2645 return;
2633 } 2646 }
2634 2647
2635 editEvent(anEvent); 2648 editEvent(anEvent);
2636} 2649}
2637 2650
2638void CalendarView::appointment_delete() 2651void CalendarView::appointment_delete()
2639{ 2652{
2640 Event *anEvent = 0; 2653 Event *anEvent = 0;
2641 2654
2642 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2655 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2643 2656
2644 if (mViewManager->currentView()->isEventView()) { 2657 if (mViewManager->currentView()->isEventView()) {
2645 if ( incidence && incidence->type() == "Event" ) { 2658 if ( incidence && incidence->type() == "Event" ) {
2646 anEvent = static_cast<Event *>(incidence); 2659 anEvent = static_cast<Event *>(incidence);
2647 } 2660 }
2648 } 2661 }
2649 2662
2650 if (!anEvent) { 2663 if (!anEvent) {
2651 KNotifyClient::beep(); 2664 KNotifyClient::beep();
2652 return; 2665 return;
2653 } 2666 }
2654 2667
2655 deleteEvent(anEvent); 2668 deleteEvent(anEvent);
2656} 2669}
2657 2670
2658void CalendarView::todo_unsub(Todo *anTodo ) 2671void CalendarView::todo_unsub(Todo *anTodo )
2659{ 2672{
2660 // Todo *anTodo = selectedTodo(); 2673 // Todo *anTodo = selectedTodo();
2661 if (!anTodo) return; 2674 if (!anTodo) return;
2662 if (!anTodo->relatedTo()) return; 2675 if (!anTodo->relatedTo()) return;
2663 anTodo->relatedTo()->removeRelation(anTodo); 2676 anTodo->relatedTo()->removeRelation(anTodo);
2664 anTodo->setRelatedTo(0); 2677 anTodo->setRelatedTo(0);
2665 anTodo->updated(); 2678 anTodo->updated();
2666 anTodo->setRelatedToUid(""); 2679 anTodo->setRelatedToUid("");
2667 setModified(true); 2680 setModified(true);
2668 updateView(); 2681 updateView();
2669} 2682}
2670 2683
2671void CalendarView::deleteTodo(Todo *todo) 2684void CalendarView::deleteTodo(Todo *todo)
2672{ 2685{
2673 if (!todo) { 2686 if (!todo) {
2674 KNotifyClient::beep(); 2687 KNotifyClient::beep();
2675 return; 2688 return;
2676 } 2689 }
2677 if (KOPrefs::instance()->mConfirm) { 2690 if (KOPrefs::instance()->mConfirm) {
2678 switch (msgItemDelete()) { 2691 switch (msgItemDelete()) {
2679 case KMessageBox::Continue: // OK 2692 case KMessageBox::Continue: // OK
2680 if (!todo->relations().isEmpty()) { 2693 if (!todo->relations().isEmpty()) {
2681 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), 2694 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."),
2682 i18n("Delete To-Do")); 2695 i18n("Delete To-Do"));
2683 } else { 2696 } else {
2684 checkExternalId( todo ); 2697 checkExternalId( todo );
2685 calendar()->deleteTodo(todo); 2698 calendar()->deleteTodo(todo);
2686 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2699 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2687 updateView(); 2700 updateView();
2688 } 2701 }
2689 break; 2702 break;
2690 } // switch 2703 } // switch
2691 } else { 2704 } else {
2692 if (!todo->relations().isEmpty()) { 2705 if (!todo->relations().isEmpty()) {
2693 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), 2706 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."),
2694 i18n("Delete To-Do")); 2707 i18n("Delete To-Do"));
2695 } else { 2708 } else {
2696 checkExternalId( todo ); 2709 checkExternalId( todo );
2697 mCalendar->deleteTodo(todo); 2710 mCalendar->deleteTodo(todo);
2698 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2711 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2699 updateView(); 2712 updateView();
2700 } 2713 }
2701 } 2714 }
2702 emit updateSearchDialog(); 2715 emit updateSearchDialog();
2703} 2716}
2704void CalendarView::deleteJournal(Journal *jour) 2717void CalendarView::deleteJournal(Journal *jour)
2705{ 2718{
2706 if (!jour) { 2719 if (!jour) {
2707 KNotifyClient::beep(); 2720 KNotifyClient::beep();
2708 return; 2721 return;
2709 } 2722 }
2710 if (KOPrefs::instance()->mConfirm) { 2723 if (KOPrefs::instance()->mConfirm) {
2711 switch (msgItemDelete()) { 2724 switch (msgItemDelete()) {
2712 case KMessageBox::Continue: // OK 2725 case KMessageBox::Continue: // OK
2713 calendar()->deleteJournal(jour); 2726 calendar()->deleteJournal(jour);
2714 updateView(); 2727 updateView();
2715 break; 2728 break;
2716 } // switch 2729 } // switch
2717 } else { 2730 } else {
2718 calendar()->deleteJournal(jour);; 2731 calendar()->deleteJournal(jour);;
2719 updateView(); 2732 updateView();
2720 } 2733 }
2721 emit updateSearchDialog(); 2734 emit updateSearchDialog();
2722} 2735}
2723 2736
2724void CalendarView::deleteEvent(Event *anEvent) 2737void CalendarView::deleteEvent(Event *anEvent)
2725{ 2738{
2726 if (!anEvent) { 2739 if (!anEvent) {
2727 KNotifyClient::beep(); 2740 KNotifyClient::beep();
2728 return; 2741 return;
2729 } 2742 }
2730 2743
2731 if (anEvent->recurrence()->doesRecur()) { 2744 if (anEvent->recurrence()->doesRecur()) {
2732 QDate itemDate = mViewManager->currentSelectionDate(); 2745 QDate itemDate = mViewManager->currentSelectionDate();
2733 int km; 2746 int km;
2734 if (!itemDate.isValid()) { 2747 if (!itemDate.isValid()) {
2735 //kdDebug() << "Date Not Valid" << endl; 2748 //kdDebug() << "Date Not Valid" << endl;
2736 if (KOPrefs::instance()->mConfirm) { 2749 if (KOPrefs::instance()->mConfirm) {
2737 km = KMessageBox::warningContinueCancel(this,anEvent->summary() + 2750 km = KMessageBox::warningContinueCancel(this,anEvent->summary() +
2738 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), 2751 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"),
2739 i18n("KO/Pi Confirmation"),i18n("Delete All")); 2752 i18n("KO/Pi Confirmation"),i18n("Delete All"));
2740 if ( km == KMessageBox::Continue ) 2753 if ( km == KMessageBox::Continue )
2741 km = KMessageBox::No; // No = all below 2754 km = KMessageBox::No; // No = all below
2742 } else 2755 } else
2743 km = KMessageBox::No; 2756 km = KMessageBox::No;
2744 } else { 2757 } else {
2745 km = KMessageBox::warningYesNoCancel(this,anEvent->summary() + 2758 km = KMessageBox::warningYesNoCancel(this,anEvent->summary() +
2746 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ 2759 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+
2747 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), 2760 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"),
2748 i18n("KO/Pi Confirmation"),i18n("Current"), 2761 i18n("KO/Pi Confirmation"),i18n("Current"),
2749 i18n("All")); 2762 i18n("All"));
2750 } 2763 }
2751 switch(km) { 2764 switch(km) {
2752 2765
2753 case KMessageBox::No: // Continue // all 2766 case KMessageBox::No: // Continue // all
2754 //qDebug("KMessageBox::No "); 2767 //qDebug("KMessageBox::No ");
2755 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2768 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2756 schedule(Scheduler::Cancel,anEvent); 2769 schedule(Scheduler::Cancel,anEvent);
2757 2770
2758 checkExternalId( anEvent); 2771 checkExternalId( anEvent);
2759 mCalendar->deleteEvent(anEvent); 2772 mCalendar->deleteEvent(anEvent);
2760 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); 2773 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED);
2761 break; 2774 break;
2762 2775
2763 // Disabled because it does not work 2776 // Disabled because it does not work
2764 //#if 0 2777 //#if 0
2765 case KMessageBox::Yes: // just this one 2778 case KMessageBox::Yes: // just this one
2766 //QDate qd = mNavigator->selectedDates().first(); 2779 //QDate qd = mNavigator->selectedDates().first();
2767 //if (!qd.isValid()) { 2780 //if (!qd.isValid()) {
2768 // kdDebug() << "no date selected, or invalid date" << endl; 2781 // kdDebug() << "no date selected, or invalid date" << endl;
2769 // KNotifyClient::beep(); 2782 // KNotifyClient::beep();
2770 // return; 2783 // return;
2771 //} 2784 //}
2772 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); 2785 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1);
2773 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { 2786 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) {
2774 anEvent->addExDate(itemDate); 2787 anEvent->addExDate(itemDate);
2775 int duration = anEvent->recurrence()->duration(); 2788 int duration = anEvent->recurrence()->duration();
2776 if ( duration > 0 ) { 2789 if ( duration > 0 ) {
2777 anEvent->recurrence()->setDuration( duration - 1 ); 2790 anEvent->recurrence()->setDuration( duration - 1 );
2778 } 2791 }
2779 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); 2792 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED);
2780 } 2793 }
2781 break; 2794 break;
2782 //#endif 2795 //#endif
2783 } // switch 2796 } // switch
2784 } else { 2797 } else {
2785 if (KOPrefs::instance()->mConfirm) { 2798 if (KOPrefs::instance()->mConfirm) {
2786 switch (KMessageBox::warningContinueCancel(this,anEvent->summary() + 2799 switch (KMessageBox::warningContinueCancel(this,anEvent->summary() +
2787 i18n("\nAre you sure you want\nto delete this event?"), 2800 i18n("\nAre you sure you want\nto delete this event?"),
2788 i18n("KO/Pi Confirmation"),i18n("Delete"))) { 2801 i18n("KO/Pi Confirmation"),i18n("Delete"))) {
2789 case KMessageBox::Continue: // OK 2802 case KMessageBox::Continue: // OK
2790 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2803 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2791 schedule(Scheduler::Cancel,anEvent); 2804 schedule(Scheduler::Cancel,anEvent);
2792 checkExternalId( anEvent); 2805 checkExternalId( anEvent);
2793 mCalendar->deleteEvent(anEvent); 2806 mCalendar->deleteEvent(anEvent);
2794 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2807 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2795 break; 2808 break;
2796 } // switch 2809 } // switch
2797 } else { 2810 } else {
2798 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2811 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2799 schedule(Scheduler::Cancel,anEvent); 2812 schedule(Scheduler::Cancel,anEvent);
2800 checkExternalId( anEvent); 2813 checkExternalId( anEvent);
2801 mCalendar->deleteEvent(anEvent); 2814 mCalendar->deleteEvent(anEvent);
2802 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2815 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2803 } 2816 }
2804 } // if-else 2817 } // if-else
2805 emit updateSearchDialog(); 2818 emit updateSearchDialog();
2806} 2819}
2807 2820
2808bool CalendarView::deleteEvent(const QString &uid) 2821bool CalendarView::deleteEvent(const QString &uid)
2809{ 2822{
2810 Event *ev = mCalendar->event(uid); 2823 Event *ev = mCalendar->event(uid);
2811 if (ev) { 2824 if (ev) {
2812 deleteEvent(ev); 2825 deleteEvent(ev);
2813 return true; 2826 return true;
2814 } else { 2827 } else {
2815 return false; 2828 return false;
2816 } 2829 }
2817} 2830}
2818 2831
2819/*****************************************************************************/ 2832/*****************************************************************************/
2820 2833
2821void CalendarView::action_mail() 2834void CalendarView::action_mail()
2822{ 2835{
2823#ifndef KORG_NOMAIL 2836#ifndef KORG_NOMAIL
2824 KOMailClient mailClient; 2837 KOMailClient mailClient;
2825 2838
2826 Incidence *incidence = currentSelection(); 2839 Incidence *incidence = currentSelection();
2827 2840
2828 if (!incidence) { 2841 if (!incidence) {
2829 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 2842 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
2830 return; 2843 return;
2831 } 2844 }
2832 if(incidence->attendeeCount() == 0 ) { 2845 if(incidence->attendeeCount() == 0 ) {
2833 KMessageBox::sorry(this, 2846 KMessageBox::sorry(this,
2834 i18n("Can't generate mail:\nNo attendees defined.\n")); 2847 i18n("Can't generate mail:\nNo attendees defined.\n"));
2835 return; 2848 return;
2836 } 2849 }
2837 2850
2838 CalendarLocal cal_tmp; 2851 CalendarLocal cal_tmp;
2839 Event *event = 0; 2852 Event *event = 0;
2840 Event *ev = 0; 2853 Event *ev = 0;
2841 if ( incidence && incidence->type() == "Event" ) { 2854 if ( incidence && incidence->type() == "Event" ) {
2842 event = static_cast<Event *>(incidence); 2855 event = static_cast<Event *>(incidence);
2843 ev = new Event(*event); 2856 ev = new Event(*event);
2844 cal_tmp.addEvent(ev); 2857 cal_tmp.addEvent(ev);
2845 } 2858 }
2846 ICalFormat mForm( KOPrefs::instance()->mUseQuicksave); 2859 ICalFormat mForm( KOPrefs::instance()->mUseQuicksave);
2847 QString attachment = mForm.toString( &cal_tmp ); 2860 QString attachment = mForm.toString( &cal_tmp );
2848 if (ev) delete(ev); 2861 if (ev) delete(ev);
2849 2862
2850 mailClient.mailAttendees(currentSelection(), attachment); 2863 mailClient.mailAttendees(currentSelection(), attachment);
2851 2864
2852#endif 2865#endif
2853 2866
2854#if 0 2867#if 0
2855 Event *anEvent = 0; 2868 Event *anEvent = 0;
2856 if (mViewManager->currentView()->isEventView()) { 2869 if (mViewManager->currentView()->isEventView()) {
2857 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); 2870 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first());
2858 } 2871 }
2859 2872
2860 if (!anEvent) { 2873 if (!anEvent) {
2861 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 2874 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
2862 return; 2875 return;
2863 } 2876 }
2864 if(anEvent->attendeeCount() == 0 ) { 2877 if(anEvent->attendeeCount() == 0 ) {
2865 KMessageBox::sorry(this, 2878 KMessageBox::sorry(this,
2866 i18n("Can't generate mail:\nNo attendees defined.\n")); 2879 i18n("Can't generate mail:\nNo attendees defined.\n"));
2867 return; 2880 return;
2868 } 2881 }
2869 2882
2870 mailobject.emailEvent(anEvent); 2883 mailobject.emailEvent(anEvent);
2871#endif 2884#endif
2872} 2885}
2873 2886
2874 2887
2875void CalendarView::schedule_publish(Incidence *incidence) 2888void CalendarView::schedule_publish(Incidence *incidence)
2876{ 2889{
2877 Event *event = 0; 2890 Event *event = 0;
2878 Todo *todo = 0; 2891 Todo *todo = 0;
2879 2892
2880 if (incidence == 0) { 2893 if (incidence == 0) {
2881 incidence = mViewManager->currentView()->selectedIncidences().first(); 2894 incidence = mViewManager->currentView()->selectedIncidences().first();
2882 if (incidence == 0) { 2895 if (incidence == 0) {
2883 incidence = mTodoList->selectedIncidences().first(); 2896 incidence = mTodoList->selectedIncidences().first();
2884 } 2897 }
2885 } 2898 }
2886 if ( incidence && incidence->type() == "Event" ) { 2899 if ( incidence && incidence->type() == "Event" ) {
2887 event = static_cast<Event *>(incidence); 2900 event = static_cast<Event *>(incidence);
2888 } else { 2901 } else {
2889 if ( incidence && incidence->type() == "Todo" ) { 2902 if ( incidence && incidence->type() == "Todo" ) {
2890 todo = static_cast<Todo *>(incidence); 2903 todo = static_cast<Todo *>(incidence);
2891 } 2904 }
2892 } 2905 }
2893 2906
2894 if (!event && !todo) { 2907 if (!event && !todo) {
2895 KMessageBox::sorry(this,i18n("No event selected.")); 2908 KMessageBox::sorry(this,i18n("No event selected."));
2896 return; 2909 return;
2897 } 2910 }
2898 2911
2899 PublishDialog *publishdlg = new PublishDialog(); 2912 PublishDialog *publishdlg = new PublishDialog();
2900 if (incidence->attendeeCount()>0) { 2913 if (incidence->attendeeCount()>0) {
2901 QPtrList<Attendee> attendees = incidence->attendees(); 2914 QPtrList<Attendee> attendees = incidence->attendees();
2902 attendees.first(); 2915 attendees.first();
2903 while ( attendees.current()!=0 ) { 2916 while ( attendees.current()!=0 ) {
2904 publishdlg->addAttendee(attendees.current()); 2917 publishdlg->addAttendee(attendees.current());
2905 attendees.next(); 2918 attendees.next();
2906 } 2919 }
2907 } 2920 }
2908 bool send = true; 2921 bool send = true;
2909 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { 2922 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) {
2910 if ( publishdlg->exec() != QDialog::Accepted ) 2923 if ( publishdlg->exec() != QDialog::Accepted )
2911 send = false; 2924 send = false;
2912 } 2925 }
2913 if ( send ) { 2926 if ( send ) {
2914 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 2927 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
2915 if ( event ) { 2928 if ( event ) {
2916 Event *ev = new Event(*event); 2929 Event *ev = new Event(*event);
2917 ev->registerObserver(0); 2930 ev->registerObserver(0);
2918 ev->clearAttendees(); 2931 ev->clearAttendees();
2919 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 2932 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
2920 delete(ev); 2933 delete(ev);
2921 } 2934 }
2922 } else { 2935 } else {
2923 if ( todo ) { 2936 if ( todo ) {
2924 Todo *ev = new Todo(*todo); 2937 Todo *ev = new Todo(*todo);
2925 ev->registerObserver(0); 2938 ev->registerObserver(0);
2926 ev->clearAttendees(); 2939 ev->clearAttendees();
2927 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 2940 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
2928 delete(ev); 2941 delete(ev);
2929 } 2942 }
2930 } 2943 }
2931 } 2944 }
2932 } 2945 }
2933 delete publishdlg; 2946 delete publishdlg;
2934} 2947}
2935 2948
2936void CalendarView::schedule_request(Incidence *incidence) 2949void CalendarView::schedule_request(Incidence *incidence)
2937{ 2950{
2938 schedule(Scheduler::Request,incidence); 2951 schedule(Scheduler::Request,incidence);
2939} 2952}
2940 2953
2941void CalendarView::schedule_refresh(Incidence *incidence) 2954void CalendarView::schedule_refresh(Incidence *incidence)
2942{ 2955{
2943 schedule(Scheduler::Refresh,incidence); 2956 schedule(Scheduler::Refresh,incidence);
2944} 2957}
2945 2958
2946void CalendarView::schedule_cancel(Incidence *incidence) 2959void CalendarView::schedule_cancel(Incidence *incidence)
2947{ 2960{
2948 schedule(Scheduler::Cancel,incidence); 2961 schedule(Scheduler::Cancel,incidence);
2949} 2962}
2950 2963
2951void CalendarView::schedule_add(Incidence *incidence) 2964void CalendarView::schedule_add(Incidence *incidence)
2952{ 2965{
2953 schedule(Scheduler::Add,incidence); 2966 schedule(Scheduler::Add,incidence);
2954} 2967}
2955 2968
2956void CalendarView::schedule_reply(Incidence *incidence) 2969void CalendarView::schedule_reply(Incidence *incidence)
2957{ 2970{
2958 schedule(Scheduler::Reply,incidence); 2971 schedule(Scheduler::Reply,incidence);
2959} 2972}
2960 2973
2961void CalendarView::schedule_counter(Incidence *incidence) 2974void CalendarView::schedule_counter(Incidence *incidence)
2962{ 2975{
2963 schedule(Scheduler::Counter,incidence); 2976 schedule(Scheduler::Counter,incidence);
2964} 2977}
2965 2978
2966void CalendarView::schedule_declinecounter(Incidence *incidence) 2979void CalendarView::schedule_declinecounter(Incidence *incidence)
2967{ 2980{
2968 schedule(Scheduler::Declinecounter,incidence); 2981 schedule(Scheduler::Declinecounter,incidence);
2969} 2982}
2970 2983
2971void CalendarView::schedule_publish_freebusy(int daysToPublish) 2984void CalendarView::schedule_publish_freebusy(int daysToPublish)
2972{ 2985{
2973 QDateTime start = QDateTime::currentDateTime(); 2986 QDateTime start = QDateTime::currentDateTime();
2974 QDateTime end = start.addDays(daysToPublish); 2987 QDateTime end = start.addDays(daysToPublish);
2975 2988
2976 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); 2989 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end);
2977 freebusy->setOrganizer(KOPrefs::instance()->email()); 2990 freebusy->setOrganizer(KOPrefs::instance()->email());
2978 2991
2979 2992
2980 PublishDialog *publishdlg = new PublishDialog(); 2993 PublishDialog *publishdlg = new PublishDialog();
2981 if ( publishdlg->exec() == QDialog::Accepted ) { 2994 if ( publishdlg->exec() == QDialog::Accepted ) {
2982 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 2995 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
2983 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { 2996 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) {
2984 delete(freebusy); 2997 delete(freebusy);
2985 } 2998 }
2986 } 2999 }
2987 delete publishdlg; 3000 delete publishdlg;
2988} 3001}
2989 3002
2990void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) 3003void CalendarView::schedule(Scheduler::Method method, Incidence *incidence)
2991{ 3004{
2992 Event *event = 0; 3005 Event *event = 0;
2993 Todo *todo = 0; 3006 Todo *todo = 0;
2994 3007
2995 if (incidence == 0) { 3008 if (incidence == 0) {
2996 incidence = mViewManager->currentView()->selectedIncidences().first(); 3009 incidence = mViewManager->currentView()->selectedIncidences().first();
2997 if (incidence == 0) { 3010 if (incidence == 0) {
2998 incidence = mTodoList->selectedIncidences().first(); 3011 incidence = mTodoList->selectedIncidences().first();
2999 } 3012 }
3000 } 3013 }
3001 if ( incidence && incidence->type() == "Event" ) { 3014 if ( incidence && incidence->type() == "Event" ) {
3002 event = static_cast<Event *>(incidence); 3015 event = static_cast<Event *>(incidence);
3003 } 3016 }
3004 if ( incidence && incidence->type() == "Todo" ) { 3017 if ( incidence && incidence->type() == "Todo" ) {
3005 todo = static_cast<Todo *>(incidence); 3018 todo = static_cast<Todo *>(incidence);
3006 } 3019 }
3007 3020
3008 if (!event && !todo) { 3021 if (!event && !todo) {
3009 KMessageBox::sorry(this,i18n("No event selected.")); 3022 KMessageBox::sorry(this,i18n("No event selected."));
3010 return; 3023 return;
3011 } 3024 }
3012 3025
3013 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { 3026 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) {
3014 KMessageBox::sorry(this,i18n("The event has no attendees.")); 3027 KMessageBox::sorry(this,i18n("The event has no attendees."));
3015 return; 3028 return;
3016 } 3029 }
3017 3030
3018 Event *ev = 0; 3031 Event *ev = 0;
3019 if (event) ev = new Event(*event); 3032 if (event) ev = new Event(*event);
3020 Todo *to = 0; 3033 Todo *to = 0;
3021 if (todo) to = new Todo(*todo); 3034 if (todo) to = new Todo(*todo);
3022 3035
3023 if (method == Scheduler::Reply || method == Scheduler::Refresh) { 3036 if (method == Scheduler::Reply || method == Scheduler::Refresh) {
3024 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 3037 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
3025 if (!me) { 3038 if (!me) {
3026 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); 3039 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails."));
3027 return; 3040 return;
3028 } 3041 }
3029 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { 3042 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) {
3030 StatusDialog *statdlg = new StatusDialog(this); 3043 StatusDialog *statdlg = new StatusDialog(this);
3031 if (!statdlg->exec()==QDialog::Accepted) return; 3044 if (!statdlg->exec()==QDialog::Accepted) return;
3032 me->setStatus( statdlg->status() ); 3045 me->setStatus( statdlg->status() );
3033 delete(statdlg); 3046 delete(statdlg);
3034 } 3047 }
3035 Attendee *menew = new Attendee(*me); 3048 Attendee *menew = new Attendee(*me);
3036 if (ev) { 3049 if (ev) {
3037 ev->clearAttendees(); 3050 ev->clearAttendees();
3038 ev->addAttendee(menew,false); 3051 ev->addAttendee(menew,false);
3039 } else { 3052 } else {
3040 if (to) { 3053 if (to) {
3041 todo->clearAttendees(); 3054 todo->clearAttendees();
3042 todo->addAttendee(menew,false); 3055 todo->addAttendee(menew,false);
3043 } 3056 }
3044 } 3057 }
3045 } 3058 }
3046 3059
3047 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3060 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3048 if (ev) { 3061 if (ev) {
3049 if ( !dlg->addMessage(ev,method) ) delete(ev); 3062 if ( !dlg->addMessage(ev,method) ) delete(ev);
3050 } else { 3063 } else {
3051 if (to) { 3064 if (to) {
3052 if ( !dlg->addMessage(to,method) ) delete(to); 3065 if ( !dlg->addMessage(to,method) ) delete(to);
3053 } 3066 }
3054 } 3067 }
3055} 3068}
3056 3069
3057void CalendarView::openAddressbook() 3070void CalendarView::openAddressbook()
3058{ 3071{
3059 KRun::runCommand("kaddressbook"); 3072 KRun::runCommand("kaddressbook");
3060} 3073}
3061 3074
3062void CalendarView::setModified(bool modified) 3075void CalendarView::setModified(bool modified)
3063{ 3076{
3064 if ( modified ) 3077 if ( modified )
3065 emit signalmodified(); 3078 emit signalmodified();
3066 if (mModified != modified) { 3079 if (mModified != modified) {
3067 mModified = modified; 3080 mModified = modified;
3068 emit modifiedChanged(mModified); 3081 emit modifiedChanged(mModified);
3069 } 3082 }
3070} 3083}
3071 3084
3072bool CalendarView::isReadOnly() 3085bool CalendarView::isReadOnly()
3073{ 3086{
3074 return mReadOnly; 3087 return mReadOnly;
3075} 3088}
3076 3089
3077void CalendarView::setReadOnly(bool readOnly) 3090void CalendarView::setReadOnly(bool readOnly)
3078{ 3091{
3079 if (mReadOnly != readOnly) { 3092 if (mReadOnly != readOnly) {
3080 mReadOnly = readOnly; 3093 mReadOnly = readOnly;
3081 emit readOnlyChanged(mReadOnly); 3094 emit readOnlyChanged(mReadOnly);
3082 } 3095 }
3083} 3096}
3084 3097
3085bool CalendarView::isModified() 3098bool CalendarView::isModified()
3086{ 3099{
3087 return mModified; 3100 return mModified;
3088} 3101}
3089 3102
3090void CalendarView::printSetup() 3103void CalendarView::printSetup()
3091{ 3104{
3092#ifndef KORG_NOPRINTER 3105#ifndef KORG_NOPRINTER
3093 createPrinter(); 3106 createPrinter();
3094 3107
3095 mCalPrinter->setupPrinter(); 3108 mCalPrinter->setupPrinter();
3096#endif 3109#endif
3097} 3110}
3098 3111
3099void CalendarView::print() 3112void CalendarView::print()
3100{ 3113{
3101#ifndef KORG_NOPRINTER 3114#ifndef KORG_NOPRINTER
3102 createPrinter(); 3115 createPrinter();
3103 3116
3104 DateList tmpDateList = mNavigator->selectedDates(); 3117 DateList tmpDateList = mNavigator->selectedDates();
3105 mCalPrinter->print(CalPrinter::Month, 3118 mCalPrinter->print(CalPrinter::Month,
3106 tmpDateList.first(), tmpDateList.last()); 3119 tmpDateList.first(), tmpDateList.last());
3107#endif 3120#endif
3108} 3121}
3109 3122
3110void CalendarView::printPreview() 3123void CalendarView::printPreview()
3111{ 3124{
3112#ifndef KORG_NOPRINTER 3125#ifndef KORG_NOPRINTER
3113 kdDebug() << "CalendarView::printPreview()" << endl; 3126 kdDebug() << "CalendarView::printPreview()" << endl;
3114 3127
3115 createPrinter(); 3128 createPrinter();
3116 3129
3117 DateList tmpDateList = mNavigator->selectedDates(); 3130 DateList tmpDateList = mNavigator->selectedDates();
3118 3131
3119 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), 3132 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(),
3120 tmpDateList.last()); 3133 tmpDateList.last());
3121#endif 3134#endif
3122} 3135}
3123 3136
3124void CalendarView::exportICalendar() 3137void CalendarView::exportICalendar()
3125{ 3138{
3126 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); 3139 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this);
3127 3140
3128 // Force correct extension 3141 // Force correct extension
3129 if (filename.right(4) != ".ics") filename += ".ics"; 3142 if (filename.right(4) != ".ics") filename += ".ics";
3130 3143
3131 FileStorage storage( mCalendar, filename, new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 3144 FileStorage storage( mCalendar, filename, new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
3132 storage.save(); 3145 storage.save();
3133} 3146}
3134 3147
3135bool CalendarView::exportVCalendar( QString filename ) 3148bool CalendarView::exportVCalendar( QString filename )
3136{ 3149{
3137 if (mCalendar->journals().count() > 0) { 3150 if (mCalendar->journals().count() > 0) {
3138 int result = KMessageBox::warningContinueCancel(this, 3151 int result = KMessageBox::warningContinueCancel(this,
3139 i18n("The journal entries can not be\nexported to a vCalendar file."), 3152 i18n("The journal entries can not be\nexported to a vCalendar file."),
3140 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 3153 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
3141 true); 3154 true);
3142 if (result != KMessageBox::Continue) return false; 3155 if (result != KMessageBox::Continue) return false;
3143 } 3156 }
3144 3157
3145 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); 3158 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this);
3146 3159
3147 // Force correct extension 3160 // Force correct extension
3148 if (filename.right(4) != ".vcs") filename += ".vcs"; 3161 if (filename.right(4) != ".vcs") filename += ".vcs";
3149 3162
3150 FileStorage storage( mCalendar, filename, new VCalFormat ); 3163 FileStorage storage( mCalendar, filename, new VCalFormat );
3151 return storage.save(); 3164 return storage.save();
3152 3165
3153} 3166}
3154 3167
3155void CalendarView::eventUpdated(Incidence *) 3168void CalendarView::eventUpdated(Incidence *)
3156{ 3169{
3157 setModified(); 3170 setModified();
3158 // Don't call updateView here. The code, which has caused the update of the 3171 // Don't call updateView here. The code, which has caused the update of the
3159 // event is responsible for updating the view. 3172 // event is responsible for updating the view.
3160 // updateView(); 3173 // updateView();
3161} 3174}
3162 3175
3163void CalendarView::adaptNavigationUnits() 3176void CalendarView::adaptNavigationUnits()
3164{ 3177{
3165 if (mViewManager->currentView()->isEventView()) { 3178 if (mViewManager->currentView()->isEventView()) {
3166 int days = mViewManager->currentView()->currentDateCount(); 3179 int days = mViewManager->currentView()->currentDateCount();
3167 if (days == 1) { 3180 if (days == 1) {
3168 emit changeNavStringPrev(i18n("&Previous Day")); 3181 emit changeNavStringPrev(i18n("&Previous Day"));
3169 emit changeNavStringNext(i18n("&Next Day")); 3182 emit changeNavStringNext(i18n("&Next Day"));
3170 } else { 3183 } else {
3171 emit changeNavStringPrev(i18n("&Previous Week")); 3184 emit changeNavStringPrev(i18n("&Previous Week"));
3172 emit changeNavStringNext(i18n("&Next Week")); 3185 emit changeNavStringNext(i18n("&Next Week"));
3173 } 3186 }
3174 } 3187 }
3175} 3188}
3176 3189
3177void CalendarView::processMainViewSelection( Incidence *incidence ) 3190void CalendarView::processMainViewSelection( Incidence *incidence )
3178{ 3191{
3179 if ( incidence ) mTodoList->clearSelection(); 3192 if ( incidence ) mTodoList->clearSelection();
3180 processIncidenceSelection( incidence ); 3193 processIncidenceSelection( incidence );
3181} 3194}
3182 3195
3183void CalendarView::processTodoListSelection( Incidence *incidence ) 3196void CalendarView::processTodoListSelection( Incidence *incidence )
3184{ 3197{
3185 if ( incidence && mViewManager->currentView() ) { 3198 if ( incidence && mViewManager->currentView() ) {
3186 mViewManager->currentView()->clearSelection(); 3199 mViewManager->currentView()->clearSelection();
3187 } 3200 }
3188 processIncidenceSelection( incidence ); 3201 processIncidenceSelection( incidence );
3189} 3202}
3190 3203
3191void CalendarView::processIncidenceSelection( Incidence *incidence ) 3204void CalendarView::processIncidenceSelection( Incidence *incidence )
3192{ 3205{
3193 if ( incidence == mSelectedIncidence ) return; 3206 if ( incidence == mSelectedIncidence ) return;
3194 3207
3195 mSelectedIncidence = incidence; 3208 mSelectedIncidence = incidence;
3196 3209
3197 emit incidenceSelected( mSelectedIncidence ); 3210 emit incidenceSelected( mSelectedIncidence );
3198 3211
3199 if ( incidence && incidence->type() == "Event" ) { 3212 if ( incidence && incidence->type() == "Event" ) {
3200 Event *event = static_cast<Event *>( incidence ); 3213 Event *event = static_cast<Event *>( incidence );
3201 if ( event->organizer() == KOPrefs::instance()->email() ) { 3214 if ( event->organizer() == KOPrefs::instance()->email() ) {
3202 emit organizerEventsSelected( true ); 3215 emit organizerEventsSelected( true );
3203 } else { 3216 } else {
3204 emit organizerEventsSelected(false); 3217 emit organizerEventsSelected(false);
3205 } 3218 }
3206 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3219 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3207 KOPrefs::instance()->email() ) ) { 3220 KOPrefs::instance()->email() ) ) {
3208 emit groupEventsSelected( true ); 3221 emit groupEventsSelected( true );
3209 } else { 3222 } else {
3210 emit groupEventsSelected(false); 3223 emit groupEventsSelected(false);
3211 } 3224 }
3212 return; 3225 return;
3213 } else { 3226 } else {
3214 if ( incidence && incidence->type() == "Todo" ) { 3227 if ( incidence && incidence->type() == "Todo" ) {
3215 emit todoSelected( true ); 3228 emit todoSelected( true );
3216 Todo *event = static_cast<Todo *>( incidence ); 3229 Todo *event = static_cast<Todo *>( incidence );
3217 if ( event->organizer() == KOPrefs::instance()->email() ) { 3230 if ( event->organizer() == KOPrefs::instance()->email() ) {
3218 emit organizerEventsSelected( true ); 3231 emit organizerEventsSelected( true );
3219 } else { 3232 } else {
3220 emit organizerEventsSelected(false); 3233 emit organizerEventsSelected(false);
3221 } 3234 }
3222 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3235 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3223 KOPrefs::instance()->email() ) ) { 3236 KOPrefs::instance()->email() ) ) {
3224 emit groupEventsSelected( true ); 3237 emit groupEventsSelected( true );
3225 } else { 3238 } else {
3226 emit groupEventsSelected(false); 3239 emit groupEventsSelected(false);
3227 } 3240 }
3228 return; 3241 return;
3229 } else { 3242 } else {
3230 emit todoSelected( false ); 3243 emit todoSelected( false );
3231 emit organizerEventsSelected(false); 3244 emit organizerEventsSelected(false);
3232 emit groupEventsSelected(false); 3245 emit groupEventsSelected(false);
3233 } 3246 }
3234 return; 3247 return;
3235 } 3248 }
3236 3249
3237 /* if ( incidence && incidence->type() == "Todo" ) { 3250 /* if ( incidence && incidence->type() == "Todo" ) {
3238 emit todoSelected( true ); 3251 emit todoSelected( true );
3239 } else { 3252 } else {
3240 emit todoSelected( false ); 3253 emit todoSelected( false );
3241 }*/ 3254 }*/
3242} 3255}
3243 3256
3244 3257
3245void CalendarView::checkClipboard() 3258void CalendarView::checkClipboard()
3246{ 3259{
3247#ifndef KORG_NODND 3260#ifndef KORG_NODND
3248 if (ICalDrag::canDecode(QApplication::clipboard()->data())) { 3261 if (ICalDrag::canDecode(QApplication::clipboard()->data())) {
3249 emit pasteEnabled(true); 3262 emit pasteEnabled(true);
3250 } else { 3263 } else {
3251 emit pasteEnabled(false); 3264 emit pasteEnabled(false);
3252 } 3265 }
3253#endif 3266#endif
3254} 3267}
3255 3268
3256void CalendarView::showDates(const DateList &selectedDates) 3269void CalendarView::showDates(const DateList &selectedDates)
3257{ 3270{
3258 // kdDebug() << "CalendarView::selectDates()" << endl; 3271 // kdDebug() << "CalendarView::selectDates()" << endl;
3259 3272
3260 if ( mViewManager->currentView() ) { 3273 if ( mViewManager->currentView() ) {
3261 updateView( selectedDates.first(), selectedDates.last() ); 3274 updateView( selectedDates.first(), selectedDates.last() );
3262 } else { 3275 } else {
3263 mViewManager->showAgendaView(); 3276 mViewManager->showAgendaView();
3264 } 3277 }
3265 3278
3266 QString selDates; 3279 QString selDates;
3267 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); 3280 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true);
3268 if (selectedDates.first() < selectedDates.last() ) 3281 if (selectedDates.first() < selectedDates.last() )
3269 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); 3282 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true);
3270 topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); 3283 topLevelWidget()->setCaption( i18n("Dates: ") + selDates );
3271 3284
3272} 3285}
3273 3286
3274QPtrList<CalFilter> CalendarView::filters() 3287QPtrList<CalFilter> CalendarView::filters()
3275{ 3288{
3276 return mFilters; 3289 return mFilters;
3277 3290
3278} 3291}
3279void CalendarView::editFilters() 3292void CalendarView::editFilters()
3280{ 3293{
3281 // kdDebug() << "CalendarView::editFilters()" << endl; 3294 // kdDebug() << "CalendarView::editFilters()" << endl;
3282 3295
3283 CalFilter *filter = mFilters.first(); 3296 CalFilter *filter = mFilters.first();
3284 while(filter) { 3297 while(filter) {
3285 kdDebug() << " Filter: " << filter->name() << endl; 3298 kdDebug() << " Filter: " << filter->name() << endl;
3286 filter = mFilters.next(); 3299 filter = mFilters.next();
3287 } 3300 }
3288 3301
3289 mDialogManager->showFilterEditDialog(&mFilters); 3302 mDialogManager->showFilterEditDialog(&mFilters);
3290} 3303}
3291void CalendarView::toggleFilter() 3304void CalendarView::toggleFilter()
3292{ 3305{
3293 showFilter(! mFilterView->isVisible()); 3306 showFilter(! mFilterView->isVisible());
3294} 3307}
3295 3308
3296KOFilterView *CalendarView::filterView() 3309KOFilterView *CalendarView::filterView()
3297{ 3310{
3298 return mFilterView; 3311 return mFilterView;
3299} 3312}
3300void CalendarView::selectFilter( int fil ) 3313void CalendarView::selectFilter( int fil )
3301{ 3314{
3302 mFilterView->setSelectedFilter( fil ); 3315 mFilterView->setSelectedFilter( fil );
3303} 3316}
3304void CalendarView::showFilter(bool visible) 3317void CalendarView::showFilter(bool visible)
3305{ 3318{
3306 if (visible) mFilterView->show(); 3319 if (visible) mFilterView->show();
3307 else mFilterView->hide(); 3320 else mFilterView->hide();
3308} 3321}
3309void CalendarView::toggleFilerEnabled( ) 3322void CalendarView::toggleFilerEnabled( )
3310{ 3323{
3311 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); 3324 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() );
3312 if ( !mFilterView->filtersEnabled() ) 3325 if ( !mFilterView->filtersEnabled() )
3313 topLevelWidget()->setCaption( i18n("Filter disabled ") ); 3326 topLevelWidget()->setCaption( i18n("Filter disabled ") );
3314 3327
3315} 3328}
3316void CalendarView::updateFilter() 3329void CalendarView::updateFilter()
3317{ 3330{
3318 CalFilter *filter = mFilterView->selectedFilter(); 3331 CalFilter *filter = mFilterView->selectedFilter();
3319 if (filter) { 3332 if (filter) {
3320 if (mFilterView->filtersEnabled()) { 3333 if (mFilterView->filtersEnabled()) {
3321 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); 3334 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() );
3322 filter->setEnabled(true); 3335 filter->setEnabled(true);
3323 } 3336 }
3324 else filter->setEnabled(false); 3337 else filter->setEnabled(false);
3325 mCalendar->setFilter(filter); 3338 mCalendar->setFilter(filter);
3326 updateView(); 3339 updateView();
3327 } 3340 }
3328} 3341}
3329 3342
3330void CalendarView::filterEdited() 3343void CalendarView::filterEdited()
3331{ 3344{
3332 mFilterView->updateFilters(); 3345 mFilterView->updateFilters();
3333 updateFilter(); 3346 updateFilter();
3334 writeSettings(); 3347 writeSettings();
3335} 3348}
3336 3349
3337 3350
3338void CalendarView::takeOverEvent() 3351void CalendarView::takeOverEvent()
3339{ 3352{
3340 Incidence *incidence = currentSelection(); 3353 Incidence *incidence = currentSelection();
3341 3354
3342 if (!incidence) return; 3355 if (!incidence) return;
3343 3356
3344 incidence->setOrganizer(KOPrefs::instance()->email()); 3357 incidence->setOrganizer(KOPrefs::instance()->email());
3345 incidence->recreate(); 3358 incidence->recreate();
3346 incidence->setReadOnly(false); 3359 incidence->setReadOnly(false);
3347 3360
3348 updateView(); 3361 updateView();
3349} 3362}
3350 3363
3351void CalendarView::takeOverCalendar() 3364void CalendarView::takeOverCalendar()
3352{ 3365{
3353 // TODO: Create Calendar::allIncidences() function and use it here 3366 // TODO: Create Calendar::allIncidences() function and use it here
3354 3367
3355 QPtrList<Event> events = mCalendar->events(); 3368 QPtrList<Event> events = mCalendar->events();
3356 for(uint i=0; i<events.count(); ++i) { 3369 for(uint i=0; i<events.count(); ++i) {
3357 events.at(i)->setOrganizer(KOPrefs::instance()->email()); 3370 events.at(i)->setOrganizer(KOPrefs::instance()->email());
3358 events.at(i)->recreate(); 3371 events.at(i)->recreate();
3359 events.at(i)->setReadOnly(false); 3372 events.at(i)->setReadOnly(false);
3360 } 3373 }
3361 3374
3362 QPtrList<Todo> todos = mCalendar->todos(); 3375 QPtrList<Todo> todos = mCalendar->todos();
3363 for(uint i=0; i<todos.count(); ++i) { 3376 for(uint i=0; i<todos.count(); ++i) {
3364 todos.at(i)->setOrganizer(KOPrefs::instance()->email()); 3377 todos.at(i)->setOrganizer(KOPrefs::instance()->email());
3365 todos.at(i)->recreate(); 3378 todos.at(i)->recreate();
3366 todos.at(i)->setReadOnly(false); 3379 todos.at(i)->setReadOnly(false);
3367 } 3380 }
3368 3381
3369 QPtrList<Journal> journals = mCalendar->journals(); 3382 QPtrList<Journal> journals = mCalendar->journals();
3370 for(uint i=0; i<journals.count(); ++i) { 3383 for(uint i=0; i<journals.count(); ++i) {
3371 journals.at(i)->setOrganizer(KOPrefs::instance()->email()); 3384 journals.at(i)->setOrganizer(KOPrefs::instance()->email());
3372 journals.at(i)->recreate(); 3385 journals.at(i)->recreate();
3373 journals.at(i)->setReadOnly(false); 3386 journals.at(i)->setReadOnly(false);
3374 } 3387 }
3375 3388
3376 updateView(); 3389 updateView();
3377} 3390}
3378 3391
3379void CalendarView::showIntro() 3392void CalendarView::showIntro()
3380{ 3393{
3381 kdDebug() << "To be implemented." << endl; 3394 kdDebug() << "To be implemented." << endl;
3382} 3395}
3383 3396
3384QWidgetStack *CalendarView::viewStack() 3397QWidgetStack *CalendarView::viewStack()
3385{ 3398{
3386 return mRightFrame; 3399 return mRightFrame;
3387} 3400}
3388 3401
3389QWidget *CalendarView::leftFrame() 3402QWidget *CalendarView::leftFrame()
3390{ 3403{
3391 return mLeftFrame; 3404 return mLeftFrame;
3392} 3405}
3393 3406
3394DateNavigator *CalendarView::dateNavigator() 3407DateNavigator *CalendarView::dateNavigator()
3395{ 3408{
3396 return mNavigator; 3409 return mNavigator;
3397} 3410}
3398 3411
3399KDateNavigator* CalendarView::dateNavigatorWidget() 3412KDateNavigator* CalendarView::dateNavigatorWidget()
3400{ 3413{
3401 return mDateNavigator; 3414 return mDateNavigator;
3402} 3415}
3403void CalendarView::toggleDateNavigatorWidget() 3416void CalendarView::toggleDateNavigatorWidget()
3404{ 3417{
3405 if (mDateNavigator->isVisible()) 3418 if (mDateNavigator->isVisible())
3406 mDateNavigator->hide(); 3419 mDateNavigator->hide();
3407 else 3420 else
3408 mDateNavigator->show(); 3421 mDateNavigator->show();
3409} 3422}
3410void CalendarView::addView(KOrg::BaseView *view) 3423void CalendarView::addView(KOrg::BaseView *view)
3411{ 3424{
3412 mViewManager->addView(view); 3425 mViewManager->addView(view);
3413} 3426}
3414 3427
3415void CalendarView::showView(KOrg::BaseView *view) 3428void CalendarView::showView(KOrg::BaseView *view)
3416{ 3429{
3417 mViewManager->showView(view, mLeftFrame->isVisible()); 3430 mViewManager->showView(view, mLeftFrame->isVisible());
3418} 3431}
3419 3432
3420Incidence *CalendarView::currentSelection() 3433Incidence *CalendarView::currentSelection()
3421{ 3434{
3422 return mViewManager->currentSelection(); 3435 return mViewManager->currentSelection();
3423} 3436}
3424void CalendarView::toggleAllDaySize() 3437void CalendarView::toggleAllDaySize()
3425{ 3438{
3426 /* 3439 /*
3427 if ( KOPrefs::instance()->mAllDaySize > 47 ) 3440 if ( KOPrefs::instance()->mAllDaySize > 47 )
3428 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; 3441 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2;
3429 else 3442 else
3430 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; 3443 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2;
3431 */ 3444 */
3432 viewManager()->agendaView()->toggleAllDay(); 3445 viewManager()->agendaView()->toggleAllDay();
3433} 3446}
3434void CalendarView::toggleExpand() 3447void CalendarView::toggleExpand()
3435{ 3448{
3436 // if ( mLeftFrame->isHidden() ) { 3449 // if ( mLeftFrame->isHidden() ) {
3437 // mLeftFrame->show(); 3450 // mLeftFrame->show();
3438 // emit calendarViewExpanded( false ); 3451 // emit calendarViewExpanded( false );
3439 // } else { 3452 // } else {
3440 // mLeftFrame->hide(); 3453 // mLeftFrame->hide();
3441 // emit calendarViewExpanded( true ); 3454 // emit calendarViewExpanded( true );
3442 // } 3455 // }
3443 3456
3444 globalFlagBlockAgenda = 1; 3457 globalFlagBlockAgenda = 1;
3445 emit calendarViewExpanded( !mLeftFrame->isHidden() ); 3458 emit calendarViewExpanded( !mLeftFrame->isHidden() );
3446 globalFlagBlockAgenda = 5; 3459 globalFlagBlockAgenda = 5;
3447 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); 3460 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() );
3448 //mViewManager->showView( 0, true ); 3461 //mViewManager->showView( 0, true );
3449} 3462}
3450 3463
3451void CalendarView::calendarModified( bool modified, Calendar * ) 3464void CalendarView::calendarModified( bool modified, Calendar * )
3452{ 3465{
3453 setModified( modified ); 3466 setModified( modified );
3454} 3467}
3455 3468
3456Todo *CalendarView::selectedTodo() 3469Todo *CalendarView::selectedTodo()
3457{ 3470{
3458 Incidence *incidence = currentSelection(); 3471 Incidence *incidence = currentSelection();
3459 if ( incidence && incidence->type() == "Todo" ) { 3472 if ( incidence && incidence->type() == "Todo" ) {
3460 return static_cast<Todo *>( incidence ); 3473 return static_cast<Todo *>( incidence );
3461 } 3474 }
3462 3475
3463 incidence = mTodoList->selectedIncidences().first(); 3476 incidence = mTodoList->selectedIncidences().first();
3464 if ( incidence && incidence->type() == "Todo" ) { 3477 if ( incidence && incidence->type() == "Todo" ) {
3465 return static_cast<Todo *>( incidence ); 3478 return static_cast<Todo *>( incidence );
3466 } 3479 }
3467 3480
3468 return 0; 3481 return 0;
3469} 3482}
3470 3483
3471void CalendarView::dialogClosing(Incidence *in) 3484void CalendarView::dialogClosing(Incidence *in)
3472{ 3485{
3473 // mDialogList.remove(in); 3486 // mDialogList.remove(in);
3474} 3487}
3475 3488
3476void CalendarView::showIncidence() 3489void CalendarView::showIncidence()
3477{ 3490{
3478 Incidence *incidence = currentSelection(); 3491 Incidence *incidence = currentSelection();
3479 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3492 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3480 if ( incidence ) { 3493 if ( incidence ) {
3481 ShowIncidenceVisitor v; 3494 ShowIncidenceVisitor v;
3482 v.act( incidence, this ); 3495 v.act( incidence, this );
3483 } 3496 }
3484} 3497}
3485void CalendarView::editIncidenceDescription() 3498void CalendarView::editIncidenceDescription()
3486{ 3499{
3487 mFlagEditDescription = true; 3500 mFlagEditDescription = true;
3488 editIncidence(); 3501 editIncidence();
3489 mFlagEditDescription = false; 3502 mFlagEditDescription = false;
3490} 3503}
3491void CalendarView::editIncidence() 3504void CalendarView::editIncidence()
3492{ 3505{
3493 // qDebug("editIncidence() "); 3506 // qDebug("editIncidence() ");
3494 Incidence *incidence = currentSelection(); 3507 Incidence *incidence = currentSelection();
3495 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3508 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3496 if ( incidence ) { 3509 if ( incidence ) {
3497 EditIncidenceVisitor v; 3510 EditIncidenceVisitor v;
3498 v.act( incidence, this ); 3511 v.act( incidence, this );
3499 } 3512 }
3500} 3513}
3501 3514
3502void CalendarView::deleteIncidence() 3515void CalendarView::deleteIncidence()
3503{ 3516{
3504 Incidence *incidence = currentSelection(); 3517 Incidence *incidence = currentSelection();
3505 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3518 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3506 if ( incidence ) { 3519 if ( incidence ) {
3507 deleteIncidence(incidence); 3520 deleteIncidence(incidence);
3508 } 3521 }
3509} 3522}
3510 3523
3511void CalendarView::showIncidence(Incidence *incidence) 3524void CalendarView::showIncidence(Incidence *incidence)
3512{ 3525{
3513 if ( incidence ) { 3526 if ( incidence ) {
3514 ShowIncidenceVisitor v; 3527 ShowIncidenceVisitor v;
3515 v.act( incidence, this ); 3528 v.act( incidence, this );
3516 } 3529 }
3517} 3530}
3518 3531
3519void CalendarView::editIncidence(Incidence *incidence) 3532void CalendarView::editIncidence(Incidence *incidence)
3520{ 3533{
3521 if ( incidence ) { 3534 if ( incidence ) {
3522 3535
3523 EditIncidenceVisitor v; 3536 EditIncidenceVisitor v;
3524 v.act( incidence, this ); 3537 v.act( incidence, this );
3525 3538
3526 } 3539 }
3527} 3540}
3528 3541
3529void CalendarView::deleteIncidence(Incidence *incidence) 3542void CalendarView::deleteIncidence(Incidence *incidence)
3530{ 3543{
3531 //qDebug(" CalendarView::deleteIncidence "); 3544 //qDebug(" CalendarView::deleteIncidence ");
3532 if ( incidence ) { 3545 if ( incidence ) {
3533 DeleteIncidenceVisitor v; 3546 DeleteIncidenceVisitor v;
3534 v.act( incidence, this ); 3547 v.act( incidence, this );
3535 } 3548 }
3536} 3549}
3537 3550
3538 3551
3539void CalendarView::lookForOutgoingMessages() 3552void CalendarView::lookForOutgoingMessages()
3540{ 3553{
3541 OutgoingDialog *ogd = mDialogManager->outgoingDialog(); 3554 OutgoingDialog *ogd = mDialogManager->outgoingDialog();
3542 ogd->loadMessages(); 3555 ogd->loadMessages();
3543} 3556}
3544 3557
3545void CalendarView::lookForIncomingMessages() 3558void CalendarView::lookForIncomingMessages()
3546{ 3559{
3547 IncomingDialog *icd = mDialogManager->incomingDialog(); 3560 IncomingDialog *icd = mDialogManager->incomingDialog();
3548 icd->retrieve(); 3561 icd->retrieve();
3549} 3562}
3550 3563
3551bool CalendarView::removeCompletedSubTodos( Todo* t ) 3564bool CalendarView::removeCompletedSubTodos( Todo* t )
3552{ 3565{
3553 bool deleteTodo = true; 3566 bool deleteTodo = true;
3554 QPtrList<Incidence> subTodos; 3567 QPtrList<Incidence> subTodos;
3555 Incidence *aTodo; 3568 Incidence *aTodo;
3556 subTodos = t->relations(); 3569 subTodos = t->relations();
3557 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { 3570 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
3558 if (! removeCompletedSubTodos( (Todo*) aTodo )) 3571 if (! removeCompletedSubTodos( (Todo*) aTodo ))
3559 deleteTodo = false; 3572 deleteTodo = false;
3560 } 3573 }
3561 if ( deleteTodo ) { 3574 if ( deleteTodo ) {
3562 if ( t->isCompleted() ) { 3575 if ( t->isCompleted() ) {
3563 checkExternalId( t ); 3576 checkExternalId( t );
3564 mCalendar->deleteTodo( t ); 3577 mCalendar->deleteTodo( t );
3565 changeTodoDisplay( t,KOGlobals::EVENTDELETED ); 3578 changeTodoDisplay( t,KOGlobals::EVENTDELETED );
3566 } 3579 }
3567 else 3580 else
3568 deleteTodo = false; 3581 deleteTodo = false;
3569 } 3582 }
3570 return deleteTodo; 3583 return deleteTodo;
3571 3584
3572} 3585}
3573void CalendarView::purgeCompleted() 3586void CalendarView::purgeCompleted()
3574{ 3587{
3575 int result = KMessageBox::warningContinueCancel(this, 3588 int result = KMessageBox::warningContinueCancel(this,
3576 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); 3589 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge"));
3577 3590
3578 if (result == KMessageBox::Continue) { 3591 if (result == KMessageBox::Continue) {
3579 3592
3580 QPtrList<Todo> todoCal; 3593 QPtrList<Todo> todoCal;
3581 QPtrList<Todo> rootTodos; 3594 QPtrList<Todo> rootTodos;
3582 //QPtrList<Incidence> rel; 3595 //QPtrList<Incidence> rel;
3583 Todo *aTodo;//, *rTodo; 3596 Todo *aTodo;//, *rTodo;
3584 Incidence *rIncidence; 3597 Incidence *rIncidence;
3585 bool childDelete = false; 3598 bool childDelete = false;
3586 bool deletedOne = true; 3599 bool deletedOne = true;
3587 todoCal = calendar()->todos(); 3600 todoCal = calendar()->todos();
3588 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { 3601 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
3589 if ( !aTodo->relatedTo() ) 3602 if ( !aTodo->relatedTo() )
3590 rootTodos.append( aTodo ); 3603 rootTodos.append( aTodo );
3591 } 3604 }
3592 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { 3605 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) {
3593 removeCompletedSubTodos( aTodo ); 3606 removeCompletedSubTodos( aTodo );
3594 } 3607 }
3595 3608
3596 updateView(); 3609 updateView();
3597 } 3610 }
3598} 3611}
3599 3612
3600void CalendarView::slotCalendarChanged() 3613void CalendarView::slotCalendarChanged()
3601{ 3614{
3602 ; 3615 ;
3603} 3616}
3604 3617
3605NavigatorBar *CalendarView::navigatorBar() 3618NavigatorBar *CalendarView::navigatorBar()
3606{ 3619{
3607 return mNavigatorBar; 3620 return mNavigatorBar;
3608} 3621}
3609 3622
3610 3623
3611 3624
3612void CalendarView::keyPressEvent ( QKeyEvent *e) 3625void CalendarView::keyPressEvent ( QKeyEvent *e)
3613{ 3626{
3614 //qDebug(" alendarView::keyPressEvent "); 3627 //qDebug(" alendarView::keyPressEvent ");
3615 e->ignore(); 3628 e->ignore();
3616} 3629}
3617 3630
3618//#include "calendarview.moc" 3631//#include "calendarview.moc"
3619 3632
3620//#include "calendarviewbase.moc" 3633//#include "calendarviewbase.moc"
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index a3315ad..355bb84 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -1,590 +1,591 @@
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 watchSavedFile();
175 void recheckTimerAlarm(); 176 void recheckTimerAlarm();
176 void checkNextTimerAlarm(); 177 void checkNextTimerAlarm();
177 void addAlarm(const QDateTime &qdt, const QString &noti ); 178 void addAlarm(const QDateTime &qdt, const QString &noti );
178 void addSuspendAlarm(const QDateTime &qdt, const QString &noti ); 179 void addSuspendAlarm(const QDateTime &qdt, const QString &noti );
179 void removeAlarm(const QDateTime &qdt, const QString &noti ); 180 void removeAlarm(const QDateTime &qdt, const QString &noti );
180 181
181 /** options dialog made a changed to the configuration. we catch this 182 /** options dialog made a changed to the configuration. we catch this
182 * and notify all widgets which need to update their configuration. */ 183 * and notify all widgets which need to update their configuration. */
183 void updateConfig(); 184 void updateConfig();
184 185
185 /** 186 /**
186 Load calendar from file \a filename. If \a merge is true, load 187 Load calendar from file \a filename. If \a merge is true, load
187 calendar into existing one, if it is false, clear calendar, before 188 calendar into existing one, if it is false, clear calendar, before
188 loading. Return true, if calendar could be successfully loaded. 189 loading. Return true, if calendar could be successfully loaded.
189 */ 190 */
190 bool openCalendar(QString filename, bool merge=false); 191 bool openCalendar(QString filename, bool merge=false);
191 bool syncCalendar(QString filename,int mode = 0 ); 192 bool syncCalendar(QString filename,int mode = 0 );
192 193
193 /** 194 /**
194 Save calendar data to file. Return true if calendar could be 195 Save calendar data to file. Return true if calendar could be
195 successfully saved. 196 successfully saved.
196 */ 197 */
197 bool saveCalendar(QString filename); 198 bool saveCalendar(QString filename);
198 199
199 /** 200 /**
200 Close calendar. Clear calendar data and reset views to display an empty 201 Close calendar. Clear calendar data and reset views to display an empty
201 calendar. 202 calendar.
202 */ 203 */
203 void closeCalendar(); 204 void closeCalendar();
204 205
205 /** Archive old events of calendar */ 206 /** Archive old events of calendar */
206 void archiveCalendar(); 207 void archiveCalendar();
207 208
208 void showIncidence(); 209 void showIncidence();
209 void editIncidence(); 210 void editIncidence();
210 void editIncidenceDescription(); 211 void editIncidenceDescription();
211 void deleteIncidence(); 212 void deleteIncidence();
212 213
213 /** create an editeventwin with supplied date/time, and if bool is true, 214 /** create an editeventwin with supplied date/time, and if bool is true,
214 * make the event take all day. */ 215 * make the event take all day. */
215 void newEvent(QDateTime, QDateTime, bool allDay = false); 216 void newEvent(QDateTime, QDateTime, bool allDay = false);
216 void newEvent(QDateTime fh); 217 void newEvent(QDateTime fh);
217 void newEvent(QDate dt); 218 void newEvent(QDate dt);
218 /** create new event without having a date hint. Takes current date as 219 /** create new event without having a date hint. Takes current date as
219 default hint. */ 220 default hint. */
220 void newEvent(); 221 void newEvent();
221 void newFloatingEvent(); 222 void newFloatingEvent();
222 223
223 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ 224 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/
224 void showIncidence(Incidence *); 225 void showIncidence(Incidence *);
225 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ 226 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/
226 void editIncidence(Incidence *); 227 void editIncidence(Incidence *);
227 /** Delete the supplied incidence. It calls the correct deleteXXX method*/ 228 /** Delete the supplied incidence. It calls the correct deleteXXX method*/
228 void deleteIncidence(Incidence *); 229 void deleteIncidence(Incidence *);
229 void cloneIncidence(Incidence *); 230 void cloneIncidence(Incidence *);
230 void cancelIncidence(Incidence *); 231 void cancelIncidence(Incidence *);
231 /** Create an editor for the supplied event. */ 232 /** Create an editor for the supplied event. */
232 void editEvent(Event *); 233 void editEvent(Event *);
233 /** Delete the supplied event. */ 234 /** Delete the supplied event. */
234 void deleteEvent(Event *); 235 void deleteEvent(Event *);
235 /** Delete the event with the given unique ID. Returns false, if event wasn't 236 /** Delete the event with the given unique ID. Returns false, if event wasn't
236 found. */ 237 found. */
237 bool deleteEvent(const QString &uid); 238 bool deleteEvent(const QString &uid);
238 /** Create a read-only viewer dialog for the supplied event. */ 239 /** Create a read-only viewer dialog for the supplied event. */
239 void showEvent(Event *); 240 void showEvent(Event *);
240 241
241 void editJournal(Journal *); 242 void editJournal(Journal *);
242 void showJournal(Journal *); 243 void showJournal(Journal *);
243 void deleteJournal(Journal *); 244 void deleteJournal(Journal *);
244 /** Create an editor dialog for a todo */ 245 /** Create an editor dialog for a todo */
245 void editTodo(Todo *); 246 void editTodo(Todo *);
246 /** Create a read-only viewer dialog for the supplied todo */ 247 /** Create a read-only viewer dialog for the supplied todo */
247 void showTodo(Todo *); 248 void showTodo(Todo *);
248 /** create new todo */ 249 /** create new todo */
249 void newTodo(); 250 void newTodo();
250 /** create new todo with a parent todo */ 251 /** create new todo with a parent todo */
251 void newSubTodo(); 252 void newSubTodo();
252 /** create new todo with a parent todo */ 253 /** create new todo with a parent todo */
253 void newSubTodo(Todo *); 254 void newSubTodo(Todo *);
254 /** Delete todo */ 255 /** Delete todo */
255 void deleteTodo(Todo *); 256 void deleteTodo(Todo *);
256 257
257 258
258 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is 259 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is
259 * emitted as result. */ 260 * emitted as result. */
260 void checkClipboard(); 261 void checkClipboard();
261 262
262 /** using the KConfig associated with the kapp variable, read in the 263 /** using the KConfig associated with the kapp variable, read in the
263 * settings from the config file. 264 * settings from the config file.
264 */ 265 */
265 void readSettings(); 266 void readSettings();
266 267
267 /** write current state to config file. */ 268 /** write current state to config file. */
268 void writeSettings(); 269 void writeSettings();
269 270
270 /** read settings for calendar filters */ 271 /** read settings for calendar filters */
271 void readFilterSettings(KConfig *config); 272 void readFilterSettings(KConfig *config);
272 273
273 /** write settings for calendar filters */ 274 /** write settings for calendar filters */
274 void writeFilterSettings(KConfig *config); 275 void writeFilterSettings(KConfig *config);
275 276
276 /** passes on the message that an event has changed to the currently 277 /** passes on the message that an event has changed to the currently
277 * activated view so that it can make appropriate display changes. */ 278 * activated view so that it can make appropriate display changes. */
278 void changeEventDisplay(Event *, int); 279 void changeEventDisplay(Event *, int);
279 void changeIncidenceDisplay(Incidence *, int); 280 void changeIncidenceDisplay(Incidence *, int);
280 void changeTodoDisplay(Todo *, int); 281 void changeTodoDisplay(Todo *, int);
281 282
282 void eventAdded(Event *); 283 void eventAdded(Event *);
283 void eventChanged(Event *); 284 void eventChanged(Event *);
284 void eventToBeDeleted(Event *); 285 void eventToBeDeleted(Event *);
285 void eventDeleted(); 286 void eventDeleted();
286 287
287 void todoAdded(Todo *); 288 void todoAdded(Todo *);
288 void todoChanged(Todo *); 289 void todoChanged(Todo *);
289 void todoToBeDeleted(Todo *); 290 void todoToBeDeleted(Todo *);
290 void todoDeleted(); 291 void todoDeleted();
291 292
292 void updateView(const QDate &start, const QDate &end); 293 void updateView(const QDate &start, const QDate &end);
293 void updateView(); 294 void updateView();
294 295
295 /** Full update of visible todo views */ 296 /** Full update of visible todo views */
296 void updateTodoViews(); 297 void updateTodoViews();
297 298
298 void updateUnmanagedViews(); 299 void updateUnmanagedViews();
299 300
300 /** cut the current appointment to the clipboard */ 301 /** cut the current appointment to the clipboard */
301 void edit_cut(); 302 void edit_cut();
302 303
303 /** copy the current appointment(s) to the clipboard */ 304 /** copy the current appointment(s) to the clipboard */
304 void edit_copy(); 305 void edit_copy();
305 306
306 /** paste the current vobject(s) in the clipboard buffer into calendar */ 307 /** paste the current vobject(s) in the clipboard buffer into calendar */
307 void edit_paste(); 308 void edit_paste();
308 309
309 /** edit viewing and configuration options. */ 310 /** edit viewing and configuration options. */
310 void edit_options(); 311 void edit_options();
311 void edit_sync_options(); 312 void edit_sync_options();
312 /** 313 /**
313 Functions for printing, previewing a print, and setting up printing 314 Functions for printing, previewing a print, and setting up printing
314 parameters. 315 parameters.
315 */ 316 */
316 void print(); 317 void print();
317 void printSetup(); 318 void printSetup();
318 void printPreview(); 319 void printPreview();
319 320
320 /** Export as iCalendar file */ 321 /** Export as iCalendar file */
321 void exportICalendar(); 322 void exportICalendar();
322 323
323 /** Export as vCalendar file */ 324 /** Export as vCalendar file */
324 bool exportVCalendar( QString fn); 325 bool exportVCalendar( QString fn);
325 326
326 /** pop up a dialog to show an existing appointment. */ 327 /** pop up a dialog to show an existing appointment. */
327 void appointment_show(); 328 void appointment_show();
328 /** 329 /**
329 * pop up an Appointment Dialog to edit an existing appointment.Get 330 * pop up an Appointment Dialog to edit an existing appointment.Get
330 * information on the appointment from the list of unique IDs that is 331 * information on the appointment from the list of unique IDs that is
331 * currently in the View, called currIds. 332 * currently in the View, called currIds.
332 */ 333 */
333 void appointment_edit(); 334 void appointment_edit();
334 /** 335 /**
335 * pop up dialog confirming deletion of currently selected event in the 336 * pop up dialog confirming deletion of currently selected event in the
336 * View. 337 * View.
337 */ 338 */
338 void appointment_delete(); 339 void appointment_delete();
339 340
340 /** mails the currently selected event to a particular user as a vCalendar 341 /** mails the currently selected event to a particular user as a vCalendar
341 attachment. */ 342 attachment. */
342 void action_mail(); 343 void action_mail();
343 344
344 /* frees a subtodo from it's relation */ 345 /* frees a subtodo from it's relation */
345 void todo_unsub( Todo * ); 346 void todo_unsub( Todo * );
346 347
347 /** Take ownership of selected event. */ 348 /** Take ownership of selected event. */
348 void takeOverEvent(); 349 void takeOverEvent();
349 350
350 /** Take ownership of all events in calendar. */ 351 /** Take ownership of all events in calendar. */
351 void takeOverCalendar(); 352 void takeOverCalendar();
352 353
353 /** query whether or not the calendar is "dirty". */ 354 /** query whether or not the calendar is "dirty". */
354 bool isModified(); 355 bool isModified();
355 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ 356 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */
356 void setModified(bool modified=true); 357 void setModified(bool modified=true);
357 358
358 /** query if the calendar is read-only. */ 359 /** query if the calendar is read-only. */
359 bool isReadOnly(); 360 bool isReadOnly();
360 /** set state of calendar to read-only */ 361 /** set state of calendar to read-only */
361 void setReadOnly(bool readOnly=true); 362 void setReadOnly(bool readOnly=true);
362 363
363 void eventUpdated(Incidence *); 364 void eventUpdated(Incidence *);
364 365
365 /* iTIP scheduling actions */ 366 /* iTIP scheduling actions */
366 void schedule_publish(Incidence *incidence = 0); 367 void schedule_publish(Incidence *incidence = 0);
367 void schedule_request(Incidence *incidence = 0); 368 void schedule_request(Incidence *incidence = 0);
368 void schedule_refresh(Incidence *incidence = 0); 369 void schedule_refresh(Incidence *incidence = 0);
369 void schedule_cancel(Incidence *incidence = 0); 370 void schedule_cancel(Incidence *incidence = 0);
370 void schedule_add(Incidence *incidence = 0); 371 void schedule_add(Incidence *incidence = 0);
371 void schedule_reply(Incidence *incidence = 0); 372 void schedule_reply(Incidence *incidence = 0);
372 void schedule_counter(Incidence *incidence = 0); 373 void schedule_counter(Incidence *incidence = 0);
373 void schedule_declinecounter(Incidence *incidence = 0); 374 void schedule_declinecounter(Incidence *incidence = 0);
374 void schedule_publish_freebusy(int daysToPublish = 30); 375 void schedule_publish_freebusy(int daysToPublish = 30);
375 376
376 void openAddressbook(); 377 void openAddressbook();
377 378
378 void editFilters(); 379 void editFilters();
379 void toggleFilerEnabled(); 380 void toggleFilerEnabled();
380 QPtrList<CalFilter> filters(); 381 QPtrList<CalFilter> filters();
381 void toggleFilter(); 382 void toggleFilter();
382 void showFilter(bool visible); 383 void showFilter(bool visible);
383 void updateFilter(); 384 void updateFilter();
384 void filterEdited(); 385 void filterEdited();
385 void selectFilter( int ); 386 void selectFilter( int );
386 KOFilterView *filterView(); 387 KOFilterView *filterView();
387 388
388 void showIntro(); 389 void showIntro();
389 390
390 /** Move the curdatepient view date to today */ 391 /** Move the curdatepient view date to today */
391 void goToday(); 392 void goToday();
392 393
393 /** Move to the next date(s) in the current view */ 394 /** Move to the next date(s) in the current view */
394 void goNext(); 395 void goNext();
395 396
396 /** Move to the previous date(s) in the current view */ 397 /** Move to the previous date(s) in the current view */
397 void goPrevious(); 398 void goPrevious();
398 /** Move to the next date(s) in the current view */ 399 /** Move to the next date(s) in the current view */
399 void goNextMonth(); 400 void goNextMonth();
400 401
401 /** Move to the previous date(s) in the current view */ 402 /** Move to the previous date(s) in the current view */
402 void goPreviousMonth(); 403 void goPreviousMonth();
403 404
404 void toggleExpand(); 405 void toggleExpand();
405 void toggleDateNavigatorWidget(); 406 void toggleDateNavigatorWidget();
406 void toggleAllDaySize(); 407 void toggleAllDaySize();
407 void dialogClosing(Incidence *); 408 void dialogClosing(Incidence *);
408 409
409 /** Look for new messages in the inbox */ 410 /** Look for new messages in the inbox */
410 void lookForIncomingMessages(); 411 void lookForIncomingMessages();
411 /** Look for new messages in the outbox */ 412 /** Look for new messages in the outbox */
412 void lookForOutgoingMessages(); 413 void lookForOutgoingMessages();
413 414
414 void processMainViewSelection( Incidence * ); 415 void processMainViewSelection( Incidence * );
415 void processTodoListSelection( Incidence * ); 416 void processTodoListSelection( Incidence * );
416 417
417 void processIncidenceSelection( Incidence * ); 418 void processIncidenceSelection( Incidence * );
418 419
419 void purgeCompleted(); 420 void purgeCompleted();
420 bool removeCompletedSubTodos( Todo* ); 421 bool removeCompletedSubTodos( Todo* );
421 void slotCalendarChanged(); 422 void slotCalendarChanged();
422 bool importBday(); 423 bool importBday();
423 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); 424 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday );
424 bool importQtopia( const QString &categoriesFile, 425 bool importQtopia( const QString &categoriesFile,
425 const QString &datebookFile, 426 const QString &datebookFile,
426 const QString &tasklistFile ); 427 const QString &tasklistFile );
427 void syncSharp( ); 428 void syncSharp( );
428 void syncPhone( ); 429 void syncPhone( );
429 void syncExternal( int mode ); 430 void syncExternal( int mode );
430 void slotSelectPickerDate( QDate ) ; 431 void slotSelectPickerDate( QDate ) ;
431 void showDatePicker( ) ; 432 void showDatePicker( ) ;
432 void moveIncidence(Incidence *) ; 433 void moveIncidence(Incidence *) ;
433 void beamIncidence(Incidence *) ; 434 void beamIncidence(Incidence *) ;
434 void beamCalendar() ; 435 void beamCalendar() ;
435 void beamFilteredCalendar() ; 436 void beamFilteredCalendar() ;
436 void beamIncidenceList(QPtrList<Incidence>) ; 437 void beamIncidenceList(QPtrList<Incidence>) ;
437 void manageCategories(); 438 void manageCategories();
438 int addCategories(); 439 int addCategories();
439 void removeCategories(); 440 void removeCategories();
440 void setSyncDevice( QString ); 441 void setSyncDevice( QString );
441 void setSyncName( QString ); 442 void setSyncName( QString );
442 protected slots: 443 protected slots:
443 void timerAlarm(); 444 void timerAlarm();
444 void suspendAlarm(); 445 void suspendAlarm();
445 void beamDone( Ir *ir ); 446 void beamDone( Ir *ir );
446 /** Select a view or adapt the current view to display the specified dates. */ 447 /** Select a view or adapt the current view to display the specified dates. */
447 void showDates( const KCal::DateList & ); 448 void showDates( const KCal::DateList & );
448 void selectWeekNum ( int ); 449 void selectWeekNum ( int );
449 450
450 public: 451 public:
451 // show a standard warning 452 // show a standard warning
452 // returns KMsgBox::yesNoCancel() 453 // returns KMsgBox::yesNoCancel()
453 int msgCalModified(); 454 int msgCalModified();
454 void confSync(); 455 void confSync();
455 void setLoadedFileVersion(QDateTime); 456 void setLoadedFileVersion(QDateTime);
456 bool checkFileVersion(QString fn); 457 bool checkFileVersion(QString fn);
457 bool checkFileChanged(QString fn); 458 bool checkFileChanged(QString fn);
458 Event* getLastSyncEvent(); 459 Event* getLastSyncEvent();
459 /** Adapt navigation units correpsonding to step size of navigation of the 460 /** Adapt navigation units correpsonding to step size of navigation of the
460 * current view. 461 * current view.
461 */ 462 */
462 void adaptNavigationUnits(); 463 void adaptNavigationUnits();
463 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); 464 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode );
464 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); 465 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false );
465 //Attendee* getYourAttendee(Event *event); 466 //Attendee* getYourAttendee(Event *event);
466 protected: 467 protected:
467 void schedule(Scheduler::Method, Incidence *incidence = 0); 468 void schedule(Scheduler::Method, Incidence *incidence = 0);
468 469
469 // returns KMsgBox::OKCandel() 470 // returns KMsgBox::OKCandel()
470 int msgItemDelete(); 471 int msgItemDelete();
471 void showEventEditor(); 472 void showEventEditor();
472 void showTodoEditor(); 473 void showTodoEditor();
473 void writeLocale(); 474 void writeLocale();
474 Todo *selectedTodo(); 475 Todo *selectedTodo();
475 476
476 private: 477 private:
477 AlarmDialog * mAlarmDialog; 478 AlarmDialog * mAlarmDialog;
478 QString mAlarmNotification; 479 QString mAlarmNotification;
479 QString mSuspendAlarmNotification; 480 QString mSuspendAlarmNotification;
480 QTimer* mSuspendTimer; 481 QTimer* mSuspendTimer;
481 QTimer* mAlarmTimer; 482 QTimer* mAlarmTimer;
482 QTimer* mRecheckAlarmTimer; 483 QTimer* mRecheckAlarmTimer;
483 void computeAlarm( QString ); 484 void computeAlarm( QString );
484 void startAlarm( QString, QString ); 485 void startAlarm( QString, QString );
485 void setSyncEventsReadOnly(); 486 void setSyncEventsReadOnly();
486 487
487 QDateTime loadedFileVersion; 488 QDateTime loadedFileVersion;
488 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); 489 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete );
489 void checkExternalId( Incidence * inc ); 490 void checkExternalId( Incidence * inc );
490 int mGlobalSyncMode; 491 int mGlobalSyncMode;
491 QString mCurrentSyncDevice; 492 QString mCurrentSyncDevice;
492 QString mCurrentSyncName; 493 QString mCurrentSyncName;
493 KOBeamPrefs* beamDialog; 494 KOBeamPrefs* beamDialog;
494 void init(); 495 void init();
495 int mDatePickerMode; 496 int mDatePickerMode;
496 bool mFlagEditDescription; 497 bool mFlagEditDescription;
497 QDateTime mLastCalendarSync; 498 QDateTime mLastCalendarSync;
498 void createPrinter(); 499 void createPrinter();
499 500
500 void calendarModified( bool, Calendar * ); 501 void calendarModified( bool, Calendar * );
501 502
502 CalPrinter *mCalPrinter; 503 CalPrinter *mCalPrinter;
503 504
504 QSplitter *mPanner; 505 QSplitter *mPanner;
505 QSplitter *mLeftSplitter; 506 QSplitter *mLeftSplitter;
506 QWidget *mLeftFrame; 507 QWidget *mLeftFrame;
507 QWidgetStack *mRightFrame; 508 QWidgetStack *mRightFrame;
508 509
509 KDatePicker* mDatePicker; 510 KDatePicker* mDatePicker;
510 QVBox* mDateFrame; 511 QVBox* mDateFrame;
511 NavigatorBar *mNavigatorBar; 512 NavigatorBar *mNavigatorBar;
512 513
513 KDateNavigator *mDateNavigator; // widget showing small month view. 514 KDateNavigator *mDateNavigator; // widget showing small month view.
514 515
515 KOFilterView *mFilterView; 516 KOFilterView *mFilterView;
516 517
517 ResourceView *mResourceView; 518 ResourceView *mResourceView;
518 519
519 // calendar object for this viewing instance 520 // calendar object for this viewing instance
520 Calendar *mCalendar; 521 Calendar *mCalendar;
521 522
522 CalendarResourceManager *mResourceManager; 523 CalendarResourceManager *mResourceManager;
523 524
524 FileStorage *mStorage; 525 FileStorage *mStorage;
525 526
526 DateNavigator *mNavigator; 527 DateNavigator *mNavigator;
527 528
528 KOViewManager *mViewManager; 529 KOViewManager *mViewManager;
529 KODialogManager *mDialogManager; 530 KODialogManager *mDialogManager;
530 531
531 // Calendar filters 532 // Calendar filters
532 QPtrList<CalFilter> mFilters; 533 QPtrList<CalFilter> mFilters;
533 534
534 // various housekeeping variables. 535 // various housekeeping variables.
535 bool mModified; // flag indicating if calendar is modified 536 bool mModified; // flag indicating if calendar is modified
536 bool mReadOnly; // flag indicating if calendar is read-only 537 bool mReadOnly; // flag indicating if calendar is read-only
537 QDate mSaveSingleDate; 538 QDate mSaveSingleDate;
538 539
539 Incidence *mSelectedIncidence; 540 Incidence *mSelectedIncidence;
540 Incidence *mMoveIncidence; 541 Incidence *mMoveIncidence;
541 QPtrList<Event> mExternLastSyncEvent; 542 QPtrList<Event> mExternLastSyncEvent;
542 KOTodoView *mTodoList; 543 KOTodoView *mTodoList;
543 KOEventEditor * mEventEditor; 544 KOEventEditor * mEventEditor;
544 KOTodoEditor * mTodoEditor; 545 KOTodoEditor * mTodoEditor;
545 KOEventViewerDialog * mEventViewerDialog; 546 KOEventViewerDialog * mEventViewerDialog;
546 void keyPressEvent ( QKeyEvent *e) ; 547 void keyPressEvent ( QKeyEvent *e) ;
547 //QMap<Incidence*,KOIncidenceEditor*> mDialogList; 548 //QMap<Incidence*,KOIncidenceEditor*> mDialogList;
548}; 549};
549 550
550 551
551class CalendarViewVisitor : public Incidence::Visitor 552class CalendarViewVisitor : public Incidence::Visitor
552{ 553{
553 public: 554 public:
554 CalendarViewVisitor() : mView( 0 ) {} 555 CalendarViewVisitor() : mView( 0 ) {}
555 556
556 bool act( Incidence *incidence, CalendarView *view ) 557 bool act( Incidence *incidence, CalendarView *view )
557 { 558 {
558 mView = view; 559 mView = view;
559 return incidence->accept( *this ); 560 return incidence->accept( *this );
560 } 561 }
561 562
562 protected: 563 protected:
563 CalendarView *mView; 564 CalendarView *mView;
564}; 565};
565 566
566class ShowIncidenceVisitor : public CalendarViewVisitor 567class ShowIncidenceVisitor : public CalendarViewVisitor
567{ 568{
568 protected: 569 protected:
569 bool visit( Event *event ) { mView->showEvent( event ); return true; } 570 bool visit( Event *event ) { mView->showEvent( event ); return true; }
570 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } 571 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; }
571 bool visit( Journal * j ) { mView->showJournal( j );return true; } 572 bool visit( Journal * j ) { mView->showJournal( j );return true; }
572}; 573};
573 574
574class EditIncidenceVisitor : public CalendarViewVisitor 575class EditIncidenceVisitor : public CalendarViewVisitor
575{ 576{
576 protected: 577 protected:
577 bool visit( Event *event ) { mView->editEvent( event ); return true; } 578 bool visit( Event *event ) { mView->editEvent( event ); return true; }
578 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } 579 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; }
579 bool visit( Journal *j ) { mView->editJournal( j); return true; } 580 bool visit( Journal *j ) { mView->editJournal( j); return true; }
580}; 581};
581 582
582class DeleteIncidenceVisitor : public CalendarViewVisitor 583class DeleteIncidenceVisitor : public CalendarViewVisitor
583{ 584{
584 protected: 585 protected:
585 bool visit( Event *event ) { mView->deleteEvent( event ); return true; } 586 bool visit( Event *event ) { mView->deleteEvent( event ); return true; }
586 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } 587 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; }
587 bool visit( Journal * j) {mView->deleteJournal( j ); return true; } 588 bool visit( Journal * j) {mView->deleteJournal( j ); return true; }
588}; 589};
589 590
590#endif 591#endif
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 1c4a186..6315c64 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1,2136 +1,2137 @@
1#include <stdlib.h> 1#include <stdlib.h>
2 2
3#include <qaction.h> 3#include <qaction.h>
4#include <qpopupmenu.h> 4#include <qpopupmenu.h>
5#include <qpainter.h> 5#include <qpainter.h>
6#include <qwhatsthis.h> 6#include <qwhatsthis.h>
7#include <qmessagebox.h> 7#include <qmessagebox.h>
8#include <qlineedit.h> 8#include <qlineedit.h>
9#include <qfile.h> 9#include <qfile.h>
10#include <qdir.h> 10#include <qdir.h>
11#include <qapp.h> 11#include <qapp.h>
12#include <qfileinfo.h> 12#include <qfileinfo.h>
13#include <qlabel.h> 13#include <qlabel.h>
14#include <qmap.h> 14#include <qmap.h>
15#include <qwmatrix.h> 15#include <qwmatrix.h>
16#include <qtextbrowser.h> 16#include <qtextbrowser.h>
17#include <qtextstream.h> 17#include <qtextstream.h>
18#ifndef DESKTOP_VERSION 18#ifndef DESKTOP_VERSION
19#include <qpe/global.h> 19#include <qpe/global.h>
20#include <qpe/qpemenubar.h> 20#include <qpe/qpemenubar.h>
21#include <qpe/qpetoolbar.h> 21#include <qpe/qpetoolbar.h>
22#include <qpe/resource.h> 22#include <qpe/resource.h>
23#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
24#include <qtopia/alarmserver.h> 24#include <qtopia/alarmserver.h>
25#include <qtopia/qcopenvelope_qws.h> 25#include <qtopia/qcopenvelope_qws.h>
26#else 26#else
27#include <qmenubar.h> 27#include <qmenubar.h>
28#include <qtoolbar.h> 28#include <qtoolbar.h>
29#include <qapplication.h> 29#include <qapplication.h>
30//#include <resource.h> 30//#include <resource.h>
31 31
32#endif 32#endif
33#include <libkcal/calendarlocal.h> 33#include <libkcal/calendarlocal.h>
34#include <libkcal/todo.h> 34#include <libkcal/todo.h>
35#include <libkdepim/ksyncprofile.h> 35#include <libkdepim/ksyncprofile.h>
36#include <libkcal/kincidenceformatter.h> 36#include <libkcal/kincidenceformatter.h>
37#include <libkdepim/kpimglobalprefs.h> 37#include <libkdepim/kpimglobalprefs.h>
38 38
39#include "calendarview.h" 39#include "calendarview.h"
40#include "koviewmanager.h" 40#include "koviewmanager.h"
41#include "datenavigator.h" 41#include "datenavigator.h"
42#include "koagendaview.h" 42#include "koagendaview.h"
43#include "koagenda.h" 43#include "koagenda.h"
44#include "kodialogmanager.h" 44#include "kodialogmanager.h"
45#include "kdialogbase.h" 45#include "kdialogbase.h"
46#include "kapplication.h" 46#include "kapplication.h"
47#include "kofilterview.h" 47#include "kofilterview.h"
48#include "kstandarddirs.h" 48#include "kstandarddirs.h"
49#include "koprefs.h" 49#include "koprefs.h"
50#include "kfiledialog.h" 50#include "kfiledialog.h"
51#include "koglobals.h" 51#include "koglobals.h"
52#include "kglobal.h" 52#include "kglobal.h"
53#include "klocale.h" 53#include "klocale.h"
54#include "kconfig.h" 54#include "kconfig.h"
55#include "simplealarmclient.h" 55#include "simplealarmclient.h"
56#include "externalapphandler.h" 56#include "externalapphandler.h"
57 57
58using namespace KCal; 58using namespace KCal;
59#ifndef _WIN32_ 59#ifndef _WIN32_
60#include <unistd.h> 60#include <unistd.h>
61#else 61#else
62#include "koimportoldialog.h" 62#include "koimportoldialog.h"
63#endif 63#endif
64#include "mainwindow.h" 64#include "mainwindow.h"
65 65
66int globalFlagBlockStartup; 66int globalFlagBlockStartup;
67MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : 67MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
68 QMainWindow( parent, name ) 68 QMainWindow( parent, name )
69{ 69{
70 70
71#ifdef DESKTOP_VERSION 71#ifdef DESKTOP_VERSION
72 setFont( QFont("Arial"), 14 ); 72 setFont( QFont("Arial"), 14 );
73#endif 73#endif
74 74
75 mClosed = false; 75 mClosed = false;
76 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; 76 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
77 QString confFile = locateLocal("config","korganizerrc"); 77 QString confFile = locateLocal("config","korganizerrc");
78 QFileInfo finf ( confFile ); 78 QFileInfo finf ( confFile );
79 bool showWarning = !finf.exists(); 79 bool showWarning = !finf.exists();
80 setIcon(SmallIcon( "ko24" ) ); 80 setIcon(SmallIcon( "ko24" ) );
81 mBlockAtStartup = true; 81 mBlockAtStartup = true;
82 mFlagKeyPressed = false; 82 mFlagKeyPressed = false;
83 setCaption("KOrganizer/Pi"); 83 setCaption("KOrganizer/Pi");
84 KOPrefs *p = KOPrefs::instance(); 84 KOPrefs *p = KOPrefs::instance();
85 KPimGlobalPrefs::instance()->setGlobalConfig(); 85 KPimGlobalPrefs::instance()->setGlobalConfig();
86 // if ( QApplication::desktop()->height() > 480 ) { 86 // if ( QApplication::desktop()->height() > 480 ) {
87// if ( p->mHourSize == 4 ) 87// if ( p->mHourSize == 4 )
88// p->mHourSize = 6; 88// p->mHourSize = 6;
89// } 89// }
90 if ( p->mHourSize > 18 ) 90 if ( p->mHourSize > 18 )
91 p->mHourSize = 18; 91 p->mHourSize = 18;
92 QMainWindow::ToolBarDock tbd; 92 QMainWindow::ToolBarDock tbd;
93 if ( p->mToolBarHor ) { 93 if ( p->mToolBarHor ) {
94 if ( p->mToolBarUp ) 94 if ( p->mToolBarUp )
95 tbd = Bottom; 95 tbd = Bottom;
96 else 96 else
97 tbd = Top; 97 tbd = Top;
98 } 98 }
99 else { 99 else {
100 if ( p->mToolBarUp ) 100 if ( p->mToolBarUp )
101 tbd = Right; 101 tbd = Right;
102 else 102 else
103 tbd = Left; 103 tbd = Left;
104 } 104 }
105 if ( KOPrefs::instance()->mUseAppColors ) 105 if ( KOPrefs::instance()->mUseAppColors )
106 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 106 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
107 globalFlagBlockStartup = 1; 107 globalFlagBlockStartup = 1;
108 iconToolBar = new QPEToolBar( this ); 108 iconToolBar = new QPEToolBar( this );
109 addToolBar (iconToolBar , tbd ); 109 addToolBar (iconToolBar , tbd );
110 mBlockSaveFlag = false; 110 mBlockSaveFlag = false;
111 mCalendarModifiedFlag = false; 111 mCalendarModifiedFlag = false;
112 112
113 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); 113 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
114 splash->setAlignment ( AlignCenter ); 114 splash->setAlignment ( AlignCenter );
115 setCentralWidget( splash ); 115 setCentralWidget( splash );
116#ifndef DESKTOP_VERSION 116#ifndef DESKTOP_VERSION
117 showMaximized(); 117 showMaximized();
118#endif 118#endif
119 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); 119 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
120 setDefaultPreferences(); 120 setDefaultPreferences();
121 mCalendar = new CalendarLocal(); 121 mCalendar = new CalendarLocal();
122 mView = new CalendarView( mCalendar, this,"mCalendar " ); 122 mView = new CalendarView( mCalendar, this,"mCalendar " );
123 mView->hide(); 123 mView->hide();
124 //mView->resize(splash->size() ); 124 //mView->resize(splash->size() );
125 initActions(); 125 initActions();
126#ifndef DESKTOP_VERSION 126#ifndef DESKTOP_VERSION
127 iconToolBar->show(); 127 iconToolBar->show();
128 qApp->processEvents(); 128 qApp->processEvents();
129#endif 129#endif
130 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); 130 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
131 int vh = height() ; 131 int vh = height() ;
132 int vw = width(); 132 int vw = width();
133 //qDebug("Toolbar hei %d ",iconToolBar->height() ); 133 //qDebug("Toolbar hei %d ",iconToolBar->height() );
134 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 134 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
135 vh -= iconToolBar->height(); 135 vh -= iconToolBar->height();
136 } else { 136 } else {
137 vw -= iconToolBar->height(); 137 vw -= iconToolBar->height();
138 } 138 }
139 //mView->setMaximumSize( splash->size() ); 139 //mView->setMaximumSize( splash->size() );
140 //mView->resize( splash->size() ); 140 //mView->resize( splash->size() );
141 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 141 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
142 mView->readSettings(); 142 mView->readSettings();
143 bool oldOpened = false; 143 bool oldOpened = false;
144 bool newFile = false; 144 bool newFile = false;
145 if( !QFile::exists( defaultFileName() ) ) { 145 if( !QFile::exists( defaultFileName() ) ) {
146 QFileInfo finfo ( defaultFileName() ); 146 QFileInfo finfo ( defaultFileName() );
147 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); 147 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
148 qDebug("oldfile %s ", oldFile.latin1()); 148 qDebug("oldfile %s ", oldFile.latin1());
149 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"; 149 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";
150 finfo.setFile( oldFile ); 150 finfo.setFile( oldFile );
151 if (finfo.exists() ) { 151 if (finfo.exists() ) {
152 KMessageBox::information( this, message); 152 KMessageBox::information( this, message);
153 mView->openCalendar( oldFile ); 153 mView->openCalendar( oldFile );
154 qApp->processEvents(); 154 qApp->processEvents();
155 } else { 155 } else {
156 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); 156 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
157 finfo.setFile( oldFile ); 157 finfo.setFile( oldFile );
158 if (finfo.exists() ) { 158 if (finfo.exists() ) {
159 KMessageBox::information( this, message); 159 KMessageBox::information( this, message);
160 mView->openCalendar( oldFile ); 160 mView->openCalendar( oldFile );
161 qApp->processEvents(); 161 qApp->processEvents();
162 } 162 }
163 } 163 }
164 mView->saveCalendar( defaultFileName() ); 164 mView->saveCalendar( defaultFileName() );
165 newFile = true; 165 newFile = true;
166 } 166 }
167 167
168 QTime neededSaveTime = QDateTime::currentDateTime().time(); 168 QTime neededSaveTime = QDateTime::currentDateTime().time();
169 if ( ! oldOpened ) 169 if ( ! oldOpened )
170 mView->openCalendar( defaultFileName() ); 170 mView->openCalendar( defaultFileName() );
171 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 171 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
172 qDebug("KO: Calendar loading time: %d ms",msNeeded ); 172 qDebug("KO: Calendar loading time: %d ms",msNeeded );
173 173
174 if ( KOPrefs::instance()->mLanguageChanged ) { 174 if ( KOPrefs::instance()->mLanguageChanged ) {
175 KOPrefs::instance()->setCategoryDefaults(); 175 KOPrefs::instance()->setCategoryDefaults();
176 int count = mView->addCategories(); 176 int count = mView->addCategories();
177 KOPrefs::instance()->mLanguageChanged = false; 177 KOPrefs::instance()->mLanguageChanged = false;
178 } 178 }
179 processIncidenceSelection( 0 ); 179 processIncidenceSelection( 0 );
180 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), 180 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
181 SLOT( processIncidenceSelection( Incidence * ) ) ); 181 SLOT( processIncidenceSelection( Incidence * ) ) );
182 connect( mView, SIGNAL( modifiedChanged( bool ) ), 182 connect( mView, SIGNAL( modifiedChanged( bool ) ),
183 SLOT( slotModifiedChanged( bool ) ) ); 183 SLOT( slotModifiedChanged( bool ) ) );
184 184
185 185
186 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); 186 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
187 mView->setModified( false ); 187 mView->setModified( false );
188 mBlockAtStartup = false; 188 mBlockAtStartup = false;
189 mView->setModified( false ); 189 mView->setModified( false );
190 setCentralWidget( mView ); 190 setCentralWidget( mView );
191 globalFlagBlockStartup = 0; 191 globalFlagBlockStartup = 0;
192 mView->show(); 192 mView->show();
193 delete splash; 193 delete splash;
194 if ( newFile ) 194 if ( newFile )
195 mView->updateConfig(); 195 mView->updateConfig();
196 // qApp->processEvents(); 196 // qApp->processEvents();
197 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 197 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
198 fillSyncMenu(); 198 fillSyncMenu();
199 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); 199 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
200 if ( showWarning ) { 200 if ( showWarning ) {
201 KMessageBox::information( this, 201 KMessageBox::information( this,
202 "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"); 202 "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");
203 qApp->processEvents(); 203 qApp->processEvents();
204 mView->dialogManager()->showSyncOptions(); 204 mView->dialogManager()->showSyncOptions();
205 } 205 }
206 206
207 //US listen for result adressed from Ka/Pi 207 //US listen for result adressed from Ka/Pi
208#ifndef DESKTOP_VERSION 208#ifndef DESKTOP_VERSION
209 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 209 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
210#endif 210#endif
211} 211}
212MainWindow::~MainWindow() 212MainWindow::~MainWindow()
213{ 213{
214 //qDebug("MainWindow::~MainWindow() "); 214 //qDebug("MainWindow::~MainWindow() ");
215 //save toolbar location 215 //save toolbar location
216 216
217 delete mCalendar; 217 delete mCalendar;
218 delete KOPrefs::instance(); 218 delete KOPrefs::instance();
219 delete KIncidenceFormatter::instance(); 219 delete KIncidenceFormatter::instance();
220 220
221 221
222} 222}
223void MainWindow::showMaximized () 223void MainWindow::showMaximized ()
224{ 224{
225#ifndef DESKTOP_VERSION 225#ifndef DESKTOP_VERSION
226 if ( ! globalFlagBlockStartup ) 226 if ( ! globalFlagBlockStartup )
227 if ( mClosed ) 227 if ( mClosed )
228 mView->goToday(); 228 mView->goToday();
229#endif 229#endif
230 QWidget::showMaximized () ; 230 QWidget::showMaximized () ;
231 mClosed = false; 231 mClosed = false;
232} 232}
233void MainWindow::closeEvent( QCloseEvent* ce ) 233void MainWindow::closeEvent( QCloseEvent* ce )
234{ 234{
235 235
236 236
237 237
238 if ( ! KOPrefs::instance()->mAskForQuit ) { 238 if ( ! KOPrefs::instance()->mAskForQuit ) {
239 saveOnClose(); 239 saveOnClose();
240 mClosed = true; 240 mClosed = true;
241 ce->accept(); 241 ce->accept();
242 return; 242 return;
243 243
244 } 244 }
245 245
246 switch( QMessageBox::information( this, "KO/Pi", 246 switch( QMessageBox::information( this, "KO/Pi",
247 i18n("Do you really want\nto close KO/Pi?"), 247 i18n("Do you really want\nto close KO/Pi?"),
248 i18n("Close"), i18n("No"), 248 i18n("Close"), i18n("No"),
249 0, 0 ) ) { 249 0, 0 ) ) {
250 case 0: 250 case 0:
251 saveOnClose(); 251 saveOnClose();
252 mClosed = true; 252 mClosed = true;
253 ce->accept(); 253 ce->accept();
254 break; 254 break;
255 case 1: 255 case 1:
256 ce->ignore(); 256 ce->ignore();
257 break; 257 break;
258 case 2: 258 case 2:
259 259
260 default: 260 default:
261 break; 261 break;
262 } 262 }
263 263
264 264
265} 265}
266 266
267void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) 267void MainWindow::recieve( const QCString& cmsg, const QByteArray& data )
268{ 268{
269 QDataStream stream( data, IO_ReadOnly ); 269 QDataStream stream( data, IO_ReadOnly );
270 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); 270 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" );
271 //QString datamess; 271 //QString datamess;
272 //qDebug("message "); 272 //qDebug("message ");
273 qDebug("KO: QCOP message received: %s ", cmsg.data() ); 273 qDebug("KO: QCOP message received: %s ", cmsg.data() );
274 274
275 if ( cmsg == "-writeFile" ) { 275 if ( cmsg == "-writeFile" ) {
276 // I made from the "-writeFile" an "-writeAlarm" 276 // I made from the "-writeFile" an "-writeAlarm"
277 mView->viewManager()->showWhatsNextView(); 277 mView->viewManager()->showWhatsNextView();
278 mCalendar->checkAlarmForIncidence( 0, true); 278 mCalendar->checkAlarmForIncidence( 0, true);
279 showMaximized(); 279 showMaximized();
280 raise(); 280 raise();
281 return; 281 return;
282 } 282 }
283 283
284 if ( cmsg == "-writeFile" ) { 284 if ( cmsg == "-writeFile" ) {
285 // I made from the "-writeFile" an "-writeAlarm" 285 // I made from the "-writeFile" an "-writeAlarm"
286 mView->viewManager()->showWhatsNextView(); 286 mView->viewManager()->showWhatsNextView();
287 mCalendar->checkAlarmForIncidence( 0, true); 287 mCalendar->checkAlarmForIncidence( 0, true);
288 showMaximized(); 288 showMaximized();
289 raise(); 289 raise();
290 return; 290 return;
291 291
292 } 292 }
293 if ( cmsg == "-writeFileSilent" ) { 293 if ( cmsg == "-writeFileSilent" ) {
294 // I made from the "-writeFile" an "-writeAlarm" 294 // I made from the "-writeFile" an "-writeAlarm"
295 // mView->viewManager()->showWhatsNextView(); 295 // mView->viewManager()->showWhatsNextView();
296 mCalendar->checkAlarmForIncidence( 0, true); 296 mCalendar->checkAlarmForIncidence( 0, true);
297 //showMaximized(); 297 //showMaximized();
298 //raise(); 298 //raise();
299 hide(); 299 hide();
300 return; 300 return;
301 } 301 }
302 if ( cmsg == "-newCountdown" ) { 302 if ( cmsg == "-newCountdown" ) {
303 qDebug("newCountdown "); 303 qDebug("newCountdown ");
304 304
305 } 305 }
306 QString msg ; 306 QString msg ;
307 QString allmsg = cmsg; 307 QString allmsg = cmsg;
308 while ( allmsg.length() > 0 ) { 308 while ( allmsg.length() > 0 ) {
309 int nextC = allmsg.find( "-", 1 ); 309 int nextC = allmsg.find( "-", 1 );
310 if ( nextC == -1 ) { 310 if ( nextC == -1 ) {
311 msg = allmsg; 311 msg = allmsg;
312 allmsg = ""; 312 allmsg = "";
313 } else{ 313 } else{
314 msg = allmsg.left( nextC ); 314 msg = allmsg.left( nextC );
315 allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); 315 allmsg = allmsg.mid( nextC, allmsg.length()-nextC );
316 } 316 }
317 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); 317 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() );
318 if ( msg == "-newEvent" ) { 318 if ( msg == "-newEvent" ) {
319 mView->newEvent(); 319 mView->newEvent();
320 } 320 }
321 if ( msg == "-newTodo" ) { 321 if ( msg == "-newTodo" ) {
322 mView->newTodo(); 322 mView->newTodo();
323 323
324 } 324 }
325 if ( msg == "-showWN" ) { 325 if ( msg == "-showWN" ) {
326 mView->viewManager()->showWhatsNextView(); 326 mView->viewManager()->showWhatsNextView();
327 } 327 }
328 if ( msg == "-showTodo" ) { 328 if ( msg == "-showTodo" ) {
329 mView->viewManager()->showTodoView(); 329 mView->viewManager()->showTodoView();
330 } 330 }
331 if ( msg == "-showList" ) { 331 if ( msg == "-showList" ) {
332 mView->viewManager()->showListView(); 332 mView->viewManager()->showListView();
333 } 333 }
334 else if ( msg == "-showDay" ) { 334 else if ( msg == "-showDay" ) {
335 mView->viewManager()->showDayView(); 335 mView->viewManager()->showDayView();
336 } 336 }
337 else if ( msg == "-showWWeek" ) { 337 else if ( msg == "-showWWeek" ) {
338 mView->viewManager()->showWorkWeekView(); 338 mView->viewManager()->showWorkWeekView();
339 } 339 }
340 else if ( msg == "-ringSync" ) { 340 else if ( msg == "-ringSync" ) {
341 multiSync( false ); 341 multiSync( false );
342 } 342 }
343 else if ( msg == "-showWeek" ) { 343 else if ( msg == "-showWeek" ) {
344 mView->viewManager()->showWeekView(); 344 mView->viewManager()->showWeekView();
345 } 345 }
346 else if ( msg == "-showTodo" ) { 346 else if ( msg == "-showTodo" ) {
347 mView->viewManager()->showTodoView(); 347 mView->viewManager()->showTodoView();
348 } 348 }
349 else if ( msg == "-showJournal" ) { 349 else if ( msg == "-showJournal" ) {
350 mView->dateNavigator()->selectDates( 1 ); 350 mView->dateNavigator()->selectDates( 1 );
351 mView->dateNavigator()->selectToday(); 351 mView->dateNavigator()->selectToday();
352 mView->viewManager()->showJournalView(); 352 mView->viewManager()->showJournalView();
353 } 353 }
354 else if ( msg == "-showKO" ) { 354 else if ( msg == "-showKO" ) {
355 mView->viewManager()->showNextXView(); 355 mView->viewManager()->showNextXView();
356 } 356 }
357 else if ( msg == "-showWNext" || msg == "nextView()" ) { 357 else if ( msg == "-showWNext" || msg == "nextView()" ) {
358 mView->viewManager()->showWhatsNextView(); 358 mView->viewManager()->showWhatsNextView();
359 } 359 }
360 else if ( msg == "-showNextXView" ) { 360 else if ( msg == "-showNextXView" ) {
361 mView->viewManager()->showNextXView(); 361 mView->viewManager()->showNextXView();
362 } 362 }
363 363
364 364
365 } 365 }
366 366
367 showMaximized(); 367 showMaximized();
368 raise(); 368 raise();
369} 369}
370 370
371QPixmap MainWindow::loadPixmap( QString name ) 371QPixmap MainWindow::loadPixmap( QString name )
372{ 372{
373 return SmallIcon( name ); 373 return SmallIcon( name );
374 374
375} 375}
376void MainWindow::initActions() 376void MainWindow::initActions()
377{ 377{
378 //KOPrefs::instance()->mShowFullMenu 378 //KOPrefs::instance()->mShowFullMenu
379 iconToolBar->clear(); 379 iconToolBar->clear();
380 KOPrefs *p = KOPrefs::instance(); 380 KOPrefs *p = KOPrefs::instance();
381 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); 381 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar );
382 382
383 QPopupMenu *viewMenu = new QPopupMenu( this ); 383 QPopupMenu *viewMenu = new QPopupMenu( this );
384 QPopupMenu *actionMenu = new QPopupMenu( this ); 384 QPopupMenu *actionMenu = new QPopupMenu( this );
385 QPopupMenu *importMenu = new QPopupMenu( this ); 385 QPopupMenu *importMenu = new QPopupMenu( this );
386 selectFilterMenu = new QPopupMenu( this ); 386 selectFilterMenu = new QPopupMenu( this );
387 selectFilterMenu->setCheckable( true ); 387 selectFilterMenu->setCheckable( true );
388 syncMenu = new QPopupMenu( this ); 388 syncMenu = new QPopupMenu( this );
389 configureAgendaMenu = new QPopupMenu( this ); 389 configureAgendaMenu = new QPopupMenu( this );
390 configureToolBarMenu = new QPopupMenu( this ); 390 configureToolBarMenu = new QPopupMenu( this );
391 QPopupMenu *helpMenu = new QPopupMenu( this ); 391 QPopupMenu *helpMenu = new QPopupMenu( this );
392 if ( KOPrefs::instance()->mShowFullMenu ) { 392 if ( KOPrefs::instance()->mShowFullMenu ) {
393 QMenuBar *menuBar1; 393 QMenuBar *menuBar1;
394 menuBar1 = menuBar(); 394 menuBar1 = menuBar();
395 menuBar1->insertItem( i18n("File"), importMenu ); 395 menuBar1->insertItem( i18n("File"), importMenu );
396 menuBar1->insertItem( i18n("View"), viewMenu ); 396 menuBar1->insertItem( i18n("View"), viewMenu );
397 menuBar1->insertItem( i18n("Actions"), actionMenu ); 397 menuBar1->insertItem( i18n("Actions"), actionMenu );
398 menuBar1->insertItem( i18n("Synchronize"), syncMenu ); 398 menuBar1->insertItem( i18n("Synchronize"), syncMenu );
399 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 399 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu );
400 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); 400 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu );
401 menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); 401 menuBar1->insertItem( i18n("Filter"),selectFilterMenu );
402 menuBar1->insertItem( i18n("Help"), helpMenu ); 402 menuBar1->insertItem( i18n("Help"), helpMenu );
403 } else { 403 } else {
404 QPEMenuBar *menuBar1; 404 QPEMenuBar *menuBar1;
405 menuBar1 = new QPEMenuBar( iconToolBar ); 405 menuBar1 = new QPEMenuBar( iconToolBar );
406 QPopupMenu *menuBar = new QPopupMenu( this ); 406 QPopupMenu *menuBar = new QPopupMenu( this );
407 menuBar1->insertItem( i18n("ME"), menuBar); 407 menuBar1->insertItem( i18n("ME"), menuBar);
408 menuBar->insertItem( i18n("File"), importMenu ); 408 menuBar->insertItem( i18n("File"), importMenu );
409 menuBar->insertItem( i18n("View"), viewMenu ); 409 menuBar->insertItem( i18n("View"), viewMenu );
410 menuBar->insertItem( i18n("Actions"), actionMenu ); 410 menuBar->insertItem( i18n("Actions"), actionMenu );
411 menuBar->insertItem( i18n("Synchronize"), syncMenu ); 411 menuBar->insertItem( i18n("Synchronize"), syncMenu );
412 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 412 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu );
413 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); 413 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu );
414 menuBar->insertItem( i18n("Filter"),selectFilterMenu ); 414 menuBar->insertItem( i18n("Filter"),selectFilterMenu );
415 menuBar->insertItem( i18n("Help"), helpMenu ); 415 menuBar->insertItem( i18n("Help"), helpMenu );
416 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); 416 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() );
417 menuBar1->setMaximumSize( menuBar1->sizeHint( )); 417 menuBar1->setMaximumSize( menuBar1->sizeHint( ));
418 } 418 }
419 connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) ); 419 connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) );
420 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); 420 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
421 connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) ); 421 connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) );
422 422
423 // ****************** 423 // ******************
424 QAction *action; 424 QAction *action;
425 QIconSet icon; 425 QIconSet icon;
426 // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); 426 // QPopupMenu *configureMenu= new QPopupMenu( menuBar );
427 configureToolBarMenu->setCheckable( true ); 427 configureToolBarMenu->setCheckable( true );
428 428
429 QString pathString = ""; 429 QString pathString = "";
430 if ( !p->mToolBarMiniIcons ) { 430 if ( !p->mToolBarMiniIcons ) {
431 if ( QApplication::desktop()->width() < 480 ) 431 if ( QApplication::desktop()->width() < 480 )
432 pathString += "icons16/"; 432 pathString += "icons16/";
433 } else 433 } else
434 pathString += "iconsmini/"; 434 pathString += "iconsmini/";
435 configureAgendaMenu->setCheckable( true ); 435 configureAgendaMenu->setCheckable( true );
436 configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 ); 436 configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 );
437 configureAgendaMenu->insertSeparator(); 437 configureAgendaMenu->insertSeparator();
438 configureAgendaMenu->insertItem(i18n("Tiny"), 4 ); 438 configureAgendaMenu->insertItem(i18n("Tiny"), 4 );
439 configureAgendaMenu->insertItem(i18n("Small"), 6 ); 439 configureAgendaMenu->insertItem(i18n("Small"), 6 );
440 configureAgendaMenu->insertItem(i18n("Medium"), 8 ); 440 configureAgendaMenu->insertItem(i18n("Medium"), 8 );
441 configureAgendaMenu->insertItem(i18n("Normal"), 10 ); 441 configureAgendaMenu->insertItem(i18n("Normal"), 10 );
442 configureAgendaMenu->insertItem(i18n("Large"), 12 ); 442 configureAgendaMenu->insertItem(i18n("Large"), 12 );
443 configureAgendaMenu->insertItem(i18n("Big"), 14 ); 443 configureAgendaMenu->insertItem(i18n("Big"), 14 );
444 configureAgendaMenu->insertItem(i18n("Bigger"), 16 ); 444 configureAgendaMenu->insertItem(i18n("Bigger"), 16 );
445 configureAgendaMenu->insertItem(i18n("Biggest"), 18 ); 445 configureAgendaMenu->insertItem(i18n("Biggest"), 18 );
446 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); 446 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu );
447 447
448 icon = loadPixmap( pathString + "configure" ); 448 icon = loadPixmap( pathString + "configure" );
449 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); 449 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this );
450 action->addTo( actionMenu ); 450 action->addTo( actionMenu );
451 connect( action, SIGNAL( activated() ), 451 connect( action, SIGNAL( activated() ),
452 mView, SLOT( edit_options() ) ); 452 mView, SLOT( edit_options() ) );
453 actionMenu->insertSeparator(); 453 actionMenu->insertSeparator();
454 icon = loadPixmap( pathString + "newevent" ); 454 icon = loadPixmap( pathString + "newevent" );
455 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); 455 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 );
456 configureToolBarMenu->insertSeparator(); 456 configureToolBarMenu->insertSeparator();
457 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); 457 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 );
458 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); 458 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this );
459 ne_action->addTo( actionMenu ); 459 ne_action->addTo( actionMenu );
460 connect( ne_action, SIGNAL( activated() ), 460 connect( ne_action, SIGNAL( activated() ),
461 mView, SLOT( newEvent() ) ); 461 mView, SLOT( newEvent() ) );
462 icon = loadPixmap( pathString + "newtodo" ); 462 icon = loadPixmap( pathString + "newtodo" );
463 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); 463 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 );
464 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); 464 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this );
465 nt_action->addTo( actionMenu ); 465 nt_action->addTo( actionMenu );
466 connect( nt_action, SIGNAL( activated() ), 466 connect( nt_action, SIGNAL( activated() ),
467 mView, SLOT( newTodo() ) ); 467 mView, SLOT( newTodo() ) );
468 icon = loadPixmap( pathString + "navi" ); 468 icon = loadPixmap( pathString + "navi" );
469 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); 469 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this );
470 action->addTo( viewMenu ); 470 action->addTo( viewMenu );
471 connect( action, SIGNAL( activated() ), 471 connect( action, SIGNAL( activated() ),
472 mView, SLOT( toggleDateNavigatorWidget() ) ); 472 mView, SLOT( toggleDateNavigatorWidget() ) );
473 icon = loadPixmap( pathString + "filter" ); 473 icon = loadPixmap( pathString + "filter" );
474 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); 474 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this );
475 action->addTo( viewMenu ); 475 action->addTo( viewMenu );
476 connect( action, SIGNAL( activated() ), 476 connect( action, SIGNAL( activated() ),
477 mView, SLOT( toggleFilter() ) ); 477 mView, SLOT( toggleFilter() ) );
478 478
479 479
480 viewMenu->insertSeparator(); 480 viewMenu->insertSeparator();
481 icon = loadPixmap( pathString + "picker" ); 481 icon = loadPixmap( pathString + "picker" );
482 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); 482 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this );
483 action->addTo( viewMenu ); 483 action->addTo( viewMenu );
484 connect( action, SIGNAL( activated() ), 484 connect( action, SIGNAL( activated() ),
485 mView, SLOT( showDatePicker() ) ); 485 mView, SLOT( showDatePicker() ) );
486 action->addTo( iconToolBar ); 486 action->addTo( iconToolBar );
487 viewMenu->insertSeparator(); 487 viewMenu->insertSeparator();
488 icon = loadPixmap( pathString + "list" ); 488 icon = loadPixmap( pathString + "list" );
489 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); 489 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 );
490 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); 490 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this );
491 showlist_action->addTo( viewMenu ); 491 showlist_action->addTo( viewMenu );
492 connect( showlist_action, SIGNAL( activated() ), 492 connect( showlist_action, SIGNAL( activated() ),
493 mView->viewManager(), SLOT( showListView() ) ); 493 mView->viewManager(), SLOT( showListView() ) );
494 494
495 495
496 icon = loadPixmap( pathString + "day" ); 496 icon = loadPixmap( pathString + "day" );
497 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); 497 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 );
498 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); 498 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this );
499 day1_action->addTo( viewMenu ); 499 day1_action->addTo( viewMenu );
500 // action->addTo( toolBar ); 500 // action->addTo( toolBar );
501 connect( day1_action, SIGNAL( activated() ), 501 connect( day1_action, SIGNAL( activated() ),
502 mView->viewManager(), SLOT( showDayView() ) ); 502 mView->viewManager(), SLOT( showDayView() ) );
503 503
504 icon = loadPixmap( pathString + "workweek" ); 504 icon = loadPixmap( pathString + "workweek" );
505 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); 505 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 );
506 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); 506 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this );
507 day5_action->addTo( viewMenu ); 507 day5_action->addTo( viewMenu );
508 connect( day5_action, SIGNAL( activated() ), 508 connect( day5_action, SIGNAL( activated() ),
509 mView->viewManager(), SLOT( showWorkWeekView() ) ); 509 mView->viewManager(), SLOT( showWorkWeekView() ) );
510 510
511 icon = loadPixmap( pathString + "week" ); 511 icon = loadPixmap( pathString + "week" );
512 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); 512 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 );
513 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); 513 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this );
514 day7_action->addTo( viewMenu ); 514 day7_action->addTo( viewMenu );
515 connect( day7_action, SIGNAL( activated() ), 515 connect( day7_action, SIGNAL( activated() ),
516 mView->viewManager(), SLOT( showWeekView() ) ); 516 mView->viewManager(), SLOT( showWeekView() ) );
517 517
518 icon = loadPixmap( pathString + "month" ); 518 icon = loadPixmap( pathString + "month" );
519 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); 519 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 );
520 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); 520 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this );
521 month_action->addTo( viewMenu ); 521 month_action->addTo( viewMenu );
522 connect( month_action, SIGNAL( activated() ), 522 connect( month_action, SIGNAL( activated() ),
523 mView->viewManager(), SLOT( showMonthView() ) ); 523 mView->viewManager(), SLOT( showMonthView() ) );
524 524
525 icon = loadPixmap( pathString + "todo" ); 525 icon = loadPixmap( pathString + "todo" );
526 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); 526 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 );
527 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); 527 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this );
528 todoview_action->addTo( viewMenu ); 528 todoview_action->addTo( viewMenu );
529 connect( todoview_action, SIGNAL( activated() ), 529 connect( todoview_action, SIGNAL( activated() ),
530 mView->viewManager(), SLOT( showTodoView() ) ); 530 mView->viewManager(), SLOT( showTodoView() ) );
531 531
532 icon = loadPixmap( pathString + "journal" ); 532 icon = loadPixmap( pathString + "journal" );
533 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); 533 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 );
534 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); 534 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this );
535 viewjournal_action->addTo( viewMenu ); 535 viewjournal_action->addTo( viewMenu );
536 connect( viewjournal_action, SIGNAL( activated() ), 536 connect( viewjournal_action, SIGNAL( activated() ),
537 mView->viewManager(), SLOT( showJournalView() ) ); 537 mView->viewManager(), SLOT( showJournalView() ) );
538 538
539 icon = loadPixmap( pathString + "xdays" ); 539 icon = loadPixmap( pathString + "xdays" );
540 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 ); 540 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 );
541 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); 541 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this );
542 xdays_action->addTo( viewMenu ); 542 xdays_action->addTo( viewMenu );
543 connect( xdays_action, SIGNAL( activated() ), 543 connect( xdays_action, SIGNAL( activated() ),
544 mView->viewManager(), SLOT( showNextXView() ) ); 544 mView->viewManager(), SLOT( showNextXView() ) );
545 545
546 icon = loadPixmap( pathString + "whatsnext" ); 546 icon = loadPixmap( pathString + "whatsnext" );
547 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 ); 547 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 );
548 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); 548 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this );
549 whatsnext_action->addTo( viewMenu ); 549 whatsnext_action->addTo( viewMenu );
550 connect( whatsnext_action, SIGNAL( activated() ), 550 connect( whatsnext_action, SIGNAL( activated() ),
551 mView->viewManager(), SLOT( showWhatsNextView() ) ); 551 mView->viewManager(), SLOT( showWhatsNextView() ) );
552 552
553#if 0 553#if 0
554 action = new QAction( "view_timespan", "Time Span", 0, this ); 554 action = new QAction( "view_timespan", "Time Span", 0, this );
555 action->addTo( viewMenu ); 555 action->addTo( viewMenu );
556 connect( action, SIGNAL( activated() ), 556 connect( action, SIGNAL( activated() ),
557 mView->viewManager(), SLOT( showTimeSpanView() ) ); 557 mView->viewManager(), SLOT( showTimeSpanView() ) );
558#endif 558#endif
559 559
560 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, 560 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0,
561 this ); 561 this );
562 mNewSubTodoAction->addTo( actionMenu ); 562 mNewSubTodoAction->addTo( actionMenu );
563 connect( mNewSubTodoAction, SIGNAL( activated() ), 563 connect( mNewSubTodoAction, SIGNAL( activated() ),
564 mView, SLOT( newSubTodo() ) ); 564 mView, SLOT( newSubTodo() ) );
565 565
566 actionMenu->insertSeparator(); 566 actionMenu->insertSeparator();
567 567
568 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); 568 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this );
569 mShowAction->addTo( actionMenu ); 569 mShowAction->addTo( actionMenu );
570 connect( mShowAction, SIGNAL( activated() ), 570 connect( mShowAction, SIGNAL( activated() ),
571 mView, SLOT( showIncidence() ) ); 571 mView, SLOT( showIncidence() ) );
572 572
573 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); 573 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this );
574 mEditAction->addTo( actionMenu ); 574 mEditAction->addTo( actionMenu );
575 connect( mEditAction, SIGNAL( activated() ), 575 connect( mEditAction, SIGNAL( activated() ),
576 mView, SLOT( editIncidence() ) ); 576 mView, SLOT( editIncidence() ) );
577 577
578 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); 578 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this );
579 mDeleteAction->addTo( actionMenu ); 579 mDeleteAction->addTo( actionMenu );
580 connect( mDeleteAction, SIGNAL( activated() ), 580 connect( mDeleteAction, SIGNAL( activated() ),
581 mView, SLOT( deleteIncidence() ) ); 581 mView, SLOT( deleteIncidence() ) );
582 582
583 actionMenu->insertSeparator(); 583 actionMenu->insertSeparator();
584 584
585 action = new QAction( "purge_completed", i18n("Purge Completed"), 0, 585 action = new QAction( "purge_completed", i18n("Purge Completed"), 0,
586 this ); 586 this );
587 action->addTo( actionMenu ); 587 action->addTo( actionMenu );
588 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); 588 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) );
589 589
590 icon = loadPixmap( pathString + "search" ); 590 icon = loadPixmap( pathString + "search" );
591 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); 591 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this );
592 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4); 592 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4);
593 search_action->addTo( actionMenu ); 593 search_action->addTo( actionMenu );
594 connect( search_action, SIGNAL( activated() ), 594 connect( search_action, SIGNAL( activated() ),
595 mView->dialogManager(), SLOT( showSearchDialog() ) ); 595 mView->dialogManager(), SLOT( showSearchDialog() ) );
596 596
597 icon = loadPixmap( pathString + "today" ); 597 icon = loadPixmap( pathString + "today" );
598 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); 598 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130);
599 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); 599 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this );
600 today_action->addTo( actionMenu ); 600 today_action->addTo( actionMenu );
601 connect( today_action, SIGNAL( activated() ), 601 connect( today_action, SIGNAL( activated() ),
602 mView, SLOT( goToday() ) ); 602 mView, SLOT( goToday() ) );
603 603
604 if ( KOPrefs::instance()->mShowFullMenu ) { 604 if ( KOPrefs::instance()->mShowFullMenu ) {
605 actionMenu->insertSeparator(); 605 actionMenu->insertSeparator();
606 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); 606 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu );
607 607
608 } 608 }
609 // actionMenu->insertSeparator(); 609 // actionMenu->insertSeparator();
610 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, 610 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0,
611 this ); 611 this );
612 action->addTo( importMenu ); 612 action->addTo( importMenu );
613 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); 613 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) );
614 action = new QAction( "import_quick", i18n("Import last file"), 0, 614 action = new QAction( "import_quick", i18n("Import last file"), 0,
615 this ); 615 this );
616 action->addTo( importMenu ); 616 action->addTo( importMenu );
617 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); 617 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) );
618 importMenu->insertSeparator(); 618 importMenu->insertSeparator();
619 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, 619 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0,
620 this ); 620 this );
621 action->addTo( importMenu ); 621 action->addTo( importMenu );
622 connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); 622 connect( action, SIGNAL( activated() ), SLOT( importBday() ) );
623#ifndef DESKTOP_VERSION 623#ifndef DESKTOP_VERSION
624 importMenu->insertSeparator(); 624 importMenu->insertSeparator();
625 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, 625 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0,
626 this ); 626 this );
627 action->addTo( importMenu ); 627 action->addTo( importMenu );
628 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); 628 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) );
629#else 629#else
630#ifdef _WIN32_ 630#ifdef _WIN32_
631 importMenu->insertSeparator(); 631 importMenu->insertSeparator();
632 action = new QAction( "import_ol", i18n("Import from OL"), 0, 632 action = new QAction( "import_ol", i18n("Import from OL"), 0,
633 this ); 633 this );
634 action->addTo( importMenu ); 634 action->addTo( importMenu );
635 connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); 635 connect( action, SIGNAL( activated() ), SLOT( importOL() ) );
636#endif 636#endif
637#endif 637#endif
638 638
639 importMenu->insertSeparator(); 639 importMenu->insertSeparator();
640 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, 640 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0,
641 this ); 641 this );
642 action->addTo( importMenu ); 642 action->addTo( importMenu );
643 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); 643 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) );
644 644
645 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, 645 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0,
646 this ); 646 this );
647 action->addTo( importMenu ); 647 action->addTo( importMenu );
648 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); 648 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) );
649 649
650 importMenu->insertSeparator(); 650 importMenu->insertSeparator();
651 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, 651 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0,
652 this ); 652 this );
653 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); 653 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) );
654 importMenu->insertSeparator(); 654 importMenu->insertSeparator();
655 action = new QAction( "manage cat", i18n("Manage new categories..."), 0, 655 action = new QAction( "manage cat", i18n("Manage new categories..."), 0,
656 this ); 656 this );
657 action->addTo( importMenu ); 657 action->addTo( importMenu );
658 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); 658 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) );
659#ifndef DESKTOP_VERSION 659#ifndef DESKTOP_VERSION
660 importMenu->insertSeparator(); 660 importMenu->insertSeparator();
661 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, 661 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0,
662 this ); 662 this );
663 action->addTo( importMenu ); 663 action->addTo( importMenu );
664 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); 664 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) );
665 665
666 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, 666 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0,
667 this ); 667 this );
668 action->addTo( importMenu ); 668 action->addTo( importMenu );
669 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); 669 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) );
670#else 670#else
671 importMenu->insertSeparator(); 671 importMenu->insertSeparator();
672 icon = loadPixmap( pathString + "print" ); 672 icon = loadPixmap( pathString + "print" );
673 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); 673 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this );
674 action->addTo( importMenu ); 674 action->addTo( importMenu );
675 connect( action, SIGNAL( activated() ), 675 connect( action, SIGNAL( activated() ),
676 this, SLOT( printCal() ) ); 676 this, SLOT( printCal() ) );
677 677
678 icon = loadPixmap( pathString + "print" ); 678 icon = loadPixmap( pathString + "print" );
679 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); 679 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this );
680 action->addTo( importMenu ); 680 action->addTo( importMenu );
681 connect( action, SIGNAL( activated() ), 681 connect( action, SIGNAL( activated() ),
682 this, SLOT( printSel() ) ); 682 this, SLOT( printSel() ) );
683#endif 683#endif
684 importMenu->insertSeparator(); 684 importMenu->insertSeparator();
685 action = new QAction( "beam all", i18n("Save"), 0, 685 action = new QAction( "beam all", i18n("Save"), 0,
686 this ); 686 this );
687 action->addTo( importMenu ); 687 action->addTo( importMenu );
688 connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); 688 connect( action, SIGNAL( activated() ), this, SLOT( save() ) );
689 action = new QAction( "beam all", i18n("Exit (+save)"), 0, 689 action = new QAction( "beam all", i18n("Exit (+save)"), 0,
690 this ); 690 this );
691 action->addTo( importMenu ); 691 action->addTo( importMenu );
692 connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); 692 connect( action, SIGNAL( activated() ), this, SLOT( close() ) );
693 693
694 //menuBar->insertItem( "Configure",configureMenu ); 694 //menuBar->insertItem( "Configure",configureMenu );
695 //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); 695 //configureMenu->insertItem( "Toolbar",configureToolBarMenu );
696 icon = loadPixmap( "korganizer/korganizer" ); 696 icon = loadPixmap( "korganizer/korganizer" );
697 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); 697 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this );
698 action->addTo( helpMenu ); 698 action->addTo( helpMenu );
699 connect( action, SIGNAL( activated() ), 699 connect( action, SIGNAL( activated() ),
700 SLOT( keyBindings() ) ); 700 SLOT( keyBindings() ) );
701 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); 701 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this );
702 action->addTo( helpMenu ); 702 action->addTo( helpMenu );
703 connect( action, SIGNAL( activated() ), 703 connect( action, SIGNAL( activated() ),
704 SLOT( features() ) ); 704 SLOT( features() ) );
705 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); 705 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this );
706 action->addTo( helpMenu ); 706 action->addTo( helpMenu );
707 connect( action, SIGNAL( activated() ), 707 connect( action, SIGNAL( activated() ),
708 SLOT( aboutAutoSaving() ) ); 708 SLOT( aboutAutoSaving() ) );
709 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); 709 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this );
710 action->addTo( helpMenu ); 710 action->addTo( helpMenu );
711 connect( action, SIGNAL( activated() ), 711 connect( action, SIGNAL( activated() ),
712 SLOT( aboutKnownBugs() ) ); 712 SLOT( aboutKnownBugs() ) );
713 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); 713 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this );
714 action->addTo( helpMenu ); 714 action->addTo( helpMenu );
715 connect( action, SIGNAL( activated() ), 715 connect( action, SIGNAL( activated() ),
716 SLOT( usertrans() ) ); 716 SLOT( usertrans() ) );
717 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); 717 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this );
718 action->addTo( helpMenu ); 718 action->addTo( helpMenu );
719 connect( action, SIGNAL( activated() ), 719 connect( action, SIGNAL( activated() ),
720 SLOT( synchowto() ) ); 720 SLOT( synchowto() ) );
721 action = new QAction( "Whats New", i18n("What's new?"), 0,this ); 721 action = new QAction( "Whats New", i18n("What's new?"), 0,this );
722 action->addTo( helpMenu ); 722 action->addTo( helpMenu );
723 connect( action, SIGNAL( activated() ), 723 connect( action, SIGNAL( activated() ),
724 SLOT( whatsNew() ) ); 724 SLOT( whatsNew() ) );
725 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); 725 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this );
726 action->addTo( helpMenu ); 726 action->addTo( helpMenu );
727 connect( action, SIGNAL( activated() ), 727 connect( action, SIGNAL( activated() ),
728 SLOT( faq() ) ); 728 SLOT( faq() ) );
729 729
730 730
731 action = new QAction( "about", i18n("About..."), 0, this ); 731 action = new QAction( "about", i18n("About..."), 0, this );
732 action->addTo( helpMenu ); 732 action->addTo( helpMenu );
733 connect( action, SIGNAL( activated() ), 733 connect( action, SIGNAL( activated() ),
734 SLOT( about() ) ); 734 SLOT( about() ) );
735 action = new QAction( "licence", i18n("Licence..."), 0, this ); 735 action = new QAction( "licence", i18n("Licence..."), 0, this );
736 action->addTo( helpMenu ); 736 action->addTo( helpMenu );
737 connect( action, SIGNAL( activated() ), 737 connect( action, SIGNAL( activated() ),
738 SLOT( licence() ) ); 738 SLOT( licence() ) );
739 //menuBar->insertSeparator(); 739 //menuBar->insertSeparator();
740 740
741 // ****************************************************** 741 // ******************************************************
742 // menubar icons 742 // menubar icons
743 743
744 744
745 iconToolBar->setHorizontalStretchable (true ); 745 iconToolBar->setHorizontalStretchable (true );
746 //menuBar->insertItem( iconToolBar ); 746 //menuBar->insertItem( iconToolBar );
747 //xdays_action 747 //xdays_action
748 if (p-> mShowIconNewEvent) 748 if (p-> mShowIconNewEvent)
749 ne_action->addTo( iconToolBar ); 749 ne_action->addTo( iconToolBar );
750 if (p->mShowIconNewTodo ) 750 if (p->mShowIconNewTodo )
751 nt_action->addTo( iconToolBar ); 751 nt_action->addTo( iconToolBar );
752 if (p-> mShowIconSearch) 752 if (p-> mShowIconSearch)
753 search_action->addTo( iconToolBar ); 753 search_action->addTo( iconToolBar );
754 if (p-> mShowIconNext) 754 if (p-> mShowIconNext)
755 whatsnext_action->addTo( iconToolBar ); 755 whatsnext_action->addTo( iconToolBar );
756 if (p-> mShowIconNextDays) 756 if (p-> mShowIconNextDays)
757 xdays_action->addTo( iconToolBar ); 757 xdays_action->addTo( iconToolBar );
758 if (p-> mShowIconList) 758 if (p-> mShowIconList)
759 showlist_action->addTo( iconToolBar ); 759 showlist_action->addTo( iconToolBar );
760 if (p-> mShowIconDay1) 760 if (p-> mShowIconDay1)
761 day1_action->addTo( iconToolBar ); 761 day1_action->addTo( iconToolBar );
762 if (p-> mShowIconDay5) 762 if (p-> mShowIconDay5)
763 day5_action->addTo( iconToolBar ); 763 day5_action->addTo( iconToolBar );
764 if (p-> mShowIconDay7) 764 if (p-> mShowIconDay7)
765 day7_action->addTo( iconToolBar ); 765 day7_action->addTo( iconToolBar );
766 if (p-> mShowIconMonth) 766 if (p-> mShowIconMonth)
767 month_action->addTo( iconToolBar ); 767 month_action->addTo( iconToolBar );
768 if (p-> mShowIconTodoview) 768 if (p-> mShowIconTodoview)
769 todoview_action->addTo( iconToolBar ); 769 todoview_action->addTo( iconToolBar );
770 if (p-> mShowIconJournal) 770 if (p-> mShowIconJournal)
771 viewjournal_action->addTo( iconToolBar ); 771 viewjournal_action->addTo( iconToolBar );
772 icon = loadPixmap( pathString + "2leftarrowB" ); 772 icon = loadPixmap( pathString + "2leftarrowB" );
773 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); 773 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14);
774 if (p-> mShowIconBackFast) { 774 if (p-> mShowIconBackFast) {
775 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); 775 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this );
776 connect( action, SIGNAL( activated() ), 776 connect( action, SIGNAL( activated() ),
777 mView, SLOT( goPreviousMonth() ) ); 777 mView, SLOT( goPreviousMonth() ) );
778 action->addTo( iconToolBar ); 778 action->addTo( iconToolBar );
779 } 779 }
780 icon = loadPixmap( pathString + "1leftarrowB" ); 780 icon = loadPixmap( pathString + "1leftarrowB" );
781 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); 781 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15);
782 if (p-> mShowIconBack) { 782 if (p-> mShowIconBack) {
783 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); 783 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this );
784 connect( action, SIGNAL( activated() ), 784 connect( action, SIGNAL( activated() ),
785 mView, SLOT( goPrevious() ) ); 785 mView, SLOT( goPrevious() ) );
786 action->addTo( iconToolBar ); 786 action->addTo( iconToolBar );
787 } 787 }
788 if (p-> mShowIconToday) 788 if (p-> mShowIconToday)
789 today_action->addTo( iconToolBar ); 789 today_action->addTo( iconToolBar );
790 icon = loadPixmap( pathString + "1rightarrowB" ); 790 icon = loadPixmap( pathString + "1rightarrowB" );
791 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); 791 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220);
792 if (p-> mShowIconForward) { 792 if (p-> mShowIconForward) {
793 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); 793 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this );
794 connect( action, SIGNAL( activated() ), 794 connect( action, SIGNAL( activated() ),
795 mView, SLOT( goNext() ) ); 795 mView, SLOT( goNext() ) );
796 action->addTo( iconToolBar ); 796 action->addTo( iconToolBar );
797 } 797 }
798 icon = loadPixmap( pathString + "2rightarrowB" ); 798 icon = loadPixmap( pathString + "2rightarrowB" );
799 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); 799 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230);
800 if (p-> mShowIconForwardFast) { 800 if (p-> mShowIconForwardFast) {
801 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); 801 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this );
802 connect( action, SIGNAL( activated() ), 802 connect( action, SIGNAL( activated() ),
803 mView, SLOT( goNextMonth() ) ); 803 mView, SLOT( goNextMonth() ) );
804 action->addTo( iconToolBar ); 804 action->addTo( iconToolBar );
805 } 805 }
806 806
807 807
808 configureToolBarMenu->insertItem(i18n("What's This?"), 300); 808 configureToolBarMenu->insertItem(i18n("What's This?"), 300);
809 809
810 if (p-> mShowIconNewEvent) 810 if (p-> mShowIconNewEvent)
811 configureToolBarMenu->setItemChecked( 10, true ); 811 configureToolBarMenu->setItemChecked( 10, true );
812 if (p->mShowIconNewTodo ) 812 if (p->mShowIconNewTodo )
813 configureToolBarMenu->setItemChecked( 20, true ); 813 configureToolBarMenu->setItemChecked( 20, true );
814 if (p-> mShowIconSearch) 814 if (p-> mShowIconSearch)
815 configureToolBarMenu->setItemChecked( 120, true ); 815 configureToolBarMenu->setItemChecked( 120, true );
816 if (p-> mShowIconList) 816 if (p-> mShowIconList)
817 configureToolBarMenu->setItemChecked( 30, true ); 817 configureToolBarMenu->setItemChecked( 30, true );
818 if (p-> mShowIconDay1) 818 if (p-> mShowIconDay1)
819 configureToolBarMenu->setItemChecked( 40, true ); 819 configureToolBarMenu->setItemChecked( 40, true );
820 if (p-> mShowIconDay5) 820 if (p-> mShowIconDay5)
821 configureToolBarMenu->setItemChecked( 50, true ); 821 configureToolBarMenu->setItemChecked( 50, true );
822 if (p-> mShowIconDay7) 822 if (p-> mShowIconDay7)
823 configureToolBarMenu->setItemChecked( 60, true ); 823 configureToolBarMenu->setItemChecked( 60, true );
824 if (p-> mShowIconMonth) 824 if (p-> mShowIconMonth)
825 configureToolBarMenu->setItemChecked( 70, true ); 825 configureToolBarMenu->setItemChecked( 70, true );
826 if (p-> mShowIconTodoview) 826 if (p-> mShowIconTodoview)
827 configureToolBarMenu->setItemChecked( 80, true ); 827 configureToolBarMenu->setItemChecked( 80, true );
828 if (p-> mShowIconBackFast) 828 if (p-> mShowIconBackFast)
829 configureToolBarMenu->setItemChecked( 200, true ); 829 configureToolBarMenu->setItemChecked( 200, true );
830 if (p-> mShowIconBack) 830 if (p-> mShowIconBack)
831 configureToolBarMenu->setItemChecked( 210, true ); 831 configureToolBarMenu->setItemChecked( 210, true );
832 if (p-> mShowIconToday) 832 if (p-> mShowIconToday)
833 configureToolBarMenu->setItemChecked( 130, true ); 833 configureToolBarMenu->setItemChecked( 130, true );
834 if (p-> mShowIconForward) 834 if (p-> mShowIconForward)
835 configureToolBarMenu->setItemChecked( 220, true ); 835 configureToolBarMenu->setItemChecked( 220, true );
836 if (p-> mShowIconForwardFast) 836 if (p-> mShowIconForwardFast)
837 configureToolBarMenu->setItemChecked( 230, true ); 837 configureToolBarMenu->setItemChecked( 230, true );
838 if (p-> mShowIconNextDays) 838 if (p-> mShowIconNextDays)
839 configureToolBarMenu->setItemChecked( 100, true ); 839 configureToolBarMenu->setItemChecked( 100, true );
840 if (p-> mShowIconNext) 840 if (p-> mShowIconNext)
841 configureToolBarMenu->setItemChecked( 110, true ); 841 configureToolBarMenu->setItemChecked( 110, true );
842 if (p-> mShowIconJournal) 842 if (p-> mShowIconJournal)
843 configureToolBarMenu->setItemChecked( 90, true ); 843 configureToolBarMenu->setItemChecked( 90, true );
844 if (p-> mShowIconWhatsThis) 844 if (p-> mShowIconWhatsThis)
845 configureToolBarMenu->setItemChecked( 300, true ); 845 configureToolBarMenu->setItemChecked( 300, true );
846 846
847 QLabel* dummy = new QLabel( iconToolBar ); 847 QLabel* dummy = new QLabel( iconToolBar );
848 dummy->setBackgroundColor( iconToolBar->backgroundColor() ); 848 dummy->setBackgroundColor( iconToolBar->backgroundColor() );
849 if (!p-> mShowIconStretch) 849 if (!p-> mShowIconStretch)
850 iconToolBar->setStretchableWidget ( dummy ) ; 850 iconToolBar->setStretchableWidget ( dummy ) ;
851 else 851 else
852 configureToolBarMenu->setItemChecked( 5, true ); 852 configureToolBarMenu->setItemChecked( 5, true );
853 if (p-> mShowIconWhatsThis) 853 if (p-> mShowIconWhatsThis)
854 QWhatsThis::whatsThisButton ( iconToolBar ); 854 QWhatsThis::whatsThisButton ( iconToolBar );
855 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); 855 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) );
856 configureAgenda( p->mHourSize ); 856 configureAgenda( p->mHourSize );
857 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); 857 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) );
858} 858}
859void MainWindow::fillSyncMenu() 859void MainWindow::fillSyncMenu()
860{ 860{
861 if ( syncMenu->count() ) 861 if ( syncMenu->count() )
862 syncMenu->clear(); 862 syncMenu->clear();
863 syncMenu->insertItem( i18n("Configure..."), 0 ); 863 syncMenu->insertItem( i18n("Configure..."), 0 );
864 syncMenu->insertSeparator(); 864 syncMenu->insertSeparator();
865 syncMenu->insertItem( i18n("Multiple sync"), 1 ); 865 syncMenu->insertItem( i18n("Multiple sync"), 1 );
866 syncMenu->insertSeparator(); 866 syncMenu->insertSeparator();
867 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 867 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
868 config.setGroup("General"); 868 config.setGroup("General");
869 QStringList prof = config.readListEntry("SyncProfileNames"); 869 QStringList prof = config.readListEntry("SyncProfileNames");
870 KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); 870 KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined");
871 if ( prof.count() < 3 ) { 871 if ( prof.count() < 3 ) {
872 prof.clear(); 872 prof.clear();
873 prof << i18n("Sharp_DTM"); 873 prof << i18n("Sharp_DTM");
874 prof << i18n("Local_file"); 874 prof << i18n("Local_file");
875 prof << i18n("Last_file"); 875 prof << i18n("Last_file");
876 KSyncProfile* temp = new KSyncProfile (); 876 KSyncProfile* temp = new KSyncProfile ();
877 temp->setName( prof[0] ); 877 temp->setName( prof[0] );
878 temp->writeConfig(&config); 878 temp->writeConfig(&config);
879 temp->setName( prof[1] ); 879 temp->setName( prof[1] );
880 temp->writeConfig(&config); 880 temp->writeConfig(&config);
881 temp->setName( prof[2] ); 881 temp->setName( prof[2] );
882 temp->writeConfig(&config); 882 temp->writeConfig(&config);
883 config.setGroup("General"); 883 config.setGroup("General");
884 config.writeEntry("SyncProfileNames",prof); 884 config.writeEntry("SyncProfileNames",prof);
885 config.writeEntry("ExternSyncProfiles","Sharp_DTM"); 885 config.writeEntry("ExternSyncProfiles","Sharp_DTM");
886 config.sync(); 886 config.sync();
887 delete temp; 887 delete temp;
888 } 888 }
889 KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); 889 KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
890 KOPrefs::instance()->mSyncProfileNames = prof; 890 KOPrefs::instance()->mSyncProfileNames = prof;
891 int i; 891 int i;
892 for ( i = 0; i < prof.count(); ++i ) { 892 for ( i = 0; i < prof.count(); ++i ) {
893 893
894 syncMenu->insertItem( prof[i], 1000+i ); 894 syncMenu->insertItem( prof[i], 1000+i );
895 if ( i == 2 ) 895 if ( i == 2 )
896 syncMenu->insertSeparator(); 896 syncMenu->insertSeparator();
897 } 897 }
898 QDir app_dir; 898 QDir app_dir;
899 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { 899 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
900 syncMenu->setItemEnabled( false , 1000 ); 900 syncMenu->setItemEnabled( false , 1000 );
901 } 901 }
902 mView->setupExternSyncProfiles(); 902 mView->setupExternSyncProfiles();
903} 903}
904 904
905int MainWindow::ringSync() 905int MainWindow::ringSync()
906{ 906{
907 int syncedProfiles = 0; 907 int syncedProfiles = 0;
908 int i; 908 int i;
909 QTime timer; 909 QTime timer;
910 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 910 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
911 QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames; 911 QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames;
912 KSyncProfile* temp = new KSyncProfile (); 912 KSyncProfile* temp = new KSyncProfile ();
913 KOPrefs::instance()->mAskForPreferences = false; 913 KOPrefs::instance()->mAskForPreferences = false;
914 for ( i = 0; i < syncProfileNames.count(); ++i ) { 914 for ( i = 0; i < syncProfileNames.count(); ++i ) {
915 mCurrentSyncProfile = i; 915 mCurrentSyncProfile = i;
916 temp->setName(syncProfileNames[mCurrentSyncProfile]); 916 temp->setName(syncProfileNames[mCurrentSyncProfile]);
917 temp->readConfig(&config); 917 temp->readConfig(&config);
918 if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) { 918 if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) {
919 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); 919 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
920 ++syncedProfiles; 920 ++syncedProfiles;
921 // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 921 // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
922 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 922 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
923 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 923 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
924 KOPrefs::instance()->mWriteBackInFuture = 0; 924 KOPrefs::instance()->mWriteBackInFuture = 0;
925 if ( temp->getWriteBackFuture() ) 925 if ( temp->getWriteBackFuture() )
926 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 926 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
927 KOPrefs::instance()->mShowSyncSummary = false; 927 KOPrefs::instance()->mShowSyncSummary = false;
928 mView->setSyncDevice(syncProfileNames[i] ); 928 mView->setSyncDevice(syncProfileNames[i] );
929 mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); 929 mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
930 if ( i == 0 ) { 930 if ( i == 0 ) {
931 syncSharp(); 931 syncSharp();
932 } else { 932 } else {
933 if ( temp->getIsLocalFileSync() ) { 933 if ( temp->getIsLocalFileSync() ) {
934 if ( syncWithFile( temp->getRemoteFileName( ), true ) ) 934 if ( syncWithFile( temp->getRemoteFileName( ), true ) )
935 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); 935 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName();
936 } else { 936 } else {
937 if ( temp->getIsPhoneSync() ) { 937 if ( temp->getIsPhoneSync() ) {
938 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; 938 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ;
939 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); 939 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( );
940 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); 940 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( );
941 syncPhone(); 941 syncPhone();
942 } else 942 } else
943 syncRemote( temp, false ); 943 syncRemote( temp, false );
944 944
945 } 945 }
946 } 946 }
947 timer.start(); 947 timer.start();
948 setCaption(i18n("Multiple sync in progress ... please wait!") ); 948 setCaption(i18n("Multiple sync in progress ... please wait!") );
949 while ( timer.elapsed () < 2000 ) { 949 while ( timer.elapsed () < 2000 ) {
950 qApp->processEvents(); 950 qApp->processEvents();
951#ifndef _WIN32_ 951#ifndef _WIN32_
952 sleep (1); 952 sleep (1);
953#endif 953#endif
954 } 954 }
955 955
956 } 956 }
957 957
958 } 958 }
959 delete temp; 959 delete temp;
960 return syncedProfiles; 960 return syncedProfiles;
961} 961}
962 962
963void MainWindow::multiSync( bool askforPrefs ) 963void MainWindow::multiSync( bool askforPrefs )
964{ 964{
965 if (mBlockSaveFlag) 965 if (mBlockSaveFlag)
966 return; 966 return;
967 mBlockSaveFlag = true; 967 mBlockSaveFlag = true;
968 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 968 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
969 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 969 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
970 question, 970 question,
971 i18n("Yes"), i18n("No"), 971 i18n("Yes"), i18n("No"),
972 0, 0 ) != 0 ) { 972 0, 0 ) != 0 ) {
973 mBlockSaveFlag = false; 973 mBlockSaveFlag = false;
974 setCaption(i18n("Aborted! Nothing synced!")); 974 setCaption(i18n("Aborted! Nothing synced!"));
975 return; 975 return;
976 } 976 }
977 mView->setSyncDevice(i18n("Multiple profiles") ); 977 mView->setSyncDevice(i18n("Multiple profiles") );
978 KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs; 978 KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs;
979 if ( askforPrefs ) { 979 if ( askforPrefs ) {
980 mView->edit_sync_options(); 980 mView->edit_sync_options();
981 KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs; 981 KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs;
982 } 982 }
983 setCaption(i18n("Multiple sync started.") ); 983 setCaption(i18n("Multiple sync started.") );
984 qApp->processEvents(); 984 qApp->processEvents();
985 int num = ringSync() ; 985 int num = ringSync() ;
986 if ( num > 1 ) 986 if ( num > 1 )
987 ringSync(); 987 ringSync();
988 mBlockSaveFlag = false; 988 mBlockSaveFlag = false;
989 if ( num ) 989 if ( num )
990 save(); 990 save();
991 if ( num ) 991 if ( num )
992 setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); 992 setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) );
993 else 993 else
994 setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 994 setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
995 return; 995 return;
996} 996}
997void MainWindow::slotSyncMenu( int action ) 997void MainWindow::slotSyncMenu( int action )
998{ 998{
999 //qDebug("syncaction %d ", action); 999 //qDebug("syncaction %d ", action);
1000 if ( action == 0 ) { 1000 if ( action == 0 ) {
1001 1001
1002 // seems to be a Qt2 event handling bug 1002 // seems to be a Qt2 event handling bug
1003 // syncmenu.clear causes a segfault at first time 1003 // syncmenu.clear causes a segfault at first time
1004 // when we call it after the main event loop, it is ok 1004 // when we call it after the main event loop, it is ok
1005 // same behaviour when calling OM/Pi via QCOP for the first time 1005 // same behaviour when calling OM/Pi via QCOP for the first time
1006 QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); 1006 QTimer::singleShot ( 1, this, SLOT ( confSync() ) );
1007 //confSync(); 1007 //confSync();
1008 1008
1009 return; 1009 return;
1010 } 1010 }
1011 if ( action == 1 ) { 1011 if ( action == 1 ) {
1012 multiSync( true ); 1012 multiSync( true );
1013 return; 1013 return;
1014 } 1014 }
1015 1015
1016 if (mBlockSaveFlag) 1016 if (mBlockSaveFlag)
1017 return; 1017 return;
1018 mBlockSaveFlag = true; 1018 mBlockSaveFlag = true;
1019 mCurrentSyncProfile = action - 1000 ; 1019 mCurrentSyncProfile = action - 1000 ;
1020 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); 1020 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] );
1021 mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); 1021 mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
1022 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 1022 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
1023 KSyncProfile* temp = new KSyncProfile (); 1023 KSyncProfile* temp = new KSyncProfile ();
1024 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 1024 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
1025 temp->readConfig(&config); 1025 temp->readConfig(&config);
1026 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 1026 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
1027 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); 1027 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs();
1028 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 1028 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
1029 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 1029 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
1030 KOPrefs::instance()->mWriteBackInFuture = 0; 1030 KOPrefs::instance()->mWriteBackInFuture = 0;
1031 if ( temp->getWriteBackFuture() ) 1031 if ( temp->getWriteBackFuture() )
1032 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 1032 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
1033 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); 1033 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync();
1034 if ( action == 1000 ) { 1034 if ( action == 1000 ) {
1035 syncSharp(); 1035 syncSharp();
1036 1036
1037 } else if ( action == 1001 ) { 1037 } else if ( action == 1001 ) {
1038 syncLocalFile(); 1038 syncLocalFile();
1039 1039
1040 } else if ( action == 1002 ) { 1040 } else if ( action == 1002 ) {
1041 quickSyncLocalFile(); 1041 quickSyncLocalFile();
1042 1042
1043 } else if ( action >= 1003 ) { 1043 } else if ( action >= 1003 ) {
1044 if ( temp->getIsLocalFileSync() ) { 1044 if ( temp->getIsLocalFileSync() ) {
1045 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 1045 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
1046 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); 1046 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName();
1047 } else { 1047 } else {
1048 if ( temp->getIsPhoneSync() ) { 1048 if ( temp->getIsPhoneSync() ) {
1049 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; 1049 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ;
1050 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); 1050 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( );
1051 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); 1051 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( );
1052 syncPhone(); 1052 syncPhone();
1053 } else 1053 } else
1054 syncRemote( temp ); 1054 syncRemote( temp );
1055 1055
1056 } 1056 }
1057 } 1057 }
1058 delete temp; 1058 delete temp;
1059 mBlockSaveFlag = false; 1059 mBlockSaveFlag = false;
1060} 1060}
1061void MainWindow::setDefaultPreferences() 1061void MainWindow::setDefaultPreferences()
1062{ 1062{
1063 KOPrefs *p = KOPrefs::instance(); 1063 KOPrefs *p = KOPrefs::instance();
1064 1064
1065 p->mCompactDialogs = true; 1065 p->mCompactDialogs = true;
1066 p->mConfirm = true; 1066 p->mConfirm = true;
1067 // p->mEnableQuickTodo = false; 1067 // p->mEnableQuickTodo = false;
1068} 1068}
1069 1069
1070QString MainWindow::resourcePath() 1070QString MainWindow::resourcePath()
1071{ 1071{
1072 return KGlobal::iconLoader()->iconPath(); 1072 return KGlobal::iconLoader()->iconPath();
1073} 1073}
1074 1074
1075void MainWindow::displayText( QString text ,QString cap ) 1075void MainWindow::displayText( QString text ,QString cap )
1076{ 1076{
1077 QDialog dia( this, "name", true ); ; 1077 QDialog dia( this, "name", true ); ;
1078 dia.setCaption( cap ); 1078 dia.setCaption( cap );
1079 QVBoxLayout* lay = new QVBoxLayout( &dia ); 1079 QVBoxLayout* lay = new QVBoxLayout( &dia );
1080 lay->setSpacing( 3 ); 1080 lay->setSpacing( 3 );
1081 lay->setMargin( 3 ); 1081 lay->setMargin( 3 );
1082 QTextBrowser tb ( &dia ); 1082 QTextBrowser tb ( &dia );
1083 lay->addWidget( &tb ); 1083 lay->addWidget( &tb );
1084 tb.setText( text ); 1084 tb.setText( text );
1085#ifdef DESKTOP_VERSION 1085#ifdef DESKTOP_VERSION
1086 dia.resize( 640, 480); 1086 dia.resize( 640, 480);
1087#else 1087#else
1088 dia.showMaximized(); 1088 dia.showMaximized();
1089#endif 1089#endif
1090 dia.exec(); 1090 dia.exec();
1091} 1091}
1092void MainWindow::displayFile( QString fn, QString cap ) 1092void MainWindow::displayFile( QString fn, QString cap )
1093{ 1093{
1094 QString fileName = resourcePath() + fn; 1094 QString fileName = resourcePath() + fn;
1095 QString text; 1095 QString text;
1096 QFile file( fileName ); 1096 QFile file( fileName );
1097 if (!file.open( IO_ReadOnly ) ) { 1097 if (!file.open( IO_ReadOnly ) ) {
1098 return ; 1098 return ;
1099 1099
1100 } 1100 }
1101 QTextStream ts( &file ); 1101 QTextStream ts( &file );
1102 text = ts.read(); 1102 text = ts.read();
1103 file.close(); 1103 file.close();
1104 displayText( text, cap); 1104 displayText( text, cap);
1105} 1105}
1106void MainWindow::features() 1106void MainWindow::features()
1107{ 1107{
1108 1108
1109 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); 1109 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") );
1110} 1110}
1111 1111
1112void MainWindow::usertrans() 1112void MainWindow::usertrans()
1113{ 1113{
1114 1114
1115 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); 1115 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") );
1116} 1116}
1117#if 0 1117#if 0
1118#include <libkcal/vcalformat.h> 1118#include <libkcal/vcalformat.h>
1119#include <libkcal/event.h> 1119#include <libkcal/event.h>
1120#include <libkcal/todo.h> 1120#include <libkcal/todo.h>
1121#include <libkcal/incidence.h> 1121#include <libkcal/incidence.h>
1122#endif 1122#endif
1123void MainWindow::synchowto() 1123void MainWindow::synchowto()
1124{ 1124{
1125#if 0 1125#if 0
1126 QPtrList<Incidence> er = mCalendar->rawIncidences(); 1126 QPtrList<Incidence> er = mCalendar->rawIncidences();
1127 Incidence* inR = er.first(); 1127 Incidence* inR = er.first();
1128 VCalFormat vf; 1128 VCalFormat vf;
1129 QString strout; 1129 QString strout;
1130 while ( inR ) { 1130 while ( inR ) {
1131 if ( inR->type() == "Todo" ) 1131 if ( inR->type() == "Todo" )
1132 strout = vf.todoToString( (Todo *) inR ); 1132 strout = vf.todoToString( (Todo *) inR );
1133 if ( inR->type() == "Event" ) 1133 if ( inR->type() == "Event" )
1134 strout = vf.eventToString( (Event *) inR ); 1134 strout = vf.eventToString( (Event *) inR );
1135 qDebug("incidence: \n%s\n ente\n\n",strout.latin1() ); 1135 qDebug("incidence: \n%s\n ente\n\n",strout.latin1() );
1136 inR = er.next(); 1136 inR = er.next();
1137 } 1137 }
1138#endif 1138#endif
1139 displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") ); 1139 displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") );
1140} 1140}
1141void MainWindow::faq() 1141void MainWindow::faq()
1142{ 1142{
1143 displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); 1143 displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") );
1144 1144
1145} 1145}
1146void MainWindow::whatsNew() 1146void MainWindow::whatsNew()
1147{ 1147{
1148 displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") ); 1148 displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") );
1149 1149
1150} 1150}
1151void MainWindow::licence() 1151void MainWindow::licence()
1152{ 1152{
1153 KApplication::showLicence(); 1153 KApplication::showLicence();
1154 1154
1155} 1155}
1156void MainWindow::about() 1156void MainWindow::about()
1157{ 1157{
1158 QString version; 1158 QString version;
1159#include <../version> 1159#include <../version>
1160 QMessageBox::about( this, i18n("About KOrganizer/Pi"), 1160 QMessageBox::about( this, i18n("About KOrganizer/Pi"),
1161 i18n("KOrganizer/Platform-independent\n") + 1161 i18n("KOrganizer/Platform-independent\n") +
1162 "(KO/Pi) " + version + " - " + 1162 "(KO/Pi) " + version + " - " +
1163 1163
1164#ifdef DESKTOP_VERSION 1164#ifdef DESKTOP_VERSION
1165 i18n("Desktop Edition\n") + 1165 i18n("Desktop Edition\n") +
1166#else 1166#else
1167 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + 1167 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") +
1168#endif 1168#endif
1169 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") ); 1169 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") );
1170} 1170}
1171void MainWindow::keyBindings() 1171void MainWindow::keyBindings()
1172{ 1172{
1173 QString cap = i18n("Key bindings KOrganizer/Pi"); 1173 QString cap = i18n("Key bindings KOrganizer/Pi");
1174 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + 1174 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") +
1175 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ 1175 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+
1176 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + 1176 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") +
1177 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ 1177 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+
1178 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ 1178 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+
1179 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ 1179 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+
1180 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ 1180 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+
1181 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ 1181 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+
1182 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ 1182 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+
1183 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ 1183 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+
1184 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ 1184 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+
1185 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ 1185 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+
1186 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ 1186 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+
1187 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ 1187 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+
1188 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ 1188 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+
1189 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ 1189 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+
1190 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ 1190 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+
1191 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ 1191 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+
1192 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ 1192 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+
1193 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ 1193 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+
1194 i18n("<p><h3>In agenda view:</h3></p>\n") + 1194 i18n("<p><h3>In agenda view:</h3></p>\n") +
1195 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ 1195 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+
1196 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ 1196 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+
1197 i18n("<p><h3>In todo view:</h3></p>\n") + 1197 i18n("<p><h3>In todo view:</h3></p>\n") +
1198 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ 1198 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+
1199 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1199 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1200 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ 1200 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+
1201 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ 1201 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+
1202 i18n("<p><h3>In list view:</h3></p>\n") + 1202 i18n("<p><h3>In list view:</h3></p>\n") +
1203 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1203 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1204 i18n("<p><b>return</b>: Select item+one step down</p>\n")+ 1204 i18n("<p><b>return</b>: Select item+one step down</p>\n")+
1205 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ 1205 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+
1206 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ 1206 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+
1207 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ 1207 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+
1208 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ 1208 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+
1209 i18n("<p><h3>In event/todo viewer:</h3></p>\n") + 1209 i18n("<p><h3>In event/todo viewer:</h3></p>\n") +
1210 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ 1210 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+
1211 i18n("<p><b>A</b>: Show agenda view.</p>\n")+ 1211 i18n("<p><b>A</b>: Show agenda view.</p>\n")+
1212 i18n("<p><b>E</b>: Edit item</p>\n") + 1212 i18n("<p><b>E</b>: Edit item</p>\n") +
1213 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + 1213 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") +
1214 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + 1214 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") +
1215 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ 1215 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+
1216 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ 1216 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+
1217 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ 1217 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+
1218 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ 1218 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+
1219 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ 1219 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+
1220 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + 1220 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") +
1221 i18n("<p><b>White</b>: Item readonly</p>\n"); 1221 i18n("<p><b>White</b>: Item readonly</p>\n");
1222 displayText( text, cap); 1222 displayText( text, cap);
1223 1223
1224} 1224}
1225void MainWindow::aboutAutoSaving() 1225void MainWindow::aboutAutoSaving()
1226{ 1226{
1227 QMessageBox* msg; 1227 QMessageBox* msg;
1228 msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), 1228 msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"),
1229 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, 1229 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,
1230 QMessageBox::Ok, 1230 QMessageBox::Ok,
1231 QMessageBox::NoButton, 1231 QMessageBox::NoButton,
1232 QMessageBox::NoButton); 1232 QMessageBox::NoButton);
1233 msg->exec(); 1233 msg->exec();
1234 delete msg; 1234 delete msg;
1235 1235
1236 1236
1237} 1237}
1238void MainWindow::aboutKnownBugs() 1238void MainWindow::aboutKnownBugs()
1239{ 1239{
1240 QMessageBox* msg; 1240 QMessageBox* msg;
1241 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), 1241 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"),
1242 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")+ 1242 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")+
1243 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ 1243 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+
1244 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + 1244 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") +
1245 i18n("\nor report them in the bugtracker on\n") + 1245 i18n("\nor report them in the bugtracker on\n") +
1246 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), 1246 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"),
1247 QMessageBox::NoIcon, 1247 QMessageBox::NoIcon,
1248 QMessageBox::Ok, 1248 QMessageBox::Ok,
1249 QMessageBox::NoButton, 1249 QMessageBox::NoButton,
1250 QMessageBox::NoButton); 1250 QMessageBox::NoButton);
1251 msg->exec(); 1251 msg->exec();
1252 delete msg; 1252 delete msg;
1253 1253
1254} 1254}
1255 1255
1256QString MainWindow::defaultFileName() 1256QString MainWindow::defaultFileName()
1257{ 1257{
1258 return locateLocal( "data", "korganizer/mycalendar.ics" ); 1258 return locateLocal( "data", "korganizer/mycalendar.ics" );
1259} 1259}
1260 1260
1261void MainWindow::processIncidenceSelection( Incidence *incidence ) 1261void MainWindow::processIncidenceSelection( Incidence *incidence )
1262{ 1262{
1263 if ( !incidence ) { 1263 if ( !incidence ) {
1264 enableIncidenceActions( false ); 1264 enableIncidenceActions( false );
1265 1265
1266 mNewSubTodoAction->setEnabled( false ); 1266 mNewSubTodoAction->setEnabled( false );
1267 setCaptionToDates(); 1267 setCaptionToDates();
1268 return; 1268 return;
1269 1269
1270 } 1270 }
1271 1271
1272 //KGlobal::locale()->formatDateTime(nextA, true); 1272 //KGlobal::locale()->formatDateTime(nextA, true);
1273 QString startString = ""; 1273 QString startString = "";
1274 if ( incidence->type() != "Todo" ) { 1274 if ( incidence->type() != "Todo" ) {
1275 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { 1275 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) {
1276 if ( incidence->doesFloat() ) { 1276 if ( incidence->doesFloat() ) {
1277 startString += ": "+incidence->dtStartDateStr( true ); 1277 startString += ": "+incidence->dtStartDateStr( true );
1278 startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); 1278 startString += " --- "+((Event*)incidence)->dtEndDateStr( true );
1279 1279
1280 } else { 1280 } else {
1281 startString = ": "+incidence->dtStartStr(true); 1281 startString = ": "+incidence->dtStartStr(true);
1282 startString += " --- "+((Event*)incidence)->dtEndStr(true); 1282 startString += " --- "+((Event*)incidence)->dtEndStr(true);
1283 1283
1284 } 1284 }
1285 1285
1286 } else { 1286 } else {
1287 if ( incidence->dtStart().time() != incidence->dtEnd().time() ) 1287 if ( incidence->dtStart().time() != incidence->dtEnd().time() )
1288 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ 1288 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+
1289 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); 1289 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time());
1290 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); 1290 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true);
1291 } 1291 }
1292 1292
1293 } 1293 }
1294 else 1294 else
1295 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); 1295 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed");
1296 if ( !incidence->location().isEmpty() ) 1296 if ( !incidence->location().isEmpty() )
1297 startString += " (" +incidence->location()+")"; 1297 startString += " (" +incidence->location()+")";
1298 setCaption( incidence->summary()+startString); 1298 setCaption( incidence->summary()+startString);
1299 1299
1300 enableIncidenceActions( true ); 1300 enableIncidenceActions( true );
1301 1301
1302 if ( incidence->type() == "Event" ) { 1302 if ( incidence->type() == "Event" ) {
1303 mShowAction->setText( i18n("Show Event...") ); 1303 mShowAction->setText( i18n("Show Event...") );
1304 mEditAction->setText( i18n("Edit Event...") ); 1304 mEditAction->setText( i18n("Edit Event...") );
1305 mDeleteAction->setText( i18n("Delete Event...") ); 1305 mDeleteAction->setText( i18n("Delete Event...") );
1306 1306
1307 mNewSubTodoAction->setEnabled( false ); 1307 mNewSubTodoAction->setEnabled( false );
1308 } else if ( incidence->type() == "Todo" ) { 1308 } else if ( incidence->type() == "Todo" ) {
1309 mShowAction->setText( i18n("Show Todo...") ); 1309 mShowAction->setText( i18n("Show Todo...") );
1310 mEditAction->setText( i18n("Edit Todo...") ); 1310 mEditAction->setText( i18n("Edit Todo...") );
1311 mDeleteAction->setText( i18n("Delete Todo...") ); 1311 mDeleteAction->setText( i18n("Delete Todo...") );
1312 1312
1313 mNewSubTodoAction->setEnabled( true ); 1313 mNewSubTodoAction->setEnabled( true );
1314 } else { 1314 } else {
1315 mShowAction->setText( i18n("Show...") ); 1315 mShowAction->setText( i18n("Show...") );
1316 mShowAction->setText( i18n("Edit...") ); 1316 mShowAction->setText( i18n("Edit...") );
1317 mShowAction->setText( i18n("Delete...") ); 1317 mShowAction->setText( i18n("Delete...") );
1318 1318
1319 mNewSubTodoAction->setEnabled( false ); 1319 mNewSubTodoAction->setEnabled( false );
1320 } 1320 }
1321} 1321}
1322 1322
1323void MainWindow::enableIncidenceActions( bool enabled ) 1323void MainWindow::enableIncidenceActions( bool enabled )
1324{ 1324{
1325 mShowAction->setEnabled( enabled ); 1325 mShowAction->setEnabled( enabled );
1326 mEditAction->setEnabled( enabled ); 1326 mEditAction->setEnabled( enabled );
1327 mDeleteAction->setEnabled( enabled ); 1327 mDeleteAction->setEnabled( enabled );
1328} 1328}
1329 1329
1330void MainWindow::importOL() 1330void MainWindow::importOL()
1331{ 1331{
1332#ifdef _WIN32_ 1332#ifdef _WIN32_
1333 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); 1333 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this );
1334 id->exec(); 1334 id->exec();
1335 delete id; 1335 delete id;
1336 mView->updateView(); 1336 mView->updateView();
1337#endif 1337#endif
1338} 1338}
1339void MainWindow::importBday() 1339void MainWindow::importBday()
1340{ 1340{
1341 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1341 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1342 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), 1342 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"),
1343 i18n("Import!"), i18n("Cancel"), 0, 1343 i18n("Import!"), i18n("Cancel"), 0,
1344 0, 1 ); 1344 0, 1 );
1345 if ( result == 0 ) { 1345 if ( result == 0 ) {
1346 mView->importBday(); 1346 mView->importBday();
1347 1347
1348 } 1348 }
1349 1349
1350 1350
1351} 1351}
1352void MainWindow::importQtopia() 1352void MainWindow::importQtopia()
1353{ 1353{
1354#ifndef DESKTOP_VERSION 1354#ifndef DESKTOP_VERSION
1355 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1355 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1356 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"), 1356 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"),
1357 i18n("Import!"), i18n("Cancel"), 0, 1357 i18n("Import!"), i18n("Cancel"), 0,
1358 0, 1 ); 1358 0, 1 );
1359 if ( result == 0 ) { 1359 if ( result == 0 ) {
1360 QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); 1360 QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
1361 QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); 1361 QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
1362 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; 1362 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
1363 mView->importQtopia( categories, datebook, todolist ); 1363 mView->importQtopia( categories, datebook, todolist );
1364 } 1364 }
1365#else 1365#else
1366 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1366 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1367 i18n("Not supported \non desktop!\n"), 1367 i18n("Not supported \non desktop!\n"),
1368 i18n("Ok"), i18n("Cancel"), 0, 1368 i18n("Ok"), i18n("Cancel"), 0,
1369 0, 1 ); 1369 0, 1 );
1370 1370
1371#endif 1371#endif
1372} 1372}
1373 1373
1374void MainWindow::saveOnClose() 1374void MainWindow::saveOnClose()
1375{ 1375{
1376 KOPrefs *p = KOPrefs::instance(); 1376 KOPrefs *p = KOPrefs::instance();
1377 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); 1377 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
1378 p->mToolBarUp = iconToolBar->x() > width()/2 || 1378 p->mToolBarUp = iconToolBar->x() > width()/2 ||
1379 iconToolBar->y() > height()/2; 1379 iconToolBar->y() > height()/2;
1380 mView->writeSettings(); 1380 mView->writeSettings();
1381 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) 1381 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName()))
1382 save(); 1382 save();
1383} 1383}
1384void MainWindow::slotModifiedChanged( bool changed ) 1384void MainWindow::slotModifiedChanged( bool changed )
1385{ 1385{
1386 if ( mBlockAtStartup ) 1386 if ( mBlockAtStartup )
1387 return; 1387 return;
1388 int msec; 1388 int msec;
1389 // we store the changes after 1 minute, 1389 // we store the changes after 1 minute,
1390 // and for safety reasons after 10 minutes again 1390 // and for safety reasons after 10 minutes again
1391 if ( !mBlockSaveFlag ) 1391 if ( !mBlockSaveFlag )
1392 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1392 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1393 else 1393 else
1394 msec = 1000 * 600; 1394 msec = 1000 * 600;
1395 mSaveTimer.start( msec, true ); // 1 minute 1395 mSaveTimer.start( msec, true ); // 1 minute
1396 qDebug("KO: Saving File in %d secs!", msec/1000); 1396 qDebug("KO: Saving File in %d secs!", msec/1000);
1397 mCalendarModifiedFlag = true; 1397 mCalendarModifiedFlag = true;
1398} 1398}
1399#include <qfileinfo.h> 1399#include <qfileinfo.h>
1400void MainWindow::save() 1400void MainWindow::save()
1401{ 1401{
1402 if ( mBlockSaveFlag ) 1402 if ( mBlockSaveFlag )
1403 return; 1403 return;
1404 bool store = mBlockSaveFlag; 1404 bool store = mBlockSaveFlag;
1405 mBlockSaveFlag = true; 1405 mBlockSaveFlag = true;
1406 if ( mView->checkFileVersion( defaultFileName()) ) { 1406 if ( mView->checkFileVersion( defaultFileName()) ) {
1407 1407
1408 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1408 QTime neededSaveTime = QDateTime::currentDateTime().time();
1409 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1409 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1410 qDebug("KO: Start saving data to file!"); 1410 qDebug("KO: Start saving data to file!");
1411 mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1411 mView->saveCalendar( defaultFileName() ); 1412 mView->saveCalendar( defaultFileName() );
1412 1413
1413 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 1414 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1414 mView->setLoadedFileVersion(QDateTime::currentDateTime()); 1415 mView->watchSavedFile();
1415 qDebug("KO: Needed %d ms for saving.",msNeeded ); 1416 qDebug("KO: Needed %d ms for saving.",msNeeded );
1416 QString savemes; 1417 QString savemes;
1417 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 1418 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
1418 setCaption(savemes); 1419 setCaption(savemes);
1419 } else 1420 } else
1420 setCaption(i18n("Saving cancelled!")); 1421 setCaption(i18n("Saving cancelled!"));
1421 mCalendarModifiedFlag = false; 1422 mCalendarModifiedFlag = false;
1422 mBlockSaveFlag = store; 1423 mBlockSaveFlag = store;
1423} 1424}
1424 1425
1425void MainWindow::keyReleaseEvent ( QKeyEvent * e) 1426void MainWindow::keyReleaseEvent ( QKeyEvent * e)
1426{ 1427{
1427 if ( !e->isAutoRepeat() ) { 1428 if ( !e->isAutoRepeat() ) {
1428 mFlagKeyPressed = false; 1429 mFlagKeyPressed = false;
1429 } 1430 }
1430} 1431}
1431void MainWindow::keyPressEvent ( QKeyEvent * e ) 1432void MainWindow::keyPressEvent ( QKeyEvent * e )
1432{ 1433{
1433 qApp->processEvents(); 1434 qApp->processEvents();
1434 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 1435 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1435 e->ignore(); 1436 e->ignore();
1436 // qDebug(" ignore %d",e->isAutoRepeat() ); 1437 // qDebug(" ignore %d",e->isAutoRepeat() );
1437 return; 1438 return;
1438 } 1439 }
1439 if (! e->isAutoRepeat() ) 1440 if (! e->isAutoRepeat() )
1440 mFlagKeyPressed = true; 1441 mFlagKeyPressed = true;
1441 KOPrefs *p = KOPrefs::instance(); 1442 KOPrefs *p = KOPrefs::instance();
1442 bool showSelectedDates = false; 1443 bool showSelectedDates = false;
1443 int size; 1444 int size;
1444 int pro = 0; 1445 int pro = 0;
1445 //qDebug("MainWindow::keyPressEvent "); 1446 //qDebug("MainWindow::keyPressEvent ");
1446 switch ( e->key() ) { 1447 switch ( e->key() ) {
1447 case Qt::Key_Right: 1448 case Qt::Key_Right:
1448 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1449 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1449 mView->goNextMonth(); 1450 mView->goNextMonth();
1450 else 1451 else
1451 mView->goNext(); 1452 mView->goNext();
1452 showSelectedDates = true; 1453 showSelectedDates = true;
1453 break; 1454 break;
1454 case Qt::Key_Left: 1455 case Qt::Key_Left:
1455 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1456 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1456 mView->goPreviousMonth(); 1457 mView->goPreviousMonth();
1457 else 1458 else
1458 mView->goPrevious(); 1459 mView->goPrevious();
1459 showSelectedDates = true; 1460 showSelectedDates = true;
1460 break; 1461 break;
1461 case Qt::Key_Down: 1462 case Qt::Key_Down:
1462 mView->viewManager()->agendaView()->scrollOneHourDown(); 1463 mView->viewManager()->agendaView()->scrollOneHourDown();
1463 break; 1464 break;
1464 case Qt::Key_Up: 1465 case Qt::Key_Up:
1465 mView->viewManager()->agendaView()->scrollOneHourUp(); 1466 mView->viewManager()->agendaView()->scrollOneHourUp();
1466 break; 1467 break;
1467 case Qt::Key_I: 1468 case Qt::Key_I:
1468 mView->showIncidence(); 1469 mView->showIncidence();
1469 break; 1470 break;
1470 case Qt::Key_Delete: 1471 case Qt::Key_Delete:
1471 case Qt::Key_Backspace: 1472 case Qt::Key_Backspace:
1472 mView->deleteIncidence(); 1473 mView->deleteIncidence();
1473 break; 1474 break;
1474 case Qt::Key_D: 1475 case Qt::Key_D:
1475 mView->viewManager()->showDayView(); 1476 mView->viewManager()->showDayView();
1476 showSelectedDates = true; 1477 showSelectedDates = true;
1477 break; 1478 break;
1478 case Qt::Key_O: 1479 case Qt::Key_O:
1479 mView->toggleFilerEnabled( ); 1480 mView->toggleFilerEnabled( );
1480 break; 1481 break;
1481 case Qt::Key_0: 1482 case Qt::Key_0:
1482 case Qt::Key_1: 1483 case Qt::Key_1:
1483 case Qt::Key_2: 1484 case Qt::Key_2:
1484 case Qt::Key_3: 1485 case Qt::Key_3:
1485 case Qt::Key_4: 1486 case Qt::Key_4:
1486 case Qt::Key_5: 1487 case Qt::Key_5:
1487 case Qt::Key_6: 1488 case Qt::Key_6:
1488 case Qt::Key_7: 1489 case Qt::Key_7:
1489 case Qt::Key_8: 1490 case Qt::Key_8:
1490 case Qt::Key_9: 1491 case Qt::Key_9:
1491 pro = e->key()-48; 1492 pro = e->key()-48;
1492 if ( pro == 0 ) 1493 if ( pro == 0 )
1493 pro = 10; 1494 pro = 10;
1494 if ( e->state() == Qt::ControlButton) 1495 if ( e->state() == Qt::ControlButton)
1495 pro += 10; 1496 pro += 10;
1496 break; 1497 break;
1497 case Qt::Key_M: 1498 case Qt::Key_M:
1498 mView->viewManager()->showMonthView(); 1499 mView->viewManager()->showMonthView();
1499 showSelectedDates = true; 1500 showSelectedDates = true;
1500 break; 1501 break;
1501 case Qt::Key_Insert: 1502 case Qt::Key_Insert:
1502 mView->newEvent(); 1503 mView->newEvent();
1503 break; 1504 break;
1504 case Qt::Key_S : 1505 case Qt::Key_S :
1505 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1506 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1506 mView->newSubTodo(); 1507 mView->newSubTodo();
1507 else 1508 else
1508 mView->dialogManager()->showSearchDialog(); 1509 mView->dialogManager()->showSearchDialog();
1509 break; 1510 break;
1510 case Qt::Key_Y : 1511 case Qt::Key_Y :
1511 case Qt::Key_Z : 1512 case Qt::Key_Z :
1512 mView->viewManager()->showWorkWeekView(); 1513 mView->viewManager()->showWorkWeekView();
1513 showSelectedDates = true; 1514 showSelectedDates = true;
1514 break; 1515 break;
1515 case Qt::Key_U : 1516 case Qt::Key_U :
1516 mView->viewManager()->showWeekView(); 1517 mView->viewManager()->showWeekView();
1517 showSelectedDates = true; 1518 showSelectedDates = true;
1518 break; 1519 break;
1519 case Qt::Key_H : 1520 case Qt::Key_H :
1520 keyBindings(); 1521 keyBindings();
1521 break; 1522 break;
1522 case Qt::Key_W: 1523 case Qt::Key_W:
1523 mView->viewManager()->showWhatsNextView(); 1524 mView->viewManager()->showWhatsNextView();
1524 break; 1525 break;
1525 case Qt::Key_L: 1526 case Qt::Key_L:
1526 mView->viewManager()->showListView(); 1527 mView->viewManager()->showListView();
1527 break; 1528 break;
1528 case Qt::Key_N: 1529 case Qt::Key_N:
1529 mView->viewManager()->showNextXView(); 1530 mView->viewManager()->showNextXView();
1530 showSelectedDates = true; 1531 showSelectedDates = true;
1531 break; 1532 break;
1532 case Qt::Key_V: 1533 case Qt::Key_V:
1533 mView->viewManager()->showTodoView(); 1534 mView->viewManager()->showTodoView();
1534 break; 1535 break;
1535 case Qt::Key_C: 1536 case Qt::Key_C:
1536 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); 1537 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() );
1537 break; 1538 break;
1538 case Qt::Key_P: 1539 case Qt::Key_P:
1539 mView->showDatePicker( ); 1540 mView->showDatePicker( );
1540 break; 1541 break;
1541 case Qt::Key_F: 1542 case Qt::Key_F:
1542 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1543 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1543 mView->editFilters(); 1544 mView->editFilters();
1544 else 1545 else
1545 mView->toggleFilter(); 1546 mView->toggleFilter();
1546 break; 1547 break;
1547 case Qt::Key_X: 1548 case Qt::Key_X:
1548 mView->toggleDateNavigatorWidget(); 1549 mView->toggleDateNavigatorWidget();
1549 break; 1550 break;
1550 case Qt::Key_Space: 1551 case Qt::Key_Space:
1551 mView->toggleExpand(); 1552 mView->toggleExpand();
1552 break; 1553 break;
1553 case Qt::Key_A: 1554 case Qt::Key_A:
1554 mView->toggleAllDaySize(); 1555 mView->toggleAllDaySize();
1555 break; 1556 break;
1556 case Qt::Key_T: 1557 case Qt::Key_T:
1557 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1558 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1558 mView->newTodo(); 1559 mView->newTodo();
1559 else { 1560 else {
1560 mView->goToday(); 1561 mView->goToday();
1561 showSelectedDates = true; 1562 showSelectedDates = true;
1562 } 1563 }
1563 break; 1564 break;
1564 case Qt::Key_J: 1565 case Qt::Key_J:
1565 mView->viewManager()->showJournalView(); 1566 mView->viewManager()->showJournalView();
1566 break; 1567 break;
1567 case Qt::Key_B: 1568 case Qt::Key_B:
1568 mView->editIncidenceDescription();; 1569 mView->editIncidenceDescription();;
1569 break; 1570 break;
1570 // case Qt::Key_Return: 1571 // case Qt::Key_Return:
1571 case Qt::Key_E: 1572 case Qt::Key_E:
1572 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1573 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1573 mView->newEvent(); 1574 mView->newEvent();
1574 else 1575 else
1575 mView->editIncidence(); 1576 mView->editIncidence();
1576 break; 1577 break;
1577 case Qt::Key_Plus: 1578 case Qt::Key_Plus:
1578 size = p->mHourSize +2; 1579 size = p->mHourSize +2;
1579 if ( size <= 18 ) 1580 if ( size <= 18 )
1580 configureAgenda( size ); 1581 configureAgenda( size );
1581 break; 1582 break;
1582 case Qt::Key_Minus: 1583 case Qt::Key_Minus:
1583 size = p->mHourSize - 2; 1584 size = p->mHourSize - 2;
1584 if ( size >= 4 ) 1585 if ( size >= 4 )
1585 configureAgenda( size ); 1586 configureAgenda( size );
1586 break; 1587 break;
1587 1588
1588 1589
1589 default: 1590 default:
1590 e->ignore(); 1591 e->ignore();
1591 } 1592 }
1592 if ( pro > 0 ) { 1593 if ( pro > 0 ) {
1593 mView->selectFilter( pro-1 ); 1594 mView->selectFilter( pro-1 );
1594 } 1595 }
1595 if ( showSelectedDates ) { 1596 if ( showSelectedDates ) {
1596 ;// setCaptionToDates(); 1597 ;// setCaptionToDates();
1597 } 1598 }
1598 1599
1599} 1600}
1600 1601
1601void MainWindow::fillFilterMenu() 1602void MainWindow::fillFilterMenu()
1602{ 1603{
1603 selectFilterMenu->clear(); 1604 selectFilterMenu->clear();
1604 bool disable = false; 1605 bool disable = false;
1605 if ( mView->filterView()->filtersEnabled() ) { 1606 if ( mView->filterView()->filtersEnabled() ) {
1606 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 ); 1607 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 );
1607 } 1608 }
1608 else { 1609 else {
1609 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 ); 1610 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 );
1610 disable = true; 1611 disable = true;
1611 } 1612 }
1612 selectFilterMenu->insertSeparator(); 1613 selectFilterMenu->insertSeparator();
1613 QPtrList<CalFilter> fili = mView->filters(); 1614 QPtrList<CalFilter> fili = mView->filters();
1614 CalFilter *curfilter = mView->filterView()->selectedFilter(); 1615 CalFilter *curfilter = mView->filterView()->selectedFilter();
1615 CalFilter *filter = fili.first(); 1616 CalFilter *filter = fili.first();
1616 int iii = 1; 1617 int iii = 1;
1617 while(filter) { 1618 while(filter) {
1618 selectFilterMenu->insertItem( filter->name(), iii ); 1619 selectFilterMenu->insertItem( filter->name(), iii );
1619 if ( filter == curfilter) 1620 if ( filter == curfilter)
1620 selectFilterMenu->setItemChecked( iii, true ); 1621 selectFilterMenu->setItemChecked( iii, true );
1621 if ( disable ) 1622 if ( disable )
1622 selectFilterMenu->setItemEnabled( iii, false ); 1623 selectFilterMenu->setItemEnabled( iii, false );
1623 filter = fili.next(); 1624 filter = fili.next();
1624 ++iii; 1625 ++iii;
1625 } 1626 }
1626} 1627}
1627void MainWindow::selectFilter( int fil ) 1628void MainWindow::selectFilter( int fil )
1628{ 1629{
1629 if ( fil == 0 ) { 1630 if ( fil == 0 ) {
1630 mView->toggleFilerEnabled( ); 1631 mView->toggleFilerEnabled( );
1631 } else { 1632 } else {
1632 mView->selectFilter( fil-1 ); 1633 mView->selectFilter( fil-1 );
1633 } 1634 }
1634} 1635}
1635void MainWindow::configureToolBar( int item ) 1636void MainWindow::configureToolBar( int item )
1636{ 1637{
1637 1638
1638 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); 1639 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) );
1639 KOPrefs *p = KOPrefs::instance(); 1640 KOPrefs *p = KOPrefs::instance();
1640 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); 1641 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 );
1641 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); 1642 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 );
1642 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); 1643 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 );
1643 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); 1644 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 );
1644 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); 1645 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 );
1645 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); 1646 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 );
1646 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); 1647 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 );
1647 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); 1648 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 );
1648 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); 1649 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 );
1649 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); 1650 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 );
1650 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); 1651 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 );
1651 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); 1652 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 );
1652 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); 1653 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 );
1653 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); 1654 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 );
1654 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); 1655 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 );
1655 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); 1656 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 );
1656 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); 1657 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 );
1657 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); 1658 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 );
1658 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); 1659 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 );
1659 // initActions(); 1660 // initActions();
1660} 1661}
1661 1662
1662void MainWindow::setCaptionToDates() 1663void MainWindow::setCaptionToDates()
1663{ 1664{
1664 QString selDates; 1665 QString selDates;
1665 selDates = KGlobal::locale()->formatDate(mView->startDate(), true); 1666 selDates = KGlobal::locale()->formatDate(mView->startDate(), true);
1666 if (mView->startDate() < mView->endDate() ) 1667 if (mView->startDate() < mView->endDate() )
1667 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); 1668 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true);
1668 setCaption( i18n("Dates: ") + selDates ); 1669 setCaption( i18n("Dates: ") + selDates );
1669 1670
1670} 1671}
1671// parameter item == 0: reinit 1672// parameter item == 0: reinit
1672void MainWindow::configureAgenda( int item ) 1673void MainWindow::configureAgenda( int item )
1673{ 1674{
1674 1675
1675 KOPrefs *p = KOPrefs::instance(); 1676 KOPrefs *p = KOPrefs::instance();
1676 1677
1677 int i; 1678 int i;
1678 if ( item == 1 ) { 1679 if ( item == 1 ) {
1679 mView->toggleAllDaySize(); 1680 mView->toggleAllDaySize();
1680 return; 1681 return;
1681 } 1682 }
1682 // do not allow 4 for widgets higher than 480 1683 // do not allow 4 for widgets higher than 480
1683 // if ( QApplication::desktop()->height() > 480 ) { 1684 // if ( QApplication::desktop()->height() > 480 ) {
1684// if ( item == 4 ) 1685// if ( item == 4 )
1685// item = 6; 1686// item = 6;
1686// } 1687// }
1687 for ( i = 4; i <= 18; i= i+2 ) 1688 for ( i = 4; i <= 18; i= i+2 )
1688 configureAgendaMenu->setItemChecked( i, false ); 1689 configureAgendaMenu->setItemChecked( i, false );
1689 configureAgendaMenu->setItemChecked( item, true ); 1690 configureAgendaMenu->setItemChecked( item, true );
1690 if ( p->mHourSize == item ) 1691 if ( p->mHourSize == item )
1691 return; 1692 return;
1692 p->mHourSize=item; 1693 p->mHourSize=item;
1693 mView->viewManager()->agendaView()->updateConfig(); 1694 mView->viewManager()->agendaView()->updateConfig();
1694} 1695}
1695 1696
1696void MainWindow::saveCalendar() 1697void MainWindow::saveCalendar()
1697{ 1698{
1698 QString fn = KOPrefs::instance()->mLastSaveFile; 1699 QString fn = KOPrefs::instance()->mLastSaveFile;
1699 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); 1700 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this );
1700 1701
1701 if ( fn == "" ) 1702 if ( fn == "" )
1702 return; 1703 return;
1703 QFileInfo info; 1704 QFileInfo info;
1704 info.setFile( fn ); 1705 info.setFile( fn );
1705 QString mes; 1706 QString mes;
1706 bool createbup = true; 1707 bool createbup = true;
1707 if ( info. exists() ) { 1708 if ( info. exists() ) {
1708 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; 1709 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ;
1709 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1710 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1710 i18n("Overwrite!"), i18n("Cancel"), 0, 1711 i18n("Overwrite!"), i18n("Cancel"), 0,
1711 0, 1 ); 1712 0, 1 );
1712 if ( result != 0 ) { 1713 if ( result != 0 ) {
1713 createbup = false; 1714 createbup = false;
1714 } 1715 }
1715 } 1716 }
1716 if ( createbup ) { 1717 if ( createbup ) {
1717 mView->saveCalendar( fn ); 1718 mView->saveCalendar( fn );
1718 mes = i18n("KO/Pi:Saved %1").arg(fn); 1719 mes = i18n("KO/Pi:Saved %1").arg(fn);
1719 KOPrefs::instance()->mLastSaveFile = fn; 1720 KOPrefs::instance()->mLastSaveFile = fn;
1720 setCaption(mes); 1721 setCaption(mes);
1721 } 1722 }
1722} 1723}
1723void MainWindow::loadCalendar() 1724void MainWindow::loadCalendar()
1724{ 1725{
1725 1726
1726 QString fn = KOPrefs::instance()->mLastLoadFile; 1727 QString fn = KOPrefs::instance()->mLastLoadFile;
1727 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); 1728 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this );
1728 1729
1729 if ( fn == "" ) 1730 if ( fn == "" )
1730 return; 1731 return;
1731 QFileInfo info; 1732 QFileInfo info;
1732 info.setFile( fn ); 1733 info.setFile( fn );
1733 QString mess; 1734 QString mess;
1734 bool loadbup = true; 1735 bool loadbup = true;
1735 if ( info. exists() ) { 1736 if ( info. exists() ) {
1736 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1737 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1737 int result = QMessageBox::warning( this, "KO/Pi: Warning!", 1738 int result = QMessageBox::warning( this, "KO/Pi: Warning!",
1738 mess, 1739 mess,
1739 i18n("Load!"), i18n("Cancel"), 0, 1740 i18n("Load!"), i18n("Cancel"), 0,
1740 0, 1 ); 1741 0, 1 );
1741 if ( result != 0 ) { 1742 if ( result != 0 ) {
1742 loadbup = false; 1743 loadbup = false;
1743 } 1744 }
1744 } else { 1745 } else {
1745 QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1746 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1746 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, 1747 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0,
1747 0, 1 ); 1748 0, 1 );
1748 1749
1749 return; 1750 return;
1750 } 1751 }
1751 if ( loadbup ) { 1752 if ( loadbup ) {
1752 mView->openCalendar( fn ); 1753 mView->openCalendar( fn );
1753 KOPrefs::instance()->mLastLoadFile = fn; 1754 KOPrefs::instance()->mLastLoadFile = fn;
1754 mess = i18n("KO/Pi:Loaded %1").arg(fn) ; 1755 mess = i18n("KO/Pi:Loaded %1").arg(fn) ;
1755 setCaption(mess); 1756 setCaption(mess);
1756 } 1757 }
1757 1758
1758} 1759}
1759void MainWindow::quickImportIcal() 1760void MainWindow::quickImportIcal()
1760{ 1761{
1761 importFile( KOPrefs::instance()->mLastImportFile, false ); 1762 importFile( KOPrefs::instance()->mLastImportFile, false );
1762} 1763}
1763void MainWindow::importFile( QString fn, bool quick ) 1764void MainWindow::importFile( QString fn, bool quick )
1764{ 1765{
1765 QFileInfo info; 1766 QFileInfo info;
1766 info.setFile( fn ); 1767 info.setFile( fn );
1767 QString mess; 1768 QString mess;
1768 bool loadbup = true; 1769 bool loadbup = true;
1769 if ( !info. exists() ) { 1770 if ( !info. exists() ) {
1770 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); 1771 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30));
1771 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1772 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1772 mess ); 1773 mess );
1773 return; 1774 return;
1774 } 1775 }
1775 int result = 0; 1776 int result = 0;
1776 if ( !quick ) { 1777 if ( !quick ) {
1777 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 )); 1778 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 ));
1778 result = QMessageBox::warning( this, "KO/Pi: Warning!", 1779 result = QMessageBox::warning( this, "KO/Pi: Warning!",
1779 mess, 1780 mess,
1780 "Import", "Cancel", 0, 1781 "Import", "Cancel", 0,
1781 0, 1 ); 1782 0, 1 );
1782 } 1783 }
1783 if ( result == 0 ) { 1784 if ( result == 0 ) {
1784 if ( mView->openCalendar( fn, true )) { 1785 if ( mView->openCalendar( fn, true )) {
1785 KOPrefs::instance()->mLastImportFile = fn; 1786 KOPrefs::instance()->mLastImportFile = fn;
1786 setCaption(i18n("Imported file successfully")); 1787 setCaption(i18n("Imported file successfully"));
1787 } else { 1788 } else {
1788 setCaption(i18n("Error importing file")); 1789 setCaption(i18n("Error importing file"));
1789 } 1790 }
1790 } 1791 }
1791} 1792}
1792 1793
1793void MainWindow::importIcal() 1794void MainWindow::importIcal()
1794{ 1795{
1795 1796
1796 QString fn =KOPrefs::instance()->mLastImportFile; 1797 QString fn =KOPrefs::instance()->mLastImportFile;
1797 1798
1798 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); 1799 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this );
1799 if ( fn == "" ) 1800 if ( fn == "" )
1800 return; 1801 return;
1801 importFile( fn, true ); 1802 importFile( fn, true );
1802 1803
1803} 1804}
1804 1805
1805void MainWindow::exportVCalendar() 1806void MainWindow::exportVCalendar()
1806{ 1807{
1807 QString fn = KOPrefs::instance()->mLastVcalFile; 1808 QString fn = KOPrefs::instance()->mLastVcalFile;
1808 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); 1809 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this );
1809 if ( fn == "" ) 1810 if ( fn == "" )
1810 return; 1811 return;
1811 QFileInfo info; 1812 QFileInfo info;
1812 info.setFile( fn ); 1813 info.setFile( fn );
1813 QString mes; 1814 QString mes;
1814 bool createbup = true; 1815 bool createbup = true;
1815 if ( info. exists() ) { 1816 if ( info. exists() ) {
1816 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 1817 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
1817 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1818 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1818 i18n("Overwrite!"), i18n("Cancel"), 0, 1819 i18n("Overwrite!"), i18n("Cancel"), 0,
1819 0, 1 ); 1820 0, 1 );
1820 if ( result != 0 ) { 1821 if ( result != 0 ) {
1821 createbup = false; 1822 createbup = false;
1822 } 1823 }
1823 } 1824 }
1824 if ( createbup ) { 1825 if ( createbup ) {
1825 if ( mView->exportVCalendar( fn ) ) { 1826 if ( mView->exportVCalendar( fn ) ) {
1826 KOPrefs::instance()->mLastVcalFile = fn; 1827 KOPrefs::instance()->mLastVcalFile = fn;
1827 if ( fn.length() > 20 ) 1828 if ( fn.length() > 20 )
1828 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; 1829 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ;
1829 else 1830 else
1830 mes = i18n("KO/Pi:Exported to %1").arg(fn ); 1831 mes = i18n("KO/Pi:Exported to %1").arg(fn );
1831 setCaption(mes); 1832 setCaption(mes);
1832 } 1833 }
1833 } 1834 }
1834 1835
1835} 1836}
1836#include <qpushbutton.h> 1837#include <qpushbutton.h>
1837QString MainWindow::getPassword( ) 1838QString MainWindow::getPassword( )
1838{ 1839{
1839 QString retfile = ""; 1840 QString retfile = "";
1840 QDialog dia ( this, "input-dialog", true ); 1841 QDialog dia ( this, "input-dialog", true );
1841 QLineEdit lab ( &dia ); 1842 QLineEdit lab ( &dia );
1842 lab.setEchoMode( QLineEdit::Password ); 1843 lab.setEchoMode( QLineEdit::Password );
1843 QVBoxLayout lay( &dia ); 1844 QVBoxLayout lay( &dia );
1844 lay.setMargin(7); 1845 lay.setMargin(7);
1845 lay.setSpacing(7); 1846 lay.setSpacing(7);
1846 lay.addWidget( &lab); 1847 lay.addWidget( &lab);
1847 dia.setFixedSize( 230,50 ); 1848 dia.setFixedSize( 230,50 );
1848 dia.setCaption( i18n("Enter password") ); 1849 dia.setCaption( i18n("Enter password") );
1849 QPushButton pb ( "OK", &dia); 1850 QPushButton pb ( "OK", &dia);
1850 lay.addWidget( &pb ); 1851 lay.addWidget( &pb );
1851 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 1852 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
1852 dia.show(); 1853 dia.show();
1853 int res = dia.exec(); 1854 int res = dia.exec();
1854 if ( res ) 1855 if ( res )
1855 retfile = lab.text(); 1856 retfile = lab.text();
1856 dia.hide(); 1857 dia.hide();
1857 qApp->processEvents(); 1858 qApp->processEvents();
1858 return retfile; 1859 return retfile;
1859 1860
1860} 1861}
1861 1862
1862void MainWindow::syncLocalFile() 1863void MainWindow::syncLocalFile()
1863{ 1864{
1864 1865
1865 QString fn =KOPrefs::instance()->mLastSyncedLocalFile; 1866 QString fn =KOPrefs::instance()->mLastSyncedLocalFile;
1866 1867
1867 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); 1868 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this );
1868 if ( fn == "" ) 1869 if ( fn == "" )
1869 return; 1870 return;
1870 //mView->setSyncDevice("local-file" ); 1871 //mView->setSyncDevice("local-file" );
1871 if ( syncWithFile( fn, false ) ) { 1872 if ( syncWithFile( fn, false ) ) {
1872 // Event* e = mView->getLastSyncEvent(); 1873 // Event* e = mView->getLastSyncEvent();
1873// e->setReadOnly( false ); 1874// e->setReadOnly( false );
1874// e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); 1875// e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile);
1875// e->setReadOnly( true ); 1876// e->setReadOnly( true );
1876 } 1877 }
1877 1878
1878} 1879}
1879 1880
1880bool MainWindow::syncWithFile( QString fn , bool quick ) 1881bool MainWindow::syncWithFile( QString fn , bool quick )
1881{ 1882{
1882 bool ret = false; 1883 bool ret = false;
1883 QFileInfo info; 1884 QFileInfo info;
1884 info.setFile( fn ); 1885 info.setFile( fn );
1885 QString mess; 1886 QString mess;
1886 bool loadbup = true; 1887 bool loadbup = true;
1887 if ( !info. exists() ) { 1888 if ( !info. exists() ) {
1888 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 1889 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
1889 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1890 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1890 mess ); 1891 mess );
1891 return ret; 1892 return ret;
1892 } 1893 }
1893 int result = 0; 1894 int result = 0;
1894 if ( !quick ) { 1895 if ( !quick ) {
1895 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1896 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1896 result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1897 result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1897 mess, 1898 mess,
1898 i18n("Sync"), i18n("Cancel"), 0, 1899 i18n("Sync"), i18n("Cancel"), 0,
1899 0, 1 ); 1900 0, 1 );
1900 if ( result ) 1901 if ( result )
1901 return false; 1902 return false;
1902 } 1903 }
1903 if ( KOPrefs::instance()->mAskForPreferences ) 1904 if ( KOPrefs::instance()->mAskForPreferences )
1904 mView->edit_sync_options(); 1905 mView->edit_sync_options();
1905 if ( result == 0 ) { 1906 if ( result == 0 ) {
1906 //qDebug("Now sycing ... "); 1907 //qDebug("Now sycing ... ");
1907 if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) ) 1908 if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) )
1908 setCaption( i18n("Synchronization successful") ); 1909 setCaption( i18n("Synchronization successful") );
1909 else 1910 else
1910 setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); 1911 setCaption( i18n("Sync cancelled or failed. Nothing synced.") );
1911 if ( ! quick ) 1912 if ( ! quick )
1912 KOPrefs::instance()->mLastSyncedLocalFile = fn; 1913 KOPrefs::instance()->mLastSyncedLocalFile = fn;
1913 slotModifiedChanged( true ); 1914 slotModifiedChanged( true );
1914 } 1915 }
1915 return ret; 1916 return ret;
1916} 1917}
1917void MainWindow::quickSyncLocalFile() 1918void MainWindow::quickSyncLocalFile()
1918{ 1919{
1919 //mView->setSyncDevice("local-file" ); 1920 //mView->setSyncDevice("local-file" );
1920 //qDebug("quickSyncLocalFile() "); 1921 //qDebug("quickSyncLocalFile() ");
1921 if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) { 1922 if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) {
1922 // Event* e = mView->getLastSyncEvent(); 1923 // Event* e = mView->getLastSyncEvent();
1923// e->setReadOnly( false ); 1924// e->setReadOnly( false );
1924// e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); 1925// e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile);
1925// e->setReadOnly( true ); 1926// e->setReadOnly( true );
1926 1927
1927 } 1928 }
1928} 1929}
1929 1930
1930void MainWindow::confSync() 1931void MainWindow::confSync()
1931{ 1932{
1932 mView->confSync(); 1933 mView->confSync();
1933 fillSyncMenu(); 1934 fillSyncMenu();
1934} 1935}
1935void MainWindow::syncRemote( KSyncProfile* prof, bool ask) 1936void MainWindow::syncRemote( KSyncProfile* prof, bool ask)
1936{ 1937{
1937 QString question; 1938 QString question;
1938 if ( ask ) { 1939 if ( ask ) {
1939 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; 1940 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
1940 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 1941 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
1941 question, 1942 question,
1942 i18n("Yes"), i18n("No"), 1943 i18n("Yes"), i18n("No"),
1943 0, 0 ) != 0 ) 1944 0, 0 ) != 0 )
1944 return; 1945 return;
1945 } 1946 }
1946 QString command = prof->getPreSyncCommand(); 1947 QString command = prof->getPreSyncCommand();
1947 int fi; 1948 int fi;
1948 if ( (fi = command.find("$PWD$")) > 0 ) { 1949 if ( (fi = command.find("$PWD$")) > 0 ) {
1949 QString pwd = getPassword(); 1950 QString pwd = getPassword();
1950 command = command.left( fi )+ pwd + command.mid( fi+5 ); 1951 command = command.left( fi )+ pwd + command.mid( fi+5 );
1951 1952
1952 } 1953 }
1953 int maxlen = 30; 1954 int maxlen = 30;
1954 if ( QApplication::desktop()->width() > 320 ) 1955 if ( QApplication::desktop()->width() > 320 )
1955 maxlen += 25; 1956 maxlen += 25;
1956 setCaption ( i18n( "Copy remote file to local machine..." ) ); 1957 setCaption ( i18n( "Copy remote file to local machine..." ) );
1957 int fileSize = 0; 1958 int fileSize = 0;
1958 int result = system ( command ); 1959 int result = system ( command );
1959 // 0 : okay 1960 // 0 : okay
1960 // 256: no such file or dir 1961 // 256: no such file or dir
1961 // 1962 //
1962 qDebug("KO: Remote copy result(0 = okay): %d ",result ); 1963 qDebug("KO: Remote copy result(0 = okay): %d ",result );
1963 if ( result != 0 ) { 1964 if ( result != 0 ) {
1964 int len = maxlen; 1965 int len = maxlen;
1965 while ( len < command.length() ) { 1966 while ( len < command.length() ) {
1966 command.insert( len , "\n" ); 1967 command.insert( len , "\n" );
1967 len += maxlen +2; 1968 len += maxlen +2;
1968 } 1969 }
1969 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) ; 1970 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) ;
1970 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), 1971 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
1971 question, 1972 question,
1972 i18n("Okay!")) ; 1973 i18n("Okay!")) ;
1973 setCaption ("KO/Pi"); 1974 setCaption ("KO/Pi");
1974 return; 1975 return;
1975 } 1976 }
1976 setCaption ( i18n( "Copying succeed." ) ); 1977 setCaption ( i18n( "Copying succeed." ) );
1977 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); 1978 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
1978 if ( syncWithFile( prof->getLocalTempFile(), true ) ) { 1979 if ( syncWithFile( prof->getLocalTempFile(), true ) ) {
1979// Event* e = mView->getLastSyncEvent(); 1980// Event* e = mView->getLastSyncEvent();
1980// e->setReadOnly( false ); 1981// e->setReadOnly( false );
1981// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 1982// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
1982// e->setReadOnly( true ); 1983// e->setReadOnly( true );
1983 if ( KOPrefs::instance()->mWriteBackFile ) { 1984 if ( KOPrefs::instance()->mWriteBackFile ) {
1984 command = prof->getPostSyncCommand(); 1985 command = prof->getPostSyncCommand();
1985 int fi; 1986 int fi;
1986 if ( (fi = command.find("$PWD$")) > 0 ) { 1987 if ( (fi = command.find("$PWD$")) > 0 ) {
1987 QString pwd = getPassword(); 1988 QString pwd = getPassword();
1988 command = command.left( fi )+ pwd + command.mid( fi+5 ); 1989 command = command.left( fi )+ pwd + command.mid( fi+5 );
1989 1990
1990 } 1991 }
1991 setCaption ( i18n( "Writing back file ..." ) ); 1992 setCaption ( i18n( "Writing back file ..." ) );
1992 result = system ( command ); 1993 result = system ( command );
1993 qDebug("KO: Writing back file result: %d ", result); 1994 qDebug("KO: Writing back file result: %d ", result);
1994 if ( result != 0 ) { 1995 if ( result != 0 ) {
1995 setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); 1996 setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
1996 return; 1997 return;
1997 } else { 1998 } else {
1998 setCaption ( i18n( "Syncronization sucessfully completed" ) ); 1999 setCaption ( i18n( "Syncronization sucessfully completed" ) );
1999 } 2000 }
2000 } 2001 }
2001 } 2002 }
2002 return; 2003 return;
2003} 2004}
2004void MainWindow::syncSSH() 2005void MainWindow::syncSSH()
2005{ 2006{
2006 // not used anymore 2007 // not used anymore
2007 QTime timer; 2008 QTime timer;
2008 timer.start(); 2009 timer.start();
2009 //qDebug("MainWindow::syncssh() "); 2010 //qDebug("MainWindow::syncssh() ");
2010 KOPrefs *p = KOPrefs::instance(); 2011 KOPrefs *p = KOPrefs::instance();
2011 QString localFile = p->mLocalTempFile; 2012 QString localFile = p->mLocalTempFile;
2012 QString remoteIP = p->mRemoteIP; 2013 QString remoteIP = p->mRemoteIP;
2013 QString remoteUser = p->mRemoteUser; 2014 QString remoteUser = p->mRemoteUser;
2014 QString remoteFile = p->mRemoteFile; 2015 QString remoteFile = p->mRemoteFile;
2015 if ( p->mUsePassWd && p->mRemotePassWd.length() > 0 ) 2016 if ( p->mUsePassWd && p->mRemotePassWd.length() > 0 )
2016 remoteUser += ":" + p->mRemotePassWd; 2017 remoteUser += ":" + p->mRemotePassWd;
2017 2018
2018 QString question = i18n("Do you really want\nto remote sync?\n \n") + 2019 QString question = i18n("Do you really want\nto remote sync?\n \n") +
2019 i18n("IP: " ) +remoteIP +"\n" + 2020 i18n("IP: " ) +remoteIP +"\n" +
2020 i18n("User: " ) + remoteUser +"\n" ; 2021 i18n("User: " ) + remoteUser +"\n" ;
2021 int maxlen = 30; 2022 int maxlen = 30;
2022 if ( QApplication::desktop()->width() > 320 ) 2023 if ( QApplication::desktop()->width() > 320 )
2023 maxlen += 25; 2024 maxlen += 25;
2024 if ( remoteFile.length() > maxlen ) 2025 if ( remoteFile.length() > maxlen )
2025 question += i18n("Remote file:\n..." ) + remoteFile.right(maxlen) +"\n"; 2026 question += i18n("Remote file:\n..." ) + remoteFile.right(maxlen) +"\n";
2026 else 2027 else
2027 question += i18n("Remote file:\n " ) + remoteFile +"\n"; 2028 question += i18n("Remote file:\n " ) + remoteFile +"\n";
2028 if ( localFile.length() > maxlen ) 2029 if ( localFile.length() > maxlen )
2029 question += i18n("Local temp file:\n..." ) + localFile.right(maxlen) +"\n"; 2030 question += i18n("Local temp file:\n..." ) + localFile.right(maxlen) +"\n";
2030 else 2031 else
2031 question += i18n("Local temp file:\n " ) + localFile +"\n"; 2032 question += i18n("Local temp file:\n " ) + localFile +"\n";
2032 2033
2033 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 2034 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
2034 question, 2035 question,
2035 i18n("Yes"), i18n("No"), 2036 i18n("Yes"), i18n("No"),
2036 0, 0 ) != 0 ) 2037 0, 0 ) != 0 )
2037 return; 2038 return;
2038 // if ( !p->mUsePassWd ) { 2039 // if ( !p->mUsePassWd ) {
2039 // QString pass = getPassword(); 2040 // QString pass = getPassword();
2040 // if ( pass.length() > 0 ) 2041 // if ( pass.length() > 0 )
2041 // remoteUser += ":" + pass; 2042 // remoteUser += ":" + pass;
2042 // } 2043 // }
2043 QString command = "scp " + remoteUser + "@" + remoteIP +":" + remoteFile +" " +localFile; 2044 QString command = "scp " + remoteUser + "@" + remoteIP +":" + remoteFile +" " +localFile;
2044 setCaption ( i18n( "Copy remote file to local machine..." ) ); 2045 setCaption ( i18n( "Copy remote file to local machine..." ) );
2045 int fileSize = 0; 2046 int fileSize = 0;
2046 int result = system ( command ); 2047 int result = system ( command );
2047 // 0 : okay 2048 // 0 : okay
2048 // 256: no such file or dir 2049 // 256: no such file or dir
2049 // 2050 //
2050 qDebug("KO: Remote copy result(0 = okay): %d ",result ); 2051 qDebug("KO: Remote copy result(0 = okay): %d ",result );
2051 if ( result != 0 ) { 2052 if ( result != 0 ) {
2052 int len = maxlen; 2053 int len = maxlen;
2053 while ( len < command.length() ) { 2054 while ( len < command.length() ) {
2054 command.insert( len , "\n" ); 2055 command.insert( len , "\n" );
2055 len += maxlen +2; 2056 len += maxlen +2;
2056 } 2057 }
2057 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) ; 2058 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) ;
2058 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), 2059 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
2059 question, 2060 question,
2060 i18n("Okay!")) ; 2061 i18n("Okay!")) ;
2061 setCaption ("KO/Pi"); 2062 setCaption ("KO/Pi");
2062 return; 2063 return;
2063 } 2064 }
2064 2065
2065 2066
2066 setCaption ( i18n( "Copying succeed." ) ); 2067 setCaption ( i18n( "Copying succeed." ) );
2067 //mView->setSyncDevice("ssh-scp" ); 2068 //mView->setSyncDevice("ssh-scp" );
2068 if ( syncWithFile(localFile , true ) ) { 2069 if ( syncWithFile(localFile , true ) ) {
2069// Event* e = mView->getLastSyncEvent(); 2070// Event* e = mView->getLastSyncEvent();
2070// e->setReadOnly( false ); 2071// e->setReadOnly( false );
2071// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 2072// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
2072// e->setReadOnly( true ); 2073// e->setReadOnly( true );
2073 if ( KOPrefs::instance()->mWriteBackFile ) { 2074 if ( KOPrefs::instance()->mWriteBackFile ) {
2074 command = "scp " + localFile +" " +remoteUser + "@" + remoteIP +":" + remoteFile ; 2075 command = "scp " + localFile +" " +remoteUser + "@" + remoteIP +":" + remoteFile ;
2075 setCaption ( i18n( "Writing back file ..." ) ); 2076 setCaption ( i18n( "Writing back file ..." ) );
2076 result = system ( command ); 2077 result = system ( command );
2077 if ( result != 0 ) { 2078 if ( result != 0 ) {
2078 int len = maxlen; 2079 int len = maxlen;
2079 while ( len < command.length() ) { 2080 while ( len < command.length() ) {
2080 command.insert( len , "\n" ); 2081 command.insert( len , "\n" );
2081 len += maxlen +2; 2082 len += maxlen +2;
2082 } 2083 }
2083 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) ; 2084 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) ;
2084 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), 2085 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
2085 question, 2086 question,
2086 i18n("Okay!")) ; 2087 i18n("Okay!")) ;
2087 setCaption ("KO/Pi"); 2088 setCaption ("KO/Pi");
2088 return; 2089 return;
2089 } else { 2090 } else {
2090 setCaption ( i18n( "Syncronization sucessfully completed" ) ); 2091 setCaption ( i18n( "Syncronization sucessfully completed" ) );
2091 } 2092 }
2092 } 2093 }
2093 } 2094 }
2094 return; 2095 return;
2095#if 0 2096#if 0
2096 system ("scp zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics /home/polo/Applications/korganizer/z_sync.ics"); 2097 system ("scp zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics /home/polo/Applications/korganizer/z_sync.ics");
2097 while ( timer.elapsed() < 5000 ) 2098 while ( timer.elapsed() < 5000 )
2098 qApp->processEvents(); 2099 qApp->processEvents();
2099 2100
2100 qDebug("MainWindow::merging) "); 2101 qDebug("MainWindow::merging) ");
2101 mView->syncCalendar( "/home/polo/Applications/korganizer/z_sync.ics", 0 ); 2102 mView->syncCalendar( "/home/polo/Applications/korganizer/z_sync.ics", 0 );
2102 while ( mBlockSaveFlag ) 2103 while ( mBlockSaveFlag )
2103 qApp->processEvents(); 2104 qApp->processEvents();
2104 save(); 2105 save();
2105 system ("scp /home/polo/Applications/korganizer/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics"); 2106 system ("scp /home/polo/Applications/korganizer/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics");
2106#endif 2107#endif
2107 2108
2108} 2109}
2109 2110
2110 2111
2111void MainWindow::syncSharp() 2112void MainWindow::syncSharp()
2112{ 2113{
2113 if ( mCalendarModifiedFlag ) 2114 if ( mCalendarModifiedFlag )
2114 save(); 2115 save();
2115 mView->syncSharp(); 2116 mView->syncSharp();
2116 slotModifiedChanged( true ); 2117 slotModifiedChanged( true );
2117 2118
2118} 2119}
2119void MainWindow::syncPhone() 2120void MainWindow::syncPhone()
2120{ 2121{
2121 if ( mCalendarModifiedFlag ) 2122 if ( mCalendarModifiedFlag )
2122 save(); 2123 save();
2123 mView->syncPhone(); 2124 mView->syncPhone();
2124 slotModifiedChanged( true ); 2125 slotModifiedChanged( true );
2125 2126
2126} 2127}
2127 2128
2128void MainWindow::printSel( ) 2129void MainWindow::printSel( )
2129{ 2130{
2130 mView->viewManager()->agendaView()->agenda()->printSelection(); 2131 mView->viewManager()->agendaView()->agenda()->printSelection();
2131} 2132}
2132 2133
2133void MainWindow::printCal() 2134void MainWindow::printCal()
2134{ 2135{
2135 mView->print();//mCp->showDialog(); 2136 mView->print();//mCp->showDialog();
2136} 2137}