summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp4
-rw-r--r--korganizer/koagendaview.cpp37
-rw-r--r--korganizer/koagendaview.h7
-rw-r--r--korganizer/kodialogmanager.cpp7
4 files changed, 51 insertions, 4 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 06454c2..1d5a57e 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,3906 +1,3906 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Requires the Qt and KDE widget libraries, available at no cost at 4 Requires the Qt and KDE widget libraries, available at no cost at
5 http://www.troll.no and http://www.kde.org respectively 5 http://www.troll.no and http://www.kde.org respectively
6 6
7 Copyright (c) 1997, 1998, 1999 7 Copyright (c) 1997, 1998, 1999
8 Preston Brown (preston.brown@yale.edu) 8 Preston Brown (preston.brown@yale.edu)
9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) 9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl)
10 Ian Dawes (iadawes@globalserve.net) 10 Ian Dawes (iadawes@globalserve.net)
11 Laszlo Boloni (boloni@cs.purdue.edu) 11 Laszlo Boloni (boloni@cs.purdue.edu)
12 12
13 Copyright (c) 2000, 2001, 2002 13 Copyright (c) 2000, 2001, 2002
14 Cornelius Schumacher <schumacher@kde.org> 14 Cornelius Schumacher <schumacher@kde.org>
15 15
16 This program is free software; you can redistribute it and/or modify 16 This program is free software; you can redistribute it and/or modify
17 it under the terms of the GNU General Public License as published by 17 it under the terms of the GNU General Public License as published by
18 the Free Software Foundation; either version 2 of the License, or 18 the Free Software Foundation; either version 2 of the License, or
19 (at your option) any later version. 19 (at your option) any later version.
20 20
21 This program is distributed in the hope that it will be useful, 21 This program is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of 22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
24 GNU General Public License for more details. 24 GNU General Public License for more details.
25 25
26 You should have received a copy of the GNU General Public License 26 You should have received a copy of the GNU General Public License
27 along with this program; if not, write to the Free Software 27 along with this program; if not, write to the Free Software
28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29*/ 29*/
30 30
31#include <stdlib.h> 31#include <stdlib.h>
32 32
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qradiobutton.h> 34#include <qradiobutton.h>
35#include <qbuttongroup.h> 35#include <qbuttongroup.h>
36#include <qlayout.h> 36#include <qlayout.h>
37#include <qclipboard.h> 37#include <qclipboard.h>
38#include <qcursor.h> 38#include <qcursor.h>
39#include <qmessagebox.h> 39#include <qmessagebox.h>
40#include <qprogressbar.h> 40#include <qprogressbar.h>
41#include <qmultilineedit.h> 41#include <qmultilineedit.h>
42#include <qtimer.h> 42#include <qtimer.h>
43#include <qwidgetstack.h> 43#include <qwidgetstack.h>
44#include <qptrlist.h> 44#include <qptrlist.h>
45#include <qregexp.h> 45#include <qregexp.h>
46#include <qgroupbox.h> 46#include <qgroupbox.h>
47#include <qfile.h> 47#include <qfile.h>
48#include <qdir.h> 48#include <qdir.h>
49#ifndef KORG_NOSPLITTER 49#ifndef KORG_NOSPLITTER
50#include <qsplitter.h> 50#include <qsplitter.h>
51#endif 51#endif
52 52
53#include <kglobal.h> 53#include <kglobal.h>
54#include <kdebug.h> 54#include <kdebug.h>
55#include <kstandarddirs.h> 55#include <kstandarddirs.h>
56#include <kfiledialog.h> 56#include <kfiledialog.h>
57#include <kmessagebox.h> 57#include <kmessagebox.h>
58#include <knotifyclient.h> 58#include <knotifyclient.h>
59#include <kconfig.h> 59#include <kconfig.h>
60 60
61#include <libkdepim/ksyncprefsdialog.h> 61#include <libkdepim/ksyncprefsdialog.h>
62#include <krun.h> 62#include <krun.h>
63#include <kdirwatch.h> 63#include <kdirwatch.h>
64#include <libkdepim/kdatepicker.h> 64#include <libkdepim/kdatepicker.h>
65#include <libkdepim/ksyncprofile.h> 65#include <libkdepim/ksyncprofile.h>
66#include <libkdepim/kpimglobalprefs.h> 66#include <libkdepim/kpimglobalprefs.h>
67 67
68#include <libkcal/vcaldrag.h> 68#include <libkcal/vcaldrag.h>
69#include <libkcal/icaldrag.h> 69#include <libkcal/icaldrag.h>
70#include <libkcal/icalformat.h> 70#include <libkcal/icalformat.h>
71#include <libkcal/vcalformat.h> 71#include <libkcal/vcalformat.h>
72#include <libkcal/scheduler.h> 72#include <libkcal/scheduler.h>
73#include <libkcal/calendarlocal.h> 73#include <libkcal/calendarlocal.h>
74#include <libkcal/journal.h> 74#include <libkcal/journal.h>
75#include <libkcal/calfilter.h> 75#include <libkcal/calfilter.h>
76#include <libkcal/attendee.h> 76#include <libkcal/attendee.h>
77#include <libkcal/dndfactory.h> 77#include <libkcal/dndfactory.h>
78#include <libkcal/freebusy.h> 78#include <libkcal/freebusy.h>
79#include <libkcal/filestorage.h> 79#include <libkcal/filestorage.h>
80#include <libkcal/calendarresources.h> 80#include <libkcal/calendarresources.h>
81#include <libkcal/qtopiaformat.h> 81#include <libkcal/qtopiaformat.h>
82#include "../kalarmd/alarmdialog.h" 82#include "../kalarmd/alarmdialog.h"
83 83
84#ifndef DESKTOP_VERSION 84#ifndef DESKTOP_VERSION
85#include <libkcal/sharpformat.h> 85#include <libkcal/sharpformat.h>
86#include <externalapphandler.h> 86#include <externalapphandler.h>
87#endif 87#endif
88#include <libkcal/phoneformat.h> 88#include <libkcal/phoneformat.h>
89#ifndef KORG_NOMAIL 89#ifndef KORG_NOMAIL
90#include "komailclient.h" 90#include "komailclient.h"
91#endif 91#endif
92#ifndef KORG_NOPRINTER 92#ifndef KORG_NOPRINTER
93#include "calprinter.h" 93#include "calprinter.h"
94#endif 94#endif
95#ifndef KORG_NOPLUGINS 95#ifndef KORG_NOPLUGINS
96#include "kocore.h" 96#include "kocore.h"
97#endif 97#endif
98#include "koeventeditor.h" 98#include "koeventeditor.h"
99#include "kotodoeditor.h" 99#include "kotodoeditor.h"
100#include "koprefs.h" 100#include "koprefs.h"
101#include "koeventviewerdialog.h" 101#include "koeventviewerdialog.h"
102#include "publishdialog.h" 102#include "publishdialog.h"
103#include "kofilterview.h" 103#include "kofilterview.h"
104#include "koglobals.h" 104#include "koglobals.h"
105#include "koviewmanager.h" 105#include "koviewmanager.h"
106#include "koagendaview.h" 106#include "koagendaview.h"
107#include "kodialogmanager.h" 107#include "kodialogmanager.h"
108#include "outgoingdialog.h" 108#include "outgoingdialog.h"
109#include "incomingdialog.h" 109#include "incomingdialog.h"
110#include "statusdialog.h" 110#include "statusdialog.h"
111#include "kdatenavigator.h" 111#include "kdatenavigator.h"
112#include "kotodoview.h" 112#include "kotodoview.h"
113#include "datenavigator.h" 113#include "datenavigator.h"
114#include "resourceview.h" 114#include "resourceview.h"
115#include "navigatorbar.h" 115#include "navigatorbar.h"
116#include "searchdialog.h" 116#include "searchdialog.h"
117#include "mainwindow.h" 117#include "mainwindow.h"
118 118
119#include "calendarview.h" 119#include "calendarview.h"
120#ifndef DESKTOP_VERSION 120#ifndef DESKTOP_VERSION
121#include <qtopia/alarmserver.h> 121#include <qtopia/alarmserver.h>
122#endif 122#endif
123#ifndef _WIN32_ 123#ifndef _WIN32_
124#include <stdlib.h> 124#include <stdlib.h>
125#include <stdio.h> 125#include <stdio.h>
126#include <unistd.h> 126#include <unistd.h>
127#else 127#else
128#include <qprocess.h> 128#include <qprocess.h>
129#endif 129#endif
130 130
131#ifdef DESKTOP_VERSION 131#ifdef DESKTOP_VERSION
132#include <kabc/stdaddressbook.h> 132#include <kabc/stdaddressbook.h>
133#endif 133#endif
134using namespace KOrg; 134using namespace KOrg;
135using namespace KCal; 135using namespace KCal;
136extern int globalFlagBlockAgenda; 136extern int globalFlagBlockAgenda;
137extern int globalFlagBlockStartup; 137extern int globalFlagBlockStartup;
138 138
139 139
140 140
141class KOBeamPrefs : public QDialog 141class KOBeamPrefs : public QDialog
142{ 142{
143 public: 143 public:
144 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : 144 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) :
145 QDialog( parent, name, true ) 145 QDialog( parent, name, true )
146 { 146 {
147 setCaption( i18n("Beam Options") ); 147 setCaption( i18n("Beam Options") );
148 QVBoxLayout* lay = new QVBoxLayout( this ); 148 QVBoxLayout* lay = new QVBoxLayout( this );
149 lay->setSpacing( 3 ); 149 lay->setSpacing( 3 );
150 lay->setMargin( 3 ); 150 lay->setMargin( 3 );
151 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); 151 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this );
152 lay->addWidget( format ); 152 lay->addWidget( format );
153 format->setExclusive ( true ) ; 153 format->setExclusive ( true ) ;
154 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); 154 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this );
155 lay->addWidget( time ); time->setExclusive ( true ) ; 155 lay->addWidget( time ); time->setExclusive ( true ) ;
156 vcal = new QRadioButton(" vCalendar ", format ); 156 vcal = new QRadioButton(" vCalendar ", format );
157 ical = new QRadioButton(" iCalendar ", format ); 157 ical = new QRadioButton(" iCalendar ", format );
158 vcal->setChecked( true ); 158 vcal->setChecked( true );
159 tz = new QRadioButton(i18n(" With timezone "), time ); 159 tz = new QRadioButton(i18n(" With timezone "), time );
160 local = new QRadioButton(i18n(" Local time "), time ); 160 local = new QRadioButton(i18n(" Local time "), time );
161 tz->setChecked( true ); 161 tz->setChecked( true );
162 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); 162 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this );
163 lay->addWidget( ok ); 163 lay->addWidget( ok );
164 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 164 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
165 lay->addWidget( cancel ); 165 lay->addWidget( cancel );
166 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 166 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
167 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 167 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
168 resize( 200, 200 ); 168 resize( 200, 200 );
169 } 169 }
170 170
171 bool beamVcal() { return vcal->isChecked(); } 171 bool beamVcal() { return vcal->isChecked(); }
172 bool beamLocal() { return local->isChecked(); } 172 bool beamLocal() { return local->isChecked(); }
173private: 173private:
174 QRadioButton* vcal, *ical, *local, *tz; 174 QRadioButton* vcal, *ical, *local, *tz;
175}; 175};
176class KOCatPrefs : public QDialog 176class KOCatPrefs : public QDialog
177{ 177{
178 public: 178 public:
179 KOCatPrefs( QWidget *parent=0, const char *name=0 ) : 179 KOCatPrefs( QWidget *parent=0, const char *name=0 ) :
180 QDialog( parent, name, true ) 180 QDialog( parent, name, true )
181 { 181 {
182 setCaption( i18n("Manage new Categories") ); 182 setCaption( i18n("Manage new Categories") );
183 QVBoxLayout* lay = new QVBoxLayout( this ); 183 QVBoxLayout* lay = new QVBoxLayout( this );
184 lay->setSpacing( 3 ); 184 lay->setSpacing( 3 );
185 lay->setMargin( 3 ); 185 lay->setMargin( 3 );
186 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); 186 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this );
187 lay->addWidget( lab ); 187 lay->addWidget( lab );
188 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 188 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
189 lay->addWidget( format ); 189 lay->addWidget( format );
190 format->setExclusive ( true ) ; 190 format->setExclusive ( true ) ;
191 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 191 addCatBut = new QRadioButton(i18n("Add to category list"), format );
192 new QRadioButton(i18n("Remove from Events/Todos"), format ); 192 new QRadioButton(i18n("Remove from Events/Todos"), format );
193 addCatBut->setChecked( true ); 193 addCatBut->setChecked( true );
194 QPushButton * ok = new QPushButton( i18n("OK"), this ); 194 QPushButton * ok = new QPushButton( i18n("OK"), this );
195 lay->addWidget( ok ); 195 lay->addWidget( ok );
196 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 196 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
197 lay->addWidget( cancel ); 197 lay->addWidget( cancel );
198 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 198 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
199 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 199 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
200 resize( 200, 200 ); 200 resize( 200, 200 );
201 } 201 }
202 202
203 bool addCat() { return addCatBut->isChecked(); } 203 bool addCat() { return addCatBut->isChecked(); }
204private: 204private:
205 QRadioButton* addCatBut; 205 QRadioButton* addCatBut;
206}; 206};
207 207
208 208
209 209
210CalendarView::CalendarView( CalendarResources *calendar, 210CalendarView::CalendarView( CalendarResources *calendar,
211 QWidget *parent, const char *name ) 211 QWidget *parent, const char *name )
212 : CalendarViewBase( parent, name ), 212 : CalendarViewBase( parent, name ),
213 mCalendar( calendar ), 213 mCalendar( calendar ),
214 mResourceManager( calendar->resourceManager() ) 214 mResourceManager( calendar->resourceManager() )
215{ 215{
216 216
217 mEventEditor = 0; 217 mEventEditor = 0;
218 mTodoEditor = 0; 218 mTodoEditor = 0;
219 219
220 init(); 220 init();
221} 221}
222 222
223CalendarView::CalendarView( Calendar *calendar, 223CalendarView::CalendarView( Calendar *calendar,
224 QWidget *parent, const char *name ) 224 QWidget *parent, const char *name )
225 : CalendarViewBase( parent, name ), 225 : CalendarViewBase( parent, name ),
226 mCalendar( calendar ), 226 mCalendar( calendar ),
227 mResourceManager( 0 ) 227 mResourceManager( 0 )
228{ 228{
229 229
230 mEventEditor = 0; 230 mEventEditor = 0;
231 mTodoEditor = 0; 231 mTodoEditor = 0;
232 init();} 232 init();}
233 233
234void CalendarView::init() 234void CalendarView::init()
235{ 235{
236 mBlockShowDates = false; 236 mBlockShowDates = false;
237 beamDialog = new KOBeamPrefs(); 237 beamDialog = new KOBeamPrefs();
238 mDatePickerMode = 0; 238 mDatePickerMode = 0;
239 mCurrentSyncDevice = ""; 239 mCurrentSyncDevice = "";
240 writeLocale(); 240 writeLocale();
241 mViewManager = new KOViewManager( this ); 241 mViewManager = new KOViewManager( this );
242 mDialogManager = new KODialogManager( this ); 242 mDialogManager = new KODialogManager( this );
243 mEventViewerDialog = 0; 243 mEventViewerDialog = 0;
244 mModified = false; 244 mModified = false;
245 mReadOnly = false; 245 mReadOnly = false;
246 mSelectedIncidence = 0; 246 mSelectedIncidence = 0;
247 mCalPrinter = 0; 247 mCalPrinter = 0;
248 mFilters.setAutoDelete(true); 248 mFilters.setAutoDelete(true);
249 249
250 mCalendar->registerObserver( this ); 250 mCalendar->registerObserver( this );
251 // TODO: Make sure that view is updated, when calendar is changed. 251 // TODO: Make sure that view is updated, when calendar is changed.
252 252
253 mStorage = new FileStorage( mCalendar ); 253 mStorage = new FileStorage( mCalendar );
254 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 254 mNavigator = new DateNavigator( this, "datevav", mViewManager );
255 255
256 QBoxLayout *topLayout = (QBoxLayout*)layout(); 256 QBoxLayout *topLayout = (QBoxLayout*)layout();
257#ifndef KORG_NOSPLITTER 257#ifndef KORG_NOSPLITTER
258 // create the main layout frames. 258 // create the main layout frames.
259 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 259 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
260 topLayout->addWidget(mPanner); 260 topLayout->addWidget(mPanner);
261 261
262 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 262 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
263 "CalendarView::LeftFrame"); 263 "CalendarView::LeftFrame");
264 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 264 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
265 265
266 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, 266 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE,
267 "CalendarView::DateNavigator", QDate::currentDate() ); 267 "CalendarView::DateNavigator", QDate::currentDate() );
268 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 268 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
269 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 269 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
270 mTodoList->setNavigator( mNavigator ); 270 mTodoList->setNavigator( mNavigator );
271 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 271 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
272 272
273#ifdef KORG_NORESOURCEVIEW 273#ifdef KORG_NORESOURCEVIEW
274 mResourceView = 0; 274 mResourceView = 0;
275#else 275#else
276 if ( mResourceManager ) { 276 if ( mResourceManager ) {
277 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 277 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
278 mResourceView->updateView(); 278 mResourceView->updateView();
279 connect( mResourceView, SIGNAL( resourcesChanged() ), 279 connect( mResourceView, SIGNAL( resourcesChanged() ),
280 SLOT( updateView() ) ); 280 SLOT( updateView() ) );
281 } else { 281 } else {
282 mResourceView = 0; 282 mResourceView = 0;
283 } 283 }
284#endif 284#endif
285 QWidget *rightBox = new QWidget( mPanner ); 285 QWidget *rightBox = new QWidget( mPanner );
286 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 286 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
287 287
288 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 288 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
289 rightLayout->addWidget( mNavigatorBar ); 289 rightLayout->addWidget( mNavigatorBar );
290 290
291 mRightFrame = new QWidgetStack( rightBox ); 291 mRightFrame = new QWidgetStack( rightBox );
292 rightLayout->addWidget( mRightFrame, 1 ); 292 rightLayout->addWidget( mRightFrame, 1 );
293 293
294 mLeftFrame = mLeftSplitter; 294 mLeftFrame = mLeftSplitter;
295#else 295#else
296 QWidget *mainBox = new QWidget( this ); 296 QWidget *mainBox = new QWidget( this );
297 QWidget *leftFrame = new QWidget( mainBox ); 297 QWidget *leftFrame = new QWidget( mainBox );
298 298
299 QBoxLayout * mainBoxLayout; 299 QBoxLayout * mainBoxLayout;
300 QBoxLayout * leftFrameLayout; 300 QBoxLayout * leftFrameLayout;
301 if ( KOPrefs::instance()->mVerticalScreen ) { 301 if ( KOPrefs::instance()->mVerticalScreen ) {
302 mainBoxLayout = new QVBoxLayout(mainBox); 302 mainBoxLayout = new QVBoxLayout(mainBox);
303 leftFrameLayout = new QHBoxLayout(leftFrame ); 303 leftFrameLayout = new QHBoxLayout(leftFrame );
304 } else { 304 } else {
305 mainBoxLayout = new QHBoxLayout(mainBox); 305 mainBoxLayout = new QHBoxLayout(mainBox);
306 leftFrameLayout = new QVBoxLayout(leftFrame ); 306 leftFrameLayout = new QVBoxLayout(leftFrame );
307 } 307 }
308 topLayout->addWidget( mainBox ); 308 topLayout->addWidget( mainBox );
309 mainBoxLayout->addWidget (leftFrame); 309 mainBoxLayout->addWidget (leftFrame);
310 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, 310 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE,
311 "CalendarView::DateNavigator", QDate::currentDate()); 311 "CalendarView::DateNavigator", QDate::currentDate());
312 // mDateNavigator->blockSignals( true ); 312 // mDateNavigator->blockSignals( true );
313 leftFrameLayout->addWidget( mDateNavigator ); 313 leftFrameLayout->addWidget( mDateNavigator );
314 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); 314 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView");
315 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall"); 315 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall");
316 mTodoList->setNavigator( mNavigator ); 316 mTodoList->setNavigator( mNavigator );
317 317
318 if ( QApplication::desktop()->width() < 480 ) { 318 if ( QApplication::desktop()->width() < 480 ) {
319 leftFrameLayout->addWidget(mFilterView); 319 leftFrameLayout->addWidget(mFilterView);
320 leftFrameLayout->addWidget(mTodoList, 2 ); 320 leftFrameLayout->addWidget(mTodoList, 2 );
321 321
322 } else { 322 } else {
323 leftFrameLayout->addWidget(mTodoList,2 ); 323 leftFrameLayout->addWidget(mTodoList,2 );
324 leftFrameLayout->addWidget(mFilterView ); 324 leftFrameLayout->addWidget(mFilterView );
325 } 325 }
326 mFilterView->hide(); 326 mFilterView->hide();
327 QWidget *rightBox = new QWidget( mainBox ); 327 QWidget *rightBox = new QWidget( mainBox );
328 mainBoxLayout->addWidget ( rightBox, 10 ); 328 mainBoxLayout->addWidget ( rightBox, 10 );
329 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 329 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
330 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 330 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
331 mRightFrame = new QWidgetStack( rightBox ); 331 mRightFrame = new QWidgetStack( rightBox );
332 rightLayout->addWidget( mNavigatorBar ); 332 rightLayout->addWidget( mNavigatorBar );
333 rightLayout->addWidget( mRightFrame, 10 ); 333 rightLayout->addWidget( mRightFrame, 10 );
334 334
335 mLeftFrame = leftFrame; 335 mLeftFrame = leftFrame;
336 if ( KOPrefs::instance()->mVerticalScreen ) { 336 if ( KOPrefs::instance()->mVerticalScreen ) {
337 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 337 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
338 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 338 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
339 } else { 339 } else {
340 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 340 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
341 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 341 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
342 } 342 }
343 if ( !KOPrefs::instance()->mShowDateNavigator) 343 if ( !KOPrefs::instance()->mShowDateNavigator)
344 mDateNavigator->hide(); 344 mDateNavigator->hide();
345 //qDebug("Calendarview Size %d %d ", width(), height()); 345 //qDebug("Calendarview Size %d %d ", width(), height());
346#endif 346#endif
347 347
348 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 348 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
349 SLOT( showDates( const KCal::DateList & ) ) ); 349 SLOT( showDates( const KCal::DateList & ) ) );
350 350
351 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 351 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
352 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 352 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
353 connect( mNavigatorBar, SIGNAL( goPrevYear() ), 353 connect( mNavigatorBar, SIGNAL( goPrevYear() ),
354 mNavigator, SLOT( selectPreviousYear() ) ); 354 mNavigator, SLOT( selectPreviousYear() ) );
355 connect( mNavigatorBar, SIGNAL( goNextYear() ), 355 connect( mNavigatorBar, SIGNAL( goNextYear() ),
356 mNavigator, SLOT( selectNextYear() ) ); 356 mNavigator, SLOT( selectNextYear() ) );
357 connect( mNavigatorBar, SIGNAL( goPrevMonth() ), 357 connect( mNavigatorBar, SIGNAL( goPrevMonth() ),
358 mNavigator, SLOT( selectPreviousMonth() ) ); 358 mNavigator, SLOT( selectPreviousMonth() ) );
359 connect( mNavigatorBar, SIGNAL( goNextMonth() ), 359 connect( mNavigatorBar, SIGNAL( goNextMonth() ),
360 mNavigator, SLOT( selectNextMonth() ) ); 360 mNavigator, SLOT( selectNextMonth() ) );
361 361
362 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 362 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
363 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); 363 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) );
364 364
365 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 365 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
366 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 366 mNavigator, SLOT( selectWeek( const QDate & ) ) );
367 367
368 connect( mDateNavigator, SIGNAL( goPrevYear() ), 368 connect( mDateNavigator, SIGNAL( goPrevYear() ),
369 mNavigator, SLOT( selectPreviousYear() ) ); 369 mNavigator, SLOT( selectPreviousYear() ) );
370 connect( mDateNavigator, SIGNAL( goNextYear() ), 370 connect( mDateNavigator, SIGNAL( goNextYear() ),
371 mNavigator, SLOT( selectNextYear() ) ); 371 mNavigator, SLOT( selectNextYear() ) );
372 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 372 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
373 mNavigator, SLOT( selectPreviousMonth() ) ); 373 mNavigator, SLOT( selectPreviousMonth() ) );
374 connect( mDateNavigator, SIGNAL( goNextMonth() ), 374 connect( mDateNavigator, SIGNAL( goNextMonth() ),
375 mNavigator, SLOT( selectNextMonth() ) ); 375 mNavigator, SLOT( selectNextMonth() ) );
376 376
377 connect( mDateNavigator, SIGNAL( goPrevious() ), 377 connect( mDateNavigator, SIGNAL( goPrevious() ),
378 mNavigator, SLOT( selectPrevious() ) ); 378 mNavigator, SLOT( selectPrevious() ) );
379 connect( mDateNavigator, SIGNAL( goNext() ), 379 connect( mDateNavigator, SIGNAL( goNext() ),
380 mNavigator, SLOT( selectNext() ) ); 380 mNavigator, SLOT( selectNext() ) );
381 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 381 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
382 mNavigator, SLOT( slotMonthSelect( int ) ) ); 382 mNavigator, SLOT( slotMonthSelect( int ) ) );
383 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), 383 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ),
384 mNavigator, SLOT( slotMonthSelect( int ) ) ); 384 mNavigator, SLOT( slotMonthSelect( int ) ) );
385 385
386 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 386 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
387 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 387 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
388 388
389 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), 389 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ),
390 SLOT( eventAdded( Event *) ) ); 390 SLOT( eventAdded( Event *) ) );
391 391
392 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 392 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
393 393
394 connect( this, SIGNAL( configChanged() ), 394 connect( this, SIGNAL( configChanged() ),
395 mDateNavigator, SLOT( updateConfig() ) ); 395 mDateNavigator, SLOT( updateConfig() ) );
396 396
397 connect( mTodoList, SIGNAL( newTodoSignal() ), 397 connect( mTodoList, SIGNAL( newTodoSignal() ),
398 SLOT( newTodo() ) ); 398 SLOT( newTodo() ) );
399 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 399 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
400 SLOT( newSubTodo( Todo * ) ) ); 400 SLOT( newSubTodo( Todo * ) ) );
401 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 401 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
402 SLOT( editTodo( Todo * ) ) ); 402 SLOT( editTodo( Todo * ) ) );
403 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 403 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
404 SLOT( showTodo( Todo *) ) ); 404 SLOT( showTodo( Todo *) ) );
405 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 405 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
406 SLOT( deleteTodo( Todo *) ) ); 406 SLOT( deleteTodo( Todo *) ) );
407 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 407 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
408 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 408 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
409 SLOT( purgeCompleted() ) ); 409 SLOT( purgeCompleted() ) );
410 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 410 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
411 SIGNAL( todoModified( Todo *, int ) ) ); 411 SIGNAL( todoModified( Todo *, int ) ) );
412 412
413 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 413 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
414 this, SLOT ( cloneIncidence( Incidence * ) ) ); 414 this, SLOT ( cloneIncidence( Incidence * ) ) );
415 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 415 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
416 this, SLOT (cancelIncidence( Incidence * ) ) ); 416 this, SLOT (cancelIncidence( Incidence * ) ) );
417 417
418 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 418 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
419 this, SLOT ( moveIncidence( Incidence * ) ) ); 419 this, SLOT ( moveIncidence( Incidence * ) ) );
420 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 420 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
421 this, SLOT ( beamIncidence( Incidence * ) ) ); 421 this, SLOT ( beamIncidence( Incidence * ) ) );
422 422
423 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 423 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
424 this, SLOT ( todo_unsub( Todo * ) ) ); 424 this, SLOT ( todo_unsub( Todo * ) ) );
425 425
426 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 426 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
427 this, SLOT ( todo_resub( Todo *,Todo * ) ) ); 427 this, SLOT ( todo_resub( Todo *,Todo * ) ) );
428 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 428 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
429 SLOT( updateTodo( Todo *, int ) ) ); 429 SLOT( updateTodo( Todo *, int ) ) );
430 connect( this, SIGNAL( todoModified( Todo *, int )), this, 430 connect( this, SIGNAL( todoModified( Todo *, int )), this,
431 SLOT( changeTodoDisplay( Todo *, int ) ) ); 431 SLOT( changeTodoDisplay( Todo *, int ) ) );
432 432
433 433
434 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 434 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
435 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 435 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
436 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 436 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
437 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 437 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
438 438
439 439
440 440
441 441
442 442
443 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 443 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
444 SLOT(checkClipboard())); 444 SLOT(checkClipboard()));
445 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 445 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
446 SLOT( processTodoListSelection( Incidence * ) ) ); 446 SLOT( processTodoListSelection( Incidence * ) ) );
447 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 447 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
448 448
449 // kdDebug() << "CalendarView::CalendarView() done" << endl; 449 // kdDebug() << "CalendarView::CalendarView() done" << endl;
450 450
451 mDateFrame = new QVBox(0,0,WType_Popup); 451 mDateFrame = new QVBox(0,0,WType_Popup);
452 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 452 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
453 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 453 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
454 mDateFrame->setLineWidth(3); 454 mDateFrame->setLineWidth(3);
455 mDateFrame->hide(); 455 mDateFrame->hide();
456 mDateFrame->setCaption( i18n( "Pick a date to display")); 456 mDateFrame->setCaption( i18n( "Pick a date to display"));
457 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 457 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
458 458
459 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 459 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
460 460
461 mEventEditor = mDialogManager->getEventEditor(); 461 mEventEditor = mDialogManager->getEventEditor();
462 mTodoEditor = mDialogManager->getTodoEditor(); 462 mTodoEditor = mDialogManager->getTodoEditor();
463 463
464 mFlagEditDescription = false; 464 mFlagEditDescription = false;
465 465
466 mSuspendTimer = new QTimer( this ); 466 mSuspendTimer = new QTimer( this );
467 mAlarmTimer = new QTimer( this ); 467 mAlarmTimer = new QTimer( this );
468 mRecheckAlarmTimer = new QTimer( this ); 468 mRecheckAlarmTimer = new QTimer( this );
469 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 469 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
470 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 470 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
471 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 471 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
472 mAlarmDialog = new AlarmDialog( this ); 472 mAlarmDialog = new AlarmDialog( this );
473 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 473 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
474 mAlarmDialog->setServerNotification( false ); 474 mAlarmDialog->setServerNotification( false );
475 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 475 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
476 476
477 477
478#ifndef DESKTOP_VERSION 478#ifndef DESKTOP_VERSION
479//US listen for arriving address resultsets 479//US listen for arriving address resultsets
480 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), 480 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)),
481 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 481 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
482#endif 482#endif
483 483
484} 484}
485 485
486 486
487CalendarView::~CalendarView() 487CalendarView::~CalendarView()
488{ 488{
489 // kdDebug() << "~CalendarView()" << endl; 489 // kdDebug() << "~CalendarView()" << endl;
490 //qDebug("CalendarView::~CalendarView() "); 490 //qDebug("CalendarView::~CalendarView() ");
491 delete mDialogManager; 491 delete mDialogManager;
492 delete mViewManager; 492 delete mViewManager;
493 delete mStorage; 493 delete mStorage;
494 delete mDateFrame ; 494 delete mDateFrame ;
495 delete beamDialog; 495 delete beamDialog;
496 //kdDebug() << "~CalendarView() done" << endl; 496 //kdDebug() << "~CalendarView() done" << endl;
497} 497}
498 498
499void CalendarView::showDay( QDate d ) 499void CalendarView::showDay( QDate d )
500{ 500{
501 dateNavigator()->blockSignals( true ); 501 dateNavigator()->blockSignals( true );
502 dateNavigator()->selectDate( d ); 502 dateNavigator()->selectDate( d );
503 dateNavigator()->blockSignals( false ); 503 dateNavigator()->blockSignals( false );
504 mViewManager->showDayView(); 504 mViewManager->showDayView();
505 //dateNavigator()->selectDate( d ); 505 //dateNavigator()->selectDate( d );
506} 506}
507void CalendarView::timerAlarm() 507void CalendarView::timerAlarm()
508{ 508{
509 //qDebug("CalendarView::timerAlarm() "); 509 //qDebug("CalendarView::timerAlarm() ");
510 computeAlarm(mAlarmNotification ); 510 computeAlarm(mAlarmNotification );
511} 511}
512 512
513void CalendarView::suspendAlarm() 513void CalendarView::suspendAlarm()
514{ 514{
515 //qDebug(" CalendarView::suspendAlarm() "); 515 //qDebug(" CalendarView::suspendAlarm() ");
516 computeAlarm(mSuspendAlarmNotification ); 516 computeAlarm(mSuspendAlarmNotification );
517 517
518} 518}
519 519
520void CalendarView::startAlarm( QString mess , QString filename) 520void CalendarView::startAlarm( QString mess , QString filename)
521{ 521{
522 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 522 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
523 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); 523 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
524 524
525} 525}
526 526
527void CalendarView::checkNextTimerAlarm() 527void CalendarView::checkNextTimerAlarm()
528{ 528{
529 mCalendar->checkAlarmForIncidence( 0, true ); 529 mCalendar->checkAlarmForIncidence( 0, true );
530} 530}
531 531
532void CalendarView::computeAlarm( QString msg ) 532void CalendarView::computeAlarm( QString msg )
533{ 533{
534 534
535 QString mess = msg; 535 QString mess = msg;
536 QString mAlarmMessage = mess.mid( 9 ); 536 QString mAlarmMessage = mess.mid( 9 );
537 QString filename = MainWindow::resourcePath(); 537 QString filename = MainWindow::resourcePath();
538 filename += "koalarm.wav"; 538 filename += "koalarm.wav";
539 QString tempfilename; 539 QString tempfilename;
540 if ( mess.left( 13 ) == "suspend_alarm") { 540 if ( mess.left( 13 ) == "suspend_alarm") {
541 bool error = false; 541 bool error = false;
542 int len = mess.mid( 13 ).find("+++"); 542 int len = mess.mid( 13 ).find("+++");
543 if ( len < 2 ) 543 if ( len < 2 )
544 error = true; 544 error = true;
545 else { 545 else {
546 tempfilename = mess.mid( 13, len ); 546 tempfilename = mess.mid( 13, len );
547 if ( !QFile::exists( tempfilename ) ) 547 if ( !QFile::exists( tempfilename ) )
548 error = true; 548 error = true;
549 } 549 }
550 if ( ! error ) { 550 if ( ! error ) {
551 filename = tempfilename; 551 filename = tempfilename;
552 } 552 }
553 mAlarmMessage = mess.mid( 13+len+3 ); 553 mAlarmMessage = mess.mid( 13+len+3 );
554 //qDebug("suspend file %s ",tempfilename.latin1() ); 554 //qDebug("suspend file %s ",tempfilename.latin1() );
555 startAlarm( mAlarmMessage, filename); 555 startAlarm( mAlarmMessage, filename);
556 return; 556 return;
557 } 557 }
558 if ( mess.left( 11 ) == "timer_alarm") { 558 if ( mess.left( 11 ) == "timer_alarm") {
559 //mTimerTime = 0; 559 //mTimerTime = 0;
560 startAlarm( mess.mid( 11 ), filename ); 560 startAlarm( mess.mid( 11 ), filename );
561 return; 561 return;
562 } 562 }
563 if ( mess.left( 10 ) == "proc_alarm") { 563 if ( mess.left( 10 ) == "proc_alarm") {
564 bool error = false; 564 bool error = false;
565 int len = mess.mid( 10 ).find("+++"); 565 int len = mess.mid( 10 ).find("+++");
566 if ( len < 2 ) 566 if ( len < 2 )
567 error = true; 567 error = true;
568 else { 568 else {
569 tempfilename = mess.mid( 10, len ); 569 tempfilename = mess.mid( 10, len );
570 if ( !QFile::exists( tempfilename ) ) 570 if ( !QFile::exists( tempfilename ) )
571 error = true; 571 error = true;
572 } 572 }
573 if ( error ) { 573 if ( error ) {
574 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 574 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
575 mAlarmMessage += mess.mid( 10+len+3+9 ); 575 mAlarmMessage += mess.mid( 10+len+3+9 );
576 } else { 576 } else {
577 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 577 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
578 //qDebug("-----system command %s ",tempfilename.latin1() ); 578 //qDebug("-----system command %s ",tempfilename.latin1() );
579#ifndef _WIN32_ 579#ifndef _WIN32_
580 if ( vfork () == 0 ) { 580 if ( vfork () == 0 ) {
581 execl ( tempfilename.latin1(), 0 ); 581 execl ( tempfilename.latin1(), 0 );
582 return; 582 return;
583 } 583 }
584#else 584#else
585 QProcess* p = new QProcess(); 585 QProcess* p = new QProcess();
586 p->addArgument( tempfilename.latin1() ); 586 p->addArgument( tempfilename.latin1() );
587 p->start(); 587 p->start();
588 return; 588 return;
589#endif 589#endif
590 590
591 return; 591 return;
592 } 592 }
593 593
594 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 594 //qDebug("+++++++system command %s ",tempfilename.latin1() );
595 } 595 }
596 if ( mess.left( 11 ) == "audio_alarm") { 596 if ( mess.left( 11 ) == "audio_alarm") {
597 bool error = false; 597 bool error = false;
598 int len = mess.mid( 11 ).find("+++"); 598 int len = mess.mid( 11 ).find("+++");
599 if ( len < 2 ) 599 if ( len < 2 )
600 error = true; 600 error = true;
601 else { 601 else {
602 tempfilename = mess.mid( 11, len ); 602 tempfilename = mess.mid( 11, len );
603 if ( !QFile::exists( tempfilename ) ) 603 if ( !QFile::exists( tempfilename ) )
604 error = true; 604 error = true;
605 } 605 }
606 if ( ! error ) { 606 if ( ! error ) {
607 filename = tempfilename; 607 filename = tempfilename;
608 } 608 }
609 mAlarmMessage = mess.mid( 11+len+3+9 ); 609 mAlarmMessage = mess.mid( 11+len+3+9 );
610 //qDebug("audio file command %s ",tempfilename.latin1() ); 610 //qDebug("audio file command %s ",tempfilename.latin1() );
611 } 611 }
612 if ( mess.left( 9 ) == "cal_alarm") { 612 if ( mess.left( 9 ) == "cal_alarm") {
613 mAlarmMessage = mess.mid( 9 ) ; 613 mAlarmMessage = mess.mid( 9 ) ;
614 } 614 }
615 615
616 startAlarm( mAlarmMessage, filename ); 616 startAlarm( mAlarmMessage, filename );
617 617
618 618
619} 619}
620 620
621void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 621void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
622{ 622{
623 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 623 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
624 624
625 mSuspendAlarmNotification = noti; 625 mSuspendAlarmNotification = noti;
626 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 626 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
627 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 627 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
628 mSuspendTimer->start( ms , true ); 628 mSuspendTimer->start( ms , true );
629 629
630} 630}
631 631
632void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 632void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
633{ 633{
634 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 634 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
635 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 635 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
636#ifndef DESKTOP_VERSION 636#ifndef DESKTOP_VERSION
637 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); 637 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() );
638#endif 638#endif
639 return; 639 return;
640 } 640 }
641 int maxSec; 641 int maxSec;
642 //maxSec = 5; //testing only 642 //maxSec = 5; //testing only
643 maxSec = 86400+3600; // one day+1hour 643 maxSec = 86400+3600; // one day+1hour
644 mAlarmNotification = noti; 644 mAlarmNotification = noti;
645 int sec = QDateTime::currentDateTime().secsTo( qdt ); 645 int sec = QDateTime::currentDateTime().secsTo( qdt );
646 if ( sec > maxSec ) { 646 if ( sec > maxSec ) {
647 mRecheckAlarmTimer->start( maxSec * 1000 ); 647 mRecheckAlarmTimer->start( maxSec * 1000 );
648 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 648 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
649 return; 649 return;
650 } else { 650 } else {
651 mRecheckAlarmTimer->stop(); 651 mRecheckAlarmTimer->stop();
652 } 652 }
653 //qDebug("Alarm timer started with secs: %d ", sec); 653 //qDebug("Alarm timer started with secs: %d ", sec);
654 mAlarmTimer->start( sec *1000 , true ); 654 mAlarmTimer->start( sec *1000 , true );
655 655
656} 656}
657// called by mRecheckAlarmTimer to get next alarm 657// called by mRecheckAlarmTimer to get next alarm
658// we need this, because a QTimer has only a max range of 25 days 658// we need this, because a QTimer has only a max range of 25 days
659void CalendarView::recheckTimerAlarm() 659void CalendarView::recheckTimerAlarm()
660{ 660{
661 mAlarmTimer->stop(); 661 mAlarmTimer->stop();
662 mRecheckAlarmTimer->stop(); 662 mRecheckAlarmTimer->stop();
663 mCalendar->checkAlarmForIncidence( 0, true ); 663 mCalendar->checkAlarmForIncidence( 0, true );
664} 664}
665void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 665void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
666{ 666{
667 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 667 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
668 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 668 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
669#ifndef DESKTOP_VERSION 669#ifndef DESKTOP_VERSION
670 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 670 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
671#endif 671#endif
672 return; 672 return;
673 } 673 }
674 mAlarmTimer->stop(); 674 mAlarmTimer->stop();
675} 675}
676void CalendarView::selectWeekNum ( int num ) 676void CalendarView::selectWeekNum ( int num )
677{ 677{
678 dateNavigator()->blockSignals( true ); 678 dateNavigator()->blockSignals( true );
679 dateNavigator()->selectWeek( num ); 679 dateNavigator()->selectWeek( num );
680 dateNavigator()->blockSignals( false ); 680 dateNavigator()->blockSignals( false );
681 mViewManager->showWeekView(); 681 mViewManager->showWeekView();
682} 682}
683KOViewManager *CalendarView::viewManager() 683KOViewManager *CalendarView::viewManager()
684{ 684{
685 return mViewManager; 685 return mViewManager;
686} 686}
687 687
688KODialogManager *CalendarView::dialogManager() 688KODialogManager *CalendarView::dialogManager()
689{ 689{
690 return mDialogManager; 690 return mDialogManager;
691} 691}
692 692
693QDate CalendarView::startDate() 693QDate CalendarView::startDate()
694{ 694{
695 DateList dates = mNavigator->selectedDates(); 695 DateList dates = mNavigator->selectedDates();
696 696
697 return dates.first(); 697 return dates.first();
698} 698}
699 699
700QDate CalendarView::endDate() 700QDate CalendarView::endDate()
701{ 701{
702 DateList dates = mNavigator->selectedDates(); 702 DateList dates = mNavigator->selectedDates();
703 703
704 return dates.last(); 704 return dates.last();
705} 705}
706 706
707 707
708void CalendarView::createPrinter() 708void CalendarView::createPrinter()
709{ 709{
710#ifndef KORG_NOPRINTER 710#ifndef KORG_NOPRINTER
711 if (!mCalPrinter) { 711 if (!mCalPrinter) {
712 mCalPrinter = new CalPrinter(this, mCalendar); 712 mCalPrinter = new CalPrinter(this, mCalendar);
713 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 713 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
714 } 714 }
715#endif 715#endif
716} 716}
717 717
718 718
719//KOPrefs::instance()->mWriteBackFile 719//KOPrefs::instance()->mWriteBackFile
720//KOPrefs::instance()->mWriteBackExistingOnly 720//KOPrefs::instance()->mWriteBackExistingOnly
721 721
722// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 722// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
723// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 723// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
724// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 724// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
725// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 725// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
726// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 726// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
727// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 727// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
728 728
729int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 729int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
730{ 730{
731 731
732 // 0 equal 732 // 0 equal
733 // 1 take local 733 // 1 take local
734 // 2 take remote 734 // 2 take remote
735 // 3 cancel 735 // 3 cancel
736 QDateTime lastSync = mLastCalendarSync; 736 QDateTime lastSync = mLastCalendarSync;
737 QDateTime localMod = local->lastModified(); 737 QDateTime localMod = local->lastModified();
738 QDateTime remoteMod = remote->lastModified(); 738 QDateTime remoteMod = remote->lastModified();
739 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 739 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
740 bool remCh, locCh; 740 bool remCh, locCh;
741 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 741 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
742 //if ( remCh ) 742 //if ( remCh )
743 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 743 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
744 locCh = ( localMod > mLastCalendarSync ); 744 locCh = ( localMod > mLastCalendarSync );
745 if ( !remCh && ! locCh ) { 745 if ( !remCh && ! locCh ) {
746 //qDebug("both not changed "); 746 //qDebug("both not changed ");
747 lastSync = localMod.addDays(1); 747 lastSync = localMod.addDays(1);
748 if ( mode <= SYNC_PREF_ASK ) 748 if ( mode <= SYNC_PREF_ASK )
749 return 0; 749 return 0;
750 } else { 750 } else {
751 if ( locCh ) { 751 if ( locCh ) {
752 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); 752 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1());
753 lastSync = localMod.addDays( -1 ); 753 lastSync = localMod.addDays( -1 );
754 if ( !remCh ) 754 if ( !remCh )
755 remoteMod = ( lastSync.addDays( -1 ) ); 755 remoteMod = ( lastSync.addDays( -1 ) );
756 } else { 756 } else {
757 //qDebug(" not loc changed "); 757 //qDebug(" not loc changed ");
758 lastSync = localMod.addDays( 1 ); 758 lastSync = localMod.addDays( 1 );
759 if ( remCh ) 759 if ( remCh )
760 remoteMod =( lastSync.addDays( 1 ) ); 760 remoteMod =( lastSync.addDays( 1 ) );
761 761
762 } 762 }
763 } 763 }
764 full = true; 764 full = true;
765 if ( mode < SYNC_PREF_ASK ) 765 if ( mode < SYNC_PREF_ASK )
766 mode = SYNC_PREF_ASK; 766 mode = SYNC_PREF_ASK;
767 } else { 767 } else {
768 if ( localMod == remoteMod ) 768 if ( localMod == remoteMod )
769 // if ( local->revision() == remote->revision() ) 769 // if ( local->revision() == remote->revision() )
770 return 0; 770 return 0;
771 771
772 } 772 }
773 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 773 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
774 774
775 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); 775 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision());
776 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); 776 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() );
777 //full = true; //debug only 777 //full = true; //debug only
778 if ( full ) { 778 if ( full ) {
779 bool equ = false; 779 bool equ = false;
780 if ( local->type() == "Event" ) { 780 if ( local->type() == "Event" ) {
781 equ = (*((Event*) local) == *((Event*) remote)); 781 equ = (*((Event*) local) == *((Event*) remote));
782 } 782 }
783 else if ( local->type() =="Todo" ) 783 else if ( local->type() =="Todo" )
784 equ = (*((Todo*) local) == (*(Todo*) remote)); 784 equ = (*((Todo*) local) == (*(Todo*) remote));
785 else if ( local->type() =="Journal" ) 785 else if ( local->type() =="Journal" )
786 equ = (*((Journal*) local) == *((Journal*) remote)); 786 equ = (*((Journal*) local) == *((Journal*) remote));
787 if ( equ ) { 787 if ( equ ) {
788 //qDebug("equal "); 788 //qDebug("equal ");
789 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 789 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
790 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 790 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
791 } 791 }
792 if ( mode < SYNC_PREF_FORCE_LOCAL ) 792 if ( mode < SYNC_PREF_FORCE_LOCAL )
793 return 0; 793 return 0;
794 794
795 }//else //debug only 795 }//else //debug only
796 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 796 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
797 } 797 }
798 int result; 798 int result;
799 bool localIsNew; 799 bool localIsNew;
800 //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() ); 800 //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() );
801 801
802 if ( full && mode < SYNC_PREF_NEWEST ) 802 if ( full && mode < SYNC_PREF_NEWEST )
803 mode = SYNC_PREF_ASK; 803 mode = SYNC_PREF_ASK;
804 804
805 switch( mode ) { 805 switch( mode ) {
806 case SYNC_PREF_LOCAL: 806 case SYNC_PREF_LOCAL:
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 1; 811 return 1;
812 break; 812 break;
813 case SYNC_PREF_REMOTE: 813 case SYNC_PREF_REMOTE:
814 if ( lastSync > remoteMod ) 814 if ( lastSync > remoteMod )
815 return 1; 815 return 1;
816 if ( lastSync > localMod ) 816 if ( lastSync > localMod )
817 return 2; 817 return 2;
818 return 2; 818 return 2;
819 break; 819 break;
820 case SYNC_PREF_NEWEST: 820 case SYNC_PREF_NEWEST:
821 if ( localMod > remoteMod ) 821 if ( localMod > remoteMod )
822 return 1; 822 return 1;
823 else 823 else
824 return 2; 824 return 2;
825 break; 825 break;
826 case SYNC_PREF_ASK: 826 case SYNC_PREF_ASK:
827 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 827 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
828 if ( lastSync > remoteMod ) 828 if ( lastSync > remoteMod )
829 return 1; 829 return 1;
830 if ( lastSync > localMod ) 830 if ( lastSync > localMod )
831 return 2; 831 return 2;
832 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 832 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
833 localIsNew = localMod >= remoteMod; 833 localIsNew = localMod >= remoteMod;
834 if ( localIsNew ) 834 if ( localIsNew )
835 getEventViewerDialog()->setColorMode( 1 ); 835 getEventViewerDialog()->setColorMode( 1 );
836 else 836 else
837 getEventViewerDialog()->setColorMode( 2 ); 837 getEventViewerDialog()->setColorMode( 2 );
838 getEventViewerDialog()->setIncidence(local); 838 getEventViewerDialog()->setIncidence(local);
839 if ( localIsNew ) 839 if ( localIsNew )
840 getEventViewerDialog()->setColorMode( 2 ); 840 getEventViewerDialog()->setColorMode( 2 );
841 else 841 else
842 getEventViewerDialog()->setColorMode( 1 ); 842 getEventViewerDialog()->setColorMode( 1 );
843 getEventViewerDialog()->addIncidence(remote); 843 getEventViewerDialog()->addIncidence(remote);
844 getEventViewerDialog()->setColorMode( 0 ); 844 getEventViewerDialog()->setColorMode( 0 );
845 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 845 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
846 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 846 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
847 getEventViewerDialog()->showMe(); 847 getEventViewerDialog()->showMe();
848 result = getEventViewerDialog()->executeS( localIsNew ); 848 result = getEventViewerDialog()->executeS( localIsNew );
849 return result; 849 return result;
850 850
851 break; 851 break;
852 case SYNC_PREF_FORCE_LOCAL: 852 case SYNC_PREF_FORCE_LOCAL:
853 return 1; 853 return 1;
854 break; 854 break;
855 case SYNC_PREF_FORCE_REMOTE: 855 case SYNC_PREF_FORCE_REMOTE:
856 return 2; 856 return 2;
857 break; 857 break;
858 858
859 default: 859 default:
860 // SYNC_PREF_TAKE_BOTH not implemented 860 // SYNC_PREF_TAKE_BOTH not implemented
861 break; 861 break;
862 } 862 }
863 return 0; 863 return 0;
864} 864}
865Event* CalendarView::getLastSyncEvent() 865Event* CalendarView::getLastSyncEvent()
866{ 866{
867 Event* lse; 867 Event* lse;
868 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 868 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
869 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 869 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
870 if (!lse) { 870 if (!lse) {
871 lse = new Event(); 871 lse = new Event();
872 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 872 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
873 QString sum = ""; 873 QString sum = "";
874 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 874 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
875 sum = "E: "; 875 sum = "E: ";
876 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 876 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
877 lse->setDtStart( mLastCalendarSync ); 877 lse->setDtStart( mLastCalendarSync );
878 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 878 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
879 lse->setCategories( i18n("SyncEvent") ); 879 lse->setCategories( i18n("SyncEvent") );
880 lse->setReadOnly( true ); 880 lse->setReadOnly( true );
881 mCalendar->addEvent( lse ); 881 mCalendar->addEvent( lse );
882 } 882 }
883 883
884 return lse; 884 return lse;
885 885
886} 886}
887 887
888// we check, if the to delete event has a id for a profile 888// we check, if the to delete event has a id for a profile
889// if yes, we set this id in the profile to delete 889// if yes, we set this id in the profile to delete
890void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 890void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
891{ 891{
892 if ( lastSync.count() == 0 ) { 892 if ( lastSync.count() == 0 ) {
893 //qDebug(" lastSync.count() == 0"); 893 //qDebug(" lastSync.count() == 0");
894 return; 894 return;
895 } 895 }
896 if ( toDelete->type() == "Journal" ) 896 if ( toDelete->type() == "Journal" )
897 return; 897 return;
898 898
899 Event* eve = lastSync.first(); 899 Event* eve = lastSync.first();
900 900
901 while ( eve ) { 901 while ( eve ) {
902 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 902 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
903 if ( !id.isEmpty() ) { 903 if ( !id.isEmpty() ) {
904 QString des = eve->description(); 904 QString des = eve->description();
905 QString pref = "e"; 905 QString pref = "e";
906 if ( toDelete->type() == "Todo" ) 906 if ( toDelete->type() == "Todo" )
907 pref = "t"; 907 pref = "t";
908 des += pref+ id + ","; 908 des += pref+ id + ",";
909 eve->setReadOnly( false ); 909 eve->setReadOnly( false );
910 eve->setDescription( des ); 910 eve->setDescription( des );
911 //qDebug("setdes %s ", des.latin1()); 911 //qDebug("setdes %s ", des.latin1());
912 eve->setReadOnly( true ); 912 eve->setReadOnly( true );
913 } 913 }
914 eve = lastSync.next(); 914 eve = lastSync.next();
915 } 915 }
916 916
917} 917}
918void CalendarView::checkExternalId( Incidence * inc ) 918void CalendarView::checkExternalId( Incidence * inc )
919{ 919{
920 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 920 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
921 checkExternSyncEvent( lastSync, inc ); 921 checkExternSyncEvent( lastSync, inc );
922 922
923} 923}
924bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 924bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
925{ 925{
926 bool syncOK = true; 926 bool syncOK = true;
927 int addedEvent = 0; 927 int addedEvent = 0;
928 int addedEventR = 0; 928 int addedEventR = 0;
929 int deletedEventR = 0; 929 int deletedEventR = 0;
930 int deletedEventL = 0; 930 int deletedEventL = 0;
931 int changedLocal = 0; 931 int changedLocal = 0;
932 int changedRemote = 0; 932 int changedRemote = 0;
933 int filteredIN = 0; 933 int filteredIN = 0;
934 int filteredOUT = 0; 934 int filteredOUT = 0;
935 //QPtrList<Event> el = local->rawEvents(); 935 //QPtrList<Event> el = local->rawEvents();
936 Event* eventR; 936 Event* eventR;
937 QString uid; 937 QString uid;
938 int take; 938 int take;
939 Event* eventL; 939 Event* eventL;
940 Event* eventRSync; 940 Event* eventRSync;
941 Event* eventLSync; 941 Event* eventLSync;
942 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 942 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
943 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 943 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
944 bool fullDateRange = false; 944 bool fullDateRange = false;
945 local->resetTempSyncStat(); 945 local->resetTempSyncStat();
946 mLastCalendarSync = QDateTime::currentDateTime(); 946 mLastCalendarSync = QDateTime::currentDateTime();
947 if ( mSyncManager->syncWithDesktop() ) { 947 if ( mSyncManager->syncWithDesktop() ) {
948 remote->resetPilotStat(1); 948 remote->resetPilotStat(1);
949 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 949 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
950 mLastCalendarSync = KSyncManager::mRequestedSyncEvent; 950 mLastCalendarSync = KSyncManager::mRequestedSyncEvent;
951 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); 951 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() );
952 } else { 952 } else {
953 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 953 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
954 } 954 }
955 } 955 }
956 QDateTime modifiedCalendar = mLastCalendarSync; 956 QDateTime modifiedCalendar = mLastCalendarSync;
957 eventLSync = getLastSyncEvent(); 957 eventLSync = getLastSyncEvent();
958 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 958 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
959 if ( eventR ) { 959 if ( eventR ) {
960 eventRSync = (Event*) eventR->clone(); 960 eventRSync = (Event*) eventR->clone();
961 remote->deleteEvent(eventR ); 961 remote->deleteEvent(eventR );
962 962
963 } else { 963 } else {
964 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { 964 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) {
965 eventRSync = (Event*)eventLSync->clone(); 965 eventRSync = (Event*)eventLSync->clone();
966 } else { 966 } else {
967 fullDateRange = true; 967 fullDateRange = true;
968 eventRSync = new Event(); 968 eventRSync = new Event();
969 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 969 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
970 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 970 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
971 eventRSync->setDtStart( mLastCalendarSync ); 971 eventRSync->setDtStart( mLastCalendarSync );
972 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 972 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
973 eventRSync->setCategories( i18n("SyncEvent") ); 973 eventRSync->setCategories( i18n("SyncEvent") );
974 } 974 }
975 } 975 }
976 if ( eventLSync->dtStart() == mLastCalendarSync ) 976 if ( eventLSync->dtStart() == mLastCalendarSync )
977 fullDateRange = true; 977 fullDateRange = true;
978 978
979 if ( ! fullDateRange ) { 979 if ( ! fullDateRange ) {
980 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 980 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
981 981
982 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 982 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
983 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 983 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
984 fullDateRange = true; 984 fullDateRange = true;
985 } 985 }
986 } 986 }
987 if ( mSyncManager->syncWithDesktop() ) { 987 if ( mSyncManager->syncWithDesktop() ) {
988 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); 988 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync );
989 } 989 }
990 if ( fullDateRange ) 990 if ( fullDateRange )
991 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 991 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
992 else 992 else
993 mLastCalendarSync = eventLSync->dtStart(); 993 mLastCalendarSync = eventLSync->dtStart();
994 // for resyncing if own file has changed 994 // for resyncing if own file has changed
995 if ( mCurrentSyncDevice == "deleteaftersync" ) { 995 if ( mCurrentSyncDevice == "deleteaftersync" ) {
996 mLastCalendarSync = loadedFileVersion; 996 mLastCalendarSync = loadedFileVersion;
997 //qDebug("setting mLastCalendarSync "); 997 //qDebug("setting mLastCalendarSync ");
998 } 998 }
999 //qDebug("*************************** "); 999 //qDebug("*************************** ");
1000 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); 1000 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange);
1001 QPtrList<Incidence> er = remote->rawIncidences(); 1001 QPtrList<Incidence> er = remote->rawIncidences();
1002 Incidence* inR = er.first(); 1002 Incidence* inR = er.first();
1003 Incidence* inL; 1003 Incidence* inL;
1004 QProgressBar bar( er.count(),0 ); 1004 QProgressBar bar( er.count(),0 );
1005 bar.setCaption (i18n("Syncing - close to abort!") ); 1005 bar.setCaption (i18n("Syncing - close to abort!") );
1006 1006
1007 // ************** setting up filter ************* 1007 // ************** setting up filter *************
1008 CalFilter *filterIN = 0; 1008 CalFilter *filterIN = 0;
1009 CalFilter *filterOUT = 0; 1009 CalFilter *filterOUT = 0;
1010 CalFilter *filter = mFilters.first(); 1010 CalFilter *filter = mFilters.first();
1011 while(filter) { 1011 while(filter) {
1012 if ( filter->name() == mSyncManager->mFilterInCal ) 1012 if ( filter->name() == mSyncManager->mFilterInCal )
1013 filterIN = filter; 1013 filterIN = filter;
1014 if ( filter->name() == mSyncManager->mFilterOutCal ) 1014 if ( filter->name() == mSyncManager->mFilterOutCal )
1015 filterOUT = filter; 1015 filterOUT = filter;
1016 filter = mFilters.next(); 1016 filter = mFilters.next();
1017 } 1017 }
1018 int w = 300; 1018 int w = 300;
1019 if ( QApplication::desktop()->width() < 320 ) 1019 if ( QApplication::desktop()->width() < 320 )
1020 w = 220; 1020 w = 220;
1021 int h = bar.sizeHint().height() ; 1021 int h = bar.sizeHint().height() ;
1022 int dw = QApplication::desktop()->width(); 1022 int dw = QApplication::desktop()->width();
1023 int dh = QApplication::desktop()->height(); 1023 int dh = QApplication::desktop()->height();
1024 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1024 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1025 bar.show(); 1025 bar.show();
1026 int modulo = (er.count()/10)+1; 1026 int modulo = (er.count()/10)+1;
1027 int incCounter = 0; 1027 int incCounter = 0;
1028 while ( inR ) { 1028 while ( inR ) {
1029 if ( ! bar.isVisible() ) 1029 if ( ! bar.isVisible() )
1030 return false; 1030 return false;
1031 if ( incCounter % modulo == 0 ) 1031 if ( incCounter % modulo == 0 )
1032 bar.setProgress( incCounter ); 1032 bar.setProgress( incCounter );
1033 ++incCounter; 1033 ++incCounter;
1034 uid = inR->uid(); 1034 uid = inR->uid();
1035 bool skipIncidence = false; 1035 bool skipIncidence = false;
1036 if ( uid.left(15) == QString("last-syncEvent-") ) 1036 if ( uid.left(15) == QString("last-syncEvent-") )
1037 skipIncidence = true; 1037 skipIncidence = true;
1038 QString idS; 1038 QString idS;
1039 qApp->processEvents(); 1039 qApp->processEvents();
1040 if ( !skipIncidence ) { 1040 if ( !skipIncidence ) {
1041 inL = local->incidence( uid ); 1041 inL = local->incidence( uid );
1042 if ( inL ) { // maybe conflict - same uid in both calendars 1042 if ( inL ) { // maybe conflict - same uid in both calendars
1043 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1043 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1044 //qDebug("take %d %s ", take, inL->summary().latin1()); 1044 //qDebug("take %d %s ", take, inL->summary().latin1());
1045 if ( take == 3 ) 1045 if ( take == 3 )
1046 return false; 1046 return false;
1047 if ( take == 1 ) {// take local ********************** 1047 if ( take == 1 ) {// take local **********************
1048 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1048 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1049 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1049 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1050 else 1050 else
1051 idS = inR->IDStr(); 1051 idS = inR->IDStr();
1052 remote->deleteIncidence( inR ); 1052 remote->deleteIncidence( inR );
1053 inR = inL->clone(); 1053 inR = inL->clone();
1054 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1054 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1055 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1055 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1056 inR->setIDStr( idS ); 1056 inR->setIDStr( idS );
1057 remote->addIncidence( inR ); 1057 remote->addIncidence( inR );
1058 if ( mSyncManager->syncWithDesktop() ) 1058 if ( mSyncManager->syncWithDesktop() )
1059 inR->setPilotId( 2 ); 1059 inR->setPilotId( 2 );
1060 ++changedRemote; 1060 ++changedRemote;
1061 } else {// take remote ********************** 1061 } else {// take remote **********************
1062 idS = inL->IDStr(); 1062 idS = inL->IDStr();
1063 int pid = inL->pilotId(); 1063 int pid = inL->pilotId();
1064 local->deleteIncidence( inL ); 1064 local->deleteIncidence( inL );
1065 inL = inR->clone(); 1065 inL = inR->clone();
1066 if ( mSyncManager->syncWithDesktop() ) 1066 if ( mSyncManager->syncWithDesktop() )
1067 inL->setPilotId( pid ); 1067 inL->setPilotId( pid );
1068 inL->setIDStr( idS ); 1068 inL->setIDStr( idS );
1069 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1069 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1070 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1070 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1071 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1071 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1072 } 1072 }
1073 local->addIncidence( inL ); 1073 local->addIncidence( inL );
1074 ++changedLocal; 1074 ++changedLocal;
1075 } 1075 }
1076 } 1076 }
1077 } else { // no conflict ********** add or delete remote 1077 } else { // no conflict ********** add or delete remote
1078 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ 1078 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){
1079 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1079 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1080 QString des = eventLSync->description(); 1080 QString des = eventLSync->description();
1081 QString pref = "e"; 1081 QString pref = "e";
1082 if ( inR->type() == "Todo" ) 1082 if ( inR->type() == "Todo" )
1083 pref = "t"; 1083 pref = "t";
1084 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1084 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1085 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1085 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1086 //remote->deleteIncidence( inR ); 1086 //remote->deleteIncidence( inR );
1087 ++deletedEventR; 1087 ++deletedEventR;
1088 } else { 1088 } else {
1089 inR->setLastModified( modifiedCalendar ); 1089 inR->setLastModified( modifiedCalendar );
1090 inL = inR->clone(); 1090 inL = inR->clone();
1091 inL->setIDStr( ":" ); 1091 inL->setIDStr( ":" );
1092 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1092 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1093 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1093 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1094 local->addIncidence( inL ); 1094 local->addIncidence( inL );
1095 ++addedEvent; 1095 ++addedEvent;
1096 1096
1097 } 1097 }
1098 } else { 1098 } else {
1099 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1099 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1100 inR->setLastModified( modifiedCalendar ); 1100 inR->setLastModified( modifiedCalendar );
1101 inL = inR->clone(); 1101 inL = inR->clone();
1102 inL->setIDStr( ":" ); 1102 inL->setIDStr( ":" );
1103 local->addIncidence( inL ); 1103 local->addIncidence( inL );
1104 ++addedEvent; 1104 ++addedEvent;
1105 1105
1106 } else { 1106 } else {
1107 checkExternSyncEvent(eventRSyncSharp, inR); 1107 checkExternSyncEvent(eventRSyncSharp, inR);
1108 remote->deleteIncidence( inR ); 1108 remote->deleteIncidence( inR );
1109 ++deletedEventR; 1109 ++deletedEventR;
1110 } 1110 }
1111 } 1111 }
1112 } else { 1112 } else {
1113 ++filteredIN; 1113 ++filteredIN;
1114 } 1114 }
1115 } 1115 }
1116 } 1116 }
1117 inR = er.next(); 1117 inR = er.next();
1118 } 1118 }
1119 QPtrList<Incidence> el = local->rawIncidences(); 1119 QPtrList<Incidence> el = local->rawIncidences();
1120 inL = el.first(); 1120 inL = el.first();
1121 modulo = (el.count()/10)+1; 1121 modulo = (el.count()/10)+1;
1122 bar.setCaption (i18n("Add / remove events") ); 1122 bar.setCaption (i18n("Add / remove events") );
1123 bar.setTotalSteps ( el.count() ) ; 1123 bar.setTotalSteps ( el.count() ) ;
1124 bar.show(); 1124 bar.show();
1125 incCounter = 0; 1125 incCounter = 0;
1126 1126
1127 while ( inL ) { 1127 while ( inL ) {
1128 1128
1129 qApp->processEvents(); 1129 qApp->processEvents();
1130 if ( ! bar.isVisible() ) 1130 if ( ! bar.isVisible() )
1131 return false; 1131 return false;
1132 if ( incCounter % modulo == 0 ) 1132 if ( incCounter % modulo == 0 )
1133 bar.setProgress( incCounter ); 1133 bar.setProgress( incCounter );
1134 ++incCounter; 1134 ++incCounter;
1135 uid = inL->uid(); 1135 uid = inL->uid();
1136 bool skipIncidence = false; 1136 bool skipIncidence = false;
1137 if ( uid.left(15) == QString("last-syncEvent-") ) 1137 if ( uid.left(15) == QString("last-syncEvent-") )
1138 skipIncidence = true; 1138 skipIncidence = true;
1139 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) 1139 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
1140 skipIncidence = true; 1140 skipIncidence = true;
1141 if ( !skipIncidence ) { 1141 if ( !skipIncidence ) {
1142 inR = remote->incidence( uid ); 1142 inR = remote->incidence( uid );
1143 if ( ! inR ) { 1143 if ( ! inR ) {
1144 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ 1144 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){
1145 // no conflict ********** add or delete local 1145 // no conflict ********** add or delete local
1146 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1146 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1147 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1147 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1148 checkExternSyncEvent(eventLSyncSharp, inL); 1148 checkExternSyncEvent(eventLSyncSharp, inL);
1149 local->deleteIncidence( inL ); 1149 local->deleteIncidence( inL );
1150 ++deletedEventL; 1150 ++deletedEventL;
1151 } else { 1151 } else {
1152 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1152 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1153 inL->removeID(mCurrentSyncDevice ); 1153 inL->removeID(mCurrentSyncDevice );
1154 ++addedEventR; 1154 ++addedEventR;
1155 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1155 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1156 inL->setLastModified( modifiedCalendar ); 1156 inL->setLastModified( modifiedCalendar );
1157 inR = inL->clone(); 1157 inR = inL->clone();
1158 inR->setIDStr( ":" ); 1158 inR->setIDStr( ":" );
1159 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1159 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1160 remote->addIncidence( inR ); 1160 remote->addIncidence( inR );
1161 } 1161 }
1162 } 1162 }
1163 } else { 1163 } else {
1164 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1164 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1165 checkExternSyncEvent(eventLSyncSharp, inL); 1165 checkExternSyncEvent(eventLSyncSharp, inL);
1166 local->deleteIncidence( inL ); 1166 local->deleteIncidence( inL );
1167 ++deletedEventL; 1167 ++deletedEventL;
1168 } else { 1168 } else {
1169 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1169 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1170 ++addedEventR; 1170 ++addedEventR;
1171 inL->setLastModified( modifiedCalendar ); 1171 inL->setLastModified( modifiedCalendar );
1172 inR = inL->clone(); 1172 inR = inL->clone();
1173 inR->setIDStr( ":" ); 1173 inR->setIDStr( ":" );
1174 remote->addIncidence( inR ); 1174 remote->addIncidence( inR );
1175 } 1175 }
1176 } 1176 }
1177 } 1177 }
1178 } else { 1178 } else {
1179 ++filteredOUT; 1179 ++filteredOUT;
1180 } 1180 }
1181 } 1181 }
1182 } 1182 }
1183 inL = el.next(); 1183 inL = el.next();
1184 } 1184 }
1185 int delFut = 0; 1185 int delFut = 0;
1186 int remRem = 0; 1186 int remRem = 0;
1187 if ( mSyncManager->mWriteBackInFuture ) { 1187 if ( mSyncManager->mWriteBackInFuture ) {
1188 er = remote->rawIncidences(); 1188 er = remote->rawIncidences();
1189 remRem = er.count(); 1189 remRem = er.count();
1190 inR = er.first(); 1190 inR = er.first();
1191 QDateTime dt; 1191 QDateTime dt;
1192 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); 1192 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) );
1193 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); 1193 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 );
1194 while ( inR ) { 1194 while ( inR ) {
1195 if ( inR->type() == "Todo" ) { 1195 if ( inR->type() == "Todo" ) {
1196 Todo * t = (Todo*)inR; 1196 Todo * t = (Todo*)inR;
1197 if ( t->hasDueDate() ) 1197 if ( t->hasDueDate() )
1198 dt = t->dtDue(); 1198 dt = t->dtDue();
1199 else 1199 else
1200 dt = cur.addSecs( 62 ); 1200 dt = cur.addSecs( 62 );
1201 } 1201 }
1202 else if (inR->type() == "Event" ) { 1202 else if (inR->type() == "Event" ) {
1203 bool ok; 1203 bool ok;
1204 dt = inR->getNextOccurence( cur, &ok ); 1204 dt = inR->getNextOccurence( cur, &ok );
1205 if ( !ok ) 1205 if ( !ok )
1206 dt = cur.addSecs( -62 ); 1206 dt = cur.addSecs( -62 );
1207 } 1207 }
1208 else 1208 else
1209 dt = inR->dtStart(); 1209 dt = inR->dtStart();
1210 if ( dt < cur || dt > end ) { 1210 if ( dt < cur || dt > end ) {
1211 remote->deleteIncidence( inR ); 1211 remote->deleteIncidence( inR );
1212 ++delFut; 1212 ++delFut;
1213 } 1213 }
1214 inR = er.next(); 1214 inR = er.next();
1215 } 1215 }
1216 } 1216 }
1217 bar.hide(); 1217 bar.hide();
1218 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1218 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1219 eventLSync->setReadOnly( false ); 1219 eventLSync->setReadOnly( false );
1220 eventLSync->setDtStart( mLastCalendarSync ); 1220 eventLSync->setDtStart( mLastCalendarSync );
1221 eventRSync->setDtStart( mLastCalendarSync ); 1221 eventRSync->setDtStart( mLastCalendarSync );
1222 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1222 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1223 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1223 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1224 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1224 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1225 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1225 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1226 eventLSync->setReadOnly( true ); 1226 eventLSync->setReadOnly( true );
1227 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); 1227 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL );
1228 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... 1228 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal...
1229 remote->addEvent( eventRSync ); 1229 remote->addEvent( eventRSync );
1230 else 1230 else
1231 delete eventRSync; 1231 delete eventRSync;
1232 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); 1232 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() );
1233 QString mes; 1233 QString mes;
1234 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 %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); 1234 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 %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT );
1235 QString delmess; 1235 QString delmess;
1236 if ( delFut ) { 1236 if ( delFut ) {
1237 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); 1237 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut);
1238 mes += delmess; 1238 mes += delmess;
1239 } 1239 }
1240 mes = i18n("Local calendar changed!\n") +mes; 1240 mes = i18n("Local calendar changed!\n") +mes;
1241 mCalendar->checkAlarmForIncidence( 0, true ); 1241 mCalendar->checkAlarmForIncidence( 0, true );
1242 qDebug( mes ); 1242 qDebug( mes );
1243 if ( mSyncManager->mShowSyncSummary ) { 1243 if ( mSyncManager->mShowSyncSummary ) {
1244 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 1244 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
1245 i18n("KO/Pi Synchronization"),i18n("Write back"))) { 1245 i18n("KO/Pi Synchronization"),i18n("Write back"))) {
1246 qDebug("KO: WB cancelled "); 1246 qDebug("KO: WB cancelled ");
1247 return false; 1247 return false;
1248 } 1248 }
1249 } 1249 }
1250 return syncOK; 1250 return syncOK;
1251} 1251}
1252 1252
1253void CalendarView::setSyncDevice( QString s ) 1253void CalendarView::setSyncDevice( QString s )
1254{ 1254{
1255 mCurrentSyncDevice= s; 1255 mCurrentSyncDevice= s;
1256} 1256}
1257void CalendarView::setSyncName( QString s ) 1257void CalendarView::setSyncName( QString s )
1258{ 1258{
1259 mCurrentSyncName= s; 1259 mCurrentSyncName= s;
1260} 1260}
1261bool CalendarView::syncCalendar(QString filename, int mode) 1261bool CalendarView::syncCalendar(QString filename, int mode)
1262{ 1262{
1263 //qDebug("syncCalendar %s ", filename.latin1()); 1263 //qDebug("syncCalendar %s ", filename.latin1());
1264 mGlobalSyncMode = SYNC_MODE_NORMAL; 1264 mGlobalSyncMode = SYNC_MODE_NORMAL;
1265 CalendarLocal* calendar = new CalendarLocal(); 1265 CalendarLocal* calendar = new CalendarLocal();
1266 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1266 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1267 FileStorage* storage = new FileStorage( calendar ); 1267 FileStorage* storage = new FileStorage( calendar );
1268 bool syncOK = false; 1268 bool syncOK = false;
1269 storage->setFileName( filename ); 1269 storage->setFileName( filename );
1270 // qDebug("loading ... "); 1270 // qDebug("loading ... ");
1271 if ( storage->load() ) { 1271 if ( storage->load() ) {
1272 getEventViewerDialog()->setSyncMode( true ); 1272 getEventViewerDialog()->setSyncMode( true );
1273 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1273 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1274 getEventViewerDialog()->setSyncMode( false ); 1274 getEventViewerDialog()->setSyncMode( false );
1275 if ( syncOK ) { 1275 if ( syncOK ) {
1276 if ( mSyncManager->mWriteBackFile ) 1276 if ( mSyncManager->mWriteBackFile )
1277 { 1277 {
1278 storage->setSaveFormat( new ICalFormat() ); 1278 storage->setSaveFormat( new ICalFormat() );
1279 storage->save(); 1279 storage->save();
1280 } 1280 }
1281 } 1281 }
1282 setModified( true ); 1282 setModified( true );
1283 } 1283 }
1284 delete storage; 1284 delete storage;
1285 delete calendar; 1285 delete calendar;
1286 if ( syncOK ) 1286 if ( syncOK )
1287 updateView(); 1287 updateView();
1288 return syncOK; 1288 return syncOK;
1289} 1289}
1290 1290
1291void CalendarView::syncExternal( int mode ) 1291void CalendarView::syncExternal( int mode )
1292{ 1292{
1293 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1293 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1294 1294
1295 qApp->processEvents(); 1295 qApp->processEvents();
1296 CalendarLocal* calendar = new CalendarLocal(); 1296 CalendarLocal* calendar = new CalendarLocal();
1297 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1297 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1298 bool syncOK = false; 1298 bool syncOK = false;
1299 bool loadSuccess = false; 1299 bool loadSuccess = false;
1300 PhoneFormat* phoneFormat = 0; 1300 PhoneFormat* phoneFormat = 0;
1301 emit tempDisableBR(true); 1301 emit tempDisableBR(true);
1302#ifndef DESKTOP_VERSION 1302#ifndef DESKTOP_VERSION
1303 SharpFormat* sharpFormat = 0; 1303 SharpFormat* sharpFormat = 0;
1304 if ( mode == 0 ) { // sharp 1304 if ( mode == 0 ) { // sharp
1305 sharpFormat = new SharpFormat () ; 1305 sharpFormat = new SharpFormat () ;
1306 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1306 loadSuccess = sharpFormat->load( calendar, mCalendar );
1307 1307
1308 } else 1308 } else
1309#endif 1309#endif
1310 if ( mode == 1 ) { // phone 1310 if ( mode == 1 ) { // phone
1311 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1311 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1312 mSyncManager->mPhoneDevice, 1312 mSyncManager->mPhoneDevice,
1313 mSyncManager->mPhoneConnection, 1313 mSyncManager->mPhoneConnection,
1314 mSyncManager->mPhoneModel); 1314 mSyncManager->mPhoneModel);
1315 loadSuccess = phoneFormat->load( calendar,mCalendar); 1315 loadSuccess = phoneFormat->load( calendar,mCalendar);
1316 1316
1317 } else { 1317 } else {
1318 emit tempDisableBR(false); 1318 emit tempDisableBR(false);
1319 return; 1319 return;
1320 } 1320 }
1321 if ( loadSuccess ) { 1321 if ( loadSuccess ) {
1322 getEventViewerDialog()->setSyncMode( true ); 1322 getEventViewerDialog()->setSyncMode( true );
1323 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1323 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1324 getEventViewerDialog()->setSyncMode( false ); 1324 getEventViewerDialog()->setSyncMode( false );
1325 qApp->processEvents(); 1325 qApp->processEvents();
1326 if ( syncOK ) { 1326 if ( syncOK ) {
1327 if ( mSyncManager->mWriteBackFile ) 1327 if ( mSyncManager->mWriteBackFile )
1328 { 1328 {
1329 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1329 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1330 Incidence* inc = iL.first(); 1330 Incidence* inc = iL.first();
1331 if ( phoneFormat ) { 1331 if ( phoneFormat ) {
1332 while ( inc ) { 1332 while ( inc ) {
1333 inc->removeID(mCurrentSyncDevice); 1333 inc->removeID(mCurrentSyncDevice);
1334 inc = iL.next(); 1334 inc = iL.next();
1335 } 1335 }
1336 } 1336 }
1337#ifndef DESKTOP_VERSION 1337#ifndef DESKTOP_VERSION
1338 if ( sharpFormat ) 1338 if ( sharpFormat )
1339 sharpFormat->save(calendar); 1339 sharpFormat->save(calendar);
1340#endif 1340#endif
1341 if ( phoneFormat ) 1341 if ( phoneFormat )
1342 phoneFormat->save(calendar); 1342 phoneFormat->save(calendar);
1343 iL = calendar->rawIncidences(); 1343 iL = calendar->rawIncidences();
1344 inc = iL.first(); 1344 inc = iL.first();
1345 Incidence* loc; 1345 Incidence* loc;
1346 while ( inc ) { 1346 while ( inc ) {
1347 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1347 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1348 loc = mCalendar->incidence(inc->uid() ); 1348 loc = mCalendar->incidence(inc->uid() );
1349 if ( loc ) { 1349 if ( loc ) {
1350 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1350 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1351 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1351 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1352 } 1352 }
1353 } 1353 }
1354 inc = iL.next(); 1354 inc = iL.next();
1355 } 1355 }
1356 Incidence* lse = getLastSyncEvent(); 1356 Incidence* lse = getLastSyncEvent();
1357 if ( lse ) { 1357 if ( lse ) {
1358 lse->setReadOnly( false ); 1358 lse->setReadOnly( false );
1359 lse->setDescription( "" ); 1359 lse->setDescription( "" );
1360 lse->setReadOnly( true ); 1360 lse->setReadOnly( true );
1361 } 1361 }
1362 } 1362 }
1363 } else { 1363 } else {
1364 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 1364 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
1365 } 1365 }
1366 setModified( true ); 1366 setModified( true );
1367 } else { 1367 } else {
1368 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1368 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1369 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1369 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1370 question, i18n("Ok")) ; 1370 question, i18n("Ok")) ;
1371 1371
1372 } 1372 }
1373 delete calendar; 1373 delete calendar;
1374 updateView(); 1374 updateView();
1375 emit tempDisableBR(false); 1375 emit tempDisableBR(false);
1376 return ;//syncOK; 1376 return ;//syncOK;
1377 1377
1378} 1378}
1379 1379
1380bool CalendarView::importBday() 1380bool CalendarView::importBday()
1381{ 1381{
1382#ifndef KORG_NOKABC 1382#ifndef KORG_NOKABC
1383 1383
1384#ifdef DESKTOP_VERSION 1384#ifdef DESKTOP_VERSION
1385 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1385 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1386 KABC::AddressBook::Iterator it; 1386 KABC::AddressBook::Iterator it;
1387 int count = 0; 1387 int count = 0;
1388 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1388 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1389 ++count; 1389 ++count;
1390 } 1390 }
1391 QProgressBar bar(count,0 ); 1391 QProgressBar bar(count,0 );
1392 int w = 300; 1392 int w = 300;
1393 if ( QApplication::desktop()->width() < 320 ) 1393 if ( QApplication::desktop()->width() < 320 )
1394 w = 220; 1394 w = 220;
1395 int h = bar.sizeHint().height() ; 1395 int h = bar.sizeHint().height() ;
1396 int dw = QApplication::desktop()->width(); 1396 int dw = QApplication::desktop()->width();
1397 int dh = QApplication::desktop()->height(); 1397 int dh = QApplication::desktop()->height();
1398 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1398 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1399 bar.show(); 1399 bar.show();
1400 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1400 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1401 qApp->processEvents(); 1401 qApp->processEvents();
1402 count = 0; 1402 count = 0;
1403 int addCount = 0; 1403 int addCount = 0;
1404 KCal::Attendee* a = 0; 1404 KCal::Attendee* a = 0;
1405 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1405 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1406 if ( ! bar.isVisible() ) 1406 if ( ! bar.isVisible() )
1407 return false; 1407 return false;
1408 bar.setProgress( count++ ); 1408 bar.setProgress( count++ );
1409 qApp->processEvents(); 1409 qApp->processEvents();
1410 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1410 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1411 if ( (*it).birthday().date().isValid() ){ 1411 if ( (*it).birthday().date().isValid() ){
1412 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1412 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1413 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1413 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1414 ++addCount; 1414 ++addCount;
1415 } 1415 }
1416 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1416 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1417 if ( anni.isValid() ){ 1417 if ( anni.isValid() ){
1418 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1418 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1419 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1419 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1420 ++addCount; 1420 ++addCount;
1421 } 1421 }
1422 } 1422 }
1423 updateView(); 1423 updateView();
1424 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1424 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1425#else //DESKTOP_VERSION 1425#else //DESKTOP_VERSION
1426 1426
1427 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 1427 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
1428 // the result should now arrive through method insertBirthdays 1428 // the result should now arrive through method insertBirthdays
1429 1429
1430#endif //DESKTOP_VERSION 1430#endif //DESKTOP_VERSION
1431 1431
1432#endif //KORG_NOKABC 1432#endif //KORG_NOKABC
1433 1433
1434 1434
1435 return true; 1435 return true;
1436} 1436}
1437 1437
1438// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI 1438// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
1439void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, 1439void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
1440 const QStringList& anniversaryList, const QStringList& realNameList, 1440 const QStringList& anniversaryList, const QStringList& realNameList,
1441 const QStringList& emailList, const QStringList& assembledNameList, 1441 const QStringList& emailList, const QStringList& assembledNameList,
1442 const QStringList& uidList) 1442 const QStringList& uidList)
1443{ 1443{
1444 //qDebug("KO::CalendarView::insertBirthdays"); 1444 //qDebug("KO::CalendarView::insertBirthdays");
1445 if (uid == this->name()) 1445 if (uid == this->name())
1446 { 1446 {
1447 int count = birthdayList.count(); 1447 int count = birthdayList.count();
1448 int addCount = 0; 1448 int addCount = 0;
1449 KCal::Attendee* a = 0; 1449 KCal::Attendee* a = 0;
1450 1450
1451 //qDebug("CalView 1 %i", count); 1451 //qDebug("CalView 1 %i", count);
1452 1452
1453 QProgressBar bar(count,0 ); 1453 QProgressBar bar(count,0 );
1454 int w = 300; 1454 int w = 300;
1455 if ( QApplication::desktop()->width() < 320 ) 1455 if ( QApplication::desktop()->width() < 320 )
1456 w = 220; 1456 w = 220;
1457 int h = bar.sizeHint().height() ; 1457 int h = bar.sizeHint().height() ;
1458 int dw = QApplication::desktop()->width(); 1458 int dw = QApplication::desktop()->width();
1459 int dh = QApplication::desktop()->height(); 1459 int dh = QApplication::desktop()->height();
1460 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1460 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1461 bar.show(); 1461 bar.show();
1462 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 1462 bar.setCaption (i18n("inserting birthdays - close to abort!") );
1463 qApp->processEvents(); 1463 qApp->processEvents();
1464 1464
1465 QDate birthday; 1465 QDate birthday;
1466 QDate anniversary; 1466 QDate anniversary;
1467 QString realName; 1467 QString realName;
1468 QString email; 1468 QString email;
1469 QString assembledName; 1469 QString assembledName;
1470 QString uid; 1470 QString uid;
1471 bool ok = true; 1471 bool ok = true;
1472 for ( int i = 0; i < count; i++) 1472 for ( int i = 0; i < count; i++)
1473 { 1473 {
1474 if ( ! bar.isVisible() ) 1474 if ( ! bar.isVisible() )
1475 return; 1475 return;
1476 bar.setProgress( i ); 1476 bar.setProgress( i );
1477 qApp->processEvents(); 1477 qApp->processEvents();
1478 1478
1479 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); 1479 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
1480 if (!ok) { 1480 if (!ok) {
1481 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); 1481 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
1482 } 1482 }
1483 1483
1484 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); 1484 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
1485 if (!ok) { 1485 if (!ok) {
1486 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); 1486 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
1487 } 1487 }
1488 realName = realNameList[i]; 1488 realName = realNameList[i];
1489 email = emailList[i]; 1489 email = emailList[i];
1490 assembledName = assembledNameList[i]; 1490 assembledName = assembledNameList[i];
1491 uid = uidList[i]; 1491 uid = uidList[i];
1492 //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); 1492 //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() );
1493 1493
1494 if ( birthday.isValid() ){ 1494 if ( birthday.isValid() ){
1495 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1495 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1496 KCal::Attendee::ReqParticipant,uid) ; 1496 KCal::Attendee::ReqParticipant,uid) ;
1497 if ( addAnniversary( birthday, assembledName, a, true ) ) 1497 if ( addAnniversary( birthday, assembledName, a, true ) )
1498 ++addCount; 1498 ++addCount;
1499 } 1499 }
1500 1500
1501 if ( anniversary.isValid() ){ 1501 if ( anniversary.isValid() ){
1502 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1502 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1503 KCal::Attendee::ReqParticipant,uid) ; 1503 KCal::Attendee::ReqParticipant,uid) ;
1504 if ( addAnniversary( anniversary, assembledName, a, false ) ) 1504 if ( addAnniversary( anniversary, assembledName, a, false ) )
1505 ++addCount; 1505 ++addCount;
1506 } 1506 }
1507 } 1507 }
1508 1508
1509 updateView(); 1509 updateView();
1510 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1510 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1511 1511
1512 } 1512 }
1513 1513
1514} 1514}
1515 1515
1516 1516
1517 1517
1518bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1518bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1519{ 1519{
1520 //qDebug("addAnni "); 1520 //qDebug("addAnni ");
1521 Event * ev = new Event(); 1521 Event * ev = new Event();
1522 if ( a ) { 1522 if ( a ) {
1523 ev->addAttendee( a ); 1523 ev->addAttendee( a );
1524 } 1524 }
1525 QString kind; 1525 QString kind;
1526 if ( birthday ) 1526 if ( birthday )
1527 kind = i18n( "Birthday" ); 1527 kind = i18n( "Birthday" );
1528 else 1528 else
1529 kind = i18n( "Anniversary" ); 1529 kind = i18n( "Anniversary" );
1530 ev->setSummary( name + " - " + kind ); 1530 ev->setSummary( name + " - " + kind );
1531 ev->setOrganizer(a->email()); 1531 ev->setOrganizer(a->email());
1532 ev->setCategories( kind ); 1532 ev->setCategories( kind );
1533 ev->setDtStart( QDateTime(date) ); 1533 ev->setDtStart( QDateTime(date) );
1534 ev->setDtEnd( QDateTime(date) ); 1534 ev->setDtEnd( QDateTime(date) );
1535 ev->setFloats( true ); 1535 ev->setFloats( true );
1536 Recurrence * rec = ev->recurrence(); 1536 Recurrence * rec = ev->recurrence();
1537 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1537 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1538 rec->addYearlyNum( date.month() ); 1538 rec->addYearlyNum( date.month() );
1539 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1539 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1540 delete ev; 1540 delete ev;
1541 return false; 1541 return false;
1542 } 1542 }
1543 return true; 1543 return true;
1544 1544
1545} 1545}
1546bool CalendarView::importQtopia( const QString &categories, 1546bool CalendarView::importQtopia( const QString &categories,
1547 const QString &datebook, 1547 const QString &datebook,
1548 const QString &todolist ) 1548 const QString &todolist )
1549{ 1549{
1550 1550
1551 QtopiaFormat qtopiaFormat; 1551 QtopiaFormat qtopiaFormat;
1552 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1552 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1553 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1553 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1554 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1554 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1555 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1555 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1556 1556
1557 updateView(); 1557 updateView();
1558 return true; 1558 return true;
1559 1559
1560#if 0 1560#if 0
1561 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1561 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1562 mCurrentSyncDevice = "qtopia-XML"; 1562 mCurrentSyncDevice = "qtopia-XML";
1563 if ( mSyncManager->mAskForPreferences ) 1563 if ( mSyncManager->mAskForPreferences )
1564 edit_sync_options(); 1564 edit_sync_options();
1565 qApp->processEvents(); 1565 qApp->processEvents();
1566 CalendarLocal* calendar = new CalendarLocal(); 1566 CalendarLocal* calendar = new CalendarLocal();
1567 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1567 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1568 bool syncOK = false; 1568 bool syncOK = false;
1569 QtopiaFormat qtopiaFormat; 1569 QtopiaFormat qtopiaFormat;
1570 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1570 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1571 bool loadOk = true; 1571 bool loadOk = true;
1572 if ( !categories.isEmpty() ) 1572 if ( !categories.isEmpty() )
1573 loadOk = qtopiaFormat.load( calendar, categories ); 1573 loadOk = qtopiaFormat.load( calendar, categories );
1574 if ( loadOk && !datebook.isEmpty() ) 1574 if ( loadOk && !datebook.isEmpty() )
1575 loadOk = qtopiaFormat.load( calendar, datebook ); 1575 loadOk = qtopiaFormat.load( calendar, datebook );
1576 if ( loadOk && !todolist.isEmpty() ) 1576 if ( loadOk && !todolist.isEmpty() )
1577 loadOk = qtopiaFormat.load( calendar, todolist ); 1577 loadOk = qtopiaFormat.load( calendar, todolist );
1578 1578
1579 if ( loadOk ) { 1579 if ( loadOk ) {
1580 getEventViewerDialog()->setSyncMode( true ); 1580 getEventViewerDialog()->setSyncMode( true );
1581 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1581 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1582 getEventViewerDialog()->setSyncMode( false ); 1582 getEventViewerDialog()->setSyncMode( false );
1583 qApp->processEvents(); 1583 qApp->processEvents();
1584 if ( syncOK ) { 1584 if ( syncOK ) {
1585 if ( mSyncManager->mWriteBackFile ) 1585 if ( mSyncManager->mWriteBackFile )
1586 { 1586 {
1587 // write back XML file 1587 // write back XML file
1588 1588
1589 } 1589 }
1590 setModified( true ); 1590 setModified( true );
1591 } 1591 }
1592 } else { 1592 } else {
1593 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1593 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1594 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1594 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1595 question, i18n("Ok")) ; 1595 question, i18n("Ok")) ;
1596 } 1596 }
1597 delete calendar; 1597 delete calendar;
1598 updateView(); 1598 updateView();
1599 return syncOK; 1599 return syncOK;
1600 1600
1601 1601
1602#endif 1602#endif
1603 1603
1604} 1604}
1605 1605
1606void CalendarView::setSyncEventsReadOnly() 1606void CalendarView::setSyncEventsReadOnly()
1607{ 1607{
1608 Event * ev; 1608 Event * ev;
1609 QPtrList<Event> eL = mCalendar->rawEvents(); 1609 QPtrList<Event> eL = mCalendar->rawEvents();
1610 ev = eL.first(); 1610 ev = eL.first();
1611 while ( ev ) { 1611 while ( ev ) {
1612 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1612 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1613 ev->setReadOnly( true ); 1613 ev->setReadOnly( true );
1614 ev = eL.next(); 1614 ev = eL.next();
1615 } 1615 }
1616} 1616}
1617bool CalendarView::openCalendar(QString filename, bool merge) 1617bool CalendarView::openCalendar(QString filename, bool merge)
1618{ 1618{
1619 1619
1620 if (filename.isEmpty()) { 1620 if (filename.isEmpty()) {
1621 return false; 1621 return false;
1622 } 1622 }
1623 1623
1624 if (!QFile::exists(filename)) { 1624 if (!QFile::exists(filename)) {
1625 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1625 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1626 return false; 1626 return false;
1627 } 1627 }
1628 1628
1629 globalFlagBlockAgenda = 1; 1629 globalFlagBlockAgenda = 1;
1630 if (!merge) mCalendar->close(); 1630 if (!merge) mCalendar->close();
1631 1631
1632 mStorage->setFileName( filename ); 1632 mStorage->setFileName( filename );
1633 1633
1634 if ( mStorage->load() ) { 1634 if ( mStorage->load() ) {
1635 if ( merge ) ;//setModified( true ); 1635 if ( merge ) ;//setModified( true );
1636 else { 1636 else {
1637 //setModified( true ); 1637 //setModified( true );
1638 mViewManager->setDocumentId( filename ); 1638 mViewManager->setDocumentId( filename );
1639 mDialogManager->setDocumentId( filename ); 1639 mDialogManager->setDocumentId( filename );
1640 mTodoList->setDocumentId( filename ); 1640 mTodoList->setDocumentId( filename );
1641 } 1641 }
1642 globalFlagBlockAgenda = 2; 1642 globalFlagBlockAgenda = 2;
1643 // if ( getLastSyncEvent() ) 1643 // if ( getLastSyncEvent() )
1644 // getLastSyncEvent()->setReadOnly( true ); 1644 // getLastSyncEvent()->setReadOnly( true );
1645 mCalendar->reInitAlarmSettings(); 1645 mCalendar->reInitAlarmSettings();
1646 setSyncEventsReadOnly(); 1646 setSyncEventsReadOnly();
1647 updateUnmanagedViews(); 1647 updateUnmanagedViews();
1648 updateView(); 1648 updateView();
1649 if ( filename != MainWindow::defaultFileName() ) { 1649 if ( filename != MainWindow::defaultFileName() ) {
1650 saveCalendar( MainWindow::defaultFileName() ); 1650 saveCalendar( MainWindow::defaultFileName() );
1651 } else { 1651 } else {
1652 QFileInfo finf ( MainWindow::defaultFileName()); 1652 QFileInfo finf ( MainWindow::defaultFileName());
1653 if ( finf.exists() ) { 1653 if ( finf.exists() ) {
1654 setLoadedFileVersion( finf.lastModified () ); 1654 setLoadedFileVersion( finf.lastModified () );
1655 } 1655 }
1656 } 1656 }
1657 return true; 1657 return true;
1658 } else { 1658 } else {
1659 // while failing to load, the calendar object could 1659 // while failing to load, the calendar object could
1660 // have become partially populated. Clear it out. 1660 // have become partially populated. Clear it out.
1661 if ( !merge ) { 1661 if ( !merge ) {
1662 mCalendar->close(); 1662 mCalendar->close();
1663 mViewManager->setDocumentId( filename ); 1663 mViewManager->setDocumentId( filename );
1664 mDialogManager->setDocumentId( filename ); 1664 mDialogManager->setDocumentId( filename );
1665 mTodoList->setDocumentId( filename ); 1665 mTodoList->setDocumentId( filename );
1666 } 1666 }
1667 1667
1668 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1668 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1669 1669
1670 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 1670 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
1671 globalFlagBlockAgenda = 2; 1671 globalFlagBlockAgenda = 2;
1672 mCalendar->reInitAlarmSettings(); 1672 mCalendar->reInitAlarmSettings();
1673 setSyncEventsReadOnly(); 1673 setSyncEventsReadOnly();
1674 updateUnmanagedViews(); 1674 updateUnmanagedViews();
1675 updateView(); 1675 updateView();
1676 } 1676 }
1677 return false; 1677 return false;
1678} 1678}
1679void CalendarView::showOpenError() 1679void CalendarView::showOpenError()
1680{ 1680{
1681 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 1681 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
1682} 1682}
1683void CalendarView::setLoadedFileVersion(QDateTime dt) 1683void CalendarView::setLoadedFileVersion(QDateTime dt)
1684{ 1684{
1685 loadedFileVersion = dt; 1685 loadedFileVersion = dt;
1686} 1686}
1687bool CalendarView::checkFileChanged(QString fn) 1687bool CalendarView::checkFileChanged(QString fn)
1688{ 1688{
1689 QFileInfo finf ( fn ); 1689 QFileInfo finf ( fn );
1690 if ( !finf.exists() ) 1690 if ( !finf.exists() )
1691 return true; 1691 return true;
1692 QDateTime dt = finf.lastModified (); 1692 QDateTime dt = finf.lastModified ();
1693 if ( dt <= loadedFileVersion ) 1693 if ( dt <= loadedFileVersion )
1694 return false; 1694 return false;
1695 return true; 1695 return true;
1696 1696
1697} 1697}
1698void CalendarView::watchSavedFile() 1698void CalendarView::watchSavedFile()
1699{ 1699{
1700 QFileInfo finf ( MainWindow::defaultFileName()); 1700 QFileInfo finf ( MainWindow::defaultFileName());
1701 if ( !finf.exists() ) 1701 if ( !finf.exists() )
1702 return; 1702 return;
1703 QDateTime dt = finf.lastModified (); 1703 QDateTime dt = finf.lastModified ();
1704 if ( dt < loadedFileVersion ) { 1704 if ( dt < loadedFileVersion ) {
1705 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 1705 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
1706 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 1706 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1707 return; 1707 return;
1708 } 1708 }
1709 loadedFileVersion = dt; 1709 loadedFileVersion = dt;
1710} 1710}
1711 1711
1712bool CalendarView::checkFileVersion(QString fn) 1712bool CalendarView::checkFileVersion(QString fn)
1713{ 1713{
1714 QFileInfo finf ( fn ); 1714 QFileInfo finf ( fn );
1715 if ( !finf.exists() ) 1715 if ( !finf.exists() )
1716 return true; 1716 return true;
1717 QDateTime dt = finf.lastModified (); 1717 QDateTime dt = finf.lastModified ();
1718 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1718 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1719 //qDebug("file on disk version %s",dt.toString().latin1()); 1719 //qDebug("file on disk version %s",dt.toString().latin1());
1720 if ( dt <= loadedFileVersion ) 1720 if ( dt <= loadedFileVersion )
1721 return true; 1721 return true;
1722 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)) , 1722 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)) ,
1723 i18n("KO/Pi Warning"),i18n("Overwrite"), 1723 i18n("KO/Pi Warning"),i18n("Overwrite"),
1724 i18n("Sync+save")); 1724 i18n("Sync+save"));
1725 1725
1726 if ( km == KMessageBox::Cancel ) 1726 if ( km == KMessageBox::Cancel )
1727 return false; 1727 return false;
1728 if ( km == KMessageBox::Yes ) 1728 if ( km == KMessageBox::Yes )
1729 return true; 1729 return true;
1730 1730
1731 setSyncDevice("deleteaftersync" ); 1731 setSyncDevice("deleteaftersync" );
1732 mSyncManager->mAskForPreferences = true; 1732 mSyncManager->mAskForPreferences = true;
1733 mSyncManager->mSyncAlgoPrefs = 3; 1733 mSyncManager->mSyncAlgoPrefs = 3;
1734 mSyncManager->mWriteBackFile = false; 1734 mSyncManager->mWriteBackFile = false;
1735 mSyncManager->mWriteBackExistingOnly = false; 1735 mSyncManager->mWriteBackExistingOnly = false;
1736 mSyncManager->mShowSyncSummary = false; 1736 mSyncManager->mShowSyncSummary = false;
1737 syncCalendar( fn, 3 ); 1737 syncCalendar( fn, 3 );
1738 Event * e = getLastSyncEvent(); 1738 Event * e = getLastSyncEvent();
1739 mCalendar->deleteEvent ( e ); 1739 mCalendar->deleteEvent ( e );
1740 updateView(); 1740 updateView();
1741 return true; 1741 return true;
1742} 1742}
1743 1743
1744bool CalendarView::saveCalendar( QString filename ) 1744bool CalendarView::saveCalendar( QString filename )
1745{ 1745{
1746 1746
1747 // Store back all unsaved data into calendar object 1747 // Store back all unsaved data into calendar object
1748 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1748 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1749 if ( mViewManager->currentView() ) 1749 if ( mViewManager->currentView() )
1750 mViewManager->currentView()->flushView(); 1750 mViewManager->currentView()->flushView();
1751 1751
1752 1752
1753 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 1753 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
1754 mStorage->setSaveFormat( new ICalFormat() ); 1754 mStorage->setSaveFormat( new ICalFormat() );
1755 mStorage->setFileName( filename ); 1755 mStorage->setFileName( filename );
1756 bool success; 1756 bool success;
1757 success = mStorage->save(); 1757 success = mStorage->save();
1758 if ( !success ) { 1758 if ( !success ) {
1759 return false; 1759 return false;
1760 } 1760 }
1761 if ( filename == MainWindow::defaultFileName() ) { 1761 if ( filename == MainWindow::defaultFileName() ) {
1762 setLoadedFileVersion( lfv ); 1762 setLoadedFileVersion( lfv );
1763 watchSavedFile(); 1763 watchSavedFile();
1764 } 1764 }
1765 return true; 1765 return true;
1766} 1766}
1767 1767
1768void CalendarView::closeCalendar() 1768void CalendarView::closeCalendar()
1769{ 1769{
1770 1770
1771 // child windows no longer valid 1771 // child windows no longer valid
1772 emit closingDown(); 1772 emit closingDown();
1773 1773
1774 mCalendar->close(); 1774 mCalendar->close();
1775 setModified(false); 1775 setModified(false);
1776 updateView(); 1776 updateView();
1777} 1777}
1778 1778
1779void CalendarView::archiveCalendar() 1779void CalendarView::archiveCalendar()
1780{ 1780{
1781 mDialogManager->showArchiveDialog(); 1781 mDialogManager->showArchiveDialog();
1782} 1782}
1783 1783
1784 1784
1785void CalendarView::readSettings() 1785void CalendarView::readSettings()
1786{ 1786{
1787 1787
1788 1788
1789 // mViewManager->showAgendaView(); 1789 // mViewManager->showAgendaView();
1790 QString str; 1790 QString str;
1791 //qDebug("CalendarView::readSettings() "); 1791 //qDebug("CalendarView::readSettings() ");
1792 // read settings from the KConfig, supplying reasonable 1792 // read settings from the KConfig, supplying reasonable
1793 // defaults where none are to be found 1793 // defaults where none are to be found
1794 KConfig *config = KOGlobals::config(); 1794 KConfig *config = KOGlobals::config();
1795#ifndef KORG_NOSPLITTER 1795#ifndef KORG_NOSPLITTER
1796 config->setGroup("KOrganizer Geometry"); 1796 config->setGroup("KOrganizer Geometry");
1797 1797
1798 QValueList<int> sizes = config->readIntListEntry("Separator1"); 1798 QValueList<int> sizes = config->readIntListEntry("Separator1");
1799 if (sizes.count() != 2) { 1799 if (sizes.count() != 2) {
1800 sizes << mDateNavigator->minimumSizeHint().width(); 1800 sizes << mDateNavigator->minimumSizeHint().width();
1801 sizes << 300; 1801 sizes << 300;
1802 } 1802 }
1803 mPanner->setSizes(sizes); 1803 mPanner->setSizes(sizes);
1804 1804
1805 sizes = config->readIntListEntry("Separator2"); 1805 sizes = config->readIntListEntry("Separator2");
1806 if ( ( mResourceView && sizes.count() == 4 ) || 1806 if ( ( mResourceView && sizes.count() == 4 ) ||
1807 ( !mResourceView && sizes.count() == 3 ) ) { 1807 ( !mResourceView && sizes.count() == 3 ) ) {
1808 mLeftSplitter->setSizes(sizes); 1808 mLeftSplitter->setSizes(sizes);
1809 } 1809 }
1810#endif 1810#endif
1811 globalFlagBlockAgenda = 1; 1811 globalFlagBlockAgenda = 1;
1812 mViewManager->showAgendaView(); 1812 mViewManager->showAgendaView();
1813 //mViewManager->readSettings( config ); 1813 //mViewManager->readSettings( config );
1814 mTodoList->restoreLayout(config,QString("Todo Layout")); 1814 mTodoList->restoreLayout(config,QString("Todo Layout"));
1815 readFilterSettings(config); 1815 readFilterSettings(config);
1816 config->setGroup( "Views" ); 1816 config->setGroup( "Views" );
1817 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 1817 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
1818 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 1818 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
1819 else if ( dateCount == 7 ) mNavigator->selectWeek(); 1819 else if ( dateCount == 7 ) mNavigator->selectWeek();
1820 else mNavigator->selectDates( dateCount ); 1820 else mNavigator->selectDates( dateCount );
1821 // mViewManager->readSettings( config ); 1821 // mViewManager->readSettings( config );
1822 updateConfig(); 1822 updateConfig();
1823 globalFlagBlockAgenda = 2; 1823 globalFlagBlockAgenda = 2;
1824 mViewManager->readSettings( config ); 1824 mViewManager->readSettings( config );
1825#ifdef DESKTOP_VERSION 1825#ifdef DESKTOP_VERSION
1826 config->setGroup("WidgetLayout"); 1826 config->setGroup("WidgetLayout");
1827 QStringList list; 1827 QStringList list;
1828 list = config->readListEntry("MainLayout"); 1828 list = config->readListEntry("MainLayout");
1829 int x,y,w,h; 1829 int x,y,w,h;
1830 if ( ! list.isEmpty() ) { 1830 if ( ! list.isEmpty() ) {
1831 x = list[0].toInt(); 1831 x = list[0].toInt();
1832 y = list[1].toInt(); 1832 y = list[1].toInt();
1833 w = list[2].toInt(); 1833 w = list[2].toInt();
1834 h = list[3].toInt(); 1834 h = list[3].toInt();
1835 topLevelWidget()->setGeometry(x,y,w,h); 1835 topLevelWidget()->setGeometry(x,y,w,h);
1836 1836
1837 } else { 1837 } else {
1838 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 1838 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
1839 } 1839 }
1840 list = config->readListEntry("EditEventLayout"); 1840 list = config->readListEntry("EditEventLayout");
1841 if ( ! list.isEmpty() ) { 1841 if ( ! list.isEmpty() ) {
1842 x = list[0].toInt(); 1842 x = list[0].toInt();
1843 y = list[1].toInt(); 1843 y = list[1].toInt();
1844 w = list[2].toInt(); 1844 w = list[2].toInt();
1845 h = list[3].toInt(); 1845 h = list[3].toInt();
1846 mEventEditor->setGeometry(x,y,w,h); 1846 mEventEditor->setGeometry(x,y,w,h);
1847 1847
1848 } 1848 }
1849 list = config->readListEntry("EditTodoLayout"); 1849 list = config->readListEntry("EditTodoLayout");
1850 if ( ! list.isEmpty() ) { 1850 if ( ! list.isEmpty() ) {
1851 x = list[0].toInt(); 1851 x = list[0].toInt();
1852 y = list[1].toInt(); 1852 y = list[1].toInt();
1853 w = list[2].toInt(); 1853 w = list[2].toInt();
1854 h = list[3].toInt(); 1854 h = list[3].toInt();
1855 mTodoEditor->setGeometry(x,y,w,h); 1855 mTodoEditor->setGeometry(x,y,w,h);
1856 1856
1857 } 1857 }
1858 list = config->readListEntry("ViewerLayout"); 1858 list = config->readListEntry("ViewerLayout");
1859 if ( ! list.isEmpty() ) { 1859 if ( ! list.isEmpty() ) {
1860 x = list[0].toInt(); 1860 x = list[0].toInt();
1861 y = list[1].toInt(); 1861 y = list[1].toInt();
1862 w = list[2].toInt(); 1862 w = list[2].toInt();
1863 h = list[3].toInt(); 1863 h = list[3].toInt();
1864 getEventViewerDialog()->setGeometry(x,y,w,h); 1864 getEventViewerDialog()->setGeometry(x,y,w,h);
1865 } 1865 }
1866#endif 1866#endif
1867 1867
1868} 1868}
1869 1869
1870 1870
1871void CalendarView::writeSettings() 1871void CalendarView::writeSettings()
1872{ 1872{
1873 // kdDebug() << "CalendarView::writeSettings" << endl; 1873 // kdDebug() << "CalendarView::writeSettings" << endl;
1874 1874
1875 KConfig *config = KOGlobals::config(); 1875 KConfig *config = KOGlobals::config();
1876 1876
1877#ifndef KORG_NOSPLITTER 1877#ifndef KORG_NOSPLITTER
1878 config->setGroup("KOrganizer Geometry"); 1878 config->setGroup("KOrganizer Geometry");
1879 1879
1880 QValueList<int> list = mPanner->sizes(); 1880 QValueList<int> list = mPanner->sizes();
1881 config->writeEntry("Separator1",list); 1881 config->writeEntry("Separator1",list);
1882 1882
1883 list = mLeftSplitter->sizes(); 1883 list = mLeftSplitter->sizes();
1884 config->writeEntry("Separator2",list); 1884 config->writeEntry("Separator2",list);
1885#endif 1885#endif
1886 1886
1887 mViewManager->writeSettings( config ); 1887 mViewManager->writeSettings( config );
1888 mTodoList->saveLayout(config,QString("Todo Layout")); 1888 mTodoList->saveLayout(config,QString("Todo Layout"));
1889 mDialogManager->writeSettings( config ); 1889 mDialogManager->writeSettings( config );
1890 //KOPrefs::instance()->usrWriteConfig(); 1890 //KOPrefs::instance()->usrWriteConfig();
1891 KOPrefs::instance()->writeConfig(); 1891 KOPrefs::instance()->writeConfig();
1892 1892
1893 writeFilterSettings(config); 1893 writeFilterSettings(config);
1894 1894
1895 config->setGroup( "Views" ); 1895 config->setGroup( "Views" );
1896 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 1896 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
1897 1897
1898#ifdef DESKTOP_VERSION 1898#ifdef DESKTOP_VERSION
1899 config->setGroup("WidgetLayout"); 1899 config->setGroup("WidgetLayout");
1900 QStringList list ;//= config->readListEntry("MainLayout"); 1900 QStringList list ;//= config->readListEntry("MainLayout");
1901 int x,y,w,h; 1901 int x,y,w,h;
1902 QWidget* wid; 1902 QWidget* wid;
1903 wid = topLevelWidget(); 1903 wid = topLevelWidget();
1904 x = wid->geometry().x(); 1904 x = wid->geometry().x();
1905 y = wid->geometry().y(); 1905 y = wid->geometry().y();
1906 w = wid->width(); 1906 w = wid->width();
1907 h = wid->height(); 1907 h = wid->height();
1908 list.clear(); 1908 list.clear();
1909 list << QString::number( x ); 1909 list << QString::number( x );
1910 list << QString::number( y ); 1910 list << QString::number( y );
1911 list << QString::number( w ); 1911 list << QString::number( w );
1912 list << QString::number( h ); 1912 list << QString::number( h );
1913 config->writeEntry("MainLayout",list ); 1913 config->writeEntry("MainLayout",list );
1914 1914
1915 wid = mEventEditor; 1915 wid = mEventEditor;
1916 x = wid->geometry().x(); 1916 x = wid->geometry().x();
1917 y = wid->geometry().y(); 1917 y = wid->geometry().y();
1918 w = wid->width(); 1918 w = wid->width();
1919 h = wid->height(); 1919 h = wid->height();
1920 list.clear(); 1920 list.clear();
1921 list << QString::number( x ); 1921 list << QString::number( x );
1922 list << QString::number( y ); 1922 list << QString::number( y );
1923 list << QString::number( w ); 1923 list << QString::number( w );
1924 list << QString::number( h ); 1924 list << QString::number( h );
1925 config->writeEntry("EditEventLayout",list ); 1925 config->writeEntry("EditEventLayout",list );
1926 1926
1927 wid = mTodoEditor; 1927 wid = mTodoEditor;
1928 x = wid->geometry().x(); 1928 x = wid->geometry().x();
1929 y = wid->geometry().y(); 1929 y = wid->geometry().y();
1930 w = wid->width(); 1930 w = wid->width();
1931 h = wid->height(); 1931 h = wid->height();
1932 list.clear(); 1932 list.clear();
1933 list << QString::number( x ); 1933 list << QString::number( x );
1934 list << QString::number( y ); 1934 list << QString::number( y );
1935 list << QString::number( w ); 1935 list << QString::number( w );
1936 list << QString::number( h ); 1936 list << QString::number( h );
1937 config->writeEntry("EditTodoLayout",list ); 1937 config->writeEntry("EditTodoLayout",list );
1938 wid = getEventViewerDialog(); 1938 wid = getEventViewerDialog();
1939 x = wid->geometry().x(); 1939 x = wid->geometry().x();
1940 y = wid->geometry().y(); 1940 y = wid->geometry().y();
1941 w = wid->width(); 1941 w = wid->width();
1942 h = wid->height(); 1942 h = wid->height();
1943 list.clear(); 1943 list.clear();
1944 list << QString::number( x ); 1944 list << QString::number( x );
1945 list << QString::number( y ); 1945 list << QString::number( y );
1946 list << QString::number( w ); 1946 list << QString::number( w );
1947 list << QString::number( h ); 1947 list << QString::number( h );
1948 config->writeEntry("ViewerLayout",list ); 1948 config->writeEntry("ViewerLayout",list );
1949 wid = mDialogManager->getSearchDialog(); 1949 wid = mDialogManager->getSearchDialog();
1950 if ( wid ) { 1950 if ( wid ) {
1951 x = wid->geometry().x(); 1951 x = wid->geometry().x();
1952 y = wid->geometry().y(); 1952 y = wid->geometry().y();
1953 w = wid->width(); 1953 w = wid->width();
1954 h = wid->height(); 1954 h = wid->height();
1955 list.clear(); 1955 list.clear();
1956 list << QString::number( x ); 1956 list << QString::number( x );
1957 list << QString::number( y ); 1957 list << QString::number( y );
1958 list << QString::number( w ); 1958 list << QString::number( w );
1959 list << QString::number( h ); 1959 list << QString::number( h );
1960 config->writeEntry("SearchLayout",list ); 1960 config->writeEntry("SearchLayout",list );
1961 } 1961 }
1962#endif 1962#endif
1963 1963
1964 1964
1965 config->sync(); 1965 config->sync();
1966} 1966}
1967 1967
1968void CalendarView::readFilterSettings(KConfig *config) 1968void CalendarView::readFilterSettings(KConfig *config)
1969{ 1969{
1970 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 1970 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
1971 1971
1972 mFilters.clear(); 1972 mFilters.clear();
1973 1973
1974 config->setGroup("General"); 1974 config->setGroup("General");
1975 QStringList filterList = config->readListEntry("CalendarFilters"); 1975 QStringList filterList = config->readListEntry("CalendarFilters");
1976 1976
1977 QStringList::ConstIterator it = filterList.begin(); 1977 QStringList::ConstIterator it = filterList.begin();
1978 QStringList::ConstIterator end = filterList.end(); 1978 QStringList::ConstIterator end = filterList.end();
1979 while(it != end) { 1979 while(it != end) {
1980 // kdDebug() << " filter: " << (*it) << endl; 1980 // kdDebug() << " filter: " << (*it) << endl;
1981 1981
1982 CalFilter *filter; 1982 CalFilter *filter;
1983 filter = new CalFilter(*it); 1983 filter = new CalFilter(*it);
1984 config->setGroup("Filter_" + (*it)); 1984 config->setGroup("Filter_" + (*it));
1985 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 1985 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
1986 filter->setCriteria(config->readNumEntry("Criteria",0)); 1986 filter->setCriteria(config->readNumEntry("Criteria",0));
1987 filter->setCategoryList(config->readListEntry("CategoryList")); 1987 filter->setCategoryList(config->readListEntry("CategoryList"));
1988 mFilters.append(filter); 1988 mFilters.append(filter);
1989 1989
1990 ++it; 1990 ++it;
1991 } 1991 }
1992 1992
1993 if (mFilters.count() == 0) { 1993 if (mFilters.count() == 0) {
1994 CalFilter *filter = new CalFilter(i18n("Default")); 1994 CalFilter *filter = new CalFilter(i18n("Default"));
1995 mFilters.append(filter); 1995 mFilters.append(filter);
1996 } 1996 }
1997 mFilterView->updateFilters(); 1997 mFilterView->updateFilters();
1998 config->setGroup("FilterView"); 1998 config->setGroup("FilterView");
1999 1999
2000 mFilterView->blockSignals(true); 2000 mFilterView->blockSignals(true);
2001 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 2001 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
2002 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 2002 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
2003 mFilterView->blockSignals(false); 2003 mFilterView->blockSignals(false);
2004 // We do it manually to avoid it being done twice by the above calls 2004 // We do it manually to avoid it being done twice by the above calls
2005 updateFilter(); 2005 updateFilter();
2006} 2006}
2007 2007
2008void CalendarView::writeFilterSettings(KConfig *config) 2008void CalendarView::writeFilterSettings(KConfig *config)
2009{ 2009{
2010 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 2010 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
2011 2011
2012 QStringList filterList; 2012 QStringList filterList;
2013 2013
2014 CalFilter *filter = mFilters.first(); 2014 CalFilter *filter = mFilters.first();
2015 while(filter) { 2015 while(filter) {
2016 // kdDebug() << " fn: " << filter->name() << endl; 2016 // kdDebug() << " fn: " << filter->name() << endl;
2017 filterList << filter->name(); 2017 filterList << filter->name();
2018 config->setGroup("Filter_" + filter->name()); 2018 config->setGroup("Filter_" + filter->name());
2019 config->writeEntry("Criteria",filter->criteria()); 2019 config->writeEntry("Criteria",filter->criteria());
2020 config->writeEntry("CategoryList",filter->categoryList()); 2020 config->writeEntry("CategoryList",filter->categoryList());
2021 filter = mFilters.next(); 2021 filter = mFilters.next();
2022 } 2022 }
2023 config->setGroup("General"); 2023 config->setGroup("General");
2024 config->writeEntry("CalendarFilters",filterList); 2024 config->writeEntry("CalendarFilters",filterList);
2025 2025
2026 config->setGroup("FilterView"); 2026 config->setGroup("FilterView");
2027 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 2027 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
2028 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 2028 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
2029} 2029}
2030 2030
2031 2031
2032void CalendarView::goToday() 2032void CalendarView::goToday()
2033{ 2033{
2034 if ( mViewManager->currentView()->isMonthView() ) 2034 if ( mViewManager->currentView()->isMonthView() )
2035 mNavigator->selectTodayMonth(); 2035 mNavigator->selectTodayMonth();
2036 else 2036 else
2037 mNavigator->selectToday(); 2037 mNavigator->selectToday();
2038} 2038}
2039 2039
2040void CalendarView::goNext() 2040void CalendarView::goNext()
2041{ 2041{
2042 mNavigator->selectNext(); 2042 mNavigator->selectNext();
2043} 2043}
2044 2044
2045void CalendarView::goPrevious() 2045void CalendarView::goPrevious()
2046{ 2046{
2047 mNavigator->selectPrevious(); 2047 mNavigator->selectPrevious();
2048} 2048}
2049void CalendarView::goNextMonth() 2049void CalendarView::goNextMonth()
2050{ 2050{
2051 mNavigator->selectNextMonth(); 2051 mNavigator->selectNextMonth();
2052} 2052}
2053 2053
2054void CalendarView::goPreviousMonth() 2054void CalendarView::goPreviousMonth()
2055{ 2055{
2056 mNavigator->selectPreviousMonth(); 2056 mNavigator->selectPreviousMonth();
2057} 2057}
2058void CalendarView::writeLocale() 2058void CalendarView::writeLocale()
2059{ 2059{
2060 //KPimGlobalPrefs::instance()->setGlobalConfig(); 2060 //KPimGlobalPrefs::instance()->setGlobalConfig();
2061#if 0 2061#if 0
2062 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); 2062 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime );
2063 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); 2063 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday );
2064 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); 2064 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate );
2065 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); 2065 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage );
2066 QString dummy = KOPrefs::instance()->mUserDateFormatLong; 2066 QString dummy = KOPrefs::instance()->mUserDateFormatLong;
2067 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 2067 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
2068 dummy = KOPrefs::instance()->mUserDateFormatShort; 2068 dummy = KOPrefs::instance()->mUserDateFormatShort;
2069 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 2069 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
2070 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, 2070 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving,
2071 KOPrefs::instance()->mDaylightsavingStart, 2071 KOPrefs::instance()->mDaylightsavingStart,
2072 KOPrefs::instance()->mDaylightsavingEnd ); 2072 KOPrefs::instance()->mDaylightsavingEnd );
2073 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); 2073 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId );
2074#endif 2074#endif
2075} 2075}
2076void CalendarView::updateConfig() 2076void CalendarView::updateConfig()
2077{ 2077{
2078 writeLocale(); 2078 writeLocale();
2079 if ( KOPrefs::instance()->mUseAppColors ) 2079 if ( KOPrefs::instance()->mUseAppColors )
2080 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 2080 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
2081 emit configChanged(); 2081 emit configChanged();
2082 mTodoList->updateConfig(); 2082 mTodoList->updateConfig();
2083 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 2083 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
2084 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2084 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2085 // To make the "fill window" configurations work 2085 // To make the "fill window" configurations work
2086 //mViewManager->raiseCurrentView(); 2086 //mViewManager->raiseCurrentView();
2087} 2087}
2088 2088
2089 2089
2090void CalendarView::eventChanged(Event *event) 2090void CalendarView::eventChanged(Event *event)
2091{ 2091{
2092 changeEventDisplay(event,KOGlobals::EVENTEDITED); 2092 changeEventDisplay(event,KOGlobals::EVENTEDITED);
2093 //updateUnmanagedViews(); 2093 //updateUnmanagedViews();
2094} 2094}
2095 2095
2096void CalendarView::eventAdded(Event *event) 2096void CalendarView::eventAdded(Event *event)
2097{ 2097{
2098 changeEventDisplay(event,KOGlobals::EVENTADDED); 2098 changeEventDisplay(event,KOGlobals::EVENTADDED);
2099} 2099}
2100 2100
2101void CalendarView::eventToBeDeleted(Event *) 2101void CalendarView::eventToBeDeleted(Event *)
2102{ 2102{
2103 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 2103 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
2104} 2104}
2105 2105
2106void CalendarView::eventDeleted() 2106void CalendarView::eventDeleted()
2107{ 2107{
2108 changeEventDisplay(0,KOGlobals::EVENTDELETED); 2108 changeEventDisplay(0,KOGlobals::EVENTDELETED);
2109} 2109}
2110void CalendarView::changeTodoDisplay(Todo *which, int action) 2110void CalendarView::changeTodoDisplay(Todo *which, int action)
2111{ 2111{
2112 changeIncidenceDisplay((Incidence *)which, action); 2112 changeIncidenceDisplay((Incidence *)which, action);
2113 mDateNavigator->updateView(); //LR 2113 mDateNavigator->updateView(); //LR
2114 //mDialogManager->updateSearchDialog(); 2114 //mDialogManager->updateSearchDialog();
2115 2115
2116 if (which) { 2116 if (which) {
2117 mViewManager->updateWNview(); 2117 mViewManager->updateWNview();
2118 //mTodoList->updateView(); 2118 //mTodoList->updateView();
2119 } 2119 }
2120 2120
2121} 2121}
2122 2122
2123void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 2123void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
2124{ 2124{
2125 updateUnmanagedViews(); 2125 updateUnmanagedViews();
2126 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 2126 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
2127 if ( action == KOGlobals::EVENTDELETED ) { //delete 2127 if ( action == KOGlobals::EVENTDELETED ) { //delete
2128 mCalendar->checkAlarmForIncidence( 0, true ); 2128 mCalendar->checkAlarmForIncidence( 0, true );
2129 if ( mEventViewerDialog ) 2129 if ( mEventViewerDialog )
2130 mEventViewerDialog->hide(); 2130 mEventViewerDialog->hide();
2131 } 2131 }
2132 else 2132 else
2133 mCalendar->checkAlarmForIncidence( which , false ); 2133 mCalendar->checkAlarmForIncidence( which , false );
2134} 2134}
2135 2135
2136// most of the changeEventDisplays() right now just call the view's 2136// most of the changeEventDisplays() right now just call the view's
2137// total update mode, but they SHOULD be recoded to be more refresh-efficient. 2137// total update mode, but they SHOULD be recoded to be more refresh-efficient.
2138void CalendarView::changeEventDisplay(Event *which, int action) 2138void CalendarView::changeEventDisplay(Event *which, int action)
2139{ 2139{
2140 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 2140 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
2141 changeIncidenceDisplay((Incidence *)which, action); 2141 changeIncidenceDisplay((Incidence *)which, action);
2142 mDateNavigator->updateView(); 2142 mDateNavigator->updateView();
2143 //mDialogManager->updateSearchDialog(); 2143 //mDialogManager->updateSearchDialog();
2144 2144
2145 if (which) { 2145 if (which) {
2146 // If there is an event view visible update the display 2146 // If there is an event view visible update the display
2147 mViewManager->currentView()->changeEventDisplay(which,action); 2147 mViewManager->currentView()->changeEventDisplay(which,action);
2148 // TODO: check, if update needed 2148 // TODO: check, if update needed
2149 // if (which->getTodoStatus()) { 2149 // if (which->getTodoStatus()) {
2150 mTodoList->updateView(); 2150 mTodoList->updateView();
2151 // } 2151 // }
2152 } else { 2152 } else {
2153 mViewManager->currentView()->updateView(); 2153 mViewManager->currentView()->updateView();
2154 } 2154 }
2155} 2155}
2156 2156
2157 2157
2158void CalendarView::updateTodoViews() 2158void CalendarView::updateTodoViews()
2159{ 2159{
2160 2160
2161 mTodoList->updateView(); 2161 mTodoList->updateView();
2162 mViewManager->currentView()->updateView(); 2162 mViewManager->currentView()->updateView();
2163 2163
2164} 2164}
2165 2165
2166 2166
2167void CalendarView::updateView(const QDate &start, const QDate &end) 2167void CalendarView::updateView(const QDate &start, const QDate &end)
2168{ 2168{
2169 mTodoList->updateView(); 2169 mTodoList->updateView();
2170 mViewManager->updateView(start, end); 2170 mViewManager->updateView(start, end);
2171 //mDateNavigator->updateView(); 2171 //mDateNavigator->updateView();
2172} 2172}
2173 2173
2174void CalendarView::updateView() 2174void CalendarView::updateView()
2175{ 2175{
2176 DateList tmpList = mNavigator->selectedDates(); 2176 DateList tmpList = mNavigator->selectedDates();
2177 2177
2178 if ( KOPrefs::instance()->mHideNonStartedTodos ) 2178 if ( KOPrefs::instance()->mHideNonStartedTodos )
2179 mTodoList->updateView(); 2179 mTodoList->updateView();
2180 // We assume that the navigator only selects consecutive days. 2180 // We assume that the navigator only selects consecutive days.
2181 updateView( tmpList.first(), tmpList.last() ); 2181 updateView( tmpList.first(), tmpList.last() );
2182} 2182}
2183 2183
2184void CalendarView::updateUnmanagedViews() 2184void CalendarView::updateUnmanagedViews()
2185{ 2185{
2186 mDateNavigator->updateDayMatrix(); 2186 mDateNavigator->updateDayMatrix();
2187} 2187}
2188 2188
2189int CalendarView::msgItemDelete(const QString name) 2189int CalendarView::msgItemDelete(const QString name)
2190{ 2190{
2191 return KMessageBox::warningContinueCancel(this,name +"\n\n"+ 2191 return KMessageBox::warningContinueCancel(this,name +"\n\n"+
2192 i18n("This item will be\npermanently deleted."), 2192 i18n("This item will be\npermanently deleted."),
2193 i18n("KO/Pi Confirmation"),i18n("Delete")); 2193 i18n("KO/Pi Confirmation"),i18n("Delete"));
2194} 2194}
2195 2195
2196 2196
2197void CalendarView::edit_cut() 2197void CalendarView::edit_cut()
2198{ 2198{
2199 Event *anEvent=0; 2199 Event *anEvent=0;
2200 2200
2201 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2201 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2202 2202
2203 if (mViewManager->currentView()->isEventView()) { 2203 if (mViewManager->currentView()->isEventView()) {
2204 if ( incidence && incidence->type() == "Event" ) { 2204 if ( incidence && incidence->type() == "Event" ) {
2205 anEvent = static_cast<Event *>(incidence); 2205 anEvent = static_cast<Event *>(incidence);
2206 } 2206 }
2207 } 2207 }
2208 2208
2209 if (!anEvent) { 2209 if (!anEvent) {
2210 KNotifyClient::beep(); 2210 KNotifyClient::beep();
2211 return; 2211 return;
2212 } 2212 }
2213 DndFactory factory( mCalendar ); 2213 DndFactory factory( mCalendar );
2214 factory.cutEvent(anEvent); 2214 factory.cutEvent(anEvent);
2215 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2215 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2216} 2216}
2217 2217
2218void CalendarView::edit_copy() 2218void CalendarView::edit_copy()
2219{ 2219{
2220 Event *anEvent=0; 2220 Event *anEvent=0;
2221 2221
2222 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2222 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2223 2223
2224 if (mViewManager->currentView()->isEventView()) { 2224 if (mViewManager->currentView()->isEventView()) {
2225 if ( incidence && incidence->type() == "Event" ) { 2225 if ( incidence && incidence->type() == "Event" ) {
2226 anEvent = static_cast<Event *>(incidence); 2226 anEvent = static_cast<Event *>(incidence);
2227 } 2227 }
2228 } 2228 }
2229 2229
2230 if (!anEvent) { 2230 if (!anEvent) {
2231 KNotifyClient::beep(); 2231 KNotifyClient::beep();
2232 return; 2232 return;
2233 } 2233 }
2234 DndFactory factory( mCalendar ); 2234 DndFactory factory( mCalendar );
2235 factory.copyEvent(anEvent); 2235 factory.copyEvent(anEvent);
2236} 2236}
2237 2237
2238void CalendarView::edit_paste() 2238void CalendarView::edit_paste()
2239{ 2239{
2240 QDate date = mNavigator->selectedDates().first(); 2240 QDate date = mNavigator->selectedDates().first();
2241 2241
2242 DndFactory factory( mCalendar ); 2242 DndFactory factory( mCalendar );
2243 Event *pastedEvent = factory.pasteEvent( date ); 2243 Event *pastedEvent = factory.pasteEvent( date );
2244 2244
2245 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 2245 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
2246} 2246}
2247 2247
2248void CalendarView::edit_options() 2248void CalendarView::edit_options()
2249{ 2249{
2250 mDialogManager->showOptionsDialog(); 2250 mDialogManager->showOptionsDialog();
2251 //writeSettings(); 2251 //writeSettings();
2252} 2252}
2253 2253
2254 2254
2255void CalendarView::slotSelectPickerDate( QDate d) 2255void CalendarView::slotSelectPickerDate( QDate d)
2256{ 2256{
2257 mDateFrame->hide(); 2257 mDateFrame->hide();
2258 if ( mDatePickerMode == 1 ) { 2258 if ( mDatePickerMode == 1 ) {
2259 mNavigator->slotDaySelect( d ); 2259 mNavigator->slotDaySelect( d );
2260 } else if ( mDatePickerMode == 2 ) { 2260 } else if ( mDatePickerMode == 2 ) {
2261 if ( mMoveIncidence->type() == "Todo" ) { 2261 if ( mMoveIncidence->type() == "Todo" ) {
2262 Todo * to = (Todo *) mMoveIncidence; 2262 Todo * to = (Todo *) mMoveIncidence;
2263 QTime tim; 2263 QTime tim;
2264 if ( to->hasDueDate() ) 2264 if ( to->hasDueDate() )
2265 tim = to->dtDue().time(); 2265 tim = to->dtDue().time();
2266 else { 2266 else {
2267 tim = QTime ( 0,0,0 ); 2267 tim = QTime ( 0,0,0 );
2268 to->setFloats( true ); 2268 to->setFloats( true );
2269 to->setHasDueDate( true ); 2269 to->setHasDueDate( true );
2270 } 2270 }
2271 QDateTime dt ( d,tim ); 2271 QDateTime dt ( d,tim );
2272 to->setDtDue( dt ); 2272 to->setDtDue( dt );
2273 todoChanged( to ); 2273 todoChanged( to );
2274 } else { 2274 } else {
2275 if ( mMoveIncidence->doesRecur() ) { 2275 if ( mMoveIncidence->doesRecur() ) {
2276#if 0 2276#if 0
2277 // PENDING implement this 2277 // PENDING implement this
2278 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); 2278 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate );
2279 mCalendar()->addIncidence( newInc ); 2279 mCalendar()->addIncidence( newInc );
2280 if ( mMoveIncidence->type() == "Todo" ) 2280 if ( mMoveIncidence->type() == "Todo" )
2281 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); 2281 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED );
2282 else 2282 else
2283 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); 2283 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED);
2284 mMoveIncidence = newInc; 2284 mMoveIncidence = newInc;
2285 2285
2286#endif 2286#endif
2287 } 2287 }
2288 QTime tim = mMoveIncidence->dtStart().time(); 2288 QTime tim = mMoveIncidence->dtStart().time();
2289 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2289 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2290 QDateTime dt ( d,tim ); 2290 QDateTime dt ( d,tim );
2291 mMoveIncidence->setDtStart( dt ); 2291 mMoveIncidence->setDtStart( dt );
2292 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2292 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2293 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2293 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2294 } 2294 }
2295 2295
2296 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2296 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2297 } 2297 }
2298} 2298}
2299 2299
2300void CalendarView::removeCategories() 2300void CalendarView::removeCategories()
2301{ 2301{
2302 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2302 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2303 QStringList catList = KOPrefs::instance()->mCustomCategories; 2303 QStringList catList = KOPrefs::instance()->mCustomCategories;
2304 QStringList catIncList; 2304 QStringList catIncList;
2305 QStringList newCatList; 2305 QStringList newCatList;
2306 Incidence* inc = incList.first(); 2306 Incidence* inc = incList.first();
2307 int i; 2307 int i;
2308 int count = 0; 2308 int count = 0;
2309 while ( inc ) { 2309 while ( inc ) {
2310 newCatList.clear(); 2310 newCatList.clear();
2311 catIncList = inc->categories() ; 2311 catIncList = inc->categories() ;
2312 for( i = 0; i< catIncList.count(); ++i ) { 2312 for( i = 0; i< catIncList.count(); ++i ) {
2313 if ( catList.contains (catIncList[i])) 2313 if ( catList.contains (catIncList[i]))
2314 newCatList.append( catIncList[i] ); 2314 newCatList.append( catIncList[i] );
2315 } 2315 }
2316 newCatList.sort(); 2316 newCatList.sort();
2317 inc->setCategories( newCatList.join(",") ); 2317 inc->setCategories( newCatList.join(",") );
2318 inc = incList.next(); 2318 inc = incList.next();
2319 } 2319 }
2320} 2320}
2321 2321
2322int CalendarView::addCategories() 2322int CalendarView::addCategories()
2323{ 2323{
2324 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2324 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2325 QStringList catList = KOPrefs::instance()->mCustomCategories; 2325 QStringList catList = KOPrefs::instance()->mCustomCategories;
2326 QStringList catIncList; 2326 QStringList catIncList;
2327 Incidence* inc = incList.first(); 2327 Incidence* inc = incList.first();
2328 int i; 2328 int i;
2329 int count = 0; 2329 int count = 0;
2330 while ( inc ) { 2330 while ( inc ) {
2331 catIncList = inc->categories() ; 2331 catIncList = inc->categories() ;
2332 for( i = 0; i< catIncList.count(); ++i ) { 2332 for( i = 0; i< catIncList.count(); ++i ) {
2333 if ( !catList.contains (catIncList[i])) { 2333 if ( !catList.contains (catIncList[i])) {
2334 catList.append( catIncList[i] ); 2334 catList.append( catIncList[i] );
2335 //qDebug("add cat %s ", catIncList[i].latin1()); 2335 //qDebug("add cat %s ", catIncList[i].latin1());
2336 ++count; 2336 ++count;
2337 } 2337 }
2338 } 2338 }
2339 inc = incList.next(); 2339 inc = incList.next();
2340 } 2340 }
2341 catList.sort(); 2341 catList.sort();
2342 KOPrefs::instance()->mCustomCategories = catList; 2342 KOPrefs::instance()->mCustomCategories = catList;
2343 return count; 2343 return count;
2344} 2344}
2345 2345
2346void CalendarView::manageCategories() 2346void CalendarView::manageCategories()
2347{ 2347{
2348 KOCatPrefs* cp = new KOCatPrefs(); 2348 KOCatPrefs* cp = new KOCatPrefs();
2349 cp->show(); 2349 cp->show();
2350 int w =cp->sizeHint().width() ; 2350 int w =cp->sizeHint().width() ;
2351 int h = cp->sizeHint().height() ; 2351 int h = cp->sizeHint().height() ;
2352 int dw = QApplication::desktop()->width(); 2352 int dw = QApplication::desktop()->width();
2353 int dh = QApplication::desktop()->height(); 2353 int dh = QApplication::desktop()->height();
2354 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2354 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2355 if ( !cp->exec() ) { 2355 if ( !cp->exec() ) {
2356 delete cp; 2356 delete cp;
2357 return; 2357 return;
2358 } 2358 }
2359 int count = 0; 2359 int count = 0;
2360 if ( cp->addCat() ) { 2360 if ( cp->addCat() ) {
2361 count = addCategories(); 2361 count = addCategories();
2362 if ( count ) { 2362 if ( count ) {
2363 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2363 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2364 writeSettings(); 2364 writeSettings();
2365 } else 2365 } else
2366 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); 2366 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! "));
2367 } else { 2367 } else {
2368 removeCategories(); 2368 removeCategories();
2369 updateView(); 2369 updateView();
2370 } 2370 }
2371 delete cp; 2371 delete cp;
2372} 2372}
2373 2373
2374void CalendarView::beamIncidence(Incidence * Inc) 2374void CalendarView::beamIncidence(Incidence * Inc)
2375{ 2375{
2376 QPtrList<Incidence> delSel ; 2376 QPtrList<Incidence> delSel ;
2377 delSel.append(Inc); 2377 delSel.append(Inc);
2378 beamIncidenceList( delSel ); 2378 beamIncidenceList( delSel );
2379} 2379}
2380void CalendarView::beamCalendar() 2380void CalendarView::beamCalendar()
2381{ 2381{
2382 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2382 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2383 //qDebug("beamCalendar() "); 2383 //qDebug("beamCalendar() ");
2384 beamIncidenceList( delSel ); 2384 beamIncidenceList( delSel );
2385} 2385}
2386void CalendarView::beamFilteredCalendar() 2386void CalendarView::beamFilteredCalendar()
2387{ 2387{
2388 QPtrList<Incidence> delSel = mCalendar->incidences(); 2388 QPtrList<Incidence> delSel = mCalendar->incidences();
2389 //qDebug("beamFilteredCalendar() "); 2389 //qDebug("beamFilteredCalendar() ");
2390 beamIncidenceList( delSel ); 2390 beamIncidenceList( delSel );
2391} 2391}
2392void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2392void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2393{ 2393{
2394 if ( beamDialog->exec () == QDialog::Rejected ) 2394 if ( beamDialog->exec () == QDialog::Rejected )
2395 return; 2395 return;
2396#ifdef DESKTOP_VERSION 2396#ifdef DESKTOP_VERSION
2397 QString fn = locateLocal( "tmp", "kopibeamfile" ); 2397 QString fn = locateLocal( "tmp", "kopibeamfile" );
2398#else 2398#else
2399 QString fn = "/tmp/kopibeamfile"; 2399 QString fn = "/tmp/kopibeamfile";
2400#endif 2400#endif
2401 QString mes; 2401 QString mes;
2402 bool createbup = true; 2402 bool createbup = true;
2403 if ( createbup ) { 2403 if ( createbup ) {
2404 QString description = "\n"; 2404 QString description = "\n";
2405 CalendarLocal* cal = new CalendarLocal(); 2405 CalendarLocal* cal = new CalendarLocal();
2406 if ( beamDialog->beamLocal() ) 2406 if ( beamDialog->beamLocal() )
2407 cal->setLocalTime(); 2407 cal->setLocalTime();
2408 else 2408 else
2409 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2409 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2410 Incidence *incidence = delSel.first(); 2410 Incidence *incidence = delSel.first();
2411 bool addText = false; 2411 bool addText = false;
2412 if ( delSel.count() < 10 ) 2412 if ( delSel.count() < 10 )
2413 addText = true; 2413 addText = true;
2414 else { 2414 else {
2415 description.sprintf(i18n(" %d items?"),delSel.count() ); 2415 description.sprintf(i18n(" %d items?"),delSel.count() );
2416 } 2416 }
2417 while ( incidence ) { 2417 while ( incidence ) {
2418 Incidence *in = incidence->clone(); 2418 Incidence *in = incidence->clone();
2419 if ( ! in->summary().isEmpty() ) { 2419 if ( ! in->summary().isEmpty() ) {
2420 in->setDescription(""); 2420 in->setDescription("");
2421 } else { 2421 } else {
2422 in->setSummary( in->description().left(20)); 2422 in->setSummary( in->description().left(20));
2423 in->setDescription(""); 2423 in->setDescription("");
2424 } 2424 }
2425 if ( addText ) 2425 if ( addText )
2426 description += in->summary() + "\n"; 2426 description += in->summary() + "\n";
2427 cal->addIncidence( in ); 2427 cal->addIncidence( in );
2428 incidence = delSel.next(); 2428 incidence = delSel.next();
2429 } 2429 }
2430 if ( beamDialog->beamVcal() ) { 2430 if ( beamDialog->beamVcal() ) {
2431 fn += ".vcs"; 2431 fn += ".vcs";
2432 FileStorage storage( cal, fn, new VCalFormat ); 2432 FileStorage storage( cal, fn, new VCalFormat );
2433 storage.save(); 2433 storage.save();
2434 } else { 2434 } else {
2435 fn += ".ics"; 2435 fn += ".ics";
2436 FileStorage storage( cal, fn, new ICalFormat( ) ); 2436 FileStorage storage( cal, fn, new ICalFormat( ) );
2437 storage.save(); 2437 storage.save();
2438 } 2438 }
2439 delete cal; 2439 delete cal;
2440 mes = i18n("KO/Pi: Ready for beaming"); 2440 mes = i18n("KO/Pi: Ready for beaming");
2441 topLevelWidget()->setCaption(mes); 2441 topLevelWidget()->setCaption(mes);
2442 KApplication::convert2latin1( fn ); 2442 KApplication::convert2latin1( fn );
2443#ifndef DESKTOP_VERSION 2443#ifndef DESKTOP_VERSION
2444 Ir *ir = new Ir( this ); 2444 Ir *ir = new Ir( this );
2445 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 2445 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2446 ir->send( fn, description, "text/x-vCalendar" ); 2446 ir->send( fn, description, "text/x-vCalendar" );
2447#endif 2447#endif
2448 } 2448 }
2449} 2449}
2450void CalendarView::beamDone( Ir *ir ) 2450void CalendarView::beamDone( Ir *ir )
2451{ 2451{
2452#ifndef DESKTOP_VERSION 2452#ifndef DESKTOP_VERSION
2453 delete ir; 2453 delete ir;
2454#endif 2454#endif
2455 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); 2455 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") );
2456 topLevelWidget()->raise(); 2456 topLevelWidget()->raise();
2457} 2457}
2458 2458
2459void CalendarView::moveIncidence(Incidence * inc ) 2459void CalendarView::moveIncidence(Incidence * inc )
2460{ 2460{
2461 if ( !inc ) return; 2461 if ( !inc ) return;
2462 // qDebug("showDatePickerForIncidence( ) "); 2462 // qDebug("showDatePickerForIncidence( ) ");
2463 if ( mDateFrame->isVisible() ) 2463 if ( mDateFrame->isVisible() )
2464 mDateFrame->hide(); 2464 mDateFrame->hide();
2465 else { 2465 else {
2466 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; 2466 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ;
2467 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; 2467 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ;
2468 int dw = QApplication::desktop()->width(); 2468 int dw = QApplication::desktop()->width();
2469 int dh = QApplication::desktop()->height(); 2469 int dh = QApplication::desktop()->height();
2470 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2470 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2471 mDateFrame->show(); 2471 mDateFrame->show();
2472 } 2472 }
2473 mDatePickerMode = 2; 2473 mDatePickerMode = 2;
2474 mMoveIncidence = inc ; 2474 mMoveIncidence = inc ;
2475 QDate da; 2475 QDate da;
2476 if ( mMoveIncidence->type() == "Todo" ) { 2476 if ( mMoveIncidence->type() == "Todo" ) {
2477 Todo * to = (Todo *) mMoveIncidence; 2477 Todo * to = (Todo *) mMoveIncidence;
2478 if ( to->hasDueDate() ) 2478 if ( to->hasDueDate() )
2479 da = to->dtDue().date(); 2479 da = to->dtDue().date();
2480 else 2480 else
2481 da = QDate::currentDate(); 2481 da = QDate::currentDate();
2482 } else { 2482 } else {
2483 da = mMoveIncidence->dtStart().date(); 2483 da = mMoveIncidence->dtStart().date();
2484 } 2484 }
2485 //PENDING set date for recurring incidence to date of recurrence 2485 //PENDING set date for recurring incidence to date of recurrence
2486 //mMoveIncidenceOldDate; 2486 //mMoveIncidenceOldDate;
2487 mDatePicker->setDate( da ); 2487 mDatePicker->setDate( da );
2488} 2488}
2489void CalendarView::showDatePicker( ) 2489void CalendarView::showDatePicker( )
2490{ 2490{
2491 //qDebug("CalendarView::showDatePicker( ) "); 2491 //qDebug("CalendarView::showDatePicker( ) ");
2492 if ( mDateFrame->isVisible() ) 2492 if ( mDateFrame->isVisible() )
2493 mDateFrame->hide(); 2493 mDateFrame->hide();
2494 else { 2494 else {
2495 int w =mDatePicker->sizeHint().width() ; 2495 int w =mDatePicker->sizeHint().width() ;
2496 int h = mDatePicker->sizeHint().height() ; 2496 int h = mDatePicker->sizeHint().height() ;
2497 int dw = QApplication::desktop()->width(); 2497 int dw = QApplication::desktop()->width();
2498 int dh = QApplication::desktop()->height(); 2498 int dh = QApplication::desktop()->height();
2499 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2499 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2500 mDateFrame->show(); 2500 mDateFrame->show();
2501 } 2501 }
2502 mDatePickerMode = 1; 2502 mDatePickerMode = 1;
2503 mDatePicker->setDate( mNavigator->selectedDates().first() ); 2503 mDatePicker->setDate( mNavigator->selectedDates().first() );
2504} 2504}
2505 2505
2506void CalendarView::showEventEditor() 2506void CalendarView::showEventEditor()
2507{ 2507{
2508#ifdef DESKTOP_VERSION 2508#ifdef DESKTOP_VERSION
2509 mEventEditor->show(); 2509 mEventEditor->show();
2510#else 2510#else
2511 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { 2511 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) {
2512 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2512 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2513 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); 2513 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() );
2514 delete mEventEditor; 2514 delete mEventEditor;
2515 mEventEditor = mDialogManager->getEventEditor(); 2515 mEventEditor = mDialogManager->getEventEditor();
2516 topLevelWidget()->setCaption( i18n("") );
2516 } 2517 }
2517 mEventEditor->showMaximized(); 2518 mEventEditor->showMaximized();
2518 topLevelWidget()->setCaption( i18n("") );
2519#endif 2519#endif
2520} 2520}
2521void CalendarView::showTodoEditor() 2521void CalendarView::showTodoEditor()
2522{ 2522{
2523#ifdef DESKTOP_VERSION 2523#ifdef DESKTOP_VERSION
2524 mTodoEditor->show(); 2524 mTodoEditor->show();
2525#else 2525#else
2526 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { 2526 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) {
2527 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2527 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2528 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); 2528 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() );
2529 delete mTodoEditor; 2529 delete mTodoEditor;
2530 mTodoEditor = mDialogManager->getTodoEditor(); 2530 mTodoEditor = mDialogManager->getTodoEditor();
2531 topLevelWidget()->setCaption( i18n("") );
2531 } 2532 }
2532 mTodoEditor->showMaximized(); 2533 mTodoEditor->showMaximized();
2533 topLevelWidget()->setCaption( i18n("") );
2534#endif 2534#endif
2535} 2535}
2536 2536
2537void CalendarView::cloneIncidence() 2537void CalendarView::cloneIncidence()
2538{ 2538{
2539 Incidence *incidence = currentSelection(); 2539 Incidence *incidence = currentSelection();
2540 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2540 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2541 if ( incidence ) { 2541 if ( incidence ) {
2542 cloneIncidence(incidence); 2542 cloneIncidence(incidence);
2543 } 2543 }
2544} 2544}
2545void CalendarView::moveIncidence() 2545void CalendarView::moveIncidence()
2546{ 2546{
2547 Incidence *incidence = currentSelection(); 2547 Incidence *incidence = currentSelection();
2548 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2548 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2549 if ( incidence ) { 2549 if ( incidence ) {
2550 moveIncidence(incidence); 2550 moveIncidence(incidence);
2551 } 2551 }
2552} 2552}
2553void CalendarView::beamIncidence() 2553void CalendarView::beamIncidence()
2554{ 2554{
2555 Incidence *incidence = currentSelection(); 2555 Incidence *incidence = currentSelection();
2556 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2556 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2557 if ( incidence ) { 2557 if ( incidence ) {
2558 beamIncidence(incidence); 2558 beamIncidence(incidence);
2559 } 2559 }
2560} 2560}
2561void CalendarView::toggleCancelIncidence() 2561void CalendarView::toggleCancelIncidence()
2562{ 2562{
2563 Incidence *incidence = currentSelection(); 2563 Incidence *incidence = currentSelection();
2564 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2564 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2565 if ( incidence ) { 2565 if ( incidence ) {
2566 cancelIncidence(incidence); 2566 cancelIncidence(incidence);
2567 } 2567 }
2568} 2568}
2569 2569
2570 2570
2571void CalendarView::cancelIncidence(Incidence * inc ) 2571void CalendarView::cancelIncidence(Incidence * inc )
2572{ 2572{
2573 inc->setCancelled( ! inc->cancelled() ); 2573 inc->setCancelled( ! inc->cancelled() );
2574 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 2574 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
2575 updateView(); 2575 updateView();
2576} 2576}
2577void CalendarView::cloneIncidence(Incidence * orgInc ) 2577void CalendarView::cloneIncidence(Incidence * orgInc )
2578{ 2578{
2579 Incidence * newInc = orgInc->clone(); 2579 Incidence * newInc = orgInc->clone();
2580 newInc->recreate(); 2580 newInc->recreate();
2581 2581
2582 if ( newInc->type() == "Todo" ) { 2582 if ( newInc->type() == "Todo" ) {
2583 Todo* t = (Todo*) newInc; 2583 Todo* t = (Todo*) newInc;
2584 showTodoEditor(); 2584 showTodoEditor();
2585 mTodoEditor->editTodo( t ); 2585 mTodoEditor->editTodo( t );
2586 if ( mTodoEditor->exec() ) { 2586 if ( mTodoEditor->exec() ) {
2587 mCalendar->addTodo( t ); 2587 mCalendar->addTodo( t );
2588 updateView(); 2588 updateView();
2589 } else { 2589 } else {
2590 delete t; 2590 delete t;
2591 } 2591 }
2592 } 2592 }
2593 else { 2593 else {
2594 Event* e = (Event*) newInc; 2594 Event* e = (Event*) newInc;
2595 showEventEditor(); 2595 showEventEditor();
2596 mEventEditor->editEvent( e ); 2596 mEventEditor->editEvent( e );
2597 if ( mEventEditor->exec() ) { 2597 if ( mEventEditor->exec() ) {
2598 mCalendar->addEvent( e ); 2598 mCalendar->addEvent( e );
2599 updateView(); 2599 updateView();
2600 } else { 2600 } else {
2601 delete e; 2601 delete e;
2602 } 2602 }
2603 } 2603 }
2604} 2604}
2605 2605
2606void CalendarView::newEvent() 2606void CalendarView::newEvent()
2607{ 2607{
2608 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 2608 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
2609 KOAgendaView *aView = mViewManager->agendaView(); 2609 KOAgendaView *aView = mViewManager->agendaView();
2610 if (aView) { 2610 if (aView) {
2611 if (aView->selectionStart().isValid()) { 2611 if (aView->selectionStart().isValid()) {
2612 if (aView->selectedIsAllDay()) { 2612 if (aView->selectedIsAllDay()) {
2613 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 2613 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
2614 } else { 2614 } else {
2615 newEvent(aView->selectionStart(),aView->selectionEnd()); 2615 newEvent(aView->selectionStart(),aView->selectionEnd());
2616 } 2616 }
2617 return; 2617 return;
2618 } 2618 }
2619 } 2619 }
2620 2620
2621 QDate date = mNavigator->selectedDates().first(); 2621 QDate date = mNavigator->selectedDates().first();
2622 QDateTime current = QDateTime::currentDateTime(); 2622 QDateTime current = QDateTime::currentDateTime();
2623 if ( date <= current.date() ) { 2623 if ( date <= current.date() ) {
2624 int hour = current.time().hour() +1; 2624 int hour = current.time().hour() +1;
2625 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 2625 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
2626 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2626 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2627 } else 2627 } else
2628 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 2628 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
2629 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 2629 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
2630 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2630 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2631} 2631}
2632 2632
2633void CalendarView::newEvent(QDateTime fh) 2633void CalendarView::newEvent(QDateTime fh)
2634{ 2634{
2635 newEvent(fh, 2635 newEvent(fh,
2636 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 2636 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
2637} 2637}
2638 2638
2639void CalendarView::newEvent(QDate dt) 2639void CalendarView::newEvent(QDate dt)
2640{ 2640{
2641 newEvent(QDateTime(dt, QTime(0,0,0)), 2641 newEvent(QDateTime(dt, QTime(0,0,0)),
2642 QDateTime(dt, QTime(0,0,0)), true); 2642 QDateTime(dt, QTime(0,0,0)), true);
2643} 2643}
2644 2644
2645void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 2645void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
2646{ 2646{
2647 2647
2648 showEventEditor(); 2648 showEventEditor();
2649 mEventEditor->newEvent(fromHint,toHint,allDay); 2649 mEventEditor->newEvent(fromHint,toHint,allDay);
2650 if ( mFilterView->filtersEnabled() ) { 2650 if ( mFilterView->filtersEnabled() ) {
2651 CalFilter *filter = mFilterView->selectedFilter(); 2651 CalFilter *filter = mFilterView->selectedFilter();
2652 if (filter && filter->showCategories()) { 2652 if (filter && filter->showCategories()) {
2653 mEventEditor->setCategories(filter->categoryList().join(",") ); 2653 mEventEditor->setCategories(filter->categoryList().join(",") );
2654 } 2654 }
2655 if ( filter ) 2655 if ( filter )
2656 mEventEditor->setSecrecy( filter->getSecrecy() ); 2656 mEventEditor->setSecrecy( filter->getSecrecy() );
2657 } 2657 }
2658} 2658}
2659void CalendarView::todoAdded(Todo * t) 2659void CalendarView::todoAdded(Todo * t)
2660{ 2660{
2661 2661
2662 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 2662 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
2663 updateTodoViews(); 2663 updateTodoViews();
2664} 2664}
2665void CalendarView::todoChanged(Todo * t) 2665void CalendarView::todoChanged(Todo * t)
2666{ 2666{
2667 emit todoModified( t, 4 ); 2667 emit todoModified( t, 4 );
2668 // updateTodoViews(); 2668 // updateTodoViews();
2669} 2669}
2670void CalendarView::todoToBeDeleted(Todo *) 2670void CalendarView::todoToBeDeleted(Todo *)
2671{ 2671{
2672 //qDebug("todoToBeDeleted(Todo *) "); 2672 //qDebug("todoToBeDeleted(Todo *) ");
2673 updateTodoViews(); 2673 updateTodoViews();
2674} 2674}
2675void CalendarView::todoDeleted() 2675void CalendarView::todoDeleted()
2676{ 2676{
2677 //qDebug(" todoDeleted()"); 2677 //qDebug(" todoDeleted()");
2678 updateTodoViews(); 2678 updateTodoViews();
2679} 2679}
2680 2680
2681 2681
2682 2682
2683void CalendarView::newTodo() 2683void CalendarView::newTodo()
2684{ 2684{
2685 2685
2686 showTodoEditor(); 2686 showTodoEditor();
2687 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); 2687 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true);
2688 if ( mFilterView->filtersEnabled() ) { 2688 if ( mFilterView->filtersEnabled() ) {
2689 CalFilter *filter = mFilterView->selectedFilter(); 2689 CalFilter *filter = mFilterView->selectedFilter();
2690 if (filter && filter->showCategories()) { 2690 if (filter && filter->showCategories()) {
2691 mTodoEditor->setCategories(filter->categoryList().join(",") ); 2691 mTodoEditor->setCategories(filter->categoryList().join(",") );
2692 } 2692 }
2693 if ( filter ) 2693 if ( filter )
2694 mTodoEditor->setSecrecy( filter->getSecrecy() ); 2694 mTodoEditor->setSecrecy( filter->getSecrecy() );
2695 } 2695 }
2696} 2696}
2697 2697
2698void CalendarView::newSubTodo() 2698void CalendarView::newSubTodo()
2699{ 2699{
2700 Todo *todo = selectedTodo(); 2700 Todo *todo = selectedTodo();
2701 if ( todo ) newSubTodo( todo ); 2701 if ( todo ) newSubTodo( todo );
2702} 2702}
2703 2703
2704void CalendarView::newSubTodo(Todo *parentEvent) 2704void CalendarView::newSubTodo(Todo *parentEvent)
2705{ 2705{
2706 2706
2707 showTodoEditor(); 2707 showTodoEditor();
2708 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); 2708 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true);
2709} 2709}
2710 2710
2711void CalendarView::newFloatingEvent() 2711void CalendarView::newFloatingEvent()
2712{ 2712{
2713 DateList tmpList = mNavigator->selectedDates(); 2713 DateList tmpList = mNavigator->selectedDates();
2714 QDate date = tmpList.first(); 2714 QDate date = tmpList.first();
2715 2715
2716 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 2716 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
2717 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 2717 QDateTime( date, QTime( 12, 0, 0 ) ), true );
2718} 2718}
2719 2719
2720 2720
2721void CalendarView::editEvent( Event *event ) 2721void CalendarView::editEvent( Event *event )
2722{ 2722{
2723 2723
2724 if ( !event ) return; 2724 if ( !event ) return;
2725 if ( event->isReadOnly() ) { 2725 if ( event->isReadOnly() ) {
2726 showEvent( event ); 2726 showEvent( event );
2727 return; 2727 return;
2728 } 2728 }
2729 showEventEditor(); 2729 showEventEditor();
2730 mEventEditor->editEvent( event , mFlagEditDescription); 2730 mEventEditor->editEvent( event , mFlagEditDescription);
2731} 2731}
2732void CalendarView::editJournal( Journal *jour ) 2732void CalendarView::editJournal( Journal *jour )
2733{ 2733{
2734 if ( !jour ) return; 2734 if ( !jour ) return;
2735 mDialogManager->hideSearchDialog(); 2735 mDialogManager->hideSearchDialog();
2736 mViewManager->showJournalView(); 2736 mViewManager->showJournalView();
2737 mNavigator->slotDaySelect( jour->dtStart().date() ); 2737 mNavigator->slotDaySelect( jour->dtStart().date() );
2738} 2738}
2739void CalendarView::editTodo( Todo *todo ) 2739void CalendarView::editTodo( Todo *todo )
2740{ 2740{
2741 if ( !todo ) return; 2741 if ( !todo ) return;
2742 2742
2743 if ( todo->isReadOnly() ) { 2743 if ( todo->isReadOnly() ) {
2744 showTodo( todo ); 2744 showTodo( todo );
2745 return; 2745 return;
2746 } 2746 }
2747 showTodoEditor(); 2747 showTodoEditor();
2748 mTodoEditor->editTodo( todo ,mFlagEditDescription); 2748 mTodoEditor->editTodo( todo ,mFlagEditDescription);
2749 2749
2750} 2750}
2751 2751
2752KOEventViewerDialog* CalendarView::getEventViewerDialog() 2752KOEventViewerDialog* CalendarView::getEventViewerDialog()
2753{ 2753{
2754 if ( !mEventViewerDialog ) { 2754 if ( !mEventViewerDialog ) {
2755 mEventViewerDialog = new KOEventViewerDialog(this); 2755 mEventViewerDialog = new KOEventViewerDialog(this);
2756 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 2756 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
2757 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 2757 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
2758 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 2758 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
2759 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 2759 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
2760 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 2760 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
2761 viewManager(), SLOT( showAgendaView( bool ) ) ); 2761 viewManager(), SLOT( showAgendaView( bool ) ) );
2762 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), 2762 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ),
2763 this, SLOT( todoChanged(Todo *) ) ); 2763 this, SLOT( todoChanged(Todo *) ) );
2764 mEventViewerDialog->resize( 640, 480 ); 2764 mEventViewerDialog->resize( 640, 480 );
2765 2765
2766 } 2766 }
2767 return mEventViewerDialog; 2767 return mEventViewerDialog;
2768} 2768}
2769void CalendarView::showEvent(Event *event) 2769void CalendarView::showEvent(Event *event)
2770{ 2770{
2771 getEventViewerDialog()->setEvent(event); 2771 getEventViewerDialog()->setEvent(event);
2772 getEventViewerDialog()->showMe(); 2772 getEventViewerDialog()->showMe();
2773} 2773}
2774 2774
2775void CalendarView::showTodo(Todo *event) 2775void CalendarView::showTodo(Todo *event)
2776{ 2776{
2777 getEventViewerDialog()->setTodo(event); 2777 getEventViewerDialog()->setTodo(event);
2778 getEventViewerDialog()->showMe(); 2778 getEventViewerDialog()->showMe();
2779} 2779}
2780void CalendarView::showJournal( Journal *jour ) 2780void CalendarView::showJournal( Journal *jour )
2781{ 2781{
2782 getEventViewerDialog()->setJournal(jour); 2782 getEventViewerDialog()->setJournal(jour);
2783 getEventViewerDialog()->showMe(); 2783 getEventViewerDialog()->showMe();
2784 2784
2785} 2785}
2786// void CalendarView::todoModified (Todo *event, int changed) 2786// void CalendarView::todoModified (Todo *event, int changed)
2787// { 2787// {
2788// // if (mDialogList.find (event) != mDialogList.end ()) { 2788// // if (mDialogList.find (event) != mDialogList.end ()) {
2789// // kdDebug() << "Todo modified and open" << endl; 2789// // kdDebug() << "Todo modified and open" << endl;
2790// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 2790// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
2791// // temp->modified (changed); 2791// // temp->modified (changed);
2792 2792
2793// // } 2793// // }
2794 2794
2795// mViewManager->updateView(); 2795// mViewManager->updateView();
2796// } 2796// }
2797 2797
2798void CalendarView::appointment_show() 2798void CalendarView::appointment_show()
2799{ 2799{
2800 Event *anEvent = 0; 2800 Event *anEvent = 0;
2801 2801
2802 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2802 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2803 2803
2804 if (mViewManager->currentView()->isEventView()) { 2804 if (mViewManager->currentView()->isEventView()) {
2805 if ( incidence && incidence->type() == "Event" ) { 2805 if ( incidence && incidence->type() == "Event" ) {
2806 anEvent = static_cast<Event *>(incidence); 2806 anEvent = static_cast<Event *>(incidence);
2807 } 2807 }
2808 } 2808 }
2809 2809
2810 if (!anEvent) { 2810 if (!anEvent) {
2811 KNotifyClient::beep(); 2811 KNotifyClient::beep();
2812 return; 2812 return;
2813 } 2813 }
2814 2814
2815 showEvent(anEvent); 2815 showEvent(anEvent);
2816} 2816}
2817 2817
2818void CalendarView::appointment_edit() 2818void CalendarView::appointment_edit()
2819{ 2819{
2820 Event *anEvent = 0; 2820 Event *anEvent = 0;
2821 2821
2822 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2822 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2823 2823
2824 if (mViewManager->currentView()->isEventView()) { 2824 if (mViewManager->currentView()->isEventView()) {
2825 if ( incidence && incidence->type() == "Event" ) { 2825 if ( incidence && incidence->type() == "Event" ) {
2826 anEvent = static_cast<Event *>(incidence); 2826 anEvent = static_cast<Event *>(incidence);
2827 } 2827 }
2828 } 2828 }
2829 2829
2830 if (!anEvent) { 2830 if (!anEvent) {
2831 KNotifyClient::beep(); 2831 KNotifyClient::beep();
2832 return; 2832 return;
2833 } 2833 }
2834 2834
2835 editEvent(anEvent); 2835 editEvent(anEvent);
2836} 2836}
2837 2837
2838void CalendarView::appointment_delete() 2838void CalendarView::appointment_delete()
2839{ 2839{
2840 Event *anEvent = 0; 2840 Event *anEvent = 0;
2841 2841
2842 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2842 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2843 2843
2844 if (mViewManager->currentView()->isEventView()) { 2844 if (mViewManager->currentView()->isEventView()) {
2845 if ( incidence && incidence->type() == "Event" ) { 2845 if ( incidence && incidence->type() == "Event" ) {
2846 anEvent = static_cast<Event *>(incidence); 2846 anEvent = static_cast<Event *>(incidence);
2847 } 2847 }
2848 } 2848 }
2849 2849
2850 if (!anEvent) { 2850 if (!anEvent) {
2851 KNotifyClient::beep(); 2851 KNotifyClient::beep();
2852 return; 2852 return;
2853 } 2853 }
2854 2854
2855 deleteEvent(anEvent); 2855 deleteEvent(anEvent);
2856} 2856}
2857 2857
2858void CalendarView::todo_resub( Todo * parent, Todo * sub ) 2858void CalendarView::todo_resub( Todo * parent, Todo * sub )
2859{ 2859{
2860 if (!sub) return; 2860 if (!sub) return;
2861 if (!parent) return; 2861 if (!parent) return;
2862 if ( sub->relatedTo() ) 2862 if ( sub->relatedTo() )
2863 sub->relatedTo()->removeRelation(sub); 2863 sub->relatedTo()->removeRelation(sub);
2864 sub->setRelatedTo(parent); 2864 sub->setRelatedTo(parent);
2865 sub->setRelatedToUid(parent->uid()); 2865 sub->setRelatedToUid(parent->uid());
2866 parent->addRelation(sub); 2866 parent->addRelation(sub);
2867 sub->updated(); 2867 sub->updated();
2868 parent->updated(); 2868 parent->updated();
2869 setModified(true); 2869 setModified(true);
2870 updateView(); 2870 updateView();
2871} 2871}
2872void CalendarView::todo_unsub(Todo *anTodo ) 2872void CalendarView::todo_unsub(Todo *anTodo )
2873{ 2873{
2874 // Todo *anTodo = selectedTodo(); 2874 // Todo *anTodo = selectedTodo();
2875 if (!anTodo) return; 2875 if (!anTodo) return;
2876 if (!anTodo->relatedTo()) return; 2876 if (!anTodo->relatedTo()) return;
2877 anTodo->relatedTo()->removeRelation(anTodo); 2877 anTodo->relatedTo()->removeRelation(anTodo);
2878 anTodo->setRelatedTo(0); 2878 anTodo->setRelatedTo(0);
2879 anTodo->updated(); 2879 anTodo->updated();
2880 anTodo->setRelatedToUid(""); 2880 anTodo->setRelatedToUid("");
2881 setModified(true); 2881 setModified(true);
2882 updateView(); 2882 updateView();
2883} 2883}
2884 2884
2885void CalendarView::deleteTodo(Todo *todo) 2885void CalendarView::deleteTodo(Todo *todo)
2886{ 2886{
2887 if (!todo) { 2887 if (!todo) {
2888 KNotifyClient::beep(); 2888 KNotifyClient::beep();
2889 return; 2889 return;
2890 } 2890 }
2891 if (KOPrefs::instance()->mConfirm) { 2891 if (KOPrefs::instance()->mConfirm) {
2892 QString text = todo->summary().left(20); 2892 QString text = todo->summary().left(20);
2893 if (!todo->relations().isEmpty()) { 2893 if (!todo->relations().isEmpty()) {
2894 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); 2894 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!");
2895 2895
2896 } 2896 }
2897 switch (msgItemDelete(text)) { 2897 switch (msgItemDelete(text)) {
2898 case KMessageBox::Continue: // OK 2898 case KMessageBox::Continue: // OK
2899 bool deleteT = false; 2899 bool deleteT = false;
2900 if (!todo->relations().isEmpty()) { 2900 if (!todo->relations().isEmpty()) {
2901 deleteT = removeCompletedSubTodos( todo ); 2901 deleteT = removeCompletedSubTodos( todo );
2902 } 2902 }
2903 // deleteT == true: todo already deleted in removeCompletedSubTodos 2903 // deleteT == true: todo already deleted in removeCompletedSubTodos
2904 if ( !deleteT ) { 2904 if ( !deleteT ) {
2905 checkExternalId( todo ); 2905 checkExternalId( todo );
2906 calendar()->deleteTodo(todo); 2906 calendar()->deleteTodo(todo);
2907 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2907 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2908 updateView(); 2908 updateView();
2909 } 2909 }
2910 break; 2910 break;
2911 } // switch 2911 } // switch
2912 } else { 2912 } else {
2913 checkExternalId( todo ); 2913 checkExternalId( todo );
2914 mCalendar->deleteTodo(todo); 2914 mCalendar->deleteTodo(todo);
2915 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2915 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2916 updateView(); 2916 updateView();
2917 } 2917 }
2918 2918
2919 emit updateSearchDialog(); 2919 emit updateSearchDialog();
2920} 2920}
2921void CalendarView::deleteJournal(Journal *jour) 2921void CalendarView::deleteJournal(Journal *jour)
2922{ 2922{
2923 if (!jour) { 2923 if (!jour) {
2924 KNotifyClient::beep(); 2924 KNotifyClient::beep();
2925 return; 2925 return;
2926 } 2926 }
2927 if (KOPrefs::instance()->mConfirm) { 2927 if (KOPrefs::instance()->mConfirm) {
2928 switch (msgItemDelete( jour->description().left(20))) { 2928 switch (msgItemDelete( jour->description().left(20))) {
2929 case KMessageBox::Continue: // OK 2929 case KMessageBox::Continue: // OK
2930 calendar()->deleteJournal(jour); 2930 calendar()->deleteJournal(jour);
2931 updateView(); 2931 updateView();
2932 break; 2932 break;
2933 } // switch 2933 } // switch
2934 } else { 2934 } else {
2935 calendar()->deleteJournal(jour);; 2935 calendar()->deleteJournal(jour);;
2936 updateView(); 2936 updateView();
2937 } 2937 }
2938 emit updateSearchDialog(); 2938 emit updateSearchDialog();
2939} 2939}
2940 2940
2941void CalendarView::deleteEvent(Event *anEvent) 2941void CalendarView::deleteEvent(Event *anEvent)
2942{ 2942{
2943 if (!anEvent) { 2943 if (!anEvent) {
2944 KNotifyClient::beep(); 2944 KNotifyClient::beep();
2945 return; 2945 return;
2946 } 2946 }
2947 2947
2948 if (anEvent->recurrence()->doesRecur()) { 2948 if (anEvent->recurrence()->doesRecur()) {
2949 QDate itemDate = mViewManager->currentSelectionDate(); 2949 QDate itemDate = mViewManager->currentSelectionDate();
2950 int km; 2950 int km;
2951 if (!itemDate.isValid()) { 2951 if (!itemDate.isValid()) {
2952 //kdDebug() << "Date Not Valid" << endl; 2952 //kdDebug() << "Date Not Valid" << endl;
2953 if (KOPrefs::instance()->mConfirm) { 2953 if (KOPrefs::instance()->mConfirm) {
2954 km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + 2954 km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) +
2955 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), 2955 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"),
2956 i18n("KO/Pi Confirmation"),i18n("Delete All")); 2956 i18n("KO/Pi Confirmation"),i18n("Delete All"));
2957 if ( km == KMessageBox::Continue ) 2957 if ( km == KMessageBox::Continue )
2958 km = KMessageBox::No; // No = all below 2958 km = KMessageBox::No; // No = all below
2959 } else 2959 } else
2960 km = KMessageBox::No; 2960 km = KMessageBox::No;
2961 } else { 2961 } else {
2962 km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + 2962 km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) +
2963 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ 2963 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+
2964 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), 2964 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"),
2965 i18n("KO/Pi Confirmation"),i18n("Current"), 2965 i18n("KO/Pi Confirmation"),i18n("Current"),
2966 i18n("All")); 2966 i18n("All"));
2967 } 2967 }
2968 switch(km) { 2968 switch(km) {
2969 2969
2970 case KMessageBox::No: // Continue // all 2970 case KMessageBox::No: // Continue // all
2971 //qDebug("KMessageBox::No "); 2971 //qDebug("KMessageBox::No ");
2972 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2972 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2973 schedule(Scheduler::Cancel,anEvent); 2973 schedule(Scheduler::Cancel,anEvent);
2974 2974
2975 checkExternalId( anEvent); 2975 checkExternalId( anEvent);
2976 mCalendar->deleteEvent(anEvent); 2976 mCalendar->deleteEvent(anEvent);
2977 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); 2977 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED);
2978 break; 2978 break;
2979 2979
2980 // Disabled because it does not work 2980 // Disabled because it does not work
2981 //#if 0 2981 //#if 0
2982 case KMessageBox::Yes: // just this one 2982 case KMessageBox::Yes: // just this one
2983 //QDate qd = mNavigator->selectedDates().first(); 2983 //QDate qd = mNavigator->selectedDates().first();
2984 //if (!qd.isValid()) { 2984 //if (!qd.isValid()) {
2985 // kdDebug() << "no date selected, or invalid date" << endl; 2985 // kdDebug() << "no date selected, or invalid date" << endl;
2986 // KNotifyClient::beep(); 2986 // KNotifyClient::beep();
2987 // return; 2987 // return;
2988 //} 2988 //}
2989 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); 2989 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1);
2990 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { 2990 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) {
2991 anEvent->addExDate(itemDate); 2991 anEvent->addExDate(itemDate);
2992 int duration = anEvent->recurrence()->duration(); 2992 int duration = anEvent->recurrence()->duration();
2993 if ( duration > 0 ) { 2993 if ( duration > 0 ) {
2994 anEvent->recurrence()->setDuration( duration - 1 ); 2994 anEvent->recurrence()->setDuration( duration - 1 );
2995 } 2995 }
2996 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); 2996 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED);
2997 } 2997 }
2998 break; 2998 break;
2999 //#endif 2999 //#endif
3000 } // switch 3000 } // switch
3001 } else { 3001 } else {
3002 if (KOPrefs::instance()->mConfirm) { 3002 if (KOPrefs::instance()->mConfirm) {
3003 switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + 3003 switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) +
3004 i18n("\nAre you sure you want\nto delete this event?"), 3004 i18n("\nAre you sure you want\nto delete this event?"),
3005 i18n("KO/Pi Confirmation"),i18n("Delete"))) { 3005 i18n("KO/Pi Confirmation"),i18n("Delete"))) {
3006 case KMessageBox::Continue: // OK 3006 case KMessageBox::Continue: // OK
3007 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3007 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3008 schedule(Scheduler::Cancel,anEvent); 3008 schedule(Scheduler::Cancel,anEvent);
3009 checkExternalId( anEvent); 3009 checkExternalId( anEvent);
3010 mCalendar->deleteEvent(anEvent); 3010 mCalendar->deleteEvent(anEvent);
3011 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3011 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3012 break; 3012 break;
3013 } // switch 3013 } // switch
3014 } else { 3014 } else {
3015 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3015 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3016 schedule(Scheduler::Cancel,anEvent); 3016 schedule(Scheduler::Cancel,anEvent);
3017 checkExternalId( anEvent); 3017 checkExternalId( anEvent);
3018 mCalendar->deleteEvent(anEvent); 3018 mCalendar->deleteEvent(anEvent);
3019 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3019 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3020 } 3020 }
3021 } // if-else 3021 } // if-else
3022 emit updateSearchDialog(); 3022 emit updateSearchDialog();
3023} 3023}
3024 3024
3025bool CalendarView::deleteEvent(const QString &uid) 3025bool CalendarView::deleteEvent(const QString &uid)
3026{ 3026{
3027 Event *ev = mCalendar->event(uid); 3027 Event *ev = mCalendar->event(uid);
3028 if (ev) { 3028 if (ev) {
3029 deleteEvent(ev); 3029 deleteEvent(ev);
3030 return true; 3030 return true;
3031 } else { 3031 } else {
3032 return false; 3032 return false;
3033 } 3033 }
3034} 3034}
3035 3035
3036/*****************************************************************************/ 3036/*****************************************************************************/
3037 3037
3038void CalendarView::action_mail() 3038void CalendarView::action_mail()
3039{ 3039{
3040#ifndef KORG_NOMAIL 3040#ifndef KORG_NOMAIL
3041 KOMailClient mailClient; 3041 KOMailClient mailClient;
3042 3042
3043 Incidence *incidence = currentSelection(); 3043 Incidence *incidence = currentSelection();
3044 3044
3045 if (!incidence) { 3045 if (!incidence) {
3046 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3046 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3047 return; 3047 return;
3048 } 3048 }
3049 if(incidence->attendeeCount() == 0 ) { 3049 if(incidence->attendeeCount() == 0 ) {
3050 KMessageBox::sorry(this, 3050 KMessageBox::sorry(this,
3051 i18n("Can't generate mail:\nNo attendees defined.\n")); 3051 i18n("Can't generate mail:\nNo attendees defined.\n"));
3052 return; 3052 return;
3053 } 3053 }
3054 3054
3055 CalendarLocal cal_tmp; 3055 CalendarLocal cal_tmp;
3056 Event *event = 0; 3056 Event *event = 0;
3057 Event *ev = 0; 3057 Event *ev = 0;
3058 if ( incidence && incidence->type() == "Event" ) { 3058 if ( incidence && incidence->type() == "Event" ) {
3059 event = static_cast<Event *>(incidence); 3059 event = static_cast<Event *>(incidence);
3060 ev = new Event(*event); 3060 ev = new Event(*event);
3061 cal_tmp.addEvent(ev); 3061 cal_tmp.addEvent(ev);
3062 } 3062 }
3063 ICalFormat mForm(); 3063 ICalFormat mForm();
3064 QString attachment = mForm.toString( &cal_tmp ); 3064 QString attachment = mForm.toString( &cal_tmp );
3065 if (ev) delete(ev); 3065 if (ev) delete(ev);
3066 3066
3067 mailClient.mailAttendees(currentSelection(), attachment); 3067 mailClient.mailAttendees(currentSelection(), attachment);
3068 3068
3069#endif 3069#endif
3070 3070
3071#if 0 3071#if 0
3072 Event *anEvent = 0; 3072 Event *anEvent = 0;
3073 if (mViewManager->currentView()->isEventView()) { 3073 if (mViewManager->currentView()->isEventView()) {
3074 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); 3074 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first());
3075 } 3075 }
3076 3076
3077 if (!anEvent) { 3077 if (!anEvent) {
3078 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3078 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3079 return; 3079 return;
3080 } 3080 }
3081 if(anEvent->attendeeCount() == 0 ) { 3081 if(anEvent->attendeeCount() == 0 ) {
3082 KMessageBox::sorry(this, 3082 KMessageBox::sorry(this,
3083 i18n("Can't generate mail:\nNo attendees defined.\n")); 3083 i18n("Can't generate mail:\nNo attendees defined.\n"));
3084 return; 3084 return;
3085 } 3085 }
3086 3086
3087 mailobject.emailEvent(anEvent); 3087 mailobject.emailEvent(anEvent);
3088#endif 3088#endif
3089} 3089}
3090 3090
3091 3091
3092void CalendarView::schedule_publish(Incidence *incidence) 3092void CalendarView::schedule_publish(Incidence *incidence)
3093{ 3093{
3094 Event *event = 0; 3094 Event *event = 0;
3095 Todo *todo = 0; 3095 Todo *todo = 0;
3096 3096
3097 if (incidence == 0) { 3097 if (incidence == 0) {
3098 incidence = mViewManager->currentView()->selectedIncidences().first(); 3098 incidence = mViewManager->currentView()->selectedIncidences().first();
3099 if (incidence == 0) { 3099 if (incidence == 0) {
3100 incidence = mTodoList->selectedIncidences().first(); 3100 incidence = mTodoList->selectedIncidences().first();
3101 } 3101 }
3102 } 3102 }
3103 if ( incidence && incidence->type() == "Event" ) { 3103 if ( incidence && incidence->type() == "Event" ) {
3104 event = static_cast<Event *>(incidence); 3104 event = static_cast<Event *>(incidence);
3105 } else { 3105 } else {
3106 if ( incidence && incidence->type() == "Todo" ) { 3106 if ( incidence && incidence->type() == "Todo" ) {
3107 todo = static_cast<Todo *>(incidence); 3107 todo = static_cast<Todo *>(incidence);
3108 } 3108 }
3109 } 3109 }
3110 3110
3111 if (!event && !todo) { 3111 if (!event && !todo) {
3112 KMessageBox::sorry(this,i18n("No event selected.")); 3112 KMessageBox::sorry(this,i18n("No event selected."));
3113 return; 3113 return;
3114 } 3114 }
3115 3115
3116 PublishDialog *publishdlg = new PublishDialog(); 3116 PublishDialog *publishdlg = new PublishDialog();
3117 if (incidence->attendeeCount()>0) { 3117 if (incidence->attendeeCount()>0) {
3118 QPtrList<Attendee> attendees = incidence->attendees(); 3118 QPtrList<Attendee> attendees = incidence->attendees();
3119 attendees.first(); 3119 attendees.first();
3120 while ( attendees.current()!=0 ) { 3120 while ( attendees.current()!=0 ) {
3121 publishdlg->addAttendee(attendees.current()); 3121 publishdlg->addAttendee(attendees.current());
3122 attendees.next(); 3122 attendees.next();
3123 } 3123 }
3124 } 3124 }
3125 bool send = true; 3125 bool send = true;
3126 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { 3126 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) {
3127 if ( publishdlg->exec() != QDialog::Accepted ) 3127 if ( publishdlg->exec() != QDialog::Accepted )
3128 send = false; 3128 send = false;
3129 } 3129 }
3130 if ( send ) { 3130 if ( send ) {
3131 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3131 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3132 if ( event ) { 3132 if ( event ) {
3133 Event *ev = new Event(*event); 3133 Event *ev = new Event(*event);
3134 ev->registerObserver(0); 3134 ev->registerObserver(0);
3135 ev->clearAttendees(); 3135 ev->clearAttendees();
3136 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3136 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3137 delete(ev); 3137 delete(ev);
3138 } 3138 }
3139 } else { 3139 } else {
3140 if ( todo ) { 3140 if ( todo ) {
3141 Todo *ev = new Todo(*todo); 3141 Todo *ev = new Todo(*todo);
3142 ev->registerObserver(0); 3142 ev->registerObserver(0);
3143 ev->clearAttendees(); 3143 ev->clearAttendees();
3144 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3144 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3145 delete(ev); 3145 delete(ev);
3146 } 3146 }
3147 } 3147 }
3148 } 3148 }
3149 } 3149 }
3150 delete publishdlg; 3150 delete publishdlg;
3151} 3151}
3152 3152
3153void CalendarView::schedule_request(Incidence *incidence) 3153void CalendarView::schedule_request(Incidence *incidence)
3154{ 3154{
3155 schedule(Scheduler::Request,incidence); 3155 schedule(Scheduler::Request,incidence);
3156} 3156}
3157 3157
3158void CalendarView::schedule_refresh(Incidence *incidence) 3158void CalendarView::schedule_refresh(Incidence *incidence)
3159{ 3159{
3160 schedule(Scheduler::Refresh,incidence); 3160 schedule(Scheduler::Refresh,incidence);
3161} 3161}
3162 3162
3163void CalendarView::schedule_cancel(Incidence *incidence) 3163void CalendarView::schedule_cancel(Incidence *incidence)
3164{ 3164{
3165 schedule(Scheduler::Cancel,incidence); 3165 schedule(Scheduler::Cancel,incidence);
3166} 3166}
3167 3167
3168void CalendarView::schedule_add(Incidence *incidence) 3168void CalendarView::schedule_add(Incidence *incidence)
3169{ 3169{
3170 schedule(Scheduler::Add,incidence); 3170 schedule(Scheduler::Add,incidence);
3171} 3171}
3172 3172
3173void CalendarView::schedule_reply(Incidence *incidence) 3173void CalendarView::schedule_reply(Incidence *incidence)
3174{ 3174{
3175 schedule(Scheduler::Reply,incidence); 3175 schedule(Scheduler::Reply,incidence);
3176} 3176}
3177 3177
3178void CalendarView::schedule_counter(Incidence *incidence) 3178void CalendarView::schedule_counter(Incidence *incidence)
3179{ 3179{
3180 schedule(Scheduler::Counter,incidence); 3180 schedule(Scheduler::Counter,incidence);
3181} 3181}
3182 3182
3183void CalendarView::schedule_declinecounter(Incidence *incidence) 3183void CalendarView::schedule_declinecounter(Incidence *incidence)
3184{ 3184{
3185 schedule(Scheduler::Declinecounter,incidence); 3185 schedule(Scheduler::Declinecounter,incidence);
3186} 3186}
3187 3187
3188void CalendarView::schedule_publish_freebusy(int daysToPublish) 3188void CalendarView::schedule_publish_freebusy(int daysToPublish)
3189{ 3189{
3190 QDateTime start = QDateTime::currentDateTime(); 3190 QDateTime start = QDateTime::currentDateTime();
3191 QDateTime end = start.addDays(daysToPublish); 3191 QDateTime end = start.addDays(daysToPublish);
3192 3192
3193 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); 3193 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end);
3194 freebusy->setOrganizer(KOPrefs::instance()->email()); 3194 freebusy->setOrganizer(KOPrefs::instance()->email());
3195 3195
3196 3196
3197 PublishDialog *publishdlg = new PublishDialog(); 3197 PublishDialog *publishdlg = new PublishDialog();
3198 if ( publishdlg->exec() == QDialog::Accepted ) { 3198 if ( publishdlg->exec() == QDialog::Accepted ) {
3199 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3199 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3200 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { 3200 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) {
3201 delete(freebusy); 3201 delete(freebusy);
3202 } 3202 }
3203 } 3203 }
3204 delete publishdlg; 3204 delete publishdlg;
3205} 3205}
3206 3206
3207void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) 3207void CalendarView::schedule(Scheduler::Method method, Incidence *incidence)
3208{ 3208{
3209 Event *event = 0; 3209 Event *event = 0;
3210 Todo *todo = 0; 3210 Todo *todo = 0;
3211 3211
3212 if (incidence == 0) { 3212 if (incidence == 0) {
3213 incidence = mViewManager->currentView()->selectedIncidences().first(); 3213 incidence = mViewManager->currentView()->selectedIncidences().first();
3214 if (incidence == 0) { 3214 if (incidence == 0) {
3215 incidence = mTodoList->selectedIncidences().first(); 3215 incidence = mTodoList->selectedIncidences().first();
3216 } 3216 }
3217 } 3217 }
3218 if ( incidence && incidence->type() == "Event" ) { 3218 if ( incidence && incidence->type() == "Event" ) {
3219 event = static_cast<Event *>(incidence); 3219 event = static_cast<Event *>(incidence);
3220 } 3220 }
3221 if ( incidence && incidence->type() == "Todo" ) { 3221 if ( incidence && incidence->type() == "Todo" ) {
3222 todo = static_cast<Todo *>(incidence); 3222 todo = static_cast<Todo *>(incidence);
3223 } 3223 }
3224 3224
3225 if (!event && !todo) { 3225 if (!event && !todo) {
3226 KMessageBox::sorry(this,i18n("No event selected.")); 3226 KMessageBox::sorry(this,i18n("No event selected."));
3227 return; 3227 return;
3228 } 3228 }
3229 3229
3230 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { 3230 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) {
3231 KMessageBox::sorry(this,i18n("The event has no attendees.")); 3231 KMessageBox::sorry(this,i18n("The event has no attendees."));
3232 return; 3232 return;
3233 } 3233 }
3234 3234
3235 Event *ev = 0; 3235 Event *ev = 0;
3236 if (event) ev = new Event(*event); 3236 if (event) ev = new Event(*event);
3237 Todo *to = 0; 3237 Todo *to = 0;
3238 if (todo) to = new Todo(*todo); 3238 if (todo) to = new Todo(*todo);
3239 3239
3240 if (method == Scheduler::Reply || method == Scheduler::Refresh) { 3240 if (method == Scheduler::Reply || method == Scheduler::Refresh) {
3241 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 3241 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
3242 if (!me) { 3242 if (!me) {
3243 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); 3243 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails."));
3244 return; 3244 return;
3245 } 3245 }
3246 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { 3246 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) {
3247 StatusDialog *statdlg = new StatusDialog(this); 3247 StatusDialog *statdlg = new StatusDialog(this);
3248 if (!statdlg->exec()==QDialog::Accepted) return; 3248 if (!statdlg->exec()==QDialog::Accepted) return;
3249 me->setStatus( statdlg->status() ); 3249 me->setStatus( statdlg->status() );
3250 delete(statdlg); 3250 delete(statdlg);
3251 } 3251 }
3252 Attendee *menew = new Attendee(*me); 3252 Attendee *menew = new Attendee(*me);
3253 if (ev) { 3253 if (ev) {
3254 ev->clearAttendees(); 3254 ev->clearAttendees();
3255 ev->addAttendee(menew,false); 3255 ev->addAttendee(menew,false);
3256 } else { 3256 } else {
3257 if (to) { 3257 if (to) {
3258 todo->clearAttendees(); 3258 todo->clearAttendees();
3259 todo->addAttendee(menew,false); 3259 todo->addAttendee(menew,false);
3260 } 3260 }
3261 } 3261 }
3262 } 3262 }
3263 3263
3264 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3264 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3265 if (ev) { 3265 if (ev) {
3266 if ( !dlg->addMessage(ev,method) ) delete(ev); 3266 if ( !dlg->addMessage(ev,method) ) delete(ev);
3267 } else { 3267 } else {
3268 if (to) { 3268 if (to) {
3269 if ( !dlg->addMessage(to,method) ) delete(to); 3269 if ( !dlg->addMessage(to,method) ) delete(to);
3270 } 3270 }
3271 } 3271 }
3272} 3272}
3273 3273
3274void CalendarView::openAddressbook() 3274void CalendarView::openAddressbook()
3275{ 3275{
3276 KRun::runCommand("kaddressbook"); 3276 KRun::runCommand("kaddressbook");
3277} 3277}
3278 3278
3279void CalendarView::setModified(bool modified) 3279void CalendarView::setModified(bool modified)
3280{ 3280{
3281 if ( modified ) 3281 if ( modified )
3282 emit signalmodified(); 3282 emit signalmodified();
3283 if (mModified != modified) { 3283 if (mModified != modified) {
3284 mModified = modified; 3284 mModified = modified;
3285 emit modifiedChanged(mModified); 3285 emit modifiedChanged(mModified);
3286 } 3286 }
3287} 3287}
3288 3288
3289bool CalendarView::isReadOnly() 3289bool CalendarView::isReadOnly()
3290{ 3290{
3291 return mReadOnly; 3291 return mReadOnly;
3292} 3292}
3293 3293
3294void CalendarView::setReadOnly(bool readOnly) 3294void CalendarView::setReadOnly(bool readOnly)
3295{ 3295{
3296 if (mReadOnly != readOnly) { 3296 if (mReadOnly != readOnly) {
3297 mReadOnly = readOnly; 3297 mReadOnly = readOnly;
3298 emit readOnlyChanged(mReadOnly); 3298 emit readOnlyChanged(mReadOnly);
3299 } 3299 }
3300} 3300}
3301 3301
3302bool CalendarView::isModified() 3302bool CalendarView::isModified()
3303{ 3303{
3304 return mModified; 3304 return mModified;
3305} 3305}
3306 3306
3307void CalendarView::printSetup() 3307void CalendarView::printSetup()
3308{ 3308{
3309#ifndef KORG_NOPRINTER 3309#ifndef KORG_NOPRINTER
3310 createPrinter(); 3310 createPrinter();
3311 3311
3312 mCalPrinter->setupPrinter(); 3312 mCalPrinter->setupPrinter();
3313#endif 3313#endif
3314} 3314}
3315 3315
3316void CalendarView::print() 3316void CalendarView::print()
3317{ 3317{
3318#ifndef KORG_NOPRINTER 3318#ifndef KORG_NOPRINTER
3319 createPrinter(); 3319 createPrinter();
3320 3320
3321 DateList tmpDateList = mNavigator->selectedDates(); 3321 DateList tmpDateList = mNavigator->selectedDates();
3322 mCalPrinter->print(CalPrinter::Month, 3322 mCalPrinter->print(CalPrinter::Month,
3323 tmpDateList.first(), tmpDateList.last()); 3323 tmpDateList.first(), tmpDateList.last());
3324#endif 3324#endif
3325} 3325}
3326 3326
3327void CalendarView::printPreview() 3327void CalendarView::printPreview()
3328{ 3328{
3329#ifndef KORG_NOPRINTER 3329#ifndef KORG_NOPRINTER
3330 kdDebug() << "CalendarView::printPreview()" << endl; 3330 kdDebug() << "CalendarView::printPreview()" << endl;
3331 3331
3332 createPrinter(); 3332 createPrinter();
3333 3333
3334 DateList tmpDateList = mNavigator->selectedDates(); 3334 DateList tmpDateList = mNavigator->selectedDates();
3335 3335
3336 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), 3336 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(),
3337 tmpDateList.last()); 3337 tmpDateList.last());
3338#endif 3338#endif
3339} 3339}
3340 3340
3341void CalendarView::exportICalendar() 3341void CalendarView::exportICalendar()
3342{ 3342{
3343 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); 3343 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this);
3344 3344
3345 // Force correct extension 3345 // Force correct extension
3346 if (filename.right(4) != ".ics") filename += ".ics"; 3346 if (filename.right(4) != ".ics") filename += ".ics";
3347 3347
3348 FileStorage storage( mCalendar, filename, new ICalFormat() ); 3348 FileStorage storage( mCalendar, filename, new ICalFormat() );
3349 storage.save(); 3349 storage.save();
3350} 3350}
3351 3351
3352bool CalendarView::exportVCalendar( QString filename ) 3352bool CalendarView::exportVCalendar( QString filename )
3353{ 3353{
3354 if (mCalendar->journals().count() > 0) { 3354 if (mCalendar->journals().count() > 0) {
3355 int result = KMessageBox::warningContinueCancel(this, 3355 int result = KMessageBox::warningContinueCancel(this,
3356 i18n("The journal entries can not be\nexported to a vCalendar file."), 3356 i18n("The journal entries can not be\nexported to a vCalendar file."),
3357 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 3357 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
3358 true); 3358 true);
3359 if (result != KMessageBox::Continue) return false; 3359 if (result != KMessageBox::Continue) return false;
3360 } 3360 }
3361 3361
3362 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); 3362 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this);
3363 3363
3364 // Force correct extension 3364 // Force correct extension
3365 if (filename.right(4) != ".vcs") filename += ".vcs"; 3365 if (filename.right(4) != ".vcs") filename += ".vcs";
3366 3366
3367 FileStorage storage( mCalendar, filename, new VCalFormat ); 3367 FileStorage storage( mCalendar, filename, new VCalFormat );
3368 return storage.save(); 3368 return storage.save();
3369 3369
3370} 3370}
3371 3371
3372void CalendarView::eventUpdated(Incidence *) 3372void CalendarView::eventUpdated(Incidence *)
3373{ 3373{
3374 setModified(); 3374 setModified();
3375 // Don't call updateView here. The code, which has caused the update of the 3375 // Don't call updateView here. The code, which has caused the update of the
3376 // event is responsible for updating the view. 3376 // event is responsible for updating the view.
3377 // updateView(); 3377 // updateView();
3378} 3378}
3379 3379
3380void CalendarView::adaptNavigationUnits() 3380void CalendarView::adaptNavigationUnits()
3381{ 3381{
3382 if (mViewManager->currentView()->isEventView()) { 3382 if (mViewManager->currentView()->isEventView()) {
3383 int days = mViewManager->currentView()->currentDateCount(); 3383 int days = mViewManager->currentView()->currentDateCount();
3384 if (days == 1) { 3384 if (days == 1) {
3385 emit changeNavStringPrev(i18n("&Previous Day")); 3385 emit changeNavStringPrev(i18n("&Previous Day"));
3386 emit changeNavStringNext(i18n("&Next Day")); 3386 emit changeNavStringNext(i18n("&Next Day"));
3387 } else { 3387 } else {
3388 emit changeNavStringPrev(i18n("&Previous Week")); 3388 emit changeNavStringPrev(i18n("&Previous Week"));
3389 emit changeNavStringNext(i18n("&Next Week")); 3389 emit changeNavStringNext(i18n("&Next Week"));
3390 } 3390 }
3391 } 3391 }
3392} 3392}
3393 3393
3394void CalendarView::processMainViewSelection( Incidence *incidence ) 3394void CalendarView::processMainViewSelection( Incidence *incidence )
3395{ 3395{
3396 if ( incidence ) mTodoList->clearSelection(); 3396 if ( incidence ) mTodoList->clearSelection();
3397 processIncidenceSelection( incidence ); 3397 processIncidenceSelection( incidence );
3398} 3398}
3399 3399
3400void CalendarView::processTodoListSelection( Incidence *incidence ) 3400void CalendarView::processTodoListSelection( Incidence *incidence )
3401{ 3401{
3402 if ( incidence && mViewManager->currentView() ) { 3402 if ( incidence && mViewManager->currentView() ) {
3403 mViewManager->currentView()->clearSelection(); 3403 mViewManager->currentView()->clearSelection();
3404 } 3404 }
3405 processIncidenceSelection( incidence ); 3405 processIncidenceSelection( incidence );
3406} 3406}
3407 3407
3408void CalendarView::processIncidenceSelection( Incidence *incidence ) 3408void CalendarView::processIncidenceSelection( Incidence *incidence )
3409{ 3409{
3410 if ( incidence == mSelectedIncidence ) return; 3410 if ( incidence == mSelectedIncidence ) return;
3411 3411
3412 mSelectedIncidence = incidence; 3412 mSelectedIncidence = incidence;
3413 3413
3414 emit incidenceSelected( mSelectedIncidence ); 3414 emit incidenceSelected( mSelectedIncidence );
3415 3415
3416 if ( incidence && incidence->type() == "Event" ) { 3416 if ( incidence && incidence->type() == "Event" ) {
3417 Event *event = static_cast<Event *>( incidence ); 3417 Event *event = static_cast<Event *>( incidence );
3418 if ( event->organizer() == KOPrefs::instance()->email() ) { 3418 if ( event->organizer() == KOPrefs::instance()->email() ) {
3419 emit organizerEventsSelected( true ); 3419 emit organizerEventsSelected( true );
3420 } else { 3420 } else {
3421 emit organizerEventsSelected(false); 3421 emit organizerEventsSelected(false);
3422 } 3422 }
3423 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3423 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3424 KOPrefs::instance()->email() ) ) { 3424 KOPrefs::instance()->email() ) ) {
3425 emit groupEventsSelected( true ); 3425 emit groupEventsSelected( true );
3426 } else { 3426 } else {
3427 emit groupEventsSelected(false); 3427 emit groupEventsSelected(false);
3428 } 3428 }
3429 return; 3429 return;
3430 } else { 3430 } else {
3431 if ( incidence && incidence->type() == "Todo" ) { 3431 if ( incidence && incidence->type() == "Todo" ) {
3432 emit todoSelected( true ); 3432 emit todoSelected( true );
3433 Todo *event = static_cast<Todo *>( incidence ); 3433 Todo *event = static_cast<Todo *>( incidence );
3434 if ( event->organizer() == KOPrefs::instance()->email() ) { 3434 if ( event->organizer() == KOPrefs::instance()->email() ) {
3435 emit organizerEventsSelected( true ); 3435 emit organizerEventsSelected( true );
3436 } else { 3436 } else {
3437 emit organizerEventsSelected(false); 3437 emit organizerEventsSelected(false);
3438 } 3438 }
3439 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3439 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3440 KOPrefs::instance()->email() ) ) { 3440 KOPrefs::instance()->email() ) ) {
3441 emit groupEventsSelected( true ); 3441 emit groupEventsSelected( true );
3442 } else { 3442 } else {
3443 emit groupEventsSelected(false); 3443 emit groupEventsSelected(false);
3444 } 3444 }
3445 return; 3445 return;
3446 } else { 3446 } else {
3447 emit todoSelected( false ); 3447 emit todoSelected( false );
3448 emit organizerEventsSelected(false); 3448 emit organizerEventsSelected(false);
3449 emit groupEventsSelected(false); 3449 emit groupEventsSelected(false);
3450 } 3450 }
3451 return; 3451 return;
3452 } 3452 }
3453 3453
3454 /* if ( incidence && incidence->type() == "Todo" ) { 3454 /* if ( incidence && incidence->type() == "Todo" ) {
3455 emit todoSelected( true ); 3455 emit todoSelected( true );
3456 } else { 3456 } else {
3457 emit todoSelected( false ); 3457 emit todoSelected( false );
3458 }*/ 3458 }*/
3459} 3459}
3460 3460
3461 3461
3462void CalendarView::checkClipboard() 3462void CalendarView::checkClipboard()
3463{ 3463{
3464#ifndef KORG_NODND 3464#ifndef KORG_NODND
3465 if (ICalDrag::canDecode(QApplication::clipboard()->data())) { 3465 if (ICalDrag::canDecode(QApplication::clipboard()->data())) {
3466 emit pasteEnabled(true); 3466 emit pasteEnabled(true);
3467 } else { 3467 } else {
3468 emit pasteEnabled(false); 3468 emit pasteEnabled(false);
3469 } 3469 }
3470#endif 3470#endif
3471} 3471}
3472 3472
3473void CalendarView::showDates(const DateList &selectedDates) 3473void CalendarView::showDates(const DateList &selectedDates)
3474{ 3474{
3475 // kdDebug() << "CalendarView::selectDates()" << endl; 3475 // kdDebug() << "CalendarView::selectDates()" << endl;
3476 3476
3477 3477
3478 if ( !mBlockShowDates ) { 3478 if ( !mBlockShowDates ) {
3479 if ( mViewManager->currentView() ) { 3479 if ( mViewManager->currentView() ) {
3480 updateView( selectedDates.first(), selectedDates.last() ); 3480 updateView( selectedDates.first(), selectedDates.last() );
3481 } else { 3481 } else {
3482 mViewManager->showAgendaView(); 3482 mViewManager->showAgendaView();
3483 } 3483 }
3484 } 3484 }
3485 3485
3486 QString selDates; 3486 QString selDates;
3487 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); 3487 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true);
3488 if (selectedDates.first() < selectedDates.last() ) 3488 if (selectedDates.first() < selectedDates.last() )
3489 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); 3489 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true);
3490 else { 3490 else {
3491 QString addString; 3491 QString addString;
3492 if ( selectedDates.first() == QDateTime::currentDateTime().date() ) 3492 if ( selectedDates.first() == QDateTime::currentDateTime().date() )
3493 addString = i18n("Today"); 3493 addString = i18n("Today");
3494 else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) 3494 else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(1) )
3495 addString = i18n("Tomorrow"); 3495 addString = i18n("Tomorrow");
3496 else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) 3496 else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) )
3497 addString = i18n("Yesterday"); 3497 addString = i18n("Yesterday");
3498 else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) 3498 else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) )
3499 addString = i18n("Day before yesterday"); 3499 addString = i18n("Day before yesterday");
3500 else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) 3500 else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(2) )
3501 addString = i18n("Day after tomorrow"); 3501 addString = i18n("Day after tomorrow");
3502 if ( !addString.isEmpty() ) { 3502 if ( !addString.isEmpty() ) {
3503 topLevelWidget()->setCaption( addString+", " + selDates ); 3503 topLevelWidget()->setCaption( addString+", " + selDates );
3504 return; 3504 return;
3505 } 3505 }
3506 } 3506 }
3507 topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); 3507 topLevelWidget()->setCaption( i18n("Dates: ") + selDates );
3508 3508
3509} 3509}
3510 3510
3511QPtrList<CalFilter> CalendarView::filters() 3511QPtrList<CalFilter> CalendarView::filters()
3512{ 3512{
3513 return mFilters; 3513 return mFilters;
3514 3514
3515} 3515}
3516void CalendarView::editFilters() 3516void CalendarView::editFilters()
3517{ 3517{
3518 // kdDebug() << "CalendarView::editFilters()" << endl; 3518 // kdDebug() << "CalendarView::editFilters()" << endl;
3519 3519
3520 CalFilter *filter = mFilters.first(); 3520 CalFilter *filter = mFilters.first();
3521 while(filter) { 3521 while(filter) {
3522 kdDebug() << " Filter: " << filter->name() << endl; 3522 kdDebug() << " Filter: " << filter->name() << endl;
3523 filter = mFilters.next(); 3523 filter = mFilters.next();
3524 } 3524 }
3525 3525
3526 mDialogManager->showFilterEditDialog(&mFilters); 3526 mDialogManager->showFilterEditDialog(&mFilters);
3527} 3527}
3528void CalendarView::toggleFilter() 3528void CalendarView::toggleFilter()
3529{ 3529{
3530 showFilter(! mFilterView->isVisible()); 3530 showFilter(! mFilterView->isVisible());
3531} 3531}
3532 3532
3533KOFilterView *CalendarView::filterView() 3533KOFilterView *CalendarView::filterView()
3534{ 3534{
3535 return mFilterView; 3535 return mFilterView;
3536} 3536}
3537void CalendarView::selectFilter( int fil ) 3537void CalendarView::selectFilter( int fil )
3538{ 3538{
3539 mFilterView->setSelectedFilter( fil ); 3539 mFilterView->setSelectedFilter( fil );
3540} 3540}
3541void CalendarView::showFilter(bool visible) 3541void CalendarView::showFilter(bool visible)
3542{ 3542{
3543 if (visible) mFilterView->show(); 3543 if (visible) mFilterView->show();
3544 else mFilterView->hide(); 3544 else mFilterView->hide();
3545} 3545}
3546void CalendarView::toggleFilerEnabled( ) 3546void CalendarView::toggleFilerEnabled( )
3547{ 3547{
3548 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); 3548 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() );
3549 if ( !mFilterView->filtersEnabled() ) 3549 if ( !mFilterView->filtersEnabled() )
3550 topLevelWidget()->setCaption( i18n("Filter disabled ") ); 3550 topLevelWidget()->setCaption( i18n("Filter disabled ") );
3551 3551
3552} 3552}
3553void CalendarView::updateFilter() 3553void CalendarView::updateFilter()
3554{ 3554{
3555 CalFilter *filter = mFilterView->selectedFilter(); 3555 CalFilter *filter = mFilterView->selectedFilter();
3556 if (filter) { 3556 if (filter) {
3557 if (mFilterView->filtersEnabled()) { 3557 if (mFilterView->filtersEnabled()) {
3558 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); 3558 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() );
3559 filter->setEnabled(true); 3559 filter->setEnabled(true);
3560 } 3560 }
3561 else filter->setEnabled(false); 3561 else filter->setEnabled(false);
3562 mCalendar->setFilter(filter); 3562 mCalendar->setFilter(filter);
3563 updateView(); 3563 updateView();
3564 } 3564 }
3565} 3565}
3566 3566
3567void CalendarView::filterEdited() 3567void CalendarView::filterEdited()
3568{ 3568{
3569 mFilterView->updateFilters(); 3569 mFilterView->updateFilters();
3570 updateFilter(); 3570 updateFilter();
3571 writeSettings(); 3571 writeSettings();
3572} 3572}
3573 3573
3574 3574
3575void CalendarView::takeOverEvent() 3575void CalendarView::takeOverEvent()
3576{ 3576{
3577 Incidence *incidence = currentSelection(); 3577 Incidence *incidence = currentSelection();
3578 3578
3579 if (!incidence) return; 3579 if (!incidence) return;
3580 3580
3581 incidence->setOrganizer(KOPrefs::instance()->email()); 3581 incidence->setOrganizer(KOPrefs::instance()->email());
3582 incidence->recreate(); 3582 incidence->recreate();
3583 incidence->setReadOnly(false); 3583 incidence->setReadOnly(false);
3584 3584
3585 updateView(); 3585 updateView();
3586} 3586}
3587 3587
3588void CalendarView::takeOverCalendar() 3588void CalendarView::takeOverCalendar()
3589{ 3589{
3590 // TODO: Create Calendar::allIncidences() function and use it here 3590 // TODO: Create Calendar::allIncidences() function and use it here
3591 3591
3592 QPtrList<Event> events = mCalendar->events(); 3592 QPtrList<Event> events = mCalendar->events();
3593 for(uint i=0; i<events.count(); ++i) { 3593 for(uint i=0; i<events.count(); ++i) {
3594 events.at(i)->setOrganizer(KOPrefs::instance()->email()); 3594 events.at(i)->setOrganizer(KOPrefs::instance()->email());
3595 events.at(i)->recreate(); 3595 events.at(i)->recreate();
3596 events.at(i)->setReadOnly(false); 3596 events.at(i)->setReadOnly(false);
3597 } 3597 }
3598 3598
3599 QPtrList<Todo> todos = mCalendar->todos(); 3599 QPtrList<Todo> todos = mCalendar->todos();
3600 for(uint i=0; i<todos.count(); ++i) { 3600 for(uint i=0; i<todos.count(); ++i) {
3601 todos.at(i)->setOrganizer(KOPrefs::instance()->email()); 3601 todos.at(i)->setOrganizer(KOPrefs::instance()->email());
3602 todos.at(i)->recreate(); 3602 todos.at(i)->recreate();
3603 todos.at(i)->setReadOnly(false); 3603 todos.at(i)->setReadOnly(false);
3604 } 3604 }
3605 3605
3606 QPtrList<Journal> journals = mCalendar->journals(); 3606 QPtrList<Journal> journals = mCalendar->journals();
3607 for(uint i=0; i<journals.count(); ++i) { 3607 for(uint i=0; i<journals.count(); ++i) {
3608 journals.at(i)->setOrganizer(KOPrefs::instance()->email()); 3608 journals.at(i)->setOrganizer(KOPrefs::instance()->email());
3609 journals.at(i)->recreate(); 3609 journals.at(i)->recreate();
3610 journals.at(i)->setReadOnly(false); 3610 journals.at(i)->setReadOnly(false);
3611 } 3611 }
3612 3612
3613 updateView(); 3613 updateView();
3614} 3614}
3615 3615
3616void CalendarView::showIntro() 3616void CalendarView::showIntro()
3617{ 3617{
3618 kdDebug() << "To be implemented." << endl; 3618 kdDebug() << "To be implemented." << endl;
3619} 3619}
3620 3620
3621QWidgetStack *CalendarView::viewStack() 3621QWidgetStack *CalendarView::viewStack()
3622{ 3622{
3623 return mRightFrame; 3623 return mRightFrame;
3624} 3624}
3625 3625
3626QWidget *CalendarView::leftFrame() 3626QWidget *CalendarView::leftFrame()
3627{ 3627{
3628 return mLeftFrame; 3628 return mLeftFrame;
3629} 3629}
3630 3630
3631DateNavigator *CalendarView::dateNavigator() 3631DateNavigator *CalendarView::dateNavigator()
3632{ 3632{
3633 return mNavigator; 3633 return mNavigator;
3634} 3634}
3635 3635
3636KDateNavigator* CalendarView::dateNavigatorWidget() 3636KDateNavigator* CalendarView::dateNavigatorWidget()
3637{ 3637{
3638 return mDateNavigator; 3638 return mDateNavigator;
3639} 3639}
3640void CalendarView::toggleDateNavigatorWidget() 3640void CalendarView::toggleDateNavigatorWidget()
3641{ 3641{
3642 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; 3642 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ;
3643 if (!KOPrefs::instance()->mShowDateNavigator ) 3643 if (!KOPrefs::instance()->mShowDateNavigator )
3644 mDateNavigator->hide(); 3644 mDateNavigator->hide();
3645 else 3645 else
3646 mDateNavigator->show(); 3646 mDateNavigator->show();
3647} 3647}
3648void CalendarView::addView(KOrg::BaseView *view) 3648void CalendarView::addView(KOrg::BaseView *view)
3649{ 3649{
3650 mViewManager->addView(view); 3650 mViewManager->addView(view);
3651} 3651}
3652 3652
3653void CalendarView::showView(KOrg::BaseView *view) 3653void CalendarView::showView(KOrg::BaseView *view)
3654{ 3654{
3655 mViewManager->showView(view, mLeftFrame->isVisible()); 3655 mViewManager->showView(view, mLeftFrame->isVisible());
3656} 3656}
3657 3657
3658Incidence *CalendarView::currentSelection() 3658Incidence *CalendarView::currentSelection()
3659{ 3659{
3660 return mViewManager->currentSelection(); 3660 return mViewManager->currentSelection();
3661} 3661}
3662void CalendarView::toggleAllDaySize() 3662void CalendarView::toggleAllDaySize()
3663{ 3663{
3664 /* 3664 /*
3665 if ( KOPrefs::instance()->mAllDaySize > 47 ) 3665 if ( KOPrefs::instance()->mAllDaySize > 47 )
3666 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; 3666 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2;
3667 else 3667 else
3668 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; 3668 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2;
3669 */ 3669 */
3670 viewManager()->agendaView()->toggleAllDay(); 3670 viewManager()->agendaView()->toggleAllDay();
3671} 3671}
3672void CalendarView::toggleExpand() 3672void CalendarView::toggleExpand()
3673{ 3673{
3674 // if ( mLeftFrame->isHidden() ) { 3674 // if ( mLeftFrame->isHidden() ) {
3675 // mLeftFrame->show(); 3675 // mLeftFrame->show();
3676 // emit calendarViewExpanded( false ); 3676 // emit calendarViewExpanded( false );
3677 // } else { 3677 // } else {
3678 // mLeftFrame->hide(); 3678 // mLeftFrame->hide();
3679 // emit calendarViewExpanded( true ); 3679 // emit calendarViewExpanded( true );
3680 // } 3680 // }
3681 3681
3682 globalFlagBlockAgenda = 1; 3682 globalFlagBlockAgenda = 1;
3683 emit calendarViewExpanded( !mLeftFrame->isHidden() ); 3683 emit calendarViewExpanded( !mLeftFrame->isHidden() );
3684 globalFlagBlockAgenda = 5; 3684 globalFlagBlockAgenda = 5;
3685 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); 3685 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() );
3686 //mViewManager->showView( 0, true ); 3686 //mViewManager->showView( 0, true );
3687} 3687}
3688 3688
3689void CalendarView::calendarModified( bool modified, Calendar * ) 3689void CalendarView::calendarModified( bool modified, Calendar * )
3690{ 3690{
3691 setModified( modified ); 3691 setModified( modified );
3692} 3692}
3693 3693
3694Todo *CalendarView::selectedTodo() 3694Todo *CalendarView::selectedTodo()
3695{ 3695{
3696 Incidence *incidence = currentSelection(); 3696 Incidence *incidence = currentSelection();
3697 if ( incidence && incidence->type() == "Todo" ) { 3697 if ( incidence && incidence->type() == "Todo" ) {
3698 return static_cast<Todo *>( incidence ); 3698 return static_cast<Todo *>( incidence );
3699 } 3699 }
3700 3700
3701 incidence = mTodoList->selectedIncidences().first(); 3701 incidence = mTodoList->selectedIncidences().first();
3702 if ( incidence && incidence->type() == "Todo" ) { 3702 if ( incidence && incidence->type() == "Todo" ) {
3703 return static_cast<Todo *>( incidence ); 3703 return static_cast<Todo *>( incidence );
3704 } 3704 }
3705 3705
3706 return 0; 3706 return 0;
3707} 3707}
3708 3708
3709void CalendarView::dialogClosing(Incidence *in) 3709void CalendarView::dialogClosing(Incidence *in)
3710{ 3710{
3711 // mDialogList.remove(in); 3711 // mDialogList.remove(in);
3712} 3712}
3713 3713
3714void CalendarView::showIncidence() 3714void CalendarView::showIncidence()
3715{ 3715{
3716 Incidence *incidence = currentSelection(); 3716 Incidence *incidence = currentSelection();
3717 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3717 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3718 if ( incidence ) { 3718 if ( incidence ) {
3719 ShowIncidenceVisitor v; 3719 ShowIncidenceVisitor v;
3720 v.act( incidence, this ); 3720 v.act( incidence, this );
3721 } 3721 }
3722} 3722}
3723void CalendarView::editIncidenceDescription() 3723void CalendarView::editIncidenceDescription()
3724{ 3724{
3725 mFlagEditDescription = true; 3725 mFlagEditDescription = true;
3726 editIncidence(); 3726 editIncidence();
3727 mFlagEditDescription = false; 3727 mFlagEditDescription = false;
3728} 3728}
3729void CalendarView::editIncidence() 3729void CalendarView::editIncidence()
3730{ 3730{
3731 // qDebug("editIncidence() "); 3731 // qDebug("editIncidence() ");
3732 Incidence *incidence = currentSelection(); 3732 Incidence *incidence = currentSelection();
3733 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3733 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3734 if ( incidence ) { 3734 if ( incidence ) {
3735 EditIncidenceVisitor v; 3735 EditIncidenceVisitor v;
3736 v.act( incidence, this ); 3736 v.act( incidence, this );
3737 } 3737 }
3738} 3738}
3739 3739
3740void CalendarView::deleteIncidence() 3740void CalendarView::deleteIncidence()
3741{ 3741{
3742 Incidence *incidence = currentSelection(); 3742 Incidence *incidence = currentSelection();
3743 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3743 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3744 if ( incidence ) { 3744 if ( incidence ) {
3745 deleteIncidence(incidence); 3745 deleteIncidence(incidence);
3746 } 3746 }
3747} 3747}
3748 3748
3749void CalendarView::showIncidence(Incidence *incidence) 3749void CalendarView::showIncidence(Incidence *incidence)
3750{ 3750{
3751 if ( incidence ) { 3751 if ( incidence ) {
3752 ShowIncidenceVisitor v; 3752 ShowIncidenceVisitor v;
3753 v.act( incidence, this ); 3753 v.act( incidence, this );
3754 } 3754 }
3755} 3755}
3756 3756
3757void CalendarView::editIncidence(Incidence *incidence) 3757void CalendarView::editIncidence(Incidence *incidence)
3758{ 3758{
3759 if ( incidence ) { 3759 if ( incidence ) {
3760 3760
3761 EditIncidenceVisitor v; 3761 EditIncidenceVisitor v;
3762 v.act( incidence, this ); 3762 v.act( incidence, this );
3763 3763
3764 } 3764 }
3765} 3765}
3766 3766
3767void CalendarView::deleteIncidence(Incidence *incidence) 3767void CalendarView::deleteIncidence(Incidence *incidence)
3768{ 3768{
3769 //qDebug(" CalendarView::deleteIncidence "); 3769 //qDebug(" CalendarView::deleteIncidence ");
3770 if ( incidence ) { 3770 if ( incidence ) {
3771 DeleteIncidenceVisitor v; 3771 DeleteIncidenceVisitor v;
3772 v.act( incidence, this ); 3772 v.act( incidence, this );
3773 } 3773 }
3774} 3774}
3775 3775
3776 3776
3777void CalendarView::lookForOutgoingMessages() 3777void CalendarView::lookForOutgoingMessages()
3778{ 3778{
3779 OutgoingDialog *ogd = mDialogManager->outgoingDialog(); 3779 OutgoingDialog *ogd = mDialogManager->outgoingDialog();
3780 ogd->loadMessages(); 3780 ogd->loadMessages();
3781} 3781}
3782 3782
3783void CalendarView::lookForIncomingMessages() 3783void CalendarView::lookForIncomingMessages()
3784{ 3784{
3785 IncomingDialog *icd = mDialogManager->incomingDialog(); 3785 IncomingDialog *icd = mDialogManager->incomingDialog();
3786 icd->retrieve(); 3786 icd->retrieve();
3787} 3787}
3788 3788
3789bool CalendarView::removeCompletedSubTodos( Todo* t ) 3789bool CalendarView::removeCompletedSubTodos( Todo* t )
3790{ 3790{
3791 bool deleteTodo = true; 3791 bool deleteTodo = true;
3792 QPtrList<Incidence> subTodos; 3792 QPtrList<Incidence> subTodos;
3793 Incidence *aTodo; 3793 Incidence *aTodo;
3794 subTodos = t->relations(); 3794 subTodos = t->relations();
3795 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { 3795 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
3796 if (! removeCompletedSubTodos( (Todo*) aTodo )) 3796 if (! removeCompletedSubTodos( (Todo*) aTodo ))
3797 deleteTodo = false; 3797 deleteTodo = false;
3798 } 3798 }
3799 if ( deleteTodo ) { 3799 if ( deleteTodo ) {
3800 if ( t->isCompleted() ) { 3800 if ( t->isCompleted() ) {
3801 checkExternalId( t ); 3801 checkExternalId( t );
3802 mCalendar->deleteTodo( t ); 3802 mCalendar->deleteTodo( t );
3803 changeTodoDisplay( t,KOGlobals::EVENTDELETED ); 3803 changeTodoDisplay( t,KOGlobals::EVENTDELETED );
3804 } 3804 }
3805 else 3805 else
3806 deleteTodo = false; 3806 deleteTodo = false;
3807 } 3807 }
3808 return deleteTodo; 3808 return deleteTodo;
3809 3809
3810} 3810}
3811void CalendarView::purgeCompleted() 3811void CalendarView::purgeCompleted()
3812{ 3812{
3813 int result = KMessageBox::warningContinueCancel(this, 3813 int result = KMessageBox::warningContinueCancel(this,
3814 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); 3814 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge"));
3815 3815
3816 if (result == KMessageBox::Continue) { 3816 if (result == KMessageBox::Continue) {
3817 3817
3818 QPtrList<Todo> todoCal; 3818 QPtrList<Todo> todoCal;
3819 QPtrList<Todo> rootTodos; 3819 QPtrList<Todo> rootTodos;
3820 //QPtrList<Incidence> rel; 3820 //QPtrList<Incidence> rel;
3821 Todo *aTodo;//, *rTodo; 3821 Todo *aTodo;//, *rTodo;
3822 Incidence *rIncidence; 3822 Incidence *rIncidence;
3823 bool childDelete = false; 3823 bool childDelete = false;
3824 bool deletedOne = true; 3824 bool deletedOne = true;
3825 todoCal = calendar()->todos(); 3825 todoCal = calendar()->todos();
3826 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { 3826 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
3827 if ( !aTodo->relatedTo() ) 3827 if ( !aTodo->relatedTo() )
3828 rootTodos.append( aTodo ); 3828 rootTodos.append( aTodo );
3829 } 3829 }
3830 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { 3830 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) {
3831 removeCompletedSubTodos( aTodo ); 3831 removeCompletedSubTodos( aTodo );
3832 } 3832 }
3833 3833
3834 updateView(); 3834 updateView();
3835 } 3835 }
3836} 3836}
3837 3837
3838void CalendarView::slotCalendarChanged() 3838void CalendarView::slotCalendarChanged()
3839{ 3839{
3840 ; 3840 ;
3841} 3841}
3842 3842
3843NavigatorBar *CalendarView::navigatorBar() 3843NavigatorBar *CalendarView::navigatorBar()
3844{ 3844{
3845 return mNavigatorBar; 3845 return mNavigatorBar;
3846} 3846}
3847 3847
3848 3848
3849 3849
3850void CalendarView::keyPressEvent ( QKeyEvent *e) 3850void CalendarView::keyPressEvent ( QKeyEvent *e)
3851{ 3851{
3852 //qDebug(" alendarView::keyPressEvent "); 3852 //qDebug(" alendarView::keyPressEvent ");
3853 e->ignore(); 3853 e->ignore();
3854} 3854}
3855 3855
3856 3856
3857bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) 3857bool CalendarView::sync(KSyncManager* manager, QString filename, int mode)
3858{ 3858{
3859 // mSyncManager = manager; 3859 // mSyncManager = manager;
3860 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { 3860 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) {
3861 qDebug("KO: SyncKDE request detected!"); 3861 qDebug("KO: SyncKDE request detected!");
3862 } 3862 }
3863 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 3863 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
3864 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 3864 mCurrentSyncName = mSyncManager->getCurrentSyncName();
3865 return syncCalendar( filename, mode ); 3865 return syncCalendar( filename, mode );
3866} 3866}
3867bool CalendarView::syncExternal(KSyncManager* manager, QString resource) 3867bool CalendarView::syncExternal(KSyncManager* manager, QString resource)
3868{ 3868{
3869 //mSyncManager = manager; 3869 //mSyncManager = manager;
3870 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 3870 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
3871 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 3871 mCurrentSyncName = mSyncManager->getCurrentSyncName();
3872 if ( resource == "sharp" ) 3872 if ( resource == "sharp" )
3873 syncExternal( 0 ); 3873 syncExternal( 0 );
3874 if ( resource == "phone" ) 3874 if ( resource == "phone" )
3875 syncExternal( 1 ); 3875 syncExternal( 1 );
3876 // pending setmodified 3876 // pending setmodified
3877 return true; 3877 return true;
3878} 3878}
3879void CalendarView::setSyncManager(KSyncManager* manager) 3879void CalendarView::setSyncManager(KSyncManager* manager)
3880{ 3880{
3881 mSyncManager = manager; 3881 mSyncManager = manager;
3882} 3882}
3883 3883
3884void CalendarView::removeSyncInfo( QString syncProfile) 3884void CalendarView::removeSyncInfo( QString syncProfile)
3885{ 3885{
3886 qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); 3886 qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1());
3887 mCalendar->removeSyncInfo( syncProfile ); 3887 mCalendar->removeSyncInfo( syncProfile );
3888 3888
3889} 3889}
3890 3890
3891void CalendarView::undo_delete() 3891void CalendarView::undo_delete()
3892{ 3892{
3893 //qDebug("undo_delete() "); 3893 //qDebug("undo_delete() ");
3894 Incidence* undo = mCalendar->undoIncidence(); 3894 Incidence* undo = mCalendar->undoIncidence();
3895 if ( !undo ) { 3895 if ( !undo ) {
3896 KMessageBox::sorry(this,i18n("There is nothing to undo!"), 3896 KMessageBox::sorry(this,i18n("There is nothing to undo!"),
3897 i18n("KO/Pi")); 3897 i18n("KO/Pi"));
3898 return; 3898 return;
3899 } 3899 }
3900 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + 3900 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) +
3901 i18n("\nAre you sure you want\nto restore this?"), 3901 i18n("\nAre you sure you want\nto restore this?"),
3902 i18n("KO/Pi Confirmation"),i18n("Restore"))) { 3902 i18n("KO/Pi Confirmation"),i18n("Restore"))) {
3903 mCalendar->undoDeleteIncidence(); 3903 mCalendar->undoDeleteIncidence();
3904 updateView(); 3904 updateView();
3905 } 3905 }
3906} 3906}
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index 6428757..b5596d9 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -1,1472 +1,1509 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qhbox.h> 24#include <qhbox.h>
25#include <qvbox.h> 25#include <qvbox.h>
26#include <qlabel.h> 26#include <qlabel.h>
27#include <qframe.h> 27#include <qframe.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#ifndef KORG_NOSPLITTER 29#ifndef KORG_NOSPLITTER
30#include <qsplitter.h> 30#include <qsplitter.h>
31#endif 31#endif
32#include <qfont.h> 32#include <qfont.h>
33#include <qfontmetrics.h> 33#include <qfontmetrics.h>
34#include <qpopupmenu.h> 34#include <qpopupmenu.h>
35#include <qtooltip.h> 35#include <qtooltip.h>
36#include <qpainter.h> 36#include <qpainter.h>
37#include <qpushbutton.h> 37#include <qpushbutton.h>
38#include <qapplication.h> 38#include <qapplication.h>
39 39
40#include <kapplication.h> 40#include <kapplication.h>
41#include <KDGanttMinimizeSplitter.h> 41#include <KDGanttMinimizeSplitter.h>
42#include <kdebug.h> 42#include <kdebug.h>
43#include <kstandarddirs.h> 43#include <kstandarddirs.h>
44#include <kiconloader.h> 44#include <kiconloader.h>
45#include <klocale.h> 45#include <klocale.h>
46#include <kconfig.h> 46#include <kconfig.h>
47#include <kglobal.h> 47#include <kglobal.h>
48#include "calendarview.h" 48#include "calendarview.h"
49#include "koviewmanager.h" 49#include "koviewmanager.h"
50 50
51#include <libkcal/calendar.h> 51#include <libkcal/calendar.h>
52#include <libkcal/icaldrag.h> 52#include <libkcal/icaldrag.h>
53#include <libkcal/dndfactory.h> 53#include <libkcal/dndfactory.h>
54 54
55#include <kcalendarsystem.h> 55#include <kcalendarsystem.h>
56 56
57#include "koglobals.h" 57#include "koglobals.h"
58#ifndef KORG_NOPLUGINS 58#ifndef KORG_NOPLUGINS
59#include "kocore.h" 59#include "kocore.h"
60#endif 60#endif
61#include "koprefs.h" 61#include "koprefs.h"
62#include "koagenda.h" 62#include "koagenda.h"
63#include "koagendaitem.h" 63#include "koagendaitem.h"
64#ifndef KORG_NOPRINTER 64#ifndef KORG_NOPRINTER
65#include "calprinter.h" 65#include "calprinter.h"
66#endif 66#endif
67 67
68#include "koagendaview.h" 68#include "koagendaview.h"
69//#include "koagendaview.moc" 69//#include "koagendaview.moc"
70 70
71//extern bool globalFlagBlockPainting; 71//extern bool globalFlagBlockPainting;
72extern int globalFlagBlockAgenda; 72extern int globalFlagBlockAgenda;
73extern int globalFlagBlockStartup; 73extern int globalFlagBlockStartup;
74extern int globalFlagBlockAgendaItemPaint; 74extern int globalFlagBlockAgendaItemPaint;
75extern int globalFlagBlockAgendaItemUpdate; 75extern int globalFlagBlockAgendaItemUpdate;
76extern int globalFlagBlockLabel; 76extern int globalFlagBlockLabel;
77using namespace KOrg; 77using namespace KOrg;
78 78
79TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : 79TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) :
80 QScrollView(parent,name,f) 80 QScrollView(parent,name,f)
81{ 81{
82 mRows = rows; 82 mRows = rows;
83 83
84 setMinimumHeight( 20 ); 84 setMinimumHeight( 20 );
85 mCellHeight = KOPrefs::instance()->mHourSize*4; 85 mCellHeight = KOPrefs::instance()->mHourSize*4;
86 86
87 enableClipper(true); 87 enableClipper(true);
88 88
89 setHScrollBarMode(AlwaysOff); 89 setHScrollBarMode(AlwaysOff);
90 setVScrollBarMode(AlwaysOff); 90 setVScrollBarMode(AlwaysOff);
91 91
92 resizeContents(50,mRows * mCellHeight); 92 resizeContents(50,mRows * mCellHeight);
93 93
94 viewport()->setBackgroundMode( PaletteBackground ); 94 viewport()->setBackgroundMode( PaletteBackground );
95} 95}
96 96
97void TimeLabels::setCellHeight(int height) 97void TimeLabels::setCellHeight(int height)
98{ 98{
99 mCellHeight = height; 99 mCellHeight = height;
100} 100}
101 101
102/* 102/*
103 Optimization so that only the "dirty" portion of the scroll view 103 Optimization so that only the "dirty" portion of the scroll view
104 is redrawn. Unfortunately, this is not called by default paintEvent() method. 104 is redrawn. Unfortunately, this is not called by default paintEvent() method.
105*/ 105*/
106void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) 106void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch)
107{ 107{
108 108
109 // if ( globalFlagBlockAgenda ) 109 // if ( globalFlagBlockAgenda )
110 // return; 110 // return;
111 // bug: the parameters cx, cy, cw, ch are the areas that need to be 111 // bug: the parameters cx, cy, cw, ch are the areas that need to be
112 // redrawn, not the area of the widget. unfortunately, this 112 // redrawn, not the area of the widget. unfortunately, this
113 // code assumes the latter... 113 // code assumes the latter...
114 114
115 // now, for a workaround... 115 // now, for a workaround...
116 // these two assignments fix the weird redraw bug 116 // these two assignments fix the weird redraw bug
117 cx = contentsX() + 2; 117 cx = contentsX() + 2;
118 cw = contentsWidth() - 2; 118 cw = contentsWidth() - 2;
119 // end of workaround 119 // end of workaround
120 120
121 int cell = ((int)(cy/mCellHeight)); 121 int cell = ((int)(cy/mCellHeight));
122 int y = cell * mCellHeight; 122 int y = cell * mCellHeight;
123 QFontMetrics fm = fontMetrics(); 123 QFontMetrics fm = fontMetrics();
124 QString hour; 124 QString hour;
125 QString suffix; 125 QString suffix;
126 QString fullTime; 126 QString fullTime;
127 int tW = fm.width("24:00i"); 127 int tW = fm.width("24:00i");
128 128
129 while (y < cy + ch) { 129 while (y < cy + ch) {
130 p->drawLine(cx,y,cx+tW,y); 130 p->drawLine(cx,y,cx+tW,y);
131 hour.setNum(cell); 131 hour.setNum(cell);
132 suffix = "am"; 132 suffix = "am";
133 133
134 // handle 24h and am/pm time formats 134 // handle 24h and am/pm time formats
135 if (KGlobal::locale()->use12Clock()) { 135 if (KGlobal::locale()->use12Clock()) {
136 if (cell > 11) suffix = "pm"; 136 if (cell > 11) suffix = "pm";
137 if (cell == 0) hour.setNum(12); 137 if (cell == 0) hour.setNum(12);
138 if (cell > 12) hour.setNum(cell - 12); 138 if (cell > 12) hour.setNum(cell - 12);
139 } else { 139 } else {
140 suffix = ":00"; 140 suffix = ":00";
141 } 141 }
142 142
143 // create string in format of "XX:XX" or "XXpm/am" 143 // create string in format of "XX:XX" or "XXpm/am"
144 fullTime = hour + suffix; 144 fullTime = hour + suffix;
145 145
146 // center and draw the time label 146 // center and draw the time label
147 int timeWidth = fm.width(fullTime+"i"); 147 int timeWidth = fm.width(fullTime+"i");
148 int offset = this->width() - timeWidth; 148 int offset = this->width() - timeWidth;
149 int borderWidth = 5; 149 int borderWidth = 5;
150 int timeHeight = fm.height(); 150 int timeHeight = fm.height();
151 timeHeight = timeHeight + 2 - ( timeHeight / 4 ); 151 timeHeight = timeHeight + 2 - ( timeHeight / 4 );
152 p->drawText(cx -borderWidth + offset, y+ timeHeight, fullTime); 152 p->drawText(cx -borderWidth + offset, y+ timeHeight, fullTime);
153 153
154 // increment indices 154 // increment indices
155 y += mCellHeight; 155 y += mCellHeight;
156 cell++; 156 cell++;
157 } 157 }
158} 158}
159 159
160/** 160/**
161 Calculates the minimum width. 161 Calculates the minimum width.
162*/ 162*/
163int TimeLabels::minimumWidth() const 163int TimeLabels::minimumWidth() const
164{ 164{
165 QFontMetrics fm = fontMetrics(); 165 QFontMetrics fm = fontMetrics();
166 166
167 //TODO: calculate this value 167 //TODO: calculate this value
168 int borderWidth = 4; 168 int borderWidth = 4;
169 169
170 // the maximum width possible 170 // the maximum width possible
171 int width = fm.width("88:88x") + borderWidth; 171 int width = fm.width("88:88x") + borderWidth;
172 172
173 return width; 173 return width;
174} 174}
175 175
176/** updates widget's internal state */ 176/** updates widget's internal state */
177void TimeLabels::updateConfig() 177void TimeLabels::updateConfig()
178{ 178{
179 // set the font 179 // set the font
180 // config->setGroup("Fonts"); 180 // config->setGroup("Fonts");
181 // QFont font = config->readFontEntry("TimeBar Font"); 181 // QFont font = config->readFontEntry("TimeBar Font");
182 setFont(KOPrefs::instance()->mTimeBarFont); 182 setFont(KOPrefs::instance()->mTimeBarFont);
183 183
184 // update geometry restrictions based on new settings 184 // update geometry restrictions based on new settings
185 setFixedWidth(minimumWidth()); 185 setFixedWidth(minimumWidth());
186 186
187 // update HourSize 187 // update HourSize
188 mCellHeight = KOPrefs::instance()->mHourSize*4; 188 mCellHeight = KOPrefs::instance()->mHourSize*4;
189 resizeContents(50,mRows * mCellHeight); 189 resizeContents(50,mRows * mCellHeight);
190} 190}
191 191
192/** update time label positions */ 192/** update time label positions */
193void TimeLabels::positionChanged() 193void TimeLabels::positionChanged()
194{ 194{
195 int adjustment = mAgenda->contentsY(); 195 int adjustment = mAgenda->contentsY();
196 setContentsPos(0, adjustment); 196 setContentsPos(0, adjustment);
197} 197}
198 198
199/** */ 199/** */
200void TimeLabels::setAgenda(KOAgenda* agenda) 200void TimeLabels::setAgenda(KOAgenda* agenda)
201{ 201{
202 mAgenda = agenda; 202 mAgenda = agenda;
203} 203}
204
205void TimeLabels::contentsMousePressEvent ( QMouseEvent * e)
206{
207 mMouseDownY = e->pos().y();
208}
209
210void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e )
211{
212 int diff = mMouseDownY - e->pos().y();
213 if ( diff < 10 && diff > -10 )
214 return;
215 int tSize = KOPrefs::instance()->mHourSize + (diff/10) ;
216 if ( tSize < 4 )
217 tSize = 4;
218 if ( tSize > 18 )
219 tSize = 18;
220 tSize = (tSize-2)/2;
221 topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize));
204 222
223}
224void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e )
225{
226 int diff = mMouseDownY - e->pos().y();
227 if ( diff < 10 && diff > -10 )
228 return;
229 int tSize = KOPrefs::instance()->mHourSize + (diff/10);
230 if ( tSize < 4 )
231 tSize = 4;
232 if ( tSize > 18 )
233 tSize = 18;
234 tSize = (tSize/2)*2;
235 if ( tSize == KOPrefs::instance()->mHourSize )
236 return;
237 KOPrefs::instance()->mHourSize = tSize;
238 emit scaleChanged();
239}
205 240
206/** This is called in response to repaint() */ 241/** This is called in response to repaint() */
207void TimeLabels::paintEvent(QPaintEvent*) 242void TimeLabels::paintEvent(QPaintEvent*)
208{ 243{
209 244
210 // kdDebug() << "paintevent..." << endl; 245 // kdDebug() << "paintevent..." << endl;
211 // this is another hack! 246 // this is another hack!
212 // QPainter painter(this); 247 // QPainter painter(this);
213 //QString c 248 //QString c
214 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); 249 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight());
215} 250}
216 251
217//////////////////////////////////////////////////////////////////////////// 252////////////////////////////////////////////////////////////////////////////
218 253
219EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) 254EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name)
220 : QFrame(parent,name) 255 : QFrame(parent,name)
221{ 256{
222 mColumns = 1; 257 mColumns = 1;
223 mTopBox = 0; 258 mTopBox = 0;
224 mLocation = loc; 259 mLocation = loc;
225 mTopLayout = 0; 260 mTopLayout = 0;
226 mPaintWidget = 0; 261 mPaintWidget = 0;
227 mXOffset = 0; 262 mXOffset = 0;
228 if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); 263 if (mLocation == Top) mPixmap = SmallIcon("1uparrow");
229 else mPixmap = SmallIcon("1downarrow"); 264 else mPixmap = SmallIcon("1downarrow");
230 mEnabled.resize(mColumns); 265 mEnabled.resize(mColumns);
231 if (mLocation == Top) 266 if (mLocation == Top)
232 setMaximumHeight(0); 267 setMaximumHeight(0);
233 else 268 else
234 setMinimumHeight(mPixmap.height()); 269 setMinimumHeight(mPixmap.height());
235} 270}
236 271
237EventIndicator::~EventIndicator() 272EventIndicator::~EventIndicator()
238{ 273{
239} 274}
240 275
241void EventIndicator::drawContents(QPainter *p) 276void EventIndicator::drawContents(QPainter *p)
242{ 277{
243 278
244 // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; 279 // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl;
245 KDGanttSplitterHandle* han = 0; 280 KDGanttSplitterHandle* han = 0;
246 if ( mPaintWidget ) 281 if ( mPaintWidget )
247 han = mPaintWidget->firstHandle(); 282 han = mPaintWidget->firstHandle();
248 if ( ! han ) { 283 if ( ! han ) {
249 int i; 284 int i;
250 for(i=0;i<mColumns;++i) { 285 for(i=0;i<mColumns;++i) {
251 if (mEnabled[i]) { 286 if (mEnabled[i]) {
252 int cellWidth = contentsRect().right()/mColumns; 287 int cellWidth = contentsRect().right()/mColumns;
253 int xOffset = KOGlobals::self()->reverseLayout() ? 288 int xOffset = KOGlobals::self()->reverseLayout() ?
254 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : 289 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 :
255 i*cellWidth + cellWidth/2 -mPixmap.width()/2; 290 i*cellWidth + cellWidth/2 -mPixmap.width()/2;
256 p->drawPixmap(QPoint(xOffset,0),mPixmap); 291 p->drawPixmap(QPoint(xOffset,0),mPixmap);
257 } 292 }
258 } 293 }
259 } else { 294 } else {
260 han->repaint(); 295 han->repaint();
261 //mPaintWidget->setBackgroundColor( red ); 296 //mPaintWidget->setBackgroundColor( red );
262 297
263 QPainter pa( han ); 298 QPainter pa( han );
264 int i; 299 int i;
265 bool setColor = false; 300 bool setColor = false;
266 for(i=0;i<mColumns;++i) { 301 for(i=0;i<mColumns;++i) {
267 if (mEnabled[i]) { 302 if (mEnabled[i]) {
268 setColor = true; 303 setColor = true;
269 304
270 int cellWidth = contentsRect().right()/mColumns; 305 int cellWidth = contentsRect().right()/mColumns;
271 int xOffset = KOGlobals::self()->reverseLayout() ? 306 int xOffset = KOGlobals::self()->reverseLayout() ?
272 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : 307 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 :
273 i*cellWidth + cellWidth/2 -mPixmap.width()/2; 308 i*cellWidth + cellWidth/2 -mPixmap.width()/2;
274 pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); 309 pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap);
275 //qDebug("222draw pix %d ",xOffset ); 310 //qDebug("222draw pix %d ",xOffset );
276 311
277 } 312 }
278 313
279 } 314 }
280 pa.end(); 315 pa.end();
281 316
282 } 317 }
283} 318}
284 319
285void EventIndicator::setXOffset( int x ) 320void EventIndicator::setXOffset( int x )
286{ 321{
287 mXOffset = x; 322 mXOffset = x;
288} 323}
289void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) 324void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w )
290{ 325{
291 mPaintWidget = w; 326 mPaintWidget = w;
292} 327}
293void EventIndicator::changeColumns(int columns) 328void EventIndicator::changeColumns(int columns)
294{ 329{
295 mColumns = columns; 330 mColumns = columns;
296 mEnabled.resize(mColumns); 331 mEnabled.resize(mColumns);
297 332
298 update(); 333 update();
299} 334}
300 335
301void EventIndicator::enableColumn(int column, bool enable) 336void EventIndicator::enableColumn(int column, bool enable)
302{ 337{
303 mEnabled[column] = enable; 338 mEnabled[column] = enable;
304} 339}
305 340
306 341
307//////////////////////////////////////////////////////////////////////////// 342////////////////////////////////////////////////////////////////////////////
308//////////////////////////////////////////////////////////////////////////// 343////////////////////////////////////////////////////////////////////////////
309//////////////////////////////////////////////////////////////////////////// 344////////////////////////////////////////////////////////////////////////////
310 345
311KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : 346KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
312 KOEventView (cal,parent,name) 347 KOEventView (cal,parent,name)
313{ 348{
314 mBlockUpdating = true; 349 mBlockUpdating = true;
315 mStartHour = 8; 350 mStartHour = 8;
316 mSelectedDates.append(QDate::currentDate()); 351 mSelectedDates.append(QDate::currentDate());
317 352
318 mLayoutDayLabels = 0; 353 mLayoutDayLabels = 0;
319 mDayLabelsFrame = 0; 354 mDayLabelsFrame = 0;
320 mDayLabels = 0; 355 mDayLabels = 0;
321 bool isRTL = KOGlobals::self()->reverseLayout(); 356 bool isRTL = KOGlobals::self()->reverseLayout();
322 357
323 if ( KOPrefs::instance()->mVerticalScreen ) { 358 if ( KOPrefs::instance()->mVerticalScreen ) {
324 mExpandedPixmap = SmallIcon( "1downarrow" ); 359 mExpandedPixmap = SmallIcon( "1downarrow" );
325 mNotExpandedPixmap = SmallIcon( "1uparrow" ); 360 mNotExpandedPixmap = SmallIcon( "1uparrow" );
326 } else { 361 } else {
327 mExpandedPixmap = SmallIcon( isRTL ? "1leftarrow" : "1rightarrow" ); 362 mExpandedPixmap = SmallIcon( isRTL ? "1leftarrow" : "1rightarrow" );
328 mNotExpandedPixmap = SmallIcon( isRTL ? "1rightarrow" : "1leftarrow" ); 363 mNotExpandedPixmap = SmallIcon( isRTL ? "1rightarrow" : "1leftarrow" );
329 } 364 }
330 365
331 QBoxLayout *topLayout = new QVBoxLayout(this); 366 QBoxLayout *topLayout = new QVBoxLayout(this);
332 367
333 // Create day name labels for agenda columns 368 // Create day name labels for agenda columns
334 mDayLabelsFrame = new QHBox(this); 369 mDayLabelsFrame = new QHBox(this);
335 topLayout->addWidget(mDayLabelsFrame); 370 topLayout->addWidget(mDayLabelsFrame);
336 mDayLabels = new QFrame (mDayLabelsFrame); 371 mDayLabels = new QFrame (mDayLabelsFrame);
337 mLayoutDayLabels = new QHBoxLayout(mDayLabels); 372 mLayoutDayLabels = new QHBoxLayout(mDayLabels);
338 // Create agenda splitter 373 // Create agenda splitter
339#ifndef KORG_NOSPLITTER 374#ifndef KORG_NOSPLITTER
340 mSplitterAgenda = new QSplitter(Vertical,this); 375 mSplitterAgenda = new QSplitter(Vertical,this);
341 topLayout->addWidget(mSplitterAgenda); 376 topLayout->addWidget(mSplitterAgenda);
342 mSplitterAgenda->setOpaqueResize(); 377 mSplitterAgenda->setOpaqueResize();
343 378
344 mAllDayFrame = new QHBox(mSplitterAgenda); 379 mAllDayFrame = new QHBox(mSplitterAgenda);
345 380
346 QWidget *agendaFrame = new QWidget(mSplitterAgenda); 381 QWidget *agendaFrame = new QWidget(mSplitterAgenda);
347#else 382#else
348#if 0 383#if 0
349 QWidget *mainBox = new QWidget( this ); 384 QWidget *mainBox = new QWidget( this );
350 topLayout->addWidget( mainBox ); 385 topLayout->addWidget( mainBox );
351 QBoxLayout *mainLayout = new QVBoxLayout(mainBox); 386 QBoxLayout *mainLayout = new QVBoxLayout(mainBox);
352 mAllDayFrame = new QHBox(mainBox); 387 mAllDayFrame = new QHBox(mainBox);
353 mainLayout->addWidget(mAllDayFrame); 388 mainLayout->addWidget(mAllDayFrame);
354 mainLayout->setStretchFactor( mAllDayFrame, 0 ); 389 mainLayout->setStretchFactor( mAllDayFrame, 0 );
355 mAllDayFrame->setFocusPolicy(NoFocus); 390 mAllDayFrame->setFocusPolicy(NoFocus);
356 QWidget *agendaFrame = new QWidget(mainBox); 391 QWidget *agendaFrame = new QWidget(mainBox);
357 mainLayout->addWidget(agendaFrame); 392 mainLayout->addWidget(agendaFrame);
358 mainLayout->setStretchFactor( agendaFrame, 10 ); 393 mainLayout->setStretchFactor( agendaFrame, 10 );
359 394
360 agendaFrame->setFocusPolicy(NoFocus); 395 agendaFrame->setFocusPolicy(NoFocus);
361#endif 396#endif
362 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); 397 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this);
363 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 398 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
364 topLayout->addWidget( mSplitterAgenda ); 399 topLayout->addWidget( mSplitterAgenda );
365 mAllDayFrame = new QHBox(mSplitterAgenda); 400 mAllDayFrame = new QHBox(mSplitterAgenda);
366 mAllDayFrame->setFocusPolicy(NoFocus); 401 mAllDayFrame->setFocusPolicy(NoFocus);
367 QWidget *agendaFrame = new QWidget(mSplitterAgenda); 402 QWidget *agendaFrame = new QWidget(mSplitterAgenda);
368 agendaFrame->setFocusPolicy(NoFocus); 403 agendaFrame->setFocusPolicy(NoFocus);
369 404
370#endif 405#endif
371 406
372 // Create all-day agenda widget 407 // Create all-day agenda widget
373 mDummyAllDayLeft = new QVBox( mAllDayFrame ); 408 mDummyAllDayLeft = new QVBox( mAllDayFrame );
374 409
375 mExpandButton = new QPushButton(mDummyAllDayLeft); 410 mExpandButton = new QPushButton(mDummyAllDayLeft);
376 mExpandButton->setPixmap( mNotExpandedPixmap ); 411 mExpandButton->setPixmap( mNotExpandedPixmap );
377 int widebut = mExpandButton->sizeHint().width(); 412 int widebut = mExpandButton->sizeHint().width();
378 if ( QApplication::desktop()->width() < 480 ) 413 if ( QApplication::desktop()->width() < 480 )
379 widebut = widebut*2; 414 widebut = widebut*2;
380 else 415 else
381 widebut = (widebut*3) / 2; 416 widebut = (widebut*3) / 2;
382 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, 417 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed,
383 // QSizePolicy::Fixed ) ); 418 // QSizePolicy::Fixed ) );
384 mExpandButton->setFixedSize( widebut, widebut); 419 mExpandButton->setFixedSize( widebut, widebut);
385 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); 420 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) );
386 mExpandButton->setFocusPolicy(NoFocus); 421 mExpandButton->setFocusPolicy(NoFocus);
387 mAllDayAgenda = new KOAgenda(1,mAllDayFrame); 422 mAllDayAgenda = new KOAgenda(1,mAllDayFrame);
388 mAllDayAgenda->setFocusPolicy(NoFocus); 423 mAllDayAgenda->setFocusPolicy(NoFocus);
389 QWidget *dummyAllDayRight = new QWidget(mAllDayFrame); 424 QWidget *dummyAllDayRight = new QWidget(mAllDayFrame);
390 425
391 // Create event context menu for all day agenda 426 // Create event context menu for all day agenda
392 mAllDayAgendaPopup = eventPopup(); 427 mAllDayAgendaPopup = eventPopup();
393 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 428 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
394 mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 429 mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
395 430
396 // Create agenda frame 431 // Create agenda frame
397 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,3,3); 432 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,3,3);
398 // QHBox *agendaFrame = new QHBox(splitterAgenda); 433 // QHBox *agendaFrame = new QHBox(splitterAgenda);
399 434
400 // create event indicator bars 435 // create event indicator bars
401 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); 436 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame);
402 agendaLayout->addWidget(mEventIndicatorTop,0,1); 437 agendaLayout->addWidget(mEventIndicatorTop,0,1);
403 mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); 438 mEventIndicatorTop->setPaintWidget( mSplitterAgenda );
404 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, 439 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom,
405 agendaFrame); 440 agendaFrame);
406 agendaLayout->addWidget(mEventIndicatorBottom,2,1); 441 agendaLayout->addWidget(mEventIndicatorBottom,2,1);
407 QWidget *dummyAgendaRight = new QWidget(agendaFrame); 442 QWidget *dummyAgendaRight = new QWidget(agendaFrame);
408 agendaLayout->addWidget(dummyAgendaRight,0,2); 443 agendaLayout->addWidget(dummyAgendaRight,0,2);
409 444
410 // Create time labels 445 // Create time labels
411 mTimeLabels = new TimeLabels(24,agendaFrame); 446 mTimeLabels = new TimeLabels(24,agendaFrame);
412 agendaLayout->addWidget(mTimeLabels,1,0); 447 agendaLayout->addWidget(mTimeLabels,1,0);
448 connect(mTimeLabels,SIGNAL( scaleChanged()),
449 this,SLOT(updateConfig()));
413 450
414 // Create agenda 451 // Create agenda
415 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); 452 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame);
416 agendaLayout->addMultiCellWidget(mAgenda,1,1,1,2); 453 agendaLayout->addMultiCellWidget(mAgenda,1,1,1,2);
417 agendaLayout->setColStretch(1,1); 454 agendaLayout->setColStretch(1,1);
418 mAgenda->setFocusPolicy(NoFocus); 455 mAgenda->setFocusPolicy(NoFocus);
419 // Create event context menu for agenda 456 // Create event context menu for agenda
420 mAgendaPopup = eventPopup(); 457 mAgendaPopup = eventPopup();
421 458
422 mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), 459 mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")),
423 i18n("Toggle Alarm"),mAgenda, 460 i18n("Toggle Alarm"),mAgenda,
424 SLOT(popupAlarm()),true); 461 SLOT(popupAlarm()),true);
425 462
426 463
427 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 464 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
428 mAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 465 mAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
429 466
430 // make connections between dependent widgets 467 // make connections between dependent widgets
431 mTimeLabels->setAgenda(mAgenda); 468 mTimeLabels->setAgenda(mAgenda);
432 469
433 // Update widgets to reflect user preferences 470 // Update widgets to reflect user preferences
434 // updateConfig(); 471 // updateConfig();
435 472
436 // createDayLabels(); 473 // createDayLabels();
437 474
438 // these blank widgets make the All Day Event box line up with the agenda 475 // these blank widgets make the All Day Event box line up with the agenda
439 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 476 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
440 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 477 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
441 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 478 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
442 479
443 // Scrolling 480 // Scrolling
444 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), 481 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)),
445 mTimeLabels, SLOT(positionChanged())); 482 mTimeLabels, SLOT(positionChanged()));
446 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), 483 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)),
447 SLOT(setContentsPos(int))); 484 SLOT(setContentsPos(int)));
448 485
449 // Create/Show/Edit/Delete Event 486 // Create/Show/Edit/Delete Event
450 connect(mAgenda,SIGNAL(newEventSignal(int,int)), 487 connect(mAgenda,SIGNAL(newEventSignal(int,int)),
451 SLOT(newEvent(int,int))); 488 SLOT(newEvent(int,int)));
452 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), 489 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)),
453 SLOT(newEvent(int,int,int,int))); 490 SLOT(newEvent(int,int,int,int)));
454 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), 491 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)),
455 SLOT(newEventAllDay(int,int))); 492 SLOT(newEventAllDay(int,int)));
456 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), 493 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)),
457 SLOT(newEventAllDay(int,int))); 494 SLOT(newEventAllDay(int,int)));
458 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 495 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
459 SLOT(newTimeSpanSelected(int,int,int,int))); 496 SLOT(newTimeSpanSelected(int,int,int,int)));
460 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 497 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
461 SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); 498 SLOT(newTimeSpanSelectedAllDay(int,int,int,int)));
462 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 499 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
463 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 500 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
464 501
465 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 502 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
466 SIGNAL(editIncidenceSignal(Incidence *))); 503 SIGNAL(editIncidenceSignal(Incidence *)));
467 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 504 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
468 SIGNAL(editIncidenceSignal(Incidence *))); 505 SIGNAL(editIncidenceSignal(Incidence *)));
469 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 506 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
470 SIGNAL(showIncidenceSignal(Incidence *))); 507 SIGNAL(showIncidenceSignal(Incidence *)));
471 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 508 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
472 SIGNAL(showIncidenceSignal(Incidence *))); 509 SIGNAL(showIncidenceSignal(Incidence *)));
473 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 510 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
474 SIGNAL(deleteIncidenceSignal(Incidence *))); 511 SIGNAL(deleteIncidenceSignal(Incidence *)));
475 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 512 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
476 SIGNAL(deleteIncidenceSignal(Incidence *))); 513 SIGNAL(deleteIncidenceSignal(Incidence *)));
477 514
478 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 515 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
479 SLOT(updateEventDates(KOAgendaItem *, int ))); 516 SLOT(updateEventDates(KOAgendaItem *, int )));
480 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 517 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
481 SLOT(updateEventDates(KOAgendaItem *, int))); 518 SLOT(updateEventDates(KOAgendaItem *, int)));
482 519
483 // event indicator update 520 // event indicator update
484 connect(mAgenda,SIGNAL(lowerYChanged(int)), 521 connect(mAgenda,SIGNAL(lowerYChanged(int)),
485 SLOT(updateEventIndicatorTop(int))); 522 SLOT(updateEventIndicatorTop(int)));
486 connect(mAgenda,SIGNAL(upperYChanged(int)), 523 connect(mAgenda,SIGNAL(upperYChanged(int)),
487 SLOT(updateEventIndicatorBottom(int))); 524 SLOT(updateEventIndicatorBottom(int)));
488 // drag signals 525 // drag signals
489 /* 526 /*
490 connect(mAgenda,SIGNAL(startDragSignal(Event *)), 527 connect(mAgenda,SIGNAL(startDragSignal(Event *)),
491 SLOT(startDrag(Event *))); 528 SLOT(startDrag(Event *)));
492 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), 529 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)),
493 SLOT(startDrag(Event *))); 530 SLOT(startDrag(Event *)));
494 */ 531 */
495 // synchronize selections 532 // synchronize selections
496 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 533 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
497 mAllDayAgenda, SLOT( deselectItem() ) ); 534 mAllDayAgenda, SLOT( deselectItem() ) );
498 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 535 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
499 mAgenda, SLOT( deselectItem() ) ); 536 mAgenda, SLOT( deselectItem() ) );
500 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 537 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
501 SIGNAL( incidenceSelected( Incidence * ) ) ); 538 SIGNAL( incidenceSelected( Incidence * ) ) );
502 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 539 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
503 SIGNAL( incidenceSelected( Incidence * ) ) ); 540 SIGNAL( incidenceSelected( Incidence * ) ) );
504 connect( mAgenda, SIGNAL( resizedSignal() ), 541 connect( mAgenda, SIGNAL( resizedSignal() ),
505 SLOT( updateConfig( ) ) ); 542 SLOT( updateConfig( ) ) );
506 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), 543 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ),
507 SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); 544 SLOT( addToCalSlot(Incidence *, Incidence * ) ) );
508 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), 545 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ),
509 SLOT( addToCalSlot(Incidence * , Incidence *) ) ); 546 SLOT( addToCalSlot(Incidence * , Incidence *) ) );
510 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 547 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
511 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 548 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
512 549
513 550
514} 551}
515 552
516void KOAgendaView::toggleAllDay() 553void KOAgendaView::toggleAllDay()
517{ 554{
518 if ( mSplitterAgenda->firstHandle() ) 555 if ( mSplitterAgenda->firstHandle() )
519 mSplitterAgenda->firstHandle()->toggle(); 556 mSplitterAgenda->firstHandle()->toggle();
520} 557}
521void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) 558void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld )
522{ 559{
523 calendar()->addIncidence( inc ); 560 calendar()->addIncidence( inc );
524 561
525 if ( incOld ) { 562 if ( incOld ) {
526 if ( incOld->type() == "Todo" ) 563 if ( incOld->type() == "Todo" )
527 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); 564 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED );
528 else 565 else
529 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); 566 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED);
530 } 567 }
531 568
532} 569}
533 570
534KOAgendaView::~KOAgendaView() 571KOAgendaView::~KOAgendaView()
535{ 572{
536 delete mAgendaPopup; 573 delete mAgendaPopup;
537 delete mAllDayAgendaPopup; 574 delete mAllDayAgendaPopup;
538 delete KOAgendaItem::paintPix(); 575 delete KOAgendaItem::paintPix();
539 delete KOAgendaItem::paintPixSel(); 576 delete KOAgendaItem::paintPixSel();
540} 577}
541void KOAgendaView::resizeEvent( QResizeEvent* e ) 578void KOAgendaView::resizeEvent( QResizeEvent* e )
542{ 579{
543 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); 580 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width());
544 bool uc = false; 581 bool uc = false;
545 int ow = e->oldSize().width(); 582 int ow = e->oldSize().width();
546 int oh = e->oldSize().height(); 583 int oh = e->oldSize().height();
547 int w = e->size().width(); 584 int w = e->size().width();
548 int h = e->size().height(); 585 int h = e->size().height();
549 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { 586 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) {
550 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) 587 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda )
551 uc = true; 588 uc = true;
552 //qDebug("view changed %d %d %d %d ", ow, oh , w , h); 589 //qDebug("view changed %d %d %d %d ", ow, oh , w , h);
553 } 590 }
554 mUpcomingWidth = e->size().width() ; 591 mUpcomingWidth = e->size().width() ;
555 if ( mBlockUpdating || uc ) { 592 if ( mBlockUpdating || uc ) {
556 mBlockUpdating = false; 593 mBlockUpdating = false;
557 //mAgenda->setMinimumSize(800 , 600 ); 594 //mAgenda->setMinimumSize(800 , 600 );
558 //qDebug("mAgenda->resize+++++++++++++++ "); 595 //qDebug("mAgenda->resize+++++++++++++++ ");
559 updateConfig(); 596 updateConfig();
560 //qDebug("KOAgendaView::Updating now possible "); 597 //qDebug("KOAgendaView::Updating now possible ");
561 } else 598 } else
562 createDayLabels(); 599 createDayLabels();
563 //qDebug("resizeEvent end "); 600 //qDebug("resizeEvent end ");
564 601
565} 602}
566void KOAgendaView::createDayLabels() 603void KOAgendaView::createDayLabels()
567{ 604{
568 605
569 if ( mBlockUpdating || globalFlagBlockLabel == 1) { 606 if ( mBlockUpdating || globalFlagBlockLabel == 1) {
570 // qDebug(" KOAgendaView::createDayLabels() blocked "); 607 // qDebug(" KOAgendaView::createDayLabels() blocked ");
571 return; 608 return;
572 609
573 } 610 }
574 int newHight; 611 int newHight;
575 612
576 // ### Before deleting and recreating we could check if mSelectedDates changed... 613 // ### Before deleting and recreating we could check if mSelectedDates changed...
577 // It would remove some flickering and gain speed (since this is called by 614 // It would remove some flickering and gain speed (since this is called by
578 // each updateView() call) 615 // each updateView() call)
579 616
580 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2; 617 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2;
581 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); 618 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth );
582 if ( maxWid < 0 ) 619 if ( maxWid < 0 )
583 maxWid = 20; 620 maxWid = 20;
584 621
585 QFont dlf = KOPrefs::instance()->mTimeLabelsFont; 622 QFont dlf = KOPrefs::instance()->mTimeLabelsFont;
586 QFontMetrics fm ( dlf ); 623 QFontMetrics fm ( dlf );
587 int selCount = mSelectedDates.count(); 624 int selCount = mSelectedDates.count();
588 QString dayTest = "Mon 20"; 625 QString dayTest = "Mon 20";
589 int wid = fm.width( dayTest ); 626 int wid = fm.width( dayTest );
590 maxWid -= ( selCount * 3 ); 627 maxWid -= ( selCount * 3 );
591 if ( maxWid < 0 ) 628 if ( maxWid < 0 )
592 maxWid = 20; 629 maxWid = 20;
593 int needWid = wid * selCount; 630 int needWid = wid * selCount;
594 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); 631 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid );
595 //if ( needWid > maxWid ) 632 //if ( needWid > maxWid )
596 // qDebug("DAYLABELS TOOOOOOO BIG "); 633 // qDebug("DAYLABELS TOOOOOOO BIG ");
597 while ( needWid > maxWid ) { 634 while ( needWid > maxWid ) {
598 dayTest = dayTest.left( dayTest.length() - 1 ); 635 dayTest = dayTest.left( dayTest.length() - 1 );
599 wid = fm.width( dayTest ); 636 wid = fm.width( dayTest );
600 needWid = wid * selCount; 637 needWid = wid * selCount;
601 } 638 }
602 int maxLen = dayTest.length(); 639 int maxLen = dayTest.length();
603 int fontPoint = dlf.pointSize(); 640 int fontPoint = dlf.pointSize();
604 if ( maxLen < 2 ) { 641 if ( maxLen < 2 ) {
605 int fontPoint = dlf.pointSize(); 642 int fontPoint = dlf.pointSize();
606 while ( fontPoint > 4 ) { 643 while ( fontPoint > 4 ) {
607 --fontPoint; 644 --fontPoint;
608 dlf.setPointSize( fontPoint ); 645 dlf.setPointSize( fontPoint );
609 QFontMetrics f( dlf ); 646 QFontMetrics f( dlf );
610 wid = f.width( "20" ); 647 wid = f.width( "20" );
611 needWid = wid * selCount; 648 needWid = wid * selCount;
612 if ( needWid < maxWid ) 649 if ( needWid < maxWid )
613 break; 650 break;
614 } 651 }
615 maxLen = 2; 652 maxLen = 2;
616 } 653 }
617 //qDebug("Max len %d ", dayTest.length() ); 654 //qDebug("Max len %d ", dayTest.length() );
618 655
619 QFontMetrics tempF( dlf ); 656 QFontMetrics tempF( dlf );
620 newHight = tempF.height(); 657 newHight = tempF.height();
621 mDayLabels->setFont( dlf ); 658 mDayLabels->setFont( dlf );
622 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; 659 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);;
623 // mLayoutDayLabels->addSpacing(mTimeLabels->width()); 660 // mLayoutDayLabels->addSpacing(mTimeLabels->width());
624 //mLayoutDayLabels->addSpacing( 2 ); 661 //mLayoutDayLabels->addSpacing( 2 );
625 // QFont lFont = dlf; 662 // QFont lFont = dlf;
626 bool appendLabels = false; 663 bool appendLabels = false;
627 QLabel *dayLabel; 664 QLabel *dayLabel;
628 dayLabel = mDayLabelsList.first(); 665 dayLabel = mDayLabelsList.first();
629 if ( !dayLabel ) { 666 if ( !dayLabel ) {
630 appendLabels = true; 667 appendLabels = true;
631 dayLabel = new QLabel(mDayLabels); 668 dayLabel = new QLabel(mDayLabels);
632 mDayLabelsList.append( dayLabel ); 669 mDayLabelsList.append( dayLabel );
633 mLayoutDayLabels->addWidget(dayLabel); 670 mLayoutDayLabels->addWidget(dayLabel);
634 } 671 }
635 dayLabel->setFixedWidth( mTimeLabels->width()+2 ); 672 dayLabel->setFixedWidth( mTimeLabels->width()+2 );
636 dayLabel->setFont( dlf ); 673 dayLabel->setFont( dlf );
637 dayLabel->setAlignment(QLabel::AlignHCenter); 674 dayLabel->setAlignment(QLabel::AlignHCenter);
638 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); 675 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) );
639 dayLabel->show(); 676 dayLabel->show();
640 DateList::ConstIterator dit; 677 DateList::ConstIterator dit;
641 bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); 678 bool oneday = (mSelectedDates.first() == mSelectedDates.last() );
642 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 679 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
643 QDate date = *dit; 680 QDate date = *dit;
644 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); 681 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels);
645 if ( ! appendLabels ) { 682 if ( ! appendLabels ) {
646 dayLabel = mDayLabelsList.next(); 683 dayLabel = mDayLabelsList.next();
647 if ( !dayLabel ) 684 if ( !dayLabel )
648 appendLabels = true; 685 appendLabels = true;
649 } 686 }
650 if ( appendLabels ) { 687 if ( appendLabels ) {
651 dayLabel = new QLabel(mDayLabels); 688 dayLabel = new QLabel(mDayLabels);
652 mDayLabelsList.append( dayLabel ); 689 mDayLabelsList.append( dayLabel );
653 mLayoutDayLabels->addWidget(dayLabel); 690 mLayoutDayLabels->addWidget(dayLabel);
654 } 691 }
655 dayLabel->setMinimumWidth( 1 ); 692 dayLabel->setMinimumWidth( 1 );
656 dayLabel->setMaximumWidth( 2048 ); 693 dayLabel->setMaximumWidth( 2048 );
657 dayLabel->setFont( dlf ); 694 dayLabel->setFont( dlf );
658 dayLabel->show(); 695 dayLabel->show();
659 QString str; 696 QString str;
660 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); 697 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date);
661 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); 698 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true );
662 switch ( maxLen ) { 699 switch ( maxLen ) {
663 case 2: 700 case 2:
664 str = QString::number( date.day() ); 701 str = QString::number( date.day() );
665 break; 702 break;
666 703
667 case 3: 704 case 3:
668 str = dayName.left( 1 ) +QString::number( date.day()); 705 str = dayName.left( 1 ) +QString::number( date.day());
669 706
670 break; 707 break;
671 case 4: 708 case 4:
672 str = dayName.left( 1 ) + " " +QString::number( date.day()); 709 str = dayName.left( 1 ) + " " +QString::number( date.day());
673 710
674 break; 711 break;
675 case 5: 712 case 5:
676 str = dayName.left( 2 ) + " " +QString::number( date.day()); 713 str = dayName.left( 2 ) + " " +QString::number( date.day());
677 714
678 break; 715 break;
679 case 6: 716 case 6:
680 str = dayName.left( 3 ) + " " +QString::number( date.day()); 717 str = dayName.left( 3 ) + " " +QString::number( date.day());
681 break; 718 break;
682 719
683 default: 720 default:
684 break; 721 break;
685 } 722 }
686 if ( oneday ) { 723 if ( oneday ) {
687 QString addString; 724 QString addString;
688 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) 725 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() )
689 addString = i18n("Today"); 726 addString = i18n("Today");
690 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) 727 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) )
691 addString = i18n("Tomorrow"); 728 addString = i18n("Tomorrow");
692 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) 729 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) )
693 addString = i18n("Yesterday"); 730 addString = i18n("Yesterday");
694 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) 731 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) )
695 addString = i18n("Day before yesterday"); 732 addString = i18n("Day before yesterday");
696 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) 733 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) )
697 addString = i18n("Day after tomorrow"); 734 addString = i18n("Day after tomorrow");
698 if ( !addString.isEmpty() ) { 735 if ( !addString.isEmpty() ) {
699 str = addString+", " + str; 736 str = addString+", " + str;
700 } 737 }
701 } 738 }
702 dayLabel->setText(str); 739 dayLabel->setText(str);
703 dayLabel->setAlignment(QLabel::AlignHCenter); 740 dayLabel->setAlignment(QLabel::AlignHCenter);
704 if (date == QDate::currentDate()) { 741 if (date == QDate::currentDate()) {
705 QFont bFont = dlf; 742 QFont bFont = dlf;
706 bFont.setBold( true ); 743 bFont.setBold( true );
707 dayLabel->setFont(bFont); 744 dayLabel->setFont(bFont);
708 } 745 }
709 //dayLayout->addWidget(dayLabel); 746 //dayLayout->addWidget(dayLabel);
710 747
711#ifndef KORG_NOPLUGINS 748#ifndef KORG_NOPLUGINS
712 CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); 749 CalendarDecoration::List cds = KOCore::self()->calendarDecorations();
713 CalendarDecoration *it; 750 CalendarDecoration *it;
714 for(it = cds.first(); it; it = cds.next()) { 751 for(it = cds.first(); it; it = cds.next()) {
715 QString text = it->shortText( date ); 752 QString text = it->shortText( date );
716 if ( !text.isEmpty() ) { 753 if ( !text.isEmpty() ) {
717 QLabel *label = new QLabel(text,mDayLabels); 754 QLabel *label = new QLabel(text,mDayLabels);
718 label->setAlignment(AlignCenter); 755 label->setAlignment(AlignCenter);
719 dayLayout->addWidget(label); 756 dayLayout->addWidget(label);
720 } 757 }
721 } 758 }
722 759
723 for(it = cds.first(); it; it = cds.next()) { 760 for(it = cds.first(); it; it = cds.next()) {
724 QWidget *wid = it->smallWidget(mDayLabels,date); 761 QWidget *wid = it->smallWidget(mDayLabels,date);
725 if ( wid ) { 762 if ( wid ) {
726 // wid->setHeight(20); 763 // wid->setHeight(20);
727 dayLayout->addWidget(wid); 764 dayLayout->addWidget(wid);
728 } 765 }
729 } 766 }
730#endif 767#endif
731 } 768 }
732 if ( ! appendLabels ) { 769 if ( ! appendLabels ) {
733 dayLabel = mDayLabelsList.next(); 770 dayLabel = mDayLabelsList.next();
734 if ( !dayLabel ) 771 if ( !dayLabel )
735 appendLabels = true; 772 appendLabels = true;
736 } 773 }
737 if ( appendLabels ) { 774 if ( appendLabels ) {
738 dayLabel = new QLabel(mDayLabels); 775 dayLabel = new QLabel(mDayLabels);
739 mDayLabelsList.append( dayLabel ); 776 mDayLabelsList.append( dayLabel );
740 mLayoutDayLabels->addWidget(dayLabel); 777 mLayoutDayLabels->addWidget(dayLabel);
741 } 778 }
742 //dayLabel->hide();//test only 779 //dayLabel->hide();//test only
743 780
744 int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ; 781 int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ;
745 if ( offset < 0 ) offset = 0; 782 if ( offset < 0 ) offset = 0;
746 //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); 783 //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 );
747 dayLabel->setText("");//QString::number ( mSelectedDates.first().month() ) ); 784 dayLabel->setText("");//QString::number ( mSelectedDates.first().month() ) );
748 dayLabel->show(); 785 dayLabel->show();
749 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); 786 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset );
750 //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); 787 //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2);
751 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); 788 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2);
752 if ( !appendLabels ) { 789 if ( !appendLabels ) {
753 dayLabel = mDayLabelsList.next(); 790 dayLabel = mDayLabelsList.next();
754 while ( dayLabel ) { 791 while ( dayLabel ) {
755 //qDebug("!dayLabel %d",dayLabel ); 792 //qDebug("!dayLabel %d",dayLabel );
756 dayLabel->hide(); 793 dayLabel->hide();
757 dayLabel = mDayLabelsList.next(); 794 dayLabel = mDayLabelsList.next();
758 } 795 }
759 } 796 }
760 //mDayLabelsFrame->show(); 797 //mDayLabelsFrame->show();
761 //mDayLabels->show(); 798 //mDayLabels->show();
762 //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight); 799 //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight);
763 //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight ); 800 //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight );
764 mDayLabelsFrame->setFixedHeight( newHight ); 801 mDayLabelsFrame->setFixedHeight( newHight );
765} 802}
766 803
767int KOAgendaView::maxDatesHint() 804int KOAgendaView::maxDatesHint()
768{ 805{
769 // Not sure about the max number of events, so return 0 for now. 806 // Not sure about the max number of events, so return 0 for now.
770 return 0; 807 return 0;
771} 808}
772 809
773int KOAgendaView::currentDateCount() 810int KOAgendaView::currentDateCount()
774{ 811{
775 return mSelectedDates.count(); 812 return mSelectedDates.count();
776} 813}
777 814
778QPtrList<Incidence> KOAgendaView::selectedIncidences() 815QPtrList<Incidence> KOAgendaView::selectedIncidences()
779{ 816{
780 QPtrList<Incidence> selected; 817 QPtrList<Incidence> selected;
781 Incidence *incidence; 818 Incidence *incidence;
782 819
783 incidence = mAgenda->selectedIncidence(); 820 incidence = mAgenda->selectedIncidence();
784 if (incidence) selected.append(incidence); 821 if (incidence) selected.append(incidence);
785 822
786 incidence = mAllDayAgenda->selectedIncidence(); 823 incidence = mAllDayAgenda->selectedIncidence();
787 if (incidence) selected.append(incidence); 824 if (incidence) selected.append(incidence);
788 825
789 return selected; 826 return selected;
790} 827}
791 828
792DateList KOAgendaView::selectedDates() 829DateList KOAgendaView::selectedDates()
793{ 830{
794 DateList selected; 831 DateList selected;
795 QDate qd; 832 QDate qd;
796 833
797 qd = mAgenda->selectedIncidenceDate(); 834 qd = mAgenda->selectedIncidenceDate();
798 if (qd.isValid()) selected.append(qd); 835 if (qd.isValid()) selected.append(qd);
799 836
800 qd = mAllDayAgenda->selectedIncidenceDate(); 837 qd = mAllDayAgenda->selectedIncidenceDate();
801 if (qd.isValid()) selected.append(qd); 838 if (qd.isValid()) selected.append(qd);
802 839
803 return selected; 840 return selected;
804} 841}
805 842
806 843
807void KOAgendaView::updateView() 844void KOAgendaView::updateView()
808{ 845{
809 if ( mBlockUpdating ) 846 if ( mBlockUpdating )
810 return; 847 return;
811 // kdDebug() << "KOAgendaView::updateView()" << endl; 848 // kdDebug() << "KOAgendaView::updateView()" << endl;
812 fillAgenda(); 849 fillAgenda();
813 850
814} 851}
815 852
816 853
817/* 854/*
818 Update configuration settings for the agenda view. This method is not 855 Update configuration settings for the agenda view. This method is not
819 complete. 856 complete.
820*/ 857*/
821void KOAgendaView::updateConfig() 858void KOAgendaView::updateConfig()
822{ 859{
823 if ( mBlockUpdating ) 860 if ( mBlockUpdating )
824 return; 861 return;
825 // kdDebug() << "KOAgendaView::updateConfig()" << endl; 862 // kdDebug() << "KOAgendaView::updateConfig()" << endl;
826 863
827 // update config for children 864 // update config for children
828 mTimeLabels->updateConfig(); 865 mTimeLabels->updateConfig();
829 mAgenda->storePosition(); 866 mAgenda->storePosition();
830 mAgenda->updateConfig(); 867 mAgenda->updateConfig();
831 mAllDayAgenda->updateConfig(); 868 mAllDayAgenda->updateConfig();
832 // widget synchronization 869 // widget synchronization
833 //TODO: find a better way, maybe signal/slot 870 //TODO: find a better way, maybe signal/slot
834 mTimeLabels->positionChanged(); 871 mTimeLabels->positionChanged();
835 872
836 // for some reason, this needs to be called explicitly 873 // for some reason, this needs to be called explicitly
837 mTimeLabels->repaint(); 874 mTimeLabels->repaint();
838 875
839 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 876 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
840 877
841 // ToolTips displaying summary of events 878 // ToolTips displaying summary of events
842 KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() 879 KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance()
843 ->mEnableToolTips); 880 ->mEnableToolTips);
844 881
845 //setHolidayMasks(); 882 //setHolidayMasks();
846 883
847 //createDayLabels(); called by via updateView(); 884 //createDayLabels(); called by via updateView();
848 mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); 885 mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth());
849 updateView(); 886 updateView();
850 mAgenda->restorePosition(); 887 mAgenda->restorePosition();
851} 888}
852 889
853 890
854void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) 891void KOAgendaView::updateEventDates(KOAgendaItem *item, int type)
855{ 892{
856 // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; 893 // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl;
857 //qDebug("KOAgendaView::updateEventDates "); 894 //qDebug("KOAgendaView::updateEventDates ");
858 QDateTime startDt,endDt; 895 QDateTime startDt,endDt;
859 QDate startDate; 896 QDate startDate;
860 int lenInSecs; 897 int lenInSecs;
861 // if ( type == KOAgenda::RESIZETOP ) 898 // if ( type == KOAgenda::RESIZETOP )
862 // qDebug("RESIZETOP "); 899 // qDebug("RESIZETOP ");
863 // if ( type == KOAgenda::RESIZEBOTTOM ) 900 // if ( type == KOAgenda::RESIZEBOTTOM )
864 // qDebug("RESIZEBOTTOM "); 901 // qDebug("RESIZEBOTTOM ");
865 // if ( type == KOAgenda::MOVE ) 902 // if ( type == KOAgenda::MOVE )
866 // qDebug("MOVE "); 903 // qDebug("MOVE ");
867 if ( item->incidence()->type() == "Event" ) { 904 if ( item->incidence()->type() == "Event" ) {
868 startDt =item->incidence()->dtStart(); 905 startDt =item->incidence()->dtStart();
869 endDt = item->incidence()->dtEnd(); 906 endDt = item->incidence()->dtEnd();
870 lenInSecs = startDt.secsTo( endDt ); 907 lenInSecs = startDt.secsTo( endDt );
871 } 908 }
872 909
873 // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); 910 // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED );
874 911
875 if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { 912 if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) {
876 startDate = mSelectedDates[item->mLastMoveXPos]; 913 startDate = mSelectedDates[item->mLastMoveXPos];
877 } else { 914 } else {
878 if (item->cellX() < 0) { 915 if (item->cellX() < 0) {
879 startDate = (mSelectedDates.first()).addDays(item->cellX()); 916 startDate = (mSelectedDates.first()).addDays(item->cellX());
880 } else { 917 } else {
881 startDate = mSelectedDates[item->cellX()]; 918 startDate = mSelectedDates[item->cellX()];
882 } 919 }
883 } 920 }
884 startDt.setDate(startDate); 921 startDt.setDate(startDate);
885 922
886 if (item->incidence()->doesFloat()) { 923 if (item->incidence()->doesFloat()) {
887 endDt.setDate(startDate.addDays(item->cellWidth() - 1)); 924 endDt.setDate(startDate.addDays(item->cellWidth() - 1));
888 } else { 925 } else {
889 if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) 926 if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE )
890 startDt.setTime(mAgenda->gyToTime(item->cellYTop())); 927 startDt.setTime(mAgenda->gyToTime(item->cellYTop()));
891 if ( item->incidence()->type() == "Event" ) { 928 if ( item->incidence()->type() == "Event" ) {
892 if ( type == KOAgenda::MOVE ) { 929 if ( type == KOAgenda::MOVE ) {
893 endDt = startDt.addSecs(lenInSecs); 930 endDt = startDt.addSecs(lenInSecs);
894 931
895 } else if ( type == KOAgenda::RESIZEBOTTOM ) { 932 } else if ( type == KOAgenda::RESIZEBOTTOM ) {
896 if (item->lastMultiItem()) { 933 if (item->lastMultiItem()) {
897 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 934 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
898 endDt.setDate(startDate. 935 endDt.setDate(startDate.
899 addDays(item->lastMultiItem()->cellX() - item->cellX())); 936 addDays(item->lastMultiItem()->cellX() - item->cellX()));
900 } else { 937 } else {
901 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 938 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
902 endDt.setDate(startDate); 939 endDt.setDate(startDate);
903 } 940 }
904 } 941 }
905 } else { 942 } else {
906 // todo 943 // todo
907 if (item->lastMultiItem()) { 944 if (item->lastMultiItem()) {
908 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 945 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
909 endDt.setDate(startDate. 946 endDt.setDate(startDate.
910 addDays(item->lastMultiItem()->cellX() - item->cellX())); 947 addDays(item->lastMultiItem()->cellX() - item->cellX()));
911 } else { 948 } else {
912 //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); 949 //qDebug("tem->cellYBottom() %d",item->cellYBottom() );
913 if ( item->cellYBottom() > 0 ) 950 if ( item->cellYBottom() > 0 )
914 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 951 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
915 else 952 else
916 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); 953 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time());
917 endDt.setDate(startDate); 954 endDt.setDate(startDate);
918 } 955 }
919 } 956 }
920 } 957 }
921 958
922 959
923 if ( item->incidence()->type() == "Event" ) { 960 if ( item->incidence()->type() == "Event" ) {
924 item->incidence()->setDtStart(startDt); 961 item->incidence()->setDtStart(startDt);
925 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); 962 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt);
926 } else if ( item->incidence()->type() == "Todo" ) { 963 } else if ( item->incidence()->type() == "Todo" ) {
927 (static_cast<Todo*>(item->incidence()))->setDtDue(endDt); 964 (static_cast<Todo*>(item->incidence()))->setDtDue(endDt);
928 } 965 }
929 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); 966 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() );
930 item->incidence()->setRevision(item->incidence()->revision()+1); 967 item->incidence()->setRevision(item->incidence()->revision()+1);
931 item->setItemDate(startDt.date()); 968 item->setItemDate(startDt.date());
932 //item->updateItem(); 969 //item->updateItem();
933 if ( item->incidence()->type() == "Todo" ) { 970 if ( item->incidence()->type() == "Todo" ) {
934 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); 971 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED );
935 972
936 } 973 }
937 else 974 else
938 emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); 975 emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED);
939 item->updateItem(); 976 item->updateItem();
940} 977}
941 978
942void KOAgendaView::showDates( const QDate &start, const QDate &end ) 979void KOAgendaView::showDates( const QDate &start, const QDate &end )
943{ 980{
944 // kdDebug() << "KOAgendaView::selectDates" << endl; 981 // kdDebug() << "KOAgendaView::selectDates" << endl;
945 982
946 mSelectedDates.clear(); 983 mSelectedDates.clear();
947 // qDebug("KOAgendaView::showDates "); 984 // qDebug("KOAgendaView::showDates ");
948 QDate d = start; 985 QDate d = start;
949 while (d <= end) { 986 while (d <= end) {
950 mSelectedDates.append(d); 987 mSelectedDates.append(d);
951 d = d.addDays( 1 ); 988 d = d.addDays( 1 );
952 } 989 }
953 990
954 // and update the view 991 // and update the view
955 fillAgenda(); 992 fillAgenda();
956} 993}
957 994
958 995
959void KOAgendaView::showEvents(QPtrList<Event>) 996void KOAgendaView::showEvents(QPtrList<Event>)
960{ 997{
961 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; 998 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl;
962} 999}
963 1000
964void KOAgendaView::changeEventDisplay(Event *, int) 1001void KOAgendaView::changeEventDisplay(Event *, int)
965{ 1002{
966 // qDebug("KOAgendaView::changeEventDisplay "); 1003 // qDebug("KOAgendaView::changeEventDisplay ");
967 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; 1004 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl;
968 // this should be re-written to be MUCH smarter. Right now we 1005 // this should be re-written to be MUCH smarter. Right now we
969 // are just playing dumb. 1006 // are just playing dumb.
970 fillAgenda(); 1007 fillAgenda();
971} 1008}
972 1009
973void KOAgendaView::fillAgenda(const QDate &) 1010void KOAgendaView::fillAgenda(const QDate &)
974{ 1011{
975 // qDebug("KOAgendaView::fillAgenda "); 1012 // qDebug("KOAgendaView::fillAgenda ");
976 fillAgenda(); 1013 fillAgenda();
977} 1014}
978 1015
979void KOAgendaView::fillAgenda() 1016void KOAgendaView::fillAgenda()
980{ 1017{
981 if ( globalFlagBlockStartup ) 1018 if ( globalFlagBlockStartup )
982 return; 1019 return;
983 if ( globalFlagBlockAgenda == 1 ) 1020 if ( globalFlagBlockAgenda == 1 )
984 return; 1021 return;
985 //if ( globalFlagBlockAgenda == 2 ) 1022 //if ( globalFlagBlockAgenda == 2 )
986 //globalFlagBlockAgenda = 0; 1023 //globalFlagBlockAgenda = 0;
987 // globalFlagBlockPainting = false; 1024 // globalFlagBlockPainting = false;
988 if ( globalFlagBlockAgenda == 0 ) 1025 if ( globalFlagBlockAgenda == 0 )
989 globalFlagBlockAgenda = 1; 1026 globalFlagBlockAgenda = 1;
990 // clearView(); 1027 // clearView();
991 //qDebug("fillAgenda()++++ "); 1028 //qDebug("fillAgenda()++++ ");
992 globalFlagBlockAgendaItemPaint = 1; 1029 globalFlagBlockAgendaItemPaint = 1;
993 mAllDayAgenda->changeColumns(mSelectedDates.count()); 1030 mAllDayAgenda->changeColumns(mSelectedDates.count());
994 mAgenda->changeColumns(mSelectedDates.count()); 1031 mAgenda->changeColumns(mSelectedDates.count());
995 qApp->processEvents(); 1032 qApp->processEvents();
996 mEventIndicatorTop->changeColumns(mSelectedDates.count()); 1033 mEventIndicatorTop->changeColumns(mSelectedDates.count());
997 mEventIndicatorBottom->changeColumns(mSelectedDates.count()); 1034 mEventIndicatorBottom->changeColumns(mSelectedDates.count());
998 setHolidayMasks(); 1035 setHolidayMasks();
999 1036
1000 //mAgenda->hideUnused(); 1037 //mAgenda->hideUnused();
1001 //mAllDayAgenda->hideUnused(); 1038 //mAllDayAgenda->hideUnused();
1002 1039
1003 // mAgenda->blockNextRepaint( false ); 1040 // mAgenda->blockNextRepaint( false );
1004 // mAgenda->viewport()->repaint(); 1041 // mAgenda->viewport()->repaint();
1005 // mAgenda->blockNextRepaint( true ); 1042 // mAgenda->blockNextRepaint( true );
1006 mMinY.resize(mSelectedDates.count()); 1043 mMinY.resize(mSelectedDates.count());
1007 mMaxY.resize(mSelectedDates.count()); 1044 mMaxY.resize(mSelectedDates.count());
1008 1045
1009 QPtrList<Event> dayEvents; 1046 QPtrList<Event> dayEvents;
1010 1047
1011 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1048 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1012 // Therefore, get all of them. 1049 // Therefore, get all of them.
1013 QPtrList<Todo> todos = calendar()->todos(); 1050 QPtrList<Todo> todos = calendar()->todos();
1014 1051
1015 mAgenda->setDateList(mSelectedDates); 1052 mAgenda->setDateList(mSelectedDates);
1016 1053
1017 QDate today = QDate::currentDate(); 1054 QDate today = QDate::currentDate();
1018 1055
1019 DateList::ConstIterator dit; 1056 DateList::ConstIterator dit;
1020 int curCol = 0; 1057 int curCol = 0;
1021 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 1058 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
1022 QDate currentDate = *dit; 1059 QDate currentDate = *dit;
1023 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() 1060 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString()
1024 // << endl; 1061 // << endl;
1025 1062
1026 dayEvents = calendar()->events(currentDate,true); 1063 dayEvents = calendar()->events(currentDate,true);
1027 1064
1028 // Default values, which can never be reached 1065 // Default values, which can never be reached
1029 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; 1066 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1;
1030 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; 1067 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1;
1031 1068
1032 unsigned int numEvent; 1069 unsigned int numEvent;
1033 for(numEvent=0;numEvent<dayEvents.count();++numEvent) { 1070 for(numEvent=0;numEvent<dayEvents.count();++numEvent) {
1034 Event *event = dayEvents.at(numEvent); 1071 Event *event = dayEvents.at(numEvent);
1035 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) 1072 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") )
1036 if ( event->uid().left(15) == QString("last-syncEvent-") ) 1073 if ( event->uid().left(15) == QString("last-syncEvent-") )
1037 continue; 1074 continue;
1038 // kdDebug() << " Event: " << event->summary() << endl; 1075 // kdDebug() << " Event: " << event->summary() << endl;
1039 1076
1040 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; 1077 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol;
1041 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; 1078 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol;
1042 1079
1043 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; 1080 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl;
1044 1081
1045 if (event->doesFloat()) { 1082 if (event->doesFloat()) {
1046 if (event->recurrence()->doesRecur()) { 1083 if (event->recurrence()->doesRecur()) {
1047 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); 1084 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol);
1048 } else { 1085 } else {
1049 if (beginX <= 0 && curCol == 0) { 1086 if (beginX <= 0 && curCol == 0) {
1050 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1087 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1051 } else if (beginX == curCol) { 1088 } else if (beginX == curCol) {
1052 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1089 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1053 } 1090 }
1054 } 1091 }
1055 } else if (event->isMultiDay()) { 1092 } else if (event->isMultiDay()) {
1056 if ( event->doesRecur () ) { 1093 if ( event->doesRecur () ) {
1057 QDate dateit = currentDate; 1094 QDate dateit = currentDate;
1058 int count = 0; 1095 int count = 0;
1059 int max = event->dtStart().daysTo( event->dtEnd() ) +2; 1096 int max = event->dtStart().daysTo( event->dtEnd() ) +2;
1060 while (! event->recursOn( dateit ) && count <= max ) { 1097 while (! event->recursOn( dateit ) && count <= max ) {
1061 ++count; 1098 ++count;
1062 dateit = dateit.addDays( -1 ); 1099 dateit = dateit.addDays( -1 );
1063 } 1100 }
1064 bool ok; 1101 bool ok;
1065 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); 1102 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok );
1066 if ( ok ) 1103 if ( ok )
1067 { 1104 {
1068 int secs = event->dtStart().secsTo( event->dtEnd() ); 1105 int secs = event->dtStart().secsTo( event->dtEnd() );
1069 QDateTime nextOcend =nextOcstart.addSecs( secs ); ; 1106 QDateTime nextOcend =nextOcstart.addSecs( secs ); ;
1070 beginX = currentDate.daysTo(nextOcstart.date()) + curCol; 1107 beginX = currentDate.daysTo(nextOcstart.date()) + curCol;
1071 endX = currentDate.daysTo(nextOcend.date()) + curCol; 1108 endX = currentDate.daysTo(nextOcend.date()) + curCol;
1072 1109
1073 } 1110 }
1074 } 1111 }
1075 int startY = mAgenda->timeToY(event->dtStart().time()); 1112 int startY = mAgenda->timeToY(event->dtStart().time());
1076 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1113 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1077 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); 1114 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol );
1078 if ((beginX <= 0 && curCol == 0) || beginX == curCol) { 1115 if ((beginX <= 0 && curCol == 0) || beginX == curCol) {
1079 //qDebug("insert!!! "); 1116 //qDebug("insert!!! ");
1080 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); 1117 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY);
1081 } 1118 }
1082 if (beginX == curCol) { 1119 if (beginX == curCol) {
1083 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1120 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1084 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1121 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1085 } else if (endX == curCol) { 1122 } else if (endX == curCol) {
1086 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1123 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1087 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1124 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1088 } else { 1125 } else {
1089 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1126 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1090 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1127 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1091 } 1128 }
1092 } else { 1129 } else {
1093 int startY = mAgenda->timeToY(event->dtStart().time()); 1130 int startY = mAgenda->timeToY(event->dtStart().time());
1094 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1131 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1095 if (endY < startY) endY = startY; 1132 if (endY < startY) endY = startY;
1096 mAgenda->insertItem(event,currentDate,curCol,startY,endY); 1133 mAgenda->insertItem(event,currentDate,curCol,startY,endY);
1097 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1134 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1098 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1135 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1099 } 1136 }
1100 } 1137 }
1101 // ---------- [display Todos -------------- 1138 // ---------- [display Todos --------------
1102 unsigned int numTodo; 1139 unsigned int numTodo;
1103 for (numTodo = 0; numTodo < todos.count(); ++numTodo) { 1140 for (numTodo = 0; numTodo < todos.count(); ++numTodo) {
1104 Todo *todo = todos.at(numTodo); 1141 Todo *todo = todos.at(numTodo);
1105 1142
1106 if ( ! todo->hasDueDate() ) continue; // todo shall not be displayed if it has no date 1143 if ( ! todo->hasDueDate() ) continue; // todo shall not be displayed if it has no date
1107 1144
1108 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1145 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1109 // Already completed items can be displayed on their original due date 1146 // Already completed items can be displayed on their original due date
1110 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda 1147 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda
1111 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; 1148 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda;
1112 1149
1113 if ( ((todo->dtDue().date() == currentDate) && !overdue) || 1150 if ( ((todo->dtDue().date() == currentDate) && !overdue) ||
1114 ((currentDate == today) && overdue) ) { 1151 ((currentDate == today) && overdue) ) {
1115 if ( todo->doesFloat() || overdue ) { // Todo has no due-time set or is already overdue 1152 if ( todo->doesFloat() || overdue ) { // Todo has no due-time set or is already overdue
1116 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1153 if ( KOPrefs::instance()->mShowTodoInAgenda )
1117 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); 1154 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol);
1118 } 1155 }
1119 else { 1156 else {
1120 1157
1121 int endY = mAgenda->timeToY(todo->dtDue().time()) - 1; 1158 int endY = mAgenda->timeToY(todo->dtDue().time()) - 1;
1122 int hi = (18/KOPrefs::instance()->mHourSize); 1159 int hi = (18/KOPrefs::instance()->mHourSize);
1123 //qDebug("hei %d ",KOPrefs::instance()->mHourSize); 1160 //qDebug("hei %d ",KOPrefs::instance()->mHourSize);
1124 int startY = endY -hi; 1161 int startY = endY -hi;
1125 1162
1126 mAgenda->insertItem(todo,currentDate,curCol,startY,endY); 1163 mAgenda->insertItem(todo,currentDate,curCol,startY,endY);
1127 1164
1128 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1165 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1129 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1166 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1130 } 1167 }
1131 } 1168 }
1132 } 1169 }
1133 // ---------- display Todos] -------------- 1170 // ---------- display Todos] --------------
1134 1171
1135 ++curCol; 1172 ++curCol;
1136 } 1173 }
1137 mAgenda->hideUnused(); 1174 mAgenda->hideUnused();
1138 mAllDayAgenda->hideUnused(); 1175 mAllDayAgenda->hideUnused();
1139 mAgenda->checkScrollBoundaries(); 1176 mAgenda->checkScrollBoundaries();
1140 1177
1141 deleteSelectedDateTime(); 1178 deleteSelectedDateTime();
1142 1179
1143 createDayLabels(); 1180 createDayLabels();
1144 emit incidenceSelected( 0 ); 1181 emit incidenceSelected( 0 );
1145 1182
1146 if ( globalFlagBlockAgenda == 2 ) { 1183 if ( globalFlagBlockAgenda == 2 ) {
1147 if ( KOPrefs::instance()->mSetTimeToDayStartAt ) 1184 if ( KOPrefs::instance()->mSetTimeToDayStartAt )
1148 setStartHour( KOPrefs::instance()->mDayBegins ); 1185 setStartHour( KOPrefs::instance()->mDayBegins );
1149 else if ( KOPrefs::instance()->mCenterOnCurrentTime ) 1186 else if ( KOPrefs::instance()->mCenterOnCurrentTime )
1150 setStartHour( QTime::currentTime ().hour() ); 1187 setStartHour( QTime::currentTime ().hour() );
1151 // qApp->processEvents(); 1188 // qApp->processEvents();
1152 } 1189 }
1153 qApp->processEvents(); 1190 qApp->processEvents();
1154 //qDebug("qApp->processEvents(); END "); 1191 //qDebug("qApp->processEvents(); END ");
1155 globalFlagBlockAgenda = 0; 1192 globalFlagBlockAgenda = 0;
1156 1193
1157 // mAgenda->hideUnused(); 1194 // mAgenda->hideUnused();
1158 //mAllDayAgenda->hideUnused(); 1195 //mAllDayAgenda->hideUnused();
1159 mAllDayAgenda->drawContentsToPainter(); 1196 mAllDayAgenda->drawContentsToPainter();
1160 mAgenda->drawContentsToPainter(); 1197 mAgenda->drawContentsToPainter();
1161 repaintAgenda(); 1198 repaintAgenda();
1162 // mAgenda->finishUpdate(); 1199 // mAgenda->finishUpdate();
1163 //mAllDayAgenda->finishUpdate(); 1200 //mAllDayAgenda->finishUpdate();
1164 1201
1165 // repaintAgenda(); 1202 // repaintAgenda();
1166 //qApp->processEvents(); 1203 //qApp->processEvents();
1167 // globalFlagBlockAgenda = 0; 1204 // globalFlagBlockAgenda = 0;
1168} 1205}
1169void KOAgendaView::repaintAgenda() 1206void KOAgendaView::repaintAgenda()
1170{ 1207{
1171 // mAllDayAgenda->drawContentsToPainter(); 1208 // mAllDayAgenda->drawContentsToPainter();
1172// mAllDayAgenda->viewport()->repaint( false ); 1209// mAllDayAgenda->viewport()->repaint( false );
1173// mAgenda->drawContentsToPainter(); 1210// mAgenda->drawContentsToPainter();
1174// mAgenda->viewport()->repaint( false ); 1211// mAgenda->viewport()->repaint( false );
1175// qApp->processEvents(); 1212// qApp->processEvents();
1176 1213
1177 //qDebug("KOAgendaView::repaintAgenda() "); 1214 //qDebug("KOAgendaView::repaintAgenda() ");
1178 //qApp->processEvents(); 1215 //qApp->processEvents();
1179 mAgenda->viewport()->repaint( false ); 1216 mAgenda->viewport()->repaint( false );
1180 mAllDayAgenda->viewport()->repaint( false ); 1217 mAllDayAgenda->viewport()->repaint( false );
1181 mAgenda->finishUpdate(); 1218 mAgenda->finishUpdate();
1182 mAllDayAgenda->finishUpdate(); 1219 mAllDayAgenda->finishUpdate();
1183} 1220}
1184 1221
1185 1222
1186void KOAgendaView::clearView() 1223void KOAgendaView::clearView()
1187{ 1224{
1188 // kdDebug() << "ClearView" << endl; 1225 // kdDebug() << "ClearView" << endl;
1189 mAllDayAgenda->clear(); 1226 mAllDayAgenda->clear();
1190 mAgenda->clear(); 1227 mAgenda->clear();
1191} 1228}
1192 1229
1193void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, 1230void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd,
1194 const QDate &td) 1231 const QDate &td)
1195{ 1232{
1196#ifndef KORG_NOPRINTER 1233#ifndef KORG_NOPRINTER
1197 if (fd == td) 1234 if (fd == td)
1198 calPrinter->preview(CalPrinter::Day, fd, td); 1235 calPrinter->preview(CalPrinter::Day, fd, td);
1199 else 1236 else
1200 calPrinter->preview(CalPrinter::Week, fd, td); 1237 calPrinter->preview(CalPrinter::Week, fd, td);
1201#endif 1238#endif
1202} 1239}
1203 1240
1204// void KOAgendaView::updateMovedTodo() 1241// void KOAgendaView::updateMovedTodo()
1205// { 1242// {
1206// // updateConfig(); 1243// // updateConfig();
1207// // emit updateTodoViews(); 1244// // emit updateTodoViews();
1208// } 1245// }
1209 1246
1210void KOAgendaView::newEvent(int gx, int gy) 1247void KOAgendaView::newEvent(int gx, int gy)
1211{ 1248{
1212 if (!mSelectedDates.count()) return; 1249 if (!mSelectedDates.count()) return;
1213 1250
1214 QDate day = mSelectedDates[gx]; 1251 QDate day = mSelectedDates[gx];
1215 1252
1216 QTime time = mAgenda->gyToTime(gy); 1253 QTime time = mAgenda->gyToTime(gy);
1217 QDateTime dt(day,time); 1254 QDateTime dt(day,time);
1218 // if ( dt < QDateTime::currentDateTime () ) 1255 // if ( dt < QDateTime::currentDateTime () )
1219 // dt = QDateTime::currentDateTime ().addSecs( 3600 ); 1256 // dt = QDateTime::currentDateTime ().addSecs( 3600 );
1220 emit newEventSignal(dt); 1257 emit newEventSignal(dt);
1221} 1258}
1222 1259
1223void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) 1260void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd)
1224{ 1261{
1225 if (!mSelectedDates.count()) return; 1262 if (!mSelectedDates.count()) return;
1226 1263
1227 QDate dayStart = mSelectedDates[gxStart]; 1264 QDate dayStart = mSelectedDates[gxStart];
1228 QDate dayEnd = mSelectedDates[gxEnd]; 1265 QDate dayEnd = mSelectedDates[gxEnd];
1229 1266
1230 QTime timeStart = mAgenda->gyToTime(gyStart); 1267 QTime timeStart = mAgenda->gyToTime(gyStart);
1231 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); 1268 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 );
1232 1269
1233 QDateTime dtStart(dayStart,timeStart); 1270 QDateTime dtStart(dayStart,timeStart);
1234 QDateTime dtEnd(dayEnd,timeEnd); 1271 QDateTime dtEnd(dayEnd,timeEnd);
1235 1272
1236 emit newEventSignal(dtStart,dtEnd); 1273 emit newEventSignal(dtStart,dtEnd);
1237} 1274}
1238 1275
1239void KOAgendaView::newEventAllDay(int gx, int ) 1276void KOAgendaView::newEventAllDay(int gx, int )
1240{ 1277{
1241 if (!mSelectedDates.count()) return; 1278 if (!mSelectedDates.count()) return;
1242 1279
1243 QDate day = mSelectedDates[gx]; 1280 QDate day = mSelectedDates[gx];
1244 1281
1245 emit newEventSignal(day); 1282 emit newEventSignal(day);
1246} 1283}
1247 1284
1248void KOAgendaView::updateEventIndicatorTop(int newY) 1285void KOAgendaView::updateEventIndicatorTop(int newY)
1249{ 1286{
1250 uint i; 1287 uint i;
1251 for(i=0;i<mMinY.size();++i) { 1288 for(i=0;i<mMinY.size();++i) {
1252 if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); 1289 if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true);
1253 else mEventIndicatorTop->enableColumn(i,false); 1290 else mEventIndicatorTop->enableColumn(i,false);
1254 } 1291 }
1255 1292
1256 mEventIndicatorTop->update(); 1293 mEventIndicatorTop->update();
1257} 1294}
1258 1295
1259void KOAgendaView::updateEventIndicatorBottom(int newY) 1296void KOAgendaView::updateEventIndicatorBottom(int newY)
1260{ 1297{
1261 uint i; 1298 uint i;
1262 for(i=0;i<mMaxY.size();++i) { 1299 for(i=0;i<mMaxY.size();++i) {
1263 if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); 1300 if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true);
1264 else mEventIndicatorBottom->enableColumn(i,false); 1301 else mEventIndicatorBottom->enableColumn(i,false);
1265 } 1302 }
1266 1303
1267 mEventIndicatorBottom->update(); 1304 mEventIndicatorBottom->update();
1268} 1305}
1269 1306
1270void KOAgendaView::startDrag(Event *event) 1307void KOAgendaView::startDrag(Event *event)
1271{ 1308{
1272#ifndef KORG_NODND 1309#ifndef KORG_NODND
1273 DndFactory factory( calendar() ); 1310 DndFactory factory( calendar() );
1274 ICalDrag *vd = factory.createDrag(event,this); 1311 ICalDrag *vd = factory.createDrag(event,this);
1275 if (vd->drag()) { 1312 if (vd->drag()) {
1276 kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; 1313 kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl;
1277 } 1314 }
1278#endif 1315#endif
1279} 1316}
1280 1317
1281void KOAgendaView::readSettings() 1318void KOAgendaView::readSettings()
1282{ 1319{
1283 readSettings(KOGlobals::config()); 1320 readSettings(KOGlobals::config());
1284} 1321}
1285 1322
1286void KOAgendaView::readSettings(KConfig *config) 1323void KOAgendaView::readSettings(KConfig *config)
1287{ 1324{
1288 // kdDebug() << "KOAgendaView::readSettings()" << endl; 1325 // kdDebug() << "KOAgendaView::readSettings()" << endl;
1289 1326
1290 config->setGroup("Views"); 1327 config->setGroup("Views");
1291 1328
1292 //#ifndef KORG_NOSPLITTER 1329 //#ifndef KORG_NOSPLITTER
1293 QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); 1330 QValueList<int> sizes = config->readIntListEntry("Separator AgendaView");
1294 if (sizes.count() == 2) { 1331 if (sizes.count() == 2) {
1295 if ( sizes[0] < 20 ) { 1332 if ( sizes[0] < 20 ) {
1296 sizes[1] = sizes[1] +20 - sizes[0]; 1333 sizes[1] = sizes[1] +20 - sizes[0];
1297 sizes[0] = 20; 1334 sizes[0] = 20;
1298 } 1335 }
1299 mSplitterAgenda->setSizes(sizes); 1336 mSplitterAgenda->setSizes(sizes);
1300 // qDebug("read %d %d ",sizes[0],sizes[1] ); 1337 // qDebug("read %d %d ",sizes[0],sizes[1] );
1301 } 1338 }
1302 //#endif 1339 //#endif
1303 1340
1304 // updateConfig(); 1341 // updateConfig();
1305} 1342}
1306 1343
1307void KOAgendaView::writeSettings(KConfig *config) 1344void KOAgendaView::writeSettings(KConfig *config)
1308{ 1345{
1309 // kdDebug() << "KOAgendaView::writeSettings()" << endl; 1346 // kdDebug() << "KOAgendaView::writeSettings()" << endl;
1310 1347
1311 config->setGroup("Views"); 1348 config->setGroup("Views");
1312 1349
1313 //#ifndef KORG_NOSPLITTER 1350 //#ifndef KORG_NOSPLITTER
1314 QValueList<int> list = mSplitterAgenda->sizes(); 1351 QValueList<int> list = mSplitterAgenda->sizes();
1315 config->writeEntry("Separator AgendaView",list); 1352 config->writeEntry("Separator AgendaView",list);
1316 //qDebug("write %d %d ", list[0],list[1] ); 1353 //qDebug("write %d %d ", list[0],list[1] );
1317 //#endif 1354 //#endif
1318} 1355}
1319 1356
1320void KOAgendaView::setHolidayMasks() 1357void KOAgendaView::setHolidayMasks()
1321{ 1358{
1322 mHolidayMask.resize(mSelectedDates.count()); 1359 mHolidayMask.resize(mSelectedDates.count());
1323 1360
1324 uint i; 1361 uint i;
1325 for(i=0;i<mSelectedDates.count();++i) { 1362 for(i=0;i<mSelectedDates.count();++i) {
1326 QDate date = mSelectedDates[i]; 1363 QDate date = mSelectedDates[i];
1327 bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); 1364 bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6);
1328 bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); 1365 bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7);
1329 bool showHoliday = false; 1366 bool showHoliday = false;
1330 if ( KOPrefs::instance()->mExcludeHolidays ) { 1367 if ( KOPrefs::instance()->mExcludeHolidays ) {
1331 QPtrList<Event> events = calendar()->events( date, true ); 1368 QPtrList<Event> events = calendar()->events( date, true );
1332 Event *event; 1369 Event *event;
1333 for( event = events.first(); event; event = events.next() ) { 1370 for( event = events.first(); event; event = events.next() ) {
1334 if ( event->categories().contains("Holiday") || 1371 if ( event->categories().contains("Holiday") ||
1335 event->categories().contains(i18n("Holiday"))) { 1372 event->categories().contains(i18n("Holiday"))) {
1336 showHoliday = true; 1373 showHoliday = true;
1337 break; 1374 break;
1338 } 1375 }
1339 } 1376 }
1340 1377
1341 } 1378 }
1342 1379
1343#ifndef KORG_NOPLUGINS 1380#ifndef KORG_NOPLUGINS
1344 bool showHoliday = KOPrefs::instance()->mExcludeHolidays && 1381 bool showHoliday = KOPrefs::instance()->mExcludeHolidays &&
1345 !KOCore::self()->holiday(date).isEmpty(); 1382 !KOCore::self()->holiday(date).isEmpty();
1346#endif 1383#endif
1347 bool showDay = showSaturday || showSunday || showHoliday; 1384 bool showDay = showSaturday || showSunday || showHoliday;
1348 1385
1349 if (showDay) { 1386 if (showDay) {
1350 mHolidayMask.at(i) = true; 1387 mHolidayMask.at(i) = true;
1351 } else { 1388 } else {
1352 mHolidayMask.at(i) = false; 1389 mHolidayMask.at(i) = false;
1353 } 1390 }
1354 } 1391 }
1355 1392
1356 mAgenda->setHolidayMask(&mHolidayMask); 1393 mAgenda->setHolidayMask(&mHolidayMask);
1357 mAllDayAgenda->setHolidayMask(&mHolidayMask); 1394 mAllDayAgenda->setHolidayMask(&mHolidayMask);
1358} 1395}
1359 1396
1360void KOAgendaView::setContentsPos(int y) 1397void KOAgendaView::setContentsPos(int y)
1361{ 1398{
1362 mAgenda->setContentsPos(0,y); 1399 mAgenda->setContentsPos(0,y);
1363} 1400}
1364 1401
1365void KOAgendaView::setExpandedButton( bool expanded ) 1402void KOAgendaView::setExpandedButton( bool expanded )
1366{ 1403{
1367 if ( expanded ) { 1404 if ( expanded ) {
1368 mExpandButton->setPixmap( mExpandedPixmap ); 1405 mExpandButton->setPixmap( mExpandedPixmap );
1369 } else { 1406 } else {
1370 mExpandButton->setPixmap( mNotExpandedPixmap ); 1407 mExpandButton->setPixmap( mNotExpandedPixmap );
1371 } 1408 }
1372} 1409}
1373 1410
1374void KOAgendaView::clearSelection() 1411void KOAgendaView::clearSelection()
1375{ 1412{
1376 mAgenda->deselectItem(); 1413 mAgenda->deselectItem();
1377 mAllDayAgenda->deselectItem(); 1414 mAllDayAgenda->deselectItem();
1378} 1415}
1379 1416
1380void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, 1417void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart,
1381 int gxEnd, int gyEnd) 1418 int gxEnd, int gyEnd)
1382{ 1419{
1383 mTimeSpanInAllDay = true; 1420 mTimeSpanInAllDay = true;
1384 newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); 1421 newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd);
1385} 1422}
1386 1423
1387 1424
1388 1425
1389 1426
1390void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart, 1427void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart,
1391 int gxEnd, int gyEnd) 1428 int gxEnd, int gyEnd)
1392{ 1429{
1393 if (!mSelectedDates.count()) return; 1430 if (!mSelectedDates.count()) return;
1394 1431
1395 QDate dayStart = mSelectedDates[gxStart]; 1432 QDate dayStart = mSelectedDates[gxStart];
1396 QDate dayEnd = mSelectedDates[gxEnd]; 1433 QDate dayEnd = mSelectedDates[gxEnd];
1397 1434
1398 QTime timeStart = mAgenda->gyToTime(gyStart); 1435 QTime timeStart = mAgenda->gyToTime(gyStart);
1399 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); 1436 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 );
1400 1437
1401 QDateTime dtStart(dayStart,timeStart); 1438 QDateTime dtStart(dayStart,timeStart);
1402 QDateTime dtEnd(dayEnd,timeEnd); 1439 QDateTime dtEnd(dayEnd,timeEnd);
1403 1440
1404 mTimeSpanBegin = dtStart; 1441 mTimeSpanBegin = dtStart;
1405 mTimeSpanEnd = dtEnd; 1442 mTimeSpanEnd = dtEnd;
1406 1443
1407} 1444}
1408 1445
1409void KOAgendaView::deleteSelectedDateTime() 1446void KOAgendaView::deleteSelectedDateTime()
1410{ 1447{
1411 mTimeSpanBegin.setDate(QDate()); 1448 mTimeSpanBegin.setDate(QDate());
1412 mTimeSpanEnd.setDate(QDate()); 1449 mTimeSpanEnd.setDate(QDate());
1413 mTimeSpanInAllDay = false; 1450 mTimeSpanInAllDay = false;
1414} 1451}
1415 1452
1416void KOAgendaView::keyPressEvent ( QKeyEvent * e ) 1453void KOAgendaView::keyPressEvent ( QKeyEvent * e )
1417{ 1454{
1418 e->ignore(); 1455 e->ignore();
1419} 1456}
1420 1457
1421void KOAgendaView::scrollOneHourUp() 1458void KOAgendaView::scrollOneHourUp()
1422{ 1459{
1423 1460
1424 mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 ); 1461 mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 );
1425} 1462}
1426void KOAgendaView::scrollOneHourDown() 1463void KOAgendaView::scrollOneHourDown()
1427{ 1464{
1428 mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 ); 1465 mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 );
1429} 1466}
1430 1467
1431void KOAgendaView::setStartHour( int h ) 1468void KOAgendaView::setStartHour( int h )
1432{ 1469{
1433 mAgenda->setStartHour( h ); 1470 mAgenda->setStartHour( h );
1434 1471
1435} 1472}
1436 1473
1437void KOAgendaView::updateTodo( Todo * t, int ) 1474void KOAgendaView::updateTodo( Todo * t, int )
1438{ 1475{
1439 1476
1440 bool remove = false; 1477 bool remove = false;
1441 bool removeAD = false; 1478 bool removeAD = false;
1442 if ( ! t->hasDueDate() ) { 1479 if ( ! t->hasDueDate() ) {
1443 remove = true; 1480 remove = true;
1444 removeAD = true; 1481 removeAD = true;
1445 } 1482 }
1446 else { 1483 else {
1447 bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ; 1484 bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ;
1448 if ( overdue && 1485 if ( overdue &&
1449 QDate::currentDate() >= mSelectedDates.first() && 1486 QDate::currentDate() >= mSelectedDates.first() &&
1450 QDate::currentDate() <= mSelectedDates.last()) { 1487 QDate::currentDate() <= mSelectedDates.last()) {
1451 removeAD = false; 1488 removeAD = false;
1452 remove = true; 1489 remove = true;
1453 } 1490 }
1454 else { 1491 else {
1455 if ( t->dtDue().date() < mSelectedDates.first() || 1492 if ( t->dtDue().date() < mSelectedDates.first() ||
1456 t->dtDue().date() > mSelectedDates.last() ) { 1493 t->dtDue().date() > mSelectedDates.last() ) {
1457 remove = true; 1494 remove = true;
1458 removeAD = true; 1495 removeAD = true;
1459 } else { 1496 } else {
1460 remove = t->doesFloat(); 1497 remove = t->doesFloat();
1461 removeAD = !remove; 1498 removeAD = !remove;
1462 } 1499 }
1463 } 1500 }
1464 } 1501 }
1465 int days = mSelectedDates.first().daysTo( t->dtDue().date() ); 1502 int days = mSelectedDates.first().daysTo( t->dtDue().date() );
1466 // qDebug("daysto %d ", days ); 1503 // qDebug("daysto %d ", days );
1467 mAgenda->updateTodo( t , days, remove); 1504 mAgenda->updateTodo( t , days, remove);
1468 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1505 if ( KOPrefs::instance()->mShowTodoInAgenda )
1469 mAllDayAgenda->updateTodo( t , days, removeAD); 1506 mAllDayAgenda->updateTodo( t , days, removeAD);
1470 //qDebug("KOAgendaView::updateTodo( Todo *, int ) "); 1507 //qDebug("KOAgendaView::updateTodo( Todo *, int ) ");
1471 1508
1472} 1509}
diff --git a/korganizer/koagendaview.h b/korganizer/koagendaview.h
index 0079253..221b0ea 100644
--- a/korganizer/koagendaview.h
+++ b/korganizer/koagendaview.h
@@ -1,252 +1,257 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23#ifndef KOAGENDAVIEW_H 23#ifndef KOAGENDAVIEW_H
24#define KOAGENDAVIEW_H 24#define KOAGENDAVIEW_H
25 25
26#include <qscrollview.h> 26#include <qscrollview.h>
27#include <qdatetime.h> 27#include <qdatetime.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#ifndef DESKTOP_VERSION 29#ifndef DESKTOP_VERSION
30#include <qksplitter.h> 30#include <qksplitter.h>
31#else 31#else
32#include <qsplitter.h> 32#include <qsplitter.h>
33#endif 33#endif
34#include <qmemarray.h> 34#include <qmemarray.h>
35 35
36#include "koeventview.h" 36#include "koeventview.h"
37 37
38 38
39class QHBox; 39class QHBox;
40class QFrame; 40class QFrame;
41class QLabel; 41class QLabel;
42class QPushButton; 42class QPushButton;
43class CalendarView; 43class CalendarView;
44class KOAgenda; 44class KOAgenda;
45class KOAgendaItem; 45class KOAgendaItem;
46class KConfig; 46class KConfig;
47class KDGanttMinimizeSplitter; 47class KDGanttMinimizeSplitter;
48class TimeLabels : public QScrollView { 48class TimeLabels : public QScrollView {
49 Q_OBJECT 49 Q_OBJECT
50 public: 50 public:
51 TimeLabels(int rows,QWidget *parent=0,const char *name=0,WFlags f=0); 51 TimeLabels(int rows,QWidget *parent=0,const char *name=0,WFlags f=0);
52 52
53 void setCellHeight(int height); 53 void setCellHeight(int height);
54 54
55 /** Calculates the minimum width */ 55 /** Calculates the minimum width */
56 virtual int minimumWidth() const; 56 virtual int minimumWidth() const;
57 57
58 /** updates widget's internal state */ 58 /** updates widget's internal state */
59 void updateConfig(); 59 void updateConfig();
60 60
61 /** */ 61 /** */
62 void setAgenda(KOAgenda* agenda); 62 void setAgenda(KOAgenda* agenda);
63 63
64 /** */ 64 /** */
65 virtual void paintEvent(QPaintEvent* e); 65 virtual void paintEvent(QPaintEvent* e);
66 void contentsMousePressEvent ( QMouseEvent * ) ;
67 void contentsMouseReleaseEvent ( QMouseEvent * );
68 void contentsMouseMoveEvent ( QMouseEvent * );
66 69
67 public slots: 70 public slots:
68 /** update time label positions */ 71 /** update time label positions */
69 void positionChanged(); 72 void positionChanged();
70 73 signals:
74 void scaleChanged();
71 protected: 75 protected:
72 void drawContents(QPainter *p,int cx, int cy, int cw, int ch); 76 void drawContents(QPainter *p,int cx, int cy, int cw, int ch);
73 77
74 private: 78 private:
79 int mMouseDownY;
75 int mRows; 80 int mRows;
76 int mCellHeight; 81 int mCellHeight;
77 82
78 /** */ 83 /** */
79 KOAgenda* mAgenda; 84 KOAgenda* mAgenda;
80}; 85};
81 86
82class EventIndicator : public QFrame { 87class EventIndicator : public QFrame {
83 Q_OBJECT 88 Q_OBJECT
84 public: 89 public:
85 enum Location { Top, Bottom }; 90 enum Location { Top, Bottom };
86 EventIndicator(Location loc=Top,QWidget *parent=0,const char *name=0); 91 EventIndicator(Location loc=Top,QWidget *parent=0,const char *name=0);
87 virtual ~EventIndicator(); 92 virtual ~EventIndicator();
88 93
89 void changeColumns(int columns); 94 void changeColumns(int columns);
90 void setPaintWidget( KDGanttMinimizeSplitter* ); 95 void setPaintWidget( KDGanttMinimizeSplitter* );
91 void setXOffset( int ); 96 void setXOffset( int );
92 void enableColumn(int column, bool enable); 97 void enableColumn(int column, bool enable);
93 98
94 protected: 99 protected:
95 void drawContents(QPainter *); 100 void drawContents(QPainter *);
96 101
97 private: 102 private:
98 int mXOffset; 103 int mXOffset;
99 KDGanttMinimizeSplitter* mPaintWidget; 104 KDGanttMinimizeSplitter* mPaintWidget;
100 int mColumns; 105 int mColumns;
101 QHBox *mTopBox; 106 QHBox *mTopBox;
102 QBoxLayout *mTopLayout; 107 QBoxLayout *mTopLayout;
103 Location mLocation; 108 Location mLocation;
104 QPixmap mPixmap; 109 QPixmap mPixmap;
105 QMemArray<bool> mEnabled; 110 QMemArray<bool> mEnabled;
106}; 111};
107 112
108/** 113/**
109 KOAgendaView is the agenda-like view used to display events in an one or 114 KOAgendaView is the agenda-like view used to display events in an one or
110 multi-day view. 115 multi-day view.
111*/ 116*/
112class KOAgendaView : public KOEventView { 117class KOAgendaView : public KOEventView {
113 Q_OBJECT 118 Q_OBJECT
114 public: 119 public:
115 KOAgendaView(Calendar *cal,QWidget *parent = 0,const char *name = 0 ); 120 KOAgendaView(Calendar *cal,QWidget *parent = 0,const char *name = 0 );
116 virtual ~KOAgendaView(); 121 virtual ~KOAgendaView();
117 void setStartHour( int ); 122 void setStartHour( int );
118 void toggleAllDay(); 123 void toggleAllDay();
119 124
120 125
121 /** Returns maximum number of days supported by the koagendaview */ 126 /** Returns maximum number of days supported by the koagendaview */
122 virtual int maxDatesHint(); 127 virtual int maxDatesHint();
123 128
124 /** Returns number of currently shown dates. */ 129 /** Returns number of currently shown dates. */
125 virtual int currentDateCount(); 130 virtual int currentDateCount();
126 131
127 /** returns the currently selected events */ 132 /** returns the currently selected events */
128 virtual QPtrList<Incidence> selectedIncidences(); 133 virtual QPtrList<Incidence> selectedIncidences();
129 134
130 /** returns the currently selected events */ 135 /** returns the currently selected events */
131 virtual DateList selectedDates(); 136 virtual DateList selectedDates();
132 137
133 /** Remove all events from view */ 138 /** Remove all events from view */
134 void clearView(); 139 void clearView();
135 KOAgenda *agenda() { return mAgenda;} 140 KOAgenda *agenda() { return mAgenda;}
136 virtual void printPreview(CalPrinter *calPrinter, 141 virtual void printPreview(CalPrinter *calPrinter,
137 const QDate &, const QDate &); 142 const QDate &, const QDate &);
138 143
139 /** start-datetime of selection */ 144 /** start-datetime of selection */
140 QDateTime selectionStart() {return mTimeSpanBegin;} 145 QDateTime selectionStart() {return mTimeSpanBegin;}
141 /** end-datetime of selection */ 146 /** end-datetime of selection */
142 QDateTime selectionEnd() {return mTimeSpanEnd;} 147 QDateTime selectionEnd() {return mTimeSpanEnd;}
143 /** returns true if selection is for whole day */ 148 /** returns true if selection is for whole day */
144 bool selectedIsAllDay() {return mTimeSpanInAllDay;} 149 bool selectedIsAllDay() {return mTimeSpanInAllDay;}
145 /** make selected start/end invalid */ 150 /** make selected start/end invalid */
146 void deleteSelectedDateTime(); 151 void deleteSelectedDateTime();
147 void repaintAgenda(); 152 void repaintAgenda();
148 public slots: 153 public slots:
149 virtual void updateView(); 154 virtual void updateView();
150 virtual void updateConfig(); 155 virtual void updateConfig();
151 virtual void showDates(const QDate &start, const QDate &end); 156 virtual void showDates(const QDate &start, const QDate &end);
152 virtual void showEvents(QPtrList<Event> eventList); 157 virtual void showEvents(QPtrList<Event> eventList);
153 158
154 void updateTodo( Todo *, int ); 159 void updateTodo( Todo *, int );
155 void changeEventDisplay(Event *, int); 160 void changeEventDisplay(Event *, int);
156 161
157 void clearSelection(); 162 void clearSelection();
158 163
159 void newEvent(int gx,int gy); 164 void newEvent(int gx,int gy);
160 void newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd); 165 void newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd);
161 void newEventAllDay(int gx, int gy); 166 void newEventAllDay(int gx, int gy);
162 167
163 void startDrag(Event *); 168 void startDrag(Event *);
164 169
165 void readSettings(); 170 void readSettings();
166 void readSettings(KConfig *); 171 void readSettings(KConfig *);
167 void writeSettings(KConfig *); 172 void writeSettings(KConfig *);
168 173
169 void setContentsPos(int y); 174 void setContentsPos(int y);
170 175
171 void setExpandedButton( bool expanded ); 176 void setExpandedButton( bool expanded );
172 void scrollOneHourUp(); 177 void scrollOneHourUp();
173 void scrollOneHourDown(); 178 void scrollOneHourDown();
174 void addToCalSlot(Incidence *, Incidence *); 179 void addToCalSlot(Incidence *, Incidence *);
175 180
176 signals: 181 signals:
177 void toggleExpand(); 182 void toggleExpand();
178 void todoMoved( Todo *, int ); 183 void todoMoved( Todo *, int );
179 void incidenceChanged(Incidence * , int ); 184 void incidenceChanged(Incidence * , int );
180 // void cloneIncidenceSignal(Incidence *); 185 // void cloneIncidenceSignal(Incidence *);
181 186
182 protected: 187 protected:
183 bool mBlockUpdating; 188 bool mBlockUpdating;
184 int mUpcomingWidth; 189 int mUpcomingWidth;
185 /** Fill agenda beginning with date startDate */ 190 /** Fill agenda beginning with date startDate */
186 void fillAgenda(const QDate &startDate); 191 void fillAgenda(const QDate &startDate);
187 void resizeEvent( QResizeEvent* e ); 192 void resizeEvent( QResizeEvent* e );
188 /** Fill agenda using the current set value for the start date */ 193 /** Fill agenda using the current set value for the start date */
189 void fillAgenda(); 194 void fillAgenda();
190 195
191 /** Create labels for the selected dates. */ 196 /** Create labels for the selected dates. */
192 void createDayLabels(); 197 void createDayLabels();
193 198
194 /** 199 /**
195 Set the masks on the agenda widgets indicating, which days are holidays. 200 Set the masks on the agenda widgets indicating, which days are holidays.
196 */ 201 */
197 void setHolidayMasks(); 202 void setHolidayMasks();
198 203
199 protected slots: 204 protected slots:
200 /** Update event belonging to agenda item */ 205 /** Update event belonging to agenda item */
201 void updateEventDates(KOAgendaItem *item, int mode = -1); 206 void updateEventDates(KOAgendaItem *item, int mode = -1);
202 //void updateMovedTodo(); 207 //void updateMovedTodo();
203 208
204 void updateEventIndicatorTop(int newY); 209 void updateEventIndicatorTop(int newY);
205 void updateEventIndicatorBottom(int newY); 210 void updateEventIndicatorBottom(int newY);
206 211
207 /** Updates data for selected timespan */ 212 /** Updates data for selected timespan */
208 void newTimeSpanSelected(int gxStart, int gyStart, int gxEnd, int gyEnd); 213 void newTimeSpanSelected(int gxStart, int gyStart, int gxEnd, int gyEnd);
209 /** Updates data for selected timespan for all day event*/ 214 /** Updates data for selected timespan for all day event*/
210 void newTimeSpanSelectedAllDay(int gxStart, int gyStart, int gxEnd, int gyEnd); 215 void newTimeSpanSelectedAllDay(int gxStart, int gyStart, int gxEnd, int gyEnd);
211 216
212 private: 217 private:
213 // view widgets 218 // view widgets
214 QFrame *mDayLabels; 219 QFrame *mDayLabels;
215 QHBox *mDayLabelsFrame; 220 QHBox *mDayLabelsFrame;
216 QBoxLayout *mLayoutDayLabels; 221 QBoxLayout *mLayoutDayLabels;
217 QFrame *mAllDayFrame; 222 QFrame *mAllDayFrame;
218 KOAgenda *mAllDayAgenda; 223 KOAgenda *mAllDayAgenda;
219 KOAgenda *mAgenda; 224 KOAgenda *mAgenda;
220 TimeLabels *mTimeLabels; 225 TimeLabels *mTimeLabels;
221 QWidget *mDummyAllDayLeft; 226 QWidget *mDummyAllDayLeft;
222 227
223 KDGanttMinimizeSplitter* mSplitterAgenda; 228 KDGanttMinimizeSplitter* mSplitterAgenda;
224 QPushButton *mExpandButton; 229 QPushButton *mExpandButton;
225 230
226 DateList mSelectedDates; // List of dates to be displayed 231 DateList mSelectedDates; // List of dates to be displayed
227 int mViewType; 232 int mViewType;
228 233
229 bool mWeekStartsMonday; 234 bool mWeekStartsMonday;
230 int mStartHour; 235 int mStartHour;
231 236
232 KOEventPopupMenu *mAgendaPopup; 237 KOEventPopupMenu *mAgendaPopup;
233 KOEventPopupMenu *mAllDayAgendaPopup; 238 KOEventPopupMenu *mAllDayAgendaPopup;
234 239
235 EventIndicator *mEventIndicatorTop; 240 EventIndicator *mEventIndicatorTop;
236 EventIndicator *mEventIndicatorBottom; 241 EventIndicator *mEventIndicatorBottom;
237 242
238 QMemArray<int> mMinY; 243 QMemArray<int> mMinY;
239 QMemArray<int> mMaxY; 244 QMemArray<int> mMaxY;
240 245
241 QMemArray<bool> mHolidayMask; 246 QMemArray<bool> mHolidayMask;
242 247
243 QPixmap mExpandedPixmap; 248 QPixmap mExpandedPixmap;
244 QPixmap mNotExpandedPixmap; 249 QPixmap mNotExpandedPixmap;
245 QPtrList<QLabel> mDayLabelsList; 250 QPtrList<QLabel> mDayLabelsList;
246 QDateTime mTimeSpanBegin; 251 QDateTime mTimeSpanBegin;
247 QDateTime mTimeSpanEnd; 252 QDateTime mTimeSpanEnd;
248 bool mTimeSpanInAllDay; 253 bool mTimeSpanInAllDay;
249 void keyPressEvent ( QKeyEvent * e ); 254 void keyPressEvent ( QKeyEvent * e );
250}; 255};
251 256
252#endif // KOAGENDAVIEW_H 257#endif // KOAGENDAVIEW_H
diff --git a/korganizer/kodialogmanager.cpp b/korganizer/kodialogmanager.cpp
index c99c0cb..41a4dc1 100644
--- a/korganizer/kodialogmanager.cpp
+++ b/korganizer/kodialogmanager.cpp
@@ -1,341 +1,346 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Copyright (c) 2001 4 Copyright (c) 2001
5 Cornelius Schumacher <schumacher@kde.org> 5 Cornelius Schumacher <schumacher@kde.org>
6 6
7 This program is free software; you can redistribute it and/or modify 7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or 9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version. 10 (at your option) any later version.
11 11
12 This program is distributed in the hope that it will be useful, 12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
15 GNU General Public License for more details. 15 GNU General Public License for more details.
16 16
17 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software 18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22#include <libkdepim/categoryeditdialog.h> 22#include <libkdepim/categoryeditdialog.h>
23 23
24#include "calendarview.h" 24#include "calendarview.h"
25#include "incomingdialog.h" 25#include "incomingdialog.h"
26#include "outgoingdialog.h" 26#include "outgoingdialog.h"
27#include "koprefsdialog.h" 27#include "koprefsdialog.h"
28#include "koeventeditor.h" 28#include "koeventeditor.h"
29#include "koprefs.h" 29#include "koprefs.h"
30#include "datenavigator.h" 30#include "datenavigator.h"
31#include "kotodoeditor.h" 31#include "kotodoeditor.h"
32#include "searchdialog.h" 32#include "searchdialog.h"
33#include "filtereditdialog.h" 33#include "filtereditdialog.h"
34#ifndef KORG_NOPLUGINS 34#ifndef KORG_NOPLUGINS
35#include "plugindialog.h" 35#include "plugindialog.h"
36#endif 36#endif
37#ifndef KORG_NOARCHIVE 37#ifndef KORG_NOARCHIVE
38#include "archivedialog.h" 38#include "archivedialog.h"
39#endif 39#endif
40 40
41#include "kconfig.h" 41#include "kconfig.h"
42#include "kodialogmanager.h" 42#include "kodialogmanager.h"
43 43
44KODialogManager::KODialogManager( CalendarView *mainView ) : 44KODialogManager::KODialogManager( CalendarView *mainView ) :
45 QObject(), mMainView( mainView ) 45 QObject(), mMainView( mainView )
46{ 46{
47 mOutgoingDialog = 0; 47 mOutgoingDialog = 0;
48 mIncomingDialog = 0; 48 mIncomingDialog = 0;
49 mOptionsDialog = 0; 49 mOptionsDialog = 0;
50 mSearchDialog = 0; 50 mSearchDialog = 0;
51 mArchiveDialog = 0; 51 mArchiveDialog = 0;
52 mFilterEditDialog = 0; 52 mFilterEditDialog = 0;
53 mPluginDialog = 0; 53 mPluginDialog = 0;
54 54
55 // mCategoryEditDialog = new KPIM::CategoryEditDialog(KOPrefs::instance(),mMainView); 55 // mCategoryEditDialog = new KPIM::CategoryEditDialog(KOPrefs::instance(),mMainView);
56 //KOGlobals::fitDialogToScreen( mCategoryEditDialog ); 56 //KOGlobals::fitDialogToScreen( mCategoryEditDialog );
57} 57}
58 58
59KODialogManager::~KODialogManager() 59KODialogManager::~KODialogManager()
60{ 60{
61 delete mOutgoingDialog; 61 delete mOutgoingDialog;
62 delete mIncomingDialog; 62 delete mIncomingDialog;
63 delete mOptionsDialog; 63 delete mOptionsDialog;
64 delete mSearchDialog; 64 delete mSearchDialog;
65#ifndef KORG_NOARCHIVE 65#ifndef KORG_NOARCHIVE
66 delete mArchiveDialog; 66 delete mArchiveDialog;
67#endif 67#endif
68 delete mFilterEditDialog; 68 delete mFilterEditDialog;
69#ifndef KORG_NOPLUGINS 69#ifndef KORG_NOPLUGINS
70 delete mPluginDialog; 70 delete mPluginDialog;
71#endif 71#endif
72} 72}
73 73
74OutgoingDialog *KODialogManager::outgoingDialog() 74OutgoingDialog *KODialogManager::outgoingDialog()
75{ 75{
76 createOutgoingDialog(); 76 createOutgoingDialog();
77 return mOutgoingDialog; 77 return mOutgoingDialog;
78} 78}
79 79
80void KODialogManager::createOutgoingDialog() 80void KODialogManager::createOutgoingDialog()
81{ 81{
82 if (!mOutgoingDialog) { 82 if (!mOutgoingDialog) {
83 mOutgoingDialog = new OutgoingDialog(mMainView->calendar(),mMainView); 83 mOutgoingDialog = new OutgoingDialog(mMainView->calendar(),mMainView);
84 if (mIncomingDialog) mIncomingDialog->setOutgoingDialog(mOutgoingDialog); 84 if (mIncomingDialog) mIncomingDialog->setOutgoingDialog(mOutgoingDialog);
85 connect(mOutgoingDialog,SIGNAL(numMessagesChanged(int)), 85 connect(mOutgoingDialog,SIGNAL(numMessagesChanged(int)),
86 mMainView,SIGNAL(numOutgoingChanged(int))); 86 mMainView,SIGNAL(numOutgoingChanged(int)));
87 } 87 }
88} 88}
89 89
90void KODialogManager::showOptionsDialog( bool showSync ) 90void KODialogManager::showOptionsDialog( bool showSync )
91{ 91{
92 92
93 if (!mOptionsDialog) { 93 if (!mOptionsDialog) {
94 mOptionsDialog = new KOPrefsDialog(mMainView); 94 mOptionsDialog = new KOPrefsDialog(mMainView);
95 //mOptionsDialog->readConfig(); 95 //mOptionsDialog->readConfig();
96 connect(mOptionsDialog,SIGNAL(configChanged()), 96 connect(mOptionsDialog,SIGNAL(configChanged()),
97 mMainView,SLOT(updateConfig())); 97 mMainView,SLOT(updateConfig()));
98 //connect(mCategoryEditDialog,SIGNAL(categoryConfigChanged()), 98 //connect(mCategoryEditDialog,SIGNAL(categoryConfigChanged()),
99 // mOptionsDialog,SLOT(updateCategories())); 99 // mOptionsDialog,SLOT(updateCategories()));
100 100
101 } 101 }
102 mOptionsDialog->readConfig(); 102 mOptionsDialog->readConfig();
103#ifndef DESKTOP_VERSION 103#ifndef DESKTOP_VERSION
104 mOptionsDialog->showMaximized(); 104 mOptionsDialog->showMaximized();
105#else 105#else
106 mOptionsDialog->show(); 106 mOptionsDialog->show();
107#endif 107#endif
108 if ( showSync ) 108 if ( showSync )
109 mOptionsDialog->showSyncPage(); 109 mOptionsDialog->showSyncPage();
110 mOptionsDialog->exec(); 110 mOptionsDialog->exec();
111 111
112} 112}
113void KODialogManager::showSyncOptions() 113void KODialogManager::showSyncOptions()
114{ 114{
115 showOptionsDialog( true ); 115 showOptionsDialog( true );
116 116
117} 117}
118void KODialogManager::showOutgoingDialog() 118void KODialogManager::showOutgoingDialog()
119{ 119{
120 createOutgoingDialog(); 120 createOutgoingDialog();
121 mOutgoingDialog->show(); 121 mOutgoingDialog->show();
122 mOutgoingDialog->raise(); 122 mOutgoingDialog->raise();
123} 123}
124 124
125IncomingDialog *KODialogManager::incomingDialog() 125IncomingDialog *KODialogManager::incomingDialog()
126{ 126{
127 createOutgoingDialog(); 127 createOutgoingDialog();
128 if (!mIncomingDialog) { 128 if (!mIncomingDialog) {
129 mIncomingDialog = new IncomingDialog(mMainView->calendar(),mOutgoingDialog,mMainView); 129 mIncomingDialog = new IncomingDialog(mMainView->calendar(),mOutgoingDialog,mMainView);
130 connect(mIncomingDialog,SIGNAL(numMessagesChanged(int)), 130 connect(mIncomingDialog,SIGNAL(numMessagesChanged(int)),
131 mMainView,SIGNAL(numIncomingChanged(int))); 131 mMainView,SIGNAL(numIncomingChanged(int)));
132 connect(mIncomingDialog,SIGNAL(calendarUpdated()), 132 connect(mIncomingDialog,SIGNAL(calendarUpdated()),
133 mMainView,SLOT(updateView())); 133 mMainView,SLOT(updateView()));
134 } 134 }
135 return mIncomingDialog; 135 return mIncomingDialog;
136} 136}
137 137
138void KODialogManager::createIncomingDialog() 138void KODialogManager::createIncomingDialog()
139{ 139{
140 createOutgoingDialog(); 140 createOutgoingDialog();
141 if (!mIncomingDialog) { 141 if (!mIncomingDialog) {
142 mIncomingDialog = new IncomingDialog(mMainView->calendar(),mOutgoingDialog,mMainView); 142 mIncomingDialog = new IncomingDialog(mMainView->calendar(),mOutgoingDialog,mMainView);
143 connect(mIncomingDialog,SIGNAL(numMessagesChanged(int)), 143 connect(mIncomingDialog,SIGNAL(numMessagesChanged(int)),
144 mMainView,SIGNAL(numIncomingChanged(int))); 144 mMainView,SIGNAL(numIncomingChanged(int)));
145 connect(mIncomingDialog,SIGNAL(calendarUpdated()), 145 connect(mIncomingDialog,SIGNAL(calendarUpdated()),
146 mMainView,SLOT(updateView())); 146 mMainView,SLOT(updateView()));
147 } 147 }
148} 148}
149 149
150void KODialogManager::showIncomingDialog() 150void KODialogManager::showIncomingDialog()
151{ 151{
152 createIncomingDialog(); 152 createIncomingDialog();
153 mIncomingDialog->show(); 153 mIncomingDialog->show();
154 mIncomingDialog->raise(); 154 mIncomingDialog->raise();
155} 155}
156/* 156/*
157void KODialogManager::showCategoryEditDialog() 157void KODialogManager::showCategoryEditDialog()
158{ 158{
159 mCategoryEditDialog->show(); 159 mCategoryEditDialog->show();
160} 160}
161*/ 161*/
162void KODialogManager::hideSearchDialog() 162void KODialogManager::hideSearchDialog()
163{ 163{
164 if (mSearchDialog) 164 if (mSearchDialog)
165 mSearchDialog->hide(); 165 mSearchDialog->hide();
166} 166}
167 167
168void KODialogManager::showSearchDialog() 168void KODialogManager::showSearchDialog()
169{ 169{
170 if (!mSearchDialog) { 170 if (!mSearchDialog) {
171 mSearchDialog = new SearchDialog(mMainView->calendar(),mMainView); 171 mSearchDialog = new SearchDialog(mMainView->calendar(),mMainView);
172 KOListView * lview = mSearchDialog->listview(); 172 KOListView * lview = mSearchDialog->listview();
173 173
174 connect(lview, SIGNAL(showIncidenceSignal(Incidence *)), 174 connect(lview, SIGNAL(showIncidenceSignal(Incidence *)),
175 mMainView, SLOT(showIncidence(Incidence *))); 175 mMainView, SLOT(showIncidence(Incidence *)));
176 connect(lview, SIGNAL(editIncidenceSignal(Incidence *)), 176 connect(lview, SIGNAL(editIncidenceSignal(Incidence *)),
177 mMainView, SLOT(editIncidence(Incidence *))); 177 mMainView, SLOT(editIncidence(Incidence *)));
178 connect(lview, SIGNAL(deleteIncidenceSignal(Incidence *)), 178 connect(lview, SIGNAL(deleteIncidenceSignal(Incidence *)),
179 mMainView, SLOT(deleteIncidence(Incidence *))); 179 mMainView, SLOT(deleteIncidence(Incidence *)));
180 connect(lview, SIGNAL(cloneIncidenceSignal(Incidence *)), 180 connect(lview, SIGNAL(cloneIncidenceSignal(Incidence *)),
181 mMainView, SLOT(cloneIncidence(Incidence *))); 181 mMainView, SLOT(cloneIncidence(Incidence *)));
182 connect(lview, SIGNAL(beamIncidenceSignal(Incidence *)), 182 connect(lview, SIGNAL(beamIncidenceSignal(Incidence *)),
183 mMainView, SLOT(beamIncidence(Incidence *))); 183 mMainView, SLOT(beamIncidence(Incidence *)));
184 connect(lview, SIGNAL(moveIncidenceSignal(Incidence *)), 184 connect(lview, SIGNAL(moveIncidenceSignal(Incidence *)),
185 mMainView, SLOT(moveIncidence(Incidence *))); 185 mMainView, SLOT(moveIncidence(Incidence *)));
186 connect(lview, SIGNAL(beamIncidenceList(QPtrList<Incidence> )), 186 connect(lview, SIGNAL(beamIncidenceList(QPtrList<Incidence> )),
187 mMainView, SLOT(beamIncidenceList(QPtrList<Incidence> ))); 187 mMainView, SLOT(beamIncidenceList(QPtrList<Incidence> )));
188 188
189 connect(mMainView, SIGNAL(configChanged()), mSearchDialog, SLOT(updateConfig())); 189 connect(mMainView, SIGNAL(configChanged()), mSearchDialog, SLOT(updateConfig()));
190 connect(mMainView, SIGNAL(updateSearchDialog()), mSearchDialog, SLOT(updateList())); 190 connect(mMainView, SIGNAL(updateSearchDialog()), mSearchDialog, SLOT(updateList()));
191 // connect( lview, SIGNAL( incidenceSelected( Incidence * ) ), 191 // connect( lview, SIGNAL( incidenceSelected( Incidence * ) ),
192 // mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 192 // mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
193#ifndef DESKTOP_VERSION 193#ifndef DESKTOP_VERSION
194 mSearchDialog->setMaximumSize( QApplication::desktop()->size()); 194 mSearchDialog->setMaximumSize( QApplication::desktop()->size());
195 //mSearchDialog->setGeometry( 40,40, 400, 300); 195 //mSearchDialog->setGeometry( 40,40, 400, 300);
196 mSearchDialog->showMaximized(); 196 mSearchDialog->showMaximized();
197#else 197#else
198 KConfig *config = KOGlobals::config(); 198 KConfig *config = KOGlobals::config();
199 config->setGroup("WidgetLayout"); 199 config->setGroup("WidgetLayout");
200 QStringList list; 200 QStringList list;
201 list = config->readListEntry("SearchLayout"); 201 list = config->readListEntry("SearchLayout");
202 int x,y,w,h; 202 int x,y,w,h;
203 if ( ! list.isEmpty() ) { 203 if ( ! list.isEmpty() ) {
204 x = list[0].toInt(); 204 x = list[0].toInt();
205 y = list[1].toInt(); 205 y = list[1].toInt();
206 w = list[2].toInt(); 206 w = list[2].toInt();
207 h = list[3].toInt(); 207 h = list[3].toInt();
208 mSearchDialog->setGeometry(x,y,w,h); 208 mSearchDialog->setGeometry(x,y,w,h);
209 209
210 } 210 }
211 211
212#endif 212#endif
213 } 213 }
214 // make sure the widget is on top again 214 // make sure the widget is on top again
215 mSearchDialog->show(); 215 mSearchDialog->show();
216 mSearchDialog->raise(); 216 mSearchDialog->raise();
217} 217}
218 218
219SearchDialog * KODialogManager::getSearchDialog() 219SearchDialog * KODialogManager::getSearchDialog()
220{ 220{
221 return mSearchDialog; 221 return mSearchDialog;
222} 222}
223void KODialogManager::showArchiveDialog() 223void KODialogManager::showArchiveDialog()
224{ 224{
225#ifndef KORG_NOARCHIVE 225#ifndef KORG_NOARCHIVE
226 if (!mArchiveDialog) { 226 if (!mArchiveDialog) {
227 mArchiveDialog = new ArchiveDialog(mMainView->calendar(),mMainView); 227 mArchiveDialog = new ArchiveDialog(mMainView->calendar(),mMainView);
228 connect(mArchiveDialog,SIGNAL(eventsDeleted()), 228 connect(mArchiveDialog,SIGNAL(eventsDeleted()),
229 mMainView,SLOT(updateView())); 229 mMainView,SLOT(updateView()));
230 } 230 }
231 mArchiveDialog->show(); 231 mArchiveDialog->show();
232 mArchiveDialog->raise(); 232 mArchiveDialog->raise();
233 233
234 // Workaround. 234 // Workaround.
235 QApplication::restoreOverrideCursor(); 235 QApplication::restoreOverrideCursor();
236#endif 236#endif
237} 237}
238 238
239void KODialogManager::showFilterEditDialog(QPtrList<CalFilter> *filters) 239void KODialogManager::showFilterEditDialog(QPtrList<CalFilter> *filters)
240{ 240{
241 if (!mFilterEditDialog) { 241 if (!mFilterEditDialog) {
242 mFilterEditDialog = new FilterEditDialog(filters,mMainView); 242 mFilterEditDialog = new FilterEditDialog(filters,mMainView);
243 connect(mFilterEditDialog,SIGNAL(filterChanged()), 243 connect(mFilterEditDialog,SIGNAL(filterChanged()),
244 mMainView,SLOT(filterEdited())); 244 mMainView,SLOT(filterEdited()));
245 245
246 } 246 }
247 247
248#ifndef DESKTOP_VERSION 248#ifndef DESKTOP_VERSION
249 mFilterEditDialog->showMaximized(); 249 mFilterEditDialog->showMaximized();
250#else 250#else
251 mFilterEditDialog->show(); 251 mFilterEditDialog->show();
252#endif 252#endif
253 mFilterEditDialog->raise(); 253 mFilterEditDialog->raise();
254} 254}
255 255
256void KODialogManager::showPluginDialog() 256void KODialogManager::showPluginDialog()
257{ 257{
258#ifndef KORG_NOPLUGINS 258#ifndef KORG_NOPLUGINS
259 if (!mPluginDialog) { 259 if (!mPluginDialog) {
260 mPluginDialog = new PluginDialog(mMainView); 260 mPluginDialog = new PluginDialog(mMainView);
261 connect(mPluginDialog,SIGNAL(configChanged()), 261 connect(mPluginDialog,SIGNAL(configChanged()),
262 mMainView,SLOT(updateConfig())); 262 mMainView,SLOT(updateConfig()));
263 } 263 }
264 mPluginDialog->show(); 264 mPluginDialog->show();
265 mPluginDialog->raise(); 265 mPluginDialog->raise();
266#endif 266#endif
267} 267}
268 268
269KOEventEditor *KODialogManager::getEventEditor() 269KOEventEditor *KODialogManager::getEventEditor()
270{ 270{
271 KOEventEditor *eventEditor = new KOEventEditor( mMainView->calendar(), 271 KOEventEditor *eventEditor = new KOEventEditor( mMainView->calendar(),
272 mMainView ); 272 mMainView );
273 273
274 connect(eventEditor,SIGNAL(eventAdded(Event *)), 274 connect(eventEditor,SIGNAL(eventAdded(Event *)),
275 mMainView,SLOT(eventAdded(Event *))); 275 mMainView,SLOT(eventAdded(Event *)));
276 connect(eventEditor,SIGNAL(eventChanged(Event *)), 276 connect(eventEditor,SIGNAL(eventChanged(Event *)),
277 mMainView,SLOT(eventChanged(Event *))); 277 mMainView,SLOT(eventChanged(Event *)));
278 connect(eventEditor,SIGNAL(eventDeleted()), 278 connect(eventEditor,SIGNAL(eventDeleted()),
279 mMainView,SLOT(eventDeleted())); 279 mMainView,SLOT(eventDeleted()));
280 connect(eventEditor,SIGNAL(deleteAttendee(Incidence *)), 280 connect(eventEditor,SIGNAL(deleteAttendee(Incidence *)),
281 mMainView,SLOT(schedule_cancel(Incidence *))); 281 mMainView,SLOT(schedule_cancel(Incidence *)));
282 connect( eventEditor, SIGNAL(jumpToTime( const QDate &)), 282 connect( eventEditor, SIGNAL(jumpToTime( const QDate &)),
283 mMainView->dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 283 mMainView->dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
284 connect( eventEditor, SIGNAL( showAgendaView( bool)), 284 connect( eventEditor, SIGNAL( showAgendaView( bool)),
285 mMainView->viewManager(), SLOT( showAgendaView( bool) ) ); 285 mMainView->viewManager(), SLOT( showAgendaView( bool) ) );
286 286
287 // connect(mCategoryEditDialog,SIGNAL(categoryConfigChanged()), 287 // connect(mCategoryEditDialog,SIGNAL(categoryConfigChanged()),
288 // eventEditor,SLOT(updateCategoryConfig())); 288 // eventEditor,SLOT(updateCategoryConfig()));
289 // connect(eventEditor,SIGNAL(editCategories()), 289 // connect(eventEditor,SIGNAL(editCategories()),
290 // mCategoryEditDialog,SLOT(show())); 290 // mCategoryEditDialog,SLOT(show()));
291 connect(eventEditor,SIGNAL(dialogClose(Incidence*)), 291 connect(eventEditor,SIGNAL(dialogClose(Incidence*)),
292 mMainView,SLOT(dialogClosing(Incidence*))); 292 mMainView,SLOT(dialogClosing(Incidence*)));
293 293
294 //connect(mMainView,SIGNAL(closingDown()),eventEditor,SLOT(reject())); 294 //connect(mMainView,SIGNAL(closingDown()),eventEditor,SLOT(reject()));
295 295
296#ifndef DESKTOP_VERSION
297 eventEditor->resize( QApplication::desktop()->width() -20, 100 );
298#endif
296 return eventEditor; 299 return eventEditor;
297} 300}
298 301
299KOTodoEditor *KODialogManager::getTodoEditor() 302KOTodoEditor *KODialogManager::getTodoEditor()
300{ 303{
301 KOTodoEditor *todoEditor = new KOTodoEditor( mMainView->calendar(), 304 KOTodoEditor *todoEditor = new KOTodoEditor( mMainView->calendar(),
302 mMainView ); 305 mMainView );
303 306
304 // connect(mCategoryEditDialog,SIGNAL(categoryConfigChanged()), 307 // connect(mCategoryEditDialog,SIGNAL(categoryConfigChanged()),
305 // todoEditor,SLOT(updateCategoryConfig())); 308 // todoEditor,SLOT(updateCategoryConfig()));
306 // connect(todoEditor,SIGNAL(editCategories()),mCategoryEditDialog,SLOT(show())); 309 // connect(todoEditor,SIGNAL(editCategories()),mCategoryEditDialog,SLOT(show()));
307 310
308 connect(todoEditor,SIGNAL(todoAdded(Todo *)), 311 connect(todoEditor,SIGNAL(todoAdded(Todo *)),
309 mMainView,SLOT(todoAdded(Todo *))); 312 mMainView,SLOT(todoAdded(Todo *)));
310 connect(todoEditor,SIGNAL(todoChanged(Todo *)), 313 connect(todoEditor,SIGNAL(todoChanged(Todo *)),
311 mMainView,SLOT(todoChanged(Todo *))); 314 mMainView,SLOT(todoChanged(Todo *)));
312 connect(todoEditor,SIGNAL(todoDeleted()), 315 connect(todoEditor,SIGNAL(todoDeleted()),
313 mMainView,SLOT(todoDeleted())); 316 mMainView,SLOT(todoDeleted()));
314 connect(todoEditor,SIGNAL(dialogClose(Incidence*)), 317 connect(todoEditor,SIGNAL(dialogClose(Incidence*)),
315 mMainView,SLOT(dialogClosing(Incidence*))); 318 mMainView,SLOT(dialogClosing(Incidence*)));
316 connect( todoEditor, SIGNAL(jumpToTime( const QDate &)), 319 connect( todoEditor, SIGNAL(jumpToTime( const QDate &)),
317 mMainView->dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 320 mMainView->dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
318 connect( todoEditor, SIGNAL( showAgendaView( bool)), 321 connect( todoEditor, SIGNAL( showAgendaView( bool)),
319 mMainView->viewManager(), SLOT( showAgendaView( bool) ) ); 322 mMainView->viewManager(), SLOT( showAgendaView( bool) ) );
320 // connect(todoEditor,SIGNAL(deleteAttendee(Incidence *)), 323 // connect(todoEditor,SIGNAL(deleteAttendee(Incidence *)),
321 // mMainView,SLOT(schedule_cancel(Incidence *))); 324 // mMainView,SLOT(schedule_cancel(Incidence *)));
322 //connect(mMainView,SIGNAL(closingDown()),todoEditor,SLOT(reject())); 325 //connect(mMainView,SIGNAL(closingDown()),todoEditor,SLOT(reject()));
323 326#ifndef DESKTOP_VERSION
327 todoEditor->resize( QApplication::desktop()->width() -20, 100 );
328#endif
324 return todoEditor; 329 return todoEditor;
325} 330}
326 331
327void KODialogManager::updateSearchDialog() 332void KODialogManager::updateSearchDialog()
328{ 333{
329 if (mSearchDialog) mSearchDialog->updateView(); 334 if (mSearchDialog) mSearchDialog->updateView();
330} 335}
331 336
332void KODialogManager::setDocumentId( const QString &id ) 337void KODialogManager::setDocumentId( const QString &id )
333{ 338{
334 if (mOutgoingDialog) mOutgoingDialog->setDocumentId( id ); 339 if (mOutgoingDialog) mOutgoingDialog->setDocumentId( id );
335} 340}
336 341
337void KODialogManager::writeSettings( KConfig *config ) 342void KODialogManager::writeSettings( KConfig *config )
338{ 343{
339 if (mSearchDialog) 344 if (mSearchDialog)
340 mSearchDialog->listview()->writeSettings(config,"SearchListView Layout"); 345 mSearchDialog->listview()->writeSettings(config,"SearchListView Layout");
341} 346}