summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp1
-rw-r--r--korganizer/mainwindow.cpp4
-rw-r--r--libkdepim/ksyncprefsdialog.cpp5
3 files changed, 7 insertions, 3 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 387b751..cfc6b10 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,3481 +1,3480 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Requires the Qt and KDE widget libraries, available at no cost at 4 Requires the Qt and KDE widget libraries, available at no cost at
5 http://www.troll.no and http://www.kde.org respectively 5 http://www.troll.no and http://www.kde.org respectively
6 6
7 Copyright (c) 1997, 1998, 1999 7 Copyright (c) 1997, 1998, 1999
8 Preston Brown (preston.brown@yale.edu) 8 Preston Brown (preston.brown@yale.edu)
9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) 9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl)
10 Ian Dawes (iadawes@globalserve.net) 10 Ian Dawes (iadawes@globalserve.net)
11 Laszlo Boloni (boloni@cs.purdue.edu) 11 Laszlo Boloni (boloni@cs.purdue.edu)
12 12
13 Copyright (c) 2000, 2001, 2002 13 Copyright (c) 2000, 2001, 2002
14 Cornelius Schumacher <schumacher@kde.org> 14 Cornelius Schumacher <schumacher@kde.org>
15 15
16 This program is free software; you can redistribute it and/or modify 16 This program is free software; you can redistribute it and/or modify
17 it under the terms of the GNU General Public License as published by 17 it under the terms of the GNU General Public License as published by
18 the Free Software Foundation; either version 2 of the License, or 18 the Free Software Foundation; either version 2 of the License, or
19 (at your option) any later version. 19 (at your option) any later version.
20 20
21 This program is distributed in the hope that it will be useful, 21 This program is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of 22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
24 GNU General Public License for more details. 24 GNU General Public License for more details.
25 25
26 You should have received a copy of the GNU General Public License 26 You should have received a copy of the GNU General Public License
27 along with this program; if not, write to the Free Software 27 along with this program; if not, write to the Free Software
28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29*/ 29*/
30 30
31#include <stdlib.h> 31#include <stdlib.h>
32 32
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qradiobutton.h> 34#include <qradiobutton.h>
35#include <qbuttongroup.h> 35#include <qbuttongroup.h>
36#include <qlayout.h> 36#include <qlayout.h>
37#include <qclipboard.h> 37#include <qclipboard.h>
38#include <qcursor.h> 38#include <qcursor.h>
39#include <qmessagebox.h> 39#include <qmessagebox.h>
40#include <qprogressbar.h> 40#include <qprogressbar.h>
41#include <qmultilineedit.h> 41#include <qmultilineedit.h>
42#include <qtimer.h> 42#include <qtimer.h>
43#include <qwidgetstack.h> 43#include <qwidgetstack.h>
44#include <qptrlist.h> 44#include <qptrlist.h>
45#include <qregexp.h> 45#include <qregexp.h>
46#include <qgroupbox.h> 46#include <qgroupbox.h>
47#include <qfile.h> 47#include <qfile.h>
48#include <qdir.h> 48#include <qdir.h>
49#ifndef KORG_NOSPLITTER 49#ifndef KORG_NOSPLITTER
50#include <qsplitter.h> 50#include <qsplitter.h>
51#endif 51#endif
52 52
53#include <kglobal.h> 53#include <kglobal.h>
54#include <kdebug.h> 54#include <kdebug.h>
55#include <kstandarddirs.h> 55#include <kstandarddirs.h>
56#include <kfiledialog.h> 56#include <kfiledialog.h>
57#include <kmessagebox.h> 57#include <kmessagebox.h>
58#include <knotifyclient.h> 58#include <knotifyclient.h>
59#include <kconfig.h> 59#include <kconfig.h>
60 60
61#include <libkdepim/ksyncprefsdialog.h> 61#include <libkdepim/ksyncprefsdialog.h>
62#include <krun.h> 62#include <krun.h>
63#include <kdirwatch.h> 63#include <kdirwatch.h>
64#include <libkdepim/kdatepicker.h> 64#include <libkdepim/kdatepicker.h>
65#include <libkdepim/ksyncprofile.h> 65#include <libkdepim/ksyncprofile.h>
66 66
67#include <libkcal/vcaldrag.h> 67#include <libkcal/vcaldrag.h>
68#include <libkcal/icaldrag.h> 68#include <libkcal/icaldrag.h>
69#include <libkcal/icalformat.h> 69#include <libkcal/icalformat.h>
70#include <libkcal/vcalformat.h> 70#include <libkcal/vcalformat.h>
71#include <libkcal/scheduler.h> 71#include <libkcal/scheduler.h>
72#include <libkcal/calendarlocal.h> 72#include <libkcal/calendarlocal.h>
73#include <libkcal/journal.h> 73#include <libkcal/journal.h>
74#include <libkcal/calfilter.h> 74#include <libkcal/calfilter.h>
75#include <libkcal/attendee.h> 75#include <libkcal/attendee.h>
76#include <libkcal/dndfactory.h> 76#include <libkcal/dndfactory.h>
77#include <libkcal/freebusy.h> 77#include <libkcal/freebusy.h>
78#include <libkcal/filestorage.h> 78#include <libkcal/filestorage.h>
79#include <libkcal/calendarresources.h> 79#include <libkcal/calendarresources.h>
80#include <libkcal/qtopiaformat.h> 80#include <libkcal/qtopiaformat.h>
81#include "../kalarmd/alarmdialog.h" 81#include "../kalarmd/alarmdialog.h"
82 82
83#ifndef DESKTOP_VERSION 83#ifndef DESKTOP_VERSION
84#include <libkcal/sharpformat.h> 84#include <libkcal/sharpformat.h>
85#endif 85#endif
86#ifndef KORG_NOMAIL 86#ifndef KORG_NOMAIL
87#include "komailclient.h" 87#include "komailclient.h"
88#endif 88#endif
89#ifndef KORG_NOPRINTER 89#ifndef KORG_NOPRINTER
90#include "calprinter.h" 90#include "calprinter.h"
91#endif 91#endif
92#ifndef KORG_NOPLUGINS 92#ifndef KORG_NOPLUGINS
93#include "kocore.h" 93#include "kocore.h"
94#endif 94#endif
95#include "koeventeditor.h" 95#include "koeventeditor.h"
96#include "kotodoeditor.h" 96#include "kotodoeditor.h"
97#include "koprefs.h" 97#include "koprefs.h"
98#include "koeventviewerdialog.h" 98#include "koeventviewerdialog.h"
99#include "publishdialog.h" 99#include "publishdialog.h"
100#include "kofilterview.h" 100#include "kofilterview.h"
101#include "koglobals.h" 101#include "koglobals.h"
102#include "koviewmanager.h" 102#include "koviewmanager.h"
103#include "koagendaview.h" 103#include "koagendaview.h"
104#include "kodialogmanager.h" 104#include "kodialogmanager.h"
105#include "outgoingdialog.h" 105#include "outgoingdialog.h"
106#include "incomingdialog.h" 106#include "incomingdialog.h"
107#include "statusdialog.h" 107#include "statusdialog.h"
108#include "kdatenavigator.h" 108#include "kdatenavigator.h"
109#include "kotodoview.h" 109#include "kotodoview.h"
110#include "datenavigator.h" 110#include "datenavigator.h"
111#include "resourceview.h" 111#include "resourceview.h"
112#include "navigatorbar.h" 112#include "navigatorbar.h"
113#include "searchdialog.h" 113#include "searchdialog.h"
114#include "mainwindow.h" 114#include "mainwindow.h"
115 115
116#include "calendarview.h" 116#include "calendarview.h"
117#ifndef DESKTOP_VERSION 117#ifndef DESKTOP_VERSION
118#include <qtopia/alarmserver.h> 118#include <qtopia/alarmserver.h>
119#endif 119#endif
120#ifndef _WIN32_ 120#ifndef _WIN32_
121#include <stdlib.h> 121#include <stdlib.h>
122#include <stdio.h> 122#include <stdio.h>
123#include <unistd.h> 123#include <unistd.h>
124#else 124#else
125#include <qprocess.h> 125#include <qprocess.h>
126#endif 126#endif
127using namespace KOrg; 127using namespace KOrg;
128using namespace KCal; 128using namespace KCal;
129extern int globalFlagBlockAgenda; 129extern int globalFlagBlockAgenda;
130extern int globalFlagBlockStartup; 130extern int globalFlagBlockStartup;
131 131
132 132
133 133
134class KOBeamPrefs : public QDialog 134class KOBeamPrefs : public QDialog
135{ 135{
136 public: 136 public:
137 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : 137 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) :
138 QDialog( parent, name, true ) 138 QDialog( parent, name, true )
139 { 139 {
140 setCaption( i18n("Beam Options") ); 140 setCaption( i18n("Beam Options") );
141 QVBoxLayout* lay = new QVBoxLayout( this ); 141 QVBoxLayout* lay = new QVBoxLayout( this );
142 lay->setSpacing( 3 ); 142 lay->setSpacing( 3 );
143 lay->setMargin( 3 ); 143 lay->setMargin( 3 );
144 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); 144 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this );
145 lay->addWidget( format ); 145 lay->addWidget( format );
146 format->setExclusive ( true ) ; 146 format->setExclusive ( true ) ;
147 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); 147 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this );
148 lay->addWidget( time ); time->setExclusive ( true ) ; 148 lay->addWidget( time ); time->setExclusive ( true ) ;
149 vcal = new QRadioButton(" vCalendar ", format ); 149 vcal = new QRadioButton(" vCalendar ", format );
150 ical = new QRadioButton(" iCalendar ", format ); 150 ical = new QRadioButton(" iCalendar ", format );
151 vcal->setChecked( true ); 151 vcal->setChecked( true );
152 tz = new QRadioButton(i18n(" With timezone "), time ); 152 tz = new QRadioButton(i18n(" With timezone "), time );
153 local = new QRadioButton(i18n(" Local time "), time ); 153 local = new QRadioButton(i18n(" Local time "), time );
154 tz->setChecked( true ); 154 tz->setChecked( true );
155 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); 155 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this );
156 lay->addWidget( ok ); 156 lay->addWidget( ok );
157 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 157 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
158 lay->addWidget( cancel ); 158 lay->addWidget( cancel );
159 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 159 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
160 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 160 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
161 resize( 200, 200 ); 161 resize( 200, 200 );
162 } 162 }
163 163
164 bool beamVcal() { return vcal->isChecked(); } 164 bool beamVcal() { return vcal->isChecked(); }
165 bool beamLocal() { return local->isChecked(); } 165 bool beamLocal() { return local->isChecked(); }
166private: 166private:
167 QRadioButton* vcal, *ical, *local, *tz; 167 QRadioButton* vcal, *ical, *local, *tz;
168}; 168};
169class KOCatPrefs : public QDialog 169class KOCatPrefs : public QDialog
170{ 170{
171 public: 171 public:
172 KOCatPrefs( QWidget *parent=0, const char *name=0 ) : 172 KOCatPrefs( QWidget *parent=0, const char *name=0 ) :
173 QDialog( parent, name, true ) 173 QDialog( parent, name, true )
174 { 174 {
175 setCaption( i18n("Manage new Categories") ); 175 setCaption( i18n("Manage new Categories") );
176 QVBoxLayout* lay = new QVBoxLayout( this ); 176 QVBoxLayout* lay = new QVBoxLayout( this );
177 lay->setSpacing( 3 ); 177 lay->setSpacing( 3 );
178 lay->setMargin( 3 ); 178 lay->setMargin( 3 );
179 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); 179 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this );
180 lay->addWidget( lab ); 180 lay->addWidget( lab );
181 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 181 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
182 lay->addWidget( format ); 182 lay->addWidget( format );
183 format->setExclusive ( true ) ; 183 format->setExclusive ( true ) ;
184 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 184 addCatBut = new QRadioButton(i18n("Add to category list"), format );
185 new QRadioButton(i18n("Remove from Events/Todos"), format ); 185 new QRadioButton(i18n("Remove from Events/Todos"), format );
186 addCatBut->setChecked( true ); 186 addCatBut->setChecked( true );
187 QPushButton * ok = new QPushButton( i18n("OK"), this ); 187 QPushButton * ok = new QPushButton( i18n("OK"), this );
188 lay->addWidget( ok ); 188 lay->addWidget( ok );
189 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 189 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
190 lay->addWidget( cancel ); 190 lay->addWidget( cancel );
191 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 191 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
192 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 192 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
193 resize( 200, 200 ); 193 resize( 200, 200 );
194 } 194 }
195 195
196 bool addCat() { return addCatBut->isChecked(); } 196 bool addCat() { return addCatBut->isChecked(); }
197private: 197private:
198 QRadioButton* addCatBut; 198 QRadioButton* addCatBut;
199}; 199};
200 200
201 201
202 202
203CalendarView::CalendarView( CalendarResources *calendar, 203CalendarView::CalendarView( CalendarResources *calendar,
204 QWidget *parent, const char *name ) 204 QWidget *parent, const char *name )
205 : CalendarViewBase( parent, name ), 205 : CalendarViewBase( parent, name ),
206 mCalendar( calendar ), 206 mCalendar( calendar ),
207 mResourceManager( calendar->resourceManager() ) 207 mResourceManager( calendar->resourceManager() )
208{ 208{
209 209
210 mEventEditor = 0; 210 mEventEditor = 0;
211 mTodoEditor = 0; 211 mTodoEditor = 0;
212 212
213 init(); 213 init();
214} 214}
215 215
216CalendarView::CalendarView( Calendar *calendar, 216CalendarView::CalendarView( Calendar *calendar,
217 QWidget *parent, const char *name ) 217 QWidget *parent, const char *name )
218 : CalendarViewBase( parent, name ), 218 : CalendarViewBase( parent, name ),
219 mCalendar( calendar ), 219 mCalendar( calendar ),
220 mResourceManager( 0 ) 220 mResourceManager( 0 )
221{ 221{
222 222
223 mEventEditor = 0; 223 mEventEditor = 0;
224 mTodoEditor = 0; 224 mTodoEditor = 0;
225 init();} 225 init();}
226 226
227void CalendarView::init() 227void CalendarView::init()
228{ 228{
229 beamDialog = new KOBeamPrefs(); 229 beamDialog = new KOBeamPrefs();
230 mDatePickerMode = 0; 230 mDatePickerMode = 0;
231 mCurrentSyncDevice = ""; 231 mCurrentSyncDevice = "";
232 writeLocale(); 232 writeLocale();
233 mViewManager = new KOViewManager( this ); 233 mViewManager = new KOViewManager( this );
234 mDialogManager = new KODialogManager( this ); 234 mDialogManager = new KODialogManager( this );
235 mEventViewerDialog = 0; 235 mEventViewerDialog = 0;
236 mModified = false; 236 mModified = false;
237 mReadOnly = false; 237 mReadOnly = false;
238 mSelectedIncidence = 0; 238 mSelectedIncidence = 0;
239 mCalPrinter = 0; 239 mCalPrinter = 0;
240 mFilters.setAutoDelete(true); 240 mFilters.setAutoDelete(true);
241 241
242 mCalendar->registerObserver( this ); 242 mCalendar->registerObserver( this );
243 // TODO: Make sure that view is updated, when calendar is changed. 243 // TODO: Make sure that view is updated, when calendar is changed.
244 244
245 mStorage = new FileStorage( mCalendar ); 245 mStorage = new FileStorage( mCalendar );
246 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 246 mNavigator = new DateNavigator( this, "datevav", mViewManager );
247 247
248 QBoxLayout *topLayout = (QBoxLayout*)layout(); 248 QBoxLayout *topLayout = (QBoxLayout*)layout();
249#ifndef KORG_NOSPLITTER 249#ifndef KORG_NOSPLITTER
250 // create the main layout frames. 250 // create the main layout frames.
251 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 251 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
252 topLayout->addWidget(mPanner); 252 topLayout->addWidget(mPanner);
253 253
254 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 254 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
255 "CalendarView::LeftFrame"); 255 "CalendarView::LeftFrame");
256 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 256 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
257 257
258 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, 258 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE,
259 "CalendarView::DateNavigator", QDate::currentDate() ); 259 "CalendarView::DateNavigator", QDate::currentDate() );
260 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 260 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
261 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 261 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
262 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 262 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
263 263
264#ifdef KORG_NORESOURCEVIEW 264#ifdef KORG_NORESOURCEVIEW
265 mResourceView = 0; 265 mResourceView = 0;
266#else 266#else
267 if ( mResourceManager ) { 267 if ( mResourceManager ) {
268 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 268 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
269 mResourceView->updateView(); 269 mResourceView->updateView();
270 connect( mResourceView, SIGNAL( resourcesChanged() ), 270 connect( mResourceView, SIGNAL( resourcesChanged() ),
271 SLOT( updateView() ) ); 271 SLOT( updateView() ) );
272 } else { 272 } else {
273 mResourceView = 0; 273 mResourceView = 0;
274 } 274 }
275#endif 275#endif
276 QWidget *rightBox = new QWidget( mPanner ); 276 QWidget *rightBox = new QWidget( mPanner );
277 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 277 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
278 278
279 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 279 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
280 rightLayout->addWidget( mNavigatorBar ); 280 rightLayout->addWidget( mNavigatorBar );
281 281
282 mRightFrame = new QWidgetStack( rightBox ); 282 mRightFrame = new QWidgetStack( rightBox );
283 rightLayout->addWidget( mRightFrame, 1 ); 283 rightLayout->addWidget( mRightFrame, 1 );
284 284
285 mLeftFrame = mLeftSplitter; 285 mLeftFrame = mLeftSplitter;
286#else 286#else
287 QWidget *mainBox = new QWidget( this ); 287 QWidget *mainBox = new QWidget( this );
288 QWidget *leftFrame = new QWidget( mainBox ); 288 QWidget *leftFrame = new QWidget( mainBox );
289 289
290 QBoxLayout * mainBoxLayout; 290 QBoxLayout * mainBoxLayout;
291 QBoxLayout * leftFrameLayout; 291 QBoxLayout * leftFrameLayout;
292 if ( KOPrefs::instance()->mVerticalScreen ) { 292 if ( KOPrefs::instance()->mVerticalScreen ) {
293 mainBoxLayout = new QVBoxLayout(mainBox); 293 mainBoxLayout = new QVBoxLayout(mainBox);
294 leftFrameLayout = new QHBoxLayout(leftFrame ); 294 leftFrameLayout = new QHBoxLayout(leftFrame );
295 } else { 295 } else {
296 mainBoxLayout = new QHBoxLayout(mainBox); 296 mainBoxLayout = new QHBoxLayout(mainBox);
297 leftFrameLayout = new QVBoxLayout(leftFrame ); 297 leftFrameLayout = new QVBoxLayout(leftFrame );
298 } 298 }
299 topLayout->addWidget( mainBox ); 299 topLayout->addWidget( mainBox );
300 mainBoxLayout->addWidget (leftFrame); 300 mainBoxLayout->addWidget (leftFrame);
301 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, 301 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE,
302 "CalendarView::DateNavigator", QDate::currentDate()); 302 "CalendarView::DateNavigator", QDate::currentDate());
303 // mDateNavigator->blockSignals( true ); 303 // mDateNavigator->blockSignals( true );
304 leftFrameLayout->addWidget( mDateNavigator ); 304 leftFrameLayout->addWidget( mDateNavigator );
305 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); 305 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView");
306 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolist"); 306 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolist");
307 307
308 if ( QApplication::desktop()->width() < 480 ) { 308 if ( QApplication::desktop()->width() < 480 ) {
309 leftFrameLayout->addWidget(mFilterView); 309 leftFrameLayout->addWidget(mFilterView);
310 leftFrameLayout->addWidget(mTodoList, 2 ); 310 leftFrameLayout->addWidget(mTodoList, 2 );
311 311
312 } else { 312 } else {
313 leftFrameLayout->addWidget(mTodoList,2 ); 313 leftFrameLayout->addWidget(mTodoList,2 );
314 leftFrameLayout->addWidget(mFilterView ); 314 leftFrameLayout->addWidget(mFilterView );
315 } 315 }
316 mFilterView->hide(); 316 mFilterView->hide();
317 QWidget *rightBox = new QWidget( mainBox ); 317 QWidget *rightBox = new QWidget( mainBox );
318 mainBoxLayout->addWidget ( rightBox, 10 ); 318 mainBoxLayout->addWidget ( rightBox, 10 );
319 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 319 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
320 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 320 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
321 mRightFrame = new QWidgetStack( rightBox ); 321 mRightFrame = new QWidgetStack( rightBox );
322 rightLayout->addWidget( mNavigatorBar ); 322 rightLayout->addWidget( mNavigatorBar );
323 rightLayout->addWidget( mRightFrame, 10 ); 323 rightLayout->addWidget( mRightFrame, 10 );
324 324
325 mLeftFrame = leftFrame; 325 mLeftFrame = leftFrame;
326 if ( KOPrefs::instance()->mVerticalScreen ) { 326 if ( KOPrefs::instance()->mVerticalScreen ) {
327 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 327 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
328 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 328 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
329 } else { 329 } else {
330 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 330 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
331 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 331 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
332 } 332 }
333 333
334 //qDebug("Calendarview Size %d %d ", width(), height()); 334 //qDebug("Calendarview Size %d %d ", width(), height());
335#endif 335#endif
336 336
337 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 337 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
338 SLOT( showDates( const KCal::DateList & ) ) ); 338 SLOT( showDates( const KCal::DateList & ) ) );
339 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 339 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
340 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 340 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
341 341
342 connect( mNavigatorBar, SIGNAL( goPrevYear() ), 342 connect( mNavigatorBar, SIGNAL( goPrevYear() ),
343 mNavigator, SLOT( selectPreviousYear() ) ); 343 mNavigator, SLOT( selectPreviousYear() ) );
344 connect( mNavigatorBar, SIGNAL( goNextYear() ), 344 connect( mNavigatorBar, SIGNAL( goNextYear() ),
345 mNavigator, SLOT( selectNextYear() ) ); 345 mNavigator, SLOT( selectNextYear() ) );
346 connect( mNavigatorBar, SIGNAL( goPrevMonth() ), 346 connect( mNavigatorBar, SIGNAL( goPrevMonth() ),
347 mNavigator, SLOT( selectPreviousMonth() ) ); 347 mNavigator, SLOT( selectPreviousMonth() ) );
348 connect( mNavigatorBar, SIGNAL( goNextMonth() ), 348 connect( mNavigatorBar, SIGNAL( goNextMonth() ),
349 mNavigator, SLOT( selectNextMonth() ) ); 349 mNavigator, SLOT( selectNextMonth() ) );
350 350
351 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 351 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
352 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); 352 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) );
353 353
354 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 354 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
355 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 355 mNavigator, SLOT( selectWeek( const QDate & ) ) );
356 356
357 connect( mDateNavigator, SIGNAL( goPrevYear() ), 357 connect( mDateNavigator, SIGNAL( goPrevYear() ),
358 mNavigator, SLOT( selectPreviousYear() ) ); 358 mNavigator, SLOT( selectPreviousYear() ) );
359 connect( mDateNavigator, SIGNAL( goNextYear() ), 359 connect( mDateNavigator, SIGNAL( goNextYear() ),
360 mNavigator, SLOT( selectNextYear() ) ); 360 mNavigator, SLOT( selectNextYear() ) );
361 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 361 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
362 mNavigator, SLOT( selectPreviousMonth() ) ); 362 mNavigator, SLOT( selectPreviousMonth() ) );
363 connect( mDateNavigator, SIGNAL( goNextMonth() ), 363 connect( mDateNavigator, SIGNAL( goNextMonth() ),
364 mNavigator, SLOT( selectNextMonth() ) ); 364 mNavigator, SLOT( selectNextMonth() ) );
365 365
366 connect( mDateNavigator, SIGNAL( goPrevious() ), 366 connect( mDateNavigator, SIGNAL( goPrevious() ),
367 mNavigator, SLOT( selectPrevious() ) ); 367 mNavigator, SLOT( selectPrevious() ) );
368 connect( mDateNavigator, SIGNAL( goNext() ), 368 connect( mDateNavigator, SIGNAL( goNext() ),
369 mNavigator, SLOT( selectNext() ) ); 369 mNavigator, SLOT( selectNext() ) );
370 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 370 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
371 mNavigator, SLOT( slotMonthSelect( int ) ) ); 371 mNavigator, SLOT( slotMonthSelect( int ) ) );
372 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), 372 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ),
373 mNavigator, SLOT( slotMonthSelect( int ) ) ); 373 mNavigator, SLOT( slotMonthSelect( int ) ) );
374 374
375 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 375 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
376 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 376 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
377 377
378 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), 378 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ),
379 SLOT( eventAdded( Event *) ) ); 379 SLOT( eventAdded( Event *) ) );
380 380
381 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 381 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
382 382
383 connect( this, SIGNAL( configChanged() ), 383 connect( this, SIGNAL( configChanged() ),
384 mDateNavigator, SLOT( updateConfig() ) ); 384 mDateNavigator, SLOT( updateConfig() ) );
385 385
386 connect( mTodoList, SIGNAL( newTodoSignal() ), 386 connect( mTodoList, SIGNAL( newTodoSignal() ),
387 SLOT( newTodo() ) ); 387 SLOT( newTodo() ) );
388 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 388 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
389 SLOT( newSubTodo( Todo * ) ) ); 389 SLOT( newSubTodo( Todo * ) ) );
390 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 390 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
391 SLOT( editTodo( Todo * ) ) ); 391 SLOT( editTodo( Todo * ) ) );
392 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 392 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
393 SLOT( showTodo( Todo *) ) ); 393 SLOT( showTodo( Todo *) ) );
394 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 394 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
395 SLOT( deleteTodo( Todo *) ) ); 395 SLOT( deleteTodo( Todo *) ) );
396 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 396 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
397 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 397 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
398 SLOT( purgeCompleted() ) ); 398 SLOT( purgeCompleted() ) );
399 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 399 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
400 SIGNAL( todoModified( Todo *, int ) ) ); 400 SIGNAL( todoModified( Todo *, int ) ) );
401 401
402 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 402 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
403 this, SLOT ( cloneIncidence( Incidence * ) ) ); 403 this, SLOT ( cloneIncidence( Incidence * ) ) );
404 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 404 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
405 this, SLOT (cancelIncidence( Incidence * ) ) ); 405 this, SLOT (cancelIncidence( Incidence * ) ) );
406 406
407 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 407 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
408 this, SLOT ( moveIncidence( Incidence * ) ) ); 408 this, SLOT ( moveIncidence( Incidence * ) ) );
409 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 409 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
410 this, SLOT ( beamIncidence( Incidence * ) ) ); 410 this, SLOT ( beamIncidence( Incidence * ) ) );
411 411
412 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 412 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
413 this, SLOT ( todo_unsub( Todo * ) ) ); 413 this, SLOT ( todo_unsub( Todo * ) ) );
414 414
415 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 415 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
416 SLOT( updateTodo( Todo *, int ) ) ); 416 SLOT( updateTodo( Todo *, int ) ) );
417 connect( this, SIGNAL( todoModified( Todo *, int )), this, 417 connect( this, SIGNAL( todoModified( Todo *, int )), this,
418 SLOT( changeTodoDisplay( Todo *, int ) ) ); 418 SLOT( changeTodoDisplay( Todo *, int ) ) );
419 419
420 420
421 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 421 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
422 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 422 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
423 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 423 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
424 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 424 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
425 425
426 426
427 427
428 428
429 429
430 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 430 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
431 SLOT(checkClipboard())); 431 SLOT(checkClipboard()));
432 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 432 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
433 SLOT( processTodoListSelection( Incidence * ) ) ); 433 SLOT( processTodoListSelection( Incidence * ) ) );
434 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 434 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
435 435
436 // kdDebug() << "CalendarView::CalendarView() done" << endl; 436 // kdDebug() << "CalendarView::CalendarView() done" << endl;
437 437
438 mDateFrame = new QVBox(0,0,WType_Popup); 438 mDateFrame = new QVBox(0,0,WType_Popup);
439 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 439 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
440 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 440 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
441 mDateFrame->setLineWidth(3); 441 mDateFrame->setLineWidth(3);
442 mDateFrame->hide(); 442 mDateFrame->hide();
443 mDateFrame->setCaption( i18n( "Pick a date to display")); 443 mDateFrame->setCaption( i18n( "Pick a date to display"));
444 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 444 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
445 445
446 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 446 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
447 447
448 mEventEditor = mDialogManager->getEventEditor(); 448 mEventEditor = mDialogManager->getEventEditor();
449 mTodoEditor = mDialogManager->getTodoEditor(); 449 mTodoEditor = mDialogManager->getTodoEditor();
450 450
451 mFlagEditDescription = false; 451 mFlagEditDescription = false;
452 452
453 mSuspendTimer = new QTimer( this ); 453 mSuspendTimer = new QTimer( this );
454 mAlarmTimer = new QTimer( this ); 454 mAlarmTimer = new QTimer( this );
455 mRecheckAlarmTimer = new QTimer( this ); 455 mRecheckAlarmTimer = new QTimer( this );
456 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 456 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
457 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 457 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
458 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 458 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
459 mAlarmDialog = new AlarmDialog( this ); 459 mAlarmDialog = new AlarmDialog( this );
460 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 460 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
461 mAlarmDialog->setServerNotification( false ); 461 mAlarmDialog->setServerNotification( false );
462 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 462 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
463} 463}
464 464
465 465
466CalendarView::~CalendarView() 466CalendarView::~CalendarView()
467{ 467{
468 // kdDebug() << "~CalendarView()" << endl; 468 // kdDebug() << "~CalendarView()" << endl;
469 //qDebug("CalendarView::~CalendarView() "); 469 //qDebug("CalendarView::~CalendarView() ");
470 delete mDialogManager; 470 delete mDialogManager;
471 delete mViewManager; 471 delete mViewManager;
472 delete mStorage; 472 delete mStorage;
473 delete mDateFrame ; 473 delete mDateFrame ;
474 delete beamDialog; 474 delete beamDialog;
475 //kdDebug() << "~CalendarView() done" << endl; 475 //kdDebug() << "~CalendarView() done" << endl;
476} 476}
477void CalendarView::timerAlarm() 477void CalendarView::timerAlarm()
478{ 478{
479 //qDebug("CalendarView::timerAlarm() "); 479 //qDebug("CalendarView::timerAlarm() ");
480 computeAlarm(mAlarmNotification ); 480 computeAlarm(mAlarmNotification );
481} 481}
482 482
483void CalendarView::suspendAlarm() 483void CalendarView::suspendAlarm()
484{ 484{
485 //qDebug(" CalendarView::suspendAlarm() "); 485 //qDebug(" CalendarView::suspendAlarm() ");
486 computeAlarm(mSuspendAlarmNotification ); 486 computeAlarm(mSuspendAlarmNotification );
487 487
488} 488}
489 489
490void CalendarView::startAlarm( QString mess , QString filename) 490void CalendarView::startAlarm( QString mess , QString filename)
491{ 491{
492 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 492 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
493 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); 493 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
494 494
495} 495}
496 496
497void CalendarView::checkNextTimerAlarm() 497void CalendarView::checkNextTimerAlarm()
498{ 498{
499 mCalendar->checkAlarmForIncidence( 0, true ); 499 mCalendar->checkAlarmForIncidence( 0, true );
500} 500}
501 501
502void CalendarView::computeAlarm( QString msg ) 502void CalendarView::computeAlarm( QString msg )
503{ 503{
504 504
505 QString mess = msg; 505 QString mess = msg;
506 QString mAlarmMessage = mess.mid( 9 ); 506 QString mAlarmMessage = mess.mid( 9 );
507 QString filename = MainWindow::resourcePath(); 507 QString filename = MainWindow::resourcePath();
508 filename += "koalarm.wav"; 508 filename += "koalarm.wav";
509 QString tempfilename; 509 QString tempfilename;
510 if ( mess.left( 13 ) == "suspend_alarm") { 510 if ( mess.left( 13 ) == "suspend_alarm") {
511 bool error = false; 511 bool error = false;
512 int len = mess.mid( 13 ).find("+++"); 512 int len = mess.mid( 13 ).find("+++");
513 if ( len < 2 ) 513 if ( len < 2 )
514 error = true; 514 error = true;
515 else { 515 else {
516 tempfilename = mess.mid( 13, len ); 516 tempfilename = mess.mid( 13, len );
517 if ( !QFile::exists( tempfilename ) ) 517 if ( !QFile::exists( tempfilename ) )
518 error = true; 518 error = true;
519 } 519 }
520 if ( ! error ) { 520 if ( ! error ) {
521 filename = tempfilename; 521 filename = tempfilename;
522 } 522 }
523 mAlarmMessage = mess.mid( 13+len+3 ); 523 mAlarmMessage = mess.mid( 13+len+3 );
524 //qDebug("suspend file %s ",tempfilename.latin1() ); 524 //qDebug("suspend file %s ",tempfilename.latin1() );
525 startAlarm( mAlarmMessage, filename); 525 startAlarm( mAlarmMessage, filename);
526 return; 526 return;
527 } 527 }
528 if ( mess.left( 11 ) == "timer_alarm") { 528 if ( mess.left( 11 ) == "timer_alarm") {
529 //mTimerTime = 0; 529 //mTimerTime = 0;
530 startAlarm( mess.mid( 11 ), filename ); 530 startAlarm( mess.mid( 11 ), filename );
531 return; 531 return;
532 } 532 }
533 if ( mess.left( 10 ) == "proc_alarm") { 533 if ( mess.left( 10 ) == "proc_alarm") {
534 bool error = false; 534 bool error = false;
535 int len = mess.mid( 10 ).find("+++"); 535 int len = mess.mid( 10 ).find("+++");
536 if ( len < 2 ) 536 if ( len < 2 )
537 error = true; 537 error = true;
538 else { 538 else {
539 tempfilename = mess.mid( 10, len ); 539 tempfilename = mess.mid( 10, len );
540 if ( !QFile::exists( tempfilename ) ) 540 if ( !QFile::exists( tempfilename ) )
541 error = true; 541 error = true;
542 } 542 }
543 if ( error ) { 543 if ( error ) {
544 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 544 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
545 mAlarmMessage += mess.mid( 10+len+3+9 ); 545 mAlarmMessage += mess.mid( 10+len+3+9 );
546 } else { 546 } else {
547 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 547 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
548 //qDebug("-----system command %s ",tempfilename.latin1() ); 548 //qDebug("-----system command %s ",tempfilename.latin1() );
549#ifndef _WIN32_ 549#ifndef _WIN32_
550 if ( vfork () == 0 ) { 550 if ( vfork () == 0 ) {
551 execl ( tempfilename.latin1(), 0 ); 551 execl ( tempfilename.latin1(), 0 );
552 return; 552 return;
553 } 553 }
554#else 554#else
555 QProcess* p = new QProcess(); 555 QProcess* p = new QProcess();
556 p->addArgument( tempfilename.latin1() ); 556 p->addArgument( tempfilename.latin1() );
557 p->start(); 557 p->start();
558 return; 558 return;
559#endif 559#endif
560 560
561 return; 561 return;
562 } 562 }
563 563
564 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 564 //qDebug("+++++++system command %s ",tempfilename.latin1() );
565 } 565 }
566 if ( mess.left( 11 ) == "audio_alarm") { 566 if ( mess.left( 11 ) == "audio_alarm") {
567 bool error = false; 567 bool error = false;
568 int len = mess.mid( 11 ).find("+++"); 568 int len = mess.mid( 11 ).find("+++");
569 if ( len < 2 ) 569 if ( len < 2 )
570 error = true; 570 error = true;
571 else { 571 else {
572 tempfilename = mess.mid( 11, len ); 572 tempfilename = mess.mid( 11, len );
573 if ( !QFile::exists( tempfilename ) ) 573 if ( !QFile::exists( tempfilename ) )
574 error = true; 574 error = true;
575 } 575 }
576 if ( ! error ) { 576 if ( ! error ) {
577 filename = tempfilename; 577 filename = tempfilename;
578 } 578 }
579 mAlarmMessage = mess.mid( 11+len+3+9 ); 579 mAlarmMessage = mess.mid( 11+len+3+9 );
580 //qDebug("audio file command %s ",tempfilename.latin1() ); 580 //qDebug("audio file command %s ",tempfilename.latin1() );
581 } 581 }
582 if ( mess.left( 9 ) == "cal_alarm") { 582 if ( mess.left( 9 ) == "cal_alarm") {
583 mAlarmMessage = mess.mid( 9 ) ; 583 mAlarmMessage = mess.mid( 9 ) ;
584 } 584 }
585 585
586 startAlarm( mAlarmMessage, filename ); 586 startAlarm( mAlarmMessage, filename );
587 587
588 588
589} 589}
590 590
591void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 591void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
592{ 592{
593 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 593 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
594 594
595 mSuspendAlarmNotification = noti; 595 mSuspendAlarmNotification = noti;
596 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 596 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
597 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 597 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
598 mSuspendTimer->start( ms , true ); 598 mSuspendTimer->start( ms , true );
599 599
600} 600}
601 601
602void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 602void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
603{ 603{
604 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 604 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
605 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 605 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
606#ifndef DESKTOP_VERSION 606#ifndef DESKTOP_VERSION
607 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); 607 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() );
608#endif 608#endif
609 return; 609 return;
610 } 610 }
611 int maxSec; 611 int maxSec;
612 //maxSec = 5; //testing only 612 //maxSec = 5; //testing only
613 maxSec = 86400+3600; // one day+1hour 613 maxSec = 86400+3600; // one day+1hour
614 mAlarmNotification = noti; 614 mAlarmNotification = noti;
615 int sec = QDateTime::currentDateTime().secsTo( qdt ); 615 int sec = QDateTime::currentDateTime().secsTo( qdt );
616 if ( sec > maxSec ) { 616 if ( sec > maxSec ) {
617 mRecheckAlarmTimer->start( maxSec * 1000 ); 617 mRecheckAlarmTimer->start( maxSec * 1000 );
618 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 618 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
619 return; 619 return;
620 } else { 620 } else {
621 mRecheckAlarmTimer->stop(); 621 mRecheckAlarmTimer->stop();
622 } 622 }
623 //qDebug("Alarm timer started with secs: %d ", sec); 623 //qDebug("Alarm timer started with secs: %d ", sec);
624 mAlarmTimer->start( sec *1000 , true ); 624 mAlarmTimer->start( sec *1000 , true );
625 625
626} 626}
627// called by mRecheckAlarmTimer to get next alarm 627// called by mRecheckAlarmTimer to get next alarm
628// we need this, because a QTimer has only a max range of 25 days 628// we need this, because a QTimer has only a max range of 25 days
629void CalendarView::recheckTimerAlarm() 629void CalendarView::recheckTimerAlarm()
630{ 630{
631 mAlarmTimer->stop(); 631 mAlarmTimer->stop();
632 mRecheckAlarmTimer->stop(); 632 mRecheckAlarmTimer->stop();
633 mCalendar->checkAlarmForIncidence( 0, true ); 633 mCalendar->checkAlarmForIncidence( 0, true );
634} 634}
635void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 635void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
636{ 636{
637 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 637 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
638 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 638 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
639#ifndef DESKTOP_VERSION 639#ifndef DESKTOP_VERSION
640 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 640 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
641#endif 641#endif
642 return; 642 return;
643 } 643 }
644 mAlarmTimer->stop(); 644 mAlarmTimer->stop();
645} 645}
646void CalendarView::selectWeekNum ( int num ) 646void CalendarView::selectWeekNum ( int num )
647{ 647{
648 dateNavigator()->selectWeek( num ); 648 dateNavigator()->selectWeek( num );
649 mViewManager->showWeekView(); 649 mViewManager->showWeekView();
650} 650}
651KOViewManager *CalendarView::viewManager() 651KOViewManager *CalendarView::viewManager()
652{ 652{
653 return mViewManager; 653 return mViewManager;
654} 654}
655 655
656KODialogManager *CalendarView::dialogManager() 656KODialogManager *CalendarView::dialogManager()
657{ 657{
658 return mDialogManager; 658 return mDialogManager;
659} 659}
660 660
661QDate CalendarView::startDate() 661QDate CalendarView::startDate()
662{ 662{
663 DateList dates = mNavigator->selectedDates(); 663 DateList dates = mNavigator->selectedDates();
664 664
665 return dates.first(); 665 return dates.first();
666} 666}
667 667
668QDate CalendarView::endDate() 668QDate CalendarView::endDate()
669{ 669{
670 DateList dates = mNavigator->selectedDates(); 670 DateList dates = mNavigator->selectedDates();
671 671
672 return dates.last(); 672 return dates.last();
673} 673}
674 674
675 675
676void CalendarView::createPrinter() 676void CalendarView::createPrinter()
677{ 677{
678#ifndef KORG_NOPRINTER 678#ifndef KORG_NOPRINTER
679 if (!mCalPrinter) { 679 if (!mCalPrinter) {
680 mCalPrinter = new CalPrinter(this, mCalendar); 680 mCalPrinter = new CalPrinter(this, mCalendar);
681 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 681 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
682 } 682 }
683#endif 683#endif
684} 684}
685 685
686void CalendarView::confSync() 686void CalendarView::confSync()
687{ 687{
688 static KSyncPrefsDialog* sp = 0; 688 static KSyncPrefsDialog* sp = 0;
689 if ( ! sp ) { 689 if ( ! sp ) {
690 sp = new KSyncPrefsDialog( this, "syncprefs", true ); 690 sp = new KSyncPrefsDialog( this, "syncprefs", true );
691 } 691 }
692 sp->setLocalMachineName ( KOPrefs::instance()->mLocalMachineName );
693 sp->usrReadConfig(); 692 sp->usrReadConfig();
694#ifndef DESKTOP_VERSION 693#ifndef DESKTOP_VERSION
695 sp->showMaximized(); 694 sp->showMaximized();
696#else 695#else
697 sp->show(); 696 sp->show();
698#endif 697#endif
699 sp->exec(); 698 sp->exec();
700 KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); 699 KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames();
701 KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); 700 KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName ();
702} 701}
703 702
704 703
705//KOPrefs::instance()->mWriteBackFile 704//KOPrefs::instance()->mWriteBackFile
706//KOPrefs::instance()->mWriteBackExistingOnly 705//KOPrefs::instance()->mWriteBackExistingOnly
707 706
708// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 707// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
709// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 708// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
710// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 709// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
711// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 710// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
712// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 711// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
713// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 712// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
714 713
715int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 714int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
716{ 715{
717 716
718 //void setZaurusId(int id); 717 //void setZaurusId(int id);
719 // int zaurusId() const; 718 // int zaurusId() const;
720 // void setZaurusUid(int id); 719 // void setZaurusUid(int id);
721 // int zaurusUid() const; 720 // int zaurusUid() const;
722 // void setZaurusStat(int id); 721 // void setZaurusStat(int id);
723 // int zaurusStat() const; 722 // int zaurusStat() const;
724 // 0 equal 723 // 0 equal
725 // 1 take local 724 // 1 take local
726 // 2 take remote 725 // 2 take remote
727 // 3 cancel 726 // 3 cancel
728 QDateTime lastSync = mLastCalendarSync; 727 QDateTime lastSync = mLastCalendarSync;
729 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 728 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
730 bool remCh, locCh; 729 bool remCh, locCh;
731 remCh = ( remote->zaurusUid() != local->zaurusUid() ); 730 remCh = ( remote->zaurusUid() != local->zaurusUid() );
732 locCh = ( local->lastModified() > mLastCalendarSync ); 731 locCh = ( local->lastModified() > mLastCalendarSync );
733 //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() ); 732 //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() );
734 if ( !remCh && ! locCh ) { 733 if ( !remCh && ! locCh ) {
735 //qDebug("both not changed "); 734 //qDebug("both not changed ");
736 lastSync = local->lastModified().addDays(1); 735 lastSync = local->lastModified().addDays(1);
737 } else { 736 } else {
738 if ( locCh ) { 737 if ( locCh ) {
739 //qDebug("loc changed %d %d", local->zaurusStat(), local->revision() ); 738 //qDebug("loc changed %d %d", local->zaurusStat(), local->revision() );
740 lastSync = local->lastModified().addDays( -1 ); 739 lastSync = local->lastModified().addDays( -1 );
741 if ( !remCh ) 740 if ( !remCh )
742 remote->setLastModified( lastSync.addDays( -1 ) ); 741 remote->setLastModified( lastSync.addDays( -1 ) );
743 } else { 742 } else {
744 //qDebug(" not loc changed "); 743 //qDebug(" not loc changed ");
745 lastSync = local->lastModified().addDays( 1 ); 744 lastSync = local->lastModified().addDays( 1 );
746 if ( remCh ) 745 if ( remCh )
747 remote->setLastModified( lastSync.addDays( 1 ) ); 746 remote->setLastModified( lastSync.addDays( 1 ) );
748 747
749 } 748 }
750 } 749 }
751 full = true; 750 full = true;
752 if ( mode < SYNC_PREF_ASK ) 751 if ( mode < SYNC_PREF_ASK )
753 mode = SYNC_PREF_ASK; 752 mode = SYNC_PREF_ASK;
754 } else { 753 } else {
755 if ( local->lastModified() == remote->lastModified() ) 754 if ( local->lastModified() == remote->lastModified() )
756 if ( local->revision() == remote->revision() ) 755 if ( local->revision() == remote->revision() )
757 return 0; 756 return 0;
758 757
759 } 758 }
760 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 759 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
761 760
762 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); 761 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision());
763 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); 762 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() );
764 //full = true; //debug only 763 //full = true; //debug only
765 if ( full ) { 764 if ( full ) {
766 bool equ = false; 765 bool equ = false;
767 if ( local->type() == "Event" ) { 766 if ( local->type() == "Event" ) {
768 equ = (*((Event*) local) == *((Event*) remote)); 767 equ = (*((Event*) local) == *((Event*) remote));
769 } 768 }
770 else if ( local->type() =="Todo" ) 769 else if ( local->type() =="Todo" )
771 equ = (*((Todo*) local) == (*(Todo*) remote)); 770 equ = (*((Todo*) local) == (*(Todo*) remote));
772 else if ( local->type() =="Journal" ) 771 else if ( local->type() =="Journal" )
773 equ = (*((Journal*) local) == *((Journal*) remote)); 772 equ = (*((Journal*) local) == *((Journal*) remote));
774 if ( equ ) { 773 if ( equ ) {
775 //qDebug("equal "); 774 //qDebug("equal ");
776 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 775 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
777 local->setZaurusUid( remote->zaurusUid() ); 776 local->setZaurusUid( remote->zaurusUid() );
778 } 777 }
779 if ( mode < SYNC_PREF_FORCE_LOCAL ) 778 if ( mode < SYNC_PREF_FORCE_LOCAL )
780 return 0; 779 return 0;
781 780
782 }//else //debug only 781 }//else //debug only
783 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 782 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
784 } 783 }
785 int result; 784 int result;
786 bool localIsNew; 785 bool localIsNew;
787 if ( full && mode < SYNC_PREF_NEWEST ) 786 if ( full && mode < SYNC_PREF_NEWEST )
788 mode = SYNC_PREF_ASK; 787 mode = SYNC_PREF_ASK;
789 788
790 switch( mode ) { 789 switch( mode ) {
791 case SYNC_PREF_LOCAL: 790 case SYNC_PREF_LOCAL:
792 if ( lastSync > remote->lastModified() ) 791 if ( lastSync > remote->lastModified() )
793 return 1; 792 return 1;
794 if ( lastSync > local->lastModified() ) 793 if ( lastSync > local->lastModified() )
795 return 2; 794 return 2;
796 return 1; 795 return 1;
797 break; 796 break;
798 case SYNC_PREF_REMOTE: 797 case SYNC_PREF_REMOTE:
799 if ( lastSync > remote->lastModified() ) 798 if ( lastSync > remote->lastModified() )
800 return 1; 799 return 1;
801 if ( lastSync > local->lastModified() ) 800 if ( lastSync > local->lastModified() )
802 return 2; 801 return 2;
803 return 2; 802 return 2;
804 break; 803 break;
805 case SYNC_PREF_NEWEST: 804 case SYNC_PREF_NEWEST:
806 if ( local->lastModified() > remote->lastModified() ) 805 if ( local->lastModified() > remote->lastModified() )
807 return 1; 806 return 1;
808 else 807 else
809 return 2; 808 return 2;
810 break; 809 break;
811 case SYNC_PREF_ASK: 810 case SYNC_PREF_ASK:
812 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); 811 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() );
813 if ( lastSync > remote->lastModified() ) 812 if ( lastSync > remote->lastModified() )
814 return 1; 813 return 1;
815 if ( lastSync > local->lastModified() ) 814 if ( lastSync > local->lastModified() )
816 return 2; 815 return 2;
817 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); 816 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() );
818 localIsNew = local->lastModified() > remote->lastModified(); 817 localIsNew = local->lastModified() > remote->lastModified();
819 if ( localIsNew ) 818 if ( localIsNew )
820 getEventViewerDialog()->setColorMode( 1 ); 819 getEventViewerDialog()->setColorMode( 1 );
821 else 820 else
822 getEventViewerDialog()->setColorMode( 2 ); 821 getEventViewerDialog()->setColorMode( 2 );
823 getEventViewerDialog()->setIncidence(local); 822 getEventViewerDialog()->setIncidence(local);
824 if ( localIsNew ) 823 if ( localIsNew )
825 getEventViewerDialog()->setColorMode( 2 ); 824 getEventViewerDialog()->setColorMode( 2 );
826 else 825 else
827 getEventViewerDialog()->setColorMode( 1 ); 826 getEventViewerDialog()->setColorMode( 1 );
828 getEventViewerDialog()->addIncidence(remote); 827 getEventViewerDialog()->addIncidence(remote);
829 getEventViewerDialog()->setColorMode( 0 ); 828 getEventViewerDialog()->setColorMode( 0 );
830 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 829 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
831 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 830 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
832 getEventViewerDialog()->showMe(); 831 getEventViewerDialog()->showMe();
833 result = getEventViewerDialog()->executeS( localIsNew ); 832 result = getEventViewerDialog()->executeS( localIsNew );
834 return result; 833 return result;
835 834
836 break; 835 break;
837 case SYNC_PREF_FORCE_LOCAL: 836 case SYNC_PREF_FORCE_LOCAL:
838 return 1; 837 return 1;
839 break; 838 break;
840 case SYNC_PREF_FORCE_REMOTE: 839 case SYNC_PREF_FORCE_REMOTE:
841 return 2; 840 return 2;
842 break; 841 break;
843 842
844 default: 843 default:
845 // SYNC_PREF_TAKE_BOTH not implemented 844 // SYNC_PREF_TAKE_BOTH not implemented
846 break; 845 break;
847 } 846 }
848 return 0; 847 return 0;
849} 848}
850Event* CalendarView::getLastSyncEvent() 849Event* CalendarView::getLastSyncEvent()
851{ 850{
852 Event* lse; 851 Event* lse;
853 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 852 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
854 lse = mCalendar->event( "last-syncEvent-device-"+mCurrentSyncDevice ); 853 lse = mCalendar->event( "last-syncEvent-device-"+mCurrentSyncDevice );
855 if (!lse) { 854 if (!lse) {
856 lse = new Event(); 855 lse = new Event();
857 lse->setUid( "last-syncEvent-device-"+mCurrentSyncDevice ); 856 lse->setUid( "last-syncEvent-device-"+mCurrentSyncDevice );
858 lse->setSummary(mCurrentSyncDevice + i18n(" - sync event")); 857 lse->setSummary(mCurrentSyncDevice + i18n(" - sync event"));
859 lse->setDtStart( mLastCalendarSync ); 858 lse->setDtStart( mLastCalendarSync );
860 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 859 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
861 lse->setCategories( i18n("SyncEvent") ); 860 lse->setCategories( i18n("SyncEvent") );
862 lse->setReadOnly( true ); 861 lse->setReadOnly( true );
863 mCalendar->addEvent( lse ); 862 mCalendar->addEvent( lse );
864 } 863 }
865 864
866 return lse; 865 return lse;
867 866
868} 867}
869void CalendarView::checkSharpEvent( Event* lastSync, Incidence* toDelete ) 868void CalendarView::checkSharpEvent( Event* lastSync, Incidence* toDelete )
870{ 869{
871 if ( ! lastSync ) 870 if ( ! lastSync )
872 return; 871 return;
873 if ( toDelete->zaurusId() < 0 ) 872 if ( toDelete->zaurusId() < 0 )
874 return; 873 return;
875 if ( toDelete->type() == "Journal" ) 874 if ( toDelete->type() == "Journal" )
876 return; 875 return;
877 QString des = lastSync->description(); 876 QString des = lastSync->description();
878 QString pref = "e"; 877 QString pref = "e";
879 if ( toDelete->type() == "Todo" ) 878 if ( toDelete->type() == "Todo" )
880 pref = "t"; 879 pref = "t";
881 des += pref+ QString::number ( toDelete->zaurusId() ) + ","; 880 des += pref+ QString::number ( toDelete->zaurusId() ) + ",";
882 lastSync->setReadOnly( false ); 881 lastSync->setReadOnly( false );
883 lastSync->setDescription( des ); 882 lastSync->setDescription( des );
884 lastSync->setReadOnly( true ); 883 lastSync->setReadOnly( true );
885 884
886} 885}
887bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 886bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
888{ 887{
889 bool syncOK = true; 888 bool syncOK = true;
890 int addedEvent = 0; 889 int addedEvent = 0;
891 int addedEventR = 0; 890 int addedEventR = 0;
892 int deletedEventR = 0; 891 int deletedEventR = 0;
893 int deletedEventL = 0; 892 int deletedEventL = 0;
894 int changedLocal = 0; 893 int changedLocal = 0;
895 int changedRemote = 0; 894 int changedRemote = 0;
896 //QPtrList<Event> el = local->rawEvents(); 895 //QPtrList<Event> el = local->rawEvents();
897 Event* eventR; 896 Event* eventR;
898 QString uid; 897 QString uid;
899 int take; 898 int take;
900 Event* eventL; 899 Event* eventL;
901 Event* eventRSync; 900 Event* eventRSync;
902 Event* eventLSync; 901 Event* eventLSync;
903 Event* eventRSyncSharp = remote->event( "last-syncEvent-device-Sharp-DTM"); 902 Event* eventRSyncSharp = remote->event( "last-syncEvent-device-Sharp-DTM");
904 Event* eventLSyncSharp = local->event( "last-syncEvent-device-Sharp-DTM"); 903 Event* eventLSyncSharp = local->event( "last-syncEvent-device-Sharp-DTM");
905 bool fullDateRange = false; 904 bool fullDateRange = false;
906 mLastCalendarSync = QDateTime::currentDateTime(); 905 mLastCalendarSync = QDateTime::currentDateTime();
907 QDateTime modifiedCalendar = mLastCalendarSync;; 906 QDateTime modifiedCalendar = mLastCalendarSync;;
908 eventR = remote->event("last-syncEvent-device-"+mCurrentSyncName ); 907 eventR = remote->event("last-syncEvent-device-"+mCurrentSyncName );
909 if ( eventR ) { 908 if ( eventR ) {
910 eventRSync = (Event*) eventR->clone(); 909 eventRSync = (Event*) eventR->clone();
911 remote->deleteEvent(eventR ); 910 remote->deleteEvent(eventR );
912 911
913 } else { 912 } else {
914 fullDateRange = true; 913 fullDateRange = true;
915 eventRSync = new Event(); 914 eventRSync = new Event();
916 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 915 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
917 eventRSync->setUid("last-syncEvent-device-"+mCurrentSyncName ); 916 eventRSync->setUid("last-syncEvent-device-"+mCurrentSyncName );
918 eventRSync->setDtStart( mLastCalendarSync ); 917 eventRSync->setDtStart( mLastCalendarSync );
919 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 918 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
920 eventRSync->setCategories( i18n("SyncEvent") ); 919 eventRSync->setCategories( i18n("SyncEvent") );
921 } 920 }
922 eventLSync = getLastSyncEvent(); 921 eventLSync = getLastSyncEvent();
923 if ( eventLSync->dtStart() == mLastCalendarSync ) 922 if ( eventLSync->dtStart() == mLastCalendarSync )
924 fullDateRange = true; 923 fullDateRange = true;
925 924
926 if ( ! fullDateRange ) { 925 if ( ! fullDateRange ) {
927 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 926 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
928 927
929 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 928 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
930 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 929 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
931 fullDateRange = true; 930 fullDateRange = true;
932 } 931 }
933 } 932 }
934 if ( fullDateRange ) 933 if ( fullDateRange )
935 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 934 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
936 else 935 else
937 mLastCalendarSync = eventLSync->dtStart(); 936 mLastCalendarSync = eventLSync->dtStart();
938 // for resyncing if own file has changed 937 // for resyncing if own file has changed
939 if ( mCurrentSyncDevice == "deleteaftersync" ) { 938 if ( mCurrentSyncDevice == "deleteaftersync" ) {
940 mLastCalendarSync = loadedFileVersion; 939 mLastCalendarSync = loadedFileVersion;
941 qDebug("setting mLastCalendarSync "); 940 qDebug("setting mLastCalendarSync ");
942 } 941 }
943 //qDebug("*************************** "); 942 //qDebug("*************************** ");
944 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); 943 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() );
945 QPtrList<Incidence> er = remote->rawIncidences(); 944 QPtrList<Incidence> er = remote->rawIncidences();
946 Incidence* inR = er.first(); 945 Incidence* inR = er.first();
947 Incidence* inL; 946 Incidence* inL;
948 QProgressBar bar( er.count(),0 ); 947 QProgressBar bar( er.count(),0 );
949 bar.setCaption (i18n("Syncing - close to abort!") ); 948 bar.setCaption (i18n("Syncing - close to abort!") );
950 949
951 int w = 300; 950 int w = 300;
952 if ( QApplication::desktop()->width() < 320 ) 951 if ( QApplication::desktop()->width() < 320 )
953 w = 220; 952 w = 220;
954 int h = bar.sizeHint().height() ; 953 int h = bar.sizeHint().height() ;
955 int dw = QApplication::desktop()->width(); 954 int dw = QApplication::desktop()->width();
956 int dh = QApplication::desktop()->height(); 955 int dh = QApplication::desktop()->height();
957 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 956 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
958 bar.show(); 957 bar.show();
959 int modulo = (er.count()/10)+1; 958 int modulo = (er.count()/10)+1;
960 int incCounter = 0; 959 int incCounter = 0;
961 while ( inR ) { 960 while ( inR ) {
962 if ( ! bar.isVisible() ) 961 if ( ! bar.isVisible() )
963 return false; 962 return false;
964 if ( incCounter % modulo == 0 ) 963 if ( incCounter % modulo == 0 )
965 bar.setProgress( incCounter ); 964 bar.setProgress( incCounter );
966 ++incCounter; 965 ++incCounter;
967 uid = inR->uid(); 966 uid = inR->uid();
968 bool skipIncidence = false; 967 bool skipIncidence = false;
969 if ( uid.left(21) == QString("last-syncEvent-device") ) 968 if ( uid.left(21) == QString("last-syncEvent-device") )
970 skipIncidence = true; 969 skipIncidence = true;
971 970
972 qApp->processEvents(); 971 qApp->processEvents();
973 if ( !skipIncidence ) { 972 if ( !skipIncidence ) {
974 inL = local->incidence( uid ); 973 inL = local->incidence( uid );
975 if ( inL ) { // maybe conflict - same uid in both calendars 974 if ( inL ) { // maybe conflict - same uid in both calendars
976 int maxrev = inL->revision(); 975 int maxrev = inL->revision();
977 if ( maxrev < inR->revision() ) 976 if ( maxrev < inR->revision() )
978 maxrev = inR->revision(); 977 maxrev = inR->revision();
979 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 978 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
980 //qDebug("take %d %s ", take, inL->summary().latin1()); 979 //qDebug("take %d %s ", take, inL->summary().latin1());
981 if ( take == 3 ) 980 if ( take == 3 )
982 return false; 981 return false;
983 if ( take == 1 ) {// take local 982 if ( take == 1 ) {// take local
984 inL->setZaurusUid( inR->zaurusUid() ); 983 inL->setZaurusUid( inR->zaurusUid() );
985 remote->deleteIncidence( inR ); 984 remote->deleteIncidence( inR );
986 if ( inL->revision() < maxrev ) 985 if ( inL->revision() < maxrev )
987 inL->setRevision( maxrev ); 986 inL->setRevision( maxrev );
988 remote->addIncidence( inL->clone() ); 987 remote->addIncidence( inL->clone() );
989 ++changedRemote; 988 ++changedRemote;
990 } else { 989 } else {
991 if ( inR->revision() < maxrev ) 990 if ( inR->revision() < maxrev )
992 inR->setRevision( maxrev ); 991 inR->setRevision( maxrev );
993 local->deleteIncidence( inL ); 992 local->deleteIncidence( inL );
994 local->addIncidence( inR->clone() ); 993 local->addIncidence( inR->clone() );
995 ++changedLocal; 994 ++changedLocal;
996 } 995 }
997 } 996 }
998 } else { // no conflict 997 } else { // no conflict
999 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 998 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1000 QString des = eventLSync->description(); 999 QString des = eventLSync->description();
1001 QString pref = "e"; 1000 QString pref = "e";
1002 if ( inR->type() == "Todo" ) 1001 if ( inR->type() == "Todo" )
1003 pref = "t"; 1002 pref = "t";
1004 if ( des.find(pref+QString::number( inR->zaurusId() ) +"," ) >= 0 && mode != 5) { // delete it 1003 if ( des.find(pref+QString::number( inR->zaurusId() ) +"," ) >= 0 && mode != 5) { // delete it
1005 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1004 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1006 //remote->deleteIncidence( inR ); 1005 //remote->deleteIncidence( inR );
1007 ++deletedEventR; 1006 ++deletedEventR;
1008 } else { 1007 } else {
1009 inR->setLastModified( modifiedCalendar ); 1008 inR->setLastModified( modifiedCalendar );
1010 local->addIncidence( inR->clone() ); 1009 local->addIncidence( inR->clone() );
1011 ++addedEvent; 1010 ++addedEvent;
1012 } 1011 }
1013 } else { 1012 } else {
1014 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1013 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1015 inR->setLastModified( modifiedCalendar ); 1014 inR->setLastModified( modifiedCalendar );
1016 local->addIncidence( inR->clone() ); 1015 local->addIncidence( inR->clone() );
1017 ++addedEvent; 1016 ++addedEvent;
1018 } else { 1017 } else {
1019 checkSharpEvent(eventRSyncSharp, inR); 1018 checkSharpEvent(eventRSyncSharp, inR);
1020 remote->deleteIncidence( inR ); 1019 remote->deleteIncidence( inR );
1021 ++deletedEventR; 1020 ++deletedEventR;
1022 } 1021 }
1023 } 1022 }
1024 } 1023 }
1025 } 1024 }
1026 inR = er.next(); 1025 inR = er.next();
1027 } 1026 }
1028 QPtrList<Incidence> el = local->rawIncidences(); 1027 QPtrList<Incidence> el = local->rawIncidences();
1029 inL = el.first(); 1028 inL = el.first();
1030 modulo = (el.count()/10)+1; 1029 modulo = (el.count()/10)+1;
1031 bar.setCaption (i18n("Add / remove events") ); 1030 bar.setCaption (i18n("Add / remove events") );
1032 bar.setTotalSteps ( el.count() ) ; 1031 bar.setTotalSteps ( el.count() ) ;
1033 bar.show(); 1032 bar.show();
1034 incCounter = 0; 1033 incCounter = 0;
1035 1034
1036 while ( inL ) { 1035 while ( inL ) {
1037 1036
1038 qApp->processEvents(); 1037 qApp->processEvents();
1039 if ( ! bar.isVisible() ) 1038 if ( ! bar.isVisible() )
1040 return false; 1039 return false;
1041 if ( incCounter % modulo == 0 ) 1040 if ( incCounter % modulo == 0 )
1042 bar.setProgress( incCounter ); 1041 bar.setProgress( incCounter );
1043 ++incCounter; 1042 ++incCounter;
1044 uid = inL->uid(); 1043 uid = inL->uid();
1045 bool skipIncidence = false; 1044 bool skipIncidence = false;
1046 if ( uid.left(21) == QString("last-syncEvent-device") ) 1045 if ( uid.left(21) == QString("last-syncEvent-device") )
1047 skipIncidence = true; 1046 skipIncidence = true;
1048 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) 1047 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
1049 skipIncidence = true; 1048 skipIncidence = true;
1050 if ( !skipIncidence ) { 1049 if ( !skipIncidence ) {
1051 inR = remote->incidence( uid ); 1050 inR = remote->incidence( uid );
1052 if ( ! inR ) { 1051 if ( ! inR ) {
1053 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1052 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1054 if ( inL->zaurusId() >= 0 && mode != 4 ) { 1053 if ( inL->zaurusId() >= 0 && mode != 4 ) {
1055 local->deleteIncidence( inL ); 1054 local->deleteIncidence( inL );
1056 ++deletedEventL; 1055 ++deletedEventL;
1057 } else { 1056 } else {
1058 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { 1057 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
1059 inL->setZaurusId( -1 ); 1058 inL->setZaurusId( -1 );
1060 ++addedEventR; 1059 ++addedEventR;
1061 inL->setLastModified( modifiedCalendar ); 1060 inL->setLastModified( modifiedCalendar );
1062 remote->addIncidence( inL->clone() ); 1061 remote->addIncidence( inL->clone() );
1063 } 1062 }
1064 } 1063 }
1065 } else { 1064 } else {
1066 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1065 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1067 checkSharpEvent(eventLSyncSharp, inL); 1066 checkSharpEvent(eventLSyncSharp, inL);
1068 local->deleteIncidence( inL ); 1067 local->deleteIncidence( inL );
1069 ++deletedEventL; 1068 ++deletedEventL;
1070 } else { 1069 } else {
1071 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { 1070 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
1072 ++addedEventR; 1071 ++addedEventR;
1073 inL->setLastModified( modifiedCalendar ); 1072 inL->setLastModified( modifiedCalendar );
1074 remote->addIncidence( inL->clone() ); 1073 remote->addIncidence( inL->clone() );
1075 } 1074 }
1076 } 1075 }
1077 } 1076 }
1078 } 1077 }
1079 } 1078 }
1080 inL = el.next(); 1079 inL = el.next();
1081 } 1080 }
1082 1081
1083 bar.hide(); 1082 bar.hide();
1084 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1083 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1085 eventLSync->setReadOnly( false ); 1084 eventLSync->setReadOnly( false );
1086 eventLSync->setDtStart( mLastCalendarSync ); 1085 eventLSync->setDtStart( mLastCalendarSync );
1087 eventRSync->setDtStart( mLastCalendarSync ); 1086 eventRSync->setDtStart( mLastCalendarSync );
1088 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1087 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1089 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1088 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1090 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1089 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1091 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1090 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1092 eventLSync->setReadOnly( true ); 1091 eventLSync->setReadOnly( true );
1093 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 1092 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
1094 remote->addEvent( eventRSync ); 1093 remote->addEvent( eventRSync );
1095 QString mes; 1094 QString mes;
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 ); 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 );
1097 if ( KOPrefs::instance()->mShowSyncSummary ) { 1096 if ( KOPrefs::instance()->mShowSyncSummary ) {
1098 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); 1097 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") );
1099 } 1098 }
1100 qDebug( mes ); 1099 qDebug( mes );
1101 mCalendar->checkAlarmForIncidence( 0, true ); 1100 mCalendar->checkAlarmForIncidence( 0, true );
1102 return syncOK; 1101 return syncOK;
1103} 1102}
1104 1103
1105void CalendarView::setSyncDevice( QString s ) 1104void CalendarView::setSyncDevice( QString s )
1106{ 1105{
1107 mCurrentSyncDevice= s; 1106 mCurrentSyncDevice= s;
1108} 1107}
1109void CalendarView::setSyncName( QString s ) 1108void CalendarView::setSyncName( QString s )
1110{ 1109{
1111 mCurrentSyncName= s; 1110 mCurrentSyncName= s;
1112} 1111}
1113bool CalendarView::syncCalendar(QString filename, int mode) 1112bool CalendarView::syncCalendar(QString filename, int mode)
1114{ 1113{
1115 mGlobalSyncMode = SYNC_MODE_NORMAL; 1114 mGlobalSyncMode = SYNC_MODE_NORMAL;
1116 CalendarLocal* calendar = new CalendarLocal(); 1115 CalendarLocal* calendar = new CalendarLocal();
1117 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1116 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1118 FileStorage* storage = new FileStorage( calendar ); 1117 FileStorage* storage = new FileStorage( calendar );
1119 bool syncOK = false; 1118 bool syncOK = false;
1120 storage->setFileName( filename ); 1119 storage->setFileName( filename );
1121 // qDebug("loading ... "); 1120 // qDebug("loading ... ");
1122 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { 1121 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) {
1123 getEventViewerDialog()->setSyncMode( true ); 1122 getEventViewerDialog()->setSyncMode( true );
1124 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1123 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1125 getEventViewerDialog()->setSyncMode( false ); 1124 getEventViewerDialog()->setSyncMode( false );
1126 if ( syncOK ) { 1125 if ( syncOK ) {
1127 if ( KOPrefs::instance()->mWriteBackFile ) 1126 if ( KOPrefs::instance()->mWriteBackFile )
1128 { 1127 {
1129 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 1128 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
1130 storage->save(); 1129 storage->save();
1131 } 1130 }
1132 } 1131 }
1133 setModified( true ); 1132 setModified( true );
1134 } 1133 }
1135 delete storage; 1134 delete storage;
1136 delete calendar; 1135 delete calendar;
1137 if ( syncOK ) 1136 if ( syncOK )
1138 updateView(); 1137 updateView();
1139 return syncOK; 1138 return syncOK;
1140} 1139}
1141void CalendarView::syncSharp() 1140void CalendarView::syncSharp()
1142{ 1141{
1143#ifndef DESKTOP_VERSION 1142#ifndef DESKTOP_VERSION
1144 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1143 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1145 //mCurrentSyncDevice = "sharp-DTM"; 1144 //mCurrentSyncDevice = "sharp-DTM";
1146 if ( KOPrefs::instance()->mAskForPreferences ) 1145 if ( KOPrefs::instance()->mAskForPreferences )
1147 edit_sync_options(); 1146 edit_sync_options();
1148 qApp->processEvents(); 1147 qApp->processEvents();
1149 CalendarLocal* calendar = new CalendarLocal(); 1148 CalendarLocal* calendar = new CalendarLocal();
1150 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1149 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1151 bool syncOK = false; 1150 bool syncOK = false;
1152 SharpFormat sharpFormat; 1151 SharpFormat sharpFormat;
1153 if ( sharpFormat.load( calendar, mCalendar ) ) { 1152 if ( sharpFormat.load( calendar, mCalendar ) ) {
1154 getEventViewerDialog()->setSyncMode( true ); 1153 getEventViewerDialog()->setSyncMode( true );
1155 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); 1154 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
1156 getEventViewerDialog()->setSyncMode( false ); 1155 getEventViewerDialog()->setSyncMode( false );
1157 qApp->processEvents(); 1156 qApp->processEvents();
1158 if ( syncOK ) { 1157 if ( syncOK ) {
1159 if ( KOPrefs::instance()->mWriteBackFile ) 1158 if ( KOPrefs::instance()->mWriteBackFile )
1160 { 1159 {
1161 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1160 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1162 Incidence* inc = iL.first(); 1161 Incidence* inc = iL.first();
1163 /* obsolete 1162 /* obsolete
1164 while ( inc ) { 1163 while ( inc ) {
1165 inc->setZaurusStat( inc->revision () ); 1164 inc->setZaurusStat( inc->revision () );
1166 inc = iL.next(); 1165 inc = iL.next();
1167 } 1166 }
1168 */ 1167 */
1169 // pending: clean last sync event description 1168 // pending: clean last sync event description
1170 sharpFormat.save(calendar); 1169 sharpFormat.save(calendar);
1171 iL = calendar->rawIncidences(); 1170 iL = calendar->rawIncidences();
1172 inc = iL.first(); 1171 inc = iL.first();
1173 Incidence* loc; 1172 Incidence* loc;
1174 while ( inc ) { 1173 while ( inc ) {
1175 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1174 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1176 loc = mCalendar->incidence(inc->uid() ); 1175 loc = mCalendar->incidence(inc->uid() );
1177 if ( loc ) { 1176 if ( loc ) {
1178 loc->setZaurusId( inc->zaurusId() ); 1177 loc->setZaurusId( inc->zaurusId() );
1179 loc->setZaurusUid( inc->zaurusUid() ); 1178 loc->setZaurusUid( inc->zaurusUid() );
1180 } 1179 }
1181 } 1180 }
1182 inc = iL.next(); 1181 inc = iL.next();
1183 } 1182 }
1184 Incidence* lse = getLastSyncEvent(); 1183 Incidence* lse = getLastSyncEvent();
1185 if ( lse ) { 1184 if ( lse ) {
1186 lse->setReadOnly( false ); 1185 lse->setReadOnly( false );
1187 lse->setDescription( "" ); 1186 lse->setDescription( "" );
1188 lse->setReadOnly( true ); 1187 lse->setReadOnly( true );
1189 } 1188 }
1190 } 1189 }
1191 } 1190 }
1192 setModified( true ); 1191 setModified( true );
1193 } else { 1192 } else {
1194 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1193 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1195 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1194 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1196 question, i18n("Ok")) ; 1195 question, i18n("Ok")) ;
1197 1196
1198 } 1197 }
1199 delete calendar; 1198 delete calendar;
1200 updateView(); 1199 updateView();
1201 return ;//syncOK; 1200 return ;//syncOK;
1202#endif 1201#endif
1203} 1202}
1204 1203
1205 1204
1206#include <kabc/stdaddressbook.h> 1205#include <kabc/stdaddressbook.h>
1207bool CalendarView::importBday() 1206bool CalendarView::importBday()
1208{ 1207{
1209 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1208 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1210 KABC::AddressBook::Iterator it; 1209 KABC::AddressBook::Iterator it;
1211 int count = 0; 1210 int count = 0;
1212 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1211 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1213 ++count; 1212 ++count;
1214 } 1213 }
1215 QProgressBar bar(count,0 ); 1214 QProgressBar bar(count,0 );
1216 int w = 300; 1215 int w = 300;
1217 if ( QApplication::desktop()->width() < 320 ) 1216 if ( QApplication::desktop()->width() < 320 )
1218 w = 220; 1217 w = 220;
1219 int h = bar.sizeHint().height() ; 1218 int h = bar.sizeHint().height() ;
1220 int dw = QApplication::desktop()->width(); 1219 int dw = QApplication::desktop()->width();
1221 int dh = QApplication::desktop()->height(); 1220 int dh = QApplication::desktop()->height();
1222 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1221 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1223 bar.show(); 1222 bar.show();
1224 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1223 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1225 qApp->processEvents(); 1224 qApp->processEvents();
1226 count = 0; 1225 count = 0;
1227 int addCount = 0; 1226 int addCount = 0;
1228 KCal::Attendee* a = 0; 1227 KCal::Attendee* a = 0;
1229 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1228 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1230 if ( ! bar.isVisible() ) 1229 if ( ! bar.isVisible() )
1231 return false; 1230 return false;
1232 bar.setProgress( count++ ); 1231 bar.setProgress( count++ );
1233 qApp->processEvents(); 1232 qApp->processEvents();
1234 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1233 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1235 if ( (*it).birthday().date().isValid() ){ 1234 if ( (*it).birthday().date().isValid() ){
1236 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1235 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1237 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1236 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1238 ++addCount; 1237 ++addCount;
1239 } 1238 }
1240 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1239 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1241 if ( anni.isValid() ){ 1240 if ( anni.isValid() ){
1242 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1241 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1243 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1242 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1244 ++addCount; 1243 ++addCount;
1245 } 1244 }
1246 } 1245 }
1247 updateView(); 1246 updateView();
1248 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1247 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1249 return true; 1248 return true;
1250} 1249}
1251 1250
1252bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1251bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1253{ 1252{
1254 //qDebug("addAnni "); 1253 //qDebug("addAnni ");
1255 Event * ev = new Event(); 1254 Event * ev = new Event();
1256 if ( a ) { 1255 if ( a ) {
1257 ev->addAttendee( a ); 1256 ev->addAttendee( a );
1258 } 1257 }
1259 QString kind; 1258 QString kind;
1260 if ( birthday ) 1259 if ( birthday )
1261 kind = i18n( "Birthday" ); 1260 kind = i18n( "Birthday" );
1262 else 1261 else
1263 kind = i18n( "Anniversary" ); 1262 kind = i18n( "Anniversary" );
1264 ev->setSummary( name + " - " + kind ); 1263 ev->setSummary( name + " - " + kind );
1265 ev->setOrganizer( "nobody@nowhere" ); 1264 ev->setOrganizer( "nobody@nowhere" );
1266 ev->setCategories( kind ); 1265 ev->setCategories( kind );
1267 ev->setDtStart( QDateTime(date) ); 1266 ev->setDtStart( QDateTime(date) );
1268 ev->setDtEnd( QDateTime(date) ); 1267 ev->setDtEnd( QDateTime(date) );
1269 ev->setFloats( true ); 1268 ev->setFloats( true );
1270 Recurrence * rec = ev->recurrence(); 1269 Recurrence * rec = ev->recurrence();
1271 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1270 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1272 rec->addYearlyNum( date.month() ); 1271 rec->addYearlyNum( date.month() );
1273 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1272 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1274 delete ev; 1273 delete ev;
1275 return false; 1274 return false;
1276 } 1275 }
1277 return true; 1276 return true;
1278 1277
1279} 1278}
1280bool CalendarView::importQtopia( const QString &categories, 1279bool CalendarView::importQtopia( const QString &categories,
1281 const QString &datebook, 1280 const QString &datebook,
1282 const QString &todolist ) 1281 const QString &todolist )
1283{ 1282{
1284 1283
1285 QtopiaFormat qtopiaFormat; 1284 QtopiaFormat qtopiaFormat;
1286 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1285 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1287 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1286 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1288 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1287 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1289 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1288 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1290 1289
1291 updateView(); 1290 updateView();
1292 return true; 1291 return true;
1293 1292
1294#if 0 1293#if 0
1295 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1294 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1296 mCurrentSyncDevice = "qtopia-XML"; 1295 mCurrentSyncDevice = "qtopia-XML";
1297 if ( KOPrefs::instance()->mAskForPreferences ) 1296 if ( KOPrefs::instance()->mAskForPreferences )
1298 edit_sync_options(); 1297 edit_sync_options();
1299 qApp->processEvents(); 1298 qApp->processEvents();
1300 CalendarLocal* calendar = new CalendarLocal(); 1299 CalendarLocal* calendar = new CalendarLocal();
1301 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1300 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1302 bool syncOK = false; 1301 bool syncOK = false;
1303 QtopiaFormat qtopiaFormat; 1302 QtopiaFormat qtopiaFormat;
1304 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1303 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1305 bool loadOk = true; 1304 bool loadOk = true;
1306 if ( !categories.isEmpty() ) 1305 if ( !categories.isEmpty() )
1307 loadOk = qtopiaFormat.load( calendar, categories ); 1306 loadOk = qtopiaFormat.load( calendar, categories );
1308 if ( loadOk && !datebook.isEmpty() ) 1307 if ( loadOk && !datebook.isEmpty() )
1309 loadOk = qtopiaFormat.load( calendar, datebook ); 1308 loadOk = qtopiaFormat.load( calendar, datebook );
1310 if ( loadOk && !todolist.isEmpty() ) 1309 if ( loadOk && !todolist.isEmpty() )
1311 loadOk = qtopiaFormat.load( calendar, todolist ); 1310 loadOk = qtopiaFormat.load( calendar, todolist );
1312 1311
1313 if ( loadOk ) { 1312 if ( loadOk ) {
1314 getEventViewerDialog()->setSyncMode( true ); 1313 getEventViewerDialog()->setSyncMode( true );
1315 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); 1314 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
1316 getEventViewerDialog()->setSyncMode( false ); 1315 getEventViewerDialog()->setSyncMode( false );
1317 qApp->processEvents(); 1316 qApp->processEvents();
1318 if ( syncOK ) { 1317 if ( syncOK ) {
1319 if ( KOPrefs::instance()->mWriteBackFile ) 1318 if ( KOPrefs::instance()->mWriteBackFile )
1320 { 1319 {
1321 // write back XML file 1320 // write back XML file
1322 1321
1323 } 1322 }
1324 setModified( true ); 1323 setModified( true );
1325 } 1324 }
1326 } else { 1325 } else {
1327 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1326 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1328 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1327 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1329 question, i18n("Ok")) ; 1328 question, i18n("Ok")) ;
1330 } 1329 }
1331 delete calendar; 1330 delete calendar;
1332 updateView(); 1331 updateView();
1333 return syncOK; 1332 return syncOK;
1334 1333
1335 1334
1336#endif 1335#endif
1337 1336
1338} 1337}
1339 1338
1340void CalendarView::setSyncEventsReadOnly() 1339void CalendarView::setSyncEventsReadOnly()
1341{ 1340{
1342 Event * ev; 1341 Event * ev;
1343 QPtrList<Event> eL = mCalendar->rawEvents(); 1342 QPtrList<Event> eL = mCalendar->rawEvents();
1344 ev = eL.first(); 1343 ev = eL.first();
1345 while ( ev ) { 1344 while ( ev ) {
1346 if ( ev->uid().left(21) == QString("last-syncEvent-device") ) 1345 if ( ev->uid().left(21) == QString("last-syncEvent-device") )
1347 ev->setReadOnly( true ); 1346 ev->setReadOnly( true );
1348 ev = eL.next(); 1347 ev = eL.next();
1349 } 1348 }
1350} 1349}
1351bool CalendarView::openCalendar(QString filename, bool merge) 1350bool CalendarView::openCalendar(QString filename, bool merge)
1352{ 1351{
1353 1352
1354 if (filename.isEmpty()) { 1353 if (filename.isEmpty()) {
1355 return false; 1354 return false;
1356 } 1355 }
1357 1356
1358 if (!QFile::exists(filename)) { 1357 if (!QFile::exists(filename)) {
1359 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1358 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1360 return false; 1359 return false;
1361 } 1360 }
1362 1361
1363 globalFlagBlockAgenda = 1; 1362 globalFlagBlockAgenda = 1;
1364 if (!merge) mCalendar->close(); 1363 if (!merge) mCalendar->close();
1365 1364
1366 mStorage->setFileName( filename ); 1365 mStorage->setFileName( filename );
1367 1366
1368 if ( mStorage->load(KOPrefs::instance()->mUseQuicksave) ) { 1367 if ( mStorage->load(KOPrefs::instance()->mUseQuicksave) ) {
1369 if ( merge ) ;//setModified( true ); 1368 if ( merge ) ;//setModified( true );
1370 else { 1369 else {
1371 //setModified( true ); 1370 //setModified( true );
1372 mViewManager->setDocumentId( filename ); 1371 mViewManager->setDocumentId( filename );
1373 mDialogManager->setDocumentId( filename ); 1372 mDialogManager->setDocumentId( filename );
1374 mTodoList->setDocumentId( filename ); 1373 mTodoList->setDocumentId( filename );
1375 } 1374 }
1376 globalFlagBlockAgenda = 2; 1375 globalFlagBlockAgenda = 2;
1377 // if ( getLastSyncEvent() ) 1376 // if ( getLastSyncEvent() )
1378 // getLastSyncEvent()->setReadOnly( true ); 1377 // getLastSyncEvent()->setReadOnly( true );
1379 mCalendar->reInitAlarmSettings(); 1378 mCalendar->reInitAlarmSettings();
1380 setSyncEventsReadOnly(); 1379 setSyncEventsReadOnly();
1381 updateUnmanagedViews(); 1380 updateUnmanagedViews();
1382 updateView(); 1381 updateView();
1383 if ( filename != MainWindow::defaultFileName() ) 1382 if ( filename != MainWindow::defaultFileName() )
1384 saveCalendar( MainWindow::defaultFileName() ); 1383 saveCalendar( MainWindow::defaultFileName() );
1385 loadedFileVersion = QDateTime::currentDateTime(); 1384 loadedFileVersion = QDateTime::currentDateTime();
1386 return true; 1385 return true;
1387 } else { 1386 } else {
1388 // while failing to load, the calendar object could 1387 // while failing to load, the calendar object could
1389 // have become partially populated. Clear it out. 1388 // have become partially populated. Clear it out.
1390 if ( !merge ) mCalendar->close(); 1389 if ( !merge ) mCalendar->close();
1391 1390
1392 KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1391 KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1393 1392
1394 globalFlagBlockAgenda = 2; 1393 globalFlagBlockAgenda = 2;
1395 updateView(); 1394 updateView();
1396 } 1395 }
1397 return false; 1396 return false;
1398} 1397}
1399void CalendarView::setLoadedFileVersion(QDateTime dt) 1398void CalendarView::setLoadedFileVersion(QDateTime dt)
1400{ 1399{
1401 loadedFileVersion = dt; 1400 loadedFileVersion = dt;
1402} 1401}
1403bool CalendarView::checkFileChanged(QString fn) 1402bool CalendarView::checkFileChanged(QString fn)
1404{ 1403{
1405 QFileInfo finf ( fn ); 1404 QFileInfo finf ( fn );
1406 if ( !finf.exists() ) 1405 if ( !finf.exists() )
1407 return true; 1406 return true;
1408 QDateTime dt = finf.lastModified (); 1407 QDateTime dt = finf.lastModified ();
1409 if ( dt <= loadedFileVersion ) 1408 if ( dt <= loadedFileVersion )
1410 return false; 1409 return false;
1411 return true; 1410 return true;
1412 1411
1413} 1412}
1414bool CalendarView::checkFileVersion(QString fn) 1413bool CalendarView::checkFileVersion(QString fn)
1415{ 1414{
1416 QFileInfo finf ( fn ); 1415 QFileInfo finf ( fn );
1417 if ( !finf.exists() ) 1416 if ( !finf.exists() )
1418 return true; 1417 return true;
1419 QDateTime dt = finf.lastModified (); 1418 QDateTime dt = finf.lastModified ();
1420 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1419 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1421 //qDebug("file on disk version %s",dt.toString().latin1()); 1420 //qDebug("file on disk version %s",dt.toString().latin1());
1422 if ( dt <= loadedFileVersion ) 1421 if ( dt <= loadedFileVersion )
1423 return true; 1422 return true;
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)) , 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)) ,
1425 i18n("KO/Pi Warning"),i18n("Overwrite"), 1424 i18n("KO/Pi Warning"),i18n("Overwrite"),
1426 i18n("Sync+save")); 1425 i18n("Sync+save"));
1427 1426
1428 if ( km == KMessageBox::Cancel ) 1427 if ( km == KMessageBox::Cancel )
1429 return false; 1428 return false;
1430 if ( km == KMessageBox::Yes ) 1429 if ( km == KMessageBox::Yes )
1431 return true; 1430 return true;
1432 1431
1433 setSyncDevice("deleteaftersync" ); 1432 setSyncDevice("deleteaftersync" );
1434 KOPrefs::instance()->mAskForPreferences = true; 1433 KOPrefs::instance()->mAskForPreferences = true;
1435 KOPrefs::instance()->mSyncAlgoPrefs = 3; 1434 KOPrefs::instance()->mSyncAlgoPrefs = 3;
1436 KOPrefs::instance()->mWriteBackFile = false; 1435 KOPrefs::instance()->mWriteBackFile = false;
1437 KOPrefs::instance()->mWriteBackExistingOnly = false; 1436 KOPrefs::instance()->mWriteBackExistingOnly = false;
1438 KOPrefs::instance()->mShowSyncSummary = false; 1437 KOPrefs::instance()->mShowSyncSummary = false;
1439 syncCalendar( fn, 3 ); 1438 syncCalendar( fn, 3 );
1440 Event * e = getLastSyncEvent(); 1439 Event * e = getLastSyncEvent();
1441 mCalendar->deleteEvent ( e ); 1440 mCalendar->deleteEvent ( e );
1442 updateView(); 1441 updateView();
1443 return true; 1442 return true;
1444} 1443}
1445 1444
1446bool CalendarView::saveCalendar( QString filename ) 1445bool CalendarView::saveCalendar( QString filename )
1447{ 1446{
1448 1447
1449 // Store back all unsaved data into calendar object 1448 // Store back all unsaved data into calendar object
1450 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1449 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1451 if ( mViewManager->currentView() ) 1450 if ( mViewManager->currentView() )
1452 mViewManager->currentView()->flushView(); 1451 mViewManager->currentView()->flushView();
1453 1452
1454 //mStorage->setFileName( filename ); 1453 //mStorage->setFileName( filename );
1455 1454
1456 mStorage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 1455 mStorage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
1457 mStorage->setFileName( filename ); 1456 mStorage->setFileName( filename );
1458 bool success; 1457 bool success;
1459 success = mStorage->save(); 1458 success = mStorage->save();
1460 if ( !success ) { 1459 if ( !success ) {
1461 return false; 1460 return false;
1462 } 1461 }
1463 1462
1464 return true; 1463 return true;
1465} 1464}
1466 1465
1467void CalendarView::closeCalendar() 1466void CalendarView::closeCalendar()
1468{ 1467{
1469 1468
1470 // child windows no longer valid 1469 // child windows no longer valid
1471 emit closingDown(); 1470 emit closingDown();
1472 1471
1473 mCalendar->close(); 1472 mCalendar->close();
1474 setModified(false); 1473 setModified(false);
1475 updateView(); 1474 updateView();
1476} 1475}
1477 1476
1478void CalendarView::archiveCalendar() 1477void CalendarView::archiveCalendar()
1479{ 1478{
1480 mDialogManager->showArchiveDialog(); 1479 mDialogManager->showArchiveDialog();
1481} 1480}
1482 1481
1483 1482
1484void CalendarView::readSettings() 1483void CalendarView::readSettings()
1485{ 1484{
1486 1485
1487 1486
1488 // mViewManager->showAgendaView(); 1487 // mViewManager->showAgendaView();
1489 QString str; 1488 QString str;
1490 //qDebug("CalendarView::readSettings() "); 1489 //qDebug("CalendarView::readSettings() ");
1491 // read settings from the KConfig, supplying reasonable 1490 // read settings from the KConfig, supplying reasonable
1492 // defaults where none are to be found 1491 // defaults where none are to be found
1493 KConfig *config = KOGlobals::config(); 1492 KConfig *config = KOGlobals::config();
1494#ifndef KORG_NOSPLITTER 1493#ifndef KORG_NOSPLITTER
1495 config->setGroup("KOrganizer Geometry"); 1494 config->setGroup("KOrganizer Geometry");
1496 1495
1497 QValueList<int> sizes = config->readIntListEntry("Separator1"); 1496 QValueList<int> sizes = config->readIntListEntry("Separator1");
1498 if (sizes.count() != 2) { 1497 if (sizes.count() != 2) {
1499 sizes << mDateNavigator->minimumSizeHint().width(); 1498 sizes << mDateNavigator->minimumSizeHint().width();
1500 sizes << 300; 1499 sizes << 300;
1501 } 1500 }
1502 mPanner->setSizes(sizes); 1501 mPanner->setSizes(sizes);
1503 1502
1504 sizes = config->readIntListEntry("Separator2"); 1503 sizes = config->readIntListEntry("Separator2");
1505 if ( ( mResourceView && sizes.count() == 4 ) || 1504 if ( ( mResourceView && sizes.count() == 4 ) ||
1506 ( !mResourceView && sizes.count() == 3 ) ) { 1505 ( !mResourceView && sizes.count() == 3 ) ) {
1507 mLeftSplitter->setSizes(sizes); 1506 mLeftSplitter->setSizes(sizes);
1508 } 1507 }
1509#endif 1508#endif
1510 globalFlagBlockAgenda = 1; 1509 globalFlagBlockAgenda = 1;
1511 mViewManager->showAgendaView(); 1510 mViewManager->showAgendaView();
1512 //mViewManager->readSettings( config ); 1511 //mViewManager->readSettings( config );
1513 mTodoList->restoreLayout(config,QString("Todo Layout")); 1512 mTodoList->restoreLayout(config,QString("Todo Layout"));
1514 readFilterSettings(config); 1513 readFilterSettings(config);
1515 config->setGroup( "Views" ); 1514 config->setGroup( "Views" );
1516 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 1515 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
1517 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 1516 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
1518 else if ( dateCount == 7 ) mNavigator->selectWeek(); 1517 else if ( dateCount == 7 ) mNavigator->selectWeek();
1519 else mNavigator->selectDates( dateCount ); 1518 else mNavigator->selectDates( dateCount );
1520 // mViewManager->readSettings( config ); 1519 // mViewManager->readSettings( config );
1521 updateConfig(); 1520 updateConfig();
1522 globalFlagBlockAgenda = 2; 1521 globalFlagBlockAgenda = 2;
1523 mViewManager->readSettings( config ); 1522 mViewManager->readSettings( config );
1524#ifdef DESKTOP_VERSION 1523#ifdef DESKTOP_VERSION
1525 config->setGroup("WidgetLayout"); 1524 config->setGroup("WidgetLayout");
1526 QStringList list; 1525 QStringList list;
1527 list = config->readListEntry("MainLayout"); 1526 list = config->readListEntry("MainLayout");
1528 int x,y,w,h; 1527 int x,y,w,h;
1529 if ( ! list.isEmpty() ) { 1528 if ( ! list.isEmpty() ) {
1530 x = list[0].toInt(); 1529 x = list[0].toInt();
1531 y = list[1].toInt(); 1530 y = list[1].toInt();
1532 w = list[2].toInt(); 1531 w = list[2].toInt();
1533 h = list[3].toInt(); 1532 h = list[3].toInt();
1534 topLevelWidget()->setGeometry(x,y,w,h); 1533 topLevelWidget()->setGeometry(x,y,w,h);
1535 1534
1536 } else { 1535 } else {
1537 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 1536 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
1538 } 1537 }
1539 list = config->readListEntry("EditEventLayout"); 1538 list = config->readListEntry("EditEventLayout");
1540 if ( ! list.isEmpty() ) { 1539 if ( ! list.isEmpty() ) {
1541 x = list[0].toInt(); 1540 x = list[0].toInt();
1542 y = list[1].toInt(); 1541 y = list[1].toInt();
1543 w = list[2].toInt(); 1542 w = list[2].toInt();
1544 h = list[3].toInt(); 1543 h = list[3].toInt();
1545 mEventEditor->setGeometry(x,y,w,h); 1544 mEventEditor->setGeometry(x,y,w,h);
1546 1545
1547 } 1546 }
1548 list = config->readListEntry("EditTodoLayout"); 1547 list = config->readListEntry("EditTodoLayout");
1549 if ( ! list.isEmpty() ) { 1548 if ( ! list.isEmpty() ) {
1550 x = list[0].toInt(); 1549 x = list[0].toInt();
1551 y = list[1].toInt(); 1550 y = list[1].toInt();
1552 w = list[2].toInt(); 1551 w = list[2].toInt();
1553 h = list[3].toInt(); 1552 h = list[3].toInt();
1554 mTodoEditor->setGeometry(x,y,w,h); 1553 mTodoEditor->setGeometry(x,y,w,h);
1555 1554
1556 } 1555 }
1557 list = config->readListEntry("ViewerLayout"); 1556 list = config->readListEntry("ViewerLayout");
1558 if ( ! list.isEmpty() ) { 1557 if ( ! list.isEmpty() ) {
1559 x = list[0].toInt(); 1558 x = list[0].toInt();
1560 y = list[1].toInt(); 1559 y = list[1].toInt();
1561 w = list[2].toInt(); 1560 w = list[2].toInt();
1562 h = list[3].toInt(); 1561 h = list[3].toInt();
1563 getEventViewerDialog()->setGeometry(x,y,w,h); 1562 getEventViewerDialog()->setGeometry(x,y,w,h);
1564 } 1563 }
1565#endif 1564#endif
1566 1565
1567} 1566}
1568 1567
1569 1568
1570void CalendarView::writeSettings() 1569void CalendarView::writeSettings()
1571{ 1570{
1572 // kdDebug() << "CalendarView::writeSettings" << endl; 1571 // kdDebug() << "CalendarView::writeSettings" << endl;
1573 1572
1574 KConfig *config = KOGlobals::config(); 1573 KConfig *config = KOGlobals::config();
1575 1574
1576#ifndef KORG_NOSPLITTER 1575#ifndef KORG_NOSPLITTER
1577 config->setGroup("KOrganizer Geometry"); 1576 config->setGroup("KOrganizer Geometry");
1578 1577
1579 QValueList<int> list = mPanner->sizes(); 1578 QValueList<int> list = mPanner->sizes();
1580 config->writeEntry("Separator1",list); 1579 config->writeEntry("Separator1",list);
1581 1580
1582 list = mLeftSplitter->sizes(); 1581 list = mLeftSplitter->sizes();
1583 config->writeEntry("Separator2",list); 1582 config->writeEntry("Separator2",list);
1584#endif 1583#endif
1585 1584
1586 mViewManager->writeSettings( config ); 1585 mViewManager->writeSettings( config );
1587 mTodoList->saveLayout(config,QString("Todo Layout")); 1586 mTodoList->saveLayout(config,QString("Todo Layout"));
1588 mDialogManager->writeSettings( config ); 1587 mDialogManager->writeSettings( config );
1589 //KOPrefs::instance()->usrWriteConfig(); 1588 //KOPrefs::instance()->usrWriteConfig();
1590 KOPrefs::instance()->writeConfig(); 1589 KOPrefs::instance()->writeConfig();
1591 1590
1592 writeFilterSettings(config); 1591 writeFilterSettings(config);
1593 1592
1594 config->setGroup( "Views" ); 1593 config->setGroup( "Views" );
1595 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 1594 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
1596 1595
1597#ifdef DESKTOP_VERSION 1596#ifdef DESKTOP_VERSION
1598 config->setGroup("WidgetLayout"); 1597 config->setGroup("WidgetLayout");
1599 QStringList list ;//= config->readListEntry("MainLayout"); 1598 QStringList list ;//= config->readListEntry("MainLayout");
1600 int x,y,w,h; 1599 int x,y,w,h;
1601 QWidget* wid; 1600 QWidget* wid;
1602 wid = topLevelWidget(); 1601 wid = topLevelWidget();
1603 x = wid->geometry().x(); 1602 x = wid->geometry().x();
1604 y = wid->geometry().y(); 1603 y = wid->geometry().y();
1605 w = wid->width(); 1604 w = wid->width();
1606 h = wid->height(); 1605 h = wid->height();
1607 list.clear(); 1606 list.clear();
1608 list << QString::number( x ); 1607 list << QString::number( x );
1609 list << QString::number( y ); 1608 list << QString::number( y );
1610 list << QString::number( w ); 1609 list << QString::number( w );
1611 list << QString::number( h ); 1610 list << QString::number( h );
1612 config->writeEntry("MainLayout",list ); 1611 config->writeEntry("MainLayout",list );
1613 1612
1614 wid = mEventEditor; 1613 wid = mEventEditor;
1615 x = wid->geometry().x(); 1614 x = wid->geometry().x();
1616 y = wid->geometry().y(); 1615 y = wid->geometry().y();
1617 w = wid->width(); 1616 w = wid->width();
1618 h = wid->height(); 1617 h = wid->height();
1619 list.clear(); 1618 list.clear();
1620 list << QString::number( x ); 1619 list << QString::number( x );
1621 list << QString::number( y ); 1620 list << QString::number( y );
1622 list << QString::number( w ); 1621 list << QString::number( w );
1623 list << QString::number( h ); 1622 list << QString::number( h );
1624 config->writeEntry("EditEventLayout",list ); 1623 config->writeEntry("EditEventLayout",list );
1625 1624
1626 wid = mTodoEditor; 1625 wid = mTodoEditor;
1627 x = wid->geometry().x(); 1626 x = wid->geometry().x();
1628 y = wid->geometry().y(); 1627 y = wid->geometry().y();
1629 w = wid->width(); 1628 w = wid->width();
1630 h = wid->height(); 1629 h = wid->height();
1631 list.clear(); 1630 list.clear();
1632 list << QString::number( x ); 1631 list << QString::number( x );
1633 list << QString::number( y ); 1632 list << QString::number( y );
1634 list << QString::number( w ); 1633 list << QString::number( w );
1635 list << QString::number( h ); 1634 list << QString::number( h );
1636 config->writeEntry("EditTodoLayout",list ); 1635 config->writeEntry("EditTodoLayout",list );
1637 wid = getEventViewerDialog(); 1636 wid = getEventViewerDialog();
1638 x = wid->geometry().x(); 1637 x = wid->geometry().x();
1639 y = wid->geometry().y(); 1638 y = wid->geometry().y();
1640 w = wid->width(); 1639 w = wid->width();
1641 h = wid->height(); 1640 h = wid->height();
1642 list.clear(); 1641 list.clear();
1643 list << QString::number( x ); 1642 list << QString::number( x );
1644 list << QString::number( y ); 1643 list << QString::number( y );
1645 list << QString::number( w ); 1644 list << QString::number( w );
1646 list << QString::number( h ); 1645 list << QString::number( h );
1647 config->writeEntry("ViewerLayout",list ); 1646 config->writeEntry("ViewerLayout",list );
1648 wid = mDialogManager->getSearchDialog(); 1647 wid = mDialogManager->getSearchDialog();
1649 if ( wid ) { 1648 if ( wid ) {
1650 x = wid->geometry().x(); 1649 x = wid->geometry().x();
1651 y = wid->geometry().y(); 1650 y = wid->geometry().y();
1652 w = wid->width(); 1651 w = wid->width();
1653 h = wid->height(); 1652 h = wid->height();
1654 list.clear(); 1653 list.clear();
1655 list << QString::number( x ); 1654 list << QString::number( x );
1656 list << QString::number( y ); 1655 list << QString::number( y );
1657 list << QString::number( w ); 1656 list << QString::number( w );
1658 list << QString::number( h ); 1657 list << QString::number( h );
1659 config->writeEntry("SearchLayout",list ); 1658 config->writeEntry("SearchLayout",list );
1660 } 1659 }
1661#endif 1660#endif
1662 1661
1663 1662
1664 config->sync(); 1663 config->sync();
1665} 1664}
1666 1665
1667void CalendarView::readFilterSettings(KConfig *config) 1666void CalendarView::readFilterSettings(KConfig *config)
1668{ 1667{
1669 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 1668 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
1670 1669
1671 mFilters.clear(); 1670 mFilters.clear();
1672 1671
1673 config->setGroup("General"); 1672 config->setGroup("General");
1674 QStringList filterList = config->readListEntry("CalendarFilters"); 1673 QStringList filterList = config->readListEntry("CalendarFilters");
1675 1674
1676 QStringList::ConstIterator it = filterList.begin(); 1675 QStringList::ConstIterator it = filterList.begin();
1677 QStringList::ConstIterator end = filterList.end(); 1676 QStringList::ConstIterator end = filterList.end();
1678 while(it != end) { 1677 while(it != end) {
1679 // kdDebug() << " filter: " << (*it) << endl; 1678 // kdDebug() << " filter: " << (*it) << endl;
1680 1679
1681 CalFilter *filter; 1680 CalFilter *filter;
1682 filter = new CalFilter(*it); 1681 filter = new CalFilter(*it);
1683 config->setGroup("Filter_" + (*it)); 1682 config->setGroup("Filter_" + (*it));
1684 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 1683 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
1685 filter->setCriteria(config->readNumEntry("Criteria",0)); 1684 filter->setCriteria(config->readNumEntry("Criteria",0));
1686 filter->setCategoryList(config->readListEntry("CategoryList")); 1685 filter->setCategoryList(config->readListEntry("CategoryList"));
1687 mFilters.append(filter); 1686 mFilters.append(filter);
1688 1687
1689 ++it; 1688 ++it;
1690 } 1689 }
1691 1690
1692 if (mFilters.count() == 0) { 1691 if (mFilters.count() == 0) {
1693 CalFilter *filter = new CalFilter(i18n("Default")); 1692 CalFilter *filter = new CalFilter(i18n("Default"));
1694 mFilters.append(filter); 1693 mFilters.append(filter);
1695 } 1694 }
1696 mFilterView->updateFilters(); 1695 mFilterView->updateFilters();
1697 config->setGroup("FilterView"); 1696 config->setGroup("FilterView");
1698 1697
1699 mFilterView->blockSignals(true); 1698 mFilterView->blockSignals(true);
1700 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 1699 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
1701 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 1700 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
1702 mFilterView->blockSignals(false); 1701 mFilterView->blockSignals(false);
1703 // We do it manually to avoid it being done twice by the above calls 1702 // We do it manually to avoid it being done twice by the above calls
1704 updateFilter(); 1703 updateFilter();
1705} 1704}
1706 1705
1707void CalendarView::writeFilterSettings(KConfig *config) 1706void CalendarView::writeFilterSettings(KConfig *config)
1708{ 1707{
1709 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 1708 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
1710 1709
1711 QStringList filterList; 1710 QStringList filterList;
1712 1711
1713 CalFilter *filter = mFilters.first(); 1712 CalFilter *filter = mFilters.first();
1714 while(filter) { 1713 while(filter) {
1715 // kdDebug() << " fn: " << filter->name() << endl; 1714 // kdDebug() << " fn: " << filter->name() << endl;
1716 filterList << filter->name(); 1715 filterList << filter->name();
1717 config->setGroup("Filter_" + filter->name()); 1716 config->setGroup("Filter_" + filter->name());
1718 config->writeEntry("Criteria",filter->criteria()); 1717 config->writeEntry("Criteria",filter->criteria());
1719 config->writeEntry("CategoryList",filter->categoryList()); 1718 config->writeEntry("CategoryList",filter->categoryList());
1720 filter = mFilters.next(); 1719 filter = mFilters.next();
1721 } 1720 }
1722 config->setGroup("General"); 1721 config->setGroup("General");
1723 config->writeEntry("CalendarFilters",filterList); 1722 config->writeEntry("CalendarFilters",filterList);
1724 1723
1725 config->setGroup("FilterView"); 1724 config->setGroup("FilterView");
1726 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 1725 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
1727 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 1726 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
1728} 1727}
1729 1728
1730 1729
1731void CalendarView::goToday() 1730void CalendarView::goToday()
1732{ 1731{
1733 mNavigator->selectToday(); 1732 mNavigator->selectToday();
1734} 1733}
1735 1734
1736void CalendarView::goNext() 1735void CalendarView::goNext()
1737{ 1736{
1738 mNavigator->selectNext(); 1737 mNavigator->selectNext();
1739} 1738}
1740 1739
1741void CalendarView::goPrevious() 1740void CalendarView::goPrevious()
1742{ 1741{
1743 mNavigator->selectPrevious(); 1742 mNavigator->selectPrevious();
1744} 1743}
1745void CalendarView::goNextMonth() 1744void CalendarView::goNextMonth()
1746{ 1745{
1747 mNavigator->selectNextMonth(); 1746 mNavigator->selectNextMonth();
1748} 1747}
1749 1748
1750void CalendarView::goPreviousMonth() 1749void CalendarView::goPreviousMonth()
1751{ 1750{
1752 mNavigator->selectPreviousMonth(); 1751 mNavigator->selectPreviousMonth();
1753} 1752}
1754void CalendarView::writeLocale() 1753void CalendarView::writeLocale()
1755{ 1754{
1756 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); 1755 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime );
1757 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); 1756 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday );
1758 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); 1757 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate );
1759 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); 1758 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage );
1760 QString dummy = KOPrefs::instance()->mUserDateFormatLong; 1759 QString dummy = KOPrefs::instance()->mUserDateFormatLong;
1761 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 1760 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
1762 dummy = KOPrefs::instance()->mUserDateFormatShort; 1761 dummy = KOPrefs::instance()->mUserDateFormatShort;
1763 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 1762 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
1764 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, 1763 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving,
1765 KOPrefs::instance()->mDaylightsavingStart, 1764 KOPrefs::instance()->mDaylightsavingStart,
1766 KOPrefs::instance()->mDaylightsavingEnd ); 1765 KOPrefs::instance()->mDaylightsavingEnd );
1767 KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId ); 1766 KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId );
1768} 1767}
1769void CalendarView::updateConfig() 1768void CalendarView::updateConfig()
1770{ 1769{
1771 writeLocale(); 1770 writeLocale();
1772 if ( KOPrefs::instance()->mUseAppColors ) 1771 if ( KOPrefs::instance()->mUseAppColors )
1773 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 1772 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
1774 emit configChanged(); 1773 emit configChanged();
1775 mTodoList->updateConfig(); 1774 mTodoList->updateConfig();
1776 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 1775 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
1777 mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1776 mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1778 // To make the "fill window" configurations work 1777 // To make the "fill window" configurations work
1779 //mViewManager->raiseCurrentView(); 1778 //mViewManager->raiseCurrentView();
1780} 1779}
1781 1780
1782 1781
1783void CalendarView::eventChanged(Event *event) 1782void CalendarView::eventChanged(Event *event)
1784{ 1783{
1785 changeEventDisplay(event,KOGlobals::EVENTEDITED); 1784 changeEventDisplay(event,KOGlobals::EVENTEDITED);
1786 //updateUnmanagedViews(); 1785 //updateUnmanagedViews();
1787} 1786}
1788 1787
1789void CalendarView::eventAdded(Event *event) 1788void CalendarView::eventAdded(Event *event)
1790{ 1789{
1791 changeEventDisplay(event,KOGlobals::EVENTADDED); 1790 changeEventDisplay(event,KOGlobals::EVENTADDED);
1792} 1791}
1793 1792
1794void CalendarView::eventToBeDeleted(Event *) 1793void CalendarView::eventToBeDeleted(Event *)
1795{ 1794{
1796 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 1795 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
1797} 1796}
1798 1797
1799void CalendarView::eventDeleted() 1798void CalendarView::eventDeleted()
1800{ 1799{
1801 changeEventDisplay(0,KOGlobals::EVENTDELETED); 1800 changeEventDisplay(0,KOGlobals::EVENTDELETED);
1802} 1801}
1803void CalendarView::changeTodoDisplay(Todo *which, int action) 1802void CalendarView::changeTodoDisplay(Todo *which, int action)
1804{ 1803{
1805 changeIncidenceDisplay((Incidence *)which, action); 1804 changeIncidenceDisplay((Incidence *)which, action);
1806} 1805}
1807void CalendarView::checkZaurusId( int id, bool todo ) 1806void CalendarView::checkZaurusId( int id, bool todo )
1808{ 1807{
1809 if ( id >= 0 ) { 1808 if ( id >= 0 ) {
1810 Incidence* lse = mCalendar->event( "last-syncEvent-device-Sharp-DTM"); 1809 Incidence* lse = mCalendar->event( "last-syncEvent-device-Sharp-DTM");
1811 if ( lse ) { 1810 if ( lse ) {
1812 QString des = lse->description(); 1811 QString des = lse->description();
1813 QString pref = "e"; 1812 QString pref = "e";
1814 if ( todo ) 1813 if ( todo )
1815 pref = "t"; 1814 pref = "t";
1816 des += pref+ QString::number ( id ) + ","; 1815 des += pref+ QString::number ( id ) + ",";
1817 lse->setReadOnly( false ); 1816 lse->setReadOnly( false );
1818 lse->setDescription( des ); 1817 lse->setDescription( des );
1819 lse->setReadOnly( true ); 1818 lse->setReadOnly( true );
1820 } 1819 }
1821 } 1820 }
1822} 1821}
1823void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 1822void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
1824{ 1823{
1825 updateUnmanagedViews(); 1824 updateUnmanagedViews();
1826 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 1825 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
1827 if ( action == KOGlobals::EVENTDELETED ) { //delete 1826 if ( action == KOGlobals::EVENTDELETED ) { //delete
1828 mCalendar->checkAlarmForIncidence( 0, true ); 1827 mCalendar->checkAlarmForIncidence( 0, true );
1829 if ( mEventViewerDialog ) 1828 if ( mEventViewerDialog )
1830 mEventViewerDialog->hide(); 1829 mEventViewerDialog->hide();
1831 } 1830 }
1832 else 1831 else
1833 mCalendar->checkAlarmForIncidence( which , false ); 1832 mCalendar->checkAlarmForIncidence( which , false );
1834} 1833}
1835 1834
1836// most of the changeEventDisplays() right now just call the view's 1835// most of the changeEventDisplays() right now just call the view's
1837// total update mode, but they SHOULD be recoded to be more refresh-efficient. 1836// total update mode, but they SHOULD be recoded to be more refresh-efficient.
1838void CalendarView::changeEventDisplay(Event *which, int action) 1837void CalendarView::changeEventDisplay(Event *which, int action)
1839{ 1838{
1840 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 1839 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
1841 changeIncidenceDisplay((Incidence *)which, action); 1840 changeIncidenceDisplay((Incidence *)which, action);
1842 mDateNavigator->updateView(); 1841 mDateNavigator->updateView();
1843 //mDialogManager->updateSearchDialog(); 1842 //mDialogManager->updateSearchDialog();
1844 1843
1845 if (which) { 1844 if (which) {
1846 // If there is an event view visible update the display 1845 // If there is an event view visible update the display
1847 mViewManager->currentView()->changeEventDisplay(which,action); 1846 mViewManager->currentView()->changeEventDisplay(which,action);
1848 // TODO: check, if update needed 1847 // TODO: check, if update needed
1849 // if (which->getTodoStatus()) { 1848 // if (which->getTodoStatus()) {
1850 mTodoList->updateView(); 1849 mTodoList->updateView();
1851 // } 1850 // }
1852 } else { 1851 } else {
1853 mViewManager->currentView()->updateView(); 1852 mViewManager->currentView()->updateView();
1854 } 1853 }
1855} 1854}
1856 1855
1857 1856
1858void CalendarView::updateTodoViews() 1857void CalendarView::updateTodoViews()
1859{ 1858{
1860 1859
1861 mTodoList->updateView(); 1860 mTodoList->updateView();
1862 mViewManager->currentView()->updateView(); 1861 mViewManager->currentView()->updateView();
1863 1862
1864} 1863}
1865 1864
1866 1865
1867void CalendarView::updateView(const QDate &start, const QDate &end) 1866void CalendarView::updateView(const QDate &start, const QDate &end)
1868{ 1867{
1869 mTodoList->updateView(); 1868 mTodoList->updateView();
1870 mViewManager->updateView(start, end); 1869 mViewManager->updateView(start, end);
1871 //mDateNavigator->updateView(); 1870 //mDateNavigator->updateView();
1872} 1871}
1873 1872
1874void CalendarView::updateView() 1873void CalendarView::updateView()
1875{ 1874{
1876 DateList tmpList = mNavigator->selectedDates(); 1875 DateList tmpList = mNavigator->selectedDates();
1877 1876
1878 // We assume that the navigator only selects consecutive days. 1877 // We assume that the navigator only selects consecutive days.
1879 updateView( tmpList.first(), tmpList.last() ); 1878 updateView( tmpList.first(), tmpList.last() );
1880} 1879}
1881 1880
1882void CalendarView::updateUnmanagedViews() 1881void CalendarView::updateUnmanagedViews()
1883{ 1882{
1884 mDateNavigator->updateDayMatrix(); 1883 mDateNavigator->updateDayMatrix();
1885} 1884}
1886 1885
1887int CalendarView::msgItemDelete() 1886int CalendarView::msgItemDelete()
1888{ 1887{
1889 return KMessageBox::warningContinueCancel(this, 1888 return KMessageBox::warningContinueCancel(this,
1890 i18n("This item will be\npermanently deleted."), 1889 i18n("This item will be\npermanently deleted."),
1891 i18n("KO/Pi Confirmation"),i18n("Delete")); 1890 i18n("KO/Pi Confirmation"),i18n("Delete"));
1892} 1891}
1893 1892
1894 1893
1895void CalendarView::edit_cut() 1894void CalendarView::edit_cut()
1896{ 1895{
1897 Event *anEvent=0; 1896 Event *anEvent=0;
1898 1897
1899 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 1898 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
1900 1899
1901 if (mViewManager->currentView()->isEventView()) { 1900 if (mViewManager->currentView()->isEventView()) {
1902 if ( incidence && incidence->type() == "Event" ) { 1901 if ( incidence && incidence->type() == "Event" ) {
1903 anEvent = static_cast<Event *>(incidence); 1902 anEvent = static_cast<Event *>(incidence);
1904 } 1903 }
1905 } 1904 }
1906 1905
1907 if (!anEvent) { 1906 if (!anEvent) {
1908 KNotifyClient::beep(); 1907 KNotifyClient::beep();
1909 return; 1908 return;
1910 } 1909 }
1911 DndFactory factory( mCalendar ); 1910 DndFactory factory( mCalendar );
1912 factory.cutEvent(anEvent); 1911 factory.cutEvent(anEvent);
1913 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 1912 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
1914} 1913}
1915 1914
1916void CalendarView::edit_copy() 1915void CalendarView::edit_copy()
1917{ 1916{
1918 Event *anEvent=0; 1917 Event *anEvent=0;
1919 1918
1920 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 1919 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
1921 1920
1922 if (mViewManager->currentView()->isEventView()) { 1921 if (mViewManager->currentView()->isEventView()) {
1923 if ( incidence && incidence->type() == "Event" ) { 1922 if ( incidence && incidence->type() == "Event" ) {
1924 anEvent = static_cast<Event *>(incidence); 1923 anEvent = static_cast<Event *>(incidence);
1925 } 1924 }
1926 } 1925 }
1927 1926
1928 if (!anEvent) { 1927 if (!anEvent) {
1929 KNotifyClient::beep(); 1928 KNotifyClient::beep();
1930 return; 1929 return;
1931 } 1930 }
1932 DndFactory factory( mCalendar ); 1931 DndFactory factory( mCalendar );
1933 factory.copyEvent(anEvent); 1932 factory.copyEvent(anEvent);
1934} 1933}
1935 1934
1936void CalendarView::edit_paste() 1935void CalendarView::edit_paste()
1937{ 1936{
1938 QDate date = mNavigator->selectedDates().first(); 1937 QDate date = mNavigator->selectedDates().first();
1939 1938
1940 DndFactory factory( mCalendar ); 1939 DndFactory factory( mCalendar );
1941 Event *pastedEvent = factory.pasteEvent( date ); 1940 Event *pastedEvent = factory.pasteEvent( date );
1942 1941
1943 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 1942 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
1944} 1943}
1945 1944
1946void CalendarView::edit_options() 1945void CalendarView::edit_options()
1947{ 1946{
1948 mDialogManager->showOptionsDialog(); 1947 mDialogManager->showOptionsDialog();
1949 //writeSettings(); 1948 //writeSettings();
1950} 1949}
1951void CalendarView::edit_sync_options() 1950void CalendarView::edit_sync_options()
1952{ 1951{
1953 //mDialogManager->showSyncOptions(); 1952 //mDialogManager->showSyncOptions();
1954 //KOPrefs::instance()->mSyncAlgoPrefs 1953 //KOPrefs::instance()->mSyncAlgoPrefs
1955 QDialog dia( this, "dia", true ); 1954 QDialog dia( this, "dia", true );
1956 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); 1955 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice );
1957 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); 1956 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia);
1958 QVBoxLayout lay ( &dia ); 1957 QVBoxLayout lay ( &dia );
1959 lay.setSpacing( 2 ); 1958 lay.setSpacing( 2 );
1960 lay.setMargin( 3 ); 1959 lay.setMargin( 3 );
1961 lay.addWidget(&gr); 1960 lay.addWidget(&gr);
1962 QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); 1961 QRadioButton loc ( i18n("Take local entry on conflict"), &gr );
1963 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); 1962 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr );
1964 QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); 1963 QRadioButton newest( i18n("Take newest entry on conflict"), &gr );
1965 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); 1964 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr );
1966 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); 1965 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr );
1967 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); 1966 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr );
1968 //QRadioButton both( i18n("Take both on conflict"), &gr ); 1967 //QRadioButton both( i18n("Take both on conflict"), &gr );
1969 QPushButton pb ( "OK", &dia); 1968 QPushButton pb ( "OK", &dia);
1970 lay.addWidget( &pb ); 1969 lay.addWidget( &pb );
1971 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 1970 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
1972 switch ( KOPrefs::instance()->mSyncAlgoPrefs ) { 1971 switch ( KOPrefs::instance()->mSyncAlgoPrefs ) {
1973 case 0: 1972 case 0:
1974 loc.setChecked( true); 1973 loc.setChecked( true);
1975 break; 1974 break;
1976 case 1: 1975 case 1:
1977 rem.setChecked( true ); 1976 rem.setChecked( true );
1978 break; 1977 break;
1979 case 2: 1978 case 2:
1980 newest.setChecked( true); 1979 newest.setChecked( true);
1981 break; 1980 break;
1982 case 3: 1981 case 3:
1983 ask.setChecked( true); 1982 ask.setChecked( true);
1984 break; 1983 break;
1985 case 4: 1984 case 4:
1986 f_loc.setChecked( true); 1985 f_loc.setChecked( true);
1987 break; 1986 break;
1988 case 5: 1987 case 5:
1989 f_rem.setChecked( true); 1988 f_rem.setChecked( true);
1990 break; 1989 break;
1991 case 6: 1990 case 6:
1992 // both.setChecked( true); 1991 // both.setChecked( true);
1993 break; 1992 break;
1994 default: 1993 default:
1995 break; 1994 break;
1996 } 1995 }
1997 if ( dia.exec() ) { 1996 if ( dia.exec() ) {
1998 KOPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; 1997 KOPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ;
1999 } 1998 }
2000 1999
2001} 2000}
2002 2001
2003void CalendarView::slotSelectPickerDate( QDate d) 2002void CalendarView::slotSelectPickerDate( QDate d)
2004{ 2003{
2005 mDateFrame->hide(); 2004 mDateFrame->hide();
2006 if ( mDatePickerMode == 1 ) { 2005 if ( mDatePickerMode == 1 ) {
2007 mNavigator->slotDaySelect( d ); 2006 mNavigator->slotDaySelect( d );
2008 } else if ( mDatePickerMode == 2 ) { 2007 } else if ( mDatePickerMode == 2 ) {
2009 if ( mMoveIncidence->type() == "Todo" ) { 2008 if ( mMoveIncidence->type() == "Todo" ) {
2010 Todo * to = (Todo *) mMoveIncidence; 2009 Todo * to = (Todo *) mMoveIncidence;
2011 QTime tim; 2010 QTime tim;
2012 if ( to->hasDueDate() ) 2011 if ( to->hasDueDate() )
2013 tim = to->dtDue().time(); 2012 tim = to->dtDue().time();
2014 else { 2013 else {
2015 tim = QTime ( 0,0,0 ); 2014 tim = QTime ( 0,0,0 );
2016 to->setFloats( true ); 2015 to->setFloats( true );
2017 to->setHasDueDate( true ); 2016 to->setHasDueDate( true );
2018 } 2017 }
2019 QDateTime dt ( d,tim ); 2018 QDateTime dt ( d,tim );
2020 to->setDtDue( dt ); 2019 to->setDtDue( dt );
2021 todoChanged( to ); 2020 todoChanged( to );
2022 } else { 2021 } else {
2023 QTime tim = mMoveIncidence->dtStart().time(); 2022 QTime tim = mMoveIncidence->dtStart().time();
2024 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2023 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2025 QDateTime dt ( d,tim ); 2024 QDateTime dt ( d,tim );
2026 mMoveIncidence->setDtStart( dt ); 2025 mMoveIncidence->setDtStart( dt );
2027 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2026 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2028 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2027 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2029 } 2028 }
2030 2029
2031 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2030 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2032 } 2031 }
2033} 2032}
2034 2033
2035void CalendarView::removeCategories() 2034void CalendarView::removeCategories()
2036{ 2035{
2037 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2036 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2038 QStringList catList = KOPrefs::instance()->mCustomCategories; 2037 QStringList catList = KOPrefs::instance()->mCustomCategories;
2039 QStringList catIncList; 2038 QStringList catIncList;
2040 QStringList newCatList; 2039 QStringList newCatList;
2041 Incidence* inc = incList.first(); 2040 Incidence* inc = incList.first();
2042 int i; 2041 int i;
2043 int count = 0; 2042 int count = 0;
2044 while ( inc ) { 2043 while ( inc ) {
2045 newCatList.clear(); 2044 newCatList.clear();
2046 catIncList = inc->categories() ; 2045 catIncList = inc->categories() ;
2047 for( i = 0; i< catIncList.count(); ++i ) { 2046 for( i = 0; i< catIncList.count(); ++i ) {
2048 if ( catList.contains (catIncList[i])) 2047 if ( catList.contains (catIncList[i]))
2049 newCatList.append( catIncList[i] ); 2048 newCatList.append( catIncList[i] );
2050 } 2049 }
2051 newCatList.sort(); 2050 newCatList.sort();
2052 inc->setCategories( newCatList.join(",") ); 2051 inc->setCategories( newCatList.join(",") );
2053 inc = incList.next(); 2052 inc = incList.next();
2054 } 2053 }
2055} 2054}
2056 2055
2057int CalendarView::addCategories() 2056int CalendarView::addCategories()
2058{ 2057{
2059 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2058 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2060 QStringList catList = KOPrefs::instance()->mCustomCategories; 2059 QStringList catList = KOPrefs::instance()->mCustomCategories;
2061 QStringList catIncList; 2060 QStringList catIncList;
2062 Incidence* inc = incList.first(); 2061 Incidence* inc = incList.first();
2063 int i; 2062 int i;
2064 int count = 0; 2063 int count = 0;
2065 while ( inc ) { 2064 while ( inc ) {
2066 catIncList = inc->categories() ; 2065 catIncList = inc->categories() ;
2067 for( i = 0; i< catIncList.count(); ++i ) { 2066 for( i = 0; i< catIncList.count(); ++i ) {
2068 if ( !catList.contains (catIncList[i])) { 2067 if ( !catList.contains (catIncList[i])) {
2069 catList.append( catIncList[i] ); 2068 catList.append( catIncList[i] );
2070 //qDebug("add cat %s ", catIncList[i].latin1()); 2069 //qDebug("add cat %s ", catIncList[i].latin1());
2071 ++count; 2070 ++count;
2072 } 2071 }
2073 } 2072 }
2074 inc = incList.next(); 2073 inc = incList.next();
2075 } 2074 }
2076 catList.sort(); 2075 catList.sort();
2077 KOPrefs::instance()->mCustomCategories = catList; 2076 KOPrefs::instance()->mCustomCategories = catList;
2078 return count; 2077 return count;
2079} 2078}
2080 2079
2081void CalendarView::manageCategories() 2080void CalendarView::manageCategories()
2082{ 2081{
2083 KOCatPrefs* cp = new KOCatPrefs(); 2082 KOCatPrefs* cp = new KOCatPrefs();
2084 cp->show(); 2083 cp->show();
2085 int w =cp->sizeHint().width() ; 2084 int w =cp->sizeHint().width() ;
2086 int h = cp->sizeHint().height() ; 2085 int h = cp->sizeHint().height() ;
2087 int dw = QApplication::desktop()->width(); 2086 int dw = QApplication::desktop()->width();
2088 int dh = QApplication::desktop()->height(); 2087 int dh = QApplication::desktop()->height();
2089 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2088 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2090 if ( !cp->exec() ) { 2089 if ( !cp->exec() ) {
2091 delete cp; 2090 delete cp;
2092 return; 2091 return;
2093 } 2092 }
2094 int count = 0; 2093 int count = 0;
2095 if ( cp->addCat() ) { 2094 if ( cp->addCat() ) {
2096 count = addCategories(); 2095 count = addCategories();
2097 if ( count ) { 2096 if ( count ) {
2098 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2097 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2099 writeSettings(); 2098 writeSettings();
2100 } 2099 }
2101 } else { 2100 } else {
2102 removeCategories(); 2101 removeCategories();
2103 updateView(); 2102 updateView();
2104 } 2103 }
2105 delete cp; 2104 delete cp;
2106} 2105}
2107 2106
2108void CalendarView::beamIncidence(Incidence * Inc) 2107void CalendarView::beamIncidence(Incidence * Inc)
2109{ 2108{
2110 QPtrList<Incidence> delSel ; 2109 QPtrList<Incidence> delSel ;
2111 delSel.append(Inc); 2110 delSel.append(Inc);
2112 beamIncidenceList( delSel ); 2111 beamIncidenceList( delSel );
2113} 2112}
2114void CalendarView::beamCalendar() 2113void CalendarView::beamCalendar()
2115{ 2114{
2116 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2115 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2117 //qDebug("beamCalendar() "); 2116 //qDebug("beamCalendar() ");
2118 beamIncidenceList( delSel ); 2117 beamIncidenceList( delSel );
2119} 2118}
2120void CalendarView::beamFilteredCalendar() 2119void CalendarView::beamFilteredCalendar()
2121{ 2120{
2122 QPtrList<Incidence> delSel = mCalendar->incidences(); 2121 QPtrList<Incidence> delSel = mCalendar->incidences();
2123 //qDebug("beamFilteredCalendar() "); 2122 //qDebug("beamFilteredCalendar() ");
2124 beamIncidenceList( delSel ); 2123 beamIncidenceList( delSel );
2125} 2124}
2126void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2125void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2127{ 2126{
2128 if ( beamDialog->exec () == QDialog::Rejected ) 2127 if ( beamDialog->exec () == QDialog::Rejected )
2129 return; 2128 return;
2130 2129
2131 QString fn = "/tmp/kopibeamfile"; 2130 QString fn = "/tmp/kopibeamfile";
2132 QString mes; 2131 QString mes;
2133 bool createbup = true; 2132 bool createbup = true;
2134 if ( createbup ) { 2133 if ( createbup ) {
2135 QString description = "\n"; 2134 QString description = "\n";
2136 CalendarLocal* cal = new CalendarLocal(); 2135 CalendarLocal* cal = new CalendarLocal();
2137 if ( beamDialog->beamLocal() ) 2136 if ( beamDialog->beamLocal() )
2138 cal->setLocalTime(); 2137 cal->setLocalTime();
2139 else 2138 else
2140 cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 2139 cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
2141 Incidence *incidence = delSel.first(); 2140 Incidence *incidence = delSel.first();
2142 bool addText = false; 2141 bool addText = false;
2143 if ( delSel.count() < 10 ) 2142 if ( delSel.count() < 10 )
2144 addText = true; 2143 addText = true;
2145 else { 2144 else {
2146 description.sprintf(i18n(" %d items?"),delSel.count() ); 2145 description.sprintf(i18n(" %d items?"),delSel.count() );
2147 } 2146 }
2148 while ( incidence ) { 2147 while ( incidence ) {
2149 Incidence *in = incidence->clone(); 2148 Incidence *in = incidence->clone();
2150 if ( addText ) 2149 if ( addText )
2151 description += in->summary() + "\n"; 2150 description += in->summary() + "\n";
2152 cal->addIncidence( in ); 2151 cal->addIncidence( in );
2153 incidence = delSel.next(); 2152 incidence = delSel.next();
2154 } 2153 }
2155 if ( beamDialog->beamVcal() ) { 2154 if ( beamDialog->beamVcal() ) {
2156 fn += ".vcs"; 2155 fn += ".vcs";
2157 FileStorage storage( cal, fn, new VCalFormat ); 2156 FileStorage storage( cal, fn, new VCalFormat );
2158 storage.save(); 2157 storage.save();
2159 } else { 2158 } else {
2160 fn += ".ics"; 2159 fn += ".ics";
2161 FileStorage storage( cal, fn, new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 2160 FileStorage storage( cal, fn, new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
2162 storage.save(); 2161 storage.save();
2163 } 2162 }
2164 delete cal; 2163 delete cal;
2165 mes = i18n("KO/Pi: Ready for beaming"); 2164 mes = i18n("KO/Pi: Ready for beaming");
2166 setCaption(mes); 2165 setCaption(mes);
2167 2166
2168#ifndef DESKTOP_VERSION 2167#ifndef DESKTOP_VERSION
2169 Ir *ir = new Ir( this ); 2168 Ir *ir = new Ir( this );
2170 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 2169 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2171 ir->send( fn, description, "text/x-vCalendar" ); 2170 ir->send( fn, description, "text/x-vCalendar" );
2172#endif 2171#endif
2173 } 2172 }
2174} 2173}
2175void CalendarView::beamDone( Ir *ir ) 2174void CalendarView::beamDone( Ir *ir )
2176{ 2175{
2177#ifndef DESKTOP_VERSION 2176#ifndef DESKTOP_VERSION
2178 delete ir; 2177 delete ir;
2179#endif 2178#endif
2180} 2179}
2181 2180
2182void CalendarView::moveIncidence(Incidence * inc ) 2181void CalendarView::moveIncidence(Incidence * inc )
2183{ 2182{
2184 if ( !inc ) return; 2183 if ( !inc ) return;
2185 // qDebug("showDatePickerForIncidence( ) "); 2184 // qDebug("showDatePickerForIncidence( ) ");
2186 if ( mDateFrame->isVisible() ) 2185 if ( mDateFrame->isVisible() )
2187 mDateFrame->hide(); 2186 mDateFrame->hide();
2188 else { 2187 else {
2189 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; 2188 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ;
2190 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; 2189 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ;
2191 int dw = QApplication::desktop()->width(); 2190 int dw = QApplication::desktop()->width();
2192 int dh = QApplication::desktop()->height(); 2191 int dh = QApplication::desktop()->height();
2193 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2192 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2194 mDateFrame->show(); 2193 mDateFrame->show();
2195 } 2194 }
2196 mDatePickerMode = 2; 2195 mDatePickerMode = 2;
2197 mMoveIncidence = inc ; 2196 mMoveIncidence = inc ;
2198 QDate da; 2197 QDate da;
2199 if ( mMoveIncidence->type() == "Todo" ) { 2198 if ( mMoveIncidence->type() == "Todo" ) {
2200 Todo * to = (Todo *) mMoveIncidence; 2199 Todo * to = (Todo *) mMoveIncidence;
2201 if ( to->hasDueDate() ) 2200 if ( to->hasDueDate() )
2202 da = to->dtDue().date(); 2201 da = to->dtDue().date();
2203 else 2202 else
2204 da = QDate::currentDate(); 2203 da = QDate::currentDate();
2205 } else { 2204 } else {
2206 da = mMoveIncidence->dtStart().date(); 2205 da = mMoveIncidence->dtStart().date();
2207 } 2206 }
2208 mDatePicker->setDate( da ); 2207 mDatePicker->setDate( da );
2209} 2208}
2210void CalendarView::showDatePicker( ) 2209void CalendarView::showDatePicker( )
2211{ 2210{
2212 //qDebug("CalendarView::showDatePicker( ) "); 2211 //qDebug("CalendarView::showDatePicker( ) ");
2213 if ( mDateFrame->isVisible() ) 2212 if ( mDateFrame->isVisible() )
2214 mDateFrame->hide(); 2213 mDateFrame->hide();
2215 else { 2214 else {
2216 int w =mDatePicker->sizeHint().width() ; 2215 int w =mDatePicker->sizeHint().width() ;
2217 int h = mDatePicker->sizeHint().height() ; 2216 int h = mDatePicker->sizeHint().height() ;
2218 int dw = QApplication::desktop()->width(); 2217 int dw = QApplication::desktop()->width();
2219 int dh = QApplication::desktop()->height(); 2218 int dh = QApplication::desktop()->height();
2220 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2219 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2221 mDateFrame->show(); 2220 mDateFrame->show();
2222 } 2221 }
2223 mDatePickerMode = 1; 2222 mDatePickerMode = 1;
2224 mDatePicker->setDate( mNavigator->selectedDates().first() ); 2223 mDatePicker->setDate( mNavigator->selectedDates().first() );
2225} 2224}
2226 2225
2227void CalendarView::showEventEditor() 2226void CalendarView::showEventEditor()
2228{ 2227{
2229#ifdef DESKTOP_VERSION 2228#ifdef DESKTOP_VERSION
2230 mEventEditor->show(); 2229 mEventEditor->show();
2231#else 2230#else
2232 mEventEditor->showMaximized(); 2231 mEventEditor->showMaximized();
2233#endif 2232#endif
2234} 2233}
2235void CalendarView::showTodoEditor() 2234void CalendarView::showTodoEditor()
2236{ 2235{
2237#ifdef DESKTOP_VERSION 2236#ifdef DESKTOP_VERSION
2238 mTodoEditor->show(); 2237 mTodoEditor->show();
2239#else 2238#else
2240 mTodoEditor->showMaximized(); 2239 mTodoEditor->showMaximized();
2241#endif 2240#endif
2242} 2241}
2243void CalendarView::cancelIncidence(Incidence * inc ) 2242void CalendarView::cancelIncidence(Incidence * inc )
2244{ 2243{
2245 inc->setCancelled( ! inc->cancelled() ); 2244 inc->setCancelled( ! inc->cancelled() );
2246 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 2245 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
2247 updateView(); 2246 updateView();
2248} 2247}
2249void CalendarView::cloneIncidence(Incidence * orgInc ) 2248void CalendarView::cloneIncidence(Incidence * orgInc )
2250{ 2249{
2251 Incidence * newInc = orgInc->clone(); 2250 Incidence * newInc = orgInc->clone();
2252 newInc->recreate(); 2251 newInc->recreate();
2253 2252
2254 if ( newInc->type() == "Todo" ) { 2253 if ( newInc->type() == "Todo" ) {
2255 Todo* t = (Todo*) newInc; 2254 Todo* t = (Todo*) newInc;
2256 mTodoEditor->editTodo( t ); 2255 mTodoEditor->editTodo( t );
2257 showTodoEditor(); 2256 showTodoEditor();
2258 if ( mTodoEditor->exec() ) { 2257 if ( mTodoEditor->exec() ) {
2259 mCalendar->addTodo( t ); 2258 mCalendar->addTodo( t );
2260 updateView(); 2259 updateView();
2261 } else { 2260 } else {
2262 delete t; 2261 delete t;
2263 } 2262 }
2264 } 2263 }
2265 else { 2264 else {
2266 Event* e = (Event*) newInc; 2265 Event* e = (Event*) newInc;
2267 mEventEditor->editEvent( e ); 2266 mEventEditor->editEvent( e );
2268 showEventEditor(); 2267 showEventEditor();
2269 if ( mEventEditor->exec() ) { 2268 if ( mEventEditor->exec() ) {
2270 mCalendar->addEvent( e ); 2269 mCalendar->addEvent( e );
2271 updateView(); 2270 updateView();
2272 } else { 2271 } else {
2273 delete e; 2272 delete e;
2274 } 2273 }
2275 } 2274 }
2276} 2275}
2277 2276
2278void CalendarView::newEvent() 2277void CalendarView::newEvent()
2279{ 2278{
2280 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 2279 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
2281 KOAgendaView *aView = mViewManager->agendaView(); 2280 KOAgendaView *aView = mViewManager->agendaView();
2282 if (aView) { 2281 if (aView) {
2283 if (aView->selectionStart().isValid()) { 2282 if (aView->selectionStart().isValid()) {
2284 if (aView->selectedIsAllDay()) { 2283 if (aView->selectedIsAllDay()) {
2285 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 2284 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
2286 } else { 2285 } else {
2287 newEvent(aView->selectionStart(),aView->selectionEnd()); 2286 newEvent(aView->selectionStart(),aView->selectionEnd());
2288 } 2287 }
2289 return; 2288 return;
2290 } 2289 }
2291 } 2290 }
2292 2291
2293 QDate date = mNavigator->selectedDates().first(); 2292 QDate date = mNavigator->selectedDates().first();
2294 QDateTime current = QDateTime::currentDateTime(); 2293 QDateTime current = QDateTime::currentDateTime();
2295 if ( date <= current.date() ) { 2294 if ( date <= current.date() ) {
2296 int hour = current.time().hour() +1; 2295 int hour = current.time().hour() +1;
2297 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 2296 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
2298 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2297 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2299 } else 2298 } else
2300 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 2299 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
2301 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 2300 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
2302 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2301 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2303} 2302}
2304 2303
2305void CalendarView::newEvent(QDateTime fh) 2304void CalendarView::newEvent(QDateTime fh)
2306{ 2305{
2307 newEvent(fh, 2306 newEvent(fh,
2308 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 2307 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
2309} 2308}
2310 2309
2311void CalendarView::newEvent(QDate dt) 2310void CalendarView::newEvent(QDate dt)
2312{ 2311{
2313 newEvent(QDateTime(dt, QTime(0,0,0)), 2312 newEvent(QDateTime(dt, QTime(0,0,0)),
2314 QDateTime(dt, QTime(0,0,0)), true); 2313 QDateTime(dt, QTime(0,0,0)), true);
2315} 2314}
2316 2315
2317void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 2316void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
2318{ 2317{
2319 2318
2320 mEventEditor->newEvent(fromHint,toHint,allDay); 2319 mEventEditor->newEvent(fromHint,toHint,allDay);
2321 if ( mFilterView->filtersEnabled() ) { 2320 if ( mFilterView->filtersEnabled() ) {
2322 CalFilter *filter = mFilterView->selectedFilter(); 2321 CalFilter *filter = mFilterView->selectedFilter();
2323 if (filter && filter->showCategories()) { 2322 if (filter && filter->showCategories()) {
2324 mEventEditor->setCategories(filter->categoryList().join(",") ); 2323 mEventEditor->setCategories(filter->categoryList().join(",") );
2325 } 2324 }
2326 if ( filter ) 2325 if ( filter )
2327 mEventEditor->setSecrecy( filter->getSecrecy() ); 2326 mEventEditor->setSecrecy( filter->getSecrecy() );
2328 } 2327 }
2329 showEventEditor(); 2328 showEventEditor();
2330} 2329}
2331void CalendarView::todoAdded(Todo * t) 2330void CalendarView::todoAdded(Todo * t)
2332{ 2331{
2333 2332
2334 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 2333 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
2335 updateTodoViews(); 2334 updateTodoViews();
2336} 2335}
2337void CalendarView::todoChanged(Todo * t) 2336void CalendarView::todoChanged(Todo * t)
2338{ 2337{
2339 emit todoModified( t, 4 ); 2338 emit todoModified( t, 4 );
2340 // updateTodoViews(); 2339 // updateTodoViews();
2341} 2340}
2342void CalendarView::todoToBeDeleted(Todo *) 2341void CalendarView::todoToBeDeleted(Todo *)
2343{ 2342{
2344 //qDebug("todoToBeDeleted(Todo *) "); 2343 //qDebug("todoToBeDeleted(Todo *) ");
2345 updateTodoViews(); 2344 updateTodoViews();
2346} 2345}
2347void CalendarView::todoDeleted() 2346void CalendarView::todoDeleted()
2348{ 2347{
2349 //qDebug(" todoDeleted()"); 2348 //qDebug(" todoDeleted()");
2350 updateTodoViews(); 2349 updateTodoViews();
2351} 2350}
2352 2351
2353 2352
2354 2353
2355void CalendarView::newTodo() 2354void CalendarView::newTodo()
2356{ 2355{
2357 2356
2358 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); 2357 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true);
2359 if ( mFilterView->filtersEnabled() ) { 2358 if ( mFilterView->filtersEnabled() ) {
2360 CalFilter *filter = mFilterView->selectedFilter(); 2359 CalFilter *filter = mFilterView->selectedFilter();
2361 if (filter && filter->showCategories()) { 2360 if (filter && filter->showCategories()) {
2362 mTodoEditor->setCategories(filter->categoryList().join(",") ); 2361 mTodoEditor->setCategories(filter->categoryList().join(",") );
2363 } 2362 }
2364 if ( filter ) 2363 if ( filter )
2365 mTodoEditor->setSecrecy( filter->getSecrecy() ); 2364 mTodoEditor->setSecrecy( filter->getSecrecy() );
2366 } 2365 }
2367 showTodoEditor(); 2366 showTodoEditor();
2368} 2367}
2369 2368
2370void CalendarView::newSubTodo() 2369void CalendarView::newSubTodo()
2371{ 2370{
2372 Todo *todo = selectedTodo(); 2371 Todo *todo = selectedTodo();
2373 if ( todo ) newSubTodo( todo ); 2372 if ( todo ) newSubTodo( todo );
2374} 2373}
2375 2374
2376void CalendarView::newSubTodo(Todo *parentEvent) 2375void CalendarView::newSubTodo(Todo *parentEvent)
2377{ 2376{
2378 2377
2379 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); 2378 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true);
2380 showTodoEditor(); 2379 showTodoEditor();
2381} 2380}
2382 2381
2383void CalendarView::newFloatingEvent() 2382void CalendarView::newFloatingEvent()
2384{ 2383{
2385 DateList tmpList = mNavigator->selectedDates(); 2384 DateList tmpList = mNavigator->selectedDates();
2386 QDate date = tmpList.first(); 2385 QDate date = tmpList.first();
2387 2386
2388 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 2387 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
2389 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 2388 QDateTime( date, QTime( 12, 0, 0 ) ), true );
2390} 2389}
2391 2390
2392 2391
2393void CalendarView::editEvent( Event *event ) 2392void CalendarView::editEvent( Event *event )
2394{ 2393{
2395 2394
2396 if ( !event ) return; 2395 if ( !event ) return;
2397 if ( event->isReadOnly() ) { 2396 if ( event->isReadOnly() ) {
2398 showEvent( event ); 2397 showEvent( event );
2399 return; 2398 return;
2400 } 2399 }
2401 mEventEditor->editEvent( event , mFlagEditDescription); 2400 mEventEditor->editEvent( event , mFlagEditDescription);
2402 showEventEditor(); 2401 showEventEditor();
2403} 2402}
2404void CalendarView::editJournal( Journal *jour ) 2403void CalendarView::editJournal( Journal *jour )
2405{ 2404{
2406 if ( !jour ) return; 2405 if ( !jour ) return;
2407 mDialogManager->hideSearchDialog(); 2406 mDialogManager->hideSearchDialog();
2408 mViewManager->showJournalView(); 2407 mViewManager->showJournalView();
2409 mNavigator->slotDaySelect( jour->dtStart().date() ); 2408 mNavigator->slotDaySelect( jour->dtStart().date() );
2410} 2409}
2411void CalendarView::editTodo( Todo *todo ) 2410void CalendarView::editTodo( Todo *todo )
2412{ 2411{
2413 if ( !todo ) return; 2412 if ( !todo ) return;
2414 2413
2415 if ( todo->isReadOnly() ) { 2414 if ( todo->isReadOnly() ) {
2416 showTodo( todo ); 2415 showTodo( todo );
2417 return; 2416 return;
2418 } 2417 }
2419 mTodoEditor->editTodo( todo ,mFlagEditDescription); 2418 mTodoEditor->editTodo( todo ,mFlagEditDescription);
2420 showTodoEditor(); 2419 showTodoEditor();
2421 2420
2422} 2421}
2423 2422
2424KOEventViewerDialog* CalendarView::getEventViewerDialog() 2423KOEventViewerDialog* CalendarView::getEventViewerDialog()
2425{ 2424{
2426 if ( !mEventViewerDialog ) { 2425 if ( !mEventViewerDialog ) {
2427 mEventViewerDialog = new KOEventViewerDialog(this); 2426 mEventViewerDialog = new KOEventViewerDialog(this);
2428 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 2427 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
2429 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 2428 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
2430 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 2429 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
2431 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 2430 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
2432 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 2431 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
2433 viewManager(), SLOT( showAgendaView( bool ) ) ); 2432 viewManager(), SLOT( showAgendaView( bool ) ) );
2434 mEventViewerDialog->resize( 640, 480 ); 2433 mEventViewerDialog->resize( 640, 480 );
2435 2434
2436 } 2435 }
2437 return mEventViewerDialog; 2436 return mEventViewerDialog;
2438} 2437}
2439void CalendarView::showEvent(Event *event) 2438void CalendarView::showEvent(Event *event)
2440{ 2439{
2441 getEventViewerDialog()->setEvent(event); 2440 getEventViewerDialog()->setEvent(event);
2442 getEventViewerDialog()->showMe(); 2441 getEventViewerDialog()->showMe();
2443} 2442}
2444 2443
2445void CalendarView::showTodo(Todo *event) 2444void CalendarView::showTodo(Todo *event)
2446{ 2445{
2447 getEventViewerDialog()->setTodo(event); 2446 getEventViewerDialog()->setTodo(event);
2448 getEventViewerDialog()->showMe(); 2447 getEventViewerDialog()->showMe();
2449} 2448}
2450void CalendarView::showJournal( Journal *jour ) 2449void CalendarView::showJournal( Journal *jour )
2451{ 2450{
2452 getEventViewerDialog()->setJournal(jour); 2451 getEventViewerDialog()->setJournal(jour);
2453 getEventViewerDialog()->showMe(); 2452 getEventViewerDialog()->showMe();
2454 2453
2455} 2454}
2456// void CalendarView::todoModified (Todo *event, int changed) 2455// void CalendarView::todoModified (Todo *event, int changed)
2457// { 2456// {
2458// // if (mDialogList.find (event) != mDialogList.end ()) { 2457// // if (mDialogList.find (event) != mDialogList.end ()) {
2459// // kdDebug() << "Todo modified and open" << endl; 2458// // kdDebug() << "Todo modified and open" << endl;
2460// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 2459// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
2461// // temp->modified (changed); 2460// // temp->modified (changed);
2462 2461
2463// // } 2462// // }
2464 2463
2465// mViewManager->updateView(); 2464// mViewManager->updateView();
2466// } 2465// }
2467 2466
2468void CalendarView::appointment_show() 2467void CalendarView::appointment_show()
2469{ 2468{
2470 Event *anEvent = 0; 2469 Event *anEvent = 0;
2471 2470
2472 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2471 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2473 2472
2474 if (mViewManager->currentView()->isEventView()) { 2473 if (mViewManager->currentView()->isEventView()) {
2475 if ( incidence && incidence->type() == "Event" ) { 2474 if ( incidence && incidence->type() == "Event" ) {
2476 anEvent = static_cast<Event *>(incidence); 2475 anEvent = static_cast<Event *>(incidence);
2477 } 2476 }
2478 } 2477 }
2479 2478
2480 if (!anEvent) { 2479 if (!anEvent) {
2481 KNotifyClient::beep(); 2480 KNotifyClient::beep();
2482 return; 2481 return;
2483 } 2482 }
2484 2483
2485 showEvent(anEvent); 2484 showEvent(anEvent);
2486} 2485}
2487 2486
2488void CalendarView::appointment_edit() 2487void CalendarView::appointment_edit()
2489{ 2488{
2490 Event *anEvent = 0; 2489 Event *anEvent = 0;
2491 2490
2492 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2491 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2493 2492
2494 if (mViewManager->currentView()->isEventView()) { 2493 if (mViewManager->currentView()->isEventView()) {
2495 if ( incidence && incidence->type() == "Event" ) { 2494 if ( incidence && incidence->type() == "Event" ) {
2496 anEvent = static_cast<Event *>(incidence); 2495 anEvent = static_cast<Event *>(incidence);
2497 } 2496 }
2498 } 2497 }
2499 2498
2500 if (!anEvent) { 2499 if (!anEvent) {
2501 KNotifyClient::beep(); 2500 KNotifyClient::beep();
2502 return; 2501 return;
2503 } 2502 }
2504 2503
2505 editEvent(anEvent); 2504 editEvent(anEvent);
2506} 2505}
2507 2506
2508void CalendarView::appointment_delete() 2507void CalendarView::appointment_delete()
2509{ 2508{
2510 Event *anEvent = 0; 2509 Event *anEvent = 0;
2511 2510
2512 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2511 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2513 2512
2514 if (mViewManager->currentView()->isEventView()) { 2513 if (mViewManager->currentView()->isEventView()) {
2515 if ( incidence && incidence->type() == "Event" ) { 2514 if ( incidence && incidence->type() == "Event" ) {
2516 anEvent = static_cast<Event *>(incidence); 2515 anEvent = static_cast<Event *>(incidence);
2517 } 2516 }
2518 } 2517 }
2519 2518
2520 if (!anEvent) { 2519 if (!anEvent) {
2521 KNotifyClient::beep(); 2520 KNotifyClient::beep();
2522 return; 2521 return;
2523 } 2522 }
2524 2523
2525 deleteEvent(anEvent); 2524 deleteEvent(anEvent);
2526} 2525}
2527 2526
2528void CalendarView::todo_unsub(Todo *anTodo ) 2527void CalendarView::todo_unsub(Todo *anTodo )
2529{ 2528{
2530 // Todo *anTodo = selectedTodo(); 2529 // Todo *anTodo = selectedTodo();
2531 if (!anTodo) return; 2530 if (!anTodo) return;
2532 if (!anTodo->relatedTo()) return; 2531 if (!anTodo->relatedTo()) return;
2533 anTodo->relatedTo()->removeRelation(anTodo); 2532 anTodo->relatedTo()->removeRelation(anTodo);
2534 anTodo->setRelatedTo(0); 2533 anTodo->setRelatedTo(0);
2535 anTodo->updated(); 2534 anTodo->updated();
2536 anTodo->setRelatedToUid(""); 2535 anTodo->setRelatedToUid("");
2537 setModified(true); 2536 setModified(true);
2538 updateView(); 2537 updateView();
2539} 2538}
2540 2539
2541void CalendarView::deleteTodo(Todo *todo) 2540void CalendarView::deleteTodo(Todo *todo)
2542{ 2541{
2543 if (!todo) { 2542 if (!todo) {
2544 KNotifyClient::beep(); 2543 KNotifyClient::beep();
2545 return; 2544 return;
2546 } 2545 }
2547 if (KOPrefs::instance()->mConfirm) { 2546 if (KOPrefs::instance()->mConfirm) {
2548 switch (msgItemDelete()) { 2547 switch (msgItemDelete()) {
2549 case KMessageBox::Continue: // OK 2548 case KMessageBox::Continue: // OK
2550 if (!todo->relations().isEmpty()) { 2549 if (!todo->relations().isEmpty()) {
2551 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), 2550 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."),
2552 i18n("Delete To-Do")); 2551 i18n("Delete To-Do"));
2553 } else { 2552 } else {
2554 checkZaurusId( todo->zaurusId(), true ); 2553 checkZaurusId( todo->zaurusId(), true );
2555 calendar()->deleteTodo(todo); 2554 calendar()->deleteTodo(todo);
2556 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2555 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2557 updateView(); 2556 updateView();
2558 } 2557 }
2559 break; 2558 break;
2560 } // switch 2559 } // switch
2561 } else { 2560 } else {
2562 if (!todo->relations().isEmpty()) { 2561 if (!todo->relations().isEmpty()) {
2563 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), 2562 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."),
2564 i18n("Delete To-Do")); 2563 i18n("Delete To-Do"));
2565 } else { 2564 } else {
2566 checkZaurusId( todo->zaurusId(), true ); 2565 checkZaurusId( todo->zaurusId(), true );
2567 mCalendar->deleteTodo(todo); 2566 mCalendar->deleteTodo(todo);
2568 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2567 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2569 updateView(); 2568 updateView();
2570 } 2569 }
2571 } 2570 }
2572 emit updateSearchDialog(); 2571 emit updateSearchDialog();
2573} 2572}
2574void CalendarView::deleteJournal(Journal *jour) 2573void CalendarView::deleteJournal(Journal *jour)
2575{ 2574{
2576 if (!jour) { 2575 if (!jour) {
2577 KNotifyClient::beep(); 2576 KNotifyClient::beep();
2578 return; 2577 return;
2579 } 2578 }
2580 if (KOPrefs::instance()->mConfirm) { 2579 if (KOPrefs::instance()->mConfirm) {
2581 switch (msgItemDelete()) { 2580 switch (msgItemDelete()) {
2582 case KMessageBox::Continue: // OK 2581 case KMessageBox::Continue: // OK
2583 calendar()->deleteJournal(jour); 2582 calendar()->deleteJournal(jour);
2584 updateView(); 2583 updateView();
2585 break; 2584 break;
2586 } // switch 2585 } // switch
2587 } else { 2586 } else {
2588 calendar()->deleteJournal(jour);; 2587 calendar()->deleteJournal(jour);;
2589 updateView(); 2588 updateView();
2590 } 2589 }
2591 emit updateSearchDialog(); 2590 emit updateSearchDialog();
2592} 2591}
2593 2592
2594void CalendarView::deleteEvent(Event *anEvent) 2593void CalendarView::deleteEvent(Event *anEvent)
2595{ 2594{
2596 if (!anEvent) { 2595 if (!anEvent) {
2597 KNotifyClient::beep(); 2596 KNotifyClient::beep();
2598 return; 2597 return;
2599 } 2598 }
2600 2599
2601 if (anEvent->recurrence()->doesRecur()) { 2600 if (anEvent->recurrence()->doesRecur()) {
2602 QDate itemDate = mViewManager->currentSelectionDate(); 2601 QDate itemDate = mViewManager->currentSelectionDate();
2603 int km; 2602 int km;
2604 if (!itemDate.isValid()) { 2603 if (!itemDate.isValid()) {
2605 //kdDebug() << "Date Not Valid" << endl; 2604 //kdDebug() << "Date Not Valid" << endl;
2606 if (KOPrefs::instance()->mConfirm) { 2605 if (KOPrefs::instance()->mConfirm) {
2607 km = KMessageBox::warningContinueCancel(this,anEvent->summary() + 2606 km = KMessageBox::warningContinueCancel(this,anEvent->summary() +
2608 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), 2607 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"),
2609 i18n("KO/Pi Confirmation"),i18n("Delete All")); 2608 i18n("KO/Pi Confirmation"),i18n("Delete All"));
2610 if ( km == KMessageBox::Continue ) 2609 if ( km == KMessageBox::Continue )
2611 km = KMessageBox::No; // No = all below 2610 km = KMessageBox::No; // No = all below
2612 } else 2611 } else
2613 km = KMessageBox::No; 2612 km = KMessageBox::No;
2614 } else { 2613 } else {
2615 km = KMessageBox::warningYesNoCancel(this,anEvent->summary() + 2614 km = KMessageBox::warningYesNoCancel(this,anEvent->summary() +
2616 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ 2615 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+
2617 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), 2616 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"),
2618 i18n("KO/Pi Confirmation"),i18n("Current"), 2617 i18n("KO/Pi Confirmation"),i18n("Current"),
2619 i18n("All")); 2618 i18n("All"));
2620 } 2619 }
2621 switch(km) { 2620 switch(km) {
2622 2621
2623 case KMessageBox::No: // Continue // all 2622 case KMessageBox::No: // Continue // all
2624 //qDebug("KMessageBox::No "); 2623 //qDebug("KMessageBox::No ");
2625 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2624 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2626 schedule(Scheduler::Cancel,anEvent); 2625 schedule(Scheduler::Cancel,anEvent);
2627 2626
2628 checkZaurusId( anEvent->zaurusId()); 2627 checkZaurusId( anEvent->zaurusId());
2629 mCalendar->deleteEvent(anEvent); 2628 mCalendar->deleteEvent(anEvent);
2630 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); 2629 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED);
2631 break; 2630 break;
2632 2631
2633 // Disabled because it does not work 2632 // Disabled because it does not work
2634 //#if 0 2633 //#if 0
2635 case KMessageBox::Yes: // just this one 2634 case KMessageBox::Yes: // just this one
2636 //QDate qd = mNavigator->selectedDates().first(); 2635 //QDate qd = mNavigator->selectedDates().first();
2637 //if (!qd.isValid()) { 2636 //if (!qd.isValid()) {
2638 // kdDebug() << "no date selected, or invalid date" << endl; 2637 // kdDebug() << "no date selected, or invalid date" << endl;
2639 // KNotifyClient::beep(); 2638 // KNotifyClient::beep();
2640 // return; 2639 // return;
2641 //} 2640 //}
2642 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); 2641 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1);
2643 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { 2642 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) {
2644 anEvent->addExDate(itemDate); 2643 anEvent->addExDate(itemDate);
2645 int duration = anEvent->recurrence()->duration(); 2644 int duration = anEvent->recurrence()->duration();
2646 if ( duration > 0 ) { 2645 if ( duration > 0 ) {
2647 anEvent->recurrence()->setDuration( duration - 1 ); 2646 anEvent->recurrence()->setDuration( duration - 1 );
2648 } 2647 }
2649 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); 2648 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED);
2650 } 2649 }
2651 break; 2650 break;
2652 //#endif 2651 //#endif
2653 } // switch 2652 } // switch
2654 } else { 2653 } else {
2655 if (KOPrefs::instance()->mConfirm) { 2654 if (KOPrefs::instance()->mConfirm) {
2656 switch (KMessageBox::warningContinueCancel(this,anEvent->summary() + 2655 switch (KMessageBox::warningContinueCancel(this,anEvent->summary() +
2657 i18n("\nAre you sure you want\nto delete this event?"), 2656 i18n("\nAre you sure you want\nto delete this event?"),
2658 i18n("KO/Pi Confirmation"),i18n("Delete"))) { 2657 i18n("KO/Pi Confirmation"),i18n("Delete"))) {
2659 case KMessageBox::Continue: // OK 2658 case KMessageBox::Continue: // OK
2660 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2659 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2661 schedule(Scheduler::Cancel,anEvent); 2660 schedule(Scheduler::Cancel,anEvent);
2662 checkZaurusId( anEvent->zaurusId()); 2661 checkZaurusId( anEvent->zaurusId());
2663 mCalendar->deleteEvent(anEvent); 2662 mCalendar->deleteEvent(anEvent);
2664 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2663 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2665 break; 2664 break;
2666 } // switch 2665 } // switch
2667 } else { 2666 } else {
2668 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2667 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2669 schedule(Scheduler::Cancel,anEvent); 2668 schedule(Scheduler::Cancel,anEvent);
2670 checkZaurusId( anEvent->zaurusId()); 2669 checkZaurusId( anEvent->zaurusId());
2671 mCalendar->deleteEvent(anEvent); 2670 mCalendar->deleteEvent(anEvent);
2672 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2671 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2673 } 2672 }
2674 } // if-else 2673 } // if-else
2675 emit updateSearchDialog(); 2674 emit updateSearchDialog();
2676} 2675}
2677 2676
2678bool CalendarView::deleteEvent(const QString &uid) 2677bool CalendarView::deleteEvent(const QString &uid)
2679{ 2678{
2680 Event *ev = mCalendar->event(uid); 2679 Event *ev = mCalendar->event(uid);
2681 if (ev) { 2680 if (ev) {
2682 deleteEvent(ev); 2681 deleteEvent(ev);
2683 return true; 2682 return true;
2684 } else { 2683 } else {
2685 return false; 2684 return false;
2686 } 2685 }
2687} 2686}
2688 2687
2689/*****************************************************************************/ 2688/*****************************************************************************/
2690 2689
2691void CalendarView::action_mail() 2690void CalendarView::action_mail()
2692{ 2691{
2693#ifndef KORG_NOMAIL 2692#ifndef KORG_NOMAIL
2694 KOMailClient mailClient; 2693 KOMailClient mailClient;
2695 2694
2696 Incidence *incidence = currentSelection(); 2695 Incidence *incidence = currentSelection();
2697 2696
2698 if (!incidence) { 2697 if (!incidence) {
2699 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 2698 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
2700 return; 2699 return;
2701 } 2700 }
2702 if(incidence->attendeeCount() == 0 ) { 2701 if(incidence->attendeeCount() == 0 ) {
2703 KMessageBox::sorry(this, 2702 KMessageBox::sorry(this,
2704 i18n("Can't generate mail:\nNo attendees defined.\n")); 2703 i18n("Can't generate mail:\nNo attendees defined.\n"));
2705 return; 2704 return;
2706 } 2705 }
2707 2706
2708 CalendarLocal cal_tmp; 2707 CalendarLocal cal_tmp;
2709 Event *event = 0; 2708 Event *event = 0;
2710 Event *ev = 0; 2709 Event *ev = 0;
2711 if ( incidence && incidence->type() == "Event" ) { 2710 if ( incidence && incidence->type() == "Event" ) {
2712 event = static_cast<Event *>(incidence); 2711 event = static_cast<Event *>(incidence);
2713 ev = new Event(*event); 2712 ev = new Event(*event);
2714 cal_tmp.addEvent(ev); 2713 cal_tmp.addEvent(ev);
2715 } 2714 }
2716 ICalFormat mForm( KOPrefs::instance()->mUseQuicksave); 2715 ICalFormat mForm( KOPrefs::instance()->mUseQuicksave);
2717 QString attachment = mForm.toString( &cal_tmp ); 2716 QString attachment = mForm.toString( &cal_tmp );
2718 if (ev) delete(ev); 2717 if (ev) delete(ev);
2719 2718
2720 mailClient.mailAttendees(currentSelection(), attachment); 2719 mailClient.mailAttendees(currentSelection(), attachment);
2721 2720
2722#endif 2721#endif
2723 2722
2724#if 0 2723#if 0
2725 Event *anEvent = 0; 2724 Event *anEvent = 0;
2726 if (mViewManager->currentView()->isEventView()) { 2725 if (mViewManager->currentView()->isEventView()) {
2727 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); 2726 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first());
2728 } 2727 }
2729 2728
2730 if (!anEvent) { 2729 if (!anEvent) {
2731 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 2730 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
2732 return; 2731 return;
2733 } 2732 }
2734 if(anEvent->attendeeCount() == 0 ) { 2733 if(anEvent->attendeeCount() == 0 ) {
2735 KMessageBox::sorry(this, 2734 KMessageBox::sorry(this,
2736 i18n("Can't generate mail:\nNo attendees defined.\n")); 2735 i18n("Can't generate mail:\nNo attendees defined.\n"));
2737 return; 2736 return;
2738 } 2737 }
2739 2738
2740 mailobject.emailEvent(anEvent); 2739 mailobject.emailEvent(anEvent);
2741#endif 2740#endif
2742} 2741}
2743 2742
2744 2743
2745void CalendarView::schedule_publish(Incidence *incidence) 2744void CalendarView::schedule_publish(Incidence *incidence)
2746{ 2745{
2747 Event *event = 0; 2746 Event *event = 0;
2748 Todo *todo = 0; 2747 Todo *todo = 0;
2749 2748
2750 if (incidence == 0) { 2749 if (incidence == 0) {
2751 incidence = mViewManager->currentView()->selectedIncidences().first(); 2750 incidence = mViewManager->currentView()->selectedIncidences().first();
2752 if (incidence == 0) { 2751 if (incidence == 0) {
2753 incidence = mTodoList->selectedIncidences().first(); 2752 incidence = mTodoList->selectedIncidences().first();
2754 } 2753 }
2755 } 2754 }
2756 if ( incidence && incidence->type() == "Event" ) { 2755 if ( incidence && incidence->type() == "Event" ) {
2757 event = static_cast<Event *>(incidence); 2756 event = static_cast<Event *>(incidence);
2758 } else { 2757 } else {
2759 if ( incidence && incidence->type() == "Todo" ) { 2758 if ( incidence && incidence->type() == "Todo" ) {
2760 todo = static_cast<Todo *>(incidence); 2759 todo = static_cast<Todo *>(incidence);
2761 } 2760 }
2762 } 2761 }
2763 2762
2764 if (!event && !todo) { 2763 if (!event && !todo) {
2765 KMessageBox::sorry(this,i18n("No event selected.")); 2764 KMessageBox::sorry(this,i18n("No event selected."));
2766 return; 2765 return;
2767 } 2766 }
2768 2767
2769 PublishDialog *publishdlg = new PublishDialog(); 2768 PublishDialog *publishdlg = new PublishDialog();
2770 if (incidence->attendeeCount()>0) { 2769 if (incidence->attendeeCount()>0) {
2771 QPtrList<Attendee> attendees = incidence->attendees(); 2770 QPtrList<Attendee> attendees = incidence->attendees();
2772 attendees.first(); 2771 attendees.first();
2773 while ( attendees.current()!=0 ) { 2772 while ( attendees.current()!=0 ) {
2774 publishdlg->addAttendee(attendees.current()); 2773 publishdlg->addAttendee(attendees.current());
2775 attendees.next(); 2774 attendees.next();
2776 } 2775 }
2777 } 2776 }
2778 bool send = true; 2777 bool send = true;
2779 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { 2778 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) {
2780 if ( publishdlg->exec() != QDialog::Accepted ) 2779 if ( publishdlg->exec() != QDialog::Accepted )
2781 send = false; 2780 send = false;
2782 } 2781 }
2783 if ( send ) { 2782 if ( send ) {
2784 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 2783 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
2785 if ( event ) { 2784 if ( event ) {
2786 Event *ev = new Event(*event); 2785 Event *ev = new Event(*event);
2787 ev->registerObserver(0); 2786 ev->registerObserver(0);
2788 ev->clearAttendees(); 2787 ev->clearAttendees();
2789 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 2788 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
2790 delete(ev); 2789 delete(ev);
2791 } 2790 }
2792 } else { 2791 } else {
2793 if ( todo ) { 2792 if ( todo ) {
2794 Todo *ev = new Todo(*todo); 2793 Todo *ev = new Todo(*todo);
2795 ev->registerObserver(0); 2794 ev->registerObserver(0);
2796 ev->clearAttendees(); 2795 ev->clearAttendees();
2797 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 2796 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
2798 delete(ev); 2797 delete(ev);
2799 } 2798 }
2800 } 2799 }
2801 } 2800 }
2802 } 2801 }
2803 delete publishdlg; 2802 delete publishdlg;
2804} 2803}
2805 2804
2806void CalendarView::schedule_request(Incidence *incidence) 2805void CalendarView::schedule_request(Incidence *incidence)
2807{ 2806{
2808 schedule(Scheduler::Request,incidence); 2807 schedule(Scheduler::Request,incidence);
2809} 2808}
2810 2809
2811void CalendarView::schedule_refresh(Incidence *incidence) 2810void CalendarView::schedule_refresh(Incidence *incidence)
2812{ 2811{
2813 schedule(Scheduler::Refresh,incidence); 2812 schedule(Scheduler::Refresh,incidence);
2814} 2813}
2815 2814
2816void CalendarView::schedule_cancel(Incidence *incidence) 2815void CalendarView::schedule_cancel(Incidence *incidence)
2817{ 2816{
2818 schedule(Scheduler::Cancel,incidence); 2817 schedule(Scheduler::Cancel,incidence);
2819} 2818}
2820 2819
2821void CalendarView::schedule_add(Incidence *incidence) 2820void CalendarView::schedule_add(Incidence *incidence)
2822{ 2821{
2823 schedule(Scheduler::Add,incidence); 2822 schedule(Scheduler::Add,incidence);
2824} 2823}
2825 2824
2826void CalendarView::schedule_reply(Incidence *incidence) 2825void CalendarView::schedule_reply(Incidence *incidence)
2827{ 2826{
2828 schedule(Scheduler::Reply,incidence); 2827 schedule(Scheduler::Reply,incidence);
2829} 2828}
2830 2829
2831void CalendarView::schedule_counter(Incidence *incidence) 2830void CalendarView::schedule_counter(Incidence *incidence)
2832{ 2831{
2833 schedule(Scheduler::Counter,incidence); 2832 schedule(Scheduler::Counter,incidence);
2834} 2833}
2835 2834
2836void CalendarView::schedule_declinecounter(Incidence *incidence) 2835void CalendarView::schedule_declinecounter(Incidence *incidence)
2837{ 2836{
2838 schedule(Scheduler::Declinecounter,incidence); 2837 schedule(Scheduler::Declinecounter,incidence);
2839} 2838}
2840 2839
2841void CalendarView::schedule_publish_freebusy(int daysToPublish) 2840void CalendarView::schedule_publish_freebusy(int daysToPublish)
2842{ 2841{
2843 QDateTime start = QDateTime::currentDateTime(); 2842 QDateTime start = QDateTime::currentDateTime();
2844 QDateTime end = start.addDays(daysToPublish); 2843 QDateTime end = start.addDays(daysToPublish);
2845 2844
2846 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); 2845 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end);
2847 freebusy->setOrganizer(KOPrefs::instance()->email()); 2846 freebusy->setOrganizer(KOPrefs::instance()->email());
2848 2847
2849 2848
2850 PublishDialog *publishdlg = new PublishDialog(); 2849 PublishDialog *publishdlg = new PublishDialog();
2851 if ( publishdlg->exec() == QDialog::Accepted ) { 2850 if ( publishdlg->exec() == QDialog::Accepted ) {
2852 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 2851 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
2853 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { 2852 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) {
2854 delete(freebusy); 2853 delete(freebusy);
2855 } 2854 }
2856 } 2855 }
2857 delete publishdlg; 2856 delete publishdlg;
2858} 2857}
2859 2858
2860void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) 2859void CalendarView::schedule(Scheduler::Method method, Incidence *incidence)
2861{ 2860{
2862 Event *event = 0; 2861 Event *event = 0;
2863 Todo *todo = 0; 2862 Todo *todo = 0;
2864 2863
2865 if (incidence == 0) { 2864 if (incidence == 0) {
2866 incidence = mViewManager->currentView()->selectedIncidences().first(); 2865 incidence = mViewManager->currentView()->selectedIncidences().first();
2867 if (incidence == 0) { 2866 if (incidence == 0) {
2868 incidence = mTodoList->selectedIncidences().first(); 2867 incidence = mTodoList->selectedIncidences().first();
2869 } 2868 }
2870 } 2869 }
2871 if ( incidence && incidence->type() == "Event" ) { 2870 if ( incidence && incidence->type() == "Event" ) {
2872 event = static_cast<Event *>(incidence); 2871 event = static_cast<Event *>(incidence);
2873 } 2872 }
2874 if ( incidence && incidence->type() == "Todo" ) { 2873 if ( incidence && incidence->type() == "Todo" ) {
2875 todo = static_cast<Todo *>(incidence); 2874 todo = static_cast<Todo *>(incidence);
2876 } 2875 }
2877 2876
2878 if (!event && !todo) { 2877 if (!event && !todo) {
2879 KMessageBox::sorry(this,i18n("No event selected.")); 2878 KMessageBox::sorry(this,i18n("No event selected."));
2880 return; 2879 return;
2881 } 2880 }
2882 2881
2883 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { 2882 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) {
2884 KMessageBox::sorry(this,i18n("The event has no attendees.")); 2883 KMessageBox::sorry(this,i18n("The event has no attendees."));
2885 return; 2884 return;
2886 } 2885 }
2887 2886
2888 Event *ev = 0; 2887 Event *ev = 0;
2889 if (event) ev = new Event(*event); 2888 if (event) ev = new Event(*event);
2890 Todo *to = 0; 2889 Todo *to = 0;
2891 if (todo) to = new Todo(*todo); 2890 if (todo) to = new Todo(*todo);
2892 2891
2893 if (method == Scheduler::Reply || method == Scheduler::Refresh) { 2892 if (method == Scheduler::Reply || method == Scheduler::Refresh) {
2894 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 2893 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
2895 if (!me) { 2894 if (!me) {
2896 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); 2895 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails."));
2897 return; 2896 return;
2898 } 2897 }
2899 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { 2898 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) {
2900 StatusDialog *statdlg = new StatusDialog(this); 2899 StatusDialog *statdlg = new StatusDialog(this);
2901 if (!statdlg->exec()==QDialog::Accepted) return; 2900 if (!statdlg->exec()==QDialog::Accepted) return;
2902 me->setStatus( statdlg->status() ); 2901 me->setStatus( statdlg->status() );
2903 delete(statdlg); 2902 delete(statdlg);
2904 } 2903 }
2905 Attendee *menew = new Attendee(*me); 2904 Attendee *menew = new Attendee(*me);
2906 if (ev) { 2905 if (ev) {
2907 ev->clearAttendees(); 2906 ev->clearAttendees();
2908 ev->addAttendee(menew,false); 2907 ev->addAttendee(menew,false);
2909 } else { 2908 } else {
2910 if (to) { 2909 if (to) {
2911 todo->clearAttendees(); 2910 todo->clearAttendees();
2912 todo->addAttendee(menew,false); 2911 todo->addAttendee(menew,false);
2913 } 2912 }
2914 } 2913 }
2915 } 2914 }
2916 2915
2917 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 2916 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
2918 if (ev) { 2917 if (ev) {
2919 if ( !dlg->addMessage(ev,method) ) delete(ev); 2918 if ( !dlg->addMessage(ev,method) ) delete(ev);
2920 } else { 2919 } else {
2921 if (to) { 2920 if (to) {
2922 if ( !dlg->addMessage(to,method) ) delete(to); 2921 if ( !dlg->addMessage(to,method) ) delete(to);
2923 } 2922 }
2924 } 2923 }
2925} 2924}
2926 2925
2927void CalendarView::openAddressbook() 2926void CalendarView::openAddressbook()
2928{ 2927{
2929 KRun::runCommand("kaddressbook"); 2928 KRun::runCommand("kaddressbook");
2930} 2929}
2931 2930
2932void CalendarView::setModified(bool modified) 2931void CalendarView::setModified(bool modified)
2933{ 2932{
2934 if ( modified ) 2933 if ( modified )
2935 emit signalmodified(); 2934 emit signalmodified();
2936 if (mModified != modified) { 2935 if (mModified != modified) {
2937 mModified = modified; 2936 mModified = modified;
2938 emit modifiedChanged(mModified); 2937 emit modifiedChanged(mModified);
2939 } 2938 }
2940} 2939}
2941 2940
2942bool CalendarView::isReadOnly() 2941bool CalendarView::isReadOnly()
2943{ 2942{
2944 return mReadOnly; 2943 return mReadOnly;
2945} 2944}
2946 2945
2947void CalendarView::setReadOnly(bool readOnly) 2946void CalendarView::setReadOnly(bool readOnly)
2948{ 2947{
2949 if (mReadOnly != readOnly) { 2948 if (mReadOnly != readOnly) {
2950 mReadOnly = readOnly; 2949 mReadOnly = readOnly;
2951 emit readOnlyChanged(mReadOnly); 2950 emit readOnlyChanged(mReadOnly);
2952 } 2951 }
2953} 2952}
2954 2953
2955bool CalendarView::isModified() 2954bool CalendarView::isModified()
2956{ 2955{
2957 return mModified; 2956 return mModified;
2958} 2957}
2959 2958
2960void CalendarView::printSetup() 2959void CalendarView::printSetup()
2961{ 2960{
2962#ifndef KORG_NOPRINTER 2961#ifndef KORG_NOPRINTER
2963 createPrinter(); 2962 createPrinter();
2964 2963
2965 mCalPrinter->setupPrinter(); 2964 mCalPrinter->setupPrinter();
2966#endif 2965#endif
2967} 2966}
2968 2967
2969void CalendarView::print() 2968void CalendarView::print()
2970{ 2969{
2971#ifndef KORG_NOPRINTER 2970#ifndef KORG_NOPRINTER
2972 createPrinter(); 2971 createPrinter();
2973 2972
2974 DateList tmpDateList = mNavigator->selectedDates(); 2973 DateList tmpDateList = mNavigator->selectedDates();
2975 mCalPrinter->print(CalPrinter::Month, 2974 mCalPrinter->print(CalPrinter::Month,
2976 tmpDateList.first(), tmpDateList.last()); 2975 tmpDateList.first(), tmpDateList.last());
2977#endif 2976#endif
2978} 2977}
2979 2978
2980void CalendarView::printPreview() 2979void CalendarView::printPreview()
2981{ 2980{
2982#ifndef KORG_NOPRINTER 2981#ifndef KORG_NOPRINTER
2983 kdDebug() << "CalendarView::printPreview()" << endl; 2982 kdDebug() << "CalendarView::printPreview()" << endl;
2984 2983
2985 createPrinter(); 2984 createPrinter();
2986 2985
2987 DateList tmpDateList = mNavigator->selectedDates(); 2986 DateList tmpDateList = mNavigator->selectedDates();
2988 2987
2989 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), 2988 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(),
2990 tmpDateList.last()); 2989 tmpDateList.last());
2991#endif 2990#endif
2992} 2991}
2993 2992
2994void CalendarView::exportICalendar() 2993void CalendarView::exportICalendar()
2995{ 2994{
2996 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); 2995 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this);
2997 2996
2998 // Force correct extension 2997 // Force correct extension
2999 if (filename.right(4) != ".ics") filename += ".ics"; 2998 if (filename.right(4) != ".ics") filename += ".ics";
3000 2999
3001 FileStorage storage( mCalendar, filename, new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 3000 FileStorage storage( mCalendar, filename, new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
3002 storage.save(); 3001 storage.save();
3003} 3002}
3004 3003
3005bool CalendarView::exportVCalendar( QString filename ) 3004bool CalendarView::exportVCalendar( QString filename )
3006{ 3005{
3007 if (mCalendar->journals().count() > 0) { 3006 if (mCalendar->journals().count() > 0) {
3008 int result = KMessageBox::warningContinueCancel(this, 3007 int result = KMessageBox::warningContinueCancel(this,
3009 i18n("The journal entries can not be\nexported to a vCalendar file."), 3008 i18n("The journal entries can not be\nexported to a vCalendar file."),
3010 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 3009 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
3011 true); 3010 true);
3012 if (result != KMessageBox::Continue) return false; 3011 if (result != KMessageBox::Continue) return false;
3013 } 3012 }
3014 3013
3015 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); 3014 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this);
3016 3015
3017 // Force correct extension 3016 // Force correct extension
3018 if (filename.right(4) != ".vcs") filename += ".vcs"; 3017 if (filename.right(4) != ".vcs") filename += ".vcs";
3019 3018
3020 FileStorage storage( mCalendar, filename, new VCalFormat ); 3019 FileStorage storage( mCalendar, filename, new VCalFormat );
3021 return storage.save(); 3020 return storage.save();
3022 3021
3023} 3022}
3024 3023
3025void CalendarView::eventUpdated(Incidence *) 3024void CalendarView::eventUpdated(Incidence *)
3026{ 3025{
3027 setModified(); 3026 setModified();
3028 // Don't call updateView here. The code, which has caused the update of the 3027 // Don't call updateView here. The code, which has caused the update of the
3029 // event is responsible for updating the view. 3028 // event is responsible for updating the view.
3030 // updateView(); 3029 // updateView();
3031} 3030}
3032 3031
3033void CalendarView::adaptNavigationUnits() 3032void CalendarView::adaptNavigationUnits()
3034{ 3033{
3035 if (mViewManager->currentView()->isEventView()) { 3034 if (mViewManager->currentView()->isEventView()) {
3036 int days = mViewManager->currentView()->currentDateCount(); 3035 int days = mViewManager->currentView()->currentDateCount();
3037 if (days == 1) { 3036 if (days == 1) {
3038 emit changeNavStringPrev(i18n("&Previous Day")); 3037 emit changeNavStringPrev(i18n("&Previous Day"));
3039 emit changeNavStringNext(i18n("&Next Day")); 3038 emit changeNavStringNext(i18n("&Next Day"));
3040 } else { 3039 } else {
3041 emit changeNavStringPrev(i18n("&Previous Week")); 3040 emit changeNavStringPrev(i18n("&Previous Week"));
3042 emit changeNavStringNext(i18n("&Next Week")); 3041 emit changeNavStringNext(i18n("&Next Week"));
3043 } 3042 }
3044 } 3043 }
3045} 3044}
3046 3045
3047void CalendarView::processMainViewSelection( Incidence *incidence ) 3046void CalendarView::processMainViewSelection( Incidence *incidence )
3048{ 3047{
3049 if ( incidence ) mTodoList->clearSelection(); 3048 if ( incidence ) mTodoList->clearSelection();
3050 processIncidenceSelection( incidence ); 3049 processIncidenceSelection( incidence );
3051} 3050}
3052 3051
3053void CalendarView::processTodoListSelection( Incidence *incidence ) 3052void CalendarView::processTodoListSelection( Incidence *incidence )
3054{ 3053{
3055 if ( incidence && mViewManager->currentView() ) { 3054 if ( incidence && mViewManager->currentView() ) {
3056 mViewManager->currentView()->clearSelection(); 3055 mViewManager->currentView()->clearSelection();
3057 } 3056 }
3058 processIncidenceSelection( incidence ); 3057 processIncidenceSelection( incidence );
3059} 3058}
3060 3059
3061void CalendarView::processIncidenceSelection( Incidence *incidence ) 3060void CalendarView::processIncidenceSelection( Incidence *incidence )
3062{ 3061{
3063 if ( incidence == mSelectedIncidence ) return; 3062 if ( incidence == mSelectedIncidence ) return;
3064 3063
3065 mSelectedIncidence = incidence; 3064 mSelectedIncidence = incidence;
3066 3065
3067 emit incidenceSelected( mSelectedIncidence ); 3066 emit incidenceSelected( mSelectedIncidence );
3068 3067
3069 if ( incidence && incidence->type() == "Event" ) { 3068 if ( incidence && incidence->type() == "Event" ) {
3070 Event *event = static_cast<Event *>( incidence ); 3069 Event *event = static_cast<Event *>( incidence );
3071 if ( event->organizer() == KOPrefs::instance()->email() ) { 3070 if ( event->organizer() == KOPrefs::instance()->email() ) {
3072 emit organizerEventsSelected( true ); 3071 emit organizerEventsSelected( true );
3073 } else { 3072 } else {
3074 emit organizerEventsSelected(false); 3073 emit organizerEventsSelected(false);
3075 } 3074 }
3076 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3075 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3077 KOPrefs::instance()->email() ) ) { 3076 KOPrefs::instance()->email() ) ) {
3078 emit groupEventsSelected( true ); 3077 emit groupEventsSelected( true );
3079 } else { 3078 } else {
3080 emit groupEventsSelected(false); 3079 emit groupEventsSelected(false);
3081 } 3080 }
3082 return; 3081 return;
3083 } else { 3082 } else {
3084 if ( incidence && incidence->type() == "Todo" ) { 3083 if ( incidence && incidence->type() == "Todo" ) {
3085 emit todoSelected( true ); 3084 emit todoSelected( true );
3086 Todo *event = static_cast<Todo *>( incidence ); 3085 Todo *event = static_cast<Todo *>( incidence );
3087 if ( event->organizer() == KOPrefs::instance()->email() ) { 3086 if ( event->organizer() == KOPrefs::instance()->email() ) {
3088 emit organizerEventsSelected( true ); 3087 emit organizerEventsSelected( true );
3089 } else { 3088 } else {
3090 emit organizerEventsSelected(false); 3089 emit organizerEventsSelected(false);
3091 } 3090 }
3092 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3091 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3093 KOPrefs::instance()->email() ) ) { 3092 KOPrefs::instance()->email() ) ) {
3094 emit groupEventsSelected( true ); 3093 emit groupEventsSelected( true );
3095 } else { 3094 } else {
3096 emit groupEventsSelected(false); 3095 emit groupEventsSelected(false);
3097 } 3096 }
3098 return; 3097 return;
3099 } else { 3098 } else {
3100 emit todoSelected( false ); 3099 emit todoSelected( false );
3101 emit organizerEventsSelected(false); 3100 emit organizerEventsSelected(false);
3102 emit groupEventsSelected(false); 3101 emit groupEventsSelected(false);
3103 } 3102 }
3104 return; 3103 return;
3105 } 3104 }
3106 3105
3107 /* if ( incidence && incidence->type() == "Todo" ) { 3106 /* if ( incidence && incidence->type() == "Todo" ) {
3108 emit todoSelected( true ); 3107 emit todoSelected( true );
3109 } else { 3108 } else {
3110 emit todoSelected( false ); 3109 emit todoSelected( false );
3111 }*/ 3110 }*/
3112} 3111}
3113 3112
3114 3113
3115void CalendarView::checkClipboard() 3114void CalendarView::checkClipboard()
3116{ 3115{
3117#ifndef KORG_NODND 3116#ifndef KORG_NODND
3118 if (ICalDrag::canDecode(QApplication::clipboard()->data())) { 3117 if (ICalDrag::canDecode(QApplication::clipboard()->data())) {
3119 emit pasteEnabled(true); 3118 emit pasteEnabled(true);
3120 } else { 3119 } else {
3121 emit pasteEnabled(false); 3120 emit pasteEnabled(false);
3122 } 3121 }
3123#endif 3122#endif
3124} 3123}
3125 3124
3126void CalendarView::showDates(const DateList &selectedDates) 3125void CalendarView::showDates(const DateList &selectedDates)
3127{ 3126{
3128 // kdDebug() << "CalendarView::selectDates()" << endl; 3127 // kdDebug() << "CalendarView::selectDates()" << endl;
3129 3128
3130 if ( mViewManager->currentView() ) { 3129 if ( mViewManager->currentView() ) {
3131 updateView( selectedDates.first(), selectedDates.last() ); 3130 updateView( selectedDates.first(), selectedDates.last() );
3132 } else { 3131 } else {
3133 mViewManager->showAgendaView(); 3132 mViewManager->showAgendaView();
3134 } 3133 }
3135 3134
3136 QString selDates; 3135 QString selDates;
3137 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); 3136 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true);
3138 if (selectedDates.first() < selectedDates.last() ) 3137 if (selectedDates.first() < selectedDates.last() )
3139 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); 3138 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true);
3140 topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); 3139 topLevelWidget()->setCaption( i18n("Dates: ") + selDates );
3141 3140
3142} 3141}
3143 3142
3144void CalendarView::editFilters() 3143void CalendarView::editFilters()
3145{ 3144{
3146 // kdDebug() << "CalendarView::editFilters()" << endl; 3145 // kdDebug() << "CalendarView::editFilters()" << endl;
3147 3146
3148 CalFilter *filter = mFilters.first(); 3147 CalFilter *filter = mFilters.first();
3149 while(filter) { 3148 while(filter) {
3150 kdDebug() << " Filter: " << filter->name() << endl; 3149 kdDebug() << " Filter: " << filter->name() << endl;
3151 filter = mFilters.next(); 3150 filter = mFilters.next();
3152 } 3151 }
3153 3152
3154 mDialogManager->showFilterEditDialog(&mFilters); 3153 mDialogManager->showFilterEditDialog(&mFilters);
3155} 3154}
3156void CalendarView::toggleFilter() 3155void CalendarView::toggleFilter()
3157{ 3156{
3158 showFilter(! mFilterView->isVisible()); 3157 showFilter(! mFilterView->isVisible());
3159} 3158}
3160 3159
3161void CalendarView::selectFilter( int fil ) 3160void CalendarView::selectFilter( int fil )
3162{ 3161{
3163 mFilterView->setSelectedFilter( fil ); 3162 mFilterView->setSelectedFilter( fil );
3164} 3163}
3165void CalendarView::showFilter(bool visible) 3164void CalendarView::showFilter(bool visible)
3166{ 3165{
3167 if (visible) mFilterView->show(); 3166 if (visible) mFilterView->show();
3168 else mFilterView->hide(); 3167 else mFilterView->hide();
3169} 3168}
3170void CalendarView::toggleFilerEnabled( ) 3169void CalendarView::toggleFilerEnabled( )
3171{ 3170{
3172 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); 3171 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() );
3173 if ( !mFilterView->filtersEnabled() ) 3172 if ( !mFilterView->filtersEnabled() )
3174 topLevelWidget()->setCaption( i18n("Filter disabled ") ); 3173 topLevelWidget()->setCaption( i18n("Filter disabled ") );
3175 3174
3176} 3175}
3177void CalendarView::updateFilter() 3176void CalendarView::updateFilter()
3178{ 3177{
3179 CalFilter *filter = mFilterView->selectedFilter(); 3178 CalFilter *filter = mFilterView->selectedFilter();
3180 if (filter) { 3179 if (filter) {
3181 if (mFilterView->filtersEnabled()) { 3180 if (mFilterView->filtersEnabled()) {
3182 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); 3181 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() );
3183 filter->setEnabled(true); 3182 filter->setEnabled(true);
3184 } 3183 }
3185 else filter->setEnabled(false); 3184 else filter->setEnabled(false);
3186 mCalendar->setFilter(filter); 3185 mCalendar->setFilter(filter);
3187 updateView(); 3186 updateView();
3188 } 3187 }
3189} 3188}
3190 3189
3191void CalendarView::filterEdited() 3190void CalendarView::filterEdited()
3192{ 3191{
3193 mFilterView->updateFilters(); 3192 mFilterView->updateFilters();
3194 updateFilter(); 3193 updateFilter();
3195 writeSettings(); 3194 writeSettings();
3196} 3195}
3197 3196
3198 3197
3199void CalendarView::takeOverEvent() 3198void CalendarView::takeOverEvent()
3200{ 3199{
3201 Incidence *incidence = currentSelection(); 3200 Incidence *incidence = currentSelection();
3202 3201
3203 if (!incidence) return; 3202 if (!incidence) return;
3204 3203
3205 incidence->setOrganizer(KOPrefs::instance()->email()); 3204 incidence->setOrganizer(KOPrefs::instance()->email());
3206 incidence->recreate(); 3205 incidence->recreate();
3207 incidence->setReadOnly(false); 3206 incidence->setReadOnly(false);
3208 3207
3209 updateView(); 3208 updateView();
3210} 3209}
3211 3210
3212void CalendarView::takeOverCalendar() 3211void CalendarView::takeOverCalendar()
3213{ 3212{
3214 // TODO: Create Calendar::allIncidences() function and use it here 3213 // TODO: Create Calendar::allIncidences() function and use it here
3215 3214
3216 QPtrList<Event> events = mCalendar->events(); 3215 QPtrList<Event> events = mCalendar->events();
3217 for(uint i=0; i<events.count(); ++i) { 3216 for(uint i=0; i<events.count(); ++i) {
3218 events.at(i)->setOrganizer(KOPrefs::instance()->email()); 3217 events.at(i)->setOrganizer(KOPrefs::instance()->email());
3219 events.at(i)->recreate(); 3218 events.at(i)->recreate();
3220 events.at(i)->setReadOnly(false); 3219 events.at(i)->setReadOnly(false);
3221 } 3220 }
3222 3221
3223 QPtrList<Todo> todos = mCalendar->todos(); 3222 QPtrList<Todo> todos = mCalendar->todos();
3224 for(uint i=0; i<todos.count(); ++i) { 3223 for(uint i=0; i<todos.count(); ++i) {
3225 todos.at(i)->setOrganizer(KOPrefs::instance()->email()); 3224 todos.at(i)->setOrganizer(KOPrefs::instance()->email());
3226 todos.at(i)->recreate(); 3225 todos.at(i)->recreate();
3227 todos.at(i)->setReadOnly(false); 3226 todos.at(i)->setReadOnly(false);
3228 } 3227 }
3229 3228
3230 QPtrList<Journal> journals = mCalendar->journals(); 3229 QPtrList<Journal> journals = mCalendar->journals();
3231 for(uint i=0; i<journals.count(); ++i) { 3230 for(uint i=0; i<journals.count(); ++i) {
3232 journals.at(i)->setOrganizer(KOPrefs::instance()->email()); 3231 journals.at(i)->setOrganizer(KOPrefs::instance()->email());
3233 journals.at(i)->recreate(); 3232 journals.at(i)->recreate();
3234 journals.at(i)->setReadOnly(false); 3233 journals.at(i)->setReadOnly(false);
3235 } 3234 }
3236 3235
3237 updateView(); 3236 updateView();
3238} 3237}
3239 3238
3240void CalendarView::showIntro() 3239void CalendarView::showIntro()
3241{ 3240{
3242 kdDebug() << "To be implemented." << endl; 3241 kdDebug() << "To be implemented." << endl;
3243} 3242}
3244 3243
3245QWidgetStack *CalendarView::viewStack() 3244QWidgetStack *CalendarView::viewStack()
3246{ 3245{
3247 return mRightFrame; 3246 return mRightFrame;
3248} 3247}
3249 3248
3250QWidget *CalendarView::leftFrame() 3249QWidget *CalendarView::leftFrame()
3251{ 3250{
3252 return mLeftFrame; 3251 return mLeftFrame;
3253} 3252}
3254 3253
3255DateNavigator *CalendarView::dateNavigator() 3254DateNavigator *CalendarView::dateNavigator()
3256{ 3255{
3257 return mNavigator; 3256 return mNavigator;
3258} 3257}
3259 3258
3260KDateNavigator* CalendarView::dateNavigatorWidget() 3259KDateNavigator* CalendarView::dateNavigatorWidget()
3261{ 3260{
3262 return mDateNavigator; 3261 return mDateNavigator;
3263} 3262}
3264void CalendarView::toggleDateNavigatorWidget() 3263void CalendarView::toggleDateNavigatorWidget()
3265{ 3264{
3266 if (mDateNavigator->isVisible()) 3265 if (mDateNavigator->isVisible())
3267 mDateNavigator->hide(); 3266 mDateNavigator->hide();
3268 else 3267 else
3269 mDateNavigator->show(); 3268 mDateNavigator->show();
3270} 3269}
3271void CalendarView::addView(KOrg::BaseView *view) 3270void CalendarView::addView(KOrg::BaseView *view)
3272{ 3271{
3273 mViewManager->addView(view); 3272 mViewManager->addView(view);
3274} 3273}
3275 3274
3276void CalendarView::showView(KOrg::BaseView *view) 3275void CalendarView::showView(KOrg::BaseView *view)
3277{ 3276{
3278 mViewManager->showView(view, mLeftFrame->isVisible()); 3277 mViewManager->showView(view, mLeftFrame->isVisible());
3279} 3278}
3280 3279
3281Incidence *CalendarView::currentSelection() 3280Incidence *CalendarView::currentSelection()
3282{ 3281{
3283 return mViewManager->currentSelection(); 3282 return mViewManager->currentSelection();
3284} 3283}
3285void CalendarView::toggleAllDaySize() 3284void CalendarView::toggleAllDaySize()
3286{ 3285{
3287 /* 3286 /*
3288 if ( KOPrefs::instance()->mAllDaySize > 47 ) 3287 if ( KOPrefs::instance()->mAllDaySize > 47 )
3289 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; 3288 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2;
3290 else 3289 else
3291 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; 3290 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2;
3292 */ 3291 */
3293 viewManager()->agendaView()->toggleAllDay(); 3292 viewManager()->agendaView()->toggleAllDay();
3294} 3293}
3295void CalendarView::toggleExpand() 3294void CalendarView::toggleExpand()
3296{ 3295{
3297 // if ( mLeftFrame->isHidden() ) { 3296 // if ( mLeftFrame->isHidden() ) {
3298 // mLeftFrame->show(); 3297 // mLeftFrame->show();
3299 // emit calendarViewExpanded( false ); 3298 // emit calendarViewExpanded( false );
3300 // } else { 3299 // } else {
3301 // mLeftFrame->hide(); 3300 // mLeftFrame->hide();
3302 // emit calendarViewExpanded( true ); 3301 // emit calendarViewExpanded( true );
3303 // } 3302 // }
3304 3303
3305 globalFlagBlockAgenda = 1; 3304 globalFlagBlockAgenda = 1;
3306 emit calendarViewExpanded( !mLeftFrame->isHidden() ); 3305 emit calendarViewExpanded( !mLeftFrame->isHidden() );
3307 globalFlagBlockAgenda = 5; 3306 globalFlagBlockAgenda = 5;
3308 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); 3307 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() );
3309 //mViewManager->showView( 0, true ); 3308 //mViewManager->showView( 0, true );
3310} 3309}
3311 3310
3312void CalendarView::calendarModified( bool modified, Calendar * ) 3311void CalendarView::calendarModified( bool modified, Calendar * )
3313{ 3312{
3314 setModified( modified ); 3313 setModified( modified );
3315} 3314}
3316 3315
3317Todo *CalendarView::selectedTodo() 3316Todo *CalendarView::selectedTodo()
3318{ 3317{
3319 Incidence *incidence = currentSelection(); 3318 Incidence *incidence = currentSelection();
3320 if ( incidence && incidence->type() == "Todo" ) { 3319 if ( incidence && incidence->type() == "Todo" ) {
3321 return static_cast<Todo *>( incidence ); 3320 return static_cast<Todo *>( incidence );
3322 } 3321 }
3323 3322
3324 incidence = mTodoList->selectedIncidences().first(); 3323 incidence = mTodoList->selectedIncidences().first();
3325 if ( incidence && incidence->type() == "Todo" ) { 3324 if ( incidence && incidence->type() == "Todo" ) {
3326 return static_cast<Todo *>( incidence ); 3325 return static_cast<Todo *>( incidence );
3327 } 3326 }
3328 3327
3329 return 0; 3328 return 0;
3330} 3329}
3331 3330
3332void CalendarView::dialogClosing(Incidence *in) 3331void CalendarView::dialogClosing(Incidence *in)
3333{ 3332{
3334 // mDialogList.remove(in); 3333 // mDialogList.remove(in);
3335} 3334}
3336 3335
3337void CalendarView::showIncidence() 3336void CalendarView::showIncidence()
3338{ 3337{
3339 Incidence *incidence = currentSelection(); 3338 Incidence *incidence = currentSelection();
3340 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3339 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3341 if ( incidence ) { 3340 if ( incidence ) {
3342 ShowIncidenceVisitor v; 3341 ShowIncidenceVisitor v;
3343 v.act( incidence, this ); 3342 v.act( incidence, this );
3344 } 3343 }
3345} 3344}
3346void CalendarView::editIncidenceDescription() 3345void CalendarView::editIncidenceDescription()
3347{ 3346{
3348 mFlagEditDescription = true; 3347 mFlagEditDescription = true;
3349 editIncidence(); 3348 editIncidence();
3350 mFlagEditDescription = false; 3349 mFlagEditDescription = false;
3351} 3350}
3352void CalendarView::editIncidence() 3351void CalendarView::editIncidence()
3353{ 3352{
3354 // qDebug("editIncidence() "); 3353 // qDebug("editIncidence() ");
3355 Incidence *incidence = currentSelection(); 3354 Incidence *incidence = currentSelection();
3356 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3355 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3357 if ( incidence ) { 3356 if ( incidence ) {
3358 EditIncidenceVisitor v; 3357 EditIncidenceVisitor v;
3359 v.act( incidence, this ); 3358 v.act( incidence, this );
3360 } 3359 }
3361} 3360}
3362 3361
3363void CalendarView::deleteIncidence() 3362void CalendarView::deleteIncidence()
3364{ 3363{
3365 Incidence *incidence = currentSelection(); 3364 Incidence *incidence = currentSelection();
3366 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3365 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3367 if ( incidence ) { 3366 if ( incidence ) {
3368 deleteIncidence(incidence); 3367 deleteIncidence(incidence);
3369 } 3368 }
3370} 3369}
3371 3370
3372void CalendarView::showIncidence(Incidence *incidence) 3371void CalendarView::showIncidence(Incidence *incidence)
3373{ 3372{
3374 if ( incidence ) { 3373 if ( incidence ) {
3375 ShowIncidenceVisitor v; 3374 ShowIncidenceVisitor v;
3376 v.act( incidence, this ); 3375 v.act( incidence, this );
3377 } 3376 }
3378} 3377}
3379 3378
3380void CalendarView::editIncidence(Incidence *incidence) 3379void CalendarView::editIncidence(Incidence *incidence)
3381{ 3380{
3382 if ( incidence ) { 3381 if ( incidence ) {
3383 3382
3384 EditIncidenceVisitor v; 3383 EditIncidenceVisitor v;
3385 v.act( incidence, this ); 3384 v.act( incidence, this );
3386 3385
3387 } 3386 }
3388} 3387}
3389 3388
3390void CalendarView::deleteIncidence(Incidence *incidence) 3389void CalendarView::deleteIncidence(Incidence *incidence)
3391{ 3390{
3392 //qDebug(" CalendarView::deleteIncidence "); 3391 //qDebug(" CalendarView::deleteIncidence ");
3393 if ( incidence ) { 3392 if ( incidence ) {
3394 DeleteIncidenceVisitor v; 3393 DeleteIncidenceVisitor v;
3395 v.act( incidence, this ); 3394 v.act( incidence, this );
3396 } 3395 }
3397} 3396}
3398 3397
3399 3398
3400void CalendarView::lookForOutgoingMessages() 3399void CalendarView::lookForOutgoingMessages()
3401{ 3400{
3402 OutgoingDialog *ogd = mDialogManager->outgoingDialog(); 3401 OutgoingDialog *ogd = mDialogManager->outgoingDialog();
3403 ogd->loadMessages(); 3402 ogd->loadMessages();
3404} 3403}
3405 3404
3406void CalendarView::lookForIncomingMessages() 3405void CalendarView::lookForIncomingMessages()
3407{ 3406{
3408 IncomingDialog *icd = mDialogManager->incomingDialog(); 3407 IncomingDialog *icd = mDialogManager->incomingDialog();
3409 icd->retrieve(); 3408 icd->retrieve();
3410} 3409}
3411 3410
3412bool CalendarView::removeCompletedSubTodos( Todo* t ) 3411bool CalendarView::removeCompletedSubTodos( Todo* t )
3413{ 3412{
3414 bool deleteTodo = true; 3413 bool deleteTodo = true;
3415 QPtrList<Incidence> subTodos; 3414 QPtrList<Incidence> subTodos;
3416 Incidence *aTodo; 3415 Incidence *aTodo;
3417 subTodos = t->relations(); 3416 subTodos = t->relations();
3418 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { 3417 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
3419 if (! removeCompletedSubTodos( (Todo*) aTodo )) 3418 if (! removeCompletedSubTodos( (Todo*) aTodo ))
3420 deleteTodo = false; 3419 deleteTodo = false;
3421 } 3420 }
3422 if ( deleteTodo ) { 3421 if ( deleteTodo ) {
3423 if ( t->isCompleted() ) { 3422 if ( t->isCompleted() ) {
3424 checkZaurusId( t->zaurusId(), true ); 3423 checkZaurusId( t->zaurusId(), true );
3425 mCalendar->deleteTodo( t ); 3424 mCalendar->deleteTodo( t );
3426 changeTodoDisplay( t,KOGlobals::EVENTDELETED ); 3425 changeTodoDisplay( t,KOGlobals::EVENTDELETED );
3427 } 3426 }
3428 else 3427 else
3429 deleteTodo = false; 3428 deleteTodo = false;
3430 } 3429 }
3431 return deleteTodo; 3430 return deleteTodo;
3432 3431
3433} 3432}
3434void CalendarView::purgeCompleted() 3433void CalendarView::purgeCompleted()
3435{ 3434{
3436 int result = KMessageBox::warningContinueCancel(this, 3435 int result = KMessageBox::warningContinueCancel(this,
3437 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); 3436 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge"));
3438 3437
3439 if (result == KMessageBox::Continue) { 3438 if (result == KMessageBox::Continue) {
3440 3439
3441 QPtrList<Todo> todoCal; 3440 QPtrList<Todo> todoCal;
3442 QPtrList<Todo> rootTodos; 3441 QPtrList<Todo> rootTodos;
3443 //QPtrList<Incidence> rel; 3442 //QPtrList<Incidence> rel;
3444 Todo *aTodo;//, *rTodo; 3443 Todo *aTodo;//, *rTodo;
3445 Incidence *rIncidence; 3444 Incidence *rIncidence;
3446 bool childDelete = false; 3445 bool childDelete = false;
3447 bool deletedOne = true; 3446 bool deletedOne = true;
3448 todoCal = calendar()->todos(); 3447 todoCal = calendar()->todos();
3449 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { 3448 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
3450 if ( !aTodo->relatedTo() ) 3449 if ( !aTodo->relatedTo() )
3451 rootTodos.append( aTodo ); 3450 rootTodos.append( aTodo );
3452 } 3451 }
3453 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { 3452 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) {
3454 removeCompletedSubTodos( aTodo ); 3453 removeCompletedSubTodos( aTodo );
3455 } 3454 }
3456 3455
3457 updateView(); 3456 updateView();
3458 } 3457 }
3459} 3458}
3460 3459
3461void CalendarView::slotCalendarChanged() 3460void CalendarView::slotCalendarChanged()
3462{ 3461{
3463 ; 3462 ;
3464} 3463}
3465 3464
3466NavigatorBar *CalendarView::navigatorBar() 3465NavigatorBar *CalendarView::navigatorBar()
3467{ 3466{
3468 return mNavigatorBar; 3467 return mNavigatorBar;
3469} 3468}
3470 3469
3471 3470
3472 3471
3473void CalendarView::keyPressEvent ( QKeyEvent *e) 3472void CalendarView::keyPressEvent ( QKeyEvent *e)
3474{ 3473{
3475 //qDebug(" alendarView::keyPressEvent "); 3474 //qDebug(" alendarView::keyPressEvent ");
3476 e->ignore(); 3475 e->ignore();
3477} 3476}
3478 3477
3479//#include "calendarview.moc" 3478//#include "calendarview.moc"
3480 3479
3481//#include "calendarviewbase.moc" 3480//#include "calendarviewbase.moc"
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 589ab2d..d0d1f3b 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1,1993 +1,1995 @@
1#include <stdlib.h> 1#include <stdlib.h>
2 2
3#include <qaction.h> 3#include <qaction.h>
4#include <qpopupmenu.h> 4#include <qpopupmenu.h>
5#include <qpainter.h> 5#include <qpainter.h>
6#include <qwhatsthis.h> 6#include <qwhatsthis.h>
7#include <qmessagebox.h> 7#include <qmessagebox.h>
8#include <qlineedit.h> 8#include <qlineedit.h>
9#include <qfile.h> 9#include <qfile.h>
10#include <qdir.h> 10#include <qdir.h>
11#include <qapp.h> 11#include <qapp.h>
12#include <qfileinfo.h> 12#include <qfileinfo.h>
13#include <qlabel.h> 13#include <qlabel.h>
14#include <qwmatrix.h> 14#include <qwmatrix.h>
15#include <qtextbrowser.h> 15#include <qtextbrowser.h>
16#include <qtextstream.h> 16#include <qtextstream.h>
17#ifndef DESKTOP_VERSION 17#ifndef DESKTOP_VERSION
18#include <qpe/global.h> 18#include <qpe/global.h>
19#include <qpe/qpemenubar.h> 19#include <qpe/qpemenubar.h>
20#include <qpe/qpetoolbar.h> 20#include <qpe/qpetoolbar.h>
21#include <qpe/resource.h> 21#include <qpe/resource.h>
22#include <qpe/qpeapplication.h> 22#include <qpe/qpeapplication.h>
23#include <qtopia/alarmserver.h> 23#include <qtopia/alarmserver.h>
24#include <qtopia/qcopenvelope_qws.h> 24#include <qtopia/qcopenvelope_qws.h>
25#else 25#else
26#include <qmenubar.h> 26#include <qmenubar.h>
27#include <qtoolbar.h> 27#include <qtoolbar.h>
28#include <qapplication.h> 28#include <qapplication.h>
29//#include <resource.h> 29//#include <resource.h>
30 30
31#endif 31#endif
32#include <libkcal/calendarlocal.h> 32#include <libkcal/calendarlocal.h>
33#include <libkcal/todo.h> 33#include <libkcal/todo.h>
34#include <libkdepim/ksyncprofile.h> 34#include <libkdepim/ksyncprofile.h>
35#include <libkdepim/kincidenceformatter.h> 35#include <libkdepim/kincidenceformatter.h>
36 36
37#include "calendarview.h" 37#include "calendarview.h"
38#include "koviewmanager.h" 38#include "koviewmanager.h"
39#include "datenavigator.h" 39#include "datenavigator.h"
40#include "koagendaview.h" 40#include "koagendaview.h"
41#include "koagenda.h" 41#include "koagenda.h"
42#include "kodialogmanager.h" 42#include "kodialogmanager.h"
43#include "kdialogbase.h" 43#include "kdialogbase.h"
44#include "kstandarddirs.h" 44#include "kstandarddirs.h"
45#include "koprefs.h" 45#include "koprefs.h"
46#include "kfiledialog.h" 46#include "kfiledialog.h"
47#include "koglobals.h" 47#include "koglobals.h"
48#include "kglobal.h" 48#include "kglobal.h"
49#include "klocale.h" 49#include "klocale.h"
50#include "kconfig.h" 50#include "kconfig.h"
51#include "simplealarmclient.h" 51#include "simplealarmclient.h"
52using namespace KCal; 52using namespace KCal;
53#ifndef _WIN32_ 53#ifndef _WIN32_
54#include <unistd.h> 54#include <unistd.h>
55#else 55#else
56#include "koimportoldialog.h" 56#include "koimportoldialog.h"
57#endif 57#endif
58#include "mainwindow.h" 58#include "mainwindow.h"
59 59
60int globalFlagBlockStartup; 60int globalFlagBlockStartup;
61MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : 61MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
62 QMainWindow( parent, name ) 62 QMainWindow( parent, name )
63{ 63{
64 64
65#ifdef DESKTOP_VERSION 65#ifdef DESKTOP_VERSION
66 setFont( QFont("Arial"), 14 ); 66 setFont( QFont("Arial"), 14 );
67#endif 67#endif
68 68
69 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; 69 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
70 QString confFile = locateLocal("config","korganizerrc"); 70 QString confFile = locateLocal("config","korganizerrc");
71 QFileInfo finf ( confFile ); 71 QFileInfo finf ( confFile );
72 bool showWarning = !finf.exists(); 72 bool showWarning = !finf.exists();
73 setIcon(SmallIcon( "ko24" ) ); 73 setIcon(SmallIcon( "ko24" ) );
74 mBlockAtStartup = true; 74 mBlockAtStartup = true;
75 mFlagKeyPressed = false; 75 mFlagKeyPressed = false;
76 setCaption("KOrganizer/Pi"); 76 setCaption("KOrganizer/Pi");
77 KOPrefs *p = KOPrefs::instance(); 77 KOPrefs *p = KOPrefs::instance();
78 // if ( QApplication::desktop()->height() > 480 ) { 78 // if ( QApplication::desktop()->height() > 480 ) {
79// if ( p->mHourSize == 4 ) 79// if ( p->mHourSize == 4 )
80// p->mHourSize = 6; 80// p->mHourSize = 6;
81// } 81// }
82 if ( p->mHourSize > 18 ) 82 if ( p->mHourSize > 18 )
83 p->mHourSize = 18; 83 p->mHourSize = 18;
84 QMainWindow::ToolBarDock tbd; 84 QMainWindow::ToolBarDock tbd;
85 if ( p->mToolBarHor ) { 85 if ( p->mToolBarHor ) {
86 if ( p->mToolBarUp ) 86 if ( p->mToolBarUp )
87 tbd = Bottom; 87 tbd = Bottom;
88 else 88 else
89 tbd = Top; 89 tbd = Top;
90 } 90 }
91 else { 91 else {
92 if ( p->mToolBarUp ) 92 if ( p->mToolBarUp )
93 tbd = Right; 93 tbd = Right;
94 else 94 else
95 tbd = Left; 95 tbd = Left;
96 } 96 }
97 if ( KOPrefs::instance()->mUseAppColors ) 97 if ( KOPrefs::instance()->mUseAppColors )
98 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 98 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
99 globalFlagBlockStartup = 1; 99 globalFlagBlockStartup = 1;
100 iconToolBar = new QPEToolBar( this ); 100 iconToolBar = new QPEToolBar( this );
101 addToolBar (iconToolBar , tbd ); 101 addToolBar (iconToolBar , tbd );
102 mBlockSaveFlag = false; 102 mBlockSaveFlag = false;
103 mCalendarModifiedFlag = false; 103 mCalendarModifiedFlag = false;
104 104
105 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); 105 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
106 splash->setAlignment ( AlignCenter ); 106 splash->setAlignment ( AlignCenter );
107 setCentralWidget( splash ); 107 setCentralWidget( splash );
108#ifndef DESKTOP_VERSION 108#ifndef DESKTOP_VERSION
109 showMaximized(); 109 showMaximized();
110#endif 110#endif
111 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); 111 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
112 setDefaultPreferences(); 112 setDefaultPreferences();
113 mCalendar = new CalendarLocal(); 113 mCalendar = new CalendarLocal();
114 mView = new CalendarView( mCalendar, this,"mCalendar " ); 114 mView = new CalendarView( mCalendar, this,"mCalendar " );
115 mView->hide(); 115 mView->hide();
116 //mView->resize(splash->size() ); 116 //mView->resize(splash->size() );
117 initActions(); 117 initActions();
118#ifndef DESKTOP_VERSION 118#ifndef DESKTOP_VERSION
119 iconToolBar->show(); 119 iconToolBar->show();
120 qApp->processEvents(); 120 qApp->processEvents();
121#endif 121#endif
122 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); 122 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
123 int vh = height() ; 123 int vh = height() ;
124 int vw = width(); 124 int vw = width();
125 //qDebug("Toolbar hei %d ",iconToolBar->height() ); 125 //qDebug("Toolbar hei %d ",iconToolBar->height() );
126 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 126 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
127 vh -= iconToolBar->height(); 127 vh -= iconToolBar->height();
128 } else { 128 } else {
129 vw -= iconToolBar->height(); 129 vw -= iconToolBar->height();
130 } 130 }
131 //mView->setMaximumSize( splash->size() ); 131 //mView->setMaximumSize( splash->size() );
132 //mView->resize( splash->size() ); 132 //mView->resize( splash->size() );
133 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 133 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
134 mView->readSettings(); 134 mView->readSettings();
135 bool oldOpened = false; 135 bool oldOpened = false;
136 bool newFile = false; 136 bool newFile = false;
137 if( !QFile::exists( defaultFileName() ) ) { 137 if( !QFile::exists( defaultFileName() ) ) {
138 QFileInfo finfo ( defaultFileName() ); 138 QFileInfo finfo ( defaultFileName() );
139 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); 139 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
140 qDebug("oldfile %s ", oldFile.latin1()); 140 qDebug("oldfile %s ", oldFile.latin1());
141 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; 141 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n";
142 finfo.setFile( oldFile ); 142 finfo.setFile( oldFile );
143 if (finfo.exists() ) { 143 if (finfo.exists() ) {
144 KMessageBox::information( this, message); 144 KMessageBox::information( this, message);
145 mView->openCalendar( oldFile ); 145 mView->openCalendar( oldFile );
146 qApp->processEvents(); 146 qApp->processEvents();
147 } else { 147 } else {
148 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); 148 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
149 finfo.setFile( oldFile ); 149 finfo.setFile( oldFile );
150 if (finfo.exists() ) { 150 if (finfo.exists() ) {
151 KMessageBox::information( this, message); 151 KMessageBox::information( this, message);
152 mView->openCalendar( oldFile ); 152 mView->openCalendar( oldFile );
153 qApp->processEvents(); 153 qApp->processEvents();
154 } 154 }
155 } 155 }
156 mView->saveCalendar( defaultFileName() ); 156 mView->saveCalendar( defaultFileName() );
157 newFile = true; 157 newFile = true;
158 } 158 }
159 159
160 QTime neededSaveTime = QDateTime::currentDateTime().time(); 160 QTime neededSaveTime = QDateTime::currentDateTime().time();
161 if ( ! oldOpened ) 161 if ( ! oldOpened )
162 mView->openCalendar( defaultFileName() ); 162 mView->openCalendar( defaultFileName() );
163 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 163 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
164 qDebug("KO: Calendar loading time: %d ms",msNeeded ); 164 qDebug("KO: Calendar loading time: %d ms",msNeeded );
165 165
166 if ( KOPrefs::instance()->mLanguageChanged ) { 166 if ( KOPrefs::instance()->mLanguageChanged ) {
167 KOPrefs::instance()->setCategoryDefaults(); 167 KOPrefs::instance()->setCategoryDefaults();
168 int count = mView->addCategories(); 168 int count = mView->addCategories();
169 KOPrefs::instance()->mLanguageChanged = false; 169 KOPrefs::instance()->mLanguageChanged = false;
170 } 170 }
171 processIncidenceSelection( 0 ); 171 processIncidenceSelection( 0 );
172 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), 172 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
173 SLOT( processIncidenceSelection( Incidence * ) ) ); 173 SLOT( processIncidenceSelection( Incidence * ) ) );
174 connect( mView, SIGNAL( modifiedChanged( bool ) ), 174 connect( mView, SIGNAL( modifiedChanged( bool ) ),
175 SLOT( slotModifiedChanged( bool ) ) ); 175 SLOT( slotModifiedChanged( bool ) ) );
176 176
177 177
178 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); 178 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
179 mView->setModified( false ); 179 mView->setModified( false );
180 mBlockAtStartup = false; 180 mBlockAtStartup = false;
181 mView->setModified( false ); 181 mView->setModified( false );
182 setCentralWidget( mView ); 182 setCentralWidget( mView );
183 globalFlagBlockStartup = 0; 183 globalFlagBlockStartup = 0;
184 mView->show(); 184 mView->show();
185 delete splash; 185 delete splash;
186 if ( newFile ) 186 if ( newFile )
187 mView->updateConfig(); 187 mView->updateConfig();
188 // qApp->processEvents(); 188 // qApp->processEvents();
189 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 189 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
190 fillSyncMenu(); 190 fillSyncMenu();
191 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); 191 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
192 if ( showWarning ) { 192 if ( showWarning ) {
193 KMessageBox::information( this, 193 KMessageBox::information( this,
194 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); 194 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information");
195 qApp->processEvents(); 195 qApp->processEvents();
196 mView->dialogManager()->showSyncOptions(); 196 mView->dialogManager()->showSyncOptions();
197 } 197 }
198} 198}
199MainWindow::~MainWindow() 199MainWindow::~MainWindow()
200{ 200{
201 //qDebug("MainWindow::~MainWindow() "); 201 //qDebug("MainWindow::~MainWindow() ");
202 //save toolbar location 202 //save toolbar location
203 203
204 delete mCalendar; 204 delete mCalendar;
205 delete KOPrefs::instance(); 205 delete KOPrefs::instance();
206 delete KIncidenceFormatter::instance(); 206 delete KIncidenceFormatter::instance();
207 207
208 208
209} 209}
210void MainWindow::closeEvent( QCloseEvent* ce ) 210void MainWindow::closeEvent( QCloseEvent* ce )
211{ 211{
212 212
213 213
214 214
215 if ( ! KOPrefs::instance()->mAskForQuit ) { 215 if ( ! KOPrefs::instance()->mAskForQuit ) {
216 saveOnClose(); 216 saveOnClose();
217 ce->accept(); 217 ce->accept();
218 return; 218 return;
219 219
220 } 220 }
221 221
222 switch( QMessageBox::information( this, "KO/Pi", 222 switch( QMessageBox::information( this, "KO/Pi",
223 i18n("Do you really want\nto close KO/Pi?"), 223 i18n("Do you really want\nto close KO/Pi?"),
224 i18n("Close"), i18n("No"), 224 i18n("Close"), i18n("No"),
225 0, 0 ) ) { 225 0, 0 ) ) {
226 case 0: 226 case 0:
227 saveOnClose(); 227 saveOnClose();
228 ce->accept(); 228 ce->accept();
229 break; 229 break;
230 case 1: 230 case 1:
231 ce->ignore(); 231 ce->ignore();
232 break; 232 break;
233 case 2: 233 case 2:
234 234
235 default: 235 default:
236 break; 236 break;
237 } 237 }
238 238
239 239
240} 240}
241 241
242void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) 242void MainWindow::recieve( const QCString& cmsg, const QByteArray& data )
243{ 243{
244 QDataStream stream( data, IO_ReadOnly ); 244 QDataStream stream( data, IO_ReadOnly );
245 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); 245 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" );
246 //QString datamess; 246 //QString datamess;
247 //qDebug("message "); 247 //qDebug("message ");
248 qDebug("KO: QCOP message received: %s ", cmsg.data() ); 248 qDebug("KO: QCOP message received: %s ", cmsg.data() );
249 if ( cmsg == "-writeFile" ) { 249 if ( cmsg == "-writeFile" ) {
250 // I made from the "-writeFile" an "-writeAlarm" 250 // I made from the "-writeFile" an "-writeAlarm"
251 mView->viewManager()->showWhatsNextView(); 251 mView->viewManager()->showWhatsNextView();
252 mCalendar->checkAlarmForIncidence( 0, true); 252 mCalendar->checkAlarmForIncidence( 0, true);
253 showMaximized(); 253 showMaximized();
254 raise(); 254 raise();
255 return; 255 return;
256 256
257 } 257 }
258 if ( cmsg == "-writeFileSilent" ) { 258 if ( cmsg == "-writeFileSilent" ) {
259 // I made from the "-writeFile" an "-writeAlarm" 259 // I made from the "-writeFile" an "-writeAlarm"
260 // mView->viewManager()->showWhatsNextView(); 260 // mView->viewManager()->showWhatsNextView();
261 mCalendar->checkAlarmForIncidence( 0, true); 261 mCalendar->checkAlarmForIncidence( 0, true);
262 //showMaximized(); 262 //showMaximized();
263 //raise(); 263 //raise();
264 hide(); 264 hide();
265 return; 265 return;
266 } 266 }
267 if ( cmsg == "-newCountdown" ) { 267 if ( cmsg == "-newCountdown" ) {
268 qDebug("newCountdown "); 268 qDebug("newCountdown ");
269 269
270 } 270 }
271 QString msg ; 271 QString msg ;
272 QString allmsg = cmsg; 272 QString allmsg = cmsg;
273 while ( allmsg.length() > 0 ) { 273 while ( allmsg.length() > 0 ) {
274 int nextC = allmsg.find( "-", 1 ); 274 int nextC = allmsg.find( "-", 1 );
275 if ( nextC == -1 ) { 275 if ( nextC == -1 ) {
276 msg = allmsg; 276 msg = allmsg;
277 allmsg = ""; 277 allmsg = "";
278 } else{ 278 } else{
279 msg = allmsg.left( nextC ); 279 msg = allmsg.left( nextC );
280 allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); 280 allmsg = allmsg.mid( nextC, allmsg.length()-nextC );
281 } 281 }
282 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); 282 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() );
283 if ( msg == "-newEvent" ) { 283 if ( msg == "-newEvent" ) {
284 mView->newEvent(); 284 mView->newEvent();
285 } 285 }
286 if ( msg == "-newTodo" ) { 286 if ( msg == "-newTodo" ) {
287 mView->newTodo(); 287 mView->newTodo();
288 288
289 } 289 }
290 if ( msg == "-showWN" ) { 290 if ( msg == "-showWN" ) {
291 mView->viewManager()->showWhatsNextView(); 291 mView->viewManager()->showWhatsNextView();
292 } 292 }
293 if ( msg == "-showTodo" ) { 293 if ( msg == "-showTodo" ) {
294 mView->viewManager()->showTodoView(); 294 mView->viewManager()->showTodoView();
295 } 295 }
296 if ( msg == "-showList" ) { 296 if ( msg == "-showList" ) {
297 mView->viewManager()->showListView(); 297 mView->viewManager()->showListView();
298 } 298 }
299 else if ( msg == "-showDay" ) { 299 else if ( msg == "-showDay" ) {
300 mView->viewManager()->showDayView(); 300 mView->viewManager()->showDayView();
301 } 301 }
302 else if ( msg == "-showWWeek" ) { 302 else if ( msg == "-showWWeek" ) {
303 mView->viewManager()->showWorkWeekView(); 303 mView->viewManager()->showWorkWeekView();
304 } 304 }
305 else if ( msg == "-ringSync" ) { 305 else if ( msg == "-ringSync" ) {
306 multiSync( false ); 306 multiSync( false );
307 } 307 }
308 else if ( msg == "-showWeek" ) { 308 else if ( msg == "-showWeek" ) {
309 mView->viewManager()->showWeekView(); 309 mView->viewManager()->showWeekView();
310 } 310 }
311 else if ( msg == "-showTodo" ) { 311 else if ( msg == "-showTodo" ) {
312 mView->viewManager()->showTodoView(); 312 mView->viewManager()->showTodoView();
313 } 313 }
314 else if ( msg == "-showJournal" ) { 314 else if ( msg == "-showJournal" ) {
315 mView->dateNavigator()->selectDates( 1 ); 315 mView->dateNavigator()->selectDates( 1 );
316 mView->dateNavigator()->selectToday(); 316 mView->dateNavigator()->selectToday();
317 mView->viewManager()->showJournalView(); 317 mView->viewManager()->showJournalView();
318 } 318 }
319 else if ( msg == "-showKO" ) { 319 else if ( msg == "-showKO" ) {
320 mView->viewManager()->showNextXView(); 320 mView->viewManager()->showNextXView();
321 } 321 }
322 else if ( msg == "-showWNext" || msg == "nextView()" ) { 322 else if ( msg == "-showWNext" || msg == "nextView()" ) {
323 mView->viewManager()->showWhatsNextView(); 323 mView->viewManager()->showWhatsNextView();
324 } 324 }
325 else if ( msg == "-showNextXView" ) { 325 else if ( msg == "-showNextXView" ) {
326 mView->viewManager()->showNextXView(); 326 mView->viewManager()->showNextXView();
327 } 327 }
328 328
329 329
330 } 330 }
331 331
332 showMaximized(); 332 showMaximized();
333 raise(); 333 raise();
334} 334}
335 335
336QPixmap MainWindow::loadPixmap( QString name ) 336QPixmap MainWindow::loadPixmap( QString name )
337{ 337{
338 return SmallIcon( name ); 338 return SmallIcon( name );
339 339
340} 340}
341void MainWindow::initActions() 341void MainWindow::initActions()
342{ 342{
343 //KOPrefs::instance()->mShowFullMenu 343 //KOPrefs::instance()->mShowFullMenu
344 iconToolBar->clear(); 344 iconToolBar->clear();
345 KOPrefs *p = KOPrefs::instance(); 345 KOPrefs *p = KOPrefs::instance();
346 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); 346 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar );
347 347
348 QPopupMenu *viewMenu = new QPopupMenu( this ); 348 QPopupMenu *viewMenu = new QPopupMenu( this );
349 QPopupMenu *actionMenu = new QPopupMenu( this ); 349 QPopupMenu *actionMenu = new QPopupMenu( this );
350 QPopupMenu *importMenu = new QPopupMenu( this ); 350 QPopupMenu *importMenu = new QPopupMenu( this );
351 351
352 syncMenu = new QPopupMenu( this ); 352 syncMenu = new QPopupMenu( this );
353 configureAgendaMenu = new QPopupMenu( this ); 353 configureAgendaMenu = new QPopupMenu( this );
354 configureToolBarMenu = new QPopupMenu( this ); 354 configureToolBarMenu = new QPopupMenu( this );
355 QPopupMenu *helpMenu = new QPopupMenu( this ); 355 QPopupMenu *helpMenu = new QPopupMenu( this );
356 if ( KOPrefs::instance()->mShowFullMenu ) { 356 if ( KOPrefs::instance()->mShowFullMenu ) {
357 QMenuBar *menuBar1; 357 QMenuBar *menuBar1;
358 menuBar1 = menuBar(); 358 menuBar1 = menuBar();
359 menuBar1->insertItem( i18n("File"), importMenu ); 359 menuBar1->insertItem( i18n("File"), importMenu );
360 menuBar1->insertItem( i18n("View"), viewMenu ); 360 menuBar1->insertItem( i18n("View"), viewMenu );
361 menuBar1->insertItem( i18n("Actions"), actionMenu ); 361 menuBar1->insertItem( i18n("Actions"), actionMenu );
362 menuBar1->insertItem( i18n("Synchronize"), syncMenu ); 362 menuBar1->insertItem( i18n("Synchronize"), syncMenu );
363 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 363 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu );
364 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); 364 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu );
365 menuBar1->insertItem( i18n("Help"), helpMenu ); 365 menuBar1->insertItem( i18n("Help"), helpMenu );
366 } else { 366 } else {
367 QPEMenuBar *menuBar1; 367 QPEMenuBar *menuBar1;
368 menuBar1 = new QPEMenuBar( iconToolBar ); 368 menuBar1 = new QPEMenuBar( iconToolBar );
369 QPopupMenu *menuBar = new QPopupMenu( this ); 369 QPopupMenu *menuBar = new QPopupMenu( this );
370 menuBar1->insertItem( i18n("ME"), menuBar); 370 menuBar1->insertItem( i18n("ME"), menuBar);
371 menuBar->insertItem( i18n("File"), importMenu ); 371 menuBar->insertItem( i18n("File"), importMenu );
372 menuBar->insertItem( i18n("View"), viewMenu ); 372 menuBar->insertItem( i18n("View"), viewMenu );
373 menuBar->insertItem( i18n("Actions"), actionMenu ); 373 menuBar->insertItem( i18n("Actions"), actionMenu );
374 menuBar->insertItem( i18n("Synchronize"), syncMenu ); 374 menuBar->insertItem( i18n("Synchronize"), syncMenu );
375 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 375 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu );
376 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); 376 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu );
377 menuBar->insertItem( i18n("Help"), helpMenu ); 377 menuBar->insertItem( i18n("Help"), helpMenu );
378 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); 378 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() );
379 menuBar1->setMaximumSize( menuBar1->sizeHint( )); 379 menuBar1->setMaximumSize( menuBar1->sizeHint( ));
380 } 380 }
381 connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) ); 381 connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) );
382 // ****************** 382 // ******************
383 QAction *action; 383 QAction *action;
384 QIconSet icon; 384 QIconSet icon;
385 // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); 385 // QPopupMenu *configureMenu= new QPopupMenu( menuBar );
386 configureToolBarMenu->setCheckable( true ); 386 configureToolBarMenu->setCheckable( true );
387 387
388 QString pathString = ""; 388 QString pathString = "";
389 if ( !p->mToolBarMiniIcons ) { 389 if ( !p->mToolBarMiniIcons ) {
390 if ( QApplication::desktop()->width() < 480 ) 390 if ( QApplication::desktop()->width() < 480 )
391 pathString += "icons16/"; 391 pathString += "icons16/";
392 } else 392 } else
393 pathString += "iconsmini/"; 393 pathString += "iconsmini/";
394 configureAgendaMenu->setCheckable( true ); 394 configureAgendaMenu->setCheckable( true );
395 configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 ); 395 configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 );
396 configureAgendaMenu->insertSeparator(); 396 configureAgendaMenu->insertSeparator();
397 configureAgendaMenu->insertItem(i18n("Tiny"), 4 ); 397 configureAgendaMenu->insertItem(i18n("Tiny"), 4 );
398 configureAgendaMenu->insertItem(i18n("Small"), 6 ); 398 configureAgendaMenu->insertItem(i18n("Small"), 6 );
399 configureAgendaMenu->insertItem(i18n("Medium"), 8 ); 399 configureAgendaMenu->insertItem(i18n("Medium"), 8 );
400 configureAgendaMenu->insertItem(i18n("Normal"), 10 ); 400 configureAgendaMenu->insertItem(i18n("Normal"), 10 );
401 configureAgendaMenu->insertItem(i18n("Large"), 12 ); 401 configureAgendaMenu->insertItem(i18n("Large"), 12 );
402 configureAgendaMenu->insertItem(i18n("Big"), 14 ); 402 configureAgendaMenu->insertItem(i18n("Big"), 14 );
403 configureAgendaMenu->insertItem(i18n("Bigger"), 16 ); 403 configureAgendaMenu->insertItem(i18n("Bigger"), 16 );
404 configureAgendaMenu->insertItem(i18n("Biggest"), 18 ); 404 configureAgendaMenu->insertItem(i18n("Biggest"), 18 );
405 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); 405 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu );
406 406
407 icon = loadPixmap( pathString + "configure" ); 407 icon = loadPixmap( pathString + "configure" );
408 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); 408 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this );
409 action->addTo( actionMenu ); 409 action->addTo( actionMenu );
410 connect( action, SIGNAL( activated() ), 410 connect( action, SIGNAL( activated() ),
411 mView, SLOT( edit_options() ) ); 411 mView, SLOT( edit_options() ) );
412 actionMenu->insertSeparator(); 412 actionMenu->insertSeparator();
413 icon = loadPixmap( pathString + "newevent" ); 413 icon = loadPixmap( pathString + "newevent" );
414 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); 414 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 );
415 configureToolBarMenu->insertSeparator(); 415 configureToolBarMenu->insertSeparator();
416 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); 416 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 );
417 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); 417 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this );
418 ne_action->addTo( actionMenu ); 418 ne_action->addTo( actionMenu );
419 connect( ne_action, SIGNAL( activated() ), 419 connect( ne_action, SIGNAL( activated() ),
420 mView, SLOT( newEvent() ) ); 420 mView, SLOT( newEvent() ) );
421 icon = loadPixmap( pathString + "newtodo" ); 421 icon = loadPixmap( pathString + "newtodo" );
422 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); 422 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 );
423 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); 423 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this );
424 nt_action->addTo( actionMenu ); 424 nt_action->addTo( actionMenu );
425 connect( nt_action, SIGNAL( activated() ), 425 connect( nt_action, SIGNAL( activated() ),
426 mView, SLOT( newTodo() ) ); 426 mView, SLOT( newTodo() ) );
427 icon = loadPixmap( pathString + "navi" ); 427 icon = loadPixmap( pathString + "navi" );
428 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); 428 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this );
429 action->addTo( viewMenu ); 429 action->addTo( viewMenu );
430 connect( action, SIGNAL( activated() ), 430 connect( action, SIGNAL( activated() ),
431 mView, SLOT( toggleDateNavigatorWidget() ) ); 431 mView, SLOT( toggleDateNavigatorWidget() ) );
432 icon = loadPixmap( pathString + "filter" ); 432 icon = loadPixmap( pathString + "filter" );
433 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); 433 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this );
434 action->addTo( viewMenu ); 434 action->addTo( viewMenu );
435 connect( action, SIGNAL( activated() ), 435 connect( action, SIGNAL( activated() ),
436 mView, SLOT( toggleFilter() ) ); 436 mView, SLOT( toggleFilter() ) );
437 437
438 438
439 viewMenu->insertSeparator(); 439 viewMenu->insertSeparator();
440 icon = loadPixmap( pathString + "picker" ); 440 icon = loadPixmap( pathString + "picker" );
441 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); 441 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this );
442 action->addTo( viewMenu ); 442 action->addTo( viewMenu );
443 connect( action, SIGNAL( activated() ), 443 connect( action, SIGNAL( activated() ),
444 mView, SLOT( showDatePicker() ) ); 444 mView, SLOT( showDatePicker() ) );
445 action->addTo( iconToolBar ); 445 action->addTo( iconToolBar );
446 viewMenu->insertSeparator(); 446 viewMenu->insertSeparator();
447 icon = loadPixmap( pathString + "list" ); 447 icon = loadPixmap( pathString + "list" );
448 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); 448 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 );
449 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); 449 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this );
450 showlist_action->addTo( viewMenu ); 450 showlist_action->addTo( viewMenu );
451 connect( showlist_action, SIGNAL( activated() ), 451 connect( showlist_action, SIGNAL( activated() ),
452 mView->viewManager(), SLOT( showListView() ) ); 452 mView->viewManager(), SLOT( showListView() ) );
453 453
454 454
455 icon = loadPixmap( pathString + "day" ); 455 icon = loadPixmap( pathString + "day" );
456 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); 456 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 );
457 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); 457 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this );
458 day1_action->addTo( viewMenu ); 458 day1_action->addTo( viewMenu );
459 // action->addTo( toolBar ); 459 // action->addTo( toolBar );
460 connect( day1_action, SIGNAL( activated() ), 460 connect( day1_action, SIGNAL( activated() ),
461 mView->viewManager(), SLOT( showDayView() ) ); 461 mView->viewManager(), SLOT( showDayView() ) );
462 462
463 icon = loadPixmap( pathString + "workweek" ); 463 icon = loadPixmap( pathString + "workweek" );
464 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); 464 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 );
465 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); 465 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this );
466 day5_action->addTo( viewMenu ); 466 day5_action->addTo( viewMenu );
467 connect( day5_action, SIGNAL( activated() ), 467 connect( day5_action, SIGNAL( activated() ),
468 mView->viewManager(), SLOT( showWorkWeekView() ) ); 468 mView->viewManager(), SLOT( showWorkWeekView() ) );
469 469
470 icon = loadPixmap( pathString + "week" ); 470 icon = loadPixmap( pathString + "week" );
471 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); 471 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 );
472 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); 472 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this );
473 day7_action->addTo( viewMenu ); 473 day7_action->addTo( viewMenu );
474 connect( day7_action, SIGNAL( activated() ), 474 connect( day7_action, SIGNAL( activated() ),
475 mView->viewManager(), SLOT( showWeekView() ) ); 475 mView->viewManager(), SLOT( showWeekView() ) );
476 476
477 icon = loadPixmap( pathString + "month" ); 477 icon = loadPixmap( pathString + "month" );
478 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); 478 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 );
479 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); 479 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this );
480 month_action->addTo( viewMenu ); 480 month_action->addTo( viewMenu );
481 connect( month_action, SIGNAL( activated() ), 481 connect( month_action, SIGNAL( activated() ),
482 mView->viewManager(), SLOT( showMonthView() ) ); 482 mView->viewManager(), SLOT( showMonthView() ) );
483 483
484 icon = loadPixmap( pathString + "todo" ); 484 icon = loadPixmap( pathString + "todo" );
485 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); 485 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 );
486 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); 486 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this );
487 todoview_action->addTo( viewMenu ); 487 todoview_action->addTo( viewMenu );
488 connect( todoview_action, SIGNAL( activated() ), 488 connect( todoview_action, SIGNAL( activated() ),
489 mView->viewManager(), SLOT( showTodoView() ) ); 489 mView->viewManager(), SLOT( showTodoView() ) );
490 490
491 icon = loadPixmap( pathString + "journal" ); 491 icon = loadPixmap( pathString + "journal" );
492 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); 492 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 );
493 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); 493 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this );
494 viewjournal_action->addTo( viewMenu ); 494 viewjournal_action->addTo( viewMenu );
495 connect( viewjournal_action, SIGNAL( activated() ), 495 connect( viewjournal_action, SIGNAL( activated() ),
496 mView->viewManager(), SLOT( showJournalView() ) ); 496 mView->viewManager(), SLOT( showJournalView() ) );
497 497
498 icon = loadPixmap( pathString + "xdays" ); 498 icon = loadPixmap( pathString + "xdays" );
499 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 ); 499 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 );
500 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); 500 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this );
501 xdays_action->addTo( viewMenu ); 501 xdays_action->addTo( viewMenu );
502 connect( xdays_action, SIGNAL( activated() ), 502 connect( xdays_action, SIGNAL( activated() ),
503 mView->viewManager(), SLOT( showNextXView() ) ); 503 mView->viewManager(), SLOT( showNextXView() ) );
504 504
505 icon = loadPixmap( pathString + "whatsnext" ); 505 icon = loadPixmap( pathString + "whatsnext" );
506 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 ); 506 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 );
507 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); 507 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this );
508 whatsnext_action->addTo( viewMenu ); 508 whatsnext_action->addTo( viewMenu );
509 connect( whatsnext_action, SIGNAL( activated() ), 509 connect( whatsnext_action, SIGNAL( activated() ),
510 mView->viewManager(), SLOT( showWhatsNextView() ) ); 510 mView->viewManager(), SLOT( showWhatsNextView() ) );
511 511
512#if 0 512#if 0
513 action = new QAction( "view_timespan", "Time Span", 0, this ); 513 action = new QAction( "view_timespan", "Time Span", 0, this );
514 action->addTo( viewMenu ); 514 action->addTo( viewMenu );
515 connect( action, SIGNAL( activated() ), 515 connect( action, SIGNAL( activated() ),
516 mView->viewManager(), SLOT( showTimeSpanView() ) ); 516 mView->viewManager(), SLOT( showTimeSpanView() ) );
517#endif 517#endif
518 518
519 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, 519 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0,
520 this ); 520 this );
521 mNewSubTodoAction->addTo( actionMenu ); 521 mNewSubTodoAction->addTo( actionMenu );
522 connect( mNewSubTodoAction, SIGNAL( activated() ), 522 connect( mNewSubTodoAction, SIGNAL( activated() ),
523 mView, SLOT( newSubTodo() ) ); 523 mView, SLOT( newSubTodo() ) );
524 524
525 actionMenu->insertSeparator(); 525 actionMenu->insertSeparator();
526 526
527 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); 527 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this );
528 mShowAction->addTo( actionMenu ); 528 mShowAction->addTo( actionMenu );
529 connect( mShowAction, SIGNAL( activated() ), 529 connect( mShowAction, SIGNAL( activated() ),
530 mView, SLOT( showIncidence() ) ); 530 mView, SLOT( showIncidence() ) );
531 531
532 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); 532 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this );
533 mEditAction->addTo( actionMenu ); 533 mEditAction->addTo( actionMenu );
534 connect( mEditAction, SIGNAL( activated() ), 534 connect( mEditAction, SIGNAL( activated() ),
535 mView, SLOT( editIncidence() ) ); 535 mView, SLOT( editIncidence() ) );
536 536
537 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); 537 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this );
538 mDeleteAction->addTo( actionMenu ); 538 mDeleteAction->addTo( actionMenu );
539 connect( mDeleteAction, SIGNAL( activated() ), 539 connect( mDeleteAction, SIGNAL( activated() ),
540 mView, SLOT( deleteIncidence() ) ); 540 mView, SLOT( deleteIncidence() ) );
541 541
542 actionMenu->insertSeparator(); 542 actionMenu->insertSeparator();
543 543
544 action = new QAction( "purge_completed", i18n("Purge Completed"), 0, 544 action = new QAction( "purge_completed", i18n("Purge Completed"), 0,
545 this ); 545 this );
546 action->addTo( actionMenu ); 546 action->addTo( actionMenu );
547 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); 547 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) );
548 548
549 icon = loadPixmap( pathString + "search" ); 549 icon = loadPixmap( pathString + "search" );
550 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); 550 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this );
551 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4); 551 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4);
552 search_action->addTo( actionMenu ); 552 search_action->addTo( actionMenu );
553 connect( search_action, SIGNAL( activated() ), 553 connect( search_action, SIGNAL( activated() ),
554 mView->dialogManager(), SLOT( showSearchDialog() ) ); 554 mView->dialogManager(), SLOT( showSearchDialog() ) );
555 555
556 icon = loadPixmap( pathString + "today" ); 556 icon = loadPixmap( pathString + "today" );
557 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); 557 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130);
558 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); 558 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this );
559 today_action->addTo( actionMenu ); 559 today_action->addTo( actionMenu );
560 connect( today_action, SIGNAL( activated() ), 560 connect( today_action, SIGNAL( activated() ),
561 mView, SLOT( goToday() ) ); 561 mView, SLOT( goToday() ) );
562 562
563 if ( KOPrefs::instance()->mShowFullMenu ) { 563 if ( KOPrefs::instance()->mShowFullMenu ) {
564 actionMenu->insertSeparator(); 564 actionMenu->insertSeparator();
565 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); 565 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu );
566 566
567 } 567 }
568 // actionMenu->insertSeparator(); 568 // actionMenu->insertSeparator();
569 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, 569 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0,
570 this ); 570 this );
571 action->addTo( importMenu ); 571 action->addTo( importMenu );
572 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); 572 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) );
573 action = new QAction( "import_quick", i18n("Import last file"), 0, 573 action = new QAction( "import_quick", i18n("Import last file"), 0,
574 this ); 574 this );
575 action->addTo( importMenu ); 575 action->addTo( importMenu );
576 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); 576 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) );
577 importMenu->insertSeparator(); 577 importMenu->insertSeparator();
578 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, 578 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0,
579 this ); 579 this );
580 action->addTo( importMenu ); 580 action->addTo( importMenu );
581 connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); 581 connect( action, SIGNAL( activated() ), SLOT( importBday() ) );
582#ifndef DESKTOP_VERSION 582#ifndef DESKTOP_VERSION
583 importMenu->insertSeparator(); 583 importMenu->insertSeparator();
584 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, 584 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0,
585 this ); 585 this );
586 action->addTo( importMenu ); 586 action->addTo( importMenu );
587 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); 587 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) );
588#else 588#else
589#ifdef _WIN32_ 589#ifdef _WIN32_
590 importMenu->insertSeparator(); 590 importMenu->insertSeparator();
591 action = new QAction( "import_ol", i18n("Import from OL"), 0, 591 action = new QAction( "import_ol", i18n("Import from OL"), 0,
592 this ); 592 this );
593 action->addTo( importMenu ); 593 action->addTo( importMenu );
594 connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); 594 connect( action, SIGNAL( activated() ), SLOT( importOL() ) );
595#endif 595#endif
596#endif 596#endif
597 597
598 importMenu->insertSeparator(); 598 importMenu->insertSeparator();
599 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, 599 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0,
600 this ); 600 this );
601 action->addTo( importMenu ); 601 action->addTo( importMenu );
602 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); 602 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) );
603 603
604 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, 604 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0,
605 this ); 605 this );
606 action->addTo( importMenu ); 606 action->addTo( importMenu );
607 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); 607 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) );
608 608
609 importMenu->insertSeparator(); 609 importMenu->insertSeparator();
610 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, 610 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0,
611 this ); 611 this );
612 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); 612 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) );
613 importMenu->insertSeparator(); 613 importMenu->insertSeparator();
614 action = new QAction( "manage cat", i18n("Manage new categories..."), 0, 614 action = new QAction( "manage cat", i18n("Manage new categories..."), 0,
615 this ); 615 this );
616 action->addTo( importMenu ); 616 action->addTo( importMenu );
617 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); 617 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) );
618#ifndef DESKTOP_VERSION 618#ifndef DESKTOP_VERSION
619 importMenu->insertSeparator(); 619 importMenu->insertSeparator();
620 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, 620 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0,
621 this ); 621 this );
622 action->addTo( importMenu ); 622 action->addTo( importMenu );
623 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); 623 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) );
624 624
625 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, 625 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0,
626 this ); 626 this );
627 action->addTo( importMenu ); 627 action->addTo( importMenu );
628 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); 628 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) );
629#else 629#else
630 importMenu->insertSeparator(); 630 importMenu->insertSeparator();
631 icon = loadPixmap( pathString + "print" ); 631 icon = loadPixmap( pathString + "print" );
632 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); 632 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this );
633 action->addTo( importMenu ); 633 action->addTo( importMenu );
634 connect( action, SIGNAL( activated() ), 634 connect( action, SIGNAL( activated() ),
635 this, SLOT( printCal() ) ); 635 this, SLOT( printCal() ) );
636 636
637 icon = loadPixmap( pathString + "print" ); 637 icon = loadPixmap( pathString + "print" );
638 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); 638 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this );
639 action->addTo( importMenu ); 639 action->addTo( importMenu );
640 connect( action, SIGNAL( activated() ), 640 connect( action, SIGNAL( activated() ),
641 this, SLOT( printSel() ) ); 641 this, SLOT( printSel() ) );
642#endif 642#endif
643 importMenu->insertSeparator(); 643 importMenu->insertSeparator();
644 action = new QAction( "beam all", i18n("Save"), 0, 644 action = new QAction( "beam all", i18n("Save"), 0,
645 this ); 645 this );
646 action->addTo( importMenu ); 646 action->addTo( importMenu );
647 connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); 647 connect( action, SIGNAL( activated() ), this, SLOT( save() ) );
648 action = new QAction( "beam all", i18n("Exit (+save)"), 0, 648 action = new QAction( "beam all", i18n("Exit (+save)"), 0,
649 this ); 649 this );
650 action->addTo( importMenu ); 650 action->addTo( importMenu );
651 connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); 651 connect( action, SIGNAL( activated() ), this, SLOT( close() ) );
652 652
653 //menuBar->insertItem( "Configure",configureMenu ); 653 //menuBar->insertItem( "Configure",configureMenu );
654 //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); 654 //configureMenu->insertItem( "Toolbar",configureToolBarMenu );
655 icon = loadPixmap( "korganizer/korganizer" ); 655 icon = loadPixmap( "korganizer/korganizer" );
656 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); 656 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this );
657 action->addTo( helpMenu ); 657 action->addTo( helpMenu );
658 connect( action, SIGNAL( activated() ), 658 connect( action, SIGNAL( activated() ),
659 SLOT( keyBindings() ) ); 659 SLOT( keyBindings() ) );
660 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); 660 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this );
661 action->addTo( helpMenu ); 661 action->addTo( helpMenu );
662 connect( action, SIGNAL( activated() ), 662 connect( action, SIGNAL( activated() ),
663 SLOT( features() ) ); 663 SLOT( features() ) );
664 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); 664 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this );
665 action->addTo( helpMenu ); 665 action->addTo( helpMenu );
666 connect( action, SIGNAL( activated() ), 666 connect( action, SIGNAL( activated() ),
667 SLOT( aboutAutoSaving() ) ); 667 SLOT( aboutAutoSaving() ) );
668 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); 668 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this );
669 action->addTo( helpMenu ); 669 action->addTo( helpMenu );
670 connect( action, SIGNAL( activated() ), 670 connect( action, SIGNAL( activated() ),
671 SLOT( aboutKnownBugs() ) ); 671 SLOT( aboutKnownBugs() ) );
672 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); 672 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this );
673 action->addTo( helpMenu ); 673 action->addTo( helpMenu );
674 connect( action, SIGNAL( activated() ), 674 connect( action, SIGNAL( activated() ),
675 SLOT( usertrans() ) ); 675 SLOT( usertrans() ) );
676 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); 676 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this );
677 action->addTo( helpMenu ); 677 action->addTo( helpMenu );
678 connect( action, SIGNAL( activated() ), 678 connect( action, SIGNAL( activated() ),
679 SLOT( synchowto() ) ); 679 SLOT( synchowto() ) );
680 action = new QAction( "Whats New", i18n("What's new?"), 0,this ); 680 action = new QAction( "Whats New", i18n("What's new?"), 0,this );
681 action->addTo( helpMenu ); 681 action->addTo( helpMenu );
682 connect( action, SIGNAL( activated() ), 682 connect( action, SIGNAL( activated() ),
683 SLOT( whatsNew() ) ); 683 SLOT( whatsNew() ) );
684 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); 684 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this );
685 action->addTo( helpMenu ); 685 action->addTo( helpMenu );
686 connect( action, SIGNAL( activated() ), 686 connect( action, SIGNAL( activated() ),
687 SLOT( faq() ) ); 687 SLOT( faq() ) );
688 688
689 689
690 action = new QAction( "about", i18n("About..."), 0, this ); 690 action = new QAction( "about", i18n("About..."), 0, this );
691 action->addTo( helpMenu ); 691 action->addTo( helpMenu );
692 connect( action, SIGNAL( activated() ), 692 connect( action, SIGNAL( activated() ),
693 SLOT( about() ) ); 693 SLOT( about() ) );
694 //menuBar->insertSeparator(); 694 //menuBar->insertSeparator();
695 695
696 // ****************************************************** 696 // ******************************************************
697 // menubar icons 697 // menubar icons
698 698
699 699
700 iconToolBar->setHorizontalStretchable (true ); 700 iconToolBar->setHorizontalStretchable (true );
701 //menuBar->insertItem( iconToolBar ); 701 //menuBar->insertItem( iconToolBar );
702 //xdays_action 702 //xdays_action
703 if (p-> mShowIconNewEvent) 703 if (p-> mShowIconNewEvent)
704 ne_action->addTo( iconToolBar ); 704 ne_action->addTo( iconToolBar );
705 if (p->mShowIconNewTodo ) 705 if (p->mShowIconNewTodo )
706 nt_action->addTo( iconToolBar ); 706 nt_action->addTo( iconToolBar );
707 if (p-> mShowIconSearch) 707 if (p-> mShowIconSearch)
708 search_action->addTo( iconToolBar ); 708 search_action->addTo( iconToolBar );
709 if (p-> mShowIconNext) 709 if (p-> mShowIconNext)
710 whatsnext_action->addTo( iconToolBar ); 710 whatsnext_action->addTo( iconToolBar );
711 if (p-> mShowIconNextDays) 711 if (p-> mShowIconNextDays)
712 xdays_action->addTo( iconToolBar ); 712 xdays_action->addTo( iconToolBar );
713 if (p-> mShowIconList) 713 if (p-> mShowIconList)
714 showlist_action->addTo( iconToolBar ); 714 showlist_action->addTo( iconToolBar );
715 if (p-> mShowIconDay1) 715 if (p-> mShowIconDay1)
716 day1_action->addTo( iconToolBar ); 716 day1_action->addTo( iconToolBar );
717 if (p-> mShowIconDay5) 717 if (p-> mShowIconDay5)
718 day5_action->addTo( iconToolBar ); 718 day5_action->addTo( iconToolBar );
719 if (p-> mShowIconDay7) 719 if (p-> mShowIconDay7)
720 day7_action->addTo( iconToolBar ); 720 day7_action->addTo( iconToolBar );
721 if (p-> mShowIconMonth) 721 if (p-> mShowIconMonth)
722 month_action->addTo( iconToolBar ); 722 month_action->addTo( iconToolBar );
723 if (p-> mShowIconTodoview) 723 if (p-> mShowIconTodoview)
724 todoview_action->addTo( iconToolBar ); 724 todoview_action->addTo( iconToolBar );
725 if (p-> mShowIconJournal) 725 if (p-> mShowIconJournal)
726 viewjournal_action->addTo( iconToolBar ); 726 viewjournal_action->addTo( iconToolBar );
727 icon = loadPixmap( pathString + "2leftarrowB" ); 727 icon = loadPixmap( pathString + "2leftarrowB" );
728 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); 728 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14);
729 if (p-> mShowIconBackFast) { 729 if (p-> mShowIconBackFast) {
730 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); 730 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this );
731 connect( action, SIGNAL( activated() ), 731 connect( action, SIGNAL( activated() ),
732 mView, SLOT( goPreviousMonth() ) ); 732 mView, SLOT( goPreviousMonth() ) );
733 action->addTo( iconToolBar ); 733 action->addTo( iconToolBar );
734 } 734 }
735 icon = loadPixmap( pathString + "1leftarrowB" ); 735 icon = loadPixmap( pathString + "1leftarrowB" );
736 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); 736 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15);
737 if (p-> mShowIconBack) { 737 if (p-> mShowIconBack) {
738 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); 738 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this );
739 connect( action, SIGNAL( activated() ), 739 connect( action, SIGNAL( activated() ),
740 mView, SLOT( goPrevious() ) ); 740 mView, SLOT( goPrevious() ) );
741 action->addTo( iconToolBar ); 741 action->addTo( iconToolBar );
742 } 742 }
743 if (p-> mShowIconToday) 743 if (p-> mShowIconToday)
744 today_action->addTo( iconToolBar ); 744 today_action->addTo( iconToolBar );
745 icon = loadPixmap( pathString + "1rightarrowB" ); 745 icon = loadPixmap( pathString + "1rightarrowB" );
746 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); 746 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220);
747 if (p-> mShowIconForward) { 747 if (p-> mShowIconForward) {
748 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); 748 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this );
749 connect( action, SIGNAL( activated() ), 749 connect( action, SIGNAL( activated() ),
750 mView, SLOT( goNext() ) ); 750 mView, SLOT( goNext() ) );
751 action->addTo( iconToolBar ); 751 action->addTo( iconToolBar );
752 } 752 }
753 icon = loadPixmap( pathString + "2rightarrowB" ); 753 icon = loadPixmap( pathString + "2rightarrowB" );
754 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); 754 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230);
755 if (p-> mShowIconForwardFast) { 755 if (p-> mShowIconForwardFast) {
756 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); 756 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this );
757 connect( action, SIGNAL( activated() ), 757 connect( action, SIGNAL( activated() ),
758 mView, SLOT( goNextMonth() ) ); 758 mView, SLOT( goNextMonth() ) );
759 action->addTo( iconToolBar ); 759 action->addTo( iconToolBar );
760 } 760 }
761 761
762 762
763 configureToolBarMenu->insertItem(i18n("What's This?"), 300); 763 configureToolBarMenu->insertItem(i18n("What's This?"), 300);
764 764
765 if (p-> mShowIconNewEvent) 765 if (p-> mShowIconNewEvent)
766 configureToolBarMenu->setItemChecked( 10, true ); 766 configureToolBarMenu->setItemChecked( 10, true );
767 if (p->mShowIconNewTodo ) 767 if (p->mShowIconNewTodo )
768 configureToolBarMenu->setItemChecked( 20, true ); 768 configureToolBarMenu->setItemChecked( 20, true );
769 if (p-> mShowIconSearch) 769 if (p-> mShowIconSearch)
770 configureToolBarMenu->setItemChecked( 120, true ); 770 configureToolBarMenu->setItemChecked( 120, true );
771 if (p-> mShowIconList) 771 if (p-> mShowIconList)
772 configureToolBarMenu->setItemChecked( 30, true ); 772 configureToolBarMenu->setItemChecked( 30, true );
773 if (p-> mShowIconDay1) 773 if (p-> mShowIconDay1)
774 configureToolBarMenu->setItemChecked( 40, true ); 774 configureToolBarMenu->setItemChecked( 40, true );
775 if (p-> mShowIconDay5) 775 if (p-> mShowIconDay5)
776 configureToolBarMenu->setItemChecked( 50, true ); 776 configureToolBarMenu->setItemChecked( 50, true );
777 if (p-> mShowIconDay7) 777 if (p-> mShowIconDay7)
778 configureToolBarMenu->setItemChecked( 60, true ); 778 configureToolBarMenu->setItemChecked( 60, true );
779 if (p-> mShowIconMonth) 779 if (p-> mShowIconMonth)
780 configureToolBarMenu->setItemChecked( 70, true ); 780 configureToolBarMenu->setItemChecked( 70, true );
781 if (p-> mShowIconTodoview) 781 if (p-> mShowIconTodoview)
782 configureToolBarMenu->setItemChecked( 80, true ); 782 configureToolBarMenu->setItemChecked( 80, true );
783 if (p-> mShowIconBackFast) 783 if (p-> mShowIconBackFast)
784 configureToolBarMenu->setItemChecked( 200, true ); 784 configureToolBarMenu->setItemChecked( 200, true );
785 if (p-> mShowIconBack) 785 if (p-> mShowIconBack)
786 configureToolBarMenu->setItemChecked( 210, true ); 786 configureToolBarMenu->setItemChecked( 210, true );
787 if (p-> mShowIconToday) 787 if (p-> mShowIconToday)
788 configureToolBarMenu->setItemChecked( 130, true ); 788 configureToolBarMenu->setItemChecked( 130, true );
789 if (p-> mShowIconForward) 789 if (p-> mShowIconForward)
790 configureToolBarMenu->setItemChecked( 220, true ); 790 configureToolBarMenu->setItemChecked( 220, true );
791 if (p-> mShowIconForwardFast) 791 if (p-> mShowIconForwardFast)
792 configureToolBarMenu->setItemChecked( 230, true ); 792 configureToolBarMenu->setItemChecked( 230, true );
793 if (p-> mShowIconNextDays) 793 if (p-> mShowIconNextDays)
794 configureToolBarMenu->setItemChecked( 100, true ); 794 configureToolBarMenu->setItemChecked( 100, true );
795 if (p-> mShowIconNext) 795 if (p-> mShowIconNext)
796 configureToolBarMenu->setItemChecked( 110, true ); 796 configureToolBarMenu->setItemChecked( 110, true );
797 if (p-> mShowIconJournal) 797 if (p-> mShowIconJournal)
798 configureToolBarMenu->setItemChecked( 90, true ); 798 configureToolBarMenu->setItemChecked( 90, true );
799 if (p-> mShowIconWhatsThis) 799 if (p-> mShowIconWhatsThis)
800 configureToolBarMenu->setItemChecked( 300, true ); 800 configureToolBarMenu->setItemChecked( 300, true );
801 801
802 QLabel* dummy = new QLabel( iconToolBar ); 802 QLabel* dummy = new QLabel( iconToolBar );
803 dummy->setBackgroundColor( iconToolBar->backgroundColor() ); 803 dummy->setBackgroundColor( iconToolBar->backgroundColor() );
804 if (!p-> mShowIconStretch) 804 if (!p-> mShowIconStretch)
805 iconToolBar->setStretchableWidget ( dummy ) ; 805 iconToolBar->setStretchableWidget ( dummy ) ;
806 else 806 else
807 configureToolBarMenu->setItemChecked( 5, true ); 807 configureToolBarMenu->setItemChecked( 5, true );
808 if (p-> mShowIconWhatsThis) 808 if (p-> mShowIconWhatsThis)
809 QWhatsThis::whatsThisButton ( iconToolBar ); 809 QWhatsThis::whatsThisButton ( iconToolBar );
810 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); 810 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) );
811 configureAgenda( p->mHourSize ); 811 configureAgenda( p->mHourSize );
812 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); 812 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) );
813} 813}
814void MainWindow::fillSyncMenu() 814void MainWindow::fillSyncMenu()
815{ 815{
816 syncMenu->clear(); 816 syncMenu->clear();
817 syncMenu->insertItem( i18n("Configure..."), 0 ); 817 syncMenu->insertItem( i18n("Configure..."), 0 );
818 syncMenu->insertSeparator(); 818 syncMenu->insertSeparator();
819 syncMenu->insertItem( i18n("Multiple sync"), 1 ); 819 syncMenu->insertItem( i18n("Multiple sync"), 1 );
820 syncMenu->insertSeparator(); 820 syncMenu->insertSeparator();
821 KConfig config ( locateLocal( "config","syncprofilesrc" ) ); 821 KConfig config ( locateLocal( "config","syncprofilesrc" ) );
822 config.setGroup("SyncProfiles"); 822 config.setGroup("SyncProfiles");
823 QStringList prof = config.readListEntry("SyncProfileNames"); 823 QStringList prof = config.readListEntry("SyncProfileNames");
824 824 KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined");
825 if ( prof.count() < 3 ) { 825 if ( prof.count() < 3 ) {
826 prof.clear(); 826 prof.clear();
827 prof << i18n("Sharp-DTM"); 827 prof << i18n("Sharp-DTM");
828 prof << i18n("Local file"); 828 prof << i18n("Local file");
829 prof << i18n("Last file"); 829 prof << i18n("Last file");
830 KSyncProfile* temp = new KSyncProfile (); 830 KSyncProfile* temp = new KSyncProfile ();
831 temp->setName( prof[0] ); 831 temp->setName( prof[0] );
832 temp->writeConfig(&config); 832 temp->writeConfig(&config);
833 temp->setName( prof[1] ); 833 temp->setName( prof[1] );
834 temp->writeConfig(&config); 834 temp->writeConfig(&config);
835 temp->setName( prof[2] ); 835 temp->setName( prof[2] );
836 temp->writeConfig(&config); 836 temp->writeConfig(&config);
837 config.setGroup("SyncProfiles");
838 config.writeEntry("SyncProfileNames",prof);
837 config.sync(); 839 config.sync();
838 delete temp; 840 delete temp;
839 } 841 }
840 KOPrefs::instance()->mSyncProfileNames = prof; 842 KOPrefs::instance()->mSyncProfileNames = prof;
841 int i; 843 int i;
842 for ( i = 0; i < prof.count(); ++i ) { 844 for ( i = 0; i < prof.count(); ++i ) {
843 845
844 syncMenu->insertItem( prof[i], 1000+i ); 846 syncMenu->insertItem( prof[i], 1000+i );
845 if ( i == 2 ) 847 if ( i == 2 )
846 syncMenu->insertSeparator(); 848 syncMenu->insertSeparator();
847 } 849 }
848 QDir app_dir; 850 QDir app_dir;
849 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { 851 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
850 syncMenu->setItemEnabled( false , 1000 ); 852 syncMenu->setItemEnabled( false , 1000 );
851 } 853 }
852} 854}
853 855
854int MainWindow::ringSync() 856int MainWindow::ringSync()
855{ 857{
856 int syncedProfiles = 0; 858 int syncedProfiles = 0;
857 int i; 859 int i;
858 QTime timer; 860 QTime timer;
859 KConfig *config = KOGlobals::config(); 861 KConfig *config = KOGlobals::config();
860 QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames; 862 QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames;
861 KSyncProfile* temp = new KSyncProfile (); 863 KSyncProfile* temp = new KSyncProfile ();
862 KOPrefs::instance()->mAskForPreferences = false; 864 KOPrefs::instance()->mAskForPreferences = false;
863 for ( i = 0; i < syncProfileNames.count(); ++i ) { 865 for ( i = 0; i < syncProfileNames.count(); ++i ) {
864 mCurrentSyncProfile = i; 866 mCurrentSyncProfile = i;
865 temp->setName(syncProfileNames[mCurrentSyncProfile]); 867 temp->setName(syncProfileNames[mCurrentSyncProfile]);
866 temp->readConfig(config); 868 temp->readConfig(config);
867 if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) { 869 if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) {
868 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); 870 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
869 ++syncedProfiles; 871 ++syncedProfiles;
870 // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 872 // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
871 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 873 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
872 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 874 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
873 KOPrefs::instance()->mShowSyncSummary = false; 875 KOPrefs::instance()->mShowSyncSummary = false;
874 mView->setSyncDevice(syncProfileNames[i] ); 876 mView->setSyncDevice(syncProfileNames[i] );
875 mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); 877 mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
876 if ( i == 0 ) { 878 if ( i == 0 ) {
877 syncSharp(); 879 syncSharp();
878 } else { 880 } else {
879 if ( temp->getIsLocalFileSync() ) { 881 if ( temp->getIsLocalFileSync() ) {
880 if ( syncWithFile( temp->getRemoteFileName( ), true ) ) 882 if ( syncWithFile( temp->getRemoteFileName( ), true ) )
881 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); 883 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName();
882 } else { 884 } else {
883 syncRemote( temp, false ); 885 syncRemote( temp, false );
884 886
885 } 887 }
886 } 888 }
887 timer.start(); 889 timer.start();
888 setCaption(i18n("Multiple sync in progress ... please wait!") ); 890 setCaption(i18n("Multiple sync in progress ... please wait!") );
889 while ( timer.elapsed () < 2000 ) { 891 while ( timer.elapsed () < 2000 ) {
890 qApp->processEvents(); 892 qApp->processEvents();
891#ifndef _WIN32_ 893#ifndef _WIN32_
892 sleep (1); 894 sleep (1);
893#endif 895#endif
894 } 896 }
895 897
896 } 898 }
897 899
898 } 900 }
899 delete temp; 901 delete temp;
900 return syncedProfiles; 902 return syncedProfiles;
901} 903}
902 904
903void MainWindow::multiSync( bool askforPrefs ) 905void MainWindow::multiSync( bool askforPrefs )
904{ 906{
905 if (mBlockSaveFlag) 907 if (mBlockSaveFlag)
906 return; 908 return;
907 mBlockSaveFlag = true; 909 mBlockSaveFlag = true;
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 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
909 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 911 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
910 question, 912 question,
911 i18n("Yes"), i18n("No"), 913 i18n("Yes"), i18n("No"),
912 0, 0 ) != 0 ) { 914 0, 0 ) != 0 ) {
913 mBlockSaveFlag = false; 915 mBlockSaveFlag = false;
914 setCaption(i18n("Aborted! Nothing synced!")); 916 setCaption(i18n("Aborted! Nothing synced!"));
915 return; 917 return;
916 } 918 }
917 mView->setSyncDevice(i18n("Multiple profiles") ); 919 mView->setSyncDevice(i18n("Multiple profiles") );
918 KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs; 920 KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs;
919 if ( askforPrefs ) { 921 if ( askforPrefs ) {
920 mView->edit_sync_options(); 922 mView->edit_sync_options();
921 KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs; 923 KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs;
922 } 924 }
923 setCaption(i18n("Multiple sync started.") ); 925 setCaption(i18n("Multiple sync started.") );
924 qApp->processEvents(); 926 qApp->processEvents();
925 int num = ringSync() ; 927 int num = ringSync() ;
926 if ( num > 1 ) 928 if ( num > 1 )
927 ringSync(); 929 ringSync();
928 mBlockSaveFlag = false; 930 mBlockSaveFlag = false;
929 if ( num ) 931 if ( num )
930 save(); 932 save();
931 if ( num ) 933 if ( num )
932 setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); 934 setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) );
933 else 935 else
934 setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 936 setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
935 return; 937 return;
936} 938}
937void MainWindow::slotSyncMenu( int action ) 939void MainWindow::slotSyncMenu( int action )
938{ 940{
939 //qDebug("syncaction %d ", action); 941 //qDebug("syncaction %d ", action);
940 if ( action == 0 ) { 942 if ( action == 0 ) {
941 943
942 confSync(); 944 confSync();
943 945
944 return; 946 return;
945 } 947 }
946 if ( action == 1 ) { 948 if ( action == 1 ) {
947 multiSync( true ); 949 multiSync( true );
948 return; 950 return;
949 } 951 }
950 952
951 if (mBlockSaveFlag) 953 if (mBlockSaveFlag)
952 return; 954 return;
953 mBlockSaveFlag = true; 955 mBlockSaveFlag = true;
954 mCurrentSyncProfile = action - 1000 ; 956 mCurrentSyncProfile = action - 1000 ;
955 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); 957 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] );
956 mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); 958 mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
957 KConfig *config = KOGlobals::config(); 959 KConfig *config = KOGlobals::config();
958 KSyncProfile* temp = new KSyncProfile (); 960 KSyncProfile* temp = new KSyncProfile ();
959 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 961 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
960 temp->readConfig(config); 962 temp->readConfig(config);
961 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 963 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
962 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); 964 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs();
963 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 965 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
964 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 966 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
965 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); 967 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync();
966 if ( action == 1000 ) { 968 if ( action == 1000 ) {
967 syncSharp(); 969 syncSharp();
968 970
969 } else if ( action == 1001 ) { 971 } else if ( action == 1001 ) {
970 syncLocalFile(); 972 syncLocalFile();
971 973
972 } else if ( action == 1002 ) { 974 } else if ( action == 1002 ) {
973 quickSyncLocalFile(); 975 quickSyncLocalFile();
974 976
975 } else if ( action >= 1003 ) { 977 } else if ( action >= 1003 ) {
976 if ( temp->getIsLocalFileSync() ) { 978 if ( temp->getIsLocalFileSync() ) {
977 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 979 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
978 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); 980 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName();
979 } else { 981 } else {
980 syncRemote( temp ); 982 syncRemote( temp );
981 983
982 } 984 }
983 } 985 }
984 delete temp; 986 delete temp;
985 mBlockSaveFlag = false; 987 mBlockSaveFlag = false;
986} 988}
987void MainWindow::setDefaultPreferences() 989void MainWindow::setDefaultPreferences()
988{ 990{
989 KOPrefs *p = KOPrefs::instance(); 991 KOPrefs *p = KOPrefs::instance();
990 992
991 p->mCompactDialogs = true; 993 p->mCompactDialogs = true;
992 p->mConfirm = true; 994 p->mConfirm = true;
993 // p->mEnableQuickTodo = false; 995 // p->mEnableQuickTodo = false;
994} 996}
995 997
996QString MainWindow::resourcePath() 998QString MainWindow::resourcePath()
997{ 999{
998 return KGlobal::iconLoader()->iconPath(); 1000 return KGlobal::iconLoader()->iconPath();
999} 1001}
1000 1002
1001void MainWindow::displayText( QString text ,QString cap ) 1003void MainWindow::displayText( QString text ,QString cap )
1002{ 1004{
1003 QDialog dia( this, "name", true ); ; 1005 QDialog dia( this, "name", true ); ;
1004 dia.setCaption( cap ); 1006 dia.setCaption( cap );
1005 QVBoxLayout* lay = new QVBoxLayout( &dia ); 1007 QVBoxLayout* lay = new QVBoxLayout( &dia );
1006 lay->setSpacing( 3 ); 1008 lay->setSpacing( 3 );
1007 lay->setMargin( 3 ); 1009 lay->setMargin( 3 );
1008 QTextBrowser tb ( &dia ); 1010 QTextBrowser tb ( &dia );
1009 lay->addWidget( &tb ); 1011 lay->addWidget( &tb );
1010 tb.setText( text ); 1012 tb.setText( text );
1011#ifdef DESKTOP_VERSION 1013#ifdef DESKTOP_VERSION
1012 dia.resize( 640, 480); 1014 dia.resize( 640, 480);
1013#else 1015#else
1014 dia.showMaximized(); 1016 dia.showMaximized();
1015#endif 1017#endif
1016 dia.exec(); 1018 dia.exec();
1017} 1019}
1018void MainWindow::displayFile( QString fn, QString cap ) 1020void MainWindow::displayFile( QString fn, QString cap )
1019{ 1021{
1020 QString fileName = resourcePath() + fn; 1022 QString fileName = resourcePath() + fn;
1021 QString text; 1023 QString text;
1022 QFile file( fileName ); 1024 QFile file( fileName );
1023 if (!file.open( IO_ReadOnly ) ) { 1025 if (!file.open( IO_ReadOnly ) ) {
1024 return ; 1026 return ;
1025 1027
1026 } 1028 }
1027 QTextStream ts( &file ); 1029 QTextStream ts( &file );
1028 text = ts.read(); 1030 text = ts.read();
1029 file.close(); 1031 file.close();
1030 displayText( text, cap); 1032 displayText( text, cap);
1031} 1033}
1032void MainWindow::features() 1034void MainWindow::features()
1033{ 1035{
1034 1036
1035 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); 1037 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") );
1036} 1038}
1037 1039
1038void MainWindow::usertrans() 1040void MainWindow::usertrans()
1039{ 1041{
1040 1042
1041 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); 1043 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") );
1042} 1044}
1043void MainWindow::synchowto() 1045void MainWindow::synchowto()
1044{ 1046{
1045 1047
1046 displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") ); 1048 displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") );
1047} 1049}
1048void MainWindow::faq() 1050void MainWindow::faq()
1049{ 1051{
1050 displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); 1052 displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") );
1051 1053
1052} 1054}
1053void MainWindow::whatsNew() 1055void MainWindow::whatsNew()
1054{ 1056{
1055 displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") ); 1057 displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") );
1056 1058
1057} 1059}
1058void MainWindow::about() 1060void MainWindow::about()
1059{ 1061{
1060 QString version; 1062 QString version;
1061#include <../version> 1063#include <../version>
1062 QMessageBox::about( this, i18n("About KOrganizer/Pi"), 1064 QMessageBox::about( this, i18n("About KOrganizer/Pi"),
1063 i18n("KOrganizer/Platform-independent\n") + 1065 i18n("KOrganizer/Platform-independent\n") +
1064 "(KO/Pi) " + version + " - " + 1066 "(KO/Pi) " + version + " - " +
1065 1067
1066#ifdef DESKTOP_VERSION 1068#ifdef DESKTOP_VERSION
1067 i18n("Desktop Edition\n") + 1069 i18n("Desktop Edition\n") +
1068#else 1070#else
1069 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + 1071 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") +
1070#endif 1072#endif
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 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") );
1072} 1074}
1073void MainWindow::keyBindings() 1075void MainWindow::keyBindings()
1074{ 1076{
1075 QString cap = i18n("Key bindings KOrganizer/Pi"); 1077 QString cap = i18n("Key bindings KOrganizer/Pi");
1076 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + 1078 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") +
1077 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ 1079 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+
1078 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + 1080 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") +
1079 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ 1081 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+
1080 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ 1082 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+
1081 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ 1083 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+
1082 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ 1084 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+
1083 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ 1085 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+
1084 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ 1086 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+
1085 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ 1087 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+
1086 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ 1088 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+
1087 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ 1089 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+
1088 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ 1090 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+
1089 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ 1091 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+
1090 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ 1092 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+
1091 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ 1093 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+
1092 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ 1094 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+
1093 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ 1095 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+
1094 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ 1096 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+
1095 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ 1097 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+
1096 i18n("<p><h3>In agenda view:</h3></p>\n") + 1098 i18n("<p><h3>In agenda view:</h3></p>\n") +
1097 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ 1099 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+
1098 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ 1100 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+
1099 i18n("<p><h3>In todo view:</h3></p>\n") + 1101 i18n("<p><h3>In todo view:</h3></p>\n") +
1100 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ 1102 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+
1101 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1103 i18n("<p><b>I</b>: Show info of current item+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</b>: Mark item as 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><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+
1104 i18n("<p><h3>In list view:</h3></p>\n") + 1106 i18n("<p><h3>In list view:</h3></p>\n") +
1105 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1107 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1106 i18n("<p><b>return</b>: Select item+one step down</p>\n")+ 1108 i18n("<p><b>return</b>: Select item+one step down</p>\n")+
1107 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ 1109 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+
1108 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ 1110 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+
1109 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ 1111 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+
1110 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ 1112 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+
1111 i18n("<p><h3>In event/todo viewer:</h3></p>\n") + 1113 i18n("<p><h3>In event/todo viewer:</h3></p>\n") +
1112 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ 1114 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+
1113 i18n("<p><b>A</b>: Show agenda view.</p>\n")+ 1115 i18n("<p><b>A</b>: Show agenda view.</p>\n")+
1114 i18n("<p><b>E</b>: Edit item</p>\n") + 1116 i18n("<p><b>E</b>: Edit item</p>\n") +
1115 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + 1117 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") +
1116 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + 1118 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") +
1117 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ 1119 i18n("<p><b>Cross</b>: Item cancelled.([c] 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>Red</b>: Alarm set.([a] 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>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+
1120 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ 1122 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+
1121 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ 1123 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+
1122 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + 1124 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") +
1123 i18n("<p><b>White</b>: Item readonly</p>\n"); 1125 i18n("<p><b>White</b>: Item readonly</p>\n");
1124 displayText( text, cap); 1126 displayText( text, cap);
1125 1127
1126} 1128}
1127void MainWindow::aboutAutoSaving() 1129void MainWindow::aboutAutoSaving()
1128{ 1130{
1129 QMessageBox* msg; 1131 QMessageBox* msg;
1130 msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), 1132 msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"),
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 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,
1132 QMessageBox::Ok, 1134 QMessageBox::Ok,
1133 QMessageBox::NoButton, 1135 QMessageBox::NoButton,
1134 QMessageBox::NoButton); 1136 QMessageBox::NoButton);
1135 msg->exec(); 1137 msg->exec();
1136 delete msg; 1138 delete msg;
1137 1139
1138 1140
1139} 1141}
1140void MainWindow::aboutKnownBugs() 1142void MainWindow::aboutKnownBugs()
1141{ 1143{
1142 QMessageBox* msg; 1144 QMessageBox* msg;
1143 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), 1145 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"),
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("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")+
1145 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ 1147 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+
1146 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + 1148 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") +
1147 i18n("\nor report them in the bugtracker on\n") + 1149 i18n("\nor report them in the bugtracker on\n") +
1148 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), 1150 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"),
1149 QMessageBox::NoIcon, 1151 QMessageBox::NoIcon,
1150 QMessageBox::Ok, 1152 QMessageBox::Ok,
1151 QMessageBox::NoButton, 1153 QMessageBox::NoButton,
1152 QMessageBox::NoButton); 1154 QMessageBox::NoButton);
1153 msg->exec(); 1155 msg->exec();
1154 delete msg; 1156 delete msg;
1155 1157
1156} 1158}
1157 1159
1158QString MainWindow::defaultFileName() 1160QString MainWindow::defaultFileName()
1159{ 1161{
1160 return locateLocal( "data", "korganizer/mycalendar.ics" ); 1162 return locateLocal( "data", "korganizer/mycalendar.ics" );
1161} 1163}
1162 1164
1163void MainWindow::processIncidenceSelection( Incidence *incidence ) 1165void MainWindow::processIncidenceSelection( Incidence *incidence )
1164{ 1166{
1165 if ( !incidence ) { 1167 if ( !incidence ) {
1166 enableIncidenceActions( false ); 1168 enableIncidenceActions( false );
1167 1169
1168 mNewSubTodoAction->setEnabled( false ); 1170 mNewSubTodoAction->setEnabled( false );
1169 setCaptionToDates(); 1171 setCaptionToDates();
1170 return; 1172 return;
1171 1173
1172 } 1174 }
1173 1175
1174 //KGlobal::locale()->formatDateTime(nextA, true); 1176 //KGlobal::locale()->formatDateTime(nextA, true);
1175 QString startString = ""; 1177 QString startString = "";
1176 if ( incidence->type() != "Todo" ) { 1178 if ( incidence->type() != "Todo" ) {
1177 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { 1179 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) {
1178 if ( incidence->doesFloat() ) { 1180 if ( incidence->doesFloat() ) {
1179 startString += ": "+incidence->dtStartDateStr( true ); 1181 startString += ": "+incidence->dtStartDateStr( true );
1180 startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); 1182 startString += " --- "+((Event*)incidence)->dtEndDateStr( true );
1181 1183
1182 } else { 1184 } else {
1183 startString = ": "+incidence->dtStartStr(true); 1185 startString = ": "+incidence->dtStartStr(true);
1184 startString += " --- "+((Event*)incidence)->dtEndStr(true); 1186 startString += " --- "+((Event*)incidence)->dtEndStr(true);
1185 1187
1186 } 1188 }
1187 1189
1188 } else { 1190 } else {
1189 if ( incidence->dtStart().time() != incidence->dtEnd().time() ) 1191 if ( incidence->dtStart().time() != incidence->dtEnd().time() )
1190 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ 1192 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+
1191 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); 1193 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time());
1192 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); 1194 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true);
1193 } 1195 }
1194 1196
1195 } 1197 }
1196 else 1198 else
1197 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); 1199 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed");
1198 if ( !incidence->location().isEmpty() ) 1200 if ( !incidence->location().isEmpty() )
1199 startString += " (" +incidence->location()+")"; 1201 startString += " (" +incidence->location()+")";
1200 setCaption( incidence->summary()+startString); 1202 setCaption( incidence->summary()+startString);
1201 1203
1202 enableIncidenceActions( true ); 1204 enableIncidenceActions( true );
1203 1205
1204 if ( incidence->type() == "Event" ) { 1206 if ( incidence->type() == "Event" ) {
1205 mShowAction->setText( i18n("Show Event...") ); 1207 mShowAction->setText( i18n("Show Event...") );
1206 mEditAction->setText( i18n("Edit Event...") ); 1208 mEditAction->setText( i18n("Edit Event...") );
1207 mDeleteAction->setText( i18n("Delete Event...") ); 1209 mDeleteAction->setText( i18n("Delete Event...") );
1208 1210
1209 mNewSubTodoAction->setEnabled( false ); 1211 mNewSubTodoAction->setEnabled( false );
1210 } else if ( incidence->type() == "Todo" ) { 1212 } else if ( incidence->type() == "Todo" ) {
1211 mShowAction->setText( i18n("Show Todo...") ); 1213 mShowAction->setText( i18n("Show Todo...") );
1212 mEditAction->setText( i18n("Edit Todo...") ); 1214 mEditAction->setText( i18n("Edit Todo...") );
1213 mDeleteAction->setText( i18n("Delete Todo...") ); 1215 mDeleteAction->setText( i18n("Delete Todo...") );
1214 1216
1215 mNewSubTodoAction->setEnabled( true ); 1217 mNewSubTodoAction->setEnabled( true );
1216 } else { 1218 } else {
1217 mShowAction->setText( i18n("Show...") ); 1219 mShowAction->setText( i18n("Show...") );
1218 mShowAction->setText( i18n("Edit...") ); 1220 mShowAction->setText( i18n("Edit...") );
1219 mShowAction->setText( i18n("Delete...") ); 1221 mShowAction->setText( i18n("Delete...") );
1220 1222
1221 mNewSubTodoAction->setEnabled( false ); 1223 mNewSubTodoAction->setEnabled( false );
1222 } 1224 }
1223} 1225}
1224 1226
1225void MainWindow::enableIncidenceActions( bool enabled ) 1227void MainWindow::enableIncidenceActions( bool enabled )
1226{ 1228{
1227 mShowAction->setEnabled( enabled ); 1229 mShowAction->setEnabled( enabled );
1228 mEditAction->setEnabled( enabled ); 1230 mEditAction->setEnabled( enabled );
1229 mDeleteAction->setEnabled( enabled ); 1231 mDeleteAction->setEnabled( enabled );
1230} 1232}
1231 1233
1232void MainWindow::importOL() 1234void MainWindow::importOL()
1233{ 1235{
1234#ifdef _WIN32_ 1236#ifdef _WIN32_
1235 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); 1237 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this );
1236 id->exec(); 1238 id->exec();
1237 delete id; 1239 delete id;
1238 mView->updateView(); 1240 mView->updateView();
1239#endif 1241#endif
1240} 1242}
1241void MainWindow::importBday() 1243void MainWindow::importBday()
1242{ 1244{
1243 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1245 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1244 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), 1246 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"),
1245 i18n("Import!"), i18n("Cancel"), 0, 1247 i18n("Import!"), i18n("Cancel"), 0,
1246 0, 1 ); 1248 0, 1 );
1247 if ( result == 0 ) { 1249 if ( result == 0 ) {
1248 mView->importBday(); 1250 mView->importBday();
1249 1251
1250 } 1252 }
1251 1253
1252 1254
1253} 1255}
1254void MainWindow::importQtopia() 1256void MainWindow::importQtopia()
1255{ 1257{
1256#ifndef DESKTOP_VERSION 1258#ifndef DESKTOP_VERSION
1257 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1259 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
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("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"),
1259 i18n("Import!"), i18n("Cancel"), 0, 1261 i18n("Import!"), i18n("Cancel"), 0,
1260 0, 1 ); 1262 0, 1 );
1261 if ( result == 0 ) { 1263 if ( result == 0 ) {
1262 QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); 1264 QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
1263 QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); 1265 QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
1264 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; 1266 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
1265 mView->importQtopia( categories, datebook, todolist ); 1267 mView->importQtopia( categories, datebook, todolist );
1266 } 1268 }
1267#else 1269#else
1268 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1270 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1269 i18n("Not supported \non desktop!\n"), 1271 i18n("Not supported \non desktop!\n"),
1270 i18n("Ok"), i18n("Cancel"), 0, 1272 i18n("Ok"), i18n("Cancel"), 0,
1271 0, 1 ); 1273 0, 1 );
1272 1274
1273#endif 1275#endif
1274} 1276}
1275 1277
1276void MainWindow::saveOnClose() 1278void MainWindow::saveOnClose()
1277{ 1279{
1278 KOPrefs *p = KOPrefs::instance(); 1280 KOPrefs *p = KOPrefs::instance();
1279 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); 1281 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
1280 p->mToolBarUp = iconToolBar->x() > width()/2 || 1282 p->mToolBarUp = iconToolBar->x() > width()/2 ||
1281 iconToolBar->y() > height()/2; 1283 iconToolBar->y() > height()/2;
1282 mView->writeSettings(); 1284 mView->writeSettings();
1283 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) 1285 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName()))
1284 save(); 1286 save();
1285} 1287}
1286void MainWindow::slotModifiedChanged( bool changed ) 1288void MainWindow::slotModifiedChanged( bool changed )
1287{ 1289{
1288 if ( mBlockAtStartup ) 1290 if ( mBlockAtStartup )
1289 return; 1291 return;
1290 int msec; 1292 int msec;
1291 // we store the changes after 1 minute, 1293 // we store the changes after 1 minute,
1292 // and for safety reasons after 10 minutes again 1294 // and for safety reasons after 10 minutes again
1293 if ( !mBlockSaveFlag ) 1295 if ( !mBlockSaveFlag )
1294 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1296 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1295 else 1297 else
1296 msec = 1000 * 600; 1298 msec = 1000 * 600;
1297 mSaveTimer.start( msec, true ); // 1 minute 1299 mSaveTimer.start( msec, true ); // 1 minute
1298 qDebug("KO: Saving File in %d secs!", msec/1000); 1300 qDebug("KO: Saving File in %d secs!", msec/1000);
1299 mCalendarModifiedFlag = true; 1301 mCalendarModifiedFlag = true;
1300} 1302}
1301#include <qfileinfo.h> 1303#include <qfileinfo.h>
1302void MainWindow::save() 1304void MainWindow::save()
1303{ 1305{
1304 if ( mBlockSaveFlag ) 1306 if ( mBlockSaveFlag )
1305 return; 1307 return;
1306 bool store = mBlockSaveFlag; 1308 bool store = mBlockSaveFlag;
1307 mBlockSaveFlag = true; 1309 mBlockSaveFlag = true;
1308 if ( mView->checkFileVersion( defaultFileName()) ) { 1310 if ( mView->checkFileVersion( defaultFileName()) ) {
1309 1311
1310 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1312 QTime neededSaveTime = QDateTime::currentDateTime().time();
1311 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1313 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1312 qDebug("KO: Start saving data to file!"); 1314 qDebug("KO: Start saving data to file!");
1313 mView->saveCalendar( defaultFileName() ); 1315 mView->saveCalendar( defaultFileName() );
1314 1316
1315 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 1317 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1316 mView->setLoadedFileVersion(QDateTime::currentDateTime()); 1318 mView->setLoadedFileVersion(QDateTime::currentDateTime());
1317 qDebug("KO: Needed %d ms for saving.",msNeeded ); 1319 qDebug("KO: Needed %d ms for saving.",msNeeded );
1318 QString savemes; 1320 QString savemes;
1319 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 1321 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
1320 setCaption(savemes); 1322 setCaption(savemes);
1321 } else 1323 } else
1322 setCaption(i18n("Saving cancelled!")); 1324 setCaption(i18n("Saving cancelled!"));
1323 mCalendarModifiedFlag = false; 1325 mCalendarModifiedFlag = false;
1324 mBlockSaveFlag = store; 1326 mBlockSaveFlag = store;
1325} 1327}
1326 1328
1327void MainWindow::keyReleaseEvent ( QKeyEvent * e) 1329void MainWindow::keyReleaseEvent ( QKeyEvent * e)
1328{ 1330{
1329 if ( !e->isAutoRepeat() ) { 1331 if ( !e->isAutoRepeat() ) {
1330 mFlagKeyPressed = false; 1332 mFlagKeyPressed = false;
1331 } 1333 }
1332} 1334}
1333void MainWindow::keyPressEvent ( QKeyEvent * e ) 1335void MainWindow::keyPressEvent ( QKeyEvent * e )
1334{ 1336{
1335 qApp->processEvents(); 1337 qApp->processEvents();
1336 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 1338 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1337 e->ignore(); 1339 e->ignore();
1338 // qDebug(" ignore %d",e->isAutoRepeat() ); 1340 // qDebug(" ignore %d",e->isAutoRepeat() );
1339 return; 1341 return;
1340 } 1342 }
1341 if (! e->isAutoRepeat() ) 1343 if (! e->isAutoRepeat() )
1342 mFlagKeyPressed = true; 1344 mFlagKeyPressed = true;
1343 KOPrefs *p = KOPrefs::instance(); 1345 KOPrefs *p = KOPrefs::instance();
1344 bool showSelectedDates = false; 1346 bool showSelectedDates = false;
1345 int size; 1347 int size;
1346 int pro = 0; 1348 int pro = 0;
1347 //qDebug("MainWindow::keyPressEvent "); 1349 //qDebug("MainWindow::keyPressEvent ");
1348 switch ( e->key() ) { 1350 switch ( e->key() ) {
1349 case Qt::Key_Right: 1351 case Qt::Key_Right:
1350 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1352 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1351 mView->goNextMonth(); 1353 mView->goNextMonth();
1352 else 1354 else
1353 mView->goNext(); 1355 mView->goNext();
1354 showSelectedDates = true; 1356 showSelectedDates = true;
1355 break; 1357 break;
1356 case Qt::Key_Left: 1358 case Qt::Key_Left:
1357 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1359 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1358 mView->goPreviousMonth(); 1360 mView->goPreviousMonth();
1359 else 1361 else
1360 mView->goPrevious(); 1362 mView->goPrevious();
1361 showSelectedDates = true; 1363 showSelectedDates = true;
1362 break; 1364 break;
1363 case Qt::Key_Down: 1365 case Qt::Key_Down:
1364 mView->viewManager()->agendaView()->scrollOneHourDown(); 1366 mView->viewManager()->agendaView()->scrollOneHourDown();
1365 break; 1367 break;
1366 case Qt::Key_Up: 1368 case Qt::Key_Up:
1367 mView->viewManager()->agendaView()->scrollOneHourUp(); 1369 mView->viewManager()->agendaView()->scrollOneHourUp();
1368 break; 1370 break;
1369 case Qt::Key_I: 1371 case Qt::Key_I:
1370 mView->showIncidence(); 1372 mView->showIncidence();
1371 break; 1373 break;
1372 case Qt::Key_Delete: 1374 case Qt::Key_Delete:
1373 case Qt::Key_Backspace: 1375 case Qt::Key_Backspace:
1374 mView->deleteIncidence(); 1376 mView->deleteIncidence();
1375 break; 1377 break;
1376 case Qt::Key_D: 1378 case Qt::Key_D:
1377 mView->viewManager()->showDayView(); 1379 mView->viewManager()->showDayView();
1378 showSelectedDates = true; 1380 showSelectedDates = true;
1379 break; 1381 break;
1380 case Qt::Key_O: 1382 case Qt::Key_O:
1381 mView->toggleFilerEnabled( ); 1383 mView->toggleFilerEnabled( );
1382 break; 1384 break;
1383 case Qt::Key_0: 1385 case Qt::Key_0:
1384 case Qt::Key_1: 1386 case Qt::Key_1:
1385 case Qt::Key_2: 1387 case Qt::Key_2:
1386 case Qt::Key_3: 1388 case Qt::Key_3:
1387 case Qt::Key_4: 1389 case Qt::Key_4:
1388 case Qt::Key_5: 1390 case Qt::Key_5:
1389 case Qt::Key_6: 1391 case Qt::Key_6:
1390 case Qt::Key_7: 1392 case Qt::Key_7:
1391 case Qt::Key_8: 1393 case Qt::Key_8:
1392 case Qt::Key_9: 1394 case Qt::Key_9:
1393 pro = e->key()-48; 1395 pro = e->key()-48;
1394 if ( pro == 0 ) 1396 if ( pro == 0 )
1395 pro = 10; 1397 pro = 10;
1396 if ( e->state() == Qt::ControlButton) 1398 if ( e->state() == Qt::ControlButton)
1397 pro += 10; 1399 pro += 10;
1398 break; 1400 break;
1399 case Qt::Key_M: 1401 case Qt::Key_M:
1400 mView->viewManager()->showMonthView(); 1402 mView->viewManager()->showMonthView();
1401 showSelectedDates = true; 1403 showSelectedDates = true;
1402 break; 1404 break;
1403 case Qt::Key_Insert: 1405 case Qt::Key_Insert:
1404 mView->newEvent(); 1406 mView->newEvent();
1405 break; 1407 break;
1406 case Qt::Key_S : 1408 case Qt::Key_S :
1407 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1409 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1408 mView->newSubTodo(); 1410 mView->newSubTodo();
1409 else 1411 else
1410 mView->dialogManager()->showSearchDialog(); 1412 mView->dialogManager()->showSearchDialog();
1411 break; 1413 break;
1412 case Qt::Key_Y : 1414 case Qt::Key_Y :
1413 case Qt::Key_Z : 1415 case Qt::Key_Z :
1414 mView->viewManager()->showWorkWeekView(); 1416 mView->viewManager()->showWorkWeekView();
1415 showSelectedDates = true; 1417 showSelectedDates = true;
1416 break; 1418 break;
1417 case Qt::Key_U : 1419 case Qt::Key_U :
1418 mView->viewManager()->showWeekView(); 1420 mView->viewManager()->showWeekView();
1419 showSelectedDates = true; 1421 showSelectedDates = true;
1420 break; 1422 break;
1421 case Qt::Key_H : 1423 case Qt::Key_H :
1422 keyBindings(); 1424 keyBindings();
1423 break; 1425 break;
1424 case Qt::Key_W: 1426 case Qt::Key_W:
1425 mView->viewManager()->showWhatsNextView(); 1427 mView->viewManager()->showWhatsNextView();
1426 break; 1428 break;
1427 case Qt::Key_L: 1429 case Qt::Key_L:
1428 mView->viewManager()->showListView(); 1430 mView->viewManager()->showListView();
1429 break; 1431 break;
1430 case Qt::Key_N: 1432 case Qt::Key_N:
1431 mView->viewManager()->showNextXView(); 1433 mView->viewManager()->showNextXView();
1432 showSelectedDates = true; 1434 showSelectedDates = true;
1433 break; 1435 break;
1434 case Qt::Key_V: 1436 case Qt::Key_V:
1435 mView->viewManager()->showTodoView(); 1437 mView->viewManager()->showTodoView();
1436 break; 1438 break;
1437 case Qt::Key_C: 1439 case Qt::Key_C:
1438 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); 1440 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() );
1439 break; 1441 break;
1440 case Qt::Key_P: 1442 case Qt::Key_P:
1441 mView->showDatePicker( ); 1443 mView->showDatePicker( );
1442 break; 1444 break;
1443 case Qt::Key_F: 1445 case Qt::Key_F:
1444 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1446 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1445 mView->editFilters(); 1447 mView->editFilters();
1446 else 1448 else
1447 mView->toggleFilter(); 1449 mView->toggleFilter();
1448 break; 1450 break;
1449 case Qt::Key_X: 1451 case Qt::Key_X:
1450 mView->toggleDateNavigatorWidget(); 1452 mView->toggleDateNavigatorWidget();
1451 break; 1453 break;
1452 case Qt::Key_Space: 1454 case Qt::Key_Space:
1453 mView->toggleExpand(); 1455 mView->toggleExpand();
1454 break; 1456 break;
1455 case Qt::Key_A: 1457 case Qt::Key_A:
1456 mView->toggleAllDaySize(); 1458 mView->toggleAllDaySize();
1457 break; 1459 break;
1458 case Qt::Key_T: 1460 case Qt::Key_T:
1459 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1461 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1460 mView->newTodo(); 1462 mView->newTodo();
1461 else { 1463 else {
1462 mView->goToday(); 1464 mView->goToday();
1463 showSelectedDates = true; 1465 showSelectedDates = true;
1464 } 1466 }
1465 break; 1467 break;
1466 case Qt::Key_J: 1468 case Qt::Key_J:
1467 mView->viewManager()->showJournalView(); 1469 mView->viewManager()->showJournalView();
1468 break; 1470 break;
1469 case Qt::Key_B: 1471 case Qt::Key_B:
1470 mView->editIncidenceDescription();; 1472 mView->editIncidenceDescription();;
1471 break; 1473 break;
1472 // case Qt::Key_Return: 1474 // case Qt::Key_Return:
1473 case Qt::Key_E: 1475 case Qt::Key_E:
1474 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1476 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1475 mView->newEvent(); 1477 mView->newEvent();
1476 else 1478 else
1477 mView->editIncidence(); 1479 mView->editIncidence();
1478 break; 1480 break;
1479 case Qt::Key_Plus: 1481 case Qt::Key_Plus:
1480 size = p->mHourSize +2; 1482 size = p->mHourSize +2;
1481 if ( size <= 18 ) 1483 if ( size <= 18 )
1482 configureAgenda( size ); 1484 configureAgenda( size );
1483 break; 1485 break;
1484 case Qt::Key_Minus: 1486 case Qt::Key_Minus:
1485 size = p->mHourSize - 2; 1487 size = p->mHourSize - 2;
1486 if ( size >= 4 ) 1488 if ( size >= 4 )
1487 configureAgenda( size ); 1489 configureAgenda( size );
1488 break; 1490 break;
1489 1491
1490 1492
1491 default: 1493 default:
1492 e->ignore(); 1494 e->ignore();
1493 } 1495 }
1494 if ( pro > 0 ) { 1496 if ( pro > 0 ) {
1495 mView->selectFilter( pro-1 ); 1497 mView->selectFilter( pro-1 );
1496 } 1498 }
1497 if ( showSelectedDates ) { 1499 if ( showSelectedDates ) {
1498 ;// setCaptionToDates(); 1500 ;// setCaptionToDates();
1499 } 1501 }
1500 1502
1501} 1503}
1502 1504
1503void MainWindow::configureToolBar( int item ) 1505void MainWindow::configureToolBar( int item )
1504{ 1506{
1505 1507
1506 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); 1508 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) );
1507 KOPrefs *p = KOPrefs::instance(); 1509 KOPrefs *p = KOPrefs::instance();
1508 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); 1510 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 );
1509 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); 1511 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 );
1510 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); 1512 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 );
1511 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); 1513 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 );
1512 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); 1514 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 );
1513 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); 1515 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 );
1514 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); 1516 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 );
1515 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); 1517 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 );
1516 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); 1518 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 );
1517 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); 1519 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 );
1518 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); 1520 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 );
1519 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); 1521 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 );
1520 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); 1522 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 );
1521 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); 1523 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 );
1522 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); 1524 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 );
1523 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); 1525 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 );
1524 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); 1526 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 );
1525 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); 1527 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 );
1526 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); 1528 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 );
1527 // initActions(); 1529 // initActions();
1528} 1530}
1529 1531
1530void MainWindow::setCaptionToDates() 1532void MainWindow::setCaptionToDates()
1531{ 1533{
1532 QString selDates; 1534 QString selDates;
1533 selDates = KGlobal::locale()->formatDate(mView->startDate(), true); 1535 selDates = KGlobal::locale()->formatDate(mView->startDate(), true);
1534 if (mView->startDate() < mView->endDate() ) 1536 if (mView->startDate() < mView->endDate() )
1535 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); 1537 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true);
1536 setCaption( i18n("Dates: ") + selDates ); 1538 setCaption( i18n("Dates: ") + selDates );
1537 1539
1538} 1540}
1539// parameter item == 0: reinit 1541// parameter item == 0: reinit
1540void MainWindow::configureAgenda( int item ) 1542void MainWindow::configureAgenda( int item )
1541{ 1543{
1542 1544
1543 KOPrefs *p = KOPrefs::instance(); 1545 KOPrefs *p = KOPrefs::instance();
1544 1546
1545 int i; 1547 int i;
1546 if ( item == 1 ) { 1548 if ( item == 1 ) {
1547 mView->toggleAllDaySize(); 1549 mView->toggleAllDaySize();
1548 return; 1550 return;
1549 } 1551 }
1550 // do not allow 4 for widgets higher than 480 1552 // do not allow 4 for widgets higher than 480
1551 // if ( QApplication::desktop()->height() > 480 ) { 1553 // if ( QApplication::desktop()->height() > 480 ) {
1552// if ( item == 4 ) 1554// if ( item == 4 )
1553// item = 6; 1555// item = 6;
1554// } 1556// }
1555 for ( i = 4; i <= 18; i= i+2 ) 1557 for ( i = 4; i <= 18; i= i+2 )
1556 configureAgendaMenu->setItemChecked( i, false ); 1558 configureAgendaMenu->setItemChecked( i, false );
1557 configureAgendaMenu->setItemChecked( item, true ); 1559 configureAgendaMenu->setItemChecked( item, true );
1558 if ( p->mHourSize == item ) 1560 if ( p->mHourSize == item )
1559 return; 1561 return;
1560 p->mHourSize=item; 1562 p->mHourSize=item;
1561 mView->viewManager()->agendaView()->updateConfig(); 1563 mView->viewManager()->agendaView()->updateConfig();
1562} 1564}
1563 1565
1564void MainWindow::saveCalendar() 1566void MainWindow::saveCalendar()
1565{ 1567{
1566 QString fn = KOPrefs::instance()->mLastSaveFile; 1568 QString fn = KOPrefs::instance()->mLastSaveFile;
1567 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); 1569 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this );
1568 1570
1569 if ( fn == "" ) 1571 if ( fn == "" )
1570 return; 1572 return;
1571 QFileInfo info; 1573 QFileInfo info;
1572 info.setFile( fn ); 1574 info.setFile( fn );
1573 QString mes; 1575 QString mes;
1574 bool createbup = true; 1576 bool createbup = true;
1575 if ( info. exists() ) { 1577 if ( info. exists() ) {
1576 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; 1578 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ;
1577 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1579 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1578 i18n("Overwrite!"), i18n("Cancel"), 0, 1580 i18n("Overwrite!"), i18n("Cancel"), 0,
1579 0, 1 ); 1581 0, 1 );
1580 if ( result != 0 ) { 1582 if ( result != 0 ) {
1581 createbup = false; 1583 createbup = false;
1582 } 1584 }
1583 } 1585 }
1584 if ( createbup ) { 1586 if ( createbup ) {
1585 mView->saveCalendar( fn ); 1587 mView->saveCalendar( fn );
1586 mes = i18n("KO/Pi:Saved %1").arg(fn); 1588 mes = i18n("KO/Pi:Saved %1").arg(fn);
1587 KOPrefs::instance()->mLastSaveFile = fn; 1589 KOPrefs::instance()->mLastSaveFile = fn;
1588 setCaption(mes); 1590 setCaption(mes);
1589 } 1591 }
1590} 1592}
1591void MainWindow::loadCalendar() 1593void MainWindow::loadCalendar()
1592{ 1594{
1593 1595
1594 QString fn = KOPrefs::instance()->mLastLoadFile; 1596 QString fn = KOPrefs::instance()->mLastLoadFile;
1595 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); 1597 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this );
1596 1598
1597 if ( fn == "" ) 1599 if ( fn == "" )
1598 return; 1600 return;
1599 QFileInfo info; 1601 QFileInfo info;
1600 info.setFile( fn ); 1602 info.setFile( fn );
1601 QString mess; 1603 QString mess;
1602 bool loadbup = true; 1604 bool loadbup = true;
1603 if ( info. exists() ) { 1605 if ( info. exists() ) {
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 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1605 int result = QMessageBox::warning( this, "KO/Pi: Warning!", 1607 int result = QMessageBox::warning( this, "KO/Pi: Warning!",
1606 mess, 1608 mess,
1607 i18n("Load!"), i18n("Cancel"), 0, 1609 i18n("Load!"), i18n("Cancel"), 0,
1608 0, 1 ); 1610 0, 1 );
1609 if ( result != 0 ) { 1611 if ( result != 0 ) {
1610 loadbup = false; 1612 loadbup = false;
1611 } 1613 }
1612 } else { 1614 } else {
1613 QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1615 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1614 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, 1616 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0,
1615 0, 1 ); 1617 0, 1 );
1616 1618
1617 return; 1619 return;
1618 } 1620 }
1619 if ( loadbup ) { 1621 if ( loadbup ) {
1620 mView->openCalendar( fn ); 1622 mView->openCalendar( fn );
1621 KOPrefs::instance()->mLastLoadFile = fn; 1623 KOPrefs::instance()->mLastLoadFile = fn;
1622 mess = i18n("KO/Pi:Loaded %1").arg(fn) ; 1624 mess = i18n("KO/Pi:Loaded %1").arg(fn) ;
1623 setCaption(mess); 1625 setCaption(mess);
1624 } 1626 }
1625 1627
1626} 1628}
1627void MainWindow::quickImportIcal() 1629void MainWindow::quickImportIcal()
1628{ 1630{
1629 importFile( KOPrefs::instance()->mLastImportFile, false ); 1631 importFile( KOPrefs::instance()->mLastImportFile, false );
1630} 1632}
1631void MainWindow::importFile( QString fn, bool quick ) 1633void MainWindow::importFile( QString fn, bool quick )
1632{ 1634{
1633 QFileInfo info; 1635 QFileInfo info;
1634 info.setFile( fn ); 1636 info.setFile( fn );
1635 QString mess; 1637 QString mess;
1636 bool loadbup = true; 1638 bool loadbup = true;
1637 if ( !info. exists() ) { 1639 if ( !info. exists() ) {
1638 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); 1640 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30));
1639 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1641 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1640 mess ); 1642 mess );
1641 return; 1643 return;
1642 } 1644 }
1643 int result = 0; 1645 int result = 0;
1644 if ( !quick ) { 1646 if ( !quick ) {
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 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 ));
1646 result = QMessageBox::warning( this, "KO/Pi: Warning!", 1648 result = QMessageBox::warning( this, "KO/Pi: Warning!",
1647 mess, 1649 mess,
1648 "Import", "Cancel", 0, 1650 "Import", "Cancel", 0,
1649 0, 1 ); 1651 0, 1 );
1650 } 1652 }
1651 if ( result == 0 ) { 1653 if ( result == 0 ) {
1652 if ( mView->openCalendar( fn, true )) { 1654 if ( mView->openCalendar( fn, true )) {
1653 KOPrefs::instance()->mLastImportFile = fn; 1655 KOPrefs::instance()->mLastImportFile = fn;
1654 setCaption(i18n("Imported file successfully")); 1656 setCaption(i18n("Imported file successfully"));
1655 } else { 1657 } else {
1656 setCaption(i18n("Error importing file")); 1658 setCaption(i18n("Error importing file"));
1657 } 1659 }
1658 } 1660 }
1659} 1661}
1660 1662
1661void MainWindow::importIcal() 1663void MainWindow::importIcal()
1662{ 1664{
1663 1665
1664 QString fn =KOPrefs::instance()->mLastImportFile; 1666 QString fn =KOPrefs::instance()->mLastImportFile;
1665 1667
1666 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); 1668 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this );
1667 if ( fn == "" ) 1669 if ( fn == "" )
1668 return; 1670 return;
1669 importFile( fn, true ); 1671 importFile( fn, true );
1670 1672
1671} 1673}
1672 1674
1673void MainWindow::exportVCalendar() 1675void MainWindow::exportVCalendar()
1674{ 1676{
1675 QString fn = KOPrefs::instance()->mLastVcalFile; 1677 QString fn = KOPrefs::instance()->mLastVcalFile;
1676 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); 1678 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this );
1677 if ( fn == "" ) 1679 if ( fn == "" )
1678 return; 1680 return;
1679 QFileInfo info; 1681 QFileInfo info;
1680 info.setFile( fn ); 1682 info.setFile( fn );
1681 QString mes; 1683 QString mes;
1682 bool createbup = true; 1684 bool createbup = true;
1683 if ( info. exists() ) { 1685 if ( info. exists() ) {
1684 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 1686 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
1685 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1687 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1686 i18n("Overwrite!"), i18n("Cancel"), 0, 1688 i18n("Overwrite!"), i18n("Cancel"), 0,
1687 0, 1 ); 1689 0, 1 );
1688 if ( result != 0 ) { 1690 if ( result != 0 ) {
1689 createbup = false; 1691 createbup = false;
1690 } 1692 }
1691 } 1693 }
1692 if ( createbup ) { 1694 if ( createbup ) {
1693 if ( mView->exportVCalendar( fn ) ) { 1695 if ( mView->exportVCalendar( fn ) ) {
1694 KOPrefs::instance()->mLastVcalFile = fn; 1696 KOPrefs::instance()->mLastVcalFile = fn;
1695 if ( fn.length() > 20 ) 1697 if ( fn.length() > 20 )
1696 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; 1698 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ;
1697 else 1699 else
1698 mes = i18n("KO/Pi:Exported to %1").arg(fn ); 1700 mes = i18n("KO/Pi:Exported to %1").arg(fn );
1699 setCaption(mes); 1701 setCaption(mes);
1700 } 1702 }
1701 } 1703 }
1702 1704
1703} 1705}
1704#include <qpushbutton.h> 1706#include <qpushbutton.h>
1705QString MainWindow::getPassword( ) 1707QString MainWindow::getPassword( )
1706{ 1708{
1707 QString retfile = ""; 1709 QString retfile = "";
1708 QDialog dia ( this, "input-dialog", true ); 1710 QDialog dia ( this, "input-dialog", true );
1709 QLineEdit lab ( &dia ); 1711 QLineEdit lab ( &dia );
1710 lab.setEchoMode( QLineEdit::Password ); 1712 lab.setEchoMode( QLineEdit::Password );
1711 QVBoxLayout lay( &dia ); 1713 QVBoxLayout lay( &dia );
1712 lay.setMargin(7); 1714 lay.setMargin(7);
1713 lay.setSpacing(7); 1715 lay.setSpacing(7);
1714 lay.addWidget( &lab); 1716 lay.addWidget( &lab);
1715 dia.setFixedSize( 230,50 ); 1717 dia.setFixedSize( 230,50 );
1716 dia.setCaption( i18n("Enter password") ); 1718 dia.setCaption( i18n("Enter password") );
1717 QPushButton pb ( "OK", &dia); 1719 QPushButton pb ( "OK", &dia);
1718 lay.addWidget( &pb ); 1720 lay.addWidget( &pb );
1719 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 1721 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
1720 dia.show(); 1722 dia.show();
1721 int res = dia.exec(); 1723 int res = dia.exec();
1722 if ( res ) 1724 if ( res )
1723 retfile = lab.text(); 1725 retfile = lab.text();
1724 dia.hide(); 1726 dia.hide();
1725 qApp->processEvents(); 1727 qApp->processEvents();
1726 return retfile; 1728 return retfile;
1727 1729
1728} 1730}
1729 1731
1730void MainWindow::syncLocalFile() 1732void MainWindow::syncLocalFile()
1731{ 1733{
1732 1734
1733 QString fn =KOPrefs::instance()->mLastSyncedLocalFile; 1735 QString fn =KOPrefs::instance()->mLastSyncedLocalFile;
1734 1736
1735 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); 1737 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this );
1736 if ( fn == "" ) 1738 if ( fn == "" )
1737 return; 1739 return;
1738 //mView->setSyncDevice("local-file" ); 1740 //mView->setSyncDevice("local-file" );
1739 if ( syncWithFile( fn, false ) ) { 1741 if ( syncWithFile( fn, false ) ) {
1740 // Event* e = mView->getLastSyncEvent(); 1742 // Event* e = mView->getLastSyncEvent();
1741// e->setReadOnly( false ); 1743// e->setReadOnly( false );
1742// e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); 1744// e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile);
1743// e->setReadOnly( true ); 1745// e->setReadOnly( true );
1744 } 1746 }
1745 1747
1746} 1748}
1747 1749
1748bool MainWindow::syncWithFile( QString fn , bool quick ) 1750bool MainWindow::syncWithFile( QString fn , bool quick )
1749{ 1751{
1750 bool ret = false; 1752 bool ret = false;
1751 QFileInfo info; 1753 QFileInfo info;
1752 info.setFile( fn ); 1754 info.setFile( fn );
1753 QString mess; 1755 QString mess;
1754 bool loadbup = true; 1756 bool loadbup = true;
1755 if ( !info. exists() ) { 1757 if ( !info. exists() ) {
1756 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 1758 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
1757 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1759 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1758 mess ); 1760 mess );
1759 return ret; 1761 return ret;
1760 } 1762 }
1761 int result = 0; 1763 int result = 0;
1762 if ( !quick ) { 1764 if ( !quick ) {
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 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1764 result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1766 result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1765 mess, 1767 mess,
1766 i18n("Sync"), i18n("Cancel"), 0, 1768 i18n("Sync"), i18n("Cancel"), 0,
1767 0, 1 ); 1769 0, 1 );
1768 if ( result ) 1770 if ( result )
1769 return false; 1771 return false;
1770 } 1772 }
1771 if ( KOPrefs::instance()->mAskForPreferences ) 1773 if ( KOPrefs::instance()->mAskForPreferences )
1772 mView->edit_sync_options(); 1774 mView->edit_sync_options();
1773 if ( result == 0 ) { 1775 if ( result == 0 ) {
1774 //qDebug("Now sycing ... "); 1776 //qDebug("Now sycing ... ");
1775 if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) ) 1777 if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) )
1776 setCaption( i18n("Synchronization successful") ); 1778 setCaption( i18n("Synchronization successful") );
1777 else 1779 else
1778 setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); 1780 setCaption( i18n("Sync cancelled or failed. Nothing synced.") );
1779 if ( ! quick ) 1781 if ( ! quick )
1780 KOPrefs::instance()->mLastSyncedLocalFile = fn; 1782 KOPrefs::instance()->mLastSyncedLocalFile = fn;
1781 slotModifiedChanged( true ); 1783 slotModifiedChanged( true );
1782 } 1784 }
1783 return ret; 1785 return ret;
1784} 1786}
1785void MainWindow::quickSyncLocalFile() 1787void MainWindow::quickSyncLocalFile()
1786{ 1788{
1787 //mView->setSyncDevice("local-file" ); 1789 //mView->setSyncDevice("local-file" );
1788 //qDebug("quickSyncLocalFile() "); 1790 //qDebug("quickSyncLocalFile() ");
1789 if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) { 1791 if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) {
1790 // Event* e = mView->getLastSyncEvent(); 1792 // Event* e = mView->getLastSyncEvent();
1791// e->setReadOnly( false ); 1793// e->setReadOnly( false );
1792// e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); 1794// e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile);
1793// e->setReadOnly( true ); 1795// e->setReadOnly( true );
1794 1796
1795 } 1797 }
1796} 1798}
1797 1799
1798void MainWindow::confSync() 1800void MainWindow::confSync()
1799{ 1801{
1800 mView->confSync(); 1802 mView->confSync();
1801 fillSyncMenu(); 1803 fillSyncMenu();
1802 //mView->writeSettings(); 1804 //mView->writeSettings();
1803 1805
1804 1806
1805} 1807}
1806void MainWindow::syncRemote( KSyncProfile* prof, bool ask) 1808void MainWindow::syncRemote( KSyncProfile* prof, bool ask)
1807{ 1809{
1808 QString question; 1810 QString question;
1809 if ( ask ) { 1811 if ( ask ) {
1810 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; 1812 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
1811 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 1813 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
1812 question, 1814 question,
1813 i18n("Yes"), i18n("No"), 1815 i18n("Yes"), i18n("No"),
1814 0, 0 ) != 0 ) 1816 0, 0 ) != 0 )
1815 return; 1817 return;
1816 } 1818 }
1817 QString command = prof->getPreSyncCommand(); 1819 QString command = prof->getPreSyncCommand();
1818 int fi; 1820 int fi;
1819 if ( (fi = command.find("$PWD$")) > 0 ) { 1821 if ( (fi = command.find("$PWD$")) > 0 ) {
1820 QString pwd = getPassword(); 1822 QString pwd = getPassword();
1821 command = command.left( fi )+ pwd + command.mid( fi+5 ); 1823 command = command.left( fi )+ pwd + command.mid( fi+5 );
1822 1824
1823 } 1825 }
1824 int maxlen = 30; 1826 int maxlen = 30;
1825 if ( QApplication::desktop()->width() > 320 ) 1827 if ( QApplication::desktop()->width() > 320 )
1826 maxlen += 25; 1828 maxlen += 25;
1827 setCaption ( i18n( "Copy remote file to local machine..." ) ); 1829 setCaption ( i18n( "Copy remote file to local machine..." ) );
1828 int fileSize = 0; 1830 int fileSize = 0;
1829 int result = system ( command ); 1831 int result = system ( command );
1830 // 0 : okay 1832 // 0 : okay
1831 // 256: no such file or dir 1833 // 256: no such file or dir
1832 // 1834 //
1833 qDebug("KO: Remote copy result(0 = okay): %d ",result ); 1835 qDebug("KO: Remote copy result(0 = okay): %d ",result );
1834 if ( result != 0 ) { 1836 if ( result != 0 ) {
1835 int len = maxlen; 1837 int len = maxlen;
1836 while ( len < command.length() ) { 1838 while ( len < command.length() ) {
1837 command.insert( len , "\n" ); 1839 command.insert( len , "\n" );
1838 len += maxlen +2; 1840 len += maxlen +2;
1839 } 1841 }
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 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) ;
1841 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), 1843 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
1842 question, 1844 question,
1843 i18n("Okay!")) ; 1845 i18n("Okay!")) ;
1844 setCaption ("KO/Pi"); 1846 setCaption ("KO/Pi");
1845 return; 1847 return;
1846 } 1848 }
1847 setCaption ( i18n( "Copying succeed." ) ); 1849 setCaption ( i18n( "Copying succeed." ) );
1848 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); 1850 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
1849 if ( syncWithFile( prof->getLocalTempFile(), true ) ) { 1851 if ( syncWithFile( prof->getLocalTempFile(), true ) ) {
1850// Event* e = mView->getLastSyncEvent(); 1852// Event* e = mView->getLastSyncEvent();
1851// e->setReadOnly( false ); 1853// e->setReadOnly( false );
1852// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 1854// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
1853// e->setReadOnly( true ); 1855// e->setReadOnly( true );
1854 if ( KOPrefs::instance()->mWriteBackFile ) { 1856 if ( KOPrefs::instance()->mWriteBackFile ) {
1855 command = prof->getPostSyncCommand(); 1857 command = prof->getPostSyncCommand();
1856 setCaption ( i18n( "Writing back file ..." ) ); 1858 setCaption ( i18n( "Writing back file ..." ) );
1857 result = system ( command ); 1859 result = system ( command );
1858 qDebug("KO: Writing back file result: %d ", result); 1860 qDebug("KO: Writing back file result: %d ", result);
1859 if ( result != 0 ) { 1861 if ( result != 0 ) {
1860 setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); 1862 setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
1861 return; 1863 return;
1862 } else { 1864 } else {
1863 setCaption ( i18n( "Syncronization sucessfully completed" ) ); 1865 setCaption ( i18n( "Syncronization sucessfully completed" ) );
1864 } 1866 }
1865 } 1867 }
1866 } 1868 }
1867 return; 1869 return;
1868} 1870}
1869void MainWindow::syncSSH() 1871void MainWindow::syncSSH()
1870{ 1872{
1871 // not used anymore 1873 // not used anymore
1872 QTime timer; 1874 QTime timer;
1873 timer.start(); 1875 timer.start();
1874 //qDebug("MainWindow::syncssh() "); 1876 //qDebug("MainWindow::syncssh() ");
1875 KOPrefs *p = KOPrefs::instance(); 1877 KOPrefs *p = KOPrefs::instance();
1876 QString localFile = p->mLocalTempFile; 1878 QString localFile = p->mLocalTempFile;
1877 QString remoteIP = p->mRemoteIP; 1879 QString remoteIP = p->mRemoteIP;
1878 QString remoteUser = p->mRemoteUser; 1880 QString remoteUser = p->mRemoteUser;
1879 QString remoteFile = p->mRemoteFile; 1881 QString remoteFile = p->mRemoteFile;
1880 if ( p->mUsePassWd && p->mRemotePassWd.length() > 0 ) 1882 if ( p->mUsePassWd && p->mRemotePassWd.length() > 0 )
1881 remoteUser += ":" + p->mRemotePassWd; 1883 remoteUser += ":" + p->mRemotePassWd;
1882 1884
1883 QString question = i18n("Do you really want\nto remote sync?\n \n") + 1885 QString question = i18n("Do you really want\nto remote sync?\n \n") +
1884 i18n("IP: " ) +remoteIP +"\n" + 1886 i18n("IP: " ) +remoteIP +"\n" +
1885 i18n("User: " ) + remoteUser +"\n" ; 1887 i18n("User: " ) + remoteUser +"\n" ;
1886 int maxlen = 30; 1888 int maxlen = 30;
1887 if ( QApplication::desktop()->width() > 320 ) 1889 if ( QApplication::desktop()->width() > 320 )
1888 maxlen += 25; 1890 maxlen += 25;
1889 if ( remoteFile.length() > maxlen ) 1891 if ( remoteFile.length() > maxlen )
1890 question += i18n("Remote file:\n..." ) + remoteFile.right(maxlen) +"\n"; 1892 question += i18n("Remote file:\n..." ) + remoteFile.right(maxlen) +"\n";
1891 else 1893 else
1892 question += i18n("Remote file:\n " ) + remoteFile +"\n"; 1894 question += i18n("Remote file:\n " ) + remoteFile +"\n";
1893 if ( localFile.length() > maxlen ) 1895 if ( localFile.length() > maxlen )
1894 question += i18n("Local temp file:\n..." ) + localFile.right(maxlen) +"\n"; 1896 question += i18n("Local temp file:\n..." ) + localFile.right(maxlen) +"\n";
1895 else 1897 else
1896 question += i18n("Local temp file:\n " ) + localFile +"\n"; 1898 question += i18n("Local temp file:\n " ) + localFile +"\n";
1897 1899
1898 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 1900 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
1899 question, 1901 question,
1900 i18n("Yes"), i18n("No"), 1902 i18n("Yes"), i18n("No"),
1901 0, 0 ) != 0 ) 1903 0, 0 ) != 0 )
1902 return; 1904 return;
1903 // if ( !p->mUsePassWd ) { 1905 // if ( !p->mUsePassWd ) {
1904 // QString pass = getPassword(); 1906 // QString pass = getPassword();
1905 // if ( pass.length() > 0 ) 1907 // if ( pass.length() > 0 )
1906 // remoteUser += ":" + pass; 1908 // remoteUser += ":" + pass;
1907 // } 1909 // }
1908 QString command = "scp " + remoteUser + "@" + remoteIP +":" + remoteFile +" " +localFile; 1910 QString command = "scp " + remoteUser + "@" + remoteIP +":" + remoteFile +" " +localFile;
1909 setCaption ( i18n( "Copy remote file to local machine..." ) ); 1911 setCaption ( i18n( "Copy remote file to local machine..." ) );
1910 int fileSize = 0; 1912 int fileSize = 0;
1911 int result = system ( command ); 1913 int result = system ( command );
1912 // 0 : okay 1914 // 0 : okay
1913 // 256: no such file or dir 1915 // 256: no such file or dir
1914 // 1916 //
1915 qDebug("KO: Remote copy result(0 = okay): %d ",result ); 1917 qDebug("KO: Remote copy result(0 = okay): %d ",result );
1916 if ( result != 0 ) { 1918 if ( result != 0 ) {
1917 int len = maxlen; 1919 int len = maxlen;
1918 while ( len < command.length() ) { 1920 while ( len < command.length() ) {
1919 command.insert( len , "\n" ); 1921 command.insert( len , "\n" );
1920 len += maxlen +2; 1922 len += maxlen +2;
1921 } 1923 }
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 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) ;
1923 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), 1925 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
1924 question, 1926 question,
1925 i18n("Okay!")) ; 1927 i18n("Okay!")) ;
1926 setCaption ("KO/Pi"); 1928 setCaption ("KO/Pi");
1927 return; 1929 return;
1928 } 1930 }
1929 1931
1930 1932
1931 setCaption ( i18n( "Copying succeed." ) ); 1933 setCaption ( i18n( "Copying succeed." ) );
1932 //mView->setSyncDevice("ssh-scp" ); 1934 //mView->setSyncDevice("ssh-scp" );
1933 if ( syncWithFile(localFile , true ) ) { 1935 if ( syncWithFile(localFile , true ) ) {
1934// Event* e = mView->getLastSyncEvent(); 1936// Event* e = mView->getLastSyncEvent();
1935// e->setReadOnly( false ); 1937// e->setReadOnly( false );
1936// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 1938// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
1937// e->setReadOnly( true ); 1939// e->setReadOnly( true );
1938 if ( KOPrefs::instance()->mWriteBackFile ) { 1940 if ( KOPrefs::instance()->mWriteBackFile ) {
1939 command = "scp " + localFile +" " +remoteUser + "@" + remoteIP +":" + remoteFile ; 1941 command = "scp " + localFile +" " +remoteUser + "@" + remoteIP +":" + remoteFile ;
1940 setCaption ( i18n( "Writing back file ..." ) ); 1942 setCaption ( i18n( "Writing back file ..." ) );
1941 result = system ( command ); 1943 result = system ( command );
1942 if ( result != 0 ) { 1944 if ( result != 0 ) {
1943 int len = maxlen; 1945 int len = maxlen;
1944 while ( len < command.length() ) { 1946 while ( len < command.length() ) {
1945 command.insert( len , "\n" ); 1947 command.insert( len , "\n" );
1946 len += maxlen +2; 1948 len += maxlen +2;
1947 } 1949 }
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 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) ;
1949 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), 1951 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
1950 question, 1952 question,
1951 i18n("Okay!")) ; 1953 i18n("Okay!")) ;
1952 setCaption ("KO/Pi"); 1954 setCaption ("KO/Pi");
1953 return; 1955 return;
1954 } else { 1956 } else {
1955 setCaption ( i18n( "Syncronization sucessfully completed" ) ); 1957 setCaption ( i18n( "Syncronization sucessfully completed" ) );
1956 } 1958 }
1957 } 1959 }
1958 } 1960 }
1959 return; 1961 return;
1960#if 0 1962#if 0
1961 system ("scp zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics /home/polo/Applications/korganizer/z_sync.ics"); 1963 system ("scp zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics /home/polo/Applications/korganizer/z_sync.ics");
1962 while ( timer.elapsed() < 5000 ) 1964 while ( timer.elapsed() < 5000 )
1963 qApp->processEvents(); 1965 qApp->processEvents();
1964 1966
1965 qDebug("MainWindow::merging) "); 1967 qDebug("MainWindow::merging) ");
1966 mView->syncCalendar( "/home/polo/Applications/korganizer/z_sync.ics", 0 ); 1968 mView->syncCalendar( "/home/polo/Applications/korganizer/z_sync.ics", 0 );
1967 while ( mBlockSaveFlag ) 1969 while ( mBlockSaveFlag )
1968 qApp->processEvents(); 1970 qApp->processEvents();
1969 save(); 1971 save();
1970 system ("scp /home/polo/Applications/korganizer/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics"); 1972 system ("scp /home/polo/Applications/korganizer/mycalendar.ics zaurus@192.168.0.65:/home/zaurus/Applications/korganizer/mycalendar.ics");
1971#endif 1973#endif
1972 1974
1973} 1975}
1974 1976
1975 1977
1976void MainWindow::syncSharp() 1978void MainWindow::syncSharp()
1977{ 1979{
1978 if ( mCalendarModifiedFlag ) 1980 if ( mCalendarModifiedFlag )
1979 save(); 1981 save();
1980 mView->syncSharp(); 1982 mView->syncSharp();
1981 slotModifiedChanged( true ); 1983 slotModifiedChanged( true );
1982 1984
1983} 1985}
1984 1986
1985void MainWindow::printSel( ) 1987void MainWindow::printSel( )
1986{ 1988{
1987 mView->viewManager()->agendaView()->agenda()->printSelection(); 1989 mView->viewManager()->agendaView()->agenda()->printSelection();
1988} 1990}
1989 1991
1990void MainWindow::printCal() 1992void MainWindow::printCal()
1991{ 1993{
1992 mView->print();//mCp->showDialog(); 1994 mView->print();//mCp->showDialog();
1993} 1995}
diff --git a/libkdepim/ksyncprefsdialog.cpp b/libkdepim/ksyncprefsdialog.cpp
index 8d610d8..3df2a3b 100644
--- a/libkdepim/ksyncprefsdialog.cpp
+++ b/libkdepim/ksyncprefsdialog.cpp
@@ -1,468 +1,471 @@
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 <qdir.h>
33#include <qtextstream.h> 33#include <qtextstream.h>
34#include <qcombobox.h> 34#include <qcombobox.h>
35#include <qvbox.h> 35#include <qvbox.h>
36#include <qhbox.h> 36#include <qhbox.h>
37#include <qspinbox.h> 37#include <qspinbox.h>
38#include <qdatetime.h> 38#include <qdatetime.h>
39#include <qcheckbox.h> 39#include <qcheckbox.h>
40#include <qradiobutton.h> 40#include <qradiobutton.h>
41#include <qpushbutton.h> 41#include <qpushbutton.h>
42#include <qstrlist.h> 42#include <qstrlist.h>
43#include <qapplication.h> 43#include <qapplication.h>
44#include <qlayout.h> 44#include <qlayout.h>
45#include <qscrollview.h> 45#include <qscrollview.h>
46 46
47#include <kcolorbutton.h> 47#include <kcolorbutton.h>
48#include <kdebug.h> 48#include <kdebug.h>
49#include <klocale.h> 49#include <klocale.h>
50#include <kglobal.h> 50#include <kglobal.h>
51#include <kfontdialog.h> 51#include <kfontdialog.h>
52#include <kmessagebox.h> 52#include <kmessagebox.h>
53#include <kcolordialog.h> 53#include <kcolordialog.h>
54#include <kiconloader.h> 54#include <kiconloader.h>
55#include <kemailsettings.h> 55#include <kemailsettings.h>
56#include <kstandarddirs.h> 56#include <kstandarddirs.h>
57#include <kfiledialog.h> 57#include <kfiledialog.h>
58#include <kmessagebox.h> 58#include <kmessagebox.h>
59 59
60//#include <kurlrequester.h> 60//#include <kurlrequester.h>
61#include <klineedit.h> 61#include <klineedit.h>
62#include "ksyncprofile.h" 62#include "ksyncprofile.h"
63 63
64 64
65//#include "koprefs.h" 65//#include "koprefs.h"
66 66
67#include "ksyncprefsdialog.h" 67#include "ksyncprefsdialog.h"
68//#include "koglobals.h" 68//#include "koglobals.h"
69 69
70 70
71KSyncPrefsDialog::KSyncPrefsDialog(QWidget *parent, char *name, bool modal) : 71KSyncPrefsDialog::KSyncPrefsDialog(QWidget *parent, char *name, bool modal) :
72 KDialog(parent,name,true) 72 KDialog(parent,name,true)
73{ 73{
74 74
75 setCaption( i18n("Synchronization Preferences")); 75 setCaption( i18n("Synchronization Preferences"));
76 76
77 mSyncProfiles.setAutoDelete( true ); 77 mSyncProfiles.setAutoDelete( true );
78 setupSyncAlgTab(); 78 setupSyncAlgTab();
79} 79}
80 80
81 81
82KSyncPrefsDialog::~KSyncPrefsDialog() 82KSyncPrefsDialog::~KSyncPrefsDialog()
83{ 83{
84} 84}
85 85
86void KSyncPrefsDialog::setupSyncAlgTab() 86void KSyncPrefsDialog::setupSyncAlgTab()
87{ 87{
88 QLabel * lab; 88 QLabel * lab;
89 //QFrame *page = addPage(i18n("Sync Prefs"),0,0); 89 //QFrame *page = addPage(i18n("Sync Prefs"),0,0);
90 QVBox * mainbox = new QVBox( this ); 90 QVBox * mainbox = new QVBox( this );
91 QScrollView* sv = new QScrollView( mainbox ); 91 QScrollView* sv = new QScrollView( mainbox );
92 QHBoxLayout * lay = new QHBoxLayout( this ); 92 QHBoxLayout * lay = new QHBoxLayout( this );
93 lay->addWidget( mainbox ); 93 lay->addWidget( mainbox );
94 QHBox * b_box = new QHBox( mainbox ); 94 QHBox * b_box = new QHBox( mainbox );
95 95
96 QPushButton* button = new QPushButton( i18n("Ok"), b_box ); 96 QPushButton* button = new QPushButton( i18n("Ok"), b_box );
97 connect ( button, SIGNAL( clicked()), this, SLOT (slotOK() ) ); 97 connect ( button, SIGNAL( clicked()), this, SLOT (slotOK() ) );
98 button = new QPushButton( i18n("Cancel"), b_box ); 98 button = new QPushButton( i18n("Cancel"), b_box );
99 connect ( button, SIGNAL( clicked()), this, SLOT (reject() ) ); 99 connect ( button, SIGNAL( clicked()), this, SLOT (reject() ) );
100 //QBoxLayout * sl = new QVBoxLayout(this ); 100 //QBoxLayout * sl = new QVBoxLayout(this );
101 //sl->addWidget ( sv ); 101 //sl->addWidget ( sv );
102 sv->setResizePolicy ( QScrollView::AutoOneFit ); 102 sv->setResizePolicy ( QScrollView::AutoOneFit );
103 QFrame *topFrame = new QFrame ( sv ); 103 QFrame *topFrame = new QFrame ( sv );
104 sv->addChild( topFrame ); 104 sv->addChild( topFrame );
105 mSetupSyncAlgTab = topFrame; 105 mSetupSyncAlgTab = topFrame;
106 QGridLayout *topLayout = new QGridLayout(topFrame,6,2); 106 QGridLayout *topLayout = new QGridLayout(topFrame,6,2);
107 topLayout->setSpacing(spacingHint()); 107 topLayout->setSpacing(spacingHint());
108 topLayout->setMargin(marginHint()); 108 topLayout->setMargin(marginHint());
109 109
110 //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);
111 int iii = 0; 111 int iii = 0;
112 //topLayout->addMultiCellWidget(lab , iii,iii,0,1); 112 //topLayout->addMultiCellWidget(lab , iii,iii,0,1);
113 //++iii; 113 //++iii;
114 114
115 mMyMachineName = new QLineEdit(topFrame); 115 mMyMachineName = new QLineEdit(topFrame);
116 lab = new QLabel(mMyMachineName, i18n("Local device name:"), topFrame); 116 lab = new QLabel(mMyMachineName, i18n("Local device name:"), topFrame);
117 topLayout->addWidget(lab ,iii,0); 117 topLayout->addWidget(lab ,iii,0);
118 topLayout->addWidget(mMyMachineName,iii,1); 118 topLayout->addWidget(mMyMachineName,iii,1);
119 ++iii; 119 ++iii;
120 120
121 QHBox* buttonbox = new QHBox( topFrame); 121 QHBox* buttonbox = new QHBox( topFrame);
122 topLayout->addMultiCellWidget(buttonbox, iii,iii,0,1); 122 topLayout->addMultiCellWidget(buttonbox, iii,iii,0,1);
123 ++iii; 123 ++iii;
124 button = new QPushButton( i18n("New profile"), buttonbox ); 124 button = new QPushButton( i18n("New profile"), buttonbox );
125 connect ( button, SIGNAL( clicked()), this, SLOT (newProfile() ) ); 125 connect ( button, SIGNAL( clicked()), this, SLOT (newProfile() ) );
126 126
127 button = new QPushButton( i18n("Clone profile"), buttonbox ); 127 button = new QPushButton( i18n("Clone profile"), buttonbox );
128 connect ( button, SIGNAL( clicked()), this, SLOT ( cloneProfile() ) ); 128 connect ( button, SIGNAL( clicked()), this, SLOT ( cloneProfile() ) );
129 129
130 button = new QPushButton( i18n("Delete profile"), buttonbox ); 130 button = new QPushButton( i18n("Delete profile"), buttonbox );
131 connect ( button, SIGNAL( clicked()), this, SLOT (deleteProfile() ) ); 131 connect ( button, SIGNAL( clicked()), this, SLOT (deleteProfile() ) );
132 132
133 mProfileBox = new QComboBox(topFrame); 133 mProfileBox = new QComboBox(topFrame);
134 mProfileBox->setEditable ( true ); 134 mProfileBox->setEditable ( true );
135 connect ( mProfileBox, SIGNAL(activated ( int ) ), this, SLOT (profileChanged( int ) ) ); 135 connect ( mProfileBox, SIGNAL(activated ( int ) ), this, SLOT (profileChanged( int ) ) );
136 connect ( mProfileBox, SIGNAL( textChanged ( const QString & ) ), this, SLOT (textChanged( const QString & ) ) ); 136 connect ( mProfileBox, SIGNAL( textChanged ( const QString & ) ), this, SLOT (textChanged( const QString & ) ) );
137 137
138 lab = new QLabel(mProfileBox, i18n("Profile:"), topFrame); 138 lab = new QLabel(mProfileBox, i18n("Profile:"), topFrame);
139 topLayout->addWidget(lab ,iii,0); 139 topLayout->addWidget(lab ,iii,0);
140 topLayout->addWidget(mProfileBox, iii,1); 140 topLayout->addWidget(mProfileBox, iii,1);
141 ++iii; 141 ++iii;
142 142
143 mIncludeInRing = new QCheckBox( i18n("Include in multiple sync"), topFrame ); 143 mIncludeInRing = new QCheckBox( i18n("Include in multiple sync"), topFrame );
144 topLayout->addMultiCellWidget(mIncludeInRing, iii,iii,0,1); 144 topLayout->addMultiCellWidget(mIncludeInRing, iii,iii,0,1);
145 ++iii; 145 ++iii;
146 146
147 mAskForPreferences = new QCheckBox( i18n("Ask for preferences before sync"), topFrame ); 147 mAskForPreferences = new QCheckBox( i18n("Ask for preferences before sync"), topFrame );
148 topLayout->addMultiCellWidget(mAskForPreferences, iii,iii,0,1); 148 topLayout->addMultiCellWidget(mAskForPreferences, iii,iii,0,1);
149 ++iii; 149 ++iii;
150 QButtonGroup* gr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Sync preferences"), topFrame); 150 QButtonGroup* gr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Sync preferences"), topFrame);
151 topLayout->addMultiCellWidget(gr, iii,iii,0,1); 151 topLayout->addMultiCellWidget(gr, iii,iii,0,1);
152 ++iii; 152 ++iii;
153 loc = new QRadioButton ( i18n("Take local entry on conflict"), gr ); 153 loc = new QRadioButton ( i18n("Take local entry on conflict"), gr );
154 rem = new QRadioButton ( i18n("Take remote entry on conflict"), gr ); 154 rem = new QRadioButton ( i18n("Take remote entry on conflict"), gr );
155 newest = new QRadioButton ( i18n("Take newest entry on conflict"), gr ); 155 newest = new QRadioButton ( i18n("Take newest entry on conflict"), gr );
156 ask = new QRadioButton ( i18n("Ask for every entry on conflict"), gr ); 156 ask = new QRadioButton ( i18n("Ask for every entry on conflict"), gr );
157 f_loc= new QRadioButton ( i18n("Force: Take local entry always"), gr ); 157 f_loc= new QRadioButton ( i18n("Force: Take local entry always"), gr );
158 f_rem = new QRadioButton ( i18n("Force: Take remote entry always"), gr ); 158 f_rem = new QRadioButton ( i18n("Force: Take remote entry always"), gr );
159 // both = new QRadioButton ( i18n("Take both on conflict"), gr ); 159 // both = new QRadioButton ( i18n("Take both on conflict"), gr );
160 160
161 mShowSummaryAfterSync = new QCheckBox( i18n("Show summary after sync"), topFrame ); 161 mShowSummaryAfterSync = new QCheckBox( i18n("Show summary after sync"), topFrame );
162 topLayout->addMultiCellWidget(mShowSummaryAfterSync, iii,iii,0,1); 162 topLayout->addMultiCellWidget(mShowSummaryAfterSync, iii,iii,0,1);
163 ++iii; 163 ++iii;
164 164
165 mWriteBackExisting= new QCheckBox( i18n("Write back existing entries only"), topFrame ); 165 mWriteBackExisting= new QCheckBox( i18n("Write back existing entries only"), topFrame );
166 topLayout->addMultiCellWidget(mWriteBackExisting, iii,iii,0,1); 166 topLayout->addMultiCellWidget(mWriteBackExisting, iii,iii,0,1);
167 ++iii; 167 ++iii;
168 168
169 mWriteBackFile = new QCheckBox( i18n("Write back file"), topFrame ); 169 mWriteBackFile = new QCheckBox( i18n("Write back file"), topFrame );
170 topLayout->addMultiCellWidget(mWriteBackFile, iii,iii,0,1); 170 topLayout->addMultiCellWidget(mWriteBackFile, iii,iii,0,1);
171 ++iii; 171 ++iii;
172 172
173 proGr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Profile kind"), topFrame); 173 proGr = new QButtonGroup ( 1, Qt::Horizontal, i18n("Profile kind"), topFrame);
174 gr = proGr; 174 gr = proGr;
175 topLayout->addMultiCellWidget(gr, iii,iii,0,1); 175 topLayout->addMultiCellWidget(gr, iii,iii,0,1);
176 ++iii; 176 ++iii;
177 mIsLocal = new QRadioButton ( i18n("Local file"), gr ); 177 mIsLocal = new QRadioButton ( i18n("Local file"), gr );
178 mIsNotLocal = new QRadioButton ( i18n("Remote file (w down/upload command)"), gr ); 178 mIsNotLocal = new QRadioButton ( i18n("Remote file (w down/upload command)"), gr );
179 connect (mIsLocal, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) ); 179 connect (mIsLocal, SIGNAL( toggled(bool)), this, SLOT (kindChanged(bool) ) );
180 180
181 localFileWidget = new QVBox( topFrame); 181 localFileWidget = new QVBox( topFrame);
182 topLayout->addMultiCellWidget(localFileWidget, iii,iii,0,1); 182 topLayout->addMultiCellWidget(localFileWidget, iii,iii,0,1);
183 ++iii; 183 ++iii;
184 QHBox* temphb = new QHBox( localFileWidget ); 184 QHBox* temphb = new QHBox( localFileWidget );
185 lab = new QLabel( i18n("Local file:"), temphb); 185 lab = new QLabel( i18n("Local file:"), temphb);
186 mRemoteFile = new QLineEdit(localFileWidget); 186 mRemoteFile = new QLineEdit(localFileWidget);
187 187
188 button = new QPushButton( i18n("Choose..."), temphb ); 188 button = new QPushButton( i18n("Choose..."), temphb );
189 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFile() ) ); 189 connect ( button, SIGNAL( clicked()), this, SLOT ( chooseFile() ) );
190 190
191 191
192 remoteFileWidget = new QVBox( topFrame); 192 remoteFileWidget = new QVBox( topFrame);
193 topLayout->addMultiCellWidget(remoteFileWidget, iii,iii,0,1); 193 topLayout->addMultiCellWidget(remoteFileWidget, iii,iii,0,1);
194 ++iii; 194 ++iii;
195 lab = new QLabel( i18n("Pre sync (download) command:"), remoteFileWidget); 195 lab = new QLabel( i18n("Pre sync (download) command:"), remoteFileWidget);
196 mRemotePrecommand = new QLineEdit(remoteFileWidget); 196 mRemotePrecommand = new QLineEdit(remoteFileWidget);
197 197
198 lab = new QLabel( i18n("Local temp file:"), remoteFileWidget); 198 lab = new QLabel( i18n("Local temp file:"), remoteFileWidget);
199 mLocalTempFile = new QLineEdit(remoteFileWidget); 199 mLocalTempFile = new QLineEdit(remoteFileWidget);
200 200
201 201
202 lab = new QLabel( i18n("Post sync (upload) command:"), remoteFileWidget); 202 lab = new QLabel( i18n("Post sync (upload) command:"), remoteFileWidget);
203 mRemotePostcommand = new QLineEdit(remoteFileWidget); 203 mRemotePostcommand = new QLineEdit(remoteFileWidget);
204 204
205 lab = new QLabel( i18n("Fill in default values for:"), remoteFileWidget); 205 lab = new QLabel( i18n("Fill in default values for:"), remoteFileWidget);
206 temphb = new QHBox( remoteFileWidget ); 206 temphb = new QHBox( remoteFileWidget );
207 button = new QPushButton( i18n("ssh/scp"), temphb ); 207 button = new QPushButton( i18n("ssh/scp"), temphb );
208 connect ( button, SIGNAL( clicked()), this, SLOT (fillSSH() ) ); 208 connect ( button, SIGNAL( clicked()), this, SLOT (fillSSH() ) );
209 button = new QPushButton( i18n("ftp"), temphb ); 209 button = new QPushButton( i18n("ftp"), temphb );
210 connect ( button, SIGNAL( clicked()), this, SLOT (fillFTP() ) ); 210 connect ( button, SIGNAL( clicked()), this, SLOT (fillFTP() ) );
211 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);
212 212
213 213
214} 214}
215void KSyncPrefsDialog::slotOK() 215void KSyncPrefsDialog::slotOK()
216{ 216{
217 if ( mMyMachineName->text() == "undefined" ) { 217 if ( mMyMachineName->text() == "undefined" ) {
218 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"));
219 return; 219 return;
220 } 220 }
221 int i; 221 int i;
222 for (i = 0; i < mSyncProfileNames.count(); ++ i) { 222 for (i = 0; i < mSyncProfileNames.count(); ++ i) {
223 if ( mSyncProfileNames.contains( mSyncProfileNames[i]) > 1 ) { 223 if ( mSyncProfileNames.contains( mSyncProfileNames[i]) > 1 ) {
224 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"));
225 return; 225 return;
226 } 226 }
227 } 227 }
228 usrWriteConfig(); 228 usrWriteConfig();
229 QDialog::accept(); 229 QDialog::accept();
230} 230}
231void KSyncPrefsDialog::accept() 231void KSyncPrefsDialog::accept()
232{ 232{
233 slotOK(); 233 slotOK();
234} 234}
235void KSyncPrefsDialog::chooseFile() 235void KSyncPrefsDialog::chooseFile()
236{ 236{
237 QString fn = QDir::homeDirPath(); 237 QString fn = QDir::homeDirPath();
238 238
239 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); 239 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this );
240 if ( fn == "" ) 240 if ( fn == "" )
241 return; 241 return;
242 mRemoteFile->setText( fn ); 242 mRemoteFile->setText( fn );
243} 243}
244 244
245void KSyncPrefsDialog::textChanged( const QString & s ) 245void KSyncPrefsDialog::textChanged( const QString & s )
246{ 246{
247 if ( mProfileBox->count() == 0 ) 247 if ( mProfileBox->count() == 0 )
248 return; 248 return;
249 if ( currentSelection < 3 ) { 249 if ( currentSelection < 3 ) {
250 //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"));
251 mProfileBox->blockSignals( true ); 251 mProfileBox->blockSignals( true );
252 mProfileBox->setCurrentItem(mProfileBox-> currentItem ()); 252 mProfileBox->setCurrentItem(mProfileBox-> currentItem ());
253 mProfileBox->blockSignals( false ); 253 mProfileBox->blockSignals( false );
254 return; 254 return;
255 } 255 }
256 //qDebug("cur i %d ",mProfileBox-> currentItem () ); 256 //qDebug("cur i %d ",mProfileBox-> currentItem () );
257 mProfileBox->changeItem ( s, mProfileBox-> currentItem () ) ; 257 mProfileBox->changeItem ( s, mProfileBox-> currentItem () ) ;
258 KSyncProfile* prof = mSyncProfiles.at(mProfileBox-> currentItem ()) ; 258 KSyncProfile* prof = mSyncProfiles.at(mProfileBox-> currentItem ()) ;
259 prof->setName( s ); 259 prof->setName( s );
260 mSyncProfileNames[mProfileBox-> currentItem ()] = s; 260 mSyncProfileNames[mProfileBox-> currentItem ()] = s;
261} 261}
262void KSyncPrefsDialog::profileChanged( int item ) 262void KSyncPrefsDialog::profileChanged( int item )
263{ 263{
264 //qDebug("KSyncPrefsDialog::profileChanged %d ", item ); 264 //qDebug("KSyncPrefsDialog::profileChanged %d ", item );
265 KSyncProfile* prof; 265 KSyncProfile* prof;
266 saveProfile(); 266 saveProfile();
267 currentSelection = item; 267 currentSelection = item;
268 prof = mSyncProfiles.at(item) ; 268 prof = mSyncProfiles.at(item) ;
269 mRemotePrecommand->setText(prof->getPreSyncCommand()); 269 mRemotePrecommand->setText(prof->getPreSyncCommand());
270 mRemotePostcommand->setText(prof->getPostSyncCommand()); 270 mRemotePostcommand->setText(prof->getPostSyncCommand());
271 mLocalTempFile->setText(prof->getLocalTempFile()); 271 mLocalTempFile->setText(prof->getLocalTempFile());
272 mRemoteFile->setText(prof->getRemoteFileName()) ; 272 mRemoteFile->setText(prof->getRemoteFileName()) ;
273 mShowSummaryAfterSync->setChecked( prof->getShowSummaryAfterSync()); 273 mShowSummaryAfterSync->setChecked( prof->getShowSummaryAfterSync());
274 mAskForPreferences->setChecked( prof->getAskForPreferences()); 274 mAskForPreferences->setChecked( prof->getAskForPreferences());
275 mWriteBackExisting->setChecked( prof->getWriteBackExisting() ); 275 mWriteBackExisting->setChecked( prof->getWriteBackExisting() );
276 mWriteBackFile->setChecked( prof->getWriteBackFile()); 276 mWriteBackFile->setChecked( prof->getWriteBackFile());
277 mIncludeInRing->setChecked( prof->getIncludeInRingSync() ); 277 mIncludeInRing->setChecked( prof->getIncludeInRingSync() );
278 278
279 switch ( prof->getSyncPrefs() ) { 279 switch ( prof->getSyncPrefs() ) {
280 case 0: 280 case 0:
281 loc->setChecked( true); 281 loc->setChecked( true);
282 break; 282 break;
283 case 1: 283 case 1:
284 rem->setChecked( true ); 284 rem->setChecked( true );
285 break; 285 break;
286 case 2: 286 case 2:
287 newest->setChecked( true); 287 newest->setChecked( true);
288 break; 288 break;
289 case 3: 289 case 3:
290 ask->setChecked( true); 290 ask->setChecked( true);
291 break; 291 break;
292 case 4: 292 case 4:
293 f_loc->setChecked( true); 293 f_loc->setChecked( true);
294 break; 294 break;
295 case 5: 295 case 5:
296 f_rem->setChecked( true); 296 f_rem->setChecked( true);
297 break; 297 break;
298 case 6: 298 case 6:
299 //both->setChecked( true); 299 //both->setChecked( true);
300 break; 300 break;
301 default: 301 default:
302 break; 302 break;
303 } 303 }
304 mIsLocal->setChecked(prof->getIsLocalFileSync()) ; 304 mIsLocal->setChecked(prof->getIsLocalFileSync()) ;
305 mIsNotLocal->setChecked(!prof->getIsLocalFileSync()); 305 mIsNotLocal->setChecked(!prof->getIsLocalFileSync());
306 proGr->setEnabled( item > 2 ); 306 proGr->setEnabled( item > 2 );
307 if ( item < 3 ) { 307 if ( item < 3 ) {
308 localFileWidget->setEnabled(false); 308 localFileWidget->setEnabled(false);
309 remoteFileWidget->setEnabled(false); 309 remoteFileWidget->setEnabled(false);
310 310
311 } else 311 } else
312 kindChanged( prof->getIsLocalFileSync() ); 312 kindChanged( prof->getIsLocalFileSync() );
313} 313}
314 314
315void KSyncPrefsDialog::fillSSH() 315void KSyncPrefsDialog::fillSSH()
316{ 316{
317 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" );
318 mLocalTempFile->setText("/tmp/mycalendar.ics" ); 318 mLocalTempFile->setText("/tmp/mycalendar.ics" );
319 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" );
320} 320}
321void KSyncPrefsDialog::fillFTP() 321void KSyncPrefsDialog::fillFTP()
322{ 322{
323 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" );
324 mLocalTempFile->setText("/tmp/mycalendar.ics" ); 324 mLocalTempFile->setText("/tmp/mycalendar.ics" );
325 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" );
326 326
327} 327}
328void KSyncPrefsDialog::kindChanged( bool b ) 328void KSyncPrefsDialog::kindChanged( bool b )
329{ 329{
330 330
331 localFileWidget->setEnabled(b); 331 localFileWidget->setEnabled(b);
332 remoteFileWidget->setEnabled(!b); 332 remoteFileWidget->setEnabled(!b);
333 333
334} 334}
335void KSyncPrefsDialog::deleteProfile() 335void KSyncPrefsDialog::deleteProfile()
336{ 336{
337 //qDebug("KSyncPrefsDialog::deleteProfile() "); 337 //qDebug("KSyncPrefsDialog::deleteProfile() ");
338 if ( currentSelection >= 0 ) { 338 if ( currentSelection >= 0 ) {
339 if ( currentSelection < 3 ) { 339 if ( currentSelection < 3 ) {
340 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"));
341 return; 341 return;
342 } 342 }
343 KSyncProfile* temp = mSyncProfiles.at(currentSelection); 343 KSyncProfile* temp = mSyncProfiles.at(currentSelection);
344 mSyncProfiles.remove( temp ); 344 mSyncProfiles.remove( temp );
345 mSyncProfileNames.remove( mSyncProfileNames.at( currentSelection )); 345 mSyncProfileNames.remove( mSyncProfileNames.at( currentSelection ));
346 insertProfiles(); 346 insertProfiles();
347 } 347 }
348} 348}
349 349
350void KSyncPrefsDialog::saveProfile() 350void KSyncPrefsDialog::saveProfile()
351{ 351{
352 KSyncProfile* prof; 352 KSyncProfile* prof;
353 if ( currentSelection >= 0 ) { 353 if ( currentSelection >= 0 ) {
354 prof = mSyncProfiles.at(currentSelection) ; 354 prof = mSyncProfiles.at(currentSelection) ;
355 prof->setPreSyncCommand( mRemotePrecommand->text()); 355 prof->setPreSyncCommand( mRemotePrecommand->text());
356 prof->setPostSyncCommand( mRemotePostcommand->text() ); 356 prof->setPostSyncCommand( mRemotePostcommand->text() );
357 prof->setLocalTempFile( mLocalTempFile->text()); 357 prof->setLocalTempFile( mLocalTempFile->text());
358 prof->setRemoteFileName( mRemoteFile->text() ); 358 prof->setRemoteFileName( mRemoteFile->text() );
359 prof->setShowSummaryAfterSync( mShowSummaryAfterSync->isChecked() ); 359 prof->setShowSummaryAfterSync( mShowSummaryAfterSync->isChecked() );
360 prof->setAskForPreferences( mAskForPreferences->isChecked()); 360 prof->setAskForPreferences( mAskForPreferences->isChecked());
361 prof->setWriteBackExisting(mWriteBackExisting->isChecked() ); 361 prof->setWriteBackExisting(mWriteBackExisting->isChecked() );
362 prof->setWriteBackFile( mWriteBackFile->isChecked()); 362 prof->setWriteBackFile( mWriteBackFile->isChecked());
363 prof->setIncludeInRingSync( mIncludeInRing->isChecked() ); 363 prof->setIncludeInRingSync( mIncludeInRing->isChecked() );
364 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 ;
365 prof->setSyncPrefs( syncprefs); 365 prof->setSyncPrefs( syncprefs);
366 prof->setIsLocalFileSync( mIsLocal->isChecked() ); 366 prof->setIsLocalFileSync( mIsLocal->isChecked() );
367 } 367 }
368 368
369} 369}
370 370
371void KSyncPrefsDialog::insertProfiles() 371void KSyncPrefsDialog::insertProfiles()
372{ 372{
373 int curItem = mProfileBox->currentItem(); 373 int curItem = mProfileBox->currentItem();
374 mProfileBox->blockSignals( true ); 374 mProfileBox->blockSignals( true );
375 mProfileBox->clear(); 375 mProfileBox->clear();
376 mProfileBox->insertStringList (mSyncProfileNames ); 376 mProfileBox->insertStringList (mSyncProfileNames );
377 int item = mSyncProfileNames.count() -1; 377 int item = mSyncProfileNames.count() -1;
378 if ( curItem >= 0 && mSyncProfileNames.count() > 0 && curItem < mSyncProfileNames.count() ) 378 if ( curItem >= 0 && mSyncProfileNames.count() > 0 && curItem < mSyncProfileNames.count() )
379 mProfileBox->setCurrentItem( curItem ); 379 mProfileBox->setCurrentItem( curItem );
380 else if ( item >= 0 ) { 380 else if ( item >= 0 ) {
381 mProfileBox->setCurrentItem( item ); 381 mProfileBox->setCurrentItem( item );
382 } 382 }
383 currentSelection = -1; 383 currentSelection = -1;
384 if ( mSyncProfileNames.count() > 0 ) { 384 if ( mSyncProfileNames.count() > 0 ) {
385 //qDebug(" profileChanged( mProfileBox->currentItem() "); 385 //qDebug(" profileChanged( mProfileBox->currentItem() ");
386 profileChanged( mProfileBox->currentItem() ); 386 profileChanged( mProfileBox->currentItem() );
387 currentSelection = mProfileBox->currentItem(); 387 currentSelection = mProfileBox->currentItem();
388 } 388 }
389 mProfileBox->blockSignals( false ); 389 mProfileBox->blockSignals( false );
390} 390}
391 391
392void KSyncPrefsDialog::addProfile ( KSyncProfile* temp ) 392void KSyncPrefsDialog::addProfile ( KSyncProfile* temp )
393{ 393{
394 saveProfile(); 394 saveProfile();
395 mSyncProfiles.append( temp ); 395 mSyncProfiles.append( temp );
396 mSyncProfileNames << temp->getName(); 396 mSyncProfileNames << temp->getName();
397 insertProfiles(); 397 insertProfiles();
398 int last = mProfileBox->count() -1; 398 int last = mProfileBox->count() -1;
399 mProfileBox->blockSignals( true ); 399 mProfileBox->blockSignals( true );
400 mProfileBox->setCurrentItem( last ); 400 mProfileBox->setCurrentItem( last );
401 mProfileBox->blockSignals( false ); 401 mProfileBox->blockSignals( false );
402 profileChanged(last); 402 profileChanged(last);
403} 403}
404void KSyncPrefsDialog::newProfile() 404void KSyncPrefsDialog::newProfile()
405{ 405{
406 addProfile ( new KSyncProfile () ); 406 addProfile ( new KSyncProfile () );
407} 407}
408 408
409void KSyncPrefsDialog::cloneProfile() 409void KSyncPrefsDialog::cloneProfile()
410{ 410{
411 if ( currentSelection >= 0 ) 411 if ( currentSelection >= 0 )
412 addProfile (mSyncProfiles.at(currentSelection)->clone()) ; 412 addProfile (mSyncProfiles.at(currentSelection)->clone()) ;
413 else 413 else
414 newProfile(); 414 newProfile();
415} 415}
416 416
417void KSyncPrefsDialog::setLocalMachineName ( const QString& name ) 417void KSyncPrefsDialog::setLocalMachineName ( const QString& name )
418{ 418{
419 mMyMachineName->setText( name ); 419 mMyMachineName->setText( name );
420 420
421} 421}
422QString KSyncPrefsDialog::getLocalMachineName ( ) 422QString KSyncPrefsDialog::getLocalMachineName ( )
423{ 423{
424 return mMyMachineName->text(); 424 return mMyMachineName->text();
425} 425}
426 426
427QStringList KSyncPrefsDialog::getSyncProfileNames() 427QStringList KSyncPrefsDialog::getSyncProfileNames()
428{ 428{
429 return mSyncProfileNames; 429 return mSyncProfileNames;
430} 430}
431void KSyncPrefsDialog::usrReadConfig() 431void KSyncPrefsDialog::usrReadConfig()
432{ 432{
433 //KConfig *config = KOGlobals::config(); 433 //KConfig *config = KOGlobals::config();
434 KConfig config ( locateLocal( "config","syncprofilesrc" ) ); 434 KConfig config ( locateLocal( "config","syncprofilesrc" ) );
435 config.setGroup("SyncProfiles"); 435 config.setGroup("SyncProfiles");
436 mSyncProfileNames =config.readListEntry("SyncProfileNames"); 436 mSyncProfileNames =config.readListEntry("SyncProfileNames");
437 mMyMachineName->setText(config.readEntry("LocalMachineName","undefined"));
437 int i; 438 int i;
438 KSyncProfile* temp ; 439 KSyncProfile* temp ;
439 mSyncProfiles.clear(); 440 mSyncProfiles.clear();
440 for ( i = 0; i < mSyncProfileNames.count();++i ) { 441 for ( i = 0; i < mSyncProfileNames.count();++i ) {
441 temp = new KSyncProfile (); 442 temp = new KSyncProfile ();
442 temp->setName( mSyncProfileNames[i] ); 443 temp->setName( mSyncProfileNames[i] );
443 temp->readConfig( &config ); 444 temp->readConfig( &config );
444 mSyncProfiles.append( temp ); 445 mSyncProfiles.append( temp );
445 } 446 }
446 insertProfiles(); 447 insertProfiles();
447 //mMyMachineName->setText(KOPrefs::instance()->mLocalMachineName ); 448 //mMyMachineName->setText(KOPrefs::instance()->mLocalMachineName );
448} 449}
449 450
450 451
451void KSyncPrefsDialog::usrWriteConfig() 452void KSyncPrefsDialog::usrWriteConfig()
452{ 453{
453 saveProfile(); 454 saveProfile();
454 if ( currentSelection >= 0 ) 455 if ( currentSelection >= 0 )
455 profileChanged(currentSelection); 456 profileChanged(currentSelection);
456 //KConfig *config = KOGlobals::config(); 457 //KConfig *config = KOGlobals::config();
457 KConfig config ( locateLocal( "config","syncprofilesrc" ) ); 458 KConfig config ( locateLocal( "config","syncprofilesrc" ) );
458 config.setGroup("SyncProfiles"); 459 config.setGroup("SyncProfiles");
459 KSyncProfile* prof = mSyncProfiles.first(); 460 KSyncProfile* prof = mSyncProfiles.first();
460 while ( prof ) { 461 while ( prof ) {
461 prof->writeConfig(&config); 462 prof->writeConfig(&config);
462 prof = mSyncProfiles.next(); 463 prof = mSyncProfiles.next();
463 } 464 }
464 //KOPrefs::instance()->mSyncProfileNames = mSyncProfileNames; 465 //KOPrefs::instance()->mSyncProfileNames = mSyncProfileNames;
465 //KOPrefs::instance()->mLocalMachineName = mMyMachineName->text(); 466 //KOPrefs::instance()->mLocalMachineName = mMyMachineName->text();
466 config.writeEntry("SyncProfileNames",&mSyncProfileNames); 467 config.writeEntry("SyncProfileNames",mSyncProfileNames);
468 QString name = mMyMachineName->text();
469 config.writeEntry("LocalMachineName",name);
467} 470}
468 471