summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp28
-rw-r--r--korganizer/calendarview.h2
-rw-r--r--korganizer/kosyncprefsdialog.cpp44
-rw-r--r--korganizer/kosyncprefsdialog.h4
-rw-r--r--korganizer/mainwindow.cpp21
5 files changed, 47 insertions, 52 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index b543eca..c75d10e 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,3503 +1,3481 @@
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 "kosyncprefsdialog.h" 61#include "kosyncprefsdialog.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 mSyncProfiles.setAutoDelete(true);
240 mCalPrinter = 0; 239 mCalPrinter = 0;
241 mFilters.setAutoDelete(true); 240 mFilters.setAutoDelete(true);
242 241
243 mCalendar->registerObserver( this ); 242 mCalendar->registerObserver( this );
244 // TODO: Make sure that view is updated, when calendar is changed. 243 // TODO: Make sure that view is updated, when calendar is changed.
245 244
246 mStorage = new FileStorage( mCalendar ); 245 mStorage = new FileStorage( mCalendar );
247 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 246 mNavigator = new DateNavigator( this, "datevav", mViewManager );
248 247
249 QBoxLayout *topLayout = (QBoxLayout*)layout(); 248 QBoxLayout *topLayout = (QBoxLayout*)layout();
250#ifndef KORG_NOSPLITTER 249#ifndef KORG_NOSPLITTER
251 // create the main layout frames. 250 // create the main layout frames.
252 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 251 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
253 topLayout->addWidget(mPanner); 252 topLayout->addWidget(mPanner);
254 253
255 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 254 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
256 "CalendarView::LeftFrame"); 255 "CalendarView::LeftFrame");
257 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 256 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
258 257
259 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, 258 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE,
260 "CalendarView::DateNavigator", QDate::currentDate() ); 259 "CalendarView::DateNavigator", QDate::currentDate() );
261 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 260 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
262 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 261 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
263 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 262 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
264 263
265#ifdef KORG_NORESOURCEVIEW 264#ifdef KORG_NORESOURCEVIEW
266 mResourceView = 0; 265 mResourceView = 0;
267#else 266#else
268 if ( mResourceManager ) { 267 if ( mResourceManager ) {
269 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 268 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
270 mResourceView->updateView(); 269 mResourceView->updateView();
271 connect( mResourceView, SIGNAL( resourcesChanged() ), 270 connect( mResourceView, SIGNAL( resourcesChanged() ),
272 SLOT( updateView() ) ); 271 SLOT( updateView() ) );
273 } else { 272 } else {
274 mResourceView = 0; 273 mResourceView = 0;
275 } 274 }
276#endif 275#endif
277 QWidget *rightBox = new QWidget( mPanner ); 276 QWidget *rightBox = new QWidget( mPanner );
278 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 277 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
279 278
280 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 279 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
281 rightLayout->addWidget( mNavigatorBar ); 280 rightLayout->addWidget( mNavigatorBar );
282 281
283 mRightFrame = new QWidgetStack( rightBox ); 282 mRightFrame = new QWidgetStack( rightBox );
284 rightLayout->addWidget( mRightFrame, 1 ); 283 rightLayout->addWidget( mRightFrame, 1 );
285 284
286 mLeftFrame = mLeftSplitter; 285 mLeftFrame = mLeftSplitter;
287#else 286#else
288 QWidget *mainBox = new QWidget( this ); 287 QWidget *mainBox = new QWidget( this );
289 QWidget *leftFrame = new QWidget( mainBox ); 288 QWidget *leftFrame = new QWidget( mainBox );
290 289
291 QBoxLayout * mainBoxLayout; 290 QBoxLayout * mainBoxLayout;
292 QBoxLayout * leftFrameLayout; 291 QBoxLayout * leftFrameLayout;
293 if ( KOPrefs::instance()->mVerticalScreen ) { 292 if ( KOPrefs::instance()->mVerticalScreen ) {
294 mainBoxLayout = new QVBoxLayout(mainBox); 293 mainBoxLayout = new QVBoxLayout(mainBox);
295 leftFrameLayout = new QHBoxLayout(leftFrame ); 294 leftFrameLayout = new QHBoxLayout(leftFrame );
296 } else { 295 } else {
297 mainBoxLayout = new QHBoxLayout(mainBox); 296 mainBoxLayout = new QHBoxLayout(mainBox);
298 leftFrameLayout = new QVBoxLayout(leftFrame ); 297 leftFrameLayout = new QVBoxLayout(leftFrame );
299 } 298 }
300 topLayout->addWidget( mainBox ); 299 topLayout->addWidget( mainBox );
301 mainBoxLayout->addWidget (leftFrame); 300 mainBoxLayout->addWidget (leftFrame);
302 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, 301 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE,
303 "CalendarView::DateNavigator", QDate::currentDate()); 302 "CalendarView::DateNavigator", QDate::currentDate());
304 // mDateNavigator->blockSignals( true ); 303 // mDateNavigator->blockSignals( true );
305 leftFrameLayout->addWidget( mDateNavigator ); 304 leftFrameLayout->addWidget( mDateNavigator );
306 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); 305 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView");
307 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolist"); 306 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolist");
308 307
309 if ( QApplication::desktop()->width() < 480 ) { 308 if ( QApplication::desktop()->width() < 480 ) {
310 leftFrameLayout->addWidget(mFilterView); 309 leftFrameLayout->addWidget(mFilterView);
311 leftFrameLayout->addWidget(mTodoList, 2 ); 310 leftFrameLayout->addWidget(mTodoList, 2 );
312 311
313 } else { 312 } else {
314 leftFrameLayout->addWidget(mTodoList,2 ); 313 leftFrameLayout->addWidget(mTodoList,2 );
315 leftFrameLayout->addWidget(mFilterView ); 314 leftFrameLayout->addWidget(mFilterView );
316 } 315 }
317 mFilterView->hide(); 316 mFilterView->hide();
318 QWidget *rightBox = new QWidget( mainBox ); 317 QWidget *rightBox = new QWidget( mainBox );
319 mainBoxLayout->addWidget ( rightBox, 10 ); 318 mainBoxLayout->addWidget ( rightBox, 10 );
320 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 319 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
321 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 320 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
322 mRightFrame = new QWidgetStack( rightBox ); 321 mRightFrame = new QWidgetStack( rightBox );
323 rightLayout->addWidget( mNavigatorBar ); 322 rightLayout->addWidget( mNavigatorBar );
324 rightLayout->addWidget( mRightFrame, 10 ); 323 rightLayout->addWidget( mRightFrame, 10 );
325 324
326 mLeftFrame = leftFrame; 325 mLeftFrame = leftFrame;
327 if ( KOPrefs::instance()->mVerticalScreen ) { 326 if ( KOPrefs::instance()->mVerticalScreen ) {
328 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 327 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
329 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 328 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
330 } else { 329 } else {
331 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 330 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
332 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 331 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
333 } 332 }
334 333
335 //qDebug("Calendarview Size %d %d ", width(), height()); 334 //qDebug("Calendarview Size %d %d ", width(), height());
336#endif 335#endif
337 336
338 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 337 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
339 SLOT( showDates( const KCal::DateList & ) ) ); 338 SLOT( showDates( const KCal::DateList & ) ) );
340 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 339 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
341 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 340 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
342 341
343 connect( mNavigatorBar, SIGNAL( goPrevYear() ), 342 connect( mNavigatorBar, SIGNAL( goPrevYear() ),
344 mNavigator, SLOT( selectPreviousYear() ) ); 343 mNavigator, SLOT( selectPreviousYear() ) );
345 connect( mNavigatorBar, SIGNAL( goNextYear() ), 344 connect( mNavigatorBar, SIGNAL( goNextYear() ),
346 mNavigator, SLOT( selectNextYear() ) ); 345 mNavigator, SLOT( selectNextYear() ) );
347 connect( mNavigatorBar, SIGNAL( goPrevMonth() ), 346 connect( mNavigatorBar, SIGNAL( goPrevMonth() ),
348 mNavigator, SLOT( selectPreviousMonth() ) ); 347 mNavigator, SLOT( selectPreviousMonth() ) );
349 connect( mNavigatorBar, SIGNAL( goNextMonth() ), 348 connect( mNavigatorBar, SIGNAL( goNextMonth() ),
350 mNavigator, SLOT( selectNextMonth() ) ); 349 mNavigator, SLOT( selectNextMonth() ) );
351 350
352 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 351 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
353 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); 352 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) );
354 353
355 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 354 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
356 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 355 mNavigator, SLOT( selectWeek( const QDate & ) ) );
357 356
358 connect( mDateNavigator, SIGNAL( goPrevYear() ), 357 connect( mDateNavigator, SIGNAL( goPrevYear() ),
359 mNavigator, SLOT( selectPreviousYear() ) ); 358 mNavigator, SLOT( selectPreviousYear() ) );
360 connect( mDateNavigator, SIGNAL( goNextYear() ), 359 connect( mDateNavigator, SIGNAL( goNextYear() ),
361 mNavigator, SLOT( selectNextYear() ) ); 360 mNavigator, SLOT( selectNextYear() ) );
362 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 361 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
363 mNavigator, SLOT( selectPreviousMonth() ) ); 362 mNavigator, SLOT( selectPreviousMonth() ) );
364 connect( mDateNavigator, SIGNAL( goNextMonth() ), 363 connect( mDateNavigator, SIGNAL( goNextMonth() ),
365 mNavigator, SLOT( selectNextMonth() ) ); 364 mNavigator, SLOT( selectNextMonth() ) );
366 365
367 connect( mDateNavigator, SIGNAL( goPrevious() ), 366 connect( mDateNavigator, SIGNAL( goPrevious() ),
368 mNavigator, SLOT( selectPrevious() ) ); 367 mNavigator, SLOT( selectPrevious() ) );
369 connect( mDateNavigator, SIGNAL( goNext() ), 368 connect( mDateNavigator, SIGNAL( goNext() ),
370 mNavigator, SLOT( selectNext() ) ); 369 mNavigator, SLOT( selectNext() ) );
371 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 370 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
372 mNavigator, SLOT( slotMonthSelect( int ) ) ); 371 mNavigator, SLOT( slotMonthSelect( int ) ) );
373 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), 372 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ),
374 mNavigator, SLOT( slotMonthSelect( int ) ) ); 373 mNavigator, SLOT( slotMonthSelect( int ) ) );
375 374
376 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 375 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
377 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 376 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
378 377
379 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), 378 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ),
380 SLOT( eventAdded( Event *) ) ); 379 SLOT( eventAdded( Event *) ) );
381 380
382 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 381 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
383 382
384 connect( this, SIGNAL( configChanged() ), 383 connect( this, SIGNAL( configChanged() ),
385 mDateNavigator, SLOT( updateConfig() ) ); 384 mDateNavigator, SLOT( updateConfig() ) );
386 385
387 connect( mTodoList, SIGNAL( newTodoSignal() ), 386 connect( mTodoList, SIGNAL( newTodoSignal() ),
388 SLOT( newTodo() ) ); 387 SLOT( newTodo() ) );
389 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 388 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
390 SLOT( newSubTodo( Todo * ) ) ); 389 SLOT( newSubTodo( Todo * ) ) );
391 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 390 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
392 SLOT( editTodo( Todo * ) ) ); 391 SLOT( editTodo( Todo * ) ) );
393 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 392 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
394 SLOT( showTodo( Todo *) ) ); 393 SLOT( showTodo( Todo *) ) );
395 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 394 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
396 SLOT( deleteTodo( Todo *) ) ); 395 SLOT( deleteTodo( Todo *) ) );
397 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 396 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
398 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 397 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
399 SLOT( purgeCompleted() ) ); 398 SLOT( purgeCompleted() ) );
400 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 399 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
401 SIGNAL( todoModified( Todo *, int ) ) ); 400 SIGNAL( todoModified( Todo *, int ) ) );
402 401
403 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 402 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
404 this, SLOT ( cloneIncidence( Incidence * ) ) ); 403 this, SLOT ( cloneIncidence( Incidence * ) ) );
405 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 404 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
406 this, SLOT (cancelIncidence( Incidence * ) ) ); 405 this, SLOT (cancelIncidence( Incidence * ) ) );
407 406
408 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 407 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
409 this, SLOT ( moveIncidence( Incidence * ) ) ); 408 this, SLOT ( moveIncidence( Incidence * ) ) );
410 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 409 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
411 this, SLOT ( beamIncidence( Incidence * ) ) ); 410 this, SLOT ( beamIncidence( Incidence * ) ) );
412 411
413 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 412 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
414 this, SLOT ( todo_unsub( Todo * ) ) ); 413 this, SLOT ( todo_unsub( Todo * ) ) );
415 414
416 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 415 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
417 SLOT( updateTodo( Todo *, int ) ) ); 416 SLOT( updateTodo( Todo *, int ) ) );
418 connect( this, SIGNAL( todoModified( Todo *, int )), this, 417 connect( this, SIGNAL( todoModified( Todo *, int )), this,
419 SLOT( changeTodoDisplay( Todo *, int ) ) ); 418 SLOT( changeTodoDisplay( Todo *, int ) ) );
420 419
421 420
422 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 421 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
423 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 422 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
424 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 & ) ) );
425 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 & ) ) );
426 425
427 426
428 427
429 428
430 429
431 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 430 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
432 SLOT(checkClipboard())); 431 SLOT(checkClipboard()));
433 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 432 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
434 SLOT( processTodoListSelection( Incidence * ) ) ); 433 SLOT( processTodoListSelection( Incidence * ) ) );
435 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 434 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
436 435
437 // kdDebug() << "CalendarView::CalendarView() done" << endl; 436 // kdDebug() << "CalendarView::CalendarView() done" << endl;
438 437
439 mDateFrame = new QVBox(0,0,WType_Popup); 438 mDateFrame = new QVBox(0,0,WType_Popup);
440 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 439 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
441 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 440 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
442 mDateFrame->setLineWidth(3); 441 mDateFrame->setLineWidth(3);
443 mDateFrame->hide(); 442 mDateFrame->hide();
444 mDateFrame->setCaption( i18n( "Pick a date to display")); 443 mDateFrame->setCaption( i18n( "Pick a date to display"));
445 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 444 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
446 445
447 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 446 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
448 447
449 mEventEditor = mDialogManager->getEventEditor(); 448 mEventEditor = mDialogManager->getEventEditor();
450 mTodoEditor = mDialogManager->getTodoEditor(); 449 mTodoEditor = mDialogManager->getTodoEditor();
451 450
452 mFlagEditDescription = false; 451 mFlagEditDescription = false;
453 452
454 mSuspendTimer = new QTimer( this ); 453 mSuspendTimer = new QTimer( this );
455 mAlarmTimer = new QTimer( this ); 454 mAlarmTimer = new QTimer( this );
456 mRecheckAlarmTimer = new QTimer( this ); 455 mRecheckAlarmTimer = new QTimer( this );
457 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 456 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
458 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 457 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
459 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 458 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
460 mAlarmDialog = new AlarmDialog( this ); 459 mAlarmDialog = new AlarmDialog( this );
461 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 & ) ) );
462 mAlarmDialog->setServerNotification( false ); 461 mAlarmDialog->setServerNotification( false );
463 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 462 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
464} 463}
465 464
466 465
467CalendarView::~CalendarView() 466CalendarView::~CalendarView()
468{ 467{
469 // kdDebug() << "~CalendarView()" << endl; 468 // kdDebug() << "~CalendarView()" << endl;
470 //qDebug("CalendarView::~CalendarView() "); 469 //qDebug("CalendarView::~CalendarView() ");
471 delete mDialogManager; 470 delete mDialogManager;
472 delete mViewManager; 471 delete mViewManager;
473 delete mStorage; 472 delete mStorage;
474 delete mDateFrame ; 473 delete mDateFrame ;
475 delete beamDialog; 474 delete beamDialog;
476 //kdDebug() << "~CalendarView() done" << endl; 475 //kdDebug() << "~CalendarView() done" << endl;
477} 476}
478void CalendarView::timerAlarm() 477void CalendarView::timerAlarm()
479{ 478{
480 //qDebug("CalendarView::timerAlarm() "); 479 //qDebug("CalendarView::timerAlarm() ");
481 computeAlarm(mAlarmNotification ); 480 computeAlarm(mAlarmNotification );
482} 481}
483 482
484void CalendarView::suspendAlarm() 483void CalendarView::suspendAlarm()
485{ 484{
486 //qDebug(" CalendarView::suspendAlarm() "); 485 //qDebug(" CalendarView::suspendAlarm() ");
487 computeAlarm(mSuspendAlarmNotification ); 486 computeAlarm(mSuspendAlarmNotification );
488 487
489} 488}
490 489
491void CalendarView::startAlarm( QString mess , QString filename) 490void CalendarView::startAlarm( QString mess , QString filename)
492{ 491{
493 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 );
494 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); 493 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
495 494
496} 495}
497 496
498void CalendarView::checkNextTimerAlarm() 497void CalendarView::checkNextTimerAlarm()
499{ 498{
500 mCalendar->checkAlarmForIncidence( 0, true ); 499 mCalendar->checkAlarmForIncidence( 0, true );
501} 500}
502 501
503void CalendarView::computeAlarm( QString msg ) 502void CalendarView::computeAlarm( QString msg )
504{ 503{
505 504
506 QString mess = msg; 505 QString mess = msg;
507 QString mAlarmMessage = mess.mid( 9 ); 506 QString mAlarmMessage = mess.mid( 9 );
508 QString filename = MainWindow::resourcePath(); 507 QString filename = MainWindow::resourcePath();
509 filename += "koalarm.wav"; 508 filename += "koalarm.wav";
510 QString tempfilename; 509 QString tempfilename;
511 if ( mess.left( 13 ) == "suspend_alarm") { 510 if ( mess.left( 13 ) == "suspend_alarm") {
512 bool error = false; 511 bool error = false;
513 int len = mess.mid( 13 ).find("+++"); 512 int len = mess.mid( 13 ).find("+++");
514 if ( len < 2 ) 513 if ( len < 2 )
515 error = true; 514 error = true;
516 else { 515 else {
517 tempfilename = mess.mid( 13, len ); 516 tempfilename = mess.mid( 13, len );
518 if ( !QFile::exists( tempfilename ) ) 517 if ( !QFile::exists( tempfilename ) )
519 error = true; 518 error = true;
520 } 519 }
521 if ( ! error ) { 520 if ( ! error ) {
522 filename = tempfilename; 521 filename = tempfilename;
523 } 522 }
524 mAlarmMessage = mess.mid( 13+len+3 ); 523 mAlarmMessage = mess.mid( 13+len+3 );
525 //qDebug("suspend file %s ",tempfilename.latin1() ); 524 //qDebug("suspend file %s ",tempfilename.latin1() );
526 startAlarm( mAlarmMessage, filename); 525 startAlarm( mAlarmMessage, filename);
527 return; 526 return;
528 } 527 }
529 if ( mess.left( 11 ) == "timer_alarm") { 528 if ( mess.left( 11 ) == "timer_alarm") {
530 //mTimerTime = 0; 529 //mTimerTime = 0;
531 startAlarm( mess.mid( 11 ), filename ); 530 startAlarm( mess.mid( 11 ), filename );
532 return; 531 return;
533 } 532 }
534 if ( mess.left( 10 ) == "proc_alarm") { 533 if ( mess.left( 10 ) == "proc_alarm") {
535 bool error = false; 534 bool error = false;
536 int len = mess.mid( 10 ).find("+++"); 535 int len = mess.mid( 10 ).find("+++");
537 if ( len < 2 ) 536 if ( len < 2 )
538 error = true; 537 error = true;
539 else { 538 else {
540 tempfilename = mess.mid( 10, len ); 539 tempfilename = mess.mid( 10, len );
541 if ( !QFile::exists( tempfilename ) ) 540 if ( !QFile::exists( tempfilename ) )
542 error = true; 541 error = true;
543 } 542 }
544 if ( error ) { 543 if ( error ) {
545 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 544 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
546 mAlarmMessage += mess.mid( 10+len+3+9 ); 545 mAlarmMessage += mess.mid( 10+len+3+9 );
547 } else { 546 } else {
548 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 547 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
549 //qDebug("-----system command %s ",tempfilename.latin1() ); 548 //qDebug("-----system command %s ",tempfilename.latin1() );
550#ifndef _WIN32_ 549#ifndef _WIN32_
551 if ( vfork () == 0 ) { 550 if ( vfork () == 0 ) {
552 execl ( tempfilename.latin1(), 0 ); 551 execl ( tempfilename.latin1(), 0 );
553 return; 552 return;
554 } 553 }
555#else 554#else
556 QProcess* p = new QProcess(); 555 QProcess* p = new QProcess();
557 p->addArgument( tempfilename.latin1() ); 556 p->addArgument( tempfilename.latin1() );
558 p->start(); 557 p->start();
559 return; 558 return;
560#endif 559#endif
561 560
562 return; 561 return;
563 } 562 }
564 563
565 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 564 //qDebug("+++++++system command %s ",tempfilename.latin1() );
566 } 565 }
567 if ( mess.left( 11 ) == "audio_alarm") { 566 if ( mess.left( 11 ) == "audio_alarm") {
568 bool error = false; 567 bool error = false;
569 int len = mess.mid( 11 ).find("+++"); 568 int len = mess.mid( 11 ).find("+++");
570 if ( len < 2 ) 569 if ( len < 2 )
571 error = true; 570 error = true;
572 else { 571 else {
573 tempfilename = mess.mid( 11, len ); 572 tempfilename = mess.mid( 11, len );
574 if ( !QFile::exists( tempfilename ) ) 573 if ( !QFile::exists( tempfilename ) )
575 error = true; 574 error = true;
576 } 575 }
577 if ( ! error ) { 576 if ( ! error ) {
578 filename = tempfilename; 577 filename = tempfilename;
579 } 578 }
580 mAlarmMessage = mess.mid( 11+len+3+9 ); 579 mAlarmMessage = mess.mid( 11+len+3+9 );
581 //qDebug("audio file command %s ",tempfilename.latin1() ); 580 //qDebug("audio file command %s ",tempfilename.latin1() );
582 } 581 }
583 if ( mess.left( 9 ) == "cal_alarm") { 582 if ( mess.left( 9 ) == "cal_alarm") {
584 mAlarmMessage = mess.mid( 9 ) ; 583 mAlarmMessage = mess.mid( 9 ) ;
585 } 584 }
586 585
587 startAlarm( mAlarmMessage, filename ); 586 startAlarm( mAlarmMessage, filename );
588 587
589 588
590} 589}
591 590
592void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 591void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
593{ 592{
594 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 593 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
595 594
596 mSuspendAlarmNotification = noti; 595 mSuspendAlarmNotification = noti;
597 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 596 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
598 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 597 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
599 mSuspendTimer->start( ms , true ); 598 mSuspendTimer->start( ms , true );
600 599
601} 600}
602 601
603void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 602void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
604{ 603{
605 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 604 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
606 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 605 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
607#ifndef DESKTOP_VERSION 606#ifndef DESKTOP_VERSION
608 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); 607 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() );
609#endif 608#endif
610 return; 609 return;
611 } 610 }
612 int maxSec; 611 int maxSec;
613 //maxSec = 5; //testing only 612 //maxSec = 5; //testing only
614 maxSec = 86400+3600; // one day+1hour 613 maxSec = 86400+3600; // one day+1hour
615 mAlarmNotification = noti; 614 mAlarmNotification = noti;
616 int sec = QDateTime::currentDateTime().secsTo( qdt ); 615 int sec = QDateTime::currentDateTime().secsTo( qdt );
617 if ( sec > maxSec ) { 616 if ( sec > maxSec ) {
618 mRecheckAlarmTimer->start( maxSec * 1000 ); 617 mRecheckAlarmTimer->start( maxSec * 1000 );
619 // 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 );
620 return; 619 return;
621 } else { 620 } else {
622 mRecheckAlarmTimer->stop(); 621 mRecheckAlarmTimer->stop();
623 } 622 }
624 //qDebug("Alarm timer started with secs: %d ", sec); 623 //qDebug("Alarm timer started with secs: %d ", sec);
625 mAlarmTimer->start( sec *1000 , true ); 624 mAlarmTimer->start( sec *1000 , true );
626 625
627} 626}
628// called by mRecheckAlarmTimer to get next alarm 627// called by mRecheckAlarmTimer to get next alarm
629// 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
630void CalendarView::recheckTimerAlarm() 629void CalendarView::recheckTimerAlarm()
631{ 630{
632 mAlarmTimer->stop(); 631 mAlarmTimer->stop();
633 mRecheckAlarmTimer->stop(); 632 mRecheckAlarmTimer->stop();
634 mCalendar->checkAlarmForIncidence( 0, true ); 633 mCalendar->checkAlarmForIncidence( 0, true );
635} 634}
636void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 635void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
637{ 636{
638 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 637 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
639 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 638 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
640#ifndef DESKTOP_VERSION 639#ifndef DESKTOP_VERSION
641 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 640 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
642#endif 641#endif
643 return; 642 return;
644 } 643 }
645 mAlarmTimer->stop(); 644 mAlarmTimer->stop();
646} 645}
647void CalendarView::selectWeekNum ( int num ) 646void CalendarView::selectWeekNum ( int num )
648{ 647{
649 dateNavigator()->selectWeek( num ); 648 dateNavigator()->selectWeek( num );
650 mViewManager->showWeekView(); 649 mViewManager->showWeekView();
651} 650}
652KOViewManager *CalendarView::viewManager() 651KOViewManager *CalendarView::viewManager()
653{ 652{
654 return mViewManager; 653 return mViewManager;
655} 654}
656 655
657KODialogManager *CalendarView::dialogManager() 656KODialogManager *CalendarView::dialogManager()
658{ 657{
659 return mDialogManager; 658 return mDialogManager;
660} 659}
661 660
662QDate CalendarView::startDate() 661QDate CalendarView::startDate()
663{ 662{
664 DateList dates = mNavigator->selectedDates(); 663 DateList dates = mNavigator->selectedDates();
665 664
666 return dates.first(); 665 return dates.first();
667} 666}
668 667
669QDate CalendarView::endDate() 668QDate CalendarView::endDate()
670{ 669{
671 DateList dates = mNavigator->selectedDates(); 670 DateList dates = mNavigator->selectedDates();
672 671
673 return dates.last(); 672 return dates.last();
674} 673}
675 674
676 675
677void CalendarView::createPrinter() 676void CalendarView::createPrinter()
678{ 677{
679#ifndef KORG_NOPRINTER 678#ifndef KORG_NOPRINTER
680 if (!mCalPrinter) { 679 if (!mCalPrinter) {
681 mCalPrinter = new CalPrinter(this, mCalendar); 680 mCalPrinter = new CalPrinter(this, mCalendar);
682 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 681 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
683 } 682 }
684#endif 683#endif
685} 684}
686 685
687void CalendarView::confSync() 686void CalendarView::confSync()
688{ 687{
689 static KOSyncPrefsDialog* sp = 0; 688 static KOSyncPrefsDialog* sp = 0;
690 if ( ! sp ) { 689 if ( ! sp ) {
691 sp = new KOSyncPrefsDialog( this, "syncprefs", true ); 690 sp = new KOSyncPrefsDialog( this, "syncprefs", true );
692 } 691 }
692 sp->setLocalMachineName ( KOPrefs::instance()->mLocalMachineName );
693 sp->usrReadConfig(); 693 sp->usrReadConfig();
694#ifndef DESKTOP_VERSION 694#ifndef DESKTOP_VERSION
695 sp->showMaximized(); 695 sp->showMaximized();
696#else 696#else
697 sp->show(); 697 sp->show();
698#endif 698#endif
699 sp->exec(); 699 sp->exec();
700 700 KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames();
701 KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName ();
701} 702}
702 703
703 704
704//KOPrefs::instance()->mWriteBackFile 705//KOPrefs::instance()->mWriteBackFile
705//KOPrefs::instance()->mWriteBackExistingOnly 706//KOPrefs::instance()->mWriteBackExistingOnly
706 707
707// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 708// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
708// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 709// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
709// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 710// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
710// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 711// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
711// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 712// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
712// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 713// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
713 714
714int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 715int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
715{ 716{
716 717
717 //void setZaurusId(int id); 718 //void setZaurusId(int id);
718 // int zaurusId() const; 719 // int zaurusId() const;
719 // void setZaurusUid(int id); 720 // void setZaurusUid(int id);
720 // int zaurusUid() const; 721 // int zaurusUid() const;
721 // void setZaurusStat(int id); 722 // void setZaurusStat(int id);
722 // int zaurusStat() const; 723 // int zaurusStat() const;
723 // 0 equal 724 // 0 equal
724 // 1 take local 725 // 1 take local
725 // 2 take remote 726 // 2 take remote
726 // 3 cancel 727 // 3 cancel
727 QDateTime lastSync = mLastCalendarSync; 728 QDateTime lastSync = mLastCalendarSync;
728 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 729 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
729 bool remCh, locCh; 730 bool remCh, locCh;
730 remCh = ( remote->zaurusUid() != local->zaurusUid() ); 731 remCh = ( remote->zaurusUid() != local->zaurusUid() );
731 locCh = ( local->lastModified() > mLastCalendarSync ); 732 locCh = ( local->lastModified() > mLastCalendarSync );
732 //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() ); 733 //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() );
733 if ( !remCh && ! locCh ) { 734 if ( !remCh && ! locCh ) {
734 //qDebug("both not changed "); 735 //qDebug("both not changed ");
735 lastSync = local->lastModified().addDays(1); 736 lastSync = local->lastModified().addDays(1);
736 } else { 737 } else {
737 if ( locCh ) { 738 if ( locCh ) {
738 //qDebug("loc changed %d %d", local->zaurusStat(), local->revision() ); 739 //qDebug("loc changed %d %d", local->zaurusStat(), local->revision() );
739 lastSync = local->lastModified().addDays( -1 ); 740 lastSync = local->lastModified().addDays( -1 );
740 if ( !remCh ) 741 if ( !remCh )
741 remote->setLastModified( lastSync.addDays( -1 ) ); 742 remote->setLastModified( lastSync.addDays( -1 ) );
742 } else { 743 } else {
743 //qDebug(" not loc changed "); 744 //qDebug(" not loc changed ");
744 lastSync = local->lastModified().addDays( 1 ); 745 lastSync = local->lastModified().addDays( 1 );
745 if ( remCh ) 746 if ( remCh )
746 remote->setLastModified( lastSync.addDays( 1 ) ); 747 remote->setLastModified( lastSync.addDays( 1 ) );
747 748
748 } 749 }
749 } 750 }
750 full = true; 751 full = true;
751 if ( mode < SYNC_PREF_ASK ) 752 if ( mode < SYNC_PREF_ASK )
752 mode = SYNC_PREF_ASK; 753 mode = SYNC_PREF_ASK;
753 } else { 754 } else {
754 if ( local->lastModified() == remote->lastModified() ) 755 if ( local->lastModified() == remote->lastModified() )
755 if ( local->revision() == remote->revision() ) 756 if ( local->revision() == remote->revision() )
756 return 0; 757 return 0;
757 758
758 } 759 }
759 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 760 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
760 761
761 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); 762 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision());
762 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); 763 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() );
763 //full = true; //debug only 764 //full = true; //debug only
764 if ( full ) { 765 if ( full ) {
765 bool equ = false; 766 bool equ = false;
766 if ( local->type() == "Event" ) { 767 if ( local->type() == "Event" ) {
767 equ = (*((Event*) local) == *((Event*) remote)); 768 equ = (*((Event*) local) == *((Event*) remote));
768 } 769 }
769 else if ( local->type() =="Todo" ) 770 else if ( local->type() =="Todo" )
770 equ = (*((Todo*) local) == (*(Todo*) remote)); 771 equ = (*((Todo*) local) == (*(Todo*) remote));
771 else if ( local->type() =="Journal" ) 772 else if ( local->type() =="Journal" )
772 equ = (*((Journal*) local) == *((Journal*) remote)); 773 equ = (*((Journal*) local) == *((Journal*) remote));
773 if ( equ ) { 774 if ( equ ) {
774 //qDebug("equal "); 775 //qDebug("equal ");
775 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 776 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
776 local->setZaurusUid( remote->zaurusUid() ); 777 local->setZaurusUid( remote->zaurusUid() );
777 } 778 }
778 if ( mode < SYNC_PREF_FORCE_LOCAL ) 779 if ( mode < SYNC_PREF_FORCE_LOCAL )
779 return 0; 780 return 0;
780 781
781 }//else //debug only 782 }//else //debug only
782 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 783 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
783 } 784 }
784 int result; 785 int result;
785 bool localIsNew; 786 bool localIsNew;
786 if ( full && mode < SYNC_PREF_NEWEST ) 787 if ( full && mode < SYNC_PREF_NEWEST )
787 mode = SYNC_PREF_ASK; 788 mode = SYNC_PREF_ASK;
788 789
789 switch( mode ) { 790 switch( mode ) {
790 case SYNC_PREF_LOCAL: 791 case SYNC_PREF_LOCAL:
791 if ( lastSync > remote->lastModified() ) 792 if ( lastSync > remote->lastModified() )
792 return 1; 793 return 1;
793 if ( lastSync > local->lastModified() ) 794 if ( lastSync > local->lastModified() )
794 return 2; 795 return 2;
795 return 1; 796 return 1;
796 break; 797 break;
797 case SYNC_PREF_REMOTE: 798 case SYNC_PREF_REMOTE:
798 if ( lastSync > remote->lastModified() ) 799 if ( lastSync > remote->lastModified() )
799 return 1; 800 return 1;
800 if ( lastSync > local->lastModified() ) 801 if ( lastSync > local->lastModified() )
801 return 2; 802 return 2;
802 return 2; 803 return 2;
803 break; 804 break;
804 case SYNC_PREF_NEWEST: 805 case SYNC_PREF_NEWEST:
805 if ( local->lastModified() > remote->lastModified() ) 806 if ( local->lastModified() > remote->lastModified() )
806 return 1; 807 return 1;
807 else 808 else
808 return 2; 809 return 2;
809 break; 810 break;
810 case SYNC_PREF_ASK: 811 case SYNC_PREF_ASK:
811 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); 812 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() );
812 if ( lastSync > remote->lastModified() ) 813 if ( lastSync > remote->lastModified() )
813 return 1; 814 return 1;
814 if ( lastSync > local->lastModified() ) 815 if ( lastSync > local->lastModified() )
815 return 2; 816 return 2;
816 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); 817 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() );
817 localIsNew = local->lastModified() > remote->lastModified(); 818 localIsNew = local->lastModified() > remote->lastModified();
818 if ( localIsNew ) 819 if ( localIsNew )
819 getEventViewerDialog()->setColorMode( 1 ); 820 getEventViewerDialog()->setColorMode( 1 );
820 else 821 else
821 getEventViewerDialog()->setColorMode( 2 ); 822 getEventViewerDialog()->setColorMode( 2 );
822 getEventViewerDialog()->setIncidence(local); 823 getEventViewerDialog()->setIncidence(local);
823 if ( localIsNew ) 824 if ( localIsNew )
824 getEventViewerDialog()->setColorMode( 2 ); 825 getEventViewerDialog()->setColorMode( 2 );
825 else 826 else
826 getEventViewerDialog()->setColorMode( 1 ); 827 getEventViewerDialog()->setColorMode( 1 );
827 getEventViewerDialog()->addIncidence(remote); 828 getEventViewerDialog()->addIncidence(remote);
828 getEventViewerDialog()->setColorMode( 0 ); 829 getEventViewerDialog()->setColorMode( 0 );
829 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 830 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
830 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 831 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
831 getEventViewerDialog()->showMe(); 832 getEventViewerDialog()->showMe();
832 result = getEventViewerDialog()->executeS( localIsNew ); 833 result = getEventViewerDialog()->executeS( localIsNew );
833 return result; 834 return result;
834 835
835 break; 836 break;
836 case SYNC_PREF_FORCE_LOCAL: 837 case SYNC_PREF_FORCE_LOCAL:
837 return 1; 838 return 1;
838 break; 839 break;
839 case SYNC_PREF_FORCE_REMOTE: 840 case SYNC_PREF_FORCE_REMOTE:
840 return 2; 841 return 2;
841 break; 842 break;
842 843
843 default: 844 default:
844 // SYNC_PREF_TAKE_BOTH not implemented 845 // SYNC_PREF_TAKE_BOTH not implemented
845 break; 846 break;
846 } 847 }
847 return 0; 848 return 0;
848} 849}
849Event* CalendarView::getLastSyncEvent() 850Event* CalendarView::getLastSyncEvent()
850{ 851{
851 Event* lse; 852 Event* lse;
852 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 853 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
853 lse = mCalendar->event( "last-syncEvent-device-"+mCurrentSyncDevice ); 854 lse = mCalendar->event( "last-syncEvent-device-"+mCurrentSyncDevice );
854 if (!lse) { 855 if (!lse) {
855 lse = new Event(); 856 lse = new Event();
856 lse->setUid( "last-syncEvent-device-"+mCurrentSyncDevice ); 857 lse->setUid( "last-syncEvent-device-"+mCurrentSyncDevice );
857 lse->setSummary(mCurrentSyncDevice + i18n(" - sync event")); 858 lse->setSummary(mCurrentSyncDevice + i18n(" - sync event"));
858 lse->setDtStart( mLastCalendarSync ); 859 lse->setDtStart( mLastCalendarSync );
859 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 860 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
860 lse->setCategories( i18n("SyncEvent") ); 861 lse->setCategories( i18n("SyncEvent") );
861 lse->setReadOnly( true ); 862 lse->setReadOnly( true );
862 mCalendar->addEvent( lse ); 863 mCalendar->addEvent( lse );
863 } 864 }
864 865
865 return lse; 866 return lse;
866 867
867} 868}
868void CalendarView::checkSharpEvent( Event* lastSync, Incidence* toDelete ) 869void CalendarView::checkSharpEvent( Event* lastSync, Incidence* toDelete )
869{ 870{
870 if ( ! lastSync ) 871 if ( ! lastSync )
871 return; 872 return;
872 if ( toDelete->zaurusId() < 0 ) 873 if ( toDelete->zaurusId() < 0 )
873 return; 874 return;
874 if ( toDelete->type() == "Journal" ) 875 if ( toDelete->type() == "Journal" )
875 return; 876 return;
876 QString des = lastSync->description(); 877 QString des = lastSync->description();
877 QString pref = "e"; 878 QString pref = "e";
878 if ( toDelete->type() == "Todo" ) 879 if ( toDelete->type() == "Todo" )
879 pref = "t"; 880 pref = "t";
880 des += pref+ QString::number ( toDelete->zaurusId() ) + ","; 881 des += pref+ QString::number ( toDelete->zaurusId() ) + ",";
881 lastSync->setReadOnly( false ); 882 lastSync->setReadOnly( false );
882 lastSync->setDescription( des ); 883 lastSync->setDescription( des );
883 lastSync->setReadOnly( true ); 884 lastSync->setReadOnly( true );
884 885
885} 886}
886bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 887bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
887{ 888{
888 bool syncOK = true; 889 bool syncOK = true;
889 int addedEvent = 0; 890 int addedEvent = 0;
890 int addedEventR = 0; 891 int addedEventR = 0;
891 int deletedEventR = 0; 892 int deletedEventR = 0;
892 int deletedEventL = 0; 893 int deletedEventL = 0;
893 int changedLocal = 0; 894 int changedLocal = 0;
894 int changedRemote = 0; 895 int changedRemote = 0;
895 //QPtrList<Event> el = local->rawEvents(); 896 //QPtrList<Event> el = local->rawEvents();
896 Event* eventR; 897 Event* eventR;
897 QString uid; 898 QString uid;
898 int take; 899 int take;
899 Event* eventL; 900 Event* eventL;
900 Event* eventRSync; 901 Event* eventRSync;
901 Event* eventLSync; 902 Event* eventLSync;
902 Event* eventRSyncSharp = remote->event( "last-syncEvent-device-Sharp-DTM"); 903 Event* eventRSyncSharp = remote->event( "last-syncEvent-device-Sharp-DTM");
903 Event* eventLSyncSharp = local->event( "last-syncEvent-device-Sharp-DTM"); 904 Event* eventLSyncSharp = local->event( "last-syncEvent-device-Sharp-DTM");
904 bool fullDateRange = false; 905 bool fullDateRange = false;
905 mLastCalendarSync = QDateTime::currentDateTime(); 906 mLastCalendarSync = QDateTime::currentDateTime();
906 QDateTime modifiedCalendar = mLastCalendarSync;; 907 QDateTime modifiedCalendar = mLastCalendarSync;;
907 eventR = remote->event("last-syncEvent-device-"+mCurrentSyncName ); 908 eventR = remote->event("last-syncEvent-device-"+mCurrentSyncName );
908 if ( eventR ) { 909 if ( eventR ) {
909 eventRSync = (Event*) eventR->clone(); 910 eventRSync = (Event*) eventR->clone();
910 remote->deleteEvent(eventR ); 911 remote->deleteEvent(eventR );
911 912
912 } else { 913 } else {
913 fullDateRange = true; 914 fullDateRange = true;
914 eventRSync = new Event(); 915 eventRSync = new Event();
915 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 916 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
916 eventRSync->setUid("last-syncEvent-device-"+mCurrentSyncName ); 917 eventRSync->setUid("last-syncEvent-device-"+mCurrentSyncName );
917 eventRSync->setDtStart( mLastCalendarSync ); 918 eventRSync->setDtStart( mLastCalendarSync );
918 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 919 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
919 eventRSync->setCategories( i18n("SyncEvent") ); 920 eventRSync->setCategories( i18n("SyncEvent") );
920 } 921 }
921 eventLSync = getLastSyncEvent(); 922 eventLSync = getLastSyncEvent();
922 if ( eventLSync->dtStart() == mLastCalendarSync ) 923 if ( eventLSync->dtStart() == mLastCalendarSync )
923 fullDateRange = true; 924 fullDateRange = true;
924 925
925 if ( ! fullDateRange ) { 926 if ( ! fullDateRange ) {
926 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 927 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
927 928
928 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 929 // 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()); 930 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
930 fullDateRange = true; 931 fullDateRange = true;
931 } 932 }
932 } 933 }
933 if ( fullDateRange ) 934 if ( fullDateRange )
934 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 935 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
935 else 936 else
936 mLastCalendarSync = eventLSync->dtStart(); 937 mLastCalendarSync = eventLSync->dtStart();
937 // for resyncing if own file has changed 938 // for resyncing if own file has changed
938 if ( mCurrentSyncDevice == "deleteaftersync" ) { 939 if ( mCurrentSyncDevice == "deleteaftersync" ) {
939 mLastCalendarSync = loadedFileVersion; 940 mLastCalendarSync = loadedFileVersion;
940 qDebug("setting mLastCalendarSync "); 941 qDebug("setting mLastCalendarSync ");
941 } 942 }
942 //qDebug("*************************** "); 943 //qDebug("*************************** ");
943 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); 944 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() );
944 QPtrList<Incidence> er = remote->rawIncidences(); 945 QPtrList<Incidence> er = remote->rawIncidences();
945 Incidence* inR = er.first(); 946 Incidence* inR = er.first();
946 Incidence* inL; 947 Incidence* inL;
947 QProgressBar bar( er.count(),0 ); 948 QProgressBar bar( er.count(),0 );
948 bar.setCaption (i18n("Syncing - close to abort!") ); 949 bar.setCaption (i18n("Syncing - close to abort!") );
949 950
950 int w = 300; 951 int w = 300;
951 if ( QApplication::desktop()->width() < 320 ) 952 if ( QApplication::desktop()->width() < 320 )
952 w = 220; 953 w = 220;
953 int h = bar.sizeHint().height() ; 954 int h = bar.sizeHint().height() ;
954 int dw = QApplication::desktop()->width(); 955 int dw = QApplication::desktop()->width();
955 int dh = QApplication::desktop()->height(); 956 int dh = QApplication::desktop()->height();
956 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 957 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
957 bar.show(); 958 bar.show();
958 int modulo = (er.count()/10)+1; 959 int modulo = (er.count()/10)+1;
959 int incCounter = 0; 960 int incCounter = 0;
960 while ( inR ) { 961 while ( inR ) {
961 if ( ! bar.isVisible() ) 962 if ( ! bar.isVisible() )
962 return false; 963 return false;
963 if ( incCounter % modulo == 0 ) 964 if ( incCounter % modulo == 0 )
964 bar.setProgress( incCounter ); 965 bar.setProgress( incCounter );
965 ++incCounter; 966 ++incCounter;
966 uid = inR->uid(); 967 uid = inR->uid();
967 bool skipIncidence = false; 968 bool skipIncidence = false;
968 if ( uid.left(21) == QString("last-syncEvent-device") ) 969 if ( uid.left(21) == QString("last-syncEvent-device") )
969 skipIncidence = true; 970 skipIncidence = true;
970 971
971 qApp->processEvents(); 972 qApp->processEvents();
972 if ( !skipIncidence ) { 973 if ( !skipIncidence ) {
973 inL = local->incidence( uid ); 974 inL = local->incidence( uid );
974 if ( inL ) { // maybe conflict - same uid in both calendars 975 if ( inL ) { // maybe conflict - same uid in both calendars
975 int maxrev = inL->revision(); 976 int maxrev = inL->revision();
976 if ( maxrev < inR->revision() ) 977 if ( maxrev < inR->revision() )
977 maxrev = inR->revision(); 978 maxrev = inR->revision();
978 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 979 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
979 //qDebug("take %d %s ", take, inL->summary().latin1()); 980 //qDebug("take %d %s ", take, inL->summary().latin1());
980 if ( take == 3 ) 981 if ( take == 3 )
981 return false; 982 return false;
982 if ( take == 1 ) {// take local 983 if ( take == 1 ) {// take local
983 inL->setZaurusUid( inR->zaurusUid() ); 984 inL->setZaurusUid( inR->zaurusUid() );
984 remote->deleteIncidence( inR ); 985 remote->deleteIncidence( inR );
985 if ( inL->revision() < maxrev ) 986 if ( inL->revision() < maxrev )
986 inL->setRevision( maxrev ); 987 inL->setRevision( maxrev );
987 remote->addIncidence( inL->clone() ); 988 remote->addIncidence( inL->clone() );
988 ++changedRemote; 989 ++changedRemote;
989 } else { 990 } else {
990 if ( inR->revision() < maxrev ) 991 if ( inR->revision() < maxrev )
991 inR->setRevision( maxrev ); 992 inR->setRevision( maxrev );
992 local->deleteIncidence( inL ); 993 local->deleteIncidence( inL );
993 local->addIncidence( inR->clone() ); 994 local->addIncidence( inR->clone() );
994 ++changedLocal; 995 ++changedLocal;
995 } 996 }
996 } 997 }
997 } else { // no conflict 998 } else { // no conflict
998 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 999 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
999 QString des = eventLSync->description(); 1000 QString des = eventLSync->description();
1000 QString pref = "e"; 1001 QString pref = "e";
1001 if ( inR->type() == "Todo" ) 1002 if ( inR->type() == "Todo" )
1002 pref = "t"; 1003 pref = "t";
1003 if ( des.find(pref+QString::number( inR->zaurusId() ) +"," ) >= 0 && mode != 5) { // delete it 1004 if ( des.find(pref+QString::number( inR->zaurusId() ) +"," ) >= 0 && mode != 5) { // delete it
1004 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1005 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1005 //remote->deleteIncidence( inR ); 1006 //remote->deleteIncidence( inR );
1006 ++deletedEventR; 1007 ++deletedEventR;
1007 } else { 1008 } else {
1008 inR->setLastModified( modifiedCalendar ); 1009 inR->setLastModified( modifiedCalendar );
1009 local->addIncidence( inR->clone() ); 1010 local->addIncidence( inR->clone() );
1010 ++addedEvent; 1011 ++addedEvent;
1011 } 1012 }
1012 } else { 1013 } else {
1013 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1014 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1014 inR->setLastModified( modifiedCalendar ); 1015 inR->setLastModified( modifiedCalendar );
1015 local->addIncidence( inR->clone() ); 1016 local->addIncidence( inR->clone() );
1016 ++addedEvent; 1017 ++addedEvent;
1017 } else { 1018 } else {
1018 checkSharpEvent(eventRSyncSharp, inR); 1019 checkSharpEvent(eventRSyncSharp, inR);
1019 remote->deleteIncidence( inR ); 1020 remote->deleteIncidence( inR );
1020 ++deletedEventR; 1021 ++deletedEventR;
1021 } 1022 }
1022 } 1023 }
1023 } 1024 }
1024 } 1025 }
1025 inR = er.next(); 1026 inR = er.next();
1026 } 1027 }
1027 QPtrList<Incidence> el = local->rawIncidences(); 1028 QPtrList<Incidence> el = local->rawIncidences();
1028 inL = el.first(); 1029 inL = el.first();
1029 modulo = (el.count()/10)+1; 1030 modulo = (el.count()/10)+1;
1030 bar.setCaption (i18n("Add / remove events") ); 1031 bar.setCaption (i18n("Add / remove events") );
1031 bar.setTotalSteps ( el.count() ) ; 1032 bar.setTotalSteps ( el.count() ) ;
1032 bar.show(); 1033 bar.show();
1033 incCounter = 0; 1034 incCounter = 0;
1034 1035
1035 while ( inL ) { 1036 while ( inL ) {
1036 1037
1037 qApp->processEvents(); 1038 qApp->processEvents();
1038 if ( ! bar.isVisible() ) 1039 if ( ! bar.isVisible() )
1039 return false; 1040 return false;
1040 if ( incCounter % modulo == 0 ) 1041 if ( incCounter % modulo == 0 )
1041 bar.setProgress( incCounter ); 1042 bar.setProgress( incCounter );
1042 ++incCounter; 1043 ++incCounter;
1043 uid = inL->uid(); 1044 uid = inL->uid();
1044 bool skipIncidence = false; 1045 bool skipIncidence = false;
1045 if ( uid.left(21) == QString("last-syncEvent-device") ) 1046 if ( uid.left(21) == QString("last-syncEvent-device") )
1046 skipIncidence = true; 1047 skipIncidence = true;
1047 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) 1048 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
1048 skipIncidence = true; 1049 skipIncidence = true;
1049 if ( !skipIncidence ) { 1050 if ( !skipIncidence ) {
1050 inR = remote->incidence( uid ); 1051 inR = remote->incidence( uid );
1051 if ( ! inR ) { 1052 if ( ! inR ) {
1052 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1053 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1053 if ( inL->zaurusId() >= 0 && mode != 4 ) { 1054 if ( inL->zaurusId() >= 0 && mode != 4 ) {
1054 local->deleteIncidence( inL ); 1055 local->deleteIncidence( inL );
1055 ++deletedEventL; 1056 ++deletedEventL;
1056 } else { 1057 } else {
1057 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { 1058 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
1058 inL->setZaurusId( -1 ); 1059 inL->setZaurusId( -1 );
1059 ++addedEventR; 1060 ++addedEventR;
1060 inL->setLastModified( modifiedCalendar ); 1061 inL->setLastModified( modifiedCalendar );
1061 remote->addIncidence( inL->clone() ); 1062 remote->addIncidence( inL->clone() );
1062 } 1063 }
1063 } 1064 }
1064 } else { 1065 } else {
1065 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1066 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1066 checkSharpEvent(eventLSyncSharp, inL); 1067 checkSharpEvent(eventLSyncSharp, inL);
1067 local->deleteIncidence( inL ); 1068 local->deleteIncidence( inL );
1068 ++deletedEventL; 1069 ++deletedEventL;
1069 } else { 1070 } else {
1070 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { 1071 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
1071 ++addedEventR; 1072 ++addedEventR;
1072 inL->setLastModified( modifiedCalendar ); 1073 inL->setLastModified( modifiedCalendar );
1073 remote->addIncidence( inL->clone() ); 1074 remote->addIncidence( inL->clone() );
1074 } 1075 }
1075 } 1076 }
1076 } 1077 }
1077 } 1078 }
1078 } 1079 }
1079 inL = el.next(); 1080 inL = el.next();
1080 } 1081 }
1081 1082
1082 bar.hide(); 1083 bar.hide();
1083 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1084 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1084 eventLSync->setReadOnly( false ); 1085 eventLSync->setReadOnly( false );
1085 eventLSync->setDtStart( mLastCalendarSync ); 1086 eventLSync->setDtStart( mLastCalendarSync );
1086 eventRSync->setDtStart( mLastCalendarSync ); 1087 eventRSync->setDtStart( mLastCalendarSync );
1087 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1088 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1088 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1089 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1089 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1090 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1090 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1091 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1091 eventLSync->setReadOnly( true ); 1092 eventLSync->setReadOnly( true );
1092 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 1093 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
1093 remote->addEvent( eventRSync ); 1094 remote->addEvent( eventRSync );
1094 QString mes; 1095 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 ); 1096 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 ) { 1097 if ( KOPrefs::instance()->mShowSyncSummary ) {
1097 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); 1098 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") );
1098 } 1099 }
1099 qDebug( mes ); 1100 qDebug( mes );
1100 mCalendar->checkAlarmForIncidence( 0, true ); 1101 mCalendar->checkAlarmForIncidence( 0, true );
1101 return syncOK; 1102 return syncOK;
1102} 1103}
1103 1104
1104void CalendarView::setSyncDevice( QString s ) 1105void CalendarView::setSyncDevice( QString s )
1105{ 1106{
1106 mCurrentSyncDevice= s; 1107 mCurrentSyncDevice= s;
1107} 1108}
1108void CalendarView::setSyncName( QString s ) 1109void CalendarView::setSyncName( QString s )
1109{ 1110{
1110 mCurrentSyncName= s; 1111 mCurrentSyncName= s;
1111} 1112}
1112bool CalendarView::syncCalendar(QString filename, int mode) 1113bool CalendarView::syncCalendar(QString filename, int mode)
1113{ 1114{
1114 mGlobalSyncMode = SYNC_MODE_NORMAL; 1115 mGlobalSyncMode = SYNC_MODE_NORMAL;
1115 CalendarLocal* calendar = new CalendarLocal(); 1116 CalendarLocal* calendar = new CalendarLocal();
1116 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1117 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1117 FileStorage* storage = new FileStorage( calendar ); 1118 FileStorage* storage = new FileStorage( calendar );
1118 bool syncOK = false; 1119 bool syncOK = false;
1119 storage->setFileName( filename ); 1120 storage->setFileName( filename );
1120 // qDebug("loading ... "); 1121 // qDebug("loading ... ");
1121 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { 1122 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) {
1122 getEventViewerDialog()->setSyncMode( true ); 1123 getEventViewerDialog()->setSyncMode( true );
1123 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1124 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1124 getEventViewerDialog()->setSyncMode( false ); 1125 getEventViewerDialog()->setSyncMode( false );
1125 if ( syncOK ) { 1126 if ( syncOK ) {
1126 if ( KOPrefs::instance()->mWriteBackFile ) 1127 if ( KOPrefs::instance()->mWriteBackFile )
1127 { 1128 {
1128 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 1129 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
1129 storage->save(); 1130 storage->save();
1130 } 1131 }
1131 } 1132 }
1132 setModified( true ); 1133 setModified( true );
1133 } 1134 }
1134 delete storage; 1135 delete storage;
1135 delete calendar; 1136 delete calendar;
1136 if ( syncOK ) 1137 if ( syncOK )
1137 updateView(); 1138 updateView();
1138 return syncOK; 1139 return syncOK;
1139} 1140}
1140void CalendarView::syncSharp() 1141void CalendarView::syncSharp()
1141{ 1142{
1142#ifndef DESKTOP_VERSION 1143#ifndef DESKTOP_VERSION
1143 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1144 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1144 //mCurrentSyncDevice = "sharp-DTM"; 1145 //mCurrentSyncDevice = "sharp-DTM";
1145 if ( KOPrefs::instance()->mAskForPreferences ) 1146 if ( KOPrefs::instance()->mAskForPreferences )
1146 edit_sync_options(); 1147 edit_sync_options();
1147 qApp->processEvents(); 1148 qApp->processEvents();
1148 CalendarLocal* calendar = new CalendarLocal(); 1149 CalendarLocal* calendar = new CalendarLocal();
1149 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1150 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1150 bool syncOK = false; 1151 bool syncOK = false;
1151 SharpFormat sharpFormat; 1152 SharpFormat sharpFormat;
1152 if ( sharpFormat.load( calendar, mCalendar ) ) { 1153 if ( sharpFormat.load( calendar, mCalendar ) ) {
1153 getEventViewerDialog()->setSyncMode( true ); 1154 getEventViewerDialog()->setSyncMode( true );
1154 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); 1155 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
1155 getEventViewerDialog()->setSyncMode( false ); 1156 getEventViewerDialog()->setSyncMode( false );
1156 qApp->processEvents(); 1157 qApp->processEvents();
1157 if ( syncOK ) { 1158 if ( syncOK ) {
1158 if ( KOPrefs::instance()->mWriteBackFile ) 1159 if ( KOPrefs::instance()->mWriteBackFile )
1159 { 1160 {
1160 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1161 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1161 Incidence* inc = iL.first(); 1162 Incidence* inc = iL.first();
1162 /* obsolete 1163 /* obsolete
1163 while ( inc ) { 1164 while ( inc ) {
1164 inc->setZaurusStat( inc->revision () ); 1165 inc->setZaurusStat( inc->revision () );
1165 inc = iL.next(); 1166 inc = iL.next();
1166 } 1167 }
1167 */ 1168 */
1168 // pending: clean last sync event description 1169 // pending: clean last sync event description
1169 sharpFormat.save(calendar); 1170 sharpFormat.save(calendar);
1170 iL = calendar->rawIncidences(); 1171 iL = calendar->rawIncidences();
1171 inc = iL.first(); 1172 inc = iL.first();
1172 Incidence* loc; 1173 Incidence* loc;
1173 while ( inc ) { 1174 while ( inc ) {
1174 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1175 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1175 loc = mCalendar->incidence(inc->uid() ); 1176 loc = mCalendar->incidence(inc->uid() );
1176 if ( loc ) { 1177 if ( loc ) {
1177 loc->setZaurusId( inc->zaurusId() ); 1178 loc->setZaurusId( inc->zaurusId() );
1178 loc->setZaurusUid( inc->zaurusUid() ); 1179 loc->setZaurusUid( inc->zaurusUid() );
1179 } 1180 }
1180 } 1181 }
1181 inc = iL.next(); 1182 inc = iL.next();
1182 } 1183 }
1183 Incidence* lse = getLastSyncEvent(); 1184 Incidence* lse = getLastSyncEvent();
1184 if ( lse ) { 1185 if ( lse ) {
1185 lse->setReadOnly( false ); 1186 lse->setReadOnly( false );
1186 lse->setDescription( "" ); 1187 lse->setDescription( "" );
1187 lse->setReadOnly( true ); 1188 lse->setReadOnly( true );
1188 } 1189 }
1189 } 1190 }
1190 } 1191 }
1191 setModified( true ); 1192 setModified( true );
1192 } else { 1193 } else {
1193 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1194 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1194 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1195 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1195 question, i18n("Ok")) ; 1196 question, i18n("Ok")) ;
1196 1197
1197 } 1198 }
1198 delete calendar; 1199 delete calendar;
1199 updateView(); 1200 updateView();
1200 return ;//syncOK; 1201 return ;//syncOK;
1201#endif 1202#endif
1202} 1203}
1203 1204
1204 1205
1205#include <kabc/stdaddressbook.h> 1206#include <kabc/stdaddressbook.h>
1206bool CalendarView::importBday() 1207bool CalendarView::importBday()
1207{ 1208{
1208 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1209 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1209 KABC::AddressBook::Iterator it; 1210 KABC::AddressBook::Iterator it;
1210 int count = 0; 1211 int count = 0;
1211 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1212 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1212 ++count; 1213 ++count;
1213 } 1214 }
1214 QProgressBar bar(count,0 ); 1215 QProgressBar bar(count,0 );
1215 int w = 300; 1216 int w = 300;
1216 if ( QApplication::desktop()->width() < 320 ) 1217 if ( QApplication::desktop()->width() < 320 )
1217 w = 220; 1218 w = 220;
1218 int h = bar.sizeHint().height() ; 1219 int h = bar.sizeHint().height() ;
1219 int dw = QApplication::desktop()->width(); 1220 int dw = QApplication::desktop()->width();
1220 int dh = QApplication::desktop()->height(); 1221 int dh = QApplication::desktop()->height();
1221 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1222 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1222 bar.show(); 1223 bar.show();
1223 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1224 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1224 qApp->processEvents(); 1225 qApp->processEvents();
1225 count = 0; 1226 count = 0;
1226 int addCount = 0; 1227 int addCount = 0;
1227 KCal::Attendee* a = 0; 1228 KCal::Attendee* a = 0;
1228 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1229 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1229 if ( ! bar.isVisible() ) 1230 if ( ! bar.isVisible() )
1230 return false; 1231 return false;
1231 bar.setProgress( count++ ); 1232 bar.setProgress( count++ );
1232 qApp->processEvents(); 1233 qApp->processEvents();
1233 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1234 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1234 if ( (*it).birthday().date().isValid() ){ 1235 if ( (*it).birthday().date().isValid() ){
1235 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1236 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 ) ) 1237 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1237 ++addCount; 1238 ++addCount;
1238 } 1239 }
1239 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1240 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1240 if ( anni.isValid() ){ 1241 if ( anni.isValid() ){
1241 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1242 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 ) ) 1243 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1243 ++addCount; 1244 ++addCount;
1244 } 1245 }
1245 } 1246 }
1246 updateView(); 1247 updateView();
1247 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1248 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1248 return true; 1249 return true;
1249} 1250}
1250 1251
1251bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1252bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1252{ 1253{
1253 //qDebug("addAnni "); 1254 //qDebug("addAnni ");
1254 Event * ev = new Event(); 1255 Event * ev = new Event();
1255 if ( a ) { 1256 if ( a ) {
1256 ev->addAttendee( a ); 1257 ev->addAttendee( a );
1257 } 1258 }
1258 QString kind; 1259 QString kind;
1259 if ( birthday ) 1260 if ( birthday )
1260 kind = i18n( "Birthday" ); 1261 kind = i18n( "Birthday" );
1261 else 1262 else
1262 kind = i18n( "Anniversary" ); 1263 kind = i18n( "Anniversary" );
1263 ev->setSummary( name + " - " + kind ); 1264 ev->setSummary( name + " - " + kind );
1264 ev->setOrganizer( "nobody@nowhere" ); 1265 ev->setOrganizer( "nobody@nowhere" );
1265 ev->setCategories( kind ); 1266 ev->setCategories( kind );
1266 ev->setDtStart( QDateTime(date) ); 1267 ev->setDtStart( QDateTime(date) );
1267 ev->setDtEnd( QDateTime(date) ); 1268 ev->setDtEnd( QDateTime(date) );
1268 ev->setFloats( true ); 1269 ev->setFloats( true );
1269 Recurrence * rec = ev->recurrence(); 1270 Recurrence * rec = ev->recurrence();
1270 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1271 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1271 rec->addYearlyNum( date.month() ); 1272 rec->addYearlyNum( date.month() );
1272 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1273 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1273 delete ev; 1274 delete ev;
1274 return false; 1275 return false;
1275 } 1276 }
1276 return true; 1277 return true;
1277 1278
1278} 1279}
1279bool CalendarView::importQtopia( const QString &categories, 1280bool CalendarView::importQtopia( const QString &categories,
1280 const QString &datebook, 1281 const QString &datebook,
1281 const QString &todolist ) 1282 const QString &todolist )
1282{ 1283{
1283 1284
1284 QtopiaFormat qtopiaFormat; 1285 QtopiaFormat qtopiaFormat;
1285 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1286 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1286 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1287 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1287 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1288 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1288 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1289 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1289 1290
1290 updateView(); 1291 updateView();
1291 return true; 1292 return true;
1292 1293
1293#if 0 1294#if 0
1294 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1295 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1295 mCurrentSyncDevice = "qtopia-XML"; 1296 mCurrentSyncDevice = "qtopia-XML";
1296 if ( KOPrefs::instance()->mAskForPreferences ) 1297 if ( KOPrefs::instance()->mAskForPreferences )
1297 edit_sync_options(); 1298 edit_sync_options();
1298 qApp->processEvents(); 1299 qApp->processEvents();
1299 CalendarLocal* calendar = new CalendarLocal(); 1300 CalendarLocal* calendar = new CalendarLocal();
1300 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1301 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1301 bool syncOK = false; 1302 bool syncOK = false;
1302 QtopiaFormat qtopiaFormat; 1303 QtopiaFormat qtopiaFormat;
1303 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1304 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1304 bool loadOk = true; 1305 bool loadOk = true;
1305 if ( !categories.isEmpty() ) 1306 if ( !categories.isEmpty() )
1306 loadOk = qtopiaFormat.load( calendar, categories ); 1307 loadOk = qtopiaFormat.load( calendar, categories );
1307 if ( loadOk && !datebook.isEmpty() ) 1308 if ( loadOk && !datebook.isEmpty() )
1308 loadOk = qtopiaFormat.load( calendar, datebook ); 1309 loadOk = qtopiaFormat.load( calendar, datebook );
1309 if ( loadOk && !todolist.isEmpty() ) 1310 if ( loadOk && !todolist.isEmpty() )
1310 loadOk = qtopiaFormat.load( calendar, todolist ); 1311 loadOk = qtopiaFormat.load( calendar, todolist );
1311 1312
1312 if ( loadOk ) { 1313 if ( loadOk ) {
1313 getEventViewerDialog()->setSyncMode( true ); 1314 getEventViewerDialog()->setSyncMode( true );
1314 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); 1315 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
1315 getEventViewerDialog()->setSyncMode( false ); 1316 getEventViewerDialog()->setSyncMode( false );
1316 qApp->processEvents(); 1317 qApp->processEvents();
1317 if ( syncOK ) { 1318 if ( syncOK ) {
1318 if ( KOPrefs::instance()->mWriteBackFile ) 1319 if ( KOPrefs::instance()->mWriteBackFile )
1319 { 1320 {
1320 // write back XML file 1321 // write back XML file
1321 1322
1322 } 1323 }
1323 setModified( true ); 1324 setModified( true );
1324 } 1325 }
1325 } else { 1326 } else {
1326 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1327 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1327 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1328 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1328 question, i18n("Ok")) ; 1329 question, i18n("Ok")) ;
1329 } 1330 }
1330 delete calendar; 1331 delete calendar;
1331 updateView(); 1332 updateView();
1332 return syncOK; 1333 return syncOK;
1333 1334
1334 1335
1335#endif 1336#endif
1336 1337
1337} 1338}
1338 1339
1339void CalendarView::setSyncEventsReadOnly() 1340void CalendarView::setSyncEventsReadOnly()
1340{ 1341{
1341 Event * ev; 1342 Event * ev;
1342 QPtrList<Event> eL = mCalendar->rawEvents(); 1343 QPtrList<Event> eL = mCalendar->rawEvents();
1343 ev = eL.first(); 1344 ev = eL.first();
1344 while ( ev ) { 1345 while ( ev ) {
1345 if ( ev->uid().left(21) == QString("last-syncEvent-device") ) 1346 if ( ev->uid().left(21) == QString("last-syncEvent-device") )
1346 ev->setReadOnly( true ); 1347 ev->setReadOnly( true );
1347 ev = eL.next(); 1348 ev = eL.next();
1348 } 1349 }
1349} 1350}
1350bool CalendarView::openCalendar(QString filename, bool merge) 1351bool CalendarView::openCalendar(QString filename, bool merge)
1351{ 1352{
1352 1353
1353 if (filename.isEmpty()) { 1354 if (filename.isEmpty()) {
1354 return false; 1355 return false;
1355 } 1356 }
1356 1357
1357 if (!QFile::exists(filename)) { 1358 if (!QFile::exists(filename)) {
1358 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1359 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1359 return false; 1360 return false;
1360 } 1361 }
1361 1362
1362 globalFlagBlockAgenda = 1; 1363 globalFlagBlockAgenda = 1;
1363 if (!merge) mCalendar->close(); 1364 if (!merge) mCalendar->close();
1364 1365
1365 mStorage->setFileName( filename ); 1366 mStorage->setFileName( filename );
1366 1367
1367 if ( mStorage->load(KOPrefs::instance()->mUseQuicksave) ) { 1368 if ( mStorage->load(KOPrefs::instance()->mUseQuicksave) ) {
1368 if ( merge ) ;//setModified( true ); 1369 if ( merge ) ;//setModified( true );
1369 else { 1370 else {
1370 //setModified( true ); 1371 //setModified( true );
1371 mViewManager->setDocumentId( filename ); 1372 mViewManager->setDocumentId( filename );
1372 mDialogManager->setDocumentId( filename ); 1373 mDialogManager->setDocumentId( filename );
1373 mTodoList->setDocumentId( filename ); 1374 mTodoList->setDocumentId( filename );
1374 } 1375 }
1375 globalFlagBlockAgenda = 2; 1376 globalFlagBlockAgenda = 2;
1376 // if ( getLastSyncEvent() ) 1377 // if ( getLastSyncEvent() )
1377 // getLastSyncEvent()->setReadOnly( true ); 1378 // getLastSyncEvent()->setReadOnly( true );
1378 mCalendar->reInitAlarmSettings(); 1379 mCalendar->reInitAlarmSettings();
1379 setSyncEventsReadOnly(); 1380 setSyncEventsReadOnly();
1380 updateUnmanagedViews(); 1381 updateUnmanagedViews();
1381 updateView(); 1382 updateView();
1382 if ( filename != MainWindow::defaultFileName() ) 1383 if ( filename != MainWindow::defaultFileName() )
1383 saveCalendar( MainWindow::defaultFileName() ); 1384 saveCalendar( MainWindow::defaultFileName() );
1384 loadedFileVersion = QDateTime::currentDateTime(); 1385 loadedFileVersion = QDateTime::currentDateTime();
1385 return true; 1386 return true;
1386 } else { 1387 } else {
1387 // while failing to load, the calendar object could 1388 // while failing to load, the calendar object could
1388 // have become partially populated. Clear it out. 1389 // have become partially populated. Clear it out.
1389 if ( !merge ) mCalendar->close(); 1390 if ( !merge ) mCalendar->close();
1390 1391
1391 KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1392 KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1392 1393
1393 globalFlagBlockAgenda = 2; 1394 globalFlagBlockAgenda = 2;
1394 updateView(); 1395 updateView();
1395 } 1396 }
1396 return false; 1397 return false;
1397} 1398}
1398void CalendarView::setLoadedFileVersion(QDateTime dt) 1399void CalendarView::setLoadedFileVersion(QDateTime dt)
1399{ 1400{
1400 loadedFileVersion = dt; 1401 loadedFileVersion = dt;
1401} 1402}
1402bool CalendarView::checkFileChanged(QString fn) 1403bool CalendarView::checkFileChanged(QString fn)
1403{ 1404{
1404 QFileInfo finf ( fn ); 1405 QFileInfo finf ( fn );
1405 if ( !finf.exists() ) 1406 if ( !finf.exists() )
1406 return true; 1407 return true;
1407 QDateTime dt = finf.lastModified (); 1408 QDateTime dt = finf.lastModified ();
1408 if ( dt <= loadedFileVersion ) 1409 if ( dt <= loadedFileVersion )
1409 return false; 1410 return false;
1410 return true; 1411 return true;
1411 1412
1412} 1413}
1413bool CalendarView::checkFileVersion(QString fn) 1414bool CalendarView::checkFileVersion(QString fn)
1414{ 1415{
1415 QFileInfo finf ( fn ); 1416 QFileInfo finf ( fn );
1416 if ( !finf.exists() ) 1417 if ( !finf.exists() )
1417 return true; 1418 return true;
1418 QDateTime dt = finf.lastModified (); 1419 QDateTime dt = finf.lastModified ();
1419 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1420 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1420 //qDebug("file on disk version %s",dt.toString().latin1()); 1421 //qDebug("file on disk version %s",dt.toString().latin1());
1421 if ( dt <= loadedFileVersion ) 1422 if ( dt <= loadedFileVersion )
1422 return true; 1423 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)) , 1424 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"), 1425 i18n("KO/Pi Warning"),i18n("Overwrite"),
1425 i18n("Sync+save")); 1426 i18n("Sync+save"));
1426 1427
1427 if ( km == KMessageBox::Cancel ) 1428 if ( km == KMessageBox::Cancel )
1428 return false; 1429 return false;
1429 if ( km == KMessageBox::Yes ) 1430 if ( km == KMessageBox::Yes )
1430 return true; 1431 return true;
1431 1432
1432 setSyncDevice("deleteaftersync" ); 1433 setSyncDevice("deleteaftersync" );
1433 KOPrefs::instance()->mAskForPreferences = true; 1434 KOPrefs::instance()->mAskForPreferences = true;
1434 KOPrefs::instance()->mSyncAlgoPrefs = 3; 1435 KOPrefs::instance()->mSyncAlgoPrefs = 3;
1435 KOPrefs::instance()->mWriteBackFile = false; 1436 KOPrefs::instance()->mWriteBackFile = false;
1436 KOPrefs::instance()->mWriteBackExistingOnly = false; 1437 KOPrefs::instance()->mWriteBackExistingOnly = false;
1437 KOPrefs::instance()->mShowSyncSummary = false; 1438 KOPrefs::instance()->mShowSyncSummary = false;
1438 syncCalendar( fn, 3 ); 1439 syncCalendar( fn, 3 );
1439 Event * e = getLastSyncEvent(); 1440 Event * e = getLastSyncEvent();
1440 mCalendar->deleteEvent ( e ); 1441 mCalendar->deleteEvent ( e );
1441 updateView(); 1442 updateView();
1442 return true; 1443 return true;
1443} 1444}
1444 1445
1445bool CalendarView::saveCalendar( QString filename ) 1446bool CalendarView::saveCalendar( QString filename )
1446{ 1447{
1447 1448
1448 // Store back all unsaved data into calendar object 1449 // Store back all unsaved data into calendar object
1449 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1450 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1450 if ( mViewManager->currentView() ) 1451 if ( mViewManager->currentView() )
1451 mViewManager->currentView()->flushView(); 1452 mViewManager->currentView()->flushView();
1452 1453
1453 //mStorage->setFileName( filename ); 1454 //mStorage->setFileName( filename );
1454 1455
1455 mStorage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 1456 mStorage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
1456 mStorage->setFileName( filename ); 1457 mStorage->setFileName( filename );
1457 bool success; 1458 bool success;
1458 success = mStorage->save(); 1459 success = mStorage->save();
1459 if ( !success ) { 1460 if ( !success ) {
1460 return false; 1461 return false;
1461 } 1462 }
1462 1463
1463 return true; 1464 return true;
1464} 1465}
1465 1466
1466void CalendarView::closeCalendar() 1467void CalendarView::closeCalendar()
1467{ 1468{
1468 1469
1469 // child windows no longer valid 1470 // child windows no longer valid
1470 emit closingDown(); 1471 emit closingDown();
1471 1472
1472 mCalendar->close(); 1473 mCalendar->close();
1473 setModified(false); 1474 setModified(false);
1474 updateView(); 1475 updateView();
1475} 1476}
1476 1477
1477void CalendarView::archiveCalendar() 1478void CalendarView::archiveCalendar()
1478{ 1479{
1479 mDialogManager->showArchiveDialog(); 1480 mDialogManager->showArchiveDialog();
1480} 1481}
1481 1482
1482 1483
1483void CalendarView::readSettings() 1484void CalendarView::readSettings()
1484{ 1485{
1485 1486
1486 1487
1487 // mViewManager->showAgendaView(); 1488 // mViewManager->showAgendaView();
1488 QString str; 1489 QString str;
1489 //qDebug("CalendarView::readSettings() "); 1490 //qDebug("CalendarView::readSettings() ");
1490 // read settings from the KConfig, supplying reasonable 1491 // read settings from the KConfig, supplying reasonable
1491 // defaults where none are to be found 1492 // defaults where none are to be found
1492 KConfig *config = KOGlobals::config(); 1493 KConfig *config = KOGlobals::config();
1493#ifndef KORG_NOSPLITTER 1494#ifndef KORG_NOSPLITTER
1494 config->setGroup("KOrganizer Geometry"); 1495 config->setGroup("KOrganizer Geometry");
1495 1496
1496 QValueList<int> sizes = config->readIntListEntry("Separator1"); 1497 QValueList<int> sizes = config->readIntListEntry("Separator1");
1497 if (sizes.count() != 2) { 1498 if (sizes.count() != 2) {
1498 sizes << mDateNavigator->minimumSizeHint().width(); 1499 sizes << mDateNavigator->minimumSizeHint().width();
1499 sizes << 300; 1500 sizes << 300;
1500 } 1501 }
1501 mPanner->setSizes(sizes); 1502 mPanner->setSizes(sizes);
1502 1503
1503 sizes = config->readIntListEntry("Separator2"); 1504 sizes = config->readIntListEntry("Separator2");
1504 if ( ( mResourceView && sizes.count() == 4 ) || 1505 if ( ( mResourceView && sizes.count() == 4 ) ||
1505 ( !mResourceView && sizes.count() == 3 ) ) { 1506 ( !mResourceView && sizes.count() == 3 ) ) {
1506 mLeftSplitter->setSizes(sizes); 1507 mLeftSplitter->setSizes(sizes);
1507 } 1508 }
1508#endif 1509#endif
1509 globalFlagBlockAgenda = 1; 1510 globalFlagBlockAgenda = 1;
1510 mViewManager->showAgendaView(); 1511 mViewManager->showAgendaView();
1511 //mViewManager->readSettings( config ); 1512 //mViewManager->readSettings( config );
1512 mTodoList->restoreLayout(config,QString("Todo Layout")); 1513 mTodoList->restoreLayout(config,QString("Todo Layout"));
1513 readFilterSettings(config); 1514 readFilterSettings(config);
1514 config->setGroup( "Views" ); 1515 config->setGroup( "Views" );
1515 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 1516 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
1516 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 1517 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
1517 else if ( dateCount == 7 ) mNavigator->selectWeek(); 1518 else if ( dateCount == 7 ) mNavigator->selectWeek();
1518 else mNavigator->selectDates( dateCount ); 1519 else mNavigator->selectDates( dateCount );
1519 // mViewManager->readSettings( config ); 1520 // mViewManager->readSettings( config );
1520 updateConfig(); 1521 updateConfig();
1521 globalFlagBlockAgenda = 2; 1522 globalFlagBlockAgenda = 2;
1522 mViewManager->readSettings( config ); 1523 mViewManager->readSettings( config );
1523#ifdef DESKTOP_VERSION 1524#ifdef DESKTOP_VERSION
1524 config->setGroup("WidgetLayout"); 1525 config->setGroup("WidgetLayout");
1525 QStringList list; 1526 QStringList list;
1526 list = config->readListEntry("MainLayout"); 1527 list = config->readListEntry("MainLayout");
1527 int x,y,w,h; 1528 int x,y,w,h;
1528 if ( ! list.isEmpty() ) { 1529 if ( ! list.isEmpty() ) {
1529 x = list[0].toInt(); 1530 x = list[0].toInt();
1530 y = list[1].toInt(); 1531 y = list[1].toInt();
1531 w = list[2].toInt(); 1532 w = list[2].toInt();
1532 h = list[3].toInt(); 1533 h = list[3].toInt();
1533 topLevelWidget()->setGeometry(x,y,w,h); 1534 topLevelWidget()->setGeometry(x,y,w,h);
1534 1535
1535 } else { 1536 } else {
1536 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 1537 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
1537 } 1538 }
1538 list = config->readListEntry("EditEventLayout"); 1539 list = config->readListEntry("EditEventLayout");
1539 if ( ! list.isEmpty() ) { 1540 if ( ! list.isEmpty() ) {
1540 x = list[0].toInt(); 1541 x = list[0].toInt();
1541 y = list[1].toInt(); 1542 y = list[1].toInt();
1542 w = list[2].toInt(); 1543 w = list[2].toInt();
1543 h = list[3].toInt(); 1544 h = list[3].toInt();
1544 mEventEditor->setGeometry(x,y,w,h); 1545 mEventEditor->setGeometry(x,y,w,h);
1545 1546
1546 } 1547 }
1547 list = config->readListEntry("EditTodoLayout"); 1548 list = config->readListEntry("EditTodoLayout");
1548 if ( ! list.isEmpty() ) { 1549 if ( ! list.isEmpty() ) {
1549 x = list[0].toInt(); 1550 x = list[0].toInt();
1550 y = list[1].toInt(); 1551 y = list[1].toInt();
1551 w = list[2].toInt(); 1552 w = list[2].toInt();
1552 h = list[3].toInt(); 1553 h = list[3].toInt();
1553 mTodoEditor->setGeometry(x,y,w,h); 1554 mTodoEditor->setGeometry(x,y,w,h);
1554 1555
1555 } 1556 }
1556 list = config->readListEntry("ViewerLayout"); 1557 list = config->readListEntry("ViewerLayout");
1557 if ( ! list.isEmpty() ) { 1558 if ( ! list.isEmpty() ) {
1558 x = list[0].toInt(); 1559 x = list[0].toInt();
1559 y = list[1].toInt(); 1560 y = list[1].toInt();
1560 w = list[2].toInt(); 1561 w = list[2].toInt();
1561 h = list[3].toInt(); 1562 h = list[3].toInt();
1562 getEventViewerDialog()->setGeometry(x,y,w,h); 1563 getEventViewerDialog()->setGeometry(x,y,w,h);
1563 } 1564 }
1564#endif 1565#endif
1565 1566
1566
1567 // pending read sync settings;
1568 mSyncProfileNames.clear();
1569 mSyncProfileNames << "Profile_1";
1570 mSyncProfileNames << "Profile_2";
1571 mSyncProfileNames << "Profile_3";
1572 mSyncProfileNames << "Profile_4";
1573 mSyncProfileNames << "Profile_5";
1574 KSyncProfile* temp = new KSyncProfile ();
1575 temp->setName("Profile_1" );
1576 mSyncProfiles.append( temp );
1577 temp = new KSyncProfile ();
1578 temp->setName("Profile_2" );
1579 mSyncProfiles.append( temp );
1580 temp = new KSyncProfile ();
1581 temp->setName("Profile_3" );
1582 mSyncProfiles.append( temp );
1583 temp = new KSyncProfile ();
1584 temp->setName("Profile_4" );
1585 mSyncProfiles.append( temp );
1586 temp = new KSyncProfile ();
1587 temp->setName("Profile_5" );
1588 mSyncProfiles.append( temp );
1589} 1567}
1590 1568
1591 1569
1592void CalendarView::writeSettings() 1570void CalendarView::writeSettings()
1593{ 1571{
1594 // kdDebug() << "CalendarView::writeSettings" << endl; 1572 // kdDebug() << "CalendarView::writeSettings" << endl;
1595 1573
1596 KConfig *config = KOGlobals::config(); 1574 KConfig *config = KOGlobals::config();
1597 1575
1598#ifndef KORG_NOSPLITTER 1576#ifndef KORG_NOSPLITTER
1599 config->setGroup("KOrganizer Geometry"); 1577 config->setGroup("KOrganizer Geometry");
1600 1578
1601 QValueList<int> list = mPanner->sizes(); 1579 QValueList<int> list = mPanner->sizes();
1602 config->writeEntry("Separator1",list); 1580 config->writeEntry("Separator1",list);
1603 1581
1604 list = mLeftSplitter->sizes(); 1582 list = mLeftSplitter->sizes();
1605 config->writeEntry("Separator2",list); 1583 config->writeEntry("Separator2",list);
1606#endif 1584#endif
1607 1585
1608 mViewManager->writeSettings( config ); 1586 mViewManager->writeSettings( config );
1609 mTodoList->saveLayout(config,QString("Todo Layout")); 1587 mTodoList->saveLayout(config,QString("Todo Layout"));
1610 mDialogManager->writeSettings( config ); 1588 mDialogManager->writeSettings( config );
1611 //KOPrefs::instance()->usrWriteConfig(); 1589 //KOPrefs::instance()->usrWriteConfig();
1612 KOPrefs::instance()->writeConfig(); 1590 KOPrefs::instance()->writeConfig();
1613 1591
1614 writeFilterSettings(config); 1592 writeFilterSettings(config);
1615 1593
1616 config->setGroup( "Views" ); 1594 config->setGroup( "Views" );
1617 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 1595 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
1618 1596
1619#ifdef DESKTOP_VERSION 1597#ifdef DESKTOP_VERSION
1620 config->setGroup("WidgetLayout"); 1598 config->setGroup("WidgetLayout");
1621 QStringList list ;//= config->readListEntry("MainLayout"); 1599 QStringList list ;//= config->readListEntry("MainLayout");
1622 int x,y,w,h; 1600 int x,y,w,h;
1623 QWidget* wid; 1601 QWidget* wid;
1624 wid = topLevelWidget(); 1602 wid = topLevelWidget();
1625 x = wid->geometry().x(); 1603 x = wid->geometry().x();
1626 y = wid->geometry().y(); 1604 y = wid->geometry().y();
1627 w = wid->width(); 1605 w = wid->width();
1628 h = wid->height(); 1606 h = wid->height();
1629 list.clear(); 1607 list.clear();
1630 list << QString::number( x ); 1608 list << QString::number( x );
1631 list << QString::number( y ); 1609 list << QString::number( y );
1632 list << QString::number( w ); 1610 list << QString::number( w );
1633 list << QString::number( h ); 1611 list << QString::number( h );
1634 config->writeEntry("MainLayout",list ); 1612 config->writeEntry("MainLayout",list );
1635 1613
1636 wid = mEventEditor; 1614 wid = mEventEditor;
1637 x = wid->geometry().x(); 1615 x = wid->geometry().x();
1638 y = wid->geometry().y(); 1616 y = wid->geometry().y();
1639 w = wid->width(); 1617 w = wid->width();
1640 h = wid->height(); 1618 h = wid->height();
1641 list.clear(); 1619 list.clear();
1642 list << QString::number( x ); 1620 list << QString::number( x );
1643 list << QString::number( y ); 1621 list << QString::number( y );
1644 list << QString::number( w ); 1622 list << QString::number( w );
1645 list << QString::number( h ); 1623 list << QString::number( h );
1646 config->writeEntry("EditEventLayout",list ); 1624 config->writeEntry("EditEventLayout",list );
1647 1625
1648 wid = mTodoEditor; 1626 wid = mTodoEditor;
1649 x = wid->geometry().x(); 1627 x = wid->geometry().x();
1650 y = wid->geometry().y(); 1628 y = wid->geometry().y();
1651 w = wid->width(); 1629 w = wid->width();
1652 h = wid->height(); 1630 h = wid->height();
1653 list.clear(); 1631 list.clear();
1654 list << QString::number( x ); 1632 list << QString::number( x );
1655 list << QString::number( y ); 1633 list << QString::number( y );
1656 list << QString::number( w ); 1634 list << QString::number( w );
1657 list << QString::number( h ); 1635 list << QString::number( h );
1658 config->writeEntry("EditTodoLayout",list ); 1636 config->writeEntry("EditTodoLayout",list );
1659 wid = getEventViewerDialog(); 1637 wid = getEventViewerDialog();
1660 x = wid->geometry().x(); 1638 x = wid->geometry().x();
1661 y = wid->geometry().y(); 1639 y = wid->geometry().y();
1662 w = wid->width(); 1640 w = wid->width();
1663 h = wid->height(); 1641 h = wid->height();
1664 list.clear(); 1642 list.clear();
1665 list << QString::number( x ); 1643 list << QString::number( x );
1666 list << QString::number( y ); 1644 list << QString::number( y );
1667 list << QString::number( w ); 1645 list << QString::number( w );
1668 list << QString::number( h ); 1646 list << QString::number( h );
1669 config->writeEntry("ViewerLayout",list ); 1647 config->writeEntry("ViewerLayout",list );
1670 wid = mDialogManager->getSearchDialog(); 1648 wid = mDialogManager->getSearchDialog();
1671 if ( wid ) { 1649 if ( wid ) {
1672 x = wid->geometry().x(); 1650 x = wid->geometry().x();
1673 y = wid->geometry().y(); 1651 y = wid->geometry().y();
1674 w = wid->width(); 1652 w = wid->width();
1675 h = wid->height(); 1653 h = wid->height();
1676 list.clear(); 1654 list.clear();
1677 list << QString::number( x ); 1655 list << QString::number( x );
1678 list << QString::number( y ); 1656 list << QString::number( y );
1679 list << QString::number( w ); 1657 list << QString::number( w );
1680 list << QString::number( h ); 1658 list << QString::number( h );
1681 config->writeEntry("SearchLayout",list ); 1659 config->writeEntry("SearchLayout",list );
1682 } 1660 }
1683#endif 1661#endif
1684 1662
1685 1663
1686 config->sync(); 1664 config->sync();
1687} 1665}
1688 1666
1689void CalendarView::readFilterSettings(KConfig *config) 1667void CalendarView::readFilterSettings(KConfig *config)
1690{ 1668{
1691 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 1669 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
1692 1670
1693 mFilters.clear(); 1671 mFilters.clear();
1694 1672
1695 config->setGroup("General"); 1673 config->setGroup("General");
1696 QStringList filterList = config->readListEntry("CalendarFilters"); 1674 QStringList filterList = config->readListEntry("CalendarFilters");
1697 1675
1698 QStringList::ConstIterator it = filterList.begin(); 1676 QStringList::ConstIterator it = filterList.begin();
1699 QStringList::ConstIterator end = filterList.end(); 1677 QStringList::ConstIterator end = filterList.end();
1700 while(it != end) { 1678 while(it != end) {
1701 // kdDebug() << " filter: " << (*it) << endl; 1679 // kdDebug() << " filter: " << (*it) << endl;
1702 1680
1703 CalFilter *filter; 1681 CalFilter *filter;
1704 filter = new CalFilter(*it); 1682 filter = new CalFilter(*it);
1705 config->setGroup("Filter_" + (*it)); 1683 config->setGroup("Filter_" + (*it));
1706 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 1684 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
1707 filter->setCriteria(config->readNumEntry("Criteria",0)); 1685 filter->setCriteria(config->readNumEntry("Criteria",0));
1708 filter->setCategoryList(config->readListEntry("CategoryList")); 1686 filter->setCategoryList(config->readListEntry("CategoryList"));
1709 mFilters.append(filter); 1687 mFilters.append(filter);
1710 1688
1711 ++it; 1689 ++it;
1712 } 1690 }
1713 1691
1714 if (mFilters.count() == 0) { 1692 if (mFilters.count() == 0) {
1715 CalFilter *filter = new CalFilter(i18n("Default")); 1693 CalFilter *filter = new CalFilter(i18n("Default"));
1716 mFilters.append(filter); 1694 mFilters.append(filter);
1717 } 1695 }
1718 mFilterView->updateFilters(); 1696 mFilterView->updateFilters();
1719 config->setGroup("FilterView"); 1697 config->setGroup("FilterView");
1720 1698
1721 mFilterView->blockSignals(true); 1699 mFilterView->blockSignals(true);
1722 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 1700 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
1723 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 1701 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
1724 mFilterView->blockSignals(false); 1702 mFilterView->blockSignals(false);
1725 // We do it manually to avoid it being done twice by the above calls 1703 // We do it manually to avoid it being done twice by the above calls
1726 updateFilter(); 1704 updateFilter();
1727} 1705}
1728 1706
1729void CalendarView::writeFilterSettings(KConfig *config) 1707void CalendarView::writeFilterSettings(KConfig *config)
1730{ 1708{
1731 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 1709 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
1732 1710
1733 QStringList filterList; 1711 QStringList filterList;
1734 1712
1735 CalFilter *filter = mFilters.first(); 1713 CalFilter *filter = mFilters.first();
1736 while(filter) { 1714 while(filter) {
1737 // kdDebug() << " fn: " << filter->name() << endl; 1715 // kdDebug() << " fn: " << filter->name() << endl;
1738 filterList << filter->name(); 1716 filterList << filter->name();
1739 config->setGroup("Filter_" + filter->name()); 1717 config->setGroup("Filter_" + filter->name());
1740 config->writeEntry("Criteria",filter->criteria()); 1718 config->writeEntry("Criteria",filter->criteria());
1741 config->writeEntry("CategoryList",filter->categoryList()); 1719 config->writeEntry("CategoryList",filter->categoryList());
1742 filter = mFilters.next(); 1720 filter = mFilters.next();
1743 } 1721 }
1744 config->setGroup("General"); 1722 config->setGroup("General");
1745 config->writeEntry("CalendarFilters",filterList); 1723 config->writeEntry("CalendarFilters",filterList);
1746 1724
1747 config->setGroup("FilterView"); 1725 config->setGroup("FilterView");
1748 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 1726 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
1749 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 1727 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
1750} 1728}
1751 1729
1752 1730
1753void CalendarView::goToday() 1731void CalendarView::goToday()
1754{ 1732{
1755 mNavigator->selectToday(); 1733 mNavigator->selectToday();
1756} 1734}
1757 1735
1758void CalendarView::goNext() 1736void CalendarView::goNext()
1759{ 1737{
1760 mNavigator->selectNext(); 1738 mNavigator->selectNext();
1761} 1739}
1762 1740
1763void CalendarView::goPrevious() 1741void CalendarView::goPrevious()
1764{ 1742{
1765 mNavigator->selectPrevious(); 1743 mNavigator->selectPrevious();
1766} 1744}
1767void CalendarView::goNextMonth() 1745void CalendarView::goNextMonth()
1768{ 1746{
1769 mNavigator->selectNextMonth(); 1747 mNavigator->selectNextMonth();
1770} 1748}
1771 1749
1772void CalendarView::goPreviousMonth() 1750void CalendarView::goPreviousMonth()
1773{ 1751{
1774 mNavigator->selectPreviousMonth(); 1752 mNavigator->selectPreviousMonth();
1775} 1753}
1776void CalendarView::writeLocale() 1754void CalendarView::writeLocale()
1777{ 1755{
1778 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); 1756 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime );
1779 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); 1757 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday );
1780 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); 1758 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate );
1781 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); 1759 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage );
1782 QString dummy = KOPrefs::instance()->mUserDateFormatLong; 1760 QString dummy = KOPrefs::instance()->mUserDateFormatLong;
1783 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 1761 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
1784 dummy = KOPrefs::instance()->mUserDateFormatShort; 1762 dummy = KOPrefs::instance()->mUserDateFormatShort;
1785 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 1763 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
1786 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, 1764 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving,
1787 KOPrefs::instance()->mDaylightsavingStart, 1765 KOPrefs::instance()->mDaylightsavingStart,
1788 KOPrefs::instance()->mDaylightsavingEnd ); 1766 KOPrefs::instance()->mDaylightsavingEnd );
1789 KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId ); 1767 KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId );
1790} 1768}
1791void CalendarView::updateConfig() 1769void CalendarView::updateConfig()
1792{ 1770{
1793 writeLocale(); 1771 writeLocale();
1794 if ( KOPrefs::instance()->mUseAppColors ) 1772 if ( KOPrefs::instance()->mUseAppColors )
1795 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 1773 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
1796 emit configChanged(); 1774 emit configChanged();
1797 mTodoList->updateConfig(); 1775 mTodoList->updateConfig();
1798 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 1776 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
1799 mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1777 mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1800 // To make the "fill window" configurations work 1778 // To make the "fill window" configurations work
1801 //mViewManager->raiseCurrentView(); 1779 //mViewManager->raiseCurrentView();
1802} 1780}
1803 1781
1804 1782
1805void CalendarView::eventChanged(Event *event) 1783void CalendarView::eventChanged(Event *event)
1806{ 1784{
1807 changeEventDisplay(event,KOGlobals::EVENTEDITED); 1785 changeEventDisplay(event,KOGlobals::EVENTEDITED);
1808 //updateUnmanagedViews(); 1786 //updateUnmanagedViews();
1809} 1787}
1810 1788
1811void CalendarView::eventAdded(Event *event) 1789void CalendarView::eventAdded(Event *event)
1812{ 1790{
1813 changeEventDisplay(event,KOGlobals::EVENTADDED); 1791 changeEventDisplay(event,KOGlobals::EVENTADDED);
1814} 1792}
1815 1793
1816void CalendarView::eventToBeDeleted(Event *) 1794void CalendarView::eventToBeDeleted(Event *)
1817{ 1795{
1818 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 1796 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
1819} 1797}
1820 1798
1821void CalendarView::eventDeleted() 1799void CalendarView::eventDeleted()
1822{ 1800{
1823 changeEventDisplay(0,KOGlobals::EVENTDELETED); 1801 changeEventDisplay(0,KOGlobals::EVENTDELETED);
1824} 1802}
1825void CalendarView::changeTodoDisplay(Todo *which, int action) 1803void CalendarView::changeTodoDisplay(Todo *which, int action)
1826{ 1804{
1827 changeIncidenceDisplay((Incidence *)which, action); 1805 changeIncidenceDisplay((Incidence *)which, action);
1828} 1806}
1829void CalendarView::checkZaurusId( int id, bool todo ) 1807void CalendarView::checkZaurusId( int id, bool todo )
1830{ 1808{
1831 if ( id >= 0 ) { 1809 if ( id >= 0 ) {
1832 Incidence* lse = mCalendar->event( "last-syncEvent-device-Sharp-DTM"); 1810 Incidence* lse = mCalendar->event( "last-syncEvent-device-Sharp-DTM");
1833 if ( lse ) { 1811 if ( lse ) {
1834 QString des = lse->description(); 1812 QString des = lse->description();
1835 QString pref = "e"; 1813 QString pref = "e";
1836 if ( todo ) 1814 if ( todo )
1837 pref = "t"; 1815 pref = "t";
1838 des += pref+ QString::number ( id ) + ","; 1816 des += pref+ QString::number ( id ) + ",";
1839 lse->setReadOnly( false ); 1817 lse->setReadOnly( false );
1840 lse->setDescription( des ); 1818 lse->setDescription( des );
1841 lse->setReadOnly( true ); 1819 lse->setReadOnly( true );
1842 } 1820 }
1843 } 1821 }
1844} 1822}
1845void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 1823void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
1846{ 1824{
1847 updateUnmanagedViews(); 1825 updateUnmanagedViews();
1848 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 1826 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
1849 if ( action == KOGlobals::EVENTDELETED ) { //delete 1827 if ( action == KOGlobals::EVENTDELETED ) { //delete
1850 mCalendar->checkAlarmForIncidence( 0, true ); 1828 mCalendar->checkAlarmForIncidence( 0, true );
1851 if ( mEventViewerDialog ) 1829 if ( mEventViewerDialog )
1852 mEventViewerDialog->hide(); 1830 mEventViewerDialog->hide();
1853 } 1831 }
1854 else 1832 else
1855 mCalendar->checkAlarmForIncidence( which , false ); 1833 mCalendar->checkAlarmForIncidence( which , false );
1856} 1834}
1857 1835
1858// most of the changeEventDisplays() right now just call the view's 1836// most of the changeEventDisplays() right now just call the view's
1859// total update mode, but they SHOULD be recoded to be more refresh-efficient. 1837// total update mode, but they SHOULD be recoded to be more refresh-efficient.
1860void CalendarView::changeEventDisplay(Event *which, int action) 1838void CalendarView::changeEventDisplay(Event *which, int action)
1861{ 1839{
1862 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 1840 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
1863 changeIncidenceDisplay((Incidence *)which, action); 1841 changeIncidenceDisplay((Incidence *)which, action);
1864 mDateNavigator->updateView(); 1842 mDateNavigator->updateView();
1865 //mDialogManager->updateSearchDialog(); 1843 //mDialogManager->updateSearchDialog();
1866 1844
1867 if (which) { 1845 if (which) {
1868 // If there is an event view visible update the display 1846 // If there is an event view visible update the display
1869 mViewManager->currentView()->changeEventDisplay(which,action); 1847 mViewManager->currentView()->changeEventDisplay(which,action);
1870 // TODO: check, if update needed 1848 // TODO: check, if update needed
1871 // if (which->getTodoStatus()) { 1849 // if (which->getTodoStatus()) {
1872 mTodoList->updateView(); 1850 mTodoList->updateView();
1873 // } 1851 // }
1874 } else { 1852 } else {
1875 mViewManager->currentView()->updateView(); 1853 mViewManager->currentView()->updateView();
1876 } 1854 }
1877} 1855}
1878 1856
1879 1857
1880void CalendarView::updateTodoViews() 1858void CalendarView::updateTodoViews()
1881{ 1859{
1882 1860
1883 mTodoList->updateView(); 1861 mTodoList->updateView();
1884 mViewManager->currentView()->updateView(); 1862 mViewManager->currentView()->updateView();
1885 1863
1886} 1864}
1887 1865
1888 1866
1889void CalendarView::updateView(const QDate &start, const QDate &end) 1867void CalendarView::updateView(const QDate &start, const QDate &end)
1890{ 1868{
1891 mTodoList->updateView(); 1869 mTodoList->updateView();
1892 mViewManager->updateView(start, end); 1870 mViewManager->updateView(start, end);
1893 //mDateNavigator->updateView(); 1871 //mDateNavigator->updateView();
1894} 1872}
1895 1873
1896void CalendarView::updateView() 1874void CalendarView::updateView()
1897{ 1875{
1898 DateList tmpList = mNavigator->selectedDates(); 1876 DateList tmpList = mNavigator->selectedDates();
1899 1877
1900 // We assume that the navigator only selects consecutive days. 1878 // We assume that the navigator only selects consecutive days.
1901 updateView( tmpList.first(), tmpList.last() ); 1879 updateView( tmpList.first(), tmpList.last() );
1902} 1880}
1903 1881
1904void CalendarView::updateUnmanagedViews() 1882void CalendarView::updateUnmanagedViews()
1905{ 1883{
1906 mDateNavigator->updateDayMatrix(); 1884 mDateNavigator->updateDayMatrix();
1907} 1885}
1908 1886
1909int CalendarView::msgItemDelete() 1887int CalendarView::msgItemDelete()
1910{ 1888{
1911 return KMessageBox::warningContinueCancel(this, 1889 return KMessageBox::warningContinueCancel(this,
1912 i18n("This item will be\npermanently deleted."), 1890 i18n("This item will be\npermanently deleted."),
1913 i18n("KO/Pi Confirmation"),i18n("Delete")); 1891 i18n("KO/Pi Confirmation"),i18n("Delete"));
1914} 1892}
1915 1893
1916 1894
1917void CalendarView::edit_cut() 1895void CalendarView::edit_cut()
1918{ 1896{
1919 Event *anEvent=0; 1897 Event *anEvent=0;
1920 1898
1921 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 1899 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
1922 1900
1923 if (mViewManager->currentView()->isEventView()) { 1901 if (mViewManager->currentView()->isEventView()) {
1924 if ( incidence && incidence->type() == "Event" ) { 1902 if ( incidence && incidence->type() == "Event" ) {
1925 anEvent = static_cast<Event *>(incidence); 1903 anEvent = static_cast<Event *>(incidence);
1926 } 1904 }
1927 } 1905 }
1928 1906
1929 if (!anEvent) { 1907 if (!anEvent) {
1930 KNotifyClient::beep(); 1908 KNotifyClient::beep();
1931 return; 1909 return;
1932 } 1910 }
1933 DndFactory factory( mCalendar ); 1911 DndFactory factory( mCalendar );
1934 factory.cutEvent(anEvent); 1912 factory.cutEvent(anEvent);
1935 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 1913 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
1936} 1914}
1937 1915
1938void CalendarView::edit_copy() 1916void CalendarView::edit_copy()
1939{ 1917{
1940 Event *anEvent=0; 1918 Event *anEvent=0;
1941 1919
1942 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 1920 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
1943 1921
1944 if (mViewManager->currentView()->isEventView()) { 1922 if (mViewManager->currentView()->isEventView()) {
1945 if ( incidence && incidence->type() == "Event" ) { 1923 if ( incidence && incidence->type() == "Event" ) {
1946 anEvent = static_cast<Event *>(incidence); 1924 anEvent = static_cast<Event *>(incidence);
1947 } 1925 }
1948 } 1926 }
1949 1927
1950 if (!anEvent) { 1928 if (!anEvent) {
1951 KNotifyClient::beep(); 1929 KNotifyClient::beep();
1952 return; 1930 return;
1953 } 1931 }
1954 DndFactory factory( mCalendar ); 1932 DndFactory factory( mCalendar );
1955 factory.copyEvent(anEvent); 1933 factory.copyEvent(anEvent);
1956} 1934}
1957 1935
1958void CalendarView::edit_paste() 1936void CalendarView::edit_paste()
1959{ 1937{
1960 QDate date = mNavigator->selectedDates().first(); 1938 QDate date = mNavigator->selectedDates().first();
1961 1939
1962 DndFactory factory( mCalendar ); 1940 DndFactory factory( mCalendar );
1963 Event *pastedEvent = factory.pasteEvent( date ); 1941 Event *pastedEvent = factory.pasteEvent( date );
1964 1942
1965 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 1943 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
1966} 1944}
1967 1945
1968void CalendarView::edit_options() 1946void CalendarView::edit_options()
1969{ 1947{
1970 mDialogManager->showOptionsDialog(); 1948 mDialogManager->showOptionsDialog();
1971 //writeSettings(); 1949 //writeSettings();
1972} 1950}
1973void CalendarView::edit_sync_options() 1951void CalendarView::edit_sync_options()
1974{ 1952{
1975 //mDialogManager->showSyncOptions(); 1953 //mDialogManager->showSyncOptions();
1976 //KOPrefs::instance()->mSyncAlgoPrefs 1954 //KOPrefs::instance()->mSyncAlgoPrefs
1977 QDialog dia( this, "dia", true ); 1955 QDialog dia( this, "dia", true );
1978 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); 1956 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice );
1979 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); 1957 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia);
1980 QVBoxLayout lay ( &dia ); 1958 QVBoxLayout lay ( &dia );
1981 lay.setSpacing( 2 ); 1959 lay.setSpacing( 2 );
1982 lay.setMargin( 3 ); 1960 lay.setMargin( 3 );
1983 lay.addWidget(&gr); 1961 lay.addWidget(&gr);
1984 QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); 1962 QRadioButton loc ( i18n("Take local entry on conflict"), &gr );
1985 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); 1963 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr );
1986 QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); 1964 QRadioButton newest( i18n("Take newest entry on conflict"), &gr );
1987 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); 1965 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr );
1988 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); 1966 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr );
1989 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); 1967 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr );
1990 //QRadioButton both( i18n("Take both on conflict"), &gr ); 1968 //QRadioButton both( i18n("Take both on conflict"), &gr );
1991 QPushButton pb ( "OK", &dia); 1969 QPushButton pb ( "OK", &dia);
1992 lay.addWidget( &pb ); 1970 lay.addWidget( &pb );
1993 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 1971 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
1994 switch ( KOPrefs::instance()->mSyncAlgoPrefs ) { 1972 switch ( KOPrefs::instance()->mSyncAlgoPrefs ) {
1995 case 0: 1973 case 0:
1996 loc.setChecked( true); 1974 loc.setChecked( true);
1997 break; 1975 break;
1998 case 1: 1976 case 1:
1999 rem.setChecked( true ); 1977 rem.setChecked( true );
2000 break; 1978 break;
2001 case 2: 1979 case 2:
2002 newest.setChecked( true); 1980 newest.setChecked( true);
2003 break; 1981 break;
2004 case 3: 1982 case 3:
2005 ask.setChecked( true); 1983 ask.setChecked( true);
2006 break; 1984 break;
2007 case 4: 1985 case 4:
2008 f_loc.setChecked( true); 1986 f_loc.setChecked( true);
2009 break; 1987 break;
2010 case 5: 1988 case 5:
2011 f_rem.setChecked( true); 1989 f_rem.setChecked( true);
2012 break; 1990 break;
2013 case 6: 1991 case 6:
2014 // both.setChecked( true); 1992 // both.setChecked( true);
2015 break; 1993 break;
2016 default: 1994 default:
2017 break; 1995 break;
2018 } 1996 }
2019 if ( dia.exec() ) { 1997 if ( dia.exec() ) {
2020 KOPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; 1998 KOPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ;
2021 } 1999 }
2022 2000
2023} 2001}
2024 2002
2025void CalendarView::slotSelectPickerDate( QDate d) 2003void CalendarView::slotSelectPickerDate( QDate d)
2026{ 2004{
2027 mDateFrame->hide(); 2005 mDateFrame->hide();
2028 if ( mDatePickerMode == 1 ) { 2006 if ( mDatePickerMode == 1 ) {
2029 mNavigator->slotDaySelect( d ); 2007 mNavigator->slotDaySelect( d );
2030 } else if ( mDatePickerMode == 2 ) { 2008 } else if ( mDatePickerMode == 2 ) {
2031 if ( mMoveIncidence->type() == "Todo" ) { 2009 if ( mMoveIncidence->type() == "Todo" ) {
2032 Todo * to = (Todo *) mMoveIncidence; 2010 Todo * to = (Todo *) mMoveIncidence;
2033 QTime tim; 2011 QTime tim;
2034 if ( to->hasDueDate() ) 2012 if ( to->hasDueDate() )
2035 tim = to->dtDue().time(); 2013 tim = to->dtDue().time();
2036 else { 2014 else {
2037 tim = QTime ( 0,0,0 ); 2015 tim = QTime ( 0,0,0 );
2038 to->setFloats( true ); 2016 to->setFloats( true );
2039 to->setHasDueDate( true ); 2017 to->setHasDueDate( true );
2040 } 2018 }
2041 QDateTime dt ( d,tim ); 2019 QDateTime dt ( d,tim );
2042 to->setDtDue( dt ); 2020 to->setDtDue( dt );
2043 todoChanged( to ); 2021 todoChanged( to );
2044 } else { 2022 } else {
2045 QTime tim = mMoveIncidence->dtStart().time(); 2023 QTime tim = mMoveIncidence->dtStart().time();
2046 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2024 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2047 QDateTime dt ( d,tim ); 2025 QDateTime dt ( d,tim );
2048 mMoveIncidence->setDtStart( dt ); 2026 mMoveIncidence->setDtStart( dt );
2049 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2027 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2050 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2028 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2051 } 2029 }
2052 2030
2053 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2031 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2054 } 2032 }
2055} 2033}
2056 2034
2057void CalendarView::removeCategories() 2035void CalendarView::removeCategories()
2058{ 2036{
2059 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2037 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2060 QStringList catList = KOPrefs::instance()->mCustomCategories; 2038 QStringList catList = KOPrefs::instance()->mCustomCategories;
2061 QStringList catIncList; 2039 QStringList catIncList;
2062 QStringList newCatList; 2040 QStringList newCatList;
2063 Incidence* inc = incList.first(); 2041 Incidence* inc = incList.first();
2064 int i; 2042 int i;
2065 int count = 0; 2043 int count = 0;
2066 while ( inc ) { 2044 while ( inc ) {
2067 newCatList.clear(); 2045 newCatList.clear();
2068 catIncList = inc->categories() ; 2046 catIncList = inc->categories() ;
2069 for( i = 0; i< catIncList.count(); ++i ) { 2047 for( i = 0; i< catIncList.count(); ++i ) {
2070 if ( catList.contains (catIncList[i])) 2048 if ( catList.contains (catIncList[i]))
2071 newCatList.append( catIncList[i] ); 2049 newCatList.append( catIncList[i] );
2072 } 2050 }
2073 newCatList.sort(); 2051 newCatList.sort();
2074 inc->setCategories( newCatList.join(",") ); 2052 inc->setCategories( newCatList.join(",") );
2075 inc = incList.next(); 2053 inc = incList.next();
2076 } 2054 }
2077} 2055}
2078 2056
2079int CalendarView::addCategories() 2057int CalendarView::addCategories()
2080{ 2058{
2081 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2059 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2082 QStringList catList = KOPrefs::instance()->mCustomCategories; 2060 QStringList catList = KOPrefs::instance()->mCustomCategories;
2083 QStringList catIncList; 2061 QStringList catIncList;
2084 Incidence* inc = incList.first(); 2062 Incidence* inc = incList.first();
2085 int i; 2063 int i;
2086 int count = 0; 2064 int count = 0;
2087 while ( inc ) { 2065 while ( inc ) {
2088 catIncList = inc->categories() ; 2066 catIncList = inc->categories() ;
2089 for( i = 0; i< catIncList.count(); ++i ) { 2067 for( i = 0; i< catIncList.count(); ++i ) {
2090 if ( !catList.contains (catIncList[i])) { 2068 if ( !catList.contains (catIncList[i])) {
2091 catList.append( catIncList[i] ); 2069 catList.append( catIncList[i] );
2092 //qDebug("add cat %s ", catIncList[i].latin1()); 2070 //qDebug("add cat %s ", catIncList[i].latin1());
2093 ++count; 2071 ++count;
2094 } 2072 }
2095 } 2073 }
2096 inc = incList.next(); 2074 inc = incList.next();
2097 } 2075 }
2098 catList.sort(); 2076 catList.sort();
2099 KOPrefs::instance()->mCustomCategories = catList; 2077 KOPrefs::instance()->mCustomCategories = catList;
2100 return count; 2078 return count;
2101} 2079}
2102 2080
2103void CalendarView::manageCategories() 2081void CalendarView::manageCategories()
2104{ 2082{
2105 KOCatPrefs* cp = new KOCatPrefs(); 2083 KOCatPrefs* cp = new KOCatPrefs();
2106 cp->show(); 2084 cp->show();
2107 int w =cp->sizeHint().width() ; 2085 int w =cp->sizeHint().width() ;
2108 int h = cp->sizeHint().height() ; 2086 int h = cp->sizeHint().height() ;
2109 int dw = QApplication::desktop()->width(); 2087 int dw = QApplication::desktop()->width();
2110 int dh = QApplication::desktop()->height(); 2088 int dh = QApplication::desktop()->height();
2111 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2089 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2112 if ( !cp->exec() ) { 2090 if ( !cp->exec() ) {
2113 delete cp; 2091 delete cp;
2114 return; 2092 return;
2115 } 2093 }
2116 int count = 0; 2094 int count = 0;
2117 if ( cp->addCat() ) { 2095 if ( cp->addCat() ) {
2118 count = addCategories(); 2096 count = addCategories();
2119 if ( count ) { 2097 if ( count ) {
2120 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2098 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2121 writeSettings(); 2099 writeSettings();
2122 } 2100 }
2123 } else { 2101 } else {
2124 removeCategories(); 2102 removeCategories();
2125 updateView(); 2103 updateView();
2126 } 2104 }
2127 delete cp; 2105 delete cp;
2128} 2106}
2129 2107
2130void CalendarView::beamIncidence(Incidence * Inc) 2108void CalendarView::beamIncidence(Incidence * Inc)
2131{ 2109{
2132 QPtrList<Incidence> delSel ; 2110 QPtrList<Incidence> delSel ;
2133 delSel.append(Inc); 2111 delSel.append(Inc);
2134 beamIncidenceList( delSel ); 2112 beamIncidenceList( delSel );
2135} 2113}
2136void CalendarView::beamCalendar() 2114void CalendarView::beamCalendar()
2137{ 2115{
2138 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2116 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2139 //qDebug("beamCalendar() "); 2117 //qDebug("beamCalendar() ");
2140 beamIncidenceList( delSel ); 2118 beamIncidenceList( delSel );
2141} 2119}
2142void CalendarView::beamFilteredCalendar() 2120void CalendarView::beamFilteredCalendar()
2143{ 2121{
2144 QPtrList<Incidence> delSel = mCalendar->incidences(); 2122 QPtrList<Incidence> delSel = mCalendar->incidences();
2145 //qDebug("beamFilteredCalendar() "); 2123 //qDebug("beamFilteredCalendar() ");
2146 beamIncidenceList( delSel ); 2124 beamIncidenceList( delSel );
2147} 2125}
2148void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2126void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2149{ 2127{
2150 if ( beamDialog->exec () == QDialog::Rejected ) 2128 if ( beamDialog->exec () == QDialog::Rejected )
2151 return; 2129 return;
2152 2130
2153 QString fn = "/tmp/kopibeamfile"; 2131 QString fn = "/tmp/kopibeamfile";
2154 QString mes; 2132 QString mes;
2155 bool createbup = true; 2133 bool createbup = true;
2156 if ( createbup ) { 2134 if ( createbup ) {
2157 QString description = "\n"; 2135 QString description = "\n";
2158 CalendarLocal* cal = new CalendarLocal(); 2136 CalendarLocal* cal = new CalendarLocal();
2159 if ( beamDialog->beamLocal() ) 2137 if ( beamDialog->beamLocal() )
2160 cal->setLocalTime(); 2138 cal->setLocalTime();
2161 else 2139 else
2162 cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 2140 cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
2163 Incidence *incidence = delSel.first(); 2141 Incidence *incidence = delSel.first();
2164 bool addText = false; 2142 bool addText = false;
2165 if ( delSel.count() < 10 ) 2143 if ( delSel.count() < 10 )
2166 addText = true; 2144 addText = true;
2167 else { 2145 else {
2168 description.sprintf(i18n(" %d items?"),delSel.count() ); 2146 description.sprintf(i18n(" %d items?"),delSel.count() );
2169 } 2147 }
2170 while ( incidence ) { 2148 while ( incidence ) {
2171 Incidence *in = incidence->clone(); 2149 Incidence *in = incidence->clone();
2172 if ( addText ) 2150 if ( addText )
2173 description += in->summary() + "\n"; 2151 description += in->summary() + "\n";
2174 cal->addIncidence( in ); 2152 cal->addIncidence( in );
2175 incidence = delSel.next(); 2153 incidence = delSel.next();
2176 } 2154 }
2177 if ( beamDialog->beamVcal() ) { 2155 if ( beamDialog->beamVcal() ) {
2178 fn += ".vcs"; 2156 fn += ".vcs";
2179 FileStorage storage( cal, fn, new VCalFormat ); 2157 FileStorage storage( cal, fn, new VCalFormat );
2180 storage.save(); 2158 storage.save();
2181 } else { 2159 } else {
2182 fn += ".ics"; 2160 fn += ".ics";
2183 FileStorage storage( cal, fn, new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 2161 FileStorage storage( cal, fn, new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
2184 storage.save(); 2162 storage.save();
2185 } 2163 }
2186 delete cal; 2164 delete cal;
2187 mes = i18n("KO/Pi: Ready for beaming"); 2165 mes = i18n("KO/Pi: Ready for beaming");
2188 setCaption(mes); 2166 setCaption(mes);
2189 2167
2190#ifndef DESKTOP_VERSION 2168#ifndef DESKTOP_VERSION
2191 Ir *ir = new Ir( this ); 2169 Ir *ir = new Ir( this );
2192 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 2170 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2193 ir->send( fn, description, "text/x-vCalendar" ); 2171 ir->send( fn, description, "text/x-vCalendar" );
2194#endif 2172#endif
2195 } 2173 }
2196} 2174}
2197void CalendarView::beamDone( Ir *ir ) 2175void CalendarView::beamDone( Ir *ir )
2198{ 2176{
2199#ifndef DESKTOP_VERSION 2177#ifndef DESKTOP_VERSION
2200 delete ir; 2178 delete ir;
2201#endif 2179#endif
2202} 2180}
2203 2181
2204void CalendarView::moveIncidence(Incidence * inc ) 2182void CalendarView::moveIncidence(Incidence * inc )
2205{ 2183{
2206 if ( !inc ) return; 2184 if ( !inc ) return;
2207 // qDebug("showDatePickerForIncidence( ) "); 2185 // qDebug("showDatePickerForIncidence( ) ");
2208 if ( mDateFrame->isVisible() ) 2186 if ( mDateFrame->isVisible() )
2209 mDateFrame->hide(); 2187 mDateFrame->hide();
2210 else { 2188 else {
2211 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; 2189 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ;
2212 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; 2190 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ;
2213 int dw = QApplication::desktop()->width(); 2191 int dw = QApplication::desktop()->width();
2214 int dh = QApplication::desktop()->height(); 2192 int dh = QApplication::desktop()->height();
2215 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2193 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2216 mDateFrame->show(); 2194 mDateFrame->show();
2217 } 2195 }
2218 mDatePickerMode = 2; 2196 mDatePickerMode = 2;
2219 mMoveIncidence = inc ; 2197 mMoveIncidence = inc ;
2220 QDate da; 2198 QDate da;
2221 if ( mMoveIncidence->type() == "Todo" ) { 2199 if ( mMoveIncidence->type() == "Todo" ) {
2222 Todo * to = (Todo *) mMoveIncidence; 2200 Todo * to = (Todo *) mMoveIncidence;
2223 if ( to->hasDueDate() ) 2201 if ( to->hasDueDate() )
2224 da = to->dtDue().date(); 2202 da = to->dtDue().date();
2225 else 2203 else
2226 da = QDate::currentDate(); 2204 da = QDate::currentDate();
2227 } else { 2205 } else {
2228 da = mMoveIncidence->dtStart().date(); 2206 da = mMoveIncidence->dtStart().date();
2229 } 2207 }
2230 mDatePicker->setDate( da ); 2208 mDatePicker->setDate( da );
2231} 2209}
2232void CalendarView::showDatePicker( ) 2210void CalendarView::showDatePicker( )
2233{ 2211{
2234 //qDebug("CalendarView::showDatePicker( ) "); 2212 //qDebug("CalendarView::showDatePicker( ) ");
2235 if ( mDateFrame->isVisible() ) 2213 if ( mDateFrame->isVisible() )
2236 mDateFrame->hide(); 2214 mDateFrame->hide();
2237 else { 2215 else {
2238 int w =mDatePicker->sizeHint().width() ; 2216 int w =mDatePicker->sizeHint().width() ;
2239 int h = mDatePicker->sizeHint().height() ; 2217 int h = mDatePicker->sizeHint().height() ;
2240 int dw = QApplication::desktop()->width(); 2218 int dw = QApplication::desktop()->width();
2241 int dh = QApplication::desktop()->height(); 2219 int dh = QApplication::desktop()->height();
2242 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2220 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2243 mDateFrame->show(); 2221 mDateFrame->show();
2244 } 2222 }
2245 mDatePickerMode = 1; 2223 mDatePickerMode = 1;
2246 mDatePicker->setDate( mNavigator->selectedDates().first() ); 2224 mDatePicker->setDate( mNavigator->selectedDates().first() );
2247} 2225}
2248 2226
2249void CalendarView::showEventEditor() 2227void CalendarView::showEventEditor()
2250{ 2228{
2251#ifdef DESKTOP_VERSION 2229#ifdef DESKTOP_VERSION
2252 mEventEditor->show(); 2230 mEventEditor->show();
2253#else 2231#else
2254 mEventEditor->showMaximized(); 2232 mEventEditor->showMaximized();
2255#endif 2233#endif
2256} 2234}
2257void CalendarView::showTodoEditor() 2235void CalendarView::showTodoEditor()
2258{ 2236{
2259#ifdef DESKTOP_VERSION 2237#ifdef DESKTOP_VERSION
2260 mTodoEditor->show(); 2238 mTodoEditor->show();
2261#else 2239#else
2262 mTodoEditor->showMaximized(); 2240 mTodoEditor->showMaximized();
2263#endif 2241#endif
2264} 2242}
2265void CalendarView::cancelIncidence(Incidence * inc ) 2243void CalendarView::cancelIncidence(Incidence * inc )
2266{ 2244{
2267 inc->setCancelled( ! inc->cancelled() ); 2245 inc->setCancelled( ! inc->cancelled() );
2268 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 2246 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
2269 updateView(); 2247 updateView();
2270} 2248}
2271void CalendarView::cloneIncidence(Incidence * orgInc ) 2249void CalendarView::cloneIncidence(Incidence * orgInc )
2272{ 2250{
2273 Incidence * newInc = orgInc->clone(); 2251 Incidence * newInc = orgInc->clone();
2274 newInc->recreate(); 2252 newInc->recreate();
2275 2253
2276 if ( newInc->type() == "Todo" ) { 2254 if ( newInc->type() == "Todo" ) {
2277 Todo* t = (Todo*) newInc; 2255 Todo* t = (Todo*) newInc;
2278 mTodoEditor->editTodo( t ); 2256 mTodoEditor->editTodo( t );
2279 showTodoEditor(); 2257 showTodoEditor();
2280 if ( mTodoEditor->exec() ) { 2258 if ( mTodoEditor->exec() ) {
2281 mCalendar->addTodo( t ); 2259 mCalendar->addTodo( t );
2282 updateView(); 2260 updateView();
2283 } else { 2261 } else {
2284 delete t; 2262 delete t;
2285 } 2263 }
2286 } 2264 }
2287 else { 2265 else {
2288 Event* e = (Event*) newInc; 2266 Event* e = (Event*) newInc;
2289 mEventEditor->editEvent( e ); 2267 mEventEditor->editEvent( e );
2290 showEventEditor(); 2268 showEventEditor();
2291 if ( mEventEditor->exec() ) { 2269 if ( mEventEditor->exec() ) {
2292 mCalendar->addEvent( e ); 2270 mCalendar->addEvent( e );
2293 updateView(); 2271 updateView();
2294 } else { 2272 } else {
2295 delete e; 2273 delete e;
2296 } 2274 }
2297 } 2275 }
2298} 2276}
2299 2277
2300void CalendarView::newEvent() 2278void CalendarView::newEvent()
2301{ 2279{
2302 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 2280 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
2303 KOAgendaView *aView = mViewManager->agendaView(); 2281 KOAgendaView *aView = mViewManager->agendaView();
2304 if (aView) { 2282 if (aView) {
2305 if (aView->selectionStart().isValid()) { 2283 if (aView->selectionStart().isValid()) {
2306 if (aView->selectedIsAllDay()) { 2284 if (aView->selectedIsAllDay()) {
2307 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 2285 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
2308 } else { 2286 } else {
2309 newEvent(aView->selectionStart(),aView->selectionEnd()); 2287 newEvent(aView->selectionStart(),aView->selectionEnd());
2310 } 2288 }
2311 return; 2289 return;
2312 } 2290 }
2313 } 2291 }
2314 2292
2315 QDate date = mNavigator->selectedDates().first(); 2293 QDate date = mNavigator->selectedDates().first();
2316 QDateTime current = QDateTime::currentDateTime(); 2294 QDateTime current = QDateTime::currentDateTime();
2317 if ( date <= current.date() ) { 2295 if ( date <= current.date() ) {
2318 int hour = current.time().hour() +1; 2296 int hour = current.time().hour() +1;
2319 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 2297 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
2320 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2298 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2321 } else 2299 } else
2322 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 2300 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
2323 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 2301 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
2324 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2302 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2325} 2303}
2326 2304
2327void CalendarView::newEvent(QDateTime fh) 2305void CalendarView::newEvent(QDateTime fh)
2328{ 2306{
2329 newEvent(fh, 2307 newEvent(fh,
2330 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 2308 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
2331} 2309}
2332 2310
2333void CalendarView::newEvent(QDate dt) 2311void CalendarView::newEvent(QDate dt)
2334{ 2312{
2335 newEvent(QDateTime(dt, QTime(0,0,0)), 2313 newEvent(QDateTime(dt, QTime(0,0,0)),
2336 QDateTime(dt, QTime(0,0,0)), true); 2314 QDateTime(dt, QTime(0,0,0)), true);
2337} 2315}
2338 2316
2339void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 2317void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
2340{ 2318{
2341 2319
2342 mEventEditor->newEvent(fromHint,toHint,allDay); 2320 mEventEditor->newEvent(fromHint,toHint,allDay);
2343 if ( mFilterView->filtersEnabled() ) { 2321 if ( mFilterView->filtersEnabled() ) {
2344 CalFilter *filter = mFilterView->selectedFilter(); 2322 CalFilter *filter = mFilterView->selectedFilter();
2345 if (filter && filter->showCategories()) { 2323 if (filter && filter->showCategories()) {
2346 mEventEditor->setCategories(filter->categoryList().join(",") ); 2324 mEventEditor->setCategories(filter->categoryList().join(",") );
2347 } 2325 }
2348 if ( filter ) 2326 if ( filter )
2349 mEventEditor->setSecrecy( filter->getSecrecy() ); 2327 mEventEditor->setSecrecy( filter->getSecrecy() );
2350 } 2328 }
2351 showEventEditor(); 2329 showEventEditor();
2352} 2330}
2353void CalendarView::todoAdded(Todo * t) 2331void CalendarView::todoAdded(Todo * t)
2354{ 2332{
2355 2333
2356 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 2334 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
2357 updateTodoViews(); 2335 updateTodoViews();
2358} 2336}
2359void CalendarView::todoChanged(Todo * t) 2337void CalendarView::todoChanged(Todo * t)
2360{ 2338{
2361 emit todoModified( t, 4 ); 2339 emit todoModified( t, 4 );
2362 // updateTodoViews(); 2340 // updateTodoViews();
2363} 2341}
2364void CalendarView::todoToBeDeleted(Todo *) 2342void CalendarView::todoToBeDeleted(Todo *)
2365{ 2343{
2366 //qDebug("todoToBeDeleted(Todo *) "); 2344 //qDebug("todoToBeDeleted(Todo *) ");
2367 updateTodoViews(); 2345 updateTodoViews();
2368} 2346}
2369void CalendarView::todoDeleted() 2347void CalendarView::todoDeleted()
2370{ 2348{
2371 //qDebug(" todoDeleted()"); 2349 //qDebug(" todoDeleted()");
2372 updateTodoViews(); 2350 updateTodoViews();
2373} 2351}
2374 2352
2375 2353
2376 2354
2377void CalendarView::newTodo() 2355void CalendarView::newTodo()
2378{ 2356{
2379 2357
2380 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); 2358 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true);
2381 if ( mFilterView->filtersEnabled() ) { 2359 if ( mFilterView->filtersEnabled() ) {
2382 CalFilter *filter = mFilterView->selectedFilter(); 2360 CalFilter *filter = mFilterView->selectedFilter();
2383 if (filter && filter->showCategories()) { 2361 if (filter && filter->showCategories()) {
2384 mTodoEditor->setCategories(filter->categoryList().join(",") ); 2362 mTodoEditor->setCategories(filter->categoryList().join(",") );
2385 } 2363 }
2386 if ( filter ) 2364 if ( filter )
2387 mTodoEditor->setSecrecy( filter->getSecrecy() ); 2365 mTodoEditor->setSecrecy( filter->getSecrecy() );
2388 } 2366 }
2389 showTodoEditor(); 2367 showTodoEditor();
2390} 2368}
2391 2369
2392void CalendarView::newSubTodo() 2370void CalendarView::newSubTodo()
2393{ 2371{
2394 Todo *todo = selectedTodo(); 2372 Todo *todo = selectedTodo();
2395 if ( todo ) newSubTodo( todo ); 2373 if ( todo ) newSubTodo( todo );
2396} 2374}
2397 2375
2398void CalendarView::newSubTodo(Todo *parentEvent) 2376void CalendarView::newSubTodo(Todo *parentEvent)
2399{ 2377{
2400 2378
2401 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); 2379 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true);
2402 showTodoEditor(); 2380 showTodoEditor();
2403} 2381}
2404 2382
2405void CalendarView::newFloatingEvent() 2383void CalendarView::newFloatingEvent()
2406{ 2384{
2407 DateList tmpList = mNavigator->selectedDates(); 2385 DateList tmpList = mNavigator->selectedDates();
2408 QDate date = tmpList.first(); 2386 QDate date = tmpList.first();
2409 2387
2410 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 2388 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
2411 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 2389 QDateTime( date, QTime( 12, 0, 0 ) ), true );
2412} 2390}
2413 2391
2414 2392
2415void CalendarView::editEvent( Event *event ) 2393void CalendarView::editEvent( Event *event )
2416{ 2394{
2417 2395
2418 if ( !event ) return; 2396 if ( !event ) return;
2419 if ( event->isReadOnly() ) { 2397 if ( event->isReadOnly() ) {
2420 showEvent( event ); 2398 showEvent( event );
2421 return; 2399 return;
2422 } 2400 }
2423 mEventEditor->editEvent( event , mFlagEditDescription); 2401 mEventEditor->editEvent( event , mFlagEditDescription);
2424 showEventEditor(); 2402 showEventEditor();
2425} 2403}
2426void CalendarView::editJournal( Journal *jour ) 2404void CalendarView::editJournal( Journal *jour )
2427{ 2405{
2428 if ( !jour ) return; 2406 if ( !jour ) return;
2429 mDialogManager->hideSearchDialog(); 2407 mDialogManager->hideSearchDialog();
2430 mViewManager->showJournalView(); 2408 mViewManager->showJournalView();
2431 mNavigator->slotDaySelect( jour->dtStart().date() ); 2409 mNavigator->slotDaySelect( jour->dtStart().date() );
2432} 2410}
2433void CalendarView::editTodo( Todo *todo ) 2411void CalendarView::editTodo( Todo *todo )
2434{ 2412{
2435 if ( !todo ) return; 2413 if ( !todo ) return;
2436 2414
2437 if ( todo->isReadOnly() ) { 2415 if ( todo->isReadOnly() ) {
2438 showTodo( todo ); 2416 showTodo( todo );
2439 return; 2417 return;
2440 } 2418 }
2441 mTodoEditor->editTodo( todo ,mFlagEditDescription); 2419 mTodoEditor->editTodo( todo ,mFlagEditDescription);
2442 showTodoEditor(); 2420 showTodoEditor();
2443 2421
2444} 2422}
2445 2423
2446KOEventViewerDialog* CalendarView::getEventViewerDialog() 2424KOEventViewerDialog* CalendarView::getEventViewerDialog()
2447{ 2425{
2448 if ( !mEventViewerDialog ) { 2426 if ( !mEventViewerDialog ) {
2449 mEventViewerDialog = new KOEventViewerDialog(this); 2427 mEventViewerDialog = new KOEventViewerDialog(this);
2450 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 2428 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
2451 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 2429 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
2452 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 2430 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
2453 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 2431 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
2454 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 2432 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
2455 viewManager(), SLOT( showAgendaView( bool ) ) ); 2433 viewManager(), SLOT( showAgendaView( bool ) ) );
2456 mEventViewerDialog->resize( 640, 480 ); 2434 mEventViewerDialog->resize( 640, 480 );
2457 2435
2458 } 2436 }
2459 return mEventViewerDialog; 2437 return mEventViewerDialog;
2460} 2438}
2461void CalendarView::showEvent(Event *event) 2439void CalendarView::showEvent(Event *event)
2462{ 2440{
2463 getEventViewerDialog()->setEvent(event); 2441 getEventViewerDialog()->setEvent(event);
2464 getEventViewerDialog()->showMe(); 2442 getEventViewerDialog()->showMe();
2465} 2443}
2466 2444
2467void CalendarView::showTodo(Todo *event) 2445void CalendarView::showTodo(Todo *event)
2468{ 2446{
2469 getEventViewerDialog()->setTodo(event); 2447 getEventViewerDialog()->setTodo(event);
2470 getEventViewerDialog()->showMe(); 2448 getEventViewerDialog()->showMe();
2471} 2449}
2472void CalendarView::showJournal( Journal *jour ) 2450void CalendarView::showJournal( Journal *jour )
2473{ 2451{
2474 getEventViewerDialog()->setJournal(jour); 2452 getEventViewerDialog()->setJournal(jour);
2475 getEventViewerDialog()->showMe(); 2453 getEventViewerDialog()->showMe();
2476 2454
2477} 2455}
2478// void CalendarView::todoModified (Todo *event, int changed) 2456// void CalendarView::todoModified (Todo *event, int changed)
2479// { 2457// {
2480// // if (mDialogList.find (event) != mDialogList.end ()) { 2458// // if (mDialogList.find (event) != mDialogList.end ()) {
2481// // kdDebug() << "Todo modified and open" << endl; 2459// // kdDebug() << "Todo modified and open" << endl;
2482// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 2460// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
2483// // temp->modified (changed); 2461// // temp->modified (changed);
2484 2462
2485// // } 2463// // }
2486 2464
2487// mViewManager->updateView(); 2465// mViewManager->updateView();
2488// } 2466// }
2489 2467
2490void CalendarView::appointment_show() 2468void CalendarView::appointment_show()
2491{ 2469{
2492 Event *anEvent = 0; 2470 Event *anEvent = 0;
2493 2471
2494 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2472 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2495 2473
2496 if (mViewManager->currentView()->isEventView()) { 2474 if (mViewManager->currentView()->isEventView()) {
2497 if ( incidence && incidence->type() == "Event" ) { 2475 if ( incidence && incidence->type() == "Event" ) {
2498 anEvent = static_cast<Event *>(incidence); 2476 anEvent = static_cast<Event *>(incidence);
2499 } 2477 }
2500 } 2478 }
2501 2479
2502 if (!anEvent) { 2480 if (!anEvent) {
2503 KNotifyClient::beep(); 2481 KNotifyClient::beep();
2504 return; 2482 return;
2505 } 2483 }
2506 2484
2507 showEvent(anEvent); 2485 showEvent(anEvent);
2508} 2486}
2509 2487
2510void CalendarView::appointment_edit() 2488void CalendarView::appointment_edit()
2511{ 2489{
2512 Event *anEvent = 0; 2490 Event *anEvent = 0;
2513 2491
2514 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2492 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2515 2493
2516 if (mViewManager->currentView()->isEventView()) { 2494 if (mViewManager->currentView()->isEventView()) {
2517 if ( incidence && incidence->type() == "Event" ) { 2495 if ( incidence && incidence->type() == "Event" ) {
2518 anEvent = static_cast<Event *>(incidence); 2496 anEvent = static_cast<Event *>(incidence);
2519 } 2497 }
2520 } 2498 }
2521 2499
2522 if (!anEvent) { 2500 if (!anEvent) {
2523 KNotifyClient::beep(); 2501 KNotifyClient::beep();
2524 return; 2502 return;
2525 } 2503 }
2526 2504
2527 editEvent(anEvent); 2505 editEvent(anEvent);
2528} 2506}
2529 2507
2530void CalendarView::appointment_delete() 2508void CalendarView::appointment_delete()
2531{ 2509{
2532 Event *anEvent = 0; 2510 Event *anEvent = 0;
2533 2511
2534 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2512 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2535 2513
2536 if (mViewManager->currentView()->isEventView()) { 2514 if (mViewManager->currentView()->isEventView()) {
2537 if ( incidence && incidence->type() == "Event" ) { 2515 if ( incidence && incidence->type() == "Event" ) {
2538 anEvent = static_cast<Event *>(incidence); 2516 anEvent = static_cast<Event *>(incidence);
2539 } 2517 }
2540 } 2518 }
2541 2519
2542 if (!anEvent) { 2520 if (!anEvent) {
2543 KNotifyClient::beep(); 2521 KNotifyClient::beep();
2544 return; 2522 return;
2545 } 2523 }
2546 2524
2547 deleteEvent(anEvent); 2525 deleteEvent(anEvent);
2548} 2526}
2549 2527
2550void CalendarView::todo_unsub(Todo *anTodo ) 2528void CalendarView::todo_unsub(Todo *anTodo )
2551{ 2529{
2552 // Todo *anTodo = selectedTodo(); 2530 // Todo *anTodo = selectedTodo();
2553 if (!anTodo) return; 2531 if (!anTodo) return;
2554 if (!anTodo->relatedTo()) return; 2532 if (!anTodo->relatedTo()) return;
2555 anTodo->relatedTo()->removeRelation(anTodo); 2533 anTodo->relatedTo()->removeRelation(anTodo);
2556 anTodo->setRelatedTo(0); 2534 anTodo->setRelatedTo(0);
2557 anTodo->updated(); 2535 anTodo->updated();
2558 anTodo->setRelatedToUid(""); 2536 anTodo->setRelatedToUid("");
2559 setModified(true); 2537 setModified(true);
2560 updateView(); 2538 updateView();
2561} 2539}
2562 2540
2563void CalendarView::deleteTodo(Todo *todo) 2541void CalendarView::deleteTodo(Todo *todo)
2564{ 2542{
2565 if (!todo) { 2543 if (!todo) {
2566 KNotifyClient::beep(); 2544 KNotifyClient::beep();
2567 return; 2545 return;
2568 } 2546 }
2569 if (KOPrefs::instance()->mConfirm) { 2547 if (KOPrefs::instance()->mConfirm) {
2570 switch (msgItemDelete()) { 2548 switch (msgItemDelete()) {
2571 case KMessageBox::Continue: // OK 2549 case KMessageBox::Continue: // OK
2572 if (!todo->relations().isEmpty()) { 2550 if (!todo->relations().isEmpty()) {
2573 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), 2551 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."),
2574 i18n("Delete To-Do")); 2552 i18n("Delete To-Do"));
2575 } else { 2553 } else {
2576 checkZaurusId( todo->zaurusId(), true ); 2554 checkZaurusId( todo->zaurusId(), true );
2577 calendar()->deleteTodo(todo); 2555 calendar()->deleteTodo(todo);
2578 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2556 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2579 updateView(); 2557 updateView();
2580 } 2558 }
2581 break; 2559 break;
2582 } // switch 2560 } // switch
2583 } else { 2561 } else {
2584 if (!todo->relations().isEmpty()) { 2562 if (!todo->relations().isEmpty()) {
2585 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), 2563 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."),
2586 i18n("Delete To-Do")); 2564 i18n("Delete To-Do"));
2587 } else { 2565 } else {
2588 checkZaurusId( todo->zaurusId(), true ); 2566 checkZaurusId( todo->zaurusId(), true );
2589 mCalendar->deleteTodo(todo); 2567 mCalendar->deleteTodo(todo);
2590 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2568 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2591 updateView(); 2569 updateView();
2592 } 2570 }
2593 } 2571 }
2594 emit updateSearchDialog(); 2572 emit updateSearchDialog();
2595} 2573}
2596void CalendarView::deleteJournal(Journal *jour) 2574void CalendarView::deleteJournal(Journal *jour)
2597{ 2575{
2598 if (!jour) { 2576 if (!jour) {
2599 KNotifyClient::beep(); 2577 KNotifyClient::beep();
2600 return; 2578 return;
2601 } 2579 }
2602 if (KOPrefs::instance()->mConfirm) { 2580 if (KOPrefs::instance()->mConfirm) {
2603 switch (msgItemDelete()) { 2581 switch (msgItemDelete()) {
2604 case KMessageBox::Continue: // OK 2582 case KMessageBox::Continue: // OK
2605 calendar()->deleteJournal(jour); 2583 calendar()->deleteJournal(jour);
2606 updateView(); 2584 updateView();
2607 break; 2585 break;
2608 } // switch 2586 } // switch
2609 } else { 2587 } else {
2610 calendar()->deleteJournal(jour);; 2588 calendar()->deleteJournal(jour);;
2611 updateView(); 2589 updateView();
2612 } 2590 }
2613 emit updateSearchDialog(); 2591 emit updateSearchDialog();
2614} 2592}
2615 2593
2616void CalendarView::deleteEvent(Event *anEvent) 2594void CalendarView::deleteEvent(Event *anEvent)
2617{ 2595{
2618 if (!anEvent) { 2596 if (!anEvent) {
2619 KNotifyClient::beep(); 2597 KNotifyClient::beep();
2620 return; 2598 return;
2621 } 2599 }
2622 2600
2623 if (anEvent->recurrence()->doesRecur()) { 2601 if (anEvent->recurrence()->doesRecur()) {
2624 QDate itemDate = mViewManager->currentSelectionDate(); 2602 QDate itemDate = mViewManager->currentSelectionDate();
2625 int km; 2603 int km;
2626 if (!itemDate.isValid()) { 2604 if (!itemDate.isValid()) {
2627 //kdDebug() << "Date Not Valid" << endl; 2605 //kdDebug() << "Date Not Valid" << endl;
2628 if (KOPrefs::instance()->mConfirm) { 2606 if (KOPrefs::instance()->mConfirm) {
2629 km = KMessageBox::warningContinueCancel(this,anEvent->summary() + 2607 km = KMessageBox::warningContinueCancel(this,anEvent->summary() +
2630 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), 2608 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"),
2631 i18n("KO/Pi Confirmation"),i18n("Delete All")); 2609 i18n("KO/Pi Confirmation"),i18n("Delete All"));
2632 if ( km == KMessageBox::Continue ) 2610 if ( km == KMessageBox::Continue )
2633 km = KMessageBox::No; // No = all below 2611 km = KMessageBox::No; // No = all below
2634 } else 2612 } else
2635 km = KMessageBox::No; 2613 km = KMessageBox::No;
2636 } else { 2614 } else {
2637 km = KMessageBox::warningYesNoCancel(this,anEvent->summary() + 2615 km = KMessageBox::warningYesNoCancel(this,anEvent->summary() +
2638 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ 2616 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+
2639 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), 2617 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"),
2640 i18n("KO/Pi Confirmation"),i18n("Current"), 2618 i18n("KO/Pi Confirmation"),i18n("Current"),
2641 i18n("All")); 2619 i18n("All"));
2642 } 2620 }
2643 switch(km) { 2621 switch(km) {
2644 2622
2645 case KMessageBox::No: // Continue // all 2623 case KMessageBox::No: // Continue // all
2646 //qDebug("KMessageBox::No "); 2624 //qDebug("KMessageBox::No ");
2647 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2625 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2648 schedule(Scheduler::Cancel,anEvent); 2626 schedule(Scheduler::Cancel,anEvent);
2649 2627
2650 checkZaurusId( anEvent->zaurusId()); 2628 checkZaurusId( anEvent->zaurusId());
2651 mCalendar->deleteEvent(anEvent); 2629 mCalendar->deleteEvent(anEvent);
2652 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); 2630 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED);
2653 break; 2631 break;
2654 2632
2655 // Disabled because it does not work 2633 // Disabled because it does not work
2656 //#if 0 2634 //#if 0
2657 case KMessageBox::Yes: // just this one 2635 case KMessageBox::Yes: // just this one
2658 //QDate qd = mNavigator->selectedDates().first(); 2636 //QDate qd = mNavigator->selectedDates().first();
2659 //if (!qd.isValid()) { 2637 //if (!qd.isValid()) {
2660 // kdDebug() << "no date selected, or invalid date" << endl; 2638 // kdDebug() << "no date selected, or invalid date" << endl;
2661 // KNotifyClient::beep(); 2639 // KNotifyClient::beep();
2662 // return; 2640 // return;
2663 //} 2641 //}
2664 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); 2642 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1);
2665 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { 2643 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) {
2666 anEvent->addExDate(itemDate); 2644 anEvent->addExDate(itemDate);
2667 int duration = anEvent->recurrence()->duration(); 2645 int duration = anEvent->recurrence()->duration();
2668 if ( duration > 0 ) { 2646 if ( duration > 0 ) {
2669 anEvent->recurrence()->setDuration( duration - 1 ); 2647 anEvent->recurrence()->setDuration( duration - 1 );
2670 } 2648 }
2671 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); 2649 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED);
2672 } 2650 }
2673 break; 2651 break;
2674 //#endif 2652 //#endif
2675 } // switch 2653 } // switch
2676 } else { 2654 } else {
2677 if (KOPrefs::instance()->mConfirm) { 2655 if (KOPrefs::instance()->mConfirm) {
2678 switch (KMessageBox::warningContinueCancel(this,anEvent->summary() + 2656 switch (KMessageBox::warningContinueCancel(this,anEvent->summary() +
2679 i18n("\nAre you sure you want\nto delete this event?"), 2657 i18n("\nAre you sure you want\nto delete this event?"),
2680 i18n("KO/Pi Confirmation"),i18n("Delete"))) { 2658 i18n("KO/Pi Confirmation"),i18n("Delete"))) {
2681 case KMessageBox::Continue: // OK 2659 case KMessageBox::Continue: // OK
2682 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2660 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2683 schedule(Scheduler::Cancel,anEvent); 2661 schedule(Scheduler::Cancel,anEvent);
2684 checkZaurusId( anEvent->zaurusId()); 2662 checkZaurusId( anEvent->zaurusId());
2685 mCalendar->deleteEvent(anEvent); 2663 mCalendar->deleteEvent(anEvent);
2686 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2664 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2687 break; 2665 break;
2688 } // switch 2666 } // switch
2689 } else { 2667 } else {
2690 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2668 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2691 schedule(Scheduler::Cancel,anEvent); 2669 schedule(Scheduler::Cancel,anEvent);
2692 checkZaurusId( anEvent->zaurusId()); 2670 checkZaurusId( anEvent->zaurusId());
2693 mCalendar->deleteEvent(anEvent); 2671 mCalendar->deleteEvent(anEvent);
2694 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2672 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2695 } 2673 }
2696 } // if-else 2674 } // if-else
2697 emit updateSearchDialog(); 2675 emit updateSearchDialog();
2698} 2676}
2699 2677
2700bool CalendarView::deleteEvent(const QString &uid) 2678bool CalendarView::deleteEvent(const QString &uid)
2701{ 2679{
2702 Event *ev = mCalendar->event(uid); 2680 Event *ev = mCalendar->event(uid);
2703 if (ev) { 2681 if (ev) {
2704 deleteEvent(ev); 2682 deleteEvent(ev);
2705 return true; 2683 return true;
2706 } else { 2684 } else {
2707 return false; 2685 return false;
2708 } 2686 }
2709} 2687}
2710 2688
2711/*****************************************************************************/ 2689/*****************************************************************************/
2712 2690
2713void CalendarView::action_mail() 2691void CalendarView::action_mail()
2714{ 2692{
2715#ifndef KORG_NOMAIL 2693#ifndef KORG_NOMAIL
2716 KOMailClient mailClient; 2694 KOMailClient mailClient;
2717 2695
2718 Incidence *incidence = currentSelection(); 2696 Incidence *incidence = currentSelection();
2719 2697
2720 if (!incidence) { 2698 if (!incidence) {
2721 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 2699 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
2722 return; 2700 return;
2723 } 2701 }
2724 if(incidence->attendeeCount() == 0 ) { 2702 if(incidence->attendeeCount() == 0 ) {
2725 KMessageBox::sorry(this, 2703 KMessageBox::sorry(this,
2726 i18n("Can't generate mail:\nNo attendees defined.\n")); 2704 i18n("Can't generate mail:\nNo attendees defined.\n"));
2727 return; 2705 return;
2728 } 2706 }
2729 2707
2730 CalendarLocal cal_tmp; 2708 CalendarLocal cal_tmp;
2731 Event *event = 0; 2709 Event *event = 0;
2732 Event *ev = 0; 2710 Event *ev = 0;
2733 if ( incidence && incidence->type() == "Event" ) { 2711 if ( incidence && incidence->type() == "Event" ) {
2734 event = static_cast<Event *>(incidence); 2712 event = static_cast<Event *>(incidence);
2735 ev = new Event(*event); 2713 ev = new Event(*event);
2736 cal_tmp.addEvent(ev); 2714 cal_tmp.addEvent(ev);
2737 } 2715 }
2738 ICalFormat mForm( KOPrefs::instance()->mUseQuicksave); 2716 ICalFormat mForm( KOPrefs::instance()->mUseQuicksave);
2739 QString attachment = mForm.toString( &cal_tmp ); 2717 QString attachment = mForm.toString( &cal_tmp );
2740 if (ev) delete(ev); 2718 if (ev) delete(ev);
2741 2719
2742 mailClient.mailAttendees(currentSelection(), attachment); 2720 mailClient.mailAttendees(currentSelection(), attachment);
2743 2721
2744#endif 2722#endif
2745 2723
2746#if 0 2724#if 0
2747 Event *anEvent = 0; 2725 Event *anEvent = 0;
2748 if (mViewManager->currentView()->isEventView()) { 2726 if (mViewManager->currentView()->isEventView()) {
2749 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); 2727 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first());
2750 } 2728 }
2751 2729
2752 if (!anEvent) { 2730 if (!anEvent) {
2753 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 2731 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
2754 return; 2732 return;
2755 } 2733 }
2756 if(anEvent->attendeeCount() == 0 ) { 2734 if(anEvent->attendeeCount() == 0 ) {
2757 KMessageBox::sorry(this, 2735 KMessageBox::sorry(this,
2758 i18n("Can't generate mail:\nNo attendees defined.\n")); 2736 i18n("Can't generate mail:\nNo attendees defined.\n"));
2759 return; 2737 return;
2760 } 2738 }
2761 2739
2762 mailobject.emailEvent(anEvent); 2740 mailobject.emailEvent(anEvent);
2763#endif 2741#endif
2764} 2742}
2765 2743
2766 2744
2767void CalendarView::schedule_publish(Incidence *incidence) 2745void CalendarView::schedule_publish(Incidence *incidence)
2768{ 2746{
2769 Event *event = 0; 2747 Event *event = 0;
2770 Todo *todo = 0; 2748 Todo *todo = 0;
2771 2749
2772 if (incidence == 0) { 2750 if (incidence == 0) {
2773 incidence = mViewManager->currentView()->selectedIncidences().first(); 2751 incidence = mViewManager->currentView()->selectedIncidences().first();
2774 if (incidence == 0) { 2752 if (incidence == 0) {
2775 incidence = mTodoList->selectedIncidences().first(); 2753 incidence = mTodoList->selectedIncidences().first();
2776 } 2754 }
2777 } 2755 }
2778 if ( incidence && incidence->type() == "Event" ) { 2756 if ( incidence && incidence->type() == "Event" ) {
2779 event = static_cast<Event *>(incidence); 2757 event = static_cast<Event *>(incidence);
2780 } else { 2758 } else {
2781 if ( incidence && incidence->type() == "Todo" ) { 2759 if ( incidence && incidence->type() == "Todo" ) {
2782 todo = static_cast<Todo *>(incidence); 2760 todo = static_cast<Todo *>(incidence);
2783 } 2761 }
2784 } 2762 }
2785 2763
2786 if (!event && !todo) { 2764 if (!event && !todo) {
2787 KMessageBox::sorry(this,i18n("No event selected.")); 2765 KMessageBox::sorry(this,i18n("No event selected."));
2788 return; 2766 return;
2789 } 2767 }
2790 2768
2791 PublishDialog *publishdlg = new PublishDialog(); 2769 PublishDialog *publishdlg = new PublishDialog();
2792 if (incidence->attendeeCount()>0) { 2770 if (incidence->attendeeCount()>0) {
2793 QPtrList<Attendee> attendees = incidence->attendees(); 2771 QPtrList<Attendee> attendees = incidence->attendees();
2794 attendees.first(); 2772 attendees.first();
2795 while ( attendees.current()!=0 ) { 2773 while ( attendees.current()!=0 ) {
2796 publishdlg->addAttendee(attendees.current()); 2774 publishdlg->addAttendee(attendees.current());
2797 attendees.next(); 2775 attendees.next();
2798 } 2776 }
2799 } 2777 }
2800 bool send = true; 2778 bool send = true;
2801 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { 2779 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) {
2802 if ( publishdlg->exec() != QDialog::Accepted ) 2780 if ( publishdlg->exec() != QDialog::Accepted )
2803 send = false; 2781 send = false;
2804 } 2782 }
2805 if ( send ) { 2783 if ( send ) {
2806 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 2784 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
2807 if ( event ) { 2785 if ( event ) {
2808 Event *ev = new Event(*event); 2786 Event *ev = new Event(*event);
2809 ev->registerObserver(0); 2787 ev->registerObserver(0);
2810 ev->clearAttendees(); 2788 ev->clearAttendees();
2811 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 2789 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
2812 delete(ev); 2790 delete(ev);
2813 } 2791 }
2814 } else { 2792 } else {
2815 if ( todo ) { 2793 if ( todo ) {
2816 Todo *ev = new Todo(*todo); 2794 Todo *ev = new Todo(*todo);
2817 ev->registerObserver(0); 2795 ev->registerObserver(0);
2818 ev->clearAttendees(); 2796 ev->clearAttendees();
2819 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 2797 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
2820 delete(ev); 2798 delete(ev);
2821 } 2799 }
2822 } 2800 }
2823 } 2801 }
2824 } 2802 }
2825 delete publishdlg; 2803 delete publishdlg;
2826} 2804}
2827 2805
2828void CalendarView::schedule_request(Incidence *incidence) 2806void CalendarView::schedule_request(Incidence *incidence)
2829{ 2807{
2830 schedule(Scheduler::Request,incidence); 2808 schedule(Scheduler::Request,incidence);
2831} 2809}
2832 2810
2833void CalendarView::schedule_refresh(Incidence *incidence) 2811void CalendarView::schedule_refresh(Incidence *incidence)
2834{ 2812{
2835 schedule(Scheduler::Refresh,incidence); 2813 schedule(Scheduler::Refresh,incidence);
2836} 2814}
2837 2815
2838void CalendarView::schedule_cancel(Incidence *incidence) 2816void CalendarView::schedule_cancel(Incidence *incidence)
2839{ 2817{
2840 schedule(Scheduler::Cancel,incidence); 2818 schedule(Scheduler::Cancel,incidence);
2841} 2819}
2842 2820
2843void CalendarView::schedule_add(Incidence *incidence) 2821void CalendarView::schedule_add(Incidence *incidence)
2844{ 2822{
2845 schedule(Scheduler::Add,incidence); 2823 schedule(Scheduler::Add,incidence);
2846} 2824}
2847 2825
2848void CalendarView::schedule_reply(Incidence *incidence) 2826void CalendarView::schedule_reply(Incidence *incidence)
2849{ 2827{
2850 schedule(Scheduler::Reply,incidence); 2828 schedule(Scheduler::Reply,incidence);
2851} 2829}
2852 2830
2853void CalendarView::schedule_counter(Incidence *incidence) 2831void CalendarView::schedule_counter(Incidence *incidence)
2854{ 2832{
2855 schedule(Scheduler::Counter,incidence); 2833 schedule(Scheduler::Counter,incidence);
2856} 2834}
2857 2835
2858void CalendarView::schedule_declinecounter(Incidence *incidence) 2836void CalendarView::schedule_declinecounter(Incidence *incidence)
2859{ 2837{
2860 schedule(Scheduler::Declinecounter,incidence); 2838 schedule(Scheduler::Declinecounter,incidence);
2861} 2839}
2862 2840
2863void CalendarView::schedule_publish_freebusy(int daysToPublish) 2841void CalendarView::schedule_publish_freebusy(int daysToPublish)
2864{ 2842{
2865 QDateTime start = QDateTime::currentDateTime(); 2843 QDateTime start = QDateTime::currentDateTime();
2866 QDateTime end = start.addDays(daysToPublish); 2844 QDateTime end = start.addDays(daysToPublish);
2867 2845
2868 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); 2846 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end);
2869 freebusy->setOrganizer(KOPrefs::instance()->email()); 2847 freebusy->setOrganizer(KOPrefs::instance()->email());
2870 2848
2871 2849
2872 PublishDialog *publishdlg = new PublishDialog(); 2850 PublishDialog *publishdlg = new PublishDialog();
2873 if ( publishdlg->exec() == QDialog::Accepted ) { 2851 if ( publishdlg->exec() == QDialog::Accepted ) {
2874 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 2852 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
2875 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { 2853 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) {
2876 delete(freebusy); 2854 delete(freebusy);
2877 } 2855 }
2878 } 2856 }
2879 delete publishdlg; 2857 delete publishdlg;
2880} 2858}
2881 2859
2882void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) 2860void CalendarView::schedule(Scheduler::Method method, Incidence *incidence)
2883{ 2861{
2884 Event *event = 0; 2862 Event *event = 0;
2885 Todo *todo = 0; 2863 Todo *todo = 0;
2886 2864
2887 if (incidence == 0) { 2865 if (incidence == 0) {
2888 incidence = mViewManager->currentView()->selectedIncidences().first(); 2866 incidence = mViewManager->currentView()->selectedIncidences().first();
2889 if (incidence == 0) { 2867 if (incidence == 0) {
2890 incidence = mTodoList->selectedIncidences().first(); 2868 incidence = mTodoList->selectedIncidences().first();
2891 } 2869 }
2892 } 2870 }
2893 if ( incidence && incidence->type() == "Event" ) { 2871 if ( incidence && incidence->type() == "Event" ) {
2894 event = static_cast<Event *>(incidence); 2872 event = static_cast<Event *>(incidence);
2895 } 2873 }
2896 if ( incidence && incidence->type() == "Todo" ) { 2874 if ( incidence && incidence->type() == "Todo" ) {
2897 todo = static_cast<Todo *>(incidence); 2875 todo = static_cast<Todo *>(incidence);
2898 } 2876 }
2899 2877
2900 if (!event && !todo) { 2878 if (!event && !todo) {
2901 KMessageBox::sorry(this,i18n("No event selected.")); 2879 KMessageBox::sorry(this,i18n("No event selected."));
2902 return; 2880 return;
2903 } 2881 }
2904 2882
2905 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { 2883 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) {
2906 KMessageBox::sorry(this,i18n("The event has no attendees.")); 2884 KMessageBox::sorry(this,i18n("The event has no attendees."));
2907 return; 2885 return;
2908 } 2886 }
2909 2887
2910 Event *ev = 0; 2888 Event *ev = 0;
2911 if (event) ev = new Event(*event); 2889 if (event) ev = new Event(*event);
2912 Todo *to = 0; 2890 Todo *to = 0;
2913 if (todo) to = new Todo(*todo); 2891 if (todo) to = new Todo(*todo);
2914 2892
2915 if (method == Scheduler::Reply || method == Scheduler::Refresh) { 2893 if (method == Scheduler::Reply || method == Scheduler::Refresh) {
2916 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 2894 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
2917 if (!me) { 2895 if (!me) {
2918 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); 2896 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails."));
2919 return; 2897 return;
2920 } 2898 }
2921 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { 2899 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) {
2922 StatusDialog *statdlg = new StatusDialog(this); 2900 StatusDialog *statdlg = new StatusDialog(this);
2923 if (!statdlg->exec()==QDialog::Accepted) return; 2901 if (!statdlg->exec()==QDialog::Accepted) return;
2924 me->setStatus( statdlg->status() ); 2902 me->setStatus( statdlg->status() );
2925 delete(statdlg); 2903 delete(statdlg);
2926 } 2904 }
2927 Attendee *menew = new Attendee(*me); 2905 Attendee *menew = new Attendee(*me);
2928 if (ev) { 2906 if (ev) {
2929 ev->clearAttendees(); 2907 ev->clearAttendees();
2930 ev->addAttendee(menew,false); 2908 ev->addAttendee(menew,false);
2931 } else { 2909 } else {
2932 if (to) { 2910 if (to) {
2933 todo->clearAttendees(); 2911 todo->clearAttendees();
2934 todo->addAttendee(menew,false); 2912 todo->addAttendee(menew,false);
2935 } 2913 }
2936 } 2914 }
2937 } 2915 }
2938 2916
2939 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 2917 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
2940 if (ev) { 2918 if (ev) {
2941 if ( !dlg->addMessage(ev,method) ) delete(ev); 2919 if ( !dlg->addMessage(ev,method) ) delete(ev);
2942 } else { 2920 } else {
2943 if (to) { 2921 if (to) {
2944 if ( !dlg->addMessage(to,method) ) delete(to); 2922 if ( !dlg->addMessage(to,method) ) delete(to);
2945 } 2923 }
2946 } 2924 }
2947} 2925}
2948 2926
2949void CalendarView::openAddressbook() 2927void CalendarView::openAddressbook()
2950{ 2928{
2951 KRun::runCommand("kaddressbook"); 2929 KRun::runCommand("kaddressbook");
2952} 2930}
2953 2931
2954void CalendarView::setModified(bool modified) 2932void CalendarView::setModified(bool modified)
2955{ 2933{
2956 if ( modified ) 2934 if ( modified )
2957 emit signalmodified(); 2935 emit signalmodified();
2958 if (mModified != modified) { 2936 if (mModified != modified) {
2959 mModified = modified; 2937 mModified = modified;
2960 emit modifiedChanged(mModified); 2938 emit modifiedChanged(mModified);
2961 } 2939 }
2962} 2940}
2963 2941
2964bool CalendarView::isReadOnly() 2942bool CalendarView::isReadOnly()
2965{ 2943{
2966 return mReadOnly; 2944 return mReadOnly;
2967} 2945}
2968 2946
2969void CalendarView::setReadOnly(bool readOnly) 2947void CalendarView::setReadOnly(bool readOnly)
2970{ 2948{
2971 if (mReadOnly != readOnly) { 2949 if (mReadOnly != readOnly) {
2972 mReadOnly = readOnly; 2950 mReadOnly = readOnly;
2973 emit readOnlyChanged(mReadOnly); 2951 emit readOnlyChanged(mReadOnly);
2974 } 2952 }
2975} 2953}
2976 2954
2977bool CalendarView::isModified() 2955bool CalendarView::isModified()
2978{ 2956{
2979 return mModified; 2957 return mModified;
2980} 2958}
2981 2959
2982void CalendarView::printSetup() 2960void CalendarView::printSetup()
2983{ 2961{
2984#ifndef KORG_NOPRINTER 2962#ifndef KORG_NOPRINTER
2985 createPrinter(); 2963 createPrinter();
2986 2964
2987 mCalPrinter->setupPrinter(); 2965 mCalPrinter->setupPrinter();
2988#endif 2966#endif
2989} 2967}
2990 2968
2991void CalendarView::print() 2969void CalendarView::print()
2992{ 2970{
2993#ifndef KORG_NOPRINTER 2971#ifndef KORG_NOPRINTER
2994 createPrinter(); 2972 createPrinter();
2995 2973
2996 DateList tmpDateList = mNavigator->selectedDates(); 2974 DateList tmpDateList = mNavigator->selectedDates();
2997 mCalPrinter->print(CalPrinter::Month, 2975 mCalPrinter->print(CalPrinter::Month,
2998 tmpDateList.first(), tmpDateList.last()); 2976 tmpDateList.first(), tmpDateList.last());
2999#endif 2977#endif
3000} 2978}
3001 2979
3002void CalendarView::printPreview() 2980void CalendarView::printPreview()
3003{ 2981{
3004#ifndef KORG_NOPRINTER 2982#ifndef KORG_NOPRINTER
3005 kdDebug() << "CalendarView::printPreview()" << endl; 2983 kdDebug() << "CalendarView::printPreview()" << endl;
3006 2984
3007 createPrinter(); 2985 createPrinter();
3008 2986
3009 DateList tmpDateList = mNavigator->selectedDates(); 2987 DateList tmpDateList = mNavigator->selectedDates();
3010 2988
3011 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), 2989 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(),
3012 tmpDateList.last()); 2990 tmpDateList.last());
3013#endif 2991#endif
3014} 2992}
3015 2993
3016void CalendarView::exportICalendar() 2994void CalendarView::exportICalendar()
3017{ 2995{
3018 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); 2996 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this);
3019 2997
3020 // Force correct extension 2998 // Force correct extension
3021 if (filename.right(4) != ".ics") filename += ".ics"; 2999 if (filename.right(4) != ".ics") filename += ".ics";
3022 3000
3023 FileStorage storage( mCalendar, filename, new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 3001 FileStorage storage( mCalendar, filename, new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
3024 storage.save(); 3002 storage.save();
3025} 3003}
3026 3004
3027bool CalendarView::exportVCalendar( QString filename ) 3005bool CalendarView::exportVCalendar( QString filename )
3028{ 3006{
3029 if (mCalendar->journals().count() > 0) { 3007 if (mCalendar->journals().count() > 0) {
3030 int result = KMessageBox::warningContinueCancel(this, 3008 int result = KMessageBox::warningContinueCancel(this,
3031 i18n("The journal entries can not be\nexported to a vCalendar file."), 3009 i18n("The journal entries can not be\nexported to a vCalendar file."),
3032 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 3010 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
3033 true); 3011 true);
3034 if (result != KMessageBox::Continue) return false; 3012 if (result != KMessageBox::Continue) return false;
3035 } 3013 }
3036 3014
3037 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); 3015 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this);
3038 3016
3039 // Force correct extension 3017 // Force correct extension
3040 if (filename.right(4) != ".vcs") filename += ".vcs"; 3018 if (filename.right(4) != ".vcs") filename += ".vcs";
3041 3019
3042 FileStorage storage( mCalendar, filename, new VCalFormat ); 3020 FileStorage storage( mCalendar, filename, new VCalFormat );
3043 return storage.save(); 3021 return storage.save();
3044 3022
3045} 3023}
3046 3024
3047void CalendarView::eventUpdated(Incidence *) 3025void CalendarView::eventUpdated(Incidence *)
3048{ 3026{
3049 setModified(); 3027 setModified();
3050 // Don't call updateView here. The code, which has caused the update of the 3028 // Don't call updateView here. The code, which has caused the update of the
3051 // event is responsible for updating the view. 3029 // event is responsible for updating the view.
3052 // updateView(); 3030 // updateView();
3053} 3031}
3054 3032
3055void CalendarView::adaptNavigationUnits() 3033void CalendarView::adaptNavigationUnits()
3056{ 3034{
3057 if (mViewManager->currentView()->isEventView()) { 3035 if (mViewManager->currentView()->isEventView()) {
3058 int days = mViewManager->currentView()->currentDateCount(); 3036 int days = mViewManager->currentView()->currentDateCount();
3059 if (days == 1) { 3037 if (days == 1) {
3060 emit changeNavStringPrev(i18n("&Previous Day")); 3038 emit changeNavStringPrev(i18n("&Previous Day"));
3061 emit changeNavStringNext(i18n("&Next Day")); 3039 emit changeNavStringNext(i18n("&Next Day"));
3062 } else { 3040 } else {
3063 emit changeNavStringPrev(i18n("&Previous Week")); 3041 emit changeNavStringPrev(i18n("&Previous Week"));
3064 emit changeNavStringNext(i18n("&Next Week")); 3042 emit changeNavStringNext(i18n("&Next Week"));
3065 } 3043 }
3066 } 3044 }
3067} 3045}
3068 3046
3069void CalendarView::processMainViewSelection( Incidence *incidence ) 3047void CalendarView::processMainViewSelection( Incidence *incidence )
3070{ 3048{
3071 if ( incidence ) mTodoList->clearSelection(); 3049 if ( incidence ) mTodoList->clearSelection();
3072 processIncidenceSelection( incidence ); 3050 processIncidenceSelection( incidence );
3073} 3051}
3074 3052
3075void CalendarView::processTodoListSelection( Incidence *incidence ) 3053void CalendarView::processTodoListSelection( Incidence *incidence )
3076{ 3054{
3077 if ( incidence && mViewManager->currentView() ) { 3055 if ( incidence && mViewManager->currentView() ) {
3078 mViewManager->currentView()->clearSelection(); 3056 mViewManager->currentView()->clearSelection();
3079 } 3057 }
3080 processIncidenceSelection( incidence ); 3058 processIncidenceSelection( incidence );
3081} 3059}
3082 3060
3083void CalendarView::processIncidenceSelection( Incidence *incidence ) 3061void CalendarView::processIncidenceSelection( Incidence *incidence )
3084{ 3062{
3085 if ( incidence == mSelectedIncidence ) return; 3063 if ( incidence == mSelectedIncidence ) return;
3086 3064
3087 mSelectedIncidence = incidence; 3065 mSelectedIncidence = incidence;
3088 3066
3089 emit incidenceSelected( mSelectedIncidence ); 3067 emit incidenceSelected( mSelectedIncidence );
3090 3068
3091 if ( incidence && incidence->type() == "Event" ) { 3069 if ( incidence && incidence->type() == "Event" ) {
3092 Event *event = static_cast<Event *>( incidence ); 3070 Event *event = static_cast<Event *>( incidence );
3093 if ( event->organizer() == KOPrefs::instance()->email() ) { 3071 if ( event->organizer() == KOPrefs::instance()->email() ) {
3094 emit organizerEventsSelected( true ); 3072 emit organizerEventsSelected( true );
3095 } else { 3073 } else {
3096 emit organizerEventsSelected(false); 3074 emit organizerEventsSelected(false);
3097 } 3075 }
3098 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3076 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3099 KOPrefs::instance()->email() ) ) { 3077 KOPrefs::instance()->email() ) ) {
3100 emit groupEventsSelected( true ); 3078 emit groupEventsSelected( true );
3101 } else { 3079 } else {
3102 emit groupEventsSelected(false); 3080 emit groupEventsSelected(false);
3103 } 3081 }
3104 return; 3082 return;
3105 } else { 3083 } else {
3106 if ( incidence && incidence->type() == "Todo" ) { 3084 if ( incidence && incidence->type() == "Todo" ) {
3107 emit todoSelected( true ); 3085 emit todoSelected( true );
3108 Todo *event = static_cast<Todo *>( incidence ); 3086 Todo *event = static_cast<Todo *>( incidence );
3109 if ( event->organizer() == KOPrefs::instance()->email() ) { 3087 if ( event->organizer() == KOPrefs::instance()->email() ) {
3110 emit organizerEventsSelected( true ); 3088 emit organizerEventsSelected( true );
3111 } else { 3089 } else {
3112 emit organizerEventsSelected(false); 3090 emit organizerEventsSelected(false);
3113 } 3091 }
3114 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3092 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3115 KOPrefs::instance()->email() ) ) { 3093 KOPrefs::instance()->email() ) ) {
3116 emit groupEventsSelected( true ); 3094 emit groupEventsSelected( true );
3117 } else { 3095 } else {
3118 emit groupEventsSelected(false); 3096 emit groupEventsSelected(false);
3119 } 3097 }
3120 return; 3098 return;
3121 } else { 3099 } else {
3122 emit todoSelected( false ); 3100 emit todoSelected( false );
3123 emit organizerEventsSelected(false); 3101 emit organizerEventsSelected(false);
3124 emit groupEventsSelected(false); 3102 emit groupEventsSelected(false);
3125 } 3103 }
3126 return; 3104 return;
3127 } 3105 }
3128 3106
3129 /* if ( incidence && incidence->type() == "Todo" ) { 3107 /* if ( incidence && incidence->type() == "Todo" ) {
3130 emit todoSelected( true ); 3108 emit todoSelected( true );
3131 } else { 3109 } else {
3132 emit todoSelected( false ); 3110 emit todoSelected( false );
3133 }*/ 3111 }*/
3134} 3112}
3135 3113
3136 3114
3137void CalendarView::checkClipboard() 3115void CalendarView::checkClipboard()
3138{ 3116{
3139#ifndef KORG_NODND 3117#ifndef KORG_NODND
3140 if (ICalDrag::canDecode(QApplication::clipboard()->data())) { 3118 if (ICalDrag::canDecode(QApplication::clipboard()->data())) {
3141 emit pasteEnabled(true); 3119 emit pasteEnabled(true);
3142 } else { 3120 } else {
3143 emit pasteEnabled(false); 3121 emit pasteEnabled(false);
3144 } 3122 }
3145#endif 3123#endif
3146} 3124}
3147 3125
3148void CalendarView::showDates(const DateList &selectedDates) 3126void CalendarView::showDates(const DateList &selectedDates)
3149{ 3127{
3150 // kdDebug() << "CalendarView::selectDates()" << endl; 3128 // kdDebug() << "CalendarView::selectDates()" << endl;
3151 3129
3152 if ( mViewManager->currentView() ) { 3130 if ( mViewManager->currentView() ) {
3153 updateView( selectedDates.first(), selectedDates.last() ); 3131 updateView( selectedDates.first(), selectedDates.last() );
3154 } else { 3132 } else {
3155 mViewManager->showAgendaView(); 3133 mViewManager->showAgendaView();
3156 } 3134 }
3157 3135
3158 QString selDates; 3136 QString selDates;
3159 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); 3137 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true);
3160 if (selectedDates.first() < selectedDates.last() ) 3138 if (selectedDates.first() < selectedDates.last() )
3161 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); 3139 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true);
3162 topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); 3140 topLevelWidget()->setCaption( i18n("Dates: ") + selDates );
3163 3141
3164} 3142}
3165 3143
3166void CalendarView::editFilters() 3144void CalendarView::editFilters()
3167{ 3145{
3168 // kdDebug() << "CalendarView::editFilters()" << endl; 3146 // kdDebug() << "CalendarView::editFilters()" << endl;
3169 3147
3170 CalFilter *filter = mFilters.first(); 3148 CalFilter *filter = mFilters.first();
3171 while(filter) { 3149 while(filter) {
3172 kdDebug() << " Filter: " << filter->name() << endl; 3150 kdDebug() << " Filter: " << filter->name() << endl;
3173 filter = mFilters.next(); 3151 filter = mFilters.next();
3174 } 3152 }
3175 3153
3176 mDialogManager->showFilterEditDialog(&mFilters); 3154 mDialogManager->showFilterEditDialog(&mFilters);
3177} 3155}
3178void CalendarView::toggleFilter() 3156void CalendarView::toggleFilter()
3179{ 3157{
3180 showFilter(! mFilterView->isVisible()); 3158 showFilter(! mFilterView->isVisible());
3181} 3159}
3182 3160
3183void CalendarView::selectFilter( int fil ) 3161void CalendarView::selectFilter( int fil )
3184{ 3162{
3185 mFilterView->setSelectedFilter( fil ); 3163 mFilterView->setSelectedFilter( fil );
3186} 3164}
3187void CalendarView::showFilter(bool visible) 3165void CalendarView::showFilter(bool visible)
3188{ 3166{
3189 if (visible) mFilterView->show(); 3167 if (visible) mFilterView->show();
3190 else mFilterView->hide(); 3168 else mFilterView->hide();
3191} 3169}
3192void CalendarView::toggleFilerEnabled( ) 3170void CalendarView::toggleFilerEnabled( )
3193{ 3171{
3194 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); 3172 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() );
3195 if ( !mFilterView->filtersEnabled() ) 3173 if ( !mFilterView->filtersEnabled() )
3196 topLevelWidget()->setCaption( i18n("Filter disabled ") ); 3174 topLevelWidget()->setCaption( i18n("Filter disabled ") );
3197 3175
3198} 3176}
3199void CalendarView::updateFilter() 3177void CalendarView::updateFilter()
3200{ 3178{
3201 CalFilter *filter = mFilterView->selectedFilter(); 3179 CalFilter *filter = mFilterView->selectedFilter();
3202 if (filter) { 3180 if (filter) {
3203 if (mFilterView->filtersEnabled()) { 3181 if (mFilterView->filtersEnabled()) {
3204 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); 3182 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() );
3205 filter->setEnabled(true); 3183 filter->setEnabled(true);
3206 } 3184 }
3207 else filter->setEnabled(false); 3185 else filter->setEnabled(false);
3208 mCalendar->setFilter(filter); 3186 mCalendar->setFilter(filter);
3209 updateView(); 3187 updateView();
3210 } 3188 }
3211} 3189}
3212 3190
3213void CalendarView::filterEdited() 3191void CalendarView::filterEdited()
3214{ 3192{
3215 mFilterView->updateFilters(); 3193 mFilterView->updateFilters();
3216 updateFilter(); 3194 updateFilter();
3217 writeSettings(); 3195 writeSettings();
3218} 3196}
3219 3197
3220 3198
3221void CalendarView::takeOverEvent() 3199void CalendarView::takeOverEvent()
3222{ 3200{
3223 Incidence *incidence = currentSelection(); 3201 Incidence *incidence = currentSelection();
3224 3202
3225 if (!incidence) return; 3203 if (!incidence) return;
3226 3204
3227 incidence->setOrganizer(KOPrefs::instance()->email()); 3205 incidence->setOrganizer(KOPrefs::instance()->email());
3228 incidence->recreate(); 3206 incidence->recreate();
3229 incidence->setReadOnly(false); 3207 incidence->setReadOnly(false);
3230 3208
3231 updateView(); 3209 updateView();
3232} 3210}
3233 3211
3234void CalendarView::takeOverCalendar() 3212void CalendarView::takeOverCalendar()
3235{ 3213{
3236 // TODO: Create Calendar::allIncidences() function and use it here 3214 // TODO: Create Calendar::allIncidences() function and use it here
3237 3215
3238 QPtrList<Event> events = mCalendar->events(); 3216 QPtrList<Event> events = mCalendar->events();
3239 for(uint i=0; i<events.count(); ++i) { 3217 for(uint i=0; i<events.count(); ++i) {
3240 events.at(i)->setOrganizer(KOPrefs::instance()->email()); 3218 events.at(i)->setOrganizer(KOPrefs::instance()->email());
3241 events.at(i)->recreate(); 3219 events.at(i)->recreate();
3242 events.at(i)->setReadOnly(false); 3220 events.at(i)->setReadOnly(false);
3243 } 3221 }
3244 3222
3245 QPtrList<Todo> todos = mCalendar->todos(); 3223 QPtrList<Todo> todos = mCalendar->todos();
3246 for(uint i=0; i<todos.count(); ++i) { 3224 for(uint i=0; i<todos.count(); ++i) {
3247 todos.at(i)->setOrganizer(KOPrefs::instance()->email()); 3225 todos.at(i)->setOrganizer(KOPrefs::instance()->email());
3248 todos.at(i)->recreate(); 3226 todos.at(i)->recreate();
3249 todos.at(i)->setReadOnly(false); 3227 todos.at(i)->setReadOnly(false);
3250 } 3228 }
3251 3229
3252 QPtrList<Journal> journals = mCalendar->journals(); 3230 QPtrList<Journal> journals = mCalendar->journals();
3253 for(uint i=0; i<journals.count(); ++i) { 3231 for(uint i=0; i<journals.count(); ++i) {
3254 journals.at(i)->setOrganizer(KOPrefs::instance()->email()); 3232 journals.at(i)->setOrganizer(KOPrefs::instance()->email());
3255 journals.at(i)->recreate(); 3233 journals.at(i)->recreate();
3256 journals.at(i)->setReadOnly(false); 3234 journals.at(i)->setReadOnly(false);
3257 } 3235 }
3258 3236
3259 updateView(); 3237 updateView();
3260} 3238}
3261 3239
3262void CalendarView::showIntro() 3240void CalendarView::showIntro()
3263{ 3241{
3264 kdDebug() << "To be implemented." << endl; 3242 kdDebug() << "To be implemented." << endl;
3265} 3243}
3266 3244
3267QWidgetStack *CalendarView::viewStack() 3245QWidgetStack *CalendarView::viewStack()
3268{ 3246{
3269 return mRightFrame; 3247 return mRightFrame;
3270} 3248}
3271 3249
3272QWidget *CalendarView::leftFrame() 3250QWidget *CalendarView::leftFrame()
3273{ 3251{
3274 return mLeftFrame; 3252 return mLeftFrame;
3275} 3253}
3276 3254
3277DateNavigator *CalendarView::dateNavigator() 3255DateNavigator *CalendarView::dateNavigator()
3278{ 3256{
3279 return mNavigator; 3257 return mNavigator;
3280} 3258}
3281 3259
3282KDateNavigator* CalendarView::dateNavigatorWidget() 3260KDateNavigator* CalendarView::dateNavigatorWidget()
3283{ 3261{
3284 return mDateNavigator; 3262 return mDateNavigator;
3285} 3263}
3286void CalendarView::toggleDateNavigatorWidget() 3264void CalendarView::toggleDateNavigatorWidget()
3287{ 3265{
3288 if (mDateNavigator->isVisible()) 3266 if (mDateNavigator->isVisible())
3289 mDateNavigator->hide(); 3267 mDateNavigator->hide();
3290 else 3268 else
3291 mDateNavigator->show(); 3269 mDateNavigator->show();
3292} 3270}
3293void CalendarView::addView(KOrg::BaseView *view) 3271void CalendarView::addView(KOrg::BaseView *view)
3294{ 3272{
3295 mViewManager->addView(view); 3273 mViewManager->addView(view);
3296} 3274}
3297 3275
3298void CalendarView::showView(KOrg::BaseView *view) 3276void CalendarView::showView(KOrg::BaseView *view)
3299{ 3277{
3300 mViewManager->showView(view, mLeftFrame->isVisible()); 3278 mViewManager->showView(view, mLeftFrame->isVisible());
3301} 3279}
3302 3280
3303Incidence *CalendarView::currentSelection() 3281Incidence *CalendarView::currentSelection()
3304{ 3282{
3305 return mViewManager->currentSelection(); 3283 return mViewManager->currentSelection();
3306} 3284}
3307void CalendarView::toggleAllDaySize() 3285void CalendarView::toggleAllDaySize()
3308{ 3286{
3309 /* 3287 /*
3310 if ( KOPrefs::instance()->mAllDaySize > 47 ) 3288 if ( KOPrefs::instance()->mAllDaySize > 47 )
3311 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; 3289 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2;
3312 else 3290 else
3313 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; 3291 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2;
3314 */ 3292 */
3315 viewManager()->agendaView()->toggleAllDay(); 3293 viewManager()->agendaView()->toggleAllDay();
3316} 3294}
3317void CalendarView::toggleExpand() 3295void CalendarView::toggleExpand()
3318{ 3296{
3319 // if ( mLeftFrame->isHidden() ) { 3297 // if ( mLeftFrame->isHidden() ) {
3320 // mLeftFrame->show(); 3298 // mLeftFrame->show();
3321 // emit calendarViewExpanded( false ); 3299 // emit calendarViewExpanded( false );
3322 // } else { 3300 // } else {
3323 // mLeftFrame->hide(); 3301 // mLeftFrame->hide();
3324 // emit calendarViewExpanded( true ); 3302 // emit calendarViewExpanded( true );
3325 // } 3303 // }
3326 3304
3327 globalFlagBlockAgenda = 1; 3305 globalFlagBlockAgenda = 1;
3328 emit calendarViewExpanded( !mLeftFrame->isHidden() ); 3306 emit calendarViewExpanded( !mLeftFrame->isHidden() );
3329 globalFlagBlockAgenda = 5; 3307 globalFlagBlockAgenda = 5;
3330 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); 3308 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() );
3331 //mViewManager->showView( 0, true ); 3309 //mViewManager->showView( 0, true );
3332} 3310}
3333 3311
3334void CalendarView::calendarModified( bool modified, Calendar * ) 3312void CalendarView::calendarModified( bool modified, Calendar * )
3335{ 3313{
3336 setModified( modified ); 3314 setModified( modified );
3337} 3315}
3338 3316
3339Todo *CalendarView::selectedTodo() 3317Todo *CalendarView::selectedTodo()
3340{ 3318{
3341 Incidence *incidence = currentSelection(); 3319 Incidence *incidence = currentSelection();
3342 if ( incidence && incidence->type() == "Todo" ) { 3320 if ( incidence && incidence->type() == "Todo" ) {
3343 return static_cast<Todo *>( incidence ); 3321 return static_cast<Todo *>( incidence );
3344 } 3322 }
3345 3323
3346 incidence = mTodoList->selectedIncidences().first(); 3324 incidence = mTodoList->selectedIncidences().first();
3347 if ( incidence && incidence->type() == "Todo" ) { 3325 if ( incidence && incidence->type() == "Todo" ) {
3348 return static_cast<Todo *>( incidence ); 3326 return static_cast<Todo *>( incidence );
3349 } 3327 }
3350 3328
3351 return 0; 3329 return 0;
3352} 3330}
3353 3331
3354void CalendarView::dialogClosing(Incidence *in) 3332void CalendarView::dialogClosing(Incidence *in)
3355{ 3333{
3356 // mDialogList.remove(in); 3334 // mDialogList.remove(in);
3357} 3335}
3358 3336
3359void CalendarView::showIncidence() 3337void CalendarView::showIncidence()
3360{ 3338{
3361 Incidence *incidence = currentSelection(); 3339 Incidence *incidence = currentSelection();
3362 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3340 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3363 if ( incidence ) { 3341 if ( incidence ) {
3364 ShowIncidenceVisitor v; 3342 ShowIncidenceVisitor v;
3365 v.act( incidence, this ); 3343 v.act( incidence, this );
3366 } 3344 }
3367} 3345}
3368void CalendarView::editIncidenceDescription() 3346void CalendarView::editIncidenceDescription()
3369{ 3347{
3370 mFlagEditDescription = true; 3348 mFlagEditDescription = true;
3371 editIncidence(); 3349 editIncidence();
3372 mFlagEditDescription = false; 3350 mFlagEditDescription = false;
3373} 3351}
3374void CalendarView::editIncidence() 3352void CalendarView::editIncidence()
3375{ 3353{
3376 // qDebug("editIncidence() "); 3354 // qDebug("editIncidence() ");
3377 Incidence *incidence = currentSelection(); 3355 Incidence *incidence = currentSelection();
3378 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3356 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3379 if ( incidence ) { 3357 if ( incidence ) {
3380 EditIncidenceVisitor v; 3358 EditIncidenceVisitor v;
3381 v.act( incidence, this ); 3359 v.act( incidence, this );
3382 } 3360 }
3383} 3361}
3384 3362
3385void CalendarView::deleteIncidence() 3363void CalendarView::deleteIncidence()
3386{ 3364{
3387 Incidence *incidence = currentSelection(); 3365 Incidence *incidence = currentSelection();
3388 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3366 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3389 if ( incidence ) { 3367 if ( incidence ) {
3390 deleteIncidence(incidence); 3368 deleteIncidence(incidence);
3391 } 3369 }
3392} 3370}
3393 3371
3394void CalendarView::showIncidence(Incidence *incidence) 3372void CalendarView::showIncidence(Incidence *incidence)
3395{ 3373{
3396 if ( incidence ) { 3374 if ( incidence ) {
3397 ShowIncidenceVisitor v; 3375 ShowIncidenceVisitor v;
3398 v.act( incidence, this ); 3376 v.act( incidence, this );
3399 } 3377 }
3400} 3378}
3401 3379
3402void CalendarView::editIncidence(Incidence *incidence) 3380void CalendarView::editIncidence(Incidence *incidence)
3403{ 3381{
3404 if ( incidence ) { 3382 if ( incidence ) {
3405 3383
3406 EditIncidenceVisitor v; 3384 EditIncidenceVisitor v;
3407 v.act( incidence, this ); 3385 v.act( incidence, this );
3408 3386
3409 } 3387 }
3410} 3388}
3411 3389
3412void CalendarView::deleteIncidence(Incidence *incidence) 3390void CalendarView::deleteIncidence(Incidence *incidence)
3413{ 3391{
3414 //qDebug(" CalendarView::deleteIncidence "); 3392 //qDebug(" CalendarView::deleteIncidence ");
3415 if ( incidence ) { 3393 if ( incidence ) {
3416 DeleteIncidenceVisitor v; 3394 DeleteIncidenceVisitor v;
3417 v.act( incidence, this ); 3395 v.act( incidence, this );
3418 } 3396 }
3419} 3397}
3420 3398
3421 3399
3422void CalendarView::lookForOutgoingMessages() 3400void CalendarView::lookForOutgoingMessages()
3423{ 3401{
3424 OutgoingDialog *ogd = mDialogManager->outgoingDialog(); 3402 OutgoingDialog *ogd = mDialogManager->outgoingDialog();
3425 ogd->loadMessages(); 3403 ogd->loadMessages();
3426} 3404}
3427 3405
3428void CalendarView::lookForIncomingMessages() 3406void CalendarView::lookForIncomingMessages()
3429{ 3407{
3430 IncomingDialog *icd = mDialogManager->incomingDialog(); 3408 IncomingDialog *icd = mDialogManager->incomingDialog();
3431 icd->retrieve(); 3409 icd->retrieve();
3432} 3410}
3433 3411
3434bool CalendarView::removeCompletedSubTodos( Todo* t ) 3412bool CalendarView::removeCompletedSubTodos( Todo* t )
3435{ 3413{
3436 bool deleteTodo = true; 3414 bool deleteTodo = true;
3437 QPtrList<Incidence> subTodos; 3415 QPtrList<Incidence> subTodos;
3438 Incidence *aTodo; 3416 Incidence *aTodo;
3439 subTodos = t->relations(); 3417 subTodos = t->relations();
3440 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { 3418 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
3441 if (! removeCompletedSubTodos( (Todo*) aTodo )) 3419 if (! removeCompletedSubTodos( (Todo*) aTodo ))
3442 deleteTodo = false; 3420 deleteTodo = false;
3443 } 3421 }
3444 if ( deleteTodo ) { 3422 if ( deleteTodo ) {
3445 if ( t->isCompleted() ) { 3423 if ( t->isCompleted() ) {
3446 checkZaurusId( t->zaurusId(), true ); 3424 checkZaurusId( t->zaurusId(), true );
3447 mCalendar->deleteTodo( t ); 3425 mCalendar->deleteTodo( t );
3448 changeTodoDisplay( t,KOGlobals::EVENTDELETED ); 3426 changeTodoDisplay( t,KOGlobals::EVENTDELETED );
3449 } 3427 }
3450 else 3428 else
3451 deleteTodo = false; 3429 deleteTodo = false;
3452 } 3430 }
3453 return deleteTodo; 3431 return deleteTodo;
3454 3432
3455} 3433}
3456void CalendarView::purgeCompleted() 3434void CalendarView::purgeCompleted()
3457{ 3435{
3458 int result = KMessageBox::warningContinueCancel(this, 3436 int result = KMessageBox::warningContinueCancel(this,
3459 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); 3437 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge"));
3460 3438
3461 if (result == KMessageBox::Continue) { 3439 if (result == KMessageBox::Continue) {
3462 3440
3463 QPtrList<Todo> todoCal; 3441 QPtrList<Todo> todoCal;
3464 QPtrList<Todo> rootTodos; 3442 QPtrList<Todo> rootTodos;
3465 //QPtrList<Incidence> rel; 3443 //QPtrList<Incidence> rel;
3466 Todo *aTodo;//, *rTodo; 3444 Todo *aTodo;//, *rTodo;
3467 Incidence *rIncidence; 3445 Incidence *rIncidence;
3468 bool childDelete = false; 3446 bool childDelete = false;
3469 bool deletedOne = true; 3447 bool deletedOne = true;
3470 todoCal = calendar()->todos(); 3448 todoCal = calendar()->todos();
3471 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { 3449 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
3472 if ( !aTodo->relatedTo() ) 3450 if ( !aTodo->relatedTo() )
3473 rootTodos.append( aTodo ); 3451 rootTodos.append( aTodo );
3474 } 3452 }
3475 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { 3453 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) {
3476 removeCompletedSubTodos( aTodo ); 3454 removeCompletedSubTodos( aTodo );
3477 } 3455 }
3478 3456
3479 updateView(); 3457 updateView();
3480 } 3458 }
3481} 3459}
3482 3460
3483void CalendarView::slotCalendarChanged() 3461void CalendarView::slotCalendarChanged()
3484{ 3462{
3485 ; 3463 ;
3486} 3464}
3487 3465
3488NavigatorBar *CalendarView::navigatorBar() 3466NavigatorBar *CalendarView::navigatorBar()
3489{ 3467{
3490 return mNavigatorBar; 3468 return mNavigatorBar;
3491} 3469}
3492 3470
3493 3471
3494 3472
3495void CalendarView::keyPressEvent ( QKeyEvent *e) 3473void CalendarView::keyPressEvent ( QKeyEvent *e)
3496{ 3474{
3497 //qDebug(" alendarView::keyPressEvent "); 3475 //qDebug(" alendarView::keyPressEvent ");
3498 e->ignore(); 3476 e->ignore();
3499} 3477}
3500 3478
3501//#include "calendarview.moc" 3479//#include "calendarview.moc"
3502 3480
3503//#include "calendarviewbase.moc" 3481//#include "calendarviewbase.moc"
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index fda02f7..8aa5e1c 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -1,588 +1,586 @@
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 116
117 signals: 117 signals:
118 /** This todo has been modified */ 118 /** This todo has been modified */
119 void todoModified(Todo *, int); 119 void todoModified(Todo *, int);
120 120
121 /** when change is made to options dialog, the topwidget will catch this 121 /** when change is made to options dialog, the topwidget will catch this
122 * and emit this signal which notifies all widgets which have registered 122 * and emit this signal which notifies all widgets which have registered
123 * for notification to update their settings. */ 123 * for notification to update their settings. */
124 void configChanged(); 124 void configChanged();
125 /** emitted when the topwidget is closing down, so that any attached 125 /** emitted when the topwidget is closing down, so that any attached
126 child windows can also close. */ 126 child windows can also close. */
127 void closingDown(); 127 void closingDown();
128 /** emitted right before we die */ 128 /** emitted right before we die */
129 void closed(QWidget *); 129 void closed(QWidget *);
130 130
131 /** Emitted when state of modified flag changes */ 131 /** Emitted when state of modified flag changes */
132 void modifiedChanged(bool); 132 void modifiedChanged(bool);
133 void signalmodified(); 133 void signalmodified();
134 134
135 /** Emitted when state of read-only flag changes */ 135 /** Emitted when state of read-only flag changes */
136 void readOnlyChanged(bool); 136 void readOnlyChanged(bool);
137 137
138 /** Emitted when the unit of navigation changes */ 138 /** Emitted when the unit of navigation changes */
139 void changeNavStringPrev(const QString &); 139 void changeNavStringPrev(const QString &);
140 void changeNavStringNext(const QString &); 140 void changeNavStringNext(const QString &);
141 141
142 /** Emitted when state of events selection has changed and user is organizer*/ 142 /** Emitted when state of events selection has changed and user is organizer*/
143 void organizerEventsSelected(bool); 143 void organizerEventsSelected(bool);
144 /** Emitted when state of events selection has changed and user is attendee*/ 144 /** Emitted when state of events selection has changed and user is attendee*/
145 void groupEventsSelected(bool); 145 void groupEventsSelected(bool);
146 /** 146 /**
147 Emitted when an incidence gets selected. If the selection is cleared the 147 Emitted when an incidence gets selected. If the selection is cleared the
148 signal is emitted with 0 as argument. 148 signal is emitted with 0 as argument.
149 */ 149 */
150 void incidenceSelected( Incidence * ); 150 void incidenceSelected( Incidence * );
151 /** Emitted, when a todoitem is selected or deselected. */ 151 /** Emitted, when a todoitem is selected or deselected. */
152 void todoSelected( bool ); 152 void todoSelected( bool );
153 153
154 /** 154 /**
155 Emitted, when clipboard content changes. Parameter indicates if paste 155 Emitted, when clipboard content changes. Parameter indicates if paste
156 is possible or not. 156 is possible or not.
157 */ 157 */
158 void pasteEnabled(bool); 158 void pasteEnabled(bool);
159 159
160 /** Emitted, when the number of incoming messages has changed. */ 160 /** Emitted, when the number of incoming messages has changed. */
161 void numIncomingChanged(int); 161 void numIncomingChanged(int);
162 162
163 /** Emitted, when the number of outgoing messages has changed. */ 163 /** Emitted, when the number of outgoing messages has changed. */
164 void numOutgoingChanged(int); 164 void numOutgoingChanged(int);
165 165
166 /** Send status message, which can e.g. be displayed in the status bar. */ 166 /** Send status message, which can e.g. be displayed in the status bar. */
167 void statusMessage(const QString &); 167 void statusMessage(const QString &);
168 168
169 void calendarViewExpanded( bool ); 169 void calendarViewExpanded( bool );
170 void updateSearchDialog(); 170 void updateSearchDialog();
171 171
172 172
173 public slots: 173 public slots:
174 void recheckTimerAlarm(); 174 void recheckTimerAlarm();
175 void checkNextTimerAlarm(); 175 void checkNextTimerAlarm();
176 void addAlarm(const QDateTime &qdt, const QString &noti ); 176 void addAlarm(const QDateTime &qdt, const QString &noti );
177 void addSuspendAlarm(const QDateTime &qdt, const QString &noti ); 177 void addSuspendAlarm(const QDateTime &qdt, const QString &noti );
178 void removeAlarm(const QDateTime &qdt, const QString &noti ); 178 void removeAlarm(const QDateTime &qdt, const QString &noti );
179 179
180 /** options dialog made a changed to the configuration. we catch this 180 /** options dialog made a changed to the configuration. we catch this
181 * and notify all widgets which need to update their configuration. */ 181 * and notify all widgets which need to update their configuration. */
182 void updateConfig(); 182 void updateConfig();
183 183
184 /** 184 /**
185 Load calendar from file \a filename. If \a merge is true, load 185 Load calendar from file \a filename. If \a merge is true, load
186 calendar into existing one, if it is false, clear calendar, before 186 calendar into existing one, if it is false, clear calendar, before
187 loading. Return true, if calendar could be successfully loaded. 187 loading. Return true, if calendar could be successfully loaded.
188 */ 188 */
189 bool openCalendar(QString filename, bool merge=false); 189 bool openCalendar(QString filename, bool merge=false);
190 bool syncCalendar(QString filename,int mode = 0 ); 190 bool syncCalendar(QString filename,int mode = 0 );
191 191
192 /** 192 /**
193 Save calendar data to file. Return true if calendar could be 193 Save calendar data to file. Return true if calendar could be
194 successfully saved. 194 successfully saved.
195 */ 195 */
196 bool saveCalendar(QString filename); 196 bool saveCalendar(QString filename);
197 197
198 /** 198 /**
199 Close calendar. Clear calendar data and reset views to display an empty 199 Close calendar. Clear calendar data and reset views to display an empty
200 calendar. 200 calendar.
201 */ 201 */
202 void closeCalendar(); 202 void closeCalendar();
203 203
204 /** Archive old events of calendar */ 204 /** Archive old events of calendar */
205 void archiveCalendar(); 205 void archiveCalendar();
206 206
207 void showIncidence(); 207 void showIncidence();
208 void editIncidence(); 208 void editIncidence();
209 void editIncidenceDescription(); 209 void editIncidenceDescription();
210 void deleteIncidence(); 210 void deleteIncidence();
211 211
212 /** create an editeventwin with supplied date/time, and if bool is true, 212 /** create an editeventwin with supplied date/time, and if bool is true,
213 * make the event take all day. */ 213 * make the event take all day. */
214 void newEvent(QDateTime, QDateTime, bool allDay = false); 214 void newEvent(QDateTime, QDateTime, bool allDay = false);
215 void newEvent(QDateTime fh); 215 void newEvent(QDateTime fh);
216 void newEvent(QDate dt); 216 void newEvent(QDate dt);
217 /** create new event without having a date hint. Takes current date as 217 /** create new event without having a date hint. Takes current date as
218 default hint. */ 218 default hint. */
219 void newEvent(); 219 void newEvent();
220 void newFloatingEvent(); 220 void newFloatingEvent();
221 221
222 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ 222 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/
223 void showIncidence(Incidence *); 223 void showIncidence(Incidence *);
224 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ 224 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/
225 void editIncidence(Incidence *); 225 void editIncidence(Incidence *);
226 /** Delete the supplied incidence. It calls the correct deleteXXX method*/ 226 /** Delete the supplied incidence. It calls the correct deleteXXX method*/
227 void deleteIncidence(Incidence *); 227 void deleteIncidence(Incidence *);
228 void cloneIncidence(Incidence *); 228 void cloneIncidence(Incidence *);
229 void cancelIncidence(Incidence *); 229 void cancelIncidence(Incidence *);
230 /** Create an editor for the supplied event. */ 230 /** Create an editor for the supplied event. */
231 void editEvent(Event *); 231 void editEvent(Event *);
232 /** Delete the supplied event. */ 232 /** Delete the supplied event. */
233 void deleteEvent(Event *); 233 void deleteEvent(Event *);
234 /** Delete the event with the given unique ID. Returns false, if event wasn't 234 /** Delete the event with the given unique ID. Returns false, if event wasn't
235 found. */ 235 found. */
236 bool deleteEvent(const QString &uid); 236 bool deleteEvent(const QString &uid);
237 /** Create a read-only viewer dialog for the supplied event. */ 237 /** Create a read-only viewer dialog for the supplied event. */
238 void showEvent(Event *); 238 void showEvent(Event *);
239 239
240 void editJournal(Journal *); 240 void editJournal(Journal *);
241 void showJournal(Journal *); 241 void showJournal(Journal *);
242 void deleteJournal(Journal *); 242 void deleteJournal(Journal *);
243 /** Create an editor dialog for a todo */ 243 /** Create an editor dialog for a todo */
244 void editTodo(Todo *); 244 void editTodo(Todo *);
245 /** Create a read-only viewer dialog for the supplied todo */ 245 /** Create a read-only viewer dialog for the supplied todo */
246 void showTodo(Todo *); 246 void showTodo(Todo *);
247 /** create new todo */ 247 /** create new todo */
248 void newTodo(); 248 void newTodo();
249 /** create new todo with a parent todo */ 249 /** create new todo with a parent todo */
250 void newSubTodo(); 250 void newSubTodo();
251 /** create new todo with a parent todo */ 251 /** create new todo with a parent todo */
252 void newSubTodo(Todo *); 252 void newSubTodo(Todo *);
253 /** Delete todo */ 253 /** Delete todo */
254 void deleteTodo(Todo *); 254 void deleteTodo(Todo *);
255 255
256 256
257 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is 257 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is
258 * emitted as result. */ 258 * emitted as result. */
259 void checkClipboard(); 259 void checkClipboard();
260 260
261 /** using the KConfig associated with the kapp variable, read in the 261 /** using the KConfig associated with the kapp variable, read in the
262 * settings from the config file. 262 * settings from the config file.
263 */ 263 */
264 void readSettings(); 264 void readSettings();
265 265
266 /** write current state to config file. */ 266 /** write current state to config file. */
267 void writeSettings(); 267 void writeSettings();
268 268
269 /** read settings for calendar filters */ 269 /** read settings for calendar filters */
270 void readFilterSettings(KConfig *config); 270 void readFilterSettings(KConfig *config);
271 271
272 /** write settings for calendar filters */ 272 /** write settings for calendar filters */
273 void writeFilterSettings(KConfig *config); 273 void writeFilterSettings(KConfig *config);
274 274
275 /** passes on the message that an event has changed to the currently 275 /** passes on the message that an event has changed to the currently
276 * activated view so that it can make appropriate display changes. */ 276 * activated view so that it can make appropriate display changes. */
277 void changeEventDisplay(Event *, int); 277 void changeEventDisplay(Event *, int);
278 void changeIncidenceDisplay(Incidence *, int); 278 void changeIncidenceDisplay(Incidence *, int);
279 void changeTodoDisplay(Todo *, int); 279 void changeTodoDisplay(Todo *, int);
280 280
281 void eventAdded(Event *); 281 void eventAdded(Event *);
282 void eventChanged(Event *); 282 void eventChanged(Event *);
283 void eventToBeDeleted(Event *); 283 void eventToBeDeleted(Event *);
284 void eventDeleted(); 284 void eventDeleted();
285 285
286 void todoAdded(Todo *); 286 void todoAdded(Todo *);
287 void todoChanged(Todo *); 287 void todoChanged(Todo *);
288 void todoToBeDeleted(Todo *); 288 void todoToBeDeleted(Todo *);
289 void todoDeleted(); 289 void todoDeleted();
290 290
291 void updateView(const QDate &start, const QDate &end); 291 void updateView(const QDate &start, const QDate &end);
292 void updateView(); 292 void updateView();
293 293
294 /** Full update of visible todo views */ 294 /** Full update of visible todo views */
295 void updateTodoViews(); 295 void updateTodoViews();
296 296
297 void updateUnmanagedViews(); 297 void updateUnmanagedViews();
298 298
299 /** cut the current appointment to the clipboard */ 299 /** cut the current appointment to the clipboard */
300 void edit_cut(); 300 void edit_cut();
301 301
302 /** copy the current appointment(s) to the clipboard */ 302 /** copy the current appointment(s) to the clipboard */
303 void edit_copy(); 303 void edit_copy();
304 304
305 /** paste the current vobject(s) in the clipboard buffer into calendar */ 305 /** paste the current vobject(s) in the clipboard buffer into calendar */
306 void edit_paste(); 306 void edit_paste();
307 307
308 /** edit viewing and configuration options. */ 308 /** edit viewing and configuration options. */
309 void edit_options(); 309 void edit_options();
310 void edit_sync_options(); 310 void edit_sync_options();
311 /** 311 /**
312 Functions for printing, previewing a print, and setting up printing 312 Functions for printing, previewing a print, and setting up printing
313 parameters. 313 parameters.
314 */ 314 */
315 void print(); 315 void print();
316 void printSetup(); 316 void printSetup();
317 void printPreview(); 317 void printPreview();
318 318
319 /** Export as iCalendar file */ 319 /** Export as iCalendar file */
320 void exportICalendar(); 320 void exportICalendar();
321 321
322 /** Export as vCalendar file */ 322 /** Export as vCalendar file */
323 bool exportVCalendar( QString fn); 323 bool exportVCalendar( QString fn);
324 324
325 /** pop up a dialog to show an existing appointment. */ 325 /** pop up a dialog to show an existing appointment. */
326 void appointment_show(); 326 void appointment_show();
327 /** 327 /**
328 * pop up an Appointment Dialog to edit an existing appointment.Get 328 * pop up an Appointment Dialog to edit an existing appointment.Get
329 * information on the appointment from the list of unique IDs that is 329 * information on the appointment from the list of unique IDs that is
330 * currently in the View, called currIds. 330 * currently in the View, called currIds.
331 */ 331 */
332 void appointment_edit(); 332 void appointment_edit();
333 /** 333 /**
334 * pop up dialog confirming deletion of currently selected event in the 334 * pop up dialog confirming deletion of currently selected event in the
335 * View. 335 * View.
336 */ 336 */
337 void appointment_delete(); 337 void appointment_delete();
338 338
339 /** mails the currently selected event to a particular user as a vCalendar 339 /** mails the currently selected event to a particular user as a vCalendar
340 attachment. */ 340 attachment. */
341 void action_mail(); 341 void action_mail();
342 342
343 /* frees a subtodo from it's relation */ 343 /* frees a subtodo from it's relation */
344 void todo_unsub( Todo * ); 344 void todo_unsub( Todo * );
345 345
346 /** Take ownership of selected event. */ 346 /** Take ownership of selected event. */
347 void takeOverEvent(); 347 void takeOverEvent();
348 348
349 /** Take ownership of all events in calendar. */ 349 /** Take ownership of all events in calendar. */
350 void takeOverCalendar(); 350 void takeOverCalendar();
351 351
352 /** query whether or not the calendar is "dirty". */ 352 /** query whether or not the calendar is "dirty". */
353 bool isModified(); 353 bool isModified();
354 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ 354 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */
355 void setModified(bool modified=true); 355 void setModified(bool modified=true);
356 356
357 /** query if the calendar is read-only. */ 357 /** query if the calendar is read-only. */
358 bool isReadOnly(); 358 bool isReadOnly();
359 /** set state of calendar to read-only */ 359 /** set state of calendar to read-only */
360 void setReadOnly(bool readOnly=true); 360 void setReadOnly(bool readOnly=true);
361 361
362 void eventUpdated(Incidence *); 362 void eventUpdated(Incidence *);
363 363
364 /* iTIP scheduling actions */ 364 /* iTIP scheduling actions */
365 void schedule_publish(Incidence *incidence = 0); 365 void schedule_publish(Incidence *incidence = 0);
366 void schedule_request(Incidence *incidence = 0); 366 void schedule_request(Incidence *incidence = 0);
367 void schedule_refresh(Incidence *incidence = 0); 367 void schedule_refresh(Incidence *incidence = 0);
368 void schedule_cancel(Incidence *incidence = 0); 368 void schedule_cancel(Incidence *incidence = 0);
369 void schedule_add(Incidence *incidence = 0); 369 void schedule_add(Incidence *incidence = 0);
370 void schedule_reply(Incidence *incidence = 0); 370 void schedule_reply(Incidence *incidence = 0);
371 void schedule_counter(Incidence *incidence = 0); 371 void schedule_counter(Incidence *incidence = 0);
372 void schedule_declinecounter(Incidence *incidence = 0); 372 void schedule_declinecounter(Incidence *incidence = 0);
373 void schedule_publish_freebusy(int daysToPublish = 30); 373 void schedule_publish_freebusy(int daysToPublish = 30);
374 374
375 void openAddressbook(); 375 void openAddressbook();
376 376
377 void editFilters(); 377 void editFilters();
378 void toggleFilerEnabled(); 378 void toggleFilerEnabled();
379 379
380 void toggleFilter(); 380 void toggleFilter();
381 void showFilter(bool visible); 381 void showFilter(bool visible);
382 void updateFilter(); 382 void updateFilter();
383 void filterEdited(); 383 void filterEdited();
384 void selectFilter( int ); 384 void selectFilter( int );
385 385
386 void showIntro(); 386 void showIntro();
387 387
388 /** Move the curdatepient view date to today */ 388 /** Move the curdatepient view date to today */
389 void goToday(); 389 void goToday();
390 390
391 /** Move to the next date(s) in the current view */ 391 /** Move to the next date(s) in the current view */
392 void goNext(); 392 void goNext();
393 393
394 /** Move to the previous date(s) in the current view */ 394 /** Move to the previous date(s) in the current view */
395 void goPrevious(); 395 void goPrevious();
396 /** Move to the next date(s) in the current view */ 396 /** Move to the next date(s) in the current view */
397 void goNextMonth(); 397 void goNextMonth();
398 398
399 /** Move to the previous date(s) in the current view */ 399 /** Move to the previous date(s) in the current view */
400 void goPreviousMonth(); 400 void goPreviousMonth();
401 401
402 void toggleExpand(); 402 void toggleExpand();
403 void toggleDateNavigatorWidget(); 403 void toggleDateNavigatorWidget();
404 void toggleAllDaySize(); 404 void toggleAllDaySize();
405 void dialogClosing(Incidence *); 405 void dialogClosing(Incidence *);
406 406
407 /** Look for new messages in the inbox */ 407 /** Look for new messages in the inbox */
408 void lookForIncomingMessages(); 408 void lookForIncomingMessages();
409 /** Look for new messages in the outbox */ 409 /** Look for new messages in the outbox */
410 void lookForOutgoingMessages(); 410 void lookForOutgoingMessages();
411 411
412 void processMainViewSelection( Incidence * ); 412 void processMainViewSelection( Incidence * );
413 void processTodoListSelection( Incidence * ); 413 void processTodoListSelection( Incidence * );
414 414
415 void processIncidenceSelection( Incidence * ); 415 void processIncidenceSelection( Incidence * );
416 416
417 void purgeCompleted(); 417 void purgeCompleted();
418 bool removeCompletedSubTodos( Todo* ); 418 bool removeCompletedSubTodos( Todo* );
419 void slotCalendarChanged(); 419 void slotCalendarChanged();
420 bool importBday(); 420 bool importBday();
421 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); 421 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday );
422 bool importQtopia( const QString &categoriesFile, 422 bool importQtopia( const QString &categoriesFile,
423 const QString &datebookFile, 423 const QString &datebookFile,
424 const QString &tasklistFile ); 424 const QString &tasklistFile );
425 void syncSharp( ); 425 void syncSharp( );
426 void slotSelectPickerDate( QDate ) ; 426 void slotSelectPickerDate( QDate ) ;
427 void showDatePicker( ) ; 427 void showDatePicker( ) ;
428 void moveIncidence(Incidence *) ; 428 void moveIncidence(Incidence *) ;
429 void beamIncidence(Incidence *) ; 429 void beamIncidence(Incidence *) ;
430 void beamCalendar() ; 430 void beamCalendar() ;
431 void beamFilteredCalendar() ; 431 void beamFilteredCalendar() ;
432 void beamIncidenceList(QPtrList<Incidence>) ; 432 void beamIncidenceList(QPtrList<Incidence>) ;
433 void manageCategories(); 433 void manageCategories();
434 int addCategories(); 434 int addCategories();
435 void removeCategories(); 435 void removeCategories();
436 void setSyncDevice( QString ); 436 void setSyncDevice( QString );
437 void setSyncName( QString ); 437 void setSyncName( QString );
438 protected slots: 438 protected slots:
439 void timerAlarm(); 439 void timerAlarm();
440 void suspendAlarm(); 440 void suspendAlarm();
441 void beamDone( Ir *ir ); 441 void beamDone( Ir *ir );
442 /** Select a view or adapt the current view to display the specified dates. */ 442 /** Select a view or adapt the current view to display the specified dates. */
443 void showDates( const KCal::DateList & ); 443 void showDates( const KCal::DateList & );
444 void selectWeekNum ( int ); 444 void selectWeekNum ( int );
445 445
446 public: 446 public:
447 // show a standard warning 447 // show a standard warning
448 // returns KMsgBox::yesNoCancel() 448 // returns KMsgBox::yesNoCancel()
449 int msgCalModified(); 449 int msgCalModified();
450 void confSync(); 450 void confSync();
451 void setLoadedFileVersion(QDateTime); 451 void setLoadedFileVersion(QDateTime);
452 bool checkFileVersion(QString fn); 452 bool checkFileVersion(QString fn);
453 bool checkFileChanged(QString fn); 453 bool checkFileChanged(QString fn);
454 Event* getLastSyncEvent(); 454 Event* getLastSyncEvent();
455 /** Adapt navigation units correpsonding to step size of navigation of the 455 /** Adapt navigation units correpsonding to step size of navigation of the
456 * current view. 456 * current view.
457 */ 457 */
458 void adaptNavigationUnits(); 458 void adaptNavigationUnits();
459 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); 459 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode );
460 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); 460 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false );
461 //Attendee* getYourAttendee(Event *event); 461 //Attendee* getYourAttendee(Event *event);
462 protected: 462 protected:
463 void schedule(Scheduler::Method, Incidence *incidence = 0); 463 void schedule(Scheduler::Method, Incidence *incidence = 0);
464 464
465 // returns KMsgBox::OKCandel() 465 // returns KMsgBox::OKCandel()
466 int msgItemDelete(); 466 int msgItemDelete();
467 void showEventEditor(); 467 void showEventEditor();
468 void showTodoEditor(); 468 void showTodoEditor();
469 void writeLocale(); 469 void writeLocale();
470 Todo *selectedTodo(); 470 Todo *selectedTodo();
471 471
472 private: 472 private:
473 AlarmDialog * mAlarmDialog; 473 AlarmDialog * mAlarmDialog;
474 QString mAlarmNotification; 474 QString mAlarmNotification;
475 QString mSuspendAlarmNotification; 475 QString mSuspendAlarmNotification;
476 QTimer* mSuspendTimer; 476 QTimer* mSuspendTimer;
477 QTimer* mAlarmTimer; 477 QTimer* mAlarmTimer;
478 QTimer* mRecheckAlarmTimer; 478 QTimer* mRecheckAlarmTimer;
479 void computeAlarm( QString ); 479 void computeAlarm( QString );
480 void startAlarm( QString, QString ); 480 void startAlarm( QString, QString );
481 void setSyncEventsReadOnly(); 481 void setSyncEventsReadOnly();
482 482
483 QDateTime loadedFileVersion; 483 QDateTime loadedFileVersion;
484 void checkSharpEvent( Event* lastSync, Incidence* toDelete ); 484 void checkSharpEvent( Event* lastSync, Incidence* toDelete );
485 QPtrList<KSyncProfile> mSyncProfiles;
486 QStringList mSyncProfileNames;
487 void checkZaurusId( int id, bool todo = false ); 485 void checkZaurusId( int id, bool todo = false );
488 int mGlobalSyncMode; 486 int mGlobalSyncMode;
489 QString mCurrentSyncDevice; 487 QString mCurrentSyncDevice;
490 QString mCurrentSyncName; 488 QString mCurrentSyncName;
491 KOBeamPrefs* beamDialog; 489 KOBeamPrefs* beamDialog;
492 void init(); 490 void init();
493 int mDatePickerMode; 491 int mDatePickerMode;
494 bool mFlagEditDescription; 492 bool mFlagEditDescription;
495 QDateTime mLastCalendarSync; 493 QDateTime mLastCalendarSync;
496 void createPrinter(); 494 void createPrinter();
497 495
498 void calendarModified( bool, Calendar * ); 496 void calendarModified( bool, Calendar * );
499 497
500 CalPrinter *mCalPrinter; 498 CalPrinter *mCalPrinter;
501 499
502 QSplitter *mPanner; 500 QSplitter *mPanner;
503 QSplitter *mLeftSplitter; 501 QSplitter *mLeftSplitter;
504 QWidget *mLeftFrame; 502 QWidget *mLeftFrame;
505 QWidgetStack *mRightFrame; 503 QWidgetStack *mRightFrame;
506 504
507 KDatePicker* mDatePicker; 505 KDatePicker* mDatePicker;
508 QVBox* mDateFrame; 506 QVBox* mDateFrame;
509 NavigatorBar *mNavigatorBar; 507 NavigatorBar *mNavigatorBar;
510 508
511 KDateNavigator *mDateNavigator; // widget showing small month view. 509 KDateNavigator *mDateNavigator; // widget showing small month view.
512 510
513 KOFilterView *mFilterView; 511 KOFilterView *mFilterView;
514 512
515 ResourceView *mResourceView; 513 ResourceView *mResourceView;
516 514
517 // calendar object for this viewing instance 515 // calendar object for this viewing instance
518 Calendar *mCalendar; 516 Calendar *mCalendar;
519 517
520 CalendarResourceManager *mResourceManager; 518 CalendarResourceManager *mResourceManager;
521 519
522 FileStorage *mStorage; 520 FileStorage *mStorage;
523 521
524 DateNavigator *mNavigator; 522 DateNavigator *mNavigator;
525 523
526 KOViewManager *mViewManager; 524 KOViewManager *mViewManager;
527 KODialogManager *mDialogManager; 525 KODialogManager *mDialogManager;
528 526
529 // Calendar filters 527 // Calendar filters
530 QPtrList<CalFilter> mFilters; 528 QPtrList<CalFilter> mFilters;
531 529
532 // various housekeeping variables. 530 // various housekeeping variables.
533 bool mModified; // flag indicating if calendar is modified 531 bool mModified; // flag indicating if calendar is modified
534 bool mReadOnly; // flag indicating if calendar is read-only 532 bool mReadOnly; // flag indicating if calendar is read-only
535 QDate mSaveSingleDate; 533 QDate mSaveSingleDate;
536 534
537 Incidence *mSelectedIncidence; 535 Incidence *mSelectedIncidence;
538 Incidence *mMoveIncidence; 536 Incidence *mMoveIncidence;
539 537
540 KOTodoView *mTodoList; 538 KOTodoView *mTodoList;
541 KOEventEditor * mEventEditor; 539 KOEventEditor * mEventEditor;
542 KOTodoEditor * mTodoEditor; 540 KOTodoEditor * mTodoEditor;
543 KOEventViewerDialog * mEventViewerDialog; 541 KOEventViewerDialog * mEventViewerDialog;
544 void keyPressEvent ( QKeyEvent *e) ; 542 void keyPressEvent ( QKeyEvent *e) ;
545 //QMap<Incidence*,KOIncidenceEditor*> mDialogList; 543 //QMap<Incidence*,KOIncidenceEditor*> mDialogList;
546}; 544};
547 545
548 546
549class CalendarViewVisitor : public Incidence::Visitor 547class CalendarViewVisitor : public Incidence::Visitor
550{ 548{
551 public: 549 public:
552 CalendarViewVisitor() : mView( 0 ) {} 550 CalendarViewVisitor() : mView( 0 ) {}
553 551
554 bool act( Incidence *incidence, CalendarView *view ) 552 bool act( Incidence *incidence, CalendarView *view )
555 { 553 {
556 mView = view; 554 mView = view;
557 return incidence->accept( *this ); 555 return incidence->accept( *this );
558 } 556 }
559 557
560 protected: 558 protected:
561 CalendarView *mView; 559 CalendarView *mView;
562}; 560};
563 561
564class ShowIncidenceVisitor : public CalendarViewVisitor 562class ShowIncidenceVisitor : public CalendarViewVisitor
565{ 563{
566 protected: 564 protected:
567 bool visit( Event *event ) { mView->showEvent( event ); return true; } 565 bool visit( Event *event ) { mView->showEvent( event ); return true; }
568 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } 566 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; }
569 bool visit( Journal * j ) { mView->showJournal( j );return true; } 567 bool visit( Journal * j ) { mView->showJournal( j );return true; }
570}; 568};
571 569
572class EditIncidenceVisitor : public CalendarViewVisitor 570class EditIncidenceVisitor : public CalendarViewVisitor
573{ 571{
574 protected: 572 protected:
575 bool visit( Event *event ) { mView->editEvent( event ); return true; } 573 bool visit( Event *event ) { mView->editEvent( event ); return true; }
576 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } 574 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; }
577 bool visit( Journal *j ) { mView->editJournal( j); return true; } 575 bool visit( Journal *j ) { mView->editJournal( j); return true; }
578}; 576};
579 577
580class DeleteIncidenceVisitor : public CalendarViewVisitor 578class DeleteIncidenceVisitor : public CalendarViewVisitor
581{ 579{
582 protected: 580 protected:
583 bool visit( Event *event ) { mView->deleteEvent( event ); return true; } 581 bool visit( Event *event ) { mView->deleteEvent( event ); return true; }
584 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } 582 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; }
585 bool visit( Journal * j) {mView->deleteJournal( j ); return true; } 583 bool visit( Journal * j) {mView->deleteJournal( j ); return true; }
586}; 584};
587 585
588#endif 586#endif
diff --git a/korganizer/kosyncprefsdialog.cpp b/korganizer/kosyncprefsdialog.cpp
index b7e4265..7c838f5 100644
--- a/korganizer/kosyncprefsdialog.cpp
+++ b/korganizer/kosyncprefsdialog.cpp
@@ -1,452 +1,468 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2004 Lutz Rogowski <rogowski@kde.org> 3 Copyright (c) 2004 Lutz Rogowski <rogowski@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 <qlayout.h> 24#include <qlayout.h>
25#include <qlabel.h> 25#include <qlabel.h>
26#include <qgroupbox.h> 26#include <qgroupbox.h>
27#include <qbuttongroup.h> 27#include <qbuttongroup.h>
28#include <qlineedit.h> 28#include <qlineedit.h>
29#include <qfont.h> 29#include <qfont.h>
30#include <qslider.h> 30#include <qslider.h>
31#include <qfile.h> 31#include <qfile.h>
32#include <qdir.h>
32#include <qtextstream.h> 33#include <qtextstream.h>
33#include <qcombobox.h> 34#include <qcombobox.h>
34#include <qvbox.h> 35#include <qvbox.h>
35#include <qhbox.h> 36#include <qhbox.h>
36#include <qspinbox.h> 37#include <qspinbox.h>
37#include <qdatetime.h> 38#include <qdatetime.h>
38#include <qcheckbox.h> 39#include <qcheckbox.h>
39#include <qradiobutton.h> 40#include <qradiobutton.h>
40#include <qpushbutton.h> 41#include <qpushbutton.h>
41#include <qstrlist.h> 42#include <qstrlist.h>
42#include <qapplication.h> 43#include <qapplication.h>
43 44
44#include <kcolorbutton.h> 45#include <kcolorbutton.h>
45#include <kdebug.h> 46#include <kdebug.h>
46#include <klocale.h> 47#include <klocale.h>
47#include <kglobal.h> 48#include <kglobal.h>
48#include <kfontdialog.h> 49#include <kfontdialog.h>
49#include <kmessagebox.h> 50#include <kmessagebox.h>
50#include <kcolordialog.h> 51#include <kcolordialog.h>
51#include <kiconloader.h> 52#include <kiconloader.h>
52#include <kemailsettings.h> 53#include <kemailsettings.h>
53#include <kstandarddirs.h> 54#include <kstandarddirs.h>
54#include <kfiledialog.h> 55#include <kfiledialog.h>
55#include <kmessagebox.h> 56#include <kmessagebox.h>
56 57
57#include <kurlrequester.h> 58#include <kurlrequester.h>
58#include <klineedit.h> 59#include <klineedit.h>
59#include <libkdepim/ksyncprofile.h> 60#include <libkdepim/ksyncprofile.h>
60 61
61 62
62#include "koprefs.h" 63//#include "koprefs.h"
63 64
64#include "kosyncprefsdialog.h" 65#include "kosyncprefsdialog.h"
65#include "koglobals.h" 66//#include "koglobals.h"
66 67
67 68
68KOSyncPrefsDialog::KOSyncPrefsDialog(QWidget *parent, char *name, bool modal) : 69KOSyncPrefsDialog::KOSyncPrefsDialog(QWidget *parent, char *name, bool modal) :
69 KDialog(parent,name,true) 70 KDialog(parent,name,true)
70{ 71{
71 72
72 setCaption( i18n("Synchronization Preferences")); 73 setCaption( i18n("Synchronization Preferences"));
73 74
74 mSyncProfiles.setAutoDelete( true ); 75 mSyncProfiles.setAutoDelete( true );
75 setupSyncAlgTab(); 76 setupSyncAlgTab();
76} 77}
77 78
78 79
79KOSyncPrefsDialog::~KOSyncPrefsDialog() 80KOSyncPrefsDialog::~KOSyncPrefsDialog()
80{ 81{
81} 82}
82 83
83#include <qlayout.h> 84#include <qlayout.h>
84#include <qscrollview.h> 85#include <qscrollview.h>
85void KOSyncPrefsDialog::setupSyncAlgTab() 86void KOSyncPrefsDialog::setupSyncAlgTab()
86{ 87{
87 QLabel * lab; 88 QLabel * lab;
88 //QFrame *page = addPage(i18n("Sync Prefs"),0,0); 89 //QFrame *page = addPage(i18n("Sync Prefs"),0,0);
89 QVBox * mainbox = new QVBox( this ); 90 QVBox * mainbox = new QVBox( this );
90 QScrollView* sv = new QScrollView( mainbox ); 91 QScrollView* sv = new QScrollView( mainbox );
91 QHBoxLayout * lay = new QHBoxLayout( this ); 92 QHBoxLayout * lay = new QHBoxLayout( this );
92 lay->addWidget( mainbox ); 93 lay->addWidget( mainbox );
93 QHBox * b_box = new QHBox( mainbox ); 94 QHBox * b_box = new QHBox( mainbox );
94 95
95 QPushButton* button = new QPushButton( i18n("Ok"), b_box ); 96 QPushButton* button = new QPushButton( i18n("Ok"), b_box );
96 connect ( button, SIGNAL( clicked()), this, SLOT (slotOK() ) ); 97 connect ( button, SIGNAL( clicked()), this, SLOT (slotOK() ) );
97 button = new QPushButton( i18n("Cancel"), b_box ); 98 button = new QPushButton( i18n("Cancel"), b_box );
98 connect ( button, SIGNAL( clicked()), this, SLOT (reject() ) ); 99 connect ( button, SIGNAL( clicked()), this, SLOT (reject() ) );
99 //QBoxLayout * sl = new QVBoxLayout(this ); 100 //QBoxLayout * sl = new QVBoxLayout(this );
100 //sl->addWidget ( sv ); 101 //sl->addWidget ( sv );
101 sv->setResizePolicy ( QScrollView::AutoOneFit ); 102 sv->setResizePolicy ( QScrollView::AutoOneFit );
102 QFrame *topFrame = new QFrame ( sv ); 103 QFrame *topFrame = new QFrame ( sv );
103 sv->addChild( topFrame ); 104 sv->addChild( topFrame );
104 mSetupSyncAlgTab = topFrame; 105 mSetupSyncAlgTab = topFrame;
105 QGridLayout *topLayout = new QGridLayout(topFrame,6,2); 106 QGridLayout *topLayout = new QGridLayout(topFrame,6,2);
106 topLayout->setSpacing(spacingHint()); 107 topLayout->setSpacing(spacingHint());
107 topLayout->setMargin(marginHint()); 108 topLayout->setMargin(marginHint());
108 109
109 //lab = new QLabel(i18n("Sync settings not yet implemented. DO NOT USE!"), topFrame); 110 //lab = new QLabel(i18n("Sync settings not yet implemented. DO NOT USE!"), topFrame);
110 int iii = 0; 111 int iii = 0;
111 //topLayout->addMultiCellWidget(lab , iii,iii,0,1); 112 //topLayout->addMultiCellWidget(lab , iii,iii,0,1);
112 //++iii; 113 //++iii;
113 114
114 mMyMachineName = new QLineEdit(topFrame); 115 mMyMachineName = new QLineEdit(topFrame);
115 lab = new QLabel(mMyMachineName, i18n("Local device name:"), topFrame); 116 lab = new QLabel(mMyMachineName, i18n("Local device name:"), topFrame);
116 topLayout->addWidget(lab ,iii,0); 117 topLayout->addWidget(lab ,iii,0);
117 topLayout->addWidget(mMyMachineName,iii,1); 118 topLayout->addWidget(mMyMachineName,iii,1);
118 ++iii; 119 ++iii;
119 120
120 QHBox* buttonbox = new QHBox( topFrame); 121 QHBox* buttonbox = new QHBox( topFrame);
121 topLayout->addMultiCellWidget(buttonbox, iii,iii,0,1); 122 topLayout->addMultiCellWidget(buttonbox, iii,iii,0,1);
122 ++iii; 123 ++iii;
123 button = new QPushButton( i18n("New profile"), buttonbox ); 124 button = new QPushButton( i18n("New profile"), buttonbox );
124 connect ( button, SIGNAL( clicked()), this, SLOT (newProfile() ) ); 125 connect ( button, SIGNAL( clicked()), this, SLOT (newProfile() ) );
125 126
126 button = new QPushButton( i18n("Clone profile"), buttonbox ); 127 button = new QPushButton( i18n("Clone profile"), buttonbox );
127 connect ( button, SIGNAL( clicked()), this, SLOT ( cloneProfile() ) ); 128 connect ( button, SIGNAL( clicked()), this, SLOT ( cloneProfile() ) );
128 129
129 button = new QPushButton( i18n("Delete profile"), buttonbox ); 130 button = new QPushButton( i18n("Delete profile"), buttonbox );
130 connect ( button, SIGNAL( clicked()), this, SLOT (deleteProfile() ) ); 131 connect ( button, SIGNAL( clicked()), this, SLOT (deleteProfile() ) );
131 132
132 mProfileBox = new QComboBox(topFrame); 133 mProfileBox = new QComboBox(topFrame);
133 mProfileBox->setEditable ( true ); 134 mProfileBox->setEditable ( true );
134 connect ( mProfileBox, SIGNAL(activated ( int ) ), this, SLOT (profileChanged( int ) ) ); 135 connect ( mProfileBox, SIGNAL(activated ( int ) ), this, SLOT (profileChanged( int ) ) );
135 connect ( mProfileBox, SIGNAL( textChanged ( const QString & ) ), this, SLOT (textChanged( const QString & ) ) ); 136 connect ( mProfileBox, SIGNAL( textChanged ( const QString & ) ), this, SLOT (textChanged( const QString & ) ) );
136 137
137 lab = new QLabel(mProfileBox, i18n("Profile:"), topFrame); 138 lab = new QLabel(mProfileBox, i18n("Profile:"), topFrame);
138 topLayout->addWidget(lab ,iii,0); 139 topLayout->addWidget(lab ,iii,0);
139 topLayout->addWidget(mProfileBox, iii,1); 140 topLayout->addWidget(mProfileBox, iii,1);
140 ++iii; 141 ++iii;
141 142
142 mIncludeInRing = new QCheckBox( i18n("Include in multiple sync"), topFrame ); 143 mIncludeInRing = new QCheckBox( i18n("Include in multiple sync"), topFrame );
143 topLayout->addMultiCellWidget(mIncludeInRing, iii,iii,0,1); 144 topLayout->addMultiCellWidget(mIncludeInRing, iii,iii,0,1);
144 ++iii; 145 ++iii;
145 146
146 mAskForPreferences = new QCheckBox( i18n("Ask for preferences before sync"), topFrame ); 147 mAskForPreferences = new QCheckBox( i18n("Ask for preferences before sync"), topFrame );
147 topLayout->addMultiCellWidget(mAskForPreferences, iii,iii,0,1); 148 topLayout->addMultiCellWidget(mAskForPreferences, iii,iii,0,1);
148 ++iii; 149 ++iii;
149 QButtonGroup* gr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Sync preferences"), topFrame); 150 QButtonGroup* gr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Sync preferences"), topFrame);
150 topLayout->addMultiCellWidget(gr, iii,iii,0,1); 151 topLayout->addMultiCellWidget(gr, iii,iii,0,1);
151 ++iii; 152 ++iii;
152 loc = new QRadioButton ( i18n("Take local entry on conflict"), gr ); 153 loc = new QRadioButton ( i18n("Take local entry on conflict"), gr );
153 rem = new QRadioButton ( i18n("Take remote entry on conflict"), gr ); 154 rem = new QRadioButton ( i18n("Take remote entry on conflict"), gr );
154 newest = new QRadioButton ( i18n("Take newest entry on conflict"), gr ); 155 newest = new QRadioButton ( i18n("Take newest entry on conflict"), gr );
155 ask = new QRadioButton ( i18n("Ask for every entry on conflict"), gr ); 156 ask = new QRadioButton ( i18n("Ask for every entry on conflict"), gr );
156 f_loc= new QRadioButton ( i18n("Force: Take local entry always"), gr ); 157 f_loc= new QRadioButton ( i18n("Force: Take local entry always"), gr );
157 f_rem = new QRadioButton ( i18n("Force: Take remote entry always"), gr ); 158 f_rem = new QRadioButton ( i18n("Force: Take remote entry always"), gr );
158 // both = new QRadioButton ( i18n("Take both on conflict"), gr ); 159 // both = new QRadioButton ( i18n("Take both on conflict"), gr );
159 160
160 mShowSummaryAfterSync = new QCheckBox( i18n("Show summary after sync"), topFrame ); 161 mShowSummaryAfterSync = new QCheckBox( i18n("Show summary after sync"), topFrame );
161 topLayout->addMultiCellWidget(mShowSummaryAfterSync, iii,iii,0,1); 162 topLayout->addMultiCellWidget(mShowSummaryAfterSync, iii,iii,0,1);
162 ++iii; 163 ++iii;
163 164
164 mWriteBackExisting= new QCheckBox( i18n("Write back existing entries only"), topFrame ); 165 mWriteBackExisting= new QCheckBox( i18n("Write back existing entries only"), topFrame );
165 topLayout->addMultiCellWidget(mWriteBackExisting, iii,iii,0,1); 166 topLayout->addMultiCellWidget(mWriteBackExisting, iii,iii,0,1);
166 ++iii; 167 ++iii;
167 168
168 mWriteBackFile = new QCheckBox( i18n("Write back file"), topFrame ); 169 mWriteBackFile = new QCheckBox( i18n("Write back file"), topFrame );
169 topLayout->addMultiCellWidget(mWriteBackFile, iii,iii,0,1); 170 topLayout->addMultiCellWidget(mWriteBackFile, iii,iii,0,1);
170 ++iii; 171 ++iii;
171 172
172 proGr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Profile kind"), topFrame); 173 proGr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Profile kind"), topFrame);
173 gr = proGr; 174 gr = proGr;
174 topLayout->addMultiCellWidget(gr, iii,iii,0,1); 175 topLayout->addMultiCellWidget(gr, iii,iii,0,1);
175 ++iii; 176 ++iii;
176 mIsLocal = new QRadioButton ( i18n("Local file"), gr ); 177 mIsLocal = new QRadioButton ( i18n("Local file"), gr );
177 mIsNotLocal = new QRadioButton ( i18n("Remote file (w down/upload command)"), gr ); 178 mIsNotLocal = new QRadioButton ( i18n("Remote file (w down/upload command)"), gr );
178 connect (mIsLocal, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); 179 connect (mIsLocal, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) );
179 180
180 localFileWidget = new QVBox( topFrame); 181 localFileWidget = new QVBox( topFrame);
181 topLayout->addMultiCellWidget(localFileWidget, iii,iii,0,1); 182 topLayout->addMultiCellWidget(localFileWidget, iii,iii,0,1);
182 ++iii; 183 ++iii;
183 QHBox* temphb = new QHBox( localFileWidget ); 184 QHBox* temphb = new QHBox( localFileWidget );
184 lab = new QLabel( i18n("Local file:"), temphb); 185 lab = new QLabel( i18n("Local file:"), temphb);
185 mRemoteFile = new QLineEdit(localFileWidget); 186 mRemoteFile = new QLineEdit(localFileWidget);
186 187
187 button = new QPushButton( i18n("Choose..."), temphb ); 188 button = new QPushButton( i18n("Choose..."), temphb );
188 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFile() ) ); 189 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFile() ) );
189 190
190 191
191 remoteFileWidget = new QVBox( topFrame); 192 remoteFileWidget = new QVBox( topFrame);
192 topLayout->addMultiCellWidget(remoteFileWidget, iii,iii,0,1); 193 topLayout->addMultiCellWidget(remoteFileWidget, iii,iii,0,1);
193 ++iii; 194 ++iii;
194 lab = new QLabel( i18n("Pre sync (download) command:"), remoteFileWidget); 195 lab = new QLabel( i18n("Pre sync (download) command:"), remoteFileWidget);
195 mRemotePrecommand = new QLineEdit(remoteFileWidget); 196 mRemotePrecommand = new QLineEdit(remoteFileWidget);
196 197
197 lab = new QLabel( i18n("Local temp file:"), remoteFileWidget); 198 lab = new QLabel( i18n("Local temp file:"), remoteFileWidget);
198 mLocalTempFile = new QLineEdit(remoteFileWidget); 199 mLocalTempFile = new QLineEdit(remoteFileWidget);
199 200
200 201
201 lab = new QLabel( i18n("Post sync (upload) command:"), remoteFileWidget); 202 lab = new QLabel( i18n("Post sync (upload) command:"), remoteFileWidget);
202 mRemotePostcommand = new QLineEdit(remoteFileWidget); 203 mRemotePostcommand = new QLineEdit(remoteFileWidget);
203 204
204 lab = new QLabel( i18n("Fill in default values for:"), remoteFileWidget); 205 lab = new QLabel( i18n("Fill in default values for:"), remoteFileWidget);
205 temphb = new QHBox( remoteFileWidget ); 206 temphb = new QHBox( remoteFileWidget );
206 button = new QPushButton( i18n("ssh/scp"), temphb ); 207 button = new QPushButton( i18n("ssh/scp"), temphb );
207 connect ( button, SIGNAL( clicked()), this, SLOT (fillSSH() ) ); 208 connect ( button, SIGNAL( clicked()), this, SLOT (fillSSH() ) );
208 button = new QPushButton( i18n("ftp"), temphb ); 209 button = new QPushButton( i18n("ftp"), temphb );
209 connect ( button, SIGNAL( clicked()), this, SLOT (fillFTP() ) ); 210 connect ( button, SIGNAL( clicked()), this, SLOT (fillFTP() ) );
210 lab = new QLabel( i18n("Hint: Use $PWD$ for placeholder of password!"), remoteFileWidget); 211 lab = new QLabel( i18n("Hint: Use $PWD$ for placeholder of password!"), remoteFileWidget);
211 212
212 213
213} 214}
214void KOSyncPrefsDialog::slotOK() 215void KOSyncPrefsDialog::slotOK()
215{ 216{
216 if ( mMyMachineName->text() == "undefined" ) { 217 if ( mMyMachineName->text() == "undefined" ) {
217 KMessageBox::error(this,i18n("Local device name undefined!\nPlease define device name!"),i18n("KO/Pi config error")); 218 KMessageBox::error(this,i18n("Local device name undefined!\nPlease define device name!"),i18n("KO/Pi config error"));
218 return; 219 return;
219 } 220 }
220 int i; 221 int i;
221 for (i = 0; i < mSyncProfileNames.count(); ++ i) { 222 for (i = 0; i < mSyncProfileNames.count(); ++ i) {
222 if ( mSyncProfileNames.contains( mSyncProfileNames[i]) > 1 ) { 223 if ( mSyncProfileNames.contains( mSyncProfileNames[i]) > 1 ) {
223 KMessageBox::error(this,i18n("Multiple profiles with same name!\nPlease use unique profile names!"),i18n("KO/Pi config error")); 224 KMessageBox::error(this,i18n("Multiple profiles with same name!\nPlease use unique profile names!"),i18n("KO/Pi config error"));
224 return; 225 return;
225 } 226 }
226 } 227 }
227 usrWriteConfig(); 228 usrWriteConfig();
228 QDialog::accept(); 229 QDialog::accept();
229} 230}
230void KOSyncPrefsDialog::accept() 231void KOSyncPrefsDialog::accept()
231{ 232{
232 slotOK(); 233 slotOK();
233} 234}
234void KOSyncPrefsDialog::chooseFile() 235void KOSyncPrefsDialog::chooseFile()
235{ 236{
236 QString fn =KOPrefs::instance()->mLastSyncedLocalFile; 237 QString fn = QDir::homeDirPath();
237 238
238 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); 239 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this );
239 if ( fn == "" ) 240 if ( fn == "" )
240 return; 241 return;
241 mRemoteFile->setText( fn ); 242 mRemoteFile->setText( fn );
242} 243}
243 244
244void KOSyncPrefsDialog::textChanged( const QString & s ) 245void KOSyncPrefsDialog::textChanged( const QString & s )
245{ 246{
246 if ( mProfileBox->count() == 0 ) 247 if ( mProfileBox->count() == 0 )
247 return; 248 return;
248 if ( currentSelection < 3 ) { 249 if ( currentSelection < 3 ) {
249 //KMessageBox::error(this,i18n("This profil name\ncannot be edited!\n"),i18n("KO/Pi config error")); 250 //KMessageBox::error(this,i18n("This profil name\ncannot be edited!\n"),i18n("KO/Pi config error"));
250 mProfileBox->blockSignals( true ); 251 mProfileBox->blockSignals( true );
251 mProfileBox->setCurrentItem(mProfileBox-> currentItem ()); 252 mProfileBox->setCurrentItem(mProfileBox-> currentItem ());
252 mProfileBox->blockSignals( false ); 253 mProfileBox->blockSignals( false );
253 return; 254 return;
254 } 255 }
255 //qDebug("cur i %d ",mProfileBox-> currentItem () ); 256 //qDebug("cur i %d ",mProfileBox-> currentItem () );
256 mProfileBox->changeItem ( s, mProfileBox-> currentItem () ) ; 257 mProfileBox->changeItem ( s, mProfileBox-> currentItem () ) ;
257 KSyncProfile* prof = mSyncProfiles.at(mProfileBox-> currentItem ()) ; 258 KSyncProfile* prof = mSyncProfiles.at(mProfileBox-> currentItem ()) ;
258 prof->setName( s ); 259 prof->setName( s );
259 mSyncProfileNames[mProfileBox-> currentItem ()] = s; 260 mSyncProfileNames[mProfileBox-> currentItem ()] = s;
260} 261}
261void KOSyncPrefsDialog::profileChanged( int item ) 262void KOSyncPrefsDialog::profileChanged( int item )
262{ 263{
263 //qDebug("KOSyncPrefsDialog::profileChanged %d ", item ); 264 //qDebug("KOSyncPrefsDialog::profileChanged %d ", item );
264 KSyncProfile* prof; 265 KSyncProfile* prof;
265 saveProfile(); 266 saveProfile();
266 currentSelection = item; 267 currentSelection = item;
267 prof = mSyncProfiles.at(item) ; 268 prof = mSyncProfiles.at(item) ;
268 mRemotePrecommand->setText(prof->getPreSyncCommand()); 269 mRemotePrecommand->setText(prof->getPreSyncCommand());
269 mRemotePostcommand->setText(prof->getPostSyncCommand()); 270 mRemotePostcommand->setText(prof->getPostSyncCommand());
270 mLocalTempFile->setText(prof->getLocalTempFile()); 271 mLocalTempFile->setText(prof->getLocalTempFile());
271 mRemoteFile->setText(prof->getRemoteFileName()) ; 272 mRemoteFile->setText(prof->getRemoteFileName()) ;
272 mShowSummaryAfterSync->setChecked( prof->getShowSummaryAfterSync()); 273 mShowSummaryAfterSync->setChecked( prof->getShowSummaryAfterSync());
273 mAskForPreferences->setChecked( prof->getAskForPreferences()); 274 mAskForPreferences->setChecked( prof->getAskForPreferences());
274 mWriteBackExisting->setChecked( prof->getWriteBackExisting() ); 275 mWriteBackExisting->setChecked( prof->getWriteBackExisting() );
275 mWriteBackFile->setChecked( prof->getWriteBackFile()); 276 mWriteBackFile->setChecked( prof->getWriteBackFile());
276 mIncludeInRing->setChecked( prof->getIncludeInRingSync() ); 277 mIncludeInRing->setChecked( prof->getIncludeInRingSync() );
277 278
278 switch ( prof->getSyncPrefs() ) { 279 switch ( prof->getSyncPrefs() ) {
279 case 0: 280 case 0:
280 loc->setChecked( true); 281 loc->setChecked( true);
281 break; 282 break;
282 case 1: 283 case 1:
283 rem->setChecked( true ); 284 rem->setChecked( true );
284 break; 285 break;
285 case 2: 286 case 2:
286 newest->setChecked( true); 287 newest->setChecked( true);
287 break; 288 break;
288 case 3: 289 case 3:
289 ask->setChecked( true); 290 ask->setChecked( true);
290 break; 291 break;
291 case 4: 292 case 4:
292 f_loc->setChecked( true); 293 f_loc->setChecked( true);
293 break; 294 break;
294 case 5: 295 case 5:
295 f_rem->setChecked( true); 296 f_rem->setChecked( true);
296 break; 297 break;
297 case 6: 298 case 6:
298 //both->setChecked( true); 299 //both->setChecked( true);
299 break; 300 break;
300 default: 301 default:
301 break; 302 break;
302 } 303 }
303 mIsLocal->setChecked(prof->getIsLocalFileSync()) ; 304 mIsLocal->setChecked(prof->getIsLocalFileSync()) ;
304 mIsNotLocal->setChecked(!prof->getIsLocalFileSync()); 305 mIsNotLocal->setChecked(!prof->getIsLocalFileSync());
305 proGr->setEnabled( item > 2 ); 306 proGr->setEnabled( item > 2 );
306 if ( item < 3 ) { 307 if ( item < 3 ) {
307 localFileWidget->setEnabled(false); 308 localFileWidget->setEnabled(false);
308 remoteFileWidget->setEnabled(false); 309 remoteFileWidget->setEnabled(false);
309 310
310 } else 311 } else
311 kindChanged( prof->getIsLocalFileSync() ); 312 kindChanged( prof->getIsLocalFileSync() );
312} 313}
313 314
314void KOSyncPrefsDialog::fillSSH() 315void KOSyncPrefsDialog::fillSSH()
315{ 316{
316 mRemotePrecommand->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" ); 317 mRemotePrecommand->setText("scp zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" );
317 mLocalTempFile->setText("/tmp/mycalendar.ics" ); 318 mLocalTempFile->setText("/tmp/mycalendar.ics" );
318 mRemotePostcommand->setText("scp /tmp/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics" ); 319 mRemotePostcommand->setText("scp /tmp/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/kdepim/apps/korganizer/mycalendar.ics" );
319} 320}
320void KOSyncPrefsDialog::fillFTP() 321void KOSyncPrefsDialog::fillFTP()
321{ 322{
322 mRemotePrecommand->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics" ); 323 mRemotePrecommand->setText("cd /tmp;ftp ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics" );
323 mLocalTempFile->setText("/tmp/mycalendar.ics" ); 324 mLocalTempFile->setText("/tmp/mycalendar.ics" );
324 mRemotePostcommand->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" ); 325 mRemotePostcommand->setText("ftp -u ftp://zaurus:a@192.168.0.65/kdepim/apps/korganizer/mycalendar.ics /tmp/mycalendar.ics" );
325 326
326} 327}
327void KOSyncPrefsDialog::kindChanged( bool b ) 328void KOSyncPrefsDialog::kindChanged( bool b )
328{ 329{
329 330
330 localFileWidget->setEnabled(b); 331 localFileWidget->setEnabled(b);
331 remoteFileWidget->setEnabled(!b); 332 remoteFileWidget->setEnabled(!b);
332 333
333} 334}
334void KOSyncPrefsDialog::deleteProfile() 335void KOSyncPrefsDialog::deleteProfile()
335{ 336{
336 //qDebug("KOSyncPrefsDialog::deleteProfile() "); 337 //qDebug("KOSyncPrefsDialog::deleteProfile() ");
337 if ( currentSelection >= 0 ) { 338 if ( currentSelection >= 0 ) {
338 if ( currentSelection < 3 ) { 339 if ( currentSelection < 3 ) {
339 KMessageBox::error(this,i18n("This profil cannot be deleted!\n"),i18n("KO/Pi config error")); 340 KMessageBox::error(this,i18n("This profil cannot be deleted!\n"),i18n("KO/Pi config error"));
340 return; 341 return;
341 } 342 }
342 KSyncProfile* temp = mSyncProfiles.at(currentSelection); 343 KSyncProfile* temp = mSyncProfiles.at(currentSelection);
343 mSyncProfiles.remove( temp ); 344 mSyncProfiles.remove( temp );
344 mSyncProfileNames.remove( mSyncProfileNames.at( currentSelection )); 345 mSyncProfileNames.remove( mSyncProfileNames.at( currentSelection ));
345 insertProfiles(); 346 insertProfiles();
346 } 347 }
347} 348}
348 349
349void KOSyncPrefsDialog::saveProfile() 350void KOSyncPrefsDialog::saveProfile()
350{ 351{
351 KSyncProfile* prof; 352 KSyncProfile* prof;
352 if ( currentSelection >= 0 ) { 353 if ( currentSelection >= 0 ) {
353 prof = mSyncProfiles.at(currentSelection) ; 354 prof = mSyncProfiles.at(currentSelection) ;
354 prof->setPreSyncCommand( mRemotePrecommand->text()); 355 prof->setPreSyncCommand( mRemotePrecommand->text());
355 prof->setPostSyncCommand( mRemotePostcommand->text() ); 356 prof->setPostSyncCommand( mRemotePostcommand->text() );
356 prof->setLocalTempFile( mLocalTempFile->text()); 357 prof->setLocalTempFile( mLocalTempFile->text());
357 prof->setRemoteFileName( mRemoteFile->text() ); 358 prof->setRemoteFileName( mRemoteFile->text() );
358 prof->setShowSummaryAfterSync( mShowSummaryAfterSync->isChecked() ); 359 prof->setShowSummaryAfterSync( mShowSummaryAfterSync->isChecked() );
359 prof->setAskForPreferences( mAskForPreferences->isChecked()); 360 prof->setAskForPreferences( mAskForPreferences->isChecked());
360 prof->setWriteBackExisting(mWriteBackExisting->isChecked() ); 361 prof->setWriteBackExisting(mWriteBackExisting->isChecked() );
361 prof->setWriteBackFile( mWriteBackFile->isChecked()); 362 prof->setWriteBackFile( mWriteBackFile->isChecked());
362 prof->setIncludeInRingSync( mIncludeInRing->isChecked() ); 363 prof->setIncludeInRingSync( mIncludeInRing->isChecked() );
363 int syncprefs = rem->isChecked()*1+newest->isChecked()*2+ ask->isChecked()*3+ f_loc->isChecked()*4+ f_rem->isChecked()*5 ;//+ both->isChecked()*6 ; 364 int syncprefs = rem->isChecked()*1+newest->isChecked()*2+ ask->isChecked()*3+ f_loc->isChecked()*4+ f_rem->isChecked()*5 ;//+ both->isChecked()*6 ;
364 prof->setSyncPrefs( syncprefs); 365 prof->setSyncPrefs( syncprefs);
365 prof->setIsLocalFileSync( mIsLocal->isChecked() ); 366 prof->setIsLocalFileSync( mIsLocal->isChecked() );
366 } 367 }
367 368
368} 369}
369 370
370void KOSyncPrefsDialog::insertProfiles() 371void KOSyncPrefsDialog::insertProfiles()
371{ 372{
372 int curItem = mProfileBox->currentItem(); 373 int curItem = mProfileBox->currentItem();
373 mProfileBox->blockSignals( true ); 374 mProfileBox->blockSignals( true );
374 mProfileBox->clear(); 375 mProfileBox->clear();
375 mProfileBox->insertStringList (mSyncProfileNames ); 376 mProfileBox->insertStringList (mSyncProfileNames );
376 int item = mSyncProfileNames.count() -1; 377 int item = mSyncProfileNames.count() -1;
377 if ( curItem >= 0 && mSyncProfileNames.count() > 0 && curItem < mSyncProfileNames.count() ) 378 if ( curItem >= 0 && mSyncProfileNames.count() > 0 && curItem < mSyncProfileNames.count() )
378 mProfileBox->setCurrentItem( curItem ); 379 mProfileBox->setCurrentItem( curItem );
379 else if ( item >= 0 ) { 380 else if ( item >= 0 ) {
380 mProfileBox->setCurrentItem( item ); 381 mProfileBox->setCurrentItem( item );
381 } 382 }
382 currentSelection = -1; 383 currentSelection = -1;
383 if ( mSyncProfileNames.count() > 0 ) { 384 if ( mSyncProfileNames.count() > 0 ) {
384 //qDebug(" profileChanged( mProfileBox->currentItem() "); 385 //qDebug(" profileChanged( mProfileBox->currentItem() ");
385 profileChanged( mProfileBox->currentItem() ); 386 profileChanged( mProfileBox->currentItem() );
386 currentSelection = mProfileBox->currentItem(); 387 currentSelection = mProfileBox->currentItem();
387 } 388 }
388 mProfileBox->blockSignals( false ); 389 mProfileBox->blockSignals( false );
389} 390}
390 391
391void KOSyncPrefsDialog::addProfile ( KSyncProfile* temp ) 392void KOSyncPrefsDialog::addProfile ( KSyncProfile* temp )
392{ 393{
393 saveProfile(); 394 saveProfile();
394 mSyncProfiles.append( temp ); 395 mSyncProfiles.append( temp );
395 mSyncProfileNames << temp->getName(); 396 mSyncProfileNames << temp->getName();
396 insertProfiles(); 397 insertProfiles();
397 int last = mProfileBox->count() -1; 398 int last = mProfileBox->count() -1;
398 mProfileBox->blockSignals( true ); 399 mProfileBox->blockSignals( true );
399 mProfileBox->setCurrentItem( last ); 400 mProfileBox->setCurrentItem( last );
400 mProfileBox->blockSignals( false ); 401 mProfileBox->blockSignals( false );
401 profileChanged(last); 402 profileChanged(last);
402} 403}
403void KOSyncPrefsDialog::newProfile() 404void KOSyncPrefsDialog::newProfile()
404{ 405{
405 addProfile ( new KSyncProfile () ); 406 addProfile ( new KSyncProfile () );
406} 407}
407 408
408void KOSyncPrefsDialog::cloneProfile() 409void KOSyncPrefsDialog::cloneProfile()
409{ 410{
410 if ( currentSelection >= 0 ) 411 if ( currentSelection >= 0 )
411 addProfile (mSyncProfiles.at(currentSelection)->clone()) ; 412 addProfile (mSyncProfiles.at(currentSelection)->clone()) ;
412 else 413 else
413 newProfile(); 414 newProfile();
414} 415}
415 416
417void KOSyncPrefsDialog::setLocalMachineName ( const QString& name )
418{
419 mMyMachineName->setText( name );
416 420
421}
422QString KOSyncPrefsDialog::getLocalMachineName ( )
423{
424 return mMyMachineName->text();
425}
426
427QStringList KOSyncPrefsDialog::getSyncProfileNames()
428{
429 return mSyncProfileNames;
430}
417void KOSyncPrefsDialog::usrReadConfig() 431void KOSyncPrefsDialog::usrReadConfig()
418{ 432{
419 KConfig *config = KOGlobals::config(); 433 //KConfig *config = KOGlobals::config();
420 config->setGroup("SyncProfiles"); 434 KConfig config ( locateLocal( "config","syncprofilesrc" ) );
421 mSyncProfileNames = KOPrefs::instance()->mSyncProfileNames; 435 config.setGroup("SyncProfiles");
436 mSyncProfileNames =config.readListEntry("SyncProfileNames");
422 int i; 437 int i;
423 KSyncProfile* temp ; 438 KSyncProfile* temp ;
424 mSyncProfiles.clear(); 439 mSyncProfiles.clear();
425 for ( i = 0; i < mSyncProfileNames.count();++i ) { 440 for ( i = 0; i < mSyncProfileNames.count();++i ) {
426 temp = new KSyncProfile (); 441 temp = new KSyncProfile ();
427 temp->setName( mSyncProfileNames[i] ); 442 temp->setName( mSyncProfileNames[i] );
428 temp->readConfig( config ); 443 temp->readConfig( &config );
429 mSyncProfiles.append( temp ); 444 mSyncProfiles.append( temp );
430 } 445 }
431 insertProfiles(); 446 insertProfiles();
432 mMyMachineName->setText(KOPrefs::instance()->mLocalMachineName ); 447 //mMyMachineName->setText(KOPrefs::instance()->mLocalMachineName );
433} 448}
434 449
435 450
436void KOSyncPrefsDialog::usrWriteConfig() 451void KOSyncPrefsDialog::usrWriteConfig()
437{ 452{
438 saveProfile(); 453 saveProfile();
439 if ( currentSelection >= 0 ) 454 if ( currentSelection >= 0 )
440 profileChanged(currentSelection); 455 profileChanged(currentSelection);
441 KConfig *config = KOGlobals::config(); 456 //KConfig *config = KOGlobals::config();
442 config->setGroup("SyncProfiles"); 457 KConfig config ( locateLocal( "config","syncprofilesrc" ) );
458 config.setGroup("SyncProfiles");
443 KSyncProfile* prof = mSyncProfiles.first(); 459 KSyncProfile* prof = mSyncProfiles.first();
444 while ( prof ) { 460 while ( prof ) {
445 prof->writeConfig(config); 461 prof->writeConfig(&config);
446 prof = mSyncProfiles.next(); 462 prof = mSyncProfiles.next();
447 } 463 }
448 KOPrefs::instance()->mSyncProfileNames = mSyncProfileNames; 464 //KOPrefs::instance()->mSyncProfileNames = mSyncProfileNames;
449 KOPrefs::instance()->mLocalMachineName = mMyMachineName->text(); 465 //KOPrefs::instance()->mLocalMachineName = mMyMachineName->text();
450 config->writeEntry("SyncProfileNames",&mSyncProfileNames); 466 config.writeEntry("SyncProfileNames",&mSyncProfileNames);
451} 467}
452 468
diff --git a/korganizer/kosyncprefsdialog.h b/korganizer/kosyncprefsdialog.h
index d2d8c6f..541d18b 100644
--- a/korganizer/kosyncprefsdialog.h
+++ b/korganizer/kosyncprefsdialog.h
@@ -1,109 +1,113 @@
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 _KOPREFSDIALOG_H 23#ifndef _KOPREFSDIALOG_H
24#define _KOPREFSDIALOG_H 24#define _KOPREFSDIALOG_H
25 25
26//#include <qframe.h> 26//#include <qframe.h>
27//#include <qdict.h> 27//#include <qdict.h>
28#include <qvbox.h> 28#include <qvbox.h>
29#include <qhbox.h> 29#include <qhbox.h>
30//#include <qcolor.h> 30//#include <qcolor.h>
31//#include <qlistview.h> 31//#include <qlistview.h>
32 32
33#include <kdialogbase.h> 33#include <kdialogbase.h>
34 34
35#include <libkdepim/kprefsdialog.h> 35#include <libkdepim/kprefsdialog.h>
36 36
37class KColorButton; 37class KColorButton;
38class QSpinBox;; 38class QSpinBox;;
39class QRadioButton; 39class QRadioButton;
40class QCheckBox; 40class QCheckBox;
41class QSlider; 41class QSlider;
42class KURLRequester; 42class KURLRequester;
43class QComboBox; 43class QComboBox;
44class QLineEdit; 44class QLineEdit;
45class QStringList; 45class QStringList;
46class KSyncProfile; 46class KSyncProfile;
47 47
48/** Dialog to change the korganizer configuration. 48/** Dialog to change the korganizer configuration.
49 */ 49 */
50class KOSyncPrefsDialog : public KDialog 50class KOSyncPrefsDialog : public KDialog
51{ 51{
52 Q_OBJECT 52 Q_OBJECT
53 public: 53 public:
54 /** Initialize dialog and pages */ 54 /** Initialize dialog and pages */
55 KOSyncPrefsDialog(QWidget *parent=0,char *name=0,bool modal=false); 55 KOSyncPrefsDialog(QWidget *parent=0,char *name=0,bool modal=false);
56 ~KOSyncPrefsDialog(); 56 ~KOSyncPrefsDialog();
57 void usrReadConfig(); 57 void usrReadConfig();
58 void setLocalMachineName ( const QString& name );
59 QString getLocalMachineName ( );
60
61 QStringList getSyncProfileNames();
58 62
59 public slots: 63 public slots:
60 protected slots: 64 protected slots:
61 void accept(); 65 void accept();
62 void deleteProfile(); 66 void deleteProfile();
63 void newProfile(); 67 void newProfile();
64 void cloneProfile(); 68 void cloneProfile();
65 void kindChanged(bool); 69 void kindChanged(bool);
66 void fillSSH(); 70 void fillSSH();
67 void fillFTP(); 71 void fillFTP();
68 void textChanged( const QString & ); 72 void textChanged( const QString & );
69 void profileChanged( int ); 73 void profileChanged( int );
70 void chooseFile(); 74 void chooseFile();
71 void slotOK(); 75 void slotOK();
72 76
73 protected: 77 protected:
74 void usrWriteConfig(); 78 void usrWriteConfig();
75 79
76 void setupSyncAlgTab(); 80 void setupSyncAlgTab();
77 81
78 private: 82 private:
79 int currentSelection; 83 int currentSelection;
80 QPtrList<KSyncProfile> mSyncProfiles; 84 QPtrList<KSyncProfile> mSyncProfiles;
81 QStringList mSyncProfileNames; 85 QStringList mSyncProfileNames;
82 QLineEdit * mMyMachineName; 86 QLineEdit * mMyMachineName;
83 QComboBox * mProfileBox; 87 QComboBox * mProfileBox;
84 QRadioButton* mIsLocal; 88 QRadioButton* mIsLocal;
85 QRadioButton* mIsNotLocal; 89 QRadioButton* mIsNotLocal;
86 QCheckBox* mIncludeInRing; 90 QCheckBox* mIncludeInRing;
87 void addProfile ( KSyncProfile* ); 91 void addProfile ( KSyncProfile* );
88 void insertProfiles(); 92 void insertProfiles();
89 void saveProfile(); 93 void saveProfile();
90 QButtonGroup* proGr; 94 QButtonGroup* proGr;
91 95
92 QRadioButton* loc, *rem, *newest, *ask, *f_loc,* f_rem, *both; 96 QRadioButton* loc, *rem, *newest, *ask, *f_loc,* f_rem, *both;
93 97
94 98
95 QLineEdit * mRemotePostcommand; 99 QLineEdit * mRemotePostcommand;
96 QLineEdit * mRemotePrecommand; 100 QLineEdit * mRemotePrecommand;
97 QLineEdit * mRemoteFile; 101 QLineEdit * mRemoteFile;
98 QLineEdit * mLocalTempFile; 102 QLineEdit * mLocalTempFile;
99 QWidget* mSetupSyncAlgTab; 103 QWidget* mSetupSyncAlgTab;
100 104
101 QVBox* localFileWidget; 105 QVBox* localFileWidget;
102 QVBox* remoteFileWidget; 106 QVBox* remoteFileWidget;
103 QCheckBox* mWriteBackFile; 107 QCheckBox* mWriteBackFile;
104 QCheckBox* mWriteBackExisting; 108 QCheckBox* mWriteBackExisting;
105 QCheckBox* mAskForPreferences; 109 QCheckBox* mAskForPreferences;
106 QCheckBox* mShowSummaryAfterSync; 110 QCheckBox* mShowSummaryAfterSync;
107}; 111};
108 112
109#endif 113#endif
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index a487f14..589ab2d 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1,1994 +1,1993 @@
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 821 KConfig config ( locateLocal( "config","syncprofilesrc" ) );
822 QStringList prof = KOPrefs::instance()->mSyncProfileNames; 822 config.setGroup("SyncProfiles");
823 823 QStringList prof = config.readListEntry("SyncProfileNames");
824
824 if ( prof.count() < 3 ) { 825 if ( prof.count() < 3 ) {
825 KConfig *config = KOGlobals::config();
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->sync(); 837 config.sync();
838 delete temp; 838 delete temp;
839 KOPrefs::instance()->mSyncProfileNames = prof;
840 } 839 }
841 840 KOPrefs::instance()->mSyncProfileNames = prof;
842 int i; 841 int i;
843 for ( i = 0; i < prof.count(); ++i ) { 842 for ( i = 0; i < prof.count(); ++i ) {
844 843
845 syncMenu->insertItem( prof[i], 1000+i ); 844 syncMenu->insertItem( prof[i], 1000+i );
846 if ( i == 2 ) 845 if ( i == 2 )
847 syncMenu->insertSeparator(); 846 syncMenu->insertSeparator();
848 } 847 }
849 QDir app_dir; 848 QDir app_dir;
850 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { 849 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
851 syncMenu->setItemEnabled( false , 1000 ); 850 syncMenu->setItemEnabled( false , 1000 );
852 } 851 }
853} 852}
854 853
855int MainWindow::ringSync() 854int MainWindow::ringSync()
856{ 855{
857 int syncedProfiles = 0; 856 int syncedProfiles = 0;
858 int i; 857 int i;
859 QTime timer; 858 QTime timer;
860 KConfig *config = KOGlobals::config(); 859 KConfig *config = KOGlobals::config();
861 QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames; 860 QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames;
862 KSyncProfile* temp = new KSyncProfile (); 861 KSyncProfile* temp = new KSyncProfile ();
863 KOPrefs::instance()->mAskForPreferences = false; 862 KOPrefs::instance()->mAskForPreferences = false;
864 for ( i = 0; i < syncProfileNames.count(); ++i ) { 863 for ( i = 0; i < syncProfileNames.count(); ++i ) {
865 mCurrentSyncProfile = i; 864 mCurrentSyncProfile = i;
866 temp->setName(syncProfileNames[mCurrentSyncProfile]); 865 temp->setName(syncProfileNames[mCurrentSyncProfile]);
867 temp->readConfig(config); 866 temp->readConfig(config);
868 if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) { 867 if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) {
869 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); 868 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
870 ++syncedProfiles; 869 ++syncedProfiles;
871 // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 870 // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
872 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 871 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
873 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 872 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
874 KOPrefs::instance()->mShowSyncSummary = false; 873 KOPrefs::instance()->mShowSyncSummary = false;
875 mView->setSyncDevice(syncProfileNames[i] ); 874 mView->setSyncDevice(syncProfileNames[i] );
876 mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); 875 mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
877 if ( i == 0 ) { 876 if ( i == 0 ) {
878 syncSharp(); 877 syncSharp();
879 } else { 878 } else {
880 if ( temp->getIsLocalFileSync() ) { 879 if ( temp->getIsLocalFileSync() ) {
881 if ( syncWithFile( temp->getRemoteFileName( ), true ) ) 880 if ( syncWithFile( temp->getRemoteFileName( ), true ) )
882 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); 881 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName();
883 } else { 882 } else {
884 syncRemote( temp, false ); 883 syncRemote( temp, false );
885 884
886 } 885 }
887 } 886 }
888 timer.start(); 887 timer.start();
889 setCaption(i18n("Multiple sync in progress ... please wait!") ); 888 setCaption(i18n("Multiple sync in progress ... please wait!") );
890 while ( timer.elapsed () < 2000 ) { 889 while ( timer.elapsed () < 2000 ) {
891 qApp->processEvents(); 890 qApp->processEvents();
892#ifndef _WIN32_ 891#ifndef _WIN32_
893 sleep (1); 892 sleep (1);
894#endif 893#endif
895 } 894 }
896 895
897 } 896 }
898 897
899 } 898 }
900 delete temp; 899 delete temp;
901 return syncedProfiles; 900 return syncedProfiles;
902} 901}
903 902
904void MainWindow::multiSync( bool askforPrefs ) 903void MainWindow::multiSync( bool askforPrefs )
905{ 904{
906 if (mBlockSaveFlag) 905 if (mBlockSaveFlag)
907 return; 906 return;
908 mBlockSaveFlag = true; 907 mBlockSaveFlag = true;
909 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 908 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
910 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 909 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
911 question, 910 question,
912 i18n("Yes"), i18n("No"), 911 i18n("Yes"), i18n("No"),
913 0, 0 ) != 0 ) { 912 0, 0 ) != 0 ) {
914 mBlockSaveFlag = false; 913 mBlockSaveFlag = false;
915 setCaption(i18n("Aborted! Nothing synced!")); 914 setCaption(i18n("Aborted! Nothing synced!"));
916 return; 915 return;
917 } 916 }
918 mView->setSyncDevice(i18n("Multiple profiles") ); 917 mView->setSyncDevice(i18n("Multiple profiles") );
919 KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs; 918 KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs;
920 if ( askforPrefs ) { 919 if ( askforPrefs ) {
921 mView->edit_sync_options(); 920 mView->edit_sync_options();
922 KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs; 921 KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs;
923 } 922 }
924 setCaption(i18n("Multiple sync started.") ); 923 setCaption(i18n("Multiple sync started.") );
925 qApp->processEvents(); 924 qApp->processEvents();
926 int num = ringSync() ; 925 int num = ringSync() ;
927 if ( num > 1 ) 926 if ( num > 1 )
928 ringSync(); 927 ringSync();
929 mBlockSaveFlag = false; 928 mBlockSaveFlag = false;
930 if ( num ) 929 if ( num )
931 save(); 930 save();
932 if ( num ) 931 if ( num )
933 setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); 932 setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) );
934 else 933 else
935 setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 934 setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
936 return; 935 return;
937} 936}
938void MainWindow::slotSyncMenu( int action ) 937void MainWindow::slotSyncMenu( int action )
939{ 938{
940 //qDebug("syncaction %d ", action); 939 //qDebug("syncaction %d ", action);
941 if ( action == 0 ) { 940 if ( action == 0 ) {
942 941
943 confSync(); 942 confSync();
944 943
945 return; 944 return;
946 } 945 }
947 if ( action == 1 ) { 946 if ( action == 1 ) {
948 multiSync( true ); 947 multiSync( true );
949 return; 948 return;
950 } 949 }
951 950
952 if (mBlockSaveFlag) 951 if (mBlockSaveFlag)
953 return; 952 return;
954 mBlockSaveFlag = true; 953 mBlockSaveFlag = true;
955 mCurrentSyncProfile = action - 1000 ; 954 mCurrentSyncProfile = action - 1000 ;
956 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); 955 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] );
957 mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); 956 mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
958 KConfig *config = KOGlobals::config(); 957 KConfig *config = KOGlobals::config();
959 KSyncProfile* temp = new KSyncProfile (); 958 KSyncProfile* temp = new KSyncProfile ();
960 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 959 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
961 temp->readConfig(config); 960 temp->readConfig(config);
962 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 961 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
963 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); 962 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs();
964 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 963 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
965 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 964 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
966 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); 965 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync();
967 if ( action == 1000 ) { 966 if ( action == 1000 ) {
968 syncSharp(); 967 syncSharp();
969 968
970 } else if ( action == 1001 ) { 969 } else if ( action == 1001 ) {
971 syncLocalFile(); 970 syncLocalFile();
972 971
973 } else if ( action == 1002 ) { 972 } else if ( action == 1002 ) {
974 quickSyncLocalFile(); 973 quickSyncLocalFile();
975 974
976 } else if ( action >= 1003 ) { 975 } else if ( action >= 1003 ) {
977 if ( temp->getIsLocalFileSync() ) { 976 if ( temp->getIsLocalFileSync() ) {
978 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 977 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
979 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); 978 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName();
980 } else { 979 } else {
981 syncRemote( temp ); 980 syncRemote( temp );
982 981
983 } 982 }
984 } 983 }
985 delete temp; 984 delete temp;
986 mBlockSaveFlag = false; 985 mBlockSaveFlag = false;
987} 986}
988void MainWindow::setDefaultPreferences() 987void MainWindow::setDefaultPreferences()
989{ 988{
990 KOPrefs *p = KOPrefs::instance(); 989 KOPrefs *p = KOPrefs::instance();
991 990
992 p->mCompactDialogs = true; 991 p->mCompactDialogs = true;
993 p->mConfirm = true; 992 p->mConfirm = true;
994 // p->mEnableQuickTodo = false; 993 // p->mEnableQuickTodo = false;
995} 994}
996 995
997QString MainWindow::resourcePath() 996QString MainWindow::resourcePath()
998{ 997{
999 return KGlobal::iconLoader()->iconPath(); 998 return KGlobal::iconLoader()->iconPath();
1000} 999}
1001 1000
1002void MainWindow::displayText( QString text ,QString cap ) 1001void MainWindow::displayText( QString text ,QString cap )
1003{ 1002{
1004 QDialog dia( this, "name", true ); ; 1003 QDialog dia( this, "name", true ); ;
1005 dia.setCaption( cap ); 1004 dia.setCaption( cap );
1006 QVBoxLayout* lay = new QVBoxLayout( &dia ); 1005 QVBoxLayout* lay = new QVBoxLayout( &dia );
1007 lay->setSpacing( 3 ); 1006 lay->setSpacing( 3 );
1008 lay->setMargin( 3 ); 1007 lay->setMargin( 3 );
1009 QTextBrowser tb ( &dia ); 1008 QTextBrowser tb ( &dia );
1010 lay->addWidget( &tb ); 1009 lay->addWidget( &tb );
1011 tb.setText( text ); 1010 tb.setText( text );
1012#ifdef DESKTOP_VERSION 1011#ifdef DESKTOP_VERSION
1013 dia.resize( 640, 480); 1012 dia.resize( 640, 480);
1014#else 1013#else
1015 dia.showMaximized(); 1014 dia.showMaximized();
1016#endif 1015#endif
1017 dia.exec(); 1016 dia.exec();
1018} 1017}
1019void MainWindow::displayFile( QString fn, QString cap ) 1018void MainWindow::displayFile( QString fn, QString cap )
1020{ 1019{
1021 QString fileName = resourcePath() + fn; 1020 QString fileName = resourcePath() + fn;
1022 QString text; 1021 QString text;
1023 QFile file( fileName ); 1022 QFile file( fileName );
1024 if (!file.open( IO_ReadOnly ) ) { 1023 if (!file.open( IO_ReadOnly ) ) {
1025 return ; 1024 return ;
1026 1025
1027 } 1026 }
1028 QTextStream ts( &file ); 1027 QTextStream ts( &file );
1029 text = ts.read(); 1028 text = ts.read();
1030 file.close(); 1029 file.close();
1031 displayText( text, cap); 1030 displayText( text, cap);
1032} 1031}
1033void MainWindow::features() 1032void MainWindow::features()
1034{ 1033{
1035 1034
1036 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); 1035 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") );
1037} 1036}
1038 1037
1039void MainWindow::usertrans() 1038void MainWindow::usertrans()
1040{ 1039{
1041 1040
1042 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); 1041 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") );
1043} 1042}
1044void MainWindow::synchowto() 1043void MainWindow::synchowto()
1045{ 1044{
1046 1045
1047 displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") ); 1046 displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") );
1048} 1047}
1049void MainWindow::faq() 1048void MainWindow::faq()
1050{ 1049{
1051 displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); 1050 displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") );
1052 1051
1053} 1052}
1054void MainWindow::whatsNew() 1053void MainWindow::whatsNew()
1055{ 1054{
1056 displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") ); 1055 displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") );
1057 1056
1058} 1057}
1059void MainWindow::about() 1058void MainWindow::about()
1060{ 1059{
1061 QString version; 1060 QString version;
1062#include <../version> 1061#include <../version>
1063 QMessageBox::about( this, i18n("About KOrganizer/Pi"), 1062 QMessageBox::about( this, i18n("About KOrganizer/Pi"),
1064 i18n("KOrganizer/Platform-independent\n") + 1063 i18n("KOrganizer/Platform-independent\n") +
1065 "(KO/Pi) " + version + " - " + 1064 "(KO/Pi) " + version + " - " +
1066 1065
1067#ifdef DESKTOP_VERSION 1066#ifdef DESKTOP_VERSION
1068 i18n("Desktop Edition\n") + 1067 i18n("Desktop Edition\n") +
1069#else 1068#else
1070 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + 1069 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") +
1071#endif 1070#endif
1072 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") ); 1071 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") );
1073} 1072}
1074void MainWindow::keyBindings() 1073void MainWindow::keyBindings()
1075{ 1074{
1076 QString cap = i18n("Key bindings KOrganizer/Pi"); 1075 QString cap = i18n("Key bindings KOrganizer/Pi");
1077 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + 1076 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") +
1078 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ 1077 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+
1079 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + 1078 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") +
1080 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ 1079 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+
1081 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ 1080 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+
1082 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ 1081 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+
1083 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ 1082 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+
1084 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ 1083 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+
1085 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ 1084 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+
1086 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ 1085 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+
1087 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ 1086 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+
1088 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ 1087 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+
1089 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ 1088 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+
1090 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ 1089 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+
1091 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ 1090 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+
1092 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ 1091 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+
1093 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ 1092 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+
1094 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ 1093 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+
1095 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ 1094 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+
1096 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ 1095 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+
1097 i18n("<p><h3>In agenda view:</h3></p>\n") + 1096 i18n("<p><h3>In agenda view:</h3></p>\n") +
1098 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ 1097 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+
1099 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ 1098 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+
1100 i18n("<p><h3>In todo view:</h3></p>\n") + 1099 i18n("<p><h3>In todo view:</h3></p>\n") +
1101 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ 1100 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+
1102 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1101 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1103 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ 1102 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+
1104 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ 1103 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+
1105 i18n("<p><h3>In list view:</h3></p>\n") + 1104 i18n("<p><h3>In list view:</h3></p>\n") +
1106 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1105 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1107 i18n("<p><b>return</b>: Select item+one step down</p>\n")+ 1106 i18n("<p><b>return</b>: Select item+one step down</p>\n")+
1108 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ 1107 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+
1109 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ 1108 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+
1110 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ 1109 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+
1111 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ 1110 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+
1112 i18n("<p><h3>In event/todo viewer:</h3></p>\n") + 1111 i18n("<p><h3>In event/todo viewer:</h3></p>\n") +
1113 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ 1112 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+
1114 i18n("<p><b>A</b>: Show agenda view.</p>\n")+ 1113 i18n("<p><b>A</b>: Show agenda view.</p>\n")+
1115 i18n("<p><b>E</b>: Edit item</p>\n") + 1114 i18n("<p><b>E</b>: Edit item</p>\n") +
1116 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + 1115 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") +
1117 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + 1116 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") +
1118 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ 1117 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+
1119 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ 1118 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+
1120 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ 1119 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+
1121 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ 1120 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+
1122 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ 1121 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+
1123 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + 1122 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") +
1124 i18n("<p><b>White</b>: Item readonly</p>\n"); 1123 i18n("<p><b>White</b>: Item readonly</p>\n");
1125 displayText( text, cap); 1124 displayText( text, cap);
1126 1125
1127} 1126}
1128void MainWindow::aboutAutoSaving() 1127void MainWindow::aboutAutoSaving()
1129{ 1128{
1130 QMessageBox* msg; 1129 QMessageBox* msg;
1131 msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), 1130 msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"),
1132 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, 1131 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,
1133 QMessageBox::Ok, 1132 QMessageBox::Ok,
1134 QMessageBox::NoButton, 1133 QMessageBox::NoButton,
1135 QMessageBox::NoButton); 1134 QMessageBox::NoButton);
1136 msg->exec(); 1135 msg->exec();
1137 delete msg; 1136 delete msg;
1138 1137
1139 1138
1140} 1139}
1141void MainWindow::aboutKnownBugs() 1140void MainWindow::aboutKnownBugs()
1142{ 1141{
1143 QMessageBox* msg; 1142 QMessageBox* msg;
1144 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), 1143 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"),
1145 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")+ 1144 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")+
1146 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ 1145 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+
1147 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + 1146 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") +
1148 i18n("\nor report them in the bugtracker on\n") + 1147 i18n("\nor report them in the bugtracker on\n") +
1149 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), 1148 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"),
1150 QMessageBox::NoIcon, 1149 QMessageBox::NoIcon,
1151 QMessageBox::Ok, 1150 QMessageBox::Ok,
1152 QMessageBox::NoButton, 1151 QMessageBox::NoButton,
1153 QMessageBox::NoButton); 1152 QMessageBox::NoButton);
1154 msg->exec(); 1153 msg->exec();
1155 delete msg; 1154 delete msg;
1156 1155
1157} 1156}
1158 1157
1159QString MainWindow::defaultFileName() 1158QString MainWindow::defaultFileName()
1160{ 1159{
1161 return locateLocal( "data", "korganizer/mycalendar.ics" ); 1160 return locateLocal( "data", "korganizer/mycalendar.ics" );
1162} 1161}
1163 1162
1164void MainWindow::processIncidenceSelection( Incidence *incidence ) 1163void MainWindow::processIncidenceSelection( Incidence *incidence )
1165{ 1164{
1166 if ( !incidence ) { 1165 if ( !incidence ) {
1167 enableIncidenceActions( false ); 1166 enableIncidenceActions( false );
1168 1167
1169 mNewSubTodoAction->setEnabled( false ); 1168 mNewSubTodoAction->setEnabled( false );
1170 setCaptionToDates(); 1169 setCaptionToDates();
1171 return; 1170 return;
1172 1171
1173 } 1172 }
1174 1173
1175 //KGlobal::locale()->formatDateTime(nextA, true); 1174 //KGlobal::locale()->formatDateTime(nextA, true);
1176 QString startString = ""; 1175 QString startString = "";
1177 if ( incidence->type() != "Todo" ) { 1176 if ( incidence->type() != "Todo" ) {
1178 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { 1177 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) {
1179 if ( incidence->doesFloat() ) { 1178 if ( incidence->doesFloat() ) {
1180 startString += ": "+incidence->dtStartDateStr( true ); 1179 startString += ": "+incidence->dtStartDateStr( true );
1181 startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); 1180 startString += " --- "+((Event*)incidence)->dtEndDateStr( true );
1182 1181
1183 } else { 1182 } else {
1184 startString = ": "+incidence->dtStartStr(true); 1183 startString = ": "+incidence->dtStartStr(true);
1185 startString += " --- "+((Event*)incidence)->dtEndStr(true); 1184 startString += " --- "+((Event*)incidence)->dtEndStr(true);
1186 1185
1187 } 1186 }
1188 1187
1189 } else { 1188 } else {
1190 if ( incidence->dtStart().time() != incidence->dtEnd().time() ) 1189 if ( incidence->dtStart().time() != incidence->dtEnd().time() )
1191 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ 1190 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+
1192 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); 1191 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time());
1193 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); 1192 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true);
1194 } 1193 }
1195 1194
1196 } 1195 }
1197 else 1196 else
1198 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); 1197 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed");
1199 if ( !incidence->location().isEmpty() ) 1198 if ( !incidence->location().isEmpty() )
1200 startString += " (" +incidence->location()+")"; 1199 startString += " (" +incidence->location()+")";
1201 setCaption( incidence->summary()+startString); 1200 setCaption( incidence->summary()+startString);
1202 1201
1203 enableIncidenceActions( true ); 1202 enableIncidenceActions( true );
1204 1203
1205 if ( incidence->type() == "Event" ) { 1204 if ( incidence->type() == "Event" ) {
1206 mShowAction->setText( i18n("Show Event...") ); 1205 mShowAction->setText( i18n("Show Event...") );
1207 mEditAction->setText( i18n("Edit Event...") ); 1206 mEditAction->setText( i18n("Edit Event...") );
1208 mDeleteAction->setText( i18n("Delete Event...") ); 1207 mDeleteAction->setText( i18n("Delete Event...") );
1209 1208
1210 mNewSubTodoAction->setEnabled( false ); 1209 mNewSubTodoAction->setEnabled( false );
1211 } else if ( incidence->type() == "Todo" ) { 1210 } else if ( incidence->type() == "Todo" ) {
1212 mShowAction->setText( i18n("Show Todo...") ); 1211 mShowAction->setText( i18n("Show Todo...") );
1213 mEditAction->setText( i18n("Edit Todo...") ); 1212 mEditAction->setText( i18n("Edit Todo...") );
1214 mDeleteAction->setText( i18n("Delete Todo...") ); 1213 mDeleteAction->setText( i18n("Delete Todo...") );
1215 1214
1216 mNewSubTodoAction->setEnabled( true ); 1215 mNewSubTodoAction->setEnabled( true );
1217 } else { 1216 } else {
1218 mShowAction->setText( i18n("Show...") ); 1217 mShowAction->setText( i18n("Show...") );
1219 mShowAction->setText( i18n("Edit...") ); 1218 mShowAction->setText( i18n("Edit...") );
1220 mShowAction->setText( i18n("Delete...") ); 1219 mShowAction->setText( i18n("Delete...") );
1221 1220
1222 mNewSubTodoAction->setEnabled( false ); 1221 mNewSubTodoAction->setEnabled( false );
1223 } 1222 }
1224} 1223}
1225 1224
1226void MainWindow::enableIncidenceActions( bool enabled ) 1225void MainWindow::enableIncidenceActions( bool enabled )
1227{ 1226{
1228 mShowAction->setEnabled( enabled ); 1227 mShowAction->setEnabled( enabled );
1229 mEditAction->setEnabled( enabled ); 1228 mEditAction->setEnabled( enabled );
1230 mDeleteAction->setEnabled( enabled ); 1229 mDeleteAction->setEnabled( enabled );
1231} 1230}
1232 1231
1233void MainWindow::importOL() 1232void MainWindow::importOL()
1234{ 1233{
1235#ifdef _WIN32_ 1234#ifdef _WIN32_
1236 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); 1235 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this );
1237 id->exec(); 1236 id->exec();
1238 delete id; 1237 delete id;
1239 mView->updateView(); 1238 mView->updateView();
1240#endif 1239#endif
1241} 1240}
1242void MainWindow::importBday() 1241void MainWindow::importBday()
1243{ 1242{
1244 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1243 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1245 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), 1244 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"),
1246 i18n("Import!"), i18n("Cancel"), 0, 1245 i18n("Import!"), i18n("Cancel"), 0,
1247 0, 1 ); 1246 0, 1 );
1248 if ( result == 0 ) { 1247 if ( result == 0 ) {
1249 mView->importBday(); 1248 mView->importBday();
1250 1249
1251 } 1250 }
1252 1251
1253 1252
1254} 1253}
1255void MainWindow::importQtopia() 1254void MainWindow::importQtopia()
1256{ 1255{
1257#ifndef DESKTOP_VERSION 1256#ifndef DESKTOP_VERSION
1258 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1257 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1259 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"), 1258 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"),
1260 i18n("Import!"), i18n("Cancel"), 0, 1259 i18n("Import!"), i18n("Cancel"), 0,
1261 0, 1 ); 1260 0, 1 );
1262 if ( result == 0 ) { 1261 if ( result == 0 ) {
1263 QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); 1262 QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
1264 QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); 1263 QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
1265 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; 1264 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
1266 mView->importQtopia( categories, datebook, todolist ); 1265 mView->importQtopia( categories, datebook, todolist );
1267 } 1266 }
1268#else 1267#else
1269 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1268 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1270 i18n("Not supported \non desktop!\n"), 1269 i18n("Not supported \non desktop!\n"),
1271 i18n("Ok"), i18n("Cancel"), 0, 1270 i18n("Ok"), i18n("Cancel"), 0,
1272 0, 1 ); 1271 0, 1 );
1273 1272
1274#endif 1273#endif
1275} 1274}
1276 1275
1277void MainWindow::saveOnClose() 1276void MainWindow::saveOnClose()
1278{ 1277{
1279 KOPrefs *p = KOPrefs::instance(); 1278 KOPrefs *p = KOPrefs::instance();
1280 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); 1279 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
1281 p->mToolBarUp = iconToolBar->x() > width()/2 || 1280 p->mToolBarUp = iconToolBar->x() > width()/2 ||
1282 iconToolBar->y() > height()/2; 1281 iconToolBar->y() > height()/2;
1283 mView->writeSettings(); 1282 mView->writeSettings();
1284 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) 1283 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName()))
1285 save(); 1284 save();
1286} 1285}
1287void MainWindow::slotModifiedChanged( bool changed ) 1286void MainWindow::slotModifiedChanged( bool changed )
1288{ 1287{
1289 if ( mBlockAtStartup ) 1288 if ( mBlockAtStartup )
1290 return; 1289 return;
1291 int msec; 1290 int msec;
1292 // we store the changes after 1 minute, 1291 // we store the changes after 1 minute,
1293 // and for safety reasons after 10 minutes again 1292 // and for safety reasons after 10 minutes again
1294 if ( !mBlockSaveFlag ) 1293 if ( !mBlockSaveFlag )
1295 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1294 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1296 else 1295 else
1297 msec = 1000 * 600; 1296 msec = 1000 * 600;
1298 mSaveTimer.start( msec, true ); // 1 minute 1297 mSaveTimer.start( msec, true ); // 1 minute
1299 qDebug("KO: Saving File in %d secs!", msec/1000); 1298 qDebug("KO: Saving File in %d secs!", msec/1000);
1300 mCalendarModifiedFlag = true; 1299 mCalendarModifiedFlag = true;
1301} 1300}
1302#include <qfileinfo.h> 1301#include <qfileinfo.h>
1303void MainWindow::save() 1302void MainWindow::save()
1304{ 1303{
1305 if ( mBlockSaveFlag ) 1304 if ( mBlockSaveFlag )
1306 return; 1305 return;
1307 bool store = mBlockSaveFlag; 1306 bool store = mBlockSaveFlag;
1308 mBlockSaveFlag = true; 1307 mBlockSaveFlag = true;
1309 if ( mView->checkFileVersion( defaultFileName()) ) { 1308 if ( mView->checkFileVersion( defaultFileName()) ) {
1310 1309
1311 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1310 QTime neededSaveTime = QDateTime::currentDateTime().time();
1312 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1311 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1313 qDebug("KO: Start saving data to file!"); 1312 qDebug("KO: Start saving data to file!");
1314 mView->saveCalendar( defaultFileName() ); 1313 mView->saveCalendar( defaultFileName() );
1315 1314
1316 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 1315 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1317 mView->setLoadedFileVersion(QDateTime::currentDateTime()); 1316 mView->setLoadedFileVersion(QDateTime::currentDateTime());
1318 qDebug("KO: Needed %d ms for saving.",msNeeded ); 1317 qDebug("KO: Needed %d ms for saving.",msNeeded );
1319 QString savemes; 1318 QString savemes;
1320 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 1319 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
1321 setCaption(savemes); 1320 setCaption(savemes);
1322 } else 1321 } else
1323 setCaption(i18n("Saving cancelled!")); 1322 setCaption(i18n("Saving cancelled!"));
1324 mCalendarModifiedFlag = false; 1323 mCalendarModifiedFlag = false;
1325 mBlockSaveFlag = store; 1324 mBlockSaveFlag = store;
1326} 1325}
1327 1326
1328void MainWindow::keyReleaseEvent ( QKeyEvent * e) 1327void MainWindow::keyReleaseEvent ( QKeyEvent * e)
1329{ 1328{
1330 if ( !e->isAutoRepeat() ) { 1329 if ( !e->isAutoRepeat() ) {
1331 mFlagKeyPressed = false; 1330 mFlagKeyPressed = false;
1332 } 1331 }
1333} 1332}
1334void MainWindow::keyPressEvent ( QKeyEvent * e ) 1333void MainWindow::keyPressEvent ( QKeyEvent * e )
1335{ 1334{
1336 qApp->processEvents(); 1335 qApp->processEvents();
1337 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 1336 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1338 e->ignore(); 1337 e->ignore();
1339 // qDebug(" ignore %d",e->isAutoRepeat() ); 1338 // qDebug(" ignore %d",e->isAutoRepeat() );
1340 return; 1339 return;
1341 } 1340 }
1342 if (! e->isAutoRepeat() ) 1341 if (! e->isAutoRepeat() )
1343 mFlagKeyPressed = true; 1342 mFlagKeyPressed = true;
1344 KOPrefs *p = KOPrefs::instance(); 1343 KOPrefs *p = KOPrefs::instance();
1345 bool showSelectedDates = false; 1344 bool showSelectedDates = false;
1346 int size; 1345 int size;
1347 int pro = 0; 1346 int pro = 0;
1348 //qDebug("MainWindow::keyPressEvent "); 1347 //qDebug("MainWindow::keyPressEvent ");
1349 switch ( e->key() ) { 1348 switch ( e->key() ) {
1350 case Qt::Key_Right: 1349 case Qt::Key_Right:
1351 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1350 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1352 mView->goNextMonth(); 1351 mView->goNextMonth();
1353 else 1352 else
1354 mView->goNext(); 1353 mView->goNext();
1355 showSelectedDates = true; 1354 showSelectedDates = true;
1356 break; 1355 break;
1357 case Qt::Key_Left: 1356 case Qt::Key_Left:
1358 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1357 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1359 mView->goPreviousMonth(); 1358 mView->goPreviousMonth();
1360 else 1359 else
1361 mView->goPrevious(); 1360 mView->goPrevious();
1362 showSelectedDates = true; 1361 showSelectedDates = true;
1363 break; 1362 break;
1364 case Qt::Key_Down: 1363 case Qt::Key_Down:
1365 mView->viewManager()->agendaView()->scrollOneHourDown(); 1364 mView->viewManager()->agendaView()->scrollOneHourDown();
1366 break; 1365 break;
1367 case Qt::Key_Up: 1366 case Qt::Key_Up:
1368 mView->viewManager()->agendaView()->scrollOneHourUp(); 1367 mView->viewManager()->agendaView()->scrollOneHourUp();
1369 break; 1368 break;
1370 case Qt::Key_I: 1369 case Qt::Key_I:
1371 mView->showIncidence(); 1370 mView->showIncidence();
1372 break; 1371 break;
1373 case Qt::Key_Delete: 1372 case Qt::Key_Delete:
1374 case Qt::Key_Backspace: 1373 case Qt::Key_Backspace:
1375 mView->deleteIncidence(); 1374 mView->deleteIncidence();
1376 break; 1375 break;
1377 case Qt::Key_D: 1376 case Qt::Key_D:
1378 mView->viewManager()->showDayView(); 1377 mView->viewManager()->showDayView();
1379 showSelectedDates = true; 1378 showSelectedDates = true;
1380 break; 1379 break;
1381 case Qt::Key_O: 1380 case Qt::Key_O:
1382 mView->toggleFilerEnabled( ); 1381 mView->toggleFilerEnabled( );
1383 break; 1382 break;
1384 case Qt::Key_0: 1383 case Qt::Key_0:
1385 case Qt::Key_1: 1384 case Qt::Key_1:
1386 case Qt::Key_2: 1385 case Qt::Key_2:
1387 case Qt::Key_3: 1386 case Qt::Key_3:
1388 case Qt::Key_4: 1387 case Qt::Key_4:
1389 case Qt::Key_5: 1388 case Qt::Key_5:
1390 case Qt::Key_6: 1389 case Qt::Key_6:
1391 case Qt::Key_7: 1390 case Qt::Key_7:
1392 case Qt::Key_8: 1391 case Qt::Key_8:
1393 case Qt::Key_9: 1392 case Qt::Key_9:
1394 pro = e->key()-48; 1393 pro = e->key()-48;
1395 if ( pro == 0 ) 1394 if ( pro == 0 )
1396 pro = 10; 1395 pro = 10;
1397 if ( e->state() == Qt::ControlButton) 1396 if ( e->state() == Qt::ControlButton)
1398 pro += 10; 1397 pro += 10;
1399 break; 1398 break;
1400 case Qt::Key_M: 1399 case Qt::Key_M:
1401 mView->viewManager()->showMonthView(); 1400 mView->viewManager()->showMonthView();
1402 showSelectedDates = true; 1401 showSelectedDates = true;
1403 break; 1402 break;
1404 case Qt::Key_Insert: 1403 case Qt::Key_Insert:
1405 mView->newEvent(); 1404 mView->newEvent();
1406 break; 1405 break;
1407 case Qt::Key_S : 1406 case Qt::Key_S :
1408 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1407 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1409 mView->newSubTodo(); 1408 mView->newSubTodo();
1410 else 1409 else
1411 mView->dialogManager()->showSearchDialog(); 1410 mView->dialogManager()->showSearchDialog();
1412 break; 1411 break;
1413 case Qt::Key_Y : 1412 case Qt::Key_Y :
1414 case Qt::Key_Z : 1413 case Qt::Key_Z :
1415 mView->viewManager()->showWorkWeekView(); 1414 mView->viewManager()->showWorkWeekView();
1416 showSelectedDates = true; 1415 showSelectedDates = true;
1417 break; 1416 break;
1418 case Qt::Key_U : 1417 case Qt::Key_U :
1419 mView->viewManager()->showWeekView(); 1418 mView->viewManager()->showWeekView();
1420 showSelectedDates = true; 1419 showSelectedDates = true;
1421 break; 1420 break;
1422 case Qt::Key_H : 1421 case Qt::Key_H :
1423 keyBindings(); 1422 keyBindings();
1424 break; 1423 break;
1425 case Qt::Key_W: 1424 case Qt::Key_W:
1426 mView->viewManager()->showWhatsNextView(); 1425 mView->viewManager()->showWhatsNextView();
1427 break; 1426 break;
1428 case Qt::Key_L: 1427 case Qt::Key_L:
1429 mView->viewManager()->showListView(); 1428 mView->viewManager()->showListView();
1430 break; 1429 break;
1431 case Qt::Key_N: 1430 case Qt::Key_N:
1432 mView->viewManager()->showNextXView(); 1431 mView->viewManager()->showNextXView();
1433 showSelectedDates = true; 1432 showSelectedDates = true;
1434 break; 1433 break;
1435 case Qt::Key_V: 1434 case Qt::Key_V:
1436 mView->viewManager()->showTodoView(); 1435 mView->viewManager()->showTodoView();
1437 break; 1436 break;
1438 case Qt::Key_C: 1437 case Qt::Key_C:
1439 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); 1438 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() );
1440 break; 1439 break;
1441 case Qt::Key_P: 1440 case Qt::Key_P:
1442 mView->showDatePicker( ); 1441 mView->showDatePicker( );
1443 break; 1442 break;
1444 case Qt::Key_F: 1443 case Qt::Key_F:
1445 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1444 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1446 mView->editFilters(); 1445 mView->editFilters();
1447 else 1446 else
1448 mView->toggleFilter(); 1447 mView->toggleFilter();
1449 break; 1448 break;
1450 case Qt::Key_X: 1449 case Qt::Key_X:
1451 mView->toggleDateNavigatorWidget(); 1450 mView->toggleDateNavigatorWidget();
1452 break; 1451 break;
1453 case Qt::Key_Space: 1452 case Qt::Key_Space:
1454 mView->toggleExpand(); 1453 mView->toggleExpand();
1455 break; 1454 break;
1456 case Qt::Key_A: 1455 case Qt::Key_A:
1457 mView->toggleAllDaySize(); 1456 mView->toggleAllDaySize();
1458 break; 1457 break;
1459 case Qt::Key_T: 1458 case Qt::Key_T:
1460 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1459 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1461 mView->newTodo(); 1460 mView->newTodo();
1462 else { 1461 else {
1463 mView->goToday(); 1462 mView->goToday();
1464 showSelectedDates = true; 1463 showSelectedDates = true;
1465 } 1464 }
1466 break; 1465 break;
1467 case Qt::Key_J: 1466 case Qt::Key_J:
1468 mView->viewManager()->showJournalView(); 1467 mView->viewManager()->showJournalView();
1469 break; 1468 break;
1470 case Qt::Key_B: 1469 case Qt::Key_B:
1471 mView->editIncidenceDescription();; 1470 mView->editIncidenceDescription();;
1472 break; 1471 break;
1473 // case Qt::Key_Return: 1472 // case Qt::Key_Return:
1474 case Qt::Key_E: 1473 case Qt::Key_E:
1475 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1474 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1476 mView->newEvent(); 1475 mView->newEvent();
1477 else 1476 else
1478 mView->editIncidence(); 1477 mView->editIncidence();
1479 break; 1478 break;
1480 case Qt::Key_Plus: 1479 case Qt::Key_Plus:
1481 size = p->mHourSize +2; 1480 size = p->mHourSize +2;
1482 if ( size <= 18 ) 1481 if ( size <= 18 )
1483 configureAgenda( size ); 1482 configureAgenda( size );
1484 break; 1483 break;
1485 case Qt::Key_Minus: 1484 case Qt::Key_Minus:
1486 size = p->mHourSize - 2; 1485 size = p->mHourSize - 2;
1487 if ( size >= 4 ) 1486 if ( size >= 4 )
1488 configureAgenda( size ); 1487 configureAgenda( size );
1489 break; 1488 break;
1490 1489
1491 1490
1492 default: 1491 default:
1493 e->ignore(); 1492 e->ignore();
1494 } 1493 }
1495 if ( pro > 0 ) { 1494 if ( pro > 0 ) {
1496 mView->selectFilter( pro-1 ); 1495 mView->selectFilter( pro-1 );
1497 } 1496 }
1498 if ( showSelectedDates ) { 1497 if ( showSelectedDates ) {
1499 ;// setCaptionToDates(); 1498 ;// setCaptionToDates();
1500 } 1499 }
1501 1500
1502} 1501}
1503 1502
1504void MainWindow::configureToolBar( int item ) 1503void MainWindow::configureToolBar( int item )
1505{ 1504{
1506 1505
1507 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); 1506 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) );
1508 KOPrefs *p = KOPrefs::instance(); 1507 KOPrefs *p = KOPrefs::instance();
1509 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); 1508 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 );
1510 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); 1509 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 );
1511 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); 1510 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 );
1512 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); 1511 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 );
1513 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); 1512 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 );
1514 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); 1513 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 );
1515 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); 1514 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 );
1516 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); 1515 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 );
1517 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); 1516 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 );
1518 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); 1517 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 );
1519 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); 1518 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 );
1520 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); 1519 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 );
1521 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); 1520 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 );
1522 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); 1521 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 );
1523 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); 1522 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 );
1524 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); 1523 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 );
1525 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); 1524 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 );
1526 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); 1525 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 );
1527 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); 1526 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 );
1528 // initActions(); 1527 // initActions();
1529} 1528}
1530 1529
1531void MainWindow::setCaptionToDates() 1530void MainWindow::setCaptionToDates()
1532{ 1531{
1533 QString selDates; 1532 QString selDates;
1534 selDates = KGlobal::locale()->formatDate(mView->startDate(), true); 1533 selDates = KGlobal::locale()->formatDate(mView->startDate(), true);
1535 if (mView->startDate() < mView->endDate() ) 1534 if (mView->startDate() < mView->endDate() )
1536 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); 1535 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true);
1537 setCaption( i18n("Dates: ") + selDates ); 1536 setCaption( i18n("Dates: ") + selDates );
1538 1537
1539} 1538}
1540// parameter item == 0: reinit 1539// parameter item == 0: reinit
1541void MainWindow::configureAgenda( int item ) 1540void MainWindow::configureAgenda( int item )
1542{ 1541{
1543 1542
1544 KOPrefs *p = KOPrefs::instance(); 1543 KOPrefs *p = KOPrefs::instance();
1545 1544
1546 int i; 1545 int i;
1547 if ( item == 1 ) { 1546 if ( item == 1 ) {
1548 mView->toggleAllDaySize(); 1547 mView->toggleAllDaySize();
1549 return; 1548 return;
1550 } 1549 }
1551 // do not allow 4 for widgets higher than 480 1550 // do not allow 4 for widgets higher than 480
1552 // if ( QApplication::desktop()->height() > 480 ) { 1551 // if ( QApplication::desktop()->height() > 480 ) {
1553// if ( item == 4 ) 1552// if ( item == 4 )
1554// item = 6; 1553// item = 6;
1555// } 1554// }
1556 for ( i = 4; i <= 18; i= i+2 ) 1555 for ( i = 4; i <= 18; i= i+2 )
1557 configureAgendaMenu->setItemChecked( i, false ); 1556 configureAgendaMenu->setItemChecked( i, false );
1558 configureAgendaMenu->setItemChecked( item, true ); 1557 configureAgendaMenu->setItemChecked( item, true );
1559 if ( p->mHourSize == item ) 1558 if ( p->mHourSize == item )
1560 return; 1559 return;
1561 p->mHourSize=item; 1560 p->mHourSize=item;
1562 mView->viewManager()->agendaView()->updateConfig(); 1561 mView->viewManager()->agendaView()->updateConfig();
1563} 1562}
1564 1563
1565void MainWindow::saveCalendar() 1564void MainWindow::saveCalendar()
1566{ 1565{
1567 QString fn = KOPrefs::instance()->mLastSaveFile; 1566 QString fn = KOPrefs::instance()->mLastSaveFile;
1568 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); 1567 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this );
1569 1568
1570 if ( fn == "" ) 1569 if ( fn == "" )
1571 return; 1570 return;
1572 QFileInfo info; 1571 QFileInfo info;
1573 info.setFile( fn ); 1572 info.setFile( fn );
1574 QString mes; 1573 QString mes;
1575 bool createbup = true; 1574 bool createbup = true;
1576 if ( info. exists() ) { 1575 if ( info. exists() ) {
1577 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; 1576 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ;
1578 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1577 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1579 i18n("Overwrite!"), i18n("Cancel"), 0, 1578 i18n("Overwrite!"), i18n("Cancel"), 0,
1580 0, 1 ); 1579 0, 1 );
1581 if ( result != 0 ) { 1580 if ( result != 0 ) {
1582 createbup = false; 1581 createbup = false;
1583 } 1582 }
1584 } 1583 }
1585 if ( createbup ) { 1584 if ( createbup ) {
1586 mView->saveCalendar( fn ); 1585 mView->saveCalendar( fn );
1587 mes = i18n("KO/Pi:Saved %1").arg(fn); 1586 mes = i18n("KO/Pi:Saved %1").arg(fn);
1588 KOPrefs::instance()->mLastSaveFile = fn; 1587 KOPrefs::instance()->mLastSaveFile = fn;
1589 setCaption(mes); 1588 setCaption(mes);
1590 } 1589 }
1591} 1590}
1592void MainWindow::loadCalendar() 1591void MainWindow::loadCalendar()
1593{ 1592{
1594 1593
1595 QString fn = KOPrefs::instance()->mLastLoadFile; 1594 QString fn = KOPrefs::instance()->mLastLoadFile;
1596 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); 1595 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this );
1597 1596
1598 if ( fn == "" ) 1597 if ( fn == "" )
1599 return; 1598 return;
1600 QFileInfo info; 1599 QFileInfo info;
1601 info.setFile( fn ); 1600 info.setFile( fn );
1602 QString mess; 1601 QString mess;
1603 bool loadbup = true; 1602 bool loadbup = true;
1604 if ( info. exists() ) { 1603 if ( info. exists() ) {
1605 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1604 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1606 int result = QMessageBox::warning( this, "KO/Pi: Warning!", 1605 int result = QMessageBox::warning( this, "KO/Pi: Warning!",
1607 mess, 1606 mess,
1608 i18n("Load!"), i18n("Cancel"), 0, 1607 i18n("Load!"), i18n("Cancel"), 0,
1609 0, 1 ); 1608 0, 1 );
1610 if ( result != 0 ) { 1609 if ( result != 0 ) {
1611 loadbup = false; 1610 loadbup = false;
1612 } 1611 }
1613 } else { 1612 } else {
1614 QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1613 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1615 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, 1614 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0,
1616 0, 1 ); 1615 0, 1 );
1617 1616
1618 return; 1617 return;
1619 } 1618 }
1620 if ( loadbup ) { 1619 if ( loadbup ) {
1621 mView->openCalendar( fn ); 1620 mView->openCalendar( fn );
1622 KOPrefs::instance()->mLastLoadFile = fn; 1621 KOPrefs::instance()->mLastLoadFile = fn;
1623 mess = i18n("KO/Pi:Loaded %1").arg(fn) ; 1622 mess = i18n("KO/Pi:Loaded %1").arg(fn) ;
1624 setCaption(mess); 1623 setCaption(mess);
1625 } 1624 }
1626 1625
1627} 1626}
1628void MainWindow::quickImportIcal() 1627void MainWindow::quickImportIcal()
1629{ 1628{
1630 importFile( KOPrefs::instance()->mLastImportFile, false ); 1629 importFile( KOPrefs::instance()->mLastImportFile, false );
1631} 1630}
1632void MainWindow::importFile( QString fn, bool quick ) 1631void MainWindow::importFile( QString fn, bool quick )
1633{ 1632{
1634 QFileInfo info; 1633 QFileInfo info;
1635 info.setFile( fn ); 1634 info.setFile( fn );
1636 QString mess; 1635 QString mess;
1637 bool loadbup = true; 1636 bool loadbup = true;
1638 if ( !info. exists() ) { 1637 if ( !info. exists() ) {
1639 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); 1638 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30));
1640 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1639 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1641 mess ); 1640 mess );
1642 return; 1641 return;
1643 } 1642 }
1644 int result = 0; 1643 int result = 0;
1645 if ( !quick ) { 1644 if ( !quick ) {
1646 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 )); 1645 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 ));
1647 result = QMessageBox::warning( this, "KO/Pi: Warning!", 1646 result = QMessageBox::warning( this, "KO/Pi: Warning!",
1648 mess, 1647 mess,
1649 "Import", "Cancel", 0, 1648 "Import", "Cancel", 0,
1650 0, 1 ); 1649 0, 1 );
1651 } 1650 }
1652 if ( result == 0 ) { 1651 if ( result == 0 ) {
1653 if ( mView->openCalendar( fn, true )) { 1652 if ( mView->openCalendar( fn, true )) {
1654 KOPrefs::instance()->mLastImportFile = fn; 1653 KOPrefs::instance()->mLastImportFile = fn;
1655 setCaption(i18n("Imported file successfully")); 1654 setCaption(i18n("Imported file successfully"));
1656 } else { 1655 } else {
1657 setCaption(i18n("Error importing file")); 1656 setCaption(i18n("Error importing file"));
1658 } 1657 }
1659 } 1658 }
1660} 1659}
1661 1660
1662void MainWindow::importIcal() 1661void MainWindow::importIcal()
1663{ 1662{
1664 1663
1665 QString fn =KOPrefs::instance()->mLastImportFile; 1664 QString fn =KOPrefs::instance()->mLastImportFile;
1666 1665
1667 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); 1666 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this );
1668 if ( fn == "" ) 1667 if ( fn == "" )
1669 return; 1668 return;
1670 importFile( fn, true ); 1669 importFile( fn, true );
1671 1670
1672} 1671}
1673 1672
1674void MainWindow::exportVCalendar() 1673void MainWindow::exportVCalendar()
1675{ 1674{
1676 QString fn = KOPrefs::instance()->mLastVcalFile; 1675 QString fn = KOPrefs::instance()->mLastVcalFile;
1677 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); 1676 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this );
1678 if ( fn == "" ) 1677 if ( fn == "" )
1679 return; 1678 return;
1680 QFileInfo info; 1679 QFileInfo info;
1681 info.setFile( fn ); 1680 info.setFile( fn );
1682 QString mes; 1681 QString mes;
1683 bool createbup = true; 1682 bool createbup = true;
1684 if ( info. exists() ) { 1683 if ( info. exists() ) {
1685 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 1684 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
1686 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1685 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1687 i18n("Overwrite!"), i18n("Cancel"), 0, 1686 i18n("Overwrite!"), i18n("Cancel"), 0,
1688 0, 1 ); 1687 0, 1 );
1689 if ( result != 0 ) { 1688 if ( result != 0 ) {
1690 createbup = false; 1689 createbup = false;
1691 } 1690 }
1692 } 1691 }
1693 if ( createbup ) { 1692 if ( createbup ) {
1694 if ( mView->exportVCalendar( fn ) ) { 1693 if ( mView->exportVCalendar( fn ) ) {
1695 KOPrefs::instance()->mLastVcalFile = fn; 1694 KOPrefs::instance()->mLastVcalFile = fn;
1696 if ( fn.length() > 20 ) 1695 if ( fn.length() > 20 )
1697 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; 1696 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ;
1698 else 1697 else
1699 mes = i18n("KO/Pi:Exported to %1").arg(fn ); 1698 mes = i18n("KO/Pi:Exported to %1").arg(fn );
1700 setCaption(mes); 1699 setCaption(mes);
1701 } 1700 }
1702 } 1701 }
1703 1702
1704} 1703}
1705#include <qpushbutton.h> 1704#include <qpushbutton.h>
1706QString MainWindow::getPassword( ) 1705QString MainWindow::getPassword( )
1707{ 1706{
1708 QString retfile = ""; 1707 QString retfile = "";
1709 QDialog dia ( this, "input-dialog", true ); 1708 QDialog dia ( this, "input-dialog", true );
1710 QLineEdit lab ( &dia ); 1709 QLineEdit lab ( &dia );
1711 lab.setEchoMode( QLineEdit::Password ); 1710 lab.setEchoMode( QLineEdit::Password );
1712 QVBoxLayout lay( &dia ); 1711 QVBoxLayout lay( &dia );
1713 lay.setMargin(7); 1712 lay.setMargin(7);
1714 lay.setSpacing(7); 1713 lay.setSpacing(7);
1715 lay.addWidget( &lab); 1714 lay.addWidget( &lab);
1716 dia.setFixedSize( 230,50 ); 1715 dia.setFixedSize( 230,50 );
1717 dia.setCaption( i18n("Enter password") ); 1716 dia.setCaption( i18n("Enter password") );
1718 QPushButton pb ( "OK", &dia); 1717 QPushButton pb ( "OK", &dia);
1719 lay.addWidget( &pb ); 1718 lay.addWidget( &pb );
1720 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 1719 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
1721 dia.show(); 1720 dia.show();
1722 int res = dia.exec(); 1721 int res = dia.exec();
1723 if ( res ) 1722 if ( res )
1724 retfile = lab.text(); 1723 retfile = lab.text();
1725 dia.hide(); 1724 dia.hide();
1726 qApp->processEvents(); 1725 qApp->processEvents();
1727 return retfile; 1726 return retfile;
1728 1727
1729} 1728}
1730 1729
1731void MainWindow::syncLocalFile() 1730void MainWindow::syncLocalFile()
1732{ 1731{
1733 1732
1734 QString fn =KOPrefs::instance()->mLastSyncedLocalFile; 1733 QString fn =KOPrefs::instance()->mLastSyncedLocalFile;
1735 1734
1736 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); 1735 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this );
1737 if ( fn == "" ) 1736 if ( fn == "" )
1738 return; 1737 return;
1739 //mView->setSyncDevice("local-file" ); 1738 //mView->setSyncDevice("local-file" );
1740 if ( syncWithFile( fn, false ) ) { 1739 if ( syncWithFile( fn, false ) ) {
1741 // Event* e = mView->getLastSyncEvent(); 1740 // Event* e = mView->getLastSyncEvent();
1742// e->setReadOnly( false ); 1741// e->setReadOnly( false );
1743// e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); 1742// e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile);
1744// e->setReadOnly( true ); 1743// e->setReadOnly( true );
1745 } 1744 }
1746 1745
1747} 1746}
1748 1747
1749bool MainWindow::syncWithFile( QString fn , bool quick ) 1748bool MainWindow::syncWithFile( QString fn , bool quick )
1750{ 1749{
1751 bool ret = false; 1750 bool ret = false;
1752 QFileInfo info; 1751 QFileInfo info;
1753 info.setFile( fn ); 1752 info.setFile( fn );
1754 QString mess; 1753 QString mess;
1755 bool loadbup = true; 1754 bool loadbup = true;
1756 if ( !info. exists() ) { 1755 if ( !info. exists() ) {
1757 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 1756 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
1758 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1757 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1759 mess ); 1758 mess );
1760 return ret; 1759 return ret;
1761 } 1760 }
1762 int result = 0; 1761 int result = 0;
1763 if ( !quick ) { 1762 if ( !quick ) {
1764 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1763 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1765 result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1764 result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1766 mess, 1765 mess,
1767 i18n("Sync"), i18n("Cancel"), 0, 1766 i18n("Sync"), i18n("Cancel"), 0,
1768 0, 1 ); 1767 0, 1 );
1769 if ( result ) 1768 if ( result )
1770 return false; 1769 return false;
1771 } 1770 }
1772 if ( KOPrefs::instance()->mAskForPreferences ) 1771 if ( KOPrefs::instance()->mAskForPreferences )
1773 mView->edit_sync_options(); 1772 mView->edit_sync_options();
1774 if ( result == 0 ) { 1773 if ( result == 0 ) {
1775 //qDebug("Now sycing ... "); 1774 //qDebug("Now sycing ... ");
1776 if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) ) 1775 if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) )
1777 setCaption( i18n("Synchronization successful") ); 1776 setCaption( i18n("Synchronization successful") );
1778 else 1777 else
1779 setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); 1778 setCaption( i18n("Sync cancelled or failed. Nothing synced.") );
1780 if ( ! quick ) 1779 if ( ! quick )
1781 KOPrefs::instance()->mLastSyncedLocalFile = fn; 1780 KOPrefs::instance()->mLastSyncedLocalFile = fn;
1782 slotModifiedChanged( true ); 1781 slotModifiedChanged( true );
1783 } 1782 }
1784 return ret; 1783 return ret;
1785} 1784}
1786void MainWindow::quickSyncLocalFile() 1785void MainWindow::quickSyncLocalFile()
1787{ 1786{
1788 //mView->setSyncDevice("local-file" ); 1787 //mView->setSyncDevice("local-file" );
1789 //qDebug("quickSyncLocalFile() "); 1788 //qDebug("quickSyncLocalFile() ");
1790 if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) { 1789 if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) {
1791 // Event* e = mView->getLastSyncEvent(); 1790 // Event* e = mView->getLastSyncEvent();
1792// e->setReadOnly( false ); 1791// e->setReadOnly( false );
1793// e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); 1792// e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile);
1794// e->setReadOnly( true ); 1793// e->setReadOnly( true );
1795 1794
1796 } 1795 }
1797} 1796}
1798 1797
1799void MainWindow::confSync() 1798void MainWindow::confSync()
1800{ 1799{
1801 mView->confSync(); 1800 mView->confSync();
1802 fillSyncMenu(); 1801 fillSyncMenu();
1803 mView->writeSettings(); 1802 //mView->writeSettings();
1804 1803
1805 1804
1806} 1805}
1807void MainWindow::syncRemote( KSyncProfile* prof, bool ask) 1806void MainWindow::syncRemote( KSyncProfile* prof, bool ask)
1808{ 1807{
1809 QString question; 1808 QString question;
1810 if ( ask ) { 1809 if ( ask ) {
1811 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; 1810 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
1812 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 1811 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
1813 question, 1812 question,
1814 i18n("Yes"), i18n("No"), 1813 i18n("Yes"), i18n("No"),
1815 0, 0 ) != 0 ) 1814 0, 0 ) != 0 )
1816 return; 1815 return;
1817 } 1816 }
1818 QString command = prof->getPreSyncCommand(); 1817 QString command = prof->getPreSyncCommand();
1819 int fi; 1818 int fi;
1820 if ( (fi = command.find("$PWD$")) > 0 ) { 1819 if ( (fi = command.find("$PWD$")) > 0 ) {
1821 QString pwd = getPassword(); 1820 QString pwd = getPassword();
1822 command = command.left( fi )+ pwd + command.mid( fi+5 ); 1821 command = command.left( fi )+ pwd + command.mid( fi+5 );
1823 1822
1824 } 1823 }
1825 int maxlen = 30; 1824 int maxlen = 30;
1826 if ( QApplication::desktop()->width() > 320 ) 1825 if ( QApplication::desktop()->width() > 320 )
1827 maxlen += 25; 1826 maxlen += 25;
1828 setCaption ( i18n( "Copy remote file to local machine..." ) ); 1827 setCaption ( i18n( "Copy remote file to local machine..." ) );
1829 int fileSize = 0; 1828 int fileSize = 0;
1830 int result = system ( command ); 1829 int result = system ( command );
1831 // 0 : okay 1830 // 0 : okay
1832 // 256: no such file or dir 1831 // 256: no such file or dir
1833 // 1832 //
1834 qDebug("KO: Remote copy result(0 = okay): %d ",result ); 1833 qDebug("KO: Remote copy result(0 = okay): %d ",result );
1835 if ( result != 0 ) { 1834 if ( result != 0 ) {
1836 int len = maxlen; 1835 int len = maxlen;
1837 while ( len < command.length() ) { 1836 while ( len < command.length() ) {
1838 command.insert( len , "\n" ); 1837 command.insert( len , "\n" );
1839 len += maxlen +2; 1838 len += maxlen +2;
1840 } 1839 }
1841 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) ; 1840 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) ;
1842 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), 1841 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
1843 question, 1842 question,
1844 i18n("Okay!")) ; 1843 i18n("Okay!")) ;
1845 setCaption ("KO/Pi"); 1844 setCaption ("KO/Pi");
1846 return; 1845 return;
1847 } 1846 }
1848 setCaption ( i18n( "Copying succeed." ) ); 1847 setCaption ( i18n( "Copying succeed." ) );
1849 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); 1848 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
1850 if ( syncWithFile( prof->getLocalTempFile(), true ) ) { 1849 if ( syncWithFile( prof->getLocalTempFile(), true ) ) {
1851// Event* e = mView->getLastSyncEvent(); 1850// Event* e = mView->getLastSyncEvent();
1852// e->setReadOnly( false ); 1851// e->setReadOnly( false );
1853// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 1852// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
1854// e->setReadOnly( true ); 1853// e->setReadOnly( true );
1855 if ( KOPrefs::instance()->mWriteBackFile ) { 1854 if ( KOPrefs::instance()->mWriteBackFile ) {
1856 command = prof->getPostSyncCommand(); 1855 command = prof->getPostSyncCommand();
1857 setCaption ( i18n( "Writing back file ..." ) ); 1856 setCaption ( i18n( "Writing back file ..." ) );
1858 result = system ( command ); 1857 result = system ( command );
1859 qDebug("KO: Writing back file result: %d ", result); 1858 qDebug("KO: Writing back file result: %d ", result);
1860 if ( result != 0 ) { 1859 if ( result != 0 ) {
1861 setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); 1860 setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
1862 return; 1861 return;
1863 } else { 1862 } else {
1864 setCaption ( i18n( "Syncronization sucessfully completed" ) ); 1863 setCaption ( i18n( "Syncronization sucessfully completed" ) );
1865 } 1864 }
1866 } 1865 }
1867 } 1866 }
1868 return; 1867 return;
1869} 1868}
1870void MainWindow::syncSSH() 1869void MainWindow::syncSSH()
1871{ 1870{
1872 // not used anymore 1871 // not used anymore
1873 QTime timer; 1872 QTime timer;
1874 timer.start(); 1873 timer.start();
1875 //qDebug("MainWindow::syncssh() "); 1874 //qDebug("MainWindow::syncssh() ");
1876 KOPrefs *p = KOPrefs::instance(); 1875 KOPrefs *p = KOPrefs::instance();
1877 QString localFile = p->mLocalTempFile; 1876 QString localFile = p->mLocalTempFile;
1878 QString remoteIP = p->mRemoteIP; 1877 QString remoteIP = p->mRemoteIP;
1879 QString remoteUser = p->mRemoteUser; 1878 QString remoteUser = p->mRemoteUser;
1880 QString remoteFile = p->mRemoteFile; 1879 QString remoteFile = p->mRemoteFile;
1881 if ( p->mUsePassWd && p->mRemotePassWd.length() > 0 ) 1880 if ( p->mUsePassWd && p->mRemotePassWd.length() > 0 )
1882 remoteUser += ":" + p->mRemotePassWd; 1881 remoteUser += ":" + p->mRemotePassWd;
1883 1882
1884 QString question = i18n("Do you really want\nto remote sync?\n \n") + 1883 QString question = i18n("Do you really want\nto remote sync?\n \n") +
1885 i18n("IP: " ) +remoteIP +"\n" + 1884 i18n("IP: " ) +remoteIP +"\n" +
1886 i18n("User: " ) + remoteUser +"\n" ; 1885 i18n("User: " ) + remoteUser +"\n" ;
1887 int maxlen = 30; 1886 int maxlen = 30;
1888 if ( QApplication::desktop()->width() > 320 ) 1887 if ( QApplication::desktop()->width() > 320 )
1889 maxlen += 25; 1888 maxlen += 25;
1890 if ( remoteFile.length() > maxlen ) 1889 if ( remoteFile.length() > maxlen )
1891 question += i18n("Remote file:\n..." ) + remoteFile.right(maxlen) +"\n"; 1890 question += i18n("Remote file:\n..." ) + remoteFile.right(maxlen) +"\n";
1892 else 1891 else
1893 question += i18n("Remote file:\n " ) + remoteFile +"\n"; 1892 question += i18n("Remote file:\n " ) + remoteFile +"\n";
1894 if ( localFile.length() > maxlen ) 1893 if ( localFile.length() > maxlen )
1895 question += i18n("Local temp file:\n..." ) + localFile.right(maxlen) +"\n"; 1894 question += i18n("Local temp file:\n..." ) + localFile.right(maxlen) +"\n";
1896 else 1895 else
1897 question += i18n("Local temp file:\n " ) + localFile +"\n"; 1896 question += i18n("Local temp file:\n " ) + localFile +"\n";
1898 1897
1899 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 1898 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
1900 question, 1899 question,
1901 i18n("Yes"), i18n("No"), 1900 i18n("Yes"), i18n("No"),
1902 0, 0 ) != 0 ) 1901 0, 0 ) != 0 )
1903 return; 1902 return;
1904 // if ( !p->mUsePassWd ) { 1903 // if ( !p->mUsePassWd ) {
1905 // QString pass = getPassword(); 1904 // QString pass = getPassword();
1906 // if ( pass.length() > 0 ) 1905 // if ( pass.length() > 0 )
1907 // remoteUser += ":" + pass; 1906 // remoteUser += ":" + pass;
1908 // } 1907 // }
1909 QString command = "scp " + remoteUser + "@" + remoteIP +":" + remoteFile +" " +localFile; 1908 QString command = "scp " + remoteUser + "@" + remoteIP +":" + remoteFile +" " +localFile;
1910 setCaption ( i18n( "Copy remote file to local machine..." ) ); 1909 setCaption ( i18n( "Copy remote file to local machine..." ) );
1911 int fileSize = 0; 1910 int fileSize = 0;
1912 int result = system ( command ); 1911 int result = system ( command );
1913 // 0 : okay 1912 // 0 : okay
1914 // 256: no such file or dir 1913 // 256: no such file or dir
1915 // 1914 //
1916 qDebug("KO: Remote copy result(0 = okay): %d ",result ); 1915 qDebug("KO: Remote copy result(0 = okay): %d ",result );
1917 if ( result != 0 ) { 1916 if ( result != 0 ) {
1918 int len = maxlen; 1917 int len = maxlen;
1919 while ( len < command.length() ) { 1918 while ( len < command.length() ) {
1920 command.insert( len , "\n" ); 1919 command.insert( len , "\n" );
1921 len += maxlen +2; 1920 len += maxlen +2;
1922 } 1921 }
1923 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) ; 1922 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) ;
1924 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), 1923 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
1925 question, 1924 question,
1926 i18n("Okay!")) ; 1925 i18n("Okay!")) ;
1927 setCaption ("KO/Pi"); 1926 setCaption ("KO/Pi");
1928 return; 1927 return;
1929 } 1928 }
1930 1929
1931 1930
1932 setCaption ( i18n( "Copying succeed." ) ); 1931 setCaption ( i18n( "Copying succeed." ) );
1933 //mView->setSyncDevice("ssh-scp" ); 1932 //mView->setSyncDevice("ssh-scp" );
1934 if ( syncWithFile(localFile , true ) ) { 1933 if ( syncWithFile(localFile , true ) ) {
1935// Event* e = mView->getLastSyncEvent(); 1934// Event* e = mView->getLastSyncEvent();
1936// e->setReadOnly( false ); 1935// e->setReadOnly( false );
1937// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 1936// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
1938// e->setReadOnly( true ); 1937// e->setReadOnly( true );
1939 if ( KOPrefs::instance()->mWriteBackFile ) { 1938 if ( KOPrefs::instance()->mWriteBackFile ) {
1940 command = "scp " + localFile +" " +remoteUser + "@" + remoteIP +":" + remoteFile ; 1939 command = "scp " + localFile +" " +remoteUser + "@" + remoteIP +":" + remoteFile ;
1941 setCaption ( i18n( "Writing back file ..." ) ); 1940 setCaption ( i18n( "Writing back file ..." ) );
1942 result = system ( command ); 1941 result = system ( command );
1943 if ( result != 0 ) { 1942 if ( result != 0 ) {
1944 int len = maxlen; 1943 int len = maxlen;
1945 while ( len < command.length() ) { 1944 while ( len < command.length() ) {
1946 command.insert( len , "\n" ); 1945 command.insert( len , "\n" );
1947 len += maxlen +2; 1946 len += maxlen +2;
1948 } 1947 }
1949 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) ; 1948 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) ;
1950 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), 1949 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
1951 question, 1950 question,
1952 i18n("Okay!")) ; 1951 i18n("Okay!")) ;
1953 setCaption ("KO/Pi"); 1952 setCaption ("KO/Pi");
1954 return; 1953 return;
1955 } else { 1954 } else {
1956 setCaption ( i18n( "Syncronization sucessfully completed" ) ); 1955 setCaption ( i18n( "Syncronization sucessfully completed" ) );
1957 } 1956 }
1958 } 1957 }
1959 } 1958 }
1960 return; 1959 return;
1961#if 0 1960#if 0
1962 system ("scp zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics /home/polo/Applications/korganizer/z_sync.ics"); 1961 system ("scp zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics /home/polo/Applications/korganizer/z_sync.ics");
1963 while ( timer.elapsed() < 5000 ) 1962 while ( timer.elapsed() < 5000 )
1964 qApp->processEvents(); 1963 qApp->processEvents();
1965 1964
1966 qDebug("MainWindow::merging) "); 1965 qDebug("MainWindow::merging) ");
1967 mView->syncCalendar( "/home/polo/Applications/korganizer/z_sync.ics", 0 ); 1966 mView->syncCalendar( "/home/polo/Applications/korganizer/z_sync.ics", 0 );
1968 while ( mBlockSaveFlag ) 1967 while ( mBlockSaveFlag )
1969 qApp->processEvents(); 1968 qApp->processEvents();
1970 save(); 1969 save();
1971 system ("scp /home/polo/Applications/korganizer/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics"); 1970 system ("scp /home/polo/Applications/korganizer/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics");
1972#endif 1971#endif
1973 1972
1974} 1973}
1975 1974
1976 1975
1977void MainWindow::syncSharp() 1976void MainWindow::syncSharp()
1978{ 1977{
1979 if ( mCalendarModifiedFlag ) 1978 if ( mCalendarModifiedFlag )
1980 save(); 1979 save();
1981 mView->syncSharp(); 1980 mView->syncSharp();
1982 slotModifiedChanged( true ); 1981 slotModifiedChanged( true );
1983 1982
1984} 1983}
1985 1984
1986void MainWindow::printSel( ) 1985void MainWindow::printSel( )
1987{ 1986{
1988 mView->viewManager()->agendaView()->agenda()->printSelection(); 1987 mView->viewManager()->agendaView()->agenda()->printSelection();
1989} 1988}
1990 1989
1991void MainWindow::printCal() 1990void MainWindow::printCal()
1992{ 1991{
1993 mView->print();//mCp->showDialog(); 1992 mView->print();//mCp->showDialog();
1994} 1993}