summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp22
-rw-r--r--korganizer/calendarview.h2
-rw-r--r--korganizer/komonthview.cpp89
-rw-r--r--korganizer/komonthview.h8
-rw-r--r--korganizer/koviewmanager.cpp6
5 files changed, 85 insertions, 42 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 12af655..f9af769 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,1059 +1,1064 @@
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 beamDialog = new KOBeamPrefs(); 237 beamDialog = new KOBeamPrefs();
237 mDatePickerMode = 0; 238 mDatePickerMode = 0;
238 mCurrentSyncDevice = ""; 239 mCurrentSyncDevice = "";
239 writeLocale(); 240 writeLocale();
240 mViewManager = new KOViewManager( this ); 241 mViewManager = new KOViewManager( this );
241 mDialogManager = new KODialogManager( this ); 242 mDialogManager = new KODialogManager( this );
242 mEventViewerDialog = 0; 243 mEventViewerDialog = 0;
243 mModified = false; 244 mModified = false;
244 mReadOnly = false; 245 mReadOnly = false;
245 mSelectedIncidence = 0; 246 mSelectedIncidence = 0;
246 mCalPrinter = 0; 247 mCalPrinter = 0;
247 mFilters.setAutoDelete(true); 248 mFilters.setAutoDelete(true);
248 249
249 mCalendar->registerObserver( this ); 250 mCalendar->registerObserver( this );
250 // TODO: Make sure that view is updated, when calendar is changed. 251 // TODO: Make sure that view is updated, when calendar is changed.
251 252
252 mStorage = new FileStorage( mCalendar ); 253 mStorage = new FileStorage( mCalendar );
253 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 254 mNavigator = new DateNavigator( this, "datevav", mViewManager );
254 255
255 QBoxLayout *topLayout = (QBoxLayout*)layout(); 256 QBoxLayout *topLayout = (QBoxLayout*)layout();
256#ifndef KORG_NOSPLITTER 257#ifndef KORG_NOSPLITTER
257 // create the main layout frames. 258 // create the main layout frames.
258 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 259 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
259 topLayout->addWidget(mPanner); 260 topLayout->addWidget(mPanner);
260 261
261 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 262 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
262 "CalendarView::LeftFrame"); 263 "CalendarView::LeftFrame");
263 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 264 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
264 265
265 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, 266 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE,
266 "CalendarView::DateNavigator", QDate::currentDate() ); 267 "CalendarView::DateNavigator", QDate::currentDate() );
267 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 268 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
268 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 269 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
269 mTodoList->setNavigator( mNavigator ); 270 mTodoList->setNavigator( mNavigator );
270 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 271 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
271 272
272#ifdef KORG_NORESOURCEVIEW 273#ifdef KORG_NORESOURCEVIEW
273 mResourceView = 0; 274 mResourceView = 0;
274#else 275#else
275 if ( mResourceManager ) { 276 if ( mResourceManager ) {
276 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 277 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
277 mResourceView->updateView(); 278 mResourceView->updateView();
278 connect( mResourceView, SIGNAL( resourcesChanged() ), 279 connect( mResourceView, SIGNAL( resourcesChanged() ),
279 SLOT( updateView() ) ); 280 SLOT( updateView() ) );
280 } else { 281 } else {
281 mResourceView = 0; 282 mResourceView = 0;
282 } 283 }
283#endif 284#endif
284 QWidget *rightBox = new QWidget( mPanner ); 285 QWidget *rightBox = new QWidget( mPanner );
285 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 286 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
286 287
287 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 288 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
288 rightLayout->addWidget( mNavigatorBar ); 289 rightLayout->addWidget( mNavigatorBar );
289 290
290 mRightFrame = new QWidgetStack( rightBox ); 291 mRightFrame = new QWidgetStack( rightBox );
291 rightLayout->addWidget( mRightFrame, 1 ); 292 rightLayout->addWidget( mRightFrame, 1 );
292 293
293 mLeftFrame = mLeftSplitter; 294 mLeftFrame = mLeftSplitter;
294#else 295#else
295 QWidget *mainBox = new QWidget( this ); 296 QWidget *mainBox = new QWidget( this );
296 QWidget *leftFrame = new QWidget( mainBox ); 297 QWidget *leftFrame = new QWidget( mainBox );
297 298
298 QBoxLayout * mainBoxLayout; 299 QBoxLayout * mainBoxLayout;
299 QBoxLayout * leftFrameLayout; 300 QBoxLayout * leftFrameLayout;
300 if ( KOPrefs::instance()->mVerticalScreen ) { 301 if ( KOPrefs::instance()->mVerticalScreen ) {
301 mainBoxLayout = new QVBoxLayout(mainBox); 302 mainBoxLayout = new QVBoxLayout(mainBox);
302 leftFrameLayout = new QHBoxLayout(leftFrame ); 303 leftFrameLayout = new QHBoxLayout(leftFrame );
303 } else { 304 } else {
304 mainBoxLayout = new QHBoxLayout(mainBox); 305 mainBoxLayout = new QHBoxLayout(mainBox);
305 leftFrameLayout = new QVBoxLayout(leftFrame ); 306 leftFrameLayout = new QVBoxLayout(leftFrame );
306 } 307 }
307 topLayout->addWidget( mainBox ); 308 topLayout->addWidget( mainBox );
308 mainBoxLayout->addWidget (leftFrame); 309 mainBoxLayout->addWidget (leftFrame);
309 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, 310 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE,
310 "CalendarView::DateNavigator", QDate::currentDate()); 311 "CalendarView::DateNavigator", QDate::currentDate());
311 // mDateNavigator->blockSignals( true ); 312 // mDateNavigator->blockSignals( true );
312 leftFrameLayout->addWidget( mDateNavigator ); 313 leftFrameLayout->addWidget( mDateNavigator );
313 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); 314 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView");
314 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall"); 315 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall");
315 mTodoList->setNavigator( mNavigator ); 316 mTodoList->setNavigator( mNavigator );
316 317
317 if ( QApplication::desktop()->width() < 480 ) { 318 if ( QApplication::desktop()->width() < 480 ) {
318 leftFrameLayout->addWidget(mFilterView); 319 leftFrameLayout->addWidget(mFilterView);
319 leftFrameLayout->addWidget(mTodoList, 2 ); 320 leftFrameLayout->addWidget(mTodoList, 2 );
320 321
321 } else { 322 } else {
322 leftFrameLayout->addWidget(mTodoList,2 ); 323 leftFrameLayout->addWidget(mTodoList,2 );
323 leftFrameLayout->addWidget(mFilterView ); 324 leftFrameLayout->addWidget(mFilterView );
324 } 325 }
325 mFilterView->hide(); 326 mFilterView->hide();
326 QWidget *rightBox = new QWidget( mainBox ); 327 QWidget *rightBox = new QWidget( mainBox );
327 mainBoxLayout->addWidget ( rightBox, 10 ); 328 mainBoxLayout->addWidget ( rightBox, 10 );
328 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 329 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
329 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 330 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
330 mRightFrame = new QWidgetStack( rightBox ); 331 mRightFrame = new QWidgetStack( rightBox );
331 rightLayout->addWidget( mNavigatorBar ); 332 rightLayout->addWidget( mNavigatorBar );
332 rightLayout->addWidget( mRightFrame, 10 ); 333 rightLayout->addWidget( mRightFrame, 10 );
333 334
334 mLeftFrame = leftFrame; 335 mLeftFrame = leftFrame;
335 if ( KOPrefs::instance()->mVerticalScreen ) { 336 if ( KOPrefs::instance()->mVerticalScreen ) {
336 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 337 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
337 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 338 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
338 } else { 339 } else {
339 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 340 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
340 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 341 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
341 } 342 }
342 if ( !KOPrefs::instance()->mShowDateNavigator) 343 if ( !KOPrefs::instance()->mShowDateNavigator)
343 mDateNavigator->hide(); 344 mDateNavigator->hide();
344 //qDebug("Calendarview Size %d %d ", width(), height()); 345 //qDebug("Calendarview Size %d %d ", width(), height());
345#endif 346#endif
346 347
347 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 348 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
348 SLOT( showDates( const KCal::DateList & ) ) ); 349 SLOT( showDates( const KCal::DateList & ) ) );
350
349 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 351 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
350 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 352 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
351
352 connect( mNavigatorBar, SIGNAL( goPrevYear() ), 353 connect( mNavigatorBar, SIGNAL( goPrevYear() ),
353 mNavigator, SLOT( selectPreviousYear() ) ); 354 mNavigator, SLOT( selectPreviousYear() ) );
354 connect( mNavigatorBar, SIGNAL( goNextYear() ), 355 connect( mNavigatorBar, SIGNAL( goNextYear() ),
355 mNavigator, SLOT( selectNextYear() ) ); 356 mNavigator, SLOT( selectNextYear() ) );
356 connect( mNavigatorBar, SIGNAL( goPrevMonth() ), 357 connect( mNavigatorBar, SIGNAL( goPrevMonth() ),
357 mNavigator, SLOT( selectPreviousMonth() ) ); 358 mNavigator, SLOT( selectPreviousMonth() ) );
358 connect( mNavigatorBar, SIGNAL( goNextMonth() ), 359 connect( mNavigatorBar, SIGNAL( goNextMonth() ),
359 mNavigator, SLOT( selectNextMonth() ) ); 360 mNavigator, SLOT( selectNextMonth() ) );
360 361
361 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 362 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
362 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); 363 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) );
363 364
364 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 365 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
365 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 366 mNavigator, SLOT( selectWeek( const QDate & ) ) );
366 367
367 connect( mDateNavigator, SIGNAL( goPrevYear() ), 368 connect( mDateNavigator, SIGNAL( goPrevYear() ),
368 mNavigator, SLOT( selectPreviousYear() ) ); 369 mNavigator, SLOT( selectPreviousYear() ) );
369 connect( mDateNavigator, SIGNAL( goNextYear() ), 370 connect( mDateNavigator, SIGNAL( goNextYear() ),
370 mNavigator, SLOT( selectNextYear() ) ); 371 mNavigator, SLOT( selectNextYear() ) );
371 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 372 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
372 mNavigator, SLOT( selectPreviousMonth() ) ); 373 mNavigator, SLOT( selectPreviousMonth() ) );
373 connect( mDateNavigator, SIGNAL( goNextMonth() ), 374 connect( mDateNavigator, SIGNAL( goNextMonth() ),
374 mNavigator, SLOT( selectNextMonth() ) ); 375 mNavigator, SLOT( selectNextMonth() ) );
375 376
376 connect( mDateNavigator, SIGNAL( goPrevious() ), 377 connect( mDateNavigator, SIGNAL( goPrevious() ),
377 mNavigator, SLOT( selectPrevious() ) ); 378 mNavigator, SLOT( selectPrevious() ) );
378 connect( mDateNavigator, SIGNAL( goNext() ), 379 connect( mDateNavigator, SIGNAL( goNext() ),
379 mNavigator, SLOT( selectNext() ) ); 380 mNavigator, SLOT( selectNext() ) );
380 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 381 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
381 mNavigator, SLOT( slotMonthSelect( int ) ) ); 382 mNavigator, SLOT( slotMonthSelect( int ) ) );
382 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), 383 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ),
383 mNavigator, SLOT( slotMonthSelect( int ) ) ); 384 mNavigator, SLOT( slotMonthSelect( int ) ) );
384 385
385 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 386 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
386 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 387 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
387 388
388 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), 389 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ),
389 SLOT( eventAdded( Event *) ) ); 390 SLOT( eventAdded( Event *) ) );
390 391
391 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 392 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
392 393
393 connect( this, SIGNAL( configChanged() ), 394 connect( this, SIGNAL( configChanged() ),
394 mDateNavigator, SLOT( updateConfig() ) ); 395 mDateNavigator, SLOT( updateConfig() ) );
395 396
396 connect( mTodoList, SIGNAL( newTodoSignal() ), 397 connect( mTodoList, SIGNAL( newTodoSignal() ),
397 SLOT( newTodo() ) ); 398 SLOT( newTodo() ) );
398 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 399 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
399 SLOT( newSubTodo( Todo * ) ) ); 400 SLOT( newSubTodo( Todo * ) ) );
400 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 401 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
401 SLOT( editTodo( Todo * ) ) ); 402 SLOT( editTodo( Todo * ) ) );
402 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 403 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
403 SLOT( showTodo( Todo *) ) ); 404 SLOT( showTodo( Todo *) ) );
404 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 405 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
405 SLOT( deleteTodo( Todo *) ) ); 406 SLOT( deleteTodo( Todo *) ) );
406 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 407 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
407 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 408 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
408 SLOT( purgeCompleted() ) ); 409 SLOT( purgeCompleted() ) );
409 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 410 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
410 SIGNAL( todoModified( Todo *, int ) ) ); 411 SIGNAL( todoModified( Todo *, int ) ) );
411 412
412 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 413 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
413 this, SLOT ( cloneIncidence( Incidence * ) ) ); 414 this, SLOT ( cloneIncidence( Incidence * ) ) );
414 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 415 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
415 this, SLOT (cancelIncidence( Incidence * ) ) ); 416 this, SLOT (cancelIncidence( Incidence * ) ) );
416 417
417 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 418 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
418 this, SLOT ( moveIncidence( Incidence * ) ) ); 419 this, SLOT ( moveIncidence( Incidence * ) ) );
419 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 420 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
420 this, SLOT ( beamIncidence( Incidence * ) ) ); 421 this, SLOT ( beamIncidence( Incidence * ) ) );
421 422
422 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 423 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
423 this, SLOT ( todo_unsub( Todo * ) ) ); 424 this, SLOT ( todo_unsub( Todo * ) ) );
424 425
425 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 426 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
426 this, SLOT ( todo_resub( Todo *,Todo * ) ) ); 427 this, SLOT ( todo_resub( Todo *,Todo * ) ) );
427 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 428 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
428 SLOT( updateTodo( Todo *, int ) ) ); 429 SLOT( updateTodo( Todo *, int ) ) );
429 connect( this, SIGNAL( todoModified( Todo *, int )), this, 430 connect( this, SIGNAL( todoModified( Todo *, int )), this,
430 SLOT( changeTodoDisplay( Todo *, int ) ) ); 431 SLOT( changeTodoDisplay( Todo *, int ) ) );
431 432
432 433
433 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 434 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
434 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 435 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
435 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 & ) ) );
436 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 & ) ) );
437 438
438 439
439 440
440 441
441 442
442 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 443 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
443 SLOT(checkClipboard())); 444 SLOT(checkClipboard()));
444 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 445 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
445 SLOT( processTodoListSelection( Incidence * ) ) ); 446 SLOT( processTodoListSelection( Incidence * ) ) );
446 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 447 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
447 448
448 // kdDebug() << "CalendarView::CalendarView() done" << endl; 449 // kdDebug() << "CalendarView::CalendarView() done" << endl;
449 450
450 mDateFrame = new QVBox(0,0,WType_Popup); 451 mDateFrame = new QVBox(0,0,WType_Popup);
451 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 452 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
452 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 453 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
453 mDateFrame->setLineWidth(3); 454 mDateFrame->setLineWidth(3);
454 mDateFrame->hide(); 455 mDateFrame->hide();
455 mDateFrame->setCaption( i18n( "Pick a date to display")); 456 mDateFrame->setCaption( i18n( "Pick a date to display"));
456 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 457 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
457 458
458 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 459 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
459 460
460 mEventEditor = mDialogManager->getEventEditor(); 461 mEventEditor = mDialogManager->getEventEditor();
461 mTodoEditor = mDialogManager->getTodoEditor(); 462 mTodoEditor = mDialogManager->getTodoEditor();
462 463
463 mFlagEditDescription = false; 464 mFlagEditDescription = false;
464 465
465 mSuspendTimer = new QTimer( this ); 466 mSuspendTimer = new QTimer( this );
466 mAlarmTimer = new QTimer( this ); 467 mAlarmTimer = new QTimer( this );
467 mRecheckAlarmTimer = new QTimer( this ); 468 mRecheckAlarmTimer = new QTimer( this );
468 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 469 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
469 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 470 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
470 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 471 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
471 mAlarmDialog = new AlarmDialog( this ); 472 mAlarmDialog = new AlarmDialog( this );
472 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 & ) ) );
473 mAlarmDialog->setServerNotification( false ); 474 mAlarmDialog->setServerNotification( false );
474 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 475 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
475 476
476 477
477#ifndef DESKTOP_VERSION 478#ifndef DESKTOP_VERSION
478//US listen for arriving address resultsets 479//US listen for arriving address resultsets
479 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&)),
480 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&)));
481#endif 482#endif
482 483
483} 484}
484 485
485 486
486CalendarView::~CalendarView() 487CalendarView::~CalendarView()
487{ 488{
488 // kdDebug() << "~CalendarView()" << endl; 489 // kdDebug() << "~CalendarView()" << endl;
489 //qDebug("CalendarView::~CalendarView() "); 490 //qDebug("CalendarView::~CalendarView() ");
490 delete mDialogManager; 491 delete mDialogManager;
491 delete mViewManager; 492 delete mViewManager;
492 delete mStorage; 493 delete mStorage;
493 delete mDateFrame ; 494 delete mDateFrame ;
494 delete beamDialog; 495 delete beamDialog;
495 //kdDebug() << "~CalendarView() done" << endl; 496 //kdDebug() << "~CalendarView() done" << endl;
496} 497}
497 498
498void CalendarView::showDay( QDate d ) 499void CalendarView::showDay( QDate d )
499{ 500{
501 dateNavigator()->blockSignals( true );
500 dateNavigator()->selectDate( d ); 502 dateNavigator()->selectDate( d );
503 dateNavigator()->blockSignals( false );
501 mViewManager->showWeekView(); 504 mViewManager->showWeekView();
502 dateNavigator()->selectDate( d ); 505 dateNavigator()->selectDate( d );
503} 506}
504void CalendarView::timerAlarm() 507void CalendarView::timerAlarm()
505{ 508{
506 //qDebug("CalendarView::timerAlarm() "); 509 //qDebug("CalendarView::timerAlarm() ");
507 computeAlarm(mAlarmNotification ); 510 computeAlarm(mAlarmNotification );
508} 511}
509 512
510void CalendarView::suspendAlarm() 513void CalendarView::suspendAlarm()
511{ 514{
512 //qDebug(" CalendarView::suspendAlarm() "); 515 //qDebug(" CalendarView::suspendAlarm() ");
513 computeAlarm(mSuspendAlarmNotification ); 516 computeAlarm(mSuspendAlarmNotification );
514 517
515} 518}
516 519
517void CalendarView::startAlarm( QString mess , QString filename) 520void CalendarView::startAlarm( QString mess , QString filename)
518{ 521{
519 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 );
520 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); 523 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
521 524
522} 525}
523 526
524void CalendarView::checkNextTimerAlarm() 527void CalendarView::checkNextTimerAlarm()
525{ 528{
526 mCalendar->checkAlarmForIncidence( 0, true ); 529 mCalendar->checkAlarmForIncidence( 0, true );
527} 530}
528 531
529void CalendarView::computeAlarm( QString msg ) 532void CalendarView::computeAlarm( QString msg )
530{ 533{
531 534
532 QString mess = msg; 535 QString mess = msg;
533 QString mAlarmMessage = mess.mid( 9 ); 536 QString mAlarmMessage = mess.mid( 9 );
534 QString filename = MainWindow::resourcePath(); 537 QString filename = MainWindow::resourcePath();
535 filename += "koalarm.wav"; 538 filename += "koalarm.wav";
536 QString tempfilename; 539 QString tempfilename;
537 if ( mess.left( 13 ) == "suspend_alarm") { 540 if ( mess.left( 13 ) == "suspend_alarm") {
538 bool error = false; 541 bool error = false;
539 int len = mess.mid( 13 ).find("+++"); 542 int len = mess.mid( 13 ).find("+++");
540 if ( len < 2 ) 543 if ( len < 2 )
541 error = true; 544 error = true;
542 else { 545 else {
543 tempfilename = mess.mid( 13, len ); 546 tempfilename = mess.mid( 13, len );
544 if ( !QFile::exists( tempfilename ) ) 547 if ( !QFile::exists( tempfilename ) )
545 error = true; 548 error = true;
546 } 549 }
547 if ( ! error ) { 550 if ( ! error ) {
548 filename = tempfilename; 551 filename = tempfilename;
549 } 552 }
550 mAlarmMessage = mess.mid( 13+len+3 ); 553 mAlarmMessage = mess.mid( 13+len+3 );
551 //qDebug("suspend file %s ",tempfilename.latin1() ); 554 //qDebug("suspend file %s ",tempfilename.latin1() );
552 startAlarm( mAlarmMessage, filename); 555 startAlarm( mAlarmMessage, filename);
553 return; 556 return;
554 } 557 }
555 if ( mess.left( 11 ) == "timer_alarm") { 558 if ( mess.left( 11 ) == "timer_alarm") {
556 //mTimerTime = 0; 559 //mTimerTime = 0;
557 startAlarm( mess.mid( 11 ), filename ); 560 startAlarm( mess.mid( 11 ), filename );
558 return; 561 return;
559 } 562 }
560 if ( mess.left( 10 ) == "proc_alarm") { 563 if ( mess.left( 10 ) == "proc_alarm") {
561 bool error = false; 564 bool error = false;
562 int len = mess.mid( 10 ).find("+++"); 565 int len = mess.mid( 10 ).find("+++");
563 if ( len < 2 ) 566 if ( len < 2 )
564 error = true; 567 error = true;
565 else { 568 else {
566 tempfilename = mess.mid( 10, len ); 569 tempfilename = mess.mid( 10, len );
567 if ( !QFile::exists( tempfilename ) ) 570 if ( !QFile::exists( tempfilename ) )
568 error = true; 571 error = true;
569 } 572 }
570 if ( error ) { 573 if ( error ) {
571 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 574 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
572 mAlarmMessage += mess.mid( 10+len+3+9 ); 575 mAlarmMessage += mess.mid( 10+len+3+9 );
573 } else { 576 } else {
574 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 577 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
575 //qDebug("-----system command %s ",tempfilename.latin1() ); 578 //qDebug("-----system command %s ",tempfilename.latin1() );
576#ifndef _WIN32_ 579#ifndef _WIN32_
577 if ( vfork () == 0 ) { 580 if ( vfork () == 0 ) {
578 execl ( tempfilename.latin1(), 0 ); 581 execl ( tempfilename.latin1(), 0 );
579 return; 582 return;
580 } 583 }
581#else 584#else
582 QProcess* p = new QProcess(); 585 QProcess* p = new QProcess();
583 p->addArgument( tempfilename.latin1() ); 586 p->addArgument( tempfilename.latin1() );
584 p->start(); 587 p->start();
585 return; 588 return;
586#endif 589#endif
587 590
588 return; 591 return;
589 } 592 }
590 593
591 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 594 //qDebug("+++++++system command %s ",tempfilename.latin1() );
592 } 595 }
593 if ( mess.left( 11 ) == "audio_alarm") { 596 if ( mess.left( 11 ) == "audio_alarm") {
594 bool error = false; 597 bool error = false;
595 int len = mess.mid( 11 ).find("+++"); 598 int len = mess.mid( 11 ).find("+++");
596 if ( len < 2 ) 599 if ( len < 2 )
597 error = true; 600 error = true;
598 else { 601 else {
599 tempfilename = mess.mid( 11, len ); 602 tempfilename = mess.mid( 11, len );
600 if ( !QFile::exists( tempfilename ) ) 603 if ( !QFile::exists( tempfilename ) )
601 error = true; 604 error = true;
602 } 605 }
603 if ( ! error ) { 606 if ( ! error ) {
604 filename = tempfilename; 607 filename = tempfilename;
605 } 608 }
606 mAlarmMessage = mess.mid( 11+len+3+9 ); 609 mAlarmMessage = mess.mid( 11+len+3+9 );
607 //qDebug("audio file command %s ",tempfilename.latin1() ); 610 //qDebug("audio file command %s ",tempfilename.latin1() );
608 } 611 }
609 if ( mess.left( 9 ) == "cal_alarm") { 612 if ( mess.left( 9 ) == "cal_alarm") {
610 mAlarmMessage = mess.mid( 9 ) ; 613 mAlarmMessage = mess.mid( 9 ) ;
611 } 614 }
612 615
613 startAlarm( mAlarmMessage, filename ); 616 startAlarm( mAlarmMessage, filename );
614 617
615 618
616} 619}
617 620
618void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 621void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
619{ 622{
620 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 623 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
621 624
622 mSuspendAlarmNotification = noti; 625 mSuspendAlarmNotification = noti;
623 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 626 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
624 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 627 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
625 mSuspendTimer->start( ms , true ); 628 mSuspendTimer->start( ms , true );
626 629
627} 630}
628 631
629void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 632void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
630{ 633{
631 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 634 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
632 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 635 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
633#ifndef DESKTOP_VERSION 636#ifndef DESKTOP_VERSION
634 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); 637 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() );
635#endif 638#endif
636 return; 639 return;
637 } 640 }
638 int maxSec; 641 int maxSec;
639 //maxSec = 5; //testing only 642 //maxSec = 5; //testing only
640 maxSec = 86400+3600; // one day+1hour 643 maxSec = 86400+3600; // one day+1hour
641 mAlarmNotification = noti; 644 mAlarmNotification = noti;
642 int sec = QDateTime::currentDateTime().secsTo( qdt ); 645 int sec = QDateTime::currentDateTime().secsTo( qdt );
643 if ( sec > maxSec ) { 646 if ( sec > maxSec ) {
644 mRecheckAlarmTimer->start( maxSec * 1000 ); 647 mRecheckAlarmTimer->start( maxSec * 1000 );
645 // 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 );
646 return; 649 return;
647 } else { 650 } else {
648 mRecheckAlarmTimer->stop(); 651 mRecheckAlarmTimer->stop();
649 } 652 }
650 //qDebug("Alarm timer started with secs: %d ", sec); 653 //qDebug("Alarm timer started with secs: %d ", sec);
651 mAlarmTimer->start( sec *1000 , true ); 654 mAlarmTimer->start( sec *1000 , true );
652 655
653} 656}
654// called by mRecheckAlarmTimer to get next alarm 657// called by mRecheckAlarmTimer to get next alarm
655// 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
656void CalendarView::recheckTimerAlarm() 659void CalendarView::recheckTimerAlarm()
657{ 660{
658 mAlarmTimer->stop(); 661 mAlarmTimer->stop();
659 mRecheckAlarmTimer->stop(); 662 mRecheckAlarmTimer->stop();
660 mCalendar->checkAlarmForIncidence( 0, true ); 663 mCalendar->checkAlarmForIncidence( 0, true );
661} 664}
662void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 665void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
663{ 666{
664 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 667 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
665 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 668 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
666#ifndef DESKTOP_VERSION 669#ifndef DESKTOP_VERSION
667 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 670 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
668#endif 671#endif
669 return; 672 return;
670 } 673 }
671 mAlarmTimer->stop(); 674 mAlarmTimer->stop();
672} 675}
673void CalendarView::selectWeekNum ( int num ) 676void CalendarView::selectWeekNum ( int num )
674{ 677{
678 dateNavigator()->blockSignals( true );
675 dateNavigator()->selectWeek( num ); 679 dateNavigator()->selectWeek( num );
680 dateNavigator()->blockSignals( false );
676 mViewManager->showWeekView(); 681 mViewManager->showWeekView();
677} 682}
678KOViewManager *CalendarView::viewManager() 683KOViewManager *CalendarView::viewManager()
679{ 684{
680 return mViewManager; 685 return mViewManager;
681} 686}
682 687
683KODialogManager *CalendarView::dialogManager() 688KODialogManager *CalendarView::dialogManager()
684{ 689{
685 return mDialogManager; 690 return mDialogManager;
686} 691}
687 692
688QDate CalendarView::startDate() 693QDate CalendarView::startDate()
689{ 694{
690 DateList dates = mNavigator->selectedDates(); 695 DateList dates = mNavigator->selectedDates();
691 696
692 return dates.first(); 697 return dates.first();
693} 698}
694 699
695QDate CalendarView::endDate() 700QDate CalendarView::endDate()
696{ 701{
697 DateList dates = mNavigator->selectedDates(); 702 DateList dates = mNavigator->selectedDates();
698 703
699 return dates.last(); 704 return dates.last();
700} 705}
701 706
702 707
703void CalendarView::createPrinter() 708void CalendarView::createPrinter()
704{ 709{
705#ifndef KORG_NOPRINTER 710#ifndef KORG_NOPRINTER
706 if (!mCalPrinter) { 711 if (!mCalPrinter) {
707 mCalPrinter = new CalPrinter(this, mCalendar); 712 mCalPrinter = new CalPrinter(this, mCalendar);
708 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 713 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
709 } 714 }
710#endif 715#endif
711} 716}
712 717
713 718
714//KOPrefs::instance()->mWriteBackFile 719//KOPrefs::instance()->mWriteBackFile
715//KOPrefs::instance()->mWriteBackExistingOnly 720//KOPrefs::instance()->mWriteBackExistingOnly
716 721
717// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 722// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
718// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 723// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
719// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 724// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
720// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 725// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
721// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 726// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
722// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 727// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
723 728
724int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 729int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
725{ 730{
726 731
727 // 0 equal 732 // 0 equal
728 // 1 take local 733 // 1 take local
729 // 2 take remote 734 // 2 take remote
730 // 3 cancel 735 // 3 cancel
731 QDateTime lastSync = mLastCalendarSync; 736 QDateTime lastSync = mLastCalendarSync;
732 QDateTime localMod = local->lastModified(); 737 QDateTime localMod = local->lastModified();
733 QDateTime remoteMod = remote->lastModified(); 738 QDateTime remoteMod = remote->lastModified();
734 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 739 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
735 bool remCh, locCh; 740 bool remCh, locCh;
736 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 741 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
737 //if ( remCh ) 742 //if ( remCh )
738 //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() );
739 locCh = ( localMod > mLastCalendarSync ); 744 locCh = ( localMod > mLastCalendarSync );
740 if ( !remCh && ! locCh ) { 745 if ( !remCh && ! locCh ) {
741 //qDebug("both not changed "); 746 //qDebug("both not changed ");
742 lastSync = localMod.addDays(1); 747 lastSync = localMod.addDays(1);
743 if ( mode <= SYNC_PREF_ASK ) 748 if ( mode <= SYNC_PREF_ASK )
744 return 0; 749 return 0;
745 } else { 750 } else {
746 if ( locCh ) { 751 if ( locCh ) {
747 //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());
748 lastSync = localMod.addDays( -1 ); 753 lastSync = localMod.addDays( -1 );
749 if ( !remCh ) 754 if ( !remCh )
750 remoteMod = ( lastSync.addDays( -1 ) ); 755 remoteMod = ( lastSync.addDays( -1 ) );
751 } else { 756 } else {
752 //qDebug(" not loc changed "); 757 //qDebug(" not loc changed ");
753 lastSync = localMod.addDays( 1 ); 758 lastSync = localMod.addDays( 1 );
754 if ( remCh ) 759 if ( remCh )
755 remoteMod =( lastSync.addDays( 1 ) ); 760 remoteMod =( lastSync.addDays( 1 ) );
756 761
757 } 762 }
758 } 763 }
759 full = true; 764 full = true;
760 if ( mode < SYNC_PREF_ASK ) 765 if ( mode < SYNC_PREF_ASK )
761 mode = SYNC_PREF_ASK; 766 mode = SYNC_PREF_ASK;
762 } else { 767 } else {
763 if ( localMod == remoteMod ) 768 if ( localMod == remoteMod )
764 // if ( local->revision() == remote->revision() ) 769 // if ( local->revision() == remote->revision() )
765 return 0; 770 return 0;
766 771
767 } 772 }
768 // 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() );
769 774
770 //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());
771 //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() );
772 //full = true; //debug only 777 //full = true; //debug only
773 if ( full ) { 778 if ( full ) {
774 bool equ = false; 779 bool equ = false;
775 if ( local->type() == "Event" ) { 780 if ( local->type() == "Event" ) {
776 equ = (*((Event*) local) == *((Event*) remote)); 781 equ = (*((Event*) local) == *((Event*) remote));
777 } 782 }
778 else if ( local->type() =="Todo" ) 783 else if ( local->type() =="Todo" )
779 equ = (*((Todo*) local) == (*(Todo*) remote)); 784 equ = (*((Todo*) local) == (*(Todo*) remote));
780 else if ( local->type() =="Journal" ) 785 else if ( local->type() =="Journal" )
781 equ = (*((Journal*) local) == *((Journal*) remote)); 786 equ = (*((Journal*) local) == *((Journal*) remote));
782 if ( equ ) { 787 if ( equ ) {
783 //qDebug("equal "); 788 //qDebug("equal ");
784 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 789 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
785 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 790 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
786 } 791 }
787 if ( mode < SYNC_PREF_FORCE_LOCAL ) 792 if ( mode < SYNC_PREF_FORCE_LOCAL )
788 return 0; 793 return 0;
789 794
790 }//else //debug only 795 }//else //debug only
791 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 796 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
792 } 797 }
793 int result; 798 int result;
794 bool localIsNew; 799 bool localIsNew;
795 //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() );
796 801
797 if ( full && mode < SYNC_PREF_NEWEST ) 802 if ( full && mode < SYNC_PREF_NEWEST )
798 mode = SYNC_PREF_ASK; 803 mode = SYNC_PREF_ASK;
799 804
800 switch( mode ) { 805 switch( mode ) {
801 case SYNC_PREF_LOCAL: 806 case SYNC_PREF_LOCAL:
802 if ( lastSync > remoteMod ) 807 if ( lastSync > remoteMod )
803 return 1; 808 return 1;
804 if ( lastSync > localMod ) 809 if ( lastSync > localMod )
805 return 2; 810 return 2;
806 return 1; 811 return 1;
807 break; 812 break;
808 case SYNC_PREF_REMOTE: 813 case SYNC_PREF_REMOTE:
809 if ( lastSync > remoteMod ) 814 if ( lastSync > remoteMod )
810 return 1; 815 return 1;
811 if ( lastSync > localMod ) 816 if ( lastSync > localMod )
812 return 2; 817 return 2;
813 return 2; 818 return 2;
814 break; 819 break;
815 case SYNC_PREF_NEWEST: 820 case SYNC_PREF_NEWEST:
816 if ( localMod > remoteMod ) 821 if ( localMod > remoteMod )
817 return 1; 822 return 1;
818 else 823 else
819 return 2; 824 return 2;
820 break; 825 break;
821 case SYNC_PREF_ASK: 826 case SYNC_PREF_ASK:
822 //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() );
823 if ( lastSync > remoteMod ) 828 if ( lastSync > remoteMod )
824 return 1; 829 return 1;
825 if ( lastSync > localMod ) 830 if ( lastSync > localMod )
826 return 2; 831 return 2;
827 //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() );
828 localIsNew = localMod >= remoteMod; 833 localIsNew = localMod >= remoteMod;
829 if ( localIsNew ) 834 if ( localIsNew )
830 getEventViewerDialog()->setColorMode( 1 ); 835 getEventViewerDialog()->setColorMode( 1 );
831 else 836 else
832 getEventViewerDialog()->setColorMode( 2 ); 837 getEventViewerDialog()->setColorMode( 2 );
833 getEventViewerDialog()->setIncidence(local); 838 getEventViewerDialog()->setIncidence(local);
834 if ( localIsNew ) 839 if ( localIsNew )
835 getEventViewerDialog()->setColorMode( 2 ); 840 getEventViewerDialog()->setColorMode( 2 );
836 else 841 else
837 getEventViewerDialog()->setColorMode( 1 ); 842 getEventViewerDialog()->setColorMode( 1 );
838 getEventViewerDialog()->addIncidence(remote); 843 getEventViewerDialog()->addIncidence(remote);
839 getEventViewerDialog()->setColorMode( 0 ); 844 getEventViewerDialog()->setColorMode( 0 );
840 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 845 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
841 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 846 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
842 getEventViewerDialog()->showMe(); 847 getEventViewerDialog()->showMe();
843 result = getEventViewerDialog()->executeS( localIsNew ); 848 result = getEventViewerDialog()->executeS( localIsNew );
844 return result; 849 return result;
845 850
846 break; 851 break;
847 case SYNC_PREF_FORCE_LOCAL: 852 case SYNC_PREF_FORCE_LOCAL:
848 return 1; 853 return 1;
849 break; 854 break;
850 case SYNC_PREF_FORCE_REMOTE: 855 case SYNC_PREF_FORCE_REMOTE:
851 return 2; 856 return 2;
852 break; 857 break;
853 858
854 default: 859 default:
855 // SYNC_PREF_TAKE_BOTH not implemented 860 // SYNC_PREF_TAKE_BOTH not implemented
856 break; 861 break;
857 } 862 }
858 return 0; 863 return 0;
859} 864}
860Event* CalendarView::getLastSyncEvent() 865Event* CalendarView::getLastSyncEvent()
861{ 866{
862 Event* lse; 867 Event* lse;
863 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 868 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
864 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 869 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
865 if (!lse) { 870 if (!lse) {
866 lse = new Event(); 871 lse = new Event();
867 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 872 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
868 QString sum = ""; 873 QString sum = "";
869 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 874 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
870 sum = "E: "; 875 sum = "E: ";
871 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 876 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
872 lse->setDtStart( mLastCalendarSync ); 877 lse->setDtStart( mLastCalendarSync );
873 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 878 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
874 lse->setCategories( i18n("SyncEvent") ); 879 lse->setCategories( i18n("SyncEvent") );
875 lse->setReadOnly( true ); 880 lse->setReadOnly( true );
876 mCalendar->addEvent( lse ); 881 mCalendar->addEvent( lse );
877 } 882 }
878 883
879 return lse; 884 return lse;
880 885
881} 886}
882 887
883// 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
884// if yes, we set this id in the profile to delete 889// if yes, we set this id in the profile to delete
885void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 890void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
886{ 891{
887 if ( lastSync.count() == 0 ) { 892 if ( lastSync.count() == 0 ) {
888 //qDebug(" lastSync.count() == 0"); 893 //qDebug(" lastSync.count() == 0");
889 return; 894 return;
890 } 895 }
891 if ( toDelete->type() == "Journal" ) 896 if ( toDelete->type() == "Journal" )
892 return; 897 return;
893 898
894 Event* eve = lastSync.first(); 899 Event* eve = lastSync.first();
895 900
896 while ( eve ) { 901 while ( eve ) {
897 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
898 if ( !id.isEmpty() ) { 903 if ( !id.isEmpty() ) {
899 QString des = eve->description(); 904 QString des = eve->description();
900 QString pref = "e"; 905 QString pref = "e";
901 if ( toDelete->type() == "Todo" ) 906 if ( toDelete->type() == "Todo" )
902 pref = "t"; 907 pref = "t";
903 des += pref+ id + ","; 908 des += pref+ id + ",";
904 eve->setReadOnly( false ); 909 eve->setReadOnly( false );
905 eve->setDescription( des ); 910 eve->setDescription( des );
906 //qDebug("setdes %s ", des.latin1()); 911 //qDebug("setdes %s ", des.latin1());
907 eve->setReadOnly( true ); 912 eve->setReadOnly( true );
908 } 913 }
909 eve = lastSync.next(); 914 eve = lastSync.next();
910 } 915 }
911 916
912} 917}
913void CalendarView::checkExternalId( Incidence * inc ) 918void CalendarView::checkExternalId( Incidence * inc )
914{ 919{
915 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 920 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
916 checkExternSyncEvent( lastSync, inc ); 921 checkExternSyncEvent( lastSync, inc );
917 922
918} 923}
919bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 924bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
920{ 925{
921 bool syncOK = true; 926 bool syncOK = true;
922 int addedEvent = 0; 927 int addedEvent = 0;
923 int addedEventR = 0; 928 int addedEventR = 0;
924 int deletedEventR = 0; 929 int deletedEventR = 0;
925 int deletedEventL = 0; 930 int deletedEventL = 0;
926 int changedLocal = 0; 931 int changedLocal = 0;
927 int changedRemote = 0; 932 int changedRemote = 0;
928 int filteredIN = 0; 933 int filteredIN = 0;
929 int filteredOUT = 0; 934 int filteredOUT = 0;
930 //QPtrList<Event> el = local->rawEvents(); 935 //QPtrList<Event> el = local->rawEvents();
931 Event* eventR; 936 Event* eventR;
932 QString uid; 937 QString uid;
933 int take; 938 int take;
934 Event* eventL; 939 Event* eventL;
935 Event* eventRSync; 940 Event* eventRSync;
936 Event* eventLSync; 941 Event* eventLSync;
937 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 942 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
938 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 943 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
939 bool fullDateRange = false; 944 bool fullDateRange = false;
940 local->resetTempSyncStat(); 945 local->resetTempSyncStat();
941 mLastCalendarSync = QDateTime::currentDateTime(); 946 mLastCalendarSync = QDateTime::currentDateTime();
942 if ( mSyncManager->syncWithDesktop() ) { 947 if ( mSyncManager->syncWithDesktop() ) {
943 remote->resetPilotStat(1); 948 remote->resetPilotStat(1);
944 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 949 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
945 mLastCalendarSync = KSyncManager::mRequestedSyncEvent; 950 mLastCalendarSync = KSyncManager::mRequestedSyncEvent;
946 qDebug("using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); 951 qDebug("using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() );
947 } else { 952 } else {
948 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 953 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
949 } 954 }
950 } 955 }
951 QDateTime modifiedCalendar = mLastCalendarSync; 956 QDateTime modifiedCalendar = mLastCalendarSync;
952 eventLSync = getLastSyncEvent(); 957 eventLSync = getLastSyncEvent();
953 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 958 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
954 if ( eventR ) { 959 if ( eventR ) {
955 eventRSync = (Event*) eventR->clone(); 960 eventRSync = (Event*) eventR->clone();
956 remote->deleteEvent(eventR ); 961 remote->deleteEvent(eventR );
957 962
958 } else { 963 } else {
959 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { 964 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) {
960 eventRSync = (Event*)eventLSync->clone(); 965 eventRSync = (Event*)eventLSync->clone();
961 } else { 966 } else {
962 fullDateRange = true; 967 fullDateRange = true;
963 eventRSync = new Event(); 968 eventRSync = new Event();
964 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 969 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
965 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 970 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
966 eventRSync->setDtStart( mLastCalendarSync ); 971 eventRSync->setDtStart( mLastCalendarSync );
967 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 972 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
968 eventRSync->setCategories( i18n("SyncEvent") ); 973 eventRSync->setCategories( i18n("SyncEvent") );
969 } 974 }
970 } 975 }
971 if ( eventLSync->dtStart() == mLastCalendarSync ) 976 if ( eventLSync->dtStart() == mLastCalendarSync )
972 fullDateRange = true; 977 fullDateRange = true;
973 978
974 if ( ! fullDateRange ) { 979 if ( ! fullDateRange ) {
975 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 980 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
976 981
977 // 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() );
978 //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());
979 fullDateRange = true; 984 fullDateRange = true;
980 } 985 }
981 } 986 }
982 if ( mSyncManager->syncWithDesktop() ) { 987 if ( mSyncManager->syncWithDesktop() ) {
983 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); 988 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync );
984 } 989 }
985 if ( fullDateRange ) 990 if ( fullDateRange )
986 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 991 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
987 else 992 else
988 mLastCalendarSync = eventLSync->dtStart(); 993 mLastCalendarSync = eventLSync->dtStart();
989 // for resyncing if own file has changed 994 // for resyncing if own file has changed
990 if ( mCurrentSyncDevice == "deleteaftersync" ) { 995 if ( mCurrentSyncDevice == "deleteaftersync" ) {
991 mLastCalendarSync = loadedFileVersion; 996 mLastCalendarSync = loadedFileVersion;
992 //qDebug("setting mLastCalendarSync "); 997 //qDebug("setting mLastCalendarSync ");
993 } 998 }
994 //qDebug("*************************** "); 999 //qDebug("*************************** ");
995 qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); 1000 qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange);
996 QPtrList<Incidence> er = remote->rawIncidences(); 1001 QPtrList<Incidence> er = remote->rawIncidences();
997 Incidence* inR = er.first(); 1002 Incidence* inR = er.first();
998 Incidence* inL; 1003 Incidence* inL;
999 QProgressBar bar( er.count(),0 ); 1004 QProgressBar bar( er.count(),0 );
1000 bar.setCaption (i18n("Syncing - close to abort!") ); 1005 bar.setCaption (i18n("Syncing - close to abort!") );
1001 1006
1002 // ************** setting up filter ************* 1007 // ************** setting up filter *************
1003 CalFilter *filterIN = 0; 1008 CalFilter *filterIN = 0;
1004 CalFilter *filterOUT = 0; 1009 CalFilter *filterOUT = 0;
1005 CalFilter *filter = mFilters.first(); 1010 CalFilter *filter = mFilters.first();
1006 while(filter) { 1011 while(filter) {
1007 if ( filter->name() == mSyncManager->mFilterInCal ) 1012 if ( filter->name() == mSyncManager->mFilterInCal )
1008 filterIN = filter; 1013 filterIN = filter;
1009 if ( filter->name() == mSyncManager->mFilterOutCal ) 1014 if ( filter->name() == mSyncManager->mFilterOutCal )
1010 filterOUT = filter; 1015 filterOUT = filter;
1011 filter = mFilters.next(); 1016 filter = mFilters.next();
1012 } 1017 }
1013 int w = 300; 1018 int w = 300;
1014 if ( QApplication::desktop()->width() < 320 ) 1019 if ( QApplication::desktop()->width() < 320 )
1015 w = 220; 1020 w = 220;
1016 int h = bar.sizeHint().height() ; 1021 int h = bar.sizeHint().height() ;
1017 int dw = QApplication::desktop()->width(); 1022 int dw = QApplication::desktop()->width();
1018 int dh = QApplication::desktop()->height(); 1023 int dh = QApplication::desktop()->height();
1019 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1024 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1020 bar.show(); 1025 bar.show();
1021 int modulo = (er.count()/10)+1; 1026 int modulo = (er.count()/10)+1;
1022 int incCounter = 0; 1027 int incCounter = 0;
1023 while ( inR ) { 1028 while ( inR ) {
1024 if ( ! bar.isVisible() ) 1029 if ( ! bar.isVisible() )
1025 return false; 1030 return false;
1026 if ( incCounter % modulo == 0 ) 1031 if ( incCounter % modulo == 0 )
1027 bar.setProgress( incCounter ); 1032 bar.setProgress( incCounter );
1028 ++incCounter; 1033 ++incCounter;
1029 uid = inR->uid(); 1034 uid = inR->uid();
1030 bool skipIncidence = false; 1035 bool skipIncidence = false;
1031 if ( uid.left(15) == QString("last-syncEvent-") ) 1036 if ( uid.left(15) == QString("last-syncEvent-") )
1032 skipIncidence = true; 1037 skipIncidence = true;
1033 QString idS; 1038 QString idS;
1034 qApp->processEvents(); 1039 qApp->processEvents();
1035 if ( !skipIncidence ) { 1040 if ( !skipIncidence ) {
1036 inL = local->incidence( uid ); 1041 inL = local->incidence( uid );
1037 if ( inL ) { // maybe conflict - same uid in both calendars 1042 if ( inL ) { // maybe conflict - same uid in both calendars
1038 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1043 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1039 //qDebug("take %d %s ", take, inL->summary().latin1()); 1044 //qDebug("take %d %s ", take, inL->summary().latin1());
1040 if ( take == 3 ) 1045 if ( take == 3 )
1041 return false; 1046 return false;
1042 if ( take == 1 ) {// take local ********************** 1047 if ( take == 1 ) {// take local **********************
1043 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1048 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1044 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1049 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1045 else 1050 else
1046 idS = inR->IDStr(); 1051 idS = inR->IDStr();
1047 remote->deleteIncidence( inR ); 1052 remote->deleteIncidence( inR );
1048 inR = inL->clone(); 1053 inR = inL->clone();
1049 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1054 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1050 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1055 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1051 inR->setIDStr( idS ); 1056 inR->setIDStr( idS );
1052 remote->addIncidence( inR ); 1057 remote->addIncidence( inR );
1053 if ( mSyncManager->syncWithDesktop() ) 1058 if ( mSyncManager->syncWithDesktop() )
1054 inR->setPilotId( 2 ); 1059 inR->setPilotId( 2 );
1055 ++changedRemote; 1060 ++changedRemote;
1056 } else {// take remote ********************** 1061 } else {// take remote **********************
1057 idS = inL->IDStr(); 1062 idS = inL->IDStr();
1058 int pid = inL->pilotId(); 1063 int pid = inL->pilotId();
1059 local->deleteIncidence( inL ); 1064 local->deleteIncidence( inL );
@@ -3084,772 +3089,775 @@ void CalendarView::schedule_publish(Incidence *incidence)
3084{ 3089{
3085 Event *event = 0; 3090 Event *event = 0;
3086 Todo *todo = 0; 3091 Todo *todo = 0;
3087 3092
3088 if (incidence == 0) { 3093 if (incidence == 0) {
3089 incidence = mViewManager->currentView()->selectedIncidences().first(); 3094 incidence = mViewManager->currentView()->selectedIncidences().first();
3090 if (incidence == 0) { 3095 if (incidence == 0) {
3091 incidence = mTodoList->selectedIncidences().first(); 3096 incidence = mTodoList->selectedIncidences().first();
3092 } 3097 }
3093 } 3098 }
3094 if ( incidence && incidence->type() == "Event" ) { 3099 if ( incidence && incidence->type() == "Event" ) {
3095 event = static_cast<Event *>(incidence); 3100 event = static_cast<Event *>(incidence);
3096 } else { 3101 } else {
3097 if ( incidence && incidence->type() == "Todo" ) { 3102 if ( incidence && incidence->type() == "Todo" ) {
3098 todo = static_cast<Todo *>(incidence); 3103 todo = static_cast<Todo *>(incidence);
3099 } 3104 }
3100 } 3105 }
3101 3106
3102 if (!event && !todo) { 3107 if (!event && !todo) {
3103 KMessageBox::sorry(this,i18n("No event selected.")); 3108 KMessageBox::sorry(this,i18n("No event selected."));
3104 return; 3109 return;
3105 } 3110 }
3106 3111
3107 PublishDialog *publishdlg = new PublishDialog(); 3112 PublishDialog *publishdlg = new PublishDialog();
3108 if (incidence->attendeeCount()>0) { 3113 if (incidence->attendeeCount()>0) {
3109 QPtrList<Attendee> attendees = incidence->attendees(); 3114 QPtrList<Attendee> attendees = incidence->attendees();
3110 attendees.first(); 3115 attendees.first();
3111 while ( attendees.current()!=0 ) { 3116 while ( attendees.current()!=0 ) {
3112 publishdlg->addAttendee(attendees.current()); 3117 publishdlg->addAttendee(attendees.current());
3113 attendees.next(); 3118 attendees.next();
3114 } 3119 }
3115 } 3120 }
3116 bool send = true; 3121 bool send = true;
3117 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { 3122 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) {
3118 if ( publishdlg->exec() != QDialog::Accepted ) 3123 if ( publishdlg->exec() != QDialog::Accepted )
3119 send = false; 3124 send = false;
3120 } 3125 }
3121 if ( send ) { 3126 if ( send ) {
3122 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3127 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3123 if ( event ) { 3128 if ( event ) {
3124 Event *ev = new Event(*event); 3129 Event *ev = new Event(*event);
3125 ev->registerObserver(0); 3130 ev->registerObserver(0);
3126 ev->clearAttendees(); 3131 ev->clearAttendees();
3127 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3132 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3128 delete(ev); 3133 delete(ev);
3129 } 3134 }
3130 } else { 3135 } else {
3131 if ( todo ) { 3136 if ( todo ) {
3132 Todo *ev = new Todo(*todo); 3137 Todo *ev = new Todo(*todo);
3133 ev->registerObserver(0); 3138 ev->registerObserver(0);
3134 ev->clearAttendees(); 3139 ev->clearAttendees();
3135 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3140 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3136 delete(ev); 3141 delete(ev);
3137 } 3142 }
3138 } 3143 }
3139 } 3144 }
3140 } 3145 }
3141 delete publishdlg; 3146 delete publishdlg;
3142} 3147}
3143 3148
3144void CalendarView::schedule_request(Incidence *incidence) 3149void CalendarView::schedule_request(Incidence *incidence)
3145{ 3150{
3146 schedule(Scheduler::Request,incidence); 3151 schedule(Scheduler::Request,incidence);
3147} 3152}
3148 3153
3149void CalendarView::schedule_refresh(Incidence *incidence) 3154void CalendarView::schedule_refresh(Incidence *incidence)
3150{ 3155{
3151 schedule(Scheduler::Refresh,incidence); 3156 schedule(Scheduler::Refresh,incidence);
3152} 3157}
3153 3158
3154void CalendarView::schedule_cancel(Incidence *incidence) 3159void CalendarView::schedule_cancel(Incidence *incidence)
3155{ 3160{
3156 schedule(Scheduler::Cancel,incidence); 3161 schedule(Scheduler::Cancel,incidence);
3157} 3162}
3158 3163
3159void CalendarView::schedule_add(Incidence *incidence) 3164void CalendarView::schedule_add(Incidence *incidence)
3160{ 3165{
3161 schedule(Scheduler::Add,incidence); 3166 schedule(Scheduler::Add,incidence);
3162} 3167}
3163 3168
3164void CalendarView::schedule_reply(Incidence *incidence) 3169void CalendarView::schedule_reply(Incidence *incidence)
3165{ 3170{
3166 schedule(Scheduler::Reply,incidence); 3171 schedule(Scheduler::Reply,incidence);
3167} 3172}
3168 3173
3169void CalendarView::schedule_counter(Incidence *incidence) 3174void CalendarView::schedule_counter(Incidence *incidence)
3170{ 3175{
3171 schedule(Scheduler::Counter,incidence); 3176 schedule(Scheduler::Counter,incidence);
3172} 3177}
3173 3178
3174void CalendarView::schedule_declinecounter(Incidence *incidence) 3179void CalendarView::schedule_declinecounter(Incidence *incidence)
3175{ 3180{
3176 schedule(Scheduler::Declinecounter,incidence); 3181 schedule(Scheduler::Declinecounter,incidence);
3177} 3182}
3178 3183
3179void CalendarView::schedule_publish_freebusy(int daysToPublish) 3184void CalendarView::schedule_publish_freebusy(int daysToPublish)
3180{ 3185{
3181 QDateTime start = QDateTime::currentDateTime(); 3186 QDateTime start = QDateTime::currentDateTime();
3182 QDateTime end = start.addDays(daysToPublish); 3187 QDateTime end = start.addDays(daysToPublish);
3183 3188
3184 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); 3189 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end);
3185 freebusy->setOrganizer(KOPrefs::instance()->email()); 3190 freebusy->setOrganizer(KOPrefs::instance()->email());
3186 3191
3187 3192
3188 PublishDialog *publishdlg = new PublishDialog(); 3193 PublishDialog *publishdlg = new PublishDialog();
3189 if ( publishdlg->exec() == QDialog::Accepted ) { 3194 if ( publishdlg->exec() == QDialog::Accepted ) {
3190 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3195 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3191 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { 3196 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) {
3192 delete(freebusy); 3197 delete(freebusy);
3193 } 3198 }
3194 } 3199 }
3195 delete publishdlg; 3200 delete publishdlg;
3196} 3201}
3197 3202
3198void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) 3203void CalendarView::schedule(Scheduler::Method method, Incidence *incidence)
3199{ 3204{
3200 Event *event = 0; 3205 Event *event = 0;
3201 Todo *todo = 0; 3206 Todo *todo = 0;
3202 3207
3203 if (incidence == 0) { 3208 if (incidence == 0) {
3204 incidence = mViewManager->currentView()->selectedIncidences().first(); 3209 incidence = mViewManager->currentView()->selectedIncidences().first();
3205 if (incidence == 0) { 3210 if (incidence == 0) {
3206 incidence = mTodoList->selectedIncidences().first(); 3211 incidence = mTodoList->selectedIncidences().first();
3207 } 3212 }
3208 } 3213 }
3209 if ( incidence && incidence->type() == "Event" ) { 3214 if ( incidence && incidence->type() == "Event" ) {
3210 event = static_cast<Event *>(incidence); 3215 event = static_cast<Event *>(incidence);
3211 } 3216 }
3212 if ( incidence && incidence->type() == "Todo" ) { 3217 if ( incidence && incidence->type() == "Todo" ) {
3213 todo = static_cast<Todo *>(incidence); 3218 todo = static_cast<Todo *>(incidence);
3214 } 3219 }
3215 3220
3216 if (!event && !todo) { 3221 if (!event && !todo) {
3217 KMessageBox::sorry(this,i18n("No event selected.")); 3222 KMessageBox::sorry(this,i18n("No event selected."));
3218 return; 3223 return;
3219 } 3224 }
3220 3225
3221 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { 3226 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) {
3222 KMessageBox::sorry(this,i18n("The event has no attendees.")); 3227 KMessageBox::sorry(this,i18n("The event has no attendees."));
3223 return; 3228 return;
3224 } 3229 }
3225 3230
3226 Event *ev = 0; 3231 Event *ev = 0;
3227 if (event) ev = new Event(*event); 3232 if (event) ev = new Event(*event);
3228 Todo *to = 0; 3233 Todo *to = 0;
3229 if (todo) to = new Todo(*todo); 3234 if (todo) to = new Todo(*todo);
3230 3235
3231 if (method == Scheduler::Reply || method == Scheduler::Refresh) { 3236 if (method == Scheduler::Reply || method == Scheduler::Refresh) {
3232 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 3237 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
3233 if (!me) { 3238 if (!me) {
3234 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); 3239 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails."));
3235 return; 3240 return;
3236 } 3241 }
3237 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { 3242 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) {
3238 StatusDialog *statdlg = new StatusDialog(this); 3243 StatusDialog *statdlg = new StatusDialog(this);
3239 if (!statdlg->exec()==QDialog::Accepted) return; 3244 if (!statdlg->exec()==QDialog::Accepted) return;
3240 me->setStatus( statdlg->status() ); 3245 me->setStatus( statdlg->status() );
3241 delete(statdlg); 3246 delete(statdlg);
3242 } 3247 }
3243 Attendee *menew = new Attendee(*me); 3248 Attendee *menew = new Attendee(*me);
3244 if (ev) { 3249 if (ev) {
3245 ev->clearAttendees(); 3250 ev->clearAttendees();
3246 ev->addAttendee(menew,false); 3251 ev->addAttendee(menew,false);
3247 } else { 3252 } else {
3248 if (to) { 3253 if (to) {
3249 todo->clearAttendees(); 3254 todo->clearAttendees();
3250 todo->addAttendee(menew,false); 3255 todo->addAttendee(menew,false);
3251 } 3256 }
3252 } 3257 }
3253 } 3258 }
3254 3259
3255 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3260 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3256 if (ev) { 3261 if (ev) {
3257 if ( !dlg->addMessage(ev,method) ) delete(ev); 3262 if ( !dlg->addMessage(ev,method) ) delete(ev);
3258 } else { 3263 } else {
3259 if (to) { 3264 if (to) {
3260 if ( !dlg->addMessage(to,method) ) delete(to); 3265 if ( !dlg->addMessage(to,method) ) delete(to);
3261 } 3266 }
3262 } 3267 }
3263} 3268}
3264 3269
3265void CalendarView::openAddressbook() 3270void CalendarView::openAddressbook()
3266{ 3271{
3267 KRun::runCommand("kaddressbook"); 3272 KRun::runCommand("kaddressbook");
3268} 3273}
3269 3274
3270void CalendarView::setModified(bool modified) 3275void CalendarView::setModified(bool modified)
3271{ 3276{
3272 if ( modified ) 3277 if ( modified )
3273 emit signalmodified(); 3278 emit signalmodified();
3274 if (mModified != modified) { 3279 if (mModified != modified) {
3275 mModified = modified; 3280 mModified = modified;
3276 emit modifiedChanged(mModified); 3281 emit modifiedChanged(mModified);
3277 } 3282 }
3278} 3283}
3279 3284
3280bool CalendarView::isReadOnly() 3285bool CalendarView::isReadOnly()
3281{ 3286{
3282 return mReadOnly; 3287 return mReadOnly;
3283} 3288}
3284 3289
3285void CalendarView::setReadOnly(bool readOnly) 3290void CalendarView::setReadOnly(bool readOnly)
3286{ 3291{
3287 if (mReadOnly != readOnly) { 3292 if (mReadOnly != readOnly) {
3288 mReadOnly = readOnly; 3293 mReadOnly = readOnly;
3289 emit readOnlyChanged(mReadOnly); 3294 emit readOnlyChanged(mReadOnly);
3290 } 3295 }
3291} 3296}
3292 3297
3293bool CalendarView::isModified() 3298bool CalendarView::isModified()
3294{ 3299{
3295 return mModified; 3300 return mModified;
3296} 3301}
3297 3302
3298void CalendarView::printSetup() 3303void CalendarView::printSetup()
3299{ 3304{
3300#ifndef KORG_NOPRINTER 3305#ifndef KORG_NOPRINTER
3301 createPrinter(); 3306 createPrinter();
3302 3307
3303 mCalPrinter->setupPrinter(); 3308 mCalPrinter->setupPrinter();
3304#endif 3309#endif
3305} 3310}
3306 3311
3307void CalendarView::print() 3312void CalendarView::print()
3308{ 3313{
3309#ifndef KORG_NOPRINTER 3314#ifndef KORG_NOPRINTER
3310 createPrinter(); 3315 createPrinter();
3311 3316
3312 DateList tmpDateList = mNavigator->selectedDates(); 3317 DateList tmpDateList = mNavigator->selectedDates();
3313 mCalPrinter->print(CalPrinter::Month, 3318 mCalPrinter->print(CalPrinter::Month,
3314 tmpDateList.first(), tmpDateList.last()); 3319 tmpDateList.first(), tmpDateList.last());
3315#endif 3320#endif
3316} 3321}
3317 3322
3318void CalendarView::printPreview() 3323void CalendarView::printPreview()
3319{ 3324{
3320#ifndef KORG_NOPRINTER 3325#ifndef KORG_NOPRINTER
3321 kdDebug() << "CalendarView::printPreview()" << endl; 3326 kdDebug() << "CalendarView::printPreview()" << endl;
3322 3327
3323 createPrinter(); 3328 createPrinter();
3324 3329
3325 DateList tmpDateList = mNavigator->selectedDates(); 3330 DateList tmpDateList = mNavigator->selectedDates();
3326 3331
3327 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), 3332 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(),
3328 tmpDateList.last()); 3333 tmpDateList.last());
3329#endif 3334#endif
3330} 3335}
3331 3336
3332void CalendarView::exportICalendar() 3337void CalendarView::exportICalendar()
3333{ 3338{
3334 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); 3339 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this);
3335 3340
3336 // Force correct extension 3341 // Force correct extension
3337 if (filename.right(4) != ".ics") filename += ".ics"; 3342 if (filename.right(4) != ".ics") filename += ".ics";
3338 3343
3339 FileStorage storage( mCalendar, filename, new ICalFormat() ); 3344 FileStorage storage( mCalendar, filename, new ICalFormat() );
3340 storage.save(); 3345 storage.save();
3341} 3346}
3342 3347
3343bool CalendarView::exportVCalendar( QString filename ) 3348bool CalendarView::exportVCalendar( QString filename )
3344{ 3349{
3345 if (mCalendar->journals().count() > 0) { 3350 if (mCalendar->journals().count() > 0) {
3346 int result = KMessageBox::warningContinueCancel(this, 3351 int result = KMessageBox::warningContinueCancel(this,
3347 i18n("The journal entries can not be\nexported to a vCalendar file."), 3352 i18n("The journal entries can not be\nexported to a vCalendar file."),
3348 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 3353 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
3349 true); 3354 true);
3350 if (result != KMessageBox::Continue) return false; 3355 if (result != KMessageBox::Continue) return false;
3351 } 3356 }
3352 3357
3353 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); 3358 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this);
3354 3359
3355 // Force correct extension 3360 // Force correct extension
3356 if (filename.right(4) != ".vcs") filename += ".vcs"; 3361 if (filename.right(4) != ".vcs") filename += ".vcs";
3357 3362
3358 FileStorage storage( mCalendar, filename, new VCalFormat ); 3363 FileStorage storage( mCalendar, filename, new VCalFormat );
3359 return storage.save(); 3364 return storage.save();
3360 3365
3361} 3366}
3362 3367
3363void CalendarView::eventUpdated(Incidence *) 3368void CalendarView::eventUpdated(Incidence *)
3364{ 3369{
3365 setModified(); 3370 setModified();
3366 // Don't call updateView here. The code, which has caused the update of the 3371 // Don't call updateView here. The code, which has caused the update of the
3367 // event is responsible for updating the view. 3372 // event is responsible for updating the view.
3368 // updateView(); 3373 // updateView();
3369} 3374}
3370 3375
3371void CalendarView::adaptNavigationUnits() 3376void CalendarView::adaptNavigationUnits()
3372{ 3377{
3373 if (mViewManager->currentView()->isEventView()) { 3378 if (mViewManager->currentView()->isEventView()) {
3374 int days = mViewManager->currentView()->currentDateCount(); 3379 int days = mViewManager->currentView()->currentDateCount();
3375 if (days == 1) { 3380 if (days == 1) {
3376 emit changeNavStringPrev(i18n("&Previous Day")); 3381 emit changeNavStringPrev(i18n("&Previous Day"));
3377 emit changeNavStringNext(i18n("&Next Day")); 3382 emit changeNavStringNext(i18n("&Next Day"));
3378 } else { 3383 } else {
3379 emit changeNavStringPrev(i18n("&Previous Week")); 3384 emit changeNavStringPrev(i18n("&Previous Week"));
3380 emit changeNavStringNext(i18n("&Next Week")); 3385 emit changeNavStringNext(i18n("&Next Week"));
3381 } 3386 }
3382 } 3387 }
3383} 3388}
3384 3389
3385void CalendarView::processMainViewSelection( Incidence *incidence ) 3390void CalendarView::processMainViewSelection( Incidence *incidence )
3386{ 3391{
3387 if ( incidence ) mTodoList->clearSelection(); 3392 if ( incidence ) mTodoList->clearSelection();
3388 processIncidenceSelection( incidence ); 3393 processIncidenceSelection( incidence );
3389} 3394}
3390 3395
3391void CalendarView::processTodoListSelection( Incidence *incidence ) 3396void CalendarView::processTodoListSelection( Incidence *incidence )
3392{ 3397{
3393 if ( incidence && mViewManager->currentView() ) { 3398 if ( incidence && mViewManager->currentView() ) {
3394 mViewManager->currentView()->clearSelection(); 3399 mViewManager->currentView()->clearSelection();
3395 } 3400 }
3396 processIncidenceSelection( incidence ); 3401 processIncidenceSelection( incidence );
3397} 3402}
3398 3403
3399void CalendarView::processIncidenceSelection( Incidence *incidence ) 3404void CalendarView::processIncidenceSelection( Incidence *incidence )
3400{ 3405{
3401 if ( incidence == mSelectedIncidence ) return; 3406 if ( incidence == mSelectedIncidence ) return;
3402 3407
3403 mSelectedIncidence = incidence; 3408 mSelectedIncidence = incidence;
3404 3409
3405 emit incidenceSelected( mSelectedIncidence ); 3410 emit incidenceSelected( mSelectedIncidence );
3406 3411
3407 if ( incidence && incidence->type() == "Event" ) { 3412 if ( incidence && incidence->type() == "Event" ) {
3408 Event *event = static_cast<Event *>( incidence ); 3413 Event *event = static_cast<Event *>( incidence );
3409 if ( event->organizer() == KOPrefs::instance()->email() ) { 3414 if ( event->organizer() == KOPrefs::instance()->email() ) {
3410 emit organizerEventsSelected( true ); 3415 emit organizerEventsSelected( true );
3411 } else { 3416 } else {
3412 emit organizerEventsSelected(false); 3417 emit organizerEventsSelected(false);
3413 } 3418 }
3414 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3419 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3415 KOPrefs::instance()->email() ) ) { 3420 KOPrefs::instance()->email() ) ) {
3416 emit groupEventsSelected( true ); 3421 emit groupEventsSelected( true );
3417 } else { 3422 } else {
3418 emit groupEventsSelected(false); 3423 emit groupEventsSelected(false);
3419 } 3424 }
3420 return; 3425 return;
3421 } else { 3426 } else {
3422 if ( incidence && incidence->type() == "Todo" ) { 3427 if ( incidence && incidence->type() == "Todo" ) {
3423 emit todoSelected( true ); 3428 emit todoSelected( true );
3424 Todo *event = static_cast<Todo *>( incidence ); 3429 Todo *event = static_cast<Todo *>( incidence );
3425 if ( event->organizer() == KOPrefs::instance()->email() ) { 3430 if ( event->organizer() == KOPrefs::instance()->email() ) {
3426 emit organizerEventsSelected( true ); 3431 emit organizerEventsSelected( true );
3427 } else { 3432 } else {
3428 emit organizerEventsSelected(false); 3433 emit organizerEventsSelected(false);
3429 } 3434 }
3430 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3435 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3431 KOPrefs::instance()->email() ) ) { 3436 KOPrefs::instance()->email() ) ) {
3432 emit groupEventsSelected( true ); 3437 emit groupEventsSelected( true );
3433 } else { 3438 } else {
3434 emit groupEventsSelected(false); 3439 emit groupEventsSelected(false);
3435 } 3440 }
3436 return; 3441 return;
3437 } else { 3442 } else {
3438 emit todoSelected( false ); 3443 emit todoSelected( false );
3439 emit organizerEventsSelected(false); 3444 emit organizerEventsSelected(false);
3440 emit groupEventsSelected(false); 3445 emit groupEventsSelected(false);
3441 } 3446 }
3442 return; 3447 return;
3443 } 3448 }
3444 3449
3445 /* if ( incidence && incidence->type() == "Todo" ) { 3450 /* if ( incidence && incidence->type() == "Todo" ) {
3446 emit todoSelected( true ); 3451 emit todoSelected( true );
3447 } else { 3452 } else {
3448 emit todoSelected( false ); 3453 emit todoSelected( false );
3449 }*/ 3454 }*/
3450} 3455}
3451 3456
3452 3457
3453void CalendarView::checkClipboard() 3458void CalendarView::checkClipboard()
3454{ 3459{
3455#ifndef KORG_NODND 3460#ifndef KORG_NODND
3456 if (ICalDrag::canDecode(QApplication::clipboard()->data())) { 3461 if (ICalDrag::canDecode(QApplication::clipboard()->data())) {
3457 emit pasteEnabled(true); 3462 emit pasteEnabled(true);
3458 } else { 3463 } else {
3459 emit pasteEnabled(false); 3464 emit pasteEnabled(false);
3460 } 3465 }
3461#endif 3466#endif
3462} 3467}
3463 3468
3464void CalendarView::showDates(const DateList &selectedDates) 3469void CalendarView::showDates(const DateList &selectedDates)
3465{ 3470{
3466 // kdDebug() << "CalendarView::selectDates()" << endl; 3471 // kdDebug() << "CalendarView::selectDates()" << endl;
3467 3472
3468 if ( mViewManager->currentView() ) { 3473
3469 updateView( selectedDates.first(), selectedDates.last() ); 3474 if ( !mBlockShowDates ) {
3470 } else { 3475 if ( mViewManager->currentView() ) {
3471 mViewManager->showAgendaView(); 3476 updateView( selectedDates.first(), selectedDates.last() );
3477 } else {
3478 mViewManager->showAgendaView();
3479 }
3472 } 3480 }
3473 3481
3474 QString selDates; 3482 QString selDates;
3475 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); 3483 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true);
3476 if (selectedDates.first() < selectedDates.last() ) 3484 if (selectedDates.first() < selectedDates.last() )
3477 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); 3485 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true);
3478 topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); 3486 topLevelWidget()->setCaption( i18n("Dates: ") + selDates );
3479 3487
3480} 3488}
3481 3489
3482QPtrList<CalFilter> CalendarView::filters() 3490QPtrList<CalFilter> CalendarView::filters()
3483{ 3491{
3484 return mFilters; 3492 return mFilters;
3485 3493
3486} 3494}
3487void CalendarView::editFilters() 3495void CalendarView::editFilters()
3488{ 3496{
3489 // kdDebug() << "CalendarView::editFilters()" << endl; 3497 // kdDebug() << "CalendarView::editFilters()" << endl;
3490 3498
3491 CalFilter *filter = mFilters.first(); 3499 CalFilter *filter = mFilters.first();
3492 while(filter) { 3500 while(filter) {
3493 kdDebug() << " Filter: " << filter->name() << endl; 3501 kdDebug() << " Filter: " << filter->name() << endl;
3494 filter = mFilters.next(); 3502 filter = mFilters.next();
3495 } 3503 }
3496 3504
3497 mDialogManager->showFilterEditDialog(&mFilters); 3505 mDialogManager->showFilterEditDialog(&mFilters);
3498} 3506}
3499void CalendarView::toggleFilter() 3507void CalendarView::toggleFilter()
3500{ 3508{
3501 showFilter(! mFilterView->isVisible()); 3509 showFilter(! mFilterView->isVisible());
3502} 3510}
3503 3511
3504KOFilterView *CalendarView::filterView() 3512KOFilterView *CalendarView::filterView()
3505{ 3513{
3506 return mFilterView; 3514 return mFilterView;
3507} 3515}
3508void CalendarView::selectFilter( int fil ) 3516void CalendarView::selectFilter( int fil )
3509{ 3517{
3510 mFilterView->setSelectedFilter( fil ); 3518 mFilterView->setSelectedFilter( fil );
3511} 3519}
3512void CalendarView::showFilter(bool visible) 3520void CalendarView::showFilter(bool visible)
3513{ 3521{
3514 if (visible) mFilterView->show(); 3522 if (visible) mFilterView->show();
3515 else mFilterView->hide(); 3523 else mFilterView->hide();
3516} 3524}
3517void CalendarView::toggleFilerEnabled( ) 3525void CalendarView::toggleFilerEnabled( )
3518{ 3526{
3519 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); 3527 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() );
3520 if ( !mFilterView->filtersEnabled() ) 3528 if ( !mFilterView->filtersEnabled() )
3521 topLevelWidget()->setCaption( i18n("Filter disabled ") ); 3529 topLevelWidget()->setCaption( i18n("Filter disabled ") );
3522 3530
3523} 3531}
3524void CalendarView::updateFilter() 3532void CalendarView::updateFilter()
3525{ 3533{
3526 CalFilter *filter = mFilterView->selectedFilter(); 3534 CalFilter *filter = mFilterView->selectedFilter();
3527 if (filter) { 3535 if (filter) {
3528 if (mFilterView->filtersEnabled()) { 3536 if (mFilterView->filtersEnabled()) {
3529 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); 3537 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() );
3530 filter->setEnabled(true); 3538 filter->setEnabled(true);
3531 } 3539 }
3532 else filter->setEnabled(false); 3540 else filter->setEnabled(false);
3533 mCalendar->setFilter(filter); 3541 mCalendar->setFilter(filter);
3534 updateView(); 3542 updateView();
3535 } 3543 }
3536} 3544}
3537 3545
3538void CalendarView::filterEdited() 3546void CalendarView::filterEdited()
3539{ 3547{
3540 mFilterView->updateFilters(); 3548 mFilterView->updateFilters();
3541 updateFilter(); 3549 updateFilter();
3542 writeSettings(); 3550 writeSettings();
3543} 3551}
3544 3552
3545 3553
3546void CalendarView::takeOverEvent() 3554void CalendarView::takeOverEvent()
3547{ 3555{
3548 Incidence *incidence = currentSelection(); 3556 Incidence *incidence = currentSelection();
3549 3557
3550 if (!incidence) return; 3558 if (!incidence) return;
3551 3559
3552 incidence->setOrganizer(KOPrefs::instance()->email()); 3560 incidence->setOrganizer(KOPrefs::instance()->email());
3553 incidence->recreate(); 3561 incidence->recreate();
3554 incidence->setReadOnly(false); 3562 incidence->setReadOnly(false);
3555 3563
3556 updateView(); 3564 updateView();
3557} 3565}
3558 3566
3559void CalendarView::takeOverCalendar() 3567void CalendarView::takeOverCalendar()
3560{ 3568{
3561 // TODO: Create Calendar::allIncidences() function and use it here 3569 // TODO: Create Calendar::allIncidences() function and use it here
3562 3570
3563 QPtrList<Event> events = mCalendar->events(); 3571 QPtrList<Event> events = mCalendar->events();
3564 for(uint i=0; i<events.count(); ++i) { 3572 for(uint i=0; i<events.count(); ++i) {
3565 events.at(i)->setOrganizer(KOPrefs::instance()->email()); 3573 events.at(i)->setOrganizer(KOPrefs::instance()->email());
3566 events.at(i)->recreate(); 3574 events.at(i)->recreate();
3567 events.at(i)->setReadOnly(false); 3575 events.at(i)->setReadOnly(false);
3568 } 3576 }
3569 3577
3570 QPtrList<Todo> todos = mCalendar->todos(); 3578 QPtrList<Todo> todos = mCalendar->todos();
3571 for(uint i=0; i<todos.count(); ++i) { 3579 for(uint i=0; i<todos.count(); ++i) {
3572 todos.at(i)->setOrganizer(KOPrefs::instance()->email()); 3580 todos.at(i)->setOrganizer(KOPrefs::instance()->email());
3573 todos.at(i)->recreate(); 3581 todos.at(i)->recreate();
3574 todos.at(i)->setReadOnly(false); 3582 todos.at(i)->setReadOnly(false);
3575 } 3583 }
3576 3584
3577 QPtrList<Journal> journals = mCalendar->journals(); 3585 QPtrList<Journal> journals = mCalendar->journals();
3578 for(uint i=0; i<journals.count(); ++i) { 3586 for(uint i=0; i<journals.count(); ++i) {
3579 journals.at(i)->setOrganizer(KOPrefs::instance()->email()); 3587 journals.at(i)->setOrganizer(KOPrefs::instance()->email());
3580 journals.at(i)->recreate(); 3588 journals.at(i)->recreate();
3581 journals.at(i)->setReadOnly(false); 3589 journals.at(i)->setReadOnly(false);
3582 } 3590 }
3583 3591
3584 updateView(); 3592 updateView();
3585} 3593}
3586 3594
3587void CalendarView::showIntro() 3595void CalendarView::showIntro()
3588{ 3596{
3589 kdDebug() << "To be implemented." << endl; 3597 kdDebug() << "To be implemented." << endl;
3590} 3598}
3591 3599
3592QWidgetStack *CalendarView::viewStack() 3600QWidgetStack *CalendarView::viewStack()
3593{ 3601{
3594 return mRightFrame; 3602 return mRightFrame;
3595} 3603}
3596 3604
3597QWidget *CalendarView::leftFrame() 3605QWidget *CalendarView::leftFrame()
3598{ 3606{
3599 return mLeftFrame; 3607 return mLeftFrame;
3600} 3608}
3601 3609
3602DateNavigator *CalendarView::dateNavigator() 3610DateNavigator *CalendarView::dateNavigator()
3603{ 3611{
3604 return mNavigator; 3612 return mNavigator;
3605} 3613}
3606 3614
3607KDateNavigator* CalendarView::dateNavigatorWidget() 3615KDateNavigator* CalendarView::dateNavigatorWidget()
3608{ 3616{
3609 return mDateNavigator; 3617 return mDateNavigator;
3610} 3618}
3611void CalendarView::toggleDateNavigatorWidget() 3619void CalendarView::toggleDateNavigatorWidget()
3612{ 3620{
3613 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; 3621 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ;
3614 if (!KOPrefs::instance()->mShowDateNavigator ) 3622 if (!KOPrefs::instance()->mShowDateNavigator )
3615 mDateNavigator->hide(); 3623 mDateNavigator->hide();
3616 else 3624 else
3617 mDateNavigator->show(); 3625 mDateNavigator->show();
3618} 3626}
3619void CalendarView::addView(KOrg::BaseView *view) 3627void CalendarView::addView(KOrg::BaseView *view)
3620{ 3628{
3621 mViewManager->addView(view); 3629 mViewManager->addView(view);
3622} 3630}
3623 3631
3624void CalendarView::showView(KOrg::BaseView *view) 3632void CalendarView::showView(KOrg::BaseView *view)
3625{ 3633{
3626 mViewManager->showView(view, mLeftFrame->isVisible()); 3634 mViewManager->showView(view, mLeftFrame->isVisible());
3627} 3635}
3628 3636
3629Incidence *CalendarView::currentSelection() 3637Incidence *CalendarView::currentSelection()
3630{ 3638{
3631 return mViewManager->currentSelection(); 3639 return mViewManager->currentSelection();
3632} 3640}
3633void CalendarView::toggleAllDaySize() 3641void CalendarView::toggleAllDaySize()
3634{ 3642{
3635 /* 3643 /*
3636 if ( KOPrefs::instance()->mAllDaySize > 47 ) 3644 if ( KOPrefs::instance()->mAllDaySize > 47 )
3637 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; 3645 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2;
3638 else 3646 else
3639 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; 3647 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2;
3640 */ 3648 */
3641 viewManager()->agendaView()->toggleAllDay(); 3649 viewManager()->agendaView()->toggleAllDay();
3642} 3650}
3643void CalendarView::toggleExpand() 3651void CalendarView::toggleExpand()
3644{ 3652{
3645 // if ( mLeftFrame->isHidden() ) { 3653 // if ( mLeftFrame->isHidden() ) {
3646 // mLeftFrame->show(); 3654 // mLeftFrame->show();
3647 // emit calendarViewExpanded( false ); 3655 // emit calendarViewExpanded( false );
3648 // } else { 3656 // } else {
3649 // mLeftFrame->hide(); 3657 // mLeftFrame->hide();
3650 // emit calendarViewExpanded( true ); 3658 // emit calendarViewExpanded( true );
3651 // } 3659 // }
3652 3660
3653 globalFlagBlockAgenda = 1; 3661 globalFlagBlockAgenda = 1;
3654 emit calendarViewExpanded( !mLeftFrame->isHidden() ); 3662 emit calendarViewExpanded( !mLeftFrame->isHidden() );
3655 globalFlagBlockAgenda = 5; 3663 globalFlagBlockAgenda = 5;
3656 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); 3664 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() );
3657 //mViewManager->showView( 0, true ); 3665 //mViewManager->showView( 0, true );
3658} 3666}
3659 3667
3660void CalendarView::calendarModified( bool modified, Calendar * ) 3668void CalendarView::calendarModified( bool modified, Calendar * )
3661{ 3669{
3662 setModified( modified ); 3670 setModified( modified );
3663} 3671}
3664 3672
3665Todo *CalendarView::selectedTodo() 3673Todo *CalendarView::selectedTodo()
3666{ 3674{
3667 Incidence *incidence = currentSelection(); 3675 Incidence *incidence = currentSelection();
3668 if ( incidence && incidence->type() == "Todo" ) { 3676 if ( incidence && incidence->type() == "Todo" ) {
3669 return static_cast<Todo *>( incidence ); 3677 return static_cast<Todo *>( incidence );
3670 } 3678 }
3671 3679
3672 incidence = mTodoList->selectedIncidences().first(); 3680 incidence = mTodoList->selectedIncidences().first();
3673 if ( incidence && incidence->type() == "Todo" ) { 3681 if ( incidence && incidence->type() == "Todo" ) {
3674 return static_cast<Todo *>( incidence ); 3682 return static_cast<Todo *>( incidence );
3675 } 3683 }
3676 3684
3677 return 0; 3685 return 0;
3678} 3686}
3679 3687
3680void CalendarView::dialogClosing(Incidence *in) 3688void CalendarView::dialogClosing(Incidence *in)
3681{ 3689{
3682 // mDialogList.remove(in); 3690 // mDialogList.remove(in);
3683} 3691}
3684 3692
3685void CalendarView::showIncidence() 3693void CalendarView::showIncidence()
3686{ 3694{
3687 Incidence *incidence = currentSelection(); 3695 Incidence *incidence = currentSelection();
3688 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3696 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3689 if ( incidence ) { 3697 if ( incidence ) {
3690 ShowIncidenceVisitor v; 3698 ShowIncidenceVisitor v;
3691 v.act( incidence, this ); 3699 v.act( incidence, this );
3692 } 3700 }
3693} 3701}
3694void CalendarView::editIncidenceDescription() 3702void CalendarView::editIncidenceDescription()
3695{ 3703{
3696 mFlagEditDescription = true; 3704 mFlagEditDescription = true;
3697 editIncidence(); 3705 editIncidence();
3698 mFlagEditDescription = false; 3706 mFlagEditDescription = false;
3699} 3707}
3700void CalendarView::editIncidence() 3708void CalendarView::editIncidence()
3701{ 3709{
3702 // qDebug("editIncidence() "); 3710 // qDebug("editIncidence() ");
3703 Incidence *incidence = currentSelection(); 3711 Incidence *incidence = currentSelection();
3704 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3712 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3705 if ( incidence ) { 3713 if ( incidence ) {
3706 EditIncidenceVisitor v; 3714 EditIncidenceVisitor v;
3707 v.act( incidence, this ); 3715 v.act( incidence, this );
3708 } 3716 }
3709} 3717}
3710 3718
3711void CalendarView::deleteIncidence() 3719void CalendarView::deleteIncidence()
3712{ 3720{
3713 Incidence *incidence = currentSelection(); 3721 Incidence *incidence = currentSelection();
3714 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3722 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3715 if ( incidence ) { 3723 if ( incidence ) {
3716 deleteIncidence(incidence); 3724 deleteIncidence(incidence);
3717 } 3725 }
3718} 3726}
3719 3727
3720void CalendarView::showIncidence(Incidence *incidence) 3728void CalendarView::showIncidence(Incidence *incidence)
3721{ 3729{
3722 if ( incidence ) { 3730 if ( incidence ) {
3723 ShowIncidenceVisitor v; 3731 ShowIncidenceVisitor v;
3724 v.act( incidence, this ); 3732 v.act( incidence, this );
3725 } 3733 }
3726} 3734}
3727 3735
3728void CalendarView::editIncidence(Incidence *incidence) 3736void CalendarView::editIncidence(Incidence *incidence)
3729{ 3737{
3730 if ( incidence ) { 3738 if ( incidence ) {
3731 3739
3732 EditIncidenceVisitor v; 3740 EditIncidenceVisitor v;
3733 v.act( incidence, this ); 3741 v.act( incidence, this );
3734 3742
3735 } 3743 }
3736} 3744}
3737 3745
3738void CalendarView::deleteIncidence(Incidence *incidence) 3746void CalendarView::deleteIncidence(Incidence *incidence)
3739{ 3747{
3740 //qDebug(" CalendarView::deleteIncidence "); 3748 //qDebug(" CalendarView::deleteIncidence ");
3741 if ( incidence ) { 3749 if ( incidence ) {
3742 DeleteIncidenceVisitor v; 3750 DeleteIncidenceVisitor v;
3743 v.act( incidence, this ); 3751 v.act( incidence, this );
3744 } 3752 }
3745} 3753}
3746 3754
3747 3755
3748void CalendarView::lookForOutgoingMessages() 3756void CalendarView::lookForOutgoingMessages()
3749{ 3757{
3750 OutgoingDialog *ogd = mDialogManager->outgoingDialog(); 3758 OutgoingDialog *ogd = mDialogManager->outgoingDialog();
3751 ogd->loadMessages(); 3759 ogd->loadMessages();
3752} 3760}
3753 3761
3754void CalendarView::lookForIncomingMessages() 3762void CalendarView::lookForIncomingMessages()
3755{ 3763{
3756 IncomingDialog *icd = mDialogManager->incomingDialog(); 3764 IncomingDialog *icd = mDialogManager->incomingDialog();
3757 icd->retrieve(); 3765 icd->retrieve();
3758} 3766}
3759 3767
3760bool CalendarView::removeCompletedSubTodos( Todo* t ) 3768bool CalendarView::removeCompletedSubTodos( Todo* t )
3761{ 3769{
3762 bool deleteTodo = true; 3770 bool deleteTodo = true;
3763 QPtrList<Incidence> subTodos; 3771 QPtrList<Incidence> subTodos;
3764 Incidence *aTodo; 3772 Incidence *aTodo;
3765 subTodos = t->relations(); 3773 subTodos = t->relations();
3766 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { 3774 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
3767 if (! removeCompletedSubTodos( (Todo*) aTodo )) 3775 if (! removeCompletedSubTodos( (Todo*) aTodo ))
3768 deleteTodo = false; 3776 deleteTodo = false;
3769 } 3777 }
3770 if ( deleteTodo ) { 3778 if ( deleteTodo ) {
3771 if ( t->isCompleted() ) { 3779 if ( t->isCompleted() ) {
3772 checkExternalId( t ); 3780 checkExternalId( t );
3773 mCalendar->deleteTodo( t ); 3781 mCalendar->deleteTodo( t );
3774 changeTodoDisplay( t,KOGlobals::EVENTDELETED ); 3782 changeTodoDisplay( t,KOGlobals::EVENTDELETED );
3775 } 3783 }
3776 else 3784 else
3777 deleteTodo = false; 3785 deleteTodo = false;
3778 } 3786 }
3779 return deleteTodo; 3787 return deleteTodo;
3780 3788
3781} 3789}
3782void CalendarView::purgeCompleted() 3790void CalendarView::purgeCompleted()
3783{ 3791{
3784 int result = KMessageBox::warningContinueCancel(this, 3792 int result = KMessageBox::warningContinueCancel(this,
3785 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); 3793 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge"));
3786 3794
3787 if (result == KMessageBox::Continue) { 3795 if (result == KMessageBox::Continue) {
3788 3796
3789 QPtrList<Todo> todoCal; 3797 QPtrList<Todo> todoCal;
3790 QPtrList<Todo> rootTodos; 3798 QPtrList<Todo> rootTodos;
3791 //QPtrList<Incidence> rel; 3799 //QPtrList<Incidence> rel;
3792 Todo *aTodo;//, *rTodo; 3800 Todo *aTodo;//, *rTodo;
3793 Incidence *rIncidence; 3801 Incidence *rIncidence;
3794 bool childDelete = false; 3802 bool childDelete = false;
3795 bool deletedOne = true; 3803 bool deletedOne = true;
3796 todoCal = calendar()->todos(); 3804 todoCal = calendar()->todos();
3797 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { 3805 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
3798 if ( !aTodo->relatedTo() ) 3806 if ( !aTodo->relatedTo() )
3799 rootTodos.append( aTodo ); 3807 rootTodos.append( aTodo );
3800 } 3808 }
3801 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { 3809 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) {
3802 removeCompletedSubTodos( aTodo ); 3810 removeCompletedSubTodos( aTodo );
3803 } 3811 }
3804 3812
3805 updateView(); 3813 updateView();
3806 } 3814 }
3807} 3815}
3808 3816
3809void CalendarView::slotCalendarChanged() 3817void CalendarView::slotCalendarChanged()
3810{ 3818{
3811 ; 3819 ;
3812} 3820}
3813 3821
3814NavigatorBar *CalendarView::navigatorBar() 3822NavigatorBar *CalendarView::navigatorBar()
3815{ 3823{
3816 return mNavigatorBar; 3824 return mNavigatorBar;
3817} 3825}
3818 3826
3819 3827
3820 3828
3821void CalendarView::keyPressEvent ( QKeyEvent *e) 3829void CalendarView::keyPressEvent ( QKeyEvent *e)
3822{ 3830{
3823 //qDebug(" alendarView::keyPressEvent "); 3831 //qDebug(" alendarView::keyPressEvent ");
3824 e->ignore(); 3832 e->ignore();
3825} 3833}
3826 3834
3827 3835
3828bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) 3836bool CalendarView::sync(KSyncManager* manager, QString filename, int mode)
3829{ 3837{
3830 // mSyncManager = manager; 3838 // mSyncManager = manager;
3831 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { 3839 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) {
3832 qDebug("SyncKDE request detected!"); 3840 qDebug("SyncKDE request detected!");
3833 } 3841 }
3834 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 3842 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
3835 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 3843 mCurrentSyncName = mSyncManager->getCurrentSyncName();
3836 return syncCalendar( filename, mode ); 3844 return syncCalendar( filename, mode );
3837} 3845}
3838bool CalendarView::syncExternal(KSyncManager* manager, QString resource) 3846bool CalendarView::syncExternal(KSyncManager* manager, QString resource)
3839{ 3847{
3840 //mSyncManager = manager; 3848 //mSyncManager = manager;
3841 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 3849 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
3842 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 3850 mCurrentSyncName = mSyncManager->getCurrentSyncName();
3843 if ( resource == "sharp" ) 3851 if ( resource == "sharp" )
3844 syncExternal( 0 ); 3852 syncExternal( 0 );
3845 if ( resource == "phone" ) 3853 if ( resource == "phone" )
3846 syncExternal( 1 ); 3854 syncExternal( 1 );
3847 // pending setmodified 3855 // pending setmodified
3848 return true; 3856 return true;
3849} 3857}
3850void CalendarView::setSyncManager(KSyncManager* manager) 3858void CalendarView::setSyncManager(KSyncManager* manager)
3851{ 3859{
3852 mSyncManager = manager; 3860 mSyncManager = manager;
3853} 3861}
3854 3862
3855void CalendarView::removeSyncInfo( QString syncProfile) 3863void CalendarView::removeSyncInfo( QString syncProfile)
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index 646973d..e27da9a 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -99,510 +99,512 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
99 Calendar *calendar() { return mCalendar; } 99 Calendar *calendar() { return mCalendar; }
100 100
101 KOViewManager *viewManager(); 101 KOViewManager *viewManager();
102 KODialogManager *dialogManager(); 102 KODialogManager *dialogManager();
103 103
104 QDate startDate(); 104 QDate startDate();
105 QDate endDate(); 105 QDate endDate();
106 106
107 QWidgetStack *viewStack(); 107 QWidgetStack *viewStack();
108 QWidget *leftFrame(); 108 QWidget *leftFrame();
109 NavigatorBar *navigatorBar(); 109 NavigatorBar *navigatorBar();
110 110
111 DateNavigator *dateNavigator(); 111 DateNavigator *dateNavigator();
112 KDateNavigator *dateNavigatorWidget(); 112 KDateNavigator *dateNavigatorWidget();
113 113
114 void addView(KOrg::BaseView *); 114 void addView(KOrg::BaseView *);
115 void showView(KOrg::BaseView *); 115 void showView(KOrg::BaseView *);
116 KOEventViewerDialog* getEventViewerDialog(); 116 KOEventViewerDialog* getEventViewerDialog();
117 Incidence *currentSelection(); 117 Incidence *currentSelection();
118 118
119 signals: 119 signals:
120 void tempDisableBR(bool); 120 void tempDisableBR(bool);
121 /** This todo has been modified */ 121 /** This todo has been modified */
122 void todoModified(Todo *, int); 122 void todoModified(Todo *, int);
123 123
124 /** when change is made to options dialog, the topwidget will catch this 124 /** when change is made to options dialog, the topwidget will catch this
125 * and emit this signal which notifies all widgets which have registered 125 * and emit this signal which notifies all widgets which have registered
126 * for notification to update their settings. */ 126 * for notification to update their settings. */
127 void configChanged(); 127 void configChanged();
128 /** emitted when the topwidget is closing down, so that any attached 128 /** emitted when the topwidget is closing down, so that any attached
129 child windows can also close. */ 129 child windows can also close. */
130 void closingDown(); 130 void closingDown();
131 /** emitted right before we die */ 131 /** emitted right before we die */
132 void closed(QWidget *); 132 void closed(QWidget *);
133 133
134 /** Emitted when state of modified flag changes */ 134 /** Emitted when state of modified flag changes */
135 void modifiedChanged(bool); 135 void modifiedChanged(bool);
136 void signalmodified(); 136 void signalmodified();
137 137
138 /** Emitted when state of read-only flag changes */ 138 /** Emitted when state of read-only flag changes */
139 void readOnlyChanged(bool); 139 void readOnlyChanged(bool);
140 140
141 /** Emitted when the unit of navigation changes */ 141 /** Emitted when the unit of navigation changes */
142 void changeNavStringPrev(const QString &); 142 void changeNavStringPrev(const QString &);
143 void changeNavStringNext(const QString &); 143 void changeNavStringNext(const QString &);
144 144
145 /** Emitted when state of events selection has changed and user is organizer*/ 145 /** Emitted when state of events selection has changed and user is organizer*/
146 void organizerEventsSelected(bool); 146 void organizerEventsSelected(bool);
147 /** Emitted when state of events selection has changed and user is attendee*/ 147 /** Emitted when state of events selection has changed and user is attendee*/
148 void groupEventsSelected(bool); 148 void groupEventsSelected(bool);
149 /** 149 /**
150 Emitted when an incidence gets selected. If the selection is cleared the 150 Emitted when an incidence gets selected. If the selection is cleared the
151 signal is emitted with 0 as argument. 151 signal is emitted with 0 as argument.
152 */ 152 */
153 void incidenceSelected( Incidence * ); 153 void incidenceSelected( Incidence * );
154 /** Emitted, when a todoitem is selected or deselected. */ 154 /** Emitted, when a todoitem is selected or deselected. */
155 void todoSelected( bool ); 155 void todoSelected( bool );
156 156
157 /** 157 /**
158 Emitted, when clipboard content changes. Parameter indicates if paste 158 Emitted, when clipboard content changes. Parameter indicates if paste
159 is possible or not. 159 is possible or not.
160 */ 160 */
161 void pasteEnabled(bool); 161 void pasteEnabled(bool);
162 162
163 /** Emitted, when the number of incoming messages has changed. */ 163 /** Emitted, when the number of incoming messages has changed. */
164 void numIncomingChanged(int); 164 void numIncomingChanged(int);
165 165
166 /** Emitted, when the number of outgoing messages has changed. */ 166 /** Emitted, when the number of outgoing messages has changed. */
167 void numOutgoingChanged(int); 167 void numOutgoingChanged(int);
168 168
169 /** Send status message, which can e.g. be displayed in the status bar. */ 169 /** Send status message, which can e.g. be displayed in the status bar. */
170 void statusMessage(const QString &); 170 void statusMessage(const QString &);
171 171
172 void calendarViewExpanded( bool ); 172 void calendarViewExpanded( bool );
173 void updateSearchDialog(); 173 void updateSearchDialog();
174 174
175 175
176 public slots: 176 public slots:
177 void showOpenError(); 177 void showOpenError();
178 void watchSavedFile(); 178 void watchSavedFile();
179 void recheckTimerAlarm(); 179 void recheckTimerAlarm();
180 void checkNextTimerAlarm(); 180 void checkNextTimerAlarm();
181 void addAlarm(const QDateTime &qdt, const QString &noti ); 181 void addAlarm(const QDateTime &qdt, const QString &noti );
182 void addSuspendAlarm(const QDateTime &qdt, const QString &noti ); 182 void addSuspendAlarm(const QDateTime &qdt, const QString &noti );
183 void removeAlarm(const QDateTime &qdt, const QString &noti ); 183 void removeAlarm(const QDateTime &qdt, const QString &noti );
184 184
185 /** options dialog made a changed to the configuration. we catch this 185 /** options dialog made a changed to the configuration. we catch this
186 * and notify all widgets which need to update their configuration. */ 186 * and notify all widgets which need to update their configuration. */
187 void updateConfig(); 187 void updateConfig();
188 188
189 void insertBirthdays(const QString& uid, const QStringList& birthdayList, 189 void insertBirthdays(const QString& uid, const QStringList& birthdayList,
190 const QStringList& anniversaryList, const QStringList& realNameList, 190 const QStringList& anniversaryList, const QStringList& realNameList,
191 const QStringList& emailList, const QStringList& assembledNameList, 191 const QStringList& emailList, const QStringList& assembledNameList,
192 const QStringList& uidList); 192 const QStringList& uidList);
193 193
194 /** 194 /**
195 Load calendar from file \a filename. If \a merge is true, load 195 Load calendar from file \a filename. If \a merge is true, load
196 calendar into existing one, if it is false, clear calendar, before 196 calendar into existing one, if it is false, clear calendar, before
197 loading. Return true, if calendar could be successfully loaded. 197 loading. Return true, if calendar could be successfully loaded.
198 */ 198 */
199 bool openCalendar(QString filename, bool merge=false); 199 bool openCalendar(QString filename, bool merge=false);
200 bool syncCalendar(QString filename,int mode = 0 ); 200 bool syncCalendar(QString filename,int mode = 0 );
201 201
202 /** 202 /**
203 Save calendar data to file. Return true if calendar could be 203 Save calendar data to file. Return true if calendar could be
204 successfully saved. 204 successfully saved.
205 */ 205 */
206 bool saveCalendar(QString filename); 206 bool saveCalendar(QString filename);
207 207
208 /** 208 /**
209 Close calendar. Clear calendar data and reset views to display an empty 209 Close calendar. Clear calendar data and reset views to display an empty
210 calendar. 210 calendar.
211 */ 211 */
212 void closeCalendar(); 212 void closeCalendar();
213 213
214 /** Archive old events of calendar */ 214 /** Archive old events of calendar */
215 void archiveCalendar(); 215 void archiveCalendar();
216 216
217 void showIncidence(); 217 void showIncidence();
218 void editIncidence(); 218 void editIncidence();
219 void editIncidenceDescription(); 219 void editIncidenceDescription();
220 void deleteIncidence(); 220 void deleteIncidence();
221 void cloneIncidence(); 221 void cloneIncidence();
222 void moveIncidence(); 222 void moveIncidence();
223 void beamIncidence(); 223 void beamIncidence();
224 void toggleCancelIncidence(); 224 void toggleCancelIncidence();
225 225
226 /** create an editeventwin with supplied date/time, and if bool is true, 226 /** create an editeventwin with supplied date/time, and if bool is true,
227 * make the event take all day. */ 227 * make the event take all day. */
228 void newEvent(QDateTime, QDateTime, bool allDay = false); 228 void newEvent(QDateTime, QDateTime, bool allDay = false);
229 void newEvent(QDateTime fh); 229 void newEvent(QDateTime fh);
230 void newEvent(QDate dt); 230 void newEvent(QDate dt);
231 /** create new event without having a date hint. Takes current date as 231 /** create new event without having a date hint. Takes current date as
232 default hint. */ 232 default hint. */
233 void newEvent(); 233 void newEvent();
234 void newFloatingEvent(); 234 void newFloatingEvent();
235 235
236 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ 236 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/
237 void showIncidence(Incidence *); 237 void showIncidence(Incidence *);
238 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ 238 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/
239 void editIncidence(Incidence *); 239 void editIncidence(Incidence *);
240 /** Delete the supplied incidence. It calls the correct deleteXXX method*/ 240 /** Delete the supplied incidence. It calls the correct deleteXXX method*/
241 void deleteIncidence(Incidence *); 241 void deleteIncidence(Incidence *);
242 void cloneIncidence(Incidence *); 242 void cloneIncidence(Incidence *);
243 void cancelIncidence(Incidence *); 243 void cancelIncidence(Incidence *);
244 /** Create an editor for the supplied event. */ 244 /** Create an editor for the supplied event. */
245 void editEvent(Event *); 245 void editEvent(Event *);
246 /** Delete the supplied event. */ 246 /** Delete the supplied event. */
247 void deleteEvent(Event *); 247 void deleteEvent(Event *);
248 /** Delete the event with the given unique ID. Returns false, if event wasn't 248 /** Delete the event with the given unique ID. Returns false, if event wasn't
249 found. */ 249 found. */
250 bool deleteEvent(const QString &uid); 250 bool deleteEvent(const QString &uid);
251 /** Create a read-only viewer dialog for the supplied event. */ 251 /** Create a read-only viewer dialog for the supplied event. */
252 void showEvent(Event *); 252 void showEvent(Event *);
253 253
254 void editJournal(Journal *); 254 void editJournal(Journal *);
255 void showJournal(Journal *); 255 void showJournal(Journal *);
256 void deleteJournal(Journal *); 256 void deleteJournal(Journal *);
257 /** Create an editor dialog for a todo */ 257 /** Create an editor dialog for a todo */
258 void editTodo(Todo *); 258 void editTodo(Todo *);
259 /** Create a read-only viewer dialog for the supplied todo */ 259 /** Create a read-only viewer dialog for the supplied todo */
260 void showTodo(Todo *); 260 void showTodo(Todo *);
261 /** create new todo */ 261 /** create new todo */
262 void newTodo(); 262 void newTodo();
263 /** create new todo with a parent todo */ 263 /** create new todo with a parent todo */
264 void newSubTodo(); 264 void newSubTodo();
265 /** create new todo with a parent todo */ 265 /** create new todo with a parent todo */
266 void newSubTodo(Todo *); 266 void newSubTodo(Todo *);
267 /** Delete todo */ 267 /** Delete todo */
268 void deleteTodo(Todo *); 268 void deleteTodo(Todo *);
269 269
270 270
271 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is 271 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is
272 * emitted as result. */ 272 * emitted as result. */
273 void checkClipboard(); 273 void checkClipboard();
274 274
275 /** using the KConfig associated with the kapp variable, read in the 275 /** using the KConfig associated with the kapp variable, read in the
276 * settings from the config file. 276 * settings from the config file.
277 */ 277 */
278 void readSettings(); 278 void readSettings();
279 279
280 /** write current state to config file. */ 280 /** write current state to config file. */
281 void writeSettings(); 281 void writeSettings();
282 282
283 /** read settings for calendar filters */ 283 /** read settings for calendar filters */
284 void readFilterSettings(KConfig *config); 284 void readFilterSettings(KConfig *config);
285 285
286 /** write settings for calendar filters */ 286 /** write settings for calendar filters */
287 void writeFilterSettings(KConfig *config); 287 void writeFilterSettings(KConfig *config);
288 288
289 /** passes on the message that an event has changed to the currently 289 /** passes on the message that an event has changed to the currently
290 * activated view so that it can make appropriate display changes. */ 290 * activated view so that it can make appropriate display changes. */
291 void changeEventDisplay(Event *, int); 291 void changeEventDisplay(Event *, int);
292 void changeIncidenceDisplay(Incidence *, int); 292 void changeIncidenceDisplay(Incidence *, int);
293 void changeTodoDisplay(Todo *, int); 293 void changeTodoDisplay(Todo *, int);
294 294
295 void eventAdded(Event *); 295 void eventAdded(Event *);
296 void eventChanged(Event *); 296 void eventChanged(Event *);
297 void eventToBeDeleted(Event *); 297 void eventToBeDeleted(Event *);
298 void eventDeleted(); 298 void eventDeleted();
299 299
300 void todoAdded(Todo *); 300 void todoAdded(Todo *);
301 void todoChanged(Todo *); 301 void todoChanged(Todo *);
302 void todoToBeDeleted(Todo *); 302 void todoToBeDeleted(Todo *);
303 void todoDeleted(); 303 void todoDeleted();
304 304
305 void updateView(const QDate &start, const QDate &end); 305 void updateView(const QDate &start, const QDate &end);
306 void updateView(); 306 void updateView();
307 307
308 /** Full update of visible todo views */ 308 /** Full update of visible todo views */
309 void updateTodoViews(); 309 void updateTodoViews();
310 310
311 void updateUnmanagedViews(); 311 void updateUnmanagedViews();
312 312
313 /** cut the current appointment to the clipboard */ 313 /** cut the current appointment to the clipboard */
314 void edit_cut(); 314 void edit_cut();
315 315
316 /** copy the current appointment(s) to the clipboard */ 316 /** copy the current appointment(s) to the clipboard */
317 void edit_copy(); 317 void edit_copy();
318 318
319 /** paste the current vobject(s) in the clipboard buffer into calendar */ 319 /** paste the current vobject(s) in the clipboard buffer into calendar */
320 void edit_paste(); 320 void edit_paste();
321 321
322 /** edit viewing and configuration options. */ 322 /** edit viewing and configuration options. */
323 void edit_options(); 323 void edit_options();
324 /** 324 /**
325 Functions for printing, previewing a print, and setting up printing 325 Functions for printing, previewing a print, and setting up printing
326 parameters. 326 parameters.
327 */ 327 */
328 void print(); 328 void print();
329 void printSetup(); 329 void printSetup();
330 void printPreview(); 330 void printPreview();
331 331
332 /** Export as iCalendar file */ 332 /** Export as iCalendar file */
333 void exportICalendar(); 333 void exportICalendar();
334 334
335 /** Export as vCalendar file */ 335 /** Export as vCalendar file */
336 bool exportVCalendar( QString fn); 336 bool exportVCalendar( QString fn);
337 337
338 /** pop up a dialog to show an existing appointment. */ 338 /** pop up a dialog to show an existing appointment. */
339 void appointment_show(); 339 void appointment_show();
340 /** 340 /**
341 * pop up an Appointment Dialog to edit an existing appointment.Get 341 * pop up an Appointment Dialog to edit an existing appointment.Get
342 * information on the appointment from the list of unique IDs that is 342 * information on the appointment from the list of unique IDs that is
343 * currently in the View, called currIds. 343 * currently in the View, called currIds.
344 */ 344 */
345 void appointment_edit(); 345 void appointment_edit();
346 /** 346 /**
347 * pop up dialog confirming deletion of currently selected event in the 347 * pop up dialog confirming deletion of currently selected event in the
348 * View. 348 * View.
349 */ 349 */
350 void appointment_delete(); 350 void appointment_delete();
351 351
352 /** mails the currently selected event to a particular user as a vCalendar 352 /** mails the currently selected event to a particular user as a vCalendar
353 attachment. */ 353 attachment. */
354 void action_mail(); 354 void action_mail();
355 355
356 /* frees a subtodo from it's relation */ 356 /* frees a subtodo from it's relation */
357 void todo_unsub( Todo * ); 357 void todo_unsub( Todo * );
358 void todo_resub( Todo * parent, Todo * sub ); 358 void todo_resub( Todo * parent, Todo * sub );
359 359
360 /** Take ownership of selected event. */ 360 /** Take ownership of selected event. */
361 void takeOverEvent(); 361 void takeOverEvent();
362 362
363 /** Take ownership of all events in calendar. */ 363 /** Take ownership of all events in calendar. */
364 void takeOverCalendar(); 364 void takeOverCalendar();
365 365
366 /** query whether or not the calendar is "dirty". */ 366 /** query whether or not the calendar is "dirty". */
367 bool isModified(); 367 bool isModified();
368 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ 368 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */
369 void setModified(bool modified=true); 369 void setModified(bool modified=true);
370 370
371 /** query if the calendar is read-only. */ 371 /** query if the calendar is read-only. */
372 bool isReadOnly(); 372 bool isReadOnly();
373 /** set state of calendar to read-only */ 373 /** set state of calendar to read-only */
374 void setReadOnly(bool readOnly=true); 374 void setReadOnly(bool readOnly=true);
375 375
376 void eventUpdated(Incidence *); 376 void eventUpdated(Incidence *);
377 377
378 /* iTIP scheduling actions */ 378 /* iTIP scheduling actions */
379 void schedule_publish(Incidence *incidence = 0); 379 void schedule_publish(Incidence *incidence = 0);
380 void schedule_request(Incidence *incidence = 0); 380 void schedule_request(Incidence *incidence = 0);
381 void schedule_refresh(Incidence *incidence = 0); 381 void schedule_refresh(Incidence *incidence = 0);
382 void schedule_cancel(Incidence *incidence = 0); 382 void schedule_cancel(Incidence *incidence = 0);
383 void schedule_add(Incidence *incidence = 0); 383 void schedule_add(Incidence *incidence = 0);
384 void schedule_reply(Incidence *incidence = 0); 384 void schedule_reply(Incidence *incidence = 0);
385 void schedule_counter(Incidence *incidence = 0); 385 void schedule_counter(Incidence *incidence = 0);
386 void schedule_declinecounter(Incidence *incidence = 0); 386 void schedule_declinecounter(Incidence *incidence = 0);
387 void schedule_publish_freebusy(int daysToPublish = 30); 387 void schedule_publish_freebusy(int daysToPublish = 30);
388 388
389 void openAddressbook(); 389 void openAddressbook();
390 390
391 void editFilters(); 391 void editFilters();
392 void toggleFilerEnabled(); 392 void toggleFilerEnabled();
393 QPtrList<CalFilter> filters(); 393 QPtrList<CalFilter> filters();
394 void toggleFilter(); 394 void toggleFilter();
395 void showFilter(bool visible); 395 void showFilter(bool visible);
396 void updateFilter(); 396 void updateFilter();
397 void filterEdited(); 397 void filterEdited();
398 void selectFilter( int ); 398 void selectFilter( int );
399 KOFilterView *filterView(); 399 KOFilterView *filterView();
400 400
401 void showIntro(); 401 void showIntro();
402 402
403 /** Move the curdatepient view date to today */ 403 /** Move the curdatepient view date to today */
404 void goToday(); 404 void goToday();
405 405
406 /** Move to the next date(s) in the current view */ 406 /** Move to the next date(s) in the current view */
407 void goNext(); 407 void goNext();
408 408
409 /** Move to the previous date(s) in the current view */ 409 /** Move to the previous date(s) in the current view */
410 void goPrevious(); 410 void goPrevious();
411 /** Move to the next date(s) in the current view */ 411 /** Move to the next date(s) in the current view */
412 void goNextMonth(); 412 void goNextMonth();
413 413
414 /** Move to the previous date(s) in the current view */ 414 /** Move to the previous date(s) in the current view */
415 void goPreviousMonth(); 415 void goPreviousMonth();
416 416
417 void toggleExpand(); 417 void toggleExpand();
418 void toggleDateNavigatorWidget(); 418 void toggleDateNavigatorWidget();
419 void toggleAllDaySize(); 419 void toggleAllDaySize();
420 void dialogClosing(Incidence *); 420 void dialogClosing(Incidence *);
421 421
422 /** Look for new messages in the inbox */ 422 /** Look for new messages in the inbox */
423 void lookForIncomingMessages(); 423 void lookForIncomingMessages();
424 /** Look for new messages in the outbox */ 424 /** Look for new messages in the outbox */
425 void lookForOutgoingMessages(); 425 void lookForOutgoingMessages();
426 426
427 void processMainViewSelection( Incidence * ); 427 void processMainViewSelection( Incidence * );
428 void processTodoListSelection( Incidence * ); 428 void processTodoListSelection( Incidence * );
429 429
430 void processIncidenceSelection( Incidence * ); 430 void processIncidenceSelection( Incidence * );
431 431
432 void purgeCompleted(); 432 void purgeCompleted();
433 bool removeCompletedSubTodos( Todo* ); 433 bool removeCompletedSubTodos( Todo* );
434 void slotCalendarChanged(); 434 void slotCalendarChanged();
435 bool importBday(); 435 bool importBday();
436 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); 436 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday );
437 bool importQtopia( const QString &categoriesFile, 437 bool importQtopia( const QString &categoriesFile,
438 const QString &datebookFile, 438 const QString &datebookFile,
439 const QString &tasklistFile ); 439 const QString &tasklistFile );
440 void syncExternal( int mode ); 440 void syncExternal( int mode );
441 void slotSelectPickerDate( QDate ) ; 441 void slotSelectPickerDate( QDate ) ;
442 void showDatePicker( ) ; 442 void showDatePicker( ) ;
443 void moveIncidence(Incidence *) ; 443 void moveIncidence(Incidence *) ;
444 void beamIncidence(Incidence *) ; 444 void beamIncidence(Incidence *) ;
445 void beamCalendar() ; 445 void beamCalendar() ;
446 void beamFilteredCalendar() ; 446 void beamFilteredCalendar() ;
447 void beamIncidenceList(QPtrList<Incidence>) ; 447 void beamIncidenceList(QPtrList<Incidence>) ;
448 void manageCategories(); 448 void manageCategories();
449 int addCategories(); 449 int addCategories();
450 void removeCategories(); 450 void removeCategories();
451 void setSyncDevice( QString ); 451 void setSyncDevice( QString );
452 void setSyncName( QString ); 452 void setSyncName( QString );
453 void showDay( QDate ); 453 void showDay( QDate );
454 void undo_delete(); 454 void undo_delete();
455 protected slots: 455 protected slots:
456 void timerAlarm(); 456 void timerAlarm();
457 void suspendAlarm(); 457 void suspendAlarm();
458 void beamDone( Ir *ir ); 458 void beamDone( Ir *ir );
459 /** Select a view or adapt the current view to display the specified dates. */ 459 /** Select a view or adapt the current view to display the specified dates. */
460 void showDates( const KCal::DateList & ); 460 void showDates( const KCal::DateList & );
461 void selectWeekNum ( int ); 461 void selectWeekNum ( int );
462 462
463 public: 463 public:
464 // show a standard warning 464 // show a standard warning
465 // returns KMsgBox::yesNoCancel() 465 // returns KMsgBox::yesNoCancel()
466 int msgCalModified(); 466 int msgCalModified();
467 virtual bool sync(KSyncManager* manager, QString filename, int mode); 467 virtual bool sync(KSyncManager* manager, QString filename, int mode);
468 468
469 virtual bool syncExternal(KSyncManager* manager, QString resource); 469 virtual bool syncExternal(KSyncManager* manager, QString resource);
470 virtual void removeSyncInfo( QString syncProfile); 470 virtual void removeSyncInfo( QString syncProfile);
471 void setSyncManager(KSyncManager* manager); 471 void setSyncManager(KSyncManager* manager);
472 void setLoadedFileVersion(QDateTime); 472 void setLoadedFileVersion(QDateTime);
473 bool checkFileVersion(QString fn); 473 bool checkFileVersion(QString fn);
474 bool checkFileChanged(QString fn); 474 bool checkFileChanged(QString fn);
475 Event* getLastSyncEvent(); 475 Event* getLastSyncEvent();
476 /** Adapt navigation units correpsonding to step size of navigation of the 476 /** Adapt navigation units correpsonding to step size of navigation of the
477 * current view. 477 * current view.
478 */ 478 */
479 void adaptNavigationUnits(); 479 void adaptNavigationUnits();
480 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); 480 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode );
481 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); 481 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false );
482 //Attendee* getYourAttendee(Event *event); 482 //Attendee* getYourAttendee(Event *event);
483 void setBlockShowDates( bool b ) { mBlockShowDates = b ;}
483 protected: 484 protected:
484 void schedule(Scheduler::Method, Incidence *incidence = 0); 485 void schedule(Scheduler::Method, Incidence *incidence = 0);
485 486
486 // returns KMsgBox::OKCandel() 487 // returns KMsgBox::OKCandel()
487 int msgItemDelete(); 488 int msgItemDelete();
488 void showEventEditor(); 489 void showEventEditor();
489 void showTodoEditor(); 490 void showTodoEditor();
490 void writeLocale(); 491 void writeLocale();
491 Todo *selectedTodo(); 492 Todo *selectedTodo();
492 493
493 private: 494 private:
495 bool mBlockShowDates;
494 KSyncManager* mSyncManager; 496 KSyncManager* mSyncManager;
495 AlarmDialog * mAlarmDialog; 497 AlarmDialog * mAlarmDialog;
496 QString mAlarmNotification; 498 QString mAlarmNotification;
497 QString mSuspendAlarmNotification; 499 QString mSuspendAlarmNotification;
498 QTimer* mSuspendTimer; 500 QTimer* mSuspendTimer;
499 QTimer* mAlarmTimer; 501 QTimer* mAlarmTimer;
500 QTimer* mRecheckAlarmTimer; 502 QTimer* mRecheckAlarmTimer;
501 void computeAlarm( QString ); 503 void computeAlarm( QString );
502 void startAlarm( QString, QString ); 504 void startAlarm( QString, QString );
503 void setSyncEventsReadOnly(); 505 void setSyncEventsReadOnly();
504 506
505 QDateTime loadedFileVersion; 507 QDateTime loadedFileVersion;
506 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); 508 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete );
507 void checkExternalId( Incidence * inc ); 509 void checkExternalId( Incidence * inc );
508 int mGlobalSyncMode; 510 int mGlobalSyncMode;
509 QString mCurrentSyncDevice; 511 QString mCurrentSyncDevice;
510 QString mCurrentSyncName; 512 QString mCurrentSyncName;
511 KOBeamPrefs* beamDialog; 513 KOBeamPrefs* beamDialog;
512 void init(); 514 void init();
513 int mDatePickerMode; 515 int mDatePickerMode;
514 bool mFlagEditDescription; 516 bool mFlagEditDescription;
515 QDateTime mLastCalendarSync; 517 QDateTime mLastCalendarSync;
516 void createPrinter(); 518 void createPrinter();
517 519
518 void calendarModified( bool, Calendar * ); 520 void calendarModified( bool, Calendar * );
519 521
520 CalPrinter *mCalPrinter; 522 CalPrinter *mCalPrinter;
521 523
522 QSplitter *mPanner; 524 QSplitter *mPanner;
523 QSplitter *mLeftSplitter; 525 QSplitter *mLeftSplitter;
524 QWidget *mLeftFrame; 526 QWidget *mLeftFrame;
525 QWidgetStack *mRightFrame; 527 QWidgetStack *mRightFrame;
526 528
527 KDatePicker* mDatePicker; 529 KDatePicker* mDatePicker;
528 QVBox* mDateFrame; 530 QVBox* mDateFrame;
529 NavigatorBar *mNavigatorBar; 531 NavigatorBar *mNavigatorBar;
530 532
531 KDateNavigator *mDateNavigator; // widget showing small month view. 533 KDateNavigator *mDateNavigator; // widget showing small month view.
532 534
533 KOFilterView *mFilterView; 535 KOFilterView *mFilterView;
534 536
535 ResourceView *mResourceView; 537 ResourceView *mResourceView;
536 538
537 // calendar object for this viewing instance 539 // calendar object for this viewing instance
538 Calendar *mCalendar; 540 Calendar *mCalendar;
539 541
540 CalendarResourceManager *mResourceManager; 542 CalendarResourceManager *mResourceManager;
541 543
542 FileStorage *mStorage; 544 FileStorage *mStorage;
543 545
544 DateNavigator *mNavigator; 546 DateNavigator *mNavigator;
545 547
546 KOViewManager *mViewManager; 548 KOViewManager *mViewManager;
547 KODialogManager *mDialogManager; 549 KODialogManager *mDialogManager;
548 550
549 // Calendar filters 551 // Calendar filters
550 QPtrList<CalFilter> mFilters; 552 QPtrList<CalFilter> mFilters;
551 553
552 // various housekeeping variables. 554 // various housekeeping variables.
553 bool mModified; // flag indicating if calendar is modified 555 bool mModified; // flag indicating if calendar is modified
554 bool mReadOnly; // flag indicating if calendar is read-only 556 bool mReadOnly; // flag indicating if calendar is read-only
555 QDate mSaveSingleDate; 557 QDate mSaveSingleDate;
556 558
557 Incidence *mSelectedIncidence; 559 Incidence *mSelectedIncidence;
558 Incidence *mMoveIncidence; 560 Incidence *mMoveIncidence;
559 QDate mMoveIncidenceOldDate; 561 QDate mMoveIncidenceOldDate;
560 KOTodoView *mTodoList; 562 KOTodoView *mTodoList;
561 KOEventEditor * mEventEditor; 563 KOEventEditor * mEventEditor;
562 KOTodoEditor * mTodoEditor; 564 KOTodoEditor * mTodoEditor;
563 KOEventViewerDialog * mEventViewerDialog; 565 KOEventViewerDialog * mEventViewerDialog;
564 void keyPressEvent ( QKeyEvent *e) ; 566 void keyPressEvent ( QKeyEvent *e) ;
565 //QMap<Incidence*,KOIncidenceEditor*> mDialogList; 567 //QMap<Incidence*,KOIncidenceEditor*> mDialogList;
566}; 568};
567 569
568 570
569class CalendarViewVisitor : public Incidence::Visitor 571class CalendarViewVisitor : public Incidence::Visitor
570{ 572{
571 public: 573 public:
572 CalendarViewVisitor() : mView( 0 ) {} 574 CalendarViewVisitor() : mView( 0 ) {}
573 575
574 bool act( Incidence *incidence, CalendarView *view ) 576 bool act( Incidence *incidence, CalendarView *view )
575 { 577 {
576 mView = view; 578 mView = view;
577 return incidence->accept( *this ); 579 return incidence->accept( *this );
578 } 580 }
579 581
580 protected: 582 protected:
581 CalendarView *mView; 583 CalendarView *mView;
582}; 584};
583 585
584class ShowIncidenceVisitor : public CalendarViewVisitor 586class ShowIncidenceVisitor : public CalendarViewVisitor
585{ 587{
586 protected: 588 protected:
587 bool visit( Event *event ) { mView->showEvent( event ); return true; } 589 bool visit( Event *event ) { mView->showEvent( event ); return true; }
588 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } 590 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; }
589 bool visit( Journal * j ) { mView->showJournal( j );return true; } 591 bool visit( Journal * j ) { mView->showJournal( j );return true; }
590}; 592};
591 593
592class EditIncidenceVisitor : public CalendarViewVisitor 594class EditIncidenceVisitor : public CalendarViewVisitor
593{ 595{
594 protected: 596 protected:
595 bool visit( Event *event ) { mView->editEvent( event ); return true; } 597 bool visit( Event *event ) { mView->editEvent( event ); return true; }
596 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } 598 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; }
597 bool visit( Journal *j ) { mView->editJournal( j); return true; } 599 bool visit( Journal *j ) { mView->editJournal( j); return true; }
598}; 600};
599 601
600class DeleteIncidenceVisitor : public CalendarViewVisitor 602class DeleteIncidenceVisitor : public CalendarViewVisitor
601{ 603{
602 protected: 604 protected:
603 bool visit( Event *event ) { mView->deleteEvent( event ); return true; } 605 bool visit( Event *event ) { mView->deleteEvent( event ); return true; }
604 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } 606 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; }
605 bool visit( Journal * j) {mView->deleteJournal( j ); return true; } 607 bool visit( Journal * j) {mView->deleteJournal( j ); return true; }
606}; 608};
607 609
608#endif 610#endif
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 9344567..842f6eb 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -1,1092 +1,1115 @@
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 19
20#include <qpopupmenu.h> 20#include <qpopupmenu.h>
21#include <qfont.h> 21#include <qfont.h>
22#include <qfontmetrics.h> 22#include <qfontmetrics.h>
23#include <qkeycode.h> 23#include <qkeycode.h>
24#include <qhbox.h> 24#include <qhbox.h>
25#include <qvbox.h> 25#include <qvbox.h>
26#include <qpushbutton.h> 26#include <qpushbutton.h>
27#include <qtooltip.h> 27#include <qtooltip.h>
28#include <qpainter.h> 28#include <qpainter.h>
29#include <qwhatsthis.h> 29#include <qwhatsthis.h>
30#ifndef DESKTOP_VERSION 30#ifndef DESKTOP_VERSION
31#include <qpe/qpeapplication.h> 31#include <qpe/qpeapplication.h>
32#else 32#else
33#include <qapplication.h> 33#include <qapplication.h>
34#endif 34#endif
35 35
36#include <kdebug.h> 36#include <kdebug.h>
37#include <klocale.h> 37#include <klocale.h>
38#include <kglobal.h> 38#include <kglobal.h>
39#include <kconfig.h> 39#include <kconfig.h>
40#include <kiconloader.h> 40#include <kiconloader.h>
41 41
42#include <kcalendarsystem.h> 42#include <kcalendarsystem.h>
43 43
44#ifndef KORG_NOPRINTER 44#ifndef KORG_NOPRINTER
45#include "calprinter.h" 45#include "calprinter.h"
46#endif 46#endif
47#include "koprefs.h" 47#include "koprefs.h"
48#ifndef KORG_NOPLUGINS 48#ifndef KORG_NOPLUGINS
49#include "kocore.h" 49#include "kocore.h"
50#endif 50#endif
51#include "koglobals.h" 51#include "koglobals.h"
52#include <libkcal/kincidenceformatter.h> 52#include <libkcal/kincidenceformatter.h>
53 53
54#include "komonthview.h" 54#include "komonthview.h"
55 55
56#define PIXMAP_SIZE 5 56#define PIXMAP_SIZE 5
57#ifdef DESKTOP_VERSION 57#ifdef DESKTOP_VERSION
58 QToolTipGroup *MonthViewCell::mToolTipGroup = 0; 58 QToolTipGroup *MonthViewCell::mToolTipGroup = 0;
59#endif 59#endif
60class KNOWhatsThis :public QWhatsThis 60class KNOWhatsThis :public QWhatsThis
61{ 61{
62public: 62public:
63 KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; 63 KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { };
64 64
65protected: 65protected:
66 virtual QString text( const QPoint& p) 66 virtual QString text( const QPoint& p)
67 { 67 {
68 return _wid->getWhatsThisText(p) ; 68 return _wid->getWhatsThisText(p) ;
69 }; 69 };
70private: 70private:
71 KNoScrollListBox* _wid; 71 KNoScrollListBox* _wid;
72 72
73}; 73};
74 74
75 75
76KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) 76KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name)
77 : QListBox(parent, name) 77 : QListBox(parent, name)
78{ 78{
79#ifndef DESKTOP_VERSION 79#ifndef DESKTOP_VERSION
80 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 80 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
81#endif 81#endif
82 new KNOWhatsThis(this); 82 mWT = new KNOWhatsThis(this);
83}
84KNoScrollListBox::~KNoScrollListBox()
85{
86 delete mWT;
83} 87}
84
85QString KNoScrollListBox::getWhatsThisText(QPoint p) 88QString KNoScrollListBox::getWhatsThisText(QPoint p)
86{ 89{
87 QListBoxItem* item = itemAt ( p ); 90 QListBoxItem* item = itemAt ( p );
88 if ( ! item ) { 91 if ( ! item ) {
89 return i18n("Click in the cell\nto add an event!"); 92 return i18n("Click in the cell\nto add an event!");
90 } 93 }
91 return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence()); 94 return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence());
92} 95}
93void KNoScrollListBox::keyPressEvent(QKeyEvent *e) 96void KNoScrollListBox::keyPressEvent(QKeyEvent *e)
94{ 97{
95 98
96 switch(e->key()) { 99 switch(e->key()) {
97 case Key_Right: 100 case Key_Right:
98 // if ( e->state() == Qt::ControlButton ) 101 // if ( e->state() == Qt::ControlButton )
99 { 102 {
100 e->ignore(); 103 e->ignore();
101 return; 104 return;
102 } 105 }
103 scrollBy(4,0); 106 scrollBy(4,0);
104 break; 107 break;
105 case Key_Left: 108 case Key_Left:
106 // if ( e->state() == Qt::ControlButton ) 109 // if ( e->state() == Qt::ControlButton )
107 { 110 {
108 e->ignore(); 111 e->ignore();
109 return; 112 return;
110 } 113 }
111 scrollBy(-4,0); 114 scrollBy(-4,0);
112 break; 115 break;
113 case Key_Up: 116 case Key_Up:
114 if(!count()) break; 117 if(!count()) break;
115 setCurrentItem((currentItem()+count()-1)%count()); 118 setCurrentItem((currentItem()+count()-1)%count());
116 if(!itemVisible(currentItem())) { 119 if(!itemVisible(currentItem())) {
117 if((unsigned int) currentItem() == (count()-1)) { 120 if((unsigned int) currentItem() == (count()-1)) {
118 setTopItem(currentItem()-numItemsVisible()+1); 121 setTopItem(currentItem()-numItemsVisible()+1);
119 } else { 122 } else {
120 setTopItem(topItem()-1); 123 setTopItem(topItem()-1);
121 } 124 }
122 } 125 }
123 break; 126 break;
124 case Key_Down: 127 case Key_Down:
125 if(!count()) break; 128 if(!count()) break;
126 setCurrentItem((currentItem()+1)%count()); 129 setCurrentItem((currentItem()+1)%count());
127 if(!itemVisible(currentItem())) { 130 if(!itemVisible(currentItem())) {
128 if(currentItem() == 0) { 131 if(currentItem() == 0) {
129 setTopItem(0); 132 setTopItem(0);
130 } else { 133 } else {
131 setTopItem(topItem()+1); 134 setTopItem(topItem()+1);
132 } 135 }
133 } 136 }
134 break; 137 break;
135 case Key_Shift: 138 case Key_Shift:
136 emit shiftDown(); 139 emit shiftDown();
137 break; 140 break;
138 default: 141 default:
139 e->ignore(); 142 e->ignore();
140 break; 143 break;
141 } 144 }
142} 145}
143 146
144void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) 147void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e)
145{ 148{
146 switch(e->key()) { 149 switch(e->key()) {
147 case Key_Shift: 150 case Key_Shift:
148 emit shiftUp(); 151 emit shiftUp();
149 break; 152 break;
150 default: 153 default:
151 break; 154 break;
152 } 155 }
153} 156}
154 157
155void KNoScrollListBox::mousePressEvent(QMouseEvent *e) 158void KNoScrollListBox::mousePressEvent(QMouseEvent *e)
156{ 159{
157 QListBox::mousePressEvent(e); 160 QListBox::mousePressEvent(e);
158 161
159 if(e->button() == RightButton) { 162 if(e->button() == RightButton) {
160 emit rightClick(); 163 emit rightClick();
161 } 164 }
162} 165}
163 166
164MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) 167MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s)
165 : QListBoxItem() 168 : QListBoxItem()
166{ 169{
167 setText( s ); 170 setText( s );
168 171
169 mIncidence = incidence; 172 mIncidence = incidence;
170 mDate = qd; 173 mDate = qd;
171 // QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence )); 174 // QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence ));
172 mRecur = false; 175 mRecur = false;
173 mAlarm = false; 176 mAlarm = false;
174 mReply = false; 177 mReply = false;
175 mInfo = false; 178 mInfo = false;
176} 179}
177 180
178void MonthViewItem::paint(QPainter *p) 181void MonthViewItem::paint(QPainter *p)
179{ 182{
180#if QT_VERSION >= 0x030000 183#if QT_VERSION >= 0x030000
181 bool sel = isSelected(); 184 bool sel = isSelected();
182#else 185#else
183 bool sel = selected(); 186 bool sel = selected();
184#endif 187#endif
185 188
186 189
187 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) 190 if (KOPrefs::instance()->mMonthViewUsesCategoryColor)
188 { 191 {
189 p->setBackgroundColor( palette().color( QPalette::Normal, \ 192 p->setBackgroundColor( palette().color( QPalette::Normal, \
190 sel ? QColorGroup::Highlight : QColorGroup::Background ) ); 193 sel ? QColorGroup::Highlight : QColorGroup::Background ) );
191 p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); 194 p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) );
192 } 195 }
193 int x = 1; 196 int x = 1;
194 int y = 3;//(height() - mRecurPixmap.height()) /2; 197 int y = 3;//(height() - mRecurPixmap.height()) /2;
195 int size = PIXMAP_SIZE; 198 int size = PIXMAP_SIZE;
196 if ( QApplication::desktop()->width() < 300 ) 199 if ( QApplication::desktop()->width() < 300 )
197 size = 3; 200 size = 3;
198 if ( KOPrefs::instance()->mMonthShowIcons ) { 201 if ( KOPrefs::instance()->mMonthShowIcons ) {
199 if ( mInfo ) { 202 if ( mInfo ) {
200 p->fillRect ( x, y,size,size, Qt::darkGreen ); 203 p->fillRect ( x, y,size,size, Qt::darkGreen );
201 x += size + 1; 204 x += size + 1;
202 } 205 }
203 if ( mRecur ) { 206 if ( mRecur ) {
204 p->fillRect ( x, y,size,size, Qt::blue ); 207 p->fillRect ( x, y,size,size, Qt::blue );
205 x += size + 1; 208 x += size + 1;
206 } 209 }
207 if ( mAlarm ) { 210 if ( mAlarm ) {
208 p->fillRect ( x, y,size,size, Qt::red ); 211 p->fillRect ( x, y,size,size, Qt::red );
209 x += size + 1; 212 x += size + 1;
210 } 213 }
211 if ( mReply ) { 214 if ( mReply ) {
212 p->fillRect ( x, y,size,size, Qt::yellow ); 215 p->fillRect ( x, y,size,size, Qt::yellow );
213 x += size + 1; 216 x += size + 1;
214 } 217 }
215 } 218 }
216 QFontMetrics fm = p->fontMetrics(); 219 QFontMetrics fm = p->fontMetrics();
217 int yPos; 220 int yPos;
218 int pmheight = size; 221 int pmheight = size;
219 if( pmheight < fm.height() ) 222 if( pmheight < fm.height() )
220 yPos = fm.ascent() + fm.leading()/2; 223 yPos = fm.ascent() + fm.leading()/2;
221 else 224 else
222 yPos = pmheight/2 - fm.height()/2 + fm.ascent(); 225 yPos = pmheight/2 - fm.height()/2 + fm.ascent();
223 p->setPen( palette().color( QPalette::Normal, sel ? \ 226 p->setPen( palette().color( QPalette::Normal, sel ? \
224 QColorGroup::HighlightedText : QColorGroup::Foreground ) ); 227 QColorGroup::HighlightedText : QColorGroup::Foreground ) );
225 p->drawText( x, yPos, text() ); 228 p->drawText( x, yPos, text() );
226 if ( mIncidence->cancelled() ) { 229 if ( mIncidence->cancelled() ) {
227 int wid = fm.width( text() ); 230 int wid = fm.width( text() );
228 p->drawLine( x, yPos- fm.height()/2+2,x+wid, yPos- fm.height()/2 +2); 231 p->drawLine( x, yPos- fm.height()/2+2,x+wid, yPos- fm.height()/2 +2);
229 } 232 }
230 233
231} 234}
232 235
233int MonthViewItem::height(const QListBox *lb) const 236int MonthViewItem::height(const QListBox *lb) const
234{ 237{
235 return lb->fontMetrics().lineSpacing()+1; 238 return lb->fontMetrics().lineSpacing()+1;
236} 239}
237 240
238int MonthViewItem::width(const QListBox *lb) const 241int MonthViewItem::width(const QListBox *lb) const
239{ 242{
240 int size = PIXMAP_SIZE; 243 int size = PIXMAP_SIZE;
241 if ( QApplication::desktop()->width() < 300 ) 244 if ( QApplication::desktop()->width() < 300 )
242 size = 3; 245 size = 3;
243 int x = 1; 246 int x = 1;
244 if ( mInfo ) { 247 if ( mInfo ) {
245 x += size + 1; 248 x += size + 1;
246 } 249 }
247 if( mRecur ) { 250 if( mRecur ) {
248 x += size+1; 251 x += size+1;
249 } 252 }
250 if( mAlarm ) { 253 if( mAlarm ) {
251 x += size+1; 254 x += size+1;
252 } 255 }
253 if( mReply ) { 256 if( mReply ) {
254 x += size+1; 257 x += size+1;
255 } 258 }
256 259
257 return( x + lb->fontMetrics().width( text() ) + 1 ); 260 return( x + lb->fontMetrics().width( text() ) + 1 );
258} 261}
259 262
260 263
261MonthViewCell::MonthViewCell( KOMonthView *parent) 264MonthViewCell::MonthViewCell( KOMonthView *parent)
262 : QWidget( parent ), 265 : QWidget( parent ),
263 mMonthView( parent ) 266 mMonthView( parent )
264{ 267{
265 268
266 QVBoxLayout *topLayout = new QVBoxLayout( this ); 269 QVBoxLayout *topLayout = new QVBoxLayout( this );
267 270
268 // mLabel = new QLabel( this );QPushButton 271 // mLabel = new QLabel( this );QPushButton
269 mLabel = new QPushButton( this ); 272 mLabel = new QPushButton( this );
270 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); 273 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain );
271 //mLabel->setLineWidth( 1 ); 274 //mLabel->setLineWidth( 1 );
272 //mLabel->setAlignment( AlignCenter ); 275 //mLabel->setAlignment( AlignCenter );
273 mLabel->setFlat( true ); 276 mLabel->setFlat( true );
274 mItemList = new KNoScrollListBox( this ); 277 mItemList = new KNoScrollListBox( this );
275 mItemList->setMinimumSize( 10, 10 ); 278 mItemList->setMinimumSize( 10, 10 );
276 mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain ); 279 mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain );
277 mItemList->setLineWidth( 1 ); 280 mItemList->setLineWidth( 1 );
278 topLayout->addWidget( mItemList ); 281 topLayout->addWidget( mItemList );
279 mLabel->raise(); 282 mLabel->raise();
280 // QColor( 0,0,255 ) QColor( 160,1600,255 ) 283 // QColor( 0,0,255 ) QColor( 160,1600,255 )
281 mStandardPalette = palette(); 284 mStandardPalette = palette();
282 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); 285 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) );
283 286
284 enableScrollBars( false ); 287 enableScrollBars( false );
285 updateConfig(); 288 updateConfig();
286 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); 289 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() ));
287 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); 290 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() ));
288 connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ), 291 connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ),
289 SLOT( defaultAction( QListBoxItem * ) ) ); 292 SLOT( defaultAction( QListBoxItem * ) ) );
290 connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *, 293 connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *,
291 const QPoint &) ), 294 const QPoint &) ),
292 SLOT( contextMenu( QListBoxItem * ) ) ); 295 SLOT( contextMenu( QListBoxItem * ) ) );
293 connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ), 296 connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ),
294 SLOT( selection( QListBoxItem * ) ) ); 297 SLOT( selection( QListBoxItem * ) ) );
295 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), 298 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ),
296 SLOT( cellClicked( QListBoxItem * ) ) ); 299 SLOT( cellClicked( QListBoxItem * ) ) );
297 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), 300 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ),
298 SLOT( selection( QListBoxItem * ) ) ); 301 SLOT( selection( QListBoxItem * ) ) );
299} 302}
300#ifdef DESKTOP_VERSION 303#ifdef DESKTOP_VERSION
301QToolTipGroup *MonthViewCell::toolTipGroup() 304QToolTipGroup *MonthViewCell::toolTipGroup()
302{ 305{
303 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); 306 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0);
304 return mToolTipGroup; 307 return mToolTipGroup;
305} 308}
306#endif 309#endif
307 310
308void MonthViewCell::setDate( const QDate &date ) 311void MonthViewCell::setDate( const QDate &date )
309{ 312{
310// kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; 313// kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl;
311
312 mDate = date; 314 mDate = date;
313 315
314 QString text; 316
315 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog;
316 if ( KOGlobals::self()->calendarSystem()->day( date ) == 1 || (date.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) {
317 text = KOGlobals::self()->calendarSystem()->monthName( date, true ) + " ";
318 mLabel->resize( mLabelBigSize );
319 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
320 } else {
321 mLabel->resize( mLabelSize );
322 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
323 }
324 mLabel->setText( text );
325 317
326 //resizeEvent( 0 ); 318 //resizeEvent( 0 );
327} 319}
328 320
329QDate MonthViewCell::date() const 321QDate MonthViewCell::date() const
330{ 322{
331 return mDate; 323 return mDate;
332} 324}
333 325
334void MonthViewCell::setPrimary( bool primary ) 326void MonthViewCell::setPrimary( bool primary )
335{ 327{
336 mPrimary = primary; 328 mPrimary = primary;
337 //setMyPalette(); 329 //setMyPalette();
338} 330}
339void MonthViewCell::setMyPalette() 331void MonthViewCell::setMyPalette()
340{ 332{
341 333
342 if ( mHoliday) { 334 if ( mHoliday) {
343 setPalette( mHolidayPalette ); 335 setPalette( mHolidayPalette );
344 } else { 336 } else {
345 if ( mPrimary ) { 337 if ( mPrimary ) {
346 setPalette( mPrimaryPalette ); 338 setPalette( mPrimaryPalette );
347 } else { 339 } else {
348 setPalette( mNonPrimaryPalette ); 340 setPalette( mNonPrimaryPalette );
349 } 341 }
350 } 342 }
351 QPalette pal = palette(); 343 QPalette pal = palette();
352 344
353 mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); 345 mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) ));
354} 346}
355QPalette MonthViewCell::getPalette () 347QPalette MonthViewCell::getPalette ()
356{ 348{
357 if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) 349 if ( !KOPrefs::instance()->mMonthViewUsesDayColors )
358 return mStandardPalette; 350 return mStandardPalette;
359 if ( mHoliday) { 351 if ( mHoliday) {
360 return mHolidayPalette ; 352 return mHolidayPalette ;
361 } else { 353 } else {
362 if ( mPrimary ) { 354 if ( mPrimary ) {
363 return mPrimaryPalette ; 355 return mPrimaryPalette ;
364 } 356 }
365 } 357 }
366 return mNonPrimaryPalette; 358 return mNonPrimaryPalette;
367} 359}
368bool MonthViewCell::isPrimary() const 360bool MonthViewCell::isPrimary() const
369{ 361{
370 return mPrimary; 362 return mPrimary;
371} 363}
372 364
373void MonthViewCell::setHoliday( bool holiday ) 365void MonthViewCell::setHoliday( bool holiday )
374{ 366{
375 mHoliday = holiday; 367 mHoliday = holiday;
376 //setMyPalette(); 368 //setMyPalette();
377} 369}
378 370
379void MonthViewCell::setHoliday( const QString &holiday ) 371void MonthViewCell::setHoliday( const QString &holiday )
380{ 372{
381 mHolidayString = holiday; 373 mHolidayString = holiday;
382 374
383 if ( !holiday.isEmpty() ) { 375 if ( !holiday.isEmpty() ) {
384 setHoliday( true ); 376 setHoliday( true );
385 } 377 }
386} 378}
387void MonthViewCell::keyPressEvent ( QKeyEvent * e ) 379void MonthViewCell::keyPressEvent ( QKeyEvent * e )
388{ 380{
389 381
390 e->ignore(); 382 e->ignore();
391 383
392} 384}
393void MonthViewCell::updateCell() 385void MonthViewCell::updateCell()
394{ 386{
395 387 if ( !mMonthView->isUpdatePossible() )
388 return;
389 if ( !isVisible() ){
390 return;
391 }
396 setPrimary( mDate.month()%2 ); 392 setPrimary( mDate.month()%2 );
397 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); 393 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays);
398 if ( mDate == QDate::currentDate() ) { 394 if ( mDate == QDate::currentDate() ) {
399 mItemList->setLineWidth( 3 ); 395 mItemList->setLineWidth( 3 );
400 } else { 396 } else {
401 mItemList->setLineWidth( 1 ); 397 mItemList->setLineWidth( 1 );
402 } 398 }
403 mItemList->clear(); 399 mItemList->clear();
400
401
402
404#ifdef DESKTOP_VERSION 403#ifdef DESKTOP_VERSION
405 QToolTip::remove(this); 404 QToolTip::remove(this);
406#endif 405#endif
407 QString tipText(""); 406 QString tipText("");
408 //qApp->processEvents(); 407 //qApp->processEvents();
409 if ( !mHolidayString.isEmpty() ) { 408 if ( !mHolidayString.isEmpty() ) {
410 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); 409 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString );
411 item->setPalette( mHolidayPalette ); 410 item->setPalette( mHolidayPalette );
412 mItemList->insertItem( item ); 411 mItemList->insertItem( item );
413 tipText += mHolidayString+"\n"; 412 tipText += mHolidayString+"\n";
414 } 413 }
415 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 414 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
416 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); 415 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true );
417 Event *event; 416 Event *event;
418 for( event = events.first(); event; event = events.next() ) { 417 for( event = events.first(); event; event = events.next() ) { // for event
418
419 if ( !(event->doesRecur() == Recurrence::rNone) ) {
420 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily )
421 continue;
422 else
423 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly )
424 continue;
425 }
426
419 if ( event->categories().contains("Holiday") || 427 if ( event->categories().contains("Holiday") ||
420 event->categories().contains(i18n("Holiday"))) { 428 event->categories().contains(i18n("Holiday"))) {
421 setHoliday( true ); 429 setHoliday( true );
422 if ( mDate.dayOfWeek() == 7 ) 430 if ( mDate.dayOfWeek() == 7 )
423 mItemList->setLineWidth( 3 ); 431 mItemList->setLineWidth( 3 );
424 } 432 }
425 QString text; 433 QString text;
426 if (event->isMultiDay()) { 434 if (event->isMultiDay()) {
427 QString prefix = "<->"; 435 QString prefix = "<->";
428 if ( event->doesRecur() ) { 436 if ( event->doesRecur() ) {
429 if ( event->recursOn( mDate) ) 437 if ( event->recursOn( mDate) )
430 prefix ="->" ; 438 prefix ="->" ;
431 else { 439 else {
432 int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); 440 int days = event->dtStart().date().daysTo ( event->dtEnd().date() );
433 if ( event->recursOn( mDate.addDays( -days)) ) 441 if ( event->recursOn( mDate.addDays( -days)) )
434 prefix ="<-" ; 442 prefix ="<-" ;
435 } 443 }
436 444
437 } else { 445 } else {
438 if (mDate == event->dtStart().date()) { 446 if (mDate == event->dtStart().date()) {
439 prefix ="->" ; 447 prefix ="->" ;
440 } else if (mDate == event->dtEnd().date()) { 448 } else if (mDate == event->dtEnd().date()) {
441 prefix ="<-" ; 449 prefix ="<-" ;
442 } 450 }
443 } 451 }
444 text = prefix + event->summary(); 452 text = prefix + event->summary();
445 tipText += text; 453 tipText += text;
446 } else { 454 } else {
447 if (event->doesFloat()) { 455 if (event->doesFloat()) {
448 text = event->summary(); 456 text = event->summary();
449 tipText += text; 457 tipText += text;
450 } 458 }
451 else { 459 else {
452 text = KGlobal::locale()->formatTime(event->dtStart().time()); 460 text = KGlobal::locale()->formatTime(event->dtStart().time());
453 text += " " + event->summary(); 461 text += " " + event->summary();
454 tipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); 462 tipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary();
455 } 463 }
456 } 464 }
457 465
458 MonthViewItem *item = new MonthViewItem( event, mDate, text ); 466 MonthViewItem *item = new MonthViewItem( event, mDate, text );
459 QPalette pal; 467 QPalette pal;
460 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 468 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
461 QStringList categories = event->categories(); 469 QStringList categories = event->categories();
462 QString cat = categories.first(); 470 QString cat = categories.first();
463 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 471 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
464 pal = getPalette(); 472 pal = getPalette();
465 if (cat.isEmpty()) { 473 if (cat.isEmpty()) {
466 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 474 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
467 } else { 475 } else {
468 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 476 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
469 } 477 }
470 478
471 } else { 479 } else {
472 if (cat.isEmpty()) { 480 if (cat.isEmpty()) {
473 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 481 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
474 } else { 482 } else {
475 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 483 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
476 } 484 }
477 } 485 }
478 486
479 } else { 487 } else {
480 pal = mStandardPalette ; 488 pal = mStandardPalette ;
481 } 489 }
482 item->setPalette( pal ); 490 item->setPalette( pal );
483 item->setRecur( event->recurrence()->doesRecur() ); 491 item->setRecur( event->recurrence()->doesRecur() );
484 item->setAlarm( event->isAlarmEnabled() ); 492 item->setAlarm( event->isAlarmEnabled() );
485 item->setMoreInfo( event->description().length() > 0 ); 493 item->setMoreInfo( event->description().length() > 0 );
494#ifdef DESKTOP_VERSION
486 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, 495 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails,
487 KOPrefs::instance()->email()); 496 KOPrefs::instance()->email());
488 if ( me != 0 ) { 497 if ( me != 0 ) {
489 if ( me->status() == Attendee::NeedsAction && me->RSVP()) 498 if ( me->status() == Attendee::NeedsAction && me->RSVP())
490 item->setReply(true); 499 item->setReply(true);
491 else 500 else
492 item->setReply(false); 501 item->setReply(false);
493 } else 502 } else
494 item->setReply(false); 503 item->setReply(false);
495 bool insert = true; 504#endif
496 if ( !(event->doesRecur() == Recurrence::rNone) ) { 505 mItemList->insertItem( item );
497 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) 506 tipText += "\n";
498 insert = false; 507
499 else
500 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly )
501 insert = false;
502
503 }
504 if ( insert ) {
505 mItemList->insertItem( item );
506 tipText += "\n";
507 } else
508 tipText = "";
509 } 508 }
510 509
511 // insert due todos 510 // insert due todos
512 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); 511 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate );
513 Todo *todo; 512 Todo *todo;
514 for(todo = todos.first(); todo; todo = todos.next()) { 513 for(todo = todos.first(); todo; todo = todos.next()) {
515 QString text; 514 QString text;
516 if (todo->hasDueDate()) { 515 if (todo->hasDueDate()) {
517 if (!todo->doesFloat()) { 516 if (!todo->doesFloat()) {
518 text += KGlobal::locale()->formatTime(todo->dtDue().time()); 517 text += KGlobal::locale()->formatTime(todo->dtDue().time());
519 text += " "; 518 text += " ";
520 } 519 }
521 } 520 }
522 text += i18n("To-Do: %1").arg(todo->summary()); 521 text += i18n("To-Do: %1").arg(todo->summary());
523 522
524 MonthViewItem *item = new MonthViewItem( todo, mDate, text ); 523 MonthViewItem *item = new MonthViewItem( todo, mDate, text );
525 //item->setPalette( mStandardPalette ); 524 //item->setPalette( mStandardPalette );
526 QPalette pal; 525 QPalette pal;
527 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 526 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
528 QStringList categories = todo->categories(); 527 QStringList categories = todo->categories();
529 QString cat = categories.first(); 528 QString cat = categories.first();
530 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 529 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
531 pal = getPalette(); 530 pal = getPalette();
532 if (cat.isEmpty()) { 531 if (cat.isEmpty()) {
533 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 532 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
534 } else { 533 } else {
535 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 534 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
536 } 535 }
537 536
538 } else { 537 } else {
539 if (cat.isEmpty()) { 538 if (cat.isEmpty()) {
540 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 539 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
541 } else { 540 } else {
542 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 541 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
543 } 542 }
544 } 543 }
545 544
546 } else { 545 } else {
547 pal = mStandardPalette ; 546 pal = mStandardPalette ;
548 } 547 }
549 item->setPalette( pal ); 548 item->setPalette( pal );
550 mItemList->insertItem( item ); 549 mItemList->insertItem( item );
551 tipText += text+"\n"; 550 tipText += text+"\n";
552 } 551 }
553#ifdef DESKTOP_VERSION 552#ifdef DESKTOP_VERSION
554 if (tipText != "") 553 if (tipText != "")
555 QToolTip::add(this,tipText,toolTipGroup(),""); 554 QToolTip::add(this,tipText,toolTipGroup(),"");
556#endif 555#endif
557 556
558 //setMyPalette(); 557 //setMyPalette();
559 setMyPalette(); 558 setMyPalette();
559 QString text;
560 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog;
561 if ( KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) {
562 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " ";
563 mLabel->resize( mLabelBigSize );
564 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
565 } else {
566 mLabel->resize( mLabelSize );
567 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
568 }
569 mLabel->setText( text );
560 resizeEvent( 0 ); 570 resizeEvent( 0 );
561 // if ( isVisible()) 571 // if ( isVisible())
562 // qApp->processEvents(); 572 qApp->processEvents();
563} 573}
564 574
565void MonthViewCell::updateConfig() 575void MonthViewCell::updateConfig()
566{ 576{
567 577
568 setFont( KOPrefs::instance()->mMonthViewFont ); 578 setFont( KOPrefs::instance()->mMonthViewFont );
569 579
570 QFontMetrics fm( font() ); 580 QFontMetrics fm( font() );
571 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); 581 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 );
572 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); 582 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 );
573 mHolidayPalette = mStandardPalette; 583 mHolidayPalette = mStandardPalette;
574 mPrimaryPalette = mStandardPalette; 584 mPrimaryPalette = mStandardPalette;
575 mNonPrimaryPalette = mStandardPalette; 585 mNonPrimaryPalette = mStandardPalette;
576 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { 586 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) {
577 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); 587 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor );
578 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); 588 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor );
579 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); 589 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark());
580 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); 590 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark());
581 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); 591 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor);
582 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); 592 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor);
583 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); 593 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark());
584 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); 594 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor);
585 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); 595 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor);
586 } 596 }
587 updateCell(); 597 updateCell();
588} 598}
589 599
590void MonthViewCell::enableScrollBars( bool enabled ) 600void MonthViewCell::enableScrollBars( bool enabled )
591{ 601{
592 if ( enabled ) { 602 if ( enabled ) {
593 mItemList->setVScrollBarMode(QScrollView::Auto); 603 mItemList->setVScrollBarMode(QScrollView::Auto);
594 mItemList->setHScrollBarMode(QScrollView::Auto); 604 mItemList->setHScrollBarMode(QScrollView::Auto);
595 } else { 605 } else {
596 mItemList->setVScrollBarMode(QScrollView::AlwaysOff); 606 mItemList->setVScrollBarMode(QScrollView::AlwaysOff);
597 mItemList->setHScrollBarMode(QScrollView::AlwaysOff); 607 mItemList->setHScrollBarMode(QScrollView::AlwaysOff);
598 } 608 }
599} 609}
600 610
601Incidence *MonthViewCell::selectedIncidence() 611Incidence *MonthViewCell::selectedIncidence()
602{ 612{
603 int index = mItemList->currentItem(); 613 int index = mItemList->currentItem();
604 if ( index < 0 ) return 0; 614 if ( index < 0 ) return 0;
605 615
606 MonthViewItem *item = 616 MonthViewItem *item =
607 static_cast<MonthViewItem *>( mItemList->item( index ) ); 617 static_cast<MonthViewItem *>( mItemList->item( index ) );
608 618
609 if ( !item ) return 0; 619 if ( !item ) return 0;
610 620
611 return item->incidence(); 621 return item->incidence();
612} 622}
613 623
614QDate MonthViewCell::selectedIncidenceDate() 624QDate MonthViewCell::selectedIncidenceDate()
615{ 625{
616 QDate qd; 626 QDate qd;
617 int index = mItemList->currentItem(); 627 int index = mItemList->currentItem();
618 if ( index < 0 ) return qd; 628 if ( index < 0 ) return qd;
619 629
620 MonthViewItem *item = 630 MonthViewItem *item =
621 static_cast<MonthViewItem *>( mItemList->item( index ) ); 631 static_cast<MonthViewItem *>( mItemList->item( index ) );
622 632
623 if ( !item ) return qd; 633 if ( !item ) return qd;
624 634
625 return item->incidenceDate(); 635 return item->incidenceDate();
626} 636}
627 637
628void MonthViewCell::deselect() 638void MonthViewCell::deselect()
629{ 639{
630 mItemList->clearSelection(); 640 mItemList->clearSelection();
631 enableScrollBars( false ); 641 enableScrollBars( false );
632 // updateCell(); 642 // updateCell();
633} 643}
634void MonthViewCell::select() 644void MonthViewCell::select()
635{ 645{
636 ;// updateCell(); 646 ;// updateCell();
637} 647}
638 648
639void MonthViewCell::resizeEvent ( QResizeEvent * ) 649void MonthViewCell::resizeEvent ( QResizeEvent * )
640{ 650{
651 if ( !mMonthView->isUpdatePossible() )
652 return;
653 if ( !isVisible() ){
654 return;
655 }
641 int size = height() - mLabel->height(); 656 int size = height() - mLabel->height();
642 if ( size > 0 ) 657 if ( size > 0 )
643 mItemList->verticalScrollBar()->setMaximumHeight( size ); 658 mItemList->verticalScrollBar()->setMaximumHeight( size );
644 size = width() - mLabel->width(); 659 size = width() - mLabel->width();
645 if ( size > 0 ) 660 if ( size > 0 )
646 mItemList->horizontalScrollBar()->setMaximumWidth( size ); 661 mItemList->horizontalScrollBar()->setMaximumWidth( size );
647 mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() ); 662 mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() );
648 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 663 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
649} 664}
650 665
651void MonthViewCell::defaultAction( QListBoxItem *item ) 666void MonthViewCell::defaultAction( QListBoxItem *item )
652{ 667{
653 if ( !item ) return; 668 if ( !item ) return;
654 669
655 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 670 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
656 Incidence *incidence = eventItem->incidence(); 671 Incidence *incidence = eventItem->incidence();
657 if ( incidence ) mMonthView->defaultAction( incidence ); 672 if ( incidence ) mMonthView->defaultAction( incidence );
658} 673}
659void MonthViewCell::showDay() 674void MonthViewCell::showDay()
660{ 675{
661 emit showDaySignal( date() ); 676 emit showDaySignal( date() );
662} 677}
663void MonthViewCell::newEvent() 678void MonthViewCell::newEvent()
664{ 679{
665 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 680 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
666 emit newEventSignal( dt ); 681 emit newEventSignal( dt );
667} 682}
668void MonthViewCell::cellClicked( QListBoxItem *item ) 683void MonthViewCell::cellClicked( QListBoxItem *item )
669{ 684{
670 static QListBoxItem * lastClicked = 0; 685 static QListBoxItem * lastClicked = 0;
671 if ( item == 0 ) { 686 if ( item == 0 ) {
672 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 687 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
673 emit newEventSignal( dt ); 688 emit newEventSignal( dt );
674 return; 689 return;
675 } 690 }
676 /* 691 /*
677 if ( lastClicked ) 692 if ( lastClicked )
678 if ( ! item ) { 693 if ( ! item ) {
679 if ( lastClicked->listBox() != item->listBox() ) 694 if ( lastClicked->listBox() != item->listBox() )
680 lastClicked->listBox()->clearSelection(); 695 lastClicked->listBox()->clearSelection();
681 } 696 }
682 */ 697 */
683 698
684 mMonthView->setSelectedCell( this ); 699 mMonthView->setSelectedCell( this );
685 if( KOPrefs::instance()->mEnableMonthScroll ) enableScrollBars( true ); 700 if( KOPrefs::instance()->mEnableMonthScroll ) enableScrollBars( true );
686 select(); 701 select();
687} 702}
688 703
689void MonthViewCell::contextMenu( QListBoxItem *item ) 704void MonthViewCell::contextMenu( QListBoxItem *item )
690{ 705{
691 if ( !item ) return; 706 if ( !item ) return;
692 707
693 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 708 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
694 Incidence *incidence = eventItem->incidence(); 709 Incidence *incidence = eventItem->incidence();
695 if ( incidence ) mMonthView->showContextMenu( incidence ); 710 if ( incidence ) mMonthView->showContextMenu( incidence );
696} 711}
697 712
698void MonthViewCell::selection( QListBoxItem *item ) 713void MonthViewCell::selection( QListBoxItem *item )
699{ 714{
700 if ( !item ) return; 715 if ( !item ) return;
701 716
702 mMonthView->setSelectedCell( this ); 717 mMonthView->setSelectedCell( this );
703} 718}
704 719
705 720
706// ******************************************************************************* 721// *******************************************************************************
707// ******************************************************************************* 722// *******************************************************************************
708// ******************************************************************************* 723// *******************************************************************************
709 724
710 725
711KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) 726KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
712 : KOEventView( calendar, parent, name ), 727 : KOEventView( calendar, parent, name ),
713 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), 728 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ),
714 mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) 729 mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 )
715{ 730{
731 updatePossible = false;
716 mCells.setAutoDelete( true ); 732 mCells.setAutoDelete( true );
717 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 733 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
718 // mDayLayout = new QGridLayout( this ); 734 // mDayLayout = new QGridLayout( this );
719 // create the day of the week labels (Sun, Mon, etc) and add them to 735 // create the day of the week labels (Sun, Mon, etc) and add them to
720 // the layout. 736 // the layout.
721 mDayLabels.resize( mDaysPerWeek ); 737 mDayLabels.resize( mDaysPerWeek );
722 QFont bfont = font(); 738 QFont bfont = font();
723 if ( QApplication::desktop()->width() < 650 ) { 739 if ( QApplication::desktop()->width() < 650 ) {
724 bfont.setPointSize( bfont.pointSize() - 2 ); 740 bfont.setPointSize( bfont.pointSize() - 2 );
725 } 741 }
726 bfont.setBold( true ); 742 bfont.setBold( true );
727 int i; 743 int i;
728 744
729 for( i = 0; i < mDaysPerWeek; i++ ) { 745 for( i = 0; i < mDaysPerWeek; i++ ) {
730 QLabel *label = new QLabel( this ); 746 QLabel *label = new QLabel( this );
731 label->setFont(bfont); 747 label->setFont(bfont);
732 label->setFrameStyle(QFrame::Panel|QFrame::Raised); 748 label->setFrameStyle(QFrame::Panel|QFrame::Raised);
733 label->setLineWidth(1); 749 label->setLineWidth(1);
734 label->setAlignment(AlignCenter); 750 label->setAlignment(AlignCenter);
735 mDayLabels.insert( i, label ); 751 mDayLabels.insert( i, label );
736 } 752 }
737 753
738 bfont.setBold( false ); 754 bfont.setBold( false );
739 mWeekLabels.resize( mNumWeeks+1 ); 755 mWeekLabels.resize( mNumWeeks+1 );
740 for( i = 0; i < mNumWeeks+1; i++ ) { 756 for( i = 0; i < mNumWeeks+1; i++ ) {
741 KOWeekButton *label = new KOWeekButton( this ); 757 KOWeekButton *label = new KOWeekButton( this );
742 label->setFont(bfont); 758 label->setFont(bfont);
743 connect( label, SIGNAL( selectWeekNum ( int )),this, SIGNAL( selectWeekNum ( int )) ); 759 connect( label, SIGNAL( selectWeekNum ( int )),this, SIGNAL( selectWeekNum ( int )) );
744 label->setFlat(true); 760 label->setFlat(true);
745 QWhatsThis::add(label,i18n("Click on the week number to\nshow week in agenda view")); 761 QWhatsThis::add(label,i18n("Click on the week number to\nshow week in agenda view"));
746 //label->setFrameStyle(QFrame::Panel|QFrame::Raised); 762 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
747 //label->setLineWidth(1); 763 //label->setLineWidth(1);
748 //label->setAlignment(AlignCenter); 764 //label->setAlignment(AlignCenter);
749 mWeekLabels.insert( i, label ); 765 mWeekLabels.insert( i, label );
750 } 766 }
751 mWeekLabels[mNumWeeks]->setText( i18n("W")); 767 mWeekLabels[mNumWeeks]->setText( i18n("W"));
752 int row, col; 768 int row, col;
753 mCells.resize( mNumCells ); 769 mCells.resize( mNumCells );
754 for( row = 0; row < mNumWeeks; ++row ) { 770 for( row = 0; row < mNumWeeks; ++row ) {
755 for( col = 0; col < mDaysPerWeek; ++col ) { 771 for( col = 0; col < mDaysPerWeek; ++col ) {
756 MonthViewCell *cell = new MonthViewCell( this ); 772 MonthViewCell *cell = new MonthViewCell( this );
757 mCells.insert( row * mDaysPerWeek + col, cell ); 773 mCells.insert( row * mDaysPerWeek + col, cell );
758 774
759 connect( cell, SIGNAL( defaultAction( Incidence * ) ), 775 connect( cell, SIGNAL( defaultAction( Incidence * ) ),
760 SLOT( defaultAction( Incidence * ) ) ); 776 SLOT( defaultAction( Incidence * ) ) );
761 connect( cell, SIGNAL( newEventSignal( QDateTime ) ), 777 connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
762 SIGNAL( newEventSignal( QDateTime ) ) ); 778 SIGNAL( newEventSignal( QDateTime ) ) );
763 connect( cell, SIGNAL( showDaySignal( QDate ) ), 779 connect( cell, SIGNAL( showDaySignal( QDate ) ),
764 SIGNAL( showDaySignal( QDate ) ) ); 780 SIGNAL( showDaySignal( QDate ) ) );
765 } 781 }
766 } 782 }
767 783
768 mContextMenu = eventPopup(); 784 mContextMenu = eventPopup();
769 // updateConfig(); //useless here 785 // updateConfig(); //useless here
770 786
771 emit incidenceSelected( 0 ); 787 emit incidenceSelected( 0 );
772} 788}
773 789
774KOMonthView::~KOMonthView() 790KOMonthView::~KOMonthView()
775{ 791{
776 delete mContextMenu; 792 delete mContextMenu;
777} 793}
778 794
779int KOMonthView::maxDatesHint() 795int KOMonthView::maxDatesHint()
780{ 796{
781 return mNumCells; 797 return mNumCells;
782} 798}
783 799
784int KOMonthView::currentDateCount() 800int KOMonthView::currentDateCount()
785{ 801{
786 return mNumCells; 802 return mNumCells;
787} 803}
788 804
789QPtrList<Incidence> KOMonthView::selectedIncidences() 805QPtrList<Incidence> KOMonthView::selectedIncidences()
790{ 806{
791 QPtrList<Incidence> selected; 807 QPtrList<Incidence> selected;
792 808
793 if ( mSelectedCell ) { 809 if ( mSelectedCell ) {
794 Incidence *incidence = mSelectedCell->selectedIncidence(); 810 Incidence *incidence = mSelectedCell->selectedIncidence();
795 if ( incidence ) selected.append( incidence ); 811 if ( incidence ) selected.append( incidence );
796 } 812 }
797 813
798 return selected; 814 return selected;
799} 815}
800 816
801DateList KOMonthView::selectedDates() 817DateList KOMonthView::selectedDates()
802{ 818{
803 DateList selected; 819 DateList selected;
804 820
805 if ( mSelectedCell ) { 821 if ( mSelectedCell ) {
806 QDate qd = mSelectedCell->selectedIncidenceDate(); 822 QDate qd = mSelectedCell->selectedIncidenceDate();
807 if ( qd.isValid() ) selected.append( qd ); 823 if ( qd.isValid() ) selected.append( qd );
808 } 824 }
809 825
810 return selected; 826 return selected;
811} 827}
812 828
813void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, 829void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd,
814 const QDate &td) 830 const QDate &td)
815{ 831{
816#ifndef KORG_NOPRINTER 832#ifndef KORG_NOPRINTER
817 calPrinter->preview(CalPrinter::Month, fd, td); 833 calPrinter->preview(CalPrinter::Month, fd, td);
818#endif 834#endif
819} 835}
820 836
821void KOMonthView::updateConfig() 837void KOMonthView::updateConfig()
822{ 838{
823 839
824 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); 840 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
825 841
826 QFontMetrics fontmetric(mDayLabels[0]->font()); 842 QFontMetrics fontmetric(mDayLabels[0]->font());
827 mWidthLongDayLabel = 0; 843 mWidthLongDayLabel = 0;
828 844
829 for (int i = 0; i < 7; i++) { 845 for (int i = 0; i < 7; i++) {
830 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); 846 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1));
831 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; 847 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
832 } 848 }
833 bool temp = mShowSatSunComp ; 849 bool temp = mShowSatSunComp ;
834 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 850 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
835 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) 851 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog )
836 computeLayout(); 852 computeLayout();
837 updateDayLabels(); 853 updateDayLabels();
838 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); 854 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks);
839 int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; 855 int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks;
840 //resizeEvent( 0 ); 856 //resizeEvent( 0 );
841 for (uint i = 0; i < mCells.count(); ++i) { 857 for (uint i = 0; i < mCells.count(); ++i) {
842 mCells[i]->updateConfig(); 858 mCells[i]->updateConfig();
843 } 859 }
844#ifdef DESKTOP_VERSION 860#ifdef DESKTOP_VERSION
845 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); 861 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips);
846#endif 862#endif
847} 863}
848 864
849void KOMonthView::updateDayLabels() 865void KOMonthView::updateDayLabels()
850{ 866{
851 867
852 for (int i = 0; i < 7; i++) { 868 for (int i = 0; i < 7; i++) {
853 if (mWeekStartsMonday) { 869 if (mWeekStartsMonday) {
854 bool show = mShortDayLabels; 870 bool show = mShortDayLabels;
855 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() ) 871 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() )
856 show = true; 872 show = true;
857 mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); 873 mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
858 } else { 874 } else {
859 if (i==0) mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels)); 875 if (i==0) mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels));
860 else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); 876 else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels));
861 877
862 } 878 }
863 } 879 }
864} 880}
865 881
866void KOMonthView::showDates(const QDate &start, const QDate &) 882void KOMonthView::showDates(const QDate &start, const QDate &)
867{ 883{
868// kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; 884// kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl;
869 885
870 886
871 mStartDate = start; 887 mStartDate = start;
872 888
873 int startWeekDay = mWeekStartsMonday ? 1 : 7; 889 int startWeekDay = mWeekStartsMonday ? 1 : 7;
874 890
875 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { 891 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) {
876 mStartDate = mStartDate.addDays( -1 ); 892 mStartDate = mStartDate.addDays( -1 );
877 } 893 }
878 894
879 bool primary = false; 895 bool primary = false;
880 uint i; 896 uint i;
881 for( i = 0; i < mCells.size(); ++i ) { 897 for( i = 0; i < mCells.size(); ++i ) {
882 QDate date = mStartDate.addDays( i ); 898 QDate date = mStartDate.addDays( i );
883 mCells[i]->setDate( date ); 899 mCells[i]->setDate( date );
884 900
885#ifndef KORG_NOPLUGINS 901#ifndef KORG_NOPLUGINS
886 // add holiday, if present 902 // add holiday, if present
887 QString hstring(KOCore::self()->holiday(date)); 903 QString hstring(KOCore::self()->holiday(date));
888 mCells[i]->setHoliday( hstring ); 904 mCells[i]->setHoliday( hstring );
889#endif 905#endif
890 906
891 } 907 }
892 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); 908 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 );
893 for( i = 0; i < 6; ++i ) { 909 for( i = 0; i < 6; ++i ) {
894 int wno; 910 int wno;
895 // remember, according to ISO 8601, the first week of the year is the 911 // remember, according to ISO 8601, the first week of the year is the
896 // first week that contains a thursday. Thus we must subtract off 4, 912 // first week that contains a thursday. Thus we must subtract off 4,
897 // not just 1. 913 // not just 1.
898 int dayOfYear = date.dayOfYear(); 914 int dayOfYear = date.dayOfYear();
899 if (dayOfYear % 7 != 0) 915 if (dayOfYear % 7 != 0)
900 wno = dayOfYear / 7 + 1; 916 wno = dayOfYear / 7 + 1;
901 else 917 else
902 wno =dayOfYear / 7; 918 wno =dayOfYear / 7;
903 mWeekLabels[i]->setWeekNum( wno ); 919 mWeekLabels[i]->setWeekNum( wno );
904 date = date.addDays( 7 ); 920 date = date.addDays( 7 );
905 } 921 }
906 updateView(); 922 updateView();
907} 923}
908 924
909void KOMonthView::showEvents(QPtrList<Event>) 925void KOMonthView::showEvents(QPtrList<Event>)
910{ 926{
911 qDebug("KOMonthView::selectEvents is not implemented yet. "); 927 qDebug("KOMonthView::selectEvents is not implemented yet. ");
912} 928}
913 929
914void KOMonthView::changeEventDisplay(Event *, int) 930void KOMonthView::changeEventDisplay(Event *, int)
915{ 931{
916 // this should be re-written to be much more efficient, but this 932 // this should be re-written to be much more efficient, but this
917 // quick-and-dirty-hack gets the job done for right now. 933 // quick-and-dirty-hack gets the job done for right now.
918 updateView(); 934 updateView();
919} 935}
920 936
921void KOMonthView::updateView() 937void KOMonthView::updateView()
922{ 938{
923 939 static int iii = 0;
940 ++iii;
941 if ( !updatePossible )
942 return;
924 uint i; 943 uint i;
925 for( i = 0; i < mCells.count(); ++i ) { 944 for( i = 0; i < mCells.count(); ++i ) {
926 mCells[i]->updateCell(); 945 mCells[i]->updateCell();
927 } 946 }
928 //qDebug("KOMonthView::updateView() "); 947 //qDebug("KOMonthView::updateView() ");
929 processSelectionChange(); 948 processSelectionChange();
930} 949}
931 950
932void KOMonthView::resizeEvent(QResizeEvent * e) 951void KOMonthView::resizeEvent(QResizeEvent * e)
933{ 952{
934 computeLayout(); 953 computeLayout();
935} 954}
936void KOMonthView::computeLayout() 955void KOMonthView::computeLayout()
937{ 956{
938 // select the appropriate heading string size. E.g. "Wednesday" or "Wed". 957 // select the appropriate heading string size. E.g. "Wednesday" or "Wed".
939 // note this only changes the text if the requested size crosses the 958 // note this only changes the text if the requested size crosses the
940 // threshold between big enough to support the full name and not big 959 // threshold between big enough to support the full name and not big
941 // enough. 960 // enough.
942 961
943 int daysToShow = 7; 962 int daysToShow = 7;
944 bool combinedSatSun = false; 963 bool combinedSatSun = false;
945 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { 964 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
946 daysToShow = 6; 965 daysToShow = 6;
947 combinedSatSun = true; 966 combinedSatSun = true;
948 } 967 }
949 int tWid = topLevelWidget()->size().width(); 968 int tWid = topLevelWidget()->size().width();
950 int tHei = topLevelWidget()->size().height(); 969 int tHei = topLevelWidget()->size().height();
951 970
952 int wid = size().width();//e 971 int wid = size().width();//e
953 int hei = size().height()-1; 972 int hei = size().height()-1;
954 973
955 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) 974 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei )
956 return; 975 return;
957 976 //qDebug("KOMonthView::computeLayout()------------------------------------ ");
958 QFontMetrics fm ( mWeekLabels[0]->font() ); 977 QFontMetrics fm ( mWeekLabels[0]->font() );
959 int weeklabelwid = fm.width( "888" ); 978 int weeklabelwid = fm.width( "888" );
960 wid -= weeklabelwid; 979 wid -= weeklabelwid;
961 980
962 int colWid = wid / daysToShow; 981 int colWid = wid / daysToShow;
963 int lastCol = wid - ( colWid*6 ); 982 int lastCol = wid - ( colWid*6 );
964 int dayLabelHei = mDayLabels[0]->sizeHint().height(); 983 int dayLabelHei = mDayLabels[0]->sizeHint().height();
965 int cellHei = (hei - dayLabelHei) /6; 984 int cellHei = (hei - dayLabelHei) /6;
966 int colModulo = wid % daysToShow; 985 int colModulo = wid % daysToShow;
967 int rowModulo = (hei- dayLabelHei) % 6; 986 int rowModulo = (hei- dayLabelHei) % 6;
968 //qDebug("rowmod %d ", rowModulo); 987 //qDebug("rowmod %d ", rowModulo);
969 int i; 988 int i;
970 int x,y,w,h; 989 int x,y,w,h;
971 x= 0; 990 x= 0;
972 y= 0; 991 y= 0;
973 w = colWid; 992 w = colWid;
974 h = dayLabelHei ; 993 h = dayLabelHei ;
975 for ( i = 0; i < 7; i++) { 994 for ( i = 0; i < 7; i++) {
976 if ( i == daysToShow-colModulo ) 995 if ( i == daysToShow-colModulo )
977 ++w; 996 ++w;
978 if ( combinedSatSun ) { 997 if ( combinedSatSun ) {
979 if ( i >= daysToShow-1 ) { 998 if ( i >= daysToShow-1 ) {
980 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); 999 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h);
981 x -= w/2 ; 1000 x -= w/2 ;
982 } 1001 }
983 else 1002 else
984 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 1003 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
985 } else 1004 } else
986 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 1005 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
987 x += w; 1006 x += w;
988 } 1007 }
989 x= 0; 1008 x= 0;
990 y= dayLabelHei; 1009 y= dayLabelHei;
991 w = colWid; 1010 w = colWid;
992 h = cellHei ; 1011 h = cellHei ;
993 for ( i = 0; i < mCells.count(); ++i) { 1012 for ( i = 0; i < mCells.count(); ++i) {
994 1013
995 w = colWid; 1014 w = colWid;
996 if ( ((i) % 7) >= 7-colModulo ) { 1015 if ( ((i) % 7) >= 7-colModulo ) {
997 ++w; 1016 ++w;
998 } 1017 }
999 if ( i == (6-rowModulo)*7) 1018 if ( i == (6-rowModulo)*7)
1000 ++h; 1019 ++h;
1001 if ( combinedSatSun ) { 1020 if ( combinedSatSun ) {
1002 if ( (i)%7 >= daysToShow-1 ) { 1021 if ( (i)%7 >= daysToShow-1 ) {
1003 if ( (i)%7 == daysToShow-1 ) { 1022 if ( (i)%7 == daysToShow-1 ) {
1004 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); 1023 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 );
1005 x -= w ;y += h/2; 1024 x -= w ;y += h/2;
1006 } else { 1025 } else {
1007 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); 1026 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 );
1008 y -= h/2; 1027 y -= h/2;
1009 } 1028 }
1010 } else 1029 } else
1011 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1030 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
1012 1031
1013 } 1032 }
1014 else 1033 else
1015 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1034 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
1016 x += w; 1035 x += w;
1017 if ( x + w/2 > wid ) { 1036 if ( x + w/2 > wid ) {
1018 x = 0; 1037 x = 0;
1019 y += h; 1038 y += h;
1020 } 1039 }
1021 } 1040 }
1022 y= dayLabelHei; 1041 y= dayLabelHei;
1023 h = cellHei ; 1042 h = cellHei ;
1024 for ( i = 0; i < 6; i++) { 1043 for ( i = 0; i < 6; i++) {
1025 if ( i == (6-rowModulo)) 1044 if ( i == (6-rowModulo))
1026 ++h; 1045 ++h;
1027 mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); 1046 mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h);
1028 y += h; 1047 y += h;
1029 } 1048 }
1030 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); 1049 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei);
1031 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); 1050 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height());
1032 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); 1051 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height());
1033 mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ; 1052 mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ;
1034 updateDayLabels(); 1053 updateDayLabels();
1054 bool forceUpdate = !updatePossible;
1055 updatePossible = true;
1056 if ( forceUpdate )
1057 updateView();
1035} 1058}
1036 1059
1037void KOMonthView::showContextMenu( Incidence *incidence ) 1060void KOMonthView::showContextMenu( Incidence *incidence )
1038{ 1061{
1039 mContextMenu->showIncidencePopup(incidence); 1062 mContextMenu->showIncidencePopup(incidence);
1040 /* 1063 /*
1041 if( incidence && incidence->type() == "Event" ) { 1064 if( incidence && incidence->type() == "Event" ) {
1042 Event *event = static_cast<Event *>(incidence); 1065 Event *event = static_cast<Event *>(incidence);
1043 mContextMenu->showEventPopup(event); 1066 mContextMenu->showEventPopup(event);
1044 } else { 1067 } else {
1045 kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; 1068 kdDebug() << "MonthView::showContextMenu(): cast failed." << endl;
1046 } 1069 }
1047 */ 1070 */
1048} 1071}
1049MonthViewCell * KOMonthView::selectedCell( ) 1072MonthViewCell * KOMonthView::selectedCell( )
1050{ 1073{
1051 return mSelectedCell; 1074 return mSelectedCell;
1052} 1075}
1053void KOMonthView::setSelectedCell( MonthViewCell *cell ) 1076void KOMonthView::setSelectedCell( MonthViewCell *cell )
1054{ 1077{
1055 // qDebug("KOMonthView::setSelectedCell "); 1078 // qDebug("KOMonthView::setSelectedCell ");
1056 if ( mSelectedCell && mSelectedCell != cell ) { 1079 if ( mSelectedCell && mSelectedCell != cell ) {
1057 MonthViewCell * mvc = mSelectedCell; 1080 MonthViewCell * mvc = mSelectedCell;
1058 mSelectedCell = cell; 1081 mSelectedCell = cell;
1059 mvc->deselect(); 1082 mvc->deselect();
1060 } else 1083 } else
1061 mSelectedCell = cell; 1084 mSelectedCell = cell;
1062 // if ( mSelectedCell ) 1085 // if ( mSelectedCell )
1063// mSelectedCell->select(); 1086// mSelectedCell->select();
1064 if ( !mSelectedCell ) 1087 if ( !mSelectedCell )
1065 emit incidenceSelected( 0 ); 1088 emit incidenceSelected( 0 );
1066 else 1089 else
1067 emit incidenceSelected( mSelectedCell->selectedIncidence() ); 1090 emit incidenceSelected( mSelectedCell->selectedIncidence() );
1068} 1091}
1069 1092
1070void KOMonthView::processSelectionChange() 1093void KOMonthView::processSelectionChange()
1071{ 1094{
1072 QPtrList<Incidence> incidences = selectedIncidences(); 1095 QPtrList<Incidence> incidences = selectedIncidences();
1073 if (incidences.count() > 0) { 1096 if (incidences.count() > 0) {
1074 emit incidenceSelected( incidences.first() ); 1097 emit incidenceSelected( incidences.first() );
1075 } else { 1098 } else {
1076 emit incidenceSelected( 0 ); 1099 emit incidenceSelected( 0 );
1077 } 1100 }
1078} 1101}
1079 1102
1080void KOMonthView::clearSelection() 1103void KOMonthView::clearSelection()
1081{ 1104{
1082 if ( mSelectedCell ) { 1105 if ( mSelectedCell ) {
1083 mSelectedCell->deselect(); 1106 mSelectedCell->deselect();
1084 mSelectedCell = 0; 1107 mSelectedCell = 0;
1085 } 1108 }
1086} 1109}
1087void KOMonthView::keyPressEvent ( QKeyEvent * e ) 1110void KOMonthView::keyPressEvent ( QKeyEvent * e )
1088{ 1111{
1089 1112
1090 e->ignore(); 1113 e->ignore();
1091 1114
1092} 1115}
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h
index 4c1567c..727f511 100644
--- a/korganizer/komonthview.h
+++ b/korganizer/komonthview.h
@@ -1,265 +1,271 @@
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 19
20#ifndef _KOMONTHVIEW_H 20#ifndef _KOMONTHVIEW_H
21#define _KOMONTHVIEW_H 21#define _KOMONTHVIEW_H
22 22
23#include <qlabel.h> 23#include <qlabel.h>
24#include <qframe.h> 24#include <qframe.h>
25#include <qdatetime.h> 25#include <qdatetime.h>
26#include <qlistbox.h> 26#include <qlistbox.h>
27#include <qpoint.h> 27#include <qpoint.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#include <qintdict.h> 29#include <qintdict.h>
30#include <qpushbutton.h> 30#include <qpushbutton.h>
31#include <qvaluelist.h> 31#include <qvaluelist.h>
32#include <qptrvector.h> 32#include <qptrvector.h>
33 33
34#include <libkcal/calendar.h> 34#include <libkcal/calendar.h>
35#include <libkcal/event.h> 35#include <libkcal/event.h>
36 36
37#include "koeventview.h" 37#include "koeventview.h"
38 38
39#ifdef DESKTOP_VERSION 39#ifdef DESKTOP_VERSION
40class QToolTipGroup; 40class QToolTipGroup;
41#endif 41#endif
42 42
43class KNOWhatsThis;
43class KOWeekButton : public QPushButton 44class KOWeekButton : public QPushButton
44{ 45{
45 Q_OBJECT 46 Q_OBJECT
46 public: 47 public:
47 KOWeekButton( QWidget *parent=0, const char *name=0 ) : 48 KOWeekButton( QWidget *parent=0, const char *name=0 ) :
48 QPushButton( parent, name) 49 QPushButton( parent, name)
49 { 50 {
50 connect( this, SIGNAL( clicked() ), 51 connect( this, SIGNAL( clicked() ),
51 SLOT( bottonClicked() )); 52 SLOT( bottonClicked() ));
52 mNumber = -1; 53 mNumber = -1;
53 } 54 }
54 void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));} 55 void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));}
55 signals: 56 signals:
56 void selectWeekNum ( int ); 57 void selectWeekNum ( int );
57private: 58private:
58 int mNumber; 59 int mNumber;
59private slots : 60private slots :
60 void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); } 61 void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); }
61}; 62};
62 63
63class KNoScrollListBox: public QListBox 64class KNoScrollListBox: public QListBox
64{ 65{
65 Q_OBJECT 66 Q_OBJECT
66 public: 67 public:
67 KNoScrollListBox(QWidget *parent=0, const char *name=0); 68 KNoScrollListBox(QWidget *parent=0, const char *name=0);
68 ~KNoScrollListBox() {} 69 ~KNoScrollListBox();
69 QString getWhatsThisText(QPoint p) ; 70 QString getWhatsThisText(QPoint p) ;
70 71
71 signals: 72 signals:
72 void shiftDown(); 73 void shiftDown();
73 void shiftUp(); 74 void shiftUp();
74 void rightClick(); 75 void rightClick();
75 76
76 protected slots: 77 protected slots:
77 void keyPressEvent(QKeyEvent *); 78 void keyPressEvent(QKeyEvent *);
78 void keyReleaseEvent(QKeyEvent *); 79 void keyReleaseEvent(QKeyEvent *);
79 void mousePressEvent(QMouseEvent *); 80 void mousePressEvent(QMouseEvent *);
81
82 private:
83 KNOWhatsThis * mWT;
80}; 84};
81 85
82 86
83class MonthViewItem: public QListBoxItem 87class MonthViewItem: public QListBoxItem
84{ 88{
85 public: 89 public:
86 MonthViewItem( Incidence *, QDate qd, const QString & title ); 90 MonthViewItem( Incidence *, QDate qd, const QString & title );
87 91
88 void setRecur(bool on) { mRecur = on; } 92 void setRecur(bool on) { mRecur = on; }
89 void setAlarm(bool on) { mAlarm = on; } 93 void setAlarm(bool on) { mAlarm = on; }
90 void setReply(bool on) { mReply = on; } 94 void setReply(bool on) { mReply = on; }
91 void setMoreInfo(bool on) { mInfo = on; } 95 void setMoreInfo(bool on) { mInfo = on; }
92 96
93 97
94 void setPalette(const QPalette &p) { mPalette = p; } 98 void setPalette(const QPalette &p) { mPalette = p; }
95 QPalette palette() const { return mPalette; } 99 QPalette palette() const { return mPalette; }
96 100
97 Incidence *incidence() const { return mIncidence; } 101 Incidence *incidence() const { return mIncidence; }
98 QDate incidenceDate() { return mDate; } 102 QDate incidenceDate() { return mDate; }
99 103
100 protected: 104 protected:
101 virtual void paint(QPainter *); 105 virtual void paint(QPainter *);
102 virtual int height(const QListBox *) const; 106 virtual int height(const QListBox *) const;
103 virtual int width(const QListBox *) const; 107 virtual int width(const QListBox *) const;
104 108
105 private: 109 private:
106 bool mRecur; 110 bool mRecur;
107 bool mAlarm; 111 bool mAlarm;
108 bool mReply; 112 bool mReply;
109 bool mInfo; 113 bool mInfo;
110 114
111 QPalette mPalette; 115 QPalette mPalette;
112 QDate mDate; 116 QDate mDate;
113 117
114 Incidence *mIncidence; 118 Incidence *mIncidence;
115}; 119};
116 120
117 121
118class KOMonthView; 122class KOMonthView;
119 123
120class MonthViewCell : public QWidget 124class MonthViewCell : public QWidget
121{ 125{
122 Q_OBJECT 126 Q_OBJECT
123 public: 127 public:
124 MonthViewCell( KOMonthView * ); 128 MonthViewCell( KOMonthView * );
125 129
126 void setDate( const QDate & ); 130 void setDate( const QDate & );
127 QDate date() const; 131 QDate date() const;
128 132
129 void setPrimary( bool ); 133 void setPrimary( bool );
130 bool isPrimary() const; 134 bool isPrimary() const;
131 135
132 void setHoliday( bool ); 136 void setHoliday( bool );
133 void setHoliday( const QString & ); 137 void setHoliday( const QString & );
134 138
135 void updateCell(); 139 void updateCell();
136 140
137 void updateConfig(); 141 void updateConfig();
138 142
139 void enableScrollBars( bool ); 143 void enableScrollBars( bool );
140 144
141 Incidence *selectedIncidence(); 145 Incidence *selectedIncidence();
142 QDate selectedIncidenceDate(); 146 QDate selectedIncidenceDate();
143 147
144 void deselect(); 148 void deselect();
145 void select(); 149 void select();
146 150
147#ifdef DESKTOP_VERSION 151#ifdef DESKTOP_VERSION
148 static QToolTipGroup *toolTipGroup(); 152 static QToolTipGroup *toolTipGroup();
149#endif 153#endif
150 signals: 154 signals:
151 void defaultAction( Incidence * ); 155 void defaultAction( Incidence * );
152 void newEventSignal( QDateTime ); 156 void newEventSignal( QDateTime );
153 void showDaySignal( QDate ); 157 void showDaySignal( QDate );
154 158
155 protected: 159 protected:
156 void resizeEvent( QResizeEvent * ); 160 void resizeEvent( QResizeEvent * );
157 161
158 protected slots: 162 protected slots:
159 void defaultAction( QListBoxItem * ); 163 void defaultAction( QListBoxItem * );
160 void contextMenu( QListBoxItem * ); 164 void contextMenu( QListBoxItem * );
161 void selection( QListBoxItem * ); 165 void selection( QListBoxItem * );
162 void cellClicked( QListBoxItem * ); 166 void cellClicked( QListBoxItem * );
163 void newEvent(); 167 void newEvent();
164 void showDay(); 168 void showDay();
165 169
166 private: 170 private:
167 KOMonthView *mMonthView; 171 KOMonthView *mMonthView;
168 172
169 QDate mDate; 173 QDate mDate;
170 bool mPrimary; 174 bool mPrimary;
171 bool mHoliday; 175 bool mHoliday;
172 QString mHolidayString; 176 QString mHolidayString;
173 177
174 //QLabel *mLabel; 178 //QLabel *mLabel;
175 QPushButton *mLabel; 179 QPushButton *mLabel;
176 QListBox *mItemList; 180 QListBox *mItemList;
177#ifdef DESKTOP_VERSION 181#ifdef DESKTOP_VERSION
178 static QToolTipGroup *mToolTipGroup; 182 static QToolTipGroup *mToolTipGroup;
179#endif 183#endif
180 QSize mLabelSize; 184 QSize mLabelSize;
181 QSize mLabelBigSize; 185 QSize mLabelBigSize;
182 QPalette mHolidayPalette; 186 QPalette mHolidayPalette;
183 QPalette mStandardPalette; 187 QPalette mStandardPalette;
184 QPalette mPrimaryPalette; 188 QPalette mPrimaryPalette;
185 QPalette mNonPrimaryPalette; 189 QPalette mNonPrimaryPalette;
186 void setMyPalette(); 190 void setMyPalette();
187 QPalette getPalette (); 191 QPalette getPalette ();
188 void keyPressEvent ( QKeyEvent * ) ; 192 void keyPressEvent ( QKeyEvent * ) ;
189 193
190}; 194};
191 195
192 196
193class KOMonthView: public KOEventView 197class KOMonthView: public KOEventView
194{ 198{
195 Q_OBJECT 199 Q_OBJECT
196 public: 200 public:
197 KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 ); 201 KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 );
198 ~KOMonthView(); 202 ~KOMonthView();
199 203
200 /** Returns maximum number of days supported by the komonthview */ 204 /** Returns maximum number of days supported by the komonthview */
201 virtual int maxDatesHint(); 205 virtual int maxDatesHint();
202 206
203 /** Returns number of currently shown dates. */ 207 /** Returns number of currently shown dates. */
204 virtual int currentDateCount(); 208 virtual int currentDateCount();
205 209
206 /** returns the currently selected events */ 210 /** returns the currently selected events */
207 virtual QPtrList<Incidence> selectedIncidences(); 211 virtual QPtrList<Incidence> selectedIncidences();
208 212
209 /** returns dates of the currently selected events */ 213 /** returns dates of the currently selected events */
210 virtual DateList selectedDates(); 214 virtual DateList selectedDates();
211 215
212 virtual void printPreview(CalPrinter *calPrinter, 216 virtual void printPreview(CalPrinter *calPrinter,
213 const QDate &, const QDate &); 217 const QDate &, const QDate &);
214 bool isMonthView() { return true; } 218 bool isMonthView() { return true; }
219 bool isUpdatePossible() { return updatePossible; }
215 220
216 MonthViewCell * selectedCell(); 221 MonthViewCell * selectedCell();
217 public slots: 222 public slots:
218 virtual void updateView(); 223 virtual void updateView();
219 virtual void updateConfig(); 224 virtual void updateConfig();
220 virtual void showDates(const QDate &start, const QDate &end); 225 virtual void showDates(const QDate &start, const QDate &end);
221 virtual void showEvents(QPtrList<Event> eventList); 226 virtual void showEvents(QPtrList<Event> eventList);
222 227
223 void changeEventDisplay(Event *, int); 228 void changeEventDisplay(Event *, int);
224 229
225 void clearSelection(); 230 void clearSelection();
226 231
227 void showContextMenu( Incidence * ); 232 void showContextMenu( Incidence * );
228 233
229 void setSelectedCell( MonthViewCell * ); 234 void setSelectedCell( MonthViewCell * );
230 235
231 protected slots: 236 protected slots:
232 void processSelectionChange(); 237 void processSelectionChange();
233 signals: 238 signals:
234 void selectWeekNum ( int ); 239 void selectWeekNum ( int );
235 void showDaySignal( QDate ); 240 void showDaySignal( QDate );
236 protected: 241 protected:
237 void resizeEvent(QResizeEvent *); 242 void resizeEvent(QResizeEvent *);
238 void viewChanged(); 243 void viewChanged();
239 void updateDayLabels(); 244 void updateDayLabels();
240 245
241 private: 246 private:
247 bool updatePossible;
242 int mDaysPerWeek; 248 int mDaysPerWeek;
243 int mNumWeeks; 249 int mNumWeeks;
244 int mNumCells; 250 int mNumCells;
245 bool mWeekStartsMonday; 251 bool mWeekStartsMonday;
246 bool mShowSatSunComp; 252 bool mShowSatSunComp;
247 void computeLayout(); 253 void computeLayout();
248 254
249 QPtrVector<MonthViewCell> mCells; 255 QPtrVector<MonthViewCell> mCells;
250 QPtrVector<QLabel> mDayLabels; 256 QPtrVector<QLabel> mDayLabels;
251 QPtrVector<KOWeekButton> mWeekLabels; 257 QPtrVector<KOWeekButton> mWeekLabels;
252 258
253 bool mShortDayLabels; 259 bool mShortDayLabels;
254 int mWidthLongDayLabel; 260 int mWidthLongDayLabel;
255 261
256 QDate mStartDate; 262 QDate mStartDate;
257 263
258 MonthViewCell *mSelectedCell; 264 MonthViewCell *mSelectedCell;
259 265
260 KOEventPopupMenu *mContextMenu; 266 KOEventPopupMenu *mContextMenu;
261 void keyPressEvent ( QKeyEvent * ) ; 267 void keyPressEvent ( QKeyEvent * ) ;
262 268
263}; 269};
264 270
265#endif 271#endif
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp
index cf56fcf..00a5842 100644
--- a/korganizer/koviewmanager.cpp
+++ b/korganizer/koviewmanager.cpp
@@ -1,583 +1,587 @@
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 As a special exception, permission is given to link this program 21 As a special exception, permission is given to link this program
22 with any edition of Qt, and distribute the resulting executable, 22 with any edition of Qt, and distribute the resulting executable,
23 without including the source code for Qt in the source distribution. 23 without including the source code for Qt in the source distribution.
24*/ 24*/
25 25
26#include <qwidgetstack.h> 26#include <qwidgetstack.h>
27 27
28#include <kconfig.h> 28#include <kconfig.h>
29#include <kglobal.h> 29#include <kglobal.h>
30#ifndef DESKTOP_VERSION 30#ifndef DESKTOP_VERSION
31#include <qpe/qpeapplication.h> 31#include <qpe/qpeapplication.h>
32#else 32#else
33#include <qapplication.h> 33#include <qapplication.h>
34#endif 34#endif
35#include <qdatetime.h> 35#include <qdatetime.h>
36#include "calendarview.h" 36#include "calendarview.h"
37#include "datenavigator.h" 37#include "datenavigator.h"
38#include "kotodoview.h" 38#include "kotodoview.h"
39#include "koagendaview.h" 39#include "koagendaview.h"
40#include "kodialogmanager.h" 40#include "kodialogmanager.h"
41#include "komonthview.h" 41#include "komonthview.h"
42#include "kolistview.h" 42#include "kolistview.h"
43#include "kowhatsnextview.h" 43#include "kowhatsnextview.h"
44#include "kojournalview.h" 44#include "kojournalview.h"
45#include "kotimespanview.h" 45#include "kotimespanview.h"
46#include "koprefs.h" 46#include "koprefs.h"
47#include "navigatorbar.h" 47#include "navigatorbar.h"
48#include "kdatenavigator.h"
48 49
49#include "koviewmanager.h" 50#include "koviewmanager.h"
50//extern bool externFlagMonthviewBlockPainting; 51//extern bool externFlagMonthviewBlockPainting;
51 52
52//bool globalFlagBlockPainting = false; 53//bool globalFlagBlockPainting = false;
53int globalFlagBlockAgenda = 0; 54int globalFlagBlockAgenda = 0;
54int globalFlagBlockLabel = 0; 55int globalFlagBlockLabel = 0;
55int globalFlagBlockAgendaItemPaint = 1; 56int globalFlagBlockAgendaItemPaint = 1;
56int globalFlagBlockAgendaItemUpdate = 1; 57int globalFlagBlockAgendaItemUpdate = 1;
57 58
58 59
59KOViewManager::KOViewManager( CalendarView *mainView ) : 60KOViewManager::KOViewManager( CalendarView *mainView ) :
60 QObject(), mMainView( mainView ) 61 QObject(), mMainView( mainView )
61{ 62{
62 mCurrentView = 0; 63 mCurrentView = 0;
63 64
64 mWhatsNextView = 0; 65 mWhatsNextView = 0;
65 mTodoView = 0; 66 mTodoView = 0;
66 mAgendaView = 0; 67 mAgendaView = 0;
67 mMonthView = 0; 68 mMonthView = 0;
68 mListView = 0; 69 mListView = 0;
69 mJournalView = 0; 70 mJournalView = 0;
70 mTimeSpanView = 0; 71 mTimeSpanView = 0;
71 mCurrentAgendaView = 0 ; 72 mCurrentAgendaView = 0 ;
72 mFlagShowNextxDays = false; 73 mFlagShowNextxDays = false;
73} 74}
74 75
75KOViewManager::~KOViewManager() 76KOViewManager::~KOViewManager()
76{ 77{
77} 78}
78 79
79 80
80KOrg::BaseView *KOViewManager::currentView() 81KOrg::BaseView *KOViewManager::currentView()
81{ 82{
82 return mCurrentView; 83 return mCurrentView;
83} 84}
84 85
85void KOViewManager::readSettings(KConfig *config) 86void KOViewManager::readSettings(KConfig *config)
86{ 87{
87 config->setGroup("General"); 88 config->setGroup("General");
88 QString view = config->readEntry("Current View"); 89 QString view = config->readEntry("Current View");
89 if (view == "WhatsNext") showWhatsNextView(); 90 if (view == "WhatsNext") showWhatsNextView();
90 else if (view == "Month") showMonthView(); 91 else if (view == "Month") showMonthView();
91 else if (view == "List") showListView(); 92 else if (view == "List") showListView();
92 else if (view == "Journal") showJournalView(); 93 else if (view == "Journal") showJournalView();
93 else if (view == "TimeSpan") showTimeSpanView(); 94 else if (view == "TimeSpan") showTimeSpanView();
94 else if (view == "Todo") showTodoView(); 95 else if (view == "Todo") showTodoView();
95 else { 96 else {
96 showAgendaView(); 97 showAgendaView();
97 } 98 }
98} 99}
99 100
100void KOViewManager::writeSettings(KConfig *config) 101void KOViewManager::writeSettings(KConfig *config)
101{ 102{
102 config->setGroup("General"); 103 config->setGroup("General");
103 104
104 QString view; 105 QString view;
105 if (mCurrentView == mWhatsNextView) view = "WhatsNext"; 106 if (mCurrentView == mWhatsNextView) view = "WhatsNext";
106 else if (mCurrentView == mMonthView) view = "Month"; 107 else if (mCurrentView == mMonthView) view = "Month";
107 else if (mCurrentView == mListView) view = "List"; 108 else if (mCurrentView == mListView) view = "List";
108 else if (mCurrentView == mJournalView) view = "Journal"; 109 else if (mCurrentView == mJournalView) view = "Journal";
109 else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; 110 else if (mCurrentView == mTimeSpanView) view = "TimeSpan";
110 else if (mCurrentView == mTodoView) view = "Todo"; 111 else if (mCurrentView == mTodoView) view = "Todo";
111 else view = "Agenda"; 112 else view = "Agenda";
112 113
113 config->writeEntry("Current View",view); 114 config->writeEntry("Current View",view);
114 115
115 if (mAgendaView) { 116 if (mAgendaView) {
116 mAgendaView->writeSettings(config); 117 mAgendaView->writeSettings(config);
117 } 118 }
118 if (mTimeSpanView) { 119 if (mTimeSpanView) {
119 mTimeSpanView->writeSettings(config); 120 mTimeSpanView->writeSettings(config);
120 } 121 }
121 if (mListView) { 122 if (mListView) {
122 mListView->writeSettings(config); 123 mListView->writeSettings(config);
123 } 124 }
124 if (mTodoView) { 125 if (mTodoView) {
125 mTodoView->saveLayout(config,"Todo View"); 126 mTodoView->saveLayout(config,"Todo View");
126 } 127 }
127} 128}
128 129
129void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) 130void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen )
130{ 131{
131 132
132 //mFlagShowNextxDays = false; 133 //mFlagShowNextxDays = false;
133 //if(view == mCurrentView) return; 134 //if(view == mCurrentView) return;
134 if ( view == 0 ) { 135 if ( view == 0 ) {
135 view = mCurrentView; 136 view = mCurrentView;
136 if ( view == 0 ) 137 if ( view == 0 )
137 return; 138 return;
138 } 139 }
139 bool full = fullScreen; 140 bool full = fullScreen;
140 if(view == mCurrentView && view != mWhatsNextView ) { 141 if(view == mCurrentView && view != mWhatsNextView ) {
141 if ( mCurrentAgendaView < 0 ) 142 if ( mCurrentAgendaView < 0 )
142 return; 143 return;
143 full = mMainView->leftFrame()->isVisible(); 144 full = mMainView->leftFrame()->isVisible();
144 } else { 145 } else {
145 mCurrentView = view; 146 mCurrentView = view;
146 147
147 // bool full = fullScreen; 148 // bool full = fullScreen;
148 bool isFull = !mMainView->leftFrame()->isVisible(); 149 bool isFull = !mMainView->leftFrame()->isVisible();
149 if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) 150 if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen )
150 full = true; 151 full = true;
151 if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) 152 if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen )
152 full = false; 153 full = false;
153 } 154 }
154 if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); 155 if ( mAgendaView ) mAgendaView->deleteSelectedDateTime();
155 raiseCurrentView( full ); 156 raiseCurrentView( full );
156 mMainView->processIncidenceSelection( 0 ); 157 mMainView->processIncidenceSelection( 0 );
157 mMainView->updateView(); 158 mMainView->updateView();
158 mMainView->adaptNavigationUnits(); 159 mMainView->adaptNavigationUnits();
159} 160}
160 161
161void KOViewManager::raiseCurrentView( bool fullScreen ) 162void KOViewManager::raiseCurrentView( bool fullScreen )
162{ 163{
163 //qDebug("raiseCurrentView "); 164 //qDebug("raiseCurrentView ");
164 mCurrentAgendaView = 0; 165 mCurrentAgendaView = 0;
165 int wid = mMainView->width() ; 166 int wid = mMainView->width() ;
166 int hei = mMainView->height(); 167 int hei = mMainView->height();
167 if ( mCurrentView == mMonthView ) { 168 if ( mCurrentView == mMonthView ) {
168 mMainView->navigatorBar()->show(); 169 mMainView->navigatorBar()->show();
169 hei -= mMainView->navigatorBar()->sizeHint().height(); 170 hei -= mMainView->navigatorBar()->sizeHint().height();
170 //mMainView->navigatorBar()->hide(); 171 //mMainView->navigatorBar()->hide();
171 } else { 172 } else {
172 mMainView->navigatorBar()->hide(); 173 mMainView->navigatorBar()->hide();
173 } 174 }
174 if ( fullScreen ) { 175 if ( fullScreen ) {
175 mMainView->leftFrame()->hide(); 176 mMainView->leftFrame()->hide();
176 } else { 177 } else {
177 mMainView->leftFrame()->show(); 178 mMainView->leftFrame()->show();
178 if ( KOPrefs::instance()->mVerticalScreen ) 179 if ( KOPrefs::instance()->mVerticalScreen )
179 hei -= mMainView->leftFrame()->height(); 180 hei -= mMainView->leftFrame()->height();
180 else 181 else
181 wid -= mMainView->leftFrame()->width(); 182 wid -= mMainView->leftFrame()->width();
182 } 183 }
183 184
184 if ( globalFlagBlockAgenda == 5 ) { 185 if ( globalFlagBlockAgenda == 5 ) {
185 globalFlagBlockAgenda = 4; 186 globalFlagBlockAgenda = 4;
186 globalFlagBlockAgendaItemPaint = 1; 187 globalFlagBlockAgendaItemPaint = 1;
187 } 188 }
188 mMainView->viewStack()->raiseWidget(mCurrentView); 189 mMainView->viewStack()->raiseWidget(mCurrentView);
189 if ( globalFlagBlockAgenda == 4 ) { 190 if ( globalFlagBlockAgenda == 4 ) {
190 if ( mCurrentView == mAgendaView ) { 191 if ( mCurrentView == mAgendaView ) {
191 //globalFlagBlockAgenda =1 ; 192 //globalFlagBlockAgenda =1 ;
192 if ( KOPrefs::instance()->mSetTimeToDayStartAt ) 193 if ( KOPrefs::instance()->mSetTimeToDayStartAt )
193 mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins ); 194 mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins );
194 else if ( KOPrefs::instance()->mCenterOnCurrentTime ) 195 else if ( KOPrefs::instance()->mCenterOnCurrentTime )
195 mAgendaView->setStartHour( QTime::currentTime ().hour() ); 196 mAgendaView->setStartHour( QTime::currentTime ().hour() );
196 qApp->processEvents(); 197 qApp->processEvents();
197 //qDebug("qApp->processEvents() "); 198 //qDebug("qApp->processEvents() ");
198 globalFlagBlockAgenda = 0; 199 globalFlagBlockAgenda = 0;
199 mAgendaView->repaintAgenda(); 200 mAgendaView->repaintAgenda();
200 201
201 } 202 }
202 globalFlagBlockAgenda = 0; 203 globalFlagBlockAgenda = 0;
203 } 204 }
204 //qDebug("raiseCurrentView ende "); 205 //qDebug("raiseCurrentView ende ");
205} 206}
206 207
207void KOViewManager::updateView() 208void KOViewManager::updateView()
208{ 209{
209 // qDebug("KOViewManager::updateView() "); 210 // qDebug("KOViewManager::updateView() ");
210 // if we are updating mTodoView, we get endless recursion 211 // if we are updating mTodoView, we get endless recursion
211 if ( mTodoView == mCurrentView ) 212 if ( mTodoView == mCurrentView )
212 return; 213 return;
213 if ( mCurrentView ) mCurrentView->updateView(); 214 if ( mCurrentView ) mCurrentView->updateView();
214 215
215} 216}
216 217
217void KOViewManager::updateView(const QDate &start, const QDate &end) 218void KOViewManager::updateView(const QDate &start, const QDate &end)
218{ 219{
219 // kdDebug() << "KOViewManager::updateView()" << endl; 220 // kdDebug() << "KOViewManager::updateView()" << endl;
220 221
221 if (mCurrentView) mCurrentView->showDates(start, end); 222 if (mCurrentView) mCurrentView->showDates(start, end);
222 223
223 if (mTodoView) mTodoView->updateView(); 224 if (mTodoView) mTodoView->updateView();
224} 225}
225 226
226 227
227void KOViewManager::updateWNview() 228void KOViewManager::updateWNview()
228{ 229{
229 if ( mCurrentView == mWhatsNextView && mWhatsNextView ) 230 if ( mCurrentView == mWhatsNextView && mWhatsNextView )
230 mWhatsNextView->updateView(); 231 mWhatsNextView->updateView();
231 232
232} 233}
233void KOViewManager::showWhatsNextView() 234void KOViewManager::showWhatsNextView()
234{ 235{
235 if (!mWhatsNextView) { 236 if (!mWhatsNextView) {
236 mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(), 237 mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(),
237 "KOViewManager::WhatsNextView"); 238 "KOViewManager::WhatsNextView");
238 mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog()); 239 mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog());
239 connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig())); 240 connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig()));
240 addView(mWhatsNextView); 241 addView(mWhatsNextView);
241 connect(this, SIGNAL( printWNV() ), 242 connect(this, SIGNAL( printWNV() ),
242 mWhatsNextView, SLOT( printMe() ) ); 243 mWhatsNextView, SLOT( printMe() ) );
243 } 244 }
244 globalFlagBlockAgenda = 1; 245 globalFlagBlockAgenda = 1;
245 showView(mWhatsNextView, true ); 246 showView(mWhatsNextView, true );
246 //mWhatsNextView->updateView(); 247 //mWhatsNextView->updateView();
247 248
248} 249}
249 250
250void KOViewManager::showListView() 251void KOViewManager::showListView()
251{ 252{
252 if (!mListView) { 253 if (!mListView) {
253 mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView"); 254 mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView");
254 addView(mListView); 255 addView(mListView);
255 256
256 connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)), 257 connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)),
257 mMainView, SLOT(showIncidence(Incidence *))); 258 mMainView, SLOT(showIncidence(Incidence *)));
258 connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)), 259 connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)),
259 mMainView, SLOT(editIncidence(Incidence *))); 260 mMainView, SLOT(editIncidence(Incidence *)));
260 connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)), 261 connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)),
261 mMainView, SLOT(deleteIncidence(Incidence *))); 262 mMainView, SLOT(deleteIncidence(Incidence *)));
262 connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ), 263 connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ),
263 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 264 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
264 connect( mListView, SIGNAL( signalNewEvent() ), 265 connect( mListView, SIGNAL( signalNewEvent() ),
265 mMainView, SLOT( newEvent() ) ); 266 mMainView, SLOT( newEvent() ) );
266 connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig())); 267 connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig()));
267 connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), 268 connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ),
268 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 269 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
269 connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), 270 connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ),
270 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 271 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
271 connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 272 connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
272 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 273 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
273 connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 274 connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
274 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 275 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
275 } 276 }
276 // bool temp = mFlagShowNextxDays; 277 // bool temp = mFlagShowNextxDays;
277 //globalFlagBlockPainting = true; 278 //globalFlagBlockPainting = true;
278 globalFlagBlockAgenda = 1; 279 globalFlagBlockAgenda = 1;
279 if ( KOPrefs::instance()->mListViewMonthTimespan ) 280 if ( KOPrefs::instance()->mListViewMonthTimespan ) {
281 mMainView->setBlockShowDates( true );
280 mMainView->dateNavigator()->selectMonth(); 282 mMainView->dateNavigator()->selectMonth();
283 mMainView->setBlockShowDates( false );
284 }
281 showView(mListView, KOPrefs::instance()->mFullViewTodo); 285 showView(mListView, KOPrefs::instance()->mFullViewTodo);
282 //mFlagShowNextxDays = temp; 286 //mFlagShowNextxDays = temp;
283} 287}
284 288
285void KOViewManager::showAgendaView( bool fullScreen ) 289void KOViewManager::showAgendaView( bool fullScreen )
286{ 290{
287 291
288 mMainView->dialogManager()->hideSearchDialog(); 292 mMainView->dialogManager()->hideSearchDialog();
289 // qDebug("KOViewManager::showAgendaView "); 293 // qDebug("KOViewManager::showAgendaView ");
290 bool full; 294 bool full;
291 full = fullScreen; 295 full = fullScreen;
292 if (!mAgendaView) { 296 if (!mAgendaView) {
293 full = false; 297 full = false;
294 mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView"); 298 mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView");
295 addView(mAgendaView); 299 addView(mAgendaView);
296#ifndef DESKTOP_VERSION 300#ifndef DESKTOP_VERSION
297 QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold ); 301 QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold );
298#endif 302#endif
299 connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )), 303 connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )),
300 mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) )); 304 mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) ));
301 305
302 // SIGNALS/SLOTS FOR DAY/WEEK VIEW 306 // SIGNALS/SLOTS FOR DAY/WEEK VIEW
303 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)), 307 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)),
304 mMainView, SLOT(newEvent(QDateTime))); 308 mMainView, SLOT(newEvent(QDateTime)));
305 // connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)), 309 // connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)),
306 // mMainView, SLOT(newEvent(QDateTime,QDateTime))); 310 // mMainView, SLOT(newEvent(QDateTime,QDateTime)));
307 connect(mAgendaView,SIGNAL(newEventSignal(QDate)), 311 connect(mAgendaView,SIGNAL(newEventSignal(QDate)),
308 mMainView, SLOT(newEvent(QDate))); 312 mMainView, SLOT(newEvent(QDate)));
309 313
310 connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)), 314 connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)),
311 mMainView, SLOT(editIncidence(Incidence *))); 315 mMainView, SLOT(editIncidence(Incidence *)));
312 connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)), 316 connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)),
313 mMainView, SLOT(showIncidence(Incidence *))); 317 mMainView, SLOT(showIncidence(Incidence *)));
314 connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)), 318 connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)),
315 mMainView, SLOT(deleteIncidence(Incidence *))); 319 mMainView, SLOT(deleteIncidence(Incidence *)));
316 320
317 connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ), 321 connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ),
318 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 322 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
319 323
320 connect(mAgendaView, SIGNAL( toggleExpand() ), 324 connect(mAgendaView, SIGNAL( toggleExpand() ),
321 mMainView, SLOT( toggleExpand() ) ); 325 mMainView, SLOT( toggleExpand() ) );
322 326
323 connect(mMainView, SIGNAL( calendarViewExpanded( bool ) ), 327 connect(mMainView, SIGNAL( calendarViewExpanded( bool ) ),
324 mAgendaView, SLOT( setExpandedButton( bool ) ) ); 328 mAgendaView, SLOT( setExpandedButton( bool ) ) );
325 connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ), 329 connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ),
326 mMainView, SLOT(cloneIncidence(Incidence *) ) ) ; 330 mMainView, SLOT(cloneIncidence(Incidence *) ) ) ;
327 connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ), 331 connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ),
328 mMainView, SLOT(cancelIncidence(Incidence *) ) ) ; 332 mMainView, SLOT(cancelIncidence(Incidence *) ) ) ;
329 connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig())); 333 connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig()));
330 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView, 334 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView,
331 SLOT( updateTodo( Todo *, int ) ) ); 335 SLOT( updateTodo( Todo *, int ) ) );
332 connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )), 336 connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )),
333 mMainView, SIGNAL( todoModified( Todo *, int ))); 337 mMainView, SIGNAL( todoModified( Todo *, int )));
334 connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 338 connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
335 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 339 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
336 connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 340 connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
337 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 341 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
338 mAgendaView->readSettings(); 342 mAgendaView->readSettings();
339 mAgendaView->updateConfig(); 343 mAgendaView->updateConfig();
340 } 344 }
341 345
342 showView( mAgendaView, full); 346 showView( mAgendaView, full);
343 347
344} 348}
345 349
346void KOViewManager::showDayView() 350void KOViewManager::showDayView()
347{ 351{
348 mFlagShowNextxDays = false; 352 mFlagShowNextxDays = false;
349 globalFlagBlockLabel = 1; 353 globalFlagBlockLabel = 1;
350 globalFlagBlockAgenda = 1; 354 globalFlagBlockAgenda = 1;
351 if ( mCurrentAgendaView != 1 ) 355 if ( mCurrentAgendaView != 1 )
352 mCurrentAgendaView = -1; 356 mCurrentAgendaView = -1;
353 showAgendaView(); 357 showAgendaView();
354 qApp->processEvents(); 358 qApp->processEvents();
355 globalFlagBlockAgenda = 2; 359 globalFlagBlockAgenda = 2;
356 globalFlagBlockLabel = 0; 360 globalFlagBlockLabel = 0;
357 mMainView->dateNavigator()->selectDates( 1 ); 361 mMainView->dateNavigator()->selectDates( 1 );
358 mCurrentAgendaView = 1 ; 362 mCurrentAgendaView = 1 ;
359 363
360} 364}
361 365
362void KOViewManager::showWorkWeekView() 366void KOViewManager::showWorkWeekView()
363{ 367{
364 mFlagShowNextxDays = false; 368 mFlagShowNextxDays = false;
365 globalFlagBlockAgenda = 1; 369 globalFlagBlockAgenda = 1;
366 globalFlagBlockLabel = 1; 370 globalFlagBlockLabel = 1;
367 if ( mCurrentAgendaView != 5 ) 371 if ( mCurrentAgendaView != 5 )
368 mCurrentAgendaView = -1; 372 mCurrentAgendaView = -1;
369 showAgendaView(); 373 showAgendaView();
370 qApp->processEvents(); 374 qApp->processEvents();
371 globalFlagBlockAgenda = 2; 375 globalFlagBlockAgenda = 2;
372 globalFlagBlockLabel = 0; 376 globalFlagBlockLabel = 0;
373 mMainView->dateNavigator()->selectWorkWeek(); 377 mMainView->dateNavigator()->selectWorkWeek();
374 mCurrentAgendaView = 5 ; 378 mCurrentAgendaView = 5 ;
375 379
376} 380}
377 381
378void KOViewManager::showWeekView() 382void KOViewManager::showWeekView()
379{ 383{
380 /* 384 /*
381 globalFlagBlockAgenda = 2; 385 globalFlagBlockAgenda = 2;
382 qDebug("4globalFlagBlockAgenda = 2; "); 386 qDebug("4globalFlagBlockAgenda = 2; ");
383 //globalFlagBlockPainting = true; 387 //globalFlagBlockPainting = true;
384 mMainView->dateNavigator()->selectWeek(); 388 mMainView->dateNavigator()->selectWeek();
385 showAgendaView(); 389 showAgendaView();
386 */ 390 */
387 391
388 392
389 mFlagShowNextxDays = false; 393 mFlagShowNextxDays = false;
390 globalFlagBlockAgenda = 1; 394 globalFlagBlockAgenda = 1;
391 globalFlagBlockLabel = 1; 395 globalFlagBlockLabel = 1;
392 if ( mCurrentAgendaView != 7 ) 396 if ( mCurrentAgendaView != 7 )
393 mCurrentAgendaView = -1; 397 mCurrentAgendaView = -1;
394 showAgendaView(); 398 showAgendaView();
395 qApp->processEvents(); 399 qApp->processEvents();
396 globalFlagBlockAgenda = 2; 400 globalFlagBlockAgenda = 2;
397 globalFlagBlockLabel = 0; 401 globalFlagBlockLabel = 0;
398 mMainView->dateNavigator()->selectWeek(); 402 mMainView->dateNavigator()->selectWeek();
399 mCurrentAgendaView = 7 ; 403 mCurrentAgendaView = 7 ;
400} 404}
401 405
402void KOViewManager::showNextXView() 406void KOViewManager::showNextXView()
403{ 407{
404 408
405 globalFlagBlockAgenda = 1; 409 globalFlagBlockAgenda = 1;
406 if ( mCurrentAgendaView != 3 ) 410 if ( mCurrentAgendaView != 3 )
407 mCurrentAgendaView = -1; 411 mCurrentAgendaView = -1;
408 showAgendaView(KOPrefs::instance()->mFullViewMonth); 412 showAgendaView(KOPrefs::instance()->mFullViewMonth);
409 globalFlagBlockAgenda = 2; 413 globalFlagBlockAgenda = 2;
410 mMainView->dateNavigator()->selectDates( QDate::currentDate(), 414 mMainView->dateNavigator()->selectDates( QDate::currentDate(),
411 KOPrefs::instance()->mNextXDays ); 415 KOPrefs::instance()->mNextXDays );
412 mFlagShowNextxDays = true; 416 mFlagShowNextxDays = true;
413 mCurrentAgendaView = 3 ; 417 mCurrentAgendaView = 3 ;
414} 418}
415bool KOViewManager::showsNextDays() 419bool KOViewManager::showsNextDays()
416{ 420{
417 return mFlagShowNextxDays; 421 return mFlagShowNextxDays;
418} 422}
419void KOViewManager::showMonthView() 423void KOViewManager::showMonthView()
420{ 424{
421 if (!mMonthView) { 425 if (!mMonthView) {
422 mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView"); 426 mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView");
423 427
424 addView(mMonthView); 428 addView(mMonthView);
425 // mMonthView->show(); 429 // mMonthView->show();
426 // SIGNALS/SLOTS FOR MONTH VIEW 430 // SIGNALS/SLOTS FOR MONTH VIEW
427 connect(mMonthView, SIGNAL(newEventSignal(QDateTime)), 431 connect(mMonthView, SIGNAL(newEventSignal(QDateTime)),
428 mMainView, SLOT(newEvent(QDateTime))); 432 mMainView, SLOT(newEvent(QDateTime)));
429 433
430 connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)), 434 connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)),
431 mMainView, SLOT(showIncidence(Incidence *))); 435 mMainView, SLOT(showIncidence(Incidence *)));
432 connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)), 436 connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)),
433 mMainView, SLOT(editIncidence(Incidence *))); 437 mMainView, SLOT(editIncidence(Incidence *)));
434 connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)), 438 connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)),
435 mMainView, SLOT(deleteIncidence(Incidence *))); 439 mMainView, SLOT(deleteIncidence(Incidence *)));
436 440
437 connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ), 441 connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ),
438 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 442 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
439 connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), 443 connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ),
440 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 444 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
441 connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), 445 connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ),
442 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 446 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
443 447
444 connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 448 connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
445 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 449 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
446 connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 450 connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
447 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 451 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
448 connect( mMonthView, SIGNAL( selectWeekNum( int ) ), 452 connect( mMonthView, SIGNAL( selectWeekNum( int ) ),
449 mMainView, SLOT ( selectWeekNum( int ) ) ); 453 mMainView, SLOT ( selectWeekNum( int ) ) );
450 connect( mMonthView, SIGNAL( showDaySignal( QDate ) ), 454 connect( mMonthView, SIGNAL( showDaySignal( QDate ) ),
451 mMainView, SLOT ( showDay( QDate ) ) ); 455 mMainView, SLOT ( showDay( QDate ) ) );
452 connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig())); 456 connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig()));
453 mMonthView->updateConfig(); 457 mMonthView->updateConfig();
454 } 458 }
455 459
456 globalFlagBlockAgenda = 1; 460 globalFlagBlockAgenda = 1;
457 //mFlagShowNextxDays = false; 461 //mFlagShowNextxDays = false;
458 // if(mMonthView == mCurrentView) return; 462 // if(mMonthView == mCurrentView) return;
459 mMainView->dateNavigator()->selectMonth(); 463 mMainView->dateNavigator()->selectMonth();
460 // DateList tmpList = mMainView->dateNavigator()->selectedDates( ); 464 // DateList tmpList = mMainView->dateNavigator()->selectedDates( );
461 //mMonthView->showDates(tmpList.first(), tmpList.last()); 465 //mMonthView->showDates(tmpList.first(), tmpList.last());
462 466
463 showView(mMonthView, true ); 467 showView(mMonthView, true );
464 468
465} 469}
466 470
467void KOViewManager::showTodoView() 471void KOViewManager::showTodoView()
468{ 472{
469 //mFlagShowNextxDays = false; 473 //mFlagShowNextxDays = false;
470 if ( !mTodoView ) { 474 if ( !mTodoView ) {
471 mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(), 475 mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(),
472 "KOViewManager::TodoView" ); 476 "KOViewManager::TodoView" );
473 477
474 addView( mTodoView ); 478 addView( mTodoView );
475 // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold ); 479 // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold );
476 480
477 // SIGNALS/SLOTS FOR TODO VIEW 481 // SIGNALS/SLOTS FOR TODO VIEW
478 connect( mTodoView, SIGNAL( newTodoSignal() ), 482 connect( mTodoView, SIGNAL( newTodoSignal() ),
479 mMainView, SLOT( newTodo() ) ); 483 mMainView, SLOT( newTodo() ) );
480 connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ), 484 connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ),
481 mMainView, SLOT( newSubTodo( Todo *) ) ); 485 mMainView, SLOT( newSubTodo( Todo *) ) );
482 connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ), 486 connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ),
483 mMainView, SLOT( showTodo( Todo * ) ) ); 487 mMainView, SLOT( showTodo( Todo * ) ) );
484 connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ), 488 connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ),
485 mMainView, SLOT( editTodo( Todo * ) ) ); 489 mMainView, SLOT( editTodo( Todo * ) ) );
486 connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ), 490 connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ),
487 mMainView, SLOT( deleteTodo( Todo * ) ) ); 491 mMainView, SLOT( deleteTodo( Todo * ) ) );
488 connect( mTodoView, SIGNAL( purgeCompletedSignal() ), 492 connect( mTodoView, SIGNAL( purgeCompletedSignal() ),
489 mMainView, SLOT( purgeCompleted() ) ); 493 mMainView, SLOT( purgeCompleted() ) );
490 494
491 connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ), 495 connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ),
492 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 496 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
493 497
494 connect( mMainView, SIGNAL( configChanged() ), mTodoView, 498 connect( mMainView, SIGNAL( configChanged() ), mTodoView,
495 SLOT( updateConfig() ) ); 499 SLOT( updateConfig() ) );
496 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView, 500 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView,
497 SLOT( updateTodo( Todo *, int ) ) ); 501 SLOT( updateTodo( Todo *, int ) ) );
498 connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ), 502 connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ),
499 mMainView, SIGNAL ( todoModified( Todo *, int ) ) ); 503 mMainView, SIGNAL ( todoModified( Todo *, int ) ) );
500 connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ), 504 connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ),
501 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 505 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
502 connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ), 506 connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ),
503 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 507 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
504 connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ), 508 connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ),
505 mMainView, SLOT ( todo_unsub( Todo * ) ) ); 509 mMainView, SLOT ( todo_unsub( Todo * ) ) );
506 connect( mTodoView, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 510 connect( mTodoView, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
507 mMainView, SLOT ( todo_resub( Todo *, Todo *) ) ); 511 mMainView, SLOT ( todo_resub( Todo *, Todo *) ) );
508 connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ), 512 connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ),
509 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 513 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
510 connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ), 514 connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ),
511 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 515 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
512 KConfig *config = KOGlobals::config(); 516 KConfig *config = KOGlobals::config();
513 mTodoView->restoreLayout(config,"Todo View"); 517 mTodoView->restoreLayout(config,"Todo View");
514 mTodoView->setNavigator( mMainView->dateNavigator() ); 518 mTodoView->setNavigator( mMainView->dateNavigator() );
515 } 519 }
516 520
517 globalFlagBlockAgenda = 1; 521 globalFlagBlockAgenda = 1;
518 showView( mTodoView, true ); 522 showView( mTodoView, true );
519 523
520} 524}
521 525
522void KOViewManager::showJournalView() 526void KOViewManager::showJournalView()
523{ 527{
524 //mFlagShowNextxDays = false; 528 //mFlagShowNextxDays = false;
525 if (!mJournalView) { 529 if (!mJournalView) {
526 mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(), 530 mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(),
527 "KOViewManager::JournalView"); 531 "KOViewManager::JournalView");
528 connect( mMainView, SIGNAL( configChanged() ), mJournalView, 532 connect( mMainView, SIGNAL( configChanged() ), mJournalView,
529 SLOT( updateConfig() ) ); 533 SLOT( updateConfig() ) );
530 connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) ); 534 connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) );
531 addView(mJournalView); 535 addView(mJournalView);
532 } 536 }
533 537
534 showView(mJournalView); 538 showView(mJournalView);
535} 539}
536 540
537void KOViewManager::showTimeSpanView() 541void KOViewManager::showTimeSpanView()
538{ 542{
539 //mFlagShowNextxDays = false; 543 //mFlagShowNextxDays = false;
540 if (!mTimeSpanView) { 544 if (!mTimeSpanView) {
541 mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(), 545 mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(),
542 "KOViewManager::TimeSpanView"); 546 "KOViewManager::TimeSpanView");
543 addView(mTimeSpanView); 547 addView(mTimeSpanView);
544 548
545 mTimeSpanView->readSettings(); 549 mTimeSpanView->readSettings();
546 } 550 }
547 551
548 showView(mTimeSpanView); 552 showView(mTimeSpanView);
549} 553}
550 554
551Incidence *KOViewManager::currentSelection() 555Incidence *KOViewManager::currentSelection()
552{ 556{
553 if (!mCurrentView) return 0; 557 if (!mCurrentView) return 0;
554 if ( mCurrentView == mListView ) { 558 if ( mCurrentView == mListView ) {
555 if ( mListView->currentItem() ) 559 if ( mListView->currentItem() )
556 return mListView->currentItem(); 560 return mListView->currentItem();
557 } 561 }
558 return mCurrentView->selectedIncidences().first(); 562 return mCurrentView->selectedIncidences().first();
559} 563}
560 564
561QDate KOViewManager::currentSelectionDate() 565QDate KOViewManager::currentSelectionDate()
562{ 566{
563 QDate qd; 567 QDate qd;
564 if (mCurrentView) { 568 if (mCurrentView) {
565 DateList qvl = mCurrentView->selectedDates(); 569 DateList qvl = mCurrentView->selectedDates();
566 if (!qvl.isEmpty()) qd = qvl.first(); 570 if (!qvl.isEmpty()) qd = qvl.first();
567 } 571 }
568 return qd; 572 return qd;
569} 573}
570 574
571void KOViewManager::addView(KOrg::BaseView *view) 575void KOViewManager::addView(KOrg::BaseView *view)
572{ 576{
573#if QT_VERSION >= 300 577#if QT_VERSION >= 300
574 mMainView->viewStack()->addWidget( view ); 578 mMainView->viewStack()->addWidget( view );
575#else 579#else
576 mMainView->viewStack()->addWidget( view, 1 ); 580 mMainView->viewStack()->addWidget( view, 1 );
577#endif 581#endif
578} 582}
579 583
580void KOViewManager::setDocumentId( const QString &id ) 584void KOViewManager::setDocumentId( const QString &id )
581{ 585{
582 if (mTodoView) mTodoView->setDocumentId( id ); 586 if (mTodoView) mTodoView->setDocumentId( id );
583} 587}