summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp1
-rw-r--r--korganizer/mainwindow.cpp4
2 files changed, 3 insertions, 2 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 387b751..cfc6b10 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,1460 +1,1459 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Requires the Qt and KDE widget libraries, available at no cost at 4 Requires the Qt and KDE widget libraries, available at no cost at
5 http://www.troll.no and http://www.kde.org respectively 5 http://www.troll.no and http://www.kde.org respectively
6 6
7 Copyright (c) 1997, 1998, 1999 7 Copyright (c) 1997, 1998, 1999
8 Preston Brown (preston.brown@yale.edu) 8 Preston Brown (preston.brown@yale.edu)
9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) 9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl)
10 Ian Dawes (iadawes@globalserve.net) 10 Ian Dawes (iadawes@globalserve.net)
11 Laszlo Boloni (boloni@cs.purdue.edu) 11 Laszlo Boloni (boloni@cs.purdue.edu)
12 12
13 Copyright (c) 2000, 2001, 2002 13 Copyright (c) 2000, 2001, 2002
14 Cornelius Schumacher <schumacher@kde.org> 14 Cornelius Schumacher <schumacher@kde.org>
15 15
16 This program is free software; you can redistribute it and/or modify 16 This program is free software; you can redistribute it and/or modify
17 it under the terms of the GNU General Public License as published by 17 it under the terms of the GNU General Public License as published by
18 the Free Software Foundation; either version 2 of the License, or 18 the Free Software Foundation; either version 2 of the License, or
19 (at your option) any later version. 19 (at your option) any later version.
20 20
21 This program is distributed in the hope that it will be useful, 21 This program is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of 22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
24 GNU General Public License for more details. 24 GNU General Public License for more details.
25 25
26 You should have received a copy of the GNU General Public License 26 You should have received a copy of the GNU General Public License
27 along with this program; if not, write to the Free Software 27 along with this program; if not, write to the Free Software
28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29*/ 29*/
30 30
31#include <stdlib.h> 31#include <stdlib.h>
32 32
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qradiobutton.h> 34#include <qradiobutton.h>
35#include <qbuttongroup.h> 35#include <qbuttongroup.h>
36#include <qlayout.h> 36#include <qlayout.h>
37#include <qclipboard.h> 37#include <qclipboard.h>
38#include <qcursor.h> 38#include <qcursor.h>
39#include <qmessagebox.h> 39#include <qmessagebox.h>
40#include <qprogressbar.h> 40#include <qprogressbar.h>
41#include <qmultilineedit.h> 41#include <qmultilineedit.h>
42#include <qtimer.h> 42#include <qtimer.h>
43#include <qwidgetstack.h> 43#include <qwidgetstack.h>
44#include <qptrlist.h> 44#include <qptrlist.h>
45#include <qregexp.h> 45#include <qregexp.h>
46#include <qgroupbox.h> 46#include <qgroupbox.h>
47#include <qfile.h> 47#include <qfile.h>
48#include <qdir.h> 48#include <qdir.h>
49#ifndef KORG_NOSPLITTER 49#ifndef KORG_NOSPLITTER
50#include <qsplitter.h> 50#include <qsplitter.h>
51#endif 51#endif
52 52
53#include <kglobal.h> 53#include <kglobal.h>
54#include <kdebug.h> 54#include <kdebug.h>
55#include <kstandarddirs.h> 55#include <kstandarddirs.h>
56#include <kfiledialog.h> 56#include <kfiledialog.h>
57#include <kmessagebox.h> 57#include <kmessagebox.h>
58#include <knotifyclient.h> 58#include <knotifyclient.h>
59#include <kconfig.h> 59#include <kconfig.h>
60 60
61#include <libkdepim/ksyncprefsdialog.h> 61#include <libkdepim/ksyncprefsdialog.h>
62#include <krun.h> 62#include <krun.h>
63#include <kdirwatch.h> 63#include <kdirwatch.h>
64#include <libkdepim/kdatepicker.h> 64#include <libkdepim/kdatepicker.h>
65#include <libkdepim/ksyncprofile.h> 65#include <libkdepim/ksyncprofile.h>
66 66
67#include <libkcal/vcaldrag.h> 67#include <libkcal/vcaldrag.h>
68#include <libkcal/icaldrag.h> 68#include <libkcal/icaldrag.h>
69#include <libkcal/icalformat.h> 69#include <libkcal/icalformat.h>
70#include <libkcal/vcalformat.h> 70#include <libkcal/vcalformat.h>
71#include <libkcal/scheduler.h> 71#include <libkcal/scheduler.h>
72#include <libkcal/calendarlocal.h> 72#include <libkcal/calendarlocal.h>
73#include <libkcal/journal.h> 73#include <libkcal/journal.h>
74#include <libkcal/calfilter.h> 74#include <libkcal/calfilter.h>
75#include <libkcal/attendee.h> 75#include <libkcal/attendee.h>
76#include <libkcal/dndfactory.h> 76#include <libkcal/dndfactory.h>
77#include <libkcal/freebusy.h> 77#include <libkcal/freebusy.h>
78#include <libkcal/filestorage.h> 78#include <libkcal/filestorage.h>
79#include <libkcal/calendarresources.h> 79#include <libkcal/calendarresources.h>
80#include <libkcal/qtopiaformat.h> 80#include <libkcal/qtopiaformat.h>
81#include "../kalarmd/alarmdialog.h" 81#include "../kalarmd/alarmdialog.h"
82 82
83#ifndef DESKTOP_VERSION 83#ifndef DESKTOP_VERSION
84#include <libkcal/sharpformat.h> 84#include <libkcal/sharpformat.h>
85#endif 85#endif
86#ifndef KORG_NOMAIL 86#ifndef KORG_NOMAIL
87#include "komailclient.h" 87#include "komailclient.h"
88#endif 88#endif
89#ifndef KORG_NOPRINTER 89#ifndef KORG_NOPRINTER
90#include "calprinter.h" 90#include "calprinter.h"
91#endif 91#endif
92#ifndef KORG_NOPLUGINS 92#ifndef KORG_NOPLUGINS
93#include "kocore.h" 93#include "kocore.h"
94#endif 94#endif
95#include "koeventeditor.h" 95#include "koeventeditor.h"
96#include "kotodoeditor.h" 96#include "kotodoeditor.h"
97#include "koprefs.h" 97#include "koprefs.h"
98#include "koeventviewerdialog.h" 98#include "koeventviewerdialog.h"
99#include "publishdialog.h" 99#include "publishdialog.h"
100#include "kofilterview.h" 100#include "kofilterview.h"
101#include "koglobals.h" 101#include "koglobals.h"
102#include "koviewmanager.h" 102#include "koviewmanager.h"
103#include "koagendaview.h" 103#include "koagendaview.h"
104#include "kodialogmanager.h" 104#include "kodialogmanager.h"
105#include "outgoingdialog.h" 105#include "outgoingdialog.h"
106#include "incomingdialog.h" 106#include "incomingdialog.h"
107#include "statusdialog.h" 107#include "statusdialog.h"
108#include "kdatenavigator.h" 108#include "kdatenavigator.h"
109#include "kotodoview.h" 109#include "kotodoview.h"
110#include "datenavigator.h" 110#include "datenavigator.h"
111#include "resourceview.h" 111#include "resourceview.h"
112#include "navigatorbar.h" 112#include "navigatorbar.h"
113#include "searchdialog.h" 113#include "searchdialog.h"
114#include "mainwindow.h" 114#include "mainwindow.h"
115 115
116#include "calendarview.h" 116#include "calendarview.h"
117#ifndef DESKTOP_VERSION 117#ifndef DESKTOP_VERSION
118#include <qtopia/alarmserver.h> 118#include <qtopia/alarmserver.h>
119#endif 119#endif
120#ifndef _WIN32_ 120#ifndef _WIN32_
121#include <stdlib.h> 121#include <stdlib.h>
122#include <stdio.h> 122#include <stdio.h>
123#include <unistd.h> 123#include <unistd.h>
124#else 124#else
125#include <qprocess.h> 125#include <qprocess.h>
126#endif 126#endif
127using namespace KOrg; 127using namespace KOrg;
128using namespace KCal; 128using namespace KCal;
129extern int globalFlagBlockAgenda; 129extern int globalFlagBlockAgenda;
130extern int globalFlagBlockStartup; 130extern int globalFlagBlockStartup;
131 131
132 132
133 133
134class KOBeamPrefs : public QDialog 134class KOBeamPrefs : public QDialog
135{ 135{
136 public: 136 public:
137 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : 137 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) :
138 QDialog( parent, name, true ) 138 QDialog( parent, name, true )
139 { 139 {
140 setCaption( i18n("Beam Options") ); 140 setCaption( i18n("Beam Options") );
141 QVBoxLayout* lay = new QVBoxLayout( this ); 141 QVBoxLayout* lay = new QVBoxLayout( this );
142 lay->setSpacing( 3 ); 142 lay->setSpacing( 3 );
143 lay->setMargin( 3 ); 143 lay->setMargin( 3 );
144 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); 144 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this );
145 lay->addWidget( format ); 145 lay->addWidget( format );
146 format->setExclusive ( true ) ; 146 format->setExclusive ( true ) ;
147 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); 147 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this );
148 lay->addWidget( time ); time->setExclusive ( true ) ; 148 lay->addWidget( time ); time->setExclusive ( true ) ;
149 vcal = new QRadioButton(" vCalendar ", format ); 149 vcal = new QRadioButton(" vCalendar ", format );
150 ical = new QRadioButton(" iCalendar ", format ); 150 ical = new QRadioButton(" iCalendar ", format );
151 vcal->setChecked( true ); 151 vcal->setChecked( true );
152 tz = new QRadioButton(i18n(" With timezone "), time ); 152 tz = new QRadioButton(i18n(" With timezone "), time );
153 local = new QRadioButton(i18n(" Local time "), time ); 153 local = new QRadioButton(i18n(" Local time "), time );
154 tz->setChecked( true ); 154 tz->setChecked( true );
155 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); 155 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this );
156 lay->addWidget( ok ); 156 lay->addWidget( ok );
157 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 157 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
158 lay->addWidget( cancel ); 158 lay->addWidget( cancel );
159 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 159 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
160 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 160 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
161 resize( 200, 200 ); 161 resize( 200, 200 );
162 } 162 }
163 163
164 bool beamVcal() { return vcal->isChecked(); } 164 bool beamVcal() { return vcal->isChecked(); }
165 bool beamLocal() { return local->isChecked(); } 165 bool beamLocal() { return local->isChecked(); }
166private: 166private:
167 QRadioButton* vcal, *ical, *local, *tz; 167 QRadioButton* vcal, *ical, *local, *tz;
168}; 168};
169class KOCatPrefs : public QDialog 169class KOCatPrefs : public QDialog
170{ 170{
171 public: 171 public:
172 KOCatPrefs( QWidget *parent=0, const char *name=0 ) : 172 KOCatPrefs( QWidget *parent=0, const char *name=0 ) :
173 QDialog( parent, name, true ) 173 QDialog( parent, name, true )
174 { 174 {
175 setCaption( i18n("Manage new Categories") ); 175 setCaption( i18n("Manage new Categories") );
176 QVBoxLayout* lay = new QVBoxLayout( this ); 176 QVBoxLayout* lay = new QVBoxLayout( this );
177 lay->setSpacing( 3 ); 177 lay->setSpacing( 3 );
178 lay->setMargin( 3 ); 178 lay->setMargin( 3 );
179 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); 179 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this );
180 lay->addWidget( lab ); 180 lay->addWidget( lab );
181 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 181 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
182 lay->addWidget( format ); 182 lay->addWidget( format );
183 format->setExclusive ( true ) ; 183 format->setExclusive ( true ) ;
184 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 184 addCatBut = new QRadioButton(i18n("Add to category list"), format );
185 new QRadioButton(i18n("Remove from Events/Todos"), format ); 185 new QRadioButton(i18n("Remove from Events/Todos"), format );
186 addCatBut->setChecked( true ); 186 addCatBut->setChecked( true );
187 QPushButton * ok = new QPushButton( i18n("OK"), this ); 187 QPushButton * ok = new QPushButton( i18n("OK"), this );
188 lay->addWidget( ok ); 188 lay->addWidget( ok );
189 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 189 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
190 lay->addWidget( cancel ); 190 lay->addWidget( cancel );
191 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 191 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
192 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 192 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
193 resize( 200, 200 ); 193 resize( 200, 200 );
194 } 194 }
195 195
196 bool addCat() { return addCatBut->isChecked(); } 196 bool addCat() { return addCatBut->isChecked(); }
197private: 197private:
198 QRadioButton* addCatBut; 198 QRadioButton* addCatBut;
199}; 199};
200 200
201 201
202 202
203CalendarView::CalendarView( CalendarResources *calendar, 203CalendarView::CalendarView( CalendarResources *calendar,
204 QWidget *parent, const char *name ) 204 QWidget *parent, const char *name )
205 : CalendarViewBase( parent, name ), 205 : CalendarViewBase( parent, name ),
206 mCalendar( calendar ), 206 mCalendar( calendar ),
207 mResourceManager( calendar->resourceManager() ) 207 mResourceManager( calendar->resourceManager() )
208{ 208{
209 209
210 mEventEditor = 0; 210 mEventEditor = 0;
211 mTodoEditor = 0; 211 mTodoEditor = 0;
212 212
213 init(); 213 init();
214} 214}
215 215
216CalendarView::CalendarView( Calendar *calendar, 216CalendarView::CalendarView( Calendar *calendar,
217 QWidget *parent, const char *name ) 217 QWidget *parent, const char *name )
218 : CalendarViewBase( parent, name ), 218 : CalendarViewBase( parent, name ),
219 mCalendar( calendar ), 219 mCalendar( calendar ),
220 mResourceManager( 0 ) 220 mResourceManager( 0 )
221{ 221{
222 222
223 mEventEditor = 0; 223 mEventEditor = 0;
224 mTodoEditor = 0; 224 mTodoEditor = 0;
225 init();} 225 init();}
226 226
227void CalendarView::init() 227void CalendarView::init()
228{ 228{
229 beamDialog = new KOBeamPrefs(); 229 beamDialog = new KOBeamPrefs();
230 mDatePickerMode = 0; 230 mDatePickerMode = 0;
231 mCurrentSyncDevice = ""; 231 mCurrentSyncDevice = "";
232 writeLocale(); 232 writeLocale();
233 mViewManager = new KOViewManager( this ); 233 mViewManager = new KOViewManager( this );
234 mDialogManager = new KODialogManager( this ); 234 mDialogManager = new KODialogManager( this );
235 mEventViewerDialog = 0; 235 mEventViewerDialog = 0;
236 mModified = false; 236 mModified = false;
237 mReadOnly = false; 237 mReadOnly = false;
238 mSelectedIncidence = 0; 238 mSelectedIncidence = 0;
239 mCalPrinter = 0; 239 mCalPrinter = 0;
240 mFilters.setAutoDelete(true); 240 mFilters.setAutoDelete(true);
241 241
242 mCalendar->registerObserver( this ); 242 mCalendar->registerObserver( this );
243 // TODO: Make sure that view is updated, when calendar is changed. 243 // TODO: Make sure that view is updated, when calendar is changed.
244 244
245 mStorage = new FileStorage( mCalendar ); 245 mStorage = new FileStorage( mCalendar );
246 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 246 mNavigator = new DateNavigator( this, "datevav", mViewManager );
247 247
248 QBoxLayout *topLayout = (QBoxLayout*)layout(); 248 QBoxLayout *topLayout = (QBoxLayout*)layout();
249#ifndef KORG_NOSPLITTER 249#ifndef KORG_NOSPLITTER
250 // create the main layout frames. 250 // create the main layout frames.
251 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 251 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
252 topLayout->addWidget(mPanner); 252 topLayout->addWidget(mPanner);
253 253
254 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 254 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
255 "CalendarView::LeftFrame"); 255 "CalendarView::LeftFrame");
256 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 256 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
257 257
258 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, 258 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE,
259 "CalendarView::DateNavigator", QDate::currentDate() ); 259 "CalendarView::DateNavigator", QDate::currentDate() );
260 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 260 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
261 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 261 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
262 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 262 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
263 263
264#ifdef KORG_NORESOURCEVIEW 264#ifdef KORG_NORESOURCEVIEW
265 mResourceView = 0; 265 mResourceView = 0;
266#else 266#else
267 if ( mResourceManager ) { 267 if ( mResourceManager ) {
268 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 268 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
269 mResourceView->updateView(); 269 mResourceView->updateView();
270 connect( mResourceView, SIGNAL( resourcesChanged() ), 270 connect( mResourceView, SIGNAL( resourcesChanged() ),
271 SLOT( updateView() ) ); 271 SLOT( updateView() ) );
272 } else { 272 } else {
273 mResourceView = 0; 273 mResourceView = 0;
274 } 274 }
275#endif 275#endif
276 QWidget *rightBox = new QWidget( mPanner ); 276 QWidget *rightBox = new QWidget( mPanner );
277 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 277 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
278 278
279 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 279 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
280 rightLayout->addWidget( mNavigatorBar ); 280 rightLayout->addWidget( mNavigatorBar );
281 281
282 mRightFrame = new QWidgetStack( rightBox ); 282 mRightFrame = new QWidgetStack( rightBox );
283 rightLayout->addWidget( mRightFrame, 1 ); 283 rightLayout->addWidget( mRightFrame, 1 );
284 284
285 mLeftFrame = mLeftSplitter; 285 mLeftFrame = mLeftSplitter;
286#else 286#else
287 QWidget *mainBox = new QWidget( this ); 287 QWidget *mainBox = new QWidget( this );
288 QWidget *leftFrame = new QWidget( mainBox ); 288 QWidget *leftFrame = new QWidget( mainBox );
289 289
290 QBoxLayout * mainBoxLayout; 290 QBoxLayout * mainBoxLayout;
291 QBoxLayout * leftFrameLayout; 291 QBoxLayout * leftFrameLayout;
292 if ( KOPrefs::instance()->mVerticalScreen ) { 292 if ( KOPrefs::instance()->mVerticalScreen ) {
293 mainBoxLayout = new QVBoxLayout(mainBox); 293 mainBoxLayout = new QVBoxLayout(mainBox);
294 leftFrameLayout = new QHBoxLayout(leftFrame ); 294 leftFrameLayout = new QHBoxLayout(leftFrame );
295 } else { 295 } else {
296 mainBoxLayout = new QHBoxLayout(mainBox); 296 mainBoxLayout = new QHBoxLayout(mainBox);
297 leftFrameLayout = new QVBoxLayout(leftFrame ); 297 leftFrameLayout = new QVBoxLayout(leftFrame );
298 } 298 }
299 topLayout->addWidget( mainBox ); 299 topLayout->addWidget( mainBox );
300 mainBoxLayout->addWidget (leftFrame); 300 mainBoxLayout->addWidget (leftFrame);
301 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, 301 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE,
302 "CalendarView::DateNavigator", QDate::currentDate()); 302 "CalendarView::DateNavigator", QDate::currentDate());
303 // mDateNavigator->blockSignals( true ); 303 // mDateNavigator->blockSignals( true );
304 leftFrameLayout->addWidget( mDateNavigator ); 304 leftFrameLayout->addWidget( mDateNavigator );
305 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); 305 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView");
306 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolist"); 306 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolist");
307 307
308 if ( QApplication::desktop()->width() < 480 ) { 308 if ( QApplication::desktop()->width() < 480 ) {
309 leftFrameLayout->addWidget(mFilterView); 309 leftFrameLayout->addWidget(mFilterView);
310 leftFrameLayout->addWidget(mTodoList, 2 ); 310 leftFrameLayout->addWidget(mTodoList, 2 );
311 311
312 } else { 312 } else {
313 leftFrameLayout->addWidget(mTodoList,2 ); 313 leftFrameLayout->addWidget(mTodoList,2 );
314 leftFrameLayout->addWidget(mFilterView ); 314 leftFrameLayout->addWidget(mFilterView );
315 } 315 }
316 mFilterView->hide(); 316 mFilterView->hide();
317 QWidget *rightBox = new QWidget( mainBox ); 317 QWidget *rightBox = new QWidget( mainBox );
318 mainBoxLayout->addWidget ( rightBox, 10 ); 318 mainBoxLayout->addWidget ( rightBox, 10 );
319 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 319 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
320 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 320 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
321 mRightFrame = new QWidgetStack( rightBox ); 321 mRightFrame = new QWidgetStack( rightBox );
322 rightLayout->addWidget( mNavigatorBar ); 322 rightLayout->addWidget( mNavigatorBar );
323 rightLayout->addWidget( mRightFrame, 10 ); 323 rightLayout->addWidget( mRightFrame, 10 );
324 324
325 mLeftFrame = leftFrame; 325 mLeftFrame = leftFrame;
326 if ( KOPrefs::instance()->mVerticalScreen ) { 326 if ( KOPrefs::instance()->mVerticalScreen ) {
327 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 327 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
328 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 328 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
329 } else { 329 } else {
330 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 330 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
331 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 331 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
332 } 332 }
333 333
334 //qDebug("Calendarview Size %d %d ", width(), height()); 334 //qDebug("Calendarview Size %d %d ", width(), height());
335#endif 335#endif
336 336
337 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 337 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
338 SLOT( showDates( const KCal::DateList & ) ) ); 338 SLOT( showDates( const KCal::DateList & ) ) );
339 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 339 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
340 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 340 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
341 341
342 connect( mNavigatorBar, SIGNAL( goPrevYear() ), 342 connect( mNavigatorBar, SIGNAL( goPrevYear() ),
343 mNavigator, SLOT( selectPreviousYear() ) ); 343 mNavigator, SLOT( selectPreviousYear() ) );
344 connect( mNavigatorBar, SIGNAL( goNextYear() ), 344 connect( mNavigatorBar, SIGNAL( goNextYear() ),
345 mNavigator, SLOT( selectNextYear() ) ); 345 mNavigator, SLOT( selectNextYear() ) );
346 connect( mNavigatorBar, SIGNAL( goPrevMonth() ), 346 connect( mNavigatorBar, SIGNAL( goPrevMonth() ),
347 mNavigator, SLOT( selectPreviousMonth() ) ); 347 mNavigator, SLOT( selectPreviousMonth() ) );
348 connect( mNavigatorBar, SIGNAL( goNextMonth() ), 348 connect( mNavigatorBar, SIGNAL( goNextMonth() ),
349 mNavigator, SLOT( selectNextMonth() ) ); 349 mNavigator, SLOT( selectNextMonth() ) );
350 350
351 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 351 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
352 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); 352 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) );
353 353
354 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 354 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
355 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 355 mNavigator, SLOT( selectWeek( const QDate & ) ) );
356 356
357 connect( mDateNavigator, SIGNAL( goPrevYear() ), 357 connect( mDateNavigator, SIGNAL( goPrevYear() ),
358 mNavigator, SLOT( selectPreviousYear() ) ); 358 mNavigator, SLOT( selectPreviousYear() ) );
359 connect( mDateNavigator, SIGNAL( goNextYear() ), 359 connect( mDateNavigator, SIGNAL( goNextYear() ),
360 mNavigator, SLOT( selectNextYear() ) ); 360 mNavigator, SLOT( selectNextYear() ) );
361 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 361 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
362 mNavigator, SLOT( selectPreviousMonth() ) ); 362 mNavigator, SLOT( selectPreviousMonth() ) );
363 connect( mDateNavigator, SIGNAL( goNextMonth() ), 363 connect( mDateNavigator, SIGNAL( goNextMonth() ),
364 mNavigator, SLOT( selectNextMonth() ) ); 364 mNavigator, SLOT( selectNextMonth() ) );
365 365
366 connect( mDateNavigator, SIGNAL( goPrevious() ), 366 connect( mDateNavigator, SIGNAL( goPrevious() ),
367 mNavigator, SLOT( selectPrevious() ) ); 367 mNavigator, SLOT( selectPrevious() ) );
368 connect( mDateNavigator, SIGNAL( goNext() ), 368 connect( mDateNavigator, SIGNAL( goNext() ),
369 mNavigator, SLOT( selectNext() ) ); 369 mNavigator, SLOT( selectNext() ) );
370 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 370 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
371 mNavigator, SLOT( slotMonthSelect( int ) ) ); 371 mNavigator, SLOT( slotMonthSelect( int ) ) );
372 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), 372 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ),
373 mNavigator, SLOT( slotMonthSelect( int ) ) ); 373 mNavigator, SLOT( slotMonthSelect( int ) ) );
374 374
375 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 375 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
376 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 376 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
377 377
378 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), 378 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ),
379 SLOT( eventAdded( Event *) ) ); 379 SLOT( eventAdded( Event *) ) );
380 380
381 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 381 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
382 382
383 connect( this, SIGNAL( configChanged() ), 383 connect( this, SIGNAL( configChanged() ),
384 mDateNavigator, SLOT( updateConfig() ) ); 384 mDateNavigator, SLOT( updateConfig() ) );
385 385
386 connect( mTodoList, SIGNAL( newTodoSignal() ), 386 connect( mTodoList, SIGNAL( newTodoSignal() ),
387 SLOT( newTodo() ) ); 387 SLOT( newTodo() ) );
388 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 388 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
389 SLOT( newSubTodo( Todo * ) ) ); 389 SLOT( newSubTodo( Todo * ) ) );
390 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 390 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
391 SLOT( editTodo( Todo * ) ) ); 391 SLOT( editTodo( Todo * ) ) );
392 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 392 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
393 SLOT( showTodo( Todo *) ) ); 393 SLOT( showTodo( Todo *) ) );
394 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 394 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
395 SLOT( deleteTodo( Todo *) ) ); 395 SLOT( deleteTodo( Todo *) ) );
396 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 396 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
397 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 397 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
398 SLOT( purgeCompleted() ) ); 398 SLOT( purgeCompleted() ) );
399 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 399 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
400 SIGNAL( todoModified( Todo *, int ) ) ); 400 SIGNAL( todoModified( Todo *, int ) ) );
401 401
402 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 402 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
403 this, SLOT ( cloneIncidence( Incidence * ) ) ); 403 this, SLOT ( cloneIncidence( Incidence * ) ) );
404 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 404 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
405 this, SLOT (cancelIncidence( Incidence * ) ) ); 405 this, SLOT (cancelIncidence( Incidence * ) ) );
406 406
407 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 407 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
408 this, SLOT ( moveIncidence( Incidence * ) ) ); 408 this, SLOT ( moveIncidence( Incidence * ) ) );
409 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 409 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
410 this, SLOT ( beamIncidence( Incidence * ) ) ); 410 this, SLOT ( beamIncidence( Incidence * ) ) );
411 411
412 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 412 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
413 this, SLOT ( todo_unsub( Todo * ) ) ); 413 this, SLOT ( todo_unsub( Todo * ) ) );
414 414
415 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 415 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
416 SLOT( updateTodo( Todo *, int ) ) ); 416 SLOT( updateTodo( Todo *, int ) ) );
417 connect( this, SIGNAL( todoModified( Todo *, int )), this, 417 connect( this, SIGNAL( todoModified( Todo *, int )), this,
418 SLOT( changeTodoDisplay( Todo *, int ) ) ); 418 SLOT( changeTodoDisplay( Todo *, int ) ) );
419 419
420 420
421 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 421 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
422 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 422 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
423 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 423 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
424 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 424 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
425 425
426 426
427 427
428 428
429 429
430 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 430 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
431 SLOT(checkClipboard())); 431 SLOT(checkClipboard()));
432 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 432 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
433 SLOT( processTodoListSelection( Incidence * ) ) ); 433 SLOT( processTodoListSelection( Incidence * ) ) );
434 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 434 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
435 435
436 // kdDebug() << "CalendarView::CalendarView() done" << endl; 436 // kdDebug() << "CalendarView::CalendarView() done" << endl;
437 437
438 mDateFrame = new QVBox(0,0,WType_Popup); 438 mDateFrame = new QVBox(0,0,WType_Popup);
439 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 439 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
440 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 440 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
441 mDateFrame->setLineWidth(3); 441 mDateFrame->setLineWidth(3);
442 mDateFrame->hide(); 442 mDateFrame->hide();
443 mDateFrame->setCaption( i18n( "Pick a date to display")); 443 mDateFrame->setCaption( i18n( "Pick a date to display"));
444 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 444 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
445 445
446 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 446 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
447 447
448 mEventEditor = mDialogManager->getEventEditor(); 448 mEventEditor = mDialogManager->getEventEditor();
449 mTodoEditor = mDialogManager->getTodoEditor(); 449 mTodoEditor = mDialogManager->getTodoEditor();
450 450
451 mFlagEditDescription = false; 451 mFlagEditDescription = false;
452 452
453 mSuspendTimer = new QTimer( this ); 453 mSuspendTimer = new QTimer( this );
454 mAlarmTimer = new QTimer( this ); 454 mAlarmTimer = new QTimer( this );
455 mRecheckAlarmTimer = new QTimer( this ); 455 mRecheckAlarmTimer = new QTimer( this );
456 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 456 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
457 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 457 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
458 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 458 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
459 mAlarmDialog = new AlarmDialog( this ); 459 mAlarmDialog = new AlarmDialog( this );
460 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 460 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
461 mAlarmDialog->setServerNotification( false ); 461 mAlarmDialog->setServerNotification( false );
462 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 462 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
463} 463}
464 464
465 465
466CalendarView::~CalendarView() 466CalendarView::~CalendarView()
467{ 467{
468 // kdDebug() << "~CalendarView()" << endl; 468 // kdDebug() << "~CalendarView()" << endl;
469 //qDebug("CalendarView::~CalendarView() "); 469 //qDebug("CalendarView::~CalendarView() ");
470 delete mDialogManager; 470 delete mDialogManager;
471 delete mViewManager; 471 delete mViewManager;
472 delete mStorage; 472 delete mStorage;
473 delete mDateFrame ; 473 delete mDateFrame ;
474 delete beamDialog; 474 delete beamDialog;
475 //kdDebug() << "~CalendarView() done" << endl; 475 //kdDebug() << "~CalendarView() done" << endl;
476} 476}
477void CalendarView::timerAlarm() 477void CalendarView::timerAlarm()
478{ 478{
479 //qDebug("CalendarView::timerAlarm() "); 479 //qDebug("CalendarView::timerAlarm() ");
480 computeAlarm(mAlarmNotification ); 480 computeAlarm(mAlarmNotification );
481} 481}
482 482
483void CalendarView::suspendAlarm() 483void CalendarView::suspendAlarm()
484{ 484{
485 //qDebug(" CalendarView::suspendAlarm() "); 485 //qDebug(" CalendarView::suspendAlarm() ");
486 computeAlarm(mSuspendAlarmNotification ); 486 computeAlarm(mSuspendAlarmNotification );
487 487
488} 488}
489 489
490void CalendarView::startAlarm( QString mess , QString filename) 490void CalendarView::startAlarm( QString mess , QString filename)
491{ 491{
492 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 492 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
493 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); 493 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
494 494
495} 495}
496 496
497void CalendarView::checkNextTimerAlarm() 497void CalendarView::checkNextTimerAlarm()
498{ 498{
499 mCalendar->checkAlarmForIncidence( 0, true ); 499 mCalendar->checkAlarmForIncidence( 0, true );
500} 500}
501 501
502void CalendarView::computeAlarm( QString msg ) 502void CalendarView::computeAlarm( QString msg )
503{ 503{
504 504
505 QString mess = msg; 505 QString mess = msg;
506 QString mAlarmMessage = mess.mid( 9 ); 506 QString mAlarmMessage = mess.mid( 9 );
507 QString filename = MainWindow::resourcePath(); 507 QString filename = MainWindow::resourcePath();
508 filename += "koalarm.wav"; 508 filename += "koalarm.wav";
509 QString tempfilename; 509 QString tempfilename;
510 if ( mess.left( 13 ) == "suspend_alarm") { 510 if ( mess.left( 13 ) == "suspend_alarm") {
511 bool error = false; 511 bool error = false;
512 int len = mess.mid( 13 ).find("+++"); 512 int len = mess.mid( 13 ).find("+++");
513 if ( len < 2 ) 513 if ( len < 2 )
514 error = true; 514 error = true;
515 else { 515 else {
516 tempfilename = mess.mid( 13, len ); 516 tempfilename = mess.mid( 13, len );
517 if ( !QFile::exists( tempfilename ) ) 517 if ( !QFile::exists( tempfilename ) )
518 error = true; 518 error = true;
519 } 519 }
520 if ( ! error ) { 520 if ( ! error ) {
521 filename = tempfilename; 521 filename = tempfilename;
522 } 522 }
523 mAlarmMessage = mess.mid( 13+len+3 ); 523 mAlarmMessage = mess.mid( 13+len+3 );
524 //qDebug("suspend file %s ",tempfilename.latin1() ); 524 //qDebug("suspend file %s ",tempfilename.latin1() );
525 startAlarm( mAlarmMessage, filename); 525 startAlarm( mAlarmMessage, filename);
526 return; 526 return;
527 } 527 }
528 if ( mess.left( 11 ) == "timer_alarm") { 528 if ( mess.left( 11 ) == "timer_alarm") {
529 //mTimerTime = 0; 529 //mTimerTime = 0;
530 startAlarm( mess.mid( 11 ), filename ); 530 startAlarm( mess.mid( 11 ), filename );
531 return; 531 return;
532 } 532 }
533 if ( mess.left( 10 ) == "proc_alarm") { 533 if ( mess.left( 10 ) == "proc_alarm") {
534 bool error = false; 534 bool error = false;
535 int len = mess.mid( 10 ).find("+++"); 535 int len = mess.mid( 10 ).find("+++");
536 if ( len < 2 ) 536 if ( len < 2 )
537 error = true; 537 error = true;
538 else { 538 else {
539 tempfilename = mess.mid( 10, len ); 539 tempfilename = mess.mid( 10, len );
540 if ( !QFile::exists( tempfilename ) ) 540 if ( !QFile::exists( tempfilename ) )
541 error = true; 541 error = true;
542 } 542 }
543 if ( error ) { 543 if ( error ) {
544 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 544 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
545 mAlarmMessage += mess.mid( 10+len+3+9 ); 545 mAlarmMessage += mess.mid( 10+len+3+9 );
546 } else { 546 } else {
547 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 547 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
548 //qDebug("-----system command %s ",tempfilename.latin1() ); 548 //qDebug("-----system command %s ",tempfilename.latin1() );
549#ifndef _WIN32_ 549#ifndef _WIN32_
550 if ( vfork () == 0 ) { 550 if ( vfork () == 0 ) {
551 execl ( tempfilename.latin1(), 0 ); 551 execl ( tempfilename.latin1(), 0 );
552 return; 552 return;
553 } 553 }
554#else 554#else
555 QProcess* p = new QProcess(); 555 QProcess* p = new QProcess();
556 p->addArgument( tempfilename.latin1() ); 556 p->addArgument( tempfilename.latin1() );
557 p->start(); 557 p->start();
558 return; 558 return;
559#endif 559#endif
560 560
561 return; 561 return;
562 } 562 }
563 563
564 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 564 //qDebug("+++++++system command %s ",tempfilename.latin1() );
565 } 565 }
566 if ( mess.left( 11 ) == "audio_alarm") { 566 if ( mess.left( 11 ) == "audio_alarm") {
567 bool error = false; 567 bool error = false;
568 int len = mess.mid( 11 ).find("+++"); 568 int len = mess.mid( 11 ).find("+++");
569 if ( len < 2 ) 569 if ( len < 2 )
570 error = true; 570 error = true;
571 else { 571 else {
572 tempfilename = mess.mid( 11, len ); 572 tempfilename = mess.mid( 11, len );
573 if ( !QFile::exists( tempfilename ) ) 573 if ( !QFile::exists( tempfilename ) )
574 error = true; 574 error = true;
575 } 575 }
576 if ( ! error ) { 576 if ( ! error ) {
577 filename = tempfilename; 577 filename = tempfilename;
578 } 578 }
579 mAlarmMessage = mess.mid( 11+len+3+9 ); 579 mAlarmMessage = mess.mid( 11+len+3+9 );
580 //qDebug("audio file command %s ",tempfilename.latin1() ); 580 //qDebug("audio file command %s ",tempfilename.latin1() );
581 } 581 }
582 if ( mess.left( 9 ) == "cal_alarm") { 582 if ( mess.left( 9 ) == "cal_alarm") {
583 mAlarmMessage = mess.mid( 9 ) ; 583 mAlarmMessage = mess.mid( 9 ) ;
584 } 584 }
585 585
586 startAlarm( mAlarmMessage, filename ); 586 startAlarm( mAlarmMessage, filename );
587 587
588 588
589} 589}
590 590
591void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 591void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
592{ 592{
593 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 593 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
594 594
595 mSuspendAlarmNotification = noti; 595 mSuspendAlarmNotification = noti;
596 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 596 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
597 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 597 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
598 mSuspendTimer->start( ms , true ); 598 mSuspendTimer->start( ms , true );
599 599
600} 600}
601 601
602void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 602void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
603{ 603{
604 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 604 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
605 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 605 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
606#ifndef DESKTOP_VERSION 606#ifndef DESKTOP_VERSION
607 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); 607 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() );
608#endif 608#endif
609 return; 609 return;
610 } 610 }
611 int maxSec; 611 int maxSec;
612 //maxSec = 5; //testing only 612 //maxSec = 5; //testing only
613 maxSec = 86400+3600; // one day+1hour 613 maxSec = 86400+3600; // one day+1hour
614 mAlarmNotification = noti; 614 mAlarmNotification = noti;
615 int sec = QDateTime::currentDateTime().secsTo( qdt ); 615 int sec = QDateTime::currentDateTime().secsTo( qdt );
616 if ( sec > maxSec ) { 616 if ( sec > maxSec ) {
617 mRecheckAlarmTimer->start( maxSec * 1000 ); 617 mRecheckAlarmTimer->start( maxSec * 1000 );
618 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 618 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
619 return; 619 return;
620 } else { 620 } else {
621 mRecheckAlarmTimer->stop(); 621 mRecheckAlarmTimer->stop();
622 } 622 }
623 //qDebug("Alarm timer started with secs: %d ", sec); 623 //qDebug("Alarm timer started with secs: %d ", sec);
624 mAlarmTimer->start( sec *1000 , true ); 624 mAlarmTimer->start( sec *1000 , true );
625 625
626} 626}
627// called by mRecheckAlarmTimer to get next alarm 627// called by mRecheckAlarmTimer to get next alarm
628// we need this, because a QTimer has only a max range of 25 days 628// we need this, because a QTimer has only a max range of 25 days
629void CalendarView::recheckTimerAlarm() 629void CalendarView::recheckTimerAlarm()
630{ 630{
631 mAlarmTimer->stop(); 631 mAlarmTimer->stop();
632 mRecheckAlarmTimer->stop(); 632 mRecheckAlarmTimer->stop();
633 mCalendar->checkAlarmForIncidence( 0, true ); 633 mCalendar->checkAlarmForIncidence( 0, true );
634} 634}
635void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 635void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
636{ 636{
637 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 637 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
638 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 638 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
639#ifndef DESKTOP_VERSION 639#ifndef DESKTOP_VERSION
640 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 640 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
641#endif 641#endif
642 return; 642 return;
643 } 643 }
644 mAlarmTimer->stop(); 644 mAlarmTimer->stop();
645} 645}
646void CalendarView::selectWeekNum ( int num ) 646void CalendarView::selectWeekNum ( int num )
647{ 647{
648 dateNavigator()->selectWeek( num ); 648 dateNavigator()->selectWeek( num );
649 mViewManager->showWeekView(); 649 mViewManager->showWeekView();
650} 650}
651KOViewManager *CalendarView::viewManager() 651KOViewManager *CalendarView::viewManager()
652{ 652{
653 return mViewManager; 653 return mViewManager;
654} 654}
655 655
656KODialogManager *CalendarView::dialogManager() 656KODialogManager *CalendarView::dialogManager()
657{ 657{
658 return mDialogManager; 658 return mDialogManager;
659} 659}
660 660
661QDate CalendarView::startDate() 661QDate CalendarView::startDate()
662{ 662{
663 DateList dates = mNavigator->selectedDates(); 663 DateList dates = mNavigator->selectedDates();
664 664
665 return dates.first(); 665 return dates.first();
666} 666}
667 667
668QDate CalendarView::endDate() 668QDate CalendarView::endDate()
669{ 669{
670 DateList dates = mNavigator->selectedDates(); 670 DateList dates = mNavigator->selectedDates();
671 671
672 return dates.last(); 672 return dates.last();
673} 673}
674 674
675 675
676void CalendarView::createPrinter() 676void CalendarView::createPrinter()
677{ 677{
678#ifndef KORG_NOPRINTER 678#ifndef KORG_NOPRINTER
679 if (!mCalPrinter) { 679 if (!mCalPrinter) {
680 mCalPrinter = new CalPrinter(this, mCalendar); 680 mCalPrinter = new CalPrinter(this, mCalendar);
681 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 681 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
682 } 682 }
683#endif 683#endif
684} 684}
685 685
686void CalendarView::confSync() 686void CalendarView::confSync()
687{ 687{
688 static KSyncPrefsDialog* sp = 0; 688 static KSyncPrefsDialog* sp = 0;
689 if ( ! sp ) { 689 if ( ! sp ) {
690 sp = new KSyncPrefsDialog( this, "syncprefs", true ); 690 sp = new KSyncPrefsDialog( this, "syncprefs", true );
691 } 691 }
692 sp->setLocalMachineName ( KOPrefs::instance()->mLocalMachineName );
693 sp->usrReadConfig(); 692 sp->usrReadConfig();
694#ifndef DESKTOP_VERSION 693#ifndef DESKTOP_VERSION
695 sp->showMaximized(); 694 sp->showMaximized();
696#else 695#else
697 sp->show(); 696 sp->show();
698#endif 697#endif
699 sp->exec(); 698 sp->exec();
700 KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); 699 KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames();
701 KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); 700 KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName ();
702} 701}
703 702
704 703
705//KOPrefs::instance()->mWriteBackFile 704//KOPrefs::instance()->mWriteBackFile
706//KOPrefs::instance()->mWriteBackExistingOnly 705//KOPrefs::instance()->mWriteBackExistingOnly
707 706
708// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 707// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
709// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 708// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
710// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 709// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
711// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 710// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
712// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 711// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
713// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 712// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
714 713
715int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 714int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
716{ 715{
717 716
718 //void setZaurusId(int id); 717 //void setZaurusId(int id);
719 // int zaurusId() const; 718 // int zaurusId() const;
720 // void setZaurusUid(int id); 719 // void setZaurusUid(int id);
721 // int zaurusUid() const; 720 // int zaurusUid() const;
722 // void setZaurusStat(int id); 721 // void setZaurusStat(int id);
723 // int zaurusStat() const; 722 // int zaurusStat() const;
724 // 0 equal 723 // 0 equal
725 // 1 take local 724 // 1 take local
726 // 2 take remote 725 // 2 take remote
727 // 3 cancel 726 // 3 cancel
728 QDateTime lastSync = mLastCalendarSync; 727 QDateTime lastSync = mLastCalendarSync;
729 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 728 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
730 bool remCh, locCh; 729 bool remCh, locCh;
731 remCh = ( remote->zaurusUid() != local->zaurusUid() ); 730 remCh = ( remote->zaurusUid() != local->zaurusUid() );
732 locCh = ( local->lastModified() > mLastCalendarSync ); 731 locCh = ( local->lastModified() > mLastCalendarSync );
733 //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() ); 732 //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() );
734 if ( !remCh && ! locCh ) { 733 if ( !remCh && ! locCh ) {
735 //qDebug("both not changed "); 734 //qDebug("both not changed ");
736 lastSync = local->lastModified().addDays(1); 735 lastSync = local->lastModified().addDays(1);
737 } else { 736 } else {
738 if ( locCh ) { 737 if ( locCh ) {
739 //qDebug("loc changed %d %d", local->zaurusStat(), local->revision() ); 738 //qDebug("loc changed %d %d", local->zaurusStat(), local->revision() );
740 lastSync = local->lastModified().addDays( -1 ); 739 lastSync = local->lastModified().addDays( -1 );
741 if ( !remCh ) 740 if ( !remCh )
742 remote->setLastModified( lastSync.addDays( -1 ) ); 741 remote->setLastModified( lastSync.addDays( -1 ) );
743 } else { 742 } else {
744 //qDebug(" not loc changed "); 743 //qDebug(" not loc changed ");
745 lastSync = local->lastModified().addDays( 1 ); 744 lastSync = local->lastModified().addDays( 1 );
746 if ( remCh ) 745 if ( remCh )
747 remote->setLastModified( lastSync.addDays( 1 ) ); 746 remote->setLastModified( lastSync.addDays( 1 ) );
748 747
749 } 748 }
750 } 749 }
751 full = true; 750 full = true;
752 if ( mode < SYNC_PREF_ASK ) 751 if ( mode < SYNC_PREF_ASK )
753 mode = SYNC_PREF_ASK; 752 mode = SYNC_PREF_ASK;
754 } else { 753 } else {
755 if ( local->lastModified() == remote->lastModified() ) 754 if ( local->lastModified() == remote->lastModified() )
756 if ( local->revision() == remote->revision() ) 755 if ( local->revision() == remote->revision() )
757 return 0; 756 return 0;
758 757
759 } 758 }
760 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 759 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
761 760
762 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); 761 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision());
763 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); 762 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() );
764 //full = true; //debug only 763 //full = true; //debug only
765 if ( full ) { 764 if ( full ) {
766 bool equ = false; 765 bool equ = false;
767 if ( local->type() == "Event" ) { 766 if ( local->type() == "Event" ) {
768 equ = (*((Event*) local) == *((Event*) remote)); 767 equ = (*((Event*) local) == *((Event*) remote));
769 } 768 }
770 else if ( local->type() =="Todo" ) 769 else if ( local->type() =="Todo" )
771 equ = (*((Todo*) local) == (*(Todo*) remote)); 770 equ = (*((Todo*) local) == (*(Todo*) remote));
772 else if ( local->type() =="Journal" ) 771 else if ( local->type() =="Journal" )
773 equ = (*((Journal*) local) == *((Journal*) remote)); 772 equ = (*((Journal*) local) == *((Journal*) remote));
774 if ( equ ) { 773 if ( equ ) {
775 //qDebug("equal "); 774 //qDebug("equal ");
776 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 775 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
777 local->setZaurusUid( remote->zaurusUid() ); 776 local->setZaurusUid( remote->zaurusUid() );
778 } 777 }
779 if ( mode < SYNC_PREF_FORCE_LOCAL ) 778 if ( mode < SYNC_PREF_FORCE_LOCAL )
780 return 0; 779 return 0;
781 780
782 }//else //debug only 781 }//else //debug only
783 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 782 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
784 } 783 }
785 int result; 784 int result;
786 bool localIsNew; 785 bool localIsNew;
787 if ( full && mode < SYNC_PREF_NEWEST ) 786 if ( full && mode < SYNC_PREF_NEWEST )
788 mode = SYNC_PREF_ASK; 787 mode = SYNC_PREF_ASK;
789 788
790 switch( mode ) { 789 switch( mode ) {
791 case SYNC_PREF_LOCAL: 790 case SYNC_PREF_LOCAL:
792 if ( lastSync > remote->lastModified() ) 791 if ( lastSync > remote->lastModified() )
793 return 1; 792 return 1;
794 if ( lastSync > local->lastModified() ) 793 if ( lastSync > local->lastModified() )
795 return 2; 794 return 2;
796 return 1; 795 return 1;
797 break; 796 break;
798 case SYNC_PREF_REMOTE: 797 case SYNC_PREF_REMOTE:
799 if ( lastSync > remote->lastModified() ) 798 if ( lastSync > remote->lastModified() )
800 return 1; 799 return 1;
801 if ( lastSync > local->lastModified() ) 800 if ( lastSync > local->lastModified() )
802 return 2; 801 return 2;
803 return 2; 802 return 2;
804 break; 803 break;
805 case SYNC_PREF_NEWEST: 804 case SYNC_PREF_NEWEST:
806 if ( local->lastModified() > remote->lastModified() ) 805 if ( local->lastModified() > remote->lastModified() )
807 return 1; 806 return 1;
808 else 807 else
809 return 2; 808 return 2;
810 break; 809 break;
811 case SYNC_PREF_ASK: 810 case SYNC_PREF_ASK:
812 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); 811 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() );
813 if ( lastSync > remote->lastModified() ) 812 if ( lastSync > remote->lastModified() )
814 return 1; 813 return 1;
815 if ( lastSync > local->lastModified() ) 814 if ( lastSync > local->lastModified() )
816 return 2; 815 return 2;
817 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); 816 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() );
818 localIsNew = local->lastModified() > remote->lastModified(); 817 localIsNew = local->lastModified() > remote->lastModified();
819 if ( localIsNew ) 818 if ( localIsNew )
820 getEventViewerDialog()->setColorMode( 1 ); 819 getEventViewerDialog()->setColorMode( 1 );
821 else 820 else
822 getEventViewerDialog()->setColorMode( 2 ); 821 getEventViewerDialog()->setColorMode( 2 );
823 getEventViewerDialog()->setIncidence(local); 822 getEventViewerDialog()->setIncidence(local);
824 if ( localIsNew ) 823 if ( localIsNew )
825 getEventViewerDialog()->setColorMode( 2 ); 824 getEventViewerDialog()->setColorMode( 2 );
826 else 825 else
827 getEventViewerDialog()->setColorMode( 1 ); 826 getEventViewerDialog()->setColorMode( 1 );
828 getEventViewerDialog()->addIncidence(remote); 827 getEventViewerDialog()->addIncidence(remote);
829 getEventViewerDialog()->setColorMode( 0 ); 828 getEventViewerDialog()->setColorMode( 0 );
830 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 829 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
831 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 830 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
832 getEventViewerDialog()->showMe(); 831 getEventViewerDialog()->showMe();
833 result = getEventViewerDialog()->executeS( localIsNew ); 832 result = getEventViewerDialog()->executeS( localIsNew );
834 return result; 833 return result;
835 834
836 break; 835 break;
837 case SYNC_PREF_FORCE_LOCAL: 836 case SYNC_PREF_FORCE_LOCAL:
838 return 1; 837 return 1;
839 break; 838 break;
840 case SYNC_PREF_FORCE_REMOTE: 839 case SYNC_PREF_FORCE_REMOTE:
841 return 2; 840 return 2;
842 break; 841 break;
843 842
844 default: 843 default:
845 // SYNC_PREF_TAKE_BOTH not implemented 844 // SYNC_PREF_TAKE_BOTH not implemented
846 break; 845 break;
847 } 846 }
848 return 0; 847 return 0;
849} 848}
850Event* CalendarView::getLastSyncEvent() 849Event* CalendarView::getLastSyncEvent()
851{ 850{
852 Event* lse; 851 Event* lse;
853 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 852 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
854 lse = mCalendar->event( "last-syncEvent-device-"+mCurrentSyncDevice ); 853 lse = mCalendar->event( "last-syncEvent-device-"+mCurrentSyncDevice );
855 if (!lse) { 854 if (!lse) {
856 lse = new Event(); 855 lse = new Event();
857 lse->setUid( "last-syncEvent-device-"+mCurrentSyncDevice ); 856 lse->setUid( "last-syncEvent-device-"+mCurrentSyncDevice );
858 lse->setSummary(mCurrentSyncDevice + i18n(" - sync event")); 857 lse->setSummary(mCurrentSyncDevice + i18n(" - sync event"));
859 lse->setDtStart( mLastCalendarSync ); 858 lse->setDtStart( mLastCalendarSync );
860 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 859 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
861 lse->setCategories( i18n("SyncEvent") ); 860 lse->setCategories( i18n("SyncEvent") );
862 lse->setReadOnly( true ); 861 lse->setReadOnly( true );
863 mCalendar->addEvent( lse ); 862 mCalendar->addEvent( lse );
864 } 863 }
865 864
866 return lse; 865 return lse;
867 866
868} 867}
869void CalendarView::checkSharpEvent( Event* lastSync, Incidence* toDelete ) 868void CalendarView::checkSharpEvent( Event* lastSync, Incidence* toDelete )
870{ 869{
871 if ( ! lastSync ) 870 if ( ! lastSync )
872 return; 871 return;
873 if ( toDelete->zaurusId() < 0 ) 872 if ( toDelete->zaurusId() < 0 )
874 return; 873 return;
875 if ( toDelete->type() == "Journal" ) 874 if ( toDelete->type() == "Journal" )
876 return; 875 return;
877 QString des = lastSync->description(); 876 QString des = lastSync->description();
878 QString pref = "e"; 877 QString pref = "e";
879 if ( toDelete->type() == "Todo" ) 878 if ( toDelete->type() == "Todo" )
880 pref = "t"; 879 pref = "t";
881 des += pref+ QString::number ( toDelete->zaurusId() ) + ","; 880 des += pref+ QString::number ( toDelete->zaurusId() ) + ",";
882 lastSync->setReadOnly( false ); 881 lastSync->setReadOnly( false );
883 lastSync->setDescription( des ); 882 lastSync->setDescription( des );
884 lastSync->setReadOnly( true ); 883 lastSync->setReadOnly( true );
885 884
886} 885}
887bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 886bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
888{ 887{
889 bool syncOK = true; 888 bool syncOK = true;
890 int addedEvent = 0; 889 int addedEvent = 0;
891 int addedEventR = 0; 890 int addedEventR = 0;
892 int deletedEventR = 0; 891 int deletedEventR = 0;
893 int deletedEventL = 0; 892 int deletedEventL = 0;
894 int changedLocal = 0; 893 int changedLocal = 0;
895 int changedRemote = 0; 894 int changedRemote = 0;
896 //QPtrList<Event> el = local->rawEvents(); 895 //QPtrList<Event> el = local->rawEvents();
897 Event* eventR; 896 Event* eventR;
898 QString uid; 897 QString uid;
899 int take; 898 int take;
900 Event* eventL; 899 Event* eventL;
901 Event* eventRSync; 900 Event* eventRSync;
902 Event* eventLSync; 901 Event* eventLSync;
903 Event* eventRSyncSharp = remote->event( "last-syncEvent-device-Sharp-DTM"); 902 Event* eventRSyncSharp = remote->event( "last-syncEvent-device-Sharp-DTM");
904 Event* eventLSyncSharp = local->event( "last-syncEvent-device-Sharp-DTM"); 903 Event* eventLSyncSharp = local->event( "last-syncEvent-device-Sharp-DTM");
905 bool fullDateRange = false; 904 bool fullDateRange = false;
906 mLastCalendarSync = QDateTime::currentDateTime(); 905 mLastCalendarSync = QDateTime::currentDateTime();
907 QDateTime modifiedCalendar = mLastCalendarSync;; 906 QDateTime modifiedCalendar = mLastCalendarSync;;
908 eventR = remote->event("last-syncEvent-device-"+mCurrentSyncName ); 907 eventR = remote->event("last-syncEvent-device-"+mCurrentSyncName );
909 if ( eventR ) { 908 if ( eventR ) {
910 eventRSync = (Event*) eventR->clone(); 909 eventRSync = (Event*) eventR->clone();
911 remote->deleteEvent(eventR ); 910 remote->deleteEvent(eventR );
912 911
913 } else { 912 } else {
914 fullDateRange = true; 913 fullDateRange = true;
915 eventRSync = new Event(); 914 eventRSync = new Event();
916 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 915 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
917 eventRSync->setUid("last-syncEvent-device-"+mCurrentSyncName ); 916 eventRSync->setUid("last-syncEvent-device-"+mCurrentSyncName );
918 eventRSync->setDtStart( mLastCalendarSync ); 917 eventRSync->setDtStart( mLastCalendarSync );
919 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 918 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
920 eventRSync->setCategories( i18n("SyncEvent") ); 919 eventRSync->setCategories( i18n("SyncEvent") );
921 } 920 }
922 eventLSync = getLastSyncEvent(); 921 eventLSync = getLastSyncEvent();
923 if ( eventLSync->dtStart() == mLastCalendarSync ) 922 if ( eventLSync->dtStart() == mLastCalendarSync )
924 fullDateRange = true; 923 fullDateRange = true;
925 924
926 if ( ! fullDateRange ) { 925 if ( ! fullDateRange ) {
927 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 926 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
928 927
929 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 928 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
930 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 929 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
931 fullDateRange = true; 930 fullDateRange = true;
932 } 931 }
933 } 932 }
934 if ( fullDateRange ) 933 if ( fullDateRange )
935 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 934 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
936 else 935 else
937 mLastCalendarSync = eventLSync->dtStart(); 936 mLastCalendarSync = eventLSync->dtStart();
938 // for resyncing if own file has changed 937 // for resyncing if own file has changed
939 if ( mCurrentSyncDevice == "deleteaftersync" ) { 938 if ( mCurrentSyncDevice == "deleteaftersync" ) {
940 mLastCalendarSync = loadedFileVersion; 939 mLastCalendarSync = loadedFileVersion;
941 qDebug("setting mLastCalendarSync "); 940 qDebug("setting mLastCalendarSync ");
942 } 941 }
943 //qDebug("*************************** "); 942 //qDebug("*************************** ");
944 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); 943 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() );
945 QPtrList<Incidence> er = remote->rawIncidences(); 944 QPtrList<Incidence> er = remote->rawIncidences();
946 Incidence* inR = er.first(); 945 Incidence* inR = er.first();
947 Incidence* inL; 946 Incidence* inL;
948 QProgressBar bar( er.count(),0 ); 947 QProgressBar bar( er.count(),0 );
949 bar.setCaption (i18n("Syncing - close to abort!") ); 948 bar.setCaption (i18n("Syncing - close to abort!") );
950 949
951 int w = 300; 950 int w = 300;
952 if ( QApplication::desktop()->width() < 320 ) 951 if ( QApplication::desktop()->width() < 320 )
953 w = 220; 952 w = 220;
954 int h = bar.sizeHint().height() ; 953 int h = bar.sizeHint().height() ;
955 int dw = QApplication::desktop()->width(); 954 int dw = QApplication::desktop()->width();
956 int dh = QApplication::desktop()->height(); 955 int dh = QApplication::desktop()->height();
957 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 956 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
958 bar.show(); 957 bar.show();
959 int modulo = (er.count()/10)+1; 958 int modulo = (er.count()/10)+1;
960 int incCounter = 0; 959 int incCounter = 0;
961 while ( inR ) { 960 while ( inR ) {
962 if ( ! bar.isVisible() ) 961 if ( ! bar.isVisible() )
963 return false; 962 return false;
964 if ( incCounter % modulo == 0 ) 963 if ( incCounter % modulo == 0 )
965 bar.setProgress( incCounter ); 964 bar.setProgress( incCounter );
966 ++incCounter; 965 ++incCounter;
967 uid = inR->uid(); 966 uid = inR->uid();
968 bool skipIncidence = false; 967 bool skipIncidence = false;
969 if ( uid.left(21) == QString("last-syncEvent-device") ) 968 if ( uid.left(21) == QString("last-syncEvent-device") )
970 skipIncidence = true; 969 skipIncidence = true;
971 970
972 qApp->processEvents(); 971 qApp->processEvents();
973 if ( !skipIncidence ) { 972 if ( !skipIncidence ) {
974 inL = local->incidence( uid ); 973 inL = local->incidence( uid );
975 if ( inL ) { // maybe conflict - same uid in both calendars 974 if ( inL ) { // maybe conflict - same uid in both calendars
976 int maxrev = inL->revision(); 975 int maxrev = inL->revision();
977 if ( maxrev < inR->revision() ) 976 if ( maxrev < inR->revision() )
978 maxrev = inR->revision(); 977 maxrev = inR->revision();
979 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 978 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
980 //qDebug("take %d %s ", take, inL->summary().latin1()); 979 //qDebug("take %d %s ", take, inL->summary().latin1());
981 if ( take == 3 ) 980 if ( take == 3 )
982 return false; 981 return false;
983 if ( take == 1 ) {// take local 982 if ( take == 1 ) {// take local
984 inL->setZaurusUid( inR->zaurusUid() ); 983 inL->setZaurusUid( inR->zaurusUid() );
985 remote->deleteIncidence( inR ); 984 remote->deleteIncidence( inR );
986 if ( inL->revision() < maxrev ) 985 if ( inL->revision() < maxrev )
987 inL->setRevision( maxrev ); 986 inL->setRevision( maxrev );
988 remote->addIncidence( inL->clone() ); 987 remote->addIncidence( inL->clone() );
989 ++changedRemote; 988 ++changedRemote;
990 } else { 989 } else {
991 if ( inR->revision() < maxrev ) 990 if ( inR->revision() < maxrev )
992 inR->setRevision( maxrev ); 991 inR->setRevision( maxrev );
993 local->deleteIncidence( inL ); 992 local->deleteIncidence( inL );
994 local->addIncidence( inR->clone() ); 993 local->addIncidence( inR->clone() );
995 ++changedLocal; 994 ++changedLocal;
996 } 995 }
997 } 996 }
998 } else { // no conflict 997 } else { // no conflict
999 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 998 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1000 QString des = eventLSync->description(); 999 QString des = eventLSync->description();
1001 QString pref = "e"; 1000 QString pref = "e";
1002 if ( inR->type() == "Todo" ) 1001 if ( inR->type() == "Todo" )
1003 pref = "t"; 1002 pref = "t";
1004 if ( des.find(pref+QString::number( inR->zaurusId() ) +"," ) >= 0 && mode != 5) { // delete it 1003 if ( des.find(pref+QString::number( inR->zaurusId() ) +"," ) >= 0 && mode != 5) { // delete it
1005 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1004 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1006 //remote->deleteIncidence( inR ); 1005 //remote->deleteIncidence( inR );
1007 ++deletedEventR; 1006 ++deletedEventR;
1008 } else { 1007 } else {
1009 inR->setLastModified( modifiedCalendar ); 1008 inR->setLastModified( modifiedCalendar );
1010 local->addIncidence( inR->clone() ); 1009 local->addIncidence( inR->clone() );
1011 ++addedEvent; 1010 ++addedEvent;
1012 } 1011 }
1013 } else { 1012 } else {
1014 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1013 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1015 inR->setLastModified( modifiedCalendar ); 1014 inR->setLastModified( modifiedCalendar );
1016 local->addIncidence( inR->clone() ); 1015 local->addIncidence( inR->clone() );
1017 ++addedEvent; 1016 ++addedEvent;
1018 } else { 1017 } else {
1019 checkSharpEvent(eventRSyncSharp, inR); 1018 checkSharpEvent(eventRSyncSharp, inR);
1020 remote->deleteIncidence( inR ); 1019 remote->deleteIncidence( inR );
1021 ++deletedEventR; 1020 ++deletedEventR;
1022 } 1021 }
1023 } 1022 }
1024 } 1023 }
1025 } 1024 }
1026 inR = er.next(); 1025 inR = er.next();
1027 } 1026 }
1028 QPtrList<Incidence> el = local->rawIncidences(); 1027 QPtrList<Incidence> el = local->rawIncidences();
1029 inL = el.first(); 1028 inL = el.first();
1030 modulo = (el.count()/10)+1; 1029 modulo = (el.count()/10)+1;
1031 bar.setCaption (i18n("Add / remove events") ); 1030 bar.setCaption (i18n("Add / remove events") );
1032 bar.setTotalSteps ( el.count() ) ; 1031 bar.setTotalSteps ( el.count() ) ;
1033 bar.show(); 1032 bar.show();
1034 incCounter = 0; 1033 incCounter = 0;
1035 1034
1036 while ( inL ) { 1035 while ( inL ) {
1037 1036
1038 qApp->processEvents(); 1037 qApp->processEvents();
1039 if ( ! bar.isVisible() ) 1038 if ( ! bar.isVisible() )
1040 return false; 1039 return false;
1041 if ( incCounter % modulo == 0 ) 1040 if ( incCounter % modulo == 0 )
1042 bar.setProgress( incCounter ); 1041 bar.setProgress( incCounter );
1043 ++incCounter; 1042 ++incCounter;
1044 uid = inL->uid(); 1043 uid = inL->uid();
1045 bool skipIncidence = false; 1044 bool skipIncidence = false;
1046 if ( uid.left(21) == QString("last-syncEvent-device") ) 1045 if ( uid.left(21) == QString("last-syncEvent-device") )
1047 skipIncidence = true; 1046 skipIncidence = true;
1048 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) 1047 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
1049 skipIncidence = true; 1048 skipIncidence = true;
1050 if ( !skipIncidence ) { 1049 if ( !skipIncidence ) {
1051 inR = remote->incidence( uid ); 1050 inR = remote->incidence( uid );
1052 if ( ! inR ) { 1051 if ( ! inR ) {
1053 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1052 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1054 if ( inL->zaurusId() >= 0 && mode != 4 ) { 1053 if ( inL->zaurusId() >= 0 && mode != 4 ) {
1055 local->deleteIncidence( inL ); 1054 local->deleteIncidence( inL );
1056 ++deletedEventL; 1055 ++deletedEventL;
1057 } else { 1056 } else {
1058 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { 1057 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
1059 inL->setZaurusId( -1 ); 1058 inL->setZaurusId( -1 );
1060 ++addedEventR; 1059 ++addedEventR;
1061 inL->setLastModified( modifiedCalendar ); 1060 inL->setLastModified( modifiedCalendar );
1062 remote->addIncidence( inL->clone() ); 1061 remote->addIncidence( inL->clone() );
1063 } 1062 }
1064 } 1063 }
1065 } else { 1064 } else {
1066 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1065 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1067 checkSharpEvent(eventLSyncSharp, inL); 1066 checkSharpEvent(eventLSyncSharp, inL);
1068 local->deleteIncidence( inL ); 1067 local->deleteIncidence( inL );
1069 ++deletedEventL; 1068 ++deletedEventL;
1070 } else { 1069 } else {
1071 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { 1070 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
1072 ++addedEventR; 1071 ++addedEventR;
1073 inL->setLastModified( modifiedCalendar ); 1072 inL->setLastModified( modifiedCalendar );
1074 remote->addIncidence( inL->clone() ); 1073 remote->addIncidence( inL->clone() );
1075 } 1074 }
1076 } 1075 }
1077 } 1076 }
1078 } 1077 }
1079 } 1078 }
1080 inL = el.next(); 1079 inL = el.next();
1081 } 1080 }
1082 1081
1083 bar.hide(); 1082 bar.hide();
1084 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1083 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1085 eventLSync->setReadOnly( false ); 1084 eventLSync->setReadOnly( false );
1086 eventLSync->setDtStart( mLastCalendarSync ); 1085 eventLSync->setDtStart( mLastCalendarSync );
1087 eventRSync->setDtStart( mLastCalendarSync ); 1086 eventRSync->setDtStart( mLastCalendarSync );
1088 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1087 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1089 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1088 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1090 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1089 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1091 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1090 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1092 eventLSync->setReadOnly( true ); 1091 eventLSync->setReadOnly( true );
1093 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 1092 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
1094 remote->addEvent( eventRSync ); 1093 remote->addEvent( eventRSync );
1095 QString mes; 1094 QString mes;
1096 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); 1095 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR );
1097 if ( KOPrefs::instance()->mShowSyncSummary ) { 1096 if ( KOPrefs::instance()->mShowSyncSummary ) {
1098 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); 1097 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") );
1099 } 1098 }
1100 qDebug( mes ); 1099 qDebug( mes );
1101 mCalendar->checkAlarmForIncidence( 0, true ); 1100 mCalendar->checkAlarmForIncidence( 0, true );
1102 return syncOK; 1101 return syncOK;
1103} 1102}
1104 1103
1105void CalendarView::setSyncDevice( QString s ) 1104void CalendarView::setSyncDevice( QString s )
1106{ 1105{
1107 mCurrentSyncDevice= s; 1106 mCurrentSyncDevice= s;
1108} 1107}
1109void CalendarView::setSyncName( QString s ) 1108void CalendarView::setSyncName( QString s )
1110{ 1109{
1111 mCurrentSyncName= s; 1110 mCurrentSyncName= s;
1112} 1111}
1113bool CalendarView::syncCalendar(QString filename, int mode) 1112bool CalendarView::syncCalendar(QString filename, int mode)
1114{ 1113{
1115 mGlobalSyncMode = SYNC_MODE_NORMAL; 1114 mGlobalSyncMode = SYNC_MODE_NORMAL;
1116 CalendarLocal* calendar = new CalendarLocal(); 1115 CalendarLocal* calendar = new CalendarLocal();
1117 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1116 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1118 FileStorage* storage = new FileStorage( calendar ); 1117 FileStorage* storage = new FileStorage( calendar );
1119 bool syncOK = false; 1118 bool syncOK = false;
1120 storage->setFileName( filename ); 1119 storage->setFileName( filename );
1121 // qDebug("loading ... "); 1120 // qDebug("loading ... ");
1122 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { 1121 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) {
1123 getEventViewerDialog()->setSyncMode( true ); 1122 getEventViewerDialog()->setSyncMode( true );
1124 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1123 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1125 getEventViewerDialog()->setSyncMode( false ); 1124 getEventViewerDialog()->setSyncMode( false );
1126 if ( syncOK ) { 1125 if ( syncOK ) {
1127 if ( KOPrefs::instance()->mWriteBackFile ) 1126 if ( KOPrefs::instance()->mWriteBackFile )
1128 { 1127 {
1129 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 1128 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
1130 storage->save(); 1129 storage->save();
1131 } 1130 }
1132 } 1131 }
1133 setModified( true ); 1132 setModified( true );
1134 } 1133 }
1135 delete storage; 1134 delete storage;
1136 delete calendar; 1135 delete calendar;
1137 if ( syncOK ) 1136 if ( syncOK )
1138 updateView(); 1137 updateView();
1139 return syncOK; 1138 return syncOK;
1140} 1139}
1141void CalendarView::syncSharp() 1140void CalendarView::syncSharp()
1142{ 1141{
1143#ifndef DESKTOP_VERSION 1142#ifndef DESKTOP_VERSION
1144 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1143 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1145 //mCurrentSyncDevice = "sharp-DTM"; 1144 //mCurrentSyncDevice = "sharp-DTM";
1146 if ( KOPrefs::instance()->mAskForPreferences ) 1145 if ( KOPrefs::instance()->mAskForPreferences )
1147 edit_sync_options(); 1146 edit_sync_options();
1148 qApp->processEvents(); 1147 qApp->processEvents();
1149 CalendarLocal* calendar = new CalendarLocal(); 1148 CalendarLocal* calendar = new CalendarLocal();
1150 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1149 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1151 bool syncOK = false; 1150 bool syncOK = false;
1152 SharpFormat sharpFormat; 1151 SharpFormat sharpFormat;
1153 if ( sharpFormat.load( calendar, mCalendar ) ) { 1152 if ( sharpFormat.load( calendar, mCalendar ) ) {
1154 getEventViewerDialog()->setSyncMode( true ); 1153 getEventViewerDialog()->setSyncMode( true );
1155 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); 1154 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
1156 getEventViewerDialog()->setSyncMode( false ); 1155 getEventViewerDialog()->setSyncMode( false );
1157 qApp->processEvents(); 1156 qApp->processEvents();
1158 if ( syncOK ) { 1157 if ( syncOK ) {
1159 if ( KOPrefs::instance()->mWriteBackFile ) 1158 if ( KOPrefs::instance()->mWriteBackFile )
1160 { 1159 {
1161 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1160 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1162 Incidence* inc = iL.first(); 1161 Incidence* inc = iL.first();
1163 /* obsolete 1162 /* obsolete
1164 while ( inc ) { 1163 while ( inc ) {
1165 inc->setZaurusStat( inc->revision () ); 1164 inc->setZaurusStat( inc->revision () );
1166 inc = iL.next(); 1165 inc = iL.next();
1167 } 1166 }
1168 */ 1167 */
1169 // pending: clean last sync event description 1168 // pending: clean last sync event description
1170 sharpFormat.save(calendar); 1169 sharpFormat.save(calendar);
1171 iL = calendar->rawIncidences(); 1170 iL = calendar->rawIncidences();
1172 inc = iL.first(); 1171 inc = iL.first();
1173 Incidence* loc; 1172 Incidence* loc;
1174 while ( inc ) { 1173 while ( inc ) {
1175 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1174 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1176 loc = mCalendar->incidence(inc->uid() ); 1175 loc = mCalendar->incidence(inc->uid() );
1177 if ( loc ) { 1176 if ( loc ) {
1178 loc->setZaurusId( inc->zaurusId() ); 1177 loc->setZaurusId( inc->zaurusId() );
1179 loc->setZaurusUid( inc->zaurusUid() ); 1178 loc->setZaurusUid( inc->zaurusUid() );
1180 } 1179 }
1181 } 1180 }
1182 inc = iL.next(); 1181 inc = iL.next();
1183 } 1182 }
1184 Incidence* lse = getLastSyncEvent(); 1183 Incidence* lse = getLastSyncEvent();
1185 if ( lse ) { 1184 if ( lse ) {
1186 lse->setReadOnly( false ); 1185 lse->setReadOnly( false );
1187 lse->setDescription( "" ); 1186 lse->setDescription( "" );
1188 lse->setReadOnly( true ); 1187 lse->setReadOnly( true );
1189 } 1188 }
1190 } 1189 }
1191 } 1190 }
1192 setModified( true ); 1191 setModified( true );
1193 } else { 1192 } else {
1194 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1193 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1195 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1194 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1196 question, i18n("Ok")) ; 1195 question, i18n("Ok")) ;
1197 1196
1198 } 1197 }
1199 delete calendar; 1198 delete calendar;
1200 updateView(); 1199 updateView();
1201 return ;//syncOK; 1200 return ;//syncOK;
1202#endif 1201#endif
1203} 1202}
1204 1203
1205 1204
1206#include <kabc/stdaddressbook.h> 1205#include <kabc/stdaddressbook.h>
1207bool CalendarView::importBday() 1206bool CalendarView::importBday()
1208{ 1207{
1209 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1208 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1210 KABC::AddressBook::Iterator it; 1209 KABC::AddressBook::Iterator it;
1211 int count = 0; 1210 int count = 0;
1212 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1211 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1213 ++count; 1212 ++count;
1214 } 1213 }
1215 QProgressBar bar(count,0 ); 1214 QProgressBar bar(count,0 );
1216 int w = 300; 1215 int w = 300;
1217 if ( QApplication::desktop()->width() < 320 ) 1216 if ( QApplication::desktop()->width() < 320 )
1218 w = 220; 1217 w = 220;
1219 int h = bar.sizeHint().height() ; 1218 int h = bar.sizeHint().height() ;
1220 int dw = QApplication::desktop()->width(); 1219 int dw = QApplication::desktop()->width();
1221 int dh = QApplication::desktop()->height(); 1220 int dh = QApplication::desktop()->height();
1222 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1221 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1223 bar.show(); 1222 bar.show();
1224 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1223 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1225 qApp->processEvents(); 1224 qApp->processEvents();
1226 count = 0; 1225 count = 0;
1227 int addCount = 0; 1226 int addCount = 0;
1228 KCal::Attendee* a = 0; 1227 KCal::Attendee* a = 0;
1229 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1228 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1230 if ( ! bar.isVisible() ) 1229 if ( ! bar.isVisible() )
1231 return false; 1230 return false;
1232 bar.setProgress( count++ ); 1231 bar.setProgress( count++ );
1233 qApp->processEvents(); 1232 qApp->processEvents();
1234 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1233 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1235 if ( (*it).birthday().date().isValid() ){ 1234 if ( (*it).birthday().date().isValid() ){
1236 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1235 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1237 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1236 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1238 ++addCount; 1237 ++addCount;
1239 } 1238 }
1240 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1239 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1241 if ( anni.isValid() ){ 1240 if ( anni.isValid() ){
1242 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1241 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1243 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1242 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1244 ++addCount; 1243 ++addCount;
1245 } 1244 }
1246 } 1245 }
1247 updateView(); 1246 updateView();
1248 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1247 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1249 return true; 1248 return true;
1250} 1249}
1251 1250
1252bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1251bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1253{ 1252{
1254 //qDebug("addAnni "); 1253 //qDebug("addAnni ");
1255 Event * ev = new Event(); 1254 Event * ev = new Event();
1256 if ( a ) { 1255 if ( a ) {
1257 ev->addAttendee( a ); 1256 ev->addAttendee( a );
1258 } 1257 }
1259 QString kind; 1258 QString kind;
1260 if ( birthday ) 1259 if ( birthday )
1261 kind = i18n( "Birthday" ); 1260 kind = i18n( "Birthday" );
1262 else 1261 else
1263 kind = i18n( "Anniversary" ); 1262 kind = i18n( "Anniversary" );
1264 ev->setSummary( name + " - " + kind ); 1263 ev->setSummary( name + " - " + kind );
1265 ev->setOrganizer( "nobody@nowhere" ); 1264 ev->setOrganizer( "nobody@nowhere" );
1266 ev->setCategories( kind ); 1265 ev->setCategories( kind );
1267 ev->setDtStart( QDateTime(date) ); 1266 ev->setDtStart( QDateTime(date) );
1268 ev->setDtEnd( QDateTime(date) ); 1267 ev->setDtEnd( QDateTime(date) );
1269 ev->setFloats( true ); 1268 ev->setFloats( true );
1270 Recurrence * rec = ev->recurrence(); 1269 Recurrence * rec = ev->recurrence();
1271 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1270 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1272 rec->addYearlyNum( date.month() ); 1271 rec->addYearlyNum( date.month() );
1273 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1272 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1274 delete ev; 1273 delete ev;
1275 return false; 1274 return false;
1276 } 1275 }
1277 return true; 1276 return true;
1278 1277
1279} 1278}
1280bool CalendarView::importQtopia( const QString &categories, 1279bool CalendarView::importQtopia( const QString &categories,
1281 const QString &datebook, 1280 const QString &datebook,
1282 const QString &todolist ) 1281 const QString &todolist )
1283{ 1282{
1284 1283
1285 QtopiaFormat qtopiaFormat; 1284 QtopiaFormat qtopiaFormat;
1286 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1285 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1287 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1286 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1288 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1287 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1289 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1288 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1290 1289
1291 updateView(); 1290 updateView();
1292 return true; 1291 return true;
1293 1292
1294#if 0 1293#if 0
1295 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1294 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1296 mCurrentSyncDevice = "qtopia-XML"; 1295 mCurrentSyncDevice = "qtopia-XML";
1297 if ( KOPrefs::instance()->mAskForPreferences ) 1296 if ( KOPrefs::instance()->mAskForPreferences )
1298 edit_sync_options(); 1297 edit_sync_options();
1299 qApp->processEvents(); 1298 qApp->processEvents();
1300 CalendarLocal* calendar = new CalendarLocal(); 1299 CalendarLocal* calendar = new CalendarLocal();
1301 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1300 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1302 bool syncOK = false; 1301 bool syncOK = false;
1303 QtopiaFormat qtopiaFormat; 1302 QtopiaFormat qtopiaFormat;
1304 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1303 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1305 bool loadOk = true; 1304 bool loadOk = true;
1306 if ( !categories.isEmpty() ) 1305 if ( !categories.isEmpty() )
1307 loadOk = qtopiaFormat.load( calendar, categories ); 1306 loadOk = qtopiaFormat.load( calendar, categories );
1308 if ( loadOk && !datebook.isEmpty() ) 1307 if ( loadOk && !datebook.isEmpty() )
1309 loadOk = qtopiaFormat.load( calendar, datebook ); 1308 loadOk = qtopiaFormat.load( calendar, datebook );
1310 if ( loadOk && !todolist.isEmpty() ) 1309 if ( loadOk && !todolist.isEmpty() )
1311 loadOk = qtopiaFormat.load( calendar, todolist ); 1310 loadOk = qtopiaFormat.load( calendar, todolist );
1312 1311
1313 if ( loadOk ) { 1312 if ( loadOk ) {
1314 getEventViewerDialog()->setSyncMode( true ); 1313 getEventViewerDialog()->setSyncMode( true );
1315 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); 1314 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
1316 getEventViewerDialog()->setSyncMode( false ); 1315 getEventViewerDialog()->setSyncMode( false );
1317 qApp->processEvents(); 1316 qApp->processEvents();
1318 if ( syncOK ) { 1317 if ( syncOK ) {
1319 if ( KOPrefs::instance()->mWriteBackFile ) 1318 if ( KOPrefs::instance()->mWriteBackFile )
1320 { 1319 {
1321 // write back XML file 1320 // write back XML file
1322 1321
1323 } 1322 }
1324 setModified( true ); 1323 setModified( true );
1325 } 1324 }
1326 } else { 1325 } else {
1327 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1326 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1328 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1327 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1329 question, i18n("Ok")) ; 1328 question, i18n("Ok")) ;
1330 } 1329 }
1331 delete calendar; 1330 delete calendar;
1332 updateView(); 1331 updateView();
1333 return syncOK; 1332 return syncOK;
1334 1333
1335 1334
1336#endif 1335#endif
1337 1336
1338} 1337}
1339 1338
1340void CalendarView::setSyncEventsReadOnly() 1339void CalendarView::setSyncEventsReadOnly()
1341{ 1340{
1342 Event * ev; 1341 Event * ev;
1343 QPtrList<Event> eL = mCalendar->rawEvents(); 1342 QPtrList<Event> eL = mCalendar->rawEvents();
1344 ev = eL.first(); 1343 ev = eL.first();
1345 while ( ev ) { 1344 while ( ev ) {
1346 if ( ev->uid().left(21) == QString("last-syncEvent-device") ) 1345 if ( ev->uid().left(21) == QString("last-syncEvent-device") )
1347 ev->setReadOnly( true ); 1346 ev->setReadOnly( true );
1348 ev = eL.next(); 1347 ev = eL.next();
1349 } 1348 }
1350} 1349}
1351bool CalendarView::openCalendar(QString filename, bool merge) 1350bool CalendarView::openCalendar(QString filename, bool merge)
1352{ 1351{
1353 1352
1354 if (filename.isEmpty()) { 1353 if (filename.isEmpty()) {
1355 return false; 1354 return false;
1356 } 1355 }
1357 1356
1358 if (!QFile::exists(filename)) { 1357 if (!QFile::exists(filename)) {
1359 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1358 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1360 return false; 1359 return false;
1361 } 1360 }
1362 1361
1363 globalFlagBlockAgenda = 1; 1362 globalFlagBlockAgenda = 1;
1364 if (!merge) mCalendar->close(); 1363 if (!merge) mCalendar->close();
1365 1364
1366 mStorage->setFileName( filename ); 1365 mStorage->setFileName( filename );
1367 1366
1368 if ( mStorage->load(KOPrefs::instance()->mUseQuicksave) ) { 1367 if ( mStorage->load(KOPrefs::instance()->mUseQuicksave) ) {
1369 if ( merge ) ;//setModified( true ); 1368 if ( merge ) ;//setModified( true );
1370 else { 1369 else {
1371 //setModified( true ); 1370 //setModified( true );
1372 mViewManager->setDocumentId( filename ); 1371 mViewManager->setDocumentId( filename );
1373 mDialogManager->setDocumentId( filename ); 1372 mDialogManager->setDocumentId( filename );
1374 mTodoList->setDocumentId( filename ); 1373 mTodoList->setDocumentId( filename );
1375 } 1374 }
1376 globalFlagBlockAgenda = 2; 1375 globalFlagBlockAgenda = 2;
1377 // if ( getLastSyncEvent() ) 1376 // if ( getLastSyncEvent() )
1378 // getLastSyncEvent()->setReadOnly( true ); 1377 // getLastSyncEvent()->setReadOnly( true );
1379 mCalendar->reInitAlarmSettings(); 1378 mCalendar->reInitAlarmSettings();
1380 setSyncEventsReadOnly(); 1379 setSyncEventsReadOnly();
1381 updateUnmanagedViews(); 1380 updateUnmanagedViews();
1382 updateView(); 1381 updateView();
1383 if ( filename != MainWindow::defaultFileName() ) 1382 if ( filename != MainWindow::defaultFileName() )
1384 saveCalendar( MainWindow::defaultFileName() ); 1383 saveCalendar( MainWindow::defaultFileName() );
1385 loadedFileVersion = QDateTime::currentDateTime(); 1384 loadedFileVersion = QDateTime::currentDateTime();
1386 return true; 1385 return true;
1387 } else { 1386 } else {
1388 // while failing to load, the calendar object could 1387 // while failing to load, the calendar object could
1389 // have become partially populated. Clear it out. 1388 // have become partially populated. Clear it out.
1390 if ( !merge ) mCalendar->close(); 1389 if ( !merge ) mCalendar->close();
1391 1390
1392 KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1391 KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1393 1392
1394 globalFlagBlockAgenda = 2; 1393 globalFlagBlockAgenda = 2;
1395 updateView(); 1394 updateView();
1396 } 1395 }
1397 return false; 1396 return false;
1398} 1397}
1399void CalendarView::setLoadedFileVersion(QDateTime dt) 1398void CalendarView::setLoadedFileVersion(QDateTime dt)
1400{ 1399{
1401 loadedFileVersion = dt; 1400 loadedFileVersion = dt;
1402} 1401}
1403bool CalendarView::checkFileChanged(QString fn) 1402bool CalendarView::checkFileChanged(QString fn)
1404{ 1403{
1405 QFileInfo finf ( fn ); 1404 QFileInfo finf ( fn );
1406 if ( !finf.exists() ) 1405 if ( !finf.exists() )
1407 return true; 1406 return true;
1408 QDateTime dt = finf.lastModified (); 1407 QDateTime dt = finf.lastModified ();
1409 if ( dt <= loadedFileVersion ) 1408 if ( dt <= loadedFileVersion )
1410 return false; 1409 return false;
1411 return true; 1410 return true;
1412 1411
1413} 1412}
1414bool CalendarView::checkFileVersion(QString fn) 1413bool CalendarView::checkFileVersion(QString fn)
1415{ 1414{
1416 QFileInfo finf ( fn ); 1415 QFileInfo finf ( fn );
1417 if ( !finf.exists() ) 1416 if ( !finf.exists() )
1418 return true; 1417 return true;
1419 QDateTime dt = finf.lastModified (); 1418 QDateTime dt = finf.lastModified ();
1420 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1419 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1421 //qDebug("file on disk version %s",dt.toString().latin1()); 1420 //qDebug("file on disk version %s",dt.toString().latin1());
1422 if ( dt <= loadedFileVersion ) 1421 if ( dt <= loadedFileVersion )
1423 return true; 1422 return true;
1424 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, false)) , 1423 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, false)) ,
1425 i18n("KO/Pi Warning"),i18n("Overwrite"), 1424 i18n("KO/Pi Warning"),i18n("Overwrite"),
1426 i18n("Sync+save")); 1425 i18n("Sync+save"));
1427 1426
1428 if ( km == KMessageBox::Cancel ) 1427 if ( km == KMessageBox::Cancel )
1429 return false; 1428 return false;
1430 if ( km == KMessageBox::Yes ) 1429 if ( km == KMessageBox::Yes )
1431 return true; 1430 return true;
1432 1431
1433 setSyncDevice("deleteaftersync" ); 1432 setSyncDevice("deleteaftersync" );
1434 KOPrefs::instance()->mAskForPreferences = true; 1433 KOPrefs::instance()->mAskForPreferences = true;
1435 KOPrefs::instance()->mSyncAlgoPrefs = 3; 1434 KOPrefs::instance()->mSyncAlgoPrefs = 3;
1436 KOPrefs::instance()->mWriteBackFile = false; 1435 KOPrefs::instance()->mWriteBackFile = false;
1437 KOPrefs::instance()->mWriteBackExistingOnly = false; 1436 KOPrefs::instance()->mWriteBackExistingOnly = false;
1438 KOPrefs::instance()->mShowSyncSummary = false; 1437 KOPrefs::instance()->mShowSyncSummary = false;
1439 syncCalendar( fn, 3 ); 1438 syncCalendar( fn, 3 );
1440 Event * e = getLastSyncEvent(); 1439 Event * e = getLastSyncEvent();
1441 mCalendar->deleteEvent ( e ); 1440 mCalendar->deleteEvent ( e );
1442 updateView(); 1441 updateView();
1443 return true; 1442 return true;
1444} 1443}
1445 1444
1446bool CalendarView::saveCalendar( QString filename ) 1445bool CalendarView::saveCalendar( QString filename )
1447{ 1446{
1448 1447
1449 // Store back all unsaved data into calendar object 1448 // Store back all unsaved data into calendar object
1450 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1449 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1451 if ( mViewManager->currentView() ) 1450 if ( mViewManager->currentView() )
1452 mViewManager->currentView()->flushView(); 1451 mViewManager->currentView()->flushView();
1453 1452
1454 //mStorage->setFileName( filename ); 1453 //mStorage->setFileName( filename );
1455 1454
1456 mStorage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 1455 mStorage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
1457 mStorage->setFileName( filename ); 1456 mStorage->setFileName( filename );
1458 bool success; 1457 bool success;
1459 success = mStorage->save(); 1458 success = mStorage->save();
1460 if ( !success ) { 1459 if ( !success ) {
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 589ab2d..d0d1f3b 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -56,1549 +56,1551 @@ using namespace KCal;
56#include "koimportoldialog.h" 56#include "koimportoldialog.h"
57#endif 57#endif
58#include "mainwindow.h" 58#include "mainwindow.h"
59 59
60int globalFlagBlockStartup; 60int globalFlagBlockStartup;
61MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : 61MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
62 QMainWindow( parent, name ) 62 QMainWindow( parent, name )
63{ 63{
64 64
65#ifdef DESKTOP_VERSION 65#ifdef DESKTOP_VERSION
66 setFont( QFont("Arial"), 14 ); 66 setFont( QFont("Arial"), 14 );
67#endif 67#endif
68 68
69 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; 69 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
70 QString confFile = locateLocal("config","korganizerrc"); 70 QString confFile = locateLocal("config","korganizerrc");
71 QFileInfo finf ( confFile ); 71 QFileInfo finf ( confFile );
72 bool showWarning = !finf.exists(); 72 bool showWarning = !finf.exists();
73 setIcon(SmallIcon( "ko24" ) ); 73 setIcon(SmallIcon( "ko24" ) );
74 mBlockAtStartup = true; 74 mBlockAtStartup = true;
75 mFlagKeyPressed = false; 75 mFlagKeyPressed = false;
76 setCaption("KOrganizer/Pi"); 76 setCaption("KOrganizer/Pi");
77 KOPrefs *p = KOPrefs::instance(); 77 KOPrefs *p = KOPrefs::instance();
78 // if ( QApplication::desktop()->height() > 480 ) { 78 // if ( QApplication::desktop()->height() > 480 ) {
79// if ( p->mHourSize == 4 ) 79// if ( p->mHourSize == 4 )
80// p->mHourSize = 6; 80// p->mHourSize = 6;
81// } 81// }
82 if ( p->mHourSize > 18 ) 82 if ( p->mHourSize > 18 )
83 p->mHourSize = 18; 83 p->mHourSize = 18;
84 QMainWindow::ToolBarDock tbd; 84 QMainWindow::ToolBarDock tbd;
85 if ( p->mToolBarHor ) { 85 if ( p->mToolBarHor ) {
86 if ( p->mToolBarUp ) 86 if ( p->mToolBarUp )
87 tbd = Bottom; 87 tbd = Bottom;
88 else 88 else
89 tbd = Top; 89 tbd = Top;
90 } 90 }
91 else { 91 else {
92 if ( p->mToolBarUp ) 92 if ( p->mToolBarUp )
93 tbd = Right; 93 tbd = Right;
94 else 94 else
95 tbd = Left; 95 tbd = Left;
96 } 96 }
97 if ( KOPrefs::instance()->mUseAppColors ) 97 if ( KOPrefs::instance()->mUseAppColors )
98 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 98 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
99 globalFlagBlockStartup = 1; 99 globalFlagBlockStartup = 1;
100 iconToolBar = new QPEToolBar( this ); 100 iconToolBar = new QPEToolBar( this );
101 addToolBar (iconToolBar , tbd ); 101 addToolBar (iconToolBar , tbd );
102 mBlockSaveFlag = false; 102 mBlockSaveFlag = false;
103 mCalendarModifiedFlag = false; 103 mCalendarModifiedFlag = false;
104 104
105 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); 105 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
106 splash->setAlignment ( AlignCenter ); 106 splash->setAlignment ( AlignCenter );
107 setCentralWidget( splash ); 107 setCentralWidget( splash );
108#ifndef DESKTOP_VERSION 108#ifndef DESKTOP_VERSION
109 showMaximized(); 109 showMaximized();
110#endif 110#endif
111 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); 111 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
112 setDefaultPreferences(); 112 setDefaultPreferences();
113 mCalendar = new CalendarLocal(); 113 mCalendar = new CalendarLocal();
114 mView = new CalendarView( mCalendar, this,"mCalendar " ); 114 mView = new CalendarView( mCalendar, this,"mCalendar " );
115 mView->hide(); 115 mView->hide();
116 //mView->resize(splash->size() ); 116 //mView->resize(splash->size() );
117 initActions(); 117 initActions();
118#ifndef DESKTOP_VERSION 118#ifndef DESKTOP_VERSION
119 iconToolBar->show(); 119 iconToolBar->show();
120 qApp->processEvents(); 120 qApp->processEvents();
121#endif 121#endif
122 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); 122 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
123 int vh = height() ; 123 int vh = height() ;
124 int vw = width(); 124 int vw = width();
125 //qDebug("Toolbar hei %d ",iconToolBar->height() ); 125 //qDebug("Toolbar hei %d ",iconToolBar->height() );
126 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 126 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
127 vh -= iconToolBar->height(); 127 vh -= iconToolBar->height();
128 } else { 128 } else {
129 vw -= iconToolBar->height(); 129 vw -= iconToolBar->height();
130 } 130 }
131 //mView->setMaximumSize( splash->size() ); 131 //mView->setMaximumSize( splash->size() );
132 //mView->resize( splash->size() ); 132 //mView->resize( splash->size() );
133 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 133 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
134 mView->readSettings(); 134 mView->readSettings();
135 bool oldOpened = false; 135 bool oldOpened = false;
136 bool newFile = false; 136 bool newFile = false;
137 if( !QFile::exists( defaultFileName() ) ) { 137 if( !QFile::exists( defaultFileName() ) ) {
138 QFileInfo finfo ( defaultFileName() ); 138 QFileInfo finfo ( defaultFileName() );
139 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); 139 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
140 qDebug("oldfile %s ", oldFile.latin1()); 140 qDebug("oldfile %s ", oldFile.latin1());
141 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; 141 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n";
142 finfo.setFile( oldFile ); 142 finfo.setFile( oldFile );
143 if (finfo.exists() ) { 143 if (finfo.exists() ) {
144 KMessageBox::information( this, message); 144 KMessageBox::information( this, message);
145 mView->openCalendar( oldFile ); 145 mView->openCalendar( oldFile );
146 qApp->processEvents(); 146 qApp->processEvents();
147 } else { 147 } else {
148 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); 148 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
149 finfo.setFile( oldFile ); 149 finfo.setFile( oldFile );
150 if (finfo.exists() ) { 150 if (finfo.exists() ) {
151 KMessageBox::information( this, message); 151 KMessageBox::information( this, message);
152 mView->openCalendar( oldFile ); 152 mView->openCalendar( oldFile );
153 qApp->processEvents(); 153 qApp->processEvents();
154 } 154 }
155 } 155 }
156 mView->saveCalendar( defaultFileName() ); 156 mView->saveCalendar( defaultFileName() );
157 newFile = true; 157 newFile = true;
158 } 158 }
159 159
160 QTime neededSaveTime = QDateTime::currentDateTime().time(); 160 QTime neededSaveTime = QDateTime::currentDateTime().time();
161 if ( ! oldOpened ) 161 if ( ! oldOpened )
162 mView->openCalendar( defaultFileName() ); 162 mView->openCalendar( defaultFileName() );
163 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 163 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
164 qDebug("KO: Calendar loading time: %d ms",msNeeded ); 164 qDebug("KO: Calendar loading time: %d ms",msNeeded );
165 165
166 if ( KOPrefs::instance()->mLanguageChanged ) { 166 if ( KOPrefs::instance()->mLanguageChanged ) {
167 KOPrefs::instance()->setCategoryDefaults(); 167 KOPrefs::instance()->setCategoryDefaults();
168 int count = mView->addCategories(); 168 int count = mView->addCategories();
169 KOPrefs::instance()->mLanguageChanged = false; 169 KOPrefs::instance()->mLanguageChanged = false;
170 } 170 }
171 processIncidenceSelection( 0 ); 171 processIncidenceSelection( 0 );
172 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), 172 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
173 SLOT( processIncidenceSelection( Incidence * ) ) ); 173 SLOT( processIncidenceSelection( Incidence * ) ) );
174 connect( mView, SIGNAL( modifiedChanged( bool ) ), 174 connect( mView, SIGNAL( modifiedChanged( bool ) ),
175 SLOT( slotModifiedChanged( bool ) ) ); 175 SLOT( slotModifiedChanged( bool ) ) );
176 176
177 177
178 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); 178 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
179 mView->setModified( false ); 179 mView->setModified( false );
180 mBlockAtStartup = false; 180 mBlockAtStartup = false;
181 mView->setModified( false ); 181 mView->setModified( false );
182 setCentralWidget( mView ); 182 setCentralWidget( mView );
183 globalFlagBlockStartup = 0; 183 globalFlagBlockStartup = 0;
184 mView->show(); 184 mView->show();
185 delete splash; 185 delete splash;
186 if ( newFile ) 186 if ( newFile )
187 mView->updateConfig(); 187 mView->updateConfig();
188 // qApp->processEvents(); 188 // qApp->processEvents();
189 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 189 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
190 fillSyncMenu(); 190 fillSyncMenu();
191 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); 191 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
192 if ( showWarning ) { 192 if ( showWarning ) {
193 KMessageBox::information( this, 193 KMessageBox::information( this,
194 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); 194 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information");
195 qApp->processEvents(); 195 qApp->processEvents();
196 mView->dialogManager()->showSyncOptions(); 196 mView->dialogManager()->showSyncOptions();
197 } 197 }
198} 198}
199MainWindow::~MainWindow() 199MainWindow::~MainWindow()
200{ 200{
201 //qDebug("MainWindow::~MainWindow() "); 201 //qDebug("MainWindow::~MainWindow() ");
202 //save toolbar location 202 //save toolbar location
203 203
204 delete mCalendar; 204 delete mCalendar;
205 delete KOPrefs::instance(); 205 delete KOPrefs::instance();
206 delete KIncidenceFormatter::instance(); 206 delete KIncidenceFormatter::instance();
207 207
208 208
209} 209}
210void MainWindow::closeEvent( QCloseEvent* ce ) 210void MainWindow::closeEvent( QCloseEvent* ce )
211{ 211{
212 212
213 213
214 214
215 if ( ! KOPrefs::instance()->mAskForQuit ) { 215 if ( ! KOPrefs::instance()->mAskForQuit ) {
216 saveOnClose(); 216 saveOnClose();
217 ce->accept(); 217 ce->accept();
218 return; 218 return;
219 219
220 } 220 }
221 221
222 switch( QMessageBox::information( this, "KO/Pi", 222 switch( QMessageBox::information( this, "KO/Pi",
223 i18n("Do you really want\nto close KO/Pi?"), 223 i18n("Do you really want\nto close KO/Pi?"),
224 i18n("Close"), i18n("No"), 224 i18n("Close"), i18n("No"),
225 0, 0 ) ) { 225 0, 0 ) ) {
226 case 0: 226 case 0:
227 saveOnClose(); 227 saveOnClose();
228 ce->accept(); 228 ce->accept();
229 break; 229 break;
230 case 1: 230 case 1:
231 ce->ignore(); 231 ce->ignore();
232 break; 232 break;
233 case 2: 233 case 2:
234 234
235 default: 235 default:
236 break; 236 break;
237 } 237 }
238 238
239 239
240} 240}
241 241
242void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) 242void MainWindow::recieve( const QCString& cmsg, const QByteArray& data )
243{ 243{
244 QDataStream stream( data, IO_ReadOnly ); 244 QDataStream stream( data, IO_ReadOnly );
245 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); 245 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" );
246 //QString datamess; 246 //QString datamess;
247 //qDebug("message "); 247 //qDebug("message ");
248 qDebug("KO: QCOP message received: %s ", cmsg.data() ); 248 qDebug("KO: QCOP message received: %s ", cmsg.data() );
249 if ( cmsg == "-writeFile" ) { 249 if ( cmsg == "-writeFile" ) {
250 // I made from the "-writeFile" an "-writeAlarm" 250 // I made from the "-writeFile" an "-writeAlarm"
251 mView->viewManager()->showWhatsNextView(); 251 mView->viewManager()->showWhatsNextView();
252 mCalendar->checkAlarmForIncidence( 0, true); 252 mCalendar->checkAlarmForIncidence( 0, true);
253 showMaximized(); 253 showMaximized();
254 raise(); 254 raise();
255 return; 255 return;
256 256
257 } 257 }
258 if ( cmsg == "-writeFileSilent" ) { 258 if ( cmsg == "-writeFileSilent" ) {
259 // I made from the "-writeFile" an "-writeAlarm" 259 // I made from the "-writeFile" an "-writeAlarm"
260 // mView->viewManager()->showWhatsNextView(); 260 // mView->viewManager()->showWhatsNextView();
261 mCalendar->checkAlarmForIncidence( 0, true); 261 mCalendar->checkAlarmForIncidence( 0, true);
262 //showMaximized(); 262 //showMaximized();
263 //raise(); 263 //raise();
264 hide(); 264 hide();
265 return; 265 return;
266 } 266 }
267 if ( cmsg == "-newCountdown" ) { 267 if ( cmsg == "-newCountdown" ) {
268 qDebug("newCountdown "); 268 qDebug("newCountdown ");
269 269
270 } 270 }
271 QString msg ; 271 QString msg ;
272 QString allmsg = cmsg; 272 QString allmsg = cmsg;
273 while ( allmsg.length() > 0 ) { 273 while ( allmsg.length() > 0 ) {
274 int nextC = allmsg.find( "-", 1 ); 274 int nextC = allmsg.find( "-", 1 );
275 if ( nextC == -1 ) { 275 if ( nextC == -1 ) {
276 msg = allmsg; 276 msg = allmsg;
277 allmsg = ""; 277 allmsg = "";
278 } else{ 278 } else{
279 msg = allmsg.left( nextC ); 279 msg = allmsg.left( nextC );
280 allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); 280 allmsg = allmsg.mid( nextC, allmsg.length()-nextC );
281 } 281 }
282 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); 282 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() );
283 if ( msg == "-newEvent" ) { 283 if ( msg == "-newEvent" ) {
284 mView->newEvent(); 284 mView->newEvent();
285 } 285 }
286 if ( msg == "-newTodo" ) { 286 if ( msg == "-newTodo" ) {
287 mView->newTodo(); 287 mView->newTodo();
288 288
289 } 289 }
290 if ( msg == "-showWN" ) { 290 if ( msg == "-showWN" ) {
291 mView->viewManager()->showWhatsNextView(); 291 mView->viewManager()->showWhatsNextView();
292 } 292 }
293 if ( msg == "-showTodo" ) { 293 if ( msg == "-showTodo" ) {
294 mView->viewManager()->showTodoView(); 294 mView->viewManager()->showTodoView();
295 } 295 }
296 if ( msg == "-showList" ) { 296 if ( msg == "-showList" ) {
297 mView->viewManager()->showListView(); 297 mView->viewManager()->showListView();
298 } 298 }
299 else if ( msg == "-showDay" ) { 299 else if ( msg == "-showDay" ) {
300 mView->viewManager()->showDayView(); 300 mView->viewManager()->showDayView();
301 } 301 }
302 else if ( msg == "-showWWeek" ) { 302 else if ( msg == "-showWWeek" ) {
303 mView->viewManager()->showWorkWeekView(); 303 mView->viewManager()->showWorkWeekView();
304 } 304 }
305 else if ( msg == "-ringSync" ) { 305 else if ( msg == "-ringSync" ) {
306 multiSync( false ); 306 multiSync( false );
307 } 307 }
308 else if ( msg == "-showWeek" ) { 308 else if ( msg == "-showWeek" ) {
309 mView->viewManager()->showWeekView(); 309 mView->viewManager()->showWeekView();
310 } 310 }
311 else if ( msg == "-showTodo" ) { 311 else if ( msg == "-showTodo" ) {
312 mView->viewManager()->showTodoView(); 312 mView->viewManager()->showTodoView();
313 } 313 }
314 else if ( msg == "-showJournal" ) { 314 else if ( msg == "-showJournal" ) {
315 mView->dateNavigator()->selectDates( 1 ); 315 mView->dateNavigator()->selectDates( 1 );
316 mView->dateNavigator()->selectToday(); 316 mView->dateNavigator()->selectToday();
317 mView->viewManager()->showJournalView(); 317 mView->viewManager()->showJournalView();
318 } 318 }
319 else if ( msg == "-showKO" ) { 319 else if ( msg == "-showKO" ) {
320 mView->viewManager()->showNextXView(); 320 mView->viewManager()->showNextXView();
321 } 321 }
322 else if ( msg == "-showWNext" || msg == "nextView()" ) { 322 else if ( msg == "-showWNext" || msg == "nextView()" ) {
323 mView->viewManager()->showWhatsNextView(); 323 mView->viewManager()->showWhatsNextView();
324 } 324 }
325 else if ( msg == "-showNextXView" ) { 325 else if ( msg == "-showNextXView" ) {
326 mView->viewManager()->showNextXView(); 326 mView->viewManager()->showNextXView();
327 } 327 }
328 328
329 329
330 } 330 }
331 331
332 showMaximized(); 332 showMaximized();
333 raise(); 333 raise();
334} 334}
335 335
336QPixmap MainWindow::loadPixmap( QString name ) 336QPixmap MainWindow::loadPixmap( QString name )
337{ 337{
338 return SmallIcon( name ); 338 return SmallIcon( name );
339 339
340} 340}
341void MainWindow::initActions() 341void MainWindow::initActions()
342{ 342{
343 //KOPrefs::instance()->mShowFullMenu 343 //KOPrefs::instance()->mShowFullMenu
344 iconToolBar->clear(); 344 iconToolBar->clear();
345 KOPrefs *p = KOPrefs::instance(); 345 KOPrefs *p = KOPrefs::instance();
346 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); 346 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar );
347 347
348 QPopupMenu *viewMenu = new QPopupMenu( this ); 348 QPopupMenu *viewMenu = new QPopupMenu( this );
349 QPopupMenu *actionMenu = new QPopupMenu( this ); 349 QPopupMenu *actionMenu = new QPopupMenu( this );
350 QPopupMenu *importMenu = new QPopupMenu( this ); 350 QPopupMenu *importMenu = new QPopupMenu( this );
351 351
352 syncMenu = new QPopupMenu( this ); 352 syncMenu = new QPopupMenu( this );
353 configureAgendaMenu = new QPopupMenu( this ); 353 configureAgendaMenu = new QPopupMenu( this );
354 configureToolBarMenu = new QPopupMenu( this ); 354 configureToolBarMenu = new QPopupMenu( this );
355 QPopupMenu *helpMenu = new QPopupMenu( this ); 355 QPopupMenu *helpMenu = new QPopupMenu( this );
356 if ( KOPrefs::instance()->mShowFullMenu ) { 356 if ( KOPrefs::instance()->mShowFullMenu ) {
357 QMenuBar *menuBar1; 357 QMenuBar *menuBar1;
358 menuBar1 = menuBar(); 358 menuBar1 = menuBar();
359 menuBar1->insertItem( i18n("File"), importMenu ); 359 menuBar1->insertItem( i18n("File"), importMenu );
360 menuBar1->insertItem( i18n("View"), viewMenu ); 360 menuBar1->insertItem( i18n("View"), viewMenu );
361 menuBar1->insertItem( i18n("Actions"), actionMenu ); 361 menuBar1->insertItem( i18n("Actions"), actionMenu );
362 menuBar1->insertItem( i18n("Synchronize"), syncMenu ); 362 menuBar1->insertItem( i18n("Synchronize"), syncMenu );
363 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 363 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu );
364 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); 364 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu );
365 menuBar1->insertItem( i18n("Help"), helpMenu ); 365 menuBar1->insertItem( i18n("Help"), helpMenu );
366 } else { 366 } else {
367 QPEMenuBar *menuBar1; 367 QPEMenuBar *menuBar1;
368 menuBar1 = new QPEMenuBar( iconToolBar ); 368 menuBar1 = new QPEMenuBar( iconToolBar );
369 QPopupMenu *menuBar = new QPopupMenu( this ); 369 QPopupMenu *menuBar = new QPopupMenu( this );
370 menuBar1->insertItem( i18n("ME"), menuBar); 370 menuBar1->insertItem( i18n("ME"), menuBar);
371 menuBar->insertItem( i18n("File"), importMenu ); 371 menuBar->insertItem( i18n("File"), importMenu );
372 menuBar->insertItem( i18n("View"), viewMenu ); 372 menuBar->insertItem( i18n("View"), viewMenu );
373 menuBar->insertItem( i18n("Actions"), actionMenu ); 373 menuBar->insertItem( i18n("Actions"), actionMenu );
374 menuBar->insertItem( i18n("Synchronize"), syncMenu ); 374 menuBar->insertItem( i18n("Synchronize"), syncMenu );
375 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 375 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu );
376 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); 376 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu );
377 menuBar->insertItem( i18n("Help"), helpMenu ); 377 menuBar->insertItem( i18n("Help"), helpMenu );
378 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); 378 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() );
379 menuBar1->setMaximumSize( menuBar1->sizeHint( )); 379 menuBar1->setMaximumSize( menuBar1->sizeHint( ));
380 } 380 }
381 connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) ); 381 connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) );
382 // ****************** 382 // ******************
383 QAction *action; 383 QAction *action;
384 QIconSet icon; 384 QIconSet icon;
385 // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); 385 // QPopupMenu *configureMenu= new QPopupMenu( menuBar );
386 configureToolBarMenu->setCheckable( true ); 386 configureToolBarMenu->setCheckable( true );
387 387
388 QString pathString = ""; 388 QString pathString = "";
389 if ( !p->mToolBarMiniIcons ) { 389 if ( !p->mToolBarMiniIcons ) {
390 if ( QApplication::desktop()->width() < 480 ) 390 if ( QApplication::desktop()->width() < 480 )
391 pathString += "icons16/"; 391 pathString += "icons16/";
392 } else 392 } else
393 pathString += "iconsmini/"; 393 pathString += "iconsmini/";
394 configureAgendaMenu->setCheckable( true ); 394 configureAgendaMenu->setCheckable( true );
395 configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 ); 395 configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 );
396 configureAgendaMenu->insertSeparator(); 396 configureAgendaMenu->insertSeparator();
397 configureAgendaMenu->insertItem(i18n("Tiny"), 4 ); 397 configureAgendaMenu->insertItem(i18n("Tiny"), 4 );
398 configureAgendaMenu->insertItem(i18n("Small"), 6 ); 398 configureAgendaMenu->insertItem(i18n("Small"), 6 );
399 configureAgendaMenu->insertItem(i18n("Medium"), 8 ); 399 configureAgendaMenu->insertItem(i18n("Medium"), 8 );
400 configureAgendaMenu->insertItem(i18n("Normal"), 10 ); 400 configureAgendaMenu->insertItem(i18n("Normal"), 10 );
401 configureAgendaMenu->insertItem(i18n("Large"), 12 ); 401 configureAgendaMenu->insertItem(i18n("Large"), 12 );
402 configureAgendaMenu->insertItem(i18n("Big"), 14 ); 402 configureAgendaMenu->insertItem(i18n("Big"), 14 );
403 configureAgendaMenu->insertItem(i18n("Bigger"), 16 ); 403 configureAgendaMenu->insertItem(i18n("Bigger"), 16 );
404 configureAgendaMenu->insertItem(i18n("Biggest"), 18 ); 404 configureAgendaMenu->insertItem(i18n("Biggest"), 18 );
405 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); 405 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu );
406 406
407 icon = loadPixmap( pathString + "configure" ); 407 icon = loadPixmap( pathString + "configure" );
408 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); 408 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this );
409 action->addTo( actionMenu ); 409 action->addTo( actionMenu );
410 connect( action, SIGNAL( activated() ), 410 connect( action, SIGNAL( activated() ),
411 mView, SLOT( edit_options() ) ); 411 mView, SLOT( edit_options() ) );
412 actionMenu->insertSeparator(); 412 actionMenu->insertSeparator();
413 icon = loadPixmap( pathString + "newevent" ); 413 icon = loadPixmap( pathString + "newevent" );
414 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); 414 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 );
415 configureToolBarMenu->insertSeparator(); 415 configureToolBarMenu->insertSeparator();
416 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); 416 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 );
417 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); 417 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this );
418 ne_action->addTo( actionMenu ); 418 ne_action->addTo( actionMenu );
419 connect( ne_action, SIGNAL( activated() ), 419 connect( ne_action, SIGNAL( activated() ),
420 mView, SLOT( newEvent() ) ); 420 mView, SLOT( newEvent() ) );
421 icon = loadPixmap( pathString + "newtodo" ); 421 icon = loadPixmap( pathString + "newtodo" );
422 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); 422 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 );
423 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); 423 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this );
424 nt_action->addTo( actionMenu ); 424 nt_action->addTo( actionMenu );
425 connect( nt_action, SIGNAL( activated() ), 425 connect( nt_action, SIGNAL( activated() ),
426 mView, SLOT( newTodo() ) ); 426 mView, SLOT( newTodo() ) );
427 icon = loadPixmap( pathString + "navi" ); 427 icon = loadPixmap( pathString + "navi" );
428 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); 428 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this );
429 action->addTo( viewMenu ); 429 action->addTo( viewMenu );
430 connect( action, SIGNAL( activated() ), 430 connect( action, SIGNAL( activated() ),
431 mView, SLOT( toggleDateNavigatorWidget() ) ); 431 mView, SLOT( toggleDateNavigatorWidget() ) );
432 icon = loadPixmap( pathString + "filter" ); 432 icon = loadPixmap( pathString + "filter" );
433 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); 433 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this );
434 action->addTo( viewMenu ); 434 action->addTo( viewMenu );
435 connect( action, SIGNAL( activated() ), 435 connect( action, SIGNAL( activated() ),
436 mView, SLOT( toggleFilter() ) ); 436 mView, SLOT( toggleFilter() ) );
437 437
438 438
439 viewMenu->insertSeparator(); 439 viewMenu->insertSeparator();
440 icon = loadPixmap( pathString + "picker" ); 440 icon = loadPixmap( pathString + "picker" );
441 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); 441 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this );
442 action->addTo( viewMenu ); 442 action->addTo( viewMenu );
443 connect( action, SIGNAL( activated() ), 443 connect( action, SIGNAL( activated() ),
444 mView, SLOT( showDatePicker() ) ); 444 mView, SLOT( showDatePicker() ) );
445 action->addTo( iconToolBar ); 445 action->addTo( iconToolBar );
446 viewMenu->insertSeparator(); 446 viewMenu->insertSeparator();
447 icon = loadPixmap( pathString + "list" ); 447 icon = loadPixmap( pathString + "list" );
448 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); 448 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 );
449 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); 449 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this );
450 showlist_action->addTo( viewMenu ); 450 showlist_action->addTo( viewMenu );
451 connect( showlist_action, SIGNAL( activated() ), 451 connect( showlist_action, SIGNAL( activated() ),
452 mView->viewManager(), SLOT( showListView() ) ); 452 mView->viewManager(), SLOT( showListView() ) );
453 453
454 454
455 icon = loadPixmap( pathString + "day" ); 455 icon = loadPixmap( pathString + "day" );
456 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); 456 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 );
457 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); 457 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this );
458 day1_action->addTo( viewMenu ); 458 day1_action->addTo( viewMenu );
459 // action->addTo( toolBar ); 459 // action->addTo( toolBar );
460 connect( day1_action, SIGNAL( activated() ), 460 connect( day1_action, SIGNAL( activated() ),
461 mView->viewManager(), SLOT( showDayView() ) ); 461 mView->viewManager(), SLOT( showDayView() ) );
462 462
463 icon = loadPixmap( pathString + "workweek" ); 463 icon = loadPixmap( pathString + "workweek" );
464 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); 464 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 );
465 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); 465 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this );
466 day5_action->addTo( viewMenu ); 466 day5_action->addTo( viewMenu );
467 connect( day5_action, SIGNAL( activated() ), 467 connect( day5_action, SIGNAL( activated() ),
468 mView->viewManager(), SLOT( showWorkWeekView() ) ); 468 mView->viewManager(), SLOT( showWorkWeekView() ) );
469 469
470 icon = loadPixmap( pathString + "week" ); 470 icon = loadPixmap( pathString + "week" );
471 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); 471 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 );
472 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); 472 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this );
473 day7_action->addTo( viewMenu ); 473 day7_action->addTo( viewMenu );
474 connect( day7_action, SIGNAL( activated() ), 474 connect( day7_action, SIGNAL( activated() ),
475 mView->viewManager(), SLOT( showWeekView() ) ); 475 mView->viewManager(), SLOT( showWeekView() ) );
476 476
477 icon = loadPixmap( pathString + "month" ); 477 icon = loadPixmap( pathString + "month" );
478 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); 478 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 );
479 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); 479 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this );
480 month_action->addTo( viewMenu ); 480 month_action->addTo( viewMenu );
481 connect( month_action, SIGNAL( activated() ), 481 connect( month_action, SIGNAL( activated() ),
482 mView->viewManager(), SLOT( showMonthView() ) ); 482 mView->viewManager(), SLOT( showMonthView() ) );
483 483
484 icon = loadPixmap( pathString + "todo" ); 484 icon = loadPixmap( pathString + "todo" );
485 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); 485 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 );
486 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); 486 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this );
487 todoview_action->addTo( viewMenu ); 487 todoview_action->addTo( viewMenu );
488 connect( todoview_action, SIGNAL( activated() ), 488 connect( todoview_action, SIGNAL( activated() ),
489 mView->viewManager(), SLOT( showTodoView() ) ); 489 mView->viewManager(), SLOT( showTodoView() ) );
490 490
491 icon = loadPixmap( pathString + "journal" ); 491 icon = loadPixmap( pathString + "journal" );
492 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); 492 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 );
493 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); 493 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this );
494 viewjournal_action->addTo( viewMenu ); 494 viewjournal_action->addTo( viewMenu );
495 connect( viewjournal_action, SIGNAL( activated() ), 495 connect( viewjournal_action, SIGNAL( activated() ),
496 mView->viewManager(), SLOT( showJournalView() ) ); 496 mView->viewManager(), SLOT( showJournalView() ) );
497 497
498 icon = loadPixmap( pathString + "xdays" ); 498 icon = loadPixmap( pathString + "xdays" );
499 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 ); 499 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 );
500 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); 500 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this );
501 xdays_action->addTo( viewMenu ); 501 xdays_action->addTo( viewMenu );
502 connect( xdays_action, SIGNAL( activated() ), 502 connect( xdays_action, SIGNAL( activated() ),
503 mView->viewManager(), SLOT( showNextXView() ) ); 503 mView->viewManager(), SLOT( showNextXView() ) );
504 504
505 icon = loadPixmap( pathString + "whatsnext" ); 505 icon = loadPixmap( pathString + "whatsnext" );
506 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 ); 506 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 );
507 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); 507 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this );
508 whatsnext_action->addTo( viewMenu ); 508 whatsnext_action->addTo( viewMenu );
509 connect( whatsnext_action, SIGNAL( activated() ), 509 connect( whatsnext_action, SIGNAL( activated() ),
510 mView->viewManager(), SLOT( showWhatsNextView() ) ); 510 mView->viewManager(), SLOT( showWhatsNextView() ) );
511 511
512#if 0 512#if 0
513 action = new QAction( "view_timespan", "Time Span", 0, this ); 513 action = new QAction( "view_timespan", "Time Span", 0, this );
514 action->addTo( viewMenu ); 514 action->addTo( viewMenu );
515 connect( action, SIGNAL( activated() ), 515 connect( action, SIGNAL( activated() ),
516 mView->viewManager(), SLOT( showTimeSpanView() ) ); 516 mView->viewManager(), SLOT( showTimeSpanView() ) );
517#endif 517#endif
518 518
519 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, 519 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0,
520 this ); 520 this );
521 mNewSubTodoAction->addTo( actionMenu ); 521 mNewSubTodoAction->addTo( actionMenu );
522 connect( mNewSubTodoAction, SIGNAL( activated() ), 522 connect( mNewSubTodoAction, SIGNAL( activated() ),
523 mView, SLOT( newSubTodo() ) ); 523 mView, SLOT( newSubTodo() ) );
524 524
525 actionMenu->insertSeparator(); 525 actionMenu->insertSeparator();
526 526
527 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); 527 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this );
528 mShowAction->addTo( actionMenu ); 528 mShowAction->addTo( actionMenu );
529 connect( mShowAction, SIGNAL( activated() ), 529 connect( mShowAction, SIGNAL( activated() ),
530 mView, SLOT( showIncidence() ) ); 530 mView, SLOT( showIncidence() ) );
531 531
532 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); 532 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this );
533 mEditAction->addTo( actionMenu ); 533 mEditAction->addTo( actionMenu );
534 connect( mEditAction, SIGNAL( activated() ), 534 connect( mEditAction, SIGNAL( activated() ),
535 mView, SLOT( editIncidence() ) ); 535 mView, SLOT( editIncidence() ) );
536 536
537 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); 537 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this );
538 mDeleteAction->addTo( actionMenu ); 538 mDeleteAction->addTo( actionMenu );
539 connect( mDeleteAction, SIGNAL( activated() ), 539 connect( mDeleteAction, SIGNAL( activated() ),
540 mView, SLOT( deleteIncidence() ) ); 540 mView, SLOT( deleteIncidence() ) );
541 541
542 actionMenu->insertSeparator(); 542 actionMenu->insertSeparator();
543 543
544 action = new QAction( "purge_completed", i18n("Purge Completed"), 0, 544 action = new QAction( "purge_completed", i18n("Purge Completed"), 0,
545 this ); 545 this );
546 action->addTo( actionMenu ); 546 action->addTo( actionMenu );
547 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); 547 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) );
548 548
549 icon = loadPixmap( pathString + "search" ); 549 icon = loadPixmap( pathString + "search" );
550 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); 550 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this );
551 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4); 551 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4);
552 search_action->addTo( actionMenu ); 552 search_action->addTo( actionMenu );
553 connect( search_action, SIGNAL( activated() ), 553 connect( search_action, SIGNAL( activated() ),
554 mView->dialogManager(), SLOT( showSearchDialog() ) ); 554 mView->dialogManager(), SLOT( showSearchDialog() ) );
555 555
556 icon = loadPixmap( pathString + "today" ); 556 icon = loadPixmap( pathString + "today" );
557 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); 557 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130);
558 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); 558 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this );
559 today_action->addTo( actionMenu ); 559 today_action->addTo( actionMenu );
560 connect( today_action, SIGNAL( activated() ), 560 connect( today_action, SIGNAL( activated() ),
561 mView, SLOT( goToday() ) ); 561 mView, SLOT( goToday() ) );
562 562
563 if ( KOPrefs::instance()->mShowFullMenu ) { 563 if ( KOPrefs::instance()->mShowFullMenu ) {
564 actionMenu->insertSeparator(); 564 actionMenu->insertSeparator();
565 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); 565 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu );
566 566
567 } 567 }
568 // actionMenu->insertSeparator(); 568 // actionMenu->insertSeparator();
569 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, 569 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0,
570 this ); 570 this );
571 action->addTo( importMenu ); 571 action->addTo( importMenu );
572 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); 572 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) );
573 action = new QAction( "import_quick", i18n("Import last file"), 0, 573 action = new QAction( "import_quick", i18n("Import last file"), 0,
574 this ); 574 this );
575 action->addTo( importMenu ); 575 action->addTo( importMenu );
576 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); 576 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) );
577 importMenu->insertSeparator(); 577 importMenu->insertSeparator();
578 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, 578 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0,
579 this ); 579 this );
580 action->addTo( importMenu ); 580 action->addTo( importMenu );
581 connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); 581 connect( action, SIGNAL( activated() ), SLOT( importBday() ) );
582#ifndef DESKTOP_VERSION 582#ifndef DESKTOP_VERSION
583 importMenu->insertSeparator(); 583 importMenu->insertSeparator();
584 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, 584 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0,
585 this ); 585 this );
586 action->addTo( importMenu ); 586 action->addTo( importMenu );
587 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); 587 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) );
588#else 588#else
589#ifdef _WIN32_ 589#ifdef _WIN32_
590 importMenu->insertSeparator(); 590 importMenu->insertSeparator();
591 action = new QAction( "import_ol", i18n("Import from OL"), 0, 591 action = new QAction( "import_ol", i18n("Import from OL"), 0,
592 this ); 592 this );
593 action->addTo( importMenu ); 593 action->addTo( importMenu );
594 connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); 594 connect( action, SIGNAL( activated() ), SLOT( importOL() ) );
595#endif 595#endif
596#endif 596#endif
597 597
598 importMenu->insertSeparator(); 598 importMenu->insertSeparator();
599 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, 599 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0,
600 this ); 600 this );
601 action->addTo( importMenu ); 601 action->addTo( importMenu );
602 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); 602 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) );
603 603
604 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, 604 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0,
605 this ); 605 this );
606 action->addTo( importMenu ); 606 action->addTo( importMenu );
607 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); 607 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) );
608 608
609 importMenu->insertSeparator(); 609 importMenu->insertSeparator();
610 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, 610 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0,
611 this ); 611 this );
612 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); 612 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) );
613 importMenu->insertSeparator(); 613 importMenu->insertSeparator();
614 action = new QAction( "manage cat", i18n("Manage new categories..."), 0, 614 action = new QAction( "manage cat", i18n("Manage new categories..."), 0,
615 this ); 615 this );
616 action->addTo( importMenu ); 616 action->addTo( importMenu );
617 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); 617 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) );
618#ifndef DESKTOP_VERSION 618#ifndef DESKTOP_VERSION
619 importMenu->insertSeparator(); 619 importMenu->insertSeparator();
620 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, 620 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0,
621 this ); 621 this );
622 action->addTo( importMenu ); 622 action->addTo( importMenu );
623 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); 623 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) );
624 624
625 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, 625 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0,
626 this ); 626 this );
627 action->addTo( importMenu ); 627 action->addTo( importMenu );
628 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); 628 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) );
629#else 629#else
630 importMenu->insertSeparator(); 630 importMenu->insertSeparator();
631 icon = loadPixmap( pathString + "print" ); 631 icon = loadPixmap( pathString + "print" );
632 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); 632 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this );
633 action->addTo( importMenu ); 633 action->addTo( importMenu );
634 connect( action, SIGNAL( activated() ), 634 connect( action, SIGNAL( activated() ),
635 this, SLOT( printCal() ) ); 635 this, SLOT( printCal() ) );
636 636
637 icon = loadPixmap( pathString + "print" ); 637 icon = loadPixmap( pathString + "print" );
638 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); 638 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this );
639 action->addTo( importMenu ); 639 action->addTo( importMenu );
640 connect( action, SIGNAL( activated() ), 640 connect( action, SIGNAL( activated() ),
641 this, SLOT( printSel() ) ); 641 this, SLOT( printSel() ) );
642#endif 642#endif
643 importMenu->insertSeparator(); 643 importMenu->insertSeparator();
644 action = new QAction( "beam all", i18n("Save"), 0, 644 action = new QAction( "beam all", i18n("Save"), 0,
645 this ); 645 this );
646 action->addTo( importMenu ); 646 action->addTo( importMenu );
647 connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); 647 connect( action, SIGNAL( activated() ), this, SLOT( save() ) );
648 action = new QAction( "beam all", i18n("Exit (+save)"), 0, 648 action = new QAction( "beam all", i18n("Exit (+save)"), 0,
649 this ); 649 this );
650 action->addTo( importMenu ); 650 action->addTo( importMenu );
651 connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); 651 connect( action, SIGNAL( activated() ), this, SLOT( close() ) );
652 652
653 //menuBar->insertItem( "Configure",configureMenu ); 653 //menuBar->insertItem( "Configure",configureMenu );
654 //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); 654 //configureMenu->insertItem( "Toolbar",configureToolBarMenu );
655 icon = loadPixmap( "korganizer/korganizer" ); 655 icon = loadPixmap( "korganizer/korganizer" );
656 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); 656 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this );
657 action->addTo( helpMenu ); 657 action->addTo( helpMenu );
658 connect( action, SIGNAL( activated() ), 658 connect( action, SIGNAL( activated() ),
659 SLOT( keyBindings() ) ); 659 SLOT( keyBindings() ) );
660 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); 660 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this );
661 action->addTo( helpMenu ); 661 action->addTo( helpMenu );
662 connect( action, SIGNAL( activated() ), 662 connect( action, SIGNAL( activated() ),
663 SLOT( features() ) ); 663 SLOT( features() ) );
664 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); 664 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this );
665 action->addTo( helpMenu ); 665 action->addTo( helpMenu );
666 connect( action, SIGNAL( activated() ), 666 connect( action, SIGNAL( activated() ),
667 SLOT( aboutAutoSaving() ) ); 667 SLOT( aboutAutoSaving() ) );
668 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); 668 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this );
669 action->addTo( helpMenu ); 669 action->addTo( helpMenu );
670 connect( action, SIGNAL( activated() ), 670 connect( action, SIGNAL( activated() ),
671 SLOT( aboutKnownBugs() ) ); 671 SLOT( aboutKnownBugs() ) );
672 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); 672 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this );
673 action->addTo( helpMenu ); 673 action->addTo( helpMenu );
674 connect( action, SIGNAL( activated() ), 674 connect( action, SIGNAL( activated() ),
675 SLOT( usertrans() ) ); 675 SLOT( usertrans() ) );
676 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); 676 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this );
677 action->addTo( helpMenu ); 677 action->addTo( helpMenu );
678 connect( action, SIGNAL( activated() ), 678 connect( action, SIGNAL( activated() ),
679 SLOT( synchowto() ) ); 679 SLOT( synchowto() ) );
680 action = new QAction( "Whats New", i18n("What's new?"), 0,this ); 680 action = new QAction( "Whats New", i18n("What's new?"), 0,this );
681 action->addTo( helpMenu ); 681 action->addTo( helpMenu );
682 connect( action, SIGNAL( activated() ), 682 connect( action, SIGNAL( activated() ),
683 SLOT( whatsNew() ) ); 683 SLOT( whatsNew() ) );
684 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); 684 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this );
685 action->addTo( helpMenu ); 685 action->addTo( helpMenu );
686 connect( action, SIGNAL( activated() ), 686 connect( action, SIGNAL( activated() ),
687 SLOT( faq() ) ); 687 SLOT( faq() ) );
688 688
689 689
690 action = new QAction( "about", i18n("About..."), 0, this ); 690 action = new QAction( "about", i18n("About..."), 0, this );
691 action->addTo( helpMenu ); 691 action->addTo( helpMenu );
692 connect( action, SIGNAL( activated() ), 692 connect( action, SIGNAL( activated() ),
693 SLOT( about() ) ); 693 SLOT( about() ) );
694 //menuBar->insertSeparator(); 694 //menuBar->insertSeparator();
695 695
696 // ****************************************************** 696 // ******************************************************
697 // menubar icons 697 // menubar icons
698 698
699 699
700 iconToolBar->setHorizontalStretchable (true ); 700 iconToolBar->setHorizontalStretchable (true );
701 //menuBar->insertItem( iconToolBar ); 701 //menuBar->insertItem( iconToolBar );
702 //xdays_action 702 //xdays_action
703 if (p-> mShowIconNewEvent) 703 if (p-> mShowIconNewEvent)
704 ne_action->addTo( iconToolBar ); 704 ne_action->addTo( iconToolBar );
705 if (p->mShowIconNewTodo ) 705 if (p->mShowIconNewTodo )
706 nt_action->addTo( iconToolBar ); 706 nt_action->addTo( iconToolBar );
707 if (p-> mShowIconSearch) 707 if (p-> mShowIconSearch)
708 search_action->addTo( iconToolBar ); 708 search_action->addTo( iconToolBar );
709 if (p-> mShowIconNext) 709 if (p-> mShowIconNext)
710 whatsnext_action->addTo( iconToolBar ); 710 whatsnext_action->addTo( iconToolBar );
711 if (p-> mShowIconNextDays) 711 if (p-> mShowIconNextDays)
712 xdays_action->addTo( iconToolBar ); 712 xdays_action->addTo( iconToolBar );
713 if (p-> mShowIconList) 713 if (p-> mShowIconList)
714 showlist_action->addTo( iconToolBar ); 714 showlist_action->addTo( iconToolBar );
715 if (p-> mShowIconDay1) 715 if (p-> mShowIconDay1)
716 day1_action->addTo( iconToolBar ); 716 day1_action->addTo( iconToolBar );
717 if (p-> mShowIconDay5) 717 if (p-> mShowIconDay5)
718 day5_action->addTo( iconToolBar ); 718 day5_action->addTo( iconToolBar );
719 if (p-> mShowIconDay7) 719 if (p-> mShowIconDay7)
720 day7_action->addTo( iconToolBar ); 720 day7_action->addTo( iconToolBar );
721 if (p-> mShowIconMonth) 721 if (p-> mShowIconMonth)
722 month_action->addTo( iconToolBar ); 722 month_action->addTo( iconToolBar );
723 if (p-> mShowIconTodoview) 723 if (p-> mShowIconTodoview)
724 todoview_action->addTo( iconToolBar ); 724 todoview_action->addTo( iconToolBar );
725 if (p-> mShowIconJournal) 725 if (p-> mShowIconJournal)
726 viewjournal_action->addTo( iconToolBar ); 726 viewjournal_action->addTo( iconToolBar );
727 icon = loadPixmap( pathString + "2leftarrowB" ); 727 icon = loadPixmap( pathString + "2leftarrowB" );
728 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); 728 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14);
729 if (p-> mShowIconBackFast) { 729 if (p-> mShowIconBackFast) {
730 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); 730 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this );
731 connect( action, SIGNAL( activated() ), 731 connect( action, SIGNAL( activated() ),
732 mView, SLOT( goPreviousMonth() ) ); 732 mView, SLOT( goPreviousMonth() ) );
733 action->addTo( iconToolBar ); 733 action->addTo( iconToolBar );
734 } 734 }
735 icon = loadPixmap( pathString + "1leftarrowB" ); 735 icon = loadPixmap( pathString + "1leftarrowB" );
736 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); 736 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15);
737 if (p-> mShowIconBack) { 737 if (p-> mShowIconBack) {
738 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); 738 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this );
739 connect( action, SIGNAL( activated() ), 739 connect( action, SIGNAL( activated() ),
740 mView, SLOT( goPrevious() ) ); 740 mView, SLOT( goPrevious() ) );
741 action->addTo( iconToolBar ); 741 action->addTo( iconToolBar );
742 } 742 }
743 if (p-> mShowIconToday) 743 if (p-> mShowIconToday)
744 today_action->addTo( iconToolBar ); 744 today_action->addTo( iconToolBar );
745 icon = loadPixmap( pathString + "1rightarrowB" ); 745 icon = loadPixmap( pathString + "1rightarrowB" );
746 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); 746 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220);
747 if (p-> mShowIconForward) { 747 if (p-> mShowIconForward) {
748 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); 748 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this );
749 connect( action, SIGNAL( activated() ), 749 connect( action, SIGNAL( activated() ),
750 mView, SLOT( goNext() ) ); 750 mView, SLOT( goNext() ) );
751 action->addTo( iconToolBar ); 751 action->addTo( iconToolBar );
752 } 752 }
753 icon = loadPixmap( pathString + "2rightarrowB" ); 753 icon = loadPixmap( pathString + "2rightarrowB" );
754 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); 754 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230);
755 if (p-> mShowIconForwardFast) { 755 if (p-> mShowIconForwardFast) {
756 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); 756 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this );
757 connect( action, SIGNAL( activated() ), 757 connect( action, SIGNAL( activated() ),
758 mView, SLOT( goNextMonth() ) ); 758 mView, SLOT( goNextMonth() ) );
759 action->addTo( iconToolBar ); 759 action->addTo( iconToolBar );
760 } 760 }
761 761
762 762
763 configureToolBarMenu->insertItem(i18n("What's This?"), 300); 763 configureToolBarMenu->insertItem(i18n("What's This?"), 300);
764 764
765 if (p-> mShowIconNewEvent) 765 if (p-> mShowIconNewEvent)
766 configureToolBarMenu->setItemChecked( 10, true ); 766 configureToolBarMenu->setItemChecked( 10, true );
767 if (p->mShowIconNewTodo ) 767 if (p->mShowIconNewTodo )
768 configureToolBarMenu->setItemChecked( 20, true ); 768 configureToolBarMenu->setItemChecked( 20, true );
769 if (p-> mShowIconSearch) 769 if (p-> mShowIconSearch)
770 configureToolBarMenu->setItemChecked( 120, true ); 770 configureToolBarMenu->setItemChecked( 120, true );
771 if (p-> mShowIconList) 771 if (p-> mShowIconList)
772 configureToolBarMenu->setItemChecked( 30, true ); 772 configureToolBarMenu->setItemChecked( 30, true );
773 if (p-> mShowIconDay1) 773 if (p-> mShowIconDay1)
774 configureToolBarMenu->setItemChecked( 40, true ); 774 configureToolBarMenu->setItemChecked( 40, true );
775 if (p-> mShowIconDay5) 775 if (p-> mShowIconDay5)
776 configureToolBarMenu->setItemChecked( 50, true ); 776 configureToolBarMenu->setItemChecked( 50, true );
777 if (p-> mShowIconDay7) 777 if (p-> mShowIconDay7)
778 configureToolBarMenu->setItemChecked( 60, true ); 778 configureToolBarMenu->setItemChecked( 60, true );
779 if (p-> mShowIconMonth) 779 if (p-> mShowIconMonth)
780 configureToolBarMenu->setItemChecked( 70, true ); 780 configureToolBarMenu->setItemChecked( 70, true );
781 if (p-> mShowIconTodoview) 781 if (p-> mShowIconTodoview)
782 configureToolBarMenu->setItemChecked( 80, true ); 782 configureToolBarMenu->setItemChecked( 80, true );
783 if (p-> mShowIconBackFast) 783 if (p-> mShowIconBackFast)
784 configureToolBarMenu->setItemChecked( 200, true ); 784 configureToolBarMenu->setItemChecked( 200, true );
785 if (p-> mShowIconBack) 785 if (p-> mShowIconBack)
786 configureToolBarMenu->setItemChecked( 210, true ); 786 configureToolBarMenu->setItemChecked( 210, true );
787 if (p-> mShowIconToday) 787 if (p-> mShowIconToday)
788 configureToolBarMenu->setItemChecked( 130, true ); 788 configureToolBarMenu->setItemChecked( 130, true );
789 if (p-> mShowIconForward) 789 if (p-> mShowIconForward)
790 configureToolBarMenu->setItemChecked( 220, true ); 790 configureToolBarMenu->setItemChecked( 220, true );
791 if (p-> mShowIconForwardFast) 791 if (p-> mShowIconForwardFast)
792 configureToolBarMenu->setItemChecked( 230, true ); 792 configureToolBarMenu->setItemChecked( 230, true );
793 if (p-> mShowIconNextDays) 793 if (p-> mShowIconNextDays)
794 configureToolBarMenu->setItemChecked( 100, true ); 794 configureToolBarMenu->setItemChecked( 100, true );
795 if (p-> mShowIconNext) 795 if (p-> mShowIconNext)
796 configureToolBarMenu->setItemChecked( 110, true ); 796 configureToolBarMenu->setItemChecked( 110, true );
797 if (p-> mShowIconJournal) 797 if (p-> mShowIconJournal)
798 configureToolBarMenu->setItemChecked( 90, true ); 798 configureToolBarMenu->setItemChecked( 90, true );
799 if (p-> mShowIconWhatsThis) 799 if (p-> mShowIconWhatsThis)
800 configureToolBarMenu->setItemChecked( 300, true ); 800 configureToolBarMenu->setItemChecked( 300, true );
801 801
802 QLabel* dummy = new QLabel( iconToolBar ); 802 QLabel* dummy = new QLabel( iconToolBar );
803 dummy->setBackgroundColor( iconToolBar->backgroundColor() ); 803 dummy->setBackgroundColor( iconToolBar->backgroundColor() );
804 if (!p-> mShowIconStretch) 804 if (!p-> mShowIconStretch)
805 iconToolBar->setStretchableWidget ( dummy ) ; 805 iconToolBar->setStretchableWidget ( dummy ) ;
806 else 806 else
807 configureToolBarMenu->setItemChecked( 5, true ); 807 configureToolBarMenu->setItemChecked( 5, true );
808 if (p-> mShowIconWhatsThis) 808 if (p-> mShowIconWhatsThis)
809 QWhatsThis::whatsThisButton ( iconToolBar ); 809 QWhatsThis::whatsThisButton ( iconToolBar );
810 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); 810 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) );
811 configureAgenda( p->mHourSize ); 811 configureAgenda( p->mHourSize );
812 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); 812 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) );
813} 813}
814void MainWindow::fillSyncMenu() 814void MainWindow::fillSyncMenu()
815{ 815{
816 syncMenu->clear(); 816 syncMenu->clear();
817 syncMenu->insertItem( i18n("Configure..."), 0 ); 817 syncMenu->insertItem( i18n("Configure..."), 0 );
818 syncMenu->insertSeparator(); 818 syncMenu->insertSeparator();
819 syncMenu->insertItem( i18n("Multiple sync"), 1 ); 819 syncMenu->insertItem( i18n("Multiple sync"), 1 );
820 syncMenu->insertSeparator(); 820 syncMenu->insertSeparator();
821 KConfig config ( locateLocal( "config","syncprofilesrc" ) ); 821 KConfig config ( locateLocal( "config","syncprofilesrc" ) );
822 config.setGroup("SyncProfiles"); 822 config.setGroup("SyncProfiles");
823 QStringList prof = config.readListEntry("SyncProfileNames"); 823 QStringList prof = config.readListEntry("SyncProfileNames");
824 824 KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined");
825 if ( prof.count() < 3 ) { 825 if ( prof.count() < 3 ) {
826 prof.clear(); 826 prof.clear();
827 prof << i18n("Sharp-DTM"); 827 prof << i18n("Sharp-DTM");
828 prof << i18n("Local file"); 828 prof << i18n("Local file");
829 prof << i18n("Last file"); 829 prof << i18n("Last file");
830 KSyncProfile* temp = new KSyncProfile (); 830 KSyncProfile* temp = new KSyncProfile ();
831 temp->setName( prof[0] ); 831 temp->setName( prof[0] );
832 temp->writeConfig(&config); 832 temp->writeConfig(&config);
833 temp->setName( prof[1] ); 833 temp->setName( prof[1] );
834 temp->writeConfig(&config); 834 temp->writeConfig(&config);
835 temp->setName( prof[2] ); 835 temp->setName( prof[2] );
836 temp->writeConfig(&config); 836 temp->writeConfig(&config);
837 config.setGroup("SyncProfiles");
838 config.writeEntry("SyncProfileNames",prof);
837 config.sync(); 839 config.sync();
838 delete temp; 840 delete temp;
839 } 841 }
840 KOPrefs::instance()->mSyncProfileNames = prof; 842 KOPrefs::instance()->mSyncProfileNames = prof;
841 int i; 843 int i;
842 for ( i = 0; i < prof.count(); ++i ) { 844 for ( i = 0; i < prof.count(); ++i ) {
843 845
844 syncMenu->insertItem( prof[i], 1000+i ); 846 syncMenu->insertItem( prof[i], 1000+i );
845 if ( i == 2 ) 847 if ( i == 2 )
846 syncMenu->insertSeparator(); 848 syncMenu->insertSeparator();
847 } 849 }
848 QDir app_dir; 850 QDir app_dir;
849 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { 851 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
850 syncMenu->setItemEnabled( false , 1000 ); 852 syncMenu->setItemEnabled( false , 1000 );
851 } 853 }
852} 854}
853 855
854int MainWindow::ringSync() 856int MainWindow::ringSync()
855{ 857{
856 int syncedProfiles = 0; 858 int syncedProfiles = 0;
857 int i; 859 int i;
858 QTime timer; 860 QTime timer;
859 KConfig *config = KOGlobals::config(); 861 KConfig *config = KOGlobals::config();
860 QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames; 862 QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames;
861 KSyncProfile* temp = new KSyncProfile (); 863 KSyncProfile* temp = new KSyncProfile ();
862 KOPrefs::instance()->mAskForPreferences = false; 864 KOPrefs::instance()->mAskForPreferences = false;
863 for ( i = 0; i < syncProfileNames.count(); ++i ) { 865 for ( i = 0; i < syncProfileNames.count(); ++i ) {
864 mCurrentSyncProfile = i; 866 mCurrentSyncProfile = i;
865 temp->setName(syncProfileNames[mCurrentSyncProfile]); 867 temp->setName(syncProfileNames[mCurrentSyncProfile]);
866 temp->readConfig(config); 868 temp->readConfig(config);
867 if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) { 869 if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) {
868 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); 870 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
869 ++syncedProfiles; 871 ++syncedProfiles;
870 // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 872 // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
871 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 873 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
872 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 874 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
873 KOPrefs::instance()->mShowSyncSummary = false; 875 KOPrefs::instance()->mShowSyncSummary = false;
874 mView->setSyncDevice(syncProfileNames[i] ); 876 mView->setSyncDevice(syncProfileNames[i] );
875 mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); 877 mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
876 if ( i == 0 ) { 878 if ( i == 0 ) {
877 syncSharp(); 879 syncSharp();
878 } else { 880 } else {
879 if ( temp->getIsLocalFileSync() ) { 881 if ( temp->getIsLocalFileSync() ) {
880 if ( syncWithFile( temp->getRemoteFileName( ), true ) ) 882 if ( syncWithFile( temp->getRemoteFileName( ), true ) )
881 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); 883 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName();
882 } else { 884 } else {
883 syncRemote( temp, false ); 885 syncRemote( temp, false );
884 886
885 } 887 }
886 } 888 }
887 timer.start(); 889 timer.start();
888 setCaption(i18n("Multiple sync in progress ... please wait!") ); 890 setCaption(i18n("Multiple sync in progress ... please wait!") );
889 while ( timer.elapsed () < 2000 ) { 891 while ( timer.elapsed () < 2000 ) {
890 qApp->processEvents(); 892 qApp->processEvents();
891#ifndef _WIN32_ 893#ifndef _WIN32_
892 sleep (1); 894 sleep (1);
893#endif 895#endif
894 } 896 }
895 897
896 } 898 }
897 899
898 } 900 }
899 delete temp; 901 delete temp;
900 return syncedProfiles; 902 return syncedProfiles;
901} 903}
902 904
903void MainWindow::multiSync( bool askforPrefs ) 905void MainWindow::multiSync( bool askforPrefs )
904{ 906{
905 if (mBlockSaveFlag) 907 if (mBlockSaveFlag)
906 return; 908 return;
907 mBlockSaveFlag = true; 909 mBlockSaveFlag = true;
908 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 910 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
909 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 911 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
910 question, 912 question,
911 i18n("Yes"), i18n("No"), 913 i18n("Yes"), i18n("No"),
912 0, 0 ) != 0 ) { 914 0, 0 ) != 0 ) {
913 mBlockSaveFlag = false; 915 mBlockSaveFlag = false;
914 setCaption(i18n("Aborted! Nothing synced!")); 916 setCaption(i18n("Aborted! Nothing synced!"));
915 return; 917 return;
916 } 918 }
917 mView->setSyncDevice(i18n("Multiple profiles") ); 919 mView->setSyncDevice(i18n("Multiple profiles") );
918 KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs; 920 KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs;
919 if ( askforPrefs ) { 921 if ( askforPrefs ) {
920 mView->edit_sync_options(); 922 mView->edit_sync_options();
921 KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs; 923 KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs;
922 } 924 }
923 setCaption(i18n("Multiple sync started.") ); 925 setCaption(i18n("Multiple sync started.") );
924 qApp->processEvents(); 926 qApp->processEvents();
925 int num = ringSync() ; 927 int num = ringSync() ;
926 if ( num > 1 ) 928 if ( num > 1 )
927 ringSync(); 929 ringSync();
928 mBlockSaveFlag = false; 930 mBlockSaveFlag = false;
929 if ( num ) 931 if ( num )
930 save(); 932 save();
931 if ( num ) 933 if ( num )
932 setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); 934 setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) );
933 else 935 else
934 setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 936 setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
935 return; 937 return;
936} 938}
937void MainWindow::slotSyncMenu( int action ) 939void MainWindow::slotSyncMenu( int action )
938{ 940{
939 //qDebug("syncaction %d ", action); 941 //qDebug("syncaction %d ", action);
940 if ( action == 0 ) { 942 if ( action == 0 ) {
941 943
942 confSync(); 944 confSync();
943 945
944 return; 946 return;
945 } 947 }
946 if ( action == 1 ) { 948 if ( action == 1 ) {
947 multiSync( true ); 949 multiSync( true );
948 return; 950 return;
949 } 951 }
950 952
951 if (mBlockSaveFlag) 953 if (mBlockSaveFlag)
952 return; 954 return;
953 mBlockSaveFlag = true; 955 mBlockSaveFlag = true;
954 mCurrentSyncProfile = action - 1000 ; 956 mCurrentSyncProfile = action - 1000 ;
955 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); 957 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] );
956 mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); 958 mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
957 KConfig *config = KOGlobals::config(); 959 KConfig *config = KOGlobals::config();
958 KSyncProfile* temp = new KSyncProfile (); 960 KSyncProfile* temp = new KSyncProfile ();
959 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 961 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
960 temp->readConfig(config); 962 temp->readConfig(config);
961 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 963 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
962 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); 964 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs();
963 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 965 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
964 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 966 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
965 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); 967 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync();
966 if ( action == 1000 ) { 968 if ( action == 1000 ) {
967 syncSharp(); 969 syncSharp();
968 970
969 } else if ( action == 1001 ) { 971 } else if ( action == 1001 ) {
970 syncLocalFile(); 972 syncLocalFile();
971 973
972 } else if ( action == 1002 ) { 974 } else if ( action == 1002 ) {
973 quickSyncLocalFile(); 975 quickSyncLocalFile();
974 976
975 } else if ( action >= 1003 ) { 977 } else if ( action >= 1003 ) {
976 if ( temp->getIsLocalFileSync() ) { 978 if ( temp->getIsLocalFileSync() ) {
977 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 979 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
978 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); 980 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName();
979 } else { 981 } else {
980 syncRemote( temp ); 982 syncRemote( temp );
981 983
982 } 984 }
983 } 985 }
984 delete temp; 986 delete temp;
985 mBlockSaveFlag = false; 987 mBlockSaveFlag = false;
986} 988}
987void MainWindow::setDefaultPreferences() 989void MainWindow::setDefaultPreferences()
988{ 990{
989 KOPrefs *p = KOPrefs::instance(); 991 KOPrefs *p = KOPrefs::instance();
990 992
991 p->mCompactDialogs = true; 993 p->mCompactDialogs = true;
992 p->mConfirm = true; 994 p->mConfirm = true;
993 // p->mEnableQuickTodo = false; 995 // p->mEnableQuickTodo = false;
994} 996}
995 997
996QString MainWindow::resourcePath() 998QString MainWindow::resourcePath()
997{ 999{
998 return KGlobal::iconLoader()->iconPath(); 1000 return KGlobal::iconLoader()->iconPath();
999} 1001}
1000 1002
1001void MainWindow::displayText( QString text ,QString cap ) 1003void MainWindow::displayText( QString text ,QString cap )
1002{ 1004{
1003 QDialog dia( this, "name", true ); ; 1005 QDialog dia( this, "name", true ); ;
1004 dia.setCaption( cap ); 1006 dia.setCaption( cap );
1005 QVBoxLayout* lay = new QVBoxLayout( &dia ); 1007 QVBoxLayout* lay = new QVBoxLayout( &dia );
1006 lay->setSpacing( 3 ); 1008 lay->setSpacing( 3 );
1007 lay->setMargin( 3 ); 1009 lay->setMargin( 3 );
1008 QTextBrowser tb ( &dia ); 1010 QTextBrowser tb ( &dia );
1009 lay->addWidget( &tb ); 1011 lay->addWidget( &tb );
1010 tb.setText( text ); 1012 tb.setText( text );
1011#ifdef DESKTOP_VERSION 1013#ifdef DESKTOP_VERSION
1012 dia.resize( 640, 480); 1014 dia.resize( 640, 480);
1013#else 1015#else
1014 dia.showMaximized(); 1016 dia.showMaximized();
1015#endif 1017#endif
1016 dia.exec(); 1018 dia.exec();
1017} 1019}
1018void MainWindow::displayFile( QString fn, QString cap ) 1020void MainWindow::displayFile( QString fn, QString cap )
1019{ 1021{
1020 QString fileName = resourcePath() + fn; 1022 QString fileName = resourcePath() + fn;
1021 QString text; 1023 QString text;
1022 QFile file( fileName ); 1024 QFile file( fileName );
1023 if (!file.open( IO_ReadOnly ) ) { 1025 if (!file.open( IO_ReadOnly ) ) {
1024 return ; 1026 return ;
1025 1027
1026 } 1028 }
1027 QTextStream ts( &file ); 1029 QTextStream ts( &file );
1028 text = ts.read(); 1030 text = ts.read();
1029 file.close(); 1031 file.close();
1030 displayText( text, cap); 1032 displayText( text, cap);
1031} 1033}
1032void MainWindow::features() 1034void MainWindow::features()
1033{ 1035{
1034 1036
1035 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); 1037 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") );
1036} 1038}
1037 1039
1038void MainWindow::usertrans() 1040void MainWindow::usertrans()
1039{ 1041{
1040 1042
1041 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); 1043 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") );
1042} 1044}
1043void MainWindow::synchowto() 1045void MainWindow::synchowto()
1044{ 1046{
1045 1047
1046 displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") ); 1048 displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") );
1047} 1049}
1048void MainWindow::faq() 1050void MainWindow::faq()
1049{ 1051{
1050 displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); 1052 displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") );
1051 1053
1052} 1054}
1053void MainWindow::whatsNew() 1055void MainWindow::whatsNew()
1054{ 1056{
1055 displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") ); 1057 displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") );
1056 1058
1057} 1059}
1058void MainWindow::about() 1060void MainWindow::about()
1059{ 1061{
1060 QString version; 1062 QString version;
1061#include <../version> 1063#include <../version>
1062 QMessageBox::about( this, i18n("About KOrganizer/Pi"), 1064 QMessageBox::about( this, i18n("About KOrganizer/Pi"),
1063 i18n("KOrganizer/Platform-independent\n") + 1065 i18n("KOrganizer/Platform-independent\n") +
1064 "(KO/Pi) " + version + " - " + 1066 "(KO/Pi) " + version + " - " +
1065 1067
1066#ifdef DESKTOP_VERSION 1068#ifdef DESKTOP_VERSION
1067 i18n("Desktop Edition\n") + 1069 i18n("Desktop Edition\n") +
1068#else 1070#else
1069 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + 1071 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") +
1070#endif 1072#endif
1071 i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") ); 1073 i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") );
1072} 1074}
1073void MainWindow::keyBindings() 1075void MainWindow::keyBindings()
1074{ 1076{
1075 QString cap = i18n("Key bindings KOrganizer/Pi"); 1077 QString cap = i18n("Key bindings KOrganizer/Pi");
1076 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + 1078 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") +
1077 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ 1079 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+
1078 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + 1080 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") +
1079 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ 1081 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+
1080 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ 1082 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+
1081 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ 1083 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+
1082 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ 1084 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+
1083 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ 1085 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+
1084 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ 1086 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+
1085 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ 1087 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+
1086 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ 1088 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+
1087 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ 1089 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+
1088 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ 1090 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+
1089 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ 1091 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+
1090 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ 1092 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+
1091 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ 1093 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+
1092 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ 1094 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+
1093 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ 1095 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+
1094 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ 1096 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+
1095 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ 1097 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+
1096 i18n("<p><h3>In agenda view:</h3></p>\n") + 1098 i18n("<p><h3>In agenda view:</h3></p>\n") +
1097 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ 1099 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+
1098 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ 1100 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+
1099 i18n("<p><h3>In todo view:</h3></p>\n") + 1101 i18n("<p><h3>In todo view:</h3></p>\n") +
1100 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ 1102 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+
1101 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1103 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1102 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ 1104 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+
1103 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ 1105 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+
1104 i18n("<p><h3>In list view:</h3></p>\n") + 1106 i18n("<p><h3>In list view:</h3></p>\n") +
1105 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1107 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1106 i18n("<p><b>return</b>: Select item+one step down</p>\n")+ 1108 i18n("<p><b>return</b>: Select item+one step down</p>\n")+
1107 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ 1109 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+
1108 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ 1110 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+
1109 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ 1111 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+
1110 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ 1112 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+
1111 i18n("<p><h3>In event/todo viewer:</h3></p>\n") + 1113 i18n("<p><h3>In event/todo viewer:</h3></p>\n") +
1112 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ 1114 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+
1113 i18n("<p><b>A</b>: Show agenda view.</p>\n")+ 1115 i18n("<p><b>A</b>: Show agenda view.</p>\n")+
1114 i18n("<p><b>E</b>: Edit item</p>\n") + 1116 i18n("<p><b>E</b>: Edit item</p>\n") +
1115 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + 1117 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") +
1116 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + 1118 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") +
1117 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ 1119 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+
1118 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ 1120 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+
1119 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ 1121 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+
1120 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ 1122 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+
1121 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ 1123 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+
1122 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + 1124 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") +
1123 i18n("<p><b>White</b>: Item readonly</p>\n"); 1125 i18n("<p><b>White</b>: Item readonly</p>\n");
1124 displayText( text, cap); 1126 displayText( text, cap);
1125 1127
1126} 1128}
1127void MainWindow::aboutAutoSaving() 1129void MainWindow::aboutAutoSaving()
1128{ 1130{
1129 QMessageBox* msg; 1131 QMessageBox* msg;
1130 msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), 1132 msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"),
1131 i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configureable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"), QMessageBox::NoIcon, 1133 i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configureable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"), QMessageBox::NoIcon,
1132 QMessageBox::Ok, 1134 QMessageBox::Ok,
1133 QMessageBox::NoButton, 1135 QMessageBox::NoButton,
1134 QMessageBox::NoButton); 1136 QMessageBox::NoButton);
1135 msg->exec(); 1137 msg->exec();
1136 delete msg; 1138 delete msg;
1137 1139
1138 1140
1139} 1141}
1140void MainWindow::aboutKnownBugs() 1142void MainWindow::aboutKnownBugs()
1141{ 1143{
1142 QMessageBox* msg; 1144 QMessageBox* msg;
1143 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), 1145 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"),
1144 i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ 1146 i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+
1145 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ 1147 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+
1146 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + 1148 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") +
1147 i18n("\nor report them in the bugtracker on\n") + 1149 i18n("\nor report them in the bugtracker on\n") +
1148 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), 1150 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"),
1149 QMessageBox::NoIcon, 1151 QMessageBox::NoIcon,
1150 QMessageBox::Ok, 1152 QMessageBox::Ok,
1151 QMessageBox::NoButton, 1153 QMessageBox::NoButton,
1152 QMessageBox::NoButton); 1154 QMessageBox::NoButton);
1153 msg->exec(); 1155 msg->exec();
1154 delete msg; 1156 delete msg;
1155 1157
1156} 1158}
1157 1159
1158QString MainWindow::defaultFileName() 1160QString MainWindow::defaultFileName()
1159{ 1161{
1160 return locateLocal( "data", "korganizer/mycalendar.ics" ); 1162 return locateLocal( "data", "korganizer/mycalendar.ics" );
1161} 1163}
1162 1164
1163void MainWindow::processIncidenceSelection( Incidence *incidence ) 1165void MainWindow::processIncidenceSelection( Incidence *incidence )
1164{ 1166{
1165 if ( !incidence ) { 1167 if ( !incidence ) {
1166 enableIncidenceActions( false ); 1168 enableIncidenceActions( false );
1167 1169
1168 mNewSubTodoAction->setEnabled( false ); 1170 mNewSubTodoAction->setEnabled( false );
1169 setCaptionToDates(); 1171 setCaptionToDates();
1170 return; 1172 return;
1171 1173
1172 } 1174 }
1173 1175
1174 //KGlobal::locale()->formatDateTime(nextA, true); 1176 //KGlobal::locale()->formatDateTime(nextA, true);
1175 QString startString = ""; 1177 QString startString = "";
1176 if ( incidence->type() != "Todo" ) { 1178 if ( incidence->type() != "Todo" ) {
1177 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { 1179 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) {
1178 if ( incidence->doesFloat() ) { 1180 if ( incidence->doesFloat() ) {
1179 startString += ": "+incidence->dtStartDateStr( true ); 1181 startString += ": "+incidence->dtStartDateStr( true );
1180 startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); 1182 startString += " --- "+((Event*)incidence)->dtEndDateStr( true );
1181 1183
1182 } else { 1184 } else {
1183 startString = ": "+incidence->dtStartStr(true); 1185 startString = ": "+incidence->dtStartStr(true);
1184 startString += " --- "+((Event*)incidence)->dtEndStr(true); 1186 startString += " --- "+((Event*)incidence)->dtEndStr(true);
1185 1187
1186 } 1188 }
1187 1189
1188 } else { 1190 } else {
1189 if ( incidence->dtStart().time() != incidence->dtEnd().time() ) 1191 if ( incidence->dtStart().time() != incidence->dtEnd().time() )
1190 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ 1192 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+
1191 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); 1193 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time());
1192 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); 1194 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true);
1193 } 1195 }
1194 1196
1195 } 1197 }
1196 else 1198 else
1197 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); 1199 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed");
1198 if ( !incidence->location().isEmpty() ) 1200 if ( !incidence->location().isEmpty() )
1199 startString += " (" +incidence->location()+")"; 1201 startString += " (" +incidence->location()+")";
1200 setCaption( incidence->summary()+startString); 1202 setCaption( incidence->summary()+startString);
1201 1203
1202 enableIncidenceActions( true ); 1204 enableIncidenceActions( true );
1203 1205
1204 if ( incidence->type() == "Event" ) { 1206 if ( incidence->type() == "Event" ) {
1205 mShowAction->setText( i18n("Show Event...") ); 1207 mShowAction->setText( i18n("Show Event...") );
1206 mEditAction->setText( i18n("Edit Event...") ); 1208 mEditAction->setText( i18n("Edit Event...") );
1207 mDeleteAction->setText( i18n("Delete Event...") ); 1209 mDeleteAction->setText( i18n("Delete Event...") );
1208 1210
1209 mNewSubTodoAction->setEnabled( false ); 1211 mNewSubTodoAction->setEnabled( false );
1210 } else if ( incidence->type() == "Todo" ) { 1212 } else if ( incidence->type() == "Todo" ) {
1211 mShowAction->setText( i18n("Show Todo...") ); 1213 mShowAction->setText( i18n("Show Todo...") );
1212 mEditAction->setText( i18n("Edit Todo...") ); 1214 mEditAction->setText( i18n("Edit Todo...") );
1213 mDeleteAction->setText( i18n("Delete Todo...") ); 1215 mDeleteAction->setText( i18n("Delete Todo...") );
1214 1216
1215 mNewSubTodoAction->setEnabled( true ); 1217 mNewSubTodoAction->setEnabled( true );
1216 } else { 1218 } else {
1217 mShowAction->setText( i18n("Show...") ); 1219 mShowAction->setText( i18n("Show...") );
1218 mShowAction->setText( i18n("Edit...") ); 1220 mShowAction->setText( i18n("Edit...") );
1219 mShowAction->setText( i18n("Delete...") ); 1221 mShowAction->setText( i18n("Delete...") );
1220 1222
1221 mNewSubTodoAction->setEnabled( false ); 1223 mNewSubTodoAction->setEnabled( false );
1222 } 1224 }
1223} 1225}
1224 1226
1225void MainWindow::enableIncidenceActions( bool enabled ) 1227void MainWindow::enableIncidenceActions( bool enabled )
1226{ 1228{
1227 mShowAction->setEnabled( enabled ); 1229 mShowAction->setEnabled( enabled );
1228 mEditAction->setEnabled( enabled ); 1230 mEditAction->setEnabled( enabled );
1229 mDeleteAction->setEnabled( enabled ); 1231 mDeleteAction->setEnabled( enabled );
1230} 1232}
1231 1233
1232void MainWindow::importOL() 1234void MainWindow::importOL()
1233{ 1235{
1234#ifdef _WIN32_ 1236#ifdef _WIN32_
1235 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); 1237 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this );
1236 id->exec(); 1238 id->exec();
1237 delete id; 1239 delete id;
1238 mView->updateView(); 1240 mView->updateView();
1239#endif 1241#endif
1240} 1242}
1241void MainWindow::importBday() 1243void MainWindow::importBday()
1242{ 1244{
1243 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1245 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1244 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), 1246 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"),
1245 i18n("Import!"), i18n("Cancel"), 0, 1247 i18n("Import!"), i18n("Cancel"), 0,
1246 0, 1 ); 1248 0, 1 );
1247 if ( result == 0 ) { 1249 if ( result == 0 ) {
1248 mView->importBday(); 1250 mView->importBday();
1249 1251
1250 } 1252 }
1251 1253
1252 1254
1253} 1255}
1254void MainWindow::importQtopia() 1256void MainWindow::importQtopia()
1255{ 1257{
1256#ifndef DESKTOP_VERSION 1258#ifndef DESKTOP_VERSION
1257 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1259 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1258 i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"), 1260 i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"),
1259 i18n("Import!"), i18n("Cancel"), 0, 1261 i18n("Import!"), i18n("Cancel"), 0,
1260 0, 1 ); 1262 0, 1 );
1261 if ( result == 0 ) { 1263 if ( result == 0 ) {
1262 QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); 1264 QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
1263 QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); 1265 QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
1264 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; 1266 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
1265 mView->importQtopia( categories, datebook, todolist ); 1267 mView->importQtopia( categories, datebook, todolist );
1266 } 1268 }
1267#else 1269#else
1268 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1270 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1269 i18n("Not supported \non desktop!\n"), 1271 i18n("Not supported \non desktop!\n"),
1270 i18n("Ok"), i18n("Cancel"), 0, 1272 i18n("Ok"), i18n("Cancel"), 0,
1271 0, 1 ); 1273 0, 1 );
1272 1274
1273#endif 1275#endif
1274} 1276}
1275 1277
1276void MainWindow::saveOnClose() 1278void MainWindow::saveOnClose()
1277{ 1279{
1278 KOPrefs *p = KOPrefs::instance(); 1280 KOPrefs *p = KOPrefs::instance();
1279 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); 1281 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
1280 p->mToolBarUp = iconToolBar->x() > width()/2 || 1282 p->mToolBarUp = iconToolBar->x() > width()/2 ||
1281 iconToolBar->y() > height()/2; 1283 iconToolBar->y() > height()/2;
1282 mView->writeSettings(); 1284 mView->writeSettings();
1283 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) 1285 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName()))
1284 save(); 1286 save();
1285} 1287}
1286void MainWindow::slotModifiedChanged( bool changed ) 1288void MainWindow::slotModifiedChanged( bool changed )
1287{ 1289{
1288 if ( mBlockAtStartup ) 1290 if ( mBlockAtStartup )
1289 return; 1291 return;
1290 int msec; 1292 int msec;
1291 // we store the changes after 1 minute, 1293 // we store the changes after 1 minute,
1292 // and for safety reasons after 10 minutes again 1294 // and for safety reasons after 10 minutes again
1293 if ( !mBlockSaveFlag ) 1295 if ( !mBlockSaveFlag )
1294 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1296 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1295 else 1297 else
1296 msec = 1000 * 600; 1298 msec = 1000 * 600;
1297 mSaveTimer.start( msec, true ); // 1 minute 1299 mSaveTimer.start( msec, true ); // 1 minute
1298 qDebug("KO: Saving File in %d secs!", msec/1000); 1300 qDebug("KO: Saving File in %d secs!", msec/1000);
1299 mCalendarModifiedFlag = true; 1301 mCalendarModifiedFlag = true;
1300} 1302}
1301#include <qfileinfo.h> 1303#include <qfileinfo.h>
1302void MainWindow::save() 1304void MainWindow::save()
1303{ 1305{
1304 if ( mBlockSaveFlag ) 1306 if ( mBlockSaveFlag )
1305 return; 1307 return;
1306 bool store = mBlockSaveFlag; 1308 bool store = mBlockSaveFlag;
1307 mBlockSaveFlag = true; 1309 mBlockSaveFlag = true;
1308 if ( mView->checkFileVersion( defaultFileName()) ) { 1310 if ( mView->checkFileVersion( defaultFileName()) ) {
1309 1311
1310 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1312 QTime neededSaveTime = QDateTime::currentDateTime().time();
1311 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1313 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1312 qDebug("KO: Start saving data to file!"); 1314 qDebug("KO: Start saving data to file!");
1313 mView->saveCalendar( defaultFileName() ); 1315 mView->saveCalendar( defaultFileName() );
1314 1316
1315 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 1317 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1316 mView->setLoadedFileVersion(QDateTime::currentDateTime()); 1318 mView->setLoadedFileVersion(QDateTime::currentDateTime());
1317 qDebug("KO: Needed %d ms for saving.",msNeeded ); 1319 qDebug("KO: Needed %d ms for saving.",msNeeded );
1318 QString savemes; 1320 QString savemes;
1319 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 1321 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
1320 setCaption(savemes); 1322 setCaption(savemes);
1321 } else 1323 } else
1322 setCaption(i18n("Saving cancelled!")); 1324 setCaption(i18n("Saving cancelled!"));
1323 mCalendarModifiedFlag = false; 1325 mCalendarModifiedFlag = false;
1324 mBlockSaveFlag = store; 1326 mBlockSaveFlag = store;
1325} 1327}
1326 1328
1327void MainWindow::keyReleaseEvent ( QKeyEvent * e) 1329void MainWindow::keyReleaseEvent ( QKeyEvent * e)
1328{ 1330{
1329 if ( !e->isAutoRepeat() ) { 1331 if ( !e->isAutoRepeat() ) {
1330 mFlagKeyPressed = false; 1332 mFlagKeyPressed = false;
1331 } 1333 }
1332} 1334}
1333void MainWindow::keyPressEvent ( QKeyEvent * e ) 1335void MainWindow::keyPressEvent ( QKeyEvent * e )
1334{ 1336{
1335 qApp->processEvents(); 1337 qApp->processEvents();
1336 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 1338 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1337 e->ignore(); 1339 e->ignore();
1338 // qDebug(" ignore %d",e->isAutoRepeat() ); 1340 // qDebug(" ignore %d",e->isAutoRepeat() );
1339 return; 1341 return;
1340 } 1342 }
1341 if (! e->isAutoRepeat() ) 1343 if (! e->isAutoRepeat() )
1342 mFlagKeyPressed = true; 1344 mFlagKeyPressed = true;
1343 KOPrefs *p = KOPrefs::instance(); 1345 KOPrefs *p = KOPrefs::instance();
1344 bool showSelectedDates = false; 1346 bool showSelectedDates = false;
1345 int size; 1347 int size;
1346 int pro = 0; 1348 int pro = 0;
1347 //qDebug("MainWindow::keyPressEvent "); 1349 //qDebug("MainWindow::keyPressEvent ");
1348 switch ( e->key() ) { 1350 switch ( e->key() ) {
1349 case Qt::Key_Right: 1351 case Qt::Key_Right:
1350 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1352 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1351 mView->goNextMonth(); 1353 mView->goNextMonth();
1352 else 1354 else
1353 mView->goNext(); 1355 mView->goNext();
1354 showSelectedDates = true; 1356 showSelectedDates = true;
1355 break; 1357 break;
1356 case Qt::Key_Left: 1358 case Qt::Key_Left:
1357 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1359 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1358 mView->goPreviousMonth(); 1360 mView->goPreviousMonth();
1359 else 1361 else
1360 mView->goPrevious(); 1362 mView->goPrevious();
1361 showSelectedDates = true; 1363 showSelectedDates = true;
1362 break; 1364 break;
1363 case Qt::Key_Down: 1365 case Qt::Key_Down:
1364 mView->viewManager()->agendaView()->scrollOneHourDown(); 1366 mView->viewManager()->agendaView()->scrollOneHourDown();
1365 break; 1367 break;
1366 case Qt::Key_Up: 1368 case Qt::Key_Up:
1367 mView->viewManager()->agendaView()->scrollOneHourUp(); 1369 mView->viewManager()->agendaView()->scrollOneHourUp();
1368 break; 1370 break;
1369 case Qt::Key_I: 1371 case Qt::Key_I:
1370 mView->showIncidence(); 1372 mView->showIncidence();
1371 break; 1373 break;
1372 case Qt::Key_Delete: 1374 case Qt::Key_Delete:
1373 case Qt::Key_Backspace: 1375 case Qt::Key_Backspace:
1374 mView->deleteIncidence(); 1376 mView->deleteIncidence();
1375 break; 1377 break;
1376 case Qt::Key_D: 1378 case Qt::Key_D:
1377 mView->viewManager()->showDayView(); 1379 mView->viewManager()->showDayView();
1378 showSelectedDates = true; 1380 showSelectedDates = true;
1379 break; 1381 break;
1380 case Qt::Key_O: 1382 case Qt::Key_O:
1381 mView->toggleFilerEnabled( ); 1383 mView->toggleFilerEnabled( );
1382 break; 1384 break;
1383 case Qt::Key_0: 1385 case Qt::Key_0:
1384 case Qt::Key_1: 1386 case Qt::Key_1:
1385 case Qt::Key_2: 1387 case Qt::Key_2:
1386 case Qt::Key_3: 1388 case Qt::Key_3:
1387 case Qt::Key_4: 1389 case Qt::Key_4:
1388 case Qt::Key_5: 1390 case Qt::Key_5:
1389 case Qt::Key_6: 1391 case Qt::Key_6:
1390 case Qt::Key_7: 1392 case Qt::Key_7:
1391 case Qt::Key_8: 1393 case Qt::Key_8:
1392 case Qt::Key_9: 1394 case Qt::Key_9:
1393 pro = e->key()-48; 1395 pro = e->key()-48;
1394 if ( pro == 0 ) 1396 if ( pro == 0 )
1395 pro = 10; 1397 pro = 10;
1396 if ( e->state() == Qt::ControlButton) 1398 if ( e->state() == Qt::ControlButton)
1397 pro += 10; 1399 pro += 10;
1398 break; 1400 break;
1399 case Qt::Key_M: 1401 case Qt::Key_M:
1400 mView->viewManager()->showMonthView(); 1402 mView->viewManager()->showMonthView();
1401 showSelectedDates = true; 1403 showSelectedDates = true;
1402 break; 1404 break;
1403 case Qt::Key_Insert: 1405 case Qt::Key_Insert:
1404 mView->newEvent(); 1406 mView->newEvent();
1405 break; 1407 break;
1406 case Qt::Key_S : 1408 case Qt::Key_S :
1407 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1409 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1408 mView->newSubTodo(); 1410 mView->newSubTodo();
1409 else 1411 else
1410 mView->dialogManager()->showSearchDialog(); 1412 mView->dialogManager()->showSearchDialog();
1411 break; 1413 break;
1412 case Qt::Key_Y : 1414 case Qt::Key_Y :
1413 case Qt::Key_Z : 1415 case Qt::Key_Z :
1414 mView->viewManager()->showWorkWeekView(); 1416 mView->viewManager()->showWorkWeekView();
1415 showSelectedDates = true; 1417 showSelectedDates = true;
1416 break; 1418 break;
1417 case Qt::Key_U : 1419 case Qt::Key_U :
1418 mView->viewManager()->showWeekView(); 1420 mView->viewManager()->showWeekView();
1419 showSelectedDates = true; 1421 showSelectedDates = true;
1420 break; 1422 break;
1421 case Qt::Key_H : 1423 case Qt::Key_H :
1422 keyBindings(); 1424 keyBindings();
1423 break; 1425 break;
1424 case Qt::Key_W: 1426 case Qt::Key_W:
1425 mView->viewManager()->showWhatsNextView(); 1427 mView->viewManager()->showWhatsNextView();
1426 break; 1428 break;
1427 case Qt::Key_L: 1429 case Qt::Key_L:
1428 mView->viewManager()->showListView(); 1430 mView->viewManager()->showListView();
1429 break; 1431 break;
1430 case Qt::Key_N: 1432 case Qt::Key_N:
1431 mView->viewManager()->showNextXView(); 1433 mView->viewManager()->showNextXView();
1432 showSelectedDates = true; 1434 showSelectedDates = true;
1433 break; 1435 break;
1434 case Qt::Key_V: 1436 case Qt::Key_V:
1435 mView->viewManager()->showTodoView(); 1437 mView->viewManager()->showTodoView();
1436 break; 1438 break;
1437 case Qt::Key_C: 1439 case Qt::Key_C:
1438 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); 1440 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() );
1439 break; 1441 break;
1440 case Qt::Key_P: 1442 case Qt::Key_P:
1441 mView->showDatePicker( ); 1443 mView->showDatePicker( );
1442 break; 1444 break;
1443 case Qt::Key_F: 1445 case Qt::Key_F:
1444 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1446 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1445 mView->editFilters(); 1447 mView->editFilters();
1446 else 1448 else
1447 mView->toggleFilter(); 1449 mView->toggleFilter();
1448 break; 1450 break;
1449 case Qt::Key_X: 1451 case Qt::Key_X:
1450 mView->toggleDateNavigatorWidget(); 1452 mView->toggleDateNavigatorWidget();
1451 break; 1453 break;
1452 case Qt::Key_Space: 1454 case Qt::Key_Space:
1453 mView->toggleExpand(); 1455 mView->toggleExpand();
1454 break; 1456 break;
1455 case Qt::Key_A: 1457 case Qt::Key_A:
1456 mView->toggleAllDaySize(); 1458 mView->toggleAllDaySize();
1457 break; 1459 break;
1458 case Qt::Key_T: 1460 case Qt::Key_T:
1459 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1461 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1460 mView->newTodo(); 1462 mView->newTodo();
1461 else { 1463 else {
1462 mView->goToday(); 1464 mView->goToday();
1463 showSelectedDates = true; 1465 showSelectedDates = true;
1464 } 1466 }
1465 break; 1467 break;
1466 case Qt::Key_J: 1468 case Qt::Key_J:
1467 mView->viewManager()->showJournalView(); 1469 mView->viewManager()->showJournalView();
1468 break; 1470 break;
1469 case Qt::Key_B: 1471 case Qt::Key_B:
1470 mView->editIncidenceDescription();; 1472 mView->editIncidenceDescription();;
1471 break; 1473 break;
1472 // case Qt::Key_Return: 1474 // case Qt::Key_Return:
1473 case Qt::Key_E: 1475 case Qt::Key_E:
1474 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1476 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1475 mView->newEvent(); 1477 mView->newEvent();
1476 else 1478 else
1477 mView->editIncidence(); 1479 mView->editIncidence();
1478 break; 1480 break;
1479 case Qt::Key_Plus: 1481 case Qt::Key_Plus:
1480 size = p->mHourSize +2; 1482 size = p->mHourSize +2;
1481 if ( size <= 18 ) 1483 if ( size <= 18 )
1482 configureAgenda( size ); 1484 configureAgenda( size );
1483 break; 1485 break;
1484 case Qt::Key_Minus: 1486 case Qt::Key_Minus:
1485 size = p->mHourSize - 2; 1487 size = p->mHourSize - 2;
1486 if ( size >= 4 ) 1488 if ( size >= 4 )
1487 configureAgenda( size ); 1489 configureAgenda( size );
1488 break; 1490 break;
1489 1491
1490 1492
1491 default: 1493 default:
1492 e->ignore(); 1494 e->ignore();
1493 } 1495 }
1494 if ( pro > 0 ) { 1496 if ( pro > 0 ) {
1495 mView->selectFilter( pro-1 ); 1497 mView->selectFilter( pro-1 );
1496 } 1498 }
1497 if ( showSelectedDates ) { 1499 if ( showSelectedDates ) {
1498 ;// setCaptionToDates(); 1500 ;// setCaptionToDates();
1499 } 1501 }
1500 1502
1501} 1503}
1502 1504
1503void MainWindow::configureToolBar( int item ) 1505void MainWindow::configureToolBar( int item )
1504{ 1506{
1505 1507
1506 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); 1508 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) );
1507 KOPrefs *p = KOPrefs::instance(); 1509 KOPrefs *p = KOPrefs::instance();
1508 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); 1510 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 );
1509 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); 1511 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 );
1510 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); 1512 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 );
1511 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); 1513 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 );
1512 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); 1514 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 );
1513 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); 1515 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 );
1514 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); 1516 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 );
1515 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); 1517 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 );
1516 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); 1518 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 );
1517 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); 1519 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 );
1518 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); 1520 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 );
1519 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); 1521 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 );
1520 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); 1522 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 );
1521 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); 1523 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 );
1522 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); 1524 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 );
1523 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); 1525 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 );
1524 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); 1526 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 );
1525 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); 1527 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 );
1526 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); 1528 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 );
1527 // initActions(); 1529 // initActions();
1528} 1530}
1529 1531
1530void MainWindow::setCaptionToDates() 1532void MainWindow::setCaptionToDates()
1531{ 1533{
1532 QString selDates; 1534 QString selDates;
1533 selDates = KGlobal::locale()->formatDate(mView->startDate(), true); 1535 selDates = KGlobal::locale()->formatDate(mView->startDate(), true);
1534 if (mView->startDate() < mView->endDate() ) 1536 if (mView->startDate() < mView->endDate() )
1535 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); 1537 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true);
1536 setCaption( i18n("Dates: ") + selDates ); 1538 setCaption( i18n("Dates: ") + selDates );
1537 1539
1538} 1540}
1539// parameter item == 0: reinit 1541// parameter item == 0: reinit
1540void MainWindow::configureAgenda( int item ) 1542void MainWindow::configureAgenda( int item )
1541{ 1543{
1542 1544
1543 KOPrefs *p = KOPrefs::instance(); 1545 KOPrefs *p = KOPrefs::instance();
1544 1546
1545 int i; 1547 int i;
1546 if ( item == 1 ) { 1548 if ( item == 1 ) {
1547 mView->toggleAllDaySize(); 1549 mView->toggleAllDaySize();
1548 return; 1550 return;
1549 } 1551 }
1550 // do not allow 4 for widgets higher than 480 1552 // do not allow 4 for widgets higher than 480
1551 // if ( QApplication::desktop()->height() > 480 ) { 1553 // if ( QApplication::desktop()->height() > 480 ) {
1552// if ( item == 4 ) 1554// if ( item == 4 )
1553// item = 6; 1555// item = 6;
1554// } 1556// }
1555 for ( i = 4; i <= 18; i= i+2 ) 1557 for ( i = 4; i <= 18; i= i+2 )
1556 configureAgendaMenu->setItemChecked( i, false ); 1558 configureAgendaMenu->setItemChecked( i, false );
1557 configureAgendaMenu->setItemChecked( item, true ); 1559 configureAgendaMenu->setItemChecked( item, true );
1558 if ( p->mHourSize == item ) 1560 if ( p->mHourSize == item )
1559 return; 1561 return;
1560 p->mHourSize=item; 1562 p->mHourSize=item;
1561 mView->viewManager()->agendaView()->updateConfig(); 1563 mView->viewManager()->agendaView()->updateConfig();
1562} 1564}
1563 1565
1564void MainWindow::saveCalendar() 1566void MainWindow::saveCalendar()
1565{ 1567{
1566 QString fn = KOPrefs::instance()->mLastSaveFile; 1568 QString fn = KOPrefs::instance()->mLastSaveFile;
1567 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); 1569 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this );
1568 1570
1569 if ( fn == "" ) 1571 if ( fn == "" )
1570 return; 1572 return;
1571 QFileInfo info; 1573 QFileInfo info;
1572 info.setFile( fn ); 1574 info.setFile( fn );
1573 QString mes; 1575 QString mes;
1574 bool createbup = true; 1576 bool createbup = true;
1575 if ( info. exists() ) { 1577 if ( info. exists() ) {
1576 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; 1578 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ;
1577 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1579 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1578 i18n("Overwrite!"), i18n("Cancel"), 0, 1580 i18n("Overwrite!"), i18n("Cancel"), 0,
1579 0, 1 ); 1581 0, 1 );
1580 if ( result != 0 ) { 1582 if ( result != 0 ) {
1581 createbup = false; 1583 createbup = false;
1582 } 1584 }
1583 } 1585 }
1584 if ( createbup ) { 1586 if ( createbup ) {
1585 mView->saveCalendar( fn ); 1587 mView->saveCalendar( fn );
1586 mes = i18n("KO/Pi:Saved %1").arg(fn); 1588 mes = i18n("KO/Pi:Saved %1").arg(fn);
1587 KOPrefs::instance()->mLastSaveFile = fn; 1589 KOPrefs::instance()->mLastSaveFile = fn;
1588 setCaption(mes); 1590 setCaption(mes);
1589 } 1591 }
1590} 1592}
1591void MainWindow::loadCalendar() 1593void MainWindow::loadCalendar()
1592{ 1594{
1593 1595
1594 QString fn = KOPrefs::instance()->mLastLoadFile; 1596 QString fn = KOPrefs::instance()->mLastLoadFile;
1595 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); 1597 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this );
1596 1598
1597 if ( fn == "" ) 1599 if ( fn == "" )
1598 return; 1600 return;
1599 QFileInfo info; 1601 QFileInfo info;
1600 info.setFile( fn ); 1602 info.setFile( fn );
1601 QString mess; 1603 QString mess;
1602 bool loadbup = true; 1604 bool loadbup = true;
1603 if ( info. exists() ) { 1605 if ( info. exists() ) {
1604 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1606 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));