summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp19
-rw-r--r--korganizer/koagendaview.cpp4
-rw-r--r--korganizer/koeditorgeneral.cpp69
-rw-r--r--korganizer/kotodoview.cpp11
-rw-r--r--korganizer/kotodoview.h1
5 files changed, 62 insertions, 42 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index beb19d9..76cce26 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,4117 +1,4132 @@
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 "datenavigatorcontainer.h" 110#include "datenavigatorcontainer.h"
111#include "statusdialog.h" 111#include "statusdialog.h"
112#include "kdatenavigator.h" 112#include "kdatenavigator.h"
113#include "kotodoview.h" 113#include "kotodoview.h"
114#include "datenavigator.h" 114#include "datenavigator.h"
115#include "resourceview.h" 115#include "resourceview.h"
116#include "navigatorbar.h" 116#include "navigatorbar.h"
117#include "searchdialog.h" 117#include "searchdialog.h"
118#include "mainwindow.h" 118#include "mainwindow.h"
119 119
120#include "calendarview.h" 120#include "calendarview.h"
121#ifndef DESKTOP_VERSION 121#ifndef DESKTOP_VERSION
122#include <qtopia/alarmserver.h> 122#include <qtopia/alarmserver.h>
123#endif 123#endif
124#ifndef _WIN32_ 124#ifndef _WIN32_
125#include <stdlib.h> 125#include <stdlib.h>
126#include <stdio.h> 126#include <stdio.h>
127#include <unistd.h> 127#include <unistd.h>
128#else 128#else
129#include <qprocess.h> 129#include <qprocess.h>
130#endif 130#endif
131 131
132#ifdef DESKTOP_VERSION 132#ifdef DESKTOP_VERSION
133#include <kabc/stdaddressbook.h> 133#include <kabc/stdaddressbook.h>
134#endif 134#endif
135using namespace KOrg; 135using namespace KOrg;
136using namespace KCal; 136using namespace KCal;
137extern int globalFlagBlockAgenda; 137extern int globalFlagBlockAgenda;
138extern int globalFlagBlockStartup; 138extern int globalFlagBlockStartup;
139 139
140 140
141 141
142class KOBeamPrefs : public QDialog 142class KOBeamPrefs : public QDialog
143{ 143{
144 public: 144 public:
145 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : 145 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) :
146 QDialog( parent, name, true ) 146 QDialog( parent, name, true )
147 { 147 {
148 setCaption( i18n("Beam Options") ); 148 setCaption( i18n("Beam Options") );
149 QVBoxLayout* lay = new QVBoxLayout( this ); 149 QVBoxLayout* lay = new QVBoxLayout( this );
150 lay->setSpacing( 3 ); 150 lay->setSpacing( 3 );
151 lay->setMargin( 3 ); 151 lay->setMargin( 3 );
152 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); 152 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this );
153 lay->addWidget( format ); 153 lay->addWidget( format );
154 format->setExclusive ( true ) ; 154 format->setExclusive ( true ) ;
155 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); 155 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this );
156 lay->addWidget( time ); time->setExclusive ( true ) ; 156 lay->addWidget( time ); time->setExclusive ( true ) ;
157 vcal = new QRadioButton(" vCalendar ", format ); 157 vcal = new QRadioButton(" vCalendar ", format );
158 ical = new QRadioButton(" iCalendar ", format ); 158 ical = new QRadioButton(" iCalendar ", format );
159 vcal->setChecked( true ); 159 vcal->setChecked( true );
160 tz = new QRadioButton(i18n(" With timezone "), time ); 160 tz = new QRadioButton(i18n(" With timezone "), time );
161 local = new QRadioButton(i18n(" Local time "), time ); 161 local = new QRadioButton(i18n(" Local time "), time );
162 tz->setChecked( true ); 162 tz->setChecked( true );
163 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); 163 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this );
164 lay->addWidget( ok ); 164 lay->addWidget( ok );
165 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 165 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
166 lay->addWidget( cancel ); 166 lay->addWidget( cancel );
167 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 167 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
168 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 168 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
169 resize( 200, 200 ); 169 resize( 200, 200 );
170 } 170 }
171 171
172 bool beamVcal() { return vcal->isChecked(); } 172 bool beamVcal() { return vcal->isChecked(); }
173 bool beamLocal() { return local->isChecked(); } 173 bool beamLocal() { return local->isChecked(); }
174private: 174private:
175 QRadioButton* vcal, *ical, *local, *tz; 175 QRadioButton* vcal, *ical, *local, *tz;
176}; 176};
177class KOCatPrefs : public QDialog 177class KOCatPrefs : public QDialog
178{ 178{
179 public: 179 public:
180 KOCatPrefs( QWidget *parent=0, const char *name=0 ) : 180 KOCatPrefs( QWidget *parent=0, const char *name=0 ) :
181 QDialog( parent, name, true ) 181 QDialog( parent, name, true )
182 { 182 {
183 setCaption( i18n("Manage new Categories") ); 183 setCaption( i18n("Manage new Categories") );
184 QVBoxLayout* lay = new QVBoxLayout( this ); 184 QVBoxLayout* lay = new QVBoxLayout( this );
185 lay->setSpacing( 3 ); 185 lay->setSpacing( 3 );
186 lay->setMargin( 3 ); 186 lay->setMargin( 3 );
187 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 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 );
188 lay->addWidget( lab ); 188 lay->addWidget( lab );
189 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 189 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
190 lay->addWidget( format ); 190 lay->addWidget( format );
191 format->setExclusive ( true ) ; 191 format->setExclusive ( true ) ;
192 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 192 addCatBut = new QRadioButton(i18n("Add to category list"), format );
193 new QRadioButton(i18n("Remove from Events/Todos"), format ); 193 new QRadioButton(i18n("Remove from Events/Todos"), format );
194 addCatBut->setChecked( true ); 194 addCatBut->setChecked( true );
195 QPushButton * ok = new QPushButton( i18n("OK"), this ); 195 QPushButton * ok = new QPushButton( i18n("OK"), this );
196 lay->addWidget( ok ); 196 lay->addWidget( ok );
197 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 197 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
198 lay->addWidget( cancel ); 198 lay->addWidget( cancel );
199 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 199 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
200 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 200 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
201 resize( 200, 200 ); 201 resize( 200, 200 );
202 } 202 }
203 203
204 bool addCat() { return addCatBut->isChecked(); } 204 bool addCat() { return addCatBut->isChecked(); }
205private: 205private:
206 QRadioButton* addCatBut; 206 QRadioButton* addCatBut;
207}; 207};
208 208
209 209
210 210
211CalendarView::CalendarView( CalendarResources *calendar, 211CalendarView::CalendarView( CalendarResources *calendar,
212 QWidget *parent, const char *name ) 212 QWidget *parent, const char *name )
213 : CalendarViewBase( parent, name ), 213 : CalendarViewBase( parent, name ),
214 mCalendar( calendar ), 214 mCalendar( calendar ),
215 mResourceManager( calendar->resourceManager() ) 215 mResourceManager( calendar->resourceManager() )
216{ 216{
217 217
218 mEventEditor = 0; 218 mEventEditor = 0;
219 mTodoEditor = 0; 219 mTodoEditor = 0;
220 220
221 init(); 221 init();
222} 222}
223 223
224CalendarView::CalendarView( Calendar *calendar, 224CalendarView::CalendarView( Calendar *calendar,
225 QWidget *parent, const char *name ) 225 QWidget *parent, const char *name )
226 : CalendarViewBase( parent, name ), 226 : CalendarViewBase( parent, name ),
227 mCalendar( calendar ), 227 mCalendar( calendar ),
228 mResourceManager( 0 ) 228 mResourceManager( 0 )
229{ 229{
230 230
231 mEventEditor = 0; 231 mEventEditor = 0;
232 mTodoEditor = 0; 232 mTodoEditor = 0;
233 init(); 233 init();
234} 234}
235 235
236void CalendarView::init() 236void CalendarView::init()
237{ 237{
238 mNextAlarmDateTime = QDateTime::currentDateTime(); 238 mNextAlarmDateTime = QDateTime::currentDateTime();
239 setFocusPolicy ( WheelFocus ); 239 setFocusPolicy ( WheelFocus );
240 mViewerCallerIsSearchDialog = false; 240 mViewerCallerIsSearchDialog = false;
241 mBlockShowDates = false; 241 mBlockShowDates = false;
242 beamDialog = new KOBeamPrefs(); 242 beamDialog = new KOBeamPrefs();
243 mDatePickerMode = 0; 243 mDatePickerMode = 0;
244 mCurrentSyncDevice = ""; 244 mCurrentSyncDevice = "";
245 writeLocale(); 245 writeLocale();
246 mViewManager = new KOViewManager( this ); 246 mViewManager = new KOViewManager( this );
247 mDialogManager = new KODialogManager( this ); 247 mDialogManager = new KODialogManager( this );
248 mEventViewerDialog = 0; 248 mEventViewerDialog = 0;
249 mModified = false; 249 mModified = false;
250 mReadOnly = false; 250 mReadOnly = false;
251 mSelectedIncidence = 0; 251 mSelectedIncidence = 0;
252 mCalPrinter = 0; 252 mCalPrinter = 0;
253 mFilters.setAutoDelete(true); 253 mFilters.setAutoDelete(true);
254 254
255 mCalendar->registerObserver( this ); 255 mCalendar->registerObserver( this );
256 // TODO: Make sure that view is updated, when calendar is changed. 256 // TODO: Make sure that view is updated, when calendar is changed.
257 257
258 mStorage = new FileStorage( mCalendar ); 258 mStorage = new FileStorage( mCalendar );
259 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 259 mNavigator = new DateNavigator( this, "datevav", mViewManager );
260 260
261 QBoxLayout *topLayout = (QBoxLayout*)layout(); 261 QBoxLayout *topLayout = (QBoxLayout*)layout();
262#ifndef KORG_NOSPLITTER 262#ifndef KORG_NOSPLITTER
263 // create the main layout frames. 263 // create the main layout frames.
264 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 264 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
265 topLayout->addWidget(mPanner); 265 topLayout->addWidget(mPanner);
266 266
267 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 267 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
268 "CalendarView::LeftFrame"); 268 "CalendarView::LeftFrame");
269 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 269 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
270 270
271 mDateNavigator = new DateNavigatorContainer( mLeftSplitter, 271 mDateNavigator = new DateNavigatorContainer( mLeftSplitter,
272 "CalendarView::DateNavigator" ); 272 "CalendarView::DateNavigator" );
273 273
274 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 274 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
275 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 275 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
276 mTodoList->setNavigator( mNavigator ); 276 mTodoList->setNavigator( mNavigator );
277 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 277 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
278 278
279#ifdef KORG_NORESOURCEVIEW 279#ifdef KORG_NORESOURCEVIEW
280 mResourceView = 0; 280 mResourceView = 0;
281#else 281#else
282 if ( mResourceManager ) { 282 if ( mResourceManager ) {
283 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 283 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
284 mResourceView->updateView(); 284 mResourceView->updateView();
285 connect( mResourceView, SIGNAL( resourcesChanged() ), 285 connect( mResourceView, SIGNAL( resourcesChanged() ),
286 SLOT( updateView() ) ); 286 SLOT( updateView() ) );
287 } else { 287 } else {
288 mResourceView = 0; 288 mResourceView = 0;
289 } 289 }
290#endif 290#endif
291 QWidget *rightBox = new QWidget( mPanner ); 291 QWidget *rightBox = new QWidget( mPanner );
292 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 292 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
293 293
294 mRightFrame = new QWidgetStack( rightBox ); 294 mRightFrame = new QWidgetStack( rightBox );
295 rightLayout->addWidget( mRightFrame, 1 ); 295 rightLayout->addWidget( mRightFrame, 1 );
296 296
297 mLeftFrame = mLeftSplitter; 297 mLeftFrame = mLeftSplitter;
298#else 298#else
299 //QWidget *mainBox = new QWidget( this ); 299 //QWidget *mainBox = new QWidget( this );
300 //QWidget *leftFrame = new QWidget( mainBox ); 300 //QWidget *leftFrame = new QWidget( mainBox );
301 //QBoxLayout * mainBoxLayout; 301 //QBoxLayout * mainBoxLayout;
302 if ( KOPrefs::instance()->mVerticalScreen ) { 302 if ( KOPrefs::instance()->mVerticalScreen ) {
303 //mainBoxLayout = new QVBoxLayout(mainBox); 303 //mainBoxLayout = new QVBoxLayout(mainBox);
304 //leftFrameLayout = new QHBoxLayout(leftFrame ); 304 //leftFrameLayout = new QHBoxLayout(leftFrame );
305 mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); 305 mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this );
306 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 306 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
307 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; 307 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);;
308 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 308 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
309 } else { 309 } else {
310 //mainBoxLayout = new QHBoxLayout(mainBox); 310 //mainBoxLayout = new QHBoxLayout(mainBox);
311 //leftFrameLayout = new QVBoxLayout(leftFrame ); 311 //leftFrameLayout = new QVBoxLayout(leftFrame );
312 mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 312 mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
313 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); 313 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left);
314 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); 314 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame);
315 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 315 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
316 } 316 }
317 mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); 317 mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) );
318 //QBoxLayout * leftFrameLayout; 318 //QBoxLayout * leftFrameLayout;
319 topLayout->addWidget( mMainFrame ); 319 topLayout->addWidget( mMainFrame );
320 //mainBoxLayout->addWidget (mLeftFrame); 320 //mainBoxLayout->addWidget (mLeftFrame);
321 mDateNavigator = new DateNavigatorContainer( mLeftFrame, 321 mDateNavigator = new DateNavigatorContainer( mLeftFrame,
322 "CalendarView::DateNavigator" ); 322 "CalendarView::DateNavigator" );
323#if 0 323#if 0
324 // FIXME 324 // FIXME
325 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, 325 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE,
326 "CalendarView::DateNavigator", QDate::currentDate()); 326 "CalendarView::DateNavigator", QDate::currentDate());
327#endif 327#endif
328 // mDateNavigator->blockSignals( true ); 328 // mDateNavigator->blockSignals( true );
329 //leftFrameLayout->addWidget( mDateNavigator ); 329 //leftFrameLayout->addWidget( mDateNavigator );
330 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); 330 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall");
331 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); 331 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView");
332 mTodoList->setNavigator( mNavigator ); 332 mTodoList->setNavigator( mNavigator );
333#if 0 333#if 0
334 if ( QApplication::desktop()->width() < 480 ) { 334 if ( QApplication::desktop()->width() < 480 ) {
335 leftFrameLayout->addWidget(mFilterView); 335 leftFrameLayout->addWidget(mFilterView);
336 leftFrameLayout->addWidget(mTodoList, 2 ); 336 leftFrameLayout->addWidget(mTodoList, 2 );
337 337
338 } else { 338 } else {
339 leftFrameLayout->addWidget(mTodoList,2 ); 339 leftFrameLayout->addWidget(mTodoList,2 );
340 leftFrameLayout->addWidget(mFilterView ); 340 leftFrameLayout->addWidget(mFilterView );
341 } 341 }
342#endif 342#endif
343 mFilterView->hide(); 343 mFilterView->hide();
344 QWidget *rightBox = new QWidget( mMainFrame ); 344 QWidget *rightBox = new QWidget( mMainFrame );
345 //mainBoxLayout->addWidget ( rightBox, 10 ); 345 //mainBoxLayout->addWidget ( rightBox, 10 );
346 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 346 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
347 mRightFrame = new QWidgetStack( rightBox ); 347 mRightFrame = new QWidgetStack( rightBox );
348 rightLayout->addWidget( mRightFrame, 10 ); 348 rightLayout->addWidget( mRightFrame, 10 );
349 349
350 //mLeftFrame = (QWidget *)leftFrame; 350 //mLeftFrame = (QWidget *)leftFrame;
351 if ( KOPrefs::instance()->mVerticalScreen ) { 351 if ( KOPrefs::instance()->mVerticalScreen ) {
352 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); 352 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() );
353 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); 353 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() );
354 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 354 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
355 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 355 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
356 } else { 356 } else {
357 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); 357 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() );
358 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 358 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
359 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 359 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
360 } 360 }
361 if ( !KOPrefs::instance()->mShowDateNavigator) 361 if ( !KOPrefs::instance()->mShowDateNavigator)
362 mDateNavigator->hide(); 362 mDateNavigator->hide();
363 //qDebug("Calendarview Size %d %d ", width(), height()); 363 //qDebug("Calendarview Size %d %d ", width(), height());
364#endif 364#endif
365 365
366 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 366 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
367 SLOT( showDates( const KCal::DateList & ) ) ); 367 SLOT( showDates( const KCal::DateList & ) ) );
368 368
369 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 369 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
370 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 370 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
371 371
372 372
373 373
374 connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), 374 connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ),
375 mViewManager, SLOT( showMonth( const QDate & ) ) ); 375 mViewManager, SLOT( showMonth( const QDate & ) ) );
376 376
377 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 377 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
378 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 378 mNavigator, SLOT( selectWeek( const QDate & ) ) );
379 379
380 connect( mDateNavigator, SIGNAL( goPrevYear() ), 380 connect( mDateNavigator, SIGNAL( goPrevYear() ),
381 mNavigator, SLOT( selectPreviousYear() ) ); 381 mNavigator, SLOT( selectPreviousYear() ) );
382 connect( mDateNavigator, SIGNAL( goNextYear() ), 382 connect( mDateNavigator, SIGNAL( goNextYear() ),
383 mNavigator, SLOT( selectNextYear() ) ); 383 mNavigator, SLOT( selectNextYear() ) );
384 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 384 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
385 mNavigator, SLOT( selectPreviousMonth() ) ); 385 mNavigator, SLOT( selectPreviousMonth() ) );
386 connect( mDateNavigator, SIGNAL( goNextMonth() ), 386 connect( mDateNavigator, SIGNAL( goNextMonth() ),
387 mNavigator, SLOT( selectNextMonth() ) ); 387 mNavigator, SLOT( selectNextMonth() ) );
388 388
389 connect( mDateNavigator, SIGNAL( goPrevious() ), 389 connect( mDateNavigator, SIGNAL( goPrevious() ),
390 mNavigator, SLOT( selectPrevious() ) ); 390 mNavigator, SLOT( selectPrevious() ) );
391 connect( mDateNavigator, SIGNAL( goNext() ), 391 connect( mDateNavigator, SIGNAL( goNext() ),
392 mNavigator, SLOT( selectNext() ) ); 392 mNavigator, SLOT( selectNext() ) );
393 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 393 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
394 mNavigator, SLOT( slotMonthSelect( int ) ) ); 394 mNavigator, SLOT( slotMonthSelect( int ) ) );
395 395
396 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 396 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
397 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 397 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
398#if 0 398#if 0
399 connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), 399 connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ),
400 SLOT( incidenceAdded( Incidence *) ) ); 400 SLOT( incidenceAdded( Incidence *) ) );
401#endif 401#endif
402 // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 402 // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
403 403
404 connect( this, SIGNAL( configChanged() ), 404 connect( this, SIGNAL( configChanged() ),
405 mDateNavigator, SLOT( updateConfig() ) ); 405 mDateNavigator, SLOT( updateConfig() ) );
406 406
407 connect( mTodoList, SIGNAL( newTodoSignal() ), 407 connect( mTodoList, SIGNAL( newTodoSignal() ),
408 SLOT( newTodo() ) ); 408 SLOT( newTodo() ) );
409 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 409 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
410 SLOT( newSubTodo( Todo * ) ) ); 410 SLOT( newSubTodo( Todo * ) ) );
411 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 411 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
412 SLOT( editTodo( Todo * ) ) ); 412 SLOT( editTodo( Todo * ) ) );
413 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 413 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
414 SLOT( showTodo( Todo *) ) ); 414 SLOT( showTodo( Todo *) ) );
415 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 415 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
416 SLOT( deleteTodo( Todo *) ) ); 416 SLOT( deleteTodo( Todo *) ) );
417 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 417 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
418 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 418 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
419 SLOT( purgeCompleted() ) ); 419 SLOT( purgeCompleted() ) );
420 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 420 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
421 SIGNAL( todoModified( Todo *, int ) ) ); 421 SIGNAL( todoModified( Todo *, int ) ) );
422 422
423 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 423 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
424 this, SLOT ( cloneIncidence( Incidence * ) ) ); 424 this, SLOT ( cloneIncidence( Incidence * ) ) );
425 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 425 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
426 this, SLOT (cancelIncidence( Incidence * ) ) ); 426 this, SLOT (cancelIncidence( Incidence * ) ) );
427 427
428 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 428 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
429 this, SLOT ( moveIncidence( Incidence * ) ) ); 429 this, SLOT ( moveIncidence( Incidence * ) ) );
430 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 430 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
431 this, SLOT ( beamIncidence( Incidence * ) ) ); 431 this, SLOT ( beamIncidence( Incidence * ) ) );
432 432
433 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 433 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
434 this, SLOT ( todo_unsub( Todo * ) ) ); 434 this, SLOT ( todo_unsub( Todo * ) ) );
435 435
436 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 436 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
437 this, SLOT ( todo_resub( Todo *,Todo * ) ) ); 437 this, SLOT ( todo_resub( Todo *,Todo * ) ) );
438 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 438 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
439 SLOT( updateTodo( Todo *, int ) ) ); 439 SLOT( updateTodo( Todo *, int ) ) );
440 connect( this, SIGNAL( todoModified( Todo *, int )), this, 440 connect( this, SIGNAL( todoModified( Todo *, int )), this,
441 SLOT( changeTodoDisplay( Todo *, int ) ) ); 441 SLOT( changeTodoDisplay( Todo *, int ) ) );
442 442
443 443
444 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 444 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
445 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 445 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
446 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 446 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
447 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 447 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
448 448
449 449
450 450
451 451
452 452
453 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 453 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
454 SLOT(checkClipboard())); 454 SLOT(checkClipboard()));
455 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 455 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
456 SLOT( processTodoListSelection( Incidence * ) ) ); 456 SLOT( processTodoListSelection( Incidence * ) ) );
457 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 457 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
458 458
459 // kdDebug() << "CalendarView::CalendarView() done" << endl; 459 // kdDebug() << "CalendarView::CalendarView() done" << endl;
460 460
461 mDateFrame = new QVBox(0,0,WType_Popup); 461 mDateFrame = new QVBox(0,0,WType_Popup);
462 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 462 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
463 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 463 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
464 mDateFrame->setLineWidth(3); 464 mDateFrame->setLineWidth(3);
465 mDateFrame->hide(); 465 mDateFrame->hide();
466 mDateFrame->setCaption( i18n( "Pick a date to display")); 466 mDateFrame->setCaption( i18n( "Pick a date to display"));
467 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 467 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
468 468
469 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 469 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
470 470
471 mEventEditor = mDialogManager->getEventEditor(); 471 mEventEditor = mDialogManager->getEventEditor();
472 mTodoEditor = mDialogManager->getTodoEditor(); 472 mTodoEditor = mDialogManager->getTodoEditor();
473 473
474 mFlagEditDescription = false; 474 mFlagEditDescription = false;
475 475
476 mSuspendTimer = new QTimer( this ); 476 mSuspendTimer = new QTimer( this );
477 mAlarmTimer = new QTimer( this ); 477 mAlarmTimer = new QTimer( this );
478 mRecheckAlarmTimer = new QTimer( this ); 478 mRecheckAlarmTimer = new QTimer( this );
479 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 479 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
480 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 480 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
481 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 481 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
482 mAlarmDialog = new AlarmDialog( this ); 482 mAlarmDialog = new AlarmDialog( this );
483 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 483 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
484 mAlarmDialog->setServerNotification( false ); 484 mAlarmDialog->setServerNotification( false );
485 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 485 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
486 486
487 487
488#ifndef DESKTOP_VERSION 488#ifndef DESKTOP_VERSION
489//US listen for arriving address resultsets 489//US listen for arriving address resultsets
490 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), 490 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)),
491 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 491 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
492#endif 492#endif
493 mDateNavigator->setCalendar( mCalendar ); 493 mDateNavigator->setCalendar( mCalendar );
494} 494}
495 495
496 496
497CalendarView::~CalendarView() 497CalendarView::~CalendarView()
498{ 498{
499 // kdDebug() << "~CalendarView()" << endl; 499 // kdDebug() << "~CalendarView()" << endl;
500 //qDebug("CalendarView::~CalendarView() "); 500 //qDebug("CalendarView::~CalendarView() ");
501 delete mDialogManager; 501 delete mDialogManager;
502 delete mViewManager; 502 delete mViewManager;
503 delete mStorage; 503 delete mStorage;
504 delete mDateFrame ; 504 delete mDateFrame ;
505 delete beamDialog; 505 delete beamDialog;
506 delete mEventViewerDialog; 506 delete mEventViewerDialog;
507 //kdDebug() << "~CalendarView() done" << endl; 507 //kdDebug() << "~CalendarView() done" << endl;
508} 508}
509 509
510void CalendarView::showDay( QDate d ) 510void CalendarView::showDay( QDate d )
511{ 511{
512 dateNavigator()->blockSignals( true ); 512 dateNavigator()->blockSignals( true );
513 dateNavigator()->selectDate( d ); 513 dateNavigator()->selectDate( d );
514 dateNavigator()->blockSignals( false ); 514 dateNavigator()->blockSignals( false );
515 mViewManager->showDayView(); 515 mViewManager->showDayView();
516 //dateNavigator()->selectDate( d ); 516 //dateNavigator()->selectDate( d );
517} 517}
518void CalendarView::timerAlarm() 518void CalendarView::timerAlarm()
519{ 519{
520 //qDebug("CalendarView::timerAlarm() "); 520 //qDebug("CalendarView::timerAlarm() ");
521 computeAlarm(mAlarmNotification ); 521 computeAlarm(mAlarmNotification );
522} 522}
523 523
524void CalendarView::suspendAlarm() 524void CalendarView::suspendAlarm()
525{ 525{
526 //qDebug(" CalendarView::suspendAlarm() "); 526 //qDebug(" CalendarView::suspendAlarm() ");
527 computeAlarm(mSuspendAlarmNotification ); 527 computeAlarm(mSuspendAlarmNotification );
528 528
529} 529}
530 530
531void CalendarView::startAlarm( QString mess , QString filename) 531void CalendarView::startAlarm( QString mess , QString filename)
532{ 532{
533
534 topLevelWidget()->showNormal();
535 topLevelWidget()->setActiveWindow();
536 topLevelWidget()->raise();
537
533 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 538 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
534 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); 539 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
535 540
536} 541}
537 542
538void CalendarView::checkNextTimerAlarm() 543void CalendarView::checkNextTimerAlarm()
539{ 544{
540 mCalendar->checkAlarmForIncidence( 0, true ); 545 mCalendar->checkAlarmForIncidence( 0, true );
541} 546}
542 547
543void CalendarView::computeAlarm( QString msg ) 548void CalendarView::computeAlarm( QString msg )
544{ 549{
545 550
546 QString mess = msg; 551 QString mess = msg;
547 QString mAlarmMessage = mess.mid( 9 ); 552 QString mAlarmMessage = mess.mid( 9 );
548 QString filename = MainWindow::resourcePath(); 553 QString filename = MainWindow::resourcePath();
549 filename += "koalarm.wav"; 554 filename += "koalarm.wav";
550 QString tempfilename; 555 QString tempfilename;
551 if ( mess.left( 13 ) == "suspend_alarm") { 556 if ( mess.left( 13 ) == "suspend_alarm") {
552 bool error = false; 557 bool error = false;
553 int len = mess.mid( 13 ).find("+++"); 558 int len = mess.mid( 13 ).find("+++");
554 if ( len < 2 ) 559 if ( len < 2 )
555 error = true; 560 error = true;
556 else { 561 else {
557 tempfilename = mess.mid( 13, len ); 562 tempfilename = mess.mid( 13, len );
558 if ( !QFile::exists( tempfilename ) ) 563 if ( !QFile::exists( tempfilename ) )
559 error = true; 564 error = true;
560 } 565 }
561 if ( ! error ) { 566 if ( ! error ) {
562 filename = tempfilename; 567 filename = tempfilename;
563 } 568 }
564 mAlarmMessage = mess.mid( 13+len+3 ); 569 mAlarmMessage = mess.mid( 13+len+3 );
565 //qDebug("suspend file %s ",tempfilename.latin1() ); 570 //qDebug("suspend file %s ",tempfilename.latin1() );
566 startAlarm( mAlarmMessage, filename); 571 startAlarm( mAlarmMessage, filename);
567 return; 572 return;
568 } 573 }
569 if ( mess.left( 11 ) == "timer_alarm") { 574 if ( mess.left( 11 ) == "timer_alarm") {
570 //mTimerTime = 0; 575 //mTimerTime = 0;
571 startAlarm( mess.mid( 11 ), filename ); 576 startAlarm( mess.mid( 11 ), filename );
572 return; 577 return;
573 } 578 }
574 if ( mess.left( 10 ) == "proc_alarm") { 579 if ( mess.left( 10 ) == "proc_alarm") {
575 bool error = false; 580 bool error = false;
576 int len = mess.mid( 10 ).find("+++"); 581 int len = mess.mid( 10 ).find("+++");
577 if ( len < 2 ) 582 if ( len < 2 )
578 error = true; 583 error = true;
579 else { 584 else {
580 tempfilename = mess.mid( 10, len ); 585 tempfilename = mess.mid( 10, len );
581 if ( !QFile::exists( tempfilename ) ) 586 if ( !QFile::exists( tempfilename ) )
582 error = true; 587 error = true;
583 } 588 }
584 if ( error ) { 589 if ( error ) {
585 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 590 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
586 mAlarmMessage += mess.mid( 10+len+3+9 ); 591 mAlarmMessage += mess.mid( 10+len+3+9 );
587 } else { 592 } else {
588 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 593 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
589 //qDebug("-----system command %s ",tempfilename.latin1() ); 594 //qDebug("-----system command %s ",tempfilename.latin1() );
590#ifndef _WIN32_ 595#ifndef _WIN32_
591 if ( vfork () == 0 ) { 596 if ( vfork () == 0 ) {
592 execl ( tempfilename.latin1(), 0 ); 597 execl ( tempfilename.latin1(), 0 );
593 return; 598 return;
594 } 599 }
595#else 600#else
596 QProcess* p = new QProcess(); 601 QProcess* p = new QProcess();
597 p->addArgument( tempfilename.latin1() ); 602 p->addArgument( tempfilename.latin1() );
598 p->start(); 603 p->start();
599 return; 604 return;
600#endif 605#endif
601 606
602 return; 607 return;
603 } 608 }
604 609
605 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 610 //qDebug("+++++++system command %s ",tempfilename.latin1() );
606 } 611 }
607 if ( mess.left( 11 ) == "audio_alarm") { 612 if ( mess.left( 11 ) == "audio_alarm") {
608 bool error = false; 613 bool error = false;
609 int len = mess.mid( 11 ).find("+++"); 614 int len = mess.mid( 11 ).find("+++");
610 if ( len < 2 ) 615 if ( len < 2 )
611 error = true; 616 error = true;
612 else { 617 else {
613 tempfilename = mess.mid( 11, len ); 618 tempfilename = mess.mid( 11, len );
614 if ( !QFile::exists( tempfilename ) ) 619 if ( !QFile::exists( tempfilename ) )
615 error = true; 620 error = true;
616 } 621 }
617 if ( ! error ) { 622 if ( ! error ) {
618 filename = tempfilename; 623 filename = tempfilename;
619 } 624 }
620 mAlarmMessage = mess.mid( 11+len+3+9 ); 625 mAlarmMessage = mess.mid( 11+len+3+9 );
621 //qDebug("audio file command %s ",tempfilename.latin1() ); 626 //qDebug("audio file command %s ",tempfilename.latin1() );
622 } 627 }
623 if ( mess.left( 9 ) == "cal_alarm") { 628 if ( mess.left( 9 ) == "cal_alarm") {
624 mAlarmMessage = mess.mid( 9 ) ; 629 mAlarmMessage = mess.mid( 9 ) ;
625 } 630 }
626 631
627 startAlarm( mAlarmMessage, filename ); 632 startAlarm( mAlarmMessage, filename );
628 633
629 634
630} 635}
631 636
632void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 637void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
633{ 638{
634 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 639 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
635 640
636 mSuspendAlarmNotification = noti; 641 mSuspendAlarmNotification = noti;
637 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 642 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
638 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 643 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
639 mSuspendTimer->start( ms , true ); 644 mSuspendTimer->start( ms , true );
640 645
641} 646}
642 647
643void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 648void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
644{ 649{
645 mNextAlarmDateTime = qdt; 650 mNextAlarmDateTime = qdt;
646 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 651 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
647 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 652 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
648#ifndef DESKTOP_VERSION 653#ifndef DESKTOP_VERSION
649 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); 654 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() );
650#endif 655#endif
651 return; 656 return;
652 } 657 }
653 int maxSec; 658 int maxSec;
654 //maxSec = 5; //testing only 659 //maxSec = 5; //testing only
655 maxSec = 86400+3600; // one day+1hour 660 maxSec = 86400+3600; // one day+1hour
656 mAlarmNotification = noti; 661 mAlarmNotification = noti;
657 int sec = QDateTime::currentDateTime().secsTo( qdt ); 662 int sec = QDateTime::currentDateTime().secsTo( qdt );
658 if ( sec > maxSec ) { 663 if ( sec > maxSec ) {
659 mRecheckAlarmTimer->start( maxSec * 1000 ); 664 mRecheckAlarmTimer->start( maxSec * 1000 );
660 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 665 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
661 return; 666 return;
662 } else { 667 } else {
663 mRecheckAlarmTimer->stop(); 668 mRecheckAlarmTimer->stop();
664 } 669 }
665 //qDebug("Alarm timer started with secs: %d ", sec); 670 //qDebug("Alarm timer started with secs: %d ", sec);
666 mAlarmTimer->start( sec *1000 , true ); 671 mAlarmTimer->start( sec *1000 , true );
667 672
668} 673}
669// called by mRecheckAlarmTimer to get next alarm 674// called by mRecheckAlarmTimer to get next alarm
670// we need this, because a QTimer has only a max range of 25 days 675// we need this, because a QTimer has only a max range of 25 days
671void CalendarView::recheckTimerAlarm() 676void CalendarView::recheckTimerAlarm()
672{ 677{
673 mAlarmTimer->stop(); 678 mAlarmTimer->stop();
674 mRecheckAlarmTimer->stop(); 679 mRecheckAlarmTimer->stop();
675 mCalendar->checkAlarmForIncidence( 0, true ); 680 mCalendar->checkAlarmForIncidence( 0, true );
676} 681}
677void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 682void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
678{ 683{
679 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 684 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
680 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 685 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
681#ifndef DESKTOP_VERSION 686#ifndef DESKTOP_VERSION
682 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 687 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
683#endif 688#endif
684 return; 689 return;
685 } 690 }
686 mAlarmTimer->stop(); 691 mAlarmTimer->stop();
687} 692}
688void CalendarView::selectWeekNum ( int num ) 693void CalendarView::selectWeekNum ( int num )
689{ 694{
690 dateNavigator()->blockSignals( true ); 695 dateNavigator()->blockSignals( true );
691 dateNavigator()->selectWeek( num ); 696 dateNavigator()->selectWeek( num );
692 dateNavigator()->blockSignals( false ); 697 dateNavigator()->blockSignals( false );
693 mViewManager->showWeekView(); 698 mViewManager->showWeekView();
694} 699}
695KOViewManager *CalendarView::viewManager() 700KOViewManager *CalendarView::viewManager()
696{ 701{
697 return mViewManager; 702 return mViewManager;
698} 703}
699 704
700KODialogManager *CalendarView::dialogManager() 705KODialogManager *CalendarView::dialogManager()
701{ 706{
702 return mDialogManager; 707 return mDialogManager;
703} 708}
704 709
705QDate CalendarView::startDate() 710QDate CalendarView::startDate()
706{ 711{
707 DateList dates = mNavigator->selectedDates(); 712 DateList dates = mNavigator->selectedDates();
708 713
709 return dates.first(); 714 return dates.first();
710} 715}
711 716
712QDate CalendarView::endDate() 717QDate CalendarView::endDate()
713{ 718{
714 DateList dates = mNavigator->selectedDates(); 719 DateList dates = mNavigator->selectedDates();
715 720
716 return dates.last(); 721 return dates.last();
717} 722}
718 723
719 724
720void CalendarView::createPrinter() 725void CalendarView::createPrinter()
721{ 726{
722#ifndef KORG_NOPRINTER 727#ifndef KORG_NOPRINTER
723 if (!mCalPrinter) { 728 if (!mCalPrinter) {
724 mCalPrinter = new CalPrinter(this, mCalendar); 729 mCalPrinter = new CalPrinter(this, mCalendar);
725 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 730 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
726 } 731 }
727#endif 732#endif
728} 733}
729 734
730 735
731//KOPrefs::instance()->mWriteBackFile 736//KOPrefs::instance()->mWriteBackFile
732//KOPrefs::instance()->mWriteBackExistingOnly 737//KOPrefs::instance()->mWriteBackExistingOnly
733 738
734// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 739// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
735// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 740// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
736// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 741// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
737// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 742// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
738// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 743// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
739// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 744// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
740 745
741int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 746int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
742{ 747{
743 748
744 // 0 equal 749 // 0 equal
745 // 1 take local 750 // 1 take local
746 // 2 take remote 751 // 2 take remote
747 // 3 cancel 752 // 3 cancel
748 QDateTime lastSync = mLastCalendarSync; 753 QDateTime lastSync = mLastCalendarSync;
749 QDateTime localMod = local->lastModified(); 754 QDateTime localMod = local->lastModified();
750 QDateTime remoteMod = remote->lastModified(); 755 QDateTime remoteMod = remote->lastModified();
751 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 756 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
752 bool remCh, locCh; 757 bool remCh, locCh;
753 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 758 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
754 //if ( remCh ) 759 //if ( remCh )
755 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 760 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
756 locCh = ( localMod > mLastCalendarSync ); 761 locCh = ( localMod > mLastCalendarSync );
757 if ( !remCh && ! locCh ) { 762 if ( !remCh && ! locCh ) {
758 //qDebug("both not changed "); 763 //qDebug("both not changed ");
759 lastSync = localMod.addDays(1); 764 lastSync = localMod.addDays(1);
760 if ( mode <= SYNC_PREF_ASK ) 765 if ( mode <= SYNC_PREF_ASK )
761 return 0; 766 return 0;
762 } else { 767 } else {
763 if ( locCh ) { 768 if ( locCh ) {
764 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); 769 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1());
765 lastSync = localMod.addDays( -1 ); 770 lastSync = localMod.addDays( -1 );
766 if ( !remCh ) 771 if ( !remCh )
767 remoteMod = ( lastSync.addDays( -1 ) ); 772 remoteMod = ( lastSync.addDays( -1 ) );
768 } else { 773 } else {
769 //qDebug(" not loc changed "); 774 //qDebug(" not loc changed ");
770 lastSync = localMod.addDays( 1 ); 775 lastSync = localMod.addDays( 1 );
771 if ( remCh ) 776 if ( remCh )
772 remoteMod =( lastSync.addDays( 1 ) ); 777 remoteMod =( lastSync.addDays( 1 ) );
773 778
774 } 779 }
775 } 780 }
776 full = true; 781 full = true;
777 if ( mode < SYNC_PREF_ASK ) 782 if ( mode < SYNC_PREF_ASK )
778 mode = SYNC_PREF_ASK; 783 mode = SYNC_PREF_ASK;
779 } else { 784 } else {
780 if ( localMod == remoteMod ) 785 if ( localMod == remoteMod )
781 // if ( local->revision() == remote->revision() ) 786 // if ( local->revision() == remote->revision() )
782 return 0; 787 return 0;
783 788
784 } 789 }
785 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 790 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
786 791
787 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); 792 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision());
788 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); 793 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() );
789 //full = true; //debug only 794 //full = true; //debug only
790 if ( full ) { 795 if ( full ) {
791 bool equ = false; 796 bool equ = false;
792 if ( local->type() == "Event" ) { 797 if ( local->type() == "Event" ) {
793 equ = (*((Event*) local) == *((Event*) remote)); 798 equ = (*((Event*) local) == *((Event*) remote));
794 } 799 }
795 else if ( local->type() =="Todo" ) 800 else if ( local->type() =="Todo" )
796 equ = (*((Todo*) local) == (*(Todo*) remote)); 801 equ = (*((Todo*) local) == (*(Todo*) remote));
797 else if ( local->type() =="Journal" ) 802 else if ( local->type() =="Journal" )
798 equ = (*((Journal*) local) == *((Journal*) remote)); 803 equ = (*((Journal*) local) == *((Journal*) remote));
799 if ( equ ) { 804 if ( equ ) {
800 //qDebug("equal "); 805 //qDebug("equal ");
801 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 806 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
802 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 807 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
803 } 808 }
804 if ( mode < SYNC_PREF_FORCE_LOCAL ) 809 if ( mode < SYNC_PREF_FORCE_LOCAL )
805 return 0; 810 return 0;
806 811
807 }//else //debug only 812 }//else //debug only
808 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 813 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
809 } 814 }
810 int result; 815 int result;
811 bool localIsNew; 816 bool localIsNew;
812 //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() ); 817 //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() );
813 818
814 if ( full && mode < SYNC_PREF_NEWEST ) 819 if ( full && mode < SYNC_PREF_NEWEST )
815 mode = SYNC_PREF_ASK; 820 mode = SYNC_PREF_ASK;
816 821
817 switch( mode ) { 822 switch( mode ) {
818 case SYNC_PREF_LOCAL: 823 case SYNC_PREF_LOCAL:
819 if ( lastSync > remoteMod ) 824 if ( lastSync > remoteMod )
820 return 1; 825 return 1;
821 if ( lastSync > localMod ) 826 if ( lastSync > localMod )
822 return 2; 827 return 2;
823 return 1; 828 return 1;
824 break; 829 break;
825 case SYNC_PREF_REMOTE: 830 case SYNC_PREF_REMOTE:
826 if ( lastSync > remoteMod ) 831 if ( lastSync > remoteMod )
827 return 1; 832 return 1;
828 if ( lastSync > localMod ) 833 if ( lastSync > localMod )
829 return 2; 834 return 2;
830 return 2; 835 return 2;
831 break; 836 break;
832 case SYNC_PREF_NEWEST: 837 case SYNC_PREF_NEWEST:
833 if ( localMod > remoteMod ) 838 if ( localMod > remoteMod )
834 return 1; 839 return 1;
835 else 840 else
836 return 2; 841 return 2;
837 break; 842 break;
838 case SYNC_PREF_ASK: 843 case SYNC_PREF_ASK:
839 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 844 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
840 if ( lastSync > remoteMod ) 845 if ( lastSync > remoteMod )
841 return 1; 846 return 1;
842 if ( lastSync > localMod ) 847 if ( lastSync > localMod )
843 return 2; 848 return 2;
844 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 849 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
845 localIsNew = localMod >= remoteMod; 850 localIsNew = localMod >= remoteMod;
846 if ( localIsNew ) 851 if ( localIsNew )
847 getEventViewerDialog()->setColorMode( 1 ); 852 getEventViewerDialog()->setColorMode( 1 );
848 else 853 else
849 getEventViewerDialog()->setColorMode( 2 ); 854 getEventViewerDialog()->setColorMode( 2 );
850 getEventViewerDialog()->setIncidence(local); 855 getEventViewerDialog()->setIncidence(local);
851 if ( localIsNew ) 856 if ( localIsNew )
852 getEventViewerDialog()->setColorMode( 2 ); 857 getEventViewerDialog()->setColorMode( 2 );
853 else 858 else
854 getEventViewerDialog()->setColorMode( 1 ); 859 getEventViewerDialog()->setColorMode( 1 );
855 getEventViewerDialog()->addIncidence(remote); 860 getEventViewerDialog()->addIncidence(remote);
856 getEventViewerDialog()->setColorMode( 0 ); 861 getEventViewerDialog()->setColorMode( 0 );
857 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 862 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
858 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 863 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
859 getEventViewerDialog()->showMe(); 864 getEventViewerDialog()->showMe();
860 result = getEventViewerDialog()->executeS( localIsNew ); 865 result = getEventViewerDialog()->executeS( localIsNew );
861 return result; 866 return result;
862 867
863 break; 868 break;
864 case SYNC_PREF_FORCE_LOCAL: 869 case SYNC_PREF_FORCE_LOCAL:
865 return 1; 870 return 1;
866 break; 871 break;
867 case SYNC_PREF_FORCE_REMOTE: 872 case SYNC_PREF_FORCE_REMOTE:
868 return 2; 873 return 2;
869 break; 874 break;
870 875
871 default: 876 default:
872 // SYNC_PREF_TAKE_BOTH not implemented 877 // SYNC_PREF_TAKE_BOTH not implemented
873 break; 878 break;
874 } 879 }
875 return 0; 880 return 0;
876} 881}
877Event* CalendarView::getLastSyncEvent() 882Event* CalendarView::getLastSyncEvent()
878{ 883{
879 Event* lse; 884 Event* lse;
880 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 885 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
881 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 886 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
882 if (!lse) { 887 if (!lse) {
883 lse = new Event(); 888 lse = new Event();
884 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 889 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
885 QString sum = ""; 890 QString sum = "";
886 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 891 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
887 sum = "E: "; 892 sum = "E: ";
888 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 893 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
889 lse->setDtStart( mLastCalendarSync ); 894 lse->setDtStart( mLastCalendarSync );
890 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 895 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
891 lse->setCategories( i18n("SyncEvent") ); 896 lse->setCategories( i18n("SyncEvent") );
892 lse->setReadOnly( true ); 897 lse->setReadOnly( true );
893 mCalendar->addEvent( lse ); 898 mCalendar->addEvent( lse );
894 } 899 }
895 900
896 return lse; 901 return lse;
897 902
898} 903}
899 904
900// we check, if the to delete event has a id for a profile 905// we check, if the to delete event has a id for a profile
901// if yes, we set this id in the profile to delete 906// if yes, we set this id in the profile to delete
902void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 907void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
903{ 908{
904 if ( lastSync.count() == 0 ) { 909 if ( lastSync.count() == 0 ) {
905 //qDebug(" lastSync.count() == 0"); 910 //qDebug(" lastSync.count() == 0");
906 return; 911 return;
907 } 912 }
908 if ( toDelete->type() == "Journal" ) 913 if ( toDelete->type() == "Journal" )
909 return; 914 return;
910 915
911 Event* eve = lastSync.first(); 916 Event* eve = lastSync.first();
912 917
913 while ( eve ) { 918 while ( eve ) {
914 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 919 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
915 if ( !id.isEmpty() ) { 920 if ( !id.isEmpty() ) {
916 QString des = eve->description(); 921 QString des = eve->description();
917 QString pref = "e"; 922 QString pref = "e";
918 if ( toDelete->type() == "Todo" ) 923 if ( toDelete->type() == "Todo" )
919 pref = "t"; 924 pref = "t";
920 des += pref+ id + ","; 925 des += pref+ id + ",";
921 eve->setReadOnly( false ); 926 eve->setReadOnly( false );
922 eve->setDescription( des ); 927 eve->setDescription( des );
923 //qDebug("setdes %s ", des.latin1()); 928 //qDebug("setdes %s ", des.latin1());
924 eve->setReadOnly( true ); 929 eve->setReadOnly( true );
925 } 930 }
926 eve = lastSync.next(); 931 eve = lastSync.next();
927 } 932 }
928 933
929} 934}
930void CalendarView::checkExternalId( Incidence * inc ) 935void CalendarView::checkExternalId( Incidence * inc )
931{ 936{
932 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 937 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
933 checkExternSyncEvent( lastSync, inc ); 938 checkExternSyncEvent( lastSync, inc );
934 939
935} 940}
936bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 941bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
937{ 942{
938 bool syncOK = true; 943 bool syncOK = true;
939 int addedEvent = 0; 944 int addedEvent = 0;
940 int addedEventR = 0; 945 int addedEventR = 0;
941 int deletedEventR = 0; 946 int deletedEventR = 0;
942 int deletedEventL = 0; 947 int deletedEventL = 0;
943 int changedLocal = 0; 948 int changedLocal = 0;
944 int changedRemote = 0; 949 int changedRemote = 0;
945 int filteredIN = 0; 950 int filteredIN = 0;
946 int filteredOUT = 0; 951 int filteredOUT = 0;
947 //QPtrList<Event> el = local->rawEvents(); 952 //QPtrList<Event> el = local->rawEvents();
948 Event* eventR; 953 Event* eventR;
949 QString uid; 954 QString uid;
950 int take; 955 int take;
951 Event* eventL; 956 Event* eventL;
952 Event* eventRSync; 957 Event* eventRSync;
953 Event* eventLSync; 958 Event* eventLSync;
954 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 959 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
955 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 960 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
956 bool fullDateRange = false; 961 bool fullDateRange = false;
957 local->resetTempSyncStat(); 962 local->resetTempSyncStat();
958 mLastCalendarSync = QDateTime::currentDateTime(); 963 mLastCalendarSync = QDateTime::currentDateTime();
959 if ( mSyncManager->syncWithDesktop() ) { 964 if ( mSyncManager->syncWithDesktop() ) {
960 remote->resetPilotStat(1); 965 remote->resetPilotStat(1);
961 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 966 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
962 mLastCalendarSync = KSyncManager::mRequestedSyncEvent; 967 mLastCalendarSync = KSyncManager::mRequestedSyncEvent;
963 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); 968 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() );
964 } else { 969 } else {
965 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 970 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
966 } 971 }
967 } 972 }
968 QDateTime modifiedCalendar = mLastCalendarSync; 973 QDateTime modifiedCalendar = mLastCalendarSync;
969 eventLSync = getLastSyncEvent(); 974 eventLSync = getLastSyncEvent();
970 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 975 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
971 if ( eventR ) { 976 if ( eventR ) {
972 eventRSync = (Event*) eventR->clone(); 977 eventRSync = (Event*) eventR->clone();
973 remote->deleteEvent(eventR ); 978 remote->deleteEvent(eventR );
974 979
975 } else { 980 } else {
976 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { 981 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) {
977 eventRSync = (Event*)eventLSync->clone(); 982 eventRSync = (Event*)eventLSync->clone();
978 } else { 983 } else {
979 fullDateRange = true; 984 fullDateRange = true;
980 eventRSync = new Event(); 985 eventRSync = new Event();
981 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 986 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
982 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 987 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
983 eventRSync->setDtStart( mLastCalendarSync ); 988 eventRSync->setDtStart( mLastCalendarSync );
984 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 989 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
985 eventRSync->setCategories( i18n("SyncEvent") ); 990 eventRSync->setCategories( i18n("SyncEvent") );
986 } 991 }
987 } 992 }
988 if ( eventLSync->dtStart() == mLastCalendarSync ) 993 if ( eventLSync->dtStart() == mLastCalendarSync )
989 fullDateRange = true; 994 fullDateRange = true;
990 995
991 if ( ! fullDateRange ) { 996 if ( ! fullDateRange ) {
992 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 997 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
993 998
994 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 999 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
995 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 1000 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
996 fullDateRange = true; 1001 fullDateRange = true;
997 } 1002 }
998 } 1003 }
999 if ( mSyncManager->syncWithDesktop() ) { 1004 if ( mSyncManager->syncWithDesktop() ) {
1000 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); 1005 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync );
1001 } 1006 }
1002 if ( fullDateRange ) 1007 if ( fullDateRange )
1003 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 1008 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
1004 else 1009 else
1005 mLastCalendarSync = eventLSync->dtStart(); 1010 mLastCalendarSync = eventLSync->dtStart();
1006 // for resyncing if own file has changed 1011 // for resyncing if own file has changed
1007 if ( mCurrentSyncDevice == "deleteaftersync" ) { 1012 if ( mCurrentSyncDevice == "deleteaftersync" ) {
1008 mLastCalendarSync = loadedFileVersion; 1013 mLastCalendarSync = loadedFileVersion;
1009 //qDebug("setting mLastCalendarSync "); 1014 //qDebug("setting mLastCalendarSync ");
1010 } 1015 }
1011 //qDebug("*************************** "); 1016 //qDebug("*************************** ");
1012 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); 1017 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange);
1013 QPtrList<Incidence> er = remote->rawIncidences(); 1018 QPtrList<Incidence> er = remote->rawIncidences();
1014 Incidence* inR = er.first(); 1019 Incidence* inR = er.first();
1015 Incidence* inL; 1020 Incidence* inL;
1016 QProgressBar bar( er.count(),0 ); 1021 QProgressBar bar( er.count(),0 );
1017 bar.setCaption (i18n("Syncing - close to abort!") ); 1022 bar.setCaption (i18n("Syncing - close to abort!") );
1018 1023
1019 // ************** setting up filter ************* 1024 // ************** setting up filter *************
1020 CalFilter *filterIN = 0; 1025 CalFilter *filterIN = 0;
1021 CalFilter *filterOUT = 0; 1026 CalFilter *filterOUT = 0;
1022 CalFilter *filter = mFilters.first(); 1027 CalFilter *filter = mFilters.first();
1023 while(filter) { 1028 while(filter) {
1024 if ( filter->name() == mSyncManager->mFilterInCal ) 1029 if ( filter->name() == mSyncManager->mFilterInCal )
1025 filterIN = filter; 1030 filterIN = filter;
1026 if ( filter->name() == mSyncManager->mFilterOutCal ) 1031 if ( filter->name() == mSyncManager->mFilterOutCal )
1027 filterOUT = filter; 1032 filterOUT = filter;
1028 filter = mFilters.next(); 1033 filter = mFilters.next();
1029 } 1034 }
1030 int w = 300; 1035 int w = 300;
1031 if ( QApplication::desktop()->width() < 320 ) 1036 if ( QApplication::desktop()->width() < 320 )
1032 w = 220; 1037 w = 220;
1033 int h = bar.sizeHint().height() ; 1038 int h = bar.sizeHint().height() ;
1034 int dw = QApplication::desktop()->width(); 1039 int dw = QApplication::desktop()->width();
1035 int dh = QApplication::desktop()->height(); 1040 int dh = QApplication::desktop()->height();
1036 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1041 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1037 bar.show(); 1042 bar.show();
1038 int modulo = (er.count()/10)+1; 1043 int modulo = (er.count()/10)+1;
1039 int incCounter = 0; 1044 int incCounter = 0;
1040 while ( inR ) { 1045 while ( inR ) {
1041 if ( ! bar.isVisible() ) 1046 if ( ! bar.isVisible() )
1042 return false; 1047 return false;
1043 if ( incCounter % modulo == 0 ) 1048 if ( incCounter % modulo == 0 )
1044 bar.setProgress( incCounter ); 1049 bar.setProgress( incCounter );
1045 ++incCounter; 1050 ++incCounter;
1046 uid = inR->uid(); 1051 uid = inR->uid();
1047 bool skipIncidence = false; 1052 bool skipIncidence = false;
1048 if ( uid.left(15) == QString("last-syncEvent-") ) 1053 if ( uid.left(15) == QString("last-syncEvent-") )
1049 skipIncidence = true; 1054 skipIncidence = true;
1050 QString idS; 1055 QString idS;
1051 qApp->processEvents(); 1056 qApp->processEvents();
1052 if ( !skipIncidence ) { 1057 if ( !skipIncidence ) {
1053 inL = local->incidence( uid ); 1058 inL = local->incidence( uid );
1054 if ( inL ) { // maybe conflict - same uid in both calendars 1059 if ( inL ) { // maybe conflict - same uid in both calendars
1055 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1060 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1056 //qDebug("take %d %s ", take, inL->summary().latin1()); 1061 //qDebug("take %d %s ", take, inL->summary().latin1());
1057 if ( take == 3 ) 1062 if ( take == 3 )
1058 return false; 1063 return false;
1059 if ( take == 1 ) {// take local ********************** 1064 if ( take == 1 ) {// take local **********************
1060 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1065 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1061 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1066 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1062 else 1067 else
1063 idS = inR->IDStr(); 1068 idS = inR->IDStr();
1064 remote->deleteIncidence( inR ); 1069 remote->deleteIncidence( inR );
1065 inR = inL->clone(); 1070 inR = inL->clone();
1066 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1071 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1067 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1072 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1068 inR->setIDStr( idS ); 1073 inR->setIDStr( idS );
1069 remote->addIncidence( inR ); 1074 remote->addIncidence( inR );
1070 if ( mSyncManager->syncWithDesktop() ) 1075 if ( mSyncManager->syncWithDesktop() )
1071 inR->setPilotId( 2 ); 1076 inR->setPilotId( 2 );
1072 ++changedRemote; 1077 ++changedRemote;
1073 } else {// take remote ********************** 1078 } else {// take remote **********************
1074 idS = inL->IDStr(); 1079 idS = inL->IDStr();
1075 int pid = inL->pilotId(); 1080 int pid = inL->pilotId();
1076 local->deleteIncidence( inL ); 1081 local->deleteIncidence( inL );
1077 inL = inR->clone(); 1082 inL = inR->clone();
1078 if ( mSyncManager->syncWithDesktop() ) 1083 if ( mSyncManager->syncWithDesktop() )
1079 inL->setPilotId( pid ); 1084 inL->setPilotId( pid );
1080 inL->setIDStr( idS ); 1085 inL->setIDStr( idS );
1081 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1086 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1082 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1087 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1083 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1088 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1084 } 1089 }
1085 local->addIncidence( inL ); 1090 local->addIncidence( inL );
1086 ++changedLocal; 1091 ++changedLocal;
1087 } 1092 }
1088 } 1093 }
1089 } else { // no conflict ********** add or delete remote 1094 } else { // no conflict ********** add or delete remote
1090 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ 1095 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){
1091 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1096 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1092 QString des = eventLSync->description(); 1097 QString des = eventLSync->description();
1093 QString pref = "e"; 1098 QString pref = "e";
1094 if ( inR->type() == "Todo" ) 1099 if ( inR->type() == "Todo" )
1095 pref = "t"; 1100 pref = "t";
1096 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1101 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1097 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1102 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1098 //remote->deleteIncidence( inR ); 1103 //remote->deleteIncidence( inR );
1099 ++deletedEventR; 1104 ++deletedEventR;
1100 } else { 1105 } else {
1101 inR->setLastModified( modifiedCalendar ); 1106 inR->setLastModified( modifiedCalendar );
1102 inL = inR->clone(); 1107 inL = inR->clone();
1103 inL->setIDStr( ":" ); 1108 inL->setIDStr( ":" );
1104 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1109 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1105 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1110 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1106 local->addIncidence( inL ); 1111 local->addIncidence( inL );
1107 ++addedEvent; 1112 ++addedEvent;
1108 1113
1109 } 1114 }
1110 } else { 1115 } else {
1111 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1116 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1112 inR->setLastModified( modifiedCalendar ); 1117 inR->setLastModified( modifiedCalendar );
1113 inL = inR->clone(); 1118 inL = inR->clone();
1114 inL->setIDStr( ":" ); 1119 inL->setIDStr( ":" );
1115 local->addIncidence( inL ); 1120 local->addIncidence( inL );
1116 ++addedEvent; 1121 ++addedEvent;
1117 1122
1118 } else { 1123 } else {
1119 checkExternSyncEvent(eventRSyncSharp, inR); 1124 checkExternSyncEvent(eventRSyncSharp, inR);
1120 remote->deleteIncidence( inR ); 1125 remote->deleteIncidence( inR );
1121 ++deletedEventR; 1126 ++deletedEventR;
1122 } 1127 }
1123 } 1128 }
1124 } else { 1129 } else {
1125 ++filteredIN; 1130 ++filteredIN;
1126 } 1131 }
1127 } 1132 }
1128 } 1133 }
1129 inR = er.next(); 1134 inR = er.next();
1130 } 1135 }
1131 QPtrList<Incidence> el = local->rawIncidences(); 1136 QPtrList<Incidence> el = local->rawIncidences();
1132 inL = el.first(); 1137 inL = el.first();
1133 modulo = (el.count()/10)+1; 1138 modulo = (el.count()/10)+1;
1134 bar.setCaption (i18n("Add / remove events") ); 1139 bar.setCaption (i18n("Add / remove events") );
1135 bar.setTotalSteps ( el.count() ) ; 1140 bar.setTotalSteps ( el.count() ) ;
1136 bar.show(); 1141 bar.show();
1137 incCounter = 0; 1142 incCounter = 0;
1138 1143
1139 while ( inL ) { 1144 while ( inL ) {
1140 1145
1141 qApp->processEvents(); 1146 qApp->processEvents();
1142 if ( ! bar.isVisible() ) 1147 if ( ! bar.isVisible() )
1143 return false; 1148 return false;
1144 if ( incCounter % modulo == 0 ) 1149 if ( incCounter % modulo == 0 )
1145 bar.setProgress( incCounter ); 1150 bar.setProgress( incCounter );
1146 ++incCounter; 1151 ++incCounter;
1147 uid = inL->uid(); 1152 uid = inL->uid();
1148 bool skipIncidence = false; 1153 bool skipIncidence = false;
1149 if ( uid.left(15) == QString("last-syncEvent-") ) 1154 if ( uid.left(15) == QString("last-syncEvent-") )
1150 skipIncidence = true; 1155 skipIncidence = true;
1151 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) 1156 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
1152 skipIncidence = true; 1157 skipIncidence = true;
1153 if ( !skipIncidence ) { 1158 if ( !skipIncidence ) {
1154 inR = remote->incidence( uid ); 1159 inR = remote->incidence( uid );
1155 if ( ! inR ) { 1160 if ( ! inR ) {
1156 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ 1161 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){
1157 // no conflict ********** add or delete local 1162 // no conflict ********** add or delete local
1158 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1163 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1159 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1164 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1160 checkExternSyncEvent(eventLSyncSharp, inL); 1165 checkExternSyncEvent(eventLSyncSharp, inL);
1161 local->deleteIncidence( inL ); 1166 local->deleteIncidence( inL );
1162 ++deletedEventL; 1167 ++deletedEventL;
1163 } else { 1168 } else {
1164 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1169 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1165 inL->removeID(mCurrentSyncDevice ); 1170 inL->removeID(mCurrentSyncDevice );
1166 ++addedEventR; 1171 ++addedEventR;
1167 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1172 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1168 inL->setLastModified( modifiedCalendar ); 1173 inL->setLastModified( modifiedCalendar );
1169 inR = inL->clone(); 1174 inR = inL->clone();
1170 inR->setIDStr( ":" ); 1175 inR->setIDStr( ":" );
1171 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1176 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1172 remote->addIncidence( inR ); 1177 remote->addIncidence( inR );
1173 } 1178 }
1174 } 1179 }
1175 } else { 1180 } else {
1176 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1181 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1177 checkExternSyncEvent(eventLSyncSharp, inL); 1182 checkExternSyncEvent(eventLSyncSharp, inL);
1178 local->deleteIncidence( inL ); 1183 local->deleteIncidence( inL );
1179 ++deletedEventL; 1184 ++deletedEventL;
1180 } else { 1185 } else {
1181 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1186 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1182 ++addedEventR; 1187 ++addedEventR;
1183 inL->setLastModified( modifiedCalendar ); 1188 inL->setLastModified( modifiedCalendar );
1184 inR = inL->clone(); 1189 inR = inL->clone();
1185 inR->setIDStr( ":" ); 1190 inR->setIDStr( ":" );
1186 remote->addIncidence( inR ); 1191 remote->addIncidence( inR );
1187 } 1192 }
1188 } 1193 }
1189 } 1194 }
1190 } else { 1195 } else {
1191 ++filteredOUT; 1196 ++filteredOUT;
1192 } 1197 }
1193 } 1198 }
1194 } 1199 }
1195 inL = el.next(); 1200 inL = el.next();
1196 } 1201 }
1197 int delFut = 0; 1202 int delFut = 0;
1198 int remRem = 0; 1203 int remRem = 0;
1199 if ( mSyncManager->mWriteBackInFuture ) { 1204 if ( mSyncManager->mWriteBackInFuture ) {
1200 er = remote->rawIncidences(); 1205 er = remote->rawIncidences();
1201 remRem = er.count(); 1206 remRem = er.count();
1202 inR = er.first(); 1207 inR = er.first();
1203 QDateTime dt; 1208 QDateTime dt;
1204 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); 1209 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) );
1205 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); 1210 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 );
1206 while ( inR ) { 1211 while ( inR ) {
1207 if ( inR->type() == "Todo" ) { 1212 if ( inR->type() == "Todo" ) {
1208 Todo * t = (Todo*)inR; 1213 Todo * t = (Todo*)inR;
1209 if ( t->hasDueDate() ) 1214 if ( t->hasDueDate() )
1210 dt = t->dtDue(); 1215 dt = t->dtDue();
1211 else 1216 else
1212 dt = cur.addSecs( 62 ); 1217 dt = cur.addSecs( 62 );
1213 } 1218 }
1214 else if (inR->type() == "Event" ) { 1219 else if (inR->type() == "Event" ) {
1215 bool ok; 1220 bool ok;
1216 dt = inR->getNextOccurence( cur, &ok ); 1221 dt = inR->getNextOccurence( cur, &ok );
1217 if ( !ok ) 1222 if ( !ok )
1218 dt = cur.addSecs( -62 ); 1223 dt = cur.addSecs( -62 );
1219 } 1224 }
1220 else 1225 else
1221 dt = inR->dtStart(); 1226 dt = inR->dtStart();
1222 if ( dt < cur || dt > end ) { 1227 if ( dt < cur || dt > end ) {
1223 remote->deleteIncidence( inR ); 1228 remote->deleteIncidence( inR );
1224 ++delFut; 1229 ++delFut;
1225 } 1230 }
1226 inR = er.next(); 1231 inR = er.next();
1227 } 1232 }
1228 } 1233 }
1229 bar.hide(); 1234 bar.hide();
1230 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1235 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1231 eventLSync->setReadOnly( false ); 1236 eventLSync->setReadOnly( false );
1232 eventLSync->setDtStart( mLastCalendarSync ); 1237 eventLSync->setDtStart( mLastCalendarSync );
1233 eventRSync->setDtStart( mLastCalendarSync ); 1238 eventRSync->setDtStart( mLastCalendarSync );
1234 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1239 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1235 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1240 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1236 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1241 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1237 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1242 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1238 eventLSync->setReadOnly( true ); 1243 eventLSync->setReadOnly( true );
1239 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); 1244 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL );
1240 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... 1245 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal...
1241 remote->addEvent( eventRSync ); 1246 remote->addEvent( eventRSync );
1242 else 1247 else
1243 delete eventRSync; 1248 delete eventRSync;
1244 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); 1249 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() );
1245 QString mes; 1250 QString mes;
1246 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 ); 1251 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 );
1247 QString delmess; 1252 QString delmess;
1248 if ( delFut ) { 1253 if ( delFut ) {
1249 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); 1254 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);
1250 mes += delmess; 1255 mes += delmess;
1251 } 1256 }
1252 mes = i18n("Local calendar changed!\n") +mes; 1257 mes = i18n("Local calendar changed!\n") +mes;
1253 mCalendar->checkAlarmForIncidence( 0, true ); 1258 mCalendar->checkAlarmForIncidence( 0, true );
1254 qDebug( mes ); 1259 qDebug( mes );
1255 if ( mSyncManager->mShowSyncSummary ) { 1260 if ( mSyncManager->mShowSyncSummary ) {
1256 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 1261 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
1257 i18n("KO/Pi Synchronization"),i18n("Write back"))) { 1262 i18n("KO/Pi Synchronization"),i18n("Write back"))) {
1258 qDebug("KO: WB cancelled "); 1263 qDebug("KO: WB cancelled ");
1259 mSyncManager->mWriteBackFile = false; 1264 mSyncManager->mWriteBackFile = false;
1260 return syncOK; 1265 return syncOK;
1261 } 1266 }
1262 } 1267 }
1263 return syncOK; 1268 return syncOK;
1264} 1269}
1265 1270
1266void CalendarView::setSyncDevice( QString s ) 1271void CalendarView::setSyncDevice( QString s )
1267{ 1272{
1268 mCurrentSyncDevice= s; 1273 mCurrentSyncDevice= s;
1269} 1274}
1270void CalendarView::setSyncName( QString s ) 1275void CalendarView::setSyncName( QString s )
1271{ 1276{
1272 mCurrentSyncName= s; 1277 mCurrentSyncName= s;
1273} 1278}
1274bool CalendarView::syncCalendar(QString filename, int mode) 1279bool CalendarView::syncCalendar(QString filename, int mode)
1275{ 1280{
1276 //qDebug("syncCalendar %s ", filename.latin1()); 1281 //qDebug("syncCalendar %s ", filename.latin1());
1277 mGlobalSyncMode = SYNC_MODE_NORMAL; 1282 mGlobalSyncMode = SYNC_MODE_NORMAL;
1278 CalendarLocal* calendar = new CalendarLocal(); 1283 CalendarLocal* calendar = new CalendarLocal();
1279 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1284 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1280 FileStorage* storage = new FileStorage( calendar ); 1285 FileStorage* storage = new FileStorage( calendar );
1281 bool syncOK = false; 1286 bool syncOK = false;
1282 storage->setFileName( filename ); 1287 storage->setFileName( filename );
1283 // qDebug("loading ... "); 1288 // qDebug("loading ... ");
1284 if ( storage->load() ) { 1289 if ( storage->load() ) {
1285 getEventViewerDialog()->setSyncMode( true ); 1290 getEventViewerDialog()->setSyncMode( true );
1286 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1291 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1287 getEventViewerDialog()->setSyncMode( false ); 1292 getEventViewerDialog()->setSyncMode( false );
1288 if ( syncOK ) { 1293 if ( syncOK ) {
1289 if ( mSyncManager->mWriteBackFile ) 1294 if ( mSyncManager->mWriteBackFile )
1290 { 1295 {
1291 storage->setSaveFormat( new ICalFormat() ); 1296 storage->setSaveFormat( new ICalFormat() );
1292 storage->save(); 1297 storage->save();
1293 } 1298 }
1294 } 1299 }
1295 setModified( true ); 1300 setModified( true );
1296 } 1301 }
1297 delete storage; 1302 delete storage;
1298 delete calendar; 1303 delete calendar;
1299 if ( syncOK ) 1304 if ( syncOK )
1300 updateView(); 1305 updateView();
1301 return syncOK; 1306 return syncOK;
1302} 1307}
1303 1308
1304void CalendarView::syncExternal( int mode ) 1309void CalendarView::syncExternal( int mode )
1305{ 1310{
1306 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1311 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1307 1312
1308 qApp->processEvents(); 1313 qApp->processEvents();
1309 CalendarLocal* calendar = new CalendarLocal(); 1314 CalendarLocal* calendar = new CalendarLocal();
1310 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1315 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1311 bool syncOK = false; 1316 bool syncOK = false;
1312 bool loadSuccess = false; 1317 bool loadSuccess = false;
1313 PhoneFormat* phoneFormat = 0; 1318 PhoneFormat* phoneFormat = 0;
1314 emit tempDisableBR(true); 1319 emit tempDisableBR(true);
1315#ifndef DESKTOP_VERSION 1320#ifndef DESKTOP_VERSION
1316 SharpFormat* sharpFormat = 0; 1321 SharpFormat* sharpFormat = 0;
1317 if ( mode == 0 ) { // sharp 1322 if ( mode == 0 ) { // sharp
1318 sharpFormat = new SharpFormat () ; 1323 sharpFormat = new SharpFormat () ;
1319 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1324 loadSuccess = sharpFormat->load( calendar, mCalendar );
1320 1325
1321 } else 1326 } else
1322#endif 1327#endif
1323 if ( mode == 1 ) { // phone 1328 if ( mode == 1 ) { // phone
1324 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1329 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1325 mSyncManager->mPhoneDevice, 1330 mSyncManager->mPhoneDevice,
1326 mSyncManager->mPhoneConnection, 1331 mSyncManager->mPhoneConnection,
1327 mSyncManager->mPhoneModel); 1332 mSyncManager->mPhoneModel);
1328 loadSuccess = phoneFormat->load( calendar,mCalendar); 1333 loadSuccess = phoneFormat->load( calendar,mCalendar);
1329 1334
1330 } else { 1335 } else {
1331 emit tempDisableBR(false); 1336 emit tempDisableBR(false);
1332 return; 1337 return;
1333 } 1338 }
1334 if ( loadSuccess ) { 1339 if ( loadSuccess ) {
1335 getEventViewerDialog()->setSyncMode( true ); 1340 getEventViewerDialog()->setSyncMode( true );
1336 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1341 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1337 getEventViewerDialog()->setSyncMode( false ); 1342 getEventViewerDialog()->setSyncMode( false );
1338 qApp->processEvents(); 1343 qApp->processEvents();
1339 if ( syncOK ) { 1344 if ( syncOK ) {
1340 if ( mSyncManager->mWriteBackFile ) 1345 if ( mSyncManager->mWriteBackFile )
1341 { 1346 {
1342 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1347 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1343 Incidence* inc = iL.first(); 1348 Incidence* inc = iL.first();
1344 if ( phoneFormat ) { 1349 if ( phoneFormat ) {
1345 while ( inc ) { 1350 while ( inc ) {
1346 inc->removeID(mCurrentSyncDevice); 1351 inc->removeID(mCurrentSyncDevice);
1347 inc = iL.next(); 1352 inc = iL.next();
1348 } 1353 }
1349 } 1354 }
1350#ifndef DESKTOP_VERSION 1355#ifndef DESKTOP_VERSION
1351 if ( sharpFormat ) 1356 if ( sharpFormat )
1352 sharpFormat->save(calendar); 1357 sharpFormat->save(calendar);
1353#endif 1358#endif
1354 if ( phoneFormat ) 1359 if ( phoneFormat )
1355 phoneFormat->save(calendar); 1360 phoneFormat->save(calendar);
1356 iL = calendar->rawIncidences(); 1361 iL = calendar->rawIncidences();
1357 inc = iL.first(); 1362 inc = iL.first();
1358 Incidence* loc; 1363 Incidence* loc;
1359 while ( inc ) { 1364 while ( inc ) {
1360 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1365 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1361 loc = mCalendar->incidence(inc->uid() ); 1366 loc = mCalendar->incidence(inc->uid() );
1362 if ( loc ) { 1367 if ( loc ) {
1363 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1368 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1364 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1369 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1365 } 1370 }
1366 } 1371 }
1367 inc = iL.next(); 1372 inc = iL.next();
1368 } 1373 }
1369 Incidence* lse = getLastSyncEvent(); 1374 Incidence* lse = getLastSyncEvent();
1370 if ( lse ) { 1375 if ( lse ) {
1371 lse->setReadOnly( false ); 1376 lse->setReadOnly( false );
1372 lse->setDescription( "" ); 1377 lse->setDescription( "" );
1373 lse->setReadOnly( true ); 1378 lse->setReadOnly( true );
1374 } 1379 }
1375 } 1380 }
1376 } else { 1381 } else {
1377 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 1382 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
1378 } 1383 }
1379 setModified( true ); 1384 setModified( true );
1380 } else { 1385 } else {
1381 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1386 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1382 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1387 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1383 question, i18n("Ok")) ; 1388 question, i18n("Ok")) ;
1384 1389
1385 } 1390 }
1386 delete calendar; 1391 delete calendar;
1387 updateView(); 1392 updateView();
1388 emit tempDisableBR(false); 1393 emit tempDisableBR(false);
1389 return ;//syncOK; 1394 return ;//syncOK;
1390 1395
1391} 1396}
1392 1397
1393bool CalendarView::importBday() 1398bool CalendarView::importBday()
1394{ 1399{
1395#ifndef KORG_NOKABC 1400#ifndef KORG_NOKABC
1396 1401
1397#ifdef DESKTOP_VERSION 1402#ifdef DESKTOP_VERSION
1398 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1403 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1399 KABC::AddressBook::Iterator it; 1404 KABC::AddressBook::Iterator it;
1400 int count = 0; 1405 int count = 0;
1401 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1406 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1402 ++count; 1407 ++count;
1403 } 1408 }
1404 QProgressBar bar(count,0 ); 1409 QProgressBar bar(count,0 );
1405 int w = 300; 1410 int w = 300;
1406 if ( QApplication::desktop()->width() < 320 ) 1411 if ( QApplication::desktop()->width() < 320 )
1407 w = 220; 1412 w = 220;
1408 int h = bar.sizeHint().height() ; 1413 int h = bar.sizeHint().height() ;
1409 int dw = QApplication::desktop()->width(); 1414 int dw = QApplication::desktop()->width();
1410 int dh = QApplication::desktop()->height(); 1415 int dh = QApplication::desktop()->height();
1411 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1416 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1412 bar.show(); 1417 bar.show();
1413 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1418 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1414 qApp->processEvents(); 1419 qApp->processEvents();
1415 count = 0; 1420 count = 0;
1416 int addCount = 0; 1421 int addCount = 0;
1417 KCal::Attendee* a = 0; 1422 KCal::Attendee* a = 0;
1418 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1423 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1419 if ( ! bar.isVisible() ) 1424 if ( ! bar.isVisible() )
1420 return false; 1425 return false;
1421 bar.setProgress( count++ ); 1426 bar.setProgress( count++ );
1422 qApp->processEvents(); 1427 qApp->processEvents();
1423 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1428 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1424 if ( (*it).birthday().date().isValid() ){ 1429 if ( (*it).birthday().date().isValid() ){
1425 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1430 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1426 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1431 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1427 ++addCount; 1432 ++addCount;
1428 } 1433 }
1429 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1434 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1430 if ( anni.isValid() ){ 1435 if ( anni.isValid() ){
1431 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1436 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1432 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1437 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1433 ++addCount; 1438 ++addCount;
1434 } 1439 }
1435 } 1440 }
1436 updateView(); 1441 updateView();
1437 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1442 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1438#else //DESKTOP_VERSION 1443#else //DESKTOP_VERSION
1439 1444
1440 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 1445 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
1441 // the result should now arrive through method insertBirthdays 1446 // the result should now arrive through method insertBirthdays
1442 1447
1443#endif //DESKTOP_VERSION 1448#endif //DESKTOP_VERSION
1444 1449
1445#endif //KORG_NOKABC 1450#endif //KORG_NOKABC
1446 1451
1447 1452
1448 return true; 1453 return true;
1449} 1454}
1450 1455
1451// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI 1456// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
1452void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, 1457void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
1453 const QStringList& anniversaryList, const QStringList& realNameList, 1458 const QStringList& anniversaryList, const QStringList& realNameList,
1454 const QStringList& emailList, const QStringList& assembledNameList, 1459 const QStringList& emailList, const QStringList& assembledNameList,
1455 const QStringList& uidList) 1460 const QStringList& uidList)
1456{ 1461{
1457 //qDebug("KO::CalendarView::insertBirthdays"); 1462 //qDebug("KO::CalendarView::insertBirthdays");
1458 if (uid == this->name()) 1463 if (uid == this->name())
1459 { 1464 {
1460 int count = birthdayList.count(); 1465 int count = birthdayList.count();
1461 int addCount = 0; 1466 int addCount = 0;
1462 KCal::Attendee* a = 0; 1467 KCal::Attendee* a = 0;
1463 1468
1464 //qDebug("CalView 1 %i", count); 1469 //qDebug("CalView 1 %i", count);
1465 1470
1466 QProgressBar bar(count,0 ); 1471 QProgressBar bar(count,0 );
1467 int w = 300; 1472 int w = 300;
1468 if ( QApplication::desktop()->width() < 320 ) 1473 if ( QApplication::desktop()->width() < 320 )
1469 w = 220; 1474 w = 220;
1470 int h = bar.sizeHint().height() ; 1475 int h = bar.sizeHint().height() ;
1471 int dw = QApplication::desktop()->width(); 1476 int dw = QApplication::desktop()->width();
1472 int dh = QApplication::desktop()->height(); 1477 int dh = QApplication::desktop()->height();
1473 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1478 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1474 bar.show(); 1479 bar.show();
1475 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 1480 bar.setCaption (i18n("inserting birthdays - close to abort!") );
1476 qApp->processEvents(); 1481 qApp->processEvents();
1477 1482
1478 QDate birthday; 1483 QDate birthday;
1479 QDate anniversary; 1484 QDate anniversary;
1480 QString realName; 1485 QString realName;
1481 QString email; 1486 QString email;
1482 QString assembledName; 1487 QString assembledName;
1483 QString uid; 1488 QString uid;
1484 bool ok = true; 1489 bool ok = true;
1485 for ( int i = 0; i < count; i++) 1490 for ( int i = 0; i < count; i++)
1486 { 1491 {
1487 if ( ! bar.isVisible() ) 1492 if ( ! bar.isVisible() )
1488 return; 1493 return;
1489 bar.setProgress( i ); 1494 bar.setProgress( i );
1490 qApp->processEvents(); 1495 qApp->processEvents();
1491 1496
1492 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); 1497 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
1493 if (!ok) { 1498 if (!ok) {
1494 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); 1499 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
1495 } 1500 }
1496 1501
1497 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); 1502 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
1498 if (!ok) { 1503 if (!ok) {
1499 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); 1504 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
1500 } 1505 }
1501 realName = realNameList[i]; 1506 realName = realNameList[i];
1502 email = emailList[i]; 1507 email = emailList[i];
1503 assembledName = assembledNameList[i]; 1508 assembledName = assembledNameList[i];
1504 uid = uidList[i]; 1509 uid = uidList[i];
1505 //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() ); 1510 //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() );
1506 1511
1507 if ( birthday.isValid() ){ 1512 if ( birthday.isValid() ){
1508 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1513 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1509 KCal::Attendee::ReqParticipant,uid) ; 1514 KCal::Attendee::ReqParticipant,uid) ;
1510 if ( addAnniversary( birthday, assembledName, a, true ) ) 1515 if ( addAnniversary( birthday, assembledName, a, true ) )
1511 ++addCount; 1516 ++addCount;
1512 } 1517 }
1513 1518
1514 if ( anniversary.isValid() ){ 1519 if ( anniversary.isValid() ){
1515 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1520 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1516 KCal::Attendee::ReqParticipant,uid) ; 1521 KCal::Attendee::ReqParticipant,uid) ;
1517 if ( addAnniversary( anniversary, assembledName, a, false ) ) 1522 if ( addAnniversary( anniversary, assembledName, a, false ) )
1518 ++addCount; 1523 ++addCount;
1519 } 1524 }
1520 } 1525 }
1521 1526
1522 updateView(); 1527 updateView();
1523 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1528 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1524 1529
1525 } 1530 }
1526 1531
1527} 1532}
1528 1533
1529 1534
1530 1535
1531bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1536bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1532{ 1537{
1533 //qDebug("addAnni "); 1538 //qDebug("addAnni ");
1534 Event * ev = new Event(); 1539 Event * ev = new Event();
1535 ev->setOrganizer(KOPrefs::instance()->email()); 1540 ev->setOrganizer(KOPrefs::instance()->email());
1536 if ( a ) { 1541 if ( a ) {
1537 ev->addAttendee( a ); 1542 ev->addAttendee( a );
1538 } 1543 }
1539 QString kind; 1544 QString kind;
1540 if ( birthday ) { 1545 if ( birthday ) {
1541 kind = i18n( "Birthday" ); 1546 kind = i18n( "Birthday" );
1542 ev->setSummary( name + " (" + QString::number(date.year()) +")"); 1547 ev->setSummary( name + " (" + QString::number(date.year()) +")");
1543 } 1548 }
1544 else { 1549 else {
1545 kind = i18n( "Anniversary" ); 1550 kind = i18n( "Anniversary" );
1546 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); 1551 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind );
1547 } 1552 }
1548 ev->setCategories( kind ); 1553 ev->setCategories( kind );
1549 ev->setDtStart( QDateTime(date) ); 1554 ev->setDtStart( QDateTime(date) );
1550 ev->setDtEnd( QDateTime(date) ); 1555 ev->setDtEnd( QDateTime(date) );
1551 ev->setFloats( true ); 1556 ev->setFloats( true );
1552 Recurrence * rec = ev->recurrence(); 1557 Recurrence * rec = ev->recurrence();
1553 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1558 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1554 rec->addYearlyNum( date.month() ); 1559 rec->addYearlyNum( date.month() );
1555 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1560 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1556 delete ev; 1561 delete ev;
1557 return false; 1562 return false;
1558 } 1563 }
1559 return true; 1564 return true;
1560 1565
1561} 1566}
1562bool CalendarView::importQtopia( const QString &categories, 1567bool CalendarView::importQtopia( const QString &categories,
1563 const QString &datebook, 1568 const QString &datebook,
1564 const QString &todolist ) 1569 const QString &todolist )
1565{ 1570{
1566 1571
1567 QtopiaFormat qtopiaFormat; 1572 QtopiaFormat qtopiaFormat;
1568 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1573 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1569 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1574 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1570 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1575 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1571 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1576 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1572 1577
1573 updateView(); 1578 updateView();
1574 return true; 1579 return true;
1575 1580
1576#if 0 1581#if 0
1577 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1582 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1578 mCurrentSyncDevice = "qtopia-XML"; 1583 mCurrentSyncDevice = "qtopia-XML";
1579 if ( mSyncManager->mAskForPreferences ) 1584 if ( mSyncManager->mAskForPreferences )
1580 edit_sync_options(); 1585 edit_sync_options();
1581 qApp->processEvents(); 1586 qApp->processEvents();
1582 CalendarLocal* calendar = new CalendarLocal(); 1587 CalendarLocal* calendar = new CalendarLocal();
1583 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1588 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1584 bool syncOK = false; 1589 bool syncOK = false;
1585 QtopiaFormat qtopiaFormat; 1590 QtopiaFormat qtopiaFormat;
1586 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1591 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1587 bool loadOk = true; 1592 bool loadOk = true;
1588 if ( !categories.isEmpty() ) 1593 if ( !categories.isEmpty() )
1589 loadOk = qtopiaFormat.load( calendar, categories ); 1594 loadOk = qtopiaFormat.load( calendar, categories );
1590 if ( loadOk && !datebook.isEmpty() ) 1595 if ( loadOk && !datebook.isEmpty() )
1591 loadOk = qtopiaFormat.load( calendar, datebook ); 1596 loadOk = qtopiaFormat.load( calendar, datebook );
1592 if ( loadOk && !todolist.isEmpty() ) 1597 if ( loadOk && !todolist.isEmpty() )
1593 loadOk = qtopiaFormat.load( calendar, todolist ); 1598 loadOk = qtopiaFormat.load( calendar, todolist );
1594 1599
1595 if ( loadOk ) { 1600 if ( loadOk ) {
1596 getEventViewerDialog()->setSyncMode( true ); 1601 getEventViewerDialog()->setSyncMode( true );
1597 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1602 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1598 getEventViewerDialog()->setSyncMode( false ); 1603 getEventViewerDialog()->setSyncMode( false );
1599 qApp->processEvents(); 1604 qApp->processEvents();
1600 if ( syncOK ) { 1605 if ( syncOK ) {
1601 if ( mSyncManager->mWriteBackFile ) 1606 if ( mSyncManager->mWriteBackFile )
1602 { 1607 {
1603 // write back XML file 1608 // write back XML file
1604 1609
1605 } 1610 }
1606 setModified( true ); 1611 setModified( true );
1607 } 1612 }
1608 } else { 1613 } else {
1609 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1614 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1610 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1615 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1611 question, i18n("Ok")) ; 1616 question, i18n("Ok")) ;
1612 } 1617 }
1613 delete calendar; 1618 delete calendar;
1614 updateView(); 1619 updateView();
1615 return syncOK; 1620 return syncOK;
1616 1621
1617 1622
1618#endif 1623#endif
1619 1624
1620} 1625}
1621 1626
1622void CalendarView::setSyncEventsReadOnly() 1627void CalendarView::setSyncEventsReadOnly()
1623{ 1628{
1624 Event * ev; 1629 Event * ev;
1625 QPtrList<Event> eL = mCalendar->rawEvents(); 1630 QPtrList<Event> eL = mCalendar->rawEvents();
1626 ev = eL.first(); 1631 ev = eL.first();
1627 while ( ev ) { 1632 while ( ev ) {
1628 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1633 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1629 ev->setReadOnly( true ); 1634 ev->setReadOnly( true );
1630 ev = eL.next(); 1635 ev = eL.next();
1631 } 1636 }
1632} 1637}
1633bool CalendarView::openCalendar(QString filename, bool merge) 1638bool CalendarView::openCalendar(QString filename, bool merge)
1634{ 1639{
1635 1640
1636 if (filename.isEmpty()) { 1641 if (filename.isEmpty()) {
1637 return false; 1642 return false;
1638 } 1643 }
1639 1644
1640 if (!QFile::exists(filename)) { 1645 if (!QFile::exists(filename)) {
1641 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1646 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1642 return false; 1647 return false;
1643 } 1648 }
1644 1649
1645 globalFlagBlockAgenda = 1; 1650 globalFlagBlockAgenda = 1;
1646 if (!merge) mCalendar->close(); 1651 if (!merge) mCalendar->close();
1647 1652
1648 mStorage->setFileName( filename ); 1653 mStorage->setFileName( filename );
1649 1654
1650 if ( mStorage->load() ) { 1655 if ( mStorage->load() ) {
1651 if ( merge ) ;//setModified( true ); 1656 if ( merge ) ;//setModified( true );
1652 else { 1657 else {
1653 //setModified( true ); 1658 //setModified( true );
1654 mViewManager->setDocumentId( filename ); 1659 mViewManager->setDocumentId( filename );
1655 mDialogManager->setDocumentId( filename ); 1660 mDialogManager->setDocumentId( filename );
1656 mTodoList->setDocumentId( filename ); 1661 mTodoList->setDocumentId( filename );
1657 } 1662 }
1658 globalFlagBlockAgenda = 2; 1663 globalFlagBlockAgenda = 2;
1659 // if ( getLastSyncEvent() ) 1664 // if ( getLastSyncEvent() )
1660 // getLastSyncEvent()->setReadOnly( true ); 1665 // getLastSyncEvent()->setReadOnly( true );
1661 mCalendar->reInitAlarmSettings(); 1666 mCalendar->reInitAlarmSettings();
1662 setSyncEventsReadOnly(); 1667 setSyncEventsReadOnly();
1663 updateUnmanagedViews(); 1668 updateUnmanagedViews();
1664 updateView(); 1669 updateView();
1665 if ( filename != MainWindow::defaultFileName() ) { 1670 if ( filename != MainWindow::defaultFileName() ) {
1666 saveCalendar( MainWindow::defaultFileName() ); 1671 saveCalendar( MainWindow::defaultFileName() );
1667 } else { 1672 } else {
1668 QFileInfo finf ( MainWindow::defaultFileName()); 1673 QFileInfo finf ( MainWindow::defaultFileName());
1669 if ( finf.exists() ) { 1674 if ( finf.exists() ) {
1670 setLoadedFileVersion( finf.lastModified () ); 1675 setLoadedFileVersion( finf.lastModified () );
1671 } 1676 }
1672 } 1677 }
1673 return true; 1678 return true;
1674 } else { 1679 } else {
1675 // while failing to load, the calendar object could 1680 // while failing to load, the calendar object could
1676 // have become partially populated. Clear it out. 1681 // have become partially populated. Clear it out.
1677 if ( !merge ) { 1682 if ( !merge ) {
1678 mCalendar->close(); 1683 mCalendar->close();
1679 mViewManager->setDocumentId( filename ); 1684 mViewManager->setDocumentId( filename );
1680 mDialogManager->setDocumentId( filename ); 1685 mDialogManager->setDocumentId( filename );
1681 mTodoList->setDocumentId( filename ); 1686 mTodoList->setDocumentId( filename );
1682 } 1687 }
1683 1688
1684 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1689 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1685 1690
1686 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 1691 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
1687 globalFlagBlockAgenda = 2; 1692 globalFlagBlockAgenda = 2;
1688 mCalendar->reInitAlarmSettings(); 1693 mCalendar->reInitAlarmSettings();
1689 setSyncEventsReadOnly(); 1694 setSyncEventsReadOnly();
1690 updateUnmanagedViews(); 1695 updateUnmanagedViews();
1691 updateView(); 1696 updateView();
1692 } 1697 }
1693 return false; 1698 return false;
1694} 1699}
1695void CalendarView::showOpenError() 1700void CalendarView::showOpenError()
1696{ 1701{
1697 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 1702 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
1698} 1703}
1699void CalendarView::setLoadedFileVersion(QDateTime dt) 1704void CalendarView::setLoadedFileVersion(QDateTime dt)
1700{ 1705{
1701 loadedFileVersion = dt; 1706 loadedFileVersion = dt;
1702} 1707}
1703bool CalendarView::checkFileChanged(QString fn) 1708bool CalendarView::checkFileChanged(QString fn)
1704{ 1709{
1705 QFileInfo finf ( fn ); 1710 QFileInfo finf ( fn );
1706 if ( !finf.exists() ) 1711 if ( !finf.exists() )
1707 return true; 1712 return true;
1708 QDateTime dt = finf.lastModified (); 1713 QDateTime dt = finf.lastModified ();
1709 if ( dt <= loadedFileVersion ) 1714 if ( dt <= loadedFileVersion )
1710 return false; 1715 return false;
1711 return true; 1716 return true;
1712 1717
1713} 1718}
1714void CalendarView::watchSavedFile() 1719void CalendarView::watchSavedFile()
1715{ 1720{
1716 QFileInfo finf ( MainWindow::defaultFileName()); 1721 QFileInfo finf ( MainWindow::defaultFileName());
1717 if ( !finf.exists() ) 1722 if ( !finf.exists() )
1718 return; 1723 return;
1719 QDateTime dt = finf.lastModified (); 1724 QDateTime dt = finf.lastModified ();
1720 if ( dt < loadedFileVersion ) { 1725 if ( dt < loadedFileVersion ) {
1721 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 1726 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
1722 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 1727 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1723 return; 1728 return;
1724 } 1729 }
1725 loadedFileVersion = dt; 1730 loadedFileVersion = dt;
1726} 1731}
1727 1732
1728bool CalendarView::checkFileVersion(QString fn) 1733bool CalendarView::checkFileVersion(QString fn)
1729{ 1734{
1730 QFileInfo finf ( fn ); 1735 QFileInfo finf ( fn );
1731 if ( !finf.exists() ) 1736 if ( !finf.exists() )
1732 return true; 1737 return true;
1733 QDateTime dt = finf.lastModified (); 1738 QDateTime dt = finf.lastModified ();
1734 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1739 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1735 //qDebug("file on disk version %s",dt.toString().latin1()); 1740 //qDebug("file on disk version %s",dt.toString().latin1());
1736 if ( dt <= loadedFileVersion ) 1741 if ( dt <= loadedFileVersion )
1737 return true; 1742 return true;
1738 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)) , 1743 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)) ,
1739 i18n("KO/Pi Warning"),i18n("Overwrite"), 1744 i18n("KO/Pi Warning"),i18n("Overwrite"),
1740 i18n("Sync+save")); 1745 i18n("Sync+save"));
1741 1746
1742 if ( km == KMessageBox::Cancel ) 1747 if ( km == KMessageBox::Cancel )
1743 return false; 1748 return false;
1744 if ( km == KMessageBox::Yes ) 1749 if ( km == KMessageBox::Yes )
1745 return true; 1750 return true;
1746 1751
1747 setSyncDevice("deleteaftersync" ); 1752 setSyncDevice("deleteaftersync" );
1748 mSyncManager->mAskForPreferences = true; 1753 mSyncManager->mAskForPreferences = true;
1749 mSyncManager->mSyncAlgoPrefs = 3; 1754 mSyncManager->mSyncAlgoPrefs = 3;
1750 mSyncManager->mWriteBackFile = false; 1755 mSyncManager->mWriteBackFile = false;
1751 mSyncManager->mWriteBackExistingOnly = false; 1756 mSyncManager->mWriteBackExistingOnly = false;
1752 mSyncManager->mShowSyncSummary = false; 1757 mSyncManager->mShowSyncSummary = false;
1753 syncCalendar( fn, 3 ); 1758 syncCalendar( fn, 3 );
1754 Event * e = getLastSyncEvent(); 1759 Event * e = getLastSyncEvent();
1755 mCalendar->deleteEvent ( e ); 1760 mCalendar->deleteEvent ( e );
1756 updateView(); 1761 updateView();
1757 return true; 1762 return true;
1758} 1763}
1759 1764
1760bool CalendarView::saveCalendar( QString filename ) 1765bool CalendarView::saveCalendar( QString filename )
1761{ 1766{
1762 1767
1763 // Store back all unsaved data into calendar object 1768 // Store back all unsaved data into calendar object
1764 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1769 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1765 if ( mViewManager->currentView() ) 1770 if ( mViewManager->currentView() )
1766 mViewManager->currentView()->flushView(); 1771 mViewManager->currentView()->flushView();
1767 1772
1768 1773
1769 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 1774 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
1770 mStorage->setSaveFormat( new ICalFormat() ); 1775 mStorage->setSaveFormat( new ICalFormat() );
1771 mStorage->setFileName( filename ); 1776 mStorage->setFileName( filename );
1772 bool success; 1777 bool success;
1773 success = mStorage->save(); 1778 success = mStorage->save();
1774 if ( !success ) { 1779 if ( !success ) {
1775 return false; 1780 return false;
1776 } 1781 }
1777 if ( filename == MainWindow::defaultFileName() ) { 1782 if ( filename == MainWindow::defaultFileName() ) {
1778 setLoadedFileVersion( lfv ); 1783 setLoadedFileVersion( lfv );
1779 watchSavedFile(); 1784 watchSavedFile();
1780 } 1785 }
1781 return true; 1786 return true;
1782} 1787}
1783 1788
1784void CalendarView::closeCalendar() 1789void CalendarView::closeCalendar()
1785{ 1790{
1786 1791
1787 // child windows no longer valid 1792 // child windows no longer valid
1788 emit closingDown(); 1793 emit closingDown();
1789 1794
1790 mCalendar->close(); 1795 mCalendar->close();
1791 setModified(false); 1796 setModified(false);
1792 updateView(); 1797 updateView();
1793} 1798}
1794 1799
1795void CalendarView::archiveCalendar() 1800void CalendarView::archiveCalendar()
1796{ 1801{
1797 mDialogManager->showArchiveDialog(); 1802 mDialogManager->showArchiveDialog();
1798} 1803}
1799 1804
1800 1805
1801void CalendarView::readSettings() 1806void CalendarView::readSettings()
1802{ 1807{
1803 1808
1804 1809
1805 // mViewManager->showAgendaView(); 1810 // mViewManager->showAgendaView();
1806 QString str; 1811 QString str;
1807 //qDebug("CalendarView::readSettings() "); 1812 //qDebug("CalendarView::readSettings() ");
1808 // read settings from the KConfig, supplying reasonable 1813 // read settings from the KConfig, supplying reasonable
1809 // defaults where none are to be found 1814 // defaults where none are to be found
1810 KConfig *config = KOGlobals::config(); 1815 KConfig *config = KOGlobals::config();
1811#ifndef KORG_NOSPLITTER 1816#ifndef KORG_NOSPLITTER
1812 config->setGroup("KOrganizer Geometry"); 1817 config->setGroup("KOrganizer Geometry");
1813 1818
1814 QValueList<int> sizes = config->readIntListEntry("Separator1"); 1819 QValueList<int> sizes = config->readIntListEntry("Separator1");
1815 if (sizes.count() != 2) { 1820 if (sizes.count() != 2) {
1816 sizes << mDateNavigator->minimumSizeHint().width(); 1821 sizes << mDateNavigator->minimumSizeHint().width();
1817 sizes << 300; 1822 sizes << 300;
1818 } 1823 }
1819 mPanner->setSizes(sizes); 1824 mPanner->setSizes(sizes);
1820 1825
1821 sizes = config->readIntListEntry("Separator2"); 1826 sizes = config->readIntListEntry("Separator2");
1822 if ( ( mResourceView && sizes.count() == 4 ) || 1827 if ( ( mResourceView && sizes.count() == 4 ) ||
1823 ( !mResourceView && sizes.count() == 3 ) ) { 1828 ( !mResourceView && sizes.count() == 3 ) ) {
1824 mLeftSplitter->setSizes(sizes); 1829 mLeftSplitter->setSizes(sizes);
1825 } 1830 }
1826#endif 1831#endif
1827 globalFlagBlockAgenda = 1; 1832 globalFlagBlockAgenda = 1;
1828 mViewManager->showAgendaView(); 1833 mViewManager->showAgendaView();
1829 //mViewManager->readSettings( config ); 1834 //mViewManager->readSettings( config );
1830 mTodoList->restoreLayout(config,QString("Todo Layout")); 1835 mTodoList->restoreLayout(config,QString("Todo Layout"));
1831 readFilterSettings(config); 1836 readFilterSettings(config);
1832 1837
1833#ifdef DESKTOP_VERSION 1838#ifdef DESKTOP_VERSION
1834 config->setGroup("WidgetLayout"); 1839 config->setGroup("WidgetLayout");
1835 QStringList list; 1840 QStringList list;
1836 list = config->readListEntry("MainLayout"); 1841 list = config->readListEntry("MainLayout");
1837 int x,y,w,h; 1842 int x,y,w,h;
1838 if ( ! list.isEmpty() ) { 1843 if ( ! list.isEmpty() ) {
1839 x = list[0].toInt(); 1844 x = list[0].toInt();
1840 y = list[1].toInt(); 1845 y = list[1].toInt();
1841 w = list[2].toInt(); 1846 w = list[2].toInt();
1842 h = list[3].toInt(); 1847 h = list[3].toInt();
1843 KApplication::testCoords( &x,&y,&w,&h ); 1848 KApplication::testCoords( &x,&y,&w,&h );
1844 topLevelWidget()->setGeometry(x,y,w,h); 1849 topLevelWidget()->setGeometry(x,y,w,h);
1845 1850
1846 } else { 1851 } else {
1847 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 1852 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
1848 } 1853 }
1849 list = config->readListEntry("EditEventLayout"); 1854 list = config->readListEntry("EditEventLayout");
1850 if ( ! list.isEmpty() ) { 1855 if ( ! list.isEmpty() ) {
1851 x = list[0].toInt(); 1856 x = list[0].toInt();
1852 y = list[1].toInt(); 1857 y = list[1].toInt();
1853 w = list[2].toInt(); 1858 w = list[2].toInt();
1854 h = list[3].toInt(); 1859 h = list[3].toInt();
1855 KApplication::testCoords( &x,&y,&w,&h ); 1860 KApplication::testCoords( &x,&y,&w,&h );
1856 mEventEditor->setGeometry(x,y,w,h); 1861 mEventEditor->setGeometry(x,y,w,h);
1857 1862
1858 } 1863 }
1859 list = config->readListEntry("EditTodoLayout"); 1864 list = config->readListEntry("EditTodoLayout");
1860 if ( ! list.isEmpty() ) { 1865 if ( ! list.isEmpty() ) {
1861 x = list[0].toInt(); 1866 x = list[0].toInt();
1862 y = list[1].toInt(); 1867 y = list[1].toInt();
1863 w = list[2].toInt(); 1868 w = list[2].toInt();
1864 h = list[3].toInt(); 1869 h = list[3].toInt();
1865 KApplication::testCoords( &x,&y,&w,&h ); 1870 KApplication::testCoords( &x,&y,&w,&h );
1866 mTodoEditor->setGeometry(x,y,w,h); 1871 mTodoEditor->setGeometry(x,y,w,h);
1867 1872
1868 } 1873 }
1869 list = config->readListEntry("ViewerLayout"); 1874 list = config->readListEntry("ViewerLayout");
1870 if ( ! list.isEmpty() ) { 1875 if ( ! list.isEmpty() ) {
1871 x = list[0].toInt(); 1876 x = list[0].toInt();
1872 y = list[1].toInt(); 1877 y = list[1].toInt();
1873 w = list[2].toInt(); 1878 w = list[2].toInt();
1874 h = list[3].toInt(); 1879 h = list[3].toInt();
1875 KApplication::testCoords( &x,&y,&w,&h ); 1880 KApplication::testCoords( &x,&y,&w,&h );
1876 getEventViewerDialog()->setGeometry(x,y,w,h); 1881 getEventViewerDialog()->setGeometry(x,y,w,h);
1877 } 1882 }
1878#endif 1883#endif
1879 config->setGroup( "Views" ); 1884 config->setGroup( "Views" );
1880 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 1885 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
1881 1886
1882 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); 1887 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame");
1883 1888
1884 int resetval = 0; 1889 int resetval = 0;
1885 int maxVal = 0; 1890 int maxVal = 0;
1886 if (sizes.count() != 3) { 1891 if (sizes.count() != 3) {
1887 if ( KOPrefs::instance()->mVerticalScreen ) { 1892 if ( KOPrefs::instance()->mVerticalScreen ) {
1888 resetval = mDateNavigator->sizeHint().width()+2; 1893 resetval = mDateNavigator->sizeHint().width()+2;
1889 } else { 1894 } else {
1890 resetval = mDateNavigator->sizeHint().height()+2; 1895 resetval = mDateNavigator->sizeHint().height()+2;
1891 } 1896 }
1892 } 1897 }
1893 if ( resetval ) { 1898 if ( resetval ) {
1894 sizes.clear(); 1899 sizes.clear();
1895 if ( KOPrefs::instance()->mVerticalScreen ) { 1900 if ( KOPrefs::instance()->mVerticalScreen ) {
1896 maxVal = QApplication::desktop()->width() -10; 1901 maxVal = QApplication::desktop()->width() -10;
1897 } else { 1902 } else {
1898 maxVal = QApplication::desktop()->height()-10; 1903 maxVal = QApplication::desktop()->height()-10;
1899 } 1904 }
1900 sizes << resetval; 1905 sizes << resetval;
1901 if ( maxVal < resetval + resetval) 1906 if ( maxVal < resetval + resetval)
1902 resetval = maxVal - resetval; 1907 resetval = maxVal - resetval;
1903 sizes << resetval; 1908 sizes << resetval;
1904 sizes << 100; 1909 sizes << 100;
1905 } 1910 }
1906 mLeftFrame->setSizes(sizes); 1911 mLeftFrame->setSizes(sizes);
1907 sizes = config->readIntListEntry("Main Splitter Frame"); 1912 sizes = config->readIntListEntry("Main Splitter Frame");
1908 resetval = 0; 1913 resetval = 0;
1909 maxVal = 0; 1914 maxVal = 0;
1910 if (sizes.count() != 2) { 1915 if (sizes.count() != 2) {
1911 if ( !KOPrefs::instance()->mVerticalScreen ) { 1916 if ( !KOPrefs::instance()->mVerticalScreen ) {
1912 resetval = mDateNavigator->sizeHint().width()+2; 1917 resetval = mDateNavigator->sizeHint().width()+2;
1913 } else { 1918 } else {
1914 resetval = mDateNavigator->sizeHint().height()+2; 1919 resetval = mDateNavigator->sizeHint().height()+2;
1915 } 1920 }
1916 } 1921 }
1917 if ( resetval ) { 1922 if ( resetval ) {
1918 sizes.clear(); 1923 sizes.clear();
1919 if ( !KOPrefs::instance()->mVerticalScreen ) { 1924 if ( !KOPrefs::instance()->mVerticalScreen ) {
1920 maxVal = QApplication::desktop()->width() -10; 1925 maxVal = QApplication::desktop()->width() -10;
1921 } else { 1926 } else {
1922 maxVal = QApplication::desktop()->height()-10; 1927 maxVal = QApplication::desktop()->height()-10;
1923 } 1928 }
1924 sizes << resetval; 1929 sizes << resetval;
1925 if ( maxVal < resetval + resetval) 1930 if ( maxVal < resetval + resetval)
1926 resetval = maxVal - resetval; 1931 resetval = maxVal - resetval;
1927 sizes << resetval; 1932 sizes << resetval;
1928 } 1933 }
1929 mMainFrame->setSizes(sizes); 1934 mMainFrame->setSizes(sizes);
1930 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 1935 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
1931 else if ( dateCount == 7 ) mNavigator->selectWeek(); 1936 else if ( dateCount == 7 ) mNavigator->selectWeek();
1932 else mNavigator->selectDates( dateCount ); 1937 else mNavigator->selectDates( dateCount );
1933 // mViewManager->readSettings( config ); 1938 // mViewManager->readSettings( config );
1934 updateConfig(); 1939 updateConfig();
1935 globalFlagBlockAgenda = 2; 1940 globalFlagBlockAgenda = 2;
1936 mViewManager->readSettings( config ); 1941 mViewManager->readSettings( config );
1937 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); 1942 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) );
1938} 1943}
1939 1944
1940 1945
1941void CalendarView::writeSettings() 1946void CalendarView::writeSettings()
1942{ 1947{
1943 // kdDebug() << "CalendarView::writeSettings" << endl; 1948 // kdDebug() << "CalendarView::writeSettings" << endl;
1944 1949
1945 KConfig *config = KOGlobals::config(); 1950 KConfig *config = KOGlobals::config();
1946 1951
1947 mViewManager->writeSettings( config ); 1952 mViewManager->writeSettings( config );
1948 mTodoList->saveLayout(config,QString("Todo Layout")); 1953 mTodoList->saveLayout(config,QString("Todo Layout"));
1949 mDialogManager->writeSettings( config ); 1954 mDialogManager->writeSettings( config );
1950 //KOPrefs::instance()->usrWriteConfig(); 1955 //KOPrefs::instance()->usrWriteConfig();
1951 KOPrefs::instance()->writeConfig(); 1956 KOPrefs::instance()->writeConfig();
1952 1957
1953 writeFilterSettings(config); 1958 writeFilterSettings(config);
1954 1959
1955 config->setGroup( "Views" ); 1960 config->setGroup( "Views" );
1956 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 1961 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
1957 1962
1958 QValueList<int> listINT = mLeftFrame->sizes(); 1963 QValueList<int> listINT = mLeftFrame->sizes();
1959 config->writeEntry("Left Splitter Frame",listINT); 1964 config->writeEntry("Left Splitter Frame",listINT);
1960 QValueList<int> listINT2 = mMainFrame->sizes(); 1965 QValueList<int> listINT2 = mMainFrame->sizes();
1961 config->writeEntry("Main Splitter Frame",listINT2); 1966 config->writeEntry("Main Splitter Frame",listINT2);
1962#ifdef DESKTOP_VERSION 1967#ifdef DESKTOP_VERSION
1963 config->setGroup("WidgetLayout"); 1968 config->setGroup("WidgetLayout");
1964 QStringList list ;//= config->readListEntry("MainLayout"); 1969 QStringList list ;//= config->readListEntry("MainLayout");
1965 int x,y,w,h; 1970 int x,y,w,h;
1966 QWidget* wid; 1971 QWidget* wid;
1967 wid = topLevelWidget(); 1972 wid = topLevelWidget();
1968 x = wid->geometry().x(); 1973 x = wid->geometry().x();
1969 y = wid->geometry().y(); 1974 y = wid->geometry().y();
1970 w = wid->width(); 1975 w = wid->width();
1971 h = wid->height(); 1976 h = wid->height();
1972 list.clear(); 1977 list.clear();
1973 list << QString::number( x ); 1978 list << QString::number( x );
1974 list << QString::number( y ); 1979 list << QString::number( y );
1975 list << QString::number( w ); 1980 list << QString::number( w );
1976 list << QString::number( h ); 1981 list << QString::number( h );
1977 config->writeEntry("MainLayout",list ); 1982 config->writeEntry("MainLayout",list );
1978 1983
1979 wid = mEventEditor; 1984 wid = mEventEditor;
1980 x = wid->geometry().x(); 1985 x = wid->geometry().x();
1981 y = wid->geometry().y(); 1986 y = wid->geometry().y();
1982 w = wid->width(); 1987 w = wid->width();
1983 h = wid->height(); 1988 h = wid->height();
1984 list.clear(); 1989 list.clear();
1985 list << QString::number( x ); 1990 list << QString::number( x );
1986 list << QString::number( y ); 1991 list << QString::number( y );
1987 list << QString::number( w ); 1992 list << QString::number( w );
1988 list << QString::number( h ); 1993 list << QString::number( h );
1989 config->writeEntry("EditEventLayout",list ); 1994 config->writeEntry("EditEventLayout",list );
1990 1995
1991 wid = mTodoEditor; 1996 wid = mTodoEditor;
1992 x = wid->geometry().x(); 1997 x = wid->geometry().x();
1993 y = wid->geometry().y(); 1998 y = wid->geometry().y();
1994 w = wid->width(); 1999 w = wid->width();
1995 h = wid->height(); 2000 h = wid->height();
1996 list.clear(); 2001 list.clear();
1997 list << QString::number( x ); 2002 list << QString::number( x );
1998 list << QString::number( y ); 2003 list << QString::number( y );
1999 list << QString::number( w ); 2004 list << QString::number( w );
2000 list << QString::number( h ); 2005 list << QString::number( h );
2001 config->writeEntry("EditTodoLayout",list ); 2006 config->writeEntry("EditTodoLayout",list );
2002 wid = getEventViewerDialog(); 2007 wid = getEventViewerDialog();
2003 x = wid->geometry().x(); 2008 x = wid->geometry().x();
2004 y = wid->geometry().y(); 2009 y = wid->geometry().y();
2005 w = wid->width(); 2010 w = wid->width();
2006 h = wid->height(); 2011 h = wid->height();
2007 list.clear(); 2012 list.clear();
2008 list << QString::number( x ); 2013 list << QString::number( x );
2009 list << QString::number( y ); 2014 list << QString::number( y );
2010 list << QString::number( w ); 2015 list << QString::number( w );
2011 list << QString::number( h ); 2016 list << QString::number( h );
2012 config->writeEntry("ViewerLayout",list ); 2017 config->writeEntry("ViewerLayout",list );
2013 wid = mDialogManager->getSearchDialog(); 2018 wid = mDialogManager->getSearchDialog();
2014 if ( wid ) { 2019 if ( wid ) {
2015 x = wid->geometry().x(); 2020 x = wid->geometry().x();
2016 y = wid->geometry().y(); 2021 y = wid->geometry().y();
2017 w = wid->width(); 2022 w = wid->width();
2018 h = wid->height(); 2023 h = wid->height();
2019 list.clear(); 2024 list.clear();
2020 list << QString::number( x ); 2025 list << QString::number( x );
2021 list << QString::number( y ); 2026 list << QString::number( y );
2022 list << QString::number( w ); 2027 list << QString::number( w );
2023 list << QString::number( h ); 2028 list << QString::number( h );
2024 config->writeEntry("SearchLayout",list ); 2029 config->writeEntry("SearchLayout",list );
2025 } 2030 }
2026#endif 2031#endif
2027 2032
2028 2033
2029 config->sync(); 2034 config->sync();
2030} 2035}
2031 2036
2032void CalendarView::readFilterSettings(KConfig *config) 2037void CalendarView::readFilterSettings(KConfig *config)
2033{ 2038{
2034 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 2039 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
2035 2040
2036 mFilters.clear(); 2041 mFilters.clear();
2037 2042
2038 config->setGroup("General"); 2043 config->setGroup("General");
2039 QStringList filterList = config->readListEntry("CalendarFilters"); 2044 QStringList filterList = config->readListEntry("CalendarFilters");
2040 2045
2041 QStringList::ConstIterator it = filterList.begin(); 2046 QStringList::ConstIterator it = filterList.begin();
2042 QStringList::ConstIterator end = filterList.end(); 2047 QStringList::ConstIterator end = filterList.end();
2043 while(it != end) { 2048 while(it != end) {
2044 // kdDebug() << " filter: " << (*it) << endl; 2049 // kdDebug() << " filter: " << (*it) << endl;
2045 2050
2046 CalFilter *filter; 2051 CalFilter *filter;
2047 filter = new CalFilter(*it); 2052 filter = new CalFilter(*it);
2048 config->setGroup("Filter_" + (*it).utf8()); 2053 config->setGroup("Filter_" + (*it).utf8());
2049 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 2054 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
2050 filter->setCriteria(config->readNumEntry("Criteria",0)); 2055 filter->setCriteria(config->readNumEntry("Criteria",0));
2051 filter->setCategoryList(config->readListEntry("CategoryList")); 2056 filter->setCategoryList(config->readListEntry("CategoryList"));
2052 mFilters.append(filter); 2057 mFilters.append(filter);
2053 2058
2054 ++it; 2059 ++it;
2055 } 2060 }
2056 2061
2057 if (mFilters.count() == 0) { 2062 if (mFilters.count() == 0) {
2058 CalFilter *filter = new CalFilter(i18n("Default")); 2063 CalFilter *filter = new CalFilter(i18n("Default"));
2059 mFilters.append(filter); 2064 mFilters.append(filter);
2060 } 2065 }
2061 mFilterView->updateFilters(); 2066 mFilterView->updateFilters();
2062 config->setGroup("FilterView"); 2067 config->setGroup("FilterView");
2063 2068
2064 mFilterView->blockSignals(true); 2069 mFilterView->blockSignals(true);
2065 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 2070 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
2066 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 2071 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
2067 mFilterView->blockSignals(false); 2072 mFilterView->blockSignals(false);
2068 // We do it manually to avoid it being done twice by the above calls 2073 // We do it manually to avoid it being done twice by the above calls
2069 updateFilter(); 2074 updateFilter();
2070} 2075}
2071 2076
2072void CalendarView::writeFilterSettings(KConfig *config) 2077void CalendarView::writeFilterSettings(KConfig *config)
2073{ 2078{
2074 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 2079 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
2075 2080
2076 QStringList filterList; 2081 QStringList filterList;
2077 2082
2078 CalFilter *filter = mFilters.first(); 2083 CalFilter *filter = mFilters.first();
2079 while(filter) { 2084 while(filter) {
2080 // kdDebug() << " fn: " << filter->name() << endl; 2085 // kdDebug() << " fn: " << filter->name() << endl;
2081 filterList << filter->name(); 2086 filterList << filter->name();
2082 config->setGroup("Filter_" + filter->name().utf8()); 2087 config->setGroup("Filter_" + filter->name().utf8());
2083 config->writeEntry("Criteria",filter->criteria()); 2088 config->writeEntry("Criteria",filter->criteria());
2084 config->writeEntry("CategoryList",filter->categoryList()); 2089 config->writeEntry("CategoryList",filter->categoryList());
2085 filter = mFilters.next(); 2090 filter = mFilters.next();
2086 } 2091 }
2087 config->setGroup("General"); 2092 config->setGroup("General");
2088 config->writeEntry("CalendarFilters",filterList); 2093 config->writeEntry("CalendarFilters",filterList);
2089 2094
2090 config->setGroup("FilterView"); 2095 config->setGroup("FilterView");
2091 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 2096 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
2092 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 2097 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
2093} 2098}
2094 2099
2095 2100
2096void CalendarView::goToday() 2101void CalendarView::goToday()
2097{ 2102{
2098 if ( mViewManager->currentView()->isMonthView() ) 2103 if ( mViewManager->currentView()->isMonthView() )
2099 mNavigator->selectTodayMonth(); 2104 mNavigator->selectTodayMonth();
2100 else 2105 else
2101 mNavigator->selectToday(); 2106 mNavigator->selectToday();
2102} 2107}
2103 2108
2104void CalendarView::goNext() 2109void CalendarView::goNext()
2105{ 2110{
2106 mNavigator->selectNext(); 2111 mNavigator->selectNext();
2107} 2112}
2108 2113
2109void CalendarView::goPrevious() 2114void CalendarView::goPrevious()
2110{ 2115{
2111 mNavigator->selectPrevious(); 2116 mNavigator->selectPrevious();
2112} 2117}
2113void CalendarView::goNextMonth() 2118void CalendarView::goNextMonth()
2114{ 2119{
2115 mNavigator->selectNextMonth(); 2120 mNavigator->selectNextMonth();
2116} 2121}
2117 2122
2118void CalendarView::goPreviousMonth() 2123void CalendarView::goPreviousMonth()
2119{ 2124{
2120 mNavigator->selectPreviousMonth(); 2125 mNavigator->selectPreviousMonth();
2121} 2126}
2122void CalendarView::writeLocale() 2127void CalendarView::writeLocale()
2123{ 2128{
2124 //KPimGlobalPrefs::instance()->setGlobalConfig(); 2129 //KPimGlobalPrefs::instance()->setGlobalConfig();
2125#if 0 2130#if 0
2126 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); 2131 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime );
2127 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); 2132 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday );
2128 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); 2133 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate );
2129 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); 2134 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage );
2130 QString dummy = KOPrefs::instance()->mUserDateFormatLong; 2135 QString dummy = KOPrefs::instance()->mUserDateFormatLong;
2131 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 2136 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
2132 dummy = KOPrefs::instance()->mUserDateFormatShort; 2137 dummy = KOPrefs::instance()->mUserDateFormatShort;
2133 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 2138 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
2134 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, 2139 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving,
2135 KOPrefs::instance()->mDaylightsavingStart, 2140 KOPrefs::instance()->mDaylightsavingStart,
2136 KOPrefs::instance()->mDaylightsavingEnd ); 2141 KOPrefs::instance()->mDaylightsavingEnd );
2137 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); 2142 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId );
2138#endif 2143#endif
2139} 2144}
2140void CalendarView::updateConfig() 2145void CalendarView::updateConfig()
2141{ 2146{
2142 writeLocale(); 2147 writeLocale();
2143 if ( KOPrefs::instance()->mUseAppColors ) 2148 if ( KOPrefs::instance()->mUseAppColors )
2144 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 2149 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
2145 emit configChanged(); 2150 emit configChanged();
2146 mTodoList->updateConfig(); 2151 mTodoList->updateConfig();
2147 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 2152 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
2148 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2153 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2149 // To make the "fill window" configurations work 2154 // To make the "fill window" configurations work
2150 //mViewManager->raiseCurrentView(); 2155 //mViewManager->raiseCurrentView();
2151} 2156}
2152 2157
2153 2158
2154void CalendarView::eventChanged(Event *event) 2159void CalendarView::eventChanged(Event *event)
2155{ 2160{
2156 changeEventDisplay(event,KOGlobals::EVENTEDITED); 2161 changeEventDisplay(event,KOGlobals::EVENTEDITED);
2157 //updateUnmanagedViews(); 2162 //updateUnmanagedViews();
2158} 2163}
2159 2164
2160void CalendarView::eventAdded(Event *event) 2165void CalendarView::eventAdded(Event *event)
2161{ 2166{
2162 changeEventDisplay(event,KOGlobals::EVENTADDED); 2167 changeEventDisplay(event,KOGlobals::EVENTADDED);
2163} 2168}
2164 2169
2165void CalendarView::eventToBeDeleted(Event *) 2170void CalendarView::eventToBeDeleted(Event *)
2166{ 2171{
2167 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 2172 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
2168} 2173}
2169 2174
2170void CalendarView::eventDeleted() 2175void CalendarView::eventDeleted()
2171{ 2176{
2172 changeEventDisplay(0,KOGlobals::EVENTDELETED); 2177 changeEventDisplay(0,KOGlobals::EVENTDELETED);
2173} 2178}
2174void CalendarView::changeTodoDisplay(Todo *which, int action) 2179void CalendarView::changeTodoDisplay(Todo *which, int action)
2175{ 2180{
2176 changeIncidenceDisplay((Incidence *)which, action); 2181 changeIncidenceDisplay((Incidence *)which, action);
2177 mDateNavigator->updateView(); //LR 2182 mDateNavigator->updateView(); //LR
2178 //mDialogManager->updateSearchDialog(); 2183 //mDialogManager->updateSearchDialog();
2179 2184
2180 if (which) { 2185 if (which) {
2181 mViewManager->updateWNview(); 2186 mViewManager->updateWNview();
2182 //mTodoList->updateView(); 2187 //mTodoList->updateView();
2183 } 2188 }
2184 2189
2185} 2190}
2186 2191
2187void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 2192void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
2188{ 2193{
2189 updateUnmanagedViews(); 2194 updateUnmanagedViews();
2190 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 2195 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
2191 if ( action == KOGlobals::EVENTDELETED ) { //delete 2196 if ( action == KOGlobals::EVENTDELETED ) { //delete
2192 mCalendar->checkAlarmForIncidence( 0, true ); 2197 mCalendar->checkAlarmForIncidence( 0, true );
2193 if ( mEventViewerDialog ) 2198 if ( mEventViewerDialog )
2194 mEventViewerDialog->hide(); 2199 mEventViewerDialog->hide();
2195 } 2200 }
2196 else 2201 else
2197 mCalendar->checkAlarmForIncidence( which , false ); 2202 mCalendar->checkAlarmForIncidence( which , false );
2198} 2203}
2199 2204
2200// most of the changeEventDisplays() right now just call the view's 2205// most of the changeEventDisplays() right now just call the view's
2201// total update mode, but they SHOULD be recoded to be more refresh-efficient. 2206// total update mode, but they SHOULD be recoded to be more refresh-efficient.
2202void CalendarView::changeEventDisplay(Event *which, int action) 2207void CalendarView::changeEventDisplay(Event *which, int action)
2203{ 2208{
2204 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 2209 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
2205 changeIncidenceDisplay((Incidence *)which, action); 2210 changeIncidenceDisplay((Incidence *)which, action);
2206 mDateNavigator->updateView(); 2211 mDateNavigator->updateView();
2207 //mDialogManager->updateSearchDialog(); 2212 //mDialogManager->updateSearchDialog();
2208 2213
2209 if (which) { 2214 if (which) {
2210 // If there is an event view visible update the display 2215 // If there is an event view visible update the display
2211 mViewManager->currentView()->changeEventDisplay(which,action); 2216 mViewManager->currentView()->changeEventDisplay(which,action);
2212 // TODO: check, if update needed 2217 // TODO: check, if update needed
2213 // if (which->getTodoStatus()) { 2218 // if (which->getTodoStatus()) {
2214 mTodoList->updateView(); 2219 mTodoList->updateView();
2215 // } 2220 // }
2216 } else { 2221 } else {
2217 mViewManager->currentView()->updateView(); 2222 mViewManager->currentView()->updateView();
2218 } 2223 }
2219} 2224}
2220 2225
2221 2226
2222void CalendarView::updateTodoViews() 2227void CalendarView::updateTodoViews()
2223{ 2228{
2224 mTodoList->updateView(); 2229 mTodoList->updateView();
2225 mViewManager->currentView()->updateView(); 2230 mViewManager->currentView()->updateView();
2226 2231
2227} 2232}
2228 2233
2229 2234
2230void CalendarView::updateView(const QDate &start, const QDate &end) 2235void CalendarView::updateView(const QDate &start, const QDate &end)
2231{ 2236{
2232 mTodoList->updateView(); 2237 mTodoList->updateView();
2233 mViewManager->updateView(start, end); 2238 mViewManager->updateView(start, end);
2234 //mDateNavigator->updateView(); 2239 //mDateNavigator->updateView();
2235} 2240}
2236 2241
2237void CalendarView::updateView() 2242void CalendarView::updateView()
2238{ 2243{
2239 DateList tmpList = mNavigator->selectedDates(); 2244 DateList tmpList = mNavigator->selectedDates();
2240 2245
2241 if ( KOPrefs::instance()->mHideNonStartedTodos ) 2246 if ( KOPrefs::instance()->mHideNonStartedTodos )
2242 mTodoList->updateView(); 2247 mTodoList->updateView();
2243 // We assume that the navigator only selects consecutive days. 2248 // We assume that the navigator only selects consecutive days.
2244 updateView( tmpList.first(), tmpList.last() ); 2249 updateView( tmpList.first(), tmpList.last() );
2245} 2250}
2246 2251
2247void CalendarView::updateUnmanagedViews() 2252void CalendarView::updateUnmanagedViews()
2248{ 2253{
2249 mDateNavigator->updateDayMatrix(); 2254 mDateNavigator->updateDayMatrix();
2250} 2255}
2251 2256
2252int CalendarView::msgItemDelete(const QString name) 2257int CalendarView::msgItemDelete(const QString name)
2253{ 2258{
2254 return KMessageBox::warningContinueCancel(this,name +"\n\n"+ 2259 return KMessageBox::warningContinueCancel(this,name +"\n\n"+
2255 i18n("This item will be\npermanently deleted."), 2260 i18n("This item will be\npermanently deleted."),
2256 i18n("KO/Pi Confirmation"),i18n("Delete")); 2261 i18n("KO/Pi Confirmation"),i18n("Delete"));
2257} 2262}
2258 2263
2259 2264
2260void CalendarView::edit_cut() 2265void CalendarView::edit_cut()
2261{ 2266{
2262 Event *anEvent=0; 2267 Event *anEvent=0;
2263 2268
2264 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2269 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2265 2270
2266 if (mViewManager->currentView()->isEventView()) { 2271 if (mViewManager->currentView()->isEventView()) {
2267 if ( incidence && incidence->type() == "Event" ) { 2272 if ( incidence && incidence->type() == "Event" ) {
2268 anEvent = static_cast<Event *>(incidence); 2273 anEvent = static_cast<Event *>(incidence);
2269 } 2274 }
2270 } 2275 }
2271 2276
2272 if (!anEvent) { 2277 if (!anEvent) {
2273 KNotifyClient::beep(); 2278 KNotifyClient::beep();
2274 return; 2279 return;
2275 } 2280 }
2276 DndFactory factory( mCalendar ); 2281 DndFactory factory( mCalendar );
2277 factory.cutIncidence(anEvent); 2282 factory.cutIncidence(anEvent);
2278 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2283 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2279} 2284}
2280 2285
2281void CalendarView::edit_copy() 2286void CalendarView::edit_copy()
2282{ 2287{
2283 Event *anEvent=0; 2288 Event *anEvent=0;
2284 2289
2285 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2290 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2286 2291
2287 if (mViewManager->currentView()->isEventView()) { 2292 if (mViewManager->currentView()->isEventView()) {
2288 if ( incidence && incidence->type() == "Event" ) { 2293 if ( incidence && incidence->type() == "Event" ) {
2289 anEvent = static_cast<Event *>(incidence); 2294 anEvent = static_cast<Event *>(incidence);
2290 } 2295 }
2291 } 2296 }
2292 2297
2293 if (!anEvent) { 2298 if (!anEvent) {
2294 KNotifyClient::beep(); 2299 KNotifyClient::beep();
2295 return; 2300 return;
2296 } 2301 }
2297 DndFactory factory( mCalendar ); 2302 DndFactory factory( mCalendar );
2298 factory.copyIncidence(anEvent); 2303 factory.copyIncidence(anEvent);
2299} 2304}
2300 2305
2301void CalendarView::edit_paste() 2306void CalendarView::edit_paste()
2302{ 2307{
2303 QDate date = mNavigator->selectedDates().first(); 2308 QDate date = mNavigator->selectedDates().first();
2304 2309
2305 DndFactory factory( mCalendar ); 2310 DndFactory factory( mCalendar );
2306 Event *pastedEvent = (Event *)factory.pasteIncidence( date ); 2311 Event *pastedEvent = (Event *)factory.pasteIncidence( date );
2307 2312
2308 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 2313 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
2309} 2314}
2310 2315
2311void CalendarView::edit_options() 2316void CalendarView::edit_options()
2312{ 2317{
2313 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; 2318 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId;
2314 emit save(); 2319 emit save();
2315 emit saveStopTimer(); 2320 emit saveStopTimer();
2316 mDialogManager->showOptionsDialog(); 2321 mDialogManager->showOptionsDialog();
2317 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { 2322 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) {
2318 emit saveStopTimer(); 2323 emit saveStopTimer();
2319 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!"), 2324 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!"),
2320 i18n("Timezone settings"),i18n("Reload"))) { 2325 i18n("Timezone settings"),i18n("Reload"))) {
2321 qDebug("KO: TZ reload cancelled "); 2326 qDebug("KO: TZ reload cancelled ");
2322 return; 2327 return;
2323 } 2328 }
2324 qDebug("KO: Timezone change "); 2329 qDebug("KO: Timezone change ");
2325 openCalendar( MainWindow::defaultFileName() ); 2330 openCalendar( MainWindow::defaultFileName() );
2326 setModified(true); 2331 setModified(true);
2327 } 2332 }
2328 else 2333 else
2329 qDebug("KO: No tz change "); 2334 qDebug("KO: No tz change ");
2330 2335
2331} 2336}
2332 2337
2333 2338
2334void CalendarView::slotSelectPickerDate( QDate d) 2339void CalendarView::slotSelectPickerDate( QDate d)
2335{ 2340{
2336 mDateFrame->hide(); 2341 mDateFrame->hide();
2337 if ( mDatePickerMode == 1 ) { 2342 if ( mDatePickerMode == 1 ) {
2338 mNavigator->slotDaySelect( d ); 2343 mNavigator->slotDaySelect( d );
2339 } else if ( mDatePickerMode == 2 ) { 2344 } else if ( mDatePickerMode == 2 ) {
2340 if ( mMoveIncidence->type() == "Todo" ) { 2345 if ( mMoveIncidence->type() == "Todo" ) {
2341 Todo * to = (Todo *) mMoveIncidence; 2346 Todo * to = (Todo *) mMoveIncidence;
2342 QTime tim; 2347 QTime tim;
2343 int len = 0; 2348 int len = 0;
2344 if ( to->hasStartDate() && to->hasDueDate() ) 2349 if ( to->hasStartDate() && to->hasDueDate() )
2345 len = to->dtStart().secsTo( to->dtDue()); 2350 len = to->dtStart().secsTo( to->dtDue());
2346 if ( to->hasDueDate() ) 2351 if ( to->hasDueDate() )
2347 tim = to->dtDue().time(); 2352 tim = to->dtDue().time();
2348 else { 2353 else {
2349 tim = QTime ( 0,0,0 ); 2354 tim = QTime ( 0,0,0 );
2350 to->setFloats( true ); 2355 to->setFloats( true );
2351 to->setHasDueDate( true ); 2356 to->setHasDueDate( true );
2352 } 2357 }
2353 QDateTime dt ( d,tim ); 2358 QDateTime dt ( d,tim );
2354 to->setDtDue( dt ); 2359 to->setDtDue( dt );
2355 2360
2356 if ( to->hasStartDate() ) { 2361 if ( to->hasStartDate() ) {
2357 if ( len>0 ) 2362 if ( len>0 )
2358 to->setDtStart(to->dtDue().addSecs( -len )); 2363 to->setDtStart(to->dtDue().addSecs( -len ));
2359 else 2364 else
2360 if (to->dtStart() > to->dtDue() ) 2365 if (to->dtStart() > to->dtDue() )
2361 to->setDtStart(to->dtDue().addDays( -3 )); 2366 to->setDtStart(to->dtDue().addDays( -3 ));
2362 } 2367 }
2363 2368
2364 todoChanged( to ); 2369 todoChanged( to );
2365 } else { 2370 } else {
2366 if ( mMoveIncidence->doesRecur() ) { 2371 if ( mMoveIncidence->doesRecur() ) {
2367#if 0 2372#if 0
2368 // PENDING implement this 2373 // PENDING implement this
2369 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); 2374 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate );
2370 mCalendar()->addIncidence( newInc ); 2375 mCalendar()->addIncidence( newInc );
2371 if ( mMoveIncidence->type() == "Todo" ) 2376 if ( mMoveIncidence->type() == "Todo" )
2372 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); 2377 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED );
2373 else 2378 else
2374 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); 2379 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED);
2375 mMoveIncidence = newInc; 2380 mMoveIncidence = newInc;
2376 2381
2377#endif 2382#endif
2378 } 2383 }
2379 QTime tim = mMoveIncidence->dtStart().time(); 2384 QTime tim = mMoveIncidence->dtStart().time();
2380 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2385 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2381 QDateTime dt ( d,tim ); 2386 QDateTime dt ( d,tim );
2382 mMoveIncidence->setDtStart( dt ); 2387 mMoveIncidence->setDtStart( dt );
2383 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2388 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2384 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2389 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2385 } 2390 }
2386 2391
2387 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2392 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2388 } 2393 }
2389} 2394}
2390 2395
2391void CalendarView::removeCategories() 2396void CalendarView::removeCategories()
2392{ 2397{
2393 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2398 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2394 QStringList catList = KOPrefs::instance()->mCustomCategories; 2399 QStringList catList = KOPrefs::instance()->mCustomCategories;
2395 QStringList catIncList; 2400 QStringList catIncList;
2396 QStringList newCatList; 2401 QStringList newCatList;
2397 Incidence* inc = incList.first(); 2402 Incidence* inc = incList.first();
2398 int i; 2403 int i;
2399 int count = 0; 2404 int count = 0;
2400 while ( inc ) { 2405 while ( inc ) {
2401 newCatList.clear(); 2406 newCatList.clear();
2402 catIncList = inc->categories() ; 2407 catIncList = inc->categories() ;
2403 for( i = 0; i< catIncList.count(); ++i ) { 2408 for( i = 0; i< catIncList.count(); ++i ) {
2404 if ( catList.contains (catIncList[i])) 2409 if ( catList.contains (catIncList[i]))
2405 newCatList.append( catIncList[i] ); 2410 newCatList.append( catIncList[i] );
2406 } 2411 }
2407 newCatList.sort(); 2412 newCatList.sort();
2408 inc->setCategories( newCatList.join(",") ); 2413 inc->setCategories( newCatList.join(",") );
2409 inc = incList.next(); 2414 inc = incList.next();
2410 } 2415 }
2411} 2416}
2412 2417
2413int CalendarView::addCategories() 2418int CalendarView::addCategories()
2414{ 2419{
2415 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2420 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2416 QStringList catList = KOPrefs::instance()->mCustomCategories; 2421 QStringList catList = KOPrefs::instance()->mCustomCategories;
2417 QStringList catIncList; 2422 QStringList catIncList;
2418 Incidence* inc = incList.first(); 2423 Incidence* inc = incList.first();
2419 int i; 2424 int i;
2420 int count = 0; 2425 int count = 0;
2421 while ( inc ) { 2426 while ( inc ) {
2422 catIncList = inc->categories() ; 2427 catIncList = inc->categories() ;
2423 for( i = 0; i< catIncList.count(); ++i ) { 2428 for( i = 0; i< catIncList.count(); ++i ) {
2424 if ( !catList.contains (catIncList[i])) { 2429 if ( !catList.contains (catIncList[i])) {
2425 catList.append( catIncList[i] ); 2430 catList.append( catIncList[i] );
2426 //qDebug("add cat %s ", catIncList[i].latin1()); 2431 //qDebug("add cat %s ", catIncList[i].latin1());
2427 ++count; 2432 ++count;
2428 } 2433 }
2429 } 2434 }
2430 inc = incList.next(); 2435 inc = incList.next();
2431 } 2436 }
2432 catList.sort(); 2437 catList.sort();
2433 KOPrefs::instance()->mCustomCategories = catList; 2438 KOPrefs::instance()->mCustomCategories = catList;
2434 return count; 2439 return count;
2435} 2440}
2436 2441
2437void CalendarView::manageCategories() 2442void CalendarView::manageCategories()
2438{ 2443{
2439 KOCatPrefs* cp = new KOCatPrefs(); 2444 KOCatPrefs* cp = new KOCatPrefs();
2440 cp->show(); 2445 cp->show();
2441 int w =cp->sizeHint().width() ; 2446 int w =cp->sizeHint().width() ;
2442 int h = cp->sizeHint().height() ; 2447 int h = cp->sizeHint().height() ;
2443 int dw = QApplication::desktop()->width(); 2448 int dw = QApplication::desktop()->width();
2444 int dh = QApplication::desktop()->height(); 2449 int dh = QApplication::desktop()->height();
2445 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2450 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2446 if ( !cp->exec() ) { 2451 if ( !cp->exec() ) {
2447 delete cp; 2452 delete cp;
2448 return; 2453 return;
2449 } 2454 }
2450 int count = 0; 2455 int count = 0;
2451 if ( cp->addCat() ) { 2456 if ( cp->addCat() ) {
2452 count = addCategories(); 2457 count = addCategories();
2453 if ( count ) { 2458 if ( count ) {
2454 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2459 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2455 writeSettings(); 2460 writeSettings();
2456 } else 2461 } else
2457 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); 2462 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! "));
2458 } else { 2463 } else {
2459 removeCategories(); 2464 removeCategories();
2460 updateView(); 2465 updateView();
2461 } 2466 }
2462 delete cp; 2467 delete cp;
2463} 2468}
2464 2469
2465void CalendarView::beamIncidence(Incidence * Inc) 2470void CalendarView::beamIncidence(Incidence * Inc)
2466{ 2471{
2467 QPtrList<Incidence> delSel ; 2472 QPtrList<Incidence> delSel ;
2468 delSel.append(Inc); 2473 delSel.append(Inc);
2469 beamIncidenceList( delSel ); 2474 beamIncidenceList( delSel );
2470} 2475}
2471void CalendarView::beamCalendar() 2476void CalendarView::beamCalendar()
2472{ 2477{
2473 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2478 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2474 //qDebug("beamCalendar() "); 2479 //qDebug("beamCalendar() ");
2475 beamIncidenceList( delSel ); 2480 beamIncidenceList( delSel );
2476} 2481}
2477void CalendarView::beamFilteredCalendar() 2482void CalendarView::beamFilteredCalendar()
2478{ 2483{
2479 QPtrList<Incidence> delSel = mCalendar->incidences(); 2484 QPtrList<Incidence> delSel = mCalendar->incidences();
2480 //qDebug("beamFilteredCalendar() "); 2485 //qDebug("beamFilteredCalendar() ");
2481 beamIncidenceList( delSel ); 2486 beamIncidenceList( delSel );
2482} 2487}
2483void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2488void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2484{ 2489{
2485 if ( beamDialog->exec () == QDialog::Rejected ) 2490 if ( beamDialog->exec () == QDialog::Rejected )
2486 return; 2491 return;
2487#ifdef DESKTOP_VERSION 2492#ifdef DESKTOP_VERSION
2488 QString fn = locateLocal( "tmp", "kopibeamfile" ); 2493 QString fn = locateLocal( "tmp", "kopibeamfile" );
2489#else 2494#else
2490 QString fn = "/tmp/kopibeamfile"; 2495 QString fn = "/tmp/kopibeamfile";
2491#endif 2496#endif
2492 QString mes; 2497 QString mes;
2493 bool createbup = true; 2498 bool createbup = true;
2494 if ( createbup ) { 2499 if ( createbup ) {
2495 QString description = "\n"; 2500 QString description = "\n";
2496 CalendarLocal* cal = new CalendarLocal(); 2501 CalendarLocal* cal = new CalendarLocal();
2497 if ( beamDialog->beamLocal() ) 2502 if ( beamDialog->beamLocal() )
2498 cal->setLocalTime(); 2503 cal->setLocalTime();
2499 else 2504 else
2500 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2505 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2501 Incidence *incidence = delSel.first(); 2506 Incidence *incidence = delSel.first();
2502 bool addText = false; 2507 bool addText = false;
2503 if ( delSel.count() < 10 ) 2508 if ( delSel.count() < 10 )
2504 addText = true; 2509 addText = true;
2505 else { 2510 else {
2506 description.sprintf(i18n(" %d items?"),delSel.count() ); 2511 description.sprintf(i18n(" %d items?"),delSel.count() );
2507 } 2512 }
2508 while ( incidence ) { 2513 while ( incidence ) {
2509 Incidence *in = incidence->clone(); 2514 Incidence *in = incidence->clone();
2510 if ( ! in->summary().isEmpty() ) { 2515 if ( ! in->summary().isEmpty() ) {
2511 in->setDescription(""); 2516 in->setDescription("");
2512 } else { 2517 } else {
2513 in->setSummary( in->description().left(20)); 2518 in->setSummary( in->description().left(20));
2514 in->setDescription(""); 2519 in->setDescription("");
2515 } 2520 }
2516 if ( addText ) 2521 if ( addText )
2517 description += in->summary() + "\n"; 2522 description += in->summary() + "\n";
2518 cal->addIncidence( in ); 2523 cal->addIncidence( in );
2519 incidence = delSel.next(); 2524 incidence = delSel.next();
2520 } 2525 }
2521 if ( beamDialog->beamVcal() ) { 2526 if ( beamDialog->beamVcal() ) {
2522 fn += ".vcs"; 2527 fn += ".vcs";
2523 FileStorage storage( cal, fn, new VCalFormat ); 2528 FileStorage storage( cal, fn, new VCalFormat );
2524 storage.save(); 2529 storage.save();
2525 } else { 2530 } else {
2526 fn += ".ics"; 2531 fn += ".ics";
2527 FileStorage storage( cal, fn, new ICalFormat( ) ); 2532 FileStorage storage( cal, fn, new ICalFormat( ) );
2528 storage.save(); 2533 storage.save();
2529 } 2534 }
2530 delete cal; 2535 delete cal;
2531 mes = i18n("KO/Pi: Ready for beaming"); 2536 mes = i18n("KO/Pi: Ready for beaming");
2532 topLevelWidget()->setCaption(mes); 2537 topLevelWidget()->setCaption(mes);
2533 KApplication::convert2latin1( fn ); 2538 KApplication::convert2latin1( fn );
2534#ifndef DESKTOP_VERSION 2539#ifndef DESKTOP_VERSION
2535 Ir *ir = new Ir( this ); 2540 Ir *ir = new Ir( this );
2536 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 2541 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2537 ir->send( fn, description, "text/x-vCalendar" ); 2542 ir->send( fn, description, "text/x-vCalendar" );
2538#endif 2543#endif
2539 } 2544 }
2540} 2545}
2541void CalendarView::beamDone( Ir *ir ) 2546void CalendarView::beamDone( Ir *ir )
2542{ 2547{
2543#ifndef DESKTOP_VERSION 2548#ifndef DESKTOP_VERSION
2544 delete ir; 2549 delete ir;
2545#endif 2550#endif
2546 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); 2551 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") );
2547 topLevelWidget()->raise(); 2552 topLevelWidget()->raise();
2548} 2553}
2549 2554
2550void CalendarView::moveIncidence(Incidence * inc ) 2555void CalendarView::moveIncidence(Incidence * inc )
2551{ 2556{
2552 if ( !inc ) return; 2557 if ( !inc ) return;
2553 showDatePickerPopup(); 2558 showDatePickerPopup();
2554 mDatePickerMode = 2; 2559 mDatePickerMode = 2;
2555 mMoveIncidence = inc ; 2560 mMoveIncidence = inc ;
2556 QDate da; 2561 QDate da;
2557 if ( mMoveIncidence->type() == "Todo" ) { 2562 if ( mMoveIncidence->type() == "Todo" ) {
2558 Todo * to = (Todo *) mMoveIncidence; 2563 Todo * to = (Todo *) mMoveIncidence;
2559 if ( to->hasDueDate() ) 2564 if ( to->hasDueDate() )
2560 da = to->dtDue().date(); 2565 da = to->dtDue().date();
2561 else 2566 else
2562 da = QDate::currentDate(); 2567 da = QDate::currentDate();
2563 } else { 2568 } else {
2564 da = mMoveIncidence->dtStart().date(); 2569 da = mMoveIncidence->dtStart().date();
2565 } 2570 }
2566 //PENDING set date for recurring incidence to date of recurrence 2571 //PENDING set date for recurring incidence to date of recurrence
2567 //mMoveIncidenceOldDate; 2572 //mMoveIncidenceOldDate;
2568 mDatePicker->setDate( da ); 2573 mDatePicker->setDate( da );
2569} 2574}
2570void CalendarView::showDatePickerPopup() 2575void CalendarView::showDatePickerPopup()
2571{ 2576{
2572 if ( mDateFrame->isVisible() ) 2577 if ( mDateFrame->isVisible() )
2573 mDateFrame->hide(); 2578 mDateFrame->hide();
2574 else { 2579 else {
2575 int offX = 0, offY = 0; 2580 int offX = 0, offY = 0;
2576#ifdef DESKTOP_VERSION 2581#ifdef DESKTOP_VERSION
2577 int w =mDatePicker->sizeHint().width() ; 2582 int w =mDatePicker->sizeHint().width() ;
2578 int h = mDatePicker->sizeHint().height() ; 2583 int h = mDatePicker->sizeHint().height() ;
2579 int dw = topLevelWidget()->width(); 2584 int dw = topLevelWidget()->width();
2580 int dh = topLevelWidget()->height(); 2585 int dh = topLevelWidget()->height();
2581 offX = topLevelWidget()->x(); 2586 offX = topLevelWidget()->x();
2582 offY = topLevelWidget()->y(); 2587 offY = topLevelWidget()->y();
2583#else 2588#else
2584 int w =mDatePicker->sizeHint().width() ; 2589 int w =mDatePicker->sizeHint().width() ;
2585 int h = mDatePicker->sizeHint().height() ; 2590 int h = mDatePicker->sizeHint().height() ;
2586 int dw = QApplication::desktop()->width(); 2591 int dw = QApplication::desktop()->width();
2587 int dh = QApplication::desktop()->height(); 2592 int dh = QApplication::desktop()->height();
2588#endif 2593#endif
2589 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); 2594 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h );
2590 mDateFrame->show(); 2595 mDateFrame->show();
2591 } 2596 }
2592} 2597}
2593void CalendarView::showDatePicker( ) 2598void CalendarView::showDatePicker( )
2594{ 2599{
2595 showDatePickerPopup(); 2600 showDatePickerPopup();
2596 mDatePickerMode = 1; 2601 mDatePickerMode = 1;
2597 mDatePicker->setDate( mNavigator->selectedDates().first() ); 2602 mDatePicker->setDate( mNavigator->selectedDates().first() );
2598} 2603}
2599 2604
2600void CalendarView::showEventEditor() 2605void CalendarView::showEventEditor()
2601{ 2606{
2602#ifdef DESKTOP_VERSION 2607#ifdef DESKTOP_VERSION
2603 int x,y,w,h; 2608 int x,y,w,h;
2604 x = mEventEditor->geometry().x(); 2609 x = mEventEditor->geometry().x();
2605 y = mEventEditor->geometry().y(); 2610 y = mEventEditor->geometry().y();
2606 w = mEventEditor->width(); 2611 w = mEventEditor->width();
2607 h = mEventEditor->height(); 2612 h = mEventEditor->height();
2608 mEventEditor->show(); 2613 mEventEditor->show();
2609 mEventEditor->setGeometry(x,y,w,h); 2614 mEventEditor->setGeometry(x,y,w,h);
2610#else 2615#else
2611 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { 2616 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) {
2612 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2617 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2613 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); 2618 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() );
2614 qApp->processEvents(); 2619 qApp->processEvents();
2615 delete mEventEditor; 2620 delete mEventEditor;
2616 mEventEditor = mDialogManager->getEventEditor(); 2621 mEventEditor = mDialogManager->getEventEditor();
2617 topLevelWidget()->setCaption( i18n("") ); 2622 topLevelWidget()->setCaption( i18n("") );
2618 } 2623 }
2619 mEventEditor->showMaximized(); 2624 mEventEditor->showMaximized();
2620#endif 2625#endif
2621} 2626}
2622void CalendarView::showTodoEditor() 2627void CalendarView::showTodoEditor()
2623{ 2628{
2624#ifdef DESKTOP_VERSION 2629#ifdef DESKTOP_VERSION
2625 int x,y,w,h; 2630 int x,y,w,h;
2626 x = mTodoEditor->geometry().x(); 2631 x = mTodoEditor->geometry().x();
2627 y = mTodoEditor->geometry().y(); 2632 y = mTodoEditor->geometry().y();
2628 w = mTodoEditor->width(); 2633 w = mTodoEditor->width();
2629 h = mTodoEditor->height(); 2634 h = mTodoEditor->height();
2630 mTodoEditor->show(); 2635 mTodoEditor->show();
2631 mTodoEditor->setGeometry(x,y,w,h); 2636 mTodoEditor->setGeometry(x,y,w,h);
2632#else 2637#else
2633 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { 2638 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) {
2634 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2639 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2635 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); 2640 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() );
2636 qApp->processEvents(); 2641 qApp->processEvents();
2637 delete mTodoEditor; 2642 delete mTodoEditor;
2638 mTodoEditor = mDialogManager->getTodoEditor(); 2643 mTodoEditor = mDialogManager->getTodoEditor();
2639 topLevelWidget()->setCaption( i18n("") ); 2644 topLevelWidget()->setCaption( i18n("") );
2640 } 2645 }
2641 mTodoEditor->showMaximized(); 2646 mTodoEditor->showMaximized();
2642#endif 2647#endif
2643} 2648}
2644 2649
2645void CalendarView::cloneIncidence() 2650void CalendarView::cloneIncidence()
2646{ 2651{
2647 Incidence *incidence = currentSelection(); 2652 Incidence *incidence = currentSelection();
2648 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2653 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2649 if ( incidence ) { 2654 if ( incidence ) {
2650 cloneIncidence(incidence); 2655 cloneIncidence(incidence);
2651 } 2656 }
2652} 2657}
2653void CalendarView::moveIncidence() 2658void CalendarView::moveIncidence()
2654{ 2659{
2655 Incidence *incidence = currentSelection(); 2660 Incidence *incidence = currentSelection();
2656 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2661 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2657 if ( incidence ) { 2662 if ( incidence ) {
2658 moveIncidence(incidence); 2663 moveIncidence(incidence);
2659 } 2664 }
2660} 2665}
2661void CalendarView::beamIncidence() 2666void CalendarView::beamIncidence()
2662{ 2667{
2663 Incidence *incidence = currentSelection(); 2668 Incidence *incidence = currentSelection();
2664 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2669 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2665 if ( incidence ) { 2670 if ( incidence ) {
2666 beamIncidence(incidence); 2671 beamIncidence(incidence);
2667 } 2672 }
2668} 2673}
2669void CalendarView::toggleCancelIncidence() 2674void CalendarView::toggleCancelIncidence()
2670{ 2675{
2671 Incidence *incidence = currentSelection(); 2676 Incidence *incidence = currentSelection();
2672 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2677 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2673 if ( incidence ) { 2678 if ( incidence ) {
2674 cancelIncidence(incidence); 2679 cancelIncidence(incidence);
2675 } 2680 }
2676} 2681}
2677 2682
2678 2683
2679void CalendarView::cancelIncidence(Incidence * inc ) 2684void CalendarView::cancelIncidence(Incidence * inc )
2680{ 2685{
2681 inc->setCancelled( ! inc->cancelled() ); 2686 inc->setCancelled( ! inc->cancelled() );
2682 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 2687 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
2683 updateView(); 2688 updateView();
2684} 2689}
2685void CalendarView::cloneIncidence(Incidence * orgInc ) 2690void CalendarView::cloneIncidence(Incidence * orgInc )
2686{ 2691{
2687 Incidence * newInc = orgInc->clone(); 2692 Incidence * newInc = orgInc->clone();
2688 newInc->recreate(); 2693 newInc->recreate();
2689 2694
2690 if ( newInc->type() == "Todo" ) { 2695 if ( newInc->type() == "Todo" ) {
2691 Todo* t = (Todo*) newInc; 2696 Todo* t = (Todo*) newInc;
2692 showTodoEditor(); 2697 showTodoEditor();
2693 mTodoEditor->editTodo( t ); 2698 mTodoEditor->editTodo( t );
2694 if ( mTodoEditor->exec() ) { 2699 if ( mTodoEditor->exec() ) {
2695 mCalendar->addTodo( t ); 2700 mCalendar->addTodo( t );
2696 updateView(); 2701 updateView();
2697 } else { 2702 } else {
2698 delete t; 2703 delete t;
2699 } 2704 }
2700 } 2705 }
2701 else { 2706 else {
2702 Event* e = (Event*) newInc; 2707 Event* e = (Event*) newInc;
2703 showEventEditor(); 2708 showEventEditor();
2704 mEventEditor->editEvent( e ); 2709 mEventEditor->editEvent( e );
2705 if ( mEventEditor->exec() ) { 2710 if ( mEventEditor->exec() ) {
2706 mCalendar->addEvent( e ); 2711 mCalendar->addEvent( e );
2707 updateView(); 2712 updateView();
2708 } else { 2713 } else {
2709 delete e; 2714 delete e;
2710 } 2715 }
2711 } 2716 }
2712 setActiveWindow(); 2717 setActiveWindow();
2713} 2718}
2714 2719
2715void CalendarView::newEvent() 2720void CalendarView::newEvent()
2716{ 2721{
2717 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 2722 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
2718 KOAgendaView *aView = mViewManager->agendaView(); 2723 KOAgendaView *aView = mViewManager->agendaView();
2719 if (aView) { 2724 if (aView) {
2720 if (aView->selectionStart().isValid()) { 2725 if (aView->selectionStart().isValid()) {
2721 if (aView->selectedIsAllDay()) { 2726 if (aView->selectedIsAllDay()) {
2722 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 2727 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
2723 } else { 2728 } else {
2724 newEvent(aView->selectionStart(),aView->selectionEnd()); 2729 newEvent(aView->selectionStart(),aView->selectionEnd());
2725 } 2730 }
2726 return; 2731 return;
2727 } 2732 }
2728 } 2733 }
2729 2734
2730 QDate date = mNavigator->selectedDates().first(); 2735 QDate date = mNavigator->selectedDates().first();
2731 QDateTime current = QDateTime::currentDateTime(); 2736 QDateTime current = QDateTime::currentDateTime();
2732 if ( date <= current.date() ) { 2737 if ( date <= current.date() ) {
2733 int hour = current.time().hour() +1; 2738 int hour = current.time().hour() +1;
2734 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 2739 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
2735 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2740 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2736 } else 2741 } else
2737 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 2742 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
2738 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 2743 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
2739 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2744 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2740} 2745}
2741 2746
2742void CalendarView::newEvent(QDateTime fh) 2747void CalendarView::newEvent(QDateTime fh)
2743{ 2748{
2744 newEvent(fh, 2749 newEvent(fh,
2745 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 2750 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
2746} 2751}
2747 2752
2748void CalendarView::newEvent(QDate dt) 2753void CalendarView::newEvent(QDate dt)
2749{ 2754{
2750 newEvent(QDateTime(dt, QTime(0,0,0)), 2755 newEvent(QDateTime(dt, QTime(0,0,0)),
2751 QDateTime(dt, QTime(0,0,0)), true); 2756 QDateTime(dt, QTime(0,0,0)), true);
2752} 2757}
2753void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) 2758void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint)
2754{ 2759{
2755 newEvent(fromHint, toHint, false); 2760 newEvent(fromHint, toHint, false);
2756} 2761}
2757void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 2762void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
2758{ 2763{
2759 2764
2760 showEventEditor(); 2765 showEventEditor();
2761 mEventEditor->newEvent(fromHint,toHint,allDay); 2766 mEventEditor->newEvent(fromHint,toHint,allDay);
2762 if ( mFilterView->filtersEnabled() ) { 2767 if ( mFilterView->filtersEnabled() ) {
2763 CalFilter *filter = mFilterView->selectedFilter(); 2768 CalFilter *filter = mFilterView->selectedFilter();
2764 if (filter && filter->showCategories()) { 2769 if (filter && filter->showCategories()) {
2765 mEventEditor->setCategories(filter->categoryList().join(",") ); 2770 mEventEditor->setCategories(filter->categoryList().join(",") );
2766 } 2771 }
2767 if ( filter ) 2772 if ( filter )
2768 mEventEditor->setSecrecy( filter->getSecrecy() ); 2773 mEventEditor->setSecrecy( filter->getSecrecy() );
2769 } 2774 }
2770 mEventEditor->exec(); 2775 mEventEditor->exec();
2771 setActiveWindow(); 2776 setActiveWindow();
2772} 2777}
2773void CalendarView::todoAdded(Todo * t) 2778void CalendarView::todoAdded(Todo * t)
2774{ 2779{
2775 2780
2776 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 2781 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
2777 updateTodoViews(); 2782 updateTodoViews();
2778} 2783}
2779void CalendarView::todoChanged(Todo * t) 2784void CalendarView::todoChanged(Todo * t)
2780{ 2785{
2781 emit todoModified( t, 4 ); 2786 emit todoModified( t, 4 );
2782 // updateTodoViews(); 2787 // updateTodoViews();
2783} 2788}
2784void CalendarView::todoToBeDeleted(Todo *) 2789void CalendarView::todoToBeDeleted(Todo *)
2785{ 2790{
2786 //qDebug("todoToBeDeleted(Todo *) "); 2791 //qDebug("todoToBeDeleted(Todo *) ");
2787 updateTodoViews(); 2792 updateTodoViews();
2788} 2793}
2789void CalendarView::todoDeleted() 2794void CalendarView::todoDeleted()
2790{ 2795{
2791 //qDebug(" todoDeleted()"); 2796 //qDebug(" todoDeleted()");
2792 updateTodoViews(); 2797 updateTodoViews();
2793} 2798}
2794 2799
2795 2800
2796void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) 2801void CalendarView::newTodoDateTime( QDateTime dt, bool allday )
2797{ 2802{
2798 showTodoEditor(); 2803 showTodoEditor();
2799 mTodoEditor->newTodo(dt,0,allday); 2804 mTodoEditor->newTodo(dt,0,allday);
2800 if ( mFilterView->filtersEnabled() ) { 2805 if ( mFilterView->filtersEnabled() ) {
2801 CalFilter *filter = mFilterView->selectedFilter(); 2806 CalFilter *filter = mFilterView->selectedFilter();
2802 if (filter && filter->showCategories()) { 2807 if (filter && filter->showCategories()) {
2803 mTodoEditor->setCategories(filter->categoryList().join(",") ); 2808 mTodoEditor->setCategories(filter->categoryList().join(",") );
2804 } 2809 }
2805 if ( filter ) 2810 if ( filter )
2806 mTodoEditor->setSecrecy( filter->getSecrecy() ); 2811 mTodoEditor->setSecrecy( filter->getSecrecy() );
2807 } 2812 }
2808 mTodoEditor->exec(); 2813 mTodoEditor->exec();
2809 setActiveWindow(); 2814 setActiveWindow();
2810} 2815}
2811 2816
2812void CalendarView::newTodo() 2817void CalendarView::newTodo()
2813{ 2818{
2814 newTodoDateTime( QDateTime(),true ); 2819 newTodoDateTime( QDateTime(),true );
2815} 2820}
2816 2821
2817void CalendarView::newSubTodo() 2822void CalendarView::newSubTodo()
2818{ 2823{
2819 Todo *todo = selectedTodo(); 2824 Todo *todo = selectedTodo();
2820 if ( todo ) newSubTodo( todo ); 2825 if ( todo ) newSubTodo( todo );
2821} 2826}
2822 2827
2823void CalendarView::newSubTodo(Todo *parentEvent) 2828void CalendarView::newSubTodo(Todo *parentEvent)
2824{ 2829{
2825 2830
2826 showTodoEditor(); 2831 showTodoEditor();
2827 mTodoEditor->newTodo(QDateTime(),parentEvent,true); 2832 mTodoEditor->newTodo(QDateTime(),parentEvent,true);
2828 mTodoEditor->exec(); 2833 mTodoEditor->exec();
2829 setActiveWindow(); 2834 setActiveWindow();
2830} 2835}
2831 2836
2832void CalendarView::newFloatingEvent() 2837void CalendarView::newFloatingEvent()
2833{ 2838{
2834 DateList tmpList = mNavigator->selectedDates(); 2839 DateList tmpList = mNavigator->selectedDates();
2835 QDate date = tmpList.first(); 2840 QDate date = tmpList.first();
2836 2841
2837 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 2842 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
2838 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 2843 QDateTime( date, QTime( 12, 0, 0 ) ), true );
2839} 2844}
2840 2845
2841 2846
2842void CalendarView::editEvent( Event *event ) 2847void CalendarView::editEvent( Event *event )
2843{ 2848{
2844 2849
2845 if ( !event ) return; 2850 if ( !event ) return;
2846 if ( event->isReadOnly() ) { 2851 if ( event->isReadOnly() ) {
2847 showEvent( event ); 2852 showEvent( event );
2848 return; 2853 return;
2849 } 2854 }
2850 showEventEditor(); 2855 showEventEditor();
2851 mEventEditor->editEvent( event , mFlagEditDescription); 2856 mEventEditor->editEvent( event , mFlagEditDescription);
2852 mEventEditor->exec(); 2857 mEventEditor->exec();
2853 setActiveWindow(); 2858 setActiveWindow();
2854 2859
2855} 2860}
2856void CalendarView::editJournal( Journal *jour ) 2861void CalendarView::editJournal( Journal *jour )
2857{ 2862{
2858 if ( !jour ) return; 2863 if ( !jour ) return;
2859 mDialogManager->hideSearchDialog(); 2864 mDialogManager->hideSearchDialog();
2860 mViewManager->showJournalView(); 2865 mViewManager->showJournalView();
2861 mNavigator->slotDaySelect( jour->dtStart().date() ); 2866 mNavigator->slotDaySelect( jour->dtStart().date() );
2862} 2867}
2863void CalendarView::editTodo( Todo *todo ) 2868void CalendarView::editTodo( Todo *todo )
2864{ 2869{
2865 if ( !todo ) return; 2870 if ( !todo ) return;
2866 2871
2867 if ( todo->isReadOnly() ) { 2872 if ( todo->isReadOnly() ) {
2868 showTodo( todo ); 2873 showTodo( todo );
2869 return; 2874 return;
2870 } 2875 }
2871 showTodoEditor(); 2876 showTodoEditor();
2872 mTodoEditor->editTodo( todo ,mFlagEditDescription); 2877 mTodoEditor->editTodo( todo ,mFlagEditDescription);
2873 mTodoEditor->exec(); 2878 mTodoEditor->exec();
2874 setActiveWindow(); 2879 setActiveWindow();
2875 2880
2876} 2881}
2877 2882
2878KOEventViewerDialog* CalendarView::getEventViewerDialog() 2883KOEventViewerDialog* CalendarView::getEventViewerDialog()
2879{ 2884{
2880 if ( !mEventViewerDialog ) { 2885 if ( !mEventViewerDialog ) {
2881 mEventViewerDialog = new KOEventViewerDialog(0); 2886 mEventViewerDialog = new KOEventViewerDialog(0);
2882 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 2887 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
2883 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 2888 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
2884 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 2889 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
2885 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 2890 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
2886 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 2891 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
2887 viewManager(), SLOT( showAgendaView( bool ) ) ); 2892 viewManager(), SLOT( showAgendaView( bool ) ) );
2888 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), 2893 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()),
2889 this, SLOT( slotViewerClosed() ) ); 2894 this, SLOT( slotViewerClosed() ) );
2890 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), 2895 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ),
2891 this, SLOT( todoChanged(Todo *) ) ); 2896 this, SLOT( todoChanged(Todo *) ) );
2892 mEventViewerDialog->resize( 640, 480 ); 2897 mEventViewerDialog->resize( 640, 480 );
2893 2898
2894 } 2899 }
2895 return mEventViewerDialog; 2900 return mEventViewerDialog;
2896} 2901}
2897void CalendarView::showEvent(Event *event) 2902void CalendarView::showEvent(Event *event)
2898{ 2903{
2899 getEventViewerDialog()->setEvent(event); 2904 getEventViewerDialog()->setEvent(event);
2900 getEventViewerDialog()->showMe(); 2905 getEventViewerDialog()->showMe();
2901} 2906}
2902 2907
2903void CalendarView::showTodo(Todo *event) 2908void CalendarView::showTodo(Todo *event)
2904{ 2909{
2905 getEventViewerDialog()->setTodo(event); 2910 getEventViewerDialog()->setTodo(event);
2906 getEventViewerDialog()->showMe(); 2911 getEventViewerDialog()->showMe();
2907} 2912}
2908void CalendarView::showJournal( Journal *jour ) 2913void CalendarView::showJournal( Journal *jour )
2909{ 2914{
2910 getEventViewerDialog()->setJournal(jour); 2915 getEventViewerDialog()->setJournal(jour);
2911 getEventViewerDialog()->showMe(); 2916 getEventViewerDialog()->showMe();
2912 2917
2913} 2918}
2914// void CalendarView::todoModified (Todo *event, int changed) 2919// void CalendarView::todoModified (Todo *event, int changed)
2915// { 2920// {
2916// // if (mDialogList.find (event) != mDialogList.end ()) { 2921// // if (mDialogList.find (event) != mDialogList.end ()) {
2917// // kdDebug() << "Todo modified and open" << endl; 2922// // kdDebug() << "Todo modified and open" << endl;
2918// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 2923// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
2919// // temp->modified (changed); 2924// // temp->modified (changed);
2920 2925
2921// // } 2926// // }
2922 2927
2923// mViewManager->updateView(); 2928// mViewManager->updateView();
2924// } 2929// }
2925 2930
2926void CalendarView::appointment_show() 2931void CalendarView::appointment_show()
2927{ 2932{
2928 Event *anEvent = 0; 2933 Event *anEvent = 0;
2929 2934
2930 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2935 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2931 2936
2932 if (mViewManager->currentView()->isEventView()) { 2937 if (mViewManager->currentView()->isEventView()) {
2933 if ( incidence && incidence->type() == "Event" ) { 2938 if ( incidence && incidence->type() == "Event" ) {
2934 anEvent = static_cast<Event *>(incidence); 2939 anEvent = static_cast<Event *>(incidence);
2935 } 2940 }
2936 } 2941 }
2937 2942
2938 if (!anEvent) { 2943 if (!anEvent) {
2939 KNotifyClient::beep(); 2944 KNotifyClient::beep();
2940 return; 2945 return;
2941 } 2946 }
2942 2947
2943 showEvent(anEvent); 2948 showEvent(anEvent);
2944} 2949}
2945 2950
2946void CalendarView::appointment_edit() 2951void CalendarView::appointment_edit()
2947{ 2952{
2948 Event *anEvent = 0; 2953 Event *anEvent = 0;
2949 2954
2950 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2955 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2951 2956
2952 if (mViewManager->currentView()->isEventView()) { 2957 if (mViewManager->currentView()->isEventView()) {
2953 if ( incidence && incidence->type() == "Event" ) { 2958 if ( incidence && incidence->type() == "Event" ) {
2954 anEvent = static_cast<Event *>(incidence); 2959 anEvent = static_cast<Event *>(incidence);
2955 } 2960 }
2956 } 2961 }
2957 2962
2958 if (!anEvent) { 2963 if (!anEvent) {
2959 KNotifyClient::beep(); 2964 KNotifyClient::beep();
2960 return; 2965 return;
2961 } 2966 }
2962 2967
2963 editEvent(anEvent); 2968 editEvent(anEvent);
2964} 2969}
2965 2970
2966void CalendarView::appointment_delete() 2971void CalendarView::appointment_delete()
2967{ 2972{
2968 Event *anEvent = 0; 2973 Event *anEvent = 0;
2969 2974
2970 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2975 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2971 2976
2972 if (mViewManager->currentView()->isEventView()) { 2977 if (mViewManager->currentView()->isEventView()) {
2973 if ( incidence && incidence->type() == "Event" ) { 2978 if ( incidence && incidence->type() == "Event" ) {
2974 anEvent = static_cast<Event *>(incidence); 2979 anEvent = static_cast<Event *>(incidence);
2975 } 2980 }
2976 } 2981 }
2977 2982
2978 if (!anEvent) { 2983 if (!anEvent) {
2979 KNotifyClient::beep(); 2984 KNotifyClient::beep();
2980 return; 2985 return;
2981 } 2986 }
2982 2987
2983 deleteEvent(anEvent); 2988 deleteEvent(anEvent);
2984} 2989}
2985 2990
2986void CalendarView::todo_resub( Todo * parent, Todo * sub ) 2991void CalendarView::todo_resub( Todo * parent, Todo * sub )
2987{ 2992{
2988 if (!sub) return; 2993 if (!sub) return;
2989 if (!parent) return; 2994 if (!parent) return;
2990 if ( sub->relatedTo() ) 2995 if ( sub->relatedTo() )
2991 sub->relatedTo()->removeRelation(sub); 2996 sub->relatedTo()->removeRelation(sub);
2992 sub->setRelatedTo(parent); 2997 sub->setRelatedTo(parent);
2993 sub->setRelatedToUid(parent->uid()); 2998 sub->setRelatedToUid(parent->uid());
2994 parent->addRelation(sub); 2999 parent->addRelation(sub);
2995 sub->updated(); 3000 sub->updated();
2996 parent->updated(); 3001 parent->updated();
2997 setModified(true); 3002 setModified(true);
2998 updateView(); 3003 updateView();
2999} 3004}
3000void CalendarView::todo_unsub(Todo *anTodo ) 3005void CalendarView::todo_unsub(Todo *anTodo )
3001{ 3006{
3002 // Todo *anTodo = selectedTodo(); 3007 // Todo *anTodo = selectedTodo();
3003 if (!anTodo) return; 3008 if (!anTodo) return;
3004 if (!anTodo->relatedTo()) return; 3009 if (!anTodo->relatedTo()) return;
3005 anTodo->relatedTo()->removeRelation(anTodo); 3010 anTodo->relatedTo()->removeRelation(anTodo);
3006 anTodo->setRelatedTo(0); 3011 anTodo->setRelatedTo(0);
3007 anTodo->updated(); 3012 anTodo->updated();
3008 anTodo->setRelatedToUid(""); 3013 anTodo->setRelatedToUid("");
3009 setModified(true); 3014 setModified(true);
3010 updateView(); 3015 updateView();
3011} 3016}
3012 3017
3013void CalendarView::deleteTodo(Todo *todo) 3018void CalendarView::deleteTodo(Todo *todo)
3014{ 3019{
3015 if (!todo) { 3020 if (!todo) {
3016 KNotifyClient::beep(); 3021 KNotifyClient::beep();
3017 return; 3022 return;
3018 } 3023 }
3019 if (KOPrefs::instance()->mConfirm) { 3024 if (KOPrefs::instance()->mConfirm) {
3020 QString text = todo->summary().left(20); 3025 QString text = todo->summary().left(20);
3021 if (!todo->relations().isEmpty()) { 3026 if (!todo->relations().isEmpty()) {
3022 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); 3027 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!");
3023 3028
3024 } 3029 }
3025 switch (msgItemDelete(text)) { 3030 switch (msgItemDelete(text)) {
3026 case KMessageBox::Continue: // OK 3031 case KMessageBox::Continue: // OK
3027 bool deleteT = false; 3032 bool deleteT = false;
3028 if (!todo->relations().isEmpty()) { 3033 if (!todo->relations().isEmpty()) {
3029 deleteT = removeCompletedSubTodos( todo ); 3034 deleteT = removeCompletedSubTodos( todo );
3030 } 3035 }
3031 // deleteT == true: todo already deleted in removeCompletedSubTodos 3036 // deleteT == true: todo already deleted in removeCompletedSubTodos
3032 if ( !deleteT ) { 3037 if ( !deleteT ) {
3033 checkExternalId( todo ); 3038 checkExternalId( todo );
3034 calendar()->deleteTodo(todo); 3039 calendar()->deleteTodo(todo);
3035 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 3040 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
3036 updateView(); 3041 updateView();
3037 } 3042 }
3038 break; 3043 break;
3039 } // switch 3044 } // switch
3040 } else { 3045 } else {
3041 checkExternalId( todo ); 3046 checkExternalId( todo );
3042 mCalendar->deleteTodo(todo); 3047 mCalendar->deleteTodo(todo);
3043 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 3048 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
3044 updateView(); 3049 updateView();
3045 } 3050 }
3046 3051
3047 emit updateSearchDialog(); 3052 emit updateSearchDialog();
3048} 3053}
3049void CalendarView::deleteJournal(Journal *jour) 3054void CalendarView::deleteJournal(Journal *jour)
3050{ 3055{
3051 if (!jour) { 3056 if (!jour) {
3052 KNotifyClient::beep(); 3057 KNotifyClient::beep();
3053 return; 3058 return;
3054 } 3059 }
3055 if (KOPrefs::instance()->mConfirm) { 3060 if (KOPrefs::instance()->mConfirm) {
3056 switch (msgItemDelete( jour->description().left(20))) { 3061 switch (msgItemDelete( jour->description().left(20))) {
3057 case KMessageBox::Continue: // OK 3062 case KMessageBox::Continue: // OK
3058 calendar()->deleteJournal(jour); 3063 calendar()->deleteJournal(jour);
3059 updateView(); 3064 updateView();
3060 break; 3065 break;
3061 } // switch 3066 } // switch
3062 } else { 3067 } else {
3063 calendar()->deleteJournal(jour);; 3068 calendar()->deleteJournal(jour);;
3064 updateView(); 3069 updateView();
3065 } 3070 }
3066 emit updateSearchDialog(); 3071 emit updateSearchDialog();
3067} 3072}
3068 3073
3069void CalendarView::deleteEvent(Event *anEvent) 3074void CalendarView::deleteEvent(Event *anEvent)
3070{ 3075{
3071 if (!anEvent) { 3076 if (!anEvent) {
3072 KNotifyClient::beep(); 3077 KNotifyClient::beep();
3073 return; 3078 return;
3074 } 3079 }
3075 3080
3076 if (anEvent->recurrence()->doesRecur()) { 3081 if (anEvent->recurrence()->doesRecur()) {
3077 QDate itemDate = mViewManager->currentSelectionDate(); 3082 QDate itemDate = mViewManager->currentSelectionDate();
3078 int km; 3083 int km;
3079 if (!itemDate.isValid()) { 3084 if (!itemDate.isValid()) {
3080 //kdDebug() << "Date Not Valid" << endl; 3085 //kdDebug() << "Date Not Valid" << endl;
3081 if (KOPrefs::instance()->mConfirm) { 3086 if (KOPrefs::instance()->mConfirm) {
3082 km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + 3087 km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) +
3083 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), 3088 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"),
3084 i18n("KO/Pi Confirmation"),i18n("Delete All")); 3089 i18n("KO/Pi Confirmation"),i18n("Delete All"));
3085 if ( km == KMessageBox::Continue ) 3090 if ( km == KMessageBox::Continue )
3086 km = KMessageBox::No; // No = all below 3091 km = KMessageBox::No; // No = all below
3087 } else 3092 } else
3088 km = KMessageBox::No; 3093 km = KMessageBox::No;
3089 } else { 3094 } else {
3090 km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + 3095 km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) +
3091 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ 3096 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+
3092 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), 3097 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"),
3093 i18n("KO/Pi Confirmation"),i18n("Current"), 3098 i18n("KO/Pi Confirmation"),i18n("Current"),
3094 i18n("All")); 3099 i18n("All"));
3095 } 3100 }
3096 switch(km) { 3101 switch(km) {
3097 3102
3098 case KMessageBox::No: // Continue // all 3103 case KMessageBox::No: // Continue // all
3099 //qDebug("KMessageBox::No "); 3104 //qDebug("KMessageBox::No ");
3100 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3105 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3101 schedule(Scheduler::Cancel,anEvent); 3106 schedule(Scheduler::Cancel,anEvent);
3102 3107
3103 checkExternalId( anEvent); 3108 checkExternalId( anEvent);
3104 mCalendar->deleteEvent(anEvent); 3109 mCalendar->deleteEvent(anEvent);
3105 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); 3110 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED);
3106 break; 3111 break;
3107 3112
3108 // Disabled because it does not work 3113 // Disabled because it does not work
3109 //#if 0 3114 //#if 0
3110 case KMessageBox::Yes: // just this one 3115 case KMessageBox::Yes: // just this one
3111 //QDate qd = mNavigator->selectedDates().first(); 3116 //QDate qd = mNavigator->selectedDates().first();
3112 //if (!qd.isValid()) { 3117 //if (!qd.isValid()) {
3113 // kdDebug() << "no date selected, or invalid date" << endl; 3118 // kdDebug() << "no date selected, or invalid date" << endl;
3114 // KNotifyClient::beep(); 3119 // KNotifyClient::beep();
3115 // return; 3120 // return;
3116 //} 3121 //}
3117 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); 3122 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1);
3118 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { 3123 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) {
3119 anEvent->addExDate(itemDate); 3124 anEvent->addExDate(itemDate);
3120 int duration = anEvent->recurrence()->duration(); 3125 int duration = anEvent->recurrence()->duration();
3121 if ( duration > 0 ) { 3126 if ( duration > 0 ) {
3122 anEvent->recurrence()->setDuration( duration - 1 ); 3127 anEvent->recurrence()->setDuration( duration - 1 );
3123 } 3128 }
3124 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); 3129 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED);
3125 } 3130 }
3126 break; 3131 break;
3127 //#endif 3132 //#endif
3128 } // switch 3133 } // switch
3129 } else { 3134 } else {
3130 if (KOPrefs::instance()->mConfirm) { 3135 if (KOPrefs::instance()->mConfirm) {
3131 switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + 3136 switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) +
3132 i18n("\nAre you sure you want\nto delete this event?"), 3137 i18n("\nAre you sure you want\nto delete this event?"),
3133 i18n("KO/Pi Confirmation"),i18n("Delete"))) { 3138 i18n("KO/Pi Confirmation"),i18n("Delete"))) {
3134 case KMessageBox::Continue: // OK 3139 case KMessageBox::Continue: // OK
3135 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3140 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3136 schedule(Scheduler::Cancel,anEvent); 3141 schedule(Scheduler::Cancel,anEvent);
3137 checkExternalId( anEvent); 3142 checkExternalId( anEvent);
3138 mCalendar->deleteEvent(anEvent); 3143 mCalendar->deleteEvent(anEvent);
3139 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3144 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3140 break; 3145 break;
3141 } // switch 3146 } // switch
3142 } else { 3147 } else {
3143 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3148 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3144 schedule(Scheduler::Cancel,anEvent); 3149 schedule(Scheduler::Cancel,anEvent);
3145 checkExternalId( anEvent); 3150 checkExternalId( anEvent);
3146 mCalendar->deleteEvent(anEvent); 3151 mCalendar->deleteEvent(anEvent);
3147 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3152 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3148 } 3153 }
3149 } // if-else 3154 } // if-else
3150 emit updateSearchDialog(); 3155 emit updateSearchDialog();
3151} 3156}
3152 3157
3153bool CalendarView::deleteEvent(const QString &uid) 3158bool CalendarView::deleteEvent(const QString &uid)
3154{ 3159{
3155 Event *ev = mCalendar->event(uid); 3160 Event *ev = mCalendar->event(uid);
3156 if (ev) { 3161 if (ev) {
3157 deleteEvent(ev); 3162 deleteEvent(ev);
3158 return true; 3163 return true;
3159 } else { 3164 } else {
3160 return false; 3165 return false;
3161 } 3166 }
3162} 3167}
3163 3168
3164/*****************************************************************************/ 3169/*****************************************************************************/
3165 3170
3166void CalendarView::action_mail() 3171void CalendarView::action_mail()
3167{ 3172{
3168#ifndef KORG_NOMAIL 3173#ifndef KORG_NOMAIL
3169 KOMailClient mailClient; 3174 KOMailClient mailClient;
3170 3175
3171 Incidence *incidence = currentSelection(); 3176 Incidence *incidence = currentSelection();
3172 3177
3173 if (!incidence) { 3178 if (!incidence) {
3174 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3179 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3175 return; 3180 return;
3176 } 3181 }
3177 if(incidence->attendeeCount() == 0 ) { 3182 if(incidence->attendeeCount() == 0 ) {
3178 KMessageBox::sorry(this, 3183 KMessageBox::sorry(this,
3179 i18n("Can't generate mail:\nNo attendees defined.\n")); 3184 i18n("Can't generate mail:\nNo attendees defined.\n"));
3180 return; 3185 return;
3181 } 3186 }
3182 3187
3183 CalendarLocal cal_tmp; 3188 CalendarLocal cal_tmp;
3184 Event *event = 0; 3189 Event *event = 0;
3185 Event *ev = 0; 3190 Event *ev = 0;
3186 if ( incidence && incidence->type() == "Event" ) { 3191 if ( incidence && incidence->type() == "Event" ) {
3187 event = static_cast<Event *>(incidence); 3192 event = static_cast<Event *>(incidence);
3188 ev = new Event(*event); 3193 ev = new Event(*event);
3189 cal_tmp.addEvent(ev); 3194 cal_tmp.addEvent(ev);
3190 } 3195 }
3191 ICalFormat mForm(); 3196 ICalFormat mForm();
3192 QString attachment = mForm.toString( &cal_tmp ); 3197 QString attachment = mForm.toString( &cal_tmp );
3193 if (ev) delete(ev); 3198 if (ev) delete(ev);
3194 3199
3195 mailClient.mailAttendees(currentSelection(), attachment); 3200 mailClient.mailAttendees(currentSelection(), attachment);
3196 3201
3197#endif 3202#endif
3198 3203
3199#if 0 3204#if 0
3200 Event *anEvent = 0; 3205 Event *anEvent = 0;
3201 if (mViewManager->currentView()->isEventView()) { 3206 if (mViewManager->currentView()->isEventView()) {
3202 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); 3207 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first());
3203 } 3208 }
3204 3209
3205 if (!anEvent) { 3210 if (!anEvent) {
3206 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3211 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3207 return; 3212 return;
3208 } 3213 }
3209 if(anEvent->attendeeCount() == 0 ) { 3214 if(anEvent->attendeeCount() == 0 ) {
3210 KMessageBox::sorry(this, 3215 KMessageBox::sorry(this,
3211 i18n("Can't generate mail:\nNo attendees defined.\n")); 3216 i18n("Can't generate mail:\nNo attendees defined.\n"));
3212 return; 3217 return;
3213 } 3218 }
3214 3219
3215 mailobject.emailEvent(anEvent); 3220 mailobject.emailEvent(anEvent);
3216#endif 3221#endif
3217} 3222}
3218 3223
3219 3224
3220void CalendarView::schedule_publish(Incidence *incidence) 3225void CalendarView::schedule_publish(Incidence *incidence)
3221{ 3226{
3222 Event *event = 0; 3227 Event *event = 0;
3223 Todo *todo = 0; 3228 Todo *todo = 0;
3224 3229
3225 if (incidence == 0) { 3230 if (incidence == 0) {
3226 incidence = mViewManager->currentView()->selectedIncidences().first(); 3231 incidence = mViewManager->currentView()->selectedIncidences().first();
3227 if (incidence == 0) { 3232 if (incidence == 0) {
3228 incidence = mTodoList->selectedIncidences().first(); 3233 incidence = mTodoList->selectedIncidences().first();
3229 } 3234 }
3230 } 3235 }
3231 if ( incidence && incidence->type() == "Event" ) { 3236 if ( incidence && incidence->type() == "Event" ) {
3232 event = static_cast<Event *>(incidence); 3237 event = static_cast<Event *>(incidence);
3233 } else { 3238 } else {
3234 if ( incidence && incidence->type() == "Todo" ) { 3239 if ( incidence && incidence->type() == "Todo" ) {
3235 todo = static_cast<Todo *>(incidence); 3240 todo = static_cast<Todo *>(incidence);
3236 } 3241 }
3237 } 3242 }
3238 3243
3239 if (!event && !todo) { 3244 if (!event && !todo) {
3240 KMessageBox::sorry(this,i18n("No event selected.")); 3245 KMessageBox::sorry(this,i18n("No event selected."));
3241 return; 3246 return;
3242 } 3247 }
3243 3248
3244 PublishDialog *publishdlg = new PublishDialog(); 3249 PublishDialog *publishdlg = new PublishDialog();
3245 if (incidence->attendeeCount()>0) { 3250 if (incidence->attendeeCount()>0) {
3246 QPtrList<Attendee> attendees = incidence->attendees(); 3251 QPtrList<Attendee> attendees = incidence->attendees();
3247 attendees.first(); 3252 attendees.first();
3248 while ( attendees.current()!=0 ) { 3253 while ( attendees.current()!=0 ) {
3249 publishdlg->addAttendee(attendees.current()); 3254 publishdlg->addAttendee(attendees.current());
3250 attendees.next(); 3255 attendees.next();
3251 } 3256 }
3252 } 3257 }
3253 bool send = true; 3258 bool send = true;
3254 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { 3259 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) {
3255 if ( publishdlg->exec() != QDialog::Accepted ) 3260 if ( publishdlg->exec() != QDialog::Accepted )
3256 send = false; 3261 send = false;
3257 } 3262 }
3258 if ( send ) { 3263 if ( send ) {
3259 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3264 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3260 if ( event ) { 3265 if ( event ) {
3261 Event *ev = new Event(*event); 3266 Event *ev = new Event(*event);
3262 ev->registerObserver(0); 3267 ev->registerObserver(0);
3263 ev->clearAttendees(); 3268 ev->clearAttendees();
3264 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3269 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3265 delete(ev); 3270 delete(ev);
3266 } 3271 }
3267 } else { 3272 } else {
3268 if ( todo ) { 3273 if ( todo ) {
3269 Todo *ev = new Todo(*todo); 3274 Todo *ev = new Todo(*todo);
3270 ev->registerObserver(0); 3275 ev->registerObserver(0);
3271 ev->clearAttendees(); 3276 ev->clearAttendees();
3272 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3277 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3273 delete(ev); 3278 delete(ev);
3274 } 3279 }
3275 } 3280 }
3276 } 3281 }
3277 } 3282 }
3278 delete publishdlg; 3283 delete publishdlg;
3279} 3284}
3280 3285
3281void CalendarView::schedule_request(Incidence *incidence) 3286void CalendarView::schedule_request(Incidence *incidence)
3282{ 3287{
3283 schedule(Scheduler::Request,incidence); 3288 schedule(Scheduler::Request,incidence);
3284} 3289}
3285 3290
3286void CalendarView::schedule_refresh(Incidence *incidence) 3291void CalendarView::schedule_refresh(Incidence *incidence)
3287{ 3292{
3288 schedule(Scheduler::Refresh,incidence); 3293 schedule(Scheduler::Refresh,incidence);
3289} 3294}
3290 3295
3291void CalendarView::schedule_cancel(Incidence *incidence) 3296void CalendarView::schedule_cancel(Incidence *incidence)
3292{ 3297{
3293 schedule(Scheduler::Cancel,incidence); 3298 schedule(Scheduler::Cancel,incidence);
3294} 3299}
3295 3300
3296void CalendarView::schedule_add(Incidence *incidence) 3301void CalendarView::schedule_add(Incidence *incidence)
3297{ 3302{
3298 schedule(Scheduler::Add,incidence); 3303 schedule(Scheduler::Add,incidence);
3299} 3304}
3300 3305
3301void CalendarView::schedule_reply(Incidence *incidence) 3306void CalendarView::schedule_reply(Incidence *incidence)
3302{ 3307{
3303 schedule(Scheduler::Reply,incidence); 3308 schedule(Scheduler::Reply,incidence);
3304} 3309}
3305 3310
3306void CalendarView::schedule_counter(Incidence *incidence) 3311void CalendarView::schedule_counter(Incidence *incidence)
3307{ 3312{
3308 schedule(Scheduler::Counter,incidence); 3313 schedule(Scheduler::Counter,incidence);
3309} 3314}
3310 3315
3311void CalendarView::schedule_declinecounter(Incidence *incidence) 3316void CalendarView::schedule_declinecounter(Incidence *incidence)
3312{ 3317{
3313 schedule(Scheduler::Declinecounter,incidence); 3318 schedule(Scheduler::Declinecounter,incidence);
3314} 3319}
3315 3320
3316void CalendarView::schedule_publish_freebusy(int daysToPublish) 3321void CalendarView::schedule_publish_freebusy(int daysToPublish)
3317{ 3322{
3318 QDateTime start = QDateTime::currentDateTime(); 3323 QDateTime start = QDateTime::currentDateTime();
3319 QDateTime end = start.addDays(daysToPublish); 3324 QDateTime end = start.addDays(daysToPublish);
3320 3325
3321 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); 3326 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end);
3322 freebusy->setOrganizer(KOPrefs::instance()->email()); 3327 freebusy->setOrganizer(KOPrefs::instance()->email());
3323 3328
3324 3329
3325 PublishDialog *publishdlg = new PublishDialog(); 3330 PublishDialog *publishdlg = new PublishDialog();
3326 if ( publishdlg->exec() == QDialog::Accepted ) { 3331 if ( publishdlg->exec() == QDialog::Accepted ) {
3327 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3332 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3328 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { 3333 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) {
3329 delete(freebusy); 3334 delete(freebusy);
3330 } 3335 }
3331 } 3336 }
3332 delete publishdlg; 3337 delete publishdlg;
3333} 3338}
3334 3339
3335void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) 3340void CalendarView::schedule(Scheduler::Method method, Incidence *incidence)
3336{ 3341{
3337 Event *event = 0; 3342 Event *event = 0;
3338 Todo *todo = 0; 3343 Todo *todo = 0;
3339 3344
3340 if (incidence == 0) { 3345 if (incidence == 0) {
3341 incidence = mViewManager->currentView()->selectedIncidences().first(); 3346 incidence = mViewManager->currentView()->selectedIncidences().first();
3342 if (incidence == 0) { 3347 if (incidence == 0) {
3343 incidence = mTodoList->selectedIncidences().first(); 3348 incidence = mTodoList->selectedIncidences().first();
3344 } 3349 }
3345 } 3350 }
3346 if ( incidence && incidence->type() == "Event" ) { 3351 if ( incidence && incidence->type() == "Event" ) {
3347 event = static_cast<Event *>(incidence); 3352 event = static_cast<Event *>(incidence);
3348 } 3353 }
3349 if ( incidence && incidence->type() == "Todo" ) { 3354 if ( incidence && incidence->type() == "Todo" ) {
3350 todo = static_cast<Todo *>(incidence); 3355 todo = static_cast<Todo *>(incidence);
3351 } 3356 }
3352 3357
3353 if (!event && !todo) { 3358 if (!event && !todo) {
3354 KMessageBox::sorry(this,i18n("No event selected.")); 3359 KMessageBox::sorry(this,i18n("No event selected."));
3355 return; 3360 return;
3356 } 3361 }
3357 3362
3358 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { 3363 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) {
3359 KMessageBox::sorry(this,i18n("The event has no attendees.")); 3364 KMessageBox::sorry(this,i18n("The event has no attendees."));
3360 return; 3365 return;
3361 } 3366 }
3362 3367
3363 Event *ev = 0; 3368 Event *ev = 0;
3364 if (event) ev = new Event(*event); 3369 if (event) ev = new Event(*event);
3365 Todo *to = 0; 3370 Todo *to = 0;
3366 if (todo) to = new Todo(*todo); 3371 if (todo) to = new Todo(*todo);
3367 3372
3368 if (method == Scheduler::Reply || method == Scheduler::Refresh) { 3373 if (method == Scheduler::Reply || method == Scheduler::Refresh) {
3369 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 3374 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
3370 if (!me) { 3375 if (!me) {
3371 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); 3376 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails."));
3372 return; 3377 return;
3373 } 3378 }
3374 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { 3379 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) {
3375 StatusDialog *statdlg = new StatusDialog(this); 3380 StatusDialog *statdlg = new StatusDialog(this);
3376 if (!statdlg->exec()==QDialog::Accepted) return; 3381 if (!statdlg->exec()==QDialog::Accepted) return;
3377 me->setStatus( statdlg->status() ); 3382 me->setStatus( statdlg->status() );
3378 delete(statdlg); 3383 delete(statdlg);
3379 } 3384 }
3380 Attendee *menew = new Attendee(*me); 3385 Attendee *menew = new Attendee(*me);
3381 if (ev) { 3386 if (ev) {
3382 ev->clearAttendees(); 3387 ev->clearAttendees();
3383 ev->addAttendee(menew,false); 3388 ev->addAttendee(menew,false);
3384 } else { 3389 } else {
3385 if (to) { 3390 if (to) {
3386 todo->clearAttendees(); 3391 todo->clearAttendees();
3387 todo->addAttendee(menew,false); 3392 todo->addAttendee(menew,false);
3388 } 3393 }
3389 } 3394 }
3390 } 3395 }
3391 3396
3392 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3397 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3393 if (ev) { 3398 if (ev) {
3394 if ( !dlg->addMessage(ev,method) ) delete(ev); 3399 if ( !dlg->addMessage(ev,method) ) delete(ev);
3395 } else { 3400 } else {
3396 if (to) { 3401 if (to) {
3397 if ( !dlg->addMessage(to,method) ) delete(to); 3402 if ( !dlg->addMessage(to,method) ) delete(to);
3398 } 3403 }
3399 } 3404 }
3400} 3405}
3401 3406
3402void CalendarView::openAddressbook() 3407void CalendarView::openAddressbook()
3403{ 3408{
3404 KRun::runCommand("kaddressbook"); 3409 KRun::runCommand("kaddressbook");
3405} 3410}
3406 3411
3407void CalendarView::setModified(bool modified) 3412void CalendarView::setModified(bool modified)
3408{ 3413{
3409 if ( modified ) 3414 if ( modified )
3410 emit signalmodified(); 3415 emit signalmodified();
3411 if (mModified != modified) { 3416 if (mModified != modified) {
3412 mModified = modified; 3417 mModified = modified;
3413 emit modifiedChanged(mModified); 3418 emit modifiedChanged(mModified);
3414 } 3419 }
3415} 3420}
3416 3421
3417bool CalendarView::isReadOnly() 3422bool CalendarView::isReadOnly()
3418{ 3423{
3419 return mReadOnly; 3424 return mReadOnly;
3420} 3425}
3421 3426
3422void CalendarView::setReadOnly(bool readOnly) 3427void CalendarView::setReadOnly(bool readOnly)
3423{ 3428{
3424 if (mReadOnly != readOnly) { 3429 if (mReadOnly != readOnly) {
3425 mReadOnly = readOnly; 3430 mReadOnly = readOnly;
3426 emit readOnlyChanged(mReadOnly); 3431 emit readOnlyChanged(mReadOnly);
3427 } 3432 }
3428} 3433}
3429 3434
3430bool CalendarView::isModified() 3435bool CalendarView::isModified()
3431{ 3436{
3432 return mModified; 3437 return mModified;
3433} 3438}
3434void CalendarView::slotprintSelInc() 3439void CalendarView::slotprintSelInc()
3435{ 3440{
3436 if ( currentSelection() == 0 ) { 3441 if ( currentSelection() == 0 ) {
3437 KMessageBox::sorry(this,i18n("There is nothing selected!")); 3442 KMessageBox::sorry(this,i18n("There is nothing selected!"));
3438 return; 3443 return;
3439 } 3444 }
3440 showIncidence(); 3445 showIncidence();
3441 getEventViewerDialog()->print(); 3446 getEventViewerDialog()->print();
3442 3447
3443} 3448}
3444void CalendarView::printSetup() 3449void CalendarView::printSetup()
3445{ 3450{
3446#ifndef KORG_NOPRINTER 3451#ifndef KORG_NOPRINTER
3447 createPrinter(); 3452 createPrinter();
3448 3453
3449 mCalPrinter->setupPrinter(); 3454 mCalPrinter->setupPrinter();
3450#endif 3455#endif
3451} 3456}
3452 3457
3453void CalendarView::print() 3458void CalendarView::print()
3454{ 3459{
3455#ifndef KORG_NOPRINTER 3460#ifndef KORG_NOPRINTER
3456 createPrinter(); 3461 createPrinter();
3457 3462
3458 DateList tmpDateList = mNavigator->selectedDates(); 3463 DateList tmpDateList = mNavigator->selectedDates();
3459 mCalPrinter->print(CalPrinter::Month, 3464 mCalPrinter->print(CalPrinter::Month,
3460 tmpDateList.first(), tmpDateList.last()); 3465 tmpDateList.first(), tmpDateList.last());
3461#endif 3466#endif
3462} 3467}
3463 3468
3464void CalendarView::printPreview() 3469void CalendarView::printPreview()
3465{ 3470{
3466#ifndef KORG_NOPRINTER 3471#ifndef KORG_NOPRINTER
3467 kdDebug() << "CalendarView::printPreview()" << endl; 3472 kdDebug() << "CalendarView::printPreview()" << endl;
3468 3473
3469 createPrinter(); 3474 createPrinter();
3470 3475
3471 DateList tmpDateList = mNavigator->selectedDates(); 3476 DateList tmpDateList = mNavigator->selectedDates();
3472 3477
3473 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), 3478 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(),
3474 tmpDateList.last()); 3479 tmpDateList.last());
3475#endif 3480#endif
3476} 3481}
3477 3482
3478void CalendarView::exportICalendar() 3483void CalendarView::exportICalendar()
3479{ 3484{
3480 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); 3485 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this);
3481 3486
3482 // Force correct extension 3487 // Force correct extension
3483 if (filename.right(4) != ".ics") filename += ".ics"; 3488 if (filename.right(4) != ".ics") filename += ".ics";
3484 3489
3485 FileStorage storage( mCalendar, filename, new ICalFormat() ); 3490 FileStorage storage( mCalendar, filename, new ICalFormat() );
3486 storage.save(); 3491 storage.save();
3487} 3492}
3488 3493
3489bool CalendarView::exportVCalendar( QString filename ) 3494bool CalendarView::exportVCalendar( QString filename )
3490{ 3495{
3491 if (mCalendar->journals().count() > 0) { 3496 if (mCalendar->journals().count() > 0) {
3492 int result = KMessageBox::warningContinueCancel(this, 3497 int result = KMessageBox::warningContinueCancel(this,
3493 i18n("The journal entries can not be\nexported to a vCalendar file."), 3498 i18n("The journal entries can not be\nexported to a vCalendar file."),
3494 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 3499 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
3495 true); 3500 true);
3496 if (result != KMessageBox::Continue) return false; 3501 if (result != KMessageBox::Continue) return false;
3497 } 3502 }
3498 3503
3499 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); 3504 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this);
3500 3505
3501 // Force correct extension 3506 // Force correct extension
3502 if (filename.right(4) != ".vcs") filename += ".vcs"; 3507 if (filename.right(4) != ".vcs") filename += ".vcs";
3503 3508
3504 FileStorage storage( mCalendar, filename, new VCalFormat ); 3509 FileStorage storage( mCalendar, filename, new VCalFormat );
3505 return storage.save(); 3510 return storage.save();
3506 3511
3507} 3512}
3508 3513
3509void CalendarView::eventUpdated(Incidence *) 3514void CalendarView::eventUpdated(Incidence *)
3510{ 3515{
3511 setModified(); 3516 setModified();
3512 // Don't call updateView here. The code, which has caused the update of the 3517 // Don't call updateView here. The code, which has caused the update of the
3513 // event is responsible for updating the view. 3518 // event is responsible for updating the view.
3514 // updateView(); 3519 // updateView();
3515} 3520}
3516 3521
3517void CalendarView::adaptNavigationUnits() 3522void CalendarView::adaptNavigationUnits()
3518{ 3523{
3519 if (mViewManager->currentView()->isEventView()) { 3524 if (mViewManager->currentView()->isEventView()) {
3520 int days = mViewManager->currentView()->currentDateCount(); 3525 int days = mViewManager->currentView()->currentDateCount();
3521 if (days == 1) { 3526 if (days == 1) {
3522 emit changeNavStringPrev(i18n("&Previous Day")); 3527 emit changeNavStringPrev(i18n("&Previous Day"));
3523 emit changeNavStringNext(i18n("&Next Day")); 3528 emit changeNavStringNext(i18n("&Next Day"));
3524 } else { 3529 } else {
3525 emit changeNavStringPrev(i18n("&Previous Week")); 3530 emit changeNavStringPrev(i18n("&Previous Week"));
3526 emit changeNavStringNext(i18n("&Next Week")); 3531 emit changeNavStringNext(i18n("&Next Week"));
3527 } 3532 }
3528 } 3533 }
3529} 3534}
3530 3535
3531void CalendarView::processMainViewSelection( Incidence *incidence ) 3536void CalendarView::processMainViewSelection( Incidence *incidence )
3532{ 3537{
3533 if ( incidence ) mTodoList->clearSelection(); 3538 if ( incidence ) mTodoList->clearSelection();
3534 processIncidenceSelection( incidence ); 3539 processIncidenceSelection( incidence );
3535} 3540}
3536 3541
3537void CalendarView::processTodoListSelection( Incidence *incidence ) 3542void CalendarView::processTodoListSelection( Incidence *incidence )
3538{ 3543{
3539 if ( incidence && mViewManager->currentView() ) { 3544 if ( incidence && mViewManager->currentView() ) {
3540 mViewManager->currentView()->clearSelection(); 3545 mViewManager->currentView()->clearSelection();
3541 } 3546 }
3542 processIncidenceSelection( incidence ); 3547 processIncidenceSelection( incidence );
3543} 3548}
3544 3549
3545void CalendarView::processIncidenceSelection( Incidence *incidence ) 3550void CalendarView::processIncidenceSelection( Incidence *incidence )
3546{ 3551{
3547 if ( incidence == mSelectedIncidence ) return; 3552 if ( incidence == mSelectedIncidence ) return;
3548 3553
3549 mSelectedIncidence = incidence; 3554 mSelectedIncidence = incidence;
3550 3555
3551 emit incidenceSelected( mSelectedIncidence ); 3556 emit incidenceSelected( mSelectedIncidence );
3552 3557
3553 if ( incidence && incidence->type() == "Event" ) { 3558 if ( incidence && incidence->type() == "Event" ) {
3554 Event *event = static_cast<Event *>( incidence ); 3559 Event *event = static_cast<Event *>( incidence );
3555 if ( event->organizer() == KOPrefs::instance()->email() ) { 3560 if ( event->organizer() == KOPrefs::instance()->email() ) {
3556 emit organizerEventsSelected( true ); 3561 emit organizerEventsSelected( true );
3557 } else { 3562 } else {
3558 emit organizerEventsSelected(false); 3563 emit organizerEventsSelected(false);
3559 } 3564 }
3560 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3565 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3561 KOPrefs::instance()->email() ) ) { 3566 KOPrefs::instance()->email() ) ) {
3562 emit groupEventsSelected( true ); 3567 emit groupEventsSelected( true );
3563 } else { 3568 } else {
3564 emit groupEventsSelected(false); 3569 emit groupEventsSelected(false);
3565 } 3570 }
3566 return; 3571 return;
3567 } else { 3572 } else {
3568 if ( incidence && incidence->type() == "Todo" ) { 3573 if ( incidence && incidence->type() == "Todo" ) {
3569 emit todoSelected( true ); 3574 emit todoSelected( true );
3570 Todo *event = static_cast<Todo *>( incidence ); 3575 Todo *event = static_cast<Todo *>( incidence );
3571 if ( event->organizer() == KOPrefs::instance()->email() ) { 3576 if ( event->organizer() == KOPrefs::instance()->email() ) {
3572 emit organizerEventsSelected( true ); 3577 emit organizerEventsSelected( true );
3573 } else { 3578 } else {
3574 emit organizerEventsSelected(false); 3579 emit organizerEventsSelected(false);
3575 } 3580 }
3576 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3581 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3577 KOPrefs::instance()->email() ) ) { 3582 KOPrefs::instance()->email() ) ) {
3578 emit groupEventsSelected( true ); 3583 emit groupEventsSelected( true );
3579 } else { 3584 } else {
3580 emit groupEventsSelected(false); 3585 emit groupEventsSelected(false);
3581 } 3586 }
3582 return; 3587 return;
3583 } else { 3588 } else {
3584 emit todoSelected( false ); 3589 emit todoSelected( false );
3585 emit organizerEventsSelected(false); 3590 emit organizerEventsSelected(false);
3586 emit groupEventsSelected(false); 3591 emit groupEventsSelected(false);
3587 } 3592 }
3588 return; 3593 return;
3589 } 3594 }
3590 3595
3591 /* if ( incidence && incidence->type() == "Todo" ) { 3596 /* if ( incidence && incidence->type() == "Todo" ) {
3592 emit todoSelected( true ); 3597 emit todoSelected( true );
3593 } else { 3598 } else {
3594 emit todoSelected( false ); 3599 emit todoSelected( false );
3595 }*/ 3600 }*/
3596} 3601}
3597 3602
3598 3603
3599void CalendarView::checkClipboard() 3604void CalendarView::checkClipboard()
3600{ 3605{
3601#ifndef KORG_NODND 3606#ifndef KORG_NODND
3602 if (ICalDrag::canDecode(QApplication::clipboard()->data())) { 3607 if (ICalDrag::canDecode(QApplication::clipboard()->data())) {
3603 emit pasteEnabled(true); 3608 emit pasteEnabled(true);
3604 } else { 3609 } else {
3605 emit pasteEnabled(false); 3610 emit pasteEnabled(false);
3606 } 3611 }
3607#endif 3612#endif
3608} 3613}
3609 3614
3610void CalendarView::showDates(const DateList &selectedDates) 3615void CalendarView::showDates(const DateList &selectedDates)
3611{ 3616{
3612 // kdDebug() << "CalendarView::selectDates()" << endl; 3617 // kdDebug() << "CalendarView::selectDates()" << endl;
3613 3618
3614 3619
3615 if ( !mBlockShowDates ) { 3620 if ( !mBlockShowDates ) {
3616 if ( mViewManager->currentView() ) { 3621 if ( mViewManager->currentView() ) {
3617 updateView( selectedDates.first(), selectedDates.last() ); 3622 updateView( selectedDates.first(), selectedDates.last() );
3618 } else { 3623 } else {
3619 mViewManager->showAgendaView(); 3624 mViewManager->showAgendaView();
3620 } 3625 }
3621 } 3626 }
3622 3627
3623 QDate date = selectedDates.first(); 3628 QDate date = selectedDates.first();
3624 if ( ! date.isValid() ) { 3629 if ( ! date.isValid() ) {
3625 topLevelWidget()->setCaption(""); 3630 topLevelWidget()->setCaption("");
3626 return; 3631 return;
3627 } 3632 }
3628 3633
3629 QString selDates; 3634 QString selDates;
3630 selDates = KGlobal::locale()->formatDate( date, true); 3635 selDates = KGlobal::locale()->formatDate( date, true);
3631 if (selectedDates.first() < selectedDates.last() ) 3636 if (selectedDates.first() < selectedDates.last() )
3632 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); 3637 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true);
3633 else { 3638 else {
3634 QString addString; 3639 QString addString;
3635 if ( date == QDateTime::currentDateTime().date() ) 3640 if ( date == QDateTime::currentDateTime().date() )
3636 addString = i18n("Today"); 3641 addString = i18n("Today");
3637 else if ( date == QDateTime::currentDateTime().date().addDays(1) ) 3642 else if ( date == QDateTime::currentDateTime().date().addDays(1) )
3638 addString = i18n("Tomorrow"); 3643 addString = i18n("Tomorrow");
3639 else if ( date == QDateTime::currentDateTime().date().addDays(-1) ) 3644 else if ( date == QDateTime::currentDateTime().date().addDays(-1) )
3640 addString = i18n("Yesterday"); 3645 addString = i18n("Yesterday");
3641 else if ( date == QDateTime::currentDateTime().date().addDays(-2) ) 3646 else if ( date == QDateTime::currentDateTime().date().addDays(-2) )
3642 addString = i18n("Day before yesterday"); 3647 addString = i18n("Day before yesterday");
3643 else if ( date == QDateTime::currentDateTime().date().addDays(2) ) 3648 else if ( date == QDateTime::currentDateTime().date().addDays(2) )
3644 addString = i18n("Day after tomorrow"); 3649 addString = i18n("Day after tomorrow");
3645 if ( !addString.isEmpty() ) { 3650 if ( !addString.isEmpty() ) {
3646 topLevelWidget()->setCaption( addString+", " + selDates ); 3651 topLevelWidget()->setCaption( addString+", " + selDates );
3647 return; 3652 return;
3648 } 3653 }
3649 } 3654 }
3650 topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); 3655 topLevelWidget()->setCaption( i18n("Dates: ") + selDates );
3651 3656
3652} 3657}
3653 3658
3654QPtrList<CalFilter> CalendarView::filters() 3659QPtrList<CalFilter> CalendarView::filters()
3655{ 3660{
3656 return mFilters; 3661 return mFilters;
3657 3662
3658} 3663}
3659void CalendarView::editFilters() 3664void CalendarView::editFilters()
3660{ 3665{
3661 // kdDebug() << "CalendarView::editFilters()" << endl; 3666 // kdDebug() << "CalendarView::editFilters()" << endl;
3662 3667
3663 CalFilter *filter = mFilters.first(); 3668 CalFilter *filter = mFilters.first();
3664 while(filter) { 3669 while(filter) {
3665 kdDebug() << " Filter: " << filter->name() << endl; 3670 kdDebug() << " Filter: " << filter->name() << endl;
3666 filter = mFilters.next(); 3671 filter = mFilters.next();
3667 } 3672 }
3668 3673
3669 mDialogManager->showFilterEditDialog(&mFilters); 3674 mDialogManager->showFilterEditDialog(&mFilters);
3670} 3675}
3671void CalendarView::toggleFilter() 3676void CalendarView::toggleFilter()
3672{ 3677{
3673 showFilter(! mFilterView->isVisible()); 3678 showFilter(! mFilterView->isVisible());
3674} 3679}
3675 3680
3676KOFilterView *CalendarView::filterView() 3681KOFilterView *CalendarView::filterView()
3677{ 3682{
3678 return mFilterView; 3683 return mFilterView;
3679} 3684}
3680void CalendarView::selectFilter( int fil ) 3685void CalendarView::selectFilter( int fil )
3681{ 3686{
3682 mFilterView->setSelectedFilter( fil ); 3687 mFilterView->setSelectedFilter( fil );
3683} 3688}
3684void CalendarView::showFilter(bool visible) 3689void CalendarView::showFilter(bool visible)
3685{ 3690{
3686 if (visible) mFilterView->show(); 3691 if (visible) mFilterView->show();
3687 else mFilterView->hide(); 3692 else mFilterView->hide();
3688} 3693}
3689void CalendarView::toggleFilerEnabled( ) 3694void CalendarView::toggleFilerEnabled( )
3690{ 3695{
3691 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); 3696 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() );
3692 if ( !mFilterView->filtersEnabled() ) 3697 if ( !mFilterView->filtersEnabled() )
3693 topLevelWidget()->setCaption( i18n("Filter disabled ") ); 3698 topLevelWidget()->setCaption( i18n("Filter disabled ") );
3694 3699
3695} 3700}
3696void CalendarView::updateFilter() 3701void CalendarView::updateFilter()
3697{ 3702{
3698 CalFilter *filter = mFilterView->selectedFilter(); 3703 CalFilter *filter = mFilterView->selectedFilter();
3699 if (filter) { 3704 if (filter) {
3700 QString mess; 3705 QString mess;
3701 if (mFilterView->filtersEnabled()) { 3706 if (mFilterView->filtersEnabled()) {
3702 mess = i18n("Filter selected: ")+filter->name(); 3707 mess = i18n("Filter selected: ")+filter->name();
3703 filter->setEnabled(true); 3708 filter->setEnabled(true);
3704 } 3709 }
3705 else filter->setEnabled(false); 3710 else filter->setEnabled(false);
3706 mCalendar->setFilter(filter); 3711 mCalendar->setFilter(filter);
3707 updateView(); 3712 updateView();
3708 if ( !mess.isEmpty() ) 3713 if ( !mess.isEmpty() )
3709 topLevelWidget()->setCaption( mess ); 3714 topLevelWidget()->setCaption( mess );
3710 3715
3711 } 3716 }
3712} 3717}
3713 3718
3714void CalendarView::filterEdited() 3719void CalendarView::filterEdited()
3715{ 3720{
3716 mFilterView->updateFilters(); 3721 mFilterView->updateFilters();
3717 updateFilter(); 3722 updateFilter();
3718 writeSettings(); 3723 writeSettings();
3719} 3724}
3720 3725
3721 3726
3722void CalendarView::takeOverEvent() 3727void CalendarView::takeOverEvent()
3723{ 3728{
3724 Incidence *incidence = currentSelection(); 3729 Incidence *incidence = currentSelection();
3725 3730
3726 if (!incidence) return; 3731 if (!incidence) return;
3727 3732
3728 incidence->setOrganizer(KOPrefs::instance()->email()); 3733 incidence->setOrganizer(KOPrefs::instance()->email());
3729 incidence->recreate(); 3734 incidence->recreate();
3730 incidence->setReadOnly(false); 3735 incidence->setReadOnly(false);
3731 3736
3732 updateView(); 3737 updateView();
3733} 3738}
3734 3739
3735void CalendarView::takeOverCalendar() 3740void CalendarView::takeOverCalendar()
3736{ 3741{
3737 // TODO: Create Calendar::allIncidences() function and use it here 3742 // TODO: Create Calendar::allIncidences() function and use it here
3738 3743
3739 QPtrList<Event> events = mCalendar->events(); 3744 QPtrList<Event> events = mCalendar->events();
3740 for(uint i=0; i<events.count(); ++i) { 3745 for(uint i=0; i<events.count(); ++i) {
3741 events.at(i)->setOrganizer(KOPrefs::instance()->email()); 3746 events.at(i)->setOrganizer(KOPrefs::instance()->email());
3742 events.at(i)->recreate(); 3747 events.at(i)->recreate();
3743 events.at(i)->setReadOnly(false); 3748 events.at(i)->setReadOnly(false);
3744 } 3749 }
3745 3750
3746 QPtrList<Todo> todos = mCalendar->todos(); 3751 QPtrList<Todo> todos = mCalendar->todos();
3747 for(uint i=0; i<todos.count(); ++i) { 3752 for(uint i=0; i<todos.count(); ++i) {
3748 todos.at(i)->setOrganizer(KOPrefs::instance()->email()); 3753 todos.at(i)->setOrganizer(KOPrefs::instance()->email());
3749 todos.at(i)->recreate(); 3754 todos.at(i)->recreate();
3750 todos.at(i)->setReadOnly(false); 3755 todos.at(i)->setReadOnly(false);
3751 } 3756 }
3752 3757
3753 QPtrList<Journal> journals = mCalendar->journals(); 3758 QPtrList<Journal> journals = mCalendar->journals();
3754 for(uint i=0; i<journals.count(); ++i) { 3759 for(uint i=0; i<journals.count(); ++i) {
3755 journals.at(i)->setOrganizer(KOPrefs::instance()->email()); 3760 journals.at(i)->setOrganizer(KOPrefs::instance()->email());
3756 journals.at(i)->recreate(); 3761 journals.at(i)->recreate();
3757 journals.at(i)->setReadOnly(false); 3762 journals.at(i)->setReadOnly(false);
3758 } 3763 }
3759 3764
3760 updateView(); 3765 updateView();
3761} 3766}
3762 3767
3763void CalendarView::showIntro() 3768void CalendarView::showIntro()
3764{ 3769{
3765 kdDebug() << "To be implemented." << endl; 3770 kdDebug() << "To be implemented." << endl;
3766} 3771}
3767 3772
3768QWidgetStack *CalendarView::viewStack() 3773QWidgetStack *CalendarView::viewStack()
3769{ 3774{
3770 return mRightFrame; 3775 return mRightFrame;
3771} 3776}
3772 3777
3773QWidget *CalendarView::leftFrame() 3778QWidget *CalendarView::leftFrame()
3774{ 3779{
3775 return ( QWidget *)mLeftFrame; 3780 return ( QWidget *)mLeftFrame;
3776} 3781}
3777 3782
3778DateNavigator *CalendarView::dateNavigator() 3783DateNavigator *CalendarView::dateNavigator()
3779{ 3784{
3780 return mNavigator; 3785 return mNavigator;
3781} 3786}
3782 3787
3783KDateNavigator* CalendarView::dateNavigatorWidget() 3788KDateNavigator* CalendarView::dateNavigatorWidget()
3784{ 3789{
3785 return mDateNavigator->navigatorView(); 3790 return mDateNavigator->navigatorView();
3786} 3791}
3787void CalendarView::toggleDateNavigatorWidget() 3792void CalendarView::toggleDateNavigatorWidget()
3788{ 3793{
3789 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; 3794 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ;
3790 3795
3791 if (!KOPrefs::instance()->mShowDateNavigator ) 3796 if (!KOPrefs::instance()->mShowDateNavigator )
3792 mDateNavigator->hide(); 3797 mDateNavigator->hide();
3793 else 3798 else
3794 mDateNavigator->show(); 3799 mDateNavigator->show();
3795} 3800}
3796void CalendarView::addView(KOrg::BaseView *view) 3801void CalendarView::addView(KOrg::BaseView *view)
3797{ 3802{
3798 mViewManager->addView(view); 3803 mViewManager->addView(view);
3799} 3804}
3800 3805
3801void CalendarView::showView(KOrg::BaseView *view) 3806void CalendarView::showView(KOrg::BaseView *view)
3802{ 3807{
3803 mViewManager->showView(view, mLeftFrame->isVisible()); 3808 mViewManager->showView(view, mLeftFrame->isVisible());
3804} 3809}
3805 3810
3806Incidence *CalendarView::currentSelection() 3811Incidence *CalendarView::currentSelection()
3807{ 3812{
3808 return mViewManager->currentSelection(); 3813 return mViewManager->currentSelection();
3809} 3814}
3810void CalendarView::toggleAllDaySize() 3815void CalendarView::toggleAllDaySize()
3811{ 3816{
3812 /* 3817 /*
3813 if ( KOPrefs::instance()->mAllDaySize > 47 ) 3818 if ( KOPrefs::instance()->mAllDaySize > 47 )
3814 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; 3819 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2;
3815 else 3820 else
3816 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; 3821 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2;
3817 */ 3822 */
3818 viewManager()->agendaView()->toggleAllDay(); 3823 viewManager()->agendaView()->toggleAllDay();
3819} 3824}
3820void CalendarView::toggleExpand() 3825void CalendarView::toggleExpand()
3821{ 3826{
3822 // if ( mLeftFrame->isHidden() ) { 3827 // if ( mLeftFrame->isHidden() ) {
3823 // mLeftFrame->show(); 3828 // mLeftFrame->show();
3824 // emit calendarViewExpanded( false ); 3829 // emit calendarViewExpanded( false );
3825 // } else { 3830 // } else {
3826 // mLeftFrame->hide(); 3831 // mLeftFrame->hide();
3827 // emit calendarViewExpanded( true ); 3832 // emit calendarViewExpanded( true );
3828 // } 3833 // }
3829 //qDebug(" CalendarView::toggleExpand()"); 3834 //qDebug(" CalendarView::toggleExpand()");
3830 globalFlagBlockAgenda = 1; 3835 globalFlagBlockAgenda = 1;
3831 emit calendarViewExpanded( !mLeftFrame->isHidden() ); 3836 emit calendarViewExpanded( !mLeftFrame->isHidden() );
3832 globalFlagBlockAgenda = 5; 3837 globalFlagBlockAgenda = 5;
3833 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); 3838 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() );
3834 //mViewManager->showView( 0, true ); 3839 //mViewManager->showView( 0, true );
3835} 3840}
3836 3841
3837void CalendarView::calendarModified( bool modified, Calendar * ) 3842void CalendarView::calendarModified( bool modified, Calendar * )
3838{ 3843{
3839 setModified( modified ); 3844 setModified( modified );
3840} 3845}
3841 3846
3842Todo *CalendarView::selectedTodo() 3847Todo *CalendarView::selectedTodo()
3843{ 3848{
3844 Incidence *incidence = currentSelection(); 3849 Incidence *incidence = currentSelection();
3845 if ( incidence && incidence->type() == "Todo" ) { 3850 if ( incidence && incidence->type() == "Todo" ) {
3846 return static_cast<Todo *>( incidence ); 3851 return static_cast<Todo *>( incidence );
3847 } 3852 }
3848 3853
3849 incidence = mTodoList->selectedIncidences().first(); 3854 incidence = mTodoList->selectedIncidences().first();
3850 if ( incidence && incidence->type() == "Todo" ) { 3855 if ( incidence && incidence->type() == "Todo" ) {
3851 return static_cast<Todo *>( incidence ); 3856 return static_cast<Todo *>( incidence );
3852 } 3857 }
3853 3858
3854 return 0; 3859 return 0;
3855} 3860}
3856 3861
3857void CalendarView::dialogClosing(Incidence *in) 3862void CalendarView::dialogClosing(Incidence *in)
3858{ 3863{
3859 // mDialogList.remove(in); 3864 // mDialogList.remove(in);
3860} 3865}
3861 3866
3862void CalendarView::showIncidence() 3867void CalendarView::showIncidence()
3863{ 3868{
3864 mViewerCallerIsSearchDialog = false; 3869 mViewerCallerIsSearchDialog = false;
3865 Incidence *incidence = currentSelection(); 3870 Incidence *incidence = currentSelection();
3866 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3871 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3867 if ( incidence ) { 3872 if ( incidence ) {
3868 ShowIncidenceVisitor v; 3873 ShowIncidenceVisitor v;
3869 v.act( incidence, this ); 3874 v.act( incidence, this );
3870 } 3875 }
3871} 3876}
3872void CalendarView::editIncidenceDescription() 3877void CalendarView::editIncidenceDescription()
3873{ 3878{
3874 mFlagEditDescription = true; 3879 mFlagEditDescription = true;
3875 editIncidence(); 3880 editIncidence();
3876 mFlagEditDescription = false; 3881 mFlagEditDescription = false;
3877} 3882}
3878void CalendarView::editIncidence() 3883void CalendarView::editIncidence()
3879{ 3884{
3880 // qDebug("editIncidence() "); 3885 // qDebug("editIncidence() ");
3881 Incidence *incidence = currentSelection(); 3886 Incidence *incidence = currentSelection();
3882 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3887 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3883 if ( incidence ) { 3888 if ( incidence ) {
3884 EditIncidenceVisitor v; 3889 EditIncidenceVisitor v;
3885 v.act( incidence, this ); 3890 v.act( incidence, this );
3886 } 3891 }
3887} 3892}
3888 3893
3889void CalendarView::deleteIncidence() 3894void CalendarView::deleteIncidence()
3890{ 3895{
3891 Incidence *incidence = currentSelection(); 3896 Incidence *incidence = currentSelection();
3892 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3897 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3893 if ( incidence ) { 3898 if ( incidence ) {
3894 deleteIncidence(incidence); 3899 deleteIncidence(incidence);
3895 } 3900 }
3896} 3901}
3897 3902
3898void CalendarView::showIncidence(Incidence *incidence) 3903void CalendarView::showIncidence(Incidence *incidence)
3899{ 3904{
3900 mViewerCallerIsSearchDialog = false; 3905 mViewerCallerIsSearchDialog = false;
3901 //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); 3906 //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() );
3902 if ( sender() && mDialogManager->getSearchDialog() ) { 3907 if ( sender() && mDialogManager->getSearchDialog() ) {
3903 if ( sender () == mDialogManager->getSearchDialog()->listview() ) { 3908 if ( sender () == mDialogManager->getSearchDialog()->listview() ) {
3904 mViewerCallerIsSearchDialog = true; 3909 mViewerCallerIsSearchDialog = true;
3905 } 3910 }
3906 } 3911 }
3907 if ( incidence ) { 3912 if ( incidence ) {
3908 ShowIncidenceVisitor v; 3913 ShowIncidenceVisitor v;
3909 v.act( incidence, this ); 3914 v.act( incidence, this );
3910 } 3915 }
3911} 3916}
3912 3917
3913void CalendarView::editIncidence(Incidence *incidence) 3918void CalendarView::editIncidence(Incidence *incidence)
3914{ 3919{
3915 if ( incidence ) { 3920 if ( incidence ) {
3916 3921
3917 EditIncidenceVisitor v; 3922 EditIncidenceVisitor v;
3918 v.act( incidence, this ); 3923 v.act( incidence, this );
3919 3924
3920 } 3925 }
3921} 3926}
3922 3927
3923void CalendarView::deleteIncidence(Incidence *incidence) 3928void CalendarView::deleteIncidence(Incidence *incidence)
3924{ 3929{
3925 //qDebug(" CalendarView::deleteIncidence "); 3930 //qDebug(" CalendarView::deleteIncidence ");
3926 if ( incidence ) { 3931 if ( incidence ) {
3927 DeleteIncidenceVisitor v; 3932 DeleteIncidenceVisitor v;
3928 v.act( incidence, this ); 3933 v.act( incidence, this );
3929 } 3934 }
3930} 3935}
3931 3936
3932 3937
3933void CalendarView::lookForOutgoingMessages() 3938void CalendarView::lookForOutgoingMessages()
3934{ 3939{
3935 OutgoingDialog *ogd = mDialogManager->outgoingDialog(); 3940 OutgoingDialog *ogd = mDialogManager->outgoingDialog();
3936 ogd->loadMessages(); 3941 ogd->loadMessages();
3937} 3942}
3938 3943
3939void CalendarView::lookForIncomingMessages() 3944void CalendarView::lookForIncomingMessages()
3940{ 3945{
3941 IncomingDialog *icd = mDialogManager->incomingDialog(); 3946 IncomingDialog *icd = mDialogManager->incomingDialog();
3942 icd->retrieve(); 3947 icd->retrieve();
3943} 3948}
3944 3949
3945bool CalendarView::removeCompletedSubTodos( Todo* t ) 3950bool CalendarView::removeCompletedSubTodos( Todo* t )
3946{ 3951{
3947 bool deleteTodo = true; 3952 bool deleteTodo = true;
3948 QPtrList<Incidence> subTodos; 3953 QPtrList<Incidence> subTodos;
3949 Incidence *aTodo; 3954 Incidence *aTodo;
3950 subTodos = t->relations(); 3955 subTodos = t->relations();
3951 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { 3956 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
3952 if (! removeCompletedSubTodos( (Todo*) aTodo )) 3957 if (! removeCompletedSubTodos( (Todo*) aTodo ))
3953 deleteTodo = false; 3958 deleteTodo = false;
3954 } 3959 }
3955 if ( deleteTodo ) { 3960 if ( deleteTodo ) {
3956 if ( t->isCompleted() && !t->doesRecur()) { 3961 if ( t->isCompleted() && !t->doesRecur()) {
3957 checkExternalId( t ); 3962 checkExternalId( t );
3958 mCalendar->deleteTodo( t ); 3963 mCalendar->deleteTodo( t );
3959 changeTodoDisplay( t,KOGlobals::EVENTDELETED ); 3964 changeTodoDisplay( t,KOGlobals::EVENTDELETED );
3960 } 3965 }
3961 else 3966 else
3962 deleteTodo = false; 3967 deleteTodo = false;
3963 } 3968 }
3964 return deleteTodo; 3969 return deleteTodo;
3965 3970
3966} 3971}
3967void CalendarView::purgeCompleted() 3972void CalendarView::purgeCompleted()
3968{ 3973{
3969 int result = KMessageBox::warningContinueCancel(this, 3974 int result = KMessageBox::warningContinueCancel(this,
3970 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); 3975 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge"));
3971 3976
3972 if (result == KMessageBox::Continue) { 3977 if (result == KMessageBox::Continue) {
3973 3978
3974 QPtrList<Todo> todoCal; 3979 QPtrList<Todo> todoCal;
3975 QPtrList<Todo> rootTodos; 3980 QPtrList<Todo> rootTodos;
3976 //QPtrList<Incidence> rel; 3981 //QPtrList<Incidence> rel;
3977 Todo *aTodo;//, *rTodo; 3982 Todo *aTodo;//, *rTodo;
3978 Incidence *rIncidence; 3983 Incidence *rIncidence;
3979 bool childDelete = false; 3984 bool childDelete = false;
3980 bool deletedOne = true; 3985 bool deletedOne = true;
3981 todoCal = calendar()->todos(); 3986 todoCal = calendar()->todos();
3982 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { 3987 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
3983 if ( !aTodo->relatedTo() ) 3988 if ( !aTodo->relatedTo() )
3984 rootTodos.append( aTodo ); 3989 rootTodos.append( aTodo );
3985 } 3990 }
3986 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { 3991 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) {
3987 removeCompletedSubTodos( aTodo ); 3992 removeCompletedSubTodos( aTodo );
3988 } 3993 }
3989 3994
3990 updateView(); 3995 updateView();
3991 } 3996 }
3992} 3997}
3993 3998
3994void CalendarView::slotCalendarChanged() 3999void CalendarView::slotCalendarChanged()
3995{ 4000{
3996 ; 4001 ;
3997} 4002}
3998 4003
3999void CalendarView::keyPressEvent ( QKeyEvent *e) 4004void CalendarView::keyPressEvent ( QKeyEvent *e)
4000{ 4005{
4001 //qDebug(" alendarView::keyPressEvent "); 4006 //qDebug(" alendarView::keyPressEvent ");
4002 e->ignore(); 4007 e->ignore();
4003} 4008}
4004 4009
4005 4010
4006bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) 4011bool CalendarView::sync(KSyncManager* manager, QString filename, int mode)
4007{ 4012{
4008 // mSyncManager = manager; 4013 // mSyncManager = manager;
4009 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { 4014 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) {
4010 qDebug("KO: SyncKDE request detected!"); 4015 qDebug("KO: SyncKDE request detected!");
4011 } 4016 }
4012 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 4017 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
4013 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 4018 mCurrentSyncName = mSyncManager->getCurrentSyncName();
4014 return syncCalendar( filename, mode ); 4019 return syncCalendar( filename, mode );
4015} 4020}
4016bool CalendarView::syncExternal(KSyncManager* manager, QString resource) 4021bool CalendarView::syncExternal(KSyncManager* manager, QString resource)
4017{ 4022{
4018 //mSyncManager = manager; 4023 //mSyncManager = manager;
4019 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 4024 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
4020 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 4025 mCurrentSyncName = mSyncManager->getCurrentSyncName();
4021 if ( resource == "sharp" ) 4026 if ( resource == "sharp" )
4022 syncExternal( 0 ); 4027 syncExternal( 0 );
4023 if ( resource == "phone" ) 4028 if ( resource == "phone" )
4024 syncExternal( 1 ); 4029 syncExternal( 1 );
4025 // pending setmodified 4030 // pending setmodified
4026 return true; 4031 return true;
4027} 4032}
4028void CalendarView::setSyncManager(KSyncManager* manager) 4033void CalendarView::setSyncManager(KSyncManager* manager)
4029{ 4034{
4030 mSyncManager = manager; 4035 mSyncManager = manager;
4031} 4036}
4032 4037
4033void CalendarView::removeSyncInfo( QString syncProfile) 4038void CalendarView::removeSyncInfo( QString syncProfile)
4034{ 4039{
4035 qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); 4040 qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1());
4036 mCalendar->removeSyncInfo( syncProfile ); 4041 mCalendar->removeSyncInfo( syncProfile );
4037 4042
4038} 4043}
4039 4044
4040void CalendarView::undo_delete() 4045void CalendarView::undo_delete()
4041{ 4046{
4042 //qDebug("undo_delete() "); 4047 //qDebug("undo_delete() ");
4043 Incidence* undo = mCalendar->undoIncidence(); 4048 Incidence* undo = mCalendar->undoIncidence();
4044 if ( !undo ) { 4049 if ( !undo ) {
4045 KMessageBox::sorry(this,i18n("There is nothing to undo!"), 4050 KMessageBox::sorry(this,i18n("There is nothing to undo!"),
4046 i18n("KO/Pi")); 4051 i18n("KO/Pi"));
4047 return; 4052 return;
4048 } 4053 }
4049 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + 4054 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) +
4050 i18n("\nAre you sure you want\nto restore this?"), 4055 i18n("\nAre you sure you want\nto restore this?"),
4051 i18n("KO/Pi Confirmation"),i18n("Restore"))) { 4056 i18n("KO/Pi Confirmation"),i18n("Restore"))) {
4052 mCalendar->undoDeleteIncidence(); 4057 mCalendar->undoDeleteIncidence();
4053 updateView(); 4058 updateView();
4054 } 4059 }
4055} 4060}
4056 4061
4057void CalendarView::slotViewerClosed() 4062void CalendarView::slotViewerClosed()
4058{ 4063{
4059 QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); 4064 QTimer::singleShot( 50, this, SLOT ( resetFocus() ) );
4060} 4065}
4061 4066
4062void CalendarView::resetFocus() 4067void CalendarView::resetFocus()
4063{ 4068{
4064 if ( mViewerCallerIsSearchDialog ) { 4069 if ( mViewerCallerIsSearchDialog ) {
4065 if ( mDialogManager->getSearchDialog()->isVisible() ){ 4070 if ( mDialogManager->getSearchDialog()->isVisible() ){
4066 mDialogManager->getSearchDialog()->raise(); 4071 mDialogManager->getSearchDialog()->raise();
4067 mDialogManager->getSearchDialog()->setActiveWindow(); 4072 mDialogManager->getSearchDialog()->setActiveWindow();
4068 mDialogManager->getSearchDialog()->listview()->resetFocus(); 4073 mDialogManager->getSearchDialog()->listview()->resetFocus();
4069 } else 4074 } else
4070 mViewerCallerIsSearchDialog = false; 4075 mViewerCallerIsSearchDialog = false;
4071 } 4076 }
4072 if ( !mViewerCallerIsSearchDialog ) { 4077 if ( !mViewerCallerIsSearchDialog ) {
4073 //mViewManager->currentView()->setFocus(); 4078 //mViewManager->currentView()->setFocus();
4074 //qDebug("sssssssssssssssset focus "); 4079 //qDebug("sssssssssssssssset focus ");
4075 topLevelWidget()->raise(); 4080 topLevelWidget()->raise();
4076 setActiveWindow(); 4081 setActiveWindow();
4077 //setFocus(); 4082 //setFocus();
4078 } 4083 }
4079 mViewerCallerIsSearchDialog = false; 4084 mViewerCallerIsSearchDialog = false;
4080} 4085}
4081 4086
4082void CalendarView::showNextAlarms() 4087void CalendarView::showNextAlarms()
4083{ 4088{
4084 QString message; 4089 QString message;
4085 QDateTime nextAl = mCalendar->nextAlarmEventDateTime(); 4090 QDateTime nextAl = mCalendar->nextAlarmEventDateTime();
4086 if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) { 4091 if ( nextAl.isValid() && mNextAlarmDateTime > QDateTime::currentDateTime() ) {
4087 QString sum = mCalendar->nextSummary(); 4092 QString sum = mCalendar->nextSummary();
4088 QDateTime nextA = mNextAlarmDateTime; 4093 QDateTime nextA = mNextAlarmDateTime;
4089 QDateTime cur = QDateTime::currentDateTime(); 4094 QDateTime cur = QDateTime::currentDateTime();
4090 int secs = cur.secsTo( nextA ); 4095 int secs = cur.secsTo( nextA );
4091 int min = secs /60; 4096 int min = secs /60;
4092 int hours = min /60; 4097 int hours = min /60;
4093 min = min % 60; 4098 min = min % 60;
4094 int days = hours /24; 4099 int days = hours /24;
4095 hours = hours % 24; 4100 hours = hours % 24;
4096 4101
4097 message = i18n("The next alarm is in:\n"); 4102 //message = i18n("The next alarm is in:\n");
4098 if ( days > 1 ) 4103 if ( days > 1 )
4099 message += i18n("%1 days\n").arg( days ); 4104 message += i18n("%1 days\n").arg( days );
4100 else if ( days == 1 ) 4105 else if ( days == 1 )
4101 message += i18n("1 day\n"); 4106 message += i18n("1 day\n");
4102 if ( hours > 1 ) 4107 if ( hours > 1 )
4103 message += i18n("%1 hours\n").arg( hours ); 4108 message += i18n("%1 hours\n").arg( hours );
4104 else if ( hours == 1 ) 4109 else if ( hours == 1 )
4105 message += i18n("1 hour\n"); 4110 message += i18n("1 hour\n");
4106 if ( min > 1 ) 4111 if ( min > 1 )
4107 message += i18n("%1 minutes\n").arg( min ); 4112 message += i18n("%1 minutes\n").arg( min );
4108 else if ( min == 1 ) 4113 else if ( min == 1 )
4109 message += i18n("1 minute\n"); 4114 message += i18n("1 minute\n");
4110 4115 if ( message.isEmpty() )
4116 message = i18n("The next alarm is in\nless than one minute!");
4117 else
4118 message = i18n("The next alarm is in:\n") + message;
4111 message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ; 4119 message += i18n("\n(%1)\n\n%2\n(%3)\n").arg( KGlobal::locale()->formatDateTime(nextA , false)).arg(sum ).arg( KGlobal::locale()->formatDateTime(nextAl , false)) ;
4112 } else { 4120 } else {
4113 message = i18n("There is no next alarm."); 4121 message = i18n("There is no next alarm.");
4114 4122
4115 } 4123 }
4124#ifdef DESKTOP_VERSION
4125 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
4126 message += i18n("\nThe internal alarm notification is disabled!\n");
4127 message += i18n("Enable it in the settings menu, TAB alarm.");
4128 }
4129
4130#endif
4116 KMessageBox::information( this, message); 4131 KMessageBox::information( this, message);
4117} 4132}
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index d450a97..6d1e6d5 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -1,1623 +1,1623 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qhbox.h> 24#include <qhbox.h>
25#include <qvbox.h> 25#include <qvbox.h>
26#include <qlabel.h> 26#include <qlabel.h>
27#include <qframe.h> 27#include <qframe.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#ifndef KORG_NOSPLITTER 29#ifndef KORG_NOSPLITTER
30#include <qsplitter.h> 30#include <qsplitter.h>
31#endif 31#endif
32#include <qfont.h> 32#include <qfont.h>
33#include <qfontmetrics.h> 33#include <qfontmetrics.h>
34#include <qpopupmenu.h> 34#include <qpopupmenu.h>
35#include <qtooltip.h> 35#include <qtooltip.h>
36#include <qpainter.h> 36#include <qpainter.h>
37#include <qpushbutton.h> 37#include <qpushbutton.h>
38#include <qapplication.h> 38#include <qapplication.h>
39 39
40#include <kapplication.h> 40#include <kapplication.h>
41#include <KDGanttMinimizeSplitter.h> 41#include <KDGanttMinimizeSplitter.h>
42#include <kdebug.h> 42#include <kdebug.h>
43#include <kstandarddirs.h> 43#include <kstandarddirs.h>
44#include <kiconloader.h> 44#include <kiconloader.h>
45#include <klocale.h> 45#include <klocale.h>
46#include <kconfig.h> 46#include <kconfig.h>
47#include <kglobal.h> 47#include <kglobal.h>
48#include "calendarview.h" 48#include "calendarview.h"
49#include "koviewmanager.h" 49#include "koviewmanager.h"
50 50
51#include <libkcal/calendar.h> 51#include <libkcal/calendar.h>
52#include <libkcal/icaldrag.h> 52#include <libkcal/icaldrag.h>
53#include <libkcal/dndfactory.h> 53#include <libkcal/dndfactory.h>
54 54
55#include <kcalendarsystem.h> 55#include <kcalendarsystem.h>
56 56
57#include "koglobals.h" 57#include "koglobals.h"
58#ifndef KORG_NOPLUGINS 58#ifndef KORG_NOPLUGINS
59#include "kocore.h" 59#include "kocore.h"
60#endif 60#endif
61#include "koprefs.h" 61#include "koprefs.h"
62#include "koagenda.h" 62#include "koagenda.h"
63#include "koagendaitem.h" 63#include "koagendaitem.h"
64#ifndef KORG_NOPRINTER 64#ifndef KORG_NOPRINTER
65#include "calprinter.h" 65#include "calprinter.h"
66#endif 66#endif
67 67
68#include "koagendaview.h" 68#include "koagendaview.h"
69//#include "koagendaview.moc" 69//#include "koagendaview.moc"
70 70
71//extern bool globalFlagBlockPainting; 71//extern bool globalFlagBlockPainting;
72extern int globalFlagBlockAgenda; 72extern int globalFlagBlockAgenda;
73extern int globalFlagBlockStartup; 73extern int globalFlagBlockStartup;
74extern int globalFlagBlockAgendaItemPaint; 74extern int globalFlagBlockAgendaItemPaint;
75extern int globalFlagBlockAgendaItemUpdate; 75extern int globalFlagBlockAgendaItemUpdate;
76extern int globalFlagBlockLabel; 76extern int globalFlagBlockLabel;
77using namespace KOrg; 77using namespace KOrg;
78 78
79 79
80 80
81TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : 81TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) :
82 QScrollView(parent,name,f) 82 QScrollView(parent,name,f)
83{ 83{
84 myPix.resize( 1, 1 ); 84 myPix.resize( 1, 1 );
85 mRows = rows; 85 mRows = rows;
86 86
87 mRedrawNeeded = true; 87 mRedrawNeeded = true;
88 setMinimumHeight( 20 ); 88 setMinimumHeight( 20 );
89 mCellHeight = KOPrefs::instance()->mHourSize*4; 89 mCellHeight = KOPrefs::instance()->mHourSize*4;
90 90
91 enableClipper(true); 91 enableClipper(true);
92 92
93 setHScrollBarMode(AlwaysOff); 93 setHScrollBarMode(AlwaysOff);
94 setVScrollBarMode(AlwaysOff); 94 setVScrollBarMode(AlwaysOff);
95 95
96 resizeContents(50,mRows * mCellHeight); 96 resizeContents(50,mRows * mCellHeight);
97 97
98 viewport()->setBackgroundMode( PaletteBackground ); 98 viewport()->setBackgroundMode( PaletteBackground );
99} 99}
100 100
101void TimeLabels::setCellHeight(int height) 101void TimeLabels::setCellHeight(int height)
102{ 102{
103 mCellHeight = height; 103 mCellHeight = height;
104} 104}
105 105
106/* 106/*
107 Optimization so that only the "dirty" portion of the scroll view 107 Optimization so that only the "dirty" portion of the scroll view
108 is redrawn. Unfortunately, this is not called by default paintEvent() method. 108 is redrawn. Unfortunately, this is not called by default paintEvent() method.
109*/ 109*/
110void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) 110void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch)
111{ 111{
112 112
113 cx = contentsX() + frameWidth()*2; 113 cx = contentsX() + frameWidth()*2;
114 cw = contentsWidth() ; 114 cw = contentsWidth() ;
115 // end of workaround 115 // end of workaround
116 116
117 int cell = ((int)(cy/mCellHeight)); 117 int cell = ((int)(cy/mCellHeight));
118 int y = cell * mCellHeight; 118 int y = cell * mCellHeight;
119 QFontMetrics fm = fontMetrics(); 119 QFontMetrics fm = fontMetrics();
120 QString hour; 120 QString hour;
121 QString suffix = "am"; 121 QString suffix = "am";
122 int timeHeight = fm.ascent(); 122 int timeHeight = fm.ascent();
123 QFont nFont = font(); 123 QFont nFont = font();
124 p->setFont( font()); 124 p->setFont( font());
125 125
126 if (!KGlobal::locale()->use12Clock()) { 126 if (!KGlobal::locale()->use12Clock()) {
127 suffix = "00"; 127 suffix = "00";
128 } else 128 } else
129 if (cell > 11) suffix = "pm"; 129 if (cell > 11) suffix = "pm";
130 130
131 if ( timeHeight > mCellHeight ) { 131 if ( timeHeight > mCellHeight ) {
132 timeHeight = mCellHeight-1; 132 timeHeight = mCellHeight-1;
133 int pointS = nFont.pointSize(); 133 int pointS = nFont.pointSize();
134 while ( pointS > 4 ) { 134 while ( pointS > 4 ) {
135 nFont.setPointSize( pointS ); 135 nFont.setPointSize( pointS );
136 fm = QFontMetrics( nFont ); 136 fm = QFontMetrics( nFont );
137 if ( fm.ascent() < mCellHeight ) 137 if ( fm.ascent() < mCellHeight )
138 break; 138 break;
139 -- pointS; 139 -- pointS;
140 } 140 }
141 fm = QFontMetrics( nFont ); 141 fm = QFontMetrics( nFont );
142 timeHeight = fm.ascent(); 142 timeHeight = fm.ascent();
143 } 143 }
144 //timeHeight -= (timeHeight/4-2); 144 //timeHeight -= (timeHeight/4-2);
145 QFont sFont = nFont; 145 QFont sFont = nFont;
146 sFont.setPointSize( sFont.pointSize()/2 ); 146 sFont.setPointSize( sFont.pointSize()/2 );
147 QFontMetrics fmS( sFont ); 147 QFontMetrics fmS( sFont );
148 int sHei = fmS.ascent() ; 148 int sHei = fmS.ascent() ;
149 //sHei -= (sHei/4-2); 149 //sHei -= (sHei/4-2);
150 int startW = mMiniWidth - frameWidth()-2 ; 150 int startW = mMiniWidth - frameWidth()-2 ;
151 int tw2 = fmS.width(suffix); 151 int tw2 = fmS.width(suffix);
152 timeHeight = (timeHeight-1) /2 -1; 152 timeHeight = (timeHeight-1) /2 -1;
153 //testline 153 //testline
154 //p->drawLine(0,0,0,contentsHeight()); 154 //p->drawLine(0,0,0,contentsHeight());
155 while (y < cy + ch+mCellHeight) { 155 while (y < cy + ch+mCellHeight) {
156 p->drawLine(startW-tw2 ,y,cw+2,y); 156 p->drawLine(startW-tw2+1 ,y,cw+2,y);
157 hour.setNum(cell); 157 hour.setNum(cell);
158 // handle 24h and am/pm time formats 158 // handle 24h and am/pm time formats
159 if (KGlobal::locale()->use12Clock()) { 159 if (KGlobal::locale()->use12Clock()) {
160 if (cell == 12) suffix = "pm"; 160 if (cell == 12) suffix = "pm";
161 if (cell == 0) hour.setNum(12); 161 if (cell == 0) hour.setNum(12);
162 if (cell > 12) hour.setNum(cell - 12); 162 if (cell > 12) hour.setNum(cell - 12);
163 } 163 }
164 164
165 // center and draw the time label 165 // center and draw the time label
166 int timeWidth = fm.width(hour); 166 int timeWidth = fm.width(hour);
167 int offset = startW - timeWidth - tw2 -1 ; 167 int offset = startW - timeWidth - tw2 -1 ;
168 p->setFont( nFont ); 168 p->setFont( nFont );
169 p->drawText( offset, y+ timeHeight, hour); 169 p->drawText( offset, y+ timeHeight, hour);
170 p->setFont( sFont ); 170 p->setFont( sFont );
171 offset = startW - tw2; 171 offset = startW - tw2;
172 p->drawText( offset, y -1, suffix); 172 p->drawText( offset, y -1, suffix);
173 173
174 // increment indices 174 // increment indices
175 y += mCellHeight; 175 y += mCellHeight;
176 cell++; 176 cell++;
177 } 177 }
178 178
179 179
180 180
181 181
182} 182}
183 183
184/** 184/**
185 Calculates the minimum width. 185 Calculates the minimum width.
186*/ 186*/
187int TimeLabels::minimumWidth() const 187int TimeLabels::minimumWidth() const
188{ 188{
189 return mMiniWidth; 189 return mMiniWidth;
190} 190}
191 191
192/** updates widget's internal state */ 192/** updates widget's internal state */
193void TimeLabels::updateConfig() 193void TimeLabels::updateConfig()
194{ 194{
195 mRedrawNeeded = true; 195 mRedrawNeeded = true;
196 // set the font 196 // set the font
197 // config->setGroup("Fonts"); 197 // config->setGroup("Fonts");
198 // QFont font = config->readFontEntry("TimeBar Font"); 198 // QFont font = config->readFontEntry("TimeBar Font");
199 setFont(KOPrefs::instance()->mTimeBarFont); 199 setFont(KOPrefs::instance()->mTimeBarFont);
200 QString test = "20"; 200 QString test = "20";
201 if (KGlobal::locale()->use12Clock()) 201 if (KGlobal::locale()->use12Clock())
202 test = "12"; 202 test = "12";
203 mMiniWidth = fontMetrics().width(test); 203 mMiniWidth = fontMetrics().width(test);
204 if (KGlobal::locale()->use12Clock()) 204 if (KGlobal::locale()->use12Clock())
205 test = "pm"; 205 test = "pm";
206 else { 206 else {
207 test = "00"; 207 test = "00";
208 } 208 }
209 QFont sFont = font(); 209 QFont sFont = font();
210 sFont.setPointSize( sFont.pointSize()/2 ); 210 sFont.setPointSize( sFont.pointSize()/2 );
211 QFontMetrics fmS( sFont ); 211 QFontMetrics fmS( sFont );
212 mMiniWidth += fmS.width( test ) + frameWidth()*2+4 ; 212 mMiniWidth += fmS.width( test ) + frameWidth()*2+4 ;
213 // update geometry restrictions based on new settings 213 // update geometry restrictions based on new settings
214 setFixedWidth( mMiniWidth ); 214 setFixedWidth( mMiniWidth );
215 215
216 // update HourSize 216 // update HourSize
217 mCellHeight = KOPrefs::instance()->mHourSize*4; 217 mCellHeight = KOPrefs::instance()->mHourSize*4;
218 resizeContents(50,mRows * mCellHeight); 218 resizeContents(mMiniWidth,mRows * mCellHeight+1);
219} 219}
220 220
221/** update time label positions */ 221/** update time label positions */
222void TimeLabels::positionChanged() 222void TimeLabels::positionChanged()
223{ 223{
224 int adjustment = mAgenda->contentsY(); 224 int adjustment = mAgenda->contentsY();
225 setContentsPos(0, adjustment); 225 setContentsPos(0, adjustment);
226} 226}
227 227
228/** */ 228/** */
229void TimeLabels::setAgenda(KOAgenda* agenda) 229void TimeLabels::setAgenda(KOAgenda* agenda)
230{ 230{
231 mAgenda = agenda; 231 mAgenda = agenda;
232} 232}
233 233
234void TimeLabels::contentsMousePressEvent ( QMouseEvent * e) 234void TimeLabels::contentsMousePressEvent ( QMouseEvent * e)
235{ 235{
236 mMouseDownY = e->pos().y(); 236 mMouseDownY = e->pos().y();
237 mOrgCap = topLevelWidget()->caption(); 237 mOrgCap = topLevelWidget()->caption();
238} 238}
239 239
240void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e ) 240void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e )
241{ 241{
242 int diff = mMouseDownY - e->pos().y(); 242 int diff = mMouseDownY - e->pos().y();
243 if ( diff < 10 && diff > -10 ) 243 if ( diff < 10 && diff > -10 )
244 return; 244 return;
245 int tSize = KOPrefs::instance()->mHourSize + (diff/10) ; 245 int tSize = KOPrefs::instance()->mHourSize + (diff/10) ;
246 if ( tSize < 4 ) 246 if ( tSize < 4 )
247 tSize = 4; 247 tSize = 4;
248 if ( tSize > 22 ) 248 if ( tSize > 22 )
249 tSize = 22; 249 tSize = 22;
250 tSize = (tSize-2)/2; 250 tSize = (tSize-2)/2;
251 topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize)); 251 topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize));
252 252
253} 253}
254void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e ) 254void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e )
255{ 255{
256 topLevelWidget()->setCaption( mOrgCap ); 256 topLevelWidget()->setCaption( mOrgCap );
257 int diff = mMouseDownY - e->pos().y(); 257 int diff = mMouseDownY - e->pos().y();
258 if ( diff < 10 && diff > -10 ) 258 if ( diff < 10 && diff > -10 )
259 return; 259 return;
260 int tSize = KOPrefs::instance()->mHourSize + (diff/10); 260 int tSize = KOPrefs::instance()->mHourSize + (diff/10);
261 if ( tSize < 4 ) 261 if ( tSize < 4 )
262 tSize = 4; 262 tSize = 4;
263 if ( tSize > 22 ) 263 if ( tSize > 22 )
264 tSize = 22; 264 tSize = 22;
265 tSize = (tSize/2)*2; 265 tSize = (tSize/2)*2;
266 if ( tSize == KOPrefs::instance()->mHourSize ) 266 if ( tSize == KOPrefs::instance()->mHourSize )
267 return; 267 return;
268 KOPrefs::instance()->mHourSize = tSize; 268 KOPrefs::instance()->mHourSize = tSize;
269 emit scaleChanged(); 269 emit scaleChanged();
270} 270}
271 271
272/** This is called in response to repaint() */ 272/** This is called in response to repaint() */
273void TimeLabels::paintEvent(QPaintEvent*) 273void TimeLabels::paintEvent(QPaintEvent*)
274{ 274{
275 275
276 // kdDebug() << "paintevent..." << endl; 276 // kdDebug() << "paintevent..." << endl;
277 // this is another hack! 277 // this is another hack!
278 // QPainter painter(this); 278 // QPainter painter(this);
279 //QString c 279 //QString c
280 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight()); 280 repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight());
281} 281}
282 282
283//////////////////////////////////////////////////////////////////////////// 283////////////////////////////////////////////////////////////////////////////
284 284
285EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name) 285EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name)
286 : QFrame(parent,name) 286 : QFrame(parent,name)
287{ 287{
288 mColumns = 1; 288 mColumns = 1;
289 mTopBox = 0; 289 mTopBox = 0;
290 mLocation = loc; 290 mLocation = loc;
291 mTopLayout = 0; 291 mTopLayout = 0;
292 mPaintWidget = 0; 292 mPaintWidget = 0;
293 mXOffset = 0; 293 mXOffset = 0;
294 if (mLocation == Top) mPixmap = SmallIcon("1uparrow"); 294 if (mLocation == Top) mPixmap = SmallIcon("1uparrow");
295 else mPixmap = SmallIcon("1downarrow"); 295 else mPixmap = SmallIcon("1downarrow");
296 mEnabled.resize(mColumns); 296 mEnabled.resize(mColumns);
297 mEnabled.fill( false ); 297 mEnabled.fill( false );
298 setMinimumHeight(mPixmap.height()); 298 setMinimumHeight(mPixmap.height());
299} 299}
300 300
301EventIndicator::~EventIndicator() 301EventIndicator::~EventIndicator()
302{ 302{
303} 303}
304 304
305void EventIndicator::drawContents(QPainter *p) 305void EventIndicator::drawContents(QPainter *p)
306{ 306{
307 307
308 // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl; 308 // kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl;
309 KDGanttSplitterHandle* han = 0; 309 KDGanttSplitterHandle* han = 0;
310 if ( mPaintWidget ) 310 if ( mPaintWidget )
311 han = mPaintWidget->firstHandle(); 311 han = mPaintWidget->firstHandle();
312 if ( ! han ) { 312 if ( ! han ) {
313 int i; 313 int i;
314 for(i=0;i<mColumns;++i) { 314 for(i=0;i<mColumns;++i) {
315 if (mEnabled[i]) { 315 if (mEnabled[i]) {
316 int cellWidth = contentsRect().right()/mColumns; 316 int cellWidth = contentsRect().right()/mColumns;
317 int xOffset = KOGlobals::self()->reverseLayout() ? 317 int xOffset = KOGlobals::self()->reverseLayout() ?
318 (mColumns - 1 - i)*cellWidth + (cellWidth -mPixmap.width())/2 : 318 (mColumns - 1 - i)*cellWidth + (cellWidth -mPixmap.width())/2 :
319 i*cellWidth + (cellWidth -mPixmap.width()) /2; 319 i*cellWidth + (cellWidth -mPixmap.width()) /2;
320 p->drawPixmap(QPoint(1+xOffset,0),mPixmap); 320 p->drawPixmap(QPoint(1+xOffset,0),mPixmap);
321 } 321 }
322 } 322 }
323 } else { 323 } else {
324 han->repaint(); 324 han->repaint();
325 //mPaintWidget->setBackgroundColor( red ); 325 //mPaintWidget->setBackgroundColor( red );
326 326
327 QPainter pa( han ); 327 QPainter pa( han );
328 int i; 328 int i;
329 bool setColor = false; 329 bool setColor = false;
330 for(i=0;i<mColumns;++i) { 330 for(i=0;i<mColumns;++i) {
331 if (mEnabled[i]) { 331 if (mEnabled[i]) {
332 setColor = true; 332 setColor = true;
333 333
334 int cellWidth = contentsRect().right()/mColumns; 334 int cellWidth = contentsRect().right()/mColumns;
335 int xOffset = KOGlobals::self()->reverseLayout() ? 335 int xOffset = KOGlobals::self()->reverseLayout() ?
336 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 : 336 (mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 :
337 i*cellWidth + cellWidth/2 -mPixmap.width()/2; 337 i*cellWidth + cellWidth/2 -mPixmap.width()/2;
338 pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap); 338 pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap);
339 //qDebug("222draw pix %d ",xOffset ); 339 //qDebug("222draw pix %d ",xOffset );
340 340
341 } 341 }
342 342
343 } 343 }
344 pa.end(); 344 pa.end();
345 345
346 } 346 }
347} 347}
348 348
349void EventIndicator::setXOffset( int x ) 349void EventIndicator::setXOffset( int x )
350{ 350{
351 mXOffset = x; 351 mXOffset = x;
352} 352}
353void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w ) 353void EventIndicator::setPaintWidget( KDGanttMinimizeSplitter * w )
354{ 354{
355 mPaintWidget = w; 355 mPaintWidget = w;
356 setMaximumHeight(0); 356 setMaximumHeight(0);
357 setMinimumHeight(0); 357 setMinimumHeight(0);
358} 358}
359void EventIndicator::changeColumns(int columns) 359void EventIndicator::changeColumns(int columns)
360{ 360{
361 mColumns = columns; 361 mColumns = columns;
362 mEnabled.resize(mColumns); 362 mEnabled.resize(mColumns);
363 363
364 update(); 364 update();
365} 365}
366 366
367void EventIndicator::enableColumn(int column, bool enable) 367void EventIndicator::enableColumn(int column, bool enable)
368{ 368{
369 mEnabled[column] = enable; 369 mEnabled[column] = enable;
370} 370}
371 371
372 372
373//////////////////////////////////////////////////////////////////////////// 373////////////////////////////////////////////////////////////////////////////
374//////////////////////////////////////////////////////////////////////////// 374////////////////////////////////////////////////////////////////////////////
375//////////////////////////////////////////////////////////////////////////// 375////////////////////////////////////////////////////////////////////////////
376 376
377KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) : 377KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
378 KOEventView (cal,parent,name) 378 KOEventView (cal,parent,name)
379{ 379{
380 mBlockUpdating = true; 380 mBlockUpdating = true;
381 mStartHour = 8; 381 mStartHour = 8;
382 mSelectedDates.append(QDate::currentDate()); 382 mSelectedDates.append(QDate::currentDate());
383 383
384 mLayoutDayLabels = 0; 384 mLayoutDayLabels = 0;
385 mDayLabelsFrame = 0; 385 mDayLabelsFrame = 0;
386 mDayLabels = 0; 386 mDayLabels = 0;
387 bool isRTL = KOGlobals::self()->reverseLayout(); 387 bool isRTL = KOGlobals::self()->reverseLayout();
388 QPixmap expandPix; 388 QPixmap expandPix;
389 if ( KOPrefs::instance()->mVerticalScreen ) { 389 if ( KOPrefs::instance()->mVerticalScreen ) {
390 expandPix = SmallIcon( "1updownarrow" ); 390 expandPix = SmallIcon( "1updownarrow" );
391 } else { 391 } else {
392 expandPix = SmallIcon("1leftrightarrow" ); 392 expandPix = SmallIcon("1leftrightarrow" );
393 } 393 }
394 394
395 QBoxLayout *topLayout = new QVBoxLayout(this); 395 QBoxLayout *topLayout = new QVBoxLayout(this);
396 396
397 // Create day name labels for agenda columns 397 // Create day name labels for agenda columns
398 // Create agenda splitter 398 // Create agenda splitter
399 399
400 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this); 400 mSplitterAgenda = new KDGanttMinimizeSplitter( Qt::Vertical, this);
401 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 401 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
402 topLayout->addWidget( mSplitterAgenda ); 402 topLayout->addWidget( mSplitterAgenda );
403 mAllDayFrame = new QHBox(mSplitterAgenda); 403 mAllDayFrame = new QHBox(mSplitterAgenda);
404 mAllDayFrame->setFocusPolicy(NoFocus); 404 mAllDayFrame->setFocusPolicy(NoFocus);
405 QWidget *agendaFrame = new QWidget(mSplitterAgenda); 405 QWidget *agendaFrame = new QWidget(mSplitterAgenda);
406 agendaFrame->setFocusPolicy(NoFocus); 406 agendaFrame->setFocusPolicy(NoFocus);
407 407
408 // Create all-day agenda widget 408 // Create all-day agenda widget
409 mDummyAllDayLeft = new QVBox( mAllDayFrame ); 409 mDummyAllDayLeft = new QVBox( mAllDayFrame );
410 410
411 mExpandButton = new QPushButton(mDummyAllDayLeft); 411 mExpandButton = new QPushButton(mDummyAllDayLeft);
412 mExpandButton->setPixmap( expandPix ); 412 mExpandButton->setPixmap( expandPix );
413 int widebut = mExpandButton->sizeHint().width()+4; 413 int widebut = mExpandButton->sizeHint().width()+4;
414 int heibut = mExpandButton->sizeHint().height()+4; 414 int heibut = mExpandButton->sizeHint().height()+4;
415 if ( heibut > widebut ) 415 if ( heibut > widebut )
416 widebut = heibut ; 416 widebut = heibut ;
417 417
418 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, 418 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed,
419 // QSizePolicy::Fixed ) ); 419 // QSizePolicy::Fixed ) );
420 mExpandButton->setFixedSize( widebut, widebut); 420 mExpandButton->setFixedSize( widebut, widebut);
421 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); 421 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) );
422 mExpandButton->setFocusPolicy(NoFocus); 422 mExpandButton->setFocusPolicy(NoFocus);
423 mAllDayAgenda = new KOAgenda(1,mAllDayFrame); 423 mAllDayAgenda = new KOAgenda(1,mAllDayFrame);
424 mAllDayAgenda->setFocusPolicy(NoFocus); 424 mAllDayAgenda->setFocusPolicy(NoFocus);
425 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); 425 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame);
426 426
427 // Create event context menu for all day agenda 427 // Create event context menu for all day agenda
428 //mAllDayAgendaPopup = eventPopup(); 428 //mAllDayAgendaPopup = eventPopup();
429 429
430 // Create agenda frame 430 // Create agenda frame
431 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3); 431 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3);
432 // QHBox *agendaFrame = new QHBox(splitterAgenda); 432 // QHBox *agendaFrame = new QHBox(splitterAgenda);
433 433
434 // create event indicator bars 434 // create event indicator bars
435 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); 435 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame);
436#ifndef DESKTOP_VERSION 436#ifndef DESKTOP_VERSION
437 // FIX 437 // FIX
438 mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); 438 mEventIndicatorTop->setPaintWidget( mSplitterAgenda );
439#endif 439#endif
440 mDayLabelsFrame = new QHBox(agendaFrame); 440 mDayLabelsFrame = new QHBox(agendaFrame);
441 //topLayout->addWidget(mDayLabelsFrame); 441 //topLayout->addWidget(mDayLabelsFrame);
442 mDayLabels = new QFrame (mDayLabelsFrame); 442 mDayLabels = new QFrame (mDayLabelsFrame);
443 mLayoutDayLabels = new QHBoxLayout(mDayLabels); 443 mLayoutDayLabels = new QHBoxLayout(mDayLabels);
444 agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2); 444 agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2);
445 agendaLayout->addWidget(mEventIndicatorTop,1,1); 445 agendaLayout->addWidget(mEventIndicatorTop,1,1);
446 446
447 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, 447 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom,
448 agendaFrame); 448 agendaFrame);
449 agendaLayout->addWidget(mEventIndicatorBottom,3,1); 449 agendaLayout->addWidget(mEventIndicatorBottom,3,1);
450 QWidget *dummyAgendaRight = new QWidget(agendaFrame); 450 QWidget *dummyAgendaRight = new QWidget(agendaFrame);
451 agendaLayout->addWidget(dummyAgendaRight,1,2); 451 agendaLayout->addWidget(dummyAgendaRight,1,2);
452 452
453 // Create time labels 453 // Create time labels
454 mTimeLabels = new TimeLabels(24,agendaFrame); 454 mTimeLabels = new TimeLabels(24,agendaFrame);
455 agendaLayout->addWidget(mTimeLabels,2,0); 455 agendaLayout->addWidget(mTimeLabels,2,0);
456 connect(mTimeLabels,SIGNAL( scaleChanged()), 456 connect(mTimeLabels,SIGNAL( scaleChanged()),
457 this,SLOT(updateConfig())); 457 this,SLOT(updateConfig()));
458 458
459 // Create agenda 459 // Create agenda
460 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); 460 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame);
461 agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2); 461 agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2);
462 agendaLayout->setColStretch(1,1); 462 agendaLayout->setColStretch(1,1);
463 mAgenda->setFocusPolicy(NoFocus); 463 mAgenda->setFocusPolicy(NoFocus);
464 // Create event context menu for agenda 464 // Create event context menu for agenda
465 mAllAgendaPopup = eventPopup(); 465 mAllAgendaPopup = eventPopup();
466 466
467 mAllAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), 467 mAllAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")),
468 i18n("Toggle Alarm"),mAgenda, 468 i18n("Toggle Alarm"),mAgenda,
469 SLOT(popupAlarm()),true); 469 SLOT(popupAlarm()),true);
470 470
471 471
472 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 472 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
473 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 473 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
474 474
475 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 475 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
476 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 476 mAllAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
477 mAgenda->setPopup( mAllAgendaPopup ); 477 mAgenda->setPopup( mAllAgendaPopup );
478 mAllDayAgenda->setPopup( mAllAgendaPopup ); 478 mAllDayAgenda->setPopup( mAllAgendaPopup );
479 // make connections between dependent widgets 479 // make connections between dependent widgets
480 mTimeLabels->setAgenda(mAgenda); 480 mTimeLabels->setAgenda(mAgenda);
481 481
482 // Update widgets to reflect user preferences 482 // Update widgets to reflect user preferences
483 // updateConfig(); 483 // updateConfig();
484 484
485 // createDayLabels(); 485 // createDayLabels();
486 486
487 // these blank widgets make the All Day Event box line up with the agenda 487 // these blank widgets make the All Day Event box line up with the agenda
488 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 488 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
489 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 489 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
490 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 490 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
491 491
492 // Scrolling 492 // Scrolling
493 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), 493 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)),
494 mTimeLabels, SLOT(positionChanged())); 494 mTimeLabels, SLOT(positionChanged()));
495 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), 495 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)),
496 SLOT(setContentsPos(int))); 496 SLOT(setContentsPos(int)));
497 497
498 connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int ))); 498 connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int )));
499 connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) )); 499 connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) ));
500 500
501 // Create/Show/Edit/Delete Event 501 // Create/Show/Edit/Delete Event
502 connect(mAgenda,SIGNAL(newEventSignal(int,int)), 502 connect(mAgenda,SIGNAL(newEventSignal(int,int)),
503 SLOT(newEvent(int,int))); 503 SLOT(newEvent(int,int)));
504 connect(mAgenda,SIGNAL(newTodoSignal(int,int)), 504 connect(mAgenda,SIGNAL(newTodoSignal(int,int)),
505 SLOT(newTodo(int,int))); 505 SLOT(newTodo(int,int)));
506 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), 506 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)),
507 SLOT(newEvent(int,int,int,int))); 507 SLOT(newEvent(int,int,int,int)));
508 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), 508 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)),
509 SLOT(newEventAllDay(int,int))); 509 SLOT(newEventAllDay(int,int)));
510 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), 510 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)),
511 SLOT(newTodoAllDay(int,int))); 511 SLOT(newTodoAllDay(int,int)));
512 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), 512 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)),
513 SLOT(newEventAllDay(int,int))); 513 SLOT(newEventAllDay(int,int)));
514 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 514 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
515 SLOT(newTimeSpanSelected(int,int,int,int))); 515 SLOT(newTimeSpanSelected(int,int,int,int)));
516 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 516 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
517 SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); 517 SLOT(newTimeSpanSelectedAllDay(int,int,int,int)));
518 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 518 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
519 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 519 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
520 520
521 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 521 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
522 SIGNAL(editIncidenceSignal(Incidence *))); 522 SIGNAL(editIncidenceSignal(Incidence *)));
523 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 523 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
524 SIGNAL(editIncidenceSignal(Incidence *))); 524 SIGNAL(editIncidenceSignal(Incidence *)));
525 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 525 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
526 SIGNAL(showIncidenceSignal(Incidence *))); 526 SIGNAL(showIncidenceSignal(Incidence *)));
527 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 527 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
528 SIGNAL(showIncidenceSignal(Incidence *))); 528 SIGNAL(showIncidenceSignal(Incidence *)));
529 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 529 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
530 SIGNAL(deleteIncidenceSignal(Incidence *))); 530 SIGNAL(deleteIncidenceSignal(Incidence *)));
531 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 531 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
532 SIGNAL(deleteIncidenceSignal(Incidence *))); 532 SIGNAL(deleteIncidenceSignal(Incidence *)));
533 533
534 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 534 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
535 SLOT(updateEventDates(KOAgendaItem *, int ))); 535 SLOT(updateEventDates(KOAgendaItem *, int )));
536 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 536 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
537 SLOT(updateEventDates(KOAgendaItem *, int))); 537 SLOT(updateEventDates(KOAgendaItem *, int)));
538 538
539 // event indicator update 539 // event indicator update
540 connect(mAgenda,SIGNAL(lowerYChanged(int)), 540 connect(mAgenda,SIGNAL(lowerYChanged(int)),
541 SLOT(updateEventIndicatorTop(int))); 541 SLOT(updateEventIndicatorTop(int)));
542 connect(mAgenda,SIGNAL(upperYChanged(int)), 542 connect(mAgenda,SIGNAL(upperYChanged(int)),
543 SLOT(updateEventIndicatorBottom(int))); 543 SLOT(updateEventIndicatorBottom(int)));
544 // drag signals 544 // drag signals
545 /* 545 /*
546 connect(mAgenda,SIGNAL(startDragSignal(Event *)), 546 connect(mAgenda,SIGNAL(startDragSignal(Event *)),
547 SLOT(startDrag(Event *))); 547 SLOT(startDrag(Event *)));
548 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), 548 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)),
549 SLOT(startDrag(Event *))); 549 SLOT(startDrag(Event *)));
550 */ 550 */
551 // synchronize selections 551 // synchronize selections
552 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 552 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
553 mAllDayAgenda, SLOT( deselectItem() ) ); 553 mAllDayAgenda, SLOT( deselectItem() ) );
554 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 554 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
555 mAgenda, SLOT( deselectItem() ) ); 555 mAgenda, SLOT( deselectItem() ) );
556 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 556 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
557 SIGNAL( incidenceSelected( Incidence * ) ) ); 557 SIGNAL( incidenceSelected( Incidence * ) ) );
558 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 558 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
559 SIGNAL( incidenceSelected( Incidence * ) ) ); 559 SIGNAL( incidenceSelected( Incidence * ) ) );
560 connect( mAgenda, SIGNAL( resizedSignal() ), 560 connect( mAgenda, SIGNAL( resizedSignal() ),
561 SLOT( updateConfig( ) ) ); 561 SLOT( updateConfig( ) ) );
562 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), 562 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ),
563 SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); 563 SLOT( addToCalSlot(Incidence *, Incidence * ) ) );
564 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), 564 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ),
565 SLOT( addToCalSlot(Incidence * , Incidence *) ) ); 565 SLOT( addToCalSlot(Incidence * , Incidence *) ) );
566 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 566 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
567 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 567 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
568 568
569 569
570} 570}
571 571
572void KOAgendaView::toggleAllDay() 572void KOAgendaView::toggleAllDay()
573{ 573{
574 if ( mSplitterAgenda->firstHandle() ) 574 if ( mSplitterAgenda->firstHandle() )
575 mSplitterAgenda->firstHandle()->toggle(); 575 mSplitterAgenda->firstHandle()->toggle();
576} 576}
577void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) 577void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld )
578{ 578{
579 calendar()->addIncidence( inc ); 579 calendar()->addIncidence( inc );
580 580
581 if ( incOld ) { 581 if ( incOld ) {
582 if ( incOld->type() == "Todo" ) 582 if ( incOld->type() == "Todo" )
583 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); 583 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED );
584 else 584 else
585 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); 585 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED);
586 } 586 }
587 587
588} 588}
589 589
590KOAgendaView::~KOAgendaView() 590KOAgendaView::~KOAgendaView()
591{ 591{
592 delete mAllAgendaPopup; 592 delete mAllAgendaPopup;
593 //delete mAllDayAgendaPopup; 593 //delete mAllDayAgendaPopup;
594 delete KOAgendaItem::paintPix(); 594 delete KOAgendaItem::paintPix();
595 delete KOAgendaItem::paintPixSel(); 595 delete KOAgendaItem::paintPixSel();
596} 596}
597void KOAgendaView::resizeEvent( QResizeEvent* e ) 597void KOAgendaView::resizeEvent( QResizeEvent* e )
598{ 598{
599 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); 599 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width());
600 bool uc = false; 600 bool uc = false;
601 int ow = e->oldSize().width(); 601 int ow = e->oldSize().width();
602 int oh = e->oldSize().height(); 602 int oh = e->oldSize().height();
603 int w = e->size().width(); 603 int w = e->size().width();
604 int h = e->size().height(); 604 int h = e->size().height();
605 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { 605 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) {
606 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) 606 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda )
607 uc = true; 607 uc = true;
608 //qDebug("view changed %d %d %d %d ", ow, oh , w , h); 608 //qDebug("view changed %d %d %d %d ", ow, oh , w , h);
609 } 609 }
610 mUpcomingWidth = e->size().width() ; 610 mUpcomingWidth = e->size().width() ;
611 if ( mBlockUpdating || uc ) { 611 if ( mBlockUpdating || uc ) {
612 mBlockUpdating = false; 612 mBlockUpdating = false;
613 //mAgenda->setMinimumSize(800 , 600 ); 613 //mAgenda->setMinimumSize(800 , 600 );
614 //qDebug("mAgenda->resize+++++++++++++++ "); 614 //qDebug("mAgenda->resize+++++++++++++++ ");
615 updateConfig(); 615 updateConfig();
616 //qDebug("KOAgendaView::Updating now possible "); 616 //qDebug("KOAgendaView::Updating now possible ");
617 } else 617 } else
618 createDayLabels(); 618 createDayLabels();
619 //qDebug("resizeEvent end "); 619 //qDebug("resizeEvent end ");
620 620
621} 621}
622void KOAgendaView::slotDaylabelClicked( int num ) 622void KOAgendaView::slotDaylabelClicked( int num )
623{ 623{
624 624
625 QDate firstDate = mSelectedDates.first(); 625 QDate firstDate = mSelectedDates.first();
626 if ( num == -1 ) 626 if ( num == -1 )
627 emit showDateView( 6, firstDate ); 627 emit showDateView( 6, firstDate );
628 else if (num >= 0 ) { 628 else if (num >= 0 ) {
629 if ( mSelectedDates.count() == 1) 629 if ( mSelectedDates.count() == 1)
630 emit showDateView( 9, firstDate.addDays( num ) ); 630 emit showDateView( 9, firstDate.addDays( num ) );
631 else 631 else
632 emit showDateView( 3, firstDate.addDays( num ) ); 632 emit showDateView( 3, firstDate.addDays( num ) );
633 } 633 }
634 else 634 else
635 showDateView( 10, firstDate.addDays(1) ); 635 showDateView( 10, firstDate.addDays(1) );
636} 636}
637 637
638KOAgendaButton* KOAgendaView::getNewDaylabel() 638KOAgendaButton* KOAgendaView::getNewDaylabel()
639{ 639{
640 640
641 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels); 641 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels);
642 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) ); 642 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) );
643 mDayLabelsList.append( dayLabel ); 643 mDayLabelsList.append( dayLabel );
644 mLayoutDayLabels->addWidget(dayLabel); 644 mLayoutDayLabels->addWidget(dayLabel);
645 return dayLabel ; 645 return dayLabel ;
646} 646}
647 647
648void KOAgendaView::createDayLabels() 648void KOAgendaView::createDayLabels()
649{ 649{
650 650
651 if ( mBlockUpdating || globalFlagBlockLabel == 1) { 651 if ( mBlockUpdating || globalFlagBlockLabel == 1) {
652 // qDebug(" KOAgendaView::createDayLabels() blocked "); 652 // qDebug(" KOAgendaView::createDayLabels() blocked ");
653 return; 653 return;
654 654
655 } 655 }
656 int newHight; 656 int newHight;
657 if ( !mSelectedDates.count()) 657 if ( !mSelectedDates.count())
658 return; 658 return;
659 659
660 // ### Before deleting and recreating we could check if mSelectedDates changed... 660 // ### Before deleting and recreating we could check if mSelectedDates changed...
661 // It would remove some flickering and gain speed (since this is called by 661 // It would remove some flickering and gain speed (since this is called by
662 // each updateView() call) 662 // each updateView() call)
663 663
664 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2; 664 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - mAgenda->frameWidth()*2;
665 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); 665 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth );
666 if ( maxWid < 20 ) 666 if ( maxWid < 20 )
667 maxWid = 20; 667 maxWid = 20;
668 668
669 QFont dlf = KOPrefs::instance()->mTimeLabelsFont; 669 QFont dlf = KOPrefs::instance()->mTimeLabelsFont;
670 QFontMetrics fm ( dlf ); 670 QFontMetrics fm ( dlf );
671 int selCount = mSelectedDates.count(); 671 int selCount = mSelectedDates.count();
672 int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1; 672 int widModulo = maxWid - (mAgenda->gridSpacingX() * selCount)+1;
673 QString dayTest = "Mon 20"; 673 QString dayTest = "Mon 20";
674 //QString dayTest = "Mon 20"; 674 //QString dayTest = "Mon 20";
675 int wid = fm.width( dayTest ); 675 int wid = fm.width( dayTest );
676 //maxWid -= ( selCount * 3 ); //working for QLabels 676 //maxWid -= ( selCount * 3 ); //working for QLabels
677 if ( QApplication::desktop()->width() <= 320 ) 677 if ( QApplication::desktop()->width() <= 320 )
678 maxWid -= ( selCount * 3 ); //working for QPushButton 678 maxWid -= ( selCount * 3 ); //working for QPushButton
679 else 679 else
680 maxWid -= ( selCount * 3 ); //working for QPushButton 680 maxWid -= ( selCount * 3 ); //working for QPushButton
681 if ( maxWid < 0 ) 681 if ( maxWid < 0 )
682 maxWid = 20; 682 maxWid = 20;
683 int needWid = wid * selCount; 683 int needWid = wid * selCount;
684 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); 684 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid );
685 //if ( needWid > maxWid ) 685 //if ( needWid > maxWid )
686 // qDebug("DAYLABELS TOOOOOOO BIG "); 686 // qDebug("DAYLABELS TOOOOOOO BIG ");
687 while ( needWid > maxWid ) { 687 while ( needWid > maxWid ) {
688 dayTest = dayTest.left( dayTest.length() - 1 ); 688 dayTest = dayTest.left( dayTest.length() - 1 );
689 wid = fm.width( dayTest ); 689 wid = fm.width( dayTest );
690 needWid = wid * selCount; 690 needWid = wid * selCount;
691 } 691 }
692 int maxLen = dayTest.length(); 692 int maxLen = dayTest.length();
693 int fontPoint = dlf.pointSize(); 693 int fontPoint = dlf.pointSize();
694 if ( maxLen < 2 ) { 694 if ( maxLen < 2 ) {
695 int fontPoint = dlf.pointSize(); 695 int fontPoint = dlf.pointSize();
696 while ( fontPoint > 4 ) { 696 while ( fontPoint > 4 ) {
697 --fontPoint; 697 --fontPoint;
698 dlf.setPointSize( fontPoint ); 698 dlf.setPointSize( fontPoint );
699 QFontMetrics f( dlf ); 699 QFontMetrics f( dlf );
700 wid = f.width( "30" ); 700 wid = f.width( "30" );
701 needWid = wid * selCount; 701 needWid = wid * selCount;
702 if ( needWid < maxWid ) 702 if ( needWid < maxWid )
703 break; 703 break;
704 } 704 }
705 maxLen = 2; 705 maxLen = 2;
706 } 706 }
707 //qDebug("Max len %d ", dayTest.length() ); 707 //qDebug("Max len %d ", dayTest.length() );
708 708
709 QFontMetrics tempF( dlf ); 709 QFontMetrics tempF( dlf );
710 newHight = tempF.height(); 710 newHight = tempF.height();
711 mDayLabels->setFont( dlf ); 711 mDayLabels->setFont( dlf );
712 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; 712 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);;
713 // mLayoutDayLabels->addSpacing(mTimeLabels->width()); 713 // mLayoutDayLabels->addSpacing(mTimeLabels->width());
714 //mLayoutDayLabels->addSpacing( 2 ); 714 //mLayoutDayLabels->addSpacing( 2 );
715 // QFont lFont = dlf; 715 // QFont lFont = dlf;
716 bool appendLabels = false; 716 bool appendLabels = false;
717 KOAgendaButton *dayLabel; 717 KOAgendaButton *dayLabel;
718 dayLabel = mDayLabelsList.first(); 718 dayLabel = mDayLabelsList.first();
719 if ( !dayLabel ) { 719 if ( !dayLabel ) {
720 appendLabels = true; 720 appendLabels = true;
721 dayLabel = getNewDaylabel(); 721 dayLabel = getNewDaylabel();
722 } 722 }
723 dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() ); 723 dayLabel->setFixedWidth( mTimeLabels->width()+mAgenda->frameWidth() );
724 dayLabel->setFont( dlf ); 724 dayLabel->setFont( dlf );
725 dayLabel->setNum( -1 ); 725 dayLabel->setNum( -1 );
726 //dayLabel->setAlignment(QLabel::AlignHCenter); 726 //dayLabel->setAlignment(QLabel::AlignHCenter);
727#if 0 727#if 0
728 if ( QApplication::desktop()->width() <= 320 ) 728 if ( QApplication::desktop()->width() <= 320 )
729 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ).left(2) ); 729 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ).left(2) );
730 else 730 else
731#endif 731#endif
732 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); 732 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) );
733 dayLabel->show(); 733 dayLabel->show();
734 DateList::ConstIterator dit; 734 DateList::ConstIterator dit;
735 bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); 735 bool oneday = (mSelectedDates.first() == mSelectedDates.last() );
736 int counter = -1; 736 int counter = -1;
737 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 737 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
738 ++counter; 738 ++counter;
739 QDate date = *dit; 739 QDate date = *dit;
740 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); 740 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels);
741 if ( ! appendLabels ) { 741 if ( ! appendLabels ) {
742 dayLabel = mDayLabelsList.next(); 742 dayLabel = mDayLabelsList.next();
743 if ( !dayLabel ) 743 if ( !dayLabel )
744 appendLabels = true; 744 appendLabels = true;
745 } 745 }
746 if ( appendLabels ) { 746 if ( appendLabels ) {
747 dayLabel = getNewDaylabel(); 747 dayLabel = getNewDaylabel();
748 } 748 }
749 dayLabel->setMinimumWidth( 1 ); 749 dayLabel->setMinimumWidth( 1 );
750 dayLabel->setMaximumWidth( 10240 ); 750 dayLabel->setMaximumWidth( 10240 );
751 dayLabel->setFont( dlf ); 751 dayLabel->setFont( dlf );
752 dayLabel->show(); 752 dayLabel->show();
753 dayLabel->setAutoRepeat( false ); 753 dayLabel->setAutoRepeat( false );
754 dayLabel->setNum( counter ); 754 dayLabel->setNum( counter );
755 QString str; 755 QString str;
756 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); 756 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date);
757 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); 757 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true );
758 switch ( maxLen ) { 758 switch ( maxLen ) {
759 case 2: 759 case 2:
760 str = QString::number( date.day() ); 760 str = QString::number( date.day() );
761 break; 761 break;
762 762
763 case 3: 763 case 3:
764 str = dayName.left( 1 ) +QString::number( date.day()); 764 str = dayName.left( 1 ) +QString::number( date.day());
765 765
766 break; 766 break;
767 case 4: 767 case 4:
768 str = dayName.left( 1 ) + " " +QString::number( date.day()); 768 str = dayName.left( 1 ) + " " +QString::number( date.day());
769 769
770 break; 770 break;
771 case 5: 771 case 5:
772 str = dayName.left( 2 ) + " " +QString::number( date.day()); 772 str = dayName.left( 2 ) + " " +QString::number( date.day());
773 773
774 break; 774 break;
775 case 6: 775 case 6:
776 str = dayName.left( 3 ) + " " +QString::number( date.day()); 776 str = dayName.left( 3 ) + " " +QString::number( date.day());
777 break; 777 break;
778 778
779 default: 779 default:
780 break; 780 break;
781 } 781 }
782 if ( oneday ) { 782 if ( oneday ) {
783 QString addString; 783 QString addString;
784 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) 784 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() )
785 addString = i18n("Today"); 785 addString = i18n("Today");
786 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) 786 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) )
787 addString = i18n("Tomorrow"); 787 addString = i18n("Tomorrow");
788 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) 788 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) )
789 addString = i18n("Yesterday"); 789 addString = i18n("Yesterday");
790 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) 790 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) )
791 addString = i18n("Day before yesterday"); 791 addString = i18n("Day before yesterday");
792 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) 792 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) )
793 addString = i18n("Day after tomorrow"); 793 addString = i18n("Day after tomorrow");
794 if ( !addString.isEmpty() ) { 794 if ( !addString.isEmpty() ) {
795 str = addString+", " + str; 795 str = addString+", " + str;
796 } else { 796 } else {
797 str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer); 797 str = KGlobal::locale()->formatDate( date, KOPrefs::instance()->mShortDateInViewer);
798 } 798 }
799 } 799 }
800 dayLabel->setText(str); 800 dayLabel->setText(str);
801 //dayLabel->setAlignment(QLabel::AlignHCenter); 801 //dayLabel->setAlignment(QLabel::AlignHCenter);
802 if (date == QDate::currentDate()) { 802 if (date == QDate::currentDate()) {
803 QFont bFont = dlf; 803 QFont bFont = dlf;
804 bFont.setBold( true ); 804 bFont.setBold( true );
805 dayLabel->setFont(bFont); 805 dayLabel->setFont(bFont);
806 } 806 }
807 //dayLayout->addWidget(dayLabel); 807 //dayLayout->addWidget(dayLabel);
808 808
809#ifndef KORG_NOPLUGINS 809#ifndef KORG_NOPLUGINS
810 CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); 810 CalendarDecoration::List cds = KOCore::self()->calendarDecorations();
811 CalendarDecoration *it; 811 CalendarDecoration *it;
812 for(it = cds.first(); it; it = cds.next()) { 812 for(it = cds.first(); it; it = cds.next()) {
813 QString text = it->shortText( date ); 813 QString text = it->shortText( date );
814 if ( !text.isEmpty() ) { 814 if ( !text.isEmpty() ) {
815 QLabel *label = new QLabel(text,mDayLabels); 815 QLabel *label = new QLabel(text,mDayLabels);
816 label->setAlignment(AlignCenter); 816 label->setAlignment(AlignCenter);
817 dayLayout->addWidget(label); 817 dayLayout->addWidget(label);
818 } 818 }
819 } 819 }
820 820
821 for(it = cds.first(); it; it = cds.next()) { 821 for(it = cds.first(); it; it = cds.next()) {
822 QWidget *wid = it->smallWidget(mDayLabels,date); 822 QWidget *wid = it->smallWidget(mDayLabels,date);
823 if ( wid ) { 823 if ( wid ) {
824 // wid->setHeight(20); 824 // wid->setHeight(20);
825 dayLayout->addWidget(wid); 825 dayLayout->addWidget(wid);
826 } 826 }
827 } 827 }
828#endif 828#endif
829 } 829 }
830 if ( ! appendLabels ) { 830 if ( ! appendLabels ) {
831 dayLabel = mDayLabelsList.next(); 831 dayLabel = mDayLabelsList.next();
832 if ( !dayLabel ) 832 if ( !dayLabel )
833 appendLabels = true; 833 appendLabels = true;
834 } 834 }
835 if ( appendLabels ) { 835 if ( appendLabels ) {
836 dayLabel = getNewDaylabel(); 836 dayLabel = getNewDaylabel();
837 } 837 }
838 //dayLabel->hide();//test only 838 //dayLabel->hide();//test only
839 839
840 dayLabel->setText(">"); 840 dayLabel->setText(">");
841 dayLabel->setFont( dlf ); 841 dayLabel->setFont( dlf );
842 dayLabel->setAutoRepeat( true ); 842 dayLabel->setAutoRepeat( true );
843 dayLabel->show(); 843 dayLabel->show();
844 dayLabel->setNum( -2 ); 844 dayLabel->setNum( -2 );
845 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ widModulo ); 845 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ widModulo );
846 846
847 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); 847 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2);
848 if ( !appendLabels ) { 848 if ( !appendLabels ) {
849 dayLabel = mDayLabelsList.next(); 849 dayLabel = mDayLabelsList.next();
850 while ( dayLabel ) { 850 while ( dayLabel ) {
851 //qDebug("!dayLabel %d",dayLabel ); 851 //qDebug("!dayLabel %d",dayLabel );
852 dayLabel->hide(); 852 dayLabel->hide();
853 dayLabel = mDayLabelsList.next(); 853 dayLabel = mDayLabelsList.next();
854 } 854 }
855 } 855 }
856 856
857 mDayLabelsFrame->setFixedHeight( newHight + 4 ); 857 mDayLabelsFrame->setFixedHeight( newHight + 4 );
858} 858}
859 859
860int KOAgendaView::maxDatesHint() 860int KOAgendaView::maxDatesHint()
861{ 861{
862 // Not sure about the max number of events, so return 0 for now. 862 // Not sure about the max number of events, so return 0 for now.
863 return 0; 863 return 0;
864} 864}
865 865
866int KOAgendaView::currentDateCount() 866int KOAgendaView::currentDateCount()
867{ 867{
868 return mSelectedDates.count(); 868 return mSelectedDates.count();
869} 869}
870 870
871QPtrList<Incidence> KOAgendaView::selectedIncidences() 871QPtrList<Incidence> KOAgendaView::selectedIncidences()
872{ 872{
873 QPtrList<Incidence> selected; 873 QPtrList<Incidence> selected;
874 Incidence *incidence; 874 Incidence *incidence;
875 875
876 incidence = mAgenda->selectedIncidence(); 876 incidence = mAgenda->selectedIncidence();
877 if (incidence) selected.append(incidence); 877 if (incidence) selected.append(incidence);
878 878
879 incidence = mAllDayAgenda->selectedIncidence(); 879 incidence = mAllDayAgenda->selectedIncidence();
880 if (incidence) selected.append(incidence); 880 if (incidence) selected.append(incidence);
881 881
882 return selected; 882 return selected;
883} 883}
884 884
885DateList KOAgendaView::selectedDates() 885DateList KOAgendaView::selectedDates()
886{ 886{
887 DateList selected; 887 DateList selected;
888 QDate qd; 888 QDate qd;
889 889
890 qd = mAgenda->selectedIncidenceDate(); 890 qd = mAgenda->selectedIncidenceDate();
891 if (qd.isValid()) selected.append(qd); 891 if (qd.isValid()) selected.append(qd);
892 892
893 qd = mAllDayAgenda->selectedIncidenceDate(); 893 qd = mAllDayAgenda->selectedIncidenceDate();
894 if (qd.isValid()) selected.append(qd); 894 if (qd.isValid()) selected.append(qd);
895 895
896 return selected; 896 return selected;
897} 897}
898 898
899 899
900void KOAgendaView::updateView() 900void KOAgendaView::updateView()
901{ 901{
902 if ( mBlockUpdating ) 902 if ( mBlockUpdating )
903 return; 903 return;
904 // kdDebug() << "KOAgendaView::updateView()" << endl; 904 // kdDebug() << "KOAgendaView::updateView()" << endl;
905 fillAgenda(); 905 fillAgenda();
906 906
907} 907}
908 908
909 909
910/* 910/*
911 Update configuration settings for the agenda view. This method is not 911 Update configuration settings for the agenda view. This method is not
912 complete. 912 complete.
913*/ 913*/
914void KOAgendaView::updateConfig() 914void KOAgendaView::updateConfig()
915{ 915{
916 if ( mBlockUpdating ) 916 if ( mBlockUpdating )
917 return; 917 return;
918 if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) { 918 if ( mAgenda->height() > 96 * KOPrefs::instance()->mHourSize ) {
919 int old = KOPrefs::instance()->mHourSize; 919 int old = KOPrefs::instance()->mHourSize;
920 KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1; 920 KOPrefs::instance()->mHourSize = mAgenda->height()/96 +1;
921 qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize ); 921 qDebug("KOPrefs::instance()->mHourSize adjusted %d to %d ", old,KOPrefs::instance()->mHourSize );
922 } 922 }
923 923
924 924
925 // update config for children 925 // update config for children
926 mTimeLabels->updateConfig(); 926 mTimeLabels->updateConfig();
927 mAgenda->storePosition(); 927 mAgenda->storePosition();
928 mAgenda->updateConfig(); 928 mAgenda->updateConfig();
929 mAllDayAgenda->updateConfig(); 929 mAllDayAgenda->updateConfig();
930 // widget synchronization 930 // widget synchronization
931 //TODO: find a better way, maybe signal/slot 931 //TODO: find a better way, maybe signal/slot
932 mTimeLabels->positionChanged(); 932 mTimeLabels->positionChanged();
933 933
934 // for some reason, this needs to be called explicitly 934 // for some reason, this needs to be called explicitly
935 mTimeLabels->repaint(); 935 mTimeLabels->repaint();
936 936
937 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 937 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
938 938
939 // ToolTips displaying summary of events 939 // ToolTips displaying summary of events
940 KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance() 940 KOAgendaItem::toolTipGroup()->setEnabled(KOPrefs::instance()
941 ->mEnableToolTips); 941 ->mEnableToolTips);
942 942
943 //setHolidayMasks(); 943 //setHolidayMasks();
944 944
945 //createDayLabels(); called by via updateView(); 945 //createDayLabels(); called by via updateView();
946 mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth()); 946 mEventIndicatorTop->setXOffset(mTimeLabels->width() + mAgenda->frameWidth());
947 updateView(); 947 updateView();
948 mAgenda->restorePosition(); 948 mAgenda->restorePosition();
949} 949}
950 950
951 951
952void KOAgendaView::updateEventDates(KOAgendaItem *item, int type) 952void KOAgendaView::updateEventDates(KOAgendaItem *item, int type)
953{ 953{
954 // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl; 954 // kdDebug() << "KOAgendaView::updateEventDates(): " << item->text() << endl;
955 //qDebug("KOAgendaView::updateEventDates "); 955 //qDebug("KOAgendaView::updateEventDates ");
956 QDateTime startDt,endDt; 956 QDateTime startDt,endDt;
957 QDate startDate; 957 QDate startDate;
958 int lenInSecs; 958 int lenInSecs;
959 // if ( type == KOAgenda::RESIZETOP ) 959 // if ( type == KOAgenda::RESIZETOP )
960 // qDebug("RESIZETOP "); 960 // qDebug("RESIZETOP ");
961 // if ( type == KOAgenda::RESIZEBOTTOM ) 961 // if ( type == KOAgenda::RESIZEBOTTOM )
962 // qDebug("RESIZEBOTTOM "); 962 // qDebug("RESIZEBOTTOM ");
963 // if ( type == KOAgenda::MOVE ) 963 // if ( type == KOAgenda::MOVE )
964 // qDebug("MOVE "); 964 // qDebug("MOVE ");
965 if ( item->incidence()->type() == "Event" ) { 965 if ( item->incidence()->type() == "Event" ) {
966 startDt =item->incidence()->dtStart(); 966 startDt =item->incidence()->dtStart();
967 endDt = item->incidence()->dtEnd(); 967 endDt = item->incidence()->dtEnd();
968 lenInSecs = startDt.secsTo( endDt ); 968 lenInSecs = startDt.secsTo( endDt );
969 } 969 }
970 970
971 // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED ); 971 // emit incidenceItemChanged( item->incidence(), KOGlobals::EVENTEDITED );
972 972
973 if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) { 973 if ( item->incidence()->type()=="Todo" && item->mLastMoveXPos > 0 ) {
974 startDate = mSelectedDates[item->mLastMoveXPos]; 974 startDate = mSelectedDates[item->mLastMoveXPos];
975 } else { 975 } else {
976 if (item->cellX() < 0) { 976 if (item->cellX() < 0) {
977 startDate = (mSelectedDates.first()).addDays(item->cellX()); 977 startDate = (mSelectedDates.first()).addDays(item->cellX());
978 } else { 978 } else {
979 startDate = mSelectedDates[item->cellX()]; 979 startDate = mSelectedDates[item->cellX()];
980 } 980 }
981 } 981 }
982 startDt.setDate(startDate); 982 startDt.setDate(startDate);
983 983
984 if (item->incidence()->doesFloat()) { 984 if (item->incidence()->doesFloat()) {
985 endDt.setDate(startDate.addDays(item->cellWidth() - 1)); 985 endDt.setDate(startDate.addDays(item->cellWidth() - 1));
986 } else { 986 } else {
987 if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE ) 987 if ( type == KOAgenda::RESIZETOP || type == KOAgenda::MOVE )
988 startDt.setTime(mAgenda->gyToTime(item->cellYTop())); 988 startDt.setTime(mAgenda->gyToTime(item->cellYTop()));
989 if ( item->incidence()->type() == "Event" ) { 989 if ( item->incidence()->type() == "Event" ) {
990 if ( type == KOAgenda::MOVE ) { 990 if ( type == KOAgenda::MOVE ) {
991 endDt = startDt.addSecs(lenInSecs); 991 endDt = startDt.addSecs(lenInSecs);
992 992
993 } else if ( type == KOAgenda::RESIZEBOTTOM ) { 993 } else if ( type == KOAgenda::RESIZEBOTTOM ) {
994 if (item->lastMultiItem()) { 994 if (item->lastMultiItem()) {
995 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 995 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
996 endDt.setDate(startDate. 996 endDt.setDate(startDate.
997 addDays(item->lastMultiItem()->cellX() - item->cellX())); 997 addDays(item->lastMultiItem()->cellX() - item->cellX()));
998 } else { 998 } else {
999 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 999 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
1000 endDt.setDate(startDate); 1000 endDt.setDate(startDate);
1001 } 1001 }
1002 } 1002 }
1003 } else { 1003 } else {
1004 // todo 1004 // todo
1005 if (item->lastMultiItem()) { 1005 if (item->lastMultiItem()) {
1006 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1)); 1006 endDt.setTime(mAgenda->gyToTime(item->lastMultiItem()->cellYBottom()+1));
1007 endDt.setDate(startDate. 1007 endDt.setDate(startDate.
1008 addDays(item->lastMultiItem()->cellX() - item->cellX())); 1008 addDays(item->lastMultiItem()->cellX() - item->cellX()));
1009 } else { 1009 } else {
1010 //qDebug("tem->cellYBottom() %d",item->cellYBottom() ); 1010 //qDebug("tem->cellYBottom() %d",item->cellYBottom() );
1011 if ( item->cellYBottom() > 0 ) 1011 if ( item->cellYBottom() > 0 )
1012 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1)); 1012 endDt.setTime(mAgenda->gyToTime(item->cellYBottom()+1));
1013 else 1013 else
1014 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time()); 1014 endDt.setTime((static_cast<Todo*>(item->incidence()))->dtDue().time());
1015 endDt.setDate(startDate); 1015 endDt.setDate(startDate);
1016 } 1016 }
1017 } 1017 }
1018 } 1018 }
1019 if ( item->incidence()->type() == "Event" ) { 1019 if ( item->incidence()->type() == "Event" ) {
1020 item->incidence()->setDtStart(startDt); 1020 item->incidence()->setDtStart(startDt);
1021 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt); 1021 (static_cast<Event*>(item->incidence()))->setDtEnd(endDt);
1022 } else if ( item->incidence()->type() == "Todo" ) { 1022 } else if ( item->incidence()->type() == "Todo" ) {
1023 Todo* to = static_cast<Todo*>(item->incidence()); 1023 Todo* to = static_cast<Todo*>(item->incidence());
1024 1024
1025 to->setDtDue(endDt); 1025 to->setDtDue(endDt);
1026 if ( to->hasStartDate() ) { 1026 if ( to->hasStartDate() ) {
1027 if (to->dtStart() >= to->dtDue() ) 1027 if (to->dtStart() >= to->dtDue() )
1028 to->setDtStart(to->dtDue().addDays( -2 )); 1028 to->setDtStart(to->dtDue().addDays( -2 ));
1029 } 1029 }
1030 1030
1031 } 1031 }
1032 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() ); 1032 //qDebug("KOAgendaView::updateEventDates stsart %s end %s ", startDt.toString().latin1(), endDt.toString().latin1() );
1033 item->incidence()->setRevision(item->incidence()->revision()+1); 1033 item->incidence()->setRevision(item->incidence()->revision()+1);
1034 item->setItemDate(startDt.date()); 1034 item->setItemDate(startDt.date());
1035 //item->updateItem(); 1035 //item->updateItem();
1036 if ( item->incidence()->type() == "Todo" ) { 1036 if ( item->incidence()->type() == "Todo" ) {
1037 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED ); 1037 emit todoMoved((Todo*)item->incidence(), KOGlobals::EVENTEDITED );
1038 1038
1039 } 1039 }
1040 else 1040 else
1041 emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED); 1041 emit incidenceChanged(item->incidence(), KOGlobals::EVENTEDITED);
1042 item->updateItem(); 1042 item->updateItem();
1043} 1043}
1044 1044
1045void KOAgendaView::showDates( const QDate &start, const QDate &end ) 1045void KOAgendaView::showDates( const QDate &start, const QDate &end )
1046{ 1046{
1047 // kdDebug() << "KOAgendaView::selectDates" << endl; 1047 // kdDebug() << "KOAgendaView::selectDates" << endl;
1048 1048
1049 mSelectedDates.clear(); 1049 mSelectedDates.clear();
1050 // qDebug("KOAgendaView::showDates "); 1050 // qDebug("KOAgendaView::showDates ");
1051 QDate d = start; 1051 QDate d = start;
1052 while (d <= end) { 1052 while (d <= end) {
1053 mSelectedDates.append(d); 1053 mSelectedDates.append(d);
1054 d = d.addDays( 1 ); 1054 d = d.addDays( 1 );
1055 } 1055 }
1056 1056
1057 // and update the view 1057 // and update the view
1058 fillAgenda(); 1058 fillAgenda();
1059} 1059}
1060 1060
1061 1061
1062void KOAgendaView::showEvents(QPtrList<Event>) 1062void KOAgendaView::showEvents(QPtrList<Event>)
1063{ 1063{
1064 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl; 1064 kdDebug() << "KOAgendaView::showEvents() is not yet implemented" << endl;
1065} 1065}
1066 1066
1067void KOAgendaView::changeEventDisplay(Event *, int) 1067void KOAgendaView::changeEventDisplay(Event *, int)
1068{ 1068{
1069 // qDebug("KOAgendaView::changeEventDisplay "); 1069 // qDebug("KOAgendaView::changeEventDisplay ");
1070 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl; 1070 // kdDebug() << "KOAgendaView::changeEventDisplay" << endl;
1071 // this should be re-written to be MUCH smarter. Right now we 1071 // this should be re-written to be MUCH smarter. Right now we
1072 // are just playing dumb. 1072 // are just playing dumb.
1073 fillAgenda(); 1073 fillAgenda();
1074} 1074}
1075 1075
1076void KOAgendaView::fillAgenda(const QDate &) 1076void KOAgendaView::fillAgenda(const QDate &)
1077{ 1077{
1078 // qDebug("KOAgendaView::fillAgenda "); 1078 // qDebug("KOAgendaView::fillAgenda ");
1079 fillAgenda(); 1079 fillAgenda();
1080} 1080}
1081 1081
1082void KOAgendaView::fillAgenda() 1082void KOAgendaView::fillAgenda()
1083{ 1083{
1084 if ( globalFlagBlockStartup ) 1084 if ( globalFlagBlockStartup )
1085 return; 1085 return;
1086 if ( globalFlagBlockAgenda == 1 ) 1086 if ( globalFlagBlockAgenda == 1 )
1087 return; 1087 return;
1088 static bool onlyOne = false; 1088 static bool onlyOne = false;
1089 if ( onlyOne ) 1089 if ( onlyOne )
1090 return; 1090 return;
1091 onlyOne = true; 1091 onlyOne = true;
1092 //if ( globalFlagBlockAgenda == 2 ) 1092 //if ( globalFlagBlockAgenda == 2 )
1093 //globalFlagBlockAgenda = 0; 1093 //globalFlagBlockAgenda = 0;
1094 // globalFlagBlockPainting = false; 1094 // globalFlagBlockPainting = false;
1095 if ( globalFlagBlockAgenda == 0 ) 1095 if ( globalFlagBlockAgenda == 0 )
1096 globalFlagBlockAgenda = 1; 1096 globalFlagBlockAgenda = 1;
1097 // clearView(); 1097 // clearView();
1098 //qDebug("fillAgenda()++++ "); 1098 //qDebug("fillAgenda()++++ ");
1099 globalFlagBlockAgendaItemPaint = 1; 1099 globalFlagBlockAgendaItemPaint = 1;
1100 1100
1101 mAllDayAgenda->changeColumns(mSelectedDates.count()); 1101 mAllDayAgenda->changeColumns(mSelectedDates.count());
1102 mAgenda->changeColumns(mSelectedDates.count()); 1102 mAgenda->changeColumns(mSelectedDates.count());
1103 qApp->processEvents(); 1103 qApp->processEvents();
1104 mEventIndicatorTop->changeColumns(mSelectedDates.count()); 1104 mEventIndicatorTop->changeColumns(mSelectedDates.count());
1105 mEventIndicatorBottom->changeColumns(mSelectedDates.count()); 1105 mEventIndicatorBottom->changeColumns(mSelectedDates.count());
1106 setHolidayMasks(); 1106 setHolidayMasks();
1107 1107
1108 //mAgenda->hideUnused(); 1108 //mAgenda->hideUnused();
1109 //mAllDayAgenda->hideUnused(); 1109 //mAllDayAgenda->hideUnused();
1110 1110
1111 // mAgenda->blockNextRepaint( false ); 1111 // mAgenda->blockNextRepaint( false );
1112 // mAgenda->viewport()->repaint(); 1112 // mAgenda->viewport()->repaint();
1113 // mAgenda->blockNextRepaint( true ); 1113 // mAgenda->blockNextRepaint( true );
1114 mMinY.resize(mSelectedDates.count()); 1114 mMinY.resize(mSelectedDates.count());
1115 mMaxY.resize(mSelectedDates.count()); 1115 mMaxY.resize(mSelectedDates.count());
1116 1116
1117 QPtrList<Event> dayEvents; 1117 QPtrList<Event> dayEvents;
1118 1118
1119 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1119 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1120 // Therefore, gtodoset all of them. 1120 // Therefore, gtodoset all of them.
1121 QPtrList<Todo> todos = calendar()->todos(); 1121 QPtrList<Todo> todos = calendar()->todos();
1122 1122
1123 mAgenda->setDateList(mSelectedDates); 1123 mAgenda->setDateList(mSelectedDates);
1124 1124
1125 QDate today = QDate::currentDate(); 1125 QDate today = QDate::currentDate();
1126 1126
1127 DateList::ConstIterator dit; 1127 DateList::ConstIterator dit;
1128 int curCol = 0; 1128 int curCol = 0;
1129 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 1129 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
1130 QDate currentDate = *dit; 1130 QDate currentDate = *dit;
1131 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString() 1131 // kdDebug() << "KOAgendaView::fillAgenda(): " << currentDate.toString()
1132 // << endl; 1132 // << endl;
1133 1133
1134 dayEvents = calendar()->events(currentDate,true); 1134 dayEvents = calendar()->events(currentDate,true);
1135 1135
1136 // Default values, which can never be reached 1136 // Default values, which can never be reached
1137 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1; 1137 mMinY[curCol] = mAgenda->timeToY(QTime(23,59)) + 1;
1138 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1; 1138 mMaxY[curCol] = mAgenda->timeToY(QTime(0,0)) - 1;
1139 1139
1140 unsigned int numEvent; 1140 unsigned int numEvent;
1141 for(numEvent=0;numEvent<dayEvents.count();++numEvent) { 1141 for(numEvent=0;numEvent<dayEvents.count();++numEvent) {
1142 Event *event = dayEvents.at(numEvent); 1142 Event *event = dayEvents.at(numEvent);
1143 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) 1143 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") )
1144 if ( event->uid().left(15) == QString("last-syncEvent-") ) 1144 if ( event->uid().left(15) == QString("last-syncEvent-") )
1145 continue; 1145 continue;
1146 // kdDebug() << " Event: " << event->summary() << endl; 1146 // kdDebug() << " Event: " << event->summary() << endl;
1147 1147
1148 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol; 1148 int beginX = currentDate.daysTo(event->dtStart().date()) + curCol;
1149 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol; 1149 int endX = currentDate.daysTo(event->dtEnd().date()) + curCol;
1150 1150
1151 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl; 1151 // kdDebug() << " beginX: " << beginX << " endX: " << endX << endl;
1152 1152
1153 if (event->doesFloat()) { 1153 if (event->doesFloat()) {
1154 if (event->recurrence()->doesRecur()) { 1154 if (event->recurrence()->doesRecur()) {
1155 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol); 1155 mAllDayAgenda->insertAllDayItem(event,currentDate,curCol,curCol);
1156 } else { 1156 } else {
1157 if (beginX <= 0 && curCol == 0) { 1157 if (beginX <= 0 && curCol == 0) {
1158 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1158 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1159 } else if (beginX == curCol) { 1159 } else if (beginX == curCol) {
1160 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX); 1160 mAllDayAgenda->insertAllDayItem(event,currentDate,beginX,endX);
1161 } 1161 }
1162 } 1162 }
1163 } else if (event->isMultiDay()) { 1163 } else if (event->isMultiDay()) {
1164 if ( event->doesRecur () ) { 1164 if ( event->doesRecur () ) {
1165 QDate dateit = currentDate; 1165 QDate dateit = currentDate;
1166 int count = 0; 1166 int count = 0;
1167 int max = event->dtStart().daysTo( event->dtEnd() ) +2; 1167 int max = event->dtStart().daysTo( event->dtEnd() ) +2;
1168 while (! event->recursOn( dateit ) && count <= max ) { 1168 while (! event->recursOn( dateit ) && count <= max ) {
1169 ++count; 1169 ++count;
1170 dateit = dateit.addDays( -1 ); 1170 dateit = dateit.addDays( -1 );
1171 } 1171 }
1172 bool ok; 1172 bool ok;
1173 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok ); 1173 QDateTime nextOcstart = event->getNextOccurence( QDateTime(dateit) ,&ok );
1174 if ( ok ) 1174 if ( ok )
1175 { 1175 {
1176 int secs = event->dtStart().secsTo( event->dtEnd() ); 1176 int secs = event->dtStart().secsTo( event->dtEnd() );
1177 QDateTime nextOcend =nextOcstart.addSecs( secs ); ; 1177 QDateTime nextOcend =nextOcstart.addSecs( secs ); ;
1178 beginX = currentDate.daysTo(nextOcstart.date()) + curCol; 1178 beginX = currentDate.daysTo(nextOcstart.date()) + curCol;
1179 endX = currentDate.daysTo(nextOcend.date()) + curCol; 1179 endX = currentDate.daysTo(nextOcend.date()) + curCol;
1180 1180
1181 } 1181 }
1182 } 1182 }
1183 int startY = mAgenda->timeToY(event->dtStart().time()); 1183 int startY = mAgenda->timeToY(event->dtStart().time());
1184 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1184 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1185 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol ); 1185 //qDebug("insert %d %d %d %d %d ",beginX,endX,startY,endY , curCol );
1186 if ((beginX <= 0 && curCol == 0) || beginX == curCol) { 1186 if ((beginX <= 0 && curCol == 0) || beginX == curCol) {
1187 //qDebug("insert!!! "); 1187 //qDebug("insert!!! ");
1188 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY); 1188 mAgenda->insertMultiItem(event,currentDate,beginX,endX,startY,endY);
1189 } 1189 }
1190 if (beginX == curCol) { 1190 if (beginX == curCol) {
1191 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1191 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1192 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1192 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1193 } else if (endX == curCol) { 1193 } else if (endX == curCol) {
1194 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1194 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1195 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1195 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1196 } else { 1196 } else {
1197 mMinY[curCol] = mAgenda->timeToY(QTime(0,0)); 1197 mMinY[curCol] = mAgenda->timeToY(QTime(0,0));
1198 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59)); 1198 mMaxY[curCol] = mAgenda->timeToY(QTime(23,59));
1199 } 1199 }
1200 } else { 1200 } else {
1201 int startY = mAgenda->timeToY(event->dtStart().time()); 1201 int startY = mAgenda->timeToY(event->dtStart().time());
1202 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1; 1202 int endY = mAgenda->timeToY(event->dtEnd().time()) - 1;
1203 if (endY < startY) endY = startY; 1203 if (endY < startY) endY = startY;
1204 mAgenda->insertItem(event,currentDate,curCol,startY,endY); 1204 mAgenda->insertItem(event,currentDate,curCol,startY,endY);
1205 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1205 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1206 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1206 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1207 } 1207 }
1208 } 1208 }
1209 // ---------- [display Todos -------------- 1209 // ---------- [display Todos --------------
1210 unsigned int numTodo; 1210 unsigned int numTodo;
1211 for (numTodo = 0; numTodo < todos.count(); ++numTodo) { 1211 for (numTodo = 0; numTodo < todos.count(); ++numTodo) {
1212 Todo *todo = todos.at(numTodo); 1212 Todo *todo = todos.at(numTodo);
1213 1213
1214 if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date 1214 if ( ! todo->hasDueDate() && !todo->hasCompletedDate()) continue; // todo shall not be displayed if it has no date
1215 1215
1216 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue. 1216 // ToDo items shall be displayed for the day they are due, but only showed today if they are already overdue.
1217 // Already completed items can be displayed on their original due date 1217 // Already completed items can be displayed on their original due date
1218 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda 1218 //if not KOPrefs::instance()->mShowTodoInAgenda, show overdue in agenda
1219 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda; 1219 bool overdue = (!todo->isCompleted()) && (todo->dtDue() < today) && KOPrefs::instance()->mShowTodoInAgenda;
1220 bool fillIn = false; 1220 bool fillIn = false;
1221 if ( todo->hasCompletedDate() && todo->completed().date() == currentDate ) 1221 if ( todo->hasCompletedDate() && todo->completed().date() == currentDate )
1222 fillIn = true; 1222 fillIn = true;
1223 if ( ! fillIn && !todo->hasCompletedDate() ) 1223 if ( ! fillIn && !todo->hasCompletedDate() )
1224 fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue); 1224 fillIn = ((todo->dtDue().date() == currentDate) && !overdue) || ((currentDate == today) && overdue);
1225 if ( fillIn ) { 1225 if ( fillIn ) {
1226 if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue 1226 if ( (todo->doesFloat() || overdue ) && !todo->hasCompletedDate() ) { // Todo has no due-time set or is already overdue
1227 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1227 if ( KOPrefs::instance()->mShowTodoInAgenda )
1228 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol); 1228 mAllDayAgenda->insertAllDayItem(todo, currentDate, curCol, curCol);
1229 } 1229 }
1230 else { 1230 else {
1231 QDateTime dt; 1231 QDateTime dt;
1232 if ( todo->hasCompletedDate() ) 1232 if ( todo->hasCompletedDate() )
1233 dt = todo->completed(); 1233 dt = todo->completed();
1234 else 1234 else
1235 dt = todo->dtDue();; 1235 dt = todo->dtDue();;
1236 1236
1237 1237
1238 int endY = mAgenda->timeToY(dt.time()) - 1; 1238 int endY = mAgenda->timeToY(dt.time()) - 1;
1239 int hi = (18/KOPrefs::instance()->mHourSize); 1239 int hi = (18/KOPrefs::instance()->mHourSize);
1240 //qDebug("hei %d ",KOPrefs::instance()->mHourSize); 1240 //qDebug("hei %d ",KOPrefs::instance()->mHourSize);
1241 int startY = endY -hi; 1241 int startY = endY -hi;
1242 1242
1243 mAgenda->insertItem(todo,currentDate,curCol,startY,endY); 1243 mAgenda->insertItem(todo,currentDate,curCol,startY,endY);
1244 1244
1245 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1245 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1246 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1246 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1247 } 1247 }
1248 } 1248 }
1249 } 1249 }
1250 // ---------- display Todos] -------------- 1250 // ---------- display Todos] --------------
1251 1251
1252 ++curCol; 1252 ++curCol;
1253 } 1253 }
1254 mAgenda->hideUnused(); 1254 mAgenda->hideUnused();
1255 mAllDayAgenda->hideUnused(); 1255 mAllDayAgenda->hideUnused();
1256 mAgenda->checkScrollBoundaries(); 1256 mAgenda->checkScrollBoundaries();
1257 1257
1258 deleteSelectedDateTime(); 1258 deleteSelectedDateTime();
1259 1259
1260 createDayLabels(); 1260 createDayLabels();
1261 emit incidenceSelected( 0 ); 1261 emit incidenceSelected( 0 );
1262 1262
1263 if ( globalFlagBlockAgenda == 2 ) { 1263 if ( globalFlagBlockAgenda == 2 ) {
1264 if ( KOPrefs::instance()->mSetTimeToDayStartAt ) 1264 if ( KOPrefs::instance()->mSetTimeToDayStartAt )
1265 setStartHour( KOPrefs::instance()->mDayBegins ); 1265 setStartHour( KOPrefs::instance()->mDayBegins );
1266 else if ( KOPrefs::instance()->mCenterOnCurrentTime ) 1266 else if ( KOPrefs::instance()->mCenterOnCurrentTime )
1267 setStartHour( QTime::currentTime ().hour() ); 1267 setStartHour( QTime::currentTime ().hour() );
1268 // qApp->processEvents(); 1268 // qApp->processEvents();
1269 } 1269 }
1270 qApp->processEvents(); 1270 qApp->processEvents();
1271 //qDebug("qApp->processEvents(); END "); 1271 //qDebug("qApp->processEvents(); END ");
1272 globalFlagBlockAgenda = 0; 1272 globalFlagBlockAgenda = 0;
1273 1273
1274 // mAgenda->hideUnused(); 1274 // mAgenda->hideUnused();
1275 //mAllDayAgenda->hideUnused(); 1275 //mAllDayAgenda->hideUnused();
1276 mAllDayAgenda->drawContentsToPainter(); 1276 mAllDayAgenda->drawContentsToPainter();
1277 mAgenda->drawContentsToPainter(); 1277 mAgenda->drawContentsToPainter();
1278 repaintAgenda(); 1278 repaintAgenda();
1279 onlyOne = false; 1279 onlyOne = false;
1280 // mAgenda->finishUpdate(); 1280 // mAgenda->finishUpdate();
1281 //mAllDayAgenda->finishUpdate(); 1281 //mAllDayAgenda->finishUpdate();
1282 1282
1283 // repaintAgenda(); 1283 // repaintAgenda();
1284 //qApp->processEvents(); 1284 //qApp->processEvents();
1285 // globalFlagBlockAgenda = 0; 1285 // globalFlagBlockAgenda = 0;
1286} 1286}
1287void KOAgendaView::repaintAgenda() 1287void KOAgendaView::repaintAgenda()
1288{ 1288{
1289 // mAllDayAgenda->drawContentsToPainter(); 1289 // mAllDayAgenda->drawContentsToPainter();
1290// mAllDayAgenda->viewport()->repaint( false ); 1290// mAllDayAgenda->viewport()->repaint( false );
1291// mAgenda->drawContentsToPainter(); 1291// mAgenda->drawContentsToPainter();
1292// mAgenda->viewport()->repaint( false ); 1292// mAgenda->viewport()->repaint( false );
1293// qApp->processEvents(); 1293// qApp->processEvents();
1294 1294
1295 //qDebug("KOAgendaView::repaintAgenda() "); 1295 //qDebug("KOAgendaView::repaintAgenda() ");
1296 //qApp->processEvents(); 1296 //qApp->processEvents();
1297 mAgenda->viewport()->repaint( false ); 1297 mAgenda->viewport()->repaint( false );
1298 mAllDayAgenda->viewport()->repaint( false ); 1298 mAllDayAgenda->viewport()->repaint( false );
1299 mAgenda->finishUpdate(); 1299 mAgenda->finishUpdate();
1300 mAllDayAgenda->finishUpdate(); 1300 mAllDayAgenda->finishUpdate();
1301} 1301}
1302 1302
1303 1303
1304void KOAgendaView::clearView() 1304void KOAgendaView::clearView()
1305{ 1305{
1306 // kdDebug() << "ClearView" << endl; 1306 // kdDebug() << "ClearView" << endl;
1307 mAllDayAgenda->clear(); 1307 mAllDayAgenda->clear();
1308 mAgenda->clear(); 1308 mAgenda->clear();
1309} 1309}
1310 1310
1311void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, 1311void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd,
1312 const QDate &td) 1312 const QDate &td)
1313{ 1313{
1314#ifndef KORG_NOPRINTER 1314#ifndef KORG_NOPRINTER
1315 if (fd == td) 1315 if (fd == td)
1316 calPrinter->preview(CalPrinter::Day, fd, td); 1316 calPrinter->preview(CalPrinter::Day, fd, td);
1317 else 1317 else
1318 calPrinter->preview(CalPrinter::Week, fd, td); 1318 calPrinter->preview(CalPrinter::Week, fd, td);
1319#endif 1319#endif
1320} 1320}
1321 1321
1322// void KOAgendaView::updateMovedTodo() 1322// void KOAgendaView::updateMovedTodo()
1323// { 1323// {
1324// // updateConfig(); 1324// // updateConfig();
1325// // emit updateTodoViews(); 1325// // emit updateTodoViews();
1326// } 1326// }
1327 1327
1328void KOAgendaView::slotShowDateView( int mode , int d ) 1328void KOAgendaView::slotShowDateView( int mode , int d )
1329{ 1329{
1330 if ( d >= mSelectedDates.count() ) { 1330 if ( d >= mSelectedDates.count() ) {
1331 qDebug("KOAgendaView::slotShowDateView datecounterror %d d ", d, mSelectedDates.count() ); 1331 qDebug("KOAgendaView::slotShowDateView datecounterror %d d ", d, mSelectedDates.count() );
1332 1332
1333 } else { 1333 } else {
1334 QDate day = mSelectedDates[d]; 1334 QDate day = mSelectedDates[d];
1335 emit showDateView(mode , day ); 1335 emit showDateView(mode , day );
1336 } 1336 }
1337 1337
1338} 1338}
1339void KOAgendaView::newEvent(int gx, int gy) 1339void KOAgendaView::newEvent(int gx, int gy)
1340{ 1340{
1341 if (!mSelectedDates.count()) return; 1341 if (!mSelectedDates.count()) return;
1342 1342
1343 QDate day = mSelectedDates[gx]; 1343 QDate day = mSelectedDates[gx];
1344 1344
1345 QTime time = mAgenda->gyToTime(gy); 1345 QTime time = mAgenda->gyToTime(gy);
1346 QDateTime dt(day,time); 1346 QDateTime dt(day,time);
1347 // if ( dt < QDateTime::currentDateTime () ) 1347 // if ( dt < QDateTime::currentDateTime () )
1348 // dt = QDateTime::currentDateTime ().addSecs( 3600 ); 1348 // dt = QDateTime::currentDateTime ().addSecs( 3600 );
1349 emit newEventSignal(dt); 1349 emit newEventSignal(dt);
1350} 1350}
1351 1351
1352void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) 1352void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd)
1353{ 1353{
1354 if (!mSelectedDates.count()) return; 1354 if (!mSelectedDates.count()) return;
1355 1355
1356 QDate dayStart = mSelectedDates[gxStart]; 1356 QDate dayStart = mSelectedDates[gxStart];
1357 QDate dayEnd = mSelectedDates[gxEnd]; 1357 QDate dayEnd = mSelectedDates[gxEnd];
1358 1358
1359 QTime timeStart = mAgenda->gyToTime(gyStart); 1359 QTime timeStart = mAgenda->gyToTime(gyStart);
1360 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); 1360 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 );
1361 1361
1362 QDateTime dtStart(dayStart,timeStart); 1362 QDateTime dtStart(dayStart,timeStart);
1363 QDateTime dtEnd(dayEnd,timeEnd); 1363 QDateTime dtEnd(dayEnd,timeEnd);
1364 1364
1365 emit newEventSignal(dtStart,dtEnd); 1365 emit newEventSignal(dtStart,dtEnd);
1366} 1366}
1367 1367
1368void KOAgendaView::newEventAllDay(int gx, int ) 1368void KOAgendaView::newEventAllDay(int gx, int )
1369{ 1369{
1370 if (!mSelectedDates.count()) return; 1370 if (!mSelectedDates.count()) return;
1371 1371
1372 QDate day = mSelectedDates[gx]; 1372 QDate day = mSelectedDates[gx];
1373 1373
1374 emit newEventSignal(day); 1374 emit newEventSignal(day);
1375} 1375}
1376void KOAgendaView::newTodoAllDay(int gx, int ) 1376void KOAgendaView::newTodoAllDay(int gx, int )
1377{ 1377{
1378 if (!mSelectedDates.count()) return; 1378 if (!mSelectedDates.count()) return;
1379 1379
1380 QDateTime day (mSelectedDates[gx] ); 1380 QDateTime day (mSelectedDates[gx] );
1381 emit newTodoSignal(day, true); 1381 emit newTodoSignal(day, true);
1382} 1382}
1383void KOAgendaView::newTodo(int gx, int gy ) 1383void KOAgendaView::newTodo(int gx, int gy )
1384{ 1384{
1385 if (!mSelectedDates.count()) return; 1385 if (!mSelectedDates.count()) return;
1386 QDate dayStart = mSelectedDates[gx]; 1386 QDate dayStart = mSelectedDates[gx];
1387 QTime timeStart = mAgenda->gyToTime(gy); 1387 QTime timeStart = mAgenda->gyToTime(gy);
1388 QDateTime dt (dayStart,timeStart); 1388 QDateTime dt (dayStart,timeStart);
1389 emit newTodoSignal( dt, false ); 1389 emit newTodoSignal( dt, false );
1390} 1390}
1391 1391
1392void KOAgendaView::updateEventIndicatorTop(int newY) 1392void KOAgendaView::updateEventIndicatorTop(int newY)
1393{ 1393{
1394 uint i; 1394 uint i;
1395 for(i=0;i<mMinY.size();++i) { 1395 for(i=0;i<mMinY.size();++i) {
1396 if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); 1396 if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true);
1397 else mEventIndicatorTop->enableColumn(i,false); 1397 else mEventIndicatorTop->enableColumn(i,false);
1398 } 1398 }
1399 1399
1400 mEventIndicatorTop->update(); 1400 mEventIndicatorTop->update();
1401} 1401}
1402 1402
1403void KOAgendaView::updateEventIndicatorBottom(int newY) 1403void KOAgendaView::updateEventIndicatorBottom(int newY)
1404{ 1404{
1405 uint i; 1405 uint i;
1406 for(i=0;i<mMaxY.size();++i) { 1406 for(i=0;i<mMaxY.size();++i) {
1407 if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); 1407 if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true);
1408 else mEventIndicatorBottom->enableColumn(i,false); 1408 else mEventIndicatorBottom->enableColumn(i,false);
1409 } 1409 }
1410 1410
1411 mEventIndicatorBottom->update(); 1411 mEventIndicatorBottom->update();
1412} 1412}
1413 1413
1414void KOAgendaView::startDrag(Event *event) 1414void KOAgendaView::startDrag(Event *event)
1415{ 1415{
1416#ifndef KORG_NODND 1416#ifndef KORG_NODND
1417 DndFactory factory( calendar() ); 1417 DndFactory factory( calendar() );
1418 ICalDrag *vd = factory.createDrag(event,this); 1418 ICalDrag *vd = factory.createDrag(event,this);
1419 if (vd->drag()) { 1419 if (vd->drag()) {
1420 kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; 1420 kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl;
1421 } 1421 }
1422#endif 1422#endif
1423} 1423}
1424 1424
1425void KOAgendaView::readSettings() 1425void KOAgendaView::readSettings()
1426{ 1426{
1427 readSettings(KOGlobals::config()); 1427 readSettings(KOGlobals::config());
1428} 1428}
1429 1429
1430void KOAgendaView::readSettings(KConfig *config) 1430void KOAgendaView::readSettings(KConfig *config)
1431{ 1431{
1432 // kdDebug() << "KOAgendaView::readSettings()" << endl; 1432 // kdDebug() << "KOAgendaView::readSettings()" << endl;
1433 1433
1434 config->setGroup("Views"); 1434 config->setGroup("Views");
1435 1435
1436 //#ifndef KORG_NOSPLITTER 1436 //#ifndef KORG_NOSPLITTER
1437 QValueList<int> sizes = config->readIntListEntry("Separator AgendaView"); 1437 QValueList<int> sizes = config->readIntListEntry("Separator AgendaView");
1438 if (sizes.count() == 2) { 1438 if (sizes.count() == 2) {
1439 if ( sizes[0] < 20 ) { 1439 if ( sizes[0] < 20 ) {
1440 sizes[1] = sizes[1] +20 - sizes[0]; 1440 sizes[1] = sizes[1] +20 - sizes[0];
1441 sizes[0] = 20; 1441 sizes[0] = 20;
1442 } 1442 }
1443 mSplitterAgenda->setSizes(sizes); 1443 mSplitterAgenda->setSizes(sizes);
1444 // qDebug("read %d %d ",sizes[0],sizes[1] ); 1444 // qDebug("read %d %d ",sizes[0],sizes[1] );
1445 } 1445 }
1446 //#endif 1446 //#endif
1447 1447
1448 // updateConfig(); 1448 // updateConfig();
1449} 1449}
1450 1450
1451void KOAgendaView::writeSettings(KConfig *config) 1451void KOAgendaView::writeSettings(KConfig *config)
1452{ 1452{
1453 // kdDebug() << "KOAgendaView::writeSettings()" << endl; 1453 // kdDebug() << "KOAgendaView::writeSettings()" << endl;
1454 1454
1455 config->setGroup("Views"); 1455 config->setGroup("Views");
1456 1456
1457 //#ifndef KORG_NOSPLITTER 1457 //#ifndef KORG_NOSPLITTER
1458 QValueList<int> list = mSplitterAgenda->sizes(); 1458 QValueList<int> list = mSplitterAgenda->sizes();
1459 config->writeEntry("Separator AgendaView",list); 1459 config->writeEntry("Separator AgendaView",list);
1460 //qDebug("write %d %d ", list[0],list[1] ); 1460 //qDebug("write %d %d ", list[0],list[1] );
1461 //#endif 1461 //#endif
1462} 1462}
1463 1463
1464void KOAgendaView::setHolidayMasks() 1464void KOAgendaView::setHolidayMasks()
1465{ 1465{
1466 mHolidayMask.resize(mSelectedDates.count()); 1466 mHolidayMask.resize(mSelectedDates.count());
1467 1467
1468 uint i; 1468 uint i;
1469 for(i=0;i<mSelectedDates.count();++i) { 1469 for(i=0;i<mSelectedDates.count();++i) {
1470 QDate date = mSelectedDates[i]; 1470 QDate date = mSelectedDates[i];
1471 bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6); 1471 bool showSaturday = KOPrefs::instance()->mExcludeSaturdays && (date.dayOfWeek() == 6);
1472 bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7); 1472 bool showSunday = KOPrefs::instance()->mExcludeHolidays && (date.dayOfWeek() == 7);
1473 bool showHoliday = false; 1473 bool showHoliday = false;
1474 if ( KOPrefs::instance()->mExcludeHolidays ) { 1474 if ( KOPrefs::instance()->mExcludeHolidays ) {
1475 QPtrList<Event> events = calendar()->events( date, true ); 1475 QPtrList<Event> events = calendar()->events( date, true );
1476 Event *event; 1476 Event *event;
1477 for( event = events.first(); event; event = events.next() ) { 1477 for( event = events.first(); event; event = events.next() ) {
1478 if ( event->isHoliday()) { 1478 if ( event->isHoliday()) {
1479 showHoliday = true; 1479 showHoliday = true;
1480 break; 1480 break;
1481 } 1481 }
1482 } 1482 }
1483 1483
1484 } 1484 }
1485 1485
1486#ifndef KORG_NOPLUGINS 1486#ifndef KORG_NOPLUGINS
1487 bool showHoliday = KOPrefs::instance()->mExcludeHolidays && 1487 bool showHoliday = KOPrefs::instance()->mExcludeHolidays &&
1488 !KOCore::self()->holiday(date).isEmpty(); 1488 !KOCore::self()->holiday(date).isEmpty();
1489#endif 1489#endif
1490 bool showDay = showSaturday || showSunday || showHoliday; 1490 bool showDay = showSaturday || showSunday || showHoliday;
1491 1491
1492 if (showDay) { 1492 if (showDay) {
1493 mHolidayMask.at(i) = true; 1493 mHolidayMask.at(i) = true;
1494 } else { 1494 } else {
1495 mHolidayMask.at(i) = false; 1495 mHolidayMask.at(i) = false;
1496 } 1496 }
1497 } 1497 }
1498 1498
1499 mAgenda->setHolidayMask(&mHolidayMask); 1499 mAgenda->setHolidayMask(&mHolidayMask);
1500 mAllDayAgenda->setHolidayMask(&mHolidayMask); 1500 mAllDayAgenda->setHolidayMask(&mHolidayMask);
1501} 1501}
1502 1502
1503void KOAgendaView::setContentsPos(int y) 1503void KOAgendaView::setContentsPos(int y)
1504{ 1504{
1505 mAgenda->setContentsPos(0,y); 1505 mAgenda->setContentsPos(0,y);
1506} 1506}
1507 1507
1508void KOAgendaView::clearSelection() 1508void KOAgendaView::clearSelection()
1509{ 1509{
1510 mAgenda->deselectItem(); 1510 mAgenda->deselectItem();
1511 mAllDayAgenda->deselectItem(); 1511 mAllDayAgenda->deselectItem();
1512} 1512}
1513 1513
1514void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart, 1514void KOAgendaView::newTimeSpanSelectedAllDay(int gxStart, int gyStart,
1515 int gxEnd, int gyEnd) 1515 int gxEnd, int gyEnd)
1516{ 1516{
1517 mTimeSpanInAllDay = true; 1517 mTimeSpanInAllDay = true;
1518 newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd); 1518 newTimeSpanSelected(gxStart,gyStart,gxEnd,gyEnd);
1519} 1519}
1520 1520
1521 1521
1522 1522
1523 1523
1524void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart, 1524void KOAgendaView::newTimeSpanSelected(int gxStart, int gyStart,
1525 int gxEnd, int gyEnd) 1525 int gxEnd, int gyEnd)
1526{ 1526{
1527 if (!mSelectedDates.count()) return; 1527 if (!mSelectedDates.count()) return;
1528 1528
1529 QDate dayStart = mSelectedDates[gxStart]; 1529 QDate dayStart = mSelectedDates[gxStart];
1530 QDate dayEnd = mSelectedDates[gxEnd]; 1530 QDate dayEnd = mSelectedDates[gxEnd];
1531 1531
1532 QTime timeStart = mAgenda->gyToTime(gyStart); 1532 QTime timeStart = mAgenda->gyToTime(gyStart);
1533 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); 1533 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 );
1534 1534
1535 QDateTime dtStart(dayStart,timeStart); 1535 QDateTime dtStart(dayStart,timeStart);
1536 QDateTime dtEnd(dayEnd,timeEnd); 1536 QDateTime dtEnd(dayEnd,timeEnd);
1537 1537
1538 mTimeSpanBegin = dtStart; 1538 mTimeSpanBegin = dtStart;
1539 mTimeSpanEnd = dtEnd; 1539 mTimeSpanEnd = dtEnd;
1540 1540
1541} 1541}
1542 1542
1543void KOAgendaView::deleteSelectedDateTime() 1543void KOAgendaView::deleteSelectedDateTime()
1544{ 1544{
1545 mTimeSpanBegin.setDate(QDate()); 1545 mTimeSpanBegin.setDate(QDate());
1546 mTimeSpanEnd.setDate(QDate()); 1546 mTimeSpanEnd.setDate(QDate());
1547 mTimeSpanInAllDay = false; 1547 mTimeSpanInAllDay = false;
1548} 1548}
1549 1549
1550void KOAgendaView::keyPressEvent ( QKeyEvent * e ) 1550void KOAgendaView::keyPressEvent ( QKeyEvent * e )
1551{ 1551{
1552 e->ignore(); 1552 e->ignore();
1553} 1553}
1554 1554
1555void KOAgendaView::scrollOneHourUp() 1555void KOAgendaView::scrollOneHourUp()
1556{ 1556{
1557 1557
1558 mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 ); 1558 mAgenda->scrollBy ( 0, -mAgenda->contentsHeight () / 24 );
1559} 1559}
1560void KOAgendaView::scrollOneHourDown() 1560void KOAgendaView::scrollOneHourDown()
1561{ 1561{
1562 mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 ); 1562 mAgenda->scrollBy ( 0, mAgenda->contentsHeight () / 24 );
1563} 1563}
1564 1564
1565void KOAgendaView::setStartHour( int h ) 1565void KOAgendaView::setStartHour( int h )
1566{ 1566{
1567 mAgenda->setStartHour( h ); 1567 mAgenda->setStartHour( h );
1568 1568
1569} 1569}
1570void KOAgendaView::setInitStartHour() 1570void KOAgendaView::setInitStartHour()
1571{ 1571{
1572 1572
1573 if ( KOPrefs::instance()->mCenterOnCurrentTime ) 1573 if ( KOPrefs::instance()->mCenterOnCurrentTime )
1574 setStartHour( QTime::currentTime ().hour() ); 1574 setStartHour( QTime::currentTime ().hour() );
1575 else 1575 else
1576 setStartHour( KOPrefs::instance()->mDayBegins ); 1576 setStartHour( KOPrefs::instance()->mDayBegins );
1577 1577
1578} 1578}
1579 1579
1580 1580
1581void KOAgendaView::updateTodo( Todo * t, int ) 1581void KOAgendaView::updateTodo( Todo * t, int )
1582{ 1582{
1583 if ( !isVisible() ) 1583 if ( !isVisible() )
1584 return; 1584 return;
1585 bool remove = false; 1585 bool remove = false;
1586 bool removeAD = false; 1586 bool removeAD = false;
1587 QDate da; 1587 QDate da;
1588 if ( t->hasCompletedDate() ) 1588 if ( t->hasCompletedDate() )
1589 da = t->completed().date(); 1589 da = t->completed().date();
1590 else 1590 else
1591 da = t->dtDue().date(); 1591 da = t->dtDue().date();
1592 if ( ! t->hasDueDate() && !t->hasCompletedDate() ) { 1592 if ( ! t->hasDueDate() && !t->hasCompletedDate() ) {
1593 remove = true; 1593 remove = true;
1594 removeAD = true; 1594 removeAD = true;
1595 } 1595 }
1596 else { 1596 else {
1597 bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ; 1597 bool overdue = (!t->isCompleted()) && (t->dtDue() < QDate::currentDate()) && KOPrefs::instance()->mShowTodoInAgenda ;
1598 if ( overdue && 1598 if ( overdue &&
1599 QDate::currentDate() >= mSelectedDates.first() && 1599 QDate::currentDate() >= mSelectedDates.first() &&
1600 QDate::currentDate() <= mSelectedDates.last()) { 1600 QDate::currentDate() <= mSelectedDates.last()) {
1601 removeAD = false; 1601 removeAD = false;
1602 remove = true; 1602 remove = true;
1603 } 1603 }
1604 else { 1604 else {
1605 1605
1606 if ( da < mSelectedDates.first() || 1606 if ( da < mSelectedDates.first() ||
1607 da > mSelectedDates.last() ) { 1607 da > mSelectedDates.last() ) {
1608 remove = true; 1608 remove = true;
1609 removeAD = true; 1609 removeAD = true;
1610 } else { 1610 } else {
1611 remove = t->doesFloat() && !t->hasCompletedDate(); 1611 remove = t->doesFloat() && !t->hasCompletedDate();
1612 removeAD = !remove; 1612 removeAD = !remove;
1613 } 1613 }
1614 } 1614 }
1615 } 1615 }
1616 int days = mSelectedDates.first().daysTo( da ); 1616 int days = mSelectedDates.first().daysTo( da );
1617 //qDebug("daysto %d %d %d", days, remove,removeAD ); 1617 //qDebug("daysto %d %d %d", days, remove,removeAD );
1618 mAgenda->updateTodo( t , days, remove); 1618 mAgenda->updateTodo( t , days, remove);
1619 if ( KOPrefs::instance()->mShowTodoInAgenda ) 1619 if ( KOPrefs::instance()->mShowTodoInAgenda )
1620 mAllDayAgenda->updateTodo( t , days, removeAD); 1620 mAllDayAgenda->updateTodo( t , days, removeAD);
1621 //qDebug("KOAgendaView::updateTodo( Todo *, int ) "); 1621 //qDebug("KOAgendaView::updateTodo( Todo *, int ) ");
1622 1622
1623} 1623}
diff --git a/korganizer/koeditorgeneral.cpp b/korganizer/koeditorgeneral.cpp
index b14ca43..abc80d4 100644
--- a/korganizer/koeditorgeneral.cpp
+++ b/korganizer/koeditorgeneral.cpp
@@ -1,515 +1,512 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qwidget.h> 24#include <qwidget.h>
25#include <qtooltip.h> 25#include <qtooltip.h>
26#include <qlayout.h> 26#include <qlayout.h>
27#include <qvbox.h> 27#include <qvbox.h>
28#include <qbuttongroup.h> 28#include <qbuttongroup.h>
29#include <qvgroupbox.h> 29#include <qvgroupbox.h>
30#include <qwidgetstack.h> 30#include <qwidgetstack.h>
31#include <qdatetime.h> 31#include <qdatetime.h>
32#include <qfile.h> 32#include <qfile.h>
33 33
34 34
35#include <kglobal.h> 35#include <kglobal.h>
36#include <kdebug.h> 36#include <kdebug.h>
37#include <klocale.h> 37#include <klocale.h>
38#include <kiconloader.h> 38#include <kiconloader.h>
39#include <kmessagebox.h> 39#include <kmessagebox.h>
40#include <kfiledialog.h> 40#include <kfiledialog.h>
41#include <kstandarddirs.h> 41#include <kstandarddirs.h>
42 42
43#include <libkcal/todo.h> 43#include <libkcal/todo.h>
44#include <libkcal/event.h> 44#include <libkcal/event.h>
45#include <libkdepim/categoryselectdialog.h> 45#include <libkdepim/categoryselectdialog.h>
46#include <libkdepim/kdateedit.h> 46#include <libkdepim/kdateedit.h>
47 47
48#include "koprefs.h" 48#include "koprefs.h"
49#include "koglobals.h" 49#include "koglobals.h"
50 50
51#include "koeditorgeneral.h" 51#include "koeditorgeneral.h"
52#include "kolocationbox.h" 52#include "kolocationbox.h"
53#ifndef DESKTOP_VERSION 53#ifndef DESKTOP_VERSION
54#include <qpe/qpeapplication.h> 54#include <qpe/qpeapplication.h>
55#else 55#else
56#include <qapplication.h> 56#include <qapplication.h>
57#endif 57#endif
58 58
59KOEditorGeneral::KOEditorGeneral(QObject* parent, const char* name) : 59KOEditorGeneral::KOEditorGeneral(QObject* parent, const char* name) :
60 QObject( parent, name) 60 QObject( parent, name)
61{ 61{
62} 62}
63 63
64KOEditorGeneral::~KOEditorGeneral() 64KOEditorGeneral::~KOEditorGeneral()
65{ 65{
66} 66}
67 67
68void KOEditorGeneral::initHeader(QWidget *parent,QBoxLayout *topLayout) 68void KOEditorGeneral::initHeader(QWidget *parent,QBoxLayout *topLayout)
69{ 69{
70 QGridLayout *headerLayout = new QGridLayout(topLayout); 70 QGridLayout *headerLayout = new QGridLayout(topLayout);
71 71
72#if 0 72#if 0
73 mOwnerLabel = new QLabel(i18n("Owner:"),parent); 73 mOwnerLabel = new QLabel(i18n("Owner:"),parent);
74 headerLayout->addMultiCellWidget(mOwnerLabel,0,0,0,1); 74 headerLayout->addMultiCellWidget(mOwnerLabel,0,0,0,1);
75#endif 75#endif
76 76
77 QLabel *summaryLabel = new QLabel(i18n("Summary:"),parent); 77 QLabel *summaryLabel = new QLabel(i18n("Summary:"),parent);
78 headerLayout->addWidget(summaryLabel,1,0); 78 headerLayout->addWidget(summaryLabel,1,0);
79 79
80 mSummaryEdit = new KOLocationBox(TRUE,parent, 10); 80 mSummaryEdit = new KOLocationBox(TRUE,parent, 10);
81 mSummaryEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); 81 mSummaryEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) );
82 //mSummaryEdit->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5 ,(QSizePolicy::SizeType)3 ,FALSE) ); 82 //mSummaryEdit->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5 ,(QSizePolicy::SizeType)3 ,FALSE) );
83 //qDebug("h %d %d ", summaryLabel->sizeHint().height(),mSummaryEdit->sizeHint().height() ); 83 //qDebug("h %d %d ", summaryLabel->sizeHint().height(),mSummaryEdit->sizeHint().height() );
84 int hei = (summaryLabel->sizeHint().height() + mSummaryEdit->sizeHint().height())/2; 84 int hei = (summaryLabel->sizeHint().height() + mSummaryEdit->sizeHint().height())/2;
85 if ( QApplication::desktop()->width() > 320 ) 85 if ( QApplication::desktop()->width() > 320 )
86 mSummaryEdit->setMaximumHeight( hei +6 ); 86 mSummaryEdit->setMaximumHeight( hei +6 );
87 //qDebug("%d %d %d %d %d %d ", QSizePolicy::Fixed , QSizePolicy::Minimum , QSizePolicy:: Maximum , QSizePolicy:: Preferred , QSizePolicy:: MinimumExpanding , QSizePolicy::Expanding ); 87 //qDebug("%d %d %d %d %d %d ", QSizePolicy::Fixed , QSizePolicy::Minimum , QSizePolicy:: Maximum , QSizePolicy:: Preferred , QSizePolicy:: MinimumExpanding , QSizePolicy::Expanding );
88 // SizeType { Fixed = 0, Minimum = MayGrow, Maximum = MayShrink, Preferred = MayGrow|MayShrink, MinimumExpanding = Minimum|ExpMask, Expanding = MinimumExpanding|MayShrink } 88 // SizeType { Fixed = 0, Minimum = MayGrow, Maximum = MayShrink, Preferred = MayGrow|MayShrink, MinimumExpanding = Minimum|ExpMask, Expanding = MinimumExpanding|MayShrink }
89 // mSummaryEdit = new QLineEdit(parent); 89 // mSummaryEdit = new QLineEdit(parent);
90 headerLayout->addWidget(mSummaryEdit,1,1); 90 headerLayout->addWidget(mSummaryEdit,1,1);
91 connect ( mSummaryEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); 91 connect ( mSummaryEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) );
92 92
93 QLabel *locationLabel = new QLabel(i18n("Location:"),parent); 93 QLabel *locationLabel = new QLabel(i18n("Location:"),parent);
94 headerLayout->addWidget(locationLabel,2,0); 94 headerLayout->addWidget(locationLabel,2,0);
95 95
96 mLocationEdit = new KOLocationBox(TRUE,parent,10); 96 mLocationEdit = new KOLocationBox(TRUE,parent,10);
97 mLocationEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); 97 mLocationEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) );
98 if ( QApplication::desktop()->width() > 320 ) 98 if ( QApplication::desktop()->width() > 320 )
99 mLocationEdit->setMaximumHeight( hei + 6); 99 mLocationEdit->setMaximumHeight( hei + 6);
100 100
101 // mLocationEdit = new QLineEdit(parent); 101 // mLocationEdit = new QLineEdit(parent);
102 connect ( mLocationEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); 102 connect ( mLocationEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) );
103 headerLayout->addWidget(mLocationEdit,2,1); 103 headerLayout->addWidget(mLocationEdit,2,1);
104 headerLayout->setColStretch( 1, 10); 104 headerLayout->setColStretch( 1, 10);
105} 105}
106void KOEditorGeneral::setFocusOn( int i ) 106void KOEditorGeneral::setFocusOn( int i )
107{ 107{
108 qApp->processEvents(); 108 qApp->processEvents();
109 if ( i == 1 ) { 109 if ( i == 1 ) {
110 mDescriptionEdit->setFocus(); 110 mDescriptionEdit->setFocus();
111 mDescriptionEdit->setCursorPosition( mDescriptionEdit->numLines (), 333); 111 mDescriptionEdit->setCursorPosition( mDescriptionEdit->numLines (), 333);
112 } 112 }
113 if ( i == 2 ) { 113 if ( i == 2 ) {
114 mSummaryEdit->setFocus(); 114 mSummaryEdit->setFocus();
115 } 115 }
116 116
117} 117}
118void KOEditorGeneral::editCategories() 118void KOEditorGeneral::editCategories()
119{ 119{
120 // qDebug("KOEditorGeneral::editCategories() "); 120 // qDebug("KOEditorGeneral::editCategories() ");
121 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); 121 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 );
122 connect(csd,SIGNAL(categoriesSelected(const QString &)), this ,SLOT(setCategories(const QString &))); 122 connect(csd,SIGNAL(categoriesSelected(const QString &)), this ,SLOT(setCategories(const QString &)));
123 //KOGlobals::fitDialogToScreen( csd ); 123 //KOGlobals::fitDialogToScreen( csd );
124 csd->setColorEnabled(); 124 csd->setColorEnabled();
125 csd->setSelected( QStringList::split (",", mCategoriesLabel->text()) ); 125 csd->setSelected( QStringList::split (",", mCategoriesLabel->text()) );
126 csd->exec(); 126 csd->exec();
127 delete csd; 127 delete csd;
128} 128}
129void KOEditorGeneral::initCategories(QWidget *parent, QBoxLayout *topLayout) 129void KOEditorGeneral::initCategories(QWidget *parent, QBoxLayout *topLayout)
130{ 130{
131 QBoxLayout *categoriesLayout = new QHBoxLayout( topLayout ); 131 QBoxLayout *categoriesLayout = new QHBoxLayout( topLayout );
132 132
133 mCategoriesButton = new QPushButton(parent); 133 mCategoriesButton = new QPushButton(parent);
134 mCategoriesButton->setText(i18n("Categories...")); 134 mCategoriesButton->setText(i18n("Categories..."));
135 connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() )); 135 connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() ));
136 categoriesLayout->addWidget(mCategoriesButton); 136 categoriesLayout->addWidget(mCategoriesButton);
137 137
138 mCategoriesLabel = new QLabel(parent); 138 mCategoriesLabel = new QLabel(parent);
139 mCategoriesLabel->setFrameStyle(QFrame::Panel|QFrame::Sunken); 139 mCategoriesLabel->setFrameStyle(QFrame::Panel|QFrame::Sunken);
140 categoriesLayout->addWidget(mCategoriesLabel,1); 140 categoriesLayout->addWidget(mCategoriesLabel,1);
141} 141}
142 142
143void KOEditorGeneral::initSecrecy(QWidget *parent, QBoxLayout *topLayout) 143void KOEditorGeneral::initSecrecy(QWidget *parent, QBoxLayout *topLayout)
144{ 144{
145 QBoxLayout *secrecyLayout = new QHBoxLayout( topLayout ); 145 QBoxLayout *secrecyLayout = new QHBoxLayout( topLayout );
146 146
147 QLabel *secrecyLabel = new QLabel(i18n("Access:"),parent); 147 QLabel *secrecyLabel = new QLabel(i18n("Access:"),parent);
148 mCancelBox = new QCheckBox ( i18n("Cancelled"), parent); 148 mCancelBox = new QCheckBox ( i18n("Cancelled"), parent);
149 secrecyLayout->addWidget(mCancelBox); 149 secrecyLayout->addWidget(mCancelBox);
150 secrecyLayout->addWidget(secrecyLabel); 150 secrecyLayout->addWidget(secrecyLabel);
151 151
152 mSecrecyCombo = new QComboBox(parent); 152 mSecrecyCombo = new QComboBox(parent);
153 mSecrecyCombo->insertStringList(Incidence::secrecyList()); 153 mSecrecyCombo->insertStringList(Incidence::secrecyList());
154 secrecyLayout->addWidget(mSecrecyCombo); 154 secrecyLayout->addWidget(mSecrecyCombo);
155} 155}
156 156
157void KOEditorGeneral::initDescription(QWidget *parent,QBoxLayout *topLayout) 157void KOEditorGeneral::initDescription(QWidget *parent,QBoxLayout *topLayout)
158{ 158{
159 mDescriptionEdit = new KTextEdit(parent); 159 mDescriptionEdit = new KTextEdit(parent);
160 mDescriptionEdit->setFont(KOPrefs::instance()->mEditBoxFont ); 160 mDescriptionEdit->setFont(KOPrefs::instance()->mEditBoxFont );
161 mDescriptionEdit->append(""); 161 mDescriptionEdit->append("");
162 mDescriptionEdit->setReadOnly(false); 162 mDescriptionEdit->setReadOnly(false);
163 mDescriptionEdit->setOverwriteMode(false); 163 mDescriptionEdit->setOverwriteMode(false);
164 mDescriptionEdit->setWordWrap( KTextEdit::WidgetWidth ); 164 mDescriptionEdit->setWordWrap( KTextEdit::WidgetWidth );
165 topLayout->addWidget(mDescriptionEdit); 165 topLayout->addWidget(mDescriptionEdit);
166#ifndef DESKTOP_VERSION 166#ifndef DESKTOP_VERSION
167 QPEApplication::setStylusOperation( mDescriptionEdit, QPEApplication::RightOnHold ); 167 QPEApplication::setStylusOperation( mDescriptionEdit, QPEApplication::RightOnHold );
168#endif 168#endif
169 169
170} 170}
171 171
172void KOEditorGeneral::initAlarm(QWidget *parent,QBoxLayout *topLayout) 172void KOEditorGeneral::initAlarm(QWidget *parent,QBoxLayout *topLayout)
173{ 173{
174 QBoxLayout *alarmLayout = new QHBoxLayout(topLayout); 174 QBoxLayout *alarmLayout = new QHBoxLayout(topLayout);
175 175
176 //mAlarmBell = new QLabel(parent); 176 //mAlarmBell = new QLabel(parent);
177 //mAlarmBell->setPixmap(SmallIcon("bell")); 177 //mAlarmBell->setPixmap(SmallIcon("bell"));
178 //alarmLayout->addWidget(mAlarmBell); 178 //alarmLayout->addWidget(mAlarmBell);
179 if ( QApplication::desktop()->width() < 320 ) 179 if ( QApplication::desktop()->width() < 320 )
180 mAlarmButton = new QCheckBox(i18n("Rem."),parent); 180 mAlarmButton = new QCheckBox(i18n("Rem."),parent);
181 else 181 else
182 mAlarmButton = new QCheckBox(i18n("Reminder:"),parent); 182 mAlarmButton = new QCheckBox(i18n("Reminder:"),parent);
183 183
184 connect(mAlarmButton, SIGNAL(toggled(bool)), SLOT(enableAlarmEdit(bool))); 184 connect(mAlarmButton, SIGNAL(toggled(bool)), SLOT(enableAlarmEdit(bool)));
185 alarmLayout->addWidget(mAlarmButton); 185 alarmLayout->addWidget(mAlarmButton);
186 186
187 mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ; 187 mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ;
188 mAlarmTimeEdit->setButtonSymbols( QSpinBox::PlusMinus ); 188 mAlarmTimeEdit->setButtonSymbols( QSpinBox::PlusMinus );
189 alarmLayout->addWidget(mAlarmTimeEdit); 189 alarmLayout->addWidget(mAlarmTimeEdit);
190 mAlarmIncrCombo = new QComboBox(false, parent); 190 mAlarmIncrCombo = new QComboBox(false, parent);
191 if ( QApplication::desktop()->width() < 320 ) { 191 if ( QApplication::desktop()->width() < 320 ) {
192 mAlarmIncrCombo->insertItem(i18n("min")); 192 mAlarmIncrCombo->insertItem(i18n("min"));
193 mAlarmIncrCombo->insertItem(i18n("hou")); 193 mAlarmIncrCombo->insertItem(i18n("hou"));
194 mAlarmIncrCombo->insertItem(i18n("day")); 194 mAlarmIncrCombo->insertItem(i18n("day"));
195 mAlarmTimeEdit->setMaximumWidth( mAlarmTimeEdit->sizeHint().width() ); 195 mAlarmTimeEdit->setMaximumWidth( mAlarmTimeEdit->sizeHint().width() );
196 mAlarmIncrCombo->setMaximumWidth( mAlarmIncrCombo->sizeHint().width() ); 196 mAlarmIncrCombo->setMaximumWidth( mAlarmIncrCombo->sizeHint().width() );
197 } else { 197 } else {
198 mAlarmIncrCombo->insertItem(i18n("minute(s)")); 198 mAlarmIncrCombo->insertItem(i18n("minute(s)"));
199 mAlarmIncrCombo->insertItem(i18n("hour(s)")); 199 mAlarmIncrCombo->insertItem(i18n("hour(s)"));
200 mAlarmIncrCombo->insertItem(i18n("day(s)")); 200 mAlarmIncrCombo->insertItem(i18n("day(s)"));
201 } 201 }
202 202
203 // mAlarmIncrCombo->setMinimumHeight(20); 203 // mAlarmIncrCombo->setMinimumHeight(20);
204 alarmLayout->addWidget(mAlarmIncrCombo); 204 alarmLayout->addWidget(mAlarmIncrCombo);
205 mAlarmSoundButton = new QPushButton(parent); 205 mAlarmSoundButton = new QPushButton(parent);
206 mAlarmSoundButton->setPixmap(SmallIcon("playsound")); 206 mAlarmSoundButton->setPixmap(SmallIcon("playsound"));
207 mAlarmSoundButton->setToggleButton(true); 207 mAlarmSoundButton->setToggleButton(true);
208 QToolTip::add(mAlarmSoundButton, i18n("No sound set")); 208 QToolTip::add(mAlarmSoundButton, i18n("No sound set"));
209 connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound())); 209 connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound()));
210 alarmLayout->addWidget(mAlarmSoundButton); 210 alarmLayout->addWidget(mAlarmSoundButton);
211 211
212 mAlarmProgramButton = new QPushButton(parent); 212 mAlarmProgramButton = new QPushButton(parent);
213 mAlarmProgramButton->setPixmap(SmallIcon("run")); 213 mAlarmProgramButton->setPixmap(SmallIcon("run"));
214 mAlarmProgramButton->setToggleButton(true); 214 mAlarmProgramButton->setToggleButton(true);
215 QToolTip::add(mAlarmProgramButton, i18n("No program set")); 215 QToolTip::add(mAlarmProgramButton, i18n("No program set"));
216 connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram())); 216 connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram()));
217 alarmLayout->addWidget(mAlarmProgramButton); 217 alarmLayout->addWidget(mAlarmProgramButton);
218 mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 ); 218 mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 );
219 mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 ); 219 mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 );
220 // if ( KOPrefs::instance()->mCompactDialogs ) { 220 // if ( KOPrefs::instance()->mCompactDialogs ) {
221 // mAlarmSoundButton->hide(); 221 // mAlarmSoundButton->hide();
222 // mAlarmProgramButton->hide(); 222 // mAlarmProgramButton->hide();
223 // } 223 // }
224} 224}
225 225
226void KOEditorGeneral::pickAlarmSound() 226void KOEditorGeneral::pickAlarmSound()
227{ 227{
228 228
229 qDebug("KOEditorGeneral::pickAlarmSound() %d",mAlarmSoundButton->isOn() ); 229 qDebug("KOEditorGeneral::pickAlarmSound() %d",mAlarmSoundButton->isOn() );
230 //QString prefix = mAlarmSound; 230
231 if (!mAlarmSoundButton->isOn()) { 231 bool oldState = mAlarmSoundButton->isOn();
232
233 QString fileName(KFileDialog::getOpenFileName(mAlarmSound,
234 i18n("*.wav|Wav Files"), 0));
235 if (!fileName.isEmpty()) {
236 mAlarmSound = fileName;
237 QToolTip::remove(mAlarmSoundButton);
238 QString dispStr = i18n("Playing '%1'").arg(fileName);
239 QToolTip::add(mAlarmSoundButton, dispStr);
240 mAlarmProgramButton->setOn(false);
232 mAlarmSoundButton->setOn(true); 241 mAlarmSoundButton->setOn(true);
233 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); 242 QToolTip::add(mAlarmProgramButton, i18n("No program set"));
234 } else { 243 } else {
235 QString fileName(KFileDialog::getOpenFileName(mAlarmSound, 244 mAlarmProgramButton->setOn(oldState);
236 i18n("*.wav|Wav Files"), 0)); 245 mAlarmSoundButton->setOn(!oldState);
237 if (!fileName.isEmpty()) { 246
238 mAlarmSound = fileName; 247
239 QToolTip::remove(mAlarmSoundButton);
240 QString dispStr = i18n("Playing '%1'").arg(fileName);
241 QToolTip::add(mAlarmSoundButton, dispStr);
242 mAlarmProgramButton->setOn(false);
243 mAlarmSoundButton->setOn(true);
244 } else {
245 mAlarmProgramButton->setOn(true);
246 mAlarmSoundButton->setOn(false);
247
248 }
249 } 248 }
250#if 0 249
251 if (mAlarmProgramButton->isOn()) 250 if (mAlarmProgramButton->isOn())
252 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); 251 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) );
253 if ( mAlarmSoundButton->isOn()) 252 if ( mAlarmSoundButton->isOn())
254 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); 253 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) );
255#endif 254
256} 255}
257 256
258void KOEditorGeneral::pickAlarmProgram() 257void KOEditorGeneral::pickAlarmProgram()
259{ 258{
260 if (!mAlarmProgramButton->isOn()) { 259 bool oldState = mAlarmProgramButton->isOn();
260
261 QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm: ") , 0));
262 if (!fileName.isEmpty()) {
263 mAlarmProgram = fileName;
264 QToolTip::remove(mAlarmProgramButton);
265 QString dispStr = i18n("Running '%1'").arg(fileName);
266 QToolTip::add(mAlarmProgramButton, dispStr);
267 mAlarmSoundButton->setOn(false);
261 mAlarmProgramButton->setOn(true); 268 mAlarmProgramButton->setOn(true);
262 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); 269 QToolTip::add(mAlarmSoundButton, i18n("No sound set"));
263 } else { 270 } else {
264 QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm: ") , 0)); 271 mAlarmProgramButton->setOn(!oldState);
265 if (!fileName.isEmpty()) { 272 mAlarmSoundButton->setOn(oldState);
266 mAlarmProgram = fileName;
267 QToolTip::remove(mAlarmProgramButton);
268 QString dispStr = i18n("Running '%1'").arg(fileName);
269 QToolTip::add(mAlarmProgramButton, dispStr);
270 mAlarmSoundButton->setOn(false);
271 mAlarmProgramButton->setOn(true);
272 } else {
273 mAlarmProgramButton->setOn(false);
274 mAlarmSoundButton->setOn(true);
275 }
276 } 273 }
277#if 0 274
278 if (mAlarmProgramButton->isOn()) 275 if (mAlarmProgramButton->isOn())
279 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); 276 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) );
280 if ( mAlarmSoundButton->isOn()) 277 if ( mAlarmSoundButton->isOn())
281 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); 278 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) );
282#endif 279
283} 280}
284 281
285 282
286QString KOEditorGeneral::getFittingPath( const QString s ) 283QString KOEditorGeneral::getFittingPath( const QString s )
287{ 284{
288 int maxlen = 50; 285 int maxlen = 50;
289 if ( QApplication::desktop()->width() < 640 ) { 286 if ( QApplication::desktop()->width() < 640 ) {
290 if ( QApplication::desktop()->width() < 320 ) 287 if ( QApplication::desktop()->width() < 320 )
291 maxlen = 22; 288 maxlen = 22;
292 else 289 else
293 maxlen = 35; 290 maxlen = 35;
294 } 291 }
295 if ( s.length() > maxlen ) { 292 if ( s.length() > maxlen ) {
296 return "..."+s.right(maxlen -3); 293 return "..."+s.right(maxlen -3);
297 } 294 }
298 return s; 295 return s;
299} 296}
300 297
301void KOEditorGeneral::enableAlarmEdit(bool enable) 298void KOEditorGeneral::enableAlarmEdit(bool enable)
302{ 299{
303 if ( enable ) { 300 if ( enable ) {
304 if (!mAlarmProgramButton->isOn() && !mAlarmSoundButton->isOn()) { 301 if (!mAlarmProgramButton->isOn() && !mAlarmSoundButton->isOn()) {
305 mAlarmSoundButton->setOn( true ); 302 mAlarmSoundButton->setOn( true );
306 if ( mAlarmSound.isEmpty() ) 303 if ( mAlarmSound.isEmpty() )
307 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; 304 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
308 else { 305 else {
309 if ( ! QFile::exists( mAlarmSound ) ) 306 if ( ! QFile::exists( mAlarmSound ) )
310 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; 307 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
311 } 308 }
312 } 309 }
313 } 310 }
314 ((QWidget*)parent())->topLevelWidget()->setCaption(mAlarmMessage); 311 ((QWidget*)parent())->topLevelWidget()->setCaption(mAlarmMessage);
315 mAlarmTimeEdit->setEnabled(enable); 312 mAlarmTimeEdit->setEnabled(enable);
316 mAlarmSoundButton->setEnabled(enable); 313 mAlarmSoundButton->setEnabled(enable);
317 mAlarmProgramButton->setEnabled(enable); 314 mAlarmProgramButton->setEnabled(enable);
318 mAlarmIncrCombo->setEnabled(enable); 315 mAlarmIncrCombo->setEnabled(enable);
319} 316}
320 317
321void KOEditorGeneral::disableAlarmEdit(bool disable) 318void KOEditorGeneral::disableAlarmEdit(bool disable)
322{ 319{
323 enableAlarmEdit( !disable ); 320 enableAlarmEdit( !disable );
324} 321}
325 322
326void KOEditorGeneral::enableAlarm( bool enable ) 323void KOEditorGeneral::enableAlarm( bool enable )
327{ 324{
328 enableAlarmEdit( enable ); 325 enableAlarmEdit( enable );
329} 326}
330 327
331void KOEditorGeneral::alarmDisable(bool disable) 328void KOEditorGeneral::alarmDisable(bool disable)
332{ 329{
333 if (!disable) { 330 if (!disable) {
334 //mAlarmBell->setEnabled(true); 331 //mAlarmBell->setEnabled(true);
335 mAlarmButton->setEnabled(true); 332 mAlarmButton->setEnabled(true);
336 } else { 333 } else {
337 //mAlarmBell->setEnabled(false); 334 //mAlarmBell->setEnabled(false);
338 mAlarmButton->setEnabled(false); 335 mAlarmButton->setEnabled(false);
339 mAlarmButton->setChecked(false); 336 mAlarmButton->setChecked(false);
340 mAlarmTimeEdit->setEnabled(false); 337 mAlarmTimeEdit->setEnabled(false);
341 mAlarmSoundButton->setEnabled(false); 338 mAlarmSoundButton->setEnabled(false);
342 mAlarmProgramButton->setEnabled(false); 339 mAlarmProgramButton->setEnabled(false);
343 mAlarmIncrCombo->setEnabled(false); 340 mAlarmIncrCombo->setEnabled(false);
344 } 341 }
345} 342}
346 343
347void KOEditorGeneral::setCategories(const QString &str) 344void KOEditorGeneral::setCategories(const QString &str)
348{ 345{
349 mCategoriesLabel->setText(str); 346 mCategoriesLabel->setText(str);
350} 347}
351 348
352void KOEditorGeneral::setDefaults(bool allDay) 349void KOEditorGeneral::setDefaults(bool allDay)
353{ 350{
354#if 0 351#if 0
355 mOwnerLabel->setText(i18n("Owner: ") + KOPrefs::instance()->fullName()); 352 mOwnerLabel->setText(i18n("Owner: ") + KOPrefs::instance()->fullName());
356#endif 353#endif
357 354
358 mAlarmMessage = i18n("Edit new item"); 355 mAlarmMessage = i18n("Edit new item");
359 enableAlarmEdit( !allDay ); 356 enableAlarmEdit( !allDay );
360 357
361 // TODO: Implement a KPrefsComboItem to solve this in a clean way. 358 // TODO: Implement a KPrefsComboItem to solve this in a clean way.
362 int alarmTime; 359 int alarmTime;
363 int a[] = { 1,5,10,15,30,60,180, 1440 }; 360 int a[] = { 1,5,10,15,30,60,180, 1440 };
364 int index = KOPrefs::instance()->mAlarmTime; 361 int index = KOPrefs::instance()->mAlarmTime;
365 if (index < 0 || index > 7) { 362 if (index < 0 || index > 7) {
366 alarmTime = 15; 363 alarmTime = 15;
367 } else { 364 } else {
368 alarmTime = a[index]; 365 alarmTime = a[index];
369 } 366 }
370 mAlarmButton ->setChecked( false ); 367 mAlarmButton ->setChecked( false );
371 mAlarmTimeEdit->setValue(alarmTime); 368 mAlarmTimeEdit->setValue(alarmTime);
372 mAlarmIncrCombo->setCurrentItem(0); 369 mAlarmIncrCombo->setCurrentItem(0);
373 enableAlarmEdit( false ); 370 enableAlarmEdit( false );
374 //alarmDisable (false); 371 //alarmDisable (false);
375 mSecrecyCombo->setCurrentItem(Incidence::SecrecyPublic); 372 mSecrecyCombo->setCurrentItem(Incidence::SecrecyPublic);
376 mCancelBox->setChecked( false ); 373 mCancelBox->setChecked( false );
377 mSummaryEdit->setEditText(""); 374 mSummaryEdit->setEditText("");
378 mLocationEdit->setEditText(""); 375 mLocationEdit->setEditText("");
379 mDescriptionEdit->setText(""); 376 mDescriptionEdit->setText("");
380 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; 377 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
381 setCategories(""); 378 setCategories("");
382} 379}
383void KOEditorGeneral::setSecrecy( int num ) 380void KOEditorGeneral::setSecrecy( int num )
384{ 381{
385 mSecrecyCombo->setCurrentItem(num); 382 mSecrecyCombo->setCurrentItem(num);
386} 383}
387void KOEditorGeneral::readIncidence(Incidence *event) 384void KOEditorGeneral::readIncidence(Incidence *event)
388{ 385{
389 386
390 mAlarmMessage = event->summary(); 387 mAlarmMessage = event->summary();
391 if ( ! event->location().isEmpty() ) 388 if ( ! event->location().isEmpty() )
392 mAlarmMessage += " ("+event->location()+")"; 389 mAlarmMessage += " ("+event->location()+")";
393 mAlarmIncrCombo->setCurrentItem(0); 390 mAlarmIncrCombo->setCurrentItem(0);
394 mSummaryEdit->setEditText(event->summary()); 391 mSummaryEdit->setEditText(event->summary());
395 mLocationEdit->setEditText(event->location()); 392 mLocationEdit->setEditText(event->location());
396 mDescriptionEdit->setText(event->description()); 393 mDescriptionEdit->setText(event->description());
397 394
398#if 0 395#if 0
399 // organizer information 396 // organizer information
400 mOwnerLabel->setText(i18n("Owner: ") + event->organizer()); 397 mOwnerLabel->setText(i18n("Owner: ") + event->organizer());
401#endif 398#endif
402 399
403 enableAlarmEdit( event->isAlarmEnabled() ); 400 enableAlarmEdit( event->isAlarmEnabled() );
404 //qDebug("KOEditorGeneral::readIncidence(Incidence *event) "); 401 //qDebug("KOEditorGeneral::readIncidence(Incidence *event) ");
405 if(!event->isAlarmEnabled()) { 402 if(!event->isAlarmEnabled()) {
406 // TODO: Implement a KPrefsComboItem to solve this in a clean way. 403 // TODO: Implement a KPrefsComboItem to solve this in a clean way.
407 int alarmTime; 404 int alarmTime;
408 int a[] = { 1,5,10,15,30,60,180, 1440 }; 405 int a[] = { 1,5,10,15,30,60,180, 1440 };
409 int index = KOPrefs::instance()->mAlarmTime; 406 int index = KOPrefs::instance()->mAlarmTime;
410 if (index < 0 || index > 7) { 407 if (index < 0 || index > 7) {
411 alarmTime = 15; 408 alarmTime = 15;
412 } else { 409 } else {
413 alarmTime = a[index]; 410 alarmTime = a[index];
414 } 411 }
415 mAlarmTimeEdit->setValue(alarmTime); 412 mAlarmTimeEdit->setValue(alarmTime);
416 } 413 }
417 mAlarmButton->setChecked( event->isAlarmEnabled() ); 414 mAlarmButton->setChecked( event->isAlarmEnabled() );
418 mSecrecyCombo->setCurrentItem(event->secrecy()); 415 mSecrecyCombo->setCurrentItem(event->secrecy());
419 mCancelBox->setChecked( event->cancelled() ); 416 mCancelBox->setChecked( event->cancelled() );
420 mAlarmProgramButton->setOn(false); 417 mAlarmProgramButton->setOn(false);
421 mAlarmSoundButton->setOn(false); 418 mAlarmSoundButton->setOn(false);
422 419
423 // set up alarm stuff 420 // set up alarm stuff
424 QPtrList<Alarm> alarms = event->alarms(); 421 QPtrList<Alarm> alarms = event->alarms();
425 Alarm* alarm; 422 Alarm* alarm;
426 mAlarmIncrCombo->setCurrentItem(0); 423 mAlarmIncrCombo->setCurrentItem(0);
427 for ( alarm = alarms.first(); alarm; alarm = alarms.next() ) { 424 for ( alarm = alarms.first(); alarm; alarm = alarms.next() ) {
428 int offset; 425 int offset;
429 if ( alarm->hasTime() ) { 426 if ( alarm->hasTime() ) {
430 QDateTime t = alarm->time(); 427 QDateTime t = alarm->time();
431 offset = event->dtStart().secsTo( t ); 428 offset = event->dtStart().secsTo( t );
432 } else { 429 } else {
433 offset = alarm->startOffset().asSeconds(); 430 offset = alarm->startOffset().asSeconds();
434 } 431 }
435 if ( offset != 0 ) { 432 if ( offset != 0 ) {
436 offset = offset / -60; // make minutes 433 offset = offset / -60; // make minutes
437 if (offset % 60 == 0) { // divides evenly into hours? 434 if (offset % 60 == 0) { // divides evenly into hours?
438 offset = offset / 60; 435 offset = offset / 60;
439 mAlarmIncrCombo->setCurrentItem(1); 436 mAlarmIncrCombo->setCurrentItem(1);
440 if (offset % 24 == 0) { // divides evenly into days? 437 if (offset % 24 == 0) { // divides evenly into days?
441 offset = offset / 24; 438 offset = offset / 24;
442 mAlarmIncrCombo->setCurrentItem(2); 439 mAlarmIncrCombo->setCurrentItem(2);
443 } 440 }
444 } 441 }
445 } 442 }
446 mAlarmTimeEdit->setValue( offset ); 443 mAlarmTimeEdit->setValue( offset );
447 if (alarm->type() == Alarm::Procedure) { 444 if (alarm->type() == Alarm::Procedure) {
448 445
449 mAlarmProgram = alarm->programFile(); 446 mAlarmProgram = alarm->programFile();
450 mAlarmProgramButton->setOn(true); 447 mAlarmProgramButton->setOn(true);
451 QString dispStr = i18n("Running '%1'").arg(mAlarmProgram); 448 QString dispStr = i18n("Running '%1'").arg(mAlarmProgram);
452 QToolTip::add(mAlarmProgramButton, dispStr); 449 QToolTip::add(mAlarmProgramButton, dispStr);
453 } 450 }
454 else if (alarm->type() == Alarm::Audio) { 451 else if (alarm->type() == Alarm::Audio) {
455 mAlarmSound = alarm->audioFile(); 452 mAlarmSound = alarm->audioFile();
456 if ( ! QFile::exists( mAlarmSound ) ) 453 if ( ! QFile::exists( mAlarmSound ) )
457 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; 454 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
458 mAlarmSoundButton->setOn(true); 455 mAlarmSoundButton->setOn(true);
459 QString dispStr = i18n("Playing '%1'").arg(mAlarmSound); 456 QString dispStr = i18n("Playing '%1'").arg(mAlarmSound);
460 QToolTip::add(mAlarmSoundButton, dispStr); 457 QToolTip::add(mAlarmSoundButton, dispStr);
461 } 458 }
462 mAlarmButton->setChecked(alarm->enabled()); 459 mAlarmButton->setChecked(alarm->enabled());
463 enableAlarmEdit( alarm->enabled() ); 460 enableAlarmEdit( alarm->enabled() );
464 //qDebug("nableAlarmEdit( alarm->enabled() )********* "); 461 //qDebug("nableAlarmEdit( alarm->enabled() )********* ");
465 // TODO: Deal with multiple alarms 462 // TODO: Deal with multiple alarms
466 break; // For now, stop after the first alarm 463 break; // For now, stop after the first alarm
467 } 464 }
468 465
469 setCategories(event->categoriesStr()); 466 setCategories(event->categoriesStr());
470} 467}
471 468
472void KOEditorGeneral::writeIncidence(Incidence *event) 469void KOEditorGeneral::writeIncidence(Incidence *event)
473{ 470{
474 // kdDebug() << "KOEditorGeneral::writeEvent()" << endl; 471 // kdDebug() << "KOEditorGeneral::writeEvent()" << endl;
475 mLocationEdit->save(KOLocationBox::LOCATION); 472 mLocationEdit->save(KOLocationBox::LOCATION);
476 event->setSummary(mSummaryEdit->currentText()); 473 event->setSummary(mSummaryEdit->currentText());
477 event->setLocation(mLocationEdit->currentText()); 474 event->setLocation(mLocationEdit->currentText());
478 event->setDescription(mDescriptionEdit->text()); 475 event->setDescription(mDescriptionEdit->text());
479 event->setCategories(mCategoriesLabel->text()); 476 event->setCategories(mCategoriesLabel->text());
480 event->setSecrecy(mSecrecyCombo->currentItem()); 477 event->setSecrecy(mSecrecyCombo->currentItem());
481 event->setCancelled(mCancelBox->isChecked() );; 478 event->setCancelled(mCancelBox->isChecked() );;
482 // alarm stuff 479 // alarm stuff
483 if (mAlarmButton->isChecked()) { 480 if (mAlarmButton->isChecked()) {
484 if (event->alarms().count() == 0) 481 if (event->alarms().count() == 0)
485 event->newAlarm(); 482 event->newAlarm();
486 QPtrList<Alarm> alarms = event->alarms(); 483 QPtrList<Alarm> alarms = event->alarms();
487 Alarm *alarm; 484 Alarm *alarm;
488 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { 485 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) {
489 alarm->setEnabled(true); 486 alarm->setEnabled(true);
490 int j = mAlarmTimeEdit->value()* -60; 487 int j = mAlarmTimeEdit->value()* -60;
491 if (mAlarmIncrCombo->currentItem() == 1) 488 if (mAlarmIncrCombo->currentItem() == 1)
492 j = j * 60; 489 j = j * 60;
493 else if (mAlarmIncrCombo->currentItem() == 2) 490 else if (mAlarmIncrCombo->currentItem() == 2)
494 j = j * (60 * 24); 491 j = j * (60 * 24);
495 alarm->setStartOffset( j ); 492 alarm->setStartOffset( j );
496 493
497 if (!mAlarmProgram.isEmpty() && mAlarmProgramButton->isOn()) { 494 if (!mAlarmProgram.isEmpty() && mAlarmProgramButton->isOn()) {
498 alarm->setProcedureAlarm(mAlarmProgram); 495 alarm->setProcedureAlarm(mAlarmProgram);
499 } 496 }
500 else if (!mAlarmSound.isEmpty() && mAlarmSoundButton->isOn()) 497 else if (!mAlarmSound.isEmpty() && mAlarmSoundButton->isOn())
501 alarm->setAudioAlarm(mAlarmSound); 498 alarm->setAudioAlarm(mAlarmSound);
502 else 499 else
503 alarm->setType(Alarm::Invalid); 500 alarm->setType(Alarm::Invalid);
504 //alarm->setAudioAlarm("default"); 501 //alarm->setAudioAlarm("default");
505 // TODO: Deal with multiple alarms 502 // TODO: Deal with multiple alarms
506 break; // For now, stop after the first alarm 503 break; // For now, stop after the first alarm
507 } 504 }
508 } else { 505 } else {
509 Alarm* alarm = event->alarms().first(); 506 Alarm* alarm = event->alarms().first();
510 if ( alarm ) { 507 if ( alarm ) {
511 alarm->setEnabled(false); 508 alarm->setEnabled(false);
512 alarm->setType(Alarm::Invalid); 509 alarm->setType(Alarm::Invalid);
513 } 510 }
514 } 511 }
515} 512}
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index 01cf0ff..395325c 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -1,1423 +1,1430 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qlayout.h> 24#include <qlayout.h>
25#include <qheader.h> 25#include <qheader.h>
26#include <qcursor.h> 26#include <qcursor.h>
27#include <qwhatsthis.h> 27#include <qwhatsthis.h>
28 28
29#include <qvbox.h> 29#include <qvbox.h>
30#include <kdebug.h> 30#include <kdebug.h>
31#include "koprefs.h" 31#include "koprefs.h"
32#include <klocale.h> 32#include <klocale.h>
33#include <kglobal.h> 33#include <kglobal.h>
34#include <kiconloader.h> 34#include <kiconloader.h>
35#include <kmessagebox.h> 35#include <kmessagebox.h>
36 36
37#include <libkcal/icaldrag.h> 37#include <libkcal/icaldrag.h>
38#include <libkcal/vcaldrag.h> 38#include <libkcal/vcaldrag.h>
39#include <libkcal/calfilter.h> 39#include <libkcal/calfilter.h>
40#include <libkcal/dndfactory.h> 40#include <libkcal/dndfactory.h>
41#include <libkcal/calendarresources.h> 41#include <libkcal/calendarresources.h>
42#include <libkcal/resourcecalendar.h> 42#include <libkcal/resourcecalendar.h>
43#include <kresources/resourceselectdialog.h> 43#include <kresources/resourceselectdialog.h>
44#include <libkcal/kincidenceformatter.h> 44#include <libkcal/kincidenceformatter.h>
45#ifndef DESKTOP_VERSION 45#ifndef DESKTOP_VERSION
46#include <qpe/qpeapplication.h> 46#include <qpe/qpeapplication.h>
47#else 47#else
48#include <qapplication.h> 48#include <qapplication.h>
49#endif 49#endif
50#ifndef KORG_NOPRINTER 50#ifndef KORG_NOPRINTER
51#include "calprinter.h" 51#include "calprinter.h"
52#endif 52#endif
53#include "docprefs.h" 53#include "docprefs.h"
54 54
55#include "kotodoview.h" 55#include "kotodoview.h"
56using namespace KOrg; 56using namespace KOrg;
57 57
58 58
59class KOTodoViewWhatsThis :public QWhatsThis 59class KOTodoViewWhatsThis :public QWhatsThis
60{ 60{
61public: 61public:
62 KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; 62 KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { };
63 63
64protected: 64protected:
65 virtual QString text( const QPoint& p) 65 virtual QString text( const QPoint& p)
66 { 66 {
67 return _view->getWhatsThisText(p) ; 67 return _view->getWhatsThisText(p) ;
68 } 68 }
69private: 69private:
70 QWidget* _wid; 70 QWidget* _wid;
71 KOTodoView * _view; 71 KOTodoView * _view;
72}; 72};
73 73
74KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, 74KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent,
75 const char *name) : 75 const char *name) :
76 KListView(parent,name) 76 KListView(parent,name)
77{ 77{
78 mName = QString ( name ); 78 mName = QString ( name );
79 mCalendar = calendar; 79 mCalendar = calendar;
80#ifndef DESKTOP_VERSION 80#ifndef DESKTOP_VERSION
81 QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); 81 QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold );
82#endif 82#endif
83 mOldCurrent = 0; 83 mOldCurrent = 0;
84 mMousePressed = false; 84 mMousePressed = false;
85 85
86 setAcceptDrops(true); 86 setAcceptDrops(true);
87 viewport()->setAcceptDrops(true); 87 viewport()->setAcceptDrops(true);
88 int size = 16; 88 int size = 16;
89 if (qApp->desktop()->width() < 300 ) 89 if (qApp->desktop()->width() < 300 )
90 size = 12; 90 size = 12;
91 setTreeStepSize( size + 6 ); 91 setTreeStepSize( size + 6 );
92 92
93} 93}
94 94
95void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) 95void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e)
96{ 96{
97#ifndef KORG_NODND 97#ifndef KORG_NODND
98// kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; 98// kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl;
99 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && 99 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
100 !QTextDrag::canDecode( e ) ) { 100 !QTextDrag::canDecode( e ) ) {
101 e->ignore(); 101 e->ignore();
102 return; 102 return;
103 } 103 }
104 104
105 mOldCurrent = currentItem(); 105 mOldCurrent = currentItem();
106#endif 106#endif
107} 107}
108 108
109 109
110void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e) 110void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e)
111{ 111{
112#ifndef KORG_NODND 112#ifndef KORG_NODND
113// kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl; 113// kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl;
114 114
115 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && 115 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
116 !QTextDrag::canDecode( e ) ) { 116 !QTextDrag::canDecode( e ) ) {
117 e->ignore(); 117 e->ignore();
118 return; 118 return;
119 } 119 }
120 120
121 e->accept(); 121 e->accept();
122#endif 122#endif
123} 123}
124 124
125void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) 125void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *)
126{ 126{
127#ifndef KORG_NODND 127#ifndef KORG_NODND
128// kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; 128// kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl;
129 129
130 setCurrentItem(mOldCurrent); 130 setCurrentItem(mOldCurrent);
131 setSelected(mOldCurrent,true); 131 setSelected(mOldCurrent,true);
132#endif 132#endif
133} 133}
134 134
135void KOTodoListView::contentsDropEvent(QDropEvent *e) 135void KOTodoListView::contentsDropEvent(QDropEvent *e)
136{ 136{
137#ifndef KORG_NODND 137#ifndef KORG_NODND
138// kdDebug() << "KOTodoListView::contentsDropEvent" << endl; 138// kdDebug() << "KOTodoListView::contentsDropEvent" << endl;
139 139
140 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && 140 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
141 !QTextDrag::canDecode( e ) ) { 141 !QTextDrag::canDecode( e ) ) {
142 e->ignore(); 142 e->ignore();
143 return; 143 return;
144 } 144 }
145 145
146 DndFactory factory( mCalendar ); 146 DndFactory factory( mCalendar );
147 Todo *todo = factory.createDropTodo(e); 147 Todo *todo = factory.createDropTodo(e);
148 148
149 if (todo) { 149 if (todo) {
150 e->acceptAction(); 150 e->acceptAction();
151 151
152 KOTodoViewItem *destination = 152 KOTodoViewItem *destination =
153 (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); 153 (KOTodoViewItem *)itemAt(contentsToViewport(e->pos()));
154 Todo *destinationEvent = 0; 154 Todo *destinationEvent = 0;
155 if (destination) destinationEvent = destination->todo(); 155 if (destination) destinationEvent = destination->todo();
156 156
157 Todo *existingTodo = mCalendar->todo(todo->uid()); 157 Todo *existingTodo = mCalendar->todo(todo->uid());
158 158
159 if(existingTodo) { 159 if(existingTodo) {
160 Incidence *to = destinationEvent; 160 Incidence *to = destinationEvent;
161 while(to) { 161 while(to) {
162 if (to->uid() == todo->uid()) { 162 if (to->uid() == todo->uid()) {
163 KMessageBox::sorry(this, 163 KMessageBox::sorry(this,
164 i18n("Cannot move To-Do to itself\nor a child of itself"), 164 i18n("Cannot move To-Do to itself\nor a child of itself"),
165 i18n("Drop To-Do")); 165 i18n("Drop To-Do"));
166 delete todo; 166 delete todo;
167 return; 167 return;
168 } 168 }
169 to = to->relatedTo(); 169 to = to->relatedTo();
170 } 170 }
171 internalDrop = true; 171 internalDrop = true;
172 if ( destinationEvent ) 172 if ( destinationEvent )
173 reparentTodoSignal( destinationEvent, existingTodo ); 173 reparentTodoSignal( destinationEvent, existingTodo );
174 else 174 else
175 unparentTodoSignal(existingTodo); 175 unparentTodoSignal(existingTodo);
176 delete todo; 176 delete todo;
177 } else { 177 } else {
178 mCalendar->addTodo(todo); 178 mCalendar->addTodo(todo);
179 emit todoDropped(todo, KOGlobals::EVENTADDED); 179 emit todoDropped(todo, KOGlobals::EVENTADDED);
180 if ( destinationEvent ) 180 if ( destinationEvent )
181 reparentTodoSignal( destinationEvent, todo ); 181 reparentTodoSignal( destinationEvent, todo );
182 } 182 }
183 } 183 }
184 else { 184 else {
185 QString text; 185 QString text;
186 if (QTextDrag::decode(e,text)) { 186 if (QTextDrag::decode(e,text)) {
187 //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); 187 //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) );
188 KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); 188 KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) ));
189 qDebug("Dropped : " + text); 189 qDebug("Dropped : " + text);
190 QStringList emails = QStringList::split(",",text); 190 QStringList emails = QStringList::split(",",text);
191 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { 191 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) {
192 int pos = (*it).find("<"); 192 int pos = (*it).find("<");
193 QString name = (*it).left(pos); 193 QString name = (*it).left(pos);
194 QString email = (*it).mid(pos); 194 QString email = (*it).mid(pos);
195 if (!email.isEmpty() && todoi) { 195 if (!email.isEmpty() && todoi) {
196 todoi->todo()->addAttendee(new Attendee(name,email)); 196 todoi->todo()->addAttendee(new Attendee(name,email));
197 } 197 }
198 } 198 }
199 } 199 }
200 else { 200 else {
201 qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); 201 qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable ");
202 e->ignore(); 202 e->ignore();
203 } 203 }
204 } 204 }
205#endif 205#endif
206} 206}
207void KOTodoListView::wheelEvent (QWheelEvent *e)
208{
209 QListView::wheelEvent (e);
210}
207 211
208void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) 212void KOTodoListView::contentsMousePressEvent(QMouseEvent* e)
209{ 213{
210 214
211 QPoint p(contentsToViewport(e->pos())); 215 QPoint p(contentsToViewport(e->pos()));
212 QListViewItem *i = itemAt(p); 216 QListViewItem *i = itemAt(p);
213 bool rootClicked = true; 217 bool rootClicked = true;
214 if (i) { 218 if (i) {
215 // if the user clicked into the root decoration of the item, don't 219 // if the user clicked into the root decoration of the item, don't
216 // try to start a drag! 220 // try to start a drag!
217 int X = p.x(); 221 int X = p.x();
218 //qDebug("%d %d %d", X, header()->sectionPos(0), treeStepSize() ); 222 //qDebug("%d %d %d", X, header()->sectionPos(0), treeStepSize() );
219 if (X > header()->sectionPos(0) + 223 if (X > header()->sectionPos(0) +
220 treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + 224 treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) +
221 itemMargin() +i->height()|| 225 itemMargin() +i->height()||
222 X < header()->sectionPos(0)) { 226 X < header()->sectionPos(0)) {
223 rootClicked = false; 227 rootClicked = false;
224 } 228 }
225 } else { 229 } else {
226 rootClicked = false; 230 rootClicked = false;
227 } 231 }
228#ifndef KORG_NODND 232#ifndef KORG_NODND
229 mMousePressed = false; 233 mMousePressed = false;
230 if (! rootClicked ) { 234 if (! rootClicked && !( e->button() == RightButton) ) {
231 mPressPos = e->pos(); 235 mPressPos = e->pos();
232 mMousePressed = true; 236 mMousePressed = true;
237 } else {
238 mMousePressed = false;
233 } 239 }
234#endif 240#endif
235 //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked); 241 //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked);
236#ifndef DESKTOP_VERSION 242#ifndef DESKTOP_VERSION
237 if (!( e->button() == RightButton && rootClicked) ) 243 if (!( e->button() == RightButton && rootClicked) )
238 QListView::contentsMousePressEvent(e); 244 QListView::contentsMousePressEvent(e);
239#else 245#else
240 QListView::contentsMousePressEvent(e); 246 QListView::contentsMousePressEvent(e);
241#endif 247#endif
242} 248}
243void KOTodoListView::paintEvent(QPaintEvent* e) 249void KOTodoListView::paintEvent(QPaintEvent* e)
244{ 250{
245 emit paintNeeded(); 251 emit paintNeeded();
246 QListView::paintEvent( e); 252 QListView::paintEvent( e);
247} 253}
248void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) 254void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e)
249{ 255{
250 256
251#ifndef KORG_NODND 257#ifndef KORG_NODND
252 //QListView::contentsMouseMoveEvent(e); 258 //QListView::contentsMouseMoveEvent(e);
253 if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > 259 if (mMousePressed && (mPressPos - e->pos()).manhattanLength() >
254 QApplication::startDragDistance()*3) { 260 QApplication::startDragDistance()*3) {
255 mMousePressed = false; 261 mMousePressed = false;
256 QListViewItem *item = itemAt(contentsToViewport(mPressPos)); 262 QListViewItem *item = itemAt(contentsToViewport(mPressPos));
257 if (item) { 263 if (item) {
258 DndFactory factory( mCalendar ); 264 DndFactory factory( mCalendar );
259 ICalDrag *vd = factory.createDrag( 265 ICalDrag *vd = factory.createDrag(
260 ((KOTodoViewItem *)item)->todo(),viewport()); 266 ((KOTodoViewItem *)item)->todo(),viewport());
261 internalDrop = false; 267 internalDrop = false;
262 // we cannot do any senseful here, because the DnD is still broken in Qt 268 // we cannot do any senseful here, because the DnD is still broken in Qt
263 if (vd->drag()) { 269 if (vd->drag()) {
264 if ( !internalDrop ) { 270 if ( !internalDrop ) {
265 //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); 271 //emit deleteTodo( ((KOTodoViewItem *)item)->todo() );
266 qDebug("Dnd: External move: Delete drag source "); 272 qDebug("Dnd: External move: Delete drag source ");
267 } else 273 } else
268 qDebug("Dnd: Internal move "); 274 qDebug("Dnd: Internal move ");
269 275
270 } else { 276 } else {
271 if ( !internalDrop ) { 277 if ( !internalDrop ) {
272 qDebug("Dnd: External Copy"); 278 qDebug("Dnd: External Copy");
273 } else 279 } else
274 qDebug("DnD: Internal copy: Copy pending"); 280 qDebug("DnD: Internal copy: Copy pending");
275 } 281 }
276 } 282 }
277 } 283 }
278#endif 284#endif
279} 285}
280void KOTodoListView::keyReleaseEvent ( QKeyEvent *e ) 286void KOTodoListView::keyReleaseEvent ( QKeyEvent *e )
281{ 287{
282 if ( !e->isAutoRepeat() ) { 288 if ( !e->isAutoRepeat() ) {
283 mFlagKeyPressed = false; 289 mFlagKeyPressed = false;
284 } 290 }
285} 291}
286 292
287 293
288void KOTodoListView::keyPressEvent ( QKeyEvent * e ) 294void KOTodoListView::keyPressEvent ( QKeyEvent * e )
289{ 295{
290 qApp->processEvents(); 296 qApp->processEvents();
291 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 297 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
292 e->ignore(); 298 e->ignore();
293 // qDebug(" ignore %d",e->isAutoRepeat() ); 299 // qDebug(" ignore %d",e->isAutoRepeat() );
294 return; 300 return;
295 } 301 }
296 if (! e->isAutoRepeat() ) 302 if (! e->isAutoRepeat() )
297 mFlagKeyPressed = true; 303 mFlagKeyPressed = true;
298 QListViewItem* cn; 304 QListViewItem* cn;
299 if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { 305 if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) {
300 cn = currentItem(); 306 cn = currentItem();
301 if ( cn ) { 307 if ( cn ) {
302 KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); 308 KOTodoViewItem* ci = (KOTodoViewItem*)( cn );
303 if ( ci ){ 309 if ( ci ){
304 if ( e->state() == ShiftButton ) 310 if ( e->state() == ShiftButton )
305 ci->setOn( false ); 311 ci->setOn( false );
306 else 312 else
307 ci->setOn( true ); 313 ci->setOn( true );
308 cn = cn->itemBelow(); 314 cn = cn->itemBelow();
309 if ( cn ) { 315 if ( cn ) {
310 setCurrentItem ( cn ); 316 setCurrentItem ( cn );
311 ensureItemVisible ( cn ); 317 ensureItemVisible ( cn );
312 } 318 }
313 319
314 } 320 }
315 } 321 }
316 322
317 return; 323 return;
318 } 324 }
319 325
320 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { 326 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) {
321 switch ( e->key() ) { 327 switch ( e->key() ) {
322 case Qt::Key_Down: 328 case Qt::Key_Down:
323 case Qt::Key_Up: 329 case Qt::Key_Up:
324 QListView::keyPressEvent ( e ); 330 QListView::keyPressEvent ( e );
325 break; 331 break;
326 case Qt::Key_Left: 332 case Qt::Key_Left:
327 case Qt::Key_Right: 333 case Qt::Key_Right:
328 QListView::keyPressEvent ( e ); 334 QListView::keyPressEvent ( e );
329 e->accept(); 335 e->accept();
330 return; 336 return;
331 break; 337 break;
332 default: 338 default:
333 e->ignore(); 339 e->ignore();
334 break; 340 break;
335 } 341 }
336 return; 342 return;
337 } 343 }
338 e->ignore(); 344 e->ignore();
339} 345}
340void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) 346void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e)
341{ 347{
342 QListView::contentsMouseReleaseEvent(e); 348 QListView::contentsMouseReleaseEvent(e);
343 mMousePressed = false; 349 mMousePressed = false;
344} 350}
345 351
346void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) 352void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e)
347{ 353{
348 if (!e) return; 354 if (!e) return;
349 355
350 QPoint vp = contentsToViewport(e->pos()); 356 QPoint vp = contentsToViewport(e->pos());
351 357
352 QListViewItem *item = itemAt(vp); 358 QListViewItem *item = itemAt(vp);
353 359
354 emit double_Clicked(item); 360 emit double_Clicked(item);
355 if (!item) return; 361 if (!item) return;
356 362
357 emit doubleClicked(item,vp,0); 363 emit doubleClicked(item,vp,0);
358} 364}
359 365
360///////////////////////////////////////////////////////////////////////////// 366/////////////////////////////////////////////////////////////////////////////
361 367
362KOQuickTodo::KOQuickTodo(QWidget *parent) : 368KOQuickTodo::KOQuickTodo(QWidget *parent) :
363 QLineEdit(parent) 369 QLineEdit(parent)
364{ 370{
365 setText(i18n("Click to add a new Todo")); 371 setText(i18n("Click to add a new Todo"));
366} 372}
367 373
368void KOQuickTodo::focusInEvent(QFocusEvent *ev) 374void KOQuickTodo::focusInEvent(QFocusEvent *ev)
369{ 375{
370 if ( text()==i18n("Click to add a new Todo") ) 376 if ( text()==i18n("Click to add a new Todo") )
371 setText(""); 377 setText("");
372 QLineEdit::focusInEvent(ev); 378 QLineEdit::focusInEvent(ev);
373} 379}
374 380
375void KOQuickTodo::focusOutEvent(QFocusEvent *ev) 381void KOQuickTodo::focusOutEvent(QFocusEvent *ev)
376{ 382{
377 setText(i18n("Click to add a new Todo")); 383 setText(i18n("Click to add a new Todo"));
378 QLineEdit::focusOutEvent(ev); 384 QLineEdit::focusOutEvent(ev);
379} 385}
380 386
381///////////////////////////////////////////////////////////////////////////// 387/////////////////////////////////////////////////////////////////////////////
382 388
383KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : 389KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) :
384 KOrg::BaseView(calendar,parent,name) 390 KOrg::BaseView(calendar,parent,name)
385{ 391{
386 mPendingUpdateBeforeRepaint = false; 392 mPendingUpdateBeforeRepaint = false;
387 isFlatDisplay = false; 393 isFlatDisplay = false;
388 mNavigator = 0; 394 mNavigator = 0;
389 QBoxLayout *topLayout = new QVBoxLayout(this); 395 QBoxLayout *topLayout = new QVBoxLayout(this);
390 mName = QString ( name ); 396 mName = QString ( name );
391 mBlockUpdate = false; 397 mBlockUpdate = false;
392 mQuickAdd = new KOQuickTodo(this); 398 mQuickAdd = new KOQuickTodo(this);
393 topLayout->addWidget(mQuickAdd); 399 topLayout->addWidget(mQuickAdd);
394 400
395 if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); 401 if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide();
396 402
397 mTodoListView = new KOTodoListView(calendar,this, name ); 403 mTodoListView = new KOTodoListView(calendar,this, name );
398 topLayout->addWidget(mTodoListView); 404 topLayout->addWidget(mTodoListView);
399 //mTodoListView->header()->setMaximumHeight(30); 405 //mTodoListView->header()->setMaximumHeight(30);
400 mTodoListView->setRootIsDecorated(true); 406 mTodoListView->setRootIsDecorated(true);
401 mTodoListView->setAllColumnsShowFocus(true); 407 mTodoListView->setAllColumnsShowFocus(true);
402 408
403 mTodoListView->setShowSortIndicator(true); 409 mTodoListView->setShowSortIndicator(true);
404 410
405 mTodoListView->addColumn(i18n("Todo")); 411 mTodoListView->addColumn(i18n("Todo"));
406 mTodoListView->addColumn(i18n("Prio")); 412 mTodoListView->addColumn(i18n("Prio"));
407 mTodoListView->setColumnAlignment(1,AlignHCenter); 413 mTodoListView->setColumnAlignment(1,AlignHCenter);
408 mTodoListView->addColumn(i18n("Complete")); 414 mTodoListView->addColumn(i18n("Complete"));
409 mTodoListView->setColumnAlignment(2,AlignCenter); 415 mTodoListView->setColumnAlignment(2,AlignCenter);
410 416
411 mTodoListView->addColumn(i18n("Due Date")); 417 mTodoListView->addColumn(i18n("Due Date"));
412 mTodoListView->setColumnAlignment(3,AlignLeft); 418 mTodoListView->setColumnAlignment(3,AlignLeft);
413 mTodoListView->addColumn(i18n("Due Time")); 419 mTodoListView->addColumn(i18n("Due Time"));
414 mTodoListView->setColumnAlignment(4,AlignHCenter); 420 mTodoListView->setColumnAlignment(4,AlignHCenter);
415 421
416 mTodoListView->addColumn(i18n("Start Date")); 422 mTodoListView->addColumn(i18n("Start Date"));
417 mTodoListView->setColumnAlignment(5,AlignLeft); 423 mTodoListView->setColumnAlignment(5,AlignLeft);
418 mTodoListView->addColumn(i18n("Start Time")); 424 mTodoListView->addColumn(i18n("Start Time"));
419 mTodoListView->setColumnAlignment(6,AlignHCenter); 425 mTodoListView->setColumnAlignment(6,AlignHCenter);
420 426
421 mTodoListView->addColumn(i18n("Cancelled")); 427 mTodoListView->addColumn(i18n("Cancelled"));
422 mTodoListView->addColumn(i18n("Categories")); 428 mTodoListView->addColumn(i18n("Categories"));
423#if 0 429#if 0
424 mTodoListView->addColumn(i18n("Sort Id")); 430 mTodoListView->addColumn(i18n("Sort Id"));
425 mTodoListView->setColumnAlignment(4,AlignHCenter); 431 mTodoListView->setColumnAlignment(4,AlignHCenter);
426#endif 432#endif
427 433
428 mTodoListView->setMinimumHeight( 60 ); 434 mTodoListView->setMinimumHeight( 60 );
429 mTodoListView->setItemsRenameable( true ); 435 mTodoListView->setItemsRenameable( true );
430 mTodoListView->setRenameable( 0 ); 436 mTodoListView->setRenameable( 0 );
431 mTodoListView->setColumnWidth( 0, 120 ); 437 mTodoListView->setColumnWidth( 0, 120 );
432 mTodoListView->setColumnWidthMode(0, QListView::Manual); 438 mTodoListView->setColumnWidthMode(0, QListView::Manual);
433 mTodoListView->setColumnWidthMode(1, QListView::Manual); 439 mTodoListView->setColumnWidthMode(1, QListView::Manual);
434 mTodoListView->setColumnWidthMode(2, QListView::Manual); 440 mTodoListView->setColumnWidthMode(2, QListView::Manual);
435 mTodoListView->setColumnWidthMode(3, QListView::Manual); 441 mTodoListView->setColumnWidthMode(3, QListView::Manual);
436 mTodoListView->setColumnWidthMode(4, QListView::Manual); 442 mTodoListView->setColumnWidthMode(4, QListView::Manual);
437 mTodoListView->setColumnWidthMode(5, QListView::Manual); 443 mTodoListView->setColumnWidthMode(5, QListView::Manual);
438 mTodoListView->setColumnWidthMode(6, QListView::Manual); 444 mTodoListView->setColumnWidthMode(6, QListView::Manual);
439 mTodoListView->setColumnWidthMode(7, QListView::Manual); 445 mTodoListView->setColumnWidthMode(7, QListView::Manual);
440 mTodoListView->setColumnWidthMode(8, QListView::Manual); 446 mTodoListView->setColumnWidthMode(8, QListView::Manual);
441 447
442 448
443 mKOTodoViewWhatsThis = new KOTodoViewWhatsThis(mTodoListView->viewport(),this); 449 mKOTodoViewWhatsThis = new KOTodoViewWhatsThis(mTodoListView->viewport(),this);
444 450
445 mPriorityPopupMenu = new QPopupMenu(this); 451 mPriorityPopupMenu = new QPopupMenu(this);
446 for (int i = 1; i <= 5; i++) { 452 for (int i = 1; i <= 5; i++) {
447 QString label = QString ("%1").arg (i); 453 QString label = QString ("%1").arg (i);
448 mPriority[mPriorityPopupMenu->insertItem (label)] = i; 454 mPriority[mPriorityPopupMenu->insertItem (label)] = i;
449 } 455 }
450 connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); 456 connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int)));
451 457
452 mPercentageCompletedPopupMenu = new QPopupMenu(this); 458 mPercentageCompletedPopupMenu = new QPopupMenu(this);
453 for (int i = 0; i <= 100; i+=20) { 459 for (int i = 0; i <= 100; i+=20) {
454 QString label = QString ("%1 %").arg (i); 460 QString label = QString ("%1 %").arg (i);
455 mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; 461 mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i;
456 } 462 }
457 connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); 463 connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int)));
458 464
459 465
460 466
461 mItemPopupMenu = new QPopupMenu(this); 467 mItemPopupMenu = new QPopupMenu(this);
462 mItemPopupMenu->insertItem(i18n("Show..."), this, 468 mItemPopupMenu->insertItem(i18n("Show..."), this,
463 SLOT (showTodo())); 469 SLOT (showTodo()));
464 mItemPopupMenu->insertItem(i18n("Edit..."), this, 470 mItemPopupMenu->insertItem(i18n("Edit..."), this,
465 SLOT (editTodo())); 471 SLOT (editTodo()));
466 mItemPopupMenu->insertItem( i18n("Delete"), this, 472 mItemPopupMenu->insertItem( i18n("Delete"), this,
467 SLOT (deleteTodo())); 473 SLOT (deleteTodo()));
468 mItemPopupMenu->insertItem( i18n("Clone..."), this, 474 mItemPopupMenu->insertItem( i18n("Clone..."), this,
469 SLOT (cloneTodo())); 475 SLOT (cloneTodo()));
470 mItemPopupMenu->insertItem( i18n("Move..."), this, 476 mItemPopupMenu->insertItem( i18n("Move..."), this,
471 SLOT (moveTodo())); 477 SLOT (moveTodo()));
472 mItemPopupMenu->insertItem( i18n("Beam..."), this, 478 mItemPopupMenu->insertItem( i18n("Beam..."), this,
473 SLOT (beamTodo())); 479 SLOT (beamTodo()));
474 mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, 480 mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this,
475 SLOT (cancelTodo())); 481 SLOT (cancelTodo()));
476 mItemPopupMenu->insertSeparator(); 482 mItemPopupMenu->insertSeparator();
477 483
478 mItemPopupMenu->insertItem( i18n("New Todo..."), this, 484 mItemPopupMenu->insertItem( i18n("New Todo..."), this,
479 SLOT (newTodo())); 485 SLOT (newTodo()));
480 mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, 486 mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this,
481 SLOT (newSubTodo())); 487 SLOT (newSubTodo()));
482 mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, 488 mItemPopupMenu->insertItem(i18n("Unparent Todo"), this,
483 SLOT (unparentTodo()),0,21); 489 SLOT (unparentTodo()),0,21);
484 mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, 490 mItemPopupMenu->insertItem(i18n("Reparent Todo"), this,
485 SLOT (reparentTodo()),0,22); 491 SLOT (reparentTodo()),0,22);
486 mItemPopupMenu->insertSeparator(); 492 mItemPopupMenu->insertSeparator();
487#if 0 493#if 0
488 mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"), 494 mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"),
489 this, SLOT( purgeCompleted() ) ); 495 this, SLOT( purgeCompleted() ) );
490 mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), 496 mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"),
491 this, SLOT( toggleCompleted() ),0, 33 ); 497 this, SLOT( toggleCompleted() ),0, 33 );
492 mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), 498 mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"),
493 this, SLOT( toggleQuickTodo() ),0, 34 ); 499 this, SLOT( toggleQuickTodo() ),0, 34 );
494 mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), 500 mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"),
495 this, SLOT( toggleRunning() ),0, 35 ); 501 this, SLOT( toggleRunning() ),0, 35 );
496 502
497#endif 503#endif
498 mPopupMenu = new QPopupMenu(this); 504 mPopupMenu = new QPopupMenu(this);
499 mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, 505 mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this,
500 SLOT (newTodo()),0,1); 506 SLOT (newTodo()),0,1);
501 mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"), 507 mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"),
502 this, SLOT(purgeCompleted()),0,2); 508 this, SLOT(purgeCompleted()),0,2);
503 mPopupMenu->insertItem(i18n("Show Completed"), 509 mPopupMenu->insertItem(i18n("Show Completed"),
504 this, SLOT( toggleCompleted() ),0,3 ); 510 this, SLOT( toggleCompleted() ),0,3 );
505 mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), 511 mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"),
506 this, SLOT( toggleQuickTodo() ),0,4 ); 512 this, SLOT( toggleQuickTodo() ),0,4 );
507 mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), 513 mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"),
508 this, SLOT( toggleRunning() ),0,5 ); 514 this, SLOT( toggleRunning() ),0,5 );
509 mPopupMenu->insertItem(i18n(" set all open","Display all opened"), 515 mPopupMenu->insertItem(i18n(" set all open","Display all opened"),
510 this, SLOT( setAllOpen() ),0,6 ); 516 this, SLOT( setAllOpen() ),0,6 );
511 mPopupMenu->insertItem(i18n(" set all close","Display all closed"), 517 mPopupMenu->insertItem(i18n(" set all close","Display all closed"),
512 this, SLOT( setAllClose() ),0,7 ); 518 this, SLOT( setAllClose() ),0,7 );
513 mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), 519 mPopupMenu->insertItem(i18n(" set all flat","Display all flat"),
514 this, SLOT( setAllFlat() ),0,8 ); 520 this, SLOT( setAllFlat() ),0,8 );
515 mDocPrefs = new DocPrefs( name ); 521 mDocPrefs = new DocPrefs( name );
516 522
517 mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); 523 mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu );
518 mPopupMenu->setCheckable( true ); 524 mPopupMenu->setCheckable( true );
519 mItemPopupMenu->setCheckable( true ); 525 mItemPopupMenu->setCheckable( true );
520 526
521 527
522 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); 528 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo );
523 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); 529 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo );
524 530
525 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); 531 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo);
526 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); 532 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo );
527 533
528 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); 534 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos);
529 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); 535 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos );
530 536
531 537
532 // Double clicking conflicts with opening/closing the subtree 538 // Double clicking conflicts with opening/closing the subtree
533 connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), 539 connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ),
534 SLOT( editItem( QListViewItem *) ) ); 540 SLOT( editItem( QListViewItem *) ) );
535 /* 541 /*
536 connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, 542 connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *,
537 const QPoint &,int ) ), 543 const QPoint &,int ) ),
538 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); 544 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) );
539 */ 545 */
540 connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, 546 connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *,
541 const QPoint &,int ) ), 547 const QPoint &,int ) ),
542 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); 548 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) );
543 connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), 549 connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ),
544 SLOT( itemClicked( QListViewItem * ) ) ); 550 SLOT( itemClicked( QListViewItem * ) ) );
545 connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), 551 connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ),
546 SLOT( itemDoubleClicked( QListViewItem * ) ) ); 552 SLOT( itemDoubleClicked( QListViewItem * ) ) );
547 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), 553 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ),
548 SLOT( updateView() ) ); 554 SLOT( updateView() ) );
549 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), 555 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ),
550 SLOT( todoModified(Todo *, int) ) ); 556 SLOT( todoModified(Todo *, int) ) );
551 connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), 557 connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ),
552 SLOT( itemStateChanged( QListViewItem * ) ) ); 558 SLOT( itemStateChanged( QListViewItem * ) ) );
553 connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), 559 connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ),
554 SLOT( itemStateChanged( QListViewItem * ) ) ); 560 SLOT( itemStateChanged( QListViewItem * ) ) );
555 connect( mTodoListView, SIGNAL( paintNeeded() ), 561 connect( mTodoListView, SIGNAL( paintNeeded() ),
556 SLOT( paintNeeded()) ); 562 SLOT( paintNeeded()) );
557 563
558#if 0 564#if 0
559 connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), 565 connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)),
560 SLOT(selectionChanged(QListViewItem *))); 566 SLOT(selectionChanged(QListViewItem *)));
561 connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), 567 connect(mTodoListView,SIGNAL(clicked(QListViewItem *)),
562 SLOT(selectionChanged(QListViewItem *))); 568 SLOT(selectionChanged(QListViewItem *)));
563 connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), 569 connect(mTodoListView,SIGNAL(pressed(QListViewItem *)),
564 SLOT(selectionChanged(QListViewItem *))); 570 SLOT(selectionChanged(QListViewItem *)));
565#endif 571#endif
566 572
567 connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); 573 connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) ));
568 connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); 574 connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) ));
569 connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); 575 connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) ));
570 576
571 connect( mTodoListView, SIGNAL(selectionChanged() ), 577 connect( mTodoListView, SIGNAL(selectionChanged() ),
572 SLOT( processSelectionChange() ) ); 578 SLOT( processSelectionChange() ) );
573 connect( mQuickAdd, SIGNAL( returnPressed () ), 579 connect( mQuickAdd, SIGNAL( returnPressed () ),
574 SLOT( addQuickTodo() ) ); 580 SLOT( addQuickTodo() ) );
575 581
576} 582}
577 583
578KOTodoView::~KOTodoView() 584KOTodoView::~KOTodoView()
579{ 585{
580 // delete mKOTodoViewWhatsThis; 586 // delete mKOTodoViewWhatsThis;
581 delete mDocPrefs; 587 delete mDocPrefs;
582} 588}
583QString KOTodoView::getWhatsThisText(QPoint p) 589QString KOTodoView::getWhatsThisText(QPoint p)
584{ 590{
585 KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p ); 591 KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p );
586 if ( item ) 592 if ( item )
587 return KIncidenceFormatter::instance()->getFormattedText( item->todo(), 593 return KIncidenceFormatter::instance()->getFormattedText( item->todo(),
588 KOPrefs::instance()->mWTshowDetails, 594 KOPrefs::instance()->mWTshowDetails,
589 KOPrefs::instance()->mWTshowCreated, 595 KOPrefs::instance()->mWTshowCreated,
590 KOPrefs::instance()->mWTshowChanged); 596 KOPrefs::instance()->mWTshowChanged);
591 return i18n("That is the todo view" ); 597 return i18n("That is the todo view" );
592 598
593} 599}
594 600
595void KOTodoView::jumpToDate () 601void KOTodoView::jumpToDate ()
596{ 602{
597 // if (mActiveItem) { 603 // if (mActiveItem) {
598// mActiveItem->todo()); 604// mActiveItem->todo());
599// if ( mActiveItem->todo()->hasDueDate() ) 605// if ( mActiveItem->todo()->hasDueDate() )
600// emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); 606// emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() );
601} 607}
602void KOTodoView::paintNeeded() 608void KOTodoView::paintNeeded()
603{ 609{
604 if ( mPendingUpdateBeforeRepaint ) { 610 if ( mPendingUpdateBeforeRepaint ) {
605 updateView(); 611 updateView();
606 mPendingUpdateBeforeRepaint = false; 612 mPendingUpdateBeforeRepaint = false;
607 } 613 }
608} 614}
609void KOTodoView::paintEvent(QPaintEvent * pevent) 615void KOTodoView::paintEvent(QPaintEvent * pevent)
610{ 616{
611 if ( mPendingUpdateBeforeRepaint ) { 617 if ( mPendingUpdateBeforeRepaint ) {
612 updateView(); 618 updateView();
613 mPendingUpdateBeforeRepaint = false; 619 mPendingUpdateBeforeRepaint = false;
614 } 620 }
615 KOrg::BaseView::paintEvent( pevent); 621 KOrg::BaseView::paintEvent( pevent);
616} 622}
617 623
618void KOTodoView::updateView() 624void KOTodoView::updateView()
619{ 625{
620 pendingSubtodo = 0; 626 pendingSubtodo = 0;
621 if ( mBlockUpdate ) { 627 if ( mBlockUpdate ) {
622 return; 628 return;
623 } 629 }
624 if ( !isVisible() ) { 630 if ( !isVisible() ) {
625 mPendingUpdateBeforeRepaint = true; 631 mPendingUpdateBeforeRepaint = true;
626 return; 632 return;
627 } 633 }
628 storeCurrentItem(); 634 storeCurrentItem();
629 //qDebug("KOTodoView::updateView() %x", this); 635 //qDebug("KOTodoView::updateView() %x", this);
630 if ( isFlatDisplay ) { 636 if ( isFlatDisplay ) {
631 displayAllFlat(); 637 displayAllFlat();
632 resetCurrentItem(); 638 resetCurrentItem();
633 return; 639 return;
634 } 640 }
635 //qDebug("update "); 641 //qDebug("update ");
636// kdDebug() << "KOTodoView::updateView()" << endl; 642// kdDebug() << "KOTodoView::updateView()" << endl;
637 QFont fo = KOPrefs::instance()->mTodoViewFont; 643 QFont fo = KOPrefs::instance()->mTodoViewFont;
638 644
639 645
640 mTodoListView->clear(); 646 mTodoListView->clear();
641 if ( mName == "todolistsmall" ) { 647 if ( mName == "todolistsmall" ) {
642 if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { 648 if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) {
643 int ps = fo.pointSize() -2; 649 int ps = fo.pointSize() -2;
644 if ( ps > 12 ) 650 if ( ps > 12 )
645 ps -= 2; 651 ps -= 2;
646 fo.setPointSize( ps ); 652 fo.setPointSize( ps );
647 } 653 }
648 } 654 }
649 655
650 mTodoListView->setFont( fo ); 656 mTodoListView->setFont( fo );
651 // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); 657 // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont );
652 //mTodoListView->header()->setMaximumHeight(fm.height()); 658 //mTodoListView->header()->setMaximumHeight(fm.height());
653 QPtrList<Todo> todoList = calendar()->todos(); 659 QPtrList<Todo> todoList = calendar()->todos();
654 660
655/* 661/*
656 kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; 662 kdDebug() << "KOTodoView::updateView(): Todo List:" << endl;
657 Event *t; 663 Event *t;
658 for(t = todoList.first(); t; t = todoList.next()) { 664 for(t = todoList.first(); t; t = todoList.next()) {
659 kdDebug() << " " << t->getSummary() << endl; 665 kdDebug() << " " << t->getSummary() << endl;
660 666
661 if (t->getRelatedTo()) { 667 if (t->getRelatedTo()) {
662 kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; 668 kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl;
663 } 669 }
664 670
665 QPtrList<Event> l = t->getRelations(); 671 QPtrList<Event> l = t->getRelations();
666 Event *c; 672 Event *c;
667 for(c=l.first();c;c=l.next()) { 673 for(c=l.first();c;c=l.next()) {
668 kdDebug() << " - relation: " << c->getSummary() << endl; 674 kdDebug() << " - relation: " << c->getSummary() << endl;
669 } 675 }
670 } 676 }
671*/ 677*/
672 678
673 // Put for each Event a KOTodoViewItem in the list view. Don't rely on a 679 // Put for each Event a KOTodoViewItem in the list view. Don't rely on a
674 // specific order of events. That means that we have to generate parent items 680 // specific order of events. That means that we have to generate parent items
675 // recursively for proper hierarchical display of Todos. 681 // recursively for proper hierarchical display of Todos.
676 mTodoMap.clear(); 682 mTodoMap.clear();
677 Todo *todo; 683 Todo *todo;
678 todo = todoList.first();// todo; todo = todoList.next()) { 684 todo = todoList.first();// todo; todo = todoList.next()) {
679 while ( todo ) { 685 while ( todo ) {
680 bool next = true; 686 bool next = true;
681 // qDebug("todo %s ", todo->summary().latin1()); 687 // qDebug("todo %s ", todo->summary().latin1());
682 Incidence *incidence = todo->relatedTo(); 688 Incidence *incidence = todo->relatedTo();
683 while ( incidence ) { 689 while ( incidence ) {
684 if ( incidence->type() == "Todo") { 690 if ( incidence->type() == "Todo") {
685 //qDebug("related %s ",incidence->summary().latin1() ); 691 //qDebug("related %s ",incidence->summary().latin1() );
686 if ( !(todoList.contains ( ((Todo* )incidence ) ) )) { 692 if ( !(todoList.contains ( ((Todo* )incidence ) ) )) {
687 //qDebug("related not found "); 693 //qDebug("related not found ");
688 todoList.remove( ); 694 todoList.remove( );
689 todo = todoList.current(); 695 todo = todoList.current();
690 next = false; 696 next = false;
691 incidence = 0; 697 incidence = 0;
692 698
693 } else { 699 } else {
694 //qDebug("related found "); 700 //qDebug("related found ");
695 incidence = incidence->relatedTo(); 701 incidence = incidence->relatedTo();
696 } 702 }
697 } else 703 } else
698 incidence = 0; 704 incidence = 0;
699 } 705 }
700 if ( next ) 706 if ( next )
701 todo = todoList.next(); 707 todo = todoList.next();
702 } 708 }
703// qDebug("again .... "); 709// qDebug("again .... ");
704// for(todo = todoList.first(); todo; todo = todoList.next()) { 710// for(todo = todoList.first(); todo; todo = todoList.next()) {
705 711
706// qDebug("yytodo %s ", todo->summary().latin1()); 712// qDebug("yytodo %s ", todo->summary().latin1());
707// } 713// }
708 //qDebug("for "); 714 //qDebug("for ");
709 for(todo = todoList.first(); todo; todo = todoList.next()) { 715 for(todo = todoList.first(); todo; todo = todoList.next()) {
710 if (!mTodoMap.contains(todo) && checkTodo( todo ) ) 716 if (!mTodoMap.contains(todo) && checkTodo( todo ) )
711 { 717 {
712 insertTodoItem(todo); 718 insertTodoItem(todo);
713 } 719 }
714 } 720 }
715 //qDebug("for end "); 721 //qDebug("for end ");
716 // Restore opened/closed state 722 // Restore opened/closed state
717 mTodoListView->blockSignals( true ); 723 mTodoListView->blockSignals( true );
718 if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); 724 if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() );
719 mTodoListView->blockSignals( false ); 725 mTodoListView->blockSignals( false );
720 resetCurrentItem(); 726 resetCurrentItem();
721 processSelectionChange(); 727 processSelectionChange();
722} 728}
723 729
724void KOTodoView::storeCurrentItem() 730void KOTodoView::storeCurrentItem()
725{ 731{
726 mCurItem = 0; 732 mCurItem = 0;
727 mCurItemRootParent = 0; 733 mCurItemRootParent = 0;
728 mCurItemAbove = 0; 734 mCurItemAbove = 0;
729 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 735 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
730 if (mActiveItem) { 736 if (mActiveItem) {
731 mCurItem = mActiveItem->todo(); 737 mCurItem = mActiveItem->todo();
732 KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove (); 738 KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove ();
733 if ( activeItemAbove ) 739 if ( activeItemAbove )
734 mCurItemAbove = activeItemAbove->todo(); 740 mCurItemAbove = activeItemAbove->todo();
735 mCurItemRootParent = mCurItem; 741 mCurItemRootParent = mCurItem;
736 while ( mCurItemRootParent->relatedTo() != 0 ) 742 while ( mCurItemRootParent->relatedTo() != 0 )
737 mCurItemRootParent = mCurItemRootParent->relatedTo(); 743 mCurItemRootParent = mCurItemRootParent->relatedTo();
738 } 744 }
739 mActiveItem = 0; 745 mActiveItem = 0;
740} 746}
741 747
742void KOTodoView::resetCurrentItem() 748void KOTodoView::resetCurrentItem()
743{ 749{
744 mTodoListView->setFocus(); 750 mTodoListView->setFocus();
745 KOTodoViewItem* foundItem = 0; 751 KOTodoViewItem* foundItem = 0;
746 KOTodoViewItem* foundItemRoot = 0; 752 KOTodoViewItem* foundItemRoot = 0;
747 KOTodoViewItem* foundItemAbove = 0; 753 KOTodoViewItem* foundItemAbove = 0;
748 if ( mTodoListView->firstChild () ) { 754 if ( mTodoListView->firstChild () ) {
749 if ( mCurItem ) { 755 if ( mCurItem ) {
750 KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); 756 KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild ();
751 while ( item ) { 757 while ( item ) {
752 if ( item->todo() == mCurItem ) { 758 if ( item->todo() == mCurItem ) {
753 foundItem = item; 759 foundItem = item;
754 break; 760 break;
755 } else if ( item->todo() == mCurItemAbove ) { 761 } else if ( item->todo() == mCurItemAbove ) {
756 foundItemAbove = item; 762 foundItemAbove = item;
757 763
758 } else if ( item->todo() == mCurItemRootParent ) { 764 } else if ( item->todo() == mCurItemRootParent ) {
759 foundItemRoot = item; 765 foundItemRoot = item;
760 } 766 }
761 item = (KOTodoViewItem*)item->itemBelow(); 767 item = (KOTodoViewItem*)item->itemBelow();
762 } 768 }
763 if ( ! foundItem ) { 769 if ( ! foundItem ) {
764 if ( foundItemRoot ) 770 if ( foundItemRoot )
765 foundItem = foundItemRoot; 771 foundItem = foundItemRoot;
766 else 772 else
767 foundItem = foundItemAbove; 773 foundItem = foundItemAbove;
768 } 774 }
769 } 775 }
770 if ( foundItem ) { 776 if ( foundItem ) {
771 mTodoListView->setCurrentItem( foundItem ); 777 mTodoListView->setCurrentItem( foundItem );
772 mTodoListView->ensureItemVisible( foundItem ); 778 mTodoListView->ensureItemVisible( foundItem );
773 } else { 779 } else {
774 mTodoListView->setCurrentItem( mTodoListView->firstChild () ); 780 mTodoListView->setCurrentItem( mTodoListView->firstChild () );
775 } 781 }
776 } 782 }
777 mTodoListView->setFocus(); 783 mTodoListView->setFocus();
778} 784}
779//Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove; 785//Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove;
780bool KOTodoView::checkTodo( Todo * todo ) 786bool KOTodoView::checkTodo( Todo * todo )
781{ 787{
782 788
783 if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) 789 if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() )
784 return false; 790 return false;
785 if ( !todo->isCompleted() ) { 791 if ( !todo->isCompleted() ) {
786 if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) 792 if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() )
787 return true; 793 return true;
788 } 794 }
789 if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { 795 if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) {
790 if ( todo->hasStartDate() ) 796 if ( todo->hasStartDate() )
791 if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) 797 if ( mNavigator->selectedDates().last() < todo->dtStart().date() )
792 return false; 798 return false;
793 if ( todo->hasDueDate() ) 799 if ( todo->hasDueDate() )
794 if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) 800 if ( mNavigator->selectedDates().first() > todo->dtDue().date() )
795 return false; 801 return false;
796 } 802 }
797 return true; 803 return true;
798} 804}
799 805
800void KOTodoView::restoreItemState( QListViewItem *item ) 806void KOTodoView::restoreItemState( QListViewItem *item )
801{ 807{
802 pendingSubtodo = 0; 808 pendingSubtodo = 0;
803 while( item ) { 809 while( item ) {
804 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 810 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
805 todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); 811 todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) );
806 if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); 812 if( item->childCount() > 0 ) restoreItemState( item->firstChild() );
807 item = item->nextSibling(); 813 item = item->nextSibling();
808 } 814 }
809} 815}
810 816
811 817
812QMap<Todo *,KOTodoViewItem *>::ConstIterator 818QMap<Todo *,KOTodoViewItem *>::ConstIterator
813 KOTodoView::insertTodoItem(Todo *todo) 819 KOTodoView::insertTodoItem(Todo *todo)
814{ 820{
815 821
816// kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; 822// kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl;
817 // TODO: Check, if dynmaic cast is necessary 823 // TODO: Check, if dynmaic cast is necessary
818 824
819 pendingSubtodo = 0; 825 pendingSubtodo = 0;
820 Incidence *incidence = todo->relatedTo(); 826 Incidence *incidence = todo->relatedTo();
821 if (incidence && incidence->type() == "Todo") { 827 if (incidence && incidence->type() == "Todo") {
822 Todo *relatedTodo = static_cast<Todo *>(incidence); 828 Todo *relatedTodo = static_cast<Todo *>(incidence);
823 829
824// kdDebug() << " has Related" << endl; 830// kdDebug() << " has Related" << endl;
825 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; 831 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator;
826 itemIterator = mTodoMap.find(relatedTodo); 832 itemIterator = mTodoMap.find(relatedTodo);
827 if (itemIterator == mTodoMap.end()) { 833 if (itemIterator == mTodoMap.end()) {
828// kdDebug() << " related not yet in list" << endl; 834// kdDebug() << " related not yet in list" << endl;
829 itemIterator = insertTodoItem (relatedTodo); 835 itemIterator = insertTodoItem (relatedTodo);
830 } 836 }
831 // isn't this pretty stupid? We give one Todo to the KOTodoViewItem 837 // isn't this pretty stupid? We give one Todo to the KOTodoViewItem
832 // and one into the map. Sure finding is more easy but why? -zecke 838 // and one into the map. Sure finding is more easy but why? -zecke
833 KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); 839 KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this);
834 return mTodoMap.insert(todo,todoItem); 840 return mTodoMap.insert(todo,todoItem);
835 } else { 841 } else {
836// kdDebug() << " no Related" << endl; 842// kdDebug() << " no Related" << endl;
837 // see above -zecke 843 // see above -zecke
838 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); 844 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this);
839 return mTodoMap.insert(todo,todoItem); 845 return mTodoMap.insert(todo,todoItem);
840 } 846 }
841} 847}
842 848
843 849
844void KOTodoView::updateConfig() 850void KOTodoView::updateConfig()
845{ 851{
846 updateView(); 852 updateView();
847 mTodoListView->repaintContents(); 853 mTodoListView->repaintContents();
848} 854}
849 855
850QPtrList<Incidence> KOTodoView::selectedIncidences() 856QPtrList<Incidence> KOTodoView::selectedIncidences()
851{ 857{
852 QPtrList<Incidence> selected; 858 QPtrList<Incidence> selected;
853 859
854 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); 860 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem());
855// if (!item) item = mActiveItem; 861// if (!item) item = mActiveItem;
856 if (item) selected.append(item->todo()); 862 if (item) selected.append(item->todo());
857 863
858 return selected; 864 return selected;
859} 865}
860 866
861QPtrList<Todo> KOTodoView::selectedTodos() 867QPtrList<Todo> KOTodoView::selectedTodos()
862{ 868{
863 QPtrList<Todo> selected; 869 QPtrList<Todo> selected;
864 870
865 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); 871 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem());
866// if (!item) item = mActiveItem; 872// if (!item) item = mActiveItem;
867 if (item) selected.append(item->todo()); 873 if (item) selected.append(item->todo());
868 874
869 return selected; 875 return selected;
870} 876}
871 877
872void KOTodoView::changeEventDisplay(Event *, int) 878void KOTodoView::changeEventDisplay(Event *, int)
873{ 879{
874 updateView(); 880 updateView();
875} 881}
876 882
877void KOTodoView::showDates(const QDate &, const QDate &) 883void KOTodoView::showDates(const QDate &, const QDate &)
878{ 884{
879} 885}
880 886
881void KOTodoView::showEvents(QPtrList<Event>) 887void KOTodoView::showEvents(QPtrList<Event>)
882{ 888{
883 kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; 889 kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl;
884} 890}
885 891
886void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, 892void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd,
887 const QDate &td) 893 const QDate &td)
888{ 894{
889#ifndef KORG_NOPRINTER 895#ifndef KORG_NOPRINTER
890 calPrinter->preview(CalPrinter::Todolist, fd, td); 896 calPrinter->preview(CalPrinter::Todolist, fd, td);
891#endif 897#endif
892} 898}
893 899
894void KOTodoView::editItem(QListViewItem *item ) 900void KOTodoView::editItem(QListViewItem *item )
895{ 901{
896 // qDebug("editItem(QListViewItem *item ) "); 902 // qDebug("editItem(QListViewItem *item ) ");
897 emit editTodoSignal(((KOTodoViewItem *)item)->todo()); 903 emit editTodoSignal(((KOTodoViewItem *)item)->todo());
898} 904}
899 905
900void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) 906void KOTodoView::showItem(QListViewItem *item,const QPoint &,int)
901{ 907{
902 emit showTodoSignal(((KOTodoViewItem *)item)->todo()); 908 emit showTodoSignal(((KOTodoViewItem *)item)->todo());
903} 909}
904 910
905void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) 911void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column)
906{ 912{
907 pendingSubtodo = 0; 913 pendingSubtodo = 0;
908 mActiveItem = (KOTodoViewItem *)item; 914 mActiveItem = (KOTodoViewItem *)item;
909 if (item) { 915 if (item) {
910 switch (column){ 916 switch (column){
911 case 1: 917 case 1:
912 mPriorityPopupMenu->popup(QCursor::pos ()); break; 918 mPriorityPopupMenu->popup(QCursor::pos ()); break;
913 case 2: 919 case 2:
914 mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; 920 mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break;
915 case 3: 921 case 3:
916 moveTodo(); 922 moveTodo();
917 break; 923 break;
918 case 8: 924 case 8:
919 getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; 925 getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break;
920 default: 926 default:
921 mItemPopupMenu->popup(QCursor::pos()); 927 mItemPopupMenu->popup(QCursor::pos());
922 } 928 }
923 } else mPopupMenu->popup(QCursor::pos()); 929 } else mPopupMenu->popup(QCursor::pos());
924} 930}
925void KOTodoView::newTodo() 931void KOTodoView::newTodo()
926{ 932{
927 emit newTodoSignal(); 933 emit newTodoSignal();
928} 934}
929 935
930void KOTodoView::newSubTodo() 936void KOTodoView::newSubTodo()
931{ 937{
932 if (mActiveItem) { 938 if (mActiveItem) {
933 emit newSubTodoSignal(mActiveItem->todo()); 939 emit newSubTodoSignal(mActiveItem->todo());
934 } 940 }
935} 941}
936void KOTodoView::unparentTodo() 942void KOTodoView::unparentTodo()
937{ 943{
938 if (mActiveItem) { 944 if (mActiveItem) {
939 emit unparentTodoSignal(mActiveItem->todo()); 945 emit unparentTodoSignal(mActiveItem->todo());
940 } 946 }
941} 947}
942 948
943void KOTodoView::reparentTodo() 949void KOTodoView::reparentTodo()
944{ 950{
945 if (mActiveItem) { 951 if (mActiveItem) {
946 qDebug("KOTodoView::reparentTodo() "); 952 qDebug("KOTodoView::reparentTodo() ");
947 topLevelWidget()->setCaption(i18n("Click on new parent item")); 953 topLevelWidget()->setCaption(i18n("Click on new parent item"));
948 pendingSubtodo = mActiveItem; 954 pendingSubtodo = mActiveItem;
949 } 955 }
950} 956}
951void KOTodoView::editTodo() 957void KOTodoView::editTodo()
952{ 958{
953 if (mActiveItem) { 959 if (mActiveItem) {
954 emit editTodoSignal(mActiveItem->todo()); 960 emit editTodoSignal(mActiveItem->todo());
955 } 961 }
956} 962}
957void KOTodoView::cloneTodo() 963void KOTodoView::cloneTodo()
958{ 964{
959 if (mActiveItem) { 965 if (mActiveItem) {
960 emit cloneTodoSignal((Incidence*)mActiveItem->todo()); 966 emit cloneTodoSignal((Incidence*)mActiveItem->todo());
961 } 967 }
962} 968}
963void KOTodoView::cancelTodo() 969void KOTodoView::cancelTodo()
964{ 970{
965 if (mActiveItem) { 971 if (mActiveItem) {
966 emit cancelTodoSignal((Incidence*)mActiveItem->todo()); 972 emit cancelTodoSignal((Incidence*)mActiveItem->todo());
967 } 973 }
968} 974}
969void KOTodoView::moveTodo() 975void KOTodoView::moveTodo()
970{ 976{
971 if (mActiveItem) { 977 if (mActiveItem) {
972 emit moveTodoSignal((Incidence*)mActiveItem->todo()); 978 emit moveTodoSignal((Incidence*)mActiveItem->todo());
973 } 979 }
974} 980}
975void KOTodoView::beamTodo() 981void KOTodoView::beamTodo()
976{ 982{
977 if (mActiveItem) { 983 if (mActiveItem) {
978 emit beamTodoSignal((Incidence*)mActiveItem->todo()); 984 emit beamTodoSignal((Incidence*)mActiveItem->todo());
979 } 985 }
980} 986}
981 987
982 988
983void KOTodoView::showTodo() 989void KOTodoView::showTodo()
984{ 990{
985 if (mActiveItem) { 991 if (mActiveItem) {
986 emit showTodoSignal(mActiveItem->todo()); 992 emit showTodoSignal(mActiveItem->todo());
987 } 993 }
988} 994}
989 995
990void KOTodoView::deleteTodo() 996void KOTodoView::deleteTodo()
991{ 997{
992 if (mActiveItem) { 998 if (mActiveItem) {
993 emit deleteTodoSignal(mActiveItem->todo()); 999 emit deleteTodoSignal(mActiveItem->todo());
994 } 1000 }
995} 1001}
996 1002
997void KOTodoView::setNewPriority(int index) 1003void KOTodoView::setNewPriority(int index)
998{ 1004{
999 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 1005 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
1000 mActiveItem->todo()->setPriority(mPriority[index]); 1006 mActiveItem->todo()->setPriority(mPriority[index]);
1001 mActiveItem->construct(); 1007 mActiveItem->construct();
1002 todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); 1008 todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED);
1003 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 1009 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
1004 } 1010 }
1005} 1011}
1006 1012
1007void KOTodoView::setNewPercentage(int index) 1013void KOTodoView::setNewPercentage(int index)
1008{ 1014{
1009 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 1015 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
1010 1016
1011 if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { 1017 if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) {
1012 mActiveItem->setOn( true ); 1018 mActiveItem->setOn( true );
1013 return; 1019 return;
1014 } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { 1020 } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) {
1015 KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); 1021 KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent()));
1016 if ( par && par->isOn() ) 1022 if ( par && par->isOn() )
1017 par->setOn( false ); 1023 par->setOn( false );
1018 } 1024 }
1019 if (mPercentage[index] == 100) { 1025 if (mPercentage[index] == 100) {
1020 mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); 1026 mActiveItem->todo()->setCompleted(QDateTime::currentDateTime());
1021 } else { 1027 } else {
1022 mActiveItem->todo()->setCompleted(false); 1028 mActiveItem->todo()->setCompleted(false);
1023 } 1029 }
1024 mActiveItem->todo()->setPercentComplete(mPercentage[index]); 1030 mActiveItem->todo()->setPercentComplete(mPercentage[index]);
1025 mActiveItem->construct(); 1031 mActiveItem->construct();
1026 todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); 1032 todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED);
1027 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 1033 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
1028 } 1034 }
1029} 1035}
1030 1036
1031 1037
1032QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) 1038QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem)
1033{ 1039{
1034 QPopupMenu* tempMenu = new QPopupMenu (this); 1040 QPopupMenu* tempMenu = new QPopupMenu (this);
1035 QStringList checkedCategories = todoItem->todo()->categories (); 1041 QStringList checkedCategories = todoItem->todo()->categories ();
1036 1042
1037 tempMenu->setCheckable (true); 1043 tempMenu->setCheckable (true);
1038 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); 1044 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin ();
1039 it != KOPrefs::instance()->mCustomCategories.end (); 1045 it != KOPrefs::instance()->mCustomCategories.end ();
1040 ++it) { 1046 ++it) {
1041 int index = tempMenu->insertItem (*it); 1047 int index = tempMenu->insertItem (*it);
1042 mCategory[index] = *it; 1048 mCategory[index] = *it;
1043 if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); 1049 if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true);
1044 } 1050 }
1045 1051
1046 connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); 1052 connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int)));
1047 return tempMenu; 1053 return tempMenu;
1048 1054
1049 1055
1050} 1056}
1051void KOTodoView::changedCategories(int index) 1057void KOTodoView::changedCategories(int index)
1052{ 1058{
1053 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 1059 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
1054 QStringList categories = mActiveItem->todo()->categories (); 1060 QStringList categories = mActiveItem->todo()->categories ();
1055 QString colcat = categories.first(); 1061 QString colcat = categories.first();
1056 if (categories.find (mCategory[index]) != categories.end ()) 1062 if (categories.find (mCategory[index]) != categories.end ())
1057 categories.remove (mCategory[index]); 1063 categories.remove (mCategory[index]);
1058 else 1064 else
1059 categories.insert (categories.end(), mCategory[index]); 1065 categories.insert (categories.end(), mCategory[index]);
1060 categories.sort (); 1066 categories.sort ();
1061 if ( !colcat.isEmpty() ) { 1067 if ( !colcat.isEmpty() ) {
1062 if ( categories.find ( colcat ) != categories.end () ) { 1068 if ( categories.find ( colcat ) != categories.end () ) {
1063 categories.remove( colcat ); 1069 categories.remove( colcat );
1064 categories.prepend( colcat ); 1070 categories.prepend( colcat );
1065 } 1071 }
1066 } 1072 }
1067 mActiveItem->todo()->setCategories (categories); 1073 mActiveItem->todo()->setCategories (categories);
1068 mActiveItem->construct(); 1074 mActiveItem->construct();
1069 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 1075 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
1070 todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); 1076 todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED);
1071 } 1077 }
1072} 1078}
1073void KOTodoView::itemDoubleClicked(QListViewItem *item) 1079void KOTodoView::itemDoubleClicked(QListViewItem *item)
1074{ 1080{
1075 if ( pendingSubtodo != 0 ) { 1081 if ( pendingSubtodo != 0 ) {
1076 topLevelWidget()->setCaption(i18n("Reparenting aborted!")); 1082 topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
1077 } 1083 }
1078 pendingSubtodo = 0; 1084 pendingSubtodo = 0;
1079 int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() ); 1085 int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() );
1080 //qDebug("ROW %d ", row); 1086 //qDebug("ROW %d ", row);
1081 if (!item) { 1087 if (!item) {
1082 newTodo(); 1088 newTodo();
1083 return; 1089 return;
1084 } else { 1090 } else {
1085 if ( row == 1 ) { 1091 if ( row == 1 || row == 2 ) {
1086 mActiveItem = (KOTodoViewItem *) item; 1092 mActiveItem = (KOTodoViewItem *) item;
1087 newSubTodo(); 1093 newSubTodo();
1088 return; 1094 return;
1089 } 1095 }
1090 } 1096 }
1091 if ( KOPrefs::instance()->mEditOnDoubleClick ) 1097 if ( KOPrefs::instance()->mEditOnDoubleClick )
1092 editItem( item ); 1098 editItem( item );
1093 else 1099 else
1094 showItem( item , QPoint(), 0 ); 1100 showItem( item , QPoint(), 0 );
1095} 1101}
1096void KOTodoView::itemClicked(QListViewItem *item) 1102void KOTodoView::itemClicked(QListViewItem *item)
1097{ 1103{
1098 //qDebug("KOTodoView::itemClicked %d", item); 1104 //qDebug("KOTodoView::itemClicked %d", item);
1099 if (!item) { 1105 if (!item) {
1100 if ( pendingSubtodo != 0 ) { 1106 if ( pendingSubtodo != 0 ) {
1101 topLevelWidget()->setCaption(i18n("Reparenting aborted!")); 1107 topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
1102 } 1108 }
1103 pendingSubtodo = 0; 1109 pendingSubtodo = 0;
1104 return; 1110 return;
1105 } 1111 }
1106 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 1112 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
1107 if ( pendingSubtodo != 0 ) { 1113 if ( pendingSubtodo != 0 ) {
1108 bool allowReparent = true; 1114 bool allowReparent = true;
1109 QListViewItem *par = item; 1115 QListViewItem *par = item;
1110 while ( par ) { 1116 while ( par ) {
1111 if ( par == pendingSubtodo ) { 1117 if ( par == pendingSubtodo ) {
1112 allowReparent = false; 1118 allowReparent = false;
1113 break; 1119 break;
1114 } 1120 }
1115 par = par->parent(); 1121 par = par->parent();
1116 } 1122 }
1117 if ( !allowReparent ) { 1123 if ( !allowReparent ) {
1118 topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); 1124 topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!"));
1119 qDebug("Recursive reparenting not possible "); 1125 qDebug("Recursive reparenting not possible ");
1120 pendingSubtodo = 0; 1126 pendingSubtodo = 0;
1121 } else { 1127 } else {
1122 Todo* newParent = todoItem->todo(); 1128 Todo* newParent = todoItem->todo();
1123 Todo* newSub = pendingSubtodo->todo(); 1129 Todo* newSub = pendingSubtodo->todo();
1124 pendingSubtodo = 0; 1130 pendingSubtodo = 0;
1125 emit reparentTodoSignal( newParent,newSub ); 1131 emit reparentTodoSignal( newParent,newSub );
1126 return; 1132 return;
1127 } 1133 }
1128 } 1134 }
1129#if 0 1135#if 0
1130 // handled by the item itself 1136 // handled by the item itself
1131 bool completed = todoItem->todo()->isCompleted(); // Completed or not? 1137 bool completed = todoItem->todo()->isCompleted(); // Completed or not?
1132 qDebug("com %d ",completed ); 1138 qDebug("com %d ",completed );
1133 qDebug("itemclicked "); 1139 qDebug("itemclicked ");
1134 if (todoItem->isOn()) { 1140 if (todoItem->isOn()) {
1135 qDebug("on "); 1141 qDebug("on ");
1136 if (!completed) { 1142 if (!completed) {
1137 qDebug("set true "); 1143 qDebug("set true ");
1138 todoItem->todo()->setCompleted(QDateTime::currentDateTime()); 1144 todoItem->todo()->setCompleted(QDateTime::currentDateTime());
1139 } 1145 }
1140 } else { 1146 } else {
1141 qDebug("not on "); 1147 qDebug("not on ");
1142 if (completed) { 1148 if (completed) {
1143 qDebug("set false "); 1149 qDebug("set false ");
1144 todoItem->todo()->setCompleted(false); 1150 todoItem->todo()->setCompleted(false);
1145 } 1151 }
1146 } 1152 }
1147#endif 1153#endif
1148} 1154}
1149 1155
1150void KOTodoView::setDocumentId( const QString &id ) 1156void KOTodoView::setDocumentId( const QString &id )
1151{ 1157{
1152 kdDebug() << "KOTodoView::setDocumentId()" << endl; 1158 kdDebug() << "KOTodoView::setDocumentId()" << endl;
1153 1159
1154 mDocPrefs->setDoc( id ); 1160 mDocPrefs->setDoc( id );
1155} 1161}
1156 1162
1157void KOTodoView::itemStateChanged( QListViewItem *item ) 1163void KOTodoView::itemStateChanged( QListViewItem *item )
1158{ 1164{
1159 if (!item) return; 1165 if (!item) return;
1160 1166
1161 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 1167 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
1162 1168
1163// kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; 1169// kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl;
1164 1170
1165 if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); 1171 if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() );
1166} 1172}
1167 1173
1168void KOTodoView::saveLayout(KConfig *config, const QString &group) const 1174void KOTodoView::saveLayout(KConfig *config, const QString &group) const
1169{ 1175{
1170 mTodoListView->saveLayout(config,group); 1176 mTodoListView->saveLayout(config,group);
1171} 1177}
1172 1178
1173void KOTodoView::restoreLayout(KConfig *config, const QString &group) 1179void KOTodoView::restoreLayout(KConfig *config, const QString &group)
1174{ 1180{
1175 mTodoListView->restoreLayout(config,group); 1181 mTodoListView->restoreLayout(config,group);
1176} 1182}
1177 1183
1178void KOTodoView::processSelectionChange() 1184void KOTodoView::processSelectionChange()
1179{ 1185{
1180// kdDebug() << "KOTodoView::processSelectionChange()" << endl; 1186// kdDebug() << "KOTodoView::processSelectionChange()" << endl;
1181 1187
1182 KOTodoViewItem *item = 1188 KOTodoViewItem *item =
1183 static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); 1189 static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() );
1184 1190
1185 if ( !item ) { 1191 if ( !item ) {
1186 emit incidenceSelected( 0 ); 1192 emit incidenceSelected( 0 );
1187 } else { 1193 } else {
1188 emit incidenceSelected( item->todo() ); 1194 emit incidenceSelected( item->todo() );
1189 } 1195 }
1190} 1196}
1191 1197
1192void KOTodoView::modified(bool b) 1198void KOTodoView::modified(bool b)
1193{ 1199{
1194 emit isModified(b); 1200 emit isModified(b);
1195} 1201}
1196void KOTodoView::setTodoModified( Todo* todo ) 1202void KOTodoView::setTodoModified( Todo* todo )
1197{ 1203{
1198 todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); 1204 todoModified( todo, KOGlobals::UNKNOWN_MODIFIED );
1199} 1205}
1200void KOTodoView::clearSelection() 1206void KOTodoView::clearSelection()
1201{ 1207{
1202 mTodoListView->selectAll( false ); 1208 mTodoListView->selectAll( false );
1203} 1209}
1204void KOTodoView::setAllOpen() 1210void KOTodoView::setAllOpen()
1205{ 1211{
1206 if ( isFlatDisplay ) { 1212 if ( isFlatDisplay ) {
1207 isFlatDisplay = false; 1213 isFlatDisplay = false;
1208 mPopupMenu->setItemChecked( 8,false ); 1214 mPopupMenu->setItemChecked( 8,false );
1209 updateView(); 1215 updateView();
1210 } else { 1216 } else {
1211 storeCurrentItem(); 1217 storeCurrentItem();
1212 } 1218 }
1213 setOpen(mTodoListView->firstChild(), true); 1219 setOpen(mTodoListView->firstChild(), true);
1214 resetCurrentItem(); 1220 resetCurrentItem();
1215} 1221}
1216void KOTodoView::setAllClose() 1222void KOTodoView::setAllClose()
1217{ 1223{
1218 if ( isFlatDisplay ) { 1224 if ( isFlatDisplay ) {
1219 isFlatDisplay = false; 1225 isFlatDisplay = false;
1220 mPopupMenu->setItemChecked( 8,false ); 1226 mPopupMenu->setItemChecked( 8,false );
1221 updateView(); 1227 updateView();
1222 } else { 1228 } else {
1223 storeCurrentItem(); 1229 storeCurrentItem();
1224 } 1230 }
1225 setOpen(mTodoListView->firstChild(), false); 1231 setOpen(mTodoListView->firstChild(), false);
1226 resetCurrentItem(); 1232 resetCurrentItem();
1227} 1233}
1228void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) 1234void KOTodoView::setOpen( QListViewItem* item, bool setOpenI)
1229{ 1235{
1230 1236
1231 while ( item ) { 1237 while ( item ) {
1232 setOpen( item->firstChild(), setOpenI ); 1238 setOpen( item->firstChild(), setOpenI );
1233 item->setOpen( setOpenI ); 1239 item->setOpen( setOpenI );
1234 item = item->nextSibling(); 1240 item = item->nextSibling();
1235 } 1241 }
1236} 1242}
1237 1243
1238void KOTodoView::displayAllFlat() 1244void KOTodoView::displayAllFlat()
1239{ 1245{
1240 pendingSubtodo = 0; 1246 pendingSubtodo = 0;
1241 if ( mBlockUpdate ) { 1247 if ( mBlockUpdate ) {
1242 return; 1248 return;
1243 } 1249 }
1244 mPopupMenu->setItemChecked( 8,true ); 1250 mPopupMenu->setItemChecked( 8,true );
1245 isFlatDisplay = true; 1251 isFlatDisplay = true;
1246 QPtrList<Todo> todoList = calendar()->todos(); 1252 QPtrList<Todo> todoList = calendar()->todos();
1247 mTodoMap.clear(); 1253 mTodoMap.clear();
1248 mTodoListView->clear(); 1254 mTodoListView->clear();
1249 Todo *todo; 1255 Todo *todo;
1250 for(todo = todoList.first(); todo; todo = todoList.next()) { 1256 for(todo = todoList.first(); todo; todo = todoList.next()) {
1251 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); 1257 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this);
1252 mTodoMap.insert(todo,todoItem); 1258 mTodoMap.insert(todo,todoItem);
1253 } 1259 }
1254 mTodoListView->setFocus(); 1260 mTodoListView->setFocus();
1255 processSelectionChange(); 1261 processSelectionChange();
1256} 1262}
1257 1263
1258void KOTodoView::setAllFlat() 1264void KOTodoView::setAllFlat()
1259{ 1265{
1260 if ( isFlatDisplay ) { 1266 if ( isFlatDisplay ) {
1261 isFlatDisplay = false; 1267 isFlatDisplay = false;
1262 mPopupMenu->setItemChecked( 8,false ); 1268 mPopupMenu->setItemChecked( 8,false );
1263 updateView(); 1269 updateView();
1264 return; 1270 return;
1265 } 1271 }
1266 storeCurrentItem(); 1272 storeCurrentItem();
1267 displayAllFlat(); 1273 displayAllFlat();
1268 resetCurrentItem(); 1274 resetCurrentItem();
1269} 1275}
1270 1276
1271void KOTodoView::purgeCompleted() 1277void KOTodoView::purgeCompleted()
1272{ 1278{
1273 emit purgeCompletedSignal(); 1279 emit purgeCompletedSignal();
1280
1274} 1281}
1275void KOTodoView::toggleQuickTodo() 1282void KOTodoView::toggleQuickTodo()
1276{ 1283{
1277 if ( mQuickAdd->isVisible() ) { 1284 if ( mQuickAdd->isVisible() ) {
1278 mQuickAdd->hide(); 1285 mQuickAdd->hide();
1279 KOPrefs::instance()->mEnableQuickTodo = false; 1286 KOPrefs::instance()->mEnableQuickTodo = false;
1280 } 1287 }
1281 else { 1288 else {
1282 mQuickAdd->show(); 1289 mQuickAdd->show();
1283 KOPrefs::instance()->mEnableQuickTodo = true; 1290 KOPrefs::instance()->mEnableQuickTodo = true;
1284 } 1291 }
1285 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); 1292 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo);
1286 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); 1293 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo );
1287} 1294}
1288 1295
1289void KOTodoView::toggleRunning() 1296void KOTodoView::toggleRunning()
1290{ 1297{
1291 KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; 1298 KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos;
1292 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); 1299 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos);
1293 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); 1300 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos );
1294 updateView(); 1301 updateView();
1295} 1302}
1296 1303
1297void KOTodoView::toggleCompleted() 1304void KOTodoView::toggleCompleted()
1298{ 1305{
1299 KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; 1306 KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo;
1300 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); 1307 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo );
1301 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); 1308 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo );
1302 updateView(); 1309 updateView();
1303} 1310}
1304 1311
1305void KOTodoView::addQuickTodo() 1312void KOTodoView::addQuickTodo()
1306{ 1313{
1307 Todo *todo = new Todo(); 1314 Todo *todo = new Todo();
1308 todo->setSummary(mQuickAdd->text()); 1315 todo->setSummary(mQuickAdd->text());
1309 todo->setOrganizer(KOPrefs::instance()->email()); 1316 todo->setOrganizer(KOPrefs::instance()->email());
1310 CalFilter * cf = mCalendar->filter(); 1317 CalFilter * cf = mCalendar->filter();
1311 if ( cf ) { 1318 if ( cf ) {
1312 if ( cf->isEnabled()&& cf->showCategories()) { 1319 if ( cf->isEnabled()&& cf->showCategories()) {
1313 todo->setCategories(cf->categoryList()); 1320 todo->setCategories(cf->categoryList());
1314 } 1321 }
1315 if ( cf->isEnabled() ) 1322 if ( cf->isEnabled() )
1316 todo->setSecrecy( cf->getSecrecy()); 1323 todo->setSecrecy( cf->getSecrecy());
1317 } 1324 }
1318 mCalendar->addTodo(todo); 1325 mCalendar->addTodo(todo);
1319 mQuickAdd->setText(""); 1326 mQuickAdd->setText("");
1320 todoModified (todo, KOGlobals::EVENTADDED ); 1327 todoModified (todo, KOGlobals::EVENTADDED );
1321 updateView(); 1328 updateView();
1322} 1329}
1323 1330
1324void KOTodoView::keyPressEvent ( QKeyEvent * e ) 1331void KOTodoView::keyPressEvent ( QKeyEvent * e )
1325{ 1332{
1326 // e->ignore(); 1333 // e->ignore();
1327 //return; 1334 //return;
1328 //qDebug("KOTodoView::keyPressEvent "); 1335 //qDebug("KOTodoView::keyPressEvent ");
1329 switch ( e->key() ) { 1336 switch ( e->key() ) {
1330 case Qt::Key_Down: 1337 case Qt::Key_Down:
1331 case Qt::Key_Up: 1338 case Qt::Key_Up:
1332 QWidget::keyPressEvent ( e ); 1339 QWidget::keyPressEvent ( e );
1333 break; 1340 break;
1334 1341
1335 case Qt::Key_Q: 1342 case Qt::Key_Q:
1336 toggleQuickTodo(); 1343 toggleQuickTodo();
1337 break; 1344 break;
1338 case Qt::Key_U: 1345 case Qt::Key_U:
1339 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { 1346 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) {
1340 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1347 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1341 unparentTodo(); 1348 unparentTodo();
1342 e->accept(); 1349 e->accept();
1343 } else 1350 } else
1344 e->ignore(); 1351 e->ignore();
1345 break; 1352 break;
1346 case Qt::Key_S: 1353 case Qt::Key_S:
1347 if ( e->state() == Qt::ControlButton ) { 1354 if ( e->state() == Qt::ControlButton ) {
1348 e->ignore(); 1355 e->ignore();
1349 break; 1356 break;
1350 } 1357 }
1351 if ( e->state() == Qt::ShiftButton ) { 1358 if ( e->state() == Qt::ShiftButton ) {
1352 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1359 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1353 reparentTodo(); 1360 reparentTodo();
1354 e->accept(); 1361 e->accept();
1355 } else 1362 } else
1356 e->ignore(); 1363 e->ignore();
1357 break; 1364 break;
1358 case Qt::Key_P: 1365 case Qt::Key_P:
1359 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { 1366 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) {
1360 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1367 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1361 if ( pendingSubtodo ) 1368 if ( pendingSubtodo )
1362 itemClicked(mActiveItem); 1369 itemClicked(mActiveItem);
1363 e->accept(); 1370 e->accept();
1364 } else 1371 } else
1365 e->ignore(); 1372 e->ignore();
1366 break; 1373 break;
1367 case Qt::Key_Escape: 1374 case Qt::Key_Escape:
1368 if ( pendingSubtodo ) { 1375 if ( pendingSubtodo ) {
1369 itemClicked(0); 1376 itemClicked(0);
1370 e->accept(); 1377 e->accept();
1371 } else 1378 } else
1372 e->ignore(); 1379 e->ignore();
1373 break; 1380 break;
1374 default: 1381 default:
1375 e->ignore(); 1382 e->ignore();
1376 } 1383 }
1377 1384
1378 if ( true ) { 1385 if ( true ) {
1379 if ( e->key() == Qt::Key_I ) { 1386 if ( e->key() == Qt::Key_I ) {
1380 KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); 1387 KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem();
1381 if ( cn ) { 1388 if ( cn ) {
1382 mActiveItem = cn; 1389 mActiveItem = cn;
1383 KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); 1390 KOTodoViewItem* ci = (KOTodoViewItem*)( cn );
1384 if ( ci ){ 1391 if ( ci ){
1385 showTodo(); 1392 showTodo();
1386 cn = (KOTodoViewItem*)cn->itemBelow(); 1393 cn = (KOTodoViewItem*)cn->itemBelow();
1387 if ( cn ) { 1394 if ( cn ) {
1388 mTodoListView->setCurrentItem ( cn ); 1395 mTodoListView->setCurrentItem ( cn );
1389 mTodoListView->ensureItemVisible ( cn ); 1396 mTodoListView->ensureItemVisible ( cn );
1390 } 1397 }
1391 1398
1392 } 1399 }
1393 } 1400 }
1394 e->accept(); 1401 e->accept();
1395 1402
1396 } 1403 }
1397 1404
1398 } 1405 }
1399 1406
1400} 1407}
1401void KOTodoView::updateTodo( Todo * t, int type ) 1408void KOTodoView::updateTodo( Todo * t, int type )
1402{ 1409{
1403 if ( mBlockUpdate) 1410 if ( mBlockUpdate)
1404 return; 1411 return;
1405 1412
1406 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; 1413 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator;
1407 itemIterator = mTodoMap.find(t); 1414 itemIterator = mTodoMap.find(t);
1408 if (itemIterator != mTodoMap.end()) { 1415 if (itemIterator != mTodoMap.end()) {
1409 (*itemIterator)->construct(); 1416 (*itemIterator)->construct();
1410 } else { 1417 } else {
1411 if ( type == KOGlobals::EVENTADDED ) { 1418 if ( type == KOGlobals::EVENTADDED ) {
1412 insertTodoItem( t ); 1419 insertTodoItem( t );
1413 } 1420 }
1414 } 1421 }
1415 1422
1416} 1423}
1417 1424
1418void KOTodoView::todoModified(Todo * t , int p ) 1425void KOTodoView::todoModified(Todo * t , int p )
1419{ 1426{
1420 mBlockUpdate = true; 1427 mBlockUpdate = true;
1421 emit todoModifiedSignal ( t, p ); 1428 emit todoModifiedSignal ( t, p );
1422 mBlockUpdate = false; 1429 mBlockUpdate = false;
1423} 1430}
diff --git a/korganizer/kotodoview.h b/korganizer/kotodoview.h
index e553d0e..39976cf 100644
--- a/korganizer/kotodoview.h
+++ b/korganizer/kotodoview.h
@@ -1,262 +1,263 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000, 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000, 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23#ifndef KOTODOVIEW_H 23#ifndef KOTODOVIEW_H
24#define KOTODOVIEW_H 24#define KOTODOVIEW_H
25 25
26#include <qfont.h> 26#include <qfont.h>
27#include <qfontmetrics.h> 27#include <qfontmetrics.h>
28#include <qlineedit.h> 28#include <qlineedit.h>
29#include <qptrlist.h> 29#include <qptrlist.h>
30#include <qstrlist.h> 30#include <qstrlist.h>
31#include <qlistbox.h> 31#include <qlistbox.h>
32#include <qpopupmenu.h> 32#include <qpopupmenu.h>
33#include <qlabel.h> 33#include <qlabel.h>
34#include <qmap.h> 34#include <qmap.h>
35#include <qlistview.h> 35#include <qlistview.h>
36#include <klistview.h> 36#include <klistview.h>
37 37
38#include <libkcal/calendar.h> 38#include <libkcal/calendar.h>
39#include <libkcal/todo.h> 39#include <libkcal/todo.h>
40 40
41#include <korganizer/baseview.h> 41#include <korganizer/baseview.h>
42 42
43#include "kotodoviewitem.h" 43#include "kotodoviewitem.h"
44#include "koprefs.h" 44#include "koprefs.h"
45#include "koglobals.h" 45#include "koglobals.h"
46#include "datenavigator.h" 46#include "datenavigator.h"
47 47
48class QDragEnterEvent; 48class QDragEnterEvent;
49class QDragMoveEvent; 49class QDragMoveEvent;
50class QDragLeaveEvent; 50class QDragLeaveEvent;
51class QDropEvent; 51class QDropEvent;
52class KOTodoViewWhatsThis; 52class KOTodoViewWhatsThis;
53 53
54class DocPrefs; 54class DocPrefs;
55 55
56class KOTodoListView : public KListView 56class KOTodoListView : public KListView
57{ 57{
58 Q_OBJECT 58 Q_OBJECT
59 public: 59 public:
60 KOTodoListView(Calendar *,QWidget *parent=0,const char *name=0); 60 KOTodoListView(Calendar *,QWidget *parent=0,const char *name=0);
61 virtual ~KOTodoListView() {} 61 virtual ~KOTodoListView() {}
62 62
63 signals: 63 signals:
64 void paintNeeded(); 64 void paintNeeded();
65 void todoDropped(Todo *, int); 65 void todoDropped(Todo *, int);
66 void double_Clicked(QListViewItem *item); 66 void double_Clicked(QListViewItem *item);
67 void reparentTodoSignal( Todo *,Todo * ); 67 void reparentTodoSignal( Todo *,Todo * );
68 void unparentTodoSignal(Todo *); 68 void unparentTodoSignal(Todo *);
69 void deleteTodo( Todo * ); 69 void deleteTodo( Todo * );
70 protected: 70 protected:
71 void wheelEvent (QWheelEvent *e);
71 void contentsDragEnterEvent(QDragEnterEvent *); 72 void contentsDragEnterEvent(QDragEnterEvent *);
72 void contentsDragMoveEvent(QDragMoveEvent *); 73 void contentsDragMoveEvent(QDragMoveEvent *);
73 void contentsDragLeaveEvent(QDragLeaveEvent *); 74 void contentsDragLeaveEvent(QDragLeaveEvent *);
74 void contentsDropEvent(QDropEvent *); 75 void contentsDropEvent(QDropEvent *);
75 76
76 void contentsMousePressEvent(QMouseEvent *); 77 void contentsMousePressEvent(QMouseEvent *);
77 void contentsMouseMoveEvent(QMouseEvent *); 78 void contentsMouseMoveEvent(QMouseEvent *);
78 void contentsMouseReleaseEvent(QMouseEvent *); 79 void contentsMouseReleaseEvent(QMouseEvent *);
79 void contentsMouseDoubleClickEvent(QMouseEvent *); 80 void contentsMouseDoubleClickEvent(QMouseEvent *);
80 81
81 private: 82 private:
82 void paintEvent(QPaintEvent * pevent); 83 void paintEvent(QPaintEvent * pevent);
83 bool internalDrop; 84 bool internalDrop;
84 QString mName; 85 QString mName;
85 Calendar *mCalendar; 86 Calendar *mCalendar;
86 QPoint mPressPos; 87 QPoint mPressPos;
87 bool mMousePressed; 88 bool mMousePressed;
88 QListViewItem *mOldCurrent; 89 QListViewItem *mOldCurrent;
89 bool mFlagKeyPressed; 90 bool mFlagKeyPressed;
90 void keyPressEvent ( QKeyEvent * ) ; 91 void keyPressEvent ( QKeyEvent * ) ;
91 void keyReleaseEvent ( QKeyEvent * ) ; 92 void keyReleaseEvent ( QKeyEvent * ) ;
92}; 93};
93 94
94 95
95/** 96/**
96 This is the line-edit on top of the todoview for fast addition of new todos 97 This is the line-edit on top of the todoview for fast addition of new todos
97*/ 98*/
98class KOQuickTodo : public QLineEdit 99class KOQuickTodo : public QLineEdit
99{ 100{
100 public: 101 public:
101 KOQuickTodo(QWidget *parent=0); 102 KOQuickTodo(QWidget *parent=0);
102 protected: 103 protected:
103 void focusInEvent(QFocusEvent *ev); 104 void focusInEvent(QFocusEvent *ev);
104 void focusOutEvent(QFocusEvent *ev); 105 void focusOutEvent(QFocusEvent *ev);
105}; 106};
106 107
107 108
108/** 109/**
109 This class provides a multi-column list view of todo events. 110 This class provides a multi-column list view of todo events.
110 111
111 @short multi-column list view of todo events. 112 @short multi-column list view of todo events.
112 @author Cornelius Schumacher <schumacher@kde.org> 113 @author Cornelius Schumacher <schumacher@kde.org>
113*/ 114*/
114class KOTodoView : public KOrg::BaseView 115class KOTodoView : public KOrg::BaseView
115{ 116{
116 Q_OBJECT 117 Q_OBJECT
117 public: 118 public:
118 KOTodoView(Calendar *, QWidget* parent=0, const char* name=0 ); 119 KOTodoView(Calendar *, QWidget* parent=0, const char* name=0 );
119 ~KOTodoView(); 120 ~KOTodoView();
120 121
121 QPtrList<Incidence> selectedIncidences(); 122 QPtrList<Incidence> selectedIncidences();
122 QPtrList<Todo> selectedTodos(); 123 QPtrList<Todo> selectedTodos();
123 124
124 DateList selectedDates() 125 DateList selectedDates()
125 {DateList q; 126 {DateList q;
126 return q;} 127 return q;}
127 128
128 /** Return number of shown dates. TodoView does not show dates, */ 129 /** Return number of shown dates. TodoView does not show dates, */
129 int currentDateCount() { return 0; } 130 int currentDateCount() { return 0; }
130 131
131 void printPreview(CalPrinter *calPrinter, const QDate &fd, const QDate &td); 132 void printPreview(CalPrinter *calPrinter, const QDate &fd, const QDate &td);
132 133
133 void setDocumentId( const QString & ); 134 void setDocumentId( const QString & );
134 135
135 void saveLayout(KConfig *config, const QString &group) const; 136 void saveLayout(KConfig *config, const QString &group) const;
136 void restoreLayout(KConfig *config, const QString &group); 137 void restoreLayout(KConfig *config, const QString &group);
137 /** Create a popup menu to set categories */ 138 /** Create a popup menu to set categories */
138 QPopupMenu *getCategoryPopupMenu (KOTodoViewItem *todoItem); 139 QPopupMenu *getCategoryPopupMenu (KOTodoViewItem *todoItem);
139 void setNavigator( DateNavigator* nav ) {mNavigator = nav;} 140 void setNavigator( DateNavigator* nav ) {mNavigator = nav;}
140 QString getWhatsThisText(QPoint p); 141 QString getWhatsThisText(QPoint p);
141 142
142 public slots: 143 public slots:
143 void updateView(); 144 void updateView();
144 void updateConfig(); 145 void updateConfig();
145 146
146 void changeEventDisplay(Event *, int); 147 void changeEventDisplay(Event *, int);
147 148
148 void showDates(const QDate &start, const QDate &end); 149 void showDates(const QDate &start, const QDate &end);
149 void showEvents(QPtrList<Event> eventList); 150 void showEvents(QPtrList<Event> eventList);
150 151
151 void clearSelection(); 152 void clearSelection();
152 void jumpToDate (); 153 void jumpToDate ();
153 154
154 void editItem(QListViewItem *item); 155 void editItem(QListViewItem *item);
155 void showItem(QListViewItem *item,const QPoint &,int); 156 void showItem(QListViewItem *item,const QPoint &,int);
156 void popupMenu(QListViewItem *item,const QPoint &,int); 157 void popupMenu(QListViewItem *item,const QPoint &,int);
157 void newTodo(); 158 void newTodo();
158 void newSubTodo(); 159 void newSubTodo();
159 void unparentTodo(); 160 void unparentTodo();
160 void reparentTodo(); 161 void reparentTodo();
161 void showTodo(); 162 void showTodo();
162 void editTodo(); 163 void editTodo();
163 void cloneTodo(); 164 void cloneTodo();
164 void cancelTodo(); 165 void cancelTodo();
165 void moveTodo(); 166 void moveTodo();
166 void beamTodo(); 167 void beamTodo();
167 void deleteTodo(); 168 void deleteTodo();
168 169
169 void setNewPriority(int); 170 void setNewPriority(int);
170 void setNewPercentage(int); 171 void setNewPercentage(int);
171 void changedCategories(int); 172 void changedCategories(int);
172 173
173 void setAllOpen(); 174 void setAllOpen();
174 void setAllClose(); 175 void setAllClose();
175 void setAllFlat(); 176 void setAllFlat();
176 void displayAllFlat(); 177 void displayAllFlat();
177 178
178 void purgeCompleted(); 179 void purgeCompleted();
179 void toggleCompleted(); 180 void toggleCompleted();
180 void toggleRunning(); 181 void toggleRunning();
181 void toggleQuickTodo(); 182 void toggleQuickTodo();
182 void updateTodo( Todo *, int ); 183 void updateTodo( Todo *, int );
183 184
184 void itemClicked(QListViewItem *); 185 void itemClicked(QListViewItem *);
185 void itemStateChanged(QListViewItem *); 186 void itemStateChanged(QListViewItem *);
186 void modified(bool); 187 void modified(bool);
187 void itemDoubleClicked(QListViewItem *item); 188 void itemDoubleClicked(QListViewItem *item);
188 189
189 signals: 190 signals:
190 void newTodoSignal(); 191 void newTodoSignal();
191 void newSubTodoSignal(Todo *); 192 void newSubTodoSignal(Todo *);
192 void unparentTodoSignal(Todo *); 193 void unparentTodoSignal(Todo *);
193 void reparentTodoSignal( Todo *,Todo * ); 194 void reparentTodoSignal( Todo *,Todo * );
194 void showTodoSignal(Todo *); 195 void showTodoSignal(Todo *);
195 196
196 void editTodoSignal(Todo *); 197 void editTodoSignal(Todo *);
197 void deleteTodoSignal(Todo *); 198 void deleteTodoSignal(Todo *);
198 void todoModifiedSignal (Todo *, int); 199 void todoModifiedSignal (Todo *, int);
199 200
200 void isModified(bool); 201 void isModified(bool);
201 void cloneTodoSignal( Incidence * ); 202 void cloneTodoSignal( Incidence * );
202 void cancelTodoSignal( Incidence * ); 203 void cancelTodoSignal( Incidence * );
203 void moveTodoSignal( Incidence * ); 204 void moveTodoSignal( Incidence * );
204 void beamTodoSignal( Incidence * ); 205 void beamTodoSignal( Incidence * );
205 void purgeCompletedSignal(); 206 void purgeCompletedSignal();
206 207
207 protected slots: 208 protected slots:
208 void paintNeeded(); 209 void paintNeeded();
209 void processSelectionChange(); 210 void processSelectionChange();
210 void addQuickTodo(); 211 void addQuickTodo();
211 void setTodoModified( Todo* ); 212 void setTodoModified( Todo* );
212 void todoModified(Todo *, int ); 213 void todoModified(Todo *, int );
213 214
214 private: 215 private:
215 /* 216 /*
216 * the TodoEditor approach is rather unscaling in the long 217 * the TodoEditor approach is rather unscaling in the long
217 * run. 218 * run.
218 * Korganizer keeps it in memory and we need to update 219 * Korganizer keeps it in memory and we need to update
219 * 1. make KOTodoViewItem a QObject again? 220 * 1. make KOTodoViewItem a QObject again?
220 * 2. add a public method for setting one todo modified? 221 * 2. add a public method for setting one todo modified?
221 * 3. add a private method for setting a todo modified + friend here? 222 * 3. add a private method for setting a todo modified + friend here?
222 * -- zecke 2002-07-08 223 * -- zecke 2002-07-08
223 */ 224 */
224 KOTodoViewWhatsThis* mKOTodoViewWhatsThis; 225 KOTodoViewWhatsThis* mKOTodoViewWhatsThis;
225 friend class KOTodoListView; 226 friend class KOTodoListView;
226 void paintEvent(QPaintEvent * pevent); 227 void paintEvent(QPaintEvent * pevent);
227 bool mPendingUpdateBeforeRepaint; 228 bool mPendingUpdateBeforeRepaint;
228 friend class KOTodoViewItem; 229 friend class KOTodoViewItem;
229 QMap<Todo *,KOTodoViewItem *>::ConstIterator insertTodoItem(Todo *todo); 230 QMap<Todo *,KOTodoViewItem *>::ConstIterator insertTodoItem(Todo *todo);
230 void restoreItemState( QListViewItem * ); 231 void restoreItemState( QListViewItem * );
231 232
232 bool checkTodo( Todo * ); 233 bool checkTodo( Todo * );
233 bool isFlatDisplay; 234 bool isFlatDisplay;
234 void setOpen( QListViewItem*, bool setOpen); 235 void setOpen( QListViewItem*, bool setOpen);
235 KOTodoListView *mTodoListView; 236 KOTodoListView *mTodoListView;
236 QPopupMenu *mItemPopupMenu; 237 QPopupMenu *mItemPopupMenu;
237 QPopupMenu *mPopupMenu; 238 QPopupMenu *mPopupMenu;
238 QPopupMenu *mPriorityPopupMenu; 239 QPopupMenu *mPriorityPopupMenu;
239 QPopupMenu *mPercentageCompletedPopupMenu; 240 QPopupMenu *mPercentageCompletedPopupMenu;
240 QPopupMenu *mCategoryPopupMenu; 241 QPopupMenu *mCategoryPopupMenu;
241 242
242 QMap<int, int> mPercentage; 243 QMap<int, int> mPercentage;
243 QMap<int, int> mPriority; 244 QMap<int, int> mPriority;
244 QMap<int, QString> mCategory; 245 QMap<int, QString> mCategory;
245 KOTodoViewItem *mActiveItem; 246 KOTodoViewItem *mActiveItem;
246 247
247 QMap<Todo *,KOTodoViewItem *> mTodoMap; 248 QMap<Todo *,KOTodoViewItem *> mTodoMap;
248 QString mName; 249 QString mName;
249 250
250 DocPrefs *mDocPrefs; 251 DocPrefs *mDocPrefs;
251 QString mCurrentDoc; 252 QString mCurrentDoc;
252 KOQuickTodo *mQuickAdd; 253 KOQuickTodo *mQuickAdd;
253 bool mBlockUpdate; 254 bool mBlockUpdate;
254 void keyPressEvent ( QKeyEvent * ) ; 255 void keyPressEvent ( QKeyEvent * ) ;
255 KOTodoViewItem * pendingSubtodo; 256 KOTodoViewItem * pendingSubtodo;
256 DateNavigator* mNavigator; 257 DateNavigator* mNavigator;
257 void storeCurrentItem(); 258 void storeCurrentItem();
258 void resetCurrentItem(); 259 void resetCurrentItem();
259 Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove; 260 Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove;
260}; 261};
261 262
262#endif 263#endif