summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-05 08:32:25 (UTC)
committer zautrix <zautrix>2004-10-05 08:32:25 (UTC)
commit701cd3c2b2b713c12797f5bda24c35d3a7889539 (patch) (unidiff)
tree56d07b2f4a050fbc839ab6435b2266e8a52a08ba
parentad859d26b813101adab963f50e694961702561d9 (diff)
downloadkdepimpi-701cd3c2b2b713c12797f5bda24c35d3a7889539.zip
kdepimpi-701cd3c2b2b713c12797f5bda24c35d3a7889539.tar.gz
kdepimpi-701cd3c2b2b713c12797f5bda24c35d3a7889539.tar.bz2
warning dialog fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp17
-rw-r--r--korganizer/calendarview.h1
-rw-r--r--korganizer/mainwindow.cpp4
3 files changed, 17 insertions, 5 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index fecc7e2..687943e 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,3635 +1,3648 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Requires the Qt and KDE widget libraries, available at no cost at 4 Requires the Qt and KDE widget libraries, available at no cost at
5 http://www.troll.no and http://www.kde.org respectively 5 http://www.troll.no and http://www.kde.org respectively
6 6
7 Copyright (c) 1997, 1998, 1999 7 Copyright (c) 1997, 1998, 1999
8 Preston Brown (preston.brown@yale.edu) 8 Preston Brown (preston.brown@yale.edu)
9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) 9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl)
10 Ian Dawes (iadawes@globalserve.net) 10 Ian Dawes (iadawes@globalserve.net)
11 Laszlo Boloni (boloni@cs.purdue.edu) 11 Laszlo Boloni (boloni@cs.purdue.edu)
12 12
13 Copyright (c) 2000, 2001, 2002 13 Copyright (c) 2000, 2001, 2002
14 Cornelius Schumacher <schumacher@kde.org> 14 Cornelius Schumacher <schumacher@kde.org>
15 15
16 This program is free software; you can redistribute it and/or modify 16 This program is free software; you can redistribute it and/or modify
17 it under the terms of the GNU General Public License as published by 17 it under the terms of the GNU General Public License as published by
18 the Free Software Foundation; either version 2 of the License, or 18 the Free Software Foundation; either version 2 of the License, or
19 (at your option) any later version. 19 (at your option) any later version.
20 20
21 This program is distributed in the hope that it will be useful, 21 This program is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of 22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
24 GNU General Public License for more details. 24 GNU General Public License for more details.
25 25
26 You should have received a copy of the GNU General Public License 26 You should have received a copy of the GNU General Public License
27 along with this program; if not, write to the Free Software 27 along with this program; if not, write to the Free Software
28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29*/ 29*/
30 30
31#include <stdlib.h> 31#include <stdlib.h>
32 32
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qradiobutton.h> 34#include <qradiobutton.h>
35#include <qbuttongroup.h> 35#include <qbuttongroup.h>
36#include <qlayout.h> 36#include <qlayout.h>
37#include <qclipboard.h> 37#include <qclipboard.h>
38#include <qcursor.h> 38#include <qcursor.h>
39#include <qmessagebox.h> 39#include <qmessagebox.h>
40#include <qprogressbar.h> 40#include <qprogressbar.h>
41#include <qmultilineedit.h> 41#include <qmultilineedit.h>
42#include <qtimer.h> 42#include <qtimer.h>
43#include <qwidgetstack.h> 43#include <qwidgetstack.h>
44#include <qptrlist.h> 44#include <qptrlist.h>
45#include <qregexp.h> 45#include <qregexp.h>
46#include <qgroupbox.h> 46#include <qgroupbox.h>
47#include <qfile.h> 47#include <qfile.h>
48#include <qdir.h> 48#include <qdir.h>
49#ifndef KORG_NOSPLITTER 49#ifndef KORG_NOSPLITTER
50#include <qsplitter.h> 50#include <qsplitter.h>
51#endif 51#endif
52 52
53#include <kglobal.h> 53#include <kglobal.h>
54#include <kdebug.h> 54#include <kdebug.h>
55#include <kstandarddirs.h> 55#include <kstandarddirs.h>
56#include <kfiledialog.h> 56#include <kfiledialog.h>
57#include <kmessagebox.h> 57#include <kmessagebox.h>
58#include <knotifyclient.h> 58#include <knotifyclient.h>
59#include <kconfig.h> 59#include <kconfig.h>
60 60
61#include <libkdepim/ksyncprefsdialog.h> 61#include <libkdepim/ksyncprefsdialog.h>
62#include <krun.h> 62#include <krun.h>
63#include <kdirwatch.h> 63#include <kdirwatch.h>
64#include <libkdepim/kdatepicker.h> 64#include <libkdepim/kdatepicker.h>
65#include <libkdepim/ksyncprofile.h> 65#include <libkdepim/ksyncprofile.h>
66#include <libkdepim/kpimglobalprefs.h> 66#include <libkdepim/kpimglobalprefs.h>
67 67
68#include <libkcal/vcaldrag.h> 68#include <libkcal/vcaldrag.h>
69#include <libkcal/icaldrag.h> 69#include <libkcal/icaldrag.h>
70#include <libkcal/icalformat.h> 70#include <libkcal/icalformat.h>
71#include <libkcal/vcalformat.h> 71#include <libkcal/vcalformat.h>
72#include <libkcal/scheduler.h> 72#include <libkcal/scheduler.h>
73#include <libkcal/calendarlocal.h> 73#include <libkcal/calendarlocal.h>
74#include <libkcal/journal.h> 74#include <libkcal/journal.h>
75#include <libkcal/calfilter.h> 75#include <libkcal/calfilter.h>
76#include <libkcal/attendee.h> 76#include <libkcal/attendee.h>
77#include <libkcal/dndfactory.h> 77#include <libkcal/dndfactory.h>
78#include <libkcal/freebusy.h> 78#include <libkcal/freebusy.h>
79#include <libkcal/filestorage.h> 79#include <libkcal/filestorage.h>
80#include <libkcal/calendarresources.h> 80#include <libkcal/calendarresources.h>
81#include <libkcal/qtopiaformat.h> 81#include <libkcal/qtopiaformat.h>
82#include "../kalarmd/alarmdialog.h" 82#include "../kalarmd/alarmdialog.h"
83 83
84#ifndef DESKTOP_VERSION 84#ifndef DESKTOP_VERSION
85#include <libkcal/sharpformat.h> 85#include <libkcal/sharpformat.h>
86#endif 86#endif
87#include <libkcal/phoneformat.h> 87#include <libkcal/phoneformat.h>
88#ifndef KORG_NOMAIL 88#ifndef KORG_NOMAIL
89#include "komailclient.h" 89#include "komailclient.h"
90#endif 90#endif
91#ifndef KORG_NOPRINTER 91#ifndef KORG_NOPRINTER
92#include "calprinter.h" 92#include "calprinter.h"
93#endif 93#endif
94#ifndef KORG_NOPLUGINS 94#ifndef KORG_NOPLUGINS
95#include "kocore.h" 95#include "kocore.h"
96#endif 96#endif
97#include "koeventeditor.h" 97#include "koeventeditor.h"
98#include "kotodoeditor.h" 98#include "kotodoeditor.h"
99#include "koprefs.h" 99#include "koprefs.h"
100#include "koeventviewerdialog.h" 100#include "koeventviewerdialog.h"
101#include "publishdialog.h" 101#include "publishdialog.h"
102#include "kofilterview.h" 102#include "kofilterview.h"
103#include "koglobals.h" 103#include "koglobals.h"
104#include "koviewmanager.h" 104#include "koviewmanager.h"
105#include "koagendaview.h" 105#include "koagendaview.h"
106#include "kodialogmanager.h" 106#include "kodialogmanager.h"
107#include "outgoingdialog.h" 107#include "outgoingdialog.h"
108#include "incomingdialog.h" 108#include "incomingdialog.h"
109#include "statusdialog.h" 109#include "statusdialog.h"
110#include "kdatenavigator.h" 110#include "kdatenavigator.h"
111#include "kotodoview.h" 111#include "kotodoview.h"
112#include "datenavigator.h" 112#include "datenavigator.h"
113#include "resourceview.h" 113#include "resourceview.h"
114#include "navigatorbar.h" 114#include "navigatorbar.h"
115#include "searchdialog.h" 115#include "searchdialog.h"
116#include "mainwindow.h" 116#include "mainwindow.h"
117 117
118#include "calendarview.h" 118#include "calendarview.h"
119#ifndef DESKTOP_VERSION 119#ifndef DESKTOP_VERSION
120#include <qtopia/alarmserver.h> 120#include <qtopia/alarmserver.h>
121#endif 121#endif
122#ifndef _WIN32_ 122#ifndef _WIN32_
123#include <stdlib.h> 123#include <stdlib.h>
124#include <stdio.h> 124#include <stdio.h>
125#include <unistd.h> 125#include <unistd.h>
126#else 126#else
127#include <qprocess.h> 127#include <qprocess.h>
128#endif 128#endif
129using namespace KOrg; 129using namespace KOrg;
130using namespace KCal; 130using namespace KCal;
131extern int globalFlagBlockAgenda; 131extern int globalFlagBlockAgenda;
132extern int globalFlagBlockStartup; 132extern int globalFlagBlockStartup;
133 133
134 134
135 135
136class KOBeamPrefs : public QDialog 136class KOBeamPrefs : public QDialog
137{ 137{
138 public: 138 public:
139 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : 139 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) :
140 QDialog( parent, name, true ) 140 QDialog( parent, name, true )
141 { 141 {
142 setCaption( i18n("Beam Options") ); 142 setCaption( i18n("Beam Options") );
143 QVBoxLayout* lay = new QVBoxLayout( this ); 143 QVBoxLayout* lay = new QVBoxLayout( this );
144 lay->setSpacing( 3 ); 144 lay->setSpacing( 3 );
145 lay->setMargin( 3 ); 145 lay->setMargin( 3 );
146 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); 146 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this );
147 lay->addWidget( format ); 147 lay->addWidget( format );
148 format->setExclusive ( true ) ; 148 format->setExclusive ( true ) ;
149 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); 149 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this );
150 lay->addWidget( time ); time->setExclusive ( true ) ; 150 lay->addWidget( time ); time->setExclusive ( true ) ;
151 vcal = new QRadioButton(" vCalendar ", format ); 151 vcal = new QRadioButton(" vCalendar ", format );
152 ical = new QRadioButton(" iCalendar ", format ); 152 ical = new QRadioButton(" iCalendar ", format );
153 vcal->setChecked( true ); 153 vcal->setChecked( true );
154 tz = new QRadioButton(i18n(" With timezone "), time ); 154 tz = new QRadioButton(i18n(" With timezone "), time );
155 local = new QRadioButton(i18n(" Local time "), time ); 155 local = new QRadioButton(i18n(" Local time "), time );
156 tz->setChecked( true ); 156 tz->setChecked( true );
157 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); 157 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this );
158 lay->addWidget( ok ); 158 lay->addWidget( ok );
159 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 159 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
160 lay->addWidget( cancel ); 160 lay->addWidget( cancel );
161 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 161 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
162 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 162 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
163 resize( 200, 200 ); 163 resize( 200, 200 );
164 } 164 }
165 165
166 bool beamVcal() { return vcal->isChecked(); } 166 bool beamVcal() { return vcal->isChecked(); }
167 bool beamLocal() { return local->isChecked(); } 167 bool beamLocal() { return local->isChecked(); }
168private: 168private:
169 QRadioButton* vcal, *ical, *local, *tz; 169 QRadioButton* vcal, *ical, *local, *tz;
170}; 170};
171class KOCatPrefs : public QDialog 171class KOCatPrefs : public QDialog
172{ 172{
173 public: 173 public:
174 KOCatPrefs( QWidget *parent=0, const char *name=0 ) : 174 KOCatPrefs( QWidget *parent=0, const char *name=0 ) :
175 QDialog( parent, name, true ) 175 QDialog( parent, name, true )
176 { 176 {
177 setCaption( i18n("Manage new Categories") ); 177 setCaption( i18n("Manage new Categories") );
178 QVBoxLayout* lay = new QVBoxLayout( this ); 178 QVBoxLayout* lay = new QVBoxLayout( this );
179 lay->setSpacing( 3 ); 179 lay->setSpacing( 3 );
180 lay->setMargin( 3 ); 180 lay->setMargin( 3 );
181 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 ); 181 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 );
182 lay->addWidget( lab ); 182 lay->addWidget( lab );
183 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 183 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
184 lay->addWidget( format ); 184 lay->addWidget( format );
185 format->setExclusive ( true ) ; 185 format->setExclusive ( true ) ;
186 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 186 addCatBut = new QRadioButton(i18n("Add to category list"), format );
187 new QRadioButton(i18n("Remove from Events/Todos"), format ); 187 new QRadioButton(i18n("Remove from Events/Todos"), format );
188 addCatBut->setChecked( true ); 188 addCatBut->setChecked( true );
189 QPushButton * ok = new QPushButton( i18n("OK"), this ); 189 QPushButton * ok = new QPushButton( i18n("OK"), this );
190 lay->addWidget( ok ); 190 lay->addWidget( ok );
191 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 191 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
192 lay->addWidget( cancel ); 192 lay->addWidget( cancel );
193 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 193 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
194 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 194 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
195 resize( 200, 200 ); 195 resize( 200, 200 );
196 } 196 }
197 197
198 bool addCat() { return addCatBut->isChecked(); } 198 bool addCat() { return addCatBut->isChecked(); }
199private: 199private:
200 QRadioButton* addCatBut; 200 QRadioButton* addCatBut;
201}; 201};
202 202
203 203
204 204
205CalendarView::CalendarView( CalendarResources *calendar, 205CalendarView::CalendarView( CalendarResources *calendar,
206 QWidget *parent, const char *name ) 206 QWidget *parent, const char *name )
207 : CalendarViewBase( parent, name ), 207 : CalendarViewBase( parent, name ),
208 mCalendar( calendar ), 208 mCalendar( calendar ),
209 mResourceManager( calendar->resourceManager() ) 209 mResourceManager( calendar->resourceManager() )
210{ 210{
211 211
212 mEventEditor = 0; 212 mEventEditor = 0;
213 mTodoEditor = 0; 213 mTodoEditor = 0;
214 214
215 init(); 215 init();
216} 216}
217 217
218CalendarView::CalendarView( Calendar *calendar, 218CalendarView::CalendarView( Calendar *calendar,
219 QWidget *parent, const char *name ) 219 QWidget *parent, const char *name )
220 : CalendarViewBase( parent, name ), 220 : CalendarViewBase( parent, name ),
221 mCalendar( calendar ), 221 mCalendar( calendar ),
222 mResourceManager( 0 ) 222 mResourceManager( 0 )
223{ 223{
224 224
225 mEventEditor = 0; 225 mEventEditor = 0;
226 mTodoEditor = 0; 226 mTodoEditor = 0;
227 init();} 227 init();}
228 228
229void CalendarView::init() 229void CalendarView::init()
230{ 230{
231 beamDialog = new KOBeamPrefs(); 231 beamDialog = new KOBeamPrefs();
232 mDatePickerMode = 0; 232 mDatePickerMode = 0;
233 mCurrentSyncDevice = ""; 233 mCurrentSyncDevice = "";
234 writeLocale(); 234 writeLocale();
235 mViewManager = new KOViewManager( this ); 235 mViewManager = new KOViewManager( this );
236 mDialogManager = new KODialogManager( this ); 236 mDialogManager = new KODialogManager( this );
237 mEventViewerDialog = 0; 237 mEventViewerDialog = 0;
238 mModified = false; 238 mModified = false;
239 mReadOnly = false; 239 mReadOnly = false;
240 mSelectedIncidence = 0; 240 mSelectedIncidence = 0;
241 mCalPrinter = 0; 241 mCalPrinter = 0;
242 mFilters.setAutoDelete(true); 242 mFilters.setAutoDelete(true);
243 243
244 mCalendar->registerObserver( this ); 244 mCalendar->registerObserver( this );
245 // TODO: Make sure that view is updated, when calendar is changed. 245 // TODO: Make sure that view is updated, when calendar is changed.
246 246
247 mStorage = new FileStorage( mCalendar ); 247 mStorage = new FileStorage( mCalendar );
248 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 248 mNavigator = new DateNavigator( this, "datevav", mViewManager );
249 249
250 QBoxLayout *topLayout = (QBoxLayout*)layout(); 250 QBoxLayout *topLayout = (QBoxLayout*)layout();
251#ifndef KORG_NOSPLITTER 251#ifndef KORG_NOSPLITTER
252 // create the main layout frames. 252 // create the main layout frames.
253 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 253 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
254 topLayout->addWidget(mPanner); 254 topLayout->addWidget(mPanner);
255 255
256 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 256 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
257 "CalendarView::LeftFrame"); 257 "CalendarView::LeftFrame");
258 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 258 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
259 259
260 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, 260 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE,
261 "CalendarView::DateNavigator", QDate::currentDate() ); 261 "CalendarView::DateNavigator", QDate::currentDate() );
262 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 262 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
263 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 263 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
264 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 264 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
265 265
266#ifdef KORG_NORESOURCEVIEW 266#ifdef KORG_NORESOURCEVIEW
267 mResourceView = 0; 267 mResourceView = 0;
268#else 268#else
269 if ( mResourceManager ) { 269 if ( mResourceManager ) {
270 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 270 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
271 mResourceView->updateView(); 271 mResourceView->updateView();
272 connect( mResourceView, SIGNAL( resourcesChanged() ), 272 connect( mResourceView, SIGNAL( resourcesChanged() ),
273 SLOT( updateView() ) ); 273 SLOT( updateView() ) );
274 } else { 274 } else {
275 mResourceView = 0; 275 mResourceView = 0;
276 } 276 }
277#endif 277#endif
278 QWidget *rightBox = new QWidget( mPanner ); 278 QWidget *rightBox = new QWidget( mPanner );
279 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 279 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
280 280
281 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 281 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
282 rightLayout->addWidget( mNavigatorBar ); 282 rightLayout->addWidget( mNavigatorBar );
283 283
284 mRightFrame = new QWidgetStack( rightBox ); 284 mRightFrame = new QWidgetStack( rightBox );
285 rightLayout->addWidget( mRightFrame, 1 ); 285 rightLayout->addWidget( mRightFrame, 1 );
286 286
287 mLeftFrame = mLeftSplitter; 287 mLeftFrame = mLeftSplitter;
288#else 288#else
289 QWidget *mainBox = new QWidget( this ); 289 QWidget *mainBox = new QWidget( this );
290 QWidget *leftFrame = new QWidget( mainBox ); 290 QWidget *leftFrame = new QWidget( mainBox );
291 291
292 QBoxLayout * mainBoxLayout; 292 QBoxLayout * mainBoxLayout;
293 QBoxLayout * leftFrameLayout; 293 QBoxLayout * leftFrameLayout;
294 if ( KOPrefs::instance()->mVerticalScreen ) { 294 if ( KOPrefs::instance()->mVerticalScreen ) {
295 mainBoxLayout = new QVBoxLayout(mainBox); 295 mainBoxLayout = new QVBoxLayout(mainBox);
296 leftFrameLayout = new QHBoxLayout(leftFrame ); 296 leftFrameLayout = new QHBoxLayout(leftFrame );
297 } else { 297 } else {
298 mainBoxLayout = new QHBoxLayout(mainBox); 298 mainBoxLayout = new QHBoxLayout(mainBox);
299 leftFrameLayout = new QVBoxLayout(leftFrame ); 299 leftFrameLayout = new QVBoxLayout(leftFrame );
300 } 300 }
301 topLayout->addWidget( mainBox ); 301 topLayout->addWidget( mainBox );
302 mainBoxLayout->addWidget (leftFrame); 302 mainBoxLayout->addWidget (leftFrame);
303 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, 303 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE,
304 "CalendarView::DateNavigator", QDate::currentDate()); 304 "CalendarView::DateNavigator", QDate::currentDate());
305 // mDateNavigator->blockSignals( true ); 305 // mDateNavigator->blockSignals( true );
306 leftFrameLayout->addWidget( mDateNavigator ); 306 leftFrameLayout->addWidget( mDateNavigator );
307 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); 307 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView");
308 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolist"); 308 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolist");
309 309
310 if ( QApplication::desktop()->width() < 480 ) { 310 if ( QApplication::desktop()->width() < 480 ) {
311 leftFrameLayout->addWidget(mFilterView); 311 leftFrameLayout->addWidget(mFilterView);
312 leftFrameLayout->addWidget(mTodoList, 2 ); 312 leftFrameLayout->addWidget(mTodoList, 2 );
313 313
314 } else { 314 } else {
315 leftFrameLayout->addWidget(mTodoList,2 ); 315 leftFrameLayout->addWidget(mTodoList,2 );
316 leftFrameLayout->addWidget(mFilterView ); 316 leftFrameLayout->addWidget(mFilterView );
317 } 317 }
318 mFilterView->hide(); 318 mFilterView->hide();
319 QWidget *rightBox = new QWidget( mainBox ); 319 QWidget *rightBox = new QWidget( mainBox );
320 mainBoxLayout->addWidget ( rightBox, 10 ); 320 mainBoxLayout->addWidget ( rightBox, 10 );
321 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 321 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
322 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 322 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
323 mRightFrame = new QWidgetStack( rightBox ); 323 mRightFrame = new QWidgetStack( rightBox );
324 rightLayout->addWidget( mNavigatorBar ); 324 rightLayout->addWidget( mNavigatorBar );
325 rightLayout->addWidget( mRightFrame, 10 ); 325 rightLayout->addWidget( mRightFrame, 10 );
326 326
327 mLeftFrame = leftFrame; 327 mLeftFrame = leftFrame;
328 if ( KOPrefs::instance()->mVerticalScreen ) { 328 if ( KOPrefs::instance()->mVerticalScreen ) {
329 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 329 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
330 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 330 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
331 } else { 331 } else {
332 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 332 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
333 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 333 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
334 } 334 }
335 335
336 //qDebug("Calendarview Size %d %d ", width(), height()); 336 //qDebug("Calendarview Size %d %d ", width(), height());
337#endif 337#endif
338 338
339 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 339 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
340 SLOT( showDates( const KCal::DateList & ) ) ); 340 SLOT( showDates( const KCal::DateList & ) ) );
341 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 341 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
342 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 342 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
343 343
344 connect( mNavigatorBar, SIGNAL( goPrevYear() ), 344 connect( mNavigatorBar, SIGNAL( goPrevYear() ),
345 mNavigator, SLOT( selectPreviousYear() ) ); 345 mNavigator, SLOT( selectPreviousYear() ) );
346 connect( mNavigatorBar, SIGNAL( goNextYear() ), 346 connect( mNavigatorBar, SIGNAL( goNextYear() ),
347 mNavigator, SLOT( selectNextYear() ) ); 347 mNavigator, SLOT( selectNextYear() ) );
348 connect( mNavigatorBar, SIGNAL( goPrevMonth() ), 348 connect( mNavigatorBar, SIGNAL( goPrevMonth() ),
349 mNavigator, SLOT( selectPreviousMonth() ) ); 349 mNavigator, SLOT( selectPreviousMonth() ) );
350 connect( mNavigatorBar, SIGNAL( goNextMonth() ), 350 connect( mNavigatorBar, SIGNAL( goNextMonth() ),
351 mNavigator, SLOT( selectNextMonth() ) ); 351 mNavigator, SLOT( selectNextMonth() ) );
352 352
353 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 353 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
354 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); 354 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) );
355 355
356 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 356 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
357 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 357 mNavigator, SLOT( selectWeek( const QDate & ) ) );
358 358
359 connect( mDateNavigator, SIGNAL( goPrevYear() ), 359 connect( mDateNavigator, SIGNAL( goPrevYear() ),
360 mNavigator, SLOT( selectPreviousYear() ) ); 360 mNavigator, SLOT( selectPreviousYear() ) );
361 connect( mDateNavigator, SIGNAL( goNextYear() ), 361 connect( mDateNavigator, SIGNAL( goNextYear() ),
362 mNavigator, SLOT( selectNextYear() ) ); 362 mNavigator, SLOT( selectNextYear() ) );
363 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 363 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
364 mNavigator, SLOT( selectPreviousMonth() ) ); 364 mNavigator, SLOT( selectPreviousMonth() ) );
365 connect( mDateNavigator, SIGNAL( goNextMonth() ), 365 connect( mDateNavigator, SIGNAL( goNextMonth() ),
366 mNavigator, SLOT( selectNextMonth() ) ); 366 mNavigator, SLOT( selectNextMonth() ) );
367 367
368 connect( mDateNavigator, SIGNAL( goPrevious() ), 368 connect( mDateNavigator, SIGNAL( goPrevious() ),
369 mNavigator, SLOT( selectPrevious() ) ); 369 mNavigator, SLOT( selectPrevious() ) );
370 connect( mDateNavigator, SIGNAL( goNext() ), 370 connect( mDateNavigator, SIGNAL( goNext() ),
371 mNavigator, SLOT( selectNext() ) ); 371 mNavigator, SLOT( selectNext() ) );
372 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 372 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
373 mNavigator, SLOT( slotMonthSelect( int ) ) ); 373 mNavigator, SLOT( slotMonthSelect( int ) ) );
374 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), 374 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ),
375 mNavigator, SLOT( slotMonthSelect( int ) ) ); 375 mNavigator, SLOT( slotMonthSelect( int ) ) );
376 376
377 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 377 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
378 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 378 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
379 379
380 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), 380 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ),
381 SLOT( eventAdded( Event *) ) ); 381 SLOT( eventAdded( Event *) ) );
382 382
383 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 383 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
384 384
385 connect( this, SIGNAL( configChanged() ), 385 connect( this, SIGNAL( configChanged() ),
386 mDateNavigator, SLOT( updateConfig() ) ); 386 mDateNavigator, SLOT( updateConfig() ) );
387 387
388 connect( mTodoList, SIGNAL( newTodoSignal() ), 388 connect( mTodoList, SIGNAL( newTodoSignal() ),
389 SLOT( newTodo() ) ); 389 SLOT( newTodo() ) );
390 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 390 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
391 SLOT( newSubTodo( Todo * ) ) ); 391 SLOT( newSubTodo( Todo * ) ) );
392 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 392 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
393 SLOT( editTodo( Todo * ) ) ); 393 SLOT( editTodo( Todo * ) ) );
394 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 394 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
395 SLOT( showTodo( Todo *) ) ); 395 SLOT( showTodo( Todo *) ) );
396 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 396 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
397 SLOT( deleteTodo( Todo *) ) ); 397 SLOT( deleteTodo( Todo *) ) );
398 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 398 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
399 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 399 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
400 SLOT( purgeCompleted() ) ); 400 SLOT( purgeCompleted() ) );
401 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 401 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
402 SIGNAL( todoModified( Todo *, int ) ) ); 402 SIGNAL( todoModified( Todo *, int ) ) );
403 403
404 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 404 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
405 this, SLOT ( cloneIncidence( Incidence * ) ) ); 405 this, SLOT ( cloneIncidence( Incidence * ) ) );
406 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 406 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
407 this, SLOT (cancelIncidence( Incidence * ) ) ); 407 this, SLOT (cancelIncidence( Incidence * ) ) );
408 408
409 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 409 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
410 this, SLOT ( moveIncidence( Incidence * ) ) ); 410 this, SLOT ( moveIncidence( Incidence * ) ) );
411 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 411 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
412 this, SLOT ( beamIncidence( Incidence * ) ) ); 412 this, SLOT ( beamIncidence( Incidence * ) ) );
413 413
414 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 414 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
415 this, SLOT ( todo_unsub( Todo * ) ) ); 415 this, SLOT ( todo_unsub( Todo * ) ) );
416 416
417 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 417 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
418 SLOT( updateTodo( Todo *, int ) ) ); 418 SLOT( updateTodo( Todo *, int ) ) );
419 connect( this, SIGNAL( todoModified( Todo *, int )), this, 419 connect( this, SIGNAL( todoModified( Todo *, int )), this,
420 SLOT( changeTodoDisplay( Todo *, int ) ) ); 420 SLOT( changeTodoDisplay( Todo *, int ) ) );
421 421
422 422
423 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 423 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
424 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 424 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
425 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 425 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
426 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 426 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
427 427
428 428
429 429
430 430
431 431
432 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 432 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
433 SLOT(checkClipboard())); 433 SLOT(checkClipboard()));
434 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 434 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
435 SLOT( processTodoListSelection( Incidence * ) ) ); 435 SLOT( processTodoListSelection( Incidence * ) ) );
436 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 436 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
437 437
438 // kdDebug() << "CalendarView::CalendarView() done" << endl; 438 // kdDebug() << "CalendarView::CalendarView() done" << endl;
439 439
440 mDateFrame = new QVBox(0,0,WType_Popup); 440 mDateFrame = new QVBox(0,0,WType_Popup);
441 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 441 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
442 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 442 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
443 mDateFrame->setLineWidth(3); 443 mDateFrame->setLineWidth(3);
444 mDateFrame->hide(); 444 mDateFrame->hide();
445 mDateFrame->setCaption( i18n( "Pick a date to display")); 445 mDateFrame->setCaption( i18n( "Pick a date to display"));
446 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 446 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
447 447
448 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 448 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
449 449
450 mEventEditor = mDialogManager->getEventEditor(); 450 mEventEditor = mDialogManager->getEventEditor();
451 mTodoEditor = mDialogManager->getTodoEditor(); 451 mTodoEditor = mDialogManager->getTodoEditor();
452 452
453 mFlagEditDescription = false; 453 mFlagEditDescription = false;
454 454
455 mSuspendTimer = new QTimer( this ); 455 mSuspendTimer = new QTimer( this );
456 mAlarmTimer = new QTimer( this ); 456 mAlarmTimer = new QTimer( this );
457 mRecheckAlarmTimer = new QTimer( this ); 457 mRecheckAlarmTimer = new QTimer( this );
458 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 458 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
459 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 459 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
460 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 460 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
461 mAlarmDialog = new AlarmDialog( this ); 461 mAlarmDialog = new AlarmDialog( this );
462 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 462 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
463 mAlarmDialog->setServerNotification( false ); 463 mAlarmDialog->setServerNotification( false );
464 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 464 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
465} 465}
466 466
467 467
468CalendarView::~CalendarView() 468CalendarView::~CalendarView()
469{ 469{
470 // kdDebug() << "~CalendarView()" << endl; 470 // kdDebug() << "~CalendarView()" << endl;
471 //qDebug("CalendarView::~CalendarView() "); 471 //qDebug("CalendarView::~CalendarView() ");
472 delete mDialogManager; 472 delete mDialogManager;
473 delete mViewManager; 473 delete mViewManager;
474 delete mStorage; 474 delete mStorage;
475 delete mDateFrame ; 475 delete mDateFrame ;
476 delete beamDialog; 476 delete beamDialog;
477 //kdDebug() << "~CalendarView() done" << endl; 477 //kdDebug() << "~CalendarView() done" << endl;
478} 478}
479void CalendarView::timerAlarm() 479void CalendarView::timerAlarm()
480{ 480{
481 //qDebug("CalendarView::timerAlarm() "); 481 //qDebug("CalendarView::timerAlarm() ");
482 computeAlarm(mAlarmNotification ); 482 computeAlarm(mAlarmNotification );
483} 483}
484 484
485void CalendarView::suspendAlarm() 485void CalendarView::suspendAlarm()
486{ 486{
487 //qDebug(" CalendarView::suspendAlarm() "); 487 //qDebug(" CalendarView::suspendAlarm() ");
488 computeAlarm(mSuspendAlarmNotification ); 488 computeAlarm(mSuspendAlarmNotification );
489 489
490} 490}
491 491
492void CalendarView::startAlarm( QString mess , QString filename) 492void CalendarView::startAlarm( QString mess , QString filename)
493{ 493{
494 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 494 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
495 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); 495 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
496 496
497} 497}
498 498
499void CalendarView::checkNextTimerAlarm() 499void CalendarView::checkNextTimerAlarm()
500{ 500{
501 mCalendar->checkAlarmForIncidence( 0, true ); 501 mCalendar->checkAlarmForIncidence( 0, true );
502} 502}
503 503
504void CalendarView::computeAlarm( QString msg ) 504void CalendarView::computeAlarm( QString msg )
505{ 505{
506 506
507 QString mess = msg; 507 QString mess = msg;
508 QString mAlarmMessage = mess.mid( 9 ); 508 QString mAlarmMessage = mess.mid( 9 );
509 QString filename = MainWindow::resourcePath(); 509 QString filename = MainWindow::resourcePath();
510 filename += "koalarm.wav"; 510 filename += "koalarm.wav";
511 QString tempfilename; 511 QString tempfilename;
512 if ( mess.left( 13 ) == "suspend_alarm") { 512 if ( mess.left( 13 ) == "suspend_alarm") {
513 bool error = false; 513 bool error = false;
514 int len = mess.mid( 13 ).find("+++"); 514 int len = mess.mid( 13 ).find("+++");
515 if ( len < 2 ) 515 if ( len < 2 )
516 error = true; 516 error = true;
517 else { 517 else {
518 tempfilename = mess.mid( 13, len ); 518 tempfilename = mess.mid( 13, len );
519 if ( !QFile::exists( tempfilename ) ) 519 if ( !QFile::exists( tempfilename ) )
520 error = true; 520 error = true;
521 } 521 }
522 if ( ! error ) { 522 if ( ! error ) {
523 filename = tempfilename; 523 filename = tempfilename;
524 } 524 }
525 mAlarmMessage = mess.mid( 13+len+3 ); 525 mAlarmMessage = mess.mid( 13+len+3 );
526 //qDebug("suspend file %s ",tempfilename.latin1() ); 526 //qDebug("suspend file %s ",tempfilename.latin1() );
527 startAlarm( mAlarmMessage, filename); 527 startAlarm( mAlarmMessage, filename);
528 return; 528 return;
529 } 529 }
530 if ( mess.left( 11 ) == "timer_alarm") { 530 if ( mess.left( 11 ) == "timer_alarm") {
531 //mTimerTime = 0; 531 //mTimerTime = 0;
532 startAlarm( mess.mid( 11 ), filename ); 532 startAlarm( mess.mid( 11 ), filename );
533 return; 533 return;
534 } 534 }
535 if ( mess.left( 10 ) == "proc_alarm") { 535 if ( mess.left( 10 ) == "proc_alarm") {
536 bool error = false; 536 bool error = false;
537 int len = mess.mid( 10 ).find("+++"); 537 int len = mess.mid( 10 ).find("+++");
538 if ( len < 2 ) 538 if ( len < 2 )
539 error = true; 539 error = true;
540 else { 540 else {
541 tempfilename = mess.mid( 10, len ); 541 tempfilename = mess.mid( 10, len );
542 if ( !QFile::exists( tempfilename ) ) 542 if ( !QFile::exists( tempfilename ) )
543 error = true; 543 error = true;
544 } 544 }
545 if ( error ) { 545 if ( error ) {
546 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 546 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
547 mAlarmMessage += mess.mid( 10+len+3+9 ); 547 mAlarmMessage += mess.mid( 10+len+3+9 );
548 } else { 548 } else {
549 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 549 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
550 //qDebug("-----system command %s ",tempfilename.latin1() ); 550 //qDebug("-----system command %s ",tempfilename.latin1() );
551#ifndef _WIN32_ 551#ifndef _WIN32_
552 if ( vfork () == 0 ) { 552 if ( vfork () == 0 ) {
553 execl ( tempfilename.latin1(), 0 ); 553 execl ( tempfilename.latin1(), 0 );
554 return; 554 return;
555 } 555 }
556#else 556#else
557 QProcess* p = new QProcess(); 557 QProcess* p = new QProcess();
558 p->addArgument( tempfilename.latin1() ); 558 p->addArgument( tempfilename.latin1() );
559 p->start(); 559 p->start();
560 return; 560 return;
561#endif 561#endif
562 562
563 return; 563 return;
564 } 564 }
565 565
566 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 566 //qDebug("+++++++system command %s ",tempfilename.latin1() );
567 } 567 }
568 if ( mess.left( 11 ) == "audio_alarm") { 568 if ( mess.left( 11 ) == "audio_alarm") {
569 bool error = false; 569 bool error = false;
570 int len = mess.mid( 11 ).find("+++"); 570 int len = mess.mid( 11 ).find("+++");
571 if ( len < 2 ) 571 if ( len < 2 )
572 error = true; 572 error = true;
573 else { 573 else {
574 tempfilename = mess.mid( 11, len ); 574 tempfilename = mess.mid( 11, len );
575 if ( !QFile::exists( tempfilename ) ) 575 if ( !QFile::exists( tempfilename ) )
576 error = true; 576 error = true;
577 } 577 }
578 if ( ! error ) { 578 if ( ! error ) {
579 filename = tempfilename; 579 filename = tempfilename;
580 } 580 }
581 mAlarmMessage = mess.mid( 11+len+3+9 ); 581 mAlarmMessage = mess.mid( 11+len+3+9 );
582 //qDebug("audio file command %s ",tempfilename.latin1() ); 582 //qDebug("audio file command %s ",tempfilename.latin1() );
583 } 583 }
584 if ( mess.left( 9 ) == "cal_alarm") { 584 if ( mess.left( 9 ) == "cal_alarm") {
585 mAlarmMessage = mess.mid( 9 ) ; 585 mAlarmMessage = mess.mid( 9 ) ;
586 } 586 }
587 587
588 startAlarm( mAlarmMessage, filename ); 588 startAlarm( mAlarmMessage, filename );
589 589
590 590
591} 591}
592 592
593void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 593void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
594{ 594{
595 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 595 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
596 596
597 mSuspendAlarmNotification = noti; 597 mSuspendAlarmNotification = noti;
598 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 598 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
599 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 599 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
600 mSuspendTimer->start( ms , true ); 600 mSuspendTimer->start( ms , true );
601 601
602} 602}
603 603
604void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 604void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
605{ 605{
606 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 606 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
607 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 607 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
608#ifndef DESKTOP_VERSION 608#ifndef DESKTOP_VERSION
609 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); 609 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() );
610#endif 610#endif
611 return; 611 return;
612 } 612 }
613 int maxSec; 613 int maxSec;
614 //maxSec = 5; //testing only 614 //maxSec = 5; //testing only
615 maxSec = 86400+3600; // one day+1hour 615 maxSec = 86400+3600; // one day+1hour
616 mAlarmNotification = noti; 616 mAlarmNotification = noti;
617 int sec = QDateTime::currentDateTime().secsTo( qdt ); 617 int sec = QDateTime::currentDateTime().secsTo( qdt );
618 if ( sec > maxSec ) { 618 if ( sec > maxSec ) {
619 mRecheckAlarmTimer->start( maxSec * 1000 ); 619 mRecheckAlarmTimer->start( maxSec * 1000 );
620 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 620 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
621 return; 621 return;
622 } else { 622 } else {
623 mRecheckAlarmTimer->stop(); 623 mRecheckAlarmTimer->stop();
624 } 624 }
625 //qDebug("Alarm timer started with secs: %d ", sec); 625 //qDebug("Alarm timer started with secs: %d ", sec);
626 mAlarmTimer->start( sec *1000 , true ); 626 mAlarmTimer->start( sec *1000 , true );
627 627
628} 628}
629// called by mRecheckAlarmTimer to get next alarm 629// called by mRecheckAlarmTimer to get next alarm
630// we need this, because a QTimer has only a max range of 25 days 630// we need this, because a QTimer has only a max range of 25 days
631void CalendarView::recheckTimerAlarm() 631void CalendarView::recheckTimerAlarm()
632{ 632{
633 mAlarmTimer->stop(); 633 mAlarmTimer->stop();
634 mRecheckAlarmTimer->stop(); 634 mRecheckAlarmTimer->stop();
635 mCalendar->checkAlarmForIncidence( 0, true ); 635 mCalendar->checkAlarmForIncidence( 0, true );
636} 636}
637void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 637void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
638{ 638{
639 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 639 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
640 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 640 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
641#ifndef DESKTOP_VERSION 641#ifndef DESKTOP_VERSION
642 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 642 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
643#endif 643#endif
644 return; 644 return;
645 } 645 }
646 mAlarmTimer->stop(); 646 mAlarmTimer->stop();
647} 647}
648void CalendarView::selectWeekNum ( int num ) 648void CalendarView::selectWeekNum ( int num )
649{ 649{
650 dateNavigator()->selectWeek( num ); 650 dateNavigator()->selectWeek( num );
651 mViewManager->showWeekView(); 651 mViewManager->showWeekView();
652} 652}
653KOViewManager *CalendarView::viewManager() 653KOViewManager *CalendarView::viewManager()
654{ 654{
655 return mViewManager; 655 return mViewManager;
656} 656}
657 657
658KODialogManager *CalendarView::dialogManager() 658KODialogManager *CalendarView::dialogManager()
659{ 659{
660 return mDialogManager; 660 return mDialogManager;
661} 661}
662 662
663QDate CalendarView::startDate() 663QDate CalendarView::startDate()
664{ 664{
665 DateList dates = mNavigator->selectedDates(); 665 DateList dates = mNavigator->selectedDates();
666 666
667 return dates.first(); 667 return dates.first();
668} 668}
669 669
670QDate CalendarView::endDate() 670QDate CalendarView::endDate()
671{ 671{
672 DateList dates = mNavigator->selectedDates(); 672 DateList dates = mNavigator->selectedDates();
673 673
674 return dates.last(); 674 return dates.last();
675} 675}
676 676
677 677
678void CalendarView::createPrinter() 678void CalendarView::createPrinter()
679{ 679{
680#ifndef KORG_NOPRINTER 680#ifndef KORG_NOPRINTER
681 if (!mCalPrinter) { 681 if (!mCalPrinter) {
682 mCalPrinter = new CalPrinter(this, mCalendar); 682 mCalPrinter = new CalPrinter(this, mCalendar);
683 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 683 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
684 } 684 }
685#endif 685#endif
686} 686}
687 687
688void CalendarView::confSync() 688void CalendarView::confSync()
689{ 689{
690 static KSyncPrefsDialog* sp = 0; 690 static KSyncPrefsDialog* sp = 0;
691 if ( ! sp ) { 691 if ( ! sp ) {
692 sp = new KSyncPrefsDialog( this, "syncprefs", true ); 692 sp = new KSyncPrefsDialog( this, "syncprefs", true );
693 } 693 }
694 sp->usrReadConfig(); 694 sp->usrReadConfig();
695#ifndef DESKTOP_VERSION 695#ifndef DESKTOP_VERSION
696 sp->showMaximized(); 696 sp->showMaximized();
697#else 697#else
698 sp->show(); 698 sp->show();
699#endif 699#endif
700 sp->exec(); 700 sp->exec();
701 KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames(); 701 KOPrefs::instance()->mSyncProfileNames = sp->getSyncProfileNames();
702 KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName (); 702 KOPrefs::instance()->mLocalMachineName = sp->getLocalMachineName ();
703} 703}
704 704
705 705
706//KOPrefs::instance()->mWriteBackFile 706//KOPrefs::instance()->mWriteBackFile
707//KOPrefs::instance()->mWriteBackExistingOnly 707//KOPrefs::instance()->mWriteBackExistingOnly
708 708
709// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 709// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
710// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 710// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
711// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 711// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
712// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 712// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
713// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 713// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
714// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 714// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
715 715
716int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 716int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
717{ 717{
718 718
719 //void setZaurusId(int id); 719 //void setZaurusId(int id);
720 // int zaurusId() const; 720 // int zaurusId() const;
721 // void setZaurusUid(int id); 721 // void setZaurusUid(int id);
722 // int zaurusUid() const; 722 // int zaurusUid() const;
723 // void setZaurusStat(int id); 723 // void setZaurusStat(int id);
724 // int zaurusStat() const; 724 // int zaurusStat() const;
725 // 0 equal 725 // 0 equal
726 // 1 take local 726 // 1 take local
727 // 2 take remote 727 // 2 take remote
728 // 3 cancel 728 // 3 cancel
729 QDateTime lastSync = mLastCalendarSync; 729 QDateTime lastSync = mLastCalendarSync;
730 QDateTime localMod = local->lastModified(); 730 QDateTime localMod = local->lastModified();
731 QDateTime remoteMod = remote->lastModified(); 731 QDateTime remoteMod = remote->lastModified();
732 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 732 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
733 bool remCh, locCh; 733 bool remCh, locCh;
734 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 734 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
735 //if ( remCh ) 735 //if ( remCh )
736 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 736 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
737 locCh = ( localMod > mLastCalendarSync ); 737 locCh = ( localMod > mLastCalendarSync );
738 if ( !remCh && ! locCh ) { 738 if ( !remCh && ! locCh ) {
739 //qDebug("both not changed "); 739 //qDebug("both not changed ");
740 lastSync = localMod.addDays(1); 740 lastSync = localMod.addDays(1);
741 if ( mode <= SYNC_PREF_ASK ) 741 if ( mode <= SYNC_PREF_ASK )
742 return 0; 742 return 0;
743 } else { 743 } else {
744 if ( locCh ) { 744 if ( locCh ) {
745 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); 745 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1());
746 lastSync = localMod.addDays( -1 ); 746 lastSync = localMod.addDays( -1 );
747 if ( !remCh ) 747 if ( !remCh )
748 remoteMod = ( lastSync.addDays( -1 ) ); 748 remoteMod = ( lastSync.addDays( -1 ) );
749 } else { 749 } else {
750 //qDebug(" not loc changed "); 750 //qDebug(" not loc changed ");
751 lastSync = localMod.addDays( 1 ); 751 lastSync = localMod.addDays( 1 );
752 if ( remCh ) 752 if ( remCh )
753 remoteMod =( lastSync.addDays( 1 ) ); 753 remoteMod =( lastSync.addDays( 1 ) );
754 754
755 } 755 }
756 } 756 }
757 full = true; 757 full = true;
758 if ( mode < SYNC_PREF_ASK ) 758 if ( mode < SYNC_PREF_ASK )
759 mode = SYNC_PREF_ASK; 759 mode = SYNC_PREF_ASK;
760 } else { 760 } else {
761 if ( localMod == remoteMod ) 761 if ( localMod == remoteMod )
762 if ( local->revision() == remote->revision() ) 762 if ( local->revision() == remote->revision() )
763 return 0; 763 return 0;
764 764
765 } 765 }
766 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 766 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
767 767
768 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); 768 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision());
769 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); 769 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() );
770 //full = true; //debug only 770 //full = true; //debug only
771 if ( full ) { 771 if ( full ) {
772 bool equ = false; 772 bool equ = false;
773 if ( local->type() == "Event" ) { 773 if ( local->type() == "Event" ) {
774 equ = (*((Event*) local) == *((Event*) remote)); 774 equ = (*((Event*) local) == *((Event*) remote));
775 } 775 }
776 else if ( local->type() =="Todo" ) 776 else if ( local->type() =="Todo" )
777 equ = (*((Todo*) local) == (*(Todo*) remote)); 777 equ = (*((Todo*) local) == (*(Todo*) remote));
778 else if ( local->type() =="Journal" ) 778 else if ( local->type() =="Journal" )
779 equ = (*((Journal*) local) == *((Journal*) remote)); 779 equ = (*((Journal*) local) == *((Journal*) remote));
780 if ( equ ) { 780 if ( equ ) {
781 //qDebug("equal "); 781 //qDebug("equal ");
782 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 782 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
783 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 783 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
784 } 784 }
785 if ( mode < SYNC_PREF_FORCE_LOCAL ) 785 if ( mode < SYNC_PREF_FORCE_LOCAL )
786 return 0; 786 return 0;
787 787
788 }//else //debug only 788 }//else //debug only
789 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 789 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
790 } 790 }
791 int result; 791 int result;
792 bool localIsNew; 792 bool localIsNew;
793 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); 793 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() );
794 794
795 if ( full && mode < SYNC_PREF_NEWEST ) 795 if ( full && mode < SYNC_PREF_NEWEST )
796 mode = SYNC_PREF_ASK; 796 mode = SYNC_PREF_ASK;
797 797
798 switch( mode ) { 798 switch( mode ) {
799 case SYNC_PREF_LOCAL: 799 case SYNC_PREF_LOCAL:
800 if ( lastSync > remoteMod ) 800 if ( lastSync > remoteMod )
801 return 1; 801 return 1;
802 if ( lastSync > localMod ) 802 if ( lastSync > localMod )
803 return 2; 803 return 2;
804 return 1; 804 return 1;
805 break; 805 break;
806 case SYNC_PREF_REMOTE: 806 case SYNC_PREF_REMOTE:
807 if ( lastSync > remoteMod ) 807 if ( lastSync > remoteMod )
808 return 1; 808 return 1;
809 if ( lastSync > localMod ) 809 if ( lastSync > localMod )
810 return 2; 810 return 2;
811 return 2; 811 return 2;
812 break; 812 break;
813 case SYNC_PREF_NEWEST: 813 case SYNC_PREF_NEWEST:
814 if ( localMod > remoteMod ) 814 if ( localMod > remoteMod )
815 return 1; 815 return 1;
816 else 816 else
817 return 2; 817 return 2;
818 break; 818 break;
819 case SYNC_PREF_ASK: 819 case SYNC_PREF_ASK:
820 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 820 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
821 if ( lastSync > remoteMod ) 821 if ( lastSync > remoteMod )
822 return 1; 822 return 1;
823 if ( lastSync > localMod ) 823 if ( lastSync > localMod )
824 return 2; 824 return 2;
825 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 825 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
826 localIsNew = localMod >= remoteMod; 826 localIsNew = localMod >= remoteMod;
827 if ( localIsNew ) 827 if ( localIsNew )
828 getEventViewerDialog()->setColorMode( 1 ); 828 getEventViewerDialog()->setColorMode( 1 );
829 else 829 else
830 getEventViewerDialog()->setColorMode( 2 ); 830 getEventViewerDialog()->setColorMode( 2 );
831 getEventViewerDialog()->setIncidence(local); 831 getEventViewerDialog()->setIncidence(local);
832 if ( localIsNew ) 832 if ( localIsNew )
833 getEventViewerDialog()->setColorMode( 2 ); 833 getEventViewerDialog()->setColorMode( 2 );
834 else 834 else
835 getEventViewerDialog()->setColorMode( 1 ); 835 getEventViewerDialog()->setColorMode( 1 );
836 getEventViewerDialog()->addIncidence(remote); 836 getEventViewerDialog()->addIncidence(remote);
837 getEventViewerDialog()->setColorMode( 0 ); 837 getEventViewerDialog()->setColorMode( 0 );
838 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 838 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
839 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 839 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
840 getEventViewerDialog()->showMe(); 840 getEventViewerDialog()->showMe();
841 result = getEventViewerDialog()->executeS( localIsNew ); 841 result = getEventViewerDialog()->executeS( localIsNew );
842 return result; 842 return result;
843 843
844 break; 844 break;
845 case SYNC_PREF_FORCE_LOCAL: 845 case SYNC_PREF_FORCE_LOCAL:
846 return 1; 846 return 1;
847 break; 847 break;
848 case SYNC_PREF_FORCE_REMOTE: 848 case SYNC_PREF_FORCE_REMOTE:
849 return 2; 849 return 2;
850 break; 850 break;
851 851
852 default: 852 default:
853 // SYNC_PREF_TAKE_BOTH not implemented 853 // SYNC_PREF_TAKE_BOTH not implemented
854 break; 854 break;
855 } 855 }
856 return 0; 856 return 0;
857} 857}
858Event* CalendarView::getLastSyncEvent() 858Event* CalendarView::getLastSyncEvent()
859{ 859{
860 Event* lse; 860 Event* lse;
861 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 861 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
862 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 862 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
863 if (!lse) { 863 if (!lse) {
864 lse = new Event(); 864 lse = new Event();
865 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 865 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
866 QString sum = ""; 866 QString sum = "";
867 if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 867 if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
868 sum = "E: "; 868 sum = "E: ";
869 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 869 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
870 lse->setDtStart( mLastCalendarSync ); 870 lse->setDtStart( mLastCalendarSync );
871 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 871 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
872 lse->setCategories( i18n("SyncEvent") ); 872 lse->setCategories( i18n("SyncEvent") );
873 lse->setReadOnly( true ); 873 lse->setReadOnly( true );
874 mCalendar->addEvent( lse ); 874 mCalendar->addEvent( lse );
875 } 875 }
876 876
877 return lse; 877 return lse;
878 878
879} 879}
880// probaly useless 880// probaly useless
881void CalendarView::setupExternSyncProfiles() 881void CalendarView::setupExternSyncProfiles()
882{ 882{
883 Event* lse; 883 Event* lse;
884 mExternLastSyncEvent.clear(); 884 mExternLastSyncEvent.clear();
885 int i; 885 int i;
886 for ( i = 0; i < KOPrefs::instance()->mExternSyncProfiles.count(); ++i ) { 886 for ( i = 0; i < KOPrefs::instance()->mExternSyncProfiles.count(); ++i ) {
887 lse = mCalendar->event( "last-syncEvent-"+ KOPrefs::instance()->mExternSyncProfiles[i] ); 887 lse = mCalendar->event( "last-syncEvent-"+ KOPrefs::instance()->mExternSyncProfiles[i] );
888 if ( lse ) 888 if ( lse )
889 mExternLastSyncEvent.append( lse ); 889 mExternLastSyncEvent.append( lse );
890 else 890 else
891 qDebug("Last Sync event not found for %s ", KOPrefs::instance()->mExternSyncProfiles[i].latin1()); 891 qDebug("Last Sync event not found for %s ", KOPrefs::instance()->mExternSyncProfiles[i].latin1());
892 } 892 }
893 893
894} 894}
895// we check, if the to delete event has a id for a profile 895// we check, if the to delete event has a id for a profile
896// if yes, we set this id in the profile to delete 896// if yes, we set this id in the profile to delete
897void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 897void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
898{ 898{
899 if ( lastSync.count() == 0 ) { 899 if ( lastSync.count() == 0 ) {
900 //qDebug(" lastSync.count() == 0"); 900 //qDebug(" lastSync.count() == 0");
901 return; 901 return;
902 } 902 }
903 if ( toDelete->type() == "Journal" ) 903 if ( toDelete->type() == "Journal" )
904 return; 904 return;
905 905
906 Event* eve = lastSync.first(); 906 Event* eve = lastSync.first();
907 907
908 while ( eve ) { 908 while ( eve ) {
909 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 909 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
910 if ( !id.isEmpty() ) { 910 if ( !id.isEmpty() ) {
911 QString des = eve->description(); 911 QString des = eve->description();
912 QString pref = "e"; 912 QString pref = "e";
913 if ( toDelete->type() == "Todo" ) 913 if ( toDelete->type() == "Todo" )
914 pref = "t"; 914 pref = "t";
915 des += pref+ id + ","; 915 des += pref+ id + ",";
916 eve->setReadOnly( false ); 916 eve->setReadOnly( false );
917 eve->setDescription( des ); 917 eve->setDescription( des );
918 //qDebug("setdes %s ", des.latin1()); 918 //qDebug("setdes %s ", des.latin1());
919 eve->setReadOnly( true ); 919 eve->setReadOnly( true );
920 } 920 }
921 eve = lastSync.next(); 921 eve = lastSync.next();
922 } 922 }
923 923
924} 924}
925void CalendarView::checkExternalId( Incidence * inc ) 925void CalendarView::checkExternalId( Incidence * inc )
926{ 926{
927 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 927 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
928 checkExternSyncEvent( lastSync, inc ); 928 checkExternSyncEvent( lastSync, inc );
929 929
930} 930}
931bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 931bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
932{ 932{
933 bool syncOK = true; 933 bool syncOK = true;
934 int addedEvent = 0; 934 int addedEvent = 0;
935 int addedEventR = 0; 935 int addedEventR = 0;
936 int deletedEventR = 0; 936 int deletedEventR = 0;
937 int deletedEventL = 0; 937 int deletedEventL = 0;
938 int changedLocal = 0; 938 int changedLocal = 0;
939 int changedRemote = 0; 939 int changedRemote = 0;
940 //QPtrList<Event> el = local->rawEvents(); 940 //QPtrList<Event> el = local->rawEvents();
941 Event* eventR; 941 Event* eventR;
942 QString uid; 942 QString uid;
943 int take; 943 int take;
944 Event* eventL; 944 Event* eventL;
945 Event* eventRSync; 945 Event* eventRSync;
946 Event* eventLSync; 946 Event* eventLSync;
947 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 947 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
948 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 948 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
949 bool fullDateRange = false; 949 bool fullDateRange = false;
950 local->resetTempSyncStat(); 950 local->resetTempSyncStat();
951 mLastCalendarSync = QDateTime::currentDateTime(); 951 mLastCalendarSync = QDateTime::currentDateTime();
952 QDateTime modifiedCalendar = mLastCalendarSync;; 952 QDateTime modifiedCalendar = mLastCalendarSync;;
953 eventLSync = getLastSyncEvent(); 953 eventLSync = getLastSyncEvent();
954 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 954 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
955 if ( eventR ) { 955 if ( eventR ) {
956 eventRSync = (Event*) eventR->clone(); 956 eventRSync = (Event*) eventR->clone();
957 remote->deleteEvent(eventR ); 957 remote->deleteEvent(eventR );
958 958
959 } else { 959 } else {
960 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 960 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
961 eventRSync = (Event*)eventLSync->clone(); 961 eventRSync = (Event*)eventLSync->clone();
962 } else { 962 } else {
963 fullDateRange = true; 963 fullDateRange = true;
964 eventRSync = new Event(); 964 eventRSync = new Event();
965 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 965 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
966 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 966 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
967 eventRSync->setDtStart( mLastCalendarSync ); 967 eventRSync->setDtStart( mLastCalendarSync );
968 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 968 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
969 eventRSync->setCategories( i18n("SyncEvent") ); 969 eventRSync->setCategories( i18n("SyncEvent") );
970 } 970 }
971 } 971 }
972 if ( eventLSync->dtStart() == mLastCalendarSync ) 972 if ( eventLSync->dtStart() == mLastCalendarSync )
973 fullDateRange = true; 973 fullDateRange = true;
974 974
975 if ( ! fullDateRange ) { 975 if ( ! fullDateRange ) {
976 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 976 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
977 977
978 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 978 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
979 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 979 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
980 fullDateRange = true; 980 fullDateRange = true;
981 } 981 }
982 } 982 }
983 if ( fullDateRange ) 983 if ( fullDateRange )
984 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 984 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
985 else 985 else
986 mLastCalendarSync = eventLSync->dtStart(); 986 mLastCalendarSync = eventLSync->dtStart();
987 // for resyncing if own file has changed 987 // for resyncing if own file has changed
988 if ( mCurrentSyncDevice == "deleteaftersync" ) { 988 if ( mCurrentSyncDevice == "deleteaftersync" ) {
989 mLastCalendarSync = loadedFileVersion; 989 mLastCalendarSync = loadedFileVersion;
990 qDebug("setting mLastCalendarSync "); 990 qDebug("setting mLastCalendarSync ");
991 } 991 }
992 //qDebug("*************************** "); 992 //qDebug("*************************** ");
993 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); 993 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() );
994 QPtrList<Incidence> er = remote->rawIncidences(); 994 QPtrList<Incidence> er = remote->rawIncidences();
995 Incidence* inR = er.first(); 995 Incidence* inR = er.first();
996 Incidence* inL; 996 Incidence* inL;
997 QProgressBar bar( er.count(),0 ); 997 QProgressBar bar( er.count(),0 );
998 bar.setCaption (i18n("Syncing - close to abort!") ); 998 bar.setCaption (i18n("Syncing - close to abort!") );
999 999
1000 int w = 300; 1000 int w = 300;
1001 if ( QApplication::desktop()->width() < 320 ) 1001 if ( QApplication::desktop()->width() < 320 )
1002 w = 220; 1002 w = 220;
1003 int h = bar.sizeHint().height() ; 1003 int h = bar.sizeHint().height() ;
1004 int dw = QApplication::desktop()->width(); 1004 int dw = QApplication::desktop()->width();
1005 int dh = QApplication::desktop()->height(); 1005 int dh = QApplication::desktop()->height();
1006 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1006 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1007 bar.show(); 1007 bar.show();
1008 int modulo = (er.count()/10)+1; 1008 int modulo = (er.count()/10)+1;
1009 int incCounter = 0; 1009 int incCounter = 0;
1010 while ( inR ) { 1010 while ( inR ) {
1011 if ( ! bar.isVisible() ) 1011 if ( ! bar.isVisible() )
1012 return false; 1012 return false;
1013 if ( incCounter % modulo == 0 ) 1013 if ( incCounter % modulo == 0 )
1014 bar.setProgress( incCounter ); 1014 bar.setProgress( incCounter );
1015 ++incCounter; 1015 ++incCounter;
1016 uid = inR->uid(); 1016 uid = inR->uid();
1017 bool skipIncidence = false; 1017 bool skipIncidence = false;
1018 if ( uid.left(15) == QString("last-syncEvent-") ) 1018 if ( uid.left(15) == QString("last-syncEvent-") )
1019 skipIncidence = true; 1019 skipIncidence = true;
1020 QString idS; 1020 QString idS;
1021 qApp->processEvents(); 1021 qApp->processEvents();
1022 if ( !skipIncidence ) { 1022 if ( !skipIncidence ) {
1023 inL = local->incidence( uid ); 1023 inL = local->incidence( uid );
1024 if ( inL ) { // maybe conflict - same uid in both calendars 1024 if ( inL ) { // maybe conflict - same uid in both calendars
1025 int maxrev = inL->revision(); 1025 int maxrev = inL->revision();
1026 if ( maxrev < inR->revision() ) 1026 if ( maxrev < inR->revision() )
1027 maxrev = inR->revision(); 1027 maxrev = inR->revision();
1028 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1028 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1029 //qDebug("take %d %s ", take, inL->summary().latin1()); 1029 //qDebug("take %d %s ", take, inL->summary().latin1());
1030 if ( take == 3 ) 1030 if ( take == 3 )
1031 return false; 1031 return false;
1032 if ( take == 1 ) {// take local 1032 if ( take == 1 ) {// take local
1033 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1033 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1034 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1034 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1035 else 1035 else
1036 idS = inR->IDStr(); 1036 idS = inR->IDStr();
1037 remote->deleteIncidence( inR ); 1037 remote->deleteIncidence( inR );
1038 if ( inL->revision() < maxrev ) 1038 if ( inL->revision() < maxrev )
1039 inL->setRevision( maxrev ); 1039 inL->setRevision( maxrev );
1040 inR = inL->clone(); 1040 inR = inL->clone();
1041 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1041 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1042 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1042 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1043 inR->setIDStr( idS ); 1043 inR->setIDStr( idS );
1044 remote->addIncidence( inR ); 1044 remote->addIncidence( inR );
1045 ++changedRemote; 1045 ++changedRemote;
1046 } else { 1046 } else {
1047 if ( inR->revision() < maxrev ) 1047 if ( inR->revision() < maxrev )
1048 inR->setRevision( maxrev ); 1048 inR->setRevision( maxrev );
1049 idS = inL->IDStr(); 1049 idS = inL->IDStr();
1050 local->deleteIncidence( inL ); 1050 local->deleteIncidence( inL );
1051 inL = inR->clone(); 1051 inL = inR->clone();
1052 inL->setIDStr( idS ); 1052 inL->setIDStr( idS );
1053 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1053 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1054 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1054 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1055 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1055 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1056 } 1056 }
1057 local->addIncidence( inL ); 1057 local->addIncidence( inL );
1058 ++changedLocal; 1058 ++changedLocal;
1059 } 1059 }
1060 } 1060 }
1061 } else { // no conflict 1061 } else { // no conflict
1062 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1062 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1063 QString des = eventLSync->description(); 1063 QString des = eventLSync->description();
1064 QString pref = "e"; 1064 QString pref = "e";
1065 if ( inR->type() == "Todo" ) 1065 if ( inR->type() == "Todo" )
1066 pref = "t"; 1066 pref = "t";
1067 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1067 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1068 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1068 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1069 //remote->deleteIncidence( inR ); 1069 //remote->deleteIncidence( inR );
1070 ++deletedEventR; 1070 ++deletedEventR;
1071 } else { 1071 } else {
1072 inR->setLastModified( modifiedCalendar ); 1072 inR->setLastModified( modifiedCalendar );
1073 inL = inR->clone(); 1073 inL = inR->clone();
1074 local->addIncidence( inL ); 1074 local->addIncidence( inL );
1075 ++addedEvent; 1075 ++addedEvent;
1076 } 1076 }
1077 } else { 1077 } else {
1078 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1078 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1079 inR->setLastModified( modifiedCalendar ); 1079 inR->setLastModified( modifiedCalendar );
1080 local->addIncidence( inR->clone() ); 1080 local->addIncidence( inR->clone() );
1081 ++addedEvent; 1081 ++addedEvent;
1082 } else { 1082 } else {
1083 checkExternSyncEvent(eventRSyncSharp, inR); 1083 checkExternSyncEvent(eventRSyncSharp, inR);
1084 remote->deleteIncidence( inR ); 1084 remote->deleteIncidence( inR );
1085 ++deletedEventR; 1085 ++deletedEventR;
1086 } 1086 }
1087 } 1087 }
1088 } 1088 }
1089 } 1089 }
1090 inR = er.next(); 1090 inR = er.next();
1091 } 1091 }
1092 QPtrList<Incidence> el = local->rawIncidences(); 1092 QPtrList<Incidence> el = local->rawIncidences();
1093 inL = el.first(); 1093 inL = el.first();
1094 modulo = (el.count()/10)+1; 1094 modulo = (el.count()/10)+1;
1095 bar.setCaption (i18n("Add / remove events") ); 1095 bar.setCaption (i18n("Add / remove events") );
1096 bar.setTotalSteps ( el.count() ) ; 1096 bar.setTotalSteps ( el.count() ) ;
1097 bar.show(); 1097 bar.show();
1098 incCounter = 0; 1098 incCounter = 0;
1099 1099
1100 while ( inL ) { 1100 while ( inL ) {
1101 1101
1102 qApp->processEvents(); 1102 qApp->processEvents();
1103 if ( ! bar.isVisible() ) 1103 if ( ! bar.isVisible() )
1104 return false; 1104 return false;
1105 if ( incCounter % modulo == 0 ) 1105 if ( incCounter % modulo == 0 )
1106 bar.setProgress( incCounter ); 1106 bar.setProgress( incCounter );
1107 ++incCounter; 1107 ++incCounter;
1108 uid = inL->uid(); 1108 uid = inL->uid();
1109 bool skipIncidence = false; 1109 bool skipIncidence = false;
1110 if ( uid.left(15) == QString("last-syncEvent-") ) 1110 if ( uid.left(15) == QString("last-syncEvent-") )
1111 skipIncidence = true; 1111 skipIncidence = true;
1112 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) 1112 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
1113 skipIncidence = true; 1113 skipIncidence = true;
1114 if ( !skipIncidence ) { 1114 if ( !skipIncidence ) {
1115 inR = remote->incidence( uid ); 1115 inR = remote->incidence( uid );
1116 if ( ! inR ) { 1116 if ( ! inR ) {
1117 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1117 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1118 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1118 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1119 checkExternSyncEvent(eventLSyncSharp, inL); 1119 checkExternSyncEvent(eventLSyncSharp, inL);
1120 local->deleteIncidence( inL ); 1120 local->deleteIncidence( inL );
1121 ++deletedEventL; 1121 ++deletedEventL;
1122 } else { 1122 } else {
1123 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { 1123 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
1124 inL->removeID(mCurrentSyncDevice ); 1124 inL->removeID(mCurrentSyncDevice );
1125 ++addedEventR; 1125 ++addedEventR;
1126 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1126 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1127 inL->setLastModified( modifiedCalendar ); 1127 inL->setLastModified( modifiedCalendar );
1128 inR = inL->clone(); 1128 inR = inL->clone();
1129 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1129 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1130 remote->addIncidence( inR ); 1130 remote->addIncidence( inR );
1131 } 1131 }
1132 } 1132 }
1133 } else { 1133 } else {
1134 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1134 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1135 checkExternSyncEvent(eventLSyncSharp, inL); 1135 checkExternSyncEvent(eventLSyncSharp, inL);
1136 local->deleteIncidence( inL ); 1136 local->deleteIncidence( inL );
1137 ++deletedEventL; 1137 ++deletedEventL;
1138 } else { 1138 } else {
1139 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { 1139 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
1140 ++addedEventR; 1140 ++addedEventR;
1141 inL->setLastModified( modifiedCalendar ); 1141 inL->setLastModified( modifiedCalendar );
1142 remote->addIncidence( inL->clone() ); 1142 remote->addIncidence( inL->clone() );
1143 } 1143 }
1144 } 1144 }
1145 } 1145 }
1146 } 1146 }
1147 } 1147 }
1148 inL = el.next(); 1148 inL = el.next();
1149 } 1149 }
1150 int delFut = 0; 1150 int delFut = 0;
1151 if ( KOPrefs::instance()->mWriteBackInFuture ) { 1151 if ( KOPrefs::instance()->mWriteBackInFuture ) {
1152 er = remote->rawIncidences(); 1152 er = remote->rawIncidences();
1153 inR = er.first(); 1153 inR = er.first();
1154 QDateTime dt; 1154 QDateTime dt;
1155 QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); 1155 QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
1156 QDateTime end = cur.addDays( (KOPrefs::instance()->mWriteBackInFuture +1 ) *7 ); 1156 QDateTime end = cur.addDays( (KOPrefs::instance()->mWriteBackInFuture +1 ) *7 );
1157 while ( inR ) { 1157 while ( inR ) {
1158 if ( inR->type() == "Todo" ) { 1158 if ( inR->type() == "Todo" ) {
1159 Todo * t = (Todo*)inR; 1159 Todo * t = (Todo*)inR;
1160 if ( t->hasDueDate() ) 1160 if ( t->hasDueDate() )
1161 dt = t->dtDue(); 1161 dt = t->dtDue();
1162 else 1162 else
1163 dt = cur.addSecs( 62 ); 1163 dt = cur.addSecs( 62 );
1164 } 1164 }
1165 else if (inR->type() == "Event" ) { 1165 else if (inR->type() == "Event" ) {
1166 bool ok; 1166 bool ok;
1167 dt = inR->getNextOccurence( cur, &ok ); 1167 dt = inR->getNextOccurence( cur, &ok );
1168 if ( !ok ) 1168 if ( !ok )
1169 dt = cur.addSecs( -62 ); 1169 dt = cur.addSecs( -62 );
1170 } 1170 }
1171 else 1171 else
1172 dt = inR->dtStart(); 1172 dt = inR->dtStart();
1173 if ( dt < cur || dt > end ) { 1173 if ( dt < cur || dt > end ) {
1174 remote->deleteIncidence( inR ); 1174 remote->deleteIncidence( inR );
1175 ++delFut; 1175 ++delFut;
1176 } 1176 }
1177 inR = er.next(); 1177 inR = er.next();
1178 } 1178 }
1179 } 1179 }
1180 bar.hide(); 1180 bar.hide();
1181 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1181 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1182 eventLSync->setReadOnly( false ); 1182 eventLSync->setReadOnly( false );
1183 eventLSync->setDtStart( mLastCalendarSync ); 1183 eventLSync->setDtStart( mLastCalendarSync );
1184 eventRSync->setDtStart( mLastCalendarSync ); 1184 eventRSync->setDtStart( mLastCalendarSync );
1185 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1185 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1186 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1186 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1187 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1187 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1188 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1188 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1189 eventLSync->setReadOnly( true ); 1189 eventLSync->setReadOnly( true );
1190 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 1190 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
1191 remote->addEvent( eventRSync ); 1191 remote->addEvent( eventRSync );
1192 QString mes; 1192 QString mes;
1193 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 ); 1193 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 );
1194 QString delmess; 1194 QString delmess;
1195 if ( delFut ) { 1195 if ( delFut ) {
1196 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\n"),delFut, KOPrefs::instance()->mWriteBackInFuture ); 1196 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\n"),delFut, KOPrefs::instance()->mWriteBackInFuture );
1197 mes += delmess; 1197 mes += delmess;
1198 } 1198 }
1199 if ( KOPrefs::instance()->mShowSyncSummary ) { 1199 if ( KOPrefs::instance()->mShowSyncSummary ) {
1200 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); 1200 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") );
1201 } 1201 }
1202 qDebug( mes ); 1202 qDebug( mes );
1203 mCalendar->checkAlarmForIncidence( 0, true ); 1203 mCalendar->checkAlarmForIncidence( 0, true );
1204 return syncOK; 1204 return syncOK;
1205} 1205}
1206 1206
1207void CalendarView::setSyncDevice( QString s ) 1207void CalendarView::setSyncDevice( QString s )
1208{ 1208{
1209 mCurrentSyncDevice= s; 1209 mCurrentSyncDevice= s;
1210} 1210}
1211void CalendarView::setSyncName( QString s ) 1211void CalendarView::setSyncName( QString s )
1212{ 1212{
1213 mCurrentSyncName= s; 1213 mCurrentSyncName= s;
1214} 1214}
1215bool CalendarView::syncCalendar(QString filename, int mode) 1215bool CalendarView::syncCalendar(QString filename, int mode)
1216{ 1216{
1217 mGlobalSyncMode = SYNC_MODE_NORMAL; 1217 mGlobalSyncMode = SYNC_MODE_NORMAL;
1218 CalendarLocal* calendar = new CalendarLocal(); 1218 CalendarLocal* calendar = new CalendarLocal();
1219 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1219 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1220 FileStorage* storage = new FileStorage( calendar ); 1220 FileStorage* storage = new FileStorage( calendar );
1221 bool syncOK = false; 1221 bool syncOK = false;
1222 storage->setFileName( filename ); 1222 storage->setFileName( filename );
1223 // qDebug("loading ... "); 1223 // qDebug("loading ... ");
1224 if ( storage->load() ) { 1224 if ( storage->load() ) {
1225 getEventViewerDialog()->setSyncMode( true ); 1225 getEventViewerDialog()->setSyncMode( true );
1226 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1226 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1227 getEventViewerDialog()->setSyncMode( false ); 1227 getEventViewerDialog()->setSyncMode( false );
1228 if ( syncOK ) { 1228 if ( syncOK ) {
1229 if ( KOPrefs::instance()->mWriteBackFile ) 1229 if ( KOPrefs::instance()->mWriteBackFile )
1230 { 1230 {
1231 storage->setSaveFormat( new ICalFormat() ); 1231 storage->setSaveFormat( new ICalFormat() );
1232 storage->save(); 1232 storage->save();
1233 } 1233 }
1234 } 1234 }
1235 setModified( true ); 1235 setModified( true );
1236 } 1236 }
1237 delete storage; 1237 delete storage;
1238 delete calendar; 1238 delete calendar;
1239 if ( syncOK ) 1239 if ( syncOK )
1240 updateView(); 1240 updateView();
1241 return syncOK; 1241 return syncOK;
1242} 1242}
1243void CalendarView::syncPhone() 1243void CalendarView::syncPhone()
1244{ 1244{
1245 syncExternal( 1 ); 1245 syncExternal( 1 );
1246} 1246}
1247void CalendarView::syncExternal( int mode ) 1247void CalendarView::syncExternal( int mode )
1248{ 1248{
1249 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1249 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1250 //mCurrentSyncDevice = "sharp-DTM"; 1250 //mCurrentSyncDevice = "sharp-DTM";
1251 if ( KOPrefs::instance()->mAskForPreferences ) 1251 if ( KOPrefs::instance()->mAskForPreferences )
1252 edit_sync_options(); 1252 edit_sync_options();
1253 qApp->processEvents(); 1253 qApp->processEvents();
1254 CalendarLocal* calendar = new CalendarLocal(); 1254 CalendarLocal* calendar = new CalendarLocal();
1255 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1255 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1256 bool syncOK = false; 1256 bool syncOK = false;
1257 bool loadSuccess = false; 1257 bool loadSuccess = false;
1258 PhoneFormat* phoneFormat = 0; 1258 PhoneFormat* phoneFormat = 0;
1259#ifndef DESKTOP_VERSION 1259#ifndef DESKTOP_VERSION
1260 SharpFormat* sharpFormat = 0; 1260 SharpFormat* sharpFormat = 0;
1261 if ( mode == 0 ) { // sharp 1261 if ( mode == 0 ) { // sharp
1262 sharpFormat = new SharpFormat () ; 1262 sharpFormat = new SharpFormat () ;
1263 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1263 loadSuccess = sharpFormat->load( calendar, mCalendar );
1264 1264
1265 } else 1265 } else
1266#endif 1266#endif
1267 if ( mode == 1 ) { // phone 1267 if ( mode == 1 ) { // phone
1268 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1268 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1269 KOPrefs::instance()->mPhoneDevice, 1269 KOPrefs::instance()->mPhoneDevice,
1270 KOPrefs::instance()->mPhoneConnection, 1270 KOPrefs::instance()->mPhoneConnection,
1271 KOPrefs::instance()->mPhoneModel); 1271 KOPrefs::instance()->mPhoneModel);
1272 loadSuccess = phoneFormat->load( calendar,mCalendar); 1272 loadSuccess = phoneFormat->load( calendar,mCalendar);
1273 1273
1274 } else 1274 } else
1275 return; 1275 return;
1276 if ( loadSuccess ) { 1276 if ( loadSuccess ) {
1277 getEventViewerDialog()->setSyncMode( true ); 1277 getEventViewerDialog()->setSyncMode( true );
1278 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); 1278 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
1279 getEventViewerDialog()->setSyncMode( false ); 1279 getEventViewerDialog()->setSyncMode( false );
1280 qApp->processEvents(); 1280 qApp->processEvents();
1281 if ( syncOK ) { 1281 if ( syncOK ) {
1282 if ( KOPrefs::instance()->mWriteBackFile ) 1282 if ( KOPrefs::instance()->mWriteBackFile )
1283 { 1283 {
1284 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1284 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1285 Incidence* inc = iL.first(); 1285 Incidence* inc = iL.first();
1286 if ( phoneFormat ) { 1286 if ( phoneFormat ) {
1287 while ( inc ) { 1287 while ( inc ) {
1288 inc->removeID(mCurrentSyncDevice); 1288 inc->removeID(mCurrentSyncDevice);
1289 inc = iL.next(); 1289 inc = iL.next();
1290 } 1290 }
1291 } 1291 }
1292#ifndef DESKTOP_VERSION 1292#ifndef DESKTOP_VERSION
1293 if ( sharpFormat ) 1293 if ( sharpFormat )
1294 sharpFormat->save(calendar); 1294 sharpFormat->save(calendar);
1295#endif 1295#endif
1296 if ( phoneFormat ) 1296 if ( phoneFormat )
1297 phoneFormat->save(calendar); 1297 phoneFormat->save(calendar);
1298 iL = calendar->rawIncidences(); 1298 iL = calendar->rawIncidences();
1299 inc = iL.first(); 1299 inc = iL.first();
1300 Incidence* loc; 1300 Incidence* loc;
1301 while ( inc ) { 1301 while ( inc ) {
1302 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1302 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1303 loc = mCalendar->incidence(inc->uid() ); 1303 loc = mCalendar->incidence(inc->uid() );
1304 if ( loc ) { 1304 if ( loc ) {
1305 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1305 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1306 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1306 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1307 } 1307 }
1308 } 1308 }
1309 inc = iL.next(); 1309 inc = iL.next();
1310 } 1310 }
1311 Incidence* lse = getLastSyncEvent(); 1311 Incidence* lse = getLastSyncEvent();
1312 if ( lse ) { 1312 if ( lse ) {
1313 lse->setReadOnly( false ); 1313 lse->setReadOnly( false );
1314 lse->setDescription( "" ); 1314 lse->setDescription( "" );
1315 lse->setReadOnly( true ); 1315 lse->setReadOnly( true );
1316 } 1316 }
1317 } 1317 }
1318 } 1318 }
1319 setModified( true ); 1319 setModified( true );
1320 } else { 1320 } else {
1321 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1321 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1322 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1322 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1323 question, i18n("Ok")) ; 1323 question, i18n("Ok")) ;
1324 1324
1325 } 1325 }
1326 delete calendar; 1326 delete calendar;
1327 updateView(); 1327 updateView();
1328 return ;//syncOK; 1328 return ;//syncOK;
1329 1329
1330} 1330}
1331void CalendarView::syncSharp() 1331void CalendarView::syncSharp()
1332{ 1332{
1333 syncExternal( 0 ); 1333 syncExternal( 0 );
1334 1334
1335} 1335}
1336 1336
1337 1337
1338//#include <kabc/stdaddressbook.h> 1338//#include <kabc/stdaddressbook.h>
1339bool CalendarView::importBday() 1339bool CalendarView::importBday()
1340{ 1340{
1341#if 0 1341#if 0
1342 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1342 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1343 KABC::AddressBook::Iterator it; 1343 KABC::AddressBook::Iterator it;
1344 int count = 0; 1344 int count = 0;
1345 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1345 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1346 ++count; 1346 ++count;
1347 } 1347 }
1348 QProgressBar bar(count,0 ); 1348 QProgressBar bar(count,0 );
1349 int w = 300; 1349 int w = 300;
1350 if ( QApplication::desktop()->width() < 320 ) 1350 if ( QApplication::desktop()->width() < 320 )
1351 w = 220; 1351 w = 220;
1352 int h = bar.sizeHint().height() ; 1352 int h = bar.sizeHint().height() ;
1353 int dw = QApplication::desktop()->width(); 1353 int dw = QApplication::desktop()->width();
1354 int dh = QApplication::desktop()->height(); 1354 int dh = QApplication::desktop()->height();
1355 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1355 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1356 bar.show(); 1356 bar.show();
1357 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1357 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1358 qApp->processEvents(); 1358 qApp->processEvents();
1359 count = 0; 1359 count = 0;
1360 int addCount = 0; 1360 int addCount = 0;
1361 KCal::Attendee* a = 0; 1361 KCal::Attendee* a = 0;
1362 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1362 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1363 if ( ! bar.isVisible() ) 1363 if ( ! bar.isVisible() )
1364 return false; 1364 return false;
1365 bar.setProgress( count++ ); 1365 bar.setProgress( count++ );
1366 qApp->processEvents(); 1366 qApp->processEvents();
1367 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1367 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1368 if ( (*it).birthday().date().isValid() ){ 1368 if ( (*it).birthday().date().isValid() ){
1369 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1369 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1370 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1370 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1371 ++addCount; 1371 ++addCount;
1372 } 1372 }
1373 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1373 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1374 if ( anni.isValid() ){ 1374 if ( anni.isValid() ){
1375 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1375 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1376 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1376 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1377 ++addCount; 1377 ++addCount;
1378 } 1378 }
1379 } 1379 }
1380 updateView(); 1380 updateView();
1381 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1381 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1382#endif 1382#endif
1383 return true; 1383 return true;
1384} 1384}
1385 1385
1386bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1386bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1387{ 1387{
1388 //qDebug("addAnni "); 1388 //qDebug("addAnni ");
1389 Event * ev = new Event(); 1389 Event * ev = new Event();
1390 if ( a ) { 1390 if ( a ) {
1391 ev->addAttendee( a ); 1391 ev->addAttendee( a );
1392 } 1392 }
1393 QString kind; 1393 QString kind;
1394 if ( birthday ) 1394 if ( birthday )
1395 kind = i18n( "Birthday" ); 1395 kind = i18n( "Birthday" );
1396 else 1396 else
1397 kind = i18n( "Anniversary" ); 1397 kind = i18n( "Anniversary" );
1398 ev->setSummary( name + " - " + kind ); 1398 ev->setSummary( name + " - " + kind );
1399 ev->setOrganizer( "nobody@nowhere" ); 1399 ev->setOrganizer( "nobody@nowhere" );
1400 ev->setCategories( kind ); 1400 ev->setCategories( kind );
1401 ev->setDtStart( QDateTime(date) ); 1401 ev->setDtStart( QDateTime(date) );
1402 ev->setDtEnd( QDateTime(date) ); 1402 ev->setDtEnd( QDateTime(date) );
1403 ev->setFloats( true ); 1403 ev->setFloats( true );
1404 Recurrence * rec = ev->recurrence(); 1404 Recurrence * rec = ev->recurrence();
1405 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1405 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1406 rec->addYearlyNum( date.month() ); 1406 rec->addYearlyNum( date.month() );
1407 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1407 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1408 delete ev; 1408 delete ev;
1409 return false; 1409 return false;
1410 } 1410 }
1411 return true; 1411 return true;
1412 1412
1413} 1413}
1414bool CalendarView::importQtopia( const QString &categories, 1414bool CalendarView::importQtopia( const QString &categories,
1415 const QString &datebook, 1415 const QString &datebook,
1416 const QString &todolist ) 1416 const QString &todolist )
1417{ 1417{
1418 1418
1419 QtopiaFormat qtopiaFormat; 1419 QtopiaFormat qtopiaFormat;
1420 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1420 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1421 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1421 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1422 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1422 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1423 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1423 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1424 1424
1425 updateView(); 1425 updateView();
1426 return true; 1426 return true;
1427 1427
1428#if 0 1428#if 0
1429 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1429 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1430 mCurrentSyncDevice = "qtopia-XML"; 1430 mCurrentSyncDevice = "qtopia-XML";
1431 if ( KOPrefs::instance()->mAskForPreferences ) 1431 if ( KOPrefs::instance()->mAskForPreferences )
1432 edit_sync_options(); 1432 edit_sync_options();
1433 qApp->processEvents(); 1433 qApp->processEvents();
1434 CalendarLocal* calendar = new CalendarLocal(); 1434 CalendarLocal* calendar = new CalendarLocal();
1435 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1435 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1436 bool syncOK = false; 1436 bool syncOK = false;
1437 QtopiaFormat qtopiaFormat; 1437 QtopiaFormat qtopiaFormat;
1438 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1438 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1439 bool loadOk = true; 1439 bool loadOk = true;
1440 if ( !categories.isEmpty() ) 1440 if ( !categories.isEmpty() )
1441 loadOk = qtopiaFormat.load( calendar, categories ); 1441 loadOk = qtopiaFormat.load( calendar, categories );
1442 if ( loadOk && !datebook.isEmpty() ) 1442 if ( loadOk && !datebook.isEmpty() )
1443 loadOk = qtopiaFormat.load( calendar, datebook ); 1443 loadOk = qtopiaFormat.load( calendar, datebook );
1444 if ( loadOk && !todolist.isEmpty() ) 1444 if ( loadOk && !todolist.isEmpty() )
1445 loadOk = qtopiaFormat.load( calendar, todolist ); 1445 loadOk = qtopiaFormat.load( calendar, todolist );
1446 1446
1447 if ( loadOk ) { 1447 if ( loadOk ) {
1448 getEventViewerDialog()->setSyncMode( true ); 1448 getEventViewerDialog()->setSyncMode( true );
1449 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); 1449 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
1450 getEventViewerDialog()->setSyncMode( false ); 1450 getEventViewerDialog()->setSyncMode( false );
1451 qApp->processEvents(); 1451 qApp->processEvents();
1452 if ( syncOK ) { 1452 if ( syncOK ) {
1453 if ( KOPrefs::instance()->mWriteBackFile ) 1453 if ( KOPrefs::instance()->mWriteBackFile )
1454 { 1454 {
1455 // write back XML file 1455 // write back XML file
1456 1456
1457 } 1457 }
1458 setModified( true ); 1458 setModified( true );
1459 } 1459 }
1460 } else { 1460 } else {
1461 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1461 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1462 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1462 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1463 question, i18n("Ok")) ; 1463 question, i18n("Ok")) ;
1464 } 1464 }
1465 delete calendar; 1465 delete calendar;
1466 updateView(); 1466 updateView();
1467 return syncOK; 1467 return syncOK;
1468 1468
1469 1469
1470#endif 1470#endif
1471 1471
1472} 1472}
1473 1473
1474void CalendarView::setSyncEventsReadOnly() 1474void CalendarView::setSyncEventsReadOnly()
1475{ 1475{
1476 Event * ev; 1476 Event * ev;
1477 QPtrList<Event> eL = mCalendar->rawEvents(); 1477 QPtrList<Event> eL = mCalendar->rawEvents();
1478 ev = eL.first(); 1478 ev = eL.first();
1479 while ( ev ) { 1479 while ( ev ) {
1480 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1480 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1481 ev->setReadOnly( true ); 1481 ev->setReadOnly( true );
1482 ev = eL.next(); 1482 ev = eL.next();
1483 } 1483 }
1484} 1484}
1485bool CalendarView::openCalendar(QString filename, bool merge) 1485bool CalendarView::openCalendar(QString filename, bool merge)
1486{ 1486{
1487 1487
1488 if (filename.isEmpty()) { 1488 if (filename.isEmpty()) {
1489 return false; 1489 return false;
1490 } 1490 }
1491 1491
1492 if (!QFile::exists(filename)) { 1492 if (!QFile::exists(filename)) {
1493 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1493 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1494 return false; 1494 return false;
1495 } 1495 }
1496 1496
1497 globalFlagBlockAgenda = 1; 1497 globalFlagBlockAgenda = 1;
1498 if (!merge) mCalendar->close(); 1498 if (!merge) mCalendar->close();
1499 1499
1500 mStorage->setFileName( filename ); 1500 mStorage->setFileName( filename );
1501 1501
1502 if ( mStorage->load() ) { 1502 if ( mStorage->load() ) {
1503 if ( merge ) ;//setModified( true ); 1503 if ( merge ) ;//setModified( true );
1504 else { 1504 else {
1505 //setModified( true ); 1505 //setModified( true );
1506 mViewManager->setDocumentId( filename ); 1506 mViewManager->setDocumentId( filename );
1507 mDialogManager->setDocumentId( filename ); 1507 mDialogManager->setDocumentId( filename );
1508 mTodoList->setDocumentId( filename ); 1508 mTodoList->setDocumentId( filename );
1509 } 1509 }
1510 globalFlagBlockAgenda = 2; 1510 globalFlagBlockAgenda = 2;
1511 // if ( getLastSyncEvent() ) 1511 // if ( getLastSyncEvent() )
1512 // getLastSyncEvent()->setReadOnly( true ); 1512 // getLastSyncEvent()->setReadOnly( true );
1513 mCalendar->reInitAlarmSettings(); 1513 mCalendar->reInitAlarmSettings();
1514 setSyncEventsReadOnly(); 1514 setSyncEventsReadOnly();
1515 updateUnmanagedViews(); 1515 updateUnmanagedViews();
1516 updateView(); 1516 updateView();
1517 loadedFileVersion = QDateTime::currentDateTime(); 1517 loadedFileVersion = QDateTime::currentDateTime();
1518 if ( filename != MainWindow::defaultFileName() ) { 1518 if ( filename != MainWindow::defaultFileName() ) {
1519 saveCalendar( MainWindow::defaultFileName() ); 1519 saveCalendar( MainWindow::defaultFileName() );
1520 watchSavedFile(); 1520 watchSavedFile();
1521 } 1521 }
1522 return true; 1522 return true;
1523 } else { 1523 } else {
1524 // while failing to load, the calendar object could 1524 // while failing to load, the calendar object could
1525 // have become partially populated. Clear it out. 1525 // have become partially populated. Clear it out.
1526 if ( !merge ) mCalendar->close(); 1526 if ( !merge ) {
1527 mCalendar->close();
1528 mViewManager->setDocumentId( filename );
1529 mDialogManager->setDocumentId( filename );
1530 mTodoList->setDocumentId( filename );
1531 }
1527 1532
1528 KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1533 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1529 1534
1535 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
1530 globalFlagBlockAgenda = 2; 1536 globalFlagBlockAgenda = 2;
1537 mCalendar->reInitAlarmSettings();
1538 setSyncEventsReadOnly();
1539 updateUnmanagedViews();
1531 updateView(); 1540 updateView();
1532 } 1541 }
1533 return false; 1542 return false;
1534} 1543}
1544void CalendarView::showOpenError()
1545{
1546 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
1547}
1535void CalendarView::setLoadedFileVersion(QDateTime dt) 1548void CalendarView::setLoadedFileVersion(QDateTime dt)
1536{ 1549{
1537 loadedFileVersion = dt; 1550 loadedFileVersion = dt;
1538} 1551}
1539bool CalendarView::checkFileChanged(QString fn) 1552bool CalendarView::checkFileChanged(QString fn)
1540{ 1553{
1541 QFileInfo finf ( fn ); 1554 QFileInfo finf ( fn );
1542 if ( !finf.exists() ) 1555 if ( !finf.exists() )
1543 return true; 1556 return true;
1544 QDateTime dt = finf.lastModified (); 1557 QDateTime dt = finf.lastModified ();
1545 if ( dt <= loadedFileVersion ) 1558 if ( dt <= loadedFileVersion )
1546 return false; 1559 return false;
1547 return true; 1560 return true;
1548 1561
1549} 1562}
1550void CalendarView::watchSavedFile() 1563void CalendarView::watchSavedFile()
1551{ 1564{
1552 QFileInfo finf ( MainWindow::defaultFileName()); 1565 QFileInfo finf ( MainWindow::defaultFileName());
1553 if ( !finf.exists() ) 1566 if ( !finf.exists() )
1554 return; 1567 return;
1555 QDateTime dt = finf.lastModified (); 1568 QDateTime dt = finf.lastModified ();
1556 if ( dt < loadedFileVersion ) { 1569 if ( dt < loadedFileVersion ) {
1557 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 1570 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1558 return; 1571 return;
1559 } 1572 }
1560 loadedFileVersion = dt; 1573 loadedFileVersion = dt;
1561} 1574}
1562 1575
1563bool CalendarView::checkFileVersion(QString fn) 1576bool CalendarView::checkFileVersion(QString fn)
1564{ 1577{
1565 QFileInfo finf ( fn ); 1578 QFileInfo finf ( fn );
1566 if ( !finf.exists() ) 1579 if ( !finf.exists() )
1567 return true; 1580 return true;
1568 QDateTime dt = finf.lastModified (); 1581 QDateTime dt = finf.lastModified ();
1569 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1582 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1570 //qDebug("file on disk version %s",dt.toString().latin1()); 1583 //qDebug("file on disk version %s",dt.toString().latin1());
1571 if ( dt <= loadedFileVersion ) 1584 if ( dt <= loadedFileVersion )
1572 return true; 1585 return true;
1573 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , 1586 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) ,
1574 i18n("KO/Pi Warning"),i18n("Overwrite"), 1587 i18n("KO/Pi Warning"),i18n("Overwrite"),
1575 i18n("Sync+save")); 1588 i18n("Sync+save"));
1576 1589
1577 if ( km == KMessageBox::Cancel ) 1590 if ( km == KMessageBox::Cancel )
1578 return false; 1591 return false;
1579 if ( km == KMessageBox::Yes ) 1592 if ( km == KMessageBox::Yes )
1580 return true; 1593 return true;
1581 1594
1582 setSyncDevice("deleteaftersync" ); 1595 setSyncDevice("deleteaftersync" );
1583 KOPrefs::instance()->mAskForPreferences = true; 1596 KOPrefs::instance()->mAskForPreferences = true;
1584 KOPrefs::instance()->mSyncAlgoPrefs = 3; 1597 KOPrefs::instance()->mSyncAlgoPrefs = 3;
1585 KOPrefs::instance()->mWriteBackFile = false; 1598 KOPrefs::instance()->mWriteBackFile = false;
1586 KOPrefs::instance()->mWriteBackExistingOnly = false; 1599 KOPrefs::instance()->mWriteBackExistingOnly = false;
1587 KOPrefs::instance()->mShowSyncSummary = false; 1600 KOPrefs::instance()->mShowSyncSummary = false;
1588 syncCalendar( fn, 3 ); 1601 syncCalendar( fn, 3 );
1589 Event * e = getLastSyncEvent(); 1602 Event * e = getLastSyncEvent();
1590 mCalendar->deleteEvent ( e ); 1603 mCalendar->deleteEvent ( e );
1591 updateView(); 1604 updateView();
1592 return true; 1605 return true;
1593} 1606}
1594 1607
1595bool CalendarView::saveCalendar( QString filename ) 1608bool CalendarView::saveCalendar( QString filename )
1596{ 1609{
1597 1610
1598 // Store back all unsaved data into calendar object 1611 // Store back all unsaved data into calendar object
1599 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1612 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1600 if ( mViewManager->currentView() ) 1613 if ( mViewManager->currentView() )
1601 mViewManager->currentView()->flushView(); 1614 mViewManager->currentView()->flushView();
1602 1615
1603 //mStorage->setFileName( filename ); 1616 //mStorage->setFileName( filename );
1604 1617
1605 mStorage->setSaveFormat( new ICalFormat() ); 1618 mStorage->setSaveFormat( new ICalFormat() );
1606 mStorage->setFileName( filename ); 1619 mStorage->setFileName( filename );
1607 bool success; 1620 bool success;
1608 success = mStorage->save(); 1621 success = mStorage->save();
1609 if ( !success ) { 1622 if ( !success ) {
1610 return false; 1623 return false;
1611 } 1624 }
1612 1625
1613 return true; 1626 return true;
1614} 1627}
1615 1628
1616void CalendarView::closeCalendar() 1629void CalendarView::closeCalendar()
1617{ 1630{
1618 1631
1619 // child windows no longer valid 1632 // child windows no longer valid
1620 emit closingDown(); 1633 emit closingDown();
1621 1634
1622 mCalendar->close(); 1635 mCalendar->close();
1623 setModified(false); 1636 setModified(false);
1624 updateView(); 1637 updateView();
1625} 1638}
1626 1639
1627void CalendarView::archiveCalendar() 1640void CalendarView::archiveCalendar()
1628{ 1641{
1629 mDialogManager->showArchiveDialog(); 1642 mDialogManager->showArchiveDialog();
1630} 1643}
1631 1644
1632 1645
1633void CalendarView::readSettings() 1646void CalendarView::readSettings()
1634{ 1647{
1635 1648
1636 1649
1637 // mViewManager->showAgendaView(); 1650 // mViewManager->showAgendaView();
1638 QString str; 1651 QString str;
1639 //qDebug("CalendarView::readSettings() "); 1652 //qDebug("CalendarView::readSettings() ");
1640 // read settings from the KConfig, supplying reasonable 1653 // read settings from the KConfig, supplying reasonable
1641 // defaults where none are to be found 1654 // defaults where none are to be found
1642 KConfig *config = KOGlobals::config(); 1655 KConfig *config = KOGlobals::config();
1643#ifndef KORG_NOSPLITTER 1656#ifndef KORG_NOSPLITTER
1644 config->setGroup("KOrganizer Geometry"); 1657 config->setGroup("KOrganizer Geometry");
1645 1658
1646 QValueList<int> sizes = config->readIntListEntry("Separator1"); 1659 QValueList<int> sizes = config->readIntListEntry("Separator1");
1647 if (sizes.count() != 2) { 1660 if (sizes.count() != 2) {
1648 sizes << mDateNavigator->minimumSizeHint().width(); 1661 sizes << mDateNavigator->minimumSizeHint().width();
1649 sizes << 300; 1662 sizes << 300;
1650 } 1663 }
1651 mPanner->setSizes(sizes); 1664 mPanner->setSizes(sizes);
1652 1665
1653 sizes = config->readIntListEntry("Separator2"); 1666 sizes = config->readIntListEntry("Separator2");
1654 if ( ( mResourceView && sizes.count() == 4 ) || 1667 if ( ( mResourceView && sizes.count() == 4 ) ||
1655 ( !mResourceView && sizes.count() == 3 ) ) { 1668 ( !mResourceView && sizes.count() == 3 ) ) {
1656 mLeftSplitter->setSizes(sizes); 1669 mLeftSplitter->setSizes(sizes);
1657 } 1670 }
1658#endif 1671#endif
1659 globalFlagBlockAgenda = 1; 1672 globalFlagBlockAgenda = 1;
1660 mViewManager->showAgendaView(); 1673 mViewManager->showAgendaView();
1661 //mViewManager->readSettings( config ); 1674 //mViewManager->readSettings( config );
1662 mTodoList->restoreLayout(config,QString("Todo Layout")); 1675 mTodoList->restoreLayout(config,QString("Todo Layout"));
1663 readFilterSettings(config); 1676 readFilterSettings(config);
1664 config->setGroup( "Views" ); 1677 config->setGroup( "Views" );
1665 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 1678 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
1666 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 1679 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
1667 else if ( dateCount == 7 ) mNavigator->selectWeek(); 1680 else if ( dateCount == 7 ) mNavigator->selectWeek();
1668 else mNavigator->selectDates( dateCount ); 1681 else mNavigator->selectDates( dateCount );
1669 // mViewManager->readSettings( config ); 1682 // mViewManager->readSettings( config );
1670 updateConfig(); 1683 updateConfig();
1671 globalFlagBlockAgenda = 2; 1684 globalFlagBlockAgenda = 2;
1672 mViewManager->readSettings( config ); 1685 mViewManager->readSettings( config );
1673#ifdef DESKTOP_VERSION 1686#ifdef DESKTOP_VERSION
1674 config->setGroup("WidgetLayout"); 1687 config->setGroup("WidgetLayout");
1675 QStringList list; 1688 QStringList list;
1676 list = config->readListEntry("MainLayout"); 1689 list = config->readListEntry("MainLayout");
1677 int x,y,w,h; 1690 int x,y,w,h;
1678 if ( ! list.isEmpty() ) { 1691 if ( ! list.isEmpty() ) {
1679 x = list[0].toInt(); 1692 x = list[0].toInt();
1680 y = list[1].toInt(); 1693 y = list[1].toInt();
1681 w = list[2].toInt(); 1694 w = list[2].toInt();
1682 h = list[3].toInt(); 1695 h = list[3].toInt();
1683 topLevelWidget()->setGeometry(x,y,w,h); 1696 topLevelWidget()->setGeometry(x,y,w,h);
1684 1697
1685 } else { 1698 } else {
1686 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 1699 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
1687 } 1700 }
1688 list = config->readListEntry("EditEventLayout"); 1701 list = config->readListEntry("EditEventLayout");
1689 if ( ! list.isEmpty() ) { 1702 if ( ! list.isEmpty() ) {
1690 x = list[0].toInt(); 1703 x = list[0].toInt();
1691 y = list[1].toInt(); 1704 y = list[1].toInt();
1692 w = list[2].toInt(); 1705 w = list[2].toInt();
1693 h = list[3].toInt(); 1706 h = list[3].toInt();
1694 mEventEditor->setGeometry(x,y,w,h); 1707 mEventEditor->setGeometry(x,y,w,h);
1695 1708
1696 } 1709 }
1697 list = config->readListEntry("EditTodoLayout"); 1710 list = config->readListEntry("EditTodoLayout");
1698 if ( ! list.isEmpty() ) { 1711 if ( ! list.isEmpty() ) {
1699 x = list[0].toInt(); 1712 x = list[0].toInt();
1700 y = list[1].toInt(); 1713 y = list[1].toInt();
1701 w = list[2].toInt(); 1714 w = list[2].toInt();
1702 h = list[3].toInt(); 1715 h = list[3].toInt();
1703 mTodoEditor->setGeometry(x,y,w,h); 1716 mTodoEditor->setGeometry(x,y,w,h);
1704 1717
1705 } 1718 }
1706 list = config->readListEntry("ViewerLayout"); 1719 list = config->readListEntry("ViewerLayout");
1707 if ( ! list.isEmpty() ) { 1720 if ( ! list.isEmpty() ) {
1708 x = list[0].toInt(); 1721 x = list[0].toInt();
1709 y = list[1].toInt(); 1722 y = list[1].toInt();
1710 w = list[2].toInt(); 1723 w = list[2].toInt();
1711 h = list[3].toInt(); 1724 h = list[3].toInt();
1712 getEventViewerDialog()->setGeometry(x,y,w,h); 1725 getEventViewerDialog()->setGeometry(x,y,w,h);
1713 } 1726 }
1714#endif 1727#endif
1715 1728
1716} 1729}
1717 1730
1718 1731
1719void CalendarView::writeSettings() 1732void CalendarView::writeSettings()
1720{ 1733{
1721 // kdDebug() << "CalendarView::writeSettings" << endl; 1734 // kdDebug() << "CalendarView::writeSettings" << endl;
1722 1735
1723 KConfig *config = KOGlobals::config(); 1736 KConfig *config = KOGlobals::config();
1724 1737
1725#ifndef KORG_NOSPLITTER 1738#ifndef KORG_NOSPLITTER
1726 config->setGroup("KOrganizer Geometry"); 1739 config->setGroup("KOrganizer Geometry");
1727 1740
1728 QValueList<int> list = mPanner->sizes(); 1741 QValueList<int> list = mPanner->sizes();
1729 config->writeEntry("Separator1",list); 1742 config->writeEntry("Separator1",list);
1730 1743
1731 list = mLeftSplitter->sizes(); 1744 list = mLeftSplitter->sizes();
1732 config->writeEntry("Separator2",list); 1745 config->writeEntry("Separator2",list);
1733#endif 1746#endif
1734 1747
1735 mViewManager->writeSettings( config ); 1748 mViewManager->writeSettings( config );
1736 mTodoList->saveLayout(config,QString("Todo Layout")); 1749 mTodoList->saveLayout(config,QString("Todo Layout"));
1737 mDialogManager->writeSettings( config ); 1750 mDialogManager->writeSettings( config );
1738 //KOPrefs::instance()->usrWriteConfig(); 1751 //KOPrefs::instance()->usrWriteConfig();
1739 KOPrefs::instance()->writeConfig(); 1752 KOPrefs::instance()->writeConfig();
1740 1753
1741 writeFilterSettings(config); 1754 writeFilterSettings(config);
1742 1755
1743 config->setGroup( "Views" ); 1756 config->setGroup( "Views" );
1744 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 1757 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
1745 1758
1746#ifdef DESKTOP_VERSION 1759#ifdef DESKTOP_VERSION
1747 config->setGroup("WidgetLayout"); 1760 config->setGroup("WidgetLayout");
1748 QStringList list ;//= config->readListEntry("MainLayout"); 1761 QStringList list ;//= config->readListEntry("MainLayout");
1749 int x,y,w,h; 1762 int x,y,w,h;
1750 QWidget* wid; 1763 QWidget* wid;
1751 wid = topLevelWidget(); 1764 wid = topLevelWidget();
1752 x = wid->geometry().x(); 1765 x = wid->geometry().x();
1753 y = wid->geometry().y(); 1766 y = wid->geometry().y();
1754 w = wid->width(); 1767 w = wid->width();
1755 h = wid->height(); 1768 h = wid->height();
1756 list.clear(); 1769 list.clear();
1757 list << QString::number( x ); 1770 list << QString::number( x );
1758 list << QString::number( y ); 1771 list << QString::number( y );
1759 list << QString::number( w ); 1772 list << QString::number( w );
1760 list << QString::number( h ); 1773 list << QString::number( h );
1761 config->writeEntry("MainLayout",list ); 1774 config->writeEntry("MainLayout",list );
1762 1775
1763 wid = mEventEditor; 1776 wid = mEventEditor;
1764 x = wid->geometry().x(); 1777 x = wid->geometry().x();
1765 y = wid->geometry().y(); 1778 y = wid->geometry().y();
1766 w = wid->width(); 1779 w = wid->width();
1767 h = wid->height(); 1780 h = wid->height();
1768 list.clear(); 1781 list.clear();
1769 list << QString::number( x ); 1782 list << QString::number( x );
1770 list << QString::number( y ); 1783 list << QString::number( y );
1771 list << QString::number( w ); 1784 list << QString::number( w );
1772 list << QString::number( h ); 1785 list << QString::number( h );
1773 config->writeEntry("EditEventLayout",list ); 1786 config->writeEntry("EditEventLayout",list );
1774 1787
1775 wid = mTodoEditor; 1788 wid = mTodoEditor;
1776 x = wid->geometry().x(); 1789 x = wid->geometry().x();
1777 y = wid->geometry().y(); 1790 y = wid->geometry().y();
1778 w = wid->width(); 1791 w = wid->width();
1779 h = wid->height(); 1792 h = wid->height();
1780 list.clear(); 1793 list.clear();
1781 list << QString::number( x ); 1794 list << QString::number( x );
1782 list << QString::number( y ); 1795 list << QString::number( y );
1783 list << QString::number( w ); 1796 list << QString::number( w );
1784 list << QString::number( h ); 1797 list << QString::number( h );
1785 config->writeEntry("EditTodoLayout",list ); 1798 config->writeEntry("EditTodoLayout",list );
1786 wid = getEventViewerDialog(); 1799 wid = getEventViewerDialog();
1787 x = wid->geometry().x(); 1800 x = wid->geometry().x();
1788 y = wid->geometry().y(); 1801 y = wid->geometry().y();
1789 w = wid->width(); 1802 w = wid->width();
1790 h = wid->height(); 1803 h = wid->height();
1791 list.clear(); 1804 list.clear();
1792 list << QString::number( x ); 1805 list << QString::number( x );
1793 list << QString::number( y ); 1806 list << QString::number( y );
1794 list << QString::number( w ); 1807 list << QString::number( w );
1795 list << QString::number( h ); 1808 list << QString::number( h );
1796 config->writeEntry("ViewerLayout",list ); 1809 config->writeEntry("ViewerLayout",list );
1797 wid = mDialogManager->getSearchDialog(); 1810 wid = mDialogManager->getSearchDialog();
1798 if ( wid ) { 1811 if ( wid ) {
1799 x = wid->geometry().x(); 1812 x = wid->geometry().x();
1800 y = wid->geometry().y(); 1813 y = wid->geometry().y();
1801 w = wid->width(); 1814 w = wid->width();
1802 h = wid->height(); 1815 h = wid->height();
1803 list.clear(); 1816 list.clear();
1804 list << QString::number( x ); 1817 list << QString::number( x );
1805 list << QString::number( y ); 1818 list << QString::number( y );
1806 list << QString::number( w ); 1819 list << QString::number( w );
1807 list << QString::number( h ); 1820 list << QString::number( h );
1808 config->writeEntry("SearchLayout",list ); 1821 config->writeEntry("SearchLayout",list );
1809 } 1822 }
1810#endif 1823#endif
1811 1824
1812 1825
1813 config->sync(); 1826 config->sync();
1814} 1827}
1815 1828
1816void CalendarView::readFilterSettings(KConfig *config) 1829void CalendarView::readFilterSettings(KConfig *config)
1817{ 1830{
1818 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 1831 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
1819 1832
1820 mFilters.clear(); 1833 mFilters.clear();
1821 1834
1822 config->setGroup("General"); 1835 config->setGroup("General");
1823 QStringList filterList = config->readListEntry("CalendarFilters"); 1836 QStringList filterList = config->readListEntry("CalendarFilters");
1824 1837
1825 QStringList::ConstIterator it = filterList.begin(); 1838 QStringList::ConstIterator it = filterList.begin();
1826 QStringList::ConstIterator end = filterList.end(); 1839 QStringList::ConstIterator end = filterList.end();
1827 while(it != end) { 1840 while(it != end) {
1828 // kdDebug() << " filter: " << (*it) << endl; 1841 // kdDebug() << " filter: " << (*it) << endl;
1829 1842
1830 CalFilter *filter; 1843 CalFilter *filter;
1831 filter = new CalFilter(*it); 1844 filter = new CalFilter(*it);
1832 config->setGroup("Filter_" + (*it)); 1845 config->setGroup("Filter_" + (*it));
1833 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 1846 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
1834 filter->setCriteria(config->readNumEntry("Criteria",0)); 1847 filter->setCriteria(config->readNumEntry("Criteria",0));
1835 filter->setCategoryList(config->readListEntry("CategoryList")); 1848 filter->setCategoryList(config->readListEntry("CategoryList"));
1836 mFilters.append(filter); 1849 mFilters.append(filter);
1837 1850
1838 ++it; 1851 ++it;
1839 } 1852 }
1840 1853
1841 if (mFilters.count() == 0) { 1854 if (mFilters.count() == 0) {
1842 CalFilter *filter = new CalFilter(i18n("Default")); 1855 CalFilter *filter = new CalFilter(i18n("Default"));
1843 mFilters.append(filter); 1856 mFilters.append(filter);
1844 } 1857 }
1845 mFilterView->updateFilters(); 1858 mFilterView->updateFilters();
1846 config->setGroup("FilterView"); 1859 config->setGroup("FilterView");
1847 1860
1848 mFilterView->blockSignals(true); 1861 mFilterView->blockSignals(true);
1849 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 1862 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
1850 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 1863 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
1851 mFilterView->blockSignals(false); 1864 mFilterView->blockSignals(false);
1852 // We do it manually to avoid it being done twice by the above calls 1865 // We do it manually to avoid it being done twice by the above calls
1853 updateFilter(); 1866 updateFilter();
1854} 1867}
1855 1868
1856void CalendarView::writeFilterSettings(KConfig *config) 1869void CalendarView::writeFilterSettings(KConfig *config)
1857{ 1870{
1858 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 1871 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
1859 1872
1860 QStringList filterList; 1873 QStringList filterList;
1861 1874
1862 CalFilter *filter = mFilters.first(); 1875 CalFilter *filter = mFilters.first();
1863 while(filter) { 1876 while(filter) {
1864 // kdDebug() << " fn: " << filter->name() << endl; 1877 // kdDebug() << " fn: " << filter->name() << endl;
1865 filterList << filter->name(); 1878 filterList << filter->name();
1866 config->setGroup("Filter_" + filter->name()); 1879 config->setGroup("Filter_" + filter->name());
1867 config->writeEntry("Criteria",filter->criteria()); 1880 config->writeEntry("Criteria",filter->criteria());
1868 config->writeEntry("CategoryList",filter->categoryList()); 1881 config->writeEntry("CategoryList",filter->categoryList());
1869 filter = mFilters.next(); 1882 filter = mFilters.next();
1870 } 1883 }
1871 config->setGroup("General"); 1884 config->setGroup("General");
1872 config->writeEntry("CalendarFilters",filterList); 1885 config->writeEntry("CalendarFilters",filterList);
1873 1886
1874 config->setGroup("FilterView"); 1887 config->setGroup("FilterView");
1875 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 1888 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
1876 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 1889 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
1877} 1890}
1878 1891
1879 1892
1880void CalendarView::goToday() 1893void CalendarView::goToday()
1881{ 1894{
1882 mNavigator->selectToday(); 1895 mNavigator->selectToday();
1883} 1896}
1884 1897
1885void CalendarView::goNext() 1898void CalendarView::goNext()
1886{ 1899{
1887 mNavigator->selectNext(); 1900 mNavigator->selectNext();
1888} 1901}
1889 1902
1890void CalendarView::goPrevious() 1903void CalendarView::goPrevious()
1891{ 1904{
1892 mNavigator->selectPrevious(); 1905 mNavigator->selectPrevious();
1893} 1906}
1894void CalendarView::goNextMonth() 1907void CalendarView::goNextMonth()
1895{ 1908{
1896 mNavigator->selectNextMonth(); 1909 mNavigator->selectNextMonth();
1897} 1910}
1898 1911
1899void CalendarView::goPreviousMonth() 1912void CalendarView::goPreviousMonth()
1900{ 1913{
1901 mNavigator->selectPreviousMonth(); 1914 mNavigator->selectPreviousMonth();
1902} 1915}
1903void CalendarView::writeLocale() 1916void CalendarView::writeLocale()
1904{ 1917{
1905 //KPimGlobalPrefs::instance()->setGlobalConfig(); 1918 //KPimGlobalPrefs::instance()->setGlobalConfig();
1906#if 0 1919#if 0
1907 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); 1920 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime );
1908 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); 1921 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday );
1909 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); 1922 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate );
1910 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); 1923 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage );
1911 QString dummy = KOPrefs::instance()->mUserDateFormatLong; 1924 QString dummy = KOPrefs::instance()->mUserDateFormatLong;
1912 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 1925 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
1913 dummy = KOPrefs::instance()->mUserDateFormatShort; 1926 dummy = KOPrefs::instance()->mUserDateFormatShort;
1914 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 1927 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
1915 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, 1928 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving,
1916 KOPrefs::instance()->mDaylightsavingStart, 1929 KOPrefs::instance()->mDaylightsavingStart,
1917 KOPrefs::instance()->mDaylightsavingEnd ); 1930 KOPrefs::instance()->mDaylightsavingEnd );
1918 KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId ); 1931 KGlobal::locale()->setTimezone( KOPrefs::instance()->mTimeZoneId );
1919#endif 1932#endif
1920} 1933}
1921void CalendarView::updateConfig() 1934void CalendarView::updateConfig()
1922{ 1935{
1923 writeLocale(); 1936 writeLocale();
1924 if ( KOPrefs::instance()->mUseAppColors ) 1937 if ( KOPrefs::instance()->mUseAppColors )
1925 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 1938 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
1926 emit configChanged(); 1939 emit configChanged();
1927 mTodoList->updateConfig(); 1940 mTodoList->updateConfig();
1928 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 1941 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
1929 mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1942 mCalendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1930 // To make the "fill window" configurations work 1943 // To make the "fill window" configurations work
1931 //mViewManager->raiseCurrentView(); 1944 //mViewManager->raiseCurrentView();
1932} 1945}
1933 1946
1934 1947
1935void CalendarView::eventChanged(Event *event) 1948void CalendarView::eventChanged(Event *event)
1936{ 1949{
1937 changeEventDisplay(event,KOGlobals::EVENTEDITED); 1950 changeEventDisplay(event,KOGlobals::EVENTEDITED);
1938 //updateUnmanagedViews(); 1951 //updateUnmanagedViews();
1939} 1952}
1940 1953
1941void CalendarView::eventAdded(Event *event) 1954void CalendarView::eventAdded(Event *event)
1942{ 1955{
1943 changeEventDisplay(event,KOGlobals::EVENTADDED); 1956 changeEventDisplay(event,KOGlobals::EVENTADDED);
1944} 1957}
1945 1958
1946void CalendarView::eventToBeDeleted(Event *) 1959void CalendarView::eventToBeDeleted(Event *)
1947{ 1960{
1948 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 1961 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
1949} 1962}
1950 1963
1951void CalendarView::eventDeleted() 1964void CalendarView::eventDeleted()
1952{ 1965{
1953 changeEventDisplay(0,KOGlobals::EVENTDELETED); 1966 changeEventDisplay(0,KOGlobals::EVENTDELETED);
1954} 1967}
1955void CalendarView::changeTodoDisplay(Todo *which, int action) 1968void CalendarView::changeTodoDisplay(Todo *which, int action)
1956{ 1969{
1957 changeIncidenceDisplay((Incidence *)which, action); 1970 changeIncidenceDisplay((Incidence *)which, action);
1958 mDateNavigator->updateView(); //LR 1971 mDateNavigator->updateView(); //LR
1959 //mDialogManager->updateSearchDialog(); 1972 //mDialogManager->updateSearchDialog();
1960 1973
1961 if (which) { 1974 if (which) {
1962 mViewManager->updateWNview(); 1975 mViewManager->updateWNview();
1963 //mTodoList->updateView(); 1976 //mTodoList->updateView();
1964 } 1977 }
1965 1978
1966} 1979}
1967 1980
1968void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 1981void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
1969{ 1982{
1970 updateUnmanagedViews(); 1983 updateUnmanagedViews();
1971 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 1984 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
1972 if ( action == KOGlobals::EVENTDELETED ) { //delete 1985 if ( action == KOGlobals::EVENTDELETED ) { //delete
1973 mCalendar->checkAlarmForIncidence( 0, true ); 1986 mCalendar->checkAlarmForIncidence( 0, true );
1974 if ( mEventViewerDialog ) 1987 if ( mEventViewerDialog )
1975 mEventViewerDialog->hide(); 1988 mEventViewerDialog->hide();
1976 } 1989 }
1977 else 1990 else
1978 mCalendar->checkAlarmForIncidence( which , false ); 1991 mCalendar->checkAlarmForIncidence( which , false );
1979} 1992}
1980 1993
1981// most of the changeEventDisplays() right now just call the view's 1994// most of the changeEventDisplays() right now just call the view's
1982// total update mode, but they SHOULD be recoded to be more refresh-efficient. 1995// total update mode, but they SHOULD be recoded to be more refresh-efficient.
1983void CalendarView::changeEventDisplay(Event *which, int action) 1996void CalendarView::changeEventDisplay(Event *which, int action)
1984{ 1997{
1985 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 1998 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
1986 changeIncidenceDisplay((Incidence *)which, action); 1999 changeIncidenceDisplay((Incidence *)which, action);
1987 mDateNavigator->updateView(); 2000 mDateNavigator->updateView();
1988 //mDialogManager->updateSearchDialog(); 2001 //mDialogManager->updateSearchDialog();
1989 2002
1990 if (which) { 2003 if (which) {
1991 // If there is an event view visible update the display 2004 // If there is an event view visible update the display
1992 mViewManager->currentView()->changeEventDisplay(which,action); 2005 mViewManager->currentView()->changeEventDisplay(which,action);
1993 // TODO: check, if update needed 2006 // TODO: check, if update needed
1994 // if (which->getTodoStatus()) { 2007 // if (which->getTodoStatus()) {
1995 mTodoList->updateView(); 2008 mTodoList->updateView();
1996 // } 2009 // }
1997 } else { 2010 } else {
1998 mViewManager->currentView()->updateView(); 2011 mViewManager->currentView()->updateView();
1999 } 2012 }
2000} 2013}
2001 2014
2002 2015
2003void CalendarView::updateTodoViews() 2016void CalendarView::updateTodoViews()
2004{ 2017{
2005 2018
2006 mTodoList->updateView(); 2019 mTodoList->updateView();
2007 mViewManager->currentView()->updateView(); 2020 mViewManager->currentView()->updateView();
2008 2021
2009} 2022}
2010 2023
2011 2024
2012void CalendarView::updateView(const QDate &start, const QDate &end) 2025void CalendarView::updateView(const QDate &start, const QDate &end)
2013{ 2026{
2014 mTodoList->updateView(); 2027 mTodoList->updateView();
2015 mViewManager->updateView(start, end); 2028 mViewManager->updateView(start, end);
2016 //mDateNavigator->updateView(); 2029 //mDateNavigator->updateView();
2017} 2030}
2018 2031
2019void CalendarView::updateView() 2032void CalendarView::updateView()
2020{ 2033{
2021 DateList tmpList = mNavigator->selectedDates(); 2034 DateList tmpList = mNavigator->selectedDates();
2022 2035
2023 // We assume that the navigator only selects consecutive days. 2036 // We assume that the navigator only selects consecutive days.
2024 updateView( tmpList.first(), tmpList.last() ); 2037 updateView( tmpList.first(), tmpList.last() );
2025} 2038}
2026 2039
2027void CalendarView::updateUnmanagedViews() 2040void CalendarView::updateUnmanagedViews()
2028{ 2041{
2029 mDateNavigator->updateDayMatrix(); 2042 mDateNavigator->updateDayMatrix();
2030} 2043}
2031 2044
2032int CalendarView::msgItemDelete() 2045int CalendarView::msgItemDelete()
2033{ 2046{
2034 return KMessageBox::warningContinueCancel(this, 2047 return KMessageBox::warningContinueCancel(this,
2035 i18n("This item will be\npermanently deleted."), 2048 i18n("This item will be\npermanently deleted."),
2036 i18n("KO/Pi Confirmation"),i18n("Delete")); 2049 i18n("KO/Pi Confirmation"),i18n("Delete"));
2037} 2050}
2038 2051
2039 2052
2040void CalendarView::edit_cut() 2053void CalendarView::edit_cut()
2041{ 2054{
2042 Event *anEvent=0; 2055 Event *anEvent=0;
2043 2056
2044 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2057 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2045 2058
2046 if (mViewManager->currentView()->isEventView()) { 2059 if (mViewManager->currentView()->isEventView()) {
2047 if ( incidence && incidence->type() == "Event" ) { 2060 if ( incidence && incidence->type() == "Event" ) {
2048 anEvent = static_cast<Event *>(incidence); 2061 anEvent = static_cast<Event *>(incidence);
2049 } 2062 }
2050 } 2063 }
2051 2064
2052 if (!anEvent) { 2065 if (!anEvent) {
2053 KNotifyClient::beep(); 2066 KNotifyClient::beep();
2054 return; 2067 return;
2055 } 2068 }
2056 DndFactory factory( mCalendar ); 2069 DndFactory factory( mCalendar );
2057 factory.cutEvent(anEvent); 2070 factory.cutEvent(anEvent);
2058 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2071 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2059} 2072}
2060 2073
2061void CalendarView::edit_copy() 2074void CalendarView::edit_copy()
2062{ 2075{
2063 Event *anEvent=0; 2076 Event *anEvent=0;
2064 2077
2065 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2078 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2066 2079
2067 if (mViewManager->currentView()->isEventView()) { 2080 if (mViewManager->currentView()->isEventView()) {
2068 if ( incidence && incidence->type() == "Event" ) { 2081 if ( incidence && incidence->type() == "Event" ) {
2069 anEvent = static_cast<Event *>(incidence); 2082 anEvent = static_cast<Event *>(incidence);
2070 } 2083 }
2071 } 2084 }
2072 2085
2073 if (!anEvent) { 2086 if (!anEvent) {
2074 KNotifyClient::beep(); 2087 KNotifyClient::beep();
2075 return; 2088 return;
2076 } 2089 }
2077 DndFactory factory( mCalendar ); 2090 DndFactory factory( mCalendar );
2078 factory.copyEvent(anEvent); 2091 factory.copyEvent(anEvent);
2079} 2092}
2080 2093
2081void CalendarView::edit_paste() 2094void CalendarView::edit_paste()
2082{ 2095{
2083 QDate date = mNavigator->selectedDates().first(); 2096 QDate date = mNavigator->selectedDates().first();
2084 2097
2085 DndFactory factory( mCalendar ); 2098 DndFactory factory( mCalendar );
2086 Event *pastedEvent = factory.pasteEvent( date ); 2099 Event *pastedEvent = factory.pasteEvent( date );
2087 2100
2088 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 2101 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
2089} 2102}
2090 2103
2091void CalendarView::edit_options() 2104void CalendarView::edit_options()
2092{ 2105{
2093 mDialogManager->showOptionsDialog(); 2106 mDialogManager->showOptionsDialog();
2094 //writeSettings(); 2107 //writeSettings();
2095} 2108}
2096void CalendarView::edit_sync_options() 2109void CalendarView::edit_sync_options()
2097{ 2110{
2098 //mDialogManager->showSyncOptions(); 2111 //mDialogManager->showSyncOptions();
2099 //KOPrefs::instance()->mSyncAlgoPrefs 2112 //KOPrefs::instance()->mSyncAlgoPrefs
2100 QDialog dia( this, "dia", true ); 2113 QDialog dia( this, "dia", true );
2101 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice ); 2114 dia.setCaption( i18n("Device: " ) +mCurrentSyncDevice );
2102 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia); 2115 QButtonGroup gr ( 1, Qt::Horizontal, i18n("Sync preferences"), &dia);
2103 QVBoxLayout lay ( &dia ); 2116 QVBoxLayout lay ( &dia );
2104 lay.setSpacing( 2 ); 2117 lay.setSpacing( 2 );
2105 lay.setMargin( 3 ); 2118 lay.setMargin( 3 );
2106 lay.addWidget(&gr); 2119 lay.addWidget(&gr);
2107 QRadioButton loc ( i18n("Take local entry on conflict"), &gr ); 2120 QRadioButton loc ( i18n("Take local entry on conflict"), &gr );
2108 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr ); 2121 QRadioButton rem ( i18n("Take remote entry on conflict"), &gr );
2109 QRadioButton newest( i18n("Take newest entry on conflict"), &gr ); 2122 QRadioButton newest( i18n("Take newest entry on conflict"), &gr );
2110 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr ); 2123 QRadioButton ask( i18n("Ask for every entry on conflict"), &gr );
2111 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr ); 2124 QRadioButton f_loc( i18n("Force: Take local entry always"), &gr );
2112 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr ); 2125 QRadioButton f_rem( i18n("Force: Take remote entry always"), &gr );
2113 //QRadioButton both( i18n("Take both on conflict"), &gr ); 2126 //QRadioButton both( i18n("Take both on conflict"), &gr );
2114 QPushButton pb ( "OK", &dia); 2127 QPushButton pb ( "OK", &dia);
2115 lay.addWidget( &pb ); 2128 lay.addWidget( &pb );
2116 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 2129 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
2117 switch ( KOPrefs::instance()->mSyncAlgoPrefs ) { 2130 switch ( KOPrefs::instance()->mSyncAlgoPrefs ) {
2118 case 0: 2131 case 0:
2119 loc.setChecked( true); 2132 loc.setChecked( true);
2120 break; 2133 break;
2121 case 1: 2134 case 1:
2122 rem.setChecked( true ); 2135 rem.setChecked( true );
2123 break; 2136 break;
2124 case 2: 2137 case 2:
2125 newest.setChecked( true); 2138 newest.setChecked( true);
2126 break; 2139 break;
2127 case 3: 2140 case 3:
2128 ask.setChecked( true); 2141 ask.setChecked( true);
2129 break; 2142 break;
2130 case 4: 2143 case 4:
2131 f_loc.setChecked( true); 2144 f_loc.setChecked( true);
2132 break; 2145 break;
2133 case 5: 2146 case 5:
2134 f_rem.setChecked( true); 2147 f_rem.setChecked( true);
2135 break; 2148 break;
2136 case 6: 2149 case 6:
2137 // both.setChecked( true); 2150 // both.setChecked( true);
2138 break; 2151 break;
2139 default: 2152 default:
2140 break; 2153 break;
2141 } 2154 }
2142 if ( dia.exec() ) { 2155 if ( dia.exec() ) {
2143 KOPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ; 2156 KOPrefs::instance()->mSyncAlgoPrefs = rem.isChecked()*1+newest.isChecked()*2+ ask.isChecked()*3+ f_loc.isChecked()*4+ f_rem.isChecked()*5;//+ both.isChecked()*6 ;
2144 } 2157 }
2145 2158
2146} 2159}
2147 2160
2148void CalendarView::slotSelectPickerDate( QDate d) 2161void CalendarView::slotSelectPickerDate( QDate d)
2149{ 2162{
2150 mDateFrame->hide(); 2163 mDateFrame->hide();
2151 if ( mDatePickerMode == 1 ) { 2164 if ( mDatePickerMode == 1 ) {
2152 mNavigator->slotDaySelect( d ); 2165 mNavigator->slotDaySelect( d );
2153 } else if ( mDatePickerMode == 2 ) { 2166 } else if ( mDatePickerMode == 2 ) {
2154 if ( mMoveIncidence->type() == "Todo" ) { 2167 if ( mMoveIncidence->type() == "Todo" ) {
2155 Todo * to = (Todo *) mMoveIncidence; 2168 Todo * to = (Todo *) mMoveIncidence;
2156 QTime tim; 2169 QTime tim;
2157 if ( to->hasDueDate() ) 2170 if ( to->hasDueDate() )
2158 tim = to->dtDue().time(); 2171 tim = to->dtDue().time();
2159 else { 2172 else {
2160 tim = QTime ( 0,0,0 ); 2173 tim = QTime ( 0,0,0 );
2161 to->setFloats( true ); 2174 to->setFloats( true );
2162 to->setHasDueDate( true ); 2175 to->setHasDueDate( true );
2163 } 2176 }
2164 QDateTime dt ( d,tim ); 2177 QDateTime dt ( d,tim );
2165 to->setDtDue( dt ); 2178 to->setDtDue( dt );
2166 todoChanged( to ); 2179 todoChanged( to );
2167 } else { 2180 } else {
2168 QTime tim = mMoveIncidence->dtStart().time(); 2181 QTime tim = mMoveIncidence->dtStart().time();
2169 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2182 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2170 QDateTime dt ( d,tim ); 2183 QDateTime dt ( d,tim );
2171 mMoveIncidence->setDtStart( dt ); 2184 mMoveIncidence->setDtStart( dt );
2172 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2185 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2173 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2186 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2174 } 2187 }
2175 2188
2176 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2189 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2177 } 2190 }
2178} 2191}
2179 2192
2180void CalendarView::removeCategories() 2193void CalendarView::removeCategories()
2181{ 2194{
2182 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2195 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2183 QStringList catList = KOPrefs::instance()->mCustomCategories; 2196 QStringList catList = KOPrefs::instance()->mCustomCategories;
2184 QStringList catIncList; 2197 QStringList catIncList;
2185 QStringList newCatList; 2198 QStringList newCatList;
2186 Incidence* inc = incList.first(); 2199 Incidence* inc = incList.first();
2187 int i; 2200 int i;
2188 int count = 0; 2201 int count = 0;
2189 while ( inc ) { 2202 while ( inc ) {
2190 newCatList.clear(); 2203 newCatList.clear();
2191 catIncList = inc->categories() ; 2204 catIncList = inc->categories() ;
2192 for( i = 0; i< catIncList.count(); ++i ) { 2205 for( i = 0; i< catIncList.count(); ++i ) {
2193 if ( catList.contains (catIncList[i])) 2206 if ( catList.contains (catIncList[i]))
2194 newCatList.append( catIncList[i] ); 2207 newCatList.append( catIncList[i] );
2195 } 2208 }
2196 newCatList.sort(); 2209 newCatList.sort();
2197 inc->setCategories( newCatList.join(",") ); 2210 inc->setCategories( newCatList.join(",") );
2198 inc = incList.next(); 2211 inc = incList.next();
2199 } 2212 }
2200} 2213}
2201 2214
2202int CalendarView::addCategories() 2215int CalendarView::addCategories()
2203{ 2216{
2204 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2217 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2205 QStringList catList = KOPrefs::instance()->mCustomCategories; 2218 QStringList catList = KOPrefs::instance()->mCustomCategories;
2206 QStringList catIncList; 2219 QStringList catIncList;
2207 Incidence* inc = incList.first(); 2220 Incidence* inc = incList.first();
2208 int i; 2221 int i;
2209 int count = 0; 2222 int count = 0;
2210 while ( inc ) { 2223 while ( inc ) {
2211 catIncList = inc->categories() ; 2224 catIncList = inc->categories() ;
2212 for( i = 0; i< catIncList.count(); ++i ) { 2225 for( i = 0; i< catIncList.count(); ++i ) {
2213 if ( !catList.contains (catIncList[i])) { 2226 if ( !catList.contains (catIncList[i])) {
2214 catList.append( catIncList[i] ); 2227 catList.append( catIncList[i] );
2215 //qDebug("add cat %s ", catIncList[i].latin1()); 2228 //qDebug("add cat %s ", catIncList[i].latin1());
2216 ++count; 2229 ++count;
2217 } 2230 }
2218 } 2231 }
2219 inc = incList.next(); 2232 inc = incList.next();
2220 } 2233 }
2221 catList.sort(); 2234 catList.sort();
2222 KOPrefs::instance()->mCustomCategories = catList; 2235 KOPrefs::instance()->mCustomCategories = catList;
2223 return count; 2236 return count;
2224} 2237}
2225 2238
2226void CalendarView::manageCategories() 2239void CalendarView::manageCategories()
2227{ 2240{
2228 KOCatPrefs* cp = new KOCatPrefs(); 2241 KOCatPrefs* cp = new KOCatPrefs();
2229 cp->show(); 2242 cp->show();
2230 int w =cp->sizeHint().width() ; 2243 int w =cp->sizeHint().width() ;
2231 int h = cp->sizeHint().height() ; 2244 int h = cp->sizeHint().height() ;
2232 int dw = QApplication::desktop()->width(); 2245 int dw = QApplication::desktop()->width();
2233 int dh = QApplication::desktop()->height(); 2246 int dh = QApplication::desktop()->height();
2234 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2247 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2235 if ( !cp->exec() ) { 2248 if ( !cp->exec() ) {
2236 delete cp; 2249 delete cp;
2237 return; 2250 return;
2238 } 2251 }
2239 int count = 0; 2252 int count = 0;
2240 if ( cp->addCat() ) { 2253 if ( cp->addCat() ) {
2241 count = addCategories(); 2254 count = addCategories();
2242 if ( count ) { 2255 if ( count ) {
2243 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2256 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2244 writeSettings(); 2257 writeSettings();
2245 } 2258 }
2246 } else { 2259 } else {
2247 removeCategories(); 2260 removeCategories();
2248 updateView(); 2261 updateView();
2249 } 2262 }
2250 delete cp; 2263 delete cp;
2251} 2264}
2252 2265
2253void CalendarView::beamIncidence(Incidence * Inc) 2266void CalendarView::beamIncidence(Incidence * Inc)
2254{ 2267{
2255 QPtrList<Incidence> delSel ; 2268 QPtrList<Incidence> delSel ;
2256 delSel.append(Inc); 2269 delSel.append(Inc);
2257 beamIncidenceList( delSel ); 2270 beamIncidenceList( delSel );
2258} 2271}
2259void CalendarView::beamCalendar() 2272void CalendarView::beamCalendar()
2260{ 2273{
2261 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2274 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2262 //qDebug("beamCalendar() "); 2275 //qDebug("beamCalendar() ");
2263 beamIncidenceList( delSel ); 2276 beamIncidenceList( delSel );
2264} 2277}
2265void CalendarView::beamFilteredCalendar() 2278void CalendarView::beamFilteredCalendar()
2266{ 2279{
2267 QPtrList<Incidence> delSel = mCalendar->incidences(); 2280 QPtrList<Incidence> delSel = mCalendar->incidences();
2268 //qDebug("beamFilteredCalendar() "); 2281 //qDebug("beamFilteredCalendar() ");
2269 beamIncidenceList( delSel ); 2282 beamIncidenceList( delSel );
2270} 2283}
2271void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2284void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2272{ 2285{
2273 if ( beamDialog->exec () == QDialog::Rejected ) 2286 if ( beamDialog->exec () == QDialog::Rejected )
2274 return; 2287 return;
2275 2288
2276 QString fn = "/tmp/kopibeamfile"; 2289 QString fn = "/tmp/kopibeamfile";
2277 QString mes; 2290 QString mes;
2278 bool createbup = true; 2291 bool createbup = true;
2279 if ( createbup ) { 2292 if ( createbup ) {
2280 QString description = "\n"; 2293 QString description = "\n";
2281 CalendarLocal* cal = new CalendarLocal(); 2294 CalendarLocal* cal = new CalendarLocal();
2282 if ( beamDialog->beamLocal() ) 2295 if ( beamDialog->beamLocal() )
2283 cal->setLocalTime(); 2296 cal->setLocalTime();
2284 else 2297 else
2285 cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 2298 cal->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
2286 Incidence *incidence = delSel.first(); 2299 Incidence *incidence = delSel.first();
2287 bool addText = false; 2300 bool addText = false;
2288 if ( delSel.count() < 10 ) 2301 if ( delSel.count() < 10 )
2289 addText = true; 2302 addText = true;
2290 else { 2303 else {
2291 description.sprintf(i18n(" %d items?"),delSel.count() ); 2304 description.sprintf(i18n(" %d items?"),delSel.count() );
2292 } 2305 }
2293 while ( incidence ) { 2306 while ( incidence ) {
2294 Incidence *in = incidence->clone(); 2307 Incidence *in = incidence->clone();
2295 if ( addText ) 2308 if ( addText )
2296 description += in->summary() + "\n"; 2309 description += in->summary() + "\n";
2297 cal->addIncidence( in ); 2310 cal->addIncidence( in );
2298 incidence = delSel.next(); 2311 incidence = delSel.next();
2299 } 2312 }
2300 if ( beamDialog->beamVcal() ) { 2313 if ( beamDialog->beamVcal() ) {
2301 fn += ".vcs"; 2314 fn += ".vcs";
2302 FileStorage storage( cal, fn, new VCalFormat ); 2315 FileStorage storage( cal, fn, new VCalFormat );
2303 storage.save(); 2316 storage.save();
2304 } else { 2317 } else {
2305 fn += ".ics"; 2318 fn += ".ics";
2306 FileStorage storage( cal, fn, new ICalFormat( ) ); 2319 FileStorage storage( cal, fn, new ICalFormat( ) );
2307 storage.save(); 2320 storage.save();
2308 } 2321 }
2309 delete cal; 2322 delete cal;
2310 mes = i18n("KO/Pi: Ready for beaming"); 2323 mes = i18n("KO/Pi: Ready for beaming");
2311 setCaption(mes); 2324 setCaption(mes);
2312 2325
2313#ifndef DESKTOP_VERSION 2326#ifndef DESKTOP_VERSION
2314 Ir *ir = new Ir( this ); 2327 Ir *ir = new Ir( this );
2315 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 2328 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2316 ir->send( fn, description, "text/x-vCalendar" ); 2329 ir->send( fn, description, "text/x-vCalendar" );
2317#endif 2330#endif
2318 } 2331 }
2319} 2332}
2320void CalendarView::beamDone( Ir *ir ) 2333void CalendarView::beamDone( Ir *ir )
2321{ 2334{
2322#ifndef DESKTOP_VERSION 2335#ifndef DESKTOP_VERSION
2323 delete ir; 2336 delete ir;
2324#endif 2337#endif
2325} 2338}
2326 2339
2327void CalendarView::moveIncidence(Incidence * inc ) 2340void CalendarView::moveIncidence(Incidence * inc )
2328{ 2341{
2329 if ( !inc ) return; 2342 if ( !inc ) return;
2330 // qDebug("showDatePickerForIncidence( ) "); 2343 // qDebug("showDatePickerForIncidence( ) ");
2331 if ( mDateFrame->isVisible() ) 2344 if ( mDateFrame->isVisible() )
2332 mDateFrame->hide(); 2345 mDateFrame->hide();
2333 else { 2346 else {
2334 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; 2347 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ;
2335 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; 2348 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ;
2336 int dw = QApplication::desktop()->width(); 2349 int dw = QApplication::desktop()->width();
2337 int dh = QApplication::desktop()->height(); 2350 int dh = QApplication::desktop()->height();
2338 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2351 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2339 mDateFrame->show(); 2352 mDateFrame->show();
2340 } 2353 }
2341 mDatePickerMode = 2; 2354 mDatePickerMode = 2;
2342 mMoveIncidence = inc ; 2355 mMoveIncidence = inc ;
2343 QDate da; 2356 QDate da;
2344 if ( mMoveIncidence->type() == "Todo" ) { 2357 if ( mMoveIncidence->type() == "Todo" ) {
2345 Todo * to = (Todo *) mMoveIncidence; 2358 Todo * to = (Todo *) mMoveIncidence;
2346 if ( to->hasDueDate() ) 2359 if ( to->hasDueDate() )
2347 da = to->dtDue().date(); 2360 da = to->dtDue().date();
2348 else 2361 else
2349 da = QDate::currentDate(); 2362 da = QDate::currentDate();
2350 } else { 2363 } else {
2351 da = mMoveIncidence->dtStart().date(); 2364 da = mMoveIncidence->dtStart().date();
2352 } 2365 }
2353 mDatePicker->setDate( da ); 2366 mDatePicker->setDate( da );
2354} 2367}
2355void CalendarView::showDatePicker( ) 2368void CalendarView::showDatePicker( )
2356{ 2369{
2357 //qDebug("CalendarView::showDatePicker( ) "); 2370 //qDebug("CalendarView::showDatePicker( ) ");
2358 if ( mDateFrame->isVisible() ) 2371 if ( mDateFrame->isVisible() )
2359 mDateFrame->hide(); 2372 mDateFrame->hide();
2360 else { 2373 else {
2361 int w =mDatePicker->sizeHint().width() ; 2374 int w =mDatePicker->sizeHint().width() ;
2362 int h = mDatePicker->sizeHint().height() ; 2375 int h = mDatePicker->sizeHint().height() ;
2363 int dw = QApplication::desktop()->width(); 2376 int dw = QApplication::desktop()->width();
2364 int dh = QApplication::desktop()->height(); 2377 int dh = QApplication::desktop()->height();
2365 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2378 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2366 mDateFrame->show(); 2379 mDateFrame->show();
2367 } 2380 }
2368 mDatePickerMode = 1; 2381 mDatePickerMode = 1;
2369 mDatePicker->setDate( mNavigator->selectedDates().first() ); 2382 mDatePicker->setDate( mNavigator->selectedDates().first() );
2370} 2383}
2371 2384
2372void CalendarView::showEventEditor() 2385void CalendarView::showEventEditor()
2373{ 2386{
2374#ifdef DESKTOP_VERSION 2387#ifdef DESKTOP_VERSION
2375 mEventEditor->show(); 2388 mEventEditor->show();
2376#else 2389#else
2377 mEventEditor->showMaximized(); 2390 mEventEditor->showMaximized();
2378#endif 2391#endif
2379} 2392}
2380void CalendarView::showTodoEditor() 2393void CalendarView::showTodoEditor()
2381{ 2394{
2382#ifdef DESKTOP_VERSION 2395#ifdef DESKTOP_VERSION
2383 mTodoEditor->show(); 2396 mTodoEditor->show();
2384#else 2397#else
2385 mTodoEditor->showMaximized(); 2398 mTodoEditor->showMaximized();
2386#endif 2399#endif
2387} 2400}
2388void CalendarView::cancelIncidence(Incidence * inc ) 2401void CalendarView::cancelIncidence(Incidence * inc )
2389{ 2402{
2390 inc->setCancelled( ! inc->cancelled() ); 2403 inc->setCancelled( ! inc->cancelled() );
2391 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 2404 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
2392 updateView(); 2405 updateView();
2393} 2406}
2394void CalendarView::cloneIncidence(Incidence * orgInc ) 2407void CalendarView::cloneIncidence(Incidence * orgInc )
2395{ 2408{
2396 Incidence * newInc = orgInc->clone(); 2409 Incidence * newInc = orgInc->clone();
2397 newInc->recreate(); 2410 newInc->recreate();
2398 2411
2399 if ( newInc->type() == "Todo" ) { 2412 if ( newInc->type() == "Todo" ) {
2400 Todo* t = (Todo*) newInc; 2413 Todo* t = (Todo*) newInc;
2401 mTodoEditor->editTodo( t ); 2414 mTodoEditor->editTodo( t );
2402 showTodoEditor(); 2415 showTodoEditor();
2403 if ( mTodoEditor->exec() ) { 2416 if ( mTodoEditor->exec() ) {
2404 mCalendar->addTodo( t ); 2417 mCalendar->addTodo( t );
2405 updateView(); 2418 updateView();
2406 } else { 2419 } else {
2407 delete t; 2420 delete t;
2408 } 2421 }
2409 } 2422 }
2410 else { 2423 else {
2411 Event* e = (Event*) newInc; 2424 Event* e = (Event*) newInc;
2412 mEventEditor->editEvent( e ); 2425 mEventEditor->editEvent( e );
2413 showEventEditor(); 2426 showEventEditor();
2414 if ( mEventEditor->exec() ) { 2427 if ( mEventEditor->exec() ) {
2415 mCalendar->addEvent( e ); 2428 mCalendar->addEvent( e );
2416 updateView(); 2429 updateView();
2417 } else { 2430 } else {
2418 delete e; 2431 delete e;
2419 } 2432 }
2420 } 2433 }
2421} 2434}
2422 2435
2423void CalendarView::newEvent() 2436void CalendarView::newEvent()
2424{ 2437{
2425 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 2438 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
2426 KOAgendaView *aView = mViewManager->agendaView(); 2439 KOAgendaView *aView = mViewManager->agendaView();
2427 if (aView) { 2440 if (aView) {
2428 if (aView->selectionStart().isValid()) { 2441 if (aView->selectionStart().isValid()) {
2429 if (aView->selectedIsAllDay()) { 2442 if (aView->selectedIsAllDay()) {
2430 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 2443 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
2431 } else { 2444 } else {
2432 newEvent(aView->selectionStart(),aView->selectionEnd()); 2445 newEvent(aView->selectionStart(),aView->selectionEnd());
2433 } 2446 }
2434 return; 2447 return;
2435 } 2448 }
2436 } 2449 }
2437 2450
2438 QDate date = mNavigator->selectedDates().first(); 2451 QDate date = mNavigator->selectedDates().first();
2439 QDateTime current = QDateTime::currentDateTime(); 2452 QDateTime current = QDateTime::currentDateTime();
2440 if ( date <= current.date() ) { 2453 if ( date <= current.date() ) {
2441 int hour = current.time().hour() +1; 2454 int hour = current.time().hour() +1;
2442 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 2455 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
2443 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2456 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2444 } else 2457 } else
2445 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 2458 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
2446 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 2459 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
2447 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2460 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2448} 2461}
2449 2462
2450void CalendarView::newEvent(QDateTime fh) 2463void CalendarView::newEvent(QDateTime fh)
2451{ 2464{
2452 newEvent(fh, 2465 newEvent(fh,
2453 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 2466 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
2454} 2467}
2455 2468
2456void CalendarView::newEvent(QDate dt) 2469void CalendarView::newEvent(QDate dt)
2457{ 2470{
2458 newEvent(QDateTime(dt, QTime(0,0,0)), 2471 newEvent(QDateTime(dt, QTime(0,0,0)),
2459 QDateTime(dt, QTime(0,0,0)), true); 2472 QDateTime(dt, QTime(0,0,0)), true);
2460} 2473}
2461 2474
2462void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 2475void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
2463{ 2476{
2464 2477
2465 mEventEditor->newEvent(fromHint,toHint,allDay); 2478 mEventEditor->newEvent(fromHint,toHint,allDay);
2466 if ( mFilterView->filtersEnabled() ) { 2479 if ( mFilterView->filtersEnabled() ) {
2467 CalFilter *filter = mFilterView->selectedFilter(); 2480 CalFilter *filter = mFilterView->selectedFilter();
2468 if (filter && filter->showCategories()) { 2481 if (filter && filter->showCategories()) {
2469 mEventEditor->setCategories(filter->categoryList().join(",") ); 2482 mEventEditor->setCategories(filter->categoryList().join(",") );
2470 } 2483 }
2471 if ( filter ) 2484 if ( filter )
2472 mEventEditor->setSecrecy( filter->getSecrecy() ); 2485 mEventEditor->setSecrecy( filter->getSecrecy() );
2473 } 2486 }
2474 showEventEditor(); 2487 showEventEditor();
2475} 2488}
2476void CalendarView::todoAdded(Todo * t) 2489void CalendarView::todoAdded(Todo * t)
2477{ 2490{
2478 2491
2479 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 2492 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
2480 updateTodoViews(); 2493 updateTodoViews();
2481} 2494}
2482void CalendarView::todoChanged(Todo * t) 2495void CalendarView::todoChanged(Todo * t)
2483{ 2496{
2484 emit todoModified( t, 4 ); 2497 emit todoModified( t, 4 );
2485 // updateTodoViews(); 2498 // updateTodoViews();
2486} 2499}
2487void CalendarView::todoToBeDeleted(Todo *) 2500void CalendarView::todoToBeDeleted(Todo *)
2488{ 2501{
2489 //qDebug("todoToBeDeleted(Todo *) "); 2502 //qDebug("todoToBeDeleted(Todo *) ");
2490 updateTodoViews(); 2503 updateTodoViews();
2491} 2504}
2492void CalendarView::todoDeleted() 2505void CalendarView::todoDeleted()
2493{ 2506{
2494 //qDebug(" todoDeleted()"); 2507 //qDebug(" todoDeleted()");
2495 updateTodoViews(); 2508 updateTodoViews();
2496} 2509}
2497 2510
2498 2511
2499 2512
2500void CalendarView::newTodo() 2513void CalendarView::newTodo()
2501{ 2514{
2502 2515
2503 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); 2516 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true);
2504 if ( mFilterView->filtersEnabled() ) { 2517 if ( mFilterView->filtersEnabled() ) {
2505 CalFilter *filter = mFilterView->selectedFilter(); 2518 CalFilter *filter = mFilterView->selectedFilter();
2506 if (filter && filter->showCategories()) { 2519 if (filter && filter->showCategories()) {
2507 mTodoEditor->setCategories(filter->categoryList().join(",") ); 2520 mTodoEditor->setCategories(filter->categoryList().join(",") );
2508 } 2521 }
2509 if ( filter ) 2522 if ( filter )
2510 mTodoEditor->setSecrecy( filter->getSecrecy() ); 2523 mTodoEditor->setSecrecy( filter->getSecrecy() );
2511 } 2524 }
2512 showTodoEditor(); 2525 showTodoEditor();
2513} 2526}
2514 2527
2515void CalendarView::newSubTodo() 2528void CalendarView::newSubTodo()
2516{ 2529{
2517 Todo *todo = selectedTodo(); 2530 Todo *todo = selectedTodo();
2518 if ( todo ) newSubTodo( todo ); 2531 if ( todo ) newSubTodo( todo );
2519} 2532}
2520 2533
2521void CalendarView::newSubTodo(Todo *parentEvent) 2534void CalendarView::newSubTodo(Todo *parentEvent)
2522{ 2535{
2523 2536
2524 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); 2537 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true);
2525 showTodoEditor(); 2538 showTodoEditor();
2526} 2539}
2527 2540
2528void CalendarView::newFloatingEvent() 2541void CalendarView::newFloatingEvent()
2529{ 2542{
2530 DateList tmpList = mNavigator->selectedDates(); 2543 DateList tmpList = mNavigator->selectedDates();
2531 QDate date = tmpList.first(); 2544 QDate date = tmpList.first();
2532 2545
2533 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 2546 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
2534 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 2547 QDateTime( date, QTime( 12, 0, 0 ) ), true );
2535} 2548}
2536 2549
2537 2550
2538void CalendarView::editEvent( Event *event ) 2551void CalendarView::editEvent( Event *event )
2539{ 2552{
2540 2553
2541 if ( !event ) return; 2554 if ( !event ) return;
2542 if ( event->isReadOnly() ) { 2555 if ( event->isReadOnly() ) {
2543 showEvent( event ); 2556 showEvent( event );
2544 return; 2557 return;
2545 } 2558 }
2546 mEventEditor->editEvent( event , mFlagEditDescription); 2559 mEventEditor->editEvent( event , mFlagEditDescription);
2547 showEventEditor(); 2560 showEventEditor();
2548} 2561}
2549void CalendarView::editJournal( Journal *jour ) 2562void CalendarView::editJournal( Journal *jour )
2550{ 2563{
2551 if ( !jour ) return; 2564 if ( !jour ) return;
2552 mDialogManager->hideSearchDialog(); 2565 mDialogManager->hideSearchDialog();
2553 mViewManager->showJournalView(); 2566 mViewManager->showJournalView();
2554 mNavigator->slotDaySelect( jour->dtStart().date() ); 2567 mNavigator->slotDaySelect( jour->dtStart().date() );
2555} 2568}
2556void CalendarView::editTodo( Todo *todo ) 2569void CalendarView::editTodo( Todo *todo )
2557{ 2570{
2558 if ( !todo ) return; 2571 if ( !todo ) return;
2559 2572
2560 if ( todo->isReadOnly() ) { 2573 if ( todo->isReadOnly() ) {
2561 showTodo( todo ); 2574 showTodo( todo );
2562 return; 2575 return;
2563 } 2576 }
2564 mTodoEditor->editTodo( todo ,mFlagEditDescription); 2577 mTodoEditor->editTodo( todo ,mFlagEditDescription);
2565 showTodoEditor(); 2578 showTodoEditor();
2566 2579
2567} 2580}
2568 2581
2569KOEventViewerDialog* CalendarView::getEventViewerDialog() 2582KOEventViewerDialog* CalendarView::getEventViewerDialog()
2570{ 2583{
2571 if ( !mEventViewerDialog ) { 2584 if ( !mEventViewerDialog ) {
2572 mEventViewerDialog = new KOEventViewerDialog(this); 2585 mEventViewerDialog = new KOEventViewerDialog(this);
2573 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 2586 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
2574 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 2587 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
2575 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 2588 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
2576 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 2589 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
2577 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 2590 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
2578 viewManager(), SLOT( showAgendaView( bool ) ) ); 2591 viewManager(), SLOT( showAgendaView( bool ) ) );
2579 mEventViewerDialog->resize( 640, 480 ); 2592 mEventViewerDialog->resize( 640, 480 );
2580 2593
2581 } 2594 }
2582 return mEventViewerDialog; 2595 return mEventViewerDialog;
2583} 2596}
2584void CalendarView::showEvent(Event *event) 2597void CalendarView::showEvent(Event *event)
2585{ 2598{
2586 getEventViewerDialog()->setEvent(event); 2599 getEventViewerDialog()->setEvent(event);
2587 getEventViewerDialog()->showMe(); 2600 getEventViewerDialog()->showMe();
2588} 2601}
2589 2602
2590void CalendarView::showTodo(Todo *event) 2603void CalendarView::showTodo(Todo *event)
2591{ 2604{
2592 getEventViewerDialog()->setTodo(event); 2605 getEventViewerDialog()->setTodo(event);
2593 getEventViewerDialog()->showMe(); 2606 getEventViewerDialog()->showMe();
2594} 2607}
2595void CalendarView::showJournal( Journal *jour ) 2608void CalendarView::showJournal( Journal *jour )
2596{ 2609{
2597 getEventViewerDialog()->setJournal(jour); 2610 getEventViewerDialog()->setJournal(jour);
2598 getEventViewerDialog()->showMe(); 2611 getEventViewerDialog()->showMe();
2599 2612
2600} 2613}
2601// void CalendarView::todoModified (Todo *event, int changed) 2614// void CalendarView::todoModified (Todo *event, int changed)
2602// { 2615// {
2603// // if (mDialogList.find (event) != mDialogList.end ()) { 2616// // if (mDialogList.find (event) != mDialogList.end ()) {
2604// // kdDebug() << "Todo modified and open" << endl; 2617// // kdDebug() << "Todo modified and open" << endl;
2605// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 2618// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
2606// // temp->modified (changed); 2619// // temp->modified (changed);
2607 2620
2608// // } 2621// // }
2609 2622
2610// mViewManager->updateView(); 2623// mViewManager->updateView();
2611// } 2624// }
2612 2625
2613void CalendarView::appointment_show() 2626void CalendarView::appointment_show()
2614{ 2627{
2615 Event *anEvent = 0; 2628 Event *anEvent = 0;
2616 2629
2617 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2630 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2618 2631
2619 if (mViewManager->currentView()->isEventView()) { 2632 if (mViewManager->currentView()->isEventView()) {
2620 if ( incidence && incidence->type() == "Event" ) { 2633 if ( incidence && incidence->type() == "Event" ) {
2621 anEvent = static_cast<Event *>(incidence); 2634 anEvent = static_cast<Event *>(incidence);
2622 } 2635 }
2623 } 2636 }
2624 2637
2625 if (!anEvent) { 2638 if (!anEvent) {
2626 KNotifyClient::beep(); 2639 KNotifyClient::beep();
2627 return; 2640 return;
2628 } 2641 }
2629 2642
2630 showEvent(anEvent); 2643 showEvent(anEvent);
2631} 2644}
2632 2645
2633void CalendarView::appointment_edit() 2646void CalendarView::appointment_edit()
2634{ 2647{
2635 Event *anEvent = 0; 2648 Event *anEvent = 0;
2636 2649
2637 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2650 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2638 2651
2639 if (mViewManager->currentView()->isEventView()) { 2652 if (mViewManager->currentView()->isEventView()) {
2640 if ( incidence && incidence->type() == "Event" ) { 2653 if ( incidence && incidence->type() == "Event" ) {
2641 anEvent = static_cast<Event *>(incidence); 2654 anEvent = static_cast<Event *>(incidence);
2642 } 2655 }
2643 } 2656 }
2644 2657
2645 if (!anEvent) { 2658 if (!anEvent) {
2646 KNotifyClient::beep(); 2659 KNotifyClient::beep();
2647 return; 2660 return;
2648 } 2661 }
2649 2662
2650 editEvent(anEvent); 2663 editEvent(anEvent);
2651} 2664}
2652 2665
2653void CalendarView::appointment_delete() 2666void CalendarView::appointment_delete()
2654{ 2667{
2655 Event *anEvent = 0; 2668 Event *anEvent = 0;
2656 2669
2657 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2670 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2658 2671
2659 if (mViewManager->currentView()->isEventView()) { 2672 if (mViewManager->currentView()->isEventView()) {
2660 if ( incidence && incidence->type() == "Event" ) { 2673 if ( incidence && incidence->type() == "Event" ) {
2661 anEvent = static_cast<Event *>(incidence); 2674 anEvent = static_cast<Event *>(incidence);
2662 } 2675 }
2663 } 2676 }
2664 2677
2665 if (!anEvent) { 2678 if (!anEvent) {
2666 KNotifyClient::beep(); 2679 KNotifyClient::beep();
2667 return; 2680 return;
2668 } 2681 }
2669 2682
2670 deleteEvent(anEvent); 2683 deleteEvent(anEvent);
2671} 2684}
2672 2685
2673void CalendarView::todo_unsub(Todo *anTodo ) 2686void CalendarView::todo_unsub(Todo *anTodo )
2674{ 2687{
2675 // Todo *anTodo = selectedTodo(); 2688 // Todo *anTodo = selectedTodo();
2676 if (!anTodo) return; 2689 if (!anTodo) return;
2677 if (!anTodo->relatedTo()) return; 2690 if (!anTodo->relatedTo()) return;
2678 anTodo->relatedTo()->removeRelation(anTodo); 2691 anTodo->relatedTo()->removeRelation(anTodo);
2679 anTodo->setRelatedTo(0); 2692 anTodo->setRelatedTo(0);
2680 anTodo->updated(); 2693 anTodo->updated();
2681 anTodo->setRelatedToUid(""); 2694 anTodo->setRelatedToUid("");
2682 setModified(true); 2695 setModified(true);
2683 updateView(); 2696 updateView();
2684} 2697}
2685 2698
2686void CalendarView::deleteTodo(Todo *todo) 2699void CalendarView::deleteTodo(Todo *todo)
2687{ 2700{
2688 if (!todo) { 2701 if (!todo) {
2689 KNotifyClient::beep(); 2702 KNotifyClient::beep();
2690 return; 2703 return;
2691 } 2704 }
2692 if (KOPrefs::instance()->mConfirm) { 2705 if (KOPrefs::instance()->mConfirm) {
2693 switch (msgItemDelete()) { 2706 switch (msgItemDelete()) {
2694 case KMessageBox::Continue: // OK 2707 case KMessageBox::Continue: // OK
2695 if (!todo->relations().isEmpty()) { 2708 if (!todo->relations().isEmpty()) {
2696 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), 2709 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."),
2697 i18n("Delete To-Do")); 2710 i18n("Delete To-Do"));
2698 } else { 2711 } else {
2699 checkExternalId( todo ); 2712 checkExternalId( todo );
2700 calendar()->deleteTodo(todo); 2713 calendar()->deleteTodo(todo);
2701 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2714 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2702 updateView(); 2715 updateView();
2703 } 2716 }
2704 break; 2717 break;
2705 } // switch 2718 } // switch
2706 } else { 2719 } else {
2707 if (!todo->relations().isEmpty()) { 2720 if (!todo->relations().isEmpty()) {
2708 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), 2721 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."),
2709 i18n("Delete To-Do")); 2722 i18n("Delete To-Do"));
2710 } else { 2723 } else {
2711 checkExternalId( todo ); 2724 checkExternalId( todo );
2712 mCalendar->deleteTodo(todo); 2725 mCalendar->deleteTodo(todo);
2713 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2726 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2714 updateView(); 2727 updateView();
2715 } 2728 }
2716 } 2729 }
2717 emit updateSearchDialog(); 2730 emit updateSearchDialog();
2718} 2731}
2719void CalendarView::deleteJournal(Journal *jour) 2732void CalendarView::deleteJournal(Journal *jour)
2720{ 2733{
2721 if (!jour) { 2734 if (!jour) {
2722 KNotifyClient::beep(); 2735 KNotifyClient::beep();
2723 return; 2736 return;
2724 } 2737 }
2725 if (KOPrefs::instance()->mConfirm) { 2738 if (KOPrefs::instance()->mConfirm) {
2726 switch (msgItemDelete()) { 2739 switch (msgItemDelete()) {
2727 case KMessageBox::Continue: // OK 2740 case KMessageBox::Continue: // OK
2728 calendar()->deleteJournal(jour); 2741 calendar()->deleteJournal(jour);
2729 updateView(); 2742 updateView();
2730 break; 2743 break;
2731 } // switch 2744 } // switch
2732 } else { 2745 } else {
2733 calendar()->deleteJournal(jour);; 2746 calendar()->deleteJournal(jour);;
2734 updateView(); 2747 updateView();
2735 } 2748 }
2736 emit updateSearchDialog(); 2749 emit updateSearchDialog();
2737} 2750}
2738 2751
2739void CalendarView::deleteEvent(Event *anEvent) 2752void CalendarView::deleteEvent(Event *anEvent)
2740{ 2753{
2741 if (!anEvent) { 2754 if (!anEvent) {
2742 KNotifyClient::beep(); 2755 KNotifyClient::beep();
2743 return; 2756 return;
2744 } 2757 }
2745 2758
2746 if (anEvent->recurrence()->doesRecur()) { 2759 if (anEvent->recurrence()->doesRecur()) {
2747 QDate itemDate = mViewManager->currentSelectionDate(); 2760 QDate itemDate = mViewManager->currentSelectionDate();
2748 int km; 2761 int km;
2749 if (!itemDate.isValid()) { 2762 if (!itemDate.isValid()) {
2750 //kdDebug() << "Date Not Valid" << endl; 2763 //kdDebug() << "Date Not Valid" << endl;
2751 if (KOPrefs::instance()->mConfirm) { 2764 if (KOPrefs::instance()->mConfirm) {
2752 km = KMessageBox::warningContinueCancel(this,anEvent->summary() + 2765 km = KMessageBox::warningContinueCancel(this,anEvent->summary() +
2753 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), 2766 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"),
2754 i18n("KO/Pi Confirmation"),i18n("Delete All")); 2767 i18n("KO/Pi Confirmation"),i18n("Delete All"));
2755 if ( km == KMessageBox::Continue ) 2768 if ( km == KMessageBox::Continue )
2756 km = KMessageBox::No; // No = all below 2769 km = KMessageBox::No; // No = all below
2757 } else 2770 } else
2758 km = KMessageBox::No; 2771 km = KMessageBox::No;
2759 } else { 2772 } else {
2760 km = KMessageBox::warningYesNoCancel(this,anEvent->summary() + 2773 km = KMessageBox::warningYesNoCancel(this,anEvent->summary() +
2761 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ 2774 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+
2762 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), 2775 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"),
2763 i18n("KO/Pi Confirmation"),i18n("Current"), 2776 i18n("KO/Pi Confirmation"),i18n("Current"),
2764 i18n("All")); 2777 i18n("All"));
2765 } 2778 }
2766 switch(km) { 2779 switch(km) {
2767 2780
2768 case KMessageBox::No: // Continue // all 2781 case KMessageBox::No: // Continue // all
2769 //qDebug("KMessageBox::No "); 2782 //qDebug("KMessageBox::No ");
2770 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2783 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2771 schedule(Scheduler::Cancel,anEvent); 2784 schedule(Scheduler::Cancel,anEvent);
2772 2785
2773 checkExternalId( anEvent); 2786 checkExternalId( anEvent);
2774 mCalendar->deleteEvent(anEvent); 2787 mCalendar->deleteEvent(anEvent);
2775 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); 2788 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED);
2776 break; 2789 break;
2777 2790
2778 // Disabled because it does not work 2791 // Disabled because it does not work
2779 //#if 0 2792 //#if 0
2780 case KMessageBox::Yes: // just this one 2793 case KMessageBox::Yes: // just this one
2781 //QDate qd = mNavigator->selectedDates().first(); 2794 //QDate qd = mNavigator->selectedDates().first();
2782 //if (!qd.isValid()) { 2795 //if (!qd.isValid()) {
2783 // kdDebug() << "no date selected, or invalid date" << endl; 2796 // kdDebug() << "no date selected, or invalid date" << endl;
2784 // KNotifyClient::beep(); 2797 // KNotifyClient::beep();
2785 // return; 2798 // return;
2786 //} 2799 //}
2787 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); 2800 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1);
2788 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { 2801 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) {
2789 anEvent->addExDate(itemDate); 2802 anEvent->addExDate(itemDate);
2790 int duration = anEvent->recurrence()->duration(); 2803 int duration = anEvent->recurrence()->duration();
2791 if ( duration > 0 ) { 2804 if ( duration > 0 ) {
2792 anEvent->recurrence()->setDuration( duration - 1 ); 2805 anEvent->recurrence()->setDuration( duration - 1 );
2793 } 2806 }
2794 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); 2807 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED);
2795 } 2808 }
2796 break; 2809 break;
2797 //#endif 2810 //#endif
2798 } // switch 2811 } // switch
2799 } else { 2812 } else {
2800 if (KOPrefs::instance()->mConfirm) { 2813 if (KOPrefs::instance()->mConfirm) {
2801 switch (KMessageBox::warningContinueCancel(this,anEvent->summary() + 2814 switch (KMessageBox::warningContinueCancel(this,anEvent->summary() +
2802 i18n("\nAre you sure you want\nto delete this event?"), 2815 i18n("\nAre you sure you want\nto delete this event?"),
2803 i18n("KO/Pi Confirmation"),i18n("Delete"))) { 2816 i18n("KO/Pi Confirmation"),i18n("Delete"))) {
2804 case KMessageBox::Continue: // OK 2817 case KMessageBox::Continue: // OK
2805 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2818 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2806 schedule(Scheduler::Cancel,anEvent); 2819 schedule(Scheduler::Cancel,anEvent);
2807 checkExternalId( anEvent); 2820 checkExternalId( anEvent);
2808 mCalendar->deleteEvent(anEvent); 2821 mCalendar->deleteEvent(anEvent);
2809 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2822 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2810 break; 2823 break;
2811 } // switch 2824 } // switch
2812 } else { 2825 } else {
2813 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2826 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2814 schedule(Scheduler::Cancel,anEvent); 2827 schedule(Scheduler::Cancel,anEvent);
2815 checkExternalId( anEvent); 2828 checkExternalId( anEvent);
2816 mCalendar->deleteEvent(anEvent); 2829 mCalendar->deleteEvent(anEvent);
2817 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2830 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2818 } 2831 }
2819 } // if-else 2832 } // if-else
2820 emit updateSearchDialog(); 2833 emit updateSearchDialog();
2821} 2834}
2822 2835
2823bool CalendarView::deleteEvent(const QString &uid) 2836bool CalendarView::deleteEvent(const QString &uid)
2824{ 2837{
2825 Event *ev = mCalendar->event(uid); 2838 Event *ev = mCalendar->event(uid);
2826 if (ev) { 2839 if (ev) {
2827 deleteEvent(ev); 2840 deleteEvent(ev);
2828 return true; 2841 return true;
2829 } else { 2842 } else {
2830 return false; 2843 return false;
2831 } 2844 }
2832} 2845}
2833 2846
2834/*****************************************************************************/ 2847/*****************************************************************************/
2835 2848
2836void CalendarView::action_mail() 2849void CalendarView::action_mail()
2837{ 2850{
2838#ifndef KORG_NOMAIL 2851#ifndef KORG_NOMAIL
2839 KOMailClient mailClient; 2852 KOMailClient mailClient;
2840 2853
2841 Incidence *incidence = currentSelection(); 2854 Incidence *incidence = currentSelection();
2842 2855
2843 if (!incidence) { 2856 if (!incidence) {
2844 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 2857 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
2845 return; 2858 return;
2846 } 2859 }
2847 if(incidence->attendeeCount() == 0 ) { 2860 if(incidence->attendeeCount() == 0 ) {
2848 KMessageBox::sorry(this, 2861 KMessageBox::sorry(this,
2849 i18n("Can't generate mail:\nNo attendees defined.\n")); 2862 i18n("Can't generate mail:\nNo attendees defined.\n"));
2850 return; 2863 return;
2851 } 2864 }
2852 2865
2853 CalendarLocal cal_tmp; 2866 CalendarLocal cal_tmp;
2854 Event *event = 0; 2867 Event *event = 0;
2855 Event *ev = 0; 2868 Event *ev = 0;
2856 if ( incidence && incidence->type() == "Event" ) { 2869 if ( incidence && incidence->type() == "Event" ) {
2857 event = static_cast<Event *>(incidence); 2870 event = static_cast<Event *>(incidence);
2858 ev = new Event(*event); 2871 ev = new Event(*event);
2859 cal_tmp.addEvent(ev); 2872 cal_tmp.addEvent(ev);
2860 } 2873 }
2861 ICalFormat mForm(); 2874 ICalFormat mForm();
2862 QString attachment = mForm.toString( &cal_tmp ); 2875 QString attachment = mForm.toString( &cal_tmp );
2863 if (ev) delete(ev); 2876 if (ev) delete(ev);
2864 2877
2865 mailClient.mailAttendees(currentSelection(), attachment); 2878 mailClient.mailAttendees(currentSelection(), attachment);
2866 2879
2867#endif 2880#endif
2868 2881
2869#if 0 2882#if 0
2870 Event *anEvent = 0; 2883 Event *anEvent = 0;
2871 if (mViewManager->currentView()->isEventView()) { 2884 if (mViewManager->currentView()->isEventView()) {
2872 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); 2885 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first());
2873 } 2886 }
2874 2887
2875 if (!anEvent) { 2888 if (!anEvent) {
2876 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 2889 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
2877 return; 2890 return;
2878 } 2891 }
2879 if(anEvent->attendeeCount() == 0 ) { 2892 if(anEvent->attendeeCount() == 0 ) {
2880 KMessageBox::sorry(this, 2893 KMessageBox::sorry(this,
2881 i18n("Can't generate mail:\nNo attendees defined.\n")); 2894 i18n("Can't generate mail:\nNo attendees defined.\n"));
2882 return; 2895 return;
2883 } 2896 }
2884 2897
2885 mailobject.emailEvent(anEvent); 2898 mailobject.emailEvent(anEvent);
2886#endif 2899#endif
2887} 2900}
2888 2901
2889 2902
2890void CalendarView::schedule_publish(Incidence *incidence) 2903void CalendarView::schedule_publish(Incidence *incidence)
2891{ 2904{
2892 Event *event = 0; 2905 Event *event = 0;
2893 Todo *todo = 0; 2906 Todo *todo = 0;
2894 2907
2895 if (incidence == 0) { 2908 if (incidence == 0) {
2896 incidence = mViewManager->currentView()->selectedIncidences().first(); 2909 incidence = mViewManager->currentView()->selectedIncidences().first();
2897 if (incidence == 0) { 2910 if (incidence == 0) {
2898 incidence = mTodoList->selectedIncidences().first(); 2911 incidence = mTodoList->selectedIncidences().first();
2899 } 2912 }
2900 } 2913 }
2901 if ( incidence && incidence->type() == "Event" ) { 2914 if ( incidence && incidence->type() == "Event" ) {
2902 event = static_cast<Event *>(incidence); 2915 event = static_cast<Event *>(incidence);
2903 } else { 2916 } else {
2904 if ( incidence && incidence->type() == "Todo" ) { 2917 if ( incidence && incidence->type() == "Todo" ) {
2905 todo = static_cast<Todo *>(incidence); 2918 todo = static_cast<Todo *>(incidence);
2906 } 2919 }
2907 } 2920 }
2908 2921
2909 if (!event && !todo) { 2922 if (!event && !todo) {
2910 KMessageBox::sorry(this,i18n("No event selected.")); 2923 KMessageBox::sorry(this,i18n("No event selected."));
2911 return; 2924 return;
2912 } 2925 }
2913 2926
2914 PublishDialog *publishdlg = new PublishDialog(); 2927 PublishDialog *publishdlg = new PublishDialog();
2915 if (incidence->attendeeCount()>0) { 2928 if (incidence->attendeeCount()>0) {
2916 QPtrList<Attendee> attendees = incidence->attendees(); 2929 QPtrList<Attendee> attendees = incidence->attendees();
2917 attendees.first(); 2930 attendees.first();
2918 while ( attendees.current()!=0 ) { 2931 while ( attendees.current()!=0 ) {
2919 publishdlg->addAttendee(attendees.current()); 2932 publishdlg->addAttendee(attendees.current());
2920 attendees.next(); 2933 attendees.next();
2921 } 2934 }
2922 } 2935 }
2923 bool send = true; 2936 bool send = true;
2924 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { 2937 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) {
2925 if ( publishdlg->exec() != QDialog::Accepted ) 2938 if ( publishdlg->exec() != QDialog::Accepted )
2926 send = false; 2939 send = false;
2927 } 2940 }
2928 if ( send ) { 2941 if ( send ) {
2929 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 2942 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
2930 if ( event ) { 2943 if ( event ) {
2931 Event *ev = new Event(*event); 2944 Event *ev = new Event(*event);
2932 ev->registerObserver(0); 2945 ev->registerObserver(0);
2933 ev->clearAttendees(); 2946 ev->clearAttendees();
2934 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 2947 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
2935 delete(ev); 2948 delete(ev);
2936 } 2949 }
2937 } else { 2950 } else {
2938 if ( todo ) { 2951 if ( todo ) {
2939 Todo *ev = new Todo(*todo); 2952 Todo *ev = new Todo(*todo);
2940 ev->registerObserver(0); 2953 ev->registerObserver(0);
2941 ev->clearAttendees(); 2954 ev->clearAttendees();
2942 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 2955 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
2943 delete(ev); 2956 delete(ev);
2944 } 2957 }
2945 } 2958 }
2946 } 2959 }
2947 } 2960 }
2948 delete publishdlg; 2961 delete publishdlg;
2949} 2962}
2950 2963
2951void CalendarView::schedule_request(Incidence *incidence) 2964void CalendarView::schedule_request(Incidence *incidence)
2952{ 2965{
2953 schedule(Scheduler::Request,incidence); 2966 schedule(Scheduler::Request,incidence);
2954} 2967}
2955 2968
2956void CalendarView::schedule_refresh(Incidence *incidence) 2969void CalendarView::schedule_refresh(Incidence *incidence)
2957{ 2970{
2958 schedule(Scheduler::Refresh,incidence); 2971 schedule(Scheduler::Refresh,incidence);
2959} 2972}
2960 2973
2961void CalendarView::schedule_cancel(Incidence *incidence) 2974void CalendarView::schedule_cancel(Incidence *incidence)
2962{ 2975{
2963 schedule(Scheduler::Cancel,incidence); 2976 schedule(Scheduler::Cancel,incidence);
2964} 2977}
2965 2978
2966void CalendarView::schedule_add(Incidence *incidence) 2979void CalendarView::schedule_add(Incidence *incidence)
2967{ 2980{
2968 schedule(Scheduler::Add,incidence); 2981 schedule(Scheduler::Add,incidence);
2969} 2982}
2970 2983
2971void CalendarView::schedule_reply(Incidence *incidence) 2984void CalendarView::schedule_reply(Incidence *incidence)
2972{ 2985{
2973 schedule(Scheduler::Reply,incidence); 2986 schedule(Scheduler::Reply,incidence);
2974} 2987}
2975 2988
2976void CalendarView::schedule_counter(Incidence *incidence) 2989void CalendarView::schedule_counter(Incidence *incidence)
2977{ 2990{
2978 schedule(Scheduler::Counter,incidence); 2991 schedule(Scheduler::Counter,incidence);
2979} 2992}
2980 2993
2981void CalendarView::schedule_declinecounter(Incidence *incidence) 2994void CalendarView::schedule_declinecounter(Incidence *incidence)
2982{ 2995{
2983 schedule(Scheduler::Declinecounter,incidence); 2996 schedule(Scheduler::Declinecounter,incidence);
2984} 2997}
2985 2998
2986void CalendarView::schedule_publish_freebusy(int daysToPublish) 2999void CalendarView::schedule_publish_freebusy(int daysToPublish)
2987{ 3000{
2988 QDateTime start = QDateTime::currentDateTime(); 3001 QDateTime start = QDateTime::currentDateTime();
2989 QDateTime end = start.addDays(daysToPublish); 3002 QDateTime end = start.addDays(daysToPublish);
2990 3003
2991 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); 3004 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end);
2992 freebusy->setOrganizer(KOPrefs::instance()->email()); 3005 freebusy->setOrganizer(KOPrefs::instance()->email());
2993 3006
2994 3007
2995 PublishDialog *publishdlg = new PublishDialog(); 3008 PublishDialog *publishdlg = new PublishDialog();
2996 if ( publishdlg->exec() == QDialog::Accepted ) { 3009 if ( publishdlg->exec() == QDialog::Accepted ) {
2997 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3010 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
2998 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { 3011 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) {
2999 delete(freebusy); 3012 delete(freebusy);
3000 } 3013 }
3001 } 3014 }
3002 delete publishdlg; 3015 delete publishdlg;
3003} 3016}
3004 3017
3005void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) 3018void CalendarView::schedule(Scheduler::Method method, Incidence *incidence)
3006{ 3019{
3007 Event *event = 0; 3020 Event *event = 0;
3008 Todo *todo = 0; 3021 Todo *todo = 0;
3009 3022
3010 if (incidence == 0) { 3023 if (incidence == 0) {
3011 incidence = mViewManager->currentView()->selectedIncidences().first(); 3024 incidence = mViewManager->currentView()->selectedIncidences().first();
3012 if (incidence == 0) { 3025 if (incidence == 0) {
3013 incidence = mTodoList->selectedIncidences().first(); 3026 incidence = mTodoList->selectedIncidences().first();
3014 } 3027 }
3015 } 3028 }
3016 if ( incidence && incidence->type() == "Event" ) { 3029 if ( incidence && incidence->type() == "Event" ) {
3017 event = static_cast<Event *>(incidence); 3030 event = static_cast<Event *>(incidence);
3018 } 3031 }
3019 if ( incidence && incidence->type() == "Todo" ) { 3032 if ( incidence && incidence->type() == "Todo" ) {
3020 todo = static_cast<Todo *>(incidence); 3033 todo = static_cast<Todo *>(incidence);
3021 } 3034 }
3022 3035
3023 if (!event && !todo) { 3036 if (!event && !todo) {
3024 KMessageBox::sorry(this,i18n("No event selected.")); 3037 KMessageBox::sorry(this,i18n("No event selected."));
3025 return; 3038 return;
3026 } 3039 }
3027 3040
3028 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { 3041 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) {
3029 KMessageBox::sorry(this,i18n("The event has no attendees.")); 3042 KMessageBox::sorry(this,i18n("The event has no attendees."));
3030 return; 3043 return;
3031 } 3044 }
3032 3045
3033 Event *ev = 0; 3046 Event *ev = 0;
3034 if (event) ev = new Event(*event); 3047 if (event) ev = new Event(*event);
3035 Todo *to = 0; 3048 Todo *to = 0;
3036 if (todo) to = new Todo(*todo); 3049 if (todo) to = new Todo(*todo);
3037 3050
3038 if (method == Scheduler::Reply || method == Scheduler::Refresh) { 3051 if (method == Scheduler::Reply || method == Scheduler::Refresh) {
3039 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 3052 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
3040 if (!me) { 3053 if (!me) {
3041 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); 3054 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails."));
3042 return; 3055 return;
3043 } 3056 }
3044 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { 3057 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) {
3045 StatusDialog *statdlg = new StatusDialog(this); 3058 StatusDialog *statdlg = new StatusDialog(this);
3046 if (!statdlg->exec()==QDialog::Accepted) return; 3059 if (!statdlg->exec()==QDialog::Accepted) return;
3047 me->setStatus( statdlg->status() ); 3060 me->setStatus( statdlg->status() );
3048 delete(statdlg); 3061 delete(statdlg);
3049 } 3062 }
3050 Attendee *menew = new Attendee(*me); 3063 Attendee *menew = new Attendee(*me);
3051 if (ev) { 3064 if (ev) {
3052 ev->clearAttendees(); 3065 ev->clearAttendees();
3053 ev->addAttendee(menew,false); 3066 ev->addAttendee(menew,false);
3054 } else { 3067 } else {
3055 if (to) { 3068 if (to) {
3056 todo->clearAttendees(); 3069 todo->clearAttendees();
3057 todo->addAttendee(menew,false); 3070 todo->addAttendee(menew,false);
3058 } 3071 }
3059 } 3072 }
3060 } 3073 }
3061 3074
3062 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3075 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3063 if (ev) { 3076 if (ev) {
3064 if ( !dlg->addMessage(ev,method) ) delete(ev); 3077 if ( !dlg->addMessage(ev,method) ) delete(ev);
3065 } else { 3078 } else {
3066 if (to) { 3079 if (to) {
3067 if ( !dlg->addMessage(to,method) ) delete(to); 3080 if ( !dlg->addMessage(to,method) ) delete(to);
3068 } 3081 }
3069 } 3082 }
3070} 3083}
3071 3084
3072void CalendarView::openAddressbook() 3085void CalendarView::openAddressbook()
3073{ 3086{
3074 KRun::runCommand("kaddressbook"); 3087 KRun::runCommand("kaddressbook");
3075} 3088}
3076 3089
3077void CalendarView::setModified(bool modified) 3090void CalendarView::setModified(bool modified)
3078{ 3091{
3079 if ( modified ) 3092 if ( modified )
3080 emit signalmodified(); 3093 emit signalmodified();
3081 if (mModified != modified) { 3094 if (mModified != modified) {
3082 mModified = modified; 3095 mModified = modified;
3083 emit modifiedChanged(mModified); 3096 emit modifiedChanged(mModified);
3084 } 3097 }
3085} 3098}
3086 3099
3087bool CalendarView::isReadOnly() 3100bool CalendarView::isReadOnly()
3088{ 3101{
3089 return mReadOnly; 3102 return mReadOnly;
3090} 3103}
3091 3104
3092void CalendarView::setReadOnly(bool readOnly) 3105void CalendarView::setReadOnly(bool readOnly)
3093{ 3106{
3094 if (mReadOnly != readOnly) { 3107 if (mReadOnly != readOnly) {
3095 mReadOnly = readOnly; 3108 mReadOnly = readOnly;
3096 emit readOnlyChanged(mReadOnly); 3109 emit readOnlyChanged(mReadOnly);
3097 } 3110 }
3098} 3111}
3099 3112
3100bool CalendarView::isModified() 3113bool CalendarView::isModified()
3101{ 3114{
3102 return mModified; 3115 return mModified;
3103} 3116}
3104 3117
3105void CalendarView::printSetup() 3118void CalendarView::printSetup()
3106{ 3119{
3107#ifndef KORG_NOPRINTER 3120#ifndef KORG_NOPRINTER
3108 createPrinter(); 3121 createPrinter();
3109 3122
3110 mCalPrinter->setupPrinter(); 3123 mCalPrinter->setupPrinter();
3111#endif 3124#endif
3112} 3125}
3113 3126
3114void CalendarView::print() 3127void CalendarView::print()
3115{ 3128{
3116#ifndef KORG_NOPRINTER 3129#ifndef KORG_NOPRINTER
3117 createPrinter(); 3130 createPrinter();
3118 3131
3119 DateList tmpDateList = mNavigator->selectedDates(); 3132 DateList tmpDateList = mNavigator->selectedDates();
3120 mCalPrinter->print(CalPrinter::Month, 3133 mCalPrinter->print(CalPrinter::Month,
3121 tmpDateList.first(), tmpDateList.last()); 3134 tmpDateList.first(), tmpDateList.last());
3122#endif 3135#endif
3123} 3136}
3124 3137
3125void CalendarView::printPreview() 3138void CalendarView::printPreview()
3126{ 3139{
3127#ifndef KORG_NOPRINTER 3140#ifndef KORG_NOPRINTER
3128 kdDebug() << "CalendarView::printPreview()" << endl; 3141 kdDebug() << "CalendarView::printPreview()" << endl;
3129 3142
3130 createPrinter(); 3143 createPrinter();
3131 3144
3132 DateList tmpDateList = mNavigator->selectedDates(); 3145 DateList tmpDateList = mNavigator->selectedDates();
3133 3146
3134 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), 3147 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(),
3135 tmpDateList.last()); 3148 tmpDateList.last());
3136#endif 3149#endif
3137} 3150}
3138 3151
3139void CalendarView::exportICalendar() 3152void CalendarView::exportICalendar()
3140{ 3153{
3141 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); 3154 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this);
3142 3155
3143 // Force correct extension 3156 // Force correct extension
3144 if (filename.right(4) != ".ics") filename += ".ics"; 3157 if (filename.right(4) != ".ics") filename += ".ics";
3145 3158
3146 FileStorage storage( mCalendar, filename, new ICalFormat() ); 3159 FileStorage storage( mCalendar, filename, new ICalFormat() );
3147 storage.save(); 3160 storage.save();
3148} 3161}
3149 3162
3150bool CalendarView::exportVCalendar( QString filename ) 3163bool CalendarView::exportVCalendar( QString filename )
3151{ 3164{
3152 if (mCalendar->journals().count() > 0) { 3165 if (mCalendar->journals().count() > 0) {
3153 int result = KMessageBox::warningContinueCancel(this, 3166 int result = KMessageBox::warningContinueCancel(this,
3154 i18n("The journal entries can not be\nexported to a vCalendar file."), 3167 i18n("The journal entries can not be\nexported to a vCalendar file."),
3155 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 3168 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
3156 true); 3169 true);
3157 if (result != KMessageBox::Continue) return false; 3170 if (result != KMessageBox::Continue) return false;
3158 } 3171 }
3159 3172
3160 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); 3173 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this);
3161 3174
3162 // Force correct extension 3175 // Force correct extension
3163 if (filename.right(4) != ".vcs") filename += ".vcs"; 3176 if (filename.right(4) != ".vcs") filename += ".vcs";
3164 3177
3165 FileStorage storage( mCalendar, filename, new VCalFormat ); 3178 FileStorage storage( mCalendar, filename, new VCalFormat );
3166 return storage.save(); 3179 return storage.save();
3167 3180
3168} 3181}
3169 3182
3170void CalendarView::eventUpdated(Incidence *) 3183void CalendarView::eventUpdated(Incidence *)
3171{ 3184{
3172 setModified(); 3185 setModified();
3173 // Don't call updateView here. The code, which has caused the update of the 3186 // Don't call updateView here. The code, which has caused the update of the
3174 // event is responsible for updating the view. 3187 // event is responsible for updating the view.
3175 // updateView(); 3188 // updateView();
3176} 3189}
3177 3190
3178void CalendarView::adaptNavigationUnits() 3191void CalendarView::adaptNavigationUnits()
3179{ 3192{
3180 if (mViewManager->currentView()->isEventView()) { 3193 if (mViewManager->currentView()->isEventView()) {
3181 int days = mViewManager->currentView()->currentDateCount(); 3194 int days = mViewManager->currentView()->currentDateCount();
3182 if (days == 1) { 3195 if (days == 1) {
3183 emit changeNavStringPrev(i18n("&Previous Day")); 3196 emit changeNavStringPrev(i18n("&Previous Day"));
3184 emit changeNavStringNext(i18n("&Next Day")); 3197 emit changeNavStringNext(i18n("&Next Day"));
3185 } else { 3198 } else {
3186 emit changeNavStringPrev(i18n("&Previous Week")); 3199 emit changeNavStringPrev(i18n("&Previous Week"));
3187 emit changeNavStringNext(i18n("&Next Week")); 3200 emit changeNavStringNext(i18n("&Next Week"));
3188 } 3201 }
3189 } 3202 }
3190} 3203}
3191 3204
3192void CalendarView::processMainViewSelection( Incidence *incidence ) 3205void CalendarView::processMainViewSelection( Incidence *incidence )
3193{ 3206{
3194 if ( incidence ) mTodoList->clearSelection(); 3207 if ( incidence ) mTodoList->clearSelection();
3195 processIncidenceSelection( incidence ); 3208 processIncidenceSelection( incidence );
3196} 3209}
3197 3210
3198void CalendarView::processTodoListSelection( Incidence *incidence ) 3211void CalendarView::processTodoListSelection( Incidence *incidence )
3199{ 3212{
3200 if ( incidence && mViewManager->currentView() ) { 3213 if ( incidence && mViewManager->currentView() ) {
3201 mViewManager->currentView()->clearSelection(); 3214 mViewManager->currentView()->clearSelection();
3202 } 3215 }
3203 processIncidenceSelection( incidence ); 3216 processIncidenceSelection( incidence );
3204} 3217}
3205 3218
3206void CalendarView::processIncidenceSelection( Incidence *incidence ) 3219void CalendarView::processIncidenceSelection( Incidence *incidence )
3207{ 3220{
3208 if ( incidence == mSelectedIncidence ) return; 3221 if ( incidence == mSelectedIncidence ) return;
3209 3222
3210 mSelectedIncidence = incidence; 3223 mSelectedIncidence = incidence;
3211 3224
3212 emit incidenceSelected( mSelectedIncidence ); 3225 emit incidenceSelected( mSelectedIncidence );
3213 3226
3214 if ( incidence && incidence->type() == "Event" ) { 3227 if ( incidence && incidence->type() == "Event" ) {
3215 Event *event = static_cast<Event *>( incidence ); 3228 Event *event = static_cast<Event *>( incidence );
3216 if ( event->organizer() == KOPrefs::instance()->email() ) { 3229 if ( event->organizer() == KOPrefs::instance()->email() ) {
3217 emit organizerEventsSelected( true ); 3230 emit organizerEventsSelected( true );
3218 } else { 3231 } else {
3219 emit organizerEventsSelected(false); 3232 emit organizerEventsSelected(false);
3220 } 3233 }
3221 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3234 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3222 KOPrefs::instance()->email() ) ) { 3235 KOPrefs::instance()->email() ) ) {
3223 emit groupEventsSelected( true ); 3236 emit groupEventsSelected( true );
3224 } else { 3237 } else {
3225 emit groupEventsSelected(false); 3238 emit groupEventsSelected(false);
3226 } 3239 }
3227 return; 3240 return;
3228 } else { 3241 } else {
3229 if ( incidence && incidence->type() == "Todo" ) { 3242 if ( incidence && incidence->type() == "Todo" ) {
3230 emit todoSelected( true ); 3243 emit todoSelected( true );
3231 Todo *event = static_cast<Todo *>( incidence ); 3244 Todo *event = static_cast<Todo *>( incidence );
3232 if ( event->organizer() == KOPrefs::instance()->email() ) { 3245 if ( event->organizer() == KOPrefs::instance()->email() ) {
3233 emit organizerEventsSelected( true ); 3246 emit organizerEventsSelected( true );
3234 } else { 3247 } else {
3235 emit organizerEventsSelected(false); 3248 emit organizerEventsSelected(false);
3236 } 3249 }
3237 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3250 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3238 KOPrefs::instance()->email() ) ) { 3251 KOPrefs::instance()->email() ) ) {
3239 emit groupEventsSelected( true ); 3252 emit groupEventsSelected( true );
3240 } else { 3253 } else {
3241 emit groupEventsSelected(false); 3254 emit groupEventsSelected(false);
3242 } 3255 }
3243 return; 3256 return;
3244 } else { 3257 } else {
3245 emit todoSelected( false ); 3258 emit todoSelected( false );
3246 emit organizerEventsSelected(false); 3259 emit organizerEventsSelected(false);
3247 emit groupEventsSelected(false); 3260 emit groupEventsSelected(false);
3248 } 3261 }
3249 return; 3262 return;
3250 } 3263 }
3251 3264
3252 /* if ( incidence && incidence->type() == "Todo" ) { 3265 /* if ( incidence && incidence->type() == "Todo" ) {
3253 emit todoSelected( true ); 3266 emit todoSelected( true );
3254 } else { 3267 } else {
3255 emit todoSelected( false ); 3268 emit todoSelected( false );
3256 }*/ 3269 }*/
3257} 3270}
3258 3271
3259 3272
3260void CalendarView::checkClipboard() 3273void CalendarView::checkClipboard()
3261{ 3274{
3262#ifndef KORG_NODND 3275#ifndef KORG_NODND
3263 if (ICalDrag::canDecode(QApplication::clipboard()->data())) { 3276 if (ICalDrag::canDecode(QApplication::clipboard()->data())) {
3264 emit pasteEnabled(true); 3277 emit pasteEnabled(true);
3265 } else { 3278 } else {
3266 emit pasteEnabled(false); 3279 emit pasteEnabled(false);
3267 } 3280 }
3268#endif 3281#endif
3269} 3282}
3270 3283
3271void CalendarView::showDates(const DateList &selectedDates) 3284void CalendarView::showDates(const DateList &selectedDates)
3272{ 3285{
3273 // kdDebug() << "CalendarView::selectDates()" << endl; 3286 // kdDebug() << "CalendarView::selectDates()" << endl;
3274 3287
3275 if ( mViewManager->currentView() ) { 3288 if ( mViewManager->currentView() ) {
3276 updateView( selectedDates.first(), selectedDates.last() ); 3289 updateView( selectedDates.first(), selectedDates.last() );
3277 } else { 3290 } else {
3278 mViewManager->showAgendaView(); 3291 mViewManager->showAgendaView();
3279 } 3292 }
3280 3293
3281 QString selDates; 3294 QString selDates;
3282 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); 3295 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true);
3283 if (selectedDates.first() < selectedDates.last() ) 3296 if (selectedDates.first() < selectedDates.last() )
3284 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); 3297 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true);
3285 topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); 3298 topLevelWidget()->setCaption( i18n("Dates: ") + selDates );
3286 3299
3287} 3300}
3288 3301
3289QPtrList<CalFilter> CalendarView::filters() 3302QPtrList<CalFilter> CalendarView::filters()
3290{ 3303{
3291 return mFilters; 3304 return mFilters;
3292 3305
3293} 3306}
3294void CalendarView::editFilters() 3307void CalendarView::editFilters()
3295{ 3308{
3296 // kdDebug() << "CalendarView::editFilters()" << endl; 3309 // kdDebug() << "CalendarView::editFilters()" << endl;
3297 3310
3298 CalFilter *filter = mFilters.first(); 3311 CalFilter *filter = mFilters.first();
3299 while(filter) { 3312 while(filter) {
3300 kdDebug() << " Filter: " << filter->name() << endl; 3313 kdDebug() << " Filter: " << filter->name() << endl;
3301 filter = mFilters.next(); 3314 filter = mFilters.next();
3302 } 3315 }
3303 3316
3304 mDialogManager->showFilterEditDialog(&mFilters); 3317 mDialogManager->showFilterEditDialog(&mFilters);
3305} 3318}
3306void CalendarView::toggleFilter() 3319void CalendarView::toggleFilter()
3307{ 3320{
3308 showFilter(! mFilterView->isVisible()); 3321 showFilter(! mFilterView->isVisible());
3309} 3322}
3310 3323
3311KOFilterView *CalendarView::filterView() 3324KOFilterView *CalendarView::filterView()
3312{ 3325{
3313 return mFilterView; 3326 return mFilterView;
3314} 3327}
3315void CalendarView::selectFilter( int fil ) 3328void CalendarView::selectFilter( int fil )
3316{ 3329{
3317 mFilterView->setSelectedFilter( fil ); 3330 mFilterView->setSelectedFilter( fil );
3318} 3331}
3319void CalendarView::showFilter(bool visible) 3332void CalendarView::showFilter(bool visible)
3320{ 3333{
3321 if (visible) mFilterView->show(); 3334 if (visible) mFilterView->show();
3322 else mFilterView->hide(); 3335 else mFilterView->hide();
3323} 3336}
3324void CalendarView::toggleFilerEnabled( ) 3337void CalendarView::toggleFilerEnabled( )
3325{ 3338{
3326 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); 3339 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() );
3327 if ( !mFilterView->filtersEnabled() ) 3340 if ( !mFilterView->filtersEnabled() )
3328 topLevelWidget()->setCaption( i18n("Filter disabled ") ); 3341 topLevelWidget()->setCaption( i18n("Filter disabled ") );
3329 3342
3330} 3343}
3331void CalendarView::updateFilter() 3344void CalendarView::updateFilter()
3332{ 3345{
3333 CalFilter *filter = mFilterView->selectedFilter(); 3346 CalFilter *filter = mFilterView->selectedFilter();
3334 if (filter) { 3347 if (filter) {
3335 if (mFilterView->filtersEnabled()) { 3348 if (mFilterView->filtersEnabled()) {
3336 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); 3349 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() );
3337 filter->setEnabled(true); 3350 filter->setEnabled(true);
3338 } 3351 }
3339 else filter->setEnabled(false); 3352 else filter->setEnabled(false);
3340 mCalendar->setFilter(filter); 3353 mCalendar->setFilter(filter);
3341 updateView(); 3354 updateView();
3342 } 3355 }
3343} 3356}
3344 3357
3345void CalendarView::filterEdited() 3358void CalendarView::filterEdited()
3346{ 3359{
3347 mFilterView->updateFilters(); 3360 mFilterView->updateFilters();
3348 updateFilter(); 3361 updateFilter();
3349 writeSettings(); 3362 writeSettings();
3350} 3363}
3351 3364
3352 3365
3353void CalendarView::takeOverEvent() 3366void CalendarView::takeOverEvent()
3354{ 3367{
3355 Incidence *incidence = currentSelection(); 3368 Incidence *incidence = currentSelection();
3356 3369
3357 if (!incidence) return; 3370 if (!incidence) return;
3358 3371
3359 incidence->setOrganizer(KOPrefs::instance()->email()); 3372 incidence->setOrganizer(KOPrefs::instance()->email());
3360 incidence->recreate(); 3373 incidence->recreate();
3361 incidence->setReadOnly(false); 3374 incidence->setReadOnly(false);
3362 3375
3363 updateView(); 3376 updateView();
3364} 3377}
3365 3378
3366void CalendarView::takeOverCalendar() 3379void CalendarView::takeOverCalendar()
3367{ 3380{
3368 // TODO: Create Calendar::allIncidences() function and use it here 3381 // TODO: Create Calendar::allIncidences() function and use it here
3369 3382
3370 QPtrList<Event> events = mCalendar->events(); 3383 QPtrList<Event> events = mCalendar->events();
3371 for(uint i=0; i<events.count(); ++i) { 3384 for(uint i=0; i<events.count(); ++i) {
3372 events.at(i)->setOrganizer(KOPrefs::instance()->email()); 3385 events.at(i)->setOrganizer(KOPrefs::instance()->email());
3373 events.at(i)->recreate(); 3386 events.at(i)->recreate();
3374 events.at(i)->setReadOnly(false); 3387 events.at(i)->setReadOnly(false);
3375 } 3388 }
3376 3389
3377 QPtrList<Todo> todos = mCalendar->todos(); 3390 QPtrList<Todo> todos = mCalendar->todos();
3378 for(uint i=0; i<todos.count(); ++i) { 3391 for(uint i=0; i<todos.count(); ++i) {
3379 todos.at(i)->setOrganizer(KOPrefs::instance()->email()); 3392 todos.at(i)->setOrganizer(KOPrefs::instance()->email());
3380 todos.at(i)->recreate(); 3393 todos.at(i)->recreate();
3381 todos.at(i)->setReadOnly(false); 3394 todos.at(i)->setReadOnly(false);
3382 } 3395 }
3383 3396
3384 QPtrList<Journal> journals = mCalendar->journals(); 3397 QPtrList<Journal> journals = mCalendar->journals();
3385 for(uint i=0; i<journals.count(); ++i) { 3398 for(uint i=0; i<journals.count(); ++i) {
3386 journals.at(i)->setOrganizer(KOPrefs::instance()->email()); 3399 journals.at(i)->setOrganizer(KOPrefs::instance()->email());
3387 journals.at(i)->recreate(); 3400 journals.at(i)->recreate();
3388 journals.at(i)->setReadOnly(false); 3401 journals.at(i)->setReadOnly(false);
3389 } 3402 }
3390 3403
3391 updateView(); 3404 updateView();
3392} 3405}
3393 3406
3394void CalendarView::showIntro() 3407void CalendarView::showIntro()
3395{ 3408{
3396 kdDebug() << "To be implemented." << endl; 3409 kdDebug() << "To be implemented." << endl;
3397} 3410}
3398 3411
3399QWidgetStack *CalendarView::viewStack() 3412QWidgetStack *CalendarView::viewStack()
3400{ 3413{
3401 return mRightFrame; 3414 return mRightFrame;
3402} 3415}
3403 3416
3404QWidget *CalendarView::leftFrame() 3417QWidget *CalendarView::leftFrame()
3405{ 3418{
3406 return mLeftFrame; 3419 return mLeftFrame;
3407} 3420}
3408 3421
3409DateNavigator *CalendarView::dateNavigator() 3422DateNavigator *CalendarView::dateNavigator()
3410{ 3423{
3411 return mNavigator; 3424 return mNavigator;
3412} 3425}
3413 3426
3414KDateNavigator* CalendarView::dateNavigatorWidget() 3427KDateNavigator* CalendarView::dateNavigatorWidget()
3415{ 3428{
3416 return mDateNavigator; 3429 return mDateNavigator;
3417} 3430}
3418void CalendarView::toggleDateNavigatorWidget() 3431void CalendarView::toggleDateNavigatorWidget()
3419{ 3432{
3420 if (mDateNavigator->isVisible()) 3433 if (mDateNavigator->isVisible())
3421 mDateNavigator->hide(); 3434 mDateNavigator->hide();
3422 else 3435 else
3423 mDateNavigator->show(); 3436 mDateNavigator->show();
3424} 3437}
3425void CalendarView::addView(KOrg::BaseView *view) 3438void CalendarView::addView(KOrg::BaseView *view)
3426{ 3439{
3427 mViewManager->addView(view); 3440 mViewManager->addView(view);
3428} 3441}
3429 3442
3430void CalendarView::showView(KOrg::BaseView *view) 3443void CalendarView::showView(KOrg::BaseView *view)
3431{ 3444{
3432 mViewManager->showView(view, mLeftFrame->isVisible()); 3445 mViewManager->showView(view, mLeftFrame->isVisible());
3433} 3446}
3434 3447
3435Incidence *CalendarView::currentSelection() 3448Incidence *CalendarView::currentSelection()
3436{ 3449{
3437 return mViewManager->currentSelection(); 3450 return mViewManager->currentSelection();
3438} 3451}
3439void CalendarView::toggleAllDaySize() 3452void CalendarView::toggleAllDaySize()
3440{ 3453{
3441 /* 3454 /*
3442 if ( KOPrefs::instance()->mAllDaySize > 47 ) 3455 if ( KOPrefs::instance()->mAllDaySize > 47 )
3443 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; 3456 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2;
3444 else 3457 else
3445 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; 3458 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2;
3446 */ 3459 */
3447 viewManager()->agendaView()->toggleAllDay(); 3460 viewManager()->agendaView()->toggleAllDay();
3448} 3461}
3449void CalendarView::toggleExpand() 3462void CalendarView::toggleExpand()
3450{ 3463{
3451 // if ( mLeftFrame->isHidden() ) { 3464 // if ( mLeftFrame->isHidden() ) {
3452 // mLeftFrame->show(); 3465 // mLeftFrame->show();
3453 // emit calendarViewExpanded( false ); 3466 // emit calendarViewExpanded( false );
3454 // } else { 3467 // } else {
3455 // mLeftFrame->hide(); 3468 // mLeftFrame->hide();
3456 // emit calendarViewExpanded( true ); 3469 // emit calendarViewExpanded( true );
3457 // } 3470 // }
3458 3471
3459 globalFlagBlockAgenda = 1; 3472 globalFlagBlockAgenda = 1;
3460 emit calendarViewExpanded( !mLeftFrame->isHidden() ); 3473 emit calendarViewExpanded( !mLeftFrame->isHidden() );
3461 globalFlagBlockAgenda = 5; 3474 globalFlagBlockAgenda = 5;
3462 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); 3475 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() );
3463 //mViewManager->showView( 0, true ); 3476 //mViewManager->showView( 0, true );
3464} 3477}
3465 3478
3466void CalendarView::calendarModified( bool modified, Calendar * ) 3479void CalendarView::calendarModified( bool modified, Calendar * )
3467{ 3480{
3468 setModified( modified ); 3481 setModified( modified );
3469} 3482}
3470 3483
3471Todo *CalendarView::selectedTodo() 3484Todo *CalendarView::selectedTodo()
3472{ 3485{
3473 Incidence *incidence = currentSelection(); 3486 Incidence *incidence = currentSelection();
3474 if ( incidence && incidence->type() == "Todo" ) { 3487 if ( incidence && incidence->type() == "Todo" ) {
3475 return static_cast<Todo *>( incidence ); 3488 return static_cast<Todo *>( incidence );
3476 } 3489 }
3477 3490
3478 incidence = mTodoList->selectedIncidences().first(); 3491 incidence = mTodoList->selectedIncidences().first();
3479 if ( incidence && incidence->type() == "Todo" ) { 3492 if ( incidence && incidence->type() == "Todo" ) {
3480 return static_cast<Todo *>( incidence ); 3493 return static_cast<Todo *>( incidence );
3481 } 3494 }
3482 3495
3483 return 0; 3496 return 0;
3484} 3497}
3485 3498
3486void CalendarView::dialogClosing(Incidence *in) 3499void CalendarView::dialogClosing(Incidence *in)
3487{ 3500{
3488 // mDialogList.remove(in); 3501 // mDialogList.remove(in);
3489} 3502}
3490 3503
3491void CalendarView::showIncidence() 3504void CalendarView::showIncidence()
3492{ 3505{
3493 Incidence *incidence = currentSelection(); 3506 Incidence *incidence = currentSelection();
3494 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3507 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3495 if ( incidence ) { 3508 if ( incidence ) {
3496 ShowIncidenceVisitor v; 3509 ShowIncidenceVisitor v;
3497 v.act( incidence, this ); 3510 v.act( incidence, this );
3498 } 3511 }
3499} 3512}
3500void CalendarView::editIncidenceDescription() 3513void CalendarView::editIncidenceDescription()
3501{ 3514{
3502 mFlagEditDescription = true; 3515 mFlagEditDescription = true;
3503 editIncidence(); 3516 editIncidence();
3504 mFlagEditDescription = false; 3517 mFlagEditDescription = false;
3505} 3518}
3506void CalendarView::editIncidence() 3519void CalendarView::editIncidence()
3507{ 3520{
3508 // qDebug("editIncidence() "); 3521 // qDebug("editIncidence() ");
3509 Incidence *incidence = currentSelection(); 3522 Incidence *incidence = currentSelection();
3510 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3523 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3511 if ( incidence ) { 3524 if ( incidence ) {
3512 EditIncidenceVisitor v; 3525 EditIncidenceVisitor v;
3513 v.act( incidence, this ); 3526 v.act( incidence, this );
3514 } 3527 }
3515} 3528}
3516 3529
3517void CalendarView::deleteIncidence() 3530void CalendarView::deleteIncidence()
3518{ 3531{
3519 Incidence *incidence = currentSelection(); 3532 Incidence *incidence = currentSelection();
3520 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3533 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3521 if ( incidence ) { 3534 if ( incidence ) {
3522 deleteIncidence(incidence); 3535 deleteIncidence(incidence);
3523 } 3536 }
3524} 3537}
3525 3538
3526void CalendarView::showIncidence(Incidence *incidence) 3539void CalendarView::showIncidence(Incidence *incidence)
3527{ 3540{
3528 if ( incidence ) { 3541 if ( incidence ) {
3529 ShowIncidenceVisitor v; 3542 ShowIncidenceVisitor v;
3530 v.act( incidence, this ); 3543 v.act( incidence, this );
3531 } 3544 }
3532} 3545}
3533 3546
3534void CalendarView::editIncidence(Incidence *incidence) 3547void CalendarView::editIncidence(Incidence *incidence)
3535{ 3548{
3536 if ( incidence ) { 3549 if ( incidence ) {
3537 3550
3538 EditIncidenceVisitor v; 3551 EditIncidenceVisitor v;
3539 v.act( incidence, this ); 3552 v.act( incidence, this );
3540 3553
3541 } 3554 }
3542} 3555}
3543 3556
3544void CalendarView::deleteIncidence(Incidence *incidence) 3557void CalendarView::deleteIncidence(Incidence *incidence)
3545{ 3558{
3546 //qDebug(" CalendarView::deleteIncidence "); 3559 //qDebug(" CalendarView::deleteIncidence ");
3547 if ( incidence ) { 3560 if ( incidence ) {
3548 DeleteIncidenceVisitor v; 3561 DeleteIncidenceVisitor v;
3549 v.act( incidence, this ); 3562 v.act( incidence, this );
3550 } 3563 }
3551} 3564}
3552 3565
3553 3566
3554void CalendarView::lookForOutgoingMessages() 3567void CalendarView::lookForOutgoingMessages()
3555{ 3568{
3556 OutgoingDialog *ogd = mDialogManager->outgoingDialog(); 3569 OutgoingDialog *ogd = mDialogManager->outgoingDialog();
3557 ogd->loadMessages(); 3570 ogd->loadMessages();
3558} 3571}
3559 3572
3560void CalendarView::lookForIncomingMessages() 3573void CalendarView::lookForIncomingMessages()
3561{ 3574{
3562 IncomingDialog *icd = mDialogManager->incomingDialog(); 3575 IncomingDialog *icd = mDialogManager->incomingDialog();
3563 icd->retrieve(); 3576 icd->retrieve();
3564} 3577}
3565 3578
3566bool CalendarView::removeCompletedSubTodos( Todo* t ) 3579bool CalendarView::removeCompletedSubTodos( Todo* t )
3567{ 3580{
3568 bool deleteTodo = true; 3581 bool deleteTodo = true;
3569 QPtrList<Incidence> subTodos; 3582 QPtrList<Incidence> subTodos;
3570 Incidence *aTodo; 3583 Incidence *aTodo;
3571 subTodos = t->relations(); 3584 subTodos = t->relations();
3572 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { 3585 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
3573 if (! removeCompletedSubTodos( (Todo*) aTodo )) 3586 if (! removeCompletedSubTodos( (Todo*) aTodo ))
3574 deleteTodo = false; 3587 deleteTodo = false;
3575 } 3588 }
3576 if ( deleteTodo ) { 3589 if ( deleteTodo ) {
3577 if ( t->isCompleted() ) { 3590 if ( t->isCompleted() ) {
3578 checkExternalId( t ); 3591 checkExternalId( t );
3579 mCalendar->deleteTodo( t ); 3592 mCalendar->deleteTodo( t );
3580 changeTodoDisplay( t,KOGlobals::EVENTDELETED ); 3593 changeTodoDisplay( t,KOGlobals::EVENTDELETED );
3581 } 3594 }
3582 else 3595 else
3583 deleteTodo = false; 3596 deleteTodo = false;
3584 } 3597 }
3585 return deleteTodo; 3598 return deleteTodo;
3586 3599
3587} 3600}
3588void CalendarView::purgeCompleted() 3601void CalendarView::purgeCompleted()
3589{ 3602{
3590 int result = KMessageBox::warningContinueCancel(this, 3603 int result = KMessageBox::warningContinueCancel(this,
3591 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); 3604 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge"));
3592 3605
3593 if (result == KMessageBox::Continue) { 3606 if (result == KMessageBox::Continue) {
3594 3607
3595 QPtrList<Todo> todoCal; 3608 QPtrList<Todo> todoCal;
3596 QPtrList<Todo> rootTodos; 3609 QPtrList<Todo> rootTodos;
3597 //QPtrList<Incidence> rel; 3610 //QPtrList<Incidence> rel;
3598 Todo *aTodo;//, *rTodo; 3611 Todo *aTodo;//, *rTodo;
3599 Incidence *rIncidence; 3612 Incidence *rIncidence;
3600 bool childDelete = false; 3613 bool childDelete = false;
3601 bool deletedOne = true; 3614 bool deletedOne = true;
3602 todoCal = calendar()->todos(); 3615 todoCal = calendar()->todos();
3603 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { 3616 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
3604 if ( !aTodo->relatedTo() ) 3617 if ( !aTodo->relatedTo() )
3605 rootTodos.append( aTodo ); 3618 rootTodos.append( aTodo );
3606 } 3619 }
3607 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { 3620 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) {
3608 removeCompletedSubTodos( aTodo ); 3621 removeCompletedSubTodos( aTodo );
3609 } 3622 }
3610 3623
3611 updateView(); 3624 updateView();
3612 } 3625 }
3613} 3626}
3614 3627
3615void CalendarView::slotCalendarChanged() 3628void CalendarView::slotCalendarChanged()
3616{ 3629{
3617 ; 3630 ;
3618} 3631}
3619 3632
3620NavigatorBar *CalendarView::navigatorBar() 3633NavigatorBar *CalendarView::navigatorBar()
3621{ 3634{
3622 return mNavigatorBar; 3635 return mNavigatorBar;
3623} 3636}
3624 3637
3625 3638
3626 3639
3627void CalendarView::keyPressEvent ( QKeyEvent *e) 3640void CalendarView::keyPressEvent ( QKeyEvent *e)
3628{ 3641{
3629 //qDebug(" alendarView::keyPressEvent "); 3642 //qDebug(" alendarView::keyPressEvent ");
3630 e->ignore(); 3643 e->ignore();
3631} 3644}
3632 3645
3633//#include "calendarview.moc" 3646//#include "calendarview.moc"
3634 3647
3635//#include "calendarviewbase.moc" 3648//#include "calendarviewbase.moc"
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index 355bb84..cd54685 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -1,591 +1,592 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000, 2001 3 Copyright (c) 2000, 2001
4 Cornelius Schumacher <schumacher@kde.org> 4 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24#ifndef CALENDARVIEW_H 24#ifndef CALENDARVIEW_H
25#define CALENDARVIEW_H 25#define CALENDARVIEW_H
26 26
27#include <qframe.h> 27#include <qframe.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#include <qwidget.h> 29#include <qwidget.h>
30#include <qptrlist.h> 30#include <qptrlist.h>
31#include <qvbox.h> 31#include <qvbox.h>
32#include <qmap.h> 32#include <qmap.h>
33#ifndef DESKTOP_VERSION 33#ifndef DESKTOP_VERSION
34#include <qtopia/ir.h> 34#include <qtopia/ir.h>
35#else 35#else
36#define Ir char 36#define Ir char
37#endif 37#endif
38#include <libkcal/calendar.h> 38#include <libkcal/calendar.h>
39#include <libkcal/scheduler.h> 39#include <libkcal/scheduler.h>
40#include <libkcal/calendarresources.h> 40#include <libkcal/calendarresources.h>
41#include <libkcal/resourcecalendar.h> 41#include <libkcal/resourcecalendar.h>
42 42
43#include <korganizer/calendarviewbase.h> 43#include <korganizer/calendarviewbase.h>
44 44
45class QWidgetStack; 45class QWidgetStack;
46class QSplitter; 46class QSplitter;
47 47
48class CalPrinter; 48class CalPrinter;
49class KOFilterView; 49class KOFilterView;
50class KOViewManager; 50class KOViewManager;
51class KODialogManager; 51class KODialogManager;
52class KOTodoView; 52class KOTodoView;
53class KDateNavigator; 53class KDateNavigator;
54class DateNavigator; 54class DateNavigator;
55class KOIncidenceEditor; 55class KOIncidenceEditor;
56class KDatePicker; 56class KDatePicker;
57class ResourceView; 57class ResourceView;
58class NavigatorBar; 58class NavigatorBar;
59class KOEventEditor; 59class KOEventEditor;
60class KOTodoEditor ; 60class KOTodoEditor ;
61class KOEventViewerDialog; 61class KOEventViewerDialog;
62class KOBeamPrefs; 62class KOBeamPrefs;
63class KSyncProfile; 63class KSyncProfile;
64class AlarmDialog; 64class AlarmDialog;
65class KCal::Attendee; 65class KCal::Attendee;
66 66
67namespace KCal { class FileStorage; } 67namespace KCal { class FileStorage; }
68 68
69using namespace KCal; 69using namespace KCal;
70 70
71/** 71/**
72 This is the main calendar widget. It provides the different vies on t he 72 This is the main calendar widget. It provides the different vies on t he
73 calendar data as well as the date navigator. It also handles synchronisation 73 calendar data as well as the date navigator. It also handles synchronisation
74 of the different views and controls the different dialogs like preferences, 74 of the different views and controls the different dialogs like preferences,
75 event editor, search dialog etc. 75 event editor, search dialog etc.
76 76
77 @short main calendar view widget 77 @short main calendar view widget
78 @author Cornelius Schumacher 78 @author Cornelius Schumacher
79*/ 79*/
80class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer 80class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer
81{ 81{
82 Q_OBJECT 82 Q_OBJECT
83 public: 83 public:
84 /** 84 /**
85 Constructs a new calendar view widget. 85 Constructs a new calendar view widget.
86 86
87 @param calendar calendar document 87 @param calendar calendar document
88 @param parent parent window 88 @param parent parent window
89 @param name Qt internal widget object name 89 @param name Qt internal widget object name
90 */ 90 */
91 CalendarView( CalendarResources *calendar, QWidget *parent = 0, 91 CalendarView( CalendarResources *calendar, QWidget *parent = 0,
92 const char *name = 0 ); 92 const char *name = 0 );
93 CalendarView( Calendar *calendar, QWidget *parent = 0, 93 CalendarView( Calendar *calendar, QWidget *parent = 0,
94 const char *name = 0 ); 94 const char *name = 0 );
95 virtual ~CalendarView(); 95 virtual ~CalendarView();
96 96
97 Calendar *calendar() { return mCalendar; } 97 Calendar *calendar() { return mCalendar; }
98 98
99 KOViewManager *viewManager(); 99 KOViewManager *viewManager();
100 KODialogManager *dialogManager(); 100 KODialogManager *dialogManager();
101 101
102 QDate startDate(); 102 QDate startDate();
103 QDate endDate(); 103 QDate endDate();
104 104
105 QWidgetStack *viewStack(); 105 QWidgetStack *viewStack();
106 QWidget *leftFrame(); 106 QWidget *leftFrame();
107 NavigatorBar *navigatorBar(); 107 NavigatorBar *navigatorBar();
108 108
109 DateNavigator *dateNavigator(); 109 DateNavigator *dateNavigator();
110 KDateNavigator *dateNavigatorWidget(); 110 KDateNavigator *dateNavigatorWidget();
111 111
112 void addView(KOrg::BaseView *); 112 void addView(KOrg::BaseView *);
113 void showView(KOrg::BaseView *); 113 void showView(KOrg::BaseView *);
114 KOEventViewerDialog* getEventViewerDialog(); 114 KOEventViewerDialog* getEventViewerDialog();
115 Incidence *currentSelection(); 115 Incidence *currentSelection();
116 void setupExternSyncProfiles(); 116 void setupExternSyncProfiles();
117 117
118 signals: 118 signals:
119 /** This todo has been modified */ 119 /** This todo has been modified */
120 void todoModified(Todo *, int); 120 void todoModified(Todo *, int);
121 121
122 /** when change is made to options dialog, the topwidget will catch this 122 /** when change is made to options dialog, the topwidget will catch this
123 * and emit this signal which notifies all widgets which have registered 123 * and emit this signal which notifies all widgets which have registered
124 * for notification to update their settings. */ 124 * for notification to update their settings. */
125 void configChanged(); 125 void configChanged();
126 /** emitted when the topwidget is closing down, so that any attached 126 /** emitted when the topwidget is closing down, so that any attached
127 child windows can also close. */ 127 child windows can also close. */
128 void closingDown(); 128 void closingDown();
129 /** emitted right before we die */ 129 /** emitted right before we die */
130 void closed(QWidget *); 130 void closed(QWidget *);
131 131
132 /** Emitted when state of modified flag changes */ 132 /** Emitted when state of modified flag changes */
133 void modifiedChanged(bool); 133 void modifiedChanged(bool);
134 void signalmodified(); 134 void signalmodified();
135 135
136 /** Emitted when state of read-only flag changes */ 136 /** Emitted when state of read-only flag changes */
137 void readOnlyChanged(bool); 137 void readOnlyChanged(bool);
138 138
139 /** Emitted when the unit of navigation changes */ 139 /** Emitted when the unit of navigation changes */
140 void changeNavStringPrev(const QString &); 140 void changeNavStringPrev(const QString &);
141 void changeNavStringNext(const QString &); 141 void changeNavStringNext(const QString &);
142 142
143 /** Emitted when state of events selection has changed and user is organizer*/ 143 /** Emitted when state of events selection has changed and user is organizer*/
144 void organizerEventsSelected(bool); 144 void organizerEventsSelected(bool);
145 /** Emitted when state of events selection has changed and user is attendee*/ 145 /** Emitted when state of events selection has changed and user is attendee*/
146 void groupEventsSelected(bool); 146 void groupEventsSelected(bool);
147 /** 147 /**
148 Emitted when an incidence gets selected. If the selection is cleared the 148 Emitted when an incidence gets selected. If the selection is cleared the
149 signal is emitted with 0 as argument. 149 signal is emitted with 0 as argument.
150 */ 150 */
151 void incidenceSelected( Incidence * ); 151 void incidenceSelected( Incidence * );
152 /** Emitted, when a todoitem is selected or deselected. */ 152 /** Emitted, when a todoitem is selected or deselected. */
153 void todoSelected( bool ); 153 void todoSelected( bool );
154 154
155 /** 155 /**
156 Emitted, when clipboard content changes. Parameter indicates if paste 156 Emitted, when clipboard content changes. Parameter indicates if paste
157 is possible or not. 157 is possible or not.
158 */ 158 */
159 void pasteEnabled(bool); 159 void pasteEnabled(bool);
160 160
161 /** Emitted, when the number of incoming messages has changed. */ 161 /** Emitted, when the number of incoming messages has changed. */
162 void numIncomingChanged(int); 162 void numIncomingChanged(int);
163 163
164 /** Emitted, when the number of outgoing messages has changed. */ 164 /** Emitted, when the number of outgoing messages has changed. */
165 void numOutgoingChanged(int); 165 void numOutgoingChanged(int);
166 166
167 /** Send status message, which can e.g. be displayed in the status bar. */ 167 /** Send status message, which can e.g. be displayed in the status bar. */
168 void statusMessage(const QString &); 168 void statusMessage(const QString &);
169 169
170 void calendarViewExpanded( bool ); 170 void calendarViewExpanded( bool );
171 void updateSearchDialog(); 171 void updateSearchDialog();
172 172
173 173
174 public slots: 174 public slots:
175 void showOpenError();
175 void watchSavedFile(); 176 void watchSavedFile();
176 void recheckTimerAlarm(); 177 void recheckTimerAlarm();
177 void checkNextTimerAlarm(); 178 void checkNextTimerAlarm();
178 void addAlarm(const QDateTime &qdt, const QString &noti ); 179 void addAlarm(const QDateTime &qdt, const QString &noti );
179 void addSuspendAlarm(const QDateTime &qdt, const QString &noti ); 180 void addSuspendAlarm(const QDateTime &qdt, const QString &noti );
180 void removeAlarm(const QDateTime &qdt, const QString &noti ); 181 void removeAlarm(const QDateTime &qdt, const QString &noti );
181 182
182 /** options dialog made a changed to the configuration. we catch this 183 /** options dialog made a changed to the configuration. we catch this
183 * and notify all widgets which need to update their configuration. */ 184 * and notify all widgets which need to update their configuration. */
184 void updateConfig(); 185 void updateConfig();
185 186
186 /** 187 /**
187 Load calendar from file \a filename. If \a merge is true, load 188 Load calendar from file \a filename. If \a merge is true, load
188 calendar into existing one, if it is false, clear calendar, before 189 calendar into existing one, if it is false, clear calendar, before
189 loading. Return true, if calendar could be successfully loaded. 190 loading. Return true, if calendar could be successfully loaded.
190 */ 191 */
191 bool openCalendar(QString filename, bool merge=false); 192 bool openCalendar(QString filename, bool merge=false);
192 bool syncCalendar(QString filename,int mode = 0 ); 193 bool syncCalendar(QString filename,int mode = 0 );
193 194
194 /** 195 /**
195 Save calendar data to file. Return true if calendar could be 196 Save calendar data to file. Return true if calendar could be
196 successfully saved. 197 successfully saved.
197 */ 198 */
198 bool saveCalendar(QString filename); 199 bool saveCalendar(QString filename);
199 200
200 /** 201 /**
201 Close calendar. Clear calendar data and reset views to display an empty 202 Close calendar. Clear calendar data and reset views to display an empty
202 calendar. 203 calendar.
203 */ 204 */
204 void closeCalendar(); 205 void closeCalendar();
205 206
206 /** Archive old events of calendar */ 207 /** Archive old events of calendar */
207 void archiveCalendar(); 208 void archiveCalendar();
208 209
209 void showIncidence(); 210 void showIncidence();
210 void editIncidence(); 211 void editIncidence();
211 void editIncidenceDescription(); 212 void editIncidenceDescription();
212 void deleteIncidence(); 213 void deleteIncidence();
213 214
214 /** create an editeventwin with supplied date/time, and if bool is true, 215 /** create an editeventwin with supplied date/time, and if bool is true,
215 * make the event take all day. */ 216 * make the event take all day. */
216 void newEvent(QDateTime, QDateTime, bool allDay = false); 217 void newEvent(QDateTime, QDateTime, bool allDay = false);
217 void newEvent(QDateTime fh); 218 void newEvent(QDateTime fh);
218 void newEvent(QDate dt); 219 void newEvent(QDate dt);
219 /** create new event without having a date hint. Takes current date as 220 /** create new event without having a date hint. Takes current date as
220 default hint. */ 221 default hint. */
221 void newEvent(); 222 void newEvent();
222 void newFloatingEvent(); 223 void newFloatingEvent();
223 224
224 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ 225 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/
225 void showIncidence(Incidence *); 226 void showIncidence(Incidence *);
226 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ 227 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/
227 void editIncidence(Incidence *); 228 void editIncidence(Incidence *);
228 /** Delete the supplied incidence. It calls the correct deleteXXX method*/ 229 /** Delete the supplied incidence. It calls the correct deleteXXX method*/
229 void deleteIncidence(Incidence *); 230 void deleteIncidence(Incidence *);
230 void cloneIncidence(Incidence *); 231 void cloneIncidence(Incidence *);
231 void cancelIncidence(Incidence *); 232 void cancelIncidence(Incidence *);
232 /** Create an editor for the supplied event. */ 233 /** Create an editor for the supplied event. */
233 void editEvent(Event *); 234 void editEvent(Event *);
234 /** Delete the supplied event. */ 235 /** Delete the supplied event. */
235 void deleteEvent(Event *); 236 void deleteEvent(Event *);
236 /** Delete the event with the given unique ID. Returns false, if event wasn't 237 /** Delete the event with the given unique ID. Returns false, if event wasn't
237 found. */ 238 found. */
238 bool deleteEvent(const QString &uid); 239 bool deleteEvent(const QString &uid);
239 /** Create a read-only viewer dialog for the supplied event. */ 240 /** Create a read-only viewer dialog for the supplied event. */
240 void showEvent(Event *); 241 void showEvent(Event *);
241 242
242 void editJournal(Journal *); 243 void editJournal(Journal *);
243 void showJournal(Journal *); 244 void showJournal(Journal *);
244 void deleteJournal(Journal *); 245 void deleteJournal(Journal *);
245 /** Create an editor dialog for a todo */ 246 /** Create an editor dialog for a todo */
246 void editTodo(Todo *); 247 void editTodo(Todo *);
247 /** Create a read-only viewer dialog for the supplied todo */ 248 /** Create a read-only viewer dialog for the supplied todo */
248 void showTodo(Todo *); 249 void showTodo(Todo *);
249 /** create new todo */ 250 /** create new todo */
250 void newTodo(); 251 void newTodo();
251 /** create new todo with a parent todo */ 252 /** create new todo with a parent todo */
252 void newSubTodo(); 253 void newSubTodo();
253 /** create new todo with a parent todo */ 254 /** create new todo with a parent todo */
254 void newSubTodo(Todo *); 255 void newSubTodo(Todo *);
255 /** Delete todo */ 256 /** Delete todo */
256 void deleteTodo(Todo *); 257 void deleteTodo(Todo *);
257 258
258 259
259 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is 260 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is
260 * emitted as result. */ 261 * emitted as result. */
261 void checkClipboard(); 262 void checkClipboard();
262 263
263 /** using the KConfig associated with the kapp variable, read in the 264 /** using the KConfig associated with the kapp variable, read in the
264 * settings from the config file. 265 * settings from the config file.
265 */ 266 */
266 void readSettings(); 267 void readSettings();
267 268
268 /** write current state to config file. */ 269 /** write current state to config file. */
269 void writeSettings(); 270 void writeSettings();
270 271
271 /** read settings for calendar filters */ 272 /** read settings for calendar filters */
272 void readFilterSettings(KConfig *config); 273 void readFilterSettings(KConfig *config);
273 274
274 /** write settings for calendar filters */ 275 /** write settings for calendar filters */
275 void writeFilterSettings(KConfig *config); 276 void writeFilterSettings(KConfig *config);
276 277
277 /** passes on the message that an event has changed to the currently 278 /** passes on the message that an event has changed to the currently
278 * activated view so that it can make appropriate display changes. */ 279 * activated view so that it can make appropriate display changes. */
279 void changeEventDisplay(Event *, int); 280 void changeEventDisplay(Event *, int);
280 void changeIncidenceDisplay(Incidence *, int); 281 void changeIncidenceDisplay(Incidence *, int);
281 void changeTodoDisplay(Todo *, int); 282 void changeTodoDisplay(Todo *, int);
282 283
283 void eventAdded(Event *); 284 void eventAdded(Event *);
284 void eventChanged(Event *); 285 void eventChanged(Event *);
285 void eventToBeDeleted(Event *); 286 void eventToBeDeleted(Event *);
286 void eventDeleted(); 287 void eventDeleted();
287 288
288 void todoAdded(Todo *); 289 void todoAdded(Todo *);
289 void todoChanged(Todo *); 290 void todoChanged(Todo *);
290 void todoToBeDeleted(Todo *); 291 void todoToBeDeleted(Todo *);
291 void todoDeleted(); 292 void todoDeleted();
292 293
293 void updateView(const QDate &start, const QDate &end); 294 void updateView(const QDate &start, const QDate &end);
294 void updateView(); 295 void updateView();
295 296
296 /** Full update of visible todo views */ 297 /** Full update of visible todo views */
297 void updateTodoViews(); 298 void updateTodoViews();
298 299
299 void updateUnmanagedViews(); 300 void updateUnmanagedViews();
300 301
301 /** cut the current appointment to the clipboard */ 302 /** cut the current appointment to the clipboard */
302 void edit_cut(); 303 void edit_cut();
303 304
304 /** copy the current appointment(s) to the clipboard */ 305 /** copy the current appointment(s) to the clipboard */
305 void edit_copy(); 306 void edit_copy();
306 307
307 /** paste the current vobject(s) in the clipboard buffer into calendar */ 308 /** paste the current vobject(s) in the clipboard buffer into calendar */
308 void edit_paste(); 309 void edit_paste();
309 310
310 /** edit viewing and configuration options. */ 311 /** edit viewing and configuration options. */
311 void edit_options(); 312 void edit_options();
312 void edit_sync_options(); 313 void edit_sync_options();
313 /** 314 /**
314 Functions for printing, previewing a print, and setting up printing 315 Functions for printing, previewing a print, and setting up printing
315 parameters. 316 parameters.
316 */ 317 */
317 void print(); 318 void print();
318 void printSetup(); 319 void printSetup();
319 void printPreview(); 320 void printPreview();
320 321
321 /** Export as iCalendar file */ 322 /** Export as iCalendar file */
322 void exportICalendar(); 323 void exportICalendar();
323 324
324 /** Export as vCalendar file */ 325 /** Export as vCalendar file */
325 bool exportVCalendar( QString fn); 326 bool exportVCalendar( QString fn);
326 327
327 /** pop up a dialog to show an existing appointment. */ 328 /** pop up a dialog to show an existing appointment. */
328 void appointment_show(); 329 void appointment_show();
329 /** 330 /**
330 * pop up an Appointment Dialog to edit an existing appointment.Get 331 * pop up an Appointment Dialog to edit an existing appointment.Get
331 * information on the appointment from the list of unique IDs that is 332 * information on the appointment from the list of unique IDs that is
332 * currently in the View, called currIds. 333 * currently in the View, called currIds.
333 */ 334 */
334 void appointment_edit(); 335 void appointment_edit();
335 /** 336 /**
336 * pop up dialog confirming deletion of currently selected event in the 337 * pop up dialog confirming deletion of currently selected event in the
337 * View. 338 * View.
338 */ 339 */
339 void appointment_delete(); 340 void appointment_delete();
340 341
341 /** mails the currently selected event to a particular user as a vCalendar 342 /** mails the currently selected event to a particular user as a vCalendar
342 attachment. */ 343 attachment. */
343 void action_mail(); 344 void action_mail();
344 345
345 /* frees a subtodo from it's relation */ 346 /* frees a subtodo from it's relation */
346 void todo_unsub( Todo * ); 347 void todo_unsub( Todo * );
347 348
348 /** Take ownership of selected event. */ 349 /** Take ownership of selected event. */
349 void takeOverEvent(); 350 void takeOverEvent();
350 351
351 /** Take ownership of all events in calendar. */ 352 /** Take ownership of all events in calendar. */
352 void takeOverCalendar(); 353 void takeOverCalendar();
353 354
354 /** query whether or not the calendar is "dirty". */ 355 /** query whether or not the calendar is "dirty". */
355 bool isModified(); 356 bool isModified();
356 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ 357 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */
357 void setModified(bool modified=true); 358 void setModified(bool modified=true);
358 359
359 /** query if the calendar is read-only. */ 360 /** query if the calendar is read-only. */
360 bool isReadOnly(); 361 bool isReadOnly();
361 /** set state of calendar to read-only */ 362 /** set state of calendar to read-only */
362 void setReadOnly(bool readOnly=true); 363 void setReadOnly(bool readOnly=true);
363 364
364 void eventUpdated(Incidence *); 365 void eventUpdated(Incidence *);
365 366
366 /* iTIP scheduling actions */ 367 /* iTIP scheduling actions */
367 void schedule_publish(Incidence *incidence = 0); 368 void schedule_publish(Incidence *incidence = 0);
368 void schedule_request(Incidence *incidence = 0); 369 void schedule_request(Incidence *incidence = 0);
369 void schedule_refresh(Incidence *incidence = 0); 370 void schedule_refresh(Incidence *incidence = 0);
370 void schedule_cancel(Incidence *incidence = 0); 371 void schedule_cancel(Incidence *incidence = 0);
371 void schedule_add(Incidence *incidence = 0); 372 void schedule_add(Incidence *incidence = 0);
372 void schedule_reply(Incidence *incidence = 0); 373 void schedule_reply(Incidence *incidence = 0);
373 void schedule_counter(Incidence *incidence = 0); 374 void schedule_counter(Incidence *incidence = 0);
374 void schedule_declinecounter(Incidence *incidence = 0); 375 void schedule_declinecounter(Incidence *incidence = 0);
375 void schedule_publish_freebusy(int daysToPublish = 30); 376 void schedule_publish_freebusy(int daysToPublish = 30);
376 377
377 void openAddressbook(); 378 void openAddressbook();
378 379
379 void editFilters(); 380 void editFilters();
380 void toggleFilerEnabled(); 381 void toggleFilerEnabled();
381 QPtrList<CalFilter> filters(); 382 QPtrList<CalFilter> filters();
382 void toggleFilter(); 383 void toggleFilter();
383 void showFilter(bool visible); 384 void showFilter(bool visible);
384 void updateFilter(); 385 void updateFilter();
385 void filterEdited(); 386 void filterEdited();
386 void selectFilter( int ); 387 void selectFilter( int );
387 KOFilterView *filterView(); 388 KOFilterView *filterView();
388 389
389 void showIntro(); 390 void showIntro();
390 391
391 /** Move the curdatepient view date to today */ 392 /** Move the curdatepient view date to today */
392 void goToday(); 393 void goToday();
393 394
394 /** Move to the next date(s) in the current view */ 395 /** Move to the next date(s) in the current view */
395 void goNext(); 396 void goNext();
396 397
397 /** Move to the previous date(s) in the current view */ 398 /** Move to the previous date(s) in the current view */
398 void goPrevious(); 399 void goPrevious();
399 /** Move to the next date(s) in the current view */ 400 /** Move to the next date(s) in the current view */
400 void goNextMonth(); 401 void goNextMonth();
401 402
402 /** Move to the previous date(s) in the current view */ 403 /** Move to the previous date(s) in the current view */
403 void goPreviousMonth(); 404 void goPreviousMonth();
404 405
405 void toggleExpand(); 406 void toggleExpand();
406 void toggleDateNavigatorWidget(); 407 void toggleDateNavigatorWidget();
407 void toggleAllDaySize(); 408 void toggleAllDaySize();
408 void dialogClosing(Incidence *); 409 void dialogClosing(Incidence *);
409 410
410 /** Look for new messages in the inbox */ 411 /** Look for new messages in the inbox */
411 void lookForIncomingMessages(); 412 void lookForIncomingMessages();
412 /** Look for new messages in the outbox */ 413 /** Look for new messages in the outbox */
413 void lookForOutgoingMessages(); 414 void lookForOutgoingMessages();
414 415
415 void processMainViewSelection( Incidence * ); 416 void processMainViewSelection( Incidence * );
416 void processTodoListSelection( Incidence * ); 417 void processTodoListSelection( Incidence * );
417 418
418 void processIncidenceSelection( Incidence * ); 419 void processIncidenceSelection( Incidence * );
419 420
420 void purgeCompleted(); 421 void purgeCompleted();
421 bool removeCompletedSubTodos( Todo* ); 422 bool removeCompletedSubTodos( Todo* );
422 void slotCalendarChanged(); 423 void slotCalendarChanged();
423 bool importBday(); 424 bool importBday();
424 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); 425 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday );
425 bool importQtopia( const QString &categoriesFile, 426 bool importQtopia( const QString &categoriesFile,
426 const QString &datebookFile, 427 const QString &datebookFile,
427 const QString &tasklistFile ); 428 const QString &tasklistFile );
428 void syncSharp( ); 429 void syncSharp( );
429 void syncPhone( ); 430 void syncPhone( );
430 void syncExternal( int mode ); 431 void syncExternal( int mode );
431 void slotSelectPickerDate( QDate ) ; 432 void slotSelectPickerDate( QDate ) ;
432 void showDatePicker( ) ; 433 void showDatePicker( ) ;
433 void moveIncidence(Incidence *) ; 434 void moveIncidence(Incidence *) ;
434 void beamIncidence(Incidence *) ; 435 void beamIncidence(Incidence *) ;
435 void beamCalendar() ; 436 void beamCalendar() ;
436 void beamFilteredCalendar() ; 437 void beamFilteredCalendar() ;
437 void beamIncidenceList(QPtrList<Incidence>) ; 438 void beamIncidenceList(QPtrList<Incidence>) ;
438 void manageCategories(); 439 void manageCategories();
439 int addCategories(); 440 int addCategories();
440 void removeCategories(); 441 void removeCategories();
441 void setSyncDevice( QString ); 442 void setSyncDevice( QString );
442 void setSyncName( QString ); 443 void setSyncName( QString );
443 protected slots: 444 protected slots:
444 void timerAlarm(); 445 void timerAlarm();
445 void suspendAlarm(); 446 void suspendAlarm();
446 void beamDone( Ir *ir ); 447 void beamDone( Ir *ir );
447 /** Select a view or adapt the current view to display the specified dates. */ 448 /** Select a view or adapt the current view to display the specified dates. */
448 void showDates( const KCal::DateList & ); 449 void showDates( const KCal::DateList & );
449 void selectWeekNum ( int ); 450 void selectWeekNum ( int );
450 451
451 public: 452 public:
452 // show a standard warning 453 // show a standard warning
453 // returns KMsgBox::yesNoCancel() 454 // returns KMsgBox::yesNoCancel()
454 int msgCalModified(); 455 int msgCalModified();
455 void confSync(); 456 void confSync();
456 void setLoadedFileVersion(QDateTime); 457 void setLoadedFileVersion(QDateTime);
457 bool checkFileVersion(QString fn); 458 bool checkFileVersion(QString fn);
458 bool checkFileChanged(QString fn); 459 bool checkFileChanged(QString fn);
459 Event* getLastSyncEvent(); 460 Event* getLastSyncEvent();
460 /** Adapt navigation units correpsonding to step size of navigation of the 461 /** Adapt navigation units correpsonding to step size of navigation of the
461 * current view. 462 * current view.
462 */ 463 */
463 void adaptNavigationUnits(); 464 void adaptNavigationUnits();
464 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); 465 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode );
465 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); 466 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false );
466 //Attendee* getYourAttendee(Event *event); 467 //Attendee* getYourAttendee(Event *event);
467 protected: 468 protected:
468 void schedule(Scheduler::Method, Incidence *incidence = 0); 469 void schedule(Scheduler::Method, Incidence *incidence = 0);
469 470
470 // returns KMsgBox::OKCandel() 471 // returns KMsgBox::OKCandel()
471 int msgItemDelete(); 472 int msgItemDelete();
472 void showEventEditor(); 473 void showEventEditor();
473 void showTodoEditor(); 474 void showTodoEditor();
474 void writeLocale(); 475 void writeLocale();
475 Todo *selectedTodo(); 476 Todo *selectedTodo();
476 477
477 private: 478 private:
478 AlarmDialog * mAlarmDialog; 479 AlarmDialog * mAlarmDialog;
479 QString mAlarmNotification; 480 QString mAlarmNotification;
480 QString mSuspendAlarmNotification; 481 QString mSuspendAlarmNotification;
481 QTimer* mSuspendTimer; 482 QTimer* mSuspendTimer;
482 QTimer* mAlarmTimer; 483 QTimer* mAlarmTimer;
483 QTimer* mRecheckAlarmTimer; 484 QTimer* mRecheckAlarmTimer;
484 void computeAlarm( QString ); 485 void computeAlarm( QString );
485 void startAlarm( QString, QString ); 486 void startAlarm( QString, QString );
486 void setSyncEventsReadOnly(); 487 void setSyncEventsReadOnly();
487 488
488 QDateTime loadedFileVersion; 489 QDateTime loadedFileVersion;
489 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); 490 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete );
490 void checkExternalId( Incidence * inc ); 491 void checkExternalId( Incidence * inc );
491 int mGlobalSyncMode; 492 int mGlobalSyncMode;
492 QString mCurrentSyncDevice; 493 QString mCurrentSyncDevice;
493 QString mCurrentSyncName; 494 QString mCurrentSyncName;
494 KOBeamPrefs* beamDialog; 495 KOBeamPrefs* beamDialog;
495 void init(); 496 void init();
496 int mDatePickerMode; 497 int mDatePickerMode;
497 bool mFlagEditDescription; 498 bool mFlagEditDescription;
498 QDateTime mLastCalendarSync; 499 QDateTime mLastCalendarSync;
499 void createPrinter(); 500 void createPrinter();
500 501
501 void calendarModified( bool, Calendar * ); 502 void calendarModified( bool, Calendar * );
502 503
503 CalPrinter *mCalPrinter; 504 CalPrinter *mCalPrinter;
504 505
505 QSplitter *mPanner; 506 QSplitter *mPanner;
506 QSplitter *mLeftSplitter; 507 QSplitter *mLeftSplitter;
507 QWidget *mLeftFrame; 508 QWidget *mLeftFrame;
508 QWidgetStack *mRightFrame; 509 QWidgetStack *mRightFrame;
509 510
510 KDatePicker* mDatePicker; 511 KDatePicker* mDatePicker;
511 QVBox* mDateFrame; 512 QVBox* mDateFrame;
512 NavigatorBar *mNavigatorBar; 513 NavigatorBar *mNavigatorBar;
513 514
514 KDateNavigator *mDateNavigator; // widget showing small month view. 515 KDateNavigator *mDateNavigator; // widget showing small month view.
515 516
516 KOFilterView *mFilterView; 517 KOFilterView *mFilterView;
517 518
518 ResourceView *mResourceView; 519 ResourceView *mResourceView;
519 520
520 // calendar object for this viewing instance 521 // calendar object for this viewing instance
521 Calendar *mCalendar; 522 Calendar *mCalendar;
522 523
523 CalendarResourceManager *mResourceManager; 524 CalendarResourceManager *mResourceManager;
524 525
525 FileStorage *mStorage; 526 FileStorage *mStorage;
526 527
527 DateNavigator *mNavigator; 528 DateNavigator *mNavigator;
528 529
529 KOViewManager *mViewManager; 530 KOViewManager *mViewManager;
530 KODialogManager *mDialogManager; 531 KODialogManager *mDialogManager;
531 532
532 // Calendar filters 533 // Calendar filters
533 QPtrList<CalFilter> mFilters; 534 QPtrList<CalFilter> mFilters;
534 535
535 // various housekeeping variables. 536 // various housekeeping variables.
536 bool mModified; // flag indicating if calendar is modified 537 bool mModified; // flag indicating if calendar is modified
537 bool mReadOnly; // flag indicating if calendar is read-only 538 bool mReadOnly; // flag indicating if calendar is read-only
538 QDate mSaveSingleDate; 539 QDate mSaveSingleDate;
539 540
540 Incidence *mSelectedIncidence; 541 Incidence *mSelectedIncidence;
541 Incidence *mMoveIncidence; 542 Incidence *mMoveIncidence;
542 QPtrList<Event> mExternLastSyncEvent; 543 QPtrList<Event> mExternLastSyncEvent;
543 KOTodoView *mTodoList; 544 KOTodoView *mTodoList;
544 KOEventEditor * mEventEditor; 545 KOEventEditor * mEventEditor;
545 KOTodoEditor * mTodoEditor; 546 KOTodoEditor * mTodoEditor;
546 KOEventViewerDialog * mEventViewerDialog; 547 KOEventViewerDialog * mEventViewerDialog;
547 void keyPressEvent ( QKeyEvent *e) ; 548 void keyPressEvent ( QKeyEvent *e) ;
548 //QMap<Incidence*,KOIncidenceEditor*> mDialogList; 549 //QMap<Incidence*,KOIncidenceEditor*> mDialogList;
549}; 550};
550 551
551 552
552class CalendarViewVisitor : public Incidence::Visitor 553class CalendarViewVisitor : public Incidence::Visitor
553{ 554{
554 public: 555 public:
555 CalendarViewVisitor() : mView( 0 ) {} 556 CalendarViewVisitor() : mView( 0 ) {}
556 557
557 bool act( Incidence *incidence, CalendarView *view ) 558 bool act( Incidence *incidence, CalendarView *view )
558 { 559 {
559 mView = view; 560 mView = view;
560 return incidence->accept( *this ); 561 return incidence->accept( *this );
561 } 562 }
562 563
563 protected: 564 protected:
564 CalendarView *mView; 565 CalendarView *mView;
565}; 566};
566 567
567class ShowIncidenceVisitor : public CalendarViewVisitor 568class ShowIncidenceVisitor : public CalendarViewVisitor
568{ 569{
569 protected: 570 protected:
570 bool visit( Event *event ) { mView->showEvent( event ); return true; } 571 bool visit( Event *event ) { mView->showEvent( event ); return true; }
571 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } 572 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; }
572 bool visit( Journal * j ) { mView->showJournal( j );return true; } 573 bool visit( Journal * j ) { mView->showJournal( j );return true; }
573}; 574};
574 575
575class EditIncidenceVisitor : public CalendarViewVisitor 576class EditIncidenceVisitor : public CalendarViewVisitor
576{ 577{
577 protected: 578 protected:
578 bool visit( Event *event ) { mView->editEvent( event ); return true; } 579 bool visit( Event *event ) { mView->editEvent( event ); return true; }
579 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } 580 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; }
580 bool visit( Journal *j ) { mView->editJournal( j); return true; } 581 bool visit( Journal *j ) { mView->editJournal( j); return true; }
581}; 582};
582 583
583class DeleteIncidenceVisitor : public CalendarViewVisitor 584class DeleteIncidenceVisitor : public CalendarViewVisitor
584{ 585{
585 protected: 586 protected:
586 bool visit( Event *event ) { mView->deleteEvent( event ); return true; } 587 bool visit( Event *event ) { mView->deleteEvent( event ); return true; }
587 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } 588 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; }
588 bool visit( Journal * j) {mView->deleteJournal( j ); return true; } 589 bool visit( Journal * j) {mView->deleteJournal( j ); return true; }
589}; 590};
590 591
591#endif 592#endif
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 43ee2d7..7b666d1 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1,2502 +1,2500 @@
1#include <stdlib.h> 1#include <stdlib.h>
2 2
3#include <qaction.h> 3#include <qaction.h>
4#include <qpopupmenu.h> 4#include <qpopupmenu.h>
5#include <qpainter.h> 5#include <qpainter.h>
6#include <qwhatsthis.h> 6#include <qwhatsthis.h>
7#include <qpushbutton.h> 7#include <qpushbutton.h>
8#include <qmessagebox.h> 8#include <qmessagebox.h>
9#include <qlineedit.h> 9#include <qlineedit.h>
10#include <qtextcodec.h> 10#include <qtextcodec.h>
11#include <qfile.h> 11#include <qfile.h>
12#include <qdir.h> 12#include <qdir.h>
13#include <qapp.h> 13#include <qapp.h>
14#include <qfileinfo.h> 14#include <qfileinfo.h>
15#include <qlabel.h> 15#include <qlabel.h>
16#include <qmap.h> 16#include <qmap.h>
17#include <qwmatrix.h> 17#include <qwmatrix.h>
18#include <qtextbrowser.h> 18#include <qtextbrowser.h>
19#include <qtextstream.h> 19#include <qtextstream.h>
20#ifndef DESKTOP_VERSION 20#ifndef DESKTOP_VERSION
21#include <qpe/global.h> 21#include <qpe/global.h>
22#include <qpe/qpemenubar.h> 22#include <qpe/qpemenubar.h>
23#include <qpe/qpetoolbar.h> 23#include <qpe/qpetoolbar.h>
24#include <qpe/resource.h> 24#include <qpe/resource.h>
25#include <qpe/qpeapplication.h> 25#include <qpe/qpeapplication.h>
26#include <qtopia/alarmserver.h> 26#include <qtopia/alarmserver.h>
27#include <qtopia/qcopenvelope_qws.h> 27#include <qtopia/qcopenvelope_qws.h>
28#include <unistd.h> // for sleep 28#include <unistd.h> // for sleep
29#else 29#else
30#include <qmenubar.h> 30#include <qmenubar.h>
31#include <qtoolbar.h> 31#include <qtoolbar.h>
32#include <qapplication.h> 32#include <qapplication.h>
33//#include <resource.h> 33//#include <resource.h>
34 34
35#endif 35#endif
36#include <libkcal/calendarlocal.h> 36#include <libkcal/calendarlocal.h>
37#include <libkcal/todo.h> 37#include <libkcal/todo.h>
38#include <libkdepim/ksyncprofile.h> 38#include <libkdepim/ksyncprofile.h>
39#include <libkcal/kincidenceformatter.h> 39#include <libkcal/kincidenceformatter.h>
40#include <libkdepim/kpimglobalprefs.h> 40#include <libkdepim/kpimglobalprefs.h>
41 41
42#include "calendarview.h" 42#include "calendarview.h"
43#include "koviewmanager.h" 43#include "koviewmanager.h"
44#include "datenavigator.h" 44#include "datenavigator.h"
45#include "koagendaview.h" 45#include "koagendaview.h"
46#include "koagenda.h" 46#include "koagenda.h"
47#include "kodialogmanager.h" 47#include "kodialogmanager.h"
48#include "kdialogbase.h" 48#include "kdialogbase.h"
49#include "kapplication.h" 49#include "kapplication.h"
50#include "kofilterview.h" 50#include "kofilterview.h"
51#include "kstandarddirs.h" 51#include "kstandarddirs.h"
52#include "koprefs.h" 52#include "koprefs.h"
53#include "kfiledialog.h" 53#include "kfiledialog.h"
54#include "koglobals.h" 54#include "koglobals.h"
55#include "kglobal.h" 55#include "kglobal.h"
56#include "klocale.h" 56#include "klocale.h"
57#include "kconfig.h" 57#include "kconfig.h"
58#include "simplealarmclient.h" 58#include "simplealarmclient.h"
59#include "externalapphandler.h" 59#include "externalapphandler.h"
60 60
61using namespace KCal; 61using namespace KCal;
62#ifndef _WIN32_ 62#ifndef _WIN32_
63#include <unistd.h> 63#include <unistd.h>
64#else 64#else
65#include "koimportoldialog.h" 65#include "koimportoldialog.h"
66#endif 66#endif
67#include "mainwindow.h" 67#include "mainwindow.h"
68 68
69int globalFlagBlockStartup; 69int globalFlagBlockStartup;
70MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : 70MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
71 QMainWindow( parent, name ) 71 QMainWindow( parent, name )
72{ 72{
73 mPassWordPiSync = "abc"; 73 mPassWordPiSync = "abc";
74#ifdef DESKTOP_VERSION 74#ifdef DESKTOP_VERSION
75 setFont( QFont("Arial"), 14 ); 75 setFont( QFont("Arial"), 14 );
76#endif 76#endif
77 mSyncActionDialog = 0; 77 mSyncActionDialog = 0;
78 mServerSocket = 0; 78 mServerSocket = 0;
79 mClosed = false; 79 mClosed = false;
80 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; 80 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
81 QString confFile = locateLocal("config","korganizerrc"); 81 QString confFile = locateLocal("config","korganizerrc");
82 QFileInfo finf ( confFile ); 82 QFileInfo finf ( confFile );
83 bool showWarning = !finf.exists(); 83 bool showWarning = !finf.exists();
84 setIcon(SmallIcon( "ko24" ) ); 84 setIcon(SmallIcon( "ko24" ) );
85 mBlockAtStartup = true; 85 mBlockAtStartup = true;
86 mFlagKeyPressed = false; 86 mFlagKeyPressed = false;
87 setCaption("KOrganizer/Pi"); 87 setCaption("KOrganizer/Pi");
88 KOPrefs *p = KOPrefs::instance(); 88 KOPrefs *p = KOPrefs::instance();
89 KPimGlobalPrefs::instance()->setGlobalConfig(); 89 KPimGlobalPrefs::instance()->setGlobalConfig();
90 // if ( QApplication::desktop()->height() > 480 ) { 90 // if ( QApplication::desktop()->height() > 480 ) {
91// if ( p->mHourSize == 4 ) 91// if ( p->mHourSize == 4 )
92// p->mHourSize = 6; 92// p->mHourSize = 6;
93// } 93// }
94 if ( p->mHourSize > 18 ) 94 if ( p->mHourSize > 18 )
95 p->mHourSize = 18; 95 p->mHourSize = 18;
96 QMainWindow::ToolBarDock tbd; 96 QMainWindow::ToolBarDock tbd;
97 if ( p->mToolBarHor ) { 97 if ( p->mToolBarHor ) {
98 if ( p->mToolBarUp ) 98 if ( p->mToolBarUp )
99 tbd = Bottom; 99 tbd = Bottom;
100 else 100 else
101 tbd = Top; 101 tbd = Top;
102 } 102 }
103 else { 103 else {
104 if ( p->mToolBarUp ) 104 if ( p->mToolBarUp )
105 tbd = Right; 105 tbd = Right;
106 else 106 else
107 tbd = Left; 107 tbd = Left;
108 } 108 }
109 if ( KOPrefs::instance()->mUseAppColors ) 109 if ( KOPrefs::instance()->mUseAppColors )
110 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 110 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
111 globalFlagBlockStartup = 1; 111 globalFlagBlockStartup = 1;
112 iconToolBar = new QPEToolBar( this ); 112 iconToolBar = new QPEToolBar( this );
113 addToolBar (iconToolBar , tbd ); 113 addToolBar (iconToolBar , tbd );
114 mBlockSaveFlag = false; 114 mBlockSaveFlag = false;
115 mCalendarModifiedFlag = false; 115 mCalendarModifiedFlag = false;
116 116
117 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); 117 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
118 splash->setAlignment ( AlignCenter ); 118 splash->setAlignment ( AlignCenter );
119 setCentralWidget( splash ); 119 setCentralWidget( splash );
120#ifndef DESKTOP_VERSION 120#ifndef DESKTOP_VERSION
121 showMaximized(); 121 showMaximized();
122#endif 122#endif
123 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); 123 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
124 setDefaultPreferences(); 124 setDefaultPreferences();
125 mCalendar = new CalendarLocal(); 125 mCalendar = new CalendarLocal();
126 mView = new CalendarView( mCalendar, this,"mCalendar " ); 126 mView = new CalendarView( mCalendar, this,"mCalendar " );
127 mView->hide(); 127 mView->hide();
128 //mView->resize(splash->size() ); 128 //mView->resize(splash->size() );
129 initActions(); 129 initActions();
130#ifndef DESKTOP_VERSION 130#ifndef DESKTOP_VERSION
131 iconToolBar->show(); 131 iconToolBar->show();
132 qApp->processEvents(); 132 qApp->processEvents();
133#endif 133#endif
134 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); 134 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
135 int vh = height() ; 135 int vh = height() ;
136 int vw = width(); 136 int vw = width();
137 //qDebug("Toolbar hei %d ",iconToolBar->height() ); 137 //qDebug("Toolbar hei %d ",iconToolBar->height() );
138 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 138 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
139 vh -= iconToolBar->height(); 139 vh -= iconToolBar->height();
140 } else { 140 } else {
141 vw -= iconToolBar->height(); 141 vw -= iconToolBar->height();
142 } 142 }
143 //mView->setMaximumSize( splash->size() ); 143 //mView->setMaximumSize( splash->size() );
144 //mView->resize( splash->size() ); 144 //mView->resize( splash->size() );
145 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 145 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
146 mView->readSettings(); 146 mView->readSettings();
147 bool oldOpened = false;
148 bool newFile = false; 147 bool newFile = false;
149 if( !QFile::exists( defaultFileName() ) ) { 148 if( !QFile::exists( defaultFileName() ) ) {
150 QFileInfo finfo ( defaultFileName() ); 149 QFileInfo finfo ( defaultFileName() );
151 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); 150 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
152 qDebug("oldfile %s ", oldFile.latin1()); 151 qDebug("oldfile %s ", oldFile.latin1());
153 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"; 152 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";
154 finfo.setFile( oldFile ); 153 finfo.setFile( oldFile );
155 if (finfo.exists() ) { 154 if (finfo.exists() ) {
156 KMessageBox::information( this, message); 155 KMessageBox::information( this, message);
157 mView->openCalendar( oldFile ); 156 mView->openCalendar( oldFile );
158 qApp->processEvents(); 157 qApp->processEvents();
159 } else { 158 } else {
160 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); 159 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
161 finfo.setFile( oldFile ); 160 finfo.setFile( oldFile );
162 if (finfo.exists() ) { 161 if (finfo.exists() ) {
163 KMessageBox::information( this, message); 162 KMessageBox::information( this, message);
164 mView->openCalendar( oldFile ); 163 mView->openCalendar( oldFile );
165 qApp->processEvents(); 164 qApp->processEvents();
166 } 165 }
167 } 166 }
168 mView->saveCalendar( defaultFileName() ); 167 mView->saveCalendar( defaultFileName() );
169 newFile = true; 168 newFile = true;
170 } 169 }
171 170
172 QTime neededSaveTime = QDateTime::currentDateTime().time(); 171 QTime neededSaveTime = QDateTime::currentDateTime().time();
173 if ( ! oldOpened ) 172 mView->openCalendar( defaultFileName() );
174 mView->openCalendar( defaultFileName() );
175 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 173 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
176 qDebug("KO: Calendar loading time: %d ms",msNeeded ); 174 qDebug("KO: Calendar loading time: %d ms",msNeeded );
177 175
178 if ( KOPrefs::instance()->mLanguageChanged ) { 176 if ( KOPrefs::instance()->mLanguageChanged ) {
179 KOPrefs::instance()->setCategoryDefaults(); 177 KOPrefs::instance()->setCategoryDefaults();
180 int count = mView->addCategories(); 178 int count = mView->addCategories();
181 KOPrefs::instance()->mLanguageChanged = false; 179 KOPrefs::instance()->mLanguageChanged = false;
182 } 180 }
183 processIncidenceSelection( 0 ); 181 processIncidenceSelection( 0 );
184 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), 182 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
185 SLOT( processIncidenceSelection( Incidence * ) ) ); 183 SLOT( processIncidenceSelection( Incidence * ) ) );
186 connect( mView, SIGNAL( modifiedChanged( bool ) ), 184 connect( mView, SIGNAL( modifiedChanged( bool ) ),
187 SLOT( slotModifiedChanged( bool ) ) ); 185 SLOT( slotModifiedChanged( bool ) ) );
188 186
189 187
190 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); 188 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
191 mView->setModified( false ); 189 mView->setModified( false );
192 mBlockAtStartup = false; 190 mBlockAtStartup = false;
193 mView->setModified( false ); 191 mView->setModified( false );
194 setCentralWidget( mView ); 192 setCentralWidget( mView );
195 globalFlagBlockStartup = 0; 193 globalFlagBlockStartup = 0;
196 mView->show(); 194 mView->show();
197 delete splash; 195 delete splash;
198 if ( newFile ) 196 if ( newFile )
199 mView->updateConfig(); 197 mView->updateConfig();
200 // qApp->processEvents(); 198 // qApp->processEvents();
201 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 199 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
202 fillSyncMenu(); 200 fillSyncMenu();
203 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); 201 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
204 if ( showWarning ) { 202 if ( showWarning ) {
205 KMessageBox::information( this, 203 KMessageBox::information( this,
206 "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"); 204 "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");
207 qApp->processEvents(); 205 qApp->processEvents();
208 mView->dialogManager()->showSyncOptions(); 206 mView->dialogManager()->showSyncOptions();
209 } 207 }
210 208
211 //US listen for result adressed from Ka/Pi 209 //US listen for result adressed from Ka/Pi
212#ifndef DESKTOP_VERSION 210#ifndef DESKTOP_VERSION
213 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 211 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
214#endif 212#endif
215} 213}
216MainWindow::~MainWindow() 214MainWindow::~MainWindow()
217{ 215{
218 //qDebug("MainWindow::~MainWindow() "); 216 //qDebug("MainWindow::~MainWindow() ");
219 //save toolbar location 217 //save toolbar location
220 delete mServerSocket; 218 delete mServerSocket;
221 delete mCalendar; 219 delete mCalendar;
222 delete KOPrefs::instance(); 220 delete KOPrefs::instance();
223 delete KIncidenceFormatter::instance(); 221 delete KIncidenceFormatter::instance();
224 222
225 223
226} 224}
227void MainWindow::showMaximized () 225void MainWindow::showMaximized ()
228{ 226{
229#ifndef DESKTOP_VERSION 227#ifndef DESKTOP_VERSION
230 if ( ! globalFlagBlockStartup ) 228 if ( ! globalFlagBlockStartup )
231 if ( mClosed ) 229 if ( mClosed )
232 mView->goToday(); 230 mView->goToday();
233#endif 231#endif
234 QWidget::showMaximized () ; 232 QWidget::showMaximized () ;
235 mClosed = false; 233 mClosed = false;
236} 234}
237void MainWindow::closeEvent( QCloseEvent* ce ) 235void MainWindow::closeEvent( QCloseEvent* ce )
238{ 236{
239 237
240 238
241 239
242 if ( ! KOPrefs::instance()->mAskForQuit ) { 240 if ( ! KOPrefs::instance()->mAskForQuit ) {
243 saveOnClose(); 241 saveOnClose();
244 mClosed = true; 242 mClosed = true;
245 ce->accept(); 243 ce->accept();
246 return; 244 return;
247 245
248 } 246 }
249 247
250 switch( QMessageBox::information( this, "KO/Pi", 248 switch( QMessageBox::information( this, "KO/Pi",
251 i18n("Do you really want\nto close KO/Pi?"), 249 i18n("Do you really want\nto close KO/Pi?"),
252 i18n("Close"), i18n("No"), 250 i18n("Close"), i18n("No"),
253 0, 0 ) ) { 251 0, 0 ) ) {
254 case 0: 252 case 0:
255 saveOnClose(); 253 saveOnClose();
256 mClosed = true; 254 mClosed = true;
257 ce->accept(); 255 ce->accept();
258 break; 256 break;
259 case 1: 257 case 1:
260 ce->ignore(); 258 ce->ignore();
261 break; 259 break;
262 case 2: 260 case 2:
263 261
264 default: 262 default:
265 break; 263 break;
266 } 264 }
267 265
268 266
269} 267}
270 268
271void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) 269void MainWindow::recieve( const QCString& cmsg, const QByteArray& data )
272{ 270{
273 QDataStream stream( data, IO_ReadOnly ); 271 QDataStream stream( data, IO_ReadOnly );
274 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); 272 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" );
275 //QString datamess; 273 //QString datamess;
276 //qDebug("message "); 274 //qDebug("message ");
277 qDebug("KO: QCOP message received: %s ", cmsg.data() ); 275 qDebug("KO: QCOP message received: %s ", cmsg.data() );
278 276
279 if ( cmsg == "-writeFile" ) { 277 if ( cmsg == "-writeFile" ) {
280 // I made from the "-writeFile" an "-writeAlarm" 278 // I made from the "-writeFile" an "-writeAlarm"
281 mView->viewManager()->showWhatsNextView(); 279 mView->viewManager()->showWhatsNextView();
282 mCalendar->checkAlarmForIncidence( 0, true); 280 mCalendar->checkAlarmForIncidence( 0, true);
283 showMaximized(); 281 showMaximized();
284 raise(); 282 raise();
285 return; 283 return;
286 } 284 }
287 285
288 if ( cmsg == "-writeFile" ) { 286 if ( cmsg == "-writeFile" ) {
289 // I made from the "-writeFile" an "-writeAlarm" 287 // I made from the "-writeFile" an "-writeAlarm"
290 mView->viewManager()->showWhatsNextView(); 288 mView->viewManager()->showWhatsNextView();
291 mCalendar->checkAlarmForIncidence( 0, true); 289 mCalendar->checkAlarmForIncidence( 0, true);
292 showMaximized(); 290 showMaximized();
293 raise(); 291 raise();
294 return; 292 return;
295 293
296 } 294 }
297 if ( cmsg == "-writeFileSilent" ) { 295 if ( cmsg == "-writeFileSilent" ) {
298 // I made from the "-writeFile" an "-writeAlarm" 296 // I made from the "-writeFile" an "-writeAlarm"
299 // mView->viewManager()->showWhatsNextView(); 297 // mView->viewManager()->showWhatsNextView();
300 mCalendar->checkAlarmForIncidence( 0, true); 298 mCalendar->checkAlarmForIncidence( 0, true);
301 //showMaximized(); 299 //showMaximized();
302 //raise(); 300 //raise();
303 hide(); 301 hide();
304 return; 302 return;
305 } 303 }
306 if ( cmsg == "-newCountdown" ) { 304 if ( cmsg == "-newCountdown" ) {
307 qDebug("newCountdown "); 305 qDebug("newCountdown ");
308 306
309 } 307 }
310 QString msg ; 308 QString msg ;
311 QString allmsg = cmsg; 309 QString allmsg = cmsg;
312 while ( allmsg.length() > 0 ) { 310 while ( allmsg.length() > 0 ) {
313 int nextC = allmsg.find( "-", 1 ); 311 int nextC = allmsg.find( "-", 1 );
314 if ( nextC == -1 ) { 312 if ( nextC == -1 ) {
315 msg = allmsg; 313 msg = allmsg;
316 allmsg = ""; 314 allmsg = "";
317 } else{ 315 } else{
318 msg = allmsg.left( nextC ); 316 msg = allmsg.left( nextC );
319 allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); 317 allmsg = allmsg.mid( nextC, allmsg.length()-nextC );
320 } 318 }
321 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); 319 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() );
322 if ( msg == "-newEvent" ) { 320 if ( msg == "-newEvent" ) {
323 mView->newEvent(); 321 mView->newEvent();
324 } 322 }
325 if ( msg == "-newTodo" ) { 323 if ( msg == "-newTodo" ) {
326 mView->newTodo(); 324 mView->newTodo();
327 325
328 } 326 }
329 if ( msg == "-showWN" ) { 327 if ( msg == "-showWN" ) {
330 mView->viewManager()->showWhatsNextView(); 328 mView->viewManager()->showWhatsNextView();
331 } 329 }
332 if ( msg == "-showTodo" ) { 330 if ( msg == "-showTodo" ) {
333 mView->viewManager()->showTodoView(); 331 mView->viewManager()->showTodoView();
334 } 332 }
335 if ( msg == "-showList" ) { 333 if ( msg == "-showList" ) {
336 mView->viewManager()->showListView(); 334 mView->viewManager()->showListView();
337 } 335 }
338 else if ( msg == "-showDay" ) { 336 else if ( msg == "-showDay" ) {
339 mView->viewManager()->showDayView(); 337 mView->viewManager()->showDayView();
340 } 338 }
341 else if ( msg == "-showWWeek" ) { 339 else if ( msg == "-showWWeek" ) {
342 mView->viewManager()->showWorkWeekView(); 340 mView->viewManager()->showWorkWeekView();
343 } 341 }
344 else if ( msg == "-ringSync" ) { 342 else if ( msg == "-ringSync" ) {
345 multiSync( false ); 343 multiSync( false );
346 } 344 }
347 else if ( msg == "-showWeek" ) { 345 else if ( msg == "-showWeek" ) {
348 mView->viewManager()->showWeekView(); 346 mView->viewManager()->showWeekView();
349 } 347 }
350 else if ( msg == "-showTodo" ) { 348 else if ( msg == "-showTodo" ) {
351 mView->viewManager()->showTodoView(); 349 mView->viewManager()->showTodoView();
352 } 350 }
353 else if ( msg == "-showJournal" ) { 351 else if ( msg == "-showJournal" ) {
354 mView->dateNavigator()->selectDates( 1 ); 352 mView->dateNavigator()->selectDates( 1 );
355 mView->dateNavigator()->selectToday(); 353 mView->dateNavigator()->selectToday();
356 mView->viewManager()->showJournalView(); 354 mView->viewManager()->showJournalView();
357 } 355 }
358 else if ( msg == "-showKO" ) { 356 else if ( msg == "-showKO" ) {
359 mView->viewManager()->showNextXView(); 357 mView->viewManager()->showNextXView();
360 } 358 }
361 else if ( msg == "-showWNext" || msg == "nextView()" ) { 359 else if ( msg == "-showWNext" || msg == "nextView()" ) {
362 mView->viewManager()->showWhatsNextView(); 360 mView->viewManager()->showWhatsNextView();
363 } 361 }
364 else if ( msg == "-showNextXView" ) { 362 else if ( msg == "-showNextXView" ) {
365 mView->viewManager()->showNextXView(); 363 mView->viewManager()->showNextXView();
366 } 364 }
367 365
368 366
369 } 367 }
370 368
371 showMaximized(); 369 showMaximized();
372 raise(); 370 raise();
373} 371}
374 372
375QPixmap MainWindow::loadPixmap( QString name ) 373QPixmap MainWindow::loadPixmap( QString name )
376{ 374{
377 return SmallIcon( name ); 375 return SmallIcon( name );
378 376
379} 377}
380void MainWindow::initActions() 378void MainWindow::initActions()
381{ 379{
382 //KOPrefs::instance()->mShowFullMenu 380 //KOPrefs::instance()->mShowFullMenu
383 iconToolBar->clear(); 381 iconToolBar->clear();
384 KOPrefs *p = KOPrefs::instance(); 382 KOPrefs *p = KOPrefs::instance();
385 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); 383 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar );
386 384
387 QPopupMenu *viewMenu = new QPopupMenu( this ); 385 QPopupMenu *viewMenu = new QPopupMenu( this );
388 QPopupMenu *actionMenu = new QPopupMenu( this ); 386 QPopupMenu *actionMenu = new QPopupMenu( this );
389 QPopupMenu *importMenu = new QPopupMenu( this ); 387 QPopupMenu *importMenu = new QPopupMenu( this );
390 selectFilterMenu = new QPopupMenu( this ); 388 selectFilterMenu = new QPopupMenu( this );
391 selectFilterMenu->setCheckable( true ); 389 selectFilterMenu->setCheckable( true );
392 syncMenu = new QPopupMenu( this ); 390 syncMenu = new QPopupMenu( this );
393 configureAgendaMenu = new QPopupMenu( this ); 391 configureAgendaMenu = new QPopupMenu( this );
394 configureToolBarMenu = new QPopupMenu( this ); 392 configureToolBarMenu = new QPopupMenu( this );
395 QPopupMenu *helpMenu = new QPopupMenu( this ); 393 QPopupMenu *helpMenu = new QPopupMenu( this );
396 if ( KOPrefs::instance()->mShowFullMenu ) { 394 if ( KOPrefs::instance()->mShowFullMenu ) {
397 QMenuBar *menuBar1; 395 QMenuBar *menuBar1;
398 menuBar1 = menuBar(); 396 menuBar1 = menuBar();
399 menuBar1->insertItem( i18n("File"), importMenu ); 397 menuBar1->insertItem( i18n("File"), importMenu );
400 menuBar1->insertItem( i18n("View"), viewMenu ); 398 menuBar1->insertItem( i18n("View"), viewMenu );
401 menuBar1->insertItem( i18n("Actions"), actionMenu ); 399 menuBar1->insertItem( i18n("Actions"), actionMenu );
402 menuBar1->insertItem( i18n("Synchronize"), syncMenu ); 400 menuBar1->insertItem( i18n("Synchronize"), syncMenu );
403 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 401 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu );
404 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); 402 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu );
405 menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); 403 menuBar1->insertItem( i18n("Filter"),selectFilterMenu );
406 menuBar1->insertItem( i18n("Help"), helpMenu ); 404 menuBar1->insertItem( i18n("Help"), helpMenu );
407 } else { 405 } else {
408 QPEMenuBar *menuBar1; 406 QPEMenuBar *menuBar1;
409 menuBar1 = new QPEMenuBar( iconToolBar ); 407 menuBar1 = new QPEMenuBar( iconToolBar );
410 QPopupMenu *menuBar = new QPopupMenu( this ); 408 QPopupMenu *menuBar = new QPopupMenu( this );
411 menuBar1->insertItem( i18n("ME"), menuBar); 409 menuBar1->insertItem( i18n("ME"), menuBar);
412 menuBar->insertItem( i18n("File"), importMenu ); 410 menuBar->insertItem( i18n("File"), importMenu );
413 menuBar->insertItem( i18n("View"), viewMenu ); 411 menuBar->insertItem( i18n("View"), viewMenu );
414 menuBar->insertItem( i18n("Actions"), actionMenu ); 412 menuBar->insertItem( i18n("Actions"), actionMenu );
415 menuBar->insertItem( i18n("Synchronize"), syncMenu ); 413 menuBar->insertItem( i18n("Synchronize"), syncMenu );
416 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 414 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu );
417 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); 415 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu );
418 menuBar->insertItem( i18n("Filter"),selectFilterMenu ); 416 menuBar->insertItem( i18n("Filter"),selectFilterMenu );
419 menuBar->insertItem( i18n("Help"), helpMenu ); 417 menuBar->insertItem( i18n("Help"), helpMenu );
420 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); 418 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() );
421 menuBar1->setMaximumSize( menuBar1->sizeHint( )); 419 menuBar1->setMaximumSize( menuBar1->sizeHint( ));
422 } 420 }
423 connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) ); 421 connect ( syncMenu, SIGNAL( activated ( int ) ), this, SLOT (slotSyncMenu( int ) ) );
424 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); 422 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
425 connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) ); 423 connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) );
426 424
427 // ****************** 425 // ******************
428 QAction *action; 426 QAction *action;
429 QIconSet icon; 427 QIconSet icon;
430 // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); 428 // QPopupMenu *configureMenu= new QPopupMenu( menuBar );
431 configureToolBarMenu->setCheckable( true ); 429 configureToolBarMenu->setCheckable( true );
432 430
433 QString pathString = ""; 431 QString pathString = "";
434 if ( !p->mToolBarMiniIcons ) { 432 if ( !p->mToolBarMiniIcons ) {
435 if ( QApplication::desktop()->width() < 480 ) 433 if ( QApplication::desktop()->width() < 480 )
436 pathString += "icons16/"; 434 pathString += "icons16/";
437 } else 435 } else
438 pathString += "iconsmini/"; 436 pathString += "iconsmini/";
439 configureAgendaMenu->setCheckable( true ); 437 configureAgendaMenu->setCheckable( true );
440 configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 ); 438 configureAgendaMenu->insertItem(i18n("Toggle Allday"), 1 );
441 configureAgendaMenu->insertSeparator(); 439 configureAgendaMenu->insertSeparator();
442 configureAgendaMenu->insertItem(i18n("Tiny"), 4 ); 440 configureAgendaMenu->insertItem(i18n("Tiny"), 4 );
443 configureAgendaMenu->insertItem(i18n("Small"), 6 ); 441 configureAgendaMenu->insertItem(i18n("Small"), 6 );
444 configureAgendaMenu->insertItem(i18n("Medium"), 8 ); 442 configureAgendaMenu->insertItem(i18n("Medium"), 8 );
445 configureAgendaMenu->insertItem(i18n("Normal"), 10 ); 443 configureAgendaMenu->insertItem(i18n("Normal"), 10 );
446 configureAgendaMenu->insertItem(i18n("Large"), 12 ); 444 configureAgendaMenu->insertItem(i18n("Large"), 12 );
447 configureAgendaMenu->insertItem(i18n("Big"), 14 ); 445 configureAgendaMenu->insertItem(i18n("Big"), 14 );
448 configureAgendaMenu->insertItem(i18n("Bigger"), 16 ); 446 configureAgendaMenu->insertItem(i18n("Bigger"), 16 );
449 configureAgendaMenu->insertItem(i18n("Biggest"), 18 ); 447 configureAgendaMenu->insertItem(i18n("Biggest"), 18 );
450 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); 448 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu );
451 449
452 icon = loadPixmap( pathString + "configure" ); 450 icon = loadPixmap( pathString + "configure" );
453 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); 451 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this );
454 action->addTo( actionMenu ); 452 action->addTo( actionMenu );
455 connect( action, SIGNAL( activated() ), 453 connect( action, SIGNAL( activated() ),
456 mView, SLOT( edit_options() ) ); 454 mView, SLOT( edit_options() ) );
457 actionMenu->insertSeparator(); 455 actionMenu->insertSeparator();
458 icon = loadPixmap( pathString + "newevent" ); 456 icon = loadPixmap( pathString + "newevent" );
459 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); 457 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 );
460 configureToolBarMenu->insertSeparator(); 458 configureToolBarMenu->insertSeparator();
461 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); 459 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 );
462 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); 460 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this );
463 ne_action->addTo( actionMenu ); 461 ne_action->addTo( actionMenu );
464 connect( ne_action, SIGNAL( activated() ), 462 connect( ne_action, SIGNAL( activated() ),
465 mView, SLOT( newEvent() ) ); 463 mView, SLOT( newEvent() ) );
466 icon = loadPixmap( pathString + "newtodo" ); 464 icon = loadPixmap( pathString + "newtodo" );
467 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); 465 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 );
468 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); 466 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this );
469 nt_action->addTo( actionMenu ); 467 nt_action->addTo( actionMenu );
470 connect( nt_action, SIGNAL( activated() ), 468 connect( nt_action, SIGNAL( activated() ),
471 mView, SLOT( newTodo() ) ); 469 mView, SLOT( newTodo() ) );
472 icon = loadPixmap( pathString + "navi" ); 470 icon = loadPixmap( pathString + "navi" );
473 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); 471 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this );
474 action->addTo( viewMenu ); 472 action->addTo( viewMenu );
475 connect( action, SIGNAL( activated() ), 473 connect( action, SIGNAL( activated() ),
476 mView, SLOT( toggleDateNavigatorWidget() ) ); 474 mView, SLOT( toggleDateNavigatorWidget() ) );
477 icon = loadPixmap( pathString + "filter" ); 475 icon = loadPixmap( pathString + "filter" );
478 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); 476 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this );
479 action->addTo( viewMenu ); 477 action->addTo( viewMenu );
480 connect( action, SIGNAL( activated() ), 478 connect( action, SIGNAL( activated() ),
481 mView, SLOT( toggleFilter() ) ); 479 mView, SLOT( toggleFilter() ) );
482 480
483 481
484 viewMenu->insertSeparator(); 482 viewMenu->insertSeparator();
485 icon = loadPixmap( pathString + "picker" ); 483 icon = loadPixmap( pathString + "picker" );
486 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); 484 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this );
487 action->addTo( viewMenu ); 485 action->addTo( viewMenu );
488 connect( action, SIGNAL( activated() ), 486 connect( action, SIGNAL( activated() ),
489 mView, SLOT( showDatePicker() ) ); 487 mView, SLOT( showDatePicker() ) );
490 action->addTo( iconToolBar ); 488 action->addTo( iconToolBar );
491 viewMenu->insertSeparator(); 489 viewMenu->insertSeparator();
492 icon = loadPixmap( pathString + "list" ); 490 icon = loadPixmap( pathString + "list" );
493 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); 491 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 );
494 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); 492 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this );
495 showlist_action->addTo( viewMenu ); 493 showlist_action->addTo( viewMenu );
496 connect( showlist_action, SIGNAL( activated() ), 494 connect( showlist_action, SIGNAL( activated() ),
497 mView->viewManager(), SLOT( showListView() ) ); 495 mView->viewManager(), SLOT( showListView() ) );
498 496
499 497
500 icon = loadPixmap( pathString + "day" ); 498 icon = loadPixmap( pathString + "day" );
501 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); 499 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 );
502 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); 500 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this );
503 day1_action->addTo( viewMenu ); 501 day1_action->addTo( viewMenu );
504 // action->addTo( toolBar ); 502 // action->addTo( toolBar );
505 connect( day1_action, SIGNAL( activated() ), 503 connect( day1_action, SIGNAL( activated() ),
506 mView->viewManager(), SLOT( showDayView() ) ); 504 mView->viewManager(), SLOT( showDayView() ) );
507 505
508 icon = loadPixmap( pathString + "workweek" ); 506 icon = loadPixmap( pathString + "workweek" );
509 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); 507 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 );
510 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); 508 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this );
511 day5_action->addTo( viewMenu ); 509 day5_action->addTo( viewMenu );
512 connect( day5_action, SIGNAL( activated() ), 510 connect( day5_action, SIGNAL( activated() ),
513 mView->viewManager(), SLOT( showWorkWeekView() ) ); 511 mView->viewManager(), SLOT( showWorkWeekView() ) );
514 512
515 icon = loadPixmap( pathString + "week" ); 513 icon = loadPixmap( pathString + "week" );
516 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); 514 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 );
517 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); 515 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this );
518 day7_action->addTo( viewMenu ); 516 day7_action->addTo( viewMenu );
519 connect( day7_action, SIGNAL( activated() ), 517 connect( day7_action, SIGNAL( activated() ),
520 mView->viewManager(), SLOT( showWeekView() ) ); 518 mView->viewManager(), SLOT( showWeekView() ) );
521 519
522 icon = loadPixmap( pathString + "month" ); 520 icon = loadPixmap( pathString + "month" );
523 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); 521 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 );
524 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); 522 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this );
525 month_action->addTo( viewMenu ); 523 month_action->addTo( viewMenu );
526 connect( month_action, SIGNAL( activated() ), 524 connect( month_action, SIGNAL( activated() ),
527 mView->viewManager(), SLOT( showMonthView() ) ); 525 mView->viewManager(), SLOT( showMonthView() ) );
528 526
529 icon = loadPixmap( pathString + "todo" ); 527 icon = loadPixmap( pathString + "todo" );
530 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); 528 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 );
531 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); 529 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this );
532 todoview_action->addTo( viewMenu ); 530 todoview_action->addTo( viewMenu );
533 connect( todoview_action, SIGNAL( activated() ), 531 connect( todoview_action, SIGNAL( activated() ),
534 mView->viewManager(), SLOT( showTodoView() ) ); 532 mView->viewManager(), SLOT( showTodoView() ) );
535 533
536 icon = loadPixmap( pathString + "journal" ); 534 icon = loadPixmap( pathString + "journal" );
537 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); 535 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 );
538 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); 536 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this );
539 viewjournal_action->addTo( viewMenu ); 537 viewjournal_action->addTo( viewMenu );
540 connect( viewjournal_action, SIGNAL( activated() ), 538 connect( viewjournal_action, SIGNAL( activated() ),
541 mView->viewManager(), SLOT( showJournalView() ) ); 539 mView->viewManager(), SLOT( showJournalView() ) );
542 540
543 icon = loadPixmap( pathString + "xdays" ); 541 icon = loadPixmap( pathString + "xdays" );
544 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 ); 542 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 );
545 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); 543 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this );
546 xdays_action->addTo( viewMenu ); 544 xdays_action->addTo( viewMenu );
547 connect( xdays_action, SIGNAL( activated() ), 545 connect( xdays_action, SIGNAL( activated() ),
548 mView->viewManager(), SLOT( showNextXView() ) ); 546 mView->viewManager(), SLOT( showNextXView() ) );
549 547
550 icon = loadPixmap( pathString + "whatsnext" ); 548 icon = loadPixmap( pathString + "whatsnext" );
551 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 ); 549 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 );
552 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); 550 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this );
553 whatsnext_action->addTo( viewMenu ); 551 whatsnext_action->addTo( viewMenu );
554 connect( whatsnext_action, SIGNAL( activated() ), 552 connect( whatsnext_action, SIGNAL( activated() ),
555 mView->viewManager(), SLOT( showWhatsNextView() ) ); 553 mView->viewManager(), SLOT( showWhatsNextView() ) );
556 554
557#if 0 555#if 0
558 action = new QAction( "view_timespan", "Time Span", 0, this ); 556 action = new QAction( "view_timespan", "Time Span", 0, this );
559 action->addTo( viewMenu ); 557 action->addTo( viewMenu );
560 connect( action, SIGNAL( activated() ), 558 connect( action, SIGNAL( activated() ),
561 mView->viewManager(), SLOT( showTimeSpanView() ) ); 559 mView->viewManager(), SLOT( showTimeSpanView() ) );
562#endif 560#endif
563 561
564 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, 562 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0,
565 this ); 563 this );
566 mNewSubTodoAction->addTo( actionMenu ); 564 mNewSubTodoAction->addTo( actionMenu );
567 connect( mNewSubTodoAction, SIGNAL( activated() ), 565 connect( mNewSubTodoAction, SIGNAL( activated() ),
568 mView, SLOT( newSubTodo() ) ); 566 mView, SLOT( newSubTodo() ) );
569 567
570 actionMenu->insertSeparator(); 568 actionMenu->insertSeparator();
571 569
572 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); 570 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this );
573 mShowAction->addTo( actionMenu ); 571 mShowAction->addTo( actionMenu );
574 connect( mShowAction, SIGNAL( activated() ), 572 connect( mShowAction, SIGNAL( activated() ),
575 mView, SLOT( showIncidence() ) ); 573 mView, SLOT( showIncidence() ) );
576 574
577 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); 575 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this );
578 mEditAction->addTo( actionMenu ); 576 mEditAction->addTo( actionMenu );
579 connect( mEditAction, SIGNAL( activated() ), 577 connect( mEditAction, SIGNAL( activated() ),
580 mView, SLOT( editIncidence() ) ); 578 mView, SLOT( editIncidence() ) );
581 579
582 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); 580 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this );
583 mDeleteAction->addTo( actionMenu ); 581 mDeleteAction->addTo( actionMenu );
584 connect( mDeleteAction, SIGNAL( activated() ), 582 connect( mDeleteAction, SIGNAL( activated() ),
585 mView, SLOT( deleteIncidence() ) ); 583 mView, SLOT( deleteIncidence() ) );
586 584
587 actionMenu->insertSeparator(); 585 actionMenu->insertSeparator();
588 586
589 action = new QAction( "purge_completed", i18n("Purge Completed"), 0, 587 action = new QAction( "purge_completed", i18n("Purge Completed"), 0,
590 this ); 588 this );
591 action->addTo( actionMenu ); 589 action->addTo( actionMenu );
592 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); 590 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) );
593 591
594 icon = loadPixmap( pathString + "search" ); 592 icon = loadPixmap( pathString + "search" );
595 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); 593 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this );
596 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4); 594 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4);
597 search_action->addTo( actionMenu ); 595 search_action->addTo( actionMenu );
598 connect( search_action, SIGNAL( activated() ), 596 connect( search_action, SIGNAL( activated() ),
599 mView->dialogManager(), SLOT( showSearchDialog() ) ); 597 mView->dialogManager(), SLOT( showSearchDialog() ) );
600 598
601 icon = loadPixmap( pathString + "today" ); 599 icon = loadPixmap( pathString + "today" );
602 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); 600 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130);
603 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); 601 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this );
604 today_action->addTo( actionMenu ); 602 today_action->addTo( actionMenu );
605 connect( today_action, SIGNAL( activated() ), 603 connect( today_action, SIGNAL( activated() ),
606 mView, SLOT( goToday() ) ); 604 mView, SLOT( goToday() ) );
607 605
608 if ( KOPrefs::instance()->mShowFullMenu ) { 606 if ( KOPrefs::instance()->mShowFullMenu ) {
609 actionMenu->insertSeparator(); 607 actionMenu->insertSeparator();
610 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); 608 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu );
611 609
612 } 610 }
613 // actionMenu->insertSeparator(); 611 // actionMenu->insertSeparator();
614 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, 612 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0,
615 this ); 613 this );
616 action->addTo( importMenu ); 614 action->addTo( importMenu );
617 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); 615 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) );
618 action = new QAction( "import_quick", i18n("Import last file"), 0, 616 action = new QAction( "import_quick", i18n("Import last file"), 0,
619 this ); 617 this );
620 action->addTo( importMenu ); 618 action->addTo( importMenu );
621 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); 619 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) );
622 importMenu->insertSeparator(); 620 importMenu->insertSeparator();
623 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, 621 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0,
624 this ); 622 this );
625 action->addTo( importMenu ); 623 action->addTo( importMenu );
626 connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); 624 connect( action, SIGNAL( activated() ), SLOT( importBday() ) );
627#ifndef DESKTOP_VERSION 625#ifndef DESKTOP_VERSION
628 importMenu->insertSeparator(); 626 importMenu->insertSeparator();
629 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, 627 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0,
630 this ); 628 this );
631 action->addTo( importMenu ); 629 action->addTo( importMenu );
632 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); 630 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) );
633#else 631#else
634#ifdef _WIN32_ 632#ifdef _WIN32_
635 importMenu->insertSeparator(); 633 importMenu->insertSeparator();
636 action = new QAction( "import_ol", i18n("Import from OL"), 0, 634 action = new QAction( "import_ol", i18n("Import from OL"), 0,
637 this ); 635 this );
638 action->addTo( importMenu ); 636 action->addTo( importMenu );
639 connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); 637 connect( action, SIGNAL( activated() ), SLOT( importOL() ) );
640#endif 638#endif
641#endif 639#endif
642 640
643 importMenu->insertSeparator(); 641 importMenu->insertSeparator();
644 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, 642 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0,
645 this ); 643 this );
646 action->addTo( importMenu ); 644 action->addTo( importMenu );
647 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); 645 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) );
648 646
649 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, 647 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0,
650 this ); 648 this );
651 action->addTo( importMenu ); 649 action->addTo( importMenu );
652 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); 650 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) );
653 651
654 importMenu->insertSeparator(); 652 importMenu->insertSeparator();
655 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, 653 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0,
656 this ); 654 this );
657 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); 655 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) );
658 importMenu->insertSeparator(); 656 importMenu->insertSeparator();
659 action = new QAction( "manage cat", i18n("Manage new categories..."), 0, 657 action = new QAction( "manage cat", i18n("Manage new categories..."), 0,
660 this ); 658 this );
661 action->addTo( importMenu ); 659 action->addTo( importMenu );
662 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); 660 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) );
663#ifndef DESKTOP_VERSION 661#ifndef DESKTOP_VERSION
664 importMenu->insertSeparator(); 662 importMenu->insertSeparator();
665 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, 663 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0,
666 this ); 664 this );
667 action->addTo( importMenu ); 665 action->addTo( importMenu );
668 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); 666 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) );
669 667
670 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, 668 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0,
671 this ); 669 this );
672 action->addTo( importMenu ); 670 action->addTo( importMenu );
673 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); 671 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) );
674#else 672#else
675 importMenu->insertSeparator(); 673 importMenu->insertSeparator();
676 icon = loadPixmap( pathString + "print" ); 674 icon = loadPixmap( pathString + "print" );
677 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); 675 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this );
678 action->addTo( importMenu ); 676 action->addTo( importMenu );
679 connect( action, SIGNAL( activated() ), 677 connect( action, SIGNAL( activated() ),
680 this, SLOT( printCal() ) ); 678 this, SLOT( printCal() ) );
681 679
682 icon = loadPixmap( pathString + "print" ); 680 icon = loadPixmap( pathString + "print" );
683 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); 681 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this );
684 action->addTo( importMenu ); 682 action->addTo( importMenu );
685 connect( action, SIGNAL( activated() ), 683 connect( action, SIGNAL( activated() ),
686 this, SLOT( printSel() ) ); 684 this, SLOT( printSel() ) );
687#endif 685#endif
688 importMenu->insertSeparator(); 686 importMenu->insertSeparator();
689 action = new QAction( "beam all", i18n("Save"), 0, 687 action = new QAction( "beam all", i18n("Save"), 0,
690 this ); 688 this );
691 action->addTo( importMenu ); 689 action->addTo( importMenu );
692 connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); 690 connect( action, SIGNAL( activated() ), this, SLOT( save() ) );
693 action = new QAction( "beam all", i18n("Exit (+save)"), 0, 691 action = new QAction( "beam all", i18n("Exit (+save)"), 0,
694 this ); 692 this );
695 action->addTo( importMenu ); 693 action->addTo( importMenu );
696 connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); 694 connect( action, SIGNAL( activated() ), this, SLOT( close() ) );
697 695
698 //menuBar->insertItem( "Configure",configureMenu ); 696 //menuBar->insertItem( "Configure",configureMenu );
699 //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); 697 //configureMenu->insertItem( "Toolbar",configureToolBarMenu );
700 icon = loadPixmap( "korganizer/korganizer" ); 698 icon = loadPixmap( "korganizer/korganizer" );
701 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); 699 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this );
702 action->addTo( helpMenu ); 700 action->addTo( helpMenu );
703 connect( action, SIGNAL( activated() ), 701 connect( action, SIGNAL( activated() ),
704 SLOT( keyBindings() ) ); 702 SLOT( keyBindings() ) );
705 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); 703 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this );
706 action->addTo( helpMenu ); 704 action->addTo( helpMenu );
707 connect( action, SIGNAL( activated() ), 705 connect( action, SIGNAL( activated() ),
708 SLOT( features() ) ); 706 SLOT( features() ) );
709 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); 707 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this );
710 action->addTo( helpMenu ); 708 action->addTo( helpMenu );
711 connect( action, SIGNAL( activated() ), 709 connect( action, SIGNAL( activated() ),
712 SLOT( aboutAutoSaving() ) ); 710 SLOT( aboutAutoSaving() ) );
713 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); 711 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this );
714 action->addTo( helpMenu ); 712 action->addTo( helpMenu );
715 connect( action, SIGNAL( activated() ), 713 connect( action, SIGNAL( activated() ),
716 SLOT( aboutKnownBugs() ) ); 714 SLOT( aboutKnownBugs() ) );
717 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); 715 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this );
718 action->addTo( helpMenu ); 716 action->addTo( helpMenu );
719 connect( action, SIGNAL( activated() ), 717 connect( action, SIGNAL( activated() ),
720 SLOT( usertrans() ) ); 718 SLOT( usertrans() ) );
721 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); 719 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this );
722 action->addTo( helpMenu ); 720 action->addTo( helpMenu );
723 connect( action, SIGNAL( activated() ), 721 connect( action, SIGNAL( activated() ),
724 SLOT( synchowto() ) ); 722 SLOT( synchowto() ) );
725 action = new QAction( "Whats New", i18n("What's new?"), 0,this ); 723 action = new QAction( "Whats New", i18n("What's new?"), 0,this );
726 action->addTo( helpMenu ); 724 action->addTo( helpMenu );
727 connect( action, SIGNAL( activated() ), 725 connect( action, SIGNAL( activated() ),
728 SLOT( whatsNew() ) ); 726 SLOT( whatsNew() ) );
729 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); 727 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this );
730 action->addTo( helpMenu ); 728 action->addTo( helpMenu );
731 connect( action, SIGNAL( activated() ), 729 connect( action, SIGNAL( activated() ),
732 SLOT( faq() ) ); 730 SLOT( faq() ) );
733 731
734 732
735 action = new QAction( "about", i18n("About..."), 0, this ); 733 action = new QAction( "about", i18n("About..."), 0, this );
736 action->addTo( helpMenu ); 734 action->addTo( helpMenu );
737 connect( action, SIGNAL( activated() ), 735 connect( action, SIGNAL( activated() ),
738 SLOT( about() ) ); 736 SLOT( about() ) );
739 action = new QAction( "licence", i18n("Licence..."), 0, this ); 737 action = new QAction( "licence", i18n("Licence..."), 0, this );
740 action->addTo( helpMenu ); 738 action->addTo( helpMenu );
741 connect( action, SIGNAL( activated() ), 739 connect( action, SIGNAL( activated() ),
742 SLOT( licence() ) ); 740 SLOT( licence() ) );
743 //menuBar->insertSeparator(); 741 //menuBar->insertSeparator();
744 742
745 // ****************************************************** 743 // ******************************************************
746 // menubar icons 744 // menubar icons
747 745
748 746
749 iconToolBar->setHorizontalStretchable (true ); 747 iconToolBar->setHorizontalStretchable (true );
750 //menuBar->insertItem( iconToolBar ); 748 //menuBar->insertItem( iconToolBar );
751 //xdays_action 749 //xdays_action
752 if (p-> mShowIconNewEvent) 750 if (p-> mShowIconNewEvent)
753 ne_action->addTo( iconToolBar ); 751 ne_action->addTo( iconToolBar );
754 if (p->mShowIconNewTodo ) 752 if (p->mShowIconNewTodo )
755 nt_action->addTo( iconToolBar ); 753 nt_action->addTo( iconToolBar );
756 if (p-> mShowIconSearch) 754 if (p-> mShowIconSearch)
757 search_action->addTo( iconToolBar ); 755 search_action->addTo( iconToolBar );
758 if (p-> mShowIconNext) 756 if (p-> mShowIconNext)
759 whatsnext_action->addTo( iconToolBar ); 757 whatsnext_action->addTo( iconToolBar );
760 if (p-> mShowIconNextDays) 758 if (p-> mShowIconNextDays)
761 xdays_action->addTo( iconToolBar ); 759 xdays_action->addTo( iconToolBar );
762 if (p-> mShowIconList) 760 if (p-> mShowIconList)
763 showlist_action->addTo( iconToolBar ); 761 showlist_action->addTo( iconToolBar );
764 if (p-> mShowIconDay1) 762 if (p-> mShowIconDay1)
765 day1_action->addTo( iconToolBar ); 763 day1_action->addTo( iconToolBar );
766 if (p-> mShowIconDay5) 764 if (p-> mShowIconDay5)
767 day5_action->addTo( iconToolBar ); 765 day5_action->addTo( iconToolBar );
768 if (p-> mShowIconDay7) 766 if (p-> mShowIconDay7)
769 day7_action->addTo( iconToolBar ); 767 day7_action->addTo( iconToolBar );
770 if (p-> mShowIconMonth) 768 if (p-> mShowIconMonth)
771 month_action->addTo( iconToolBar ); 769 month_action->addTo( iconToolBar );
772 if (p-> mShowIconTodoview) 770 if (p-> mShowIconTodoview)
773 todoview_action->addTo( iconToolBar ); 771 todoview_action->addTo( iconToolBar );
774 if (p-> mShowIconJournal) 772 if (p-> mShowIconJournal)
775 viewjournal_action->addTo( iconToolBar ); 773 viewjournal_action->addTo( iconToolBar );
776 icon = loadPixmap( pathString + "2leftarrowB" ); 774 icon = loadPixmap( pathString + "2leftarrowB" );
777 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); 775 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14);
778 if (p-> mShowIconBackFast) { 776 if (p-> mShowIconBackFast) {
779 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); 777 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this );
780 connect( action, SIGNAL( activated() ), 778 connect( action, SIGNAL( activated() ),
781 mView, SLOT( goPreviousMonth() ) ); 779 mView, SLOT( goPreviousMonth() ) );
782 action->addTo( iconToolBar ); 780 action->addTo( iconToolBar );
783 } 781 }
784 icon = loadPixmap( pathString + "1leftarrowB" ); 782 icon = loadPixmap( pathString + "1leftarrowB" );
785 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); 783 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15);
786 if (p-> mShowIconBack) { 784 if (p-> mShowIconBack) {
787 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); 785 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this );
788 connect( action, SIGNAL( activated() ), 786 connect( action, SIGNAL( activated() ),
789 mView, SLOT( goPrevious() ) ); 787 mView, SLOT( goPrevious() ) );
790 action->addTo( iconToolBar ); 788 action->addTo( iconToolBar );
791 } 789 }
792 if (p-> mShowIconToday) 790 if (p-> mShowIconToday)
793 today_action->addTo( iconToolBar ); 791 today_action->addTo( iconToolBar );
794 icon = loadPixmap( pathString + "1rightarrowB" ); 792 icon = loadPixmap( pathString + "1rightarrowB" );
795 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); 793 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220);
796 if (p-> mShowIconForward) { 794 if (p-> mShowIconForward) {
797 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); 795 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this );
798 connect( action, SIGNAL( activated() ), 796 connect( action, SIGNAL( activated() ),
799 mView, SLOT( goNext() ) ); 797 mView, SLOT( goNext() ) );
800 action->addTo( iconToolBar ); 798 action->addTo( iconToolBar );
801 } 799 }
802 icon = loadPixmap( pathString + "2rightarrowB" ); 800 icon = loadPixmap( pathString + "2rightarrowB" );
803 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); 801 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230);
804 if (p-> mShowIconForwardFast) { 802 if (p-> mShowIconForwardFast) {
805 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); 803 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this );
806 connect( action, SIGNAL( activated() ), 804 connect( action, SIGNAL( activated() ),
807 mView, SLOT( goNextMonth() ) ); 805 mView, SLOT( goNextMonth() ) );
808 action->addTo( iconToolBar ); 806 action->addTo( iconToolBar );
809 } 807 }
810 808
811 809
812 configureToolBarMenu->insertItem(i18n("What's This?"), 300); 810 configureToolBarMenu->insertItem(i18n("What's This?"), 300);
813 811
814 if (p-> mShowIconNewEvent) 812 if (p-> mShowIconNewEvent)
815 configureToolBarMenu->setItemChecked( 10, true ); 813 configureToolBarMenu->setItemChecked( 10, true );
816 if (p->mShowIconNewTodo ) 814 if (p->mShowIconNewTodo )
817 configureToolBarMenu->setItemChecked( 20, true ); 815 configureToolBarMenu->setItemChecked( 20, true );
818 if (p-> mShowIconSearch) 816 if (p-> mShowIconSearch)
819 configureToolBarMenu->setItemChecked( 120, true ); 817 configureToolBarMenu->setItemChecked( 120, true );
820 if (p-> mShowIconList) 818 if (p-> mShowIconList)
821 configureToolBarMenu->setItemChecked( 30, true ); 819 configureToolBarMenu->setItemChecked( 30, true );
822 if (p-> mShowIconDay1) 820 if (p-> mShowIconDay1)
823 configureToolBarMenu->setItemChecked( 40, true ); 821 configureToolBarMenu->setItemChecked( 40, true );
824 if (p-> mShowIconDay5) 822 if (p-> mShowIconDay5)
825 configureToolBarMenu->setItemChecked( 50, true ); 823 configureToolBarMenu->setItemChecked( 50, true );
826 if (p-> mShowIconDay7) 824 if (p-> mShowIconDay7)
827 configureToolBarMenu->setItemChecked( 60, true ); 825 configureToolBarMenu->setItemChecked( 60, true );
828 if (p-> mShowIconMonth) 826 if (p-> mShowIconMonth)
829 configureToolBarMenu->setItemChecked( 70, true ); 827 configureToolBarMenu->setItemChecked( 70, true );
830 if (p-> mShowIconTodoview) 828 if (p-> mShowIconTodoview)
831 configureToolBarMenu->setItemChecked( 80, true ); 829 configureToolBarMenu->setItemChecked( 80, true );
832 if (p-> mShowIconBackFast) 830 if (p-> mShowIconBackFast)
833 configureToolBarMenu->setItemChecked( 200, true ); 831 configureToolBarMenu->setItemChecked( 200, true );
834 if (p-> mShowIconBack) 832 if (p-> mShowIconBack)
835 configureToolBarMenu->setItemChecked( 210, true ); 833 configureToolBarMenu->setItemChecked( 210, true );
836 if (p-> mShowIconToday) 834 if (p-> mShowIconToday)
837 configureToolBarMenu->setItemChecked( 130, true ); 835 configureToolBarMenu->setItemChecked( 130, true );
838 if (p-> mShowIconForward) 836 if (p-> mShowIconForward)
839 configureToolBarMenu->setItemChecked( 220, true ); 837 configureToolBarMenu->setItemChecked( 220, true );
840 if (p-> mShowIconForwardFast) 838 if (p-> mShowIconForwardFast)
841 configureToolBarMenu->setItemChecked( 230, true ); 839 configureToolBarMenu->setItemChecked( 230, true );
842 if (p-> mShowIconNextDays) 840 if (p-> mShowIconNextDays)
843 configureToolBarMenu->setItemChecked( 100, true ); 841 configureToolBarMenu->setItemChecked( 100, true );
844 if (p-> mShowIconNext) 842 if (p-> mShowIconNext)
845 configureToolBarMenu->setItemChecked( 110, true ); 843 configureToolBarMenu->setItemChecked( 110, true );
846 if (p-> mShowIconJournal) 844 if (p-> mShowIconJournal)
847 configureToolBarMenu->setItemChecked( 90, true ); 845 configureToolBarMenu->setItemChecked( 90, true );
848 if (p-> mShowIconWhatsThis) 846 if (p-> mShowIconWhatsThis)
849 configureToolBarMenu->setItemChecked( 300, true ); 847 configureToolBarMenu->setItemChecked( 300, true );
850 848
851 QLabel* dummy = new QLabel( iconToolBar ); 849 QLabel* dummy = new QLabel( iconToolBar );
852 dummy->setBackgroundColor( iconToolBar->backgroundColor() ); 850 dummy->setBackgroundColor( iconToolBar->backgroundColor() );
853 if (!p-> mShowIconStretch) 851 if (!p-> mShowIconStretch)
854 iconToolBar->setStretchableWidget ( dummy ) ; 852 iconToolBar->setStretchableWidget ( dummy ) ;
855 else 853 else
856 configureToolBarMenu->setItemChecked( 5, true ); 854 configureToolBarMenu->setItemChecked( 5, true );
857 if (p-> mShowIconWhatsThis) 855 if (p-> mShowIconWhatsThis)
858 QWhatsThis::whatsThisButton ( iconToolBar ); 856 QWhatsThis::whatsThisButton ( iconToolBar );
859 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); 857 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) );
860 configureAgenda( p->mHourSize ); 858 configureAgenda( p->mHourSize );
861 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); 859 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) );
862} 860}
863void MainWindow::fillSyncMenu() 861void MainWindow::fillSyncMenu()
864{ 862{
865 if ( syncMenu->count() ) 863 if ( syncMenu->count() )
866 syncMenu->clear(); 864 syncMenu->clear();
867 syncMenu->insertItem( i18n("Configure..."), 0 ); 865 syncMenu->insertItem( i18n("Configure..."), 0 );
868 syncMenu->insertSeparator(); 866 syncMenu->insertSeparator();
869 if ( mServerSocket == 0 ) { 867 if ( mServerSocket == 0 ) {
870 syncMenu->insertItem( i18n("Enable Pi-Sync"), 2 ); 868 syncMenu->insertItem( i18n("Enable Pi-Sync"), 2 );
871 } else { 869 } else {
872 syncMenu->insertItem( i18n("Disable Pi-Sync"), 3 ); 870 syncMenu->insertItem( i18n("Disable Pi-Sync"), 3 );
873 } 871 }
874 syncMenu->insertSeparator(); 872 syncMenu->insertSeparator();
875 syncMenu->insertItem( i18n("Multiple sync"), 1 ); 873 syncMenu->insertItem( i18n("Multiple sync"), 1 );
876 syncMenu->insertSeparator(); 874 syncMenu->insertSeparator();
877 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 875 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
878 config.setGroup("General"); 876 config.setGroup("General");
879 QStringList prof = config.readListEntry("SyncProfileNames"); 877 QStringList prof = config.readListEntry("SyncProfileNames");
880 KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined"); 878 KOPrefs::instance()->mLocalMachineName = config.readEntry("LocalMachineName","undefined");
881 if ( prof.count() < 3 ) { 879 if ( prof.count() < 3 ) {
882 prof.clear(); 880 prof.clear();
883 prof << i18n("Sharp_DTM"); 881 prof << i18n("Sharp_DTM");
884 prof << i18n("Local_file"); 882 prof << i18n("Local_file");
885 prof << i18n("Last_file"); 883 prof << i18n("Last_file");
886 KSyncProfile* temp = new KSyncProfile (); 884 KSyncProfile* temp = new KSyncProfile ();
887 temp->setName( prof[0] ); 885 temp->setName( prof[0] );
888 temp->writeConfig(&config); 886 temp->writeConfig(&config);
889 temp->setName( prof[1] ); 887 temp->setName( prof[1] );
890 temp->writeConfig(&config); 888 temp->writeConfig(&config);
891 temp->setName( prof[2] ); 889 temp->setName( prof[2] );
892 temp->writeConfig(&config); 890 temp->writeConfig(&config);
893 config.setGroup("General"); 891 config.setGroup("General");
894 config.writeEntry("SyncProfileNames",prof); 892 config.writeEntry("SyncProfileNames",prof);
895 config.writeEntry("ExternSyncProfiles","Sharp_DTM"); 893 config.writeEntry("ExternSyncProfiles","Sharp_DTM");
896 config.sync(); 894 config.sync();
897 delete temp; 895 delete temp;
898 } 896 }
899 KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); 897 KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles");
900 KOPrefs::instance()->mSyncProfileNames = prof; 898 KOPrefs::instance()->mSyncProfileNames = prof;
901 int i; 899 int i;
902 for ( i = 0; i < prof.count(); ++i ) { 900 for ( i = 0; i < prof.count(); ++i ) {
903 901
904 syncMenu->insertItem( prof[i], 1000+i ); 902 syncMenu->insertItem( prof[i], 1000+i );
905 if ( i == 2 ) 903 if ( i == 2 )
906 syncMenu->insertSeparator(); 904 syncMenu->insertSeparator();
907 } 905 }
908 QDir app_dir; 906 QDir app_dir;
909 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { 907 if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) {
910 syncMenu->setItemEnabled( false , 1000 ); 908 syncMenu->setItemEnabled( false , 1000 );
911 } 909 }
912 mView->setupExternSyncProfiles(); 910 mView->setupExternSyncProfiles();
913} 911}
914 912
915int MainWindow::ringSync() 913int MainWindow::ringSync()
916{ 914{
917 int syncedProfiles = 0; 915 int syncedProfiles = 0;
918 int i; 916 int i;
919 QTime timer; 917 QTime timer;
920 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 918 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
921 QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames; 919 QStringList syncProfileNames = KOPrefs::instance()->mSyncProfileNames;
922 KSyncProfile* temp = new KSyncProfile (); 920 KSyncProfile* temp = new KSyncProfile ();
923 KOPrefs::instance()->mAskForPreferences = false; 921 KOPrefs::instance()->mAskForPreferences = false;
924 for ( i = 0; i < syncProfileNames.count(); ++i ) { 922 for ( i = 0; i < syncProfileNames.count(); ++i ) {
925 mCurrentSyncProfile = i; 923 mCurrentSyncProfile = i;
926 temp->setName(syncProfileNames[mCurrentSyncProfile]); 924 temp->setName(syncProfileNames[mCurrentSyncProfile]);
927 temp->readConfig(&config); 925 temp->readConfig(&config);
928 if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) { 926 if ( temp->getIncludeInRingSync() && ( i < 1 || i > 2 )) {
929 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... ")); 927 setCaption(i18n("Profile ")+syncProfileNames[mCurrentSyncProfile]+ i18n(" is synced ... "));
930 ++syncedProfiles; 928 ++syncedProfiles;
931 // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 929 // KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
932 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 930 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
933 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 931 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
934 KOPrefs::instance()->mWriteBackInFuture = 0; 932 KOPrefs::instance()->mWriteBackInFuture = 0;
935 if ( temp->getWriteBackFuture() ) 933 if ( temp->getWriteBackFuture() )
936 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 934 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
937 KOPrefs::instance()->mShowSyncSummary = false; 935 KOPrefs::instance()->mShowSyncSummary = false;
938 mView->setSyncDevice(syncProfileNames[i] ); 936 mView->setSyncDevice(syncProfileNames[i] );
939 mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); 937 mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
940 if ( i == 0 ) { 938 if ( i == 0 ) {
941 syncSharp(); 939 syncSharp();
942 } else { 940 } else {
943 if ( temp->getIsLocalFileSync() ) { 941 if ( temp->getIsLocalFileSync() ) {
944 if ( syncWithFile( temp->getRemoteFileName( ), true ) ) 942 if ( syncWithFile( temp->getRemoteFileName( ), true ) )
945 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); 943 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName();
946 } else { 944 } else {
947 if ( temp->getIsPhoneSync() ) { 945 if ( temp->getIsPhoneSync() ) {
948 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; 946 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ;
949 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); 947 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( );
950 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); 948 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( );
951 syncPhone(); 949 syncPhone();
952 } else if ( temp->getIsPiSync() ) { 950 } else if ( temp->getIsPiSync() ) {
953 mPassWordPiSync = temp->getRemotePw(); 951 mPassWordPiSync = temp->getRemotePw();
954 KOPrefs::instance()->mActiveSyncPort = temp->getRemotePort(); 952 KOPrefs::instance()->mActiveSyncPort = temp->getRemotePort();
955 KOPrefs::instance()->mActiveSyncIP = temp->getRemoteIP(); 953 KOPrefs::instance()->mActiveSyncIP = temp->getRemoteIP();
956 syncPi(); 954 syncPi();
957 } else 955 } else
958 syncRemote( temp, false ); 956 syncRemote( temp, false );
959 957
960 } 958 }
961 } 959 }
962 timer.start(); 960 timer.start();
963 setCaption(i18n("Multiple sync in progress ... please wait!") ); 961 setCaption(i18n("Multiple sync in progress ... please wait!") );
964 while ( timer.elapsed () < 2000 ) { 962 while ( timer.elapsed () < 2000 ) {
965 qApp->processEvents(); 963 qApp->processEvents();
966#ifndef _WIN32_ 964#ifndef _WIN32_
967 sleep (1); 965 sleep (1);
968#endif 966#endif
969 } 967 }
970 968
971 } 969 }
972 970
973 } 971 }
974 delete temp; 972 delete temp;
975 return syncedProfiles; 973 return syncedProfiles;
976} 974}
977 975
978void MainWindow::multiSync( bool askforPrefs ) 976void MainWindow::multiSync( bool askforPrefs )
979{ 977{
980 if (mBlockSaveFlag) 978 if (mBlockSaveFlag)
981 return; 979 return;
982 mBlockSaveFlag = true; 980 mBlockSaveFlag = true;
983 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!"); 981 QString question = i18n("Do you really want\nto multiple sync\nwith all checked profiles?\nSyncing takes some\ntime - all profiles\nare synced twice!");
984 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 982 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
985 question, 983 question,
986 i18n("Yes"), i18n("No"), 984 i18n("Yes"), i18n("No"),
987 0, 0 ) != 0 ) { 985 0, 0 ) != 0 ) {
988 mBlockSaveFlag = false; 986 mBlockSaveFlag = false;
989 setCaption(i18n("Aborted! Nothing synced!")); 987 setCaption(i18n("Aborted! Nothing synced!"));
990 return; 988 return;
991 } 989 }
992 mView->setSyncDevice(i18n("Multiple profiles") ); 990 mView->setSyncDevice(i18n("Multiple profiles") );
993 KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs; 991 KOPrefs::instance()->mSyncAlgoPrefs = KOPrefs::instance()->mRingSyncAlgoPrefs;
994 if ( askforPrefs ) { 992 if ( askforPrefs ) {
995 mView->edit_sync_options(); 993 mView->edit_sync_options();
996 KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs; 994 KOPrefs::instance()->mRingSyncAlgoPrefs = KOPrefs::instance()->mSyncAlgoPrefs;
997 } 995 }
998 setCaption(i18n("Multiple sync started.") ); 996 setCaption(i18n("Multiple sync started.") );
999 qApp->processEvents(); 997 qApp->processEvents();
1000 int num = ringSync() ; 998 int num = ringSync() ;
1001 if ( num > 1 ) 999 if ( num > 1 )
1002 ringSync(); 1000 ringSync();
1003 mBlockSaveFlag = false; 1001 mBlockSaveFlag = false;
1004 if ( num ) 1002 if ( num )
1005 save(); 1003 save();
1006 if ( num ) 1004 if ( num )
1007 setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) ); 1005 setCaption(i18n("%1 profiles synced. Multiple sync completed!").arg(num) );
1008 else 1006 else
1009 setCaption(i18n("Nothing synced! No profiles defined for multisync!")); 1007 setCaption(i18n("Nothing synced! No profiles defined for multisync!"));
1010 return; 1008 return;
1011} 1009}
1012void MainWindow::slotSyncMenu( int action ) 1010void MainWindow::slotSyncMenu( int action )
1013{ 1011{
1014 qDebug("syncaction %d ", action); 1012 qDebug("syncaction %d ", action);
1015 if ( action == 0 ) { 1013 if ( action == 0 ) {
1016 1014
1017 // seems to be a Qt2 event handling bug 1015 // seems to be a Qt2 event handling bug
1018 // syncmenu.clear causes a segfault at first time 1016 // syncmenu.clear causes a segfault at first time
1019 // when we call it after the main event loop, it is ok 1017 // when we call it after the main event loop, it is ok
1020 // same behaviour when calling OM/Pi via QCOP for the first time 1018 // same behaviour when calling OM/Pi via QCOP for the first time
1021 QTimer::singleShot ( 1, this, SLOT ( confSync() ) ); 1019 QTimer::singleShot ( 1, this, SLOT ( confSync() ) );
1022 //confSync(); 1020 //confSync();
1023 1021
1024 return; 1022 return;
1025 } 1023 }
1026 if ( action == 1 ) { 1024 if ( action == 1 ) {
1027 multiSync( true ); 1025 multiSync( true );
1028 return; 1026 return;
1029 } 1027 }
1030 if ( action == 2 ) { 1028 if ( action == 2 ) {
1031 enableQuick(); 1029 enableQuick();
1032 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 1030 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
1033 return; 1031 return;
1034 } 1032 }
1035 if ( action == 3 ) { 1033 if ( action == 3 ) {
1036 delete mServerSocket; 1034 delete mServerSocket;
1037 mServerSocket = 0; 1035 mServerSocket = 0;
1038 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) ); 1036 QTimer::singleShot ( 1, this, SLOT ( fillSyncMenu() ) );
1039 return; 1037 return;
1040 } 1038 }
1041 1039
1042 if (mBlockSaveFlag) 1040 if (mBlockSaveFlag)
1043 return; 1041 return;
1044 mBlockSaveFlag = true; 1042 mBlockSaveFlag = true;
1045 mCurrentSyncProfile = action - 1000 ; 1043 mCurrentSyncProfile = action - 1000 ;
1046 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] ); 1044 mView->setSyncDevice(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile] );
1047 mView->setSyncName( KOPrefs::instance()->mLocalMachineName ); 1045 mView->setSyncName( KOPrefs::instance()->mLocalMachineName );
1048 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) ); 1046 KConfig config ( locateLocal( "config","ksyncprofilesrc" ) );
1049 KSyncProfile* temp = new KSyncProfile (); 1047 KSyncProfile* temp = new KSyncProfile ();
1050 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 1048 temp->setName(KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
1051 temp->readConfig(&config); 1049 temp->readConfig(&config);
1052 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences(); 1050 KOPrefs::instance()->mAskForPreferences = temp->getAskForPreferences();
1053 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs(); 1051 KOPrefs::instance()->mSyncAlgoPrefs = temp->getSyncPrefs();
1054 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile(); 1052 KOPrefs::instance()->mWriteBackFile = temp->getWriteBackFile();
1055 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting(); 1053 KOPrefs::instance()->mWriteBackExistingOnly = temp->getWriteBackExisting();
1056 KOPrefs::instance()->mWriteBackInFuture = 0; 1054 KOPrefs::instance()->mWriteBackInFuture = 0;
1057 if ( temp->getWriteBackFuture() ) 1055 if ( temp->getWriteBackFuture() )
1058 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( ); 1056 KOPrefs::instance()->mWriteBackInFuture = temp->getWriteBackFutureWeeks( );
1059 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync(); 1057 KOPrefs::instance()->mShowSyncSummary = temp->getShowSummaryAfterSync();
1060 if ( action == 1000 ) { 1058 if ( action == 1000 ) {
1061 syncSharp(); 1059 syncSharp();
1062 1060
1063 } else if ( action == 1001 ) { 1061 } else if ( action == 1001 ) {
1064 syncLocalFile(); 1062 syncLocalFile();
1065 1063
1066 } else if ( action == 1002 ) { 1064 } else if ( action == 1002 ) {
1067 quickSyncLocalFile(); 1065 quickSyncLocalFile();
1068 1066
1069 } else if ( action >= 1003 ) { 1067 } else if ( action >= 1003 ) {
1070 if ( temp->getIsLocalFileSync() ) { 1068 if ( temp->getIsLocalFileSync() ) {
1071 if ( syncWithFile( temp->getRemoteFileName( ), false ) ) 1069 if ( syncWithFile( temp->getRemoteFileName( ), false ) )
1072 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName(); 1070 KOPrefs::instance()->mLastSyncedLocalFile = temp->getRemoteFileName();
1073 } else { 1071 } else {
1074 if ( temp->getIsPhoneSync() ) { 1072 if ( temp->getIsPhoneSync() ) {
1075 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ; 1073 KOPrefs::instance()->mPhoneDevice = temp->getPhoneDevice( ) ;
1076 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( ); 1074 KOPrefs::instance()->mPhoneConnection = temp->getPhoneConnection( );
1077 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( ); 1075 KOPrefs::instance()->mPhoneModel = temp->getPhoneModel( );
1078 syncPhone(); 1076 syncPhone();
1079 } else if ( temp->getIsPiSync() ) { 1077 } else if ( temp->getIsPiSync() ) {
1080 mPassWordPiSync = temp->getRemotePw(); 1078 mPassWordPiSync = temp->getRemotePw();
1081 KOPrefs::instance()->mActiveSyncPort = temp->getRemotePort(); 1079 KOPrefs::instance()->mActiveSyncPort = temp->getRemotePort();
1082 KOPrefs::instance()->mActiveSyncIP = temp->getRemoteIP(); 1080 KOPrefs::instance()->mActiveSyncIP = temp->getRemoteIP();
1083 syncPi(); 1081 syncPi();
1084 } else 1082 } else
1085 syncRemote( temp ); 1083 syncRemote( temp );
1086 1084
1087 } 1085 }
1088 } 1086 }
1089 delete temp; 1087 delete temp;
1090 mBlockSaveFlag = false; 1088 mBlockSaveFlag = false;
1091} 1089}
1092void MainWindow::setDefaultPreferences() 1090void MainWindow::setDefaultPreferences()
1093{ 1091{
1094 KOPrefs *p = KOPrefs::instance(); 1092 KOPrefs *p = KOPrefs::instance();
1095 1093
1096 p->mCompactDialogs = true; 1094 p->mCompactDialogs = true;
1097 p->mConfirm = true; 1095 p->mConfirm = true;
1098 // p->mEnableQuickTodo = false; 1096 // p->mEnableQuickTodo = false;
1099} 1097}
1100 1098
1101QString MainWindow::resourcePath() 1099QString MainWindow::resourcePath()
1102{ 1100{
1103 return KGlobal::iconLoader()->iconPath(); 1101 return KGlobal::iconLoader()->iconPath();
1104} 1102}
1105 1103
1106void MainWindow::displayText( QString text ,QString cap ) 1104void MainWindow::displayText( QString text ,QString cap )
1107{ 1105{
1108 QDialog dia( this, "name", true ); ; 1106 QDialog dia( this, "name", true ); ;
1109 dia.setCaption( cap ); 1107 dia.setCaption( cap );
1110 QVBoxLayout* lay = new QVBoxLayout( &dia ); 1108 QVBoxLayout* lay = new QVBoxLayout( &dia );
1111 lay->setSpacing( 3 ); 1109 lay->setSpacing( 3 );
1112 lay->setMargin( 3 ); 1110 lay->setMargin( 3 );
1113 QTextBrowser tb ( &dia ); 1111 QTextBrowser tb ( &dia );
1114 lay->addWidget( &tb ); 1112 lay->addWidget( &tb );
1115 tb.setText( text ); 1113 tb.setText( text );
1116#ifdef DESKTOP_VERSION 1114#ifdef DESKTOP_VERSION
1117 dia.resize( 640, 480); 1115 dia.resize( 640, 480);
1118#else 1116#else
1119 dia.showMaximized(); 1117 dia.showMaximized();
1120#endif 1118#endif
1121 dia.exec(); 1119 dia.exec();
1122} 1120}
1123void MainWindow::displayFile( QString fn, QString cap ) 1121void MainWindow::displayFile( QString fn, QString cap )
1124{ 1122{
1125 QString fileName = resourcePath() + fn; 1123 QString fileName = resourcePath() + fn;
1126 QString text; 1124 QString text;
1127 QFile file( fileName ); 1125 QFile file( fileName );
1128 if (!file.open( IO_ReadOnly ) ) { 1126 if (!file.open( IO_ReadOnly ) ) {
1129 return ; 1127 return ;
1130 1128
1131 } 1129 }
1132 QTextStream ts( &file ); 1130 QTextStream ts( &file );
1133 text = ts.read(); 1131 text = ts.read();
1134 file.close(); 1132 file.close();
1135 displayText( text, cap); 1133 displayText( text, cap);
1136} 1134}
1137void MainWindow::features() 1135void MainWindow::features()
1138{ 1136{
1139 1137
1140 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") ); 1138 displayFile( "featuresKOPI.txt",i18n("KO/Pi Features and hints") );
1141} 1139}
1142 1140
1143void MainWindow::usertrans() 1141void MainWindow::usertrans()
1144{ 1142{
1145 1143
1146 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") ); 1144 displayFile( "usertranslationHOWTO.txt",i18n("KO/Pi User translation HowTo") );
1147} 1145}
1148 1146
1149void MainWindow::synchowto() 1147void MainWindow::synchowto()
1150{ 1148{
1151#if 0 1149#if 0
1152 QPtrList<Incidence> er = mCalendar->rawIncidences(); 1150 QPtrList<Incidence> er = mCalendar->rawIncidences();
1153 Incidence* inR = er.first(); 1151 Incidence* inR = er.first();
1154 VCalFormat vf; 1152 VCalFormat vf;
1155 QString strout; 1153 QString strout;
1156 while ( inR ) { 1154 while ( inR ) {
1157 if ( inR->type() == "Todo" ) 1155 if ( inR->type() == "Todo" )
1158 strout = vf.todoToString( (Todo *) inR ); 1156 strout = vf.todoToString( (Todo *) inR );
1159 if ( inR->type() == "Event" ) 1157 if ( inR->type() == "Event" )
1160 strout = vf.eventToString( (Event *) inR ); 1158 strout = vf.eventToString( (Event *) inR );
1161 qDebug("incidence: \n%s\n ente\n\n",strout.latin1() ); 1159 qDebug("incidence: \n%s\n ente\n\n",strout.latin1() );
1162 inR = er.next(); 1160 inR = er.next();
1163 } 1161 }
1164#endif 1162#endif
1165 displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") ); 1163 displayFile( "howtoSYNC.txt",i18n("KO/Pi Synchronization HowTo") );
1166} 1164}
1167void MainWindow::faq() 1165void MainWindow::faq()
1168{ 1166{
1169 displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") ); 1167 displayFile( "kopiFAQ.txt",i18n("KO/Pi FAQ") );
1170 1168
1171} 1169}
1172void MainWindow::whatsNew() 1170void MainWindow::whatsNew()
1173{ 1171{
1174 displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") ); 1172 displayFile( "kopiWhatsNew.txt",i18n("KO/Pi Version Info") );
1175 1173
1176} 1174}
1177void MainWindow::licence() 1175void MainWindow::licence()
1178{ 1176{
1179 KApplication::showLicence(); 1177 KApplication::showLicence();
1180 1178
1181} 1179}
1182void MainWindow::about() 1180void MainWindow::about()
1183{ 1181{
1184 QString version; 1182 QString version;
1185#include <../version> 1183#include <../version>
1186 QMessageBox::about( this, i18n("About KOrganizer/Pi"), 1184 QMessageBox::about( this, i18n("About KOrganizer/Pi"),
1187 i18n("KOrganizer/Platform-independent\n") + 1185 i18n("KOrganizer/Platform-independent\n") +
1188 "(KO/Pi) " + version + " - " + 1186 "(KO/Pi) " + version + " - " +
1189 1187
1190#ifdef DESKTOP_VERSION 1188#ifdef DESKTOP_VERSION
1191 i18n("Desktop Edition\n") + 1189 i18n("Desktop Edition\n") +
1192#else 1190#else
1193 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + 1191 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") +
1194#endif 1192#endif
1195 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") ); 1193 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") );
1196} 1194}
1197void MainWindow::keyBindings() 1195void MainWindow::keyBindings()
1198{ 1196{
1199 QString cap = i18n("Key bindings KOrganizer/Pi"); 1197 QString cap = i18n("Key bindings KOrganizer/Pi");
1200 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + 1198 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") +
1201 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ 1199 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+
1202 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + 1200 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") +
1203 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ 1201 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+
1204 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ 1202 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+
1205 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ 1203 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+
1206 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ 1204 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+
1207 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ 1205 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+
1208 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ 1206 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+
1209 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ 1207 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+
1210 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ 1208 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+
1211 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ 1209 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+
1212 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ 1210 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+
1213 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ 1211 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+
1214 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ 1212 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+
1215 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ 1213 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+
1216 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ 1214 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+
1217 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ 1215 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+
1218 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ 1216 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+
1219 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ 1217 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+
1220 i18n("<p><h3>In agenda view:</h3></p>\n") + 1218 i18n("<p><h3>In agenda view:</h3></p>\n") +
1221 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ 1219 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+
1222 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ 1220 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+
1223 i18n("<p><h3>In todo view:</h3></p>\n") + 1221 i18n("<p><h3>In todo view:</h3></p>\n") +
1224 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ 1222 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+
1225 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1223 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1226 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ 1224 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+
1227 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ 1225 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+
1228 i18n("<p><h3>In list view:</h3></p>\n") + 1226 i18n("<p><h3>In list view:</h3></p>\n") +
1229 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1227 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1230 i18n("<p><b>return</b>: Select item+one step down</p>\n")+ 1228 i18n("<p><b>return</b>: Select item+one step down</p>\n")+
1231 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ 1229 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+
1232 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ 1230 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+
1233 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ 1231 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+
1234 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ 1232 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+
1235 i18n("<p><h3>In event/todo viewer:</h3></p>\n") + 1233 i18n("<p><h3>In event/todo viewer:</h3></p>\n") +
1236 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ 1234 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+
1237 i18n("<p><b>A</b>: Show agenda view.</p>\n")+ 1235 i18n("<p><b>A</b>: Show agenda view.</p>\n")+
1238 i18n("<p><b>E</b>: Edit item</p>\n") + 1236 i18n("<p><b>E</b>: Edit item</p>\n") +
1239 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + 1237 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") +
1240 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + 1238 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") +
1241 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ 1239 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+
1242 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ 1240 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+
1243 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ 1241 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+
1244 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ 1242 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+
1245 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ 1243 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+
1246 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + 1244 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") +
1247 i18n("<p><b>White</b>: Item readonly</p>\n"); 1245 i18n("<p><b>White</b>: Item readonly</p>\n");
1248 displayText( text, cap); 1246 displayText( text, cap);
1249 1247
1250} 1248}
1251void MainWindow::aboutAutoSaving() 1249void MainWindow::aboutAutoSaving()
1252{ 1250{
1253 QMessageBox* msg; 1251 QMessageBox* msg;
1254 msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"), 1252 msg = new QMessageBox( i18n("Auto Saving in KOrganizer/Pi"),
1255 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, 1253 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,
1256 QMessageBox::Ok, 1254 QMessageBox::Ok,
1257 QMessageBox::NoButton, 1255 QMessageBox::NoButton,
1258 QMessageBox::NoButton); 1256 QMessageBox::NoButton);
1259 msg->exec(); 1257 msg->exec();
1260 delete msg; 1258 delete msg;
1261 1259
1262 1260
1263} 1261}
1264void MainWindow::aboutKnownBugs() 1262void MainWindow::aboutKnownBugs()
1265{ 1263{
1266 QMessageBox* msg; 1264 QMessageBox* msg;
1267 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), 1265 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"),
1268 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")+ 1266 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")+
1269 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ 1267 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+
1270 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + 1268 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") +
1271 i18n("\nor report them in the bugtracker on\n") + 1269 i18n("\nor report them in the bugtracker on\n") +
1272 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), 1270 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"),
1273 QMessageBox::NoIcon, 1271 QMessageBox::NoIcon,
1274 QMessageBox::Ok, 1272 QMessageBox::Ok,
1275 QMessageBox::NoButton, 1273 QMessageBox::NoButton,
1276 QMessageBox::NoButton); 1274 QMessageBox::NoButton);
1277 msg->exec(); 1275 msg->exec();
1278 delete msg; 1276 delete msg;
1279 1277
1280} 1278}
1281 1279
1282QString MainWindow::defaultFileName() 1280QString MainWindow::defaultFileName()
1283{ 1281{
1284 return locateLocal( "data", "korganizer/mycalendar.ics" ); 1282 return locateLocal( "data", "korganizer/mycalendar.ics" );
1285} 1283}
1286QString MainWindow::syncFileName() 1284QString MainWindow::syncFileName()
1287{ 1285{
1288#ifdef _WIN32_ 1286#ifdef _WIN32_
1289 return locateLocal( "tmp", "synccalendar.ics" ); 1287 return locateLocal( "tmp", "synccalendar.ics" );
1290#else 1288#else
1291 return QString( "/tmp/kopitempfile.ics" ); 1289 return QString( "/tmp/kopitempfile.ics" );
1292#endif 1290#endif
1293} 1291}
1294 1292
1295void MainWindow::processIncidenceSelection( Incidence *incidence ) 1293void MainWindow::processIncidenceSelection( Incidence *incidence )
1296{ 1294{
1297 if ( !incidence ) { 1295 if ( !incidence ) {
1298 enableIncidenceActions( false ); 1296 enableIncidenceActions( false );
1299 1297
1300 mNewSubTodoAction->setEnabled( false ); 1298 mNewSubTodoAction->setEnabled( false );
1301 setCaptionToDates(); 1299 setCaptionToDates();
1302 return; 1300 return;
1303 1301
1304 } 1302 }
1305 1303
1306 //KGlobal::locale()->formatDateTime(nextA, true); 1304 //KGlobal::locale()->formatDateTime(nextA, true);
1307 QString startString = ""; 1305 QString startString = "";
1308 if ( incidence->type() != "Todo" ) { 1306 if ( incidence->type() != "Todo" ) {
1309 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { 1307 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) {
1310 if ( incidence->doesFloat() ) { 1308 if ( incidence->doesFloat() ) {
1311 startString += ": "+incidence->dtStartDateStr( true ); 1309 startString += ": "+incidence->dtStartDateStr( true );
1312 startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); 1310 startString += " --- "+((Event*)incidence)->dtEndDateStr( true );
1313 1311
1314 } else { 1312 } else {
1315 startString = ": "+incidence->dtStartStr(true); 1313 startString = ": "+incidence->dtStartStr(true);
1316 startString += " --- "+((Event*)incidence)->dtEndStr(true); 1314 startString += " --- "+((Event*)incidence)->dtEndStr(true);
1317 1315
1318 } 1316 }
1319 1317
1320 } else { 1318 } else {
1321 if ( incidence->dtStart().time() != incidence->dtEnd().time() ) 1319 if ( incidence->dtStart().time() != incidence->dtEnd().time() )
1322 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ 1320 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+
1323 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); 1321 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time());
1324 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); 1322 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true);
1325 } 1323 }
1326 1324
1327 } 1325 }
1328 else 1326 else
1329 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); 1327 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed");
1330 if ( !incidence->location().isEmpty() ) 1328 if ( !incidence->location().isEmpty() )
1331 startString += " (" +incidence->location()+")"; 1329 startString += " (" +incidence->location()+")";
1332 setCaption( incidence->summary()+startString); 1330 setCaption( incidence->summary()+startString);
1333 1331
1334 enableIncidenceActions( true ); 1332 enableIncidenceActions( true );
1335 1333
1336 if ( incidence->type() == "Event" ) { 1334 if ( incidence->type() == "Event" ) {
1337 mShowAction->setText( i18n("Show Event...") ); 1335 mShowAction->setText( i18n("Show Event...") );
1338 mEditAction->setText( i18n("Edit Event...") ); 1336 mEditAction->setText( i18n("Edit Event...") );
1339 mDeleteAction->setText( i18n("Delete Event...") ); 1337 mDeleteAction->setText( i18n("Delete Event...") );
1340 1338
1341 mNewSubTodoAction->setEnabled( false ); 1339 mNewSubTodoAction->setEnabled( false );
1342 } else if ( incidence->type() == "Todo" ) { 1340 } else if ( incidence->type() == "Todo" ) {
1343 mShowAction->setText( i18n("Show Todo...") ); 1341 mShowAction->setText( i18n("Show Todo...") );
1344 mEditAction->setText( i18n("Edit Todo...") ); 1342 mEditAction->setText( i18n("Edit Todo...") );
1345 mDeleteAction->setText( i18n("Delete Todo...") ); 1343 mDeleteAction->setText( i18n("Delete Todo...") );
1346 1344
1347 mNewSubTodoAction->setEnabled( true ); 1345 mNewSubTodoAction->setEnabled( true );
1348 } else { 1346 } else {
1349 mShowAction->setText( i18n("Show...") ); 1347 mShowAction->setText( i18n("Show...") );
1350 mShowAction->setText( i18n("Edit...") ); 1348 mShowAction->setText( i18n("Edit...") );
1351 mShowAction->setText( i18n("Delete...") ); 1349 mShowAction->setText( i18n("Delete...") );
1352 1350
1353 mNewSubTodoAction->setEnabled( false ); 1351 mNewSubTodoAction->setEnabled( false );
1354 } 1352 }
1355} 1353}
1356 1354
1357void MainWindow::enableIncidenceActions( bool enabled ) 1355void MainWindow::enableIncidenceActions( bool enabled )
1358{ 1356{
1359 mShowAction->setEnabled( enabled ); 1357 mShowAction->setEnabled( enabled );
1360 mEditAction->setEnabled( enabled ); 1358 mEditAction->setEnabled( enabled );
1361 mDeleteAction->setEnabled( enabled ); 1359 mDeleteAction->setEnabled( enabled );
1362} 1360}
1363 1361
1364void MainWindow::importOL() 1362void MainWindow::importOL()
1365{ 1363{
1366#ifdef _WIN32_ 1364#ifdef _WIN32_
1367 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); 1365 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this );
1368 id->exec(); 1366 id->exec();
1369 delete id; 1367 delete id;
1370 mView->updateView(); 1368 mView->updateView();
1371#endif 1369#endif
1372} 1370}
1373void MainWindow::importBday() 1371void MainWindow::importBday()
1374{ 1372{
1375 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1373 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1376 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), 1374 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"),
1377 i18n("Import!"), i18n("Cancel"), 0, 1375 i18n("Import!"), i18n("Cancel"), 0,
1378 0, 1 ); 1376 0, 1 );
1379 if ( result == 0 ) { 1377 if ( result == 0 ) {
1380 mView->importBday(); 1378 mView->importBday();
1381 1379
1382 } 1380 }
1383 1381
1384 1382
1385} 1383}
1386void MainWindow::importQtopia() 1384void MainWindow::importQtopia()
1387{ 1385{
1388#ifndef DESKTOP_VERSION 1386#ifndef DESKTOP_VERSION
1389 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1387 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1390 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"), 1388 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"),
1391 i18n("Import!"), i18n("Cancel"), 0, 1389 i18n("Import!"), i18n("Cancel"), 0,
1392 0, 1 ); 1390 0, 1 );
1393 if ( result == 0 ) { 1391 if ( result == 0 ) {
1394 QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); 1392 QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
1395 QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); 1393 QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
1396 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; 1394 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
1397 mView->importQtopia( categories, datebook, todolist ); 1395 mView->importQtopia( categories, datebook, todolist );
1398 } 1396 }
1399#else 1397#else
1400 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1398 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1401 i18n("Not supported \non desktop!\n"), 1399 i18n("Not supported \non desktop!\n"),
1402 i18n("Ok"), i18n("Cancel"), 0, 1400 i18n("Ok"), i18n("Cancel"), 0,
1403 0, 1 ); 1401 0, 1 );
1404 1402
1405#endif 1403#endif
1406} 1404}
1407 1405
1408void MainWindow::saveOnClose() 1406void MainWindow::saveOnClose()
1409{ 1407{
1410 KOPrefs *p = KOPrefs::instance(); 1408 KOPrefs *p = KOPrefs::instance();
1411 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); 1409 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
1412 p->mToolBarUp = iconToolBar->x() > width()/2 || 1410 p->mToolBarUp = iconToolBar->x() > width()/2 ||
1413 iconToolBar->y() > height()/2; 1411 iconToolBar->y() > height()/2;
1414 mView->writeSettings(); 1412 mView->writeSettings();
1415 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) 1413 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName()))
1416 save(); 1414 save();
1417} 1415}
1418void MainWindow::slotModifiedChanged( bool changed ) 1416void MainWindow::slotModifiedChanged( bool changed )
1419{ 1417{
1420 if ( mBlockAtStartup ) 1418 if ( mBlockAtStartup )
1421 return; 1419 return;
1422 int msec; 1420 int msec;
1423 // we store the changes after 1 minute, 1421 // we store the changes after 1 minute,
1424 // and for safety reasons after 10 minutes again 1422 // and for safety reasons after 10 minutes again
1425 if ( !mBlockSaveFlag ) 1423 if ( !mBlockSaveFlag )
1426 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1424 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1427 else 1425 else
1428 msec = 1000 * 600; 1426 msec = 1000 * 600;
1429 mSaveTimer.start( msec, true ); // 1 minute 1427 mSaveTimer.start( msec, true ); // 1 minute
1430 qDebug("KO: Saving File in %d secs!", msec/1000); 1428 qDebug("KO: Saving File in %d secs!", msec/1000);
1431 mCalendarModifiedFlag = true; 1429 mCalendarModifiedFlag = true;
1432} 1430}
1433void MainWindow::save() 1431void MainWindow::save()
1434{ 1432{
1435 if ( mBlockSaveFlag ) 1433 if ( mBlockSaveFlag )
1436 return; 1434 return;
1437 bool store = mBlockSaveFlag; 1435 bool store = mBlockSaveFlag;
1438 mBlockSaveFlag = true; 1436 mBlockSaveFlag = true;
1439 if ( mView->checkFileVersion( defaultFileName()) ) { 1437 if ( mView->checkFileVersion( defaultFileName()) ) {
1440 1438
1441 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1439 QTime neededSaveTime = QDateTime::currentDateTime().time();
1442 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1440 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1443 qDebug("KO: Start saving data to file!"); 1441 qDebug("KO: Start saving data to file!");
1444 mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 1442 mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
1445 mView->saveCalendar( defaultFileName() ); 1443 mView->saveCalendar( defaultFileName() );
1446 1444
1447 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 1445 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1448 mView->watchSavedFile(); 1446 mView->watchSavedFile();
1449 qDebug("KO: Needed %d ms for saving.",msNeeded ); 1447 qDebug("KO: Needed %d ms for saving.",msNeeded );
1450 QString savemes; 1448 QString savemes;
1451 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 1449 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
1452 setCaption(savemes); 1450 setCaption(savemes);
1453 } else 1451 } else
1454 setCaption(i18n("Saving cancelled!")); 1452 setCaption(i18n("Saving cancelled!"));
1455 mCalendarModifiedFlag = false; 1453 mCalendarModifiedFlag = false;
1456 mBlockSaveFlag = store; 1454 mBlockSaveFlag = store;
1457} 1455}
1458 1456
1459void MainWindow::keyReleaseEvent ( QKeyEvent * e) 1457void MainWindow::keyReleaseEvent ( QKeyEvent * e)
1460{ 1458{
1461 if ( !e->isAutoRepeat() ) { 1459 if ( !e->isAutoRepeat() ) {
1462 mFlagKeyPressed = false; 1460 mFlagKeyPressed = false;
1463 } 1461 }
1464} 1462}
1465void MainWindow::keyPressEvent ( QKeyEvent * e ) 1463void MainWindow::keyPressEvent ( QKeyEvent * e )
1466{ 1464{
1467 qApp->processEvents(); 1465 qApp->processEvents();
1468 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 1466 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1469 e->ignore(); 1467 e->ignore();
1470 // qDebug(" ignore %d",e->isAutoRepeat() ); 1468 // qDebug(" ignore %d",e->isAutoRepeat() );
1471 return; 1469 return;
1472 } 1470 }
1473 if (! e->isAutoRepeat() ) 1471 if (! e->isAutoRepeat() )
1474 mFlagKeyPressed = true; 1472 mFlagKeyPressed = true;
1475 KOPrefs *p = KOPrefs::instance(); 1473 KOPrefs *p = KOPrefs::instance();
1476 bool showSelectedDates = false; 1474 bool showSelectedDates = false;
1477 int size; 1475 int size;
1478 int pro = 0; 1476 int pro = 0;
1479 //qDebug("MainWindow::keyPressEvent "); 1477 //qDebug("MainWindow::keyPressEvent ");
1480 switch ( e->key() ) { 1478 switch ( e->key() ) {
1481 case Qt::Key_Right: 1479 case Qt::Key_Right:
1482 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1480 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1483 mView->goNextMonth(); 1481 mView->goNextMonth();
1484 else 1482 else
1485 mView->goNext(); 1483 mView->goNext();
1486 showSelectedDates = true; 1484 showSelectedDates = true;
1487 break; 1485 break;
1488 case Qt::Key_Left: 1486 case Qt::Key_Left:
1489 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1487 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1490 mView->goPreviousMonth(); 1488 mView->goPreviousMonth();
1491 else 1489 else
1492 mView->goPrevious(); 1490 mView->goPrevious();
1493 showSelectedDates = true; 1491 showSelectedDates = true;
1494 break; 1492 break;
1495 case Qt::Key_Down: 1493 case Qt::Key_Down:
1496 mView->viewManager()->agendaView()->scrollOneHourDown(); 1494 mView->viewManager()->agendaView()->scrollOneHourDown();
1497 break; 1495 break;
1498 case Qt::Key_Up: 1496 case Qt::Key_Up:
1499 mView->viewManager()->agendaView()->scrollOneHourUp(); 1497 mView->viewManager()->agendaView()->scrollOneHourUp();
1500 break; 1498 break;
1501 case Qt::Key_I: 1499 case Qt::Key_I:
1502 mView->showIncidence(); 1500 mView->showIncidence();
1503 break; 1501 break;
1504 case Qt::Key_Delete: 1502 case Qt::Key_Delete:
1505 case Qt::Key_Backspace: 1503 case Qt::Key_Backspace:
1506 mView->deleteIncidence(); 1504 mView->deleteIncidence();
1507 break; 1505 break;
1508 case Qt::Key_D: 1506 case Qt::Key_D:
1509 mView->viewManager()->showDayView(); 1507 mView->viewManager()->showDayView();
1510 showSelectedDates = true; 1508 showSelectedDates = true;
1511 break; 1509 break;
1512 case Qt::Key_O: 1510 case Qt::Key_O:
1513 mView->toggleFilerEnabled( ); 1511 mView->toggleFilerEnabled( );
1514 break; 1512 break;
1515 case Qt::Key_0: 1513 case Qt::Key_0:
1516 case Qt::Key_1: 1514 case Qt::Key_1:
1517 case Qt::Key_2: 1515 case Qt::Key_2:
1518 case Qt::Key_3: 1516 case Qt::Key_3:
1519 case Qt::Key_4: 1517 case Qt::Key_4:
1520 case Qt::Key_5: 1518 case Qt::Key_5:
1521 case Qt::Key_6: 1519 case Qt::Key_6:
1522 case Qt::Key_7: 1520 case Qt::Key_7:
1523 case Qt::Key_8: 1521 case Qt::Key_8:
1524 case Qt::Key_9: 1522 case Qt::Key_9:
1525 pro = e->key()-48; 1523 pro = e->key()-48;
1526 if ( pro == 0 ) 1524 if ( pro == 0 )
1527 pro = 10; 1525 pro = 10;
1528 if ( e->state() == Qt::ControlButton) 1526 if ( e->state() == Qt::ControlButton)
1529 pro += 10; 1527 pro += 10;
1530 break; 1528 break;
1531 case Qt::Key_M: 1529 case Qt::Key_M:
1532 mView->viewManager()->showMonthView(); 1530 mView->viewManager()->showMonthView();
1533 showSelectedDates = true; 1531 showSelectedDates = true;
1534 break; 1532 break;
1535 case Qt::Key_Insert: 1533 case Qt::Key_Insert:
1536 mView->newEvent(); 1534 mView->newEvent();
1537 break; 1535 break;
1538 case Qt::Key_S : 1536 case Qt::Key_S :
1539 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1537 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1540 mView->newSubTodo(); 1538 mView->newSubTodo();
1541 else 1539 else
1542 mView->dialogManager()->showSearchDialog(); 1540 mView->dialogManager()->showSearchDialog();
1543 break; 1541 break;
1544 case Qt::Key_Y : 1542 case Qt::Key_Y :
1545 case Qt::Key_Z : 1543 case Qt::Key_Z :
1546 mView->viewManager()->showWorkWeekView(); 1544 mView->viewManager()->showWorkWeekView();
1547 showSelectedDates = true; 1545 showSelectedDates = true;
1548 break; 1546 break;
1549 case Qt::Key_U : 1547 case Qt::Key_U :
1550 mView->viewManager()->showWeekView(); 1548 mView->viewManager()->showWeekView();
1551 showSelectedDates = true; 1549 showSelectedDates = true;
1552 break; 1550 break;
1553 case Qt::Key_H : 1551 case Qt::Key_H :
1554 keyBindings(); 1552 keyBindings();
1555 break; 1553 break;
1556 case Qt::Key_W: 1554 case Qt::Key_W:
1557 mView->viewManager()->showWhatsNextView(); 1555 mView->viewManager()->showWhatsNextView();
1558 break; 1556 break;
1559 case Qt::Key_L: 1557 case Qt::Key_L:
1560 mView->viewManager()->showListView(); 1558 mView->viewManager()->showListView();
1561 break; 1559 break;
1562 case Qt::Key_N: 1560 case Qt::Key_N:
1563 mView->viewManager()->showNextXView(); 1561 mView->viewManager()->showNextXView();
1564 showSelectedDates = true; 1562 showSelectedDates = true;
1565 break; 1563 break;
1566 case Qt::Key_V: 1564 case Qt::Key_V:
1567 mView->viewManager()->showTodoView(); 1565 mView->viewManager()->showTodoView();
1568 break; 1566 break;
1569 case Qt::Key_C: 1567 case Qt::Key_C:
1570 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); 1568 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() );
1571 break; 1569 break;
1572 case Qt::Key_P: 1570 case Qt::Key_P:
1573 mView->showDatePicker( ); 1571 mView->showDatePicker( );
1574 break; 1572 break;
1575 case Qt::Key_F: 1573 case Qt::Key_F:
1576 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1574 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1577 mView->editFilters(); 1575 mView->editFilters();
1578 else 1576 else
1579 mView->toggleFilter(); 1577 mView->toggleFilter();
1580 break; 1578 break;
1581 case Qt::Key_X: 1579 case Qt::Key_X:
1582 mView->toggleDateNavigatorWidget(); 1580 mView->toggleDateNavigatorWidget();
1583 break; 1581 break;
1584 case Qt::Key_Space: 1582 case Qt::Key_Space:
1585 mView->toggleExpand(); 1583 mView->toggleExpand();
1586 break; 1584 break;
1587 case Qt::Key_A: 1585 case Qt::Key_A:
1588 mView->toggleAllDaySize(); 1586 mView->toggleAllDaySize();
1589 break; 1587 break;
1590 case Qt::Key_T: 1588 case Qt::Key_T:
1591 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1589 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1592 mView->newTodo(); 1590 mView->newTodo();
1593 else { 1591 else {
1594 mView->goToday(); 1592 mView->goToday();
1595 showSelectedDates = true; 1593 showSelectedDates = true;
1596 } 1594 }
1597 break; 1595 break;
1598 case Qt::Key_J: 1596 case Qt::Key_J:
1599 mView->viewManager()->showJournalView(); 1597 mView->viewManager()->showJournalView();
1600 break; 1598 break;
1601 case Qt::Key_B: 1599 case Qt::Key_B:
1602 mView->editIncidenceDescription();; 1600 mView->editIncidenceDescription();;
1603 break; 1601 break;
1604 // case Qt::Key_Return: 1602 // case Qt::Key_Return:
1605 case Qt::Key_E: 1603 case Qt::Key_E:
1606 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1604 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1607 mView->newEvent(); 1605 mView->newEvent();
1608 else 1606 else
1609 mView->editIncidence(); 1607 mView->editIncidence();
1610 break; 1608 break;
1611 case Qt::Key_Plus: 1609 case Qt::Key_Plus:
1612 size = p->mHourSize +2; 1610 size = p->mHourSize +2;
1613 if ( size <= 18 ) 1611 if ( size <= 18 )
1614 configureAgenda( size ); 1612 configureAgenda( size );
1615 break; 1613 break;
1616 case Qt::Key_Minus: 1614 case Qt::Key_Minus:
1617 size = p->mHourSize - 2; 1615 size = p->mHourSize - 2;
1618 if ( size >= 4 ) 1616 if ( size >= 4 )
1619 configureAgenda( size ); 1617 configureAgenda( size );
1620 break; 1618 break;
1621 1619
1622 1620
1623 default: 1621 default:
1624 e->ignore(); 1622 e->ignore();
1625 } 1623 }
1626 if ( pro > 0 ) { 1624 if ( pro > 0 ) {
1627 mView->selectFilter( pro-1 ); 1625 mView->selectFilter( pro-1 );
1628 } 1626 }
1629 if ( showSelectedDates ) { 1627 if ( showSelectedDates ) {
1630 ;// setCaptionToDates(); 1628 ;// setCaptionToDates();
1631 } 1629 }
1632 1630
1633} 1631}
1634 1632
1635void MainWindow::fillFilterMenu() 1633void MainWindow::fillFilterMenu()
1636{ 1634{
1637 selectFilterMenu->clear(); 1635 selectFilterMenu->clear();
1638 bool disable = false; 1636 bool disable = false;
1639 if ( mView->filterView()->filtersEnabled() ) { 1637 if ( mView->filterView()->filtersEnabled() ) {
1640 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 ); 1638 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 0 );
1641 } 1639 }
1642 else { 1640 else {
1643 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 ); 1641 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 );
1644 disable = true; 1642 disable = true;
1645 } 1643 }
1646 selectFilterMenu->insertSeparator(); 1644 selectFilterMenu->insertSeparator();
1647 QPtrList<CalFilter> fili = mView->filters(); 1645 QPtrList<CalFilter> fili = mView->filters();
1648 CalFilter *curfilter = mView->filterView()->selectedFilter(); 1646 CalFilter *curfilter = mView->filterView()->selectedFilter();
1649 CalFilter *filter = fili.first(); 1647 CalFilter *filter = fili.first();
1650 int iii = 1; 1648 int iii = 1;
1651 while(filter) { 1649 while(filter) {
1652 selectFilterMenu->insertItem( filter->name(), iii ); 1650 selectFilterMenu->insertItem( filter->name(), iii );
1653 if ( filter == curfilter) 1651 if ( filter == curfilter)
1654 selectFilterMenu->setItemChecked( iii, true ); 1652 selectFilterMenu->setItemChecked( iii, true );
1655 if ( disable ) 1653 if ( disable )
1656 selectFilterMenu->setItemEnabled( iii, false ); 1654 selectFilterMenu->setItemEnabled( iii, false );
1657 filter = fili.next(); 1655 filter = fili.next();
1658 ++iii; 1656 ++iii;
1659 } 1657 }
1660} 1658}
1661void MainWindow::selectFilter( int fil ) 1659void MainWindow::selectFilter( int fil )
1662{ 1660{
1663 if ( fil == 0 ) { 1661 if ( fil == 0 ) {
1664 mView->toggleFilerEnabled( ); 1662 mView->toggleFilerEnabled( );
1665 } else { 1663 } else {
1666 mView->selectFilter( fil-1 ); 1664 mView->selectFilter( fil-1 );
1667 } 1665 }
1668} 1666}
1669void MainWindow::configureToolBar( int item ) 1667void MainWindow::configureToolBar( int item )
1670{ 1668{
1671 1669
1672 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); 1670 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) );
1673 KOPrefs *p = KOPrefs::instance(); 1671 KOPrefs *p = KOPrefs::instance();
1674 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); 1672 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 );
1675 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); 1673 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 );
1676 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); 1674 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 );
1677 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); 1675 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 );
1678 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); 1676 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 );
1679 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); 1677 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 );
1680 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); 1678 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 );
1681 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); 1679 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 );
1682 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); 1680 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 );
1683 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); 1681 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 );
1684 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); 1682 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 );
1685 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); 1683 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 );
1686 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); 1684 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 );
1687 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); 1685 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 );
1688 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); 1686 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 );
1689 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); 1687 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 );
1690 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); 1688 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 );
1691 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); 1689 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 );
1692 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); 1690 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 );
1693 // initActions(); 1691 // initActions();
1694} 1692}
1695 1693
1696void MainWindow::setCaptionToDates() 1694void MainWindow::setCaptionToDates()
1697{ 1695{
1698 QString selDates; 1696 QString selDates;
1699 selDates = KGlobal::locale()->formatDate(mView->startDate(), true); 1697 selDates = KGlobal::locale()->formatDate(mView->startDate(), true);
1700 if (mView->startDate() < mView->endDate() ) 1698 if (mView->startDate() < mView->endDate() )
1701 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); 1699 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true);
1702 setCaption( i18n("Dates: ") + selDates ); 1700 setCaption( i18n("Dates: ") + selDates );
1703 1701
1704} 1702}
1705// parameter item == 0: reinit 1703// parameter item == 0: reinit
1706void MainWindow::configureAgenda( int item ) 1704void MainWindow::configureAgenda( int item )
1707{ 1705{
1708 1706
1709 KOPrefs *p = KOPrefs::instance(); 1707 KOPrefs *p = KOPrefs::instance();
1710 1708
1711 int i; 1709 int i;
1712 if ( item == 1 ) { 1710 if ( item == 1 ) {
1713 mView->toggleAllDaySize(); 1711 mView->toggleAllDaySize();
1714 return; 1712 return;
1715 } 1713 }
1716 // do not allow 4 for widgets higher than 480 1714 // do not allow 4 for widgets higher than 480
1717 // if ( QApplication::desktop()->height() > 480 ) { 1715 // if ( QApplication::desktop()->height() > 480 ) {
1718// if ( item == 4 ) 1716// if ( item == 4 )
1719// item = 6; 1717// item = 6;
1720// } 1718// }
1721 for ( i = 4; i <= 18; i= i+2 ) 1719 for ( i = 4; i <= 18; i= i+2 )
1722 configureAgendaMenu->setItemChecked( i, false ); 1720 configureAgendaMenu->setItemChecked( i, false );
1723 configureAgendaMenu->setItemChecked( item, true ); 1721 configureAgendaMenu->setItemChecked( item, true );
1724 if ( p->mHourSize == item ) 1722 if ( p->mHourSize == item )
1725 return; 1723 return;
1726 p->mHourSize=item; 1724 p->mHourSize=item;
1727 mView->viewManager()->agendaView()->updateConfig(); 1725 mView->viewManager()->agendaView()->updateConfig();
1728} 1726}
1729 1727
1730void MainWindow::saveCalendar() 1728void MainWindow::saveCalendar()
1731{ 1729{
1732 QString fn = KOPrefs::instance()->mLastSaveFile; 1730 QString fn = KOPrefs::instance()->mLastSaveFile;
1733 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); 1731 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this );
1734 1732
1735 if ( fn == "" ) 1733 if ( fn == "" )
1736 return; 1734 return;
1737 QFileInfo info; 1735 QFileInfo info;
1738 info.setFile( fn ); 1736 info.setFile( fn );
1739 QString mes; 1737 QString mes;
1740 bool createbup = true; 1738 bool createbup = true;
1741 if ( info. exists() ) { 1739 if ( info. exists() ) {
1742 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; 1740 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ;
1743 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1741 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1744 i18n("Overwrite!"), i18n("Cancel"), 0, 1742 i18n("Overwrite!"), i18n("Cancel"), 0,
1745 0, 1 ); 1743 0, 1 );
1746 if ( result != 0 ) { 1744 if ( result != 0 ) {
1747 createbup = false; 1745 createbup = false;
1748 } 1746 }
1749 } 1747 }
1750 if ( createbup ) { 1748 if ( createbup ) {
1751 mView->saveCalendar( fn ); 1749 mView->saveCalendar( fn );
1752 mes = i18n("KO/Pi:Saved %1").arg(fn); 1750 mes = i18n("KO/Pi:Saved %1").arg(fn);
1753 KOPrefs::instance()->mLastSaveFile = fn; 1751 KOPrefs::instance()->mLastSaveFile = fn;
1754 setCaption(mes); 1752 setCaption(mes);
1755 } 1753 }
1756} 1754}
1757void MainWindow::loadCalendar() 1755void MainWindow::loadCalendar()
1758{ 1756{
1759 1757
1760 QString fn = KOPrefs::instance()->mLastLoadFile; 1758 QString fn = KOPrefs::instance()->mLastLoadFile;
1761 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); 1759 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this );
1762 1760
1763 if ( fn == "" ) 1761 if ( fn == "" )
1764 return; 1762 return;
1765 QFileInfo info; 1763 QFileInfo info;
1766 info.setFile( fn ); 1764 info.setFile( fn );
1767 QString mess; 1765 QString mess;
1768 bool loadbup = true; 1766 bool loadbup = true;
1769 if ( info. exists() ) { 1767 if ( info. exists() ) {
1770 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1768 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1771 int result = QMessageBox::warning( this, "KO/Pi: Warning!", 1769 int result = QMessageBox::warning( this, "KO/Pi: Warning!",
1772 mess, 1770 mess,
1773 i18n("Load!"), i18n("Cancel"), 0, 1771 i18n("Load!"), i18n("Cancel"), 0,
1774 0, 1 ); 1772 0, 1 );
1775 if ( result != 0 ) { 1773 if ( result != 0 ) {
1776 loadbup = false; 1774 loadbup = false;
1777 } 1775 }
1778 } else { 1776 } else {
1779 QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1777 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1780 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, 1778 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0,
1781 0, 1 ); 1779 0, 1 );
1782 1780
1783 return; 1781 return;
1784 } 1782 }
1785 if ( loadbup ) { 1783 if ( loadbup ) {
1786 mView->openCalendar( fn ); 1784 mView->openCalendar( fn );
1787 KOPrefs::instance()->mLastLoadFile = fn; 1785 KOPrefs::instance()->mLastLoadFile = fn;
1788 mess = i18n("KO/Pi:Loaded %1").arg(fn) ; 1786 mess = i18n("KO/Pi:Loaded %1").arg(fn) ;
1789 setCaption(mess); 1787 setCaption(mess);
1790 } 1788 }
1791 1789
1792} 1790}
1793void MainWindow::quickImportIcal() 1791void MainWindow::quickImportIcal()
1794{ 1792{
1795 importFile( KOPrefs::instance()->mLastImportFile, false ); 1793 importFile( KOPrefs::instance()->mLastImportFile, false );
1796} 1794}
1797void MainWindow::importFile( QString fn, bool quick ) 1795void MainWindow::importFile( QString fn, bool quick )
1798{ 1796{
1799 QFileInfo info; 1797 QFileInfo info;
1800 info.setFile( fn ); 1798 info.setFile( fn );
1801 QString mess; 1799 QString mess;
1802 bool loadbup = true; 1800 bool loadbup = true;
1803 if ( !info. exists() ) { 1801 if ( !info. exists() ) {
1804 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); 1802 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30));
1805 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1803 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1806 mess ); 1804 mess );
1807 return; 1805 return;
1808 } 1806 }
1809 int result = 0; 1807 int result = 0;
1810 if ( !quick ) { 1808 if ( !quick ) {
1811 mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1809 mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1812 result = QMessageBox::warning( this, "KO/Pi: Warning!", 1810 result = QMessageBox::warning( this, "KO/Pi: Warning!",
1813 mess, 1811 mess,
1814 "Import", "Cancel", 0, 1812 "Import", "Cancel", 0,
1815 0, 1 ); 1813 0, 1 );
1816 } 1814 }
1817 if ( result == 0 ) { 1815 if ( result == 0 ) {
1818 if ( mView->openCalendar( fn, true )) { 1816 if ( mView->openCalendar( fn, true )) {
1819 KOPrefs::instance()->mLastImportFile = fn; 1817 KOPrefs::instance()->mLastImportFile = fn;
1820 setCaption(i18n("Imported file successfully")); 1818 setCaption(i18n("Imported file successfully"));
1821 } else { 1819 } else {
1822 setCaption(i18n("Error importing file")); 1820 setCaption(i18n("Error importing file"));
1823 } 1821 }
1824 } 1822 }
1825} 1823}
1826 1824
1827void MainWindow::importIcal() 1825void MainWindow::importIcal()
1828{ 1826{
1829 1827
1830 QString fn =KOPrefs::instance()->mLastImportFile; 1828 QString fn =KOPrefs::instance()->mLastImportFile;
1831 1829
1832 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); 1830 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this );
1833 if ( fn == "" ) 1831 if ( fn == "" )
1834 return; 1832 return;
1835 importFile( fn, true ); 1833 importFile( fn, true );
1836 1834
1837} 1835}
1838 1836
1839void MainWindow::exportVCalendar() 1837void MainWindow::exportVCalendar()
1840{ 1838{
1841 QString fn = KOPrefs::instance()->mLastVcalFile; 1839 QString fn = KOPrefs::instance()->mLastVcalFile;
1842 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); 1840 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this );
1843 if ( fn == "" ) 1841 if ( fn == "" )
1844 return; 1842 return;
1845 QFileInfo info; 1843 QFileInfo info;
1846 info.setFile( fn ); 1844 info.setFile( fn );
1847 QString mes; 1845 QString mes;
1848 bool createbup = true; 1846 bool createbup = true;
1849 if ( info. exists() ) { 1847 if ( info. exists() ) {
1850 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 1848 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
1851 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1849 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1852 i18n("Overwrite!"), i18n("Cancel"), 0, 1850 i18n("Overwrite!"), i18n("Cancel"), 0,
1853 0, 1 ); 1851 0, 1 );
1854 if ( result != 0 ) { 1852 if ( result != 0 ) {
1855 createbup = false; 1853 createbup = false;
1856 } 1854 }
1857 } 1855 }
1858 if ( createbup ) { 1856 if ( createbup ) {
1859 if ( mView->exportVCalendar( fn ) ) { 1857 if ( mView->exportVCalendar( fn ) ) {
1860 KOPrefs::instance()->mLastVcalFile = fn; 1858 KOPrefs::instance()->mLastVcalFile = fn;
1861 if ( fn.length() > 20 ) 1859 if ( fn.length() > 20 )
1862 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; 1860 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ;
1863 else 1861 else
1864 mes = i18n("KO/Pi:Exported to %1").arg(fn ); 1862 mes = i18n("KO/Pi:Exported to %1").arg(fn );
1865 setCaption(mes); 1863 setCaption(mes);
1866 } 1864 }
1867 } 1865 }
1868 1866
1869} 1867}
1870QString MainWindow::getPassword( ) 1868QString MainWindow::getPassword( )
1871{ 1869{
1872 QString retfile = ""; 1870 QString retfile = "";
1873 QDialog dia ( this, "input-dialog", true ); 1871 QDialog dia ( this, "input-dialog", true );
1874 QLineEdit lab ( &dia ); 1872 QLineEdit lab ( &dia );
1875 lab.setEchoMode( QLineEdit::Password ); 1873 lab.setEchoMode( QLineEdit::Password );
1876 QVBoxLayout lay( &dia ); 1874 QVBoxLayout lay( &dia );
1877 lay.setMargin(7); 1875 lay.setMargin(7);
1878 lay.setSpacing(7); 1876 lay.setSpacing(7);
1879 lay.addWidget( &lab); 1877 lay.addWidget( &lab);
1880 dia.setFixedSize( 230,50 ); 1878 dia.setFixedSize( 230,50 );
1881 dia.setCaption( i18n("Enter password") ); 1879 dia.setCaption( i18n("Enter password") );
1882 QPushButton pb ( "OK", &dia); 1880 QPushButton pb ( "OK", &dia);
1883 lay.addWidget( &pb ); 1881 lay.addWidget( &pb );
1884 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 1882 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
1885 dia.show(); 1883 dia.show();
1886 int res = dia.exec(); 1884 int res = dia.exec();
1887 if ( res ) 1885 if ( res )
1888 retfile = lab.text(); 1886 retfile = lab.text();
1889 dia.hide(); 1887 dia.hide();
1890 qApp->processEvents(); 1888 qApp->processEvents();
1891 return retfile; 1889 return retfile;
1892 1890
1893} 1891}
1894 1892
1895void MainWindow::enableQuick() 1893void MainWindow::enableQuick()
1896{ 1894{
1897 QString passWordPiSync = "bhdrvmk"; 1895 QString passWordPiSync = "bhdrvmk";
1898 QString retfile = ""; 1896 QString retfile = "";
1899 QDialog dia ( this, "input-dialog", true ); 1897 QDialog dia ( this, "input-dialog", true );
1900 QLineEdit lab ( &dia ); 1898 QLineEdit lab ( &dia );
1901 QVBoxLayout lay( &dia ); 1899 QVBoxLayout lay( &dia );
1902 lab.setText( KOPrefs::instance()->mPassiveSyncPort ); 1900 lab.setText( KOPrefs::instance()->mPassiveSyncPort );
1903 lay.setMargin(7); 1901 lay.setMargin(7);
1904 lay.setSpacing(7); 1902 lay.setSpacing(7);
1905 QLabel label ( i18n("Port number (Default: 9197)"), &dia ); 1903 QLabel label ( i18n("Port number (Default: 9197)"), &dia );
1906 lay.addWidget( &label); 1904 lay.addWidget( &label);
1907 lay.addWidget( &lab); 1905 lay.addWidget( &lab);
1908 1906
1909 QLineEdit lepw ( &dia ); 1907 QLineEdit lepw ( &dia );
1910 lepw.setText( "abc" ); 1908 lepw.setText( "abc" );
1911 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); 1909 QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia );
1912 lay.addWidget( &label2); 1910 lay.addWidget( &label2);
1913 lay.addWidget( &lepw); 1911 lay.addWidget( &lepw);
1914 dia.setFixedSize( 230,80 ); 1912 dia.setFixedSize( 230,80 );
1915 dia.setCaption( i18n("Enter port for Pi-Sync") ); 1913 dia.setCaption( i18n("Enter port for Pi-Sync") );
1916 QPushButton pb ( "OK", &dia); 1914 QPushButton pb ( "OK", &dia);
1917 lay.addWidget( &pb ); 1915 lay.addWidget( &pb );
1918 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); 1916 connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) );
1919 dia.show(); 1917 dia.show();
1920 int res = dia.exec(); 1918 int res = dia.exec();
1921 if ( res ) 1919 if ( res )
1922 retfile = lab.text(); 1920 retfile = lab.text();
1923 else 1921 else
1924 return; 1922 return;
1925 dia.hide(); 1923 dia.hide();
1926 passWordPiSync = lepw.text(); 1924 passWordPiSync = lepw.text();
1927 qApp->processEvents(); 1925 qApp->processEvents();
1928 KOPrefs::instance()->mPassiveSyncPort = retfile; 1926 KOPrefs::instance()->mPassiveSyncPort = retfile;
1929 bool ok; 1927 bool ok;
1930 Q_UINT16 port = retfile.toUInt(&ok); 1928 Q_UINT16 port = retfile.toUInt(&ok);
1931 if ( ! ok ) { 1929 if ( ! ok ) {
1932 KMessageBox::information( this, i18n("No valid port")); 1930 KMessageBox::information( this, i18n("No valid port"));
1933 return; 1931 return;
1934 } 1932 }
1935 //qDebug("port %d ", port); 1933 //qDebug("port %d ", port);
1936 mServerSocket = new KServerSocket ( passWordPiSync, port ,1 ); 1934 mServerSocket = new KServerSocket ( passWordPiSync, port ,1 );
1937 mServerSocket->setFileName( defaultFileName() ); 1935 mServerSocket->setFileName( defaultFileName() );
1938 //qDebug("connected "); 1936 //qDebug("connected ");
1939 if ( !mServerSocket->ok() ) { 1937 if ( !mServerSocket->ok() ) {
1940 qWarning("Failed to bind to port %d", port); 1938 qWarning("Failed to bind to port %d", port);
1941 delete mServerSocket; 1939 delete mServerSocket;
1942 mServerSocket = 0; 1940 mServerSocket = 0;
1943 return; 1941 return;
1944 } 1942 }
1945 connect( mServerSocket, SIGNAL ( saveFile() ), this, SLOT ( save() ) ); 1943 connect( mServerSocket, SIGNAL ( saveFile() ), this, SLOT ( save() ) );
1946 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SLOT ( getFile( bool ) ) ); 1944 connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SLOT ( getFile( bool ) ) );
1947} 1945}
1948 1946
1949void MainWindow::getFile( bool success ) 1947void MainWindow::getFile( bool success )
1950{ 1948{
1951 if ( ! success ) { 1949 if ( ! success ) {
1952 setCaption( i18n("Error receiving file. Nothing changed!") ); 1950 setCaption( i18n("Error receiving file. Nothing changed!") );
1953 return; 1951 return;
1954 } 1952 }
1955 mView->watchSavedFile(); 1953 mView->watchSavedFile();
1956 mView->openCalendar( defaultFileName() ); 1954 mView->openCalendar( defaultFileName() );
1957 setCaption( i18n("Pi-Sync successful!") ); 1955 setCaption( i18n("Pi-Sync successful!") );
1958 1956
1959} 1957}
1960 1958
1961 1959
1962void MainWindow::syncPi() 1960void MainWindow::syncPi()
1963{ 1961{
1964 qApp->processEvents(); 1962 qApp->processEvents();
1965 bool ok; 1963 bool ok;
1966 Q_UINT16 port = KOPrefs::instance()->mActiveSyncPort.toUInt(&ok); 1964 Q_UINT16 port = KOPrefs::instance()->mActiveSyncPort.toUInt(&ok);
1967 if ( ! ok ) { 1965 if ( ! ok ) {
1968 setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); 1966 setCaption( i18n("Sorry, no valid port.Syncing cancelled.") );
1969 return; 1967 return;
1970 } 1968 }
1971 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, KOPrefs::instance()->mActiveSyncIP, this ); 1969 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, KOPrefs::instance()->mActiveSyncIP, this );
1972 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); 1970 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) );
1973 setCaption( i18n("Sending request for remote file ...") ); 1971 setCaption( i18n("Sending request for remote file ...") );
1974 commandSocket->readFile( syncFileName() ); 1972 commandSocket->readFile( syncFileName() );
1975} 1973}
1976 1974
1977void MainWindow::deleteCommandSocket(KCommandSocket*s, int state) 1975void MainWindow::deleteCommandSocket(KCommandSocket*s, int state)
1978{ 1976{
1979 qDebug("MainWindow::deleteCommandSocket %d", state); 1977 qDebug("MainWindow::deleteCommandSocket %d", state);
1980 1978
1981 //enum { success, errorW, errorR, quiet }; 1979 //enum { success, errorW, errorR, quiet };
1982 if ( state == KCommandSocket::errorR ) { 1980 if ( state == KCommandSocket::errorR ) {
1983 setCaption( i18n("ERROR: Receiving remote file failed.") ); 1981 setCaption( i18n("ERROR: Receiving remote file failed.") );
1984 delete s; 1982 delete s;
1985 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, KOPrefs::instance()->mActiveSyncPort.toUInt(), KOPrefs::instance()->mActiveSyncIP, this ); 1983 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, KOPrefs::instance()->mActiveSyncPort.toUInt(), KOPrefs::instance()->mActiveSyncIP, this );
1986 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 1984 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
1987 commandSocket->sendStop(); 1985 commandSocket->sendStop();
1988 return; 1986 return;
1989 1987
1990 } else if ( state == KCommandSocket::errorW ) { 1988 } else if ( state == KCommandSocket::errorW ) {
1991 setCaption( i18n("ERROR:Writing back file failed.") ); 1989 setCaption( i18n("ERROR:Writing back file failed.") );
1992 1990
1993 } else if ( state == KCommandSocket::successR ) { 1991 } else if ( state == KCommandSocket::successR ) {
1994 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); 1992 QTimer::singleShot( 1, this , SLOT ( readFileFromSocket()));
1995 1993
1996 } else if ( state == KCommandSocket::successW ) { 1994 } else if ( state == KCommandSocket::successW ) {
1997 setCaption( i18n("Pi-Sync succesful!") ); 1995 setCaption( i18n("Pi-Sync succesful!") );
1998 } 1996 }
1999 1997
2000 delete s; 1998 delete s;
2001} 1999}
2002 2000
2003void MainWindow::readFileFromSocket() 2001void MainWindow::readFileFromSocket()
2004{ 2002{
2005 QString fileName = syncFileName(); 2003 QString fileName = syncFileName();
2006 setCaption( i18n("Remote file saved to temp file.") ); 2004 setCaption( i18n("Remote file saved to temp file.") );
2007 if ( ! syncWithFile( fileName , true ) ) { 2005 if ( ! syncWithFile( fileName , true ) ) {
2008 setCaption( i18n("Syncing failed.") ); 2006 setCaption( i18n("Syncing failed.") );
2009 qDebug("Syncing failed "); 2007 qDebug("Syncing failed ");
2010 return; 2008 return;
2011 } 2009 }
2012 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, KOPrefs::instance()->mActiveSyncPort.toUInt(), KOPrefs::instance()->mActiveSyncIP, this ); 2010 KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, KOPrefs::instance()->mActiveSyncPort.toUInt(), KOPrefs::instance()->mActiveSyncIP, this );
2013 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); 2011 connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) );
2014 if ( KOPrefs::instance()->mWriteBackFile ) 2012 if ( KOPrefs::instance()->mWriteBackFile )
2015 commandSocket->writeFile( fileName ); 2013 commandSocket->writeFile( fileName );
2016 else { 2014 else {
2017 commandSocket->sendStop(); 2015 commandSocket->sendStop();
2018 setCaption( i18n("Pi-Sync succesful!") ); 2016 setCaption( i18n("Pi-Sync succesful!") );
2019 } 2017 }
2020} 2018}
2021 2019
2022void MainWindow::syncLocalFile() 2020void MainWindow::syncLocalFile()
2023{ 2021{
2024 2022
2025 QString fn =KOPrefs::instance()->mLastSyncedLocalFile; 2023 QString fn =KOPrefs::instance()->mLastSyncedLocalFile;
2026 2024
2027 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); 2025 fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this );
2028 if ( fn == "" ) 2026 if ( fn == "" )
2029 return; 2027 return;
2030 //mView->setSyncDevice("local-file" ); 2028 //mView->setSyncDevice("local-file" );
2031 if ( syncWithFile( fn, false ) ) { 2029 if ( syncWithFile( fn, false ) ) {
2032 // Event* e = mView->getLastSyncEvent(); 2030 // Event* e = mView->getLastSyncEvent();
2033// e->setReadOnly( false ); 2031// e->setReadOnly( false );
2034// e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); 2032// e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile);
2035// e->setReadOnly( true ); 2033// e->setReadOnly( true );
2036 } 2034 }
2037 2035
2038} 2036}
2039 2037
2040bool MainWindow::syncWithFile( QString fn , bool quick ) 2038bool MainWindow::syncWithFile( QString fn , bool quick )
2041{ 2039{
2042 bool ret = false; 2040 bool ret = false;
2043 QFileInfo info; 2041 QFileInfo info;
2044 info.setFile( fn ); 2042 info.setFile( fn );
2045 QString mess; 2043 QString mess;
2046 bool loadbup = true; 2044 bool loadbup = true;
2047 if ( !info. exists() ) { 2045 if ( !info. exists() ) {
2048 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); 2046 mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) );
2049 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2047 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2050 mess ); 2048 mess );
2051 return ret; 2049 return ret;
2052 } 2050 }
2053 int result = 0; 2051 int result = 0;
2054 if ( !quick ) { 2052 if ( !quick ) {
2055 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 2053 mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
2056 result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 2054 result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
2057 mess, 2055 mess,
2058 i18n("Sync"), i18n("Cancel"), 0, 2056 i18n("Sync"), i18n("Cancel"), 0,
2059 0, 1 ); 2057 0, 1 );
2060 if ( result ) 2058 if ( result )
2061 return false; 2059 return false;
2062 } 2060 }
2063 if ( KOPrefs::instance()->mAskForPreferences ) 2061 if ( KOPrefs::instance()->mAskForPreferences )
2064 mView->edit_sync_options(); 2062 mView->edit_sync_options();
2065 if ( result == 0 ) { 2063 if ( result == 0 ) {
2066 //qDebug("Now sycing ... "); 2064 //qDebug("Now sycing ... ");
2067 if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) ) 2065 if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) )
2068 setCaption( i18n("Synchronization successful") ); 2066 setCaption( i18n("Synchronization successful") );
2069 else 2067 else
2070 setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); 2068 setCaption( i18n("Sync cancelled or failed. Nothing synced.") );
2071 if ( ! quick ) 2069 if ( ! quick )
2072 KOPrefs::instance()->mLastSyncedLocalFile = fn; 2070 KOPrefs::instance()->mLastSyncedLocalFile = fn;
2073 slotModifiedChanged( true ); 2071 slotModifiedChanged( true );
2074 } 2072 }
2075 return ret; 2073 return ret;
2076} 2074}
2077void MainWindow::quickSyncLocalFile() 2075void MainWindow::quickSyncLocalFile()
2078{ 2076{
2079 //mView->setSyncDevice("local-file" ); 2077 //mView->setSyncDevice("local-file" );
2080 //qDebug("quickSyncLocalFile() "); 2078 //qDebug("quickSyncLocalFile() ");
2081 if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) { 2079 if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) {
2082 // Event* e = mView->getLastSyncEvent(); 2080 // Event* e = mView->getLastSyncEvent();
2083// e->setReadOnly( false ); 2081// e->setReadOnly( false );
2084// e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); 2082// e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile);
2085// e->setReadOnly( true ); 2083// e->setReadOnly( true );
2086 2084
2087 } 2085 }
2088} 2086}
2089 2087
2090void MainWindow::confSync() 2088void MainWindow::confSync()
2091{ 2089{
2092 mView->confSync(); 2090 mView->confSync();
2093 fillSyncMenu(); 2091 fillSyncMenu();
2094} 2092}
2095void MainWindow::syncRemote( KSyncProfile* prof, bool ask) 2093void MainWindow::syncRemote( KSyncProfile* prof, bool ask)
2096{ 2094{
2097 QString question; 2095 QString question;
2098 if ( ask ) { 2096 if ( ask ) {
2099 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; 2097 question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n";
2100 if ( QMessageBox::information( this, i18n("KO/Pi Sync"), 2098 if ( QMessageBox::information( this, i18n("KO/Pi Sync"),
2101 question, 2099 question,
2102 i18n("Yes"), i18n("No"), 2100 i18n("Yes"), i18n("No"),
2103 0, 0 ) != 0 ) 2101 0, 0 ) != 0 )
2104 return; 2102 return;
2105 } 2103 }
2106 QString command = prof->getPreSyncCommand(); 2104 QString command = prof->getPreSyncCommand();
2107 int fi; 2105 int fi;
2108 if ( (fi = command.find("$PWD$")) > 0 ) { 2106 if ( (fi = command.find("$PWD$")) > 0 ) {
2109 QString pwd = getPassword(); 2107 QString pwd = getPassword();
2110 command = command.left( fi )+ pwd + command.mid( fi+5 ); 2108 command = command.left( fi )+ pwd + command.mid( fi+5 );
2111 2109
2112 } 2110 }
2113 int maxlen = 30; 2111 int maxlen = 30;
2114 if ( QApplication::desktop()->width() > 320 ) 2112 if ( QApplication::desktop()->width() > 320 )
2115 maxlen += 25; 2113 maxlen += 25;
2116 setCaption ( i18n( "Copy remote file to local machine..." ) ); 2114 setCaption ( i18n( "Copy remote file to local machine..." ) );
2117 int fileSize = 0; 2115 int fileSize = 0;
2118 int result = system ( command ); 2116 int result = system ( command );
2119 // 0 : okay 2117 // 0 : okay
2120 // 256: no such file or dir 2118 // 256: no such file or dir
2121 // 2119 //
2122 qDebug("KO: Remote copy result(0 = okay): %d ",result ); 2120 qDebug("KO: Remote copy result(0 = okay): %d ",result );
2123 if ( result != 0 ) { 2121 if ( result != 0 ) {
2124 int len = maxlen; 2122 int len = maxlen;
2125 while ( len < command.length() ) { 2123 while ( len < command.length() ) {
2126 command.insert( len , "\n" ); 2124 command.insert( len , "\n" );
2127 len += maxlen +2; 2125 len += maxlen +2;
2128 } 2126 }
2129 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; 2127 question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ;
2130 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), 2128 QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"),
2131 question, 2129 question,
2132 i18n("Okay!")) ; 2130 i18n("Okay!")) ;
2133 setCaption ("KO/Pi"); 2131 setCaption ("KO/Pi");
2134 return; 2132 return;
2135 } 2133 }
2136 setCaption ( i18n( "Copying succeed." ) ); 2134 setCaption ( i18n( "Copying succeed." ) );
2137 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); 2135 //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() );
2138 if ( syncWithFile( prof->getLocalTempFile(), true ) ) { 2136 if ( syncWithFile( prof->getLocalTempFile(), true ) ) {
2139// Event* e = mView->getLastSyncEvent(); 2137// Event* e = mView->getLastSyncEvent();
2140// e->setReadOnly( false ); 2138// e->setReadOnly( false );
2141// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); 2139// e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]);
2142// e->setReadOnly( true ); 2140// e->setReadOnly( true );
2143 if ( KOPrefs::instance()->mWriteBackFile ) { 2141 if ( KOPrefs::instance()->mWriteBackFile ) {
2144 command = prof->getPostSyncCommand(); 2142 command = prof->getPostSyncCommand();
2145 int fi; 2143 int fi;
2146 if ( (fi = command.find("$PWD$")) > 0 ) { 2144 if ( (fi = command.find("$PWD$")) > 0 ) {
2147 QString pwd = getPassword(); 2145 QString pwd = getPassword();
2148 command = command.left( fi )+ pwd + command.mid( fi+5 ); 2146 command = command.left( fi )+ pwd + command.mid( fi+5 );
2149 2147
2150 } 2148 }
2151 setCaption ( i18n( "Writing back file ..." ) ); 2149 setCaption ( i18n( "Writing back file ..." ) );
2152 result = system ( command ); 2150 result = system ( command );
2153 qDebug("KO: Writing back file result: %d ", result); 2151 qDebug("KO: Writing back file result: %d ", result);
2154 if ( result != 0 ) { 2152 if ( result != 0 ) {
2155 setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); 2153 setCaption ( i18n( "Writing back file result: " )+QString::number( result ) );
2156 return; 2154 return;
2157 } else { 2155 } else {
2158 setCaption ( i18n( "Syncronization sucessfully completed" ) ); 2156 setCaption ( i18n( "Syncronization sucessfully completed" ) );
2159 } 2157 }
2160 } 2158 }
2161 } 2159 }
2162 return; 2160 return;
2163} 2161}
2164 2162
2165void MainWindow::syncSharp() 2163void MainWindow::syncSharp()
2166{ 2164{
2167 if ( mCalendarModifiedFlag ) 2165 if ( mCalendarModifiedFlag )
2168 save(); 2166 save();
2169 mView->syncSharp(); 2167 mView->syncSharp();
2170 slotModifiedChanged( true ); 2168 slotModifiedChanged( true );
2171 2169
2172} 2170}
2173void MainWindow::syncPhone() 2171void MainWindow::syncPhone()
2174{ 2172{
2175 if ( mCalendarModifiedFlag ) 2173 if ( mCalendarModifiedFlag )
2176 save(); 2174 save();
2177 mView->syncPhone(); 2175 mView->syncPhone();
2178 slotModifiedChanged( true ); 2176 slotModifiedChanged( true );
2179 2177
2180} 2178}
2181 2179
2182void MainWindow::printSel( ) 2180void MainWindow::printSel( )
2183{ 2181{
2184 mView->viewManager()->agendaView()->agenda()->printSelection(); 2182 mView->viewManager()->agendaView()->agenda()->printSelection();
2185} 2183}
2186 2184
2187void MainWindow::printCal() 2185void MainWindow::printCal()
2188{ 2186{
2189 mView->print();//mCp->showDialog(); 2187 mView->print();//mCp->showDialog();
2190} 2188}
2191 2189
2192 2190
2193 2191
2194KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) 2192KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name )
2195{ 2193{
2196 mPassWord = pw; 2194 mPassWord = pw;
2197 mSocket = 0; 2195 mSocket = 0;
2198 mSyncActionDialog = 0; 2196 mSyncActionDialog = 0;
2199}; 2197};
2200 2198
2201void KServerSocket::newConnection ( int socket ) 2199void KServerSocket::newConnection ( int socket )
2202{ 2200{
2203 // qDebug("KServerSocket:New connection %d ", socket); 2201 // qDebug("KServerSocket:New connection %d ", socket);
2204 if ( mSocket ) { 2202 if ( mSocket ) {
2205 qDebug("KServerSocket::newConnection Socket deleted! "); 2203 qDebug("KServerSocket::newConnection Socket deleted! ");
2206 delete mSocket; 2204 delete mSocket;
2207 mSocket = 0; 2205 mSocket = 0;
2208 } 2206 }
2209 mSocket = new QSocket( this ); 2207 mSocket = new QSocket( this );
2210 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); 2208 connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) );
2211 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); 2209 connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) );
2212 mSocket->setSocket( socket ); 2210 mSocket->setSocket( socket );
2213} 2211}
2214 2212
2215void KServerSocket::discardClient() 2213void KServerSocket::discardClient()
2216{ 2214{
2217 //qDebug(" KServerSocket::discardClient()"); 2215 //qDebug(" KServerSocket::discardClient()");
2218 if ( mSocket ) { 2216 if ( mSocket ) {
2219 delete mSocket; 2217 delete mSocket;
2220 mSocket = 0; 2218 mSocket = 0;
2221 } 2219 }
2222 //emit endConnect(); 2220 //emit endConnect();
2223} 2221}
2224void KServerSocket::readClient() 2222void KServerSocket::readClient()
2225{ 2223{
2226 if ( mSocket == 0 ) { 2224 if ( mSocket == 0 ) {
2227 qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); 2225 qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 ");
2228 return; 2226 return;
2229 } 2227 }
2230 //qDebug("KServerSocket readClient()"); 2228 //qDebug("KServerSocket readClient()");
2231 if ( mSocket->canReadLine() ) { 2229 if ( mSocket->canReadLine() ) {
2232 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), mSocket->readLine() ); 2230 QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), mSocket->readLine() );
2233 if ( tokens[0] == "GET" ) { 2231 if ( tokens[0] == "GET" ) {
2234 if ( tokens[1] == mPassWord ) 2232 if ( tokens[1] == mPassWord )
2235 //emit sendFile( mSocket ); 2233 //emit sendFile( mSocket );
2236 send_file(); 2234 send_file();
2237 else { 2235 else {
2238 KMessageBox::information( 0, i18n("ERROR:\nGot send file request\nwith invalid password")); 2236 KMessageBox::information( 0, i18n("ERROR:\nGot send file request\nwith invalid password"));
2239 qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); 2237 qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() );
2240 } 2238 }
2241 } 2239 }
2242 if ( tokens[0] == "PUT" ) { 2240 if ( tokens[0] == "PUT" ) {
2243 if ( tokens[1] == mPassWord ) 2241 if ( tokens[1] == mPassWord )
2244 //emit getFile( mSocket ); 2242 //emit getFile( mSocket );
2245 get_file(); 2243 get_file();
2246 else { 2244 else {
2247 KMessageBox::information( 0, i18n("ERROR:\nGot receive file request\nwith invalid password")); 2245 KMessageBox::information( 0, i18n("ERROR:\nGot receive file request\nwith invalid password"));
2248 qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); 2246 qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() );
2249 } 2247 }
2250 } 2248 }
2251 if ( tokens[0] == "STOP" ) { 2249 if ( tokens[0] == "STOP" ) {
2252 //emit endConnect(); 2250 //emit endConnect();
2253 end_connect(); 2251 end_connect();
2254 } 2252 }
2255 } 2253 }
2256} 2254}
2257void KServerSocket::end_connect() 2255void KServerSocket::end_connect()
2258{ 2256{
2259 delete mSyncActionDialog; 2257 delete mSyncActionDialog;
2260 mSyncActionDialog = 0; 2258 mSyncActionDialog = 0;
2261} 2259}
2262void KServerSocket::send_file() 2260void KServerSocket::send_file()
2263{ 2261{
2264 //qDebug("MainWindow::sendFile(QSocket* s) "); 2262 //qDebug("MainWindow::sendFile(QSocket* s) ");
2265 if ( mSyncActionDialog ) 2263 if ( mSyncActionDialog )
2266 delete mSyncActionDialog; 2264 delete mSyncActionDialog;
2267 mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); 2265 mSyncActionDialog = new QDialog ( 0, "input-dialog", true );
2268 mSyncActionDialog->setCaption(i18n("Received sync request")); 2266 mSyncActionDialog->setCaption(i18n("Received sync request"));
2269 QLabel* label = new QLabel( i18n("Synchronizing...\nDo not use this application!\n\nIf syncing fails you can close this dialog."), mSyncActionDialog ); 2267 QLabel* label = new QLabel( i18n("Synchronizing...\nDo not use this application!\n\nIf syncing fails you can close this dialog."), mSyncActionDialog );
2270 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); 2268 QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog );
2271 lay->addWidget( label); 2269 lay->addWidget( label);
2272 lay->setMargin(7); 2270 lay->setMargin(7);
2273 lay->setSpacing(7); 2271 lay->setSpacing(7);
2274 mSyncActionDialog->setFixedSize( 230, 120); 2272 mSyncActionDialog->setFixedSize( 230, 120);
2275 mSyncActionDialog->show(); 2273 mSyncActionDialog->show();
2276 qDebug("KSS::saving ... "); 2274 qDebug("KSS::saving ... ");
2277 emit saveFile(); 2275 emit saveFile();
2278 qApp->processEvents(); 2276 qApp->processEvents();
2279 QString fileName = mFileName; 2277 QString fileName = mFileName;
2280 QFile file( fileName ); 2278 QFile file( fileName );
2281 if (!file.open( IO_ReadOnly ) ) { 2279 if (!file.open( IO_ReadOnly ) ) {
2282 delete mSyncActionDialog; 2280 delete mSyncActionDialog;
2283 mSyncActionDialog = 0; 2281 mSyncActionDialog = 0;
2284 qDebug("KSS::error open file "); 2282 qDebug("KSS::error open file ");
2285 mSocket->close(); 2283 mSocket->close();
2286 if ( mSocket->state() == QSocket::Idle ) 2284 if ( mSocket->state() == QSocket::Idle )
2287 QTimer::singleShot( 10, this , SLOT ( discardClient())); 2285 QTimer::singleShot( 10, this , SLOT ( discardClient()));
2288 return ; 2286 return ;
2289 2287
2290 } 2288 }
2291 mSyncActionDialog->setCaption( i18n("Sending file...") ); 2289 mSyncActionDialog->setCaption( i18n("Sending file...") );
2292 QTextStream ts( &file ); 2290 QTextStream ts( &file );
2293 ts.setCodec( QTextCodec::codecForName("utf8") ); 2291 ts.setCodec( QTextCodec::codecForName("utf8") );
2294 QTextStream os( mSocket ); 2292 QTextStream os( mSocket );
2295 os.setCodec( QTextCodec::codecForName("utf8") ); 2293 os.setCodec( QTextCodec::codecForName("utf8") );
2296 //os.setEncoding( QTextStream::UnicodeUTF8 ); 2294 //os.setEncoding( QTextStream::UnicodeUTF8 );
2297 while ( ! ts.atEnd() ) { 2295 while ( ! ts.atEnd() ) {
2298 os << ts.readLine() << "\n"; 2296 os << ts.readLine() << "\n";
2299 } 2297 }
2300 //os << ts.read(); 2298 //os << ts.read();
2301 file.close(); 2299 file.close();
2302 mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); 2300 mSyncActionDialog->setCaption( i18n("Waiting for synced file...") );
2303 mSocket->close(); 2301 mSocket->close();
2304 if ( mSocket->state() == QSocket::Idle ) 2302 if ( mSocket->state() == QSocket::Idle )
2305 QTimer::singleShot( 10, this , SLOT ( discardClient())); 2303 QTimer::singleShot( 10, this , SLOT ( discardClient()));
2306} 2304}
2307void KServerSocket::get_file() 2305void KServerSocket::get_file()
2308{ 2306{
2309 mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); 2307 mSyncActionDialog->setCaption( i18n("Receiving synced file...") );
2310 2308
2311 piTime.start(); 2309 piTime.start();
2312 piFileString = ""; 2310 piFileString = "";
2313 QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); 2311 QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) ));
2314} 2312}
2315 2313
2316 2314
2317void KServerSocket::readBackFileFromSocket() 2315void KServerSocket::readBackFileFromSocket()
2318{ 2316{
2319 //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); 2317 //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ());
2320 while ( mSocket->canReadLine () ) { 2318 while ( mSocket->canReadLine () ) {
2321 piTime.restart(); 2319 piTime.restart();
2322 QString line = mSocket->readLine (); 2320 QString line = mSocket->readLine ();
2323 piFileString += line; 2321 piFileString += line;
2324 //qDebug("readline: %s ", line.latin1()); 2322 //qDebug("readline: %s ", line.latin1());
2325 mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); 2323 mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) );
2326 2324
2327 } 2325 }
2328 if ( piTime.elapsed () < 3000 ) { 2326 if ( piTime.elapsed () < 3000 ) {
2329 // wait for more 2327 // wait for more
2330 //qDebug("waitformore "); 2328 //qDebug("waitformore ");
2331 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); 2329 QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) ));
2332 return; 2330 return;
2333 } 2331 }
2334 QString fileName = mFileName; 2332 QString fileName = mFileName;
2335 QFile file ( fileName ); 2333 QFile file ( fileName );
2336 if (!file.open( IO_WriteOnly ) ) { 2334 if (!file.open( IO_WriteOnly ) ) {
2337 delete mSyncActionDialog; 2335 delete mSyncActionDialog;
2338 mSyncActionDialog = 0; 2336 mSyncActionDialog = 0;
2339 qDebug("error open cal file "); 2337 qDebug("error open cal file ");
2340 piFileString = ""; 2338 piFileString = "";
2341 emit file_received( false ); 2339 emit file_received( false );
2342 return ; 2340 return ;
2343 2341
2344 } 2342 }
2345 2343
2346 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 2344 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
2347 QTextStream ts ( &file ); 2345 QTextStream ts ( &file );
2348 ts.setCodec( QTextCodec::codecForName("utf8") ); 2346 ts.setCodec( QTextCodec::codecForName("utf8") );
2349 mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); 2347 mSyncActionDialog->setCaption( i18n("Writing file to disk...") );
2350 ts << piFileString; 2348 ts << piFileString;
2351 mSocket->close(); 2349 mSocket->close();
2352 if ( mSocket->state() == QSocket::Idle ) 2350 if ( mSocket->state() == QSocket::Idle )
2353 QTimer::singleShot( 10, this , SLOT ( discardClient())); 2351 QTimer::singleShot( 10, this , SLOT ( discardClient()));
2354 file.close(); 2352 file.close();
2355 delete mSyncActionDialog; 2353 delete mSyncActionDialog;
2356 mSyncActionDialog = 0; 2354 mSyncActionDialog = 0;
2357 piFileString = ""; 2355 piFileString = "";
2358 emit file_received( true ); 2356 emit file_received( true );
2359 2357
2360} 2358}
2361 2359
2362KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name ) 2360KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name )
2363{ 2361{
2364 mPassWord = password; 2362 mPassWord = password;
2365 mSocket = 0; 2363 mSocket = 0;
2366 mPort = port; 2364 mPort = port;
2367 mHost = host; 2365 mHost = host;
2368 2366
2369 mRetVal = quiet; 2367 mRetVal = quiet;
2370 mTimerSocket = new QTimer ( this ); 2368 mTimerSocket = new QTimer ( this );
2371 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) ); 2369 connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) );
2372} 2370}
2373void KCommandSocket::readFile( QString fn ) 2371void KCommandSocket::readFile( QString fn )
2374{ 2372{
2375 if ( !mSocket ) { 2373 if ( !mSocket ) {
2376 mSocket = new QSocket( this ); 2374 mSocket = new QSocket( this );
2377 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); 2375 connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) );
2378 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 2376 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
2379 } 2377 }
2380 mFileString = ""; 2378 mFileString = "";
2381 mFileName = fn; 2379 mFileName = fn;
2382 mFirst = true; 2380 mFirst = true;
2383 mSocket->connectToHost( mHost, mPort ); 2381 mSocket->connectToHost( mHost, mPort );
2384 QTextStream os( mSocket ); 2382 QTextStream os( mSocket );
2385 os.setEncoding( QTextStream::UnicodeUTF8 ); 2383 os.setEncoding( QTextStream::UnicodeUTF8 );
2386 os << "GET " << mPassWord << "\r\n"; 2384 os << "GET " << mPassWord << "\r\n";
2387 mTimerSocket->start( 10000 ); 2385 mTimerSocket->start( 10000 );
2388} 2386}
2389 2387
2390void KCommandSocket::writeFile( QString fileName ) 2388void KCommandSocket::writeFile( QString fileName )
2391{ 2389{
2392 if ( !mSocket ) { 2390 if ( !mSocket ) {
2393 mSocket = new QSocket( this ); 2391 mSocket = new QSocket( this );
2394 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 2392 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
2395 connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); 2393 connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) );
2396 } 2394 }
2397 mFileName = fileName ; 2395 mFileName = fileName ;
2398 mSocket->connectToHost( mHost, mPort ); 2396 mSocket->connectToHost( mHost, mPort );
2399} 2397}
2400void KCommandSocket::writeFileToSocket() 2398void KCommandSocket::writeFileToSocket()
2401{ 2399{
2402 QFile file2( mFileName ); 2400 QFile file2( mFileName );
2403 if (!file2.open( IO_ReadOnly ) ) { 2401 if (!file2.open( IO_ReadOnly ) ) {
2404 mRetVal= errorW; 2402 mRetVal= errorW;
2405 mSocket->close(); 2403 mSocket->close();
2406 if ( mSocket->state() == QSocket::Idle ) 2404 if ( mSocket->state() == QSocket::Idle )
2407 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 2405 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
2408 return ; 2406 return ;
2409 } 2407 }
2410 QTextStream ts2( &file2 ); 2408 QTextStream ts2( &file2 );
2411 ts2.setCodec( QTextCodec::codecForName("utf8") ); 2409 ts2.setCodec( QTextCodec::codecForName("utf8") );
2412 QTextStream os2( mSocket ); 2410 QTextStream os2( mSocket );
2413 os2.setCodec( QTextCodec::codecForName("utf8") ); 2411 os2.setCodec( QTextCodec::codecForName("utf8") );
2414 os2 << "PUT " << mPassWord << "\r\n";; 2412 os2 << "PUT " << mPassWord << "\r\n";;
2415 while ( ! ts2.atEnd() ) { 2413 while ( ! ts2.atEnd() ) {
2416 os2 << ts2.readLine() << "\n"; 2414 os2 << ts2.readLine() << "\n";
2417 } 2415 }
2418 mRetVal= successW; 2416 mRetVal= successW;
2419 file2.close(); 2417 file2.close();
2420 mSocket->close(); 2418 mSocket->close();
2421 if ( mSocket->state() == QSocket::Idle ) 2419 if ( mSocket->state() == QSocket::Idle )
2422 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 2420 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
2423} 2421}
2424void KCommandSocket::sendStop() 2422void KCommandSocket::sendStop()
2425{ 2423{
2426 if ( !mSocket ) { 2424 if ( !mSocket ) {
2427 mSocket = new QSocket( this ); 2425 mSocket = new QSocket( this );
2428 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 2426 connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
2429 } 2427 }
2430 mSocket->connectToHost( mHost, mPort ); 2428 mSocket->connectToHost( mHost, mPort );
2431 QTextStream os2( mSocket ); 2429 QTextStream os2( mSocket );
2432 os2.setCodec( QTextCodec::codecForName("utf8") ); 2430 os2.setCodec( QTextCodec::codecForName("utf8") );
2433 os2 << "STOP\r\n"; 2431 os2 << "STOP\r\n";
2434 mSocket->close(); 2432 mSocket->close();
2435 if ( mSocket->state() == QSocket::Idle ) 2433 if ( mSocket->state() == QSocket::Idle )
2436 QTimer::singleShot( 10, this , SLOT ( deleteSocket())); 2434 QTimer::singleShot( 10, this , SLOT ( deleteSocket()));
2437} 2435}
2438 2436
2439void KCommandSocket::startReadFileFromSocket() 2437void KCommandSocket::startReadFileFromSocket()
2440{ 2438{
2441 if ( ! mFirst ) 2439 if ( ! mFirst )
2442 return; 2440 return;
2443 mFirst = false; 2441 mFirst = false;
2444 mTimerSocket->stop(); 2442 mTimerSocket->stop();
2445 mFileString = ""; 2443 mFileString = "";
2446 mTime.start(); 2444 mTime.start();
2447 QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); 2445 QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) ));
2448 2446
2449} 2447}
2450void KCommandSocket::readFileFromSocket() 2448void KCommandSocket::readFileFromSocket()
2451{ 2449{
2452 //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); 2450 //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ());
2453 while ( mSocket->canReadLine () ) { 2451 while ( mSocket->canReadLine () ) {
2454 mTime.restart(); 2452 mTime.restart();
2455 QString line = mSocket->readLine (); 2453 QString line = mSocket->readLine ();
2456 mFileString += line; 2454 mFileString += line;
2457 //qDebug("readline: %s ", line.latin1()); 2455 //qDebug("readline: %s ", line.latin1());
2458 } 2456 }
2459 if ( mTime.elapsed () < 3000 ) { 2457 if ( mTime.elapsed () < 3000 ) {
2460 // wait for more 2458 // wait for more
2461 //qDebug("waitformore "); 2459 //qDebug("waitformore ");
2462 QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); 2460 QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) ));
2463 return; 2461 return;
2464 } 2462 }
2465 QString fileName = mFileName; 2463 QString fileName = mFileName;
2466 QFile file ( fileName ); 2464 QFile file ( fileName );
2467 if (!file.open( IO_WriteOnly ) ) { 2465 if (!file.open( IO_WriteOnly ) ) {
2468 mFileString = ""; 2466 mFileString = "";
2469 mRetVal = errorR; 2467 mRetVal = errorR;
2470 qDebug("Error open temp calender file for writing: %s",fileName.latin1() ); 2468 qDebug("Error open temp calender file for writing: %s",fileName.latin1() );
2471 deleteSocket(); 2469 deleteSocket();
2472 return ; 2470 return ;
2473 2471
2474 } 2472 }
2475 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); 2473 // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1));
2476 QTextStream ts ( &file ); 2474 QTextStream ts ( &file );
2477 ts.setCodec( QTextCodec::codecForName("utf8") ); 2475 ts.setCodec( QTextCodec::codecForName("utf8") );
2478 ts << mFileString; 2476 ts << mFileString;
2479 file.close(); 2477 file.close();
2480 mFileString = ""; 2478 mFileString = "";
2481 mRetVal = successR; 2479 mRetVal = successR;
2482 mSocket->close(); 2480 mSocket->close();
2483 // if state is not idle, deleteSocket(); is called via 2481 // if state is not idle, deleteSocket(); is called via
2484 // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); 2482 // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) );
2485 if ( mSocket->state() == QSocket::Idle ) 2483 if ( mSocket->state() == QSocket::Idle )
2486 deleteSocket(); 2484 deleteSocket();
2487} 2485}
2488 2486
2489void KCommandSocket::deleteSocket() 2487void KCommandSocket::deleteSocket()
2490{ 2488{
2491 if ( mTimerSocket->isActive () ) { 2489 if ( mTimerSocket->isActive () ) {
2492 mTimerSocket->stop(); 2490 mTimerSocket->stop();
2493 KMessageBox::information( 0, i18n("ERROR:\nConnection to remote host timed out!\nDid you forgot to enable\nsyncing on remote host? ")); 2491 KMessageBox::information( 0, i18n("ERROR:\nConnection to remote host timed out!\nDid you forgot to enable\nsyncing on remote host? "));
2494 mRetVal = errorR; 2492 mRetVal = errorR;
2495 } 2493 }
2496 //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); 2494 //qDebug("KCommandSocket::deleteSocket() %d", mRetVal );
2497 if ( mSocket) 2495 if ( mSocket)
2498 delete mSocket; 2496 delete mSocket;
2499 mSocket = 0; 2497 mSocket = 0;
2500 emit commandFinished( this, mRetVal ); 2498 emit commandFinished( this, mRetVal );
2501} 2499}
2502 2500