summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp76
-rw-r--r--korganizer/calendarview.h5
-rw-r--r--korganizer/koprefs.cpp27
-rw-r--r--korganizer/koprefs.h1
-rw-r--r--korganizer/mainwindow.cpp3
5 files changed, 72 insertions, 40 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index cfc6b10..9160e1d 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,3480 +1,3506 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Requires the Qt and KDE widget libraries, available at no cost at 4 Requires the Qt and KDE widget libraries, available at no cost at
5 http://www.troll.no and http://www.kde.org respectively 5 http://www.troll.no and http://www.kde.org respectively
6 6
7 Copyright (c) 1997, 1998, 1999 7 Copyright (c) 1997, 1998, 1999
8 Preston Brown (preston.brown@yale.edu) 8 Preston Brown (preston.brown@yale.edu)
9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) 9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl)
10 Ian Dawes (iadawes@globalserve.net) 10 Ian Dawes (iadawes@globalserve.net)
11 Laszlo Boloni (boloni@cs.purdue.edu) 11 Laszlo Boloni (boloni@cs.purdue.edu)
12 12
13 Copyright (c) 2000, 2001, 2002 13 Copyright (c) 2000, 2001, 2002
14 Cornelius Schumacher <schumacher@kde.org> 14 Cornelius Schumacher <schumacher@kde.org>
15 15
16 This program is free software; you can redistribute it and/or modify 16 This program is free software; you can redistribute it and/or modify
17 it under the terms of the GNU General Public License as published by 17 it under the terms of the GNU General Public License as published by
18 the Free Software Foundation; either version 2 of the License, or 18 the Free Software Foundation; either version 2 of the License, or
19 (at your option) any later version. 19 (at your option) any later version.
20 20
21 This program is distributed in the hope that it will be useful, 21 This program is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of 22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
24 GNU General Public License for more details. 24 GNU General Public License for more details.
25 25
26 You should have received a copy of the GNU General Public License 26 You should have received a copy of the GNU General Public License
27 along with this program; if not, write to the Free Software 27 along with this program; if not, write to the Free Software
28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29*/ 29*/
30 30
31#include <stdlib.h> 31#include <stdlib.h>
32 32
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qradiobutton.h> 34#include <qradiobutton.h>
35#include <qbuttongroup.h> 35#include <qbuttongroup.h>
36#include <qlayout.h> 36#include <qlayout.h>
37#include <qclipboard.h> 37#include <qclipboard.h>
38#include <qcursor.h> 38#include <qcursor.h>
39#include <qmessagebox.h> 39#include <qmessagebox.h>
40#include <qprogressbar.h> 40#include <qprogressbar.h>
41#include <qmultilineedit.h> 41#include <qmultilineedit.h>
42#include <qtimer.h> 42#include <qtimer.h>
43#include <qwidgetstack.h> 43#include <qwidgetstack.h>
44#include <qptrlist.h> 44#include <qptrlist.h>
45#include <qregexp.h> 45#include <qregexp.h>
46#include <qgroupbox.h> 46#include <qgroupbox.h>
47#include <qfile.h> 47#include <qfile.h>
48#include <qdir.h> 48#include <qdir.h>
49#ifndef KORG_NOSPLITTER 49#ifndef KORG_NOSPLITTER
50#include <qsplitter.h> 50#include <qsplitter.h>
51#endif 51#endif
52 52
53#include <kglobal.h> 53#include <kglobal.h>
54#include <kdebug.h> 54#include <kdebug.h>
55#include <kstandarddirs.h> 55#include <kstandarddirs.h>
56#include <kfiledialog.h> 56#include <kfiledialog.h>
57#include <kmessagebox.h> 57#include <kmessagebox.h>
58#include <knotifyclient.h> 58#include <knotifyclient.h>
59#include <kconfig.h> 59#include <kconfig.h>
60 60
61#include <libkdepim/ksyncprefsdialog.h> 61#include <libkdepim/ksyncprefsdialog.h>
62#include <krun.h> 62#include <krun.h>
63#include <kdirwatch.h> 63#include <kdirwatch.h>
64#include <libkdepim/kdatepicker.h> 64#include <libkdepim/kdatepicker.h>
65#include <libkdepim/ksyncprofile.h> 65#include <libkdepim/ksyncprofile.h>
66 66
67#include <libkcal/vcaldrag.h> 67#include <libkcal/vcaldrag.h>
68#include <libkcal/icaldrag.h> 68#include <libkcal/icaldrag.h>
69#include <libkcal/icalformat.h> 69#include <libkcal/icalformat.h>
70#include <libkcal/vcalformat.h> 70#include <libkcal/vcalformat.h>
71#include <libkcal/scheduler.h> 71#include <libkcal/scheduler.h>
72#include <libkcal/calendarlocal.h> 72#include <libkcal/calendarlocal.h>
73#include <libkcal/journal.h> 73#include <libkcal/journal.h>
74#include <libkcal/calfilter.h> 74#include <libkcal/calfilter.h>
75#include <libkcal/attendee.h> 75#include <libkcal/attendee.h>
76#include <libkcal/dndfactory.h> 76#include <libkcal/dndfactory.h>
77#include <libkcal/freebusy.h> 77#include <libkcal/freebusy.h>
78#include <libkcal/filestorage.h> 78#include <libkcal/filestorage.h>
79#include <libkcal/calendarresources.h> 79#include <libkcal/calendarresources.h>
80#include <libkcal/qtopiaformat.h> 80#include <libkcal/qtopiaformat.h>
81#include "../kalarmd/alarmdialog.h" 81#include "../kalarmd/alarmdialog.h"
82 82
83#ifndef DESKTOP_VERSION 83#ifndef DESKTOP_VERSION
84#include <libkcal/sharpformat.h> 84#include <libkcal/sharpformat.h>
85#endif 85#endif
86#ifndef KORG_NOMAIL 86#ifndef KORG_NOMAIL
87#include "komailclient.h" 87#include "komailclient.h"
88#endif 88#endif
89#ifndef KORG_NOPRINTER 89#ifndef KORG_NOPRINTER
90#include "calprinter.h" 90#include "calprinter.h"
91#endif 91#endif
92#ifndef KORG_NOPLUGINS 92#ifndef KORG_NOPLUGINS
93#include "kocore.h" 93#include "kocore.h"
94#endif 94#endif
95#include "koeventeditor.h" 95#include "koeventeditor.h"
96#include "kotodoeditor.h" 96#include "kotodoeditor.h"
97#include "koprefs.h" 97#include "koprefs.h"
98#include "koeventviewerdialog.h" 98#include "koeventviewerdialog.h"
99#include "publishdialog.h" 99#include "publishdialog.h"
100#include "kofilterview.h" 100#include "kofilterview.h"
101#include "koglobals.h" 101#include "koglobals.h"
102#include "koviewmanager.h" 102#include "koviewmanager.h"
103#include "koagendaview.h" 103#include "koagendaview.h"
104#include "kodialogmanager.h" 104#include "kodialogmanager.h"
105#include "outgoingdialog.h" 105#include "outgoingdialog.h"
106#include "incomingdialog.h" 106#include "incomingdialog.h"
107#include "statusdialog.h" 107#include "statusdialog.h"
108#include "kdatenavigator.h" 108#include "kdatenavigator.h"
109#include "kotodoview.h" 109#include "kotodoview.h"
110#include "datenavigator.h" 110#include "datenavigator.h"
111#include "resourceview.h" 111#include "resourceview.h"
112#include "navigatorbar.h" 112#include "navigatorbar.h"
113#include "searchdialog.h" 113#include "searchdialog.h"
114#include "mainwindow.h" 114#include "mainwindow.h"
115 115
116#include "calendarview.h" 116#include "calendarview.h"
117#ifndef DESKTOP_VERSION 117#ifndef DESKTOP_VERSION
118#include <qtopia/alarmserver.h> 118#include <qtopia/alarmserver.h>
119#endif 119#endif
120#ifndef _WIN32_ 120#ifndef _WIN32_
121#include <stdlib.h> 121#include <stdlib.h>
122#include <stdio.h> 122#include <stdio.h>
123#include <unistd.h> 123#include <unistd.h>
124#else 124#else
125#include <qprocess.h> 125#include <qprocess.h>
126#endif 126#endif
127using namespace KOrg; 127using namespace KOrg;
128using namespace KCal; 128using namespace KCal;
129extern int globalFlagBlockAgenda; 129extern int globalFlagBlockAgenda;
130extern int globalFlagBlockStartup; 130extern int globalFlagBlockStartup;
131 131
132 132
133 133
134class KOBeamPrefs : public QDialog 134class KOBeamPrefs : public QDialog
135{ 135{
136 public: 136 public:
137 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : 137 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) :
138 QDialog( parent, name, true ) 138 QDialog( parent, name, true )
139 { 139 {
140 setCaption( i18n("Beam Options") ); 140 setCaption( i18n("Beam Options") );
141 QVBoxLayout* lay = new QVBoxLayout( this ); 141 QVBoxLayout* lay = new QVBoxLayout( this );
142 lay->setSpacing( 3 ); 142 lay->setSpacing( 3 );
143 lay->setMargin( 3 ); 143 lay->setMargin( 3 );
144 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); 144 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this );
145 lay->addWidget( format ); 145 lay->addWidget( format );
146 format->setExclusive ( true ) ; 146 format->setExclusive ( true ) ;
147 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); 147 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this );
148 lay->addWidget( time ); time->setExclusive ( true ) ; 148 lay->addWidget( time ); time->setExclusive ( true ) ;
149 vcal = new QRadioButton(" vCalendar ", format ); 149 vcal = new QRadioButton(" vCalendar ", format );
150 ical = new QRadioButton(" iCalendar ", format ); 150 ical = new QRadioButton(" iCalendar ", format );
151 vcal->setChecked( true ); 151 vcal->setChecked( true );
152 tz = new QRadioButton(i18n(" With timezone "), time ); 152 tz = new QRadioButton(i18n(" With timezone "), time );
153 local = new QRadioButton(i18n(" Local time "), time ); 153 local = new QRadioButton(i18n(" Local time "), time );
154 tz->setChecked( true ); 154 tz->setChecked( true );
155 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); 155 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this );
156 lay->addWidget( ok ); 156 lay->addWidget( ok );
157 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 157 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
158 lay->addWidget( cancel ); 158 lay->addWidget( cancel );
159 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 159 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
160 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 160 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
161 resize( 200, 200 ); 161 resize( 200, 200 );
162 } 162 }
163 163
164 bool beamVcal() { return vcal->isChecked(); } 164 bool beamVcal() { return vcal->isChecked(); }
165 bool beamLocal() { return local->isChecked(); } 165 bool beamLocal() { return local->isChecked(); }
166private: 166private:
167 QRadioButton* vcal, *ical, *local, *tz; 167 QRadioButton* vcal, *ical, *local, *tz;
168}; 168};
169class KOCatPrefs : public QDialog 169class KOCatPrefs : public QDialog
170{ 170{
171 public: 171 public:
172 KOCatPrefs( QWidget *parent=0, const char *name=0 ) : 172 KOCatPrefs( QWidget *parent=0, const char *name=0 ) :
173 QDialog( parent, name, true ) 173 QDialog( parent, name, true )
174 { 174 {
175 setCaption( i18n("Manage new Categories") ); 175 setCaption( i18n("Manage new Categories") );
176 QVBoxLayout* lay = new QVBoxLayout( this ); 176 QVBoxLayout* lay = new QVBoxLayout( this );
177 lay->setSpacing( 3 ); 177 lay->setSpacing( 3 );
178 lay->setMargin( 3 ); 178 lay->setMargin( 3 );
179 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); 179 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this );
180 lay->addWidget( lab ); 180 lay->addWidget( lab );
181 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 181 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
182 lay->addWidget( format ); 182 lay->addWidget( format );
183 format->setExclusive ( true ) ; 183 format->setExclusive ( true ) ;
184 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 184 addCatBut = new QRadioButton(i18n("Add to category list"), format );
185 new QRadioButton(i18n("Remove from Events/Todos"), format ); 185 new QRadioButton(i18n("Remove from Events/Todos"), format );
186 addCatBut->setChecked( true ); 186 addCatBut->setChecked( true );
187 QPushButton * ok = new QPushButton( i18n("OK"), this ); 187 QPushButton * ok = new QPushButton( i18n("OK"), this );
188 lay->addWidget( ok ); 188 lay->addWidget( ok );
189 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 189 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
190 lay->addWidget( cancel ); 190 lay->addWidget( cancel );
191 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 191 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
192 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 192 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
193 resize( 200, 200 ); 193 resize( 200, 200 );
194 } 194 }
195 195
196 bool addCat() { return addCatBut->isChecked(); } 196 bool addCat() { return addCatBut->isChecked(); }
197private: 197private:
198 QRadioButton* addCatBut; 198 QRadioButton* addCatBut;
199}; 199};
200 200
201 201
202 202
203CalendarView::CalendarView( CalendarResources *calendar, 203CalendarView::CalendarView( CalendarResources *calendar,
204 QWidget *parent, const char *name ) 204 QWidget *parent, const char *name )
205 : CalendarViewBase( parent, name ), 205 : CalendarViewBase( parent, name ),
206 mCalendar( calendar ), 206 mCalendar( calendar ),
207 mResourceManager( calendar->resourceManager() ) 207 mResourceManager( calendar->resourceManager() )
208{ 208{
209 209
210 mEventEditor = 0; 210 mEventEditor = 0;
211 mTodoEditor = 0; 211 mTodoEditor = 0;
212 212
213 init(); 213 init();
214} 214}
215 215
216CalendarView::CalendarView( Calendar *calendar, 216CalendarView::CalendarView( Calendar *calendar,
217 QWidget *parent, const char *name ) 217 QWidget *parent, const char *name )
218 : CalendarViewBase( parent, name ), 218 : CalendarViewBase( parent, name ),
219 mCalendar( calendar ), 219 mCalendar( calendar ),
220 mResourceManager( 0 ) 220 mResourceManager( 0 )
221{ 221{
222 222
223 mEventEditor = 0; 223 mEventEditor = 0;
224 mTodoEditor = 0; 224 mTodoEditor = 0;
225 init();} 225 init();}
226 226
227void CalendarView::init() 227void CalendarView::init()
228{ 228{
229 beamDialog = new KOBeamPrefs(); 229 beamDialog = new KOBeamPrefs();
230 mDatePickerMode = 0; 230 mDatePickerMode = 0;
231 mCurrentSyncDevice = ""; 231 mCurrentSyncDevice = "";
232 writeLocale(); 232 writeLocale();
233 mViewManager = new KOViewManager( this ); 233 mViewManager = new KOViewManager( this );
234 mDialogManager = new KODialogManager( this ); 234 mDialogManager = new KODialogManager( this );
235 mEventViewerDialog = 0; 235 mEventViewerDialog = 0;
236 mModified = false; 236 mModified = false;
237 mReadOnly = false; 237 mReadOnly = false;
238 mSelectedIncidence = 0; 238 mSelectedIncidence = 0;
239 mCalPrinter = 0; 239 mCalPrinter = 0;
240 mFilters.setAutoDelete(true); 240 mFilters.setAutoDelete(true);
241 241
242 mCalendar->registerObserver( this ); 242 mCalendar->registerObserver( this );
243 // TODO: Make sure that view is updated, when calendar is changed. 243 // TODO: Make sure that view is updated, when calendar is changed.
244 244
245 mStorage = new FileStorage( mCalendar ); 245 mStorage = new FileStorage( mCalendar );
246 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 246 mNavigator = new DateNavigator( this, "datevav", mViewManager );
247 247
248 QBoxLayout *topLayout = (QBoxLayout*)layout(); 248 QBoxLayout *topLayout = (QBoxLayout*)layout();
249#ifndef KORG_NOSPLITTER 249#ifndef KORG_NOSPLITTER
250 // create the main layout frames. 250 // create the main layout frames.
251 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 251 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
252 topLayout->addWidget(mPanner); 252 topLayout->addWidget(mPanner);
253 253
254 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 254 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
255 "CalendarView::LeftFrame"); 255 "CalendarView::LeftFrame");
256 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 256 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
257 257
258 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, 258 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE,
259 "CalendarView::DateNavigator", QDate::currentDate() ); 259 "CalendarView::DateNavigator", QDate::currentDate() );
260 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 260 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
261 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 261 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
262 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 262 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
263 263
264#ifdef KORG_NORESOURCEVIEW 264#ifdef KORG_NORESOURCEVIEW
265 mResourceView = 0; 265 mResourceView = 0;
266#else 266#else
267 if ( mResourceManager ) { 267 if ( mResourceManager ) {
268 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 268 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
269 mResourceView->updateView(); 269 mResourceView->updateView();
270 connect( mResourceView, SIGNAL( resourcesChanged() ), 270 connect( mResourceView, SIGNAL( resourcesChanged() ),
271 SLOT( updateView() ) ); 271 SLOT( updateView() ) );
272 } else { 272 } else {
273 mResourceView = 0; 273 mResourceView = 0;
274 } 274 }
275#endif 275#endif
276 QWidget *rightBox = new QWidget( mPanner ); 276 QWidget *rightBox = new QWidget( mPanner );
277 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 277 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
278 278
279 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 279 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
280 rightLayout->addWidget( mNavigatorBar ); 280 rightLayout->addWidget( mNavigatorBar );
281 281
282 mRightFrame = new QWidgetStack( rightBox ); 282 mRightFrame = new QWidgetStack( rightBox );
283 rightLayout->addWidget( mRightFrame, 1 ); 283 rightLayout->addWidget( mRightFrame, 1 );
284 284
285 mLeftFrame = mLeftSplitter; 285 mLeftFrame = mLeftSplitter;
286#else 286#else
287 QWidget *mainBox = new QWidget( this ); 287 QWidget *mainBox = new QWidget( this );
288 QWidget *leftFrame = new QWidget( mainBox ); 288 QWidget *leftFrame = new QWidget( mainBox );
289 289
290 QBoxLayout * mainBoxLayout; 290 QBoxLayout * mainBoxLayout;
291 QBoxLayout * leftFrameLayout; 291 QBoxLayout * leftFrameLayout;
292 if ( KOPrefs::instance()->mVerticalScreen ) { 292 if ( KOPrefs::instance()->mVerticalScreen ) {
293 mainBoxLayout = new QVBoxLayout(mainBox); 293 mainBoxLayout = new QVBoxLayout(mainBox);
294 leftFrameLayout = new QHBoxLayout(leftFrame ); 294 leftFrameLayout = new QHBoxLayout(leftFrame );
295 } else { 295 } else {
296 mainBoxLayout = new QHBoxLayout(mainBox); 296 mainBoxLayout = new QHBoxLayout(mainBox);
297 leftFrameLayout = new QVBoxLayout(leftFrame ); 297 leftFrameLayout = new QVBoxLayout(leftFrame );
298 } 298 }
299 topLayout->addWidget( mainBox ); 299 topLayout->addWidget( mainBox );
300 mainBoxLayout->addWidget (leftFrame); 300 mainBoxLayout->addWidget (leftFrame);
301 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, 301 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE,
302 "CalendarView::DateNavigator", QDate::currentDate()); 302 "CalendarView::DateNavigator", QDate::currentDate());
303 // mDateNavigator->blockSignals( true ); 303 // mDateNavigator->blockSignals( true );
304 leftFrameLayout->addWidget( mDateNavigator ); 304 leftFrameLayout->addWidget( mDateNavigator );
305 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); 305 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView");
306 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolist"); 306 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolist");
307 307
308 if ( QApplication::desktop()->width() < 480 ) { 308 if ( QApplication::desktop()->width() < 480 ) {
309 leftFrameLayout->addWidget(mFilterView); 309 leftFrameLayout->addWidget(mFilterView);
310 leftFrameLayout->addWidget(mTodoList, 2 ); 310 leftFrameLayout->addWidget(mTodoList, 2 );
311 311
312 } else { 312 } else {
313 leftFrameLayout->addWidget(mTodoList,2 ); 313 leftFrameLayout->addWidget(mTodoList,2 );
314 leftFrameLayout->addWidget(mFilterView ); 314 leftFrameLayout->addWidget(mFilterView );
315 } 315 }
316 mFilterView->hide(); 316 mFilterView->hide();
317 QWidget *rightBox = new QWidget( mainBox ); 317 QWidget *rightBox = new QWidget( mainBox );
318 mainBoxLayout->addWidget ( rightBox, 10 ); 318 mainBoxLayout->addWidget ( rightBox, 10 );
319 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 319 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
320 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 320 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
321 mRightFrame = new QWidgetStack( rightBox ); 321 mRightFrame = new QWidgetStack( rightBox );
322 rightLayout->addWidget( mNavigatorBar ); 322 rightLayout->addWidget( mNavigatorBar );
323 rightLayout->addWidget( mRightFrame, 10 ); 323 rightLayout->addWidget( mRightFrame, 10 );
324 324
325 mLeftFrame = leftFrame; 325 mLeftFrame = leftFrame;
326 if ( KOPrefs::instance()->mVerticalScreen ) { 326 if ( KOPrefs::instance()->mVerticalScreen ) {
327 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 327 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
328 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 328 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
329 } else { 329 } else {
330 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 330 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
331 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 331 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
332 } 332 }
333 333
334 //qDebug("Calendarview Size %d %d ", width(), height()); 334 //qDebug("Calendarview Size %d %d ", width(), height());
335#endif 335#endif
336 336
337 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 337 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
338 SLOT( showDates( const KCal::DateList & ) ) ); 338 SLOT( showDates( const KCal::DateList & ) ) );
339 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 339 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
340 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 340 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
341 341
342 connect( mNavigatorBar, SIGNAL( goPrevYear() ), 342 connect( mNavigatorBar, SIGNAL( goPrevYear() ),
343 mNavigator, SLOT( selectPreviousYear() ) ); 343 mNavigator, SLOT( selectPreviousYear() ) );
344 connect( mNavigatorBar, SIGNAL( goNextYear() ), 344 connect( mNavigatorBar, SIGNAL( goNextYear() ),
345 mNavigator, SLOT( selectNextYear() ) ); 345 mNavigator, SLOT( selectNextYear() ) );
346 connect( mNavigatorBar, SIGNAL( goPrevMonth() ), 346 connect( mNavigatorBar, SIGNAL( goPrevMonth() ),
347 mNavigator, SLOT( selectPreviousMonth() ) ); 347 mNavigator, SLOT( selectPreviousMonth() ) );
348 connect( mNavigatorBar, SIGNAL( goNextMonth() ), 348 connect( mNavigatorBar, SIGNAL( goNextMonth() ),
349 mNavigator, SLOT( selectNextMonth() ) ); 349 mNavigator, SLOT( selectNextMonth() ) );
350 350
351 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 351 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
352 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); 352 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) );
353 353
354 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 354 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
355 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 355 mNavigator, SLOT( selectWeek( const QDate & ) ) );
356 356
357 connect( mDateNavigator, SIGNAL( goPrevYear() ), 357 connect( mDateNavigator, SIGNAL( goPrevYear() ),
358 mNavigator, SLOT( selectPreviousYear() ) ); 358 mNavigator, SLOT( selectPreviousYear() ) );
359 connect( mDateNavigator, SIGNAL( goNextYear() ), 359 connect( mDateNavigator, SIGNAL( goNextYear() ),
360 mNavigator, SLOT( selectNextYear() ) ); 360 mNavigator, SLOT( selectNextYear() ) );
361 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 361 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
362 mNavigator, SLOT( selectPreviousMonth() ) ); 362 mNavigator, SLOT( selectPreviousMonth() ) );
363 connect( mDateNavigator, SIGNAL( goNextMonth() ), 363 connect( mDateNavigator, SIGNAL( goNextMonth() ),
364 mNavigator, SLOT( selectNextMonth() ) ); 364 mNavigator, SLOT( selectNextMonth() ) );
365 365
366 connect( mDateNavigator, SIGNAL( goPrevious() ), 366 connect( mDateNavigator, SIGNAL( goPrevious() ),
367 mNavigator, SLOT( selectPrevious() ) ); 367 mNavigator, SLOT( selectPrevious() ) );
368 connect( mDateNavigator, SIGNAL( goNext() ), 368 connect( mDateNavigator, SIGNAL( goNext() ),
369 mNavigator, SLOT( selectNext() ) ); 369 mNavigator, SLOT( selectNext() ) );
370 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 370 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
371 mNavigator, SLOT( slotMonthSelect( int ) ) ); 371 mNavigator, SLOT( slotMonthSelect( int ) ) );
372 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), 372 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ),
373 mNavigator, SLOT( slotMonthSelect( int ) ) ); 373 mNavigator, SLOT( slotMonthSelect( int ) ) );
374 374
375 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 375 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
376 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 376 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
377 377
378 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), 378 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ),
379 SLOT( eventAdded( Event *) ) ); 379 SLOT( eventAdded( Event *) ) );
380 380
381 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 381 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
382 382
383 connect( this, SIGNAL( configChanged() ), 383 connect( this, SIGNAL( configChanged() ),
384 mDateNavigator, SLOT( updateConfig() ) ); 384 mDateNavigator, SLOT( updateConfig() ) );
385 385
386 connect( mTodoList, SIGNAL( newTodoSignal() ), 386 connect( mTodoList, SIGNAL( newTodoSignal() ),
387 SLOT( newTodo() ) ); 387 SLOT( newTodo() ) );
388 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 388 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
389 SLOT( newSubTodo( Todo * ) ) ); 389 SLOT( newSubTodo( Todo * ) ) );
390 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 390 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
391 SLOT( editTodo( Todo * ) ) ); 391 SLOT( editTodo( Todo * ) ) );
392 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 392 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
393 SLOT( showTodo( Todo *) ) ); 393 SLOT( showTodo( Todo *) ) );
394 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 394 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
395 SLOT( deleteTodo( Todo *) ) ); 395 SLOT( deleteTodo( Todo *) ) );
396 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 396 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
397 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 397 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
398 SLOT( purgeCompleted() ) ); 398 SLOT( purgeCompleted() ) );
399 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 399 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
400 SIGNAL( todoModified( Todo *, int ) ) ); 400 SIGNAL( todoModified( Todo *, int ) ) );
401 401
402 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 402 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
403 this, SLOT ( cloneIncidence( Incidence * ) ) ); 403 this, SLOT ( cloneIncidence( Incidence * ) ) );
404 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 404 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
405 this, SLOT (cancelIncidence( Incidence * ) ) ); 405 this, SLOT (cancelIncidence( Incidence * ) ) );
406 406
407 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 407 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
408 this, SLOT ( moveIncidence( Incidence * ) ) ); 408 this, SLOT ( moveIncidence( Incidence * ) ) );
409 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 409 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
410 this, SLOT ( beamIncidence( Incidence * ) ) ); 410 this, SLOT ( beamIncidence( Incidence * ) ) );
411 411
412 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 412 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
413 this, SLOT ( todo_unsub( Todo * ) ) ); 413 this, SLOT ( todo_unsub( Todo * ) ) );
414 414
415 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 415 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
416 SLOT( updateTodo( Todo *, int ) ) ); 416 SLOT( updateTodo( Todo *, int ) ) );
417 connect( this, SIGNAL( todoModified( Todo *, int )), this, 417 connect( this, SIGNAL( todoModified( Todo *, int )), this,
418 SLOT( changeTodoDisplay( Todo *, int ) ) ); 418 SLOT( changeTodoDisplay( Todo *, int ) ) );
419 419
420 420
421 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 421 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
422 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 422 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
423 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 423 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
424 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 424 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
425 425
426 426
427 427
428 428
429 429
430 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 430 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
431 SLOT(checkClipboard())); 431 SLOT(checkClipboard()));
432 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 432 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
433 SLOT( processTodoListSelection( Incidence * ) ) ); 433 SLOT( processTodoListSelection( Incidence * ) ) );
434 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 434 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
435 435
436 // kdDebug() << "CalendarView::CalendarView() done" << endl; 436 // kdDebug() << "CalendarView::CalendarView() done" << endl;
437 437
438 mDateFrame = new QVBox(0,0,WType_Popup); 438 mDateFrame = new QVBox(0,0,WType_Popup);
439 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 439 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
440 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 440 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
441 mDateFrame->setLineWidth(3); 441 mDateFrame->setLineWidth(3);
442 mDateFrame->hide(); 442 mDateFrame->hide();
443 mDateFrame->setCaption( i18n( "Pick a date to display")); 443 mDateFrame->setCaption( i18n( "Pick a date to display"));
444 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 444 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
445 445
446 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 446 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
447 447
448 mEventEditor = mDialogManager->getEventEditor(); 448 mEventEditor = mDialogManager->getEventEditor();
449 mTodoEditor = mDialogManager->getTodoEditor(); 449 mTodoEditor = mDialogManager->getTodoEditor();
450 450
451 mFlagEditDescription = false; 451 mFlagEditDescription = false;
452 452
453 mSuspendTimer = new QTimer( this ); 453 mSuspendTimer = new QTimer( this );
454 mAlarmTimer = new QTimer( this ); 454 mAlarmTimer = new QTimer( this );
455 mRecheckAlarmTimer = new QTimer( this ); 455 mRecheckAlarmTimer = new QTimer( this );
456 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 456 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
457 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 457 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
458 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 458 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
459 mAlarmDialog = new AlarmDialog( this ); 459 mAlarmDialog = new AlarmDialog( this );
460 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 460 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
461 mAlarmDialog->setServerNotification( false ); 461 mAlarmDialog->setServerNotification( false );
462 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 462 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
463} 463}
464 464
465 465
466CalendarView::~CalendarView() 466CalendarView::~CalendarView()
467{ 467{
468 // kdDebug() << "~CalendarView()" << endl; 468 // kdDebug() << "~CalendarView()" << endl;
469 //qDebug("CalendarView::~CalendarView() "); 469 //qDebug("CalendarView::~CalendarView() ");
470 delete mDialogManager; 470 delete mDialogManager;
471 delete mViewManager; 471 delete mViewManager;
472 delete mStorage; 472 delete mStorage;
473 delete mDateFrame ; 473 delete mDateFrame ;
474 delete beamDialog; 474 delete beamDialog;
475 //kdDebug() << "~CalendarView() done" << endl; 475 //kdDebug() << "~CalendarView() done" << endl;
476} 476}
477void CalendarView::timerAlarm() 477void CalendarView::timerAlarm()
478{ 478{
479 //qDebug("CalendarView::timerAlarm() "); 479 //qDebug("CalendarView::timerAlarm() ");
480 computeAlarm(mAlarmNotification ); 480 computeAlarm(mAlarmNotification );
481} 481}
482 482
483void CalendarView::suspendAlarm() 483void CalendarView::suspendAlarm()
484{ 484{
485 //qDebug(" CalendarView::suspendAlarm() "); 485 //qDebug(" CalendarView::suspendAlarm() ");
486 computeAlarm(mSuspendAlarmNotification ); 486 computeAlarm(mSuspendAlarmNotification );
487 487
488} 488}
489 489
490void CalendarView::startAlarm( QString mess , QString filename) 490void CalendarView::startAlarm( QString mess , QString filename)
491{ 491{
492 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 492 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
493 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); 493 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
494 494
495} 495}
496 496
497void CalendarView::checkNextTimerAlarm() 497void CalendarView::checkNextTimerAlarm()
498{ 498{
499 mCalendar->checkAlarmForIncidence( 0, true ); 499 mCalendar->checkAlarmForIncidence( 0, true );
500} 500}
501 501
502void CalendarView::computeAlarm( QString msg ) 502void CalendarView::computeAlarm( QString msg )
503{ 503{
504 504
505 QString mess = msg; 505 QString mess = msg;
506 QString mAlarmMessage = mess.mid( 9 ); 506 QString mAlarmMessage = mess.mid( 9 );
507 QString filename = MainWindow::resourcePath(); 507 QString filename = MainWindow::resourcePath();
508 filename += "koalarm.wav"; 508 filename += "koalarm.wav";
509 QString tempfilename; 509 QString tempfilename;
510 if ( mess.left( 13 ) == "suspend_alarm") { 510 if ( mess.left( 13 ) == "suspend_alarm") {
511 bool error = false; 511 bool error = false;
512 int len = mess.mid( 13 ).find("+++"); 512 int len = mess.mid( 13 ).find("+++");
513 if ( len < 2 ) 513 if ( len < 2 )
514 error = true; 514 error = true;
515 else { 515 else {
516 tempfilename = mess.mid( 13, len ); 516 tempfilename = mess.mid( 13, len );
517 if ( !QFile::exists( tempfilename ) ) 517 if ( !QFile::exists( tempfilename ) )
518 error = true; 518 error = true;
519 } 519 }
520 if ( ! error ) { 520 if ( ! error ) {
521 filename = tempfilename; 521 filename = tempfilename;
522 } 522 }
523 mAlarmMessage = mess.mid( 13+len+3 ); 523 mAlarmMessage = mess.mid( 13+len+3 );
524 //qDebug("suspend file %s ",tempfilename.latin1() ); 524 //qDebug("suspend file %s ",tempfilename.latin1() );
525 startAlarm( mAlarmMessage, filename); 525 startAlarm( mAlarmMessage, filename);
526 return; 526 return;
527 } 527 }
528 if ( mess.left( 11 ) == "timer_alarm") { 528 if ( mess.left( 11 ) == "timer_alarm") {
529 //mTimerTime = 0; 529 //mTimerTime = 0;
530 startAlarm( mess.mid( 11 ), filename ); 530 startAlarm( mess.mid( 11 ), filename );
531 return; 531 return;
532 } 532 }
533 if ( mess.left( 10 ) == "proc_alarm") { 533 if ( mess.left( 10 ) == "proc_alarm") {
534 bool error = false; 534 bool error = false;
535 int len = mess.mid( 10 ).find("+++"); 535 int len = mess.mid( 10 ).find("+++");
536 if ( len < 2 ) 536 if ( len < 2 )
537 error = true; 537 error = true;
538 else { 538 else {
539 tempfilename = mess.mid( 10, len ); 539 tempfilename = mess.mid( 10, len );
540 if ( !QFile::exists( tempfilename ) ) 540 if ( !QFile::exists( tempfilename ) )
541 error = true; 541 error = true;
542 } 542 }
543 if ( error ) { 543 if ( error ) {
544 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 544 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
545 mAlarmMessage += mess.mid( 10+len+3+9 ); 545 mAlarmMessage += mess.mid( 10+len+3+9 );
546 } else { 546 } else {
547 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 547 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
548 //qDebug("-----system command %s ",tempfilename.latin1() ); 548 //qDebug("-----system command %s ",tempfilename.latin1() );
549#ifndef _WIN32_ 549#ifndef _WIN32_
550 if ( vfork () == 0 ) { 550 if ( vfork () == 0 ) {
551 execl ( tempfilename.latin1(), 0 ); 551 execl ( tempfilename.latin1(), 0 );
552 return; 552 return;
553 } 553 }
554#else 554#else
555 QProcess* p = new QProcess(); 555 QProcess* p = new QProcess();
556 p->addArgument( tempfilename.latin1() ); 556 p->addArgument( tempfilename.latin1() );
557 p->start(); 557 p->start();
558 return; 558 return;
559#endif 559#endif
560 560
561 return; 561 return;
562 } 562 }
563 563
564 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 564 //qDebug("+++++++system command %s ",tempfilename.latin1() );
565 } 565 }
566 if ( mess.left( 11 ) == "audio_alarm") { 566 if ( mess.left( 11 ) == "audio_alarm") {
567 bool error = false; 567 bool error = false;
568 int len = mess.mid( 11 ).find("+++"); 568 int len = mess.mid( 11 ).find("+++");
569 if ( len < 2 ) 569 if ( len < 2 )
570 error = true; 570 error = true;
571 else { 571 else {
572 tempfilename = mess.mid( 11, len ); 572 tempfilename = mess.mid( 11, len );
573 if ( !QFile::exists( tempfilename ) ) 573 if ( !QFile::exists( tempfilename ) )
574 error = true; 574 error = true;
575 } 575 }
576 if ( ! error ) { 576 if ( ! error ) {
577 filename = tempfilename; 577 filename = tempfilename;
578 } 578 }
579 mAlarmMessage = mess.mid( 11+len+3+9 ); 579 mAlarmMessage = mess.mid( 11+len+3+9 );
580 //qDebug("audio file command %s ",tempfilename.latin1() ); 580 //qDebug("audio file command %s ",tempfilename.latin1() );
581 } 581 }
582 if ( mess.left( 9 ) == "cal_alarm") { 582 if ( mess.left( 9 ) == "cal_alarm") {
583 mAlarmMessage = mess.mid( 9 ) ; 583 mAlarmMessage = mess.mid( 9 ) ;
584 } 584 }
585 585
586 startAlarm( mAlarmMessage, filename ); 586 startAlarm( mAlarmMessage, filename );
587 587
588 588
589} 589}
590 590
591void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 591void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
592{ 592{
593 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 593 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
594 594
595 mSuspendAlarmNotification = noti; 595 mSuspendAlarmNotification = noti;
596 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 596 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
597 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 597 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
598 mSuspendTimer->start( ms , true ); 598 mSuspendTimer->start( ms , true );
599 599
600} 600}
601 601
602void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 602void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
603{ 603{
604 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 604 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
605 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 605 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
606#ifndef DESKTOP_VERSION 606#ifndef DESKTOP_VERSION
607 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); 607 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() );
608#endif 608#endif
609 return; 609 return;
610 } 610 }
611 int maxSec; 611 int maxSec;
612 //maxSec = 5; //testing only 612 //maxSec = 5; //testing only
613 maxSec = 86400+3600; // one day+1hour 613 maxSec = 86400+3600; // one day+1hour
614 mAlarmNotification = noti; 614 mAlarmNotification = noti;
615 int sec = QDateTime::currentDateTime().secsTo( qdt ); 615 int sec = QDateTime::currentDateTime().secsTo( qdt );
616 if ( sec > maxSec ) { 616 if ( sec > maxSec ) {
617 mRecheckAlarmTimer->start( maxSec * 1000 ); 617 mRecheckAlarmTimer->start( maxSec * 1000 );
618 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 618 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
619 return; 619 return;
620 } else { 620 } else {
621 mRecheckAlarmTimer->stop(); 621 mRecheckAlarmTimer->stop();
622 } 622 }
623 //qDebug("Alarm timer started with secs: %d ", sec); 623 //qDebug("Alarm timer started with secs: %d ", sec);
624 mAlarmTimer->start( sec *1000 , true ); 624 mAlarmTimer->start( sec *1000 , true );
625 625
626} 626}
627// called by mRecheckAlarmTimer to get next alarm 627// called by mRecheckAlarmTimer to get next alarm
628// we need this, because a QTimer has only a max range of 25 days 628// we need this, because a QTimer has only a max range of 25 days
629void CalendarView::recheckTimerAlarm() 629void CalendarView::recheckTimerAlarm()
630{ 630{
631 mAlarmTimer->stop(); 631 mAlarmTimer->stop();
632 mRecheckAlarmTimer->stop(); 632 mRecheckAlarmTimer->stop();
633 mCalendar->checkAlarmForIncidence( 0, true ); 633 mCalendar->checkAlarmForIncidence( 0, true );
634} 634}
635void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 635void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
636{ 636{
637 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 637 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
638 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 638 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
639#ifndef DESKTOP_VERSION 639#ifndef DESKTOP_VERSION
640 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 640 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
641#endif 641#endif
642 return; 642 return;
643 } 643 }
644 mAlarmTimer->stop(); 644 mAlarmTimer->stop();
645} 645}
646void CalendarView::selectWeekNum ( int num ) 646void CalendarView::selectWeekNum ( int num )
647{ 647{
648 dateNavigator()->selectWeek( num ); 648 dateNavigator()->selectWeek( num );
649 mViewManager->showWeekView(); 649 mViewManager->showWeekView();
650} 650}
651KOViewManager *CalendarView::viewManager() 651KOViewManager *CalendarView::viewManager()
652{ 652{
653 return mViewManager; 653 return mViewManager;
654} 654}
655 655
656KODialogManager *CalendarView::dialogManager() 656KODialogManager *CalendarView::dialogManager()
657{ 657{
658 return mDialogManager; 658 return mDialogManager;
659} 659}
660 660
661QDate CalendarView::startDate() 661QDate CalendarView::startDate()
662{ 662{
663 DateList dates = mNavigator->selectedDates(); 663 DateList dates = mNavigator->selectedDates();
664 664
665 return dates.first(); 665 return dates.first();
666} 666}
667 667
668QDate CalendarView::endDate() 668QDate CalendarView::endDate()
669{ 669{
670 DateList dates = mNavigator->selectedDates(); 670 DateList dates = mNavigator->selectedDates();
671 671
672 return dates.last(); 672 return dates.last();
673} 673}
674 674
675 675
676void CalendarView::createPrinter() 676void CalendarView::createPrinter()
677{ 677{
678#ifndef KORG_NOPRINTER 678#ifndef KORG_NOPRINTER
679 if (!mCalPrinter) { 679 if (!mCalPrinter) {
680 mCalPrinter = new CalPrinter(this, mCalendar); 680 mCalPrinter = new CalPrinter(this, mCalendar);
681 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 681 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
682 } 682 }
683#endif 683#endif
684} 684}
685 685
686void CalendarView::confSync() 686void CalendarView::confSync()
687{ 687{
688 static KSyncPrefsDialog* sp = 0; 688 static KSyncPrefsDialog* sp = 0;
689 if ( ! sp ) { 689 if ( ! sp ) {
690 sp = new KSyncPrefsDialog( this, "syncprefs", true ); 690 sp = new KSyncPrefsDialog( this, "syncprefs", true );
691 } 691 }
692 sp->usrReadConfig(); 692 sp->usrReadConfig();
693#ifndef DESKTOP_VERSION 693#ifndef DESKTOP_VERSION
694 sp->showMaximized(); 694 sp->showMaximized();
695#else 695#else
696 sp->show(); 696 sp->show();
697#endif 697#endif
698 sp->exec(); 698 sp->exec();
699 KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); 699 KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames();
700 KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); 700 KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName ();
701} 701}
702 702
703 703
704//KOPrefs::instance()->mWriteBackFile 704//KOPrefs::instance()->mWriteBackFile
705//KOPrefs::instance()->mWriteBackExistingOnly 705//KOPrefs::instance()->mWriteBackExistingOnly
706 706
707// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 707// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
708// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 708// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
709// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 709// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
710// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 710// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
711// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 711// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
712// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 712// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
713 713
714int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 714int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
715{ 715{
716 716
717 //void setZaurusId(int id); 717 //void setZaurusId(int id);
718 // int zaurusId() const; 718 // int zaurusId() const;
719 // void setZaurusUid(int id); 719 // void setZaurusUid(int id);
720 // int zaurusUid() const; 720 // int zaurusUid() const;
721 // void setZaurusStat(int id); 721 // void setZaurusStat(int id);
722 // int zaurusStat() const; 722 // int zaurusStat() const;
723 // 0 equal 723 // 0 equal
724 // 1 take local 724 // 1 take local
725 // 2 take remote 725 // 2 take remote
726 // 3 cancel 726 // 3 cancel
727 QDateTime lastSync = mLastCalendarSync; 727 QDateTime lastSync = mLastCalendarSync;
728 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 728 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
729 bool remCh, locCh; 729 bool remCh, locCh;
730 remCh = ( remote->zaurusUid() != local->zaurusUid() ); 730 remCh = ( remote->zaurusUid() != local->zaurusUid() );
731 locCh = ( local->lastModified() > mLastCalendarSync ); 731 locCh = ( local->lastModified() > mLastCalendarSync );
732 //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() ); 732 //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() );
733 if ( !remCh && ! locCh ) { 733 if ( !remCh && ! locCh ) {
734 //qDebug("both not changed "); 734 //qDebug("both not changed ");
735 lastSync = local->lastModified().addDays(1); 735 lastSync = local->lastModified().addDays(1);
736 } else { 736 } else {
737 if ( locCh ) { 737 if ( locCh ) {
738 //qDebug("loc changed %d %d", local->zaurusStat(), local->revision() ); 738 //qDebug("loc changed %d %d", local->zaurusStat(), local->revision() );
739 lastSync = local->lastModified().addDays( -1 ); 739 lastSync = local->lastModified().addDays( -1 );
740 if ( !remCh ) 740 if ( !remCh )
741 remote->setLastModified( lastSync.addDays( -1 ) ); 741 remote->setLastModified( lastSync.addDays( -1 ) );
742 } else { 742 } else {
743 //qDebug(" not loc changed "); 743 //qDebug(" not loc changed ");
744 lastSync = local->lastModified().addDays( 1 ); 744 lastSync = local->lastModified().addDays( 1 );
745 if ( remCh ) 745 if ( remCh )
746 remote->setLastModified( lastSync.addDays( 1 ) ); 746 remote->setLastModified( lastSync.addDays( 1 ) );
747 747
748 } 748 }
749 } 749 }
750 full = true; 750 full = true;
751 if ( mode < SYNC_PREF_ASK ) 751 if ( mode < SYNC_PREF_ASK )
752 mode = SYNC_PREF_ASK; 752 mode = SYNC_PREF_ASK;
753 } else { 753 } else {
754 if ( local->lastModified() == remote->lastModified() ) 754 if ( local->lastModified() == remote->lastModified() )
755 if ( local->revision() == remote->revision() ) 755 if ( local->revision() == remote->revision() )
756 return 0; 756 return 0;
757 757
758 } 758 }
759 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 759 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
760 760
761 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); 761 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision());
762 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); 762 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() );
763 //full = true; //debug only 763 //full = true; //debug only
764 if ( full ) { 764 if ( full ) {
765 bool equ = false; 765 bool equ = false;
766 if ( local->type() == "Event" ) { 766 if ( local->type() == "Event" ) {
767 equ = (*((Event*) local) == *((Event*) remote)); 767 equ = (*((Event*) local) == *((Event*) remote));
768 } 768 }
769 else if ( local->type() =="Todo" ) 769 else if ( local->type() =="Todo" )
770 equ = (*((Todo*) local) == (*(Todo*) remote)); 770 equ = (*((Todo*) local) == (*(Todo*) remote));
771 else if ( local->type() =="Journal" ) 771 else if ( local->type() =="Journal" )
772 equ = (*((Journal*) local) == *((Journal*) remote)); 772 equ = (*((Journal*) local) == *((Journal*) remote));
773 if ( equ ) { 773 if ( equ ) {
774 //qDebug("equal "); 774 //qDebug("equal ");
775 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 775 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
776 local->setZaurusUid( remote->zaurusUid() ); 776 local->setZaurusUid( remote->zaurusUid() );
777 } 777 }
778 if ( mode < SYNC_PREF_FORCE_LOCAL ) 778 if ( mode < SYNC_PREF_FORCE_LOCAL )
779 return 0; 779 return 0;
780 780
781 }//else //debug only 781 }//else //debug only
782 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 782 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
783 } 783 }
784 int result; 784 int result;
785 bool localIsNew; 785 bool localIsNew;
786 if ( full && mode < SYNC_PREF_NEWEST ) 786 if ( full && mode < SYNC_PREF_NEWEST )
787 mode = SYNC_PREF_ASK; 787 mode = SYNC_PREF_ASK;
788 788
789 switch( mode ) { 789 switch( mode ) {
790 case SYNC_PREF_LOCAL: 790 case SYNC_PREF_LOCAL:
791 if ( lastSync > remote->lastModified() ) 791 if ( lastSync > remote->lastModified() )
792 return 1; 792 return 1;
793 if ( lastSync > local->lastModified() ) 793 if ( lastSync > local->lastModified() )
794 return 2; 794 return 2;
795 return 1; 795 return 1;
796 break; 796 break;
797 case SYNC_PREF_REMOTE: 797 case SYNC_PREF_REMOTE:
798 if ( lastSync > remote->lastModified() ) 798 if ( lastSync > remote->lastModified() )
799 return 1; 799 return 1;
800 if ( lastSync > local->lastModified() ) 800 if ( lastSync > local->lastModified() )
801 return 2; 801 return 2;
802 return 2; 802 return 2;
803 break; 803 break;
804 case SYNC_PREF_NEWEST: 804 case SYNC_PREF_NEWEST:
805 if ( local->lastModified() > remote->lastModified() ) 805 if ( local->lastModified() > remote->lastModified() )
806 return 1; 806 return 1;
807 else 807 else
808 return 2; 808 return 2;
809 break; 809 break;
810 case SYNC_PREF_ASK: 810 case SYNC_PREF_ASK:
811 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); 811 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() );
812 if ( lastSync > remote->lastModified() ) 812 if ( lastSync > remote->lastModified() )
813 return 1; 813 return 1;
814 if ( lastSync > local->lastModified() ) 814 if ( lastSync > local->lastModified() )
815 return 2; 815 return 2;
816 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); 816 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() );
817 localIsNew = local->lastModified() > remote->lastModified(); 817 localIsNew = local->lastModified() > remote->lastModified();
818 if ( localIsNew ) 818 if ( localIsNew )
819 getEventViewerDialog()->setColorMode( 1 ); 819 getEventViewerDialog()->setColorMode( 1 );
820 else 820 else
821 getEventViewerDialog()->setColorMode( 2 ); 821 getEventViewerDialog()->setColorMode( 2 );
822 getEventViewerDialog()->setIncidence(local); 822 getEventViewerDialog()->setIncidence(local);
823 if ( localIsNew ) 823 if ( localIsNew )
824 getEventViewerDialog()->setColorMode( 2 ); 824 getEventViewerDialog()->setColorMode( 2 );
825 else 825 else
826 getEventViewerDialog()->setColorMode( 1 ); 826 getEventViewerDialog()->setColorMode( 1 );
827 getEventViewerDialog()->addIncidence(remote); 827 getEventViewerDialog()->addIncidence(remote);
828 getEventViewerDialog()->setColorMode( 0 ); 828 getEventViewerDialog()->setColorMode( 0 );
829 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 829 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
830 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 830 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
831 getEventViewerDialog()->showMe(); 831 getEventViewerDialog()->showMe();
832 result = getEventViewerDialog()->executeS( localIsNew ); 832 result = getEventViewerDialog()->executeS( localIsNew );
833 return result; 833 return result;
834 834
835 break; 835 break;
836 case SYNC_PREF_FORCE_LOCAL: 836 case SYNC_PREF_FORCE_LOCAL:
837 return 1; 837 return 1;
838 break; 838 break;
839 case SYNC_PREF_FORCE_REMOTE: 839 case SYNC_PREF_FORCE_REMOTE:
840 return 2; 840 return 2;
841 break; 841 break;
842 842
843 default: 843 default:
844 // SYNC_PREF_TAKE_BOTH not implemented 844 // SYNC_PREF_TAKE_BOTH not implemented
845 break; 845 break;
846 } 846 }
847 return 0; 847 return 0;
848} 848}
849Event* CalendarView::getLastSyncEvent() 849Event* CalendarView::getLastSyncEvent()
850{ 850{
851 Event* lse; 851 Event* lse;
852 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 852 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
853 lse = mCalendar->event( "last-syncEvent-device-"+mCurrentSyncDevice ); 853 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
854 if (!lse) { 854 if (!lse) {
855 lse = new Event(); 855 lse = new Event();
856 lse->setUid( "last-syncEvent-device-"+mCurrentSyncDevice ); 856 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
857 lse->setSummary(mCurrentSyncDevice + i18n(" - sync event")); 857 QString sum = "";
858 if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
859 sum = "E: ";
860 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
858 lse->setDtStart( mLastCalendarSync ); 861 lse->setDtStart( mLastCalendarSync );
859 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 862 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
860 lse->setCategories( i18n("SyncEvent") ); 863 lse->setCategories( i18n("SyncEvent") );
861 lse->setReadOnly( true ); 864 lse->setReadOnly( true );
862 mCalendar->addEvent( lse ); 865 mCalendar->addEvent( lse );
863 } 866 }
864 867
865 return lse; 868 return lse;
866 869
867} 870}
868void CalendarView::checkSharpEvent( Event* lastSync, Incidence* toDelete ) 871void CalendarView::setupExternSyncProfiles()
869{ 872{
870 if ( ! lastSync ) 873 Event* lse;
871 return; 874 mExternLastSyncEvent.clear();
872 if ( toDelete->zaurusId() < 0 ) 875 int i;
876 for ( i = 0; i < KOPrefs::instance()->mExternSyncProfiles.count(); ++i ) {
877 lse = mCalendar->event( "last-syncEvent-"+ KOPrefs::instance()->mExternSyncProfiles[i] );
878 if ( lse )
879 mExternLastSyncEvent.append( lse );
880 else
881 qDebug("Last Sync event not found for %s ", KOPrefs::instance()->mExternSyncProfiles[i].latin1());
882 }
883
884}
885// we check, if the to delete event has a id for a profile
886// if yes, we set this id in the profile to delete
887void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
888{
889 if ( ! lastSync.count() == 0 )
873 return; 890 return;
874 if ( toDelete->type() == "Journal" ) 891 if ( toDelete->type() == "Journal" )
875 return; 892 return;
876 QString des = lastSync->description(); 893
877 QString pref = "e"; 894 Event* eve = lastSync.first();
878 if ( toDelete->type() == "Todo" ) 895
879 pref = "t"; 896 while ( eve ) {
880 des += pref+ QString::number ( toDelete->zaurusId() ) + ","; 897 int id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
881 lastSync->setReadOnly( false ); 898 if ( id >= 0 ) {
882 lastSync->setDescription( des ); 899 QString des = eve->description();
883 lastSync->setReadOnly( true ); 900 QString pref = "e";
901 if ( toDelete->type() == "Todo" )
902 pref = "t";
903 des += pref+ QString::number ( id ) + ",";
904 eve->setReadOnly( false );
905 eve->setDescription( des );
906 eve->setReadOnly( true );
907 }
908 eve = lastSync.next();
909 }
884 910
885} 911}
886bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 912bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
887{ 913{
888 bool syncOK = true; 914 bool syncOK = true;
889 int addedEvent = 0; 915 int addedEvent = 0;
890 int addedEventR = 0; 916 int addedEventR = 0;
891 int deletedEventR = 0; 917 int deletedEventR = 0;
892 int deletedEventL = 0; 918 int deletedEventL = 0;
893 int changedLocal = 0; 919 int changedLocal = 0;
894 int changedRemote = 0; 920 int changedRemote = 0;
895 //QPtrList<Event> el = local->rawEvents(); 921 //QPtrList<Event> el = local->rawEvents();
896 Event* eventR; 922 Event* eventR;
897 QString uid; 923 QString uid;
898 int take; 924 int take;
899 Event* eventL; 925 Event* eventL;
900 Event* eventRSync; 926 Event* eventRSync;
901 Event* eventLSync; 927 Event* eventLSync;
902 Event* eventRSyncSharp = remote->event( "last-syncEvent-device-Sharp-DTM"); 928 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
903 Event* eventLSyncSharp = local->event( "last-syncEvent-device-Sharp-DTM"); 929 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
904 bool fullDateRange = false; 930 bool fullDateRange = false;
905 mLastCalendarSync = QDateTime::currentDateTime(); 931 mLastCalendarSync = QDateTime::currentDateTime();
906 QDateTime modifiedCalendar = mLastCalendarSync;; 932 QDateTime modifiedCalendar = mLastCalendarSync;;
907 eventR = remote->event("last-syncEvent-device-"+mCurrentSyncName ); 933 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
908 if ( eventR ) { 934 if ( eventR ) {
909 eventRSync = (Event*) eventR->clone(); 935 eventRSync = (Event*) eventR->clone();
910 remote->deleteEvent(eventR ); 936 remote->deleteEvent(eventR );
911 937
912 } else { 938 } else {
913 fullDateRange = true; 939 fullDateRange = true;
914 eventRSync = new Event(); 940 eventRSync = new Event();
915 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 941 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
916 eventRSync->setUid("last-syncEvent-device-"+mCurrentSyncName ); 942 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
917 eventRSync->setDtStart( mLastCalendarSync ); 943 eventRSync->setDtStart( mLastCalendarSync );
918 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 944 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
919 eventRSync->setCategories( i18n("SyncEvent") ); 945 eventRSync->setCategories( i18n("SyncEvent") );
920 } 946 }
921 eventLSync = getLastSyncEvent(); 947 eventLSync = getLastSyncEvent();
922 if ( eventLSync->dtStart() == mLastCalendarSync ) 948 if ( eventLSync->dtStart() == mLastCalendarSync )
923 fullDateRange = true; 949 fullDateRange = true;
924 950
925 if ( ! fullDateRange ) { 951 if ( ! fullDateRange ) {
926 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 952 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
927 953
928 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 954 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
929 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 955 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
930 fullDateRange = true; 956 fullDateRange = true;
931 } 957 }
932 } 958 }
933 if ( fullDateRange ) 959 if ( fullDateRange )
934 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 960 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
935 else 961 else
936 mLastCalendarSync = eventLSync->dtStart(); 962 mLastCalendarSync = eventLSync->dtStart();
937 // for resyncing if own file has changed 963 // for resyncing if own file has changed
938 if ( mCurrentSyncDevice == "deleteaftersync" ) { 964 if ( mCurrentSyncDevice == "deleteaftersync" ) {
939 mLastCalendarSync = loadedFileVersion; 965 mLastCalendarSync = loadedFileVersion;
940 qDebug("setting mLastCalendarSync "); 966 qDebug("setting mLastCalendarSync ");
941 } 967 }
942 //qDebug("*************************** "); 968 //qDebug("*************************** ");
943 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); 969 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() );
944 QPtrList<Incidence> er = remote->rawIncidences(); 970 QPtrList<Incidence> er = remote->rawIncidences();
945 Incidence* inR = er.first(); 971 Incidence* inR = er.first();
946 Incidence* inL; 972 Incidence* inL;
947 QProgressBar bar( er.count(),0 ); 973 QProgressBar bar( er.count(),0 );
948 bar.setCaption (i18n("Syncing - close to abort!") ); 974 bar.setCaption (i18n("Syncing - close to abort!") );
949 975
950 int w = 300; 976 int w = 300;
951 if ( QApplication::desktop()->width() < 320 ) 977 if ( QApplication::desktop()->width() < 320 )
952 w = 220; 978 w = 220;
953 int h = bar.sizeHint().height() ; 979 int h = bar.sizeHint().height() ;
954 int dw = QApplication::desktop()->width(); 980 int dw = QApplication::desktop()->width();
955 int dh = QApplication::desktop()->height(); 981 int dh = QApplication::desktop()->height();
956 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 982 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
957 bar.show(); 983 bar.show();
958 int modulo = (er.count()/10)+1; 984 int modulo = (er.count()/10)+1;
959 int incCounter = 0; 985 int incCounter = 0;
960 while ( inR ) { 986 while ( inR ) {
961 if ( ! bar.isVisible() ) 987 if ( ! bar.isVisible() )
962 return false; 988 return false;
963 if ( incCounter % modulo == 0 ) 989 if ( incCounter % modulo == 0 )
964 bar.setProgress( incCounter ); 990 bar.setProgress( incCounter );
965 ++incCounter; 991 ++incCounter;
966 uid = inR->uid(); 992 uid = inR->uid();
967 bool skipIncidence = false; 993 bool skipIncidence = false;
968 if ( uid.left(21) == QString("last-syncEvent-device") ) 994 if ( uid.left(15) == QString("last-syncEvent-") )
969 skipIncidence = true; 995 skipIncidence = true;
970 996
971 qApp->processEvents(); 997 qApp->processEvents();
972 if ( !skipIncidence ) { 998 if ( !skipIncidence ) {
973 inL = local->incidence( uid ); 999 inL = local->incidence( uid );
974 if ( inL ) { // maybe conflict - same uid in both calendars 1000 if ( inL ) { // maybe conflict - same uid in both calendars
975 int maxrev = inL->revision(); 1001 int maxrev = inL->revision();
976 if ( maxrev < inR->revision() ) 1002 if ( maxrev < inR->revision() )
977 maxrev = inR->revision(); 1003 maxrev = inR->revision();
978 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1004 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
979 //qDebug("take %d %s ", take, inL->summary().latin1()); 1005 //qDebug("take %d %s ", take, inL->summary().latin1());
980 if ( take == 3 ) 1006 if ( take == 3 )
981 return false; 1007 return false;
982 if ( take == 1 ) {// take local 1008 if ( take == 1 ) {// take local
983 inL->setZaurusUid( inR->zaurusUid() ); 1009 inL->setZaurusUid( inR->zaurusUid() );
984 remote->deleteIncidence( inR ); 1010 remote->deleteIncidence( inR );
985 if ( inL->revision() < maxrev ) 1011 if ( inL->revision() < maxrev )
986 inL->setRevision( maxrev ); 1012 inL->setRevision( maxrev );
987 remote->addIncidence( inL->clone() ); 1013 remote->addIncidence( inL->clone() );
988 ++changedRemote; 1014 ++changedRemote;
989 } else { 1015 } else {
990 if ( inR->revision() < maxrev ) 1016 if ( inR->revision() < maxrev )
991 inR->setRevision( maxrev ); 1017 inR->setRevision( maxrev );
992 local->deleteIncidence( inL ); 1018 local->deleteIncidence( inL );
993 local->addIncidence( inR->clone() ); 1019 local->addIncidence( inR->clone() );
994 ++changedLocal; 1020 ++changedLocal;
995 } 1021 }
996 } 1022 }
997 } else { // no conflict 1023 } else { // no conflict
998 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1024 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
999 QString des = eventLSync->description(); 1025 QString des = eventLSync->description();
1000 QString pref = "e"; 1026 QString pref = "e";
1001 if ( inR->type() == "Todo" ) 1027 if ( inR->type() == "Todo" )
1002 pref = "t"; 1028 pref = "t";
1003 if ( des.find(pref+QString::number( inR->zaurusId() ) +"," ) >= 0 && mode != 5) { // delete it 1029 if ( des.find(pref+QString::number( inR->zaurusId() ) +"," ) >= 0 && mode != 5) { // delete it
1004 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1030 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1005 //remote->deleteIncidence( inR ); 1031 //remote->deleteIncidence( inR );
1006 ++deletedEventR; 1032 ++deletedEventR;
1007 } else { 1033 } else {
1008 inR->setLastModified( modifiedCalendar ); 1034 inR->setLastModified( modifiedCalendar );
1009 local->addIncidence( inR->clone() ); 1035 local->addIncidence( inR->clone() );
1010 ++addedEvent; 1036 ++addedEvent;
1011 } 1037 }
1012 } else { 1038 } else {
1013 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1039 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1014 inR->setLastModified( modifiedCalendar ); 1040 inR->setLastModified( modifiedCalendar );
1015 local->addIncidence( inR->clone() ); 1041 local->addIncidence( inR->clone() );
1016 ++addedEvent; 1042 ++addedEvent;
1017 } else { 1043 } else {
1018 checkSharpEvent(eventRSyncSharp, inR); 1044 checkExternSyncEvent(eventRSyncSharp, inR);
1019 remote->deleteIncidence( inR ); 1045 remote->deleteIncidence( inR );
1020 ++deletedEventR; 1046 ++deletedEventR;
1021 } 1047 }
1022 } 1048 }
1023 } 1049 }
1024 } 1050 }
1025 inR = er.next(); 1051 inR = er.next();
1026 } 1052 }
1027 QPtrList<Incidence> el = local->rawIncidences(); 1053 QPtrList<Incidence> el = local->rawIncidences();
1028 inL = el.first(); 1054 inL = el.first();
1029 modulo = (el.count()/10)+1; 1055 modulo = (el.count()/10)+1;
1030 bar.setCaption (i18n("Add / remove events") ); 1056 bar.setCaption (i18n("Add / remove events") );
1031 bar.setTotalSteps ( el.count() ) ; 1057 bar.setTotalSteps ( el.count() ) ;
1032 bar.show(); 1058 bar.show();
1033 incCounter = 0; 1059 incCounter = 0;
1034 1060
1035 while ( inL ) { 1061 while ( inL ) {
1036 1062
1037 qApp->processEvents(); 1063 qApp->processEvents();
1038 if ( ! bar.isVisible() ) 1064 if ( ! bar.isVisible() )
1039 return false; 1065 return false;
1040 if ( incCounter % modulo == 0 ) 1066 if ( incCounter % modulo == 0 )
1041 bar.setProgress( incCounter ); 1067 bar.setProgress( incCounter );
1042 ++incCounter; 1068 ++incCounter;
1043 uid = inL->uid(); 1069 uid = inL->uid();
1044 bool skipIncidence = false; 1070 bool skipIncidence = false;
1045 if ( uid.left(21) == QString("last-syncEvent-device") ) 1071 if ( uid.left(15) == QString("last-syncEvent-") )
1046 skipIncidence = true; 1072 skipIncidence = true;
1047 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) 1073 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
1048 skipIncidence = true; 1074 skipIncidence = true;
1049 if ( !skipIncidence ) { 1075 if ( !skipIncidence ) {
1050 inR = remote->incidence( uid ); 1076 inR = remote->incidence( uid );
1051 if ( ! inR ) { 1077 if ( ! inR ) {
1052 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1078 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1053 if ( inL->zaurusId() >= 0 && mode != 4 ) { 1079 if ( inL->zaurusId() >= 0 && mode != 4 ) {
1054 local->deleteIncidence( inL ); 1080 local->deleteIncidence( inL );
1055 ++deletedEventL; 1081 ++deletedEventL;
1056 } else { 1082 } else {
1057 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { 1083 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
1058 inL->setZaurusId( -1 ); 1084 inL->setZaurusId( -1 );
1059 ++addedEventR; 1085 ++addedEventR;
1060 inL->setLastModified( modifiedCalendar ); 1086 inL->setLastModified( modifiedCalendar );
1061 remote->addIncidence( inL->clone() ); 1087 remote->addIncidence( inL->clone() );
1062 } 1088 }
1063 } 1089 }
1064 } else { 1090 } else {
1065 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1091 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1066 checkSharpEvent(eventLSyncSharp, inL); 1092 checkExternSyncEvent(eventLSyncSharp, inL);
1067 local->deleteIncidence( inL ); 1093 local->deleteIncidence( inL );
1068 ++deletedEventL; 1094 ++deletedEventL;
1069 } else { 1095 } else {
1070 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { 1096 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
1071 ++addedEventR; 1097 ++addedEventR;
1072 inL->setLastModified( modifiedCalendar ); 1098 inL->setLastModified( modifiedCalendar );
1073 remote->addIncidence( inL->clone() ); 1099 remote->addIncidence( inL->clone() );
1074 } 1100 }
1075 } 1101 }
1076 } 1102 }
1077 } 1103 }
1078 } 1104 }
1079 inL = el.next(); 1105 inL = el.next();
1080 } 1106 }
1081 1107
1082 bar.hide(); 1108 bar.hide();
1083 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1109 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1084 eventLSync->setReadOnly( false ); 1110 eventLSync->setReadOnly( false );
1085 eventLSync->setDtStart( mLastCalendarSync ); 1111 eventLSync->setDtStart( mLastCalendarSync );
1086 eventRSync->setDtStart( mLastCalendarSync ); 1112 eventRSync->setDtStart( mLastCalendarSync );
1087 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1113 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1088 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1114 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1089 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1115 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1090 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1116 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1091 eventLSync->setReadOnly( true ); 1117 eventLSync->setReadOnly( true );
1092 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 1118 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
1093 remote->addEvent( eventRSync ); 1119 remote->addEvent( eventRSync );
1094 QString mes; 1120 QString mes;
1095 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 ); 1121 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 );
1096 if ( KOPrefs::instance()->mShowSyncSummary ) { 1122 if ( KOPrefs::instance()->mShowSyncSummary ) {
1097 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); 1123 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") );
1098 } 1124 }
1099 qDebug( mes ); 1125 qDebug( mes );
1100 mCalendar->checkAlarmForIncidence( 0, true ); 1126 mCalendar->checkAlarmForIncidence( 0, true );
1101 return syncOK; 1127 return syncOK;
1102} 1128}
1103 1129
1104void CalendarView::setSyncDevice( QString s ) 1130void CalendarView::setSyncDevice( QString s )
1105{ 1131{
1106 mCurrentSyncDevice= s; 1132 mCurrentSyncDevice= s;
1107} 1133}
1108void CalendarView::setSyncName( QString s ) 1134void CalendarView::setSyncName( QString s )
1109{ 1135{
1110 mCurrentSyncName= s; 1136 mCurrentSyncName= s;
1111} 1137}
1112bool CalendarView::syncCalendar(QString filename, int mode) 1138bool CalendarView::syncCalendar(QString filename, int mode)
1113{ 1139{
1114 mGlobalSyncMode = SYNC_MODE_NORMAL; 1140 mGlobalSyncMode = SYNC_MODE_NORMAL;
1115 CalendarLocal* calendar = new CalendarLocal(); 1141 CalendarLocal* calendar = new CalendarLocal();
1116 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1142 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1117 FileStorage* storage = new FileStorage( calendar ); 1143 FileStorage* storage = new FileStorage( calendar );
1118 bool syncOK = false; 1144 bool syncOK = false;
1119 storage->setFileName( filename ); 1145 storage->setFileName( filename );
1120 // qDebug("loading ... "); 1146 // qDebug("loading ... ");
1121 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { 1147 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) {
1122 getEventViewerDialog()->setSyncMode( true ); 1148 getEventViewerDialog()->setSyncMode( true );
1123 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1149 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1124 getEventViewerDialog()->setSyncMode( false ); 1150 getEventViewerDialog()->setSyncMode( false );
1125 if ( syncOK ) { 1151 if ( syncOK ) {
1126 if ( KOPrefs::instance()->mWriteBackFile ) 1152 if ( KOPrefs::instance()->mWriteBackFile )
1127 { 1153 {
1128 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 1154 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
1129 storage->save(); 1155 storage->save();
1130 } 1156 }
1131 } 1157 }
1132 setModified( true ); 1158 setModified( true );
1133 } 1159 }
1134 delete storage; 1160 delete storage;
1135 delete calendar; 1161 delete calendar;
1136 if ( syncOK ) 1162 if ( syncOK )
1137 updateView(); 1163 updateView();
1138 return syncOK; 1164 return syncOK;
1139} 1165}
1140void CalendarView::syncSharp() 1166void CalendarView::syncSharp()
1141{ 1167{
1142#ifndef DESKTOP_VERSION 1168#ifndef DESKTOP_VERSION
1143 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1169 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1144 //mCurrentSyncDevice = "sharp-DTM"; 1170 //mCurrentSyncDevice = "sharp-DTM";
1145 if ( KOPrefs::instance()->mAskForPreferences ) 1171 if ( KOPrefs::instance()->mAskForPreferences )
1146 edit_sync_options(); 1172 edit_sync_options();
1147 qApp->processEvents(); 1173 qApp->processEvents();
1148 CalendarLocal* calendar = new CalendarLocal(); 1174 CalendarLocal* calendar = new CalendarLocal();
1149 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1175 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1150 bool syncOK = false; 1176 bool syncOK = false;
1151 SharpFormat sharpFormat; 1177 SharpFormat sharpFormat;
1152 if ( sharpFormat.load( calendar, mCalendar ) ) { 1178 if ( sharpFormat.load( calendar, mCalendar ) ) {
1153 getEventViewerDialog()->setSyncMode( true ); 1179 getEventViewerDialog()->setSyncMode( true );
1154 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); 1180 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
1155 getEventViewerDialog()->setSyncMode( false ); 1181 getEventViewerDialog()->setSyncMode( false );
1156 qApp->processEvents(); 1182 qApp->processEvents();
1157 if ( syncOK ) { 1183 if ( syncOK ) {
1158 if ( KOPrefs::instance()->mWriteBackFile ) 1184 if ( KOPrefs::instance()->mWriteBackFile )
1159 { 1185 {
1160 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1186 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1161 Incidence* inc = iL.first(); 1187 Incidence* inc = iL.first();
1162 /* obsolete 1188 /* obsolete
1163 while ( inc ) { 1189 while ( inc ) {
1164 inc->setZaurusStat( inc->revision () ); 1190 inc->setZaurusStat( inc->revision () );
1165 inc = iL.next(); 1191 inc = iL.next();
1166 } 1192 }
1167 */ 1193 */
1168 // pending: clean last sync event description 1194 // pending: clean last sync event description
1169 sharpFormat.save(calendar); 1195 sharpFormat.save(calendar);
1170 iL = calendar->rawIncidences(); 1196 iL = calendar->rawIncidences();
1171 inc = iL.first(); 1197 inc = iL.first();
1172 Incidence* loc; 1198 Incidence* loc;
1173 while ( inc ) { 1199 while ( inc ) {
1174 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1200 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1175 loc = mCalendar->incidence(inc->uid() ); 1201 loc = mCalendar->incidence(inc->uid() );
1176 if ( loc ) { 1202 if ( loc ) {
1177 loc->setZaurusId( inc->zaurusId() ); 1203 loc->setZaurusId( inc->zaurusId() );
1178 loc->setZaurusUid( inc->zaurusUid() ); 1204 loc->setZaurusUid( inc->zaurusUid() );
1179 } 1205 }
1180 } 1206 }
1181 inc = iL.next(); 1207 inc = iL.next();
1182 } 1208 }
1183 Incidence* lse = getLastSyncEvent(); 1209 Incidence* lse = getLastSyncEvent();
1184 if ( lse ) { 1210 if ( lse ) {
1185 lse->setReadOnly( false ); 1211 lse->setReadOnly( false );
1186 lse->setDescription( "" ); 1212 lse->setDescription( "" );
1187 lse->setReadOnly( true ); 1213 lse->setReadOnly( true );
1188 } 1214 }
1189 } 1215 }
1190 } 1216 }
1191 setModified( true ); 1217 setModified( true );
1192 } else { 1218 } else {
1193 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1219 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1194 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1220 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1195 question, i18n("Ok")) ; 1221 question, i18n("Ok")) ;
1196 1222
1197 } 1223 }
1198 delete calendar; 1224 delete calendar;
1199 updateView(); 1225 updateView();
1200 return ;//syncOK; 1226 return ;//syncOK;
1201#endif 1227#endif
1202} 1228}
1203 1229
1204 1230
1205#include <kabc/stdaddressbook.h> 1231#include <kabc/stdaddressbook.h>
1206bool CalendarView::importBday() 1232bool CalendarView::importBday()
1207{ 1233{
1208 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1234 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1209 KABC::AddressBook::Iterator it; 1235 KABC::AddressBook::Iterator it;
1210 int count = 0; 1236 int count = 0;
1211 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1237 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1212 ++count; 1238 ++count;
1213 } 1239 }
1214 QProgressBar bar(count,0 ); 1240 QProgressBar bar(count,0 );
1215 int w = 300; 1241 int w = 300;
1216 if ( QApplication::desktop()->width() < 320 ) 1242 if ( QApplication::desktop()->width() < 320 )
1217 w = 220; 1243 w = 220;
1218 int h = bar.sizeHint().height() ; 1244 int h = bar.sizeHint().height() ;
1219 int dw = QApplication::desktop()->width(); 1245 int dw = QApplication::desktop()->width();
1220 int dh = QApplication::desktop()->height(); 1246 int dh = QApplication::desktop()->height();
1221 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1247 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1222 bar.show(); 1248 bar.show();
1223 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1249 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1224 qApp->processEvents(); 1250 qApp->processEvents();
1225 count = 0; 1251 count = 0;
1226 int addCount = 0; 1252 int addCount = 0;
1227 KCal::Attendee* a = 0; 1253 KCal::Attendee* a = 0;
1228 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1254 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1229 if ( ! bar.isVisible() ) 1255 if ( ! bar.isVisible() )
1230 return false; 1256 return false;
1231 bar.setProgress( count++ ); 1257 bar.setProgress( count++ );
1232 qApp->processEvents(); 1258 qApp->processEvents();
1233 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1259 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1234 if ( (*it).birthday().date().isValid() ){ 1260 if ( (*it).birthday().date().isValid() ){
1235 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1261 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1236 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1262 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1237 ++addCount; 1263 ++addCount;
1238 } 1264 }
1239 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1265 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1240 if ( anni.isValid() ){ 1266 if ( anni.isValid() ){
1241 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1267 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1242 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1268 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1243 ++addCount; 1269 ++addCount;
1244 } 1270 }
1245 } 1271 }
1246 updateView(); 1272 updateView();
1247 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1273 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1248 return true; 1274 return true;
1249} 1275}
1250 1276
1251bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1277bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1252{ 1278{
1253 //qDebug("addAnni "); 1279 //qDebug("addAnni ");
1254 Event * ev = new Event(); 1280 Event * ev = new Event();
1255 if ( a ) { 1281 if ( a ) {
1256 ev->addAttendee( a ); 1282 ev->addAttendee( a );
1257 } 1283 }
1258 QString kind; 1284 QString kind;
1259 if ( birthday ) 1285 if ( birthday )
1260 kind = i18n( "Birthday" ); 1286 kind = i18n( "Birthday" );
1261 else 1287 else
1262 kind = i18n( "Anniversary" ); 1288 kind = i18n( "Anniversary" );
1263 ev->setSummary( name + " - " + kind ); 1289 ev->setSummary( name + " - " + kind );
1264 ev->setOrganizer( "nobody@nowhere" ); 1290 ev->setOrganizer( "nobody@nowhere" );
1265 ev->setCategories( kind ); 1291 ev->setCategories( kind );
1266 ev->setDtStart( QDateTime(date) ); 1292 ev->setDtStart( QDateTime(date) );
1267 ev->setDtEnd( QDateTime(date) ); 1293 ev->setDtEnd( QDateTime(date) );
1268 ev->setFloats( true ); 1294 ev->setFloats( true );
1269 Recurrence * rec = ev->recurrence(); 1295 Recurrence * rec = ev->recurrence();
1270 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1296 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1271 rec->addYearlyNum( date.month() ); 1297 rec->addYearlyNum( date.month() );
1272 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1298 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1273 delete ev; 1299 delete ev;
1274 return false; 1300 return false;
1275 } 1301 }
1276 return true; 1302 return true;
1277 1303
1278} 1304}
1279bool CalendarView::importQtopia( const QString &categories, 1305bool CalendarView::importQtopia( const QString &categories,
1280 const QString &datebook, 1306 const QString &datebook,
1281 const QString &todolist ) 1307 const QString &todolist )
1282{ 1308{
1283 1309
1284 QtopiaFormat qtopiaFormat; 1310 QtopiaFormat qtopiaFormat;
1285 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1311 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1286 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1312 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1287 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1313 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1288 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1314 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1289 1315
1290 updateView(); 1316 updateView();
1291 return true; 1317 return true;
1292 1318
1293#if 0 1319#if 0
1294 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1320 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1295 mCurrentSyncDevice = "qtopia-XML"; 1321 mCurrentSyncDevice = "qtopia-XML";
1296 if ( KOPrefs::instance()->mAskForPreferences ) 1322 if ( KOPrefs::instance()->mAskForPreferences )
1297 edit_sync_options(); 1323 edit_sync_options();
1298 qApp->processEvents(); 1324 qApp->processEvents();
1299 CalendarLocal* calendar = new CalendarLocal(); 1325 CalendarLocal* calendar = new CalendarLocal();
1300 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1326 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1301 bool syncOK = false; 1327 bool syncOK = false;
1302 QtopiaFormat qtopiaFormat; 1328 QtopiaFormat qtopiaFormat;
1303 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1329 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1304 bool loadOk = true; 1330 bool loadOk = true;
1305 if ( !categories.isEmpty() ) 1331 if ( !categories.isEmpty() )
1306 loadOk = qtopiaFormat.load( calendar, categories ); 1332 loadOk = qtopiaFormat.load( calendar, categories );
1307 if ( loadOk && !datebook.isEmpty() ) 1333 if ( loadOk && !datebook.isEmpty() )
1308 loadOk = qtopiaFormat.load( calendar, datebook ); 1334 loadOk = qtopiaFormat.load( calendar, datebook );
1309 if ( loadOk && !todolist.isEmpty() ) 1335 if ( loadOk && !todolist.isEmpty() )
1310 loadOk = qtopiaFormat.load( calendar, todolist ); 1336 loadOk = qtopiaFormat.load( calendar, todolist );
1311 1337
1312 if ( loadOk ) { 1338 if ( loadOk ) {
1313 getEventViewerDialog()->setSyncMode( true ); 1339 getEventViewerDialog()->setSyncMode( true );
1314 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); 1340 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
1315 getEventViewerDialog()->setSyncMode( false ); 1341 getEventViewerDialog()->setSyncMode( false );
1316 qApp->processEvents(); 1342 qApp->processEvents();
1317 if ( syncOK ) { 1343 if ( syncOK ) {
1318 if ( KOPrefs::instance()->mWriteBackFile ) 1344 if ( KOPrefs::instance()->mWriteBackFile )
1319 { 1345 {
1320 // write back XML file 1346 // write back XML file
1321 1347
1322 } 1348 }
1323 setModified( true ); 1349 setModified( true );
1324 } 1350 }
1325 } else { 1351 } else {
1326 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1352 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1327 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1353 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1328 question, i18n("Ok")) ; 1354 question, i18n("Ok")) ;
1329 } 1355 }
1330 delete calendar; 1356 delete calendar;
1331 updateView(); 1357 updateView();
1332 return syncOK; 1358 return syncOK;
1333 1359
1334 1360
1335#endif 1361#endif
1336 1362
1337} 1363}
1338 1364
1339void CalendarView::setSyncEventsReadOnly() 1365void CalendarView::setSyncEventsReadOnly()
1340{ 1366{
1341 Event * ev; 1367 Event * ev;
1342 QPtrList<Event> eL = mCalendar->rawEvents(); 1368 QPtrList<Event> eL = mCalendar->rawEvents();
1343 ev = eL.first(); 1369 ev = eL.first();
1344 while ( ev ) { 1370 while ( ev ) {
1345 if ( ev->uid().left(21) == QString("last-syncEvent-device") ) 1371 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1346 ev->setReadOnly( true ); 1372 ev->setReadOnly( true );
1347 ev = eL.next(); 1373 ev = eL.next();
1348 } 1374 }
1349} 1375}
1350bool CalendarView::openCalendar(QString filename, bool merge) 1376bool CalendarView::openCalendar(QString filename, bool merge)
1351{ 1377{
1352 1378
1353 if (filename.isEmpty()) { 1379 if (filename.isEmpty()) {
1354 return false; 1380 return false;
1355 } 1381 }
1356 1382
1357 if (!QFile::exists(filename)) { 1383 if (!QFile::exists(filename)) {
1358 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1384 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1359 return false; 1385 return false;
1360 } 1386 }
1361 1387
1362 globalFlagBlockAgenda = 1; 1388 globalFlagBlockAgenda = 1;
1363 if (!merge) mCalendar->close(); 1389 if (!merge) mCalendar->close();
1364 1390
1365 mStorage->setFileName( filename ); 1391 mStorage->setFileName( filename );
1366 1392
1367 if ( mStorage->load(KOPrefs::instance()->mUseQuicksave) ) { 1393 if ( mStorage->load(KOPrefs::instance()->mUseQuicksave) ) {
1368 if ( merge ) ;//setModified( true ); 1394 if ( merge ) ;//setModified( true );
1369 else { 1395 else {
1370 //setModified( true ); 1396 //setModified( true );
1371 mViewManager->setDocumentId( filename ); 1397 mViewManager->setDocumentId( filename );
1372 mDialogManager->setDocumentId( filename ); 1398 mDialogManager->setDocumentId( filename );
1373 mTodoList->setDocumentId( filename ); 1399 mTodoList->setDocumentId( filename );
1374 } 1400 }
1375 globalFlagBlockAgenda = 2; 1401 globalFlagBlockAgenda = 2;
1376 // if ( getLastSyncEvent() ) 1402 // if ( getLastSyncEvent() )
1377 // getLastSyncEvent()->setReadOnly( true ); 1403 // getLastSyncEvent()->setReadOnly( true );
1378 mCalendar->reInitAlarmSettings(); 1404 mCalendar->reInitAlarmSettings();
1379 setSyncEventsReadOnly(); 1405 setSyncEventsReadOnly();
1380 updateUnmanagedViews(); 1406 updateUnmanagedViews();
1381 updateView(); 1407 updateView();
1382 if ( filename != MainWindow::defaultFileName() ) 1408 if ( filename != MainWindow::defaultFileName() )
1383 saveCalendar( MainWindow::defaultFileName() ); 1409 saveCalendar( MainWindow::defaultFileName() );
1384 loadedFileVersion = QDateTime::currentDateTime(); 1410 loadedFileVersion = QDateTime::currentDateTime();
1385 return true; 1411 return true;
1386 } else { 1412 } else {
1387 // while failing to load, the calendar object could 1413 // while failing to load, the calendar object could
1388 // have become partially populated. Clear it out. 1414 // have become partially populated. Clear it out.
1389 if ( !merge ) mCalendar->close(); 1415 if ( !merge ) mCalendar->close();
1390 1416
1391 KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1417 KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1392 1418
1393 globalFlagBlockAgenda = 2; 1419 globalFlagBlockAgenda = 2;
1394 updateView(); 1420 updateView();
1395 } 1421 }
1396 return false; 1422 return false;
1397} 1423}
1398void CalendarView::setLoadedFileVersion(QDateTime dt) 1424void CalendarView::setLoadedFileVersion(QDateTime dt)
1399{ 1425{
1400 loadedFileVersion = dt; 1426 loadedFileVersion = dt;
1401} 1427}
1402bool CalendarView::checkFileChanged(QString fn) 1428bool CalendarView::checkFileChanged(QString fn)
1403{ 1429{
1404 QFileInfo finf ( fn ); 1430 QFileInfo finf ( fn );
1405 if ( !finf.exists() ) 1431 if ( !finf.exists() )
1406 return true; 1432 return true;
1407 QDateTime dt = finf.lastModified (); 1433 QDateTime dt = finf.lastModified ();
1408 if ( dt <= loadedFileVersion ) 1434 if ( dt <= loadedFileVersion )
1409 return false; 1435 return false;
1410 return true; 1436 return true;
1411 1437
1412} 1438}
1413bool CalendarView::checkFileVersion(QString fn) 1439bool CalendarView::checkFileVersion(QString fn)
1414{ 1440{
1415 QFileInfo finf ( fn ); 1441 QFileInfo finf ( fn );
1416 if ( !finf.exists() ) 1442 if ( !finf.exists() )
1417 return true; 1443 return true;
1418 QDateTime dt = finf.lastModified (); 1444 QDateTime dt = finf.lastModified ();
1419 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1445 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1420 //qDebug("file on disk version %s",dt.toString().latin1()); 1446 //qDebug("file on disk version %s",dt.toString().latin1());
1421 if ( dt <= loadedFileVersion ) 1447 if ( dt <= loadedFileVersion )
1422 return true; 1448 return true;
1423 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)) , 1449 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)) ,
1424 i18n("KO/Pi Warning"),i18n("Overwrite"), 1450 i18n("KO/Pi Warning"),i18n("Overwrite"),
1425 i18n("Sync+save")); 1451 i18n("Sync+save"));
1426 1452
1427 if ( km == KMessageBox::Cancel ) 1453 if ( km == KMessageBox::Cancel )
1428 return false; 1454 return false;
1429 if ( km == KMessageBox::Yes ) 1455 if ( km == KMessageBox::Yes )
1430 return true; 1456 return true;
1431 1457
1432 setSyncDevice("deleteaftersync" ); 1458 setSyncDevice("deleteaftersync" );
1433 KOPrefs::instance()->mAskForPreferences = true; 1459 KOPrefs::instance()->mAskForPreferences = true;
1434 KOPrefs::instance()->mSyncAlgoPrefs = 3; 1460 KOPrefs::instance()->mSyncAlgoPrefs = 3;
1435 KOPrefs::instance()->mWriteBackFile = false; 1461 KOPrefs::instance()->mWriteBackFile = false;
1436 KOPrefs::instance()->mWriteBackExistingOnly = false; 1462 KOPrefs::instance()->mWriteBackExistingOnly = false;
1437 KOPrefs::instance()->mShowSyncSummary = false; 1463 KOPrefs::instance()->mShowSyncSummary = false;
1438 syncCalendar( fn, 3 ); 1464 syncCalendar( fn, 3 );
1439 Event * e = getLastSyncEvent(); 1465 Event * e = getLastSyncEvent();
1440 mCalendar->deleteEvent ( e ); 1466 mCalendar->deleteEvent ( e );
1441 updateView(); 1467 updateView();
1442 return true; 1468 return true;
1443} 1469}
1444 1470
1445bool CalendarView::saveCalendar( QString filename ) 1471bool CalendarView::saveCalendar( QString filename )
1446{ 1472{
1447 1473
1448 // Store back all unsaved data into calendar object 1474 // Store back all unsaved data into calendar object
1449 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1475 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1450 if ( mViewManager->currentView() ) 1476 if ( mViewManager->currentView() )
1451 mViewManager->currentView()->flushView(); 1477 mViewManager->currentView()->flushView();
1452 1478
1453 //mStorage->setFileName( filename ); 1479 //mStorage->setFileName( filename );
1454 1480
1455 mStorage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 1481 mStorage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
1456 mStorage->setFileName( filename ); 1482 mStorage->setFileName( filename );
1457 bool success; 1483 bool success;
1458 success = mStorage->save(); 1484 success = mStorage->save();
1459 if ( !success ) { 1485 if ( !success ) {
1460 return false; 1486 return false;
1461 } 1487 }
1462 1488
1463 return true; 1489 return true;
1464} 1490}
1465 1491
1466void CalendarView::closeCalendar() 1492void CalendarView::closeCalendar()
1467{ 1493{
1468 1494
1469 // child windows no longer valid 1495 // child windows no longer valid
1470 emit closingDown(); 1496 emit closingDown();
1471 1497
1472 mCalendar->close(); 1498 mCalendar->close();
1473 setModified(false); 1499 setModified(false);
1474 updateView(); 1500 updateView();
1475} 1501}
1476 1502
1477void CalendarView::archiveCalendar() 1503void CalendarView::archiveCalendar()
1478{ 1504{
1479 mDialogManager->showArchiveDialog(); 1505 mDialogManager->showArchiveDialog();
1480} 1506}
1481 1507
1482 1508
1483void CalendarView::readSettings() 1509void CalendarView::readSettings()
1484{ 1510{
1485 1511
1486 1512
1487 // mViewManager->showAgendaView(); 1513 // mViewManager->showAgendaView();
1488 QString str; 1514 QString str;
1489 //qDebug("CalendarView::readSettings() "); 1515 //qDebug("CalendarView::readSettings() ");
1490 // read settings from the KConfig, supplying reasonable 1516 // read settings from the KConfig, supplying reasonable
1491 // defaults where none are to be found 1517 // defaults where none are to be found
1492 KConfig *config = KOGlobals::config(); 1518 KConfig *config = KOGlobals::config();
1493#ifndef KORG_NOSPLITTER 1519#ifndef KORG_NOSPLITTER
1494 config->setGroup("KOrganizer Geometry"); 1520 config->setGroup("KOrganizer Geometry");
1495 1521
1496 QValueList<int> sizes = config->readIntListEntry("Separator1"); 1522 QValueList<int> sizes = config->readIntListEntry("Separator1");
1497 if (sizes.count() != 2) { 1523 if (sizes.count() != 2) {
1498 sizes << mDateNavigator->minimumSizeHint().width(); 1524 sizes << mDateNavigator->minimumSizeHint().width();
1499 sizes << 300; 1525 sizes << 300;
1500 } 1526 }
1501 mPanner->setSizes(sizes); 1527 mPanner->setSizes(sizes);
1502 1528
1503 sizes = config->readIntListEntry("Separator2"); 1529 sizes = config->readIntListEntry("Separator2");
1504 if ( ( mResourceView && sizes.count() == 4 ) || 1530 if ( ( mResourceView && sizes.count() == 4 ) ||
1505 ( !mResourceView && sizes.count() == 3 ) ) { 1531 ( !mResourceView && sizes.count() == 3 ) ) {
1506 mLeftSplitter->setSizes(sizes); 1532 mLeftSplitter->setSizes(sizes);
1507 } 1533 }
1508#endif 1534#endif
1509 globalFlagBlockAgenda = 1; 1535 globalFlagBlockAgenda = 1;
1510 mViewManager->showAgendaView(); 1536 mViewManager->showAgendaView();
1511 //mViewManager->readSettings( config ); 1537 //mViewManager->readSettings( config );
1512 mTodoList->restoreLayout(config,QString("Todo Layout")); 1538 mTodoList->restoreLayout(config,QString("Todo Layout"));
1513 readFilterSettings(config); 1539 readFilterSettings(config);
1514 config->setGroup( "Views" ); 1540 config->setGroup( "Views" );
1515 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 1541 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
1516 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 1542 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
1517 else if ( dateCount == 7 ) mNavigator->selectWeek(); 1543 else if ( dateCount == 7 ) mNavigator->selectWeek();
1518 else mNavigator->selectDates( dateCount ); 1544 else mNavigator->selectDates( dateCount );
1519 // mViewManager->readSettings( config ); 1545 // mViewManager->readSettings( config );
1520 updateConfig(); 1546 updateConfig();
1521 globalFlagBlockAgenda = 2; 1547 globalFlagBlockAgenda = 2;
1522 mViewManager->readSettings( config ); 1548 mViewManager->readSettings( config );
1523#ifdef DESKTOP_VERSION 1549#ifdef DESKTOP_VERSION
1524 config->setGroup("WidgetLayout"); 1550 config->setGroup("WidgetLayout");
1525 QStringList list; 1551 QStringList list;
1526 list = config->readListEntry("MainLayout"); 1552 list = config->readListEntry("MainLayout");
1527 int x,y,w,h; 1553 int x,y,w,h;
1528 if ( ! list.isEmpty() ) { 1554 if ( ! list.isEmpty() ) {
1529 x = list[0].toInt(); 1555 x = list[0].toInt();
1530 y = list[1].toInt(); 1556 y = list[1].toInt();
1531 w = list[2].toInt(); 1557 w = list[2].toInt();
1532 h = list[3].toInt(); 1558 h = list[3].toInt();
1533 topLevelWidget()->setGeometry(x,y,w,h); 1559 topLevelWidget()->setGeometry(x,y,w,h);
1534 1560
1535 } else { 1561 } else {
1536 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 1562 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
1537 } 1563 }
1538 list = config->readListEntry("EditEventLayout"); 1564 list = config->readListEntry("EditEventLayout");
1539 if ( ! list.isEmpty() ) { 1565 if ( ! list.isEmpty() ) {
1540 x = list[0].toInt(); 1566 x = list[0].toInt();
1541 y = list[1].toInt(); 1567 y = list[1].toInt();
1542 w = list[2].toInt(); 1568 w = list[2].toInt();
1543 h = list[3].toInt(); 1569 h = list[3].toInt();
1544 mEventEditor->setGeometry(x,y,w,h); 1570 mEventEditor->setGeometry(x,y,w,h);
1545 1571
1546 } 1572 }
1547 list = config->readListEntry("EditTodoLayout"); 1573 list = config->readListEntry("EditTodoLayout");
1548 if ( ! list.isEmpty() ) { 1574 if ( ! list.isEmpty() ) {
1549 x = list[0].toInt(); 1575 x = list[0].toInt();
1550 y = list[1].toInt(); 1576 y = list[1].toInt();
1551 w = list[2].toInt(); 1577 w = list[2].toInt();
1552 h = list[3].toInt(); 1578 h = list[3].toInt();
1553 mTodoEditor->setGeometry(x,y,w,h); 1579 mTodoEditor->setGeometry(x,y,w,h);
1554 1580
1555 } 1581 }
1556 list = config->readListEntry("ViewerLayout"); 1582 list = config->readListEntry("ViewerLayout");
1557 if ( ! list.isEmpty() ) { 1583 if ( ! list.isEmpty() ) {
1558 x = list[0].toInt(); 1584 x = list[0].toInt();
1559 y = list[1].toInt(); 1585 y = list[1].toInt();
1560 w = list[2].toInt(); 1586 w = list[2].toInt();
1561 h = list[3].toInt(); 1587 h = list[3].toInt();
1562 getEventViewerDialog()->setGeometry(x,y,w,h); 1588 getEventViewerDialog()->setGeometry(x,y,w,h);
1563 } 1589 }
1564#endif 1590#endif
1565 1591
1566} 1592}
1567 1593
1568 1594
1569void CalendarView::writeSettings() 1595void CalendarView::writeSettings()
1570{ 1596{
1571 // kdDebug() << "CalendarView::writeSettings" << endl; 1597 // kdDebug() << "CalendarView::writeSettings" << endl;
1572 1598
1573 KConfig *config = KOGlobals::config(); 1599 KConfig *config = KOGlobals::config();
1574 1600
1575#ifndef KORG_NOSPLITTER 1601#ifndef KORG_NOSPLITTER
1576 config->setGroup("KOrganizer Geometry"); 1602 config->setGroup("KOrganizer Geometry");
1577 1603
1578 QValueList<int> list = mPanner->sizes(); 1604 QValueList<int> list = mPanner->sizes();
1579 config->writeEntry("Separator1",list); 1605 config->writeEntry("Separator1",list);
1580 1606
1581 list = mLeftSplitter->sizes(); 1607 list = mLeftSplitter->sizes();
1582 config->writeEntry("Separator2",list); 1608 config->writeEntry("Separator2",list);
1583#endif 1609#endif
1584 1610
1585 mViewManager->writeSettings( config ); 1611 mViewManager->writeSettings( config );
1586 mTodoList->saveLayout(config,QString("Todo Layout")); 1612 mTodoList->saveLayout(config,QString("Todo Layout"));
1587 mDialogManager->writeSettings( config ); 1613 mDialogManager->writeSettings( config );
1588 //KOPrefs::instance()->usrWriteConfig(); 1614 //KOPrefs::instance()->usrWriteConfig();
1589 KOPrefs::instance()->writeConfig(); 1615 KOPrefs::instance()->writeConfig();
1590 1616
1591 writeFilterSettings(config); 1617 writeFilterSettings(config);
1592 1618
1593 config->setGroup( "Views" ); 1619 config->setGroup( "Views" );
1594 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 1620 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
1595 1621
1596#ifdef DESKTOP_VERSION 1622#ifdef DESKTOP_VERSION
1597 config->setGroup("WidgetLayout"); 1623 config->setGroup("WidgetLayout");
1598 QStringList list ;//= config->readListEntry("MainLayout"); 1624 QStringList list ;//= config->readListEntry("MainLayout");
1599 int x,y,w,h; 1625 int x,y,w,h;
1600 QWidget* wid; 1626 QWidget* wid;
1601 wid = topLevelWidget(); 1627 wid = topLevelWidget();
1602 x = wid->geometry().x(); 1628 x = wid->geometry().x();
1603 y = wid->geometry().y(); 1629 y = wid->geometry().y();
1604 w = wid->width(); 1630 w = wid->width();
1605 h = wid->height(); 1631 h = wid->height();
1606 list.clear(); 1632 list.clear();
1607 list << QString::number( x ); 1633 list << QString::number( x );
1608 list << QString::number( y ); 1634 list << QString::number( y );
1609 list << QString::number( w ); 1635 list << QString::number( w );
1610 list << QString::number( h ); 1636 list << QString::number( h );
1611 config->writeEntry("MainLayout",list ); 1637 config->writeEntry("MainLayout",list );
1612 1638
1613 wid = mEventEditor; 1639 wid = mEventEditor;
1614 x = wid->geometry().x(); 1640 x = wid->geometry().x();
1615 y = wid->geometry().y(); 1641 y = wid->geometry().y();
1616 w = wid->width(); 1642 w = wid->width();
1617 h = wid->height(); 1643 h = wid->height();
1618 list.clear(); 1644 list.clear();
1619 list << QString::number( x ); 1645 list << QString::number( x );
1620 list << QString::number( y ); 1646 list << QString::number( y );
1621 list << QString::number( w ); 1647 list << QString::number( w );
1622 list << QString::number( h ); 1648 list << QString::number( h );
1623 config->writeEntry("EditEventLayout",list ); 1649 config->writeEntry("EditEventLayout",list );
1624 1650
1625 wid = mTodoEditor; 1651 wid = mTodoEditor;
1626 x = wid->geometry().x(); 1652 x = wid->geometry().x();
1627 y = wid->geometry().y(); 1653 y = wid->geometry().y();
1628 w = wid->width(); 1654 w = wid->width();
1629 h = wid->height(); 1655 h = wid->height();
1630 list.clear(); 1656 list.clear();
1631 list << QString::number( x ); 1657 list << QString::number( x );
1632 list << QString::number( y ); 1658 list << QString::number( y );
1633 list << QString::number( w ); 1659 list << QString::number( w );
1634 list << QString::number( h ); 1660 list << QString::number( h );
1635 config->writeEntry("EditTodoLayout",list ); 1661 config->writeEntry("EditTodoLayout",list );
1636 wid = getEventViewerDialog(); 1662 wid = getEventViewerDialog();
1637 x = wid->geometry().x(); 1663 x = wid->geometry().x();
1638 y = wid->geometry().y(); 1664 y = wid->geometry().y();
1639 w = wid->width(); 1665 w = wid->width();
1640 h = wid->height(); 1666 h = wid->height();
1641 list.clear(); 1667 list.clear();
1642 list << QString::number( x ); 1668 list << QString::number( x );
1643 list << QString::number( y ); 1669 list << QString::number( y );
1644 list << QString::number( w ); 1670 list << QString::number( w );
1645 list << QString::number( h ); 1671 list << QString::number( h );
1646 config->writeEntry("ViewerLayout",list ); 1672 config->writeEntry("ViewerLayout",list );
1647 wid = mDialogManager->getSearchDialog(); 1673 wid = mDialogManager->getSearchDialog();
1648 if ( wid ) { 1674 if ( wid ) {
1649 x = wid->geometry().x(); 1675 x = wid->geometry().x();
1650 y = wid->geometry().y(); 1676 y = wid->geometry().y();
1651 w = wid->width(); 1677 w = wid->width();
1652 h = wid->height(); 1678 h = wid->height();
1653 list.clear(); 1679 list.clear();
1654 list << QString::number( x ); 1680 list << QString::number( x );
1655 list << QString::number( y ); 1681 list << QString::number( y );
1656 list << QString::number( w ); 1682 list << QString::number( w );
1657 list << QString::number( h ); 1683 list << QString::number( h );
1658 config->writeEntry("SearchLayout",list ); 1684 config->writeEntry("SearchLayout",list );
1659 } 1685 }
1660#endif 1686#endif
1661 1687
1662 1688
1663 config->sync(); 1689 config->sync();
1664} 1690}
1665 1691
1666void CalendarView::readFilterSettings(KConfig *config) 1692void CalendarView::readFilterSettings(KConfig *config)
1667{ 1693{
1668 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 1694 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
1669 1695
1670 mFilters.clear(); 1696 mFilters.clear();
1671 1697
1672 config->setGroup("General"); 1698 config->setGroup("General");
1673 QStringList filterList = config->readListEntry("CalendarFilters"); 1699 QStringList filterList = config->readListEntry("CalendarFilters");
1674 1700
1675 QStringList::ConstIterator it = filterList.begin(); 1701 QStringList::ConstIterator it = filterList.begin();
1676 QStringList::ConstIterator end = filterList.end(); 1702 QStringList::ConstIterator end = filterList.end();
1677 while(it != end) { 1703 while(it != end) {
1678 // kdDebug() << " filter: " << (*it) << endl; 1704 // kdDebug() << " filter: " << (*it) << endl;
1679 1705
1680 CalFilter *filter; 1706 CalFilter *filter;
1681 filter = new CalFilter(*it); 1707 filter = new CalFilter(*it);
1682 config->setGroup("Filter_" + (*it)); 1708 config->setGroup("Filter_" + (*it));
1683 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 1709 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
1684 filter->setCriteria(config->readNumEntry("Criteria",0)); 1710 filter->setCriteria(config->readNumEntry("Criteria",0));
1685 filter->setCategoryList(config->readListEntry("CategoryList")); 1711 filter->setCategoryList(config->readListEntry("CategoryList"));
1686 mFilters.append(filter); 1712 mFilters.append(filter);
1687 1713
1688 ++it; 1714 ++it;
1689 } 1715 }
1690 1716
1691 if (mFilters.count() == 0) { 1717 if (mFilters.count() == 0) {
1692 CalFilter *filter = new CalFilter(i18n("Default")); 1718 CalFilter *filter = new CalFilter(i18n("Default"));
1693 mFilters.append(filter); 1719 mFilters.append(filter);
1694 } 1720 }
1695 mFilterView->updateFilters(); 1721 mFilterView->updateFilters();
1696 config->setGroup("FilterView"); 1722 config->setGroup("FilterView");
1697 1723
1698 mFilterView->blockSignals(true); 1724 mFilterView->blockSignals(true);
1699 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 1725 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
1700 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 1726 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
1701 mFilterView->blockSignals(false); 1727 mFilterView->blockSignals(false);
1702 // We do it manually to avoid it being done twice by the above calls 1728 // We do it manually to avoid it being done twice by the above calls
1703 updateFilter(); 1729 updateFilter();
1704} 1730}
1705 1731
1706void CalendarView::writeFilterSettings(KConfig *config) 1732void CalendarView::writeFilterSettings(KConfig *config)
1707{ 1733{
1708 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 1734 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
1709 1735
1710 QStringList filterList; 1736 QStringList filterList;
1711 1737
1712 CalFilter *filter = mFilters.first(); 1738 CalFilter *filter = mFilters.first();
1713 while(filter) { 1739 while(filter) {
1714 // kdDebug() << " fn: " << filter->name() << endl; 1740 // kdDebug() << " fn: " << filter->name() << endl;
1715 filterList << filter->name(); 1741 filterList << filter->name();
1716 config->setGroup("Filter_" + filter->name()); 1742 config->setGroup("Filter_" + filter->name());
1717 config->writeEntry("Criteria",filter->criteria()); 1743 config->writeEntry("Criteria",filter->criteria());
1718 config->writeEntry("CategoryList",filter->categoryList()); 1744 config->writeEntry("CategoryList",filter->categoryList());
1719 filter = mFilters.next(); 1745 filter = mFilters.next();
1720 } 1746 }
1721 config->setGroup("General"); 1747 config->setGroup("General");
1722 config->writeEntry("CalendarFilters",filterList); 1748 config->writeEntry("CalendarFilters",filterList);
1723 1749
1724 config->setGroup("FilterView"); 1750 config->setGroup("FilterView");
1725 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 1751 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
1726 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 1752 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
1727} 1753}
1728 1754
1729 1755
1730void CalendarView::goToday() 1756void CalendarView::goToday()
1731{ 1757{
1732 mNavigator->selectToday(); 1758 mNavigator->selectToday();
1733} 1759}
1734 1760
1735void CalendarView::goNext() 1761void CalendarView::goNext()
1736{ 1762{
1737 mNavigator->selectNext(); 1763 mNavigator->selectNext();
1738} 1764}
1739 1765
1740void CalendarView::goPrevious() 1766void CalendarView::goPrevious()
1741{ 1767{
1742 mNavigator->selectPrevious(); 1768 mNavigator->selectPrevious();
1743} 1769}
1744void CalendarView::goNextMonth() 1770void CalendarView::goNextMonth()
1745{ 1771{
1746 mNavigator->selectNextMonth(); 1772 mNavigator->selectNextMonth();
1747} 1773}
1748 1774
1749void CalendarView::goPreviousMonth() 1775void CalendarView::goPreviousMonth()
1750{ 1776{
1751 mNavigator->selectPreviousMonth(); 1777 mNavigator->selectPreviousMonth();
1752} 1778}
1753void CalendarView::writeLocale() 1779void CalendarView::writeLocale()
1754{ 1780{
1755 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); 1781 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime );
1756 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); 1782 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday );
1757 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); 1783 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate );
1758 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); 1784 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage );
1759 QString dummy = KOPrefs::instance()->mUserDateFormatLong; 1785 QString dummy = KOPrefs::instance()->mUserDateFormatLong;
1760 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 1786 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
1761 dummy = KOPrefs::instance()->mUserDateFormatShort; 1787 dummy = KOPrefs::instance()->mUserDateFormatShort;
1762 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 1788 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
1763 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, 1789 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving,
1764 KOPrefs::instance()->mDaylightsavingStart, 1790 KOPrefs::instance()->mDaylightsavingStart,
1765 KOPrefs::instance()->mDaylightsavingEnd ); 1791 KOPrefs::instance()->mDaylightsavingEnd );
1766 KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId ); 1792 KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId );
1767} 1793}
1768void CalendarView::updateConfig() 1794void CalendarView::updateConfig()
1769{ 1795{
1770 writeLocale(); 1796 writeLocale();
1771 if ( KOPrefs::instance()->mUseAppColors ) 1797 if ( KOPrefs::instance()->mUseAppColors )
1772 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 1798 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
1773 emit configChanged(); 1799 emit configChanged();
1774 mTodoList->updateConfig(); 1800 mTodoList->updateConfig();
1775 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 1801 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
1776 mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1802 mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1777 // To make the "fill window" configurations work 1803 // To make the "fill window" configurations work
1778 //mViewManager->raiseCurrentView(); 1804 //mViewManager->raiseCurrentView();
1779} 1805}
1780 1806
1781 1807
1782void CalendarView::eventChanged(Event *event) 1808void CalendarView::eventChanged(Event *event)
1783{ 1809{
1784 changeEventDisplay(event,KOGlobals::EVENTEDITED); 1810 changeEventDisplay(event,KOGlobals::EVENTEDITED);
1785 //updateUnmanagedViews(); 1811 //updateUnmanagedViews();
1786} 1812}
1787 1813
1788void CalendarView::eventAdded(Event *event) 1814void CalendarView::eventAdded(Event *event)
1789{ 1815{
1790 changeEventDisplay(event,KOGlobals::EVENTADDED); 1816 changeEventDisplay(event,KOGlobals::EVENTADDED);
1791} 1817}
1792 1818
1793void CalendarView::eventToBeDeleted(Event *) 1819void CalendarView::eventToBeDeleted(Event *)
1794{ 1820{
1795 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 1821 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
1796} 1822}
1797 1823
1798void CalendarView::eventDeleted() 1824void CalendarView::eventDeleted()
1799{ 1825{
1800 changeEventDisplay(0,KOGlobals::EVENTDELETED); 1826 changeEventDisplay(0,KOGlobals::EVENTDELETED);
1801} 1827}
1802void CalendarView::changeTodoDisplay(Todo *which, int action) 1828void CalendarView::changeTodoDisplay(Todo *which, int action)
1803{ 1829{
1804 changeIncidenceDisplay((Incidence *)which, action); 1830 changeIncidenceDisplay((Incidence *)which, action);
1805} 1831}
1806void CalendarView::checkZaurusId( int id, bool todo ) 1832void CalendarView::checkZaurusId( int id, bool todo )
1807{ 1833{
1808 if ( id >= 0 ) { 1834 if ( id >= 0 ) {
1809 Incidence* lse = mCalendar->event( "last-syncEvent-device-Sharp-DTM"); 1835 Incidence* lse = mCalendar->event( "last-syncEvent-Sharp-DTM");
1810 if ( lse ) { 1836 if ( lse ) {
1811 QString des = lse->description(); 1837 QString des = lse->description();
1812 QString pref = "e"; 1838 QString pref = "e";
1813 if ( todo ) 1839 if ( todo )
1814 pref = "t"; 1840 pref = "t";
1815 des += pref+ QString::number ( id ) + ","; 1841 des += pref+ QString::number ( id ) + ",";
1816 lse->setReadOnly( false ); 1842 lse->setReadOnly( false );
1817 lse->setDescription( des ); 1843 lse->setDescription( des );
1818 lse->setReadOnly( true ); 1844 lse->setReadOnly( true );
1819 } 1845 }
1820 } 1846 }
1821} 1847}
1822void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 1848void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
1823{ 1849{
1824 updateUnmanagedViews(); 1850 updateUnmanagedViews();
1825 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 1851 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
1826 if ( action == KOGlobals::EVENTDELETED ) { //delete 1852 if ( action == KOGlobals::EVENTDELETED ) { //delete
1827 mCalendar->checkAlarmForIncidence( 0, true ); 1853 mCalendar->checkAlarmForIncidence( 0, true );
1828 if ( mEventViewerDialog ) 1854 if ( mEventViewerDialog )
1829 mEventViewerDialog->hide(); 1855 mEventViewerDialog->hide();
1830 } 1856 }
1831 else 1857 else
1832 mCalendar->checkAlarmForIncidence( which , false ); 1858 mCalendar->checkAlarmForIncidence( which , false );
1833} 1859}
1834 1860
1835// most of the changeEventDisplays() right now just call the view's 1861// most of the changeEventDisplays() right now just call the view's
1836// total update mode, but they SHOULD be recoded to be more refresh-efficient. 1862// total update mode, but they SHOULD be recoded to be more refresh-efficient.
1837void CalendarView::changeEventDisplay(Event *which, int action) 1863void CalendarView::changeEventDisplay(Event *which, int action)
1838{ 1864{
1839 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 1865 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
1840 changeIncidenceDisplay((Incidence *)which, action); 1866 changeIncidenceDisplay((Incidence *)which, action);
1841 mDateNavigator->updateView(); 1867 mDateNavigator->updateView();
1842 //mDialogManager->updateSearchDialog(); 1868 //mDialogManager->updateSearchDialog();
1843 1869
1844 if (which) { 1870 if (which) {
1845 // If there is an event view visible update the display 1871 // If there is an event view visible update the display
1846 mViewManager->currentView()->changeEventDisplay(which,action); 1872 mViewManager->currentView()->changeEventDisplay(which,action);
1847 // TODO: check, if update needed 1873 // TODO: check, if update needed
1848 // if (which->getTodoStatus()) { 1874 // if (which->getTodoStatus()) {
1849 mTodoList->updateView(); 1875 mTodoList->updateView();
1850 // } 1876 // }
1851 } else { 1877 } else {
1852 mViewManager->currentView()->updateView(); 1878 mViewManager->currentView()->updateView();
1853 } 1879 }
1854} 1880}
1855 1881
1856 1882
1857void CalendarView::updateTodoViews() 1883void CalendarView::updateTodoViews()
1858{ 1884{
1859 1885
1860 mTodoList->updateView(); 1886 mTodoList->updateView();
1861 mViewManager->currentView()->updateView(); 1887 mViewManager->currentView()->updateView();
1862 1888
1863} 1889}
1864 1890
1865 1891
1866void CalendarView::updateView(const QDate &start, const QDate &end) 1892void CalendarView::updateView(const QDate &start, const QDate &end)
1867{ 1893{
1868 mTodoList->updateView(); 1894 mTodoList->updateView();
1869 mViewManager->updateView(start, end); 1895 mViewManager->updateView(start, end);
1870 //mDateNavigator->updateView(); 1896 //mDateNavigator->updateView();
1871} 1897}
1872 1898
1873void CalendarView::updateView() 1899void CalendarView::updateView()
1874{ 1900{
1875 DateList tmpList = mNavigator->selectedDates(); 1901 DateList tmpList = mNavigator->selectedDates();
1876 1902
1877 // We assume that the navigator only selects consecutive days. 1903 // We assume that the navigator only selects consecutive days.
1878 updateView( tmpList.first(), tmpList.last() ); 1904 updateView( tmpList.first(), tmpList.last() );
1879} 1905}
1880 1906
1881void CalendarView::updateUnmanagedViews() 1907void CalendarView::updateUnmanagedViews()
1882{ 1908{
1883 mDateNavigator->updateDayMatrix(); 1909 mDateNavigator->updateDayMatrix();
1884} 1910}
1885 1911
1886int CalendarView::msgItemDelete() 1912int CalendarView::msgItemDelete()
1887{ 1913{
1888 return KMessageBox::warningContinueCancel(this, 1914 return KMessageBox::warningContinueCancel(this,
1889 i18n("This item will be\npermanently deleted."), 1915 i18n("This item will be\npermanently deleted."),
1890 i18n("KO/Pi Confirmation"),i18n("Delete")); 1916 i18n("KO/Pi Confirmation"),i18n("Delete"));
1891} 1917}
1892 1918
1893 1919
1894void CalendarView::edit_cut() 1920void CalendarView::edit_cut()
1895{ 1921{
1896 Event *anEvent=0; 1922 Event *anEvent=0;
1897 1923
1898 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 1924 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
1899 1925
1900 if (mViewManager->currentView()->isEventView()) { 1926 if (mViewManager->currentView()->isEventView()) {
1901 if ( incidence && incidence->type() == "Event" ) { 1927 if ( incidence && incidence->type() == "Event" ) {
1902 anEvent = static_cast<Event *>(incidence); 1928 anEvent = static_cast<Event *>(incidence);
1903 } 1929 }
1904 } 1930 }
1905 1931
1906 if (!anEvent) { 1932 if (!anEvent) {
1907 KNotifyClient::beep(); 1933 KNotifyClient::beep();
1908 return; 1934 return;
1909 } 1935 }
1910 DndFactory factory( mCalendar ); 1936 DndFactory factory( mCalendar );
1911 factory.cutEvent(anEvent); 1937 factory.cutEvent(anEvent);
1912 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 1938 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
1913} 1939}
1914 1940
1915void CalendarView::edit_copy() 1941void CalendarView::edit_copy()
1916{ 1942{
1917 Event *anEvent=0; 1943 Event *anEvent=0;
1918 1944
1919 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 1945 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
1920 1946
1921 if (mViewManager->currentView()->isEventView()) { 1947 if (mViewManager->currentView()->isEventView()) {
1922 if ( incidence && incidence->type() == "Event" ) { 1948 if ( incidence && incidence->type() == "Event" ) {
1923 anEvent = static_cast<Event *>(incidence); 1949 anEvent = static_cast<Event *>(incidence);
1924 } 1950 }
1925 } 1951 }
1926 1952
1927 if (!anEvent) { 1953 if (!anEvent) {
1928 KNotifyClient::beep(); 1954 KNotifyClient::beep();
1929 return; 1955 return;
1930 } 1956 }
1931 DndFactory factory( mCalendar ); 1957 DndFactory factory( mCalendar );
1932 factory.copyEvent(anEvent); 1958 factory.copyEvent(anEvent);
1933} 1959}
1934 1960
1935void CalendarView::edit_paste() 1961void CalendarView::edit_paste()
1936{ 1962{
1937 QDate date = mNavigator->selectedDates().first(); 1963 QDate date = mNavigator->selectedDates().first();
1938 1964
1939 DndFactory factory( mCalendar ); 1965 DndFactory factory( mCalendar );
1940 Event *pastedEvent = factory.pasteEvent( date ); 1966 Event *pastedEvent = factory.pasteEvent( date );
1941 1967
1942 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 1968 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
1943} 1969}
1944 1970
1945void CalendarView::edit_options() 1971void CalendarView::edit_options()
1946{ 1972{
1947 mDialogManager->showOptionsDialog(); 1973 mDialogManager->showOptionsDialog();
1948 //writeSettings(); 1974 //writeSettings();
1949} 1975}
1950void CalendarView::edit_sync_options() 1976void CalendarView::edit_sync_options()
1951{ 1977{
1952 //mDialogManager->showSyncOptions(); 1978 //mDialogManager->showSyncOptions();
1953 //KOPrefs::instance()->mSyncAlgoPrefs 1979 //KOPrefs::instance()->mSyncAlgoPrefs
1954 QDialog dia( this, "dia", true ); 1980 QDialog dia( this, "dia", true );
1955 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); 1981 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice );
1956 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); 1982 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia);
1957 QVBoxLayout lay ( &dia ); 1983 QVBoxLayout lay ( &dia );
1958 lay.setSpacing( 2 ); 1984 lay.setSpacing( 2 );
1959 lay.setMargin( 3 ); 1985 lay.setMargin( 3 );
1960 lay.addWidget(&gr); 1986 lay.addWidget(&gr);
1961 QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); 1987 QRadioButton loc ( i18n("Take local entry on conflict"), &gr );
1962 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); 1988 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr );
1963 QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); 1989 QRadioButton newest( i18n("Take newest entry on conflict"), &gr );
1964 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); 1990 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr );
1965 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); 1991 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr );
1966 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); 1992 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr );
1967 //QRadioButton both( i18n("Take both on conflict"), &gr ); 1993 //QRadioButton both( i18n("Take both on conflict"), &gr );
1968 QPushButton pb ( "OK", &dia); 1994 QPushButton pb ( "OK", &dia);
1969 lay.addWidget( &pb ); 1995 lay.addWidget( &pb );
1970 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 1996 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
1971 switch ( KOPrefs::instance()->mSyncAlgoPrefs ) { 1997 switch ( KOPrefs::instance()->mSyncAlgoPrefs ) {
1972 case 0: 1998 case 0:
1973 loc.setChecked( true); 1999 loc.setChecked( true);
1974 break; 2000 break;
1975 case 1: 2001 case 1:
1976 rem.setChecked( true ); 2002 rem.setChecked( true );
1977 break; 2003 break;
1978 case 2: 2004 case 2:
1979 newest.setChecked( true); 2005 newest.setChecked( true);
1980 break; 2006 break;
1981 case 3: 2007 case 3:
1982 ask.setChecked( true); 2008 ask.setChecked( true);
1983 break; 2009 break;
1984 case 4: 2010 case 4:
1985 f_loc.setChecked( true); 2011 f_loc.setChecked( true);
1986 break; 2012 break;
1987 case 5: 2013 case 5:
1988 f_rem.setChecked( true); 2014 f_rem.setChecked( true);
1989 break; 2015 break;
1990 case 6: 2016 case 6:
1991 // both.setChecked( true); 2017 // both.setChecked( true);
1992 break; 2018 break;
1993 default: 2019 default:
1994 break; 2020 break;
1995 } 2021 }
1996 if ( dia.exec() ) { 2022 if ( dia.exec() ) {
1997 KOPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; 2023 KOPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ;
1998 } 2024 }
1999 2025
2000} 2026}
2001 2027
2002void CalendarView::slotSelectPickerDate( QDate d) 2028void CalendarView::slotSelectPickerDate( QDate d)
2003{ 2029{
2004 mDateFrame->hide(); 2030 mDateFrame->hide();
2005 if ( mDatePickerMode == 1 ) { 2031 if ( mDatePickerMode == 1 ) {
2006 mNavigator->slotDaySelect( d ); 2032 mNavigator->slotDaySelect( d );
2007 } else if ( mDatePickerMode == 2 ) { 2033 } else if ( mDatePickerMode == 2 ) {
2008 if ( mMoveIncidence->type() == "Todo" ) { 2034 if ( mMoveIncidence->type() == "Todo" ) {
2009 Todo * to = (Todo *) mMoveIncidence; 2035 Todo * to = (Todo *) mMoveIncidence;
2010 QTime tim; 2036 QTime tim;
2011 if ( to->hasDueDate() ) 2037 if ( to->hasDueDate() )
2012 tim = to->dtDue().time(); 2038 tim = to->dtDue().time();
2013 else { 2039 else {
2014 tim = QTime ( 0,0,0 ); 2040 tim = QTime ( 0,0,0 );
2015 to->setFloats( true ); 2041 to->setFloats( true );
2016 to->setHasDueDate( true ); 2042 to->setHasDueDate( true );
2017 } 2043 }
2018 QDateTime dt ( d,tim ); 2044 QDateTime dt ( d,tim );
2019 to->setDtDue( dt ); 2045 to->setDtDue( dt );
2020 todoChanged( to ); 2046 todoChanged( to );
2021 } else { 2047 } else {
2022 QTime tim = mMoveIncidence->dtStart().time(); 2048 QTime tim = mMoveIncidence->dtStart().time();
2023 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2049 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2024 QDateTime dt ( d,tim ); 2050 QDateTime dt ( d,tim );
2025 mMoveIncidence->setDtStart( dt ); 2051 mMoveIncidence->setDtStart( dt );
2026 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2052 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2027 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2053 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2028 } 2054 }
2029 2055
2030 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2056 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2031 } 2057 }
2032} 2058}
2033 2059
2034void CalendarView::removeCategories() 2060void CalendarView::removeCategories()
2035{ 2061{
2036 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2062 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2037 QStringList catList = KOPrefs::instance()->mCustomCategories; 2063 QStringList catList = KOPrefs::instance()->mCustomCategories;
2038 QStringList catIncList; 2064 QStringList catIncList;
2039 QStringList newCatList; 2065 QStringList newCatList;
2040 Incidence* inc = incList.first(); 2066 Incidence* inc = incList.first();
2041 int i; 2067 int i;
2042 int count = 0; 2068 int count = 0;
2043 while ( inc ) { 2069 while ( inc ) {
2044 newCatList.clear(); 2070 newCatList.clear();
2045 catIncList = inc->categories() ; 2071 catIncList = inc->categories() ;
2046 for( i = 0; i< catIncList.count(); ++i ) { 2072 for( i = 0; i< catIncList.count(); ++i ) {
2047 if ( catList.contains (catIncList[i])) 2073 if ( catList.contains (catIncList[i]))
2048 newCatList.append( catIncList[i] ); 2074 newCatList.append( catIncList[i] );
2049 } 2075 }
2050 newCatList.sort(); 2076 newCatList.sort();
2051 inc->setCategories( newCatList.join(",") ); 2077 inc->setCategories( newCatList.join(",") );
2052 inc = incList.next(); 2078 inc = incList.next();
2053 } 2079 }
2054} 2080}
2055 2081
2056int CalendarView::addCategories() 2082int CalendarView::addCategories()
2057{ 2083{
2058 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2084 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2059 QStringList catList = KOPrefs::instance()->mCustomCategories; 2085 QStringList catList = KOPrefs::instance()->mCustomCategories;
2060 QStringList catIncList; 2086 QStringList catIncList;
2061 Incidence* inc = incList.first(); 2087 Incidence* inc = incList.first();
2062 int i; 2088 int i;
2063 int count = 0; 2089 int count = 0;
2064 while ( inc ) { 2090 while ( inc ) {
2065 catIncList = inc->categories() ; 2091 catIncList = inc->categories() ;
2066 for( i = 0; i< catIncList.count(); ++i ) { 2092 for( i = 0; i< catIncList.count(); ++i ) {
2067 if ( !catList.contains (catIncList[i])) { 2093 if ( !catList.contains (catIncList[i])) {
2068 catList.append( catIncList[i] ); 2094 catList.append( catIncList[i] );
2069 //qDebug("add cat %s ", catIncList[i].latin1()); 2095 //qDebug("add cat %s ", catIncList[i].latin1());
2070 ++count; 2096 ++count;
2071 } 2097 }
2072 } 2098 }
2073 inc = incList.next(); 2099 inc = incList.next();
2074 } 2100 }
2075 catList.sort(); 2101 catList.sort();
2076 KOPrefs::instance()->mCustomCategories = catList; 2102 KOPrefs::instance()->mCustomCategories = catList;
2077 return count; 2103 return count;
2078} 2104}
2079 2105
2080void CalendarView::manageCategories() 2106void CalendarView::manageCategories()
2081{ 2107{
2082 KOCatPrefs* cp = new KOCatPrefs(); 2108 KOCatPrefs* cp = new KOCatPrefs();
2083 cp->show(); 2109 cp->show();
2084 int w =cp->sizeHint().width() ; 2110 int w =cp->sizeHint().width() ;
2085 int h = cp->sizeHint().height() ; 2111 int h = cp->sizeHint().height() ;
2086 int dw = QApplication::desktop()->width(); 2112 int dw = QApplication::desktop()->width();
2087 int dh = QApplication::desktop()->height(); 2113 int dh = QApplication::desktop()->height();
2088 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2114 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2089 if ( !cp->exec() ) { 2115 if ( !cp->exec() ) {
2090 delete cp; 2116 delete cp;
2091 return; 2117 return;
2092 } 2118 }
2093 int count = 0; 2119 int count = 0;
2094 if ( cp->addCat() ) { 2120 if ( cp->addCat() ) {
2095 count = addCategories(); 2121 count = addCategories();
2096 if ( count ) { 2122 if ( count ) {
2097 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2123 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2098 writeSettings(); 2124 writeSettings();
2099 } 2125 }
2100 } else { 2126 } else {
2101 removeCategories(); 2127 removeCategories();
2102 updateView(); 2128 updateView();
2103 } 2129 }
2104 delete cp; 2130 delete cp;
2105} 2131}
2106 2132
2107void CalendarView::beamIncidence(Incidence * Inc) 2133void CalendarView::beamIncidence(Incidence * Inc)
2108{ 2134{
2109 QPtrList<Incidence> delSel ; 2135 QPtrList<Incidence> delSel ;
2110 delSel.append(Inc); 2136 delSel.append(Inc);
2111 beamIncidenceList( delSel ); 2137 beamIncidenceList( delSel );
2112} 2138}
2113void CalendarView::beamCalendar() 2139void CalendarView::beamCalendar()
2114{ 2140{
2115 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2141 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2116 //qDebug("beamCalendar() "); 2142 //qDebug("beamCalendar() ");
2117 beamIncidenceList( delSel ); 2143 beamIncidenceList( delSel );
2118} 2144}
2119void CalendarView::beamFilteredCalendar() 2145void CalendarView::beamFilteredCalendar()
2120{ 2146{
2121 QPtrList<Incidence> delSel = mCalendar->incidences(); 2147 QPtrList<Incidence> delSel = mCalendar->incidences();
2122 //qDebug("beamFilteredCalendar() "); 2148 //qDebug("beamFilteredCalendar() ");
2123 beamIncidenceList( delSel ); 2149 beamIncidenceList( delSel );
2124} 2150}
2125void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2151void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2126{ 2152{
2127 if ( beamDialog->exec () == QDialog::Rejected ) 2153 if ( beamDialog->exec () == QDialog::Rejected )
2128 return; 2154 return;
2129 2155
2130 QString fn = "/tmp/kopibeamfile"; 2156 QString fn = "/tmp/kopibeamfile";
2131 QString mes; 2157 QString mes;
2132 bool createbup = true; 2158 bool createbup = true;
2133 if ( createbup ) { 2159 if ( createbup ) {
2134 QString description = "\n"; 2160 QString description = "\n";
2135 CalendarLocal* cal = new CalendarLocal(); 2161 CalendarLocal* cal = new CalendarLocal();
2136 if ( beamDialog->beamLocal() ) 2162 if ( beamDialog->beamLocal() )
2137 cal->setLocalTime(); 2163 cal->setLocalTime();
2138 else 2164 else
2139 cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 2165 cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
2140 Incidence *incidence = delSel.first(); 2166 Incidence *incidence = delSel.first();
2141 bool addText = false; 2167 bool addText = false;
2142 if ( delSel.count() < 10 ) 2168 if ( delSel.count() < 10 )
2143 addText = true; 2169 addText = true;
2144 else { 2170 else {
2145 description.sprintf(i18n(" %d items?"),delSel.count() ); 2171 description.sprintf(i18n(" %d items?"),delSel.count() );
2146 } 2172 }
2147 while ( incidence ) { 2173 while ( incidence ) {
2148 Incidence *in = incidence->clone(); 2174 Incidence *in = incidence->clone();
2149 if ( addText ) 2175 if ( addText )
2150 description += in->summary() + "\n"; 2176 description += in->summary() + "\n";
2151 cal->addIncidence( in ); 2177 cal->addIncidence( in );
2152 incidence = delSel.next(); 2178 incidence = delSel.next();
2153 } 2179 }
2154 if ( beamDialog->beamVcal() ) { 2180 if ( beamDialog->beamVcal() ) {
2155 fn += ".vcs"; 2181 fn += ".vcs";
2156 FileStorage storage( cal, fn, new VCalFormat ); 2182 FileStorage storage( cal, fn, new VCalFormat );
2157 storage.save(); 2183 storage.save();
2158 } else { 2184 } else {
2159 fn += ".ics"; 2185 fn += ".ics";
2160 FileStorage storage( cal, fn, new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 2186 FileStorage storage( cal, fn, new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
2161 storage.save(); 2187 storage.save();
2162 } 2188 }
2163 delete cal; 2189 delete cal;
2164 mes = i18n("KO/Pi: Ready for beaming"); 2190 mes = i18n("KO/Pi: Ready for beaming");
2165 setCaption(mes); 2191 setCaption(mes);
2166 2192
2167#ifndef DESKTOP_VERSION 2193#ifndef DESKTOP_VERSION
2168 Ir *ir = new Ir( this ); 2194 Ir *ir = new Ir( this );
2169 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 2195 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2170 ir->send( fn, description, "text/x-vCalendar" ); 2196 ir->send( fn, description, "text/x-vCalendar" );
2171#endif 2197#endif
2172 } 2198 }
2173} 2199}
2174void CalendarView::beamDone( Ir *ir ) 2200void CalendarView::beamDone( Ir *ir )
2175{ 2201{
2176#ifndef DESKTOP_VERSION 2202#ifndef DESKTOP_VERSION
2177 delete ir; 2203 delete ir;
2178#endif 2204#endif
2179} 2205}
2180 2206
2181void CalendarView::moveIncidence(Incidence * inc ) 2207void CalendarView::moveIncidence(Incidence * inc )
2182{ 2208{
2183 if ( !inc ) return; 2209 if ( !inc ) return;
2184 // qDebug("showDatePickerForIncidence( ) "); 2210 // qDebug("showDatePickerForIncidence( ) ");
2185 if ( mDateFrame->isVisible() ) 2211 if ( mDateFrame->isVisible() )
2186 mDateFrame->hide(); 2212 mDateFrame->hide();
2187 else { 2213 else {
2188 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; 2214 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ;
2189 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; 2215 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ;
2190 int dw = QApplication::desktop()->width(); 2216 int dw = QApplication::desktop()->width();
2191 int dh = QApplication::desktop()->height(); 2217 int dh = QApplication::desktop()->height();
2192 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2218 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2193 mDateFrame->show(); 2219 mDateFrame->show();
2194 } 2220 }
2195 mDatePickerMode = 2; 2221 mDatePickerMode = 2;
2196 mMoveIncidence = inc ; 2222 mMoveIncidence = inc ;
2197 QDate da; 2223 QDate da;
2198 if ( mMoveIncidence->type() == "Todo" ) { 2224 if ( mMoveIncidence->type() == "Todo" ) {
2199 Todo * to = (Todo *) mMoveIncidence; 2225 Todo * to = (Todo *) mMoveIncidence;
2200 if ( to->hasDueDate() ) 2226 if ( to->hasDueDate() )
2201 da = to->dtDue().date(); 2227 da = to->dtDue().date();
2202 else 2228 else
2203 da = QDate::currentDate(); 2229 da = QDate::currentDate();
2204 } else { 2230 } else {
2205 da = mMoveIncidence->dtStart().date(); 2231 da = mMoveIncidence->dtStart().date();
2206 } 2232 }
2207 mDatePicker->setDate( da ); 2233 mDatePicker->setDate( da );
2208} 2234}
2209void CalendarView::showDatePicker( ) 2235void CalendarView::showDatePicker( )
2210{ 2236{
2211 //qDebug("CalendarView::showDatePicker( ) "); 2237 //qDebug("CalendarView::showDatePicker( ) ");
2212 if ( mDateFrame->isVisible() ) 2238 if ( mDateFrame->isVisible() )
2213 mDateFrame->hide(); 2239 mDateFrame->hide();
2214 else { 2240 else {
2215 int w =mDatePicker->sizeHint().width() ; 2241 int w =mDatePicker->sizeHint().width() ;
2216 int h = mDatePicker->sizeHint().height() ; 2242 int h = mDatePicker->sizeHint().height() ;
2217 int dw = QApplication::desktop()->width(); 2243 int dw = QApplication::desktop()->width();
2218 int dh = QApplication::desktop()->height(); 2244 int dh = QApplication::desktop()->height();
2219 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2245 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2220 mDateFrame->show(); 2246 mDateFrame->show();
2221 } 2247 }
2222 mDatePickerMode = 1; 2248 mDatePickerMode = 1;
2223 mDatePicker->setDate( mNavigator->selectedDates().first() ); 2249 mDatePicker->setDate( mNavigator->selectedDates().first() );
2224} 2250}
2225 2251
2226void CalendarView::showEventEditor() 2252void CalendarView::showEventEditor()
2227{ 2253{
2228#ifdef DESKTOP_VERSION 2254#ifdef DESKTOP_VERSION
2229 mEventEditor->show(); 2255 mEventEditor->show();
2230#else 2256#else
2231 mEventEditor->showMaximized(); 2257 mEventEditor->showMaximized();
2232#endif 2258#endif
2233} 2259}
2234void CalendarView::showTodoEditor() 2260void CalendarView::showTodoEditor()
2235{ 2261{
2236#ifdef DESKTOP_VERSION 2262#ifdef DESKTOP_VERSION
2237 mTodoEditor->show(); 2263 mTodoEditor->show();
2238#else 2264#else
2239 mTodoEditor->showMaximized(); 2265 mTodoEditor->showMaximized();
2240#endif 2266#endif
2241} 2267}
2242void CalendarView::cancelIncidence(Incidence * inc ) 2268void CalendarView::cancelIncidence(Incidence * inc )
2243{ 2269{
2244 inc->setCancelled( ! inc->cancelled() ); 2270 inc->setCancelled( ! inc->cancelled() );
2245 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 2271 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
2246 updateView(); 2272 updateView();
2247} 2273}
2248void CalendarView::cloneIncidence(Incidence * orgInc ) 2274void CalendarView::cloneIncidence(Incidence * orgInc )
2249{ 2275{
2250 Incidence * newInc = orgInc->clone(); 2276 Incidence * newInc = orgInc->clone();
2251 newInc->recreate(); 2277 newInc->recreate();
2252 2278
2253 if ( newInc->type() == "Todo" ) { 2279 if ( newInc->type() == "Todo" ) {
2254 Todo* t = (Todo*) newInc; 2280 Todo* t = (Todo*) newInc;
2255 mTodoEditor->editTodo( t ); 2281 mTodoEditor->editTodo( t );
2256 showTodoEditor(); 2282 showTodoEditor();
2257 if ( mTodoEditor->exec() ) { 2283 if ( mTodoEditor->exec() ) {
2258 mCalendar->addTodo( t ); 2284 mCalendar->addTodo( t );
2259 updateView(); 2285 updateView();
2260 } else { 2286 } else {
2261 delete t; 2287 delete t;
2262 } 2288 }
2263 } 2289 }
2264 else { 2290 else {
2265 Event* e = (Event*) newInc; 2291 Event* e = (Event*) newInc;
2266 mEventEditor->editEvent( e ); 2292 mEventEditor->editEvent( e );
2267 showEventEditor(); 2293 showEventEditor();
2268 if ( mEventEditor->exec() ) { 2294 if ( mEventEditor->exec() ) {
2269 mCalendar->addEvent( e ); 2295 mCalendar->addEvent( e );
2270 updateView(); 2296 updateView();
2271 } else { 2297 } else {
2272 delete e; 2298 delete e;
2273 } 2299 }
2274 } 2300 }
2275} 2301}
2276 2302
2277void CalendarView::newEvent() 2303void CalendarView::newEvent()
2278{ 2304{
2279 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 2305 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
2280 KOAgendaView *aView = mViewManager->agendaView(); 2306 KOAgendaView *aView = mViewManager->agendaView();
2281 if (aView) { 2307 if (aView) {
2282 if (aView->selectionStart().isValid()) { 2308 if (aView->selectionStart().isValid()) {
2283 if (aView->selectedIsAllDay()) { 2309 if (aView->selectedIsAllDay()) {
2284 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 2310 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
2285 } else { 2311 } else {
2286 newEvent(aView->selectionStart(),aView->selectionEnd()); 2312 newEvent(aView->selectionStart(),aView->selectionEnd());
2287 } 2313 }
2288 return; 2314 return;
2289 } 2315 }
2290 } 2316 }
2291 2317
2292 QDate date = mNavigator->selectedDates().first(); 2318 QDate date = mNavigator->selectedDates().first();
2293 QDateTime current = QDateTime::currentDateTime(); 2319 QDateTime current = QDateTime::currentDateTime();
2294 if ( date <= current.date() ) { 2320 if ( date <= current.date() ) {
2295 int hour = current.time().hour() +1; 2321 int hour = current.time().hour() +1;
2296 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 2322 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
2297 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2323 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2298 } else 2324 } else
2299 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 2325 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
2300 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 2326 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
2301 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2327 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2302} 2328}
2303 2329
2304void CalendarView::newEvent(QDateTime fh) 2330void CalendarView::newEvent(QDateTime fh)
2305{ 2331{
2306 newEvent(fh, 2332 newEvent(fh,
2307 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 2333 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
2308} 2334}
2309 2335
2310void CalendarView::newEvent(QDate dt) 2336void CalendarView::newEvent(QDate dt)
2311{ 2337{
2312 newEvent(QDateTime(dt, QTime(0,0,0)), 2338 newEvent(QDateTime(dt, QTime(0,0,0)),
2313 QDateTime(dt, QTime(0,0,0)), true); 2339 QDateTime(dt, QTime(0,0,0)), true);
2314} 2340}
2315 2341
2316void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 2342void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
2317{ 2343{
2318 2344
2319 mEventEditor->newEvent(fromHint,toHint,allDay); 2345 mEventEditor->newEvent(fromHint,toHint,allDay);
2320 if ( mFilterView->filtersEnabled() ) { 2346 if ( mFilterView->filtersEnabled() ) {
2321 CalFilter *filter = mFilterView->selectedFilter(); 2347 CalFilter *filter = mFilterView->selectedFilter();
2322 if (filter && filter->showCategories()) { 2348 if (filter && filter->showCategories()) {
2323 mEventEditor->setCategories(filter->categoryList().join(",") ); 2349 mEventEditor->setCategories(filter->categoryList().join(",") );
2324 } 2350 }
2325 if ( filter ) 2351 if ( filter )
2326 mEventEditor->setSecrecy( filter->getSecrecy() ); 2352 mEventEditor->setSecrecy( filter->getSecrecy() );
2327 } 2353 }
2328 showEventEditor(); 2354 showEventEditor();
2329} 2355}
2330void CalendarView::todoAdded(Todo * t) 2356void CalendarView::todoAdded(Todo * t)
2331{ 2357{
2332 2358
2333 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 2359 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
2334 updateTodoViews(); 2360 updateTodoViews();
2335} 2361}
2336void CalendarView::todoChanged(Todo * t) 2362void CalendarView::todoChanged(Todo * t)
2337{ 2363{
2338 emit todoModified( t, 4 ); 2364 emit todoModified( t, 4 );
2339 // updateTodoViews(); 2365 // updateTodoViews();
2340} 2366}
2341void CalendarView::todoToBeDeleted(Todo *) 2367void CalendarView::todoToBeDeleted(Todo *)
2342{ 2368{
2343 //qDebug("todoToBeDeleted(Todo *) "); 2369 //qDebug("todoToBeDeleted(Todo *) ");
2344 updateTodoViews(); 2370 updateTodoViews();
2345} 2371}
2346void CalendarView::todoDeleted() 2372void CalendarView::todoDeleted()
2347{ 2373{
2348 //qDebug(" todoDeleted()"); 2374 //qDebug(" todoDeleted()");
2349 updateTodoViews(); 2375 updateTodoViews();
2350} 2376}
2351 2377
2352 2378
2353 2379
2354void CalendarView::newTodo() 2380void CalendarView::newTodo()
2355{ 2381{
2356 2382
2357 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); 2383 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true);
2358 if ( mFilterView->filtersEnabled() ) { 2384 if ( mFilterView->filtersEnabled() ) {
2359 CalFilter *filter = mFilterView->selectedFilter(); 2385 CalFilter *filter = mFilterView->selectedFilter();
2360 if (filter && filter->showCategories()) { 2386 if (filter && filter->showCategories()) {
2361 mTodoEditor->setCategories(filter->categoryList().join(",") ); 2387 mTodoEditor->setCategories(filter->categoryList().join(",") );
2362 } 2388 }
2363 if ( filter ) 2389 if ( filter )
2364 mTodoEditor->setSecrecy( filter->getSecrecy() ); 2390 mTodoEditor->setSecrecy( filter->getSecrecy() );
2365 } 2391 }
2366 showTodoEditor(); 2392 showTodoEditor();
2367} 2393}
2368 2394
2369void CalendarView::newSubTodo() 2395void CalendarView::newSubTodo()
2370{ 2396{
2371 Todo *todo = selectedTodo(); 2397 Todo *todo = selectedTodo();
2372 if ( todo ) newSubTodo( todo ); 2398 if ( todo ) newSubTodo( todo );
2373} 2399}
2374 2400
2375void CalendarView::newSubTodo(Todo *parentEvent) 2401void CalendarView::newSubTodo(Todo *parentEvent)
2376{ 2402{
2377 2403
2378 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); 2404 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true);
2379 showTodoEditor(); 2405 showTodoEditor();
2380} 2406}
2381 2407
2382void CalendarView::newFloatingEvent() 2408void CalendarView::newFloatingEvent()
2383{ 2409{
2384 DateList tmpList = mNavigator->selectedDates(); 2410 DateList tmpList = mNavigator->selectedDates();
2385 QDate date = tmpList.first(); 2411 QDate date = tmpList.first();
2386 2412
2387 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 2413 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
2388 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 2414 QDateTime( date, QTime( 12, 0, 0 ) ), true );
2389} 2415}
2390 2416
2391 2417
2392void CalendarView::editEvent( Event *event ) 2418void CalendarView::editEvent( Event *event )
2393{ 2419{
2394 2420
2395 if ( !event ) return; 2421 if ( !event ) return;
2396 if ( event->isReadOnly() ) { 2422 if ( event->isReadOnly() ) {
2397 showEvent( event ); 2423 showEvent( event );
2398 return; 2424 return;
2399 } 2425 }
2400 mEventEditor->editEvent( event , mFlagEditDescription); 2426 mEventEditor->editEvent( event , mFlagEditDescription);
2401 showEventEditor(); 2427 showEventEditor();
2402} 2428}
2403void CalendarView::editJournal( Journal *jour ) 2429void CalendarView::editJournal( Journal *jour )
2404{ 2430{
2405 if ( !jour ) return; 2431 if ( !jour ) return;
2406 mDialogManager->hideSearchDialog(); 2432 mDialogManager->hideSearchDialog();
2407 mViewManager->showJournalView(); 2433 mViewManager->showJournalView();
2408 mNavigator->slotDaySelect( jour->dtStart().date() ); 2434 mNavigator->slotDaySelect( jour->dtStart().date() );
2409} 2435}
2410void CalendarView::editTodo( Todo *todo ) 2436void CalendarView::editTodo( Todo *todo )
2411{ 2437{
2412 if ( !todo ) return; 2438 if ( !todo ) return;
2413 2439
2414 if ( todo->isReadOnly() ) { 2440 if ( todo->isReadOnly() ) {
2415 showTodo( todo ); 2441 showTodo( todo );
2416 return; 2442 return;
2417 } 2443 }
2418 mTodoEditor->editTodo( todo ,mFlagEditDescription); 2444 mTodoEditor->editTodo( todo ,mFlagEditDescription);
2419 showTodoEditor(); 2445 showTodoEditor();
2420 2446
2421} 2447}
2422 2448
2423KOEventViewerDialog* CalendarView::getEventViewerDialog() 2449KOEventViewerDialog* CalendarView::getEventViewerDialog()
2424{ 2450{
2425 if ( !mEventViewerDialog ) { 2451 if ( !mEventViewerDialog ) {
2426 mEventViewerDialog = new KOEventViewerDialog(this); 2452 mEventViewerDialog = new KOEventViewerDialog(this);
2427 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 2453 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
2428 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 2454 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
2429 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 2455 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
2430 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 2456 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
2431 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 2457 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
2432 viewManager(), SLOT( showAgendaView( bool ) ) ); 2458 viewManager(), SLOT( showAgendaView( bool ) ) );
2433 mEventViewerDialog->resize( 640, 480 ); 2459 mEventViewerDialog->resize( 640, 480 );
2434 2460
2435 } 2461 }
2436 return mEventViewerDialog; 2462 return mEventViewerDialog;
2437} 2463}
2438void CalendarView::showEvent(Event *event) 2464void CalendarView::showEvent(Event *event)
2439{ 2465{
2440 getEventViewerDialog()->setEvent(event); 2466 getEventViewerDialog()->setEvent(event);
2441 getEventViewerDialog()->showMe(); 2467 getEventViewerDialog()->showMe();
2442} 2468}
2443 2469
2444void CalendarView::showTodo(Todo *event) 2470void CalendarView::showTodo(Todo *event)
2445{ 2471{
2446 getEventViewerDialog()->setTodo(event); 2472 getEventViewerDialog()->setTodo(event);
2447 getEventViewerDialog()->showMe(); 2473 getEventViewerDialog()->showMe();
2448} 2474}
2449void CalendarView::showJournal( Journal *jour ) 2475void CalendarView::showJournal( Journal *jour )
2450{ 2476{
2451 getEventViewerDialog()->setJournal(jour); 2477 getEventViewerDialog()->setJournal(jour);
2452 getEventViewerDialog()->showMe(); 2478 getEventViewerDialog()->showMe();
2453 2479
2454} 2480}
2455// void CalendarView::todoModified (Todo *event, int changed) 2481// void CalendarView::todoModified (Todo *event, int changed)
2456// { 2482// {
2457// // if (mDialogList.find (event) != mDialogList.end ()) { 2483// // if (mDialogList.find (event) != mDialogList.end ()) {
2458// // kdDebug() << "Todo modified and open" << endl; 2484// // kdDebug() << "Todo modified and open" << endl;
2459// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 2485// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
2460// // temp->modified (changed); 2486// // temp->modified (changed);
2461 2487
2462// // } 2488// // }
2463 2489
2464// mViewManager->updateView(); 2490// mViewManager->updateView();
2465// } 2491// }
2466 2492
2467void CalendarView::appointment_show() 2493void CalendarView::appointment_show()
2468{ 2494{
2469 Event *anEvent = 0; 2495 Event *anEvent = 0;
2470 2496
2471 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2497 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2472 2498
2473 if (mViewManager->currentView()->isEventView()) { 2499 if (mViewManager->currentView()->isEventView()) {
2474 if ( incidence && incidence->type() == "Event" ) { 2500 if ( incidence && incidence->type() == "Event" ) {
2475 anEvent = static_cast<Event *>(incidence); 2501 anEvent = static_cast<Event *>(incidence);
2476 } 2502 }
2477 } 2503 }
2478 2504
2479 if (!anEvent) { 2505 if (!anEvent) {
2480 KNotifyClient::beep(); 2506 KNotifyClient::beep();
2481 return; 2507 return;
2482 } 2508 }
2483 2509
2484 showEvent(anEvent); 2510 showEvent(anEvent);
2485} 2511}
2486 2512
2487void CalendarView::appointment_edit() 2513void CalendarView::appointment_edit()
2488{ 2514{
2489 Event *anEvent = 0; 2515 Event *anEvent = 0;
2490 2516
2491 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2517 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2492 2518
2493 if (mViewManager->currentView()->isEventView()) { 2519 if (mViewManager->currentView()->isEventView()) {
2494 if ( incidence && incidence->type() == "Event" ) { 2520 if ( incidence && incidence->type() == "Event" ) {
2495 anEvent = static_cast<Event *>(incidence); 2521 anEvent = static_cast<Event *>(incidence);
2496 } 2522 }
2497 } 2523 }
2498 2524
2499 if (!anEvent) { 2525 if (!anEvent) {
2500 KNotifyClient::beep(); 2526 KNotifyClient::beep();
2501 return; 2527 return;
2502 } 2528 }
2503 2529
2504 editEvent(anEvent); 2530 editEvent(anEvent);
2505} 2531}
2506 2532
2507void CalendarView::appointment_delete() 2533void CalendarView::appointment_delete()
2508{ 2534{
2509 Event *anEvent = 0; 2535 Event *anEvent = 0;
2510 2536
2511 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2537 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2512 2538
2513 if (mViewManager->currentView()->isEventView()) { 2539 if (mViewManager->currentView()->isEventView()) {
2514 if ( incidence && incidence->type() == "Event" ) { 2540 if ( incidence && incidence->type() == "Event" ) {
2515 anEvent = static_cast<Event *>(incidence); 2541 anEvent = static_cast<Event *>(incidence);
2516 } 2542 }
2517 } 2543 }
2518 2544
2519 if (!anEvent) { 2545 if (!anEvent) {
2520 KNotifyClient::beep(); 2546 KNotifyClient::beep();
2521 return; 2547 return;
2522 } 2548 }
2523 2549
2524 deleteEvent(anEvent); 2550 deleteEvent(anEvent);
2525} 2551}
2526 2552
2527void CalendarView::todo_unsub(Todo *anTodo ) 2553void CalendarView::todo_unsub(Todo *anTodo )
2528{ 2554{
2529 // Todo *anTodo = selectedTodo(); 2555 // Todo *anTodo = selectedTodo();
2530 if (!anTodo) return; 2556 if (!anTodo) return;
2531 if (!anTodo->relatedTo()) return; 2557 if (!anTodo->relatedTo()) return;
2532 anTodo->relatedTo()->removeRelation(anTodo); 2558 anTodo->relatedTo()->removeRelation(anTodo);
2533 anTodo->setRelatedTo(0); 2559 anTodo->setRelatedTo(0);
2534 anTodo->updated(); 2560 anTodo->updated();
2535 anTodo->setRelatedToUid(""); 2561 anTodo->setRelatedToUid("");
2536 setModified(true); 2562 setModified(true);
2537 updateView(); 2563 updateView();
2538} 2564}
2539 2565
2540void CalendarView::deleteTodo(Todo *todo) 2566void CalendarView::deleteTodo(Todo *todo)
2541{ 2567{
2542 if (!todo) { 2568 if (!todo) {
2543 KNotifyClient::beep(); 2569 KNotifyClient::beep();
2544 return; 2570 return;
2545 } 2571 }
2546 if (KOPrefs::instance()->mConfirm) { 2572 if (KOPrefs::instance()->mConfirm) {
2547 switch (msgItemDelete()) { 2573 switch (msgItemDelete()) {
2548 case KMessageBox::Continue: // OK 2574 case KMessageBox::Continue: // OK
2549 if (!todo->relations().isEmpty()) { 2575 if (!todo->relations().isEmpty()) {
2550 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), 2576 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."),
2551 i18n("Delete To-Do")); 2577 i18n("Delete To-Do"));
2552 } else { 2578 } else {
2553 checkZaurusId( todo->zaurusId(), true ); 2579 checkZaurusId( todo->zaurusId(), true );
2554 calendar()->deleteTodo(todo); 2580 calendar()->deleteTodo(todo);
2555 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2581 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2556 updateView(); 2582 updateView();
2557 } 2583 }
2558 break; 2584 break;
2559 } // switch 2585 } // switch
2560 } else { 2586 } else {
2561 if (!todo->relations().isEmpty()) { 2587 if (!todo->relations().isEmpty()) {
2562 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), 2588 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."),
2563 i18n("Delete To-Do")); 2589 i18n("Delete To-Do"));
2564 } else { 2590 } else {
2565 checkZaurusId( todo->zaurusId(), true ); 2591 checkZaurusId( todo->zaurusId(), true );
2566 mCalendar->deleteTodo(todo); 2592 mCalendar->deleteTodo(todo);
2567 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2593 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2568 updateView(); 2594 updateView();
2569 } 2595 }
2570 } 2596 }
2571 emit updateSearchDialog(); 2597 emit updateSearchDialog();
2572} 2598}
2573void CalendarView::deleteJournal(Journal *jour) 2599void CalendarView::deleteJournal(Journal *jour)
2574{ 2600{
2575 if (!jour) { 2601 if (!jour) {
2576 KNotifyClient::beep(); 2602 KNotifyClient::beep();
2577 return; 2603 return;
2578 } 2604 }
2579 if (KOPrefs::instance()->mConfirm) { 2605 if (KOPrefs::instance()->mConfirm) {
2580 switch (msgItemDelete()) { 2606 switch (msgItemDelete()) {
2581 case KMessageBox::Continue: // OK 2607 case KMessageBox::Continue: // OK
2582 calendar()->deleteJournal(jour); 2608 calendar()->deleteJournal(jour);
2583 updateView(); 2609 updateView();
2584 break; 2610 break;
2585 } // switch 2611 } // switch
2586 } else { 2612 } else {
2587 calendar()->deleteJournal(jour);; 2613 calendar()->deleteJournal(jour);;
2588 updateView(); 2614 updateView();
2589 } 2615 }
2590 emit updateSearchDialog(); 2616 emit updateSearchDialog();
2591} 2617}
2592 2618
2593void CalendarView::deleteEvent(Event *anEvent) 2619void CalendarView::deleteEvent(Event *anEvent)
2594{ 2620{
2595 if (!anEvent) { 2621 if (!anEvent) {
2596 KNotifyClient::beep(); 2622 KNotifyClient::beep();
2597 return; 2623 return;
2598 } 2624 }
2599 2625
2600 if (anEvent->recurrence()->doesRecur()) { 2626 if (anEvent->recurrence()->doesRecur()) {
2601 QDate itemDate = mViewManager->currentSelectionDate(); 2627 QDate itemDate = mViewManager->currentSelectionDate();
2602 int km; 2628 int km;
2603 if (!itemDate.isValid()) { 2629 if (!itemDate.isValid()) {
2604 //kdDebug() << "Date Not Valid" << endl; 2630 //kdDebug() << "Date Not Valid" << endl;
2605 if (KOPrefs::instance()->mConfirm) { 2631 if (KOPrefs::instance()->mConfirm) {
2606 km = KMessageBox::warningContinueCancel(this,anEvent->summary() + 2632 km = KMessageBox::warningContinueCancel(this,anEvent->summary() +
2607 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), 2633 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"),
2608 i18n("KO/Pi Confirmation"),i18n("Delete All")); 2634 i18n("KO/Pi Confirmation"),i18n("Delete All"));
2609 if ( km == KMessageBox::Continue ) 2635 if ( km == KMessageBox::Continue )
2610 km = KMessageBox::No; // No = all below 2636 km = KMessageBox::No; // No = all below
2611 } else 2637 } else
2612 km = KMessageBox::No; 2638 km = KMessageBox::No;
2613 } else { 2639 } else {
2614 km = KMessageBox::warningYesNoCancel(this,anEvent->summary() + 2640 km = KMessageBox::warningYesNoCancel(this,anEvent->summary() +
2615 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ 2641 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+
2616 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), 2642 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"),
2617 i18n("KO/Pi Confirmation"),i18n("Current"), 2643 i18n("KO/Pi Confirmation"),i18n("Current"),
2618 i18n("All")); 2644 i18n("All"));
2619 } 2645 }
2620 switch(km) { 2646 switch(km) {
2621 2647
2622 case KMessageBox::No: // Continue // all 2648 case KMessageBox::No: // Continue // all
2623 //qDebug("KMessageBox::No "); 2649 //qDebug("KMessageBox::No ");
2624 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2650 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2625 schedule(Scheduler::Cancel,anEvent); 2651 schedule(Scheduler::Cancel,anEvent);
2626 2652
2627 checkZaurusId( anEvent->zaurusId()); 2653 checkZaurusId( anEvent->zaurusId());
2628 mCalendar->deleteEvent(anEvent); 2654 mCalendar->deleteEvent(anEvent);
2629 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); 2655 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED);
2630 break; 2656 break;
2631 2657
2632 // Disabled because it does not work 2658 // Disabled because it does not work
2633 //#if 0 2659 //#if 0
2634 case KMessageBox::Yes: // just this one 2660 case KMessageBox::Yes: // just this one
2635 //QDate qd = mNavigator->selectedDates().first(); 2661 //QDate qd = mNavigator->selectedDates().first();
2636 //if (!qd.isValid()) { 2662 //if (!qd.isValid()) {
2637 // kdDebug() << "no date selected, or invalid date" << endl; 2663 // kdDebug() << "no date selected, or invalid date" << endl;
2638 // KNotifyClient::beep(); 2664 // KNotifyClient::beep();
2639 // return; 2665 // return;
2640 //} 2666 //}
2641 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); 2667 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1);
2642 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { 2668 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) {
2643 anEvent->addExDate(itemDate); 2669 anEvent->addExDate(itemDate);
2644 int duration = anEvent->recurrence()->duration(); 2670 int duration = anEvent->recurrence()->duration();
2645 if ( duration > 0 ) { 2671 if ( duration > 0 ) {
2646 anEvent->recurrence()->setDuration( duration - 1 ); 2672 anEvent->recurrence()->setDuration( duration - 1 );
2647 } 2673 }
2648 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); 2674 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED);
2649 } 2675 }
2650 break; 2676 break;
2651 //#endif 2677 //#endif
2652 } // switch 2678 } // switch
2653 } else { 2679 } else {
2654 if (KOPrefs::instance()->mConfirm) { 2680 if (KOPrefs::instance()->mConfirm) {
2655 switch (KMessageBox::warningContinueCancel(this,anEvent->summary() + 2681 switch (KMessageBox::warningContinueCancel(this,anEvent->summary() +
2656 i18n("\nAre you sure you want\nto delete this event?"), 2682 i18n("\nAre you sure you want\nto delete this event?"),
2657 i18n("KO/Pi Confirmation"),i18n("Delete"))) { 2683 i18n("KO/Pi Confirmation"),i18n("Delete"))) {
2658 case KMessageBox::Continue: // OK 2684 case KMessageBox::Continue: // OK
2659 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2685 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2660 schedule(Scheduler::Cancel,anEvent); 2686 schedule(Scheduler::Cancel,anEvent);
2661 checkZaurusId( anEvent->zaurusId()); 2687 checkZaurusId( anEvent->zaurusId());
2662 mCalendar->deleteEvent(anEvent); 2688 mCalendar->deleteEvent(anEvent);
2663 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2689 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2664 break; 2690 break;
2665 } // switch 2691 } // switch
2666 } else { 2692 } else {
2667 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2693 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2668 schedule(Scheduler::Cancel,anEvent); 2694 schedule(Scheduler::Cancel,anEvent);
2669 checkZaurusId( anEvent->zaurusId()); 2695 checkZaurusId( anEvent->zaurusId());
2670 mCalendar->deleteEvent(anEvent); 2696 mCalendar->deleteEvent(anEvent);
2671 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2697 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2672 } 2698 }
2673 } // if-else 2699 } // if-else
2674 emit updateSearchDialog(); 2700 emit updateSearchDialog();
2675} 2701}
2676 2702
2677bool CalendarView::deleteEvent(const QString &uid) 2703bool CalendarView::deleteEvent(const QString &uid)
2678{ 2704{
2679 Event *ev = mCalendar->event(uid); 2705 Event *ev = mCalendar->event(uid);
2680 if (ev) { 2706 if (ev) {
2681 deleteEvent(ev); 2707 deleteEvent(ev);
2682 return true; 2708 return true;
2683 } else { 2709 } else {
2684 return false; 2710 return false;
2685 } 2711 }
2686} 2712}
2687 2713
2688/*****************************************************************************/ 2714/*****************************************************************************/
2689 2715
2690void CalendarView::action_mail() 2716void CalendarView::action_mail()
2691{ 2717{
2692#ifndef KORG_NOMAIL 2718#ifndef KORG_NOMAIL
2693 KOMailClient mailClient; 2719 KOMailClient mailClient;
2694 2720
2695 Incidence *incidence = currentSelection(); 2721 Incidence *incidence = currentSelection();
2696 2722
2697 if (!incidence) { 2723 if (!incidence) {
2698 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 2724 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
2699 return; 2725 return;
2700 } 2726 }
2701 if(incidence->attendeeCount() == 0 ) { 2727 if(incidence->attendeeCount() == 0 ) {
2702 KMessageBox::sorry(this, 2728 KMessageBox::sorry(this,
2703 i18n("Can't generate mail:\nNo attendees defined.\n")); 2729 i18n("Can't generate mail:\nNo attendees defined.\n"));
2704 return; 2730 return;
2705 } 2731 }
2706 2732
2707 CalendarLocal cal_tmp; 2733 CalendarLocal cal_tmp;
2708 Event *event = 0; 2734 Event *event = 0;
2709 Event *ev = 0; 2735 Event *ev = 0;
2710 if ( incidence && incidence->type() == "Event" ) { 2736 if ( incidence && incidence->type() == "Event" ) {
2711 event = static_cast<Event *>(incidence); 2737 event = static_cast<Event *>(incidence);
2712 ev = new Event(*event); 2738 ev = new Event(*event);
2713 cal_tmp.addEvent(ev); 2739 cal_tmp.addEvent(ev);
2714 } 2740 }
2715 ICalFormat mForm( KOPrefs::instance()->mUseQuicksave); 2741 ICalFormat mForm( KOPrefs::instance()->mUseQuicksave);
2716 QString attachment = mForm.toString( &cal_tmp ); 2742 QString attachment = mForm.toString( &cal_tmp );
2717 if (ev) delete(ev); 2743 if (ev) delete(ev);
2718 2744
2719 mailClient.mailAttendees(currentSelection(), attachment); 2745 mailClient.mailAttendees(currentSelection(), attachment);
2720 2746
2721#endif 2747#endif
2722 2748
2723#if 0 2749#if 0
2724 Event *anEvent = 0; 2750 Event *anEvent = 0;
2725 if (mViewManager->currentView()->isEventView()) { 2751 if (mViewManager->currentView()->isEventView()) {
2726 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); 2752 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first());
2727 } 2753 }
2728 2754
2729 if (!anEvent) { 2755 if (!anEvent) {
2730 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 2756 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
2731 return; 2757 return;
2732 } 2758 }
2733 if(anEvent->attendeeCount() == 0 ) { 2759 if(anEvent->attendeeCount() == 0 ) {
2734 KMessageBox::sorry(this, 2760 KMessageBox::sorry(this,
2735 i18n("Can't generate mail:\nNo attendees defined.\n")); 2761 i18n("Can't generate mail:\nNo attendees defined.\n"));
2736 return; 2762 return;
2737 } 2763 }
2738 2764
2739 mailobject.emailEvent(anEvent); 2765 mailobject.emailEvent(anEvent);
2740#endif 2766#endif
2741} 2767}
2742 2768
2743 2769
2744void CalendarView::schedule_publish(Incidence *incidence) 2770void CalendarView::schedule_publish(Incidence *incidence)
2745{ 2771{
2746 Event *event = 0; 2772 Event *event = 0;
2747 Todo *todo = 0; 2773 Todo *todo = 0;
2748 2774
2749 if (incidence == 0) { 2775 if (incidence == 0) {
2750 incidence = mViewManager->currentView()->selectedIncidences().first(); 2776 incidence = mViewManager->currentView()->selectedIncidences().first();
2751 if (incidence == 0) { 2777 if (incidence == 0) {
2752 incidence = mTodoList->selectedIncidences().first(); 2778 incidence = mTodoList->selectedIncidences().first();
2753 } 2779 }
2754 } 2780 }
2755 if ( incidence && incidence->type() == "Event" ) { 2781 if ( incidence && incidence->type() == "Event" ) {
2756 event = static_cast<Event *>(incidence); 2782 event = static_cast<Event *>(incidence);
2757 } else { 2783 } else {
2758 if ( incidence && incidence->type() == "Todo" ) { 2784 if ( incidence && incidence->type() == "Todo" ) {
2759 todo = static_cast<Todo *>(incidence); 2785 todo = static_cast<Todo *>(incidence);
2760 } 2786 }
2761 } 2787 }
2762 2788
2763 if (!event && !todo) { 2789 if (!event && !todo) {
2764 KMessageBox::sorry(this,i18n("No event selected.")); 2790 KMessageBox::sorry(this,i18n("No event selected."));
2765 return; 2791 return;
2766 } 2792 }
2767 2793
2768 PublishDialog *publishdlg = new PublishDialog(); 2794 PublishDialog *publishdlg = new PublishDialog();
2769 if (incidence->attendeeCount()>0) { 2795 if (incidence->attendeeCount()>0) {
2770 QPtrList<Attendee> attendees = incidence->attendees(); 2796 QPtrList<Attendee> attendees = incidence->attendees();
2771 attendees.first(); 2797 attendees.first();
2772 while ( attendees.current()!=0 ) { 2798 while ( attendees.current()!=0 ) {
2773 publishdlg->addAttendee(attendees.current()); 2799 publishdlg->addAttendee(attendees.current());
2774 attendees.next(); 2800 attendees.next();
2775 } 2801 }
2776 } 2802 }
2777 bool send = true; 2803 bool send = true;
2778 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { 2804 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) {
2779 if ( publishdlg->exec() != QDialog::Accepted ) 2805 if ( publishdlg->exec() != QDialog::Accepted )
2780 send = false; 2806 send = false;
2781 } 2807 }
2782 if ( send ) { 2808 if ( send ) {
2783 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 2809 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
2784 if ( event ) { 2810 if ( event ) {
2785 Event *ev = new Event(*event); 2811 Event *ev = new Event(*event);
2786 ev->registerObserver(0); 2812 ev->registerObserver(0);
2787 ev->clearAttendees(); 2813 ev->clearAttendees();
2788 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 2814 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
2789 delete(ev); 2815 delete(ev);
2790 } 2816 }
2791 } else { 2817 } else {
2792 if ( todo ) { 2818 if ( todo ) {
2793 Todo *ev = new Todo(*todo); 2819 Todo *ev = new Todo(*todo);
2794 ev->registerObserver(0); 2820 ev->registerObserver(0);
2795 ev->clearAttendees(); 2821 ev->clearAttendees();
2796 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 2822 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
2797 delete(ev); 2823 delete(ev);
2798 } 2824 }
2799 } 2825 }
2800 } 2826 }
2801 } 2827 }
2802 delete publishdlg; 2828 delete publishdlg;
2803} 2829}
2804 2830
2805void CalendarView::schedule_request(Incidence *incidence) 2831void CalendarView::schedule_request(Incidence *incidence)
2806{ 2832{
2807 schedule(Scheduler::Request,incidence); 2833 schedule(Scheduler::Request,incidence);
2808} 2834}
2809 2835
2810void CalendarView::schedule_refresh(Incidence *incidence) 2836void CalendarView::schedule_refresh(Incidence *incidence)
2811{ 2837{
2812 schedule(Scheduler::Refresh,incidence); 2838 schedule(Scheduler::Refresh,incidence);
2813} 2839}
2814 2840
2815void CalendarView::schedule_cancel(Incidence *incidence) 2841void CalendarView::schedule_cancel(Incidence *incidence)
2816{ 2842{
2817 schedule(Scheduler::Cancel,incidence); 2843 schedule(Scheduler::Cancel,incidence);
2818} 2844}
2819 2845
2820void CalendarView::schedule_add(Incidence *incidence) 2846void CalendarView::schedule_add(Incidence *incidence)
2821{ 2847{
2822 schedule(Scheduler::Add,incidence); 2848 schedule(Scheduler::Add,incidence);
2823} 2849}
2824 2850
2825void CalendarView::schedule_reply(Incidence *incidence) 2851void CalendarView::schedule_reply(Incidence *incidence)
2826{ 2852{
2827 schedule(Scheduler::Reply,incidence); 2853 schedule(Scheduler::Reply,incidence);
2828} 2854}
2829 2855
2830void CalendarView::schedule_counter(Incidence *incidence) 2856void CalendarView::schedule_counter(Incidence *incidence)
2831{ 2857{
2832 schedule(Scheduler::Counter,incidence); 2858 schedule(Scheduler::Counter,incidence);
2833} 2859}
2834 2860
2835void CalendarView::schedule_declinecounter(Incidence *incidence) 2861void CalendarView::schedule_declinecounter(Incidence *incidence)
2836{ 2862{
2837 schedule(Scheduler::Declinecounter,incidence); 2863 schedule(Scheduler::Declinecounter,incidence);
2838} 2864}
2839 2865
2840void CalendarView::schedule_publish_freebusy(int daysToPublish) 2866void CalendarView::schedule_publish_freebusy(int daysToPublish)
2841{ 2867{
2842 QDateTime start = QDateTime::currentDateTime(); 2868 QDateTime start = QDateTime::currentDateTime();
2843 QDateTime end = start.addDays(daysToPublish); 2869 QDateTime end = start.addDays(daysToPublish);
2844 2870
2845 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); 2871 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end);
2846 freebusy->setOrganizer(KOPrefs::instance()->email()); 2872 freebusy->setOrganizer(KOPrefs::instance()->email());
2847 2873
2848 2874
2849 PublishDialog *publishdlg = new PublishDialog(); 2875 PublishDialog *publishdlg = new PublishDialog();
2850 if ( publishdlg->exec() == QDialog::Accepted ) { 2876 if ( publishdlg->exec() == QDialog::Accepted ) {
2851 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 2877 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
2852 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { 2878 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) {
2853 delete(freebusy); 2879 delete(freebusy);
2854 } 2880 }
2855 } 2881 }
2856 delete publishdlg; 2882 delete publishdlg;
2857} 2883}
2858 2884
2859void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) 2885void CalendarView::schedule(Scheduler::Method method, Incidence *incidence)
2860{ 2886{
2861 Event *event = 0; 2887 Event *event = 0;
2862 Todo *todo = 0; 2888 Todo *todo = 0;
2863 2889
2864 if (incidence == 0) { 2890 if (incidence == 0) {
2865 incidence = mViewManager->currentView()->selectedIncidences().first(); 2891 incidence = mViewManager->currentView()->selectedIncidences().first();
2866 if (incidence == 0) { 2892 if (incidence == 0) {
2867 incidence = mTodoList->selectedIncidences().first(); 2893 incidence = mTodoList->selectedIncidences().first();
2868 } 2894 }
2869 } 2895 }
2870 if ( incidence && incidence->type() == "Event" ) { 2896 if ( incidence && incidence->type() == "Event" ) {
2871 event = static_cast<Event *>(incidence); 2897 event = static_cast<Event *>(incidence);
2872 } 2898 }
2873 if ( incidence && incidence->type() == "Todo" ) { 2899 if ( incidence && incidence->type() == "Todo" ) {
2874 todo = static_cast<Todo *>(incidence); 2900 todo = static_cast<Todo *>(incidence);
2875 } 2901 }
2876 2902
2877 if (!event && !todo) { 2903 if (!event && !todo) {
2878 KMessageBox::sorry(this,i18n("No event selected.")); 2904 KMessageBox::sorry(this,i18n("No event selected."));
2879 return; 2905 return;
2880 } 2906 }
2881 2907
2882 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { 2908 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) {
2883 KMessageBox::sorry(this,i18n("The event has no attendees.")); 2909 KMessageBox::sorry(this,i18n("The event has no attendees."));
2884 return; 2910 return;
2885 } 2911 }
2886 2912
2887 Event *ev = 0; 2913 Event *ev = 0;
2888 if (event) ev = new Event(*event); 2914 if (event) ev = new Event(*event);
2889 Todo *to = 0; 2915 Todo *to = 0;
2890 if (todo) to = new Todo(*todo); 2916 if (todo) to = new Todo(*todo);
2891 2917
2892 if (method == Scheduler::Reply || method == Scheduler::Refresh) { 2918 if (method == Scheduler::Reply || method == Scheduler::Refresh) {
2893 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 2919 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
2894 if (!me) { 2920 if (!me) {
2895 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); 2921 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails."));
2896 return; 2922 return;
2897 } 2923 }
2898 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { 2924 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) {
2899 StatusDialog *statdlg = new StatusDialog(this); 2925 StatusDialog *statdlg = new StatusDialog(this);
2900 if (!statdlg->exec()==QDialog::Accepted) return; 2926 if (!statdlg->exec()==QDialog::Accepted) return;
2901 me->setStatus( statdlg->status() ); 2927 me->setStatus( statdlg->status() );
2902 delete(statdlg); 2928 delete(statdlg);
2903 } 2929 }
2904 Attendee *menew = new Attendee(*me); 2930 Attendee *menew = new Attendee(*me);
2905 if (ev) { 2931 if (ev) {
2906 ev->clearAttendees(); 2932 ev->clearAttendees();
2907 ev->addAttendee(menew,false); 2933 ev->addAttendee(menew,false);
2908 } else { 2934 } else {
2909 if (to) { 2935 if (to) {
2910 todo->clearAttendees(); 2936 todo->clearAttendees();
2911 todo->addAttendee(menew,false); 2937 todo->addAttendee(menew,false);
2912 } 2938 }
2913 } 2939 }
2914 } 2940 }
2915 2941
2916 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 2942 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
2917 if (ev) { 2943 if (ev) {
2918 if ( !dlg->addMessage(ev,method) ) delete(ev); 2944 if ( !dlg->addMessage(ev,method) ) delete(ev);
2919 } else { 2945 } else {
2920 if (to) { 2946 if (to) {
2921 if ( !dlg->addMessage(to,method) ) delete(to); 2947 if ( !dlg->addMessage(to,method) ) delete(to);
2922 } 2948 }
2923 } 2949 }
2924} 2950}
2925 2951
2926void CalendarView::openAddressbook() 2952void CalendarView::openAddressbook()
2927{ 2953{
2928 KRun::runCommand("kaddressbook"); 2954 KRun::runCommand("kaddressbook");
2929} 2955}
2930 2956
2931void CalendarView::setModified(bool modified) 2957void CalendarView::setModified(bool modified)
2932{ 2958{
2933 if ( modified ) 2959 if ( modified )
2934 emit signalmodified(); 2960 emit signalmodified();
2935 if (mModified != modified) { 2961 if (mModified != modified) {
2936 mModified = modified; 2962 mModified = modified;
2937 emit modifiedChanged(mModified); 2963 emit modifiedChanged(mModified);
2938 } 2964 }
2939} 2965}
2940 2966
2941bool CalendarView::isReadOnly() 2967bool CalendarView::isReadOnly()
2942{ 2968{
2943 return mReadOnly; 2969 return mReadOnly;
2944} 2970}
2945 2971
2946void CalendarView::setReadOnly(bool readOnly) 2972void CalendarView::setReadOnly(bool readOnly)
2947{ 2973{
2948 if (mReadOnly != readOnly) { 2974 if (mReadOnly != readOnly) {
2949 mReadOnly = readOnly; 2975 mReadOnly = readOnly;
2950 emit readOnlyChanged(mReadOnly); 2976 emit readOnlyChanged(mReadOnly);
2951 } 2977 }
2952} 2978}
2953 2979
2954bool CalendarView::isModified() 2980bool CalendarView::isModified()
2955{ 2981{
2956 return mModified; 2982 return mModified;
2957} 2983}
2958 2984
2959void CalendarView::printSetup() 2985void CalendarView::printSetup()
2960{ 2986{
2961#ifndef KORG_NOPRINTER 2987#ifndef KORG_NOPRINTER
2962 createPrinter(); 2988 createPrinter();
2963 2989
2964 mCalPrinter->setupPrinter(); 2990 mCalPrinter->setupPrinter();
2965#endif 2991#endif
2966} 2992}
2967 2993
2968void CalendarView::print() 2994void CalendarView::print()
2969{ 2995{
2970#ifndef KORG_NOPRINTER 2996#ifndef KORG_NOPRINTER
2971 createPrinter(); 2997 createPrinter();
2972 2998
2973 DateList tmpDateList = mNavigator->selectedDates(); 2999 DateList tmpDateList = mNavigator->selectedDates();
2974 mCalPrinter->print(CalPrinter::Month, 3000 mCalPrinter->print(CalPrinter::Month,
2975 tmpDateList.first(), tmpDateList.last()); 3001 tmpDateList.first(), tmpDateList.last());
2976#endif 3002#endif
2977} 3003}
2978 3004
2979void CalendarView::printPreview() 3005void CalendarView::printPreview()
2980{ 3006{
2981#ifndef KORG_NOPRINTER 3007#ifndef KORG_NOPRINTER
2982 kdDebug() << "CalendarView::printPreview()" << endl; 3008 kdDebug() << "CalendarView::printPreview()" << endl;
2983 3009
2984 createPrinter(); 3010 createPrinter();
2985 3011
2986 DateList tmpDateList = mNavigator->selectedDates(); 3012 DateList tmpDateList = mNavigator->selectedDates();
2987 3013
2988 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), 3014 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(),
2989 tmpDateList.last()); 3015 tmpDateList.last());
2990#endif 3016#endif
2991} 3017}
2992 3018
2993void CalendarView::exportICalendar() 3019void CalendarView::exportICalendar()
2994{ 3020{
2995 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); 3021 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this);
2996 3022
2997 // Force correct extension 3023 // Force correct extension
2998 if (filename.right(4) != ".ics") filename += ".ics"; 3024 if (filename.right(4) != ".ics") filename += ".ics";
2999 3025
3000 FileStorage storage( mCalendar, filename, new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 3026 FileStorage storage( mCalendar, filename, new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
3001 storage.save(); 3027 storage.save();
3002} 3028}
3003 3029
3004bool CalendarView::exportVCalendar( QString filename ) 3030bool CalendarView::exportVCalendar( QString filename )
3005{ 3031{
3006 if (mCalendar->journals().count() > 0) { 3032 if (mCalendar->journals().count() > 0) {
3007 int result = KMessageBox::warningContinueCancel(this, 3033 int result = KMessageBox::warningContinueCancel(this,
3008 i18n("The journal entries can not be\nexported to a vCalendar file."), 3034 i18n("The journal entries can not be\nexported to a vCalendar file."),
3009 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 3035 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
3010 true); 3036 true);
3011 if (result != KMessageBox::Continue) return false; 3037 if (result != KMessageBox::Continue) return false;
3012 } 3038 }
3013 3039
3014 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); 3040 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this);
3015 3041
3016 // Force correct extension 3042 // Force correct extension
3017 if (filename.right(4) != ".vcs") filename += ".vcs"; 3043 if (filename.right(4) != ".vcs") filename += ".vcs";
3018 3044
3019 FileStorage storage( mCalendar, filename, new VCalFormat ); 3045 FileStorage storage( mCalendar, filename, new VCalFormat );
3020 return storage.save(); 3046 return storage.save();
3021 3047
3022} 3048}
3023 3049
3024void CalendarView::eventUpdated(Incidence *) 3050void CalendarView::eventUpdated(Incidence *)
3025{ 3051{
3026 setModified(); 3052 setModified();
3027 // Don't call updateView here. The code, which has caused the update of the 3053 // Don't call updateView here. The code, which has caused the update of the
3028 // event is responsible for updating the view. 3054 // event is responsible for updating the view.
3029 // updateView(); 3055 // updateView();
3030} 3056}
3031 3057
3032void CalendarView::adaptNavigationUnits() 3058void CalendarView::adaptNavigationUnits()
3033{ 3059{
3034 if (mViewManager->currentView()->isEventView()) { 3060 if (mViewManager->currentView()->isEventView()) {
3035 int days = mViewManager->currentView()->currentDateCount(); 3061 int days = mViewManager->currentView()->currentDateCount();
3036 if (days == 1) { 3062 if (days == 1) {
3037 emit changeNavStringPrev(i18n("&Previous Day")); 3063 emit changeNavStringPrev(i18n("&Previous Day"));
3038 emit changeNavStringNext(i18n("&Next Day")); 3064 emit changeNavStringNext(i18n("&Next Day"));
3039 } else { 3065 } else {
3040 emit changeNavStringPrev(i18n("&Previous Week")); 3066 emit changeNavStringPrev(i18n("&Previous Week"));
3041 emit changeNavStringNext(i18n("&Next Week")); 3067 emit changeNavStringNext(i18n("&Next Week"));
3042 } 3068 }
3043 } 3069 }
3044} 3070}
3045 3071
3046void CalendarView::processMainViewSelection( Incidence *incidence ) 3072void CalendarView::processMainViewSelection( Incidence *incidence )
3047{ 3073{
3048 if ( incidence ) mTodoList->clearSelection(); 3074 if ( incidence ) mTodoList->clearSelection();
3049 processIncidenceSelection( incidence ); 3075 processIncidenceSelection( incidence );
3050} 3076}
3051 3077
3052void CalendarView::processTodoListSelection( Incidence *incidence ) 3078void CalendarView::processTodoListSelection( Incidence *incidence )
3053{ 3079{
3054 if ( incidence && mViewManager->currentView() ) { 3080 if ( incidence && mViewManager->currentView() ) {
3055 mViewManager->currentView()->clearSelection(); 3081 mViewManager->currentView()->clearSelection();
3056 } 3082 }
3057 processIncidenceSelection( incidence ); 3083 processIncidenceSelection( incidence );
3058} 3084}
3059 3085
3060void CalendarView::processIncidenceSelection( Incidence *incidence ) 3086void CalendarView::processIncidenceSelection( Incidence *incidence )
3061{ 3087{
3062 if ( incidence == mSelectedIncidence ) return; 3088 if ( incidence == mSelectedIncidence ) return;
3063 3089
3064 mSelectedIncidence = incidence; 3090 mSelectedIncidence = incidence;
3065 3091
3066 emit incidenceSelected( mSelectedIncidence ); 3092 emit incidenceSelected( mSelectedIncidence );
3067 3093
3068 if ( incidence && incidence->type() == "Event" ) { 3094 if ( incidence && incidence->type() == "Event" ) {
3069 Event *event = static_cast<Event *>( incidence ); 3095 Event *event = static_cast<Event *>( incidence );
3070 if ( event->organizer() == KOPrefs::instance()->email() ) { 3096 if ( event->organizer() == KOPrefs::instance()->email() ) {
3071 emit organizerEventsSelected( true ); 3097 emit organizerEventsSelected( true );
3072 } else { 3098 } else {
3073 emit organizerEventsSelected(false); 3099 emit organizerEventsSelected(false);
3074 } 3100 }
3075 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3101 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3076 KOPrefs::instance()->email() ) ) { 3102 KOPrefs::instance()->email() ) ) {
3077 emit groupEventsSelected( true ); 3103 emit groupEventsSelected( true );
3078 } else { 3104 } else {
3079 emit groupEventsSelected(false); 3105 emit groupEventsSelected(false);
3080 } 3106 }
3081 return; 3107 return;
3082 } else { 3108 } else {
3083 if ( incidence && incidence->type() == "Todo" ) { 3109 if ( incidence && incidence->type() == "Todo" ) {
3084 emit todoSelected( true ); 3110 emit todoSelected( true );
3085 Todo *event = static_cast<Todo *>( incidence ); 3111 Todo *event = static_cast<Todo *>( incidence );
3086 if ( event->organizer() == KOPrefs::instance()->email() ) { 3112 if ( event->organizer() == KOPrefs::instance()->email() ) {
3087 emit organizerEventsSelected( true ); 3113 emit organizerEventsSelected( true );
3088 } else { 3114 } else {
3089 emit organizerEventsSelected(false); 3115 emit organizerEventsSelected(false);
3090 } 3116 }
3091 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3117 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3092 KOPrefs::instance()->email() ) ) { 3118 KOPrefs::instance()->email() ) ) {
3093 emit groupEventsSelected( true ); 3119 emit groupEventsSelected( true );
3094 } else { 3120 } else {
3095 emit groupEventsSelected(false); 3121 emit groupEventsSelected(false);
3096 } 3122 }
3097 return; 3123 return;
3098 } else { 3124 } else {
3099 emit todoSelected( false ); 3125 emit todoSelected( false );
3100 emit organizerEventsSelected(false); 3126 emit organizerEventsSelected(false);
3101 emit groupEventsSelected(false); 3127 emit groupEventsSelected(false);
3102 } 3128 }
3103 return; 3129 return;
3104 } 3130 }
3105 3131
3106 /* if ( incidence && incidence->type() == "Todo" ) { 3132 /* if ( incidence && incidence->type() == "Todo" ) {
3107 emit todoSelected( true ); 3133 emit todoSelected( true );
3108 } else { 3134 } else {
3109 emit todoSelected( false ); 3135 emit todoSelected( false );
3110 }*/ 3136 }*/
3111} 3137}
3112 3138
3113 3139
3114void CalendarView::checkClipboard() 3140void CalendarView::checkClipboard()
3115{ 3141{
3116#ifndef KORG_NODND 3142#ifndef KORG_NODND
3117 if (ICalDrag::canDecode(QApplication::clipboard()->data())) { 3143 if (ICalDrag::canDecode(QApplication::clipboard()->data())) {
3118 emit pasteEnabled(true); 3144 emit pasteEnabled(true);
3119 } else { 3145 } else {
3120 emit pasteEnabled(false); 3146 emit pasteEnabled(false);
3121 } 3147 }
3122#endif 3148#endif
3123} 3149}
3124 3150
3125void CalendarView::showDates(const DateList &selectedDates) 3151void CalendarView::showDates(const DateList &selectedDates)
3126{ 3152{
3127 // kdDebug() << "CalendarView::selectDates()" << endl; 3153 // kdDebug() << "CalendarView::selectDates()" << endl;
3128 3154
3129 if ( mViewManager->currentView() ) { 3155 if ( mViewManager->currentView() ) {
3130 updateView( selectedDates.first(), selectedDates.last() ); 3156 updateView( selectedDates.first(), selectedDates.last() );
3131 } else { 3157 } else {
3132 mViewManager->showAgendaView(); 3158 mViewManager->showAgendaView();
3133 } 3159 }
3134 3160
3135 QString selDates; 3161 QString selDates;
3136 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); 3162 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true);
3137 if (selectedDates.first() < selectedDates.last() ) 3163 if (selectedDates.first() < selectedDates.last() )
3138 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); 3164 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true);
3139 topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); 3165 topLevelWidget()->setCaption( i18n("Dates: ") + selDates );
3140 3166
3141} 3167}
3142 3168
3143void CalendarView::editFilters() 3169void CalendarView::editFilters()
3144{ 3170{
3145 // kdDebug() << "CalendarView::editFilters()" << endl; 3171 // kdDebug() << "CalendarView::editFilters()" << endl;
3146 3172
3147 CalFilter *filter = mFilters.first(); 3173 CalFilter *filter = mFilters.first();
3148 while(filter) { 3174 while(filter) {
3149 kdDebug() << " Filter: " << filter->name() << endl; 3175 kdDebug() << " Filter: " << filter->name() << endl;
3150 filter = mFilters.next(); 3176 filter = mFilters.next();
3151 } 3177 }
3152 3178
3153 mDialogManager->showFilterEditDialog(&mFilters); 3179 mDialogManager->showFilterEditDialog(&mFilters);
3154} 3180}
3155void CalendarView::toggleFilter() 3181void CalendarView::toggleFilter()
3156{ 3182{
3157 showFilter(! mFilterView->isVisible()); 3183 showFilter(! mFilterView->isVisible());
3158} 3184}
3159 3185
3160void CalendarView::selectFilter( int fil ) 3186void CalendarView::selectFilter( int fil )
3161{ 3187{
3162 mFilterView->setSelectedFilter( fil ); 3188 mFilterView->setSelectedFilter( fil );
3163} 3189}
3164void CalendarView::showFilter(bool visible) 3190void CalendarView::showFilter(bool visible)
3165{ 3191{
3166 if (visible) mFilterView->show(); 3192 if (visible) mFilterView->show();
3167 else mFilterView->hide(); 3193 else mFilterView->hide();
3168} 3194}
3169void CalendarView::toggleFilerEnabled( ) 3195void CalendarView::toggleFilerEnabled( )
3170{ 3196{
3171 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); 3197 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() );
3172 if ( !mFilterView->filtersEnabled() ) 3198 if ( !mFilterView->filtersEnabled() )
3173 topLevelWidget()->setCaption( i18n("Filter disabled ") ); 3199 topLevelWidget()->setCaption( i18n("Filter disabled ") );
3174 3200
3175} 3201}
3176void CalendarView::updateFilter() 3202void CalendarView::updateFilter()
3177{ 3203{
3178 CalFilter *filter = mFilterView->selectedFilter(); 3204 CalFilter *filter = mFilterView->selectedFilter();
3179 if (filter) { 3205 if (filter) {
3180 if (mFilterView->filtersEnabled()) { 3206 if (mFilterView->filtersEnabled()) {
3181 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); 3207 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() );
3182 filter->setEnabled(true); 3208 filter->setEnabled(true);
3183 } 3209 }
3184 else filter->setEnabled(false); 3210 else filter->setEnabled(false);
3185 mCalendar->setFilter(filter); 3211 mCalendar->setFilter(filter);
3186 updateView(); 3212 updateView();
3187 } 3213 }
3188} 3214}
3189 3215
3190void CalendarView::filterEdited() 3216void CalendarView::filterEdited()
3191{ 3217{
3192 mFilterView->updateFilters(); 3218 mFilterView->updateFilters();
3193 updateFilter(); 3219 updateFilter();
3194 writeSettings(); 3220 writeSettings();
3195} 3221}
3196 3222
3197 3223
3198void CalendarView::takeOverEvent() 3224void CalendarView::takeOverEvent()
3199{ 3225{
3200 Incidence *incidence = currentSelection(); 3226 Incidence *incidence = currentSelection();
3201 3227
3202 if (!incidence) return; 3228 if (!incidence) return;
3203 3229
3204 incidence->setOrganizer(KOPrefs::instance()->email()); 3230 incidence->setOrganizer(KOPrefs::instance()->email());
3205 incidence->recreate(); 3231 incidence->recreate();
3206 incidence->setReadOnly(false); 3232 incidence->setReadOnly(false);
3207 3233
3208 updateView(); 3234 updateView();
3209} 3235}
3210 3236
3211void CalendarView::takeOverCalendar() 3237void CalendarView::takeOverCalendar()
3212{ 3238{
3213 // TODO: Create Calendar::allIncidences() function and use it here 3239 // TODO: Create Calendar::allIncidences() function and use it here
3214 3240
3215 QPtrList<Event> events = mCalendar->events(); 3241 QPtrList<Event> events = mCalendar->events();
3216 for(uint i=0; i<events.count(); ++i) { 3242 for(uint i=0; i<events.count(); ++i) {
3217 events.at(i)->setOrganizer(KOPrefs::instance()->email()); 3243 events.at(i)->setOrganizer(KOPrefs::instance()->email());
3218 events.at(i)->recreate(); 3244 events.at(i)->recreate();
3219 events.at(i)->setReadOnly(false); 3245 events.at(i)->setReadOnly(false);
3220 } 3246 }
3221 3247
3222 QPtrList<Todo> todos = mCalendar->todos(); 3248 QPtrList<Todo> todos = mCalendar->todos();
3223 for(uint i=0; i<todos.count(); ++i) { 3249 for(uint i=0; i<todos.count(); ++i) {
3224 todos.at(i)->setOrganizer(KOPrefs::instance()->email()); 3250 todos.at(i)->setOrganizer(KOPrefs::instance()->email());
3225 todos.at(i)->recreate(); 3251 todos.at(i)->recreate();
3226 todos.at(i)->setReadOnly(false); 3252 todos.at(i)->setReadOnly(false);
3227 } 3253 }
3228 3254
3229 QPtrList<Journal> journals = mCalendar->journals(); 3255 QPtrList<Journal> journals = mCalendar->journals();
3230 for(uint i=0; i<journals.count(); ++i) { 3256 for(uint i=0; i<journals.count(); ++i) {
3231 journals.at(i)->setOrganizer(KOPrefs::instance()->email()); 3257 journals.at(i)->setOrganizer(KOPrefs::instance()->email());
3232 journals.at(i)->recreate(); 3258 journals.at(i)->recreate();
3233 journals.at(i)->setReadOnly(false); 3259 journals.at(i)->setReadOnly(false);
3234 } 3260 }
3235 3261
3236 updateView(); 3262 updateView();
3237} 3263}
3238 3264
3239void CalendarView::showIntro() 3265void CalendarView::showIntro()
3240{ 3266{
3241 kdDebug() << "To be implemented." << endl; 3267 kdDebug() << "To be implemented." << endl;
3242} 3268}
3243 3269
3244QWidgetStack *CalendarView::viewStack() 3270QWidgetStack *CalendarView::viewStack()
3245{ 3271{
3246 return mRightFrame; 3272 return mRightFrame;
3247} 3273}
3248 3274
3249QWidget *CalendarView::leftFrame() 3275QWidget *CalendarView::leftFrame()
3250{ 3276{
3251 return mLeftFrame; 3277 return mLeftFrame;
3252} 3278}
3253 3279
3254DateNavigator *CalendarView::dateNavigator() 3280DateNavigator *CalendarView::dateNavigator()
3255{ 3281{
3256 return mNavigator; 3282 return mNavigator;
3257} 3283}
3258 3284
3259KDateNavigator* CalendarView::dateNavigatorWidget() 3285KDateNavigator* CalendarView::dateNavigatorWidget()
3260{ 3286{
3261 return mDateNavigator; 3287 return mDateNavigator;
3262} 3288}
3263void CalendarView::toggleDateNavigatorWidget() 3289void CalendarView::toggleDateNavigatorWidget()
3264{ 3290{
3265 if (mDateNavigator->isVisible()) 3291 if (mDateNavigator->isVisible())
3266 mDateNavigator->hide(); 3292 mDateNavigator->hide();
3267 else 3293 else
3268 mDateNavigator->show(); 3294 mDateNavigator->show();
3269} 3295}
3270void CalendarView::addView(KOrg::BaseView *view) 3296void CalendarView::addView(KOrg::BaseView *view)
3271{ 3297{
3272 mViewManager->addView(view); 3298 mViewManager->addView(view);
3273} 3299}
3274 3300
3275void CalendarView::showView(KOrg::BaseView *view) 3301void CalendarView::showView(KOrg::BaseView *view)
3276{ 3302{
3277 mViewManager->showView(view, mLeftFrame->isVisible()); 3303 mViewManager->showView(view, mLeftFrame->isVisible());
3278} 3304}
3279 3305
3280Incidence *CalendarView::currentSelection() 3306Incidence *CalendarView::currentSelection()
3281{ 3307{
3282 return mViewManager->currentSelection(); 3308 return mViewManager->currentSelection();
3283} 3309}
3284void CalendarView::toggleAllDaySize() 3310void CalendarView::toggleAllDaySize()
3285{ 3311{
3286 /* 3312 /*
3287 if ( KOPrefs::instance()->mAllDaySize > 47 ) 3313 if ( KOPrefs::instance()->mAllDaySize > 47 )
3288 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; 3314 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2;
3289 else 3315 else
3290 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; 3316 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2;
3291 */ 3317 */
3292 viewManager()->agendaView()->toggleAllDay(); 3318 viewManager()->agendaView()->toggleAllDay();
3293} 3319}
3294void CalendarView::toggleExpand() 3320void CalendarView::toggleExpand()
3295{ 3321{
3296 // if ( mLeftFrame->isHidden() ) { 3322 // if ( mLeftFrame->isHidden() ) {
3297 // mLeftFrame->show(); 3323 // mLeftFrame->show();
3298 // emit calendarViewExpanded( false ); 3324 // emit calendarViewExpanded( false );
3299 // } else { 3325 // } else {
3300 // mLeftFrame->hide(); 3326 // mLeftFrame->hide();
3301 // emit calendarViewExpanded( true ); 3327 // emit calendarViewExpanded( true );
3302 // } 3328 // }
3303 3329
3304 globalFlagBlockAgenda = 1; 3330 globalFlagBlockAgenda = 1;
3305 emit calendarViewExpanded( !mLeftFrame->isHidden() ); 3331 emit calendarViewExpanded( !mLeftFrame->isHidden() );
3306 globalFlagBlockAgenda = 5; 3332 globalFlagBlockAgenda = 5;
3307 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); 3333 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() );
3308 //mViewManager->showView( 0, true ); 3334 //mViewManager->showView( 0, true );
3309} 3335}
3310 3336
3311void CalendarView::calendarModified( bool modified, Calendar * ) 3337void CalendarView::calendarModified( bool modified, Calendar * )
3312{ 3338{
3313 setModified( modified ); 3339 setModified( modified );
3314} 3340}
3315 3341
3316Todo *CalendarView::selectedTodo() 3342Todo *CalendarView::selectedTodo()
3317{ 3343{
3318 Incidence *incidence = currentSelection(); 3344 Incidence *incidence = currentSelection();
3319 if ( incidence && incidence->type() == "Todo" ) { 3345 if ( incidence && incidence->type() == "Todo" ) {
3320 return static_cast<Todo *>( incidence ); 3346 return static_cast<Todo *>( incidence );
3321 } 3347 }
3322 3348
3323 incidence = mTodoList->selectedIncidences().first(); 3349 incidence = mTodoList->selectedIncidences().first();
3324 if ( incidence && incidence->type() == "Todo" ) { 3350 if ( incidence && incidence->type() == "Todo" ) {
3325 return static_cast<Todo *>( incidence ); 3351 return static_cast<Todo *>( incidence );
3326 } 3352 }
3327 3353
3328 return 0; 3354 return 0;
3329} 3355}
3330 3356
3331void CalendarView::dialogClosing(Incidence *in) 3357void CalendarView::dialogClosing(Incidence *in)
3332{ 3358{
3333 // mDialogList.remove(in); 3359 // mDialogList.remove(in);
3334} 3360}
3335 3361
3336void CalendarView::showIncidence() 3362void CalendarView::showIncidence()
3337{ 3363{
3338 Incidence *incidence = currentSelection(); 3364 Incidence *incidence = currentSelection();
3339 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3365 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3340 if ( incidence ) { 3366 if ( incidence ) {
3341 ShowIncidenceVisitor v; 3367 ShowIncidenceVisitor v;
3342 v.act( incidence, this ); 3368 v.act( incidence, this );
3343 } 3369 }
3344} 3370}
3345void CalendarView::editIncidenceDescription() 3371void CalendarView::editIncidenceDescription()
3346{ 3372{
3347 mFlagEditDescription = true; 3373 mFlagEditDescription = true;
3348 editIncidence(); 3374 editIncidence();
3349 mFlagEditDescription = false; 3375 mFlagEditDescription = false;
3350} 3376}
3351void CalendarView::editIncidence() 3377void CalendarView::editIncidence()
3352{ 3378{
3353 // qDebug("editIncidence() "); 3379 // qDebug("editIncidence() ");
3354 Incidence *incidence = currentSelection(); 3380 Incidence *incidence = currentSelection();
3355 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3381 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3356 if ( incidence ) { 3382 if ( incidence ) {
3357 EditIncidenceVisitor v; 3383 EditIncidenceVisitor v;
3358 v.act( incidence, this ); 3384 v.act( incidence, this );
3359 } 3385 }
3360} 3386}
3361 3387
3362void CalendarView::deleteIncidence() 3388void CalendarView::deleteIncidence()
3363{ 3389{
3364 Incidence *incidence = currentSelection(); 3390 Incidence *incidence = currentSelection();
3365 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3391 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3366 if ( incidence ) { 3392 if ( incidence ) {
3367 deleteIncidence(incidence); 3393 deleteIncidence(incidence);
3368 } 3394 }
3369} 3395}
3370 3396
3371void CalendarView::showIncidence(Incidence *incidence) 3397void CalendarView::showIncidence(Incidence *incidence)
3372{ 3398{
3373 if ( incidence ) { 3399 if ( incidence ) {
3374 ShowIncidenceVisitor v; 3400 ShowIncidenceVisitor v;
3375 v.act( incidence, this ); 3401 v.act( incidence, this );
3376 } 3402 }
3377} 3403}
3378 3404
3379void CalendarView::editIncidence(Incidence *incidence) 3405void CalendarView::editIncidence(Incidence *incidence)
3380{ 3406{
3381 if ( incidence ) { 3407 if ( incidence ) {
3382 3408
3383 EditIncidenceVisitor v; 3409 EditIncidenceVisitor v;
3384 v.act( incidence, this ); 3410 v.act( incidence, this );
3385 3411
3386 } 3412 }
3387} 3413}
3388 3414
3389void CalendarView::deleteIncidence(Incidence *incidence) 3415void CalendarView::deleteIncidence(Incidence *incidence)
3390{ 3416{
3391 //qDebug(" CalendarView::deleteIncidence "); 3417 //qDebug(" CalendarView::deleteIncidence ");
3392 if ( incidence ) { 3418 if ( incidence ) {
3393 DeleteIncidenceVisitor v; 3419 DeleteIncidenceVisitor v;
3394 v.act( incidence, this ); 3420 v.act( incidence, this );
3395 } 3421 }
3396} 3422}
3397 3423
3398 3424
3399void CalendarView::lookForOutgoingMessages() 3425void CalendarView::lookForOutgoingMessages()
3400{ 3426{
3401 OutgoingDialog *ogd = mDialogManager->outgoingDialog(); 3427 OutgoingDialog *ogd = mDialogManager->outgoingDialog();
3402 ogd->loadMessages(); 3428 ogd->loadMessages();
3403} 3429}
3404 3430
3405void CalendarView::lookForIncomingMessages() 3431void CalendarView::lookForIncomingMessages()
3406{ 3432{
3407 IncomingDialog *icd = mDialogManager->incomingDialog(); 3433 IncomingDialog *icd = mDialogManager->incomingDialog();
3408 icd->retrieve(); 3434 icd->retrieve();
3409} 3435}
3410 3436
3411bool CalendarView::removeCompletedSubTodos( Todo* t ) 3437bool CalendarView::removeCompletedSubTodos( Todo* t )
3412{ 3438{
3413 bool deleteTodo = true; 3439 bool deleteTodo = true;
3414 QPtrList<Incidence> subTodos; 3440 QPtrList<Incidence> subTodos;
3415 Incidence *aTodo; 3441 Incidence *aTodo;
3416 subTodos = t->relations(); 3442 subTodos = t->relations();
3417 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { 3443 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
3418 if (! removeCompletedSubTodos( (Todo*) aTodo )) 3444 if (! removeCompletedSubTodos( (Todo*) aTodo ))
3419 deleteTodo = false; 3445 deleteTodo = false;
3420 } 3446 }
3421 if ( deleteTodo ) { 3447 if ( deleteTodo ) {
3422 if ( t->isCompleted() ) { 3448 if ( t->isCompleted() ) {
3423 checkZaurusId( t->zaurusId(), true ); 3449 checkZaurusId( t->zaurusId(), true );
3424 mCalendar->deleteTodo( t ); 3450 mCalendar->deleteTodo( t );
3425 changeTodoDisplay( t,KOGlobals::EVENTDELETED ); 3451 changeTodoDisplay( t,KOGlobals::EVENTDELETED );
3426 } 3452 }
3427 else 3453 else
3428 deleteTodo = false; 3454 deleteTodo = false;
3429 } 3455 }
3430 return deleteTodo; 3456 return deleteTodo;
3431 3457
3432} 3458}
3433void CalendarView::purgeCompleted() 3459void CalendarView::purgeCompleted()
3434{ 3460{
3435 int result = KMessageBox::warningContinueCancel(this, 3461 int result = KMessageBox::warningContinueCancel(this,
3436 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); 3462 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge"));
3437 3463
3438 if (result == KMessageBox::Continue) { 3464 if (result == KMessageBox::Continue) {
3439 3465
3440 QPtrList<Todo> todoCal; 3466 QPtrList<Todo> todoCal;
3441 QPtrList<Todo> rootTodos; 3467 QPtrList<Todo> rootTodos;
3442 //QPtrList<Incidence> rel; 3468 //QPtrList<Incidence> rel;
3443 Todo *aTodo;//, *rTodo; 3469 Todo *aTodo;//, *rTodo;
3444 Incidence *rIncidence; 3470 Incidence *rIncidence;
3445 bool childDelete = false; 3471 bool childDelete = false;
3446 bool deletedOne = true; 3472 bool deletedOne = true;
3447 todoCal = calendar()->todos(); 3473 todoCal = calendar()->todos();
3448 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { 3474 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
3449 if ( !aTodo->relatedTo() ) 3475 if ( !aTodo->relatedTo() )
3450 rootTodos.append( aTodo ); 3476 rootTodos.append( aTodo );
3451 } 3477 }
3452 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { 3478 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) {
3453 removeCompletedSubTodos( aTodo ); 3479 removeCompletedSubTodos( aTodo );
3454 } 3480 }
3455 3481
3456 updateView(); 3482 updateView();
3457 } 3483 }
3458} 3484}
3459 3485
3460void CalendarView::slotCalendarChanged() 3486void CalendarView::slotCalendarChanged()
3461{ 3487{
3462 ; 3488 ;
3463} 3489}
3464 3490
3465NavigatorBar *CalendarView::navigatorBar() 3491NavigatorBar *CalendarView::navigatorBar()
3466{ 3492{
3467 return mNavigatorBar; 3493 return mNavigatorBar;
3468} 3494}
3469 3495
3470 3496
3471 3497
3472void CalendarView::keyPressEvent ( QKeyEvent *e) 3498void CalendarView::keyPressEvent ( QKeyEvent *e)
3473{ 3499{
3474 //qDebug(" alendarView::keyPressEvent "); 3500 //qDebug(" alendarView::keyPressEvent ");
3475 e->ignore(); 3501 e->ignore();
3476} 3502}
3477 3503
3478//#include "calendarview.moc" 3504//#include "calendarview.moc"
3479 3505
3480//#include "calendarviewbase.moc" 3506//#include "calendarviewbase.moc"
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index 8aa5e1c..557554f 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -1,586 +1,587 @@
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 117
117 signals: 118 signals:
118 /** This todo has been modified */ 119 /** This todo has been modified */
119 void todoModified(Todo *, int); 120 void todoModified(Todo *, int);
120 121
121 /** 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
122 * and emit this signal which notifies all widgets which have registered 123 * and emit this signal which notifies all widgets which have registered
123 * for notification to update their settings. */ 124 * for notification to update their settings. */
124 void configChanged(); 125 void configChanged();
125 /** emitted when the topwidget is closing down, so that any attached 126 /** emitted when the topwidget is closing down, so that any attached
126 child windows can also close. */ 127 child windows can also close. */
127 void closingDown(); 128 void closingDown();
128 /** emitted right before we die */ 129 /** emitted right before we die */
129 void closed(QWidget *); 130 void closed(QWidget *);
130 131
131 /** Emitted when state of modified flag changes */ 132 /** Emitted when state of modified flag changes */
132 void modifiedChanged(bool); 133 void modifiedChanged(bool);
133 void signalmodified(); 134 void signalmodified();
134 135
135 /** Emitted when state of read-only flag changes */ 136 /** Emitted when state of read-only flag changes */
136 void readOnlyChanged(bool); 137 void readOnlyChanged(bool);
137 138
138 /** Emitted when the unit of navigation changes */ 139 /** Emitted when the unit of navigation changes */
139 void changeNavStringPrev(const QString &); 140 void changeNavStringPrev(const QString &);
140 void changeNavStringNext(const QString &); 141 void changeNavStringNext(const QString &);
141 142
142 /** 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*/
143 void organizerEventsSelected(bool); 144 void organizerEventsSelected(bool);
144 /** 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*/
145 void groupEventsSelected(bool); 146 void groupEventsSelected(bool);
146 /** 147 /**
147 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
148 signal is emitted with 0 as argument. 149 signal is emitted with 0 as argument.
149 */ 150 */
150 void incidenceSelected( Incidence * ); 151 void incidenceSelected( Incidence * );
151 /** Emitted, when a todoitem is selected or deselected. */ 152 /** Emitted, when a todoitem is selected or deselected. */
152 void todoSelected( bool ); 153 void todoSelected( bool );
153 154
154 /** 155 /**
155 Emitted, when clipboard content changes. Parameter indicates if paste 156 Emitted, when clipboard content changes. Parameter indicates if paste
156 is possible or not. 157 is possible or not.
157 */ 158 */
158 void pasteEnabled(bool); 159 void pasteEnabled(bool);
159 160
160 /** Emitted, when the number of incoming messages has changed. */ 161 /** Emitted, when the number of incoming messages has changed. */
161 void numIncomingChanged(int); 162 void numIncomingChanged(int);
162 163
163 /** Emitted, when the number of outgoing messages has changed. */ 164 /** Emitted, when the number of outgoing messages has changed. */
164 void numOutgoingChanged(int); 165 void numOutgoingChanged(int);
165 166
166 /** 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. */
167 void statusMessage(const QString &); 168 void statusMessage(const QString &);
168 169
169 void calendarViewExpanded( bool ); 170 void calendarViewExpanded( bool );
170 void updateSearchDialog(); 171 void updateSearchDialog();
171 172
172 173
173 public slots: 174 public slots:
174 void recheckTimerAlarm(); 175 void recheckTimerAlarm();
175 void checkNextTimerAlarm(); 176 void checkNextTimerAlarm();
176 void addAlarm(const QDateTime &qdt, const QString &noti ); 177 void addAlarm(const QDateTime &qdt, const QString &noti );
177 void addSuspendAlarm(const QDateTime &qdt, const QString &noti ); 178 void addSuspendAlarm(const QDateTime &qdt, const QString &noti );
178 void removeAlarm(const QDateTime &qdt, const QString &noti ); 179 void removeAlarm(const QDateTime &qdt, const QString &noti );
179 180
180 /** options dialog made a changed to the configuration. we catch this 181 /** options dialog made a changed to the configuration. we catch this
181 * and notify all widgets which need to update their configuration. */ 182 * and notify all widgets which need to update their configuration. */
182 void updateConfig(); 183 void updateConfig();
183 184
184 /** 185 /**
185 Load calendar from file \a filename. If \a merge is true, load 186 Load calendar from file \a filename. If \a merge is true, load
186 calendar into existing one, if it is false, clear calendar, before 187 calendar into existing one, if it is false, clear calendar, before
187 loading. Return true, if calendar could be successfully loaded. 188 loading. Return true, if calendar could be successfully loaded.
188 */ 189 */
189 bool openCalendar(QString filename, bool merge=false); 190 bool openCalendar(QString filename, bool merge=false);
190 bool syncCalendar(QString filename,int mode = 0 ); 191 bool syncCalendar(QString filename,int mode = 0 );
191 192
192 /** 193 /**
193 Save calendar data to file. Return true if calendar could be 194 Save calendar data to file. Return true if calendar could be
194 successfully saved. 195 successfully saved.
195 */ 196 */
196 bool saveCalendar(QString filename); 197 bool saveCalendar(QString filename);
197 198
198 /** 199 /**
199 Close calendar. Clear calendar data and reset views to display an empty 200 Close calendar. Clear calendar data and reset views to display an empty
200 calendar. 201 calendar.
201 */ 202 */
202 void closeCalendar(); 203 void closeCalendar();
203 204
204 /** Archive old events of calendar */ 205 /** Archive old events of calendar */
205 void archiveCalendar(); 206 void archiveCalendar();
206 207
207 void showIncidence(); 208 void showIncidence();
208 void editIncidence(); 209 void editIncidence();
209 void editIncidenceDescription(); 210 void editIncidenceDescription();
210 void deleteIncidence(); 211 void deleteIncidence();
211 212
212 /** create an editeventwin with supplied date/time, and if bool is true, 213 /** create an editeventwin with supplied date/time, and if bool is true,
213 * make the event take all day. */ 214 * make the event take all day. */
214 void newEvent(QDateTime, QDateTime, bool allDay = false); 215 void newEvent(QDateTime, QDateTime, bool allDay = false);
215 void newEvent(QDateTime fh); 216 void newEvent(QDateTime fh);
216 void newEvent(QDate dt); 217 void newEvent(QDate dt);
217 /** create new event without having a date hint. Takes current date as 218 /** create new event without having a date hint. Takes current date as
218 default hint. */ 219 default hint. */
219 void newEvent(); 220 void newEvent();
220 void newFloatingEvent(); 221 void newFloatingEvent();
221 222
222 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ 223 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/
223 void showIncidence(Incidence *); 224 void showIncidence(Incidence *);
224 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ 225 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/
225 void editIncidence(Incidence *); 226 void editIncidence(Incidence *);
226 /** Delete the supplied incidence. It calls the correct deleteXXX method*/ 227 /** Delete the supplied incidence. It calls the correct deleteXXX method*/
227 void deleteIncidence(Incidence *); 228 void deleteIncidence(Incidence *);
228 void cloneIncidence(Incidence *); 229 void cloneIncidence(Incidence *);
229 void cancelIncidence(Incidence *); 230 void cancelIncidence(Incidence *);
230 /** Create an editor for the supplied event. */ 231 /** Create an editor for the supplied event. */
231 void editEvent(Event *); 232 void editEvent(Event *);
232 /** Delete the supplied event. */ 233 /** Delete the supplied event. */
233 void deleteEvent(Event *); 234 void deleteEvent(Event *);
234 /** Delete the event with the given unique ID. Returns false, if event wasn't 235 /** Delete the event with the given unique ID. Returns false, if event wasn't
235 found. */ 236 found. */
236 bool deleteEvent(const QString &uid); 237 bool deleteEvent(const QString &uid);
237 /** Create a read-only viewer dialog for the supplied event. */ 238 /** Create a read-only viewer dialog for the supplied event. */
238 void showEvent(Event *); 239 void showEvent(Event *);
239 240
240 void editJournal(Journal *); 241 void editJournal(Journal *);
241 void showJournal(Journal *); 242 void showJournal(Journal *);
242 void deleteJournal(Journal *); 243 void deleteJournal(Journal *);
243 /** Create an editor dialog for a todo */ 244 /** Create an editor dialog for a todo */
244 void editTodo(Todo *); 245 void editTodo(Todo *);
245 /** Create a read-only viewer dialog for the supplied todo */ 246 /** Create a read-only viewer dialog for the supplied todo */
246 void showTodo(Todo *); 247 void showTodo(Todo *);
247 /** create new todo */ 248 /** create new todo */
248 void newTodo(); 249 void newTodo();
249 /** create new todo with a parent todo */ 250 /** create new todo with a parent todo */
250 void newSubTodo(); 251 void newSubTodo();
251 /** create new todo with a parent todo */ 252 /** create new todo with a parent todo */
252 void newSubTodo(Todo *); 253 void newSubTodo(Todo *);
253 /** Delete todo */ 254 /** Delete todo */
254 void deleteTodo(Todo *); 255 void deleteTodo(Todo *);
255 256
256 257
257 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is 258 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is
258 * emitted as result. */ 259 * emitted as result. */
259 void checkClipboard(); 260 void checkClipboard();
260 261
261 /** using the KConfig associated with the kapp variable, read in the 262 /** using the KConfig associated with the kapp variable, read in the
262 * settings from the config file. 263 * settings from the config file.
263 */ 264 */
264 void readSettings(); 265 void readSettings();
265 266
266 /** write current state to config file. */ 267 /** write current state to config file. */
267 void writeSettings(); 268 void writeSettings();
268 269
269 /** read settings for calendar filters */ 270 /** read settings for calendar filters */
270 void readFilterSettings(KConfig *config); 271 void readFilterSettings(KConfig *config);
271 272
272 /** write settings for calendar filters */ 273 /** write settings for calendar filters */
273 void writeFilterSettings(KConfig *config); 274 void writeFilterSettings(KConfig *config);
274 275
275 /** passes on the message that an event has changed to the currently 276 /** passes on the message that an event has changed to the currently
276 * activated view so that it can make appropriate display changes. */ 277 * activated view so that it can make appropriate display changes. */
277 void changeEventDisplay(Event *, int); 278 void changeEventDisplay(Event *, int);
278 void changeIncidenceDisplay(Incidence *, int); 279 void changeIncidenceDisplay(Incidence *, int);
279 void changeTodoDisplay(Todo *, int); 280 void changeTodoDisplay(Todo *, int);
280 281
281 void eventAdded(Event *); 282 void eventAdded(Event *);
282 void eventChanged(Event *); 283 void eventChanged(Event *);
283 void eventToBeDeleted(Event *); 284 void eventToBeDeleted(Event *);
284 void eventDeleted(); 285 void eventDeleted();
285 286
286 void todoAdded(Todo *); 287 void todoAdded(Todo *);
287 void todoChanged(Todo *); 288 void todoChanged(Todo *);
288 void todoToBeDeleted(Todo *); 289 void todoToBeDeleted(Todo *);
289 void todoDeleted(); 290 void todoDeleted();
290 291
291 void updateView(const QDate &start, const QDate &end); 292 void updateView(const QDate &start, const QDate &end);
292 void updateView(); 293 void updateView();
293 294
294 /** Full update of visible todo views */ 295 /** Full update of visible todo views */
295 void updateTodoViews(); 296 void updateTodoViews();
296 297
297 void updateUnmanagedViews(); 298 void updateUnmanagedViews();
298 299
299 /** cut the current appointment to the clipboard */ 300 /** cut the current appointment to the clipboard */
300 void edit_cut(); 301 void edit_cut();
301 302
302 /** copy the current appointment(s) to the clipboard */ 303 /** copy the current appointment(s) to the clipboard */
303 void edit_copy(); 304 void edit_copy();
304 305
305 /** paste the current vobject(s) in the clipboard buffer into calendar */ 306 /** paste the current vobject(s) in the clipboard buffer into calendar */
306 void edit_paste(); 307 void edit_paste();
307 308
308 /** edit viewing and configuration options. */ 309 /** edit viewing and configuration options. */
309 void edit_options(); 310 void edit_options();
310 void edit_sync_options(); 311 void edit_sync_options();
311 /** 312 /**
312 Functions for printing, previewing a print, and setting up printing 313 Functions for printing, previewing a print, and setting up printing
313 parameters. 314 parameters.
314 */ 315 */
315 void print(); 316 void print();
316 void printSetup(); 317 void printSetup();
317 void printPreview(); 318 void printPreview();
318 319
319 /** Export as iCalendar file */ 320 /** Export as iCalendar file */
320 void exportICalendar(); 321 void exportICalendar();
321 322
322 /** Export as vCalendar file */ 323 /** Export as vCalendar file */
323 bool exportVCalendar( QString fn); 324 bool exportVCalendar( QString fn);
324 325
325 /** pop up a dialog to show an existing appointment. */ 326 /** pop up a dialog to show an existing appointment. */
326 void appointment_show(); 327 void appointment_show();
327 /** 328 /**
328 * pop up an Appointment Dialog to edit an existing appointment.Get 329 * pop up an Appointment Dialog to edit an existing appointment.Get
329 * information on the appointment from the list of unique IDs that is 330 * information on the appointment from the list of unique IDs that is
330 * currently in the View, called currIds. 331 * currently in the View, called currIds.
331 */ 332 */
332 void appointment_edit(); 333 void appointment_edit();
333 /** 334 /**
334 * pop up dialog confirming deletion of currently selected event in the 335 * pop up dialog confirming deletion of currently selected event in the
335 * View. 336 * View.
336 */ 337 */
337 void appointment_delete(); 338 void appointment_delete();
338 339
339 /** mails the currently selected event to a particular user as a vCalendar 340 /** mails the currently selected event to a particular user as a vCalendar
340 attachment. */ 341 attachment. */
341 void action_mail(); 342 void action_mail();
342 343
343 /* frees a subtodo from it's relation */ 344 /* frees a subtodo from it's relation */
344 void todo_unsub( Todo * ); 345 void todo_unsub( Todo * );
345 346
346 /** Take ownership of selected event. */ 347 /** Take ownership of selected event. */
347 void takeOverEvent(); 348 void takeOverEvent();
348 349
349 /** Take ownership of all events in calendar. */ 350 /** Take ownership of all events in calendar. */
350 void takeOverCalendar(); 351 void takeOverCalendar();
351 352
352 /** query whether or not the calendar is "dirty". */ 353 /** query whether or not the calendar is "dirty". */
353 bool isModified(); 354 bool isModified();
354 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ 355 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */
355 void setModified(bool modified=true); 356 void setModified(bool modified=true);
356 357
357 /** query if the calendar is read-only. */ 358 /** query if the calendar is read-only. */
358 bool isReadOnly(); 359 bool isReadOnly();
359 /** set state of calendar to read-only */ 360 /** set state of calendar to read-only */
360 void setReadOnly(bool readOnly=true); 361 void setReadOnly(bool readOnly=true);
361 362
362 void eventUpdated(Incidence *); 363 void eventUpdated(Incidence *);
363 364
364 /* iTIP scheduling actions */ 365 /* iTIP scheduling actions */
365 void schedule_publish(Incidence *incidence = 0); 366 void schedule_publish(Incidence *incidence = 0);
366 void schedule_request(Incidence *incidence = 0); 367 void schedule_request(Incidence *incidence = 0);
367 void schedule_refresh(Incidence *incidence = 0); 368 void schedule_refresh(Incidence *incidence = 0);
368 void schedule_cancel(Incidence *incidence = 0); 369 void schedule_cancel(Incidence *incidence = 0);
369 void schedule_add(Incidence *incidence = 0); 370 void schedule_add(Incidence *incidence = 0);
370 void schedule_reply(Incidence *incidence = 0); 371 void schedule_reply(Incidence *incidence = 0);
371 void schedule_counter(Incidence *incidence = 0); 372 void schedule_counter(Incidence *incidence = 0);
372 void schedule_declinecounter(Incidence *incidence = 0); 373 void schedule_declinecounter(Incidence *incidence = 0);
373 void schedule_publish_freebusy(int daysToPublish = 30); 374 void schedule_publish_freebusy(int daysToPublish = 30);
374 375
375 void openAddressbook(); 376 void openAddressbook();
376 377
377 void editFilters(); 378 void editFilters();
378 void toggleFilerEnabled(); 379 void toggleFilerEnabled();
379 380
380 void toggleFilter(); 381 void toggleFilter();
381 void showFilter(bool visible); 382 void showFilter(bool visible);
382 void updateFilter(); 383 void updateFilter();
383 void filterEdited(); 384 void filterEdited();
384 void selectFilter( int ); 385 void selectFilter( int );
385 386
386 void showIntro(); 387 void showIntro();
387 388
388 /** Move the curdatepient view date to today */ 389 /** Move the curdatepient view date to today */
389 void goToday(); 390 void goToday();
390 391
391 /** Move to the next date(s) in the current view */ 392 /** Move to the next date(s) in the current view */
392 void goNext(); 393 void goNext();
393 394
394 /** Move to the previous date(s) in the current view */ 395 /** Move to the previous date(s) in the current view */
395 void goPrevious(); 396 void goPrevious();
396 /** Move to the next date(s) in the current view */ 397 /** Move to the next date(s) in the current view */
397 void goNextMonth(); 398 void goNextMonth();
398 399
399 /** Move to the previous date(s) in the current view */ 400 /** Move to the previous date(s) in the current view */
400 void goPreviousMonth(); 401 void goPreviousMonth();
401 402
402 void toggleExpand(); 403 void toggleExpand();
403 void toggleDateNavigatorWidget(); 404 void toggleDateNavigatorWidget();
404 void toggleAllDaySize(); 405 void toggleAllDaySize();
405 void dialogClosing(Incidence *); 406 void dialogClosing(Incidence *);
406 407
407 /** Look for new messages in the inbox */ 408 /** Look for new messages in the inbox */
408 void lookForIncomingMessages(); 409 void lookForIncomingMessages();
409 /** Look for new messages in the outbox */ 410 /** Look for new messages in the outbox */
410 void lookForOutgoingMessages(); 411 void lookForOutgoingMessages();
411 412
412 void processMainViewSelection( Incidence * ); 413 void processMainViewSelection( Incidence * );
413 void processTodoListSelection( Incidence * ); 414 void processTodoListSelection( Incidence * );
414 415
415 void processIncidenceSelection( Incidence * ); 416 void processIncidenceSelection( Incidence * );
416 417
417 void purgeCompleted(); 418 void purgeCompleted();
418 bool removeCompletedSubTodos( Todo* ); 419 bool removeCompletedSubTodos( Todo* );
419 void slotCalendarChanged(); 420 void slotCalendarChanged();
420 bool importBday(); 421 bool importBday();
421 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); 422 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday );
422 bool importQtopia( const QString &categoriesFile, 423 bool importQtopia( const QString &categoriesFile,
423 const QString &datebookFile, 424 const QString &datebookFile,
424 const QString &tasklistFile ); 425 const QString &tasklistFile );
425 void syncSharp( ); 426 void syncSharp( );
426 void slotSelectPickerDate( QDate ) ; 427 void slotSelectPickerDate( QDate ) ;
427 void showDatePicker( ) ; 428 void showDatePicker( ) ;
428 void moveIncidence(Incidence *) ; 429 void moveIncidence(Incidence *) ;
429 void beamIncidence(Incidence *) ; 430 void beamIncidence(Incidence *) ;
430 void beamCalendar() ; 431 void beamCalendar() ;
431 void beamFilteredCalendar() ; 432 void beamFilteredCalendar() ;
432 void beamIncidenceList(QPtrList<Incidence>) ; 433 void beamIncidenceList(QPtrList<Incidence>) ;
433 void manageCategories(); 434 void manageCategories();
434 int addCategories(); 435 int addCategories();
435 void removeCategories(); 436 void removeCategories();
436 void setSyncDevice( QString ); 437 void setSyncDevice( QString );
437 void setSyncName( QString ); 438 void setSyncName( QString );
438 protected slots: 439 protected slots:
439 void timerAlarm(); 440 void timerAlarm();
440 void suspendAlarm(); 441 void suspendAlarm();
441 void beamDone( Ir *ir ); 442 void beamDone( Ir *ir );
442 /** Select a view or adapt the current view to display the specified dates. */ 443 /** Select a view or adapt the current view to display the specified dates. */
443 void showDates( const KCal::DateList & ); 444 void showDates( const KCal::DateList & );
444 void selectWeekNum ( int ); 445 void selectWeekNum ( int );
445 446
446 public: 447 public:
447 // show a standard warning 448 // show a standard warning
448 // returns KMsgBox::yesNoCancel() 449 // returns KMsgBox::yesNoCancel()
449 int msgCalModified(); 450 int msgCalModified();
450 void confSync(); 451 void confSync();
451 void setLoadedFileVersion(QDateTime); 452 void setLoadedFileVersion(QDateTime);
452 bool checkFileVersion(QString fn); 453 bool checkFileVersion(QString fn);
453 bool checkFileChanged(QString fn); 454 bool checkFileChanged(QString fn);
454 Event* getLastSyncEvent(); 455 Event* getLastSyncEvent();
455 /** Adapt navigation units correpsonding to step size of navigation of the 456 /** Adapt navigation units correpsonding to step size of navigation of the
456 * current view. 457 * current view.
457 */ 458 */
458 void adaptNavigationUnits(); 459 void adaptNavigationUnits();
459 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); 460 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode );
460 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); 461 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false );
461 //Attendee* getYourAttendee(Event *event); 462 //Attendee* getYourAttendee(Event *event);
462 protected: 463 protected:
463 void schedule(Scheduler::Method, Incidence *incidence = 0); 464 void schedule(Scheduler::Method, Incidence *incidence = 0);
464 465
465 // returns KMsgBox::OKCandel() 466 // returns KMsgBox::OKCandel()
466 int msgItemDelete(); 467 int msgItemDelete();
467 void showEventEditor(); 468 void showEventEditor();
468 void showTodoEditor(); 469 void showTodoEditor();
469 void writeLocale(); 470 void writeLocale();
470 Todo *selectedTodo(); 471 Todo *selectedTodo();
471 472
472 private: 473 private:
473 AlarmDialog * mAlarmDialog; 474 AlarmDialog * mAlarmDialog;
474 QString mAlarmNotification; 475 QString mAlarmNotification;
475 QString mSuspendAlarmNotification; 476 QString mSuspendAlarmNotification;
476 QTimer* mSuspendTimer; 477 QTimer* mSuspendTimer;
477 QTimer* mAlarmTimer; 478 QTimer* mAlarmTimer;
478 QTimer* mRecheckAlarmTimer; 479 QTimer* mRecheckAlarmTimer;
479 void computeAlarm( QString ); 480 void computeAlarm( QString );
480 void startAlarm( QString, QString ); 481 void startAlarm( QString, QString );
481 void setSyncEventsReadOnly(); 482 void setSyncEventsReadOnly();
482 483
483 QDateTime loadedFileVersion; 484 QDateTime loadedFileVersion;
484 void checkSharpEvent( Event* lastSync, Incidence* toDelete ); 485 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete );
485 void checkZaurusId( int id, bool todo = false ); 486 void checkZaurusId( int id, bool todo = false );
486 int mGlobalSyncMode; 487 int mGlobalSyncMode;
487 QString mCurrentSyncDevice; 488 QString mCurrentSyncDevice;
488 QString mCurrentSyncName; 489 QString mCurrentSyncName;
489 KOBeamPrefs* beamDialog; 490 KOBeamPrefs* beamDialog;
490 void init(); 491 void init();
491 int mDatePickerMode; 492 int mDatePickerMode;
492 bool mFlagEditDescription; 493 bool mFlagEditDescription;
493 QDateTime mLastCalendarSync; 494 QDateTime mLastCalendarSync;
494 void createPrinter(); 495 void createPrinter();
495 496
496 void calendarModified( bool, Calendar * ); 497 void calendarModified( bool, Calendar * );
497 498
498 CalPrinter *mCalPrinter; 499 CalPrinter *mCalPrinter;
499 500
500 QSplitter *mPanner; 501 QSplitter *mPanner;
501 QSplitter *mLeftSplitter; 502 QSplitter *mLeftSplitter;
502 QWidget *mLeftFrame; 503 QWidget *mLeftFrame;
503 QWidgetStack *mRightFrame; 504 QWidgetStack *mRightFrame;
504 505
505 KDatePicker* mDatePicker; 506 KDatePicker* mDatePicker;
506 QVBox* mDateFrame; 507 QVBox* mDateFrame;
507 NavigatorBar *mNavigatorBar; 508 NavigatorBar *mNavigatorBar;
508 509
509 KDateNavigator *mDateNavigator; // widget showing small month view. 510 KDateNavigator *mDateNavigator; // widget showing small month view.
510 511
511 KOFilterView *mFilterView; 512 KOFilterView *mFilterView;
512 513
513 ResourceView *mResourceView; 514 ResourceView *mResourceView;
514 515
515 // calendar object for this viewing instance 516 // calendar object for this viewing instance
516 Calendar *mCalendar; 517 Calendar *mCalendar;
517 518
518 CalendarResourceManager *mResourceManager; 519 CalendarResourceManager *mResourceManager;
519 520
520 FileStorage *mStorage; 521 FileStorage *mStorage;
521 522
522 DateNavigator *mNavigator; 523 DateNavigator *mNavigator;
523 524
524 KOViewManager *mViewManager; 525 KOViewManager *mViewManager;
525 KODialogManager *mDialogManager; 526 KODialogManager *mDialogManager;
526 527
527 // Calendar filters 528 // Calendar filters
528 QPtrList<CalFilter> mFilters; 529 QPtrList<CalFilter> mFilters;
529 530
530 // various housekeeping variables. 531 // various housekeeping variables.
531 bool mModified; // flag indicating if calendar is modified 532 bool mModified; // flag indicating if calendar is modified
532 bool mReadOnly; // flag indicating if calendar is read-only 533 bool mReadOnly; // flag indicating if calendar is read-only
533 QDate mSaveSingleDate; 534 QDate mSaveSingleDate;
534 535
535 Incidence *mSelectedIncidence; 536 Incidence *mSelectedIncidence;
536 Incidence *mMoveIncidence; 537 Incidence *mMoveIncidence;
537 538 QPtrList<Event> mExternLastSyncEvent;
538 KOTodoView *mTodoList; 539 KOTodoView *mTodoList;
539 KOEventEditor * mEventEditor; 540 KOEventEditor * mEventEditor;
540 KOTodoEditor * mTodoEditor; 541 KOTodoEditor * mTodoEditor;
541 KOEventViewerDialog * mEventViewerDialog; 542 KOEventViewerDialog * mEventViewerDialog;
542 void keyPressEvent ( QKeyEvent *e) ; 543 void keyPressEvent ( QKeyEvent *e) ;
543 //QMap<Incidence*,KOIncidenceEditor*> mDialogList; 544 //QMap<Incidence*,KOIncidenceEditor*> mDialogList;
544}; 545};
545 546
546 547
547class CalendarViewVisitor : public Incidence::Visitor 548class CalendarViewVisitor : public Incidence::Visitor
548{ 549{
549 public: 550 public:
550 CalendarViewVisitor() : mView( 0 ) {} 551 CalendarViewVisitor() : mView( 0 ) {}
551 552
552 bool act( Incidence *incidence, CalendarView *view ) 553 bool act( Incidence *incidence, CalendarView *view )
553 { 554 {
554 mView = view; 555 mView = view;
555 return incidence->accept( *this ); 556 return incidence->accept( *this );
556 } 557 }
557 558
558 protected: 559 protected:
559 CalendarView *mView; 560 CalendarView *mView;
560}; 561};
561 562
562class ShowIncidenceVisitor : public CalendarViewVisitor 563class ShowIncidenceVisitor : public CalendarViewVisitor
563{ 564{
564 protected: 565 protected:
565 bool visit( Event *event ) { mView->showEvent( event ); return true; } 566 bool visit( Event *event ) { mView->showEvent( event ); return true; }
566 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } 567 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; }
567 bool visit( Journal * j ) { mView->showJournal( j );return true; } 568 bool visit( Journal * j ) { mView->showJournal( j );return true; }
568}; 569};
569 570
570class EditIncidenceVisitor : public CalendarViewVisitor 571class EditIncidenceVisitor : public CalendarViewVisitor
571{ 572{
572 protected: 573 protected:
573 bool visit( Event *event ) { mView->editEvent( event ); return true; } 574 bool visit( Event *event ) { mView->editEvent( event ); return true; }
574 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } 575 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; }
575 bool visit( Journal *j ) { mView->editJournal( j); return true; } 576 bool visit( Journal *j ) { mView->editJournal( j); return true; }
576}; 577};
577 578
578class DeleteIncidenceVisitor : public CalendarViewVisitor 579class DeleteIncidenceVisitor : public CalendarViewVisitor
579{ 580{
580 protected: 581 protected:
581 bool visit( Event *event ) { mView->deleteEvent( event ); return true; } 582 bool visit( Event *event ) { mView->deleteEvent( event ); return true; }
582 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } 583 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; }
583 bool visit( Journal * j) {mView->deleteJournal( j ); return true; } 584 bool visit( Journal * j) {mView->deleteJournal( j ); return true; }
584}; 585};
585 586
586#endif 587#endif
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp
index 3ba5ab2..f3231ff 100644
--- a/korganizer/koprefs.cpp
+++ b/korganizer/koprefs.cpp
@@ -1,559 +1,560 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <time.h> 24#include <time.h>
25#ifndef _WIN32_ 25#ifndef _WIN32_
26#include <unistd.h> 26#include <unistd.h>
27#endif 27#endif
28#include <qdir.h> 28#include <qdir.h>
29#include <qtextstream.h> 29#include <qtextstream.h>
30#include <qtextcodec.h> 30#include <qtextcodec.h>
31#include <qstring.h> 31#include <qstring.h>
32#include <qfont.h> 32#include <qfont.h>
33#include <qcolor.h> 33#include <qcolor.h>
34#include <qstringlist.h> 34#include <qstringlist.h>
35#include <stdlib.h> 35#include <stdlib.h>
36 36
37#include <kglobal.h> 37#include <kglobal.h>
38#include <kconfig.h> 38#include <kconfig.h>
39#include <klocale.h> 39#include <klocale.h>
40#include <kdebug.h> 40#include <kdebug.h>
41#include <kemailsettings.h> 41#include <kemailsettings.h>
42#include <kstaticdeleter.h> 42#include <kstaticdeleter.h>
43 43
44#include "koprefs.h" 44#include "koprefs.h"
45#include "mainwindow.h" 45#include "mainwindow.h"
46 46
47const char *germanwords[][2] = { 47const char *germanwords[][2] = {
48#include "wordsgerman.h" 48#include "wordsgerman.h"
49 "", "" 49 "", ""
50}; 50};
51 51
52KOPrefs *KOPrefs::mInstance = 0; 52KOPrefs *KOPrefs::mInstance = 0;
53static KStaticDeleter<KOPrefs> insd; 53static KStaticDeleter<KOPrefs> insd;
54 54
55KOPrefs::KOPrefs() : 55KOPrefs::KOPrefs() :
56 KPimPrefs("korganizerrc") 56 KPimPrefs("korganizerrc")
57{ 57{
58 mCategoryColors.setAutoDelete(true); 58 mCategoryColors.setAutoDelete(true);
59 mLocaleDict = 0; 59 mLocaleDict = 0;
60 fillMailDefaults(); 60 fillMailDefaults();
61 mDefaultCategoryColor = QColor(175,210,255);//196,196,196); 61 mDefaultCategoryColor = QColor(175,210,255);//196,196,196);
62 QColor defaultHolidayColor = QColor(255,0,0); 62 QColor defaultHolidayColor = QColor(255,0,0);
63 QColor defaultHighlightColor = QColor(129,112,255);//64,64,255); 63 QColor defaultHighlightColor = QColor(129,112,255);//64,64,255);
64 QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128); 64 QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128);
65 QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160); 65 QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160);
66 QColor defaultTodoDueTodayColor = QColor(255,220,100); 66 QColor defaultTodoDueTodayColor = QColor(255,220,100);
67 QColor defaultTodoOverdueColor = QColor(255,153,125); 67 QColor defaultTodoOverdueColor = QColor(255,153,125);
68 68
69 mTimeBarFont = QFont("helvetica",10);//,QFont::Bold); 69 mTimeBarFont = QFont("helvetica",10);//,QFont::Bold);
70 mDefaultViewFont = QFont("helvetica",10); 70 mDefaultViewFont = QFont("helvetica",10);
71 mDefaultMonthViewFont = QFont("helvetica",8); 71 mDefaultMonthViewFont = QFont("helvetica",8);
72 mMarcusBainsFont= QFont("helvetica",10); 72 mMarcusBainsFont= QFont("helvetica",10);
73 mDateNavigatorFont= QFont("helvetica",10, QFont::Bold); 73 mDateNavigatorFont= QFont("helvetica",10, QFont::Bold);
74 mEditBoxFont = QFont("helvetica",12); 74 mEditBoxFont = QFont("helvetica",12);
75 mJornalViewFont = QFont("helvetica",12); 75 mJornalViewFont = QFont("helvetica",12);
76 76
77 KPrefs::setCurrentGroup("General"); 77 KPrefs::setCurrentGroup("General");
78 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); 78 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false);
79 79
80 addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true); 80 addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true);
81 addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true); 81 addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true);
82 addItemBool("ShowIconSearch",&mShowIconSearch,true); 82 addItemBool("ShowIconSearch",&mShowIconSearch,true);
83 addItemBool("ShowIconList",&mShowIconList,true); 83 addItemBool("ShowIconList",&mShowIconList,true);
84 addItemBool("ShowIconDay1",&mShowIconDay1,true); 84 addItemBool("ShowIconDay1",&mShowIconDay1,true);
85 addItemBool("ShowIconDay5",&mShowIconDay5,true); 85 addItemBool("ShowIconDay5",&mShowIconDay5,true);
86 addItemBool("ShowIconDay7",&mShowIconDay7,true); 86 addItemBool("ShowIconDay7",&mShowIconDay7,true);
87 addItemBool("ShowIconMonth",&mShowIconMonth,true); 87 addItemBool("ShowIconMonth",&mShowIconMonth,true);
88 addItemBool("ShowIconTodoview",&mShowIconTodoview,true); 88 addItemBool("ShowIconTodoview",&mShowIconTodoview,true);
89 addItemBool("ShowIconBackFast",&mShowIconBackFast,true); 89 addItemBool("ShowIconBackFast",&mShowIconBackFast,true);
90 addItemBool("ShowIconBack",&mShowIconBack,true); 90 addItemBool("ShowIconBack",&mShowIconBack,true);
91 addItemBool("ShowIconToday",&mShowIconToday,true); 91 addItemBool("ShowIconToday",&mShowIconToday,true);
92 addItemBool("ShowIconForward",&mShowIconForward,true); 92 addItemBool("ShowIconForward",&mShowIconForward,true);
93 addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true); 93 addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true);
94 addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,false); 94 addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,false);
95 addItemBool("ShowIconNextDays",&mShowIconNextDays,true); 95 addItemBool("ShowIconNextDays",&mShowIconNextDays,true);
96 addItemBool("ShowIconNext",&mShowIconNext,true); 96 addItemBool("ShowIconNext",&mShowIconNext,true);
97 addItemBool("ShowIconJournal",&mShowIconJournal,true); 97 addItemBool("ShowIconJournal",&mShowIconJournal,true);
98 addItemBool("ShowIconStretch",&mShowIconStretch,true); 98 addItemBool("ShowIconStretch",&mShowIconStretch,true);
99 addItemBool("LanguageChanged",&mLanguageChanged,false); 99 addItemBool("LanguageChanged",&mLanguageChanged,false);
100 100
101 addItemBool("AskForQuit",&mAskForQuit,false); 101 addItemBool("AskForQuit",&mAskForQuit,false);
102 102
103#ifndef DESKTOP_VERSION 103#ifndef DESKTOP_VERSION
104 addItemBool("ShowFullMenu",&mShowFullMenu,false); 104 addItemBool("ShowFullMenu",&mShowFullMenu,false);
105#else 105#else
106 addItemBool("ShowFullMenu",&mShowFullMenu,true); 106 addItemBool("ShowFullMenu",&mShowFullMenu,true);
107#endif 107#endif
108 addItemBool("ToolBarHor",&mToolBarHor, true ); 108 addItemBool("ToolBarHor",&mToolBarHor, true );
109 addItemBool("ToolBarUp",&mToolBarUp, false ); 109 addItemBool("ToolBarUp",&mToolBarUp, false );
110 addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false ); 110 addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false );
111 addItemInt("Whats Next Days",&mWhatsNextDays,3); 111 addItemInt("Whats Next Days",&mWhatsNextDays,3);
112 addItemInt("Whats Next Prios",&mWhatsNextPrios,1); 112 addItemInt("Whats Next Prios",&mWhatsNextPrios,1);
113 113
114 addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true); 114 addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true);
115 addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true); 115 addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true);
116 addItemInt("AllDay Size",&mAllDaySize,28); 116 addItemInt("AllDay Size",&mAllDaySize,28);
117 QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav"; 117 QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav";
118 addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm ); 118 addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm );
119 119
120 addItemStringList("LocationDefaults",&mLocationDefaults ); 120 addItemStringList("LocationDefaults",&mLocationDefaults );
121 addItemStringList("EventSummary User",&mEventSummaryUser); 121 addItemStringList("EventSummary User",&mEventSummaryUser);
122 addItemStringList("TodoSummary User",&mTodoSummaryUser); 122 addItemStringList("TodoSummary User",&mTodoSummaryUser);
123 123
124 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); 124 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false);
125 addItemBool("Enable Project View",&mEnableProjectView,false); 125 addItemBool("Enable Project View",&mEnableProjectView,false);
126 addItemBool("Auto Save",&mAutoSave,false); 126 addItemBool("Auto Save",&mAutoSave,false);
127 addItemInt("Auto Save Interval",&mAutoSaveInterval,3); 127 addItemInt("Auto Save Interval",&mAutoSaveInterval,3);
128 addItemBool("Confirm Deletes",&mConfirm,true); 128 addItemBool("Confirm Deletes",&mConfirm,true);
129 addItemString("Archive File",&mArchiveFile); 129 addItemString("Archive File",&mArchiveFile);
130 addItemString("Html Export File",&mHtmlExportFile, 130 addItemString("Html Export File",&mHtmlExportFile,
131 QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html")); 131 QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html"));
132 addItemBool("Html With Save",&mHtmlWithSave,false); 132 addItemBool("Html With Save",&mHtmlWithSave,false);
133 133
134 KPrefs::setCurrentGroup("Personal Settings"); 134 KPrefs::setCurrentGroup("Personal Settings");
135 135
136 addItemInt("Mail Client",&mMailClient,MailClientKMail); 136 addItemInt("Mail Client",&mMailClient,MailClientKMail);
137 addItemBool("Use Control Center Email",&mEmailControlCenter,false); 137 addItemBool("Use Control Center Email",&mEmailControlCenter,false);
138 addItemBool("Bcc",&mBcc,false); 138 addItemBool("Bcc",&mBcc,false);
139 139
140 KPrefs::setCurrentGroup("Time & Date"); 140 KPrefs::setCurrentGroup("Time & Date");
141 141
142 // addItemString("Time Zone",&mTimeZone,"+0100"); 142 // addItemString("Time Zone",&mTimeZone,"+0100");
143 addItemString("TimeZoneName",&mTimeZoneId,i18n ("+01:00 Europe/Oslo(CET)") ); 143 addItemString("TimeZoneName",&mTimeZoneId,i18n ("+01:00 Europe/Oslo(CET)") );
144 // addItemInt("TimeZoneOffset",&mTimeZoneOffset,60); 144 // addItemInt("TimeZoneOffset",&mTimeZoneOffset,60);
145 addItemBool("UseDaylightsaving",&mUseDaylightsaving,true); 145 addItemBool("UseDaylightsaving",&mUseDaylightsaving,true);
146 addItemInt("DaylightsavingStart",&mDaylightsavingStart,90); 146 addItemInt("DaylightsavingStart",&mDaylightsavingStart,90);
147 addItemInt("DaylightsavingEnd",&mDaylightsavingEnd,304); 147 addItemInt("DaylightsavingEnd",&mDaylightsavingEnd,304);
148 148
149 149
150 addItemInt("Default Start Time",&mStartTime,10); 150 addItemInt("Default Start Time",&mStartTime,10);
151 addItemInt("Default Duration",&mDefaultDuration,2); 151 addItemInt("Default Duration",&mDefaultDuration,2);
152 addItemInt("Default Alarm Time",&mAlarmTime,3); 152 addItemInt("Default Alarm Time",&mAlarmTime,3);
153 addItemInt("Daylight Savings",&mDaylightSavings,0); 153 addItemInt("Daylight Savings",&mDaylightSavings,0);
154 KPrefs::setCurrentGroup("AlarmSettings"); 154 KPrefs::setCurrentGroup("AlarmSettings");
155 addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20); 155 addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20);
156 addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7); 156 addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7);
157 addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5); 157 addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5);
158 addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3); 158 addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3);
159 159
160 160
161 KPrefs::setCurrentGroup("Calendar"); 161 KPrefs::setCurrentGroup("Calendar");
162 162
163 addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar); 163 addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar);
164 164
165 KPrefs::setCurrentGroup("Fonts"); 165 KPrefs::setCurrentGroup("Fonts");
166 // qDebug(" KPrefs::setCurrentGroup(Fonts); "); 166 // qDebug(" KPrefs::setCurrentGroup(Fonts); ");
167 addItemFont("TimeBar Font",&mTimeBarFont); 167 addItemFont("TimeBar Font",&mTimeBarFont);
168 addItemFont("MonthView Font",&mMonthViewFont); 168 addItemFont("MonthView Font",&mMonthViewFont);
169 addItemFont("AgendaView Font",&mAgendaViewFont); 169 addItemFont("AgendaView Font",&mAgendaViewFont);
170 addItemFont("MarcusBains Font",&mMarcusBainsFont); 170 addItemFont("MarcusBains Font",&mMarcusBainsFont);
171 addItemFont("TimeLabels Font",&mTimeLabelsFont); 171 addItemFont("TimeLabels Font",&mTimeLabelsFont);
172 addItemFont("TodoView Font",&mTodoViewFont); 172 addItemFont("TodoView Font",&mTodoViewFont);
173 addItemFont("ListView Font",&mListViewFont); 173 addItemFont("ListView Font",&mListViewFont);
174 addItemFont("DateNavigator Font",&mDateNavigatorFont); 174 addItemFont("DateNavigator Font",&mDateNavigatorFont);
175 addItemFont("EditBox Font",&mEditBoxFont); 175 addItemFont("EditBox Font",&mEditBoxFont);
176 addItemFont("JournalView Font",&mJornalViewFont); 176 addItemFont("JournalView Font",&mJornalViewFont);
177 addItemFont("WhatsNextView Font",&mWhatsNextFont); 177 addItemFont("WhatsNextView Font",&mWhatsNextFont);
178 addItemFont("EventView Font",&mEventViewFont); 178 addItemFont("EventView Font",&mEventViewFont);
179 179
180 KPrefs::setCurrentGroup("SyncProfiles"); 180// KPrefs::setCurrentGroup("SyncProfiles");
181 addItemString("LocalMachineName",&mLocalMachineName, "undefined"); 181// addItemString("LocalMachineName",&mLocalMachineName, "undefined");
182 addItemStringList("SyncProfileNames",&mSyncProfileNames); 182// addItemStringList("SyncProfileNames",&mSyncProfileNames);
183// addItemStringList("ExternSyncProfiles",&mExternSyncProfileNames);
183 184
184 KPrefs::setCurrentGroup("RemoteSyncing"); 185 KPrefs::setCurrentGroup("RemoteSyncing");
185 addItemBool("UsePasswd",&mUsePassWd,false); 186// addItemBool("UsePasswd",&mUsePassWd,false);
186 addItemBool("WriteBackFile",&mWriteBackFile,true); 187// addItemBool("WriteBackFile",&mWriteBackFile,true);
187 addItemBool("WriteBackExistingOnly",&mWriteBackExistingOnly,false); 188// addItemBool("WriteBackExistingOnly",&mWriteBackExistingOnly,false);
188 addItemBool("AskForPreferences",&mAskForPreferences,true); 189// addItemBool("AskForPreferences",&mAskForPreferences,true);
189 addItemBool("ShowSyncSummary",&mShowSyncSummary,true); 190// addItemBool("ShowSyncSummary",&mShowSyncSummary,true);
190 addItemBool("ShowSyncEvents",&mShowSyncEvents,false); 191 addItemBool("ShowSyncEvents",&mShowSyncEvents,false);
191 addItemInt("LastSyncTime",&mLastSyncTime,0); 192 addItemInt("LastSyncTime",&mLastSyncTime,0);
192 addItemInt("SyncAlgoPrefs",&mSyncAlgoPrefs,3); 193 addItemInt("SyncAlgoPrefs",&mSyncAlgoPrefs,3);
193 addItemInt("RingSyncAlgoPrefs",&mRingSyncAlgoPrefs,3); 194 addItemInt("RingSyncAlgoPrefs",&mRingSyncAlgoPrefs,3);
194 195
195#ifdef _WIN32_ 196#ifdef _WIN32_
196 QString hdp= locateLocal("data","korganizer")+"\\\\"; 197 QString hdp= locateLocal("data","korganizer")+"\\\\";
197#else 198#else
198 QString hdp= locateLocal("data","korganizer")+"/"; 199 QString hdp= locateLocal("data","korganizer")+"/";
199#endif 200#endif
200 addItemString("RemoteIP",&mRemoteIP, "192.168.0.65"); 201// addItemString("RemoteIP",&mRemoteIP, "192.168.0.65");
201 addItemString("RemoteUser",&mRemoteUser, "zaurus"); 202// addItemString("RemoteUser",&mRemoteUser, "zaurus");
202 addItemString("RemotePassWd",&mRemotePassWd, ""); 203// addItemString("RemotePassWd",&mRemotePassWd, "");
203 addItemString("RemoteFile", &mRemoteFile, hdp+"mycalendar.ics"); 204// addItemString("RemoteFile", &mRemoteFile, hdp+"mycalendar.ics");
204 addItemString("LocalTempFile",&mLocalTempFile, "/tmp/tempsyncfile.ics" ); 205// addItemString("LocalTempFile",&mLocalTempFile, "/tmp/tempsyncfile.ics" );
205 206
206 207
207 KPrefs::setCurrentGroup("LoadSaveFileNames"); 208 KPrefs::setCurrentGroup("LoadSaveFileNames");
208 209
209 addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" ); 210 addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" );
210 addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" ); 211 addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" );
211 addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" ); 212 addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" );
212 addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); 213 addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" );
213 addItemString("LastSyncedLocalFile", &mLastSyncedLocalFile ,hdp +"lastsync.ics" ); 214 addItemString("LastSyncedLocalFile", &mLastSyncedLocalFile ,hdp +"lastsync.ics" );
214 215
215 216
216 KPrefs::setCurrentGroup("Locale"); 217 KPrefs::setCurrentGroup("Locale");
217 addItemInt("PreferredLanguage",&mPreferredLanguage,0); 218 addItemInt("PreferredLanguage",&mPreferredLanguage,0);
218 addItemInt("PreferredTime",&mPreferredTime,0); 219 addItemInt("PreferredTime",&mPreferredTime,0);
219 addItemInt("PreferredDate",&mPreferredDate,0); 220 addItemInt("PreferredDate",&mPreferredDate,0);
220 addItemBool("WeekStartsOnSunday",&mWeekStartsOnSunday,false); 221 addItemBool("WeekStartsOnSunday",&mWeekStartsOnSunday,false);
221 addItemBool("QuickSavingWOUnicode",&mUseQuicksave,false); 222 addItemBool("QuickSavingWOUnicode",&mUseQuicksave,false);
222 addItemBool("ShortDateInViewer",&mShortDateInViewer,false); 223 addItemBool("ShortDateInViewer",&mShortDateInViewer,false);
223 addItemString("UserDateFormatLong", &mUserDateFormatLong, "%A %d %b %y"); 224 addItemString("UserDateFormatLong", &mUserDateFormatLong, "%A %d %b %y");
224 addItemString("UserDateFormatShort", &mUserDateFormatShort, "%aK %d.%m.%y"); 225 addItemString("UserDateFormatShort", &mUserDateFormatShort, "%aK %d.%m.%y");
225 226
226 227
227 KPrefs::setCurrentGroup("Colors"); 228 KPrefs::setCurrentGroup("Colors");
228 addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor); 229 addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor);
229 addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor); 230 addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor);
230 addItemColor("Event Color",&mEventColor,mDefaultCategoryColor); 231 addItemColor("Event Color",&mEventColor,mDefaultCategoryColor);
231 addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor); 232 addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor);
232 addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor); 233 addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor);
233 addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor); 234 addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor);
234 addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor); 235 addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor);
235 addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 )); 236 addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 ));
236 addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 )); 237 addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 ));
237 addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 )); 238 addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 ));
238 addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true); 239 addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true);
239 addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true); 240 addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true);
240 addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false); 241 addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false);
241 addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 )); 242 addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 ));
242 addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 )); 243 addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 ));
243 addItemBool("UseAppColors",&mUseAppColors,false); 244 addItemBool("UseAppColors",&mUseAppColors,false);
244 245
245 246
246 247
247 KPrefs::setCurrentGroup("Views"); 248 KPrefs::setCurrentGroup("Views");
248 addItemInt("Hour Size",&mHourSize,8); 249 addItemInt("Hour Size",&mHourSize,8);
249 addItemBool("Show Daily Recurrences",&mDailyRecur,true); 250 addItemBool("Show Daily Recurrences",&mDailyRecur,true);
250 addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true); 251 addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true);
251 addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true); 252 addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true);
252 addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true); 253 addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true);
253 addItemBool("ShowShortMonthName",&mMonthShowShort,false); 254 addItemBool("ShowShortMonthName",&mMonthShowShort,false);
254 addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true); 255 addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true);
255 addItemBool("Enable ToolTips",&mEnableToolTips,false); 256 addItemBool("Enable ToolTips",&mEnableToolTips,false);
256 addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false); 257 addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false);
257 addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false); 258 addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false);
258 addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true); 259 addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true);
259 addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true); 260 addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true);
260 addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,false); 261 addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,false);
261 addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false); 262 addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false);
262 addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false); 263 addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false);
263 addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true); 264 addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true);
264 addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true); 265 addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true);
265 addItemBool("WNViewShowsParents",&mWNViewShowsParents,true); 266 addItemBool("WNViewShowsParents",&mWNViewShowsParents,true);
266 addItemBool("WNViewShowLocation",&mWNViewShowLocation,false); 267 addItemBool("WNViewShowLocation",&mWNViewShowLocation,false);
267 addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false); 268 addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false);
268 addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true); 269 addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true);
269 addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false); 270 addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false);
270 addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false); 271 addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false);
271 addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,false); 272 addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,false);
272 addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false); 273 addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false);
273 addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false); 274 addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false);
274#ifdef DESKTOP_VERSION 275#ifdef DESKTOP_VERSION
275 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true); 276 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true);
276#else 277#else
277 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false); 278 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false);
278#endif 279#endif
279 addItemInt("Day Begins",&mDayBegins,7); 280 addItemInt("Day Begins",&mDayBegins,7);
280 addItemInt("Working Hours Start",&mWorkingHoursStart,8); 281 addItemInt("Working Hours Start",&mWorkingHoursStart,8);
281 addItemInt("Working Hours End",&mWorkingHoursEnd,17); 282 addItemInt("Working Hours End",&mWorkingHoursEnd,17);
282 addItemBool("Exclude Holidays",&mExcludeHolidays,true); 283 addItemBool("Exclude Holidays",&mExcludeHolidays,true);
283 addItemBool("Exclude Saturdays",&mExcludeSaturdays,true); 284 addItemBool("Exclude Saturdays",&mExcludeSaturdays,true);
284 285
285 addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false); 286 addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false);
286 addItemBool("Full View Month",&mFullViewMonth,true); 287 addItemBool("Full View Month",&mFullViewMonth,true);
287 addItemBool("Full View Todo",&mFullViewTodo,true); 288 addItemBool("Full View Todo",&mFullViewTodo,true);
288 addItemBool("Quick Todo",&mEnableQuickTodo,false); 289 addItemBool("Quick Todo",&mEnableQuickTodo,false);
289 290
290 addItemInt("Next X Days",&mNextXDays,3); 291 addItemInt("Next X Days",&mNextXDays,3);
291 292
292 KPrefs::setCurrentGroup("Printer"); 293 KPrefs::setCurrentGroup("Printer");
293 294
294 KPrefs::setCurrentGroup("Layout"); 295 KPrefs::setCurrentGroup("Layout");
295 296
296 addItemBool("CompactDialogs",&mCompactDialogs,false); 297 addItemBool("CompactDialogs",&mCompactDialogs,false);
297 addItemBool("VerticalScreen",&mVerticalScreen,true); 298 addItemBool("VerticalScreen",&mVerticalScreen,true);
298 299
299 KPrefs::setCurrentGroup("KOrganizer Plugins"); 300 KPrefs::setCurrentGroup("KOrganizer Plugins");
300 301
301 addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays"); 302 addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays");
302 303
303 KPrefs::setCurrentGroup("Group Scheduling"); 304 KPrefs::setCurrentGroup("Group Scheduling");
304 305
305 addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail); 306 addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail);
306 addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend); 307 addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend);
307 addItemStringList("AdditionalMails",&mAdditionalMails,""); 308 addItemStringList("AdditionalMails",&mAdditionalMails,"");
308 addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto); 309 addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto);
309 addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto); 310 addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto);
310 addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto); 311 addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto);
311 addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto); 312 addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto);
312 addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto); 313 addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto);
313 314
314 KPrefs::setCurrentGroup( "Editors" ); 315 KPrefs::setCurrentGroup( "Editors" );
315 316
316 addItemStringList( "EventTemplates", &mEventTemplates ); 317 addItemStringList( "EventTemplates", &mEventTemplates );
317 addItemStringList( "TodoTemplates", &mTodoTemplates ); 318 addItemStringList( "TodoTemplates", &mTodoTemplates );
318 319
319 addItemInt("DestinationPolicy",&mDestination,standardDestination); 320 addItemInt("DestinationPolicy",&mDestination,standardDestination);
320 321
321 322
322 323
323} 324}
324 325
325 326
326KOPrefs::~KOPrefs() 327KOPrefs::~KOPrefs()
327{ 328{
328 if (mInstance == this) 329 if (mInstance == this)
329 mInstance = insd.setObject(0); 330 mInstance = insd.setObject(0);
330 setLocaleDict( 0 ); 331 setLocaleDict( 0 );
331 if ( mLocaleDict ) 332 if ( mLocaleDict )
332 delete mLocaleDict; 333 delete mLocaleDict;
333 //qDebug("KOPrefs::~KOPrefs() "); 334 //qDebug("KOPrefs::~KOPrefs() ");
334} 335}
335 336
336 337
337KOPrefs *KOPrefs::instance() 338KOPrefs *KOPrefs::instance()
338{ 339{
339 if (!mInstance) { 340 if (!mInstance) {
340 mInstance = insd.setObject(new KOPrefs()); 341 mInstance = insd.setObject(new KOPrefs());
341 mInstance->readConfig(); 342 mInstance->readConfig();
342 } 343 }
343 344
344 return mInstance; 345 return mInstance;
345} 346}
346 347
347void KOPrefs::usrSetDefaults() 348void KOPrefs::usrSetDefaults()
348{ 349{
349 350
350} 351}
351 352
352void KOPrefs::fillMailDefaults() 353void KOPrefs::fillMailDefaults()
353{ 354{
354 if (mName.isEmpty()) mName = i18n("Anonymous"); 355 if (mName.isEmpty()) mName = i18n("Anonymous");
355 if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); 356 if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere");
356} 357}
357 358
358void KOPrefs::setTimeZoneIdDefault() 359void KOPrefs::setTimeZoneIdDefault()
359{ 360{
360 mTimeZoneId = i18n("+01:00 Europe/Oslo(CET)"); 361 mTimeZoneId = i18n("+01:00 Europe/Oslo(CET)");
361} 362}
362 363
363void KOPrefs::setCategoryDefaults() 364void KOPrefs::setCategoryDefaults()
364{ 365{
365 mCustomCategories.clear(); 366 mCustomCategories.clear();
366 mCustomCategories = getDefaultList(); 367 mCustomCategories = getDefaultList();
367 368
368 QStringList::Iterator it; 369 QStringList::Iterator it;
369 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { 370 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) {
370 setCategoryColor(*it,mDefaultCategoryColor); 371 setCategoryColor(*it,mDefaultCategoryColor);
371 } 372 }
372} 373}
373 374
374QStringList KOPrefs::getDefaultList() 375QStringList KOPrefs::getDefaultList()
375{ 376{
376 QStringList retval ; 377 QStringList retval ;
377 retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Business Travel") << i18n("Cinema") << i18n("Customer") 378 retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Business Travel") << i18n("Cinema") << i18n("Customer")
378 << i18n("Break")<< i18n("Breakfast")<< i18n("Competition")<< i18n("Dinner") 379 << i18n("Break")<< i18n("Breakfast")<< i18n("Competition")<< i18n("Dinner")
379 << i18n("Education")<< i18n("Family") << i18n("Favorites") << i18n("Festival")<< i18n("Fishing")<< i18n("Flight") << i18n("Gifts") 380 << i18n("Education")<< i18n("Family") << i18n("Favorites") << i18n("Festival")<< i18n("Fishing")<< i18n("Flight") << i18n("Gifts")
380 << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") << i18n("Hiking") << i18n("Hunting") << i18n("Key Customer") << i18n("Kids") 381 << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") << i18n("Hiking") << i18n("Hunting") << i18n("Key Customer") << i18n("Kids")
381 << i18n("Lunch") << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner")<< i18n("Party") << i18n("Personal") << i18n("Personal Travel") 382 << i18n("Lunch") << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner")<< i18n("Party") << i18n("Personal") << i18n("Personal Travel")
382 << i18n("PHB") << i18n("Phone Calls") << i18n("Projects") << i18n("Recurring") << i18n("School") << i18n("Shopping") 383 << i18n("PHB") << i18n("Phone Calls") << i18n("Projects") << i18n("Recurring") << i18n("School") << i18n("Shopping")
383 << i18n("Speach") << i18n("Special Occasion") << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV")<< i18n("University") 384 << i18n("Speach") << i18n("Special Occasion") << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV")<< i18n("University")
384 << i18n("Vacation") << i18n("VIP") << i18n("SyncEvent") ; 385 << i18n("Vacation") << i18n("VIP") << i18n("SyncEvent") ;
385 retval.sort(); 386 retval.sort();
386 return retval; 387 return retval;
387} 388}
388 389
389void KOPrefs::usrReadConfig() 390void KOPrefs::usrReadConfig()
390{ 391{
391 mLocaleDict = 0; 392 mLocaleDict = 0;
392 // pending LR fix translation 393 // pending LR fix translation
393 // qDebug("KOPrefs::usrReadConfig() fix translation "); 394 // qDebug("KOPrefs::usrReadConfig() fix translation ");
394 if ( mPreferredLanguage == 1 ) { 395 if ( mPreferredLanguage == 1 ) {
395 mLocaleDict = new QDict<QString>; 396 mLocaleDict = new QDict<QString>;
396 int i = 0; 397 int i = 0;
397 QString fw ( germanwords[i] [0]); 398 QString fw ( germanwords[i] [0]);
398 while ( !fw.isEmpty() ) { 399 while ( !fw.isEmpty() ) {
399 mLocaleDict->insert( fw, new QString (germanwords[i] [1] )); 400 mLocaleDict->insert( fw, new QString (germanwords[i] [1] ));
400 ++i; 401 ++i;
401 fw = germanwords[i] [0]; 402 fw = germanwords[i] [0];
402 } 403 }
403 404
404 setLocaleDict( mLocaleDict ); 405 setLocaleDict( mLocaleDict );
405 } 406 }
406 if ( mPreferredLanguage == 3 ) { 407 if ( mPreferredLanguage == 3 ) {
407 QString fileName = MainWindow::resourcePath()+"usertranslation.txt"; 408 QString fileName = MainWindow::resourcePath()+"usertranslation.txt";
408 QFile file( fileName ); 409 QFile file( fileName );
409 if (file.open( IO_ReadOnly ) ) { 410 if (file.open( IO_ReadOnly ) ) {
410 QTextStream ts( &file ); 411 QTextStream ts( &file );
411 ts.setCodec( QTextCodec::codecForLocale() ); 412 ts.setCodec( QTextCodec::codecForLocale() );
412 QString text = ts.read(); 413 QString text = ts.read();
413 file.close(); 414 file.close();
414 415
415 QString line; 416 QString line;
416 QString we; 417 QString we;
417 QString wt; 418 QString wt;
418 int br = 0; 419 int br = 0;
419 int nbr; 420 int nbr;
420 nbr = text.find ( "},", br ); 421 nbr = text.find ( "},", br );
421 line = text.mid( br, nbr - br ); 422 line = text.mid( br, nbr - br );
422 br = nbr+1; 423 br = nbr+1;
423 int se, ee, st, et; 424 int se, ee, st, et;
424 mLocaleDict = new QDict<QString>; 425 mLocaleDict = new QDict<QString>;
425 QString end = "{ \"\",\"\" }"; 426 QString end = "{ \"\",\"\" }";
426 while ( (line != end) && (br > 1) ) { 427 while ( (line != end) && (br > 1) ) {
427 //qDebug("%d *%s* ", br, line.latin1()); 428 //qDebug("%d *%s* ", br, line.latin1());
428 se = line.find("\"")+1; 429 se = line.find("\"")+1;
429 et = line.findRev("\"",-1); 430 et = line.findRev("\"",-1);
430 ee = line.find("\",\""); 431 ee = line.find("\",\"");
431 st = ee+3; 432 st = ee+3;
432 we = line.mid( se, ee-se ); 433 we = line.mid( se, ee-se );
433 wt = line.mid( st, et-st ); 434 wt = line.mid( st, et-st );
434 //qDebug("*%s* *%s* ", we.latin1(), wt.latin1()); 435 //qDebug("*%s* *%s* ", we.latin1(), wt.latin1());
435 mLocaleDict->insert( we, new QString (wt) ); 436 mLocaleDict->insert( we, new QString (wt) );
436 nbr = text.find ( "}", br ); 437 nbr = text.find ( "}", br );
437 line = text.mid( br, nbr - br ); 438 line = text.mid( br, nbr - br );
438 br = nbr+1; 439 br = nbr+1;
439 } 440 }
440 //qDebug("end *%s* ", end.latin1()); 441 //qDebug("end *%s* ", end.latin1());
441 442
442 setLocaleDict( mLocaleDict ); 443 setLocaleDict( mLocaleDict );
443 } else { 444 } else {
444 qDebug("KO: Cannot find translation file usertranslation.txt"); 445 qDebug("KO: Cannot find translation file usertranslation.txt");
445 } 446 }
446 } 447 }
447 config()->setGroup("General"); 448 config()->setGroup("General");
448 449
449 mCustomCategories = config()->readListEntry("Custom Categories"); 450 mCustomCategories = config()->readListEntry("Custom Categories");
450 if ( KOPrefs::instance()->mLanguageChanged ) { 451 if ( KOPrefs::instance()->mLanguageChanged ) {
451 mLocationDefaults.clear(); 452 mLocationDefaults.clear();
452 mEventSummaryUser.clear(); 453 mEventSummaryUser.clear();
453 mTodoSummaryUser.clear(); 454 mTodoSummaryUser.clear();
454 } 455 }
455 if (mLocationDefaults.isEmpty()) { 456 if (mLocationDefaults.isEmpty()) {
456 mLocationDefaults << i18n("Home") << i18n("Office") << i18n("Libary") << i18n("School") << i18n("Doctor") << i18n("Beach") 457 mLocationDefaults << i18n("Home") << i18n("Office") << i18n("Libary") << i18n("School") << i18n("Doctor") << i18n("Beach")
457 << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") << i18n("Cinema") << i18n("Lake") << i18n("Kindergarden") 458 << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") << i18n("Cinema") << i18n("Lake") << i18n("Kindergarden")
458 << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ; 459 << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ;
459 // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") 460 // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("")
460 mLocationDefaults.sort(); 461 mLocationDefaults.sort();
461 } 462 }
462 463
463 if (mEventSummaryUser.isEmpty()) { 464 if (mEventSummaryUser.isEmpty()) {
464 mEventSummaryUser = getDefaultList() ; 465 mEventSummaryUser = getDefaultList() ;
465 } 466 }
466 if (mTodoSummaryUser.isEmpty()) { 467 if (mTodoSummaryUser.isEmpty()) {
467 mTodoSummaryUser = getDefaultList() ; 468 mTodoSummaryUser = getDefaultList() ;
468 } 469 }
469 470
470 if (mCustomCategories.isEmpty()) setCategoryDefaults(); 471 if (mCustomCategories.isEmpty()) setCategoryDefaults();
471 472
472 config()->setGroup("Personal Settings"); 473 config()->setGroup("Personal Settings");
473 mName = config()->readEntry("user_name",""); 474 mName = config()->readEntry("user_name","");
474 mEmail = config()->readEntry("user_email",""); 475 mEmail = config()->readEntry("user_email","");
475 fillMailDefaults(); 476 fillMailDefaults();
476 477
477 config()->setGroup("Category Colors"); 478 config()->setGroup("Category Colors");
478 QStringList::Iterator it; 479 QStringList::Iterator it;
479 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { 480 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) {
480 setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor)); 481 setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor));
481 482
482 } 483 }
483 484
484 if (mTimeZoneId.isEmpty()) { 485 if (mTimeZoneId.isEmpty()) {
485 setTimeZoneIdDefault(); 486 setTimeZoneIdDefault();
486 } 487 }
487 KPimPrefs::usrReadConfig(); 488 KPimPrefs::usrReadConfig();
488} 489}
489 490
490 491
491void KOPrefs::usrWriteConfig() 492void KOPrefs::usrWriteConfig()
492{ 493{
493 config()->setGroup("General"); 494 config()->setGroup("General");
494 config()->writeEntry("Custom Categories",mCustomCategories); 495 config()->writeEntry("Custom Categories",mCustomCategories);
495 496
496 config()->setGroup("Personal Settings"); 497 config()->setGroup("Personal Settings");
497 config()->writeEntry("user_name",mName); 498 config()->writeEntry("user_name",mName);
498 config()->writeEntry("user_email",mEmail); 499 config()->writeEntry("user_email",mEmail);
499 500
500 config()->setGroup("Category Colors"); 501 config()->setGroup("Category Colors");
501 QDictIterator<QColor> it(mCategoryColors); 502 QDictIterator<QColor> it(mCategoryColors);
502 while (it.current()) { 503 while (it.current()) {
503 config()->writeEntry(it.currentKey(),*(it.current())); 504 config()->writeEntry(it.currentKey(),*(it.current()));
504 ++it; 505 ++it;
505 } 506 }
506 507
507 508
508 KPimPrefs::usrWriteConfig(); 509 KPimPrefs::usrWriteConfig();
509} 510}
510 511
511void KOPrefs::setCategoryColor(QString cat,const QColor & color) 512void KOPrefs::setCategoryColor(QString cat,const QColor & color)
512{ 513{
513 mCategoryColors.replace(cat,new QColor(color)); 514 mCategoryColors.replace(cat,new QColor(color));
514} 515}
515 516
516QColor *KOPrefs::categoryColor(QString cat) 517QColor *KOPrefs::categoryColor(QString cat)
517{ 518{
518 QColor *color = 0; 519 QColor *color = 0;
519 520
520 if (!cat.isEmpty()) color = mCategoryColors[cat]; 521 if (!cat.isEmpty()) color = mCategoryColors[cat];
521 522
522 if (color) return color; 523 if (color) return color;
523 else return &mDefaultCategoryColor; 524 else return &mDefaultCategoryColor;
524} 525}
525 526
526void KOPrefs::setFullName(const QString &name) 527void KOPrefs::setFullName(const QString &name)
527{ 528{
528 mName = name; 529 mName = name;
529} 530}
530 531
531void KOPrefs::setEmail(const QString &email) 532void KOPrefs::setEmail(const QString &email)
532{ 533{
533 //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() ); 534 //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() );
534 mEmail = email; 535 mEmail = email;
535} 536}
536 537
537QString KOPrefs::fullName() 538QString KOPrefs::fullName()
538{ 539{
539 if (mEmailControlCenter) { 540 if (mEmailControlCenter) {
540 KEMailSettings settings; 541 KEMailSettings settings;
541 return settings.getSetting(KEMailSettings::RealName); 542 return settings.getSetting(KEMailSettings::RealName);
542 } else { 543 } else {
543 return mName; 544 return mName;
544 } 545 }
545} 546}
546 547
547QString KOPrefs::email() 548QString KOPrefs::email()
548{ 549{
549 if (mEmailControlCenter) { 550 if (mEmailControlCenter) {
550 KEMailSettings settings; 551 KEMailSettings settings;
551 return settings.getSetting(KEMailSettings::EmailAddress); 552 return settings.getSetting(KEMailSettings::EmailAddress);
552 } else { 553 } else {
553 return mEmail; 554 return mEmail;
554 } 555 }
555} 556}
556KConfig* KOPrefs::getConfig() 557KConfig* KOPrefs::getConfig()
557{ 558{
558 return config(); 559 return config();
559} 560}
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h
index fe044e6..424fa98 100644
--- a/korganizer/koprefs.h
+++ b/korganizer/koprefs.h
@@ -1,299 +1,300 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23#ifndef KOPREFS_H 23#ifndef KOPREFS_H
24#define KOPREFS_H 24#define KOPREFS_H
25 25
26#include <qdict.h> 26#include <qdict.h>
27 27
28#include <libkdepim/kpimprefs.h> 28#include <libkdepim/kpimprefs.h>
29 29
30class KConfig; 30class KConfig;
31class QFont; 31class QFont;
32class QColor; 32class QColor;
33class QStringList; 33class QStringList;
34 34
35class KOPrefs : public KPimPrefs 35class KOPrefs : public KPimPrefs
36{ 36{
37 public: 37 public:
38 enum { FormatVCalendar, FormatICalendar }; 38 enum { FormatVCalendar, FormatICalendar };
39 enum { MailClientKMail, MailClientSendmail }; 39 enum { MailClientKMail, MailClientSendmail };
40 enum { IMIPDummy, IMIPKMail }; 40 enum { IMIPDummy, IMIPKMail };
41 enum { IMIPOutbox, IMIPdirectsend }; 41 enum { IMIPOutbox, IMIPdirectsend };
42 enum { neverAuto, addressbookAuto, selectedAuto }; 42 enum { neverAuto, addressbookAuto, selectedAuto };
43 enum { standardDestination, askDestination }; 43 enum { standardDestination, askDestination };
44 44
45 virtual ~KOPrefs(); 45 virtual ~KOPrefs();
46 46
47 /** Get instance of KOPrefs. It is made sure that there is only one 47 /** Get instance of KOPrefs. It is made sure that there is only one
48 instance. */ 48 instance. */
49 static KOPrefs *instance(); 49 static KOPrefs *instance();
50 50
51 /** Set preferences to default values */ 51 /** Set preferences to default values */
52 void usrSetDefaults(); 52 void usrSetDefaults();
53 53
54 /** Read preferences from config file */ 54 /** Read preferences from config file */
55 void usrReadConfig(); 55 void usrReadConfig();
56 56
57 /** Write preferences to config file */ 57 /** Write preferences to config file */
58 void usrWriteConfig(); 58 void usrWriteConfig();
59 void setCategoryDefaults(); 59 void setCategoryDefaults();
60 60
61 protected: 61 protected:
62 void setTimeZoneIdDefault(); 62 void setTimeZoneIdDefault();
63 63
64 /** Fill empty mail fields with default values. */ 64 /** Fill empty mail fields with default values. */
65 void fillMailDefaults(); 65 void fillMailDefaults();
66 66
67 private: 67 private:
68 /** Constructor disabled for public. Use instance() to create a KOPrefs 68 /** Constructor disabled for public. Use instance() to create a KOPrefs
69 object. */ 69 object. */
70 KOPrefs(); 70 KOPrefs();
71 71
72 static KOPrefs *mInstance; 72 static KOPrefs *mInstance;
73 QDict<QString> *mLocaleDict; 73 QDict<QString> *mLocaleDict;
74 QStringList getDefaultList(); 74 QStringList getDefaultList();
75 public: 75 public:
76 // preferences data 76 // preferences data
77 KConfig* getConfig(); 77 KConfig* getConfig();
78 void setFullName(const QString &); 78 void setFullName(const QString &);
79 QString fullName(); 79 QString fullName();
80 void setEmail(const QString &); 80 void setEmail(const QString &);
81 QString email(); 81 QString email();
82 82
83 QString mAdditional; 83 QString mAdditional;
84 84
85 bool mEmailControlCenter; 85 bool mEmailControlCenter;
86 86
87 bool mBcc; 87 bool mBcc;
88 bool mAutoSave; 88 bool mAutoSave;
89 int mAutoSaveInterval; 89 int mAutoSaveInterval;
90 bool mConfirm; 90 bool mConfirm;
91 91
92 bool mEnableGroupScheduling; 92 bool mEnableGroupScheduling;
93 bool mEnableProjectView; 93 bool mEnableProjectView;
94 94
95 int mDefaultFormat; 95 int mDefaultFormat;
96 int mMailClient; 96 int mMailClient;
97 97
98 QString mTimeZone; 98 QString mTimeZone;
99 QString mTimeZoneId; 99 QString mTimeZoneId;
100 //QString mTimeZoneName; // e.g. +00:04:00 Indian/Mauritius 100 //QString mTimeZoneName; // e.g. +00:04:00 Indian/Mauritius
101 //int mTimeZoneOffset; // e.g. -240 min 101 //int mTimeZoneOffset; // e.g. -240 min
102 bool mUseDaylightsaving; 102 bool mUseDaylightsaving;
103 int mDaylightsavingStart; 103 int mDaylightsavingStart;
104 int mDaylightsavingEnd; 104 int mDaylightsavingEnd;
105 int mStartTime; 105 int mStartTime;
106 int mDefaultDuration; 106 int mDefaultDuration;
107 int mAlarmTime; 107 int mAlarmTime;
108 int mDaylightSavings; 108 int mDaylightSavings;
109 109
110 int mWorkingHoursStart; 110 int mWorkingHoursStart;
111 int mWorkingHoursEnd; 111 int mWorkingHoursEnd;
112 bool mExcludeHolidays; 112 bool mExcludeHolidays;
113 bool mExcludeSaturdays; 113 bool mExcludeSaturdays;
114 bool mMarcusBainsShowSeconds; 114 bool mMarcusBainsShowSeconds;
115 115
116 QFont mTimeBarFont; 116 QFont mTimeBarFont;
117 QFont mMonthViewFont; 117 QFont mMonthViewFont;
118 QFont mAgendaViewFont; 118 QFont mAgendaViewFont;
119 QFont mMarcusBainsFont; 119 QFont mMarcusBainsFont;
120 QFont mTimeLabelsFont; 120 QFont mTimeLabelsFont;
121 QFont mTodoViewFont; 121 QFont mTodoViewFont;
122 QFont mListViewFont; 122 QFont mListViewFont;
123 QFont mDateNavigatorFont; 123 QFont mDateNavigatorFont;
124 QFont mEditBoxFont; 124 QFont mEditBoxFont;
125 QFont mJornalViewFont; 125 QFont mJornalViewFont;
126 QFont mWhatsNextFont; 126 QFont mWhatsNextFont;
127 QFont mEventViewFont; 127 QFont mEventViewFont;
128 128
129 129
130 130
131 131
132 QColor mHolidayColor; 132 QColor mHolidayColor;
133 QColor mHighlightColor; 133 QColor mHighlightColor;
134 QColor mEventColor; 134 QColor mEventColor;
135 QColor mAgendaBgColor; 135 QColor mAgendaBgColor;
136 QColor mWorkingHoursColor; 136 QColor mWorkingHoursColor;
137 QColor mTodoDueTodayColor; 137 QColor mTodoDueTodayColor;
138 QColor mTodoOverdueColor; 138 QColor mTodoOverdueColor;
139 QColor mMonthViewEvenColor; 139 QColor mMonthViewEvenColor;
140 QColor mMonthViewOddColor; 140 QColor mMonthViewOddColor;
141 QColor mMonthViewHolidayColor; 141 QColor mMonthViewHolidayColor;
142 bool mMonthViewUsesDayColors; 142 bool mMonthViewUsesDayColors;
143 bool mMonthViewSatSunTog; 143 bool mMonthViewSatSunTog;
144 QColor mAppColor1; 144 QColor mAppColor1;
145 QColor mAppColor2; 145 QColor mAppColor2;
146 bool mUseAppColors; 146 bool mUseAppColors;
147 147
148 int mDayBegins; 148 int mDayBegins;
149 int mHourSize; 149 int mHourSize;
150 int mAllDaySize; 150 int mAllDaySize;
151 bool mShowFullMenu; 151 bool mShowFullMenu;
152 bool mDailyRecur; 152 bool mDailyRecur;
153 bool mWeeklyRecur; 153 bool mWeeklyRecur;
154 bool mMonthDailyRecur; 154 bool mMonthDailyRecur;
155 bool mMonthWeeklyRecur; 155 bool mMonthWeeklyRecur;
156 bool mMonthShowIcons; 156 bool mMonthShowIcons;
157 bool mMonthShowShort; 157 bool mMonthShowShort;
158 bool mEnableToolTips; 158 bool mEnableToolTips;
159 bool mEnableMonthScroll; 159 bool mEnableMonthScroll;
160 bool mFullViewMonth; 160 bool mFullViewMonth;
161 bool mMonthViewUsesCategoryColor; 161 bool mMonthViewUsesCategoryColor;
162 bool mFullViewTodo; 162 bool mFullViewTodo;
163 bool mShowCompletedTodo; 163 bool mShowCompletedTodo;
164 bool mMarcusBainsEnabled; 164 bool mMarcusBainsEnabled;
165 int mNextXDays; 165 int mNextXDays;
166 int mWhatsNextDays; 166 int mWhatsNextDays;
167 int mWhatsNextPrios; 167 int mWhatsNextPrios;
168 bool mEnableQuickTodo; 168 bool mEnableQuickTodo;
169 bool mLanguageChanged; 169 bool mLanguageChanged;
170 170
171 bool mCompactDialogs; 171 bool mCompactDialogs;
172 bool mVerticalScreen; 172 bool mVerticalScreen;
173 173
174 bool mShowIconNewTodo; 174 bool mShowIconNewTodo;
175 bool mShowIconNewEvent; 175 bool mShowIconNewEvent;
176 bool mShowIconSearch; 176 bool mShowIconSearch;
177 bool mShowIconList; 177 bool mShowIconList;
178 bool mShowIconDay1; 178 bool mShowIconDay1;
179 bool mShowIconDay5; 179 bool mShowIconDay5;
180 bool mShowIconDay7; 180 bool mShowIconDay7;
181 bool mShowIconMonth; 181 bool mShowIconMonth;
182 bool mShowIconTodoview; 182 bool mShowIconTodoview;
183 bool mShowIconBackFast; 183 bool mShowIconBackFast;
184 bool mShowIconBack; 184 bool mShowIconBack;
185 bool mShowIconToday; 185 bool mShowIconToday;
186 bool mShowIconForward; 186 bool mShowIconForward;
187 bool mShowIconForwardFast; 187 bool mShowIconForwardFast;
188 bool mShowIconWhatsThis; 188 bool mShowIconWhatsThis;
189 bool mShowIconNextDays; 189 bool mShowIconNextDays;
190 bool mShowIconNext; 190 bool mShowIconNext;
191 bool mShowIconJournal; 191 bool mShowIconJournal;
192 192
193 bool mShowIconStretch; 193 bool mShowIconStretch;
194 194
195 bool mToolBarHor; 195 bool mToolBarHor;
196 bool mToolBarUp; 196 bool mToolBarUp;
197 bool mToolBarMiniIcons; 197 bool mToolBarMiniIcons;
198 198
199 bool mAskForQuit; 199 bool mAskForQuit;
200 bool mUsePassWd; 200 bool mUsePassWd;
201 bool mWriteBackFile; 201 bool mWriteBackFile;
202 bool mAskForPreferences; 202 bool mAskForPreferences;
203 bool mShowSyncSummary; 203 bool mShowSyncSummary;
204 bool mShowSyncEvents; 204 bool mShowSyncEvents;
205 bool mShowTodoInAgenda; 205 bool mShowTodoInAgenda;
206 bool mWriteBackExistingOnly; 206 bool mWriteBackExistingOnly;
207 207
208 QString mRemoteIP; 208 QString mRemoteIP;
209 QString mRemoteUser; 209 QString mRemoteUser;
210 QString mRemotePassWd; 210 QString mRemotePassWd;
211 QString mRemoteFile; 211 QString mRemoteFile;
212 QString mLocalTempFile; 212 QString mLocalTempFile;
213 213
214 int mLastSyncTime; 214 int mLastSyncTime;
215 int mSyncAlgoPrefs; 215 int mSyncAlgoPrefs;
216 int mRingSyncAlgoPrefs; 216 int mRingSyncAlgoPrefs;
217 QStringList mSyncProfileNames; 217 QStringList mSyncProfileNames;
218 QStringList mExternSyncProfiles;
218 QString mLocalMachineName; 219 QString mLocalMachineName;
219 void setCategoryColor(QString cat,const QColor & color); 220 void setCategoryColor(QString cat,const QColor & color);
220 QColor *categoryColor(QString cat); 221 QColor *categoryColor(QString cat);
221 222
222 QString mArchiveFile; 223 QString mArchiveFile;
223 QString mHtmlExportFile; 224 QString mHtmlExportFile;
224 bool mHtmlWithSave; 225 bool mHtmlWithSave;
225 226
226 QStringList mSelectedPlugins; 227 QStringList mSelectedPlugins;
227 228
228 QString mLastImportFile; 229 QString mLastImportFile;
229 QString mLastVcalFile; 230 QString mLastVcalFile;
230 QString mLastSaveFile; 231 QString mLastSaveFile;
231 QString mLastLoadFile; 232 QString mLastLoadFile;
232 QString mLastSyncedLocalFile; 233 QString mLastSyncedLocalFile;
233 234
234 235
235 QString mDefaultAlarmFile; 236 QString mDefaultAlarmFile;
236 int mIMIPScheduler; 237 int mIMIPScheduler;
237 int mIMIPSend; 238 int mIMIPSend;
238 QStringList mAdditionalMails; 239 QStringList mAdditionalMails;
239 int mIMIPAutoRefresh; 240 int mIMIPAutoRefresh;
240 int mIMIPAutoInsertReply; 241 int mIMIPAutoInsertReply;
241 int mIMIPAutoInsertRequest; 242 int mIMIPAutoInsertRequest;
242 int mIMIPAutoFreeBusy; 243 int mIMIPAutoFreeBusy;
243 int mIMIPAutoFreeBusyReply; 244 int mIMIPAutoFreeBusyReply;
244 245
245 QStringList mTodoTemplates; 246 QStringList mTodoTemplates;
246 QStringList mEventTemplates; 247 QStringList mEventTemplates;
247 248
248 int mDestination; 249 int mDestination;
249 250
250 251
251 bool mEditOnDoubleClick; 252 bool mEditOnDoubleClick;
252 bool mViewChangeHoldFullscreen; 253 bool mViewChangeHoldFullscreen;
253 bool mViewChangeHoldNonFullscreen; 254 bool mViewChangeHoldNonFullscreen;
254 bool mCenterOnCurrentTime; 255 bool mCenterOnCurrentTime;
255 bool mSetTimeToDayStartAt; 256 bool mSetTimeToDayStartAt;
256 bool mHighlightCurrentDay; 257 bool mHighlightCurrentDay;
257 bool mUseHighlightLightColor; 258 bool mUseHighlightLightColor;
258 bool mListViewMonthTimespan; 259 bool mListViewMonthTimespan;
259 bool mWNViewShowsParents; 260 bool mWNViewShowsParents;
260 bool mWNViewShowLocation; 261 bool mWNViewShowLocation;
261 bool mTodoViewShowsPercentage; 262 bool mTodoViewShowsPercentage;
262 bool mTodoViewUsesCatColors; 263 bool mTodoViewUsesCatColors;
263 bool mTodoViewUsesSmallFont; 264 bool mTodoViewUsesSmallFont;
264 bool mTodoViewUsesForegroundColor; 265 bool mTodoViewUsesForegroundColor;
265 bool mMonthViewUsesForegroundColor; 266 bool mMonthViewUsesForegroundColor;
266 267
267 bool mHightlightDateTimeEdit; 268 bool mHightlightDateTimeEdit;
268 int mPreferredLanguage; 269 int mPreferredLanguage;
269 bool mUseQuicksave; 270 bool mUseQuicksave;
270 int mPreferredTime; 271 int mPreferredTime;
271 int mPreferredDate; 272 int mPreferredDate;
272 bool mWeekStartsOnSunday; 273 bool mWeekStartsOnSunday;
273 bool mShortDateInViewer; 274 bool mShortDateInViewer;
274 QString mUserDateFormatLong; 275 QString mUserDateFormatLong;
275 QString mUserDateFormatShort; 276 QString mUserDateFormatShort;
276 277
277 QStringList mLocationDefaults; 278 QStringList mLocationDefaults;
278 QStringList mEventSummaryUser; 279 QStringList mEventSummaryUser;
279 QStringList mTodoSummaryUser; 280 QStringList mTodoSummaryUser;
280 281
281 bool mUseInternalAlarmNotification; 282 bool mUseInternalAlarmNotification;
282 int mAlarmPlayBeeps; 283 int mAlarmPlayBeeps;
283 int mAlarmSuspendTime; 284 int mAlarmSuspendTime;
284 int mAlarmSuspendCount; 285 int mAlarmSuspendCount;
285 int mAlarmBeepInterval; 286 int mAlarmBeepInterval;
286 287
287 private: 288 private:
288 QDict<QColor> mCategoryColors; 289 QDict<QColor> mCategoryColors;
289 QColor mDefaultCategoryColor; 290 QColor mDefaultCategoryColor;
290 291
291 QFont mDefaultTimeBarFont; 292 QFont mDefaultTimeBarFont;
292 QFont mDefaultViewFont; 293 QFont mDefaultViewFont;
293 QFont mDefaultMonthViewFont; 294 QFont mDefaultMonthViewFont;
294 295
295 QString mName; 296 QString mName;
296 QString mEmail; 297 QString mEmail;
297}; 298};
298 299
299#endif 300#endif
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 44b1264..6020a46 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1,1995 +1,1998 @@
1#include <stdlib.h> 1#include <stdlib.h>
2 2
3#include <qaction.h> 3#include <qaction.h>
4#include <qpopupmenu.h> 4#include <qpopupmenu.h>
5#include <qpainter.h> 5#include <qpainter.h>
6#include <qwhatsthis.h> 6#include <qwhatsthis.h>
7#include <qmessagebox.h> 7#include <qmessagebox.h>
8#include <qlineedit.h> 8#include <qlineedit.h>
9#include <qfile.h> 9#include <qfile.h>
10#include <qdir.h> 10#include <qdir.h>
11#include <qapp.h> 11#include <qapp.h>
12#include <qfileinfo.h> 12#include <qfileinfo.h>
13#include <qlabel.h> 13#include <qlabel.h>
14#include <qwmatrix.h> 14#include <qwmatrix.h>
15#include <qtextbrowser.h> 15#include <qtextbrowser.h>
16#include <qtextstream.h> 16#include <qtextstream.h>
17#ifndef DESKTOP_VERSION 17#ifndef DESKTOP_VERSION
18#include <qpe/global.h> 18#include <qpe/global.h>
19#include <qpe/qpemenubar.h> 19#include <qpe/qpemenubar.h>
20#include <qpe/qpetoolbar.h> 20#include <qpe/qpetoolbar.h>
21#include <qpe/resource.h> 21#include <qpe/resource.h>
22#include <qpe/qpeapplication.h> 22#include <qpe/qpeapplication.h>
23#include <qtopia/alarmserver.h> 23#include <qtopia/alarmserver.h>
24#include <qtopia/qcopenvelope_qws.h> 24#include <qtopia/qcopenvelope_qws.h>
25#else 25#else
26#include <qmenubar.h> 26#include <qmenubar.h>
27#include <qtoolbar.h> 27#include <qtoolbar.h>
28#include <qapplication.h> 28#include <qapplication.h>
29//#include <resource.h> 29//#include <resource.h>
30 30
31#endif 31#endif
32#include <libkcal/calendarlocal.h> 32#include <libkcal/calendarlocal.h>
33#include <libkcal/todo.h> 33#include <libkcal/todo.h>
34#include <libkdepim/ksyncprofile.h> 34#include <libkdepim/ksyncprofile.h>
35#include <libkdepim/kincidenceformatter.h> 35#include <libkdepim/kincidenceformatter.h>
36 36
37#include "calendarview.h" 37#include "calendarview.h"
38#include "koviewmanager.h" 38#include "koviewmanager.h"
39#include "datenavigator.h" 39#include "datenavigator.h"
40#include "koagendaview.h" 40#include "koagendaview.h"
41#include "koagenda.h" 41#include "koagenda.h"
42#include "kodialogmanager.h" 42#include "kodialogmanager.h"
43#include "kdialogbase.h" 43#include "kdialogbase.h"
44#include "kstandarddirs.h" 44#include "kstandarddirs.h"
45#include "koprefs.h" 45#include "koprefs.h"
46#include "kfiledialog.h" 46#include "kfiledialog.h"
47#include "koglobals.h" 47#include "koglobals.h"
48#include "kglobal.h" 48#include "kglobal.h"
49#include "klocale.h" 49#include "klocale.h"
50#include "kconfig.h" 50#include "kconfig.h"
51#include "simplealarmclient.h" 51#include "simplealarmclient.h"
52using namespace KCal; 52using namespace KCal;
53#ifndef _WIN32_ 53#ifndef _WIN32_
54#include <unistd.h> 54#include <unistd.h>
55#else 55#else
56#include "koimportoldialog.h" 56#include "koimportoldialog.h"
57#endif 57#endif
58#include "mainwindow.h" 58#include "mainwindow.h"
59 59
60int globalFlagBlockStartup; 60int globalFlagBlockStartup;
61MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : 61MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
62 QMainWindow( parent, name ) 62 QMainWindow( parent, name )
63{ 63{
64 64
65#ifdef DESKTOP_VERSION 65#ifdef DESKTOP_VERSION
66 setFont( QFont("Arial"), 14 ); 66 setFont( QFont("Arial"), 14 );
67#endif 67#endif
68 68
69 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; 69 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
70 QString confFile = locateLocal("config","korganizerrc"); 70 QString confFile = locateLocal("config","korganizerrc");
71 QFileInfo finf ( confFile ); 71 QFileInfo finf ( confFile );
72 bool showWarning = !finf.exists(); 72 bool showWarning = !finf.exists();
73 setIcon(SmallIcon( "ko24" ) ); 73 setIcon(SmallIcon( "ko24" ) );
74 mBlockAtStartup = true; 74 mBlockAtStartup = true;
75 mFlagKeyPressed = false; 75 mFlagKeyPressed = false;
76 setCaption("KOrganizer/Pi"); 76 setCaption("KOrganizer/Pi");
77 KOPrefs *p = KOPrefs::instance(); 77 KOPrefs *p = KOPrefs::instance();
78 // if ( QApplication::desktop()->height() > 480 ) { 78 // if ( QApplication::desktop()->height() > 480 ) {
79// if ( p->mHourSize == 4 ) 79// if ( p->mHourSize == 4 )
80// p->mHourSize = 6; 80// p->mHourSize = 6;
81// } 81// }
82 if ( p->mHourSize > 18 ) 82 if ( p->mHourSize > 18 )
83 p->mHourSize = 18; 83 p->mHourSize = 18;
84 QMainWindow::ToolBarDock tbd; 84 QMainWindow::ToolBarDock tbd;
85 if ( p->mToolBarHor ) { 85 if ( p->mToolBarHor ) {
86 if ( p->mToolBarUp ) 86 if ( p->mToolBarUp )
87 tbd = Bottom; 87 tbd = Bottom;
88 else 88 else
89 tbd = Top; 89 tbd = Top;
90 } 90 }
91 else { 91 else {
92 if ( p->mToolBarUp ) 92 if ( p->mToolBarUp )
93 tbd = Right; 93 tbd = Right;
94 else 94 else
95 tbd = Left; 95 tbd = Left;
96 } 96 }
97 if ( KOPrefs::instance()->mUseAppColors ) 97 if ( KOPrefs::instance()->mUseAppColors )
98 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 98 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
99 globalFlagBlockStartup = 1; 99 globalFlagBlockStartup = 1;
100 iconToolBar = new QPEToolBar( this ); 100 iconToolBar = new QPEToolBar( this );
101 addToolBar (iconToolBar , tbd ); 101 addToolBar (iconToolBar , tbd );
102 mBlockSaveFlag = false; 102 mBlockSaveFlag = false;
103 mCalendarModifiedFlag = false; 103 mCalendarModifiedFlag = false;
104 104
105 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); 105 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
106 splash->setAlignment ( AlignCenter ); 106 splash->setAlignment ( AlignCenter );
107 setCentralWidget( splash ); 107 setCentralWidget( splash );
108#ifndef DESKTOP_VERSION 108#ifndef DESKTOP_VERSION
109 showMaximized(); 109 showMaximized();
110#endif 110#endif
111 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); 111 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
112 setDefaultPreferences(); 112 setDefaultPreferences();
113 mCalendar = new CalendarLocal(); 113 mCalendar = new CalendarLocal();
114 mView = new CalendarView( mCalendar, this,"mCalendar " ); 114 mView = new CalendarView( mCalendar, this,"mCalendar " );
115 mView->hide(); 115 mView->hide();
116 //mView->resize(splash->size() ); 116 //mView->resize(splash->size() );
117 initActions(); 117 initActions();
118#ifndef DESKTOP_VERSION 118#ifndef DESKTOP_VERSION
119 iconToolBar->show(); 119 iconToolBar->show();
120 qApp->processEvents(); 120 qApp->processEvents();
121#endif 121#endif
122 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); 122 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
123 int vh = height() ; 123 int vh = height() ;
124 int vw = width(); 124 int vw = width();
125 //qDebug("Toolbar hei %d ",iconToolBar->height() ); 125 //qDebug("Toolbar hei %d ",iconToolBar->height() );
126 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 126 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
127 vh -= iconToolBar->height(); 127 vh -= iconToolBar->height();
128 } else { 128 } else {
129 vw -= iconToolBar->height(); 129 vw -= iconToolBar->height();
130 } 130 }
131 //mView->setMaximumSize( splash->size() ); 131 //mView->setMaximumSize( splash->size() );
132 //mView->resize( splash->size() ); 132 //mView->resize( splash->size() );
133 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 133 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
134 mView->readSettings(); 134 mView->readSettings();
135 bool oldOpened = false; 135 bool oldOpened = false;
136 bool newFile = false; 136 bool newFile = false;
137 if( !QFile::exists( defaultFileName() ) ) { 137 if( !QFile::exists( defaultFileName() ) ) {
138 QFileInfo finfo ( defaultFileName() ); 138 QFileInfo finfo ( defaultFileName() );
139 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); 139 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
140 qDebug("oldfile %s ", oldFile.latin1()); 140 qDebug("oldfile %s ", oldFile.latin1());
141 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"; 141 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";
142 finfo.setFile( oldFile ); 142 finfo.setFile( oldFile );
143 if (finfo.exists() ) { 143 if (finfo.exists() ) {
144 KMessageBox::information( this, message); 144 KMessageBox::information( this, message);
145 mView->openCalendar( oldFile ); 145 mView->openCalendar( oldFile );
146 qApp->processEvents(); 146 qApp->processEvents();
147 } else { 147 } else {
148 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); 148 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
149 finfo.setFile( oldFile ); 149 finfo.setFile( oldFile );
150 if (finfo.exists() ) { 150 if (finfo.exists() ) {
151 KMessageBox::information( this, message); 151 KMessageBox::information( this, message);
152 mView->openCalendar( oldFile ); 152 mView->openCalendar( oldFile );
153 qApp->processEvents(); 153 qApp->processEvents();
154 } 154 }
155 } 155 }
156 mView->saveCalendar( defaultFileName() ); 156 mView->saveCalendar( defaultFileName() );
157 newFile = true; 157 newFile = true;
158 } 158 }
159 159
160 QTime neededSaveTime = QDateTime::currentDateTime().time(); 160 QTime neededSaveTime = QDateTime::currentDateTime().time();
161 if ( ! oldOpened ) 161 if ( ! oldOpened )
162 mView->openCalendar( defaultFileName() ); 162 mView->openCalendar( defaultFileName() );
163 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 163 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
164 qDebug("KO: Calendar loading time: %d ms",msNeeded ); 164 qDebug("KO: Calendar loading time: %d ms",msNeeded );
165 165
166 if ( KOPrefs::instance()->mLanguageChanged ) { 166 if ( KOPrefs::instance()->mLanguageChanged ) {
167 KOPrefs::instance()->setCategoryDefaults(); 167 KOPrefs::instance()->setCategoryDefaults();
168 int count = mView->addCategories(); 168 int count = mView->addCategories();
169 KOPrefs::instance()->mLanguageChanged = false; 169 KOPrefs::instance()->mLanguageChanged = false;
170 } 170 }
171 processIncidenceSelection( 0 ); 171 processIncidenceSelection( 0 );
172 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), 172 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
173 SLOT( processIncidenceSelection( Incidence * ) ) ); 173 SLOT( processIncidenceSelection( Incidence * ) ) );
174 connect( mView, SIGNAL( modifiedChanged( bool ) ), 174 connect( mView, SIGNAL( modifiedChanged( bool ) ),
175 SLOT( slotModifiedChanged( bool ) ) ); 175 SLOT( slotModifiedChanged( bool ) ) );
176 176
177 177
178 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); 178 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
179 mView->setModified( false ); 179 mView->setModified( false );
180 mBlockAtStartup = false; 180 mBlockAtStartup = false;
181 mView->setModified( false ); 181 mView->setModified( false );
182 setCentralWidget( mView ); 182 setCentralWidget( mView );
183 globalFlagBlockStartup = 0; 183 globalFlagBlockStartup = 0;
184 mView->show(); 184 mView->show();
185 delete splash; 185 delete splash;
186 if ( newFile ) 186 if ( newFile )
187 mView->updateConfig(); 187 mView->updateConfig();
188 // qApp->processEvents(); 188 // qApp->processEvents();
189 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 189 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
190 fillSyncMenu(); 190 fillSyncMenu();
191 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); 191 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
192 if ( showWarning ) { 192 if ( showWarning ) {
193 KMessageBox::information( this, 193 KMessageBox::information( this,
194 "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"); 194 "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");
195 qApp->processEvents(); 195 qApp->processEvents();
196 mView->dialogManager()->showSyncOptions(); 196 mView->dialogManager()->showSyncOptions();
197 } 197 }
198} 198}
199MainWindow::~MainWindow() 199MainWindow::~MainWindow()
200{ 200{
201 //qDebug("MainWindow::~MainWindow() "); 201 //qDebug("MainWindow::~MainWindow() ");
202 //save toolbar location 202 //save toolbar location
203 203
204 delete mCalendar; 204 delete mCalendar;
205 delete KOPrefs::instance(); 205 delete KOPrefs::instance();
206 delete KIncidenceFormatter::instance(); 206 delete KIncidenceFormatter::instance();
207 207
208 208
209} 209}
210void MainWindow::closeEvent( QCloseEvent* ce ) 210void MainWindow::closeEvent( QCloseEvent* ce )
211{ 211{
212 212
213 213
214 214
215 if ( ! KOPrefs::instance()->mAskForQuit ) { 215 if ( ! KOPrefs::instance()->mAskForQuit ) {
216 saveOnClose(); 216 saveOnClose();
217 ce->accept(); 217 ce->accept();
218 return; 218 return;
219 219
220 } 220 }
221 221
222 switch( QMessageBox::information( this, "KO/Pi", 222 switch( QMessageBox::information( this, "KO/Pi",
223 i18n("Do you really want\nto close KO/Pi?"), 223 i18n("Do you really want\nto close KO/Pi?"),
224 i18n("Close"), i18n("No"), 224 i18n("Close"), i18n("No"),
225 0, 0 ) ) { 225 0, 0 ) ) {
226 case 0: 226 case 0:
227 saveOnClose(); 227 saveOnClose();
228 ce->accept(); 228 ce->accept();
229 break; 229 break;
230 case 1: 230 case 1:
231 ce->ignore(); 231 ce->ignore();
232 break; 232 break;
233 case 2: 233 case 2:
234 234
235 default: 235 default:
236 break; 236 break;
237 } 237 }
238 238
239 239
240} 240}
241 241
242void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) 242void MainWindow::recieve( const QCString& cmsg, const QByteArray& data )
243{ 243{
244 QDataStream stream( data, IO_ReadOnly ); 244 QDataStream stream( data, IO_ReadOnly );
245 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); 245 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" );
246 //QString datamess; 246 //QString datamess;
247 //qDebug("message "); 247 //qDebug("message ");
248 qDebug("KO: QCOP message received: %s ", cmsg.data() ); 248 qDebug("KO: QCOP message received: %s ", cmsg.data() );
249 if ( cmsg == "-writeFile" ) { 249 if ( cmsg == "-writeFile" ) {
250 // I made from the "-writeFile" an "-writeAlarm" 250 // I made from the "-writeFile" an "-writeAlarm"
251 mView->viewManager()->showWhatsNextView(); 251 mView->viewManager()->showWhatsNextView();
252 mCalendar->checkAlarmForIncidence( 0, true); 252 mCalendar->checkAlarmForIncidence( 0, true);
253 showMaximized(); 253 showMaximized();
254 raise(); 254 raise();
255 return; 255 return;
256 256
257 } 257 }
258 if ( cmsg == "-writeFileSilent" ) { 258 if ( cmsg == "-writeFileSilent" ) {
259 // I made from the "-writeFile" an "-writeAlarm" 259 // I made from the "-writeFile" an "-writeAlarm"
260 // mView->viewManager()->showWhatsNextView(); 260 // mView->viewManager()->showWhatsNextView();
261 mCalendar->checkAlarmForIncidence( 0, true); 261 mCalendar->checkAlarmForIncidence( 0, true);
262 //showMaximized(); 262 //showMaximized();
263 //raise(); 263 //raise();
264 hide(); 264 hide();
265 return; 265 return;
266 } 266 }
267 if ( cmsg == "-newCountdown" ) { 267 if ( cmsg == "-newCountdown" ) {
268 qDebug("newCountdown "); 268 qDebug("newCountdown ");
269 269
270 } 270 }
271 QString msg ; 271 QString msg ;
272 QString allmsg = cmsg; 272 QString allmsg = cmsg;
273 while ( allmsg.length() > 0 ) { 273 while ( allmsg.length() > 0 ) {
274 int nextC = allmsg.find( "-", 1 ); 274 int nextC = allmsg.find( "-", 1 );
275 if ( nextC == -1 ) { 275 if ( nextC == -1 ) {
276 msg = allmsg; 276 msg = allmsg;
277 allmsg = ""; 277 allmsg = "";
278 } else{ 278 } else{
279 msg = allmsg.left( nextC ); 279 msg = allmsg.left( nextC );
280 allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); 280 allmsg = allmsg.mid( nextC, allmsg.length()-nextC );
281 } 281 }
282 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); 282 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() );
283 if ( msg == "-newEvent" ) { 283 if ( msg == "-newEvent" ) {
284 mView->newEvent(); 284 mView->newEvent();
285 } 285 }
286 if ( msg == "-newTodo" ) { 286 if ( msg == "-newTodo" ) {
287 mView->newTodo(); 287 mView->newTodo();
288 288
289 } 289 }
290 if ( msg == "-showWN" ) { 290 if ( msg == "-showWN" ) {
291 mView->viewManager()->showWhatsNextView(); 291 mView->viewManager()->showWhatsNextView();
292 } 292 }
293 if ( msg == "-showTodo" ) { 293 if ( msg == "-showTodo" ) {
294 mView->viewManager()->showTodoView(); 294 mView->viewManager()->showTodoView();
295 } 295 }
296 if ( msg == "-showList" ) { 296 if ( msg == "-showList" ) {
297 mView->viewManager()->showListView(); 297 mView->viewManager()->showListView();
298 } 298 }
299 else if ( msg == "-showDay" ) { 299 else if ( msg == "-showDay" ) {
300 mView->viewManager()->showDayView(); 300 mView->viewManager()->showDayView();
301 } 301 }
302 else if ( msg == "-showWWeek" ) { 302 else if ( msg == "-showWWeek" ) {
303 mView->viewManager()->showWorkWeekView(); 303 mView->viewManager()->showWorkWeekView();
304 } 304 }
305 else if ( msg == "-ringSync" ) { 305 else if ( msg == "-ringSync" ) {
306 multiSync( false ); 306 multiSync( false );
307 } 307 }
308 else if ( msg == "-showWeek" ) { 308 else if ( msg == "-showWeek" ) {
309 mView->viewManager()->showWeekView(); 309 mView->viewManager()->showWeekView();
310 } 310 }
311 else if ( msg == "-showTodo" ) { 311 else if ( msg == "-showTodo" ) {
312 mView->viewManager()->showTodoView(); 312 mView->viewManager()->showTodoView();
313 } 313 }
314 else if ( msg == "-showJournal" ) { 314 else if ( msg == "-showJournal" ) {
315 mView->dateNavigator()->selectDates( 1 ); 315 mView->dateNavigator()->selectDates( 1 );
316 mView->dateNavigator()->selectToday(); 316 mView->dateNavigator()->selectToday();
317 mView->viewManager()->showJournalView(); 317 mView->viewManager()->showJournalView();
318 } 318 }
319 else if ( msg == "-showKO" ) { 319 else if ( msg == "-showKO" ) {
320 mView->viewManager()->showNextXView(); 320 mView->viewManager()->showNextXView();
321 } 321 }
322 else if ( msg == "-showWNext" || msg == "nextView()" ) { 322 else if ( msg == "-showWNext" || msg == "nextView()" ) {
323 mView->viewManager()->showWhatsNextView(); 323 mView->viewManager()->showWhatsNextView();
324 } 324 }
325 else if ( msg == "-showNextXView" ) { 325 else if ( msg == "-showNextXView" ) {
326 mView->viewManager()->showNextXView(); 326 mView->viewManager()->showNextXView();
327 } 327 }
328 328
329 329
330 } 330 }
331 331
332 showMaximized(); 332 showMaximized();
333 raise(); 333 raise();
334} 334}
335 335
336QPixmap MainWindow::loadPixmap( QString name ) 336QPixmap MainWindow::loadPixmap( QString name )
337{ 337{
338 return SmallIcon( name ); 338 return SmallIcon( name );
339 339
340} 340}
341void MainWindow::initActions() 341void MainWindow::initActions()
342{ 342{
343 //KOPrefs::instance()->mShowFullMenu 343 //KOPrefs::instance()->mShowFullMenu
344 iconToolBar->clear(); 344 iconToolBar->clear();
345 KOPrefs *p = KOPrefs::instance(); 345 KOPrefs *p = KOPrefs::instance();
346 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); 346 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar );
347 347
348 QPopupMenu *viewMenu = new QPopupMenu( this ); 348 QPopupMenu *viewMenu = new QPopupMenu( this );
349 QPopupMenu *actionMenu = new QPopupMenu( this ); 349 QPopupMenu *actionMenu = new QPopupMenu( this );
350 QPopupMenu *importMenu = new QPopupMenu( this ); 350 QPopupMenu *importMenu = new QPopupMenu( this );
351 351
352 syncMenu = new QPopupMenu( this ); 352 syncMenu = new QPopupMenu( this );
353 configureAgendaMenu = new QPopupMenu( this ); 353 configureAgendaMenu = new QPopupMenu( this );
354 configureToolBarMenu = new QPopupMenu( this ); 354 configureToolBarMenu = new QPopupMenu( this );
355 QPopupMenu *helpMenu = new QPopupMenu( this ); 355 QPopupMenu *helpMenu = new QPopupMenu( this );
356 if ( KOPrefs::instance()->mShowFullMenu ) { 356 if ( KOPrefs::instance()->mShowFullMenu ) {
357 QMenuBar *menuBar1; 357 QMenuBar *menuBar1;
358 menuBar1 = menuBar(); 358 menuBar1 = menuBar();
359 menuBar1->insertItem( i18n("File"), importMenu ); 359 menuBar1->insertItem( i18n("File"), importMenu );
360 menuBar1->insertItem( i18n("View"), viewMenu ); 360 menuBar1->insertItem( i18n("View"), viewMenu );
361 menuBar1->insertItem( i18n("Actions"), actionMenu ); 361 menuBar1->insertItem( i18n("Actions"), actionMenu );
362 menuBar1->insertItem( i18n("Synchronize"), syncMenu ); 362 menuBar1->insertItem( i18n("Synchronize"), syncMenu );
363 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 363 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu );
364 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); 364 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu );
365 menuBar1->insertItem( i18n("Help"), helpMenu ); 365 menuBar1->insertItem( i18n("Help"), helpMenu );
366 } else { 366 } else {
367 QPEMenuBar *menuBar1; 367 QPEMenuBar *menuBar1;
368 menuBar1 = new QPEMenuBar( iconToolBar ); 368 menuBar1 = new QPEMenuBar( iconToolBar );
369 QPopupMenu *menuBar = new QPopupMenu( this ); 369 QPopupMenu *menuBar = new QPopupMenu( this );
370 menuBar1->insertItem( i18n("ME"), menuBar); 370 menuBar1->insertItem( i18n("ME"), menuBar);
371 menuBar->insertItem( i18n("File"), importMenu ); 371 menuBar->insertItem( i18n("File"), importMenu );
372 menuBar->insertItem( i18n("View"), viewMenu ); 372 menuBar->insertItem( i18n("View"), viewMenu );
373 menuBar->insertItem( i18n("Actions"), actionMenu ); 373 menuBar->insertItem( i18n("Actions"), actionMenu );
374 menuBar->insertItem( i18n("Synchronize"), syncMenu ); 374 menuBar->insertItem( i18n("Synchronize"), syncMenu );
375 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 375 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu );
376 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); 376 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu );
377 menuBar->insertItem( i18n("Help"), helpMenu ); 377 menuBar->insertItem( i18n("Help"), helpMenu );
378 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); 378 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() );
379 menuBar1->setMaximumSize( menuBar1->sizeHint( )); 379 menuBar1->setMaximumSize( menuBar1->sizeHint( ));
380 } 380 }
381 connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) ); 381 connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) );
382 // ****************** 382 // ******************
383 QAction *action; 383 QAction *action;
384 QIconSet icon; 384 QIconSet icon;
385 // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); 385 // QPopupMenu *configureMenu= new QPopupMenu( menuBar );
386 configureToolBarMenu->setCheckable( true ); 386 configureToolBarMenu->setCheckable( true );
387 387
388 QString pathString = ""; 388 QString pathString = "";
389 if ( !p->mToolBarMiniIcons ) { 389 if ( !p->mToolBarMiniIcons ) {
390 if ( QApplication::desktop()->width() < 480 ) 390 if ( QApplication::desktop()->width() < 480 )
391 pathString += "icons16/"; 391 pathString += "icons16/";
392 } else 392 } else
393 pathString += "iconsmini/"; 393 pathString += "iconsmini/";
394 configureAgendaMenu->setCheckable( true ); 394 configureAgendaMenu->setCheckable( true );
395 configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 ); 395 configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 );
396 configureAgendaMenu->insertSeparator(); 396 configureAgendaMenu->insertSeparator();
397 configureAgendaMenu->insertItem(i18n("Tiny"), 4 ); 397 configureAgendaMenu->insertItem(i18n("Tiny"), 4 );
398 configureAgendaMenu->insertItem(i18n("Small"), 6 ); 398 configureAgendaMenu->insertItem(i18n("Small"), 6 );
399 configureAgendaMenu->insertItem(i18n("Medium"), 8 ); 399 configureAgendaMenu->insertItem(i18n("Medium"), 8 );
400 configureAgendaMenu->insertItem(i18n("Normal"), 10 ); 400 configureAgendaMenu->insertItem(i18n("Normal"), 10 );
401 configureAgendaMenu->insertItem(i18n("Large"), 12 ); 401 configureAgendaMenu->insertItem(i18n("Large"), 12 );
402 configureAgendaMenu->insertItem(i18n("Big"), 14 ); 402 configureAgendaMenu->insertItem(i18n("Big"), 14 );
403 configureAgendaMenu->insertItem(i18n("Bigger"), 16 ); 403 configureAgendaMenu->insertItem(i18n("Bigger"), 16 );
404 configureAgendaMenu->insertItem(i18n("Biggest"), 18 ); 404 configureAgendaMenu->insertItem(i18n("Biggest"), 18 );
405 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); 405 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu );
406 406
407 icon = loadPixmap( pathString + "configure" ); 407 icon = loadPixmap( pathString + "configure" );
408 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); 408 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this );
409 action->addTo( actionMenu ); 409 action->addTo( actionMenu );
410 connect( action, SIGNAL( activated() ), 410 connect( action, SIGNAL( activated() ),
411 mView, SLOT( edit_options() ) ); 411 mView, SLOT( edit_options() ) );
412 actionMenu->insertSeparator(); 412 actionMenu->insertSeparator();
413 icon = loadPixmap( pathString + "newevent" ); 413 icon = loadPixmap( pathString + "newevent" );
414 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); 414 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 );
415 configureToolBarMenu->insertSeparator(); 415 configureToolBarMenu->insertSeparator();
416 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); 416 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 );
417 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); 417 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this );
418 ne_action->addTo( actionMenu ); 418 ne_action->addTo( actionMenu );
419 connect( ne_action, SIGNAL( activated() ), 419 connect( ne_action, SIGNAL( activated() ),
420 mView, SLOT( newEvent() ) ); 420 mView, SLOT( newEvent() ) );
421 icon = loadPixmap( pathString + "newtodo" ); 421 icon = loadPixmap( pathString + "newtodo" );
422 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); 422 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 );
423 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); 423 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this );
424 nt_action->addTo( actionMenu ); 424 nt_action->addTo( actionMenu );
425 connect( nt_action, SIGNAL( activated() ), 425 connect( nt_action, SIGNAL( activated() ),
426 mView, SLOT( newTodo() ) ); 426 mView, SLOT( newTodo() ) );
427 icon = loadPixmap( pathString + "navi" ); 427 icon = loadPixmap( pathString + "navi" );
428 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); 428 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this );
429 action->addTo( viewMenu ); 429 action->addTo( viewMenu );
430 connect( action, SIGNAL( activated() ), 430 connect( action, SIGNAL( activated() ),
431 mView, SLOT( toggleDateNavigatorWidget() ) ); 431 mView, SLOT( toggleDateNavigatorWidget() ) );
432 icon = loadPixmap( pathString + "filter" ); 432 icon = loadPixmap( pathString + "filter" );
433 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); 433 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this );
434 action->addTo( viewMenu ); 434 action->addTo( viewMenu );
435 connect( action, SIGNAL( activated() ), 435 connect( action, SIGNAL( activated() ),
436 mView, SLOT( toggleFilter() ) ); 436 mView, SLOT( toggleFilter() ) );
437 437
438 438
439 viewMenu->insertSeparator(); 439 viewMenu->insertSeparator();
440 icon = loadPixmap( pathString + "picker" ); 440 icon = loadPixmap( pathString + "picker" );
441 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); 441 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this );
442 action->addTo( viewMenu ); 442 action->addTo( viewMenu );
443 connect( action, SIGNAL( activated() ), 443 connect( action, SIGNAL( activated() ),
444 mView, SLOT( showDatePicker() ) ); 444 mView, SLOT( showDatePicker() ) );
445 action->addTo( iconToolBar ); 445 action->addTo( iconToolBar );
446 viewMenu->insertSeparator(); 446 viewMenu->insertSeparator();
447 icon = loadPixmap( pathString + "list" ); 447 icon = loadPixmap( pathString + "list" );
448 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); 448 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 );
449 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); 449 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this );
450 showlist_action->addTo( viewMenu ); 450 showlist_action->addTo( viewMenu );
451 connect( showlist_action, SIGNAL( activated() ), 451 connect( showlist_action, SIGNAL( activated() ),
452 mView->viewManager(), SLOT( showListView() ) ); 452 mView->viewManager(), SLOT( showListView() ) );
453 453
454 454
455 icon = loadPixmap( pathString + "day" ); 455 icon = loadPixmap( pathString + "day" );
456 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); 456 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 );
457 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); 457 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this );
458 day1_action->addTo( viewMenu ); 458 day1_action->addTo( viewMenu );
459 // action->addTo( toolBar ); 459 // action->addTo( toolBar );
460 connect( day1_action, SIGNAL( activated() ), 460 connect( day1_action, SIGNAL( activated() ),
461 mView->viewManager(), SLOT( showDayView() ) ); 461 mView->viewManager(), SLOT( showDayView() ) );
462 462
463 icon = loadPixmap( pathString + "workweek" ); 463 icon = loadPixmap( pathString + "workweek" );
464 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); 464 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 );
465 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); 465 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this );
466 day5_action->addTo( viewMenu ); 466 day5_action->addTo( viewMenu );
467 connect( day5_action, SIGNAL( activated() ), 467 connect( day5_action, SIGNAL( activated() ),
468 mView->viewManager(), SLOT( showWorkWeekView() ) ); 468 mView->viewManager(), SLOT( showWorkWeekView() ) );
469 469
470 icon = loadPixmap( pathString + "week" ); 470 icon = loadPixmap( pathString + "week" );
471 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); 471 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 );
472 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); 472 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this );
473 day7_action->addTo( viewMenu ); 473 day7_action->addTo( viewMenu );
474 connect( day7_action, SIGNAL( activated() ), 474 connect( day7_action, SIGNAL( activated() ),
475 mView->viewManager(), SLOT( showWeekView() ) ); 475 mView->viewManager(), SLOT( showWeekView() ) );
476 476
477 icon = loadPixmap( pathString + "month" ); 477 icon = loadPixmap( pathString + "month" );
478 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); 478 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 );
479 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); 479 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this );
480 month_action->addTo( viewMenu ); 480 month_action->addTo( viewMenu );
481 connect( month_action, SIGNAL( activated() ), 481 connect( month_action, SIGNAL( activated() ),
482 mView->viewManager(), SLOT( showMonthView() ) ); 482 mView->viewManager(), SLOT( showMonthView() ) );
483 483
484 icon = loadPixmap( pathString + "todo" ); 484 icon = loadPixmap( pathString + "todo" );
485 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); 485 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 );
486 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); 486 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this );
487 todoview_action->addTo( viewMenu ); 487 todoview_action->addTo( viewMenu );
488 connect( todoview_action, SIGNAL( activated() ), 488 connect( todoview_action, SIGNAL( activated() ),
489 mView->viewManager(), SLOT( showTodoView() ) ); 489 mView->viewManager(), SLOT( showTodoView() ) );
490 490
491 icon = loadPixmap( pathString + "journal" ); 491 icon = loadPixmap( pathString + "journal" );
492 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); 492 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 );
493 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); 493 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this );
494 viewjournal_action->addTo( viewMenu ); 494 viewjournal_action->addTo( viewMenu );
495 connect( viewjournal_action, SIGNAL( activated() ), 495 connect( viewjournal_action, SIGNAL( activated() ),
496 mView->viewManager(), SLOT( showJournalView() ) ); 496 mView->viewManager(), SLOT( showJournalView() ) );
497 497
498 icon = loadPixmap( pathString + "xdays" ); 498 icon = loadPixmap( pathString + "xdays" );
499 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 ); 499 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 );
500 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); 500 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this );
501 xdays_action->addTo( viewMenu ); 501 xdays_action->addTo( viewMenu );
502 connect( xdays_action, SIGNAL( activated() ), 502 connect( xdays_action, SIGNAL( activated() ),
503 mView->viewManager(), SLOT( showNextXView() ) ); 503 mView->viewManager(), SLOT( showNextXView() ) );
504 504
505 icon = loadPixmap( pathString + "whatsnext" ); 505 icon = loadPixmap( pathString + "whatsnext" );
506 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 ); 506 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 );
507 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); 507 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this );
508 whatsnext_action->addTo( viewMenu ); 508 whatsnext_action->addTo( viewMenu );
509 connect( whatsnext_action, SIGNAL( activated() ), 509 connect( whatsnext_action, SIGNAL( activated() ),
510 mView->viewManager(), SLOT( showWhatsNextView() ) ); 510 mView->viewManager(), SLOT( showWhatsNextView() ) );
511 511
512#if 0 512#if 0
513 action = new QAction( "view_timespan", "Time Span", 0, this ); 513 action = new QAction( "view_timespan", "Time Span", 0, this );
514 action->addTo( viewMenu ); 514 action->addTo( viewMenu );
515 connect( action, SIGNAL( activated() ), 515 connect( action, SIGNAL( activated() ),
516 mView->viewManager(), SLOT( showTimeSpanView() ) ); 516 mView->viewManager(), SLOT( showTimeSpanView() ) );
517#endif 517#endif
518 518
519 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, 519 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0,
520 this ); 520 this );
521 mNewSubTodoAction->addTo( actionMenu ); 521 mNewSubTodoAction->addTo( actionMenu );
522 connect( mNewSubTodoAction, SIGNAL( activated() ), 522 connect( mNewSubTodoAction, SIGNAL( activated() ),
523 mView, SLOT( newSubTodo() ) ); 523 mView, SLOT( newSubTodo() ) );
524 524
525 actionMenu->insertSeparator(); 525 actionMenu->insertSeparator();
526 526
527 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); 527 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this );
528 mShowAction->addTo( actionMenu ); 528 mShowAction->addTo( actionMenu );
529 connect( mShowAction, SIGNAL( activated() ), 529 connect( mShowAction, SIGNAL( activated() ),
530 mView, SLOT( showIncidence() ) ); 530 mView, SLOT( showIncidence() ) );
531 531
532 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); 532 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this );
533 mEditAction->addTo( actionMenu ); 533 mEditAction->addTo( actionMenu );
534 connect( mEditAction, SIGNAL( activated() ), 534 connect( mEditAction, SIGNAL( activated() ),
535 mView, SLOT( editIncidence() ) ); 535 mView, SLOT( editIncidence() ) );
536 536
537 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); 537 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this );
538 mDeleteAction->addTo( actionMenu ); 538 mDeleteAction->addTo( actionMenu );
539 connect( mDeleteAction, SIGNAL( activated() ), 539 connect( mDeleteAction, SIGNAL( activated() ),
540 mView, SLOT( deleteIncidence() ) ); 540 mView, SLOT( deleteIncidence() ) );
541 541
542 actionMenu->insertSeparator(); 542 actionMenu->insertSeparator();
543 543
544 action = new QAction( "purge_completed", i18n("Purge Completed"), 0, 544 action = new QAction( "purge_completed", i18n("Purge Completed"), 0,
545 this ); 545 this );
546 action->addTo( actionMenu ); 546 action->addTo( actionMenu );
547 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); 547 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) );
548 548
549 icon = loadPixmap( pathString + "search" ); 549 icon = loadPixmap( pathString + "search" );
550 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); 550 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this );
551 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4); 551 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4);
552 search_action->addTo( actionMenu ); 552 search_action->addTo( actionMenu );
553 connect( search_action, SIGNAL( activated() ), 553 connect( search_action, SIGNAL( activated() ),
554 mView->dialogManager(), SLOT( showSearchDialog() ) ); 554 mView->dialogManager(), SLOT( showSearchDialog() ) );
555 555
556 icon = loadPixmap( pathString + "today" ); 556 icon = loadPixmap( pathString + "today" );
557 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); 557 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130);
558 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); 558 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this );
559 today_action->addTo( actionMenu ); 559 today_action->addTo( actionMenu );
560 connect( today_action, SIGNAL( activated() ), 560 connect( today_action, SIGNAL( activated() ),
561 mView, SLOT( goToday() ) ); 561 mView, SLOT( goToday() ) );
562 562
563 if ( KOPrefs::instance()->mShowFullMenu ) { 563 if ( KOPrefs::instance()->mShowFullMenu ) {
564 actionMenu->insertSeparator(); 564 actionMenu->insertSeparator();
565 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); 565 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu );
566 566
567 } 567 }
568 // actionMenu->insertSeparator(); 568 // actionMenu->insertSeparator();
569 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, 569 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0,
570 this ); 570 this );
571 action->addTo( importMenu ); 571 action->addTo( importMenu );
572 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); 572 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) );
573 action = new QAction( "import_quick", i18n("Import last file"), 0, 573 action = new QAction( "import_quick", i18n("Import last file"), 0,
574 this ); 574 this );
575 action->addTo( importMenu ); 575 action->addTo( importMenu );
576 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); 576 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) );
577 importMenu->insertSeparator(); 577 importMenu->insertSeparator();
578 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, 578 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0,
579 this ); 579 this );
580 action->addTo( importMenu ); 580 action->addTo( importMenu );
581 connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); 581 connect( action, SIGNAL( activated() ), SLOT( importBday() ) );
582#ifndef DESKTOP_VERSION 582#ifndef DESKTOP_VERSION
583 importMenu->insertSeparator(); 583 importMenu->insertSeparator();
584 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, 584 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0,
585 this ); 585 this );
586 action->addTo( importMenu ); 586 action->addTo( importMenu );
587 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); 587 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) );
588#else 588#else
589#ifdef _WIN32_ 589#ifdef _WIN32_
590 importMenu->insertSeparator(); 590 importMenu->insertSeparator();
591 action = new QAction( "import_ol", i18n("Import from OL"), 0, 591 action = new QAction( "import_ol", i18n("Import from OL"), 0,
592 this ); 592 this );
593 action->addTo( importMenu ); 593 action->addTo( importMenu );
594 connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); 594 connect( action, SIGNAL( activated() ), SLOT( importOL() ) );
595#endif 595#endif
596#endif 596#endif
597 597
598 importMenu->insertSeparator(); 598 importMenu->insertSeparator();
599 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, 599 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0,
600 this ); 600 this );
601 action->addTo( importMenu ); 601 action->addTo( importMenu );
602 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); 602 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) );
603 603
604 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, 604 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0,
605 this ); 605 this );
606 action->addTo( importMenu ); 606 action->addTo( importMenu );
607 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); 607 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) );
608 608
609 importMenu->insertSeparator(); 609 importMenu->insertSeparator();
610 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, 610 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0,
611 this ); 611 this );
612 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); 612 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) );
613 importMenu->insertSeparator(); 613 importMenu->insertSeparator();
614 action = new QAction( "manage cat", i18n("Manage new categories..."), 0, 614 action = new QAction( "manage cat", i18n("Manage new categories..."), 0,
615 this ); 615 this );
616 action->addTo( importMenu ); 616 action->addTo( importMenu );
617 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); 617 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) );
618#ifndef DESKTOP_VERSION 618#ifndef DESKTOP_VERSION
619 importMenu->insertSeparator(); 619 importMenu->insertSeparator();
620 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, 620 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0,
621 this ); 621 this );
622 action->addTo( importMenu ); 622 action->addTo( importMenu );
623 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); 623 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) );
624 624
625 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, 625 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0,
626 this ); 626 this );
627 action->addTo( importMenu ); 627 action->addTo( importMenu );
628 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); 628 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) );
629#else 629#else
630 importMenu->insertSeparator(); 630 importMenu->insertSeparator();
631 icon = loadPixmap( pathString + "print" ); 631 icon = loadPixmap( pathString + "print" );
632 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); 632 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this );
633 action->addTo( importMenu ); 633 action->addTo( importMenu );
634 connect( action, SIGNAL( activated() ), 634 connect( action, SIGNAL( activated() ),
635 this, SLOT( printCal() ) ); 635 this, SLOT( printCal() ) );
636 636
637 icon = loadPixmap( pathString + "print" ); 637 icon = loadPixmap( pathString + "print" );
638 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); 638 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this );
639 action->addTo( importMenu ); 639 action->addTo( importMenu );
640 connect( action, SIGNAL( activated() ), 640 connect( action, SIGNAL( activated() ),
641 this, SLOT( printSel() ) ); 641 this, SLOT( printSel() ) );
642#endif 642#endif
643 importMenu->insertSeparator(); 643 importMenu->insertSeparator();
644 action = new QAction( "beam all", i18n("Save"), 0, 644 action = new QAction( "beam all", i18n("Save"), 0,
645 this ); 645 this );
646 action->addTo( importMenu ); 646 action->addTo( importMenu );
647 connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); 647 connect( action, SIGNAL( activated() ), this, SLOT( save() ) );
648 action = new QAction( "beam all", i18n("Exit (+save)"), 0, 648 action = new QAction( "beam all", i18n("Exit (+save)"), 0,
649 this ); 649 this );
650 action->addTo( importMenu ); 650 action->addTo( importMenu );
651 connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); 651 connect( action, SIGNAL( activated() ), this, SLOT( close() ) );
652 652
653 //menuBar->insertItem( "Configure",configureMenu ); 653 //menuBar->insertItem( "Configure",configureMenu );
654 //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); 654 //configureMenu->insertItem( "Toolbar",configureToolBarMenu );
655 icon = loadPixmap( "korganizer/korganizer" ); 655 icon = loadPixmap( "korganizer/korganizer" );
656 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); 656 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this );
657 action->addTo( helpMenu ); 657 action->addTo( helpMenu );
658 connect( action, SIGNAL( activated() ), 658 connect( action, SIGNAL( activated() ),
659 SLOT( keyBindings() ) ); 659 SLOT( keyBindings() ) );
660 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); 660 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this );
661 action->addTo( helpMenu ); 661 action->addTo( helpMenu );
662 connect( action, SIGNAL( activated() ), 662 connect( action, SIGNAL( activated() ),
663 SLOT( features() ) ); 663 SLOT( features() ) );
664 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); 664 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this );
665 action->addTo( helpMenu ); 665 action->addTo( helpMenu );
666 connect( action, SIGNAL( activated() ), 666 connect( action, SIGNAL( activated() ),
667 SLOT( aboutAutoSaving() ) ); 667 SLOT( aboutAutoSaving() ) );
668 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); 668 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this );
669 action->addTo( helpMenu ); 669 action->addTo( helpMenu );
670 connect( action, SIGNAL( activated() ), 670 connect( action, SIGNAL( activated() ),
671 SLOT( aboutKnownBugs() ) ); 671 SLOT( aboutKnownBugs() ) );
672 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); 672 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this );
673 action->addTo( helpMenu ); 673 action->addTo( helpMenu );
674 connect( action, SIGNAL( activated() ), 674 connect( action, SIGNAL( activated() ),
675 SLOT( usertrans() ) ); 675 SLOT( usertrans() ) );
676 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); 676 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this );
677 action->addTo( helpMenu ); 677 action->addTo( helpMenu );
678 connect( action, SIGNAL( activated() ), 678 connect( action, SIGNAL( activated() ),
679 SLOT( synchowto() ) ); 679 SLOT( synchowto() ) );
680 action = new QAction( "Whats New", i18n("What's new?"), 0,this ); 680 action = new QAction( "Whats New", i18n("What's new?"), 0,this );
681 action->addTo( helpMenu ); 681 action->addTo( helpMenu );
682 connect( action, SIGNAL( activated() ), 682 connect( action, SIGNAL( activated() ),
683 SLOT( whatsNew() ) ); 683 SLOT( whatsNew() ) );
684 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); 684 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this );
685 action->addTo( helpMenu ); 685 action->addTo( helpMenu );
686 connect( action, SIGNAL( activated() ), 686 connect( action, SIGNAL( activated() ),
687 SLOT( faq() ) ); 687 SLOT( faq() ) );
688 688
689 689
690 action = new QAction( "about", i18n("About..."), 0, this ); 690 action = new QAction( "about", i18n("About..."), 0, this );
691 action->addTo( helpMenu ); 691 action->addTo( helpMenu );
692 connect( action, SIGNAL( activated() ), 692 connect( action, SIGNAL( activated() ),
693 SLOT( about() ) ); 693 SLOT( about() ) );
694 //menuBar->insertSeparator(); 694 //menuBar->insertSeparator();
695 695
696 // ****************************************************** 696 // ******************************************************
697 // menubar icons 697 // menubar icons
698 698
699 699
700 iconToolBar->setHorizontalStretchable (true ); 700 iconToolBar->setHorizontalStretchable (true );
701 //menuBar->insertItem( iconToolBar ); 701 //menuBar->insertItem( iconToolBar );
702 //xdays_action 702 //xdays_action
703 if (p-> mShowIconNewEvent) 703 if (p-> mShowIconNewEvent)
704 ne_action->addTo( iconToolBar ); 704 ne_action->addTo( iconToolBar );
705 if (p->mShowIconNewTodo ) 705 if (p->mShowIconNewTodo )
706 nt_action->addTo( iconToolBar ); 706 nt_action->addTo( iconToolBar );
707 if (p-> mShowIconSearch) 707 if (p-> mShowIconSearch)
708 search_action->addTo( iconToolBar ); 708 search_action->addTo( iconToolBar );
709 if (p-> mShowIconNext) 709 if (p-> mShowIconNext)
710 whatsnext_action->addTo( iconToolBar ); 710 whatsnext_action->addTo( iconToolBar );
711 if (p-> mShowIconNextDays) 711 if (p-> mShowIconNextDays)
712 xdays_action->addTo( iconToolBar ); 712 xdays_action->addTo( iconToolBar );
713 if (p-> mShowIconList) 713 if (p-> mShowIconList)
714 showlist_action->addTo( iconToolBar ); 714 showlist_action->addTo( iconToolBar );
715 if (p-> mShowIconDay1) 715 if (p-> mShowIconDay1)
716 day1_action->addTo( iconToolBar ); 716 day1_action->addTo( iconToolBar );
717 if (p-> mShowIconDay5) 717 if (p-> mShowIconDay5)
718 day5_action->addTo( iconToolBar ); 718 day5_action->addTo( iconToolBar );
719 if (p-> mShowIconDay7) 719 if (p-> mShowIconDay7)
720 day7_action->addTo( iconToolBar ); 720 day7_action->addTo( iconToolBar );
721 if (p-> mShowIconMonth) 721 if (p-> mShowIconMonth)
722 month_action->addTo( iconToolBar ); 722 month_action->addTo( iconToolBar );
723 if (p-> mShowIconTodoview) 723 if (p-> mShowIconTodoview)
724 todoview_action->addTo( iconToolBar ); 724 todoview_action->addTo( iconToolBar );
725 if (p-> mShowIconJournal) 725 if (p-> mShowIconJournal)
726 viewjournal_action->addTo( iconToolBar ); 726 viewjournal_action->addTo( iconToolBar );
727 icon = loadPixmap( pathString + "2leftarrowB" ); 727 icon = loadPixmap( pathString + "2leftarrowB" );
728 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); 728 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14);
729 if (p-> mShowIconBackFast) { 729 if (p-> mShowIconBackFast) {
730 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); 730 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this );
731 connect( action, SIGNAL( activated() ), 731 connect( action, SIGNAL( activated() ),
732 mView, SLOT( goPreviousMonth() ) ); 732 mView, SLOT( goPreviousMonth() ) );
733 action->addTo( iconToolBar ); 733 action->addTo( iconToolBar );
734 } 734 }
735 icon = loadPixmap( pathString + "1leftarrowB" ); 735 icon = loadPixmap( pathString + "1leftarrowB" );
736 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); 736 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15);
737 if (p-> mShowIconBack) { 737 if (p-> mShowIconBack) {
738 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); 738 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this );
739 connect( action, SIGNAL( activated() ), 739 connect( action, SIGNAL( activated() ),
740 mView, SLOT( goPrevious() ) ); 740 mView, SLOT( goPrevious() ) );
741 action->addTo( iconToolBar ); 741 action->addTo( iconToolBar );
742 } 742 }
743 if (p-> mShowIconToday) 743 if (p-> mShowIconToday)
744 today_action->addTo( iconToolBar ); 744 today_action->addTo( iconToolBar );
745 icon = loadPixmap( pathString + "1rightarrowB" ); 745 icon = loadPixmap( pathString + "1rightarrowB" );
746 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); 746 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220);
747 if (p-> mShowIconForward) { 747 if (p-> mShowIconForward) {
748 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); 748 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this );
749 connect( action, SIGNAL( activated() ), 749 connect( action, SIGNAL( activated() ),
750 mView, SLOT( goNext() ) ); 750 mView, SLOT( goNext() ) );
751 action->addTo( iconToolBar ); 751 action->addTo( iconToolBar );
752 } 752 }
753 icon = loadPixmap( pathString + "2rightarrowB" ); 753 icon = loadPixmap( pathString + "2rightarrowB" );
754 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); 754 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230);
755 if (p-> mShowIconForwardFast) { 755 if (p-> mShowIconForwardFast) {
756 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); 756 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this );
757 connect( action, SIGNAL( activated() ), 757 connect( action, SIGNAL( activated() ),
758 mView, SLOT( goNextMonth() ) ); 758 mView, SLOT( goNextMonth() ) );
759 action->addTo( iconToolBar ); 759 action->addTo( iconToolBar );
760 } 760 }
761 761
762 762
763 configureToolBarMenu->insertItem(i18n("What's This?"), 300); 763 configureToolBarMenu->insertItem(i18n("What's This?"), 300);
764 764
765 if (p-> mShowIconNewEvent) 765 if (p-> mShowIconNewEvent)
766 configureToolBarMenu->setItemChecked( 10, true ); 766 configureToolBarMenu->setItemChecked( 10, true );
767 if (p->mShowIconNewTodo ) 767 if (p->mShowIconNewTodo )
768 configureToolBarMenu->setItemChecked( 20, true ); 768 configureToolBarMenu->setItemChecked( 20, true );
769 if (p-> mShowIconSearch) 769 if (p-> mShowIconSearch)
770 configureToolBarMenu->setItemChecked( 120, true ); 770 configureToolBarMenu->setItemChecked( 120, true );
771 if (p-> mShowIconList) 771 if (p-> mShowIconList)
772 configureToolBarMenu->setItemChecked( 30, true ); 772 configureToolBarMenu->setItemChecked( 30, true );
773 if (p-> mShowIconDay1) 773 if (p-> mShowIconDay1)
774 configureToolBarMenu->setItemChecked( 40, true ); 774 configureToolBarMenu->setItemChecked( 40, true );
775 if (p-> mShowIconDay5) 775 if (p-> mShowIconDay5)
776 configureToolBarMenu->setItemChecked( 50, true ); 776 configureToolBarMenu->setItemChecked( 50, true );
777 if (p-> mShowIconDay7) 777 if (p-> mShowIconDay7)
778 configureToolBarMenu->setItemChecked( 60, true ); 778 configureToolBarMenu->setItemChecked( 60, true );
779 if (p-> mShowIconMonth) 779 if (p-> mShowIconMonth)
780 configureToolBarMenu->setItemChecked( 70, true ); 780 configureToolBarMenu->setItemChecked( 70, true );
781 if (p-> mShowIconTodoview) 781 if (p-> mShowIconTodoview)
782 configureToolBarMenu->setItemChecked( 80, true ); 782 configureToolBarMenu->setItemChecked( 80, true );
783 if (p-> mShowIconBackFast) 783 if (p-> mShowIconBackFast)
784 configureToolBarMenu->setItemChecked( 200, true ); 784 configureToolBarMenu->setItemChecked( 200, true );
785 if (p-> mShowIconBack) 785 if (p-> mShowIconBack)
786 configureToolBarMenu->setItemChecked( 210, true ); 786 configureToolBarMenu->setItemChecked( 210, true );
787 if (p-> mShowIconToday) 787 if (p-> mShowIconToday)
788 configureToolBarMenu->setItemChecked( 130, true ); 788 configureToolBarMenu->setItemChecked( 130, true );
789 if (p-> mShowIconForward) 789 if (p-> mShowIconForward)
790 configureToolBarMenu->setItemChecked( 220, true ); 790 configureToolBarMenu->setItemChecked( 220, true );
791 if (p-> mShowIconForwardFast) 791 if (p-> mShowIconForwardFast)
792 configureToolBarMenu->setItemChecked( 230, true ); 792 configureToolBarMenu->setItemChecked( 230, true );
793 if (p-> mShowIconNextDays) 793 if (p-> mShowIconNextDays)
794 configureToolBarMenu->setItemChecked( 100, true ); 794 configureToolBarMenu->setItemChecked( 100, true );
795 if (p-> mShowIconNext) 795 if (p-> mShowIconNext)
796 configureToolBarMenu->setItemChecked( 110, true ); 796 configureToolBarMenu->setItemChecked( 110, true );
797 if (p-> mShowIconJournal) 797 if (p-> mShowIconJournal)
798 configureToolBarMenu->setItemChecked( 90, true ); 798 configureToolBarMenu->setItemChecked( 90, true );
799 if (p-> mShowIconWhatsThis) 799 if (p-> mShowIconWhatsThis)
800 configureToolBarMenu->setItemChecked( 300, true ); 800 configureToolBarMenu->setItemChecked( 300, true );
801 801
802 QLabel* dummy = new QLabel( iconToolBar ); 802 QLabel* dummy = new QLabel( iconToolBar );
803 dummy->setBackgroundColor( iconToolBar->backgroundColor() ); 803 dummy->setBackgroundColor( iconToolBar->backgroundColor() );
804 if (!p-> mShowIconStretch) 804 if (!p-> mShowIconStretch)
805 iconToolBar->setStretchableWidget ( dummy ) ; 805 iconToolBar->setStretchableWidget ( dummy ) ;
806 else 806 else
807 configureToolBarMenu->setItemChecked( 5, true ); 807 configureToolBarMenu->setItemChecked( 5, true );
808 if (p-> mShowIconWhatsThis) 808 if (p-> mShowIconWhatsThis)
809 QWhatsThis::whatsThisButton ( iconToolBar ); 809 QWhatsThis::whatsThisButton ( iconToolBar );
810 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); 810 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) );
811 configureAgenda( p->mHourSize ); 811 configureAgenda( p->mHourSize );
812 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); 812 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) );
813} 813}
814void MainWindow::fillSyncMenu() 814void MainWindow::fillSyncMenu()
815{ 815{
816 syncMenu->clear(); 816 syncMenu->clear();
817 syncMenu->insertItem( i18n("Configure..."), 0 ); 817 syncMenu->insertItem( i18n("Configure..."), 0 );
818 syncMenu->insertSeparator(); 818 syncMenu->insertSeparator();
819 syncMenu->insertItem( i18n("Multiple sync"), 1 ); 819 syncMenu->insertItem( i18n("Multiple sync"), 1 );
820 syncMenu->insertSeparator(); 820 syncMenu->insertSeparator();
821 KConfig config ( locateLocal( "config","syncprofilesrc" ) ); 821 KConfig config ( locateLocal( "config","syncprofilesrc" ) );
822 config.setGroup("General"); 822 config.setGroup("General");
823 QStringList prof = config.readListEntry("SyncProfileNames"); 823 QStringList prof = config.readListEntry("SyncProfileNames");
824 KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); 824 KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined");
825 if ( prof.count() < 3 ) { 825 if ( prof.count() < 3 ) {
826 prof.clear(); 826 prof.clear();
827 prof << i18n("Sharp_DTM"); 827 prof << i18n("Sharp_DTM");
828 prof << i18n("Local_file"); 828 prof << i18n("Local_file");
829 prof << i18n("Last_file"); 829 prof << i18n("Last_file");
830 KSyncProfile* temp = new KSyncProfile (); 830 KSyncProfile* temp = new KSyncProfile ();
831 temp->setName( prof[0] ); 831 temp->setName( prof[0] );
832 temp->writeConfig(&config); 832 temp->writeConfig(&config);
833 temp->setName( prof[1] ); 833 temp->setName( prof[1] );
834 temp->writeConfig(&config); 834 temp->writeConfig(&config);
835 temp->setName( prof[2] ); 835 temp->setName( prof[2] );
836 temp->writeConfig(&config); 836 temp->writeConfig(&config);
837 config.setGroup("General"); 837 config.setGroup("General");
838 config.writeEntry("SyncProfileNames",prof); 838 config.writeEntry("SyncProfileNames",prof);
839 config.writeEntry("ExternSyncProfiles","Sharp_DTM");
839 config.sync(); 840 config.sync();
840 delete temp; 841 delete temp;
841 } 842 }
843 KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
842 KOPrefs::instance()->mSyncProfileNames = prof; 844 KOPrefs::instance()->mSyncProfileNames = prof;
843 int i; 845 int i;
844 for ( i = 0; i < prof.count(); ++i ) { 846 for ( i = 0; i < prof.count(); ++i ) {
845 847
846 syncMenu->insertItem( prof[i], 1000+i ); 848 syncMenu->insertItem( prof[i], 1000+i );
847 if ( i == 2 ) 849 if ( i == 2 )
848 syncMenu->insertSeparator(); 850 syncMenu->insertSeparator();
849 } 851 }
850 QDir app_dir; 852 QDir app_dir;
851 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { 853 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
852 syncMenu->setItemEnabled( false , 1000 ); 854 syncMenu->setItemEnabled( false , 1000 );
853 } 855 }
856 mView->setupExternSyncProfiles();
854} 857}
855 858
856int MainWindow::ringSync() 859int MainWindow::ringSync()
857{ 860{
858 int syncedProfiles = 0; 861 int syncedProfiles = 0;
859 int i; 862 int i;
860 QTime timer; 863 QTime timer;
861 KConfig config ( locateLocal( "config","syncprofilesrc" ) ); 864 KConfig config ( locateLocal( "config","syncprofilesrc" ) );
862 QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames; 865 QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames;
863 KSyncProfile* temp = new KSyncProfile (); 866 KSyncProfile* temp = new KSyncProfile ();
864 KOPrefs::instance()->mAskForPreferences = false; 867 KOPrefs::instance()->mAskForPreferences = false;
865 for ( i = 0; i < syncProfileNames.count(); ++i ) { 868 for ( i = 0; i < syncProfileNames.count(); ++i ) {
866 mCurrentSyncProfile = i; 869 mCurrentSyncProfile = i;
867 temp->setName(syncProfileNames[mCurrentSyncProfile]); 870 temp->setName(syncProfileNames[mCurrentSyncProfile]);
868 temp->readConfig(&config); 871 temp->readConfig(&config);
869 if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) { 872 if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) {
870 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); 873 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
871 ++syncedProfiles; 874 ++syncedProfiles;
872 // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 875 // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
873 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 876 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
874 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 877 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
875 KOPrefs::instance()->mShowSyncSummary = false; 878 KOPrefs::instance()->mShowSyncSummary = false;
876 mView->setSyncDevice(syncProfileNames[i] ); 879 mView->setSyncDevice(syncProfileNames[i] );
877 mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); 880 mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
878 if ( i == 0 ) { 881 if ( i == 0 ) {
879 syncSharp(); 882 syncSharp();
880 } else { 883 } else {
881 if ( temp->getIsLocalFileSync() ) { 884 if ( temp->getIsLocalFileSync() ) {
882 if ( syncWithFile( temp->getRemoteFileName( ), true ) ) 885 if ( syncWithFile( temp->getRemoteFileName( ), true ) )
883 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); 886 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName();
884 } else { 887 } else {
885 syncRemote( temp, false ); 888 syncRemote( temp, false );
886 889
887 } 890 }
888 } 891 }
889 timer.start(); 892 timer.start();
890 setCaption(i18n("Multiple sync in progress ... please wait!") ); 893 setCaption(i18n("Multiple sync in progress ... please wait!") );
891 while ( timer.elapsed () < 2000 ) { 894 while ( timer.elapsed () < 2000 ) {
892 qApp->processEvents(); 895 qApp->processEvents();
893#ifndef _WIN32_ 896#ifndef _WIN32_
894 sleep (1); 897 sleep (1);
895#endif 898#endif
896 } 899 }
897 900
898 } 901 }
899 902
900 } 903 }
901 delete temp; 904 delete temp;
902 return syncedProfiles; 905 return syncedProfiles;
903} 906}
904 907
905void MainWindow::multiSync( bool askforPrefs ) 908void MainWindow::multiSync( bool askforPrefs )
906{ 909{
907 if (mBlockSaveFlag) 910 if (mBlockSaveFlag)
908 return; 911 return;
909 mBlockSaveFlag = true; 912 mBlockSaveFlag = true;
910 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 913 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
911 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 914 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
912 question, 915 question,
913 i18n("Yes"), i18n("No"), 916 i18n("Yes"), i18n("No"),
914 0, 0 ) != 0 ) { 917 0, 0 ) != 0 ) {
915 mBlockSaveFlag = false; 918 mBlockSaveFlag = false;
916 setCaption(i18n("Aborted! Nothing synced!")); 919 setCaption(i18n("Aborted! Nothing synced!"));
917 return; 920 return;
918 } 921 }
919 mView->setSyncDevice(i18n("Multiple profiles") ); 922 mView->setSyncDevice(i18n("Multiple profiles") );
920 KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs; 923 KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs;
921 if ( askforPrefs ) { 924 if ( askforPrefs ) {
922 mView->edit_sync_options(); 925 mView->edit_sync_options();
923 KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs; 926 KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs;
924 } 927 }
925 setCaption(i18n("Multiple sync started.") ); 928 setCaption(i18n("Multiple sync started.") );
926 qApp->processEvents(); 929 qApp->processEvents();
927 int num = ringSync() ; 930 int num = ringSync() ;
928 if ( num > 1 ) 931 if ( num > 1 )
929 ringSync(); 932 ringSync();
930 mBlockSaveFlag = false; 933 mBlockSaveFlag = false;
931 if ( num ) 934 if ( num )
932 save(); 935 save();
933 if ( num ) 936 if ( num )
934 setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); 937 setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) );
935 else 938 else
936 setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 939 setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
937 return; 940 return;
938} 941}
939void MainWindow::slotSyncMenu( int action ) 942void MainWindow::slotSyncMenu( int action )
940{ 943{
941 //qDebug("syncaction %d ", action); 944 //qDebug("syncaction %d ", action);
942 if ( action == 0 ) { 945 if ( action == 0 ) {
943 946
944 confSync(); 947 confSync();
945 948
946 return; 949 return;
947 } 950 }
948 if ( action == 1 ) { 951 if ( action == 1 ) {
949 multiSync( true ); 952 multiSync( true );
950 return; 953 return;
951 } 954 }
952 955
953 if (mBlockSaveFlag) 956 if (mBlockSaveFlag)
954 return; 957 return;
955 mBlockSaveFlag = true; 958 mBlockSaveFlag = true;
956 mCurrentSyncProfile = action - 1000 ; 959 mCurrentSyncProfile = action - 1000 ;
957 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); 960 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] );
958 mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); 961 mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
959 KConfig config ( locateLocal( "config","syncprofilesrc" ) ); 962 KConfig config ( locateLocal( "config","syncprofilesrc" ) );
960 KSyncProfile* temp = new KSyncProfile (); 963 KSyncProfile* temp = new KSyncProfile ();
961 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 964 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
962 temp->readConfig(&config); 965 temp->readConfig(&config);
963 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 966 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
964 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); 967 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs();
965 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 968 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
966 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 969 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
967 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); 970 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync();
968 if ( action == 1000 ) { 971 if ( action == 1000 ) {
969 syncSharp(); 972 syncSharp();
970 973
971 } else if ( action == 1001 ) { 974 } else if ( action == 1001 ) {
972 syncLocalFile(); 975 syncLocalFile();
973 976
974 } else if ( action == 1002 ) { 977 } else if ( action == 1002 ) {
975 quickSyncLocalFile(); 978 quickSyncLocalFile();
976 979
977 } else if ( action >= 1003 ) { 980 } else if ( action >= 1003 ) {
978 if ( temp->getIsLocalFileSync() ) { 981 if ( temp->getIsLocalFileSync() ) {
979 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 982 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
980 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); 983 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName();
981 } else { 984 } else {
982 syncRemote( temp ); 985 syncRemote( temp );
983 986
984 } 987 }
985 } 988 }
986 delete temp; 989 delete temp;
987 mBlockSaveFlag = false; 990 mBlockSaveFlag = false;
988} 991}
989void MainWindow::setDefaultPreferences() 992void MainWindow::setDefaultPreferences()
990{ 993{
991 KOPrefs *p = KOPrefs::instance(); 994 KOPrefs *p = KOPrefs::instance();
992 995
993 p->mCompactDialogs = true; 996 p->mCompactDialogs = true;
994 p->mConfirm = true; 997 p->mConfirm = true;
995 // p->mEnableQuickTodo = false; 998 // p->mEnableQuickTodo = false;
996} 999}
997 1000
998QString MainWindow::resourcePath() 1001QString MainWindow::resourcePath()
999{ 1002{
1000 return KGlobal::iconLoader()->iconPath(); 1003 return KGlobal::iconLoader()->iconPath();
1001} 1004}
1002 1005
1003void MainWindow::displayText( QString text ,QString cap ) 1006void MainWindow::displayText( QString text ,QString cap )
1004{ 1007{
1005 QDialog dia( this, "name", true ); ; 1008 QDialog dia( this, "name", true ); ;
1006 dia.setCaption( cap ); 1009 dia.setCaption( cap );
1007 QVBoxLayout* lay = new QVBoxLayout( &dia ); 1010 QVBoxLayout* lay = new QVBoxLayout( &dia );
1008 lay->setSpacing( 3 ); 1011 lay->setSpacing( 3 );
1009 lay->setMargin( 3 ); 1012 lay->setMargin( 3 );
1010 QTextBrowser tb ( &dia ); 1013 QTextBrowser tb ( &dia );
1011 lay->addWidget( &tb ); 1014 lay->addWidget( &tb );
1012 tb.setText( text ); 1015 tb.setText( text );
1013#ifdef DESKTOP_VERSION 1016#ifdef DESKTOP_VERSION
1014 dia.resize( 640, 480); 1017 dia.resize( 640, 480);
1015#else 1018#else
1016 dia.showMaximized(); 1019 dia.showMaximized();
1017#endif 1020#endif
1018 dia.exec(); 1021 dia.exec();
1019} 1022}
1020void MainWindow::displayFile( QString fn, QString cap ) 1023void MainWindow::displayFile( QString fn, QString cap )
1021{ 1024{
1022 QString fileName = resourcePath() + fn; 1025 QString fileName = resourcePath() + fn;
1023 QString text; 1026 QString text;
1024 QFile file( fileName ); 1027 QFile file( fileName );
1025 if (!file.open( IO_ReadOnly ) ) { 1028 if (!file.open( IO_ReadOnly ) ) {
1026 return ; 1029 return ;
1027 1030
1028 } 1031 }
1029 QTextStream ts( &file ); 1032 QTextStream ts( &file );
1030 text = ts.read(); 1033 text = ts.read();
1031 file.close(); 1034 file.close();
1032 displayText( text, cap); 1035 displayText( text, cap);
1033} 1036}
1034void MainWindow::features() 1037void MainWindow::features()
1035{ 1038{
1036 1039
1037 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); 1040 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") );
1038} 1041}
1039 1042
1040void MainWindow::usertrans() 1043void MainWindow::usertrans()
1041{ 1044{
1042 1045
1043 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); 1046 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") );
1044} 1047}
1045void MainWindow::synchowto() 1048void MainWindow::synchowto()
1046{ 1049{
1047 1050
1048 displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") ); 1051 displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") );
1049} 1052}
1050void MainWindow::faq() 1053void MainWindow::faq()
1051{ 1054{
1052 displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); 1055 displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") );
1053 1056
1054} 1057}
1055void MainWindow::whatsNew() 1058void MainWindow::whatsNew()
1056{ 1059{
1057 displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") ); 1060 displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") );
1058 1061
1059} 1062}
1060void MainWindow::about() 1063void MainWindow::about()
1061{ 1064{
1062 QString version; 1065 QString version;
1063#include <../version> 1066#include <../version>
1064 QMessageBox::about( this, i18n("About KOrganizer/Pi"), 1067 QMessageBox::about( this, i18n("About KOrganizer/Pi"),
1065 i18n("KOrganizer/Platform-independent\n") + 1068 i18n("KOrganizer/Platform-independent\n") +
1066 "(KO/Pi) " + version + " - " + 1069 "(KO/Pi) " + version + " - " +
1067 1070
1068#ifdef DESKTOP_VERSION 1071#ifdef DESKTOP_VERSION
1069 i18n("Desktop Edition\n") + 1072 i18n("Desktop Edition\n") +
1070#else 1073#else
1071 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + 1074 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") +
1072#endif 1075#endif
1073 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") ); 1076 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") );
1074} 1077}
1075void MainWindow::keyBindings() 1078void MainWindow::keyBindings()
1076{ 1079{
1077 QString cap = i18n("Key bindings KOrganizer/Pi"); 1080 QString cap = i18n("Key bindings KOrganizer/Pi");
1078 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + 1081 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") +
1079 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ 1082 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+
1080 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + 1083 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") +
1081 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ 1084 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+
1082 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ 1085 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+
1083 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ 1086 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+
1084 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ 1087 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+
1085 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ 1088 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+
1086 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ 1089 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+
1087 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ 1090 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+
1088 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ 1091 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+
1089 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ 1092 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+
1090 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ 1093 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+
1091 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ 1094 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+
1092 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ 1095 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+
1093 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ 1096 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+
1094 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ 1097 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+
1095 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ 1098 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+
1096 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ 1099 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+
1097 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ 1100 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+
1098 i18n("<p><h3>In agenda view:</h3></p>\n") + 1101 i18n("<p><h3>In agenda view:</h3></p>\n") +
1099 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ 1102 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+
1100 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ 1103 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+
1101 i18n("<p><h3>In todo view:</h3></p>\n") + 1104 i18n("<p><h3>In todo view:</h3></p>\n") +
1102 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ 1105 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+
1103 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1106 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1104 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ 1107 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+
1105 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ 1108 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+
1106 i18n("<p><h3>In list view:</h3></p>\n") + 1109 i18n("<p><h3>In list view:</h3></p>\n") +
1107 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1110 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1108 i18n("<p><b>return</b>: Select item+one step down</p>\n")+ 1111 i18n("<p><b>return</b>: Select item+one step down</p>\n")+
1109 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ 1112 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+
1110 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ 1113 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+
1111 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ 1114 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+
1112 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ 1115 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+
1113 i18n("<p><h3>In event/todo viewer:</h3></p>\n") + 1116 i18n("<p><h3>In event/todo viewer:</h3></p>\n") +
1114 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ 1117 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+
1115 i18n("<p><b>A</b>: Show agenda view.</p>\n")+ 1118 i18n("<p><b>A</b>: Show agenda view.</p>\n")+
1116 i18n("<p><b>E</b>: Edit item</p>\n") + 1119 i18n("<p><b>E</b>: Edit item</p>\n") +
1117 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + 1120 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") +
1118 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + 1121 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") +
1119 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ 1122 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+
1120 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ 1123 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+
1121 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ 1124 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+
1122 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ 1125 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+
1123 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ 1126 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+
1124 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + 1127 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") +
1125 i18n("<p><b>White</b>: Item readonly</p>\n"); 1128 i18n("<p><b>White</b>: Item readonly</p>\n");
1126 displayText( text, cap); 1129 displayText( text, cap);
1127 1130
1128} 1131}
1129void MainWindow::aboutAutoSaving() 1132void MainWindow::aboutAutoSaving()
1130{ 1133{
1131 QMessageBox* msg; 1134 QMessageBox* msg;
1132 msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), 1135 msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"),
1133 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, 1136 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,
1134 QMessageBox::Ok, 1137 QMessageBox::Ok,
1135 QMessageBox::NoButton, 1138 QMessageBox::NoButton,
1136 QMessageBox::NoButton); 1139 QMessageBox::NoButton);
1137 msg->exec(); 1140 msg->exec();
1138 delete msg; 1141 delete msg;
1139 1142
1140 1143
1141} 1144}
1142void MainWindow::aboutKnownBugs() 1145void MainWindow::aboutKnownBugs()
1143{ 1146{
1144 QMessageBox* msg; 1147 QMessageBox* msg;
1145 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), 1148 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"),
1146 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")+ 1149 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")+
1147 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ 1150 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+
1148 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + 1151 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") +
1149 i18n("\nor report them in the bugtracker on\n") + 1152 i18n("\nor report them in the bugtracker on\n") +
1150 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), 1153 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"),
1151 QMessageBox::NoIcon, 1154 QMessageBox::NoIcon,
1152 QMessageBox::Ok, 1155 QMessageBox::Ok,
1153 QMessageBox::NoButton, 1156 QMessageBox::NoButton,
1154 QMessageBox::NoButton); 1157 QMessageBox::NoButton);
1155 msg->exec(); 1158 msg->exec();
1156 delete msg; 1159 delete msg;
1157 1160
1158} 1161}
1159 1162
1160QString MainWindow::defaultFileName() 1163QString MainWindow::defaultFileName()
1161{ 1164{
1162 return locateLocal( "data", "korganizer/mycalendar.ics" ); 1165 return locateLocal( "data", "korganizer/mycalendar.ics" );
1163} 1166}
1164 1167
1165void MainWindow::processIncidenceSelection( Incidence *incidence ) 1168void MainWindow::processIncidenceSelection( Incidence *incidence )
1166{ 1169{
1167 if ( !incidence ) { 1170 if ( !incidence ) {
1168 enableIncidenceActions( false ); 1171 enableIncidenceActions( false );
1169 1172
1170 mNewSubTodoAction->setEnabled( false ); 1173 mNewSubTodoAction->setEnabled( false );
1171 setCaptionToDates(); 1174 setCaptionToDates();
1172 return; 1175 return;
1173 1176
1174 } 1177 }
1175 1178
1176 //KGlobal::locale()->formatDateTime(nextA, true); 1179 //KGlobal::locale()->formatDateTime(nextA, true);
1177 QString startString = ""; 1180 QString startString = "";
1178 if ( incidence->type() != "Todo" ) { 1181 if ( incidence->type() != "Todo" ) {
1179 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { 1182 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) {
1180 if ( incidence->doesFloat() ) { 1183 if ( incidence->doesFloat() ) {
1181 startString += ": "+incidence->dtStartDateStr( true ); 1184 startString += ": "+incidence->dtStartDateStr( true );
1182 startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); 1185 startString += " --- "+((Event*)incidence)->dtEndDateStr( true );
1183 1186
1184 } else { 1187 } else {
1185 startString = ": "+incidence->dtStartStr(true); 1188 startString = ": "+incidence->dtStartStr(true);
1186 startString += " --- "+((Event*)incidence)->dtEndStr(true); 1189 startString += " --- "+((Event*)incidence)->dtEndStr(true);
1187 1190
1188 } 1191 }
1189 1192
1190 } else { 1193 } else {
1191 if ( incidence->dtStart().time() != incidence->dtEnd().time() ) 1194 if ( incidence->dtStart().time() != incidence->dtEnd().time() )
1192 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ 1195 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+
1193 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); 1196 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time());
1194 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); 1197 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true);
1195 } 1198 }
1196 1199
1197 } 1200 }
1198 else 1201 else
1199 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); 1202 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed");
1200 if ( !incidence->location().isEmpty() ) 1203 if ( !incidence->location().isEmpty() )
1201 startString += " (" +incidence->location()+")"; 1204 startString += " (" +incidence->location()+")";
1202 setCaption( incidence->summary()+startString); 1205 setCaption( incidence->summary()+startString);
1203 1206
1204 enableIncidenceActions( true ); 1207 enableIncidenceActions( true );
1205 1208
1206 if ( incidence->type() == "Event" ) { 1209 if ( incidence->type() == "Event" ) {
1207 mShowAction->setText( i18n("Show Event...") ); 1210 mShowAction->setText( i18n("Show Event...") );
1208 mEditAction->setText( i18n("Edit Event...") ); 1211 mEditAction->setText( i18n("Edit Event...") );
1209 mDeleteAction->setText( i18n("Delete Event...") ); 1212 mDeleteAction->setText( i18n("Delete Event...") );
1210 1213
1211 mNewSubTodoAction->setEnabled( false ); 1214 mNewSubTodoAction->setEnabled( false );
1212 } else if ( incidence->type() == "Todo" ) { 1215 } else if ( incidence->type() == "Todo" ) {
1213 mShowAction->setText( i18n("Show Todo...") ); 1216 mShowAction->setText( i18n("Show Todo...") );
1214 mEditAction->setText( i18n("Edit Todo...") ); 1217 mEditAction->setText( i18n("Edit Todo...") );
1215 mDeleteAction->setText( i18n("Delete Todo...") ); 1218 mDeleteAction->setText( i18n("Delete Todo...") );
1216 1219
1217 mNewSubTodoAction->setEnabled( true ); 1220 mNewSubTodoAction->setEnabled( true );
1218 } else { 1221 } else {
1219 mShowAction->setText( i18n("Show...") ); 1222 mShowAction->setText( i18n("Show...") );
1220 mShowAction->setText( i18n("Edit...") ); 1223 mShowAction->setText( i18n("Edit...") );
1221 mShowAction->setText( i18n("Delete...") ); 1224 mShowAction->setText( i18n("Delete...") );
1222 1225
1223 mNewSubTodoAction->setEnabled( false ); 1226 mNewSubTodoAction->setEnabled( false );
1224 } 1227 }
1225} 1228}
1226 1229
1227void MainWindow::enableIncidenceActions( bool enabled ) 1230void MainWindow::enableIncidenceActions( bool enabled )
1228{ 1231{
1229 mShowAction->setEnabled( enabled ); 1232 mShowAction->setEnabled( enabled );
1230 mEditAction->setEnabled( enabled ); 1233 mEditAction->setEnabled( enabled );
1231 mDeleteAction->setEnabled( enabled ); 1234 mDeleteAction->setEnabled( enabled );
1232} 1235}
1233 1236
1234void MainWindow::importOL() 1237void MainWindow::importOL()
1235{ 1238{
1236#ifdef _WIN32_ 1239#ifdef _WIN32_
1237 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); 1240 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this );
1238 id->exec(); 1241 id->exec();
1239 delete id; 1242 delete id;
1240 mView->updateView(); 1243 mView->updateView();
1241#endif 1244#endif
1242} 1245}
1243void MainWindow::importBday() 1246void MainWindow::importBday()
1244{ 1247{
1245 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1248 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1246 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), 1249 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"),
1247 i18n("Import!"), i18n("Cancel"), 0, 1250 i18n("Import!"), i18n("Cancel"), 0,
1248 0, 1 ); 1251 0, 1 );
1249 if ( result == 0 ) { 1252 if ( result == 0 ) {
1250 mView->importBday(); 1253 mView->importBday();
1251 1254
1252 } 1255 }
1253 1256
1254 1257
1255} 1258}
1256void MainWindow::importQtopia() 1259void MainWindow::importQtopia()
1257{ 1260{
1258#ifndef DESKTOP_VERSION 1261#ifndef DESKTOP_VERSION
1259 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1262 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1260 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"), 1263 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"),
1261 i18n("Import!"), i18n("Cancel"), 0, 1264 i18n("Import!"), i18n("Cancel"), 0,
1262 0, 1 ); 1265 0, 1 );
1263 if ( result == 0 ) { 1266 if ( result == 0 ) {
1264 QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); 1267 QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
1265 QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); 1268 QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
1266 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; 1269 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
1267 mView->importQtopia( categories, datebook, todolist ); 1270 mView->importQtopia( categories, datebook, todolist );
1268 } 1271 }
1269#else 1272#else
1270 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1273 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1271 i18n("Not supported \non desktop!\n"), 1274 i18n("Not supported \non desktop!\n"),
1272 i18n("Ok"), i18n("Cancel"), 0, 1275 i18n("Ok"), i18n("Cancel"), 0,
1273 0, 1 ); 1276 0, 1 );
1274 1277
1275#endif 1278#endif
1276} 1279}
1277 1280
1278void MainWindow::saveOnClose() 1281void MainWindow::saveOnClose()
1279{ 1282{
1280 KOPrefs *p = KOPrefs::instance(); 1283 KOPrefs *p = KOPrefs::instance();
1281 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); 1284 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
1282 p->mToolBarUp = iconToolBar->x() > width()/2 || 1285 p->mToolBarUp = iconToolBar->x() > width()/2 ||
1283 iconToolBar->y() > height()/2; 1286 iconToolBar->y() > height()/2;
1284 mView->writeSettings(); 1287 mView->writeSettings();
1285 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) 1288 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName()))
1286 save(); 1289 save();
1287} 1290}
1288void MainWindow::slotModifiedChanged( bool changed ) 1291void MainWindow::slotModifiedChanged( bool changed )
1289{ 1292{
1290 if ( mBlockAtStartup ) 1293 if ( mBlockAtStartup )
1291 return; 1294 return;
1292 int msec; 1295 int msec;
1293 // we store the changes after 1 minute, 1296 // we store the changes after 1 minute,
1294 // and for safety reasons after 10 minutes again 1297 // and for safety reasons after 10 minutes again
1295 if ( !mBlockSaveFlag ) 1298 if ( !mBlockSaveFlag )
1296 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1299 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1297 else 1300 else
1298 msec = 1000 * 600; 1301 msec = 1000 * 600;
1299 mSaveTimer.start( msec, true ); // 1 minute 1302 mSaveTimer.start( msec, true ); // 1 minute
1300 qDebug("KO: Saving File in %d secs!", msec/1000); 1303 qDebug("KO: Saving File in %d secs!", msec/1000);
1301 mCalendarModifiedFlag = true; 1304 mCalendarModifiedFlag = true;
1302} 1305}
1303#include <qfileinfo.h> 1306#include <qfileinfo.h>
1304void MainWindow::save() 1307void MainWindow::save()
1305{ 1308{
1306 if ( mBlockSaveFlag ) 1309 if ( mBlockSaveFlag )
1307 return; 1310 return;
1308 bool store = mBlockSaveFlag; 1311 bool store = mBlockSaveFlag;
1309 mBlockSaveFlag = true; 1312 mBlockSaveFlag = true;
1310 if ( mView->checkFileVersion( defaultFileName()) ) { 1313 if ( mView->checkFileVersion( defaultFileName()) ) {
1311 1314
1312 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1315 QTime neededSaveTime = QDateTime::currentDateTime().time();
1313 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1316 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1314 qDebug("KO: Start saving data to file!"); 1317 qDebug("KO: Start saving data to file!");
1315 mView->saveCalendar( defaultFileName() ); 1318 mView->saveCalendar( defaultFileName() );
1316 1319
1317 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 1320 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1318 mView->setLoadedFileVersion(QDateTime::currentDateTime()); 1321 mView->setLoadedFileVersion(QDateTime::currentDateTime());
1319 qDebug("KO: Needed %d ms for saving.",msNeeded ); 1322 qDebug("KO: Needed %d ms for saving.",msNeeded );
1320 QString savemes; 1323 QString savemes;
1321 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 1324 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
1322 setCaption(savemes); 1325 setCaption(savemes);
1323 } else 1326 } else
1324 setCaption(i18n("Saving cancelled!")); 1327 setCaption(i18n("Saving cancelled!"));
1325 mCalendarModifiedFlag = false; 1328 mCalendarModifiedFlag = false;
1326 mBlockSaveFlag = store; 1329 mBlockSaveFlag = store;
1327} 1330}
1328 1331
1329void MainWindow::keyReleaseEvent ( QKeyEvent * e) 1332void MainWindow::keyReleaseEvent ( QKeyEvent * e)
1330{ 1333{
1331 if ( !e->isAutoRepeat() ) { 1334 if ( !e->isAutoRepeat() ) {
1332 mFlagKeyPressed = false; 1335 mFlagKeyPressed = false;
1333 } 1336 }
1334} 1337}
1335void MainWindow::keyPressEvent ( QKeyEvent * e ) 1338void MainWindow::keyPressEvent ( QKeyEvent * e )
1336{ 1339{
1337 qApp->processEvents(); 1340 qApp->processEvents();
1338 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 1341 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1339 e->ignore(); 1342 e->ignore();
1340 // qDebug(" ignore %d",e->isAutoRepeat() ); 1343 // qDebug(" ignore %d",e->isAutoRepeat() );
1341 return; 1344 return;
1342 } 1345 }
1343 if (! e->isAutoRepeat() ) 1346 if (! e->isAutoRepeat() )
1344 mFlagKeyPressed = true; 1347 mFlagKeyPressed = true;
1345 KOPrefs *p = KOPrefs::instance(); 1348 KOPrefs *p = KOPrefs::instance();
1346 bool showSelectedDates = false; 1349 bool showSelectedDates = false;
1347 int size; 1350 int size;
1348 int pro = 0; 1351 int pro = 0;
1349 //qDebug("MainWindow::keyPressEvent "); 1352 //qDebug("MainWindow::keyPressEvent ");
1350 switch ( e->key() ) { 1353 switch ( e->key() ) {
1351 case Qt::Key_Right: 1354 case Qt::Key_Right:
1352 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1355 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1353 mView->goNextMonth(); 1356 mView->goNextMonth();
1354 else 1357 else
1355 mView->goNext(); 1358 mView->goNext();
1356 showSelectedDates = true; 1359 showSelectedDates = true;
1357 break; 1360 break;
1358 case Qt::Key_Left: 1361 case Qt::Key_Left:
1359 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1362 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1360 mView->goPreviousMonth(); 1363 mView->goPreviousMonth();
1361 else 1364 else
1362 mView->goPrevious(); 1365 mView->goPrevious();
1363 showSelectedDates = true; 1366 showSelectedDates = true;
1364 break; 1367 break;
1365 case Qt::Key_Down: 1368 case Qt::Key_Down:
1366 mView->viewManager()->agendaView()->scrollOneHourDown(); 1369 mView->viewManager()->agendaView()->scrollOneHourDown();
1367 break; 1370 break;
1368 case Qt::Key_Up: 1371 case Qt::Key_Up:
1369 mView->viewManager()->agendaView()->scrollOneHourUp(); 1372 mView->viewManager()->agendaView()->scrollOneHourUp();
1370 break; 1373 break;
1371 case Qt::Key_I: 1374 case Qt::Key_I:
1372 mView->showIncidence(); 1375 mView->showIncidence();
1373 break; 1376 break;
1374 case Qt::Key_Delete: 1377 case Qt::Key_Delete:
1375 case Qt::Key_Backspace: 1378 case Qt::Key_Backspace:
1376 mView->deleteIncidence(); 1379 mView->deleteIncidence();
1377 break; 1380 break;
1378 case Qt::Key_D: 1381 case Qt::Key_D:
1379 mView->viewManager()->showDayView(); 1382 mView->viewManager()->showDayView();
1380 showSelectedDates = true; 1383 showSelectedDates = true;
1381 break; 1384 break;
1382 case Qt::Key_O: 1385 case Qt::Key_O:
1383 mView->toggleFilerEnabled( ); 1386 mView->toggleFilerEnabled( );
1384 break; 1387 break;
1385 case Qt::Key_0: 1388 case Qt::Key_0:
1386 case Qt::Key_1: 1389 case Qt::Key_1:
1387 case Qt::Key_2: 1390 case Qt::Key_2:
1388 case Qt::Key_3: 1391 case Qt::Key_3:
1389 case Qt::Key_4: 1392 case Qt::Key_4:
1390 case Qt::Key_5: 1393 case Qt::Key_5:
1391 case Qt::Key_6: 1394 case Qt::Key_6:
1392 case Qt::Key_7: 1395 case Qt::Key_7:
1393 case Qt::Key_8: 1396 case Qt::Key_8:
1394 case Qt::Key_9: 1397 case Qt::Key_9:
1395 pro = e->key()-48; 1398 pro = e->key()-48;
1396 if ( pro == 0 ) 1399 if ( pro == 0 )
1397 pro = 10; 1400 pro = 10;
1398 if ( e->state() == Qt::ControlButton) 1401 if ( e->state() == Qt::ControlButton)
1399 pro += 10; 1402 pro += 10;
1400 break; 1403 break;
1401 case Qt::Key_M: 1404 case Qt::Key_M:
1402 mView->viewManager()->showMonthView(); 1405 mView->viewManager()->showMonthView();
1403 showSelectedDates = true; 1406 showSelectedDates = true;
1404 break; 1407 break;
1405 case Qt::Key_Insert: 1408 case Qt::Key_Insert:
1406 mView->newEvent(); 1409 mView->newEvent();
1407 break; 1410 break;
1408 case Qt::Key_S : 1411 case Qt::Key_S :
1409 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1412 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1410 mView->newSubTodo(); 1413 mView->newSubTodo();
1411 else 1414 else
1412 mView->dialogManager()->showSearchDialog(); 1415 mView->dialogManager()->showSearchDialog();
1413 break; 1416 break;
1414 case Qt::Key_Y : 1417 case Qt::Key_Y :
1415 case Qt::Key_Z : 1418 case Qt::Key_Z :
1416 mView->viewManager()->showWorkWeekView(); 1419 mView->viewManager()->showWorkWeekView();
1417 showSelectedDates = true; 1420 showSelectedDates = true;
1418 break; 1421 break;
1419 case Qt::Key_U : 1422 case Qt::Key_U :
1420 mView->viewManager()->showWeekView(); 1423 mView->viewManager()->showWeekView();
1421 showSelectedDates = true; 1424 showSelectedDates = true;
1422 break; 1425 break;
1423 case Qt::Key_H : 1426 case Qt::Key_H :
1424 keyBindings(); 1427 keyBindings();
1425 break; 1428 break;
1426 case Qt::Key_W: 1429 case Qt::Key_W:
1427 mView->viewManager()->showWhatsNextView(); 1430 mView->viewManager()->showWhatsNextView();
1428 break; 1431 break;
1429 case Qt::Key_L: 1432 case Qt::Key_L:
1430 mView->viewManager()->showListView(); 1433 mView->viewManager()->showListView();
1431 break; 1434 break;
1432 case Qt::Key_N: 1435 case Qt::Key_N:
1433 mView->viewManager()->showNextXView(); 1436 mView->viewManager()->showNextXView();
1434 showSelectedDates = true; 1437 showSelectedDates = true;
1435 break; 1438 break;
1436 case Qt::Key_V: 1439 case Qt::Key_V:
1437 mView->viewManager()->showTodoView(); 1440 mView->viewManager()->showTodoView();
1438 break; 1441 break;
1439 case Qt::Key_C: 1442 case Qt::Key_C:
1440 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); 1443 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() );
1441 break; 1444 break;
1442 case Qt::Key_P: 1445 case Qt::Key_P:
1443 mView->showDatePicker( ); 1446 mView->showDatePicker( );
1444 break; 1447 break;
1445 case Qt::Key_F: 1448 case Qt::Key_F:
1446 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1449 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1447 mView->editFilters(); 1450 mView->editFilters();
1448 else 1451 else
1449 mView->toggleFilter(); 1452 mView->toggleFilter();
1450 break; 1453 break;
1451 case Qt::Key_X: 1454 case Qt::Key_X:
1452 mView->toggleDateNavigatorWidget(); 1455 mView->toggleDateNavigatorWidget();
1453 break; 1456 break;
1454 case Qt::Key_Space: 1457 case Qt::Key_Space:
1455 mView->toggleExpand(); 1458 mView->toggleExpand();
1456 break; 1459 break;
1457 case Qt::Key_A: 1460 case Qt::Key_A:
1458 mView->toggleAllDaySize(); 1461 mView->toggleAllDaySize();
1459 break; 1462 break;
1460 case Qt::Key_T: 1463 case Qt::Key_T:
1461 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1464 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1462 mView->newTodo(); 1465 mView->newTodo();
1463 else { 1466 else {
1464 mView->goToday(); 1467 mView->goToday();
1465 showSelectedDates = true; 1468 showSelectedDates = true;
1466 } 1469 }
1467 break; 1470 break;
1468 case Qt::Key_J: 1471 case Qt::Key_J:
1469 mView->viewManager()->showJournalView(); 1472 mView->viewManager()->showJournalView();
1470 break; 1473 break;
1471 case Qt::Key_B: 1474 case Qt::Key_B:
1472 mView->editIncidenceDescription();; 1475 mView->editIncidenceDescription();;
1473 break; 1476 break;
1474 // case Qt::Key_Return: 1477 // case Qt::Key_Return:
1475 case Qt::Key_E: 1478 case Qt::Key_E:
1476 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1479 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1477 mView->newEvent(); 1480 mView->newEvent();
1478 else 1481 else
1479 mView->editIncidence(); 1482 mView->editIncidence();
1480 break; 1483 break;
1481 case Qt::Key_Plus: 1484 case Qt::Key_Plus:
1482 size = p->mHourSize +2; 1485 size = p->mHourSize +2;
1483 if ( size <= 18 ) 1486 if ( size <= 18 )
1484 configureAgenda( size ); 1487 configureAgenda( size );
1485 break; 1488 break;
1486 case Qt::Key_Minus: 1489 case Qt::Key_Minus:
1487 size = p->mHourSize - 2; 1490 size = p->mHourSize - 2;
1488 if ( size >= 4 ) 1491 if ( size >= 4 )
1489 configureAgenda( size ); 1492 configureAgenda( size );
1490 break; 1493 break;
1491 1494
1492 1495
1493 default: 1496 default:
1494 e->ignore(); 1497 e->ignore();
1495 } 1498 }
1496 if ( pro > 0 ) { 1499 if ( pro > 0 ) {
1497 mView->selectFilter( pro-1 ); 1500 mView->selectFilter( pro-1 );
1498 } 1501 }
1499 if ( showSelectedDates ) { 1502 if ( showSelectedDates ) {
1500 ;// setCaptionToDates(); 1503 ;// setCaptionToDates();
1501 } 1504 }
1502 1505
1503} 1506}
1504 1507
1505void MainWindow::configureToolBar( int item ) 1508void MainWindow::configureToolBar( int item )
1506{ 1509{
1507 1510
1508 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); 1511 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) );
1509 KOPrefs *p = KOPrefs::instance(); 1512 KOPrefs *p = KOPrefs::instance();
1510 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); 1513 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 );
1511 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); 1514 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 );
1512 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); 1515 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 );
1513 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); 1516 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 );
1514 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); 1517 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 );
1515 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); 1518 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 );
1516 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); 1519 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 );
1517 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); 1520 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 );
1518 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); 1521 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 );
1519 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); 1522 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 );
1520 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); 1523 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 );
1521 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); 1524 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 );
1522 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); 1525 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 );
1523 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); 1526 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 );
1524 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); 1527 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 );
1525 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); 1528 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 );
1526 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); 1529 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 );
1527 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); 1530 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 );
1528 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); 1531 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 );
1529 // initActions(); 1532 // initActions();
1530} 1533}
1531 1534
1532void MainWindow::setCaptionToDates() 1535void MainWindow::setCaptionToDates()
1533{ 1536{
1534 QString selDates; 1537 QString selDates;
1535 selDates = KGlobal::locale()->formatDate(mView->startDate(), true); 1538 selDates = KGlobal::locale()->formatDate(mView->startDate(), true);
1536 if (mView->startDate() < mView->endDate() ) 1539 if (mView->startDate() < mView->endDate() )
1537 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); 1540 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true);
1538 setCaption( i18n("Dates: ") + selDates ); 1541 setCaption( i18n("Dates: ") + selDates );
1539 1542
1540} 1543}
1541// parameter item == 0: reinit 1544// parameter item == 0: reinit
1542void MainWindow::configureAgenda( int item ) 1545void MainWindow::configureAgenda( int item )
1543{ 1546{
1544 1547
1545 KOPrefs *p = KOPrefs::instance(); 1548 KOPrefs *p = KOPrefs::instance();
1546 1549
1547 int i; 1550 int i;
1548 if ( item == 1 ) { 1551 if ( item == 1 ) {
1549 mView->toggleAllDaySize(); 1552 mView->toggleAllDaySize();
1550 return; 1553 return;
1551 } 1554 }
1552 // do not allow 4 for widgets higher than 480 1555 // do not allow 4 for widgets higher than 480
1553 // if ( QApplication::desktop()->height() > 480 ) { 1556 // if ( QApplication::desktop()->height() > 480 ) {
1554// if ( item == 4 ) 1557// if ( item == 4 )
1555// item = 6; 1558// item = 6;
1556// } 1559// }
1557 for ( i = 4; i <= 18; i= i+2 ) 1560 for ( i = 4; i <= 18; i= i+2 )
1558 configureAgendaMenu->setItemChecked( i, false ); 1561 configureAgendaMenu->setItemChecked( i, false );
1559 configureAgendaMenu->setItemChecked( item, true ); 1562 configureAgendaMenu->setItemChecked( item, true );
1560 if ( p->mHourSize == item ) 1563 if ( p->mHourSize == item )
1561 return; 1564 return;
1562 p->mHourSize=item; 1565 p->mHourSize=item;
1563 mView->viewManager()->agendaView()->updateConfig(); 1566 mView->viewManager()->agendaView()->updateConfig();
1564} 1567}
1565 1568
1566void MainWindow::saveCalendar() 1569void MainWindow::saveCalendar()
1567{ 1570{
1568 QString fn = KOPrefs::instance()->mLastSaveFile; 1571 QString fn = KOPrefs::instance()->mLastSaveFile;
1569 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); 1572 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this );
1570 1573
1571 if ( fn == "" ) 1574 if ( fn == "" )
1572 return; 1575 return;
1573 QFileInfo info; 1576 QFileInfo info;
1574 info.setFile( fn ); 1577 info.setFile( fn );
1575 QString mes; 1578 QString mes;
1576 bool createbup = true; 1579 bool createbup = true;
1577 if ( info. exists() ) { 1580 if ( info. exists() ) {
1578 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; 1581 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ;
1579 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1582 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1580 i18n("Overwrite!"), i18n("Cancel"), 0, 1583 i18n("Overwrite!"), i18n("Cancel"), 0,
1581 0, 1 ); 1584 0, 1 );
1582 if ( result != 0 ) { 1585 if ( result != 0 ) {
1583 createbup = false; 1586 createbup = false;
1584 } 1587 }
1585 } 1588 }
1586 if ( createbup ) { 1589 if ( createbup ) {
1587 mView->saveCalendar( fn ); 1590 mView->saveCalendar( fn );
1588 mes = i18n("KO/Pi:Saved %1").arg(fn); 1591 mes = i18n("KO/Pi:Saved %1").arg(fn);
1589 KOPrefs::instance()->mLastSaveFile = fn; 1592 KOPrefs::instance()->mLastSaveFile = fn;
1590 setCaption(mes); 1593 setCaption(mes);
1591 } 1594 }
1592} 1595}
1593void MainWindow::loadCalendar() 1596void MainWindow::loadCalendar()
1594{ 1597{
1595 1598
1596 QString fn = KOPrefs::instance()->mLastLoadFile; 1599 QString fn = KOPrefs::instance()->mLastLoadFile;
1597 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); 1600 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this );
1598 1601
1599 if ( fn == "" ) 1602 if ( fn == "" )
1600 return; 1603 return;
1601 QFileInfo info; 1604 QFileInfo info;
1602 info.setFile( fn ); 1605 info.setFile( fn );
1603 QString mess; 1606 QString mess;
1604 bool loadbup = true; 1607 bool loadbup = true;
1605 if ( info. exists() ) { 1608 if ( info. exists() ) {
1606 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1609 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1607 int result = QMessageBox::warning( this, "KO/Pi: Warning!", 1610 int result = QMessageBox::warning( this, "KO/Pi: Warning!",
1608 mess, 1611 mess,
1609 i18n("Load!"), i18n("Cancel"), 0, 1612 i18n("Load!"), i18n("Cancel"), 0,
1610 0, 1 ); 1613 0, 1 );
1611 if ( result != 0 ) { 1614 if ( result != 0 ) {
1612 loadbup = false; 1615 loadbup = false;
1613 } 1616 }
1614 } else { 1617 } else {
1615 QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1618 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1616 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, 1619 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0,
1617 0, 1 ); 1620 0, 1 );
1618 1621
1619 return; 1622 return;
1620 } 1623 }
1621 if ( loadbup ) { 1624 if ( loadbup ) {
1622 mView->openCalendar( fn ); 1625 mView->openCalendar( fn );
1623 KOPrefs::instance()->mLastLoadFile = fn; 1626 KOPrefs::instance()->mLastLoadFile = fn;
1624 mess = i18n("KO/Pi:Loaded %1").arg(fn) ; 1627 mess = i18n("KO/Pi:Loaded %1").arg(fn) ;
1625 setCaption(mess); 1628 setCaption(mess);
1626 } 1629 }
1627 1630
1628} 1631}
1629void MainWindow::quickImportIcal() 1632void MainWindow::quickImportIcal()
1630{ 1633{
1631 importFile( KOPrefs::instance()->mLastImportFile, false ); 1634 importFile( KOPrefs::instance()->mLastImportFile, false );
1632} 1635}
1633void MainWindow::importFile( QString fn, bool quick ) 1636void MainWindow::importFile( QString fn, bool quick )
1634{ 1637{
1635 QFileInfo info; 1638 QFileInfo info;
1636 info.setFile( fn ); 1639 info.setFile( fn );
1637 QString mess; 1640 QString mess;
1638 bool loadbup = true; 1641 bool loadbup = true;
1639 if ( !info. exists() ) { 1642 if ( !info. exists() ) {
1640 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); 1643 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30));
1641 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1644 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1642 mess ); 1645 mess );
1643 return; 1646 return;
1644 } 1647 }
1645 int result = 0; 1648 int result = 0;
1646 if ( !quick ) { 1649 if ( !quick ) {
1647 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 )); 1650 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 ));
1648 result = QMessageBox::warning( this, "KO/Pi: Warning!", 1651 result = QMessageBox::warning( this, "KO/Pi: Warning!",
1649 mess, 1652 mess,
1650 "Import", "Cancel", 0, 1653 "Import", "Cancel", 0,
1651 0, 1 ); 1654 0, 1 );
1652 } 1655 }
1653 if ( result == 0 ) { 1656 if ( result == 0 ) {
1654 if ( mView->openCalendar( fn, true )) { 1657 if ( mView->openCalendar( fn, true )) {
1655 KOPrefs::instance()->mLastImportFile = fn; 1658 KOPrefs::instance()->mLastImportFile = fn;
1656 setCaption(i18n("Imported file successfully")); 1659 setCaption(i18n("Imported file successfully"));
1657 } else { 1660 } else {
1658 setCaption(i18n("Error importing file")); 1661 setCaption(i18n("Error importing file"));
1659 } 1662 }
1660 } 1663 }
1661} 1664}
1662 1665
1663void MainWindow::importIcal() 1666void MainWindow::importIcal()
1664{ 1667{
1665 1668
1666 QString fn =KOPrefs::instance()->mLastImportFile; 1669 QString fn =KOPrefs::instance()->mLastImportFile;
1667 1670
1668 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); 1671 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this );
1669 if ( fn == "" ) 1672 if ( fn == "" )
1670 return; 1673 return;
1671 importFile( fn, true ); 1674 importFile( fn, true );
1672 1675
1673} 1676}
1674 1677
1675void MainWindow::exportVCalendar() 1678void MainWindow::exportVCalendar()
1676{ 1679{
1677 QString fn = KOPrefs::instance()->mLastVcalFile; 1680 QString fn = KOPrefs::instance()->mLastVcalFile;
1678 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); 1681 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this );
1679 if ( fn == "" ) 1682 if ( fn == "" )
1680 return; 1683 return;
1681 QFileInfo info; 1684 QFileInfo info;
1682 info.setFile( fn ); 1685 info.setFile( fn );
1683 QString mes; 1686 QString mes;
1684 bool createbup = true; 1687 bool createbup = true;
1685 if ( info. exists() ) { 1688 if ( info. exists() ) {
1686 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 1689 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
1687 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1690 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1688 i18n("Overwrite!"), i18n("Cancel"), 0, 1691 i18n("Overwrite!"), i18n("Cancel"), 0,
1689 0, 1 ); 1692 0, 1 );
1690 if ( result != 0 ) { 1693 if ( result != 0 ) {
1691 createbup = false; 1694 createbup = false;
1692 } 1695 }
1693 } 1696 }
1694 if ( createbup ) { 1697 if ( createbup ) {
1695 if ( mView->exportVCalendar( fn ) ) { 1698 if ( mView->exportVCalendar( fn ) ) {
1696 KOPrefs::instance()->mLastVcalFile = fn; 1699 KOPrefs::instance()->mLastVcalFile = fn;
1697 if ( fn.length() > 20 ) 1700 if ( fn.length() > 20 )
1698 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; 1701 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ;
1699 else 1702 else
1700 mes = i18n("KO/Pi:Exported to %1").arg(fn ); 1703 mes = i18n("KO/Pi:Exported to %1").arg(fn );
1701 setCaption(mes); 1704 setCaption(mes);
1702 } 1705 }
1703 } 1706 }
1704 1707
1705} 1708}
1706#include <qpushbutton.h> 1709#include <qpushbutton.h>
1707QString MainWindow::getPassword( ) 1710QString MainWindow::getPassword( )
1708{ 1711{
1709 QString retfile = ""; 1712 QString retfile = "";
1710 QDialog dia ( this, "input-dialog", true ); 1713 QDialog dia ( this, "input-dialog", true );
1711 QLineEdit lab ( &dia ); 1714 QLineEdit lab ( &dia );
1712 lab.setEchoMode( QLineEdit::Password ); 1715 lab.setEchoMode( QLineEdit::Password );
1713 QVBoxLayout lay( &dia ); 1716 QVBoxLayout lay( &dia );
1714 lay.setMargin(7); 1717 lay.setMargin(7);
1715 lay.setSpacing(7); 1718 lay.setSpacing(7);
1716 lay.addWidget( &lab); 1719 lay.addWidget( &lab);
1717 dia.setFixedSize( 230,50 ); 1720 dia.setFixedSize( 230,50 );
1718 dia.setCaption( i18n("Enter password") ); 1721 dia.setCaption( i18n("Enter password") );
1719 QPushButton pb ( "OK", &dia); 1722 QPushButton pb ( "OK", &dia);
1720 lay.addWidget( &pb ); 1723 lay.addWidget( &pb );
1721 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 1724 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
1722 dia.show(); 1725 dia.show();
1723 int res = dia.exec(); 1726 int res = dia.exec();
1724 if ( res ) 1727 if ( res )
1725 retfile = lab.text(); 1728 retfile = lab.text();
1726 dia.hide(); 1729 dia.hide();
1727 qApp->processEvents(); 1730 qApp->processEvents();
1728 return retfile; 1731 return retfile;
1729 1732
1730} 1733}
1731 1734
1732void MainWindow::syncLocalFile() 1735void MainWindow::syncLocalFile()
1733{ 1736{
1734 1737
1735 QString fn =KOPrefs::instance()->mLastSyncedLocalFile; 1738 QString fn =KOPrefs::instance()->mLastSyncedLocalFile;
1736 1739
1737 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); 1740 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this );
1738 if ( fn == "" ) 1741 if ( fn == "" )
1739 return; 1742 return;
1740 //mView->setSyncDevice("local-file" ); 1743 //mView->setSyncDevice("local-file" );
1741 if ( syncWithFile( fn, false ) ) { 1744 if ( syncWithFile( fn, false ) ) {
1742 // Event* e = mView->getLastSyncEvent(); 1745 // Event* e = mView->getLastSyncEvent();
1743// e->setReadOnly( false ); 1746// e->setReadOnly( false );
1744// e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); 1747// e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile);
1745// e->setReadOnly( true ); 1748// e->setReadOnly( true );
1746 } 1749 }
1747 1750
1748} 1751}
1749 1752
1750bool MainWindow::syncWithFile( QString fn , bool quick ) 1753bool MainWindow::syncWithFile( QString fn , bool quick )
1751{ 1754{
1752 bool ret = false; 1755 bool ret = false;
1753 QFileInfo info; 1756 QFileInfo info;
1754 info.setFile( fn ); 1757 info.setFile( fn );
1755 QString mess; 1758 QString mess;
1756 bool loadbup = true; 1759 bool loadbup = true;
1757 if ( !info. exists() ) { 1760 if ( !info. exists() ) {
1758 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 1761 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
1759 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1762 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1760 mess ); 1763 mess );
1761 return ret; 1764 return ret;
1762 } 1765 }
1763 int result = 0; 1766 int result = 0;
1764 if ( !quick ) { 1767 if ( !quick ) {
1765 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1768 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1766 result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1769 result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1767 mess, 1770 mess,
1768 i18n("Sync"), i18n("Cancel"), 0, 1771 i18n("Sync"), i18n("Cancel"), 0,
1769 0, 1 ); 1772 0, 1 );
1770 if ( result ) 1773 if ( result )
1771 return false; 1774 return false;
1772 } 1775 }
1773 if ( KOPrefs::instance()->mAskForPreferences ) 1776 if ( KOPrefs::instance()->mAskForPreferences )
1774 mView->edit_sync_options(); 1777 mView->edit_sync_options();
1775 if ( result == 0 ) { 1778 if ( result == 0 ) {
1776 //qDebug("Now sycing ... "); 1779 //qDebug("Now sycing ... ");
1777 if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) ) 1780 if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) )
1778 setCaption( i18n("Synchronization successful") ); 1781 setCaption( i18n("Synchronization successful") );
1779 else 1782 else
1780 setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); 1783 setCaption( i18n("Sync cancelled or failed. Nothing synced.") );
1781 if ( ! quick ) 1784 if ( ! quick )
1782 KOPrefs::instance()->mLastSyncedLocalFile = fn; 1785 KOPrefs::instance()->mLastSyncedLocalFile = fn;
1783 slotModifiedChanged( true ); 1786 slotModifiedChanged( true );
1784 } 1787 }
1785 return ret; 1788 return ret;
1786} 1789}
1787void MainWindow::quickSyncLocalFile() 1790void MainWindow::quickSyncLocalFile()
1788{ 1791{
1789 //mView->setSyncDevice("local-file" ); 1792 //mView->setSyncDevice("local-file" );
1790 //qDebug("quickSyncLocalFile() "); 1793 //qDebug("quickSyncLocalFile() ");
1791 if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) { 1794 if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) {
1792 // Event* e = mView->getLastSyncEvent(); 1795 // Event* e = mView->getLastSyncEvent();
1793// e->setReadOnly( false ); 1796// e->setReadOnly( false );
1794// e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); 1797// e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile);
1795// e->setReadOnly( true ); 1798// e->setReadOnly( true );
1796 1799
1797 } 1800 }
1798} 1801}
1799 1802
1800void MainWindow::confSync() 1803void MainWindow::confSync()
1801{ 1804{
1802 mView->confSync(); 1805 mView->confSync();
1803 fillSyncMenu(); 1806 fillSyncMenu();
1804 //mView->writeSettings(); 1807 //mView->writeSettings();
1805 1808
1806 1809
1807} 1810}
1808void MainWindow::syncRemote( KSyncProfile* prof, bool ask) 1811void MainWindow::syncRemote( KSyncProfile* prof, bool ask)
1809{ 1812{
1810 QString question; 1813 QString question;
1811 if ( ask ) { 1814 if ( ask ) {
1812 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; 1815 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
1813 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 1816 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
1814 question, 1817 question,
1815 i18n("Yes"), i18n("No"), 1818 i18n("Yes"), i18n("No"),
1816 0, 0 ) != 0 ) 1819 0, 0 ) != 0 )
1817 return; 1820 return;
1818 } 1821 }
1819 QString command = prof->getPreSyncCommand(); 1822 QString command = prof->getPreSyncCommand();
1820 int fi; 1823 int fi;
1821 if ( (fi = command.find("$PWD$")) > 0 ) { 1824 if ( (fi = command.find("$PWD$")) > 0 ) {
1822 QString pwd = getPassword(); 1825 QString pwd = getPassword();
1823 command = command.left( fi )+ pwd + command.mid( fi+5 ); 1826 command = command.left( fi )+ pwd + command.mid( fi+5 );
1824 1827
1825 } 1828 }
1826 int maxlen = 30; 1829 int maxlen = 30;
1827 if ( QApplication::desktop()->width() > 320 ) 1830 if ( QApplication::desktop()->width() > 320 )
1828 maxlen += 25; 1831 maxlen += 25;
1829 setCaption ( i18n( "Copy remote file to local machine..." ) ); 1832 setCaption ( i18n( "Copy remote file to local machine..." ) );
1830 int fileSize = 0; 1833 int fileSize = 0;
1831 int result = system ( command ); 1834 int result = system ( command );
1832 // 0 : okay 1835 // 0 : okay
1833 // 256: no such file or dir 1836 // 256: no such file or dir
1834 // 1837 //
1835 qDebug("KO: Remote copy result(0 = okay): %d ",result ); 1838 qDebug("KO: Remote copy result(0 = okay): %d ",result );
1836 if ( result != 0 ) { 1839 if ( result != 0 ) {
1837 int len = maxlen; 1840 int len = maxlen;
1838 while ( len < command.length() ) { 1841 while ( len < command.length() ) {
1839 command.insert( len , "\n" ); 1842 command.insert( len , "\n" );
1840 len += maxlen +2; 1843 len += maxlen +2;
1841 } 1844 }
1842 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) ; 1845 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) ;
1843 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), 1846 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
1844 question, 1847 question,
1845 i18n("Okay!")) ; 1848 i18n("Okay!")) ;
1846 setCaption ("KO/Pi"); 1849 setCaption ("KO/Pi");
1847 return; 1850 return;
1848 } 1851 }
1849 setCaption ( i18n( "Copying succeed." ) ); 1852 setCaption ( i18n( "Copying succeed." ) );
1850 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); 1853 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
1851 if ( syncWithFile( prof->getLocalTempFile(), true ) ) { 1854 if ( syncWithFile( prof->getLocalTempFile(), true ) ) {
1852// Event* e = mView->getLastSyncEvent(); 1855// Event* e = mView->getLastSyncEvent();
1853// e->setReadOnly( false ); 1856// e->setReadOnly( false );
1854// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 1857// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
1855// e->setReadOnly( true ); 1858// e->setReadOnly( true );
1856 if ( KOPrefs::instance()->mWriteBackFile ) { 1859 if ( KOPrefs::instance()->mWriteBackFile ) {
1857 command = prof->getPostSyncCommand(); 1860 command = prof->getPostSyncCommand();
1858 setCaption ( i18n( "Writing back file ..." ) ); 1861 setCaption ( i18n( "Writing back file ..." ) );
1859 result = system ( command ); 1862 result = system ( command );
1860 qDebug("KO: Writing back file result: %d ", result); 1863 qDebug("KO: Writing back file result: %d ", result);
1861 if ( result != 0 ) { 1864 if ( result != 0 ) {
1862 setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); 1865 setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
1863 return; 1866 return;
1864 } else { 1867 } else {
1865 setCaption ( i18n( "Syncronization sucessfully completed" ) ); 1868 setCaption ( i18n( "Syncronization sucessfully completed" ) );
1866 } 1869 }
1867 } 1870 }
1868 } 1871 }
1869 return; 1872 return;
1870} 1873}
1871void MainWindow::syncSSH() 1874void MainWindow::syncSSH()
1872{ 1875{
1873 // not used anymore 1876 // not used anymore
1874 QTime timer; 1877 QTime timer;
1875 timer.start(); 1878 timer.start();
1876 //qDebug("MainWindow::syncssh() "); 1879 //qDebug("MainWindow::syncssh() ");
1877 KOPrefs *p = KOPrefs::instance(); 1880 KOPrefs *p = KOPrefs::instance();
1878 QString localFile = p->mLocalTempFile; 1881 QString localFile = p->mLocalTempFile;
1879 QString remoteIP = p->mRemoteIP; 1882 QString remoteIP = p->mRemoteIP;
1880 QString remoteUser = p->mRemoteUser; 1883 QString remoteUser = p->mRemoteUser;
1881 QString remoteFile = p->mRemoteFile; 1884 QString remoteFile = p->mRemoteFile;
1882 if ( p->mUsePassWd && p->mRemotePassWd.length() > 0 ) 1885 if ( p->mUsePassWd && p->mRemotePassWd.length() > 0 )
1883 remoteUser += ":" + p->mRemotePassWd; 1886 remoteUser += ":" + p->mRemotePassWd;
1884 1887
1885 QString question = i18n("Do you really want\nto remote sync?\n \n") + 1888 QString question = i18n("Do you really want\nto remote sync?\n \n") +
1886 i18n("IP: " ) +remoteIP +"\n" + 1889 i18n("IP: " ) +remoteIP +"\n" +
1887 i18n("User: " ) + remoteUser +"\n" ; 1890 i18n("User: " ) + remoteUser +"\n" ;
1888 int maxlen = 30; 1891 int maxlen = 30;
1889 if ( QApplication::desktop()->width() > 320 ) 1892 if ( QApplication::desktop()->width() > 320 )
1890 maxlen += 25; 1893 maxlen += 25;
1891 if ( remoteFile.length() > maxlen ) 1894 if ( remoteFile.length() > maxlen )
1892 question += i18n("Remote file:\n..." ) + remoteFile.right(maxlen) +"\n"; 1895 question += i18n("Remote file:\n..." ) + remoteFile.right(maxlen) +"\n";
1893 else 1896 else
1894 question += i18n("Remote file:\n " ) + remoteFile +"\n"; 1897 question += i18n("Remote file:\n " ) + remoteFile +"\n";
1895 if ( localFile.length() > maxlen ) 1898 if ( localFile.length() > maxlen )
1896 question += i18n("Local temp file:\n..." ) + localFile.right(maxlen) +"\n"; 1899 question += i18n("Local temp file:\n..." ) + localFile.right(maxlen) +"\n";
1897 else 1900 else
1898 question += i18n("Local temp file:\n " ) + localFile +"\n"; 1901 question += i18n("Local temp file:\n " ) + localFile +"\n";
1899 1902
1900 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 1903 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
1901 question, 1904 question,
1902 i18n("Yes"), i18n("No"), 1905 i18n("Yes"), i18n("No"),
1903 0, 0 ) != 0 ) 1906 0, 0 ) != 0 )
1904 return; 1907 return;
1905 // if ( !p->mUsePassWd ) { 1908 // if ( !p->mUsePassWd ) {
1906 // QString pass = getPassword(); 1909 // QString pass = getPassword();
1907 // if ( pass.length() > 0 ) 1910 // if ( pass.length() > 0 )
1908 // remoteUser += ":" + pass; 1911 // remoteUser += ":" + pass;
1909 // } 1912 // }
1910 QString command = "scp " + remoteUser + "@" + remoteIP +":" + remoteFile +" " +localFile; 1913 QString command = "scp " + remoteUser + "@" + remoteIP +":" + remoteFile +" " +localFile;
1911 setCaption ( i18n( "Copy remote file to local machine..." ) ); 1914 setCaption ( i18n( "Copy remote file to local machine..." ) );
1912 int fileSize = 0; 1915 int fileSize = 0;
1913 int result = system ( command ); 1916 int result = system ( command );
1914 // 0 : okay 1917 // 0 : okay
1915 // 256: no such file or dir 1918 // 256: no such file or dir
1916 // 1919 //
1917 qDebug("KO: Remote copy result(0 = okay): %d ",result ); 1920 qDebug("KO: Remote copy result(0 = okay): %d ",result );
1918 if ( result != 0 ) { 1921 if ( result != 0 ) {
1919 int len = maxlen; 1922 int len = maxlen;
1920 while ( len < command.length() ) { 1923 while ( len < command.length() ) {
1921 command.insert( len , "\n" ); 1924 command.insert( len , "\n" );
1922 len += maxlen +2; 1925 len += maxlen +2;
1923 } 1926 }
1924 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) ; 1927 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) ;
1925 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), 1928 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
1926 question, 1929 question,
1927 i18n("Okay!")) ; 1930 i18n("Okay!")) ;
1928 setCaption ("KO/Pi"); 1931 setCaption ("KO/Pi");
1929 return; 1932 return;
1930 } 1933 }
1931 1934
1932 1935
1933 setCaption ( i18n( "Copying succeed." ) ); 1936 setCaption ( i18n( "Copying succeed." ) );
1934 //mView->setSyncDevice("ssh-scp" ); 1937 //mView->setSyncDevice("ssh-scp" );
1935 if ( syncWithFile(localFile , true ) ) { 1938 if ( syncWithFile(localFile , true ) ) {
1936// Event* e = mView->getLastSyncEvent(); 1939// Event* e = mView->getLastSyncEvent();
1937// e->setReadOnly( false ); 1940// e->setReadOnly( false );
1938// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 1941// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
1939// e->setReadOnly( true ); 1942// e->setReadOnly( true );
1940 if ( KOPrefs::instance()->mWriteBackFile ) { 1943 if ( KOPrefs::instance()->mWriteBackFile ) {
1941 command = "scp " + localFile +" " +remoteUser + "@" + remoteIP +":" + remoteFile ; 1944 command = "scp " + localFile +" " +remoteUser + "@" + remoteIP +":" + remoteFile ;
1942 setCaption ( i18n( "Writing back file ..." ) ); 1945 setCaption ( i18n( "Writing back file ..." ) );
1943 result = system ( command ); 1946 result = system ( command );
1944 if ( result != 0 ) { 1947 if ( result != 0 ) {
1945 int len = maxlen; 1948 int len = maxlen;
1946 while ( len < command.length() ) { 1949 while ( len < command.length() ) {
1947 command.insert( len , "\n" ); 1950 command.insert( len , "\n" );
1948 len += maxlen +2; 1951 len += maxlen +2;
1949 } 1952 }
1950 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) ; 1953 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) ;
1951 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), 1954 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
1952 question, 1955 question,
1953 i18n("Okay!")) ; 1956 i18n("Okay!")) ;
1954 setCaption ("KO/Pi"); 1957 setCaption ("KO/Pi");
1955 return; 1958 return;
1956 } else { 1959 } else {
1957 setCaption ( i18n( "Syncronization sucessfully completed" ) ); 1960 setCaption ( i18n( "Syncronization sucessfully completed" ) );
1958 } 1961 }
1959 } 1962 }
1960 } 1963 }
1961 return; 1964 return;
1962#if 0 1965#if 0
1963 system ("scp zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics /home/polo/Applications/korganizer/z_sync.ics"); 1966 system ("scp zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics /home/polo/Applications/korganizer/z_sync.ics");
1964 while ( timer.elapsed() < 5000 ) 1967 while ( timer.elapsed() < 5000 )
1965 qApp->processEvents(); 1968 qApp->processEvents();
1966 1969
1967 qDebug("MainWindow::merging) "); 1970 qDebug("MainWindow::merging) ");
1968 mView->syncCalendar( "/home/polo/Applications/korganizer/z_sync.ics", 0 ); 1971 mView->syncCalendar( "/home/polo/Applications/korganizer/z_sync.ics", 0 );
1969 while ( mBlockSaveFlag ) 1972 while ( mBlockSaveFlag )
1970 qApp->processEvents(); 1973 qApp->processEvents();
1971 save(); 1974 save();
1972 system ("scp /home/polo/Applications/korganizer/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics"); 1975 system ("scp /home/polo/Applications/korganizer/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics");
1973#endif 1976#endif
1974 1977
1975} 1978}
1976 1979
1977 1980
1978void MainWindow::syncSharp() 1981void MainWindow::syncSharp()
1979{ 1982{
1980 if ( mCalendarModifiedFlag ) 1983 if ( mCalendarModifiedFlag )
1981 save(); 1984 save();
1982 mView->syncSharp(); 1985 mView->syncSharp();
1983 slotModifiedChanged( true ); 1986 slotModifiedChanged( true );
1984 1987
1985} 1988}
1986 1989
1987void MainWindow::printSel( ) 1990void MainWindow::printSel( )
1988{ 1991{
1989 mView->viewManager()->agendaView()->agenda()->printSelection(); 1992 mView->viewManager()->agendaView()->agenda()->printSelection();
1990} 1993}
1991 1994
1992void MainWindow::printCal() 1995void MainWindow::printCal()
1993{ 1996{
1994 mView->print();//mCp->showDialog(); 1997 mView->print();//mCp->showDialog();
1995} 1998}