summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-01-20 01:24:07 (UTC)
committer zautrix <zautrix>2005-01-20 01:24:07 (UTC)
commitdbb59deb5c0949f83b2d6fd79ec599e7b9e8ebf1 (patch) (unidiff)
tree3fac729225892ee1a4570a5852ee287f35e74ce7
parentade7e8fcdcf45d5bc73ea73da6f9a1b06964a64e (diff)
downloadkdepimpi-dbb59deb5c0949f83b2d6fd79ec599e7b9e8ebf1.zip
kdepimpi-dbb59deb5c0949f83b2d6fd79ec599e7b9e8ebf1.tar.gz
kdepimpi-dbb59deb5c0949f83b2d6fd79ec599e7b9e8ebf1.tar.bz2
more view fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp4
-rw-r--r--korganizer/komonthview.cpp26
-rw-r--r--korganizer/komonthview.h1
-rw-r--r--korganizer/koviewmanager.cpp3
4 files changed, 23 insertions, 11 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index f9af769..8f05276 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,3885 +1,3885 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Requires the Qt and KDE widget libraries, available at no cost at 4 Requires the Qt and KDE widget libraries, available at no cost at
5 http://www.troll.no and http://www.kde.org respectively 5 http://www.troll.no and http://www.kde.org respectively
6 6
7 Copyright (c) 1997, 1998, 1999 7 Copyright (c) 1997, 1998, 1999
8 Preston Brown (preston.brown@yale.edu) 8 Preston Brown (preston.brown@yale.edu)
9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) 9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl)
10 Ian Dawes (iadawes@globalserve.net) 10 Ian Dawes (iadawes@globalserve.net)
11 Laszlo Boloni (boloni@cs.purdue.edu) 11 Laszlo Boloni (boloni@cs.purdue.edu)
12 12
13 Copyright (c) 2000, 2001, 2002 13 Copyright (c) 2000, 2001, 2002
14 Cornelius Schumacher <schumacher@kde.org> 14 Cornelius Schumacher <schumacher@kde.org>
15 15
16 This program is free software; you can redistribute it and/or modify 16 This program is free software; you can redistribute it and/or modify
17 it under the terms of the GNU General Public License as published by 17 it under the terms of the GNU General Public License as published by
18 the Free Software Foundation; either version 2 of the License, or 18 the Free Software Foundation; either version 2 of the License, or
19 (at your option) any later version. 19 (at your option) any later version.
20 20
21 This program is distributed in the hope that it will be useful, 21 This program is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of 22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
24 GNU General Public License for more details. 24 GNU General Public License for more details.
25 25
26 You should have received a copy of the GNU General Public License 26 You should have received a copy of the GNU General Public License
27 along with this program; if not, write to the Free Software 27 along with this program; if not, write to the Free Software
28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29*/ 29*/
30 30
31#include <stdlib.h> 31#include <stdlib.h>
32 32
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qradiobutton.h> 34#include <qradiobutton.h>
35#include <qbuttongroup.h> 35#include <qbuttongroup.h>
36#include <qlayout.h> 36#include <qlayout.h>
37#include <qclipboard.h> 37#include <qclipboard.h>
38#include <qcursor.h> 38#include <qcursor.h>
39#include <qmessagebox.h> 39#include <qmessagebox.h>
40#include <qprogressbar.h> 40#include <qprogressbar.h>
41#include <qmultilineedit.h> 41#include <qmultilineedit.h>
42#include <qtimer.h> 42#include <qtimer.h>
43#include <qwidgetstack.h> 43#include <qwidgetstack.h>
44#include <qptrlist.h> 44#include <qptrlist.h>
45#include <qregexp.h> 45#include <qregexp.h>
46#include <qgroupbox.h> 46#include <qgroupbox.h>
47#include <qfile.h> 47#include <qfile.h>
48#include <qdir.h> 48#include <qdir.h>
49#ifndef KORG_NOSPLITTER 49#ifndef KORG_NOSPLITTER
50#include <qsplitter.h> 50#include <qsplitter.h>
51#endif 51#endif
52 52
53#include <kglobal.h> 53#include <kglobal.h>
54#include <kdebug.h> 54#include <kdebug.h>
55#include <kstandarddirs.h> 55#include <kstandarddirs.h>
56#include <kfiledialog.h> 56#include <kfiledialog.h>
57#include <kmessagebox.h> 57#include <kmessagebox.h>
58#include <knotifyclient.h> 58#include <knotifyclient.h>
59#include <kconfig.h> 59#include <kconfig.h>
60 60
61#include <libkdepim/ksyncprefsdialog.h> 61#include <libkdepim/ksyncprefsdialog.h>
62#include <krun.h> 62#include <krun.h>
63#include <kdirwatch.h> 63#include <kdirwatch.h>
64#include <libkdepim/kdatepicker.h> 64#include <libkdepim/kdatepicker.h>
65#include <libkdepim/ksyncprofile.h> 65#include <libkdepim/ksyncprofile.h>
66#include <libkdepim/kpimglobalprefs.h> 66#include <libkdepim/kpimglobalprefs.h>
67 67
68#include <libkcal/vcaldrag.h> 68#include <libkcal/vcaldrag.h>
69#include <libkcal/icaldrag.h> 69#include <libkcal/icaldrag.h>
70#include <libkcal/icalformat.h> 70#include <libkcal/icalformat.h>
71#include <libkcal/vcalformat.h> 71#include <libkcal/vcalformat.h>
72#include <libkcal/scheduler.h> 72#include <libkcal/scheduler.h>
73#include <libkcal/calendarlocal.h> 73#include <libkcal/calendarlocal.h>
74#include <libkcal/journal.h> 74#include <libkcal/journal.h>
75#include <libkcal/calfilter.h> 75#include <libkcal/calfilter.h>
76#include <libkcal/attendee.h> 76#include <libkcal/attendee.h>
77#include <libkcal/dndfactory.h> 77#include <libkcal/dndfactory.h>
78#include <libkcal/freebusy.h> 78#include <libkcal/freebusy.h>
79#include <libkcal/filestorage.h> 79#include <libkcal/filestorage.h>
80#include <libkcal/calendarresources.h> 80#include <libkcal/calendarresources.h>
81#include <libkcal/qtopiaformat.h> 81#include <libkcal/qtopiaformat.h>
82#include "../kalarmd/alarmdialog.h" 82#include "../kalarmd/alarmdialog.h"
83 83
84#ifndef DESKTOP_VERSION 84#ifndef DESKTOP_VERSION
85#include <libkcal/sharpformat.h> 85#include <libkcal/sharpformat.h>
86#include <externalapphandler.h> 86#include <externalapphandler.h>
87#endif 87#endif
88#include <libkcal/phoneformat.h> 88#include <libkcal/phoneformat.h>
89#ifndef KORG_NOMAIL 89#ifndef KORG_NOMAIL
90#include "komailclient.h" 90#include "komailclient.h"
91#endif 91#endif
92#ifndef KORG_NOPRINTER 92#ifndef KORG_NOPRINTER
93#include "calprinter.h" 93#include "calprinter.h"
94#endif 94#endif
95#ifndef KORG_NOPLUGINS 95#ifndef KORG_NOPLUGINS
96#include "kocore.h" 96#include "kocore.h"
97#endif 97#endif
98#include "koeventeditor.h" 98#include "koeventeditor.h"
99#include "kotodoeditor.h" 99#include "kotodoeditor.h"
100#include "koprefs.h" 100#include "koprefs.h"
101#include "koeventviewerdialog.h" 101#include "koeventviewerdialog.h"
102#include "publishdialog.h" 102#include "publishdialog.h"
103#include "kofilterview.h" 103#include "kofilterview.h"
104#include "koglobals.h" 104#include "koglobals.h"
105#include "koviewmanager.h" 105#include "koviewmanager.h"
106#include "koagendaview.h" 106#include "koagendaview.h"
107#include "kodialogmanager.h" 107#include "kodialogmanager.h"
108#include "outgoingdialog.h" 108#include "outgoingdialog.h"
109#include "incomingdialog.h" 109#include "incomingdialog.h"
110#include "statusdialog.h" 110#include "statusdialog.h"
111#include "kdatenavigator.h" 111#include "kdatenavigator.h"
112#include "kotodoview.h" 112#include "kotodoview.h"
113#include "datenavigator.h" 113#include "datenavigator.h"
114#include "resourceview.h" 114#include "resourceview.h"
115#include "navigatorbar.h" 115#include "navigatorbar.h"
116#include "searchdialog.h" 116#include "searchdialog.h"
117#include "mainwindow.h" 117#include "mainwindow.h"
118 118
119#include "calendarview.h" 119#include "calendarview.h"
120#ifndef DESKTOP_VERSION 120#ifndef DESKTOP_VERSION
121#include <qtopia/alarmserver.h> 121#include <qtopia/alarmserver.h>
122#endif 122#endif
123#ifndef _WIN32_ 123#ifndef _WIN32_
124#include <stdlib.h> 124#include <stdlib.h>
125#include <stdio.h> 125#include <stdio.h>
126#include <unistd.h> 126#include <unistd.h>
127#else 127#else
128#include <qprocess.h> 128#include <qprocess.h>
129#endif 129#endif
130 130
131#ifdef DESKTOP_VERSION 131#ifdef DESKTOP_VERSION
132#include <kabc/stdaddressbook.h> 132#include <kabc/stdaddressbook.h>
133#endif 133#endif
134using namespace KOrg; 134using namespace KOrg;
135using namespace KCal; 135using namespace KCal;
136extern int globalFlagBlockAgenda; 136extern int globalFlagBlockAgenda;
137extern int globalFlagBlockStartup; 137extern int globalFlagBlockStartup;
138 138
139 139
140 140
141class KOBeamPrefs : public QDialog 141class KOBeamPrefs : public QDialog
142{ 142{
143 public: 143 public:
144 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : 144 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) :
145 QDialog( parent, name, true ) 145 QDialog( parent, name, true )
146 { 146 {
147 setCaption( i18n("Beam Options") ); 147 setCaption( i18n("Beam Options") );
148 QVBoxLayout* lay = new QVBoxLayout( this ); 148 QVBoxLayout* lay = new QVBoxLayout( this );
149 lay->setSpacing( 3 ); 149 lay->setSpacing( 3 );
150 lay->setMargin( 3 ); 150 lay->setMargin( 3 );
151 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); 151 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this );
152 lay->addWidget( format ); 152 lay->addWidget( format );
153 format->setExclusive ( true ) ; 153 format->setExclusive ( true ) ;
154 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); 154 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this );
155 lay->addWidget( time ); time->setExclusive ( true ) ; 155 lay->addWidget( time ); time->setExclusive ( true ) ;
156 vcal = new QRadioButton(" vCalendar ", format ); 156 vcal = new QRadioButton(" vCalendar ", format );
157 ical = new QRadioButton(" iCalendar ", format ); 157 ical = new QRadioButton(" iCalendar ", format );
158 vcal->setChecked( true ); 158 vcal->setChecked( true );
159 tz = new QRadioButton(i18n(" With timezone "), time ); 159 tz = new QRadioButton(i18n(" With timezone "), time );
160 local = new QRadioButton(i18n(" Local time "), time ); 160 local = new QRadioButton(i18n(" Local time "), time );
161 tz->setChecked( true ); 161 tz->setChecked( true );
162 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); 162 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this );
163 lay->addWidget( ok ); 163 lay->addWidget( ok );
164 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 164 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
165 lay->addWidget( cancel ); 165 lay->addWidget( cancel );
166 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 166 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
167 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 167 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
168 resize( 200, 200 ); 168 resize( 200, 200 );
169 } 169 }
170 170
171 bool beamVcal() { return vcal->isChecked(); } 171 bool beamVcal() { return vcal->isChecked(); }
172 bool beamLocal() { return local->isChecked(); } 172 bool beamLocal() { return local->isChecked(); }
173private: 173private:
174 QRadioButton* vcal, *ical, *local, *tz; 174 QRadioButton* vcal, *ical, *local, *tz;
175}; 175};
176class KOCatPrefs : public QDialog 176class KOCatPrefs : public QDialog
177{ 177{
178 public: 178 public:
179 KOCatPrefs( QWidget *parent=0, const char *name=0 ) : 179 KOCatPrefs( QWidget *parent=0, const char *name=0 ) :
180 QDialog( parent, name, true ) 180 QDialog( parent, name, true )
181 { 181 {
182 setCaption( i18n("Manage new Categories") ); 182 setCaption( i18n("Manage new Categories") );
183 QVBoxLayout* lay = new QVBoxLayout( this ); 183 QVBoxLayout* lay = new QVBoxLayout( this );
184 lay->setSpacing( 3 ); 184 lay->setSpacing( 3 );
185 lay->setMargin( 3 ); 185 lay->setMargin( 3 );
186 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); 186 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this );
187 lay->addWidget( lab ); 187 lay->addWidget( lab );
188 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 188 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
189 lay->addWidget( format ); 189 lay->addWidget( format );
190 format->setExclusive ( true ) ; 190 format->setExclusive ( true ) ;
191 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 191 addCatBut = new QRadioButton(i18n("Add to category list"), format );
192 new QRadioButton(i18n("Remove from Events/Todos"), format ); 192 new QRadioButton(i18n("Remove from Events/Todos"), format );
193 addCatBut->setChecked( true ); 193 addCatBut->setChecked( true );
194 QPushButton * ok = new QPushButton( i18n("OK"), this ); 194 QPushButton * ok = new QPushButton( i18n("OK"), this );
195 lay->addWidget( ok ); 195 lay->addWidget( ok );
196 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 196 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
197 lay->addWidget( cancel ); 197 lay->addWidget( cancel );
198 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 198 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
199 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 199 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
200 resize( 200, 200 ); 200 resize( 200, 200 );
201 } 201 }
202 202
203 bool addCat() { return addCatBut->isChecked(); } 203 bool addCat() { return addCatBut->isChecked(); }
204private: 204private:
205 QRadioButton* addCatBut; 205 QRadioButton* addCatBut;
206}; 206};
207 207
208 208
209 209
210CalendarView::CalendarView( CalendarResources *calendar, 210CalendarView::CalendarView( CalendarResources *calendar,
211 QWidget *parent, const char *name ) 211 QWidget *parent, const char *name )
212 : CalendarViewBase( parent, name ), 212 : CalendarViewBase( parent, name ),
213 mCalendar( calendar ), 213 mCalendar( calendar ),
214 mResourceManager( calendar->resourceManager() ) 214 mResourceManager( calendar->resourceManager() )
215{ 215{
216 216
217 mEventEditor = 0; 217 mEventEditor = 0;
218 mTodoEditor = 0; 218 mTodoEditor = 0;
219 219
220 init(); 220 init();
221} 221}
222 222
223CalendarView::CalendarView( Calendar *calendar, 223CalendarView::CalendarView( Calendar *calendar,
224 QWidget *parent, const char *name ) 224 QWidget *parent, const char *name )
225 : CalendarViewBase( parent, name ), 225 : CalendarViewBase( parent, name ),
226 mCalendar( calendar ), 226 mCalendar( calendar ),
227 mResourceManager( 0 ) 227 mResourceManager( 0 )
228{ 228{
229 229
230 mEventEditor = 0; 230 mEventEditor = 0;
231 mTodoEditor = 0; 231 mTodoEditor = 0;
232 init();} 232 init();}
233 233
234void CalendarView::init() 234void CalendarView::init()
235{ 235{
236 mBlockShowDates = false; 236 mBlockShowDates = false;
237 beamDialog = new KOBeamPrefs(); 237 beamDialog = new KOBeamPrefs();
238 mDatePickerMode = 0; 238 mDatePickerMode = 0;
239 mCurrentSyncDevice = ""; 239 mCurrentSyncDevice = "";
240 writeLocale(); 240 writeLocale();
241 mViewManager = new KOViewManager( this ); 241 mViewManager = new KOViewManager( this );
242 mDialogManager = new KODialogManager( this ); 242 mDialogManager = new KODialogManager( this );
243 mEventViewerDialog = 0; 243 mEventViewerDialog = 0;
244 mModified = false; 244 mModified = false;
245 mReadOnly = false; 245 mReadOnly = false;
246 mSelectedIncidence = 0; 246 mSelectedIncidence = 0;
247 mCalPrinter = 0; 247 mCalPrinter = 0;
248 mFilters.setAutoDelete(true); 248 mFilters.setAutoDelete(true);
249 249
250 mCalendar->registerObserver( this ); 250 mCalendar->registerObserver( this );
251 // TODO: Make sure that view is updated, when calendar is changed. 251 // TODO: Make sure that view is updated, when calendar is changed.
252 252
253 mStorage = new FileStorage( mCalendar ); 253 mStorage = new FileStorage( mCalendar );
254 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 254 mNavigator = new DateNavigator( this, "datevav", mViewManager );
255 255
256 QBoxLayout *topLayout = (QBoxLayout*)layout(); 256 QBoxLayout *topLayout = (QBoxLayout*)layout();
257#ifndef KORG_NOSPLITTER 257#ifndef KORG_NOSPLITTER
258 // create the main layout frames. 258 // create the main layout frames.
259 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 259 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
260 topLayout->addWidget(mPanner); 260 topLayout->addWidget(mPanner);
261 261
262 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 262 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
263 "CalendarView::LeftFrame"); 263 "CalendarView::LeftFrame");
264 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 264 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
265 265
266 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, 266 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE,
267 "CalendarView::DateNavigator", QDate::currentDate() ); 267 "CalendarView::DateNavigator", QDate::currentDate() );
268 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 268 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
269 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 269 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
270 mTodoList->setNavigator( mNavigator ); 270 mTodoList->setNavigator( mNavigator );
271 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 271 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
272 272
273#ifdef KORG_NORESOURCEVIEW 273#ifdef KORG_NORESOURCEVIEW
274 mResourceView = 0; 274 mResourceView = 0;
275#else 275#else
276 if ( mResourceManager ) { 276 if ( mResourceManager ) {
277 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 277 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
278 mResourceView->updateView(); 278 mResourceView->updateView();
279 connect( mResourceView, SIGNAL( resourcesChanged() ), 279 connect( mResourceView, SIGNAL( resourcesChanged() ),
280 SLOT( updateView() ) ); 280 SLOT( updateView() ) );
281 } else { 281 } else {
282 mResourceView = 0; 282 mResourceView = 0;
283 } 283 }
284#endif 284#endif
285 QWidget *rightBox = new QWidget( mPanner ); 285 QWidget *rightBox = new QWidget( mPanner );
286 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 286 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
287 287
288 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 288 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
289 rightLayout->addWidget( mNavigatorBar ); 289 rightLayout->addWidget( mNavigatorBar );
290 290
291 mRightFrame = new QWidgetStack( rightBox ); 291 mRightFrame = new QWidgetStack( rightBox );
292 rightLayout->addWidget( mRightFrame, 1 ); 292 rightLayout->addWidget( mRightFrame, 1 );
293 293
294 mLeftFrame = mLeftSplitter; 294 mLeftFrame = mLeftSplitter;
295#else 295#else
296 QWidget *mainBox = new QWidget( this ); 296 QWidget *mainBox = new QWidget( this );
297 QWidget *leftFrame = new QWidget( mainBox ); 297 QWidget *leftFrame = new QWidget( mainBox );
298 298
299 QBoxLayout * mainBoxLayout; 299 QBoxLayout * mainBoxLayout;
300 QBoxLayout * leftFrameLayout; 300 QBoxLayout * leftFrameLayout;
301 if ( KOPrefs::instance()->mVerticalScreen ) { 301 if ( KOPrefs::instance()->mVerticalScreen ) {
302 mainBoxLayout = new QVBoxLayout(mainBox); 302 mainBoxLayout = new QVBoxLayout(mainBox);
303 leftFrameLayout = new QHBoxLayout(leftFrame ); 303 leftFrameLayout = new QHBoxLayout(leftFrame );
304 } else { 304 } else {
305 mainBoxLayout = new QHBoxLayout(mainBox); 305 mainBoxLayout = new QHBoxLayout(mainBox);
306 leftFrameLayout = new QVBoxLayout(leftFrame ); 306 leftFrameLayout = new QVBoxLayout(leftFrame );
307 } 307 }
308 topLayout->addWidget( mainBox ); 308 topLayout->addWidget( mainBox );
309 mainBoxLayout->addWidget (leftFrame); 309 mainBoxLayout->addWidget (leftFrame);
310 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, 310 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE,
311 "CalendarView::DateNavigator", QDate::currentDate()); 311 "CalendarView::DateNavigator", QDate::currentDate());
312 // mDateNavigator->blockSignals( true ); 312 // mDateNavigator->blockSignals( true );
313 leftFrameLayout->addWidget( mDateNavigator ); 313 leftFrameLayout->addWidget( mDateNavigator );
314 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); 314 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView");
315 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall"); 315 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall");
316 mTodoList->setNavigator( mNavigator ); 316 mTodoList->setNavigator( mNavigator );
317 317
318 if ( QApplication::desktop()->width() < 480 ) { 318 if ( QApplication::desktop()->width() < 480 ) {
319 leftFrameLayout->addWidget(mFilterView); 319 leftFrameLayout->addWidget(mFilterView);
320 leftFrameLayout->addWidget(mTodoList, 2 ); 320 leftFrameLayout->addWidget(mTodoList, 2 );
321 321
322 } else { 322 } else {
323 leftFrameLayout->addWidget(mTodoList,2 ); 323 leftFrameLayout->addWidget(mTodoList,2 );
324 leftFrameLayout->addWidget(mFilterView ); 324 leftFrameLayout->addWidget(mFilterView );
325 } 325 }
326 mFilterView->hide(); 326 mFilterView->hide();
327 QWidget *rightBox = new QWidget( mainBox ); 327 QWidget *rightBox = new QWidget( mainBox );
328 mainBoxLayout->addWidget ( rightBox, 10 ); 328 mainBoxLayout->addWidget ( rightBox, 10 );
329 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 329 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
330 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 330 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
331 mRightFrame = new QWidgetStack( rightBox ); 331 mRightFrame = new QWidgetStack( rightBox );
332 rightLayout->addWidget( mNavigatorBar ); 332 rightLayout->addWidget( mNavigatorBar );
333 rightLayout->addWidget( mRightFrame, 10 ); 333 rightLayout->addWidget( mRightFrame, 10 );
334 334
335 mLeftFrame = leftFrame; 335 mLeftFrame = leftFrame;
336 if ( KOPrefs::instance()->mVerticalScreen ) { 336 if ( KOPrefs::instance()->mVerticalScreen ) {
337 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 337 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
338 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 338 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
339 } else { 339 } else {
340 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 340 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
341 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 341 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
342 } 342 }
343 if ( !KOPrefs::instance()->mShowDateNavigator) 343 if ( !KOPrefs::instance()->mShowDateNavigator)
344 mDateNavigator->hide(); 344 mDateNavigator->hide();
345 //qDebug("Calendarview Size %d %d ", width(), height()); 345 //qDebug("Calendarview Size %d %d ", width(), height());
346#endif 346#endif
347 347
348 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 348 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
349 SLOT( showDates( const KCal::DateList & ) ) ); 349 SLOT( showDates( const KCal::DateList & ) ) );
350 350
351 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 351 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
352 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 352 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
353 connect( mNavigatorBar, SIGNAL( goPrevYear() ), 353 connect( mNavigatorBar, SIGNAL( goPrevYear() ),
354 mNavigator, SLOT( selectPreviousYear() ) ); 354 mNavigator, SLOT( selectPreviousYear() ) );
355 connect( mNavigatorBar, SIGNAL( goNextYear() ), 355 connect( mNavigatorBar, SIGNAL( goNextYear() ),
356 mNavigator, SLOT( selectNextYear() ) ); 356 mNavigator, SLOT( selectNextYear() ) );
357 connect( mNavigatorBar, SIGNAL( goPrevMonth() ), 357 connect( mNavigatorBar, SIGNAL( goPrevMonth() ),
358 mNavigator, SLOT( selectPreviousMonth() ) ); 358 mNavigator, SLOT( selectPreviousMonth() ) );
359 connect( mNavigatorBar, SIGNAL( goNextMonth() ), 359 connect( mNavigatorBar, SIGNAL( goNextMonth() ),
360 mNavigator, SLOT( selectNextMonth() ) ); 360 mNavigator, SLOT( selectNextMonth() ) );
361 361
362 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 362 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
363 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); 363 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) );
364 364
365 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 365 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
366 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 366 mNavigator, SLOT( selectWeek( const QDate & ) ) );
367 367
368 connect( mDateNavigator, SIGNAL( goPrevYear() ), 368 connect( mDateNavigator, SIGNAL( goPrevYear() ),
369 mNavigator, SLOT( selectPreviousYear() ) ); 369 mNavigator, SLOT( selectPreviousYear() ) );
370 connect( mDateNavigator, SIGNAL( goNextYear() ), 370 connect( mDateNavigator, SIGNAL( goNextYear() ),
371 mNavigator, SLOT( selectNextYear() ) ); 371 mNavigator, SLOT( selectNextYear() ) );
372 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 372 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
373 mNavigator, SLOT( selectPreviousMonth() ) ); 373 mNavigator, SLOT( selectPreviousMonth() ) );
374 connect( mDateNavigator, SIGNAL( goNextMonth() ), 374 connect( mDateNavigator, SIGNAL( goNextMonth() ),
375 mNavigator, SLOT( selectNextMonth() ) ); 375 mNavigator, SLOT( selectNextMonth() ) );
376 376
377 connect( mDateNavigator, SIGNAL( goPrevious() ), 377 connect( mDateNavigator, SIGNAL( goPrevious() ),
378 mNavigator, SLOT( selectPrevious() ) ); 378 mNavigator, SLOT( selectPrevious() ) );
379 connect( mDateNavigator, SIGNAL( goNext() ), 379 connect( mDateNavigator, SIGNAL( goNext() ),
380 mNavigator, SLOT( selectNext() ) ); 380 mNavigator, SLOT( selectNext() ) );
381 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 381 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
382 mNavigator, SLOT( slotMonthSelect( int ) ) ); 382 mNavigator, SLOT( slotMonthSelect( int ) ) );
383 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), 383 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ),
384 mNavigator, SLOT( slotMonthSelect( int ) ) ); 384 mNavigator, SLOT( slotMonthSelect( int ) ) );
385 385
386 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 386 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
387 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 387 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
388 388
389 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), 389 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ),
390 SLOT( eventAdded( Event *) ) ); 390 SLOT( eventAdded( Event *) ) );
391 391
392 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 392 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
393 393
394 connect( this, SIGNAL( configChanged() ), 394 connect( this, SIGNAL( configChanged() ),
395 mDateNavigator, SLOT( updateConfig() ) ); 395 mDateNavigator, SLOT( updateConfig() ) );
396 396
397 connect( mTodoList, SIGNAL( newTodoSignal() ), 397 connect( mTodoList, SIGNAL( newTodoSignal() ),
398 SLOT( newTodo() ) ); 398 SLOT( newTodo() ) );
399 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 399 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
400 SLOT( newSubTodo( Todo * ) ) ); 400 SLOT( newSubTodo( Todo * ) ) );
401 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 401 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
402 SLOT( editTodo( Todo * ) ) ); 402 SLOT( editTodo( Todo * ) ) );
403 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 403 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
404 SLOT( showTodo( Todo *) ) ); 404 SLOT( showTodo( Todo *) ) );
405 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 405 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
406 SLOT( deleteTodo( Todo *) ) ); 406 SLOT( deleteTodo( Todo *) ) );
407 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 407 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
408 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 408 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
409 SLOT( purgeCompleted() ) ); 409 SLOT( purgeCompleted() ) );
410 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 410 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
411 SIGNAL( todoModified( Todo *, int ) ) ); 411 SIGNAL( todoModified( Todo *, int ) ) );
412 412
413 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 413 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
414 this, SLOT ( cloneIncidence( Incidence * ) ) ); 414 this, SLOT ( cloneIncidence( Incidence * ) ) );
415 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 415 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
416 this, SLOT (cancelIncidence( Incidence * ) ) ); 416 this, SLOT (cancelIncidence( Incidence * ) ) );
417 417
418 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 418 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
419 this, SLOT ( moveIncidence( Incidence * ) ) ); 419 this, SLOT ( moveIncidence( Incidence * ) ) );
420 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 420 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
421 this, SLOT ( beamIncidence( Incidence * ) ) ); 421 this, SLOT ( beamIncidence( Incidence * ) ) );
422 422
423 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 423 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
424 this, SLOT ( todo_unsub( Todo * ) ) ); 424 this, SLOT ( todo_unsub( Todo * ) ) );
425 425
426 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 426 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
427 this, SLOT ( todo_resub( Todo *,Todo * ) ) ); 427 this, SLOT ( todo_resub( Todo *,Todo * ) ) );
428 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 428 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
429 SLOT( updateTodo( Todo *, int ) ) ); 429 SLOT( updateTodo( Todo *, int ) ) );
430 connect( this, SIGNAL( todoModified( Todo *, int )), this, 430 connect( this, SIGNAL( todoModified( Todo *, int )), this,
431 SLOT( changeTodoDisplay( Todo *, int ) ) ); 431 SLOT( changeTodoDisplay( Todo *, int ) ) );
432 432
433 433
434 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 434 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
435 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 435 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
436 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 436 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
437 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 437 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
438 438
439 439
440 440
441 441
442 442
443 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 443 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
444 SLOT(checkClipboard())); 444 SLOT(checkClipboard()));
445 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 445 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
446 SLOT( processTodoListSelection( Incidence * ) ) ); 446 SLOT( processTodoListSelection( Incidence * ) ) );
447 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 447 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
448 448
449 // kdDebug() << "CalendarView::CalendarView() done" << endl; 449 // kdDebug() << "CalendarView::CalendarView() done" << endl;
450 450
451 mDateFrame = new QVBox(0,0,WType_Popup); 451 mDateFrame = new QVBox(0,0,WType_Popup);
452 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 452 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
453 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 453 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
454 mDateFrame->setLineWidth(3); 454 mDateFrame->setLineWidth(3);
455 mDateFrame->hide(); 455 mDateFrame->hide();
456 mDateFrame->setCaption( i18n( "Pick a date to display")); 456 mDateFrame->setCaption( i18n( "Pick a date to display"));
457 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 457 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
458 458
459 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 459 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
460 460
461 mEventEditor = mDialogManager->getEventEditor(); 461 mEventEditor = mDialogManager->getEventEditor();
462 mTodoEditor = mDialogManager->getTodoEditor(); 462 mTodoEditor = mDialogManager->getTodoEditor();
463 463
464 mFlagEditDescription = false; 464 mFlagEditDescription = false;
465 465
466 mSuspendTimer = new QTimer( this ); 466 mSuspendTimer = new QTimer( this );
467 mAlarmTimer = new QTimer( this ); 467 mAlarmTimer = new QTimer( this );
468 mRecheckAlarmTimer = new QTimer( this ); 468 mRecheckAlarmTimer = new QTimer( this );
469 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 469 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
470 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 470 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
471 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 471 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
472 mAlarmDialog = new AlarmDialog( this ); 472 mAlarmDialog = new AlarmDialog( this );
473 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 473 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
474 mAlarmDialog->setServerNotification( false ); 474 mAlarmDialog->setServerNotification( false );
475 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 475 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
476 476
477 477
478#ifndef DESKTOP_VERSION 478#ifndef DESKTOP_VERSION
479//US listen for arriving address resultsets 479//US listen for arriving address resultsets
480 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), 480 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)),
481 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 481 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
482#endif 482#endif
483 483
484} 484}
485 485
486 486
487CalendarView::~CalendarView() 487CalendarView::~CalendarView()
488{ 488{
489 // kdDebug() << "~CalendarView()" << endl; 489 // kdDebug() << "~CalendarView()" << endl;
490 //qDebug("CalendarView::~CalendarView() "); 490 //qDebug("CalendarView::~CalendarView() ");
491 delete mDialogManager; 491 delete mDialogManager;
492 delete mViewManager; 492 delete mViewManager;
493 delete mStorage; 493 delete mStorage;
494 delete mDateFrame ; 494 delete mDateFrame ;
495 delete beamDialog; 495 delete beamDialog;
496 //kdDebug() << "~CalendarView() done" << endl; 496 //kdDebug() << "~CalendarView() done" << endl;
497} 497}
498 498
499void CalendarView::showDay( QDate d ) 499void CalendarView::showDay( QDate d )
500{ 500{
501 dateNavigator()->blockSignals( true ); 501 dateNavigator()->blockSignals( true );
502 dateNavigator()->selectDate( d ); 502 dateNavigator()->selectDate( d );
503 dateNavigator()->blockSignals( false ); 503 dateNavigator()->blockSignals( false );
504 mViewManager->showWeekView(); 504 mViewManager->showDayView();
505 dateNavigator()->selectDate( d ); 505 //dateNavigator()->selectDate( d );
506} 506}
507void CalendarView::timerAlarm() 507void CalendarView::timerAlarm()
508{ 508{
509 //qDebug("CalendarView::timerAlarm() "); 509 //qDebug("CalendarView::timerAlarm() ");
510 computeAlarm(mAlarmNotification ); 510 computeAlarm(mAlarmNotification );
511} 511}
512 512
513void CalendarView::suspendAlarm() 513void CalendarView::suspendAlarm()
514{ 514{
515 //qDebug(" CalendarView::suspendAlarm() "); 515 //qDebug(" CalendarView::suspendAlarm() ");
516 computeAlarm(mSuspendAlarmNotification ); 516 computeAlarm(mSuspendAlarmNotification );
517 517
518} 518}
519 519
520void CalendarView::startAlarm( QString mess , QString filename) 520void CalendarView::startAlarm( QString mess , QString filename)
521{ 521{
522 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 522 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
523 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); 523 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
524 524
525} 525}
526 526
527void CalendarView::checkNextTimerAlarm() 527void CalendarView::checkNextTimerAlarm()
528{ 528{
529 mCalendar->checkAlarmForIncidence( 0, true ); 529 mCalendar->checkAlarmForIncidence( 0, true );
530} 530}
531 531
532void CalendarView::computeAlarm( QString msg ) 532void CalendarView::computeAlarm( QString msg )
533{ 533{
534 534
535 QString mess = msg; 535 QString mess = msg;
536 QString mAlarmMessage = mess.mid( 9 ); 536 QString mAlarmMessage = mess.mid( 9 );
537 QString filename = MainWindow::resourcePath(); 537 QString filename = MainWindow::resourcePath();
538 filename += "koalarm.wav"; 538 filename += "koalarm.wav";
539 QString tempfilename; 539 QString tempfilename;
540 if ( mess.left( 13 ) == "suspend_alarm") { 540 if ( mess.left( 13 ) == "suspend_alarm") {
541 bool error = false; 541 bool error = false;
542 int len = mess.mid( 13 ).find("+++"); 542 int len = mess.mid( 13 ).find("+++");
543 if ( len < 2 ) 543 if ( len < 2 )
544 error = true; 544 error = true;
545 else { 545 else {
546 tempfilename = mess.mid( 13, len ); 546 tempfilename = mess.mid( 13, len );
547 if ( !QFile::exists( tempfilename ) ) 547 if ( !QFile::exists( tempfilename ) )
548 error = true; 548 error = true;
549 } 549 }
550 if ( ! error ) { 550 if ( ! error ) {
551 filename = tempfilename; 551 filename = tempfilename;
552 } 552 }
553 mAlarmMessage = mess.mid( 13+len+3 ); 553 mAlarmMessage = mess.mid( 13+len+3 );
554 //qDebug("suspend file %s ",tempfilename.latin1() ); 554 //qDebug("suspend file %s ",tempfilename.latin1() );
555 startAlarm( mAlarmMessage, filename); 555 startAlarm( mAlarmMessage, filename);
556 return; 556 return;
557 } 557 }
558 if ( mess.left( 11 ) == "timer_alarm") { 558 if ( mess.left( 11 ) == "timer_alarm") {
559 //mTimerTime = 0; 559 //mTimerTime = 0;
560 startAlarm( mess.mid( 11 ), filename ); 560 startAlarm( mess.mid( 11 ), filename );
561 return; 561 return;
562 } 562 }
563 if ( mess.left( 10 ) == "proc_alarm") { 563 if ( mess.left( 10 ) == "proc_alarm") {
564 bool error = false; 564 bool error = false;
565 int len = mess.mid( 10 ).find("+++"); 565 int len = mess.mid( 10 ).find("+++");
566 if ( len < 2 ) 566 if ( len < 2 )
567 error = true; 567 error = true;
568 else { 568 else {
569 tempfilename = mess.mid( 10, len ); 569 tempfilename = mess.mid( 10, len );
570 if ( !QFile::exists( tempfilename ) ) 570 if ( !QFile::exists( tempfilename ) )
571 error = true; 571 error = true;
572 } 572 }
573 if ( error ) { 573 if ( error ) {
574 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 574 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
575 mAlarmMessage += mess.mid( 10+len+3+9 ); 575 mAlarmMessage += mess.mid( 10+len+3+9 );
576 } else { 576 } else {
577 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 577 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
578 //qDebug("-----system command %s ",tempfilename.latin1() ); 578 //qDebug("-----system command %s ",tempfilename.latin1() );
579#ifndef _WIN32_ 579#ifndef _WIN32_
580 if ( vfork () == 0 ) { 580 if ( vfork () == 0 ) {
581 execl ( tempfilename.latin1(), 0 ); 581 execl ( tempfilename.latin1(), 0 );
582 return; 582 return;
583 } 583 }
584#else 584#else
585 QProcess* p = new QProcess(); 585 QProcess* p = new QProcess();
586 p->addArgument( tempfilename.latin1() ); 586 p->addArgument( tempfilename.latin1() );
587 p->start(); 587 p->start();
588 return; 588 return;
589#endif 589#endif
590 590
591 return; 591 return;
592 } 592 }
593 593
594 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 594 //qDebug("+++++++system command %s ",tempfilename.latin1() );
595 } 595 }
596 if ( mess.left( 11 ) == "audio_alarm") { 596 if ( mess.left( 11 ) == "audio_alarm") {
597 bool error = false; 597 bool error = false;
598 int len = mess.mid( 11 ).find("+++"); 598 int len = mess.mid( 11 ).find("+++");
599 if ( len < 2 ) 599 if ( len < 2 )
600 error = true; 600 error = true;
601 else { 601 else {
602 tempfilename = mess.mid( 11, len ); 602 tempfilename = mess.mid( 11, len );
603 if ( !QFile::exists( tempfilename ) ) 603 if ( !QFile::exists( tempfilename ) )
604 error = true; 604 error = true;
605 } 605 }
606 if ( ! error ) { 606 if ( ! error ) {
607 filename = tempfilename; 607 filename = tempfilename;
608 } 608 }
609 mAlarmMessage = mess.mid( 11+len+3+9 ); 609 mAlarmMessage = mess.mid( 11+len+3+9 );
610 //qDebug("audio file command %s ",tempfilename.latin1() ); 610 //qDebug("audio file command %s ",tempfilename.latin1() );
611 } 611 }
612 if ( mess.left( 9 ) == "cal_alarm") { 612 if ( mess.left( 9 ) == "cal_alarm") {
613 mAlarmMessage = mess.mid( 9 ) ; 613 mAlarmMessage = mess.mid( 9 ) ;
614 } 614 }
615 615
616 startAlarm( mAlarmMessage, filename ); 616 startAlarm( mAlarmMessage, filename );
617 617
618 618
619} 619}
620 620
621void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 621void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
622{ 622{
623 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 623 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
624 624
625 mSuspendAlarmNotification = noti; 625 mSuspendAlarmNotification = noti;
626 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 626 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
627 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 627 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
628 mSuspendTimer->start( ms , true ); 628 mSuspendTimer->start( ms , true );
629 629
630} 630}
631 631
632void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 632void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
633{ 633{
634 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 634 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
635 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 635 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
636#ifndef DESKTOP_VERSION 636#ifndef DESKTOP_VERSION
637 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); 637 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() );
638#endif 638#endif
639 return; 639 return;
640 } 640 }
641 int maxSec; 641 int maxSec;
642 //maxSec = 5; //testing only 642 //maxSec = 5; //testing only
643 maxSec = 86400+3600; // one day+1hour 643 maxSec = 86400+3600; // one day+1hour
644 mAlarmNotification = noti; 644 mAlarmNotification = noti;
645 int sec = QDateTime::currentDateTime().secsTo( qdt ); 645 int sec = QDateTime::currentDateTime().secsTo( qdt );
646 if ( sec > maxSec ) { 646 if ( sec > maxSec ) {
647 mRecheckAlarmTimer->start( maxSec * 1000 ); 647 mRecheckAlarmTimer->start( maxSec * 1000 );
648 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 648 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
649 return; 649 return;
650 } else { 650 } else {
651 mRecheckAlarmTimer->stop(); 651 mRecheckAlarmTimer->stop();
652 } 652 }
653 //qDebug("Alarm timer started with secs: %d ", sec); 653 //qDebug("Alarm timer started with secs: %d ", sec);
654 mAlarmTimer->start( sec *1000 , true ); 654 mAlarmTimer->start( sec *1000 , true );
655 655
656} 656}
657// called by mRecheckAlarmTimer to get next alarm 657// called by mRecheckAlarmTimer to get next alarm
658// we need this, because a QTimer has only a max range of 25 days 658// we need this, because a QTimer has only a max range of 25 days
659void CalendarView::recheckTimerAlarm() 659void CalendarView::recheckTimerAlarm()
660{ 660{
661 mAlarmTimer->stop(); 661 mAlarmTimer->stop();
662 mRecheckAlarmTimer->stop(); 662 mRecheckAlarmTimer->stop();
663 mCalendar->checkAlarmForIncidence( 0, true ); 663 mCalendar->checkAlarmForIncidence( 0, true );
664} 664}
665void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 665void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
666{ 666{
667 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 667 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
668 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 668 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
669#ifndef DESKTOP_VERSION 669#ifndef DESKTOP_VERSION
670 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 670 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
671#endif 671#endif
672 return; 672 return;
673 } 673 }
674 mAlarmTimer->stop(); 674 mAlarmTimer->stop();
675} 675}
676void CalendarView::selectWeekNum ( int num ) 676void CalendarView::selectWeekNum ( int num )
677{ 677{
678 dateNavigator()->blockSignals( true ); 678 dateNavigator()->blockSignals( true );
679 dateNavigator()->selectWeek( num ); 679 dateNavigator()->selectWeek( num );
680 dateNavigator()->blockSignals( false ); 680 dateNavigator()->blockSignals( false );
681 mViewManager->showWeekView(); 681 mViewManager->showWeekView();
682} 682}
683KOViewManager *CalendarView::viewManager() 683KOViewManager *CalendarView::viewManager()
684{ 684{
685 return mViewManager; 685 return mViewManager;
686} 686}
687 687
688KODialogManager *CalendarView::dialogManager() 688KODialogManager *CalendarView::dialogManager()
689{ 689{
690 return mDialogManager; 690 return mDialogManager;
691} 691}
692 692
693QDate CalendarView::startDate() 693QDate CalendarView::startDate()
694{ 694{
695 DateList dates = mNavigator->selectedDates(); 695 DateList dates = mNavigator->selectedDates();
696 696
697 return dates.first(); 697 return dates.first();
698} 698}
699 699
700QDate CalendarView::endDate() 700QDate CalendarView::endDate()
701{ 701{
702 DateList dates = mNavigator->selectedDates(); 702 DateList dates = mNavigator->selectedDates();
703 703
704 return dates.last(); 704 return dates.last();
705} 705}
706 706
707 707
708void CalendarView::createPrinter() 708void CalendarView::createPrinter()
709{ 709{
710#ifndef KORG_NOPRINTER 710#ifndef KORG_NOPRINTER
711 if (!mCalPrinter) { 711 if (!mCalPrinter) {
712 mCalPrinter = new CalPrinter(this, mCalendar); 712 mCalPrinter = new CalPrinter(this, mCalendar);
713 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 713 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
714 } 714 }
715#endif 715#endif
716} 716}
717 717
718 718
719//KOPrefs::instance()->mWriteBackFile 719//KOPrefs::instance()->mWriteBackFile
720//KOPrefs::instance()->mWriteBackExistingOnly 720//KOPrefs::instance()->mWriteBackExistingOnly
721 721
722// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 722// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
723// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 723// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
724// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 724// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
725// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 725// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
726// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 726// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
727// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 727// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
728 728
729int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 729int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
730{ 730{
731 731
732 // 0 equal 732 // 0 equal
733 // 1 take local 733 // 1 take local
734 // 2 take remote 734 // 2 take remote
735 // 3 cancel 735 // 3 cancel
736 QDateTime lastSync = mLastCalendarSync; 736 QDateTime lastSync = mLastCalendarSync;
737 QDateTime localMod = local->lastModified(); 737 QDateTime localMod = local->lastModified();
738 QDateTime remoteMod = remote->lastModified(); 738 QDateTime remoteMod = remote->lastModified();
739 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 739 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
740 bool remCh, locCh; 740 bool remCh, locCh;
741 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 741 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
742 //if ( remCh ) 742 //if ( remCh )
743 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 743 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
744 locCh = ( localMod > mLastCalendarSync ); 744 locCh = ( localMod > mLastCalendarSync );
745 if ( !remCh && ! locCh ) { 745 if ( !remCh && ! locCh ) {
746 //qDebug("both not changed "); 746 //qDebug("both not changed ");
747 lastSync = localMod.addDays(1); 747 lastSync = localMod.addDays(1);
748 if ( mode <= SYNC_PREF_ASK ) 748 if ( mode <= SYNC_PREF_ASK )
749 return 0; 749 return 0;
750 } else { 750 } else {
751 if ( locCh ) { 751 if ( locCh ) {
752 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); 752 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1());
753 lastSync = localMod.addDays( -1 ); 753 lastSync = localMod.addDays( -1 );
754 if ( !remCh ) 754 if ( !remCh )
755 remoteMod = ( lastSync.addDays( -1 ) ); 755 remoteMod = ( lastSync.addDays( -1 ) );
756 } else { 756 } else {
757 //qDebug(" not loc changed "); 757 //qDebug(" not loc changed ");
758 lastSync = localMod.addDays( 1 ); 758 lastSync = localMod.addDays( 1 );
759 if ( remCh ) 759 if ( remCh )
760 remoteMod =( lastSync.addDays( 1 ) ); 760 remoteMod =( lastSync.addDays( 1 ) );
761 761
762 } 762 }
763 } 763 }
764 full = true; 764 full = true;
765 if ( mode < SYNC_PREF_ASK ) 765 if ( mode < SYNC_PREF_ASK )
766 mode = SYNC_PREF_ASK; 766 mode = SYNC_PREF_ASK;
767 } else { 767 } else {
768 if ( localMod == remoteMod ) 768 if ( localMod == remoteMod )
769 // if ( local->revision() == remote->revision() ) 769 // if ( local->revision() == remote->revision() )
770 return 0; 770 return 0;
771 771
772 } 772 }
773 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 773 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
774 774
775 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); 775 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision());
776 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); 776 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() );
777 //full = true; //debug only 777 //full = true; //debug only
778 if ( full ) { 778 if ( full ) {
779 bool equ = false; 779 bool equ = false;
780 if ( local->type() == "Event" ) { 780 if ( local->type() == "Event" ) {
781 equ = (*((Event*) local) == *((Event*) remote)); 781 equ = (*((Event*) local) == *((Event*) remote));
782 } 782 }
783 else if ( local->type() =="Todo" ) 783 else if ( local->type() =="Todo" )
784 equ = (*((Todo*) local) == (*(Todo*) remote)); 784 equ = (*((Todo*) local) == (*(Todo*) remote));
785 else if ( local->type() =="Journal" ) 785 else if ( local->type() =="Journal" )
786 equ = (*((Journal*) local) == *((Journal*) remote)); 786 equ = (*((Journal*) local) == *((Journal*) remote));
787 if ( equ ) { 787 if ( equ ) {
788 //qDebug("equal "); 788 //qDebug("equal ");
789 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 789 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
790 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 790 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
791 } 791 }
792 if ( mode < SYNC_PREF_FORCE_LOCAL ) 792 if ( mode < SYNC_PREF_FORCE_LOCAL )
793 return 0; 793 return 0;
794 794
795 }//else //debug only 795 }//else //debug only
796 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 796 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
797 } 797 }
798 int result; 798 int result;
799 bool localIsNew; 799 bool localIsNew;
800 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); 800 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() );
801 801
802 if ( full && mode < SYNC_PREF_NEWEST ) 802 if ( full && mode < SYNC_PREF_NEWEST )
803 mode = SYNC_PREF_ASK; 803 mode = SYNC_PREF_ASK;
804 804
805 switch( mode ) { 805 switch( mode ) {
806 case SYNC_PREF_LOCAL: 806 case SYNC_PREF_LOCAL:
807 if ( lastSync > remoteMod ) 807 if ( lastSync > remoteMod )
808 return 1; 808 return 1;
809 if ( lastSync > localMod ) 809 if ( lastSync > localMod )
810 return 2; 810 return 2;
811 return 1; 811 return 1;
812 break; 812 break;
813 case SYNC_PREF_REMOTE: 813 case SYNC_PREF_REMOTE:
814 if ( lastSync > remoteMod ) 814 if ( lastSync > remoteMod )
815 return 1; 815 return 1;
816 if ( lastSync > localMod ) 816 if ( lastSync > localMod )
817 return 2; 817 return 2;
818 return 2; 818 return 2;
819 break; 819 break;
820 case SYNC_PREF_NEWEST: 820 case SYNC_PREF_NEWEST:
821 if ( localMod > remoteMod ) 821 if ( localMod > remoteMod )
822 return 1; 822 return 1;
823 else 823 else
824 return 2; 824 return 2;
825 break; 825 break;
826 case SYNC_PREF_ASK: 826 case SYNC_PREF_ASK:
827 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 827 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
828 if ( lastSync > remoteMod ) 828 if ( lastSync > remoteMod )
829 return 1; 829 return 1;
830 if ( lastSync > localMod ) 830 if ( lastSync > localMod )
831 return 2; 831 return 2;
832 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 832 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
833 localIsNew = localMod >= remoteMod; 833 localIsNew = localMod >= remoteMod;
834 if ( localIsNew ) 834 if ( localIsNew )
835 getEventViewerDialog()->setColorMode( 1 ); 835 getEventViewerDialog()->setColorMode( 1 );
836 else 836 else
837 getEventViewerDialog()->setColorMode( 2 ); 837 getEventViewerDialog()->setColorMode( 2 );
838 getEventViewerDialog()->setIncidence(local); 838 getEventViewerDialog()->setIncidence(local);
839 if ( localIsNew ) 839 if ( localIsNew )
840 getEventViewerDialog()->setColorMode( 2 ); 840 getEventViewerDialog()->setColorMode( 2 );
841 else 841 else
842 getEventViewerDialog()->setColorMode( 1 ); 842 getEventViewerDialog()->setColorMode( 1 );
843 getEventViewerDialog()->addIncidence(remote); 843 getEventViewerDialog()->addIncidence(remote);
844 getEventViewerDialog()->setColorMode( 0 ); 844 getEventViewerDialog()->setColorMode( 0 );
845 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 845 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
846 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 846 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
847 getEventViewerDialog()->showMe(); 847 getEventViewerDialog()->showMe();
848 result = getEventViewerDialog()->executeS( localIsNew ); 848 result = getEventViewerDialog()->executeS( localIsNew );
849 return result; 849 return result;
850 850
851 break; 851 break;
852 case SYNC_PREF_FORCE_LOCAL: 852 case SYNC_PREF_FORCE_LOCAL:
853 return 1; 853 return 1;
854 break; 854 break;
855 case SYNC_PREF_FORCE_REMOTE: 855 case SYNC_PREF_FORCE_REMOTE:
856 return 2; 856 return 2;
857 break; 857 break;
858 858
859 default: 859 default:
860 // SYNC_PREF_TAKE_BOTH not implemented 860 // SYNC_PREF_TAKE_BOTH not implemented
861 break; 861 break;
862 } 862 }
863 return 0; 863 return 0;
864} 864}
865Event* CalendarView::getLastSyncEvent() 865Event* CalendarView::getLastSyncEvent()
866{ 866{
867 Event* lse; 867 Event* lse;
868 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 868 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
869 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 869 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
870 if (!lse) { 870 if (!lse) {
871 lse = new Event(); 871 lse = new Event();
872 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 872 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
873 QString sum = ""; 873 QString sum = "";
874 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 874 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
875 sum = "E: "; 875 sum = "E: ";
876 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 876 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
877 lse->setDtStart( mLastCalendarSync ); 877 lse->setDtStart( mLastCalendarSync );
878 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 878 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
879 lse->setCategories( i18n("SyncEvent") ); 879 lse->setCategories( i18n("SyncEvent") );
880 lse->setReadOnly( true ); 880 lse->setReadOnly( true );
881 mCalendar->addEvent( lse ); 881 mCalendar->addEvent( lse );
882 } 882 }
883 883
884 return lse; 884 return lse;
885 885
886} 886}
887 887
888// we check, if the to delete event has a id for a profile 888// we check, if the to delete event has a id for a profile
889// if yes, we set this id in the profile to delete 889// if yes, we set this id in the profile to delete
890void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 890void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
891{ 891{
892 if ( lastSync.count() == 0 ) { 892 if ( lastSync.count() == 0 ) {
893 //qDebug(" lastSync.count() == 0"); 893 //qDebug(" lastSync.count() == 0");
894 return; 894 return;
895 } 895 }
896 if ( toDelete->type() == "Journal" ) 896 if ( toDelete->type() == "Journal" )
897 return; 897 return;
898 898
899 Event* eve = lastSync.first(); 899 Event* eve = lastSync.first();
900 900
901 while ( eve ) { 901 while ( eve ) {
902 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 902 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
903 if ( !id.isEmpty() ) { 903 if ( !id.isEmpty() ) {
904 QString des = eve->description(); 904 QString des = eve->description();
905 QString pref = "e"; 905 QString pref = "e";
906 if ( toDelete->type() == "Todo" ) 906 if ( toDelete->type() == "Todo" )
907 pref = "t"; 907 pref = "t";
908 des += pref+ id + ","; 908 des += pref+ id + ",";
909 eve->setReadOnly( false ); 909 eve->setReadOnly( false );
910 eve->setDescription( des ); 910 eve->setDescription( des );
911 //qDebug("setdes %s ", des.latin1()); 911 //qDebug("setdes %s ", des.latin1());
912 eve->setReadOnly( true ); 912 eve->setReadOnly( true );
913 } 913 }
914 eve = lastSync.next(); 914 eve = lastSync.next();
915 } 915 }
916 916
917} 917}
918void CalendarView::checkExternalId( Incidence * inc ) 918void CalendarView::checkExternalId( Incidence * inc )
919{ 919{
920 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 920 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
921 checkExternSyncEvent( lastSync, inc ); 921 checkExternSyncEvent( lastSync, inc );
922 922
923} 923}
924bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 924bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
925{ 925{
926 bool syncOK = true; 926 bool syncOK = true;
927 int addedEvent = 0; 927 int addedEvent = 0;
928 int addedEventR = 0; 928 int addedEventR = 0;
929 int deletedEventR = 0; 929 int deletedEventR = 0;
930 int deletedEventL = 0; 930 int deletedEventL = 0;
931 int changedLocal = 0; 931 int changedLocal = 0;
932 int changedRemote = 0; 932 int changedRemote = 0;
933 int filteredIN = 0; 933 int filteredIN = 0;
934 int filteredOUT = 0; 934 int filteredOUT = 0;
935 //QPtrList<Event> el = local->rawEvents(); 935 //QPtrList<Event> el = local->rawEvents();
936 Event* eventR; 936 Event* eventR;
937 QString uid; 937 QString uid;
938 int take; 938 int take;
939 Event* eventL; 939 Event* eventL;
940 Event* eventRSync; 940 Event* eventRSync;
941 Event* eventLSync; 941 Event* eventLSync;
942 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 942 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
943 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 943 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
944 bool fullDateRange = false; 944 bool fullDateRange = false;
945 local->resetTempSyncStat(); 945 local->resetTempSyncStat();
946 mLastCalendarSync = QDateTime::currentDateTime(); 946 mLastCalendarSync = QDateTime::currentDateTime();
947 if ( mSyncManager->syncWithDesktop() ) { 947 if ( mSyncManager->syncWithDesktop() ) {
948 remote->resetPilotStat(1); 948 remote->resetPilotStat(1);
949 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 949 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
950 mLastCalendarSync = KSyncManager::mRequestedSyncEvent; 950 mLastCalendarSync = KSyncManager::mRequestedSyncEvent;
951 qDebug("using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); 951 qDebug("using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() );
952 } else { 952 } else {
953 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 953 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
954 } 954 }
955 } 955 }
956 QDateTime modifiedCalendar = mLastCalendarSync; 956 QDateTime modifiedCalendar = mLastCalendarSync;
957 eventLSync = getLastSyncEvent(); 957 eventLSync = getLastSyncEvent();
958 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 958 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
959 if ( eventR ) { 959 if ( eventR ) {
960 eventRSync = (Event*) eventR->clone(); 960 eventRSync = (Event*) eventR->clone();
961 remote->deleteEvent(eventR ); 961 remote->deleteEvent(eventR );
962 962
963 } else { 963 } else {
964 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { 964 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) {
965 eventRSync = (Event*)eventLSync->clone(); 965 eventRSync = (Event*)eventLSync->clone();
966 } else { 966 } else {
967 fullDateRange = true; 967 fullDateRange = true;
968 eventRSync = new Event(); 968 eventRSync = new Event();
969 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 969 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
970 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 970 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
971 eventRSync->setDtStart( mLastCalendarSync ); 971 eventRSync->setDtStart( mLastCalendarSync );
972 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 972 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
973 eventRSync->setCategories( i18n("SyncEvent") ); 973 eventRSync->setCategories( i18n("SyncEvent") );
974 } 974 }
975 } 975 }
976 if ( eventLSync->dtStart() == mLastCalendarSync ) 976 if ( eventLSync->dtStart() == mLastCalendarSync )
977 fullDateRange = true; 977 fullDateRange = true;
978 978
979 if ( ! fullDateRange ) { 979 if ( ! fullDateRange ) {
980 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 980 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
981 981
982 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 982 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
983 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 983 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
984 fullDateRange = true; 984 fullDateRange = true;
985 } 985 }
986 } 986 }
987 if ( mSyncManager->syncWithDesktop() ) { 987 if ( mSyncManager->syncWithDesktop() ) {
988 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); 988 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync );
989 } 989 }
990 if ( fullDateRange ) 990 if ( fullDateRange )
991 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 991 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
992 else 992 else
993 mLastCalendarSync = eventLSync->dtStart(); 993 mLastCalendarSync = eventLSync->dtStart();
994 // for resyncing if own file has changed 994 // for resyncing if own file has changed
995 if ( mCurrentSyncDevice == "deleteaftersync" ) { 995 if ( mCurrentSyncDevice == "deleteaftersync" ) {
996 mLastCalendarSync = loadedFileVersion; 996 mLastCalendarSync = loadedFileVersion;
997 //qDebug("setting mLastCalendarSync "); 997 //qDebug("setting mLastCalendarSync ");
998 } 998 }
999 //qDebug("*************************** "); 999 //qDebug("*************************** ");
1000 qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); 1000 qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange);
1001 QPtrList<Incidence> er = remote->rawIncidences(); 1001 QPtrList<Incidence> er = remote->rawIncidences();
1002 Incidence* inR = er.first(); 1002 Incidence* inR = er.first();
1003 Incidence* inL; 1003 Incidence* inL;
1004 QProgressBar bar( er.count(),0 ); 1004 QProgressBar bar( er.count(),0 );
1005 bar.setCaption (i18n("Syncing - close to abort!") ); 1005 bar.setCaption (i18n("Syncing - close to abort!") );
1006 1006
1007 // ************** setting up filter ************* 1007 // ************** setting up filter *************
1008 CalFilter *filterIN = 0; 1008 CalFilter *filterIN = 0;
1009 CalFilter *filterOUT = 0; 1009 CalFilter *filterOUT = 0;
1010 CalFilter *filter = mFilters.first(); 1010 CalFilter *filter = mFilters.first();
1011 while(filter) { 1011 while(filter) {
1012 if ( filter->name() == mSyncManager->mFilterInCal ) 1012 if ( filter->name() == mSyncManager->mFilterInCal )
1013 filterIN = filter; 1013 filterIN = filter;
1014 if ( filter->name() == mSyncManager->mFilterOutCal ) 1014 if ( filter->name() == mSyncManager->mFilterOutCal )
1015 filterOUT = filter; 1015 filterOUT = filter;
1016 filter = mFilters.next(); 1016 filter = mFilters.next();
1017 } 1017 }
1018 int w = 300; 1018 int w = 300;
1019 if ( QApplication::desktop()->width() < 320 ) 1019 if ( QApplication::desktop()->width() < 320 )
1020 w = 220; 1020 w = 220;
1021 int h = bar.sizeHint().height() ; 1021 int h = bar.sizeHint().height() ;
1022 int dw = QApplication::desktop()->width(); 1022 int dw = QApplication::desktop()->width();
1023 int dh = QApplication::desktop()->height(); 1023 int dh = QApplication::desktop()->height();
1024 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1024 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1025 bar.show(); 1025 bar.show();
1026 int modulo = (er.count()/10)+1; 1026 int modulo = (er.count()/10)+1;
1027 int incCounter = 0; 1027 int incCounter = 0;
1028 while ( inR ) { 1028 while ( inR ) {
1029 if ( ! bar.isVisible() ) 1029 if ( ! bar.isVisible() )
1030 return false; 1030 return false;
1031 if ( incCounter % modulo == 0 ) 1031 if ( incCounter % modulo == 0 )
1032 bar.setProgress( incCounter ); 1032 bar.setProgress( incCounter );
1033 ++incCounter; 1033 ++incCounter;
1034 uid = inR->uid(); 1034 uid = inR->uid();
1035 bool skipIncidence = false; 1035 bool skipIncidence = false;
1036 if ( uid.left(15) == QString("last-syncEvent-") ) 1036 if ( uid.left(15) == QString("last-syncEvent-") )
1037 skipIncidence = true; 1037 skipIncidence = true;
1038 QString idS; 1038 QString idS;
1039 qApp->processEvents(); 1039 qApp->processEvents();
1040 if ( !skipIncidence ) { 1040 if ( !skipIncidence ) {
1041 inL = local->incidence( uid ); 1041 inL = local->incidence( uid );
1042 if ( inL ) { // maybe conflict - same uid in both calendars 1042 if ( inL ) { // maybe conflict - same uid in both calendars
1043 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1043 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1044 //qDebug("take %d %s ", take, inL->summary().latin1()); 1044 //qDebug("take %d %s ", take, inL->summary().latin1());
1045 if ( take == 3 ) 1045 if ( take == 3 )
1046 return false; 1046 return false;
1047 if ( take == 1 ) {// take local ********************** 1047 if ( take == 1 ) {// take local **********************
1048 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1048 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1049 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1049 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1050 else 1050 else
1051 idS = inR->IDStr(); 1051 idS = inR->IDStr();
1052 remote->deleteIncidence( inR ); 1052 remote->deleteIncidence( inR );
1053 inR = inL->clone(); 1053 inR = inL->clone();
1054 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1054 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1055 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1055 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1056 inR->setIDStr( idS ); 1056 inR->setIDStr( idS );
1057 remote->addIncidence( inR ); 1057 remote->addIncidence( inR );
1058 if ( mSyncManager->syncWithDesktop() ) 1058 if ( mSyncManager->syncWithDesktop() )
1059 inR->setPilotId( 2 ); 1059 inR->setPilotId( 2 );
1060 ++changedRemote; 1060 ++changedRemote;
1061 } else {// take remote ********************** 1061 } else {// take remote **********************
1062 idS = inL->IDStr(); 1062 idS = inL->IDStr();
1063 int pid = inL->pilotId(); 1063 int pid = inL->pilotId();
1064 local->deleteIncidence( inL ); 1064 local->deleteIncidence( inL );
1065 inL = inR->clone(); 1065 inL = inR->clone();
1066 if ( mSyncManager->syncWithDesktop() ) 1066 if ( mSyncManager->syncWithDesktop() )
1067 inL->setPilotId( pid ); 1067 inL->setPilotId( pid );
1068 inL->setIDStr( idS ); 1068 inL->setIDStr( idS );
1069 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1069 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1070 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1070 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1071 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1071 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1072 } 1072 }
1073 local->addIncidence( inL ); 1073 local->addIncidence( inL );
1074 ++changedLocal; 1074 ++changedLocal;
1075 } 1075 }
1076 } 1076 }
1077 } else { // no conflict ********** add or delete remote 1077 } else { // no conflict ********** add or delete remote
1078 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ 1078 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){
1079 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1079 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1080 QString des = eventLSync->description(); 1080 QString des = eventLSync->description();
1081 QString pref = "e"; 1081 QString pref = "e";
1082 if ( inR->type() == "Todo" ) 1082 if ( inR->type() == "Todo" )
1083 pref = "t"; 1083 pref = "t";
1084 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1084 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1085 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1085 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1086 //remote->deleteIncidence( inR ); 1086 //remote->deleteIncidence( inR );
1087 ++deletedEventR; 1087 ++deletedEventR;
1088 } else { 1088 } else {
1089 inR->setLastModified( modifiedCalendar ); 1089 inR->setLastModified( modifiedCalendar );
1090 inL = inR->clone(); 1090 inL = inR->clone();
1091 inL->setIDStr( ":" ); 1091 inL->setIDStr( ":" );
1092 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1092 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1093 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1093 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1094 local->addIncidence( inL ); 1094 local->addIncidence( inL );
1095 ++addedEvent; 1095 ++addedEvent;
1096 1096
1097 } 1097 }
1098 } else { 1098 } else {
1099 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1099 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1100 inR->setLastModified( modifiedCalendar ); 1100 inR->setLastModified( modifiedCalendar );
1101 inL = inR->clone(); 1101 inL = inR->clone();
1102 inL->setIDStr( ":" ); 1102 inL->setIDStr( ":" );
1103 local->addIncidence( inL ); 1103 local->addIncidence( inL );
1104 ++addedEvent; 1104 ++addedEvent;
1105 1105
1106 } else { 1106 } else {
1107 checkExternSyncEvent(eventRSyncSharp, inR); 1107 checkExternSyncEvent(eventRSyncSharp, inR);
1108 remote->deleteIncidence( inR ); 1108 remote->deleteIncidence( inR );
1109 ++deletedEventR; 1109 ++deletedEventR;
1110 } 1110 }
1111 } 1111 }
1112 } else { 1112 } else {
1113 ++filteredIN; 1113 ++filteredIN;
1114 } 1114 }
1115 } 1115 }
1116 } 1116 }
1117 inR = er.next(); 1117 inR = er.next();
1118 } 1118 }
1119 QPtrList<Incidence> el = local->rawIncidences(); 1119 QPtrList<Incidence> el = local->rawIncidences();
1120 inL = el.first(); 1120 inL = el.first();
1121 modulo = (el.count()/10)+1; 1121 modulo = (el.count()/10)+1;
1122 bar.setCaption (i18n("Add / remove events") ); 1122 bar.setCaption (i18n("Add / remove events") );
1123 bar.setTotalSteps ( el.count() ) ; 1123 bar.setTotalSteps ( el.count() ) ;
1124 bar.show(); 1124 bar.show();
1125 incCounter = 0; 1125 incCounter = 0;
1126 1126
1127 while ( inL ) { 1127 while ( inL ) {
1128 1128
1129 qApp->processEvents(); 1129 qApp->processEvents();
1130 if ( ! bar.isVisible() ) 1130 if ( ! bar.isVisible() )
1131 return false; 1131 return false;
1132 if ( incCounter % modulo == 0 ) 1132 if ( incCounter % modulo == 0 )
1133 bar.setProgress( incCounter ); 1133 bar.setProgress( incCounter );
1134 ++incCounter; 1134 ++incCounter;
1135 uid = inL->uid(); 1135 uid = inL->uid();
1136 bool skipIncidence = false; 1136 bool skipIncidence = false;
1137 if ( uid.left(15) == QString("last-syncEvent-") ) 1137 if ( uid.left(15) == QString("last-syncEvent-") )
1138 skipIncidence = true; 1138 skipIncidence = true;
1139 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) 1139 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
1140 skipIncidence = true; 1140 skipIncidence = true;
1141 if ( !skipIncidence ) { 1141 if ( !skipIncidence ) {
1142 inR = remote->incidence( uid ); 1142 inR = remote->incidence( uid );
1143 if ( ! inR ) { 1143 if ( ! inR ) {
1144 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ 1144 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){
1145 // no conflict ********** add or delete local 1145 // no conflict ********** add or delete local
1146 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1146 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1147 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1147 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1148 checkExternSyncEvent(eventLSyncSharp, inL); 1148 checkExternSyncEvent(eventLSyncSharp, inL);
1149 local->deleteIncidence( inL ); 1149 local->deleteIncidence( inL );
1150 ++deletedEventL; 1150 ++deletedEventL;
1151 } else { 1151 } else {
1152 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1152 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1153 inL->removeID(mCurrentSyncDevice ); 1153 inL->removeID(mCurrentSyncDevice );
1154 ++addedEventR; 1154 ++addedEventR;
1155 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1155 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1156 inL->setLastModified( modifiedCalendar ); 1156 inL->setLastModified( modifiedCalendar );
1157 inR = inL->clone(); 1157 inR = inL->clone();
1158 inR->setIDStr( ":" ); 1158 inR->setIDStr( ":" );
1159 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1159 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1160 remote->addIncidence( inR ); 1160 remote->addIncidence( inR );
1161 } 1161 }
1162 } 1162 }
1163 } else { 1163 } else {
1164 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1164 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1165 checkExternSyncEvent(eventLSyncSharp, inL); 1165 checkExternSyncEvent(eventLSyncSharp, inL);
1166 local->deleteIncidence( inL ); 1166 local->deleteIncidence( inL );
1167 ++deletedEventL; 1167 ++deletedEventL;
1168 } else { 1168 } else {
1169 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1169 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1170 ++addedEventR; 1170 ++addedEventR;
1171 inL->setLastModified( modifiedCalendar ); 1171 inL->setLastModified( modifiedCalendar );
1172 inR = inL->clone(); 1172 inR = inL->clone();
1173 inR->setIDStr( ":" ); 1173 inR->setIDStr( ":" );
1174 remote->addIncidence( inR ); 1174 remote->addIncidence( inR );
1175 } 1175 }
1176 } 1176 }
1177 } 1177 }
1178 } else { 1178 } else {
1179 ++filteredOUT; 1179 ++filteredOUT;
1180 } 1180 }
1181 } 1181 }
1182 } 1182 }
1183 inL = el.next(); 1183 inL = el.next();
1184 } 1184 }
1185 int delFut = 0; 1185 int delFut = 0;
1186 int remRem = 0; 1186 int remRem = 0;
1187 if ( mSyncManager->mWriteBackInFuture ) { 1187 if ( mSyncManager->mWriteBackInFuture ) {
1188 er = remote->rawIncidences(); 1188 er = remote->rawIncidences();
1189 remRem = er.count(); 1189 remRem = er.count();
1190 inR = er.first(); 1190 inR = er.first();
1191 QDateTime dt; 1191 QDateTime dt;
1192 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); 1192 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) );
1193 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); 1193 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 );
1194 while ( inR ) { 1194 while ( inR ) {
1195 if ( inR->type() == "Todo" ) { 1195 if ( inR->type() == "Todo" ) {
1196 Todo * t = (Todo*)inR; 1196 Todo * t = (Todo*)inR;
1197 if ( t->hasDueDate() ) 1197 if ( t->hasDueDate() )
1198 dt = t->dtDue(); 1198 dt = t->dtDue();
1199 else 1199 else
1200 dt = cur.addSecs( 62 ); 1200 dt = cur.addSecs( 62 );
1201 } 1201 }
1202 else if (inR->type() == "Event" ) { 1202 else if (inR->type() == "Event" ) {
1203 bool ok; 1203 bool ok;
1204 dt = inR->getNextOccurence( cur, &ok ); 1204 dt = inR->getNextOccurence( cur, &ok );
1205 if ( !ok ) 1205 if ( !ok )
1206 dt = cur.addSecs( -62 ); 1206 dt = cur.addSecs( -62 );
1207 } 1207 }
1208 else 1208 else
1209 dt = inR->dtStart(); 1209 dt = inR->dtStart();
1210 if ( dt < cur || dt > end ) { 1210 if ( dt < cur || dt > end ) {
1211 remote->deleteIncidence( inR ); 1211 remote->deleteIncidence( inR );
1212 ++delFut; 1212 ++delFut;
1213 } 1213 }
1214 inR = er.next(); 1214 inR = er.next();
1215 } 1215 }
1216 } 1216 }
1217 bar.hide(); 1217 bar.hide();
1218 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1218 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1219 eventLSync->setReadOnly( false ); 1219 eventLSync->setReadOnly( false );
1220 eventLSync->setDtStart( mLastCalendarSync ); 1220 eventLSync->setDtStart( mLastCalendarSync );
1221 eventRSync->setDtStart( mLastCalendarSync ); 1221 eventRSync->setDtStart( mLastCalendarSync );
1222 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1222 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1223 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1223 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1224 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1224 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1225 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1225 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1226 eventLSync->setReadOnly( true ); 1226 eventLSync->setReadOnly( true );
1227 qDebug("********** %d %d ", mGlobalSyncMode == SYNC_MODE_NORMAL, mSyncManager->syncWithDesktop() ); 1227 qDebug("********** %d %d ", mGlobalSyncMode == SYNC_MODE_NORMAL, mSyncManager->syncWithDesktop() );
1228 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... 1228 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal...
1229 remote->addEvent( eventRSync ); 1229 remote->addEvent( eventRSync );
1230 else 1230 else
1231 delete eventRSync; 1231 delete eventRSync;
1232 QString mes; 1232 QString mes;
1233 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); 1233 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT );
1234 QString delmess; 1234 QString delmess;
1235 if ( delFut ) { 1235 if ( delFut ) {
1236 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); 1236 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut);
1237 mes += delmess; 1237 mes += delmess;
1238 } 1238 }
1239 mes = i18n("Local calendar changed!\n") +mes; 1239 mes = i18n("Local calendar changed!\n") +mes;
1240 mCalendar->checkAlarmForIncidence( 0, true ); 1240 mCalendar->checkAlarmForIncidence( 0, true );
1241 qDebug( mes ); 1241 qDebug( mes );
1242 if ( mSyncManager->mShowSyncSummary ) { 1242 if ( mSyncManager->mShowSyncSummary ) {
1243 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 1243 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
1244 i18n("KO/Pi Synchronization"),i18n("Write back"))) { 1244 i18n("KO/Pi Synchronization"),i18n("Write back"))) {
1245 qDebug("cancelled "); 1245 qDebug("cancelled ");
1246 return false; 1246 return false;
1247 } 1247 }
1248 } 1248 }
1249 return syncOK; 1249 return syncOK;
1250} 1250}
1251 1251
1252void CalendarView::setSyncDevice( QString s ) 1252void CalendarView::setSyncDevice( QString s )
1253{ 1253{
1254 mCurrentSyncDevice= s; 1254 mCurrentSyncDevice= s;
1255} 1255}
1256void CalendarView::setSyncName( QString s ) 1256void CalendarView::setSyncName( QString s )
1257{ 1257{
1258 mCurrentSyncName= s; 1258 mCurrentSyncName= s;
1259} 1259}
1260bool CalendarView::syncCalendar(QString filename, int mode) 1260bool CalendarView::syncCalendar(QString filename, int mode)
1261{ 1261{
1262 //qDebug("syncCalendar %s ", filename.latin1()); 1262 //qDebug("syncCalendar %s ", filename.latin1());
1263 mGlobalSyncMode = SYNC_MODE_NORMAL; 1263 mGlobalSyncMode = SYNC_MODE_NORMAL;
1264 CalendarLocal* calendar = new CalendarLocal(); 1264 CalendarLocal* calendar = new CalendarLocal();
1265 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1265 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1266 FileStorage* storage = new FileStorage( calendar ); 1266 FileStorage* storage = new FileStorage( calendar );
1267 bool syncOK = false; 1267 bool syncOK = false;
1268 storage->setFileName( filename ); 1268 storage->setFileName( filename );
1269 // qDebug("loading ... "); 1269 // qDebug("loading ... ");
1270 if ( storage->load() ) { 1270 if ( storage->load() ) {
1271 getEventViewerDialog()->setSyncMode( true ); 1271 getEventViewerDialog()->setSyncMode( true );
1272 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1272 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1273 getEventViewerDialog()->setSyncMode( false ); 1273 getEventViewerDialog()->setSyncMode( false );
1274 if ( syncOK ) { 1274 if ( syncOK ) {
1275 if ( mSyncManager->mWriteBackFile ) 1275 if ( mSyncManager->mWriteBackFile )
1276 { 1276 {
1277 storage->setSaveFormat( new ICalFormat() ); 1277 storage->setSaveFormat( new ICalFormat() );
1278 storage->save(); 1278 storage->save();
1279 } 1279 }
1280 } 1280 }
1281 setModified( true ); 1281 setModified( true );
1282 } 1282 }
1283 delete storage; 1283 delete storage;
1284 delete calendar; 1284 delete calendar;
1285 if ( syncOK ) 1285 if ( syncOK )
1286 updateView(); 1286 updateView();
1287 return syncOK; 1287 return syncOK;
1288} 1288}
1289 1289
1290void CalendarView::syncExternal( int mode ) 1290void CalendarView::syncExternal( int mode )
1291{ 1291{
1292 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1292 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1293 1293
1294 qApp->processEvents(); 1294 qApp->processEvents();
1295 CalendarLocal* calendar = new CalendarLocal(); 1295 CalendarLocal* calendar = new CalendarLocal();
1296 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1296 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1297 bool syncOK = false; 1297 bool syncOK = false;
1298 bool loadSuccess = false; 1298 bool loadSuccess = false;
1299 PhoneFormat* phoneFormat = 0; 1299 PhoneFormat* phoneFormat = 0;
1300 emit tempDisableBR(true); 1300 emit tempDisableBR(true);
1301#ifndef DESKTOP_VERSION 1301#ifndef DESKTOP_VERSION
1302 SharpFormat* sharpFormat = 0; 1302 SharpFormat* sharpFormat = 0;
1303 if ( mode == 0 ) { // sharp 1303 if ( mode == 0 ) { // sharp
1304 sharpFormat = new SharpFormat () ; 1304 sharpFormat = new SharpFormat () ;
1305 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1305 loadSuccess = sharpFormat->load( calendar, mCalendar );
1306 1306
1307 } else 1307 } else
1308#endif 1308#endif
1309 if ( mode == 1 ) { // phone 1309 if ( mode == 1 ) { // phone
1310 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1310 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1311 mSyncManager->mPhoneDevice, 1311 mSyncManager->mPhoneDevice,
1312 mSyncManager->mPhoneConnection, 1312 mSyncManager->mPhoneConnection,
1313 mSyncManager->mPhoneModel); 1313 mSyncManager->mPhoneModel);
1314 loadSuccess = phoneFormat->load( calendar,mCalendar); 1314 loadSuccess = phoneFormat->load( calendar,mCalendar);
1315 1315
1316 } else { 1316 } else {
1317 emit tempDisableBR(false); 1317 emit tempDisableBR(false);
1318 return; 1318 return;
1319 } 1319 }
1320 if ( loadSuccess ) { 1320 if ( loadSuccess ) {
1321 getEventViewerDialog()->setSyncMode( true ); 1321 getEventViewerDialog()->setSyncMode( true );
1322 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1322 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1323 getEventViewerDialog()->setSyncMode( false ); 1323 getEventViewerDialog()->setSyncMode( false );
1324 qApp->processEvents(); 1324 qApp->processEvents();
1325 if ( syncOK ) { 1325 if ( syncOK ) {
1326 if ( mSyncManager->mWriteBackFile ) 1326 if ( mSyncManager->mWriteBackFile )
1327 { 1327 {
1328 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1328 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1329 Incidence* inc = iL.first(); 1329 Incidence* inc = iL.first();
1330 if ( phoneFormat ) { 1330 if ( phoneFormat ) {
1331 while ( inc ) { 1331 while ( inc ) {
1332 inc->removeID(mCurrentSyncDevice); 1332 inc->removeID(mCurrentSyncDevice);
1333 inc = iL.next(); 1333 inc = iL.next();
1334 } 1334 }
1335 } 1335 }
1336#ifndef DESKTOP_VERSION 1336#ifndef DESKTOP_VERSION
1337 if ( sharpFormat ) 1337 if ( sharpFormat )
1338 sharpFormat->save(calendar); 1338 sharpFormat->save(calendar);
1339#endif 1339#endif
1340 if ( phoneFormat ) 1340 if ( phoneFormat )
1341 phoneFormat->save(calendar); 1341 phoneFormat->save(calendar);
1342 iL = calendar->rawIncidences(); 1342 iL = calendar->rawIncidences();
1343 inc = iL.first(); 1343 inc = iL.first();
1344 Incidence* loc; 1344 Incidence* loc;
1345 while ( inc ) { 1345 while ( inc ) {
1346 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1346 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1347 loc = mCalendar->incidence(inc->uid() ); 1347 loc = mCalendar->incidence(inc->uid() );
1348 if ( loc ) { 1348 if ( loc ) {
1349 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1349 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1350 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1350 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1351 } 1351 }
1352 } 1352 }
1353 inc = iL.next(); 1353 inc = iL.next();
1354 } 1354 }
1355 Incidence* lse = getLastSyncEvent(); 1355 Incidence* lse = getLastSyncEvent();
1356 if ( lse ) { 1356 if ( lse ) {
1357 lse->setReadOnly( false ); 1357 lse->setReadOnly( false );
1358 lse->setDescription( "" ); 1358 lse->setDescription( "" );
1359 lse->setReadOnly( true ); 1359 lse->setReadOnly( true );
1360 } 1360 }
1361 } 1361 }
1362 } else { 1362 } else {
1363 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 1363 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
1364 } 1364 }
1365 setModified( true ); 1365 setModified( true );
1366 } else { 1366 } else {
1367 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1367 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1368 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1368 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1369 question, i18n("Ok")) ; 1369 question, i18n("Ok")) ;
1370 1370
1371 } 1371 }
1372 delete calendar; 1372 delete calendar;
1373 updateView(); 1373 updateView();
1374 emit tempDisableBR(false); 1374 emit tempDisableBR(false);
1375 return ;//syncOK; 1375 return ;//syncOK;
1376 1376
1377} 1377}
1378 1378
1379bool CalendarView::importBday() 1379bool CalendarView::importBday()
1380{ 1380{
1381#ifndef KORG_NOKABC 1381#ifndef KORG_NOKABC
1382 1382
1383#ifdef DESKTOP_VERSION 1383#ifdef DESKTOP_VERSION
1384 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1384 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1385 KABC::AddressBook::Iterator it; 1385 KABC::AddressBook::Iterator it;
1386 int count = 0; 1386 int count = 0;
1387 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1387 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1388 ++count; 1388 ++count;
1389 } 1389 }
1390 QProgressBar bar(count,0 ); 1390 QProgressBar bar(count,0 );
1391 int w = 300; 1391 int w = 300;
1392 if ( QApplication::desktop()->width() < 320 ) 1392 if ( QApplication::desktop()->width() < 320 )
1393 w = 220; 1393 w = 220;
1394 int h = bar.sizeHint().height() ; 1394 int h = bar.sizeHint().height() ;
1395 int dw = QApplication::desktop()->width(); 1395 int dw = QApplication::desktop()->width();
1396 int dh = QApplication::desktop()->height(); 1396 int dh = QApplication::desktop()->height();
1397 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1397 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1398 bar.show(); 1398 bar.show();
1399 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1399 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1400 qApp->processEvents(); 1400 qApp->processEvents();
1401 count = 0; 1401 count = 0;
1402 int addCount = 0; 1402 int addCount = 0;
1403 KCal::Attendee* a = 0; 1403 KCal::Attendee* a = 0;
1404 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1404 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1405 if ( ! bar.isVisible() ) 1405 if ( ! bar.isVisible() )
1406 return false; 1406 return false;
1407 bar.setProgress( count++ ); 1407 bar.setProgress( count++ );
1408 qApp->processEvents(); 1408 qApp->processEvents();
1409 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1409 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1410 if ( (*it).birthday().date().isValid() ){ 1410 if ( (*it).birthday().date().isValid() ){
1411 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1411 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1412 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1412 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1413 ++addCount; 1413 ++addCount;
1414 } 1414 }
1415 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1415 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1416 if ( anni.isValid() ){ 1416 if ( anni.isValid() ){
1417 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1417 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1418 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1418 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1419 ++addCount; 1419 ++addCount;
1420 } 1420 }
1421 } 1421 }
1422 updateView(); 1422 updateView();
1423 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1423 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1424#else //DESKTOP_VERSION 1424#else //DESKTOP_VERSION
1425 1425
1426 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 1426 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
1427 // the result should now arrive through method insertBirthdays 1427 // the result should now arrive through method insertBirthdays
1428 1428
1429#endif //DESKTOP_VERSION 1429#endif //DESKTOP_VERSION
1430 1430
1431#endif //KORG_NOKABC 1431#endif //KORG_NOKABC
1432 1432
1433 1433
1434 return true; 1434 return true;
1435} 1435}
1436 1436
1437// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI 1437// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
1438void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, 1438void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
1439 const QStringList& anniversaryList, const QStringList& realNameList, 1439 const QStringList& anniversaryList, const QStringList& realNameList,
1440 const QStringList& emailList, const QStringList& assembledNameList, 1440 const QStringList& emailList, const QStringList& assembledNameList,
1441 const QStringList& uidList) 1441 const QStringList& uidList)
1442{ 1442{
1443 qDebug("CalendarView::insertBirthdays"); 1443 qDebug("CalendarView::insertBirthdays");
1444 if (uid == this->name()) 1444 if (uid == this->name())
1445 { 1445 {
1446 int count = birthdayList.count(); 1446 int count = birthdayList.count();
1447 int addCount = 0; 1447 int addCount = 0;
1448 KCal::Attendee* a = 0; 1448 KCal::Attendee* a = 0;
1449 1449
1450 qDebug("CalView 1 %i", count); 1450 qDebug("CalView 1 %i", count);
1451 1451
1452 QProgressBar bar(count,0 ); 1452 QProgressBar bar(count,0 );
1453 int w = 300; 1453 int w = 300;
1454 if ( QApplication::desktop()->width() < 320 ) 1454 if ( QApplication::desktop()->width() < 320 )
1455 w = 220; 1455 w = 220;
1456 int h = bar.sizeHint().height() ; 1456 int h = bar.sizeHint().height() ;
1457 int dw = QApplication::desktop()->width(); 1457 int dw = QApplication::desktop()->width();
1458 int dh = QApplication::desktop()->height(); 1458 int dh = QApplication::desktop()->height();
1459 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1459 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1460 bar.show(); 1460 bar.show();
1461 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 1461 bar.setCaption (i18n("inserting birthdays - close to abort!") );
1462 qApp->processEvents(); 1462 qApp->processEvents();
1463 1463
1464 QDate birthday; 1464 QDate birthday;
1465 QDate anniversary; 1465 QDate anniversary;
1466 QString realName; 1466 QString realName;
1467 QString email; 1467 QString email;
1468 QString assembledName; 1468 QString assembledName;
1469 QString uid; 1469 QString uid;
1470 bool ok = true; 1470 bool ok = true;
1471 for ( int i = 0; i < count; i++) 1471 for ( int i = 0; i < count; i++)
1472 { 1472 {
1473 if ( ! bar.isVisible() ) 1473 if ( ! bar.isVisible() )
1474 return; 1474 return;
1475 bar.setProgress( i ); 1475 bar.setProgress( i );
1476 qApp->processEvents(); 1476 qApp->processEvents();
1477 1477
1478 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); 1478 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
1479 if (!ok) { 1479 if (!ok) {
1480 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); 1480 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
1481 } 1481 }
1482 1482
1483 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); 1483 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
1484 if (!ok) { 1484 if (!ok) {
1485 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); 1485 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
1486 } 1486 }
1487 realName = realNameList[i]; 1487 realName = realNameList[i];
1488 email = emailList[i]; 1488 email = emailList[i];
1489 assembledName = assembledNameList[i]; 1489 assembledName = assembledNameList[i];
1490 uid = uidList[i]; 1490 uid = uidList[i];
1491 //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); 1491 //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() );
1492 1492
1493 if ( birthday.isValid() ){ 1493 if ( birthday.isValid() ){
1494 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1494 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1495 KCal::Attendee::ReqParticipant,uid) ; 1495 KCal::Attendee::ReqParticipant,uid) ;
1496 if ( addAnniversary( birthday, assembledName, a, true ) ) 1496 if ( addAnniversary( birthday, assembledName, a, true ) )
1497 ++addCount; 1497 ++addCount;
1498 } 1498 }
1499 1499
1500 if ( anniversary.isValid() ){ 1500 if ( anniversary.isValid() ){
1501 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1501 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1502 KCal::Attendee::ReqParticipant,uid) ; 1502 KCal::Attendee::ReqParticipant,uid) ;
1503 if ( addAnniversary( anniversary, assembledName, a, false ) ) 1503 if ( addAnniversary( anniversary, assembledName, a, false ) )
1504 ++addCount; 1504 ++addCount;
1505 } 1505 }
1506 } 1506 }
1507 1507
1508 updateView(); 1508 updateView();
1509 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1509 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1510 1510
1511 } 1511 }
1512 1512
1513} 1513}
1514 1514
1515 1515
1516 1516
1517bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1517bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1518{ 1518{
1519 //qDebug("addAnni "); 1519 //qDebug("addAnni ");
1520 Event * ev = new Event(); 1520 Event * ev = new Event();
1521 if ( a ) { 1521 if ( a ) {
1522 ev->addAttendee( a ); 1522 ev->addAttendee( a );
1523 } 1523 }
1524 QString kind; 1524 QString kind;
1525 if ( birthday ) 1525 if ( birthday )
1526 kind = i18n( "Birthday" ); 1526 kind = i18n( "Birthday" );
1527 else 1527 else
1528 kind = i18n( "Anniversary" ); 1528 kind = i18n( "Anniversary" );
1529 ev->setSummary( name + " - " + kind ); 1529 ev->setSummary( name + " - " + kind );
1530 ev->setOrganizer(a->email()); 1530 ev->setOrganizer(a->email());
1531 ev->setCategories( kind ); 1531 ev->setCategories( kind );
1532 ev->setDtStart( QDateTime(date) ); 1532 ev->setDtStart( QDateTime(date) );
1533 ev->setDtEnd( QDateTime(date) ); 1533 ev->setDtEnd( QDateTime(date) );
1534 ev->setFloats( true ); 1534 ev->setFloats( true );
1535 Recurrence * rec = ev->recurrence(); 1535 Recurrence * rec = ev->recurrence();
1536 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1536 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1537 rec->addYearlyNum( date.month() ); 1537 rec->addYearlyNum( date.month() );
1538 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1538 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1539 delete ev; 1539 delete ev;
1540 return false; 1540 return false;
1541 } 1541 }
1542 return true; 1542 return true;
1543 1543
1544} 1544}
1545bool CalendarView::importQtopia( const QString &categories, 1545bool CalendarView::importQtopia( const QString &categories,
1546 const QString &datebook, 1546 const QString &datebook,
1547 const QString &todolist ) 1547 const QString &todolist )
1548{ 1548{
1549 1549
1550 QtopiaFormat qtopiaFormat; 1550 QtopiaFormat qtopiaFormat;
1551 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1551 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1552 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1552 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1553 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1553 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1554 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1554 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1555 1555
1556 updateView(); 1556 updateView();
1557 return true; 1557 return true;
1558 1558
1559#if 0 1559#if 0
1560 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1560 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1561 mCurrentSyncDevice = "qtopia-XML"; 1561 mCurrentSyncDevice = "qtopia-XML";
1562 if ( mSyncManager->mAskForPreferences ) 1562 if ( mSyncManager->mAskForPreferences )
1563 edit_sync_options(); 1563 edit_sync_options();
1564 qApp->processEvents(); 1564 qApp->processEvents();
1565 CalendarLocal* calendar = new CalendarLocal(); 1565 CalendarLocal* calendar = new CalendarLocal();
1566 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1566 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1567 bool syncOK = false; 1567 bool syncOK = false;
1568 QtopiaFormat qtopiaFormat; 1568 QtopiaFormat qtopiaFormat;
1569 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1569 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1570 bool loadOk = true; 1570 bool loadOk = true;
1571 if ( !categories.isEmpty() ) 1571 if ( !categories.isEmpty() )
1572 loadOk = qtopiaFormat.load( calendar, categories ); 1572 loadOk = qtopiaFormat.load( calendar, categories );
1573 if ( loadOk && !datebook.isEmpty() ) 1573 if ( loadOk && !datebook.isEmpty() )
1574 loadOk = qtopiaFormat.load( calendar, datebook ); 1574 loadOk = qtopiaFormat.load( calendar, datebook );
1575 if ( loadOk && !todolist.isEmpty() ) 1575 if ( loadOk && !todolist.isEmpty() )
1576 loadOk = qtopiaFormat.load( calendar, todolist ); 1576 loadOk = qtopiaFormat.load( calendar, todolist );
1577 1577
1578 if ( loadOk ) { 1578 if ( loadOk ) {
1579 getEventViewerDialog()->setSyncMode( true ); 1579 getEventViewerDialog()->setSyncMode( true );
1580 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1580 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1581 getEventViewerDialog()->setSyncMode( false ); 1581 getEventViewerDialog()->setSyncMode( false );
1582 qApp->processEvents(); 1582 qApp->processEvents();
1583 if ( syncOK ) { 1583 if ( syncOK ) {
1584 if ( mSyncManager->mWriteBackFile ) 1584 if ( mSyncManager->mWriteBackFile )
1585 { 1585 {
1586 // write back XML file 1586 // write back XML file
1587 1587
1588 } 1588 }
1589 setModified( true ); 1589 setModified( true );
1590 } 1590 }
1591 } else { 1591 } else {
1592 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1592 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1593 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1593 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1594 question, i18n("Ok")) ; 1594 question, i18n("Ok")) ;
1595 } 1595 }
1596 delete calendar; 1596 delete calendar;
1597 updateView(); 1597 updateView();
1598 return syncOK; 1598 return syncOK;
1599 1599
1600 1600
1601#endif 1601#endif
1602 1602
1603} 1603}
1604 1604
1605void CalendarView::setSyncEventsReadOnly() 1605void CalendarView::setSyncEventsReadOnly()
1606{ 1606{
1607 Event * ev; 1607 Event * ev;
1608 QPtrList<Event> eL = mCalendar->rawEvents(); 1608 QPtrList<Event> eL = mCalendar->rawEvents();
1609 ev = eL.first(); 1609 ev = eL.first();
1610 while ( ev ) { 1610 while ( ev ) {
1611 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1611 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1612 ev->setReadOnly( true ); 1612 ev->setReadOnly( true );
1613 ev = eL.next(); 1613 ev = eL.next();
1614 } 1614 }
1615} 1615}
1616bool CalendarView::openCalendar(QString filename, bool merge) 1616bool CalendarView::openCalendar(QString filename, bool merge)
1617{ 1617{
1618 1618
1619 if (filename.isEmpty()) { 1619 if (filename.isEmpty()) {
1620 return false; 1620 return false;
1621 } 1621 }
1622 1622
1623 if (!QFile::exists(filename)) { 1623 if (!QFile::exists(filename)) {
1624 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1624 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1625 return false; 1625 return false;
1626 } 1626 }
1627 1627
1628 globalFlagBlockAgenda = 1; 1628 globalFlagBlockAgenda = 1;
1629 if (!merge) mCalendar->close(); 1629 if (!merge) mCalendar->close();
1630 1630
1631 mStorage->setFileName( filename ); 1631 mStorage->setFileName( filename );
1632 1632
1633 if ( mStorage->load() ) { 1633 if ( mStorage->load() ) {
1634 if ( merge ) ;//setModified( true ); 1634 if ( merge ) ;//setModified( true );
1635 else { 1635 else {
1636 //setModified( true ); 1636 //setModified( true );
1637 mViewManager->setDocumentId( filename ); 1637 mViewManager->setDocumentId( filename );
1638 mDialogManager->setDocumentId( filename ); 1638 mDialogManager->setDocumentId( filename );
1639 mTodoList->setDocumentId( filename ); 1639 mTodoList->setDocumentId( filename );
1640 } 1640 }
1641 globalFlagBlockAgenda = 2; 1641 globalFlagBlockAgenda = 2;
1642 // if ( getLastSyncEvent() ) 1642 // if ( getLastSyncEvent() )
1643 // getLastSyncEvent()->setReadOnly( true ); 1643 // getLastSyncEvent()->setReadOnly( true );
1644 mCalendar->reInitAlarmSettings(); 1644 mCalendar->reInitAlarmSettings();
1645 setSyncEventsReadOnly(); 1645 setSyncEventsReadOnly();
1646 updateUnmanagedViews(); 1646 updateUnmanagedViews();
1647 updateView(); 1647 updateView();
1648 if ( filename != MainWindow::defaultFileName() ) { 1648 if ( filename != MainWindow::defaultFileName() ) {
1649 saveCalendar( MainWindow::defaultFileName() ); 1649 saveCalendar( MainWindow::defaultFileName() );
1650 } else { 1650 } else {
1651 QFileInfo finf ( MainWindow::defaultFileName()); 1651 QFileInfo finf ( MainWindow::defaultFileName());
1652 if ( finf.exists() ) { 1652 if ( finf.exists() ) {
1653 setLoadedFileVersion( finf.lastModified () ); 1653 setLoadedFileVersion( finf.lastModified () );
1654 } 1654 }
1655 } 1655 }
1656 return true; 1656 return true;
1657 } else { 1657 } else {
1658 // while failing to load, the calendar object could 1658 // while failing to load, the calendar object could
1659 // have become partially populated. Clear it out. 1659 // have become partially populated. Clear it out.
1660 if ( !merge ) { 1660 if ( !merge ) {
1661 mCalendar->close(); 1661 mCalendar->close();
1662 mViewManager->setDocumentId( filename ); 1662 mViewManager->setDocumentId( filename );
1663 mDialogManager->setDocumentId( filename ); 1663 mDialogManager->setDocumentId( filename );
1664 mTodoList->setDocumentId( filename ); 1664 mTodoList->setDocumentId( filename );
1665 } 1665 }
1666 1666
1667 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1667 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1668 1668
1669 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 1669 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
1670 globalFlagBlockAgenda = 2; 1670 globalFlagBlockAgenda = 2;
1671 mCalendar->reInitAlarmSettings(); 1671 mCalendar->reInitAlarmSettings();
1672 setSyncEventsReadOnly(); 1672 setSyncEventsReadOnly();
1673 updateUnmanagedViews(); 1673 updateUnmanagedViews();
1674 updateView(); 1674 updateView();
1675 } 1675 }
1676 return false; 1676 return false;
1677} 1677}
1678void CalendarView::showOpenError() 1678void CalendarView::showOpenError()
1679{ 1679{
1680 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 1680 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
1681} 1681}
1682void CalendarView::setLoadedFileVersion(QDateTime dt) 1682void CalendarView::setLoadedFileVersion(QDateTime dt)
1683{ 1683{
1684 loadedFileVersion = dt; 1684 loadedFileVersion = dt;
1685} 1685}
1686bool CalendarView::checkFileChanged(QString fn) 1686bool CalendarView::checkFileChanged(QString fn)
1687{ 1687{
1688 QFileInfo finf ( fn ); 1688 QFileInfo finf ( fn );
1689 if ( !finf.exists() ) 1689 if ( !finf.exists() )
1690 return true; 1690 return true;
1691 QDateTime dt = finf.lastModified (); 1691 QDateTime dt = finf.lastModified ();
1692 if ( dt <= loadedFileVersion ) 1692 if ( dt <= loadedFileVersion )
1693 return false; 1693 return false;
1694 return true; 1694 return true;
1695 1695
1696} 1696}
1697void CalendarView::watchSavedFile() 1697void CalendarView::watchSavedFile()
1698{ 1698{
1699 QFileInfo finf ( MainWindow::defaultFileName()); 1699 QFileInfo finf ( MainWindow::defaultFileName());
1700 if ( !finf.exists() ) 1700 if ( !finf.exists() )
1701 return; 1701 return;
1702 QDateTime dt = finf.lastModified (); 1702 QDateTime dt = finf.lastModified ();
1703 if ( dt < loadedFileVersion ) { 1703 if ( dt < loadedFileVersion ) {
1704 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 1704 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
1705 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 1705 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1706 return; 1706 return;
1707 } 1707 }
1708 loadedFileVersion = dt; 1708 loadedFileVersion = dt;
1709} 1709}
1710 1710
1711bool CalendarView::checkFileVersion(QString fn) 1711bool CalendarView::checkFileVersion(QString fn)
1712{ 1712{
1713 QFileInfo finf ( fn ); 1713 QFileInfo finf ( fn );
1714 if ( !finf.exists() ) 1714 if ( !finf.exists() )
1715 return true; 1715 return true;
1716 QDateTime dt = finf.lastModified (); 1716 QDateTime dt = finf.lastModified ();
1717 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1717 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1718 //qDebug("file on disk version %s",dt.toString().latin1()); 1718 //qDebug("file on disk version %s",dt.toString().latin1());
1719 if ( dt <= loadedFileVersion ) 1719 if ( dt <= loadedFileVersion )
1720 return true; 1720 return true;
1721 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , 1721 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) ,
1722 i18n("KO/Pi Warning"),i18n("Overwrite"), 1722 i18n("KO/Pi Warning"),i18n("Overwrite"),
1723 i18n("Sync+save")); 1723 i18n("Sync+save"));
1724 1724
1725 if ( km == KMessageBox::Cancel ) 1725 if ( km == KMessageBox::Cancel )
1726 return false; 1726 return false;
1727 if ( km == KMessageBox::Yes ) 1727 if ( km == KMessageBox::Yes )
1728 return true; 1728 return true;
1729 1729
1730 setSyncDevice("deleteaftersync" ); 1730 setSyncDevice("deleteaftersync" );
1731 mSyncManager->mAskForPreferences = true; 1731 mSyncManager->mAskForPreferences = true;
1732 mSyncManager->mSyncAlgoPrefs = 3; 1732 mSyncManager->mSyncAlgoPrefs = 3;
1733 mSyncManager->mWriteBackFile = false; 1733 mSyncManager->mWriteBackFile = false;
1734 mSyncManager->mWriteBackExistingOnly = false; 1734 mSyncManager->mWriteBackExistingOnly = false;
1735 mSyncManager->mShowSyncSummary = false; 1735 mSyncManager->mShowSyncSummary = false;
1736 syncCalendar( fn, 3 ); 1736 syncCalendar( fn, 3 );
1737 Event * e = getLastSyncEvent(); 1737 Event * e = getLastSyncEvent();
1738 mCalendar->deleteEvent ( e ); 1738 mCalendar->deleteEvent ( e );
1739 updateView(); 1739 updateView();
1740 return true; 1740 return true;
1741} 1741}
1742 1742
1743bool CalendarView::saveCalendar( QString filename ) 1743bool CalendarView::saveCalendar( QString filename )
1744{ 1744{
1745 1745
1746 // Store back all unsaved data into calendar object 1746 // Store back all unsaved data into calendar object
1747 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1747 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1748 if ( mViewManager->currentView() ) 1748 if ( mViewManager->currentView() )
1749 mViewManager->currentView()->flushView(); 1749 mViewManager->currentView()->flushView();
1750 1750
1751 1751
1752 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 1752 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
1753 mStorage->setSaveFormat( new ICalFormat() ); 1753 mStorage->setSaveFormat( new ICalFormat() );
1754 mStorage->setFileName( filename ); 1754 mStorage->setFileName( filename );
1755 bool success; 1755 bool success;
1756 success = mStorage->save(); 1756 success = mStorage->save();
1757 if ( !success ) { 1757 if ( !success ) {
1758 return false; 1758 return false;
1759 } 1759 }
1760 if ( filename == MainWindow::defaultFileName() ) { 1760 if ( filename == MainWindow::defaultFileName() ) {
1761 setLoadedFileVersion( lfv ); 1761 setLoadedFileVersion( lfv );
1762 watchSavedFile(); 1762 watchSavedFile();
1763 } 1763 }
1764 return true; 1764 return true;
1765} 1765}
1766 1766
1767void CalendarView::closeCalendar() 1767void CalendarView::closeCalendar()
1768{ 1768{
1769 1769
1770 // child windows no longer valid 1770 // child windows no longer valid
1771 emit closingDown(); 1771 emit closingDown();
1772 1772
1773 mCalendar->close(); 1773 mCalendar->close();
1774 setModified(false); 1774 setModified(false);
1775 updateView(); 1775 updateView();
1776} 1776}
1777 1777
1778void CalendarView::archiveCalendar() 1778void CalendarView::archiveCalendar()
1779{ 1779{
1780 mDialogManager->showArchiveDialog(); 1780 mDialogManager->showArchiveDialog();
1781} 1781}
1782 1782
1783 1783
1784void CalendarView::readSettings() 1784void CalendarView::readSettings()
1785{ 1785{
1786 1786
1787 1787
1788 // mViewManager->showAgendaView(); 1788 // mViewManager->showAgendaView();
1789 QString str; 1789 QString str;
1790 //qDebug("CalendarView::readSettings() "); 1790 //qDebug("CalendarView::readSettings() ");
1791 // read settings from the KConfig, supplying reasonable 1791 // read settings from the KConfig, supplying reasonable
1792 // defaults where none are to be found 1792 // defaults where none are to be found
1793 KConfig *config = KOGlobals::config(); 1793 KConfig *config = KOGlobals::config();
1794#ifndef KORG_NOSPLITTER 1794#ifndef KORG_NOSPLITTER
1795 config->setGroup("KOrganizer Geometry"); 1795 config->setGroup("KOrganizer Geometry");
1796 1796
1797 QValueList<int> sizes = config->readIntListEntry("Separator1"); 1797 QValueList<int> sizes = config->readIntListEntry("Separator1");
1798 if (sizes.count() != 2) { 1798 if (sizes.count() != 2) {
1799 sizes << mDateNavigator->minimumSizeHint().width(); 1799 sizes << mDateNavigator->minimumSizeHint().width();
1800 sizes << 300; 1800 sizes << 300;
1801 } 1801 }
1802 mPanner->setSizes(sizes); 1802 mPanner->setSizes(sizes);
1803 1803
1804 sizes = config->readIntListEntry("Separator2"); 1804 sizes = config->readIntListEntry("Separator2");
1805 if ( ( mResourceView && sizes.count() == 4 ) || 1805 if ( ( mResourceView && sizes.count() == 4 ) ||
1806 ( !mResourceView && sizes.count() == 3 ) ) { 1806 ( !mResourceView && sizes.count() == 3 ) ) {
1807 mLeftSplitter->setSizes(sizes); 1807 mLeftSplitter->setSizes(sizes);
1808 } 1808 }
1809#endif 1809#endif
1810 globalFlagBlockAgenda = 1; 1810 globalFlagBlockAgenda = 1;
1811 mViewManager->showAgendaView(); 1811 mViewManager->showAgendaView();
1812 //mViewManager->readSettings( config ); 1812 //mViewManager->readSettings( config );
1813 mTodoList->restoreLayout(config,QString("Todo Layout")); 1813 mTodoList->restoreLayout(config,QString("Todo Layout"));
1814 readFilterSettings(config); 1814 readFilterSettings(config);
1815 config->setGroup( "Views" ); 1815 config->setGroup( "Views" );
1816 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 1816 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
1817 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 1817 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
1818 else if ( dateCount == 7 ) mNavigator->selectWeek(); 1818 else if ( dateCount == 7 ) mNavigator->selectWeek();
1819 else mNavigator->selectDates( dateCount ); 1819 else mNavigator->selectDates( dateCount );
1820 // mViewManager->readSettings( config ); 1820 // mViewManager->readSettings( config );
1821 updateConfig(); 1821 updateConfig();
1822 globalFlagBlockAgenda = 2; 1822 globalFlagBlockAgenda = 2;
1823 mViewManager->readSettings( config ); 1823 mViewManager->readSettings( config );
1824#ifdef DESKTOP_VERSION 1824#ifdef DESKTOP_VERSION
1825 config->setGroup("WidgetLayout"); 1825 config->setGroup("WidgetLayout");
1826 QStringList list; 1826 QStringList list;
1827 list = config->readListEntry("MainLayout"); 1827 list = config->readListEntry("MainLayout");
1828 int x,y,w,h; 1828 int x,y,w,h;
1829 if ( ! list.isEmpty() ) { 1829 if ( ! list.isEmpty() ) {
1830 x = list[0].toInt(); 1830 x = list[0].toInt();
1831 y = list[1].toInt(); 1831 y = list[1].toInt();
1832 w = list[2].toInt(); 1832 w = list[2].toInt();
1833 h = list[3].toInt(); 1833 h = list[3].toInt();
1834 topLevelWidget()->setGeometry(x,y,w,h); 1834 topLevelWidget()->setGeometry(x,y,w,h);
1835 1835
1836 } else { 1836 } else {
1837 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 1837 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
1838 } 1838 }
1839 list = config->readListEntry("EditEventLayout"); 1839 list = config->readListEntry("EditEventLayout");
1840 if ( ! list.isEmpty() ) { 1840 if ( ! list.isEmpty() ) {
1841 x = list[0].toInt(); 1841 x = list[0].toInt();
1842 y = list[1].toInt(); 1842 y = list[1].toInt();
1843 w = list[2].toInt(); 1843 w = list[2].toInt();
1844 h = list[3].toInt(); 1844 h = list[3].toInt();
1845 mEventEditor->setGeometry(x,y,w,h); 1845 mEventEditor->setGeometry(x,y,w,h);
1846 1846
1847 } 1847 }
1848 list = config->readListEntry("EditTodoLayout"); 1848 list = config->readListEntry("EditTodoLayout");
1849 if ( ! list.isEmpty() ) { 1849 if ( ! list.isEmpty() ) {
1850 x = list[0].toInt(); 1850 x = list[0].toInt();
1851 y = list[1].toInt(); 1851 y = list[1].toInt();
1852 w = list[2].toInt(); 1852 w = list[2].toInt();
1853 h = list[3].toInt(); 1853 h = list[3].toInt();
1854 mTodoEditor->setGeometry(x,y,w,h); 1854 mTodoEditor->setGeometry(x,y,w,h);
1855 1855
1856 } 1856 }
1857 list = config->readListEntry("ViewerLayout"); 1857 list = config->readListEntry("ViewerLayout");
1858 if ( ! list.isEmpty() ) { 1858 if ( ! list.isEmpty() ) {
1859 x = list[0].toInt(); 1859 x = list[0].toInt();
1860 y = list[1].toInt(); 1860 y = list[1].toInt();
1861 w = list[2].toInt(); 1861 w = list[2].toInt();
1862 h = list[3].toInt(); 1862 h = list[3].toInt();
1863 getEventViewerDialog()->setGeometry(x,y,w,h); 1863 getEventViewerDialog()->setGeometry(x,y,w,h);
1864 } 1864 }
1865#endif 1865#endif
1866 1866
1867} 1867}
1868 1868
1869 1869
1870void CalendarView::writeSettings() 1870void CalendarView::writeSettings()
1871{ 1871{
1872 // kdDebug() << "CalendarView::writeSettings" << endl; 1872 // kdDebug() << "CalendarView::writeSettings" << endl;
1873 1873
1874 KConfig *config = KOGlobals::config(); 1874 KConfig *config = KOGlobals::config();
1875 1875
1876#ifndef KORG_NOSPLITTER 1876#ifndef KORG_NOSPLITTER
1877 config->setGroup("KOrganizer Geometry"); 1877 config->setGroup("KOrganizer Geometry");
1878 1878
1879 QValueList<int> list = mPanner->sizes(); 1879 QValueList<int> list = mPanner->sizes();
1880 config->writeEntry("Separator1",list); 1880 config->writeEntry("Separator1",list);
1881 1881
1882 list = mLeftSplitter->sizes(); 1882 list = mLeftSplitter->sizes();
1883 config->writeEntry("Separator2",list); 1883 config->writeEntry("Separator2",list);
1884#endif 1884#endif
1885 1885
1886 mViewManager->writeSettings( config ); 1886 mViewManager->writeSettings( config );
1887 mTodoList->saveLayout(config,QString("Todo Layout")); 1887 mTodoList->saveLayout(config,QString("Todo Layout"));
1888 mDialogManager->writeSettings( config ); 1888 mDialogManager->writeSettings( config );
1889 //KOPrefs::instance()->usrWriteConfig(); 1889 //KOPrefs::instance()->usrWriteConfig();
1890 KOPrefs::instance()->writeConfig(); 1890 KOPrefs::instance()->writeConfig();
1891 1891
1892 writeFilterSettings(config); 1892 writeFilterSettings(config);
1893 1893
1894 config->setGroup( "Views" ); 1894 config->setGroup( "Views" );
1895 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 1895 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
1896 1896
1897#ifdef DESKTOP_VERSION 1897#ifdef DESKTOP_VERSION
1898 config->setGroup("WidgetLayout"); 1898 config->setGroup("WidgetLayout");
1899 QStringList list ;//= config->readListEntry("MainLayout"); 1899 QStringList list ;//= config->readListEntry("MainLayout");
1900 int x,y,w,h; 1900 int x,y,w,h;
1901 QWidget* wid; 1901 QWidget* wid;
1902 wid = topLevelWidget(); 1902 wid = topLevelWidget();
1903 x = wid->geometry().x(); 1903 x = wid->geometry().x();
1904 y = wid->geometry().y(); 1904 y = wid->geometry().y();
1905 w = wid->width(); 1905 w = wid->width();
1906 h = wid->height(); 1906 h = wid->height();
1907 list.clear(); 1907 list.clear();
1908 list << QString::number( x ); 1908 list << QString::number( x );
1909 list << QString::number( y ); 1909 list << QString::number( y );
1910 list << QString::number( w ); 1910 list << QString::number( w );
1911 list << QString::number( h ); 1911 list << QString::number( h );
1912 config->writeEntry("MainLayout",list ); 1912 config->writeEntry("MainLayout",list );
1913 1913
1914 wid = mEventEditor; 1914 wid = mEventEditor;
1915 x = wid->geometry().x(); 1915 x = wid->geometry().x();
1916 y = wid->geometry().y(); 1916 y = wid->geometry().y();
1917 w = wid->width(); 1917 w = wid->width();
1918 h = wid->height(); 1918 h = wid->height();
1919 list.clear(); 1919 list.clear();
1920 list << QString::number( x ); 1920 list << QString::number( x );
1921 list << QString::number( y ); 1921 list << QString::number( y );
1922 list << QString::number( w ); 1922 list << QString::number( w );
1923 list << QString::number( h ); 1923 list << QString::number( h );
1924 config->writeEntry("EditEventLayout",list ); 1924 config->writeEntry("EditEventLayout",list );
1925 1925
1926 wid = mTodoEditor; 1926 wid = mTodoEditor;
1927 x = wid->geometry().x(); 1927 x = wid->geometry().x();
1928 y = wid->geometry().y(); 1928 y = wid->geometry().y();
1929 w = wid->width(); 1929 w = wid->width();
1930 h = wid->height(); 1930 h = wid->height();
1931 list.clear(); 1931 list.clear();
1932 list << QString::number( x ); 1932 list << QString::number( x );
1933 list << QString::number( y ); 1933 list << QString::number( y );
1934 list << QString::number( w ); 1934 list << QString::number( w );
1935 list << QString::number( h ); 1935 list << QString::number( h );
1936 config->writeEntry("EditTodoLayout",list ); 1936 config->writeEntry("EditTodoLayout",list );
1937 wid = getEventViewerDialog(); 1937 wid = getEventViewerDialog();
1938 x = wid->geometry().x(); 1938 x = wid->geometry().x();
1939 y = wid->geometry().y(); 1939 y = wid->geometry().y();
1940 w = wid->width(); 1940 w = wid->width();
1941 h = wid->height(); 1941 h = wid->height();
1942 list.clear(); 1942 list.clear();
1943 list << QString::number( x ); 1943 list << QString::number( x );
1944 list << QString::number( y ); 1944 list << QString::number( y );
1945 list << QString::number( w ); 1945 list << QString::number( w );
1946 list << QString::number( h ); 1946 list << QString::number( h );
1947 config->writeEntry("ViewerLayout",list ); 1947 config->writeEntry("ViewerLayout",list );
1948 wid = mDialogManager->getSearchDialog(); 1948 wid = mDialogManager->getSearchDialog();
1949 if ( wid ) { 1949 if ( wid ) {
1950 x = wid->geometry().x(); 1950 x = wid->geometry().x();
1951 y = wid->geometry().y(); 1951 y = wid->geometry().y();
1952 w = wid->width(); 1952 w = wid->width();
1953 h = wid->height(); 1953 h = wid->height();
1954 list.clear(); 1954 list.clear();
1955 list << QString::number( x ); 1955 list << QString::number( x );
1956 list << QString::number( y ); 1956 list << QString::number( y );
1957 list << QString::number( w ); 1957 list << QString::number( w );
1958 list << QString::number( h ); 1958 list << QString::number( h );
1959 config->writeEntry("SearchLayout",list ); 1959 config->writeEntry("SearchLayout",list );
1960 } 1960 }
1961#endif 1961#endif
1962 1962
1963 1963
1964 config->sync(); 1964 config->sync();
1965} 1965}
1966 1966
1967void CalendarView::readFilterSettings(KConfig *config) 1967void CalendarView::readFilterSettings(KConfig *config)
1968{ 1968{
1969 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 1969 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
1970 1970
1971 mFilters.clear(); 1971 mFilters.clear();
1972 1972
1973 config->setGroup("General"); 1973 config->setGroup("General");
1974 QStringList filterList = config->readListEntry("CalendarFilters"); 1974 QStringList filterList = config->readListEntry("CalendarFilters");
1975 1975
1976 QStringList::ConstIterator it = filterList.begin(); 1976 QStringList::ConstIterator it = filterList.begin();
1977 QStringList::ConstIterator end = filterList.end(); 1977 QStringList::ConstIterator end = filterList.end();
1978 while(it != end) { 1978 while(it != end) {
1979 // kdDebug() << " filter: " << (*it) << endl; 1979 // kdDebug() << " filter: " << (*it) << endl;
1980 1980
1981 CalFilter *filter; 1981 CalFilter *filter;
1982 filter = new CalFilter(*it); 1982 filter = new CalFilter(*it);
1983 config->setGroup("Filter_" + (*it)); 1983 config->setGroup("Filter_" + (*it));
1984 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 1984 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
1985 filter->setCriteria(config->readNumEntry("Criteria",0)); 1985 filter->setCriteria(config->readNumEntry("Criteria",0));
1986 filter->setCategoryList(config->readListEntry("CategoryList")); 1986 filter->setCategoryList(config->readListEntry("CategoryList"));
1987 mFilters.append(filter); 1987 mFilters.append(filter);
1988 1988
1989 ++it; 1989 ++it;
1990 } 1990 }
1991 1991
1992 if (mFilters.count() == 0) { 1992 if (mFilters.count() == 0) {
1993 CalFilter *filter = new CalFilter(i18n("Default")); 1993 CalFilter *filter = new CalFilter(i18n("Default"));
1994 mFilters.append(filter); 1994 mFilters.append(filter);
1995 } 1995 }
1996 mFilterView->updateFilters(); 1996 mFilterView->updateFilters();
1997 config->setGroup("FilterView"); 1997 config->setGroup("FilterView");
1998 1998
1999 mFilterView->blockSignals(true); 1999 mFilterView->blockSignals(true);
2000 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 2000 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
2001 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 2001 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
2002 mFilterView->blockSignals(false); 2002 mFilterView->blockSignals(false);
2003 // We do it manually to avoid it being done twice by the above calls 2003 // We do it manually to avoid it being done twice by the above calls
2004 updateFilter(); 2004 updateFilter();
2005} 2005}
2006 2006
2007void CalendarView::writeFilterSettings(KConfig *config) 2007void CalendarView::writeFilterSettings(KConfig *config)
2008{ 2008{
2009 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 2009 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
2010 2010
2011 QStringList filterList; 2011 QStringList filterList;
2012 2012
2013 CalFilter *filter = mFilters.first(); 2013 CalFilter *filter = mFilters.first();
2014 while(filter) { 2014 while(filter) {
2015 // kdDebug() << " fn: " << filter->name() << endl; 2015 // kdDebug() << " fn: " << filter->name() << endl;
2016 filterList << filter->name(); 2016 filterList << filter->name();
2017 config->setGroup("Filter_" + filter->name()); 2017 config->setGroup("Filter_" + filter->name());
2018 config->writeEntry("Criteria",filter->criteria()); 2018 config->writeEntry("Criteria",filter->criteria());
2019 config->writeEntry("CategoryList",filter->categoryList()); 2019 config->writeEntry("CategoryList",filter->categoryList());
2020 filter = mFilters.next(); 2020 filter = mFilters.next();
2021 } 2021 }
2022 config->setGroup("General"); 2022 config->setGroup("General");
2023 config->writeEntry("CalendarFilters",filterList); 2023 config->writeEntry("CalendarFilters",filterList);
2024 2024
2025 config->setGroup("FilterView"); 2025 config->setGroup("FilterView");
2026 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 2026 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
2027 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 2027 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
2028} 2028}
2029 2029
2030 2030
2031void CalendarView::goToday() 2031void CalendarView::goToday()
2032{ 2032{
2033 if ( mViewManager->currentView()->isMonthView() ) 2033 if ( mViewManager->currentView()->isMonthView() )
2034 mNavigator->selectTodayMonth(); 2034 mNavigator->selectTodayMonth();
2035 else 2035 else
2036 mNavigator->selectToday(); 2036 mNavigator->selectToday();
2037} 2037}
2038 2038
2039void CalendarView::goNext() 2039void CalendarView::goNext()
2040{ 2040{
2041 mNavigator->selectNext(); 2041 mNavigator->selectNext();
2042} 2042}
2043 2043
2044void CalendarView::goPrevious() 2044void CalendarView::goPrevious()
2045{ 2045{
2046 mNavigator->selectPrevious(); 2046 mNavigator->selectPrevious();
2047} 2047}
2048void CalendarView::goNextMonth() 2048void CalendarView::goNextMonth()
2049{ 2049{
2050 mNavigator->selectNextMonth(); 2050 mNavigator->selectNextMonth();
2051} 2051}
2052 2052
2053void CalendarView::goPreviousMonth() 2053void CalendarView::goPreviousMonth()
2054{ 2054{
2055 mNavigator->selectPreviousMonth(); 2055 mNavigator->selectPreviousMonth();
2056} 2056}
2057void CalendarView::writeLocale() 2057void CalendarView::writeLocale()
2058{ 2058{
2059 //KPimGlobalPrefs::instance()->setGlobalConfig(); 2059 //KPimGlobalPrefs::instance()->setGlobalConfig();
2060#if 0 2060#if 0
2061 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); 2061 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime );
2062 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); 2062 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday );
2063 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); 2063 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate );
2064 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); 2064 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage );
2065 QString dummy = KOPrefs::instance()->mUserDateFormatLong; 2065 QString dummy = KOPrefs::instance()->mUserDateFormatLong;
2066 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 2066 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
2067 dummy = KOPrefs::instance()->mUserDateFormatShort; 2067 dummy = KOPrefs::instance()->mUserDateFormatShort;
2068 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 2068 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
2069 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, 2069 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving,
2070 KOPrefs::instance()->mDaylightsavingStart, 2070 KOPrefs::instance()->mDaylightsavingStart,
2071 KOPrefs::instance()->mDaylightsavingEnd ); 2071 KOPrefs::instance()->mDaylightsavingEnd );
2072 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); 2072 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId );
2073#endif 2073#endif
2074} 2074}
2075void CalendarView::updateConfig() 2075void CalendarView::updateConfig()
2076{ 2076{
2077 writeLocale(); 2077 writeLocale();
2078 if ( KOPrefs::instance()->mUseAppColors ) 2078 if ( KOPrefs::instance()->mUseAppColors )
2079 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 2079 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
2080 emit configChanged(); 2080 emit configChanged();
2081 mTodoList->updateConfig(); 2081 mTodoList->updateConfig();
2082 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 2082 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
2083 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2083 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2084 // To make the "fill window" configurations work 2084 // To make the "fill window" configurations work
2085 //mViewManager->raiseCurrentView(); 2085 //mViewManager->raiseCurrentView();
2086} 2086}
2087 2087
2088 2088
2089void CalendarView::eventChanged(Event *event) 2089void CalendarView::eventChanged(Event *event)
2090{ 2090{
2091 changeEventDisplay(event,KOGlobals::EVENTEDITED); 2091 changeEventDisplay(event,KOGlobals::EVENTEDITED);
2092 //updateUnmanagedViews(); 2092 //updateUnmanagedViews();
2093} 2093}
2094 2094
2095void CalendarView::eventAdded(Event *event) 2095void CalendarView::eventAdded(Event *event)
2096{ 2096{
2097 changeEventDisplay(event,KOGlobals::EVENTADDED); 2097 changeEventDisplay(event,KOGlobals::EVENTADDED);
2098} 2098}
2099 2099
2100void CalendarView::eventToBeDeleted(Event *) 2100void CalendarView::eventToBeDeleted(Event *)
2101{ 2101{
2102 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 2102 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
2103} 2103}
2104 2104
2105void CalendarView::eventDeleted() 2105void CalendarView::eventDeleted()
2106{ 2106{
2107 changeEventDisplay(0,KOGlobals::EVENTDELETED); 2107 changeEventDisplay(0,KOGlobals::EVENTDELETED);
2108} 2108}
2109void CalendarView::changeTodoDisplay(Todo *which, int action) 2109void CalendarView::changeTodoDisplay(Todo *which, int action)
2110{ 2110{
2111 changeIncidenceDisplay((Incidence *)which, action); 2111 changeIncidenceDisplay((Incidence *)which, action);
2112 mDateNavigator->updateView(); //LR 2112 mDateNavigator->updateView(); //LR
2113 //mDialogManager->updateSearchDialog(); 2113 //mDialogManager->updateSearchDialog();
2114 2114
2115 if (which) { 2115 if (which) {
2116 mViewManager->updateWNview(); 2116 mViewManager->updateWNview();
2117 //mTodoList->updateView(); 2117 //mTodoList->updateView();
2118 } 2118 }
2119 2119
2120} 2120}
2121 2121
2122void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 2122void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
2123{ 2123{
2124 updateUnmanagedViews(); 2124 updateUnmanagedViews();
2125 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 2125 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
2126 if ( action == KOGlobals::EVENTDELETED ) { //delete 2126 if ( action == KOGlobals::EVENTDELETED ) { //delete
2127 mCalendar->checkAlarmForIncidence( 0, true ); 2127 mCalendar->checkAlarmForIncidence( 0, true );
2128 if ( mEventViewerDialog ) 2128 if ( mEventViewerDialog )
2129 mEventViewerDialog->hide(); 2129 mEventViewerDialog->hide();
2130 } 2130 }
2131 else 2131 else
2132 mCalendar->checkAlarmForIncidence( which , false ); 2132 mCalendar->checkAlarmForIncidence( which , false );
2133} 2133}
2134 2134
2135// most of the changeEventDisplays() right now just call the view's 2135// most of the changeEventDisplays() right now just call the view's
2136// total update mode, but they SHOULD be recoded to be more refresh-efficient. 2136// total update mode, but they SHOULD be recoded to be more refresh-efficient.
2137void CalendarView::changeEventDisplay(Event *which, int action) 2137void CalendarView::changeEventDisplay(Event *which, int action)
2138{ 2138{
2139 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 2139 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
2140 changeIncidenceDisplay((Incidence *)which, action); 2140 changeIncidenceDisplay((Incidence *)which, action);
2141 mDateNavigator->updateView(); 2141 mDateNavigator->updateView();
2142 //mDialogManager->updateSearchDialog(); 2142 //mDialogManager->updateSearchDialog();
2143 2143
2144 if (which) { 2144 if (which) {
2145 // If there is an event view visible update the display 2145 // If there is an event view visible update the display
2146 mViewManager->currentView()->changeEventDisplay(which,action); 2146 mViewManager->currentView()->changeEventDisplay(which,action);
2147 // TODO: check, if update needed 2147 // TODO: check, if update needed
2148 // if (which->getTodoStatus()) { 2148 // if (which->getTodoStatus()) {
2149 mTodoList->updateView(); 2149 mTodoList->updateView();
2150 // } 2150 // }
2151 } else { 2151 } else {
2152 mViewManager->currentView()->updateView(); 2152 mViewManager->currentView()->updateView();
2153 } 2153 }
2154} 2154}
2155 2155
2156 2156
2157void CalendarView::updateTodoViews() 2157void CalendarView::updateTodoViews()
2158{ 2158{
2159 2159
2160 mTodoList->updateView(); 2160 mTodoList->updateView();
2161 mViewManager->currentView()->updateView(); 2161 mViewManager->currentView()->updateView();
2162 2162
2163} 2163}
2164 2164
2165 2165
2166void CalendarView::updateView(const QDate &start, const QDate &end) 2166void CalendarView::updateView(const QDate &start, const QDate &end)
2167{ 2167{
2168 mTodoList->updateView(); 2168 mTodoList->updateView();
2169 mViewManager->updateView(start, end); 2169 mViewManager->updateView(start, end);
2170 //mDateNavigator->updateView(); 2170 //mDateNavigator->updateView();
2171} 2171}
2172 2172
2173void CalendarView::updateView() 2173void CalendarView::updateView()
2174{ 2174{
2175 DateList tmpList = mNavigator->selectedDates(); 2175 DateList tmpList = mNavigator->selectedDates();
2176 2176
2177 if ( KOPrefs::instance()->mHideNonStartedTodos ) 2177 if ( KOPrefs::instance()->mHideNonStartedTodos )
2178 mTodoList->updateView(); 2178 mTodoList->updateView();
2179 // We assume that the navigator only selects consecutive days. 2179 // We assume that the navigator only selects consecutive days.
2180 updateView( tmpList.first(), tmpList.last() ); 2180 updateView( tmpList.first(), tmpList.last() );
2181} 2181}
2182 2182
2183void CalendarView::updateUnmanagedViews() 2183void CalendarView::updateUnmanagedViews()
2184{ 2184{
2185 mDateNavigator->updateDayMatrix(); 2185 mDateNavigator->updateDayMatrix();
2186} 2186}
2187 2187
2188int CalendarView::msgItemDelete() 2188int CalendarView::msgItemDelete()
2189{ 2189{
2190 return KMessageBox::warningContinueCancel(this, 2190 return KMessageBox::warningContinueCancel(this,
2191 i18n("This item will be\npermanently deleted."), 2191 i18n("This item will be\npermanently deleted."),
2192 i18n("KO/Pi Confirmation"),i18n("Delete")); 2192 i18n("KO/Pi Confirmation"),i18n("Delete"));
2193} 2193}
2194 2194
2195 2195
2196void CalendarView::edit_cut() 2196void CalendarView::edit_cut()
2197{ 2197{
2198 Event *anEvent=0; 2198 Event *anEvent=0;
2199 2199
2200 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2200 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2201 2201
2202 if (mViewManager->currentView()->isEventView()) { 2202 if (mViewManager->currentView()->isEventView()) {
2203 if ( incidence && incidence->type() == "Event" ) { 2203 if ( incidence && incidence->type() == "Event" ) {
2204 anEvent = static_cast<Event *>(incidence); 2204 anEvent = static_cast<Event *>(incidence);
2205 } 2205 }
2206 } 2206 }
2207 2207
2208 if (!anEvent) { 2208 if (!anEvent) {
2209 KNotifyClient::beep(); 2209 KNotifyClient::beep();
2210 return; 2210 return;
2211 } 2211 }
2212 DndFactory factory( mCalendar ); 2212 DndFactory factory( mCalendar );
2213 factory.cutEvent(anEvent); 2213 factory.cutEvent(anEvent);
2214 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2214 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2215} 2215}
2216 2216
2217void CalendarView::edit_copy() 2217void CalendarView::edit_copy()
2218{ 2218{
2219 Event *anEvent=0; 2219 Event *anEvent=0;
2220 2220
2221 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2221 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2222 2222
2223 if (mViewManager->currentView()->isEventView()) { 2223 if (mViewManager->currentView()->isEventView()) {
2224 if ( incidence && incidence->type() == "Event" ) { 2224 if ( incidence && incidence->type() == "Event" ) {
2225 anEvent = static_cast<Event *>(incidence); 2225 anEvent = static_cast<Event *>(incidence);
2226 } 2226 }
2227 } 2227 }
2228 2228
2229 if (!anEvent) { 2229 if (!anEvent) {
2230 KNotifyClient::beep(); 2230 KNotifyClient::beep();
2231 return; 2231 return;
2232 } 2232 }
2233 DndFactory factory( mCalendar ); 2233 DndFactory factory( mCalendar );
2234 factory.copyEvent(anEvent); 2234 factory.copyEvent(anEvent);
2235} 2235}
2236 2236
2237void CalendarView::edit_paste() 2237void CalendarView::edit_paste()
2238{ 2238{
2239 QDate date = mNavigator->selectedDates().first(); 2239 QDate date = mNavigator->selectedDates().first();
2240 2240
2241 DndFactory factory( mCalendar ); 2241 DndFactory factory( mCalendar );
2242 Event *pastedEvent = factory.pasteEvent( date ); 2242 Event *pastedEvent = factory.pasteEvent( date );
2243 2243
2244 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 2244 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
2245} 2245}
2246 2246
2247void CalendarView::edit_options() 2247void CalendarView::edit_options()
2248{ 2248{
2249 mDialogManager->showOptionsDialog(); 2249 mDialogManager->showOptionsDialog();
2250 //writeSettings(); 2250 //writeSettings();
2251} 2251}
2252 2252
2253 2253
2254void CalendarView::slotSelectPickerDate( QDate d) 2254void CalendarView::slotSelectPickerDate( QDate d)
2255{ 2255{
2256 mDateFrame->hide(); 2256 mDateFrame->hide();
2257 if ( mDatePickerMode == 1 ) { 2257 if ( mDatePickerMode == 1 ) {
2258 mNavigator->slotDaySelect( d ); 2258 mNavigator->slotDaySelect( d );
2259 } else if ( mDatePickerMode == 2 ) { 2259 } else if ( mDatePickerMode == 2 ) {
2260 if ( mMoveIncidence->type() == "Todo" ) { 2260 if ( mMoveIncidence->type() == "Todo" ) {
2261 Todo * to = (Todo *) mMoveIncidence; 2261 Todo * to = (Todo *) mMoveIncidence;
2262 QTime tim; 2262 QTime tim;
2263 if ( to->hasDueDate() ) 2263 if ( to->hasDueDate() )
2264 tim = to->dtDue().time(); 2264 tim = to->dtDue().time();
2265 else { 2265 else {
2266 tim = QTime ( 0,0,0 ); 2266 tim = QTime ( 0,0,0 );
2267 to->setFloats( true ); 2267 to->setFloats( true );
2268 to->setHasDueDate( true ); 2268 to->setHasDueDate( true );
2269 } 2269 }
2270 QDateTime dt ( d,tim ); 2270 QDateTime dt ( d,tim );
2271 to->setDtDue( dt ); 2271 to->setDtDue( dt );
2272 todoChanged( to ); 2272 todoChanged( to );
2273 } else { 2273 } else {
2274 if ( mMoveIncidence->doesRecur() ) { 2274 if ( mMoveIncidence->doesRecur() ) {
2275#if 0 2275#if 0
2276 // PENDING implement this 2276 // PENDING implement this
2277 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); 2277 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate );
2278 mCalendar()->addIncidence( newInc ); 2278 mCalendar()->addIncidence( newInc );
2279 if ( mMoveIncidence->type() == "Todo" ) 2279 if ( mMoveIncidence->type() == "Todo" )
2280 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); 2280 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED );
2281 else 2281 else
2282 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); 2282 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED);
2283 mMoveIncidence = newInc; 2283 mMoveIncidence = newInc;
2284 2284
2285#endif 2285#endif
2286 } 2286 }
2287 QTime tim = mMoveIncidence->dtStart().time(); 2287 QTime tim = mMoveIncidence->dtStart().time();
2288 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2288 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2289 QDateTime dt ( d,tim ); 2289 QDateTime dt ( d,tim );
2290 mMoveIncidence->setDtStart( dt ); 2290 mMoveIncidence->setDtStart( dt );
2291 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2291 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2292 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2292 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2293 } 2293 }
2294 2294
2295 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2295 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2296 } 2296 }
2297} 2297}
2298 2298
2299void CalendarView::removeCategories() 2299void CalendarView::removeCategories()
2300{ 2300{
2301 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2301 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2302 QStringList catList = KOPrefs::instance()->mCustomCategories; 2302 QStringList catList = KOPrefs::instance()->mCustomCategories;
2303 QStringList catIncList; 2303 QStringList catIncList;
2304 QStringList newCatList; 2304 QStringList newCatList;
2305 Incidence* inc = incList.first(); 2305 Incidence* inc = incList.first();
2306 int i; 2306 int i;
2307 int count = 0; 2307 int count = 0;
2308 while ( inc ) { 2308 while ( inc ) {
2309 newCatList.clear(); 2309 newCatList.clear();
2310 catIncList = inc->categories() ; 2310 catIncList = inc->categories() ;
2311 for( i = 0; i< catIncList.count(); ++i ) { 2311 for( i = 0; i< catIncList.count(); ++i ) {
2312 if ( catList.contains (catIncList[i])) 2312 if ( catList.contains (catIncList[i]))
2313 newCatList.append( catIncList[i] ); 2313 newCatList.append( catIncList[i] );
2314 } 2314 }
2315 newCatList.sort(); 2315 newCatList.sort();
2316 inc->setCategories( newCatList.join(",") ); 2316 inc->setCategories( newCatList.join(",") );
2317 inc = incList.next(); 2317 inc = incList.next();
2318 } 2318 }
2319} 2319}
2320 2320
2321int CalendarView::addCategories() 2321int CalendarView::addCategories()
2322{ 2322{
2323 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2323 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2324 QStringList catList = KOPrefs::instance()->mCustomCategories; 2324 QStringList catList = KOPrefs::instance()->mCustomCategories;
2325 QStringList catIncList; 2325 QStringList catIncList;
2326 Incidence* inc = incList.first(); 2326 Incidence* inc = incList.first();
2327 int i; 2327 int i;
2328 int count = 0; 2328 int count = 0;
2329 while ( inc ) { 2329 while ( inc ) {
2330 catIncList = inc->categories() ; 2330 catIncList = inc->categories() ;
2331 for( i = 0; i< catIncList.count(); ++i ) { 2331 for( i = 0; i< catIncList.count(); ++i ) {
2332 if ( !catList.contains (catIncList[i])) { 2332 if ( !catList.contains (catIncList[i])) {
2333 catList.append( catIncList[i] ); 2333 catList.append( catIncList[i] );
2334 //qDebug("add cat %s ", catIncList[i].latin1()); 2334 //qDebug("add cat %s ", catIncList[i].latin1());
2335 ++count; 2335 ++count;
2336 } 2336 }
2337 } 2337 }
2338 inc = incList.next(); 2338 inc = incList.next();
2339 } 2339 }
2340 catList.sort(); 2340 catList.sort();
2341 KOPrefs::instance()->mCustomCategories = catList; 2341 KOPrefs::instance()->mCustomCategories = catList;
2342 return count; 2342 return count;
2343} 2343}
2344 2344
2345void CalendarView::manageCategories() 2345void CalendarView::manageCategories()
2346{ 2346{
2347 KOCatPrefs* cp = new KOCatPrefs(); 2347 KOCatPrefs* cp = new KOCatPrefs();
2348 cp->show(); 2348 cp->show();
2349 int w =cp->sizeHint().width() ; 2349 int w =cp->sizeHint().width() ;
2350 int h = cp->sizeHint().height() ; 2350 int h = cp->sizeHint().height() ;
2351 int dw = QApplication::desktop()->width(); 2351 int dw = QApplication::desktop()->width();
2352 int dh = QApplication::desktop()->height(); 2352 int dh = QApplication::desktop()->height();
2353 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2353 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2354 if ( !cp->exec() ) { 2354 if ( !cp->exec() ) {
2355 delete cp; 2355 delete cp;
2356 return; 2356 return;
2357 } 2357 }
2358 int count = 0; 2358 int count = 0;
2359 if ( cp->addCat() ) { 2359 if ( cp->addCat() ) {
2360 count = addCategories(); 2360 count = addCategories();
2361 if ( count ) { 2361 if ( count ) {
2362 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2362 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2363 writeSettings(); 2363 writeSettings();
2364 } else 2364 } else
2365 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); 2365 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! "));
2366 } else { 2366 } else {
2367 removeCategories(); 2367 removeCategories();
2368 updateView(); 2368 updateView();
2369 } 2369 }
2370 delete cp; 2370 delete cp;
2371} 2371}
2372 2372
2373void CalendarView::beamIncidence(Incidence * Inc) 2373void CalendarView::beamIncidence(Incidence * Inc)
2374{ 2374{
2375 QPtrList<Incidence> delSel ; 2375 QPtrList<Incidence> delSel ;
2376 delSel.append(Inc); 2376 delSel.append(Inc);
2377 beamIncidenceList( delSel ); 2377 beamIncidenceList( delSel );
2378} 2378}
2379void CalendarView::beamCalendar() 2379void CalendarView::beamCalendar()
2380{ 2380{
2381 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2381 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2382 //qDebug("beamCalendar() "); 2382 //qDebug("beamCalendar() ");
2383 beamIncidenceList( delSel ); 2383 beamIncidenceList( delSel );
2384} 2384}
2385void CalendarView::beamFilteredCalendar() 2385void CalendarView::beamFilteredCalendar()
2386{ 2386{
2387 QPtrList<Incidence> delSel = mCalendar->incidences(); 2387 QPtrList<Incidence> delSel = mCalendar->incidences();
2388 //qDebug("beamFilteredCalendar() "); 2388 //qDebug("beamFilteredCalendar() ");
2389 beamIncidenceList( delSel ); 2389 beamIncidenceList( delSel );
2390} 2390}
2391void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2391void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2392{ 2392{
2393 if ( beamDialog->exec () == QDialog::Rejected ) 2393 if ( beamDialog->exec () == QDialog::Rejected )
2394 return; 2394 return;
2395#ifdef DESKTOP_VERSION 2395#ifdef DESKTOP_VERSION
2396 QString fn = locateLocal( "tmp", "kopibeamfile" ); 2396 QString fn = locateLocal( "tmp", "kopibeamfile" );
2397#else 2397#else
2398 QString fn = "/tmp/kopibeamfile"; 2398 QString fn = "/tmp/kopibeamfile";
2399#endif 2399#endif
2400 QString mes; 2400 QString mes;
2401 bool createbup = true; 2401 bool createbup = true;
2402 if ( createbup ) { 2402 if ( createbup ) {
2403 QString description = "\n"; 2403 QString description = "\n";
2404 CalendarLocal* cal = new CalendarLocal(); 2404 CalendarLocal* cal = new CalendarLocal();
2405 if ( beamDialog->beamLocal() ) 2405 if ( beamDialog->beamLocal() )
2406 cal->setLocalTime(); 2406 cal->setLocalTime();
2407 else 2407 else
2408 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2408 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2409 Incidence *incidence = delSel.first(); 2409 Incidence *incidence = delSel.first();
2410 bool addText = false; 2410 bool addText = false;
2411 if ( delSel.count() < 10 ) 2411 if ( delSel.count() < 10 )
2412 addText = true; 2412 addText = true;
2413 else { 2413 else {
2414 description.sprintf(i18n(" %d items?"),delSel.count() ); 2414 description.sprintf(i18n(" %d items?"),delSel.count() );
2415 } 2415 }
2416 while ( incidence ) { 2416 while ( incidence ) {
2417 Incidence *in = incidence->clone(); 2417 Incidence *in = incidence->clone();
2418 if ( ! in->summary().isEmpty() ) { 2418 if ( ! in->summary().isEmpty() ) {
2419 in->setDescription(""); 2419 in->setDescription("");
2420 } else { 2420 } else {
2421 in->setSummary( in->description().left(20)); 2421 in->setSummary( in->description().left(20));
2422 in->setDescription(""); 2422 in->setDescription("");
2423 } 2423 }
2424 if ( addText ) 2424 if ( addText )
2425 description += in->summary() + "\n"; 2425 description += in->summary() + "\n";
2426 cal->addIncidence( in ); 2426 cal->addIncidence( in );
2427 incidence = delSel.next(); 2427 incidence = delSel.next();
2428 } 2428 }
2429 if ( beamDialog->beamVcal() ) { 2429 if ( beamDialog->beamVcal() ) {
2430 fn += ".vcs"; 2430 fn += ".vcs";
2431 FileStorage storage( cal, fn, new VCalFormat ); 2431 FileStorage storage( cal, fn, new VCalFormat );
2432 storage.save(); 2432 storage.save();
2433 } else { 2433 } else {
2434 fn += ".ics"; 2434 fn += ".ics";
2435 FileStorage storage( cal, fn, new ICalFormat( ) ); 2435 FileStorage storage( cal, fn, new ICalFormat( ) );
2436 storage.save(); 2436 storage.save();
2437 } 2437 }
2438 delete cal; 2438 delete cal;
2439 mes = i18n("KO/Pi: Ready for beaming"); 2439 mes = i18n("KO/Pi: Ready for beaming");
2440 topLevelWidget()->setCaption(mes); 2440 topLevelWidget()->setCaption(mes);
2441 KApplication::convert2latin1( fn ); 2441 KApplication::convert2latin1( fn );
2442#ifndef DESKTOP_VERSION 2442#ifndef DESKTOP_VERSION
2443 Ir *ir = new Ir( this ); 2443 Ir *ir = new Ir( this );
2444 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 2444 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2445 ir->send( fn, description, "text/x-vCalendar" ); 2445 ir->send( fn, description, "text/x-vCalendar" );
2446#endif 2446#endif
2447 } 2447 }
2448} 2448}
2449void CalendarView::beamDone( Ir *ir ) 2449void CalendarView::beamDone( Ir *ir )
2450{ 2450{
2451#ifndef DESKTOP_VERSION 2451#ifndef DESKTOP_VERSION
2452 delete ir; 2452 delete ir;
2453#endif 2453#endif
2454 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); 2454 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") );
2455 topLevelWidget()->raise(); 2455 topLevelWidget()->raise();
2456} 2456}
2457 2457
2458void CalendarView::moveIncidence(Incidence * inc ) 2458void CalendarView::moveIncidence(Incidence * inc )
2459{ 2459{
2460 if ( !inc ) return; 2460 if ( !inc ) return;
2461 // qDebug("showDatePickerForIncidence( ) "); 2461 // qDebug("showDatePickerForIncidence( ) ");
2462 if ( mDateFrame->isVisible() ) 2462 if ( mDateFrame->isVisible() )
2463 mDateFrame->hide(); 2463 mDateFrame->hide();
2464 else { 2464 else {
2465 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; 2465 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ;
2466 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; 2466 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ;
2467 int dw = QApplication::desktop()->width(); 2467 int dw = QApplication::desktop()->width();
2468 int dh = QApplication::desktop()->height(); 2468 int dh = QApplication::desktop()->height();
2469 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2469 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2470 mDateFrame->show(); 2470 mDateFrame->show();
2471 } 2471 }
2472 mDatePickerMode = 2; 2472 mDatePickerMode = 2;
2473 mMoveIncidence = inc ; 2473 mMoveIncidence = inc ;
2474 QDate da; 2474 QDate da;
2475 if ( mMoveIncidence->type() == "Todo" ) { 2475 if ( mMoveIncidence->type() == "Todo" ) {
2476 Todo * to = (Todo *) mMoveIncidence; 2476 Todo * to = (Todo *) mMoveIncidence;
2477 if ( to->hasDueDate() ) 2477 if ( to->hasDueDate() )
2478 da = to->dtDue().date(); 2478 da = to->dtDue().date();
2479 else 2479 else
2480 da = QDate::currentDate(); 2480 da = QDate::currentDate();
2481 } else { 2481 } else {
2482 da = mMoveIncidence->dtStart().date(); 2482 da = mMoveIncidence->dtStart().date();
2483 } 2483 }
2484 //PENDING set date for recurring incidence to date of recurrence 2484 //PENDING set date for recurring incidence to date of recurrence
2485 //mMoveIncidenceOldDate; 2485 //mMoveIncidenceOldDate;
2486 mDatePicker->setDate( da ); 2486 mDatePicker->setDate( da );
2487} 2487}
2488void CalendarView::showDatePicker( ) 2488void CalendarView::showDatePicker( )
2489{ 2489{
2490 //qDebug("CalendarView::showDatePicker( ) "); 2490 //qDebug("CalendarView::showDatePicker( ) ");
2491 if ( mDateFrame->isVisible() ) 2491 if ( mDateFrame->isVisible() )
2492 mDateFrame->hide(); 2492 mDateFrame->hide();
2493 else { 2493 else {
2494 int w =mDatePicker->sizeHint().width() ; 2494 int w =mDatePicker->sizeHint().width() ;
2495 int h = mDatePicker->sizeHint().height() ; 2495 int h = mDatePicker->sizeHint().height() ;
2496 int dw = QApplication::desktop()->width(); 2496 int dw = QApplication::desktop()->width();
2497 int dh = QApplication::desktop()->height(); 2497 int dh = QApplication::desktop()->height();
2498 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2498 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2499 mDateFrame->show(); 2499 mDateFrame->show();
2500 } 2500 }
2501 mDatePickerMode = 1; 2501 mDatePickerMode = 1;
2502 mDatePicker->setDate( mNavigator->selectedDates().first() ); 2502 mDatePicker->setDate( mNavigator->selectedDates().first() );
2503} 2503}
2504 2504
2505void CalendarView::showEventEditor() 2505void CalendarView::showEventEditor()
2506{ 2506{
2507#ifdef DESKTOP_VERSION 2507#ifdef DESKTOP_VERSION
2508 mEventEditor->show(); 2508 mEventEditor->show();
2509#else 2509#else
2510 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { 2510 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) {
2511 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2511 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2512 qDebug("CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); 2512 qDebug("CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() );
2513 delete mEventEditor; 2513 delete mEventEditor;
2514 mEventEditor = mDialogManager->getEventEditor(); 2514 mEventEditor = mDialogManager->getEventEditor();
2515 } 2515 }
2516 mEventEditor->showMaximized(); 2516 mEventEditor->showMaximized();
2517 topLevelWidget()->setCaption( i18n("") ); 2517 topLevelWidget()->setCaption( i18n("") );
2518#endif 2518#endif
2519} 2519}
2520void CalendarView::showTodoEditor() 2520void CalendarView::showTodoEditor()
2521{ 2521{
2522#ifdef DESKTOP_VERSION 2522#ifdef DESKTOP_VERSION
2523 mTodoEditor->show(); 2523 mTodoEditor->show();
2524#else 2524#else
2525 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { 2525 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) {
2526 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2526 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2527 qDebug("CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); 2527 qDebug("CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() );
2528 delete mTodoEditor; 2528 delete mTodoEditor;
2529 mTodoEditor = mDialogManager->getTodoEditor(); 2529 mTodoEditor = mDialogManager->getTodoEditor();
2530 } 2530 }
2531 mTodoEditor->showMaximized(); 2531 mTodoEditor->showMaximized();
2532 topLevelWidget()->setCaption( i18n("") ); 2532 topLevelWidget()->setCaption( i18n("") );
2533#endif 2533#endif
2534} 2534}
2535 2535
2536void CalendarView::cloneIncidence() 2536void CalendarView::cloneIncidence()
2537{ 2537{
2538 Incidence *incidence = currentSelection(); 2538 Incidence *incidence = currentSelection();
2539 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2539 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2540 if ( incidence ) { 2540 if ( incidence ) {
2541 cloneIncidence(incidence); 2541 cloneIncidence(incidence);
2542 } 2542 }
2543} 2543}
2544void CalendarView::moveIncidence() 2544void CalendarView::moveIncidence()
2545{ 2545{
2546 Incidence *incidence = currentSelection(); 2546 Incidence *incidence = currentSelection();
2547 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2547 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2548 if ( incidence ) { 2548 if ( incidence ) {
2549 moveIncidence(incidence); 2549 moveIncidence(incidence);
2550 } 2550 }
2551} 2551}
2552void CalendarView::beamIncidence() 2552void CalendarView::beamIncidence()
2553{ 2553{
2554 Incidence *incidence = currentSelection(); 2554 Incidence *incidence = currentSelection();
2555 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2555 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2556 if ( incidence ) { 2556 if ( incidence ) {
2557 beamIncidence(incidence); 2557 beamIncidence(incidence);
2558 } 2558 }
2559} 2559}
2560void CalendarView::toggleCancelIncidence() 2560void CalendarView::toggleCancelIncidence()
2561{ 2561{
2562 Incidence *incidence = currentSelection(); 2562 Incidence *incidence = currentSelection();
2563 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2563 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2564 if ( incidence ) { 2564 if ( incidence ) {
2565 cancelIncidence(incidence); 2565 cancelIncidence(incidence);
2566 } 2566 }
2567} 2567}
2568 2568
2569 2569
2570void CalendarView::cancelIncidence(Incidence * inc ) 2570void CalendarView::cancelIncidence(Incidence * inc )
2571{ 2571{
2572 inc->setCancelled( ! inc->cancelled() ); 2572 inc->setCancelled( ! inc->cancelled() );
2573 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 2573 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
2574 updateView(); 2574 updateView();
2575} 2575}
2576void CalendarView::cloneIncidence(Incidence * orgInc ) 2576void CalendarView::cloneIncidence(Incidence * orgInc )
2577{ 2577{
2578 Incidence * newInc = orgInc->clone(); 2578 Incidence * newInc = orgInc->clone();
2579 newInc->recreate(); 2579 newInc->recreate();
2580 2580
2581 if ( newInc->type() == "Todo" ) { 2581 if ( newInc->type() == "Todo" ) {
2582 Todo* t = (Todo*) newInc; 2582 Todo* t = (Todo*) newInc;
2583 showTodoEditor(); 2583 showTodoEditor();
2584 mTodoEditor->editTodo( t ); 2584 mTodoEditor->editTodo( t );
2585 if ( mTodoEditor->exec() ) { 2585 if ( mTodoEditor->exec() ) {
2586 mCalendar->addTodo( t ); 2586 mCalendar->addTodo( t );
2587 updateView(); 2587 updateView();
2588 } else { 2588 } else {
2589 delete t; 2589 delete t;
2590 } 2590 }
2591 } 2591 }
2592 else { 2592 else {
2593 Event* e = (Event*) newInc; 2593 Event* e = (Event*) newInc;
2594 showEventEditor(); 2594 showEventEditor();
2595 mEventEditor->editEvent( e ); 2595 mEventEditor->editEvent( e );
2596 if ( mEventEditor->exec() ) { 2596 if ( mEventEditor->exec() ) {
2597 mCalendar->addEvent( e ); 2597 mCalendar->addEvent( e );
2598 updateView(); 2598 updateView();
2599 } else { 2599 } else {
2600 delete e; 2600 delete e;
2601 } 2601 }
2602 } 2602 }
2603} 2603}
2604 2604
2605void CalendarView::newEvent() 2605void CalendarView::newEvent()
2606{ 2606{
2607 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 2607 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
2608 KOAgendaView *aView = mViewManager->agendaView(); 2608 KOAgendaView *aView = mViewManager->agendaView();
2609 if (aView) { 2609 if (aView) {
2610 if (aView->selectionStart().isValid()) { 2610 if (aView->selectionStart().isValid()) {
2611 if (aView->selectedIsAllDay()) { 2611 if (aView->selectedIsAllDay()) {
2612 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 2612 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
2613 } else { 2613 } else {
2614 newEvent(aView->selectionStart(),aView->selectionEnd()); 2614 newEvent(aView->selectionStart(),aView->selectionEnd());
2615 } 2615 }
2616 return; 2616 return;
2617 } 2617 }
2618 } 2618 }
2619 2619
2620 QDate date = mNavigator->selectedDates().first(); 2620 QDate date = mNavigator->selectedDates().first();
2621 QDateTime current = QDateTime::currentDateTime(); 2621 QDateTime current = QDateTime::currentDateTime();
2622 if ( date <= current.date() ) { 2622 if ( date <= current.date() ) {
2623 int hour = current.time().hour() +1; 2623 int hour = current.time().hour() +1;
2624 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 2624 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
2625 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2625 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2626 } else 2626 } else
2627 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 2627 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
2628 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 2628 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
2629 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2629 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2630} 2630}
2631 2631
2632void CalendarView::newEvent(QDateTime fh) 2632void CalendarView::newEvent(QDateTime fh)
2633{ 2633{
2634 newEvent(fh, 2634 newEvent(fh,
2635 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 2635 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
2636} 2636}
2637 2637
2638void CalendarView::newEvent(QDate dt) 2638void CalendarView::newEvent(QDate dt)
2639{ 2639{
2640 newEvent(QDateTime(dt, QTime(0,0,0)), 2640 newEvent(QDateTime(dt, QTime(0,0,0)),
2641 QDateTime(dt, QTime(0,0,0)), true); 2641 QDateTime(dt, QTime(0,0,0)), true);
2642} 2642}
2643 2643
2644void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 2644void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
2645{ 2645{
2646 2646
2647 showEventEditor(); 2647 showEventEditor();
2648 mEventEditor->newEvent(fromHint,toHint,allDay); 2648 mEventEditor->newEvent(fromHint,toHint,allDay);
2649 if ( mFilterView->filtersEnabled() ) { 2649 if ( mFilterView->filtersEnabled() ) {
2650 CalFilter *filter = mFilterView->selectedFilter(); 2650 CalFilter *filter = mFilterView->selectedFilter();
2651 if (filter && filter->showCategories()) { 2651 if (filter && filter->showCategories()) {
2652 mEventEditor->setCategories(filter->categoryList().join(",") ); 2652 mEventEditor->setCategories(filter->categoryList().join(",") );
2653 } 2653 }
2654 if ( filter ) 2654 if ( filter )
2655 mEventEditor->setSecrecy( filter->getSecrecy() ); 2655 mEventEditor->setSecrecy( filter->getSecrecy() );
2656 } 2656 }
2657} 2657}
2658void CalendarView::todoAdded(Todo * t) 2658void CalendarView::todoAdded(Todo * t)
2659{ 2659{
2660 2660
2661 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 2661 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
2662 updateTodoViews(); 2662 updateTodoViews();
2663} 2663}
2664void CalendarView::todoChanged(Todo * t) 2664void CalendarView::todoChanged(Todo * t)
2665{ 2665{
2666 emit todoModified( t, 4 ); 2666 emit todoModified( t, 4 );
2667 // updateTodoViews(); 2667 // updateTodoViews();
2668} 2668}
2669void CalendarView::todoToBeDeleted(Todo *) 2669void CalendarView::todoToBeDeleted(Todo *)
2670{ 2670{
2671 //qDebug("todoToBeDeleted(Todo *) "); 2671 //qDebug("todoToBeDeleted(Todo *) ");
2672 updateTodoViews(); 2672 updateTodoViews();
2673} 2673}
2674void CalendarView::todoDeleted() 2674void CalendarView::todoDeleted()
2675{ 2675{
2676 //qDebug(" todoDeleted()"); 2676 //qDebug(" todoDeleted()");
2677 updateTodoViews(); 2677 updateTodoViews();
2678} 2678}
2679 2679
2680 2680
2681 2681
2682void CalendarView::newTodo() 2682void CalendarView::newTodo()
2683{ 2683{
2684 2684
2685 showTodoEditor(); 2685 showTodoEditor();
2686 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); 2686 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true);
2687 if ( mFilterView->filtersEnabled() ) { 2687 if ( mFilterView->filtersEnabled() ) {
2688 CalFilter *filter = mFilterView->selectedFilter(); 2688 CalFilter *filter = mFilterView->selectedFilter();
2689 if (filter && filter->showCategories()) { 2689 if (filter && filter->showCategories()) {
2690 mTodoEditor->setCategories(filter->categoryList().join(",") ); 2690 mTodoEditor->setCategories(filter->categoryList().join(",") );
2691 } 2691 }
2692 if ( filter ) 2692 if ( filter )
2693 mTodoEditor->setSecrecy( filter->getSecrecy() ); 2693 mTodoEditor->setSecrecy( filter->getSecrecy() );
2694 } 2694 }
2695} 2695}
2696 2696
2697void CalendarView::newSubTodo() 2697void CalendarView::newSubTodo()
2698{ 2698{
2699 Todo *todo = selectedTodo(); 2699 Todo *todo = selectedTodo();
2700 if ( todo ) newSubTodo( todo ); 2700 if ( todo ) newSubTodo( todo );
2701} 2701}
2702 2702
2703void CalendarView::newSubTodo(Todo *parentEvent) 2703void CalendarView::newSubTodo(Todo *parentEvent)
2704{ 2704{
2705 2705
2706 showTodoEditor(); 2706 showTodoEditor();
2707 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); 2707 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true);
2708} 2708}
2709 2709
2710void CalendarView::newFloatingEvent() 2710void CalendarView::newFloatingEvent()
2711{ 2711{
2712 DateList tmpList = mNavigator->selectedDates(); 2712 DateList tmpList = mNavigator->selectedDates();
2713 QDate date = tmpList.first(); 2713 QDate date = tmpList.first();
2714 2714
2715 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 2715 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
2716 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 2716 QDateTime( date, QTime( 12, 0, 0 ) ), true );
2717} 2717}
2718 2718
2719 2719
2720void CalendarView::editEvent( Event *event ) 2720void CalendarView::editEvent( Event *event )
2721{ 2721{
2722 2722
2723 if ( !event ) return; 2723 if ( !event ) return;
2724 if ( event->isReadOnly() ) { 2724 if ( event->isReadOnly() ) {
2725 showEvent( event ); 2725 showEvent( event );
2726 return; 2726 return;
2727 } 2727 }
2728 showEventEditor(); 2728 showEventEditor();
2729 mEventEditor->editEvent( event , mFlagEditDescription); 2729 mEventEditor->editEvent( event , mFlagEditDescription);
2730} 2730}
2731void CalendarView::editJournal( Journal *jour ) 2731void CalendarView::editJournal( Journal *jour )
2732{ 2732{
2733 if ( !jour ) return; 2733 if ( !jour ) return;
2734 mDialogManager->hideSearchDialog(); 2734 mDialogManager->hideSearchDialog();
2735 mViewManager->showJournalView(); 2735 mViewManager->showJournalView();
2736 mNavigator->slotDaySelect( jour->dtStart().date() ); 2736 mNavigator->slotDaySelect( jour->dtStart().date() );
2737} 2737}
2738void CalendarView::editTodo( Todo *todo ) 2738void CalendarView::editTodo( Todo *todo )
2739{ 2739{
2740 if ( !todo ) return; 2740 if ( !todo ) return;
2741 2741
2742 if ( todo->isReadOnly() ) { 2742 if ( todo->isReadOnly() ) {
2743 showTodo( todo ); 2743 showTodo( todo );
2744 return; 2744 return;
2745 } 2745 }
2746 showTodoEditor(); 2746 showTodoEditor();
2747 mTodoEditor->editTodo( todo ,mFlagEditDescription); 2747 mTodoEditor->editTodo( todo ,mFlagEditDescription);
2748 2748
2749} 2749}
2750 2750
2751KOEventViewerDialog* CalendarView::getEventViewerDialog() 2751KOEventViewerDialog* CalendarView::getEventViewerDialog()
2752{ 2752{
2753 if ( !mEventViewerDialog ) { 2753 if ( !mEventViewerDialog ) {
2754 mEventViewerDialog = new KOEventViewerDialog(this); 2754 mEventViewerDialog = new KOEventViewerDialog(this);
2755 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 2755 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
2756 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 2756 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
2757 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 2757 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
2758 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 2758 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
2759 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 2759 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
2760 viewManager(), SLOT( showAgendaView( bool ) ) ); 2760 viewManager(), SLOT( showAgendaView( bool ) ) );
2761 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), 2761 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ),
2762 this, SLOT( todoChanged(Todo *) ) ); 2762 this, SLOT( todoChanged(Todo *) ) );
2763 mEventViewerDialog->resize( 640, 480 ); 2763 mEventViewerDialog->resize( 640, 480 );
2764 2764
2765 } 2765 }
2766 return mEventViewerDialog; 2766 return mEventViewerDialog;
2767} 2767}
2768void CalendarView::showEvent(Event *event) 2768void CalendarView::showEvent(Event *event)
2769{ 2769{
2770 getEventViewerDialog()->setEvent(event); 2770 getEventViewerDialog()->setEvent(event);
2771 getEventViewerDialog()->showMe(); 2771 getEventViewerDialog()->showMe();
2772} 2772}
2773 2773
2774void CalendarView::showTodo(Todo *event) 2774void CalendarView::showTodo(Todo *event)
2775{ 2775{
2776 getEventViewerDialog()->setTodo(event); 2776 getEventViewerDialog()->setTodo(event);
2777 getEventViewerDialog()->showMe(); 2777 getEventViewerDialog()->showMe();
2778} 2778}
2779void CalendarView::showJournal( Journal *jour ) 2779void CalendarView::showJournal( Journal *jour )
2780{ 2780{
2781 getEventViewerDialog()->setJournal(jour); 2781 getEventViewerDialog()->setJournal(jour);
2782 getEventViewerDialog()->showMe(); 2782 getEventViewerDialog()->showMe();
2783 2783
2784} 2784}
2785// void CalendarView::todoModified (Todo *event, int changed) 2785// void CalendarView::todoModified (Todo *event, int changed)
2786// { 2786// {
2787// // if (mDialogList.find (event) != mDialogList.end ()) { 2787// // if (mDialogList.find (event) != mDialogList.end ()) {
2788// // kdDebug() << "Todo modified and open" << endl; 2788// // kdDebug() << "Todo modified and open" << endl;
2789// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 2789// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
2790// // temp->modified (changed); 2790// // temp->modified (changed);
2791 2791
2792// // } 2792// // }
2793 2793
2794// mViewManager->updateView(); 2794// mViewManager->updateView();
2795// } 2795// }
2796 2796
2797void CalendarView::appointment_show() 2797void CalendarView::appointment_show()
2798{ 2798{
2799 Event *anEvent = 0; 2799 Event *anEvent = 0;
2800 2800
2801 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2801 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2802 2802
2803 if (mViewManager->currentView()->isEventView()) { 2803 if (mViewManager->currentView()->isEventView()) {
2804 if ( incidence && incidence->type() == "Event" ) { 2804 if ( incidence && incidence->type() == "Event" ) {
2805 anEvent = static_cast<Event *>(incidence); 2805 anEvent = static_cast<Event *>(incidence);
2806 } 2806 }
2807 } 2807 }
2808 2808
2809 if (!anEvent) { 2809 if (!anEvent) {
2810 KNotifyClient::beep(); 2810 KNotifyClient::beep();
2811 return; 2811 return;
2812 } 2812 }
2813 2813
2814 showEvent(anEvent); 2814 showEvent(anEvent);
2815} 2815}
2816 2816
2817void CalendarView::appointment_edit() 2817void CalendarView::appointment_edit()
2818{ 2818{
2819 Event *anEvent = 0; 2819 Event *anEvent = 0;
2820 2820
2821 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2821 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2822 2822
2823 if (mViewManager->currentView()->isEventView()) { 2823 if (mViewManager->currentView()->isEventView()) {
2824 if ( incidence && incidence->type() == "Event" ) { 2824 if ( incidence && incidence->type() == "Event" ) {
2825 anEvent = static_cast<Event *>(incidence); 2825 anEvent = static_cast<Event *>(incidence);
2826 } 2826 }
2827 } 2827 }
2828 2828
2829 if (!anEvent) { 2829 if (!anEvent) {
2830 KNotifyClient::beep(); 2830 KNotifyClient::beep();
2831 return; 2831 return;
2832 } 2832 }
2833 2833
2834 editEvent(anEvent); 2834 editEvent(anEvent);
2835} 2835}
2836 2836
2837void CalendarView::appointment_delete() 2837void CalendarView::appointment_delete()
2838{ 2838{
2839 Event *anEvent = 0; 2839 Event *anEvent = 0;
2840 2840
2841 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2841 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2842 2842
2843 if (mViewManager->currentView()->isEventView()) { 2843 if (mViewManager->currentView()->isEventView()) {
2844 if ( incidence && incidence->type() == "Event" ) { 2844 if ( incidence && incidence->type() == "Event" ) {
2845 anEvent = static_cast<Event *>(incidence); 2845 anEvent = static_cast<Event *>(incidence);
2846 } 2846 }
2847 } 2847 }
2848 2848
2849 if (!anEvent) { 2849 if (!anEvent) {
2850 KNotifyClient::beep(); 2850 KNotifyClient::beep();
2851 return; 2851 return;
2852 } 2852 }
2853 2853
2854 deleteEvent(anEvent); 2854 deleteEvent(anEvent);
2855} 2855}
2856 2856
2857void CalendarView::todo_resub( Todo * parent, Todo * sub ) 2857void CalendarView::todo_resub( Todo * parent, Todo * sub )
2858{ 2858{
2859 if (!sub) return; 2859 if (!sub) return;
2860 if (!parent) return; 2860 if (!parent) return;
2861 if ( sub->relatedTo() ) 2861 if ( sub->relatedTo() )
2862 sub->relatedTo()->removeRelation(sub); 2862 sub->relatedTo()->removeRelation(sub);
2863 sub->setRelatedTo(parent); 2863 sub->setRelatedTo(parent);
2864 sub->setRelatedToUid(parent->uid()); 2864 sub->setRelatedToUid(parent->uid());
2865 parent->addRelation(sub); 2865 parent->addRelation(sub);
2866 sub->updated(); 2866 sub->updated();
2867 parent->updated(); 2867 parent->updated();
2868 setModified(true); 2868 setModified(true);
2869 updateView(); 2869 updateView();
2870} 2870}
2871void CalendarView::todo_unsub(Todo *anTodo ) 2871void CalendarView::todo_unsub(Todo *anTodo )
2872{ 2872{
2873 // Todo *anTodo = selectedTodo(); 2873 // Todo *anTodo = selectedTodo();
2874 if (!anTodo) return; 2874 if (!anTodo) return;
2875 if (!anTodo->relatedTo()) return; 2875 if (!anTodo->relatedTo()) return;
2876 anTodo->relatedTo()->removeRelation(anTodo); 2876 anTodo->relatedTo()->removeRelation(anTodo);
2877 anTodo->setRelatedTo(0); 2877 anTodo->setRelatedTo(0);
2878 anTodo->updated(); 2878 anTodo->updated();
2879 anTodo->setRelatedToUid(""); 2879 anTodo->setRelatedToUid("");
2880 setModified(true); 2880 setModified(true);
2881 updateView(); 2881 updateView();
2882} 2882}
2883 2883
2884void CalendarView::deleteTodo(Todo *todo) 2884void CalendarView::deleteTodo(Todo *todo)
2885{ 2885{
2886 if (!todo) { 2886 if (!todo) {
2887 KNotifyClient::beep(); 2887 KNotifyClient::beep();
2888 return; 2888 return;
2889 } 2889 }
2890 if (KOPrefs::instance()->mConfirm) { 2890 if (KOPrefs::instance()->mConfirm) {
2891 switch (msgItemDelete()) { 2891 switch (msgItemDelete()) {
2892 case KMessageBox::Continue: // OK 2892 case KMessageBox::Continue: // OK
2893 if (!todo->relations().isEmpty()) { 2893 if (!todo->relations().isEmpty()) {
2894 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), 2894 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."),
2895 i18n("Delete To-Do")); 2895 i18n("Delete To-Do"));
2896 } else { 2896 } else {
2897 checkExternalId( todo ); 2897 checkExternalId( todo );
2898 calendar()->deleteTodo(todo); 2898 calendar()->deleteTodo(todo);
2899 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2899 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2900 updateView(); 2900 updateView();
2901 } 2901 }
2902 break; 2902 break;
2903 } // switch 2903 } // switch
2904 } else { 2904 } else {
2905 if (!todo->relations().isEmpty()) { 2905 if (!todo->relations().isEmpty()) {
2906 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), 2906 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."),
2907 i18n("Delete To-Do")); 2907 i18n("Delete To-Do"));
2908 } else { 2908 } else {
2909 checkExternalId( todo ); 2909 checkExternalId( todo );
2910 mCalendar->deleteTodo(todo); 2910 mCalendar->deleteTodo(todo);
2911 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2911 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2912 updateView(); 2912 updateView();
2913 } 2913 }
2914 } 2914 }
2915 emit updateSearchDialog(); 2915 emit updateSearchDialog();
2916} 2916}
2917void CalendarView::deleteJournal(Journal *jour) 2917void CalendarView::deleteJournal(Journal *jour)
2918{ 2918{
2919 if (!jour) { 2919 if (!jour) {
2920 KNotifyClient::beep(); 2920 KNotifyClient::beep();
2921 return; 2921 return;
2922 } 2922 }
2923 if (KOPrefs::instance()->mConfirm) { 2923 if (KOPrefs::instance()->mConfirm) {
2924 switch (msgItemDelete()) { 2924 switch (msgItemDelete()) {
2925 case KMessageBox::Continue: // OK 2925 case KMessageBox::Continue: // OK
2926 calendar()->deleteJournal(jour); 2926 calendar()->deleteJournal(jour);
2927 updateView(); 2927 updateView();
2928 break; 2928 break;
2929 } // switch 2929 } // switch
2930 } else { 2930 } else {
2931 calendar()->deleteJournal(jour);; 2931 calendar()->deleteJournal(jour);;
2932 updateView(); 2932 updateView();
2933 } 2933 }
2934 emit updateSearchDialog(); 2934 emit updateSearchDialog();
2935} 2935}
2936 2936
2937void CalendarView::deleteEvent(Event *anEvent) 2937void CalendarView::deleteEvent(Event *anEvent)
2938{ 2938{
2939 if (!anEvent) { 2939 if (!anEvent) {
2940 KNotifyClient::beep(); 2940 KNotifyClient::beep();
2941 return; 2941 return;
2942 } 2942 }
2943 2943
2944 if (anEvent->recurrence()->doesRecur()) { 2944 if (anEvent->recurrence()->doesRecur()) {
2945 QDate itemDate = mViewManager->currentSelectionDate(); 2945 QDate itemDate = mViewManager->currentSelectionDate();
2946 int km; 2946 int km;
2947 if (!itemDate.isValid()) { 2947 if (!itemDate.isValid()) {
2948 //kdDebug() << "Date Not Valid" << endl; 2948 //kdDebug() << "Date Not Valid" << endl;
2949 if (KOPrefs::instance()->mConfirm) { 2949 if (KOPrefs::instance()->mConfirm) {
2950 km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + 2950 km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) +
2951 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), 2951 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"),
2952 i18n("KO/Pi Confirmation"),i18n("Delete All")); 2952 i18n("KO/Pi Confirmation"),i18n("Delete All"));
2953 if ( km == KMessageBox::Continue ) 2953 if ( km == KMessageBox::Continue )
2954 km = KMessageBox::No; // No = all below 2954 km = KMessageBox::No; // No = all below
2955 } else 2955 } else
2956 km = KMessageBox::No; 2956 km = KMessageBox::No;
2957 } else { 2957 } else {
2958 km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + 2958 km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) +
2959 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ 2959 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+
2960 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), 2960 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"),
2961 i18n("KO/Pi Confirmation"),i18n("Current"), 2961 i18n("KO/Pi Confirmation"),i18n("Current"),
2962 i18n("All")); 2962 i18n("All"));
2963 } 2963 }
2964 switch(km) { 2964 switch(km) {
2965 2965
2966 case KMessageBox::No: // Continue // all 2966 case KMessageBox::No: // Continue // all
2967 //qDebug("KMessageBox::No "); 2967 //qDebug("KMessageBox::No ");
2968 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2968 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2969 schedule(Scheduler::Cancel,anEvent); 2969 schedule(Scheduler::Cancel,anEvent);
2970 2970
2971 checkExternalId( anEvent); 2971 checkExternalId( anEvent);
2972 mCalendar->deleteEvent(anEvent); 2972 mCalendar->deleteEvent(anEvent);
2973 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); 2973 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED);
2974 break; 2974 break;
2975 2975
2976 // Disabled because it does not work 2976 // Disabled because it does not work
2977 //#if 0 2977 //#if 0
2978 case KMessageBox::Yes: // just this one 2978 case KMessageBox::Yes: // just this one
2979 //QDate qd = mNavigator->selectedDates().first(); 2979 //QDate qd = mNavigator->selectedDates().first();
2980 //if (!qd.isValid()) { 2980 //if (!qd.isValid()) {
2981 // kdDebug() << "no date selected, or invalid date" << endl; 2981 // kdDebug() << "no date selected, or invalid date" << endl;
2982 // KNotifyClient::beep(); 2982 // KNotifyClient::beep();
2983 // return; 2983 // return;
2984 //} 2984 //}
2985 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); 2985 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1);
2986 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { 2986 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) {
2987 anEvent->addExDate(itemDate); 2987 anEvent->addExDate(itemDate);
2988 int duration = anEvent->recurrence()->duration(); 2988 int duration = anEvent->recurrence()->duration();
2989 if ( duration > 0 ) { 2989 if ( duration > 0 ) {
2990 anEvent->recurrence()->setDuration( duration - 1 ); 2990 anEvent->recurrence()->setDuration( duration - 1 );
2991 } 2991 }
2992 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); 2992 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED);
2993 } 2993 }
2994 break; 2994 break;
2995 //#endif 2995 //#endif
2996 } // switch 2996 } // switch
2997 } else { 2997 } else {
2998 if (KOPrefs::instance()->mConfirm) { 2998 if (KOPrefs::instance()->mConfirm) {
2999 switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + 2999 switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) +
3000 i18n("\nAre you sure you want\nto delete this event?"), 3000 i18n("\nAre you sure you want\nto delete this event?"),
3001 i18n("KO/Pi Confirmation"),i18n("Delete"))) { 3001 i18n("KO/Pi Confirmation"),i18n("Delete"))) {
3002 case KMessageBox::Continue: // OK 3002 case KMessageBox::Continue: // OK
3003 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3003 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3004 schedule(Scheduler::Cancel,anEvent); 3004 schedule(Scheduler::Cancel,anEvent);
3005 checkExternalId( anEvent); 3005 checkExternalId( anEvent);
3006 mCalendar->deleteEvent(anEvent); 3006 mCalendar->deleteEvent(anEvent);
3007 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3007 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3008 break; 3008 break;
3009 } // switch 3009 } // switch
3010 } else { 3010 } else {
3011 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3011 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3012 schedule(Scheduler::Cancel,anEvent); 3012 schedule(Scheduler::Cancel,anEvent);
3013 checkExternalId( anEvent); 3013 checkExternalId( anEvent);
3014 mCalendar->deleteEvent(anEvent); 3014 mCalendar->deleteEvent(anEvent);
3015 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3015 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3016 } 3016 }
3017 } // if-else 3017 } // if-else
3018 emit updateSearchDialog(); 3018 emit updateSearchDialog();
3019} 3019}
3020 3020
3021bool CalendarView::deleteEvent(const QString &uid) 3021bool CalendarView::deleteEvent(const QString &uid)
3022{ 3022{
3023 Event *ev = mCalendar->event(uid); 3023 Event *ev = mCalendar->event(uid);
3024 if (ev) { 3024 if (ev) {
3025 deleteEvent(ev); 3025 deleteEvent(ev);
3026 return true; 3026 return true;
3027 } else { 3027 } else {
3028 return false; 3028 return false;
3029 } 3029 }
3030} 3030}
3031 3031
3032/*****************************************************************************/ 3032/*****************************************************************************/
3033 3033
3034void CalendarView::action_mail() 3034void CalendarView::action_mail()
3035{ 3035{
3036#ifndef KORG_NOMAIL 3036#ifndef KORG_NOMAIL
3037 KOMailClient mailClient; 3037 KOMailClient mailClient;
3038 3038
3039 Incidence *incidence = currentSelection(); 3039 Incidence *incidence = currentSelection();
3040 3040
3041 if (!incidence) { 3041 if (!incidence) {
3042 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3042 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3043 return; 3043 return;
3044 } 3044 }
3045 if(incidence->attendeeCount() == 0 ) { 3045 if(incidence->attendeeCount() == 0 ) {
3046 KMessageBox::sorry(this, 3046 KMessageBox::sorry(this,
3047 i18n("Can't generate mail:\nNo attendees defined.\n")); 3047 i18n("Can't generate mail:\nNo attendees defined.\n"));
3048 return; 3048 return;
3049 } 3049 }
3050 3050
3051 CalendarLocal cal_tmp; 3051 CalendarLocal cal_tmp;
3052 Event *event = 0; 3052 Event *event = 0;
3053 Event *ev = 0; 3053 Event *ev = 0;
3054 if ( incidence && incidence->type() == "Event" ) { 3054 if ( incidence && incidence->type() == "Event" ) {
3055 event = static_cast<Event *>(incidence); 3055 event = static_cast<Event *>(incidence);
3056 ev = new Event(*event); 3056 ev = new Event(*event);
3057 cal_tmp.addEvent(ev); 3057 cal_tmp.addEvent(ev);
3058 } 3058 }
3059 ICalFormat mForm(); 3059 ICalFormat mForm();
3060 QString attachment = mForm.toString( &cal_tmp ); 3060 QString attachment = mForm.toString( &cal_tmp );
3061 if (ev) delete(ev); 3061 if (ev) delete(ev);
3062 3062
3063 mailClient.mailAttendees(currentSelection(), attachment); 3063 mailClient.mailAttendees(currentSelection(), attachment);
3064 3064
3065#endif 3065#endif
3066 3066
3067#if 0 3067#if 0
3068 Event *anEvent = 0; 3068 Event *anEvent = 0;
3069 if (mViewManager->currentView()->isEventView()) { 3069 if (mViewManager->currentView()->isEventView()) {
3070 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); 3070 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first());
3071 } 3071 }
3072 3072
3073 if (!anEvent) { 3073 if (!anEvent) {
3074 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3074 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3075 return; 3075 return;
3076 } 3076 }
3077 if(anEvent->attendeeCount() == 0 ) { 3077 if(anEvent->attendeeCount() == 0 ) {
3078 KMessageBox::sorry(this, 3078 KMessageBox::sorry(this,
3079 i18n("Can't generate mail:\nNo attendees defined.\n")); 3079 i18n("Can't generate mail:\nNo attendees defined.\n"));
3080 return; 3080 return;
3081 } 3081 }
3082 3082
3083 mailobject.emailEvent(anEvent); 3083 mailobject.emailEvent(anEvent);
3084#endif 3084#endif
3085} 3085}
3086 3086
3087 3087
3088void CalendarView::schedule_publish(Incidence *incidence) 3088void CalendarView::schedule_publish(Incidence *incidence)
3089{ 3089{
3090 Event *event = 0; 3090 Event *event = 0;
3091 Todo *todo = 0; 3091 Todo *todo = 0;
3092 3092
3093 if (incidence == 0) { 3093 if (incidence == 0) {
3094 incidence = mViewManager->currentView()->selectedIncidences().first(); 3094 incidence = mViewManager->currentView()->selectedIncidences().first();
3095 if (incidence == 0) { 3095 if (incidence == 0) {
3096 incidence = mTodoList->selectedIncidences().first(); 3096 incidence = mTodoList->selectedIncidences().first();
3097 } 3097 }
3098 } 3098 }
3099 if ( incidence && incidence->type() == "Event" ) { 3099 if ( incidence && incidence->type() == "Event" ) {
3100 event = static_cast<Event *>(incidence); 3100 event = static_cast<Event *>(incidence);
3101 } else { 3101 } else {
3102 if ( incidence && incidence->type() == "Todo" ) { 3102 if ( incidence && incidence->type() == "Todo" ) {
3103 todo = static_cast<Todo *>(incidence); 3103 todo = static_cast<Todo *>(incidence);
3104 } 3104 }
3105 } 3105 }
3106 3106
3107 if (!event && !todo) { 3107 if (!event && !todo) {
3108 KMessageBox::sorry(this,i18n("No event selected.")); 3108 KMessageBox::sorry(this,i18n("No event selected."));
3109 return; 3109 return;
3110 } 3110 }
3111 3111
3112 PublishDialog *publishdlg = new PublishDialog(); 3112 PublishDialog *publishdlg = new PublishDialog();
3113 if (incidence->attendeeCount()>0) { 3113 if (incidence->attendeeCount()>0) {
3114 QPtrList<Attendee> attendees = incidence->attendees(); 3114 QPtrList<Attendee> attendees = incidence->attendees();
3115 attendees.first(); 3115 attendees.first();
3116 while ( attendees.current()!=0 ) { 3116 while ( attendees.current()!=0 ) {
3117 publishdlg->addAttendee(attendees.current()); 3117 publishdlg->addAttendee(attendees.current());
3118 attendees.next(); 3118 attendees.next();
3119 } 3119 }
3120 } 3120 }
3121 bool send = true; 3121 bool send = true;
3122 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { 3122 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) {
3123 if ( publishdlg->exec() != QDialog::Accepted ) 3123 if ( publishdlg->exec() != QDialog::Accepted )
3124 send = false; 3124 send = false;
3125 } 3125 }
3126 if ( send ) { 3126 if ( send ) {
3127 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3127 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3128 if ( event ) { 3128 if ( event ) {
3129 Event *ev = new Event(*event); 3129 Event *ev = new Event(*event);
3130 ev->registerObserver(0); 3130 ev->registerObserver(0);
3131 ev->clearAttendees(); 3131 ev->clearAttendees();
3132 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3132 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3133 delete(ev); 3133 delete(ev);
3134 } 3134 }
3135 } else { 3135 } else {
3136 if ( todo ) { 3136 if ( todo ) {
3137 Todo *ev = new Todo(*todo); 3137 Todo *ev = new Todo(*todo);
3138 ev->registerObserver(0); 3138 ev->registerObserver(0);
3139 ev->clearAttendees(); 3139 ev->clearAttendees();
3140 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3140 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3141 delete(ev); 3141 delete(ev);
3142 } 3142 }
3143 } 3143 }
3144 } 3144 }
3145 } 3145 }
3146 delete publishdlg; 3146 delete publishdlg;
3147} 3147}
3148 3148
3149void CalendarView::schedule_request(Incidence *incidence) 3149void CalendarView::schedule_request(Incidence *incidence)
3150{ 3150{
3151 schedule(Scheduler::Request,incidence); 3151 schedule(Scheduler::Request,incidence);
3152} 3152}
3153 3153
3154void CalendarView::schedule_refresh(Incidence *incidence) 3154void CalendarView::schedule_refresh(Incidence *incidence)
3155{ 3155{
3156 schedule(Scheduler::Refresh,incidence); 3156 schedule(Scheduler::Refresh,incidence);
3157} 3157}
3158 3158
3159void CalendarView::schedule_cancel(Incidence *incidence) 3159void CalendarView::schedule_cancel(Incidence *incidence)
3160{ 3160{
3161 schedule(Scheduler::Cancel,incidence); 3161 schedule(Scheduler::Cancel,incidence);
3162} 3162}
3163 3163
3164void CalendarView::schedule_add(Incidence *incidence) 3164void CalendarView::schedule_add(Incidence *incidence)
3165{ 3165{
3166 schedule(Scheduler::Add,incidence); 3166 schedule(Scheduler::Add,incidence);
3167} 3167}
3168 3168
3169void CalendarView::schedule_reply(Incidence *incidence) 3169void CalendarView::schedule_reply(Incidence *incidence)
3170{ 3170{
3171 schedule(Scheduler::Reply,incidence); 3171 schedule(Scheduler::Reply,incidence);
3172} 3172}
3173 3173
3174void CalendarView::schedule_counter(Incidence *incidence) 3174void CalendarView::schedule_counter(Incidence *incidence)
3175{ 3175{
3176 schedule(Scheduler::Counter,incidence); 3176 schedule(Scheduler::Counter,incidence);
3177} 3177}
3178 3178
3179void CalendarView::schedule_declinecounter(Incidence *incidence) 3179void CalendarView::schedule_declinecounter(Incidence *incidence)
3180{ 3180{
3181 schedule(Scheduler::Declinecounter,incidence); 3181 schedule(Scheduler::Declinecounter,incidence);
3182} 3182}
3183 3183
3184void CalendarView::schedule_publish_freebusy(int daysToPublish) 3184void CalendarView::schedule_publish_freebusy(int daysToPublish)
3185{ 3185{
3186 QDateTime start = QDateTime::currentDateTime(); 3186 QDateTime start = QDateTime::currentDateTime();
3187 QDateTime end = start.addDays(daysToPublish); 3187 QDateTime end = start.addDays(daysToPublish);
3188 3188
3189 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); 3189 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end);
3190 freebusy->setOrganizer(KOPrefs::instance()->email()); 3190 freebusy->setOrganizer(KOPrefs::instance()->email());
3191 3191
3192 3192
3193 PublishDialog *publishdlg = new PublishDialog(); 3193 PublishDialog *publishdlg = new PublishDialog();
3194 if ( publishdlg->exec() == QDialog::Accepted ) { 3194 if ( publishdlg->exec() == QDialog::Accepted ) {
3195 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3195 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3196 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { 3196 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) {
3197 delete(freebusy); 3197 delete(freebusy);
3198 } 3198 }
3199 } 3199 }
3200 delete publishdlg; 3200 delete publishdlg;
3201} 3201}
3202 3202
3203void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) 3203void CalendarView::schedule(Scheduler::Method method, Incidence *incidence)
3204{ 3204{
3205 Event *event = 0; 3205 Event *event = 0;
3206 Todo *todo = 0; 3206 Todo *todo = 0;
3207 3207
3208 if (incidence == 0) { 3208 if (incidence == 0) {
3209 incidence = mViewManager->currentView()->selectedIncidences().first(); 3209 incidence = mViewManager->currentView()->selectedIncidences().first();
3210 if (incidence == 0) { 3210 if (incidence == 0) {
3211 incidence = mTodoList->selectedIncidences().first(); 3211 incidence = mTodoList->selectedIncidences().first();
3212 } 3212 }
3213 } 3213 }
3214 if ( incidence && incidence->type() == "Event" ) { 3214 if ( incidence && incidence->type() == "Event" ) {
3215 event = static_cast<Event *>(incidence); 3215 event = static_cast<Event *>(incidence);
3216 } 3216 }
3217 if ( incidence && incidence->type() == "Todo" ) { 3217 if ( incidence && incidence->type() == "Todo" ) {
3218 todo = static_cast<Todo *>(incidence); 3218 todo = static_cast<Todo *>(incidence);
3219 } 3219 }
3220 3220
3221 if (!event && !todo) { 3221 if (!event && !todo) {
3222 KMessageBox::sorry(this,i18n("No event selected.")); 3222 KMessageBox::sorry(this,i18n("No event selected."));
3223 return; 3223 return;
3224 } 3224 }
3225 3225
3226 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { 3226 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) {
3227 KMessageBox::sorry(this,i18n("The event has no attendees.")); 3227 KMessageBox::sorry(this,i18n("The event has no attendees."));
3228 return; 3228 return;
3229 } 3229 }
3230 3230
3231 Event *ev = 0; 3231 Event *ev = 0;
3232 if (event) ev = new Event(*event); 3232 if (event) ev = new Event(*event);
3233 Todo *to = 0; 3233 Todo *to = 0;
3234 if (todo) to = new Todo(*todo); 3234 if (todo) to = new Todo(*todo);
3235 3235
3236 if (method == Scheduler::Reply || method == Scheduler::Refresh) { 3236 if (method == Scheduler::Reply || method == Scheduler::Refresh) {
3237 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 3237 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
3238 if (!me) { 3238 if (!me) {
3239 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."));
3240 return; 3240 return;
3241 } 3241 }
3242 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { 3242 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) {
3243 StatusDialog *statdlg = new StatusDialog(this); 3243 StatusDialog *statdlg = new StatusDialog(this);
3244 if (!statdlg->exec()==QDialog::Accepted) return; 3244 if (!statdlg->exec()==QDialog::Accepted) return;
3245 me->setStatus( statdlg->status() ); 3245 me->setStatus( statdlg->status() );
3246 delete(statdlg); 3246 delete(statdlg);
3247 } 3247 }
3248 Attendee *menew = new Attendee(*me); 3248 Attendee *menew = new Attendee(*me);
3249 if (ev) { 3249 if (ev) {
3250 ev->clearAttendees(); 3250 ev->clearAttendees();
3251 ev->addAttendee(menew,false); 3251 ev->addAttendee(menew,false);
3252 } else { 3252 } else {
3253 if (to) { 3253 if (to) {
3254 todo->clearAttendees(); 3254 todo->clearAttendees();
3255 todo->addAttendee(menew,false); 3255 todo->addAttendee(menew,false);
3256 } 3256 }
3257 } 3257 }
3258 } 3258 }
3259 3259
3260 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3260 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3261 if (ev) { 3261 if (ev) {
3262 if ( !dlg->addMessage(ev,method) ) delete(ev); 3262 if ( !dlg->addMessage(ev,method) ) delete(ev);
3263 } else { 3263 } else {
3264 if (to) { 3264 if (to) {
3265 if ( !dlg->addMessage(to,method) ) delete(to); 3265 if ( !dlg->addMessage(to,method) ) delete(to);
3266 } 3266 }
3267 } 3267 }
3268} 3268}
3269 3269
3270void CalendarView::openAddressbook() 3270void CalendarView::openAddressbook()
3271{ 3271{
3272 KRun::runCommand("kaddressbook"); 3272 KRun::runCommand("kaddressbook");
3273} 3273}
3274 3274
3275void CalendarView::setModified(bool modified) 3275void CalendarView::setModified(bool modified)
3276{ 3276{
3277 if ( modified ) 3277 if ( modified )
3278 emit signalmodified(); 3278 emit signalmodified();
3279 if (mModified != modified) { 3279 if (mModified != modified) {
3280 mModified = modified; 3280 mModified = modified;
3281 emit modifiedChanged(mModified); 3281 emit modifiedChanged(mModified);
3282 } 3282 }
3283} 3283}
3284 3284
3285bool CalendarView::isReadOnly() 3285bool CalendarView::isReadOnly()
3286{ 3286{
3287 return mReadOnly; 3287 return mReadOnly;
3288} 3288}
3289 3289
3290void CalendarView::setReadOnly(bool readOnly) 3290void CalendarView::setReadOnly(bool readOnly)
3291{ 3291{
3292 if (mReadOnly != readOnly) { 3292 if (mReadOnly != readOnly) {
3293 mReadOnly = readOnly; 3293 mReadOnly = readOnly;
3294 emit readOnlyChanged(mReadOnly); 3294 emit readOnlyChanged(mReadOnly);
3295 } 3295 }
3296} 3296}
3297 3297
3298bool CalendarView::isModified() 3298bool CalendarView::isModified()
3299{ 3299{
3300 return mModified; 3300 return mModified;
3301} 3301}
3302 3302
3303void CalendarView::printSetup() 3303void CalendarView::printSetup()
3304{ 3304{
3305#ifndef KORG_NOPRINTER 3305#ifndef KORG_NOPRINTER
3306 createPrinter(); 3306 createPrinter();
3307 3307
3308 mCalPrinter->setupPrinter(); 3308 mCalPrinter->setupPrinter();
3309#endif 3309#endif
3310} 3310}
3311 3311
3312void CalendarView::print() 3312void CalendarView::print()
3313{ 3313{
3314#ifndef KORG_NOPRINTER 3314#ifndef KORG_NOPRINTER
3315 createPrinter(); 3315 createPrinter();
3316 3316
3317 DateList tmpDateList = mNavigator->selectedDates(); 3317 DateList tmpDateList = mNavigator->selectedDates();
3318 mCalPrinter->print(CalPrinter::Month, 3318 mCalPrinter->print(CalPrinter::Month,
3319 tmpDateList.first(), tmpDateList.last()); 3319 tmpDateList.first(), tmpDateList.last());
3320#endif 3320#endif
3321} 3321}
3322 3322
3323void CalendarView::printPreview() 3323void CalendarView::printPreview()
3324{ 3324{
3325#ifndef KORG_NOPRINTER 3325#ifndef KORG_NOPRINTER
3326 kdDebug() << "CalendarView::printPreview()" << endl; 3326 kdDebug() << "CalendarView::printPreview()" << endl;
3327 3327
3328 createPrinter(); 3328 createPrinter();
3329 3329
3330 DateList tmpDateList = mNavigator->selectedDates(); 3330 DateList tmpDateList = mNavigator->selectedDates();
3331 3331
3332 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), 3332 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(),
3333 tmpDateList.last()); 3333 tmpDateList.last());
3334#endif 3334#endif
3335} 3335}
3336 3336
3337void CalendarView::exportICalendar() 3337void CalendarView::exportICalendar()
3338{ 3338{
3339 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); 3339 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this);
3340 3340
3341 // Force correct extension 3341 // Force correct extension
3342 if (filename.right(4) != ".ics") filename += ".ics"; 3342 if (filename.right(4) != ".ics") filename += ".ics";
3343 3343
3344 FileStorage storage( mCalendar, filename, new ICalFormat() ); 3344 FileStorage storage( mCalendar, filename, new ICalFormat() );
3345 storage.save(); 3345 storage.save();
3346} 3346}
3347 3347
3348bool CalendarView::exportVCalendar( QString filename ) 3348bool CalendarView::exportVCalendar( QString filename )
3349{ 3349{
3350 if (mCalendar->journals().count() > 0) { 3350 if (mCalendar->journals().count() > 0) {
3351 int result = KMessageBox::warningContinueCancel(this, 3351 int result = KMessageBox::warningContinueCancel(this,
3352 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."),
3353 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 3353 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
3354 true); 3354 true);
3355 if (result != KMessageBox::Continue) return false; 3355 if (result != KMessageBox::Continue) return false;
3356 } 3356 }
3357 3357
3358 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); 3358 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this);
3359 3359
3360 // Force correct extension 3360 // Force correct extension
3361 if (filename.right(4) != ".vcs") filename += ".vcs"; 3361 if (filename.right(4) != ".vcs") filename += ".vcs";
3362 3362
3363 FileStorage storage( mCalendar, filename, new VCalFormat ); 3363 FileStorage storage( mCalendar, filename, new VCalFormat );
3364 return storage.save(); 3364 return storage.save();
3365 3365
3366} 3366}
3367 3367
3368void CalendarView::eventUpdated(Incidence *) 3368void CalendarView::eventUpdated(Incidence *)
3369{ 3369{
3370 setModified(); 3370 setModified();
3371 // 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
3372 // event is responsible for updating the view. 3372 // event is responsible for updating the view.
3373 // updateView(); 3373 // updateView();
3374} 3374}
3375 3375
3376void CalendarView::adaptNavigationUnits() 3376void CalendarView::adaptNavigationUnits()
3377{ 3377{
3378 if (mViewManager->currentView()->isEventView()) { 3378 if (mViewManager->currentView()->isEventView()) {
3379 int days = mViewManager->currentView()->currentDateCount(); 3379 int days = mViewManager->currentView()->currentDateCount();
3380 if (days == 1) { 3380 if (days == 1) {
3381 emit changeNavStringPrev(i18n("&Previous Day")); 3381 emit changeNavStringPrev(i18n("&Previous Day"));
3382 emit changeNavStringNext(i18n("&Next Day")); 3382 emit changeNavStringNext(i18n("&Next Day"));
3383 } else { 3383 } else {
3384 emit changeNavStringPrev(i18n("&Previous Week")); 3384 emit changeNavStringPrev(i18n("&Previous Week"));
3385 emit changeNavStringNext(i18n("&Next Week")); 3385 emit changeNavStringNext(i18n("&Next Week"));
3386 } 3386 }
3387 } 3387 }
3388} 3388}
3389 3389
3390void CalendarView::processMainViewSelection( Incidence *incidence ) 3390void CalendarView::processMainViewSelection( Incidence *incidence )
3391{ 3391{
3392 if ( incidence ) mTodoList->clearSelection(); 3392 if ( incidence ) mTodoList->clearSelection();
3393 processIncidenceSelection( incidence ); 3393 processIncidenceSelection( incidence );
3394} 3394}
3395 3395
3396void CalendarView::processTodoListSelection( Incidence *incidence ) 3396void CalendarView::processTodoListSelection( Incidence *incidence )
3397{ 3397{
3398 if ( incidence && mViewManager->currentView() ) { 3398 if ( incidence && mViewManager->currentView() ) {
3399 mViewManager->currentView()->clearSelection(); 3399 mViewManager->currentView()->clearSelection();
3400 } 3400 }
3401 processIncidenceSelection( incidence ); 3401 processIncidenceSelection( incidence );
3402} 3402}
3403 3403
3404void CalendarView::processIncidenceSelection( Incidence *incidence ) 3404void CalendarView::processIncidenceSelection( Incidence *incidence )
3405{ 3405{
3406 if ( incidence == mSelectedIncidence ) return; 3406 if ( incidence == mSelectedIncidence ) return;
3407 3407
3408 mSelectedIncidence = incidence; 3408 mSelectedIncidence = incidence;
3409 3409
3410 emit incidenceSelected( mSelectedIncidence ); 3410 emit incidenceSelected( mSelectedIncidence );
3411 3411
3412 if ( incidence && incidence->type() == "Event" ) { 3412 if ( incidence && incidence->type() == "Event" ) {
3413 Event *event = static_cast<Event *>( incidence ); 3413 Event *event = static_cast<Event *>( incidence );
3414 if ( event->organizer() == KOPrefs::instance()->email() ) { 3414 if ( event->organizer() == KOPrefs::instance()->email() ) {
3415 emit organizerEventsSelected( true ); 3415 emit organizerEventsSelected( true );
3416 } else { 3416 } else {
3417 emit organizerEventsSelected(false); 3417 emit organizerEventsSelected(false);
3418 } 3418 }
3419 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3419 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3420 KOPrefs::instance()->email() ) ) { 3420 KOPrefs::instance()->email() ) ) {
3421 emit groupEventsSelected( true ); 3421 emit groupEventsSelected( true );
3422 } else { 3422 } else {
3423 emit groupEventsSelected(false); 3423 emit groupEventsSelected(false);
3424 } 3424 }
3425 return; 3425 return;
3426 } else { 3426 } else {
3427 if ( incidence && incidence->type() == "Todo" ) { 3427 if ( incidence && incidence->type() == "Todo" ) {
3428 emit todoSelected( true ); 3428 emit todoSelected( true );
3429 Todo *event = static_cast<Todo *>( incidence ); 3429 Todo *event = static_cast<Todo *>( incidence );
3430 if ( event->organizer() == KOPrefs::instance()->email() ) { 3430 if ( event->organizer() == KOPrefs::instance()->email() ) {
3431 emit organizerEventsSelected( true ); 3431 emit organizerEventsSelected( true );
3432 } else { 3432 } else {
3433 emit organizerEventsSelected(false); 3433 emit organizerEventsSelected(false);
3434 } 3434 }
3435 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3435 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3436 KOPrefs::instance()->email() ) ) { 3436 KOPrefs::instance()->email() ) ) {
3437 emit groupEventsSelected( true ); 3437 emit groupEventsSelected( true );
3438 } else { 3438 } else {
3439 emit groupEventsSelected(false); 3439 emit groupEventsSelected(false);
3440 } 3440 }
3441 return; 3441 return;
3442 } else { 3442 } else {
3443 emit todoSelected( false ); 3443 emit todoSelected( false );
3444 emit organizerEventsSelected(false); 3444 emit organizerEventsSelected(false);
3445 emit groupEventsSelected(false); 3445 emit groupEventsSelected(false);
3446 } 3446 }
3447 return; 3447 return;
3448 } 3448 }
3449 3449
3450 /* if ( incidence && incidence->type() == "Todo" ) { 3450 /* if ( incidence && incidence->type() == "Todo" ) {
3451 emit todoSelected( true ); 3451 emit todoSelected( true );
3452 } else { 3452 } else {
3453 emit todoSelected( false ); 3453 emit todoSelected( false );
3454 }*/ 3454 }*/
3455} 3455}
3456 3456
3457 3457
3458void CalendarView::checkClipboard() 3458void CalendarView::checkClipboard()
3459{ 3459{
3460#ifndef KORG_NODND 3460#ifndef KORG_NODND
3461 if (ICalDrag::canDecode(QApplication::clipboard()->data())) { 3461 if (ICalDrag::canDecode(QApplication::clipboard()->data())) {
3462 emit pasteEnabled(true); 3462 emit pasteEnabled(true);
3463 } else { 3463 } else {
3464 emit pasteEnabled(false); 3464 emit pasteEnabled(false);
3465 } 3465 }
3466#endif 3466#endif
3467} 3467}
3468 3468
3469void CalendarView::showDates(const DateList &selectedDates) 3469void CalendarView::showDates(const DateList &selectedDates)
3470{ 3470{
3471 // kdDebug() << "CalendarView::selectDates()" << endl; 3471 // kdDebug() << "CalendarView::selectDates()" << endl;
3472 3472
3473 3473
3474 if ( !mBlockShowDates ) { 3474 if ( !mBlockShowDates ) {
3475 if ( mViewManager->currentView() ) { 3475 if ( mViewManager->currentView() ) {
3476 updateView( selectedDates.first(), selectedDates.last() ); 3476 updateView( selectedDates.first(), selectedDates.last() );
3477 } else { 3477 } else {
3478 mViewManager->showAgendaView(); 3478 mViewManager->showAgendaView();
3479 } 3479 }
3480 } 3480 }
3481 3481
3482 QString selDates; 3482 QString selDates;
3483 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); 3483 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true);
3484 if (selectedDates.first() < selectedDates.last() ) 3484 if (selectedDates.first() < selectedDates.last() )
3485 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); 3485 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true);
3486 topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); 3486 topLevelWidget()->setCaption( i18n("Dates: ") + selDates );
3487 3487
3488} 3488}
3489 3489
3490QPtrList<CalFilter> CalendarView::filters() 3490QPtrList<CalFilter> CalendarView::filters()
3491{ 3491{
3492 return mFilters; 3492 return mFilters;
3493 3493
3494} 3494}
3495void CalendarView::editFilters() 3495void CalendarView::editFilters()
3496{ 3496{
3497 // kdDebug() << "CalendarView::editFilters()" << endl; 3497 // kdDebug() << "CalendarView::editFilters()" << endl;
3498 3498
3499 CalFilter *filter = mFilters.first(); 3499 CalFilter *filter = mFilters.first();
3500 while(filter) { 3500 while(filter) {
3501 kdDebug() << " Filter: " << filter->name() << endl; 3501 kdDebug() << " Filter: " << filter->name() << endl;
3502 filter = mFilters.next(); 3502 filter = mFilters.next();
3503 } 3503 }
3504 3504
3505 mDialogManager->showFilterEditDialog(&mFilters); 3505 mDialogManager->showFilterEditDialog(&mFilters);
3506} 3506}
3507void CalendarView::toggleFilter() 3507void CalendarView::toggleFilter()
3508{ 3508{
3509 showFilter(! mFilterView->isVisible()); 3509 showFilter(! mFilterView->isVisible());
3510} 3510}
3511 3511
3512KOFilterView *CalendarView::filterView() 3512KOFilterView *CalendarView::filterView()
3513{ 3513{
3514 return mFilterView; 3514 return mFilterView;
3515} 3515}
3516void CalendarView::selectFilter( int fil ) 3516void CalendarView::selectFilter( int fil )
3517{ 3517{
3518 mFilterView->setSelectedFilter( fil ); 3518 mFilterView->setSelectedFilter( fil );
3519} 3519}
3520void CalendarView::showFilter(bool visible) 3520void CalendarView::showFilter(bool visible)
3521{ 3521{
3522 if (visible) mFilterView->show(); 3522 if (visible) mFilterView->show();
3523 else mFilterView->hide(); 3523 else mFilterView->hide();
3524} 3524}
3525void CalendarView::toggleFilerEnabled( ) 3525void CalendarView::toggleFilerEnabled( )
3526{ 3526{
3527 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); 3527 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() );
3528 if ( !mFilterView->filtersEnabled() ) 3528 if ( !mFilterView->filtersEnabled() )
3529 topLevelWidget()->setCaption( i18n("Filter disabled ") ); 3529 topLevelWidget()->setCaption( i18n("Filter disabled ") );
3530 3530
3531} 3531}
3532void CalendarView::updateFilter() 3532void CalendarView::updateFilter()
3533{ 3533{
3534 CalFilter *filter = mFilterView->selectedFilter(); 3534 CalFilter *filter = mFilterView->selectedFilter();
3535 if (filter) { 3535 if (filter) {
3536 if (mFilterView->filtersEnabled()) { 3536 if (mFilterView->filtersEnabled()) {
3537 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); 3537 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() );
3538 filter->setEnabled(true); 3538 filter->setEnabled(true);
3539 } 3539 }
3540 else filter->setEnabled(false); 3540 else filter->setEnabled(false);
3541 mCalendar->setFilter(filter); 3541 mCalendar->setFilter(filter);
3542 updateView(); 3542 updateView();
3543 } 3543 }
3544} 3544}
3545 3545
3546void CalendarView::filterEdited() 3546void CalendarView::filterEdited()
3547{ 3547{
3548 mFilterView->updateFilters(); 3548 mFilterView->updateFilters();
3549 updateFilter(); 3549 updateFilter();
3550 writeSettings(); 3550 writeSettings();
3551} 3551}
3552 3552
3553 3553
3554void CalendarView::takeOverEvent() 3554void CalendarView::takeOverEvent()
3555{ 3555{
3556 Incidence *incidence = currentSelection(); 3556 Incidence *incidence = currentSelection();
3557 3557
3558 if (!incidence) return; 3558 if (!incidence) return;
3559 3559
3560 incidence->setOrganizer(KOPrefs::instance()->email()); 3560 incidence->setOrganizer(KOPrefs::instance()->email());
3561 incidence->recreate(); 3561 incidence->recreate();
3562 incidence->setReadOnly(false); 3562 incidence->setReadOnly(false);
3563 3563
3564 updateView(); 3564 updateView();
3565} 3565}
3566 3566
3567void CalendarView::takeOverCalendar() 3567void CalendarView::takeOverCalendar()
3568{ 3568{
3569 // TODO: Create Calendar::allIncidences() function and use it here 3569 // TODO: Create Calendar::allIncidences() function and use it here
3570 3570
3571 QPtrList<Event> events = mCalendar->events(); 3571 QPtrList<Event> events = mCalendar->events();
3572 for(uint i=0; i<events.count(); ++i) { 3572 for(uint i=0; i<events.count(); ++i) {
3573 events.at(i)->setOrganizer(KOPrefs::instance()->email()); 3573 events.at(i)->setOrganizer(KOPrefs::instance()->email());
3574 events.at(i)->recreate(); 3574 events.at(i)->recreate();
3575 events.at(i)->setReadOnly(false); 3575 events.at(i)->setReadOnly(false);
3576 } 3576 }
3577 3577
3578 QPtrList<Todo> todos = mCalendar->todos(); 3578 QPtrList<Todo> todos = mCalendar->todos();
3579 for(uint i=0; i<todos.count(); ++i) { 3579 for(uint i=0; i<todos.count(); ++i) {
3580 todos.at(i)->setOrganizer(KOPrefs::instance()->email()); 3580 todos.at(i)->setOrganizer(KOPrefs::instance()->email());
3581 todos.at(i)->recreate(); 3581 todos.at(i)->recreate();
3582 todos.at(i)->setReadOnly(false); 3582 todos.at(i)->setReadOnly(false);
3583 } 3583 }
3584 3584
3585 QPtrList<Journal> journals = mCalendar->journals(); 3585 QPtrList<Journal> journals = mCalendar->journals();
3586 for(uint i=0; i<journals.count(); ++i) { 3586 for(uint i=0; i<journals.count(); ++i) {
3587 journals.at(i)->setOrganizer(KOPrefs::instance()->email()); 3587 journals.at(i)->setOrganizer(KOPrefs::instance()->email());
3588 journals.at(i)->recreate(); 3588 journals.at(i)->recreate();
3589 journals.at(i)->setReadOnly(false); 3589 journals.at(i)->setReadOnly(false);
3590 } 3590 }
3591 3591
3592 updateView(); 3592 updateView();
3593} 3593}
3594 3594
3595void CalendarView::showIntro() 3595void CalendarView::showIntro()
3596{ 3596{
3597 kdDebug() << "To be implemented." << endl; 3597 kdDebug() << "To be implemented." << endl;
3598} 3598}
3599 3599
3600QWidgetStack *CalendarView::viewStack() 3600QWidgetStack *CalendarView::viewStack()
3601{ 3601{
3602 return mRightFrame; 3602 return mRightFrame;
3603} 3603}
3604 3604
3605QWidget *CalendarView::leftFrame() 3605QWidget *CalendarView::leftFrame()
3606{ 3606{
3607 return mLeftFrame; 3607 return mLeftFrame;
3608} 3608}
3609 3609
3610DateNavigator *CalendarView::dateNavigator() 3610DateNavigator *CalendarView::dateNavigator()
3611{ 3611{
3612 return mNavigator; 3612 return mNavigator;
3613} 3613}
3614 3614
3615KDateNavigator* CalendarView::dateNavigatorWidget() 3615KDateNavigator* CalendarView::dateNavigatorWidget()
3616{ 3616{
3617 return mDateNavigator; 3617 return mDateNavigator;
3618} 3618}
3619void CalendarView::toggleDateNavigatorWidget() 3619void CalendarView::toggleDateNavigatorWidget()
3620{ 3620{
3621 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; 3621 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ;
3622 if (!KOPrefs::instance()->mShowDateNavigator ) 3622 if (!KOPrefs::instance()->mShowDateNavigator )
3623 mDateNavigator->hide(); 3623 mDateNavigator->hide();
3624 else 3624 else
3625 mDateNavigator->show(); 3625 mDateNavigator->show();
3626} 3626}
3627void CalendarView::addView(KOrg::BaseView *view) 3627void CalendarView::addView(KOrg::BaseView *view)
3628{ 3628{
3629 mViewManager->addView(view); 3629 mViewManager->addView(view);
3630} 3630}
3631 3631
3632void CalendarView::showView(KOrg::BaseView *view) 3632void CalendarView::showView(KOrg::BaseView *view)
3633{ 3633{
3634 mViewManager->showView(view, mLeftFrame->isVisible()); 3634 mViewManager->showView(view, mLeftFrame->isVisible());
3635} 3635}
3636 3636
3637Incidence *CalendarView::currentSelection() 3637Incidence *CalendarView::currentSelection()
3638{ 3638{
3639 return mViewManager->currentSelection(); 3639 return mViewManager->currentSelection();
3640} 3640}
3641void CalendarView::toggleAllDaySize() 3641void CalendarView::toggleAllDaySize()
3642{ 3642{
3643 /* 3643 /*
3644 if ( KOPrefs::instance()->mAllDaySize > 47 ) 3644 if ( KOPrefs::instance()->mAllDaySize > 47 )
3645 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; 3645 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2;
3646 else 3646 else
3647 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; 3647 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2;
3648 */ 3648 */
3649 viewManager()->agendaView()->toggleAllDay(); 3649 viewManager()->agendaView()->toggleAllDay();
3650} 3650}
3651void CalendarView::toggleExpand() 3651void CalendarView::toggleExpand()
3652{ 3652{
3653 // if ( mLeftFrame->isHidden() ) { 3653 // if ( mLeftFrame->isHidden() ) {
3654 // mLeftFrame->show(); 3654 // mLeftFrame->show();
3655 // emit calendarViewExpanded( false ); 3655 // emit calendarViewExpanded( false );
3656 // } else { 3656 // } else {
3657 // mLeftFrame->hide(); 3657 // mLeftFrame->hide();
3658 // emit calendarViewExpanded( true ); 3658 // emit calendarViewExpanded( true );
3659 // } 3659 // }
3660 3660
3661 globalFlagBlockAgenda = 1; 3661 globalFlagBlockAgenda = 1;
3662 emit calendarViewExpanded( !mLeftFrame->isHidden() ); 3662 emit calendarViewExpanded( !mLeftFrame->isHidden() );
3663 globalFlagBlockAgenda = 5; 3663 globalFlagBlockAgenda = 5;
3664 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); 3664 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() );
3665 //mViewManager->showView( 0, true ); 3665 //mViewManager->showView( 0, true );
3666} 3666}
3667 3667
3668void CalendarView::calendarModified( bool modified, Calendar * ) 3668void CalendarView::calendarModified( bool modified, Calendar * )
3669{ 3669{
3670 setModified( modified ); 3670 setModified( modified );
3671} 3671}
3672 3672
3673Todo *CalendarView::selectedTodo() 3673Todo *CalendarView::selectedTodo()
3674{ 3674{
3675 Incidence *incidence = currentSelection(); 3675 Incidence *incidence = currentSelection();
3676 if ( incidence && incidence->type() == "Todo" ) { 3676 if ( incidence && incidence->type() == "Todo" ) {
3677 return static_cast<Todo *>( incidence ); 3677 return static_cast<Todo *>( incidence );
3678 } 3678 }
3679 3679
3680 incidence = mTodoList->selectedIncidences().first(); 3680 incidence = mTodoList->selectedIncidences().first();
3681 if ( incidence && incidence->type() == "Todo" ) { 3681 if ( incidence && incidence->type() == "Todo" ) {
3682 return static_cast<Todo *>( incidence ); 3682 return static_cast<Todo *>( incidence );
3683 } 3683 }
3684 3684
3685 return 0; 3685 return 0;
3686} 3686}
3687 3687
3688void CalendarView::dialogClosing(Incidence *in) 3688void CalendarView::dialogClosing(Incidence *in)
3689{ 3689{
3690 // mDialogList.remove(in); 3690 // mDialogList.remove(in);
3691} 3691}
3692 3692
3693void CalendarView::showIncidence() 3693void CalendarView::showIncidence()
3694{ 3694{
3695 Incidence *incidence = currentSelection(); 3695 Incidence *incidence = currentSelection();
3696 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3696 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3697 if ( incidence ) { 3697 if ( incidence ) {
3698 ShowIncidenceVisitor v; 3698 ShowIncidenceVisitor v;
3699 v.act( incidence, this ); 3699 v.act( incidence, this );
3700 } 3700 }
3701} 3701}
3702void CalendarView::editIncidenceDescription() 3702void CalendarView::editIncidenceDescription()
3703{ 3703{
3704 mFlagEditDescription = true; 3704 mFlagEditDescription = true;
3705 editIncidence(); 3705 editIncidence();
3706 mFlagEditDescription = false; 3706 mFlagEditDescription = false;
3707} 3707}
3708void CalendarView::editIncidence() 3708void CalendarView::editIncidence()
3709{ 3709{
3710 // qDebug("editIncidence() "); 3710 // qDebug("editIncidence() ");
3711 Incidence *incidence = currentSelection(); 3711 Incidence *incidence = currentSelection();
3712 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3712 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3713 if ( incidence ) { 3713 if ( incidence ) {
3714 EditIncidenceVisitor v; 3714 EditIncidenceVisitor v;
3715 v.act( incidence, this ); 3715 v.act( incidence, this );
3716 } 3716 }
3717} 3717}
3718 3718
3719void CalendarView::deleteIncidence() 3719void CalendarView::deleteIncidence()
3720{ 3720{
3721 Incidence *incidence = currentSelection(); 3721 Incidence *incidence = currentSelection();
3722 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3722 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3723 if ( incidence ) { 3723 if ( incidence ) {
3724 deleteIncidence(incidence); 3724 deleteIncidence(incidence);
3725 } 3725 }
3726} 3726}
3727 3727
3728void CalendarView::showIncidence(Incidence *incidence) 3728void CalendarView::showIncidence(Incidence *incidence)
3729{ 3729{
3730 if ( incidence ) { 3730 if ( incidence ) {
3731 ShowIncidenceVisitor v; 3731 ShowIncidenceVisitor v;
3732 v.act( incidence, this ); 3732 v.act( incidence, this );
3733 } 3733 }
3734} 3734}
3735 3735
3736void CalendarView::editIncidence(Incidence *incidence) 3736void CalendarView::editIncidence(Incidence *incidence)
3737{ 3737{
3738 if ( incidence ) { 3738 if ( incidence ) {
3739 3739
3740 EditIncidenceVisitor v; 3740 EditIncidenceVisitor v;
3741 v.act( incidence, this ); 3741 v.act( incidence, this );
3742 3742
3743 } 3743 }
3744} 3744}
3745 3745
3746void CalendarView::deleteIncidence(Incidence *incidence) 3746void CalendarView::deleteIncidence(Incidence *incidence)
3747{ 3747{
3748 //qDebug(" CalendarView::deleteIncidence "); 3748 //qDebug(" CalendarView::deleteIncidence ");
3749 if ( incidence ) { 3749 if ( incidence ) {
3750 DeleteIncidenceVisitor v; 3750 DeleteIncidenceVisitor v;
3751 v.act( incidence, this ); 3751 v.act( incidence, this );
3752 } 3752 }
3753} 3753}
3754 3754
3755 3755
3756void CalendarView::lookForOutgoingMessages() 3756void CalendarView::lookForOutgoingMessages()
3757{ 3757{
3758 OutgoingDialog *ogd = mDialogManager->outgoingDialog(); 3758 OutgoingDialog *ogd = mDialogManager->outgoingDialog();
3759 ogd->loadMessages(); 3759 ogd->loadMessages();
3760} 3760}
3761 3761
3762void CalendarView::lookForIncomingMessages() 3762void CalendarView::lookForIncomingMessages()
3763{ 3763{
3764 IncomingDialog *icd = mDialogManager->incomingDialog(); 3764 IncomingDialog *icd = mDialogManager->incomingDialog();
3765 icd->retrieve(); 3765 icd->retrieve();
3766} 3766}
3767 3767
3768bool CalendarView::removeCompletedSubTodos( Todo* t ) 3768bool CalendarView::removeCompletedSubTodos( Todo* t )
3769{ 3769{
3770 bool deleteTodo = true; 3770 bool deleteTodo = true;
3771 QPtrList<Incidence> subTodos; 3771 QPtrList<Incidence> subTodos;
3772 Incidence *aTodo; 3772 Incidence *aTodo;
3773 subTodos = t->relations(); 3773 subTodos = t->relations();
3774 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { 3774 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
3775 if (! removeCompletedSubTodos( (Todo*) aTodo )) 3775 if (! removeCompletedSubTodos( (Todo*) aTodo ))
3776 deleteTodo = false; 3776 deleteTodo = false;
3777 } 3777 }
3778 if ( deleteTodo ) { 3778 if ( deleteTodo ) {
3779 if ( t->isCompleted() ) { 3779 if ( t->isCompleted() ) {
3780 checkExternalId( t ); 3780 checkExternalId( t );
3781 mCalendar->deleteTodo( t ); 3781 mCalendar->deleteTodo( t );
3782 changeTodoDisplay( t,KOGlobals::EVENTDELETED ); 3782 changeTodoDisplay( t,KOGlobals::EVENTDELETED );
3783 } 3783 }
3784 else 3784 else
3785 deleteTodo = false; 3785 deleteTodo = false;
3786 } 3786 }
3787 return deleteTodo; 3787 return deleteTodo;
3788 3788
3789} 3789}
3790void CalendarView::purgeCompleted() 3790void CalendarView::purgeCompleted()
3791{ 3791{
3792 int result = KMessageBox::warningContinueCancel(this, 3792 int result = KMessageBox::warningContinueCancel(this,
3793 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"));
3794 3794
3795 if (result == KMessageBox::Continue) { 3795 if (result == KMessageBox::Continue) {
3796 3796
3797 QPtrList<Todo> todoCal; 3797 QPtrList<Todo> todoCal;
3798 QPtrList<Todo> rootTodos; 3798 QPtrList<Todo> rootTodos;
3799 //QPtrList<Incidence> rel; 3799 //QPtrList<Incidence> rel;
3800 Todo *aTodo;//, *rTodo; 3800 Todo *aTodo;//, *rTodo;
3801 Incidence *rIncidence; 3801 Incidence *rIncidence;
3802 bool childDelete = false; 3802 bool childDelete = false;
3803 bool deletedOne = true; 3803 bool deletedOne = true;
3804 todoCal = calendar()->todos(); 3804 todoCal = calendar()->todos();
3805 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { 3805 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
3806 if ( !aTodo->relatedTo() ) 3806 if ( !aTodo->relatedTo() )
3807 rootTodos.append( aTodo ); 3807 rootTodos.append( aTodo );
3808 } 3808 }
3809 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { 3809 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) {
3810 removeCompletedSubTodos( aTodo ); 3810 removeCompletedSubTodos( aTodo );
3811 } 3811 }
3812 3812
3813 updateView(); 3813 updateView();
3814 } 3814 }
3815} 3815}
3816 3816
3817void CalendarView::slotCalendarChanged() 3817void CalendarView::slotCalendarChanged()
3818{ 3818{
3819 ; 3819 ;
3820} 3820}
3821 3821
3822NavigatorBar *CalendarView::navigatorBar() 3822NavigatorBar *CalendarView::navigatorBar()
3823{ 3823{
3824 return mNavigatorBar; 3824 return mNavigatorBar;
3825} 3825}
3826 3826
3827 3827
3828 3828
3829void CalendarView::keyPressEvent ( QKeyEvent *e) 3829void CalendarView::keyPressEvent ( QKeyEvent *e)
3830{ 3830{
3831 //qDebug(" alendarView::keyPressEvent "); 3831 //qDebug(" alendarView::keyPressEvent ");
3832 e->ignore(); 3832 e->ignore();
3833} 3833}
3834 3834
3835 3835
3836bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) 3836bool CalendarView::sync(KSyncManager* manager, QString filename, int mode)
3837{ 3837{
3838 // mSyncManager = manager; 3838 // mSyncManager = manager;
3839 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { 3839 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) {
3840 qDebug("SyncKDE request detected!"); 3840 qDebug("SyncKDE request detected!");
3841 } 3841 }
3842 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 3842 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
3843 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 3843 mCurrentSyncName = mSyncManager->getCurrentSyncName();
3844 return syncCalendar( filename, mode ); 3844 return syncCalendar( filename, mode );
3845} 3845}
3846bool CalendarView::syncExternal(KSyncManager* manager, QString resource) 3846bool CalendarView::syncExternal(KSyncManager* manager, QString resource)
3847{ 3847{
3848 //mSyncManager = manager; 3848 //mSyncManager = manager;
3849 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 3849 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
3850 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 3850 mCurrentSyncName = mSyncManager->getCurrentSyncName();
3851 if ( resource == "sharp" ) 3851 if ( resource == "sharp" )
3852 syncExternal( 0 ); 3852 syncExternal( 0 );
3853 if ( resource == "phone" ) 3853 if ( resource == "phone" )
3854 syncExternal( 1 ); 3854 syncExternal( 1 );
3855 // pending setmodified 3855 // pending setmodified
3856 return true; 3856 return true;
3857} 3857}
3858void CalendarView::setSyncManager(KSyncManager* manager) 3858void CalendarView::setSyncManager(KSyncManager* manager)
3859{ 3859{
3860 mSyncManager = manager; 3860 mSyncManager = manager;
3861} 3861}
3862 3862
3863void CalendarView::removeSyncInfo( QString syncProfile) 3863void CalendarView::removeSyncInfo( QString syncProfile)
3864{ 3864{
3865 qDebug("removeSyncInfo for profile %s ", syncProfile.latin1()); 3865 qDebug("removeSyncInfo for profile %s ", syncProfile.latin1());
3866 mCalendar->removeSyncInfo( syncProfile ); 3866 mCalendar->removeSyncInfo( syncProfile );
3867 3867
3868} 3868}
3869 3869
3870void CalendarView::undo_delete() 3870void CalendarView::undo_delete()
3871{ 3871{
3872 //qDebug("undo_delete() "); 3872 //qDebug("undo_delete() ");
3873 Incidence* undo = mCalendar->undoIncidence(); 3873 Incidence* undo = mCalendar->undoIncidence();
3874 if ( !undo ) { 3874 if ( !undo ) {
3875 KMessageBox::sorry(this,i18n("There is nothing to undo!"), 3875 KMessageBox::sorry(this,i18n("There is nothing to undo!"),
3876 i18n("KO/Pi")); 3876 i18n("KO/Pi"));
3877 return; 3877 return;
3878 } 3878 }
3879 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + 3879 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) +
3880 i18n("\nAre you sure you want\nto restore this?"), 3880 i18n("\nAre you sure you want\nto restore this?"),
3881 i18n("KO/Pi Confirmation"),i18n("Restore"))) { 3881 i18n("KO/Pi Confirmation"),i18n("Restore"))) {
3882 mCalendar->undoDeleteIncidence(); 3882 mCalendar->undoDeleteIncidence();
3883 updateView(); 3883 updateView();
3884 } 3884 }
3885} 3885}
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 842f6eb..b819eec 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -1,1115 +1,1125 @@
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, WRepaintNoErase)
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 mWT = new KNOWhatsThis(this); 82 mWT = new KNOWhatsThis(this);
83} 83}
84KNoScrollListBox::~KNoScrollListBox() 84KNoScrollListBox::~KNoScrollListBox()
85{ 85{
86 delete mWT; 86 delete mWT;
87} 87}
88QString KNoScrollListBox::getWhatsThisText(QPoint p) 88QString KNoScrollListBox::getWhatsThisText(QPoint p)
89{ 89{
90 QListBoxItem* item = itemAt ( p ); 90 QListBoxItem* item = itemAt ( p );
91 if ( ! item ) { 91 if ( ! item ) {
92 return i18n("Click in the cell\nto add an event!"); 92 return i18n("Click in the cell\nto add an event!");
93 } 93 }
94 return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence()); 94 return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence());
95} 95}
96void KNoScrollListBox::keyPressEvent(QKeyEvent *e) 96void KNoScrollListBox::keyPressEvent(QKeyEvent *e)
97{ 97{
98 98
99 switch(e->key()) { 99 switch(e->key()) {
100 case Key_Right: 100 case Key_Right:
101 // if ( e->state() == Qt::ControlButton ) 101 // if ( e->state() == Qt::ControlButton )
102 { 102 {
103 e->ignore(); 103 e->ignore();
104 return; 104 return;
105 } 105 }
106 scrollBy(4,0); 106 scrollBy(4,0);
107 break; 107 break;
108 case Key_Left: 108 case Key_Left:
109 // if ( e->state() == Qt::ControlButton ) 109 // if ( e->state() == Qt::ControlButton )
110 { 110 {
111 e->ignore(); 111 e->ignore();
112 return; 112 return;
113 } 113 }
114 scrollBy(-4,0); 114 scrollBy(-4,0);
115 break; 115 break;
116 case Key_Up: 116 case Key_Up:
117 if(!count()) break; 117 if(!count()) break;
118 setCurrentItem((currentItem()+count()-1)%count()); 118 setCurrentItem((currentItem()+count()-1)%count());
119 if(!itemVisible(currentItem())) { 119 if(!itemVisible(currentItem())) {
120 if((unsigned int) currentItem() == (count()-1)) { 120 if((unsigned int) currentItem() == (count()-1)) {
121 setTopItem(currentItem()-numItemsVisible()+1); 121 setTopItem(currentItem()-numItemsVisible()+1);
122 } else { 122 } else {
123 setTopItem(topItem()-1); 123 setTopItem(topItem()-1);
124 } 124 }
125 } 125 }
126 break; 126 break;
127 case Key_Down: 127 case Key_Down:
128 if(!count()) break; 128 if(!count()) break;
129 setCurrentItem((currentItem()+1)%count()); 129 setCurrentItem((currentItem()+1)%count());
130 if(!itemVisible(currentItem())) { 130 if(!itemVisible(currentItem())) {
131 if(currentItem() == 0) { 131 if(currentItem() == 0) {
132 setTopItem(0); 132 setTopItem(0);
133 } else { 133 } else {
134 setTopItem(topItem()+1); 134 setTopItem(topItem()+1);
135 } 135 }
136 } 136 }
137 break; 137 break;
138 case Key_Shift: 138 case Key_Shift:
139 emit shiftDown(); 139 emit shiftDown();
140 break; 140 break;
141 default: 141 default:
142 e->ignore(); 142 e->ignore();
143 break; 143 break;
144 } 144 }
145} 145}
146 146
147void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) 147void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e)
148{ 148{
149 switch(e->key()) { 149 switch(e->key()) {
150 case Key_Shift: 150 case Key_Shift:
151 emit shiftUp(); 151 emit shiftUp();
152 break; 152 break;
153 default: 153 default:
154 break; 154 break;
155 } 155 }
156} 156}
157 157
158void KNoScrollListBox::mousePressEvent(QMouseEvent *e) 158void KNoScrollListBox::mousePressEvent(QMouseEvent *e)
159{ 159{
160 QListBox::mousePressEvent(e); 160 QListBox::mousePressEvent(e);
161 161
162 if(e->button() == RightButton) { 162 if(e->button() == RightButton) {
163 emit rightClick(); 163 emit rightClick();
164 } 164 }
165} 165}
166 166
167MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) 167MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s)
168 : QListBoxItem() 168 : QListBoxItem()
169{ 169{
170 setText( s ); 170 setText( s );
171 171
172 mIncidence = incidence; 172 mIncidence = incidence;
173 mDate = qd; 173 mDate = qd;
174 // QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence )); 174 // QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence ));
175 mRecur = false; 175 mRecur = false;
176 mAlarm = false; 176 mAlarm = false;
177 mReply = false; 177 mReply = false;
178 mInfo = false; 178 mInfo = false;
179} 179}
180 180
181void MonthViewItem::paint(QPainter *p) 181void MonthViewItem::paint(QPainter *p)
182{ 182{
183#if QT_VERSION >= 0x030000 183#if QT_VERSION >= 0x030000
184 bool sel = isSelected(); 184 bool sel = isSelected();
185#else 185#else
186 bool sel = selected(); 186 bool sel = selected();
187#endif 187#endif
188 188
189 189
190 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) 190 if (KOPrefs::instance()->mMonthViewUsesCategoryColor)
191 { 191 {
192 p->setBackgroundColor( palette().color( QPalette::Normal, \ 192 p->setBackgroundColor( palette().color( QPalette::Normal, \
193 sel ? QColorGroup::Highlight : QColorGroup::Background ) ); 193 sel ? QColorGroup::Highlight : QColorGroup::Background ) );
194 p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); 194 p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) );
195 } 195 }
196 int x = 1; 196 int x = 1;
197 int y = 3;//(height() - mRecurPixmap.height()) /2; 197 int y = 3;//(height() - mRecurPixmap.height()) /2;
198 int size = PIXMAP_SIZE; 198 int size = PIXMAP_SIZE;
199 if ( QApplication::desktop()->width() < 300 ) 199 if ( QApplication::desktop()->width() < 300 )
200 size = 3; 200 size = 3;
201 if ( KOPrefs::instance()->mMonthShowIcons ) { 201 if ( KOPrefs::instance()->mMonthShowIcons ) {
202 if ( mInfo ) { 202 if ( mInfo ) {
203 p->fillRect ( x, y,size,size, Qt::darkGreen ); 203 p->fillRect ( x, y,size,size, Qt::darkGreen );
204 x += size + 1; 204 x += size + 1;
205 } 205 }
206 if ( mRecur ) { 206 if ( mRecur ) {
207 p->fillRect ( x, y,size,size, Qt::blue ); 207 p->fillRect ( x, y,size,size, Qt::blue );
208 x += size + 1; 208 x += size + 1;
209 } 209 }
210 if ( mAlarm ) { 210 if ( mAlarm ) {
211 p->fillRect ( x, y,size,size, Qt::red ); 211 p->fillRect ( x, y,size,size, Qt::red );
212 x += size + 1; 212 x += size + 1;
213 } 213 }
214 if ( mReply ) { 214 if ( mReply ) {
215 p->fillRect ( x, y,size,size, Qt::yellow ); 215 p->fillRect ( x, y,size,size, Qt::yellow );
216 x += size + 1; 216 x += size + 1;
217 } 217 }
218 } 218 }
219 QFontMetrics fm = p->fontMetrics(); 219 QFontMetrics fm = p->fontMetrics();
220 int yPos; 220 int yPos;
221 int pmheight = size; 221 int pmheight = size;
222 if( pmheight < fm.height() ) 222 if( pmheight < fm.height() )
223 yPos = fm.ascent() + fm.leading()/2; 223 yPos = fm.ascent() + fm.leading()/2;
224 else 224 else
225 yPos = pmheight/2 - fm.height()/2 + fm.ascent(); 225 yPos = pmheight/2 - fm.height()/2 + fm.ascent();
226 p->setPen( palette().color( QPalette::Normal, sel ? \ 226 p->setPen( palette().color( QPalette::Normal, sel ? \
227 QColorGroup::HighlightedText : QColorGroup::Foreground ) ); 227 QColorGroup::HighlightedText : QColorGroup::Foreground ) );
228 p->drawText( x, yPos, text() ); 228 p->drawText( x, yPos, text() );
229 if ( mIncidence->cancelled() ) { 229 if ( mIncidence->cancelled() ) {
230 int wid = fm.width( text() ); 230 int wid = fm.width( text() );
231 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);
232 } 232 }
233 233
234} 234}
235 235
236int MonthViewItem::height(const QListBox *lb) const 236int MonthViewItem::height(const QListBox *lb) const
237{ 237{
238 return lb->fontMetrics().lineSpacing()+1; 238 return lb->fontMetrics().lineSpacing()+1;
239} 239}
240 240
241int MonthViewItem::width(const QListBox *lb) const 241int MonthViewItem::width(const QListBox *lb) const
242{ 242{
243 int size = PIXMAP_SIZE; 243 int size = PIXMAP_SIZE;
244 if ( QApplication::desktop()->width() < 300 ) 244 if ( QApplication::desktop()->width() < 300 )
245 size = 3; 245 size = 3;
246 int x = 1; 246 int x = 1;
247 if ( mInfo ) { 247 if ( mInfo ) {
248 x += size + 1; 248 x += size + 1;
249 } 249 }
250 if( mRecur ) { 250 if( mRecur ) {
251 x += size+1; 251 x += size+1;
252 } 252 }
253 if( mAlarm ) { 253 if( mAlarm ) {
254 x += size+1; 254 x += size+1;
255 } 255 }
256 if( mReply ) { 256 if( mReply ) {
257 x += size+1; 257 x += size+1;
258 } 258 }
259 259
260 return( x + lb->fontMetrics().width( text() ) + 1 ); 260 return( x + lb->fontMetrics().width( text() ) + 1 );
261} 261}
262 262
263 263
264MonthViewCell::MonthViewCell( KOMonthView *parent) 264MonthViewCell::MonthViewCell( KOMonthView *parent)
265 : QWidget( parent ), 265 : QWidget( parent ),
266 mMonthView( parent ) 266 mMonthView( parent )
267{ 267{
268 268
269 QVBoxLayout *topLayout = new QVBoxLayout( this ); 269 QVBoxLayout *topLayout = new QVBoxLayout( this );
270 270
271 // mLabel = new QLabel( this );QPushButton 271 // mLabel = new QLabel( this );QPushButton
272 mLabel = new QPushButton( this ); 272 mLabel = new QPushButton( this );
273 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); 273 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain );
274 //mLabel->setLineWidth( 1 ); 274 //mLabel->setLineWidth( 1 );
275 //mLabel->setAlignment( AlignCenter ); 275 //mLabel->setAlignment( AlignCenter );
276 mLabel->setFlat( true ); 276 mLabel->setFlat( true );
277 mItemList = new KNoScrollListBox( this ); 277 mItemList = new KNoScrollListBox( this );
278 mItemList->setMinimumSize( 10, 10 ); 278 mItemList->setMinimumSize( 10, 10 );
279 mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain ); 279 mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain );
280 mItemList->setLineWidth( 1 ); 280 mItemList->setLineWidth( 1 );
281 topLayout->addWidget( mItemList ); 281 topLayout->addWidget( mItemList );
282 mLabel->raise(); 282 mLabel->raise();
283 // QColor( 0,0,255 ) QColor( 160,1600,255 ) 283 // QColor( 0,0,255 ) QColor( 160,1600,255 )
284 mStandardPalette = palette(); 284 mStandardPalette = palette();
285 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); 285 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) );
286 286
287 enableScrollBars( false ); 287 enableScrollBars( false );
288 updateConfig(); 288 updateConfig();
289 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); 289 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() ));
290 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); 290 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() ));
291 connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ), 291 connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ),
292 SLOT( defaultAction( QListBoxItem * ) ) ); 292 SLOT( defaultAction( QListBoxItem * ) ) );
293 connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *, 293 connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *,
294 const QPoint &) ), 294 const QPoint &) ),
295 SLOT( contextMenu( QListBoxItem * ) ) ); 295 SLOT( contextMenu( QListBoxItem * ) ) );
296 connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ), 296 connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ),
297 SLOT( selection( QListBoxItem * ) ) ); 297 SLOT( selection( QListBoxItem * ) ) );
298 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), 298 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ),
299 SLOT( cellClicked( QListBoxItem * ) ) ); 299 SLOT( cellClicked( QListBoxItem * ) ) );
300 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), 300 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ),
301 SLOT( selection( QListBoxItem * ) ) ); 301 SLOT( selection( QListBoxItem * ) ) );
302} 302}
303#ifdef DESKTOP_VERSION 303#ifdef DESKTOP_VERSION
304QToolTipGroup *MonthViewCell::toolTipGroup() 304QToolTipGroup *MonthViewCell::toolTipGroup()
305{ 305{
306 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); 306 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0);
307 return mToolTipGroup; 307 return mToolTipGroup;
308} 308}
309#endif 309#endif
310 310
311void MonthViewCell::setDate( const QDate &date ) 311void MonthViewCell::setDate( const QDate &date )
312{ 312{
313// kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; 313// kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl;
314 mDate = date; 314 mDate = date;
315 315
316 316
317 317
318 //resizeEvent( 0 ); 318 //resizeEvent( 0 );
319} 319}
320 320
321QDate MonthViewCell::date() const 321QDate MonthViewCell::date() const
322{ 322{
323 return mDate; 323 return mDate;
324} 324}
325 325
326void MonthViewCell::setPrimary( bool primary ) 326void MonthViewCell::setPrimary( bool primary )
327{ 327{
328 mPrimary = primary; 328 mPrimary = primary;
329 //setMyPalette(); 329 //setMyPalette();
330} 330}
331void MonthViewCell::setMyPalette() 331void MonthViewCell::setMyPalette()
332{ 332{
333 333
334 if ( mHoliday) { 334 if ( mHoliday) {
335 setPalette( mHolidayPalette ); 335 setPalette( mHolidayPalette );
336 } else { 336 } else {
337 if ( mPrimary ) { 337 if ( mPrimary ) {
338 setPalette( mPrimaryPalette ); 338 setPalette( mPrimaryPalette );
339 } else { 339 } else {
340 setPalette( mNonPrimaryPalette ); 340 setPalette( mNonPrimaryPalette );
341 } 341 }
342 } 342 }
343 QPalette pal = palette(); 343 QPalette pal = palette();
344 344
345 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 ) ));
346} 346}
347QPalette MonthViewCell::getPalette () 347QPalette MonthViewCell::getPalette ()
348{ 348{
349 if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) 349 if ( !KOPrefs::instance()->mMonthViewUsesDayColors )
350 return mStandardPalette; 350 return mStandardPalette;
351 if ( mHoliday) { 351 if ( mHoliday) {
352 return mHolidayPalette ; 352 return mHolidayPalette ;
353 } else { 353 } else {
354 if ( mPrimary ) { 354 if ( mPrimary ) {
355 return mPrimaryPalette ; 355 return mPrimaryPalette ;
356 } 356 }
357 } 357 }
358 return mNonPrimaryPalette; 358 return mNonPrimaryPalette;
359} 359}
360bool MonthViewCell::isPrimary() const 360bool MonthViewCell::isPrimary() const
361{ 361{
362 return mPrimary; 362 return mPrimary;
363} 363}
364 364
365void MonthViewCell::setHoliday( bool holiday ) 365void MonthViewCell::setHoliday( bool holiday )
366{ 366{
367 mHoliday = holiday; 367 mHoliday = holiday;
368 //setMyPalette(); 368 //setMyPalette();
369} 369}
370 370
371void MonthViewCell::setHoliday( const QString &holiday ) 371void MonthViewCell::setHoliday( const QString &holiday )
372{ 372{
373 mHolidayString = holiday; 373 mHolidayString = holiday;
374 374
375 if ( !holiday.isEmpty() ) { 375 if ( !holiday.isEmpty() ) {
376 setHoliday( true ); 376 setHoliday( true );
377 } 377 }
378} 378}
379void MonthViewCell::keyPressEvent ( QKeyEvent * e ) 379void MonthViewCell::keyPressEvent ( QKeyEvent * e )
380{ 380{
381 381
382 e->ignore(); 382 e->ignore();
383 383
384} 384}
385void MonthViewCell::clear()
386{
387 mItemList->clear();
388 QApplication::removePostedEvents ( mItemList );
389 QApplication::removePostedEvents ( mLabel );
390 QApplication::removePostedEvents ( this );
391}
385void MonthViewCell::updateCell() 392void MonthViewCell::updateCell()
386{ 393{
387 if ( !mMonthView->isUpdatePossible() ) 394 if ( !mMonthView->isUpdatePossible() )
388 return; 395 return;
389 if ( !isVisible() ){ 396 /*
397 if ( !isVisible() ){
390 return; 398 return;
391 } 399 }
400 */
401 // qDebug("MonthViewCell::updateCell() ");
392 setPrimary( mDate.month()%2 ); 402 setPrimary( mDate.month()%2 );
393 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); 403 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays);
394 if ( mDate == QDate::currentDate() ) { 404 if ( mDate == QDate::currentDate() ) {
395 mItemList->setLineWidth( 3 ); 405 mItemList->setLineWidth( 3 );
396 } else { 406 } else {
397 mItemList->setLineWidth( 1 ); 407 mItemList->setLineWidth( 1 );
398 } 408 }
399 mItemList->clear(); 409 mItemList->clear();
400 410
401
402
403#ifdef DESKTOP_VERSION 411#ifdef DESKTOP_VERSION
404 QToolTip::remove(this); 412 QToolTip::remove(this);
405#endif 413#endif
406 QString tipText(""); 414 QString tipText("");
407 //qApp->processEvents(); 415 //qApp->processEvents();
408 if ( !mHolidayString.isEmpty() ) { 416 if ( !mHolidayString.isEmpty() ) {
409 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); 417 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString );
410 item->setPalette( mHolidayPalette ); 418 item->setPalette( mHolidayPalette );
411 mItemList->insertItem( item ); 419 mItemList->insertItem( item );
412 tipText += mHolidayString+"\n"; 420 tipText += mHolidayString+"\n";
413 } 421 }
414 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 422 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
415 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); 423 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true );
416 Event *event; 424 Event *event;
417 for( event = events.first(); event; event = events.next() ) { // for event 425 for( event = events.first(); event; event = events.next() ) { // for event
418 426
419 if ( !(event->doesRecur() == Recurrence::rNone) ) { 427 if ( !(event->doesRecur() == Recurrence::rNone) ) {
420 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) 428 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily )
421 continue; 429 continue;
422 else 430 else
423 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) 431 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly )
424 continue; 432 continue;
425 } 433 }
426 434
427 if ( event->categories().contains("Holiday") || 435 if ( event->categories().contains("Holiday") ||
428 event->categories().contains(i18n("Holiday"))) { 436 event->categories().contains(i18n("Holiday"))) {
429 setHoliday( true ); 437 setHoliday( true );
430 if ( mDate.dayOfWeek() == 7 ) 438 if ( mDate.dayOfWeek() == 7 )
431 mItemList->setLineWidth( 3 ); 439 mItemList->setLineWidth( 3 );
432 } 440 }
433 QString text; 441 QString text;
434 if (event->isMultiDay()) { 442 if (event->isMultiDay()) {
435 QString prefix = "<->"; 443 QString prefix = "<->";
436 if ( event->doesRecur() ) { 444 if ( event->doesRecur() ) {
437 if ( event->recursOn( mDate) ) 445 if ( event->recursOn( mDate) )
438 prefix ="->" ; 446 prefix ="->" ;
439 else { 447 else {
440 int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); 448 int days = event->dtStart().date().daysTo ( event->dtEnd().date() );
441 if ( event->recursOn( mDate.addDays( -days)) ) 449 if ( event->recursOn( mDate.addDays( -days)) )
442 prefix ="<-" ; 450 prefix ="<-" ;
443 } 451 }
444 452
445 } else { 453 } else {
446 if (mDate == event->dtStart().date()) { 454 if (mDate == event->dtStart().date()) {
447 prefix ="->" ; 455 prefix ="->" ;
448 } else if (mDate == event->dtEnd().date()) { 456 } else if (mDate == event->dtEnd().date()) {
449 prefix ="<-" ; 457 prefix ="<-" ;
450 } 458 }
451 } 459 }
452 text = prefix + event->summary(); 460 text = prefix + event->summary();
453 tipText += text; 461 tipText += text;
454 } else { 462 } else {
455 if (event->doesFloat()) { 463 if (event->doesFloat()) {
456 text = event->summary(); 464 text = event->summary();
457 tipText += text; 465 tipText += text;
458 } 466 }
459 else { 467 else {
460 text = KGlobal::locale()->formatTime(event->dtStart().time()); 468 text = KGlobal::locale()->formatTime(event->dtStart().time());
461 text += " " + event->summary(); 469 text += " " + event->summary();
462 tipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); 470 tipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary();
463 } 471 }
464 } 472 }
465 473
466 MonthViewItem *item = new MonthViewItem( event, mDate, text ); 474 MonthViewItem *item = new MonthViewItem( event, mDate, text );
467 QPalette pal; 475 QPalette pal;
468 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 476 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
469 QStringList categories = event->categories(); 477 QStringList categories = event->categories();
470 QString cat = categories.first(); 478 QString cat = categories.first();
471 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 479 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
472 pal = getPalette(); 480 pal = getPalette();
473 if (cat.isEmpty()) { 481 if (cat.isEmpty()) {
474 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 482 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
475 } else { 483 } else {
476 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 484 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
477 } 485 }
478 486
479 } else { 487 } else {
480 if (cat.isEmpty()) { 488 if (cat.isEmpty()) {
481 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 489 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
482 } else { 490 } else {
483 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 491 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
484 } 492 }
485 } 493 }
486 494
487 } else { 495 } else {
488 pal = mStandardPalette ; 496 pal = mStandardPalette ;
489 } 497 }
490 item->setPalette( pal ); 498 item->setPalette( pal );
491 item->setRecur( event->recurrence()->doesRecur() ); 499 item->setRecur( event->recurrence()->doesRecur() );
492 item->setAlarm( event->isAlarmEnabled() ); 500 item->setAlarm( event->isAlarmEnabled() );
493 item->setMoreInfo( event->description().length() > 0 ); 501 item->setMoreInfo( event->description().length() > 0 );
494#ifdef DESKTOP_VERSION 502#ifdef DESKTOP_VERSION
495 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, 503 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails,
496 KOPrefs::instance()->email()); 504 KOPrefs::instance()->email());
497 if ( me != 0 ) { 505 if ( me != 0 ) {
498 if ( me->status() == Attendee::NeedsAction && me->RSVP()) 506 if ( me->status() == Attendee::NeedsAction && me->RSVP())
499 item->setReply(true); 507 item->setReply(true);
500 else 508 else
501 item->setReply(false); 509 item->setReply(false);
502 } else 510 } else
503 item->setReply(false); 511 item->setReply(false);
504#endif 512#endif
505 mItemList->insertItem( item ); 513 mItemList->insertItem( item );
506 tipText += "\n"; 514 tipText += "\n";
507 515
508 } 516 }
509 517
510 // insert due todos 518 // insert due todos
511 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); 519 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate );
512 Todo *todo; 520 Todo *todo;
513 for(todo = todos.first(); todo; todo = todos.next()) { 521 for(todo = todos.first(); todo; todo = todos.next()) {
514 QString text; 522 QString text;
515 if (todo->hasDueDate()) { 523 if (todo->hasDueDate()) {
516 if (!todo->doesFloat()) { 524 if (!todo->doesFloat()) {
517 text += KGlobal::locale()->formatTime(todo->dtDue().time()); 525 text += KGlobal::locale()->formatTime(todo->dtDue().time());
518 text += " "; 526 text += " ";
519 } 527 }
520 } 528 }
521 text += i18n("To-Do: %1").arg(todo->summary()); 529 text += i18n("To-Do: %1").arg(todo->summary());
522 530
523 MonthViewItem *item = new MonthViewItem( todo, mDate, text ); 531 MonthViewItem *item = new MonthViewItem( todo, mDate, text );
524 //item->setPalette( mStandardPalette ); 532 //item->setPalette( mStandardPalette );
525 QPalette pal; 533 QPalette pal;
526 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 534 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
527 QStringList categories = todo->categories(); 535 QStringList categories = todo->categories();
528 QString cat = categories.first(); 536 QString cat = categories.first();
529 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 537 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
530 pal = getPalette(); 538 pal = getPalette();
531 if (cat.isEmpty()) { 539 if (cat.isEmpty()) {
532 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 540 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
533 } else { 541 } else {
534 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 542 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
535 } 543 }
536 544
537 } else { 545 } else {
538 if (cat.isEmpty()) { 546 if (cat.isEmpty()) {
539 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 547 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
540 } else { 548 } else {
541 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 549 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
542 } 550 }
543 } 551 }
544 552
545 } else { 553 } else {
546 pal = mStandardPalette ; 554 pal = mStandardPalette ;
547 } 555 }
548 item->setPalette( pal ); 556 item->setPalette( pal );
549 mItemList->insertItem( item ); 557 mItemList->insertItem( item );
550 tipText += text+"\n"; 558 tipText += text+"\n";
551 } 559 }
552#ifdef DESKTOP_VERSION 560#ifdef DESKTOP_VERSION
553 if (tipText != "") 561 if (tipText != "")
554 QToolTip::add(this,tipText,toolTipGroup(),""); 562 QToolTip::add(this,tipText,toolTipGroup(),"");
555#endif 563#endif
556 564
557 //setMyPalette(); 565 //setMyPalette();
558 setMyPalette(); 566 setMyPalette();
559 QString text; 567 QString text;
560 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; 568 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog;
561 if ( KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { 569 if ( KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) {
562 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; 570 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " ";
563 mLabel->resize( mLabelBigSize ); 571 mLabel->resize( mLabelBigSize );
564 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 572 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
565 } else { 573 } else {
566 mLabel->resize( mLabelSize ); 574 mLabel->resize( mLabelSize );
567 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 575 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
568 } 576 }
577
569 mLabel->setText( text ); 578 mLabel->setText( text );
570 resizeEvent( 0 ); 579 resizeEvent( 0 );
571 // if ( isVisible()) 580 // if ( isVisible())
572 qApp->processEvents(); 581 //qApp->processEvents();
573} 582}
574 583
575void MonthViewCell::updateConfig() 584void MonthViewCell::updateConfig()
576{ 585{
577 586
578 setFont( KOPrefs::instance()->mMonthViewFont ); 587 setFont( KOPrefs::instance()->mMonthViewFont );
579 588
580 QFontMetrics fm( font() ); 589 QFontMetrics fm( font() );
581 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); 590 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 );
582 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); 591 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 );
583 mHolidayPalette = mStandardPalette; 592 mHolidayPalette = mStandardPalette;
584 mPrimaryPalette = mStandardPalette; 593 mPrimaryPalette = mStandardPalette;
585 mNonPrimaryPalette = mStandardPalette; 594 mNonPrimaryPalette = mStandardPalette;
586 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { 595 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) {
587 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); 596 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor );
588 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); 597 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor );
589 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); 598 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark());
590 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); 599 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark());
591 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); 600 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor);
592 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); 601 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor);
593 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); 602 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark());
594 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); 603 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor);
595 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); 604 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor);
596 } 605 }
597 updateCell(); 606 updateCell();
598} 607}
599 608
600void MonthViewCell::enableScrollBars( bool enabled ) 609void MonthViewCell::enableScrollBars( bool enabled )
601{ 610{
602 if ( enabled ) { 611 if ( enabled ) {
603 mItemList->setVScrollBarMode(QScrollView::Auto); 612 mItemList->setVScrollBarMode(QScrollView::Auto);
604 mItemList->setHScrollBarMode(QScrollView::Auto); 613 mItemList->setHScrollBarMode(QScrollView::Auto);
605 } else { 614 } else {
606 mItemList->setVScrollBarMode(QScrollView::AlwaysOff); 615 mItemList->setVScrollBarMode(QScrollView::AlwaysOff);
607 mItemList->setHScrollBarMode(QScrollView::AlwaysOff); 616 mItemList->setHScrollBarMode(QScrollView::AlwaysOff);
608 } 617 }
609} 618}
610 619
611Incidence *MonthViewCell::selectedIncidence() 620Incidence *MonthViewCell::selectedIncidence()
612{ 621{
613 int index = mItemList->currentItem(); 622 int index = mItemList->currentItem();
614 if ( index < 0 ) return 0; 623 if ( index < 0 ) return 0;
615 624
616 MonthViewItem *item = 625 MonthViewItem *item =
617 static_cast<MonthViewItem *>( mItemList->item( index ) ); 626 static_cast<MonthViewItem *>( mItemList->item( index ) );
618 627
619 if ( !item ) return 0; 628 if ( !item ) return 0;
620 629
621 return item->incidence(); 630 return item->incidence();
622} 631}
623 632
624QDate MonthViewCell::selectedIncidenceDate() 633QDate MonthViewCell::selectedIncidenceDate()
625{ 634{
626 QDate qd; 635 QDate qd;
627 int index = mItemList->currentItem(); 636 int index = mItemList->currentItem();
628 if ( index < 0 ) return qd; 637 if ( index < 0 ) return qd;
629 638
630 MonthViewItem *item = 639 MonthViewItem *item =
631 static_cast<MonthViewItem *>( mItemList->item( index ) ); 640 static_cast<MonthViewItem *>( mItemList->item( index ) );
632 641
633 if ( !item ) return qd; 642 if ( !item ) return qd;
634 643
635 return item->incidenceDate(); 644 return item->incidenceDate();
636} 645}
637 646
638void MonthViewCell::deselect() 647void MonthViewCell::deselect()
639{ 648{
640 mItemList->clearSelection(); 649 mItemList->clearSelection();
641 enableScrollBars( false ); 650 enableScrollBars( false );
642 // updateCell(); 651 // updateCell();
643} 652}
644void MonthViewCell::select() 653void MonthViewCell::select()
645{ 654{
646 ;// updateCell(); 655 ;// updateCell();
647} 656}
648 657
649void MonthViewCell::resizeEvent ( QResizeEvent * ) 658void MonthViewCell::resizeEvent ( QResizeEvent * )
650{ 659{
651 if ( !mMonthView->isUpdatePossible() ) 660 if ( !mMonthView->isUpdatePossible() )
652 return; 661 return;
653 if ( !isVisible() ){ 662 if ( !isVisible() ){
654 return; 663 return;
655 } 664 }
656 int size = height() - mLabel->height(); 665 int size = height() - mLabel->height();
657 if ( size > 0 ) 666 if ( size > 0 )
658 mItemList->verticalScrollBar()->setMaximumHeight( size ); 667 mItemList->verticalScrollBar()->setMaximumHeight( size );
659 size = width() - mLabel->width(); 668 size = width() - mLabel->width();
660 if ( size > 0 ) 669 if ( size > 0 )
661 mItemList->horizontalScrollBar()->setMaximumWidth( size ); 670 mItemList->horizontalScrollBar()->setMaximumWidth( size );
662 mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() ); 671 mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() );
663 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 672 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
664} 673}
665 674
666void MonthViewCell::defaultAction( QListBoxItem *item ) 675void MonthViewCell::defaultAction( QListBoxItem *item )
667{ 676{
668 if ( !item ) return; 677 if ( !item ) return;
669 678
670 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 679 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
671 Incidence *incidence = eventItem->incidence(); 680 Incidence *incidence = eventItem->incidence();
672 if ( incidence ) mMonthView->defaultAction( incidence ); 681 if ( incidence ) mMonthView->defaultAction( incidence );
673} 682}
674void MonthViewCell::showDay() 683void MonthViewCell::showDay()
675{ 684{
676 emit showDaySignal( date() ); 685 emit showDaySignal( date() );
677} 686}
678void MonthViewCell::newEvent() 687void MonthViewCell::newEvent()
679{ 688{
680 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 689 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
681 emit newEventSignal( dt ); 690 emit newEventSignal( dt );
682} 691}
683void MonthViewCell::cellClicked( QListBoxItem *item ) 692void MonthViewCell::cellClicked( QListBoxItem *item )
684{ 693{
685 static QListBoxItem * lastClicked = 0; 694 static QListBoxItem * lastClicked = 0;
686 if ( item == 0 ) { 695 if ( item == 0 ) {
687 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 696 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
688 emit newEventSignal( dt ); 697 emit newEventSignal( dt );
689 return; 698 return;
690 } 699 }
691 /* 700 /*
692 if ( lastClicked ) 701 if ( lastClicked )
693 if ( ! item ) { 702 if ( ! item ) {
694 if ( lastClicked->listBox() != item->listBox() ) 703 if ( lastClicked->listBox() != item->listBox() )
695 lastClicked->listBox()->clearSelection(); 704 lastClicked->listBox()->clearSelection();
696 } 705 }
697 */ 706 */
698 707
699 mMonthView->setSelectedCell( this ); 708 mMonthView->setSelectedCell( this );
700 if( KOPrefs::instance()->mEnableMonthScroll ) enableScrollBars( true ); 709 if( KOPrefs::instance()->mEnableMonthScroll ) enableScrollBars( true );
701 select(); 710 select();
702} 711}
703 712
704void MonthViewCell::contextMenu( QListBoxItem *item ) 713void MonthViewCell::contextMenu( QListBoxItem *item )
705{ 714{
706 if ( !item ) return; 715 if ( !item ) return;
707 716
708 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 717 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
709 Incidence *incidence = eventItem->incidence(); 718 Incidence *incidence = eventItem->incidence();
710 if ( incidence ) mMonthView->showContextMenu( incidence ); 719 if ( incidence ) mMonthView->showContextMenu( incidence );
711} 720}
712 721
713void MonthViewCell::selection( QListBoxItem *item ) 722void MonthViewCell::selection( QListBoxItem *item )
714{ 723{
715 if ( !item ) return; 724 if ( !item ) return;
716 725
717 mMonthView->setSelectedCell( this ); 726 mMonthView->setSelectedCell( this );
718} 727}
719 728
720 729
721// ******************************************************************************* 730// *******************************************************************************
722// ******************************************************************************* 731// *******************************************************************************
723// ******************************************************************************* 732// *******************************************************************************
724 733
725 734
726KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) 735KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
727 : KOEventView( calendar, parent, name ), 736 : KOEventView( calendar, parent, name ),
728 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), 737 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ),
729 mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) 738 mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 )
730{ 739{
731 updatePossible = false; 740 updatePossible = false;
732 mCells.setAutoDelete( true ); 741 mCells.setAutoDelete( true );
733 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 742 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
734 // mDayLayout = new QGridLayout( this ); 743 // mDayLayout = new QGridLayout( this );
735 // create the day of the week labels (Sun, Mon, etc) and add them to 744 // create the day of the week labels (Sun, Mon, etc) and add them to
736 // the layout. 745 // the layout.
737 mDayLabels.resize( mDaysPerWeek ); 746 mDayLabels.resize( mDaysPerWeek );
738 QFont bfont = font(); 747 QFont bfont = font();
739 if ( QApplication::desktop()->width() < 650 ) { 748 if ( QApplication::desktop()->width() < 650 ) {
740 bfont.setPointSize( bfont.pointSize() - 2 ); 749 bfont.setPointSize( bfont.pointSize() - 2 );
741 } 750 }
742 bfont.setBold( true ); 751 bfont.setBold( true );
743 int i; 752 int i;
744 753
745 for( i = 0; i < mDaysPerWeek; i++ ) { 754 for( i = 0; i < mDaysPerWeek; i++ ) {
746 QLabel *label = new QLabel( this ); 755 QLabel *label = new QLabel( this );
747 label->setFont(bfont); 756 label->setFont(bfont);
748 label->setFrameStyle(QFrame::Panel|QFrame::Raised); 757 label->setFrameStyle(QFrame::Panel|QFrame::Raised);
749 label->setLineWidth(1); 758 label->setLineWidth(1);
750 label->setAlignment(AlignCenter); 759 label->setAlignment(AlignCenter);
751 mDayLabels.insert( i, label ); 760 mDayLabels.insert( i, label );
752 } 761 }
753 762
754 bfont.setBold( false ); 763 bfont.setBold( false );
755 mWeekLabels.resize( mNumWeeks+1 ); 764 mWeekLabels.resize( mNumWeeks+1 );
756 for( i = 0; i < mNumWeeks+1; i++ ) { 765 for( i = 0; i < mNumWeeks+1; i++ ) {
757 KOWeekButton *label = new KOWeekButton( this ); 766 KOWeekButton *label = new KOWeekButton( this );
758 label->setFont(bfont); 767 label->setFont(bfont);
759 connect( label, SIGNAL( selectWeekNum ( int )),this, SIGNAL( selectWeekNum ( int )) ); 768 connect( label, SIGNAL( selectWeekNum ( int )),this, SIGNAL( selectWeekNum ( int )) );
760 label->setFlat(true); 769 label->setFlat(true);
761 QWhatsThis::add(label,i18n("Click on the week number to\nshow week in agenda view")); 770 QWhatsThis::add(label,i18n("Click on the week number to\nshow week in agenda view"));
762 //label->setFrameStyle(QFrame::Panel|QFrame::Raised); 771 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
763 //label->setLineWidth(1); 772 //label->setLineWidth(1);
764 //label->setAlignment(AlignCenter); 773 //label->setAlignment(AlignCenter);
765 mWeekLabels.insert( i, label ); 774 mWeekLabels.insert( i, label );
766 } 775 }
767 mWeekLabels[mNumWeeks]->setText( i18n("W")); 776 mWeekLabels[mNumWeeks]->setText( i18n("W"));
768 int row, col; 777 int row, col;
769 mCells.resize( mNumCells ); 778 mCells.resize( mNumCells );
770 for( row = 0; row < mNumWeeks; ++row ) { 779 for( row = 0; row < mNumWeeks; ++row ) {
771 for( col = 0; col < mDaysPerWeek; ++col ) { 780 for( col = 0; col < mDaysPerWeek; ++col ) {
772 MonthViewCell *cell = new MonthViewCell( this ); 781 MonthViewCell *cell = new MonthViewCell( this );
773 mCells.insert( row * mDaysPerWeek + col, cell ); 782 mCells.insert( row * mDaysPerWeek + col, cell );
774 783
775 connect( cell, SIGNAL( defaultAction( Incidence * ) ), 784 connect( cell, SIGNAL( defaultAction( Incidence * ) ),
776 SLOT( defaultAction( Incidence * ) ) ); 785 SLOT( defaultAction( Incidence * ) ) );
777 connect( cell, SIGNAL( newEventSignal( QDateTime ) ), 786 connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
778 SIGNAL( newEventSignal( QDateTime ) ) ); 787 SIGNAL( newEventSignal( QDateTime ) ) );
779 connect( cell, SIGNAL( showDaySignal( QDate ) ), 788 connect( cell, SIGNAL( showDaySignal( QDate ) ),
780 SIGNAL( showDaySignal( QDate ) ) ); 789 SIGNAL( showDaySignal( QDate ) ) );
781 } 790 }
782 } 791 }
783 792
784 mContextMenu = eventPopup(); 793 mContextMenu = eventPopup();
785 // updateConfig(); //useless here 794 // updateConfig(); //useless here
786 795
787 emit incidenceSelected( 0 ); 796 emit incidenceSelected( 0 );
788} 797}
789 798
790KOMonthView::~KOMonthView() 799KOMonthView::~KOMonthView()
791{ 800{
792 delete mContextMenu; 801 delete mContextMenu;
793} 802}
794 803
795int KOMonthView::maxDatesHint() 804int KOMonthView::maxDatesHint()
796{ 805{
797 return mNumCells; 806 return mNumCells;
798} 807}
799 808
800int KOMonthView::currentDateCount() 809int KOMonthView::currentDateCount()
801{ 810{
802 return mNumCells; 811 return mNumCells;
803} 812}
804 813
805QPtrList<Incidence> KOMonthView::selectedIncidences() 814QPtrList<Incidence> KOMonthView::selectedIncidences()
806{ 815{
807 QPtrList<Incidence> selected; 816 QPtrList<Incidence> selected;
808 817
809 if ( mSelectedCell ) { 818 if ( mSelectedCell ) {
810 Incidence *incidence = mSelectedCell->selectedIncidence(); 819 Incidence *incidence = mSelectedCell->selectedIncidence();
811 if ( incidence ) selected.append( incidence ); 820 if ( incidence ) selected.append( incidence );
812 } 821 }
813 822
814 return selected; 823 return selected;
815} 824}
816 825
817DateList KOMonthView::selectedDates() 826DateList KOMonthView::selectedDates()
818{ 827{
819 DateList selected; 828 DateList selected;
820 829
821 if ( mSelectedCell ) { 830 if ( mSelectedCell ) {
822 QDate qd = mSelectedCell->selectedIncidenceDate(); 831 QDate qd = mSelectedCell->selectedIncidenceDate();
823 if ( qd.isValid() ) selected.append( qd ); 832 if ( qd.isValid() ) selected.append( qd );
824 } 833 }
825 834
826 return selected; 835 return selected;
827} 836}
828 837
829void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, 838void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd,
830 const QDate &td) 839 const QDate &td)
831{ 840{
832#ifndef KORG_NOPRINTER 841#ifndef KORG_NOPRINTER
833 calPrinter->preview(CalPrinter::Month, fd, td); 842 calPrinter->preview(CalPrinter::Month, fd, td);
834#endif 843#endif
835} 844}
836 845
837void KOMonthView::updateConfig() 846void KOMonthView::updateConfig()
838{ 847{
839 848
840 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); 849 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
841 850
842 QFontMetrics fontmetric(mDayLabels[0]->font()); 851 QFontMetrics fontmetric(mDayLabels[0]->font());
843 mWidthLongDayLabel = 0; 852 mWidthLongDayLabel = 0;
844 853
845 for (int i = 0; i < 7; i++) { 854 for (int i = 0; i < 7; i++) {
846 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); 855 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1));
847 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; 856 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
848 } 857 }
849 bool temp = mShowSatSunComp ; 858 bool temp = mShowSatSunComp ;
850 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 859 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
851 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) 860 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog )
852 computeLayout(); 861 computeLayout();
853 updateDayLabels(); 862 updateDayLabels();
854 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); 863 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks);
855 int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; 864 int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks;
856 //resizeEvent( 0 ); 865 //resizeEvent( 0 );
857 for (uint i = 0; i < mCells.count(); ++i) { 866 for (uint i = 0; i < mCells.count(); ++i) {
858 mCells[i]->updateConfig(); 867 mCells[i]->updateConfig();
859 } 868 }
860#ifdef DESKTOP_VERSION 869#ifdef DESKTOP_VERSION
861 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); 870 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips);
862#endif 871#endif
863} 872}
864 873
865void KOMonthView::updateDayLabels() 874void KOMonthView::updateDayLabels()
866{ 875{
867 876
868 for (int i = 0; i < 7; i++) { 877 for (int i = 0; i < 7; i++) {
869 if (mWeekStartsMonday) { 878 if (mWeekStartsMonday) {
870 bool show = mShortDayLabels; 879 bool show = mShortDayLabels;
871 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() ) 880 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() )
872 show = true; 881 show = true;
873 mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); 882 mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
874 } else { 883 } else {
875 if (i==0) mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels)); 884 if (i==0) mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels));
876 else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); 885 else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels));
877 886
878 } 887 }
879 } 888 }
880} 889}
881 890
882void KOMonthView::showDates(const QDate &start, const QDate &) 891void KOMonthView::showDates(const QDate &start, const QDate &)
883{ 892{
884// kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; 893// kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl;
885 894
886 895
887 mStartDate = start; 896 mStartDate = start;
888 897
889 int startWeekDay = mWeekStartsMonday ? 1 : 7; 898 int startWeekDay = mWeekStartsMonday ? 1 : 7;
890 899
891 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { 900 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) {
892 mStartDate = mStartDate.addDays( -1 ); 901 mStartDate = mStartDate.addDays( -1 );
893 } 902 }
894 903
895 bool primary = false; 904 bool primary = false;
896 uint i; 905 uint i;
897 for( i = 0; i < mCells.size(); ++i ) { 906 for( i = 0; i < mCells.size(); ++i ) {
898 QDate date = mStartDate.addDays( i ); 907 QDate date = mStartDate.addDays( i );
899 mCells[i]->setDate( date ); 908 mCells[i]->setDate( date );
900 909
901#ifndef KORG_NOPLUGINS 910#ifndef KORG_NOPLUGINS
902 // add holiday, if present 911 // add holiday, if present
903 QString hstring(KOCore::self()->holiday(date)); 912 QString hstring(KOCore::self()->holiday(date));
904 mCells[i]->setHoliday( hstring ); 913 mCells[i]->setHoliday( hstring );
905#endif 914#endif
906 915
907 } 916 }
908 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); 917 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 );
909 for( i = 0; i < 6; ++i ) { 918 for( i = 0; i < 6; ++i ) {
910 int wno; 919 int wno;
911 // remember, according to ISO 8601, the first week of the year is the 920 // remember, according to ISO 8601, the first week of the year is the
912 // first week that contains a thursday. Thus we must subtract off 4, 921 // first week that contains a thursday. Thus we must subtract off 4,
913 // not just 1. 922 // not just 1.
914 int dayOfYear = date.dayOfYear(); 923 int dayOfYear = date.dayOfYear();
915 if (dayOfYear % 7 != 0) 924 if (dayOfYear % 7 != 0)
916 wno = dayOfYear / 7 + 1; 925 wno = dayOfYear / 7 + 1;
917 else 926 else
918 wno =dayOfYear / 7; 927 wno =dayOfYear / 7;
919 mWeekLabels[i]->setWeekNum( wno ); 928 mWeekLabels[i]->setWeekNum( wno );
920 date = date.addDays( 7 ); 929 date = date.addDays( 7 );
921 } 930 }
922 updateView(); 931 updateView();
923} 932}
924 933
925void KOMonthView::showEvents(QPtrList<Event>) 934void KOMonthView::showEvents(QPtrList<Event>)
926{ 935{
927 qDebug("KOMonthView::selectEvents is not implemented yet. "); 936 qDebug("KOMonthView::selectEvents is not implemented yet. ");
928} 937}
929 938
930void KOMonthView::changeEventDisplay(Event *, int) 939void KOMonthView::changeEventDisplay(Event *, int)
931{ 940{
932 // this should be re-written to be much more efficient, but this 941 // this should be re-written to be much more efficient, but this
933 // quick-and-dirty-hack gets the job done for right now. 942 // quick-and-dirty-hack gets the job done for right now.
934 updateView(); 943 updateView();
935} 944}
936 945
937void KOMonthView::updateView() 946void KOMonthView::updateView()
938{ 947{
939 static int iii = 0;
940 ++iii;
941 if ( !updatePossible ) 948 if ( !updatePossible )
942 return; 949 return;
943 uint i; 950 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ");
951 int i;
944 for( i = 0; i < mCells.count(); ++i ) { 952 for( i = 0; i < mCells.count(); ++i ) {
945 mCells[i]->updateCell(); 953 mCells[i]->updateCell();
946 } 954 }
955
947 //qDebug("KOMonthView::updateView() "); 956 //qDebug("KOMonthView::updateView() ");
948 processSelectionChange(); 957 processSelectionChange();
958 // qDebug("---------------------------------------------------------------------+ ");
949} 959}
950 960
951void KOMonthView::resizeEvent(QResizeEvent * e) 961void KOMonthView::resizeEvent(QResizeEvent * e)
952{ 962{
953 computeLayout(); 963 computeLayout();
954} 964}
955void KOMonthView::computeLayout() 965void KOMonthView::computeLayout()
956{ 966{
957 // select the appropriate heading string size. E.g. "Wednesday" or "Wed". 967 // select the appropriate heading string size. E.g. "Wednesday" or "Wed".
958 // note this only changes the text if the requested size crosses the 968 // note this only changes the text if the requested size crosses the
959 // threshold between big enough to support the full name and not big 969 // threshold between big enough to support the full name and not big
960 // enough. 970 // enough.
961 971
962 int daysToShow = 7; 972 int daysToShow = 7;
963 bool combinedSatSun = false; 973 bool combinedSatSun = false;
964 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { 974 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
965 daysToShow = 6; 975 daysToShow = 6;
966 combinedSatSun = true; 976 combinedSatSun = true;
967 } 977 }
968 int tWid = topLevelWidget()->size().width(); 978 int tWid = topLevelWidget()->size().width();
969 int tHei = topLevelWidget()->size().height(); 979 int tHei = topLevelWidget()->size().height();
970 980
971 int wid = size().width();//e 981 int wid = size().width();//e
972 int hei = size().height()-1; 982 int hei = size().height()-1;
973 983
974 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) 984 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei )
975 return; 985 return;
976 //qDebug("KOMonthView::computeLayout()------------------------------------ "); 986 //qDebug("KOMonthView::computeLayout()------------------------------------ ");
977 QFontMetrics fm ( mWeekLabels[0]->font() ); 987 QFontMetrics fm ( mWeekLabels[0]->font() );
978 int weeklabelwid = fm.width( "888" ); 988 int weeklabelwid = fm.width( "888" );
979 wid -= weeklabelwid; 989 wid -= weeklabelwid;
980 990
981 int colWid = wid / daysToShow; 991 int colWid = wid / daysToShow;
982 int lastCol = wid - ( colWid*6 ); 992 int lastCol = wid - ( colWid*6 );
983 int dayLabelHei = mDayLabels[0]->sizeHint().height(); 993 int dayLabelHei = mDayLabels[0]->sizeHint().height();
984 int cellHei = (hei - dayLabelHei) /6; 994 int cellHei = (hei - dayLabelHei) /6;
985 int colModulo = wid % daysToShow; 995 int colModulo = wid % daysToShow;
986 int rowModulo = (hei- dayLabelHei) % 6; 996 int rowModulo = (hei- dayLabelHei) % 6;
987 //qDebug("rowmod %d ", rowModulo); 997 //qDebug("rowmod %d ", rowModulo);
988 int i; 998 int i;
989 int x,y,w,h; 999 int x,y,w,h;
990 x= 0; 1000 x= 0;
991 y= 0; 1001 y= 0;
992 w = colWid; 1002 w = colWid;
993 h = dayLabelHei ; 1003 h = dayLabelHei ;
994 for ( i = 0; i < 7; i++) { 1004 for ( i = 0; i < 7; i++) {
995 if ( i == daysToShow-colModulo ) 1005 if ( i == daysToShow-colModulo )
996 ++w; 1006 ++w;
997 if ( combinedSatSun ) { 1007 if ( combinedSatSun ) {
998 if ( i >= daysToShow-1 ) { 1008 if ( i >= daysToShow-1 ) {
999 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); 1009 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h);
1000 x -= w/2 ; 1010 x -= w/2 ;
1001 } 1011 }
1002 else 1012 else
1003 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 1013 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
1004 } else 1014 } else
1005 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 1015 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
1006 x += w; 1016 x += w;
1007 } 1017 }
1008 x= 0; 1018 x= 0;
1009 y= dayLabelHei; 1019 y= dayLabelHei;
1010 w = colWid; 1020 w = colWid;
1011 h = cellHei ; 1021 h = cellHei ;
1012 for ( i = 0; i < mCells.count(); ++i) { 1022 for ( i = 0; i < mCells.count(); ++i) {
1013 1023
1014 w = colWid; 1024 w = colWid;
1015 if ( ((i) % 7) >= 7-colModulo ) { 1025 if ( ((i) % 7) >= 7-colModulo ) {
1016 ++w; 1026 ++w;
1017 } 1027 }
1018 if ( i == (6-rowModulo)*7) 1028 if ( i == (6-rowModulo)*7)
1019 ++h; 1029 ++h;
1020 if ( combinedSatSun ) { 1030 if ( combinedSatSun ) {
1021 if ( (i)%7 >= daysToShow-1 ) { 1031 if ( (i)%7 >= daysToShow-1 ) {
1022 if ( (i)%7 == daysToShow-1 ) { 1032 if ( (i)%7 == daysToShow-1 ) {
1023 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); 1033 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 );
1024 x -= w ;y += h/2; 1034 x -= w ;y += h/2;
1025 } else { 1035 } else {
1026 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); 1036 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 );
1027 y -= h/2; 1037 y -= h/2;
1028 } 1038 }
1029 } else 1039 } else
1030 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1040 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
1031 1041
1032 } 1042 }
1033 else 1043 else
1034 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1044 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
1035 x += w; 1045 x += w;
1036 if ( x + w/2 > wid ) { 1046 if ( x + w/2 > wid ) {
1037 x = 0; 1047 x = 0;
1038 y += h; 1048 y += h;
1039 } 1049 }
1040 } 1050 }
1041 y= dayLabelHei; 1051 y= dayLabelHei;
1042 h = cellHei ; 1052 h = cellHei ;
1043 for ( i = 0; i < 6; i++) { 1053 for ( i = 0; i < 6; i++) {
1044 if ( i == (6-rowModulo)) 1054 if ( i == (6-rowModulo))
1045 ++h; 1055 ++h;
1046 mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); 1056 mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h);
1047 y += h; 1057 y += h;
1048 } 1058 }
1049 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); 1059 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei);
1050 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); 1060 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height());
1051 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); 1061 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height());
1052 mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ; 1062 mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ;
1053 updateDayLabels(); 1063 updateDayLabels();
1054 bool forceUpdate = !updatePossible; 1064 bool forceUpdate = !updatePossible;
1055 updatePossible = true; 1065 updatePossible = true;
1056 if ( forceUpdate ) 1066 if ( forceUpdate )
1057 updateView(); 1067 updateView();
1058} 1068}
1059 1069
1060void KOMonthView::showContextMenu( Incidence *incidence ) 1070void KOMonthView::showContextMenu( Incidence *incidence )
1061{ 1071{
1062 mContextMenu->showIncidencePopup(incidence); 1072 mContextMenu->showIncidencePopup(incidence);
1063 /* 1073 /*
1064 if( incidence && incidence->type() == "Event" ) { 1074 if( incidence && incidence->type() == "Event" ) {
1065 Event *event = static_cast<Event *>(incidence); 1075 Event *event = static_cast<Event *>(incidence);
1066 mContextMenu->showEventPopup(event); 1076 mContextMenu->showEventPopup(event);
1067 } else { 1077 } else {
1068 kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; 1078 kdDebug() << "MonthView::showContextMenu(): cast failed." << endl;
1069 } 1079 }
1070 */ 1080 */
1071} 1081}
1072MonthViewCell * KOMonthView::selectedCell( ) 1082MonthViewCell * KOMonthView::selectedCell( )
1073{ 1083{
1074 return mSelectedCell; 1084 return mSelectedCell;
1075} 1085}
1076void KOMonthView::setSelectedCell( MonthViewCell *cell ) 1086void KOMonthView::setSelectedCell( MonthViewCell *cell )
1077{ 1087{
1078 // qDebug("KOMonthView::setSelectedCell "); 1088 // qDebug("KOMonthView::setSelectedCell ");
1079 if ( mSelectedCell && mSelectedCell != cell ) { 1089 if ( mSelectedCell && mSelectedCell != cell ) {
1080 MonthViewCell * mvc = mSelectedCell; 1090 MonthViewCell * mvc = mSelectedCell;
1081 mSelectedCell = cell; 1091 mSelectedCell = cell;
1082 mvc->deselect(); 1092 mvc->deselect();
1083 } else 1093 } else
1084 mSelectedCell = cell; 1094 mSelectedCell = cell;
1085 // if ( mSelectedCell ) 1095 // if ( mSelectedCell )
1086// mSelectedCell->select(); 1096// mSelectedCell->select();
1087 if ( !mSelectedCell ) 1097 if ( !mSelectedCell )
1088 emit incidenceSelected( 0 ); 1098 emit incidenceSelected( 0 );
1089 else 1099 else
1090 emit incidenceSelected( mSelectedCell->selectedIncidence() ); 1100 emit incidenceSelected( mSelectedCell->selectedIncidence() );
1091} 1101}
1092 1102
1093void KOMonthView::processSelectionChange() 1103void KOMonthView::processSelectionChange()
1094{ 1104{
1095 QPtrList<Incidence> incidences = selectedIncidences(); 1105 QPtrList<Incidence> incidences = selectedIncidences();
1096 if (incidences.count() > 0) { 1106 if (incidences.count() > 0) {
1097 emit incidenceSelected( incidences.first() ); 1107 emit incidenceSelected( incidences.first() );
1098 } else { 1108 } else {
1099 emit incidenceSelected( 0 ); 1109 emit incidenceSelected( 0 );
1100 } 1110 }
1101} 1111}
1102 1112
1103void KOMonthView::clearSelection() 1113void KOMonthView::clearSelection()
1104{ 1114{
1105 if ( mSelectedCell ) { 1115 if ( mSelectedCell ) {
1106 mSelectedCell->deselect(); 1116 mSelectedCell->deselect();
1107 mSelectedCell = 0; 1117 mSelectedCell = 0;
1108 } 1118 }
1109} 1119}
1110void KOMonthView::keyPressEvent ( QKeyEvent * e ) 1120void KOMonthView::keyPressEvent ( QKeyEvent * e )
1111{ 1121{
1112 1122
1113 e->ignore(); 1123 e->ignore();
1114 1124
1115} 1125}
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h
index 727f511..a965bf3 100644
--- a/korganizer/komonthview.h
+++ b/korganizer/komonthview.h
@@ -1,271 +1,272 @@
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 KNOWhatsThis;
44class KOWeekButton : public QPushButton 44class KOWeekButton : public QPushButton
45{ 45{
46 Q_OBJECT 46 Q_OBJECT
47 public: 47 public:
48 KOWeekButton( QWidget *parent=0, const char *name=0 ) : 48 KOWeekButton( QWidget *parent=0, const char *name=0 ) :
49 QPushButton( parent, name) 49 QPushButton( parent, name)
50 { 50 {
51 connect( this, SIGNAL( clicked() ), 51 connect( this, SIGNAL( clicked() ),
52 SLOT( bottonClicked() )); 52 SLOT( bottonClicked() ));
53 mNumber = -1; 53 mNumber = -1;
54 } 54 }
55 void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));} 55 void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));}
56 signals: 56 signals:
57 void selectWeekNum ( int ); 57 void selectWeekNum ( int );
58private: 58private:
59 int mNumber; 59 int mNumber;
60private slots : 60private slots :
61 void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); } 61 void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); }
62}; 62};
63 63
64class KNoScrollListBox: public QListBox 64class KNoScrollListBox: public QListBox
65{ 65{
66 Q_OBJECT 66 Q_OBJECT
67 public: 67 public:
68 KNoScrollListBox(QWidget *parent=0, const char *name=0); 68 KNoScrollListBox(QWidget *parent=0, const char *name=0);
69 ~KNoScrollListBox(); 69 ~KNoScrollListBox();
70 QString getWhatsThisText(QPoint p) ; 70 QString getWhatsThisText(QPoint p) ;
71 71
72 signals: 72 signals:
73 void shiftDown(); 73 void shiftDown();
74 void shiftUp(); 74 void shiftUp();
75 void rightClick(); 75 void rightClick();
76 76
77 protected slots: 77 protected slots:
78 void keyPressEvent(QKeyEvent *); 78 void keyPressEvent(QKeyEvent *);
79 void keyReleaseEvent(QKeyEvent *); 79 void keyReleaseEvent(QKeyEvent *);
80 void mousePressEvent(QMouseEvent *); 80 void mousePressEvent(QMouseEvent *);
81 81
82 private: 82 private:
83 KNOWhatsThis * mWT; 83 KNOWhatsThis * mWT;
84}; 84};
85 85
86 86
87class MonthViewItem: public QListBoxItem 87class MonthViewItem: public QListBoxItem
88{ 88{
89 public: 89 public:
90 MonthViewItem( Incidence *, QDate qd, const QString & title ); 90 MonthViewItem( Incidence *, QDate qd, const QString & title );
91 91
92 void setRecur(bool on) { mRecur = on; } 92 void setRecur(bool on) { mRecur = on; }
93 void setAlarm(bool on) { mAlarm = on; } 93 void setAlarm(bool on) { mAlarm = on; }
94 void setReply(bool on) { mReply = on; } 94 void setReply(bool on) { mReply = on; }
95 void setMoreInfo(bool on) { mInfo = on; } 95 void setMoreInfo(bool on) { mInfo = on; }
96 96
97 97
98 void setPalette(const QPalette &p) { mPalette = p; } 98 void setPalette(const QPalette &p) { mPalette = p; }
99 QPalette palette() const { return mPalette; } 99 QPalette palette() const { return mPalette; }
100 100
101 Incidence *incidence() const { return mIncidence; } 101 Incidence *incidence() const { return mIncidence; }
102 QDate incidenceDate() { return mDate; } 102 QDate incidenceDate() { return mDate; }
103 103
104 protected: 104 protected:
105 virtual void paint(QPainter *); 105 virtual void paint(QPainter *);
106 virtual int height(const QListBox *) const; 106 virtual int height(const QListBox *) const;
107 virtual int width(const QListBox *) const; 107 virtual int width(const QListBox *) const;
108 108
109 private: 109 private:
110 bool mRecur; 110 bool mRecur;
111 bool mAlarm; 111 bool mAlarm;
112 bool mReply; 112 bool mReply;
113 bool mInfo; 113 bool mInfo;
114 114
115 QPalette mPalette; 115 QPalette mPalette;
116 QDate mDate; 116 QDate mDate;
117 117
118 Incidence *mIncidence; 118 Incidence *mIncidence;
119}; 119};
120 120
121 121
122class KOMonthView; 122class KOMonthView;
123 123
124class MonthViewCell : public QWidget 124class MonthViewCell : public QWidget
125{ 125{
126 Q_OBJECT 126 Q_OBJECT
127 public: 127 public:
128 MonthViewCell( KOMonthView * ); 128 MonthViewCell( KOMonthView * );
129 129
130 void setDate( const QDate & ); 130 void setDate( const QDate & );
131 QDate date() const; 131 QDate date() const;
132 132
133 void setPrimary( bool ); 133 void setPrimary( bool );
134 bool isPrimary() const; 134 bool isPrimary() const;
135 135
136 void setHoliday( bool ); 136 void setHoliday( bool );
137 void setHoliday( const QString & ); 137 void setHoliday( const QString & );
138 138
139 void updateCell(); 139 void updateCell();
140 140
141 void updateConfig(); 141 void updateConfig();
142 142
143 void enableScrollBars( bool ); 143 void enableScrollBars( bool );
144 144
145 Incidence *selectedIncidence(); 145 Incidence *selectedIncidence();
146 QDate selectedIncidenceDate(); 146 QDate selectedIncidenceDate();
147 147
148 void deselect(); 148 void deselect();
149 void select(); 149 void select();
150 void clear();
150 151
151#ifdef DESKTOP_VERSION 152#ifdef DESKTOP_VERSION
152 static QToolTipGroup *toolTipGroup(); 153 static QToolTipGroup *toolTipGroup();
153#endif 154#endif
154 signals: 155 signals:
155 void defaultAction( Incidence * ); 156 void defaultAction( Incidence * );
156 void newEventSignal( QDateTime ); 157 void newEventSignal( QDateTime );
157 void showDaySignal( QDate ); 158 void showDaySignal( QDate );
158 159
159 protected: 160 protected:
160 void resizeEvent( QResizeEvent * ); 161 void resizeEvent( QResizeEvent * );
161 162
162 protected slots: 163 protected slots:
163 void defaultAction( QListBoxItem * ); 164 void defaultAction( QListBoxItem * );
164 void contextMenu( QListBoxItem * ); 165 void contextMenu( QListBoxItem * );
165 void selection( QListBoxItem * ); 166 void selection( QListBoxItem * );
166 void cellClicked( QListBoxItem * ); 167 void cellClicked( QListBoxItem * );
167 void newEvent(); 168 void newEvent();
168 void showDay(); 169 void showDay();
169 170
170 private: 171 private:
171 KOMonthView *mMonthView; 172 KOMonthView *mMonthView;
172 173
173 QDate mDate; 174 QDate mDate;
174 bool mPrimary; 175 bool mPrimary;
175 bool mHoliday; 176 bool mHoliday;
176 QString mHolidayString; 177 QString mHolidayString;
177 178
178 //QLabel *mLabel; 179 //QLabel *mLabel;
179 QPushButton *mLabel; 180 QPushButton *mLabel;
180 QListBox *mItemList; 181 QListBox *mItemList;
181#ifdef DESKTOP_VERSION 182#ifdef DESKTOP_VERSION
182 static QToolTipGroup *mToolTipGroup; 183 static QToolTipGroup *mToolTipGroup;
183#endif 184#endif
184 QSize mLabelSize; 185 QSize mLabelSize;
185 QSize mLabelBigSize; 186 QSize mLabelBigSize;
186 QPalette mHolidayPalette; 187 QPalette mHolidayPalette;
187 QPalette mStandardPalette; 188 QPalette mStandardPalette;
188 QPalette mPrimaryPalette; 189 QPalette mPrimaryPalette;
189 QPalette mNonPrimaryPalette; 190 QPalette mNonPrimaryPalette;
190 void setMyPalette(); 191 void setMyPalette();
191 QPalette getPalette (); 192 QPalette getPalette ();
192 void keyPressEvent ( QKeyEvent * ) ; 193 void keyPressEvent ( QKeyEvent * ) ;
193 194
194}; 195};
195 196
196 197
197class KOMonthView: public KOEventView 198class KOMonthView: public KOEventView
198{ 199{
199 Q_OBJECT 200 Q_OBJECT
200 public: 201 public:
201 KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 ); 202 KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 );
202 ~KOMonthView(); 203 ~KOMonthView();
203 204
204 /** Returns maximum number of days supported by the komonthview */ 205 /** Returns maximum number of days supported by the komonthview */
205 virtual int maxDatesHint(); 206 virtual int maxDatesHint();
206 207
207 /** Returns number of currently shown dates. */ 208 /** Returns number of currently shown dates. */
208 virtual int currentDateCount(); 209 virtual int currentDateCount();
209 210
210 /** returns the currently selected events */ 211 /** returns the currently selected events */
211 virtual QPtrList<Incidence> selectedIncidences(); 212 virtual QPtrList<Incidence> selectedIncidences();
212 213
213 /** returns dates of the currently selected events */ 214 /** returns dates of the currently selected events */
214 virtual DateList selectedDates(); 215 virtual DateList selectedDates();
215 216
216 virtual void printPreview(CalPrinter *calPrinter, 217 virtual void printPreview(CalPrinter *calPrinter,
217 const QDate &, const QDate &); 218 const QDate &, const QDate &);
218 bool isMonthView() { return true; } 219 bool isMonthView() { return true; }
219 bool isUpdatePossible() { return updatePossible; } 220 bool isUpdatePossible() { return updatePossible; }
220 221
221 MonthViewCell * selectedCell(); 222 MonthViewCell * selectedCell();
222 public slots: 223 public slots:
223 virtual void updateView(); 224 virtual void updateView();
224 virtual void updateConfig(); 225 virtual void updateConfig();
225 virtual void showDates(const QDate &start, const QDate &end); 226 virtual void showDates(const QDate &start, const QDate &end);
226 virtual void showEvents(QPtrList<Event> eventList); 227 virtual void showEvents(QPtrList<Event> eventList);
227 228
228 void changeEventDisplay(Event *, int); 229 void changeEventDisplay(Event *, int);
229 230
230 void clearSelection(); 231 void clearSelection();
231 232
232 void showContextMenu( Incidence * ); 233 void showContextMenu( Incidence * );
233 234
234 void setSelectedCell( MonthViewCell * ); 235 void setSelectedCell( MonthViewCell * );
235 236
236 protected slots: 237 protected slots:
237 void processSelectionChange(); 238 void processSelectionChange();
238 signals: 239 signals:
239 void selectWeekNum ( int ); 240 void selectWeekNum ( int );
240 void showDaySignal( QDate ); 241 void showDaySignal( QDate );
241 protected: 242 protected:
242 void resizeEvent(QResizeEvent *); 243 void resizeEvent(QResizeEvent *);
243 void viewChanged(); 244 void viewChanged();
244 void updateDayLabels(); 245 void updateDayLabels();
245 246
246 private: 247 private:
247 bool updatePossible; 248 bool updatePossible;
248 int mDaysPerWeek; 249 int mDaysPerWeek;
249 int mNumWeeks; 250 int mNumWeeks;
250 int mNumCells; 251 int mNumCells;
251 bool mWeekStartsMonday; 252 bool mWeekStartsMonday;
252 bool mShowSatSunComp; 253 bool mShowSatSunComp;
253 void computeLayout(); 254 void computeLayout();
254 255
255 QPtrVector<MonthViewCell> mCells; 256 QPtrVector<MonthViewCell> mCells;
256 QPtrVector<QLabel> mDayLabels; 257 QPtrVector<QLabel> mDayLabels;
257 QPtrVector<KOWeekButton> mWeekLabels; 258 QPtrVector<KOWeekButton> mWeekLabels;
258 259
259 bool mShortDayLabels; 260 bool mShortDayLabels;
260 int mWidthLongDayLabel; 261 int mWidthLongDayLabel;
261 262
262 QDate mStartDate; 263 QDate mStartDate;
263 264
264 MonthViewCell *mSelectedCell; 265 MonthViewCell *mSelectedCell;
265 266
266 KOEventPopupMenu *mContextMenu; 267 KOEventPopupMenu *mContextMenu;
267 void keyPressEvent ( QKeyEvent * ) ; 268 void keyPressEvent ( QKeyEvent * ) ;
268 269
269}; 270};
270 271
271#endif 272#endif
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp
index 00a5842..f6b7718 100644
--- a/korganizer/koviewmanager.cpp
+++ b/korganizer/koviewmanager.cpp
@@ -1,587 +1,588 @@
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#include "kdatenavigator.h"
49 49
50#include "koviewmanager.h" 50#include "koviewmanager.h"
51//extern bool externFlagMonthviewBlockPainting; 51//extern bool externFlagMonthviewBlockPainting;
52 52
53//bool globalFlagBlockPainting = false; 53//bool globalFlagBlockPainting = false;
54int globalFlagBlockAgenda = 0; 54int globalFlagBlockAgenda = 0;
55int globalFlagBlockLabel = 0; 55int globalFlagBlockLabel = 0;
56int globalFlagBlockAgendaItemPaint = 1; 56int globalFlagBlockAgendaItemPaint = 1;
57int globalFlagBlockAgendaItemUpdate = 1; 57int globalFlagBlockAgendaItemUpdate = 1;
58 58
59 59
60KOViewManager::KOViewManager( CalendarView *mainView ) : 60KOViewManager::KOViewManager( CalendarView *mainView ) :
61 QObject(), mMainView( mainView ) 61 QObject(), mMainView( mainView )
62{ 62{
63 mCurrentView = 0; 63 mCurrentView = 0;
64 64
65 mWhatsNextView = 0; 65 mWhatsNextView = 0;
66 mTodoView = 0; 66 mTodoView = 0;
67 mAgendaView = 0; 67 mAgendaView = 0;
68 mMonthView = 0; 68 mMonthView = 0;
69 mListView = 0; 69 mListView = 0;
70 mJournalView = 0; 70 mJournalView = 0;
71 mTimeSpanView = 0; 71 mTimeSpanView = 0;
72 mCurrentAgendaView = 0 ; 72 mCurrentAgendaView = 0 ;
73 mFlagShowNextxDays = false; 73 mFlagShowNextxDays = false;
74} 74}
75 75
76KOViewManager::~KOViewManager() 76KOViewManager::~KOViewManager()
77{ 77{
78} 78}
79 79
80 80
81KOrg::BaseView *KOViewManager::currentView() 81KOrg::BaseView *KOViewManager::currentView()
82{ 82{
83 return mCurrentView; 83 return mCurrentView;
84} 84}
85 85
86void KOViewManager::readSettings(KConfig *config) 86void KOViewManager::readSettings(KConfig *config)
87{ 87{
88 config->setGroup("General"); 88 config->setGroup("General");
89 QString view = config->readEntry("Current View"); 89 QString view = config->readEntry("Current View");
90 if (view == "WhatsNext") showWhatsNextView(); 90 if (view == "WhatsNext") showWhatsNextView();
91 else if (view == "Month") showMonthView(); 91 else if (view == "Month") showMonthView();
92 else if (view == "List") showListView(); 92 else if (view == "List") showListView();
93 else if (view == "Journal") showJournalView(); 93 else if (view == "Journal") showJournalView();
94 else if (view == "TimeSpan") showTimeSpanView(); 94 else if (view == "TimeSpan") showTimeSpanView();
95 else if (view == "Todo") showTodoView(); 95 else if (view == "Todo") showTodoView();
96 else { 96 else {
97 showAgendaView(); 97 showAgendaView();
98 } 98 }
99} 99}
100 100
101void KOViewManager::writeSettings(KConfig *config) 101void KOViewManager::writeSettings(KConfig *config)
102{ 102{
103 config->setGroup("General"); 103 config->setGroup("General");
104 104
105 QString view; 105 QString view;
106 if (mCurrentView == mWhatsNextView) view = "WhatsNext"; 106 if (mCurrentView == mWhatsNextView) view = "WhatsNext";
107 else if (mCurrentView == mMonthView) view = "Month"; 107 else if (mCurrentView == mMonthView) view = "Month";
108 else if (mCurrentView == mListView) view = "List"; 108 else if (mCurrentView == mListView) view = "List";
109 else if (mCurrentView == mJournalView) view = "Journal"; 109 else if (mCurrentView == mJournalView) view = "Journal";
110 else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; 110 else if (mCurrentView == mTimeSpanView) view = "TimeSpan";
111 else if (mCurrentView == mTodoView) view = "Todo"; 111 else if (mCurrentView == mTodoView) view = "Todo";
112 else view = "Agenda"; 112 else view = "Agenda";
113 113
114 config->writeEntry("Current View",view); 114 config->writeEntry("Current View",view);
115 115
116 if (mAgendaView) { 116 if (mAgendaView) {
117 mAgendaView->writeSettings(config); 117 mAgendaView->writeSettings(config);
118 } 118 }
119 if (mTimeSpanView) { 119 if (mTimeSpanView) {
120 mTimeSpanView->writeSettings(config); 120 mTimeSpanView->writeSettings(config);
121 } 121 }
122 if (mListView) { 122 if (mListView) {
123 mListView->writeSettings(config); 123 mListView->writeSettings(config);
124 } 124 }
125 if (mTodoView) { 125 if (mTodoView) {
126 mTodoView->saveLayout(config,"Todo View"); 126 mTodoView->saveLayout(config,"Todo View");
127 } 127 }
128} 128}
129 129
130void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) 130void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen )
131{ 131{
132 132
133 //mFlagShowNextxDays = false; 133 //mFlagShowNextxDays = false;
134 //if(view == mCurrentView) return; 134 //if(view == mCurrentView) return;
135 if ( view == 0 ) { 135 if ( view == 0 ) {
136 view = mCurrentView; 136 view = mCurrentView;
137 if ( view == 0 ) 137 if ( view == 0 )
138 return; 138 return;
139 } 139 }
140 bool full = fullScreen; 140 bool full = fullScreen;
141 if(view == mCurrentView && view != mWhatsNextView ) { 141 if(view == mCurrentView && view != mWhatsNextView ) {
142 if ( mCurrentAgendaView < 0 ) 142 if ( mCurrentAgendaView < 0 )
143 return; 143 return;
144 full = mMainView->leftFrame()->isVisible(); 144 full = mMainView->leftFrame()->isVisible();
145 } else { 145 } else {
146 mCurrentView = view; 146 mCurrentView = view;
147 147
148 // bool full = fullScreen; 148 // bool full = fullScreen;
149 bool isFull = !mMainView->leftFrame()->isVisible(); 149 bool isFull = !mMainView->leftFrame()->isVisible();
150 if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) 150 if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen )
151 full = true; 151 full = true;
152 if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) 152 if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen )
153 full = false; 153 full = false;
154 } 154 }
155 if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); 155 if ( mAgendaView ) mAgendaView->deleteSelectedDateTime();
156 raiseCurrentView( full ); 156 //raiseCurrentView( full );
157 mMainView->processIncidenceSelection( 0 ); 157 mMainView->processIncidenceSelection( 0 );
158 mMainView->updateView(); 158 mMainView->updateView();
159 raiseCurrentView( full );
159 mMainView->adaptNavigationUnits(); 160 mMainView->adaptNavigationUnits();
160} 161}
161 162
162void KOViewManager::raiseCurrentView( bool fullScreen ) 163void KOViewManager::raiseCurrentView( bool fullScreen )
163{ 164{
164 //qDebug("raiseCurrentView "); 165 //qDebug("raiseCurrentView ");
165 mCurrentAgendaView = 0; 166 mCurrentAgendaView = 0;
166 int wid = mMainView->width() ; 167 int wid = mMainView->width() ;
167 int hei = mMainView->height(); 168 int hei = mMainView->height();
168 if ( mCurrentView == mMonthView ) { 169 if ( mCurrentView == mMonthView ) {
169 mMainView->navigatorBar()->show(); 170 mMainView->navigatorBar()->show();
170 hei -= mMainView->navigatorBar()->sizeHint().height(); 171 hei -= mMainView->navigatorBar()->sizeHint().height();
171 //mMainView->navigatorBar()->hide(); 172 //mMainView->navigatorBar()->hide();
172 } else { 173 } else {
173 mMainView->navigatorBar()->hide(); 174 mMainView->navigatorBar()->hide();
174 } 175 }
175 if ( fullScreen ) { 176 if ( fullScreen ) {
176 mMainView->leftFrame()->hide(); 177 mMainView->leftFrame()->hide();
177 } else { 178 } else {
178 mMainView->leftFrame()->show(); 179 mMainView->leftFrame()->show();
179 if ( KOPrefs::instance()->mVerticalScreen ) 180 if ( KOPrefs::instance()->mVerticalScreen )
180 hei -= mMainView->leftFrame()->height(); 181 hei -= mMainView->leftFrame()->height();
181 else 182 else
182 wid -= mMainView->leftFrame()->width(); 183 wid -= mMainView->leftFrame()->width();
183 } 184 }
184 185
185 if ( globalFlagBlockAgenda == 5 ) { 186 if ( globalFlagBlockAgenda == 5 ) {
186 globalFlagBlockAgenda = 4; 187 globalFlagBlockAgenda = 4;
187 globalFlagBlockAgendaItemPaint = 1; 188 globalFlagBlockAgendaItemPaint = 1;
188 } 189 }
189 mMainView->viewStack()->raiseWidget(mCurrentView); 190 mMainView->viewStack()->raiseWidget(mCurrentView);
190 if ( globalFlagBlockAgenda == 4 ) { 191 if ( globalFlagBlockAgenda == 4 ) {
191 if ( mCurrentView == mAgendaView ) { 192 if ( mCurrentView == mAgendaView ) {
192 //globalFlagBlockAgenda =1 ; 193 //globalFlagBlockAgenda =1 ;
193 if ( KOPrefs::instance()->mSetTimeToDayStartAt ) 194 if ( KOPrefs::instance()->mSetTimeToDayStartAt )
194 mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins ); 195 mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins );
195 else if ( KOPrefs::instance()->mCenterOnCurrentTime ) 196 else if ( KOPrefs::instance()->mCenterOnCurrentTime )
196 mAgendaView->setStartHour( QTime::currentTime ().hour() ); 197 mAgendaView->setStartHour( QTime::currentTime ().hour() );
197 qApp->processEvents(); 198 qApp->processEvents();
198 //qDebug("qApp->processEvents() "); 199 //qDebug("qApp->processEvents() ");
199 globalFlagBlockAgenda = 0; 200 globalFlagBlockAgenda = 0;
200 mAgendaView->repaintAgenda(); 201 mAgendaView->repaintAgenda();
201 202
202 } 203 }
203 globalFlagBlockAgenda = 0; 204 globalFlagBlockAgenda = 0;
204 } 205 }
205 //qDebug("raiseCurrentView ende "); 206 //qDebug("raiseCurrentView ende ");
206} 207}
207 208
208void KOViewManager::updateView() 209void KOViewManager::updateView()
209{ 210{
210 // qDebug("KOViewManager::updateView() "); 211 // qDebug("KOViewManager::updateView() ");
211 // if we are updating mTodoView, we get endless recursion 212 // if we are updating mTodoView, we get endless recursion
212 if ( mTodoView == mCurrentView ) 213 if ( mTodoView == mCurrentView )
213 return; 214 return;
214 if ( mCurrentView ) mCurrentView->updateView(); 215 if ( mCurrentView ) mCurrentView->updateView();
215 216
216} 217}
217 218
218void KOViewManager::updateView(const QDate &start, const QDate &end) 219void KOViewManager::updateView(const QDate &start, const QDate &end)
219{ 220{
220 // kdDebug() << "KOViewManager::updateView()" << endl; 221 // kdDebug() << "KOViewManager::updateView()" << endl;
221 222
222 if (mCurrentView) mCurrentView->showDates(start, end); 223 if (mCurrentView) mCurrentView->showDates(start, end);
223 224
224 if (mTodoView) mTodoView->updateView(); 225 if (mTodoView) mTodoView->updateView();
225} 226}
226 227
227 228
228void KOViewManager::updateWNview() 229void KOViewManager::updateWNview()
229{ 230{
230 if ( mCurrentView == mWhatsNextView && mWhatsNextView ) 231 if ( mCurrentView == mWhatsNextView && mWhatsNextView )
231 mWhatsNextView->updateView(); 232 mWhatsNextView->updateView();
232 233
233} 234}
234void KOViewManager::showWhatsNextView() 235void KOViewManager::showWhatsNextView()
235{ 236{
236 if (!mWhatsNextView) { 237 if (!mWhatsNextView) {
237 mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(), 238 mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(),
238 "KOViewManager::WhatsNextView"); 239 "KOViewManager::WhatsNextView");
239 mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog()); 240 mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog());
240 connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig())); 241 connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig()));
241 addView(mWhatsNextView); 242 addView(mWhatsNextView);
242 connect(this, SIGNAL( printWNV() ), 243 connect(this, SIGNAL( printWNV() ),
243 mWhatsNextView, SLOT( printMe() ) ); 244 mWhatsNextView, SLOT( printMe() ) );
244 } 245 }
245 globalFlagBlockAgenda = 1; 246 globalFlagBlockAgenda = 1;
246 showView(mWhatsNextView, true ); 247 showView(mWhatsNextView, true );
247 //mWhatsNextView->updateView(); 248 //mWhatsNextView->updateView();
248 249
249} 250}
250 251
251void KOViewManager::showListView() 252void KOViewManager::showListView()
252{ 253{
253 if (!mListView) { 254 if (!mListView) {
254 mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView"); 255 mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView");
255 addView(mListView); 256 addView(mListView);
256 257
257 connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)), 258 connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)),
258 mMainView, SLOT(showIncidence(Incidence *))); 259 mMainView, SLOT(showIncidence(Incidence *)));
259 connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)), 260 connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)),
260 mMainView, SLOT(editIncidence(Incidence *))); 261 mMainView, SLOT(editIncidence(Incidence *)));
261 connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)), 262 connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)),
262 mMainView, SLOT(deleteIncidence(Incidence *))); 263 mMainView, SLOT(deleteIncidence(Incidence *)));
263 connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ), 264 connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ),
264 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 265 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
265 connect( mListView, SIGNAL( signalNewEvent() ), 266 connect( mListView, SIGNAL( signalNewEvent() ),
266 mMainView, SLOT( newEvent() ) ); 267 mMainView, SLOT( newEvent() ) );
267 connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig())); 268 connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig()));
268 connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), 269 connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ),
269 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 270 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
270 connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), 271 connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ),
271 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 272 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
272 connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 273 connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
273 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 274 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
274 connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 275 connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
275 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 276 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
276 } 277 }
277 // bool temp = mFlagShowNextxDays; 278 // bool temp = mFlagShowNextxDays;
278 //globalFlagBlockPainting = true; 279 //globalFlagBlockPainting = true;
279 globalFlagBlockAgenda = 1; 280 globalFlagBlockAgenda = 1;
280 if ( KOPrefs::instance()->mListViewMonthTimespan ) { 281 if ( KOPrefs::instance()->mListViewMonthTimespan ) {
281 mMainView->setBlockShowDates( true ); 282 mMainView->setBlockShowDates( true );
282 mMainView->dateNavigator()->selectMonth(); 283 mMainView->dateNavigator()->selectMonth();
283 mMainView->setBlockShowDates( false ); 284 mMainView->setBlockShowDates( false );
284 } 285 }
285 showView(mListView, KOPrefs::instance()->mFullViewTodo); 286 showView(mListView, KOPrefs::instance()->mFullViewTodo);
286 //mFlagShowNextxDays = temp; 287 //mFlagShowNextxDays = temp;
287} 288}
288 289
289void KOViewManager::showAgendaView( bool fullScreen ) 290void KOViewManager::showAgendaView( bool fullScreen )
290{ 291{
291 292
292 mMainView->dialogManager()->hideSearchDialog(); 293 mMainView->dialogManager()->hideSearchDialog();
293 // qDebug("KOViewManager::showAgendaView "); 294 // qDebug("KOViewManager::showAgendaView ");
294 bool full; 295 bool full;
295 full = fullScreen; 296 full = fullScreen;
296 if (!mAgendaView) { 297 if (!mAgendaView) {
297 full = false; 298 full = false;
298 mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView"); 299 mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView");
299 addView(mAgendaView); 300 addView(mAgendaView);
300#ifndef DESKTOP_VERSION 301#ifndef DESKTOP_VERSION
301 QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold ); 302 QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold );
302#endif 303#endif
303 connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )), 304 connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )),
304 mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) )); 305 mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) ));
305 306
306 // SIGNALS/SLOTS FOR DAY/WEEK VIEW 307 // SIGNALS/SLOTS FOR DAY/WEEK VIEW
307 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)), 308 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)),
308 mMainView, SLOT(newEvent(QDateTime))); 309 mMainView, SLOT(newEvent(QDateTime)));
309 // connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)), 310 // connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)),
310 // mMainView, SLOT(newEvent(QDateTime,QDateTime))); 311 // mMainView, SLOT(newEvent(QDateTime,QDateTime)));
311 connect(mAgendaView,SIGNAL(newEventSignal(QDate)), 312 connect(mAgendaView,SIGNAL(newEventSignal(QDate)),
312 mMainView, SLOT(newEvent(QDate))); 313 mMainView, SLOT(newEvent(QDate)));
313 314
314 connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)), 315 connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)),
315 mMainView, SLOT(editIncidence(Incidence *))); 316 mMainView, SLOT(editIncidence(Incidence *)));
316 connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)), 317 connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)),
317 mMainView, SLOT(showIncidence(Incidence *))); 318 mMainView, SLOT(showIncidence(Incidence *)));
318 connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)), 319 connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)),
319 mMainView, SLOT(deleteIncidence(Incidence *))); 320 mMainView, SLOT(deleteIncidence(Incidence *)));
320 321
321 connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ), 322 connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ),
322 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 323 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
323 324
324 connect(mAgendaView, SIGNAL( toggleExpand() ), 325 connect(mAgendaView, SIGNAL( toggleExpand() ),
325 mMainView, SLOT( toggleExpand() ) ); 326 mMainView, SLOT( toggleExpand() ) );
326 327
327 connect(mMainView, SIGNAL( calendarViewExpanded( bool ) ), 328 connect(mMainView, SIGNAL( calendarViewExpanded( bool ) ),
328 mAgendaView, SLOT( setExpandedButton( bool ) ) ); 329 mAgendaView, SLOT( setExpandedButton( bool ) ) );
329 connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ), 330 connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ),
330 mMainView, SLOT(cloneIncidence(Incidence *) ) ) ; 331 mMainView, SLOT(cloneIncidence(Incidence *) ) ) ;
331 connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ), 332 connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ),
332 mMainView, SLOT(cancelIncidence(Incidence *) ) ) ; 333 mMainView, SLOT(cancelIncidence(Incidence *) ) ) ;
333 connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig())); 334 connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig()));
334 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView, 335 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView,
335 SLOT( updateTodo( Todo *, int ) ) ); 336 SLOT( updateTodo( Todo *, int ) ) );
336 connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )), 337 connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )),
337 mMainView, SIGNAL( todoModified( Todo *, int ))); 338 mMainView, SIGNAL( todoModified( Todo *, int )));
338 connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 339 connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
339 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 340 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
340 connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 341 connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
341 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 342 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
342 mAgendaView->readSettings(); 343 mAgendaView->readSettings();
343 mAgendaView->updateConfig(); 344 mAgendaView->updateConfig();
344 } 345 }
345 346
346 showView( mAgendaView, full); 347 showView( mAgendaView, full);
347 348
348} 349}
349 350
350void KOViewManager::showDayView() 351void KOViewManager::showDayView()
351{ 352{
352 mFlagShowNextxDays = false; 353 mFlagShowNextxDays = false;
353 globalFlagBlockLabel = 1; 354 globalFlagBlockLabel = 1;
354 globalFlagBlockAgenda = 1; 355 globalFlagBlockAgenda = 1;
355 if ( mCurrentAgendaView != 1 ) 356 if ( mCurrentAgendaView != 1 )
356 mCurrentAgendaView = -1; 357 mCurrentAgendaView = -1;
357 showAgendaView(); 358 showAgendaView();
358 qApp->processEvents(); 359 qApp->processEvents();
359 globalFlagBlockAgenda = 2; 360 globalFlagBlockAgenda = 2;
360 globalFlagBlockLabel = 0; 361 globalFlagBlockLabel = 0;
361 mMainView->dateNavigator()->selectDates( 1 ); 362 mMainView->dateNavigator()->selectDates( 1 );
362 mCurrentAgendaView = 1 ; 363 mCurrentAgendaView = 1 ;
363 364
364} 365}
365 366
366void KOViewManager::showWorkWeekView() 367void KOViewManager::showWorkWeekView()
367{ 368{
368 mFlagShowNextxDays = false; 369 mFlagShowNextxDays = false;
369 globalFlagBlockAgenda = 1; 370 globalFlagBlockAgenda = 1;
370 globalFlagBlockLabel = 1; 371 globalFlagBlockLabel = 1;
371 if ( mCurrentAgendaView != 5 ) 372 if ( mCurrentAgendaView != 5 )
372 mCurrentAgendaView = -1; 373 mCurrentAgendaView = -1;
373 showAgendaView(); 374 showAgendaView();
374 qApp->processEvents(); 375 qApp->processEvents();
375 globalFlagBlockAgenda = 2; 376 globalFlagBlockAgenda = 2;
376 globalFlagBlockLabel = 0; 377 globalFlagBlockLabel = 0;
377 mMainView->dateNavigator()->selectWorkWeek(); 378 mMainView->dateNavigator()->selectWorkWeek();
378 mCurrentAgendaView = 5 ; 379 mCurrentAgendaView = 5 ;
379 380
380} 381}
381 382
382void KOViewManager::showWeekView() 383void KOViewManager::showWeekView()
383{ 384{
384 /* 385 /*
385 globalFlagBlockAgenda = 2; 386 globalFlagBlockAgenda = 2;
386 qDebug("4globalFlagBlockAgenda = 2; "); 387 qDebug("4globalFlagBlockAgenda = 2; ");
387 //globalFlagBlockPainting = true; 388 //globalFlagBlockPainting = true;
388 mMainView->dateNavigator()->selectWeek(); 389 mMainView->dateNavigator()->selectWeek();
389 showAgendaView(); 390 showAgendaView();
390 */ 391 */
391 392
392 393
393 mFlagShowNextxDays = false; 394 mFlagShowNextxDays = false;
394 globalFlagBlockAgenda = 1; 395 globalFlagBlockAgenda = 1;
395 globalFlagBlockLabel = 1; 396 globalFlagBlockLabel = 1;
396 if ( mCurrentAgendaView != 7 ) 397 if ( mCurrentAgendaView != 7 )
397 mCurrentAgendaView = -1; 398 mCurrentAgendaView = -1;
398 showAgendaView(); 399 showAgendaView();
399 qApp->processEvents(); 400 qApp->processEvents();
400 globalFlagBlockAgenda = 2; 401 globalFlagBlockAgenda = 2;
401 globalFlagBlockLabel = 0; 402 globalFlagBlockLabel = 0;
402 mMainView->dateNavigator()->selectWeek(); 403 mMainView->dateNavigator()->selectWeek();
403 mCurrentAgendaView = 7 ; 404 mCurrentAgendaView = 7 ;
404} 405}
405 406
406void KOViewManager::showNextXView() 407void KOViewManager::showNextXView()
407{ 408{
408 409
409 globalFlagBlockAgenda = 1; 410 globalFlagBlockAgenda = 1;
410 if ( mCurrentAgendaView != 3 ) 411 if ( mCurrentAgendaView != 3 )
411 mCurrentAgendaView = -1; 412 mCurrentAgendaView = -1;
412 showAgendaView(KOPrefs::instance()->mFullViewMonth); 413 showAgendaView(KOPrefs::instance()->mFullViewMonth);
413 globalFlagBlockAgenda = 2; 414 globalFlagBlockAgenda = 2;
414 mMainView->dateNavigator()->selectDates( QDate::currentDate(), 415 mMainView->dateNavigator()->selectDates( QDate::currentDate(),
415 KOPrefs::instance()->mNextXDays ); 416 KOPrefs::instance()->mNextXDays );
416 mFlagShowNextxDays = true; 417 mFlagShowNextxDays = true;
417 mCurrentAgendaView = 3 ; 418 mCurrentAgendaView = 3 ;
418} 419}
419bool KOViewManager::showsNextDays() 420bool KOViewManager::showsNextDays()
420{ 421{
421 return mFlagShowNextxDays; 422 return mFlagShowNextxDays;
422} 423}
423void KOViewManager::showMonthView() 424void KOViewManager::showMonthView()
424{ 425{
425 if (!mMonthView) { 426 if (!mMonthView) {
426 mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView"); 427 mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView");
427 428
428 addView(mMonthView); 429 addView(mMonthView);
429 // mMonthView->show(); 430 // mMonthView->show();
430 // SIGNALS/SLOTS FOR MONTH VIEW 431 // SIGNALS/SLOTS FOR MONTH VIEW
431 connect(mMonthView, SIGNAL(newEventSignal(QDateTime)), 432 connect(mMonthView, SIGNAL(newEventSignal(QDateTime)),
432 mMainView, SLOT(newEvent(QDateTime))); 433 mMainView, SLOT(newEvent(QDateTime)));
433 434
434 connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)), 435 connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)),
435 mMainView, SLOT(showIncidence(Incidence *))); 436 mMainView, SLOT(showIncidence(Incidence *)));
436 connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)), 437 connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)),
437 mMainView, SLOT(editIncidence(Incidence *))); 438 mMainView, SLOT(editIncidence(Incidence *)));
438 connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)), 439 connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)),
439 mMainView, SLOT(deleteIncidence(Incidence *))); 440 mMainView, SLOT(deleteIncidence(Incidence *)));
440 441
441 connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ), 442 connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ),
442 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 443 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
443 connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), 444 connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ),
444 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 445 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
445 connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), 446 connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ),
446 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 447 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
447 448
448 connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 449 connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
449 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 450 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
450 connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 451 connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
451 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 452 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
452 connect( mMonthView, SIGNAL( selectWeekNum( int ) ), 453 connect( mMonthView, SIGNAL( selectWeekNum( int ) ),
453 mMainView, SLOT ( selectWeekNum( int ) ) ); 454 mMainView, SLOT ( selectWeekNum( int ) ) );
454 connect( mMonthView, SIGNAL( showDaySignal( QDate ) ), 455 connect( mMonthView, SIGNAL( showDaySignal( QDate ) ),
455 mMainView, SLOT ( showDay( QDate ) ) ); 456 mMainView, SLOT ( showDay( QDate ) ) );
456 connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig())); 457 connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig()));
457 mMonthView->updateConfig(); 458 mMonthView->updateConfig();
458 } 459 }
459 460
460 globalFlagBlockAgenda = 1; 461 globalFlagBlockAgenda = 1;
461 //mFlagShowNextxDays = false; 462 //mFlagShowNextxDays = false;
462 // if(mMonthView == mCurrentView) return; 463 // if(mMonthView == mCurrentView) return;
463 mMainView->dateNavigator()->selectMonth(); 464 mMainView->dateNavigator()->selectMonth();
464 // DateList tmpList = mMainView->dateNavigator()->selectedDates( ); 465 // DateList tmpList = mMainView->dateNavigator()->selectedDates( );
465 //mMonthView->showDates(tmpList.first(), tmpList.last()); 466 //mMonthView->showDates(tmpList.first(), tmpList.last());
466 467
467 showView(mMonthView, true ); 468 showView(mMonthView, true );
468 469
469} 470}
470 471
471void KOViewManager::showTodoView() 472void KOViewManager::showTodoView()
472{ 473{
473 //mFlagShowNextxDays = false; 474 //mFlagShowNextxDays = false;
474 if ( !mTodoView ) { 475 if ( !mTodoView ) {
475 mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(), 476 mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(),
476 "KOViewManager::TodoView" ); 477 "KOViewManager::TodoView" );
477 478
478 addView( mTodoView ); 479 addView( mTodoView );
479 // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold ); 480 // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold );
480 481
481 // SIGNALS/SLOTS FOR TODO VIEW 482 // SIGNALS/SLOTS FOR TODO VIEW
482 connect( mTodoView, SIGNAL( newTodoSignal() ), 483 connect( mTodoView, SIGNAL( newTodoSignal() ),
483 mMainView, SLOT( newTodo() ) ); 484 mMainView, SLOT( newTodo() ) );
484 connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ), 485 connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ),
485 mMainView, SLOT( newSubTodo( Todo *) ) ); 486 mMainView, SLOT( newSubTodo( Todo *) ) );
486 connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ), 487 connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ),
487 mMainView, SLOT( showTodo( Todo * ) ) ); 488 mMainView, SLOT( showTodo( Todo * ) ) );
488 connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ), 489 connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ),
489 mMainView, SLOT( editTodo( Todo * ) ) ); 490 mMainView, SLOT( editTodo( Todo * ) ) );
490 connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ), 491 connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ),
491 mMainView, SLOT( deleteTodo( Todo * ) ) ); 492 mMainView, SLOT( deleteTodo( Todo * ) ) );
492 connect( mTodoView, SIGNAL( purgeCompletedSignal() ), 493 connect( mTodoView, SIGNAL( purgeCompletedSignal() ),
493 mMainView, SLOT( purgeCompleted() ) ); 494 mMainView, SLOT( purgeCompleted() ) );
494 495
495 connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ), 496 connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ),
496 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 497 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
497 498
498 connect( mMainView, SIGNAL( configChanged() ), mTodoView, 499 connect( mMainView, SIGNAL( configChanged() ), mTodoView,
499 SLOT( updateConfig() ) ); 500 SLOT( updateConfig() ) );
500 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView, 501 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView,
501 SLOT( updateTodo( Todo *, int ) ) ); 502 SLOT( updateTodo( Todo *, int ) ) );
502 connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ), 503 connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ),
503 mMainView, SIGNAL ( todoModified( Todo *, int ) ) ); 504 mMainView, SIGNAL ( todoModified( Todo *, int ) ) );
504 connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ), 505 connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ),
505 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 506 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
506 connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ), 507 connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ),
507 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 508 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
508 connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ), 509 connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ),
509 mMainView, SLOT ( todo_unsub( Todo * ) ) ); 510 mMainView, SLOT ( todo_unsub( Todo * ) ) );
510 connect( mTodoView, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 511 connect( mTodoView, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
511 mMainView, SLOT ( todo_resub( Todo *, Todo *) ) ); 512 mMainView, SLOT ( todo_resub( Todo *, Todo *) ) );
512 connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ), 513 connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ),
513 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 514 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
514 connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ), 515 connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ),
515 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 516 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
516 KConfig *config = KOGlobals::config(); 517 KConfig *config = KOGlobals::config();
517 mTodoView->restoreLayout(config,"Todo View"); 518 mTodoView->restoreLayout(config,"Todo View");
518 mTodoView->setNavigator( mMainView->dateNavigator() ); 519 mTodoView->setNavigator( mMainView->dateNavigator() );
519 } 520 }
520 521
521 globalFlagBlockAgenda = 1; 522 globalFlagBlockAgenda = 1;
522 showView( mTodoView, true ); 523 showView( mTodoView, true );
523 524
524} 525}
525 526
526void KOViewManager::showJournalView() 527void KOViewManager::showJournalView()
527{ 528{
528 //mFlagShowNextxDays = false; 529 //mFlagShowNextxDays = false;
529 if (!mJournalView) { 530 if (!mJournalView) {
530 mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(), 531 mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(),
531 "KOViewManager::JournalView"); 532 "KOViewManager::JournalView");
532 connect( mMainView, SIGNAL( configChanged() ), mJournalView, 533 connect( mMainView, SIGNAL( configChanged() ), mJournalView,
533 SLOT( updateConfig() ) ); 534 SLOT( updateConfig() ) );
534 connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) ); 535 connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) );
535 addView(mJournalView); 536 addView(mJournalView);
536 } 537 }
537 538
538 showView(mJournalView); 539 showView(mJournalView);
539} 540}
540 541
541void KOViewManager::showTimeSpanView() 542void KOViewManager::showTimeSpanView()
542{ 543{
543 //mFlagShowNextxDays = false; 544 //mFlagShowNextxDays = false;
544 if (!mTimeSpanView) { 545 if (!mTimeSpanView) {
545 mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(), 546 mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(),
546 "KOViewManager::TimeSpanView"); 547 "KOViewManager::TimeSpanView");
547 addView(mTimeSpanView); 548 addView(mTimeSpanView);
548 549
549 mTimeSpanView->readSettings(); 550 mTimeSpanView->readSettings();
550 } 551 }
551 552
552 showView(mTimeSpanView); 553 showView(mTimeSpanView);
553} 554}
554 555
555Incidence *KOViewManager::currentSelection() 556Incidence *KOViewManager::currentSelection()
556{ 557{
557 if (!mCurrentView) return 0; 558 if (!mCurrentView) return 0;
558 if ( mCurrentView == mListView ) { 559 if ( mCurrentView == mListView ) {
559 if ( mListView->currentItem() ) 560 if ( mListView->currentItem() )
560 return mListView->currentItem(); 561 return mListView->currentItem();
561 } 562 }
562 return mCurrentView->selectedIncidences().first(); 563 return mCurrentView->selectedIncidences().first();
563} 564}
564 565
565QDate KOViewManager::currentSelectionDate() 566QDate KOViewManager::currentSelectionDate()
566{ 567{
567 QDate qd; 568 QDate qd;
568 if (mCurrentView) { 569 if (mCurrentView) {
569 DateList qvl = mCurrentView->selectedDates(); 570 DateList qvl = mCurrentView->selectedDates();
570 if (!qvl.isEmpty()) qd = qvl.first(); 571 if (!qvl.isEmpty()) qd = qvl.first();
571 } 572 }
572 return qd; 573 return qd;
573} 574}
574 575
575void KOViewManager::addView(KOrg::BaseView *view) 576void KOViewManager::addView(KOrg::BaseView *view)
576{ 577{
577#if QT_VERSION >= 300 578#if QT_VERSION >= 300
578 mMainView->viewStack()->addWidget( view ); 579 mMainView->viewStack()->addWidget( view );
579#else 580#else
580 mMainView->viewStack()->addWidget( view, 1 ); 581 mMainView->viewStack()->addWidget( view, 1 );
581#endif 582#endif
582} 583}
583 584
584void KOViewManager::setDocumentId( const QString &id ) 585void KOViewManager::setDocumentId( const QString &id )
585{ 586{
586 if (mTodoView) mTodoView->setDocumentId( id ); 587 if (mTodoView) mTodoView->setDocumentId( id );
587} 588}