summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp33
-rw-r--r--korganizer/calendarview.h4
-rw-r--r--korganizer/komonthview.cpp55
-rw-r--r--korganizer/komonthview.h6
-rw-r--r--korganizer/koviewmanager.cpp41
-rw-r--r--korganizer/navigatorbar.cpp1
6 files changed, 55 insertions, 85 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 77de94f..0fbaa9a 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,3939 +1,3908 @@
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" );
289 rightLayout->addWidget( mNavigatorBar );
290
291 mRightFrame = new QWidgetStack( rightBox ); 288 mRightFrame = new QWidgetStack( rightBox );
292 rightLayout->addWidget( mRightFrame, 1 ); 289 rightLayout->addWidget( mRightFrame, 1 );
293 290
294 mLeftFrame = mLeftSplitter; 291 mLeftFrame = mLeftSplitter;
295#else 292#else
296 QWidget *mainBox = new QWidget( this ); 293 QWidget *mainBox = new QWidget( this );
297 QWidget *leftFrame = new QWidget( mainBox ); 294 QWidget *leftFrame = new QWidget( mainBox );
298 295
299 QBoxLayout * mainBoxLayout; 296 QBoxLayout * mainBoxLayout;
300 QBoxLayout * leftFrameLayout; 297 QBoxLayout * leftFrameLayout;
301 if ( KOPrefs::instance()->mVerticalScreen ) { 298 if ( KOPrefs::instance()->mVerticalScreen ) {
302 mainBoxLayout = new QVBoxLayout(mainBox); 299 mainBoxLayout = new QVBoxLayout(mainBox);
303 leftFrameLayout = new QHBoxLayout(leftFrame ); 300 leftFrameLayout = new QHBoxLayout(leftFrame );
304 } else { 301 } else {
305 mainBoxLayout = new QHBoxLayout(mainBox); 302 mainBoxLayout = new QHBoxLayout(mainBox);
306 leftFrameLayout = new QVBoxLayout(leftFrame ); 303 leftFrameLayout = new QVBoxLayout(leftFrame );
307 } 304 }
308 topLayout->addWidget( mainBox ); 305 topLayout->addWidget( mainBox );
309 mainBoxLayout->addWidget (leftFrame); 306 mainBoxLayout->addWidget (leftFrame);
310 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, 307 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE,
311 "CalendarView::DateNavigator", QDate::currentDate()); 308 "CalendarView::DateNavigator", QDate::currentDate());
312 // mDateNavigator->blockSignals( true ); 309 // mDateNavigator->blockSignals( true );
313 leftFrameLayout->addWidget( mDateNavigator ); 310 leftFrameLayout->addWidget( mDateNavigator );
314 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); 311 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView");
315 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall"); 312 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall");
316 mTodoList->setNavigator( mNavigator ); 313 mTodoList->setNavigator( mNavigator );
317 314
318 if ( QApplication::desktop()->width() < 480 ) { 315 if ( QApplication::desktop()->width() < 480 ) {
319 leftFrameLayout->addWidget(mFilterView); 316 leftFrameLayout->addWidget(mFilterView);
320 leftFrameLayout->addWidget(mTodoList, 2 ); 317 leftFrameLayout->addWidget(mTodoList, 2 );
321 318
322 } else { 319 } else {
323 leftFrameLayout->addWidget(mTodoList,2 ); 320 leftFrameLayout->addWidget(mTodoList,2 );
324 leftFrameLayout->addWidget(mFilterView ); 321 leftFrameLayout->addWidget(mFilterView );
325 } 322 }
326 mFilterView->hide(); 323 mFilterView->hide();
327 QWidget *rightBox = new QWidget( mainBox ); 324 QWidget *rightBox = new QWidget( mainBox );
328 mainBoxLayout->addWidget ( rightBox, 10 ); 325 mainBoxLayout->addWidget ( rightBox, 10 );
329 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 326 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
330 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
331 mRightFrame = new QWidgetStack( rightBox ); 327 mRightFrame = new QWidgetStack( rightBox );
332 rightLayout->addWidget( mNavigatorBar );
333 rightLayout->addWidget( mRightFrame, 10 ); 328 rightLayout->addWidget( mRightFrame, 10 );
334 329
335 mLeftFrame = leftFrame; 330 mLeftFrame = leftFrame;
336 if ( KOPrefs::instance()->mVerticalScreen ) { 331 if ( KOPrefs::instance()->mVerticalScreen ) {
337 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 332 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
338 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 333 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
339 } else { 334 } else {
340 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 335 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
341 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 336 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
342 } 337 }
343 if ( !KOPrefs::instance()->mShowDateNavigator) 338 if ( !KOPrefs::instance()->mShowDateNavigator)
344 mDateNavigator->hide(); 339 mDateNavigator->hide();
345 //qDebug("Calendarview Size %d %d ", width(), height()); 340 //qDebug("Calendarview Size %d %d ", width(), height());
346#endif 341#endif
347 342
348 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 343 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
349 SLOT( showDates( const KCal::DateList & ) ) ); 344 SLOT( showDates( const KCal::DateList & ) ) );
350 345
351 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 346 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
352 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 347 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
353 connect( mNavigatorBar, SIGNAL( goPrevYear() ), 348
354 mNavigator, SLOT( selectPreviousYear() ) );
355 connect( mNavigatorBar, SIGNAL( goNextYear() ),
356 mNavigator, SLOT( selectNextYear() ) );
357 connect( mNavigatorBar, SIGNAL( goPrevMonth() ),
358 mNavigator, SLOT( selectPreviousMonth() ) );
359 connect( mNavigatorBar, SIGNAL( goNextMonth() ),
360 mNavigator, SLOT( selectNextMonth() ) );
361 connect( mNavigatorBar, SIGNAL( selectWeek( int ) ),
362 mNavigator, SLOT( selectWeek( int ) ) );
363
364 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
365 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) );
366 349
367 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 350 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
368 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 351 mNavigator, SLOT( selectWeek( const QDate & ) ) );
369 352
370 connect( mDateNavigator, SIGNAL( goPrevYear() ), 353 connect( mDateNavigator, SIGNAL( goPrevYear() ),
371 mNavigator, SLOT( selectPreviousYear() ) ); 354 mNavigator, SLOT( selectPreviousYear() ) );
372 connect( mDateNavigator, SIGNAL( goNextYear() ), 355 connect( mDateNavigator, SIGNAL( goNextYear() ),
373 mNavigator, SLOT( selectNextYear() ) ); 356 mNavigator, SLOT( selectNextYear() ) );
374 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 357 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
375 mNavigator, SLOT( selectPreviousMonth() ) ); 358 mNavigator, SLOT( selectPreviousMonth() ) );
376 connect( mDateNavigator, SIGNAL( goNextMonth() ), 359 connect( mDateNavigator, SIGNAL( goNextMonth() ),
377 mNavigator, SLOT( selectNextMonth() ) ); 360 mNavigator, SLOT( selectNextMonth() ) );
378 361
379 connect( mDateNavigator, SIGNAL( goPrevious() ), 362 connect( mDateNavigator, SIGNAL( goPrevious() ),
380 mNavigator, SLOT( selectPrevious() ) ); 363 mNavigator, SLOT( selectPrevious() ) );
381 connect( mDateNavigator, SIGNAL( goNext() ), 364 connect( mDateNavigator, SIGNAL( goNext() ),
382 mNavigator, SLOT( selectNext() ) ); 365 mNavigator, SLOT( selectNext() ) );
383 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 366 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
384 mNavigator, SLOT( slotMonthSelect( int ) ) ); 367 mNavigator, SLOT( slotMonthSelect( int ) ) );
385 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ),
386 mNavigator, SLOT( slotMonthSelect( int ) ) );
387 368
388 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 369 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
389 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 370 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
390 371
391 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), 372 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ),
392 SLOT( eventAdded( Event *) ) ); 373 SLOT( eventAdded( Event *) ) );
393 374
394 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 375 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
395 376
396 connect( this, SIGNAL( configChanged() ), 377 connect( this, SIGNAL( configChanged() ),
397 mDateNavigator, SLOT( updateConfig() ) ); 378 mDateNavigator, SLOT( updateConfig() ) );
398 379
399 connect( mTodoList, SIGNAL( newTodoSignal() ), 380 connect( mTodoList, SIGNAL( newTodoSignal() ),
400 SLOT( newTodo() ) ); 381 SLOT( newTodo() ) );
401 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 382 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
402 SLOT( newSubTodo( Todo * ) ) ); 383 SLOT( newSubTodo( Todo * ) ) );
403 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 384 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
404 SLOT( editTodo( Todo * ) ) ); 385 SLOT( editTodo( Todo * ) ) );
405 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 386 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
406 SLOT( showTodo( Todo *) ) ); 387 SLOT( showTodo( Todo *) ) );
407 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 388 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
408 SLOT( deleteTodo( Todo *) ) ); 389 SLOT( deleteTodo( Todo *) ) );
409 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 390 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
410 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 391 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
411 SLOT( purgeCompleted() ) ); 392 SLOT( purgeCompleted() ) );
412 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 393 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
413 SIGNAL( todoModified( Todo *, int ) ) ); 394 SIGNAL( todoModified( Todo *, int ) ) );
414 395
415 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 396 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
416 this, SLOT ( cloneIncidence( Incidence * ) ) ); 397 this, SLOT ( cloneIncidence( Incidence * ) ) );
417 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 398 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
418 this, SLOT (cancelIncidence( Incidence * ) ) ); 399 this, SLOT (cancelIncidence( Incidence * ) ) );
419 400
420 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 401 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
421 this, SLOT ( moveIncidence( Incidence * ) ) ); 402 this, SLOT ( moveIncidence( Incidence * ) ) );
422 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 403 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
423 this, SLOT ( beamIncidence( Incidence * ) ) ); 404 this, SLOT ( beamIncidence( Incidence * ) ) );
424 405
425 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 406 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
426 this, SLOT ( todo_unsub( Todo * ) ) ); 407 this, SLOT ( todo_unsub( Todo * ) ) );
427 408
428 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 409 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
429 this, SLOT ( todo_resub( Todo *,Todo * ) ) ); 410 this, SLOT ( todo_resub( Todo *,Todo * ) ) );
430 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 411 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
431 SLOT( updateTodo( Todo *, int ) ) ); 412 SLOT( updateTodo( Todo *, int ) ) );
432 connect( this, SIGNAL( todoModified( Todo *, int )), this, 413 connect( this, SIGNAL( todoModified( Todo *, int )), this,
433 SLOT( changeTodoDisplay( Todo *, int ) ) ); 414 SLOT( changeTodoDisplay( Todo *, int ) ) );
434 415
435 416
436 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 417 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
437 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 418 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
438 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 419 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
439 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 420 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
440 421
441 422
442 423
443 424
444 425
445 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 426 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
446 SLOT(checkClipboard())); 427 SLOT(checkClipboard()));
447 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 428 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
448 SLOT( processTodoListSelection( Incidence * ) ) ); 429 SLOT( processTodoListSelection( Incidence * ) ) );
449 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 430 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
450 431
451 // kdDebug() << "CalendarView::CalendarView() done" << endl; 432 // kdDebug() << "CalendarView::CalendarView() done" << endl;
452 433
453 mDateFrame = new QVBox(0,0,WType_Popup); 434 mDateFrame = new QVBox(0,0,WType_Popup);
454 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 435 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
455 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 436 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
456 mDateFrame->setLineWidth(3); 437 mDateFrame->setLineWidth(3);
457 mDateFrame->hide(); 438 mDateFrame->hide();
458 mDateFrame->setCaption( i18n( "Pick a date to display")); 439 mDateFrame->setCaption( i18n( "Pick a date to display"));
459 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 440 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
460 441
461 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 442 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
462 443
463 mEventEditor = mDialogManager->getEventEditor(); 444 mEventEditor = mDialogManager->getEventEditor();
464 mTodoEditor = mDialogManager->getTodoEditor(); 445 mTodoEditor = mDialogManager->getTodoEditor();
465 446
466 mFlagEditDescription = false; 447 mFlagEditDescription = false;
467 448
468 mSuspendTimer = new QTimer( this ); 449 mSuspendTimer = new QTimer( this );
469 mAlarmTimer = new QTimer( this ); 450 mAlarmTimer = new QTimer( this );
470 mRecheckAlarmTimer = new QTimer( this ); 451 mRecheckAlarmTimer = new QTimer( this );
471 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 452 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
472 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 453 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
473 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 454 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
474 mAlarmDialog = new AlarmDialog( this ); 455 mAlarmDialog = new AlarmDialog( this );
475 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 456 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
476 mAlarmDialog->setServerNotification( false ); 457 mAlarmDialog->setServerNotification( false );
477 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 458 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
478 459
479 460
480#ifndef DESKTOP_VERSION 461#ifndef DESKTOP_VERSION
481//US listen for arriving address resultsets 462//US listen for arriving address resultsets
482 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), 463 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)),
483 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 464 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
484#endif 465#endif
485 466
486} 467}
487 468
488 469
489CalendarView::~CalendarView() 470CalendarView::~CalendarView()
490{ 471{
491 // kdDebug() << "~CalendarView()" << endl; 472 // kdDebug() << "~CalendarView()" << endl;
492 //qDebug("CalendarView::~CalendarView() "); 473 //qDebug("CalendarView::~CalendarView() ");
493 delete mDialogManager; 474 delete mDialogManager;
494 delete mViewManager; 475 delete mViewManager;
495 delete mStorage; 476 delete mStorage;
496 delete mDateFrame ; 477 delete mDateFrame ;
497 delete beamDialog; 478 delete beamDialog;
498 //kdDebug() << "~CalendarView() done" << endl; 479 //kdDebug() << "~CalendarView() done" << endl;
499} 480}
500 481
501void CalendarView::showDay( QDate d ) 482void CalendarView::showDay( QDate d )
502{ 483{
503 dateNavigator()->blockSignals( true ); 484 dateNavigator()->blockSignals( true );
504 dateNavigator()->selectDate( d ); 485 dateNavigator()->selectDate( d );
505 dateNavigator()->blockSignals( false ); 486 dateNavigator()->blockSignals( false );
506 mViewManager->showDayView(); 487 mViewManager->showDayView();
507 //dateNavigator()->selectDate( d ); 488 //dateNavigator()->selectDate( d );
508} 489}
509void CalendarView::timerAlarm() 490void CalendarView::timerAlarm()
510{ 491{
511 //qDebug("CalendarView::timerAlarm() "); 492 //qDebug("CalendarView::timerAlarm() ");
512 computeAlarm(mAlarmNotification ); 493 computeAlarm(mAlarmNotification );
513} 494}
514 495
515void CalendarView::suspendAlarm() 496void CalendarView::suspendAlarm()
516{ 497{
517 //qDebug(" CalendarView::suspendAlarm() "); 498 //qDebug(" CalendarView::suspendAlarm() ");
518 computeAlarm(mSuspendAlarmNotification ); 499 computeAlarm(mSuspendAlarmNotification );
519 500
520} 501}
521 502
522void CalendarView::startAlarm( QString mess , QString filename) 503void CalendarView::startAlarm( QString mess , QString filename)
523{ 504{
524 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 505 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
525 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); 506 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
526 507
527} 508}
528 509
529void CalendarView::checkNextTimerAlarm() 510void CalendarView::checkNextTimerAlarm()
530{ 511{
531 mCalendar->checkAlarmForIncidence( 0, true ); 512 mCalendar->checkAlarmForIncidence( 0, true );
532} 513}
533 514
534void CalendarView::computeAlarm( QString msg ) 515void CalendarView::computeAlarm( QString msg )
535{ 516{
536 517
537 QString mess = msg; 518 QString mess = msg;
538 QString mAlarmMessage = mess.mid( 9 ); 519 QString mAlarmMessage = mess.mid( 9 );
539 QString filename = MainWindow::resourcePath(); 520 QString filename = MainWindow::resourcePath();
540 filename += "koalarm.wav"; 521 filename += "koalarm.wav";
541 QString tempfilename; 522 QString tempfilename;
542 if ( mess.left( 13 ) == "suspend_alarm") { 523 if ( mess.left( 13 ) == "suspend_alarm") {
543 bool error = false; 524 bool error = false;
544 int len = mess.mid( 13 ).find("+++"); 525 int len = mess.mid( 13 ).find("+++");
545 if ( len < 2 ) 526 if ( len < 2 )
546 error = true; 527 error = true;
547 else { 528 else {
548 tempfilename = mess.mid( 13, len ); 529 tempfilename = mess.mid( 13, len );
549 if ( !QFile::exists( tempfilename ) ) 530 if ( !QFile::exists( tempfilename ) )
550 error = true; 531 error = true;
551 } 532 }
552 if ( ! error ) { 533 if ( ! error ) {
553 filename = tempfilename; 534 filename = tempfilename;
554 } 535 }
555 mAlarmMessage = mess.mid( 13+len+3 ); 536 mAlarmMessage = mess.mid( 13+len+3 );
556 //qDebug("suspend file %s ",tempfilename.latin1() ); 537 //qDebug("suspend file %s ",tempfilename.latin1() );
557 startAlarm( mAlarmMessage, filename); 538 startAlarm( mAlarmMessage, filename);
558 return; 539 return;
559 } 540 }
560 if ( mess.left( 11 ) == "timer_alarm") { 541 if ( mess.left( 11 ) == "timer_alarm") {
561 //mTimerTime = 0; 542 //mTimerTime = 0;
562 startAlarm( mess.mid( 11 ), filename ); 543 startAlarm( mess.mid( 11 ), filename );
563 return; 544 return;
564 } 545 }
565 if ( mess.left( 10 ) == "proc_alarm") { 546 if ( mess.left( 10 ) == "proc_alarm") {
566 bool error = false; 547 bool error = false;
567 int len = mess.mid( 10 ).find("+++"); 548 int len = mess.mid( 10 ).find("+++");
568 if ( len < 2 ) 549 if ( len < 2 )
569 error = true; 550 error = true;
570 else { 551 else {
571 tempfilename = mess.mid( 10, len ); 552 tempfilename = mess.mid( 10, len );
572 if ( !QFile::exists( tempfilename ) ) 553 if ( !QFile::exists( tempfilename ) )
573 error = true; 554 error = true;
574 } 555 }
575 if ( error ) { 556 if ( error ) {
576 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 557 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
577 mAlarmMessage += mess.mid( 10+len+3+9 ); 558 mAlarmMessage += mess.mid( 10+len+3+9 );
578 } else { 559 } else {
579 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 560 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
580 //qDebug("-----system command %s ",tempfilename.latin1() ); 561 //qDebug("-----system command %s ",tempfilename.latin1() );
581#ifndef _WIN32_ 562#ifndef _WIN32_
582 if ( vfork () == 0 ) { 563 if ( vfork () == 0 ) {
583 execl ( tempfilename.latin1(), 0 ); 564 execl ( tempfilename.latin1(), 0 );
584 return; 565 return;
585 } 566 }
586#else 567#else
587 QProcess* p = new QProcess(); 568 QProcess* p = new QProcess();
588 p->addArgument( tempfilename.latin1() ); 569 p->addArgument( tempfilename.latin1() );
589 p->start(); 570 p->start();
590 return; 571 return;
591#endif 572#endif
592 573
593 return; 574 return;
594 } 575 }
595 576
596 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 577 //qDebug("+++++++system command %s ",tempfilename.latin1() );
597 } 578 }
598 if ( mess.left( 11 ) == "audio_alarm") { 579 if ( mess.left( 11 ) == "audio_alarm") {
599 bool error = false; 580 bool error = false;
600 int len = mess.mid( 11 ).find("+++"); 581 int len = mess.mid( 11 ).find("+++");
601 if ( len < 2 ) 582 if ( len < 2 )
602 error = true; 583 error = true;
603 else { 584 else {
604 tempfilename = mess.mid( 11, len ); 585 tempfilename = mess.mid( 11, len );
605 if ( !QFile::exists( tempfilename ) ) 586 if ( !QFile::exists( tempfilename ) )
606 error = true; 587 error = true;
607 } 588 }
608 if ( ! error ) { 589 if ( ! error ) {
609 filename = tempfilename; 590 filename = tempfilename;
610 } 591 }
611 mAlarmMessage = mess.mid( 11+len+3+9 ); 592 mAlarmMessage = mess.mid( 11+len+3+9 );
612 //qDebug("audio file command %s ",tempfilename.latin1() ); 593 //qDebug("audio file command %s ",tempfilename.latin1() );
613 } 594 }
614 if ( mess.left( 9 ) == "cal_alarm") { 595 if ( mess.left( 9 ) == "cal_alarm") {
615 mAlarmMessage = mess.mid( 9 ) ; 596 mAlarmMessage = mess.mid( 9 ) ;
616 } 597 }
617 598
618 startAlarm( mAlarmMessage, filename ); 599 startAlarm( mAlarmMessage, filename );
619 600
620 601
621} 602}
622 603
623void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 604void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
624{ 605{
625 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 606 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
626 607
627 mSuspendAlarmNotification = noti; 608 mSuspendAlarmNotification = noti;
628 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 609 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
629 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 610 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
630 mSuspendTimer->start( ms , true ); 611 mSuspendTimer->start( ms , true );
631 612
632} 613}
633 614
634void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 615void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
635{ 616{
636 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 617 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
637 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 618 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
638#ifndef DESKTOP_VERSION 619#ifndef DESKTOP_VERSION
639 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); 620 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() );
640#endif 621#endif
641 return; 622 return;
642 } 623 }
643 int maxSec; 624 int maxSec;
644 //maxSec = 5; //testing only 625 //maxSec = 5; //testing only
645 maxSec = 86400+3600; // one day+1hour 626 maxSec = 86400+3600; // one day+1hour
646 mAlarmNotification = noti; 627 mAlarmNotification = noti;
647 int sec = QDateTime::currentDateTime().secsTo( qdt ); 628 int sec = QDateTime::currentDateTime().secsTo( qdt );
648 if ( sec > maxSec ) { 629 if ( sec > maxSec ) {
649 mRecheckAlarmTimer->start( maxSec * 1000 ); 630 mRecheckAlarmTimer->start( maxSec * 1000 );
650 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 631 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
651 return; 632 return;
652 } else { 633 } else {
653 mRecheckAlarmTimer->stop(); 634 mRecheckAlarmTimer->stop();
654 } 635 }
655 //qDebug("Alarm timer started with secs: %d ", sec); 636 //qDebug("Alarm timer started with secs: %d ", sec);
656 mAlarmTimer->start( sec *1000 , true ); 637 mAlarmTimer->start( sec *1000 , true );
657 638
658} 639}
659// called by mRecheckAlarmTimer to get next alarm 640// called by mRecheckAlarmTimer to get next alarm
660// we need this, because a QTimer has only a max range of 25 days 641// we need this, because a QTimer has only a max range of 25 days
661void CalendarView::recheckTimerAlarm() 642void CalendarView::recheckTimerAlarm()
662{ 643{
663 mAlarmTimer->stop(); 644 mAlarmTimer->stop();
664 mRecheckAlarmTimer->stop(); 645 mRecheckAlarmTimer->stop();
665 mCalendar->checkAlarmForIncidence( 0, true ); 646 mCalendar->checkAlarmForIncidence( 0, true );
666} 647}
667void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 648void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
668{ 649{
669 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 650 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
670 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 651 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
671#ifndef DESKTOP_VERSION 652#ifndef DESKTOP_VERSION
672 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 653 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
673#endif 654#endif
674 return; 655 return;
675 } 656 }
676 mAlarmTimer->stop(); 657 mAlarmTimer->stop();
677} 658}
678void CalendarView::selectWeekNum ( int num ) 659void CalendarView::selectWeekNum ( int num )
679{ 660{
680 dateNavigator()->blockSignals( true ); 661 dateNavigator()->blockSignals( true );
681 dateNavigator()->selectWeek( num ); 662 dateNavigator()->selectWeek( num );
682 dateNavigator()->blockSignals( false ); 663 dateNavigator()->blockSignals( false );
683 mViewManager->showWeekView(); 664 mViewManager->showWeekView();
684} 665}
685KOViewManager *CalendarView::viewManager() 666KOViewManager *CalendarView::viewManager()
686{ 667{
687 return mViewManager; 668 return mViewManager;
688} 669}
689 670
690KODialogManager *CalendarView::dialogManager() 671KODialogManager *CalendarView::dialogManager()
691{ 672{
692 return mDialogManager; 673 return mDialogManager;
693} 674}
694 675
695QDate CalendarView::startDate() 676QDate CalendarView::startDate()
696{ 677{
697 DateList dates = mNavigator->selectedDates(); 678 DateList dates = mNavigator->selectedDates();
698 679
699 return dates.first(); 680 return dates.first();
700} 681}
701 682
702QDate CalendarView::endDate() 683QDate CalendarView::endDate()
703{ 684{
704 DateList dates = mNavigator->selectedDates(); 685 DateList dates = mNavigator->selectedDates();
705 686
706 return dates.last(); 687 return dates.last();
707} 688}
708 689
709 690
710void CalendarView::createPrinter() 691void CalendarView::createPrinter()
711{ 692{
712#ifndef KORG_NOPRINTER 693#ifndef KORG_NOPRINTER
713 if (!mCalPrinter) { 694 if (!mCalPrinter) {
714 mCalPrinter = new CalPrinter(this, mCalendar); 695 mCalPrinter = new CalPrinter(this, mCalendar);
715 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 696 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
716 } 697 }
717#endif 698#endif
718} 699}
719 700
720 701
721//KOPrefs::instance()->mWriteBackFile 702//KOPrefs::instance()->mWriteBackFile
722//KOPrefs::instance()->mWriteBackExistingOnly 703//KOPrefs::instance()->mWriteBackExistingOnly
723 704
724// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 705// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
725// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 706// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
726// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 707// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
727// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 708// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
728// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 709// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
729// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 710// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
730 711
731int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 712int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
732{ 713{
733 714
734 // 0 equal 715 // 0 equal
735 // 1 take local 716 // 1 take local
736 // 2 take remote 717 // 2 take remote
737 // 3 cancel 718 // 3 cancel
738 QDateTime lastSync = mLastCalendarSync; 719 QDateTime lastSync = mLastCalendarSync;
739 QDateTime localMod = local->lastModified(); 720 QDateTime localMod = local->lastModified();
740 QDateTime remoteMod = remote->lastModified(); 721 QDateTime remoteMod = remote->lastModified();
741 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 722 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
742 bool remCh, locCh; 723 bool remCh, locCh;
743 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 724 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
744 //if ( remCh ) 725 //if ( remCh )
745 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 726 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
746 locCh = ( localMod > mLastCalendarSync ); 727 locCh = ( localMod > mLastCalendarSync );
747 if ( !remCh && ! locCh ) { 728 if ( !remCh && ! locCh ) {
748 //qDebug("both not changed "); 729 //qDebug("both not changed ");
749 lastSync = localMod.addDays(1); 730 lastSync = localMod.addDays(1);
750 if ( mode <= SYNC_PREF_ASK ) 731 if ( mode <= SYNC_PREF_ASK )
751 return 0; 732 return 0;
752 } else { 733 } else {
753 if ( locCh ) { 734 if ( locCh ) {
754 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); 735 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1());
755 lastSync = localMod.addDays( -1 ); 736 lastSync = localMod.addDays( -1 );
756 if ( !remCh ) 737 if ( !remCh )
757 remoteMod = ( lastSync.addDays( -1 ) ); 738 remoteMod = ( lastSync.addDays( -1 ) );
758 } else { 739 } else {
759 //qDebug(" not loc changed "); 740 //qDebug(" not loc changed ");
760 lastSync = localMod.addDays( 1 ); 741 lastSync = localMod.addDays( 1 );
761 if ( remCh ) 742 if ( remCh )
762 remoteMod =( lastSync.addDays( 1 ) ); 743 remoteMod =( lastSync.addDays( 1 ) );
763 744
764 } 745 }
765 } 746 }
766 full = true; 747 full = true;
767 if ( mode < SYNC_PREF_ASK ) 748 if ( mode < SYNC_PREF_ASK )
768 mode = SYNC_PREF_ASK; 749 mode = SYNC_PREF_ASK;
769 } else { 750 } else {
770 if ( localMod == remoteMod ) 751 if ( localMod == remoteMod )
771 // if ( local->revision() == remote->revision() ) 752 // if ( local->revision() == remote->revision() )
772 return 0; 753 return 0;
773 754
774 } 755 }
775 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 756 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
776 757
777 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); 758 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision());
778 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); 759 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() );
779 //full = true; //debug only 760 //full = true; //debug only
780 if ( full ) { 761 if ( full ) {
781 bool equ = false; 762 bool equ = false;
782 if ( local->type() == "Event" ) { 763 if ( local->type() == "Event" ) {
783 equ = (*((Event*) local) == *((Event*) remote)); 764 equ = (*((Event*) local) == *((Event*) remote));
784 } 765 }
785 else if ( local->type() =="Todo" ) 766 else if ( local->type() =="Todo" )
786 equ = (*((Todo*) local) == (*(Todo*) remote)); 767 equ = (*((Todo*) local) == (*(Todo*) remote));
787 else if ( local->type() =="Journal" ) 768 else if ( local->type() =="Journal" )
788 equ = (*((Journal*) local) == *((Journal*) remote)); 769 equ = (*((Journal*) local) == *((Journal*) remote));
789 if ( equ ) { 770 if ( equ ) {
790 //qDebug("equal "); 771 //qDebug("equal ");
791 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 772 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
792 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 773 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
793 } 774 }
794 if ( mode < SYNC_PREF_FORCE_LOCAL ) 775 if ( mode < SYNC_PREF_FORCE_LOCAL )
795 return 0; 776 return 0;
796 777
797 }//else //debug only 778 }//else //debug only
798 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 779 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
799 } 780 }
800 int result; 781 int result;
801 bool localIsNew; 782 bool localIsNew;
802 //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() ); 783 //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() );
803 784
804 if ( full && mode < SYNC_PREF_NEWEST ) 785 if ( full && mode < SYNC_PREF_NEWEST )
805 mode = SYNC_PREF_ASK; 786 mode = SYNC_PREF_ASK;
806 787
807 switch( mode ) { 788 switch( mode ) {
808 case SYNC_PREF_LOCAL: 789 case SYNC_PREF_LOCAL:
809 if ( lastSync > remoteMod ) 790 if ( lastSync > remoteMod )
810 return 1; 791 return 1;
811 if ( lastSync > localMod ) 792 if ( lastSync > localMod )
812 return 2; 793 return 2;
813 return 1; 794 return 1;
814 break; 795 break;
815 case SYNC_PREF_REMOTE: 796 case SYNC_PREF_REMOTE:
816 if ( lastSync > remoteMod ) 797 if ( lastSync > remoteMod )
817 return 1; 798 return 1;
818 if ( lastSync > localMod ) 799 if ( lastSync > localMod )
819 return 2; 800 return 2;
820 return 2; 801 return 2;
821 break; 802 break;
822 case SYNC_PREF_NEWEST: 803 case SYNC_PREF_NEWEST:
823 if ( localMod > remoteMod ) 804 if ( localMod > remoteMod )
824 return 1; 805 return 1;
825 else 806 else
826 return 2; 807 return 2;
827 break; 808 break;
828 case SYNC_PREF_ASK: 809 case SYNC_PREF_ASK:
829 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 810 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
830 if ( lastSync > remoteMod ) 811 if ( lastSync > remoteMod )
831 return 1; 812 return 1;
832 if ( lastSync > localMod ) 813 if ( lastSync > localMod )
833 return 2; 814 return 2;
834 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 815 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
835 localIsNew = localMod >= remoteMod; 816 localIsNew = localMod >= remoteMod;
836 if ( localIsNew ) 817 if ( localIsNew )
837 getEventViewerDialog()->setColorMode( 1 ); 818 getEventViewerDialog()->setColorMode( 1 );
838 else 819 else
839 getEventViewerDialog()->setColorMode( 2 ); 820 getEventViewerDialog()->setColorMode( 2 );
840 getEventViewerDialog()->setIncidence(local); 821 getEventViewerDialog()->setIncidence(local);
841 if ( localIsNew ) 822 if ( localIsNew )
842 getEventViewerDialog()->setColorMode( 2 ); 823 getEventViewerDialog()->setColorMode( 2 );
843 else 824 else
844 getEventViewerDialog()->setColorMode( 1 ); 825 getEventViewerDialog()->setColorMode( 1 );
845 getEventViewerDialog()->addIncidence(remote); 826 getEventViewerDialog()->addIncidence(remote);
846 getEventViewerDialog()->setColorMode( 0 ); 827 getEventViewerDialog()->setColorMode( 0 );
847 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 828 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
848 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 829 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
849 getEventViewerDialog()->showMe(); 830 getEventViewerDialog()->showMe();
850 result = getEventViewerDialog()->executeS( localIsNew ); 831 result = getEventViewerDialog()->executeS( localIsNew );
851 return result; 832 return result;
852 833
853 break; 834 break;
854 case SYNC_PREF_FORCE_LOCAL: 835 case SYNC_PREF_FORCE_LOCAL:
855 return 1; 836 return 1;
856 break; 837 break;
857 case SYNC_PREF_FORCE_REMOTE: 838 case SYNC_PREF_FORCE_REMOTE:
858 return 2; 839 return 2;
859 break; 840 break;
860 841
861 default: 842 default:
862 // SYNC_PREF_TAKE_BOTH not implemented 843 // SYNC_PREF_TAKE_BOTH not implemented
863 break; 844 break;
864 } 845 }
865 return 0; 846 return 0;
866} 847}
867Event* CalendarView::getLastSyncEvent() 848Event* CalendarView::getLastSyncEvent()
868{ 849{
869 Event* lse; 850 Event* lse;
870 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 851 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
871 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 852 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
872 if (!lse) { 853 if (!lse) {
873 lse = new Event(); 854 lse = new Event();
874 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 855 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
875 QString sum = ""; 856 QString sum = "";
876 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 857 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
877 sum = "E: "; 858 sum = "E: ";
878 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 859 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
879 lse->setDtStart( mLastCalendarSync ); 860 lse->setDtStart( mLastCalendarSync );
880 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 861 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
881 lse->setCategories( i18n("SyncEvent") ); 862 lse->setCategories( i18n("SyncEvent") );
882 lse->setReadOnly( true ); 863 lse->setReadOnly( true );
883 mCalendar->addEvent( lse ); 864 mCalendar->addEvent( lse );
884 } 865 }
885 866
886 return lse; 867 return lse;
887 868
888} 869}
889 870
890// we check, if the to delete event has a id for a profile 871// we check, if the to delete event has a id for a profile
891// if yes, we set this id in the profile to delete 872// if yes, we set this id in the profile to delete
892void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 873void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
893{ 874{
894 if ( lastSync.count() == 0 ) { 875 if ( lastSync.count() == 0 ) {
895 //qDebug(" lastSync.count() == 0"); 876 //qDebug(" lastSync.count() == 0");
896 return; 877 return;
897 } 878 }
898 if ( toDelete->type() == "Journal" ) 879 if ( toDelete->type() == "Journal" )
899 return; 880 return;
900 881
901 Event* eve = lastSync.first(); 882 Event* eve = lastSync.first();
902 883
903 while ( eve ) { 884 while ( eve ) {
904 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 885 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
905 if ( !id.isEmpty() ) { 886 if ( !id.isEmpty() ) {
906 QString des = eve->description(); 887 QString des = eve->description();
907 QString pref = "e"; 888 QString pref = "e";
908 if ( toDelete->type() == "Todo" ) 889 if ( toDelete->type() == "Todo" )
909 pref = "t"; 890 pref = "t";
910 des += pref+ id + ","; 891 des += pref+ id + ",";
911 eve->setReadOnly( false ); 892 eve->setReadOnly( false );
912 eve->setDescription( des ); 893 eve->setDescription( des );
913 //qDebug("setdes %s ", des.latin1()); 894 //qDebug("setdes %s ", des.latin1());
914 eve->setReadOnly( true ); 895 eve->setReadOnly( true );
915 } 896 }
916 eve = lastSync.next(); 897 eve = lastSync.next();
917 } 898 }
918 899
919} 900}
920void CalendarView::checkExternalId( Incidence * inc ) 901void CalendarView::checkExternalId( Incidence * inc )
921{ 902{
922 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 903 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
923 checkExternSyncEvent( lastSync, inc ); 904 checkExternSyncEvent( lastSync, inc );
924 905
925} 906}
926bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 907bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
927{ 908{
928 bool syncOK = true; 909 bool syncOK = true;
929 int addedEvent = 0; 910 int addedEvent = 0;
930 int addedEventR = 0; 911 int addedEventR = 0;
931 int deletedEventR = 0; 912 int deletedEventR = 0;
932 int deletedEventL = 0; 913 int deletedEventL = 0;
933 int changedLocal = 0; 914 int changedLocal = 0;
934 int changedRemote = 0; 915 int changedRemote = 0;
935 int filteredIN = 0; 916 int filteredIN = 0;
936 int filteredOUT = 0; 917 int filteredOUT = 0;
937 //QPtrList<Event> el = local->rawEvents(); 918 //QPtrList<Event> el = local->rawEvents();
938 Event* eventR; 919 Event* eventR;
939 QString uid; 920 QString uid;
940 int take; 921 int take;
941 Event* eventL; 922 Event* eventL;
942 Event* eventRSync; 923 Event* eventRSync;
943 Event* eventLSync; 924 Event* eventLSync;
944 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 925 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
945 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 926 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
946 bool fullDateRange = false; 927 bool fullDateRange = false;
947 local->resetTempSyncStat(); 928 local->resetTempSyncStat();
948 mLastCalendarSync = QDateTime::currentDateTime(); 929 mLastCalendarSync = QDateTime::currentDateTime();
949 if ( mSyncManager->syncWithDesktop() ) { 930 if ( mSyncManager->syncWithDesktop() ) {
950 remote->resetPilotStat(1); 931 remote->resetPilotStat(1);
951 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 932 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
952 mLastCalendarSync = KSyncManager::mRequestedSyncEvent; 933 mLastCalendarSync = KSyncManager::mRequestedSyncEvent;
953 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); 934 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() );
954 } else { 935 } else {
955 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 936 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
956 } 937 }
957 } 938 }
958 QDateTime modifiedCalendar = mLastCalendarSync; 939 QDateTime modifiedCalendar = mLastCalendarSync;
959 eventLSync = getLastSyncEvent(); 940 eventLSync = getLastSyncEvent();
960 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 941 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
961 if ( eventR ) { 942 if ( eventR ) {
962 eventRSync = (Event*) eventR->clone(); 943 eventRSync = (Event*) eventR->clone();
963 remote->deleteEvent(eventR ); 944 remote->deleteEvent(eventR );
964 945
965 } else { 946 } else {
966 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { 947 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) {
967 eventRSync = (Event*)eventLSync->clone(); 948 eventRSync = (Event*)eventLSync->clone();
968 } else { 949 } else {
969 fullDateRange = true; 950 fullDateRange = true;
970 eventRSync = new Event(); 951 eventRSync = new Event();
971 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 952 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
972 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 953 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
973 eventRSync->setDtStart( mLastCalendarSync ); 954 eventRSync->setDtStart( mLastCalendarSync );
974 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 955 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
975 eventRSync->setCategories( i18n("SyncEvent") ); 956 eventRSync->setCategories( i18n("SyncEvent") );
976 } 957 }
977 } 958 }
978 if ( eventLSync->dtStart() == mLastCalendarSync ) 959 if ( eventLSync->dtStart() == mLastCalendarSync )
979 fullDateRange = true; 960 fullDateRange = true;
980 961
981 if ( ! fullDateRange ) { 962 if ( ! fullDateRange ) {
982 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 963 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
983 964
984 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 965 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
985 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 966 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
986 fullDateRange = true; 967 fullDateRange = true;
987 } 968 }
988 } 969 }
989 if ( mSyncManager->syncWithDesktop() ) { 970 if ( mSyncManager->syncWithDesktop() ) {
990 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); 971 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync );
991 } 972 }
992 if ( fullDateRange ) 973 if ( fullDateRange )
993 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 974 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
994 else 975 else
995 mLastCalendarSync = eventLSync->dtStart(); 976 mLastCalendarSync = eventLSync->dtStart();
996 // for resyncing if own file has changed 977 // for resyncing if own file has changed
997 if ( mCurrentSyncDevice == "deleteaftersync" ) { 978 if ( mCurrentSyncDevice == "deleteaftersync" ) {
998 mLastCalendarSync = loadedFileVersion; 979 mLastCalendarSync = loadedFileVersion;
999 //qDebug("setting mLastCalendarSync "); 980 //qDebug("setting mLastCalendarSync ");
1000 } 981 }
1001 //qDebug("*************************** "); 982 //qDebug("*************************** ");
1002 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); 983 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange);
1003 QPtrList<Incidence> er = remote->rawIncidences(); 984 QPtrList<Incidence> er = remote->rawIncidences();
1004 Incidence* inR = er.first(); 985 Incidence* inR = er.first();
1005 Incidence* inL; 986 Incidence* inL;
1006 QProgressBar bar( er.count(),0 ); 987 QProgressBar bar( er.count(),0 );
1007 bar.setCaption (i18n("Syncing - close to abort!") ); 988 bar.setCaption (i18n("Syncing - close to abort!") );
1008 989
1009 // ************** setting up filter ************* 990 // ************** setting up filter *************
1010 CalFilter *filterIN = 0; 991 CalFilter *filterIN = 0;
1011 CalFilter *filterOUT = 0; 992 CalFilter *filterOUT = 0;
1012 CalFilter *filter = mFilters.first(); 993 CalFilter *filter = mFilters.first();
1013 while(filter) { 994 while(filter) {
1014 if ( filter->name() == mSyncManager->mFilterInCal ) 995 if ( filter->name() == mSyncManager->mFilterInCal )
1015 filterIN = filter; 996 filterIN = filter;
1016 if ( filter->name() == mSyncManager->mFilterOutCal ) 997 if ( filter->name() == mSyncManager->mFilterOutCal )
1017 filterOUT = filter; 998 filterOUT = filter;
1018 filter = mFilters.next(); 999 filter = mFilters.next();
1019 } 1000 }
1020 int w = 300; 1001 int w = 300;
1021 if ( QApplication::desktop()->width() < 320 ) 1002 if ( QApplication::desktop()->width() < 320 )
1022 w = 220; 1003 w = 220;
1023 int h = bar.sizeHint().height() ; 1004 int h = bar.sizeHint().height() ;
1024 int dw = QApplication::desktop()->width(); 1005 int dw = QApplication::desktop()->width();
1025 int dh = QApplication::desktop()->height(); 1006 int dh = QApplication::desktop()->height();
1026 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1007 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1027 bar.show(); 1008 bar.show();
1028 int modulo = (er.count()/10)+1; 1009 int modulo = (er.count()/10)+1;
1029 int incCounter = 0; 1010 int incCounter = 0;
1030 while ( inR ) { 1011 while ( inR ) {
1031 if ( ! bar.isVisible() ) 1012 if ( ! bar.isVisible() )
1032 return false; 1013 return false;
1033 if ( incCounter % modulo == 0 ) 1014 if ( incCounter % modulo == 0 )
1034 bar.setProgress( incCounter ); 1015 bar.setProgress( incCounter );
1035 ++incCounter; 1016 ++incCounter;
1036 uid = inR->uid(); 1017 uid = inR->uid();
1037 bool skipIncidence = false; 1018 bool skipIncidence = false;
1038 if ( uid.left(15) == QString("last-syncEvent-") ) 1019 if ( uid.left(15) == QString("last-syncEvent-") )
1039 skipIncidence = true; 1020 skipIncidence = true;
1040 QString idS; 1021 QString idS;
1041 qApp->processEvents(); 1022 qApp->processEvents();
1042 if ( !skipIncidence ) { 1023 if ( !skipIncidence ) {
1043 inL = local->incidence( uid ); 1024 inL = local->incidence( uid );
1044 if ( inL ) { // maybe conflict - same uid in both calendars 1025 if ( inL ) { // maybe conflict - same uid in both calendars
1045 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1026 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1046 //qDebug("take %d %s ", take, inL->summary().latin1()); 1027 //qDebug("take %d %s ", take, inL->summary().latin1());
1047 if ( take == 3 ) 1028 if ( take == 3 )
1048 return false; 1029 return false;
1049 if ( take == 1 ) {// take local ********************** 1030 if ( take == 1 ) {// take local **********************
1050 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1031 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1051 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1032 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1052 else 1033 else
1053 idS = inR->IDStr(); 1034 idS = inR->IDStr();
1054 remote->deleteIncidence( inR ); 1035 remote->deleteIncidence( inR );
1055 inR = inL->clone(); 1036 inR = inL->clone();
1056 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1037 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1057 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1038 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1058 inR->setIDStr( idS ); 1039 inR->setIDStr( idS );
1059 remote->addIncidence( inR ); 1040 remote->addIncidence( inR );
1060 if ( mSyncManager->syncWithDesktop() ) 1041 if ( mSyncManager->syncWithDesktop() )
1061 inR->setPilotId( 2 ); 1042 inR->setPilotId( 2 );
1062 ++changedRemote; 1043 ++changedRemote;
1063 } else {// take remote ********************** 1044 } else {// take remote **********************
1064 idS = inL->IDStr(); 1045 idS = inL->IDStr();
1065 int pid = inL->pilotId(); 1046 int pid = inL->pilotId();
1066 local->deleteIncidence( inL ); 1047 local->deleteIncidence( inL );
1067 inL = inR->clone(); 1048 inL = inR->clone();
1068 if ( mSyncManager->syncWithDesktop() ) 1049 if ( mSyncManager->syncWithDesktop() )
1069 inL->setPilotId( pid ); 1050 inL->setPilotId( pid );
1070 inL->setIDStr( idS ); 1051 inL->setIDStr( idS );
1071 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1052 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1072 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1053 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1073 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1054 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1074 } 1055 }
1075 local->addIncidence( inL ); 1056 local->addIncidence( inL );
1076 ++changedLocal; 1057 ++changedLocal;
1077 } 1058 }
1078 } 1059 }
1079 } else { // no conflict ********** add or delete remote 1060 } else { // no conflict ********** add or delete remote
1080 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ 1061 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){
1081 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1062 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1082 QString des = eventLSync->description(); 1063 QString des = eventLSync->description();
1083 QString pref = "e"; 1064 QString pref = "e";
1084 if ( inR->type() == "Todo" ) 1065 if ( inR->type() == "Todo" )
1085 pref = "t"; 1066 pref = "t";
1086 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1067 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1087 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1068 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1088 //remote->deleteIncidence( inR ); 1069 //remote->deleteIncidence( inR );
1089 ++deletedEventR; 1070 ++deletedEventR;
1090 } else { 1071 } else {
1091 inR->setLastModified( modifiedCalendar ); 1072 inR->setLastModified( modifiedCalendar );
1092 inL = inR->clone(); 1073 inL = inR->clone();
1093 inL->setIDStr( ":" ); 1074 inL->setIDStr( ":" );
1094 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1075 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1095 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1076 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1096 local->addIncidence( inL ); 1077 local->addIncidence( inL );
1097 ++addedEvent; 1078 ++addedEvent;
1098 1079
1099 } 1080 }
1100 } else { 1081 } else {
1101 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1082 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1102 inR->setLastModified( modifiedCalendar ); 1083 inR->setLastModified( modifiedCalendar );
1103 inL = inR->clone(); 1084 inL = inR->clone();
1104 inL->setIDStr( ":" ); 1085 inL->setIDStr( ":" );
1105 local->addIncidence( inL ); 1086 local->addIncidence( inL );
1106 ++addedEvent; 1087 ++addedEvent;
1107 1088
1108 } else { 1089 } else {
1109 checkExternSyncEvent(eventRSyncSharp, inR); 1090 checkExternSyncEvent(eventRSyncSharp, inR);
1110 remote->deleteIncidence( inR ); 1091 remote->deleteIncidence( inR );
1111 ++deletedEventR; 1092 ++deletedEventR;
1112 } 1093 }
1113 } 1094 }
1114 } else { 1095 } else {
1115 ++filteredIN; 1096 ++filteredIN;
1116 } 1097 }
1117 } 1098 }
1118 } 1099 }
1119 inR = er.next(); 1100 inR = er.next();
1120 } 1101 }
1121 QPtrList<Incidence> el = local->rawIncidences(); 1102 QPtrList<Incidence> el = local->rawIncidences();
1122 inL = el.first(); 1103 inL = el.first();
1123 modulo = (el.count()/10)+1; 1104 modulo = (el.count()/10)+1;
1124 bar.setCaption (i18n("Add / remove events") ); 1105 bar.setCaption (i18n("Add / remove events") );
1125 bar.setTotalSteps ( el.count() ) ; 1106 bar.setTotalSteps ( el.count() ) ;
1126 bar.show(); 1107 bar.show();
1127 incCounter = 0; 1108 incCounter = 0;
1128 1109
1129 while ( inL ) { 1110 while ( inL ) {
1130 1111
1131 qApp->processEvents(); 1112 qApp->processEvents();
1132 if ( ! bar.isVisible() ) 1113 if ( ! bar.isVisible() )
1133 return false; 1114 return false;
1134 if ( incCounter % modulo == 0 ) 1115 if ( incCounter % modulo == 0 )
1135 bar.setProgress( incCounter ); 1116 bar.setProgress( incCounter );
1136 ++incCounter; 1117 ++incCounter;
1137 uid = inL->uid(); 1118 uid = inL->uid();
1138 bool skipIncidence = false; 1119 bool skipIncidence = false;
1139 if ( uid.left(15) == QString("last-syncEvent-") ) 1120 if ( uid.left(15) == QString("last-syncEvent-") )
1140 skipIncidence = true; 1121 skipIncidence = true;
1141 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) 1122 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
1142 skipIncidence = true; 1123 skipIncidence = true;
1143 if ( !skipIncidence ) { 1124 if ( !skipIncidence ) {
1144 inR = remote->incidence( uid ); 1125 inR = remote->incidence( uid );
1145 if ( ! inR ) { 1126 if ( ! inR ) {
1146 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ 1127 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){
1147 // no conflict ********** add or delete local 1128 // no conflict ********** add or delete local
1148 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1129 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1149 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1130 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1150 checkExternSyncEvent(eventLSyncSharp, inL); 1131 checkExternSyncEvent(eventLSyncSharp, inL);
1151 local->deleteIncidence( inL ); 1132 local->deleteIncidence( inL );
1152 ++deletedEventL; 1133 ++deletedEventL;
1153 } else { 1134 } else {
1154 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1135 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1155 inL->removeID(mCurrentSyncDevice ); 1136 inL->removeID(mCurrentSyncDevice );
1156 ++addedEventR; 1137 ++addedEventR;
1157 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1138 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1158 inL->setLastModified( modifiedCalendar ); 1139 inL->setLastModified( modifiedCalendar );
1159 inR = inL->clone(); 1140 inR = inL->clone();
1160 inR->setIDStr( ":" ); 1141 inR->setIDStr( ":" );
1161 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1142 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1162 remote->addIncidence( inR ); 1143 remote->addIncidence( inR );
1163 } 1144 }
1164 } 1145 }
1165 } else { 1146 } else {
1166 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1147 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1167 checkExternSyncEvent(eventLSyncSharp, inL); 1148 checkExternSyncEvent(eventLSyncSharp, inL);
1168 local->deleteIncidence( inL ); 1149 local->deleteIncidence( inL );
1169 ++deletedEventL; 1150 ++deletedEventL;
1170 } else { 1151 } else {
1171 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1152 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1172 ++addedEventR; 1153 ++addedEventR;
1173 inL->setLastModified( modifiedCalendar ); 1154 inL->setLastModified( modifiedCalendar );
1174 inR = inL->clone(); 1155 inR = inL->clone();
1175 inR->setIDStr( ":" ); 1156 inR->setIDStr( ":" );
1176 remote->addIncidence( inR ); 1157 remote->addIncidence( inR );
1177 } 1158 }
1178 } 1159 }
1179 } 1160 }
1180 } else { 1161 } else {
1181 ++filteredOUT; 1162 ++filteredOUT;
1182 } 1163 }
1183 } 1164 }
1184 } 1165 }
1185 inL = el.next(); 1166 inL = el.next();
1186 } 1167 }
1187 int delFut = 0; 1168 int delFut = 0;
1188 int remRem = 0; 1169 int remRem = 0;
1189 if ( mSyncManager->mWriteBackInFuture ) { 1170 if ( mSyncManager->mWriteBackInFuture ) {
1190 er = remote->rawIncidences(); 1171 er = remote->rawIncidences();
1191 remRem = er.count(); 1172 remRem = er.count();
1192 inR = er.first(); 1173 inR = er.first();
1193 QDateTime dt; 1174 QDateTime dt;
1194 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); 1175 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) );
1195 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); 1176 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 );
1196 while ( inR ) { 1177 while ( inR ) {
1197 if ( inR->type() == "Todo" ) { 1178 if ( inR->type() == "Todo" ) {
1198 Todo * t = (Todo*)inR; 1179 Todo * t = (Todo*)inR;
1199 if ( t->hasDueDate() ) 1180 if ( t->hasDueDate() )
1200 dt = t->dtDue(); 1181 dt = t->dtDue();
1201 else 1182 else
1202 dt = cur.addSecs( 62 ); 1183 dt = cur.addSecs( 62 );
1203 } 1184 }
1204 else if (inR->type() == "Event" ) { 1185 else if (inR->type() == "Event" ) {
1205 bool ok; 1186 bool ok;
1206 dt = inR->getNextOccurence( cur, &ok ); 1187 dt = inR->getNextOccurence( cur, &ok );
1207 if ( !ok ) 1188 if ( !ok )
1208 dt = cur.addSecs( -62 ); 1189 dt = cur.addSecs( -62 );
1209 } 1190 }
1210 else 1191 else
1211 dt = inR->dtStart(); 1192 dt = inR->dtStart();
1212 if ( dt < cur || dt > end ) { 1193 if ( dt < cur || dt > end ) {
1213 remote->deleteIncidence( inR ); 1194 remote->deleteIncidence( inR );
1214 ++delFut; 1195 ++delFut;
1215 } 1196 }
1216 inR = er.next(); 1197 inR = er.next();
1217 } 1198 }
1218 } 1199 }
1219 bar.hide(); 1200 bar.hide();
1220 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1201 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1221 eventLSync->setReadOnly( false ); 1202 eventLSync->setReadOnly( false );
1222 eventLSync->setDtStart( mLastCalendarSync ); 1203 eventLSync->setDtStart( mLastCalendarSync );
1223 eventRSync->setDtStart( mLastCalendarSync ); 1204 eventRSync->setDtStart( mLastCalendarSync );
1224 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1205 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1225 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1206 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1226 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1207 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1227 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1208 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1228 eventLSync->setReadOnly( true ); 1209 eventLSync->setReadOnly( true );
1229 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); 1210 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL );
1230 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... 1211 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal...
1231 remote->addEvent( eventRSync ); 1212 remote->addEvent( eventRSync );
1232 else 1213 else
1233 delete eventRSync; 1214 delete eventRSync;
1234 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); 1215 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() );
1235 QString mes; 1216 QString mes;
1236 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 ); 1217 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 );
1237 QString delmess; 1218 QString delmess;
1238 if ( delFut ) { 1219 if ( delFut ) {
1239 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); 1220 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);
1240 mes += delmess; 1221 mes += delmess;
1241 } 1222 }
1242 mes = i18n("Local calendar changed!\n") +mes; 1223 mes = i18n("Local calendar changed!\n") +mes;
1243 mCalendar->checkAlarmForIncidence( 0, true ); 1224 mCalendar->checkAlarmForIncidence( 0, true );
1244 qDebug( mes ); 1225 qDebug( mes );
1245 if ( mSyncManager->mShowSyncSummary ) { 1226 if ( mSyncManager->mShowSyncSummary ) {
1246 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 1227 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
1247 i18n("KO/Pi Synchronization"),i18n("Write back"))) { 1228 i18n("KO/Pi Synchronization"),i18n("Write back"))) {
1248 qDebug("KO: WB cancelled "); 1229 qDebug("KO: WB cancelled ");
1249 return false; 1230 return false;
1250 } 1231 }
1251 } 1232 }
1252 return syncOK; 1233 return syncOK;
1253} 1234}
1254 1235
1255void CalendarView::setSyncDevice( QString s ) 1236void CalendarView::setSyncDevice( QString s )
1256{ 1237{
1257 mCurrentSyncDevice= s; 1238 mCurrentSyncDevice= s;
1258} 1239}
1259void CalendarView::setSyncName( QString s ) 1240void CalendarView::setSyncName( QString s )
1260{ 1241{
1261 mCurrentSyncName= s; 1242 mCurrentSyncName= s;
1262} 1243}
1263bool CalendarView::syncCalendar(QString filename, int mode) 1244bool CalendarView::syncCalendar(QString filename, int mode)
1264{ 1245{
1265 //qDebug("syncCalendar %s ", filename.latin1()); 1246 //qDebug("syncCalendar %s ", filename.latin1());
1266 mGlobalSyncMode = SYNC_MODE_NORMAL; 1247 mGlobalSyncMode = SYNC_MODE_NORMAL;
1267 CalendarLocal* calendar = new CalendarLocal(); 1248 CalendarLocal* calendar = new CalendarLocal();
1268 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1249 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1269 FileStorage* storage = new FileStorage( calendar ); 1250 FileStorage* storage = new FileStorage( calendar );
1270 bool syncOK = false; 1251 bool syncOK = false;
1271 storage->setFileName( filename ); 1252 storage->setFileName( filename );
1272 // qDebug("loading ... "); 1253 // qDebug("loading ... ");
1273 if ( storage->load() ) { 1254 if ( storage->load() ) {
1274 getEventViewerDialog()->setSyncMode( true ); 1255 getEventViewerDialog()->setSyncMode( true );
1275 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1256 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1276 getEventViewerDialog()->setSyncMode( false ); 1257 getEventViewerDialog()->setSyncMode( false );
1277 if ( syncOK ) { 1258 if ( syncOK ) {
1278 if ( mSyncManager->mWriteBackFile ) 1259 if ( mSyncManager->mWriteBackFile )
1279 { 1260 {
1280 storage->setSaveFormat( new ICalFormat() ); 1261 storage->setSaveFormat( new ICalFormat() );
1281 storage->save(); 1262 storage->save();
1282 } 1263 }
1283 } 1264 }
1284 setModified( true ); 1265 setModified( true );
1285 } 1266 }
1286 delete storage; 1267 delete storage;
1287 delete calendar; 1268 delete calendar;
1288 if ( syncOK ) 1269 if ( syncOK )
1289 updateView(); 1270 updateView();
1290 return syncOK; 1271 return syncOK;
1291} 1272}
1292 1273
1293void CalendarView::syncExternal( int mode ) 1274void CalendarView::syncExternal( int mode )
1294{ 1275{
1295 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1276 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1296 1277
1297 qApp->processEvents(); 1278 qApp->processEvents();
1298 CalendarLocal* calendar = new CalendarLocal(); 1279 CalendarLocal* calendar = new CalendarLocal();
1299 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1280 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1300 bool syncOK = false; 1281 bool syncOK = false;
1301 bool loadSuccess = false; 1282 bool loadSuccess = false;
1302 PhoneFormat* phoneFormat = 0; 1283 PhoneFormat* phoneFormat = 0;
1303 emit tempDisableBR(true); 1284 emit tempDisableBR(true);
1304#ifndef DESKTOP_VERSION 1285#ifndef DESKTOP_VERSION
1305 SharpFormat* sharpFormat = 0; 1286 SharpFormat* sharpFormat = 0;
1306 if ( mode == 0 ) { // sharp 1287 if ( mode == 0 ) { // sharp
1307 sharpFormat = new SharpFormat () ; 1288 sharpFormat = new SharpFormat () ;
1308 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1289 loadSuccess = sharpFormat->load( calendar, mCalendar );
1309 1290
1310 } else 1291 } else
1311#endif 1292#endif
1312 if ( mode == 1 ) { // phone 1293 if ( mode == 1 ) { // phone
1313 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1294 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1314 mSyncManager->mPhoneDevice, 1295 mSyncManager->mPhoneDevice,
1315 mSyncManager->mPhoneConnection, 1296 mSyncManager->mPhoneConnection,
1316 mSyncManager->mPhoneModel); 1297 mSyncManager->mPhoneModel);
1317 loadSuccess = phoneFormat->load( calendar,mCalendar); 1298 loadSuccess = phoneFormat->load( calendar,mCalendar);
1318 1299
1319 } else { 1300 } else {
1320 emit tempDisableBR(false); 1301 emit tempDisableBR(false);
1321 return; 1302 return;
1322 } 1303 }
1323 if ( loadSuccess ) { 1304 if ( loadSuccess ) {
1324 getEventViewerDialog()->setSyncMode( true ); 1305 getEventViewerDialog()->setSyncMode( true );
1325 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1306 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1326 getEventViewerDialog()->setSyncMode( false ); 1307 getEventViewerDialog()->setSyncMode( false );
1327 qApp->processEvents(); 1308 qApp->processEvents();
1328 if ( syncOK ) { 1309 if ( syncOK ) {
1329 if ( mSyncManager->mWriteBackFile ) 1310 if ( mSyncManager->mWriteBackFile )
1330 { 1311 {
1331 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1312 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1332 Incidence* inc = iL.first(); 1313 Incidence* inc = iL.first();
1333 if ( phoneFormat ) { 1314 if ( phoneFormat ) {
1334 while ( inc ) { 1315 while ( inc ) {
1335 inc->removeID(mCurrentSyncDevice); 1316 inc->removeID(mCurrentSyncDevice);
1336 inc = iL.next(); 1317 inc = iL.next();
1337 } 1318 }
1338 } 1319 }
1339#ifndef DESKTOP_VERSION 1320#ifndef DESKTOP_VERSION
1340 if ( sharpFormat ) 1321 if ( sharpFormat )
1341 sharpFormat->save(calendar); 1322 sharpFormat->save(calendar);
1342#endif 1323#endif
1343 if ( phoneFormat ) 1324 if ( phoneFormat )
1344 phoneFormat->save(calendar); 1325 phoneFormat->save(calendar);
1345 iL = calendar->rawIncidences(); 1326 iL = calendar->rawIncidences();
1346 inc = iL.first(); 1327 inc = iL.first();
1347 Incidence* loc; 1328 Incidence* loc;
1348 while ( inc ) { 1329 while ( inc ) {
1349 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1330 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1350 loc = mCalendar->incidence(inc->uid() ); 1331 loc = mCalendar->incidence(inc->uid() );
1351 if ( loc ) { 1332 if ( loc ) {
1352 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1333 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1353 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1334 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1354 } 1335 }
1355 } 1336 }
1356 inc = iL.next(); 1337 inc = iL.next();
1357 } 1338 }
1358 Incidence* lse = getLastSyncEvent(); 1339 Incidence* lse = getLastSyncEvent();
1359 if ( lse ) { 1340 if ( lse ) {
1360 lse->setReadOnly( false ); 1341 lse->setReadOnly( false );
1361 lse->setDescription( "" ); 1342 lse->setDescription( "" );
1362 lse->setReadOnly( true ); 1343 lse->setReadOnly( true );
1363 } 1344 }
1364 } 1345 }
1365 } else { 1346 } else {
1366 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 1347 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
1367 } 1348 }
1368 setModified( true ); 1349 setModified( true );
1369 } else { 1350 } else {
1370 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1351 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1371 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1352 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1372 question, i18n("Ok")) ; 1353 question, i18n("Ok")) ;
1373 1354
1374 } 1355 }
1375 delete calendar; 1356 delete calendar;
1376 updateView(); 1357 updateView();
1377 emit tempDisableBR(false); 1358 emit tempDisableBR(false);
1378 return ;//syncOK; 1359 return ;//syncOK;
1379 1360
1380} 1361}
1381 1362
1382bool CalendarView::importBday() 1363bool CalendarView::importBday()
1383{ 1364{
1384#ifndef KORG_NOKABC 1365#ifndef KORG_NOKABC
1385 1366
1386#ifdef DESKTOP_VERSION 1367#ifdef DESKTOP_VERSION
1387 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1368 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1388 KABC::AddressBook::Iterator it; 1369 KABC::AddressBook::Iterator it;
1389 int count = 0; 1370 int count = 0;
1390 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1371 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1391 ++count; 1372 ++count;
1392 } 1373 }
1393 QProgressBar bar(count,0 ); 1374 QProgressBar bar(count,0 );
1394 int w = 300; 1375 int w = 300;
1395 if ( QApplication::desktop()->width() < 320 ) 1376 if ( QApplication::desktop()->width() < 320 )
1396 w = 220; 1377 w = 220;
1397 int h = bar.sizeHint().height() ; 1378 int h = bar.sizeHint().height() ;
1398 int dw = QApplication::desktop()->width(); 1379 int dw = QApplication::desktop()->width();
1399 int dh = QApplication::desktop()->height(); 1380 int dh = QApplication::desktop()->height();
1400 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1381 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1401 bar.show(); 1382 bar.show();
1402 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1383 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1403 qApp->processEvents(); 1384 qApp->processEvents();
1404 count = 0; 1385 count = 0;
1405 int addCount = 0; 1386 int addCount = 0;
1406 KCal::Attendee* a = 0; 1387 KCal::Attendee* a = 0;
1407 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1388 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1408 if ( ! bar.isVisible() ) 1389 if ( ! bar.isVisible() )
1409 return false; 1390 return false;
1410 bar.setProgress( count++ ); 1391 bar.setProgress( count++ );
1411 qApp->processEvents(); 1392 qApp->processEvents();
1412 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1393 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1413 if ( (*it).birthday().date().isValid() ){ 1394 if ( (*it).birthday().date().isValid() ){
1414 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1395 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1415 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1396 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1416 ++addCount; 1397 ++addCount;
1417 } 1398 }
1418 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1399 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1419 if ( anni.isValid() ){ 1400 if ( anni.isValid() ){
1420 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1401 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1421 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1402 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1422 ++addCount; 1403 ++addCount;
1423 } 1404 }
1424 } 1405 }
1425 updateView(); 1406 updateView();
1426 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1407 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1427#else //DESKTOP_VERSION 1408#else //DESKTOP_VERSION
1428 1409
1429 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 1410 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
1430 // the result should now arrive through method insertBirthdays 1411 // the result should now arrive through method insertBirthdays
1431 1412
1432#endif //DESKTOP_VERSION 1413#endif //DESKTOP_VERSION
1433 1414
1434#endif //KORG_NOKABC 1415#endif //KORG_NOKABC
1435 1416
1436 1417
1437 return true; 1418 return true;
1438} 1419}
1439 1420
1440// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI 1421// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
1441void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, 1422void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
1442 const QStringList& anniversaryList, const QStringList& realNameList, 1423 const QStringList& anniversaryList, const QStringList& realNameList,
1443 const QStringList& emailList, const QStringList& assembledNameList, 1424 const QStringList& emailList, const QStringList& assembledNameList,
1444 const QStringList& uidList) 1425 const QStringList& uidList)
1445{ 1426{
1446 //qDebug("KO::CalendarView::insertBirthdays"); 1427 //qDebug("KO::CalendarView::insertBirthdays");
1447 if (uid == this->name()) 1428 if (uid == this->name())
1448 { 1429 {
1449 int count = birthdayList.count(); 1430 int count = birthdayList.count();
1450 int addCount = 0; 1431 int addCount = 0;
1451 KCal::Attendee* a = 0; 1432 KCal::Attendee* a = 0;
1452 1433
1453 //qDebug("CalView 1 %i", count); 1434 //qDebug("CalView 1 %i", count);
1454 1435
1455 QProgressBar bar(count,0 ); 1436 QProgressBar bar(count,0 );
1456 int w = 300; 1437 int w = 300;
1457 if ( QApplication::desktop()->width() < 320 ) 1438 if ( QApplication::desktop()->width() < 320 )
1458 w = 220; 1439 w = 220;
1459 int h = bar.sizeHint().height() ; 1440 int h = bar.sizeHint().height() ;
1460 int dw = QApplication::desktop()->width(); 1441 int dw = QApplication::desktop()->width();
1461 int dh = QApplication::desktop()->height(); 1442 int dh = QApplication::desktop()->height();
1462 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1443 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1463 bar.show(); 1444 bar.show();
1464 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 1445 bar.setCaption (i18n("inserting birthdays - close to abort!") );
1465 qApp->processEvents(); 1446 qApp->processEvents();
1466 1447
1467 QDate birthday; 1448 QDate birthday;
1468 QDate anniversary; 1449 QDate anniversary;
1469 QString realName; 1450 QString realName;
1470 QString email; 1451 QString email;
1471 QString assembledName; 1452 QString assembledName;
1472 QString uid; 1453 QString uid;
1473 bool ok = true; 1454 bool ok = true;
1474 for ( int i = 0; i < count; i++) 1455 for ( int i = 0; i < count; i++)
1475 { 1456 {
1476 if ( ! bar.isVisible() ) 1457 if ( ! bar.isVisible() )
1477 return; 1458 return;
1478 bar.setProgress( i ); 1459 bar.setProgress( i );
1479 qApp->processEvents(); 1460 qApp->processEvents();
1480 1461
1481 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); 1462 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
1482 if (!ok) { 1463 if (!ok) {
1483 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); 1464 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
1484 } 1465 }
1485 1466
1486 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); 1467 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
1487 if (!ok) { 1468 if (!ok) {
1488 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); 1469 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
1489 } 1470 }
1490 realName = realNameList[i]; 1471 realName = realNameList[i];
1491 email = emailList[i]; 1472 email = emailList[i];
1492 assembledName = assembledNameList[i]; 1473 assembledName = assembledNameList[i];
1493 uid = uidList[i]; 1474 uid = uidList[i];
1494 //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() ); 1475 //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() );
1495 1476
1496 if ( birthday.isValid() ){ 1477 if ( birthday.isValid() ){
1497 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1478 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1498 KCal::Attendee::ReqParticipant,uid) ; 1479 KCal::Attendee::ReqParticipant,uid) ;
1499 if ( addAnniversary( birthday, assembledName, a, true ) ) 1480 if ( addAnniversary( birthday, assembledName, a, true ) )
1500 ++addCount; 1481 ++addCount;
1501 } 1482 }
1502 1483
1503 if ( anniversary.isValid() ){ 1484 if ( anniversary.isValid() ){
1504 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1485 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1505 KCal::Attendee::ReqParticipant,uid) ; 1486 KCal::Attendee::ReqParticipant,uid) ;
1506 if ( addAnniversary( anniversary, assembledName, a, false ) ) 1487 if ( addAnniversary( anniversary, assembledName, a, false ) )
1507 ++addCount; 1488 ++addCount;
1508 } 1489 }
1509 } 1490 }
1510 1491
1511 updateView(); 1492 updateView();
1512 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1493 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1513 1494
1514 } 1495 }
1515 1496
1516} 1497}
1517 1498
1518 1499
1519 1500
1520bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1501bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1521{ 1502{
1522 //qDebug("addAnni "); 1503 //qDebug("addAnni ");
1523 Event * ev = new Event(); 1504 Event * ev = new Event();
1524 ev->setOrganizer(KOPrefs::instance()->email()); 1505 ev->setOrganizer(KOPrefs::instance()->email());
1525 if ( a ) { 1506 if ( a ) {
1526 ev->addAttendee( a ); 1507 ev->addAttendee( a );
1527 } 1508 }
1528 QString kind; 1509 QString kind;
1529 if ( birthday ) { 1510 if ( birthday ) {
1530 kind = i18n( "Birthday" ); 1511 kind = i18n( "Birthday" );
1531 ev->setSummary( name + " (" + QString::number(date.year()) +")"); 1512 ev->setSummary( name + " (" + QString::number(date.year()) +")");
1532 } 1513 }
1533 else { 1514 else {
1534 kind = i18n( "Anniversary" ); 1515 kind = i18n( "Anniversary" );
1535 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); 1516 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind );
1536 } 1517 }
1537 ev->setCategories( kind ); 1518 ev->setCategories( kind );
1538 ev->setDtStart( QDateTime(date) ); 1519 ev->setDtStart( QDateTime(date) );
1539 ev->setDtEnd( QDateTime(date) ); 1520 ev->setDtEnd( QDateTime(date) );
1540 ev->setFloats( true ); 1521 ev->setFloats( true );
1541 Recurrence * rec = ev->recurrence(); 1522 Recurrence * rec = ev->recurrence();
1542 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1523 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1543 rec->addYearlyNum( date.month() ); 1524 rec->addYearlyNum( date.month() );
1544 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1525 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1545 delete ev; 1526 delete ev;
1546 return false; 1527 return false;
1547 } 1528 }
1548 return true; 1529 return true;
1549 1530
1550} 1531}
1551bool CalendarView::importQtopia( const QString &categories, 1532bool CalendarView::importQtopia( const QString &categories,
1552 const QString &datebook, 1533 const QString &datebook,
1553 const QString &todolist ) 1534 const QString &todolist )
1554{ 1535{
1555 1536
1556 QtopiaFormat qtopiaFormat; 1537 QtopiaFormat qtopiaFormat;
1557 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1538 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1558 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1539 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1559 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1540 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1560 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1541 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1561 1542
1562 updateView(); 1543 updateView();
1563 return true; 1544 return true;
1564 1545
1565#if 0 1546#if 0
1566 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1547 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1567 mCurrentSyncDevice = "qtopia-XML"; 1548 mCurrentSyncDevice = "qtopia-XML";
1568 if ( mSyncManager->mAskForPreferences ) 1549 if ( mSyncManager->mAskForPreferences )
1569 edit_sync_options(); 1550 edit_sync_options();
1570 qApp->processEvents(); 1551 qApp->processEvents();
1571 CalendarLocal* calendar = new CalendarLocal(); 1552 CalendarLocal* calendar = new CalendarLocal();
1572 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1553 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1573 bool syncOK = false; 1554 bool syncOK = false;
1574 QtopiaFormat qtopiaFormat; 1555 QtopiaFormat qtopiaFormat;
1575 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1556 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1576 bool loadOk = true; 1557 bool loadOk = true;
1577 if ( !categories.isEmpty() ) 1558 if ( !categories.isEmpty() )
1578 loadOk = qtopiaFormat.load( calendar, categories ); 1559 loadOk = qtopiaFormat.load( calendar, categories );
1579 if ( loadOk && !datebook.isEmpty() ) 1560 if ( loadOk && !datebook.isEmpty() )
1580 loadOk = qtopiaFormat.load( calendar, datebook ); 1561 loadOk = qtopiaFormat.load( calendar, datebook );
1581 if ( loadOk && !todolist.isEmpty() ) 1562 if ( loadOk && !todolist.isEmpty() )
1582 loadOk = qtopiaFormat.load( calendar, todolist ); 1563 loadOk = qtopiaFormat.load( calendar, todolist );
1583 1564
1584 if ( loadOk ) { 1565 if ( loadOk ) {
1585 getEventViewerDialog()->setSyncMode( true ); 1566 getEventViewerDialog()->setSyncMode( true );
1586 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1567 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1587 getEventViewerDialog()->setSyncMode( false ); 1568 getEventViewerDialog()->setSyncMode( false );
1588 qApp->processEvents(); 1569 qApp->processEvents();
1589 if ( syncOK ) { 1570 if ( syncOK ) {
1590 if ( mSyncManager->mWriteBackFile ) 1571 if ( mSyncManager->mWriteBackFile )
1591 { 1572 {
1592 // write back XML file 1573 // write back XML file
1593 1574
1594 } 1575 }
1595 setModified( true ); 1576 setModified( true );
1596 } 1577 }
1597 } else { 1578 } else {
1598 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1579 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1599 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1580 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1600 question, i18n("Ok")) ; 1581 question, i18n("Ok")) ;
1601 } 1582 }
1602 delete calendar; 1583 delete calendar;
1603 updateView(); 1584 updateView();
1604 return syncOK; 1585 return syncOK;
1605 1586
1606 1587
1607#endif 1588#endif
1608 1589
1609} 1590}
1610 1591
1611void CalendarView::setSyncEventsReadOnly() 1592void CalendarView::setSyncEventsReadOnly()
1612{ 1593{
1613 Event * ev; 1594 Event * ev;
1614 QPtrList<Event> eL = mCalendar->rawEvents(); 1595 QPtrList<Event> eL = mCalendar->rawEvents();
1615 ev = eL.first(); 1596 ev = eL.first();
1616 while ( ev ) { 1597 while ( ev ) {
1617 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1598 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1618 ev->setReadOnly( true ); 1599 ev->setReadOnly( true );
1619 ev = eL.next(); 1600 ev = eL.next();
1620 } 1601 }
1621} 1602}
1622bool CalendarView::openCalendar(QString filename, bool merge) 1603bool CalendarView::openCalendar(QString filename, bool merge)
1623{ 1604{
1624 1605
1625 if (filename.isEmpty()) { 1606 if (filename.isEmpty()) {
1626 return false; 1607 return false;
1627 } 1608 }
1628 1609
1629 if (!QFile::exists(filename)) { 1610 if (!QFile::exists(filename)) {
1630 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1611 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1631 return false; 1612 return false;
1632 } 1613 }
1633 1614
1634 globalFlagBlockAgenda = 1; 1615 globalFlagBlockAgenda = 1;
1635 if (!merge) mCalendar->close(); 1616 if (!merge) mCalendar->close();
1636 1617
1637 mStorage->setFileName( filename ); 1618 mStorage->setFileName( filename );
1638 1619
1639 if ( mStorage->load() ) { 1620 if ( mStorage->load() ) {
1640 if ( merge ) ;//setModified( true ); 1621 if ( merge ) ;//setModified( true );
1641 else { 1622 else {
1642 //setModified( true ); 1623 //setModified( true );
1643 mViewManager->setDocumentId( filename ); 1624 mViewManager->setDocumentId( filename );
1644 mDialogManager->setDocumentId( filename ); 1625 mDialogManager->setDocumentId( filename );
1645 mTodoList->setDocumentId( filename ); 1626 mTodoList->setDocumentId( filename );
1646 } 1627 }
1647 globalFlagBlockAgenda = 2; 1628 globalFlagBlockAgenda = 2;
1648 // if ( getLastSyncEvent() ) 1629 // if ( getLastSyncEvent() )
1649 // getLastSyncEvent()->setReadOnly( true ); 1630 // getLastSyncEvent()->setReadOnly( true );
1650 mCalendar->reInitAlarmSettings(); 1631 mCalendar->reInitAlarmSettings();
1651 setSyncEventsReadOnly(); 1632 setSyncEventsReadOnly();
1652 updateUnmanagedViews(); 1633 updateUnmanagedViews();
1653 updateView(); 1634 updateView();
1654 if ( filename != MainWindow::defaultFileName() ) { 1635 if ( filename != MainWindow::defaultFileName() ) {
1655 saveCalendar( MainWindow::defaultFileName() ); 1636 saveCalendar( MainWindow::defaultFileName() );
1656 } else { 1637 } else {
1657 QFileInfo finf ( MainWindow::defaultFileName()); 1638 QFileInfo finf ( MainWindow::defaultFileName());
1658 if ( finf.exists() ) { 1639 if ( finf.exists() ) {
1659 setLoadedFileVersion( finf.lastModified () ); 1640 setLoadedFileVersion( finf.lastModified () );
1660 } 1641 }
1661 } 1642 }
1662 return true; 1643 return true;
1663 } else { 1644 } else {
1664 // while failing to load, the calendar object could 1645 // while failing to load, the calendar object could
1665 // have become partially populated. Clear it out. 1646 // have become partially populated. Clear it out.
1666 if ( !merge ) { 1647 if ( !merge ) {
1667 mCalendar->close(); 1648 mCalendar->close();
1668 mViewManager->setDocumentId( filename ); 1649 mViewManager->setDocumentId( filename );
1669 mDialogManager->setDocumentId( filename ); 1650 mDialogManager->setDocumentId( filename );
1670 mTodoList->setDocumentId( filename ); 1651 mTodoList->setDocumentId( filename );
1671 } 1652 }
1672 1653
1673 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1654 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1674 1655
1675 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 1656 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
1676 globalFlagBlockAgenda = 2; 1657 globalFlagBlockAgenda = 2;
1677 mCalendar->reInitAlarmSettings(); 1658 mCalendar->reInitAlarmSettings();
1678 setSyncEventsReadOnly(); 1659 setSyncEventsReadOnly();
1679 updateUnmanagedViews(); 1660 updateUnmanagedViews();
1680 updateView(); 1661 updateView();
1681 } 1662 }
1682 return false; 1663 return false;
1683} 1664}
1684void CalendarView::showOpenError() 1665void CalendarView::showOpenError()
1685{ 1666{
1686 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 1667 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
1687} 1668}
1688void CalendarView::setLoadedFileVersion(QDateTime dt) 1669void CalendarView::setLoadedFileVersion(QDateTime dt)
1689{ 1670{
1690 loadedFileVersion = dt; 1671 loadedFileVersion = dt;
1691} 1672}
1692bool CalendarView::checkFileChanged(QString fn) 1673bool CalendarView::checkFileChanged(QString fn)
1693{ 1674{
1694 QFileInfo finf ( fn ); 1675 QFileInfo finf ( fn );
1695 if ( !finf.exists() ) 1676 if ( !finf.exists() )
1696 return true; 1677 return true;
1697 QDateTime dt = finf.lastModified (); 1678 QDateTime dt = finf.lastModified ();
1698 if ( dt <= loadedFileVersion ) 1679 if ( dt <= loadedFileVersion )
1699 return false; 1680 return false;
1700 return true; 1681 return true;
1701 1682
1702} 1683}
1703void CalendarView::watchSavedFile() 1684void CalendarView::watchSavedFile()
1704{ 1685{
1705 QFileInfo finf ( MainWindow::defaultFileName()); 1686 QFileInfo finf ( MainWindow::defaultFileName());
1706 if ( !finf.exists() ) 1687 if ( !finf.exists() )
1707 return; 1688 return;
1708 QDateTime dt = finf.lastModified (); 1689 QDateTime dt = finf.lastModified ();
1709 if ( dt < loadedFileVersion ) { 1690 if ( dt < loadedFileVersion ) {
1710 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 1691 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
1711 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 1692 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1712 return; 1693 return;
1713 } 1694 }
1714 loadedFileVersion = dt; 1695 loadedFileVersion = dt;
1715} 1696}
1716 1697
1717bool CalendarView::checkFileVersion(QString fn) 1698bool CalendarView::checkFileVersion(QString fn)
1718{ 1699{
1719 QFileInfo finf ( fn ); 1700 QFileInfo finf ( fn );
1720 if ( !finf.exists() ) 1701 if ( !finf.exists() )
1721 return true; 1702 return true;
1722 QDateTime dt = finf.lastModified (); 1703 QDateTime dt = finf.lastModified ();
1723 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1704 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1724 //qDebug("file on disk version %s",dt.toString().latin1()); 1705 //qDebug("file on disk version %s",dt.toString().latin1());
1725 if ( dt <= loadedFileVersion ) 1706 if ( dt <= loadedFileVersion )
1726 return true; 1707 return true;
1727 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)) , 1708 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)) ,
1728 i18n("KO/Pi Warning"),i18n("Overwrite"), 1709 i18n("KO/Pi Warning"),i18n("Overwrite"),
1729 i18n("Sync+save")); 1710 i18n("Sync+save"));
1730 1711
1731 if ( km == KMessageBox::Cancel ) 1712 if ( km == KMessageBox::Cancel )
1732 return false; 1713 return false;
1733 if ( km == KMessageBox::Yes ) 1714 if ( km == KMessageBox::Yes )
1734 return true; 1715 return true;
1735 1716
1736 setSyncDevice("deleteaftersync" ); 1717 setSyncDevice("deleteaftersync" );
1737 mSyncManager->mAskForPreferences = true; 1718 mSyncManager->mAskForPreferences = true;
1738 mSyncManager->mSyncAlgoPrefs = 3; 1719 mSyncManager->mSyncAlgoPrefs = 3;
1739 mSyncManager->mWriteBackFile = false; 1720 mSyncManager->mWriteBackFile = false;
1740 mSyncManager->mWriteBackExistingOnly = false; 1721 mSyncManager->mWriteBackExistingOnly = false;
1741 mSyncManager->mShowSyncSummary = false; 1722 mSyncManager->mShowSyncSummary = false;
1742 syncCalendar( fn, 3 ); 1723 syncCalendar( fn, 3 );
1743 Event * e = getLastSyncEvent(); 1724 Event * e = getLastSyncEvent();
1744 mCalendar->deleteEvent ( e ); 1725 mCalendar->deleteEvent ( e );
1745 updateView(); 1726 updateView();
1746 return true; 1727 return true;
1747} 1728}
1748 1729
1749bool CalendarView::saveCalendar( QString filename ) 1730bool CalendarView::saveCalendar( QString filename )
1750{ 1731{
1751 1732
1752 // Store back all unsaved data into calendar object 1733 // Store back all unsaved data into calendar object
1753 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1734 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1754 if ( mViewManager->currentView() ) 1735 if ( mViewManager->currentView() )
1755 mViewManager->currentView()->flushView(); 1736 mViewManager->currentView()->flushView();
1756 1737
1757 1738
1758 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 1739 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
1759 mStorage->setSaveFormat( new ICalFormat() ); 1740 mStorage->setSaveFormat( new ICalFormat() );
1760 mStorage->setFileName( filename ); 1741 mStorage->setFileName( filename );
1761 bool success; 1742 bool success;
1762 success = mStorage->save(); 1743 success = mStorage->save();
1763 if ( !success ) { 1744 if ( !success ) {
1764 return false; 1745 return false;
1765 } 1746 }
1766 if ( filename == MainWindow::defaultFileName() ) { 1747 if ( filename == MainWindow::defaultFileName() ) {
1767 setLoadedFileVersion( lfv ); 1748 setLoadedFileVersion( lfv );
1768 watchSavedFile(); 1749 watchSavedFile();
1769 } 1750 }
1770 return true; 1751 return true;
1771} 1752}
1772 1753
1773void CalendarView::closeCalendar() 1754void CalendarView::closeCalendar()
1774{ 1755{
1775 1756
1776 // child windows no longer valid 1757 // child windows no longer valid
1777 emit closingDown(); 1758 emit closingDown();
1778 1759
1779 mCalendar->close(); 1760 mCalendar->close();
1780 setModified(false); 1761 setModified(false);
1781 updateView(); 1762 updateView();
1782} 1763}
1783 1764
1784void CalendarView::archiveCalendar() 1765void CalendarView::archiveCalendar()
1785{ 1766{
1786 mDialogManager->showArchiveDialog(); 1767 mDialogManager->showArchiveDialog();
1787} 1768}
1788 1769
1789 1770
1790void CalendarView::readSettings() 1771void CalendarView::readSettings()
1791{ 1772{
1792 1773
1793 1774
1794 // mViewManager->showAgendaView(); 1775 // mViewManager->showAgendaView();
1795 QString str; 1776 QString str;
1796 //qDebug("CalendarView::readSettings() "); 1777 //qDebug("CalendarView::readSettings() ");
1797 // read settings from the KConfig, supplying reasonable 1778 // read settings from the KConfig, supplying reasonable
1798 // defaults where none are to be found 1779 // defaults where none are to be found
1799 KConfig *config = KOGlobals::config(); 1780 KConfig *config = KOGlobals::config();
1800#ifndef KORG_NOSPLITTER 1781#ifndef KORG_NOSPLITTER
1801 config->setGroup("KOrganizer Geometry"); 1782 config->setGroup("KOrganizer Geometry");
1802 1783
1803 QValueList<int> sizes = config->readIntListEntry("Separator1"); 1784 QValueList<int> sizes = config->readIntListEntry("Separator1");
1804 if (sizes.count() != 2) { 1785 if (sizes.count() != 2) {
1805 sizes << mDateNavigator->minimumSizeHint().width(); 1786 sizes << mDateNavigator->minimumSizeHint().width();
1806 sizes << 300; 1787 sizes << 300;
1807 } 1788 }
1808 mPanner->setSizes(sizes); 1789 mPanner->setSizes(sizes);
1809 1790
1810 sizes = config->readIntListEntry("Separator2"); 1791 sizes = config->readIntListEntry("Separator2");
1811 if ( ( mResourceView && sizes.count() == 4 ) || 1792 if ( ( mResourceView && sizes.count() == 4 ) ||
1812 ( !mResourceView && sizes.count() == 3 ) ) { 1793 ( !mResourceView && sizes.count() == 3 ) ) {
1813 mLeftSplitter->setSizes(sizes); 1794 mLeftSplitter->setSizes(sizes);
1814 } 1795 }
1815#endif 1796#endif
1816 globalFlagBlockAgenda = 1; 1797 globalFlagBlockAgenda = 1;
1817 mViewManager->showAgendaView(); 1798 mViewManager->showAgendaView();
1818 //mViewManager->readSettings( config ); 1799 //mViewManager->readSettings( config );
1819 mTodoList->restoreLayout(config,QString("Todo Layout")); 1800 mTodoList->restoreLayout(config,QString("Todo Layout"));
1820 readFilterSettings(config); 1801 readFilterSettings(config);
1821 config->setGroup( "Views" ); 1802 config->setGroup( "Views" );
1822 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 1803 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
1823 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 1804 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
1824 else if ( dateCount == 7 ) mNavigator->selectWeek(); 1805 else if ( dateCount == 7 ) mNavigator->selectWeek();
1825 else mNavigator->selectDates( dateCount ); 1806 else mNavigator->selectDates( dateCount );
1826 // mViewManager->readSettings( config ); 1807 // mViewManager->readSettings( config );
1827 updateConfig(); 1808 updateConfig();
1828 globalFlagBlockAgenda = 2; 1809 globalFlagBlockAgenda = 2;
1829 mViewManager->readSettings( config ); 1810 mViewManager->readSettings( config );
1830#ifdef DESKTOP_VERSION 1811#ifdef DESKTOP_VERSION
1831 config->setGroup("WidgetLayout"); 1812 config->setGroup("WidgetLayout");
1832 QStringList list; 1813 QStringList list;
1833 list = config->readListEntry("MainLayout"); 1814 list = config->readListEntry("MainLayout");
1834 int x,y,w,h; 1815 int x,y,w,h;
1835 if ( ! list.isEmpty() ) { 1816 if ( ! list.isEmpty() ) {
1836 x = list[0].toInt(); 1817 x = list[0].toInt();
1837 y = list[1].toInt(); 1818 y = list[1].toInt();
1838 w = list[2].toInt(); 1819 w = list[2].toInt();
1839 h = list[3].toInt(); 1820 h = list[3].toInt();
1840 topLevelWidget()->setGeometry(x,y,w,h); 1821 topLevelWidget()->setGeometry(x,y,w,h);
1841 1822
1842 } else { 1823 } else {
1843 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 1824 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
1844 } 1825 }
1845 list = config->readListEntry("EditEventLayout"); 1826 list = config->readListEntry("EditEventLayout");
1846 if ( ! list.isEmpty() ) { 1827 if ( ! list.isEmpty() ) {
1847 x = list[0].toInt(); 1828 x = list[0].toInt();
1848 y = list[1].toInt(); 1829 y = list[1].toInt();
1849 w = list[2].toInt(); 1830 w = list[2].toInt();
1850 h = list[3].toInt(); 1831 h = list[3].toInt();
1851 mEventEditor->setGeometry(x,y,w,h); 1832 mEventEditor->setGeometry(x,y,w,h);
1852 1833
1853 } 1834 }
1854 list = config->readListEntry("EditTodoLayout"); 1835 list = config->readListEntry("EditTodoLayout");
1855 if ( ! list.isEmpty() ) { 1836 if ( ! list.isEmpty() ) {
1856 x = list[0].toInt(); 1837 x = list[0].toInt();
1857 y = list[1].toInt(); 1838 y = list[1].toInt();
1858 w = list[2].toInt(); 1839 w = list[2].toInt();
1859 h = list[3].toInt(); 1840 h = list[3].toInt();
1860 mTodoEditor->setGeometry(x,y,w,h); 1841 mTodoEditor->setGeometry(x,y,w,h);
1861 1842
1862 } 1843 }
1863 list = config->readListEntry("ViewerLayout"); 1844 list = config->readListEntry("ViewerLayout");
1864 if ( ! list.isEmpty() ) { 1845 if ( ! list.isEmpty() ) {
1865 x = list[0].toInt(); 1846 x = list[0].toInt();
1866 y = list[1].toInt(); 1847 y = list[1].toInt();
1867 w = list[2].toInt(); 1848 w = list[2].toInt();
1868 h = list[3].toInt(); 1849 h = list[3].toInt();
1869 getEventViewerDialog()->setGeometry(x,y,w,h); 1850 getEventViewerDialog()->setGeometry(x,y,w,h);
1870 } 1851 }
1871#endif 1852#endif
1872 1853
1873} 1854}
1874 1855
1875 1856
1876void CalendarView::writeSettings() 1857void CalendarView::writeSettings()
1877{ 1858{
1878 // kdDebug() << "CalendarView::writeSettings" << endl; 1859 // kdDebug() << "CalendarView::writeSettings" << endl;
1879 1860
1880 KConfig *config = KOGlobals::config(); 1861 KConfig *config = KOGlobals::config();
1881 1862
1882#ifndef KORG_NOSPLITTER 1863#ifndef KORG_NOSPLITTER
1883 config->setGroup("KOrganizer Geometry"); 1864 config->setGroup("KOrganizer Geometry");
1884 1865
1885 QValueList<int> list = mPanner->sizes(); 1866 QValueList<int> list = mPanner->sizes();
1886 config->writeEntry("Separator1",list); 1867 config->writeEntry("Separator1",list);
1887 1868
1888 list = mLeftSplitter->sizes(); 1869 list = mLeftSplitter->sizes();
1889 config->writeEntry("Separator2",list); 1870 config->writeEntry("Separator2",list);
1890#endif 1871#endif
1891 1872
1892 mViewManager->writeSettings( config ); 1873 mViewManager->writeSettings( config );
1893 mTodoList->saveLayout(config,QString("Todo Layout")); 1874 mTodoList->saveLayout(config,QString("Todo Layout"));
1894 mDialogManager->writeSettings( config ); 1875 mDialogManager->writeSettings( config );
1895 //KOPrefs::instance()->usrWriteConfig(); 1876 //KOPrefs::instance()->usrWriteConfig();
1896 KOPrefs::instance()->writeConfig(); 1877 KOPrefs::instance()->writeConfig();
1897 1878
1898 writeFilterSettings(config); 1879 writeFilterSettings(config);
1899 1880
1900 config->setGroup( "Views" ); 1881 config->setGroup( "Views" );
1901 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 1882 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
1902 1883
1903#ifdef DESKTOP_VERSION 1884#ifdef DESKTOP_VERSION
1904 config->setGroup("WidgetLayout"); 1885 config->setGroup("WidgetLayout");
1905 QStringList list ;//= config->readListEntry("MainLayout"); 1886 QStringList list ;//= config->readListEntry("MainLayout");
1906 int x,y,w,h; 1887 int x,y,w,h;
1907 QWidget* wid; 1888 QWidget* wid;
1908 wid = topLevelWidget(); 1889 wid = topLevelWidget();
1909 x = wid->geometry().x(); 1890 x = wid->geometry().x();
1910 y = wid->geometry().y(); 1891 y = wid->geometry().y();
1911 w = wid->width(); 1892 w = wid->width();
1912 h = wid->height(); 1893 h = wid->height();
1913 list.clear(); 1894 list.clear();
1914 list << QString::number( x ); 1895 list << QString::number( x );
1915 list << QString::number( y ); 1896 list << QString::number( y );
1916 list << QString::number( w ); 1897 list << QString::number( w );
1917 list << QString::number( h ); 1898 list << QString::number( h );
1918 config->writeEntry("MainLayout",list ); 1899 config->writeEntry("MainLayout",list );
1919 1900
1920 wid = mEventEditor; 1901 wid = mEventEditor;
1921 x = wid->geometry().x(); 1902 x = wid->geometry().x();
1922 y = wid->geometry().y(); 1903 y = wid->geometry().y();
1923 w = wid->width(); 1904 w = wid->width();
1924 h = wid->height(); 1905 h = wid->height();
1925 list.clear(); 1906 list.clear();
1926 list << QString::number( x ); 1907 list << QString::number( x );
1927 list << QString::number( y ); 1908 list << QString::number( y );
1928 list << QString::number( w ); 1909 list << QString::number( w );
1929 list << QString::number( h ); 1910 list << QString::number( h );
1930 config->writeEntry("EditEventLayout",list ); 1911 config->writeEntry("EditEventLayout",list );
1931 1912
1932 wid = mTodoEditor; 1913 wid = mTodoEditor;
1933 x = wid->geometry().x(); 1914 x = wid->geometry().x();
1934 y = wid->geometry().y(); 1915 y = wid->geometry().y();
1935 w = wid->width(); 1916 w = wid->width();
1936 h = wid->height(); 1917 h = wid->height();
1937 list.clear(); 1918 list.clear();
1938 list << QString::number( x ); 1919 list << QString::number( x );
1939 list << QString::number( y ); 1920 list << QString::number( y );
1940 list << QString::number( w ); 1921 list << QString::number( w );
1941 list << QString::number( h ); 1922 list << QString::number( h );
1942 config->writeEntry("EditTodoLayout",list ); 1923 config->writeEntry("EditTodoLayout",list );
1943 wid = getEventViewerDialog(); 1924 wid = getEventViewerDialog();
1944 x = wid->geometry().x(); 1925 x = wid->geometry().x();
1945 y = wid->geometry().y(); 1926 y = wid->geometry().y();
1946 w = wid->width(); 1927 w = wid->width();
1947 h = wid->height(); 1928 h = wid->height();
1948 list.clear(); 1929 list.clear();
1949 list << QString::number( x ); 1930 list << QString::number( x );
1950 list << QString::number( y ); 1931 list << QString::number( y );
1951 list << QString::number( w ); 1932 list << QString::number( w );
1952 list << QString::number( h ); 1933 list << QString::number( h );
1953 config->writeEntry("ViewerLayout",list ); 1934 config->writeEntry("ViewerLayout",list );
1954 wid = mDialogManager->getSearchDialog(); 1935 wid = mDialogManager->getSearchDialog();
1955 if ( wid ) { 1936 if ( wid ) {
1956 x = wid->geometry().x(); 1937 x = wid->geometry().x();
1957 y = wid->geometry().y(); 1938 y = wid->geometry().y();
1958 w = wid->width(); 1939 w = wid->width();
1959 h = wid->height(); 1940 h = wid->height();
1960 list.clear(); 1941 list.clear();
1961 list << QString::number( x ); 1942 list << QString::number( x );
1962 list << QString::number( y ); 1943 list << QString::number( y );
1963 list << QString::number( w ); 1944 list << QString::number( w );
1964 list << QString::number( h ); 1945 list << QString::number( h );
1965 config->writeEntry("SearchLayout",list ); 1946 config->writeEntry("SearchLayout",list );
1966 } 1947 }
1967#endif 1948#endif
1968 1949
1969 1950
1970 config->sync(); 1951 config->sync();
1971} 1952}
1972 1953
1973void CalendarView::readFilterSettings(KConfig *config) 1954void CalendarView::readFilterSettings(KConfig *config)
1974{ 1955{
1975 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 1956 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
1976 1957
1977 mFilters.clear(); 1958 mFilters.clear();
1978 1959
1979 config->setGroup("General"); 1960 config->setGroup("General");
1980 QStringList filterList = config->readListEntry("CalendarFilters"); 1961 QStringList filterList = config->readListEntry("CalendarFilters");
1981 1962
1982 QStringList::ConstIterator it = filterList.begin(); 1963 QStringList::ConstIterator it = filterList.begin();
1983 QStringList::ConstIterator end = filterList.end(); 1964 QStringList::ConstIterator end = filterList.end();
1984 while(it != end) { 1965 while(it != end) {
1985 // kdDebug() << " filter: " << (*it) << endl; 1966 // kdDebug() << " filter: " << (*it) << endl;
1986 1967
1987 CalFilter *filter; 1968 CalFilter *filter;
1988 filter = new CalFilter(*it); 1969 filter = new CalFilter(*it);
1989 config->setGroup("Filter_" + (*it)); 1970 config->setGroup("Filter_" + (*it));
1990 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 1971 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
1991 filter->setCriteria(config->readNumEntry("Criteria",0)); 1972 filter->setCriteria(config->readNumEntry("Criteria",0));
1992 filter->setCategoryList(config->readListEntry("CategoryList")); 1973 filter->setCategoryList(config->readListEntry("CategoryList"));
1993 mFilters.append(filter); 1974 mFilters.append(filter);
1994 1975
1995 ++it; 1976 ++it;
1996 } 1977 }
1997 1978
1998 if (mFilters.count() == 0) { 1979 if (mFilters.count() == 0) {
1999 CalFilter *filter = new CalFilter(i18n("Default")); 1980 CalFilter *filter = new CalFilter(i18n("Default"));
2000 mFilters.append(filter); 1981 mFilters.append(filter);
2001 } 1982 }
2002 mFilterView->updateFilters(); 1983 mFilterView->updateFilters();
2003 config->setGroup("FilterView"); 1984 config->setGroup("FilterView");
2004 1985
2005 mFilterView->blockSignals(true); 1986 mFilterView->blockSignals(true);
2006 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 1987 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
2007 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 1988 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
2008 mFilterView->blockSignals(false); 1989 mFilterView->blockSignals(false);
2009 // We do it manually to avoid it being done twice by the above calls 1990 // We do it manually to avoid it being done twice by the above calls
2010 updateFilter(); 1991 updateFilter();
2011} 1992}
2012 1993
2013void CalendarView::writeFilterSettings(KConfig *config) 1994void CalendarView::writeFilterSettings(KConfig *config)
2014{ 1995{
2015 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 1996 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
2016 1997
2017 QStringList filterList; 1998 QStringList filterList;
2018 1999
2019 CalFilter *filter = mFilters.first(); 2000 CalFilter *filter = mFilters.first();
2020 while(filter) { 2001 while(filter) {
2021 // kdDebug() << " fn: " << filter->name() << endl; 2002 // kdDebug() << " fn: " << filter->name() << endl;
2022 filterList << filter->name(); 2003 filterList << filter->name();
2023 config->setGroup("Filter_" + filter->name()); 2004 config->setGroup("Filter_" + filter->name());
2024 config->writeEntry("Criteria",filter->criteria()); 2005 config->writeEntry("Criteria",filter->criteria());
2025 config->writeEntry("CategoryList",filter->categoryList()); 2006 config->writeEntry("CategoryList",filter->categoryList());
2026 filter = mFilters.next(); 2007 filter = mFilters.next();
2027 } 2008 }
2028 config->setGroup("General"); 2009 config->setGroup("General");
2029 config->writeEntry("CalendarFilters",filterList); 2010 config->writeEntry("CalendarFilters",filterList);
2030 2011
2031 config->setGroup("FilterView"); 2012 config->setGroup("FilterView");
2032 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 2013 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
2033 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 2014 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
2034} 2015}
2035 2016
2036 2017
2037void CalendarView::goToday() 2018void CalendarView::goToday()
2038{ 2019{
2039 if ( mViewManager->currentView()->isMonthView() ) 2020 if ( mViewManager->currentView()->isMonthView() )
2040 mNavigator->selectTodayMonth(); 2021 mNavigator->selectTodayMonth();
2041 else 2022 else
2042 mNavigator->selectToday(); 2023 mNavigator->selectToday();
2043} 2024}
2044 2025
2045void CalendarView::goNext() 2026void CalendarView::goNext()
2046{ 2027{
2047 mNavigator->selectNext(); 2028 mNavigator->selectNext();
2048} 2029}
2049 2030
2050void CalendarView::goPrevious() 2031void CalendarView::goPrevious()
2051{ 2032{
2052 mNavigator->selectPrevious(); 2033 mNavigator->selectPrevious();
2053} 2034}
2054void CalendarView::goNextMonth() 2035void CalendarView::goNextMonth()
2055{ 2036{
2056 mNavigator->selectNextMonth(); 2037 mNavigator->selectNextMonth();
2057} 2038}
2058 2039
2059void CalendarView::goPreviousMonth() 2040void CalendarView::goPreviousMonth()
2060{ 2041{
2061 mNavigator->selectPreviousMonth(); 2042 mNavigator->selectPreviousMonth();
2062} 2043}
2063void CalendarView::writeLocale() 2044void CalendarView::writeLocale()
2064{ 2045{
2065 //KPimGlobalPrefs::instance()->setGlobalConfig(); 2046 //KPimGlobalPrefs::instance()->setGlobalConfig();
2066#if 0 2047#if 0
2067 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); 2048 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime );
2068 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); 2049 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday );
2069 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); 2050 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate );
2070 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); 2051 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage );
2071 QString dummy = KOPrefs::instance()->mUserDateFormatLong; 2052 QString dummy = KOPrefs::instance()->mUserDateFormatLong;
2072 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 2053 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
2073 dummy = KOPrefs::instance()->mUserDateFormatShort; 2054 dummy = KOPrefs::instance()->mUserDateFormatShort;
2074 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 2055 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
2075 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, 2056 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving,
2076 KOPrefs::instance()->mDaylightsavingStart, 2057 KOPrefs::instance()->mDaylightsavingStart,
2077 KOPrefs::instance()->mDaylightsavingEnd ); 2058 KOPrefs::instance()->mDaylightsavingEnd );
2078 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); 2059 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId );
2079#endif 2060#endif
2080} 2061}
2081void CalendarView::updateConfig() 2062void CalendarView::updateConfig()
2082{ 2063{
2083 writeLocale(); 2064 writeLocale();
2084 if ( KOPrefs::instance()->mUseAppColors ) 2065 if ( KOPrefs::instance()->mUseAppColors )
2085 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 2066 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
2086 emit configChanged(); 2067 emit configChanged();
2087 mTodoList->updateConfig(); 2068 mTodoList->updateConfig();
2088 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 2069 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
2089 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2070 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2090 // To make the "fill window" configurations work 2071 // To make the "fill window" configurations work
2091 //mViewManager->raiseCurrentView(); 2072 //mViewManager->raiseCurrentView();
2092} 2073}
2093 2074
2094 2075
2095void CalendarView::eventChanged(Event *event) 2076void CalendarView::eventChanged(Event *event)
2096{ 2077{
2097 changeEventDisplay(event,KOGlobals::EVENTEDITED); 2078 changeEventDisplay(event,KOGlobals::EVENTEDITED);
2098 //updateUnmanagedViews(); 2079 //updateUnmanagedViews();
2099} 2080}
2100 2081
2101void CalendarView::eventAdded(Event *event) 2082void CalendarView::eventAdded(Event *event)
2102{ 2083{
2103 changeEventDisplay(event,KOGlobals::EVENTADDED); 2084 changeEventDisplay(event,KOGlobals::EVENTADDED);
2104} 2085}
2105 2086
2106void CalendarView::eventToBeDeleted(Event *) 2087void CalendarView::eventToBeDeleted(Event *)
2107{ 2088{
2108 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 2089 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
2109} 2090}
2110 2091
2111void CalendarView::eventDeleted() 2092void CalendarView::eventDeleted()
2112{ 2093{
2113 changeEventDisplay(0,KOGlobals::EVENTDELETED); 2094 changeEventDisplay(0,KOGlobals::EVENTDELETED);
2114} 2095}
2115void CalendarView::changeTodoDisplay(Todo *which, int action) 2096void CalendarView::changeTodoDisplay(Todo *which, int action)
2116{ 2097{
2117 changeIncidenceDisplay((Incidence *)which, action); 2098 changeIncidenceDisplay((Incidence *)which, action);
2118 mDateNavigator->updateView(); //LR 2099 mDateNavigator->updateView(); //LR
2119 //mDialogManager->updateSearchDialog(); 2100 //mDialogManager->updateSearchDialog();
2120 2101
2121 if (which) { 2102 if (which) {
2122 mViewManager->updateWNview(); 2103 mViewManager->updateWNview();
2123 //mTodoList->updateView(); 2104 //mTodoList->updateView();
2124 } 2105 }
2125 2106
2126} 2107}
2127 2108
2128void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 2109void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
2129{ 2110{
2130 updateUnmanagedViews(); 2111 updateUnmanagedViews();
2131 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 2112 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
2132 if ( action == KOGlobals::EVENTDELETED ) { //delete 2113 if ( action == KOGlobals::EVENTDELETED ) { //delete
2133 mCalendar->checkAlarmForIncidence( 0, true ); 2114 mCalendar->checkAlarmForIncidence( 0, true );
2134 if ( mEventViewerDialog ) 2115 if ( mEventViewerDialog )
2135 mEventViewerDialog->hide(); 2116 mEventViewerDialog->hide();
2136 } 2117 }
2137 else 2118 else
2138 mCalendar->checkAlarmForIncidence( which , false ); 2119 mCalendar->checkAlarmForIncidence( which , false );
2139} 2120}
2140 2121
2141// most of the changeEventDisplays() right now just call the view's 2122// most of the changeEventDisplays() right now just call the view's
2142// total update mode, but they SHOULD be recoded to be more refresh-efficient. 2123// total update mode, but they SHOULD be recoded to be more refresh-efficient.
2143void CalendarView::changeEventDisplay(Event *which, int action) 2124void CalendarView::changeEventDisplay(Event *which, int action)
2144{ 2125{
2145 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 2126 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
2146 changeIncidenceDisplay((Incidence *)which, action); 2127 changeIncidenceDisplay((Incidence *)which, action);
2147 mDateNavigator->updateView(); 2128 mDateNavigator->updateView();
2148 //mDialogManager->updateSearchDialog(); 2129 //mDialogManager->updateSearchDialog();
2149 2130
2150 if (which) { 2131 if (which) {
2151 // If there is an event view visible update the display 2132 // If there is an event view visible update the display
2152 mViewManager->currentView()->changeEventDisplay(which,action); 2133 mViewManager->currentView()->changeEventDisplay(which,action);
2153 // TODO: check, if update needed 2134 // TODO: check, if update needed
2154 // if (which->getTodoStatus()) { 2135 // if (which->getTodoStatus()) {
2155 mTodoList->updateView(); 2136 mTodoList->updateView();
2156 // } 2137 // }
2157 } else { 2138 } else {
2158 mViewManager->currentView()->updateView(); 2139 mViewManager->currentView()->updateView();
2159 } 2140 }
2160} 2141}
2161 2142
2162 2143
2163void CalendarView::updateTodoViews() 2144void CalendarView::updateTodoViews()
2164{ 2145{
2165 mTodoList->updateView(); 2146 mTodoList->updateView();
2166 mViewManager->currentView()->updateView(); 2147 mViewManager->currentView()->updateView();
2167 2148
2168} 2149}
2169 2150
2170 2151
2171void CalendarView::updateView(const QDate &start, const QDate &end) 2152void CalendarView::updateView(const QDate &start, const QDate &end)
2172{ 2153{
2173 mTodoList->updateView(); 2154 mTodoList->updateView();
2174 mViewManager->updateView(start, end); 2155 mViewManager->updateView(start, end);
2175 //mDateNavigator->updateView(); 2156 //mDateNavigator->updateView();
2176} 2157}
2177 2158
2178void CalendarView::updateView() 2159void CalendarView::updateView()
2179{ 2160{
2180 DateList tmpList = mNavigator->selectedDates(); 2161 DateList tmpList = mNavigator->selectedDates();
2181 2162
2182 if ( KOPrefs::instance()->mHideNonStartedTodos ) 2163 if ( KOPrefs::instance()->mHideNonStartedTodos )
2183 mTodoList->updateView(); 2164 mTodoList->updateView();
2184 // We assume that the navigator only selects consecutive days. 2165 // We assume that the navigator only selects consecutive days.
2185 updateView( tmpList.first(), tmpList.last() ); 2166 updateView( tmpList.first(), tmpList.last() );
2186} 2167}
2187 2168
2188void CalendarView::updateUnmanagedViews() 2169void CalendarView::updateUnmanagedViews()
2189{ 2170{
2190 mDateNavigator->updateDayMatrix(); 2171 mDateNavigator->updateDayMatrix();
2191} 2172}
2192 2173
2193int CalendarView::msgItemDelete(const QString name) 2174int CalendarView::msgItemDelete(const QString name)
2194{ 2175{
2195 return KMessageBox::warningContinueCancel(this,name +"\n\n"+ 2176 return KMessageBox::warningContinueCancel(this,name +"\n\n"+
2196 i18n("This item will be\npermanently deleted."), 2177 i18n("This item will be\npermanently deleted."),
2197 i18n("KO/Pi Confirmation"),i18n("Delete")); 2178 i18n("KO/Pi Confirmation"),i18n("Delete"));
2198} 2179}
2199 2180
2200 2181
2201void CalendarView::edit_cut() 2182void CalendarView::edit_cut()
2202{ 2183{
2203 Event *anEvent=0; 2184 Event *anEvent=0;
2204 2185
2205 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2186 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2206 2187
2207 if (mViewManager->currentView()->isEventView()) { 2188 if (mViewManager->currentView()->isEventView()) {
2208 if ( incidence && incidence->type() == "Event" ) { 2189 if ( incidence && incidence->type() == "Event" ) {
2209 anEvent = static_cast<Event *>(incidence); 2190 anEvent = static_cast<Event *>(incidence);
2210 } 2191 }
2211 } 2192 }
2212 2193
2213 if (!anEvent) { 2194 if (!anEvent) {
2214 KNotifyClient::beep(); 2195 KNotifyClient::beep();
2215 return; 2196 return;
2216 } 2197 }
2217 DndFactory factory( mCalendar ); 2198 DndFactory factory( mCalendar );
2218 factory.cutIncidence(anEvent); 2199 factory.cutIncidence(anEvent);
2219 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2200 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2220} 2201}
2221 2202
2222void CalendarView::edit_copy() 2203void CalendarView::edit_copy()
2223{ 2204{
2224 Event *anEvent=0; 2205 Event *anEvent=0;
2225 2206
2226 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2207 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2227 2208
2228 if (mViewManager->currentView()->isEventView()) { 2209 if (mViewManager->currentView()->isEventView()) {
2229 if ( incidence && incidence->type() == "Event" ) { 2210 if ( incidence && incidence->type() == "Event" ) {
2230 anEvent = static_cast<Event *>(incidence); 2211 anEvent = static_cast<Event *>(incidence);
2231 } 2212 }
2232 } 2213 }
2233 2214
2234 if (!anEvent) { 2215 if (!anEvent) {
2235 KNotifyClient::beep(); 2216 KNotifyClient::beep();
2236 return; 2217 return;
2237 } 2218 }
2238 DndFactory factory( mCalendar ); 2219 DndFactory factory( mCalendar );
2239 factory.copyIncidence(anEvent); 2220 factory.copyIncidence(anEvent);
2240} 2221}
2241 2222
2242void CalendarView::edit_paste() 2223void CalendarView::edit_paste()
2243{ 2224{
2244 QDate date = mNavigator->selectedDates().first(); 2225 QDate date = mNavigator->selectedDates().first();
2245 2226
2246 DndFactory factory( mCalendar ); 2227 DndFactory factory( mCalendar );
2247 Event *pastedEvent = (Event *)factory.pasteIncidence( date ); 2228 Event *pastedEvent = (Event *)factory.pasteIncidence( date );
2248 2229
2249 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 2230 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
2250} 2231}
2251 2232
2252void CalendarView::edit_options() 2233void CalendarView::edit_options()
2253{ 2234{
2254 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; 2235 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId;
2255 emit save(); 2236 emit save();
2256 emit saveStopTimer(); 2237 emit saveStopTimer();
2257 mDialogManager->showOptionsDialog(); 2238 mDialogManager->showOptionsDialog();
2258 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { 2239 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) {
2259 emit saveStopTimer(); 2240 emit saveStopTimer();
2260 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), 2241 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"),
2261 i18n("Timezone settings"),i18n("Reload"))) { 2242 i18n("Timezone settings"),i18n("Reload"))) {
2262 qDebug("KO: TZ reload cancelled "); 2243 qDebug("KO: TZ reload cancelled ");
2263 return; 2244 return;
2264 } 2245 }
2265 qDebug("KO: Timezone change "); 2246 qDebug("KO: Timezone change ");
2266 openCalendar( MainWindow::defaultFileName() ); 2247 openCalendar( MainWindow::defaultFileName() );
2267 setModified(true); 2248 setModified(true);
2268 } 2249 }
2269 else 2250 else
2270 qDebug("KO: No tz change "); 2251 qDebug("KO: No tz change ");
2271 2252
2272} 2253}
2273 2254
2274 2255
2275void CalendarView::slotSelectPickerDate( QDate d) 2256void CalendarView::slotSelectPickerDate( QDate d)
2276{ 2257{
2277 mDateFrame->hide(); 2258 mDateFrame->hide();
2278 if ( mDatePickerMode == 1 ) { 2259 if ( mDatePickerMode == 1 ) {
2279 mNavigator->slotDaySelect( d ); 2260 mNavigator->slotDaySelect( d );
2280 } else if ( mDatePickerMode == 2 ) { 2261 } else if ( mDatePickerMode == 2 ) {
2281 if ( mMoveIncidence->type() == "Todo" ) { 2262 if ( mMoveIncidence->type() == "Todo" ) {
2282 Todo * to = (Todo *) mMoveIncidence; 2263 Todo * to = (Todo *) mMoveIncidence;
2283 QTime tim; 2264 QTime tim;
2284 if ( to->hasDueDate() ) 2265 if ( to->hasDueDate() )
2285 tim = to->dtDue().time(); 2266 tim = to->dtDue().time();
2286 else { 2267 else {
2287 tim = QTime ( 0,0,0 ); 2268 tim = QTime ( 0,0,0 );
2288 to->setFloats( true ); 2269 to->setFloats( true );
2289 to->setHasDueDate( true ); 2270 to->setHasDueDate( true );
2290 } 2271 }
2291 QDateTime dt ( d,tim ); 2272 QDateTime dt ( d,tim );
2292 to->setDtDue( dt ); 2273 to->setDtDue( dt );
2293 todoChanged( to ); 2274 todoChanged( to );
2294 } else { 2275 } else {
2295 if ( mMoveIncidence->doesRecur() ) { 2276 if ( mMoveIncidence->doesRecur() ) {
2296#if 0 2277#if 0
2297 // PENDING implement this 2278 // PENDING implement this
2298 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); 2279 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate );
2299 mCalendar()->addIncidence( newInc ); 2280 mCalendar()->addIncidence( newInc );
2300 if ( mMoveIncidence->type() == "Todo" ) 2281 if ( mMoveIncidence->type() == "Todo" )
2301 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); 2282 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED );
2302 else 2283 else
2303 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); 2284 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED);
2304 mMoveIncidence = newInc; 2285 mMoveIncidence = newInc;
2305 2286
2306#endif 2287#endif
2307 } 2288 }
2308 QTime tim = mMoveIncidence->dtStart().time(); 2289 QTime tim = mMoveIncidence->dtStart().time();
2309 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2290 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2310 QDateTime dt ( d,tim ); 2291 QDateTime dt ( d,tim );
2311 mMoveIncidence->setDtStart( dt ); 2292 mMoveIncidence->setDtStart( dt );
2312 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2293 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2313 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2294 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2314 } 2295 }
2315 2296
2316 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2297 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2317 } 2298 }
2318} 2299}
2319 2300
2320void CalendarView::removeCategories() 2301void CalendarView::removeCategories()
2321{ 2302{
2322 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2303 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2323 QStringList catList = KOPrefs::instance()->mCustomCategories; 2304 QStringList catList = KOPrefs::instance()->mCustomCategories;
2324 QStringList catIncList; 2305 QStringList catIncList;
2325 QStringList newCatList; 2306 QStringList newCatList;
2326 Incidence* inc = incList.first(); 2307 Incidence* inc = incList.first();
2327 int i; 2308 int i;
2328 int count = 0; 2309 int count = 0;
2329 while ( inc ) { 2310 while ( inc ) {
2330 newCatList.clear(); 2311 newCatList.clear();
2331 catIncList = inc->categories() ; 2312 catIncList = inc->categories() ;
2332 for( i = 0; i< catIncList.count(); ++i ) { 2313 for( i = 0; i< catIncList.count(); ++i ) {
2333 if ( catList.contains (catIncList[i])) 2314 if ( catList.contains (catIncList[i]))
2334 newCatList.append( catIncList[i] ); 2315 newCatList.append( catIncList[i] );
2335 } 2316 }
2336 newCatList.sort(); 2317 newCatList.sort();
2337 inc->setCategories( newCatList.join(",") ); 2318 inc->setCategories( newCatList.join(",") );
2338 inc = incList.next(); 2319 inc = incList.next();
2339 } 2320 }
2340} 2321}
2341 2322
2342int CalendarView::addCategories() 2323int CalendarView::addCategories()
2343{ 2324{
2344 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2325 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2345 QStringList catList = KOPrefs::instance()->mCustomCategories; 2326 QStringList catList = KOPrefs::instance()->mCustomCategories;
2346 QStringList catIncList; 2327 QStringList catIncList;
2347 Incidence* inc = incList.first(); 2328 Incidence* inc = incList.first();
2348 int i; 2329 int i;
2349 int count = 0; 2330 int count = 0;
2350 while ( inc ) { 2331 while ( inc ) {
2351 catIncList = inc->categories() ; 2332 catIncList = inc->categories() ;
2352 for( i = 0; i< catIncList.count(); ++i ) { 2333 for( i = 0; i< catIncList.count(); ++i ) {
2353 if ( !catList.contains (catIncList[i])) { 2334 if ( !catList.contains (catIncList[i])) {
2354 catList.append( catIncList[i] ); 2335 catList.append( catIncList[i] );
2355 //qDebug("add cat %s ", catIncList[i].latin1()); 2336 //qDebug("add cat %s ", catIncList[i].latin1());
2356 ++count; 2337 ++count;
2357 } 2338 }
2358 } 2339 }
2359 inc = incList.next(); 2340 inc = incList.next();
2360 } 2341 }
2361 catList.sort(); 2342 catList.sort();
2362 KOPrefs::instance()->mCustomCategories = catList; 2343 KOPrefs::instance()->mCustomCategories = catList;
2363 return count; 2344 return count;
2364} 2345}
2365 2346
2366void CalendarView::manageCategories() 2347void CalendarView::manageCategories()
2367{ 2348{
2368 KOCatPrefs* cp = new KOCatPrefs(); 2349 KOCatPrefs* cp = new KOCatPrefs();
2369 cp->show(); 2350 cp->show();
2370 int w =cp->sizeHint().width() ; 2351 int w =cp->sizeHint().width() ;
2371 int h = cp->sizeHint().height() ; 2352 int h = cp->sizeHint().height() ;
2372 int dw = QApplication::desktop()->width(); 2353 int dw = QApplication::desktop()->width();
2373 int dh = QApplication::desktop()->height(); 2354 int dh = QApplication::desktop()->height();
2374 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2355 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2375 if ( !cp->exec() ) { 2356 if ( !cp->exec() ) {
2376 delete cp; 2357 delete cp;
2377 return; 2358 return;
2378 } 2359 }
2379 int count = 0; 2360 int count = 0;
2380 if ( cp->addCat() ) { 2361 if ( cp->addCat() ) {
2381 count = addCategories(); 2362 count = addCategories();
2382 if ( count ) { 2363 if ( count ) {
2383 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2364 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2384 writeSettings(); 2365 writeSettings();
2385 } else 2366 } else
2386 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); 2367 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! "));
2387 } else { 2368 } else {
2388 removeCategories(); 2369 removeCategories();
2389 updateView(); 2370 updateView();
2390 } 2371 }
2391 delete cp; 2372 delete cp;
2392} 2373}
2393 2374
2394void CalendarView::beamIncidence(Incidence * Inc) 2375void CalendarView::beamIncidence(Incidence * Inc)
2395{ 2376{
2396 QPtrList<Incidence> delSel ; 2377 QPtrList<Incidence> delSel ;
2397 delSel.append(Inc); 2378 delSel.append(Inc);
2398 beamIncidenceList( delSel ); 2379 beamIncidenceList( delSel );
2399} 2380}
2400void CalendarView::beamCalendar() 2381void CalendarView::beamCalendar()
2401{ 2382{
2402 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2383 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2403 //qDebug("beamCalendar() "); 2384 //qDebug("beamCalendar() ");
2404 beamIncidenceList( delSel ); 2385 beamIncidenceList( delSel );
2405} 2386}
2406void CalendarView::beamFilteredCalendar() 2387void CalendarView::beamFilteredCalendar()
2407{ 2388{
2408 QPtrList<Incidence> delSel = mCalendar->incidences(); 2389 QPtrList<Incidence> delSel = mCalendar->incidences();
2409 //qDebug("beamFilteredCalendar() "); 2390 //qDebug("beamFilteredCalendar() ");
2410 beamIncidenceList( delSel ); 2391 beamIncidenceList( delSel );
2411} 2392}
2412void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2393void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2413{ 2394{
2414 if ( beamDialog->exec () == QDialog::Rejected ) 2395 if ( beamDialog->exec () == QDialog::Rejected )
2415 return; 2396 return;
2416#ifdef DESKTOP_VERSION 2397#ifdef DESKTOP_VERSION
2417 QString fn = locateLocal( "tmp", "kopibeamfile" ); 2398 QString fn = locateLocal( "tmp", "kopibeamfile" );
2418#else 2399#else
2419 QString fn = "/tmp/kopibeamfile"; 2400 QString fn = "/tmp/kopibeamfile";
2420#endif 2401#endif
2421 QString mes; 2402 QString mes;
2422 bool createbup = true; 2403 bool createbup = true;
2423 if ( createbup ) { 2404 if ( createbup ) {
2424 QString description = "\n"; 2405 QString description = "\n";
2425 CalendarLocal* cal = new CalendarLocal(); 2406 CalendarLocal* cal = new CalendarLocal();
2426 if ( beamDialog->beamLocal() ) 2407 if ( beamDialog->beamLocal() )
2427 cal->setLocalTime(); 2408 cal->setLocalTime();
2428 else 2409 else
2429 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2410 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2430 Incidence *incidence = delSel.first(); 2411 Incidence *incidence = delSel.first();
2431 bool addText = false; 2412 bool addText = false;
2432 if ( delSel.count() < 10 ) 2413 if ( delSel.count() < 10 )
2433 addText = true; 2414 addText = true;
2434 else { 2415 else {
2435 description.sprintf(i18n(" %d items?"),delSel.count() ); 2416 description.sprintf(i18n(" %d items?"),delSel.count() );
2436 } 2417 }
2437 while ( incidence ) { 2418 while ( incidence ) {
2438 Incidence *in = incidence->clone(); 2419 Incidence *in = incidence->clone();
2439 if ( ! in->summary().isEmpty() ) { 2420 if ( ! in->summary().isEmpty() ) {
2440 in->setDescription(""); 2421 in->setDescription("");
2441 } else { 2422 } else {
2442 in->setSummary( in->description().left(20)); 2423 in->setSummary( in->description().left(20));
2443 in->setDescription(""); 2424 in->setDescription("");
2444 } 2425 }
2445 if ( addText ) 2426 if ( addText )
2446 description += in->summary() + "\n"; 2427 description += in->summary() + "\n";
2447 cal->addIncidence( in ); 2428 cal->addIncidence( in );
2448 incidence = delSel.next(); 2429 incidence = delSel.next();
2449 } 2430 }
2450 if ( beamDialog->beamVcal() ) { 2431 if ( beamDialog->beamVcal() ) {
2451 fn += ".vcs"; 2432 fn += ".vcs";
2452 FileStorage storage( cal, fn, new VCalFormat ); 2433 FileStorage storage( cal, fn, new VCalFormat );
2453 storage.save(); 2434 storage.save();
2454 } else { 2435 } else {
2455 fn += ".ics"; 2436 fn += ".ics";
2456 FileStorage storage( cal, fn, new ICalFormat( ) ); 2437 FileStorage storage( cal, fn, new ICalFormat( ) );
2457 storage.save(); 2438 storage.save();
2458 } 2439 }
2459 delete cal; 2440 delete cal;
2460 mes = i18n("KO/Pi: Ready for beaming"); 2441 mes = i18n("KO/Pi: Ready for beaming");
2461 topLevelWidget()->setCaption(mes); 2442 topLevelWidget()->setCaption(mes);
2462 KApplication::convert2latin1( fn ); 2443 KApplication::convert2latin1( fn );
2463#ifndef DESKTOP_VERSION 2444#ifndef DESKTOP_VERSION
2464 Ir *ir = new Ir( this ); 2445 Ir *ir = new Ir( this );
2465 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 2446 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2466 ir->send( fn, description, "text/x-vCalendar" ); 2447 ir->send( fn, description, "text/x-vCalendar" );
2467#endif 2448#endif
2468 } 2449 }
2469} 2450}
2470void CalendarView::beamDone( Ir *ir ) 2451void CalendarView::beamDone( Ir *ir )
2471{ 2452{
2472#ifndef DESKTOP_VERSION 2453#ifndef DESKTOP_VERSION
2473 delete ir; 2454 delete ir;
2474#endif 2455#endif
2475 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); 2456 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") );
2476 topLevelWidget()->raise(); 2457 topLevelWidget()->raise();
2477} 2458}
2478 2459
2479void CalendarView::moveIncidence(Incidence * inc ) 2460void CalendarView::moveIncidence(Incidence * inc )
2480{ 2461{
2481 if ( !inc ) return; 2462 if ( !inc ) return;
2482 // qDebug("showDatePickerForIncidence( ) "); 2463 // qDebug("showDatePickerForIncidence( ) ");
2483 if ( mDateFrame->isVisible() ) 2464 if ( mDateFrame->isVisible() )
2484 mDateFrame->hide(); 2465 mDateFrame->hide();
2485 else { 2466 else {
2486 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; 2467 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ;
2487 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; 2468 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ;
2488 int dw = QApplication::desktop()->width(); 2469 int dw = QApplication::desktop()->width();
2489 int dh = QApplication::desktop()->height(); 2470 int dh = QApplication::desktop()->height();
2490 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2471 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2491 mDateFrame->show(); 2472 mDateFrame->show();
2492 } 2473 }
2493 mDatePickerMode = 2; 2474 mDatePickerMode = 2;
2494 mMoveIncidence = inc ; 2475 mMoveIncidence = inc ;
2495 QDate da; 2476 QDate da;
2496 if ( mMoveIncidence->type() == "Todo" ) { 2477 if ( mMoveIncidence->type() == "Todo" ) {
2497 Todo * to = (Todo *) mMoveIncidence; 2478 Todo * to = (Todo *) mMoveIncidence;
2498 if ( to->hasDueDate() ) 2479 if ( to->hasDueDate() )
2499 da = to->dtDue().date(); 2480 da = to->dtDue().date();
2500 else 2481 else
2501 da = QDate::currentDate(); 2482 da = QDate::currentDate();
2502 } else { 2483 } else {
2503 da = mMoveIncidence->dtStart().date(); 2484 da = mMoveIncidence->dtStart().date();
2504 } 2485 }
2505 //PENDING set date for recurring incidence to date of recurrence 2486 //PENDING set date for recurring incidence to date of recurrence
2506 //mMoveIncidenceOldDate; 2487 //mMoveIncidenceOldDate;
2507 mDatePicker->setDate( da ); 2488 mDatePicker->setDate( da );
2508} 2489}
2509void CalendarView::showDatePicker( ) 2490void CalendarView::showDatePicker( )
2510{ 2491{
2511 //qDebug("CalendarView::showDatePicker( ) "); 2492 //qDebug("CalendarView::showDatePicker( ) ");
2512 if ( mDateFrame->isVisible() ) 2493 if ( mDateFrame->isVisible() )
2513 mDateFrame->hide(); 2494 mDateFrame->hide();
2514 else { 2495 else {
2515 int w =mDatePicker->sizeHint().width() ; 2496 int w =mDatePicker->sizeHint().width() ;
2516 int h = mDatePicker->sizeHint().height() ; 2497 int h = mDatePicker->sizeHint().height() ;
2517 int dw = QApplication::desktop()->width(); 2498 int dw = QApplication::desktop()->width();
2518 int dh = QApplication::desktop()->height(); 2499 int dh = QApplication::desktop()->height();
2519 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2500 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2520 mDateFrame->show(); 2501 mDateFrame->show();
2521 } 2502 }
2522 mDatePickerMode = 1; 2503 mDatePickerMode = 1;
2523 mDatePicker->setDate( mNavigator->selectedDates().first() ); 2504 mDatePicker->setDate( mNavigator->selectedDates().first() );
2524} 2505}
2525 2506
2526void CalendarView::showEventEditor() 2507void CalendarView::showEventEditor()
2527{ 2508{
2528#ifdef DESKTOP_VERSION 2509#ifdef DESKTOP_VERSION
2529 mEventEditor->show(); 2510 mEventEditor->show();
2530#else 2511#else
2531 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { 2512 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) {
2532 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2513 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2533 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); 2514 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() );
2534 qApp->processEvents(); 2515 qApp->processEvents();
2535 delete mEventEditor; 2516 delete mEventEditor;
2536 mEventEditor = mDialogManager->getEventEditor(); 2517 mEventEditor = mDialogManager->getEventEditor();
2537 topLevelWidget()->setCaption( i18n("") ); 2518 topLevelWidget()->setCaption( i18n("") );
2538 } 2519 }
2539 mEventEditor->showMaximized(); 2520 mEventEditor->showMaximized();
2540#endif 2521#endif
2541} 2522}
2542void CalendarView::showTodoEditor() 2523void CalendarView::showTodoEditor()
2543{ 2524{
2544#ifdef DESKTOP_VERSION 2525#ifdef DESKTOP_VERSION
2545 mTodoEditor->show(); 2526 mTodoEditor->show();
2546#else 2527#else
2547 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { 2528 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) {
2548 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2529 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2549 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); 2530 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() );
2550 qApp->processEvents(); 2531 qApp->processEvents();
2551 delete mTodoEditor; 2532 delete mTodoEditor;
2552 mTodoEditor = mDialogManager->getTodoEditor(); 2533 mTodoEditor = mDialogManager->getTodoEditor();
2553 topLevelWidget()->setCaption( i18n("") ); 2534 topLevelWidget()->setCaption( i18n("") );
2554 } 2535 }
2555 mTodoEditor->showMaximized(); 2536 mTodoEditor->showMaximized();
2556#endif 2537#endif
2557} 2538}
2558 2539
2559void CalendarView::cloneIncidence() 2540void CalendarView::cloneIncidence()
2560{ 2541{
2561 Incidence *incidence = currentSelection(); 2542 Incidence *incidence = currentSelection();
2562 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2543 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2563 if ( incidence ) { 2544 if ( incidence ) {
2564 cloneIncidence(incidence); 2545 cloneIncidence(incidence);
2565 } 2546 }
2566} 2547}
2567void CalendarView::moveIncidence() 2548void CalendarView::moveIncidence()
2568{ 2549{
2569 Incidence *incidence = currentSelection(); 2550 Incidence *incidence = currentSelection();
2570 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2551 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2571 if ( incidence ) { 2552 if ( incidence ) {
2572 moveIncidence(incidence); 2553 moveIncidence(incidence);
2573 } 2554 }
2574} 2555}
2575void CalendarView::beamIncidence() 2556void CalendarView::beamIncidence()
2576{ 2557{
2577 Incidence *incidence = currentSelection(); 2558 Incidence *incidence = currentSelection();
2578 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2559 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2579 if ( incidence ) { 2560 if ( incidence ) {
2580 beamIncidence(incidence); 2561 beamIncidence(incidence);
2581 } 2562 }
2582} 2563}
2583void CalendarView::toggleCancelIncidence() 2564void CalendarView::toggleCancelIncidence()
2584{ 2565{
2585 Incidence *incidence = currentSelection(); 2566 Incidence *incidence = currentSelection();
2586 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2567 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2587 if ( incidence ) { 2568 if ( incidence ) {
2588 cancelIncidence(incidence); 2569 cancelIncidence(incidence);
2589 } 2570 }
2590} 2571}
2591 2572
2592 2573
2593void CalendarView::cancelIncidence(Incidence * inc ) 2574void CalendarView::cancelIncidence(Incidence * inc )
2594{ 2575{
2595 inc->setCancelled( ! inc->cancelled() ); 2576 inc->setCancelled( ! inc->cancelled() );
2596 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 2577 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
2597 updateView(); 2578 updateView();
2598} 2579}
2599void CalendarView::cloneIncidence(Incidence * orgInc ) 2580void CalendarView::cloneIncidence(Incidence * orgInc )
2600{ 2581{
2601 Incidence * newInc = orgInc->clone(); 2582 Incidence * newInc = orgInc->clone();
2602 newInc->recreate(); 2583 newInc->recreate();
2603 2584
2604 if ( newInc->type() == "Todo" ) { 2585 if ( newInc->type() == "Todo" ) {
2605 Todo* t = (Todo*) newInc; 2586 Todo* t = (Todo*) newInc;
2606 showTodoEditor(); 2587 showTodoEditor();
2607 mTodoEditor->editTodo( t ); 2588 mTodoEditor->editTodo( t );
2608 if ( mTodoEditor->exec() ) { 2589 if ( mTodoEditor->exec() ) {
2609 mCalendar->addTodo( t ); 2590 mCalendar->addTodo( t );
2610 updateView(); 2591 updateView();
2611 } else { 2592 } else {
2612 delete t; 2593 delete t;
2613 } 2594 }
2614 } 2595 }
2615 else { 2596 else {
2616 Event* e = (Event*) newInc; 2597 Event* e = (Event*) newInc;
2617 showEventEditor(); 2598 showEventEditor();
2618 mEventEditor->editEvent( e ); 2599 mEventEditor->editEvent( e );
2619 if ( mEventEditor->exec() ) { 2600 if ( mEventEditor->exec() ) {
2620 mCalendar->addEvent( e ); 2601 mCalendar->addEvent( e );
2621 updateView(); 2602 updateView();
2622 } else { 2603 } else {
2623 delete e; 2604 delete e;
2624 } 2605 }
2625 } 2606 }
2626} 2607}
2627 2608
2628void CalendarView::newEvent() 2609void CalendarView::newEvent()
2629{ 2610{
2630 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 2611 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
2631 KOAgendaView *aView = mViewManager->agendaView(); 2612 KOAgendaView *aView = mViewManager->agendaView();
2632 if (aView) { 2613 if (aView) {
2633 if (aView->selectionStart().isValid()) { 2614 if (aView->selectionStart().isValid()) {
2634 if (aView->selectedIsAllDay()) { 2615 if (aView->selectedIsAllDay()) {
2635 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 2616 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
2636 } else { 2617 } else {
2637 newEvent(aView->selectionStart(),aView->selectionEnd()); 2618 newEvent(aView->selectionStart(),aView->selectionEnd());
2638 } 2619 }
2639 return; 2620 return;
2640 } 2621 }
2641 } 2622 }
2642 2623
2643 QDate date = mNavigator->selectedDates().first(); 2624 QDate date = mNavigator->selectedDates().first();
2644 QDateTime current = QDateTime::currentDateTime(); 2625 QDateTime current = QDateTime::currentDateTime();
2645 if ( date <= current.date() ) { 2626 if ( date <= current.date() ) {
2646 int hour = current.time().hour() +1; 2627 int hour = current.time().hour() +1;
2647 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 2628 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
2648 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2629 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2649 } else 2630 } else
2650 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 2631 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
2651 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 2632 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
2652 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2633 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2653} 2634}
2654 2635
2655void CalendarView::newEvent(QDateTime fh) 2636void CalendarView::newEvent(QDateTime fh)
2656{ 2637{
2657 newEvent(fh, 2638 newEvent(fh,
2658 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 2639 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
2659} 2640}
2660 2641
2661void CalendarView::newEvent(QDate dt) 2642void CalendarView::newEvent(QDate dt)
2662{ 2643{
2663 newEvent(QDateTime(dt, QTime(0,0,0)), 2644 newEvent(QDateTime(dt, QTime(0,0,0)),
2664 QDateTime(dt, QTime(0,0,0)), true); 2645 QDateTime(dt, QTime(0,0,0)), true);
2665} 2646}
2666void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) 2647void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint)
2667{ 2648{
2668 newEvent(fromHint, toHint, false); 2649 newEvent(fromHint, toHint, false);
2669} 2650}
2670void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 2651void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
2671{ 2652{
2672 2653
2673 showEventEditor(); 2654 showEventEditor();
2674 mEventEditor->newEvent(fromHint,toHint,allDay); 2655 mEventEditor->newEvent(fromHint,toHint,allDay);
2675 if ( mFilterView->filtersEnabled() ) { 2656 if ( mFilterView->filtersEnabled() ) {
2676 CalFilter *filter = mFilterView->selectedFilter(); 2657 CalFilter *filter = mFilterView->selectedFilter();
2677 if (filter && filter->showCategories()) { 2658 if (filter && filter->showCategories()) {
2678 mEventEditor->setCategories(filter->categoryList().join(",") ); 2659 mEventEditor->setCategories(filter->categoryList().join(",") );
2679 } 2660 }
2680 if ( filter ) 2661 if ( filter )
2681 mEventEditor->setSecrecy( filter->getSecrecy() ); 2662 mEventEditor->setSecrecy( filter->getSecrecy() );
2682 } 2663 }
2683} 2664}
2684void CalendarView::todoAdded(Todo * t) 2665void CalendarView::todoAdded(Todo * t)
2685{ 2666{
2686 2667
2687 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 2668 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
2688 updateTodoViews(); 2669 updateTodoViews();
2689} 2670}
2690void CalendarView::todoChanged(Todo * t) 2671void CalendarView::todoChanged(Todo * t)
2691{ 2672{
2692 emit todoModified( t, 4 ); 2673 emit todoModified( t, 4 );
2693 // updateTodoViews(); 2674 // updateTodoViews();
2694} 2675}
2695void CalendarView::todoToBeDeleted(Todo *) 2676void CalendarView::todoToBeDeleted(Todo *)
2696{ 2677{
2697 //qDebug("todoToBeDeleted(Todo *) "); 2678 //qDebug("todoToBeDeleted(Todo *) ");
2698 updateTodoViews(); 2679 updateTodoViews();
2699} 2680}
2700void CalendarView::todoDeleted() 2681void CalendarView::todoDeleted()
2701{ 2682{
2702 //qDebug(" todoDeleted()"); 2683 //qDebug(" todoDeleted()");
2703 updateTodoViews(); 2684 updateTodoViews();
2704} 2685}
2705 2686
2706 2687
2707void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) 2688void CalendarView::newTodoDateTime( QDateTime dt, bool allday )
2708{ 2689{
2709 showTodoEditor(); 2690 showTodoEditor();
2710 mTodoEditor->newTodo(dt,0,allday); 2691 mTodoEditor->newTodo(dt,0,allday);
2711 if ( mFilterView->filtersEnabled() ) { 2692 if ( mFilterView->filtersEnabled() ) {
2712 CalFilter *filter = mFilterView->selectedFilter(); 2693 CalFilter *filter = mFilterView->selectedFilter();
2713 if (filter && filter->showCategories()) { 2694 if (filter && filter->showCategories()) {
2714 mTodoEditor->setCategories(filter->categoryList().join(",") ); 2695 mTodoEditor->setCategories(filter->categoryList().join(",") );
2715 } 2696 }
2716 if ( filter ) 2697 if ( filter )
2717 mTodoEditor->setSecrecy( filter->getSecrecy() ); 2698 mTodoEditor->setSecrecy( filter->getSecrecy() );
2718 } 2699 }
2719} 2700}
2720 2701
2721void CalendarView::newTodo() 2702void CalendarView::newTodo()
2722{ 2703{
2723 newTodoDateTime( QDateTime(),true ); 2704 newTodoDateTime( QDateTime(),true );
2724} 2705}
2725 2706
2726void CalendarView::newSubTodo() 2707void CalendarView::newSubTodo()
2727{ 2708{
2728 Todo *todo = selectedTodo(); 2709 Todo *todo = selectedTodo();
2729 if ( todo ) newSubTodo( todo ); 2710 if ( todo ) newSubTodo( todo );
2730} 2711}
2731 2712
2732void CalendarView::newSubTodo(Todo *parentEvent) 2713void CalendarView::newSubTodo(Todo *parentEvent)
2733{ 2714{
2734 2715
2735 showTodoEditor(); 2716 showTodoEditor();
2736 mTodoEditor->newTodo(QDateTime(),parentEvent,true); 2717 mTodoEditor->newTodo(QDateTime(),parentEvent,true);
2737} 2718}
2738 2719
2739void CalendarView::newFloatingEvent() 2720void CalendarView::newFloatingEvent()
2740{ 2721{
2741 DateList tmpList = mNavigator->selectedDates(); 2722 DateList tmpList = mNavigator->selectedDates();
2742 QDate date = tmpList.first(); 2723 QDate date = tmpList.first();
2743 2724
2744 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 2725 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
2745 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 2726 QDateTime( date, QTime( 12, 0, 0 ) ), true );
2746} 2727}
2747 2728
2748 2729
2749void CalendarView::editEvent( Event *event ) 2730void CalendarView::editEvent( Event *event )
2750{ 2731{
2751 2732
2752 if ( !event ) return; 2733 if ( !event ) return;
2753 if ( event->isReadOnly() ) { 2734 if ( event->isReadOnly() ) {
2754 showEvent( event ); 2735 showEvent( event );
2755 return; 2736 return;
2756 } 2737 }
2757 showEventEditor(); 2738 showEventEditor();
2758 mEventEditor->editEvent( event , mFlagEditDescription); 2739 mEventEditor->editEvent( event , mFlagEditDescription);
2759} 2740}
2760void CalendarView::editJournal( Journal *jour ) 2741void CalendarView::editJournal( Journal *jour )
2761{ 2742{
2762 if ( !jour ) return; 2743 if ( !jour ) return;
2763 mDialogManager->hideSearchDialog(); 2744 mDialogManager->hideSearchDialog();
2764 mViewManager->showJournalView(); 2745 mViewManager->showJournalView();
2765 mNavigator->slotDaySelect( jour->dtStart().date() ); 2746 mNavigator->slotDaySelect( jour->dtStart().date() );
2766} 2747}
2767void CalendarView::editTodo( Todo *todo ) 2748void CalendarView::editTodo( Todo *todo )
2768{ 2749{
2769 if ( !todo ) return; 2750 if ( !todo ) return;
2770 2751
2771 if ( todo->isReadOnly() ) { 2752 if ( todo->isReadOnly() ) {
2772 showTodo( todo ); 2753 showTodo( todo );
2773 return; 2754 return;
2774 } 2755 }
2775 showTodoEditor(); 2756 showTodoEditor();
2776 mTodoEditor->editTodo( todo ,mFlagEditDescription); 2757 mTodoEditor->editTodo( todo ,mFlagEditDescription);
2777 2758
2778} 2759}
2779 2760
2780KOEventViewerDialog* CalendarView::getEventViewerDialog() 2761KOEventViewerDialog* CalendarView::getEventViewerDialog()
2781{ 2762{
2782 if ( !mEventViewerDialog ) { 2763 if ( !mEventViewerDialog ) {
2783 mEventViewerDialog = new KOEventViewerDialog(this); 2764 mEventViewerDialog = new KOEventViewerDialog(this);
2784 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 2765 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
2785 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 2766 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
2786 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 2767 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
2787 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 2768 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
2788 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 2769 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
2789 viewManager(), SLOT( showAgendaView( bool ) ) ); 2770 viewManager(), SLOT( showAgendaView( bool ) ) );
2790 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), 2771 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ),
2791 this, SLOT( todoChanged(Todo *) ) ); 2772 this, SLOT( todoChanged(Todo *) ) );
2792 mEventViewerDialog->resize( 640, 480 ); 2773 mEventViewerDialog->resize( 640, 480 );
2793 2774
2794 } 2775 }
2795 return mEventViewerDialog; 2776 return mEventViewerDialog;
2796} 2777}
2797void CalendarView::showEvent(Event *event) 2778void CalendarView::showEvent(Event *event)
2798{ 2779{
2799 getEventViewerDialog()->setEvent(event); 2780 getEventViewerDialog()->setEvent(event);
2800 getEventViewerDialog()->showMe(); 2781 getEventViewerDialog()->showMe();
2801} 2782}
2802 2783
2803void CalendarView::showTodo(Todo *event) 2784void CalendarView::showTodo(Todo *event)
2804{ 2785{
2805 getEventViewerDialog()->setTodo(event); 2786 getEventViewerDialog()->setTodo(event);
2806 getEventViewerDialog()->showMe(); 2787 getEventViewerDialog()->showMe();
2807} 2788}
2808void CalendarView::showJournal( Journal *jour ) 2789void CalendarView::showJournal( Journal *jour )
2809{ 2790{
2810 getEventViewerDialog()->setJournal(jour); 2791 getEventViewerDialog()->setJournal(jour);
2811 getEventViewerDialog()->showMe(); 2792 getEventViewerDialog()->showMe();
2812 2793
2813} 2794}
2814// void CalendarView::todoModified (Todo *event, int changed) 2795// void CalendarView::todoModified (Todo *event, int changed)
2815// { 2796// {
2816// // if (mDialogList.find (event) != mDialogList.end ()) { 2797// // if (mDialogList.find (event) != mDialogList.end ()) {
2817// // kdDebug() << "Todo modified and open" << endl; 2798// // kdDebug() << "Todo modified and open" << endl;
2818// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 2799// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
2819// // temp->modified (changed); 2800// // temp->modified (changed);
2820 2801
2821// // } 2802// // }
2822 2803
2823// mViewManager->updateView(); 2804// mViewManager->updateView();
2824// } 2805// }
2825 2806
2826void CalendarView::appointment_show() 2807void CalendarView::appointment_show()
2827{ 2808{
2828 Event *anEvent = 0; 2809 Event *anEvent = 0;
2829 2810
2830 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2811 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2831 2812
2832 if (mViewManager->currentView()->isEventView()) { 2813 if (mViewManager->currentView()->isEventView()) {
2833 if ( incidence && incidence->type() == "Event" ) { 2814 if ( incidence && incidence->type() == "Event" ) {
2834 anEvent = static_cast<Event *>(incidence); 2815 anEvent = static_cast<Event *>(incidence);
2835 } 2816 }
2836 } 2817 }
2837 2818
2838 if (!anEvent) { 2819 if (!anEvent) {
2839 KNotifyClient::beep(); 2820 KNotifyClient::beep();
2840 return; 2821 return;
2841 } 2822 }
2842 2823
2843 showEvent(anEvent); 2824 showEvent(anEvent);
2844} 2825}
2845 2826
2846void CalendarView::appointment_edit() 2827void CalendarView::appointment_edit()
2847{ 2828{
2848 Event *anEvent = 0; 2829 Event *anEvent = 0;
2849 2830
2850 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2831 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2851 2832
2852 if (mViewManager->currentView()->isEventView()) { 2833 if (mViewManager->currentView()->isEventView()) {
2853 if ( incidence && incidence->type() == "Event" ) { 2834 if ( incidence && incidence->type() == "Event" ) {
2854 anEvent = static_cast<Event *>(incidence); 2835 anEvent = static_cast<Event *>(incidence);
2855 } 2836 }
2856 } 2837 }
2857 2838
2858 if (!anEvent) { 2839 if (!anEvent) {
2859 KNotifyClient::beep(); 2840 KNotifyClient::beep();
2860 return; 2841 return;
2861 } 2842 }
2862 2843
2863 editEvent(anEvent); 2844 editEvent(anEvent);
2864} 2845}
2865 2846
2866void CalendarView::appointment_delete() 2847void CalendarView::appointment_delete()
2867{ 2848{
2868 Event *anEvent = 0; 2849 Event *anEvent = 0;
2869 2850
2870 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2851 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2871 2852
2872 if (mViewManager->currentView()->isEventView()) { 2853 if (mViewManager->currentView()->isEventView()) {
2873 if ( incidence && incidence->type() == "Event" ) { 2854 if ( incidence && incidence->type() == "Event" ) {
2874 anEvent = static_cast<Event *>(incidence); 2855 anEvent = static_cast<Event *>(incidence);
2875 } 2856 }
2876 } 2857 }
2877 2858
2878 if (!anEvent) { 2859 if (!anEvent) {
2879 KNotifyClient::beep(); 2860 KNotifyClient::beep();
2880 return; 2861 return;
2881 } 2862 }
2882 2863
2883 deleteEvent(anEvent); 2864 deleteEvent(anEvent);
2884} 2865}
2885 2866
2886void CalendarView::todo_resub( Todo * parent, Todo * sub ) 2867void CalendarView::todo_resub( Todo * parent, Todo * sub )
2887{ 2868{
2888 if (!sub) return; 2869 if (!sub) return;
2889 if (!parent) return; 2870 if (!parent) return;
2890 if ( sub->relatedTo() ) 2871 if ( sub->relatedTo() )
2891 sub->relatedTo()->removeRelation(sub); 2872 sub->relatedTo()->removeRelation(sub);
2892 sub->setRelatedTo(parent); 2873 sub->setRelatedTo(parent);
2893 sub->setRelatedToUid(parent->uid()); 2874 sub->setRelatedToUid(parent->uid());
2894 parent->addRelation(sub); 2875 parent->addRelation(sub);
2895 sub->updated(); 2876 sub->updated();
2896 parent->updated(); 2877 parent->updated();
2897 setModified(true); 2878 setModified(true);
2898 updateView(); 2879 updateView();
2899} 2880}
2900void CalendarView::todo_unsub(Todo *anTodo ) 2881void CalendarView::todo_unsub(Todo *anTodo )
2901{ 2882{
2902 // Todo *anTodo = selectedTodo(); 2883 // Todo *anTodo = selectedTodo();
2903 if (!anTodo) return; 2884 if (!anTodo) return;
2904 if (!anTodo->relatedTo()) return; 2885 if (!anTodo->relatedTo()) return;
2905 anTodo->relatedTo()->removeRelation(anTodo); 2886 anTodo->relatedTo()->removeRelation(anTodo);
2906 anTodo->setRelatedTo(0); 2887 anTodo->setRelatedTo(0);
2907 anTodo->updated(); 2888 anTodo->updated();
2908 anTodo->setRelatedToUid(""); 2889 anTodo->setRelatedToUid("");
2909 setModified(true); 2890 setModified(true);
2910 updateView(); 2891 updateView();
2911} 2892}
2912 2893
2913void CalendarView::deleteTodo(Todo *todo) 2894void CalendarView::deleteTodo(Todo *todo)
2914{ 2895{
2915 if (!todo) { 2896 if (!todo) {
2916 KNotifyClient::beep(); 2897 KNotifyClient::beep();
2917 return; 2898 return;
2918 } 2899 }
2919 if (KOPrefs::instance()->mConfirm) { 2900 if (KOPrefs::instance()->mConfirm) {
2920 QString text = todo->summary().left(20); 2901 QString text = todo->summary().left(20);
2921 if (!todo->relations().isEmpty()) { 2902 if (!todo->relations().isEmpty()) {
2922 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); 2903 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!");
2923 2904
2924 } 2905 }
2925 switch (msgItemDelete(text)) { 2906 switch (msgItemDelete(text)) {
2926 case KMessageBox::Continue: // OK 2907 case KMessageBox::Continue: // OK
2927 bool deleteT = false; 2908 bool deleteT = false;
2928 if (!todo->relations().isEmpty()) { 2909 if (!todo->relations().isEmpty()) {
2929 deleteT = removeCompletedSubTodos( todo ); 2910 deleteT = removeCompletedSubTodos( todo );
2930 } 2911 }
2931 // deleteT == true: todo already deleted in removeCompletedSubTodos 2912 // deleteT == true: todo already deleted in removeCompletedSubTodos
2932 if ( !deleteT ) { 2913 if ( !deleteT ) {
2933 checkExternalId( todo ); 2914 checkExternalId( todo );
2934 calendar()->deleteTodo(todo); 2915 calendar()->deleteTodo(todo);
2935 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2916 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2936 updateView(); 2917 updateView();
2937 } 2918 }
2938 break; 2919 break;
2939 } // switch 2920 } // switch
2940 } else { 2921 } else {
2941 checkExternalId( todo ); 2922 checkExternalId( todo );
2942 mCalendar->deleteTodo(todo); 2923 mCalendar->deleteTodo(todo);
2943 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2924 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2944 updateView(); 2925 updateView();
2945 } 2926 }
2946 2927
2947 emit updateSearchDialog(); 2928 emit updateSearchDialog();
2948} 2929}
2949void CalendarView::deleteJournal(Journal *jour) 2930void CalendarView::deleteJournal(Journal *jour)
2950{ 2931{
2951 if (!jour) { 2932 if (!jour) {
2952 KNotifyClient::beep(); 2933 KNotifyClient::beep();
2953 return; 2934 return;
2954 } 2935 }
2955 if (KOPrefs::instance()->mConfirm) { 2936 if (KOPrefs::instance()->mConfirm) {
2956 switch (msgItemDelete( jour->description().left(20))) { 2937 switch (msgItemDelete( jour->description().left(20))) {
2957 case KMessageBox::Continue: // OK 2938 case KMessageBox::Continue: // OK
2958 calendar()->deleteJournal(jour); 2939 calendar()->deleteJournal(jour);
2959 updateView(); 2940 updateView();
2960 break; 2941 break;
2961 } // switch 2942 } // switch
2962 } else { 2943 } else {
2963 calendar()->deleteJournal(jour);; 2944 calendar()->deleteJournal(jour);;
2964 updateView(); 2945 updateView();
2965 } 2946 }
2966 emit updateSearchDialog(); 2947 emit updateSearchDialog();
2967} 2948}
2968 2949
2969void CalendarView::deleteEvent(Event *anEvent) 2950void CalendarView::deleteEvent(Event *anEvent)
2970{ 2951{
2971 if (!anEvent) { 2952 if (!anEvent) {
2972 KNotifyClient::beep(); 2953 KNotifyClient::beep();
2973 return; 2954 return;
2974 } 2955 }
2975 2956
2976 if (anEvent->recurrence()->doesRecur()) { 2957 if (anEvent->recurrence()->doesRecur()) {
2977 QDate itemDate = mViewManager->currentSelectionDate(); 2958 QDate itemDate = mViewManager->currentSelectionDate();
2978 int km; 2959 int km;
2979 if (!itemDate.isValid()) { 2960 if (!itemDate.isValid()) {
2980 //kdDebug() << "Date Not Valid" << endl; 2961 //kdDebug() << "Date Not Valid" << endl;
2981 if (KOPrefs::instance()->mConfirm) { 2962 if (KOPrefs::instance()->mConfirm) {
2982 km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + 2963 km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) +
2983 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), 2964 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"),
2984 i18n("KO/Pi Confirmation"),i18n("Delete All")); 2965 i18n("KO/Pi Confirmation"),i18n("Delete All"));
2985 if ( km == KMessageBox::Continue ) 2966 if ( km == KMessageBox::Continue )
2986 km = KMessageBox::No; // No = all below 2967 km = KMessageBox::No; // No = all below
2987 } else 2968 } else
2988 km = KMessageBox::No; 2969 km = KMessageBox::No;
2989 } else { 2970 } else {
2990 km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + 2971 km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) +
2991 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ 2972 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+
2992 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), 2973 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"),
2993 i18n("KO/Pi Confirmation"),i18n("Current"), 2974 i18n("KO/Pi Confirmation"),i18n("Current"),
2994 i18n("All")); 2975 i18n("All"));
2995 } 2976 }
2996 switch(km) { 2977 switch(km) {
2997 2978
2998 case KMessageBox::No: // Continue // all 2979 case KMessageBox::No: // Continue // all
2999 //qDebug("KMessageBox::No "); 2980 //qDebug("KMessageBox::No ");
3000 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2981 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3001 schedule(Scheduler::Cancel,anEvent); 2982 schedule(Scheduler::Cancel,anEvent);
3002 2983
3003 checkExternalId( anEvent); 2984 checkExternalId( anEvent);
3004 mCalendar->deleteEvent(anEvent); 2985 mCalendar->deleteEvent(anEvent);
3005 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); 2986 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED);
3006 break; 2987 break;
3007 2988
3008 // Disabled because it does not work 2989 // Disabled because it does not work
3009 //#if 0 2990 //#if 0
3010 case KMessageBox::Yes: // just this one 2991 case KMessageBox::Yes: // just this one
3011 //QDate qd = mNavigator->selectedDates().first(); 2992 //QDate qd = mNavigator->selectedDates().first();
3012 //if (!qd.isValid()) { 2993 //if (!qd.isValid()) {
3013 // kdDebug() << "no date selected, or invalid date" << endl; 2994 // kdDebug() << "no date selected, or invalid date" << endl;
3014 // KNotifyClient::beep(); 2995 // KNotifyClient::beep();
3015 // return; 2996 // return;
3016 //} 2997 //}
3017 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); 2998 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1);
3018 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { 2999 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) {
3019 anEvent->addExDate(itemDate); 3000 anEvent->addExDate(itemDate);
3020 int duration = anEvent->recurrence()->duration(); 3001 int duration = anEvent->recurrence()->duration();
3021 if ( duration > 0 ) { 3002 if ( duration > 0 ) {
3022 anEvent->recurrence()->setDuration( duration - 1 ); 3003 anEvent->recurrence()->setDuration( duration - 1 );
3023 } 3004 }
3024 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); 3005 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED);
3025 } 3006 }
3026 break; 3007 break;
3027 //#endif 3008 //#endif
3028 } // switch 3009 } // switch
3029 } else { 3010 } else {
3030 if (KOPrefs::instance()->mConfirm) { 3011 if (KOPrefs::instance()->mConfirm) {
3031 switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + 3012 switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) +
3032 i18n("\nAre you sure you want\nto delete this event?"), 3013 i18n("\nAre you sure you want\nto delete this event?"),
3033 i18n("KO/Pi Confirmation"),i18n("Delete"))) { 3014 i18n("KO/Pi Confirmation"),i18n("Delete"))) {
3034 case KMessageBox::Continue: // OK 3015 case KMessageBox::Continue: // OK
3035 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3016 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3036 schedule(Scheduler::Cancel,anEvent); 3017 schedule(Scheduler::Cancel,anEvent);
3037 checkExternalId( anEvent); 3018 checkExternalId( anEvent);
3038 mCalendar->deleteEvent(anEvent); 3019 mCalendar->deleteEvent(anEvent);
3039 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3020 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3040 break; 3021 break;
3041 } // switch 3022 } // switch
3042 } else { 3023 } else {
3043 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3024 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3044 schedule(Scheduler::Cancel,anEvent); 3025 schedule(Scheduler::Cancel,anEvent);
3045 checkExternalId( anEvent); 3026 checkExternalId( anEvent);
3046 mCalendar->deleteEvent(anEvent); 3027 mCalendar->deleteEvent(anEvent);
3047 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3028 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3048 } 3029 }
3049 } // if-else 3030 } // if-else
3050 emit updateSearchDialog(); 3031 emit updateSearchDialog();
3051} 3032}
3052 3033
3053bool CalendarView::deleteEvent(const QString &uid) 3034bool CalendarView::deleteEvent(const QString &uid)
3054{ 3035{
3055 Event *ev = mCalendar->event(uid); 3036 Event *ev = mCalendar->event(uid);
3056 if (ev) { 3037 if (ev) {
3057 deleteEvent(ev); 3038 deleteEvent(ev);
3058 return true; 3039 return true;
3059 } else { 3040 } else {
3060 return false; 3041 return false;
3061 } 3042 }
3062} 3043}
3063 3044
3064/*****************************************************************************/ 3045/*****************************************************************************/
3065 3046
3066void CalendarView::action_mail() 3047void CalendarView::action_mail()
3067{ 3048{
3068#ifndef KORG_NOMAIL 3049#ifndef KORG_NOMAIL
3069 KOMailClient mailClient; 3050 KOMailClient mailClient;
3070 3051
3071 Incidence *incidence = currentSelection(); 3052 Incidence *incidence = currentSelection();
3072 3053
3073 if (!incidence) { 3054 if (!incidence) {
3074 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3055 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3075 return; 3056 return;
3076 } 3057 }
3077 if(incidence->attendeeCount() == 0 ) { 3058 if(incidence->attendeeCount() == 0 ) {
3078 KMessageBox::sorry(this, 3059 KMessageBox::sorry(this,
3079 i18n("Can't generate mail:\nNo attendees defined.\n")); 3060 i18n("Can't generate mail:\nNo attendees defined.\n"));
3080 return; 3061 return;
3081 } 3062 }
3082 3063
3083 CalendarLocal cal_tmp; 3064 CalendarLocal cal_tmp;
3084 Event *event = 0; 3065 Event *event = 0;
3085 Event *ev = 0; 3066 Event *ev = 0;
3086 if ( incidence && incidence->type() == "Event" ) { 3067 if ( incidence && incidence->type() == "Event" ) {
3087 event = static_cast<Event *>(incidence); 3068 event = static_cast<Event *>(incidence);
3088 ev = new Event(*event); 3069 ev = new Event(*event);
3089 cal_tmp.addEvent(ev); 3070 cal_tmp.addEvent(ev);
3090 } 3071 }
3091 ICalFormat mForm(); 3072 ICalFormat mForm();
3092 QString attachment = mForm.toString( &cal_tmp ); 3073 QString attachment = mForm.toString( &cal_tmp );
3093 if (ev) delete(ev); 3074 if (ev) delete(ev);
3094 3075
3095 mailClient.mailAttendees(currentSelection(), attachment); 3076 mailClient.mailAttendees(currentSelection(), attachment);
3096 3077
3097#endif 3078#endif
3098 3079
3099#if 0 3080#if 0
3100 Event *anEvent = 0; 3081 Event *anEvent = 0;
3101 if (mViewManager->currentView()->isEventView()) { 3082 if (mViewManager->currentView()->isEventView()) {
3102 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); 3083 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first());
3103 } 3084 }
3104 3085
3105 if (!anEvent) { 3086 if (!anEvent) {
3106 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3087 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3107 return; 3088 return;
3108 } 3089 }
3109 if(anEvent->attendeeCount() == 0 ) { 3090 if(anEvent->attendeeCount() == 0 ) {
3110 KMessageBox::sorry(this, 3091 KMessageBox::sorry(this,
3111 i18n("Can't generate mail:\nNo attendees defined.\n")); 3092 i18n("Can't generate mail:\nNo attendees defined.\n"));
3112 return; 3093 return;
3113 } 3094 }
3114 3095
3115 mailobject.emailEvent(anEvent); 3096 mailobject.emailEvent(anEvent);
3116#endif 3097#endif
3117} 3098}
3118 3099
3119 3100
3120void CalendarView::schedule_publish(Incidence *incidence) 3101void CalendarView::schedule_publish(Incidence *incidence)
3121{ 3102{
3122 Event *event = 0; 3103 Event *event = 0;
3123 Todo *todo = 0; 3104 Todo *todo = 0;
3124 3105
3125 if (incidence == 0) { 3106 if (incidence == 0) {
3126 incidence = mViewManager->currentView()->selectedIncidences().first(); 3107 incidence = mViewManager->currentView()->selectedIncidences().first();
3127 if (incidence == 0) { 3108 if (incidence == 0) {
3128 incidence = mTodoList->selectedIncidences().first(); 3109 incidence = mTodoList->selectedIncidences().first();
3129 } 3110 }
3130 } 3111 }
3131 if ( incidence && incidence->type() == "Event" ) { 3112 if ( incidence && incidence->type() == "Event" ) {
3132 event = static_cast<Event *>(incidence); 3113 event = static_cast<Event *>(incidence);
3133 } else { 3114 } else {
3134 if ( incidence && incidence->type() == "Todo" ) { 3115 if ( incidence && incidence->type() == "Todo" ) {
3135 todo = static_cast<Todo *>(incidence); 3116 todo = static_cast<Todo *>(incidence);
3136 } 3117 }
3137 } 3118 }
3138 3119
3139 if (!event && !todo) { 3120 if (!event && !todo) {
3140 KMessageBox::sorry(this,i18n("No event selected.")); 3121 KMessageBox::sorry(this,i18n("No event selected."));
3141 return; 3122 return;
3142 } 3123 }
3143 3124
3144 PublishDialog *publishdlg = new PublishDialog(); 3125 PublishDialog *publishdlg = new PublishDialog();
3145 if (incidence->attendeeCount()>0) { 3126 if (incidence->attendeeCount()>0) {
3146 QPtrList<Attendee> attendees = incidence->attendees(); 3127 QPtrList<Attendee> attendees = incidence->attendees();
3147 attendees.first(); 3128 attendees.first();
3148 while ( attendees.current()!=0 ) { 3129 while ( attendees.current()!=0 ) {
3149 publishdlg->addAttendee(attendees.current()); 3130 publishdlg->addAttendee(attendees.current());
3150 attendees.next(); 3131 attendees.next();
3151 } 3132 }
3152 } 3133 }
3153 bool send = true; 3134 bool send = true;
3154 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { 3135 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) {
3155 if ( publishdlg->exec() != QDialog::Accepted ) 3136 if ( publishdlg->exec() != QDialog::Accepted )
3156 send = false; 3137 send = false;
3157 } 3138 }
3158 if ( send ) { 3139 if ( send ) {
3159 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3140 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3160 if ( event ) { 3141 if ( event ) {
3161 Event *ev = new Event(*event); 3142 Event *ev = new Event(*event);
3162 ev->registerObserver(0); 3143 ev->registerObserver(0);
3163 ev->clearAttendees(); 3144 ev->clearAttendees();
3164 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3145 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3165 delete(ev); 3146 delete(ev);
3166 } 3147 }
3167 } else { 3148 } else {
3168 if ( todo ) { 3149 if ( todo ) {
3169 Todo *ev = new Todo(*todo); 3150 Todo *ev = new Todo(*todo);
3170 ev->registerObserver(0); 3151 ev->registerObserver(0);
3171 ev->clearAttendees(); 3152 ev->clearAttendees();
3172 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3153 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3173 delete(ev); 3154 delete(ev);
3174 } 3155 }
3175 } 3156 }
3176 } 3157 }
3177 } 3158 }
3178 delete publishdlg; 3159 delete publishdlg;
3179} 3160}
3180 3161
3181void CalendarView::schedule_request(Incidence *incidence) 3162void CalendarView::schedule_request(Incidence *incidence)
3182{ 3163{
3183 schedule(Scheduler::Request,incidence); 3164 schedule(Scheduler::Request,incidence);
3184} 3165}
3185 3166
3186void CalendarView::schedule_refresh(Incidence *incidence) 3167void CalendarView::schedule_refresh(Incidence *incidence)
3187{ 3168{
3188 schedule(Scheduler::Refresh,incidence); 3169 schedule(Scheduler::Refresh,incidence);
3189} 3170}
3190 3171
3191void CalendarView::schedule_cancel(Incidence *incidence) 3172void CalendarView::schedule_cancel(Incidence *incidence)
3192{ 3173{
3193 schedule(Scheduler::Cancel,incidence); 3174 schedule(Scheduler::Cancel,incidence);
3194} 3175}
3195 3176
3196void CalendarView::schedule_add(Incidence *incidence) 3177void CalendarView::schedule_add(Incidence *incidence)
3197{ 3178{
3198 schedule(Scheduler::Add,incidence); 3179 schedule(Scheduler::Add,incidence);
3199} 3180}
3200 3181
3201void CalendarView::schedule_reply(Incidence *incidence) 3182void CalendarView::schedule_reply(Incidence *incidence)
3202{ 3183{
3203 schedule(Scheduler::Reply,incidence); 3184 schedule(Scheduler::Reply,incidence);
3204} 3185}
3205 3186
3206void CalendarView::schedule_counter(Incidence *incidence) 3187void CalendarView::schedule_counter(Incidence *incidence)
3207{ 3188{
3208 schedule(Scheduler::Counter,incidence); 3189 schedule(Scheduler::Counter,incidence);
3209} 3190}
3210 3191
3211void CalendarView::schedule_declinecounter(Incidence *incidence) 3192void CalendarView::schedule_declinecounter(Incidence *incidence)
3212{ 3193{
3213 schedule(Scheduler::Declinecounter,incidence); 3194 schedule(Scheduler::Declinecounter,incidence);
3214} 3195}
3215 3196
3216void CalendarView::schedule_publish_freebusy(int daysToPublish) 3197void CalendarView::schedule_publish_freebusy(int daysToPublish)
3217{ 3198{
3218 QDateTime start = QDateTime::currentDateTime(); 3199 QDateTime start = QDateTime::currentDateTime();
3219 QDateTime end = start.addDays(daysToPublish); 3200 QDateTime end = start.addDays(daysToPublish);
3220 3201
3221 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); 3202 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end);
3222 freebusy->setOrganizer(KOPrefs::instance()->email()); 3203 freebusy->setOrganizer(KOPrefs::instance()->email());
3223 3204
3224 3205
3225 PublishDialog *publishdlg = new PublishDialog(); 3206 PublishDialog *publishdlg = new PublishDialog();
3226 if ( publishdlg->exec() == QDialog::Accepted ) { 3207 if ( publishdlg->exec() == QDialog::Accepted ) {
3227 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3208 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3228 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { 3209 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) {
3229 delete(freebusy); 3210 delete(freebusy);
3230 } 3211 }
3231 } 3212 }
3232 delete publishdlg; 3213 delete publishdlg;
3233} 3214}
3234 3215
3235void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) 3216void CalendarView::schedule(Scheduler::Method method, Incidence *incidence)
3236{ 3217{
3237 Event *event = 0; 3218 Event *event = 0;
3238 Todo *todo = 0; 3219 Todo *todo = 0;
3239 3220
3240 if (incidence == 0) { 3221 if (incidence == 0) {
3241 incidence = mViewManager->currentView()->selectedIncidences().first(); 3222 incidence = mViewManager->currentView()->selectedIncidences().first();
3242 if (incidence == 0) { 3223 if (incidence == 0) {
3243 incidence = mTodoList->selectedIncidences().first(); 3224 incidence = mTodoList->selectedIncidences().first();
3244 } 3225 }
3245 } 3226 }
3246 if ( incidence && incidence->type() == "Event" ) { 3227 if ( incidence && incidence->type() == "Event" ) {
3247 event = static_cast<Event *>(incidence); 3228 event = static_cast<Event *>(incidence);
3248 } 3229 }
3249 if ( incidence && incidence->type() == "Todo" ) { 3230 if ( incidence && incidence->type() == "Todo" ) {
3250 todo = static_cast<Todo *>(incidence); 3231 todo = static_cast<Todo *>(incidence);
3251 } 3232 }
3252 3233
3253 if (!event && !todo) { 3234 if (!event && !todo) {
3254 KMessageBox::sorry(this,i18n("No event selected.")); 3235 KMessageBox::sorry(this,i18n("No event selected."));
3255 return; 3236 return;
3256 } 3237 }
3257 3238
3258 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { 3239 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) {
3259 KMessageBox::sorry(this,i18n("The event has no attendees.")); 3240 KMessageBox::sorry(this,i18n("The event has no attendees."));
3260 return; 3241 return;
3261 } 3242 }
3262 3243
3263 Event *ev = 0; 3244 Event *ev = 0;
3264 if (event) ev = new Event(*event); 3245 if (event) ev = new Event(*event);
3265 Todo *to = 0; 3246 Todo *to = 0;
3266 if (todo) to = new Todo(*todo); 3247 if (todo) to = new Todo(*todo);
3267 3248
3268 if (method == Scheduler::Reply || method == Scheduler::Refresh) { 3249 if (method == Scheduler::Reply || method == Scheduler::Refresh) {
3269 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 3250 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
3270 if (!me) { 3251 if (!me) {
3271 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); 3252 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails."));
3272 return; 3253 return;
3273 } 3254 }
3274 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { 3255 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) {
3275 StatusDialog *statdlg = new StatusDialog(this); 3256 StatusDialog *statdlg = new StatusDialog(this);
3276 if (!statdlg->exec()==QDialog::Accepted) return; 3257 if (!statdlg->exec()==QDialog::Accepted) return;
3277 me->setStatus( statdlg->status() ); 3258 me->setStatus( statdlg->status() );
3278 delete(statdlg); 3259 delete(statdlg);
3279 } 3260 }
3280 Attendee *menew = new Attendee(*me); 3261 Attendee *menew = new Attendee(*me);
3281 if (ev) { 3262 if (ev) {
3282 ev->clearAttendees(); 3263 ev->clearAttendees();
3283 ev->addAttendee(menew,false); 3264 ev->addAttendee(menew,false);
3284 } else { 3265 } else {
3285 if (to) { 3266 if (to) {
3286 todo->clearAttendees(); 3267 todo->clearAttendees();
3287 todo->addAttendee(menew,false); 3268 todo->addAttendee(menew,false);
3288 } 3269 }
3289 } 3270 }
3290 } 3271 }
3291 3272
3292 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3273 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3293 if (ev) { 3274 if (ev) {
3294 if ( !dlg->addMessage(ev,method) ) delete(ev); 3275 if ( !dlg->addMessage(ev,method) ) delete(ev);
3295 } else { 3276 } else {
3296 if (to) { 3277 if (to) {
3297 if ( !dlg->addMessage(to,method) ) delete(to); 3278 if ( !dlg->addMessage(to,method) ) delete(to);
3298 } 3279 }
3299 } 3280 }
3300} 3281}
3301 3282
3302void CalendarView::openAddressbook() 3283void CalendarView::openAddressbook()
3303{ 3284{
3304 KRun::runCommand("kaddressbook"); 3285 KRun::runCommand("kaddressbook");
3305} 3286}
3306 3287
3307void CalendarView::setModified(bool modified) 3288void CalendarView::setModified(bool modified)
3308{ 3289{
3309 if ( modified ) 3290 if ( modified )
3310 emit signalmodified(); 3291 emit signalmodified();
3311 if (mModified != modified) { 3292 if (mModified != modified) {
3312 mModified = modified; 3293 mModified = modified;
3313 emit modifiedChanged(mModified); 3294 emit modifiedChanged(mModified);
3314 } 3295 }
3315} 3296}
3316 3297
3317bool CalendarView::isReadOnly() 3298bool CalendarView::isReadOnly()
3318{ 3299{
3319 return mReadOnly; 3300 return mReadOnly;
3320} 3301}
3321 3302
3322void CalendarView::setReadOnly(bool readOnly) 3303void CalendarView::setReadOnly(bool readOnly)
3323{ 3304{
3324 if (mReadOnly != readOnly) { 3305 if (mReadOnly != readOnly) {
3325 mReadOnly = readOnly; 3306 mReadOnly = readOnly;
3326 emit readOnlyChanged(mReadOnly); 3307 emit readOnlyChanged(mReadOnly);
3327 } 3308 }
3328} 3309}
3329 3310
3330bool CalendarView::isModified() 3311bool CalendarView::isModified()
3331{ 3312{
3332 return mModified; 3313 return mModified;
3333} 3314}
3334 3315
3335void CalendarView::printSetup() 3316void CalendarView::printSetup()
3336{ 3317{
3337#ifndef KORG_NOPRINTER 3318#ifndef KORG_NOPRINTER
3338 createPrinter(); 3319 createPrinter();
3339 3320
3340 mCalPrinter->setupPrinter(); 3321 mCalPrinter->setupPrinter();
3341#endif 3322#endif
3342} 3323}
3343 3324
3344void CalendarView::print() 3325void CalendarView::print()
3345{ 3326{
3346#ifndef KORG_NOPRINTER 3327#ifndef KORG_NOPRINTER
3347 createPrinter(); 3328 createPrinter();
3348 3329
3349 DateList tmpDateList = mNavigator->selectedDates(); 3330 DateList tmpDateList = mNavigator->selectedDates();
3350 mCalPrinter->print(CalPrinter::Month, 3331 mCalPrinter->print(CalPrinter::Month,
3351 tmpDateList.first(), tmpDateList.last()); 3332 tmpDateList.first(), tmpDateList.last());
3352#endif 3333#endif
3353} 3334}
3354 3335
3355void CalendarView::printPreview() 3336void CalendarView::printPreview()
3356{ 3337{
3357#ifndef KORG_NOPRINTER 3338#ifndef KORG_NOPRINTER
3358 kdDebug() << "CalendarView::printPreview()" << endl; 3339 kdDebug() << "CalendarView::printPreview()" << endl;
3359 3340
3360 createPrinter(); 3341 createPrinter();
3361 3342
3362 DateList tmpDateList = mNavigator->selectedDates(); 3343 DateList tmpDateList = mNavigator->selectedDates();
3363 3344
3364 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), 3345 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(),
3365 tmpDateList.last()); 3346 tmpDateList.last());
3366#endif 3347#endif
3367} 3348}
3368 3349
3369void CalendarView::exportICalendar() 3350void CalendarView::exportICalendar()
3370{ 3351{
3371 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); 3352 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this);
3372 3353
3373 // Force correct extension 3354 // Force correct extension
3374 if (filename.right(4) != ".ics") filename += ".ics"; 3355 if (filename.right(4) != ".ics") filename += ".ics";
3375 3356
3376 FileStorage storage( mCalendar, filename, new ICalFormat() ); 3357 FileStorage storage( mCalendar, filename, new ICalFormat() );
3377 storage.save(); 3358 storage.save();
3378} 3359}
3379 3360
3380bool CalendarView::exportVCalendar( QString filename ) 3361bool CalendarView::exportVCalendar( QString filename )
3381{ 3362{
3382 if (mCalendar->journals().count() > 0) { 3363 if (mCalendar->journals().count() > 0) {
3383 int result = KMessageBox::warningContinueCancel(this, 3364 int result = KMessageBox::warningContinueCancel(this,
3384 i18n("The journal entries can not be\nexported to a vCalendar file."), 3365 i18n("The journal entries can not be\nexported to a vCalendar file."),
3385 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 3366 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
3386 true); 3367 true);
3387 if (result != KMessageBox::Continue) return false; 3368 if (result != KMessageBox::Continue) return false;
3388 } 3369 }
3389 3370
3390 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); 3371 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this);
3391 3372
3392 // Force correct extension 3373 // Force correct extension
3393 if (filename.right(4) != ".vcs") filename += ".vcs"; 3374 if (filename.right(4) != ".vcs") filename += ".vcs";
3394 3375
3395 FileStorage storage( mCalendar, filename, new VCalFormat ); 3376 FileStorage storage( mCalendar, filename, new VCalFormat );
3396 return storage.save(); 3377 return storage.save();
3397 3378
3398} 3379}
3399 3380
3400void CalendarView::eventUpdated(Incidence *) 3381void CalendarView::eventUpdated(Incidence *)
3401{ 3382{
3402 setModified(); 3383 setModified();
3403 // Don't call updateView here. The code, which has caused the update of the 3384 // Don't call updateView here. The code, which has caused the update of the
3404 // event is responsible for updating the view. 3385 // event is responsible for updating the view.
3405 // updateView(); 3386 // updateView();
3406} 3387}
3407 3388
3408void CalendarView::adaptNavigationUnits() 3389void CalendarView::adaptNavigationUnits()
3409{ 3390{
3410 if (mViewManager->currentView()->isEventView()) { 3391 if (mViewManager->currentView()->isEventView()) {
3411 int days = mViewManager->currentView()->currentDateCount(); 3392 int days = mViewManager->currentView()->currentDateCount();
3412 if (days == 1) { 3393 if (days == 1) {
3413 emit changeNavStringPrev(i18n("&Previous Day")); 3394 emit changeNavStringPrev(i18n("&Previous Day"));
3414 emit changeNavStringNext(i18n("&Next Day")); 3395 emit changeNavStringNext(i18n("&Next Day"));
3415 } else { 3396 } else {
3416 emit changeNavStringPrev(i18n("&Previous Week")); 3397 emit changeNavStringPrev(i18n("&Previous Week"));
3417 emit changeNavStringNext(i18n("&Next Week")); 3398 emit changeNavStringNext(i18n("&Next Week"));
3418 } 3399 }
3419 } 3400 }
3420} 3401}
3421 3402
3422void CalendarView::processMainViewSelection( Incidence *incidence ) 3403void CalendarView::processMainViewSelection( Incidence *incidence )
3423{ 3404{
3424 if ( incidence ) mTodoList->clearSelection(); 3405 if ( incidence ) mTodoList->clearSelection();
3425 processIncidenceSelection( incidence ); 3406 processIncidenceSelection( incidence );
3426} 3407}
3427 3408
3428void CalendarView::processTodoListSelection( Incidence *incidence ) 3409void CalendarView::processTodoListSelection( Incidence *incidence )
3429{ 3410{
3430 if ( incidence && mViewManager->currentView() ) { 3411 if ( incidence && mViewManager->currentView() ) {
3431 mViewManager->currentView()->clearSelection(); 3412 mViewManager->currentView()->clearSelection();
3432 } 3413 }
3433 processIncidenceSelection( incidence ); 3414 processIncidenceSelection( incidence );
3434} 3415}
3435 3416
3436void CalendarView::processIncidenceSelection( Incidence *incidence ) 3417void CalendarView::processIncidenceSelection( Incidence *incidence )
3437{ 3418{
3438 if ( incidence == mSelectedIncidence ) return; 3419 if ( incidence == mSelectedIncidence ) return;
3439 3420
3440 mSelectedIncidence = incidence; 3421 mSelectedIncidence = incidence;
3441 3422
3442 emit incidenceSelected( mSelectedIncidence ); 3423 emit incidenceSelected( mSelectedIncidence );
3443 3424
3444 if ( incidence && incidence->type() == "Event" ) { 3425 if ( incidence && incidence->type() == "Event" ) {
3445 Event *event = static_cast<Event *>( incidence ); 3426 Event *event = static_cast<Event *>( incidence );
3446 if ( event->organizer() == KOPrefs::instance()->email() ) { 3427 if ( event->organizer() == KOPrefs::instance()->email() ) {
3447 emit organizerEventsSelected( true ); 3428 emit organizerEventsSelected( true );
3448 } else { 3429 } else {
3449 emit organizerEventsSelected(false); 3430 emit organizerEventsSelected(false);
3450 } 3431 }
3451 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3432 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3452 KOPrefs::instance()->email() ) ) { 3433 KOPrefs::instance()->email() ) ) {
3453 emit groupEventsSelected( true ); 3434 emit groupEventsSelected( true );
3454 } else { 3435 } else {
3455 emit groupEventsSelected(false); 3436 emit groupEventsSelected(false);
3456 } 3437 }
3457 return; 3438 return;
3458 } else { 3439 } else {
3459 if ( incidence && incidence->type() == "Todo" ) { 3440 if ( incidence && incidence->type() == "Todo" ) {
3460 emit todoSelected( true ); 3441 emit todoSelected( true );
3461 Todo *event = static_cast<Todo *>( incidence ); 3442 Todo *event = static_cast<Todo *>( incidence );
3462 if ( event->organizer() == KOPrefs::instance()->email() ) { 3443 if ( event->organizer() == KOPrefs::instance()->email() ) {
3463 emit organizerEventsSelected( true ); 3444 emit organizerEventsSelected( true );
3464 } else { 3445 } else {
3465 emit organizerEventsSelected(false); 3446 emit organizerEventsSelected(false);
3466 } 3447 }
3467 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3448 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3468 KOPrefs::instance()->email() ) ) { 3449 KOPrefs::instance()->email() ) ) {
3469 emit groupEventsSelected( true ); 3450 emit groupEventsSelected( true );
3470 } else { 3451 } else {
3471 emit groupEventsSelected(false); 3452 emit groupEventsSelected(false);
3472 } 3453 }
3473 return; 3454 return;
3474 } else { 3455 } else {
3475 emit todoSelected( false ); 3456 emit todoSelected( false );
3476 emit organizerEventsSelected(false); 3457 emit organizerEventsSelected(false);
3477 emit groupEventsSelected(false); 3458 emit groupEventsSelected(false);
3478 } 3459 }
3479 return; 3460 return;
3480 } 3461 }
3481 3462
3482 /* if ( incidence && incidence->type() == "Todo" ) { 3463 /* if ( incidence && incidence->type() == "Todo" ) {
3483 emit todoSelected( true ); 3464 emit todoSelected( true );
3484 } else { 3465 } else {
3485 emit todoSelected( false ); 3466 emit todoSelected( false );
3486 }*/ 3467 }*/
3487} 3468}
3488 3469
3489 3470
3490void CalendarView::checkClipboard() 3471void CalendarView::checkClipboard()
3491{ 3472{
3492#ifndef KORG_NODND 3473#ifndef KORG_NODND
3493 if (ICalDrag::canDecode(QApplication::clipboard()->data())) { 3474 if (ICalDrag::canDecode(QApplication::clipboard()->data())) {
3494 emit pasteEnabled(true); 3475 emit pasteEnabled(true);
3495 } else { 3476 } else {
3496 emit pasteEnabled(false); 3477 emit pasteEnabled(false);
3497 } 3478 }
3498#endif 3479#endif
3499} 3480}
3500 3481
3501void CalendarView::showDates(const DateList &selectedDates) 3482void CalendarView::showDates(const DateList &selectedDates)
3502{ 3483{
3503 // kdDebug() << "CalendarView::selectDates()" << endl; 3484 // kdDebug() << "CalendarView::selectDates()" << endl;
3504 3485
3505 3486
3506 if ( !mBlockShowDates ) { 3487 if ( !mBlockShowDates ) {
3507 if ( mViewManager->currentView() ) { 3488 if ( mViewManager->currentView() ) {
3508 updateView( selectedDates.first(), selectedDates.last() ); 3489 updateView( selectedDates.first(), selectedDates.last() );
3509 } else { 3490 } else {
3510 mViewManager->showAgendaView(); 3491 mViewManager->showAgendaView();
3511 } 3492 }
3512 } 3493 }
3513 3494
3514 QString selDates; 3495 QString selDates;
3515 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); 3496 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true);
3516 if (selectedDates.first() < selectedDates.last() ) 3497 if (selectedDates.first() < selectedDates.last() )
3517 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); 3498 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true);
3518 else { 3499 else {
3519 QString addString; 3500 QString addString;
3520 if ( selectedDates.first() == QDateTime::currentDateTime().date() ) 3501 if ( selectedDates.first() == QDateTime::currentDateTime().date() )
3521 addString = i18n("Today"); 3502 addString = i18n("Today");
3522 else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) 3503 else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(1) )
3523 addString = i18n("Tomorrow"); 3504 addString = i18n("Tomorrow");
3524 else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) 3505 else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) )
3525 addString = i18n("Yesterday"); 3506 addString = i18n("Yesterday");
3526 else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) 3507 else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) )
3527 addString = i18n("Day before yesterday"); 3508 addString = i18n("Day before yesterday");
3528 else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) 3509 else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(2) )
3529 addString = i18n("Day after tomorrow"); 3510 addString = i18n("Day after tomorrow");
3530 if ( !addString.isEmpty() ) { 3511 if ( !addString.isEmpty() ) {
3531 topLevelWidget()->setCaption( addString+", " + selDates ); 3512 topLevelWidget()->setCaption( addString+", " + selDates );
3532 return; 3513 return;
3533 } 3514 }
3534 } 3515 }
3535 topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); 3516 topLevelWidget()->setCaption( i18n("Dates: ") + selDates );
3536 3517
3537} 3518}
3538 3519
3539QPtrList<CalFilter> CalendarView::filters() 3520QPtrList<CalFilter> CalendarView::filters()
3540{ 3521{
3541 return mFilters; 3522 return mFilters;
3542 3523
3543} 3524}
3544void CalendarView::editFilters() 3525void CalendarView::editFilters()
3545{ 3526{
3546 // kdDebug() << "CalendarView::editFilters()" << endl; 3527 // kdDebug() << "CalendarView::editFilters()" << endl;
3547 3528
3548 CalFilter *filter = mFilters.first(); 3529 CalFilter *filter = mFilters.first();
3549 while(filter) { 3530 while(filter) {
3550 kdDebug() << " Filter: " << filter->name() << endl; 3531 kdDebug() << " Filter: " << filter->name() << endl;
3551 filter = mFilters.next(); 3532 filter = mFilters.next();
3552 } 3533 }
3553 3534
3554 mDialogManager->showFilterEditDialog(&mFilters); 3535 mDialogManager->showFilterEditDialog(&mFilters);
3555} 3536}
3556void CalendarView::toggleFilter() 3537void CalendarView::toggleFilter()
3557{ 3538{
3558 showFilter(! mFilterView->isVisible()); 3539 showFilter(! mFilterView->isVisible());
3559} 3540}
3560 3541
3561KOFilterView *CalendarView::filterView() 3542KOFilterView *CalendarView::filterView()
3562{ 3543{
3563 return mFilterView; 3544 return mFilterView;
3564} 3545}
3565void CalendarView::selectFilter( int fil ) 3546void CalendarView::selectFilter( int fil )
3566{ 3547{
3567 mFilterView->setSelectedFilter( fil ); 3548 mFilterView->setSelectedFilter( fil );
3568} 3549}
3569void CalendarView::showFilter(bool visible) 3550void CalendarView::showFilter(bool visible)
3570{ 3551{
3571 if (visible) mFilterView->show(); 3552 if (visible) mFilterView->show();
3572 else mFilterView->hide(); 3553 else mFilterView->hide();
3573} 3554}
3574void CalendarView::toggleFilerEnabled( ) 3555void CalendarView::toggleFilerEnabled( )
3575{ 3556{
3576 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); 3557 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() );
3577 if ( !mFilterView->filtersEnabled() ) 3558 if ( !mFilterView->filtersEnabled() )
3578 topLevelWidget()->setCaption( i18n("Filter disabled ") ); 3559 topLevelWidget()->setCaption( i18n("Filter disabled ") );
3579 3560
3580} 3561}
3581void CalendarView::updateFilter() 3562void CalendarView::updateFilter()
3582{ 3563{
3583 CalFilter *filter = mFilterView->selectedFilter(); 3564 CalFilter *filter = mFilterView->selectedFilter();
3584 if (filter) { 3565 if (filter) {
3585 if (mFilterView->filtersEnabled()) { 3566 if (mFilterView->filtersEnabled()) {
3586 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); 3567 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() );
3587 filter->setEnabled(true); 3568 filter->setEnabled(true);
3588 } 3569 }
3589 else filter->setEnabled(false); 3570 else filter->setEnabled(false);
3590 mCalendar->setFilter(filter); 3571 mCalendar->setFilter(filter);
3591 updateView(); 3572 updateView();
3592 } 3573 }
3593} 3574}
3594 3575
3595void CalendarView::filterEdited() 3576void CalendarView::filterEdited()
3596{ 3577{
3597 mFilterView->updateFilters(); 3578 mFilterView->updateFilters();
3598 updateFilter(); 3579 updateFilter();
3599 writeSettings(); 3580 writeSettings();
3600} 3581}
3601 3582
3602 3583
3603void CalendarView::takeOverEvent() 3584void CalendarView::takeOverEvent()
3604{ 3585{
3605 Incidence *incidence = currentSelection(); 3586 Incidence *incidence = currentSelection();
3606 3587
3607 if (!incidence) return; 3588 if (!incidence) return;
3608 3589
3609 incidence->setOrganizer(KOPrefs::instance()->email()); 3590 incidence->setOrganizer(KOPrefs::instance()->email());
3610 incidence->recreate(); 3591 incidence->recreate();
3611 incidence->setReadOnly(false); 3592 incidence->setReadOnly(false);
3612 3593
3613 updateView(); 3594 updateView();
3614} 3595}
3615 3596
3616void CalendarView::takeOverCalendar() 3597void CalendarView::takeOverCalendar()
3617{ 3598{
3618 // TODO: Create Calendar::allIncidences() function and use it here 3599 // TODO: Create Calendar::allIncidences() function and use it here
3619 3600
3620 QPtrList<Event> events = mCalendar->events(); 3601 QPtrList<Event> events = mCalendar->events();
3621 for(uint i=0; i<events.count(); ++i) { 3602 for(uint i=0; i<events.count(); ++i) {
3622 events.at(i)->setOrganizer(KOPrefs::instance()->email()); 3603 events.at(i)->setOrganizer(KOPrefs::instance()->email());
3623 events.at(i)->recreate(); 3604 events.at(i)->recreate();
3624 events.at(i)->setReadOnly(false); 3605 events.at(i)->setReadOnly(false);
3625 } 3606 }
3626 3607
3627 QPtrList<Todo> todos = mCalendar->todos(); 3608 QPtrList<Todo> todos = mCalendar->todos();
3628 for(uint i=0; i<todos.count(); ++i) { 3609 for(uint i=0; i<todos.count(); ++i) {
3629 todos.at(i)->setOrganizer(KOPrefs::instance()->email()); 3610 todos.at(i)->setOrganizer(KOPrefs::instance()->email());
3630 todos.at(i)->recreate(); 3611 todos.at(i)->recreate();
3631 todos.at(i)->setReadOnly(false); 3612 todos.at(i)->setReadOnly(false);
3632 } 3613 }
3633 3614
3634 QPtrList<Journal> journals = mCalendar->journals(); 3615 QPtrList<Journal> journals = mCalendar->journals();
3635 for(uint i=0; i<journals.count(); ++i) { 3616 for(uint i=0; i<journals.count(); ++i) {
3636 journals.at(i)->setOrganizer(KOPrefs::instance()->email()); 3617 journals.at(i)->setOrganizer(KOPrefs::instance()->email());
3637 journals.at(i)->recreate(); 3618 journals.at(i)->recreate();
3638 journals.at(i)->setReadOnly(false); 3619 journals.at(i)->setReadOnly(false);
3639 } 3620 }
3640 3621
3641 updateView(); 3622 updateView();
3642} 3623}
3643 3624
3644void CalendarView::showIntro() 3625void CalendarView::showIntro()
3645{ 3626{
3646 kdDebug() << "To be implemented." << endl; 3627 kdDebug() << "To be implemented." << endl;
3647} 3628}
3648 3629
3649QWidgetStack *CalendarView::viewStack() 3630QWidgetStack *CalendarView::viewStack()
3650{ 3631{
3651 return mRightFrame; 3632 return mRightFrame;
3652} 3633}
3653 3634
3654QWidget *CalendarView::leftFrame() 3635QWidget *CalendarView::leftFrame()
3655{ 3636{
3656 return mLeftFrame; 3637 return mLeftFrame;
3657} 3638}
3658 3639
3659DateNavigator *CalendarView::dateNavigator() 3640DateNavigator *CalendarView::dateNavigator()
3660{ 3641{
3661 return mNavigator; 3642 return mNavigator;
3662} 3643}
3663 3644
3664KDateNavigator* CalendarView::dateNavigatorWidget() 3645KDateNavigator* CalendarView::dateNavigatorWidget()
3665{ 3646{
3666 return mDateNavigator; 3647 return mDateNavigator;
3667} 3648}
3668void CalendarView::toggleDateNavigatorWidget() 3649void CalendarView::toggleDateNavigatorWidget()
3669{ 3650{
3670 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; 3651 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ;
3671 if (!KOPrefs::instance()->mShowDateNavigator ) 3652 if (!KOPrefs::instance()->mShowDateNavigator )
3672 mDateNavigator->hide(); 3653 mDateNavigator->hide();
3673 else 3654 else
3674 mDateNavigator->show(); 3655 mDateNavigator->show();
3675} 3656}
3676void CalendarView::addView(KOrg::BaseView *view) 3657void CalendarView::addView(KOrg::BaseView *view)
3677{ 3658{
3678 mViewManager->addView(view); 3659 mViewManager->addView(view);
3679} 3660}
3680 3661
3681void CalendarView::showView(KOrg::BaseView *view) 3662void CalendarView::showView(KOrg::BaseView *view)
3682{ 3663{
3683 mViewManager->showView(view, mLeftFrame->isVisible()); 3664 mViewManager->showView(view, mLeftFrame->isVisible());
3684} 3665}
3685 3666
3686Incidence *CalendarView::currentSelection() 3667Incidence *CalendarView::currentSelection()
3687{ 3668{
3688 return mViewManager->currentSelection(); 3669 return mViewManager->currentSelection();
3689} 3670}
3690void CalendarView::toggleAllDaySize() 3671void CalendarView::toggleAllDaySize()
3691{ 3672{
3692 /* 3673 /*
3693 if ( KOPrefs::instance()->mAllDaySize > 47 ) 3674 if ( KOPrefs::instance()->mAllDaySize > 47 )
3694 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; 3675 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2;
3695 else 3676 else
3696 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; 3677 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2;
3697 */ 3678 */
3698 viewManager()->agendaView()->toggleAllDay(); 3679 viewManager()->agendaView()->toggleAllDay();
3699} 3680}
3700void CalendarView::toggleExpand() 3681void CalendarView::toggleExpand()
3701{ 3682{
3702 // if ( mLeftFrame->isHidden() ) { 3683 // if ( mLeftFrame->isHidden() ) {
3703 // mLeftFrame->show(); 3684 // mLeftFrame->show();
3704 // emit calendarViewExpanded( false ); 3685 // emit calendarViewExpanded( false );
3705 // } else { 3686 // } else {
3706 // mLeftFrame->hide(); 3687 // mLeftFrame->hide();
3707 // emit calendarViewExpanded( true ); 3688 // emit calendarViewExpanded( true );
3708 // } 3689 // }
3709 //qDebug(" CalendarView::toggleExpand()"); 3690 //qDebug(" CalendarView::toggleExpand()");
3710 globalFlagBlockAgenda = 1; 3691 globalFlagBlockAgenda = 1;
3711 emit calendarViewExpanded( !mLeftFrame->isHidden() ); 3692 emit calendarViewExpanded( !mLeftFrame->isHidden() );
3712 globalFlagBlockAgenda = 5; 3693 globalFlagBlockAgenda = 5;
3713 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); 3694 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() );
3714 //mViewManager->showView( 0, true ); 3695 //mViewManager->showView( 0, true );
3715} 3696}
3716 3697
3717void CalendarView::calendarModified( bool modified, Calendar * ) 3698void CalendarView::calendarModified( bool modified, Calendar * )
3718{ 3699{
3719 setModified( modified ); 3700 setModified( modified );
3720} 3701}
3721 3702
3722Todo *CalendarView::selectedTodo() 3703Todo *CalendarView::selectedTodo()
3723{ 3704{
3724 Incidence *incidence = currentSelection(); 3705 Incidence *incidence = currentSelection();
3725 if ( incidence && incidence->type() == "Todo" ) { 3706 if ( incidence && incidence->type() == "Todo" ) {
3726 return static_cast<Todo *>( incidence ); 3707 return static_cast<Todo *>( incidence );
3727 } 3708 }
3728 3709
3729 incidence = mTodoList->selectedIncidences().first(); 3710 incidence = mTodoList->selectedIncidences().first();
3730 if ( incidence && incidence->type() == "Todo" ) { 3711 if ( incidence && incidence->type() == "Todo" ) {
3731 return static_cast<Todo *>( incidence ); 3712 return static_cast<Todo *>( incidence );
3732 } 3713 }
3733 3714
3734 return 0; 3715 return 0;
3735} 3716}
3736 3717
3737void CalendarView::dialogClosing(Incidence *in) 3718void CalendarView::dialogClosing(Incidence *in)
3738{ 3719{
3739 // mDialogList.remove(in); 3720 // mDialogList.remove(in);
3740} 3721}
3741 3722
3742void CalendarView::showIncidence() 3723void CalendarView::showIncidence()
3743{ 3724{
3744 Incidence *incidence = currentSelection(); 3725 Incidence *incidence = currentSelection();
3745 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3726 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3746 if ( incidence ) { 3727 if ( incidence ) {
3747 ShowIncidenceVisitor v; 3728 ShowIncidenceVisitor v;
3748 v.act( incidence, this ); 3729 v.act( incidence, this );
3749 } 3730 }
3750} 3731}
3751void CalendarView::editIncidenceDescription() 3732void CalendarView::editIncidenceDescription()
3752{ 3733{
3753 mFlagEditDescription = true; 3734 mFlagEditDescription = true;
3754 editIncidence(); 3735 editIncidence();
3755 mFlagEditDescription = false; 3736 mFlagEditDescription = false;
3756} 3737}
3757void CalendarView::editIncidence() 3738void CalendarView::editIncidence()
3758{ 3739{
3759 // qDebug("editIncidence() "); 3740 // qDebug("editIncidence() ");
3760 Incidence *incidence = currentSelection(); 3741 Incidence *incidence = currentSelection();
3761 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3742 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3762 if ( incidence ) { 3743 if ( incidence ) {
3763 EditIncidenceVisitor v; 3744 EditIncidenceVisitor v;
3764 v.act( incidence, this ); 3745 v.act( incidence, this );
3765 } 3746 }
3766} 3747}
3767 3748
3768void CalendarView::deleteIncidence() 3749void CalendarView::deleteIncidence()
3769{ 3750{
3770 Incidence *incidence = currentSelection(); 3751 Incidence *incidence = currentSelection();
3771 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3752 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3772 if ( incidence ) { 3753 if ( incidence ) {
3773 deleteIncidence(incidence); 3754 deleteIncidence(incidence);
3774 } 3755 }
3775} 3756}
3776 3757
3777void CalendarView::showIncidence(Incidence *incidence) 3758void CalendarView::showIncidence(Incidence *incidence)
3778{ 3759{
3779 if ( incidence ) { 3760 if ( incidence ) {
3780 ShowIncidenceVisitor v; 3761 ShowIncidenceVisitor v;
3781 v.act( incidence, this ); 3762 v.act( incidence, this );
3782 } 3763 }
3783} 3764}
3784 3765
3785void CalendarView::editIncidence(Incidence *incidence) 3766void CalendarView::editIncidence(Incidence *incidence)
3786{ 3767{
3787 if ( incidence ) { 3768 if ( incidence ) {
3788 3769
3789 EditIncidenceVisitor v; 3770 EditIncidenceVisitor v;
3790 v.act( incidence, this ); 3771 v.act( incidence, this );
3791 3772
3792 } 3773 }
3793} 3774}
3794 3775
3795void CalendarView::deleteIncidence(Incidence *incidence) 3776void CalendarView::deleteIncidence(Incidence *incidence)
3796{ 3777{
3797 //qDebug(" CalendarView::deleteIncidence "); 3778 //qDebug(" CalendarView::deleteIncidence ");
3798 if ( incidence ) { 3779 if ( incidence ) {
3799 DeleteIncidenceVisitor v; 3780 DeleteIncidenceVisitor v;
3800 v.act( incidence, this ); 3781 v.act( incidence, this );
3801 } 3782 }
3802} 3783}
3803 3784
3804 3785
3805void CalendarView::lookForOutgoingMessages() 3786void CalendarView::lookForOutgoingMessages()
3806{ 3787{
3807 OutgoingDialog *ogd = mDialogManager->outgoingDialog(); 3788 OutgoingDialog *ogd = mDialogManager->outgoingDialog();
3808 ogd->loadMessages(); 3789 ogd->loadMessages();
3809} 3790}
3810 3791
3811void CalendarView::lookForIncomingMessages() 3792void CalendarView::lookForIncomingMessages()
3812{ 3793{
3813 IncomingDialog *icd = mDialogManager->incomingDialog(); 3794 IncomingDialog *icd = mDialogManager->incomingDialog();
3814 icd->retrieve(); 3795 icd->retrieve();
3815} 3796}
3816 3797
3817bool CalendarView::removeCompletedSubTodos( Todo* t ) 3798bool CalendarView::removeCompletedSubTodos( Todo* t )
3818{ 3799{
3819 bool deleteTodo = true; 3800 bool deleteTodo = true;
3820 QPtrList<Incidence> subTodos; 3801 QPtrList<Incidence> subTodos;
3821 Incidence *aTodo; 3802 Incidence *aTodo;
3822 subTodos = t->relations(); 3803 subTodos = t->relations();
3823 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { 3804 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
3824 if (! removeCompletedSubTodos( (Todo*) aTodo )) 3805 if (! removeCompletedSubTodos( (Todo*) aTodo ))
3825 deleteTodo = false; 3806 deleteTodo = false;
3826 } 3807 }
3827 if ( deleteTodo ) { 3808 if ( deleteTodo ) {
3828 if ( t->isCompleted() ) { 3809 if ( t->isCompleted() ) {
3829 checkExternalId( t ); 3810 checkExternalId( t );
3830 mCalendar->deleteTodo( t ); 3811 mCalendar->deleteTodo( t );
3831 changeTodoDisplay( t,KOGlobals::EVENTDELETED ); 3812 changeTodoDisplay( t,KOGlobals::EVENTDELETED );
3832 } 3813 }
3833 else 3814 else
3834 deleteTodo = false; 3815 deleteTodo = false;
3835 } 3816 }
3836 return deleteTodo; 3817 return deleteTodo;
3837 3818
3838} 3819}
3839void CalendarView::purgeCompleted() 3820void CalendarView::purgeCompleted()
3840{ 3821{
3841 int result = KMessageBox::warningContinueCancel(this, 3822 int result = KMessageBox::warningContinueCancel(this,
3842 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); 3823 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge"));
3843 3824
3844 if (result == KMessageBox::Continue) { 3825 if (result == KMessageBox::Continue) {
3845 3826
3846 QPtrList<Todo> todoCal; 3827 QPtrList<Todo> todoCal;
3847 QPtrList<Todo> rootTodos; 3828 QPtrList<Todo> rootTodos;
3848 //QPtrList<Incidence> rel; 3829 //QPtrList<Incidence> rel;
3849 Todo *aTodo;//, *rTodo; 3830 Todo *aTodo;//, *rTodo;
3850 Incidence *rIncidence; 3831 Incidence *rIncidence;
3851 bool childDelete = false; 3832 bool childDelete = false;
3852 bool deletedOne = true; 3833 bool deletedOne = true;
3853 todoCal = calendar()->todos(); 3834 todoCal = calendar()->todos();
3854 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { 3835 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
3855 if ( !aTodo->relatedTo() ) 3836 if ( !aTodo->relatedTo() )
3856 rootTodos.append( aTodo ); 3837 rootTodos.append( aTodo );
3857 } 3838 }
3858 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { 3839 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) {
3859 removeCompletedSubTodos( aTodo ); 3840 removeCompletedSubTodos( aTodo );
3860 } 3841 }
3861 3842
3862 updateView(); 3843 updateView();
3863 } 3844 }
3864} 3845}
3865 3846
3866void CalendarView::slotCalendarChanged() 3847void CalendarView::slotCalendarChanged()
3867{ 3848{
3868 ; 3849 ;
3869} 3850}
3870 3851
3871NavigatorBar *CalendarView::navigatorBar()
3872{
3873 return mNavigatorBar;
3874}
3875void CalendarView::showNavigatorBar( bool b)
3876{
3877 if ( b ) mNavigatorBar->show();
3878 else mNavigatorBar->hide();
3879}
3880
3881
3882
3883void CalendarView::keyPressEvent ( QKeyEvent *e) 3852void CalendarView::keyPressEvent ( QKeyEvent *e)
3884{ 3853{
3885 //qDebug(" alendarView::keyPressEvent "); 3854 //qDebug(" alendarView::keyPressEvent ");
3886 e->ignore(); 3855 e->ignore();
3887} 3856}
3888 3857
3889 3858
3890bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) 3859bool CalendarView::sync(KSyncManager* manager, QString filename, int mode)
3891{ 3860{
3892 // mSyncManager = manager; 3861 // mSyncManager = manager;
3893 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { 3862 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) {
3894 qDebug("KO: SyncKDE request detected!"); 3863 qDebug("KO: SyncKDE request detected!");
3895 } 3864 }
3896 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 3865 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
3897 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 3866 mCurrentSyncName = mSyncManager->getCurrentSyncName();
3898 return syncCalendar( filename, mode ); 3867 return syncCalendar( filename, mode );
3899} 3868}
3900bool CalendarView::syncExternal(KSyncManager* manager, QString resource) 3869bool CalendarView::syncExternal(KSyncManager* manager, QString resource)
3901{ 3870{
3902 //mSyncManager = manager; 3871 //mSyncManager = manager;
3903 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 3872 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
3904 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 3873 mCurrentSyncName = mSyncManager->getCurrentSyncName();
3905 if ( resource == "sharp" ) 3874 if ( resource == "sharp" )
3906 syncExternal( 0 ); 3875 syncExternal( 0 );
3907 if ( resource == "phone" ) 3876 if ( resource == "phone" )
3908 syncExternal( 1 ); 3877 syncExternal( 1 );
3909 // pending setmodified 3878 // pending setmodified
3910 return true; 3879 return true;
3911} 3880}
3912void CalendarView::setSyncManager(KSyncManager* manager) 3881void CalendarView::setSyncManager(KSyncManager* manager)
3913{ 3882{
3914 mSyncManager = manager; 3883 mSyncManager = manager;
3915} 3884}
3916 3885
3917void CalendarView::removeSyncInfo( QString syncProfile) 3886void CalendarView::removeSyncInfo( QString syncProfile)
3918{ 3887{
3919 qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); 3888 qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1());
3920 mCalendar->removeSyncInfo( syncProfile ); 3889 mCalendar->removeSyncInfo( syncProfile );
3921 3890
3922} 3891}
3923 3892
3924void CalendarView::undo_delete() 3893void CalendarView::undo_delete()
3925{ 3894{
3926 //qDebug("undo_delete() "); 3895 //qDebug("undo_delete() ");
3927 Incidence* undo = mCalendar->undoIncidence(); 3896 Incidence* undo = mCalendar->undoIncidence();
3928 if ( !undo ) { 3897 if ( !undo ) {
3929 KMessageBox::sorry(this,i18n("There is nothing to undo!"), 3898 KMessageBox::sorry(this,i18n("There is nothing to undo!"),
3930 i18n("KO/Pi")); 3899 i18n("KO/Pi"));
3931 return; 3900 return;
3932 } 3901 }
3933 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + 3902 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) +
3934 i18n("\nAre you sure you want\nto restore this?"), 3903 i18n("\nAre you sure you want\nto restore this?"),
3935 i18n("KO/Pi Confirmation"),i18n("Restore"))) { 3904 i18n("KO/Pi Confirmation"),i18n("Restore"))) {
3936 mCalendar->undoDeleteIncidence(); 3905 mCalendar->undoDeleteIncidence();
3937 updateView(); 3906 updateView();
3938 } 3907 }
3939} 3908}
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index 8d7ff36..731298d 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -1,615 +1,611 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000, 2001 3 Copyright (c) 2000, 2001
4 Cornelius Schumacher <schumacher@kde.org> 4 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24#ifndef CALENDARVIEW_H 24#ifndef CALENDARVIEW_H
25#define CALENDARVIEW_H 25#define CALENDARVIEW_H
26 26
27#include <qframe.h> 27#include <qframe.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#include <qwidget.h> 29#include <qwidget.h>
30#include <qptrlist.h> 30#include <qptrlist.h>
31#include <qvbox.h> 31#include <qvbox.h>
32#include <qmap.h> 32#include <qmap.h>
33#ifndef DESKTOP_VERSION 33#ifndef DESKTOP_VERSION
34#include <qtopia/ir.h> 34#include <qtopia/ir.h>
35#else 35#else
36#define Ir char 36#define Ir char
37#endif 37#endif
38#include <libkcal/calendar.h> 38#include <libkcal/calendar.h>
39#include <libkcal/scheduler.h> 39#include <libkcal/scheduler.h>
40#include <libkcal/calendarresources.h> 40#include <libkcal/calendarresources.h>
41#include <libkcal/resourcecalendar.h> 41#include <libkcal/resourcecalendar.h>
42 42
43#include <korganizer/calendarviewbase.h> 43#include <korganizer/calendarviewbase.h>
44 44
45#include <ksyncmanager.h> 45#include <ksyncmanager.h>
46 46
47class QWidgetStack; 47class QWidgetStack;
48class QSplitter; 48class QSplitter;
49 49
50class CalPrinter; 50class CalPrinter;
51class KOFilterView; 51class KOFilterView;
52class KOViewManager; 52class KOViewManager;
53class KODialogManager; 53class KODialogManager;
54class KOTodoView; 54class KOTodoView;
55class KDateNavigator; 55class KDateNavigator;
56class DateNavigator; 56class DateNavigator;
57class KOIncidenceEditor; 57class KOIncidenceEditor;
58class KDatePicker; 58class KDatePicker;
59class ResourceView; 59class ResourceView;
60class NavigatorBar;
61class KOEventEditor; 60class KOEventEditor;
62class KOTodoEditor ; 61class KOTodoEditor ;
63class KOEventViewerDialog; 62class KOEventViewerDialog;
64class KOBeamPrefs; 63class KOBeamPrefs;
65class KSyncProfile; 64class KSyncProfile;
66class AlarmDialog; 65class AlarmDialog;
67class KCal::Attendee; 66class KCal::Attendee;
68 67
69namespace KCal { class FileStorage; } 68namespace KCal { class FileStorage; }
70 69
71using namespace KCal; 70using namespace KCal;
72 71
73/** 72/**
74 This is the main calendar widget. It provides the different vies on t he 73 This is the main calendar widget. It provides the different vies on t he
75 calendar data as well as the date navigator. It also handles synchronisation 74 calendar data as well as the date navigator. It also handles synchronisation
76 of the different views and controls the different dialogs like preferences, 75 of the different views and controls the different dialogs like preferences,
77 event editor, search dialog etc. 76 event editor, search dialog etc.
78 77
79 @short main calendar view widget 78 @short main calendar view widget
80 @author Cornelius Schumacher 79 @author Cornelius Schumacher
81*/ 80*/
82class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface 81class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface
83{ 82{
84 Q_OBJECT 83 Q_OBJECT
85 public: 84 public:
86 /** 85 /**
87 Constructs a new calendar view widget. 86 Constructs a new calendar view widget.
88 87
89 @param calendar calendar document 88 @param calendar calendar document
90 @param parent parent window 89 @param parent parent window
91 @param name Qt internal widget object name 90 @param name Qt internal widget object name
92 */ 91 */
93 CalendarView( CalendarResources *calendar, QWidget *parent = 0, 92 CalendarView( CalendarResources *calendar, QWidget *parent = 0,
94 const char *name = 0 ); 93 const char *name = 0 );
95 CalendarView( Calendar *calendar, QWidget *parent = 0, 94 CalendarView( Calendar *calendar, QWidget *parent = 0,
96 const char *name = 0 ); 95 const char *name = 0 );
97 virtual ~CalendarView(); 96 virtual ~CalendarView();
98 97
99 Calendar *calendar() { return mCalendar; } 98 Calendar *calendar() { return mCalendar; }
100 99
101 KOViewManager *viewManager(); 100 KOViewManager *viewManager();
102 KODialogManager *dialogManager(); 101 KODialogManager *dialogManager();
103 102
104 QDate startDate(); 103 QDate startDate();
105 QDate endDate(); 104 QDate endDate();
106 105
107 QWidgetStack *viewStack(); 106 QWidgetStack *viewStack();
108 QWidget *leftFrame(); 107 QWidget *leftFrame();
109 NavigatorBar *navigatorBar();
110 108
111 DateNavigator *dateNavigator(); 109 DateNavigator *dateNavigator();
112 KDateNavigator *dateNavigatorWidget(); 110 KDateNavigator *dateNavigatorWidget();
113 111
114 void addView(KOrg::BaseView *); 112 void addView(KOrg::BaseView *);
115 void showView(KOrg::BaseView *); 113 void showView(KOrg::BaseView *);
116 KOEventViewerDialog* getEventViewerDialog(); 114 KOEventViewerDialog* getEventViewerDialog();
117 Incidence *currentSelection(); 115 Incidence *currentSelection();
118 116
119 signals: 117 signals:
120 void save (); 118 void save ();
121 void saveStopTimer (); 119 void saveStopTimer ();
122 void tempDisableBR(bool); 120 void tempDisableBR(bool);
123 /** This todo has been modified */ 121 /** This todo has been modified */
124 void todoModified(Todo *, int); 122 void todoModified(Todo *, int);
125 123
126 /** when change is made to options dialog, the topwidget will catch this 124 /** when change is made to options dialog, the topwidget will catch this
127 * and emit this signal which notifies all widgets which have registered 125 * and emit this signal which notifies all widgets which have registered
128 * for notification to update their settings. */ 126 * for notification to update their settings. */
129 void configChanged(); 127 void configChanged();
130 /** emitted when the topwidget is closing down, so that any attached 128 /** emitted when the topwidget is closing down, so that any attached
131 child windows can also close. */ 129 child windows can also close. */
132 void closingDown(); 130 void closingDown();
133 /** emitted right before we die */ 131 /** emitted right before we die */
134 void closed(QWidget *); 132 void closed(QWidget *);
135 133
136 /** Emitted when state of modified flag changes */ 134 /** Emitted when state of modified flag changes */
137 void modifiedChanged(bool); 135 void modifiedChanged(bool);
138 void signalmodified(); 136 void signalmodified();
139 137
140 /** Emitted when state of read-only flag changes */ 138 /** Emitted when state of read-only flag changes */
141 void readOnlyChanged(bool); 139 void readOnlyChanged(bool);
142 140
143 /** Emitted when the unit of navigation changes */ 141 /** Emitted when the unit of navigation changes */
144 void changeNavStringPrev(const QString &); 142 void changeNavStringPrev(const QString &);
145 void changeNavStringNext(const QString &); 143 void changeNavStringNext(const QString &);
146 144
147 /** Emitted when state of events selection has changed and user is organizer*/ 145 /** Emitted when state of events selection has changed and user is organizer*/
148 void organizerEventsSelected(bool); 146 void organizerEventsSelected(bool);
149 /** Emitted when state of events selection has changed and user is attendee*/ 147 /** Emitted when state of events selection has changed and user is attendee*/
150 void groupEventsSelected(bool); 148 void groupEventsSelected(bool);
151 /** 149 /**
152 Emitted when an incidence gets selected. If the selection is cleared the 150 Emitted when an incidence gets selected. If the selection is cleared the
153 signal is emitted with 0 as argument. 151 signal is emitted with 0 as argument.
154 */ 152 */
155 void incidenceSelected( Incidence * ); 153 void incidenceSelected( Incidence * );
156 /** Emitted, when a todoitem is selected or deselected. */ 154 /** Emitted, when a todoitem is selected or deselected. */
157 void todoSelected( bool ); 155 void todoSelected( bool );
158 156
159 /** 157 /**
160 Emitted, when clipboard content changes. Parameter indicates if paste 158 Emitted, when clipboard content changes. Parameter indicates if paste
161 is possible or not. 159 is possible or not.
162 */ 160 */
163 void pasteEnabled(bool); 161 void pasteEnabled(bool);
164 162
165 /** Emitted, when the number of incoming messages has changed. */ 163 /** Emitted, when the number of incoming messages has changed. */
166 void numIncomingChanged(int); 164 void numIncomingChanged(int);
167 165
168 /** Emitted, when the number of outgoing messages has changed. */ 166 /** Emitted, when the number of outgoing messages has changed. */
169 void numOutgoingChanged(int); 167 void numOutgoingChanged(int);
170 168
171 /** Send status message, which can e.g. be displayed in the status bar. */ 169 /** Send status message, which can e.g. be displayed in the status bar. */
172 void statusMessage(const QString &); 170 void statusMessage(const QString &);
173 171
174 void calendarViewExpanded( bool ); 172 void calendarViewExpanded( bool );
175 void updateSearchDialog(); 173 void updateSearchDialog();
176 174
177 175
178 public slots: 176 public slots:
179 void showNavigatorBar(bool);
180 void showOpenError(); 177 void showOpenError();
181 void watchSavedFile(); 178 void watchSavedFile();
182 void recheckTimerAlarm(); 179 void recheckTimerAlarm();
183 void checkNextTimerAlarm(); 180 void checkNextTimerAlarm();
184 void addAlarm(const QDateTime &qdt, const QString &noti ); 181 void addAlarm(const QDateTime &qdt, const QString &noti );
185 void addSuspendAlarm(const QDateTime &qdt, const QString &noti ); 182 void addSuspendAlarm(const QDateTime &qdt, const QString &noti );
186 void removeAlarm(const QDateTime &qdt, const QString &noti ); 183 void removeAlarm(const QDateTime &qdt, const QString &noti );
187 184
188 /** options dialog made a changed to the configuration. we catch this 185 /** options dialog made a changed to the configuration. we catch this
189 * and notify all widgets which need to update their configuration. */ 186 * and notify all widgets which need to update their configuration. */
190 void updateConfig(); 187 void updateConfig();
191 188
192 void insertBirthdays(const QString& uid, const QStringList& birthdayList, 189 void insertBirthdays(const QString& uid, const QStringList& birthdayList,
193 const QStringList& anniversaryList, const QStringList& realNameList, 190 const QStringList& anniversaryList, const QStringList& realNameList,
194 const QStringList& emailList, const QStringList& assembledNameList, 191 const QStringList& emailList, const QStringList& assembledNameList,
195 const QStringList& uidList); 192 const QStringList& uidList);
196 193
197 /** 194 /**
198 Load calendar from file \a filename. If \a merge is true, load 195 Load calendar from file \a filename. If \a merge is true, load
199 calendar into existing one, if it is false, clear calendar, before 196 calendar into existing one, if it is false, clear calendar, before
200 loading. Return true, if calendar could be successfully loaded. 197 loading. Return true, if calendar could be successfully loaded.
201 */ 198 */
202 bool openCalendar(QString filename, bool merge=false); 199 bool openCalendar(QString filename, bool merge=false);
203 bool syncCalendar(QString filename,int mode = 0 ); 200 bool syncCalendar(QString filename,int mode = 0 );
204 201
205 /** 202 /**
206 Save calendar data to file. Return true if calendar could be 203 Save calendar data to file. Return true if calendar could be
207 successfully saved. 204 successfully saved.
208 */ 205 */
209 bool saveCalendar(QString filename); 206 bool saveCalendar(QString filename);
210 207
211 /** 208 /**
212 Close calendar. Clear calendar data and reset views to display an empty 209 Close calendar. Clear calendar data and reset views to display an empty
213 calendar. 210 calendar.
214 */ 211 */
215 void closeCalendar(); 212 void closeCalendar();
216 213
217 /** Archive old events of calendar */ 214 /** Archive old events of calendar */
218 void archiveCalendar(); 215 void archiveCalendar();
219 216
220 void showIncidence(); 217 void showIncidence();
221 void editIncidence(); 218 void editIncidence();
222 void editIncidenceDescription(); 219 void editIncidenceDescription();
223 void deleteIncidence(); 220 void deleteIncidence();
224 void cloneIncidence(); 221 void cloneIncidence();
225 void moveIncidence(); 222 void moveIncidence();
226 void beamIncidence(); 223 void beamIncidence();
227 void toggleCancelIncidence(); 224 void toggleCancelIncidence();
228 225
229 /** create an editeventwin with supplied date/time, and if bool is true, 226 /** create an editeventwin with supplied date/time, and if bool is true,
230 * make the event take all day. */ 227 * make the event take all day. */
231 void newEvent(QDateTime, QDateTime, bool allDay ); 228 void newEvent(QDateTime, QDateTime, bool allDay );
232 void newEvent(QDateTime, QDateTime); 229 void newEvent(QDateTime, QDateTime);
233 void newEvent(QDateTime fh); 230 void newEvent(QDateTime fh);
234 void newEvent(QDate dt); 231 void newEvent(QDate dt);
235 /** create new event without having a date hint. Takes current date as 232 /** create new event without having a date hint. Takes current date as
236 default hint. */ 233 default hint. */
237 void newEvent(); 234 void newEvent();
238 void newFloatingEvent(); 235 void newFloatingEvent();
239 236
240 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ 237 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/
241 void showIncidence(Incidence *); 238 void showIncidence(Incidence *);
242 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ 239 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/
243 void editIncidence(Incidence *); 240 void editIncidence(Incidence *);
244 /** Delete the supplied incidence. It calls the correct deleteXXX method*/ 241 /** Delete the supplied incidence. It calls the correct deleteXXX method*/
245 void deleteIncidence(Incidence *); 242 void deleteIncidence(Incidence *);
246 void cloneIncidence(Incidence *); 243 void cloneIncidence(Incidence *);
247 void cancelIncidence(Incidence *); 244 void cancelIncidence(Incidence *);
248 /** Create an editor for the supplied event. */ 245 /** Create an editor for the supplied event. */
249 void editEvent(Event *); 246 void editEvent(Event *);
250 /** Delete the supplied event. */ 247 /** Delete the supplied event. */
251 void deleteEvent(Event *); 248 void deleteEvent(Event *);
252 /** Delete the event with the given unique ID. Returns false, if event wasn't 249 /** Delete the event with the given unique ID. Returns false, if event wasn't
253 found. */ 250 found. */
254 bool deleteEvent(const QString &uid); 251 bool deleteEvent(const QString &uid);
255 /** Create a read-only viewer dialog for the supplied event. */ 252 /** Create a read-only viewer dialog for the supplied event. */
256 void showEvent(Event *); 253 void showEvent(Event *);
257 254
258 void editJournal(Journal *); 255 void editJournal(Journal *);
259 void showJournal(Journal *); 256 void showJournal(Journal *);
260 void deleteJournal(Journal *); 257 void deleteJournal(Journal *);
261 /** Create an editor dialog for a todo */ 258 /** Create an editor dialog for a todo */
262 void editTodo(Todo *); 259 void editTodo(Todo *);
263 /** Create a read-only viewer dialog for the supplied todo */ 260 /** Create a read-only viewer dialog for the supplied todo */
264 void showTodo(Todo *); 261 void showTodo(Todo *);
265 /** create new todo */ 262 /** create new todo */
266 void newTodo(); 263 void newTodo();
267 void newTodoDateTime(QDateTime, bool allday); 264 void newTodoDateTime(QDateTime, bool allday);
268 /** create new todo with a parent todo */ 265 /** create new todo with a parent todo */
269 void newSubTodo(); 266 void newSubTodo();
270 /** create new todo with a parent todo */ 267 /** create new todo with a parent todo */
271 void newSubTodo(Todo *); 268 void newSubTodo(Todo *);
272 /** Delete todo */ 269 /** Delete todo */
273 void deleteTodo(Todo *); 270 void deleteTodo(Todo *);
274 271
275 272
276 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is 273 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is
277 * emitted as result. */ 274 * emitted as result. */
278 void checkClipboard(); 275 void checkClipboard();
279 276
280 /** using the KConfig associated with the kapp variable, read in the 277 /** using the KConfig associated with the kapp variable, read in the
281 * settings from the config file. 278 * settings from the config file.
282 */ 279 */
283 void readSettings(); 280 void readSettings();
284 281
285 /** write current state to config file. */ 282 /** write current state to config file. */
286 void writeSettings(); 283 void writeSettings();
287 284
288 /** read settings for calendar filters */ 285 /** read settings for calendar filters */
289 void readFilterSettings(KConfig *config); 286 void readFilterSettings(KConfig *config);
290 287
291 /** write settings for calendar filters */ 288 /** write settings for calendar filters */
292 void writeFilterSettings(KConfig *config); 289 void writeFilterSettings(KConfig *config);
293 290
294 /** passes on the message that an event has changed to the currently 291 /** passes on the message that an event has changed to the currently
295 * activated view so that it can make appropriate display changes. */ 292 * activated view so that it can make appropriate display changes. */
296 void changeEventDisplay(Event *, int); 293 void changeEventDisplay(Event *, int);
297 void changeIncidenceDisplay(Incidence *, int); 294 void changeIncidenceDisplay(Incidence *, int);
298 void changeTodoDisplay(Todo *, int); 295 void changeTodoDisplay(Todo *, int);
299 296
300 void eventAdded(Event *); 297 void eventAdded(Event *);
301 void eventChanged(Event *); 298 void eventChanged(Event *);
302 void eventToBeDeleted(Event *); 299 void eventToBeDeleted(Event *);
303 void eventDeleted(); 300 void eventDeleted();
304 301
305 void todoAdded(Todo *); 302 void todoAdded(Todo *);
306 void todoChanged(Todo *); 303 void todoChanged(Todo *);
307 void todoToBeDeleted(Todo *); 304 void todoToBeDeleted(Todo *);
308 void todoDeleted(); 305 void todoDeleted();
309 306
310 void updateView(const QDate &start, const QDate &end); 307 void updateView(const QDate &start, const QDate &end);
311 void updateView(); 308 void updateView();
312 309
313 /** Full update of visible todo views */ 310 /** Full update of visible todo views */
314 void updateTodoViews(); 311 void updateTodoViews();
315 312
316 void updateUnmanagedViews(); 313 void updateUnmanagedViews();
317 314
318 /** cut the current appointment to the clipboard */ 315 /** cut the current appointment to the clipboard */
319 void edit_cut(); 316 void edit_cut();
320 317
321 /** copy the current appointment(s) to the clipboard */ 318 /** copy the current appointment(s) to the clipboard */
322 void edit_copy(); 319 void edit_copy();
323 320
324 /** paste the current vobject(s) in the clipboard buffer into calendar */ 321 /** paste the current vobject(s) in the clipboard buffer into calendar */
325 void edit_paste(); 322 void edit_paste();
326 323
327 /** edit viewing and configuration options. */ 324 /** edit viewing and configuration options. */
328 void edit_options(); 325 void edit_options();
329 /** 326 /**
330 Functions for printing, previewing a print, and setting up printing 327 Functions for printing, previewing a print, and setting up printing
331 parameters. 328 parameters.
332 */ 329 */
333 void print(); 330 void print();
334 void printSetup(); 331 void printSetup();
335 void printPreview(); 332 void printPreview();
336 333
337 /** Export as iCalendar file */ 334 /** Export as iCalendar file */
338 void exportICalendar(); 335 void exportICalendar();
339 336
340 /** Export as vCalendar file */ 337 /** Export as vCalendar file */
341 bool exportVCalendar( QString fn); 338 bool exportVCalendar( QString fn);
342 339
343 /** pop up a dialog to show an existing appointment. */ 340 /** pop up a dialog to show an existing appointment. */
344 void appointment_show(); 341 void appointment_show();
345 /** 342 /**
346 * pop up an Appointment Dialog to edit an existing appointment.Get 343 * pop up an Appointment Dialog to edit an existing appointment.Get
347 * information on the appointment from the list of unique IDs that is 344 * information on the appointment from the list of unique IDs that is
348 * currently in the View, called currIds. 345 * currently in the View, called currIds.
349 */ 346 */
350 void appointment_edit(); 347 void appointment_edit();
351 /** 348 /**
352 * pop up dialog confirming deletion of currently selected event in the 349 * pop up dialog confirming deletion of currently selected event in the
353 * View. 350 * View.
354 */ 351 */
355 void appointment_delete(); 352 void appointment_delete();
356 353
357 /** mails the currently selected event to a particular user as a vCalendar 354 /** mails the currently selected event to a particular user as a vCalendar
358 attachment. */ 355 attachment. */
359 void action_mail(); 356 void action_mail();
360 357
361 /* frees a subtodo from it's relation */ 358 /* frees a subtodo from it's relation */
362 void todo_unsub( Todo * ); 359 void todo_unsub( Todo * );
363 void todo_resub( Todo * parent, Todo * sub ); 360 void todo_resub( Todo * parent, Todo * sub );
364 361
365 /** Take ownership of selected event. */ 362 /** Take ownership of selected event. */
366 void takeOverEvent(); 363 void takeOverEvent();
367 364
368 /** Take ownership of all events in calendar. */ 365 /** Take ownership of all events in calendar. */
369 void takeOverCalendar(); 366 void takeOverCalendar();
370 367
371 /** query whether or not the calendar is "dirty". */ 368 /** query whether or not the calendar is "dirty". */
372 bool isModified(); 369 bool isModified();
373 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ 370 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */
374 void setModified(bool modified=true); 371 void setModified(bool modified=true);
375 372
376 /** query if the calendar is read-only. */ 373 /** query if the calendar is read-only. */
377 bool isReadOnly(); 374 bool isReadOnly();
378 /** set state of calendar to read-only */ 375 /** set state of calendar to read-only */
379 void setReadOnly(bool readOnly=true); 376 void setReadOnly(bool readOnly=true);
380 377
381 void eventUpdated(Incidence *); 378 void eventUpdated(Incidence *);
382 379
383 /* iTIP scheduling actions */ 380 /* iTIP scheduling actions */
384 void schedule_publish(Incidence *incidence = 0); 381 void schedule_publish(Incidence *incidence = 0);
385 void schedule_request(Incidence *incidence = 0); 382 void schedule_request(Incidence *incidence = 0);
386 void schedule_refresh(Incidence *incidence = 0); 383 void schedule_refresh(Incidence *incidence = 0);
387 void schedule_cancel(Incidence *incidence = 0); 384 void schedule_cancel(Incidence *incidence = 0);
388 void schedule_add(Incidence *incidence = 0); 385 void schedule_add(Incidence *incidence = 0);
389 void schedule_reply(Incidence *incidence = 0); 386 void schedule_reply(Incidence *incidence = 0);
390 void schedule_counter(Incidence *incidence = 0); 387 void schedule_counter(Incidence *incidence = 0);
391 void schedule_declinecounter(Incidence *incidence = 0); 388 void schedule_declinecounter(Incidence *incidence = 0);
392 void schedule_publish_freebusy(int daysToPublish = 30); 389 void schedule_publish_freebusy(int daysToPublish = 30);
393 390
394 void openAddressbook(); 391 void openAddressbook();
395 392
396 void editFilters(); 393 void editFilters();
397 void toggleFilerEnabled(); 394 void toggleFilerEnabled();
398 QPtrList<CalFilter> filters(); 395 QPtrList<CalFilter> filters();
399 void toggleFilter(); 396 void toggleFilter();
400 void showFilter(bool visible); 397 void showFilter(bool visible);
401 void updateFilter(); 398 void updateFilter();
402 void filterEdited(); 399 void filterEdited();
403 void selectFilter( int ); 400 void selectFilter( int );
404 KOFilterView *filterView(); 401 KOFilterView *filterView();
405 402
406 void showIntro(); 403 void showIntro();
407 404
408 /** Move the curdatepient view date to today */ 405 /** Move the curdatepient view date to today */
409 void goToday(); 406 void goToday();
410 407
411 /** Move to the next date(s) in the current view */ 408 /** Move to the next date(s) in the current view */
412 void goNext(); 409 void goNext();
413 410
414 /** Move to the previous date(s) in the current view */ 411 /** Move to the previous date(s) in the current view */
415 void goPrevious(); 412 void goPrevious();
416 /** Move to the next date(s) in the current view */ 413 /** Move to the next date(s) in the current view */
417 void goNextMonth(); 414 void goNextMonth();
418 415
419 /** Move to the previous date(s) in the current view */ 416 /** Move to the previous date(s) in the current view */
420 void goPreviousMonth(); 417 void goPreviousMonth();
421 418
422 void toggleExpand(); 419 void toggleExpand();
423 void toggleDateNavigatorWidget(); 420 void toggleDateNavigatorWidget();
424 void toggleAllDaySize(); 421 void toggleAllDaySize();
425 void dialogClosing(Incidence *); 422 void dialogClosing(Incidence *);
426 423
427 /** Look for new messages in the inbox */ 424 /** Look for new messages in the inbox */
428 void lookForIncomingMessages(); 425 void lookForIncomingMessages();
429 /** Look for new messages in the outbox */ 426 /** Look for new messages in the outbox */
430 void lookForOutgoingMessages(); 427 void lookForOutgoingMessages();
431 428
432 void processMainViewSelection( Incidence * ); 429 void processMainViewSelection( Incidence * );
433 void processTodoListSelection( Incidence * ); 430 void processTodoListSelection( Incidence * );
434 431
435 void processIncidenceSelection( Incidence * ); 432 void processIncidenceSelection( Incidence * );
436 433
437 void purgeCompleted(); 434 void purgeCompleted();
438 bool removeCompletedSubTodos( Todo* ); 435 bool removeCompletedSubTodos( Todo* );
439 void slotCalendarChanged(); 436 void slotCalendarChanged();
440 bool importBday(); 437 bool importBday();
441 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); 438 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday );
442 bool importQtopia( const QString &categoriesFile, 439 bool importQtopia( const QString &categoriesFile,
443 const QString &datebookFile, 440 const QString &datebookFile,
444 const QString &tasklistFile ); 441 const QString &tasklistFile );
445 void syncExternal( int mode ); 442 void syncExternal( int mode );
446 void slotSelectPickerDate( QDate ) ; 443 void slotSelectPickerDate( QDate ) ;
447 void showDatePicker( ) ; 444 void showDatePicker( ) ;
448 void moveIncidence(Incidence *) ; 445 void moveIncidence(Incidence *) ;
449 void beamIncidence(Incidence *) ; 446 void beamIncidence(Incidence *) ;
450 void beamCalendar() ; 447 void beamCalendar() ;
451 void beamFilteredCalendar() ; 448 void beamFilteredCalendar() ;
452 void beamIncidenceList(QPtrList<Incidence>) ; 449 void beamIncidenceList(QPtrList<Incidence>) ;
453 void manageCategories(); 450 void manageCategories();
454 int addCategories(); 451 int addCategories();
455 void removeCategories(); 452 void removeCategories();
456 void setSyncDevice( QString ); 453 void setSyncDevice( QString );
457 void setSyncName( QString ); 454 void setSyncName( QString );
458 void showDay( QDate ); 455 void showDay( QDate );
459 void undo_delete(); 456 void undo_delete();
460 protected slots: 457 protected slots:
461 void timerAlarm(); 458 void timerAlarm();
462 void suspendAlarm(); 459 void suspendAlarm();
463 void beamDone( Ir *ir ); 460 void beamDone( Ir *ir );
464 /** Select a view or adapt the current view to display the specified dates. */ 461 /** Select a view or adapt the current view to display the specified dates. */
465 void showDates( const KCal::DateList & ); 462 void showDates( const KCal::DateList & );
466 void selectWeekNum ( int ); 463 void selectWeekNum ( int );
467 464
468 public: 465 public:
469 // show a standard warning 466 // show a standard warning
470 // returns KMsgBox::yesNoCancel() 467 // returns KMsgBox::yesNoCancel()
471 int msgCalModified(); 468 int msgCalModified();
472 virtual bool sync(KSyncManager* manager, QString filename, int mode); 469 virtual bool sync(KSyncManager* manager, QString filename, int mode);
473 470
474 virtual bool syncExternal(KSyncManager* manager, QString resource); 471 virtual bool syncExternal(KSyncManager* manager, QString resource);
475 virtual void removeSyncInfo( QString syncProfile); 472 virtual void removeSyncInfo( QString syncProfile);
476 void setSyncManager(KSyncManager* manager); 473 void setSyncManager(KSyncManager* manager);
477 void setLoadedFileVersion(QDateTime); 474 void setLoadedFileVersion(QDateTime);
478 bool checkFileVersion(QString fn); 475 bool checkFileVersion(QString fn);
479 bool checkFileChanged(QString fn); 476 bool checkFileChanged(QString fn);
480 Event* getLastSyncEvent(); 477 Event* getLastSyncEvent();
481 /** Adapt navigation units correpsonding to step size of navigation of the 478 /** Adapt navigation units correpsonding to step size of navigation of the
482 * current view. 479 * current view.
483 */ 480 */
484 void adaptNavigationUnits(); 481 void adaptNavigationUnits();
485 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); 482 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode );
486 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); 483 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false );
487 //Attendee* getYourAttendee(Event *event); 484 //Attendee* getYourAttendee(Event *event);
488 void setBlockShowDates( bool b ) { mBlockShowDates = b ;} 485 void setBlockShowDates( bool b ) { mBlockShowDates = b ;}
489 protected: 486 protected:
490 void schedule(Scheduler::Method, Incidence *incidence = 0); 487 void schedule(Scheduler::Method, Incidence *incidence = 0);
491 488
492 // returns KMsgBox::OKCandel() 489 // returns KMsgBox::OKCandel()
493 int msgItemDelete(const QString name); 490 int msgItemDelete(const QString name);
494 void showEventEditor(); 491 void showEventEditor();
495 void showTodoEditor(); 492 void showTodoEditor();
496 void writeLocale(); 493 void writeLocale();
497 Todo *selectedTodo(); 494 Todo *selectedTodo();
498 495
499 private: 496 private:
500 bool mBlockShowDates; 497 bool mBlockShowDates;
501 KSyncManager* mSyncManager; 498 KSyncManager* mSyncManager;
502 AlarmDialog * mAlarmDialog; 499 AlarmDialog * mAlarmDialog;
503 QString mAlarmNotification; 500 QString mAlarmNotification;
504 QString mSuspendAlarmNotification; 501 QString mSuspendAlarmNotification;
505 QTimer* mSuspendTimer; 502 QTimer* mSuspendTimer;
506 QTimer* mAlarmTimer; 503 QTimer* mAlarmTimer;
507 QTimer* mRecheckAlarmTimer; 504 QTimer* mRecheckAlarmTimer;
508 void computeAlarm( QString ); 505 void computeAlarm( QString );
509 void startAlarm( QString, QString ); 506 void startAlarm( QString, QString );
510 void setSyncEventsReadOnly(); 507 void setSyncEventsReadOnly();
511 508
512 QDateTime loadedFileVersion; 509 QDateTime loadedFileVersion;
513 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); 510 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete );
514 void checkExternalId( Incidence * inc ); 511 void checkExternalId( Incidence * inc );
515 int mGlobalSyncMode; 512 int mGlobalSyncMode;
516 QString mCurrentSyncDevice; 513 QString mCurrentSyncDevice;
517 QString mCurrentSyncName; 514 QString mCurrentSyncName;
518 KOBeamPrefs* beamDialog; 515 KOBeamPrefs* beamDialog;
519 void init(); 516 void init();
520 int mDatePickerMode; 517 int mDatePickerMode;
521 bool mFlagEditDescription; 518 bool mFlagEditDescription;
522 QDateTime mLastCalendarSync; 519 QDateTime mLastCalendarSync;
523 void createPrinter(); 520 void createPrinter();
524 521
525 void calendarModified( bool, Calendar * ); 522 void calendarModified( bool, Calendar * );
526 523
527 CalPrinter *mCalPrinter; 524 CalPrinter *mCalPrinter;
528 525
529 QSplitter *mPanner; 526 QSplitter *mPanner;
530 QSplitter *mLeftSplitter; 527 QSplitter *mLeftSplitter;
531 QWidget *mLeftFrame; 528 QWidget *mLeftFrame;
532 QWidgetStack *mRightFrame; 529 QWidgetStack *mRightFrame;
533 530
534 KDatePicker* mDatePicker; 531 KDatePicker* mDatePicker;
535 QVBox* mDateFrame; 532 QVBox* mDateFrame;
536 NavigatorBar *mNavigatorBar;
537 533
538 KDateNavigator *mDateNavigator; // widget showing small month view. 534 KDateNavigator *mDateNavigator; // widget showing small month view.
539 535
540 KOFilterView *mFilterView; 536 KOFilterView *mFilterView;
541 537
542 ResourceView *mResourceView; 538 ResourceView *mResourceView;
543 539
544 // calendar object for this viewing instance 540 // calendar object for this viewing instance
545 Calendar *mCalendar; 541 Calendar *mCalendar;
546 542
547 CalendarResourceManager *mResourceManager; 543 CalendarResourceManager *mResourceManager;
548 544
549 FileStorage *mStorage; 545 FileStorage *mStorage;
550 546
551 DateNavigator *mNavigator; 547 DateNavigator *mNavigator;
552 548
553 KOViewManager *mViewManager; 549 KOViewManager *mViewManager;
554 KODialogManager *mDialogManager; 550 KODialogManager *mDialogManager;
555 551
556 // Calendar filters 552 // Calendar filters
557 QPtrList<CalFilter> mFilters; 553 QPtrList<CalFilter> mFilters;
558 554
559 // various housekeeping variables. 555 // various housekeeping variables.
560 bool mModified; // flag indicating if calendar is modified 556 bool mModified; // flag indicating if calendar is modified
561 bool mReadOnly; // flag indicating if calendar is read-only 557 bool mReadOnly; // flag indicating if calendar is read-only
562 QDate mSaveSingleDate; 558 QDate mSaveSingleDate;
563 559
564 Incidence *mSelectedIncidence; 560 Incidence *mSelectedIncidence;
565 Incidence *mMoveIncidence; 561 Incidence *mMoveIncidence;
566 QDate mMoveIncidenceOldDate; 562 QDate mMoveIncidenceOldDate;
567 KOTodoView *mTodoList; 563 KOTodoView *mTodoList;
568 KOEventEditor * mEventEditor; 564 KOEventEditor * mEventEditor;
569 KOTodoEditor * mTodoEditor; 565 KOTodoEditor * mTodoEditor;
570 KOEventViewerDialog * mEventViewerDialog; 566 KOEventViewerDialog * mEventViewerDialog;
571 void keyPressEvent ( QKeyEvent *e) ; 567 void keyPressEvent ( QKeyEvent *e) ;
572 //QMap<Incidence*,KOIncidenceEditor*> mDialogList; 568 //QMap<Incidence*,KOIncidenceEditor*> mDialogList;
573}; 569};
574 570
575 571
576class CalendarViewVisitor : public Incidence::Visitor 572class CalendarViewVisitor : public Incidence::Visitor
577{ 573{
578 public: 574 public:
579 CalendarViewVisitor() : mView( 0 ) {} 575 CalendarViewVisitor() : mView( 0 ) {}
580 576
581 bool act( Incidence *incidence, CalendarView *view ) 577 bool act( Incidence *incidence, CalendarView *view )
582 { 578 {
583 mView = view; 579 mView = view;
584 return incidence->accept( *this ); 580 return incidence->accept( *this );
585 } 581 }
586 582
587 protected: 583 protected:
588 CalendarView *mView; 584 CalendarView *mView;
589}; 585};
590 586
591class ShowIncidenceVisitor : public CalendarViewVisitor 587class ShowIncidenceVisitor : public CalendarViewVisitor
592{ 588{
593 protected: 589 protected:
594 bool visit( Event *event ) { mView->showEvent( event ); return true; } 590 bool visit( Event *event ) { mView->showEvent( event ); return true; }
595 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } 591 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; }
596 bool visit( Journal * j ) { mView->showJournal( j );return true; } 592 bool visit( Journal * j ) { mView->showJournal( j );return true; }
597}; 593};
598 594
599class EditIncidenceVisitor : public CalendarViewVisitor 595class EditIncidenceVisitor : public CalendarViewVisitor
600{ 596{
601 protected: 597 protected:
602 bool visit( Event *event ) { mView->editEvent( event ); return true; } 598 bool visit( Event *event ) { mView->editEvent( event ); return true; }
603 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } 599 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; }
604 bool visit( Journal *j ) { mView->editJournal( j); return true; } 600 bool visit( Journal *j ) { mView->editJournal( j); return true; }
605}; 601};
606 602
607class DeleteIncidenceVisitor : public CalendarViewVisitor 603class DeleteIncidenceVisitor : public CalendarViewVisitor
608{ 604{
609 protected: 605 protected:
610 bool visit( Event *event ) { mView->deleteEvent( event ); return true; } 606 bool visit( Event *event ) { mView->deleteEvent( event ); return true; }
611 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } 607 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; }
612 bool visit( Journal * j) {mView->deleteJournal( j ); return true; } 608 bool visit( Journal * j) {mView->deleteJournal( j ); return true; }
613}; 609};
614 610
615#endif 611#endif
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 234375b..7ba0b2f 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -1,1596 +1,1597 @@
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 <qwidgetstack.h> 26#include <qwidgetstack.h>
27#include <qpushbutton.h> 27#include <qpushbutton.h>
28#include <qtooltip.h> 28#include <qtooltip.h>
29#include <qpainter.h> 29#include <qpainter.h>
30#include <qwhatsthis.h> 30#include <qwhatsthis.h>
31#ifndef DESKTOP_VERSION 31#ifndef DESKTOP_VERSION
32#include <qpe/qpeapplication.h> 32#include <qpe/qpeapplication.h>
33#else 33#else
34#include <qapplication.h> 34#include <qapplication.h>
35#endif 35#endif
36 36
37#include <kdebug.h> 37#include <kdebug.h>
38#include <klocale.h> 38#include <klocale.h>
39#include <kglobal.h> 39#include <kglobal.h>
40#include <kconfig.h> 40#include <kconfig.h>
41#include <kiconloader.h> 41#include <kiconloader.h>
42 42
43#include <kcalendarsystem.h> 43#include <kcalendarsystem.h>
44 44
45#ifndef KORG_NOPRINTER 45#ifndef KORG_NOPRINTER
46#include "calprinter.h" 46#include "calprinter.h"
47#endif 47#endif
48#include "koprefs.h" 48#include "koprefs.h"
49#ifndef KORG_NOPLUGINS 49#ifndef KORG_NOPLUGINS
50#include "kocore.h" 50#include "kocore.h"
51#endif 51#endif
52#include "koglobals.h" 52#include "koglobals.h"
53#include <libkcal/kincidenceformatter.h> 53#include <libkcal/kincidenceformatter.h>
54 54
55#include "komonthview.h" 55#include "komonthview.h"
56 56
57#define PIXMAP_SIZE 5 57#define PIXMAP_SIZE 5
58#ifdef DESKTOP_VERSION 58#ifdef DESKTOP_VERSION
59QToolTipGroup *MonthViewCell::mToolTipGroup = 0; 59QToolTipGroup *MonthViewCell::mToolTipGroup = 0;
60#endif 60#endif
61class KNOWhatsThis :public QWhatsThis 61class KNOWhatsThis :public QWhatsThis
62{ 62{
63public: 63public:
64 KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; 64 KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { };
65 //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; 65 //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); };
66 66
67protected: 67protected:
68 virtual QString text( const QPoint& p) 68 virtual QString text( const QPoint& p)
69 { 69 {
70 return _wid->getWhatsThisText(p) ; 70 return _wid->getWhatsThisText(p) ;
71 }; 71 };
72private: 72private:
73 KNoScrollListBox* _wid; 73 KNoScrollListBox* _wid;
74 74
75}; 75};
76 76
77 77
78KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) 78KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name)
79 : QListBox(parent, name, WRepaintNoErase) 79 : QListBox(parent, name, WRepaintNoErase)
80{ 80{
81#ifndef DESKTOP_VERSION 81#ifndef DESKTOP_VERSION
82 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 82 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
83#endif 83#endif
84 mWT = new KNOWhatsThis(this); 84 mWT = new KNOWhatsThis(this);
85} 85}
86KNoScrollListBox::~KNoScrollListBox() 86KNoScrollListBox::~KNoScrollListBox()
87{ 87{
88 88
89} 89}
90QString KNoScrollListBox::getWhatsThisText(QPoint p) 90QString KNoScrollListBox::getWhatsThisText(QPoint p)
91{ 91{
92 QListBoxItem* item = itemAt ( p ); 92 QListBoxItem* item = itemAt ( p );
93 if ( ! item ) { 93 if ( ! item ) {
94 return i18n("Click in the cell\nto add an event!"); 94 return i18n("Click in the cell\nto add an event!");
95 } 95 }
96 return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence()); 96 return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence());
97} 97}
98void KNoScrollListBox::keyPressEvent(QKeyEvent *e) 98void KNoScrollListBox::keyPressEvent(QKeyEvent *e)
99{ 99{
100 100
101 switch(e->key()) { 101 switch(e->key()) {
102 case Key_Right: 102 case Key_Right:
103 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 103 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
104 { 104 {
105 e->ignore(); 105 e->ignore();
106 return; 106 return;
107 } 107 }
108 scrollBy(10,0); 108 scrollBy(10,0);
109 break; 109 break;
110 case Key_Left: 110 case Key_Left:
111 if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 111 if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
112 { 112 {
113 e->ignore(); 113 e->ignore();
114 return; 114 return;
115 } 115 }
116 scrollBy(-10,0); 116 scrollBy(-10,0);
117 break; 117 break;
118 case Key_Up: 118 case Key_Up:
119 if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { 119 if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) {
120 e->ignore(); 120 e->ignore();
121 break; 121 break;
122 } 122 }
123 setCurrentItem((currentItem()+count()-1)%count()); 123 setCurrentItem((currentItem()+count()-1)%count());
124 if(!itemVisible(currentItem())) { 124 if(!itemVisible(currentItem())) {
125 if((unsigned int) currentItem() == (count()-1)) { 125 if((unsigned int) currentItem() == (count()-1)) {
126 setTopItem(currentItem()-numItemsVisible()+1); 126 setTopItem(currentItem()-numItemsVisible()+1);
127 } else { 127 } else {
128 setTopItem(topItem()-1); 128 setTopItem(topItem()-1);
129 } 129 }
130 } 130 }
131 break; 131 break;
132 case Key_Down: 132 case Key_Down:
133 if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { 133 if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) {
134 e->ignore(); 134 e->ignore();
135 break; 135 break;
136 } 136 }
137 setCurrentItem((currentItem()+1)%count()); 137 setCurrentItem((currentItem()+1)%count());
138 if(!itemVisible(currentItem())) { 138 if(!itemVisible(currentItem())) {
139 if(currentItem() == 0) { 139 if(currentItem() == 0) {
140 setTopItem(0); 140 setTopItem(0);
141 } else { 141 } else {
142 setTopItem(topItem()+1); 142 setTopItem(topItem()+1);
143 } 143 }
144 } 144 }
145 break; 145 break;
146 case Key_I: 146 case Key_I:
147 QTimer::singleShot( 11, this, SLOT ( oneDown() ) ); 147 QTimer::singleShot( 11, this, SLOT ( oneDown() ) );
148 e->ignore(); 148 e->ignore();
149 break; 149 break;
150 case Key_Shift: 150 case Key_Shift:
151 emit shiftDown(); 151 emit shiftDown();
152 break; 152 break;
153 default: 153 default:
154 e->ignore(); 154 e->ignore();
155 break; 155 break;
156 } 156 }
157} 157}
158 158
159void KNoScrollListBox::oneDown() 159void KNoScrollListBox::oneDown()
160{ 160{
161 setCurrentItem((currentItem()+1)%count()); 161 setCurrentItem((currentItem()+1)%count());
162 if(!itemVisible(currentItem())) { 162 if(!itemVisible(currentItem())) {
163 if(currentItem() == 0) { 163 if(currentItem() == 0) {
164 setTopItem(0); 164 setTopItem(0);
165 } else { 165 } else {
166 setTopItem(topItem()+1); 166 setTopItem(topItem()+1);
167 } 167 }
168 } 168 }
169} 169}
170void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) 170void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e)
171{ 171{
172 switch(e->key()) { 172 switch(e->key()) {
173 case Key_Shift: 173 case Key_Shift:
174 emit shiftUp(); 174 emit shiftUp();
175 break; 175 break;
176 default: 176 default:
177 break; 177 break;
178 } 178 }
179} 179}
180 180
181void KNoScrollListBox::mousePressEvent(QMouseEvent *e) 181void KNoScrollListBox::mousePressEvent(QMouseEvent *e)
182{ 182{
183 QListBox::mousePressEvent(e); 183 QListBox::mousePressEvent(e);
184 184
185 if(e->button() == RightButton) { 185 if(e->button() == RightButton) {
186 emit rightClick(); 186 emit rightClick();
187 } 187 }
188} 188}
189 189
190MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) 190MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s)
191 : QListBoxItem() 191 : QListBoxItem()
192{ 192{
193 setText( s ); 193 setText( s );
194 194
195 mIncidence = incidence; 195 mIncidence = incidence;
196 mDate = qd; 196 mDate = qd;
197 // QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence )); 197 // QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence ));
198 mRecur = false; 198 mRecur = false;
199 mAlarm = false; 199 mAlarm = false;
200 mReply = false; 200 mReply = false;
201 mInfo = false; 201 mInfo = false;
202} 202}
203 203
204void MonthViewItem::paint(QPainter *p) 204void MonthViewItem::paint(QPainter *p)
205{ 205{
206#if QT_VERSION >= 0x030000 206#if QT_VERSION >= 0x030000
207 bool sel = isSelected(); 207 bool sel = isSelected();
208#else 208#else
209 bool sel = selected(); 209 bool sel = selected();
210#endif 210#endif
211 211
212 212
213 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) 213 if (KOPrefs::instance()->mMonthViewUsesCategoryColor)
214 { 214 {
215 p->setBackgroundColor( palette().color( QPalette::Normal, \ 215 p->setBackgroundColor( palette().color( QPalette::Normal, \
216 sel ? QColorGroup::Highlight : QColorGroup::Background ) ); 216 sel ? QColorGroup::Highlight : QColorGroup::Background ) );
217 p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); 217 p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) );
218 } 218 }
219 int x = 1; 219 int x = 1;
220 int y = 3;//(height() - mRecurPixmap.height()) /2; 220 int y = 3;//(height() - mRecurPixmap.height()) /2;
221 int size = PIXMAP_SIZE; 221 int size = PIXMAP_SIZE;
222 if ( QApplication::desktop()->width() < 300 ) 222 if ( QApplication::desktop()->width() < 300 )
223 size = 3; 223 size = 3;
224 if ( KOPrefs::instance()->mMonthShowIcons ) { 224 if ( KOPrefs::instance()->mMonthShowIcons ) {
225 if ( mInfo ) { 225 if ( mInfo ) {
226 p->fillRect ( x, y,size,size, Qt::darkGreen ); 226 p->fillRect ( x, y,size,size, Qt::darkGreen );
227 x += size + 1; 227 x += size + 1;
228 } 228 }
229 if ( mRecur ) { 229 if ( mRecur ) {
230 p->fillRect ( x, y,size,size, Qt::blue ); 230 p->fillRect ( x, y,size,size, Qt::blue );
231 x += size + 1; 231 x += size + 1;
232 } 232 }
233 if ( mAlarm ) { 233 if ( mAlarm ) {
234 p->fillRect ( x, y,size,size, Qt::red ); 234 p->fillRect ( x, y,size,size, Qt::red );
235 x += size + 1; 235 x += size + 1;
236 } 236 }
237 if ( mReply ) { 237 if ( mReply ) {
238 p->fillRect ( x, y,size,size, Qt::yellow ); 238 p->fillRect ( x, y,size,size, Qt::yellow );
239 x += size + 1; 239 x += size + 1;
240 } 240 }
241 } 241 }
242 QFontMetrics fm = p->fontMetrics(); 242 QFontMetrics fm = p->fontMetrics();
243 int yPos; 243 int yPos;
244 int pmheight = size; 244 int pmheight = size;
245 if( pmheight < fm.height() ) 245 if( pmheight < fm.height() )
246 yPos = fm.ascent() + fm.leading()/2; 246 yPos = fm.ascent() + fm.leading()/2;
247 else 247 else
248 yPos = pmheight/2 - fm.height()/2 + fm.ascent(); 248 yPos = pmheight/2 - fm.height()/2 + fm.ascent();
249 p->setPen( palette().color( QPalette::Normal, sel ? \ 249 p->setPen( palette().color( QPalette::Normal, sel ? \
250 QColorGroup::HighlightedText : QColorGroup::Foreground ) ); 250 QColorGroup::HighlightedText : QColorGroup::Foreground ) );
251 p->drawText( x, yPos, text() ); 251 p->drawText( x, yPos, text() );
252 if ( mIncidence->cancelled() ) { 252 if ( mIncidence->cancelled() ) {
253 int wid = fm.width( text() ); 253 int wid = fm.width( text() );
254 p->drawLine( x, yPos- fm.height()/2+3,x+wid, yPos- fm.height()/2 +3); 254 p->drawLine( x, yPos- fm.height()/2+3,x+wid, yPos- fm.height()/2 +3);
255 } 255 }
256 256
257} 257}
258 258
259int MonthViewItem::height(const QListBox *lb) const 259int MonthViewItem::height(const QListBox *lb) const
260{ 260{
261 return lb->fontMetrics().lineSpacing()+1; 261 return lb->fontMetrics().lineSpacing()+1;
262} 262}
263 263
264int MonthViewItem::width(const QListBox *lb) const 264int MonthViewItem::width(const QListBox *lb) const
265{ 265{
266 int size = PIXMAP_SIZE; 266 int size = PIXMAP_SIZE;
267 if ( QApplication::desktop()->width() < 300 ) 267 if ( QApplication::desktop()->width() < 300 )
268 size = 3; 268 size = 3;
269 int x = 1; 269 int x = 1;
270 if ( mInfo ) { 270 if ( mInfo ) {
271 x += size + 1; 271 x += size + 1;
272 } 272 }
273 if( mRecur ) { 273 if( mRecur ) {
274 x += size+1; 274 x += size+1;
275 } 275 }
276 if( mAlarm ) { 276 if( mAlarm ) {
277 x += size+1; 277 x += size+1;
278 } 278 }
279 if( mReply ) { 279 if( mReply ) {
280 x += size+1; 280 x += size+1;
281 } 281 }
282 282
283 return( x + lb->fontMetrics().width( text() ) + 1 ); 283 return( x + lb->fontMetrics().width( text() ) + 1 );
284} 284}
285 285
286 286
287MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) 287MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par )
288 : QWidget( par ), 288 : QWidget( par ),
289 mMonthView( parent ) 289 mMonthView( parent )
290{ 290{
291 291
292 QVBoxLayout *topLayout = new QVBoxLayout( this ); 292 QVBoxLayout *topLayout = new QVBoxLayout( this );
293 293
294 // mLabel = new QLabel( this );QPushButton 294 // mLabel = new QLabel( this );QPushButton
295 mLabel = new QPushButton( this ); 295 mLabel = new QPushButton( this );
296 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); 296 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain );
297 //mLabel->setLineWidth( 1 ); 297 //mLabel->setLineWidth( 1 );
298 //mLabel->setAlignment( AlignCenter ); 298 //mLabel->setAlignment( AlignCenter );
299 mLabel->setFlat( true ); 299 mLabel->setFlat( true );
300 mLabel->setFocusPolicy(NoFocus); 300 mLabel->setFocusPolicy(NoFocus);
301 mItemList = new KNoScrollListBox( this ); 301 mItemList = new KNoScrollListBox( this );
302 mItemList->setMinimumSize( 10, 10 ); 302 mItemList->setMinimumSize( 10, 10 );
303 mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain ); 303 mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain );
304 mItemList->setLineWidth( 1 ); 304 mItemList->setLineWidth( 1 );
305 topLayout->addWidget( mItemList ); 305 topLayout->addWidget( mItemList );
306 mLabel->raise(); 306 mLabel->raise();
307 // QColor( 0,0,255 ) QColor( 160,1600,255 ) 307 // QColor( 0,0,255 ) QColor( 160,1600,255 )
308 mStandardPalette = palette(); 308 mStandardPalette = palette();
309 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); 309 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) );
310 310
311 enableScrollBars( false ); 311 enableScrollBars( false );
312 updateConfig(); 312 updateConfig();
313 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); 313 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() ));
314 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); 314 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() ));
315 connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ), 315 connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ),
316 SLOT( defaultAction( QListBoxItem * ) ) ); 316 SLOT( defaultAction( QListBoxItem * ) ) );
317 connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *, 317 connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *,
318 const QPoint &) ), 318 const QPoint &) ),
319 SLOT( contextMenu( QListBoxItem * ) ) ); 319 SLOT( contextMenu( QListBoxItem * ) ) );
320 connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ), 320 connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ),
321 SLOT( selection( QListBoxItem * ) ) ); 321 SLOT( selection( QListBoxItem * ) ) );
322 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), 322 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ),
323 SLOT( cellClicked( QListBoxItem * ) ) ); 323 SLOT( cellClicked( QListBoxItem * ) ) );
324 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), 324 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ),
325 SLOT( selection( QListBoxItem * ) ) ); 325 SLOT( selection( QListBoxItem * ) ) );
326} 326}
327#ifdef DESKTOP_VERSION 327#ifdef DESKTOP_VERSION
328QToolTipGroup *MonthViewCell::toolTipGroup() 328QToolTipGroup *MonthViewCell::toolTipGroup()
329{ 329{
330 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); 330 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0);
331 return mToolTipGroup; 331 return mToolTipGroup;
332} 332}
333#endif 333#endif
334 334
335void MonthViewCell::setDate( const QDate &date ) 335void MonthViewCell::setDate( const QDate &date )
336{ 336{
337 // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; 337 // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl;
338 mDate = date; 338 mDate = date;
339 339
340 340
341 341
342 //resizeEvent( 0 ); 342 //resizeEvent( 0 );
343} 343}
344 344
345QDate MonthViewCell::date() const 345QDate MonthViewCell::date() const
346{ 346{
347 return mDate; 347 return mDate;
348} 348}
349 349
350void MonthViewCell::setPrimary( bool primary ) 350void MonthViewCell::setPrimary( bool primary )
351{ 351{
352 mPrimary = primary; 352 mPrimary = primary;
353 //setMyPalette(); 353 //setMyPalette();
354} 354}
355void MonthViewCell::setMyPalette() 355void MonthViewCell::setMyPalette()
356{ 356{
357 357
358 if ( mHoliday) { 358 if ( mHoliday) {
359 setPalette( mHolidayPalette ); 359 setPalette( mHolidayPalette );
360 } else { 360 } else {
361 if ( mPrimary ) { 361 if ( mPrimary ) {
362 setPalette( mPrimaryPalette ); 362 setPalette( mPrimaryPalette );
363 } else { 363 } else {
364 setPalette( mNonPrimaryPalette ); 364 setPalette( mNonPrimaryPalette );
365 } 365 }
366 } 366 }
367 QPalette pal = palette(); 367 QPalette pal = palette();
368 368
369 mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); 369 mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) ));
370} 370}
371QPalette MonthViewCell::getPalette () 371QPalette MonthViewCell::getPalette ()
372{ 372{
373 if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) 373 if ( !KOPrefs::instance()->mMonthViewUsesDayColors )
374 return mStandardPalette; 374 return mStandardPalette;
375 if ( mHoliday) { 375 if ( mHoliday) {
376 return mHolidayPalette ; 376 return mHolidayPalette ;
377 } else { 377 } else {
378 if ( mPrimary ) { 378 if ( mPrimary ) {
379 return mPrimaryPalette ; 379 return mPrimaryPalette ;
380 } 380 }
381 } 381 }
382 return mNonPrimaryPalette; 382 return mNonPrimaryPalette;
383} 383}
384bool MonthViewCell::isPrimary() const 384bool MonthViewCell::isPrimary() const
385{ 385{
386 return mPrimary; 386 return mPrimary;
387} 387}
388 388
389void MonthViewCell::setHoliday( bool holiday ) 389void MonthViewCell::setHoliday( bool holiday )
390{ 390{
391 mHoliday = holiday; 391 mHoliday = holiday;
392 //setMyPalette(); 392 //setMyPalette();
393} 393}
394 394
395void MonthViewCell::setHoliday( const QString &holiday ) 395void MonthViewCell::setHoliday( const QString &holiday )
396{ 396{
397 mHolidayString = holiday; 397 mHolidayString = holiday;
398 398
399 if ( !holiday.isEmpty() ) { 399 if ( !holiday.isEmpty() ) {
400 setHoliday( true ); 400 setHoliday( true );
401 } 401 }
402} 402}
403void MonthViewCell::keyPressEvent ( QKeyEvent * e ) 403void MonthViewCell::keyPressEvent ( QKeyEvent * e )
404{ 404{
405 405
406 e->ignore(); 406 e->ignore();
407 407
408} 408}
409 409
410void MonthViewCell::startUpdateCell() 410void MonthViewCell::startUpdateCell()
411{ 411{
412 412
413 mItemList->setFocusPolicy(NoFocus); 413 mItemList->setFocusPolicy(NoFocus);
414 if ( !mMonthView->isUpdatePossible() ) 414 if ( !mMonthView->isUpdatePossible() )
415 return; 415 return;
416 416
417 /* 417 /*
418 if ( !isVisible() ){ 418 if ( !isVisible() ){
419 return; 419 return;
420 } 420 }
421 */ 421 */
422 // qDebug("MonthViewCell::updateCell() "); 422 // qDebug("MonthViewCell::updateCell() ");
423 setPrimary( mDate.month()%2 ); 423 setPrimary( mDate.month()%2 );
424 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); 424 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays);
425 if ( mDate == QDate::currentDate() ) { 425 if ( mDate == QDate::currentDate() ) {
426 mItemList->setLineWidth( 3 ); 426 mItemList->setLineWidth( 3 );
427 } else { 427 } else {
428 mItemList->setLineWidth( 1 ); 428 mItemList->setLineWidth( 1 );
429 } 429 }
430 mItemList->clear(); 430 mItemList->clear();
431 431
432#ifdef DESKTOP_VERSION 432#ifdef DESKTOP_VERSION
433 QToolTip::remove(this); 433 QToolTip::remove(this);
434#endif 434#endif
435 mToolTip = ""; 435 mToolTip = "";
436 //qApp->processEvents(); 436 //qApp->processEvents();
437 if ( !mHolidayString.isEmpty() ) { 437 if ( !mHolidayString.isEmpty() ) {
438 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); 438 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString );
439 item->setPalette( mHolidayPalette ); 439 item->setPalette( mHolidayPalette );
440 mItemList->insertItem( item ); 440 mItemList->insertItem( item );
441 mToolTip += mHolidayString+"\n"; 441 mToolTip += mHolidayString+"\n";
442 } 442 }
443} 443}
444 444
445void MonthViewCell::insertEvent(Event *event) 445void MonthViewCell::insertEvent(Event *event)
446{ 446{
447 447
448 mItemList->setFocusPolicy(WheelFocus); 448 mItemList->setFocusPolicy(WheelFocus);
449 if ( !(event->doesRecur() == Recurrence::rNone) ) { 449 if ( !(event->doesRecur() == Recurrence::rNone) ) {
450 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) 450 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily )
451 return; 451 return;
452 else 452 else
453 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) 453 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly )
454 return; 454 return;
455 } 455 }
456 456
457 if ( event->categories().contains("Holiday") || 457 if ( event->categories().contains("Holiday") ||
458 event->categories().contains(i18n("Holiday"))) { 458 event->categories().contains(i18n("Holiday"))) {
459 setHoliday( true ); 459 setHoliday( true );
460 if ( mDate.dayOfWeek() == 7 ) 460 if ( mDate.dayOfWeek() == 7 )
461 mItemList->setLineWidth( 3 ); 461 mItemList->setLineWidth( 3 );
462 } 462 }
463 QString text; 463 QString text;
464 if (event->isMultiDay()) { 464 if (event->isMultiDay()) {
465 QString prefix = "<->"; 465 QString prefix = "<->";
466 if ( event->doesRecur() ) { 466 if ( event->doesRecur() ) {
467 if ( event->recursOn( mDate) ) 467 if ( event->recursOn( mDate) )
468 prefix ="->" ; 468 prefix ="->" ;
469 else { 469 else {
470 int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); 470 int days = event->dtStart().date().daysTo ( event->dtEnd().date() );
471 if ( event->recursOn( mDate.addDays( -days)) ) 471 if ( event->recursOn( mDate.addDays( -days)) )
472 prefix ="<-" ; 472 prefix ="<-" ;
473 } 473 }
474 474
475 } else { 475 } else {
476 if (mDate == event->dtStart().date()) { 476 if (mDate == event->dtStart().date()) {
477 prefix ="->" ; 477 prefix ="->" ;
478 } else if (mDate == event->dtEnd().date()) { 478 } else if (mDate == event->dtEnd().date()) {
479 prefix ="<-" ; 479 prefix ="<-" ;
480 } 480 }
481 } 481 }
482 if ( !event->doesFloat() ) { 482 if ( !event->doesFloat() ) {
483 if ( mDate == event->dtStart().date () ) 483 if ( mDate == event->dtStart().date () )
484 prefix += KGlobal::locale()->formatTime(event->dtStart().time())+" "; 484 prefix += KGlobal::locale()->formatTime(event->dtStart().time())+" ";
485 else if ( mDate == event->dtEnd().date () ) 485 else if ( mDate == event->dtEnd().date () )
486 prefix += KGlobal::locale()->formatTime(event->dtEnd().time())+" "; 486 prefix += KGlobal::locale()->formatTime(event->dtEnd().time())+" ";
487 487
488 } 488 }
489 text = prefix + event->summary(); 489 text = prefix + event->summary();
490 mToolTip += text; 490 mToolTip += text;
491 } else { 491 } else {
492 if (event->doesFloat()) { 492 if (event->doesFloat()) {
493 text = event->summary(); 493 text = event->summary();
494 mToolTip += text; 494 mToolTip += text;
495 } 495 }
496 else { 496 else {
497 text = KGlobal::locale()->formatTime(event->dtStart().time()); 497 text = KGlobal::locale()->formatTime(event->dtStart().time());
498 text += " " + event->summary(); 498 text += " " + event->summary();
499 mToolTip += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); 499 mToolTip += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary();
500 } 500 }
501 } 501 }
502 502
503 MonthViewItem *item = new MonthViewItem( event, mDate, text ); 503 MonthViewItem *item = new MonthViewItem( event, mDate, text );
504 QPalette pal; 504 QPalette pal;
505 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 505 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
506 QStringList categories = event->categories(); 506 QStringList categories = event->categories();
507 QString cat = categories.first(); 507 QString cat = categories.first();
508 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 508 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
509 pal = getPalette(); 509 pal = getPalette();
510 if (cat.isEmpty()) { 510 if (cat.isEmpty()) {
511 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 511 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
512 } else { 512 } else {
513 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 513 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
514 } 514 }
515 515
516 } else { 516 } else {
517 if (cat.isEmpty()) { 517 if (cat.isEmpty()) {
518 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 518 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
519 } else { 519 } else {
520 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 520 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
521 } 521 }
522 } 522 }
523 523
524 } else { 524 } else {
525 pal = mStandardPalette ; 525 pal = mStandardPalette ;
526 } 526 }
527 item->setPalette( pal ); 527 item->setPalette( pal );
528 item->setRecur( event->recurrence()->doesRecur() ); 528 item->setRecur( event->recurrence()->doesRecur() );
529 item->setAlarm( event->isAlarmEnabled() ); 529 item->setAlarm( event->isAlarmEnabled() );
530 item->setMoreInfo( event->description().length() > 0 ); 530 item->setMoreInfo( event->description().length() > 0 );
531#ifdef DESKTOP_VERSION 531#ifdef DESKTOP_VERSION
532 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, 532 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails,
533 KOPrefs::instance()->email()); 533 KOPrefs::instance()->email());
534 if ( me != 0 ) { 534 if ( me != 0 ) {
535 if ( me->status() == Attendee::NeedsAction && me->RSVP()) 535 if ( me->status() == Attendee::NeedsAction && me->RSVP())
536 item->setReply(true); 536 item->setReply(true);
537 else 537 else
538 item->setReply(false); 538 item->setReply(false);
539 } else 539 } else
540 item->setReply(false); 540 item->setReply(false);
541#endif 541#endif
542 mItemList->insertItem( item ); 542 mItemList->insertItem( item );
543 mToolTip += "\n"; 543 mToolTip += "\n";
544} 544}
545void MonthViewCell::insertTodo(Todo *todo) 545void MonthViewCell::insertTodo(Todo *todo)
546{ 546{
547 mItemList->setFocusPolicy(WheelFocus); 547 mItemList->setFocusPolicy(WheelFocus);
548 QString text; 548 QString text;
549 if (todo->hasDueDate()) { 549 if (todo->hasDueDate()) {
550 if (!todo->doesFloat()) { 550 if (!todo->doesFloat()) {
551 text += KGlobal::locale()->formatTime(todo->dtDue().time()); 551 text += KGlobal::locale()->formatTime(todo->dtDue().time());
552 text += " "; 552 text += " ";
553 } 553 }
554 } 554 }
555 text += i18n("Td: %1").arg(todo->summary()); 555 text += i18n("Td: %1").arg(todo->summary());
556 556
557 MonthViewItem *item = new MonthViewItem( todo, mDate, text ); 557 MonthViewItem *item = new MonthViewItem( todo, mDate, text );
558 //item->setPalette( mStandardPalette ); 558 //item->setPalette( mStandardPalette );
559 QPalette pal; 559 QPalette pal;
560 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 560 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
561 QStringList categories = todo->categories(); 561 QStringList categories = todo->categories();
562 QString cat = categories.first(); 562 QString cat = categories.first();
563 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 563 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
564 pal = getPalette(); 564 pal = getPalette();
565 if (cat.isEmpty()) { 565 if (cat.isEmpty()) {
566 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 566 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
567 } else { 567 } else {
568 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 568 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
569 } 569 }
570 570
571 } else { 571 } else {
572 if (cat.isEmpty()) { 572 if (cat.isEmpty()) {
573 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 573 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
574 } else { 574 } else {
575 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 575 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
576 } 576 }
577 } 577 }
578 578
579 } else { 579 } else {
580 pal = mStandardPalette ; 580 pal = mStandardPalette ;
581 } 581 }
582 item->setPalette( pal ); 582 item->setPalette( pal );
583 mItemList->insertItem( item ); 583 mItemList->insertItem( item );
584 mToolTip += text+"\n"; 584 mToolTip += text+"\n";
585} 585}
586void MonthViewCell::finishUpdateCell() 586void MonthViewCell::finishUpdateCell()
587{ 587{
588#ifdef DESKTOP_VERSION 588#ifdef DESKTOP_VERSION
589 if (mToolTip != "") 589 if (mToolTip != "")
590 QToolTip::add(this,mToolTip,toolTipGroup(),""); 590 QToolTip::add(this,mToolTip,toolTipGroup(),"");
591#endif 591#endif
592 mItemList->sort(); 592 mItemList->sort();
593 //setMyPalette(); 593 //setMyPalette();
594 setMyPalette(); 594 setMyPalette();
595 QString text; 595 QString text;
596 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; 596 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog;
597 if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { 597 if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) {
598 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; 598 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " ";
599 mLabel->resize( mLabelBigSize ); 599 mLabel->resize( mLabelBigSize );
600 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 600 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
601 } else { 601 } else {
602 mLabel->resize( mLabelSize ); 602 mLabel->resize( mLabelSize );
603 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 603 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
604 } 604 }
605 605
606 mLabel->setText( text ); 606 mLabel->setText( text );
607 resizeEvent( 0 ); 607 resizeEvent( 0 );
608} 608}
609void MonthViewCell::updateCell() 609void MonthViewCell::updateCell()
610{ 610{
611 qDebug("MonthViewCell::updateCell() "); 611 qDebug("MonthViewCell::updateCell() ");
612 if ( !mMonthView->isUpdatePossible() ) 612 if ( !mMonthView->isUpdatePossible() )
613 return; 613 return;
614 startUpdateCell(); 614 startUpdateCell();
615 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 615 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
616 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); 616 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true );
617 Event *event; 617 Event *event;
618 for( event = events.first(); event; event = events.next() ) { // for event 618 for( event = events.first(); event; event = events.next() ) { // for event
619 insertEvent(event); 619 insertEvent(event);
620 } 620 }
621 // insert due todos 621 // insert due todos
622 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); 622 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate );
623 Todo *todo; 623 Todo *todo;
624 for(todo = todos.first(); todo; todo = todos.next()) { 624 for(todo = todos.first(); todo; todo = todos.next()) {
625 insertTodo( todo ); 625 insertTodo( todo );
626 } 626 }
627 finishUpdateCell(); 627 finishUpdateCell();
628 // if ( isVisible()) 628 // if ( isVisible())
629 //qApp->processEvents(); 629 //qApp->processEvents();
630} 630}
631 631
632void MonthViewCell::updateConfig( bool bigFont ) // = false 632void MonthViewCell::updateConfig( bool bigFont ) // = false
633{ 633{
634 634
635 if ( bigFont ) { 635 if ( bigFont ) {
636 QFont fo = KOPrefs::instance()->mMonthViewFont; 636 QFont fo = KOPrefs::instance()->mMonthViewFont;
637 int ps = fo.pointSize() + 2; 637 int ps = fo.pointSize() + 2;
638 if ( ps < 18 ) 638 if ( ps < 18 )
639 ps += 2; 639 ps += 2;
640 fo.setPointSize( ps ); 640 fo.setPointSize( ps );
641 setFont( fo ); 641 setFont( fo );
642 } else 642 } else
643 setFont( KOPrefs::instance()->mMonthViewFont ); 643 setFont( KOPrefs::instance()->mMonthViewFont );
644 644
645 QFontMetrics fm( font() ); 645 QFontMetrics fm( font() );
646 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); 646 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 );
647 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); 647 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 );
648 mHolidayPalette = mStandardPalette; 648 mHolidayPalette = mStandardPalette;
649 mPrimaryPalette = mStandardPalette; 649 mPrimaryPalette = mStandardPalette;
650 mNonPrimaryPalette = mStandardPalette; 650 mNonPrimaryPalette = mStandardPalette;
651 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { 651 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) {
652 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); 652 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor );
653 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); 653 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor );
654 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); 654 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark());
655 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); 655 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark());
656 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); 656 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor);
657 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); 657 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor);
658 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); 658 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark());
659 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); 659 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor);
660 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); 660 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor);
661 } 661 }
662 //updateCell(); 662 //updateCell();
663} 663}
664 664
665void MonthViewCell::enableScrollBars( bool enabled ) 665void MonthViewCell::enableScrollBars( bool enabled )
666{ 666{
667 if ( enabled ) { 667 if ( enabled ) {
668 mItemList->setVScrollBarMode(QScrollView::Auto); 668 mItemList->setVScrollBarMode(QScrollView::Auto);
669 mItemList->setHScrollBarMode(QScrollView::Auto); 669 mItemList->setHScrollBarMode(QScrollView::Auto);
670 } else { 670 } else {
671 mItemList->setVScrollBarMode(QScrollView::AlwaysOff); 671 mItemList->setVScrollBarMode(QScrollView::AlwaysOff);
672 mItemList->setHScrollBarMode(QScrollView::AlwaysOff); 672 mItemList->setHScrollBarMode(QScrollView::AlwaysOff);
673 } 673 }
674} 674}
675 675
676Incidence *MonthViewCell::selectedIncidence() 676Incidence *MonthViewCell::selectedIncidence()
677{ 677{
678 int index = mItemList->currentItem(); 678 int index = mItemList->currentItem();
679 if ( index < 0 ) return 0; 679 if ( index < 0 ) return 0;
680 680
681 MonthViewItem *item = 681 MonthViewItem *item =
682 static_cast<MonthViewItem *>( mItemList->item( index ) ); 682 static_cast<MonthViewItem *>( mItemList->item( index ) );
683 683
684 if ( !item ) return 0; 684 if ( !item ) return 0;
685 685
686 return item->incidence(); 686 return item->incidence();
687} 687}
688 688
689QDate MonthViewCell::selectedIncidenceDate() 689QDate MonthViewCell::selectedIncidenceDate()
690{ 690{
691 QDate qd; 691 QDate qd;
692 int index = mItemList->currentItem(); 692 int index = mItemList->currentItem();
693 if ( index < 0 ) return qd; 693 if ( index < 0 ) return qd;
694 694
695 MonthViewItem *item = 695 MonthViewItem *item =
696 static_cast<MonthViewItem *>( mItemList->item( index ) ); 696 static_cast<MonthViewItem *>( mItemList->item( index ) );
697 697
698 if ( !item ) return qd; 698 if ( !item ) return qd;
699 699
700 return item->incidenceDate(); 700 return item->incidenceDate();
701} 701}
702 702
703void MonthViewCell::deselect() 703void MonthViewCell::deselect()
704{ 704{
705 mItemList->clearSelection(); 705 mItemList->clearSelection();
706 enableScrollBars( false ); 706 enableScrollBars( false );
707 // updateCell(); 707 // updateCell();
708} 708}
709void MonthViewCell::select() 709void MonthViewCell::select()
710{ 710{
711 ;// updateCell(); 711 ;// updateCell();
712} 712}
713 713
714void MonthViewCell::resizeEvent ( QResizeEvent * ) 714void MonthViewCell::resizeEvent ( QResizeEvent * )
715{ 715{
716 if ( !mMonthView->isUpdatePossible() ) 716 if ( !mMonthView->isUpdatePossible() )
717 return; 717 return;
718 718
719 int size = height() - mLabel->height() - 2; 719 int size = height() - mLabel->height() - 2;
720 if ( size > 0 ) 720 if ( size > 0 )
721 mItemList->verticalScrollBar()->setMaximumHeight( size ); 721 mItemList->verticalScrollBar()->setMaximumHeight( size );
722 size = width() - mLabel->width() -2; 722 size = width() - mLabel->width() -2;
723 if ( size > 0 ) 723 if ( size > 0 )
724 mItemList->horizontalScrollBar()->setMaximumWidth( size ); 724 mItemList->horizontalScrollBar()->setMaximumWidth( size );
725 mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() ); 725 mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() );
726 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 726 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
727} 727}
728 728
729void MonthViewCell::defaultAction( QListBoxItem *item ) 729void MonthViewCell::defaultAction( QListBoxItem *item )
730{ 730{
731 if ( !item ) return; 731 if ( !item ) return;
732 732
733 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 733 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
734 Incidence *incidence = eventItem->incidence(); 734 Incidence *incidence = eventItem->incidence();
735 if ( incidence ) mMonthView->defaultAction( incidence ); 735 if ( incidence ) mMonthView->defaultAction( incidence );
736} 736}
737void MonthViewCell::showDay() 737void MonthViewCell::showDay()
738{ 738{
739 emit showDaySignal( date() ); 739 emit showDaySignal( date() );
740} 740}
741void MonthViewCell::newEvent() 741void MonthViewCell::newEvent()
742{ 742{
743 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 743 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
744 emit newEventSignal( dt ); 744 emit newEventSignal( dt );
745} 745}
746void MonthViewCell::cellClicked( QListBoxItem *item ) 746void MonthViewCell::cellClicked( QListBoxItem *item )
747{ 747{
748 static QListBoxItem * lastClicked = 0; 748 static QListBoxItem * lastClicked = 0;
749 if ( item == 0 ) { 749 if ( item == 0 ) {
750 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 750 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
751 emit newEventSignal( dt ); 751 emit newEventSignal( dt );
752 return; 752 return;
753 } 753 }
754 /* 754 /*
755 if ( lastClicked ) 755 if ( lastClicked )
756 if ( ! item ) { 756 if ( ! item ) {
757 if ( lastClicked->listBox() != item->listBox() ) 757 if ( lastClicked->listBox() != item->listBox() )
758 lastClicked->listBox()->clearSelection(); 758 lastClicked->listBox()->clearSelection();
759 } 759 }
760 */ 760 */
761 761
762 mMonthView->setSelectedCell( this ); 762 mMonthView->setSelectedCell( this );
763 if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true ); 763 if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true );
764 select(); 764 select();
765} 765}
766 766
767void MonthViewCell::contextMenu( QListBoxItem *item ) 767void MonthViewCell::contextMenu( QListBoxItem *item )
768{ 768{
769 if ( !item ) return; 769 if ( !item ) return;
770 770
771 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 771 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
772 Incidence *incidence = eventItem->incidence(); 772 Incidence *incidence = eventItem->incidence();
773 if ( incidence ) mMonthView->showContextMenu( incidence ); 773 if ( incidence ) mMonthView->showContextMenu( incidence );
774} 774}
775 775
776void MonthViewCell::selection( QListBoxItem *item ) 776void MonthViewCell::selection( QListBoxItem *item )
777{ 777{
778 if ( !item ) return; 778 if ( !item ) return;
779 779
780 mMonthView->setSelectedCell( this ); 780 mMonthView->setSelectedCell( this );
781} 781}
782 782
783 783
784// ******************************************************************************* 784// *******************************************************************************
785// ******************************************************************************* 785// *******************************************************************************
786// ******************************************************************************* 786// *******************************************************************************
787 787
788 788
789KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) 789KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
790 : KOEventView( calendar, parent, name ), 790 : KOEventView( calendar, parent, name ),
791 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), 791 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ),
792 mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) 792 mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 )
793{ 793{
794 skipResize = false; 794 skipResize = false;
795 clPending = true; 795 clPending = true;
796 mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" );
796 mWidStack = new QWidgetStack( this ); 797 mWidStack = new QWidgetStack( this );
797 QHBoxLayout* hb = new QHBoxLayout( this ); 798 QVBoxLayout* hb = new QVBoxLayout( this );
798 mMonthView = new QWidget( mWidStack ); 799 mMonthView = new QWidget( mWidStack );
799 mWeekView = new QWidget( mWidStack ); 800 mWeekView = new QWidget( mWidStack );
800#if QT_VERSION >= 0x030000 801#if QT_VERSION >= 0x030000
801 mWidStack->addWidget(mMonthView ); 802 mWidStack->addWidget(mMonthView );
802 mWidStack->addWidget(mWeekView ); 803 mWidStack->addWidget(mWeekView );
803#else 804#else
804 mWidStack->addWidget( mMonthView, 1 ); 805 mWidStack->addWidget( mMonthView, 1 );
805 mWidStack->addWidget( mWeekView , 1 ); 806 mWidStack->addWidget( mWeekView , 1 );
806#endif 807#endif
808 hb->addWidget( mNavigatorBar );
807 hb->addWidget( mWidStack ); 809 hb->addWidget( mWidStack );
808 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); 810 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
809 mShowWeekView = KOPrefs::instance()->mMonthViewWeek; 811 mShowWeekView = KOPrefs::instance()->mMonthViewWeek;
810 if ( mShowWeekView ) 812 if ( mShowWeekView )
811 mWeekStartsMonday = true; 813 mWeekStartsMonday = true;
812 updatePossible = false; 814 updatePossible = false;
815 //updatePossible = true;
813 mCells.setAutoDelete( true ); 816 mCells.setAutoDelete( true );
814 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 817 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
815 mDayLabels.resize( mDaysPerWeek ); 818 mDayLabels.resize( mDaysPerWeek );
816 mDayLabelsW.resize( mDaysPerWeek ); 819 mDayLabelsW.resize( mDaysPerWeek );
817 QFont bfont = font(); 820 QFont bfont = font();
818 if ( QApplication::desktop()->width() < 650 ) { 821 if ( QApplication::desktop()->width() < 650 ) {
819 bfont.setPointSize( bfont.pointSize() - 2 ); 822 bfont.setPointSize( bfont.pointSize() - 2 );
820 } 823 }
821 bfont.setBold( true ); 824 bfont.setBold( true );
822 int i; 825 int i;
823 826
824 for( i = 0; i < mDaysPerWeek; i++ ) { 827 for( i = 0; i < mDaysPerWeek; i++ ) {
825 QLabel *label = new QLabel( mMonthView ); 828 QLabel *label = new QLabel( mMonthView );
826 label->setFont(bfont); 829 label->setFont(bfont);
827 label->setFrameStyle(QFrame::Panel|QFrame::Raised); 830 label->setFrameStyle(QFrame::Panel|QFrame::Raised);
828 label->setLineWidth(1); 831 label->setLineWidth(1);
829 label->setAlignment(AlignCenter); 832 label->setAlignment(AlignCenter);
830 mDayLabels.insert( i, label ); 833 mDayLabels.insert( i, label );
831 label = new QLabel( mWeekView ); 834 label = new QLabel( mWeekView );
832 label->setFont(bfont); 835 label->setFont(bfont);
833 label->setFrameStyle(QFrame::Panel|QFrame::Raised); 836 label->setFrameStyle(QFrame::Panel|QFrame::Raised);
834 label->setLineWidth(1); 837 label->setLineWidth(1);
835 label->setAlignment(AlignCenter); 838 label->setAlignment(AlignCenter);
836 mDayLabelsW.insert( i, label ); 839 mDayLabelsW.insert( i, label );
837 } 840 }
838 841
839 bfont.setBold( false ); 842 bfont.setBold( false );
840 mWeekLabels.resize( mNumWeeks+1 ); 843 mWeekLabels.resize( mNumWeeks+1 );
841 mWeekLabelsW.resize( 2 ); 844 mWeekLabelsW.resize( 2 );
842 for( i = 0; i < mNumWeeks+1; i++ ) { 845 for( i = 0; i < mNumWeeks+1; i++ ) {
843 KOWeekButton *label = new KOWeekButton( mMonthView ); 846 KOWeekButton *label = new KOWeekButton( mMonthView );
844 label->setFocusPolicy(NoFocus); 847 label->setFocusPolicy(NoFocus);
845 label->setFont(bfont); 848 label->setFont(bfont);
846 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); 849 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) );
847 label->setFlat(true); 850 label->setFlat(true);
848 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); 851 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed"));
849 //label->setFrameStyle(QFrame::Panel|QFrame::Raised); 852 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
850 //label->setLineWidth(1); 853 //label->setLineWidth(1);
851 //label->setAlignment(AlignCenter); 854 //label->setAlignment(AlignCenter);
852 mWeekLabels.insert( i, label ); 855 mWeekLabels.insert( i, label );
853 } 856 }
854 mWeekLabels[mNumWeeks]->setText( i18n("W")); 857 mWeekLabels[mNumWeeks]->setText( i18n("W"));
855 QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); 858 QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number"));
856 859
857 for( i = 0; i < 1+1; i++ ) { 860 for( i = 0; i < 1+1; i++ ) {
858 KOWeekButton *label = new KOWeekButton( mWeekView ); 861 KOWeekButton *label = new KOWeekButton( mWeekView );
859 label->setFocusPolicy(NoFocus); 862 label->setFocusPolicy(NoFocus);
860 label->setFont(bfont); 863 label->setFont(bfont);
861 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); 864 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) );
862 label->setFlat(true); 865 label->setFlat(true);
863 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); 866 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed"));
864 //label->setFrameStyle(QFrame::Panel|QFrame::Raised); 867 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
865 //label->setLineWidth(1); 868 //label->setLineWidth(1);
866 //label->setAlignment(AlignCenter); 869 //label->setAlignment(AlignCenter);
867 mWeekLabelsW.insert( i, label ); 870 mWeekLabelsW.insert( i, label );
868 } 871 }
869 mWeekLabelsW[1]->setText( i18n("W")); 872 mWeekLabelsW[1]->setText( i18n("W"));
870 873
871 874
872 int row, col; 875 int row, col;
873 mCells.resize( mNumCells ); 876 mCells.resize( mNumCells );
874 for( row = 0; row < mNumWeeks; ++row ) { 877 for( row = 0; row < mNumWeeks; ++row ) {
875 for( col = 0; col < mDaysPerWeek; ++col ) { 878 for( col = 0; col < mDaysPerWeek; ++col ) {
876 MonthViewCell *cell = new MonthViewCell( this, mMonthView ); 879 MonthViewCell *cell = new MonthViewCell( this, mMonthView );
877 mCells.insert( row * mDaysPerWeek + col, cell ); 880 mCells.insert( row * mDaysPerWeek + col, cell );
878 881
879 connect( cell, SIGNAL( defaultAction( Incidence * ) ), 882 connect( cell, SIGNAL( defaultAction( Incidence * ) ),
880 SLOT( defaultAction( Incidence * ) ) ); 883 SLOT( defaultAction( Incidence * ) ) );
881 connect( cell, SIGNAL( newEventSignal( QDateTime ) ), 884 connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
882 SIGNAL( newEventSignal( QDateTime ) ) ); 885 SIGNAL( newEventSignal( QDateTime ) ) );
883 connect( cell, SIGNAL( showDaySignal( QDate ) ), 886 connect( cell, SIGNAL( showDaySignal( QDate ) ),
884 SIGNAL( showDaySignal( QDate ) ) ); 887 SIGNAL( showDaySignal( QDate ) ) );
885 } 888 }
886 } 889 }
887 mCellsW.resize( mDaysPerWeek ); 890 mCellsW.resize( mDaysPerWeek );
888 for( col = 0; col < mDaysPerWeek; ++col ) { 891 for( col = 0; col < mDaysPerWeek; ++col ) {
889 MonthViewCell *cell = new MonthViewCell( this, mWeekView ); 892 MonthViewCell *cell = new MonthViewCell( this, mWeekView );
890 mCellsW.insert( col, cell ); 893 mCellsW.insert( col, cell );
891 894
892 connect( cell, SIGNAL( defaultAction( Incidence * ) ), 895 connect( cell, SIGNAL( defaultAction( Incidence * ) ),
893 SLOT( defaultAction( Incidence * ) ) ); 896 SLOT( defaultAction( Incidence * ) ) );
894 connect( cell, SIGNAL( newEventSignal( QDateTime ) ), 897 connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
895 SIGNAL( newEventSignal( QDateTime ) ) ); 898 SIGNAL( newEventSignal( QDateTime ) ) );
896 connect( cell, SIGNAL( showDaySignal( QDate ) ), 899 connect( cell, SIGNAL( showDaySignal( QDate ) ),
897 SIGNAL( showDaySignal( QDate ) ) ); 900 SIGNAL( showDaySignal( QDate ) ) );
898 cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); 901 cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont );
899 } 902 }
900 903
901 //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); 904 //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) );
902 mContextMenu = eventPopup(); 905 mContextMenu = eventPopup();
903 // updateConfig(); //useless here... 906 // updateConfig(); //useless here...
904 // ... but we need mWidthLongDayLabel computed 907 // ... but we need mWidthLongDayLabel computed
905 QFontMetrics fontmetric(mDayLabels[0]->font()); 908 QFontMetrics fontmetric(mDayLabels[0]->font());
906 mWidthLongDayLabel = 0; 909 mWidthLongDayLabel = 0;
907 for (int i = 0; i < 7; i++) { 910 for (int i = 0; i < 7; i++) {
908 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); 911 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1));
909 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; 912 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
910 } 913 }
911 914
912 //mWeekLabels[mNumWeeks]->setText( i18n("W")); 915 //mWeekLabels[mNumWeeks]->setText( i18n("W"));
913 916
914 if ( mShowWeekView ) 917 if ( mShowWeekView )
915 mWidStack->raiseWidget( mWeekView ); 918 mWidStack->raiseWidget( mWeekView );
916 else 919 else
917 mWidStack->raiseWidget( mMonthView ); 920 mWidStack->raiseWidget( mMonthView );
918 921
919 emit incidenceSelected( 0 ); 922 emit incidenceSelected( 0 );
923#ifndef DESKTOP_VERSION
924 resize( QApplication::desktop()->size() );
925 computeLayout();
926#endif
920} 927}
921 928
922KOMonthView::~KOMonthView() 929KOMonthView::~KOMonthView()
923{ 930{
924 delete mContextMenu; 931 delete mContextMenu;
925} 932}
926 933
927void KOMonthView::selectInternalWeekNum ( int n ) 934void KOMonthView::selectInternalWeekNum ( int n )
928{ 935{
929 switchView(); 936 switchView();
930 emit selectWeekNum ( n ); 937 emit selectWeekNum ( n );
931} 938}
932 939
933int KOMonthView::currentWeek() 940int KOMonthView::currentWeek()
934{ 941{
935 if ( mShowWeekView ) 942 if ( mShowWeekView )
936 return mWeekLabelsW[0]->getWeekNum(); 943 return mWeekLabelsW[0]->getWeekNum();
937 return mWeekLabels[0]->getWeekNum(); 944 return mWeekLabels[0]->getWeekNum();
938} 945}
939void KOMonthView::switchView() 946void KOMonthView::switchView()
940{ 947{
941 948
942 if ( selectedCell( ) ) 949 if ( selectedCell( ) )
943 selectedCell()->deselect(); 950 selectedCell()->deselect();
944 mShowWeekView = !mShowWeekView; 951 mShowWeekView = !mShowWeekView;
945 KOPrefs::instance()->mMonthViewWeek = mShowWeekView; 952 KOPrefs::instance()->mMonthViewWeek = mShowWeekView;
946 //emit showNavigator( !mShowWeekView );
947 if ( clPending ) { 953 if ( clPending ) {
948 computeLayout(); 954 computeLayout();
949 updateConfig(); 955 updateConfig();
950 } 956 }
951 if ( mShowWeekView ) 957 if ( mShowWeekView )
952 mWidStack->raiseWidget( mWeekView ); 958 mWidStack->raiseWidget( mWeekView );
953 else 959 else
954 mWidStack->raiseWidget( mMonthView ); 960 mWidStack->raiseWidget( mMonthView );
955 clPending = false; 961 clPending = false;
956} 962}
957 963
958int KOMonthView::maxDatesHint() 964int KOMonthView::maxDatesHint()
959{ 965{
960 return mNumCells; 966 return mNumCells;
961} 967}
962 968
963int KOMonthView::currentDateCount() 969int KOMonthView::currentDateCount()
964{ 970{
965 return mNumCells; 971 return mNumCells;
966} 972}
967 973
968QPtrList<Incidence> KOMonthView::selectedIncidences() 974QPtrList<Incidence> KOMonthView::selectedIncidences()
969{ 975{
970 QPtrList<Incidence> selected; 976 QPtrList<Incidence> selected;
971 977
972 if ( mSelectedCell ) { 978 if ( mSelectedCell ) {
973 Incidence *incidence = mSelectedCell->selectedIncidence(); 979 Incidence *incidence = mSelectedCell->selectedIncidence();
974 if ( incidence ) selected.append( incidence ); 980 if ( incidence ) selected.append( incidence );
975 } 981 }
976 982
977 return selected; 983 return selected;
978} 984}
979 985
980DateList KOMonthView::selectedDates() 986DateList KOMonthView::selectedDates()
981{ 987{
982 DateList selected; 988 DateList selected;
983 989
984 if ( mSelectedCell ) { 990 if ( mSelectedCell ) {
985 QDate qd = mSelectedCell->selectedIncidenceDate(); 991 QDate qd = mSelectedCell->selectedIncidenceDate();
986 if ( qd.isValid() ) selected.append( qd ); 992 if ( qd.isValid() ) selected.append( qd );
987 } 993 }
988 994
989 return selected; 995 return selected;
990} 996}
991 997
992void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, 998void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd,
993 const QDate &td) 999 const QDate &td)
994{ 1000{
995#ifndef KORG_NOPRINTER 1001#ifndef KORG_NOPRINTER
996 calPrinter->preview(CalPrinter::Month, fd, td); 1002 calPrinter->preview(CalPrinter::Month, fd, td);
997#endif 1003#endif
998} 1004}
999 1005
1000void KOMonthView::updateConfig() 1006void KOMonthView::updateConfig()
1001{ 1007{
1002 1008
1003 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); 1009 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
1004 1010
1005 if ( mShowWeekView ) { 1011 if ( mShowWeekView ) {
1006 mWeekStartsMonday = true; 1012 mWeekStartsMonday = true;
1007 } 1013 }
1008 QFontMetrics fontmetric(mDayLabels[0]->font()); 1014 QFontMetrics fontmetric(mDayLabels[0]->font());
1009 mWidthLongDayLabel = 0; 1015 mWidthLongDayLabel = 0;
1010 1016
1011 for (int i = 0; i < 7; i++) { 1017 for (int i = 0; i < 7; i++) {
1012 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); 1018 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1));
1013 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; 1019 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
1014 } 1020 }
1015 bool temp = mShowSatSunComp ; 1021 bool temp = mShowSatSunComp ;
1016 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 1022 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
1017 if ( ! mShowWeekView ) { 1023 if ( ! mShowWeekView ) {
1018 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) 1024 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog )
1019 computeLayout(); 1025 computeLayout();
1020 } 1026 }
1021 updateDayLabels(); 1027 updateDayLabels();
1022 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); 1028 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks);
1023 //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; 1029 //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks;
1024 //resizeEvent( 0 ); 1030 //resizeEvent( 0 );
1025 for (uint i = 0; i < mCells.count(); ++i) { 1031 for (uint i = 0; i < mCells.count(); ++i) {
1026 mCells[i]->updateConfig(); 1032 mCells[i]->updateConfig();
1027 } 1033 }
1028 1034
1029 for (uint i = 0; i < mCellsW.count(); ++i) { 1035 for (uint i = 0; i < mCellsW.count(); ++i) {
1030 mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); 1036 mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont);
1031 } 1037 }
1032#ifdef DESKTOP_VERSION 1038#ifdef DESKTOP_VERSION
1033 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); 1039 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips);
1034#endif 1040#endif
1035 updateView(); 1041 updateView();
1036} 1042}
1037 1043
1038void KOMonthView::updateDayLabels() 1044void KOMonthView::updateDayLabels()
1039{ 1045{
1040 1046
1041 QPtrVector<QLabel> *mDayLabelsT; 1047 QPtrVector<QLabel> *mDayLabelsT;
1042 1048
1043 mDayLabelsT = &mDayLabelsW; 1049 mDayLabelsT = &mDayLabelsW;
1044 for (int i = 0; i < 7; i++) { 1050 for (int i = 0; i < 7; i++) {
1045 if (mWeekStartsMonday) { 1051 if (mWeekStartsMonday) {
1046 bool show = mShortDayLabels; 1052 bool show = mShortDayLabels;
1047 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) 1053 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() )
1048 show = true; 1054 show = true;
1049 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); 1055 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
1050 } else { 1056 } else {
1051 if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels)); 1057 if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels));
1052 else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); 1058 else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels));
1053 1059
1054 } 1060 }
1055 } 1061 }
1056 mDayLabelsT = &mDayLabels; 1062 mDayLabelsT = &mDayLabels;
1057 for (int i = 0; i < 7; i++) { 1063 for (int i = 0; i < 7; i++) {
1058 if (mWeekStartsMonday) { 1064 if (mWeekStartsMonday) {
1059 bool show = mShortDayLabels; 1065 bool show = mShortDayLabels;
1060 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) 1066 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() )
1061 show = true; 1067 show = true;
1062 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); 1068 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
1063 } else { 1069 } else {
1064 if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels)); 1070 if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels));
1065 else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); 1071 else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels));
1066 1072
1067 } 1073 }
1068 } 1074 }
1069 1075
1070} 1076}
1071 1077
1072void KOMonthView::showDates(const QDate &start, const QDate &) 1078void KOMonthView::showDates(const QDate &start, const QDate &)
1073{ 1079{
1074 // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; 1080 // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl;
1075 1081
1076 QPtrVector<MonthViewCell> *cells; 1082 QPtrVector<MonthViewCell> *cells;
1077 QPtrVector<QLabel> *dayLabels; 1083 QPtrVector<QLabel> *dayLabels;
1078 QPtrVector<KOWeekButton> *weekLabels; 1084 QPtrVector<KOWeekButton> *weekLabels;
1079 int weekNum = 6; 1085 int weekNum = 6;
1080 if ( mShowWeekView ) { 1086 if ( mShowWeekView ) {
1081 weekNum = 1; 1087 weekNum = 1;
1082 cells = &mCellsW; 1088 cells = &mCellsW;
1083 dayLabels = &mDayLabelsW; 1089 dayLabels = &mDayLabelsW;
1084 weekLabels = &mWeekLabelsW; 1090 weekLabels = &mWeekLabelsW;
1085 } else { 1091 } else {
1086 cells = &mCells; 1092 cells = &mCells;
1087 dayLabels = &mDayLabels; 1093 dayLabels = &mDayLabels;
1088 weekLabels = &mWeekLabels; 1094 weekLabels = &mWeekLabels;
1089 } 1095 }
1090 1096
1091 mStartDate = start; 1097 mStartDate = start;
1092 1098
1093 int startWeekDay = mWeekStartsMonday ? 1 : 7; 1099 int startWeekDay = mWeekStartsMonday ? 1 : 7;
1094 1100
1095 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { 1101 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) {
1096 mStartDate = mStartDate.addDays( -1 ); 1102 mStartDate = mStartDate.addDays( -1 );
1097 } 1103 }
1098 1104
1099 bool primary = false; 1105 bool primary = false;
1100 uint i; 1106 uint i;
1101 for( i = 0; i < (*cells).size(); ++i ) { 1107 for( i = 0; i < (*cells).size(); ++i ) {
1102 QDate date = mStartDate.addDays( i ); 1108 QDate date = mStartDate.addDays( i );
1103 (*cells)[i]->setDate( date ); 1109 (*cells)[i]->setDate( date );
1104 1110
1105#ifndef KORG_NOPLUGINS 1111#ifndef KORG_NOPLUGINS
1106 // add holiday, if present 1112 // add holiday, if present
1107 QString hstring(KOCore::self()->holiday(date)); 1113 QString hstring(KOCore::self()->holiday(date));
1108 (*cells)[i]->setHoliday( hstring ); 1114 (*cells)[i]->setHoliday( hstring );
1109#endif 1115#endif
1110 1116
1111 } 1117 }
1112 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); 1118 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 );
1113 for( i = 0; i < weekNum; ++i ) { 1119 for( i = 0; i < weekNum; ++i ) {
1114 int wno; 1120 int wno;
1115 // remember, according to ISO 8601, the first week of the year is the 1121 // remember, according to ISO 8601, the first week of the year is the
1116 // first week that contains a thursday. Thus we must subtract off 4, 1122 // first week that contains a thursday. Thus we must subtract off 4,
1117 // not just 1. 1123 // not just 1.
1118 int dayOfYear = date.dayOfYear(); 1124 int dayOfYear = date.dayOfYear();
1119 if (dayOfYear % 7 != 0) 1125 if (dayOfYear % 7 != 0)
1120 wno = dayOfYear / 7 + 1; 1126 wno = dayOfYear / 7 + 1;
1121 else 1127 else
1122 wno =dayOfYear / 7; 1128 wno =dayOfYear / 7;
1123 (*weekLabels)[i]->setWeekNum( wno ); 1129 (*weekLabels)[i]->setWeekNum( wno );
1124 date = date.addDays( 7 ); 1130 date = date.addDays( 7 );
1125 } 1131 }
1126 updateView(); 1132 updateView();
1127} 1133}
1128 1134
1129void KOMonthView::showEvents(QPtrList<Event>) 1135void KOMonthView::showEvents(QPtrList<Event>)
1130{ 1136{
1131 qDebug("KOMonthView::selectEvents is not implemented yet. "); 1137 qDebug("KOMonthView::selectEvents is not implemented yet. ");
1132} 1138}
1133 1139
1134void KOMonthView::changeEventDisplay(Event *, int) 1140void KOMonthView::changeEventDisplay(Event *, int)
1135{ 1141{
1136 // this should be re-written to be much more efficient, but this 1142 // this should be re-written to be much more efficient, but this
1137 // quick-and-dirty-hack gets the job done for right now. 1143 // quick-and-dirty-hack gets the job done for right now.
1138 updateView(); 1144 updateView();
1139} 1145}
1140 1146
1141void KOMonthView::updateView() 1147void KOMonthView::updateView()
1142{ 1148{
1143 1149
1144 if ( !updatePossible ) 1150 if ( !updatePossible )
1145 return; 1151 return;
1146 //QTime ti; 1152 //QTime ti;
1147 //ti.start(); 1153 //ti.start();
1148 QPtrVector<MonthViewCell> *cells; 1154 QPtrVector<MonthViewCell> *cells;
1149 if ( mShowWeekView ) { 1155 if ( mShowWeekView ) {
1150 cells = &mCellsW; 1156 cells = &mCellsW;
1151 } else { 1157 } else {
1152 cells = &mCells; 1158 cells = &mCells;
1153 } 1159 }
1154#if 1 1160#if 1
1155 int i; 1161 int i;
1156 int timeSpan = (*cells).size()-1; 1162 int timeSpan = (*cells).size()-1;
1157 if ( KOPrefs::instance()->mMonthViewWeek ) 1163 if ( KOPrefs::instance()->mMonthViewWeek )
1158 timeSpan = 6; 1164 timeSpan = 6;
1159 for( i = 0; i < timeSpan + 1; ++i ) { 1165 for( i = 0; i < timeSpan + 1; ++i ) {
1160 (*cells)[i]->startUpdateCell(); 1166 (*cells)[i]->startUpdateCell();
1161 } 1167 }
1162 1168
1163 QPtrList<Event> events = calendar()->events(); 1169 QPtrList<Event> events = calendar()->events();
1164 Event *event; 1170 Event *event;
1165 QDateTime dt; 1171 QDateTime dt;
1166 bool ok; 1172 bool ok;
1167 QDate endDate = mStartDate.addDays( timeSpan ); 1173 QDate endDate = mStartDate.addDays( timeSpan );
1168 for( event = events.first(); event; event = events.next() ) { // for event 1174 for( event = events.first(); event; event = events.next() ) { // for event
1169 if ( event->doesRecur() ) { 1175 if ( event->doesRecur() ) {
1170 bool last; 1176 bool last;
1171 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); 1177 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last );
1172 QDateTime incidenceEnd; 1178 QDateTime incidenceEnd;
1173 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); 1179 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() );
1174 bool invalid = false; 1180 bool invalid = false;
1175 while( true ) { 1181 while( true ) {
1176 if ( incidenceStart.isValid() ) { 1182 if ( incidenceStart.isValid() ) {
1177 incidenceEnd = incidenceStart.addDays( eventlen ); 1183 incidenceEnd = incidenceStart.addDays( eventlen );
1178 int st = incidenceStart.date().daysTo( endDate ); 1184 int st = incidenceStart.date().daysTo( endDate );
1179 if ( st >= 0 ) { // start before timeend 1185 if ( st >= 0 ) { // start before timeend
1180 int end = mStartDate.daysTo( incidenceEnd.date() ); 1186 int end = mStartDate.daysTo( incidenceEnd.date() );
1181 if ( end >= 0 ) { // end after timestart --- got one! 1187 if ( end >= 0 ) { // end after timestart --- got one!
1182 //normalize 1188 //normalize
1183 st = timeSpan - st; 1189 st = timeSpan - st;
1184 if ( st < 0 ) st = 0; 1190 if ( st < 0 ) st = 0;
1185 if ( end > timeSpan ) end = timeSpan; 1191 if ( end > timeSpan ) end = timeSpan;
1186 int iii; 1192 int iii;
1187 //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); 1193 //qDebug("found %s %d %d ",event->summary().latin1(), st, end );
1188 for ( iii = st;iii<= end;++iii) 1194 for ( iii = st;iii<= end;++iii)
1189 (*cells)[iii]->insertEvent( event ); 1195 (*cells)[iii]->insertEvent( event );
1190 } 1196 }
1191 } 1197 }
1192 } else { 1198 } else {
1193 if ( invalid ) 1199 if ( invalid )
1194 break; 1200 break;
1195 invalid = true; 1201 invalid = true;
1196 //qDebug("invalid %s", event->summary().latin1()); 1202 //qDebug("invalid %s", event->summary().latin1());
1197 incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; 1203 incidenceStart = QDateTime( mStartDate ).addSecs( -2 );;
1198 } 1204 }
1199 if ( last ) 1205 if ( last )
1200 break; 1206 break;
1201 bool ok; 1207 bool ok;
1202 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); 1208 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok );
1203 if ( ! ok ) 1209 if ( ! ok )
1204 break; 1210 break;
1205 if ( incidenceStart.date() > endDate ) 1211 if ( incidenceStart.date() > endDate )
1206 break; 1212 break;
1207 } 1213 }
1208 } else { // no recur 1214 } else { // no recur
1209 int st = event->dtStart().date().daysTo( endDate ); 1215 int st = event->dtStart().date().daysTo( endDate );
1210 if ( st >= 0 ) { // start before timeend 1216 if ( st >= 0 ) { // start before timeend
1211 int end = mStartDate.daysTo( event->dtEnd().date() ); 1217 int end = mStartDate.daysTo( event->dtEnd().date() );
1212 if ( end >= 0 ) { // end after timestart --- got one! 1218 if ( end >= 0 ) { // end after timestart --- got one!
1213 //normalize 1219 //normalize
1214 st = timeSpan - st; 1220 st = timeSpan - st;
1215 if ( st < 0 ) st = 0; 1221 if ( st < 0 ) st = 0;
1216 if ( end > timeSpan ) end = timeSpan; 1222 if ( end > timeSpan ) end = timeSpan;
1217 int iii; 1223 int iii;
1218 for ( iii = st;iii<= end;++iii) 1224 for ( iii = st;iii<= end;++iii)
1219 (*cells)[iii]->insertEvent( event ); 1225 (*cells)[iii]->insertEvent( event );
1220 } 1226 }
1221 } 1227 }
1222 } 1228 }
1223 } 1229 }
1224 // insert due todos 1230 // insert due todos
1225 QPtrList<Todo> todos = calendar()->todos( ); 1231 QPtrList<Todo> todos = calendar()->todos( );
1226 Todo *todo; 1232 Todo *todo;
1227 for(todo = todos.first(); todo; todo = todos.next()) { 1233 for(todo = todos.first(); todo; todo = todos.next()) {
1228 //insertTodo( todo ); 1234 //insertTodo( todo );
1229 if ( todo->hasDueDate() ) { 1235 if ( todo->hasDueDate() ) {
1230 int day = mStartDate.daysTo( todo->dtDue().date() ); 1236 int day = mStartDate.daysTo( todo->dtDue().date() );
1231 if ( day >= 0 && day < timeSpan + 1) { 1237 if ( day >= 0 && day < timeSpan + 1) {
1232 (*cells)[day]->insertTodo( todo ); 1238 (*cells)[day]->insertTodo( todo );
1233 } 1239 }
1234 } 1240 }
1235 } 1241 }
1236 1242
1237 for( i = 0; i < timeSpan+1; ++i ) { 1243 for( i = 0; i < timeSpan+1; ++i ) {
1238 (*cells)[i]->finishUpdateCell(); 1244 (*cells)[i]->finishUpdateCell();
1239 } 1245 }
1240 processSelectionChange(); 1246 processSelectionChange();
1241 (*cells)[0]->setFocus(); 1247 (*cells)[0]->setFocus();
1242 1248
1243 1249
1244#else 1250#else
1245 // old code 1251 // old code
1246 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); 1252 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ");
1247 int i; 1253 int i;
1248 for( i = 0; i < (*cells).count(); ++i ) { 1254 for( i = 0; i < (*cells).count(); ++i ) {
1249 (*cells)[i]->updateCell(); 1255 (*cells)[i]->updateCell();
1250 } 1256 }
1251 1257
1252 //qDebug("KOMonthView::updateView() "); 1258 //qDebug("KOMonthView::updateView() ");
1253 processSelectionChange(); 1259 processSelectionChange();
1254 // qDebug("---------------------------------------------------------------------+ "); 1260 // qDebug("---------------------------------------------------------------------+ ");
1255 (*cells)[0]->setFocus(); 1261 (*cells)[0]->setFocus();
1256#endif 1262#endif
1257 1263
1258 //qDebug("update time %d ", ti.elapsed()); 1264 //qDebug("update time %d ", ti.elapsed());
1259} 1265}
1260 1266
1261void KOMonthView::resizeEvent(QResizeEvent * e) 1267void KOMonthView::resizeEvent(QResizeEvent * e)
1262{ 1268{
1263 qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height()); 1269 //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height());
1264 if ( skipResize ) {
1265 skipResize = false;
1266 qDebug("skipResize ");
1267 return;
1268 }
1269 computeLayout(); 1270 computeLayout();
1270 clPending = true; 1271 clPending = true;
1271 if ( mShowWeekView ) 1272 if ( mShowWeekView )
1272 mCellsW[0]->setFocus(); 1273 mCellsW[0]->setFocus();
1273 else 1274 else
1274 mCells[0]->setFocus(); 1275 mCells[0]->setFocus();
1275} 1276}
1276void KOMonthView::computeLayoutWeek() 1277void KOMonthView::computeLayoutWeek()
1277{ 1278{
1278 static int lastWid = 0; 1279 static int lastWid = 0;
1279 static int lastHei = 0; 1280 static int lastHei = 0;
1280 int daysToShow; 1281 int daysToShow;
1281 bool combinedSatSun = false; 1282 bool combinedSatSun = false;
1282 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { 1283 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
1283 daysToShow = 6; 1284 daysToShow = 6;
1284 combinedSatSun = true; 1285 combinedSatSun = true;
1285 } 1286 }
1286 int tWid = topLevelWidget()->size().width(); 1287 int tWid = topLevelWidget()->size().width();
1287 int tHei = topLevelWidget()->size().height(); 1288 int tHei = topLevelWidget()->size().height();
1288 1289
1289 int wid = size().width();//e 1290 int wid = width();//e
1290 int hei = size().height()-1; 1291 int hei = height()-1-mNavigatorBar->height();
1291 1292
1292 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) 1293 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei )
1293 return; 1294 return;
1294 1295
1295 1296 if ( lastWid == width() && lastHei == height() )
1296 if ( lastWid == width() && lastHei ==height() )
1297 return; 1297 return;
1298 lastWid =width(); 1298 lastWid = width();
1299 lastHei = height(); 1299 lastHei = height();
1300 1300
1301 1301
1302 if ( wid < hei ) 1302 if ( wid < hei )
1303 daysToShow = 2; 1303 daysToShow = 2;
1304 else 1304 else
1305 daysToShow = 3; 1305 daysToShow = 3;
1306 mShowSatSunComp = true; 1306 mShowSatSunComp = true;
1307 combinedSatSun = true; 1307 combinedSatSun = true;
1308 1308
1309 qDebug("KOMonthView::computeLayout() WWW ------------------------------------ "); 1309 //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ ");
1310 QFontMetrics fm ( mWeekLabels[0]->font() ); 1310 QFontMetrics fm ( mWeekLabels[0]->font() );
1311 int weeklabelwid = fm.width( "888" ); 1311 int weeklabelwid = fm.width( "888" );
1312 wid -= weeklabelwid; 1312 wid -= weeklabelwid;
1313 1313
1314 int colWid = wid / daysToShow; 1314 int colWid = wid / daysToShow;
1315 int lastCol = wid - ( colWid*6 ); 1315 int lastCol = wid - ( colWid*6 );
1316 int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); 1316 int dayLabelHei = mDayLabelsW[0]->sizeHint().height();
1317 int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); 1317 int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow );
1318 int colModulo = wid % daysToShow; 1318 int colModulo = wid % daysToShow;
1319 int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; 1319 int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1;
1320 //qDebug("rowmod %d ", rowModulo); 1320 //qDebug("rowmod %d ", rowModulo);
1321 int i; 1321 int i;
1322 int x,y,w,h; 1322 int x,y,w,h;
1323 x= 0; 1323 x= 0;
1324 y= 0; 1324 y= 0;
1325 w = colWid; 1325 w = colWid;
1326 h = dayLabelHei ; 1326 h = dayLabelHei ;
1327 for ( i = 0; i < 7; i++) { 1327 for ( i = 0; i < 7; i++) {
1328 if ( i && !( i % daysToShow) && i < 6) { 1328 if ( i && !( i % daysToShow) && i < 6) {
1329 y += hei/(5-daysToShow); 1329 y += hei/(5-daysToShow);
1330 x = 0; 1330 x = 0;
1331 w = colWid; 1331 w = colWid;
1332 } 1332 }
1333 if ( ((i) % daysToShow) >= daysToShow-colModulo ) { 1333 if ( ((i) % daysToShow) >= daysToShow-colModulo ) {
1334 ++w; 1334 ++w;
1335 } 1335 }
1336 if ( i >= 5 ) { 1336 if ( i >= 5 ) {
1337 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w/2+w%2,h); 1337 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w/2+w%2,h);
1338 x -= (w/2 ); 1338 x -= (w/2 );
1339 } 1339 }
1340 else 1340 else
1341 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w,h); 1341 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w,h);
1342 x += w; 1342 x += w;
1343 } 1343 }
1344 x= 0; 1344 x= 0;
1345 y= dayLabelHei; 1345 y= dayLabelHei;
1346 w = colWid; 1346 w = colWid;
1347 h = cellHei; 1347 h = cellHei;
1348 for ( i = 0; i < mCellsW.count(); ++i) { 1348 for ( i = 0; i < mCellsW.count(); ++i) {
1349 if ( i > 6 ) { 1349 if ( i > 6 ) {
1350 mCellsW[i]->hide(); 1350 mCellsW[i]->hide();
1351 continue; 1351 continue;
1352 } 1352 }
1353 1353
1354 w = colWid; 1354 w = colWid;
1355 if ( ((i) % daysToShow) >= daysToShow-colModulo ) { 1355 if ( ((i) % daysToShow) >= daysToShow-colModulo ) {
1356 ++w; 1356 ++w;
1357 } 1357 }
1358 if ( i == (daysToShow-1-rowModulo)*7) 1358 if ( i == (daysToShow-1-rowModulo)*7)
1359 ++h; 1359 ++h;
1360 1360
1361 if ( i >= 5 ) { 1361 if ( i >= 5 ) {
1362 if ( i ==5 ) { 1362 if ( i ==5 ) {
1363 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); 1363 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h/2 );
1364 x -= w ;y += h/2; 1364 x -= w ;y += h/2;
1365 } else { 1365 } else {
1366 if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { 1366 if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) {
1367 ++w; 1367 ++w;
1368 } 1368 }
1369 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); 1369 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 );
1370 y -= h/2; 1370 y -= h/2;
1371 } 1371 }
1372 } else 1372 } else
1373 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1373 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h );
1374 1374
1375 1375
1376 x += w; 1376 x += w;
1377 if ( x + w/2 > wid ) { 1377 if ( x + w/2 > wid ) {
1378 x = 0; 1378 x = 0;
1379 y += h+dayLabelHei ; 1379 y += h+dayLabelHei ;
1380 } 1380 }
1381 } 1381 }
1382 y= dayLabelHei; 1382 y= dayLabelHei;
1383 h = cellHei ; 1383 h = cellHei ;
1384 mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); 1384 mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei);
1385 mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); 1385 mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei);
1386 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); 1386 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height());
1387 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); 1387 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height());
1388 mShortDayLabels = mDayLabelsW[0]->width() < mWidthLongDayLabel ; 1388 mShortDayLabels = mDayLabelsW[0]->width() < mWidthLongDayLabel ;
1389 updateDayLabels(); 1389 updateDayLabels();
1390 bool forceUpdate = !updatePossible; 1390 //bool forceUpdate = !updatePossible;
1391 updatePossible = true; 1391 updatePossible = true;
1392 //mWeekLabels[mNumWeeks]->setText( i18n("M")); 1392 //mWeekLabels[mNumWeeks]->setText( i18n("M"));
1393 if ( forceUpdate ) 1393 //if ( forceUpdate )
1394 updateView(); 1394 // updateView();
1395} 1395}
1396void KOMonthView::computeLayout() 1396void KOMonthView::computeLayout()
1397{ 1397{
1398 1398
1399 1399
1400 static int lastWid = 0; 1400 static int lastWid = 0;
1401 static int lastHei = 0; 1401 static int lastHei = 0;
1402 1402
1403 if ( mShowWeekView ){ 1403 if ( mShowWeekView ){
1404 computeLayoutWeek(); 1404 computeLayoutWeek();
1405 return; 1405 return;
1406 } 1406 }
1407 int daysToShow = 7; 1407 int daysToShow = 7;
1408 bool combinedSatSun = false; 1408 bool combinedSatSun = false;
1409 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { 1409 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
1410 daysToShow = 6; 1410 daysToShow = 6;
1411 combinedSatSun = true; 1411 combinedSatSun = true;
1412 } 1412 }
1413 int tWid = topLevelWidget()->size().width(); 1413 int tWid = topLevelWidget()->size().width();
1414 int tHei = topLevelWidget()->size().height(); 1414 int tHei = topLevelWidget()->size().height();
1415 1415
1416 int wid = size().width();//e 1416 int wid = width();//e
1417 int hei = size().height()-1; 1417 int hei = height()-1-mNavigatorBar->height();
1418 1418
1419 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) 1419 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) {
1420 return; 1420 return;
1421 if ( lastWid == width() && lastHei ==height() ) 1421 }
1422 if ( lastWid == width() && lastHei == height() ){
1422 return; 1423 return;
1423 lastWid =width(); 1424 }
1424 lastHei = height(); 1425
1425 qDebug("KOMonthView::computeLayout() MMM ------------------------------------ "); 1426 lastWid = width();
1427 lastHei = height();
1428 //qDebug("KOMonthView::computeLayout() MMM ------------------------------------ ");
1426 QFontMetrics fm ( mWeekLabels[0]->font() ); 1429 QFontMetrics fm ( mWeekLabels[0]->font() );
1427 int weeklabelwid = fm.width( "888" ); 1430 int weeklabelwid = fm.width( "888" );
1428 wid -= weeklabelwid; 1431 wid -= weeklabelwid;
1429 1432
1430 int colWid = wid / daysToShow; 1433 int colWid = wid / daysToShow;
1431 int lastCol = wid - ( colWid*6 ); 1434 int lastCol = wid - ( colWid*6 );
1432 int dayLabelHei = mDayLabels[0]->sizeHint().height(); 1435 int dayLabelHei = mDayLabels[0]->sizeHint().height();
1433 int cellHei = (hei - dayLabelHei) /6; 1436 int cellHei = (hei - dayLabelHei) /6;
1434 int colModulo = wid % daysToShow; 1437 int colModulo = wid % daysToShow;
1435 int rowModulo = (hei- dayLabelHei) % 6; 1438 int rowModulo = (hei- dayLabelHei) % 6;
1436 //qDebug("rowmod %d ", rowModulo); 1439 //qDebug("rowmod %d ", rowModulo);
1437 int i; 1440 int i;
1438 int x,y,w,h; 1441 int x,y,w,h;
1439 x= 0; 1442 x= 0;
1440 y= 0; 1443 y= 0;
1441 w = colWid; 1444 w = colWid;
1442 h = dayLabelHei ; 1445 h = dayLabelHei ;
1443 for ( i = 0; i < 7; i++) { 1446 for ( i = 0; i < 7; i++) {
1444 if ( i == daysToShow-colModulo ) 1447 if ( i == daysToShow-colModulo )
1445 ++w; 1448 ++w;
1446 if ( combinedSatSun ) { 1449 if ( combinedSatSun ) {
1447 if ( i >= daysToShow-1 ) { 1450 if ( i >= daysToShow-1 ) {
1448 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); 1451 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h);
1449 x -= w/2 ; 1452 x -= w/2 ;
1450 } 1453 }
1451 else 1454 else
1452 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 1455 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
1453 } else 1456 } else
1454 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 1457 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
1455 x += w; 1458 x += w;
1456 } 1459 }
1457 x= 0; 1460 x= 0;
1458 y= dayLabelHei; 1461 y= dayLabelHei;
1459 w = colWid; 1462 w = colWid;
1460 h = cellHei ; 1463 h = cellHei ;
1461 for ( i = 0; i < mCells.count(); ++i) { 1464 for ( i = 0; i < mCells.count(); ++i) {
1462 //qDebug("iii %d ", i); 1465 //qDebug("iii %d ", i);
1463 w = colWid; 1466 w = colWid;
1464 if ( ((i) % 7) >= 7-colModulo ) { 1467 if ( ((i) % 7) >= 7-colModulo ) {
1465 ++w; 1468 ++w;
1466 } 1469 }
1467 if ( i == (6-rowModulo)*7) 1470 if ( i == (6-rowModulo)*7)
1468 ++h; 1471 ++h;
1469 if ( combinedSatSun ) { 1472 if ( combinedSatSun ) {
1470 if ( (i)%7 >= daysToShow-1 ) { 1473 if ( (i)%7 >= daysToShow-1 ) {
1471 if ( (i)%7 == daysToShow-1 ) { 1474 if ( (i)%7 == daysToShow-1 ) {
1472 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); 1475 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 );
1473 x -= w ;y += h/2; 1476 x -= w ;y += h/2;
1474 } else { 1477 } else {
1475 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); 1478 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 );
1476 y -= h/2; 1479 y -= h/2;
1477 } 1480 }
1478 } else 1481 } else
1479 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1482 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
1480 1483
1481 } 1484 }
1482 else 1485 else
1483 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1486 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
1484 x += w; 1487 x += w;
1485 if ( x + w/2 > wid ) { 1488 if ( x + w/2 > wid ) {
1486 x = 0; 1489 x = 0;
1487 y += h; 1490 y += h;
1488 } 1491 }
1489 } 1492 }
1490 y= dayLabelHei; 1493 y= dayLabelHei;
1491 h = cellHei ; 1494 h = cellHei ;
1492 for ( i = 0; i < 6; i++) { 1495 for ( i = 0; i < 6; i++) {
1493 if ( i == (6-rowModulo)) 1496 if ( i == (6-rowModulo))
1494 ++h; 1497 ++h;
1495 mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); 1498 mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h);
1496 y += h; 1499 y += h;
1497 } 1500 }
1498 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); 1501 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei);
1499 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); 1502 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height());
1500 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); 1503 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height());
1501 mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ; 1504 mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ;
1502 updateDayLabels(); 1505 updateDayLabels();
1503 bool forceUpdate = !updatePossible; 1506 //bool forceUpdate = !updatePossible;
1504 updatePossible = true; 1507 updatePossible = true;
1505 //mWeekLabels[mNumWeeks]->setText( i18n("W")); 1508 //mWeekLabels[mNumWeeks]->setText( i18n("W"));
1506 if ( forceUpdate )
1507 updateView();
1508} 1509}
1509 1510
1510void KOMonthView::showContextMenu( Incidence *incidence ) 1511void KOMonthView::showContextMenu( Incidence *incidence )
1511{ 1512{
1512 mContextMenu->showIncidencePopup(incidence); 1513 mContextMenu->showIncidencePopup(incidence);
1513 /* 1514 /*
1514 if( incidence && incidence->type() == "Event" ) { 1515 if( incidence && incidence->type() == "Event" ) {
1515 Event *event = static_cast<Event *>(incidence); 1516 Event *event = static_cast<Event *>(incidence);
1516 mContextMenu->showEventPopup(event); 1517 mContextMenu->showEventPopup(event);
1517 } else { 1518 } else {
1518 kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; 1519 kdDebug() << "MonthView::showContextMenu(): cast failed." << endl;
1519 } 1520 }
1520 */ 1521 */
1521} 1522}
1522MonthViewCell * KOMonthView::selectedCell( ) 1523MonthViewCell * KOMonthView::selectedCell( )
1523{ 1524{
1524 return mSelectedCell; 1525 return mSelectedCell;
1525} 1526}
1526void KOMonthView::setSelectedCell( MonthViewCell *cell ) 1527void KOMonthView::setSelectedCell( MonthViewCell *cell )
1527{ 1528{
1528 // qDebug("KOMonthView::setSelectedCell "); 1529 // qDebug("KOMonthView::setSelectedCell ");
1529 if ( mSelectedCell && mSelectedCell != cell ) { 1530 if ( mSelectedCell && mSelectedCell != cell ) {
1530 MonthViewCell * mvc = mSelectedCell; 1531 MonthViewCell * mvc = mSelectedCell;
1531 mSelectedCell = cell; 1532 mSelectedCell = cell;
1532 mvc->deselect(); 1533 mvc->deselect();
1533 } else 1534 } else
1534 mSelectedCell = cell; 1535 mSelectedCell = cell;
1535 // if ( mSelectedCell ) 1536 // if ( mSelectedCell )
1536 // mSelectedCell->select(); 1537 // mSelectedCell->select();
1537 if ( !mSelectedCell ) 1538 if ( !mSelectedCell )
1538 emit incidenceSelected( 0 ); 1539 emit incidenceSelected( 0 );
1539 else 1540 else
1540 emit incidenceSelected( mSelectedCell->selectedIncidence() ); 1541 emit incidenceSelected( mSelectedCell->selectedIncidence() );
1541} 1542}
1542 1543
1543void KOMonthView::processSelectionChange() 1544void KOMonthView::processSelectionChange()
1544{ 1545{
1545 QPtrList<Incidence> incidences = selectedIncidences(); 1546 QPtrList<Incidence> incidences = selectedIncidences();
1546 if (incidences.count() > 0) { 1547 if (incidences.count() > 0) {
1547 emit incidenceSelected( incidences.first() ); 1548 emit incidenceSelected( incidences.first() );
1548 } else { 1549 } else {
1549 emit incidenceSelected( 0 ); 1550 emit incidenceSelected( 0 );
1550 } 1551 }
1551} 1552}
1552 1553
1553void KOMonthView::clearSelection() 1554void KOMonthView::clearSelection()
1554{ 1555{
1555 if ( mSelectedCell ) { 1556 if ( mSelectedCell ) {
1556 mSelectedCell->deselect(); 1557 mSelectedCell->deselect();
1557 mSelectedCell = 0; 1558 mSelectedCell = 0;
1558 } 1559 }
1559} 1560}
1560void KOMonthView::keyPressEvent ( QKeyEvent * e ) 1561void KOMonthView::keyPressEvent ( QKeyEvent * e )
1561{ 1562{
1562 //qDebug("KOMonthView::keyPressEvent "); 1563 //qDebug("KOMonthView::keyPressEvent ");
1563 switch(e->key()) { 1564 switch(e->key()) {
1564 case Key_Up: 1565 case Key_Up:
1565 { 1566 {
1566 emit prevMonth(); 1567 emit prevMonth();
1567 if ( mShowWeekView ) 1568 if ( mShowWeekView )
1568 mCellsW[0]->setFocus(); 1569 mCellsW[0]->setFocus();
1569 else 1570 else
1570 mCells[0]->setFocus(); 1571 mCells[0]->setFocus();
1571 } 1572 }
1572 e->accept(); 1573 e->accept();
1573 break; 1574 break;
1574 case Key_Down: 1575 case Key_Down:
1575 { 1576 {
1576 emit nextMonth(); 1577 emit nextMonth();
1577 if ( mShowWeekView ) 1578 if ( mShowWeekView )
1578 mCellsW[0]->setFocus(); 1579 mCellsW[0]->setFocus();
1579 else 1580 else
1580 mCells[0]->setFocus(); 1581 mCells[0]->setFocus();
1581 1582
1582 } 1583 }
1583 e->accept(); 1584 e->accept();
1584 break; 1585 break;
1585 case Key_Return: 1586 case Key_Return:
1586 case Key_Enter: 1587 case Key_Enter:
1587 { 1588 {
1588 selectInternalWeekNum ( currentWeek() ); 1589 selectInternalWeekNum ( currentWeek() );
1589 } 1590 }
1590 e->accept(); 1591 e->accept();
1591 break; 1592 break;
1592 default: 1593 default:
1593 e->ignore(); 1594 e->ignore();
1594 break; 1595 break;
1595 } 1596 }
1596} 1597}
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h
index a29a1a8..bf861ef 100644
--- a/korganizer/komonthview.h
+++ b/korganizer/komonthview.h
@@ -1,295 +1,297 @@
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 <qwidgetstack.h> 28#include <qwidgetstack.h>
29#include <qlayout.h> 29#include <qlayout.h>
30#include <qintdict.h> 30#include <qintdict.h>
31#include <qpushbutton.h> 31#include <qpushbutton.h>
32#include <qvaluelist.h> 32#include <qvaluelist.h>
33#include <qptrvector.h> 33#include <qptrvector.h>
34 34
35#include <libkcal/calendar.h> 35#include <libkcal/calendar.h>
36#include <libkcal/event.h> 36#include <libkcal/event.h>
37 37
38#include "koeventview.h" 38#include "koeventview.h"
39#include "navigatorbar.h"
39 40
40#ifdef DESKTOP_VERSION 41#ifdef DESKTOP_VERSION
41class QToolTipGroup; 42class QToolTipGroup;
42#endif 43#endif
43 44
44class KNOWhatsThis; 45class KNOWhatsThis;
45class KOWeekButton : public QPushButton 46class KOWeekButton : public QPushButton
46{ 47{
47 Q_OBJECT 48 Q_OBJECT
48 public: 49 public:
49 KOWeekButton( QWidget *parent=0, const char *name=0 ) : 50 KOWeekButton( QWidget *parent=0, const char *name=0 ) :
50 QPushButton( parent, name) 51 QPushButton( parent, name)
51 { 52 {
52 connect( this, SIGNAL( clicked() ), 53 connect( this, SIGNAL( clicked() ),
53 SLOT( bottonClicked() )); 54 SLOT( bottonClicked() ));
54 mNumber = -1; 55 mNumber = -1;
55 } 56 }
56 void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));} 57 void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));}
57 int getWeekNum() { return mNumber;} 58 int getWeekNum() { return mNumber;}
58 signals: 59 signals:
59 void selectWeekNum ( int ); 60 void selectWeekNum ( int );
60private: 61private:
61 int mNumber; 62 int mNumber;
62private slots : 63private slots :
63 void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); } 64 void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); }
64}; 65};
65 66
66class KNoScrollListBox: public QListBox 67class KNoScrollListBox: public QListBox
67{ 68{
68 Q_OBJECT 69 Q_OBJECT
69 public: 70 public:
70 KNoScrollListBox(QWidget *parent=0, const char *name=0); 71 KNoScrollListBox(QWidget *parent=0, const char *name=0);
71 ~KNoScrollListBox(); 72 ~KNoScrollListBox();
72 QString getWhatsThisText(QPoint p) ; 73 QString getWhatsThisText(QPoint p) ;
73 74
74 signals: 75 signals:
75 void shiftDown(); 76 void shiftDown();
76 void shiftUp(); 77 void shiftUp();
77 void rightClick(); 78 void rightClick();
78 79
79 protected slots: 80 protected slots:
80 void oneDown(); 81 void oneDown();
81 void keyPressEvent(QKeyEvent *); 82 void keyPressEvent(QKeyEvent *);
82 void keyReleaseEvent(QKeyEvent *); 83 void keyReleaseEvent(QKeyEvent *);
83 void mousePressEvent(QMouseEvent *); 84 void mousePressEvent(QMouseEvent *);
84 85
85 private: 86 private:
86 KNOWhatsThis * mWT; 87 KNOWhatsThis * mWT;
87}; 88};
88 89
89 90
90class MonthViewItem: public QListBoxItem 91class MonthViewItem: public QListBoxItem
91{ 92{
92 public: 93 public:
93 MonthViewItem( Incidence *, QDate qd, const QString & title ); 94 MonthViewItem( Incidence *, QDate qd, const QString & title );
94 95
95 void setRecur(bool on) { mRecur = on; } 96 void setRecur(bool on) { mRecur = on; }
96 void setAlarm(bool on) { mAlarm = on; } 97 void setAlarm(bool on) { mAlarm = on; }
97 void setReply(bool on) { mReply = on; } 98 void setReply(bool on) { mReply = on; }
98 void setMoreInfo(bool on) { mInfo = on; } 99 void setMoreInfo(bool on) { mInfo = on; }
99 100
100 101
101 void setPalette(const QPalette &p) { mPalette = p; } 102 void setPalette(const QPalette &p) { mPalette = p; }
102 QPalette palette() const { return mPalette; } 103 QPalette palette() const { return mPalette; }
103 104
104 Incidence *incidence() const { return mIncidence; } 105 Incidence *incidence() const { return mIncidence; }
105 QDate incidenceDate() { return mDate; } 106 QDate incidenceDate() { return mDate; }
106 107
107 protected: 108 protected:
108 virtual void paint(QPainter *); 109 virtual void paint(QPainter *);
109 virtual int height(const QListBox *) const; 110 virtual int height(const QListBox *) const;
110 virtual int width(const QListBox *) const; 111 virtual int width(const QListBox *) const;
111 112
112 private: 113 private:
113 bool mRecur; 114 bool mRecur;
114 bool mAlarm; 115 bool mAlarm;
115 bool mReply; 116 bool mReply;
116 bool mInfo; 117 bool mInfo;
117 118
118 QPalette mPalette; 119 QPalette mPalette;
119 QDate mDate; 120 QDate mDate;
120 121
121 Incidence *mIncidence; 122 Incidence *mIncidence;
122}; 123};
123 124
124 125
125class KOMonthView; 126class KOMonthView;
126 127
127class MonthViewCell : public QWidget 128class MonthViewCell : public QWidget
128{ 129{
129 Q_OBJECT 130 Q_OBJECT
130 public: 131 public:
131 MonthViewCell(KOMonthView *,QWidget* ); 132 MonthViewCell(KOMonthView *,QWidget* );
132 133
133 void setDate( const QDate & ); 134 void setDate( const QDate & );
134 QDate date() const; 135 QDate date() const;
135 136
136 void setPrimary( bool ); 137 void setPrimary( bool );
137 bool isPrimary() const; 138 bool isPrimary() const;
138 139
139 void setHoliday( bool ); 140 void setHoliday( bool );
140 void setHoliday( const QString & ); 141 void setHoliday( const QString & );
141 142
142 void updateCell(); 143 void updateCell();
143 void startUpdateCell(); 144 void startUpdateCell();
144 void finishUpdateCell(); 145 void finishUpdateCell();
145 void insertEvent(Event *); 146 void insertEvent(Event *);
146 void insertTodo(Todo *); 147 void insertTodo(Todo *);
147 148
148 void updateConfig( bool bigFont = false ); 149 void updateConfig( bool bigFont = false );
149 150
150 void enableScrollBars( bool ); 151 void enableScrollBars( bool );
151 152
152 Incidence *selectedIncidence(); 153 Incidence *selectedIncidence();
153 QDate selectedIncidenceDate(); 154 QDate selectedIncidenceDate();
154 155
155 void deselect(); 156 void deselect();
156 void select(); 157 void select();
157 158
158#ifdef DESKTOP_VERSION 159#ifdef DESKTOP_VERSION
159 static QToolTipGroup *toolTipGroup(); 160 static QToolTipGroup *toolTipGroup();
160#endif 161#endif
161 signals: 162 signals:
162 void defaultAction( Incidence * ); 163 void defaultAction( Incidence * );
163 void newEventSignal( QDateTime ); 164 void newEventSignal( QDateTime );
164 void showDaySignal( QDate ); 165 void showDaySignal( QDate );
165 166
166 protected: 167 protected:
167 QString mToolTip; 168 QString mToolTip;
168 void resizeEvent( QResizeEvent * ); 169 void resizeEvent( QResizeEvent * );
169 170
170 protected slots: 171 protected slots:
171 void defaultAction( QListBoxItem * ); 172 void defaultAction( QListBoxItem * );
172 void contextMenu( QListBoxItem * ); 173 void contextMenu( QListBoxItem * );
173 void selection( QListBoxItem * ); 174 void selection( QListBoxItem * );
174 void cellClicked( QListBoxItem * ); 175 void cellClicked( QListBoxItem * );
175 void newEvent(); 176 void newEvent();
176 void showDay(); 177 void showDay();
177 178
178 private: 179 private:
179 KOMonthView *mMonthView; 180 KOMonthView *mMonthView;
180 181
181 QDate mDate; 182 QDate mDate;
182 bool mPrimary; 183 bool mPrimary;
183 bool mHoliday; 184 bool mHoliday;
184 QString mHolidayString; 185 QString mHolidayString;
185 186
186 //QLabel *mLabel; 187 //QLabel *mLabel;
187 QPushButton *mLabel; 188 QPushButton *mLabel;
188 QListBox *mItemList; 189 QListBox *mItemList;
189#ifdef DESKTOP_VERSION 190#ifdef DESKTOP_VERSION
190 static QToolTipGroup *mToolTipGroup; 191 static QToolTipGroup *mToolTipGroup;
191#endif 192#endif
192 QSize mLabelSize; 193 QSize mLabelSize;
193 QSize mLabelBigSize; 194 QSize mLabelBigSize;
194 QPalette mHolidayPalette; 195 QPalette mHolidayPalette;
195 QPalette mStandardPalette; 196 QPalette mStandardPalette;
196 QPalette mPrimaryPalette; 197 QPalette mPrimaryPalette;
197 QPalette mNonPrimaryPalette; 198 QPalette mNonPrimaryPalette;
198 void setMyPalette(); 199 void setMyPalette();
199 QPalette getPalette (); 200 QPalette getPalette ();
200 void keyPressEvent ( QKeyEvent * ) ; 201 void keyPressEvent ( QKeyEvent * ) ;
201 202
202}; 203};
203 204
204 205
205class KOMonthView: public KOEventView 206class KOMonthView: public KOEventView
206{ 207{
207 Q_OBJECT 208 Q_OBJECT
208 public: 209 public:
209 KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 ); 210 KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 );
210 ~KOMonthView(); 211 ~KOMonthView();
211 212
212 /** Returns maximum number of days supported by the komonthview */ 213 /** Returns maximum number of days supported by the komonthview */
213 virtual int maxDatesHint(); 214 virtual int maxDatesHint();
214 215
215 /** Returns number of currently shown dates. */ 216 /** Returns number of currently shown dates. */
216 virtual int currentDateCount(); 217 virtual int currentDateCount();
217 218
218 /** returns the currently selected events */ 219 /** returns the currently selected events */
219 virtual QPtrList<Incidence> selectedIncidences(); 220 virtual QPtrList<Incidence> selectedIncidences();
220 221
221 /** returns dates of the currently selected events */ 222 /** returns dates of the currently selected events */
222 virtual DateList selectedDates(); 223 virtual DateList selectedDates();
223 224
224 virtual void printPreview(CalPrinter *calPrinter, 225 virtual void printPreview(CalPrinter *calPrinter,
225 const QDate &, const QDate &); 226 const QDate &, const QDate &);
226 bool isMonthView() { return true; } 227 bool isMonthView() { return true; }
227 bool isUpdatePossible() { return updatePossible; } 228 bool isUpdatePossible() { return updatePossible; }
228 229
229 MonthViewCell * selectedCell(); 230 MonthViewCell * selectedCell();
230 bool skipResize; 231 bool skipResize;
232 NavigatorBar* navigatorBar() { return mNavigatorBar ;}
231 public slots: 233 public slots:
232 virtual void updateView(); 234 virtual void updateView();
233 virtual void updateConfig(); 235 virtual void updateConfig();
234 virtual void showDates(const QDate &start, const QDate &end); 236 virtual void showDates(const QDate &start, const QDate &end);
235 virtual void showEvents(QPtrList<Event> eventList); 237 virtual void showEvents(QPtrList<Event> eventList);
236 238
237 void changeEventDisplay(Event *, int); 239 void changeEventDisplay(Event *, int);
238 240
239 void clearSelection(); 241 void clearSelection();
240 242
241 void showContextMenu( Incidence * ); 243 void showContextMenu( Incidence * );
242 244
243 void setSelectedCell( MonthViewCell * ); 245 void setSelectedCell( MonthViewCell * );
244 246
245 protected slots: 247 protected slots:
246 void selectInternalWeekNum ( int ); 248 void selectInternalWeekNum ( int );
247 void switchView(); 249 void switchView();
248 void processSelectionChange(); 250 void processSelectionChange();
249 signals: 251 signals:
250 void nextMonth(); 252 void nextMonth();
251 void prevMonth(); 253 void prevMonth();
252 void showNavigator( bool );
253 void selectWeekNum ( int ); 254 void selectWeekNum ( int );
254 void showDaySignal( QDate ); 255 void showDaySignal( QDate );
255 protected: 256 protected:
256 void resizeEvent(QResizeEvent *); 257 void resizeEvent(QResizeEvent *);
257 void viewChanged(); 258 void viewChanged();
258 void updateDayLabels(); 259 void updateDayLabels();
259 260
260 private: 261 private:
262 NavigatorBar* mNavigatorBar;
261 int currentWeek(); 263 int currentWeek();
262 bool clPending; 264 bool clPending;
263 QWidgetStack * mWidStack; 265 QWidgetStack * mWidStack;
264 QWidget* mMonthView; 266 QWidget* mMonthView;
265 QWidget* mWeekView; 267 QWidget* mWeekView;
266 bool mShowWeekView; 268 bool mShowWeekView;
267 bool updatePossible; 269 bool updatePossible;
268 int mDaysPerWeek; 270 int mDaysPerWeek;
269 int mNumWeeks; 271 int mNumWeeks;
270 int mNumCells; 272 int mNumCells;
271 bool mWeekStartsMonday; 273 bool mWeekStartsMonday;
272 bool mShowSatSunComp; 274 bool mShowSatSunComp;
273 void computeLayout(); 275 void computeLayout();
274 void computeLayoutWeek(); 276 void computeLayoutWeek();
275 277
276 QPtrVector<MonthViewCell> mCells; 278 QPtrVector<MonthViewCell> mCells;
277 QPtrVector<QLabel> mDayLabels; 279 QPtrVector<QLabel> mDayLabels;
278 QPtrVector<KOWeekButton> mWeekLabels; 280 QPtrVector<KOWeekButton> mWeekLabels;
279 QPtrVector<MonthViewCell> mCellsW; 281 QPtrVector<MonthViewCell> mCellsW;
280 QPtrVector<QLabel> mDayLabelsW; 282 QPtrVector<QLabel> mDayLabelsW;
281 QPtrVector<KOWeekButton> mWeekLabelsW; 283 QPtrVector<KOWeekButton> mWeekLabelsW;
282 284
283 bool mShortDayLabels; 285 bool mShortDayLabels;
284 int mWidthLongDayLabel; 286 int mWidthLongDayLabel;
285 287
286 QDate mStartDate; 288 QDate mStartDate;
287 289
288 MonthViewCell *mSelectedCell; 290 MonthViewCell *mSelectedCell;
289 291
290 KOEventPopupMenu *mContextMenu; 292 KOEventPopupMenu *mContextMenu;
291 void keyPressEvent ( QKeyEvent * ) ; 293 void keyPressEvent ( QKeyEvent * ) ;
292 294
293}; 295};
294 296
295#endif 297#endif
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp
index ba15f7f..b551e2a 100644
--- a/korganizer/koviewmanager.cpp
+++ b/korganizer/koviewmanager.cpp
@@ -1,666 +1,667 @@
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::showDateView( int view, QDate date) 101void KOViewManager::showDateView( int view, QDate date)
102{ 102{
103 static int lastMode = 0; 103 static int lastMode = 0;
104 static int lastCount = 0; 104 static int lastCount = 0;
105 static bool lastNDMode = false; 105 static bool lastNDMode = false;
106 static QDate lastDate; 106 static QDate lastDate;
107 //qDebug("date %d %s", view, date.toString().latin1()); 107 //qDebug("date %d %s", view, date.toString().latin1());
108 108
109 //qDebug("%d %d ", lastNDMode, mFlagShowNextxDays ); 109 //qDebug("%d %d ", lastNDMode, mFlagShowNextxDays );
110 bool savemFlagShowNextxDays = mFlagShowNextxDays; 110 bool savemFlagShowNextxDays = mFlagShowNextxDays;
111 mFlagShowNextxDays = false; 111 mFlagShowNextxDays = false;
112 if ( view == 3 ) { 112 if ( view == 3 ) {
113 //mCurrentAgendaView = 1 ; 113 //mCurrentAgendaView = 1 ;
114 lastDate = mMainView->dateNavigator()->selectedDates().first(); 114 lastDate = mMainView->dateNavigator()->selectedDates().first();
115 lastCount = mMainView->dateNavigator()->selectedDates().count(); 115 lastCount = mMainView->dateNavigator()->selectedDates().count();
116 lastNDMode = savemFlagShowNextxDays; 116 lastNDMode = savemFlagShowNextxDays;
117 mMainView->showDay( date ); 117 mMainView->showDay( date );
118 } else if (view == 4 ) { 118 } else if (view == 4 ) {
119 mCurrentAgendaView = 7 ; 119 mCurrentAgendaView = 7 ;
120 mMainView->dateNavigator()->selectDates( date, 7 ); 120 mMainView->dateNavigator()->selectDates( date, 7 );
121 } else if (view == 5 ) { 121 } else if (view == 5 ) {
122 mCurrentAgendaView = 14 ; 122 mCurrentAgendaView = 14 ;
123 mMainView->dateNavigator()->selectDates( date, 14); 123 mMainView->dateNavigator()->selectDates( date, 14);
124 } else if (view == 6 ) { 124 } else if (view == 6 ) {
125 //mMainView->dateNavigator()->selectDates( date, 7 ); 125 //mMainView->dateNavigator()->selectDates( date, 7 );
126 showMonthView(); 126 showMonthView();
127 } else if (view == 7 ) { 127 } else if (view == 7 ) {
128 mMainView->dateNavigator()->selectDate( date ); 128 mMainView->dateNavigator()->selectDate( date );
129 showJournalView(); 129 showJournalView();
130 } else if (view == 8 ) { 130 } else if (view == 8 ) {
131 globalFlagBlockAgenda = 1; 131 globalFlagBlockAgenda = 1;
132 if ( mCurrentAgendaView != 3 ) 132 if ( mCurrentAgendaView != 3 )
133 mCurrentAgendaView = -1; 133 mCurrentAgendaView = -1;
134 showAgendaView(KOPrefs::instance()->mFullViewMonth); 134 showAgendaView(KOPrefs::instance()->mFullViewMonth);
135 globalFlagBlockAgenda = 2; 135 globalFlagBlockAgenda = 2;
136 mMainView->dateNavigator()->selectDates( date , 136 mMainView->dateNavigator()->selectDates( date ,
137 KOPrefs::instance()->mNextXDays ); 137 KOPrefs::instance()->mNextXDays );
138 mFlagShowNextxDays = true; 138 mFlagShowNextxDays = true;
139 mCurrentAgendaView = 3 ; 139 mCurrentAgendaView = 3 ;
140 } if (view == 9) { // return behaviour, for getting back from mode == 3 (single day mode ) 140 } if (view == 9) { // return behaviour, for getting back from mode == 3 (single day mode )
141 if ( lastMode ) { 141 if ( lastMode ) {
142 mCurrentAgendaView = lastCount ; 142 mCurrentAgendaView = lastCount ;
143 mMainView->dateNavigator()->selectDates( lastDate, lastCount); 143 mMainView->dateNavigator()->selectDates( lastDate, lastCount);
144 mFlagShowNextxDays = lastNDMode; 144 mFlagShowNextxDays = lastNDMode;
145 if ( mFlagShowNextxDays ) { 145 if ( mFlagShowNextxDays ) {
146 mCurrentAgendaView = 3 ; 146 mCurrentAgendaView = 3 ;
147 } 147 }
148 } else 148 } else
149 showWeekView(); 149 showWeekView();
150 } else if (view == 10) { 150 } else if (view == 10) {
151 mMainView->dateNavigator()->selectDates( date,mMainView->dateNavigator()->selectedDates().count() ); 151 mMainView->dateNavigator()->selectDates( date,mMainView->dateNavigator()->selectedDates().count() );
152 } 152 }
153 lastMode = view; 153 lastMode = view;
154} 154}
155 155
156 156
157 157
158void KOViewManager::writeSettings(KConfig *config) 158void KOViewManager::writeSettings(KConfig *config)
159{ 159{
160 config->setGroup("General"); 160 config->setGroup("General");
161 161
162 QString view; 162 QString view;
163 if (mCurrentView == mWhatsNextView) view = "WhatsNext"; 163 if (mCurrentView == mWhatsNextView) view = "WhatsNext";
164 else if (mCurrentView == mMonthView) view = "Month"; 164 else if (mCurrentView == mMonthView) view = "Month";
165 else if (mCurrentView == mListView) view = "List"; 165 else if (mCurrentView == mListView) view = "List";
166 else if (mCurrentView == mJournalView) view = "Journal"; 166 else if (mCurrentView == mJournalView) view = "Journal";
167 else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; 167 else if (mCurrentView == mTimeSpanView) view = "TimeSpan";
168 else if (mCurrentView == mTodoView) view = "Todo"; 168 else if (mCurrentView == mTodoView) view = "Todo";
169 else view = "Agenda"; 169 else view = "Agenda";
170 170
171 config->writeEntry("Current View",view); 171 config->writeEntry("Current View",view);
172 172
173 if (mAgendaView) { 173 if (mAgendaView) {
174 mAgendaView->writeSettings(config); 174 mAgendaView->writeSettings(config);
175 } 175 }
176 if (mTimeSpanView) { 176 if (mTimeSpanView) {
177 mTimeSpanView->writeSettings(config); 177 mTimeSpanView->writeSettings(config);
178 } 178 }
179 if (mListView) { 179 if (mListView) {
180 mListView->writeSettings(config); 180 mListView->writeSettings(config);
181 } 181 }
182 if (mTodoView) { 182 if (mTodoView) {
183 mTodoView->saveLayout(config,"Todo View"); 183 mTodoView->saveLayout(config,"Todo View");
184 } 184 }
185} 185}
186 186
187void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) 187void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen )
188{ 188{
189 189
190 //mFlagShowNextxDays = false; 190 //mFlagShowNextxDays = false;
191 //if(view == mCurrentView) return; 191 //if(view == mCurrentView) return;
192 if ( view == 0 ) { 192 if ( view == 0 ) {
193 view = mCurrentView; 193 view = mCurrentView;
194 if ( view == 0 ) 194 if ( view == 0 )
195 return; 195 return;
196 } 196 }
197 bool full = fullScreen; 197 bool full = fullScreen;
198 if(view == mCurrentView && view != mWhatsNextView ) { 198 if(view == mCurrentView && view != mWhatsNextView ) {
199 if ( mCurrentAgendaView < 0 ) 199 if ( mCurrentAgendaView < 0 )
200 return; 200 return;
201 full = mMainView->leftFrame()->isVisible(); 201 full = mMainView->leftFrame()->isVisible();
202 } else { 202 } else {
203 if ( view == mMonthView && mMonthView) 203 if ( view == mMonthView && mMonthView)
204 mMonthView->skipResize = true ; 204 ;//mMonthView->skipResize = true ;
205 mCurrentView = view; 205 mCurrentView = view;
206 // bool full = fullScreen; 206 // bool full = fullScreen;
207 bool isFull = !mMainView->leftFrame()->isVisible(); 207 bool isFull = !mMainView->leftFrame()->isVisible();
208 if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) 208 if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen )
209 full = true; 209 full = true;
210 if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) 210 if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen )
211 full = false; 211 full = false;
212 } 212 }
213 if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); 213 if ( mAgendaView ) mAgendaView->deleteSelectedDateTime();
214 //raiseCurrentView( full ); 214 //raiseCurrentView( full );
215 mMainView->processIncidenceSelection( 0 ); 215 mMainView->processIncidenceSelection( 0 );
216 //mMainView->updateView(); 216 //mMainView->updateView();
217 raiseCurrentView( full, true ); 217 raiseCurrentView( full, true );
218 mMainView->adaptNavigationUnits(); 218 mMainView->adaptNavigationUnits();
219} 219}
220 220
221void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView ) 221void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView )
222{ 222{
223 mCurrentAgendaView = 0; 223 mCurrentAgendaView = 0;
224 int wid = mMainView->width() ;
225 int hei = mMainView->height();
226 if ( mCurrentView == mMonthView ) {
227 if ( true /* !KOPrefs::instance()->mMonthViewWeek*/ ) {
228 mMainView->navigatorBar()->show();
229 hei -= mMainView->navigatorBar()->sizeHint().height();
230 }
231 //mMainView->navigatorBar()->hide();
232 } else {
233 mMainView->navigatorBar()->hide();
234 }
235 if ( fullScreen ) { 224 if ( fullScreen ) {
236 mMainView->leftFrame()->hide(); 225 mMainView->leftFrame()->hide();
237 } else { 226 } else {
238 mMainView->leftFrame()->show(); 227 mMainView->leftFrame()->show();
239 if ( KOPrefs::instance()->mVerticalScreen )
240 hei -= mMainView->leftFrame()->height();
241 else
242 wid -= mMainView->leftFrame()->width();
243 } 228 }
244 emit signalFullScreen( !fullScreen ); 229 emit signalFullScreen( !fullScreen );
245 if ( callUpdateView ) 230 if ( callUpdateView )
246 mMainView->updateView(); 231 mMainView->updateView();
247 232
248 if ( globalFlagBlockAgenda == 5 ) { 233 if ( globalFlagBlockAgenda == 5 ) {
249 globalFlagBlockAgenda = 4; 234 globalFlagBlockAgenda = 4;
250 globalFlagBlockAgendaItemPaint = 1; 235 globalFlagBlockAgendaItemPaint = 1;
251 } 236 }
252 mMainView->viewStack()->raiseWidget(mCurrentView); 237 mMainView->viewStack()->raiseWidget(mCurrentView);
253 if ( globalFlagBlockAgenda == 4 ) { 238 if ( globalFlagBlockAgenda == 4 ) {
254 if ( mCurrentView == mAgendaView ) { 239 if ( mCurrentView == mAgendaView ) {
255 //globalFlagBlockAgenda =1 ; 240 //globalFlagBlockAgenda =1 ;
256 if ( KOPrefs::instance()->mSetTimeToDayStartAt ) 241 if ( KOPrefs::instance()->mSetTimeToDayStartAt )
257 mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins ); 242 mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins );
258 else if ( KOPrefs::instance()->mCenterOnCurrentTime ) 243 else if ( KOPrefs::instance()->mCenterOnCurrentTime )
259 mAgendaView->setStartHour( QTime::currentTime ().hour() ); 244 mAgendaView->setStartHour( QTime::currentTime ().hour() );
260 qApp->processEvents(); 245 qApp->processEvents();
261 //qDebug("qApp->processEvents() "); 246 //qDebug("qApp->processEvents() ");
262 globalFlagBlockAgenda = 0; 247 globalFlagBlockAgenda = 0;
263 mAgendaView->repaintAgenda(); 248 mAgendaView->repaintAgenda();
264 249
265 } 250 }
266 globalFlagBlockAgenda = 0; 251 globalFlagBlockAgenda = 0;
267 } 252 }
268 emit signalAgendaView( mCurrentView == mAgendaView ); 253 emit signalAgendaView( mCurrentView == mAgendaView );
269 //qDebug("raiseCurrentView ende "); 254 //qDebug("raiseCurrentView ende ");
270 255
271} 256}
272 257
273void KOViewManager::updateView() 258void KOViewManager::updateView()
274{ 259{
275 // qDebug("KOViewManager::updateView() "); 260 // qDebug("KOViewManager::updateView() ");
276 // if we are updating mTodoView, we get endless recursion 261 // if we are updating mTodoView, we get endless recursion
277 if ( mTodoView == mCurrentView ) 262 if ( mTodoView == mCurrentView )
278 return; 263 return;
279 if ( mCurrentView ) mCurrentView->updateView(); 264 if ( mCurrentView ) mCurrentView->updateView();
280 265
281} 266}
282 267
283void KOViewManager::updateView(const QDate &start, const QDate &end) 268void KOViewManager::updateView(const QDate &start, const QDate &end)
284{ 269{
285 // kdDebug() << "KOViewManager::updateView()" << endl; 270 // kdDebug() << "KOViewManager::updateView()" << endl;
286 271
287 if (mCurrentView) mCurrentView->showDates(start, end); 272 if (mCurrentView) mCurrentView->showDates(start, end);
288 273
289 if (mTodoView && mTodoView == mCurrentView ) mTodoView->updateView(); 274 if (mTodoView && mTodoView == mCurrentView ) mTodoView->updateView();
290} 275}
291 276
292 277
293void KOViewManager::updateWNview() 278void KOViewManager::updateWNview()
294{ 279{
295 if ( mCurrentView == mWhatsNextView && mWhatsNextView ) 280 if ( mCurrentView == mWhatsNextView && mWhatsNextView )
296 mWhatsNextView->updateView(); 281 mWhatsNextView->updateView();
297 282
298} 283}
299void KOViewManager::showWhatsNextView() 284void KOViewManager::showWhatsNextView()
300{ 285{
301 if (!mWhatsNextView) { 286 if (!mWhatsNextView) {
302 mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(), 287 mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(),
303 "KOViewManager::WhatsNextView"); 288 "KOViewManager::WhatsNextView");
304 mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog()); 289 mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog());
305 connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig())); 290 connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig()));
306 addView(mWhatsNextView); 291 addView(mWhatsNextView);
307 connect(this, SIGNAL( printWNV() ), 292 connect(this, SIGNAL( printWNV() ),
308 mWhatsNextView, SLOT( printMe() ) ); 293 mWhatsNextView, SLOT( printMe() ) );
309 } 294 }
310 globalFlagBlockAgenda = 1; 295 globalFlagBlockAgenda = 1;
311 showView(mWhatsNextView, true ); 296 showView(mWhatsNextView, true );
312 //mWhatsNextView->updateView(); 297 //mWhatsNextView->updateView();
313 298
314} 299}
315 300
316void KOViewManager::showListView() 301void KOViewManager::showListView()
317{ 302{
318 if (!mListView) { 303 if (!mListView) {
319 mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView"); 304 mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView");
320 addView(mListView); 305 addView(mListView);
321 306
322 connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)), 307 connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)),
323 mMainView, SLOT(showIncidence(Incidence *))); 308 mMainView, SLOT(showIncidence(Incidence *)));
324 connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)), 309 connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)),
325 mMainView, SLOT(editIncidence(Incidence *))); 310 mMainView, SLOT(editIncidence(Incidence *)));
326 connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)), 311 connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)),
327 mMainView, SLOT(deleteIncidence(Incidence *))); 312 mMainView, SLOT(deleteIncidence(Incidence *)));
328 connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ), 313 connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ),
329 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 314 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
330 connect( mListView, SIGNAL( signalNewEvent() ), 315 connect( mListView, SIGNAL( signalNewEvent() ),
331 mMainView, SLOT( newEvent() ) ); 316 mMainView, SLOT( newEvent() ) );
332 connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig())); 317 connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig()));
333 connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), 318 connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ),
334 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 319 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
335 connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), 320 connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ),
336 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 321 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
337 connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 322 connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
338 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 323 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
339 connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 324 connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
340 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 325 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
341 } 326 }
342 // bool temp = mFlagShowNextxDays; 327 // bool temp = mFlagShowNextxDays;
343 //globalFlagBlockPainting = true; 328 //globalFlagBlockPainting = true;
344 globalFlagBlockAgenda = 1; 329 globalFlagBlockAgenda = 1;
345 if ( KOPrefs::instance()->mListViewMonthTimespan ) { 330 if ( KOPrefs::instance()->mListViewMonthTimespan ) {
346 mMainView->setBlockShowDates( true ); 331 mMainView->setBlockShowDates( true );
347 mMainView->dateNavigator()->selectMonth(); 332 mMainView->dateNavigator()->selectMonth();
348 mMainView->setBlockShowDates( false ); 333 mMainView->setBlockShowDates( false );
349 } 334 }
350 showView(mListView, KOPrefs::instance()->mFullViewTodo); 335 showView(mListView, KOPrefs::instance()->mFullViewTodo);
351 //mFlagShowNextxDays = temp; 336 //mFlagShowNextxDays = temp;
352} 337}
353 338
354void KOViewManager::showAgendaView( bool fullScreen ) 339void KOViewManager::showAgendaView( bool fullScreen )
355{ 340{
356 341
357 mMainView->dialogManager()->hideSearchDialog(); 342 mMainView->dialogManager()->hideSearchDialog();
358 // qDebug("KOViewManager::showAgendaView "); 343 // qDebug("KOViewManager::showAgendaView ");
359 bool full; 344 bool full;
360 full = fullScreen; 345 full = fullScreen;
361 if (!mAgendaView) { 346 if (!mAgendaView) {
362 full = false; 347 full = false;
363 mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView"); 348 mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView");
364 addView(mAgendaView); 349 addView(mAgendaView);
365#ifndef DESKTOP_VERSION 350#ifndef DESKTOP_VERSION
366 QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold ); 351 QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold );
367#endif 352#endif
368 connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )), 353 connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )),
369 mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) )); 354 mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) ));
370 355
371 // SIGNALS/SLOTS FOR DAY/WEEK VIEW 356 // SIGNALS/SLOTS FOR DAY/WEEK VIEW
372 357
373 connect(mAgendaView,SIGNAL(showDateView( int, QDate )),SLOT(showDateView( int, QDate ))); 358 connect(mAgendaView,SIGNAL(showDateView( int, QDate )),SLOT(showDateView( int, QDate )));
374 359
375 connect(mAgendaView,SIGNAL(newTodoSignal(QDateTime,bool)), 360 connect(mAgendaView,SIGNAL(newTodoSignal(QDateTime,bool)),
376 mMainView, SLOT(newTodoDateTime(QDateTime,bool))); 361 mMainView, SLOT(newTodoDateTime(QDateTime,bool)));
377 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)), 362 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)),
378 mMainView, SLOT(newEvent(QDateTime))); 363 mMainView, SLOT(newEvent(QDateTime)));
379 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)), 364 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)),
380 mMainView, SLOT(newEvent(QDateTime,QDateTime))); 365 mMainView, SLOT(newEvent(QDateTime,QDateTime)));
381 connect(mAgendaView,SIGNAL(newEventSignal(QDate)), 366 connect(mAgendaView,SIGNAL(newEventSignal(QDate)),
382 mMainView, SLOT(newEvent(QDate))); 367 mMainView, SLOT(newEvent(QDate)));
383 368
384 connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)), 369 connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)),
385 mMainView, SLOT(editIncidence(Incidence *))); 370 mMainView, SLOT(editIncidence(Incidence *)));
386 connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)), 371 connect(mAgendaView, SIGNAL(showIncidenceSignal(Incidence *)),
387 mMainView, SLOT(showIncidence(Incidence *))); 372 mMainView, SLOT(showIncidence(Incidence *)));
388 connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)), 373 connect(mAgendaView, SIGNAL(deleteIncidenceSignal(Incidence *)),
389 mMainView, SLOT(deleteIncidence(Incidence *))); 374 mMainView, SLOT(deleteIncidence(Incidence *)));
390 375
391 connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ), 376 connect( mAgendaView, SIGNAL( incidenceSelected( Incidence * ) ),
392 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 377 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
393 378
394 connect(mAgendaView, SIGNAL( toggleExpand() ), 379 connect(mAgendaView, SIGNAL( toggleExpand() ),
395 mMainView, SLOT( toggleExpand() ) ); 380 mMainView, SLOT( toggleExpand() ) );
396 381
397 connect(mMainView, SIGNAL( calendarViewExpanded( bool ) ), 382 connect(mMainView, SIGNAL( calendarViewExpanded( bool ) ),
398 mAgendaView, SLOT( setExpandedButton( bool ) ) ); 383 mAgendaView, SLOT( setExpandedButton( bool ) ) );
399 connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ), 384 connect( mAgendaView, SIGNAL( cloneIncidenceSignal(Incidence *) ),
400 mMainView, SLOT(cloneIncidence(Incidence *) ) ) ; 385 mMainView, SLOT(cloneIncidence(Incidence *) ) ) ;
401 connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ), 386 connect( mAgendaView, SIGNAL( cancelIncidenceSignal(Incidence *) ),
402 mMainView, SLOT(cancelIncidence(Incidence *) ) ) ; 387 mMainView, SLOT(cancelIncidence(Incidence *) ) ) ;
403 connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig())); 388 connect(mMainView, SIGNAL(configChanged()), mAgendaView, SLOT(updateConfig()));
404 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView, 389 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mAgendaView,
405 SLOT( updateTodo( Todo *, int ) ) ); 390 SLOT( updateTodo( Todo *, int ) ) );
406 connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )), 391 connect( mAgendaView,SIGNAL( todoMoved( Todo *, int )),
407 mMainView, SIGNAL( todoModified( Todo *, int ))); 392 mMainView, SIGNAL( todoModified( Todo *, int )));
408 connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 393 connect( mAgendaView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
409 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 394 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
410 connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 395 connect( mAgendaView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
411 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 396 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
412 connect( mAgendaView, SIGNAL( selectWeekNum( int ) ), 397 connect( mAgendaView, SIGNAL( selectWeekNum( int ) ),
413 mMainView->dateNavigator(), SLOT ( selectWeek( int ) ) ); 398 mMainView->dateNavigator(), SLOT ( selectWeek( int ) ) );
414 mAgendaView->readSettings(); 399 mAgendaView->readSettings();
415 mAgendaView->updateConfig(); 400 mAgendaView->updateConfig();
416 } 401 }
417 402
418 showView( mAgendaView, full); 403 showView( mAgendaView, full);
419 404
420} 405}
421 406
422void KOViewManager::showDayView() 407void KOViewManager::showDayView()
423{ 408{
424 mFlagShowNextxDays = false; 409 mFlagShowNextxDays = false;
425 globalFlagBlockLabel = 1; 410 globalFlagBlockLabel = 1;
426 globalFlagBlockAgenda = 1; 411 globalFlagBlockAgenda = 1;
427 if ( mCurrentAgendaView != 1 ) 412 if ( mCurrentAgendaView != 1 )
428 mCurrentAgendaView = -1; 413 mCurrentAgendaView = -1;
429 showAgendaView(); 414 showAgendaView();
430 qApp->processEvents(); 415 qApp->processEvents();
431 globalFlagBlockAgenda = 2; 416 globalFlagBlockAgenda = 2;
432 globalFlagBlockLabel = 0; 417 globalFlagBlockLabel = 0;
433 mMainView->dateNavigator()->selectDates( 1 ); 418 mMainView->dateNavigator()->selectDates( 1 );
434 mCurrentAgendaView = 1 ; 419 mCurrentAgendaView = 1 ;
435 420
436} 421}
437 422
438void KOViewManager::showWorkWeekView() 423void KOViewManager::showWorkWeekView()
439{ 424{
440 mFlagShowNextxDays = false; 425 mFlagShowNextxDays = false;
441 globalFlagBlockAgenda = 1; 426 globalFlagBlockAgenda = 1;
442 globalFlagBlockLabel = 1; 427 globalFlagBlockLabel = 1;
443 if ( mCurrentAgendaView != 5 ) 428 if ( mCurrentAgendaView != 5 )
444 mCurrentAgendaView = -1; 429 mCurrentAgendaView = -1;
445 showAgendaView(); 430 showAgendaView();
446 qApp->processEvents(); 431 qApp->processEvents();
447 globalFlagBlockAgenda = 2; 432 globalFlagBlockAgenda = 2;
448 globalFlagBlockLabel = 0; 433 globalFlagBlockLabel = 0;
449 mMainView->dateNavigator()->selectWorkWeek(); 434 mMainView->dateNavigator()->selectWorkWeek();
450 mCurrentAgendaView = 5 ; 435 mCurrentAgendaView = 5 ;
451 436
452} 437}
453 438
454void KOViewManager::showWeekView() 439void KOViewManager::showWeekView()
455{ 440{
456 /* 441 /*
457 globalFlagBlockAgenda = 2; 442 globalFlagBlockAgenda = 2;
458 qDebug("4globalFlagBlockAgenda = 2; "); 443 qDebug("4globalFlagBlockAgenda = 2; ");
459 //globalFlagBlockPainting = true; 444 //globalFlagBlockPainting = true;
460 mMainView->dateNavigator()->selectWeek(); 445 mMainView->dateNavigator()->selectWeek();
461 showAgendaView(); 446 showAgendaView();
462 */ 447 */
463 448
464 449
465 mFlagShowNextxDays = false; 450 mFlagShowNextxDays = false;
466 globalFlagBlockAgenda = 1; 451 globalFlagBlockAgenda = 1;
467 globalFlagBlockLabel = 1; 452 globalFlagBlockLabel = 1;
468 if ( mCurrentAgendaView != 7 ) 453 if ( mCurrentAgendaView != 7 )
469 mCurrentAgendaView = -1; 454 mCurrentAgendaView = -1;
470 showAgendaView(); 455 showAgendaView();
471 qApp->processEvents(); 456 qApp->processEvents();
472 globalFlagBlockAgenda = 2; 457 globalFlagBlockAgenda = 2;
473 globalFlagBlockLabel = 0; 458 globalFlagBlockLabel = 0;
474 mMainView->dateNavigator()->selectWeek(); 459 mMainView->dateNavigator()->selectWeek();
475 mCurrentAgendaView = 7 ; 460 mCurrentAgendaView = 7 ;
476} 461}
477 462
478void KOViewManager::showNextXView() 463void KOViewManager::showNextXView()
479{ 464{
480 465
481 globalFlagBlockAgenda = 1; 466 globalFlagBlockAgenda = 1;
482 if ( mCurrentAgendaView != 3 ) 467 if ( mCurrentAgendaView != 3 )
483 mCurrentAgendaView = -1; 468 mCurrentAgendaView = -1;
484 showAgendaView(KOPrefs::instance()->mFullViewMonth); 469 showAgendaView(KOPrefs::instance()->mFullViewMonth);
485 globalFlagBlockAgenda = 2; 470 globalFlagBlockAgenda = 2;
486 mMainView->dateNavigator()->selectDates( QDate::currentDate(), 471 mMainView->dateNavigator()->selectDates( QDate::currentDate(),
487 KOPrefs::instance()->mNextXDays ); 472 KOPrefs::instance()->mNextXDays );
488 mFlagShowNextxDays = true; 473 mFlagShowNextxDays = true;
489 mCurrentAgendaView = 3 ; 474 mCurrentAgendaView = 3 ;
490} 475}
491bool KOViewManager::showsNextDays() 476bool KOViewManager::showsNextDays()
492{ 477{
493 return mFlagShowNextxDays; 478 return mFlagShowNextxDays;
494} 479}
495void KOViewManager::showMonthView() 480void KOViewManager::showMonthView()
496 { 481 {
497 if (!mMonthView) { 482 if (!mMonthView) {
498 mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView"); 483 mMonthView = new KOMonthView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::MonthView");
499 484
500 addView(mMonthView); 485 addView(mMonthView);
501 // mMonthView->show(); 486 // mMonthView->show();
502 // SIGNALS/SLOTS FOR MONTH VIEW 487 // SIGNALS/SLOTS FOR MONTH VIEW
503 connect(mMonthView, SIGNAL(newEventSignal(QDateTime)), 488 connect(mMonthView, SIGNAL(newEventSignal(QDateTime)),
504 mMainView, SLOT(newEvent(QDateTime))); 489 mMainView, SLOT(newEvent(QDateTime)));
505 490
506 connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)), 491 connect(mMonthView, SIGNAL(showIncidenceSignal(Incidence *)),
507 mMainView, SLOT(showIncidence(Incidence *))); 492 mMainView, SLOT(showIncidence(Incidence *)));
508 connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)), 493 connect(mMonthView, SIGNAL(editIncidenceSignal(Incidence *)),
509 mMainView, SLOT(editIncidence(Incidence *))); 494 mMainView, SLOT(editIncidence(Incidence *)));
510 connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)), 495 connect(mMonthView, SIGNAL(deleteIncidenceSignal(Incidence *)),
511 mMainView, SLOT(deleteIncidence(Incidence *))); 496 mMainView, SLOT(deleteIncidence(Incidence *)));
512 497
513 connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ), 498 connect( mMonthView, SIGNAL( incidenceSelected( Incidence * ) ),
514 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 499 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
515 connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), 500 connect( mMonthView, SIGNAL( cloneIncidenceSignal( Incidence * ) ),
516 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 501 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
517 connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), 502 connect( mMonthView, SIGNAL( cancelIncidenceSignal( Incidence * ) ),
518 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 503 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
519 504
520 connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 505 connect( mMonthView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
521 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 506 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
522 connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 507 connect( mMonthView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
523 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 508 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
524 connect( mMonthView, SIGNAL( selectWeekNum( int ) ), 509 connect( mMonthView, SIGNAL( selectWeekNum( int ) ),
525 mMainView->dateNavigator(), SLOT ( selectWeek( int ) ) ); 510 mMainView->dateNavigator(), SLOT ( selectWeek( int ) ) );
526 connect( mMonthView, SIGNAL( showDaySignal( QDate ) ), 511 connect( mMonthView, SIGNAL( showDaySignal( QDate ) ),
527 mMainView, SLOT ( showDay( QDate ) ) ); 512 mMainView, SLOT ( showDay( QDate ) ) );
528 connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig())); 513 connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig()));
529 connect( mMonthView, SIGNAL(nextMonth() ), 514 connect( mMonthView, SIGNAL(nextMonth() ),
530 mMainView->navigatorBar(), SIGNAL(goNextMonth() ) ); 515 mMonthView->navigatorBar(), SIGNAL(goNextMonth() ) );
531 connect( mMonthView, SIGNAL(prevMonth() ), 516 connect( mMonthView, SIGNAL(prevMonth() ),
532 mMainView->navigatorBar(), SIGNAL(goPrevMonth() ) ); 517 mMonthView->navigatorBar(), SIGNAL(goPrevMonth() ) );
533 connect( mMonthView, SIGNAL( showNavigator(bool) ), 518 connect( mMonthView->navigatorBar(), SIGNAL( goPrevYear() ),
534 mMainView, SLOT ( showNavigatorBar(bool) ) ); 519 mMainView->dateNavigator(), SLOT( selectPreviousYear() ) );
520 connect( mMonthView->navigatorBar(), SIGNAL( goNextYear() ),
521 mMainView->dateNavigator(), SLOT( selectNextYear() ) );
522 connect( mMonthView->navigatorBar(), SIGNAL( goPrevMonth() ),
523 mMainView->dateNavigator(), SLOT( selectPreviousMonth() ) );
524 connect( mMonthView->navigatorBar(), SIGNAL( goNextMonth() ),
525 mMainView->dateNavigator(), SLOT( selectNextMonth() ) );
526 connect( mMonthView->navigatorBar(), SIGNAL( selectWeek( int ) ),
527 mMainView->dateNavigator(), SLOT( selectWeek( int ) ) );
528
529 connect( mMainView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ),
530 mMonthView->navigatorBar(), SLOT( selectDates( const KCal::DateList & ) ) );
531
532
533 connect( mMonthView->navigatorBar(), SIGNAL( monthSelected ( int ) ),
534 mMainView->dateNavigator(), SLOT( slotMonthSelect( int ) ) );
535
535 } 536 }
536 537
537 globalFlagBlockAgenda = 1; 538 globalFlagBlockAgenda = 1;
538 //mFlagShowNextxDays = false; 539 //mFlagShowNextxDays = false;
539 // if(mMonthView == mCurrentView) return; 540 // if(mMonthView == mCurrentView) return;
540 if ( KOPrefs::instance()->mMonthViewWeek ) 541 if ( KOPrefs::instance()->mMonthViewWeek )
541 mMainView->dateNavigator()->selectWeek(); 542 mMainView->dateNavigator()->selectWeek();
542 else 543 else
543 mMainView->dateNavigator()->selectMonth(); 544 mMainView->dateNavigator()->selectMonth();
544 545
545 showView(mMonthView, true ); 546 showView(mMonthView, true );
546 547
547} 548}
548 549
549void KOViewManager::showTodoView() 550void KOViewManager::showTodoView()
550{ 551{
551 //mFlagShowNextxDays = false; 552 //mFlagShowNextxDays = false;
552 if ( !mTodoView ) { 553 if ( !mTodoView ) {
553 mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(), 554 mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(),
554 "KOViewManager::TodoView" ); 555 "KOViewManager::TodoView" );
555 556
556 addView( mTodoView ); 557 addView( mTodoView );
557 // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold ); 558 // QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold );
558 559
559 // SIGNALS/SLOTS FOR TODO VIEW 560 // SIGNALS/SLOTS FOR TODO VIEW
560 connect( mTodoView, SIGNAL( newTodoSignal() ), 561 connect( mTodoView, SIGNAL( newTodoSignal() ),
561 mMainView, SLOT( newTodo() ) ); 562 mMainView, SLOT( newTodo() ) );
562 connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ), 563 connect( mTodoView, SIGNAL( newSubTodoSignal( Todo * ) ),
563 mMainView, SLOT( newSubTodo( Todo *) ) ); 564 mMainView, SLOT( newSubTodo( Todo *) ) );
564 connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ), 565 connect( mTodoView, SIGNAL( showTodoSignal( Todo *) ),
565 mMainView, SLOT( showTodo( Todo * ) ) ); 566 mMainView, SLOT( showTodo( Todo * ) ) );
566 connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ), 567 connect( mTodoView, SIGNAL( editTodoSignal( Todo * ) ),
567 mMainView, SLOT( editTodo( Todo * ) ) ); 568 mMainView, SLOT( editTodo( Todo * ) ) );
568 connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ), 569 connect( mTodoView, SIGNAL( deleteTodoSignal( Todo * ) ),
569 mMainView, SLOT( deleteTodo( Todo * ) ) ); 570 mMainView, SLOT( deleteTodo( Todo * ) ) );
570 connect( mTodoView, SIGNAL( purgeCompletedSignal() ), 571 connect( mTodoView, SIGNAL( purgeCompletedSignal() ),
571 mMainView, SLOT( purgeCompleted() ) ); 572 mMainView, SLOT( purgeCompleted() ) );
572 573
573 connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ), 574 connect( mTodoView, SIGNAL( incidenceSelected( Incidence * ) ),
574 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 575 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
575 576
576 connect( mMainView, SIGNAL( configChanged() ), mTodoView, 577 connect( mMainView, SIGNAL( configChanged() ), mTodoView,
577 SLOT( updateConfig() ) ); 578 SLOT( updateConfig() ) );
578 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView, 579 connect( mMainView, SIGNAL( todoModified( Todo *, int )), mTodoView,
579 SLOT( updateTodo( Todo *, int ) ) ); 580 SLOT( updateTodo( Todo *, int ) ) );
580 connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ), 581 connect( mTodoView, SIGNAL( todoModifiedSignal( Todo *, int ) ),
581 mMainView, SIGNAL ( todoModified( Todo *, int ) ) ); 582 mMainView, SIGNAL ( todoModified( Todo *, int ) ) );
582 connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ), 583 connect( mTodoView, SIGNAL( cloneTodoSignal( Incidence * ) ),
583 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 584 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
584 connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ), 585 connect( mTodoView, SIGNAL( cancelTodoSignal( Incidence * ) ),
585 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 586 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
586 connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ), 587 connect( mTodoView, SIGNAL( unparentTodoSignal( Todo * ) ),
587 mMainView, SLOT ( todo_unsub( Todo * ) ) ); 588 mMainView, SLOT ( todo_unsub( Todo * ) ) );
588 connect( mTodoView, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 589 connect( mTodoView, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
589 mMainView, SLOT ( todo_resub( Todo *, Todo *) ) ); 590 mMainView, SLOT ( todo_resub( Todo *, Todo *) ) );
590 connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ), 591 connect( mTodoView, SIGNAL( moveTodoSignal( Incidence * ) ),
591 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 592 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
592 connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ), 593 connect( mTodoView, SIGNAL( beamTodoSignal( Incidence * ) ),
593 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 594 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
594 KConfig *config = KOGlobals::config(); 595 KConfig *config = KOGlobals::config();
595 mTodoView->restoreLayout(config,"Todo View"); 596 mTodoView->restoreLayout(config,"Todo View");
596 mTodoView->setNavigator( mMainView->dateNavigator() ); 597 mTodoView->setNavigator( mMainView->dateNavigator() );
597 } 598 }
598 599
599 globalFlagBlockAgenda = 1; 600 globalFlagBlockAgenda = 1;
600 showView( mTodoView, true ); 601 showView( mTodoView, true );
601 602
602} 603}
603 604
604void KOViewManager::showJournalView() 605void KOViewManager::showJournalView()
605{ 606{
606 //mFlagShowNextxDays = false; 607 //mFlagShowNextxDays = false;
607 if (!mJournalView) { 608 if (!mJournalView) {
608 mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(), 609 mJournalView = new KOJournalView(mMainView->calendar(),mMainView->viewStack(),
609 "KOViewManager::JournalView"); 610 "KOViewManager::JournalView");
610 connect( mMainView, SIGNAL( configChanged() ), mJournalView, 611 connect( mMainView, SIGNAL( configChanged() ), mJournalView,
611 SLOT( updateConfig() ) ); 612 SLOT( updateConfig() ) );
612 connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) ); 613 connect(mJournalView, SIGNAL(deleteJournal(Journal *) ), mMainView,SLOT(deleteJournal(Journal *)) );
613 addView(mJournalView); 614 addView(mJournalView);
614 } 615 }
615 616
616 showView(mJournalView); 617 showView(mJournalView);
617 mMainView->dateNavigator()->selectDates( 1 ); 618 mMainView->dateNavigator()->selectDates( 1 );
618} 619}
619 620
620void KOViewManager::showTimeSpanView() 621void KOViewManager::showTimeSpanView()
621{ 622{
622 //mFlagShowNextxDays = false; 623 //mFlagShowNextxDays = false;
623 if (!mTimeSpanView) { 624 if (!mTimeSpanView) {
624 mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(), 625 mTimeSpanView = new KOTimeSpanView(mMainView->calendar(),mMainView->viewStack(),
625 "KOViewManager::TimeSpanView"); 626 "KOViewManager::TimeSpanView");
626 addView(mTimeSpanView); 627 addView(mTimeSpanView);
627 628
628 mTimeSpanView->readSettings(); 629 mTimeSpanView->readSettings();
629 } 630 }
630 631
631 showView(mTimeSpanView); 632 showView(mTimeSpanView);
632} 633}
633 634
634Incidence *KOViewManager::currentSelection() 635Incidence *KOViewManager::currentSelection()
635{ 636{
636 if (!mCurrentView) return 0; 637 if (!mCurrentView) return 0;
637 if ( mCurrentView == mListView ) { 638 if ( mCurrentView == mListView ) {
638 if ( mListView->currentItem() ) 639 if ( mListView->currentItem() )
639 return mListView->currentItem(); 640 return mListView->currentItem();
640 } 641 }
641 return mCurrentView->selectedIncidences().first(); 642 return mCurrentView->selectedIncidences().first();
642} 643}
643 644
644QDate KOViewManager::currentSelectionDate() 645QDate KOViewManager::currentSelectionDate()
645{ 646{
646 QDate qd; 647 QDate qd;
647 if (mCurrentView) { 648 if (mCurrentView) {
648 DateList qvl = mCurrentView->selectedDates(); 649 DateList qvl = mCurrentView->selectedDates();
649 if (!qvl.isEmpty()) qd = qvl.first(); 650 if (!qvl.isEmpty()) qd = qvl.first();
650 } 651 }
651 return qd; 652 return qd;
652} 653}
653 654
654void KOViewManager::addView(KOrg::BaseView *view) 655void KOViewManager::addView(KOrg::BaseView *view)
655{ 656{
656#if QT_VERSION >= 0x030000 657#if QT_VERSION >= 0x030000
657 mMainView->viewStack()->addWidget( view ); 658 mMainView->viewStack()->addWidget( view );
658#else 659#else
659 mMainView->viewStack()->addWidget( view, 1 ); 660 mMainView->viewStack()->addWidget( view, 1 );
660#endif 661#endif
661} 662}
662 663
663void KOViewManager::setDocumentId( const QString &id ) 664void KOViewManager::setDocumentId( const QString &id )
664{ 665{
665 if (mTodoView) mTodoView->setDocumentId( id ); 666 if (mTodoView) mTodoView->setDocumentId( id );
666} 667}
diff --git a/korganizer/navigatorbar.cpp b/korganizer/navigatorbar.cpp
index 657f98d..f05e6f6 100644
--- a/korganizer/navigatorbar.cpp
+++ b/korganizer/navigatorbar.cpp
@@ -1,201 +1,202 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24 24
25#include <qstring.h> 25#include <qstring.h>
26#include <qtooltip.h> 26#include <qtooltip.h>
27#include <qpushbutton.h> 27#include <qpushbutton.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#include <qframe.h> 29#include <qframe.h>
30#include <qlabel.h> 30#include <qlabel.h>
31#include <qpopupmenu.h> 31#include <qpopupmenu.h>
32#include <qapplication.h> 32#include <qapplication.h>
33 33
34#include <kdebug.h> 34#include <kdebug.h>
35#include <klocale.h> 35#include <klocale.h>
36#include <kglobal.h> 36#include <kglobal.h>
37#include <kiconloader.h> 37#include <kiconloader.h>
38#include "libkdepim/kdatepicker.h" 38#include "libkdepim/kdatepicker.h"
39#include <knotifyclient.h> 39#include <knotifyclient.h>
40#include "kdatetbl.h" 40#include "kdatetbl.h"
41 41
42#include "koglobals.h" 42#include "koglobals.h"
43#include "koprefs.h" 43#include "koprefs.h"
44#ifndef KORG_NOPLUGINS 44#ifndef KORG_NOPLUGINS
45#include "kocore.h" 45#include "kocore.h"
46#endif 46#endif
47 47
48#include <kcalendarsystem.h> 48#include <kcalendarsystem.h>
49 49
50#include "navigatorbar.h" 50#include "navigatorbar.h"
51 51
52NavigatorBar::NavigatorBar( const QDate & date, QWidget *parent, const char *name ) 52NavigatorBar::NavigatorBar( const QDate & date, QWidget *parent, const char *name )
53 : QWidget( parent, name ) 53 : QWidget( parent, name )
54{ 54{
55 QBoxLayout *topLayout = new QHBoxLayout( this ); 55 QBoxLayout *topLayout = new QHBoxLayout( this );
56 56
57 // Set up the control buttons and date label 57 // Set up the control buttons and date label
58 mCtrlFrame = new QFrame( this ); 58 mCtrlFrame = new QFrame( this );
59 mCtrlFrame->setFrameStyle(QFrame::Panel|QFrame::Raised); 59 mCtrlFrame->setFrameStyle(QFrame::Panel|QFrame::Raised);
60 mCtrlFrame->setLineWidth(1); 60 mCtrlFrame->setLineWidth(1);
61 61
62 topLayout->addWidget( mCtrlFrame ); 62 topLayout->addWidget( mCtrlFrame );
63 63
64 QFont tfont = font(); 64 QFont tfont = font();
65 if ( QApplication::desktop()->width() >= 480 ) 65 if ( QApplication::desktop()->width() >= 480 )
66 tfont.setPointSize(tfont.pointSize()+2); 66 tfont.setPointSize(tfont.pointSize()+2);
67 tfont.setBold(true); 67 tfont.setBold(true);
68 68
69 bool isRTL = KOGlobals::self()->reverseLayout(); 69 bool isRTL = KOGlobals::self()->reverseLayout();
70#ifndef DESKTOP_VERSION 70#ifndef DESKTOP_VERSION
71 bool isDesktop = false; 71 bool isDesktop = false;
72#else 72#else
73 bool isDesktop = true; 73 bool isDesktop = true;
74#endif 74#endif
75 if ( QString ( name ) == QString("useBigPixmaps") && QApplication::desktop()->width() > 320 ) 75 if ( QString ( name ) == QString("useBigPixmaps") && QApplication::desktop()->width() > 320 )
76 isDesktop = true; 76 isDesktop = true;
77 // Create backward navigation buttons 77 // Create backward navigation buttons
78 mPrevYear = new QPushButton( mCtrlFrame ); 78 mPrevYear = new QPushButton( mCtrlFrame );
79 mPrevYear->setPixmap( SmallIcon( isDesktop ? "2leftarrowB" : "2leftarrow" ) ); 79 mPrevYear->setPixmap( SmallIcon( isDesktop ? "2leftarrowB" : "2leftarrow" ) );
80 QToolTip::add( mPrevYear, i18n("Previous Year") ); 80 QToolTip::add( mPrevYear, i18n("Previous Year") );
81 81
82 mPrevMonth = new QPushButton( mCtrlFrame ); 82 mPrevMonth = new QPushButton( mCtrlFrame );
83 mPrevMonth->setPixmap( SmallIcon( isDesktop ? "1leftarrowB" : "1leftarrow") ); 83 mPrevMonth->setPixmap( SmallIcon( isDesktop ? "1leftarrowB" : "1leftarrow") );
84 QToolTip::add( mPrevMonth, i18n("Previous Month") ); 84 QToolTip::add( mPrevMonth, i18n("Previous Month") );
85 85
86 // Create forward navigation buttons 86 // Create forward navigation buttons
87 mNextMonth = new QPushButton( mCtrlFrame ); 87 mNextMonth = new QPushButton( mCtrlFrame );
88 mNextMonth->setPixmap( SmallIcon( isDesktop ? "1rightarrowB" : "1rightarrow") ); 88 mNextMonth->setPixmap( SmallIcon( isDesktop ? "1rightarrowB" : "1rightarrow") );
89 QToolTip::add( mNextMonth, i18n("Next Month") ); 89 QToolTip::add( mNextMonth, i18n("Next Month") );
90 90
91 mNextYear = new QPushButton( mCtrlFrame ); 91 mNextYear = new QPushButton( mCtrlFrame );
92 mNextYear->setPixmap( SmallIcon( isDesktop ? "2rightarrowB": "2rightarrow") ); 92 mNextYear->setPixmap( SmallIcon( isDesktop ? "2rightarrowB": "2rightarrow") );
93 QToolTip::add( mNextYear, i18n("Next Year") ); 93 QToolTip::add( mNextYear, i18n("Next Year") );
94 mSelectMonth = new QPushButton( mCtrlFrame ); 94 mSelectMonth = new QPushButton( mCtrlFrame );
95 // Create month name label 95 // Create month name label
96 //selectMonth->setFont( tfont ); 96 //selectMonth->setFont( tfont );
97 // selectMonth->setAlignment( AlignCenter ); 97 // selectMonth->setAlignment( AlignCenter );
98 //mDateLabel = new QLabel( selectMonth ); 98 //mDateLabel = new QLabel( selectMonth );
99 //mDateLabel->setFont( tfont ); 99 //mDateLabel->setFont( tfont );
100 //mDateLabel->setAlignment( AlignCenter ); 100 //mDateLabel->setAlignment( AlignCenter );
101 if ( QString ( name ) == QString("useBigPixmaps") ) { 101 if ( QString ( name ) == QString("useBigPixmaps") ) {
102 mNextMonth->setFlat( true); 102 mNextMonth->setFlat( true);
103 mNextYear->setFlat( true); 103 mNextYear->setFlat( true);
104 mSelectMonth->setFlat( true); 104 mSelectMonth->setFlat( true);
105 mPrevYear->setFlat( true); 105 mPrevYear->setFlat( true);
106 mPrevMonth->setFlat( true); 106 mPrevMonth->setFlat( true);
107 } 107 }
108 mSelectMonth->setFont( tfont ); 108 mSelectMonth->setFont( tfont );
109 // Set minimum width to width of widest month name label 109 // Set minimum width to width of widest month name label
110 int i; 110 int i;
111 int maxwidth = 0; 111 int maxwidth = 0;
112 QFontMetrics fm ( mSelectMonth->font() ); 112 QFontMetrics fm ( mSelectMonth->font() );
113 int width = fm.width("September '00" ); 113 int width = fm.width("September '00" );
114// for( i = 1; i <= KOGlobals::self()->calendarSystem()->monthsInYear(date); 114// for( i = 1; i <= KOGlobals::self()->calendarSystem()->monthsInYear(date);
115// ++i ) { 115// ++i ) {
116// //int width = fm.width( KOGlobals::self()->calendarSystem()->monthName(i, 116// //int width = fm.width( KOGlobals::self()->calendarSystem()->monthName(i,
117// // KOGlobals::self()->calendarSystem()->year(date) ) + " 2000" ); 117// // KOGlobals::self()->calendarSystem()->year(date) ) + " 2000" );
118// int width = fm.width("September 2000" ); 118// int width = fm.width("September 2000" );
119// if ( width > maxwidth ) maxwidth = width; 119// if ( width > maxwidth ) maxwidth = width;
120// } 120// }
121 maxwidth = width+2; 121 maxwidth = width+2;
122 int size = fm.height()+2; 122 int size = fm.height()+2;
123 if ( QApplication::desktop()->width() >= 480 ) { 123 if ( QApplication::desktop()->width() >= 480 ) {
124 size += 6; 124 size += 6;
125 maxwidth+= 6; 125 maxwidth+= 6;
126 } 126 }
127 127
128 mSelectMonth->setFixedWidth( maxwidth ); 128 mSelectMonth->setFixedWidth( maxwidth );
129 mSelectMonth->setFixedHeight( size ); 129 mSelectMonth->setFixedHeight( size );
130 mPrevYear->setFixedHeight( size ); 130 mPrevYear->setFixedHeight( size );
131 mPrevMonth->setFixedHeight( size ); 131 mPrevMonth->setFixedHeight( size );
132 mNextMonth->setFixedHeight( size ); 132 mNextMonth->setFixedHeight( size );
133 mNextYear->setFixedHeight ( size ); 133 mNextYear->setFixedHeight ( size );
134 // set up control frame layout 134 // set up control frame layout
135 QBoxLayout *ctrlLayout = new QHBoxLayout( mCtrlFrame, 1 ); 135 QBoxLayout *ctrlLayout = new QHBoxLayout( mCtrlFrame, 1 );
136 ctrlLayout->addWidget( mPrevYear, 3 ); 136 ctrlLayout->addWidget( mPrevYear, 3 );
137 ctrlLayout->addWidget( mPrevMonth, 3 ); 137 ctrlLayout->addWidget( mPrevMonth, 3 );
138 //ctrlLayout->addStretch( 1 ); 138 //ctrlLayout->addStretch( 1 );
139 // ctrlLayout->addSpacing( 1 ); 139 // ctrlLayout->addSpacing( 1 );
140 // ctrlLayout->addWidget( mDateLabel ); 140 // ctrlLayout->addWidget( mDateLabel );
141 ctrlLayout->addWidget( mSelectMonth ); 141 ctrlLayout->addWidget( mSelectMonth );
142 // ctrlLayout->addSpacing( 1 ); 142 // ctrlLayout->addSpacing( 1 );
143 // ctrlLayout->addStretch( 1 ); 143 // ctrlLayout->addStretch( 1 );
144 ctrlLayout->addWidget( mNextMonth, 3 ); 144 ctrlLayout->addWidget( mNextMonth, 3 );
145 ctrlLayout->addWidget( mNextYear, 3 ); 145 ctrlLayout->addWidget( mNextYear, 3 );
146 146
147 connect( mPrevYear, SIGNAL( clicked() ), SIGNAL( goPrevYear() ) ); 147 connect( mPrevYear, SIGNAL( clicked() ), SIGNAL( goPrevYear() ) );
148 connect( mPrevMonth, SIGNAL( clicked() ), SIGNAL( goPrevMonth() ) ); 148 connect( mPrevMonth, SIGNAL( clicked() ), SIGNAL( goPrevMonth() ) );
149 connect( mNextMonth, SIGNAL( clicked() ), SIGNAL( goNextMonth() ) ); 149 connect( mNextMonth, SIGNAL( clicked() ), SIGNAL( goNextMonth() ) );
150 connect( mNextYear, SIGNAL( clicked() ), SIGNAL( goNextYear() ) ); 150 connect( mNextYear, SIGNAL( clicked() ), SIGNAL( goNextYear() ) );
151 connect( mSelectMonth, SIGNAL( clicked() ),SLOT( selectMonth() ) ); 151 connect( mSelectMonth, SIGNAL( clicked() ),SLOT( selectMonth() ) );
152 mPrevYear->setFocusPolicy(NoFocus); 152 mPrevYear->setFocusPolicy(NoFocus);
153 mPrevMonth->setFocusPolicy(NoFocus); 153 mPrevMonth->setFocusPolicy(NoFocus);
154 mNextMonth->setFocusPolicy(NoFocus); 154 mNextMonth->setFocusPolicy(NoFocus);
155 mNextYear->setFocusPolicy(NoFocus); 155 mNextYear->setFocusPolicy(NoFocus);
156 mSelectMonth->setFocusPolicy(NoFocus); 156 mSelectMonth->setFocusPolicy(NoFocus);
157 setSizePolicy( QSizePolicy ( QSizePolicy::Expanding ,QSizePolicy::Fixed ) );
157 158
158} 159}
159 160
160NavigatorBar::~NavigatorBar() 161NavigatorBar::~NavigatorBar()
161{ 162{
162} 163}
163 164
164void NavigatorBar::selectMonth() 165void NavigatorBar::selectMonth()
165{ 166{
166 167
167 int month; 168 int month;
168 KPopupFrame* popup = new KPopupFrame(this); 169 KPopupFrame* popup = new KPopupFrame(this);
169 int size = 12; 170 int size = 12;
170 if ( QApplication::desktop()->width() >= 480 ) 171 if ( QApplication::desktop()->width() >= 480 )
171 size = 18; 172 size = 18;
172 KDateInternalMonthPicker* picker = new KDateInternalMonthPicker(size, popup); 173 KDateInternalMonthPicker* picker = new KDateInternalMonthPicker(size, popup);
173 // ----- 174 // -----
174 picker->resize(picker->sizeHint()); 175 picker->resize(picker->sizeHint());
175 popup->setMainWidget(picker); 176 popup->setMainWidget(picker);
176 picker->setFocus(); 177 picker->setFocus();
177 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); 178 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int)));
178 if(popup->exec(mSelectMonth->mapToGlobal(QPoint(0, mSelectMonth->height())))) 179 if(popup->exec(mSelectMonth->mapToGlobal(QPoint(0, mSelectMonth->height()))))
179 { 180 {
180 month = picker->getResult(); 181 month = picker->getResult();
181 emit monthSelected ( month ); 182 emit monthSelected ( month );
182 } else { 183 } else {
183 KNotifyClient::beep(); 184 KNotifyClient::beep();
184 } 185 }
185 delete popup; 186 delete popup;
186} 187}
187void NavigatorBar::selectDates( const KCal::DateList &dateList ) 188void NavigatorBar::selectDates( const KCal::DateList &dateList )
188{ 189{
189 if (dateList.count() > 0) { 190 if (dateList.count() > 0) {
190 QDate date = dateList.first(); 191 QDate date = dateList.first();
191 192
192 const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem(); 193 const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem();
193 194
194 // compute the label at the top of the navigator 195 // compute the label at the top of the navigator
195 QString dtstr = i18n(calSys->monthName( date )) + " '" + 196 QString dtstr = i18n(calSys->monthName( date )) + " '" +
196 QString::number( calSys->year( date ) ).right(2); 197 QString::number( calSys->year( date ) ).right(2);
197 198
198 mSelectMonth->setText( dtstr ); 199 mSelectMonth->setText( dtstr );
199 } 200 }
200} 201}
201 202