summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2004-10-18 09:08:13 (UTC)
committer zautrix <zautrix>2004-10-18 09:08:13 (UTC)
commit56990d318b15eacf7d3cc7425ab62f68da099ddf (patch) (unidiff)
treeb2f021bd75bc6a08fa8fc51a07ce1755b8e4a95e /korganizer
parent1712d92ea25b220273859d985bc7211fa7a97a39 (diff)
downloadkdepimpi-56990d318b15eacf7d3cc7425ab62f68da099ddf.zip
kdepimpi-56990d318b15eacf7d3cc7425ab62f68da099ddf.tar.gz
kdepimpi-56990d318b15eacf7d3cc7425ab62f68da099ddf.tar.bz2
fix of tmp file path for desktop version
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp5
-rw-r--r--korganizer/koprefs.cpp6
-rw-r--r--korganizer/mainwindow.cpp4
3 files changed, 6 insertions, 9 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 290c0b9..884c61a 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,3750 +1,3753 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Requires the Qt and KDE widget libraries, available at no cost at 4 Requires the Qt and KDE widget libraries, available at no cost at
5 http://www.troll.no and http://www.kde.org respectively 5 http://www.troll.no and http://www.kde.org respectively
6 6
7 Copyright (c) 1997, 1998, 1999 7 Copyright (c) 1997, 1998, 1999
8 Preston Brown (preston.brown@yale.edu) 8 Preston Brown (preston.brown@yale.edu)
9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) 9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl)
10 Ian Dawes (iadawes@globalserve.net) 10 Ian Dawes (iadawes@globalserve.net)
11 Laszlo Boloni (boloni@cs.purdue.edu) 11 Laszlo Boloni (boloni@cs.purdue.edu)
12 12
13 Copyright (c) 2000, 2001, 2002 13 Copyright (c) 2000, 2001, 2002
14 Cornelius Schumacher <schumacher@kde.org> 14 Cornelius Schumacher <schumacher@kde.org>
15 15
16 This program is free software; you can redistribute it and/or modify 16 This program is free software; you can redistribute it and/or modify
17 it under the terms of the GNU General Public License as published by 17 it under the terms of the GNU General Public License as published by
18 the Free Software Foundation; either version 2 of the License, or 18 the Free Software Foundation; either version 2 of the License, or
19 (at your option) any later version. 19 (at your option) any later version.
20 20
21 This program is distributed in the hope that it will be useful, 21 This program is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of 22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
24 GNU General Public License for more details. 24 GNU General Public License for more details.
25 25
26 You should have received a copy of the GNU General Public License 26 You should have received a copy of the GNU General Public License
27 along with this program; if not, write to the Free Software 27 along with this program; if not, write to the Free Software
28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29*/ 29*/
30 30
31#include <stdlib.h> 31#include <stdlib.h>
32 32
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qradiobutton.h> 34#include <qradiobutton.h>
35#include <qbuttongroup.h> 35#include <qbuttongroup.h>
36#include <qlayout.h> 36#include <qlayout.h>
37#include <qclipboard.h> 37#include <qclipboard.h>
38#include <qcursor.h> 38#include <qcursor.h>
39#include <qmessagebox.h> 39#include <qmessagebox.h>
40#include <qprogressbar.h> 40#include <qprogressbar.h>
41#include <qmultilineedit.h> 41#include <qmultilineedit.h>
42#include <qtimer.h> 42#include <qtimer.h>
43#include <qwidgetstack.h> 43#include <qwidgetstack.h>
44#include <qptrlist.h> 44#include <qptrlist.h>
45#include <qregexp.h> 45#include <qregexp.h>
46#include <qgroupbox.h> 46#include <qgroupbox.h>
47#include <qfile.h> 47#include <qfile.h>
48#include <qdir.h> 48#include <qdir.h>
49#ifndef KORG_NOSPLITTER 49#ifndef KORG_NOSPLITTER
50#include <qsplitter.h> 50#include <qsplitter.h>
51#endif 51#endif
52 52
53#include <kglobal.h> 53#include <kglobal.h>
54#include <kdebug.h> 54#include <kdebug.h>
55#include <kstandarddirs.h> 55#include <kstandarddirs.h>
56#include <kfiledialog.h> 56#include <kfiledialog.h>
57#include <kmessagebox.h> 57#include <kmessagebox.h>
58#include <knotifyclient.h> 58#include <knotifyclient.h>
59#include <kconfig.h> 59#include <kconfig.h>
60 60
61#include <libkdepim/ksyncprefsdialog.h> 61#include <libkdepim/ksyncprefsdialog.h>
62#include <krun.h> 62#include <krun.h>
63#include <kdirwatch.h> 63#include <kdirwatch.h>
64#include <libkdepim/kdatepicker.h> 64#include <libkdepim/kdatepicker.h>
65#include <libkdepim/ksyncprofile.h> 65#include <libkdepim/ksyncprofile.h>
66#include <libkdepim/kpimglobalprefs.h> 66#include <libkdepim/kpimglobalprefs.h>
67 67
68#include <libkcal/vcaldrag.h> 68#include <libkcal/vcaldrag.h>
69#include <libkcal/icaldrag.h> 69#include <libkcal/icaldrag.h>
70#include <libkcal/icalformat.h> 70#include <libkcal/icalformat.h>
71#include <libkcal/vcalformat.h> 71#include <libkcal/vcalformat.h>
72#include <libkcal/scheduler.h> 72#include <libkcal/scheduler.h>
73#include <libkcal/calendarlocal.h> 73#include <libkcal/calendarlocal.h>
74#include <libkcal/journal.h> 74#include <libkcal/journal.h>
75#include <libkcal/calfilter.h> 75#include <libkcal/calfilter.h>
76#include <libkcal/attendee.h> 76#include <libkcal/attendee.h>
77#include <libkcal/dndfactory.h> 77#include <libkcal/dndfactory.h>
78#include <libkcal/freebusy.h> 78#include <libkcal/freebusy.h>
79#include <libkcal/filestorage.h> 79#include <libkcal/filestorage.h>
80#include <libkcal/calendarresources.h> 80#include <libkcal/calendarresources.h>
81#include <libkcal/qtopiaformat.h> 81#include <libkcal/qtopiaformat.h>
82#include "../kalarmd/alarmdialog.h" 82#include "../kalarmd/alarmdialog.h"
83 83
84#ifndef DESKTOP_VERSION 84#ifndef DESKTOP_VERSION
85#include <libkcal/sharpformat.h> 85#include <libkcal/sharpformat.h>
86#include <externalapphandler.h> 86#include <externalapphandler.h>
87#endif 87#endif
88#include <libkcal/phoneformat.h> 88#include <libkcal/phoneformat.h>
89#ifndef KORG_NOMAIL 89#ifndef KORG_NOMAIL
90#include "komailclient.h" 90#include "komailclient.h"
91#endif 91#endif
92#ifndef KORG_NOPRINTER 92#ifndef KORG_NOPRINTER
93#include "calprinter.h" 93#include "calprinter.h"
94#endif 94#endif
95#ifndef KORG_NOPLUGINS 95#ifndef KORG_NOPLUGINS
96#include "kocore.h" 96#include "kocore.h"
97#endif 97#endif
98#include "koeventeditor.h" 98#include "koeventeditor.h"
99#include "kotodoeditor.h" 99#include "kotodoeditor.h"
100#include "koprefs.h" 100#include "koprefs.h"
101#include "koeventviewerdialog.h" 101#include "koeventviewerdialog.h"
102#include "publishdialog.h" 102#include "publishdialog.h"
103#include "kofilterview.h" 103#include "kofilterview.h"
104#include "koglobals.h" 104#include "koglobals.h"
105#include "koviewmanager.h" 105#include "koviewmanager.h"
106#include "koagendaview.h" 106#include "koagendaview.h"
107#include "kodialogmanager.h" 107#include "kodialogmanager.h"
108#include "outgoingdialog.h" 108#include "outgoingdialog.h"
109#include "incomingdialog.h" 109#include "incomingdialog.h"
110#include "statusdialog.h" 110#include "statusdialog.h"
111#include "kdatenavigator.h" 111#include "kdatenavigator.h"
112#include "kotodoview.h" 112#include "kotodoview.h"
113#include "datenavigator.h" 113#include "datenavigator.h"
114#include "resourceview.h" 114#include "resourceview.h"
115#include "navigatorbar.h" 115#include "navigatorbar.h"
116#include "searchdialog.h" 116#include "searchdialog.h"
117#include "mainwindow.h" 117#include "mainwindow.h"
118 118
119#include "calendarview.h" 119#include "calendarview.h"
120#ifndef DESKTOP_VERSION 120#ifndef DESKTOP_VERSION
121#include <qtopia/alarmserver.h> 121#include <qtopia/alarmserver.h>
122#endif 122#endif
123#ifndef _WIN32_ 123#ifndef _WIN32_
124#include <stdlib.h> 124#include <stdlib.h>
125#include <stdio.h> 125#include <stdio.h>
126#include <unistd.h> 126#include <unistd.h>
127#else 127#else
128#include <qprocess.h> 128#include <qprocess.h>
129#endif 129#endif
130 130
131#ifdef DESKTOP_VERSION 131#ifdef DESKTOP_VERSION
132#include <kabc/stdaddressbook.h> 132#include <kabc/stdaddressbook.h>
133#endif 133#endif
134using namespace KOrg; 134using namespace KOrg;
135using namespace KCal; 135using namespace KCal;
136extern int globalFlagBlockAgenda; 136extern int globalFlagBlockAgenda;
137extern int globalFlagBlockStartup; 137extern int globalFlagBlockStartup;
138 138
139 139
140 140
141class KOBeamPrefs : public QDialog 141class KOBeamPrefs : public QDialog
142{ 142{
143 public: 143 public:
144 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : 144 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) :
145 QDialog( parent, name, true ) 145 QDialog( parent, name, true )
146 { 146 {
147 setCaption( i18n("Beam Options") ); 147 setCaption( i18n("Beam Options") );
148 QVBoxLayout* lay = new QVBoxLayout( this ); 148 QVBoxLayout* lay = new QVBoxLayout( this );
149 lay->setSpacing( 3 ); 149 lay->setSpacing( 3 );
150 lay->setMargin( 3 ); 150 lay->setMargin( 3 );
151 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); 151 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this );
152 lay->addWidget( format ); 152 lay->addWidget( format );
153 format->setExclusive ( true ) ; 153 format->setExclusive ( true ) ;
154 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); 154 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this );
155 lay->addWidget( time ); time->setExclusive ( true ) ; 155 lay->addWidget( time ); time->setExclusive ( true ) ;
156 vcal = new QRadioButton(" vCalendar ", format ); 156 vcal = new QRadioButton(" vCalendar ", format );
157 ical = new QRadioButton(" iCalendar ", format ); 157 ical = new QRadioButton(" iCalendar ", format );
158 vcal->setChecked( true ); 158 vcal->setChecked( true );
159 tz = new QRadioButton(i18n(" With timezone "), time ); 159 tz = new QRadioButton(i18n(" With timezone "), time );
160 local = new QRadioButton(i18n(" Local time "), time ); 160 local = new QRadioButton(i18n(" Local time "), time );
161 tz->setChecked( true ); 161 tz->setChecked( true );
162 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); 162 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this );
163 lay->addWidget( ok ); 163 lay->addWidget( ok );
164 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 164 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
165 lay->addWidget( cancel ); 165 lay->addWidget( cancel );
166 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 166 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
167 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 167 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
168 resize( 200, 200 ); 168 resize( 200, 200 );
169 } 169 }
170 170
171 bool beamVcal() { return vcal->isChecked(); } 171 bool beamVcal() { return vcal->isChecked(); }
172 bool beamLocal() { return local->isChecked(); } 172 bool beamLocal() { return local->isChecked(); }
173private: 173private:
174 QRadioButton* vcal, *ical, *local, *tz; 174 QRadioButton* vcal, *ical, *local, *tz;
175}; 175};
176class KOCatPrefs : public QDialog 176class KOCatPrefs : public QDialog
177{ 177{
178 public: 178 public:
179 KOCatPrefs( QWidget *parent=0, const char *name=0 ) : 179 KOCatPrefs( QWidget *parent=0, const char *name=0 ) :
180 QDialog( parent, name, true ) 180 QDialog( parent, name, true )
181 { 181 {
182 setCaption( i18n("Manage new Categories") ); 182 setCaption( i18n("Manage new Categories") );
183 QVBoxLayout* lay = new QVBoxLayout( this ); 183 QVBoxLayout* lay = new QVBoxLayout( this );
184 lay->setSpacing( 3 ); 184 lay->setSpacing( 3 );
185 lay->setMargin( 3 ); 185 lay->setMargin( 3 );
186 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 ); 186 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 );
187 lay->addWidget( lab ); 187 lay->addWidget( lab );
188 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 188 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
189 lay->addWidget( format ); 189 lay->addWidget( format );
190 format->setExclusive ( true ) ; 190 format->setExclusive ( true ) ;
191 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 191 addCatBut = new QRadioButton(i18n("Add to category list"), format );
192 new QRadioButton(i18n("Remove from Events/Todos"), format ); 192 new QRadioButton(i18n("Remove from Events/Todos"), format );
193 addCatBut->setChecked( true ); 193 addCatBut->setChecked( true );
194 QPushButton * ok = new QPushButton( i18n("OK"), this ); 194 QPushButton * ok = new QPushButton( i18n("OK"), this );
195 lay->addWidget( ok ); 195 lay->addWidget( ok );
196 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 196 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
197 lay->addWidget( cancel ); 197 lay->addWidget( cancel );
198 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 198 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
199 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 199 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
200 resize( 200, 200 ); 200 resize( 200, 200 );
201 } 201 }
202 202
203 bool addCat() { return addCatBut->isChecked(); } 203 bool addCat() { return addCatBut->isChecked(); }
204private: 204private:
205 QRadioButton* addCatBut; 205 QRadioButton* addCatBut;
206}; 206};
207 207
208 208
209 209
210CalendarView::CalendarView( CalendarResources *calendar, 210CalendarView::CalendarView( CalendarResources *calendar,
211 QWidget *parent, const char *name ) 211 QWidget *parent, const char *name )
212 : CalendarViewBase( parent, name ), 212 : CalendarViewBase( parent, name ),
213 mCalendar( calendar ), 213 mCalendar( calendar ),
214 mResourceManager( calendar->resourceManager() ) 214 mResourceManager( calendar->resourceManager() )
215{ 215{
216 216
217 mEventEditor = 0; 217 mEventEditor = 0;
218 mTodoEditor = 0; 218 mTodoEditor = 0;
219 219
220 init(); 220 init();
221} 221}
222 222
223CalendarView::CalendarView( Calendar *calendar, 223CalendarView::CalendarView( Calendar *calendar,
224 QWidget *parent, const char *name ) 224 QWidget *parent, const char *name )
225 : CalendarViewBase( parent, name ), 225 : CalendarViewBase( parent, name ),
226 mCalendar( calendar ), 226 mCalendar( calendar ),
227 mResourceManager( 0 ) 227 mResourceManager( 0 )
228{ 228{
229 229
230 mEventEditor = 0; 230 mEventEditor = 0;
231 mTodoEditor = 0; 231 mTodoEditor = 0;
232 init();} 232 init();}
233 233
234void CalendarView::init() 234void CalendarView::init()
235{ 235{
236 beamDialog = new KOBeamPrefs(); 236 beamDialog = new KOBeamPrefs();
237 mDatePickerMode = 0; 237 mDatePickerMode = 0;
238 mCurrentSyncDevice = ""; 238 mCurrentSyncDevice = "";
239 writeLocale(); 239 writeLocale();
240 mViewManager = new KOViewManager( this ); 240 mViewManager = new KOViewManager( this );
241 mDialogManager = new KODialogManager( this ); 241 mDialogManager = new KODialogManager( this );
242 mEventViewerDialog = 0; 242 mEventViewerDialog = 0;
243 mModified = false; 243 mModified = false;
244 mReadOnly = false; 244 mReadOnly = false;
245 mSelectedIncidence = 0; 245 mSelectedIncidence = 0;
246 mCalPrinter = 0; 246 mCalPrinter = 0;
247 mFilters.setAutoDelete(true); 247 mFilters.setAutoDelete(true);
248 248
249 mCalendar->registerObserver( this ); 249 mCalendar->registerObserver( this );
250 // TODO: Make sure that view is updated, when calendar is changed. 250 // TODO: Make sure that view is updated, when calendar is changed.
251 251
252 mStorage = new FileStorage( mCalendar ); 252 mStorage = new FileStorage( mCalendar );
253 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 253 mNavigator = new DateNavigator( this, "datevav", mViewManager );
254 254
255 QBoxLayout *topLayout = (QBoxLayout*)layout(); 255 QBoxLayout *topLayout = (QBoxLayout*)layout();
256#ifndef KORG_NOSPLITTER 256#ifndef KORG_NOSPLITTER
257 // create the main layout frames. 257 // create the main layout frames.
258 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 258 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
259 topLayout->addWidget(mPanner); 259 topLayout->addWidget(mPanner);
260 260
261 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 261 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
262 "CalendarView::LeftFrame"); 262 "CalendarView::LeftFrame");
263 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 263 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
264 264
265 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, 265 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE,
266 "CalendarView::DateNavigator", QDate::currentDate() ); 266 "CalendarView::DateNavigator", QDate::currentDate() );
267 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 267 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
268 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 268 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
269 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 269 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
270 270
271#ifdef KORG_NORESOURCEVIEW 271#ifdef KORG_NORESOURCEVIEW
272 mResourceView = 0; 272 mResourceView = 0;
273#else 273#else
274 if ( mResourceManager ) { 274 if ( mResourceManager ) {
275 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 275 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
276 mResourceView->updateView(); 276 mResourceView->updateView();
277 connect( mResourceView, SIGNAL( resourcesChanged() ), 277 connect( mResourceView, SIGNAL( resourcesChanged() ),
278 SLOT( updateView() ) ); 278 SLOT( updateView() ) );
279 } else { 279 } else {
280 mResourceView = 0; 280 mResourceView = 0;
281 } 281 }
282#endif 282#endif
283 QWidget *rightBox = new QWidget( mPanner ); 283 QWidget *rightBox = new QWidget( mPanner );
284 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 284 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
285 285
286 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 286 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
287 rightLayout->addWidget( mNavigatorBar ); 287 rightLayout->addWidget( mNavigatorBar );
288 288
289 mRightFrame = new QWidgetStack( rightBox ); 289 mRightFrame = new QWidgetStack( rightBox );
290 rightLayout->addWidget( mRightFrame, 1 ); 290 rightLayout->addWidget( mRightFrame, 1 );
291 291
292 mLeftFrame = mLeftSplitter; 292 mLeftFrame = mLeftSplitter;
293#else 293#else
294 QWidget *mainBox = new QWidget( this ); 294 QWidget *mainBox = new QWidget( this );
295 QWidget *leftFrame = new QWidget( mainBox ); 295 QWidget *leftFrame = new QWidget( mainBox );
296 296
297 QBoxLayout * mainBoxLayout; 297 QBoxLayout * mainBoxLayout;
298 QBoxLayout * leftFrameLayout; 298 QBoxLayout * leftFrameLayout;
299 if ( KOPrefs::instance()->mVerticalScreen ) { 299 if ( KOPrefs::instance()->mVerticalScreen ) {
300 mainBoxLayout = new QVBoxLayout(mainBox); 300 mainBoxLayout = new QVBoxLayout(mainBox);
301 leftFrameLayout = new QHBoxLayout(leftFrame ); 301 leftFrameLayout = new QHBoxLayout(leftFrame );
302 } else { 302 } else {
303 mainBoxLayout = new QHBoxLayout(mainBox); 303 mainBoxLayout = new QHBoxLayout(mainBox);
304 leftFrameLayout = new QVBoxLayout(leftFrame ); 304 leftFrameLayout = new QVBoxLayout(leftFrame );
305 } 305 }
306 topLayout->addWidget( mainBox ); 306 topLayout->addWidget( mainBox );
307 mainBoxLayout->addWidget (leftFrame); 307 mainBoxLayout->addWidget (leftFrame);
308 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, 308 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE,
309 "CalendarView::DateNavigator", QDate::currentDate()); 309 "CalendarView::DateNavigator", QDate::currentDate());
310 // mDateNavigator->blockSignals( true ); 310 // mDateNavigator->blockSignals( true );
311 leftFrameLayout->addWidget( mDateNavigator ); 311 leftFrameLayout->addWidget( mDateNavigator );
312 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); 312 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView");
313 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall"); 313 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall");
314 314
315 if ( QApplication::desktop()->width() < 480 ) { 315 if ( QApplication::desktop()->width() < 480 ) {
316 leftFrameLayout->addWidget(mFilterView); 316 leftFrameLayout->addWidget(mFilterView);
317 leftFrameLayout->addWidget(mTodoList, 2 ); 317 leftFrameLayout->addWidget(mTodoList, 2 );
318 318
319 } else { 319 } else {
320 leftFrameLayout->addWidget(mTodoList,2 ); 320 leftFrameLayout->addWidget(mTodoList,2 );
321 leftFrameLayout->addWidget(mFilterView ); 321 leftFrameLayout->addWidget(mFilterView );
322 } 322 }
323 mFilterView->hide(); 323 mFilterView->hide();
324 QWidget *rightBox = new QWidget( mainBox ); 324 QWidget *rightBox = new QWidget( mainBox );
325 mainBoxLayout->addWidget ( rightBox, 10 ); 325 mainBoxLayout->addWidget ( rightBox, 10 );
326 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 326 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
327 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 327 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
328 mRightFrame = new QWidgetStack( rightBox ); 328 mRightFrame = new QWidgetStack( rightBox );
329 rightLayout->addWidget( mNavigatorBar ); 329 rightLayout->addWidget( mNavigatorBar );
330 rightLayout->addWidget( mRightFrame, 10 ); 330 rightLayout->addWidget( mRightFrame, 10 );
331 331
332 mLeftFrame = leftFrame; 332 mLeftFrame = leftFrame;
333 if ( KOPrefs::instance()->mVerticalScreen ) { 333 if ( KOPrefs::instance()->mVerticalScreen ) {
334 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 334 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
335 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 335 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
336 } else { 336 } else {
337 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 337 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
338 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 338 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
339 } 339 }
340 340
341 //qDebug("Calendarview Size %d %d ", width(), height()); 341 //qDebug("Calendarview Size %d %d ", width(), height());
342#endif 342#endif
343 343
344 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 344 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
345 SLOT( showDates( const KCal::DateList & ) ) ); 345 SLOT( showDates( const KCal::DateList & ) ) );
346 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 346 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
347 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 347 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
348 348
349 connect( mNavigatorBar, SIGNAL( goPrevYear() ), 349 connect( mNavigatorBar, SIGNAL( goPrevYear() ),
350 mNavigator, SLOT( selectPreviousYear() ) ); 350 mNavigator, SLOT( selectPreviousYear() ) );
351 connect( mNavigatorBar, SIGNAL( goNextYear() ), 351 connect( mNavigatorBar, SIGNAL( goNextYear() ),
352 mNavigator, SLOT( selectNextYear() ) ); 352 mNavigator, SLOT( selectNextYear() ) );
353 connect( mNavigatorBar, SIGNAL( goPrevMonth() ), 353 connect( mNavigatorBar, SIGNAL( goPrevMonth() ),
354 mNavigator, SLOT( selectPreviousMonth() ) ); 354 mNavigator, SLOT( selectPreviousMonth() ) );
355 connect( mNavigatorBar, SIGNAL( goNextMonth() ), 355 connect( mNavigatorBar, SIGNAL( goNextMonth() ),
356 mNavigator, SLOT( selectNextMonth() ) ); 356 mNavigator, SLOT( selectNextMonth() ) );
357 357
358 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 358 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
359 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); 359 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) );
360 360
361 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 361 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
362 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 362 mNavigator, SLOT( selectWeek( const QDate & ) ) );
363 363
364 connect( mDateNavigator, SIGNAL( goPrevYear() ), 364 connect( mDateNavigator, SIGNAL( goPrevYear() ),
365 mNavigator, SLOT( selectPreviousYear() ) ); 365 mNavigator, SLOT( selectPreviousYear() ) );
366 connect( mDateNavigator, SIGNAL( goNextYear() ), 366 connect( mDateNavigator, SIGNAL( goNextYear() ),
367 mNavigator, SLOT( selectNextYear() ) ); 367 mNavigator, SLOT( selectNextYear() ) );
368 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 368 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
369 mNavigator, SLOT( selectPreviousMonth() ) ); 369 mNavigator, SLOT( selectPreviousMonth() ) );
370 connect( mDateNavigator, SIGNAL( goNextMonth() ), 370 connect( mDateNavigator, SIGNAL( goNextMonth() ),
371 mNavigator, SLOT( selectNextMonth() ) ); 371 mNavigator, SLOT( selectNextMonth() ) );
372 372
373 connect( mDateNavigator, SIGNAL( goPrevious() ), 373 connect( mDateNavigator, SIGNAL( goPrevious() ),
374 mNavigator, SLOT( selectPrevious() ) ); 374 mNavigator, SLOT( selectPrevious() ) );
375 connect( mDateNavigator, SIGNAL( goNext() ), 375 connect( mDateNavigator, SIGNAL( goNext() ),
376 mNavigator, SLOT( selectNext() ) ); 376 mNavigator, SLOT( selectNext() ) );
377 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 377 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
378 mNavigator, SLOT( slotMonthSelect( int ) ) ); 378 mNavigator, SLOT( slotMonthSelect( int ) ) );
379 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), 379 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ),
380 mNavigator, SLOT( slotMonthSelect( int ) ) ); 380 mNavigator, SLOT( slotMonthSelect( int ) ) );
381 381
382 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 382 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
383 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 383 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
384 384
385 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), 385 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ),
386 SLOT( eventAdded( Event *) ) ); 386 SLOT( eventAdded( Event *) ) );
387 387
388 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 388 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
389 389
390 connect( this, SIGNAL( configChanged() ), 390 connect( this, SIGNAL( configChanged() ),
391 mDateNavigator, SLOT( updateConfig() ) ); 391 mDateNavigator, SLOT( updateConfig() ) );
392 392
393 connect( mTodoList, SIGNAL( newTodoSignal() ), 393 connect( mTodoList, SIGNAL( newTodoSignal() ),
394 SLOT( newTodo() ) ); 394 SLOT( newTodo() ) );
395 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 395 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
396 SLOT( newSubTodo( Todo * ) ) ); 396 SLOT( newSubTodo( Todo * ) ) );
397 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 397 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
398 SLOT( editTodo( Todo * ) ) ); 398 SLOT( editTodo( Todo * ) ) );
399 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 399 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
400 SLOT( showTodo( Todo *) ) ); 400 SLOT( showTodo( Todo *) ) );
401 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 401 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
402 SLOT( deleteTodo( Todo *) ) ); 402 SLOT( deleteTodo( Todo *) ) );
403 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 403 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
404 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 404 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
405 SLOT( purgeCompleted() ) ); 405 SLOT( purgeCompleted() ) );
406 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 406 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
407 SIGNAL( todoModified( Todo *, int ) ) ); 407 SIGNAL( todoModified( Todo *, int ) ) );
408 408
409 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 409 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
410 this, SLOT ( cloneIncidence( Incidence * ) ) ); 410 this, SLOT ( cloneIncidence( Incidence * ) ) );
411 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 411 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
412 this, SLOT (cancelIncidence( Incidence * ) ) ); 412 this, SLOT (cancelIncidence( Incidence * ) ) );
413 413
414 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 414 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
415 this, SLOT ( moveIncidence( Incidence * ) ) ); 415 this, SLOT ( moveIncidence( Incidence * ) ) );
416 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 416 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
417 this, SLOT ( beamIncidence( Incidence * ) ) ); 417 this, SLOT ( beamIncidence( Incidence * ) ) );
418 418
419 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 419 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
420 this, SLOT ( todo_unsub( Todo * ) ) ); 420 this, SLOT ( todo_unsub( Todo * ) ) );
421 421
422 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 422 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
423 this, SLOT ( todo_resub( Todo *,Todo * ) ) ); 423 this, SLOT ( todo_resub( Todo *,Todo * ) ) );
424 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 424 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
425 SLOT( updateTodo( Todo *, int ) ) ); 425 SLOT( updateTodo( Todo *, int ) ) );
426 connect( this, SIGNAL( todoModified( Todo *, int )), this, 426 connect( this, SIGNAL( todoModified( Todo *, int )), this,
427 SLOT( changeTodoDisplay( Todo *, int ) ) ); 427 SLOT( changeTodoDisplay( Todo *, int ) ) );
428 428
429 429
430 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 430 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
431 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 431 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
432 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 432 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
433 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 433 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
434 434
435 435
436 436
437 437
438 438
439 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 439 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
440 SLOT(checkClipboard())); 440 SLOT(checkClipboard()));
441 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 441 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
442 SLOT( processTodoListSelection( Incidence * ) ) ); 442 SLOT( processTodoListSelection( Incidence * ) ) );
443 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 443 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
444 444
445 // kdDebug() << "CalendarView::CalendarView() done" << endl; 445 // kdDebug() << "CalendarView::CalendarView() done" << endl;
446 446
447 mDateFrame = new QVBox(0,0,WType_Popup); 447 mDateFrame = new QVBox(0,0,WType_Popup);
448 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 448 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
449 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 449 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
450 mDateFrame->setLineWidth(3); 450 mDateFrame->setLineWidth(3);
451 mDateFrame->hide(); 451 mDateFrame->hide();
452 mDateFrame->setCaption( i18n( "Pick a date to display")); 452 mDateFrame->setCaption( i18n( "Pick a date to display"));
453 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 453 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
454 454
455 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 455 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
456 456
457 mEventEditor = mDialogManager->getEventEditor(); 457 mEventEditor = mDialogManager->getEventEditor();
458 mTodoEditor = mDialogManager->getTodoEditor(); 458 mTodoEditor = mDialogManager->getTodoEditor();
459 459
460 mFlagEditDescription = false; 460 mFlagEditDescription = false;
461 461
462 mSuspendTimer = new QTimer( this ); 462 mSuspendTimer = new QTimer( this );
463 mAlarmTimer = new QTimer( this ); 463 mAlarmTimer = new QTimer( this );
464 mRecheckAlarmTimer = new QTimer( this ); 464 mRecheckAlarmTimer = new QTimer( this );
465 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 465 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
466 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 466 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
467 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 467 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
468 mAlarmDialog = new AlarmDialog( this ); 468 mAlarmDialog = new AlarmDialog( this );
469 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 469 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
470 mAlarmDialog->setServerNotification( false ); 470 mAlarmDialog->setServerNotification( false );
471 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 471 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
472 472
473 473
474#ifndef DESKTOP_VERSION 474#ifndef DESKTOP_VERSION
475//US listen for arriving address resultsets 475//US listen for arriving address resultsets
476 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), 476 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)),
477 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 477 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
478#endif 478#endif
479 479
480} 480}
481 481
482 482
483CalendarView::~CalendarView() 483CalendarView::~CalendarView()
484{ 484{
485 // kdDebug() << "~CalendarView()" << endl; 485 // kdDebug() << "~CalendarView()" << endl;
486 //qDebug("CalendarView::~CalendarView() "); 486 //qDebug("CalendarView::~CalendarView() ");
487 delete mDialogManager; 487 delete mDialogManager;
488 delete mViewManager; 488 delete mViewManager;
489 delete mStorage; 489 delete mStorage;
490 delete mDateFrame ; 490 delete mDateFrame ;
491 delete beamDialog; 491 delete beamDialog;
492 //kdDebug() << "~CalendarView() done" << endl; 492 //kdDebug() << "~CalendarView() done" << endl;
493} 493}
494void CalendarView::timerAlarm() 494void CalendarView::timerAlarm()
495{ 495{
496 //qDebug("CalendarView::timerAlarm() "); 496 //qDebug("CalendarView::timerAlarm() ");
497 computeAlarm(mAlarmNotification ); 497 computeAlarm(mAlarmNotification );
498} 498}
499 499
500void CalendarView::suspendAlarm() 500void CalendarView::suspendAlarm()
501{ 501{
502 //qDebug(" CalendarView::suspendAlarm() "); 502 //qDebug(" CalendarView::suspendAlarm() ");
503 computeAlarm(mSuspendAlarmNotification ); 503 computeAlarm(mSuspendAlarmNotification );
504 504
505} 505}
506 506
507void CalendarView::startAlarm( QString mess , QString filename) 507void CalendarView::startAlarm( QString mess , QString filename)
508{ 508{
509 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 509 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
510 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); 510 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
511 511
512} 512}
513 513
514void CalendarView::checkNextTimerAlarm() 514void CalendarView::checkNextTimerAlarm()
515{ 515{
516 mCalendar->checkAlarmForIncidence( 0, true ); 516 mCalendar->checkAlarmForIncidence( 0, true );
517} 517}
518 518
519void CalendarView::computeAlarm( QString msg ) 519void CalendarView::computeAlarm( QString msg )
520{ 520{
521 521
522 QString mess = msg; 522 QString mess = msg;
523 QString mAlarmMessage = mess.mid( 9 ); 523 QString mAlarmMessage = mess.mid( 9 );
524 QString filename = MainWindow::resourcePath(); 524 QString filename = MainWindow::resourcePath();
525 filename += "koalarm.wav"; 525 filename += "koalarm.wav";
526 QString tempfilename; 526 QString tempfilename;
527 if ( mess.left( 13 ) == "suspend_alarm") { 527 if ( mess.left( 13 ) == "suspend_alarm") {
528 bool error = false; 528 bool error = false;
529 int len = mess.mid( 13 ).find("+++"); 529 int len = mess.mid( 13 ).find("+++");
530 if ( len < 2 ) 530 if ( len < 2 )
531 error = true; 531 error = true;
532 else { 532 else {
533 tempfilename = mess.mid( 13, len ); 533 tempfilename = mess.mid( 13, len );
534 if ( !QFile::exists( tempfilename ) ) 534 if ( !QFile::exists( tempfilename ) )
535 error = true; 535 error = true;
536 } 536 }
537 if ( ! error ) { 537 if ( ! error ) {
538 filename = tempfilename; 538 filename = tempfilename;
539 } 539 }
540 mAlarmMessage = mess.mid( 13+len+3 ); 540 mAlarmMessage = mess.mid( 13+len+3 );
541 //qDebug("suspend file %s ",tempfilename.latin1() ); 541 //qDebug("suspend file %s ",tempfilename.latin1() );
542 startAlarm( mAlarmMessage, filename); 542 startAlarm( mAlarmMessage, filename);
543 return; 543 return;
544 } 544 }
545 if ( mess.left( 11 ) == "timer_alarm") { 545 if ( mess.left( 11 ) == "timer_alarm") {
546 //mTimerTime = 0; 546 //mTimerTime = 0;
547 startAlarm( mess.mid( 11 ), filename ); 547 startAlarm( mess.mid( 11 ), filename );
548 return; 548 return;
549 } 549 }
550 if ( mess.left( 10 ) == "proc_alarm") { 550 if ( mess.left( 10 ) == "proc_alarm") {
551 bool error = false; 551 bool error = false;
552 int len = mess.mid( 10 ).find("+++"); 552 int len = mess.mid( 10 ).find("+++");
553 if ( len < 2 ) 553 if ( len < 2 )
554 error = true; 554 error = true;
555 else { 555 else {
556 tempfilename = mess.mid( 10, len ); 556 tempfilename = mess.mid( 10, len );
557 if ( !QFile::exists( tempfilename ) ) 557 if ( !QFile::exists( tempfilename ) )
558 error = true; 558 error = true;
559 } 559 }
560 if ( error ) { 560 if ( error ) {
561 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 561 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
562 mAlarmMessage += mess.mid( 10+len+3+9 ); 562 mAlarmMessage += mess.mid( 10+len+3+9 );
563 } else { 563 } else {
564 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 564 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
565 //qDebug("-----system command %s ",tempfilename.latin1() ); 565 //qDebug("-----system command %s ",tempfilename.latin1() );
566#ifndef _WIN32_ 566#ifndef _WIN32_
567 if ( vfork () == 0 ) { 567 if ( vfork () == 0 ) {
568 execl ( tempfilename.latin1(), 0 ); 568 execl ( tempfilename.latin1(), 0 );
569 return; 569 return;
570 } 570 }
571#else 571#else
572 QProcess* p = new QProcess(); 572 QProcess* p = new QProcess();
573 p->addArgument( tempfilename.latin1() ); 573 p->addArgument( tempfilename.latin1() );
574 p->start(); 574 p->start();
575 return; 575 return;
576#endif 576#endif
577 577
578 return; 578 return;
579 } 579 }
580 580
581 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 581 //qDebug("+++++++system command %s ",tempfilename.latin1() );
582 } 582 }
583 if ( mess.left( 11 ) == "audio_alarm") { 583 if ( mess.left( 11 ) == "audio_alarm") {
584 bool error = false; 584 bool error = false;
585 int len = mess.mid( 11 ).find("+++"); 585 int len = mess.mid( 11 ).find("+++");
586 if ( len < 2 ) 586 if ( len < 2 )
587 error = true; 587 error = true;
588 else { 588 else {
589 tempfilename = mess.mid( 11, len ); 589 tempfilename = mess.mid( 11, len );
590 if ( !QFile::exists( tempfilename ) ) 590 if ( !QFile::exists( tempfilename ) )
591 error = true; 591 error = true;
592 } 592 }
593 if ( ! error ) { 593 if ( ! error ) {
594 filename = tempfilename; 594 filename = tempfilename;
595 } 595 }
596 mAlarmMessage = mess.mid( 11+len+3+9 ); 596 mAlarmMessage = mess.mid( 11+len+3+9 );
597 //qDebug("audio file command %s ",tempfilename.latin1() ); 597 //qDebug("audio file command %s ",tempfilename.latin1() );
598 } 598 }
599 if ( mess.left( 9 ) == "cal_alarm") { 599 if ( mess.left( 9 ) == "cal_alarm") {
600 mAlarmMessage = mess.mid( 9 ) ; 600 mAlarmMessage = mess.mid( 9 ) ;
601 } 601 }
602 602
603 startAlarm( mAlarmMessage, filename ); 603 startAlarm( mAlarmMessage, filename );
604 604
605 605
606} 606}
607 607
608void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 608void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
609{ 609{
610 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 610 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
611 611
612 mSuspendAlarmNotification = noti; 612 mSuspendAlarmNotification = noti;
613 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 613 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
614 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 614 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
615 mSuspendTimer->start( ms , true ); 615 mSuspendTimer->start( ms , true );
616 616
617} 617}
618 618
619void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 619void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
620{ 620{
621 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 621 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
622 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 622 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
623#ifndef DESKTOP_VERSION 623#ifndef DESKTOP_VERSION
624 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); 624 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() );
625#endif 625#endif
626 return; 626 return;
627 } 627 }
628 int maxSec; 628 int maxSec;
629 //maxSec = 5; //testing only 629 //maxSec = 5; //testing only
630 maxSec = 86400+3600; // one day+1hour 630 maxSec = 86400+3600; // one day+1hour
631 mAlarmNotification = noti; 631 mAlarmNotification = noti;
632 int sec = QDateTime::currentDateTime().secsTo( qdt ); 632 int sec = QDateTime::currentDateTime().secsTo( qdt );
633 if ( sec > maxSec ) { 633 if ( sec > maxSec ) {
634 mRecheckAlarmTimer->start( maxSec * 1000 ); 634 mRecheckAlarmTimer->start( maxSec * 1000 );
635 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 635 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
636 return; 636 return;
637 } else { 637 } else {
638 mRecheckAlarmTimer->stop(); 638 mRecheckAlarmTimer->stop();
639 } 639 }
640 //qDebug("Alarm timer started with secs: %d ", sec); 640 //qDebug("Alarm timer started with secs: %d ", sec);
641 mAlarmTimer->start( sec *1000 , true ); 641 mAlarmTimer->start( sec *1000 , true );
642 642
643} 643}
644// called by mRecheckAlarmTimer to get next alarm 644// called by mRecheckAlarmTimer to get next alarm
645// we need this, because a QTimer has only a max range of 25 days 645// we need this, because a QTimer has only a max range of 25 days
646void CalendarView::recheckTimerAlarm() 646void CalendarView::recheckTimerAlarm()
647{ 647{
648 mAlarmTimer->stop(); 648 mAlarmTimer->stop();
649 mRecheckAlarmTimer->stop(); 649 mRecheckAlarmTimer->stop();
650 mCalendar->checkAlarmForIncidence( 0, true ); 650 mCalendar->checkAlarmForIncidence( 0, true );
651} 651}
652void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 652void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
653{ 653{
654 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 654 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
655 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 655 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
656#ifndef DESKTOP_VERSION 656#ifndef DESKTOP_VERSION
657 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 657 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
658#endif 658#endif
659 return; 659 return;
660 } 660 }
661 mAlarmTimer->stop(); 661 mAlarmTimer->stop();
662} 662}
663void CalendarView::selectWeekNum ( int num ) 663void CalendarView::selectWeekNum ( int num )
664{ 664{
665 dateNavigator()->selectWeek( num ); 665 dateNavigator()->selectWeek( num );
666 mViewManager->showWeekView(); 666 mViewManager->showWeekView();
667} 667}
668KOViewManager *CalendarView::viewManager() 668KOViewManager *CalendarView::viewManager()
669{ 669{
670 return mViewManager; 670 return mViewManager;
671} 671}
672 672
673KODialogManager *CalendarView::dialogManager() 673KODialogManager *CalendarView::dialogManager()
674{ 674{
675 return mDialogManager; 675 return mDialogManager;
676} 676}
677 677
678QDate CalendarView::startDate() 678QDate CalendarView::startDate()
679{ 679{
680 DateList dates = mNavigator->selectedDates(); 680 DateList dates = mNavigator->selectedDates();
681 681
682 return dates.first(); 682 return dates.first();
683} 683}
684 684
685QDate CalendarView::endDate() 685QDate CalendarView::endDate()
686{ 686{
687 DateList dates = mNavigator->selectedDates(); 687 DateList dates = mNavigator->selectedDates();
688 688
689 return dates.last(); 689 return dates.last();
690} 690}
691 691
692 692
693void CalendarView::createPrinter() 693void CalendarView::createPrinter()
694{ 694{
695#ifndef KORG_NOPRINTER 695#ifndef KORG_NOPRINTER
696 if (!mCalPrinter) { 696 if (!mCalPrinter) {
697 mCalPrinter = new CalPrinter(this, mCalendar); 697 mCalPrinter = new CalPrinter(this, mCalendar);
698 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 698 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
699 } 699 }
700#endif 700#endif
701} 701}
702 702
703 703
704//KOPrefs::instance()->mWriteBackFile 704//KOPrefs::instance()->mWriteBackFile
705//KOPrefs::instance()->mWriteBackExistingOnly 705//KOPrefs::instance()->mWriteBackExistingOnly
706 706
707// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 707// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
708// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 708// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
709// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 709// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
710// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 710// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
711// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 711// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
712// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 712// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
713 713
714int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 714int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
715{ 715{
716 716
717 // 0 equal 717 // 0 equal
718 // 1 take local 718 // 1 take local
719 // 2 take remote 719 // 2 take remote
720 // 3 cancel 720 // 3 cancel
721 QDateTime lastSync = mLastCalendarSync; 721 QDateTime lastSync = mLastCalendarSync;
722 QDateTime localMod = local->lastModified(); 722 QDateTime localMod = local->lastModified();
723 QDateTime remoteMod = remote->lastModified(); 723 QDateTime remoteMod = remote->lastModified();
724 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 724 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
725 bool remCh, locCh; 725 bool remCh, locCh;
726 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 726 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
727 //if ( remCh ) 727 //if ( remCh )
728 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 728 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
729 locCh = ( localMod > mLastCalendarSync ); 729 locCh = ( localMod > mLastCalendarSync );
730 if ( !remCh && ! locCh ) { 730 if ( !remCh && ! locCh ) {
731 //qDebug("both not changed "); 731 //qDebug("both not changed ");
732 lastSync = localMod.addDays(1); 732 lastSync = localMod.addDays(1);
733 if ( mode <= SYNC_PREF_ASK ) 733 if ( mode <= SYNC_PREF_ASK )
734 return 0; 734 return 0;
735 } else { 735 } else {
736 if ( locCh ) { 736 if ( locCh ) {
737 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); 737 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1());
738 lastSync = localMod.addDays( -1 ); 738 lastSync = localMod.addDays( -1 );
739 if ( !remCh ) 739 if ( !remCh )
740 remoteMod = ( lastSync.addDays( -1 ) ); 740 remoteMod = ( lastSync.addDays( -1 ) );
741 } else { 741 } else {
742 //qDebug(" not loc changed "); 742 //qDebug(" not loc changed ");
743 lastSync = localMod.addDays( 1 ); 743 lastSync = localMod.addDays( 1 );
744 if ( remCh ) 744 if ( remCh )
745 remoteMod =( lastSync.addDays( 1 ) ); 745 remoteMod =( lastSync.addDays( 1 ) );
746 746
747 } 747 }
748 } 748 }
749 full = true; 749 full = true;
750 if ( mode < SYNC_PREF_ASK ) 750 if ( mode < SYNC_PREF_ASK )
751 mode = SYNC_PREF_ASK; 751 mode = SYNC_PREF_ASK;
752 } else { 752 } else {
753 if ( localMod == remoteMod ) 753 if ( localMod == remoteMod )
754 // if ( local->revision() == remote->revision() ) 754 // if ( local->revision() == remote->revision() )
755 return 0; 755 return 0;
756 756
757 } 757 }
758 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 758 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
759 759
760 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); 760 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision());
761 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); 761 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() );
762 //full = true; //debug only 762 //full = true; //debug only
763 if ( full ) { 763 if ( full ) {
764 bool equ = false; 764 bool equ = false;
765 if ( local->type() == "Event" ) { 765 if ( local->type() == "Event" ) {
766 equ = (*((Event*) local) == *((Event*) remote)); 766 equ = (*((Event*) local) == *((Event*) remote));
767 } 767 }
768 else if ( local->type() =="Todo" ) 768 else if ( local->type() =="Todo" )
769 equ = (*((Todo*) local) == (*(Todo*) remote)); 769 equ = (*((Todo*) local) == (*(Todo*) remote));
770 else if ( local->type() =="Journal" ) 770 else if ( local->type() =="Journal" )
771 equ = (*((Journal*) local) == *((Journal*) remote)); 771 equ = (*((Journal*) local) == *((Journal*) remote));
772 if ( equ ) { 772 if ( equ ) {
773 //qDebug("equal "); 773 //qDebug("equal ");
774 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 774 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
775 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 775 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
776 } 776 }
777 if ( mode < SYNC_PREF_FORCE_LOCAL ) 777 if ( mode < SYNC_PREF_FORCE_LOCAL )
778 return 0; 778 return 0;
779 779
780 }//else //debug only 780 }//else //debug only
781 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 781 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
782 } 782 }
783 int result; 783 int result;
784 bool localIsNew; 784 bool localIsNew;
785 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); 785 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() );
786 786
787 if ( full && mode < SYNC_PREF_NEWEST ) 787 if ( full && mode < SYNC_PREF_NEWEST )
788 mode = SYNC_PREF_ASK; 788 mode = SYNC_PREF_ASK;
789 789
790 switch( mode ) { 790 switch( mode ) {
791 case SYNC_PREF_LOCAL: 791 case SYNC_PREF_LOCAL:
792 if ( lastSync > remoteMod ) 792 if ( lastSync > remoteMod )
793 return 1; 793 return 1;
794 if ( lastSync > localMod ) 794 if ( lastSync > localMod )
795 return 2; 795 return 2;
796 return 1; 796 return 1;
797 break; 797 break;
798 case SYNC_PREF_REMOTE: 798 case SYNC_PREF_REMOTE:
799 if ( lastSync > remoteMod ) 799 if ( lastSync > remoteMod )
800 return 1; 800 return 1;
801 if ( lastSync > localMod ) 801 if ( lastSync > localMod )
802 return 2; 802 return 2;
803 return 2; 803 return 2;
804 break; 804 break;
805 case SYNC_PREF_NEWEST: 805 case SYNC_PREF_NEWEST:
806 if ( localMod > remoteMod ) 806 if ( localMod > remoteMod )
807 return 1; 807 return 1;
808 else 808 else
809 return 2; 809 return 2;
810 break; 810 break;
811 case SYNC_PREF_ASK: 811 case SYNC_PREF_ASK:
812 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 812 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
813 if ( lastSync > remoteMod ) 813 if ( lastSync > remoteMod )
814 return 1; 814 return 1;
815 if ( lastSync > localMod ) 815 if ( lastSync > localMod )
816 return 2; 816 return 2;
817 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 817 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
818 localIsNew = localMod >= remoteMod; 818 localIsNew = localMod >= remoteMod;
819 if ( localIsNew ) 819 if ( localIsNew )
820 getEventViewerDialog()->setColorMode( 1 ); 820 getEventViewerDialog()->setColorMode( 1 );
821 else 821 else
822 getEventViewerDialog()->setColorMode( 2 ); 822 getEventViewerDialog()->setColorMode( 2 );
823 getEventViewerDialog()->setIncidence(local); 823 getEventViewerDialog()->setIncidence(local);
824 if ( localIsNew ) 824 if ( localIsNew )
825 getEventViewerDialog()->setColorMode( 2 ); 825 getEventViewerDialog()->setColorMode( 2 );
826 else 826 else
827 getEventViewerDialog()->setColorMode( 1 ); 827 getEventViewerDialog()->setColorMode( 1 );
828 getEventViewerDialog()->addIncidence(remote); 828 getEventViewerDialog()->addIncidence(remote);
829 getEventViewerDialog()->setColorMode( 0 ); 829 getEventViewerDialog()->setColorMode( 0 );
830 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 830 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
831 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 831 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
832 getEventViewerDialog()->showMe(); 832 getEventViewerDialog()->showMe();
833 result = getEventViewerDialog()->executeS( localIsNew ); 833 result = getEventViewerDialog()->executeS( localIsNew );
834 return result; 834 return result;
835 835
836 break; 836 break;
837 case SYNC_PREF_FORCE_LOCAL: 837 case SYNC_PREF_FORCE_LOCAL:
838 return 1; 838 return 1;
839 break; 839 break;
840 case SYNC_PREF_FORCE_REMOTE: 840 case SYNC_PREF_FORCE_REMOTE:
841 return 2; 841 return 2;
842 break; 842 break;
843 843
844 default: 844 default:
845 // SYNC_PREF_TAKE_BOTH not implemented 845 // SYNC_PREF_TAKE_BOTH not implemented
846 break; 846 break;
847 } 847 }
848 return 0; 848 return 0;
849} 849}
850Event* CalendarView::getLastSyncEvent() 850Event* CalendarView::getLastSyncEvent()
851{ 851{
852 Event* lse; 852 Event* lse;
853 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 853 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
854 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 854 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
855 if (!lse) { 855 if (!lse) {
856 lse = new Event(); 856 lse = new Event();
857 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 857 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
858 QString sum = ""; 858 QString sum = "";
859 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 859 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
860 sum = "E: "; 860 sum = "E: ";
861 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 861 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
862 lse->setDtStart( mLastCalendarSync ); 862 lse->setDtStart( mLastCalendarSync );
863 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 863 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
864 lse->setCategories( i18n("SyncEvent") ); 864 lse->setCategories( i18n("SyncEvent") );
865 lse->setReadOnly( true ); 865 lse->setReadOnly( true );
866 mCalendar->addEvent( lse ); 866 mCalendar->addEvent( lse );
867 } 867 }
868 868
869 return lse; 869 return lse;
870 870
871} 871}
872 872
873// we check, if the to delete event has a id for a profile 873// we check, if the to delete event has a id for a profile
874// if yes, we set this id in the profile to delete 874// if yes, we set this id in the profile to delete
875void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 875void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
876{ 876{
877 if ( lastSync.count() == 0 ) { 877 if ( lastSync.count() == 0 ) {
878 //qDebug(" lastSync.count() == 0"); 878 //qDebug(" lastSync.count() == 0");
879 return; 879 return;
880 } 880 }
881 if ( toDelete->type() == "Journal" ) 881 if ( toDelete->type() == "Journal" )
882 return; 882 return;
883 883
884 Event* eve = lastSync.first(); 884 Event* eve = lastSync.first();
885 885
886 while ( eve ) { 886 while ( eve ) {
887 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 887 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
888 if ( !id.isEmpty() ) { 888 if ( !id.isEmpty() ) {
889 QString des = eve->description(); 889 QString des = eve->description();
890 QString pref = "e"; 890 QString pref = "e";
891 if ( toDelete->type() == "Todo" ) 891 if ( toDelete->type() == "Todo" )
892 pref = "t"; 892 pref = "t";
893 des += pref+ id + ","; 893 des += pref+ id + ",";
894 eve->setReadOnly( false ); 894 eve->setReadOnly( false );
895 eve->setDescription( des ); 895 eve->setDescription( des );
896 //qDebug("setdes %s ", des.latin1()); 896 //qDebug("setdes %s ", des.latin1());
897 eve->setReadOnly( true ); 897 eve->setReadOnly( true );
898 } 898 }
899 eve = lastSync.next(); 899 eve = lastSync.next();
900 } 900 }
901 901
902} 902}
903void CalendarView::checkExternalId( Incidence * inc ) 903void CalendarView::checkExternalId( Incidence * inc )
904{ 904{
905 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 905 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
906 checkExternSyncEvent( lastSync, inc ); 906 checkExternSyncEvent( lastSync, inc );
907 907
908} 908}
909bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 909bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
910{ 910{
911 bool syncOK = true; 911 bool syncOK = true;
912 int addedEvent = 0; 912 int addedEvent = 0;
913 int addedEventR = 0; 913 int addedEventR = 0;
914 int deletedEventR = 0; 914 int deletedEventR = 0;
915 int deletedEventL = 0; 915 int deletedEventL = 0;
916 int changedLocal = 0; 916 int changedLocal = 0;
917 int changedRemote = 0; 917 int changedRemote = 0;
918 //QPtrList<Event> el = local->rawEvents(); 918 //QPtrList<Event> el = local->rawEvents();
919 Event* eventR; 919 Event* eventR;
920 QString uid; 920 QString uid;
921 int take; 921 int take;
922 Event* eventL; 922 Event* eventL;
923 Event* eventRSync; 923 Event* eventRSync;
924 Event* eventLSync; 924 Event* eventLSync;
925 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 925 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
926 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 926 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
927 bool fullDateRange = false; 927 bool fullDateRange = false;
928 local->resetTempSyncStat(); 928 local->resetTempSyncStat();
929 if ( mSyncKDE ) 929 if ( mSyncKDE )
930 remote->resetPilotStat(1); 930 remote->resetPilotStat(1);
931 mLastCalendarSync = QDateTime::currentDateTime(); 931 mLastCalendarSync = QDateTime::currentDateTime();
932 QDateTime modifiedCalendar = mLastCalendarSync;; 932 QDateTime modifiedCalendar = mLastCalendarSync;;
933 eventLSync = getLastSyncEvent(); 933 eventLSync = getLastSyncEvent();
934 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 934 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
935 if ( eventR ) { 935 if ( eventR ) {
936 eventRSync = (Event*) eventR->clone(); 936 eventRSync = (Event*) eventR->clone();
937 remote->deleteEvent(eventR ); 937 remote->deleteEvent(eventR );
938 938
939 } else { 939 } else {
940 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncKDE) { 940 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncKDE) {
941 eventRSync = (Event*)eventLSync->clone(); 941 eventRSync = (Event*)eventLSync->clone();
942 } else { 942 } else {
943 fullDateRange = true; 943 fullDateRange = true;
944 eventRSync = new Event(); 944 eventRSync = new Event();
945 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 945 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
946 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 946 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
947 eventRSync->setDtStart( mLastCalendarSync ); 947 eventRSync->setDtStart( mLastCalendarSync );
948 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 948 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
949 eventRSync->setCategories( i18n("SyncEvent") ); 949 eventRSync->setCategories( i18n("SyncEvent") );
950 } 950 }
951 } 951 }
952 if ( eventLSync->dtStart() == mLastCalendarSync ) 952 if ( eventLSync->dtStart() == mLastCalendarSync )
953 fullDateRange = true; 953 fullDateRange = true;
954 954
955 if ( ! fullDateRange ) { 955 if ( ! fullDateRange ) {
956 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 956 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
957 957
958 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 958 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
959 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 959 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
960 fullDateRange = true; 960 fullDateRange = true;
961 } 961 }
962 } 962 }
963 if ( fullDateRange && !mSyncKDE ) 963 if ( fullDateRange && !mSyncKDE )
964 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 964 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
965 else 965 else
966 mLastCalendarSync = eventLSync->dtStart(); 966 mLastCalendarSync = eventLSync->dtStart();
967 // for resyncing if own file has changed 967 // for resyncing if own file has changed
968 if ( mCurrentSyncDevice == "deleteaftersync" ) { 968 if ( mCurrentSyncDevice == "deleteaftersync" ) {
969 mLastCalendarSync = loadedFileVersion; 969 mLastCalendarSync = loadedFileVersion;
970 //qDebug("setting mLastCalendarSync "); 970 //qDebug("setting mLastCalendarSync ");
971 } 971 }
972 //qDebug("*************************** "); 972 //qDebug("*************************** ");
973 qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); 973 qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange);
974 QPtrList<Incidence> er = remote->rawIncidences(); 974 QPtrList<Incidence> er = remote->rawIncidences();
975 Incidence* inR = er.first(); 975 Incidence* inR = er.first();
976 Incidence* inL; 976 Incidence* inL;
977 QProgressBar bar( er.count(),0 ); 977 QProgressBar bar( er.count(),0 );
978 bar.setCaption (i18n("Syncing - close to abort!") ); 978 bar.setCaption (i18n("Syncing - close to abort!") );
979 979
980 int w = 300; 980 int w = 300;
981 if ( QApplication::desktop()->width() < 320 ) 981 if ( QApplication::desktop()->width() < 320 )
982 w = 220; 982 w = 220;
983 int h = bar.sizeHint().height() ; 983 int h = bar.sizeHint().height() ;
984 int dw = QApplication::desktop()->width(); 984 int dw = QApplication::desktop()->width();
985 int dh = QApplication::desktop()->height(); 985 int dh = QApplication::desktop()->height();
986 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 986 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
987 bar.show(); 987 bar.show();
988 int modulo = (er.count()/10)+1; 988 int modulo = (er.count()/10)+1;
989 int incCounter = 0; 989 int incCounter = 0;
990 while ( inR ) { 990 while ( inR ) {
991 if ( ! bar.isVisible() ) 991 if ( ! bar.isVisible() )
992 return false; 992 return false;
993 if ( incCounter % modulo == 0 ) 993 if ( incCounter % modulo == 0 )
994 bar.setProgress( incCounter ); 994 bar.setProgress( incCounter );
995 ++incCounter; 995 ++incCounter;
996 uid = inR->uid(); 996 uid = inR->uid();
997 bool skipIncidence = false; 997 bool skipIncidence = false;
998 if ( uid.left(15) == QString("last-syncEvent-") ) 998 if ( uid.left(15) == QString("last-syncEvent-") )
999 skipIncidence = true; 999 skipIncidence = true;
1000 QString idS; 1000 QString idS;
1001 qApp->processEvents(); 1001 qApp->processEvents();
1002 if ( !skipIncidence ) { 1002 if ( !skipIncidence ) {
1003 inL = local->incidence( uid ); 1003 inL = local->incidence( uid );
1004 if ( inL ) { // maybe conflict - same uid in both calendars 1004 if ( inL ) { // maybe conflict - same uid in both calendars
1005 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1005 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1006 //qDebug("take %d %s ", take, inL->summary().latin1()); 1006 //qDebug("take %d %s ", take, inL->summary().latin1());
1007 if ( take == 3 ) 1007 if ( take == 3 )
1008 return false; 1008 return false;
1009 if ( take == 1 ) {// take local 1009 if ( take == 1 ) {// take local
1010 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1010 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1011 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1011 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1012 else 1012 else
1013 idS = inR->IDStr(); 1013 idS = inR->IDStr();
1014 remote->deleteIncidence( inR ); 1014 remote->deleteIncidence( inR );
1015 inR = inL->clone(); 1015 inR = inL->clone();
1016 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1016 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1017 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1017 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1018 inR->setIDStr( idS ); 1018 inR->setIDStr( idS );
1019 remote->addIncidence( inR ); 1019 remote->addIncidence( inR );
1020 if ( mSyncKDE ) 1020 if ( mSyncKDE )
1021 inR->setPilotId( 2 ); 1021 inR->setPilotId( 2 );
1022 ++changedRemote; 1022 ++changedRemote;
1023 } else { 1023 } else {
1024 idS = inL->IDStr(); 1024 idS = inL->IDStr();
1025 int pid = inL->pilotId(); 1025 int pid = inL->pilotId();
1026 local->deleteIncidence( inL ); 1026 local->deleteIncidence( inL );
1027 inL = inR->clone(); 1027 inL = inR->clone();
1028 if ( mSyncKDE ) 1028 if ( mSyncKDE )
1029 inL->setPilotId( pid ); 1029 inL->setPilotId( pid );
1030 inL->setIDStr( idS ); 1030 inL->setIDStr( idS );
1031 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1031 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1032 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1032 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1033 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1033 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1034 } 1034 }
1035 local->addIncidence( inL ); 1035 local->addIncidence( inL );
1036 ++changedLocal; 1036 ++changedLocal;
1037 } 1037 }
1038 } 1038 }
1039 } else { // no conflict 1039 } else { // no conflict
1040 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1040 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1041 QString des = eventLSync->description(); 1041 QString des = eventLSync->description();
1042 QString pref = "e"; 1042 QString pref = "e";
1043 if ( inR->type() == "Todo" ) 1043 if ( inR->type() == "Todo" )
1044 pref = "t"; 1044 pref = "t";
1045 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1045 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1046 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1046 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1047 //remote->deleteIncidence( inR ); 1047 //remote->deleteIncidence( inR );
1048 ++deletedEventR; 1048 ++deletedEventR;
1049 } else { 1049 } else {
1050 inR->setLastModified( modifiedCalendar ); 1050 inR->setLastModified( modifiedCalendar );
1051 inL = inR->clone(); 1051 inL = inR->clone();
1052 local->addIncidence( inL ); 1052 local->addIncidence( inL );
1053 ++addedEvent; 1053 ++addedEvent;
1054 } 1054 }
1055 } else { 1055 } else {
1056 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1056 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1057 inR->setLastModified( modifiedCalendar ); 1057 inR->setLastModified( modifiedCalendar );
1058 local->addIncidence( inR->clone() ); 1058 local->addIncidence( inR->clone() );
1059 ++addedEvent; 1059 ++addedEvent;
1060 } else { 1060 } else {
1061 checkExternSyncEvent(eventRSyncSharp, inR); 1061 checkExternSyncEvent(eventRSyncSharp, inR);
1062 remote->deleteIncidence( inR ); 1062 remote->deleteIncidence( inR );
1063 ++deletedEventR; 1063 ++deletedEventR;
1064 } 1064 }
1065 } 1065 }
1066 } 1066 }
1067 } 1067 }
1068 inR = er.next(); 1068 inR = er.next();
1069 } 1069 }
1070 QPtrList<Incidence> el = local->rawIncidences(); 1070 QPtrList<Incidence> el = local->rawIncidences();
1071 inL = el.first(); 1071 inL = el.first();
1072 modulo = (el.count()/10)+1; 1072 modulo = (el.count()/10)+1;
1073 bar.setCaption (i18n("Add / remove events") ); 1073 bar.setCaption (i18n("Add / remove events") );
1074 bar.setTotalSteps ( el.count() ) ; 1074 bar.setTotalSteps ( el.count() ) ;
1075 bar.show(); 1075 bar.show();
1076 incCounter = 0; 1076 incCounter = 0;
1077 1077
1078 while ( inL ) { 1078 while ( inL ) {
1079 1079
1080 qApp->processEvents(); 1080 qApp->processEvents();
1081 if ( ! bar.isVisible() ) 1081 if ( ! bar.isVisible() )
1082 return false; 1082 return false;
1083 if ( incCounter % modulo == 0 ) 1083 if ( incCounter % modulo == 0 )
1084 bar.setProgress( incCounter ); 1084 bar.setProgress( incCounter );
1085 ++incCounter; 1085 ++incCounter;
1086 uid = inL->uid(); 1086 uid = inL->uid();
1087 bool skipIncidence = false; 1087 bool skipIncidence = false;
1088 if ( uid.left(15) == QString("last-syncEvent-") ) 1088 if ( uid.left(15) == QString("last-syncEvent-") )
1089 skipIncidence = true; 1089 skipIncidence = true;
1090 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) 1090 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
1091 skipIncidence = true; 1091 skipIncidence = true;
1092 if ( !skipIncidence ) { 1092 if ( !skipIncidence ) {
1093 inR = remote->incidence( uid ); 1093 inR = remote->incidence( uid );
1094 if ( ! inR ) { 1094 if ( ! inR ) {
1095 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1095 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1096 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1096 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1097 checkExternSyncEvent(eventLSyncSharp, inL); 1097 checkExternSyncEvent(eventLSyncSharp, inL);
1098 local->deleteIncidence( inL ); 1098 local->deleteIncidence( inL );
1099 ++deletedEventL; 1099 ++deletedEventL;
1100 } else { 1100 } else {
1101 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1101 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1102 inL->removeID(mCurrentSyncDevice ); 1102 inL->removeID(mCurrentSyncDevice );
1103 ++addedEventR; 1103 ++addedEventR;
1104 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1104 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1105 inL->setLastModified( modifiedCalendar ); 1105 inL->setLastModified( modifiedCalendar );
1106 inR = inL->clone(); 1106 inR = inL->clone();
1107 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1107 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1108 remote->addIncidence( inR ); 1108 remote->addIncidence( inR );
1109 } 1109 }
1110 } 1110 }
1111 } else { 1111 } else {
1112 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1112 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1113 checkExternSyncEvent(eventLSyncSharp, inL); 1113 checkExternSyncEvent(eventLSyncSharp, inL);
1114 local->deleteIncidence( inL ); 1114 local->deleteIncidence( inL );
1115 ++deletedEventL; 1115 ++deletedEventL;
1116 } else { 1116 } else {
1117 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1117 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1118 ++addedEventR; 1118 ++addedEventR;
1119 inL->setLastModified( modifiedCalendar ); 1119 inL->setLastModified( modifiedCalendar );
1120 remote->addIncidence( inL->clone() ); 1120 remote->addIncidence( inL->clone() );
1121 } 1121 }
1122 } 1122 }
1123 } 1123 }
1124 } 1124 }
1125 } 1125 }
1126 inL = el.next(); 1126 inL = el.next();
1127 } 1127 }
1128 int delFut = 0; 1128 int delFut = 0;
1129 int remRem = 0; 1129 int remRem = 0;
1130 if ( mSyncManager->mWriteBackInFuture ) { 1130 if ( mSyncManager->mWriteBackInFuture ) {
1131 er = remote->rawIncidences(); 1131 er = remote->rawIncidences();
1132 remRem = er.count(); 1132 remRem = er.count();
1133 inR = er.first(); 1133 inR = er.first();
1134 QDateTime dt; 1134 QDateTime dt;
1135 QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); 1135 QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
1136 QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 ); 1136 QDateTime end = cur.addDays( (mSyncManager->mWriteBackInFuture +1 ) *7 );
1137 while ( inR ) { 1137 while ( inR ) {
1138 if ( inR->type() == "Todo" ) { 1138 if ( inR->type() == "Todo" ) {
1139 Todo * t = (Todo*)inR; 1139 Todo * t = (Todo*)inR;
1140 if ( t->hasDueDate() ) 1140 if ( t->hasDueDate() )
1141 dt = t->dtDue(); 1141 dt = t->dtDue();
1142 else 1142 else
1143 dt = cur.addSecs( 62 ); 1143 dt = cur.addSecs( 62 );
1144 } 1144 }
1145 else if (inR->type() == "Event" ) { 1145 else if (inR->type() == "Event" ) {
1146 bool ok; 1146 bool ok;
1147 dt = inR->getNextOccurence( cur, &ok ); 1147 dt = inR->getNextOccurence( cur, &ok );
1148 if ( !ok ) 1148 if ( !ok )
1149 dt = cur.addSecs( -62 ); 1149 dt = cur.addSecs( -62 );
1150 } 1150 }
1151 else 1151 else
1152 dt = inR->dtStart(); 1152 dt = inR->dtStart();
1153 if ( dt < cur || dt > end ) { 1153 if ( dt < cur || dt > end ) {
1154 remote->deleteIncidence( inR ); 1154 remote->deleteIncidence( inR );
1155 ++delFut; 1155 ++delFut;
1156 } 1156 }
1157 inR = er.next(); 1157 inR = er.next();
1158 } 1158 }
1159 } 1159 }
1160 bar.hide(); 1160 bar.hide();
1161 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1161 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1162 eventLSync->setReadOnly( false ); 1162 eventLSync->setReadOnly( false );
1163 eventLSync->setDtStart( mLastCalendarSync ); 1163 eventLSync->setDtStart( mLastCalendarSync );
1164 eventRSync->setDtStart( mLastCalendarSync ); 1164 eventRSync->setDtStart( mLastCalendarSync );
1165 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1165 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1166 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1166 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1167 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1167 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1168 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1168 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1169 eventLSync->setReadOnly( true ); 1169 eventLSync->setReadOnly( true );
1170 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncKDE) // kde is abnormal... 1170 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncKDE) // kde is abnormal...
1171 remote->addEvent( eventRSync ); 1171 remote->addEvent( eventRSync );
1172 else 1172 else
1173 delete eventRSync; 1173 delete eventRSync;
1174 QString mes; 1174 QString mes;
1175 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 ); 1175 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 );
1176 QString delmess; 1176 QString delmess;
1177 if ( delFut ) { 1177 if ( delFut ) {
1178 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInFuture, remRem-delFut); 1178 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInFuture, remRem-delFut);
1179 mes += delmess; 1179 mes += delmess;
1180 } 1180 }
1181 if ( mSyncManager->mShowSyncSummary ) { 1181 if ( mSyncManager->mShowSyncSummary ) {
1182 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); 1182 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") );
1183 } 1183 }
1184 qDebug( mes ); 1184 qDebug( mes );
1185 mCalendar->checkAlarmForIncidence( 0, true ); 1185 mCalendar->checkAlarmForIncidence( 0, true );
1186 return syncOK; 1186 return syncOK;
1187} 1187}
1188 1188
1189void CalendarView::setSyncDevice( QString s ) 1189void CalendarView::setSyncDevice( QString s )
1190{ 1190{
1191 mCurrentSyncDevice= s; 1191 mCurrentSyncDevice= s;
1192} 1192}
1193void CalendarView::setSyncName( QString s ) 1193void CalendarView::setSyncName( QString s )
1194{ 1194{
1195 mCurrentSyncName= s; 1195 mCurrentSyncName= s;
1196} 1196}
1197bool CalendarView::syncCalendar(QString filename, int mode) 1197bool CalendarView::syncCalendar(QString filename, int mode)
1198{ 1198{
1199 //qDebug("syncCalendar %s ", filename.latin1()); 1199 //qDebug("syncCalendar %s ", filename.latin1());
1200 mGlobalSyncMode = SYNC_MODE_NORMAL; 1200 mGlobalSyncMode = SYNC_MODE_NORMAL;
1201 CalendarLocal* calendar = new CalendarLocal(); 1201 CalendarLocal* calendar = new CalendarLocal();
1202 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1202 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1203 FileStorage* storage = new FileStorage( calendar ); 1203 FileStorage* storage = new FileStorage( calendar );
1204 bool syncOK = false; 1204 bool syncOK = false;
1205 storage->setFileName( filename ); 1205 storage->setFileName( filename );
1206 // qDebug("loading ... "); 1206 // qDebug("loading ... ");
1207 if ( storage->load() ) { 1207 if ( storage->load() ) {
1208 getEventViewerDialog()->setSyncMode( true ); 1208 getEventViewerDialog()->setSyncMode( true );
1209 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1209 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1210 getEventViewerDialog()->setSyncMode( false ); 1210 getEventViewerDialog()->setSyncMode( false );
1211 if ( syncOK ) { 1211 if ( syncOK ) {
1212 if ( mSyncManager->mWriteBackFile ) 1212 if ( mSyncManager->mWriteBackFile )
1213 { 1213 {
1214 storage->setSaveFormat( new ICalFormat() ); 1214 storage->setSaveFormat( new ICalFormat() );
1215 storage->save(); 1215 storage->save();
1216 } 1216 }
1217 } 1217 }
1218 setModified( true ); 1218 setModified( true );
1219 } 1219 }
1220 delete storage; 1220 delete storage;
1221 delete calendar; 1221 delete calendar;
1222 if ( syncOK ) 1222 if ( syncOK )
1223 updateView(); 1223 updateView();
1224 return syncOK; 1224 return syncOK;
1225} 1225}
1226 1226
1227void CalendarView::syncExternal( int mode ) 1227void CalendarView::syncExternal( int mode )
1228{ 1228{
1229 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1229 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1230 1230
1231 qApp->processEvents(); 1231 qApp->processEvents();
1232 CalendarLocal* calendar = new CalendarLocal(); 1232 CalendarLocal* calendar = new CalendarLocal();
1233 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1233 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1234 bool syncOK = false; 1234 bool syncOK = false;
1235 bool loadSuccess = false; 1235 bool loadSuccess = false;
1236 PhoneFormat* phoneFormat = 0; 1236 PhoneFormat* phoneFormat = 0;
1237#ifndef DESKTOP_VERSION 1237#ifndef DESKTOP_VERSION
1238 SharpFormat* sharpFormat = 0; 1238 SharpFormat* sharpFormat = 0;
1239 if ( mode == 0 ) { // sharp 1239 if ( mode == 0 ) { // sharp
1240 sharpFormat = new SharpFormat () ; 1240 sharpFormat = new SharpFormat () ;
1241 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1241 loadSuccess = sharpFormat->load( calendar, mCalendar );
1242 1242
1243 } else 1243 } else
1244#endif 1244#endif
1245 if ( mode == 1 ) { // phone 1245 if ( mode == 1 ) { // phone
1246 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1246 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1247 mSyncManager->mPhoneDevice, 1247 mSyncManager->mPhoneDevice,
1248 mSyncManager->mPhoneConnection, 1248 mSyncManager->mPhoneConnection,
1249 mSyncManager->mPhoneModel); 1249 mSyncManager->mPhoneModel);
1250 loadSuccess = phoneFormat->load( calendar,mCalendar); 1250 loadSuccess = phoneFormat->load( calendar,mCalendar);
1251 1251
1252 } else 1252 } else
1253 return; 1253 return;
1254 if ( loadSuccess ) { 1254 if ( loadSuccess ) {
1255 getEventViewerDialog()->setSyncMode( true ); 1255 getEventViewerDialog()->setSyncMode( true );
1256 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1256 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1257 getEventViewerDialog()->setSyncMode( false ); 1257 getEventViewerDialog()->setSyncMode( false );
1258 qApp->processEvents(); 1258 qApp->processEvents();
1259 if ( syncOK ) { 1259 if ( syncOK ) {
1260 if ( mSyncManager->mWriteBackFile ) 1260 if ( mSyncManager->mWriteBackFile )
1261 { 1261 {
1262 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1262 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1263 Incidence* inc = iL.first(); 1263 Incidence* inc = iL.first();
1264 if ( phoneFormat ) { 1264 if ( phoneFormat ) {
1265 while ( inc ) { 1265 while ( inc ) {
1266 inc->removeID(mCurrentSyncDevice); 1266 inc->removeID(mCurrentSyncDevice);
1267 inc = iL.next(); 1267 inc = iL.next();
1268 } 1268 }
1269 } 1269 }
1270#ifndef DESKTOP_VERSION 1270#ifndef DESKTOP_VERSION
1271 if ( sharpFormat ) 1271 if ( sharpFormat )
1272 sharpFormat->save(calendar); 1272 sharpFormat->save(calendar);
1273#endif 1273#endif
1274 if ( phoneFormat ) 1274 if ( phoneFormat )
1275 phoneFormat->save(calendar); 1275 phoneFormat->save(calendar);
1276 iL = calendar->rawIncidences(); 1276 iL = calendar->rawIncidences();
1277 inc = iL.first(); 1277 inc = iL.first();
1278 Incidence* loc; 1278 Incidence* loc;
1279 while ( inc ) { 1279 while ( inc ) {
1280 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1280 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1281 loc = mCalendar->incidence(inc->uid() ); 1281 loc = mCalendar->incidence(inc->uid() );
1282 if ( loc ) { 1282 if ( loc ) {
1283 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1283 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1284 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1284 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1285 } 1285 }
1286 } 1286 }
1287 inc = iL.next(); 1287 inc = iL.next();
1288 } 1288 }
1289 Incidence* lse = getLastSyncEvent(); 1289 Incidence* lse = getLastSyncEvent();
1290 if ( lse ) { 1290 if ( lse ) {
1291 lse->setReadOnly( false ); 1291 lse->setReadOnly( false );
1292 lse->setDescription( "" ); 1292 lse->setDescription( "" );
1293 lse->setReadOnly( true ); 1293 lse->setReadOnly( true );
1294 } 1294 }
1295 } 1295 }
1296 } 1296 }
1297 setModified( true ); 1297 setModified( true );
1298 } else { 1298 } else {
1299 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1299 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1300 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1300 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1301 question, i18n("Ok")) ; 1301 question, i18n("Ok")) ;
1302 1302
1303 } 1303 }
1304 delete calendar; 1304 delete calendar;
1305 updateView(); 1305 updateView();
1306 return ;//syncOK; 1306 return ;//syncOK;
1307 1307
1308} 1308}
1309 1309
1310bool CalendarView::importBday() 1310bool CalendarView::importBday()
1311{ 1311{
1312#ifndef KORG_NOKABC 1312#ifndef KORG_NOKABC
1313 1313
1314#ifdef DESKTOP_VERSION 1314#ifdef DESKTOP_VERSION
1315 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1315 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1316 KABC::AddressBook::Iterator it; 1316 KABC::AddressBook::Iterator it;
1317 int count = 0; 1317 int count = 0;
1318 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1318 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1319 ++count; 1319 ++count;
1320 } 1320 }
1321 QProgressBar bar(count,0 ); 1321 QProgressBar bar(count,0 );
1322 int w = 300; 1322 int w = 300;
1323 if ( QApplication::desktop()->width() < 320 ) 1323 if ( QApplication::desktop()->width() < 320 )
1324 w = 220; 1324 w = 220;
1325 int h = bar.sizeHint().height() ; 1325 int h = bar.sizeHint().height() ;
1326 int dw = QApplication::desktop()->width(); 1326 int dw = QApplication::desktop()->width();
1327 int dh = QApplication::desktop()->height(); 1327 int dh = QApplication::desktop()->height();
1328 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1328 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1329 bar.show(); 1329 bar.show();
1330 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1330 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1331 qApp->processEvents(); 1331 qApp->processEvents();
1332 count = 0; 1332 count = 0;
1333 int addCount = 0; 1333 int addCount = 0;
1334 KCal::Attendee* a = 0; 1334 KCal::Attendee* a = 0;
1335 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1335 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1336 if ( ! bar.isVisible() ) 1336 if ( ! bar.isVisible() )
1337 return false; 1337 return false;
1338 bar.setProgress( count++ ); 1338 bar.setProgress( count++ );
1339 qApp->processEvents(); 1339 qApp->processEvents();
1340 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1340 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1341 if ( (*it).birthday().date().isValid() ){ 1341 if ( (*it).birthday().date().isValid() ){
1342 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1342 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1343 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1343 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1344 ++addCount; 1344 ++addCount;
1345 } 1345 }
1346 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1346 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1347 if ( anni.isValid() ){ 1347 if ( anni.isValid() ){
1348 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1348 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1349 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1349 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1350 ++addCount; 1350 ++addCount;
1351 } 1351 }
1352 } 1352 }
1353 updateView(); 1353 updateView();
1354 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1354 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1355#else //DESKTOP_VERSION 1355#else //DESKTOP_VERSION
1356 1356
1357 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 1357 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
1358 // the result should now arrive through method insertBirthdays 1358 // the result should now arrive through method insertBirthdays
1359 1359
1360#endif //DESKTOP_VERSION 1360#endif //DESKTOP_VERSION
1361 1361
1362#endif //KORG_NOKABC 1362#endif //KORG_NOKABC
1363 1363
1364 1364
1365 return true; 1365 return true;
1366} 1366}
1367 1367
1368// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI 1368// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
1369void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, 1369void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
1370 const QStringList& anniversaryList, const QStringList& realNameList, 1370 const QStringList& anniversaryList, const QStringList& realNameList,
1371 const QStringList& emailList, const QStringList& assembledNameList, 1371 const QStringList& emailList, const QStringList& assembledNameList,
1372 const QStringList& uidList) 1372 const QStringList& uidList)
1373{ 1373{
1374 qDebug("CalendarView::insertBirthdays"); 1374 qDebug("CalendarView::insertBirthdays");
1375 if (uid == this->name()) 1375 if (uid == this->name())
1376 { 1376 {
1377 int count = birthdayList.count(); 1377 int count = birthdayList.count();
1378 int addCount = 0; 1378 int addCount = 0;
1379 KCal::Attendee* a = 0; 1379 KCal::Attendee* a = 0;
1380 1380
1381 qDebug("CalView 1 %i", count); 1381 qDebug("CalView 1 %i", count);
1382 1382
1383 QProgressBar bar(count,0 ); 1383 QProgressBar bar(count,0 );
1384 int w = 300; 1384 int w = 300;
1385 if ( QApplication::desktop()->width() < 320 ) 1385 if ( QApplication::desktop()->width() < 320 )
1386 w = 220; 1386 w = 220;
1387 int h = bar.sizeHint().height() ; 1387 int h = bar.sizeHint().height() ;
1388 int dw = QApplication::desktop()->width(); 1388 int dw = QApplication::desktop()->width();
1389 int dh = QApplication::desktop()->height(); 1389 int dh = QApplication::desktop()->height();
1390 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1390 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1391 bar.show(); 1391 bar.show();
1392 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 1392 bar.setCaption (i18n("inserting birthdays - close to abort!") );
1393 qApp->processEvents(); 1393 qApp->processEvents();
1394 1394
1395 QDate birthday; 1395 QDate birthday;
1396 QDate anniversary; 1396 QDate anniversary;
1397 QString realName; 1397 QString realName;
1398 QString email; 1398 QString email;
1399 QString assembledName; 1399 QString assembledName;
1400 QString uid; 1400 QString uid;
1401 bool ok = true; 1401 bool ok = true;
1402 for ( int i = 0; i < count; i++) 1402 for ( int i = 0; i < count; i++)
1403 { 1403 {
1404 if ( ! bar.isVisible() ) 1404 if ( ! bar.isVisible() )
1405 return; 1405 return;
1406 bar.setProgress( i ); 1406 bar.setProgress( i );
1407 qApp->processEvents(); 1407 qApp->processEvents();
1408 1408
1409 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); 1409 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
1410 if (!ok) { 1410 if (!ok) {
1411 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); 1411 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
1412 } 1412 }
1413 1413
1414 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); 1414 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
1415 if (!ok) { 1415 if (!ok) {
1416 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); 1416 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
1417 } 1417 }
1418 realName = realNameList[i]; 1418 realName = realNameList[i];
1419 email = emailList[i]; 1419 email = emailList[i];
1420 assembledName = assembledNameList[i]; 1420 assembledName = assembledNameList[i];
1421 uid = uidList[i]; 1421 uid = uidList[i];
1422 //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); 1422 //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() );
1423 1423
1424 if ( birthday.isValid() ){ 1424 if ( birthday.isValid() ){
1425 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1425 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1426 KCal::Attendee::ReqParticipant,uid) ; 1426 KCal::Attendee::ReqParticipant,uid) ;
1427 if ( addAnniversary( birthday, assembledName, a, true ) ) 1427 if ( addAnniversary( birthday, assembledName, a, true ) )
1428 ++addCount; 1428 ++addCount;
1429 } 1429 }
1430 1430
1431 if ( anniversary.isValid() ){ 1431 if ( anniversary.isValid() ){
1432 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1432 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1433 KCal::Attendee::ReqParticipant,uid) ; 1433 KCal::Attendee::ReqParticipant,uid) ;
1434 if ( addAnniversary( anniversary, assembledName, a, false ) ) 1434 if ( addAnniversary( anniversary, assembledName, a, false ) )
1435 ++addCount; 1435 ++addCount;
1436 } 1436 }
1437 } 1437 }
1438 1438
1439 updateView(); 1439 updateView();
1440 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1440 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1441 1441
1442 } 1442 }
1443 1443
1444} 1444}
1445 1445
1446 1446
1447 1447
1448bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1448bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1449{ 1449{
1450 //qDebug("addAnni "); 1450 //qDebug("addAnni ");
1451 Event * ev = new Event(); 1451 Event * ev = new Event();
1452 if ( a ) { 1452 if ( a ) {
1453 ev->addAttendee( a ); 1453 ev->addAttendee( a );
1454 } 1454 }
1455 QString kind; 1455 QString kind;
1456 if ( birthday ) 1456 if ( birthday )
1457 kind = i18n( "Birthday" ); 1457 kind = i18n( "Birthday" );
1458 else 1458 else
1459 kind = i18n( "Anniversary" ); 1459 kind = i18n( "Anniversary" );
1460 ev->setSummary( name + " - " + kind ); 1460 ev->setSummary( name + " - " + kind );
1461 ev->setOrganizer( "nobody@nowhere" ); 1461 ev->setOrganizer( "nobody@nowhere" );
1462 ev->setCategories( kind ); 1462 ev->setCategories( kind );
1463 ev->setDtStart( QDateTime(date) ); 1463 ev->setDtStart( QDateTime(date) );
1464 ev->setDtEnd( QDateTime(date) ); 1464 ev->setDtEnd( QDateTime(date) );
1465 ev->setFloats( true ); 1465 ev->setFloats( true );
1466 Recurrence * rec = ev->recurrence(); 1466 Recurrence * rec = ev->recurrence();
1467 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1467 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1468 rec->addYearlyNum( date.month() ); 1468 rec->addYearlyNum( date.month() );
1469 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1469 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1470 delete ev; 1470 delete ev;
1471 return false; 1471 return false;
1472 } 1472 }
1473 return true; 1473 return true;
1474 1474
1475} 1475}
1476bool CalendarView::importQtopia( const QString &categories, 1476bool CalendarView::importQtopia( const QString &categories,
1477 const QString &datebook, 1477 const QString &datebook,
1478 const QString &todolist ) 1478 const QString &todolist )
1479{ 1479{
1480 1480
1481 QtopiaFormat qtopiaFormat; 1481 QtopiaFormat qtopiaFormat;
1482 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1482 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1483 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1483 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1484 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1484 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1485 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1485 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1486 1486
1487 updateView(); 1487 updateView();
1488 return true; 1488 return true;
1489 1489
1490#if 0 1490#if 0
1491 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1491 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1492 mCurrentSyncDevice = "qtopia-XML"; 1492 mCurrentSyncDevice = "qtopia-XML";
1493 if ( mSyncManager->mAskForPreferences ) 1493 if ( mSyncManager->mAskForPreferences )
1494 edit_sync_options(); 1494 edit_sync_options();
1495 qApp->processEvents(); 1495 qApp->processEvents();
1496 CalendarLocal* calendar = new CalendarLocal(); 1496 CalendarLocal* calendar = new CalendarLocal();
1497 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1497 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1498 bool syncOK = false; 1498 bool syncOK = false;
1499 QtopiaFormat qtopiaFormat; 1499 QtopiaFormat qtopiaFormat;
1500 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1500 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1501 bool loadOk = true; 1501 bool loadOk = true;
1502 if ( !categories.isEmpty() ) 1502 if ( !categories.isEmpty() )
1503 loadOk = qtopiaFormat.load( calendar, categories ); 1503 loadOk = qtopiaFormat.load( calendar, categories );
1504 if ( loadOk && !datebook.isEmpty() ) 1504 if ( loadOk && !datebook.isEmpty() )
1505 loadOk = qtopiaFormat.load( calendar, datebook ); 1505 loadOk = qtopiaFormat.load( calendar, datebook );
1506 if ( loadOk && !todolist.isEmpty() ) 1506 if ( loadOk && !todolist.isEmpty() )
1507 loadOk = qtopiaFormat.load( calendar, todolist ); 1507 loadOk = qtopiaFormat.load( calendar, todolist );
1508 1508
1509 if ( loadOk ) { 1509 if ( loadOk ) {
1510 getEventViewerDialog()->setSyncMode( true ); 1510 getEventViewerDialog()->setSyncMode( true );
1511 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1511 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1512 getEventViewerDialog()->setSyncMode( false ); 1512 getEventViewerDialog()->setSyncMode( false );
1513 qApp->processEvents(); 1513 qApp->processEvents();
1514 if ( syncOK ) { 1514 if ( syncOK ) {
1515 if ( mSyncManager->mWriteBackFile ) 1515 if ( mSyncManager->mWriteBackFile )
1516 { 1516 {
1517 // write back XML file 1517 // write back XML file
1518 1518
1519 } 1519 }
1520 setModified( true ); 1520 setModified( true );
1521 } 1521 }
1522 } else { 1522 } else {
1523 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1523 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1524 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1524 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1525 question, i18n("Ok")) ; 1525 question, i18n("Ok")) ;
1526 } 1526 }
1527 delete calendar; 1527 delete calendar;
1528 updateView(); 1528 updateView();
1529 return syncOK; 1529 return syncOK;
1530 1530
1531 1531
1532#endif 1532#endif
1533 1533
1534} 1534}
1535 1535
1536void CalendarView::setSyncEventsReadOnly() 1536void CalendarView::setSyncEventsReadOnly()
1537{ 1537{
1538 Event * ev; 1538 Event * ev;
1539 QPtrList<Event> eL = mCalendar->rawEvents(); 1539 QPtrList<Event> eL = mCalendar->rawEvents();
1540 ev = eL.first(); 1540 ev = eL.first();
1541 while ( ev ) { 1541 while ( ev ) {
1542 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1542 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1543 ev->setReadOnly( true ); 1543 ev->setReadOnly( true );
1544 ev = eL.next(); 1544 ev = eL.next();
1545 } 1545 }
1546} 1546}
1547bool CalendarView::openCalendar(QString filename, bool merge) 1547bool CalendarView::openCalendar(QString filename, bool merge)
1548{ 1548{
1549 1549
1550 if (filename.isEmpty()) { 1550 if (filename.isEmpty()) {
1551 return false; 1551 return false;
1552 } 1552 }
1553 1553
1554 if (!QFile::exists(filename)) { 1554 if (!QFile::exists(filename)) {
1555 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1555 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1556 return false; 1556 return false;
1557 } 1557 }
1558 1558
1559 globalFlagBlockAgenda = 1; 1559 globalFlagBlockAgenda = 1;
1560 if (!merge) mCalendar->close(); 1560 if (!merge) mCalendar->close();
1561 1561
1562 mStorage->setFileName( filename ); 1562 mStorage->setFileName( filename );
1563 1563
1564 if ( mStorage->load() ) { 1564 if ( mStorage->load() ) {
1565 if ( merge ) ;//setModified( true ); 1565 if ( merge ) ;//setModified( true );
1566 else { 1566 else {
1567 //setModified( true ); 1567 //setModified( true );
1568 mViewManager->setDocumentId( filename ); 1568 mViewManager->setDocumentId( filename );
1569 mDialogManager->setDocumentId( filename ); 1569 mDialogManager->setDocumentId( filename );
1570 mTodoList->setDocumentId( filename ); 1570 mTodoList->setDocumentId( filename );
1571 } 1571 }
1572 globalFlagBlockAgenda = 2; 1572 globalFlagBlockAgenda = 2;
1573 // if ( getLastSyncEvent() ) 1573 // if ( getLastSyncEvent() )
1574 // getLastSyncEvent()->setReadOnly( true ); 1574 // getLastSyncEvent()->setReadOnly( true );
1575 mCalendar->reInitAlarmSettings(); 1575 mCalendar->reInitAlarmSettings();
1576 setSyncEventsReadOnly(); 1576 setSyncEventsReadOnly();
1577 updateUnmanagedViews(); 1577 updateUnmanagedViews();
1578 updateView(); 1578 updateView();
1579 if ( filename != MainWindow::defaultFileName() ) { 1579 if ( filename != MainWindow::defaultFileName() ) {
1580 saveCalendar( MainWindow::defaultFileName() ); 1580 saveCalendar( MainWindow::defaultFileName() );
1581 } else { 1581 } else {
1582 QFileInfo finf ( MainWindow::defaultFileName()); 1582 QFileInfo finf ( MainWindow::defaultFileName());
1583 if ( finf.exists() ) { 1583 if ( finf.exists() ) {
1584 setLoadedFileVersion( finf.lastModified () ); 1584 setLoadedFileVersion( finf.lastModified () );
1585 } 1585 }
1586 } 1586 }
1587 return true; 1587 return true;
1588 } else { 1588 } else {
1589 // while failing to load, the calendar object could 1589 // while failing to load, the calendar object could
1590 // have become partially populated. Clear it out. 1590 // have become partially populated. Clear it out.
1591 if ( !merge ) { 1591 if ( !merge ) {
1592 mCalendar->close(); 1592 mCalendar->close();
1593 mViewManager->setDocumentId( filename ); 1593 mViewManager->setDocumentId( filename );
1594 mDialogManager->setDocumentId( filename ); 1594 mDialogManager->setDocumentId( filename );
1595 mTodoList->setDocumentId( filename ); 1595 mTodoList->setDocumentId( filename );
1596 } 1596 }
1597 1597
1598 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1598 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1599 1599
1600 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 1600 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
1601 globalFlagBlockAgenda = 2; 1601 globalFlagBlockAgenda = 2;
1602 mCalendar->reInitAlarmSettings(); 1602 mCalendar->reInitAlarmSettings();
1603 setSyncEventsReadOnly(); 1603 setSyncEventsReadOnly();
1604 updateUnmanagedViews(); 1604 updateUnmanagedViews();
1605 updateView(); 1605 updateView();
1606 } 1606 }
1607 return false; 1607 return false;
1608} 1608}
1609void CalendarView::showOpenError() 1609void CalendarView::showOpenError()
1610{ 1610{
1611 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 1611 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
1612} 1612}
1613void CalendarView::setLoadedFileVersion(QDateTime dt) 1613void CalendarView::setLoadedFileVersion(QDateTime dt)
1614{ 1614{
1615 loadedFileVersion = dt; 1615 loadedFileVersion = dt;
1616} 1616}
1617bool CalendarView::checkFileChanged(QString fn) 1617bool CalendarView::checkFileChanged(QString fn)
1618{ 1618{
1619 QFileInfo finf ( fn ); 1619 QFileInfo finf ( fn );
1620 if ( !finf.exists() ) 1620 if ( !finf.exists() )
1621 return true; 1621 return true;
1622 QDateTime dt = finf.lastModified (); 1622 QDateTime dt = finf.lastModified ();
1623 if ( dt <= loadedFileVersion ) 1623 if ( dt <= loadedFileVersion )
1624 return false; 1624 return false;
1625 return true; 1625 return true;
1626 1626
1627} 1627}
1628void CalendarView::watchSavedFile() 1628void CalendarView::watchSavedFile()
1629{ 1629{
1630 QFileInfo finf ( MainWindow::defaultFileName()); 1630 QFileInfo finf ( MainWindow::defaultFileName());
1631 if ( !finf.exists() ) 1631 if ( !finf.exists() )
1632 return; 1632 return;
1633 QDateTime dt = finf.lastModified (); 1633 QDateTime dt = finf.lastModified ();
1634 if ( dt < loadedFileVersion ) { 1634 if ( dt < loadedFileVersion ) {
1635 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 1635 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
1636 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 1636 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1637 return; 1637 return;
1638 } 1638 }
1639 loadedFileVersion = dt; 1639 loadedFileVersion = dt;
1640} 1640}
1641 1641
1642bool CalendarView::checkFileVersion(QString fn) 1642bool CalendarView::checkFileVersion(QString fn)
1643{ 1643{
1644 QFileInfo finf ( fn ); 1644 QFileInfo finf ( fn );
1645 if ( !finf.exists() ) 1645 if ( !finf.exists() )
1646 return true; 1646 return true;
1647 QDateTime dt = finf.lastModified (); 1647 QDateTime dt = finf.lastModified ();
1648 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1648 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1649 //qDebug("file on disk version %s",dt.toString().latin1()); 1649 //qDebug("file on disk version %s",dt.toString().latin1());
1650 if ( dt <= loadedFileVersion ) 1650 if ( dt <= loadedFileVersion )
1651 return true; 1651 return true;
1652 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , 1652 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) ,
1653 i18n("KO/Pi Warning"),i18n("Overwrite"), 1653 i18n("KO/Pi Warning"),i18n("Overwrite"),
1654 i18n("Sync+save")); 1654 i18n("Sync+save"));
1655 1655
1656 if ( km == KMessageBox::Cancel ) 1656 if ( km == KMessageBox::Cancel )
1657 return false; 1657 return false;
1658 if ( km == KMessageBox::Yes ) 1658 if ( km == KMessageBox::Yes )
1659 return true; 1659 return true;
1660 1660
1661 setSyncDevice("deleteaftersync" ); 1661 setSyncDevice("deleteaftersync" );
1662 mSyncManager->mAskForPreferences = true; 1662 mSyncManager->mAskForPreferences = true;
1663 mSyncManager->mSyncAlgoPrefs = 3; 1663 mSyncManager->mSyncAlgoPrefs = 3;
1664 mSyncManager->mWriteBackFile = false; 1664 mSyncManager->mWriteBackFile = false;
1665 mSyncManager->mWriteBackExistingOnly = false; 1665 mSyncManager->mWriteBackExistingOnly = false;
1666 mSyncManager->mShowSyncSummary = false; 1666 mSyncManager->mShowSyncSummary = false;
1667 syncCalendar( fn, 3 ); 1667 syncCalendar( fn, 3 );
1668 Event * e = getLastSyncEvent(); 1668 Event * e = getLastSyncEvent();
1669 mCalendar->deleteEvent ( e ); 1669 mCalendar->deleteEvent ( e );
1670 updateView(); 1670 updateView();
1671 return true; 1671 return true;
1672} 1672}
1673 1673
1674bool CalendarView::saveCalendar( QString filename ) 1674bool CalendarView::saveCalendar( QString filename )
1675{ 1675{
1676 1676
1677 // Store back all unsaved data into calendar object 1677 // Store back all unsaved data into calendar object
1678 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1678 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1679 if ( mViewManager->currentView() ) 1679 if ( mViewManager->currentView() )
1680 mViewManager->currentView()->flushView(); 1680 mViewManager->currentView()->flushView();
1681 1681
1682 1682
1683 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 1683 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
1684 mStorage->setSaveFormat( new ICalFormat() ); 1684 mStorage->setSaveFormat( new ICalFormat() );
1685 mStorage->setFileName( filename ); 1685 mStorage->setFileName( filename );
1686 bool success; 1686 bool success;
1687 success = mStorage->save(); 1687 success = mStorage->save();
1688 if ( !success ) { 1688 if ( !success ) {
1689 return false; 1689 return false;
1690 } 1690 }
1691 if ( filename == MainWindow::defaultFileName() ) { 1691 if ( filename == MainWindow::defaultFileName() ) {
1692 setLoadedFileVersion( lfv ); 1692 setLoadedFileVersion( lfv );
1693 watchSavedFile(); 1693 watchSavedFile();
1694 } 1694 }
1695 return true; 1695 return true;
1696} 1696}
1697 1697
1698void CalendarView::closeCalendar() 1698void CalendarView::closeCalendar()
1699{ 1699{
1700 1700
1701 // child windows no longer valid 1701 // child windows no longer valid
1702 emit closingDown(); 1702 emit closingDown();
1703 1703
1704 mCalendar->close(); 1704 mCalendar->close();
1705 setModified(false); 1705 setModified(false);
1706 updateView(); 1706 updateView();
1707} 1707}
1708 1708
1709void CalendarView::archiveCalendar() 1709void CalendarView::archiveCalendar()
1710{ 1710{
1711 mDialogManager->showArchiveDialog(); 1711 mDialogManager->showArchiveDialog();
1712} 1712}
1713 1713
1714 1714
1715void CalendarView::readSettings() 1715void CalendarView::readSettings()
1716{ 1716{
1717 1717
1718 1718
1719 // mViewManager->showAgendaView(); 1719 // mViewManager->showAgendaView();
1720 QString str; 1720 QString str;
1721 //qDebug("CalendarView::readSettings() "); 1721 //qDebug("CalendarView::readSettings() ");
1722 // read settings from the KConfig, supplying reasonable 1722 // read settings from the KConfig, supplying reasonable
1723 // defaults where none are to be found 1723 // defaults where none are to be found
1724 KConfig *config = KOGlobals::config(); 1724 KConfig *config = KOGlobals::config();
1725#ifndef KORG_NOSPLITTER 1725#ifndef KORG_NOSPLITTER
1726 config->setGroup("KOrganizer Geometry"); 1726 config->setGroup("KOrganizer Geometry");
1727 1727
1728 QValueList<int> sizes = config->readIntListEntry("Separator1"); 1728 QValueList<int> sizes = config->readIntListEntry("Separator1");
1729 if (sizes.count() != 2) { 1729 if (sizes.count() != 2) {
1730 sizes << mDateNavigator->minimumSizeHint().width(); 1730 sizes << mDateNavigator->minimumSizeHint().width();
1731 sizes << 300; 1731 sizes << 300;
1732 } 1732 }
1733 mPanner->setSizes(sizes); 1733 mPanner->setSizes(sizes);
1734 1734
1735 sizes = config->readIntListEntry("Separator2"); 1735 sizes = config->readIntListEntry("Separator2");
1736 if ( ( mResourceView && sizes.count() == 4 ) || 1736 if ( ( mResourceView && sizes.count() == 4 ) ||
1737 ( !mResourceView && sizes.count() == 3 ) ) { 1737 ( !mResourceView && sizes.count() == 3 ) ) {
1738 mLeftSplitter->setSizes(sizes); 1738 mLeftSplitter->setSizes(sizes);
1739 } 1739 }
1740#endif 1740#endif
1741 globalFlagBlockAgenda = 1; 1741 globalFlagBlockAgenda = 1;
1742 mViewManager->showAgendaView(); 1742 mViewManager->showAgendaView();
1743 //mViewManager->readSettings( config ); 1743 //mViewManager->readSettings( config );
1744 mTodoList->restoreLayout(config,QString("Todo Layout")); 1744 mTodoList->restoreLayout(config,QString("Todo Layout"));
1745 readFilterSettings(config); 1745 readFilterSettings(config);
1746 config->setGroup( "Views" ); 1746 config->setGroup( "Views" );
1747 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 1747 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
1748 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 1748 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
1749 else if ( dateCount == 7 ) mNavigator->selectWeek(); 1749 else if ( dateCount == 7 ) mNavigator->selectWeek();
1750 else mNavigator->selectDates( dateCount ); 1750 else mNavigator->selectDates( dateCount );
1751 // mViewManager->readSettings( config ); 1751 // mViewManager->readSettings( config );
1752 updateConfig(); 1752 updateConfig();
1753 globalFlagBlockAgenda = 2; 1753 globalFlagBlockAgenda = 2;
1754 mViewManager->readSettings( config ); 1754 mViewManager->readSettings( config );
1755#ifdef DESKTOP_VERSION 1755#ifdef DESKTOP_VERSION
1756 config->setGroup("WidgetLayout"); 1756 config->setGroup("WidgetLayout");
1757 QStringList list; 1757 QStringList list;
1758 list = config->readListEntry("MainLayout"); 1758 list = config->readListEntry("MainLayout");
1759 int x,y,w,h; 1759 int x,y,w,h;
1760 if ( ! list.isEmpty() ) { 1760 if ( ! list.isEmpty() ) {
1761 x = list[0].toInt(); 1761 x = list[0].toInt();
1762 y = list[1].toInt(); 1762 y = list[1].toInt();
1763 w = list[2].toInt(); 1763 w = list[2].toInt();
1764 h = list[3].toInt(); 1764 h = list[3].toInt();
1765 topLevelWidget()->setGeometry(x,y,w,h); 1765 topLevelWidget()->setGeometry(x,y,w,h);
1766 1766
1767 } else { 1767 } else {
1768 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 1768 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
1769 } 1769 }
1770 list = config->readListEntry("EditEventLayout"); 1770 list = config->readListEntry("EditEventLayout");
1771 if ( ! list.isEmpty() ) { 1771 if ( ! list.isEmpty() ) {
1772 x = list[0].toInt(); 1772 x = list[0].toInt();
1773 y = list[1].toInt(); 1773 y = list[1].toInt();
1774 w = list[2].toInt(); 1774 w = list[2].toInt();
1775 h = list[3].toInt(); 1775 h = list[3].toInt();
1776 mEventEditor->setGeometry(x,y,w,h); 1776 mEventEditor->setGeometry(x,y,w,h);
1777 1777
1778 } 1778 }
1779 list = config->readListEntry("EditTodoLayout"); 1779 list = config->readListEntry("EditTodoLayout");
1780 if ( ! list.isEmpty() ) { 1780 if ( ! list.isEmpty() ) {
1781 x = list[0].toInt(); 1781 x = list[0].toInt();
1782 y = list[1].toInt(); 1782 y = list[1].toInt();
1783 w = list[2].toInt(); 1783 w = list[2].toInt();
1784 h = list[3].toInt(); 1784 h = list[3].toInt();
1785 mTodoEditor->setGeometry(x,y,w,h); 1785 mTodoEditor->setGeometry(x,y,w,h);
1786 1786
1787 } 1787 }
1788 list = config->readListEntry("ViewerLayout"); 1788 list = config->readListEntry("ViewerLayout");
1789 if ( ! list.isEmpty() ) { 1789 if ( ! list.isEmpty() ) {
1790 x = list[0].toInt(); 1790 x = list[0].toInt();
1791 y = list[1].toInt(); 1791 y = list[1].toInt();
1792 w = list[2].toInt(); 1792 w = list[2].toInt();
1793 h = list[3].toInt(); 1793 h = list[3].toInt();
1794 getEventViewerDialog()->setGeometry(x,y,w,h); 1794 getEventViewerDialog()->setGeometry(x,y,w,h);
1795 } 1795 }
1796#endif 1796#endif
1797 1797
1798} 1798}
1799 1799
1800 1800
1801void CalendarView::writeSettings() 1801void CalendarView::writeSettings()
1802{ 1802{
1803 // kdDebug() << "CalendarView::writeSettings" << endl; 1803 // kdDebug() << "CalendarView::writeSettings" << endl;
1804 1804
1805 KConfig *config = KOGlobals::config(); 1805 KConfig *config = KOGlobals::config();
1806 1806
1807#ifndef KORG_NOSPLITTER 1807#ifndef KORG_NOSPLITTER
1808 config->setGroup("KOrganizer Geometry"); 1808 config->setGroup("KOrganizer Geometry");
1809 1809
1810 QValueList<int> list = mPanner->sizes(); 1810 QValueList<int> list = mPanner->sizes();
1811 config->writeEntry("Separator1",list); 1811 config->writeEntry("Separator1",list);
1812 1812
1813 list = mLeftSplitter->sizes(); 1813 list = mLeftSplitter->sizes();
1814 config->writeEntry("Separator2",list); 1814 config->writeEntry("Separator2",list);
1815#endif 1815#endif
1816 1816
1817 mViewManager->writeSettings( config ); 1817 mViewManager->writeSettings( config );
1818 mTodoList->saveLayout(config,QString("Todo Layout")); 1818 mTodoList->saveLayout(config,QString("Todo Layout"));
1819 mDialogManager->writeSettings( config ); 1819 mDialogManager->writeSettings( config );
1820 //KOPrefs::instance()->usrWriteConfig(); 1820 //KOPrefs::instance()->usrWriteConfig();
1821 KOPrefs::instance()->writeConfig(); 1821 KOPrefs::instance()->writeConfig();
1822 1822
1823 writeFilterSettings(config); 1823 writeFilterSettings(config);
1824 1824
1825 config->setGroup( "Views" ); 1825 config->setGroup( "Views" );
1826 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 1826 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
1827 1827
1828#ifdef DESKTOP_VERSION 1828#ifdef DESKTOP_VERSION
1829 config->setGroup("WidgetLayout"); 1829 config->setGroup("WidgetLayout");
1830 QStringList list ;//= config->readListEntry("MainLayout"); 1830 QStringList list ;//= config->readListEntry("MainLayout");
1831 int x,y,w,h; 1831 int x,y,w,h;
1832 QWidget* wid; 1832 QWidget* wid;
1833 wid = topLevelWidget(); 1833 wid = topLevelWidget();
1834 x = wid->geometry().x(); 1834 x = wid->geometry().x();
1835 y = wid->geometry().y(); 1835 y = wid->geometry().y();
1836 w = wid->width(); 1836 w = wid->width();
1837 h = wid->height(); 1837 h = wid->height();
1838 list.clear(); 1838 list.clear();
1839 list << QString::number( x ); 1839 list << QString::number( x );
1840 list << QString::number( y ); 1840 list << QString::number( y );
1841 list << QString::number( w ); 1841 list << QString::number( w );
1842 list << QString::number( h ); 1842 list << QString::number( h );
1843 config->writeEntry("MainLayout",list ); 1843 config->writeEntry("MainLayout",list );
1844 1844
1845 wid = mEventEditor; 1845 wid = mEventEditor;
1846 x = wid->geometry().x(); 1846 x = wid->geometry().x();
1847 y = wid->geometry().y(); 1847 y = wid->geometry().y();
1848 w = wid->width(); 1848 w = wid->width();
1849 h = wid->height(); 1849 h = wid->height();
1850 list.clear(); 1850 list.clear();
1851 list << QString::number( x ); 1851 list << QString::number( x );
1852 list << QString::number( y ); 1852 list << QString::number( y );
1853 list << QString::number( w ); 1853 list << QString::number( w );
1854 list << QString::number( h ); 1854 list << QString::number( h );
1855 config->writeEntry("EditEventLayout",list ); 1855 config->writeEntry("EditEventLayout",list );
1856 1856
1857 wid = mTodoEditor; 1857 wid = mTodoEditor;
1858 x = wid->geometry().x(); 1858 x = wid->geometry().x();
1859 y = wid->geometry().y(); 1859 y = wid->geometry().y();
1860 w = wid->width(); 1860 w = wid->width();
1861 h = wid->height(); 1861 h = wid->height();
1862 list.clear(); 1862 list.clear();
1863 list << QString::number( x ); 1863 list << QString::number( x );
1864 list << QString::number( y ); 1864 list << QString::number( y );
1865 list << QString::number( w ); 1865 list << QString::number( w );
1866 list << QString::number( h ); 1866 list << QString::number( h );
1867 config->writeEntry("EditTodoLayout",list ); 1867 config->writeEntry("EditTodoLayout",list );
1868 wid = getEventViewerDialog(); 1868 wid = getEventViewerDialog();
1869 x = wid->geometry().x(); 1869 x = wid->geometry().x();
1870 y = wid->geometry().y(); 1870 y = wid->geometry().y();
1871 w = wid->width(); 1871 w = wid->width();
1872 h = wid->height(); 1872 h = wid->height();
1873 list.clear(); 1873 list.clear();
1874 list << QString::number( x ); 1874 list << QString::number( x );
1875 list << QString::number( y ); 1875 list << QString::number( y );
1876 list << QString::number( w ); 1876 list << QString::number( w );
1877 list << QString::number( h ); 1877 list << QString::number( h );
1878 config->writeEntry("ViewerLayout",list ); 1878 config->writeEntry("ViewerLayout",list );
1879 wid = mDialogManager->getSearchDialog(); 1879 wid = mDialogManager->getSearchDialog();
1880 if ( wid ) { 1880 if ( wid ) {
1881 x = wid->geometry().x(); 1881 x = wid->geometry().x();
1882 y = wid->geometry().y(); 1882 y = wid->geometry().y();
1883 w = wid->width(); 1883 w = wid->width();
1884 h = wid->height(); 1884 h = wid->height();
1885 list.clear(); 1885 list.clear();
1886 list << QString::number( x ); 1886 list << QString::number( x );
1887 list << QString::number( y ); 1887 list << QString::number( y );
1888 list << QString::number( w ); 1888 list << QString::number( w );
1889 list << QString::number( h ); 1889 list << QString::number( h );
1890 config->writeEntry("SearchLayout",list ); 1890 config->writeEntry("SearchLayout",list );
1891 } 1891 }
1892#endif 1892#endif
1893 1893
1894 1894
1895 config->sync(); 1895 config->sync();
1896} 1896}
1897 1897
1898void CalendarView::readFilterSettings(KConfig *config) 1898void CalendarView::readFilterSettings(KConfig *config)
1899{ 1899{
1900 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 1900 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
1901 1901
1902 mFilters.clear(); 1902 mFilters.clear();
1903 1903
1904 config->setGroup("General"); 1904 config->setGroup("General");
1905 QStringList filterList = config->readListEntry("CalendarFilters"); 1905 QStringList filterList = config->readListEntry("CalendarFilters");
1906 1906
1907 QStringList::ConstIterator it = filterList.begin(); 1907 QStringList::ConstIterator it = filterList.begin();
1908 QStringList::ConstIterator end = filterList.end(); 1908 QStringList::ConstIterator end = filterList.end();
1909 while(it != end) { 1909 while(it != end) {
1910 // kdDebug() << " filter: " << (*it) << endl; 1910 // kdDebug() << " filter: " << (*it) << endl;
1911 1911
1912 CalFilter *filter; 1912 CalFilter *filter;
1913 filter = new CalFilter(*it); 1913 filter = new CalFilter(*it);
1914 config->setGroup("Filter_" + (*it)); 1914 config->setGroup("Filter_" + (*it));
1915 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 1915 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
1916 filter->setCriteria(config->readNumEntry("Criteria",0)); 1916 filter->setCriteria(config->readNumEntry("Criteria",0));
1917 filter->setCategoryList(config->readListEntry("CategoryList")); 1917 filter->setCategoryList(config->readListEntry("CategoryList"));
1918 mFilters.append(filter); 1918 mFilters.append(filter);
1919 1919
1920 ++it; 1920 ++it;
1921 } 1921 }
1922 1922
1923 if (mFilters.count() == 0) { 1923 if (mFilters.count() == 0) {
1924 CalFilter *filter = new CalFilter(i18n("Default")); 1924 CalFilter *filter = new CalFilter(i18n("Default"));
1925 mFilters.append(filter); 1925 mFilters.append(filter);
1926 } 1926 }
1927 mFilterView->updateFilters(); 1927 mFilterView->updateFilters();
1928 config->setGroup("FilterView"); 1928 config->setGroup("FilterView");
1929 1929
1930 mFilterView->blockSignals(true); 1930 mFilterView->blockSignals(true);
1931 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 1931 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
1932 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 1932 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
1933 mFilterView->blockSignals(false); 1933 mFilterView->blockSignals(false);
1934 // We do it manually to avoid it being done twice by the above calls 1934 // We do it manually to avoid it being done twice by the above calls
1935 updateFilter(); 1935 updateFilter();
1936} 1936}
1937 1937
1938void CalendarView::writeFilterSettings(KConfig *config) 1938void CalendarView::writeFilterSettings(KConfig *config)
1939{ 1939{
1940 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 1940 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
1941 1941
1942 QStringList filterList; 1942 QStringList filterList;
1943 1943
1944 CalFilter *filter = mFilters.first(); 1944 CalFilter *filter = mFilters.first();
1945 while(filter) { 1945 while(filter) {
1946 // kdDebug() << " fn: " << filter->name() << endl; 1946 // kdDebug() << " fn: " << filter->name() << endl;
1947 filterList << filter->name(); 1947 filterList << filter->name();
1948 config->setGroup("Filter_" + filter->name()); 1948 config->setGroup("Filter_" + filter->name());
1949 config->writeEntry("Criteria",filter->criteria()); 1949 config->writeEntry("Criteria",filter->criteria());
1950 config->writeEntry("CategoryList",filter->categoryList()); 1950 config->writeEntry("CategoryList",filter->categoryList());
1951 filter = mFilters.next(); 1951 filter = mFilters.next();
1952 } 1952 }
1953 config->setGroup("General"); 1953 config->setGroup("General");
1954 config->writeEntry("CalendarFilters",filterList); 1954 config->writeEntry("CalendarFilters",filterList);
1955 1955
1956 config->setGroup("FilterView"); 1956 config->setGroup("FilterView");
1957 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 1957 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
1958 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 1958 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
1959} 1959}
1960 1960
1961 1961
1962void CalendarView::goToday() 1962void CalendarView::goToday()
1963{ 1963{
1964 mNavigator->selectToday(); 1964 mNavigator->selectToday();
1965} 1965}
1966 1966
1967void CalendarView::goNext() 1967void CalendarView::goNext()
1968{ 1968{
1969 mNavigator->selectNext(); 1969 mNavigator->selectNext();
1970} 1970}
1971 1971
1972void CalendarView::goPrevious() 1972void CalendarView::goPrevious()
1973{ 1973{
1974 mNavigator->selectPrevious(); 1974 mNavigator->selectPrevious();
1975} 1975}
1976void CalendarView::goNextMonth() 1976void CalendarView::goNextMonth()
1977{ 1977{
1978 mNavigator->selectNextMonth(); 1978 mNavigator->selectNextMonth();
1979} 1979}
1980 1980
1981void CalendarView::goPreviousMonth() 1981void CalendarView::goPreviousMonth()
1982{ 1982{
1983 mNavigator->selectPreviousMonth(); 1983 mNavigator->selectPreviousMonth();
1984} 1984}
1985void CalendarView::writeLocale() 1985void CalendarView::writeLocale()
1986{ 1986{
1987 //KPimGlobalPrefs::instance()->setGlobalConfig(); 1987 //KPimGlobalPrefs::instance()->setGlobalConfig();
1988#if 0 1988#if 0
1989 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); 1989 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime );
1990 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); 1990 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday );
1991 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); 1991 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate );
1992 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); 1992 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage );
1993 QString dummy = KOPrefs::instance()->mUserDateFormatLong; 1993 QString dummy = KOPrefs::instance()->mUserDateFormatLong;
1994 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 1994 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
1995 dummy = KOPrefs::instance()->mUserDateFormatShort; 1995 dummy = KOPrefs::instance()->mUserDateFormatShort;
1996 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 1996 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
1997 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, 1997 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving,
1998 KOPrefs::instance()->mDaylightsavingStart, 1998 KOPrefs::instance()->mDaylightsavingStart,
1999 KOPrefs::instance()->mDaylightsavingEnd ); 1999 KOPrefs::instance()->mDaylightsavingEnd );
2000 KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId ); 2000 KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId );
2001#endif 2001#endif
2002} 2002}
2003void CalendarView::updateConfig() 2003void CalendarView::updateConfig()
2004{ 2004{
2005 writeLocale(); 2005 writeLocale();
2006 if ( KOPrefs::instance()->mUseAppColors ) 2006 if ( KOPrefs::instance()->mUseAppColors )
2007 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 2007 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
2008 emit configChanged(); 2008 emit configChanged();
2009 mTodoList->updateConfig(); 2009 mTodoList->updateConfig();
2010 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 2010 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
2011 mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 2011 mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
2012 // To make the "fill window" configurations work 2012 // To make the "fill window" configurations work
2013 //mViewManager->raiseCurrentView(); 2013 //mViewManager->raiseCurrentView();
2014} 2014}
2015 2015
2016 2016
2017void CalendarView::eventChanged(Event *event) 2017void CalendarView::eventChanged(Event *event)
2018{ 2018{
2019 changeEventDisplay(event,KOGlobals::EVENTEDITED); 2019 changeEventDisplay(event,KOGlobals::EVENTEDITED);
2020 //updateUnmanagedViews(); 2020 //updateUnmanagedViews();
2021} 2021}
2022 2022
2023void CalendarView::eventAdded(Event *event) 2023void CalendarView::eventAdded(Event *event)
2024{ 2024{
2025 changeEventDisplay(event,KOGlobals::EVENTADDED); 2025 changeEventDisplay(event,KOGlobals::EVENTADDED);
2026} 2026}
2027 2027
2028void CalendarView::eventToBeDeleted(Event *) 2028void CalendarView::eventToBeDeleted(Event *)
2029{ 2029{
2030 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 2030 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
2031} 2031}
2032 2032
2033void CalendarView::eventDeleted() 2033void CalendarView::eventDeleted()
2034{ 2034{
2035 changeEventDisplay(0,KOGlobals::EVENTDELETED); 2035 changeEventDisplay(0,KOGlobals::EVENTDELETED);
2036} 2036}
2037void CalendarView::changeTodoDisplay(Todo *which, int action) 2037void CalendarView::changeTodoDisplay(Todo *which, int action)
2038{ 2038{
2039 changeIncidenceDisplay((Incidence *)which, action); 2039 changeIncidenceDisplay((Incidence *)which, action);
2040 mDateNavigator->updateView(); //LR 2040 mDateNavigator->updateView(); //LR
2041 //mDialogManager->updateSearchDialog(); 2041 //mDialogManager->updateSearchDialog();
2042 2042
2043 if (which) { 2043 if (which) {
2044 mViewManager->updateWNview(); 2044 mViewManager->updateWNview();
2045 //mTodoList->updateView(); 2045 //mTodoList->updateView();
2046 } 2046 }
2047 2047
2048} 2048}
2049 2049
2050void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 2050void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
2051{ 2051{
2052 updateUnmanagedViews(); 2052 updateUnmanagedViews();
2053 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 2053 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
2054 if ( action == KOGlobals::EVENTDELETED ) { //delete 2054 if ( action == KOGlobals::EVENTDELETED ) { //delete
2055 mCalendar->checkAlarmForIncidence( 0, true ); 2055 mCalendar->checkAlarmForIncidence( 0, true );
2056 if ( mEventViewerDialog ) 2056 if ( mEventViewerDialog )
2057 mEventViewerDialog->hide(); 2057 mEventViewerDialog->hide();
2058 } 2058 }
2059 else 2059 else
2060 mCalendar->checkAlarmForIncidence( which , false ); 2060 mCalendar->checkAlarmForIncidence( which , false );
2061} 2061}
2062 2062
2063// most of the changeEventDisplays() right now just call the view's 2063// most of the changeEventDisplays() right now just call the view's
2064// total update mode, but they SHOULD be recoded to be more refresh-efficient. 2064// total update mode, but they SHOULD be recoded to be more refresh-efficient.
2065void CalendarView::changeEventDisplay(Event *which, int action) 2065void CalendarView::changeEventDisplay(Event *which, int action)
2066{ 2066{
2067 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 2067 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
2068 changeIncidenceDisplay((Incidence *)which, action); 2068 changeIncidenceDisplay((Incidence *)which, action);
2069 mDateNavigator->updateView(); 2069 mDateNavigator->updateView();
2070 //mDialogManager->updateSearchDialog(); 2070 //mDialogManager->updateSearchDialog();
2071 2071
2072 if (which) { 2072 if (which) {
2073 // If there is an event view visible update the display 2073 // If there is an event view visible update the display
2074 mViewManager->currentView()->changeEventDisplay(which,action); 2074 mViewManager->currentView()->changeEventDisplay(which,action);
2075 // TODO: check, if update needed 2075 // TODO: check, if update needed
2076 // if (which->getTodoStatus()) { 2076 // if (which->getTodoStatus()) {
2077 mTodoList->updateView(); 2077 mTodoList->updateView();
2078 // } 2078 // }
2079 } else { 2079 } else {
2080 mViewManager->currentView()->updateView(); 2080 mViewManager->currentView()->updateView();
2081 } 2081 }
2082} 2082}
2083 2083
2084 2084
2085void CalendarView::updateTodoViews() 2085void CalendarView::updateTodoViews()
2086{ 2086{
2087 2087
2088 mTodoList->updateView(); 2088 mTodoList->updateView();
2089 mViewManager->currentView()->updateView(); 2089 mViewManager->currentView()->updateView();
2090 2090
2091} 2091}
2092 2092
2093 2093
2094void CalendarView::updateView(const QDate &start, const QDate &end) 2094void CalendarView::updateView(const QDate &start, const QDate &end)
2095{ 2095{
2096 mTodoList->updateView(); 2096 mTodoList->updateView();
2097 mViewManager->updateView(start, end); 2097 mViewManager->updateView(start, end);
2098 //mDateNavigator->updateView(); 2098 //mDateNavigator->updateView();
2099} 2099}
2100 2100
2101void CalendarView::updateView() 2101void CalendarView::updateView()
2102{ 2102{
2103 DateList tmpList = mNavigator->selectedDates(); 2103 DateList tmpList = mNavigator->selectedDates();
2104 2104
2105 // We assume that the navigator only selects consecutive days. 2105 // We assume that the navigator only selects consecutive days.
2106 updateView( tmpList.first(), tmpList.last() ); 2106 updateView( tmpList.first(), tmpList.last() );
2107} 2107}
2108 2108
2109void CalendarView::updateUnmanagedViews() 2109void CalendarView::updateUnmanagedViews()
2110{ 2110{
2111 mDateNavigator->updateDayMatrix(); 2111 mDateNavigator->updateDayMatrix();
2112} 2112}
2113 2113
2114int CalendarView::msgItemDelete() 2114int CalendarView::msgItemDelete()
2115{ 2115{
2116 return KMessageBox::warningContinueCancel(this, 2116 return KMessageBox::warningContinueCancel(this,
2117 i18n("This item will be\npermanently deleted."), 2117 i18n("This item will be\npermanently deleted."),
2118 i18n("KO/Pi Confirmation"),i18n("Delete")); 2118 i18n("KO/Pi Confirmation"),i18n("Delete"));
2119} 2119}
2120 2120
2121 2121
2122void CalendarView::edit_cut() 2122void CalendarView::edit_cut()
2123{ 2123{
2124 Event *anEvent=0; 2124 Event *anEvent=0;
2125 2125
2126 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2126 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2127 2127
2128 if (mViewManager->currentView()->isEventView()) { 2128 if (mViewManager->currentView()->isEventView()) {
2129 if ( incidence && incidence->type() == "Event" ) { 2129 if ( incidence && incidence->type() == "Event" ) {
2130 anEvent = static_cast<Event *>(incidence); 2130 anEvent = static_cast<Event *>(incidence);
2131 } 2131 }
2132 } 2132 }
2133 2133
2134 if (!anEvent) { 2134 if (!anEvent) {
2135 KNotifyClient::beep(); 2135 KNotifyClient::beep();
2136 return; 2136 return;
2137 } 2137 }
2138 DndFactory factory( mCalendar ); 2138 DndFactory factory( mCalendar );
2139 factory.cutEvent(anEvent); 2139 factory.cutEvent(anEvent);
2140 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2140 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2141} 2141}
2142 2142
2143void CalendarView::edit_copy() 2143void CalendarView::edit_copy()
2144{ 2144{
2145 Event *anEvent=0; 2145 Event *anEvent=0;
2146 2146
2147 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2147 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2148 2148
2149 if (mViewManager->currentView()->isEventView()) { 2149 if (mViewManager->currentView()->isEventView()) {
2150 if ( incidence && incidence->type() == "Event" ) { 2150 if ( incidence && incidence->type() == "Event" ) {
2151 anEvent = static_cast<Event *>(incidence); 2151 anEvent = static_cast<Event *>(incidence);
2152 } 2152 }
2153 } 2153 }
2154 2154
2155 if (!anEvent) { 2155 if (!anEvent) {
2156 KNotifyClient::beep(); 2156 KNotifyClient::beep();
2157 return; 2157 return;
2158 } 2158 }
2159 DndFactory factory( mCalendar ); 2159 DndFactory factory( mCalendar );
2160 factory.copyEvent(anEvent); 2160 factory.copyEvent(anEvent);
2161} 2161}
2162 2162
2163void CalendarView::edit_paste() 2163void CalendarView::edit_paste()
2164{ 2164{
2165 QDate date = mNavigator->selectedDates().first(); 2165 QDate date = mNavigator->selectedDates().first();
2166 2166
2167 DndFactory factory( mCalendar ); 2167 DndFactory factory( mCalendar );
2168 Event *pastedEvent = factory.pasteEvent( date ); 2168 Event *pastedEvent = factory.pasteEvent( date );
2169 2169
2170 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 2170 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
2171} 2171}
2172 2172
2173void CalendarView::edit_options() 2173void CalendarView::edit_options()
2174{ 2174{
2175 mDialogManager->showOptionsDialog(); 2175 mDialogManager->showOptionsDialog();
2176 //writeSettings(); 2176 //writeSettings();
2177} 2177}
2178 2178
2179void CalendarView::slotSelectPickerDate( QDate d) 2179void CalendarView::slotSelectPickerDate( QDate d)
2180{ 2180{
2181 mDateFrame->hide(); 2181 mDateFrame->hide();
2182 if ( mDatePickerMode == 1 ) { 2182 if ( mDatePickerMode == 1 ) {
2183 mNavigator->slotDaySelect( d ); 2183 mNavigator->slotDaySelect( d );
2184 } else if ( mDatePickerMode == 2 ) { 2184 } else if ( mDatePickerMode == 2 ) {
2185 if ( mMoveIncidence->type() == "Todo" ) { 2185 if ( mMoveIncidence->type() == "Todo" ) {
2186 Todo * to = (Todo *) mMoveIncidence; 2186 Todo * to = (Todo *) mMoveIncidence;
2187 QTime tim; 2187 QTime tim;
2188 if ( to->hasDueDate() ) 2188 if ( to->hasDueDate() )
2189 tim = to->dtDue().time(); 2189 tim = to->dtDue().time();
2190 else { 2190 else {
2191 tim = QTime ( 0,0,0 ); 2191 tim = QTime ( 0,0,0 );
2192 to->setFloats( true ); 2192 to->setFloats( true );
2193 to->setHasDueDate( true ); 2193 to->setHasDueDate( true );
2194 } 2194 }
2195 QDateTime dt ( d,tim ); 2195 QDateTime dt ( d,tim );
2196 to->setDtDue( dt ); 2196 to->setDtDue( dt );
2197 todoChanged( to ); 2197 todoChanged( to );
2198 } else { 2198 } else {
2199 QTime tim = mMoveIncidence->dtStart().time(); 2199 QTime tim = mMoveIncidence->dtStart().time();
2200 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2200 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2201 QDateTime dt ( d,tim ); 2201 QDateTime dt ( d,tim );
2202 mMoveIncidence->setDtStart( dt ); 2202 mMoveIncidence->setDtStart( dt );
2203 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2203 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2204 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2204 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2205 } 2205 }
2206 2206
2207 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2207 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2208 } 2208 }
2209} 2209}
2210 2210
2211void CalendarView::removeCategories() 2211void CalendarView::removeCategories()
2212{ 2212{
2213 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2213 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2214 QStringList catList = KOPrefs::instance()->mCustomCategories; 2214 QStringList catList = KOPrefs::instance()->mCustomCategories;
2215 QStringList catIncList; 2215 QStringList catIncList;
2216 QStringList newCatList; 2216 QStringList newCatList;
2217 Incidence* inc = incList.first(); 2217 Incidence* inc = incList.first();
2218 int i; 2218 int i;
2219 int count = 0; 2219 int count = 0;
2220 while ( inc ) { 2220 while ( inc ) {
2221 newCatList.clear(); 2221 newCatList.clear();
2222 catIncList = inc->categories() ; 2222 catIncList = inc->categories() ;
2223 for( i = 0; i< catIncList.count(); ++i ) { 2223 for( i = 0; i< catIncList.count(); ++i ) {
2224 if ( catList.contains (catIncList[i])) 2224 if ( catList.contains (catIncList[i]))
2225 newCatList.append( catIncList[i] ); 2225 newCatList.append( catIncList[i] );
2226 } 2226 }
2227 newCatList.sort(); 2227 newCatList.sort();
2228 inc->setCategories( newCatList.join(",") ); 2228 inc->setCategories( newCatList.join(",") );
2229 inc = incList.next(); 2229 inc = incList.next();
2230 } 2230 }
2231} 2231}
2232 2232
2233int CalendarView::addCategories() 2233int CalendarView::addCategories()
2234{ 2234{
2235 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2235 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2236 QStringList catList = KOPrefs::instance()->mCustomCategories; 2236 QStringList catList = KOPrefs::instance()->mCustomCategories;
2237 QStringList catIncList; 2237 QStringList catIncList;
2238 Incidence* inc = incList.first(); 2238 Incidence* inc = incList.first();
2239 int i; 2239 int i;
2240 int count = 0; 2240 int count = 0;
2241 while ( inc ) { 2241 while ( inc ) {
2242 catIncList = inc->categories() ; 2242 catIncList = inc->categories() ;
2243 for( i = 0; i< catIncList.count(); ++i ) { 2243 for( i = 0; i< catIncList.count(); ++i ) {
2244 if ( !catList.contains (catIncList[i])) { 2244 if ( !catList.contains (catIncList[i])) {
2245 catList.append( catIncList[i] ); 2245 catList.append( catIncList[i] );
2246 //qDebug("add cat %s ", catIncList[i].latin1()); 2246 //qDebug("add cat %s ", catIncList[i].latin1());
2247 ++count; 2247 ++count;
2248 } 2248 }
2249 } 2249 }
2250 inc = incList.next(); 2250 inc = incList.next();
2251 } 2251 }
2252 catList.sort(); 2252 catList.sort();
2253 KOPrefs::instance()->mCustomCategories = catList; 2253 KOPrefs::instance()->mCustomCategories = catList;
2254 return count; 2254 return count;
2255} 2255}
2256 2256
2257void CalendarView::manageCategories() 2257void CalendarView::manageCategories()
2258{ 2258{
2259 KOCatPrefs* cp = new KOCatPrefs(); 2259 KOCatPrefs* cp = new KOCatPrefs();
2260 cp->show(); 2260 cp->show();
2261 int w =cp->sizeHint().width() ; 2261 int w =cp->sizeHint().width() ;
2262 int h = cp->sizeHint().height() ; 2262 int h = cp->sizeHint().height() ;
2263 int dw = QApplication::desktop()->width(); 2263 int dw = QApplication::desktop()->width();
2264 int dh = QApplication::desktop()->height(); 2264 int dh = QApplication::desktop()->height();
2265 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2265 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2266 if ( !cp->exec() ) { 2266 if ( !cp->exec() ) {
2267 delete cp; 2267 delete cp;
2268 return; 2268 return;
2269 } 2269 }
2270 int count = 0; 2270 int count = 0;
2271 if ( cp->addCat() ) { 2271 if ( cp->addCat() ) {
2272 count = addCategories(); 2272 count = addCategories();
2273 if ( count ) { 2273 if ( count ) {
2274 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2274 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2275 writeSettings(); 2275 writeSettings();
2276 } 2276 }
2277 } else { 2277 } else {
2278 removeCategories(); 2278 removeCategories();
2279 updateView(); 2279 updateView();
2280 } 2280 }
2281 delete cp; 2281 delete cp;
2282} 2282}
2283 2283
2284void CalendarView::beamIncidence(Incidence * Inc) 2284void CalendarView::beamIncidence(Incidence * Inc)
2285{ 2285{
2286 QPtrList<Incidence> delSel ; 2286 QPtrList<Incidence> delSel ;
2287 delSel.append(Inc); 2287 delSel.append(Inc);
2288 beamIncidenceList( delSel ); 2288 beamIncidenceList( delSel );
2289} 2289}
2290void CalendarView::beamCalendar() 2290void CalendarView::beamCalendar()
2291{ 2291{
2292 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2292 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2293 //qDebug("beamCalendar() "); 2293 //qDebug("beamCalendar() ");
2294 beamIncidenceList( delSel ); 2294 beamIncidenceList( delSel );
2295} 2295}
2296void CalendarView::beamFilteredCalendar() 2296void CalendarView::beamFilteredCalendar()
2297{ 2297{
2298 QPtrList<Incidence> delSel = mCalendar->incidences(); 2298 QPtrList<Incidence> delSel = mCalendar->incidences();
2299 //qDebug("beamFilteredCalendar() "); 2299 //qDebug("beamFilteredCalendar() ");
2300 beamIncidenceList( delSel ); 2300 beamIncidenceList( delSel );
2301} 2301}
2302void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2302void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2303{ 2303{
2304 if ( beamDialog->exec () == QDialog::Rejected ) 2304 if ( beamDialog->exec () == QDialog::Rejected )
2305 return; 2305 return;
2306 2306#ifdef DESKTOP_VERSION
2307 QString fn = locateLocal( "tmp", "kopibeamfile" );
2308#else
2307 QString fn = "/tmp/kopibeamfile"; 2309 QString fn = "/tmp/kopibeamfile";
2310#endif
2308 QString mes; 2311 QString mes;
2309 bool createbup = true; 2312 bool createbup = true;
2310 if ( createbup ) { 2313 if ( createbup ) {
2311 QString description = "\n"; 2314 QString description = "\n";
2312 CalendarLocal* cal = new CalendarLocal(); 2315 CalendarLocal* cal = new CalendarLocal();
2313 if ( beamDialog->beamLocal() ) 2316 if ( beamDialog->beamLocal() )
2314 cal->setLocalTime(); 2317 cal->setLocalTime();
2315 else 2318 else
2316 cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 2319 cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
2317 Incidence *incidence = delSel.first(); 2320 Incidence *incidence = delSel.first();
2318 bool addText = false; 2321 bool addText = false;
2319 if ( delSel.count() < 10 ) 2322 if ( delSel.count() < 10 )
2320 addText = true; 2323 addText = true;
2321 else { 2324 else {
2322 description.sprintf(i18n(" %d items?"),delSel.count() ); 2325 description.sprintf(i18n(" %d items?"),delSel.count() );
2323 } 2326 }
2324 while ( incidence ) { 2327 while ( incidence ) {
2325 Incidence *in = incidence->clone(); 2328 Incidence *in = incidence->clone();
2326 if ( ! in->summary().isEmpty() ) { 2329 if ( ! in->summary().isEmpty() ) {
2327 in->setDescription(""); 2330 in->setDescription("");
2328 } else { 2331 } else {
2329 in->setSummary( in->description().left(20)); 2332 in->setSummary( in->description().left(20));
2330 in->setDescription(""); 2333 in->setDescription("");
2331 } 2334 }
2332 if ( addText ) 2335 if ( addText )
2333 description += in->summary() + "\n"; 2336 description += in->summary() + "\n";
2334 cal->addIncidence( in ); 2337 cal->addIncidence( in );
2335 incidence = delSel.next(); 2338 incidence = delSel.next();
2336 } 2339 }
2337 if ( beamDialog->beamVcal() ) { 2340 if ( beamDialog->beamVcal() ) {
2338 fn += ".vcs"; 2341 fn += ".vcs";
2339 FileStorage storage( cal, fn, new VCalFormat ); 2342 FileStorage storage( cal, fn, new VCalFormat );
2340 storage.save(); 2343 storage.save();
2341 } else { 2344 } else {
2342 fn += ".ics"; 2345 fn += ".ics";
2343 FileStorage storage( cal, fn, new ICalFormat( ) ); 2346 FileStorage storage( cal, fn, new ICalFormat( ) );
2344 storage.save(); 2347 storage.save();
2345 } 2348 }
2346 delete cal; 2349 delete cal;
2347 mes = i18n("KO/Pi: Ready for beaming"); 2350 mes = i18n("KO/Pi: Ready for beaming");
2348 topLevelWidget()->setCaption(mes); 2351 topLevelWidget()->setCaption(mes);
2349 KApplication::convert2latin1( fn ); 2352 KApplication::convert2latin1( fn );
2350#ifndef DESKTOP_VERSION 2353#ifndef DESKTOP_VERSION
2351 Ir *ir = new Ir( this ); 2354 Ir *ir = new Ir( this );
2352 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 2355 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2353 ir->send( fn, description, "text/x-vCalendar" ); 2356 ir->send( fn, description, "text/x-vCalendar" );
2354#endif 2357#endif
2355 } 2358 }
2356} 2359}
2357void CalendarView::beamDone( Ir *ir ) 2360void CalendarView::beamDone( Ir *ir )
2358{ 2361{
2359#ifndef DESKTOP_VERSION 2362#ifndef DESKTOP_VERSION
2360 delete ir; 2363 delete ir;
2361#endif 2364#endif
2362 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); 2365 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") );
2363 topLevelWidget()->raise(); 2366 topLevelWidget()->raise();
2364} 2367}
2365 2368
2366void CalendarView::moveIncidence(Incidence * inc ) 2369void CalendarView::moveIncidence(Incidence * inc )
2367{ 2370{
2368 if ( !inc ) return; 2371 if ( !inc ) return;
2369 // qDebug("showDatePickerForIncidence( ) "); 2372 // qDebug("showDatePickerForIncidence( ) ");
2370 if ( mDateFrame->isVisible() ) 2373 if ( mDateFrame->isVisible() )
2371 mDateFrame->hide(); 2374 mDateFrame->hide();
2372 else { 2375 else {
2373 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; 2376 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ;
2374 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; 2377 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ;
2375 int dw = QApplication::desktop()->width(); 2378 int dw = QApplication::desktop()->width();
2376 int dh = QApplication::desktop()->height(); 2379 int dh = QApplication::desktop()->height();
2377 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2380 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2378 mDateFrame->show(); 2381 mDateFrame->show();
2379 } 2382 }
2380 mDatePickerMode = 2; 2383 mDatePickerMode = 2;
2381 mMoveIncidence = inc ; 2384 mMoveIncidence = inc ;
2382 QDate da; 2385 QDate da;
2383 if ( mMoveIncidence->type() == "Todo" ) { 2386 if ( mMoveIncidence->type() == "Todo" ) {
2384 Todo * to = (Todo *) mMoveIncidence; 2387 Todo * to = (Todo *) mMoveIncidence;
2385 if ( to->hasDueDate() ) 2388 if ( to->hasDueDate() )
2386 da = to->dtDue().date(); 2389 da = to->dtDue().date();
2387 else 2390 else
2388 da = QDate::currentDate(); 2391 da = QDate::currentDate();
2389 } else { 2392 } else {
2390 da = mMoveIncidence->dtStart().date(); 2393 da = mMoveIncidence->dtStart().date();
2391 } 2394 }
2392 mDatePicker->setDate( da ); 2395 mDatePicker->setDate( da );
2393} 2396}
2394void CalendarView::showDatePicker( ) 2397void CalendarView::showDatePicker( )
2395{ 2398{
2396 //qDebug("CalendarView::showDatePicker( ) "); 2399 //qDebug("CalendarView::showDatePicker( ) ");
2397 if ( mDateFrame->isVisible() ) 2400 if ( mDateFrame->isVisible() )
2398 mDateFrame->hide(); 2401 mDateFrame->hide();
2399 else { 2402 else {
2400 int w =mDatePicker->sizeHint().width() ; 2403 int w =mDatePicker->sizeHint().width() ;
2401 int h = mDatePicker->sizeHint().height() ; 2404 int h = mDatePicker->sizeHint().height() ;
2402 int dw = QApplication::desktop()->width(); 2405 int dw = QApplication::desktop()->width();
2403 int dh = QApplication::desktop()->height(); 2406 int dh = QApplication::desktop()->height();
2404 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2407 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2405 mDateFrame->show(); 2408 mDateFrame->show();
2406 } 2409 }
2407 mDatePickerMode = 1; 2410 mDatePickerMode = 1;
2408 mDatePicker->setDate( mNavigator->selectedDates().first() ); 2411 mDatePicker->setDate( mNavigator->selectedDates().first() );
2409} 2412}
2410 2413
2411void CalendarView::showEventEditor() 2414void CalendarView::showEventEditor()
2412{ 2415{
2413#ifdef DESKTOP_VERSION 2416#ifdef DESKTOP_VERSION
2414 mEventEditor->show(); 2417 mEventEditor->show();
2415#else 2418#else
2416 mEventEditor->showMaximized(); 2419 mEventEditor->showMaximized();
2417#endif 2420#endif
2418} 2421}
2419void CalendarView::showTodoEditor() 2422void CalendarView::showTodoEditor()
2420{ 2423{
2421#ifdef DESKTOP_VERSION 2424#ifdef DESKTOP_VERSION
2422 mTodoEditor->show(); 2425 mTodoEditor->show();
2423#else 2426#else
2424 mTodoEditor->showMaximized(); 2427 mTodoEditor->showMaximized();
2425#endif 2428#endif
2426} 2429}
2427 2430
2428void CalendarView::cloneIncidence() 2431void CalendarView::cloneIncidence()
2429{ 2432{
2430 Incidence *incidence = currentSelection(); 2433 Incidence *incidence = currentSelection();
2431 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2434 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2432 if ( incidence ) { 2435 if ( incidence ) {
2433 cloneIncidence(incidence); 2436 cloneIncidence(incidence);
2434 } 2437 }
2435} 2438}
2436void CalendarView::moveIncidence() 2439void CalendarView::moveIncidence()
2437{ 2440{
2438 Incidence *incidence = currentSelection(); 2441 Incidence *incidence = currentSelection();
2439 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2442 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2440 if ( incidence ) { 2443 if ( incidence ) {
2441 moveIncidence(incidence); 2444 moveIncidence(incidence);
2442 } 2445 }
2443} 2446}
2444void CalendarView::beamIncidence() 2447void CalendarView::beamIncidence()
2445{ 2448{
2446 Incidence *incidence = currentSelection(); 2449 Incidence *incidence = currentSelection();
2447 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2450 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2448 if ( incidence ) { 2451 if ( incidence ) {
2449 beamIncidence(incidence); 2452 beamIncidence(incidence);
2450 } 2453 }
2451} 2454}
2452void CalendarView::toggleCancelIncidence() 2455void CalendarView::toggleCancelIncidence()
2453{ 2456{
2454 Incidence *incidence = currentSelection(); 2457 Incidence *incidence = currentSelection();
2455 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2458 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2456 if ( incidence ) { 2459 if ( incidence ) {
2457 cancelIncidence(incidence); 2460 cancelIncidence(incidence);
2458 } 2461 }
2459} 2462}
2460 2463
2461 2464
2462void CalendarView::cancelIncidence(Incidence * inc ) 2465void CalendarView::cancelIncidence(Incidence * inc )
2463{ 2466{
2464 inc->setCancelled( ! inc->cancelled() ); 2467 inc->setCancelled( ! inc->cancelled() );
2465 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 2468 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
2466 updateView(); 2469 updateView();
2467} 2470}
2468void CalendarView::cloneIncidence(Incidence * orgInc ) 2471void CalendarView::cloneIncidence(Incidence * orgInc )
2469{ 2472{
2470 Incidence * newInc = orgInc->clone(); 2473 Incidence * newInc = orgInc->clone();
2471 newInc->recreate(); 2474 newInc->recreate();
2472 2475
2473 if ( newInc->type() == "Todo" ) { 2476 if ( newInc->type() == "Todo" ) {
2474 Todo* t = (Todo*) newInc; 2477 Todo* t = (Todo*) newInc;
2475 mTodoEditor->editTodo( t ); 2478 mTodoEditor->editTodo( t );
2476 showTodoEditor(); 2479 showTodoEditor();
2477 if ( mTodoEditor->exec() ) { 2480 if ( mTodoEditor->exec() ) {
2478 mCalendar->addTodo( t ); 2481 mCalendar->addTodo( t );
2479 updateView(); 2482 updateView();
2480 } else { 2483 } else {
2481 delete t; 2484 delete t;
2482 } 2485 }
2483 } 2486 }
2484 else { 2487 else {
2485 Event* e = (Event*) newInc; 2488 Event* e = (Event*) newInc;
2486 mEventEditor->editEvent( e ); 2489 mEventEditor->editEvent( e );
2487 showEventEditor(); 2490 showEventEditor();
2488 if ( mEventEditor->exec() ) { 2491 if ( mEventEditor->exec() ) {
2489 mCalendar->addEvent( e ); 2492 mCalendar->addEvent( e );
2490 updateView(); 2493 updateView();
2491 } else { 2494 } else {
2492 delete e; 2495 delete e;
2493 } 2496 }
2494 } 2497 }
2495} 2498}
2496 2499
2497void CalendarView::newEvent() 2500void CalendarView::newEvent()
2498{ 2501{
2499 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 2502 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
2500 KOAgendaView *aView = mViewManager->agendaView(); 2503 KOAgendaView *aView = mViewManager->agendaView();
2501 if (aView) { 2504 if (aView) {
2502 if (aView->selectionStart().isValid()) { 2505 if (aView->selectionStart().isValid()) {
2503 if (aView->selectedIsAllDay()) { 2506 if (aView->selectedIsAllDay()) {
2504 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 2507 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
2505 } else { 2508 } else {
2506 newEvent(aView->selectionStart(),aView->selectionEnd()); 2509 newEvent(aView->selectionStart(),aView->selectionEnd());
2507 } 2510 }
2508 return; 2511 return;
2509 } 2512 }
2510 } 2513 }
2511 2514
2512 QDate date = mNavigator->selectedDates().first(); 2515 QDate date = mNavigator->selectedDates().first();
2513 QDateTime current = QDateTime::currentDateTime(); 2516 QDateTime current = QDateTime::currentDateTime();
2514 if ( date <= current.date() ) { 2517 if ( date <= current.date() ) {
2515 int hour = current.time().hour() +1; 2518 int hour = current.time().hour() +1;
2516 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 2519 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
2517 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2520 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2518 } else 2521 } else
2519 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 2522 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
2520 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 2523 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
2521 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2524 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2522} 2525}
2523 2526
2524void CalendarView::newEvent(QDateTime fh) 2527void CalendarView::newEvent(QDateTime fh)
2525{ 2528{
2526 newEvent(fh, 2529 newEvent(fh,
2527 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 2530 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
2528} 2531}
2529 2532
2530void CalendarView::newEvent(QDate dt) 2533void CalendarView::newEvent(QDate dt)
2531{ 2534{
2532 newEvent(QDateTime(dt, QTime(0,0,0)), 2535 newEvent(QDateTime(dt, QTime(0,0,0)),
2533 QDateTime(dt, QTime(0,0,0)), true); 2536 QDateTime(dt, QTime(0,0,0)), true);
2534} 2537}
2535 2538
2536void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 2539void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
2537{ 2540{
2538 2541
2539 mEventEditor->newEvent(fromHint,toHint,allDay); 2542 mEventEditor->newEvent(fromHint,toHint,allDay);
2540 if ( mFilterView->filtersEnabled() ) { 2543 if ( mFilterView->filtersEnabled() ) {
2541 CalFilter *filter = mFilterView->selectedFilter(); 2544 CalFilter *filter = mFilterView->selectedFilter();
2542 if (filter && filter->showCategories()) { 2545 if (filter && filter->showCategories()) {
2543 mEventEditor->setCategories(filter->categoryList().join(",") ); 2546 mEventEditor->setCategories(filter->categoryList().join(",") );
2544 } 2547 }
2545 if ( filter ) 2548 if ( filter )
2546 mEventEditor->setSecrecy( filter->getSecrecy() ); 2549 mEventEditor->setSecrecy( filter->getSecrecy() );
2547 } 2550 }
2548 showEventEditor(); 2551 showEventEditor();
2549} 2552}
2550void CalendarView::todoAdded(Todo * t) 2553void CalendarView::todoAdded(Todo * t)
2551{ 2554{
2552 2555
2553 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 2556 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
2554 updateTodoViews(); 2557 updateTodoViews();
2555} 2558}
2556void CalendarView::todoChanged(Todo * t) 2559void CalendarView::todoChanged(Todo * t)
2557{ 2560{
2558 emit todoModified( t, 4 ); 2561 emit todoModified( t, 4 );
2559 // updateTodoViews(); 2562 // updateTodoViews();
2560} 2563}
2561void CalendarView::todoToBeDeleted(Todo *) 2564void CalendarView::todoToBeDeleted(Todo *)
2562{ 2565{
2563 //qDebug("todoToBeDeleted(Todo *) "); 2566 //qDebug("todoToBeDeleted(Todo *) ");
2564 updateTodoViews(); 2567 updateTodoViews();
2565} 2568}
2566void CalendarView::todoDeleted() 2569void CalendarView::todoDeleted()
2567{ 2570{
2568 //qDebug(" todoDeleted()"); 2571 //qDebug(" todoDeleted()");
2569 updateTodoViews(); 2572 updateTodoViews();
2570} 2573}
2571 2574
2572 2575
2573 2576
2574void CalendarView::newTodo() 2577void CalendarView::newTodo()
2575{ 2578{
2576 2579
2577 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); 2580 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true);
2578 if ( mFilterView->filtersEnabled() ) { 2581 if ( mFilterView->filtersEnabled() ) {
2579 CalFilter *filter = mFilterView->selectedFilter(); 2582 CalFilter *filter = mFilterView->selectedFilter();
2580 if (filter && filter->showCategories()) { 2583 if (filter && filter->showCategories()) {
2581 mTodoEditor->setCategories(filter->categoryList().join(",") ); 2584 mTodoEditor->setCategories(filter->categoryList().join(",") );
2582 } 2585 }
2583 if ( filter ) 2586 if ( filter )
2584 mTodoEditor->setSecrecy( filter->getSecrecy() ); 2587 mTodoEditor->setSecrecy( filter->getSecrecy() );
2585 } 2588 }
2586 showTodoEditor(); 2589 showTodoEditor();
2587} 2590}
2588 2591
2589void CalendarView::newSubTodo() 2592void CalendarView::newSubTodo()
2590{ 2593{
2591 Todo *todo = selectedTodo(); 2594 Todo *todo = selectedTodo();
2592 if ( todo ) newSubTodo( todo ); 2595 if ( todo ) newSubTodo( todo );
2593} 2596}
2594 2597
2595void CalendarView::newSubTodo(Todo *parentEvent) 2598void CalendarView::newSubTodo(Todo *parentEvent)
2596{ 2599{
2597 2600
2598 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); 2601 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true);
2599 showTodoEditor(); 2602 showTodoEditor();
2600} 2603}
2601 2604
2602void CalendarView::newFloatingEvent() 2605void CalendarView::newFloatingEvent()
2603{ 2606{
2604 DateList tmpList = mNavigator->selectedDates(); 2607 DateList tmpList = mNavigator->selectedDates();
2605 QDate date = tmpList.first(); 2608 QDate date = tmpList.first();
2606 2609
2607 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 2610 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
2608 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 2611 QDateTime( date, QTime( 12, 0, 0 ) ), true );
2609} 2612}
2610 2613
2611 2614
2612void CalendarView::editEvent( Event *event ) 2615void CalendarView::editEvent( Event *event )
2613{ 2616{
2614 2617
2615 if ( !event ) return; 2618 if ( !event ) return;
2616 if ( event->isReadOnly() ) { 2619 if ( event->isReadOnly() ) {
2617 showEvent( event ); 2620 showEvent( event );
2618 return; 2621 return;
2619 } 2622 }
2620 mEventEditor->editEvent( event , mFlagEditDescription); 2623 mEventEditor->editEvent( event , mFlagEditDescription);
2621 showEventEditor(); 2624 showEventEditor();
2622} 2625}
2623void CalendarView::editJournal( Journal *jour ) 2626void CalendarView::editJournal( Journal *jour )
2624{ 2627{
2625 if ( !jour ) return; 2628 if ( !jour ) return;
2626 mDialogManager->hideSearchDialog(); 2629 mDialogManager->hideSearchDialog();
2627 mViewManager->showJournalView(); 2630 mViewManager->showJournalView();
2628 mNavigator->slotDaySelect( jour->dtStart().date() ); 2631 mNavigator->slotDaySelect( jour->dtStart().date() );
2629} 2632}
2630void CalendarView::editTodo( Todo *todo ) 2633void CalendarView::editTodo( Todo *todo )
2631{ 2634{
2632 if ( !todo ) return; 2635 if ( !todo ) return;
2633 2636
2634 if ( todo->isReadOnly() ) { 2637 if ( todo->isReadOnly() ) {
2635 showTodo( todo ); 2638 showTodo( todo );
2636 return; 2639 return;
2637 } 2640 }
2638 mTodoEditor->editTodo( todo ,mFlagEditDescription); 2641 mTodoEditor->editTodo( todo ,mFlagEditDescription);
2639 showTodoEditor(); 2642 showTodoEditor();
2640 2643
2641} 2644}
2642 2645
2643KOEventViewerDialog* CalendarView::getEventViewerDialog() 2646KOEventViewerDialog* CalendarView::getEventViewerDialog()
2644{ 2647{
2645 if ( !mEventViewerDialog ) { 2648 if ( !mEventViewerDialog ) {
2646 mEventViewerDialog = new KOEventViewerDialog(this); 2649 mEventViewerDialog = new KOEventViewerDialog(this);
2647 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 2650 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
2648 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 2651 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
2649 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 2652 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
2650 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 2653 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
2651 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 2654 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
2652 viewManager(), SLOT( showAgendaView( bool ) ) ); 2655 viewManager(), SLOT( showAgendaView( bool ) ) );
2653 mEventViewerDialog->resize( 640, 480 ); 2656 mEventViewerDialog->resize( 640, 480 );
2654 2657
2655 } 2658 }
2656 return mEventViewerDialog; 2659 return mEventViewerDialog;
2657} 2660}
2658void CalendarView::showEvent(Event *event) 2661void CalendarView::showEvent(Event *event)
2659{ 2662{
2660 getEventViewerDialog()->setEvent(event); 2663 getEventViewerDialog()->setEvent(event);
2661 getEventViewerDialog()->showMe(); 2664 getEventViewerDialog()->showMe();
2662} 2665}
2663 2666
2664void CalendarView::showTodo(Todo *event) 2667void CalendarView::showTodo(Todo *event)
2665{ 2668{
2666 getEventViewerDialog()->setTodo(event); 2669 getEventViewerDialog()->setTodo(event);
2667 getEventViewerDialog()->showMe(); 2670 getEventViewerDialog()->showMe();
2668} 2671}
2669void CalendarView::showJournal( Journal *jour ) 2672void CalendarView::showJournal( Journal *jour )
2670{ 2673{
2671 getEventViewerDialog()->setJournal(jour); 2674 getEventViewerDialog()->setJournal(jour);
2672 getEventViewerDialog()->showMe(); 2675 getEventViewerDialog()->showMe();
2673 2676
2674} 2677}
2675// void CalendarView::todoModified (Todo *event, int changed) 2678// void CalendarView::todoModified (Todo *event, int changed)
2676// { 2679// {
2677// // if (mDialogList.find (event) != mDialogList.end ()) { 2680// // if (mDialogList.find (event) != mDialogList.end ()) {
2678// // kdDebug() << "Todo modified and open" << endl; 2681// // kdDebug() << "Todo modified and open" << endl;
2679// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 2682// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
2680// // temp->modified (changed); 2683// // temp->modified (changed);
2681 2684
2682// // } 2685// // }
2683 2686
2684// mViewManager->updateView(); 2687// mViewManager->updateView();
2685// } 2688// }
2686 2689
2687void CalendarView::appointment_show() 2690void CalendarView::appointment_show()
2688{ 2691{
2689 Event *anEvent = 0; 2692 Event *anEvent = 0;
2690 2693
2691 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2694 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2692 2695
2693 if (mViewManager->currentView()->isEventView()) { 2696 if (mViewManager->currentView()->isEventView()) {
2694 if ( incidence && incidence->type() == "Event" ) { 2697 if ( incidence && incidence->type() == "Event" ) {
2695 anEvent = static_cast<Event *>(incidence); 2698 anEvent = static_cast<Event *>(incidence);
2696 } 2699 }
2697 } 2700 }
2698 2701
2699 if (!anEvent) { 2702 if (!anEvent) {
2700 KNotifyClient::beep(); 2703 KNotifyClient::beep();
2701 return; 2704 return;
2702 } 2705 }
2703 2706
2704 showEvent(anEvent); 2707 showEvent(anEvent);
2705} 2708}
2706 2709
2707void CalendarView::appointment_edit() 2710void CalendarView::appointment_edit()
2708{ 2711{
2709 Event *anEvent = 0; 2712 Event *anEvent = 0;
2710 2713
2711 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2714 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2712 2715
2713 if (mViewManager->currentView()->isEventView()) { 2716 if (mViewManager->currentView()->isEventView()) {
2714 if ( incidence && incidence->type() == "Event" ) { 2717 if ( incidence && incidence->type() == "Event" ) {
2715 anEvent = static_cast<Event *>(incidence); 2718 anEvent = static_cast<Event *>(incidence);
2716 } 2719 }
2717 } 2720 }
2718 2721
2719 if (!anEvent) { 2722 if (!anEvent) {
2720 KNotifyClient::beep(); 2723 KNotifyClient::beep();
2721 return; 2724 return;
2722 } 2725 }
2723 2726
2724 editEvent(anEvent); 2727 editEvent(anEvent);
2725} 2728}
2726 2729
2727void CalendarView::appointment_delete() 2730void CalendarView::appointment_delete()
2728{ 2731{
2729 Event *anEvent = 0; 2732 Event *anEvent = 0;
2730 2733
2731 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2734 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2732 2735
2733 if (mViewManager->currentView()->isEventView()) { 2736 if (mViewManager->currentView()->isEventView()) {
2734 if ( incidence && incidence->type() == "Event" ) { 2737 if ( incidence && incidence->type() == "Event" ) {
2735 anEvent = static_cast<Event *>(incidence); 2738 anEvent = static_cast<Event *>(incidence);
2736 } 2739 }
2737 } 2740 }
2738 2741
2739 if (!anEvent) { 2742 if (!anEvent) {
2740 KNotifyClient::beep(); 2743 KNotifyClient::beep();
2741 return; 2744 return;
2742 } 2745 }
2743 2746
2744 deleteEvent(anEvent); 2747 deleteEvent(anEvent);
2745} 2748}
2746 2749
2747void CalendarView::todo_resub( Todo * parent, Todo * sub ) 2750void CalendarView::todo_resub( Todo * parent, Todo * sub )
2748{ 2751{
2749 if (!sub) return; 2752 if (!sub) return;
2750 if (!parent) return; 2753 if (!parent) return;
2751 if ( sub->relatedTo() ) 2754 if ( sub->relatedTo() )
2752 sub->relatedTo()->removeRelation(sub); 2755 sub->relatedTo()->removeRelation(sub);
2753 sub->setRelatedTo(parent); 2756 sub->setRelatedTo(parent);
2754 sub->setRelatedToUid(parent->uid()); 2757 sub->setRelatedToUid(parent->uid());
2755 parent->addRelation(sub); 2758 parent->addRelation(sub);
2756 sub->updated(); 2759 sub->updated();
2757 parent->updated(); 2760 parent->updated();
2758 setModified(true); 2761 setModified(true);
2759 updateView(); 2762 updateView();
2760} 2763}
2761void CalendarView::todo_unsub(Todo *anTodo ) 2764void CalendarView::todo_unsub(Todo *anTodo )
2762{ 2765{
2763 // Todo *anTodo = selectedTodo(); 2766 // Todo *anTodo = selectedTodo();
2764 if (!anTodo) return; 2767 if (!anTodo) return;
2765 if (!anTodo->relatedTo()) return; 2768 if (!anTodo->relatedTo()) return;
2766 anTodo->relatedTo()->removeRelation(anTodo); 2769 anTodo->relatedTo()->removeRelation(anTodo);
2767 anTodo->setRelatedTo(0); 2770 anTodo->setRelatedTo(0);
2768 anTodo->updated(); 2771 anTodo->updated();
2769 anTodo->setRelatedToUid(""); 2772 anTodo->setRelatedToUid("");
2770 setModified(true); 2773 setModified(true);
2771 updateView(); 2774 updateView();
2772} 2775}
2773 2776
2774void CalendarView::deleteTodo(Todo *todo) 2777void CalendarView::deleteTodo(Todo *todo)
2775{ 2778{
2776 if (!todo) { 2779 if (!todo) {
2777 KNotifyClient::beep(); 2780 KNotifyClient::beep();
2778 return; 2781 return;
2779 } 2782 }
2780 if (KOPrefs::instance()->mConfirm) { 2783 if (KOPrefs::instance()->mConfirm) {
2781 switch (msgItemDelete()) { 2784 switch (msgItemDelete()) {
2782 case KMessageBox::Continue: // OK 2785 case KMessageBox::Continue: // OK
2783 if (!todo->relations().isEmpty()) { 2786 if (!todo->relations().isEmpty()) {
2784 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), 2787 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."),
2785 i18n("Delete To-Do")); 2788 i18n("Delete To-Do"));
2786 } else { 2789 } else {
2787 checkExternalId( todo ); 2790 checkExternalId( todo );
2788 calendar()->deleteTodo(todo); 2791 calendar()->deleteTodo(todo);
2789 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2792 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2790 updateView(); 2793 updateView();
2791 } 2794 }
2792 break; 2795 break;
2793 } // switch 2796 } // switch
2794 } else { 2797 } else {
2795 if (!todo->relations().isEmpty()) { 2798 if (!todo->relations().isEmpty()) {
2796 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), 2799 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."),
2797 i18n("Delete To-Do")); 2800 i18n("Delete To-Do"));
2798 } else { 2801 } else {
2799 checkExternalId( todo ); 2802 checkExternalId( todo );
2800 mCalendar->deleteTodo(todo); 2803 mCalendar->deleteTodo(todo);
2801 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2804 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2802 updateView(); 2805 updateView();
2803 } 2806 }
2804 } 2807 }
2805 emit updateSearchDialog(); 2808 emit updateSearchDialog();
2806} 2809}
2807void CalendarView::deleteJournal(Journal *jour) 2810void CalendarView::deleteJournal(Journal *jour)
2808{ 2811{
2809 if (!jour) { 2812 if (!jour) {
2810 KNotifyClient::beep(); 2813 KNotifyClient::beep();
2811 return; 2814 return;
2812 } 2815 }
2813 if (KOPrefs::instance()->mConfirm) { 2816 if (KOPrefs::instance()->mConfirm) {
2814 switch (msgItemDelete()) { 2817 switch (msgItemDelete()) {
2815 case KMessageBox::Continue: // OK 2818 case KMessageBox::Continue: // OK
2816 calendar()->deleteJournal(jour); 2819 calendar()->deleteJournal(jour);
2817 updateView(); 2820 updateView();
2818 break; 2821 break;
2819 } // switch 2822 } // switch
2820 } else { 2823 } else {
2821 calendar()->deleteJournal(jour);; 2824 calendar()->deleteJournal(jour);;
2822 updateView(); 2825 updateView();
2823 } 2826 }
2824 emit updateSearchDialog(); 2827 emit updateSearchDialog();
2825} 2828}
2826 2829
2827void CalendarView::deleteEvent(Event *anEvent) 2830void CalendarView::deleteEvent(Event *anEvent)
2828{ 2831{
2829 if (!anEvent) { 2832 if (!anEvent) {
2830 KNotifyClient::beep(); 2833 KNotifyClient::beep();
2831 return; 2834 return;
2832 } 2835 }
2833 2836
2834 if (anEvent->recurrence()->doesRecur()) { 2837 if (anEvent->recurrence()->doesRecur()) {
2835 QDate itemDate = mViewManager->currentSelectionDate(); 2838 QDate itemDate = mViewManager->currentSelectionDate();
2836 int km; 2839 int km;
2837 if (!itemDate.isValid()) { 2840 if (!itemDate.isValid()) {
2838 //kdDebug() << "Date Not Valid" << endl; 2841 //kdDebug() << "Date Not Valid" << endl;
2839 if (KOPrefs::instance()->mConfirm) { 2842 if (KOPrefs::instance()->mConfirm) {
2840 km = KMessageBox::warningContinueCancel(this,anEvent->summary() + 2843 km = KMessageBox::warningContinueCancel(this,anEvent->summary() +
2841 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), 2844 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"),
2842 i18n("KO/Pi Confirmation"),i18n("Delete All")); 2845 i18n("KO/Pi Confirmation"),i18n("Delete All"));
2843 if ( km == KMessageBox::Continue ) 2846 if ( km == KMessageBox::Continue )
2844 km = KMessageBox::No; // No = all below 2847 km = KMessageBox::No; // No = all below
2845 } else 2848 } else
2846 km = KMessageBox::No; 2849 km = KMessageBox::No;
2847 } else { 2850 } else {
2848 km = KMessageBox::warningYesNoCancel(this,anEvent->summary() + 2851 km = KMessageBox::warningYesNoCancel(this,anEvent->summary() +
2849 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ 2852 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+
2850 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), 2853 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"),
2851 i18n("KO/Pi Confirmation"),i18n("Current"), 2854 i18n("KO/Pi Confirmation"),i18n("Current"),
2852 i18n("All")); 2855 i18n("All"));
2853 } 2856 }
2854 switch(km) { 2857 switch(km) {
2855 2858
2856 case KMessageBox::No: // Continue // all 2859 case KMessageBox::No: // Continue // all
2857 //qDebug("KMessageBox::No "); 2860 //qDebug("KMessageBox::No ");
2858 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2861 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2859 schedule(Scheduler::Cancel,anEvent); 2862 schedule(Scheduler::Cancel,anEvent);
2860 2863
2861 checkExternalId( anEvent); 2864 checkExternalId( anEvent);
2862 mCalendar->deleteEvent(anEvent); 2865 mCalendar->deleteEvent(anEvent);
2863 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); 2866 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED);
2864 break; 2867 break;
2865 2868
2866 // Disabled because it does not work 2869 // Disabled because it does not work
2867 //#if 0 2870 //#if 0
2868 case KMessageBox::Yes: // just this one 2871 case KMessageBox::Yes: // just this one
2869 //QDate qd = mNavigator->selectedDates().first(); 2872 //QDate qd = mNavigator->selectedDates().first();
2870 //if (!qd.isValid()) { 2873 //if (!qd.isValid()) {
2871 // kdDebug() << "no date selected, or invalid date" << endl; 2874 // kdDebug() << "no date selected, or invalid date" << endl;
2872 // KNotifyClient::beep(); 2875 // KNotifyClient::beep();
2873 // return; 2876 // return;
2874 //} 2877 //}
2875 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); 2878 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1);
2876 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { 2879 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) {
2877 anEvent->addExDate(itemDate); 2880 anEvent->addExDate(itemDate);
2878 int duration = anEvent->recurrence()->duration(); 2881 int duration = anEvent->recurrence()->duration();
2879 if ( duration > 0 ) { 2882 if ( duration > 0 ) {
2880 anEvent->recurrence()->setDuration( duration - 1 ); 2883 anEvent->recurrence()->setDuration( duration - 1 );
2881 } 2884 }
2882 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); 2885 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED);
2883 } 2886 }
2884 break; 2887 break;
2885 //#endif 2888 //#endif
2886 } // switch 2889 } // switch
2887 } else { 2890 } else {
2888 if (KOPrefs::instance()->mConfirm) { 2891 if (KOPrefs::instance()->mConfirm) {
2889 switch (KMessageBox::warningContinueCancel(this,anEvent->summary() + 2892 switch (KMessageBox::warningContinueCancel(this,anEvent->summary() +
2890 i18n("\nAre you sure you want\nto delete this event?"), 2893 i18n("\nAre you sure you want\nto delete this event?"),
2891 i18n("KO/Pi Confirmation"),i18n("Delete"))) { 2894 i18n("KO/Pi Confirmation"),i18n("Delete"))) {
2892 case KMessageBox::Continue: // OK 2895 case KMessageBox::Continue: // OK
2893 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2896 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2894 schedule(Scheduler::Cancel,anEvent); 2897 schedule(Scheduler::Cancel,anEvent);
2895 checkExternalId( anEvent); 2898 checkExternalId( anEvent);
2896 mCalendar->deleteEvent(anEvent); 2899 mCalendar->deleteEvent(anEvent);
2897 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2900 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2898 break; 2901 break;
2899 } // switch 2902 } // switch
2900 } else { 2903 } else {
2901 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2904 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2902 schedule(Scheduler::Cancel,anEvent); 2905 schedule(Scheduler::Cancel,anEvent);
2903 checkExternalId( anEvent); 2906 checkExternalId( anEvent);
2904 mCalendar->deleteEvent(anEvent); 2907 mCalendar->deleteEvent(anEvent);
2905 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2908 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2906 } 2909 }
2907 } // if-else 2910 } // if-else
2908 emit updateSearchDialog(); 2911 emit updateSearchDialog();
2909} 2912}
2910 2913
2911bool CalendarView::deleteEvent(const QString &uid) 2914bool CalendarView::deleteEvent(const QString &uid)
2912{ 2915{
2913 Event *ev = mCalendar->event(uid); 2916 Event *ev = mCalendar->event(uid);
2914 if (ev) { 2917 if (ev) {
2915 deleteEvent(ev); 2918 deleteEvent(ev);
2916 return true; 2919 return true;
2917 } else { 2920 } else {
2918 return false; 2921 return false;
2919 } 2922 }
2920} 2923}
2921 2924
2922/*****************************************************************************/ 2925/*****************************************************************************/
2923 2926
2924void CalendarView::action_mail() 2927void CalendarView::action_mail()
2925{ 2928{
2926#ifndef KORG_NOMAIL 2929#ifndef KORG_NOMAIL
2927 KOMailClient mailClient; 2930 KOMailClient mailClient;
2928 2931
2929 Incidence *incidence = currentSelection(); 2932 Incidence *incidence = currentSelection();
2930 2933
2931 if (!incidence) { 2934 if (!incidence) {
2932 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 2935 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
2933 return; 2936 return;
2934 } 2937 }
2935 if(incidence->attendeeCount() == 0 ) { 2938 if(incidence->attendeeCount() == 0 ) {
2936 KMessageBox::sorry(this, 2939 KMessageBox::sorry(this,
2937 i18n("Can't generate mail:\nNo attendees defined.\n")); 2940 i18n("Can't generate mail:\nNo attendees defined.\n"));
2938 return; 2941 return;
2939 } 2942 }
2940 2943
2941 CalendarLocal cal_tmp; 2944 CalendarLocal cal_tmp;
2942 Event *event = 0; 2945 Event *event = 0;
2943 Event *ev = 0; 2946 Event *ev = 0;
2944 if ( incidence && incidence->type() == "Event" ) { 2947 if ( incidence && incidence->type() == "Event" ) {
2945 event = static_cast<Event *>(incidence); 2948 event = static_cast<Event *>(incidence);
2946 ev = new Event(*event); 2949 ev = new Event(*event);
2947 cal_tmp.addEvent(ev); 2950 cal_tmp.addEvent(ev);
2948 } 2951 }
2949 ICalFormat mForm(); 2952 ICalFormat mForm();
2950 QString attachment = mForm.toString( &cal_tmp ); 2953 QString attachment = mForm.toString( &cal_tmp );
2951 if (ev) delete(ev); 2954 if (ev) delete(ev);
2952 2955
2953 mailClient.mailAttendees(currentSelection(), attachment); 2956 mailClient.mailAttendees(currentSelection(), attachment);
2954 2957
2955#endif 2958#endif
2956 2959
2957#if 0 2960#if 0
2958 Event *anEvent = 0; 2961 Event *anEvent = 0;
2959 if (mViewManager->currentView()->isEventView()) { 2962 if (mViewManager->currentView()->isEventView()) {
2960 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); 2963 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first());
2961 } 2964 }
2962 2965
2963 if (!anEvent) { 2966 if (!anEvent) {
2964 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 2967 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
2965 return; 2968 return;
2966 } 2969 }
2967 if(anEvent->attendeeCount() == 0 ) { 2970 if(anEvent->attendeeCount() == 0 ) {
2968 KMessageBox::sorry(this, 2971 KMessageBox::sorry(this,
2969 i18n("Can't generate mail:\nNo attendees defined.\n")); 2972 i18n("Can't generate mail:\nNo attendees defined.\n"));
2970 return; 2973 return;
2971 } 2974 }
2972 2975
2973 mailobject.emailEvent(anEvent); 2976 mailobject.emailEvent(anEvent);
2974#endif 2977#endif
2975} 2978}
2976 2979
2977 2980
2978void CalendarView::schedule_publish(Incidence *incidence) 2981void CalendarView::schedule_publish(Incidence *incidence)
2979{ 2982{
2980 Event *event = 0; 2983 Event *event = 0;
2981 Todo *todo = 0; 2984 Todo *todo = 0;
2982 2985
2983 if (incidence == 0) { 2986 if (incidence == 0) {
2984 incidence = mViewManager->currentView()->selectedIncidences().first(); 2987 incidence = mViewManager->currentView()->selectedIncidences().first();
2985 if (incidence == 0) { 2988 if (incidence == 0) {
2986 incidence = mTodoList->selectedIncidences().first(); 2989 incidence = mTodoList->selectedIncidences().first();
2987 } 2990 }
2988 } 2991 }
2989 if ( incidence && incidence->type() == "Event" ) { 2992 if ( incidence && incidence->type() == "Event" ) {
2990 event = static_cast<Event *>(incidence); 2993 event = static_cast<Event *>(incidence);
2991 } else { 2994 } else {
2992 if ( incidence && incidence->type() == "Todo" ) { 2995 if ( incidence && incidence->type() == "Todo" ) {
2993 todo = static_cast<Todo *>(incidence); 2996 todo = static_cast<Todo *>(incidence);
2994 } 2997 }
2995 } 2998 }
2996 2999
2997 if (!event && !todo) { 3000 if (!event && !todo) {
2998 KMessageBox::sorry(this,i18n("No event selected.")); 3001 KMessageBox::sorry(this,i18n("No event selected."));
2999 return; 3002 return;
3000 } 3003 }
3001 3004
3002 PublishDialog *publishdlg = new PublishDialog(); 3005 PublishDialog *publishdlg = new PublishDialog();
3003 if (incidence->attendeeCount()>0) { 3006 if (incidence->attendeeCount()>0) {
3004 QPtrList<Attendee> attendees = incidence->attendees(); 3007 QPtrList<Attendee> attendees = incidence->attendees();
3005 attendees.first(); 3008 attendees.first();
3006 while ( attendees.current()!=0 ) { 3009 while ( attendees.current()!=0 ) {
3007 publishdlg->addAttendee(attendees.current()); 3010 publishdlg->addAttendee(attendees.current());
3008 attendees.next(); 3011 attendees.next();
3009 } 3012 }
3010 } 3013 }
3011 bool send = true; 3014 bool send = true;
3012 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { 3015 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) {
3013 if ( publishdlg->exec() != QDialog::Accepted ) 3016 if ( publishdlg->exec() != QDialog::Accepted )
3014 send = false; 3017 send = false;
3015 } 3018 }
3016 if ( send ) { 3019 if ( send ) {
3017 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3020 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3018 if ( event ) { 3021 if ( event ) {
3019 Event *ev = new Event(*event); 3022 Event *ev = new Event(*event);
3020 ev->registerObserver(0); 3023 ev->registerObserver(0);
3021 ev->clearAttendees(); 3024 ev->clearAttendees();
3022 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3025 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3023 delete(ev); 3026 delete(ev);
3024 } 3027 }
3025 } else { 3028 } else {
3026 if ( todo ) { 3029 if ( todo ) {
3027 Todo *ev = new Todo(*todo); 3030 Todo *ev = new Todo(*todo);
3028 ev->registerObserver(0); 3031 ev->registerObserver(0);
3029 ev->clearAttendees(); 3032 ev->clearAttendees();
3030 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3033 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3031 delete(ev); 3034 delete(ev);
3032 } 3035 }
3033 } 3036 }
3034 } 3037 }
3035 } 3038 }
3036 delete publishdlg; 3039 delete publishdlg;
3037} 3040}
3038 3041
3039void CalendarView::schedule_request(Incidence *incidence) 3042void CalendarView::schedule_request(Incidence *incidence)
3040{ 3043{
3041 schedule(Scheduler::Request,incidence); 3044 schedule(Scheduler::Request,incidence);
3042} 3045}
3043 3046
3044void CalendarView::schedule_refresh(Incidence *incidence) 3047void CalendarView::schedule_refresh(Incidence *incidence)
3045{ 3048{
3046 schedule(Scheduler::Refresh,incidence); 3049 schedule(Scheduler::Refresh,incidence);
3047} 3050}
3048 3051
3049void CalendarView::schedule_cancel(Incidence *incidence) 3052void CalendarView::schedule_cancel(Incidence *incidence)
3050{ 3053{
3051 schedule(Scheduler::Cancel,incidence); 3054 schedule(Scheduler::Cancel,incidence);
3052} 3055}
3053 3056
3054void CalendarView::schedule_add(Incidence *incidence) 3057void CalendarView::schedule_add(Incidence *incidence)
3055{ 3058{
3056 schedule(Scheduler::Add,incidence); 3059 schedule(Scheduler::Add,incidence);
3057} 3060}
3058 3061
3059void CalendarView::schedule_reply(Incidence *incidence) 3062void CalendarView::schedule_reply(Incidence *incidence)
3060{ 3063{
3061 schedule(Scheduler::Reply,incidence); 3064 schedule(Scheduler::Reply,incidence);
3062} 3065}
3063 3066
3064void CalendarView::schedule_counter(Incidence *incidence) 3067void CalendarView::schedule_counter(Incidence *incidence)
3065{ 3068{
3066 schedule(Scheduler::Counter,incidence); 3069 schedule(Scheduler::Counter,incidence);
3067} 3070}
3068 3071
3069void CalendarView::schedule_declinecounter(Incidence *incidence) 3072void CalendarView::schedule_declinecounter(Incidence *incidence)
3070{ 3073{
3071 schedule(Scheduler::Declinecounter,incidence); 3074 schedule(Scheduler::Declinecounter,incidence);
3072} 3075}
3073 3076
3074void CalendarView::schedule_publish_freebusy(int daysToPublish) 3077void CalendarView::schedule_publish_freebusy(int daysToPublish)
3075{ 3078{
3076 QDateTime start = QDateTime::currentDateTime(); 3079 QDateTime start = QDateTime::currentDateTime();
3077 QDateTime end = start.addDays(daysToPublish); 3080 QDateTime end = start.addDays(daysToPublish);
3078 3081
3079 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); 3082 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end);
3080 freebusy->setOrganizer(KOPrefs::instance()->email()); 3083 freebusy->setOrganizer(KOPrefs::instance()->email());
3081 3084
3082 3085
3083 PublishDialog *publishdlg = new PublishDialog(); 3086 PublishDialog *publishdlg = new PublishDialog();
3084 if ( publishdlg->exec() == QDialog::Accepted ) { 3087 if ( publishdlg->exec() == QDialog::Accepted ) {
3085 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3088 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3086 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { 3089 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) {
3087 delete(freebusy); 3090 delete(freebusy);
3088 } 3091 }
3089 } 3092 }
3090 delete publishdlg; 3093 delete publishdlg;
3091} 3094}
3092 3095
3093void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) 3096void CalendarView::schedule(Scheduler::Method method, Incidence *incidence)
3094{ 3097{
3095 Event *event = 0; 3098 Event *event = 0;
3096 Todo *todo = 0; 3099 Todo *todo = 0;
3097 3100
3098 if (incidence == 0) { 3101 if (incidence == 0) {
3099 incidence = mViewManager->currentView()->selectedIncidences().first(); 3102 incidence = mViewManager->currentView()->selectedIncidences().first();
3100 if (incidence == 0) { 3103 if (incidence == 0) {
3101 incidence = mTodoList->selectedIncidences().first(); 3104 incidence = mTodoList->selectedIncidences().first();
3102 } 3105 }
3103 } 3106 }
3104 if ( incidence && incidence->type() == "Event" ) { 3107 if ( incidence && incidence->type() == "Event" ) {
3105 event = static_cast<Event *>(incidence); 3108 event = static_cast<Event *>(incidence);
3106 } 3109 }
3107 if ( incidence && incidence->type() == "Todo" ) { 3110 if ( incidence && incidence->type() == "Todo" ) {
3108 todo = static_cast<Todo *>(incidence); 3111 todo = static_cast<Todo *>(incidence);
3109 } 3112 }
3110 3113
3111 if (!event && !todo) { 3114 if (!event && !todo) {
3112 KMessageBox::sorry(this,i18n("No event selected.")); 3115 KMessageBox::sorry(this,i18n("No event selected."));
3113 return; 3116 return;
3114 } 3117 }
3115 3118
3116 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { 3119 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) {
3117 KMessageBox::sorry(this,i18n("The event has no attendees.")); 3120 KMessageBox::sorry(this,i18n("The event has no attendees."));
3118 return; 3121 return;
3119 } 3122 }
3120 3123
3121 Event *ev = 0; 3124 Event *ev = 0;
3122 if (event) ev = new Event(*event); 3125 if (event) ev = new Event(*event);
3123 Todo *to = 0; 3126 Todo *to = 0;
3124 if (todo) to = new Todo(*todo); 3127 if (todo) to = new Todo(*todo);
3125 3128
3126 if (method == Scheduler::Reply || method == Scheduler::Refresh) { 3129 if (method == Scheduler::Reply || method == Scheduler::Refresh) {
3127 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 3130 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
3128 if (!me) { 3131 if (!me) {
3129 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); 3132 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails."));
3130 return; 3133 return;
3131 } 3134 }
3132 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { 3135 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) {
3133 StatusDialog *statdlg = new StatusDialog(this); 3136 StatusDialog *statdlg = new StatusDialog(this);
3134 if (!statdlg->exec()==QDialog::Accepted) return; 3137 if (!statdlg->exec()==QDialog::Accepted) return;
3135 me->setStatus( statdlg->status() ); 3138 me->setStatus( statdlg->status() );
3136 delete(statdlg); 3139 delete(statdlg);
3137 } 3140 }
3138 Attendee *menew = new Attendee(*me); 3141 Attendee *menew = new Attendee(*me);
3139 if (ev) { 3142 if (ev) {
3140 ev->clearAttendees(); 3143 ev->clearAttendees();
3141 ev->addAttendee(menew,false); 3144 ev->addAttendee(menew,false);
3142 } else { 3145 } else {
3143 if (to) { 3146 if (to) {
3144 todo->clearAttendees(); 3147 todo->clearAttendees();
3145 todo->addAttendee(menew,false); 3148 todo->addAttendee(menew,false);
3146 } 3149 }
3147 } 3150 }
3148 } 3151 }
3149 3152
3150 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3153 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3151 if (ev) { 3154 if (ev) {
3152 if ( !dlg->addMessage(ev,method) ) delete(ev); 3155 if ( !dlg->addMessage(ev,method) ) delete(ev);
3153 } else { 3156 } else {
3154 if (to) { 3157 if (to) {
3155 if ( !dlg->addMessage(to,method) ) delete(to); 3158 if ( !dlg->addMessage(to,method) ) delete(to);
3156 } 3159 }
3157 } 3160 }
3158} 3161}
3159 3162
3160void CalendarView::openAddressbook() 3163void CalendarView::openAddressbook()
3161{ 3164{
3162 KRun::runCommand("kaddressbook"); 3165 KRun::runCommand("kaddressbook");
3163} 3166}
3164 3167
3165void CalendarView::setModified(bool modified) 3168void CalendarView::setModified(bool modified)
3166{ 3169{
3167 if ( modified ) 3170 if ( modified )
3168 emit signalmodified(); 3171 emit signalmodified();
3169 if (mModified != modified) { 3172 if (mModified != modified) {
3170 mModified = modified; 3173 mModified = modified;
3171 emit modifiedChanged(mModified); 3174 emit modifiedChanged(mModified);
3172 } 3175 }
3173} 3176}
3174 3177
3175bool CalendarView::isReadOnly() 3178bool CalendarView::isReadOnly()
3176{ 3179{
3177 return mReadOnly; 3180 return mReadOnly;
3178} 3181}
3179 3182
3180void CalendarView::setReadOnly(bool readOnly) 3183void CalendarView::setReadOnly(bool readOnly)
3181{ 3184{
3182 if (mReadOnly != readOnly) { 3185 if (mReadOnly != readOnly) {
3183 mReadOnly = readOnly; 3186 mReadOnly = readOnly;
3184 emit readOnlyChanged(mReadOnly); 3187 emit readOnlyChanged(mReadOnly);
3185 } 3188 }
3186} 3189}
3187 3190
3188bool CalendarView::isModified() 3191bool CalendarView::isModified()
3189{ 3192{
3190 return mModified; 3193 return mModified;
3191} 3194}
3192 3195
3193void CalendarView::printSetup() 3196void CalendarView::printSetup()
3194{ 3197{
3195#ifndef KORG_NOPRINTER 3198#ifndef KORG_NOPRINTER
3196 createPrinter(); 3199 createPrinter();
3197 3200
3198 mCalPrinter->setupPrinter(); 3201 mCalPrinter->setupPrinter();
3199#endif 3202#endif
3200} 3203}
3201 3204
3202void CalendarView::print() 3205void CalendarView::print()
3203{ 3206{
3204#ifndef KORG_NOPRINTER 3207#ifndef KORG_NOPRINTER
3205 createPrinter(); 3208 createPrinter();
3206 3209
3207 DateList tmpDateList = mNavigator->selectedDates(); 3210 DateList tmpDateList = mNavigator->selectedDates();
3208 mCalPrinter->print(CalPrinter::Month, 3211 mCalPrinter->print(CalPrinter::Month,
3209 tmpDateList.first(), tmpDateList.last()); 3212 tmpDateList.first(), tmpDateList.last());
3210#endif 3213#endif
3211} 3214}
3212 3215
3213void CalendarView::printPreview() 3216void CalendarView::printPreview()
3214{ 3217{
3215#ifndef KORG_NOPRINTER 3218#ifndef KORG_NOPRINTER
3216 kdDebug() << "CalendarView::printPreview()" << endl; 3219 kdDebug() << "CalendarView::printPreview()" << endl;
3217 3220
3218 createPrinter(); 3221 createPrinter();
3219 3222
3220 DateList tmpDateList = mNavigator->selectedDates(); 3223 DateList tmpDateList = mNavigator->selectedDates();
3221 3224
3222 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), 3225 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(),
3223 tmpDateList.last()); 3226 tmpDateList.last());
3224#endif 3227#endif
3225} 3228}
3226 3229
3227void CalendarView::exportICalendar() 3230void CalendarView::exportICalendar()
3228{ 3231{
3229 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); 3232 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this);
3230 3233
3231 // Force correct extension 3234 // Force correct extension
3232 if (filename.right(4) != ".ics") filename += ".ics"; 3235 if (filename.right(4) != ".ics") filename += ".ics";
3233 3236
3234 FileStorage storage( mCalendar, filename, new ICalFormat() ); 3237 FileStorage storage( mCalendar, filename, new ICalFormat() );
3235 storage.save(); 3238 storage.save();
3236} 3239}
3237 3240
3238bool CalendarView::exportVCalendar( QString filename ) 3241bool CalendarView::exportVCalendar( QString filename )
3239{ 3242{
3240 if (mCalendar->journals().count() > 0) { 3243 if (mCalendar->journals().count() > 0) {
3241 int result = KMessageBox::warningContinueCancel(this, 3244 int result = KMessageBox::warningContinueCancel(this,
3242 i18n("The journal entries can not be\nexported to a vCalendar file."), 3245 i18n("The journal entries can not be\nexported to a vCalendar file."),
3243 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 3246 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
3244 true); 3247 true);
3245 if (result != KMessageBox::Continue) return false; 3248 if (result != KMessageBox::Continue) return false;
3246 } 3249 }
3247 3250
3248 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); 3251 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this);
3249 3252
3250 // Force correct extension 3253 // Force correct extension
3251 if (filename.right(4) != ".vcs") filename += ".vcs"; 3254 if (filename.right(4) != ".vcs") filename += ".vcs";
3252 3255
3253 FileStorage storage( mCalendar, filename, new VCalFormat ); 3256 FileStorage storage( mCalendar, filename, new VCalFormat );
3254 return storage.save(); 3257 return storage.save();
3255 3258
3256} 3259}
3257 3260
3258void CalendarView::eventUpdated(Incidence *) 3261void CalendarView::eventUpdated(Incidence *)
3259{ 3262{
3260 setModified(); 3263 setModified();
3261 // Don't call updateView here. The code, which has caused the update of the 3264 // Don't call updateView here. The code, which has caused the update of the
3262 // event is responsible for updating the view. 3265 // event is responsible for updating the view.
3263 // updateView(); 3266 // updateView();
3264} 3267}
3265 3268
3266void CalendarView::adaptNavigationUnits() 3269void CalendarView::adaptNavigationUnits()
3267{ 3270{
3268 if (mViewManager->currentView()->isEventView()) { 3271 if (mViewManager->currentView()->isEventView()) {
3269 int days = mViewManager->currentView()->currentDateCount(); 3272 int days = mViewManager->currentView()->currentDateCount();
3270 if (days == 1) { 3273 if (days == 1) {
3271 emit changeNavStringPrev(i18n("&Previous Day")); 3274 emit changeNavStringPrev(i18n("&Previous Day"));
3272 emit changeNavStringNext(i18n("&Next Day")); 3275 emit changeNavStringNext(i18n("&Next Day"));
3273 } else { 3276 } else {
3274 emit changeNavStringPrev(i18n("&Previous Week")); 3277 emit changeNavStringPrev(i18n("&Previous Week"));
3275 emit changeNavStringNext(i18n("&Next Week")); 3278 emit changeNavStringNext(i18n("&Next Week"));
3276 } 3279 }
3277 } 3280 }
3278} 3281}
3279 3282
3280void CalendarView::processMainViewSelection( Incidence *incidence ) 3283void CalendarView::processMainViewSelection( Incidence *incidence )
3281{ 3284{
3282 if ( incidence ) mTodoList->clearSelection(); 3285 if ( incidence ) mTodoList->clearSelection();
3283 processIncidenceSelection( incidence ); 3286 processIncidenceSelection( incidence );
3284} 3287}
3285 3288
3286void CalendarView::processTodoListSelection( Incidence *incidence ) 3289void CalendarView::processTodoListSelection( Incidence *incidence )
3287{ 3290{
3288 if ( incidence && mViewManager->currentView() ) { 3291 if ( incidence && mViewManager->currentView() ) {
3289 mViewManager->currentView()->clearSelection(); 3292 mViewManager->currentView()->clearSelection();
3290 } 3293 }
3291 processIncidenceSelection( incidence ); 3294 processIncidenceSelection( incidence );
3292} 3295}
3293 3296
3294void CalendarView::processIncidenceSelection( Incidence *incidence ) 3297void CalendarView::processIncidenceSelection( Incidence *incidence )
3295{ 3298{
3296 if ( incidence == mSelectedIncidence ) return; 3299 if ( incidence == mSelectedIncidence ) return;
3297 3300
3298 mSelectedIncidence = incidence; 3301 mSelectedIncidence = incidence;
3299 3302
3300 emit incidenceSelected( mSelectedIncidence ); 3303 emit incidenceSelected( mSelectedIncidence );
3301 3304
3302 if ( incidence && incidence->type() == "Event" ) { 3305 if ( incidence && incidence->type() == "Event" ) {
3303 Event *event = static_cast<Event *>( incidence ); 3306 Event *event = static_cast<Event *>( incidence );
3304 if ( event->organizer() == KOPrefs::instance()->email() ) { 3307 if ( event->organizer() == KOPrefs::instance()->email() ) {
3305 emit organizerEventsSelected( true ); 3308 emit organizerEventsSelected( true );
3306 } else { 3309 } else {
3307 emit organizerEventsSelected(false); 3310 emit organizerEventsSelected(false);
3308 } 3311 }
3309 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3312 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3310 KOPrefs::instance()->email() ) ) { 3313 KOPrefs::instance()->email() ) ) {
3311 emit groupEventsSelected( true ); 3314 emit groupEventsSelected( true );
3312 } else { 3315 } else {
3313 emit groupEventsSelected(false); 3316 emit groupEventsSelected(false);
3314 } 3317 }
3315 return; 3318 return;
3316 } else { 3319 } else {
3317 if ( incidence && incidence->type() == "Todo" ) { 3320 if ( incidence && incidence->type() == "Todo" ) {
3318 emit todoSelected( true ); 3321 emit todoSelected( true );
3319 Todo *event = static_cast<Todo *>( incidence ); 3322 Todo *event = static_cast<Todo *>( incidence );
3320 if ( event->organizer() == KOPrefs::instance()->email() ) { 3323 if ( event->organizer() == KOPrefs::instance()->email() ) {
3321 emit organizerEventsSelected( true ); 3324 emit organizerEventsSelected( true );
3322 } else { 3325 } else {
3323 emit organizerEventsSelected(false); 3326 emit organizerEventsSelected(false);
3324 } 3327 }
3325 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3328 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3326 KOPrefs::instance()->email() ) ) { 3329 KOPrefs::instance()->email() ) ) {
3327 emit groupEventsSelected( true ); 3330 emit groupEventsSelected( true );
3328 } else { 3331 } else {
3329 emit groupEventsSelected(false); 3332 emit groupEventsSelected(false);
3330 } 3333 }
3331 return; 3334 return;
3332 } else { 3335 } else {
3333 emit todoSelected( false ); 3336 emit todoSelected( false );
3334 emit organizerEventsSelected(false); 3337 emit organizerEventsSelected(false);
3335 emit groupEventsSelected(false); 3338 emit groupEventsSelected(false);
3336 } 3339 }
3337 return; 3340 return;
3338 } 3341 }
3339 3342
3340 /* if ( incidence && incidence->type() == "Todo" ) { 3343 /* if ( incidence && incidence->type() == "Todo" ) {
3341 emit todoSelected( true ); 3344 emit todoSelected( true );
3342 } else { 3345 } else {
3343 emit todoSelected( false ); 3346 emit todoSelected( false );
3344 }*/ 3347 }*/
3345} 3348}
3346 3349
3347 3350
3348void CalendarView::checkClipboard() 3351void CalendarView::checkClipboard()
3349{ 3352{
3350#ifndef KORG_NODND 3353#ifndef KORG_NODND
3351 if (ICalDrag::canDecode(QApplication::clipboard()->data())) { 3354 if (ICalDrag::canDecode(QApplication::clipboard()->data())) {
3352 emit pasteEnabled(true); 3355 emit pasteEnabled(true);
3353 } else { 3356 } else {
3354 emit pasteEnabled(false); 3357 emit pasteEnabled(false);
3355 } 3358 }
3356#endif 3359#endif
3357} 3360}
3358 3361
3359void CalendarView::showDates(const DateList &selectedDates) 3362void CalendarView::showDates(const DateList &selectedDates)
3360{ 3363{
3361 // kdDebug() << "CalendarView::selectDates()" << endl; 3364 // kdDebug() << "CalendarView::selectDates()" << endl;
3362 3365
3363 if ( mViewManager->currentView() ) { 3366 if ( mViewManager->currentView() ) {
3364 updateView( selectedDates.first(), selectedDates.last() ); 3367 updateView( selectedDates.first(), selectedDates.last() );
3365 } else { 3368 } else {
3366 mViewManager->showAgendaView(); 3369 mViewManager->showAgendaView();
3367 } 3370 }
3368 3371
3369 QString selDates; 3372 QString selDates;
3370 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); 3373 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true);
3371 if (selectedDates.first() < selectedDates.last() ) 3374 if (selectedDates.first() < selectedDates.last() )
3372 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); 3375 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true);
3373 topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); 3376 topLevelWidget()->setCaption( i18n("Dates: ") + selDates );
3374 3377
3375} 3378}
3376 3379
3377QPtrList<CalFilter> CalendarView::filters() 3380QPtrList<CalFilter> CalendarView::filters()
3378{ 3381{
3379 return mFilters; 3382 return mFilters;
3380 3383
3381} 3384}
3382void CalendarView::editFilters() 3385void CalendarView::editFilters()
3383{ 3386{
3384 // kdDebug() << "CalendarView::editFilters()" << endl; 3387 // kdDebug() << "CalendarView::editFilters()" << endl;
3385 3388
3386 CalFilter *filter = mFilters.first(); 3389 CalFilter *filter = mFilters.first();
3387 while(filter) { 3390 while(filter) {
3388 kdDebug() << " Filter: " << filter->name() << endl; 3391 kdDebug() << " Filter: " << filter->name() << endl;
3389 filter = mFilters.next(); 3392 filter = mFilters.next();
3390 } 3393 }
3391 3394
3392 mDialogManager->showFilterEditDialog(&mFilters); 3395 mDialogManager->showFilterEditDialog(&mFilters);
3393} 3396}
3394void CalendarView::toggleFilter() 3397void CalendarView::toggleFilter()
3395{ 3398{
3396 showFilter(! mFilterView->isVisible()); 3399 showFilter(! mFilterView->isVisible());
3397} 3400}
3398 3401
3399KOFilterView *CalendarView::filterView() 3402KOFilterView *CalendarView::filterView()
3400{ 3403{
3401 return mFilterView; 3404 return mFilterView;
3402} 3405}
3403void CalendarView::selectFilter( int fil ) 3406void CalendarView::selectFilter( int fil )
3404{ 3407{
3405 mFilterView->setSelectedFilter( fil ); 3408 mFilterView->setSelectedFilter( fil );
3406} 3409}
3407void CalendarView::showFilter(bool visible) 3410void CalendarView::showFilter(bool visible)
3408{ 3411{
3409 if (visible) mFilterView->show(); 3412 if (visible) mFilterView->show();
3410 else mFilterView->hide(); 3413 else mFilterView->hide();
3411} 3414}
3412void CalendarView::toggleFilerEnabled( ) 3415void CalendarView::toggleFilerEnabled( )
3413{ 3416{
3414 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); 3417 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() );
3415 if ( !mFilterView->filtersEnabled() ) 3418 if ( !mFilterView->filtersEnabled() )
3416 topLevelWidget()->setCaption( i18n("Filter disabled ") ); 3419 topLevelWidget()->setCaption( i18n("Filter disabled ") );
3417 3420
3418} 3421}
3419void CalendarView::updateFilter() 3422void CalendarView::updateFilter()
3420{ 3423{
3421 CalFilter *filter = mFilterView->selectedFilter(); 3424 CalFilter *filter = mFilterView->selectedFilter();
3422 if (filter) { 3425 if (filter) {
3423 if (mFilterView->filtersEnabled()) { 3426 if (mFilterView->filtersEnabled()) {
3424 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); 3427 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() );
3425 filter->setEnabled(true); 3428 filter->setEnabled(true);
3426 } 3429 }
3427 else filter->setEnabled(false); 3430 else filter->setEnabled(false);
3428 mCalendar->setFilter(filter); 3431 mCalendar->setFilter(filter);
3429 updateView(); 3432 updateView();
3430 } 3433 }
3431} 3434}
3432 3435
3433void CalendarView::filterEdited() 3436void CalendarView::filterEdited()
3434{ 3437{
3435 mFilterView->updateFilters(); 3438 mFilterView->updateFilters();
3436 updateFilter(); 3439 updateFilter();
3437 writeSettings(); 3440 writeSettings();
3438} 3441}
3439 3442
3440 3443
3441void CalendarView::takeOverEvent() 3444void CalendarView::takeOverEvent()
3442{ 3445{
3443 Incidence *incidence = currentSelection(); 3446 Incidence *incidence = currentSelection();
3444 3447
3445 if (!incidence) return; 3448 if (!incidence) return;
3446 3449
3447 incidence->setOrganizer(KOPrefs::instance()->email()); 3450 incidence->setOrganizer(KOPrefs::instance()->email());
3448 incidence->recreate(); 3451 incidence->recreate();
3449 incidence->setReadOnly(false); 3452 incidence->setReadOnly(false);
3450 3453
3451 updateView(); 3454 updateView();
3452} 3455}
3453 3456
3454void CalendarView::takeOverCalendar() 3457void CalendarView::takeOverCalendar()
3455{ 3458{
3456 // TODO: Create Calendar::allIncidences() function and use it here 3459 // TODO: Create Calendar::allIncidences() function and use it here
3457 3460
3458 QPtrList<Event> events = mCalendar->events(); 3461 QPtrList<Event> events = mCalendar->events();
3459 for(uint i=0; i<events.count(); ++i) { 3462 for(uint i=0; i<events.count(); ++i) {
3460 events.at(i)->setOrganizer(KOPrefs::instance()->email()); 3463 events.at(i)->setOrganizer(KOPrefs::instance()->email());
3461 events.at(i)->recreate(); 3464 events.at(i)->recreate();
3462 events.at(i)->setReadOnly(false); 3465 events.at(i)->setReadOnly(false);
3463 } 3466 }
3464 3467
3465 QPtrList<Todo> todos = mCalendar->todos(); 3468 QPtrList<Todo> todos = mCalendar->todos();
3466 for(uint i=0; i<todos.count(); ++i) { 3469 for(uint i=0; i<todos.count(); ++i) {
3467 todos.at(i)->setOrganizer(KOPrefs::instance()->email()); 3470 todos.at(i)->setOrganizer(KOPrefs::instance()->email());
3468 todos.at(i)->recreate(); 3471 todos.at(i)->recreate();
3469 todos.at(i)->setReadOnly(false); 3472 todos.at(i)->setReadOnly(false);
3470 } 3473 }
3471 3474
3472 QPtrList<Journal> journals = mCalendar->journals(); 3475 QPtrList<Journal> journals = mCalendar->journals();
3473 for(uint i=0; i<journals.count(); ++i) { 3476 for(uint i=0; i<journals.count(); ++i) {
3474 journals.at(i)->setOrganizer(KOPrefs::instance()->email()); 3477 journals.at(i)->setOrganizer(KOPrefs::instance()->email());
3475 journals.at(i)->recreate(); 3478 journals.at(i)->recreate();
3476 journals.at(i)->setReadOnly(false); 3479 journals.at(i)->setReadOnly(false);
3477 } 3480 }
3478 3481
3479 updateView(); 3482 updateView();
3480} 3483}
3481 3484
3482void CalendarView::showIntro() 3485void CalendarView::showIntro()
3483{ 3486{
3484 kdDebug() << "To be implemented." << endl; 3487 kdDebug() << "To be implemented." << endl;
3485} 3488}
3486 3489
3487QWidgetStack *CalendarView::viewStack() 3490QWidgetStack *CalendarView::viewStack()
3488{ 3491{
3489 return mRightFrame; 3492 return mRightFrame;
3490} 3493}
3491 3494
3492QWidget *CalendarView::leftFrame() 3495QWidget *CalendarView::leftFrame()
3493{ 3496{
3494 return mLeftFrame; 3497 return mLeftFrame;
3495} 3498}
3496 3499
3497DateNavigator *CalendarView::dateNavigator() 3500DateNavigator *CalendarView::dateNavigator()
3498{ 3501{
3499 return mNavigator; 3502 return mNavigator;
3500} 3503}
3501 3504
3502KDateNavigator* CalendarView::dateNavigatorWidget() 3505KDateNavigator* CalendarView::dateNavigatorWidget()
3503{ 3506{
3504 return mDateNavigator; 3507 return mDateNavigator;
3505} 3508}
3506void CalendarView::toggleDateNavigatorWidget() 3509void CalendarView::toggleDateNavigatorWidget()
3507{ 3510{
3508 if (mDateNavigator->isVisible()) 3511 if (mDateNavigator->isVisible())
3509 mDateNavigator->hide(); 3512 mDateNavigator->hide();
3510 else 3513 else
3511 mDateNavigator->show(); 3514 mDateNavigator->show();
3512} 3515}
3513void CalendarView::addView(KOrg::BaseView *view) 3516void CalendarView::addView(KOrg::BaseView *view)
3514{ 3517{
3515 mViewManager->addView(view); 3518 mViewManager->addView(view);
3516} 3519}
3517 3520
3518void CalendarView::showView(KOrg::BaseView *view) 3521void CalendarView::showView(KOrg::BaseView *view)
3519{ 3522{
3520 mViewManager->showView(view, mLeftFrame->isVisible()); 3523 mViewManager->showView(view, mLeftFrame->isVisible());
3521} 3524}
3522 3525
3523Incidence *CalendarView::currentSelection() 3526Incidence *CalendarView::currentSelection()
3524{ 3527{
3525 return mViewManager->currentSelection(); 3528 return mViewManager->currentSelection();
3526} 3529}
3527void CalendarView::toggleAllDaySize() 3530void CalendarView::toggleAllDaySize()
3528{ 3531{
3529 /* 3532 /*
3530 if ( KOPrefs::instance()->mAllDaySize > 47 ) 3533 if ( KOPrefs::instance()->mAllDaySize > 47 )
3531 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; 3534 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2;
3532 else 3535 else
3533 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; 3536 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2;
3534 */ 3537 */
3535 viewManager()->agendaView()->toggleAllDay(); 3538 viewManager()->agendaView()->toggleAllDay();
3536} 3539}
3537void CalendarView::toggleExpand() 3540void CalendarView::toggleExpand()
3538{ 3541{
3539 // if ( mLeftFrame->isHidden() ) { 3542 // if ( mLeftFrame->isHidden() ) {
3540 // mLeftFrame->show(); 3543 // mLeftFrame->show();
3541 // emit calendarViewExpanded( false ); 3544 // emit calendarViewExpanded( false );
3542 // } else { 3545 // } else {
3543 // mLeftFrame->hide(); 3546 // mLeftFrame->hide();
3544 // emit calendarViewExpanded( true ); 3547 // emit calendarViewExpanded( true );
3545 // } 3548 // }
3546 3549
3547 globalFlagBlockAgenda = 1; 3550 globalFlagBlockAgenda = 1;
3548 emit calendarViewExpanded( !mLeftFrame->isHidden() ); 3551 emit calendarViewExpanded( !mLeftFrame->isHidden() );
3549 globalFlagBlockAgenda = 5; 3552 globalFlagBlockAgenda = 5;
3550 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); 3553 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() );
3551 //mViewManager->showView( 0, true ); 3554 //mViewManager->showView( 0, true );
3552} 3555}
3553 3556
3554void CalendarView::calendarModified( bool modified, Calendar * ) 3557void CalendarView::calendarModified( bool modified, Calendar * )
3555{ 3558{
3556 setModified( modified ); 3559 setModified( modified );
3557} 3560}
3558 3561
3559Todo *CalendarView::selectedTodo() 3562Todo *CalendarView::selectedTodo()
3560{ 3563{
3561 Incidence *incidence = currentSelection(); 3564 Incidence *incidence = currentSelection();
3562 if ( incidence && incidence->type() == "Todo" ) { 3565 if ( incidence && incidence->type() == "Todo" ) {
3563 return static_cast<Todo *>( incidence ); 3566 return static_cast<Todo *>( incidence );
3564 } 3567 }
3565 3568
3566 incidence = mTodoList->selectedIncidences().first(); 3569 incidence = mTodoList->selectedIncidences().first();
3567 if ( incidence && incidence->type() == "Todo" ) { 3570 if ( incidence && incidence->type() == "Todo" ) {
3568 return static_cast<Todo *>( incidence ); 3571 return static_cast<Todo *>( incidence );
3569 } 3572 }
3570 3573
3571 return 0; 3574 return 0;
3572} 3575}
3573 3576
3574void CalendarView::dialogClosing(Incidence *in) 3577void CalendarView::dialogClosing(Incidence *in)
3575{ 3578{
3576 // mDialogList.remove(in); 3579 // mDialogList.remove(in);
3577} 3580}
3578 3581
3579void CalendarView::showIncidence() 3582void CalendarView::showIncidence()
3580{ 3583{
3581 Incidence *incidence = currentSelection(); 3584 Incidence *incidence = currentSelection();
3582 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3585 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3583 if ( incidence ) { 3586 if ( incidence ) {
3584 ShowIncidenceVisitor v; 3587 ShowIncidenceVisitor v;
3585 v.act( incidence, this ); 3588 v.act( incidence, this );
3586 } 3589 }
3587} 3590}
3588void CalendarView::editIncidenceDescription() 3591void CalendarView::editIncidenceDescription()
3589{ 3592{
3590 mFlagEditDescription = true; 3593 mFlagEditDescription = true;
3591 editIncidence(); 3594 editIncidence();
3592 mFlagEditDescription = false; 3595 mFlagEditDescription = false;
3593} 3596}
3594void CalendarView::editIncidence() 3597void CalendarView::editIncidence()
3595{ 3598{
3596 // qDebug("editIncidence() "); 3599 // qDebug("editIncidence() ");
3597 Incidence *incidence = currentSelection(); 3600 Incidence *incidence = currentSelection();
3598 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3601 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3599 if ( incidence ) { 3602 if ( incidence ) {
3600 EditIncidenceVisitor v; 3603 EditIncidenceVisitor v;
3601 v.act( incidence, this ); 3604 v.act( incidence, this );
3602 } 3605 }
3603} 3606}
3604 3607
3605void CalendarView::deleteIncidence() 3608void CalendarView::deleteIncidence()
3606{ 3609{
3607 Incidence *incidence = currentSelection(); 3610 Incidence *incidence = currentSelection();
3608 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3611 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3609 if ( incidence ) { 3612 if ( incidence ) {
3610 deleteIncidence(incidence); 3613 deleteIncidence(incidence);
3611 } 3614 }
3612} 3615}
3613 3616
3614void CalendarView::showIncidence(Incidence *incidence) 3617void CalendarView::showIncidence(Incidence *incidence)
3615{ 3618{
3616 if ( incidence ) { 3619 if ( incidence ) {
3617 ShowIncidenceVisitor v; 3620 ShowIncidenceVisitor v;
3618 v.act( incidence, this ); 3621 v.act( incidence, this );
3619 } 3622 }
3620} 3623}
3621 3624
3622void CalendarView::editIncidence(Incidence *incidence) 3625void CalendarView::editIncidence(Incidence *incidence)
3623{ 3626{
3624 if ( incidence ) { 3627 if ( incidence ) {
3625 3628
3626 EditIncidenceVisitor v; 3629 EditIncidenceVisitor v;
3627 v.act( incidence, this ); 3630 v.act( incidence, this );
3628 3631
3629 } 3632 }
3630} 3633}
3631 3634
3632void CalendarView::deleteIncidence(Incidence *incidence) 3635void CalendarView::deleteIncidence(Incidence *incidence)
3633{ 3636{
3634 //qDebug(" CalendarView::deleteIncidence "); 3637 //qDebug(" CalendarView::deleteIncidence ");
3635 if ( incidence ) { 3638 if ( incidence ) {
3636 DeleteIncidenceVisitor v; 3639 DeleteIncidenceVisitor v;
3637 v.act( incidence, this ); 3640 v.act( incidence, this );
3638 } 3641 }
3639} 3642}
3640 3643
3641 3644
3642void CalendarView::lookForOutgoingMessages() 3645void CalendarView::lookForOutgoingMessages()
3643{ 3646{
3644 OutgoingDialog *ogd = mDialogManager->outgoingDialog(); 3647 OutgoingDialog *ogd = mDialogManager->outgoingDialog();
3645 ogd->loadMessages(); 3648 ogd->loadMessages();
3646} 3649}
3647 3650
3648void CalendarView::lookForIncomingMessages() 3651void CalendarView::lookForIncomingMessages()
3649{ 3652{
3650 IncomingDialog *icd = mDialogManager->incomingDialog(); 3653 IncomingDialog *icd = mDialogManager->incomingDialog();
3651 icd->retrieve(); 3654 icd->retrieve();
3652} 3655}
3653 3656
3654bool CalendarView::removeCompletedSubTodos( Todo* t ) 3657bool CalendarView::removeCompletedSubTodos( Todo* t )
3655{ 3658{
3656 bool deleteTodo = true; 3659 bool deleteTodo = true;
3657 QPtrList<Incidence> subTodos; 3660 QPtrList<Incidence> subTodos;
3658 Incidence *aTodo; 3661 Incidence *aTodo;
3659 subTodos = t->relations(); 3662 subTodos = t->relations();
3660 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { 3663 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
3661 if (! removeCompletedSubTodos( (Todo*) aTodo )) 3664 if (! removeCompletedSubTodos( (Todo*) aTodo ))
3662 deleteTodo = false; 3665 deleteTodo = false;
3663 } 3666 }
3664 if ( deleteTodo ) { 3667 if ( deleteTodo ) {
3665 if ( t->isCompleted() ) { 3668 if ( t->isCompleted() ) {
3666 checkExternalId( t ); 3669 checkExternalId( t );
3667 mCalendar->deleteTodo( t ); 3670 mCalendar->deleteTodo( t );
3668 changeTodoDisplay( t,KOGlobals::EVENTDELETED ); 3671 changeTodoDisplay( t,KOGlobals::EVENTDELETED );
3669 } 3672 }
3670 else 3673 else
3671 deleteTodo = false; 3674 deleteTodo = false;
3672 } 3675 }
3673 return deleteTodo; 3676 return deleteTodo;
3674 3677
3675} 3678}
3676void CalendarView::purgeCompleted() 3679void CalendarView::purgeCompleted()
3677{ 3680{
3678 int result = KMessageBox::warningContinueCancel(this, 3681 int result = KMessageBox::warningContinueCancel(this,
3679 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); 3682 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge"));
3680 3683
3681 if (result == KMessageBox::Continue) { 3684 if (result == KMessageBox::Continue) {
3682 3685
3683 QPtrList<Todo> todoCal; 3686 QPtrList<Todo> todoCal;
3684 QPtrList<Todo> rootTodos; 3687 QPtrList<Todo> rootTodos;
3685 //QPtrList<Incidence> rel; 3688 //QPtrList<Incidence> rel;
3686 Todo *aTodo;//, *rTodo; 3689 Todo *aTodo;//, *rTodo;
3687 Incidence *rIncidence; 3690 Incidence *rIncidence;
3688 bool childDelete = false; 3691 bool childDelete = false;
3689 bool deletedOne = true; 3692 bool deletedOne = true;
3690 todoCal = calendar()->todos(); 3693 todoCal = calendar()->todos();
3691 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { 3694 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
3692 if ( !aTodo->relatedTo() ) 3695 if ( !aTodo->relatedTo() )
3693 rootTodos.append( aTodo ); 3696 rootTodos.append( aTodo );
3694 } 3697 }
3695 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { 3698 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) {
3696 removeCompletedSubTodos( aTodo ); 3699 removeCompletedSubTodos( aTodo );
3697 } 3700 }
3698 3701
3699 updateView(); 3702 updateView();
3700 } 3703 }
3701} 3704}
3702 3705
3703void CalendarView::slotCalendarChanged() 3706void CalendarView::slotCalendarChanged()
3704{ 3707{
3705 ; 3708 ;
3706} 3709}
3707 3710
3708NavigatorBar *CalendarView::navigatorBar() 3711NavigatorBar *CalendarView::navigatorBar()
3709{ 3712{
3710 return mNavigatorBar; 3713 return mNavigatorBar;
3711} 3714}
3712 3715
3713 3716
3714 3717
3715void CalendarView::keyPressEvent ( QKeyEvent *e) 3718void CalendarView::keyPressEvent ( QKeyEvent *e)
3716{ 3719{
3717 //qDebug(" alendarView::keyPressEvent "); 3720 //qDebug(" alendarView::keyPressEvent ");
3718 e->ignore(); 3721 e->ignore();
3719} 3722}
3720 3723
3721 3724
3722bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) 3725bool CalendarView::sync(KSyncManager* manager, QString filename, int mode)
3723{ 3726{
3724 // mSyncManager = manager; 3727 // mSyncManager = manager;
3725 mSyncKDE = false; 3728 mSyncKDE = false;
3726 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { 3729 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) {
3727 qDebug("SyncKDE request detected!"); 3730 qDebug("SyncKDE request detected!");
3728 mSyncKDE = true; 3731 mSyncKDE = true;
3729 } 3732 }
3730 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 3733 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
3731 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 3734 mCurrentSyncName = mSyncManager->getCurrentSyncName();
3732 return syncCalendar( filename, mode ); 3735 return syncCalendar( filename, mode );
3733} 3736}
3734bool CalendarView::syncExternal(KSyncManager* manager, QString resource) 3737bool CalendarView::syncExternal(KSyncManager* manager, QString resource)
3735{ 3738{
3736 mSyncKDE = false; 3739 mSyncKDE = false;
3737 //mSyncManager = manager; 3740 //mSyncManager = manager;
3738 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 3741 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
3739 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 3742 mCurrentSyncName = mSyncManager->getCurrentSyncName();
3740 if ( resource == "sharp" ) 3743 if ( resource == "sharp" )
3741 syncExternal( 0 ); 3744 syncExternal( 0 );
3742 if ( resource == "phone" ) 3745 if ( resource == "phone" )
3743 syncExternal( 1 ); 3746 syncExternal( 1 );
3744 // pending setmodified 3747 // pending setmodified
3745 return true; 3748 return true;
3746} 3749}
3747void CalendarView::setSyncManager(KSyncManager* manager) 3750void CalendarView::setSyncManager(KSyncManager* manager)
3748{ 3751{
3749 mSyncManager = manager; 3752 mSyncManager = manager;
3750} 3753}
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp
index 651442b..258f738 100644
--- a/korganizer/koprefs.cpp
+++ b/korganizer/koprefs.cpp
@@ -1,572 +1,566 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <time.h> 24#include <time.h>
25#ifndef _WIN32_ 25#ifndef _WIN32_
26#include <unistd.h> 26#include <unistd.h>
27#endif 27#endif
28#include <qdir.h> 28#include <qdir.h>
29#include <qtextstream.h> 29#include <qtextstream.h>
30#include <qtextcodec.h> 30#include <qtextcodec.h>
31#include <qstring.h> 31#include <qstring.h>
32#include <qregexp.h> 32#include <qregexp.h>
33#include <qfont.h> 33#include <qfont.h>
34#include <qcolor.h> 34#include <qcolor.h>
35#include <qstringlist.h> 35#include <qstringlist.h>
36#include <stdlib.h> 36#include <stdlib.h>
37 37
38#include <kglobal.h> 38#include <kglobal.h>
39#include <kconfig.h> 39#include <kconfig.h>
40#include <klocale.h> 40#include <klocale.h>
41#include <kdebug.h> 41#include <kdebug.h>
42#include <kemailsettings.h> 42#include <kemailsettings.h>
43#include <kstaticdeleter.h> 43#include <kstaticdeleter.h>
44#include <libkdepim/kpimglobalprefs.h> 44#include <libkdepim/kpimglobalprefs.h>
45 45
46#include "koprefs.h" 46#include "koprefs.h"
47#include "mainwindow.h" 47#include "mainwindow.h"
48 48
49const char *germanwords[][2] = { 49const char *germanwords[][2] = {
50#include "wordsgerman.h" 50#include "wordsgerman.h"
51 "", "" 51 "", ""
52}; 52};
53 53
54KOPrefs *KOPrefs::mInstance = 0; 54KOPrefs *KOPrefs::mInstance = 0;
55static KStaticDeleter<KOPrefs> insd; 55static KStaticDeleter<KOPrefs> insd;
56 56
57KOPrefs::KOPrefs() : 57KOPrefs::KOPrefs() :
58 KPimPrefs("korganizerrc") 58 KPimPrefs("korganizerrc")
59{ 59{
60 mCategoryColors.setAutoDelete(true); 60 mCategoryColors.setAutoDelete(true);
61 mLocaleDict = 0; 61 mLocaleDict = 0;
62 fillMailDefaults(); 62 fillMailDefaults();
63 mDefaultCategoryColor = QColor(175,210,255);//196,196,196); 63 mDefaultCategoryColor = QColor(175,210,255);//196,196,196);
64 QColor defaultHolidayColor = QColor(255,0,0); 64 QColor defaultHolidayColor = QColor(255,0,0);
65 QColor defaultHighlightColor = QColor(129,112,255);//64,64,255); 65 QColor defaultHighlightColor = QColor(129,112,255);//64,64,255);
66 QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128); 66 QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128);
67 QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160); 67 QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160);
68 QColor defaultTodoDueTodayColor = QColor(255,220,100); 68 QColor defaultTodoDueTodayColor = QColor(255,220,100);
69 QColor defaultTodoOverdueColor = QColor(255,153,125); 69 QColor defaultTodoOverdueColor = QColor(255,153,125);
70 70
71 mTimeBarFont = QFont("helvetica",10);//,QFont::Bold); 71 mTimeBarFont = QFont("helvetica",10);//,QFont::Bold);
72 mDefaultViewFont = QFont("helvetica",10); 72 mDefaultViewFont = QFont("helvetica",10);
73 mDefaultMonthViewFont = QFont("helvetica",8); 73 mDefaultMonthViewFont = QFont("helvetica",8);
74 mMarcusBainsFont= QFont("helvetica",10); 74 mMarcusBainsFont= QFont("helvetica",10);
75 mDateNavigatorFont= QFont("helvetica",10, QFont::Bold); 75 mDateNavigatorFont= QFont("helvetica",10, QFont::Bold);
76 mEditBoxFont = QFont("helvetica",12); 76 mEditBoxFont = QFont("helvetica",12);
77 mJornalViewFont = QFont("helvetica",12); 77 mJornalViewFont = QFont("helvetica",12);
78 78
79 KPrefs::setCurrentGroup("General"); 79 KPrefs::setCurrentGroup("General");
80 80
81 81
82 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); 82 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false);
83 83
84 addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true); 84 addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true);
85 addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true); 85 addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true);
86 addItemBool("ShowIconSearch",&mShowIconSearch,true); 86 addItemBool("ShowIconSearch",&mShowIconSearch,true);
87 addItemBool("ShowIconList",&mShowIconList,true); 87 addItemBool("ShowIconList",&mShowIconList,true);
88 addItemBool("ShowIconDay1",&mShowIconDay1,true); 88 addItemBool("ShowIconDay1",&mShowIconDay1,true);
89 addItemBool("ShowIconDay5",&mShowIconDay5,true); 89 addItemBool("ShowIconDay5",&mShowIconDay5,true);
90 addItemBool("ShowIconDay7",&mShowIconDay7,true); 90 addItemBool("ShowIconDay7",&mShowIconDay7,true);
91 addItemBool("ShowIconMonth",&mShowIconMonth,true); 91 addItemBool("ShowIconMonth",&mShowIconMonth,true);
92 addItemBool("ShowIconTodoview",&mShowIconTodoview,true); 92 addItemBool("ShowIconTodoview",&mShowIconTodoview,true);
93 addItemBool("ShowIconBackFast",&mShowIconBackFast,true); 93 addItemBool("ShowIconBackFast",&mShowIconBackFast,true);
94 addItemBool("ShowIconBack",&mShowIconBack,true); 94 addItemBool("ShowIconBack",&mShowIconBack,true);
95 addItemBool("ShowIconToday",&mShowIconToday,true); 95 addItemBool("ShowIconToday",&mShowIconToday,true);
96 addItemBool("ShowIconForward",&mShowIconForward,true); 96 addItemBool("ShowIconForward",&mShowIconForward,true);
97 addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true); 97 addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true);
98 addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,false); 98 addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,false);
99 addItemBool("ShowIconNextDays",&mShowIconNextDays,true); 99 addItemBool("ShowIconNextDays",&mShowIconNextDays,true);
100 addItemBool("ShowIconNext",&mShowIconNext,true); 100 addItemBool("ShowIconNext",&mShowIconNext,true);
101 addItemBool("ShowIconJournal",&mShowIconJournal,true); 101 addItemBool("ShowIconJournal",&mShowIconJournal,true);
102 addItemBool("ShowIconStretch",&mShowIconStretch,true); 102 addItemBool("ShowIconStretch",&mShowIconStretch,true);
103 addItemBool("LanguageChanged",&mLanguageChanged,false); 103 addItemBool("LanguageChanged",&mLanguageChanged,false);
104 104
105 addItemBool("AskForQuit",&mAskForQuit,false); 105 addItemBool("AskForQuit",&mAskForQuit,false);
106 106
107#ifndef DESKTOP_VERSION 107#ifndef DESKTOP_VERSION
108 addItemBool("ShowFullMenu",&mShowFullMenu,false); 108 addItemBool("ShowFullMenu",&mShowFullMenu,false);
109#else 109#else
110 addItemBool("ShowFullMenu",&mShowFullMenu,true); 110 addItemBool("ShowFullMenu",&mShowFullMenu,true);
111#endif 111#endif
112 addItemBool("ToolBarHor",&mToolBarHor, true ); 112 addItemBool("ToolBarHor",&mToolBarHor, true );
113 addItemBool("ToolBarUp",&mToolBarUp, false ); 113 addItemBool("ToolBarUp",&mToolBarUp, false );
114 addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false ); 114 addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false );
115 addItemInt("Whats Next Days",&mWhatsNextDays,3); 115 addItemInt("Whats Next Days",&mWhatsNextDays,3);
116 addItemInt("Whats Next Prios",&mWhatsNextPrios,1); 116 addItemInt("Whats Next Prios",&mWhatsNextPrios,1);
117 117
118 addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true); 118 addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true);
119 addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true); 119 addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true);
120 addItemInt("AllDay Size",&mAllDaySize,28); 120 addItemInt("AllDay Size",&mAllDaySize,28);
121 QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav"; 121 QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav";
122 addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm ); 122 addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm );
123 123
124 addItemStringList("LocationDefaults",&mLocationDefaults ); 124 addItemStringList("LocationDefaults",&mLocationDefaults );
125 addItemStringList("EventSummary User",&mEventSummaryUser); 125 addItemStringList("EventSummary User",&mEventSummaryUser);
126 addItemStringList("TodoSummary User",&mTodoSummaryUser); 126 addItemStringList("TodoSummary User",&mTodoSummaryUser);
127 127
128 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); 128 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false);
129 addItemBool("Enable Project View",&mEnableProjectView,false); 129 addItemBool("Enable Project View",&mEnableProjectView,false);
130 addItemBool("Auto Save",&mAutoSave,false); 130 addItemBool("Auto Save",&mAutoSave,false);
131 addItemInt("Auto Save Interval",&mAutoSaveInterval,3); 131 addItemInt("Auto Save Interval",&mAutoSaveInterval,3);
132 addItemBool("Confirm Deletes",&mConfirm,true); 132 addItemBool("Confirm Deletes",&mConfirm,true);
133 addItemString("Archive File",&mArchiveFile); 133 addItemString("Archive File",&mArchiveFile);
134 addItemString("Html Export File",&mHtmlExportFile, 134 addItemString("Html Export File",&mHtmlExportFile,
135 QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html")); 135 QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html"));
136 addItemBool("Html With Save",&mHtmlWithSave,false); 136 addItemBool("Html With Save",&mHtmlWithSave,false);
137 137
138 KPrefs::setCurrentGroup("Personal Settings"); 138 KPrefs::setCurrentGroup("Personal Settings");
139 139
140 addItemInt("Mail Client",&mMailClient,MailClientKMail); 140 addItemInt("Mail Client",&mMailClient,MailClientKMail);
141 addItemBool("Use Control Center Email",&mEmailControlCenter,false); 141 addItemBool("Use Control Center Email",&mEmailControlCenter,false);
142 addItemBool("Bcc",&mBcc,false); 142 addItemBool("Bcc",&mBcc,false);
143 143
144 KPrefs::setCurrentGroup("Time & Date"); 144 KPrefs::setCurrentGroup("Time & Date");
145 145
146 // addItemString("Time Zone",&mTimeZone,"+0100"); 146 // addItemString("Time Zone",&mTimeZone,"+0100");
147 addItemString("TimeZoneName",&mTimeZoneId,i18n ("+01:00 Europe/Oslo(CET)") ); 147 addItemString("TimeZoneName",&mTimeZoneId,i18n ("+01:00 Europe/Oslo(CET)") );
148 // addItemInt("TimeZoneOffset",&mTimeZoneOffset,60); 148 // addItemInt("TimeZoneOffset",&mTimeZoneOffset,60);
149 addItemBool("UseDaylightsaving",&mUseDaylightsaving,true); 149 addItemBool("UseDaylightsaving",&mUseDaylightsaving,true);
150 addItemInt("DaylightsavingStart",&mDaylightsavingStart,90); 150 addItemInt("DaylightsavingStart",&mDaylightsavingStart,90);
151 addItemInt("DaylightsavingEnd",&mDaylightsavingEnd,304); 151 addItemInt("DaylightsavingEnd",&mDaylightsavingEnd,304);
152 152
153 153
154 addItemInt("Default Start Time",&mStartTime,10); 154 addItemInt("Default Start Time",&mStartTime,10);
155 addItemInt("Default Duration",&mDefaultDuration,2); 155 addItemInt("Default Duration",&mDefaultDuration,2);
156 addItemInt("Default Alarm Time",&mAlarmTime,3); 156 addItemInt("Default Alarm Time",&mAlarmTime,3);
157 addItemInt("Daylight Savings",&mDaylightSavings,0); 157 addItemInt("Daylight Savings",&mDaylightSavings,0);
158 KPrefs::setCurrentGroup("AlarmSettings"); 158 KPrefs::setCurrentGroup("AlarmSettings");
159 addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20); 159 addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20);
160 addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7); 160 addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7);
161 addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5); 161 addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5);
162 addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3); 162 addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3);
163 163
164 164
165 KPrefs::setCurrentGroup("Calendar"); 165 KPrefs::setCurrentGroup("Calendar");
166 166
167 addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar); 167 addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar);
168 168
169 KPrefs::setCurrentGroup("Fonts"); 169 KPrefs::setCurrentGroup("Fonts");
170 // qDebug(" KPrefs::setCurrentGroup(Fonts); "); 170 // qDebug(" KPrefs::setCurrentGroup(Fonts); ");
171 addItemFont("TimeBar Font",&mTimeBarFont); 171 addItemFont("TimeBar Font",&mTimeBarFont);
172 addItemFont("MonthView Font",&mMonthViewFont); 172 addItemFont("MonthView Font",&mMonthViewFont);
173 addItemFont("AgendaView Font",&mAgendaViewFont); 173 addItemFont("AgendaView Font",&mAgendaViewFont);
174 addItemFont("MarcusBains Font",&mMarcusBainsFont); 174 addItemFont("MarcusBains Font",&mMarcusBainsFont);
175 addItemFont("TimeLabels Font",&mTimeLabelsFont); 175 addItemFont("TimeLabels Font",&mTimeLabelsFont);
176 addItemFont("TodoView Font",&mTodoViewFont); 176 addItemFont("TodoView Font",&mTodoViewFont);
177 addItemFont("ListView Font",&mListViewFont); 177 addItemFont("ListView Font",&mListViewFont);
178 addItemFont("DateNavigator Font",&mDateNavigatorFont); 178 addItemFont("DateNavigator Font",&mDateNavigatorFont);
179 addItemFont("EditBox Font",&mEditBoxFont); 179 addItemFont("EditBox Font",&mEditBoxFont);
180 addItemFont("JournalView Font",&mJornalViewFont); 180 addItemFont("JournalView Font",&mJornalViewFont);
181 addItemFont("WhatsNextView Font",&mWhatsNextFont); 181 addItemFont("WhatsNextView Font",&mWhatsNextFont);
182 addItemFont("EventView Font",&mEventViewFont); 182 addItemFont("EventView Font",&mEventViewFont);
183 183
184// KPrefs::setCurrentGroup("SyncProfiles"); 184// KPrefs::setCurrentGroup("SyncProfiles");
185// addItemString("LocalMachineName",&mLocalMachineName, "undefined"); 185// addItemString("LocalMachineName",&mLocalMachineName, "undefined");
186// addItemStringList("SyncProfileNames",&mSyncProfileNames); 186// addItemStringList("SyncProfileNames",&mSyncProfileNames);
187// addItemStringList("ExternSyncProfiles",&mExternSyncProfileNames); 187// addItemStringList("ExternSyncProfiles",&mExternSyncProfileNames);
188 188
189 KPrefs::setCurrentGroup("RemoteSyncing"); 189 KPrefs::setCurrentGroup("RemoteSyncing");
190// addItemBool("UsePasswd",&mUsePassWd,false); 190// addItemBool("UsePasswd",&mUsePassWd,false);
191// addItemBool("WriteBackFile",&mWriteBackFile,true); 191// addItemBool("WriteBackFile",&mWriteBackFile,true);
192// addItemBool("WriteBackExistingOnly",&mWriteBackExistingOnly,false); 192// addItemBool("WriteBackExistingOnly",&mWriteBackExistingOnly,false);
193// addItemBool("AskForPreferences",&mAskForPreferences,true); 193// addItemBool("AskForPreferences",&mAskForPreferences,true);
194// addItemBool("ShowSyncSummary",&mShowSyncSummary,true); 194// addItemBool("ShowSyncSummary",&mShowSyncSummary,true);
195 addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" ); 195 addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" );
196 addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" ); 196 addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" );
197 addItemBool("ShowSyncEvents",&mShowSyncEvents,false); 197 addItemBool("ShowSyncEvents",&mShowSyncEvents,false);
198 addItemInt("LastSyncTime",&mLastSyncTime,0); 198 addItemInt("LastSyncTime",&mLastSyncTime,0);
199 199
200#ifdef _WIN32_ 200#ifdef _WIN32_
201 QString hdp= locateLocal("data","korganizer")+"\\\\"; 201 QString hdp= locateLocal("data","korganizer")+"\\\\";
202#else 202#else
203 QString hdp= locateLocal("data","korganizer")+"/"; 203 QString hdp= locateLocal("data","korganizer")+"/";
204#endif 204#endif
205// addItemString("RemoteIP",&mRemoteIP, "192.168.0.65");
206// addItemString("RemoteUser",&mRemoteUser, "zaurus");
207// addItemString("RemotePassWd",&mRemotePassWd, "");
208// addItemString("RemoteFile", &mRemoteFile, hdp+"mycalendar.ics");
209// addItemString("LocalTempFile",&mLocalTempFile, "/tmp/tempsyncfile.ics" );
210
211 205
212 KPrefs::setCurrentGroup("LoadSaveFileNames"); 206 KPrefs::setCurrentGroup("LoadSaveFileNames");
213 207
214 addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" ); 208 addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" );
215 addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" ); 209 addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" );
216 addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" ); 210 addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" );
217 addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); 211 addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" );
218 212
219 213
220 KPrefs::setCurrentGroup("Locale"); 214 KPrefs::setCurrentGroup("Locale");
221 addItemInt("PreferredLanguage",&mPreferredLanguage,0); 215 addItemInt("PreferredLanguage",&mPreferredLanguage,0);
222 addItemInt("PreferredTime",&mPreferredTime,0); 216 addItemInt("PreferredTime",&mPreferredTime,0);
223 addItemInt("PreferredDate",&mPreferredDate,0); 217 addItemInt("PreferredDate",&mPreferredDate,0);
224 addItemBool("WeekStartsOnSunday",&mWeekStartsOnSunday,false); 218 addItemBool("WeekStartsOnSunday",&mWeekStartsOnSunday,false);
225 addItemBool("ShortDateInViewer",&mShortDateInViewer,false); 219 addItemBool("ShortDateInViewer",&mShortDateInViewer,false);
226 addItemString("UserDateFormatLong", &mUserDateFormatLong, "%A %d %b %y"); 220 addItemString("UserDateFormatLong", &mUserDateFormatLong, "%A %d %b %y");
227 addItemString("UserDateFormatShort", &mUserDateFormatShort, "%aK %d.%m.%y"); 221 addItemString("UserDateFormatShort", &mUserDateFormatShort, "%aK %d.%m.%y");
228 222
229 223
230 KPrefs::setCurrentGroup("Colors"); 224 KPrefs::setCurrentGroup("Colors");
231 addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor); 225 addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor);
232 addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor); 226 addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor);
233 addItemColor("Event Color",&mEventColor,mDefaultCategoryColor); 227 addItemColor("Event Color",&mEventColor,mDefaultCategoryColor);
234 addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor); 228 addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor);
235 addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor); 229 addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor);
236 addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor); 230 addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor);
237 addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor); 231 addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor);
238 addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 )); 232 addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 ));
239 addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 )); 233 addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 ));
240 addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 )); 234 addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 ));
241 addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true); 235 addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true);
242 addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true); 236 addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true);
243 addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false); 237 addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false);
244 addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 )); 238 addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 ));
245 addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 )); 239 addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 ));
246 addItemBool("UseAppColors",&mUseAppColors,false); 240 addItemBool("UseAppColors",&mUseAppColors,false);
247 241
248 242
249 243
250 KPrefs::setCurrentGroup("Views"); 244 KPrefs::setCurrentGroup("Views");
251 addItemInt("Hour Size",&mHourSize,8); 245 addItemInt("Hour Size",&mHourSize,8);
252 addItemBool("Show Daily Recurrences",&mDailyRecur,true); 246 addItemBool("Show Daily Recurrences",&mDailyRecur,true);
253 addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true); 247 addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true);
254 addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true); 248 addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true);
255 addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true); 249 addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true);
256 addItemBool("ShowShortMonthName",&mMonthShowShort,false); 250 addItemBool("ShowShortMonthName",&mMonthShowShort,false);
257 addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true); 251 addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true);
258 addItemBool("Enable ToolTips",&mEnableToolTips,false); 252 addItemBool("Enable ToolTips",&mEnableToolTips,false);
259 addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false); 253 addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false);
260 addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false); 254 addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false);
261 addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true); 255 addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true);
262 addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true); 256 addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true);
263 addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,false); 257 addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,false);
264 addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false); 258 addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false);
265 addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false); 259 addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false);
266 addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true); 260 addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true);
267 addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true); 261 addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true);
268 addItemBool("WNViewShowsParents",&mWNViewShowsParents,true); 262 addItemBool("WNViewShowsParents",&mWNViewShowsParents,true);
269 addItemBool("WNViewShowLocation",&mWNViewShowLocation,false); 263 addItemBool("WNViewShowLocation",&mWNViewShowLocation,false);
270 addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false); 264 addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false);
271 addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true); 265 addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true);
272 addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false); 266 addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false);
273 addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false); 267 addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false);
274 addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,false); 268 addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,false);
275 addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false); 269 addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false);
276 addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false); 270 addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false);
277#ifdef DESKTOP_VERSION 271#ifdef DESKTOP_VERSION
278 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true); 272 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true);
279#else 273#else
280 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false); 274 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false);
281#endif 275#endif
282 addItemInt("Day Begins",&mDayBegins,7); 276 addItemInt("Day Begins",&mDayBegins,7);
283 addItemInt("Working Hours Start",&mWorkingHoursStart,8); 277 addItemInt("Working Hours Start",&mWorkingHoursStart,8);
284 addItemInt("Working Hours End",&mWorkingHoursEnd,17); 278 addItemInt("Working Hours End",&mWorkingHoursEnd,17);
285 addItemBool("Exclude Holidays",&mExcludeHolidays,true); 279 addItemBool("Exclude Holidays",&mExcludeHolidays,true);
286 addItemBool("Exclude Saturdays",&mExcludeSaturdays,true); 280 addItemBool("Exclude Saturdays",&mExcludeSaturdays,true);
287 281
288 addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false); 282 addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false);
289 addItemBool("Full View Month",&mFullViewMonth,true); 283 addItemBool("Full View Month",&mFullViewMonth,true);
290 addItemBool("Full View Todo",&mFullViewTodo,true); 284 addItemBool("Full View Todo",&mFullViewTodo,true);
291 addItemBool("Quick Todo",&mEnableQuickTodo,false); 285 addItemBool("Quick Todo",&mEnableQuickTodo,false);
292 286
293 addItemInt("Next X Days",&mNextXDays,3); 287 addItemInt("Next X Days",&mNextXDays,3);
294 288
295 KPrefs::setCurrentGroup("Printer"); 289 KPrefs::setCurrentGroup("Printer");
296 290
297 KPrefs::setCurrentGroup("Layout"); 291 KPrefs::setCurrentGroup("Layout");
298 292
299 addItemBool("CompactDialogs",&mCompactDialogs,false); 293 addItemBool("CompactDialogs",&mCompactDialogs,false);
300 addItemBool("VerticalScreen",&mVerticalScreen,true); 294 addItemBool("VerticalScreen",&mVerticalScreen,true);
301 295
302 KPrefs::setCurrentGroup("KOrganizer Plugins"); 296 KPrefs::setCurrentGroup("KOrganizer Plugins");
303 297
304 addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays"); 298 addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays");
305 299
306 KPrefs::setCurrentGroup("Group Scheduling"); 300 KPrefs::setCurrentGroup("Group Scheduling");
307 301
308 addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail); 302 addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail);
309 addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend); 303 addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend);
310 addItemStringList("AdditionalMails",&mAdditionalMails,""); 304 addItemStringList("AdditionalMails",&mAdditionalMails,"");
311 addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto); 305 addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto);
312 addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto); 306 addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto);
313 addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto); 307 addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto);
314 addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto); 308 addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto);
315 addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto); 309 addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto);
316 310
317 KPrefs::setCurrentGroup( "Editors" ); 311 KPrefs::setCurrentGroup( "Editors" );
318 312
319 addItemStringList( "EventTemplates", &mEventTemplates ); 313 addItemStringList( "EventTemplates", &mEventTemplates );
320 addItemStringList( "TodoTemplates", &mTodoTemplates ); 314 addItemStringList( "TodoTemplates", &mTodoTemplates );
321 315
322 addItemInt("DestinationPolicy",&mDestination,standardDestination); 316 addItemInt("DestinationPolicy",&mDestination,standardDestination);
323 317
324 318
325 319
326} 320}
327 321
328 322
329KOPrefs::~KOPrefs() 323KOPrefs::~KOPrefs()
330{ 324{
331 if (mInstance == this) 325 if (mInstance == this)
332 mInstance = insd.setObject(0); 326 mInstance = insd.setObject(0);
333 setLocaleDict( 0 ); 327 setLocaleDict( 0 );
334 if ( mLocaleDict ) 328 if ( mLocaleDict )
335 delete mLocaleDict; 329 delete mLocaleDict;
336 //qDebug("KOPrefs::~KOPrefs() "); 330 //qDebug("KOPrefs::~KOPrefs() ");
337} 331}
338 332
339 333
340KOPrefs *KOPrefs::instance() 334KOPrefs *KOPrefs::instance()
341{ 335{
342 if (!mInstance) { 336 if (!mInstance) {
343 mInstance = insd.setObject(new KOPrefs()); 337 mInstance = insd.setObject(new KOPrefs());
344 mInstance->readConfig(); 338 mInstance->readConfig();
345 } 339 }
346 340
347 return mInstance; 341 return mInstance;
348} 342}
349 343
350void KOPrefs::usrSetDefaults() 344void KOPrefs::usrSetDefaults()
351{ 345{
352 346
353} 347}
354 348
355void KOPrefs::fillMailDefaults() 349void KOPrefs::fillMailDefaults()
356{ 350{
357 if (mName.isEmpty()) mName = i18n("Anonymous"); 351 if (mName.isEmpty()) mName = i18n("Anonymous");
358 if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); 352 if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere");
359} 353}
360 354
361void KOPrefs::setTimeZoneIdDefault() 355void KOPrefs::setTimeZoneIdDefault()
362{ 356{
363 mTimeZoneId = i18n("+01:00 Europe/Oslo(CET)"); 357 mTimeZoneId = i18n("+01:00 Europe/Oslo(CET)");
364} 358}
365 359
366void KOPrefs::setCategoryDefaults() 360void KOPrefs::setCategoryDefaults()
367{ 361{
368 mCustomCategories.clear(); 362 mCustomCategories.clear();
369 mCustomCategories = getDefaultList(); 363 mCustomCategories = getDefaultList();
370 364
371 QStringList::Iterator it; 365 QStringList::Iterator it;
372 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { 366 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) {
373 setCategoryColor(*it,mDefaultCategoryColor); 367 setCategoryColor(*it,mDefaultCategoryColor);
374 } 368 }
375} 369}
376 370
377QStringList KOPrefs::getDefaultList() 371QStringList KOPrefs::getDefaultList()
378{ 372{
379 QStringList retval ; 373 QStringList retval ;
380 retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Business Travel") << i18n("Cinema") << i18n("Customer") 374 retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Business Travel") << i18n("Cinema") << i18n("Customer")
381 << i18n("Break")<< i18n("Breakfast")<< i18n("Competition")<< i18n("Dinner") 375 << i18n("Break")<< i18n("Breakfast")<< i18n("Competition")<< i18n("Dinner")
382 << i18n("Education")<< i18n("Family") << i18n("Favorites") << i18n("Festival")<< i18n("Fishing")<< i18n("Flight") << i18n("Gifts") 376 << i18n("Education")<< i18n("Family") << i18n("Favorites") << i18n("Festival")<< i18n("Fishing")<< i18n("Flight") << i18n("Gifts")
383 << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") << i18n("Hiking") << i18n("Hunting") << i18n("Key Customer") << i18n("Kids") 377 << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") << i18n("Hiking") << i18n("Hunting") << i18n("Key Customer") << i18n("Kids")
384 << i18n("Lunch") << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner")<< i18n("Party") << i18n("Personal") << i18n("Personal Travel") 378 << i18n("Lunch") << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner")<< i18n("Party") << i18n("Personal") << i18n("Personal Travel")
385 << i18n("PHB") << i18n("Phone Calls") << i18n("Projects") << i18n("Recurring") << i18n("School") << i18n("Shopping") 379 << i18n("PHB") << i18n("Phone Calls") << i18n("Projects") << i18n("Recurring") << i18n("School") << i18n("Shopping")
386 << i18n("Speach") << i18n("Special Occasion") << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV")<< i18n("University") 380 << i18n("Speach") << i18n("Special Occasion") << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV")<< i18n("University")
387 << i18n("Vacation") << i18n("VIP") << i18n("SyncEvent") ; 381 << i18n("Vacation") << i18n("VIP") << i18n("SyncEvent") ;
388 retval.sort(); 382 retval.sort();
389 return retval; 383 return retval;
390} 384}
391 385
392void KOPrefs::usrReadConfig() 386void KOPrefs::usrReadConfig()
393{ 387{
394 mPreferredLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage; 388 mPreferredLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage;
395 mLocaleDict = 0; 389 mLocaleDict = 0;
396 // pending LR fix translation 390 // pending LR fix translation
397 // qDebug("KOPrefs::usrReadConfig() fix translation "); 391 // qDebug("KOPrefs::usrReadConfig() fix translation ");
398 if ( mPreferredLanguage > 0 && mPreferredLanguage < 5 ) { 392 if ( mPreferredLanguage > 0 && mPreferredLanguage < 5 ) {
399 if ( mPreferredLanguage == 1 ) { 393 if ( mPreferredLanguage == 1 ) {
400 mLocaleDict = new QDict<QString>; 394 mLocaleDict = new QDict<QString>;
401 int i = 0; 395 int i = 0;
402 QString fw ( germanwords[i] [0]); 396 QString fw ( germanwords[i] [0]);
403 while ( !fw.isEmpty() ) { 397 while ( !fw.isEmpty() ) {
404 mLocaleDict->insert( fw, new QString (germanwords[i] [1] )); 398 mLocaleDict->insert( fw, new QString (germanwords[i] [1] ));
405 ++i; 399 ++i;
406 fw = germanwords[i] [0]; 400 fw = germanwords[i] [0];
407 } 401 }
408 402
409 setLocaleDict( mLocaleDict ); 403 setLocaleDict( mLocaleDict );
410 } else { 404 } else {
411 QString fileName ; 405 QString fileName ;
412 if ( mPreferredLanguage == 4 ) 406 if ( mPreferredLanguage == 4 )
413 fileName = MainWindow::resourcePath()+"usertranslation.txt"; 407 fileName = MainWindow::resourcePath()+"usertranslation.txt";
414 else if ( mPreferredLanguage == 2 ) 408 else if ( mPreferredLanguage == 2 )
415 fileName = MainWindow::resourcePath()+"frenchtranslation.txt"; 409 fileName = MainWindow::resourcePath()+"frenchtranslation.txt";
416 else if ( mPreferredLanguage == 3 ) 410 else if ( mPreferredLanguage == 3 )
417 fileName = MainWindow::resourcePath()+"italiantranslation.txt"; 411 fileName = MainWindow::resourcePath()+"italiantranslation.txt";
418 QFile file( fileName ); 412 QFile file( fileName );
419 if (file.open( IO_ReadOnly ) ) { 413 if (file.open( IO_ReadOnly ) ) {
420 QTextStream ts( &file ); 414 QTextStream ts( &file );
421 ts.setEncoding( QTextStream::Latin1 ); 415 ts.setEncoding( QTextStream::Latin1 );
422 //ts.setCodec( QTextCodec::latin1 ); 416 //ts.setCodec( QTextCodec::latin1 );
423 QString text = ts.read(); 417 QString text = ts.read();
424 file.close(); 418 file.close();
425 text.replace( QRegExp("\\\\n"), "\n" ); 419 text.replace( QRegExp("\\\\n"), "\n" );
426 QString line; 420 QString line;
427 QString we; 421 QString we;
428 QString wt; 422 QString wt;
429 int br = 0; 423 int br = 0;
430 int nbr; 424 int nbr;
431 nbr = text.find ( "},", br ); 425 nbr = text.find ( "},", br );
432 line = text.mid( br, nbr - br ); 426 line = text.mid( br, nbr - br );
433 br = nbr+1; 427 br = nbr+1;
434 int se, ee, st, et; 428 int se, ee, st, et;
435 mLocaleDict = new QDict<QString>; 429 mLocaleDict = new QDict<QString>;
436 QString end = "{ \"\",\"\" }"; 430 QString end = "{ \"\",\"\" }";
437 while ( (line != end) && (br > 1) ) { 431 while ( (line != end) && (br > 1) ) {
438 //qDebug("%d *%s* ", br, line.latin1()); 432 //qDebug("%d *%s* ", br, line.latin1());
439 se = line.find("\"")+1; 433 se = line.find("\"")+1;
440 et = line.findRev("\"",-1); 434 et = line.findRev("\"",-1);
441 ee = line.find("\",\""); 435 ee = line.find("\",\"");
442 st = ee+3; 436 st = ee+3;
443 we = line.mid( se, ee-se ); 437 we = line.mid( se, ee-se );
444 wt = line.mid( st, et-st ); 438 wt = line.mid( st, et-st );
445 //qDebug("*%s* *%s* ", we.latin1(), wt.latin1()); 439 //qDebug("*%s* *%s* ", we.latin1(), wt.latin1());
446 mLocaleDict->insert( we, new QString (wt) ); 440 mLocaleDict->insert( we, new QString (wt) );
447 nbr = text.find ( "}", br ); 441 nbr = text.find ( "}", br );
448 line = text.mid( br, nbr - br ); 442 line = text.mid( br, nbr - br );
449 br = nbr+1; 443 br = nbr+1;
450 } 444 }
451 //qDebug("end *%s* ", end.latin1()); 445 //qDebug("end *%s* ", end.latin1());
452 446
453 setLocaleDict( mLocaleDict ); 447 setLocaleDict( mLocaleDict );
454 } else { 448 } else {
455 qDebug("KO: Cannot find translation file %s",fileName.latin1() ); 449 qDebug("KO: Cannot find translation file %s",fileName.latin1() );
456 } 450 }
457 451
458 } 452 }
459 } 453 }
460 config()->setGroup("General"); 454 config()->setGroup("General");
461 455
462 mCustomCategories = config()->readListEntry("Custom Categories"); 456 mCustomCategories = config()->readListEntry("Custom Categories");
463 if ( KOPrefs::instance()->mLanguageChanged ) { 457 if ( KOPrefs::instance()->mLanguageChanged ) {
464 mLocationDefaults.clear(); 458 mLocationDefaults.clear();
465 mEventSummaryUser.clear(); 459 mEventSummaryUser.clear();
466 mTodoSummaryUser.clear(); 460 mTodoSummaryUser.clear();
467 } 461 }
468 if (mLocationDefaults.isEmpty()) { 462 if (mLocationDefaults.isEmpty()) {
469 mLocationDefaults << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach") 463 mLocationDefaults << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach")
470 << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten") 464 << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten")
471 << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ; 465 << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ;
472 // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") 466 // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("")
473 mLocationDefaults.sort(); 467 mLocationDefaults.sort();
474 } 468 }
475 469
476 if (mEventSummaryUser.isEmpty()) { 470 if (mEventSummaryUser.isEmpty()) {
477 mEventSummaryUser = getDefaultList() ; 471 mEventSummaryUser = getDefaultList() ;
478 } 472 }
479 if (mTodoSummaryUser.isEmpty()) { 473 if (mTodoSummaryUser.isEmpty()) {
480 mTodoSummaryUser = getDefaultList() ; 474 mTodoSummaryUser = getDefaultList() ;
481 } 475 }
482 476
483 if (mCustomCategories.isEmpty()) setCategoryDefaults(); 477 if (mCustomCategories.isEmpty()) setCategoryDefaults();
484 478
485 config()->setGroup("Personal Settings"); 479 config()->setGroup("Personal Settings");
486 mName = config()->readEntry("user_name",""); 480 mName = config()->readEntry("user_name","");
487 mEmail = config()->readEntry("user_email",""); 481 mEmail = config()->readEntry("user_email","");
488 fillMailDefaults(); 482 fillMailDefaults();
489 483
490 config()->setGroup("Category Colors"); 484 config()->setGroup("Category Colors");
491 QStringList::Iterator it; 485 QStringList::Iterator it;
492 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { 486 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) {
493 setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor)); 487 setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor));
494 488
495 } 489 }
496 490
497 if (mTimeZoneId.isEmpty()) { 491 if (mTimeZoneId.isEmpty()) {
498 setTimeZoneIdDefault(); 492 setTimeZoneIdDefault();
499 } 493 }
500 KPimPrefs::usrReadConfig(); 494 KPimPrefs::usrReadConfig();
501} 495}
502 496
503 497
504void KOPrefs::usrWriteConfig() 498void KOPrefs::usrWriteConfig()
505{ 499{
506 config()->setGroup("General"); 500 config()->setGroup("General");
507 config()->writeEntry("Custom Categories",mCustomCategories); 501 config()->writeEntry("Custom Categories",mCustomCategories);
508 502
509 config()->setGroup("Personal Settings"); 503 config()->setGroup("Personal Settings");
510 config()->writeEntry("user_name",mName); 504 config()->writeEntry("user_name",mName);
511 config()->writeEntry("user_email",mEmail); 505 config()->writeEntry("user_email",mEmail);
512 506
513 config()->setGroup("Category Colors"); 507 config()->setGroup("Category Colors");
514 QDictIterator<QColor> it(mCategoryColors); 508 QDictIterator<QColor> it(mCategoryColors);
515 while (it.current()) { 509 while (it.current()) {
516 config()->writeEntry(it.currentKey(),*(it.current())); 510 config()->writeEntry(it.currentKey(),*(it.current()));
517 ++it; 511 ++it;
518 } 512 }
519 513
520 514
521 KPimPrefs::usrWriteConfig(); 515 KPimPrefs::usrWriteConfig();
522} 516}
523 517
524void KOPrefs::setCategoryColor(QString cat,const QColor & color) 518void KOPrefs::setCategoryColor(QString cat,const QColor & color)
525{ 519{
526 mCategoryColors.replace(cat,new QColor(color)); 520 mCategoryColors.replace(cat,new QColor(color));
527} 521}
528 522
529QColor *KOPrefs::categoryColor(QString cat) 523QColor *KOPrefs::categoryColor(QString cat)
530{ 524{
531 QColor *color = 0; 525 QColor *color = 0;
532 526
533 if (!cat.isEmpty()) color = mCategoryColors[cat]; 527 if (!cat.isEmpty()) color = mCategoryColors[cat];
534 528
535 if (color) return color; 529 if (color) return color;
536 else return &mDefaultCategoryColor; 530 else return &mDefaultCategoryColor;
537} 531}
538 532
539void KOPrefs::setFullName(const QString &name) 533void KOPrefs::setFullName(const QString &name)
540{ 534{
541 mName = name; 535 mName = name;
542} 536}
543 537
544void KOPrefs::setEmail(const QString &email) 538void KOPrefs::setEmail(const QString &email)
545{ 539{
546 //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() ); 540 //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() );
547 mEmail = email; 541 mEmail = email;
548} 542}
549 543
550QString KOPrefs::fullName() 544QString KOPrefs::fullName()
551{ 545{
552 if (mEmailControlCenter) { 546 if (mEmailControlCenter) {
553 KEMailSettings settings; 547 KEMailSettings settings;
554 return settings.getSetting(KEMailSettings::RealName); 548 return settings.getSetting(KEMailSettings::RealName);
555 } else { 549 } else {
556 return mName; 550 return mName;
557 } 551 }
558} 552}
559 553
560QString KOPrefs::email() 554QString KOPrefs::email()
561{ 555{
562 if (mEmailControlCenter) { 556 if (mEmailControlCenter) {
563 KEMailSettings settings; 557 KEMailSettings settings;
564 return settings.getSetting(KEMailSettings::EmailAddress); 558 return settings.getSetting(KEMailSettings::EmailAddress);
565 } else { 559 } else {
566 return mEmail; 560 return mEmail;
567 } 561 }
568} 562}
569KConfig* KOPrefs::getConfig() 563KConfig* KOPrefs::getConfig()
570{ 564{
571 return config(); 565 return config();
572} 566}
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 06470b8..c3e9f75 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1,1825 +1,1825 @@
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 <qpushbutton.h> 7#include <qpushbutton.h>
8#include <qmessagebox.h> 8#include <qmessagebox.h>
9#include <qlineedit.h> 9#include <qlineedit.h>
10#include <qtextcodec.h> 10#include <qtextcodec.h>
11#include <qfile.h> 11#include <qfile.h>
12#include <qdir.h> 12#include <qdir.h>
13#include <qapp.h> 13#include <qapp.h>
14#include <qfileinfo.h> 14#include <qfileinfo.h>
15#include <qlabel.h> 15#include <qlabel.h>
16#include <qspinbox.h> 16#include <qspinbox.h>
17#include <qcheckbox.h> 17#include <qcheckbox.h>
18#include <qmap.h> 18#include <qmap.h>
19#include <qwmatrix.h> 19#include <qwmatrix.h>
20#include <qtextbrowser.h> 20#include <qtextbrowser.h>
21#include <qtextstream.h> 21#include <qtextstream.h>
22#ifndef DESKTOP_VERSION 22#ifndef DESKTOP_VERSION
23#include <qpe/global.h> 23#include <qpe/global.h>
24#include <qpe/qpemenubar.h> 24#include <qpe/qpemenubar.h>
25#include <qpe/qpetoolbar.h> 25#include <qpe/qpetoolbar.h>
26#include <qpe/resource.h> 26#include <qpe/resource.h>
27#include <qpe/qpeapplication.h> 27#include <qpe/qpeapplication.h>
28#include <qtopia/alarmserver.h> 28#include <qtopia/alarmserver.h>
29#include <qtopia/qcopenvelope_qws.h> 29#include <qtopia/qcopenvelope_qws.h>
30#include <unistd.h> // for sleep 30#include <unistd.h> // for sleep
31#else 31#else
32#include <qmenubar.h> 32#include <qmenubar.h>
33#include <qtoolbar.h> 33#include <qtoolbar.h>
34#include <qapplication.h> 34#include <qapplication.h>
35//#include <resource.h> 35//#include <resource.h>
36 36
37#endif 37#endif
38#include <libkcal/calendarlocal.h> 38#include <libkcal/calendarlocal.h>
39#include <libkcal/todo.h> 39#include <libkcal/todo.h>
40#include <libkcal/phoneformat.h> 40#include <libkcal/phoneformat.h>
41#include <libkdepim/ksyncprofile.h> 41#include <libkdepim/ksyncprofile.h>
42#include <libkdepim/phoneaccess.h> 42#include <libkdepim/phoneaccess.h>
43#include <libkcal/kincidenceformatter.h> 43#include <libkcal/kincidenceformatter.h>
44#include <libkdepim/kpimglobalprefs.h> 44#include <libkdepim/kpimglobalprefs.h>
45 45
46#include "calendarview.h" 46#include "calendarview.h"
47#include "koviewmanager.h" 47#include "koviewmanager.h"
48#include "datenavigator.h" 48#include "datenavigator.h"
49#include "koagendaview.h" 49#include "koagendaview.h"
50#include "koagenda.h" 50#include "koagenda.h"
51#include "kodialogmanager.h" 51#include "kodialogmanager.h"
52#include "kdialogbase.h" 52#include "kdialogbase.h"
53#include "kapplication.h" 53#include "kapplication.h"
54#include "kofilterview.h" 54#include "kofilterview.h"
55#include "kstandarddirs.h" 55#include "kstandarddirs.h"
56#include "koprefs.h" 56#include "koprefs.h"
57#include "kfiledialog.h" 57#include "kfiledialog.h"
58#include "koglobals.h" 58#include "koglobals.h"
59#include "kglobal.h" 59#include "kglobal.h"
60#include "klocale.h" 60#include "klocale.h"
61#include "kconfig.h" 61#include "kconfig.h"
62#include "simplealarmclient.h" 62#include "simplealarmclient.h"
63#include "externalapphandler.h" 63#include "externalapphandler.h"
64 64
65using namespace KCal; 65using namespace KCal;
66#ifndef _WIN32_ 66#ifndef _WIN32_
67#include <unistd.h> 67#include <unistd.h>
68#else 68#else
69#include "koimportoldialog.h" 69#include "koimportoldialog.h"
70#endif 70#endif
71#include "mainwindow.h" 71#include "mainwindow.h"
72 72
73class KOex2phonePrefs : public QDialog 73class KOex2phonePrefs : public QDialog
74{ 74{
75 public: 75 public:
76 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 76 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
77 QDialog( parent, name, true ) 77 QDialog( parent, name, true )
78 { 78 {
79 setCaption( i18n("Export to phone options") ); 79 setCaption( i18n("Export to phone options") );
80 QVBoxLayout* lay = new QVBoxLayout( this ); 80 QVBoxLayout* lay = new QVBoxLayout( this );
81 lay->setSpacing( 3 ); 81 lay->setSpacing( 3 );
82 lay->setMargin( 3 ); 82 lay->setMargin( 3 );
83 QLabel *lab; 83 QLabel *lab;
84 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 84 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
85 lab->setAlignment (AlignHCenter ); 85 lab->setAlignment (AlignHCenter );
86 QHBox* temphb; 86 QHBox* temphb;
87 temphb = new QHBox( this ); 87 temphb = new QHBox( this );
88 new QLabel( i18n("I/O device: "), temphb ); 88 new QLabel( i18n("I/O device: "), temphb );
89 mPhoneDevice = new QLineEdit( temphb); 89 mPhoneDevice = new QLineEdit( temphb);
90 lay->addWidget( temphb ); 90 lay->addWidget( temphb );
91 temphb = new QHBox( this ); 91 temphb = new QHBox( this );
92 new QLabel( i18n("Connection: "), temphb ); 92 new QLabel( i18n("Connection: "), temphb );
93 mPhoneConnection = new QLineEdit( temphb); 93 mPhoneConnection = new QLineEdit( temphb);
94 lay->addWidget( temphb ); 94 lay->addWidget( temphb );
95 temphb = new QHBox( this ); 95 temphb = new QHBox( this );
96 new QLabel( i18n("Model(opt.): "), temphb ); 96 new QLabel( i18n("Model(opt.): "), temphb );
97 mPhoneModel = new QLineEdit( temphb); 97 mPhoneModel = new QLineEdit( temphb);
98 lay->addWidget( temphb ); 98 lay->addWidget( temphb );
99 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); 99 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this );
100 mWriteBackFuture->setChecked( true ); 100 mWriteBackFuture->setChecked( true );
101 lay->addWidget( mWriteBackFuture ); 101 lay->addWidget( mWriteBackFuture );
102 temphb = new QHBox( this ); 102 temphb = new QHBox( this );
103 new QLabel( i18n("Max. weeks in future: ") , temphb ); 103 new QLabel( i18n("Max. weeks in future: ") , temphb );
104 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); 104 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb);
105 mWriteBackFutureWeeks->setValue( 8 ); 105 mWriteBackFutureWeeks->setValue( 8 );
106 lay->addWidget( temphb ); 106 lay->addWidget( temphb );
107 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); 107 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) );
108 lab->setAlignment (AlignHCenter ); 108 lab->setAlignment (AlignHCenter );
109 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 109 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
110 lay->addWidget( ok ); 110 lay->addWidget( ok );
111 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 111 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
112 lay->addWidget( cancel ); 112 lay->addWidget( cancel );
113 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 113 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
114 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 114 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
115 resize( 220, 240 ); 115 resize( 220, 240 );
116 116
117 } 117 }
118 118
119public: 119public:
120 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 120 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
121 QCheckBox* mWriteBackFuture; 121 QCheckBox* mWriteBackFuture;
122 QSpinBox* mWriteBackFutureWeeks; 122 QSpinBox* mWriteBackFutureWeeks;
123}; 123};
124 124
125int globalFlagBlockStartup; 125int globalFlagBlockStartup;
126MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : 126MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
127 QMainWindow( parent, name ) 127 QMainWindow( parent, name )
128{ 128{
129 129
130#ifdef DESKTOP_VERSION 130#ifdef DESKTOP_VERSION
131 setFont( QFont("Arial"), 14 ); 131 setFont( QFont("Arial"), 14 );
132#endif 132#endif
133 mClosed = false; 133 mClosed = false;
134 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; 134 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
135 QString confFile = locateLocal("config","korganizerrc"); 135 QString confFile = locateLocal("config","korganizerrc");
136 QFileInfo finf ( confFile ); 136 QFileInfo finf ( confFile );
137 bool showWarning = !finf.exists(); 137 bool showWarning = !finf.exists();
138 setIcon(SmallIcon( "ko24" ) ); 138 setIcon(SmallIcon( "ko24" ) );
139 mBlockAtStartup = true; 139 mBlockAtStartup = true;
140 mFlagKeyPressed = false; 140 mFlagKeyPressed = false;
141 setCaption("KOrganizer/Pi"); 141 setCaption("KOrganizer/Pi");
142 KOPrefs *p = KOPrefs::instance(); 142 KOPrefs *p = KOPrefs::instance();
143 KPimGlobalPrefs::instance()->setGlobalConfig(); 143 KPimGlobalPrefs::instance()->setGlobalConfig();
144 if ( p->mHourSize > 18 ) 144 if ( p->mHourSize > 18 )
145 p->mHourSize = 18; 145 p->mHourSize = 18;
146 QMainWindow::ToolBarDock tbd; 146 QMainWindow::ToolBarDock tbd;
147 if ( p->mToolBarHor ) { 147 if ( p->mToolBarHor ) {
148 if ( p->mToolBarUp ) 148 if ( p->mToolBarUp )
149 tbd = Bottom; 149 tbd = Bottom;
150 else 150 else
151 tbd = Top; 151 tbd = Top;
152 } 152 }
153 else { 153 else {
154 if ( p->mToolBarUp ) 154 if ( p->mToolBarUp )
155 tbd = Right; 155 tbd = Right;
156 else 156 else
157 tbd = Left; 157 tbd = Left;
158 } 158 }
159 if ( KOPrefs::instance()->mUseAppColors ) 159 if ( KOPrefs::instance()->mUseAppColors )
160 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 160 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
161 globalFlagBlockStartup = 1; 161 globalFlagBlockStartup = 1;
162 iconToolBar = new QPEToolBar( this ); 162 iconToolBar = new QPEToolBar( this );
163 addToolBar (iconToolBar , tbd ); 163 addToolBar (iconToolBar , tbd );
164 mCalendarModifiedFlag = false; 164 mCalendarModifiedFlag = false;
165 165
166 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); 166 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
167 splash->setAlignment ( AlignCenter ); 167 splash->setAlignment ( AlignCenter );
168 setCentralWidget( splash ); 168 setCentralWidget( splash );
169#ifndef DESKTOP_VERSION 169#ifndef DESKTOP_VERSION
170 showMaximized(); 170 showMaximized();
171#endif 171#endif
172 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); 172 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
173 setDefaultPreferences(); 173 setDefaultPreferences();
174 mCalendar = new CalendarLocal(); 174 mCalendar = new CalendarLocal();
175 mView = new CalendarView( mCalendar, this,"mCalendar " ); 175 mView = new CalendarView( mCalendar, this,"mCalendar " );
176 mView->hide(); 176 mView->hide();
177 //mView->resize(splash->size() ); 177 //mView->resize(splash->size() );
178 initActions(); 178 initActions();
179 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); 179 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu);
180 mSyncManager->setBlockSave(false); 180 mSyncManager->setBlockSave(false);
181 mView->setSyncManager(mSyncManager); 181 mView->setSyncManager(mSyncManager);
182#ifndef DESKTOP_VERSION 182#ifndef DESKTOP_VERSION
183 iconToolBar->show(); 183 iconToolBar->show();
184 qApp->processEvents(); 184 qApp->processEvents();
185#endif 185#endif
186 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); 186 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
187 int vh = height() ; 187 int vh = height() ;
188 int vw = width(); 188 int vw = width();
189 //qDebug("Toolbar hei %d ",iconToolBar->height() ); 189 //qDebug("Toolbar hei %d ",iconToolBar->height() );
190 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 190 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
191 vh -= iconToolBar->height(); 191 vh -= iconToolBar->height();
192 } else { 192 } else {
193 vw -= iconToolBar->height(); 193 vw -= iconToolBar->height();
194 } 194 }
195 //mView->setMaximumSize( splash->size() ); 195 //mView->setMaximumSize( splash->size() );
196 //mView->resize( splash->size() ); 196 //mView->resize( splash->size() );
197 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 197 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
198 mView->readSettings(); 198 mView->readSettings();
199 bool newFile = false; 199 bool newFile = false;
200 if( !QFile::exists( defaultFileName() ) ) { 200 if( !QFile::exists( defaultFileName() ) ) {
201 QFileInfo finfo ( defaultFileName() ); 201 QFileInfo finfo ( defaultFileName() );
202 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); 202 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
203 qDebug("oldfile %s ", oldFile.latin1()); 203 qDebug("oldfile %s ", oldFile.latin1());
204 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"; 204 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";
205 finfo.setFile( oldFile ); 205 finfo.setFile( oldFile );
206 if (finfo.exists() ) { 206 if (finfo.exists() ) {
207 KMessageBox::information( this, message); 207 KMessageBox::information( this, message);
208 mView->openCalendar( oldFile ); 208 mView->openCalendar( oldFile );
209 qApp->processEvents(); 209 qApp->processEvents();
210 } else { 210 } else {
211 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); 211 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
212 finfo.setFile( oldFile ); 212 finfo.setFile( oldFile );
213 if (finfo.exists() ) { 213 if (finfo.exists() ) {
214 KMessageBox::information( this, message); 214 KMessageBox::information( this, message);
215 mView->openCalendar( oldFile ); 215 mView->openCalendar( oldFile );
216 qApp->processEvents(); 216 qApp->processEvents();
217 } 217 }
218 } 218 }
219 mView->saveCalendar( defaultFileName() ); 219 mView->saveCalendar( defaultFileName() );
220 newFile = true; 220 newFile = true;
221 } 221 }
222 222
223 QTime neededSaveTime = QDateTime::currentDateTime().time(); 223 QTime neededSaveTime = QDateTime::currentDateTime().time();
224 mView->openCalendar( defaultFileName() ); 224 mView->openCalendar( defaultFileName() );
225 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 225 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
226 qDebug("KO: Calendar loading time: %d ms",msNeeded ); 226 qDebug("KO: Calendar loading time: %d ms",msNeeded );
227 227
228 if ( KOPrefs::instance()->mLanguageChanged ) { 228 if ( KOPrefs::instance()->mLanguageChanged ) {
229 KOPrefs::instance()->setCategoryDefaults(); 229 KOPrefs::instance()->setCategoryDefaults();
230 int count = mView->addCategories(); 230 int count = mView->addCategories();
231 KOPrefs::instance()->mLanguageChanged = false; 231 KOPrefs::instance()->mLanguageChanged = false;
232 } 232 }
233 processIncidenceSelection( 0 ); 233 processIncidenceSelection( 0 );
234 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), 234 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
235 SLOT( processIncidenceSelection( Incidence * ) ) ); 235 SLOT( processIncidenceSelection( Incidence * ) ) );
236 connect( mView, SIGNAL( modifiedChanged( bool ) ), 236 connect( mView, SIGNAL( modifiedChanged( bool ) ),
237 SLOT( slotModifiedChanged( bool ) ) ); 237 SLOT( slotModifiedChanged( bool ) ) );
238 238
239 239
240 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); 240 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
241 mView->setModified( false ); 241 mView->setModified( false );
242 mBlockAtStartup = false; 242 mBlockAtStartup = false;
243 mView->setModified( false ); 243 mView->setModified( false );
244 setCentralWidget( mView ); 244 setCentralWidget( mView );
245 globalFlagBlockStartup = 0; 245 globalFlagBlockStartup = 0;
246 mView->show(); 246 mView->show();
247 delete splash; 247 delete splash;
248 if ( newFile ) 248 if ( newFile )
249 mView->updateConfig(); 249 mView->updateConfig();
250 // qApp->processEvents(); 250 // qApp->processEvents();
251 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 251 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
252 //fillSyncMenu(); 252 //fillSyncMenu();
253 253
254 254
255 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); 255 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) );
256 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 256 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
257 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 257 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
258 mSyncManager->setDefaultFileName( defaultFileName()); 258 mSyncManager->setDefaultFileName( defaultFileName());
259 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); 259 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) );
260 mSyncManager->fillSyncMenu(); 260 mSyncManager->fillSyncMenu();
261 261
262 262
263 263
264 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); 264 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
265 if ( showWarning ) { 265 if ( showWarning ) {
266 KMessageBox::information( this, 266 KMessageBox::information( this,
267 "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"); 267 "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");
268 qApp->processEvents(); 268 qApp->processEvents();
269 mView->dialogManager()->showSyncOptions(); 269 mView->dialogManager()->showSyncOptions();
270 } 270 }
271 271
272 //US listen for result adressed from Ka/Pi 272 //US listen for result adressed from Ka/Pi
273#ifndef DESKTOP_VERSION 273#ifndef DESKTOP_VERSION
274 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 274 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
275#endif 275#endif
276 276
277} 277}
278MainWindow::~MainWindow() 278MainWindow::~MainWindow()
279{ 279{
280 //qDebug("MainWindow::~MainWindow() "); 280 //qDebug("MainWindow::~MainWindow() ");
281 //save toolbar location 281 //save toolbar location
282 delete mCalendar; 282 delete mCalendar;
283 delete mSyncManager; 283 delete mSyncManager;
284 284
285 285
286} 286}
287void MainWindow::showMaximized () 287void MainWindow::showMaximized ()
288{ 288{
289#ifndef DESKTOP_VERSION 289#ifndef DESKTOP_VERSION
290 if ( ! globalFlagBlockStartup ) 290 if ( ! globalFlagBlockStartup )
291 if ( mClosed ) 291 if ( mClosed )
292 mView->goToday(); 292 mView->goToday();
293#endif 293#endif
294 QWidget::showMaximized () ; 294 QWidget::showMaximized () ;
295 mClosed = false; 295 mClosed = false;
296} 296}
297void MainWindow::closeEvent( QCloseEvent* ce ) 297void MainWindow::closeEvent( QCloseEvent* ce )
298{ 298{
299 299
300 300
301 301
302 if ( ! KOPrefs::instance()->mAskForQuit ) { 302 if ( ! KOPrefs::instance()->mAskForQuit ) {
303 saveOnClose(); 303 saveOnClose();
304 mClosed = true; 304 mClosed = true;
305 ce->accept(); 305 ce->accept();
306 return; 306 return;
307 307
308 } 308 }
309 309
310 switch( QMessageBox::information( this, "KO/Pi", 310 switch( QMessageBox::information( this, "KO/Pi",
311 i18n("Do you really want\nto close KO/Pi?"), 311 i18n("Do you really want\nto close KO/Pi?"),
312 i18n("Close"), i18n("No"), 312 i18n("Close"), i18n("No"),
313 0, 0 ) ) { 313 0, 0 ) ) {
314 case 0: 314 case 0:
315 saveOnClose(); 315 saveOnClose();
316 mClosed = true; 316 mClosed = true;
317 ce->accept(); 317 ce->accept();
318 break; 318 break;
319 case 1: 319 case 1:
320 ce->ignore(); 320 ce->ignore();
321 break; 321 break;
322 case 2: 322 case 2:
323 323
324 default: 324 default:
325 break; 325 break;
326 } 326 }
327 327
328 328
329} 329}
330 330
331void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) 331void MainWindow::recieve( const QCString& cmsg, const QByteArray& data )
332{ 332{
333 QDataStream stream( data, IO_ReadOnly ); 333 QDataStream stream( data, IO_ReadOnly );
334 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); 334 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" );
335 //QString datamess; 335 //QString datamess;
336 //qDebug("message "); 336 //qDebug("message ");
337 qDebug("KO: QCOP message received: %s ", cmsg.data() ); 337 qDebug("KO: QCOP message received: %s ", cmsg.data() );
338 338
339 if ( cmsg == "setDocument(QString)" ) { 339 if ( cmsg == "setDocument(QString)" ) {
340 QDataStream stream( data, IO_ReadOnly ); 340 QDataStream stream( data, IO_ReadOnly );
341 QString fileName; 341 QString fileName;
342 stream >> fileName; 342 stream >> fileName;
343 //qDebug("filename %s ", fileName.latin1()); 343 //qDebug("filename %s ", fileName.latin1());
344 showMaximized(); 344 showMaximized();
345 raise(); 345 raise();
346 KOPrefs::instance()->mLastSyncedLocalFile = fileName ; 346 KOPrefs::instance()->mLastSyncedLocalFile = fileName ;
347 mSyncManager->slotSyncMenu( 1002 ); 347 mSyncManager->slotSyncMenu( 1002 );
348 return; 348 return;
349 } 349 }
350 350
351 if ( cmsg == "-writeFile" ) { 351 if ( cmsg == "-writeFile" ) {
352 // I made from the "-writeFile" an "-writeAlarm" 352 // I made from the "-writeFile" an "-writeAlarm"
353 mView->viewManager()->showWhatsNextView(); 353 mView->viewManager()->showWhatsNextView();
354 mCalendar->checkAlarmForIncidence( 0, true); 354 mCalendar->checkAlarmForIncidence( 0, true);
355 showMaximized(); 355 showMaximized();
356 raise(); 356 raise();
357 return; 357 return;
358 358
359 } 359 }
360 if ( cmsg == "-writeFileSilent" ) { 360 if ( cmsg == "-writeFileSilent" ) {
361 // I made from the "-writeFile" an "-writeAlarm" 361 // I made from the "-writeFile" an "-writeAlarm"
362 // mView->viewManager()->showWhatsNextView(); 362 // mView->viewManager()->showWhatsNextView();
363 mCalendar->checkAlarmForIncidence( 0, true); 363 mCalendar->checkAlarmForIncidence( 0, true);
364 //showMaximized(); 364 //showMaximized();
365 //raise(); 365 //raise();
366 hide(); 366 hide();
367 return; 367 return;
368 } 368 }
369 if ( cmsg == "-newCountdown" ) { 369 if ( cmsg == "-newCountdown" ) {
370 qDebug("newCountdown "); 370 qDebug("newCountdown ");
371 371
372 } 372 }
373 QString msg ; 373 QString msg ;
374 QString allmsg = cmsg; 374 QString allmsg = cmsg;
375 while ( allmsg.length() > 0 ) { 375 while ( allmsg.length() > 0 ) {
376 int nextC = allmsg.find( "-", 1 ); 376 int nextC = allmsg.find( "-", 1 );
377 if ( nextC == -1 ) { 377 if ( nextC == -1 ) {
378 msg = allmsg; 378 msg = allmsg;
379 allmsg = ""; 379 allmsg = "";
380 } else{ 380 } else{
381 msg = allmsg.left( nextC ); 381 msg = allmsg.left( nextC );
382 allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); 382 allmsg = allmsg.mid( nextC, allmsg.length()-nextC );
383 } 383 }
384 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); 384 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() );
385 if ( msg == "-newEvent" ) { 385 if ( msg == "-newEvent" ) {
386 mView->newEvent(); 386 mView->newEvent();
387 } 387 }
388 if ( msg == "-newTodo" ) { 388 if ( msg == "-newTodo" ) {
389 mView->newTodo(); 389 mView->newTodo();
390 390
391 } 391 }
392 if ( msg == "-showWN" ) { 392 if ( msg == "-showWN" ) {
393 mView->viewManager()->showWhatsNextView(); 393 mView->viewManager()->showWhatsNextView();
394 } 394 }
395 if ( msg == "-showTodo" ) { 395 if ( msg == "-showTodo" ) {
396 mView->viewManager()->showTodoView(); 396 mView->viewManager()->showTodoView();
397 } 397 }
398 if ( msg == "-showList" ) { 398 if ( msg == "-showList" ) {
399 mView->viewManager()->showListView(); 399 mView->viewManager()->showListView();
400 } 400 }
401 else if ( msg == "-showDay" ) { 401 else if ( msg == "-showDay" ) {
402 mView->viewManager()->showDayView(); 402 mView->viewManager()->showDayView();
403 } 403 }
404 else if ( msg == "-showWWeek" ) { 404 else if ( msg == "-showWWeek" ) {
405 mView->viewManager()->showWorkWeekView(); 405 mView->viewManager()->showWorkWeekView();
406 } 406 }
407 else if ( msg == "-ringSync" ) { 407 else if ( msg == "-ringSync" ) {
408 mSyncManager->multiSync( false ); 408 mSyncManager->multiSync( false );
409 } 409 }
410 else if ( msg == "-showWeek" ) { 410 else if ( msg == "-showWeek" ) {
411 mView->viewManager()->showWeekView(); 411 mView->viewManager()->showWeekView();
412 } 412 }
413 else if ( msg == "-showTodo" ) { 413 else if ( msg == "-showTodo" ) {
414 mView->viewManager()->showTodoView(); 414 mView->viewManager()->showTodoView();
415 } 415 }
416 else if ( msg == "-showJournal" ) { 416 else if ( msg == "-showJournal" ) {
417 mView->dateNavigator()->selectDates( 1 ); 417 mView->dateNavigator()->selectDates( 1 );
418 mView->dateNavigator()->selectToday(); 418 mView->dateNavigator()->selectToday();
419 mView->viewManager()->showJournalView(); 419 mView->viewManager()->showJournalView();
420 } 420 }
421 else if ( msg == "-showKO" ) { 421 else if ( msg == "-showKO" ) {
422 mView->viewManager()->showNextXView(); 422 mView->viewManager()->showNextXView();
423 } 423 }
424 else if ( msg == "-showWNext" || msg == "nextView()" ) { 424 else if ( msg == "-showWNext" || msg == "nextView()" ) {
425 mView->viewManager()->showWhatsNextView(); 425 mView->viewManager()->showWhatsNextView();
426 } 426 }
427 else if ( msg == "-showNextXView" ) { 427 else if ( msg == "-showNextXView" ) {
428 mView->viewManager()->showNextXView(); 428 mView->viewManager()->showNextXView();
429 } 429 }
430 430
431 431
432 } 432 }
433 433
434 showMaximized(); 434 showMaximized();
435 raise(); 435 raise();
436} 436}
437 437
438QPixmap MainWindow::loadPixmap( QString name ) 438QPixmap MainWindow::loadPixmap( QString name )
439{ 439{
440 return SmallIcon( name ); 440 return SmallIcon( name );
441 441
442} 442}
443void MainWindow::initActions() 443void MainWindow::initActions()
444{ 444{
445 //KOPrefs::instance()->mShowFullMenu 445 //KOPrefs::instance()->mShowFullMenu
446 iconToolBar->clear(); 446 iconToolBar->clear();
447 KOPrefs *p = KOPrefs::instance(); 447 KOPrefs *p = KOPrefs::instance();
448 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); 448 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar );
449 449
450 QPopupMenu *viewMenu = new QPopupMenu( this ); 450 QPopupMenu *viewMenu = new QPopupMenu( this );
451 QPopupMenu *actionMenu = new QPopupMenu( this ); 451 QPopupMenu *actionMenu = new QPopupMenu( this );
452 QPopupMenu *importMenu = new QPopupMenu( this ); 452 QPopupMenu *importMenu = new QPopupMenu( this );
453 selectFilterMenu = new QPopupMenu( this ); 453 selectFilterMenu = new QPopupMenu( this );
454 selectFilterMenu->setCheckable( true ); 454 selectFilterMenu->setCheckable( true );
455 syncMenu = new QPopupMenu( this ); 455 syncMenu = new QPopupMenu( this );
456 configureAgendaMenu = new QPopupMenu( this ); 456 configureAgendaMenu = new QPopupMenu( this );
457 configureToolBarMenu = new QPopupMenu( this ); 457 configureToolBarMenu = new QPopupMenu( this );
458 QPopupMenu *helpMenu = new QPopupMenu( this ); 458 QPopupMenu *helpMenu = new QPopupMenu( this );
459 if ( KOPrefs::instance()->mShowFullMenu ) { 459 if ( KOPrefs::instance()->mShowFullMenu ) {
460 QMenuBar *menuBar1; 460 QMenuBar *menuBar1;
461 menuBar1 = menuBar(); 461 menuBar1 = menuBar();
462 menuBar1->insertItem( i18n("File"), importMenu ); 462 menuBar1->insertItem( i18n("File"), importMenu );
463 menuBar1->insertItem( i18n("View"), viewMenu ); 463 menuBar1->insertItem( i18n("View"), viewMenu );
464 menuBar1->insertItem( i18n("Actions"), actionMenu ); 464 menuBar1->insertItem( i18n("Actions"), actionMenu );
465 menuBar1->insertItem( i18n("Synchronize"), syncMenu ); 465 menuBar1->insertItem( i18n("Synchronize"), syncMenu );
466 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 466 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu );
467 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); 467 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu );
468 menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); 468 menuBar1->insertItem( i18n("Filter"),selectFilterMenu );
469 menuBar1->insertItem( i18n("Help"), helpMenu ); 469 menuBar1->insertItem( i18n("Help"), helpMenu );
470 } else { 470 } else {
471 QPEMenuBar *menuBar1; 471 QPEMenuBar *menuBar1;
472 menuBar1 = new QPEMenuBar( iconToolBar ); 472 menuBar1 = new QPEMenuBar( iconToolBar );
473 QPopupMenu *menuBar = new QPopupMenu( this ); 473 QPopupMenu *menuBar = new QPopupMenu( this );
474 menuBar1->insertItem( i18n("ME"), menuBar); 474 menuBar1->insertItem( i18n("ME"), menuBar);
475 menuBar->insertItem( i18n("File"), importMenu ); 475 menuBar->insertItem( i18n("File"), importMenu );
476 menuBar->insertItem( i18n("View"), viewMenu ); 476 menuBar->insertItem( i18n("View"), viewMenu );
477 menuBar->insertItem( i18n("Actions"), actionMenu ); 477 menuBar->insertItem( i18n("Actions"), actionMenu );
478 menuBar->insertItem( i18n("Synchronize"), syncMenu ); 478 menuBar->insertItem( i18n("Synchronize"), syncMenu );
479 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 479 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu );
480 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); 480 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu );
481 menuBar->insertItem( i18n("Filter"),selectFilterMenu ); 481 menuBar->insertItem( i18n("Filter"),selectFilterMenu );
482 menuBar->insertItem( i18n("Help"), helpMenu ); 482 menuBar->insertItem( i18n("Help"), helpMenu );
483 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); 483 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() );
484 menuBar1->setMaximumSize( menuBar1->sizeHint( )); 484 menuBar1->setMaximumSize( menuBar1->sizeHint( ));
485 } 485 }
486 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); 486 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
487 connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) ); 487 connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) );
488 488
489 // ****************** 489 // ******************
490 QAction *action; 490 QAction *action;
491 QIconSet icon; 491 QIconSet icon;
492 // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); 492 // QPopupMenu *configureMenu= new QPopupMenu( menuBar );
493 configureToolBarMenu->setCheckable( true ); 493 configureToolBarMenu->setCheckable( true );
494 494
495 QString pathString = ""; 495 QString pathString = "";
496 if ( !p->mToolBarMiniIcons ) { 496 if ( !p->mToolBarMiniIcons ) {
497 if ( QApplication::desktop()->width() < 480 ) 497 if ( QApplication::desktop()->width() < 480 )
498 pathString += "icons16/"; 498 pathString += "icons16/";
499 } else 499 } else
500 pathString += "iconsmini/"; 500 pathString += "iconsmini/";
501 configureAgendaMenu->setCheckable( true ); 501 configureAgendaMenu->setCheckable( true );
502 configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 ); 502 configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 );
503 configureAgendaMenu->insertSeparator(); 503 configureAgendaMenu->insertSeparator();
504 configureAgendaMenu->insertItem(i18n("Tiny"), 4 ); 504 configureAgendaMenu->insertItem(i18n("Tiny"), 4 );
505 configureAgendaMenu->insertItem(i18n("Small"), 6 ); 505 configureAgendaMenu->insertItem(i18n("Small"), 6 );
506 configureAgendaMenu->insertItem(i18n("Medium"), 8 ); 506 configureAgendaMenu->insertItem(i18n("Medium"), 8 );
507 configureAgendaMenu->insertItem(i18n("Normal"), 10 ); 507 configureAgendaMenu->insertItem(i18n("Normal"), 10 );
508 configureAgendaMenu->insertItem(i18n("Large"), 12 ); 508 configureAgendaMenu->insertItem(i18n("Large"), 12 );
509 configureAgendaMenu->insertItem(i18n("Big"), 14 ); 509 configureAgendaMenu->insertItem(i18n("Big"), 14 );
510 configureAgendaMenu->insertItem(i18n("Bigger"), 16 ); 510 configureAgendaMenu->insertItem(i18n("Bigger"), 16 );
511 configureAgendaMenu->insertItem(i18n("Biggest"), 18 ); 511 configureAgendaMenu->insertItem(i18n("Biggest"), 18 );
512 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); 512 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu );
513 513
514 icon = loadPixmap( pathString + "configure" ); 514 icon = loadPixmap( pathString + "configure" );
515 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); 515 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this );
516 action->addTo( actionMenu ); 516 action->addTo( actionMenu );
517 connect( action, SIGNAL( activated() ), 517 connect( action, SIGNAL( activated() ),
518 mView, SLOT( edit_options() ) ); 518 mView, SLOT( edit_options() ) );
519 actionMenu->insertSeparator(); 519 actionMenu->insertSeparator();
520 icon = loadPixmap( pathString + "newevent" ); 520 icon = loadPixmap( pathString + "newevent" );
521 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); 521 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 );
522 configureToolBarMenu->insertSeparator(); 522 configureToolBarMenu->insertSeparator();
523 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); 523 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 );
524 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); 524 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this );
525 ne_action->addTo( actionMenu ); 525 ne_action->addTo( actionMenu );
526 connect( ne_action, SIGNAL( activated() ), 526 connect( ne_action, SIGNAL( activated() ),
527 mView, SLOT( newEvent() ) ); 527 mView, SLOT( newEvent() ) );
528 icon = loadPixmap( pathString + "newtodo" ); 528 icon = loadPixmap( pathString + "newtodo" );
529 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); 529 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 );
530 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); 530 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this );
531 nt_action->addTo( actionMenu ); 531 nt_action->addTo( actionMenu );
532 connect( nt_action, SIGNAL( activated() ), 532 connect( nt_action, SIGNAL( activated() ),
533 mView, SLOT( newTodo() ) ); 533 mView, SLOT( newTodo() ) );
534 icon = loadPixmap( pathString + "navi" ); 534 icon = loadPixmap( pathString + "navi" );
535 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); 535 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this );
536 action->addTo( viewMenu ); 536 action->addTo( viewMenu );
537 connect( action, SIGNAL( activated() ), 537 connect( action, SIGNAL( activated() ),
538 mView, SLOT( toggleDateNavigatorWidget() ) ); 538 mView, SLOT( toggleDateNavigatorWidget() ) );
539 icon = loadPixmap( pathString + "filter" ); 539 icon = loadPixmap( pathString + "filter" );
540 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); 540 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this );
541 action->addTo( viewMenu ); 541 action->addTo( viewMenu );
542 connect( action, SIGNAL( activated() ), 542 connect( action, SIGNAL( activated() ),
543 mView, SLOT( toggleFilter() ) ); 543 mView, SLOT( toggleFilter() ) );
544 544
545 545
546 viewMenu->insertSeparator(); 546 viewMenu->insertSeparator();
547 icon = loadPixmap( pathString + "picker" ); 547 icon = loadPixmap( pathString + "picker" );
548 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); 548 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this );
549 action->addTo( viewMenu ); 549 action->addTo( viewMenu );
550 connect( action, SIGNAL( activated() ), 550 connect( action, SIGNAL( activated() ),
551 mView, SLOT( showDatePicker() ) ); 551 mView, SLOT( showDatePicker() ) );
552 action->addTo( iconToolBar ); 552 action->addTo( iconToolBar );
553 viewMenu->insertSeparator(); 553 viewMenu->insertSeparator();
554 icon = loadPixmap( pathString + "list" ); 554 icon = loadPixmap( pathString + "list" );
555 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); 555 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 );
556 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); 556 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this );
557 showlist_action->addTo( viewMenu ); 557 showlist_action->addTo( viewMenu );
558 connect( showlist_action, SIGNAL( activated() ), 558 connect( showlist_action, SIGNAL( activated() ),
559 mView->viewManager(), SLOT( showListView() ) ); 559 mView->viewManager(), SLOT( showListView() ) );
560 560
561 561
562 icon = loadPixmap( pathString + "day" ); 562 icon = loadPixmap( pathString + "day" );
563 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); 563 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 );
564 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); 564 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this );
565 day1_action->addTo( viewMenu ); 565 day1_action->addTo( viewMenu );
566 // action->addTo( toolBar ); 566 // action->addTo( toolBar );
567 connect( day1_action, SIGNAL( activated() ), 567 connect( day1_action, SIGNAL( activated() ),
568 mView->viewManager(), SLOT( showDayView() ) ); 568 mView->viewManager(), SLOT( showDayView() ) );
569 569
570 icon = loadPixmap( pathString + "workweek" ); 570 icon = loadPixmap( pathString + "workweek" );
571 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); 571 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 );
572 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); 572 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this );
573 day5_action->addTo( viewMenu ); 573 day5_action->addTo( viewMenu );
574 connect( day5_action, SIGNAL( activated() ), 574 connect( day5_action, SIGNAL( activated() ),
575 mView->viewManager(), SLOT( showWorkWeekView() ) ); 575 mView->viewManager(), SLOT( showWorkWeekView() ) );
576 576
577 icon = loadPixmap( pathString + "week" ); 577 icon = loadPixmap( pathString + "week" );
578 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); 578 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 );
579 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); 579 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this );
580 day7_action->addTo( viewMenu ); 580 day7_action->addTo( viewMenu );
581 connect( day7_action, SIGNAL( activated() ), 581 connect( day7_action, SIGNAL( activated() ),
582 mView->viewManager(), SLOT( showWeekView() ) ); 582 mView->viewManager(), SLOT( showWeekView() ) );
583 583
584 icon = loadPixmap( pathString + "month" ); 584 icon = loadPixmap( pathString + "month" );
585 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); 585 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 );
586 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); 586 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this );
587 month_action->addTo( viewMenu ); 587 month_action->addTo( viewMenu );
588 connect( month_action, SIGNAL( activated() ), 588 connect( month_action, SIGNAL( activated() ),
589 mView->viewManager(), SLOT( showMonthView() ) ); 589 mView->viewManager(), SLOT( showMonthView() ) );
590 590
591 icon = loadPixmap( pathString + "todo" ); 591 icon = loadPixmap( pathString + "todo" );
592 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); 592 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 );
593 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); 593 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this );
594 todoview_action->addTo( viewMenu ); 594 todoview_action->addTo( viewMenu );
595 connect( todoview_action, SIGNAL( activated() ), 595 connect( todoview_action, SIGNAL( activated() ),
596 mView->viewManager(), SLOT( showTodoView() ) ); 596 mView->viewManager(), SLOT( showTodoView() ) );
597 597
598 icon = loadPixmap( pathString + "journal" ); 598 icon = loadPixmap( pathString + "journal" );
599 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); 599 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 );
600 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); 600 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this );
601 viewjournal_action->addTo( viewMenu ); 601 viewjournal_action->addTo( viewMenu );
602 connect( viewjournal_action, SIGNAL( activated() ), 602 connect( viewjournal_action, SIGNAL( activated() ),
603 mView->viewManager(), SLOT( showJournalView() ) ); 603 mView->viewManager(), SLOT( showJournalView() ) );
604 604
605 icon = loadPixmap( pathString + "xdays" ); 605 icon = loadPixmap( pathString + "xdays" );
606 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 ); 606 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 );
607 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); 607 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this );
608 xdays_action->addTo( viewMenu ); 608 xdays_action->addTo( viewMenu );
609 connect( xdays_action, SIGNAL( activated() ), 609 connect( xdays_action, SIGNAL( activated() ),
610 mView->viewManager(), SLOT( showNextXView() ) ); 610 mView->viewManager(), SLOT( showNextXView() ) );
611 611
612 icon = loadPixmap( pathString + "whatsnext" ); 612 icon = loadPixmap( pathString + "whatsnext" );
613 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 ); 613 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 );
614 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); 614 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this );
615 whatsnext_action->addTo( viewMenu ); 615 whatsnext_action->addTo( viewMenu );
616 connect( whatsnext_action, SIGNAL( activated() ), 616 connect( whatsnext_action, SIGNAL( activated() ),
617 mView->viewManager(), SLOT( showWhatsNextView() ) ); 617 mView->viewManager(), SLOT( showWhatsNextView() ) );
618 618
619#if 0 619#if 0
620 action = new QAction( "view_timespan", "Time Span", 0, this ); 620 action = new QAction( "view_timespan", "Time Span", 0, this );
621 action->addTo( viewMenu ); 621 action->addTo( viewMenu );
622 connect( action, SIGNAL( activated() ), 622 connect( action, SIGNAL( activated() ),
623 mView->viewManager(), SLOT( showTimeSpanView() ) ); 623 mView->viewManager(), SLOT( showTimeSpanView() ) );
624#endif 624#endif
625 625
626 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, 626 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0,
627 this ); 627 this );
628 mNewSubTodoAction->addTo( actionMenu ); 628 mNewSubTodoAction->addTo( actionMenu );
629 connect( mNewSubTodoAction, SIGNAL( activated() ), 629 connect( mNewSubTodoAction, SIGNAL( activated() ),
630 mView, SLOT( newSubTodo() ) ); 630 mView, SLOT( newSubTodo() ) );
631 631
632 actionMenu->insertSeparator(); 632 actionMenu->insertSeparator();
633 633
634 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); 634 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this );
635 mShowAction->addTo( actionMenu ); 635 mShowAction->addTo( actionMenu );
636 connect( mShowAction, SIGNAL( activated() ), 636 connect( mShowAction, SIGNAL( activated() ),
637 mView, SLOT( showIncidence() ) ); 637 mView, SLOT( showIncidence() ) );
638 638
639 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); 639 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this );
640 mEditAction->addTo( actionMenu ); 640 mEditAction->addTo( actionMenu );
641 connect( mEditAction, SIGNAL( activated() ), 641 connect( mEditAction, SIGNAL( activated() ),
642 mView, SLOT( editIncidence() ) ); 642 mView, SLOT( editIncidence() ) );
643 643
644 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); 644 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this );
645 mDeleteAction->addTo( actionMenu ); 645 mDeleteAction->addTo( actionMenu );
646 connect( mDeleteAction, SIGNAL( activated() ), 646 connect( mDeleteAction, SIGNAL( activated() ),
647 mView, SLOT( deleteIncidence() ) ); 647 mView, SLOT( deleteIncidence() ) );
648 648
649 649
650 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); 650 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this );
651 mCloneAction->addTo( actionMenu ); 651 mCloneAction->addTo( actionMenu );
652 connect( mCloneAction, SIGNAL( activated() ), 652 connect( mCloneAction, SIGNAL( activated() ),
653 mView, SLOT( cloneIncidence() ) ); 653 mView, SLOT( cloneIncidence() ) );
654 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); 654 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this );
655 mMoveAction->addTo( actionMenu ); 655 mMoveAction->addTo( actionMenu );
656 connect( mMoveAction, SIGNAL( activated() ), 656 connect( mMoveAction, SIGNAL( activated() ),
657 mView, SLOT( moveIncidence() ) ); 657 mView, SLOT( moveIncidence() ) );
658 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); 658 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this );
659 mBeamAction->addTo( actionMenu ); 659 mBeamAction->addTo( actionMenu );
660 connect( mBeamAction, SIGNAL( activated() ), 660 connect( mBeamAction, SIGNAL( activated() ),
661 mView, SLOT( beamIncidence() ) ); 661 mView, SLOT( beamIncidence() ) );
662 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); 662 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this );
663 mCancelAction->addTo( actionMenu ); 663 mCancelAction->addTo( actionMenu );
664 connect( mCancelAction, SIGNAL( activated() ), 664 connect( mCancelAction, SIGNAL( activated() ),
665 mView, SLOT( toggleCancelIncidence() ) ); 665 mView, SLOT( toggleCancelIncidence() ) );
666 666
667 actionMenu->insertSeparator(); 667 actionMenu->insertSeparator();
668 668
669 action = new QAction( "purge_completed", i18n("Purge Completed"), 0, 669 action = new QAction( "purge_completed", i18n("Purge Completed"), 0,
670 this ); 670 this );
671 action->addTo( actionMenu ); 671 action->addTo( actionMenu );
672 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); 672 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) );
673 673
674 icon = loadPixmap( pathString + "search" ); 674 icon = loadPixmap( pathString + "search" );
675 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); 675 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this );
676 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4); 676 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4);
677 search_action->addTo( actionMenu ); 677 search_action->addTo( actionMenu );
678 connect( search_action, SIGNAL( activated() ), 678 connect( search_action, SIGNAL( activated() ),
679 mView->dialogManager(), SLOT( showSearchDialog() ) ); 679 mView->dialogManager(), SLOT( showSearchDialog() ) );
680 680
681 icon = loadPixmap( pathString + "today" ); 681 icon = loadPixmap( pathString + "today" );
682 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); 682 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130);
683 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); 683 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this );
684 today_action->addTo( actionMenu ); 684 today_action->addTo( actionMenu );
685 connect( today_action, SIGNAL( activated() ), 685 connect( today_action, SIGNAL( activated() ),
686 mView, SLOT( goToday() ) ); 686 mView, SLOT( goToday() ) );
687 687
688 if ( KOPrefs::instance()->mShowFullMenu ) { 688 if ( KOPrefs::instance()->mShowFullMenu ) {
689 actionMenu->insertSeparator(); 689 actionMenu->insertSeparator();
690 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); 690 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu );
691 691
692 } 692 }
693 // actionMenu->insertSeparator(); 693 // actionMenu->insertSeparator();
694 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, 694 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0,
695 this ); 695 this );
696 action->addTo( importMenu ); 696 action->addTo( importMenu );
697 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); 697 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) );
698 action = new QAction( "import_quick", i18n("Import last file"), 0, 698 action = new QAction( "import_quick", i18n("Import last file"), 0,
699 this ); 699 this );
700 action->addTo( importMenu ); 700 action->addTo( importMenu );
701 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); 701 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) );
702 importMenu->insertSeparator(); 702 importMenu->insertSeparator();
703 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, 703 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0,
704 this ); 704 this );
705 action->addTo( importMenu ); 705 action->addTo( importMenu );
706 connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); 706 connect( action, SIGNAL( activated() ), SLOT( importBday() ) );
707#ifndef DESKTOP_VERSION 707#ifndef DESKTOP_VERSION
708 importMenu->insertSeparator(); 708 importMenu->insertSeparator();
709 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, 709 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0,
710 this ); 710 this );
711 action->addTo( importMenu ); 711 action->addTo( importMenu );
712 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); 712 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) );
713#else 713#else
714#ifdef _WIN32_ 714#ifdef _WIN32_
715 importMenu->insertSeparator(); 715 importMenu->insertSeparator();
716 action = new QAction( "import_ol", i18n("Import from OL"), 0, 716 action = new QAction( "import_ol", i18n("Import from OL"), 0,
717 this ); 717 this );
718 action->addTo( importMenu ); 718 action->addTo( importMenu );
719 connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); 719 connect( action, SIGNAL( activated() ), SLOT( importOL() ) );
720#endif 720#endif
721#endif 721#endif
722 722
723 importMenu->insertSeparator(); 723 importMenu->insertSeparator();
724 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, 724 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0,
725 this ); 725 this );
726 action->addTo( importMenu ); 726 action->addTo( importMenu );
727 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); 727 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) );
728 728
729 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, 729 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0,
730 this ); 730 this );
731 action->addTo( importMenu ); 731 action->addTo( importMenu );
732 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); 732 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) );
733 733
734 importMenu->insertSeparator(); 734 importMenu->insertSeparator();
735 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, 735 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0,
736 this ); 736 this );
737 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); 737 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) );
738 738
739 739
740 //LR 740 //LR
741 QPopupMenu *ex2phone = new QPopupMenu( this ); 741 QPopupMenu *ex2phone = new QPopupMenu( this );
742 ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 742 ex2phone->insertItem(i18n("Complete calendar..."), 1 );
743 ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 743 ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
744 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); 744 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) );
745 importMenu->insertItem( i18n("Export to phone"), ex2phone ); 745 importMenu->insertItem( i18n("Export to phone"), ex2phone );
746 746
747 importMenu->insertSeparator(); 747 importMenu->insertSeparator();
748 action = new QAction( "manage cat", i18n("Manage new categories..."), 0, 748 action = new QAction( "manage cat", i18n("Manage new categories..."), 0,
749 this ); 749 this );
750 action->addTo( importMenu ); 750 action->addTo( importMenu );
751 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); 751 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) );
752#ifndef DESKTOP_VERSION 752#ifndef DESKTOP_VERSION
753 importMenu->insertSeparator(); 753 importMenu->insertSeparator();
754 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, 754 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0,
755 this ); 755 this );
756 action->addTo( importMenu ); 756 action->addTo( importMenu );
757 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); 757 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) );
758 758
759 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, 759 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0,
760 this ); 760 this );
761 action->addTo( importMenu ); 761 action->addTo( importMenu );
762 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); 762 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) );
763#else 763#else
764 importMenu->insertSeparator(); 764 importMenu->insertSeparator();
765 icon = loadPixmap( pathString + "print" ); 765 icon = loadPixmap( pathString + "print" );
766 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); 766 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this );
767 action->addTo( importMenu ); 767 action->addTo( importMenu );
768 connect( action, SIGNAL( activated() ), 768 connect( action, SIGNAL( activated() ),
769 this, SLOT( printCal() ) ); 769 this, SLOT( printCal() ) );
770 770
771 icon = loadPixmap( pathString + "print" ); 771 icon = loadPixmap( pathString + "print" );
772 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); 772 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this );
773 action->addTo( importMenu ); 773 action->addTo( importMenu );
774 connect( action, SIGNAL( activated() ), 774 connect( action, SIGNAL( activated() ),
775 this, SLOT( printSel() ) ); 775 this, SLOT( printSel() ) );
776#endif 776#endif
777 importMenu->insertSeparator(); 777 importMenu->insertSeparator();
778 action = new QAction( "beam all", i18n("Save"), 0, 778 action = new QAction( "beam all", i18n("Save"), 0,
779 this ); 779 this );
780 action->addTo( importMenu ); 780 action->addTo( importMenu );
781 connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); 781 connect( action, SIGNAL( activated() ), this, SLOT( save() ) );
782 action = new QAction( "beam all", i18n("Exit (+save)"), 0, 782 action = new QAction( "beam all", i18n("Exit (+save)"), 0,
783 this ); 783 this );
784 action->addTo( importMenu ); 784 action->addTo( importMenu );
785 connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); 785 connect( action, SIGNAL( activated() ), this, SLOT( close() ) );
786 786
787 //menuBar->insertItem( "Configure",configureMenu ); 787 //menuBar->insertItem( "Configure",configureMenu );
788 //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); 788 //configureMenu->insertItem( "Toolbar",configureToolBarMenu );
789 icon = loadPixmap( "korganizer/korganizer" ); 789 icon = loadPixmap( "korganizer/korganizer" );
790 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); 790 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this );
791 action->addTo( helpMenu ); 791 action->addTo( helpMenu );
792 connect( action, SIGNAL( activated() ), 792 connect( action, SIGNAL( activated() ),
793 SLOT( keyBindings() ) ); 793 SLOT( keyBindings() ) );
794 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); 794 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this );
795 action->addTo( helpMenu ); 795 action->addTo( helpMenu );
796 connect( action, SIGNAL( activated() ), 796 connect( action, SIGNAL( activated() ),
797 SLOT( features() ) ); 797 SLOT( features() ) );
798 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); 798 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this );
799 action->addTo( helpMenu ); 799 action->addTo( helpMenu );
800 connect( action, SIGNAL( activated() ), 800 connect( action, SIGNAL( activated() ),
801 SLOT( aboutAutoSaving() ) ); 801 SLOT( aboutAutoSaving() ) );
802 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); 802 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this );
803 action->addTo( helpMenu ); 803 action->addTo( helpMenu );
804 connect( action, SIGNAL( activated() ), 804 connect( action, SIGNAL( activated() ),
805 SLOT( aboutKnownBugs() ) ); 805 SLOT( aboutKnownBugs() ) );
806 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); 806 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this );
807 action->addTo( helpMenu ); 807 action->addTo( helpMenu );
808 connect( action, SIGNAL( activated() ), 808 connect( action, SIGNAL( activated() ),
809 SLOT( usertrans() ) ); 809 SLOT( usertrans() ) );
810 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); 810 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this );
811 action->addTo( helpMenu ); 811 action->addTo( helpMenu );
812 connect( action, SIGNAL( activated() ), 812 connect( action, SIGNAL( activated() ),
813 SLOT( synchowto() ) ); 813 SLOT( synchowto() ) );
814 action = new QAction( "Whats New", i18n("What's new?"), 0,this ); 814 action = new QAction( "Whats New", i18n("What's new?"), 0,this );
815 action->addTo( helpMenu ); 815 action->addTo( helpMenu );
816 connect( action, SIGNAL( activated() ), 816 connect( action, SIGNAL( activated() ),
817 SLOT( whatsNew() ) ); 817 SLOT( whatsNew() ) );
818 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); 818 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this );
819 action->addTo( helpMenu ); 819 action->addTo( helpMenu );
820 connect( action, SIGNAL( activated() ), 820 connect( action, SIGNAL( activated() ),
821 SLOT( faq() ) ); 821 SLOT( faq() ) );
822 822
823 823
824 action = new QAction( "about", i18n("About..."), 0, this ); 824 action = new QAction( "about", i18n("About..."), 0, this );
825 action->addTo( helpMenu ); 825 action->addTo( helpMenu );
826 connect( action, SIGNAL( activated() ), 826 connect( action, SIGNAL( activated() ),
827 SLOT( about() ) ); 827 SLOT( about() ) );
828 action = new QAction( "licence", i18n("Licence..."), 0, this ); 828 action = new QAction( "licence", i18n("Licence..."), 0, this );
829 action->addTo( helpMenu ); 829 action->addTo( helpMenu );
830 connect( action, SIGNAL( activated() ), 830 connect( action, SIGNAL( activated() ),
831 SLOT( licence() ) ); 831 SLOT( licence() ) );
832 //menuBar->insertSeparator(); 832 //menuBar->insertSeparator();
833 833
834 // ****************************************************** 834 // ******************************************************
835 // menubar icons 835 // menubar icons
836 836
837 837
838 iconToolBar->setHorizontalStretchable (true ); 838 iconToolBar->setHorizontalStretchable (true );
839 //menuBar->insertItem( iconToolBar ); 839 //menuBar->insertItem( iconToolBar );
840 //xdays_action 840 //xdays_action
841 if (p-> mShowIconNewEvent) 841 if (p-> mShowIconNewEvent)
842 ne_action->addTo( iconToolBar ); 842 ne_action->addTo( iconToolBar );
843 if (p->mShowIconNewTodo ) 843 if (p->mShowIconNewTodo )
844 nt_action->addTo( iconToolBar ); 844 nt_action->addTo( iconToolBar );
845 if (p-> mShowIconSearch) 845 if (p-> mShowIconSearch)
846 search_action->addTo( iconToolBar ); 846 search_action->addTo( iconToolBar );
847 if (p-> mShowIconNext) 847 if (p-> mShowIconNext)
848 whatsnext_action->addTo( iconToolBar ); 848 whatsnext_action->addTo( iconToolBar );
849 if (p-> mShowIconNextDays) 849 if (p-> mShowIconNextDays)
850 xdays_action->addTo( iconToolBar ); 850 xdays_action->addTo( iconToolBar );
851 if (p-> mShowIconList) 851 if (p-> mShowIconList)
852 showlist_action->addTo( iconToolBar ); 852 showlist_action->addTo( iconToolBar );
853 if (p-> mShowIconDay1) 853 if (p-> mShowIconDay1)
854 day1_action->addTo( iconToolBar ); 854 day1_action->addTo( iconToolBar );
855 if (p-> mShowIconDay5) 855 if (p-> mShowIconDay5)
856 day5_action->addTo( iconToolBar ); 856 day5_action->addTo( iconToolBar );
857 if (p-> mShowIconDay7) 857 if (p-> mShowIconDay7)
858 day7_action->addTo( iconToolBar ); 858 day7_action->addTo( iconToolBar );
859 if (p-> mShowIconMonth) 859 if (p-> mShowIconMonth)
860 month_action->addTo( iconToolBar ); 860 month_action->addTo( iconToolBar );
861 if (p-> mShowIconTodoview) 861 if (p-> mShowIconTodoview)
862 todoview_action->addTo( iconToolBar ); 862 todoview_action->addTo( iconToolBar );
863 if (p-> mShowIconJournal) 863 if (p-> mShowIconJournal)
864 viewjournal_action->addTo( iconToolBar ); 864 viewjournal_action->addTo( iconToolBar );
865 icon = loadPixmap( pathString + "2leftarrowB" ); 865 icon = loadPixmap( pathString + "2leftarrowB" );
866 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); 866 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14);
867 if (p-> mShowIconBackFast) { 867 if (p-> mShowIconBackFast) {
868 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); 868 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this );
869 connect( action, SIGNAL( activated() ), 869 connect( action, SIGNAL( activated() ),
870 mView, SLOT( goPreviousMonth() ) ); 870 mView, SLOT( goPreviousMonth() ) );
871 action->addTo( iconToolBar ); 871 action->addTo( iconToolBar );
872 } 872 }
873 icon = loadPixmap( pathString + "1leftarrowB" ); 873 icon = loadPixmap( pathString + "1leftarrowB" );
874 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); 874 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15);
875 if (p-> mShowIconBack) { 875 if (p-> mShowIconBack) {
876 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); 876 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this );
877 connect( action, SIGNAL( activated() ), 877 connect( action, SIGNAL( activated() ),
878 mView, SLOT( goPrevious() ) ); 878 mView, SLOT( goPrevious() ) );
879 action->addTo( iconToolBar ); 879 action->addTo( iconToolBar );
880 } 880 }
881 if (p-> mShowIconToday) 881 if (p-> mShowIconToday)
882 today_action->addTo( iconToolBar ); 882 today_action->addTo( iconToolBar );
883 icon = loadPixmap( pathString + "1rightarrowB" ); 883 icon = loadPixmap( pathString + "1rightarrowB" );
884 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); 884 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220);
885 if (p-> mShowIconForward) { 885 if (p-> mShowIconForward) {
886 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); 886 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this );
887 connect( action, SIGNAL( activated() ), 887 connect( action, SIGNAL( activated() ),
888 mView, SLOT( goNext() ) ); 888 mView, SLOT( goNext() ) );
889 action->addTo( iconToolBar ); 889 action->addTo( iconToolBar );
890 } 890 }
891 icon = loadPixmap( pathString + "2rightarrowB" ); 891 icon = loadPixmap( pathString + "2rightarrowB" );
892 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); 892 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230);
893 if (p-> mShowIconForwardFast) { 893 if (p-> mShowIconForwardFast) {
894 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); 894 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this );
895 connect( action, SIGNAL( activated() ), 895 connect( action, SIGNAL( activated() ),
896 mView, SLOT( goNextMonth() ) ); 896 mView, SLOT( goNextMonth() ) );
897 action->addTo( iconToolBar ); 897 action->addTo( iconToolBar );
898 } 898 }
899 899
900 900
901 configureToolBarMenu->insertItem(i18n("What's This?"), 300); 901 configureToolBarMenu->insertItem(i18n("What's This?"), 300);
902 902
903 if (p-> mShowIconNewEvent) 903 if (p-> mShowIconNewEvent)
904 configureToolBarMenu->setItemChecked( 10, true ); 904 configureToolBarMenu->setItemChecked( 10, true );
905 if (p->mShowIconNewTodo ) 905 if (p->mShowIconNewTodo )
906 configureToolBarMenu->setItemChecked( 20, true ); 906 configureToolBarMenu->setItemChecked( 20, true );
907 if (p-> mShowIconSearch) 907 if (p-> mShowIconSearch)
908 configureToolBarMenu->setItemChecked( 120, true ); 908 configureToolBarMenu->setItemChecked( 120, true );
909 if (p-> mShowIconList) 909 if (p-> mShowIconList)
910 configureToolBarMenu->setItemChecked( 30, true ); 910 configureToolBarMenu->setItemChecked( 30, true );
911 if (p-> mShowIconDay1) 911 if (p-> mShowIconDay1)
912 configureToolBarMenu->setItemChecked( 40, true ); 912 configureToolBarMenu->setItemChecked( 40, true );
913 if (p-> mShowIconDay5) 913 if (p-> mShowIconDay5)
914 configureToolBarMenu->setItemChecked( 50, true ); 914 configureToolBarMenu->setItemChecked( 50, true );
915 if (p-> mShowIconDay7) 915 if (p-> mShowIconDay7)
916 configureToolBarMenu->setItemChecked( 60, true ); 916 configureToolBarMenu->setItemChecked( 60, true );
917 if (p-> mShowIconMonth) 917 if (p-> mShowIconMonth)
918 configureToolBarMenu->setItemChecked( 70, true ); 918 configureToolBarMenu->setItemChecked( 70, true );
919 if (p-> mShowIconTodoview) 919 if (p-> mShowIconTodoview)
920 configureToolBarMenu->setItemChecked( 80, true ); 920 configureToolBarMenu->setItemChecked( 80, true );
921 if (p-> mShowIconBackFast) 921 if (p-> mShowIconBackFast)
922 configureToolBarMenu->setItemChecked( 200, true ); 922 configureToolBarMenu->setItemChecked( 200, true );
923 if (p-> mShowIconBack) 923 if (p-> mShowIconBack)
924 configureToolBarMenu->setItemChecked( 210, true ); 924 configureToolBarMenu->setItemChecked( 210, true );
925 if (p-> mShowIconToday) 925 if (p-> mShowIconToday)
926 configureToolBarMenu->setItemChecked( 130, true ); 926 configureToolBarMenu->setItemChecked( 130, true );
927 if (p-> mShowIconForward) 927 if (p-> mShowIconForward)
928 configureToolBarMenu->setItemChecked( 220, true ); 928 configureToolBarMenu->setItemChecked( 220, true );
929 if (p-> mShowIconForwardFast) 929 if (p-> mShowIconForwardFast)
930 configureToolBarMenu->setItemChecked( 230, true ); 930 configureToolBarMenu->setItemChecked( 230, true );
931 if (p-> mShowIconNextDays) 931 if (p-> mShowIconNextDays)
932 configureToolBarMenu->setItemChecked( 100, true ); 932 configureToolBarMenu->setItemChecked( 100, true );
933 if (p-> mShowIconNext) 933 if (p-> mShowIconNext)
934 configureToolBarMenu->setItemChecked( 110, true ); 934 configureToolBarMenu->setItemChecked( 110, true );
935 if (p-> mShowIconJournal) 935 if (p-> mShowIconJournal)
936 configureToolBarMenu->setItemChecked( 90, true ); 936 configureToolBarMenu->setItemChecked( 90, true );
937 if (p-> mShowIconWhatsThis) 937 if (p-> mShowIconWhatsThis)
938 configureToolBarMenu->setItemChecked( 300, true ); 938 configureToolBarMenu->setItemChecked( 300, true );
939 939
940 QLabel* dummy = new QLabel( iconToolBar ); 940 QLabel* dummy = new QLabel( iconToolBar );
941 dummy->setBackgroundColor( iconToolBar->backgroundColor() ); 941 dummy->setBackgroundColor( iconToolBar->backgroundColor() );
942 if (!p-> mShowIconStretch) 942 if (!p-> mShowIconStretch)
943 iconToolBar->setStretchableWidget ( dummy ) ; 943 iconToolBar->setStretchableWidget ( dummy ) ;
944 else 944 else
945 configureToolBarMenu->setItemChecked( 5, true ); 945 configureToolBarMenu->setItemChecked( 5, true );
946 if (p-> mShowIconWhatsThis) 946 if (p-> mShowIconWhatsThis)
947 QWhatsThis::whatsThisButton ( iconToolBar ); 947 QWhatsThis::whatsThisButton ( iconToolBar );
948 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); 948 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) );
949 configureAgenda( p->mHourSize ); 949 configureAgenda( p->mHourSize );
950 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); 950 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) );
951} 951}
952 952
953void MainWindow::exportToPhone( int mode ) 953void MainWindow::exportToPhone( int mode )
954{ 954{
955 955
956 //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 956 //ex2phone->insertItem(i18n("Complete calendar..."), 1 );
957 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 957 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
958 KOex2phonePrefs ex2phone; 958 KOex2phonePrefs ex2phone;
959 959
960 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 960 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
961 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 961 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
962 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 962 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
963 if ( mode == 1 ) 963 if ( mode == 1 )
964 ex2phone.setCaption(i18n("Export complete calendar")); 964 ex2phone.setCaption(i18n("Export complete calendar"));
965 if ( mode == 2 ) 965 if ( mode == 2 )
966 ex2phone.setCaption(i18n("Export filtered calendar")); 966 ex2phone.setCaption(i18n("Export filtered calendar"));
967 967
968 if ( !ex2phone.exec() ) { 968 if ( !ex2phone.exec() ) {
969 return; 969 return;
970 } 970 }
971 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 971 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
972 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 972 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
973 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 973 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
974 974
975 int inFuture = 0; 975 int inFuture = 0;
976 if ( ex2phone.mWriteBackFuture->isChecked() ) 976 if ( ex2phone.mWriteBackFuture->isChecked() )
977 inFuture = ex2phone.mWriteBackFutureWeeks->value(); 977 inFuture = ex2phone.mWriteBackFutureWeeks->value();
978 QPtrList<Incidence> delSel; 978 QPtrList<Incidence> delSel;
979 if ( mode == 1 ) 979 if ( mode == 1 )
980 delSel = mCalendar->rawIncidences(); 980 delSel = mCalendar->rawIncidences();
981 if ( mode == 2 ) 981 if ( mode == 2 )
982 delSel = mCalendar->incidences(); 982 delSel = mCalendar->incidences();
983 CalendarLocal* cal = new CalendarLocal(); 983 CalendarLocal* cal = new CalendarLocal();
984 cal->setLocalTime(); 984 cal->setLocalTime();
985 Incidence *incidence = delSel.first(); 985 Incidence *incidence = delSel.first();
986 QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); 986 QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
987 QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); 987 QDateTime end = cur.addDays( ( inFuture +1 ) *7 );
988 while ( incidence ) { 988 while ( incidence ) {
989 if ( incidence->type() != "Journal" ) { 989 if ( incidence->type() != "Journal" ) {
990 bool add = true; 990 bool add = true;
991 if ( inFuture ) { 991 if ( inFuture ) {
992 QDateTime dt; 992 QDateTime dt;
993 if ( incidence->type() == "Todo" ) { 993 if ( incidence->type() == "Todo" ) {
994 Todo * t = (Todo*)incidence; 994 Todo * t = (Todo*)incidence;
995 if ( t->hasDueDate() ) 995 if ( t->hasDueDate() )
996 dt = t->dtDue(); 996 dt = t->dtDue();
997 else 997 else
998 dt = cur.addSecs( 62 ); 998 dt = cur.addSecs( 62 );
999 } 999 }
1000 else { 1000 else {
1001 bool ok; 1001 bool ok;
1002 dt = incidence->getNextOccurence( cur, &ok ); 1002 dt = incidence->getNextOccurence( cur, &ok );
1003 if ( !ok ) 1003 if ( !ok )
1004 dt = cur.addSecs( -62 ); 1004 dt = cur.addSecs( -62 );
1005 } 1005 }
1006 if ( dt < cur || dt > end ) { 1006 if ( dt < cur || dt > end ) {
1007 add = false; 1007 add = false;
1008 } 1008 }
1009 } 1009 }
1010 if ( add ) { 1010 if ( add ) {
1011 Incidence *in = incidence->clone(); 1011 Incidence *in = incidence->clone();
1012 cal->addIncidence( in ); 1012 cal->addIncidence( in );
1013 } 1013 }
1014 } 1014 }
1015 incidence = delSel.next(); 1015 incidence = delSel.next();
1016 } 1016 }
1017 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 1017 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
1018 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 1018 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
1019 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1019 KPimGlobalPrefs::instance()->mEx2PhoneModel );
1020 1020
1021 setCaption( i18n("Writing to phone...")); 1021 setCaption( i18n("Writing to phone..."));
1022 if ( PhoneFormat::writeToPhone( cal ) ) 1022 if ( PhoneFormat::writeToPhone( cal ) )
1023 setCaption( i18n("Export to phone successful!")); 1023 setCaption( i18n("Export to phone successful!"));
1024 else 1024 else
1025 setCaption( i18n("Error exporting to phone!")); 1025 setCaption( i18n("Error exporting to phone!"));
1026 delete cal; 1026 delete cal;
1027} 1027}
1028 1028
1029 1029
1030void MainWindow::setDefaultPreferences() 1030void MainWindow::setDefaultPreferences()
1031{ 1031{
1032 KOPrefs *p = KOPrefs::instance(); 1032 KOPrefs *p = KOPrefs::instance();
1033 1033
1034 p->mCompactDialogs = true; 1034 p->mCompactDialogs = true;
1035 p->mConfirm = true; 1035 p->mConfirm = true;
1036 // p->mEnableQuickTodo = false; 1036 // p->mEnableQuickTodo = false;
1037 1037
1038} 1038}
1039 1039
1040QString MainWindow::resourcePath() 1040QString MainWindow::resourcePath()
1041{ 1041{
1042 return KGlobal::iconLoader()->iconPath(); 1042 return KGlobal::iconLoader()->iconPath();
1043} 1043}
1044 1044
1045void MainWindow::displayText( QString text ,QString cap ) 1045void MainWindow::displayText( QString text ,QString cap )
1046{ 1046{
1047 QDialog dia( this, "name", true ); ; 1047 QDialog dia( this, "name", true ); ;
1048 dia.setCaption( cap ); 1048 dia.setCaption( cap );
1049 QVBoxLayout* lay = new QVBoxLayout( &dia ); 1049 QVBoxLayout* lay = new QVBoxLayout( &dia );
1050 lay->setSpacing( 3 ); 1050 lay->setSpacing( 3 );
1051 lay->setMargin( 3 ); 1051 lay->setMargin( 3 );
1052 QTextBrowser tb ( &dia ); 1052 QTextBrowser tb ( &dia );
1053 lay->addWidget( &tb ); 1053 lay->addWidget( &tb );
1054 tb.setText( text ); 1054 tb.setText( text );
1055#ifdef DESKTOP_VERSION 1055#ifdef DESKTOP_VERSION
1056 dia.resize( 640, 480); 1056 dia.resize( 640, 480);
1057#else 1057#else
1058 dia.showMaximized(); 1058 dia.showMaximized();
1059#endif 1059#endif
1060 dia.exec(); 1060 dia.exec();
1061} 1061}
1062void MainWindow::displayFile( QString fn, QString cap ) 1062void MainWindow::displayFile( QString fn, QString cap )
1063{ 1063{
1064 QString fileName = resourcePath() + fn; 1064 QString fileName = resourcePath() + fn;
1065 QString text; 1065 QString text;
1066 QFile file( fileName ); 1066 QFile file( fileName );
1067 if (!file.open( IO_ReadOnly ) ) { 1067 if (!file.open( IO_ReadOnly ) ) {
1068 return ; 1068 return ;
1069 1069
1070 } 1070 }
1071 QTextStream ts( &file ); 1071 QTextStream ts( &file );
1072 text = ts.read(); 1072 text = ts.read();
1073 file.close(); 1073 file.close();
1074 displayText( text, cap); 1074 displayText( text, cap);
1075} 1075}
1076void MainWindow::features() 1076void MainWindow::features()
1077{ 1077{
1078 1078
1079 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); 1079 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") );
1080} 1080}
1081 1081
1082void MainWindow::usertrans() 1082void MainWindow::usertrans()
1083{ 1083{
1084 1084
1085 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); 1085 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") );
1086} 1086}
1087 1087
1088void MainWindow::synchowto() 1088void MainWindow::synchowto()
1089{ 1089{
1090 1090
1091 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 1091 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
1092} 1092}
1093void MainWindow::faq() 1093void MainWindow::faq()
1094{ 1094{
1095 displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); 1095 displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") );
1096 1096
1097} 1097}
1098void MainWindow::whatsNew() 1098void MainWindow::whatsNew()
1099{ 1099{
1100 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 1100 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
1101 1101
1102} 1102}
1103void MainWindow::licence() 1103void MainWindow::licence()
1104{ 1104{
1105 KApplication::showLicence(); 1105 KApplication::showLicence();
1106 1106
1107} 1107}
1108void MainWindow::about() 1108void MainWindow::about()
1109{ 1109{
1110 QString version; 1110 QString version;
1111#include <../version> 1111#include <../version>
1112 QMessageBox::about( this, i18n("About KOrganizer/Pi"), 1112 QMessageBox::about( this, i18n("About KOrganizer/Pi"),
1113 i18n("KOrganizer/Platform-independent\n") + 1113 i18n("KOrganizer/Platform-independent\n") +
1114 "(KO/Pi) " + version + " - " + 1114 "(KO/Pi) " + version + " - " +
1115 1115
1116#ifdef DESKTOP_VERSION 1116#ifdef DESKTOP_VERSION
1117 i18n("Desktop Edition\n") + 1117 i18n("Desktop Edition\n") +
1118#else 1118#else
1119 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + 1119 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") +
1120#endif 1120#endif
1121 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") ); 1121 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") );
1122} 1122}
1123void MainWindow::keyBindings() 1123void MainWindow::keyBindings()
1124{ 1124{
1125 QString cap = i18n("Key bindings KOrganizer/Pi"); 1125 QString cap = i18n("Key bindings KOrganizer/Pi");
1126 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + 1126 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") +
1127 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ 1127 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+
1128 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + 1128 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") +
1129 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ 1129 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+
1130 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ 1130 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+
1131 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ 1131 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+
1132 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ 1132 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+
1133 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ 1133 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+
1134 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ 1134 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+
1135 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ 1135 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+
1136 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ 1136 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+
1137 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ 1137 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+
1138 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ 1138 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+
1139 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ 1139 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+
1140 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ 1140 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+
1141 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ 1141 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+
1142 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ 1142 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+
1143 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ 1143 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+
1144 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ 1144 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+
1145 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ 1145 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+
1146 i18n("<p><h3>In agenda view:</h3></p>\n") + 1146 i18n("<p><h3>In agenda view:</h3></p>\n") +
1147 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ 1147 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+
1148 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ 1148 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+
1149 i18n("<p><h3>In todo view:</h3></p>\n") + 1149 i18n("<p><h3>In todo view:</h3></p>\n") +
1150 i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ 1150 i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+
1151 i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ 1151 i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+
1152 i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ 1152 i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+
1153 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ 1153 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+
1154 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1154 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1155 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ 1155 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+
1156 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ 1156 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+
1157 i18n("<p><h3>In list view:</h3></p>\n") + 1157 i18n("<p><h3>In list view:</h3></p>\n") +
1158 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1158 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1159 i18n("<p><b>return</b>: Select item+one step down</p>\n")+ 1159 i18n("<p><b>return</b>: Select item+one step down</p>\n")+
1160 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ 1160 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+
1161 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ 1161 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+
1162 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ 1162 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+
1163 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ 1163 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+
1164 i18n("<p><h3>In event/todo viewer:</h3></p>\n") + 1164 i18n("<p><h3>In event/todo viewer:</h3></p>\n") +
1165 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ 1165 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+
1166 i18n("<p><b>A</b>: Show agenda view.</p>\n")+ 1166 i18n("<p><b>A</b>: Show agenda view.</p>\n")+
1167 i18n("<p><b>E</b>: Edit item</p>\n") + 1167 i18n("<p><b>E</b>: Edit item</p>\n") +
1168 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + 1168 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") +
1169 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + 1169 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") +
1170 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ 1170 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+
1171 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ 1171 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+
1172 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ 1172 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+
1173 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ 1173 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+
1174 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ 1174 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+
1175 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + 1175 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") +
1176 i18n("<p><b>White</b>: Item readonly</p>\n"); 1176 i18n("<p><b>White</b>: Item readonly</p>\n");
1177 displayText( text, cap); 1177 displayText( text, cap);
1178 1178
1179} 1179}
1180void MainWindow::aboutAutoSaving() 1180void MainWindow::aboutAutoSaving()
1181{ 1181{
1182 QMessageBox* msg; 1182 QMessageBox* msg;
1183 msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), 1183 msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"),
1184 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, 1184 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,
1185 QMessageBox::Ok, 1185 QMessageBox::Ok,
1186 QMessageBox::NoButton, 1186 QMessageBox::NoButton,
1187 QMessageBox::NoButton); 1187 QMessageBox::NoButton);
1188 msg->exec(); 1188 msg->exec();
1189 delete msg; 1189 delete msg;
1190 1190
1191 1191
1192} 1192}
1193void MainWindow::aboutKnownBugs() 1193void MainWindow::aboutKnownBugs()
1194{ 1194{
1195 QMessageBox* msg; 1195 QMessageBox* msg;
1196 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), 1196 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"),
1197 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")+ 1197 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")+
1198 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ 1198 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+
1199 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + 1199 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") +
1200 i18n("\nor report them in the bugtracker on\n") + 1200 i18n("\nor report them in the bugtracker on\n") +
1201 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), 1201 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"),
1202 QMessageBox::NoIcon, 1202 QMessageBox::NoIcon,
1203 QMessageBox::Ok, 1203 QMessageBox::Ok,
1204 QMessageBox::NoButton, 1204 QMessageBox::NoButton,
1205 QMessageBox::NoButton); 1205 QMessageBox::NoButton);
1206 msg->exec(); 1206 msg->exec();
1207 delete msg; 1207 delete msg;
1208 1208
1209} 1209}
1210 1210
1211QString MainWindow::defaultFileName() 1211QString MainWindow::defaultFileName()
1212{ 1212{
1213 return locateLocal( "data", "korganizer/mycalendar.ics" ); 1213 return locateLocal( "data", "korganizer/mycalendar.ics" );
1214} 1214}
1215QString MainWindow::syncFileName() 1215QString MainWindow::syncFileName()
1216{ 1216{
1217#ifdef _WIN32_ 1217#ifdef DESKTOP_VERSION
1218 return locateLocal( "tmp", "synccalendar.ics" ); 1218 return locateLocal( "tmp", "synccalendar.ics" );
1219#else 1219#else
1220 return QString( "/tmp/kopitempfile.ics" ); 1220 return QString( "/tmp/synccalendar.ics" );
1221#endif 1221#endif
1222} 1222}
1223 1223
1224void MainWindow::processIncidenceSelection( Incidence *incidence ) 1224void MainWindow::processIncidenceSelection( Incidence *incidence )
1225{ 1225{
1226 if ( !incidence ) { 1226 if ( !incidence ) {
1227 enableIncidenceActions( false ); 1227 enableIncidenceActions( false );
1228 1228
1229 mNewSubTodoAction->setEnabled( false ); 1229 mNewSubTodoAction->setEnabled( false );
1230 setCaptionToDates(); 1230 setCaptionToDates();
1231 return; 1231 return;
1232 1232
1233 } 1233 }
1234 1234
1235 //KGlobal::locale()->formatDateTime(nextA, true); 1235 //KGlobal::locale()->formatDateTime(nextA, true);
1236 QString startString = ""; 1236 QString startString = "";
1237 if ( incidence->type() != "Todo" ) { 1237 if ( incidence->type() != "Todo" ) {
1238 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { 1238 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) {
1239 if ( incidence->doesFloat() ) { 1239 if ( incidence->doesFloat() ) {
1240 startString += ": "+incidence->dtStartDateStr( true ); 1240 startString += ": "+incidence->dtStartDateStr( true );
1241 startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); 1241 startString += " --- "+((Event*)incidence)->dtEndDateStr( true );
1242 1242
1243 } else { 1243 } else {
1244 startString = ": "+incidence->dtStartStr(true); 1244 startString = ": "+incidence->dtStartStr(true);
1245 startString += " --- "+((Event*)incidence)->dtEndStr(true); 1245 startString += " --- "+((Event*)incidence)->dtEndStr(true);
1246 1246
1247 } 1247 }
1248 1248
1249 } else { 1249 } else {
1250 if ( incidence->dtStart().time() != incidence->dtEnd().time() ) 1250 if ( incidence->dtStart().time() != incidence->dtEnd().time() )
1251 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ 1251 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+
1252 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); 1252 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time());
1253 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); 1253 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true);
1254 } 1254 }
1255 1255
1256 } 1256 }
1257 else 1257 else
1258 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); 1258 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed");
1259 if ( !incidence->location().isEmpty() ) 1259 if ( !incidence->location().isEmpty() )
1260 startString += " (" +incidence->location()+")"; 1260 startString += " (" +incidence->location()+")";
1261 setCaption( incidence->summary()+startString); 1261 setCaption( incidence->summary()+startString);
1262 1262
1263 enableIncidenceActions( true ); 1263 enableIncidenceActions( true );
1264 1264
1265 if ( incidence->type() == "Event" ) { 1265 if ( incidence->type() == "Event" ) {
1266 mShowAction->setText( i18n("Show Event...") ); 1266 mShowAction->setText( i18n("Show Event...") );
1267 mEditAction->setText( i18n("Edit Event...") ); 1267 mEditAction->setText( i18n("Edit Event...") );
1268 mDeleteAction->setText( i18n("Delete Event...") ); 1268 mDeleteAction->setText( i18n("Delete Event...") );
1269 1269
1270 mNewSubTodoAction->setEnabled( false ); 1270 mNewSubTodoAction->setEnabled( false );
1271 } else if ( incidence->type() == "Todo" ) { 1271 } else if ( incidence->type() == "Todo" ) {
1272 mShowAction->setText( i18n("Show Todo...") ); 1272 mShowAction->setText( i18n("Show Todo...") );
1273 mEditAction->setText( i18n("Edit Todo...") ); 1273 mEditAction->setText( i18n("Edit Todo...") );
1274 mDeleteAction->setText( i18n("Delete Todo...") ); 1274 mDeleteAction->setText( i18n("Delete Todo...") );
1275 1275
1276 mNewSubTodoAction->setEnabled( true ); 1276 mNewSubTodoAction->setEnabled( true );
1277 } else { 1277 } else {
1278 mShowAction->setText( i18n("Show...") ); 1278 mShowAction->setText( i18n("Show...") );
1279 mShowAction->setText( i18n("Edit...") ); 1279 mShowAction->setText( i18n("Edit...") );
1280 mShowAction->setText( i18n("Delete...") ); 1280 mShowAction->setText( i18n("Delete...") );
1281 1281
1282 mNewSubTodoAction->setEnabled( false ); 1282 mNewSubTodoAction->setEnabled( false );
1283 } 1283 }
1284} 1284}
1285 1285
1286void MainWindow::enableIncidenceActions( bool enabled ) 1286void MainWindow::enableIncidenceActions( bool enabled )
1287{ 1287{
1288 mShowAction->setEnabled( enabled ); 1288 mShowAction->setEnabled( enabled );
1289 mEditAction->setEnabled( enabled ); 1289 mEditAction->setEnabled( enabled );
1290 mDeleteAction->setEnabled( enabled ); 1290 mDeleteAction->setEnabled( enabled );
1291 1291
1292 mCloneAction->setEnabled( enabled ); 1292 mCloneAction->setEnabled( enabled );
1293 mMoveAction->setEnabled( enabled ); 1293 mMoveAction->setEnabled( enabled );
1294 mBeamAction->setEnabled( enabled ); 1294 mBeamAction->setEnabled( enabled );
1295 mCancelAction->setEnabled( enabled ); 1295 mCancelAction->setEnabled( enabled );
1296} 1296}
1297 1297
1298void MainWindow::importOL() 1298void MainWindow::importOL()
1299{ 1299{
1300#ifdef _WIN32_ 1300#ifdef _WIN32_
1301 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); 1301 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this );
1302 id->exec(); 1302 id->exec();
1303 delete id; 1303 delete id;
1304 mView->updateView(); 1304 mView->updateView();
1305#endif 1305#endif
1306} 1306}
1307void MainWindow::importBday() 1307void MainWindow::importBday()
1308{ 1308{
1309 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1309 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1310 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), 1310 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"),
1311 i18n("Import!"), i18n("Cancel"), 0, 1311 i18n("Import!"), i18n("Cancel"), 0,
1312 0, 1 ); 1312 0, 1 );
1313 if ( result == 0 ) { 1313 if ( result == 0 ) {
1314 mView->importBday(); 1314 mView->importBday();
1315 1315
1316 } 1316 }
1317 1317
1318 1318
1319} 1319}
1320void MainWindow::importQtopia() 1320void MainWindow::importQtopia()
1321{ 1321{
1322#ifndef DESKTOP_VERSION 1322#ifndef DESKTOP_VERSION
1323 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1323 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1324 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"), 1324 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"),
1325 i18n("Import!"), i18n("Cancel"), 0, 1325 i18n("Import!"), i18n("Cancel"), 0,
1326 0, 1 ); 1326 0, 1 );
1327 if ( result == 0 ) { 1327 if ( result == 0 ) {
1328 QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); 1328 QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
1329 QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); 1329 QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
1330 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; 1330 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
1331 mView->importQtopia( categories, datebook, todolist ); 1331 mView->importQtopia( categories, datebook, todolist );
1332 } 1332 }
1333#else 1333#else
1334 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1334 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1335 i18n("Not supported \non desktop!\n"), 1335 i18n("Not supported \non desktop!\n"),
1336 i18n("Ok"), i18n("Cancel"), 0, 1336 i18n("Ok"), i18n("Cancel"), 0,
1337 0, 1 ); 1337 0, 1 );
1338 1338
1339#endif 1339#endif
1340} 1340}
1341 1341
1342void MainWindow::saveOnClose() 1342void MainWindow::saveOnClose()
1343{ 1343{
1344 KOPrefs *p = KOPrefs::instance(); 1344 KOPrefs *p = KOPrefs::instance();
1345 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); 1345 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
1346 p->mToolBarUp = iconToolBar->x() > width()/2 || 1346 p->mToolBarUp = iconToolBar->x() > width()/2 ||
1347 iconToolBar->y() > height()/2; 1347 iconToolBar->y() > height()/2;
1348 mView->writeSettings(); 1348 mView->writeSettings();
1349 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) 1349 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName()))
1350 save(); 1350 save();
1351} 1351}
1352void MainWindow::slotModifiedChanged( bool changed ) 1352void MainWindow::slotModifiedChanged( bool changed )
1353{ 1353{
1354 if ( mBlockAtStartup ) 1354 if ( mBlockAtStartup )
1355 return; 1355 return;
1356 int msec; 1356 int msec;
1357 // we store the changes after 1 minute, 1357 // we store the changes after 1 minute,
1358 // and for safety reasons after 10 minutes again 1358 // and for safety reasons after 10 minutes again
1359 if ( !mSyncManager->blockSave() ) 1359 if ( !mSyncManager->blockSave() )
1360 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1360 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1361 else 1361 else
1362 msec = 1000 * 600; 1362 msec = 1000 * 600;
1363 mSaveTimer.start( msec, true ); // 1 minute 1363 mSaveTimer.start( msec, true ); // 1 minute
1364 qDebug("KO: Saving File in %d secs!", msec/1000); 1364 qDebug("KO: Saving File in %d secs!", msec/1000);
1365 mCalendarModifiedFlag = true; 1365 mCalendarModifiedFlag = true;
1366} 1366}
1367void MainWindow::save() 1367void MainWindow::save()
1368{ 1368{
1369 if ( mSyncManager->blockSave() ) 1369 if ( mSyncManager->blockSave() )
1370 return; 1370 return;
1371 mSyncManager->setBlockSave(true); 1371 mSyncManager->setBlockSave(true);
1372 if ( mView->checkFileVersion( defaultFileName()) ) { 1372 if ( mView->checkFileVersion( defaultFileName()) ) {
1373 1373
1374 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1374 QTime neededSaveTime = QDateTime::currentDateTime().time();
1375 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1375 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1376 qDebug("KO: Start saving data to file!"); 1376 qDebug("KO: Start saving data to file!");
1377 mView->saveCalendar( defaultFileName() ); 1377 mView->saveCalendar( defaultFileName() );
1378 1378
1379 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 1379 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1380 qDebug("KO: Needed %d ms for saving.",msNeeded ); 1380 qDebug("KO: Needed %d ms for saving.",msNeeded );
1381 QString savemes; 1381 QString savemes;
1382 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 1382 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
1383 setCaption(savemes); 1383 setCaption(savemes);
1384 } else 1384 } else
1385 setCaption(i18n("Saving cancelled!")); 1385 setCaption(i18n("Saving cancelled!"));
1386 mCalendarModifiedFlag = false; 1386 mCalendarModifiedFlag = false;
1387 mSyncManager->setBlockSave( false ); 1387 mSyncManager->setBlockSave( false );
1388} 1388}
1389 1389
1390void MainWindow::keyReleaseEvent ( QKeyEvent * e) 1390void MainWindow::keyReleaseEvent ( QKeyEvent * e)
1391{ 1391{
1392 if ( !e->isAutoRepeat() ) { 1392 if ( !e->isAutoRepeat() ) {
1393 mFlagKeyPressed = false; 1393 mFlagKeyPressed = false;
1394 } 1394 }
1395} 1395}
1396void MainWindow::keyPressEvent ( QKeyEvent * e ) 1396void MainWindow::keyPressEvent ( QKeyEvent * e )
1397{ 1397{
1398 qApp->processEvents(); 1398 qApp->processEvents();
1399 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 1399 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1400 e->ignore(); 1400 e->ignore();
1401 // qDebug(" ignore %d",e->isAutoRepeat() ); 1401 // qDebug(" ignore %d",e->isAutoRepeat() );
1402 return; 1402 return;
1403 } 1403 }
1404 if (! e->isAutoRepeat() ) 1404 if (! e->isAutoRepeat() )
1405 mFlagKeyPressed = true; 1405 mFlagKeyPressed = true;
1406 KOPrefs *p = KOPrefs::instance(); 1406 KOPrefs *p = KOPrefs::instance();
1407 bool showSelectedDates = false; 1407 bool showSelectedDates = false;
1408 int size; 1408 int size;
1409 int pro = 0; 1409 int pro = 0;
1410 //qDebug("MainWindow::keyPressEvent "); 1410 //qDebug("MainWindow::keyPressEvent ");
1411 switch ( e->key() ) { 1411 switch ( e->key() ) {
1412 case Qt::Key_Right: 1412 case Qt::Key_Right:
1413 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1413 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1414 mView->goNextMonth(); 1414 mView->goNextMonth();
1415 else 1415 else
1416 mView->goNext(); 1416 mView->goNext();
1417 showSelectedDates = true; 1417 showSelectedDates = true;
1418 break; 1418 break;
1419 case Qt::Key_Left: 1419 case Qt::Key_Left:
1420 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1420 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1421 mView->goPreviousMonth(); 1421 mView->goPreviousMonth();
1422 else 1422 else
1423 mView->goPrevious(); 1423 mView->goPrevious();
1424 showSelectedDates = true; 1424 showSelectedDates = true;
1425 break; 1425 break;
1426 case Qt::Key_Down: 1426 case Qt::Key_Down:
1427 mView->viewManager()->agendaView()->scrollOneHourDown(); 1427 mView->viewManager()->agendaView()->scrollOneHourDown();
1428 break; 1428 break;
1429 case Qt::Key_Up: 1429 case Qt::Key_Up:
1430 mView->viewManager()->agendaView()->scrollOneHourUp(); 1430 mView->viewManager()->agendaView()->scrollOneHourUp();
1431 break; 1431 break;
1432 case Qt::Key_I: 1432 case Qt::Key_I:
1433 mView->showIncidence(); 1433 mView->showIncidence();
1434 break; 1434 break;
1435 case Qt::Key_Delete: 1435 case Qt::Key_Delete:
1436 case Qt::Key_Backspace: 1436 case Qt::Key_Backspace:
1437 mView->deleteIncidence(); 1437 mView->deleteIncidence();
1438 break; 1438 break;
1439 case Qt::Key_D: 1439 case Qt::Key_D:
1440 mView->viewManager()->showDayView(); 1440 mView->viewManager()->showDayView();
1441 showSelectedDates = true; 1441 showSelectedDates = true;
1442 break; 1442 break;
1443 case Qt::Key_O: 1443 case Qt::Key_O:
1444 mView->toggleFilerEnabled( ); 1444 mView->toggleFilerEnabled( );
1445 break; 1445 break;
1446 case Qt::Key_0: 1446 case Qt::Key_0:
1447 case Qt::Key_1: 1447 case Qt::Key_1:
1448 case Qt::Key_2: 1448 case Qt::Key_2:
1449 case Qt::Key_3: 1449 case Qt::Key_3:
1450 case Qt::Key_4: 1450 case Qt::Key_4:
1451 case Qt::Key_5: 1451 case Qt::Key_5:
1452 case Qt::Key_6: 1452 case Qt::Key_6:
1453 case Qt::Key_7: 1453 case Qt::Key_7:
1454 case Qt::Key_8: 1454 case Qt::Key_8:
1455 case Qt::Key_9: 1455 case Qt::Key_9:
1456 pro = e->key()-48; 1456 pro = e->key()-48;
1457 if ( pro == 0 ) 1457 if ( pro == 0 )
1458 pro = 10; 1458 pro = 10;
1459 if ( e->state() == Qt::ControlButton) 1459 if ( e->state() == Qt::ControlButton)
1460 pro += 10; 1460 pro += 10;
1461 break; 1461 break;
1462 case Qt::Key_M: 1462 case Qt::Key_M:
1463 mView->viewManager()->showMonthView(); 1463 mView->viewManager()->showMonthView();
1464 showSelectedDates = true; 1464 showSelectedDates = true;
1465 break; 1465 break;
1466 case Qt::Key_Insert: 1466 case Qt::Key_Insert:
1467 mView->newEvent(); 1467 mView->newEvent();
1468 break; 1468 break;
1469 case Qt::Key_S : 1469 case Qt::Key_S :
1470 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1470 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1471 mView->newSubTodo(); 1471 mView->newSubTodo();
1472 else 1472 else
1473 mView->dialogManager()->showSearchDialog(); 1473 mView->dialogManager()->showSearchDialog();
1474 break; 1474 break;
1475 case Qt::Key_Y : 1475 case Qt::Key_Y :
1476 case Qt::Key_Z : 1476 case Qt::Key_Z :
1477 mView->viewManager()->showWorkWeekView(); 1477 mView->viewManager()->showWorkWeekView();
1478 showSelectedDates = true; 1478 showSelectedDates = true;
1479 break; 1479 break;
1480 case Qt::Key_U : 1480 case Qt::Key_U :
1481 mView->viewManager()->showWeekView(); 1481 mView->viewManager()->showWeekView();
1482 showSelectedDates = true; 1482 showSelectedDates = true;
1483 break; 1483 break;
1484 case Qt::Key_H : 1484 case Qt::Key_H :
1485 keyBindings(); 1485 keyBindings();
1486 break; 1486 break;
1487 case Qt::Key_W: 1487 case Qt::Key_W:
1488 mView->viewManager()->showWhatsNextView(); 1488 mView->viewManager()->showWhatsNextView();
1489 break; 1489 break;
1490 case Qt::Key_L: 1490 case Qt::Key_L:
1491 mView->viewManager()->showListView(); 1491 mView->viewManager()->showListView();
1492 break; 1492 break;
1493 case Qt::Key_N: 1493 case Qt::Key_N:
1494 mView->viewManager()->showNextXView(); 1494 mView->viewManager()->showNextXView();
1495 showSelectedDates = true; 1495 showSelectedDates = true;
1496 break; 1496 break;
1497 case Qt::Key_V: 1497 case Qt::Key_V:
1498 mView->viewManager()->showTodoView(); 1498 mView->viewManager()->showTodoView();
1499 break; 1499 break;
1500 case Qt::Key_C: 1500 case Qt::Key_C:
1501 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); 1501 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() );
1502 break; 1502 break;
1503 case Qt::Key_P: 1503 case Qt::Key_P:
1504 mView->showDatePicker( ); 1504 mView->showDatePicker( );
1505 break; 1505 break;
1506 case Qt::Key_F: 1506 case Qt::Key_F:
1507 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1507 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1508 mView->editFilters(); 1508 mView->editFilters();
1509 else 1509 else
1510 mView->toggleFilter(); 1510 mView->toggleFilter();
1511 break; 1511 break;
1512 case Qt::Key_X: 1512 case Qt::Key_X:
1513 mView->toggleDateNavigatorWidget(); 1513 mView->toggleDateNavigatorWidget();
1514 break; 1514 break;
1515 case Qt::Key_Space: 1515 case Qt::Key_Space:
1516 mView->toggleExpand(); 1516 mView->toggleExpand();
1517 break; 1517 break;
1518 case Qt::Key_A: 1518 case Qt::Key_A:
1519 mView->toggleAllDaySize(); 1519 mView->toggleAllDaySize();
1520 break; 1520 break;
1521 case Qt::Key_T: 1521 case Qt::Key_T:
1522 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1522 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1523 mView->newTodo(); 1523 mView->newTodo();
1524 else { 1524 else {
1525 mView->goToday(); 1525 mView->goToday();
1526 showSelectedDates = true; 1526 showSelectedDates = true;
1527 } 1527 }
1528 break; 1528 break;
1529 case Qt::Key_J: 1529 case Qt::Key_J:
1530 mView->viewManager()->showJournalView(); 1530 mView->viewManager()->showJournalView();
1531 break; 1531 break;
1532 case Qt::Key_B: 1532 case Qt::Key_B:
1533 mView->editIncidenceDescription();; 1533 mView->editIncidenceDescription();;
1534 break; 1534 break;
1535 // case Qt::Key_Return: 1535 // case Qt::Key_Return:
1536 case Qt::Key_E: 1536 case Qt::Key_E:
1537 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1537 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1538 mView->newEvent(); 1538 mView->newEvent();
1539 else 1539 else
1540 mView->editIncidence(); 1540 mView->editIncidence();
1541 break; 1541 break;
1542 case Qt::Key_Plus: 1542 case Qt::Key_Plus:
1543 size = p->mHourSize +2; 1543 size = p->mHourSize +2;
1544 if ( size <= 18 ) 1544 if ( size <= 18 )
1545 configureAgenda( size ); 1545 configureAgenda( size );
1546 break; 1546 break;
1547 case Qt::Key_Minus: 1547 case Qt::Key_Minus:
1548 size = p->mHourSize - 2; 1548 size = p->mHourSize - 2;
1549 if ( size >= 4 ) 1549 if ( size >= 4 )
1550 configureAgenda( size ); 1550 configureAgenda( size );
1551 break; 1551 break;
1552 1552
1553 1553
1554 default: 1554 default:
1555 e->ignore(); 1555 e->ignore();
1556 } 1556 }
1557 if ( pro > 0 ) { 1557 if ( pro > 0 ) {
1558 mView->selectFilter( pro-1 ); 1558 mView->selectFilter( pro-1 );
1559 } 1559 }
1560 if ( showSelectedDates ) { 1560 if ( showSelectedDates ) {
1561 ;// setCaptionToDates(); 1561 ;// setCaptionToDates();
1562 } 1562 }
1563 1563
1564} 1564}
1565 1565
1566void MainWindow::fillFilterMenu() 1566void MainWindow::fillFilterMenu()
1567{ 1567{
1568 selectFilterMenu->clear(); 1568 selectFilterMenu->clear();
1569 bool disable = false; 1569 bool disable = false;
1570 if ( mView->filterView()->filtersEnabled() ) { 1570 if ( mView->filterView()->filtersEnabled() ) {
1571 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 ); 1571 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 );
1572 } 1572 }
1573 else { 1573 else {
1574 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 ); 1574 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 );
1575 disable = true; 1575 disable = true;
1576 } 1576 }
1577 selectFilterMenu->insertSeparator(); 1577 selectFilterMenu->insertSeparator();
1578 QPtrList<CalFilter> fili = mView->filters(); 1578 QPtrList<CalFilter> fili = mView->filters();
1579 CalFilter *curfilter = mView->filterView()->selectedFilter(); 1579 CalFilter *curfilter = mView->filterView()->selectedFilter();
1580 CalFilter *filter = fili.first(); 1580 CalFilter *filter = fili.first();
1581 int iii = 1; 1581 int iii = 1;
1582 while(filter) { 1582 while(filter) {
1583 selectFilterMenu->insertItem( filter->name(), iii ); 1583 selectFilterMenu->insertItem( filter->name(), iii );
1584 if ( filter == curfilter) 1584 if ( filter == curfilter)
1585 selectFilterMenu->setItemChecked( iii, true ); 1585 selectFilterMenu->setItemChecked( iii, true );
1586 if ( disable ) 1586 if ( disable )
1587 selectFilterMenu->setItemEnabled( iii, false ); 1587 selectFilterMenu->setItemEnabled( iii, false );
1588 filter = fili.next(); 1588 filter = fili.next();
1589 ++iii; 1589 ++iii;
1590 } 1590 }
1591} 1591}
1592void MainWindow::selectFilter( int fil ) 1592void MainWindow::selectFilter( int fil )
1593{ 1593{
1594 if ( fil == 0 ) { 1594 if ( fil == 0 ) {
1595 mView->toggleFilerEnabled( ); 1595 mView->toggleFilerEnabled( );
1596 } else { 1596 } else {
1597 mView->selectFilter( fil-1 ); 1597 mView->selectFilter( fil-1 );
1598 } 1598 }
1599} 1599}
1600void MainWindow::configureToolBar( int item ) 1600void MainWindow::configureToolBar( int item )
1601{ 1601{
1602 1602
1603 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); 1603 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) );
1604 KOPrefs *p = KOPrefs::instance(); 1604 KOPrefs *p = KOPrefs::instance();
1605 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); 1605 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 );
1606 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); 1606 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 );
1607 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); 1607 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 );
1608 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); 1608 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 );
1609 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); 1609 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 );
1610 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); 1610 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 );
1611 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); 1611 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 );
1612 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); 1612 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 );
1613 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); 1613 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 );
1614 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); 1614 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 );
1615 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); 1615 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 );
1616 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); 1616 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 );
1617 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); 1617 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 );
1618 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); 1618 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 );
1619 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); 1619 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 );
1620 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); 1620 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 );
1621 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); 1621 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 );
1622 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); 1622 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 );
1623 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); 1623 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 );
1624 // initActions(); 1624 // initActions();
1625} 1625}
1626 1626
1627void MainWindow::setCaptionToDates() 1627void MainWindow::setCaptionToDates()
1628{ 1628{
1629 QString selDates; 1629 QString selDates;
1630 selDates = KGlobal::locale()->formatDate(mView->startDate(), true); 1630 selDates = KGlobal::locale()->formatDate(mView->startDate(), true);
1631 if (mView->startDate() < mView->endDate() ) 1631 if (mView->startDate() < mView->endDate() )
1632 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); 1632 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true);
1633 setCaption( i18n("Dates: ") + selDates ); 1633 setCaption( i18n("Dates: ") + selDates );
1634 1634
1635} 1635}
1636// parameter item == 0: reinit 1636// parameter item == 0: reinit
1637void MainWindow::configureAgenda( int item ) 1637void MainWindow::configureAgenda( int item )
1638{ 1638{
1639 1639
1640 KOPrefs *p = KOPrefs::instance(); 1640 KOPrefs *p = KOPrefs::instance();
1641 1641
1642 int i; 1642 int i;
1643 if ( item == 1 ) { 1643 if ( item == 1 ) {
1644 mView->toggleAllDaySize(); 1644 mView->toggleAllDaySize();
1645 return; 1645 return;
1646 } 1646 }
1647 // do not allow 4 for widgets higher than 480 1647 // do not allow 4 for widgets higher than 480
1648 // if ( QApplication::desktop()->height() > 480 ) { 1648 // if ( QApplication::desktop()->height() > 480 ) {
1649// if ( item == 4 ) 1649// if ( item == 4 )
1650// item = 6; 1650// item = 6;
1651// } 1651// }
1652 for ( i = 4; i <= 18; i= i+2 ) 1652 for ( i = 4; i <= 18; i= i+2 )
1653 configureAgendaMenu->setItemChecked( i, false ); 1653 configureAgendaMenu->setItemChecked( i, false );
1654 configureAgendaMenu->setItemChecked( item, true ); 1654 configureAgendaMenu->setItemChecked( item, true );
1655 if ( p->mHourSize == item ) 1655 if ( p->mHourSize == item )
1656 return; 1656 return;
1657 p->mHourSize=item; 1657 p->mHourSize=item;
1658 mView->viewManager()->agendaView()->updateConfig(); 1658 mView->viewManager()->agendaView()->updateConfig();
1659} 1659}
1660 1660
1661void MainWindow::saveCalendar() 1661void MainWindow::saveCalendar()
1662{ 1662{
1663 QString fn = KOPrefs::instance()->mLastSaveFile; 1663 QString fn = KOPrefs::instance()->mLastSaveFile;
1664 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); 1664 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this );
1665 1665
1666 if ( fn == "" ) 1666 if ( fn == "" )
1667 return; 1667 return;
1668 QFileInfo info; 1668 QFileInfo info;
1669 info.setFile( fn ); 1669 info.setFile( fn );
1670 QString mes; 1670 QString mes;
1671 bool createbup = true; 1671 bool createbup = true;
1672 if ( info. exists() ) { 1672 if ( info. exists() ) {
1673 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; 1673 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ;
1674 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1674 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1675 i18n("Overwrite!"), i18n("Cancel"), 0, 1675 i18n("Overwrite!"), i18n("Cancel"), 0,
1676 0, 1 ); 1676 0, 1 );
1677 if ( result != 0 ) { 1677 if ( result != 0 ) {
1678 createbup = false; 1678 createbup = false;
1679 } 1679 }
1680 } 1680 }
1681 if ( createbup ) { 1681 if ( createbup ) {
1682 mView->saveCalendar( fn ); 1682 mView->saveCalendar( fn );
1683 mes = i18n("KO/Pi:Saved %1").arg(fn); 1683 mes = i18n("KO/Pi:Saved %1").arg(fn);
1684 KOPrefs::instance()->mLastSaveFile = fn; 1684 KOPrefs::instance()->mLastSaveFile = fn;
1685 setCaption(mes); 1685 setCaption(mes);
1686 } 1686 }
1687} 1687}
1688void MainWindow::loadCalendar() 1688void MainWindow::loadCalendar()
1689{ 1689{
1690 1690
1691 QString fn = KOPrefs::instance()->mLastLoadFile; 1691 QString fn = KOPrefs::instance()->mLastLoadFile;
1692 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); 1692 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this );
1693 1693
1694 if ( fn == "" ) 1694 if ( fn == "" )
1695 return; 1695 return;
1696 QFileInfo info; 1696 QFileInfo info;
1697 info.setFile( fn ); 1697 info.setFile( fn );
1698 QString mess; 1698 QString mess;
1699 bool loadbup = true; 1699 bool loadbup = true;
1700 if ( info. exists() ) { 1700 if ( info. exists() ) {
1701 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1701 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1702 int result = QMessageBox::warning( this, "KO/Pi: Warning!", 1702 int result = QMessageBox::warning( this, "KO/Pi: Warning!",
1703 mess, 1703 mess,
1704 i18n("Load!"), i18n("Cancel"), 0, 1704 i18n("Load!"), i18n("Cancel"), 0,
1705 0, 1 ); 1705 0, 1 );
1706 if ( result != 0 ) { 1706 if ( result != 0 ) {
1707 loadbup = false; 1707 loadbup = false;
1708 } 1708 }
1709 } else { 1709 } else {
1710 QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1710 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1711 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, 1711 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0,
1712 0, 1 ); 1712 0, 1 );
1713 1713
1714 return; 1714 return;
1715 } 1715 }
1716 if ( loadbup ) { 1716 if ( loadbup ) {
1717 mView->openCalendar( fn ); 1717 mView->openCalendar( fn );
1718 KOPrefs::instance()->mLastLoadFile = fn; 1718 KOPrefs::instance()->mLastLoadFile = fn;
1719 mess = i18n("KO/Pi:Loaded %1").arg(fn) ; 1719 mess = i18n("KO/Pi:Loaded %1").arg(fn) ;
1720 setCaption(mess); 1720 setCaption(mess);
1721 } 1721 }
1722 1722
1723} 1723}
1724void MainWindow::quickImportIcal() 1724void MainWindow::quickImportIcal()
1725{ 1725{
1726 importFile( KOPrefs::instance()->mLastImportFile, false ); 1726 importFile( KOPrefs::instance()->mLastImportFile, false );
1727} 1727}
1728void MainWindow::importFile( QString fn, bool quick ) 1728void MainWindow::importFile( QString fn, bool quick )
1729{ 1729{
1730 QFileInfo info; 1730 QFileInfo info;
1731 info.setFile( fn ); 1731 info.setFile( fn );
1732 QString mess; 1732 QString mess;
1733 bool loadbup = true; 1733 bool loadbup = true;
1734 if ( !info. exists() ) { 1734 if ( !info. exists() ) {
1735 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); 1735 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30));
1736 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1736 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1737 mess ); 1737 mess );
1738 return; 1738 return;
1739 } 1739 }
1740 int result = 0; 1740 int result = 0;
1741 if ( !quick ) { 1741 if ( !quick ) {
1742 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 )); 1742 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 ));
1743 result = QMessageBox::warning( this, "KO/Pi: Warning!", 1743 result = QMessageBox::warning( this, "KO/Pi: Warning!",
1744 mess, 1744 mess,
1745 "Import", "Cancel", 0, 1745 "Import", "Cancel", 0,
1746 0, 1 ); 1746 0, 1 );
1747 } 1747 }
1748 if ( result == 0 ) { 1748 if ( result == 0 ) {
1749 if ( mView->openCalendar( fn, true )) { 1749 if ( mView->openCalendar( fn, true )) {
1750 KOPrefs::instance()->mLastImportFile = fn; 1750 KOPrefs::instance()->mLastImportFile = fn;
1751 setCaption(i18n("Imported file successfully")); 1751 setCaption(i18n("Imported file successfully"));
1752 } else { 1752 } else {
1753 setCaption(i18n("Error importing file")); 1753 setCaption(i18n("Error importing file"));
1754 } 1754 }
1755 } 1755 }
1756} 1756}
1757 1757
1758void MainWindow::importIcal() 1758void MainWindow::importIcal()
1759{ 1759{
1760 1760
1761 QString fn =KOPrefs::instance()->mLastImportFile; 1761 QString fn =KOPrefs::instance()->mLastImportFile;
1762 1762
1763 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); 1763 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this );
1764 if ( fn == "" ) 1764 if ( fn == "" )
1765 return; 1765 return;
1766 importFile( fn, true ); 1766 importFile( fn, true );
1767 1767
1768} 1768}
1769 1769
1770void MainWindow::exportVCalendar() 1770void MainWindow::exportVCalendar()
1771{ 1771{
1772 QString fn = KOPrefs::instance()->mLastVcalFile; 1772 QString fn = KOPrefs::instance()->mLastVcalFile;
1773 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); 1773 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this );
1774 if ( fn == "" ) 1774 if ( fn == "" )
1775 return; 1775 return;
1776 QFileInfo info; 1776 QFileInfo info;
1777 info.setFile( fn ); 1777 info.setFile( fn );
1778 QString mes; 1778 QString mes;
1779 bool createbup = true; 1779 bool createbup = true;
1780 if ( info. exists() ) { 1780 if ( info. exists() ) {
1781 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 1781 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
1782 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1782 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1783 i18n("Overwrite!"), i18n("Cancel"), 0, 1783 i18n("Overwrite!"), i18n("Cancel"), 0,
1784 0, 1 ); 1784 0, 1 );
1785 if ( result != 0 ) { 1785 if ( result != 0 ) {
1786 createbup = false; 1786 createbup = false;
1787 } 1787 }
1788 } 1788 }
1789 if ( createbup ) { 1789 if ( createbup ) {
1790 if ( mView->exportVCalendar( fn ) ) { 1790 if ( mView->exportVCalendar( fn ) ) {
1791 KOPrefs::instance()->mLastVcalFile = fn; 1791 KOPrefs::instance()->mLastVcalFile = fn;
1792 if ( fn.length() > 20 ) 1792 if ( fn.length() > 20 )
1793 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; 1793 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ;
1794 else 1794 else
1795 mes = i18n("KO/Pi:Exported to %1").arg(fn ); 1795 mes = i18n("KO/Pi:Exported to %1").arg(fn );
1796 setCaption(mes); 1796 setCaption(mes);
1797 } 1797 }
1798 } 1798 }
1799 1799
1800} 1800}
1801 1801
1802void MainWindow::syncFileRequest() 1802void MainWindow::syncFileRequest()
1803{ 1803{
1804 save(); 1804 save();
1805} 1805}
1806void MainWindow::getFile( bool success ) 1806void MainWindow::getFile( bool success )
1807{ 1807{
1808 if ( ! success ) { 1808 if ( ! success ) {
1809 setCaption( i18n("Error receiving file. Nothing changed!") ); 1809 setCaption( i18n("Error receiving file. Nothing changed!") );
1810 return; 1810 return;
1811 } 1811 }
1812 mView->openCalendar( defaultFileName() ); 1812 mView->openCalendar( defaultFileName() );
1813 setCaption( i18n("Pi-Sync successful!") ); 1813 setCaption( i18n("Pi-Sync successful!") );
1814} 1814}
1815 1815
1816void MainWindow::printSel( ) 1816void MainWindow::printSel( )
1817{ 1817{
1818 mView->viewManager()->agendaView()->agenda()->printSelection(); 1818 mView->viewManager()->agendaView()->agenda()->printSelection();
1819} 1819}
1820 1820
1821void MainWindow::printCal() 1821void MainWindow::printCal()
1822{ 1822{
1823 mView->print();//mCp->showDialog(); 1823 mView->print();//mCp->showDialog();
1824} 1824}
1825 1825