summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-02-08 14:12:31 (UTC)
committer zautrix <zautrix>2005-02-08 14:12:31 (UTC)
commit41111b332c2a5f1b2ec152df309b9199f5e9c921 (patch) (unidiff)
tree3a2e5c5a25cdb52f542b2fe84a03f94599be2fe3 /korganizer
parent9927a063f34bb826a4b5f7f7029308c9c66acbce (diff)
downloadkdepimpi-41111b332c2a5f1b2ec152df309b9199f5e9c921.zip
kdepimpi-41111b332c2a5f1b2ec152df309b9199f5e9c921.tar.gz
kdepimpi-41111b332c2a5f1b2ec152df309b9199f5e9c921.tar.bz2
fixes
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp33
-rw-r--r--korganizer/calendarview.h3
-rw-r--r--korganizer/komonthview.cpp5
-rw-r--r--korganizer/koprefs.cpp28
-rw-r--r--korganizer/ktimeedit.cpp8
-rw-r--r--korganizer/mainwindow.cpp27
-rw-r--r--korganizer/navigatorbar.cpp3
7 files changed, 69 insertions, 38 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 0fbaa9a..a9de65a 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,3908 +1,3911 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Requires the Qt and KDE widget libraries, available at no cost at 4 Requires the Qt and KDE widget libraries, available at no cost at
5 http://www.troll.no and http://www.kde.org respectively 5 http://www.troll.no and http://www.kde.org respectively
6 6
7 Copyright (c) 1997, 1998, 1999 7 Copyright (c) 1997, 1998, 1999
8 Preston Brown (preston.brown@yale.edu) 8 Preston Brown (preston.brown@yale.edu)
9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) 9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl)
10 Ian Dawes (iadawes@globalserve.net) 10 Ian Dawes (iadawes@globalserve.net)
11 Laszlo Boloni (boloni@cs.purdue.edu) 11 Laszlo Boloni (boloni@cs.purdue.edu)
12 12
13 Copyright (c) 2000, 2001, 2002 13 Copyright (c) 2000, 2001, 2002
14 Cornelius Schumacher <schumacher@kde.org> 14 Cornelius Schumacher <schumacher@kde.org>
15 15
16 This program is free software; you can redistribute it and/or modify 16 This program is free software; you can redistribute it and/or modify
17 it under the terms of the GNU General Public License as published by 17 it under the terms of the GNU General Public License as published by
18 the Free Software Foundation; either version 2 of the License, or 18 the Free Software Foundation; either version 2 of the License, or
19 (at your option) any later version. 19 (at your option) any later version.
20 20
21 This program is distributed in the hope that it will be useful, 21 This program is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of 22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
24 GNU General Public License for more details. 24 GNU General Public License for more details.
25 25
26 You should have received a copy of the GNU General Public License 26 You should have received a copy of the GNU General Public License
27 along with this program; if not, write to the Free Software 27 along with this program; if not, write to the Free Software
28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29*/ 29*/
30 30
31#include <stdlib.h> 31#include <stdlib.h>
32 32
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qradiobutton.h> 34#include <qradiobutton.h>
35#include <qbuttongroup.h> 35#include <qbuttongroup.h>
36#include <qlayout.h> 36#include <qlayout.h>
37#include <qclipboard.h> 37#include <qclipboard.h>
38#include <qcursor.h> 38#include <qcursor.h>
39#include <qmessagebox.h> 39#include <qmessagebox.h>
40#include <qprogressbar.h> 40#include <qprogressbar.h>
41#include <qmultilineedit.h> 41#include <qmultilineedit.h>
42#include <qtimer.h> 42#include <qtimer.h>
43#include <qwidgetstack.h> 43#include <qwidgetstack.h>
44#include <qptrlist.h> 44#include <qptrlist.h>
45#include <qregexp.h> 45#include <qregexp.h>
46#include <qgroupbox.h> 46#include <qgroupbox.h>
47#include <qfile.h> 47#include <qfile.h>
48#include <qdir.h> 48#include <qdir.h>
49#ifndef KORG_NOSPLITTER 49#ifndef KORG_NOSPLITTER
50#include <qsplitter.h> 50#include <qsplitter.h>
51#endif 51#endif
52 52
53#include <kglobal.h> 53#include <kglobal.h>
54#include <kdebug.h> 54#include <kdebug.h>
55#include <kstandarddirs.h> 55#include <kstandarddirs.h>
56#include <kfiledialog.h> 56#include <kfiledialog.h>
57#include <kmessagebox.h> 57#include <kmessagebox.h>
58#include <knotifyclient.h> 58#include <knotifyclient.h>
59#include <kconfig.h> 59#include <kconfig.h>
60 60
61#include <libkdepim/ksyncprefsdialog.h> 61#include <libkdepim/ksyncprefsdialog.h>
62#include <krun.h> 62#include <krun.h>
63#include <kdirwatch.h> 63#include <kdirwatch.h>
64#include <libkdepim/kdatepicker.h> 64#include <libkdepim/kdatepicker.h>
65#include <libkdepim/ksyncprofile.h> 65#include <libkdepim/ksyncprofile.h>
66#include <libkdepim/kpimglobalprefs.h> 66#include <libkdepim/kpimglobalprefs.h>
67 67
68#include <libkcal/vcaldrag.h> 68#include <libkcal/vcaldrag.h>
69#include <libkcal/icaldrag.h> 69#include <libkcal/icaldrag.h>
70#include <libkcal/icalformat.h> 70#include <libkcal/icalformat.h>
71#include <libkcal/vcalformat.h> 71#include <libkcal/vcalformat.h>
72#include <libkcal/scheduler.h> 72#include <libkcal/scheduler.h>
73#include <libkcal/calendarlocal.h> 73#include <libkcal/calendarlocal.h>
74#include <libkcal/journal.h> 74#include <libkcal/journal.h>
75#include <libkcal/calfilter.h> 75#include <libkcal/calfilter.h>
76#include <libkcal/attendee.h> 76#include <libkcal/attendee.h>
77#include <libkcal/dndfactory.h> 77#include <libkcal/dndfactory.h>
78#include <libkcal/freebusy.h> 78#include <libkcal/freebusy.h>
79#include <libkcal/filestorage.h> 79#include <libkcal/filestorage.h>
80#include <libkcal/calendarresources.h> 80#include <libkcal/calendarresources.h>
81#include <libkcal/qtopiaformat.h> 81#include <libkcal/qtopiaformat.h>
82#include "../kalarmd/alarmdialog.h" 82#include "../kalarmd/alarmdialog.h"
83 83
84#ifndef DESKTOP_VERSION 84#ifndef DESKTOP_VERSION
85#include <libkcal/sharpformat.h> 85#include <libkcal/sharpformat.h>
86#include <externalapphandler.h> 86#include <externalapphandler.h>
87#endif 87#endif
88#include <libkcal/phoneformat.h> 88#include <libkcal/phoneformat.h>
89#ifndef KORG_NOMAIL 89#ifndef KORG_NOMAIL
90#include "komailclient.h" 90#include "komailclient.h"
91#endif 91#endif
92#ifndef KORG_NOPRINTER 92#ifndef KORG_NOPRINTER
93#include "calprinter.h" 93#include "calprinter.h"
94#endif 94#endif
95#ifndef KORG_NOPLUGINS 95#ifndef KORG_NOPLUGINS
96#include "kocore.h" 96#include "kocore.h"
97#endif 97#endif
98#include "koeventeditor.h" 98#include "koeventeditor.h"
99#include "kotodoeditor.h" 99#include "kotodoeditor.h"
100#include "koprefs.h" 100#include "koprefs.h"
101#include "koeventviewerdialog.h" 101#include "koeventviewerdialog.h"
102#include "publishdialog.h" 102#include "publishdialog.h"
103#include "kofilterview.h" 103#include "kofilterview.h"
104#include "koglobals.h" 104#include "koglobals.h"
105#include "koviewmanager.h" 105#include "koviewmanager.h"
106#include "koagendaview.h" 106#include "koagendaview.h"
107#include "kodialogmanager.h" 107#include "kodialogmanager.h"
108#include "outgoingdialog.h" 108#include "outgoingdialog.h"
109#include "incomingdialog.h" 109#include "incomingdialog.h"
110#include "statusdialog.h" 110#include "statusdialog.h"
111#include "kdatenavigator.h" 111#include "kdatenavigator.h"
112#include "kotodoview.h" 112#include "kotodoview.h"
113#include "datenavigator.h" 113#include "datenavigator.h"
114#include "resourceview.h" 114#include "resourceview.h"
115#include "navigatorbar.h" 115#include "navigatorbar.h"
116#include "searchdialog.h" 116#include "searchdialog.h"
117#include "mainwindow.h" 117#include "mainwindow.h"
118 118
119#include "calendarview.h" 119#include "calendarview.h"
120#ifndef DESKTOP_VERSION 120#ifndef DESKTOP_VERSION
121#include <qtopia/alarmserver.h> 121#include <qtopia/alarmserver.h>
122#endif 122#endif
123#ifndef _WIN32_ 123#ifndef _WIN32_
124#include <stdlib.h> 124#include <stdlib.h>
125#include <stdio.h> 125#include <stdio.h>
126#include <unistd.h> 126#include <unistd.h>
127#else 127#else
128#include <qprocess.h> 128#include <qprocess.h>
129#endif 129#endif
130 130
131#ifdef DESKTOP_VERSION 131#ifdef DESKTOP_VERSION
132#include <kabc/stdaddressbook.h> 132#include <kabc/stdaddressbook.h>
133#endif 133#endif
134using namespace KOrg; 134using namespace KOrg;
135using namespace KCal; 135using namespace KCal;
136extern int globalFlagBlockAgenda; 136extern int globalFlagBlockAgenda;
137extern int globalFlagBlockStartup; 137extern int globalFlagBlockStartup;
138 138
139 139
140 140
141class KOBeamPrefs : public QDialog 141class KOBeamPrefs : public QDialog
142{ 142{
143 public: 143 public:
144 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : 144 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) :
145 QDialog( parent, name, true ) 145 QDialog( parent, name, true )
146 { 146 {
147 setCaption( i18n("Beam Options") ); 147 setCaption( i18n("Beam Options") );
148 QVBoxLayout* lay = new QVBoxLayout( this ); 148 QVBoxLayout* lay = new QVBoxLayout( this );
149 lay->setSpacing( 3 ); 149 lay->setSpacing( 3 );
150 lay->setMargin( 3 ); 150 lay->setMargin( 3 );
151 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); 151 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this );
152 lay->addWidget( format ); 152 lay->addWidget( format );
153 format->setExclusive ( true ) ; 153 format->setExclusive ( true ) ;
154 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); 154 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this );
155 lay->addWidget( time ); time->setExclusive ( true ) ; 155 lay->addWidget( time ); time->setExclusive ( true ) ;
156 vcal = new QRadioButton(" vCalendar ", format ); 156 vcal = new QRadioButton(" vCalendar ", format );
157 ical = new QRadioButton(" iCalendar ", format ); 157 ical = new QRadioButton(" iCalendar ", format );
158 vcal->setChecked( true ); 158 vcal->setChecked( true );
159 tz = new QRadioButton(i18n(" With timezone "), time ); 159 tz = new QRadioButton(i18n(" With timezone "), time );
160 local = new QRadioButton(i18n(" Local time "), time ); 160 local = new QRadioButton(i18n(" Local time "), time );
161 tz->setChecked( true ); 161 tz->setChecked( true );
162 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); 162 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this );
163 lay->addWidget( ok ); 163 lay->addWidget( ok );
164 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 164 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
165 lay->addWidget( cancel ); 165 lay->addWidget( cancel );
166 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 166 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
167 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 167 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
168 resize( 200, 200 ); 168 resize( 200, 200 );
169 } 169 }
170 170
171 bool beamVcal() { return vcal->isChecked(); } 171 bool beamVcal() { return vcal->isChecked(); }
172 bool beamLocal() { return local->isChecked(); } 172 bool beamLocal() { return local->isChecked(); }
173private: 173private:
174 QRadioButton* vcal, *ical, *local, *tz; 174 QRadioButton* vcal, *ical, *local, *tz;
175}; 175};
176class KOCatPrefs : public QDialog 176class KOCatPrefs : public QDialog
177{ 177{
178 public: 178 public:
179 KOCatPrefs( QWidget *parent=0, const char *name=0 ) : 179 KOCatPrefs( QWidget *parent=0, const char *name=0 ) :
180 QDialog( parent, name, true ) 180 QDialog( parent, name, true )
181 { 181 {
182 setCaption( i18n("Manage new Categories") ); 182 setCaption( i18n("Manage new Categories") );
183 QVBoxLayout* lay = new QVBoxLayout( this ); 183 QVBoxLayout* lay = new QVBoxLayout( this );
184 lay->setSpacing( 3 ); 184 lay->setSpacing( 3 );
185 lay->setMargin( 3 ); 185 lay->setMargin( 3 );
186 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); 186 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this );
187 lay->addWidget( lab ); 187 lay->addWidget( lab );
188 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 188 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
189 lay->addWidget( format ); 189 lay->addWidget( format );
190 format->setExclusive ( true ) ; 190 format->setExclusive ( true ) ;
191 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 191 addCatBut = new QRadioButton(i18n("Add to category list"), format );
192 new QRadioButton(i18n("Remove from Events/Todos"), format ); 192 new QRadioButton(i18n("Remove from Events/Todos"), format );
193 addCatBut->setChecked( true ); 193 addCatBut->setChecked( true );
194 QPushButton * ok = new QPushButton( i18n("OK"), this ); 194 QPushButton * ok = new QPushButton( i18n("OK"), this );
195 lay->addWidget( ok ); 195 lay->addWidget( ok );
196 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 196 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
197 lay->addWidget( cancel ); 197 lay->addWidget( cancel );
198 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 198 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
199 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 199 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
200 resize( 200, 200 ); 200 resize( 200, 200 );
201 } 201 }
202 202
203 bool addCat() { return addCatBut->isChecked(); } 203 bool addCat() { return addCatBut->isChecked(); }
204private: 204private:
205 QRadioButton* addCatBut; 205 QRadioButton* addCatBut;
206}; 206};
207 207
208 208
209 209
210CalendarView::CalendarView( CalendarResources *calendar, 210CalendarView::CalendarView( CalendarResources *calendar,
211 QWidget *parent, const char *name ) 211 QWidget *parent, const char *name )
212 : CalendarViewBase( parent, name ), 212 : CalendarViewBase( parent, name ),
213 mCalendar( calendar ), 213 mCalendar( calendar ),
214 mResourceManager( calendar->resourceManager() ) 214 mResourceManager( calendar->resourceManager() )
215{ 215{
216 216
217 mEventEditor = 0; 217 mEventEditor = 0;
218 mTodoEditor = 0; 218 mTodoEditor = 0;
219 219
220 init(); 220 init();
221} 221}
222 222
223CalendarView::CalendarView( Calendar *calendar, 223CalendarView::CalendarView( Calendar *calendar,
224 QWidget *parent, const char *name ) 224 QWidget *parent, const char *name )
225 : CalendarViewBase( parent, name ), 225 : CalendarViewBase( parent, name ),
226 mCalendar( calendar ), 226 mCalendar( calendar ),
227 mResourceManager( 0 ) 227 mResourceManager( 0 )
228{ 228{
229 229
230 mEventEditor = 0; 230 mEventEditor = 0;
231 mTodoEditor = 0; 231 mTodoEditor = 0;
232 init();} 232 init();}
233 233
234void CalendarView::init() 234void CalendarView::init()
235{ 235{
236 mBlockShowDates = false; 236 mBlockShowDates = false;
237 beamDialog = new KOBeamPrefs(); 237 beamDialog = new KOBeamPrefs();
238 mDatePickerMode = 0; 238 mDatePickerMode = 0;
239 mCurrentSyncDevice = ""; 239 mCurrentSyncDevice = "";
240 writeLocale(); 240 writeLocale();
241 mViewManager = new KOViewManager( this ); 241 mViewManager = new KOViewManager( this );
242 mDialogManager = new KODialogManager( this ); 242 mDialogManager = new KODialogManager( this );
243 mEventViewerDialog = 0; 243 mEventViewerDialog = 0;
244 mModified = false; 244 mModified = false;
245 mReadOnly = false; 245 mReadOnly = false;
246 mSelectedIncidence = 0; 246 mSelectedIncidence = 0;
247 mCalPrinter = 0; 247 mCalPrinter = 0;
248 mFilters.setAutoDelete(true); 248 mFilters.setAutoDelete(true);
249 249
250 mCalendar->registerObserver( this ); 250 mCalendar->registerObserver( this );
251 // TODO: Make sure that view is updated, when calendar is changed. 251 // TODO: Make sure that view is updated, when calendar is changed.
252 252
253 mStorage = new FileStorage( mCalendar ); 253 mStorage = new FileStorage( mCalendar );
254 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 254 mNavigator = new DateNavigator( this, "datevav", mViewManager );
255 255
256 QBoxLayout *topLayout = (QBoxLayout*)layout(); 256 QBoxLayout *topLayout = (QBoxLayout*)layout();
257#ifndef KORG_NOSPLITTER 257#ifndef KORG_NOSPLITTER
258 // create the main layout frames. 258 // create the main layout frames.
259 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 259 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
260 topLayout->addWidget(mPanner); 260 topLayout->addWidget(mPanner);
261 261
262 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 262 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
263 "CalendarView::LeftFrame"); 263 "CalendarView::LeftFrame");
264 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 264 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
265 265
266 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, 266 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE,
267 "CalendarView::DateNavigator", QDate::currentDate() ); 267 "CalendarView::DateNavigator", QDate::currentDate() );
268 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 268 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
269 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 269 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
270 mTodoList->setNavigator( mNavigator ); 270 mTodoList->setNavigator( mNavigator );
271 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 271 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
272 272
273#ifdef KORG_NORESOURCEVIEW 273#ifdef KORG_NORESOURCEVIEW
274 mResourceView = 0; 274 mResourceView = 0;
275#else 275#else
276 if ( mResourceManager ) { 276 if ( mResourceManager ) {
277 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 277 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
278 mResourceView->updateView(); 278 mResourceView->updateView();
279 connect( mResourceView, SIGNAL( resourcesChanged() ), 279 connect( mResourceView, SIGNAL( resourcesChanged() ),
280 SLOT( updateView() ) ); 280 SLOT( updateView() ) );
281 } else { 281 } else {
282 mResourceView = 0; 282 mResourceView = 0;
283 } 283 }
284#endif 284#endif
285 QWidget *rightBox = new QWidget( mPanner ); 285 QWidget *rightBox = new QWidget( mPanner );
286 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 286 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
287 287
288 mRightFrame = new QWidgetStack( rightBox ); 288 mRightFrame = new QWidgetStack( rightBox );
289 rightLayout->addWidget( mRightFrame, 1 ); 289 rightLayout->addWidget( mRightFrame, 1 );
290 290
291 mLeftFrame = mLeftSplitter; 291 mLeftFrame = mLeftSplitter;
292#else 292#else
293 QWidget *mainBox = new QWidget( this ); 293 QWidget *mainBox = new QWidget( this );
294 QWidget *leftFrame = new QWidget( mainBox ); 294 QWidget *leftFrame = new QWidget( mainBox );
295 295
296 QBoxLayout * mainBoxLayout; 296 QBoxLayout * mainBoxLayout;
297 QBoxLayout * leftFrameLayout; 297 QBoxLayout * leftFrameLayout;
298 if ( KOPrefs::instance()->mVerticalScreen ) { 298 if ( KOPrefs::instance()->mVerticalScreen ) {
299 mainBoxLayout = new QVBoxLayout(mainBox); 299 mainBoxLayout = new QVBoxLayout(mainBox);
300 leftFrameLayout = new QHBoxLayout(leftFrame ); 300 leftFrameLayout = new QHBoxLayout(leftFrame );
301 } else { 301 } else {
302 mainBoxLayout = new QHBoxLayout(mainBox); 302 mainBoxLayout = new QHBoxLayout(mainBox);
303 leftFrameLayout = new QVBoxLayout(leftFrame ); 303 leftFrameLayout = new QVBoxLayout(leftFrame );
304 } 304 }
305 topLayout->addWidget( mainBox ); 305 topLayout->addWidget( mainBox );
306 mainBoxLayout->addWidget (leftFrame); 306 mainBoxLayout->addWidget (leftFrame);
307 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, 307 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE,
308 "CalendarView::DateNavigator", QDate::currentDate()); 308 "CalendarView::DateNavigator", QDate::currentDate());
309 // mDateNavigator->blockSignals( true ); 309 // mDateNavigator->blockSignals( true );
310 leftFrameLayout->addWidget( mDateNavigator ); 310 leftFrameLayout->addWidget( mDateNavigator );
311 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); 311 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView");
312 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall"); 312 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall");
313 mTodoList->setNavigator( mNavigator ); 313 mTodoList->setNavigator( mNavigator );
314 314
315 if ( QApplication::desktop()->width() < 480 ) { 315 if ( QApplication::desktop()->width() < 480 ) {
316 leftFrameLayout->addWidget(mFilterView); 316 leftFrameLayout->addWidget(mFilterView);
317 leftFrameLayout->addWidget(mTodoList, 2 ); 317 leftFrameLayout->addWidget(mTodoList, 2 );
318 318
319 } else { 319 } else {
320 leftFrameLayout->addWidget(mTodoList,2 ); 320 leftFrameLayout->addWidget(mTodoList,2 );
321 leftFrameLayout->addWidget(mFilterView ); 321 leftFrameLayout->addWidget(mFilterView );
322 } 322 }
323 mFilterView->hide(); 323 mFilterView->hide();
324 QWidget *rightBox = new QWidget( mainBox ); 324 QWidget *rightBox = new QWidget( mainBox );
325 mainBoxLayout->addWidget ( rightBox, 10 ); 325 mainBoxLayout->addWidget ( rightBox, 10 );
326 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 326 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
327 mRightFrame = new QWidgetStack( rightBox ); 327 mRightFrame = new QWidgetStack( rightBox );
328 rightLayout->addWidget( mRightFrame, 10 ); 328 rightLayout->addWidget( mRightFrame, 10 );
329 329
330 mLeftFrame = leftFrame; 330 mLeftFrame = leftFrame;
331 if ( KOPrefs::instance()->mVerticalScreen ) { 331 if ( KOPrefs::instance()->mVerticalScreen ) {
332 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 332 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
333 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 333 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
334 } else { 334 } else {
335 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 335 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
336 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 336 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
337 } 337 }
338 if ( !KOPrefs::instance()->mShowDateNavigator) 338 if ( !KOPrefs::instance()->mShowDateNavigator)
339 mDateNavigator->hide(); 339 mDateNavigator->hide();
340 //qDebug("Calendarview Size %d %d ", width(), height()); 340 //qDebug("Calendarview Size %d %d ", width(), height());
341#endif 341#endif
342 342
343 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 343 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
344 SLOT( showDates( const KCal::DateList & ) ) ); 344 SLOT( showDates( const KCal::DateList & ) ) );
345 345
346 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 346 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
347 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 347 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
348 348
349 349
350 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 350 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
351 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 351 mNavigator, SLOT( selectWeek( const QDate & ) ) );
352 352
353 connect( mDateNavigator, SIGNAL( goPrevYear() ), 353 connect( mDateNavigator, SIGNAL( goPrevYear() ),
354 mNavigator, SLOT( selectPreviousYear() ) ); 354 mNavigator, SLOT( selectPreviousYear() ) );
355 connect( mDateNavigator, SIGNAL( goNextYear() ), 355 connect( mDateNavigator, SIGNAL( goNextYear() ),
356 mNavigator, SLOT( selectNextYear() ) ); 356 mNavigator, SLOT( selectNextYear() ) );
357 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 357 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
358 mNavigator, SLOT( selectPreviousMonth() ) ); 358 mNavigator, SLOT( selectPreviousMonth() ) );
359 connect( mDateNavigator, SIGNAL( goNextMonth() ), 359 connect( mDateNavigator, SIGNAL( goNextMonth() ),
360 mNavigator, SLOT( selectNextMonth() ) ); 360 mNavigator, SLOT( selectNextMonth() ) );
361 361
362 connect( mDateNavigator, SIGNAL( goPrevious() ), 362 connect( mDateNavigator, SIGNAL( goPrevious() ),
363 mNavigator, SLOT( selectPrevious() ) ); 363 mNavigator, SLOT( selectPrevious() ) );
364 connect( mDateNavigator, SIGNAL( goNext() ), 364 connect( mDateNavigator, SIGNAL( goNext() ),
365 mNavigator, SLOT( selectNext() ) ); 365 mNavigator, SLOT( selectNext() ) );
366 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 366 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
367 mNavigator, SLOT( slotMonthSelect( int ) ) ); 367 mNavigator, SLOT( slotMonthSelect( int ) ) );
368 368
369 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 369 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
370 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 370 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
371 371
372 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), 372 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ),
373 SLOT( eventAdded( Event *) ) ); 373 SLOT( eventAdded( Event *) ) );
374 374
375 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 375 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
376 376
377 connect( this, SIGNAL( configChanged() ), 377 connect( this, SIGNAL( configChanged() ),
378 mDateNavigator, SLOT( updateConfig() ) ); 378 mDateNavigator, SLOT( updateConfig() ) );
379 379
380 connect( mTodoList, SIGNAL( newTodoSignal() ), 380 connect( mTodoList, SIGNAL( newTodoSignal() ),
381 SLOT( newTodo() ) ); 381 SLOT( newTodo() ) );
382 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 382 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
383 SLOT( newSubTodo( Todo * ) ) ); 383 SLOT( newSubTodo( Todo * ) ) );
384 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 384 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
385 SLOT( editTodo( Todo * ) ) ); 385 SLOT( editTodo( Todo * ) ) );
386 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 386 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
387 SLOT( showTodo( Todo *) ) ); 387 SLOT( showTodo( Todo *) ) );
388 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 388 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
389 SLOT( deleteTodo( Todo *) ) ); 389 SLOT( deleteTodo( Todo *) ) );
390 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 390 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
391 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 391 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
392 SLOT( purgeCompleted() ) ); 392 SLOT( purgeCompleted() ) );
393 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 393 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
394 SIGNAL( todoModified( Todo *, int ) ) ); 394 SIGNAL( todoModified( Todo *, int ) ) );
395 395
396 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 396 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
397 this, SLOT ( cloneIncidence( Incidence * ) ) ); 397 this, SLOT ( cloneIncidence( Incidence * ) ) );
398 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 398 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
399 this, SLOT (cancelIncidence( Incidence * ) ) ); 399 this, SLOT (cancelIncidence( Incidence * ) ) );
400 400
401 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 401 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
402 this, SLOT ( moveIncidence( Incidence * ) ) ); 402 this, SLOT ( moveIncidence( Incidence * ) ) );
403 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 403 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
404 this, SLOT ( beamIncidence( Incidence * ) ) ); 404 this, SLOT ( beamIncidence( Incidence * ) ) );
405 405
406 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 406 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
407 this, SLOT ( todo_unsub( Todo * ) ) ); 407 this, SLOT ( todo_unsub( Todo * ) ) );
408 408
409 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 409 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
410 this, SLOT ( todo_resub( Todo *,Todo * ) ) ); 410 this, SLOT ( todo_resub( Todo *,Todo * ) ) );
411 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 411 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
412 SLOT( updateTodo( Todo *, int ) ) ); 412 SLOT( updateTodo( Todo *, int ) ) );
413 connect( this, SIGNAL( todoModified( Todo *, int )), this, 413 connect( this, SIGNAL( todoModified( Todo *, int )), this,
414 SLOT( changeTodoDisplay( Todo *, int ) ) ); 414 SLOT( changeTodoDisplay( Todo *, int ) ) );
415 415
416 416
417 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 417 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
418 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 418 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
419 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 419 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
420 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 420 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
421 421
422 422
423 423
424 424
425 425
426 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 426 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
427 SLOT(checkClipboard())); 427 SLOT(checkClipboard()));
428 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 428 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
429 SLOT( processTodoListSelection( Incidence * ) ) ); 429 SLOT( processTodoListSelection( Incidence * ) ) );
430 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 430 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
431 431
432 // kdDebug() << "CalendarView::CalendarView() done" << endl; 432 // kdDebug() << "CalendarView::CalendarView() done" << endl;
433 433
434 mDateFrame = new QVBox(0,0,WType_Popup); 434 mDateFrame = new QVBox(0,0,WType_Popup);
435 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 435 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
436 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 436 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
437 mDateFrame->setLineWidth(3); 437 mDateFrame->setLineWidth(3);
438 mDateFrame->hide(); 438 mDateFrame->hide();
439 mDateFrame->setCaption( i18n( "Pick a date to display")); 439 mDateFrame->setCaption( i18n( "Pick a date to display"));
440 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 440 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
441 441
442 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 442 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
443 443
444 mEventEditor = mDialogManager->getEventEditor(); 444 mEventEditor = mDialogManager->getEventEditor();
445 mTodoEditor = mDialogManager->getTodoEditor(); 445 mTodoEditor = mDialogManager->getTodoEditor();
446 446
447 mFlagEditDescription = false; 447 mFlagEditDescription = false;
448 448
449 mSuspendTimer = new QTimer( this ); 449 mSuspendTimer = new QTimer( this );
450 mAlarmTimer = new QTimer( this ); 450 mAlarmTimer = new QTimer( this );
451 mRecheckAlarmTimer = new QTimer( this ); 451 mRecheckAlarmTimer = new QTimer( this );
452 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 452 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
453 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 453 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
454 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 454 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
455 mAlarmDialog = new AlarmDialog( this ); 455 mAlarmDialog = new AlarmDialog( this );
456 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 456 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
457 mAlarmDialog->setServerNotification( false ); 457 mAlarmDialog->setServerNotification( false );
458 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 458 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
459 459
460 460
461#ifndef DESKTOP_VERSION 461#ifndef DESKTOP_VERSION
462//US listen for arriving address resultsets 462//US listen for arriving address resultsets
463 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), 463 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)),
464 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 464 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
465#endif 465#endif
466 466
467} 467}
468 468
469 469
470CalendarView::~CalendarView() 470CalendarView::~CalendarView()
471{ 471{
472 // kdDebug() << "~CalendarView()" << endl; 472 // kdDebug() << "~CalendarView()" << endl;
473 //qDebug("CalendarView::~CalendarView() "); 473 //qDebug("CalendarView::~CalendarView() ");
474 delete mDialogManager; 474 delete mDialogManager;
475 delete mViewManager; 475 delete mViewManager;
476 delete mStorage; 476 delete mStorage;
477 delete mDateFrame ; 477 delete mDateFrame ;
478 delete beamDialog; 478 delete beamDialog;
479 //kdDebug() << "~CalendarView() done" << endl; 479 //kdDebug() << "~CalendarView() done" << endl;
480} 480}
481 481
482void CalendarView::showDay( QDate d ) 482void CalendarView::showDay( QDate d )
483{ 483{
484 dateNavigator()->blockSignals( true ); 484 dateNavigator()->blockSignals( true );
485 dateNavigator()->selectDate( d ); 485 dateNavigator()->selectDate( d );
486 dateNavigator()->blockSignals( false ); 486 dateNavigator()->blockSignals( false );
487 mViewManager->showDayView(); 487 mViewManager->showDayView();
488 //dateNavigator()->selectDate( d ); 488 //dateNavigator()->selectDate( d );
489} 489}
490void CalendarView::timerAlarm() 490void CalendarView::timerAlarm()
491{ 491{
492 //qDebug("CalendarView::timerAlarm() "); 492 //qDebug("CalendarView::timerAlarm() ");
493 computeAlarm(mAlarmNotification ); 493 computeAlarm(mAlarmNotification );
494} 494}
495 495
496void CalendarView::suspendAlarm() 496void CalendarView::suspendAlarm()
497{ 497{
498 //qDebug(" CalendarView::suspendAlarm() "); 498 //qDebug(" CalendarView::suspendAlarm() ");
499 computeAlarm(mSuspendAlarmNotification ); 499 computeAlarm(mSuspendAlarmNotification );
500 500
501} 501}
502 502
503void CalendarView::startAlarm( QString mess , QString filename) 503void CalendarView::startAlarm( QString mess , QString filename)
504{ 504{
505 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 505 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
506 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); 506 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
507 507
508} 508}
509 509
510void CalendarView::checkNextTimerAlarm() 510void CalendarView::checkNextTimerAlarm()
511{ 511{
512 mCalendar->checkAlarmForIncidence( 0, true ); 512 mCalendar->checkAlarmForIncidence( 0, true );
513} 513}
514 514
515void CalendarView::computeAlarm( QString msg ) 515void CalendarView::computeAlarm( QString msg )
516{ 516{
517 517
518 QString mess = msg; 518 QString mess = msg;
519 QString mAlarmMessage = mess.mid( 9 ); 519 QString mAlarmMessage = mess.mid( 9 );
520 QString filename = MainWindow::resourcePath(); 520 QString filename = MainWindow::resourcePath();
521 filename += "koalarm.wav"; 521 filename += "koalarm.wav";
522 QString tempfilename; 522 QString tempfilename;
523 if ( mess.left( 13 ) == "suspend_alarm") { 523 if ( mess.left( 13 ) == "suspend_alarm") {
524 bool error = false; 524 bool error = false;
525 int len = mess.mid( 13 ).find("+++"); 525 int len = mess.mid( 13 ).find("+++");
526 if ( len < 2 ) 526 if ( len < 2 )
527 error = true; 527 error = true;
528 else { 528 else {
529 tempfilename = mess.mid( 13, len ); 529 tempfilename = mess.mid( 13, len );
530 if ( !QFile::exists( tempfilename ) ) 530 if ( !QFile::exists( tempfilename ) )
531 error = true; 531 error = true;
532 } 532 }
533 if ( ! error ) { 533 if ( ! error ) {
534 filename = tempfilename; 534 filename = tempfilename;
535 } 535 }
536 mAlarmMessage = mess.mid( 13+len+3 ); 536 mAlarmMessage = mess.mid( 13+len+3 );
537 //qDebug("suspend file %s ",tempfilename.latin1() ); 537 //qDebug("suspend file %s ",tempfilename.latin1() );
538 startAlarm( mAlarmMessage, filename); 538 startAlarm( mAlarmMessage, filename);
539 return; 539 return;
540 } 540 }
541 if ( mess.left( 11 ) == "timer_alarm") { 541 if ( mess.left( 11 ) == "timer_alarm") {
542 //mTimerTime = 0; 542 //mTimerTime = 0;
543 startAlarm( mess.mid( 11 ), filename ); 543 startAlarm( mess.mid( 11 ), filename );
544 return; 544 return;
545 } 545 }
546 if ( mess.left( 10 ) == "proc_alarm") { 546 if ( mess.left( 10 ) == "proc_alarm") {
547 bool error = false; 547 bool error = false;
548 int len = mess.mid( 10 ).find("+++"); 548 int len = mess.mid( 10 ).find("+++");
549 if ( len < 2 ) 549 if ( len < 2 )
550 error = true; 550 error = true;
551 else { 551 else {
552 tempfilename = mess.mid( 10, len ); 552 tempfilename = mess.mid( 10, len );
553 if ( !QFile::exists( tempfilename ) ) 553 if ( !QFile::exists( tempfilename ) )
554 error = true; 554 error = true;
555 } 555 }
556 if ( error ) { 556 if ( error ) {
557 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 557 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
558 mAlarmMessage += mess.mid( 10+len+3+9 ); 558 mAlarmMessage += mess.mid( 10+len+3+9 );
559 } else { 559 } else {
560 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 560 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
561 //qDebug("-----system command %s ",tempfilename.latin1() ); 561 //qDebug("-----system command %s ",tempfilename.latin1() );
562#ifndef _WIN32_ 562#ifndef _WIN32_
563 if ( vfork () == 0 ) { 563 if ( vfork () == 0 ) {
564 execl ( tempfilename.latin1(), 0 ); 564 execl ( tempfilename.latin1(), 0 );
565 return; 565 return;
566 } 566 }
567#else 567#else
568 QProcess* p = new QProcess(); 568 QProcess* p = new QProcess();
569 p->addArgument( tempfilename.latin1() ); 569 p->addArgument( tempfilename.latin1() );
570 p->start(); 570 p->start();
571 return; 571 return;
572#endif 572#endif
573 573
574 return; 574 return;
575 } 575 }
576 576
577 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 577 //qDebug("+++++++system command %s ",tempfilename.latin1() );
578 } 578 }
579 if ( mess.left( 11 ) == "audio_alarm") { 579 if ( mess.left( 11 ) == "audio_alarm") {
580 bool error = false; 580 bool error = false;
581 int len = mess.mid( 11 ).find("+++"); 581 int len = mess.mid( 11 ).find("+++");
582 if ( len < 2 ) 582 if ( len < 2 )
583 error = true; 583 error = true;
584 else { 584 else {
585 tempfilename = mess.mid( 11, len ); 585 tempfilename = mess.mid( 11, len );
586 if ( !QFile::exists( tempfilename ) ) 586 if ( !QFile::exists( tempfilename ) )
587 error = true; 587 error = true;
588 } 588 }
589 if ( ! error ) { 589 if ( ! error ) {
590 filename = tempfilename; 590 filename = tempfilename;
591 } 591 }
592 mAlarmMessage = mess.mid( 11+len+3+9 ); 592 mAlarmMessage = mess.mid( 11+len+3+9 );
593 //qDebug("audio file command %s ",tempfilename.latin1() ); 593 //qDebug("audio file command %s ",tempfilename.latin1() );
594 } 594 }
595 if ( mess.left( 9 ) == "cal_alarm") { 595 if ( mess.left( 9 ) == "cal_alarm") {
596 mAlarmMessage = mess.mid( 9 ) ; 596 mAlarmMessage = mess.mid( 9 ) ;
597 } 597 }
598 598
599 startAlarm( mAlarmMessage, filename ); 599 startAlarm( mAlarmMessage, filename );
600 600
601 601
602} 602}
603 603
604void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 604void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
605{ 605{
606 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 606 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
607 607
608 mSuspendAlarmNotification = noti; 608 mSuspendAlarmNotification = noti;
609 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 609 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
610 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 610 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
611 mSuspendTimer->start( ms , true ); 611 mSuspendTimer->start( ms , true );
612 612
613} 613}
614 614
615void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 615void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
616{ 616{
617 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 617 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
618 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 618 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
619#ifndef DESKTOP_VERSION 619#ifndef DESKTOP_VERSION
620 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); 620 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() );
621#endif 621#endif
622 return; 622 return;
623 } 623 }
624 int maxSec; 624 int maxSec;
625 //maxSec = 5; //testing only 625 //maxSec = 5; //testing only
626 maxSec = 86400+3600; // one day+1hour 626 maxSec = 86400+3600; // one day+1hour
627 mAlarmNotification = noti; 627 mAlarmNotification = noti;
628 int sec = QDateTime::currentDateTime().secsTo( qdt ); 628 int sec = QDateTime::currentDateTime().secsTo( qdt );
629 if ( sec > maxSec ) { 629 if ( sec > maxSec ) {
630 mRecheckAlarmTimer->start( maxSec * 1000 ); 630 mRecheckAlarmTimer->start( maxSec * 1000 );
631 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 631 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
632 return; 632 return;
633 } else { 633 } else {
634 mRecheckAlarmTimer->stop(); 634 mRecheckAlarmTimer->stop();
635 } 635 }
636 //qDebug("Alarm timer started with secs: %d ", sec); 636 //qDebug("Alarm timer started with secs: %d ", sec);
637 mAlarmTimer->start( sec *1000 , true ); 637 mAlarmTimer->start( sec *1000 , true );
638 638
639} 639}
640// called by mRecheckAlarmTimer to get next alarm 640// called by mRecheckAlarmTimer to get next alarm
641// we need this, because a QTimer has only a max range of 25 days 641// we need this, because a QTimer has only a max range of 25 days
642void CalendarView::recheckTimerAlarm() 642void CalendarView::recheckTimerAlarm()
643{ 643{
644 mAlarmTimer->stop(); 644 mAlarmTimer->stop();
645 mRecheckAlarmTimer->stop(); 645 mRecheckAlarmTimer->stop();
646 mCalendar->checkAlarmForIncidence( 0, true ); 646 mCalendar->checkAlarmForIncidence( 0, true );
647} 647}
648void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 648void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
649{ 649{
650 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 650 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
651 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 651 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
652#ifndef DESKTOP_VERSION 652#ifndef DESKTOP_VERSION
653 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 653 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
654#endif 654#endif
655 return; 655 return;
656 } 656 }
657 mAlarmTimer->stop(); 657 mAlarmTimer->stop();
658} 658}
659void CalendarView::selectWeekNum ( int num ) 659void CalendarView::selectWeekNum ( int num )
660{ 660{
661 dateNavigator()->blockSignals( true ); 661 dateNavigator()->blockSignals( true );
662 dateNavigator()->selectWeek( num ); 662 dateNavigator()->selectWeek( num );
663 dateNavigator()->blockSignals( false ); 663 dateNavigator()->blockSignals( false );
664 mViewManager->showWeekView(); 664 mViewManager->showWeekView();
665} 665}
666KOViewManager *CalendarView::viewManager() 666KOViewManager *CalendarView::viewManager()
667{ 667{
668 return mViewManager; 668 return mViewManager;
669} 669}
670 670
671KODialogManager *CalendarView::dialogManager() 671KODialogManager *CalendarView::dialogManager()
672{ 672{
673 return mDialogManager; 673 return mDialogManager;
674} 674}
675 675
676QDate CalendarView::startDate() 676QDate CalendarView::startDate()
677{ 677{
678 DateList dates = mNavigator->selectedDates(); 678 DateList dates = mNavigator->selectedDates();
679 679
680 return dates.first(); 680 return dates.first();
681} 681}
682 682
683QDate CalendarView::endDate() 683QDate CalendarView::endDate()
684{ 684{
685 DateList dates = mNavigator->selectedDates(); 685 DateList dates = mNavigator->selectedDates();
686 686
687 return dates.last(); 687 return dates.last();
688} 688}
689 689
690 690
691void CalendarView::createPrinter() 691void CalendarView::createPrinter()
692{ 692{
693#ifndef KORG_NOPRINTER 693#ifndef KORG_NOPRINTER
694 if (!mCalPrinter) { 694 if (!mCalPrinter) {
695 mCalPrinter = new CalPrinter(this, mCalendar); 695 mCalPrinter = new CalPrinter(this, mCalendar);
696 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 696 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
697 } 697 }
698#endif 698#endif
699} 699}
700 700
701 701
702//KOPrefs::instance()->mWriteBackFile 702//KOPrefs::instance()->mWriteBackFile
703//KOPrefs::instance()->mWriteBackExistingOnly 703//KOPrefs::instance()->mWriteBackExistingOnly
704 704
705// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 705// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
706// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 706// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
707// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 707// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
708// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 708// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
709// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 709// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
710// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 710// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
711 711
712int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 712int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
713{ 713{
714 714
715 // 0 equal 715 // 0 equal
716 // 1 take local 716 // 1 take local
717 // 2 take remote 717 // 2 take remote
718 // 3 cancel 718 // 3 cancel
719 QDateTime lastSync = mLastCalendarSync; 719 QDateTime lastSync = mLastCalendarSync;
720 QDateTime localMod = local->lastModified(); 720 QDateTime localMod = local->lastModified();
721 QDateTime remoteMod = remote->lastModified(); 721 QDateTime remoteMod = remote->lastModified();
722 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 722 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
723 bool remCh, locCh; 723 bool remCh, locCh;
724 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 724 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
725 //if ( remCh ) 725 //if ( remCh )
726 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 726 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
727 locCh = ( localMod > mLastCalendarSync ); 727 locCh = ( localMod > mLastCalendarSync );
728 if ( !remCh && ! locCh ) { 728 if ( !remCh && ! locCh ) {
729 //qDebug("both not changed "); 729 //qDebug("both not changed ");
730 lastSync = localMod.addDays(1); 730 lastSync = localMod.addDays(1);
731 if ( mode <= SYNC_PREF_ASK ) 731 if ( mode <= SYNC_PREF_ASK )
732 return 0; 732 return 0;
733 } else { 733 } else {
734 if ( locCh ) { 734 if ( locCh ) {
735 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); 735 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1());
736 lastSync = localMod.addDays( -1 ); 736 lastSync = localMod.addDays( -1 );
737 if ( !remCh ) 737 if ( !remCh )
738 remoteMod = ( lastSync.addDays( -1 ) ); 738 remoteMod = ( lastSync.addDays( -1 ) );
739 } else { 739 } else {
740 //qDebug(" not loc changed "); 740 //qDebug(" not loc changed ");
741 lastSync = localMod.addDays( 1 ); 741 lastSync = localMod.addDays( 1 );
742 if ( remCh ) 742 if ( remCh )
743 remoteMod =( lastSync.addDays( 1 ) ); 743 remoteMod =( lastSync.addDays( 1 ) );
744 744
745 } 745 }
746 } 746 }
747 full = true; 747 full = true;
748 if ( mode < SYNC_PREF_ASK ) 748 if ( mode < SYNC_PREF_ASK )
749 mode = SYNC_PREF_ASK; 749 mode = SYNC_PREF_ASK;
750 } else { 750 } else {
751 if ( localMod == remoteMod ) 751 if ( localMod == remoteMod )
752 // if ( local->revision() == remote->revision() ) 752 // if ( local->revision() == remote->revision() )
753 return 0; 753 return 0;
754 754
755 } 755 }
756 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 756 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
757 757
758 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); 758 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision());
759 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); 759 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() );
760 //full = true; //debug only 760 //full = true; //debug only
761 if ( full ) { 761 if ( full ) {
762 bool equ = false; 762 bool equ = false;
763 if ( local->type() == "Event" ) { 763 if ( local->type() == "Event" ) {
764 equ = (*((Event*) local) == *((Event*) remote)); 764 equ = (*((Event*) local) == *((Event*) remote));
765 } 765 }
766 else if ( local->type() =="Todo" ) 766 else if ( local->type() =="Todo" )
767 equ = (*((Todo*) local) == (*(Todo*) remote)); 767 equ = (*((Todo*) local) == (*(Todo*) remote));
768 else if ( local->type() =="Journal" ) 768 else if ( local->type() =="Journal" )
769 equ = (*((Journal*) local) == *((Journal*) remote)); 769 equ = (*((Journal*) local) == *((Journal*) remote));
770 if ( equ ) { 770 if ( equ ) {
771 //qDebug("equal "); 771 //qDebug("equal ");
772 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 772 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
773 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 773 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
774 } 774 }
775 if ( mode < SYNC_PREF_FORCE_LOCAL ) 775 if ( mode < SYNC_PREF_FORCE_LOCAL )
776 return 0; 776 return 0;
777 777
778 }//else //debug only 778 }//else //debug only
779 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 779 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
780 } 780 }
781 int result; 781 int result;
782 bool localIsNew; 782 bool localIsNew;
783 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); 783 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() );
784 784
785 if ( full && mode < SYNC_PREF_NEWEST ) 785 if ( full && mode < SYNC_PREF_NEWEST )
786 mode = SYNC_PREF_ASK; 786 mode = SYNC_PREF_ASK;
787 787
788 switch( mode ) { 788 switch( mode ) {
789 case SYNC_PREF_LOCAL: 789 case SYNC_PREF_LOCAL:
790 if ( lastSync > remoteMod ) 790 if ( lastSync > remoteMod )
791 return 1; 791 return 1;
792 if ( lastSync > localMod ) 792 if ( lastSync > localMod )
793 return 2; 793 return 2;
794 return 1; 794 return 1;
795 break; 795 break;
796 case SYNC_PREF_REMOTE: 796 case SYNC_PREF_REMOTE:
797 if ( lastSync > remoteMod ) 797 if ( lastSync > remoteMod )
798 return 1; 798 return 1;
799 if ( lastSync > localMod ) 799 if ( lastSync > localMod )
800 return 2; 800 return 2;
801 return 2; 801 return 2;
802 break; 802 break;
803 case SYNC_PREF_NEWEST: 803 case SYNC_PREF_NEWEST:
804 if ( localMod > remoteMod ) 804 if ( localMod > remoteMod )
805 return 1; 805 return 1;
806 else 806 else
807 return 2; 807 return 2;
808 break; 808 break;
809 case SYNC_PREF_ASK: 809 case SYNC_PREF_ASK:
810 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 810 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
811 if ( lastSync > remoteMod ) 811 if ( lastSync > remoteMod )
812 return 1; 812 return 1;
813 if ( lastSync > localMod ) 813 if ( lastSync > localMod )
814 return 2; 814 return 2;
815 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 815 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
816 localIsNew = localMod >= remoteMod; 816 localIsNew = localMod >= remoteMod;
817 if ( localIsNew ) 817 if ( localIsNew )
818 getEventViewerDialog()->setColorMode( 1 ); 818 getEventViewerDialog()->setColorMode( 1 );
819 else 819 else
820 getEventViewerDialog()->setColorMode( 2 ); 820 getEventViewerDialog()->setColorMode( 2 );
821 getEventViewerDialog()->setIncidence(local); 821 getEventViewerDialog()->setIncidence(local);
822 if ( localIsNew ) 822 if ( localIsNew )
823 getEventViewerDialog()->setColorMode( 2 ); 823 getEventViewerDialog()->setColorMode( 2 );
824 else 824 else
825 getEventViewerDialog()->setColorMode( 1 ); 825 getEventViewerDialog()->setColorMode( 1 );
826 getEventViewerDialog()->addIncidence(remote); 826 getEventViewerDialog()->addIncidence(remote);
827 getEventViewerDialog()->setColorMode( 0 ); 827 getEventViewerDialog()->setColorMode( 0 );
828 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 828 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
829 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 829 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
830 getEventViewerDialog()->showMe(); 830 getEventViewerDialog()->showMe();
831 result = getEventViewerDialog()->executeS( localIsNew ); 831 result = getEventViewerDialog()->executeS( localIsNew );
832 return result; 832 return result;
833 833
834 break; 834 break;
835 case SYNC_PREF_FORCE_LOCAL: 835 case SYNC_PREF_FORCE_LOCAL:
836 return 1; 836 return 1;
837 break; 837 break;
838 case SYNC_PREF_FORCE_REMOTE: 838 case SYNC_PREF_FORCE_REMOTE:
839 return 2; 839 return 2;
840 break; 840 break;
841 841
842 default: 842 default:
843 // SYNC_PREF_TAKE_BOTH not implemented 843 // SYNC_PREF_TAKE_BOTH not implemented
844 break; 844 break;
845 } 845 }
846 return 0; 846 return 0;
847} 847}
848Event* CalendarView::getLastSyncEvent() 848Event* CalendarView::getLastSyncEvent()
849{ 849{
850 Event* lse; 850 Event* lse;
851 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 851 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
852 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 852 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
853 if (!lse) { 853 if (!lse) {
854 lse = new Event(); 854 lse = new Event();
855 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 855 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
856 QString sum = ""; 856 QString sum = "";
857 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 857 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
858 sum = "E: "; 858 sum = "E: ";
859 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 859 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
860 lse->setDtStart( mLastCalendarSync ); 860 lse->setDtStart( mLastCalendarSync );
861 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 861 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
862 lse->setCategories( i18n("SyncEvent") ); 862 lse->setCategories( i18n("SyncEvent") );
863 lse->setReadOnly( true ); 863 lse->setReadOnly( true );
864 mCalendar->addEvent( lse ); 864 mCalendar->addEvent( lse );
865 } 865 }
866 866
867 return lse; 867 return lse;
868 868
869} 869}
870 870
871// we check, if the to delete event has a id for a profile 871// we check, if the to delete event has a id for a profile
872// if yes, we set this id in the profile to delete 872// if yes, we set this id in the profile to delete
873void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 873void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
874{ 874{
875 if ( lastSync.count() == 0 ) { 875 if ( lastSync.count() == 0 ) {
876 //qDebug(" lastSync.count() == 0"); 876 //qDebug(" lastSync.count() == 0");
877 return; 877 return;
878 } 878 }
879 if ( toDelete->type() == "Journal" ) 879 if ( toDelete->type() == "Journal" )
880 return; 880 return;
881 881
882 Event* eve = lastSync.first(); 882 Event* eve = lastSync.first();
883 883
884 while ( eve ) { 884 while ( eve ) {
885 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 885 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
886 if ( !id.isEmpty() ) { 886 if ( !id.isEmpty() ) {
887 QString des = eve->description(); 887 QString des = eve->description();
888 QString pref = "e"; 888 QString pref = "e";
889 if ( toDelete->type() == "Todo" ) 889 if ( toDelete->type() == "Todo" )
890 pref = "t"; 890 pref = "t";
891 des += pref+ id + ","; 891 des += pref+ id + ",";
892 eve->setReadOnly( false ); 892 eve->setReadOnly( false );
893 eve->setDescription( des ); 893 eve->setDescription( des );
894 //qDebug("setdes %s ", des.latin1()); 894 //qDebug("setdes %s ", des.latin1());
895 eve->setReadOnly( true ); 895 eve->setReadOnly( true );
896 } 896 }
897 eve = lastSync.next(); 897 eve = lastSync.next();
898 } 898 }
899 899
900} 900}
901void CalendarView::checkExternalId( Incidence * inc ) 901void CalendarView::checkExternalId( Incidence * inc )
902{ 902{
903 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 903 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
904 checkExternSyncEvent( lastSync, inc ); 904 checkExternSyncEvent( lastSync, inc );
905 905
906} 906}
907bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 907bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
908{ 908{
909 bool syncOK = true; 909 bool syncOK = true;
910 int addedEvent = 0; 910 int addedEvent = 0;
911 int addedEventR = 0; 911 int addedEventR = 0;
912 int deletedEventR = 0; 912 int deletedEventR = 0;
913 int deletedEventL = 0; 913 int deletedEventL = 0;
914 int changedLocal = 0; 914 int changedLocal = 0;
915 int changedRemote = 0; 915 int changedRemote = 0;
916 int filteredIN = 0; 916 int filteredIN = 0;
917 int filteredOUT = 0; 917 int filteredOUT = 0;
918 //QPtrList<Event> el = local->rawEvents(); 918 //QPtrList<Event> el = local->rawEvents();
919 Event* eventR; 919 Event* eventR;
920 QString uid; 920 QString uid;
921 int take; 921 int take;
922 Event* eventL; 922 Event* eventL;
923 Event* eventRSync; 923 Event* eventRSync;
924 Event* eventLSync; 924 Event* eventLSync;
925 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 925 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
926 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 926 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
927 bool fullDateRange = false; 927 bool fullDateRange = false;
928 local->resetTempSyncStat(); 928 local->resetTempSyncStat();
929 mLastCalendarSync = QDateTime::currentDateTime(); 929 mLastCalendarSync = QDateTime::currentDateTime();
930 if ( mSyncManager->syncWithDesktop() ) { 930 if ( mSyncManager->syncWithDesktop() ) {
931 remote->resetPilotStat(1); 931 remote->resetPilotStat(1);
932 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 932 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
933 mLastCalendarSync = KSyncManager::mRequestedSyncEvent; 933 mLastCalendarSync = KSyncManager::mRequestedSyncEvent;
934 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); 934 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() );
935 } else { 935 } else {
936 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 936 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
937 } 937 }
938 } 938 }
939 QDateTime modifiedCalendar = mLastCalendarSync; 939 QDateTime modifiedCalendar = mLastCalendarSync;
940 eventLSync = getLastSyncEvent(); 940 eventLSync = getLastSyncEvent();
941 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 941 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
942 if ( eventR ) { 942 if ( eventR ) {
943 eventRSync = (Event*) eventR->clone(); 943 eventRSync = (Event*) eventR->clone();
944 remote->deleteEvent(eventR ); 944 remote->deleteEvent(eventR );
945 945
946 } else { 946 } else {
947 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { 947 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) {
948 eventRSync = (Event*)eventLSync->clone(); 948 eventRSync = (Event*)eventLSync->clone();
949 } else { 949 } else {
950 fullDateRange = true; 950 fullDateRange = true;
951 eventRSync = new Event(); 951 eventRSync = new Event();
952 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 952 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
953 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 953 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
954 eventRSync->setDtStart( mLastCalendarSync ); 954 eventRSync->setDtStart( mLastCalendarSync );
955 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 955 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
956 eventRSync->setCategories( i18n("SyncEvent") ); 956 eventRSync->setCategories( i18n("SyncEvent") );
957 } 957 }
958 } 958 }
959 if ( eventLSync->dtStart() == mLastCalendarSync ) 959 if ( eventLSync->dtStart() == mLastCalendarSync )
960 fullDateRange = true; 960 fullDateRange = true;
961 961
962 if ( ! fullDateRange ) { 962 if ( ! fullDateRange ) {
963 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 963 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
964 964
965 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 965 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
966 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 966 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
967 fullDateRange = true; 967 fullDateRange = true;
968 } 968 }
969 } 969 }
970 if ( mSyncManager->syncWithDesktop() ) { 970 if ( mSyncManager->syncWithDesktop() ) {
971 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); 971 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync );
972 } 972 }
973 if ( fullDateRange ) 973 if ( fullDateRange )
974 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 974 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
975 else 975 else
976 mLastCalendarSync = eventLSync->dtStart(); 976 mLastCalendarSync = eventLSync->dtStart();
977 // for resyncing if own file has changed 977 // for resyncing if own file has changed
978 if ( mCurrentSyncDevice == "deleteaftersync" ) { 978 if ( mCurrentSyncDevice == "deleteaftersync" ) {
979 mLastCalendarSync = loadedFileVersion; 979 mLastCalendarSync = loadedFileVersion;
980 //qDebug("setting mLastCalendarSync "); 980 //qDebug("setting mLastCalendarSync ");
981 } 981 }
982 //qDebug("*************************** "); 982 //qDebug("*************************** ");
983 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); 983 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange);
984 QPtrList<Incidence> er = remote->rawIncidences(); 984 QPtrList<Incidence> er = remote->rawIncidences();
985 Incidence* inR = er.first(); 985 Incidence* inR = er.first();
986 Incidence* inL; 986 Incidence* inL;
987 QProgressBar bar( er.count(),0 ); 987 QProgressBar bar( er.count(),0 );
988 bar.setCaption (i18n("Syncing - close to abort!") ); 988 bar.setCaption (i18n("Syncing - close to abort!") );
989 989
990 // ************** setting up filter ************* 990 // ************** setting up filter *************
991 CalFilter *filterIN = 0; 991 CalFilter *filterIN = 0;
992 CalFilter *filterOUT = 0; 992 CalFilter *filterOUT = 0;
993 CalFilter *filter = mFilters.first(); 993 CalFilter *filter = mFilters.first();
994 while(filter) { 994 while(filter) {
995 if ( filter->name() == mSyncManager->mFilterInCal ) 995 if ( filter->name() == mSyncManager->mFilterInCal )
996 filterIN = filter; 996 filterIN = filter;
997 if ( filter->name() == mSyncManager->mFilterOutCal ) 997 if ( filter->name() == mSyncManager->mFilterOutCal )
998 filterOUT = filter; 998 filterOUT = filter;
999 filter = mFilters.next(); 999 filter = mFilters.next();
1000 } 1000 }
1001 int w = 300; 1001 int w = 300;
1002 if ( QApplication::desktop()->width() < 320 ) 1002 if ( QApplication::desktop()->width() < 320 )
1003 w = 220; 1003 w = 220;
1004 int h = bar.sizeHint().height() ; 1004 int h = bar.sizeHint().height() ;
1005 int dw = QApplication::desktop()->width(); 1005 int dw = QApplication::desktop()->width();
1006 int dh = QApplication::desktop()->height(); 1006 int dh = QApplication::desktop()->height();
1007 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1007 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1008 bar.show(); 1008 bar.show();
1009 int modulo = (er.count()/10)+1; 1009 int modulo = (er.count()/10)+1;
1010 int incCounter = 0; 1010 int incCounter = 0;
1011 while ( inR ) { 1011 while ( inR ) {
1012 if ( ! bar.isVisible() ) 1012 if ( ! bar.isVisible() )
1013 return false; 1013 return false;
1014 if ( incCounter % modulo == 0 ) 1014 if ( incCounter % modulo == 0 )
1015 bar.setProgress( incCounter ); 1015 bar.setProgress( incCounter );
1016 ++incCounter; 1016 ++incCounter;
1017 uid = inR->uid(); 1017 uid = inR->uid();
1018 bool skipIncidence = false; 1018 bool skipIncidence = false;
1019 if ( uid.left(15) == QString("last-syncEvent-") ) 1019 if ( uid.left(15) == QString("last-syncEvent-") )
1020 skipIncidence = true; 1020 skipIncidence = true;
1021 QString idS; 1021 QString idS;
1022 qApp->processEvents(); 1022 qApp->processEvents();
1023 if ( !skipIncidence ) { 1023 if ( !skipIncidence ) {
1024 inL = local->incidence( uid ); 1024 inL = local->incidence( uid );
1025 if ( inL ) { // maybe conflict - same uid in both calendars 1025 if ( inL ) { // maybe conflict - same uid in both calendars
1026 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1026 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1027 //qDebug("take %d %s ", take, inL->summary().latin1()); 1027 //qDebug("take %d %s ", take, inL->summary().latin1());
1028 if ( take == 3 ) 1028 if ( take == 3 )
1029 return false; 1029 return false;
1030 if ( take == 1 ) {// take local ********************** 1030 if ( take == 1 ) {// take local **********************
1031 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1031 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1032 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1032 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1033 else 1033 else
1034 idS = inR->IDStr(); 1034 idS = inR->IDStr();
1035 remote->deleteIncidence( inR ); 1035 remote->deleteIncidence( inR );
1036 inR = inL->clone(); 1036 inR = inL->clone();
1037 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1037 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1038 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1038 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1039 inR->setIDStr( idS ); 1039 inR->setIDStr( idS );
1040 remote->addIncidence( inR ); 1040 remote->addIncidence( inR );
1041 if ( mSyncManager->syncWithDesktop() ) 1041 if ( mSyncManager->syncWithDesktop() )
1042 inR->setPilotId( 2 ); 1042 inR->setPilotId( 2 );
1043 ++changedRemote; 1043 ++changedRemote;
1044 } else {// take remote ********************** 1044 } else {// take remote **********************
1045 idS = inL->IDStr(); 1045 idS = inL->IDStr();
1046 int pid = inL->pilotId(); 1046 int pid = inL->pilotId();
1047 local->deleteIncidence( inL ); 1047 local->deleteIncidence( inL );
1048 inL = inR->clone(); 1048 inL = inR->clone();
1049 if ( mSyncManager->syncWithDesktop() ) 1049 if ( mSyncManager->syncWithDesktop() )
1050 inL->setPilotId( pid ); 1050 inL->setPilotId( pid );
1051 inL->setIDStr( idS ); 1051 inL->setIDStr( idS );
1052 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1052 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1053 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1053 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1054 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1054 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1055 } 1055 }
1056 local->addIncidence( inL ); 1056 local->addIncidence( inL );
1057 ++changedLocal; 1057 ++changedLocal;
1058 } 1058 }
1059 } 1059 }
1060 } else { // no conflict ********** add or delete remote 1060 } else { // no conflict ********** add or delete remote
1061 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ 1061 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){
1062 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1062 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1063 QString des = eventLSync->description(); 1063 QString des = eventLSync->description();
1064 QString pref = "e"; 1064 QString pref = "e";
1065 if ( inR->type() == "Todo" ) 1065 if ( inR->type() == "Todo" )
1066 pref = "t"; 1066 pref = "t";
1067 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1067 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1068 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1068 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1069 //remote->deleteIncidence( inR ); 1069 //remote->deleteIncidence( inR );
1070 ++deletedEventR; 1070 ++deletedEventR;
1071 } else { 1071 } else {
1072 inR->setLastModified( modifiedCalendar ); 1072 inR->setLastModified( modifiedCalendar );
1073 inL = inR->clone(); 1073 inL = inR->clone();
1074 inL->setIDStr( ":" ); 1074 inL->setIDStr( ":" );
1075 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1075 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1076 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1076 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1077 local->addIncidence( inL ); 1077 local->addIncidence( inL );
1078 ++addedEvent; 1078 ++addedEvent;
1079 1079
1080 } 1080 }
1081 } else { 1081 } else {
1082 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1082 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1083 inR->setLastModified( modifiedCalendar ); 1083 inR->setLastModified( modifiedCalendar );
1084 inL = inR->clone(); 1084 inL = inR->clone();
1085 inL->setIDStr( ":" ); 1085 inL->setIDStr( ":" );
1086 local->addIncidence( inL ); 1086 local->addIncidence( inL );
1087 ++addedEvent; 1087 ++addedEvent;
1088 1088
1089 } else { 1089 } else {
1090 checkExternSyncEvent(eventRSyncSharp, inR); 1090 checkExternSyncEvent(eventRSyncSharp, inR);
1091 remote->deleteIncidence( inR ); 1091 remote->deleteIncidence( inR );
1092 ++deletedEventR; 1092 ++deletedEventR;
1093 } 1093 }
1094 } 1094 }
1095 } else { 1095 } else {
1096 ++filteredIN; 1096 ++filteredIN;
1097 } 1097 }
1098 } 1098 }
1099 } 1099 }
1100 inR = er.next(); 1100 inR = er.next();
1101 } 1101 }
1102 QPtrList<Incidence> el = local->rawIncidences(); 1102 QPtrList<Incidence> el = local->rawIncidences();
1103 inL = el.first(); 1103 inL = el.first();
1104 modulo = (el.count()/10)+1; 1104 modulo = (el.count()/10)+1;
1105 bar.setCaption (i18n("Add / remove events") ); 1105 bar.setCaption (i18n("Add / remove events") );
1106 bar.setTotalSteps ( el.count() ) ; 1106 bar.setTotalSteps ( el.count() ) ;
1107 bar.show(); 1107 bar.show();
1108 incCounter = 0; 1108 incCounter = 0;
1109 1109
1110 while ( inL ) { 1110 while ( inL ) {
1111 1111
1112 qApp->processEvents(); 1112 qApp->processEvents();
1113 if ( ! bar.isVisible() ) 1113 if ( ! bar.isVisible() )
1114 return false; 1114 return false;
1115 if ( incCounter % modulo == 0 ) 1115 if ( incCounter % modulo == 0 )
1116 bar.setProgress( incCounter ); 1116 bar.setProgress( incCounter );
1117 ++incCounter; 1117 ++incCounter;
1118 uid = inL->uid(); 1118 uid = inL->uid();
1119 bool skipIncidence = false; 1119 bool skipIncidence = false;
1120 if ( uid.left(15) == QString("last-syncEvent-") ) 1120 if ( uid.left(15) == QString("last-syncEvent-") )
1121 skipIncidence = true; 1121 skipIncidence = true;
1122 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) 1122 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
1123 skipIncidence = true; 1123 skipIncidence = true;
1124 if ( !skipIncidence ) { 1124 if ( !skipIncidence ) {
1125 inR = remote->incidence( uid ); 1125 inR = remote->incidence( uid );
1126 if ( ! inR ) { 1126 if ( ! inR ) {
1127 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ 1127 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){
1128 // no conflict ********** add or delete local 1128 // no conflict ********** add or delete local
1129 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1129 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1130 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1130 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1131 checkExternSyncEvent(eventLSyncSharp, inL); 1131 checkExternSyncEvent(eventLSyncSharp, inL);
1132 local->deleteIncidence( inL ); 1132 local->deleteIncidence( inL );
1133 ++deletedEventL; 1133 ++deletedEventL;
1134 } else { 1134 } else {
1135 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1135 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1136 inL->removeID(mCurrentSyncDevice ); 1136 inL->removeID(mCurrentSyncDevice );
1137 ++addedEventR; 1137 ++addedEventR;
1138 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1138 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1139 inL->setLastModified( modifiedCalendar ); 1139 inL->setLastModified( modifiedCalendar );
1140 inR = inL->clone(); 1140 inR = inL->clone();
1141 inR->setIDStr( ":" ); 1141 inR->setIDStr( ":" );
1142 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1142 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1143 remote->addIncidence( inR ); 1143 remote->addIncidence( inR );
1144 } 1144 }
1145 } 1145 }
1146 } else { 1146 } else {
1147 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1147 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1148 checkExternSyncEvent(eventLSyncSharp, inL); 1148 checkExternSyncEvent(eventLSyncSharp, inL);
1149 local->deleteIncidence( inL ); 1149 local->deleteIncidence( inL );
1150 ++deletedEventL; 1150 ++deletedEventL;
1151 } else { 1151 } else {
1152 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1152 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1153 ++addedEventR; 1153 ++addedEventR;
1154 inL->setLastModified( modifiedCalendar ); 1154 inL->setLastModified( modifiedCalendar );
1155 inR = inL->clone(); 1155 inR = inL->clone();
1156 inR->setIDStr( ":" ); 1156 inR->setIDStr( ":" );
1157 remote->addIncidence( inR ); 1157 remote->addIncidence( inR );
1158 } 1158 }
1159 } 1159 }
1160 } 1160 }
1161 } else { 1161 } else {
1162 ++filteredOUT; 1162 ++filteredOUT;
1163 } 1163 }
1164 } 1164 }
1165 } 1165 }
1166 inL = el.next(); 1166 inL = el.next();
1167 } 1167 }
1168 int delFut = 0; 1168 int delFut = 0;
1169 int remRem = 0; 1169 int remRem = 0;
1170 if ( mSyncManager->mWriteBackInFuture ) { 1170 if ( mSyncManager->mWriteBackInFuture ) {
1171 er = remote->rawIncidences(); 1171 er = remote->rawIncidences();
1172 remRem = er.count(); 1172 remRem = er.count();
1173 inR = er.first(); 1173 inR = er.first();
1174 QDateTime dt; 1174 QDateTime dt;
1175 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); 1175 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) );
1176 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); 1176 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 );
1177 while ( inR ) { 1177 while ( inR ) {
1178 if ( inR->type() == "Todo" ) { 1178 if ( inR->type() == "Todo" ) {
1179 Todo * t = (Todo*)inR; 1179 Todo * t = (Todo*)inR;
1180 if ( t->hasDueDate() ) 1180 if ( t->hasDueDate() )
1181 dt = t->dtDue(); 1181 dt = t->dtDue();
1182 else 1182 else
1183 dt = cur.addSecs( 62 ); 1183 dt = cur.addSecs( 62 );
1184 } 1184 }
1185 else if (inR->type() == "Event" ) { 1185 else if (inR->type() == "Event" ) {
1186 bool ok; 1186 bool ok;
1187 dt = inR->getNextOccurence( cur, &ok ); 1187 dt = inR->getNextOccurence( cur, &ok );
1188 if ( !ok ) 1188 if ( !ok )
1189 dt = cur.addSecs( -62 ); 1189 dt = cur.addSecs( -62 );
1190 } 1190 }
1191 else 1191 else
1192 dt = inR->dtStart(); 1192 dt = inR->dtStart();
1193 if ( dt < cur || dt > end ) { 1193 if ( dt < cur || dt > end ) {
1194 remote->deleteIncidence( inR ); 1194 remote->deleteIncidence( inR );
1195 ++delFut; 1195 ++delFut;
1196 } 1196 }
1197 inR = er.next(); 1197 inR = er.next();
1198 } 1198 }
1199 } 1199 }
1200 bar.hide(); 1200 bar.hide();
1201 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1201 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1202 eventLSync->setReadOnly( false ); 1202 eventLSync->setReadOnly( false );
1203 eventLSync->setDtStart( mLastCalendarSync ); 1203 eventLSync->setDtStart( mLastCalendarSync );
1204 eventRSync->setDtStart( mLastCalendarSync ); 1204 eventRSync->setDtStart( mLastCalendarSync );
1205 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1205 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1206 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1206 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1207 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1207 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1208 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1208 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1209 eventLSync->setReadOnly( true ); 1209 eventLSync->setReadOnly( true );
1210 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); 1210 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL );
1211 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... 1211 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal...
1212 remote->addEvent( eventRSync ); 1212 remote->addEvent( eventRSync );
1213 else 1213 else
1214 delete eventRSync; 1214 delete eventRSync;
1215 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); 1215 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() );
1216 QString mes; 1216 QString mes;
1217 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); 1217 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT );
1218 QString delmess; 1218 QString delmess;
1219 if ( delFut ) { 1219 if ( delFut ) {
1220 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); 1220 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut);
1221 mes += delmess; 1221 mes += delmess;
1222 } 1222 }
1223 mes = i18n("Local calendar changed!\n") +mes; 1223 mes = i18n("Local calendar changed!\n") +mes;
1224 mCalendar->checkAlarmForIncidence( 0, true ); 1224 mCalendar->checkAlarmForIncidence( 0, true );
1225 qDebug( mes ); 1225 qDebug( mes );
1226 if ( mSyncManager->mShowSyncSummary ) { 1226 if ( mSyncManager->mShowSyncSummary ) {
1227 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 1227 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
1228 i18n("KO/Pi Synchronization"),i18n("Write back"))) { 1228 i18n("KO/Pi Synchronization"),i18n("Write back"))) {
1229 qDebug("KO: WB cancelled "); 1229 qDebug("KO: WB cancelled ");
1230 return false; 1230 return false;
1231 } 1231 }
1232 } 1232 }
1233 return syncOK; 1233 return syncOK;
1234} 1234}
1235 1235
1236void CalendarView::setSyncDevice( QString s ) 1236void CalendarView::setSyncDevice( QString s )
1237{ 1237{
1238 mCurrentSyncDevice= s; 1238 mCurrentSyncDevice= s;
1239} 1239}
1240void CalendarView::setSyncName( QString s ) 1240void CalendarView::setSyncName( QString s )
1241{ 1241{
1242 mCurrentSyncName= s; 1242 mCurrentSyncName= s;
1243} 1243}
1244bool CalendarView::syncCalendar(QString filename, int mode) 1244bool CalendarView::syncCalendar(QString filename, int mode)
1245{ 1245{
1246 //qDebug("syncCalendar %s ", filename.latin1()); 1246 //qDebug("syncCalendar %s ", filename.latin1());
1247 mGlobalSyncMode = SYNC_MODE_NORMAL; 1247 mGlobalSyncMode = SYNC_MODE_NORMAL;
1248 CalendarLocal* calendar = new CalendarLocal(); 1248 CalendarLocal* calendar = new CalendarLocal();
1249 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1249 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1250 FileStorage* storage = new FileStorage( calendar ); 1250 FileStorage* storage = new FileStorage( calendar );
1251 bool syncOK = false; 1251 bool syncOK = false;
1252 storage->setFileName( filename ); 1252 storage->setFileName( filename );
1253 // qDebug("loading ... "); 1253 // qDebug("loading ... ");
1254 if ( storage->load() ) { 1254 if ( storage->load() ) {
1255 getEventViewerDialog()->setSyncMode( true ); 1255 getEventViewerDialog()->setSyncMode( true );
1256 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1256 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1257 getEventViewerDialog()->setSyncMode( false ); 1257 getEventViewerDialog()->setSyncMode( false );
1258 if ( syncOK ) { 1258 if ( syncOK ) {
1259 if ( mSyncManager->mWriteBackFile ) 1259 if ( mSyncManager->mWriteBackFile )
1260 { 1260 {
1261 storage->setSaveFormat( new ICalFormat() ); 1261 storage->setSaveFormat( new ICalFormat() );
1262 storage->save(); 1262 storage->save();
1263 } 1263 }
1264 } 1264 }
1265 setModified( true ); 1265 setModified( true );
1266 } 1266 }
1267 delete storage; 1267 delete storage;
1268 delete calendar; 1268 delete calendar;
1269 if ( syncOK ) 1269 if ( syncOK )
1270 updateView(); 1270 updateView();
1271 return syncOK; 1271 return syncOK;
1272} 1272}
1273 1273
1274void CalendarView::syncExternal( int mode ) 1274void CalendarView::syncExternal( int mode )
1275{ 1275{
1276 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1276 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1277 1277
1278 qApp->processEvents(); 1278 qApp->processEvents();
1279 CalendarLocal* calendar = new CalendarLocal(); 1279 CalendarLocal* calendar = new CalendarLocal();
1280 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1280 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1281 bool syncOK = false; 1281 bool syncOK = false;
1282 bool loadSuccess = false; 1282 bool loadSuccess = false;
1283 PhoneFormat* phoneFormat = 0; 1283 PhoneFormat* phoneFormat = 0;
1284 emit tempDisableBR(true); 1284 emit tempDisableBR(true);
1285#ifndef DESKTOP_VERSION 1285#ifndef DESKTOP_VERSION
1286 SharpFormat* sharpFormat = 0; 1286 SharpFormat* sharpFormat = 0;
1287 if ( mode == 0 ) { // sharp 1287 if ( mode == 0 ) { // sharp
1288 sharpFormat = new SharpFormat () ; 1288 sharpFormat = new SharpFormat () ;
1289 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1289 loadSuccess = sharpFormat->load( calendar, mCalendar );
1290 1290
1291 } else 1291 } else
1292#endif 1292#endif
1293 if ( mode == 1 ) { // phone 1293 if ( mode == 1 ) { // phone
1294 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1294 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1295 mSyncManager->mPhoneDevice, 1295 mSyncManager->mPhoneDevice,
1296 mSyncManager->mPhoneConnection, 1296 mSyncManager->mPhoneConnection,
1297 mSyncManager->mPhoneModel); 1297 mSyncManager->mPhoneModel);
1298 loadSuccess = phoneFormat->load( calendar,mCalendar); 1298 loadSuccess = phoneFormat->load( calendar,mCalendar);
1299 1299
1300 } else { 1300 } else {
1301 emit tempDisableBR(false); 1301 emit tempDisableBR(false);
1302 return; 1302 return;
1303 } 1303 }
1304 if ( loadSuccess ) { 1304 if ( loadSuccess ) {
1305 getEventViewerDialog()->setSyncMode( true ); 1305 getEventViewerDialog()->setSyncMode( true );
1306 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1306 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1307 getEventViewerDialog()->setSyncMode( false ); 1307 getEventViewerDialog()->setSyncMode( false );
1308 qApp->processEvents(); 1308 qApp->processEvents();
1309 if ( syncOK ) { 1309 if ( syncOK ) {
1310 if ( mSyncManager->mWriteBackFile ) 1310 if ( mSyncManager->mWriteBackFile )
1311 { 1311 {
1312 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1312 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1313 Incidence* inc = iL.first(); 1313 Incidence* inc = iL.first();
1314 if ( phoneFormat ) { 1314 if ( phoneFormat ) {
1315 while ( inc ) { 1315 while ( inc ) {
1316 inc->removeID(mCurrentSyncDevice); 1316 inc->removeID(mCurrentSyncDevice);
1317 inc = iL.next(); 1317 inc = iL.next();
1318 } 1318 }
1319 } 1319 }
1320#ifndef DESKTOP_VERSION 1320#ifndef DESKTOP_VERSION
1321 if ( sharpFormat ) 1321 if ( sharpFormat )
1322 sharpFormat->save(calendar); 1322 sharpFormat->save(calendar);
1323#endif 1323#endif
1324 if ( phoneFormat ) 1324 if ( phoneFormat )
1325 phoneFormat->save(calendar); 1325 phoneFormat->save(calendar);
1326 iL = calendar->rawIncidences(); 1326 iL = calendar->rawIncidences();
1327 inc = iL.first(); 1327 inc = iL.first();
1328 Incidence* loc; 1328 Incidence* loc;
1329 while ( inc ) { 1329 while ( inc ) {
1330 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1330 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1331 loc = mCalendar->incidence(inc->uid() ); 1331 loc = mCalendar->incidence(inc->uid() );
1332 if ( loc ) { 1332 if ( loc ) {
1333 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1333 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1334 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1334 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1335 } 1335 }
1336 } 1336 }
1337 inc = iL.next(); 1337 inc = iL.next();
1338 } 1338 }
1339 Incidence* lse = getLastSyncEvent(); 1339 Incidence* lse = getLastSyncEvent();
1340 if ( lse ) { 1340 if ( lse ) {
1341 lse->setReadOnly( false ); 1341 lse->setReadOnly( false );
1342 lse->setDescription( "" ); 1342 lse->setDescription( "" );
1343 lse->setReadOnly( true ); 1343 lse->setReadOnly( true );
1344 } 1344 }
1345 } 1345 }
1346 } else { 1346 } else {
1347 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 1347 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
1348 } 1348 }
1349 setModified( true ); 1349 setModified( true );
1350 } else { 1350 } else {
1351 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1351 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1352 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1352 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1353 question, i18n("Ok")) ; 1353 question, i18n("Ok")) ;
1354 1354
1355 } 1355 }
1356 delete calendar; 1356 delete calendar;
1357 updateView(); 1357 updateView();
1358 emit tempDisableBR(false); 1358 emit tempDisableBR(false);
1359 return ;//syncOK; 1359 return ;//syncOK;
1360 1360
1361} 1361}
1362 1362
1363bool CalendarView::importBday() 1363bool CalendarView::importBday()
1364{ 1364{
1365#ifndef KORG_NOKABC 1365#ifndef KORG_NOKABC
1366 1366
1367#ifdef DESKTOP_VERSION 1367#ifdef DESKTOP_VERSION
1368 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1368 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1369 KABC::AddressBook::Iterator it; 1369 KABC::AddressBook::Iterator it;
1370 int count = 0; 1370 int count = 0;
1371 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1371 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1372 ++count; 1372 ++count;
1373 } 1373 }
1374 QProgressBar bar(count,0 ); 1374 QProgressBar bar(count,0 );
1375 int w = 300; 1375 int w = 300;
1376 if ( QApplication::desktop()->width() < 320 ) 1376 if ( QApplication::desktop()->width() < 320 )
1377 w = 220; 1377 w = 220;
1378 int h = bar.sizeHint().height() ; 1378 int h = bar.sizeHint().height() ;
1379 int dw = QApplication::desktop()->width(); 1379 int dw = QApplication::desktop()->width();
1380 int dh = QApplication::desktop()->height(); 1380 int dh = QApplication::desktop()->height();
1381 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1381 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1382 bar.show(); 1382 bar.show();
1383 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1383 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1384 qApp->processEvents(); 1384 qApp->processEvents();
1385 count = 0; 1385 count = 0;
1386 int addCount = 0; 1386 int addCount = 0;
1387 KCal::Attendee* a = 0; 1387 KCal::Attendee* a = 0;
1388 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1388 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1389 if ( ! bar.isVisible() ) 1389 if ( ! bar.isVisible() )
1390 return false; 1390 return false;
1391 bar.setProgress( count++ ); 1391 bar.setProgress( count++ );
1392 qApp->processEvents(); 1392 qApp->processEvents();
1393 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1393 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1394 if ( (*it).birthday().date().isValid() ){ 1394 if ( (*it).birthday().date().isValid() ){
1395 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1395 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1396 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1396 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1397 ++addCount; 1397 ++addCount;
1398 } 1398 }
1399 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1399 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1400 if ( anni.isValid() ){ 1400 if ( anni.isValid() ){
1401 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1401 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1402 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1402 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1403 ++addCount; 1403 ++addCount;
1404 } 1404 }
1405 } 1405 }
1406 updateView(); 1406 updateView();
1407 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1407 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1408#else //DESKTOP_VERSION 1408#else //DESKTOP_VERSION
1409 1409
1410 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 1410 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
1411 // the result should now arrive through method insertBirthdays 1411 // the result should now arrive through method insertBirthdays
1412 1412
1413#endif //DESKTOP_VERSION 1413#endif //DESKTOP_VERSION
1414 1414
1415#endif //KORG_NOKABC 1415#endif //KORG_NOKABC
1416 1416
1417 1417
1418 return true; 1418 return true;
1419} 1419}
1420 1420
1421// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI 1421// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
1422void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, 1422void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
1423 const QStringList& anniversaryList, const QStringList& realNameList, 1423 const QStringList& anniversaryList, const QStringList& realNameList,
1424 const QStringList& emailList, const QStringList& assembledNameList, 1424 const QStringList& emailList, const QStringList& assembledNameList,
1425 const QStringList& uidList) 1425 const QStringList& uidList)
1426{ 1426{
1427 //qDebug("KO::CalendarView::insertBirthdays"); 1427 //qDebug("KO::CalendarView::insertBirthdays");
1428 if (uid == this->name()) 1428 if (uid == this->name())
1429 { 1429 {
1430 int count = birthdayList.count(); 1430 int count = birthdayList.count();
1431 int addCount = 0; 1431 int addCount = 0;
1432 KCal::Attendee* a = 0; 1432 KCal::Attendee* a = 0;
1433 1433
1434 //qDebug("CalView 1 %i", count); 1434 //qDebug("CalView 1 %i", count);
1435 1435
1436 QProgressBar bar(count,0 ); 1436 QProgressBar bar(count,0 );
1437 int w = 300; 1437 int w = 300;
1438 if ( QApplication::desktop()->width() < 320 ) 1438 if ( QApplication::desktop()->width() < 320 )
1439 w = 220; 1439 w = 220;
1440 int h = bar.sizeHint().height() ; 1440 int h = bar.sizeHint().height() ;
1441 int dw = QApplication::desktop()->width(); 1441 int dw = QApplication::desktop()->width();
1442 int dh = QApplication::desktop()->height(); 1442 int dh = QApplication::desktop()->height();
1443 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1443 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1444 bar.show(); 1444 bar.show();
1445 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 1445 bar.setCaption (i18n("inserting birthdays - close to abort!") );
1446 qApp->processEvents(); 1446 qApp->processEvents();
1447 1447
1448 QDate birthday; 1448 QDate birthday;
1449 QDate anniversary; 1449 QDate anniversary;
1450 QString realName; 1450 QString realName;
1451 QString email; 1451 QString email;
1452 QString assembledName; 1452 QString assembledName;
1453 QString uid; 1453 QString uid;
1454 bool ok = true; 1454 bool ok = true;
1455 for ( int i = 0; i < count; i++) 1455 for ( int i = 0; i < count; i++)
1456 { 1456 {
1457 if ( ! bar.isVisible() ) 1457 if ( ! bar.isVisible() )
1458 return; 1458 return;
1459 bar.setProgress( i ); 1459 bar.setProgress( i );
1460 qApp->processEvents(); 1460 qApp->processEvents();
1461 1461
1462 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); 1462 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
1463 if (!ok) { 1463 if (!ok) {
1464 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); 1464 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
1465 } 1465 }
1466 1466
1467 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); 1467 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
1468 if (!ok) { 1468 if (!ok) {
1469 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); 1469 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
1470 } 1470 }
1471 realName = realNameList[i]; 1471 realName = realNameList[i];
1472 email = emailList[i]; 1472 email = emailList[i];
1473 assembledName = assembledNameList[i]; 1473 assembledName = assembledNameList[i];
1474 uid = uidList[i]; 1474 uid = uidList[i];
1475 //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); 1475 //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() );
1476 1476
1477 if ( birthday.isValid() ){ 1477 if ( birthday.isValid() ){
1478 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1478 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1479 KCal::Attendee::ReqParticipant,uid) ; 1479 KCal::Attendee::ReqParticipant,uid) ;
1480 if ( addAnniversary( birthday, assembledName, a, true ) ) 1480 if ( addAnniversary( birthday, assembledName, a, true ) )
1481 ++addCount; 1481 ++addCount;
1482 } 1482 }
1483 1483
1484 if ( anniversary.isValid() ){ 1484 if ( anniversary.isValid() ){
1485 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1485 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1486 KCal::Attendee::ReqParticipant,uid) ; 1486 KCal::Attendee::ReqParticipant,uid) ;
1487 if ( addAnniversary( anniversary, assembledName, a, false ) ) 1487 if ( addAnniversary( anniversary, assembledName, a, false ) )
1488 ++addCount; 1488 ++addCount;
1489 } 1489 }
1490 } 1490 }
1491 1491
1492 updateView(); 1492 updateView();
1493 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1493 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1494 1494
1495 } 1495 }
1496 1496
1497} 1497}
1498 1498
1499 1499
1500 1500
1501bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1501bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1502{ 1502{
1503 //qDebug("addAnni "); 1503 //qDebug("addAnni ");
1504 Event * ev = new Event(); 1504 Event * ev = new Event();
1505 ev->setOrganizer(KOPrefs::instance()->email()); 1505 ev->setOrganizer(KOPrefs::instance()->email());
1506 if ( a ) { 1506 if ( a ) {
1507 ev->addAttendee( a ); 1507 ev->addAttendee( a );
1508 } 1508 }
1509 QString kind; 1509 QString kind;
1510 if ( birthday ) { 1510 if ( birthday ) {
1511 kind = i18n( "Birthday" ); 1511 kind = i18n( "Birthday" );
1512 ev->setSummary( name + " (" + QString::number(date.year()) +")"); 1512 ev->setSummary( name + " (" + QString::number(date.year()) +")");
1513 } 1513 }
1514 else { 1514 else {
1515 kind = i18n( "Anniversary" ); 1515 kind = i18n( "Anniversary" );
1516 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); 1516 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind );
1517 } 1517 }
1518 ev->setCategories( kind ); 1518 ev->setCategories( kind );
1519 ev->setDtStart( QDateTime(date) ); 1519 ev->setDtStart( QDateTime(date) );
1520 ev->setDtEnd( QDateTime(date) ); 1520 ev->setDtEnd( QDateTime(date) );
1521 ev->setFloats( true ); 1521 ev->setFloats( true );
1522 Recurrence * rec = ev->recurrence(); 1522 Recurrence * rec = ev->recurrence();
1523 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1523 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1524 rec->addYearlyNum( date.month() ); 1524 rec->addYearlyNum( date.month() );
1525 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1525 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1526 delete ev; 1526 delete ev;
1527 return false; 1527 return false;
1528 } 1528 }
1529 return true; 1529 return true;
1530 1530
1531} 1531}
1532bool CalendarView::importQtopia( const QString &categories, 1532bool CalendarView::importQtopia( const QString &categories,
1533 const QString &datebook, 1533 const QString &datebook,
1534 const QString &todolist ) 1534 const QString &todolist )
1535{ 1535{
1536 1536
1537 QtopiaFormat qtopiaFormat; 1537 QtopiaFormat qtopiaFormat;
1538 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1538 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1539 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1539 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1540 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1540 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1541 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1541 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1542 1542
1543 updateView(); 1543 updateView();
1544 return true; 1544 return true;
1545 1545
1546#if 0 1546#if 0
1547 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1547 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1548 mCurrentSyncDevice = "qtopia-XML"; 1548 mCurrentSyncDevice = "qtopia-XML";
1549 if ( mSyncManager->mAskForPreferences ) 1549 if ( mSyncManager->mAskForPreferences )
1550 edit_sync_options(); 1550 edit_sync_options();
1551 qApp->processEvents(); 1551 qApp->processEvents();
1552 CalendarLocal* calendar = new CalendarLocal(); 1552 CalendarLocal* calendar = new CalendarLocal();
1553 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1553 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1554 bool syncOK = false; 1554 bool syncOK = false;
1555 QtopiaFormat qtopiaFormat; 1555 QtopiaFormat qtopiaFormat;
1556 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1556 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1557 bool loadOk = true; 1557 bool loadOk = true;
1558 if ( !categories.isEmpty() ) 1558 if ( !categories.isEmpty() )
1559 loadOk = qtopiaFormat.load( calendar, categories ); 1559 loadOk = qtopiaFormat.load( calendar, categories );
1560 if ( loadOk && !datebook.isEmpty() ) 1560 if ( loadOk && !datebook.isEmpty() )
1561 loadOk = qtopiaFormat.load( calendar, datebook ); 1561 loadOk = qtopiaFormat.load( calendar, datebook );
1562 if ( loadOk && !todolist.isEmpty() ) 1562 if ( loadOk && !todolist.isEmpty() )
1563 loadOk = qtopiaFormat.load( calendar, todolist ); 1563 loadOk = qtopiaFormat.load( calendar, todolist );
1564 1564
1565 if ( loadOk ) { 1565 if ( loadOk ) {
1566 getEventViewerDialog()->setSyncMode( true ); 1566 getEventViewerDialog()->setSyncMode( true );
1567 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1567 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1568 getEventViewerDialog()->setSyncMode( false ); 1568 getEventViewerDialog()->setSyncMode( false );
1569 qApp->processEvents(); 1569 qApp->processEvents();
1570 if ( syncOK ) { 1570 if ( syncOK ) {
1571 if ( mSyncManager->mWriteBackFile ) 1571 if ( mSyncManager->mWriteBackFile )
1572 { 1572 {
1573 // write back XML file 1573 // write back XML file
1574 1574
1575 } 1575 }
1576 setModified( true ); 1576 setModified( true );
1577 } 1577 }
1578 } else { 1578 } else {
1579 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1579 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1580 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1580 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1581 question, i18n("Ok")) ; 1581 question, i18n("Ok")) ;
1582 } 1582 }
1583 delete calendar; 1583 delete calendar;
1584 updateView(); 1584 updateView();
1585 return syncOK; 1585 return syncOK;
1586 1586
1587 1587
1588#endif 1588#endif
1589 1589
1590} 1590}
1591 1591
1592void CalendarView::setSyncEventsReadOnly() 1592void CalendarView::setSyncEventsReadOnly()
1593{ 1593{
1594 Event * ev; 1594 Event * ev;
1595 QPtrList<Event> eL = mCalendar->rawEvents(); 1595 QPtrList<Event> eL = mCalendar->rawEvents();
1596 ev = eL.first(); 1596 ev = eL.first();
1597 while ( ev ) { 1597 while ( ev ) {
1598 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1598 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1599 ev->setReadOnly( true ); 1599 ev->setReadOnly( true );
1600 ev = eL.next(); 1600 ev = eL.next();
1601 } 1601 }
1602} 1602}
1603bool CalendarView::openCalendar(QString filename, bool merge) 1603bool CalendarView::openCalendar(QString filename, bool merge)
1604{ 1604{
1605 1605
1606 if (filename.isEmpty()) { 1606 if (filename.isEmpty()) {
1607 return false; 1607 return false;
1608 } 1608 }
1609 1609
1610 if (!QFile::exists(filename)) { 1610 if (!QFile::exists(filename)) {
1611 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1611 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1612 return false; 1612 return false;
1613 } 1613 }
1614 1614
1615 globalFlagBlockAgenda = 1; 1615 globalFlagBlockAgenda = 1;
1616 if (!merge) mCalendar->close(); 1616 if (!merge) mCalendar->close();
1617 1617
1618 mStorage->setFileName( filename ); 1618 mStorage->setFileName( filename );
1619 1619
1620 if ( mStorage->load() ) { 1620 if ( mStorage->load() ) {
1621 if ( merge ) ;//setModified( true ); 1621 if ( merge ) ;//setModified( true );
1622 else { 1622 else {
1623 //setModified( true ); 1623 //setModified( true );
1624 mViewManager->setDocumentId( filename ); 1624 mViewManager->setDocumentId( filename );
1625 mDialogManager->setDocumentId( filename ); 1625 mDialogManager->setDocumentId( filename );
1626 mTodoList->setDocumentId( filename ); 1626 mTodoList->setDocumentId( filename );
1627 } 1627 }
1628 globalFlagBlockAgenda = 2; 1628 globalFlagBlockAgenda = 2;
1629 // if ( getLastSyncEvent() ) 1629 // if ( getLastSyncEvent() )
1630 // getLastSyncEvent()->setReadOnly( true ); 1630 // getLastSyncEvent()->setReadOnly( true );
1631 mCalendar->reInitAlarmSettings(); 1631 mCalendar->reInitAlarmSettings();
1632 setSyncEventsReadOnly(); 1632 setSyncEventsReadOnly();
1633 updateUnmanagedViews(); 1633 updateUnmanagedViews();
1634 updateView(); 1634 updateView();
1635 if ( filename != MainWindow::defaultFileName() ) { 1635 if ( filename != MainWindow::defaultFileName() ) {
1636 saveCalendar( MainWindow::defaultFileName() ); 1636 saveCalendar( MainWindow::defaultFileName() );
1637 } else { 1637 } else {
1638 QFileInfo finf ( MainWindow::defaultFileName()); 1638 QFileInfo finf ( MainWindow::defaultFileName());
1639 if ( finf.exists() ) { 1639 if ( finf.exists() ) {
1640 setLoadedFileVersion( finf.lastModified () ); 1640 setLoadedFileVersion( finf.lastModified () );
1641 } 1641 }
1642 } 1642 }
1643 return true; 1643 return true;
1644 } else { 1644 } else {
1645 // while failing to load, the calendar object could 1645 // while failing to load, the calendar object could
1646 // have become partially populated. Clear it out. 1646 // have become partially populated. Clear it out.
1647 if ( !merge ) { 1647 if ( !merge ) {
1648 mCalendar->close(); 1648 mCalendar->close();
1649 mViewManager->setDocumentId( filename ); 1649 mViewManager->setDocumentId( filename );
1650 mDialogManager->setDocumentId( filename ); 1650 mDialogManager->setDocumentId( filename );
1651 mTodoList->setDocumentId( filename ); 1651 mTodoList->setDocumentId( filename );
1652 } 1652 }
1653 1653
1654 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1654 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1655 1655
1656 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 1656 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
1657 globalFlagBlockAgenda = 2; 1657 globalFlagBlockAgenda = 2;
1658 mCalendar->reInitAlarmSettings(); 1658 mCalendar->reInitAlarmSettings();
1659 setSyncEventsReadOnly(); 1659 setSyncEventsReadOnly();
1660 updateUnmanagedViews(); 1660 updateUnmanagedViews();
1661 updateView(); 1661 updateView();
1662 } 1662 }
1663 return false; 1663 return false;
1664} 1664}
1665void CalendarView::showOpenError() 1665void CalendarView::showOpenError()
1666{ 1666{
1667 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 1667 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
1668} 1668}
1669void CalendarView::setLoadedFileVersion(QDateTime dt) 1669void CalendarView::setLoadedFileVersion(QDateTime dt)
1670{ 1670{
1671 loadedFileVersion = dt; 1671 loadedFileVersion = dt;
1672} 1672}
1673bool CalendarView::checkFileChanged(QString fn) 1673bool CalendarView::checkFileChanged(QString fn)
1674{ 1674{
1675 QFileInfo finf ( fn ); 1675 QFileInfo finf ( fn );
1676 if ( !finf.exists() ) 1676 if ( !finf.exists() )
1677 return true; 1677 return true;
1678 QDateTime dt = finf.lastModified (); 1678 QDateTime dt = finf.lastModified ();
1679 if ( dt <= loadedFileVersion ) 1679 if ( dt <= loadedFileVersion )
1680 return false; 1680 return false;
1681 return true; 1681 return true;
1682 1682
1683} 1683}
1684void CalendarView::watchSavedFile() 1684void CalendarView::watchSavedFile()
1685{ 1685{
1686 QFileInfo finf ( MainWindow::defaultFileName()); 1686 QFileInfo finf ( MainWindow::defaultFileName());
1687 if ( !finf.exists() ) 1687 if ( !finf.exists() )
1688 return; 1688 return;
1689 QDateTime dt = finf.lastModified (); 1689 QDateTime dt = finf.lastModified ();
1690 if ( dt < loadedFileVersion ) { 1690 if ( dt < loadedFileVersion ) {
1691 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 1691 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
1692 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 1692 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1693 return; 1693 return;
1694 } 1694 }
1695 loadedFileVersion = dt; 1695 loadedFileVersion = dt;
1696} 1696}
1697 1697
1698bool CalendarView::checkFileVersion(QString fn) 1698bool CalendarView::checkFileVersion(QString fn)
1699{ 1699{
1700 QFileInfo finf ( fn ); 1700 QFileInfo finf ( fn );
1701 if ( !finf.exists() ) 1701 if ( !finf.exists() )
1702 return true; 1702 return true;
1703 QDateTime dt = finf.lastModified (); 1703 QDateTime dt = finf.lastModified ();
1704 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1704 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1705 //qDebug("file on disk version %s",dt.toString().latin1()); 1705 //qDebug("file on disk version %s",dt.toString().latin1());
1706 if ( dt <= loadedFileVersion ) 1706 if ( dt <= loadedFileVersion )
1707 return true; 1707 return true;
1708 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , 1708 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) ,
1709 i18n("KO/Pi Warning"),i18n("Overwrite"), 1709 i18n("KO/Pi Warning"),i18n("Overwrite"),
1710 i18n("Sync+save")); 1710 i18n("Sync+save"));
1711 1711
1712 if ( km == KMessageBox::Cancel ) 1712 if ( km == KMessageBox::Cancel )
1713 return false; 1713 return false;
1714 if ( km == KMessageBox::Yes ) 1714 if ( km == KMessageBox::Yes )
1715 return true; 1715 return true;
1716 1716
1717 setSyncDevice("deleteaftersync" ); 1717 setSyncDevice("deleteaftersync" );
1718 mSyncManager->mAskForPreferences = true; 1718 mSyncManager->mAskForPreferences = true;
1719 mSyncManager->mSyncAlgoPrefs = 3; 1719 mSyncManager->mSyncAlgoPrefs = 3;
1720 mSyncManager->mWriteBackFile = false; 1720 mSyncManager->mWriteBackFile = false;
1721 mSyncManager->mWriteBackExistingOnly = false; 1721 mSyncManager->mWriteBackExistingOnly = false;
1722 mSyncManager->mShowSyncSummary = false; 1722 mSyncManager->mShowSyncSummary = false;
1723 syncCalendar( fn, 3 ); 1723 syncCalendar( fn, 3 );
1724 Event * e = getLastSyncEvent(); 1724 Event * e = getLastSyncEvent();
1725 mCalendar->deleteEvent ( e ); 1725 mCalendar->deleteEvent ( e );
1726 updateView(); 1726 updateView();
1727 return true; 1727 return true;
1728} 1728}
1729 1729
1730bool CalendarView::saveCalendar( QString filename ) 1730bool CalendarView::saveCalendar( QString filename )
1731{ 1731{
1732 1732
1733 // Store back all unsaved data into calendar object 1733 // Store back all unsaved data into calendar object
1734 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1734 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1735 if ( mViewManager->currentView() ) 1735 if ( mViewManager->currentView() )
1736 mViewManager->currentView()->flushView(); 1736 mViewManager->currentView()->flushView();
1737 1737
1738 1738
1739 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 1739 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
1740 mStorage->setSaveFormat( new ICalFormat() ); 1740 mStorage->setSaveFormat( new ICalFormat() );
1741 mStorage->setFileName( filename ); 1741 mStorage->setFileName( filename );
1742 bool success; 1742 bool success;
1743 success = mStorage->save(); 1743 success = mStorage->save();
1744 if ( !success ) { 1744 if ( !success ) {
1745 return false; 1745 return false;
1746 } 1746 }
1747 if ( filename == MainWindow::defaultFileName() ) { 1747 if ( filename == MainWindow::defaultFileName() ) {
1748 setLoadedFileVersion( lfv ); 1748 setLoadedFileVersion( lfv );
1749 watchSavedFile(); 1749 watchSavedFile();
1750 } 1750 }
1751 return true; 1751 return true;
1752} 1752}
1753 1753
1754void CalendarView::closeCalendar() 1754void CalendarView::closeCalendar()
1755{ 1755{
1756 1756
1757 // child windows no longer valid 1757 // child windows no longer valid
1758 emit closingDown(); 1758 emit closingDown();
1759 1759
1760 mCalendar->close(); 1760 mCalendar->close();
1761 setModified(false); 1761 setModified(false);
1762 updateView(); 1762 updateView();
1763} 1763}
1764 1764
1765void CalendarView::archiveCalendar() 1765void CalendarView::archiveCalendar()
1766{ 1766{
1767 mDialogManager->showArchiveDialog(); 1767 mDialogManager->showArchiveDialog();
1768} 1768}
1769 1769
1770 1770
1771void CalendarView::readSettings() 1771void CalendarView::readSettings()
1772{ 1772{
1773 1773
1774 1774
1775 // mViewManager->showAgendaView(); 1775 // mViewManager->showAgendaView();
1776 QString str; 1776 QString str;
1777 //qDebug("CalendarView::readSettings() "); 1777 //qDebug("CalendarView::readSettings() ");
1778 // read settings from the KConfig, supplying reasonable 1778 // read settings from the KConfig, supplying reasonable
1779 // defaults where none are to be found 1779 // defaults where none are to be found
1780 KConfig *config = KOGlobals::config(); 1780 KConfig *config = KOGlobals::config();
1781#ifndef KORG_NOSPLITTER 1781#ifndef KORG_NOSPLITTER
1782 config->setGroup("KOrganizer Geometry"); 1782 config->setGroup("KOrganizer Geometry");
1783 1783
1784 QValueList<int> sizes = config->readIntListEntry("Separator1"); 1784 QValueList<int> sizes = config->readIntListEntry("Separator1");
1785 if (sizes.count() != 2) { 1785 if (sizes.count() != 2) {
1786 sizes << mDateNavigator->minimumSizeHint().width(); 1786 sizes << mDateNavigator->minimumSizeHint().width();
1787 sizes << 300; 1787 sizes << 300;
1788 } 1788 }
1789 mPanner->setSizes(sizes); 1789 mPanner->setSizes(sizes);
1790 1790
1791 sizes = config->readIntListEntry("Separator2"); 1791 sizes = config->readIntListEntry("Separator2");
1792 if ( ( mResourceView && sizes.count() == 4 ) || 1792 if ( ( mResourceView && sizes.count() == 4 ) ||
1793 ( !mResourceView && sizes.count() == 3 ) ) { 1793 ( !mResourceView && sizes.count() == 3 ) ) {
1794 mLeftSplitter->setSizes(sizes); 1794 mLeftSplitter->setSizes(sizes);
1795 } 1795 }
1796#endif 1796#endif
1797 globalFlagBlockAgenda = 1; 1797 globalFlagBlockAgenda = 1;
1798 mViewManager->showAgendaView(); 1798 mViewManager->showAgendaView();
1799 //mViewManager->readSettings( config ); 1799 //mViewManager->readSettings( config );
1800 mTodoList->restoreLayout(config,QString("Todo Layout")); 1800 mTodoList->restoreLayout(config,QString("Todo Layout"));
1801 readFilterSettings(config); 1801 readFilterSettings(config);
1802 config->setGroup( "Views" ); 1802 config->setGroup( "Views" );
1803 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 1803 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
1804 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 1804 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
1805 else if ( dateCount == 7 ) mNavigator->selectWeek(); 1805 else if ( dateCount == 7 ) mNavigator->selectWeek();
1806 else mNavigator->selectDates( dateCount ); 1806 else mNavigator->selectDates( dateCount );
1807 // mViewManager->readSettings( config ); 1807 // mViewManager->readSettings( config );
1808 updateConfig(); 1808 updateConfig();
1809 globalFlagBlockAgenda = 2; 1809 globalFlagBlockAgenda = 2;
1810 mViewManager->readSettings( config ); 1810 mViewManager->readSettings( config );
1811#ifdef DESKTOP_VERSION 1811#ifdef DESKTOP_VERSION
1812 config->setGroup("WidgetLayout"); 1812 config->setGroup("WidgetLayout");
1813 QStringList list; 1813 QStringList list;
1814 list = config->readListEntry("MainLayout"); 1814 list = config->readListEntry("MainLayout");
1815 int x,y,w,h; 1815 int x,y,w,h;
1816 if ( ! list.isEmpty() ) { 1816 if ( ! list.isEmpty() ) {
1817 x = list[0].toInt(); 1817 x = list[0].toInt();
1818 y = list[1].toInt(); 1818 y = list[1].toInt();
1819 w = list[2].toInt(); 1819 w = list[2].toInt();
1820 h = list[3].toInt(); 1820 h = list[3].toInt();
1821 topLevelWidget()->setGeometry(x,y,w,h); 1821 topLevelWidget()->setGeometry(x,y,w,h);
1822 1822
1823 } else { 1823 } else {
1824 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 1824 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
1825 } 1825 }
1826 list = config->readListEntry("EditEventLayout"); 1826 list = config->readListEntry("EditEventLayout");
1827 if ( ! list.isEmpty() ) { 1827 if ( ! list.isEmpty() ) {
1828 x = list[0].toInt(); 1828 x = list[0].toInt();
1829 y = list[1].toInt(); 1829 y = list[1].toInt();
1830 w = list[2].toInt(); 1830 w = list[2].toInt();
1831 h = list[3].toInt(); 1831 h = list[3].toInt();
1832 mEventEditor->setGeometry(x,y,w,h); 1832 mEventEditor->setGeometry(x,y,w,h);
1833 1833
1834 } 1834 }
1835 list = config->readListEntry("EditTodoLayout"); 1835 list = config->readListEntry("EditTodoLayout");
1836 if ( ! list.isEmpty() ) { 1836 if ( ! list.isEmpty() ) {
1837 x = list[0].toInt(); 1837 x = list[0].toInt();
1838 y = list[1].toInt(); 1838 y = list[1].toInt();
1839 w = list[2].toInt(); 1839 w = list[2].toInt();
1840 h = list[3].toInt(); 1840 h = list[3].toInt();
1841 mTodoEditor->setGeometry(x,y,w,h); 1841 mTodoEditor->setGeometry(x,y,w,h);
1842 1842
1843 } 1843 }
1844 list = config->readListEntry("ViewerLayout"); 1844 list = config->readListEntry("ViewerLayout");
1845 if ( ! list.isEmpty() ) { 1845 if ( ! list.isEmpty() ) {
1846 x = list[0].toInt(); 1846 x = list[0].toInt();
1847 y = list[1].toInt(); 1847 y = list[1].toInt();
1848 w = list[2].toInt(); 1848 w = list[2].toInt();
1849 h = list[3].toInt(); 1849 h = list[3].toInt();
1850 getEventViewerDialog()->setGeometry(x,y,w,h); 1850 getEventViewerDialog()->setGeometry(x,y,w,h);
1851 } 1851 }
1852#endif 1852#endif
1853 1853
1854} 1854}
1855 1855
1856 1856
1857void CalendarView::writeSettings() 1857void CalendarView::writeSettings()
1858{ 1858{
1859 // kdDebug() << "CalendarView::writeSettings" << endl; 1859 // kdDebug() << "CalendarView::writeSettings" << endl;
1860 1860
1861 KConfig *config = KOGlobals::config(); 1861 KConfig *config = KOGlobals::config();
1862 1862
1863#ifndef KORG_NOSPLITTER 1863#ifndef KORG_NOSPLITTER
1864 config->setGroup("KOrganizer Geometry"); 1864 config->setGroup("KOrganizer Geometry");
1865 1865
1866 QValueList<int> list = mPanner->sizes(); 1866 QValueList<int> list = mPanner->sizes();
1867 config->writeEntry("Separator1",list); 1867 config->writeEntry("Separator1",list);
1868 1868
1869 list = mLeftSplitter->sizes(); 1869 list = mLeftSplitter->sizes();
1870 config->writeEntry("Separator2",list); 1870 config->writeEntry("Separator2",list);
1871#endif 1871#endif
1872 1872
1873 mViewManager->writeSettings( config ); 1873 mViewManager->writeSettings( config );
1874 mTodoList->saveLayout(config,QString("Todo Layout")); 1874 mTodoList->saveLayout(config,QString("Todo Layout"));
1875 mDialogManager->writeSettings( config ); 1875 mDialogManager->writeSettings( config );
1876 //KOPrefs::instance()->usrWriteConfig(); 1876 //KOPrefs::instance()->usrWriteConfig();
1877 KOPrefs::instance()->writeConfig(); 1877 KOPrefs::instance()->writeConfig();
1878 1878
1879 writeFilterSettings(config); 1879 writeFilterSettings(config);
1880 1880
1881 config->setGroup( "Views" ); 1881 config->setGroup( "Views" );
1882 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 1882 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
1883 1883
1884#ifdef DESKTOP_VERSION 1884#ifdef DESKTOP_VERSION
1885 config->setGroup("WidgetLayout"); 1885 config->setGroup("WidgetLayout");
1886 QStringList list ;//= config->readListEntry("MainLayout"); 1886 QStringList list ;//= config->readListEntry("MainLayout");
1887 int x,y,w,h; 1887 int x,y,w,h;
1888 QWidget* wid; 1888 QWidget* wid;
1889 wid = topLevelWidget(); 1889 wid = topLevelWidget();
1890 x = wid->geometry().x(); 1890 x = wid->geometry().x();
1891 y = wid->geometry().y(); 1891 y = wid->geometry().y();
1892 w = wid->width(); 1892 w = wid->width();
1893 h = wid->height(); 1893 h = wid->height();
1894 list.clear(); 1894 list.clear();
1895 list << QString::number( x ); 1895 list << QString::number( x );
1896 list << QString::number( y ); 1896 list << QString::number( y );
1897 list << QString::number( w ); 1897 list << QString::number( w );
1898 list << QString::number( h ); 1898 list << QString::number( h );
1899 config->writeEntry("MainLayout",list ); 1899 config->writeEntry("MainLayout",list );
1900 1900
1901 wid = mEventEditor; 1901 wid = mEventEditor;
1902 x = wid->geometry().x(); 1902 x = wid->geometry().x();
1903 y = wid->geometry().y(); 1903 y = wid->geometry().y();
1904 w = wid->width(); 1904 w = wid->width();
1905 h = wid->height(); 1905 h = wid->height();
1906 list.clear(); 1906 list.clear();
1907 list << QString::number( x ); 1907 list << QString::number( x );
1908 list << QString::number( y ); 1908 list << QString::number( y );
1909 list << QString::number( w ); 1909 list << QString::number( w );
1910 list << QString::number( h ); 1910 list << QString::number( h );
1911 config->writeEntry("EditEventLayout",list ); 1911 config->writeEntry("EditEventLayout",list );
1912 1912
1913 wid = mTodoEditor; 1913 wid = mTodoEditor;
1914 x = wid->geometry().x(); 1914 x = wid->geometry().x();
1915 y = wid->geometry().y(); 1915 y = wid->geometry().y();
1916 w = wid->width(); 1916 w = wid->width();
1917 h = wid->height(); 1917 h = wid->height();
1918 list.clear(); 1918 list.clear();
1919 list << QString::number( x ); 1919 list << QString::number( x );
1920 list << QString::number( y ); 1920 list << QString::number( y );
1921 list << QString::number( w ); 1921 list << QString::number( w );
1922 list << QString::number( h ); 1922 list << QString::number( h );
1923 config->writeEntry("EditTodoLayout",list ); 1923 config->writeEntry("EditTodoLayout",list );
1924 wid = getEventViewerDialog(); 1924 wid = getEventViewerDialog();
1925 x = wid->geometry().x(); 1925 x = wid->geometry().x();
1926 y = wid->geometry().y(); 1926 y = wid->geometry().y();
1927 w = wid->width(); 1927 w = wid->width();
1928 h = wid->height(); 1928 h = wid->height();
1929 list.clear(); 1929 list.clear();
1930 list << QString::number( x ); 1930 list << QString::number( x );
1931 list << QString::number( y ); 1931 list << QString::number( y );
1932 list << QString::number( w ); 1932 list << QString::number( w );
1933 list << QString::number( h ); 1933 list << QString::number( h );
1934 config->writeEntry("ViewerLayout",list ); 1934 config->writeEntry("ViewerLayout",list );
1935 wid = mDialogManager->getSearchDialog(); 1935 wid = mDialogManager->getSearchDialog();
1936 if ( wid ) { 1936 if ( wid ) {
1937 x = wid->geometry().x(); 1937 x = wid->geometry().x();
1938 y = wid->geometry().y(); 1938 y = wid->geometry().y();
1939 w = wid->width(); 1939 w = wid->width();
1940 h = wid->height(); 1940 h = wid->height();
1941 list.clear(); 1941 list.clear();
1942 list << QString::number( x ); 1942 list << QString::number( x );
1943 list << QString::number( y ); 1943 list << QString::number( y );
1944 list << QString::number( w ); 1944 list << QString::number( w );
1945 list << QString::number( h ); 1945 list << QString::number( h );
1946 config->writeEntry("SearchLayout",list ); 1946 config->writeEntry("SearchLayout",list );
1947 } 1947 }
1948#endif 1948#endif
1949 1949
1950 1950
1951 config->sync(); 1951 config->sync();
1952} 1952}
1953 1953
1954void CalendarView::readFilterSettings(KConfig *config) 1954void CalendarView::readFilterSettings(KConfig *config)
1955{ 1955{
1956 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 1956 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
1957 1957
1958 mFilters.clear(); 1958 mFilters.clear();
1959 1959
1960 config->setGroup("General"); 1960 config->setGroup("General");
1961 QStringList filterList = config->readListEntry("CalendarFilters"); 1961 QStringList filterList = config->readListEntry("CalendarFilters");
1962 1962
1963 QStringList::ConstIterator it = filterList.begin(); 1963 QStringList::ConstIterator it = filterList.begin();
1964 QStringList::ConstIterator end = filterList.end(); 1964 QStringList::ConstIterator end = filterList.end();
1965 while(it != end) { 1965 while(it != end) {
1966 // kdDebug() << " filter: " << (*it) << endl; 1966 // kdDebug() << " filter: " << (*it) << endl;
1967 1967
1968 CalFilter *filter; 1968 CalFilter *filter;
1969 filter = new CalFilter(*it); 1969 filter = new CalFilter(*it);
1970 config->setGroup("Filter_" + (*it)); 1970 config->setGroup("Filter_" + (*it));
1971 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 1971 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
1972 filter->setCriteria(config->readNumEntry("Criteria",0)); 1972 filter->setCriteria(config->readNumEntry("Criteria",0));
1973 filter->setCategoryList(config->readListEntry("CategoryList")); 1973 filter->setCategoryList(config->readListEntry("CategoryList"));
1974 mFilters.append(filter); 1974 mFilters.append(filter);
1975 1975
1976 ++it; 1976 ++it;
1977 } 1977 }
1978 1978
1979 if (mFilters.count() == 0) { 1979 if (mFilters.count() == 0) {
1980 CalFilter *filter = new CalFilter(i18n("Default")); 1980 CalFilter *filter = new CalFilter(i18n("Default"));
1981 mFilters.append(filter); 1981 mFilters.append(filter);
1982 } 1982 }
1983 mFilterView->updateFilters(); 1983 mFilterView->updateFilters();
1984 config->setGroup("FilterView"); 1984 config->setGroup("FilterView");
1985 1985
1986 mFilterView->blockSignals(true); 1986 mFilterView->blockSignals(true);
1987 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 1987 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
1988 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 1988 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
1989 mFilterView->blockSignals(false); 1989 mFilterView->blockSignals(false);
1990 // We do it manually to avoid it being done twice by the above calls 1990 // We do it manually to avoid it being done twice by the above calls
1991 updateFilter(); 1991 updateFilter();
1992} 1992}
1993 1993
1994void CalendarView::writeFilterSettings(KConfig *config) 1994void CalendarView::writeFilterSettings(KConfig *config)
1995{ 1995{
1996 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 1996 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
1997 1997
1998 QStringList filterList; 1998 QStringList filterList;
1999 1999
2000 CalFilter *filter = mFilters.first(); 2000 CalFilter *filter = mFilters.first();
2001 while(filter) { 2001 while(filter) {
2002 // kdDebug() << " fn: " << filter->name() << endl; 2002 // kdDebug() << " fn: " << filter->name() << endl;
2003 filterList << filter->name(); 2003 filterList << filter->name();
2004 config->setGroup("Filter_" + filter->name()); 2004 config->setGroup("Filter_" + filter->name());
2005 config->writeEntry("Criteria",filter->criteria()); 2005 config->writeEntry("Criteria",filter->criteria());
2006 config->writeEntry("CategoryList",filter->categoryList()); 2006 config->writeEntry("CategoryList",filter->categoryList());
2007 filter = mFilters.next(); 2007 filter = mFilters.next();
2008 } 2008 }
2009 config->setGroup("General"); 2009 config->setGroup("General");
2010 config->writeEntry("CalendarFilters",filterList); 2010 config->writeEntry("CalendarFilters",filterList);
2011 2011
2012 config->setGroup("FilterView"); 2012 config->setGroup("FilterView");
2013 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 2013 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
2014 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 2014 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
2015} 2015}
2016 2016
2017 2017
2018void CalendarView::goToday() 2018void CalendarView::goToday()
2019{ 2019{
2020 if ( mViewManager->currentView()->isMonthView() ) 2020 if ( mViewManager->currentView()->isMonthView() )
2021 mNavigator->selectTodayMonth(); 2021 mNavigator->selectTodayMonth();
2022 else 2022 else
2023 mNavigator->selectToday(); 2023 mNavigator->selectToday();
2024} 2024}
2025 2025
2026void CalendarView::goNext() 2026void CalendarView::goNext()
2027{ 2027{
2028 mNavigator->selectNext(); 2028 mNavigator->selectNext();
2029} 2029}
2030 2030
2031void CalendarView::goPrevious() 2031void CalendarView::goPrevious()
2032{ 2032{
2033 mNavigator->selectPrevious(); 2033 mNavigator->selectPrevious();
2034} 2034}
2035void CalendarView::goNextMonth() 2035void CalendarView::goNextMonth()
2036{ 2036{
2037 mNavigator->selectNextMonth(); 2037 mNavigator->selectNextMonth();
2038} 2038}
2039 2039
2040void CalendarView::goPreviousMonth() 2040void CalendarView::goPreviousMonth()
2041{ 2041{
2042 mNavigator->selectPreviousMonth(); 2042 mNavigator->selectPreviousMonth();
2043} 2043}
2044void CalendarView::writeLocale() 2044void CalendarView::writeLocale()
2045{ 2045{
2046 //KPimGlobalPrefs::instance()->setGlobalConfig(); 2046 //KPimGlobalPrefs::instance()->setGlobalConfig();
2047#if 0 2047#if 0
2048 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); 2048 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime );
2049 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); 2049 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday );
2050 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); 2050 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate );
2051 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); 2051 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage );
2052 QString dummy = KOPrefs::instance()->mUserDateFormatLong; 2052 QString dummy = KOPrefs::instance()->mUserDateFormatLong;
2053 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 2053 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
2054 dummy = KOPrefs::instance()->mUserDateFormatShort; 2054 dummy = KOPrefs::instance()->mUserDateFormatShort;
2055 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 2055 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
2056 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, 2056 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving,
2057 KOPrefs::instance()->mDaylightsavingStart, 2057 KOPrefs::instance()->mDaylightsavingStart,
2058 KOPrefs::instance()->mDaylightsavingEnd ); 2058 KOPrefs::instance()->mDaylightsavingEnd );
2059 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); 2059 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId );
2060#endif 2060#endif
2061} 2061}
2062void CalendarView::updateConfig() 2062void CalendarView::updateConfig()
2063{ 2063{
2064 writeLocale(); 2064 writeLocale();
2065 if ( KOPrefs::instance()->mUseAppColors ) 2065 if ( KOPrefs::instance()->mUseAppColors )
2066 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 2066 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
2067 emit configChanged(); 2067 emit configChanged();
2068 mTodoList->updateConfig(); 2068 mTodoList->updateConfig();
2069 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 2069 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
2070 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2070 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2071 // To make the "fill window" configurations work 2071 // To make the "fill window" configurations work
2072 //mViewManager->raiseCurrentView(); 2072 //mViewManager->raiseCurrentView();
2073} 2073}
2074 2074
2075 2075
2076void CalendarView::eventChanged(Event *event) 2076void CalendarView::eventChanged(Event *event)
2077{ 2077{
2078 changeEventDisplay(event,KOGlobals::EVENTEDITED); 2078 changeEventDisplay(event,KOGlobals::EVENTEDITED);
2079 //updateUnmanagedViews(); 2079 //updateUnmanagedViews();
2080} 2080}
2081 2081
2082void CalendarView::eventAdded(Event *event) 2082void CalendarView::eventAdded(Event *event)
2083{ 2083{
2084 changeEventDisplay(event,KOGlobals::EVENTADDED); 2084 changeEventDisplay(event,KOGlobals::EVENTADDED);
2085} 2085}
2086 2086
2087void CalendarView::eventToBeDeleted(Event *) 2087void CalendarView::eventToBeDeleted(Event *)
2088{ 2088{
2089 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 2089 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
2090} 2090}
2091 2091
2092void CalendarView::eventDeleted() 2092void CalendarView::eventDeleted()
2093{ 2093{
2094 changeEventDisplay(0,KOGlobals::EVENTDELETED); 2094 changeEventDisplay(0,KOGlobals::EVENTDELETED);
2095} 2095}
2096void CalendarView::changeTodoDisplay(Todo *which, int action) 2096void CalendarView::changeTodoDisplay(Todo *which, int action)
2097{ 2097{
2098 changeIncidenceDisplay((Incidence *)which, action); 2098 changeIncidenceDisplay((Incidence *)which, action);
2099 mDateNavigator->updateView(); //LR 2099 mDateNavigator->updateView(); //LR
2100 //mDialogManager->updateSearchDialog(); 2100 //mDialogManager->updateSearchDialog();
2101 2101
2102 if (which) { 2102 if (which) {
2103 mViewManager->updateWNview(); 2103 mViewManager->updateWNview();
2104 //mTodoList->updateView(); 2104 //mTodoList->updateView();
2105 } 2105 }
2106 2106
2107} 2107}
2108 2108
2109void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 2109void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
2110{ 2110{
2111 updateUnmanagedViews(); 2111 updateUnmanagedViews();
2112 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 2112 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
2113 if ( action == KOGlobals::EVENTDELETED ) { //delete 2113 if ( action == KOGlobals::EVENTDELETED ) { //delete
2114 mCalendar->checkAlarmForIncidence( 0, true ); 2114 mCalendar->checkAlarmForIncidence( 0, true );
2115 if ( mEventViewerDialog ) 2115 if ( mEventViewerDialog )
2116 mEventViewerDialog->hide(); 2116 mEventViewerDialog->hide();
2117 } 2117 }
2118 else 2118 else
2119 mCalendar->checkAlarmForIncidence( which , false ); 2119 mCalendar->checkAlarmForIncidence( which , false );
2120} 2120}
2121 2121
2122// most of the changeEventDisplays() right now just call the view's 2122// most of the changeEventDisplays() right now just call the view's
2123// total update mode, but they SHOULD be recoded to be more refresh-efficient. 2123// total update mode, but they SHOULD be recoded to be more refresh-efficient.
2124void CalendarView::changeEventDisplay(Event *which, int action) 2124void CalendarView::changeEventDisplay(Event *which, int action)
2125{ 2125{
2126 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 2126 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
2127 changeIncidenceDisplay((Incidence *)which, action); 2127 changeIncidenceDisplay((Incidence *)which, action);
2128 mDateNavigator->updateView(); 2128 mDateNavigator->updateView();
2129 //mDialogManager->updateSearchDialog(); 2129 //mDialogManager->updateSearchDialog();
2130 2130
2131 if (which) { 2131 if (which) {
2132 // If there is an event view visible update the display 2132 // If there is an event view visible update the display
2133 mViewManager->currentView()->changeEventDisplay(which,action); 2133 mViewManager->currentView()->changeEventDisplay(which,action);
2134 // TODO: check, if update needed 2134 // TODO: check, if update needed
2135 // if (which->getTodoStatus()) { 2135 // if (which->getTodoStatus()) {
2136 mTodoList->updateView(); 2136 mTodoList->updateView();
2137 // } 2137 // }
2138 } else { 2138 } else {
2139 mViewManager->currentView()->updateView(); 2139 mViewManager->currentView()->updateView();
2140 } 2140 }
2141} 2141}
2142 2142
2143 2143
2144void CalendarView::updateTodoViews() 2144void CalendarView::updateTodoViews()
2145{ 2145{
2146 mTodoList->updateView(); 2146 mTodoList->updateView();
2147 mViewManager->currentView()->updateView(); 2147 mViewManager->currentView()->updateView();
2148 2148
2149} 2149}
2150 2150
2151 2151
2152void CalendarView::updateView(const QDate &start, const QDate &end) 2152void CalendarView::updateView(const QDate &start, const QDate &end)
2153{ 2153{
2154 mTodoList->updateView(); 2154 mTodoList->updateView();
2155 mViewManager->updateView(start, end); 2155 mViewManager->updateView(start, end);
2156 //mDateNavigator->updateView(); 2156 //mDateNavigator->updateView();
2157} 2157}
2158 2158
2159void CalendarView::updateView() 2159void CalendarView::updateView()
2160{ 2160{
2161 DateList tmpList = mNavigator->selectedDates(); 2161 DateList tmpList = mNavigator->selectedDates();
2162 2162
2163 if ( KOPrefs::instance()->mHideNonStartedTodos ) 2163 if ( KOPrefs::instance()->mHideNonStartedTodos )
2164 mTodoList->updateView(); 2164 mTodoList->updateView();
2165 // We assume that the navigator only selects consecutive days. 2165 // We assume that the navigator only selects consecutive days.
2166 updateView( tmpList.first(), tmpList.last() ); 2166 updateView( tmpList.first(), tmpList.last() );
2167} 2167}
2168 2168
2169void CalendarView::updateUnmanagedViews() 2169void CalendarView::updateUnmanagedViews()
2170{ 2170{
2171 mDateNavigator->updateDayMatrix(); 2171 mDateNavigator->updateDayMatrix();
2172} 2172}
2173 2173
2174int CalendarView::msgItemDelete(const QString name) 2174int CalendarView::msgItemDelete(const QString name)
2175{ 2175{
2176 return KMessageBox::warningContinueCancel(this,name +"\n\n"+ 2176 return KMessageBox::warningContinueCancel(this,name +"\n\n"+
2177 i18n("This item will be\npermanently deleted."), 2177 i18n("This item will be\npermanently deleted."),
2178 i18n("KO/Pi Confirmation"),i18n("Delete")); 2178 i18n("KO/Pi Confirmation"),i18n("Delete"));
2179} 2179}
2180 2180
2181 2181
2182void CalendarView::edit_cut() 2182void CalendarView::edit_cut()
2183{ 2183{
2184 Event *anEvent=0; 2184 Event *anEvent=0;
2185 2185
2186 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2186 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2187 2187
2188 if (mViewManager->currentView()->isEventView()) { 2188 if (mViewManager->currentView()->isEventView()) {
2189 if ( incidence && incidence->type() == "Event" ) { 2189 if ( incidence && incidence->type() == "Event" ) {
2190 anEvent = static_cast<Event *>(incidence); 2190 anEvent = static_cast<Event *>(incidence);
2191 } 2191 }
2192 } 2192 }
2193 2193
2194 if (!anEvent) { 2194 if (!anEvent) {
2195 KNotifyClient::beep(); 2195 KNotifyClient::beep();
2196 return; 2196 return;
2197 } 2197 }
2198 DndFactory factory( mCalendar ); 2198 DndFactory factory( mCalendar );
2199 factory.cutIncidence(anEvent); 2199 factory.cutIncidence(anEvent);
2200 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2200 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2201} 2201}
2202 2202
2203void CalendarView::edit_copy() 2203void CalendarView::edit_copy()
2204{ 2204{
2205 Event *anEvent=0; 2205 Event *anEvent=0;
2206 2206
2207 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2207 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2208 2208
2209 if (mViewManager->currentView()->isEventView()) { 2209 if (mViewManager->currentView()->isEventView()) {
2210 if ( incidence && incidence->type() == "Event" ) { 2210 if ( incidence && incidence->type() == "Event" ) {
2211 anEvent = static_cast<Event *>(incidence); 2211 anEvent = static_cast<Event *>(incidence);
2212 } 2212 }
2213 } 2213 }
2214 2214
2215 if (!anEvent) { 2215 if (!anEvent) {
2216 KNotifyClient::beep(); 2216 KNotifyClient::beep();
2217 return; 2217 return;
2218 } 2218 }
2219 DndFactory factory( mCalendar ); 2219 DndFactory factory( mCalendar );
2220 factory.copyIncidence(anEvent); 2220 factory.copyIncidence(anEvent);
2221} 2221}
2222 2222
2223void CalendarView::edit_paste() 2223void CalendarView::edit_paste()
2224{ 2224{
2225 QDate date = mNavigator->selectedDates().first(); 2225 QDate date = mNavigator->selectedDates().first();
2226 2226
2227 DndFactory factory( mCalendar ); 2227 DndFactory factory( mCalendar );
2228 Event *pastedEvent = (Event *)factory.pasteIncidence( date ); 2228 Event *pastedEvent = (Event *)factory.pasteIncidence( date );
2229 2229
2230 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 2230 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
2231} 2231}
2232 2232
2233void CalendarView::edit_options() 2233void CalendarView::edit_options()
2234{ 2234{
2235 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; 2235 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId;
2236 emit save(); 2236 emit save();
2237 emit saveStopTimer(); 2237 emit saveStopTimer();
2238 mDialogManager->showOptionsDialog(); 2238 mDialogManager->showOptionsDialog();
2239 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { 2239 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) {
2240 emit saveStopTimer(); 2240 emit saveStopTimer();
2241 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), 2241 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"),
2242 i18n("Timezone settings"),i18n("Reload"))) { 2242 i18n("Timezone settings"),i18n("Reload"))) {
2243 qDebug("KO: TZ reload cancelled "); 2243 qDebug("KO: TZ reload cancelled ");
2244 return; 2244 return;
2245 } 2245 }
2246 qDebug("KO: Timezone change "); 2246 qDebug("KO: Timezone change ");
2247 openCalendar( MainWindow::defaultFileName() ); 2247 openCalendar( MainWindow::defaultFileName() );
2248 setModified(true); 2248 setModified(true);
2249 } 2249 }
2250 else 2250 else
2251 qDebug("KO: No tz change "); 2251 qDebug("KO: No tz change ");
2252 2252
2253} 2253}
2254 2254
2255 2255
2256void CalendarView::slotSelectPickerDate( QDate d) 2256void CalendarView::slotSelectPickerDate( QDate d)
2257{ 2257{
2258 mDateFrame->hide(); 2258 mDateFrame->hide();
2259 if ( mDatePickerMode == 1 ) { 2259 if ( mDatePickerMode == 1 ) {
2260 mNavigator->slotDaySelect( d ); 2260 mNavigator->slotDaySelect( d );
2261 } else if ( mDatePickerMode == 2 ) { 2261 } else if ( mDatePickerMode == 2 ) {
2262 if ( mMoveIncidence->type() == "Todo" ) { 2262 if ( mMoveIncidence->type() == "Todo" ) {
2263 Todo * to = (Todo *) mMoveIncidence; 2263 Todo * to = (Todo *) mMoveIncidence;
2264 QTime tim; 2264 QTime tim;
2265 if ( to->hasDueDate() ) 2265 if ( to->hasDueDate() )
2266 tim = to->dtDue().time(); 2266 tim = to->dtDue().time();
2267 else { 2267 else {
2268 tim = QTime ( 0,0,0 ); 2268 tim = QTime ( 0,0,0 );
2269 to->setFloats( true ); 2269 to->setFloats( true );
2270 to->setHasDueDate( true ); 2270 to->setHasDueDate( true );
2271 } 2271 }
2272 QDateTime dt ( d,tim ); 2272 QDateTime dt ( d,tim );
2273 to->setDtDue( dt ); 2273 to->setDtDue( dt );
2274 todoChanged( to ); 2274 todoChanged( to );
2275 } else { 2275 } else {
2276 if ( mMoveIncidence->doesRecur() ) { 2276 if ( mMoveIncidence->doesRecur() ) {
2277#if 0 2277#if 0
2278 // PENDING implement this 2278 // PENDING implement this
2279 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); 2279 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate );
2280 mCalendar()->addIncidence( newInc ); 2280 mCalendar()->addIncidence( newInc );
2281 if ( mMoveIncidence->type() == "Todo" ) 2281 if ( mMoveIncidence->type() == "Todo" )
2282 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); 2282 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED );
2283 else 2283 else
2284 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); 2284 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED);
2285 mMoveIncidence = newInc; 2285 mMoveIncidence = newInc;
2286 2286
2287#endif 2287#endif
2288 } 2288 }
2289 QTime tim = mMoveIncidence->dtStart().time(); 2289 QTime tim = mMoveIncidence->dtStart().time();
2290 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2290 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2291 QDateTime dt ( d,tim ); 2291 QDateTime dt ( d,tim );
2292 mMoveIncidence->setDtStart( dt ); 2292 mMoveIncidence->setDtStart( dt );
2293 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2293 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2294 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2294 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2295 } 2295 }
2296 2296
2297 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2297 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2298 } 2298 }
2299} 2299}
2300 2300
2301void CalendarView::removeCategories() 2301void CalendarView::removeCategories()
2302{ 2302{
2303 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2303 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2304 QStringList catList = KOPrefs::instance()->mCustomCategories; 2304 QStringList catList = KOPrefs::instance()->mCustomCategories;
2305 QStringList catIncList; 2305 QStringList catIncList;
2306 QStringList newCatList; 2306 QStringList newCatList;
2307 Incidence* inc = incList.first(); 2307 Incidence* inc = incList.first();
2308 int i; 2308 int i;
2309 int count = 0; 2309 int count = 0;
2310 while ( inc ) { 2310 while ( inc ) {
2311 newCatList.clear(); 2311 newCatList.clear();
2312 catIncList = inc->categories() ; 2312 catIncList = inc->categories() ;
2313 for( i = 0; i< catIncList.count(); ++i ) { 2313 for( i = 0; i< catIncList.count(); ++i ) {
2314 if ( catList.contains (catIncList[i])) 2314 if ( catList.contains (catIncList[i]))
2315 newCatList.append( catIncList[i] ); 2315 newCatList.append( catIncList[i] );
2316 } 2316 }
2317 newCatList.sort(); 2317 newCatList.sort();
2318 inc->setCategories( newCatList.join(",") ); 2318 inc->setCategories( newCatList.join(",") );
2319 inc = incList.next(); 2319 inc = incList.next();
2320 } 2320 }
2321} 2321}
2322 2322
2323int CalendarView::addCategories() 2323int CalendarView::addCategories()
2324{ 2324{
2325 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2325 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2326 QStringList catList = KOPrefs::instance()->mCustomCategories; 2326 QStringList catList = KOPrefs::instance()->mCustomCategories;
2327 QStringList catIncList; 2327 QStringList catIncList;
2328 Incidence* inc = incList.first(); 2328 Incidence* inc = incList.first();
2329 int i; 2329 int i;
2330 int count = 0; 2330 int count = 0;
2331 while ( inc ) { 2331 while ( inc ) {
2332 catIncList = inc->categories() ; 2332 catIncList = inc->categories() ;
2333 for( i = 0; i< catIncList.count(); ++i ) { 2333 for( i = 0; i< catIncList.count(); ++i ) {
2334 if ( !catList.contains (catIncList[i])) { 2334 if ( !catList.contains (catIncList[i])) {
2335 catList.append( catIncList[i] ); 2335 catList.append( catIncList[i] );
2336 //qDebug("add cat %s ", catIncList[i].latin1()); 2336 //qDebug("add cat %s ", catIncList[i].latin1());
2337 ++count; 2337 ++count;
2338 } 2338 }
2339 } 2339 }
2340 inc = incList.next(); 2340 inc = incList.next();
2341 } 2341 }
2342 catList.sort(); 2342 catList.sort();
2343 KOPrefs::instance()->mCustomCategories = catList; 2343 KOPrefs::instance()->mCustomCategories = catList;
2344 return count; 2344 return count;
2345} 2345}
2346 2346
2347void CalendarView::manageCategories() 2347void CalendarView::manageCategories()
2348{ 2348{
2349 KOCatPrefs* cp = new KOCatPrefs(); 2349 KOCatPrefs* cp = new KOCatPrefs();
2350 cp->show(); 2350 cp->show();
2351 int w =cp->sizeHint().width() ; 2351 int w =cp->sizeHint().width() ;
2352 int h = cp->sizeHint().height() ; 2352 int h = cp->sizeHint().height() ;
2353 int dw = QApplication::desktop()->width(); 2353 int dw = QApplication::desktop()->width();
2354 int dh = QApplication::desktop()->height(); 2354 int dh = QApplication::desktop()->height();
2355 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2355 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2356 if ( !cp->exec() ) { 2356 if ( !cp->exec() ) {
2357 delete cp; 2357 delete cp;
2358 return; 2358 return;
2359 } 2359 }
2360 int count = 0; 2360 int count = 0;
2361 if ( cp->addCat() ) { 2361 if ( cp->addCat() ) {
2362 count = addCategories(); 2362 count = addCategories();
2363 if ( count ) { 2363 if ( count ) {
2364 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2364 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2365 writeSettings(); 2365 writeSettings();
2366 } else 2366 } else
2367 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); 2367 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! "));
2368 } else { 2368 } else {
2369 removeCategories(); 2369 removeCategories();
2370 updateView(); 2370 updateView();
2371 } 2371 }
2372 delete cp; 2372 delete cp;
2373} 2373}
2374 2374
2375void CalendarView::beamIncidence(Incidence * Inc) 2375void CalendarView::beamIncidence(Incidence * Inc)
2376{ 2376{
2377 QPtrList<Incidence> delSel ; 2377 QPtrList<Incidence> delSel ;
2378 delSel.append(Inc); 2378 delSel.append(Inc);
2379 beamIncidenceList( delSel ); 2379 beamIncidenceList( delSel );
2380} 2380}
2381void CalendarView::beamCalendar() 2381void CalendarView::beamCalendar()
2382{ 2382{
2383 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2383 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2384 //qDebug("beamCalendar() "); 2384 //qDebug("beamCalendar() ");
2385 beamIncidenceList( delSel ); 2385 beamIncidenceList( delSel );
2386} 2386}
2387void CalendarView::beamFilteredCalendar() 2387void CalendarView::beamFilteredCalendar()
2388{ 2388{
2389 QPtrList<Incidence> delSel = mCalendar->incidences(); 2389 QPtrList<Incidence> delSel = mCalendar->incidences();
2390 //qDebug("beamFilteredCalendar() "); 2390 //qDebug("beamFilteredCalendar() ");
2391 beamIncidenceList( delSel ); 2391 beamIncidenceList( delSel );
2392} 2392}
2393void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2393void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2394{ 2394{
2395 if ( beamDialog->exec () == QDialog::Rejected ) 2395 if ( beamDialog->exec () == QDialog::Rejected )
2396 return; 2396 return;
2397#ifdef DESKTOP_VERSION 2397#ifdef DESKTOP_VERSION
2398 QString fn = locateLocal( "tmp", "kopibeamfile" ); 2398 QString fn = locateLocal( "tmp", "kopibeamfile" );
2399#else 2399#else
2400 QString fn = "/tmp/kopibeamfile"; 2400 QString fn = "/tmp/kopibeamfile";
2401#endif 2401#endif
2402 QString mes; 2402 QString mes;
2403 bool createbup = true; 2403 bool createbup = true;
2404 if ( createbup ) { 2404 if ( createbup ) {
2405 QString description = "\n"; 2405 QString description = "\n";
2406 CalendarLocal* cal = new CalendarLocal(); 2406 CalendarLocal* cal = new CalendarLocal();
2407 if ( beamDialog->beamLocal() ) 2407 if ( beamDialog->beamLocal() )
2408 cal->setLocalTime(); 2408 cal->setLocalTime();
2409 else 2409 else
2410 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2410 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2411 Incidence *incidence = delSel.first(); 2411 Incidence *incidence = delSel.first();
2412 bool addText = false; 2412 bool addText = false;
2413 if ( delSel.count() < 10 ) 2413 if ( delSel.count() < 10 )
2414 addText = true; 2414 addText = true;
2415 else { 2415 else {
2416 description.sprintf(i18n(" %d items?"),delSel.count() ); 2416 description.sprintf(i18n(" %d items?"),delSel.count() );
2417 } 2417 }
2418 while ( incidence ) { 2418 while ( incidence ) {
2419 Incidence *in = incidence->clone(); 2419 Incidence *in = incidence->clone();
2420 if ( ! in->summary().isEmpty() ) { 2420 if ( ! in->summary().isEmpty() ) {
2421 in->setDescription(""); 2421 in->setDescription("");
2422 } else { 2422 } else {
2423 in->setSummary( in->description().left(20)); 2423 in->setSummary( in->description().left(20));
2424 in->setDescription(""); 2424 in->setDescription("");
2425 } 2425 }
2426 if ( addText ) 2426 if ( addText )
2427 description += in->summary() + "\n"; 2427 description += in->summary() + "\n";
2428 cal->addIncidence( in ); 2428 cal->addIncidence( in );
2429 incidence = delSel.next(); 2429 incidence = delSel.next();
2430 } 2430 }
2431 if ( beamDialog->beamVcal() ) { 2431 if ( beamDialog->beamVcal() ) {
2432 fn += ".vcs"; 2432 fn += ".vcs";
2433 FileStorage storage( cal, fn, new VCalFormat ); 2433 FileStorage storage( cal, fn, new VCalFormat );
2434 storage.save(); 2434 storage.save();
2435 } else { 2435 } else {
2436 fn += ".ics"; 2436 fn += ".ics";
2437 FileStorage storage( cal, fn, new ICalFormat( ) ); 2437 FileStorage storage( cal, fn, new ICalFormat( ) );
2438 storage.save(); 2438 storage.save();
2439 } 2439 }
2440 delete cal; 2440 delete cal;
2441 mes = i18n("KO/Pi: Ready for beaming"); 2441 mes = i18n("KO/Pi: Ready for beaming");
2442 topLevelWidget()->setCaption(mes); 2442 topLevelWidget()->setCaption(mes);
2443 KApplication::convert2latin1( fn ); 2443 KApplication::convert2latin1( fn );
2444#ifndef DESKTOP_VERSION 2444#ifndef DESKTOP_VERSION
2445 Ir *ir = new Ir( this ); 2445 Ir *ir = new Ir( this );
2446 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 2446 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2447 ir->send( fn, description, "text/x-vCalendar" ); 2447 ir->send( fn, description, "text/x-vCalendar" );
2448#endif 2448#endif
2449 } 2449 }
2450} 2450}
2451void CalendarView::beamDone( Ir *ir ) 2451void CalendarView::beamDone( Ir *ir )
2452{ 2452{
2453#ifndef DESKTOP_VERSION 2453#ifndef DESKTOP_VERSION
2454 delete ir; 2454 delete ir;
2455#endif 2455#endif
2456 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); 2456 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") );
2457 topLevelWidget()->raise(); 2457 topLevelWidget()->raise();
2458} 2458}
2459 2459
2460void CalendarView::moveIncidence(Incidence * inc ) 2460void CalendarView::moveIncidence(Incidence * inc )
2461{ 2461{
2462 if ( !inc ) return; 2462 if ( !inc ) return;
2463 // qDebug("showDatePickerForIncidence( ) "); 2463 showDatePickerPopup();
2464 if ( mDateFrame->isVisible() )
2465 mDateFrame->hide();
2466 else {
2467 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ;
2468 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ;
2469 int dw = QApplication::desktop()->width();
2470 int dh = QApplication::desktop()->height();
2471 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2472 mDateFrame->show();
2473 }
2474 mDatePickerMode = 2; 2464 mDatePickerMode = 2;
2475 mMoveIncidence = inc ; 2465 mMoveIncidence = inc ;
2476 QDate da; 2466 QDate da;
2477 if ( mMoveIncidence->type() == "Todo" ) { 2467 if ( mMoveIncidence->type() == "Todo" ) {
2478 Todo * to = (Todo *) mMoveIncidence; 2468 Todo * to = (Todo *) mMoveIncidence;
2479 if ( to->hasDueDate() ) 2469 if ( to->hasDueDate() )
2480 da = to->dtDue().date(); 2470 da = to->dtDue().date();
2481 else 2471 else
2482 da = QDate::currentDate(); 2472 da = QDate::currentDate();
2483 } else { 2473 } else {
2484 da = mMoveIncidence->dtStart().date(); 2474 da = mMoveIncidence->dtStart().date();
2485 } 2475 }
2486 //PENDING set date for recurring incidence to date of recurrence 2476 //PENDING set date for recurring incidence to date of recurrence
2487 //mMoveIncidenceOldDate; 2477 //mMoveIncidenceOldDate;
2488 mDatePicker->setDate( da ); 2478 mDatePicker->setDate( da );
2489} 2479}
2490void CalendarView::showDatePicker( ) 2480void CalendarView::showDatePickerPopup()
2491{ 2481{
2492 //qDebug("CalendarView::showDatePicker( ) "); 2482 if ( mDateFrame->isVisible() )
2493 if ( mDateFrame->isVisible() )
2494 mDateFrame->hide(); 2483 mDateFrame->hide();
2495 else { 2484 else {
2485 int offX = 0, offY = 0;
2486#ifdef DESKTOP_VERSION
2487 int w =mDatePicker->sizeHint().width() ;
2488 int h = mDatePicker->sizeHint().height() ;
2489 int dw = topLevelWidget()->width();
2490 int dh = topLevelWidget()->height();
2491 offX = topLevelWidget()->x();
2492 offY = topLevelWidget()->y();
2493#else
2496 int w =mDatePicker->sizeHint().width() ; 2494 int w =mDatePicker->sizeHint().width() ;
2497 int h = mDatePicker->sizeHint().height() ; 2495 int h = mDatePicker->sizeHint().height() ;
2498 int dw = QApplication::desktop()->width(); 2496 int dw = QApplication::desktop()->width();
2499 int dh = QApplication::desktop()->height(); 2497 int dh = QApplication::desktop()->height();
2500 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2498#endif
2499 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h );
2501 mDateFrame->show(); 2500 mDateFrame->show();
2502 } 2501 }
2502}
2503void CalendarView::showDatePicker( )
2504{
2505 showDatePickerPopup();
2503 mDatePickerMode = 1; 2506 mDatePickerMode = 1;
2504 mDatePicker->setDate( mNavigator->selectedDates().first() ); 2507 mDatePicker->setDate( mNavigator->selectedDates().first() );
2505} 2508}
2506 2509
2507void CalendarView::showEventEditor() 2510void CalendarView::showEventEditor()
2508{ 2511{
2509#ifdef DESKTOP_VERSION 2512#ifdef DESKTOP_VERSION
2510 mEventEditor->show(); 2513 mEventEditor->show();
2511#else 2514#else
2512 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { 2515 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) {
2513 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2516 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2514 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); 2517 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() );
2515 qApp->processEvents(); 2518 qApp->processEvents();
2516 delete mEventEditor; 2519 delete mEventEditor;
2517 mEventEditor = mDialogManager->getEventEditor(); 2520 mEventEditor = mDialogManager->getEventEditor();
2518 topLevelWidget()->setCaption( i18n("") ); 2521 topLevelWidget()->setCaption( i18n("") );
2519 } 2522 }
2520 mEventEditor->showMaximized(); 2523 mEventEditor->showMaximized();
2521#endif 2524#endif
2522} 2525}
2523void CalendarView::showTodoEditor() 2526void CalendarView::showTodoEditor()
2524{ 2527{
2525#ifdef DESKTOP_VERSION 2528#ifdef DESKTOP_VERSION
2526 mTodoEditor->show(); 2529 mTodoEditor->show();
2527#else 2530#else
2528 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { 2531 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) {
2529 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2532 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2530 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); 2533 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() );
2531 qApp->processEvents(); 2534 qApp->processEvents();
2532 delete mTodoEditor; 2535 delete mTodoEditor;
2533 mTodoEditor = mDialogManager->getTodoEditor(); 2536 mTodoEditor = mDialogManager->getTodoEditor();
2534 topLevelWidget()->setCaption( i18n("") ); 2537 topLevelWidget()->setCaption( i18n("") );
2535 } 2538 }
2536 mTodoEditor->showMaximized(); 2539 mTodoEditor->showMaximized();
2537#endif 2540#endif
2538} 2541}
2539 2542
2540void CalendarView::cloneIncidence() 2543void CalendarView::cloneIncidence()
2541{ 2544{
2542 Incidence *incidence = currentSelection(); 2545 Incidence *incidence = currentSelection();
2543 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2546 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2544 if ( incidence ) { 2547 if ( incidence ) {
2545 cloneIncidence(incidence); 2548 cloneIncidence(incidence);
2546 } 2549 }
2547} 2550}
2548void CalendarView::moveIncidence() 2551void CalendarView::moveIncidence()
2549{ 2552{
2550 Incidence *incidence = currentSelection(); 2553 Incidence *incidence = currentSelection();
2551 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2554 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2552 if ( incidence ) { 2555 if ( incidence ) {
2553 moveIncidence(incidence); 2556 moveIncidence(incidence);
2554 } 2557 }
2555} 2558}
2556void CalendarView::beamIncidence() 2559void CalendarView::beamIncidence()
2557{ 2560{
2558 Incidence *incidence = currentSelection(); 2561 Incidence *incidence = currentSelection();
2559 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2562 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2560 if ( incidence ) { 2563 if ( incidence ) {
2561 beamIncidence(incidence); 2564 beamIncidence(incidence);
2562 } 2565 }
2563} 2566}
2564void CalendarView::toggleCancelIncidence() 2567void CalendarView::toggleCancelIncidence()
2565{ 2568{
2566 Incidence *incidence = currentSelection(); 2569 Incidence *incidence = currentSelection();
2567 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2570 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2568 if ( incidence ) { 2571 if ( incidence ) {
2569 cancelIncidence(incidence); 2572 cancelIncidence(incidence);
2570 } 2573 }
2571} 2574}
2572 2575
2573 2576
2574void CalendarView::cancelIncidence(Incidence * inc ) 2577void CalendarView::cancelIncidence(Incidence * inc )
2575{ 2578{
2576 inc->setCancelled( ! inc->cancelled() ); 2579 inc->setCancelled( ! inc->cancelled() );
2577 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 2580 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
2578 updateView(); 2581 updateView();
2579} 2582}
2580void CalendarView::cloneIncidence(Incidence * orgInc ) 2583void CalendarView::cloneIncidence(Incidence * orgInc )
2581{ 2584{
2582 Incidence * newInc = orgInc->clone(); 2585 Incidence * newInc = orgInc->clone();
2583 newInc->recreate(); 2586 newInc->recreate();
2584 2587
2585 if ( newInc->type() == "Todo" ) { 2588 if ( newInc->type() == "Todo" ) {
2586 Todo* t = (Todo*) newInc; 2589 Todo* t = (Todo*) newInc;
2587 showTodoEditor(); 2590 showTodoEditor();
2588 mTodoEditor->editTodo( t ); 2591 mTodoEditor->editTodo( t );
2589 if ( mTodoEditor->exec() ) { 2592 if ( mTodoEditor->exec() ) {
2590 mCalendar->addTodo( t ); 2593 mCalendar->addTodo( t );
2591 updateView(); 2594 updateView();
2592 } else { 2595 } else {
2593 delete t; 2596 delete t;
2594 } 2597 }
2595 } 2598 }
2596 else { 2599 else {
2597 Event* e = (Event*) newInc; 2600 Event* e = (Event*) newInc;
2598 showEventEditor(); 2601 showEventEditor();
2599 mEventEditor->editEvent( e ); 2602 mEventEditor->editEvent( e );
2600 if ( mEventEditor->exec() ) { 2603 if ( mEventEditor->exec() ) {
2601 mCalendar->addEvent( e ); 2604 mCalendar->addEvent( e );
2602 updateView(); 2605 updateView();
2603 } else { 2606 } else {
2604 delete e; 2607 delete e;
2605 } 2608 }
2606 } 2609 }
2607} 2610}
2608 2611
2609void CalendarView::newEvent() 2612void CalendarView::newEvent()
2610{ 2613{
2611 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 2614 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
2612 KOAgendaView *aView = mViewManager->agendaView(); 2615 KOAgendaView *aView = mViewManager->agendaView();
2613 if (aView) { 2616 if (aView) {
2614 if (aView->selectionStart().isValid()) { 2617 if (aView->selectionStart().isValid()) {
2615 if (aView->selectedIsAllDay()) { 2618 if (aView->selectedIsAllDay()) {
2616 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 2619 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
2617 } else { 2620 } else {
2618 newEvent(aView->selectionStart(),aView->selectionEnd()); 2621 newEvent(aView->selectionStart(),aView->selectionEnd());
2619 } 2622 }
2620 return; 2623 return;
2621 } 2624 }
2622 } 2625 }
2623 2626
2624 QDate date = mNavigator->selectedDates().first(); 2627 QDate date = mNavigator->selectedDates().first();
2625 QDateTime current = QDateTime::currentDateTime(); 2628 QDateTime current = QDateTime::currentDateTime();
2626 if ( date <= current.date() ) { 2629 if ( date <= current.date() ) {
2627 int hour = current.time().hour() +1; 2630 int hour = current.time().hour() +1;
2628 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 2631 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
2629 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2632 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2630 } else 2633 } else
2631 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 2634 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
2632 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 2635 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
2633 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2636 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2634} 2637}
2635 2638
2636void CalendarView::newEvent(QDateTime fh) 2639void CalendarView::newEvent(QDateTime fh)
2637{ 2640{
2638 newEvent(fh, 2641 newEvent(fh,
2639 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 2642 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
2640} 2643}
2641 2644
2642void CalendarView::newEvent(QDate dt) 2645void CalendarView::newEvent(QDate dt)
2643{ 2646{
2644 newEvent(QDateTime(dt, QTime(0,0,0)), 2647 newEvent(QDateTime(dt, QTime(0,0,0)),
2645 QDateTime(dt, QTime(0,0,0)), true); 2648 QDateTime(dt, QTime(0,0,0)), true);
2646} 2649}
2647void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) 2650void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint)
2648{ 2651{
2649 newEvent(fromHint, toHint, false); 2652 newEvent(fromHint, toHint, false);
2650} 2653}
2651void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 2654void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
2652{ 2655{
2653 2656
2654 showEventEditor(); 2657 showEventEditor();
2655 mEventEditor->newEvent(fromHint,toHint,allDay); 2658 mEventEditor->newEvent(fromHint,toHint,allDay);
2656 if ( mFilterView->filtersEnabled() ) { 2659 if ( mFilterView->filtersEnabled() ) {
2657 CalFilter *filter = mFilterView->selectedFilter(); 2660 CalFilter *filter = mFilterView->selectedFilter();
2658 if (filter && filter->showCategories()) { 2661 if (filter && filter->showCategories()) {
2659 mEventEditor->setCategories(filter->categoryList().join(",") ); 2662 mEventEditor->setCategories(filter->categoryList().join(",") );
2660 } 2663 }
2661 if ( filter ) 2664 if ( filter )
2662 mEventEditor->setSecrecy( filter->getSecrecy() ); 2665 mEventEditor->setSecrecy( filter->getSecrecy() );
2663 } 2666 }
2664} 2667}
2665void CalendarView::todoAdded(Todo * t) 2668void CalendarView::todoAdded(Todo * t)
2666{ 2669{
2667 2670
2668 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 2671 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
2669 updateTodoViews(); 2672 updateTodoViews();
2670} 2673}
2671void CalendarView::todoChanged(Todo * t) 2674void CalendarView::todoChanged(Todo * t)
2672{ 2675{
2673 emit todoModified( t, 4 ); 2676 emit todoModified( t, 4 );
2674 // updateTodoViews(); 2677 // updateTodoViews();
2675} 2678}
2676void CalendarView::todoToBeDeleted(Todo *) 2679void CalendarView::todoToBeDeleted(Todo *)
2677{ 2680{
2678 //qDebug("todoToBeDeleted(Todo *) "); 2681 //qDebug("todoToBeDeleted(Todo *) ");
2679 updateTodoViews(); 2682 updateTodoViews();
2680} 2683}
2681void CalendarView::todoDeleted() 2684void CalendarView::todoDeleted()
2682{ 2685{
2683 //qDebug(" todoDeleted()"); 2686 //qDebug(" todoDeleted()");
2684 updateTodoViews(); 2687 updateTodoViews();
2685} 2688}
2686 2689
2687 2690
2688void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) 2691void CalendarView::newTodoDateTime( QDateTime dt, bool allday )
2689{ 2692{
2690 showTodoEditor(); 2693 showTodoEditor();
2691 mTodoEditor->newTodo(dt,0,allday); 2694 mTodoEditor->newTodo(dt,0,allday);
2692 if ( mFilterView->filtersEnabled() ) { 2695 if ( mFilterView->filtersEnabled() ) {
2693 CalFilter *filter = mFilterView->selectedFilter(); 2696 CalFilter *filter = mFilterView->selectedFilter();
2694 if (filter && filter->showCategories()) { 2697 if (filter && filter->showCategories()) {
2695 mTodoEditor->setCategories(filter->categoryList().join(",") ); 2698 mTodoEditor->setCategories(filter->categoryList().join(",") );
2696 } 2699 }
2697 if ( filter ) 2700 if ( filter )
2698 mTodoEditor->setSecrecy( filter->getSecrecy() ); 2701 mTodoEditor->setSecrecy( filter->getSecrecy() );
2699 } 2702 }
2700} 2703}
2701 2704
2702void CalendarView::newTodo() 2705void CalendarView::newTodo()
2703{ 2706{
2704 newTodoDateTime( QDateTime(),true ); 2707 newTodoDateTime( QDateTime(),true );
2705} 2708}
2706 2709
2707void CalendarView::newSubTodo() 2710void CalendarView::newSubTodo()
2708{ 2711{
2709 Todo *todo = selectedTodo(); 2712 Todo *todo = selectedTodo();
2710 if ( todo ) newSubTodo( todo ); 2713 if ( todo ) newSubTodo( todo );
2711} 2714}
2712 2715
2713void CalendarView::newSubTodo(Todo *parentEvent) 2716void CalendarView::newSubTodo(Todo *parentEvent)
2714{ 2717{
2715 2718
2716 showTodoEditor(); 2719 showTodoEditor();
2717 mTodoEditor->newTodo(QDateTime(),parentEvent,true); 2720 mTodoEditor->newTodo(QDateTime(),parentEvent,true);
2718} 2721}
2719 2722
2720void CalendarView::newFloatingEvent() 2723void CalendarView::newFloatingEvent()
2721{ 2724{
2722 DateList tmpList = mNavigator->selectedDates(); 2725 DateList tmpList = mNavigator->selectedDates();
2723 QDate date = tmpList.first(); 2726 QDate date = tmpList.first();
2724 2727
2725 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 2728 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
2726 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 2729 QDateTime( date, QTime( 12, 0, 0 ) ), true );
2727} 2730}
2728 2731
2729 2732
2730void CalendarView::editEvent( Event *event ) 2733void CalendarView::editEvent( Event *event )
2731{ 2734{
2732 2735
2733 if ( !event ) return; 2736 if ( !event ) return;
2734 if ( event->isReadOnly() ) { 2737 if ( event->isReadOnly() ) {
2735 showEvent( event ); 2738 showEvent( event );
2736 return; 2739 return;
2737 } 2740 }
2738 showEventEditor(); 2741 showEventEditor();
2739 mEventEditor->editEvent( event , mFlagEditDescription); 2742 mEventEditor->editEvent( event , mFlagEditDescription);
2740} 2743}
2741void CalendarView::editJournal( Journal *jour ) 2744void CalendarView::editJournal( Journal *jour )
2742{ 2745{
2743 if ( !jour ) return; 2746 if ( !jour ) return;
2744 mDialogManager->hideSearchDialog(); 2747 mDialogManager->hideSearchDialog();
2745 mViewManager->showJournalView(); 2748 mViewManager->showJournalView();
2746 mNavigator->slotDaySelect( jour->dtStart().date() ); 2749 mNavigator->slotDaySelect( jour->dtStart().date() );
2747} 2750}
2748void CalendarView::editTodo( Todo *todo ) 2751void CalendarView::editTodo( Todo *todo )
2749{ 2752{
2750 if ( !todo ) return; 2753 if ( !todo ) return;
2751 2754
2752 if ( todo->isReadOnly() ) { 2755 if ( todo->isReadOnly() ) {
2753 showTodo( todo ); 2756 showTodo( todo );
2754 return; 2757 return;
2755 } 2758 }
2756 showTodoEditor(); 2759 showTodoEditor();
2757 mTodoEditor->editTodo( todo ,mFlagEditDescription); 2760 mTodoEditor->editTodo( todo ,mFlagEditDescription);
2758 2761
2759} 2762}
2760 2763
2761KOEventViewerDialog* CalendarView::getEventViewerDialog() 2764KOEventViewerDialog* CalendarView::getEventViewerDialog()
2762{ 2765{
2763 if ( !mEventViewerDialog ) { 2766 if ( !mEventViewerDialog ) {
2764 mEventViewerDialog = new KOEventViewerDialog(this); 2767 mEventViewerDialog = new KOEventViewerDialog(this);
2765 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 2768 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
2766 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 2769 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
2767 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 2770 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
2768 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 2771 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
2769 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 2772 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
2770 viewManager(), SLOT( showAgendaView( bool ) ) ); 2773 viewManager(), SLOT( showAgendaView( bool ) ) );
2771 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), 2774 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ),
2772 this, SLOT( todoChanged(Todo *) ) ); 2775 this, SLOT( todoChanged(Todo *) ) );
2773 mEventViewerDialog->resize( 640, 480 ); 2776 mEventViewerDialog->resize( 640, 480 );
2774 2777
2775 } 2778 }
2776 return mEventViewerDialog; 2779 return mEventViewerDialog;
2777} 2780}
2778void CalendarView::showEvent(Event *event) 2781void CalendarView::showEvent(Event *event)
2779{ 2782{
2780 getEventViewerDialog()->setEvent(event); 2783 getEventViewerDialog()->setEvent(event);
2781 getEventViewerDialog()->showMe(); 2784 getEventViewerDialog()->showMe();
2782} 2785}
2783 2786
2784void CalendarView::showTodo(Todo *event) 2787void CalendarView::showTodo(Todo *event)
2785{ 2788{
2786 getEventViewerDialog()->setTodo(event); 2789 getEventViewerDialog()->setTodo(event);
2787 getEventViewerDialog()->showMe(); 2790 getEventViewerDialog()->showMe();
2788} 2791}
2789void CalendarView::showJournal( Journal *jour ) 2792void CalendarView::showJournal( Journal *jour )
2790{ 2793{
2791 getEventViewerDialog()->setJournal(jour); 2794 getEventViewerDialog()->setJournal(jour);
2792 getEventViewerDialog()->showMe(); 2795 getEventViewerDialog()->showMe();
2793 2796
2794} 2797}
2795// void CalendarView::todoModified (Todo *event, int changed) 2798// void CalendarView::todoModified (Todo *event, int changed)
2796// { 2799// {
2797// // if (mDialogList.find (event) != mDialogList.end ()) { 2800// // if (mDialogList.find (event) != mDialogList.end ()) {
2798// // kdDebug() << "Todo modified and open" << endl; 2801// // kdDebug() << "Todo modified and open" << endl;
2799// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 2802// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
2800// // temp->modified (changed); 2803// // temp->modified (changed);
2801 2804
2802// // } 2805// // }
2803 2806
2804// mViewManager->updateView(); 2807// mViewManager->updateView();
2805// } 2808// }
2806 2809
2807void CalendarView::appointment_show() 2810void CalendarView::appointment_show()
2808{ 2811{
2809 Event *anEvent = 0; 2812 Event *anEvent = 0;
2810 2813
2811 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2814 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2812 2815
2813 if (mViewManager->currentView()->isEventView()) { 2816 if (mViewManager->currentView()->isEventView()) {
2814 if ( incidence && incidence->type() == "Event" ) { 2817 if ( incidence && incidence->type() == "Event" ) {
2815 anEvent = static_cast<Event *>(incidence); 2818 anEvent = static_cast<Event *>(incidence);
2816 } 2819 }
2817 } 2820 }
2818 2821
2819 if (!anEvent) { 2822 if (!anEvent) {
2820 KNotifyClient::beep(); 2823 KNotifyClient::beep();
2821 return; 2824 return;
2822 } 2825 }
2823 2826
2824 showEvent(anEvent); 2827 showEvent(anEvent);
2825} 2828}
2826 2829
2827void CalendarView::appointment_edit() 2830void CalendarView::appointment_edit()
2828{ 2831{
2829 Event *anEvent = 0; 2832 Event *anEvent = 0;
2830 2833
2831 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2834 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2832 2835
2833 if (mViewManager->currentView()->isEventView()) { 2836 if (mViewManager->currentView()->isEventView()) {
2834 if ( incidence && incidence->type() == "Event" ) { 2837 if ( incidence && incidence->type() == "Event" ) {
2835 anEvent = static_cast<Event *>(incidence); 2838 anEvent = static_cast<Event *>(incidence);
2836 } 2839 }
2837 } 2840 }
2838 2841
2839 if (!anEvent) { 2842 if (!anEvent) {
2840 KNotifyClient::beep(); 2843 KNotifyClient::beep();
2841 return; 2844 return;
2842 } 2845 }
2843 2846
2844 editEvent(anEvent); 2847 editEvent(anEvent);
2845} 2848}
2846 2849
2847void CalendarView::appointment_delete() 2850void CalendarView::appointment_delete()
2848{ 2851{
2849 Event *anEvent = 0; 2852 Event *anEvent = 0;
2850 2853
2851 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2854 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2852 2855
2853 if (mViewManager->currentView()->isEventView()) { 2856 if (mViewManager->currentView()->isEventView()) {
2854 if ( incidence && incidence->type() == "Event" ) { 2857 if ( incidence && incidence->type() == "Event" ) {
2855 anEvent = static_cast<Event *>(incidence); 2858 anEvent = static_cast<Event *>(incidence);
2856 } 2859 }
2857 } 2860 }
2858 2861
2859 if (!anEvent) { 2862 if (!anEvent) {
2860 KNotifyClient::beep(); 2863 KNotifyClient::beep();
2861 return; 2864 return;
2862 } 2865 }
2863 2866
2864 deleteEvent(anEvent); 2867 deleteEvent(anEvent);
2865} 2868}
2866 2869
2867void CalendarView::todo_resub( Todo * parent, Todo * sub ) 2870void CalendarView::todo_resub( Todo * parent, Todo * sub )
2868{ 2871{
2869 if (!sub) return; 2872 if (!sub) return;
2870 if (!parent) return; 2873 if (!parent) return;
2871 if ( sub->relatedTo() ) 2874 if ( sub->relatedTo() )
2872 sub->relatedTo()->removeRelation(sub); 2875 sub->relatedTo()->removeRelation(sub);
2873 sub->setRelatedTo(parent); 2876 sub->setRelatedTo(parent);
2874 sub->setRelatedToUid(parent->uid()); 2877 sub->setRelatedToUid(parent->uid());
2875 parent->addRelation(sub); 2878 parent->addRelation(sub);
2876 sub->updated(); 2879 sub->updated();
2877 parent->updated(); 2880 parent->updated();
2878 setModified(true); 2881 setModified(true);
2879 updateView(); 2882 updateView();
2880} 2883}
2881void CalendarView::todo_unsub(Todo *anTodo ) 2884void CalendarView::todo_unsub(Todo *anTodo )
2882{ 2885{
2883 // Todo *anTodo = selectedTodo(); 2886 // Todo *anTodo = selectedTodo();
2884 if (!anTodo) return; 2887 if (!anTodo) return;
2885 if (!anTodo->relatedTo()) return; 2888 if (!anTodo->relatedTo()) return;
2886 anTodo->relatedTo()->removeRelation(anTodo); 2889 anTodo->relatedTo()->removeRelation(anTodo);
2887 anTodo->setRelatedTo(0); 2890 anTodo->setRelatedTo(0);
2888 anTodo->updated(); 2891 anTodo->updated();
2889 anTodo->setRelatedToUid(""); 2892 anTodo->setRelatedToUid("");
2890 setModified(true); 2893 setModified(true);
2891 updateView(); 2894 updateView();
2892} 2895}
2893 2896
2894void CalendarView::deleteTodo(Todo *todo) 2897void CalendarView::deleteTodo(Todo *todo)
2895{ 2898{
2896 if (!todo) { 2899 if (!todo) {
2897 KNotifyClient::beep(); 2900 KNotifyClient::beep();
2898 return; 2901 return;
2899 } 2902 }
2900 if (KOPrefs::instance()->mConfirm) { 2903 if (KOPrefs::instance()->mConfirm) {
2901 QString text = todo->summary().left(20); 2904 QString text = todo->summary().left(20);
2902 if (!todo->relations().isEmpty()) { 2905 if (!todo->relations().isEmpty()) {
2903 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); 2906 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!");
2904 2907
2905 } 2908 }
2906 switch (msgItemDelete(text)) { 2909 switch (msgItemDelete(text)) {
2907 case KMessageBox::Continue: // OK 2910 case KMessageBox::Continue: // OK
2908 bool deleteT = false; 2911 bool deleteT = false;
2909 if (!todo->relations().isEmpty()) { 2912 if (!todo->relations().isEmpty()) {
2910 deleteT = removeCompletedSubTodos( todo ); 2913 deleteT = removeCompletedSubTodos( todo );
2911 } 2914 }
2912 // deleteT == true: todo already deleted in removeCompletedSubTodos 2915 // deleteT == true: todo already deleted in removeCompletedSubTodos
2913 if ( !deleteT ) { 2916 if ( !deleteT ) {
2914 checkExternalId( todo ); 2917 checkExternalId( todo );
2915 calendar()->deleteTodo(todo); 2918 calendar()->deleteTodo(todo);
2916 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2919 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2917 updateView(); 2920 updateView();
2918 } 2921 }
2919 break; 2922 break;
2920 } // switch 2923 } // switch
2921 } else { 2924 } else {
2922 checkExternalId( todo ); 2925 checkExternalId( todo );
2923 mCalendar->deleteTodo(todo); 2926 mCalendar->deleteTodo(todo);
2924 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2927 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2925 updateView(); 2928 updateView();
2926 } 2929 }
2927 2930
2928 emit updateSearchDialog(); 2931 emit updateSearchDialog();
2929} 2932}
2930void CalendarView::deleteJournal(Journal *jour) 2933void CalendarView::deleteJournal(Journal *jour)
2931{ 2934{
2932 if (!jour) { 2935 if (!jour) {
2933 KNotifyClient::beep(); 2936 KNotifyClient::beep();
2934 return; 2937 return;
2935 } 2938 }
2936 if (KOPrefs::instance()->mConfirm) { 2939 if (KOPrefs::instance()->mConfirm) {
2937 switch (msgItemDelete( jour->description().left(20))) { 2940 switch (msgItemDelete( jour->description().left(20))) {
2938 case KMessageBox::Continue: // OK 2941 case KMessageBox::Continue: // OK
2939 calendar()->deleteJournal(jour); 2942 calendar()->deleteJournal(jour);
2940 updateView(); 2943 updateView();
2941 break; 2944 break;
2942 } // switch 2945 } // switch
2943 } else { 2946 } else {
2944 calendar()->deleteJournal(jour);; 2947 calendar()->deleteJournal(jour);;
2945 updateView(); 2948 updateView();
2946 } 2949 }
2947 emit updateSearchDialog(); 2950 emit updateSearchDialog();
2948} 2951}
2949 2952
2950void CalendarView::deleteEvent(Event *anEvent) 2953void CalendarView::deleteEvent(Event *anEvent)
2951{ 2954{
2952 if (!anEvent) { 2955 if (!anEvent) {
2953 KNotifyClient::beep(); 2956 KNotifyClient::beep();
2954 return; 2957 return;
2955 } 2958 }
2956 2959
2957 if (anEvent->recurrence()->doesRecur()) { 2960 if (anEvent->recurrence()->doesRecur()) {
2958 QDate itemDate = mViewManager->currentSelectionDate(); 2961 QDate itemDate = mViewManager->currentSelectionDate();
2959 int km; 2962 int km;
2960 if (!itemDate.isValid()) { 2963 if (!itemDate.isValid()) {
2961 //kdDebug() << "Date Not Valid" << endl; 2964 //kdDebug() << "Date Not Valid" << endl;
2962 if (KOPrefs::instance()->mConfirm) { 2965 if (KOPrefs::instance()->mConfirm) {
2963 km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + 2966 km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) +
2964 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), 2967 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"),
2965 i18n("KO/Pi Confirmation"),i18n("Delete All")); 2968 i18n("KO/Pi Confirmation"),i18n("Delete All"));
2966 if ( km == KMessageBox::Continue ) 2969 if ( km == KMessageBox::Continue )
2967 km = KMessageBox::No; // No = all below 2970 km = KMessageBox::No; // No = all below
2968 } else 2971 } else
2969 km = KMessageBox::No; 2972 km = KMessageBox::No;
2970 } else { 2973 } else {
2971 km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + 2974 km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) +
2972 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ 2975 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+
2973 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), 2976 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"),
2974 i18n("KO/Pi Confirmation"),i18n("Current"), 2977 i18n("KO/Pi Confirmation"),i18n("Current"),
2975 i18n("All")); 2978 i18n("All"));
2976 } 2979 }
2977 switch(km) { 2980 switch(km) {
2978 2981
2979 case KMessageBox::No: // Continue // all 2982 case KMessageBox::No: // Continue // all
2980 //qDebug("KMessageBox::No "); 2983 //qDebug("KMessageBox::No ");
2981 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2984 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2982 schedule(Scheduler::Cancel,anEvent); 2985 schedule(Scheduler::Cancel,anEvent);
2983 2986
2984 checkExternalId( anEvent); 2987 checkExternalId( anEvent);
2985 mCalendar->deleteEvent(anEvent); 2988 mCalendar->deleteEvent(anEvent);
2986 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); 2989 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED);
2987 break; 2990 break;
2988 2991
2989 // Disabled because it does not work 2992 // Disabled because it does not work
2990 //#if 0 2993 //#if 0
2991 case KMessageBox::Yes: // just this one 2994 case KMessageBox::Yes: // just this one
2992 //QDate qd = mNavigator->selectedDates().first(); 2995 //QDate qd = mNavigator->selectedDates().first();
2993 //if (!qd.isValid()) { 2996 //if (!qd.isValid()) {
2994 // kdDebug() << "no date selected, or invalid date" << endl; 2997 // kdDebug() << "no date selected, or invalid date" << endl;
2995 // KNotifyClient::beep(); 2998 // KNotifyClient::beep();
2996 // return; 2999 // return;
2997 //} 3000 //}
2998 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); 3001 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1);
2999 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { 3002 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) {
3000 anEvent->addExDate(itemDate); 3003 anEvent->addExDate(itemDate);
3001 int duration = anEvent->recurrence()->duration(); 3004 int duration = anEvent->recurrence()->duration();
3002 if ( duration > 0 ) { 3005 if ( duration > 0 ) {
3003 anEvent->recurrence()->setDuration( duration - 1 ); 3006 anEvent->recurrence()->setDuration( duration - 1 );
3004 } 3007 }
3005 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); 3008 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED);
3006 } 3009 }
3007 break; 3010 break;
3008 //#endif 3011 //#endif
3009 } // switch 3012 } // switch
3010 } else { 3013 } else {
3011 if (KOPrefs::instance()->mConfirm) { 3014 if (KOPrefs::instance()->mConfirm) {
3012 switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + 3015 switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) +
3013 i18n("\nAre you sure you want\nto delete this event?"), 3016 i18n("\nAre you sure you want\nto delete this event?"),
3014 i18n("KO/Pi Confirmation"),i18n("Delete"))) { 3017 i18n("KO/Pi Confirmation"),i18n("Delete"))) {
3015 case KMessageBox::Continue: // OK 3018 case KMessageBox::Continue: // OK
3016 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3019 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3017 schedule(Scheduler::Cancel,anEvent); 3020 schedule(Scheduler::Cancel,anEvent);
3018 checkExternalId( anEvent); 3021 checkExternalId( anEvent);
3019 mCalendar->deleteEvent(anEvent); 3022 mCalendar->deleteEvent(anEvent);
3020 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3023 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3021 break; 3024 break;
3022 } // switch 3025 } // switch
3023 } else { 3026 } else {
3024 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3027 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3025 schedule(Scheduler::Cancel,anEvent); 3028 schedule(Scheduler::Cancel,anEvent);
3026 checkExternalId( anEvent); 3029 checkExternalId( anEvent);
3027 mCalendar->deleteEvent(anEvent); 3030 mCalendar->deleteEvent(anEvent);
3028 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3031 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3029 } 3032 }
3030 } // if-else 3033 } // if-else
3031 emit updateSearchDialog(); 3034 emit updateSearchDialog();
3032} 3035}
3033 3036
3034bool CalendarView::deleteEvent(const QString &uid) 3037bool CalendarView::deleteEvent(const QString &uid)
3035{ 3038{
3036 Event *ev = mCalendar->event(uid); 3039 Event *ev = mCalendar->event(uid);
3037 if (ev) { 3040 if (ev) {
3038 deleteEvent(ev); 3041 deleteEvent(ev);
3039 return true; 3042 return true;
3040 } else { 3043 } else {
3041 return false; 3044 return false;
3042 } 3045 }
3043} 3046}
3044 3047
3045/*****************************************************************************/ 3048/*****************************************************************************/
3046 3049
3047void CalendarView::action_mail() 3050void CalendarView::action_mail()
3048{ 3051{
3049#ifndef KORG_NOMAIL 3052#ifndef KORG_NOMAIL
3050 KOMailClient mailClient; 3053 KOMailClient mailClient;
3051 3054
3052 Incidence *incidence = currentSelection(); 3055 Incidence *incidence = currentSelection();
3053 3056
3054 if (!incidence) { 3057 if (!incidence) {
3055 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3058 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3056 return; 3059 return;
3057 } 3060 }
3058 if(incidence->attendeeCount() == 0 ) { 3061 if(incidence->attendeeCount() == 0 ) {
3059 KMessageBox::sorry(this, 3062 KMessageBox::sorry(this,
3060 i18n("Can't generate mail:\nNo attendees defined.\n")); 3063 i18n("Can't generate mail:\nNo attendees defined.\n"));
3061 return; 3064 return;
3062 } 3065 }
3063 3066
3064 CalendarLocal cal_tmp; 3067 CalendarLocal cal_tmp;
3065 Event *event = 0; 3068 Event *event = 0;
3066 Event *ev = 0; 3069 Event *ev = 0;
3067 if ( incidence && incidence->type() == "Event" ) { 3070 if ( incidence && incidence->type() == "Event" ) {
3068 event = static_cast<Event *>(incidence); 3071 event = static_cast<Event *>(incidence);
3069 ev = new Event(*event); 3072 ev = new Event(*event);
3070 cal_tmp.addEvent(ev); 3073 cal_tmp.addEvent(ev);
3071 } 3074 }
3072 ICalFormat mForm(); 3075 ICalFormat mForm();
3073 QString attachment = mForm.toString( &cal_tmp ); 3076 QString attachment = mForm.toString( &cal_tmp );
3074 if (ev) delete(ev); 3077 if (ev) delete(ev);
3075 3078
3076 mailClient.mailAttendees(currentSelection(), attachment); 3079 mailClient.mailAttendees(currentSelection(), attachment);
3077 3080
3078#endif 3081#endif
3079 3082
3080#if 0 3083#if 0
3081 Event *anEvent = 0; 3084 Event *anEvent = 0;
3082 if (mViewManager->currentView()->isEventView()) { 3085 if (mViewManager->currentView()->isEventView()) {
3083 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); 3086 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first());
3084 } 3087 }
3085 3088
3086 if (!anEvent) { 3089 if (!anEvent) {
3087 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3090 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3088 return; 3091 return;
3089 } 3092 }
3090 if(anEvent->attendeeCount() == 0 ) { 3093 if(anEvent->attendeeCount() == 0 ) {
3091 KMessageBox::sorry(this, 3094 KMessageBox::sorry(this,
3092 i18n("Can't generate mail:\nNo attendees defined.\n")); 3095 i18n("Can't generate mail:\nNo attendees defined.\n"));
3093 return; 3096 return;
3094 } 3097 }
3095 3098
3096 mailobject.emailEvent(anEvent); 3099 mailobject.emailEvent(anEvent);
3097#endif 3100#endif
3098} 3101}
3099 3102
3100 3103
3101void CalendarView::schedule_publish(Incidence *incidence) 3104void CalendarView::schedule_publish(Incidence *incidence)
3102{ 3105{
3103 Event *event = 0; 3106 Event *event = 0;
3104 Todo *todo = 0; 3107 Todo *todo = 0;
3105 3108
3106 if (incidence == 0) { 3109 if (incidence == 0) {
3107 incidence = mViewManager->currentView()->selectedIncidences().first(); 3110 incidence = mViewManager->currentView()->selectedIncidences().first();
3108 if (incidence == 0) { 3111 if (incidence == 0) {
3109 incidence = mTodoList->selectedIncidences().first(); 3112 incidence = mTodoList->selectedIncidences().first();
3110 } 3113 }
3111 } 3114 }
3112 if ( incidence && incidence->type() == "Event" ) { 3115 if ( incidence && incidence->type() == "Event" ) {
3113 event = static_cast<Event *>(incidence); 3116 event = static_cast<Event *>(incidence);
3114 } else { 3117 } else {
3115 if ( incidence && incidence->type() == "Todo" ) { 3118 if ( incidence && incidence->type() == "Todo" ) {
3116 todo = static_cast<Todo *>(incidence); 3119 todo = static_cast<Todo *>(incidence);
3117 } 3120 }
3118 } 3121 }
3119 3122
3120 if (!event && !todo) { 3123 if (!event && !todo) {
3121 KMessageBox::sorry(this,i18n("No event selected.")); 3124 KMessageBox::sorry(this,i18n("No event selected."));
3122 return; 3125 return;
3123 } 3126 }
3124 3127
3125 PublishDialog *publishdlg = new PublishDialog(); 3128 PublishDialog *publishdlg = new PublishDialog();
3126 if (incidence->attendeeCount()>0) { 3129 if (incidence->attendeeCount()>0) {
3127 QPtrList<Attendee> attendees = incidence->attendees(); 3130 QPtrList<Attendee> attendees = incidence->attendees();
3128 attendees.first(); 3131 attendees.first();
3129 while ( attendees.current()!=0 ) { 3132 while ( attendees.current()!=0 ) {
3130 publishdlg->addAttendee(attendees.current()); 3133 publishdlg->addAttendee(attendees.current());
3131 attendees.next(); 3134 attendees.next();
3132 } 3135 }
3133 } 3136 }
3134 bool send = true; 3137 bool send = true;
3135 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { 3138 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) {
3136 if ( publishdlg->exec() != QDialog::Accepted ) 3139 if ( publishdlg->exec() != QDialog::Accepted )
3137 send = false; 3140 send = false;
3138 } 3141 }
3139 if ( send ) { 3142 if ( send ) {
3140 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3143 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3141 if ( event ) { 3144 if ( event ) {
3142 Event *ev = new Event(*event); 3145 Event *ev = new Event(*event);
3143 ev->registerObserver(0); 3146 ev->registerObserver(0);
3144 ev->clearAttendees(); 3147 ev->clearAttendees();
3145 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3148 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3146 delete(ev); 3149 delete(ev);
3147 } 3150 }
3148 } else { 3151 } else {
3149 if ( todo ) { 3152 if ( todo ) {
3150 Todo *ev = new Todo(*todo); 3153 Todo *ev = new Todo(*todo);
3151 ev->registerObserver(0); 3154 ev->registerObserver(0);
3152 ev->clearAttendees(); 3155 ev->clearAttendees();
3153 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3156 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3154 delete(ev); 3157 delete(ev);
3155 } 3158 }
3156 } 3159 }
3157 } 3160 }
3158 } 3161 }
3159 delete publishdlg; 3162 delete publishdlg;
3160} 3163}
3161 3164
3162void CalendarView::schedule_request(Incidence *incidence) 3165void CalendarView::schedule_request(Incidence *incidence)
3163{ 3166{
3164 schedule(Scheduler::Request,incidence); 3167 schedule(Scheduler::Request,incidence);
3165} 3168}
3166 3169
3167void CalendarView::schedule_refresh(Incidence *incidence) 3170void CalendarView::schedule_refresh(Incidence *incidence)
3168{ 3171{
3169 schedule(Scheduler::Refresh,incidence); 3172 schedule(Scheduler::Refresh,incidence);
3170} 3173}
3171 3174
3172void CalendarView::schedule_cancel(Incidence *incidence) 3175void CalendarView::schedule_cancel(Incidence *incidence)
3173{ 3176{
3174 schedule(Scheduler::Cancel,incidence); 3177 schedule(Scheduler::Cancel,incidence);
3175} 3178}
3176 3179
3177void CalendarView::schedule_add(Incidence *incidence) 3180void CalendarView::schedule_add(Incidence *incidence)
3178{ 3181{
3179 schedule(Scheduler::Add,incidence); 3182 schedule(Scheduler::Add,incidence);
3180} 3183}
3181 3184
3182void CalendarView::schedule_reply(Incidence *incidence) 3185void CalendarView::schedule_reply(Incidence *incidence)
3183{ 3186{
3184 schedule(Scheduler::Reply,incidence); 3187 schedule(Scheduler::Reply,incidence);
3185} 3188}
3186 3189
3187void CalendarView::schedule_counter(Incidence *incidence) 3190void CalendarView::schedule_counter(Incidence *incidence)
3188{ 3191{
3189 schedule(Scheduler::Counter,incidence); 3192 schedule(Scheduler::Counter,incidence);
3190} 3193}
3191 3194
3192void CalendarView::schedule_declinecounter(Incidence *incidence) 3195void CalendarView::schedule_declinecounter(Incidence *incidence)
3193{ 3196{
3194 schedule(Scheduler::Declinecounter,incidence); 3197 schedule(Scheduler::Declinecounter,incidence);
3195} 3198}
3196 3199
3197void CalendarView::schedule_publish_freebusy(int daysToPublish) 3200void CalendarView::schedule_publish_freebusy(int daysToPublish)
3198{ 3201{
3199 QDateTime start = QDateTime::currentDateTime(); 3202 QDateTime start = QDateTime::currentDateTime();
3200 QDateTime end = start.addDays(daysToPublish); 3203 QDateTime end = start.addDays(daysToPublish);
3201 3204
3202 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); 3205 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end);
3203 freebusy->setOrganizer(KOPrefs::instance()->email()); 3206 freebusy->setOrganizer(KOPrefs::instance()->email());
3204 3207
3205 3208
3206 PublishDialog *publishdlg = new PublishDialog(); 3209 PublishDialog *publishdlg = new PublishDialog();
3207 if ( publishdlg->exec() == QDialog::Accepted ) { 3210 if ( publishdlg->exec() == QDialog::Accepted ) {
3208 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3211 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3209 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { 3212 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) {
3210 delete(freebusy); 3213 delete(freebusy);
3211 } 3214 }
3212 } 3215 }
3213 delete publishdlg; 3216 delete publishdlg;
3214} 3217}
3215 3218
3216void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) 3219void CalendarView::schedule(Scheduler::Method method, Incidence *incidence)
3217{ 3220{
3218 Event *event = 0; 3221 Event *event = 0;
3219 Todo *todo = 0; 3222 Todo *todo = 0;
3220 3223
3221 if (incidence == 0) { 3224 if (incidence == 0) {
3222 incidence = mViewManager->currentView()->selectedIncidences().first(); 3225 incidence = mViewManager->currentView()->selectedIncidences().first();
3223 if (incidence == 0) { 3226 if (incidence == 0) {
3224 incidence = mTodoList->selectedIncidences().first(); 3227 incidence = mTodoList->selectedIncidences().first();
3225 } 3228 }
3226 } 3229 }
3227 if ( incidence && incidence->type() == "Event" ) { 3230 if ( incidence && incidence->type() == "Event" ) {
3228 event = static_cast<Event *>(incidence); 3231 event = static_cast<Event *>(incidence);
3229 } 3232 }
3230 if ( incidence && incidence->type() == "Todo" ) { 3233 if ( incidence && incidence->type() == "Todo" ) {
3231 todo = static_cast<Todo *>(incidence); 3234 todo = static_cast<Todo *>(incidence);
3232 } 3235 }
3233 3236
3234 if (!event && !todo) { 3237 if (!event && !todo) {
3235 KMessageBox::sorry(this,i18n("No event selected.")); 3238 KMessageBox::sorry(this,i18n("No event selected."));
3236 return; 3239 return;
3237 } 3240 }
3238 3241
3239 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { 3242 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) {
3240 KMessageBox::sorry(this,i18n("The event has no attendees.")); 3243 KMessageBox::sorry(this,i18n("The event has no attendees."));
3241 return; 3244 return;
3242 } 3245 }
3243 3246
3244 Event *ev = 0; 3247 Event *ev = 0;
3245 if (event) ev = new Event(*event); 3248 if (event) ev = new Event(*event);
3246 Todo *to = 0; 3249 Todo *to = 0;
3247 if (todo) to = new Todo(*todo); 3250 if (todo) to = new Todo(*todo);
3248 3251
3249 if (method == Scheduler::Reply || method == Scheduler::Refresh) { 3252 if (method == Scheduler::Reply || method == Scheduler::Refresh) {
3250 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 3253 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
3251 if (!me) { 3254 if (!me) {
3252 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); 3255 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails."));
3253 return; 3256 return;
3254 } 3257 }
3255 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { 3258 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) {
3256 StatusDialog *statdlg = new StatusDialog(this); 3259 StatusDialog *statdlg = new StatusDialog(this);
3257 if (!statdlg->exec()==QDialog::Accepted) return; 3260 if (!statdlg->exec()==QDialog::Accepted) return;
3258 me->setStatus( statdlg->status() ); 3261 me->setStatus( statdlg->status() );
3259 delete(statdlg); 3262 delete(statdlg);
3260 } 3263 }
3261 Attendee *menew = new Attendee(*me); 3264 Attendee *menew = new Attendee(*me);
3262 if (ev) { 3265 if (ev) {
3263 ev->clearAttendees(); 3266 ev->clearAttendees();
3264 ev->addAttendee(menew,false); 3267 ev->addAttendee(menew,false);
3265 } else { 3268 } else {
3266 if (to) { 3269 if (to) {
3267 todo->clearAttendees(); 3270 todo->clearAttendees();
3268 todo->addAttendee(menew,false); 3271 todo->addAttendee(menew,false);
3269 } 3272 }
3270 } 3273 }
3271 } 3274 }
3272 3275
3273 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3276 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3274 if (ev) { 3277 if (ev) {
3275 if ( !dlg->addMessage(ev,method) ) delete(ev); 3278 if ( !dlg->addMessage(ev,method) ) delete(ev);
3276 } else { 3279 } else {
3277 if (to) { 3280 if (to) {
3278 if ( !dlg->addMessage(to,method) ) delete(to); 3281 if ( !dlg->addMessage(to,method) ) delete(to);
3279 } 3282 }
3280 } 3283 }
3281} 3284}
3282 3285
3283void CalendarView::openAddressbook() 3286void CalendarView::openAddressbook()
3284{ 3287{
3285 KRun::runCommand("kaddressbook"); 3288 KRun::runCommand("kaddressbook");
3286} 3289}
3287 3290
3288void CalendarView::setModified(bool modified) 3291void CalendarView::setModified(bool modified)
3289{ 3292{
3290 if ( modified ) 3293 if ( modified )
3291 emit signalmodified(); 3294 emit signalmodified();
3292 if (mModified != modified) { 3295 if (mModified != modified) {
3293 mModified = modified; 3296 mModified = modified;
3294 emit modifiedChanged(mModified); 3297 emit modifiedChanged(mModified);
3295 } 3298 }
3296} 3299}
3297 3300
3298bool CalendarView::isReadOnly() 3301bool CalendarView::isReadOnly()
3299{ 3302{
3300 return mReadOnly; 3303 return mReadOnly;
3301} 3304}
3302 3305
3303void CalendarView::setReadOnly(bool readOnly) 3306void CalendarView::setReadOnly(bool readOnly)
3304{ 3307{
3305 if (mReadOnly != readOnly) { 3308 if (mReadOnly != readOnly) {
3306 mReadOnly = readOnly; 3309 mReadOnly = readOnly;
3307 emit readOnlyChanged(mReadOnly); 3310 emit readOnlyChanged(mReadOnly);
3308 } 3311 }
3309} 3312}
3310 3313
3311bool CalendarView::isModified() 3314bool CalendarView::isModified()
3312{ 3315{
3313 return mModified; 3316 return mModified;
3314} 3317}
3315 3318
3316void CalendarView::printSetup() 3319void CalendarView::printSetup()
3317{ 3320{
3318#ifndef KORG_NOPRINTER 3321#ifndef KORG_NOPRINTER
3319 createPrinter(); 3322 createPrinter();
3320 3323
3321 mCalPrinter->setupPrinter(); 3324 mCalPrinter->setupPrinter();
3322#endif 3325#endif
3323} 3326}
3324 3327
3325void CalendarView::print() 3328void CalendarView::print()
3326{ 3329{
3327#ifndef KORG_NOPRINTER 3330#ifndef KORG_NOPRINTER
3328 createPrinter(); 3331 createPrinter();
3329 3332
3330 DateList tmpDateList = mNavigator->selectedDates(); 3333 DateList tmpDateList = mNavigator->selectedDates();
3331 mCalPrinter->print(CalPrinter::Month, 3334 mCalPrinter->print(CalPrinter::Month,
3332 tmpDateList.first(), tmpDateList.last()); 3335 tmpDateList.first(), tmpDateList.last());
3333#endif 3336#endif
3334} 3337}
3335 3338
3336void CalendarView::printPreview() 3339void CalendarView::printPreview()
3337{ 3340{
3338#ifndef KORG_NOPRINTER 3341#ifndef KORG_NOPRINTER
3339 kdDebug() << "CalendarView::printPreview()" << endl; 3342 kdDebug() << "CalendarView::printPreview()" << endl;
3340 3343
3341 createPrinter(); 3344 createPrinter();
3342 3345
3343 DateList tmpDateList = mNavigator->selectedDates(); 3346 DateList tmpDateList = mNavigator->selectedDates();
3344 3347
3345 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), 3348 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(),
3346 tmpDateList.last()); 3349 tmpDateList.last());
3347#endif 3350#endif
3348} 3351}
3349 3352
3350void CalendarView::exportICalendar() 3353void CalendarView::exportICalendar()
3351{ 3354{
3352 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); 3355 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this);
3353 3356
3354 // Force correct extension 3357 // Force correct extension
3355 if (filename.right(4) != ".ics") filename += ".ics"; 3358 if (filename.right(4) != ".ics") filename += ".ics";
3356 3359
3357 FileStorage storage( mCalendar, filename, new ICalFormat() ); 3360 FileStorage storage( mCalendar, filename, new ICalFormat() );
3358 storage.save(); 3361 storage.save();
3359} 3362}
3360 3363
3361bool CalendarView::exportVCalendar( QString filename ) 3364bool CalendarView::exportVCalendar( QString filename )
3362{ 3365{
3363 if (mCalendar->journals().count() > 0) { 3366 if (mCalendar->journals().count() > 0) {
3364 int result = KMessageBox::warningContinueCancel(this, 3367 int result = KMessageBox::warningContinueCancel(this,
3365 i18n("The journal entries can not be\nexported to a vCalendar file."), 3368 i18n("The journal entries can not be\nexported to a vCalendar file."),
3366 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 3369 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
3367 true); 3370 true);
3368 if (result != KMessageBox::Continue) return false; 3371 if (result != KMessageBox::Continue) return false;
3369 } 3372 }
3370 3373
3371 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); 3374 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this);
3372 3375
3373 // Force correct extension 3376 // Force correct extension
3374 if (filename.right(4) != ".vcs") filename += ".vcs"; 3377 if (filename.right(4) != ".vcs") filename += ".vcs";
3375 3378
3376 FileStorage storage( mCalendar, filename, new VCalFormat ); 3379 FileStorage storage( mCalendar, filename, new VCalFormat );
3377 return storage.save(); 3380 return storage.save();
3378 3381
3379} 3382}
3380 3383
3381void CalendarView::eventUpdated(Incidence *) 3384void CalendarView::eventUpdated(Incidence *)
3382{ 3385{
3383 setModified(); 3386 setModified();
3384 // Don't call updateView here. The code, which has caused the update of the 3387 // Don't call updateView here. The code, which has caused the update of the
3385 // event is responsible for updating the view. 3388 // event is responsible for updating the view.
3386 // updateView(); 3389 // updateView();
3387} 3390}
3388 3391
3389void CalendarView::adaptNavigationUnits() 3392void CalendarView::adaptNavigationUnits()
3390{ 3393{
3391 if (mViewManager->currentView()->isEventView()) { 3394 if (mViewManager->currentView()->isEventView()) {
3392 int days = mViewManager->currentView()->currentDateCount(); 3395 int days = mViewManager->currentView()->currentDateCount();
3393 if (days == 1) { 3396 if (days == 1) {
3394 emit changeNavStringPrev(i18n("&Previous Day")); 3397 emit changeNavStringPrev(i18n("&Previous Day"));
3395 emit changeNavStringNext(i18n("&Next Day")); 3398 emit changeNavStringNext(i18n("&Next Day"));
3396 } else { 3399 } else {
3397 emit changeNavStringPrev(i18n("&Previous Week")); 3400 emit changeNavStringPrev(i18n("&Previous Week"));
3398 emit changeNavStringNext(i18n("&Next Week")); 3401 emit changeNavStringNext(i18n("&Next Week"));
3399 } 3402 }
3400 } 3403 }
3401} 3404}
3402 3405
3403void CalendarView::processMainViewSelection( Incidence *incidence ) 3406void CalendarView::processMainViewSelection( Incidence *incidence )
3404{ 3407{
3405 if ( incidence ) mTodoList->clearSelection(); 3408 if ( incidence ) mTodoList->clearSelection();
3406 processIncidenceSelection( incidence ); 3409 processIncidenceSelection( incidence );
3407} 3410}
3408 3411
3409void CalendarView::processTodoListSelection( Incidence *incidence ) 3412void CalendarView::processTodoListSelection( Incidence *incidence )
3410{ 3413{
3411 if ( incidence && mViewManager->currentView() ) { 3414 if ( incidence && mViewManager->currentView() ) {
3412 mViewManager->currentView()->clearSelection(); 3415 mViewManager->currentView()->clearSelection();
3413 } 3416 }
3414 processIncidenceSelection( incidence ); 3417 processIncidenceSelection( incidence );
3415} 3418}
3416 3419
3417void CalendarView::processIncidenceSelection( Incidence *incidence ) 3420void CalendarView::processIncidenceSelection( Incidence *incidence )
3418{ 3421{
3419 if ( incidence == mSelectedIncidence ) return; 3422 if ( incidence == mSelectedIncidence ) return;
3420 3423
3421 mSelectedIncidence = incidence; 3424 mSelectedIncidence = incidence;
3422 3425
3423 emit incidenceSelected( mSelectedIncidence ); 3426 emit incidenceSelected( mSelectedIncidence );
3424 3427
3425 if ( incidence && incidence->type() == "Event" ) { 3428 if ( incidence && incidence->type() == "Event" ) {
3426 Event *event = static_cast<Event *>( incidence ); 3429 Event *event = static_cast<Event *>( incidence );
3427 if ( event->organizer() == KOPrefs::instance()->email() ) { 3430 if ( event->organizer() == KOPrefs::instance()->email() ) {
3428 emit organizerEventsSelected( true ); 3431 emit organizerEventsSelected( true );
3429 } else { 3432 } else {
3430 emit organizerEventsSelected(false); 3433 emit organizerEventsSelected(false);
3431 } 3434 }
3432 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3435 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3433 KOPrefs::instance()->email() ) ) { 3436 KOPrefs::instance()->email() ) ) {
3434 emit groupEventsSelected( true ); 3437 emit groupEventsSelected( true );
3435 } else { 3438 } else {
3436 emit groupEventsSelected(false); 3439 emit groupEventsSelected(false);
3437 } 3440 }
3438 return; 3441 return;
3439 } else { 3442 } else {
3440 if ( incidence && incidence->type() == "Todo" ) { 3443 if ( incidence && incidence->type() == "Todo" ) {
3441 emit todoSelected( true ); 3444 emit todoSelected( true );
3442 Todo *event = static_cast<Todo *>( incidence ); 3445 Todo *event = static_cast<Todo *>( incidence );
3443 if ( event->organizer() == KOPrefs::instance()->email() ) { 3446 if ( event->organizer() == KOPrefs::instance()->email() ) {
3444 emit organizerEventsSelected( true ); 3447 emit organizerEventsSelected( true );
3445 } else { 3448 } else {
3446 emit organizerEventsSelected(false); 3449 emit organizerEventsSelected(false);
3447 } 3450 }
3448 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3451 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3449 KOPrefs::instance()->email() ) ) { 3452 KOPrefs::instance()->email() ) ) {
3450 emit groupEventsSelected( true ); 3453 emit groupEventsSelected( true );
3451 } else { 3454 } else {
3452 emit groupEventsSelected(false); 3455 emit groupEventsSelected(false);
3453 } 3456 }
3454 return; 3457 return;
3455 } else { 3458 } else {
3456 emit todoSelected( false ); 3459 emit todoSelected( false );
3457 emit organizerEventsSelected(false); 3460 emit organizerEventsSelected(false);
3458 emit groupEventsSelected(false); 3461 emit groupEventsSelected(false);
3459 } 3462 }
3460 return; 3463 return;
3461 } 3464 }
3462 3465
3463 /* if ( incidence && incidence->type() == "Todo" ) { 3466 /* if ( incidence && incidence->type() == "Todo" ) {
3464 emit todoSelected( true ); 3467 emit todoSelected( true );
3465 } else { 3468 } else {
3466 emit todoSelected( false ); 3469 emit todoSelected( false );
3467 }*/ 3470 }*/
3468} 3471}
3469 3472
3470 3473
3471void CalendarView::checkClipboard() 3474void CalendarView::checkClipboard()
3472{ 3475{
3473#ifndef KORG_NODND 3476#ifndef KORG_NODND
3474 if (ICalDrag::canDecode(QApplication::clipboard()->data())) { 3477 if (ICalDrag::canDecode(QApplication::clipboard()->data())) {
3475 emit pasteEnabled(true); 3478 emit pasteEnabled(true);
3476 } else { 3479 } else {
3477 emit pasteEnabled(false); 3480 emit pasteEnabled(false);
3478 } 3481 }
3479#endif 3482#endif
3480} 3483}
3481 3484
3482void CalendarView::showDates(const DateList &selectedDates) 3485void CalendarView::showDates(const DateList &selectedDates)
3483{ 3486{
3484 // kdDebug() << "CalendarView::selectDates()" << endl; 3487 // kdDebug() << "CalendarView::selectDates()" << endl;
3485 3488
3486 3489
3487 if ( !mBlockShowDates ) { 3490 if ( !mBlockShowDates ) {
3488 if ( mViewManager->currentView() ) { 3491 if ( mViewManager->currentView() ) {
3489 updateView( selectedDates.first(), selectedDates.last() ); 3492 updateView( selectedDates.first(), selectedDates.last() );
3490 } else { 3493 } else {
3491 mViewManager->showAgendaView(); 3494 mViewManager->showAgendaView();
3492 } 3495 }
3493 } 3496 }
3494 3497
3495 QString selDates; 3498 QString selDates;
3496 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); 3499 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true);
3497 if (selectedDates.first() < selectedDates.last() ) 3500 if (selectedDates.first() < selectedDates.last() )
3498 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); 3501 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true);
3499 else { 3502 else {
3500 QString addString; 3503 QString addString;
3501 if ( selectedDates.first() == QDateTime::currentDateTime().date() ) 3504 if ( selectedDates.first() == QDateTime::currentDateTime().date() )
3502 addString = i18n("Today"); 3505 addString = i18n("Today");
3503 else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) 3506 else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(1) )
3504 addString = i18n("Tomorrow"); 3507 addString = i18n("Tomorrow");
3505 else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) 3508 else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) )
3506 addString = i18n("Yesterday"); 3509 addString = i18n("Yesterday");
3507 else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) 3510 else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) )
3508 addString = i18n("Day before yesterday"); 3511 addString = i18n("Day before yesterday");
3509 else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) 3512 else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(2) )
3510 addString = i18n("Day after tomorrow"); 3513 addString = i18n("Day after tomorrow");
3511 if ( !addString.isEmpty() ) { 3514 if ( !addString.isEmpty() ) {
3512 topLevelWidget()->setCaption( addString+", " + selDates ); 3515 topLevelWidget()->setCaption( addString+", " + selDates );
3513 return; 3516 return;
3514 } 3517 }
3515 } 3518 }
3516 topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); 3519 topLevelWidget()->setCaption( i18n("Dates: ") + selDates );
3517 3520
3518} 3521}
3519 3522
3520QPtrList<CalFilter> CalendarView::filters() 3523QPtrList<CalFilter> CalendarView::filters()
3521{ 3524{
3522 return mFilters; 3525 return mFilters;
3523 3526
3524} 3527}
3525void CalendarView::editFilters() 3528void CalendarView::editFilters()
3526{ 3529{
3527 // kdDebug() << "CalendarView::editFilters()" << endl; 3530 // kdDebug() << "CalendarView::editFilters()" << endl;
3528 3531
3529 CalFilter *filter = mFilters.first(); 3532 CalFilter *filter = mFilters.first();
3530 while(filter) { 3533 while(filter) {
3531 kdDebug() << " Filter: " << filter->name() << endl; 3534 kdDebug() << " Filter: " << filter->name() << endl;
3532 filter = mFilters.next(); 3535 filter = mFilters.next();
3533 } 3536 }
3534 3537
3535 mDialogManager->showFilterEditDialog(&mFilters); 3538 mDialogManager->showFilterEditDialog(&mFilters);
3536} 3539}
3537void CalendarView::toggleFilter() 3540void CalendarView::toggleFilter()
3538{ 3541{
3539 showFilter(! mFilterView->isVisible()); 3542 showFilter(! mFilterView->isVisible());
3540} 3543}
3541 3544
3542KOFilterView *CalendarView::filterView() 3545KOFilterView *CalendarView::filterView()
3543{ 3546{
3544 return mFilterView; 3547 return mFilterView;
3545} 3548}
3546void CalendarView::selectFilter( int fil ) 3549void CalendarView::selectFilter( int fil )
3547{ 3550{
3548 mFilterView->setSelectedFilter( fil ); 3551 mFilterView->setSelectedFilter( fil );
3549} 3552}
3550void CalendarView::showFilter(bool visible) 3553void CalendarView::showFilter(bool visible)
3551{ 3554{
3552 if (visible) mFilterView->show(); 3555 if (visible) mFilterView->show();
3553 else mFilterView->hide(); 3556 else mFilterView->hide();
3554} 3557}
3555void CalendarView::toggleFilerEnabled( ) 3558void CalendarView::toggleFilerEnabled( )
3556{ 3559{
3557 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); 3560 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() );
3558 if ( !mFilterView->filtersEnabled() ) 3561 if ( !mFilterView->filtersEnabled() )
3559 topLevelWidget()->setCaption( i18n("Filter disabled ") ); 3562 topLevelWidget()->setCaption( i18n("Filter disabled ") );
3560 3563
3561} 3564}
3562void CalendarView::updateFilter() 3565void CalendarView::updateFilter()
3563{ 3566{
3564 CalFilter *filter = mFilterView->selectedFilter(); 3567 CalFilter *filter = mFilterView->selectedFilter();
3565 if (filter) { 3568 if (filter) {
3566 if (mFilterView->filtersEnabled()) { 3569 if (mFilterView->filtersEnabled()) {
3567 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); 3570 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() );
3568 filter->setEnabled(true); 3571 filter->setEnabled(true);
3569 } 3572 }
3570 else filter->setEnabled(false); 3573 else filter->setEnabled(false);
3571 mCalendar->setFilter(filter); 3574 mCalendar->setFilter(filter);
3572 updateView(); 3575 updateView();
3573 } 3576 }
3574} 3577}
3575 3578
3576void CalendarView::filterEdited() 3579void CalendarView::filterEdited()
3577{ 3580{
3578 mFilterView->updateFilters(); 3581 mFilterView->updateFilters();
3579 updateFilter(); 3582 updateFilter();
3580 writeSettings(); 3583 writeSettings();
3581} 3584}
3582 3585
3583 3586
3584void CalendarView::takeOverEvent() 3587void CalendarView::takeOverEvent()
3585{ 3588{
3586 Incidence *incidence = currentSelection(); 3589 Incidence *incidence = currentSelection();
3587 3590
3588 if (!incidence) return; 3591 if (!incidence) return;
3589 3592
3590 incidence->setOrganizer(KOPrefs::instance()->email()); 3593 incidence->setOrganizer(KOPrefs::instance()->email());
3591 incidence->recreate(); 3594 incidence->recreate();
3592 incidence->setReadOnly(false); 3595 incidence->setReadOnly(false);
3593 3596
3594 updateView(); 3597 updateView();
3595} 3598}
3596 3599
3597void CalendarView::takeOverCalendar() 3600void CalendarView::takeOverCalendar()
3598{ 3601{
3599 // TODO: Create Calendar::allIncidences() function and use it here 3602 // TODO: Create Calendar::allIncidences() function and use it here
3600 3603
3601 QPtrList<Event> events = mCalendar->events(); 3604 QPtrList<Event> events = mCalendar->events();
3602 for(uint i=0; i<events.count(); ++i) { 3605 for(uint i=0; i<events.count(); ++i) {
3603 events.at(i)->setOrganizer(KOPrefs::instance()->email()); 3606 events.at(i)->setOrganizer(KOPrefs::instance()->email());
3604 events.at(i)->recreate(); 3607 events.at(i)->recreate();
3605 events.at(i)->setReadOnly(false); 3608 events.at(i)->setReadOnly(false);
3606 } 3609 }
3607 3610
3608 QPtrList<Todo> todos = mCalendar->todos(); 3611 QPtrList<Todo> todos = mCalendar->todos();
3609 for(uint i=0; i<todos.count(); ++i) { 3612 for(uint i=0; i<todos.count(); ++i) {
3610 todos.at(i)->setOrganizer(KOPrefs::instance()->email()); 3613 todos.at(i)->setOrganizer(KOPrefs::instance()->email());
3611 todos.at(i)->recreate(); 3614 todos.at(i)->recreate();
3612 todos.at(i)->setReadOnly(false); 3615 todos.at(i)->setReadOnly(false);
3613 } 3616 }
3614 3617
3615 QPtrList<Journal> journals = mCalendar->journals(); 3618 QPtrList<Journal> journals = mCalendar->journals();
3616 for(uint i=0; i<journals.count(); ++i) { 3619 for(uint i=0; i<journals.count(); ++i) {
3617 journals.at(i)->setOrganizer(KOPrefs::instance()->email()); 3620 journals.at(i)->setOrganizer(KOPrefs::instance()->email());
3618 journals.at(i)->recreate(); 3621 journals.at(i)->recreate();
3619 journals.at(i)->setReadOnly(false); 3622 journals.at(i)->setReadOnly(false);
3620 } 3623 }
3621 3624
3622 updateView(); 3625 updateView();
3623} 3626}
3624 3627
3625void CalendarView::showIntro() 3628void CalendarView::showIntro()
3626{ 3629{
3627 kdDebug() << "To be implemented." << endl; 3630 kdDebug() << "To be implemented." << endl;
3628} 3631}
3629 3632
3630QWidgetStack *CalendarView::viewStack() 3633QWidgetStack *CalendarView::viewStack()
3631{ 3634{
3632 return mRightFrame; 3635 return mRightFrame;
3633} 3636}
3634 3637
3635QWidget *CalendarView::leftFrame() 3638QWidget *CalendarView::leftFrame()
3636{ 3639{
3637 return mLeftFrame; 3640 return mLeftFrame;
3638} 3641}
3639 3642
3640DateNavigator *CalendarView::dateNavigator() 3643DateNavigator *CalendarView::dateNavigator()
3641{ 3644{
3642 return mNavigator; 3645 return mNavigator;
3643} 3646}
3644 3647
3645KDateNavigator* CalendarView::dateNavigatorWidget() 3648KDateNavigator* CalendarView::dateNavigatorWidget()
3646{ 3649{
3647 return mDateNavigator; 3650 return mDateNavigator;
3648} 3651}
3649void CalendarView::toggleDateNavigatorWidget() 3652void CalendarView::toggleDateNavigatorWidget()
3650{ 3653{
3651 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; 3654 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ;
3652 if (!KOPrefs::instance()->mShowDateNavigator ) 3655 if (!KOPrefs::instance()->mShowDateNavigator )
3653 mDateNavigator->hide(); 3656 mDateNavigator->hide();
3654 else 3657 else
3655 mDateNavigator->show(); 3658 mDateNavigator->show();
3656} 3659}
3657void CalendarView::addView(KOrg::BaseView *view) 3660void CalendarView::addView(KOrg::BaseView *view)
3658{ 3661{
3659 mViewManager->addView(view); 3662 mViewManager->addView(view);
3660} 3663}
3661 3664
3662void CalendarView::showView(KOrg::BaseView *view) 3665void CalendarView::showView(KOrg::BaseView *view)
3663{ 3666{
3664 mViewManager->showView(view, mLeftFrame->isVisible()); 3667 mViewManager->showView(view, mLeftFrame->isVisible());
3665} 3668}
3666 3669
3667Incidence *CalendarView::currentSelection() 3670Incidence *CalendarView::currentSelection()
3668{ 3671{
3669 return mViewManager->currentSelection(); 3672 return mViewManager->currentSelection();
3670} 3673}
3671void CalendarView::toggleAllDaySize() 3674void CalendarView::toggleAllDaySize()
3672{ 3675{
3673 /* 3676 /*
3674 if ( KOPrefs::instance()->mAllDaySize > 47 ) 3677 if ( KOPrefs::instance()->mAllDaySize > 47 )
3675 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; 3678 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2;
3676 else 3679 else
3677 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; 3680 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2;
3678 */ 3681 */
3679 viewManager()->agendaView()->toggleAllDay(); 3682 viewManager()->agendaView()->toggleAllDay();
3680} 3683}
3681void CalendarView::toggleExpand() 3684void CalendarView::toggleExpand()
3682{ 3685{
3683 // if ( mLeftFrame->isHidden() ) { 3686 // if ( mLeftFrame->isHidden() ) {
3684 // mLeftFrame->show(); 3687 // mLeftFrame->show();
3685 // emit calendarViewExpanded( false ); 3688 // emit calendarViewExpanded( false );
3686 // } else { 3689 // } else {
3687 // mLeftFrame->hide(); 3690 // mLeftFrame->hide();
3688 // emit calendarViewExpanded( true ); 3691 // emit calendarViewExpanded( true );
3689 // } 3692 // }
3690 //qDebug(" CalendarView::toggleExpand()"); 3693 //qDebug(" CalendarView::toggleExpand()");
3691 globalFlagBlockAgenda = 1; 3694 globalFlagBlockAgenda = 1;
3692 emit calendarViewExpanded( !mLeftFrame->isHidden() ); 3695 emit calendarViewExpanded( !mLeftFrame->isHidden() );
3693 globalFlagBlockAgenda = 5; 3696 globalFlagBlockAgenda = 5;
3694 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); 3697 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() );
3695 //mViewManager->showView( 0, true ); 3698 //mViewManager->showView( 0, true );
3696} 3699}
3697 3700
3698void CalendarView::calendarModified( bool modified, Calendar * ) 3701void CalendarView::calendarModified( bool modified, Calendar * )
3699{ 3702{
3700 setModified( modified ); 3703 setModified( modified );
3701} 3704}
3702 3705
3703Todo *CalendarView::selectedTodo() 3706Todo *CalendarView::selectedTodo()
3704{ 3707{
3705 Incidence *incidence = currentSelection(); 3708 Incidence *incidence = currentSelection();
3706 if ( incidence && incidence->type() == "Todo" ) { 3709 if ( incidence && incidence->type() == "Todo" ) {
3707 return static_cast<Todo *>( incidence ); 3710 return static_cast<Todo *>( incidence );
3708 } 3711 }
3709 3712
3710 incidence = mTodoList->selectedIncidences().first(); 3713 incidence = mTodoList->selectedIncidences().first();
3711 if ( incidence && incidence->type() == "Todo" ) { 3714 if ( incidence && incidence->type() == "Todo" ) {
3712 return static_cast<Todo *>( incidence ); 3715 return static_cast<Todo *>( incidence );
3713 } 3716 }
3714 3717
3715 return 0; 3718 return 0;
3716} 3719}
3717 3720
3718void CalendarView::dialogClosing(Incidence *in) 3721void CalendarView::dialogClosing(Incidence *in)
3719{ 3722{
3720 // mDialogList.remove(in); 3723 // mDialogList.remove(in);
3721} 3724}
3722 3725
3723void CalendarView::showIncidence() 3726void CalendarView::showIncidence()
3724{ 3727{
3725 Incidence *incidence = currentSelection(); 3728 Incidence *incidence = currentSelection();
3726 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3729 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3727 if ( incidence ) { 3730 if ( incidence ) {
3728 ShowIncidenceVisitor v; 3731 ShowIncidenceVisitor v;
3729 v.act( incidence, this ); 3732 v.act( incidence, this );
3730 } 3733 }
3731} 3734}
3732void CalendarView::editIncidenceDescription() 3735void CalendarView::editIncidenceDescription()
3733{ 3736{
3734 mFlagEditDescription = true; 3737 mFlagEditDescription = true;
3735 editIncidence(); 3738 editIncidence();
3736 mFlagEditDescription = false; 3739 mFlagEditDescription = false;
3737} 3740}
3738void CalendarView::editIncidence() 3741void CalendarView::editIncidence()
3739{ 3742{
3740 // qDebug("editIncidence() "); 3743 // qDebug("editIncidence() ");
3741 Incidence *incidence = currentSelection(); 3744 Incidence *incidence = currentSelection();
3742 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3745 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3743 if ( incidence ) { 3746 if ( incidence ) {
3744 EditIncidenceVisitor v; 3747 EditIncidenceVisitor v;
3745 v.act( incidence, this ); 3748 v.act( incidence, this );
3746 } 3749 }
3747} 3750}
3748 3751
3749void CalendarView::deleteIncidence() 3752void CalendarView::deleteIncidence()
3750{ 3753{
3751 Incidence *incidence = currentSelection(); 3754 Incidence *incidence = currentSelection();
3752 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3755 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3753 if ( incidence ) { 3756 if ( incidence ) {
3754 deleteIncidence(incidence); 3757 deleteIncidence(incidence);
3755 } 3758 }
3756} 3759}
3757 3760
3758void CalendarView::showIncidence(Incidence *incidence) 3761void CalendarView::showIncidence(Incidence *incidence)
3759{ 3762{
3760 if ( incidence ) { 3763 if ( incidence ) {
3761 ShowIncidenceVisitor v; 3764 ShowIncidenceVisitor v;
3762 v.act( incidence, this ); 3765 v.act( incidence, this );
3763 } 3766 }
3764} 3767}
3765 3768
3766void CalendarView::editIncidence(Incidence *incidence) 3769void CalendarView::editIncidence(Incidence *incidence)
3767{ 3770{
3768 if ( incidence ) { 3771 if ( incidence ) {
3769 3772
3770 EditIncidenceVisitor v; 3773 EditIncidenceVisitor v;
3771 v.act( incidence, this ); 3774 v.act( incidence, this );
3772 3775
3773 } 3776 }
3774} 3777}
3775 3778
3776void CalendarView::deleteIncidence(Incidence *incidence) 3779void CalendarView::deleteIncidence(Incidence *incidence)
3777{ 3780{
3778 //qDebug(" CalendarView::deleteIncidence "); 3781 //qDebug(" CalendarView::deleteIncidence ");
3779 if ( incidence ) { 3782 if ( incidence ) {
3780 DeleteIncidenceVisitor v; 3783 DeleteIncidenceVisitor v;
3781 v.act( incidence, this ); 3784 v.act( incidence, this );
3782 } 3785 }
3783} 3786}
3784 3787
3785 3788
3786void CalendarView::lookForOutgoingMessages() 3789void CalendarView::lookForOutgoingMessages()
3787{ 3790{
3788 OutgoingDialog *ogd = mDialogManager->outgoingDialog(); 3791 OutgoingDialog *ogd = mDialogManager->outgoingDialog();
3789 ogd->loadMessages(); 3792 ogd->loadMessages();
3790} 3793}
3791 3794
3792void CalendarView::lookForIncomingMessages() 3795void CalendarView::lookForIncomingMessages()
3793{ 3796{
3794 IncomingDialog *icd = mDialogManager->incomingDialog(); 3797 IncomingDialog *icd = mDialogManager->incomingDialog();
3795 icd->retrieve(); 3798 icd->retrieve();
3796} 3799}
3797 3800
3798bool CalendarView::removeCompletedSubTodos( Todo* t ) 3801bool CalendarView::removeCompletedSubTodos( Todo* t )
3799{ 3802{
3800 bool deleteTodo = true; 3803 bool deleteTodo = true;
3801 QPtrList<Incidence> subTodos; 3804 QPtrList<Incidence> subTodos;
3802 Incidence *aTodo; 3805 Incidence *aTodo;
3803 subTodos = t->relations(); 3806 subTodos = t->relations();
3804 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { 3807 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
3805 if (! removeCompletedSubTodos( (Todo*) aTodo )) 3808 if (! removeCompletedSubTodos( (Todo*) aTodo ))
3806 deleteTodo = false; 3809 deleteTodo = false;
3807 } 3810 }
3808 if ( deleteTodo ) { 3811 if ( deleteTodo ) {
3809 if ( t->isCompleted() ) { 3812 if ( t->isCompleted() ) {
3810 checkExternalId( t ); 3813 checkExternalId( t );
3811 mCalendar->deleteTodo( t ); 3814 mCalendar->deleteTodo( t );
3812 changeTodoDisplay( t,KOGlobals::EVENTDELETED ); 3815 changeTodoDisplay( t,KOGlobals::EVENTDELETED );
3813 } 3816 }
3814 else 3817 else
3815 deleteTodo = false; 3818 deleteTodo = false;
3816 } 3819 }
3817 return deleteTodo; 3820 return deleteTodo;
3818 3821
3819} 3822}
3820void CalendarView::purgeCompleted() 3823void CalendarView::purgeCompleted()
3821{ 3824{
3822 int result = KMessageBox::warningContinueCancel(this, 3825 int result = KMessageBox::warningContinueCancel(this,
3823 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); 3826 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge"));
3824 3827
3825 if (result == KMessageBox::Continue) { 3828 if (result == KMessageBox::Continue) {
3826 3829
3827 QPtrList<Todo> todoCal; 3830 QPtrList<Todo> todoCal;
3828 QPtrList<Todo> rootTodos; 3831 QPtrList<Todo> rootTodos;
3829 //QPtrList<Incidence> rel; 3832 //QPtrList<Incidence> rel;
3830 Todo *aTodo;//, *rTodo; 3833 Todo *aTodo;//, *rTodo;
3831 Incidence *rIncidence; 3834 Incidence *rIncidence;
3832 bool childDelete = false; 3835 bool childDelete = false;
3833 bool deletedOne = true; 3836 bool deletedOne = true;
3834 todoCal = calendar()->todos(); 3837 todoCal = calendar()->todos();
3835 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { 3838 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
3836 if ( !aTodo->relatedTo() ) 3839 if ( !aTodo->relatedTo() )
3837 rootTodos.append( aTodo ); 3840 rootTodos.append( aTodo );
3838 } 3841 }
3839 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { 3842 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) {
3840 removeCompletedSubTodos( aTodo ); 3843 removeCompletedSubTodos( aTodo );
3841 } 3844 }
3842 3845
3843 updateView(); 3846 updateView();
3844 } 3847 }
3845} 3848}
3846 3849
3847void CalendarView::slotCalendarChanged() 3850void CalendarView::slotCalendarChanged()
3848{ 3851{
3849 ; 3852 ;
3850} 3853}
3851 3854
3852void CalendarView::keyPressEvent ( QKeyEvent *e) 3855void CalendarView::keyPressEvent ( QKeyEvent *e)
3853{ 3856{
3854 //qDebug(" alendarView::keyPressEvent "); 3857 //qDebug(" alendarView::keyPressEvent ");
3855 e->ignore(); 3858 e->ignore();
3856} 3859}
3857 3860
3858 3861
3859bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) 3862bool CalendarView::sync(KSyncManager* manager, QString filename, int mode)
3860{ 3863{
3861 // mSyncManager = manager; 3864 // mSyncManager = manager;
3862 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { 3865 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) {
3863 qDebug("KO: SyncKDE request detected!"); 3866 qDebug("KO: SyncKDE request detected!");
3864 } 3867 }
3865 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 3868 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
3866 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 3869 mCurrentSyncName = mSyncManager->getCurrentSyncName();
3867 return syncCalendar( filename, mode ); 3870 return syncCalendar( filename, mode );
3868} 3871}
3869bool CalendarView::syncExternal(KSyncManager* manager, QString resource) 3872bool CalendarView::syncExternal(KSyncManager* manager, QString resource)
3870{ 3873{
3871 //mSyncManager = manager; 3874 //mSyncManager = manager;
3872 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 3875 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
3873 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 3876 mCurrentSyncName = mSyncManager->getCurrentSyncName();
3874 if ( resource == "sharp" ) 3877 if ( resource == "sharp" )
3875 syncExternal( 0 ); 3878 syncExternal( 0 );
3876 if ( resource == "phone" ) 3879 if ( resource == "phone" )
3877 syncExternal( 1 ); 3880 syncExternal( 1 );
3878 // pending setmodified 3881 // pending setmodified
3879 return true; 3882 return true;
3880} 3883}
3881void CalendarView::setSyncManager(KSyncManager* manager) 3884void CalendarView::setSyncManager(KSyncManager* manager)
3882{ 3885{
3883 mSyncManager = manager; 3886 mSyncManager = manager;
3884} 3887}
3885 3888
3886void CalendarView::removeSyncInfo( QString syncProfile) 3889void CalendarView::removeSyncInfo( QString syncProfile)
3887{ 3890{
3888 qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); 3891 qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1());
3889 mCalendar->removeSyncInfo( syncProfile ); 3892 mCalendar->removeSyncInfo( syncProfile );
3890 3893
3891} 3894}
3892 3895
3893void CalendarView::undo_delete() 3896void CalendarView::undo_delete()
3894{ 3897{
3895 //qDebug("undo_delete() "); 3898 //qDebug("undo_delete() ");
3896 Incidence* undo = mCalendar->undoIncidence(); 3899 Incidence* undo = mCalendar->undoIncidence();
3897 if ( !undo ) { 3900 if ( !undo ) {
3898 KMessageBox::sorry(this,i18n("There is nothing to undo!"), 3901 KMessageBox::sorry(this,i18n("There is nothing to undo!"),
3899 i18n("KO/Pi")); 3902 i18n("KO/Pi"));
3900 return; 3903 return;
3901 } 3904 }
3902 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + 3905 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) +
3903 i18n("\nAre you sure you want\nto restore this?"), 3906 i18n("\nAre you sure you want\nto restore this?"),
3904 i18n("KO/Pi Confirmation"),i18n("Restore"))) { 3907 i18n("KO/Pi Confirmation"),i18n("Restore"))) {
3905 mCalendar->undoDeleteIncidence(); 3908 mCalendar->undoDeleteIncidence();
3906 updateView(); 3909 updateView();
3907 } 3910 }
3908} 3911}
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index 731298d..e626ea3 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -1,611 +1,612 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000, 2001 3 Copyright (c) 2000, 2001
4 Cornelius Schumacher <schumacher@kde.org> 4 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24#ifndef CALENDARVIEW_H 24#ifndef CALENDARVIEW_H
25#define CALENDARVIEW_H 25#define CALENDARVIEW_H
26 26
27#include <qframe.h> 27#include <qframe.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#include <qwidget.h> 29#include <qwidget.h>
30#include <qptrlist.h> 30#include <qptrlist.h>
31#include <qvbox.h> 31#include <qvbox.h>
32#include <qmap.h> 32#include <qmap.h>
33#ifndef DESKTOP_VERSION 33#ifndef DESKTOP_VERSION
34#include <qtopia/ir.h> 34#include <qtopia/ir.h>
35#else 35#else
36#define Ir char 36#define Ir char
37#endif 37#endif
38#include <libkcal/calendar.h> 38#include <libkcal/calendar.h>
39#include <libkcal/scheduler.h> 39#include <libkcal/scheduler.h>
40#include <libkcal/calendarresources.h> 40#include <libkcal/calendarresources.h>
41#include <libkcal/resourcecalendar.h> 41#include <libkcal/resourcecalendar.h>
42 42
43#include <korganizer/calendarviewbase.h> 43#include <korganizer/calendarviewbase.h>
44 44
45#include <ksyncmanager.h> 45#include <ksyncmanager.h>
46 46
47class QWidgetStack; 47class QWidgetStack;
48class QSplitter; 48class QSplitter;
49 49
50class CalPrinter; 50class CalPrinter;
51class KOFilterView; 51class KOFilterView;
52class KOViewManager; 52class KOViewManager;
53class KODialogManager; 53class KODialogManager;
54class KOTodoView; 54class KOTodoView;
55class KDateNavigator; 55class KDateNavigator;
56class DateNavigator; 56class DateNavigator;
57class KOIncidenceEditor; 57class KOIncidenceEditor;
58class KDatePicker; 58class KDatePicker;
59class ResourceView; 59class ResourceView;
60class KOEventEditor; 60class KOEventEditor;
61class KOTodoEditor ; 61class KOTodoEditor ;
62class KOEventViewerDialog; 62class KOEventViewerDialog;
63class KOBeamPrefs; 63class KOBeamPrefs;
64class KSyncProfile; 64class KSyncProfile;
65class AlarmDialog; 65class AlarmDialog;
66class KCal::Attendee; 66class KCal::Attendee;
67 67
68namespace KCal { class FileStorage; } 68namespace KCal { class FileStorage; }
69 69
70using namespace KCal; 70using namespace KCal;
71 71
72/** 72/**
73 This is the main calendar widget. It provides the different vies on t he 73 This is the main calendar widget. It provides the different vies on t he
74 calendar data as well as the date navigator. It also handles synchronisation 74 calendar data as well as the date navigator. It also handles synchronisation
75 of the different views and controls the different dialogs like preferences, 75 of the different views and controls the different dialogs like preferences,
76 event editor, search dialog etc. 76 event editor, search dialog etc.
77 77
78 @short main calendar view widget 78 @short main calendar view widget
79 @author Cornelius Schumacher 79 @author Cornelius Schumacher
80*/ 80*/
81class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface 81class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface
82{ 82{
83 Q_OBJECT 83 Q_OBJECT
84 public: 84 public:
85 /** 85 /**
86 Constructs a new calendar view widget. 86 Constructs a new calendar view widget.
87 87
88 @param calendar calendar document 88 @param calendar calendar document
89 @param parent parent window 89 @param parent parent window
90 @param name Qt internal widget object name 90 @param name Qt internal widget object name
91 */ 91 */
92 CalendarView( CalendarResources *calendar, QWidget *parent = 0, 92 CalendarView( CalendarResources *calendar, QWidget *parent = 0,
93 const char *name = 0 ); 93 const char *name = 0 );
94 CalendarView( Calendar *calendar, QWidget *parent = 0, 94 CalendarView( Calendar *calendar, QWidget *parent = 0,
95 const char *name = 0 ); 95 const char *name = 0 );
96 virtual ~CalendarView(); 96 virtual ~CalendarView();
97 97
98 Calendar *calendar() { return mCalendar; } 98 Calendar *calendar() { return mCalendar; }
99 99
100 KOViewManager *viewManager(); 100 KOViewManager *viewManager();
101 KODialogManager *dialogManager(); 101 KODialogManager *dialogManager();
102 102
103 QDate startDate(); 103 QDate startDate();
104 QDate endDate(); 104 QDate endDate();
105 105
106 QWidgetStack *viewStack(); 106 QWidgetStack *viewStack();
107 QWidget *leftFrame(); 107 QWidget *leftFrame();
108 108
109 DateNavigator *dateNavigator(); 109 DateNavigator *dateNavigator();
110 KDateNavigator *dateNavigatorWidget(); 110 KDateNavigator *dateNavigatorWidget();
111 111
112 void addView(KOrg::BaseView *); 112 void addView(KOrg::BaseView *);
113 void showView(KOrg::BaseView *); 113 void showView(KOrg::BaseView *);
114 KOEventViewerDialog* getEventViewerDialog(); 114 KOEventViewerDialog* getEventViewerDialog();
115 Incidence *currentSelection(); 115 Incidence *currentSelection();
116 116
117 signals: 117 signals:
118 void save (); 118 void save ();
119 void saveStopTimer (); 119 void saveStopTimer ();
120 void tempDisableBR(bool); 120 void tempDisableBR(bool);
121 /** This todo has been modified */ 121 /** This todo has been modified */
122 void todoModified(Todo *, int); 122 void todoModified(Todo *, int);
123 123
124 /** when change is made to options dialog, the topwidget will catch this 124 /** when change is made to options dialog, the topwidget will catch this
125 * and emit this signal which notifies all widgets which have registered 125 * and emit this signal which notifies all widgets which have registered
126 * for notification to update their settings. */ 126 * for notification to update their settings. */
127 void configChanged(); 127 void configChanged();
128 /** emitted when the topwidget is closing down, so that any attached 128 /** emitted when the topwidget is closing down, so that any attached
129 child windows can also close. */ 129 child windows can also close. */
130 void closingDown(); 130 void closingDown();
131 /** emitted right before we die */ 131 /** emitted right before we die */
132 void closed(QWidget *); 132 void closed(QWidget *);
133 133
134 /** Emitted when state of modified flag changes */ 134 /** Emitted when state of modified flag changes */
135 void modifiedChanged(bool); 135 void modifiedChanged(bool);
136 void signalmodified(); 136 void signalmodified();
137 137
138 /** Emitted when state of read-only flag changes */ 138 /** Emitted when state of read-only flag changes */
139 void readOnlyChanged(bool); 139 void readOnlyChanged(bool);
140 140
141 /** Emitted when the unit of navigation changes */ 141 /** Emitted when the unit of navigation changes */
142 void changeNavStringPrev(const QString &); 142 void changeNavStringPrev(const QString &);
143 void changeNavStringNext(const QString &); 143 void changeNavStringNext(const QString &);
144 144
145 /** Emitted when state of events selection has changed and user is organizer*/ 145 /** Emitted when state of events selection has changed and user is organizer*/
146 void organizerEventsSelected(bool); 146 void organizerEventsSelected(bool);
147 /** Emitted when state of events selection has changed and user is attendee*/ 147 /** Emitted when state of events selection has changed and user is attendee*/
148 void groupEventsSelected(bool); 148 void groupEventsSelected(bool);
149 /** 149 /**
150 Emitted when an incidence gets selected. If the selection is cleared the 150 Emitted when an incidence gets selected. If the selection is cleared the
151 signal is emitted with 0 as argument. 151 signal is emitted with 0 as argument.
152 */ 152 */
153 void incidenceSelected( Incidence * ); 153 void incidenceSelected( Incidence * );
154 /** Emitted, when a todoitem is selected or deselected. */ 154 /** Emitted, when a todoitem is selected or deselected. */
155 void todoSelected( bool ); 155 void todoSelected( bool );
156 156
157 /** 157 /**
158 Emitted, when clipboard content changes. Parameter indicates if paste 158 Emitted, when clipboard content changes. Parameter indicates if paste
159 is possible or not. 159 is possible or not.
160 */ 160 */
161 void pasteEnabled(bool); 161 void pasteEnabled(bool);
162 162
163 /** Emitted, when the number of incoming messages has changed. */ 163 /** Emitted, when the number of incoming messages has changed. */
164 void numIncomingChanged(int); 164 void numIncomingChanged(int);
165 165
166 /** Emitted, when the number of outgoing messages has changed. */ 166 /** Emitted, when the number of outgoing messages has changed. */
167 void numOutgoingChanged(int); 167 void numOutgoingChanged(int);
168 168
169 /** Send status message, which can e.g. be displayed in the status bar. */ 169 /** Send status message, which can e.g. be displayed in the status bar. */
170 void statusMessage(const QString &); 170 void statusMessage(const QString &);
171 171
172 void calendarViewExpanded( bool ); 172 void calendarViewExpanded( bool );
173 void updateSearchDialog(); 173 void updateSearchDialog();
174 174
175 175
176 public slots: 176 public slots:
177 void showOpenError(); 177 void showOpenError();
178 void watchSavedFile(); 178 void watchSavedFile();
179 void recheckTimerAlarm(); 179 void recheckTimerAlarm();
180 void checkNextTimerAlarm(); 180 void checkNextTimerAlarm();
181 void addAlarm(const QDateTime &qdt, const QString &noti ); 181 void addAlarm(const QDateTime &qdt, const QString &noti );
182 void addSuspendAlarm(const QDateTime &qdt, const QString &noti ); 182 void addSuspendAlarm(const QDateTime &qdt, const QString &noti );
183 void removeAlarm(const QDateTime &qdt, const QString &noti ); 183 void removeAlarm(const QDateTime &qdt, const QString &noti );
184 184
185 /** options dialog made a changed to the configuration. we catch this 185 /** options dialog made a changed to the configuration. we catch this
186 * and notify all widgets which need to update their configuration. */ 186 * and notify all widgets which need to update their configuration. */
187 void updateConfig(); 187 void updateConfig();
188 188
189 void insertBirthdays(const QString& uid, const QStringList& birthdayList, 189 void insertBirthdays(const QString& uid, const QStringList& birthdayList,
190 const QStringList& anniversaryList, const QStringList& realNameList, 190 const QStringList& anniversaryList, const QStringList& realNameList,
191 const QStringList& emailList, const QStringList& assembledNameList, 191 const QStringList& emailList, const QStringList& assembledNameList,
192 const QStringList& uidList); 192 const QStringList& uidList);
193 193
194 /** 194 /**
195 Load calendar from file \a filename. If \a merge is true, load 195 Load calendar from file \a filename. If \a merge is true, load
196 calendar into existing one, if it is false, clear calendar, before 196 calendar into existing one, if it is false, clear calendar, before
197 loading. Return true, if calendar could be successfully loaded. 197 loading. Return true, if calendar could be successfully loaded.
198 */ 198 */
199 bool openCalendar(QString filename, bool merge=false); 199 bool openCalendar(QString filename, bool merge=false);
200 bool syncCalendar(QString filename,int mode = 0 ); 200 bool syncCalendar(QString filename,int mode = 0 );
201 201
202 /** 202 /**
203 Save calendar data to file. Return true if calendar could be 203 Save calendar data to file. Return true if calendar could be
204 successfully saved. 204 successfully saved.
205 */ 205 */
206 bool saveCalendar(QString filename); 206 bool saveCalendar(QString filename);
207 207
208 /** 208 /**
209 Close calendar. Clear calendar data and reset views to display an empty 209 Close calendar. Clear calendar data and reset views to display an empty
210 calendar. 210 calendar.
211 */ 211 */
212 void closeCalendar(); 212 void closeCalendar();
213 213
214 /** Archive old events of calendar */ 214 /** Archive old events of calendar */
215 void archiveCalendar(); 215 void archiveCalendar();
216 216
217 void showIncidence(); 217 void showIncidence();
218 void editIncidence(); 218 void editIncidence();
219 void editIncidenceDescription(); 219 void editIncidenceDescription();
220 void deleteIncidence(); 220 void deleteIncidence();
221 void cloneIncidence(); 221 void cloneIncidence();
222 void moveIncidence(); 222 void moveIncidence();
223 void beamIncidence(); 223 void beamIncidence();
224 void toggleCancelIncidence(); 224 void toggleCancelIncidence();
225 225
226 /** create an editeventwin with supplied date/time, and if bool is true, 226 /** create an editeventwin with supplied date/time, and if bool is true,
227 * make the event take all day. */ 227 * make the event take all day. */
228 void newEvent(QDateTime, QDateTime, bool allDay ); 228 void newEvent(QDateTime, QDateTime, bool allDay );
229 void newEvent(QDateTime, QDateTime); 229 void newEvent(QDateTime, QDateTime);
230 void newEvent(QDateTime fh); 230 void newEvent(QDateTime fh);
231 void newEvent(QDate dt); 231 void newEvent(QDate dt);
232 /** create new event without having a date hint. Takes current date as 232 /** create new event without having a date hint. Takes current date as
233 default hint. */ 233 default hint. */
234 void newEvent(); 234 void newEvent();
235 void newFloatingEvent(); 235 void newFloatingEvent();
236 236
237 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ 237 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/
238 void showIncidence(Incidence *); 238 void showIncidence(Incidence *);
239 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ 239 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/
240 void editIncidence(Incidence *); 240 void editIncidence(Incidence *);
241 /** Delete the supplied incidence. It calls the correct deleteXXX method*/ 241 /** Delete the supplied incidence. It calls the correct deleteXXX method*/
242 void deleteIncidence(Incidence *); 242 void deleteIncidence(Incidence *);
243 void cloneIncidence(Incidence *); 243 void cloneIncidence(Incidence *);
244 void cancelIncidence(Incidence *); 244 void cancelIncidence(Incidence *);
245 /** Create an editor for the supplied event. */ 245 /** Create an editor for the supplied event. */
246 void editEvent(Event *); 246 void editEvent(Event *);
247 /** Delete the supplied event. */ 247 /** Delete the supplied event. */
248 void deleteEvent(Event *); 248 void deleteEvent(Event *);
249 /** Delete the event with the given unique ID. Returns false, if event wasn't 249 /** Delete the event with the given unique ID. Returns false, if event wasn't
250 found. */ 250 found. */
251 bool deleteEvent(const QString &uid); 251 bool deleteEvent(const QString &uid);
252 /** Create a read-only viewer dialog for the supplied event. */ 252 /** Create a read-only viewer dialog for the supplied event. */
253 void showEvent(Event *); 253 void showEvent(Event *);
254 254
255 void editJournal(Journal *); 255 void editJournal(Journal *);
256 void showJournal(Journal *); 256 void showJournal(Journal *);
257 void deleteJournal(Journal *); 257 void deleteJournal(Journal *);
258 /** Create an editor dialog for a todo */ 258 /** Create an editor dialog for a todo */
259 void editTodo(Todo *); 259 void editTodo(Todo *);
260 /** Create a read-only viewer dialog for the supplied todo */ 260 /** Create a read-only viewer dialog for the supplied todo */
261 void showTodo(Todo *); 261 void showTodo(Todo *);
262 /** create new todo */ 262 /** create new todo */
263 void newTodo(); 263 void newTodo();
264 void newTodoDateTime(QDateTime, bool allday); 264 void newTodoDateTime(QDateTime, bool allday);
265 /** create new todo with a parent todo */ 265 /** create new todo with a parent todo */
266 void newSubTodo(); 266 void newSubTodo();
267 /** create new todo with a parent todo */ 267 /** create new todo with a parent todo */
268 void newSubTodo(Todo *); 268 void newSubTodo(Todo *);
269 /** Delete todo */ 269 /** Delete todo */
270 void deleteTodo(Todo *); 270 void deleteTodo(Todo *);
271 271
272 272
273 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is 273 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is
274 * emitted as result. */ 274 * emitted as result. */
275 void checkClipboard(); 275 void checkClipboard();
276 276
277 /** using the KConfig associated with the kapp variable, read in the 277 /** using the KConfig associated with the kapp variable, read in the
278 * settings from the config file. 278 * settings from the config file.
279 */ 279 */
280 void readSettings(); 280 void readSettings();
281 281
282 /** write current state to config file. */ 282 /** write current state to config file. */
283 void writeSettings(); 283 void writeSettings();
284 284
285 /** read settings for calendar filters */ 285 /** read settings for calendar filters */
286 void readFilterSettings(KConfig *config); 286 void readFilterSettings(KConfig *config);
287 287
288 /** write settings for calendar filters */ 288 /** write settings for calendar filters */
289 void writeFilterSettings(KConfig *config); 289 void writeFilterSettings(KConfig *config);
290 290
291 /** passes on the message that an event has changed to the currently 291 /** passes on the message that an event has changed to the currently
292 * activated view so that it can make appropriate display changes. */ 292 * activated view so that it can make appropriate display changes. */
293 void changeEventDisplay(Event *, int); 293 void changeEventDisplay(Event *, int);
294 void changeIncidenceDisplay(Incidence *, int); 294 void changeIncidenceDisplay(Incidence *, int);
295 void changeTodoDisplay(Todo *, int); 295 void changeTodoDisplay(Todo *, int);
296 296
297 void eventAdded(Event *); 297 void eventAdded(Event *);
298 void eventChanged(Event *); 298 void eventChanged(Event *);
299 void eventToBeDeleted(Event *); 299 void eventToBeDeleted(Event *);
300 void eventDeleted(); 300 void eventDeleted();
301 301
302 void todoAdded(Todo *); 302 void todoAdded(Todo *);
303 void todoChanged(Todo *); 303 void todoChanged(Todo *);
304 void todoToBeDeleted(Todo *); 304 void todoToBeDeleted(Todo *);
305 void todoDeleted(); 305 void todoDeleted();
306 306
307 void updateView(const QDate &start, const QDate &end); 307 void updateView(const QDate &start, const QDate &end);
308 void updateView(); 308 void updateView();
309 309
310 /** Full update of visible todo views */ 310 /** Full update of visible todo views */
311 void updateTodoViews(); 311 void updateTodoViews();
312 312
313 void updateUnmanagedViews(); 313 void updateUnmanagedViews();
314 314
315 /** cut the current appointment to the clipboard */ 315 /** cut the current appointment to the clipboard */
316 void edit_cut(); 316 void edit_cut();
317 317
318 /** copy the current appointment(s) to the clipboard */ 318 /** copy the current appointment(s) to the clipboard */
319 void edit_copy(); 319 void edit_copy();
320 320
321 /** paste the current vobject(s) in the clipboard buffer into calendar */ 321 /** paste the current vobject(s) in the clipboard buffer into calendar */
322 void edit_paste(); 322 void edit_paste();
323 323
324 /** edit viewing and configuration options. */ 324 /** edit viewing and configuration options. */
325 void edit_options(); 325 void edit_options();
326 /** 326 /**
327 Functions for printing, previewing a print, and setting up printing 327 Functions for printing, previewing a print, and setting up printing
328 parameters. 328 parameters.
329 */ 329 */
330 void print(); 330 void print();
331 void printSetup(); 331 void printSetup();
332 void printPreview(); 332 void printPreview();
333 333
334 /** Export as iCalendar file */ 334 /** Export as iCalendar file */
335 void exportICalendar(); 335 void exportICalendar();
336 336
337 /** Export as vCalendar file */ 337 /** Export as vCalendar file */
338 bool exportVCalendar( QString fn); 338 bool exportVCalendar( QString fn);
339 339
340 /** pop up a dialog to show an existing appointment. */ 340 /** pop up a dialog to show an existing appointment. */
341 void appointment_show(); 341 void appointment_show();
342 /** 342 /**
343 * pop up an Appointment Dialog to edit an existing appointment.Get 343 * pop up an Appointment Dialog to edit an existing appointment.Get
344 * information on the appointment from the list of unique IDs that is 344 * information on the appointment from the list of unique IDs that is
345 * currently in the View, called currIds. 345 * currently in the View, called currIds.
346 */ 346 */
347 void appointment_edit(); 347 void appointment_edit();
348 /** 348 /**
349 * pop up dialog confirming deletion of currently selected event in the 349 * pop up dialog confirming deletion of currently selected event in the
350 * View. 350 * View.
351 */ 351 */
352 void appointment_delete(); 352 void appointment_delete();
353 353
354 /** mails the currently selected event to a particular user as a vCalendar 354 /** mails the currently selected event to a particular user as a vCalendar
355 attachment. */ 355 attachment. */
356 void action_mail(); 356 void action_mail();
357 357
358 /* frees a subtodo from it's relation */ 358 /* frees a subtodo from it's relation */
359 void todo_unsub( Todo * ); 359 void todo_unsub( Todo * );
360 void todo_resub( Todo * parent, Todo * sub ); 360 void todo_resub( Todo * parent, Todo * sub );
361 361
362 /** Take ownership of selected event. */ 362 /** Take ownership of selected event. */
363 void takeOverEvent(); 363 void takeOverEvent();
364 364
365 /** Take ownership of all events in calendar. */ 365 /** Take ownership of all events in calendar. */
366 void takeOverCalendar(); 366 void takeOverCalendar();
367 367
368 /** query whether or not the calendar is "dirty". */ 368 /** query whether or not the calendar is "dirty". */
369 bool isModified(); 369 bool isModified();
370 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ 370 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */
371 void setModified(bool modified=true); 371 void setModified(bool modified=true);
372 372
373 /** query if the calendar is read-only. */ 373 /** query if the calendar is read-only. */
374 bool isReadOnly(); 374 bool isReadOnly();
375 /** set state of calendar to read-only */ 375 /** set state of calendar to read-only */
376 void setReadOnly(bool readOnly=true); 376 void setReadOnly(bool readOnly=true);
377 377
378 void eventUpdated(Incidence *); 378 void eventUpdated(Incidence *);
379 379
380 /* iTIP scheduling actions */ 380 /* iTIP scheduling actions */
381 void schedule_publish(Incidence *incidence = 0); 381 void schedule_publish(Incidence *incidence = 0);
382 void schedule_request(Incidence *incidence = 0); 382 void schedule_request(Incidence *incidence = 0);
383 void schedule_refresh(Incidence *incidence = 0); 383 void schedule_refresh(Incidence *incidence = 0);
384 void schedule_cancel(Incidence *incidence = 0); 384 void schedule_cancel(Incidence *incidence = 0);
385 void schedule_add(Incidence *incidence = 0); 385 void schedule_add(Incidence *incidence = 0);
386 void schedule_reply(Incidence *incidence = 0); 386 void schedule_reply(Incidence *incidence = 0);
387 void schedule_counter(Incidence *incidence = 0); 387 void schedule_counter(Incidence *incidence = 0);
388 void schedule_declinecounter(Incidence *incidence = 0); 388 void schedule_declinecounter(Incidence *incidence = 0);
389 void schedule_publish_freebusy(int daysToPublish = 30); 389 void schedule_publish_freebusy(int daysToPublish = 30);
390 390
391 void openAddressbook(); 391 void openAddressbook();
392 392
393 void editFilters(); 393 void editFilters();
394 void toggleFilerEnabled(); 394 void toggleFilerEnabled();
395 QPtrList<CalFilter> filters(); 395 QPtrList<CalFilter> filters();
396 void toggleFilter(); 396 void toggleFilter();
397 void showFilter(bool visible); 397 void showFilter(bool visible);
398 void updateFilter(); 398 void updateFilter();
399 void filterEdited(); 399 void filterEdited();
400 void selectFilter( int ); 400 void selectFilter( int );
401 KOFilterView *filterView(); 401 KOFilterView *filterView();
402 402
403 void showIntro(); 403 void showIntro();
404 404
405 /** Move the curdatepient view date to today */ 405 /** Move the curdatepient view date to today */
406 void goToday(); 406 void goToday();
407 407
408 /** Move to the next date(s) in the current view */ 408 /** Move to the next date(s) in the current view */
409 void goNext(); 409 void goNext();
410 410
411 /** Move to the previous date(s) in the current view */ 411 /** Move to the previous date(s) in the current view */
412 void goPrevious(); 412 void goPrevious();
413 /** Move to the next date(s) in the current view */ 413 /** Move to the next date(s) in the current view */
414 void goNextMonth(); 414 void goNextMonth();
415 415
416 /** Move to the previous date(s) in the current view */ 416 /** Move to the previous date(s) in the current view */
417 void goPreviousMonth(); 417 void goPreviousMonth();
418 418
419 void toggleExpand(); 419 void toggleExpand();
420 void toggleDateNavigatorWidget(); 420 void toggleDateNavigatorWidget();
421 void toggleAllDaySize(); 421 void toggleAllDaySize();
422 void dialogClosing(Incidence *); 422 void dialogClosing(Incidence *);
423 423
424 /** Look for new messages in the inbox */ 424 /** Look for new messages in the inbox */
425 void lookForIncomingMessages(); 425 void lookForIncomingMessages();
426 /** Look for new messages in the outbox */ 426 /** Look for new messages in the outbox */
427 void lookForOutgoingMessages(); 427 void lookForOutgoingMessages();
428 428
429 void processMainViewSelection( Incidence * ); 429 void processMainViewSelection( Incidence * );
430 void processTodoListSelection( Incidence * ); 430 void processTodoListSelection( Incidence * );
431 431
432 void processIncidenceSelection( Incidence * ); 432 void processIncidenceSelection( Incidence * );
433 433
434 void purgeCompleted(); 434 void purgeCompleted();
435 bool removeCompletedSubTodos( Todo* ); 435 bool removeCompletedSubTodos( Todo* );
436 void slotCalendarChanged(); 436 void slotCalendarChanged();
437 bool importBday(); 437 bool importBday();
438 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); 438 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday );
439 bool importQtopia( const QString &categoriesFile, 439 bool importQtopia( const QString &categoriesFile,
440 const QString &datebookFile, 440 const QString &datebookFile,
441 const QString &tasklistFile ); 441 const QString &tasklistFile );
442 void syncExternal( int mode ); 442 void syncExternal( int mode );
443 void slotSelectPickerDate( QDate ) ; 443 void slotSelectPickerDate( QDate ) ;
444 void showDatePicker( ) ; 444 void showDatePicker() ;
445 void showDatePickerPopup() ;
445 void moveIncidence(Incidence *) ; 446 void moveIncidence(Incidence *) ;
446 void beamIncidence(Incidence *) ; 447 void beamIncidence(Incidence *) ;
447 void beamCalendar() ; 448 void beamCalendar() ;
448 void beamFilteredCalendar() ; 449 void beamFilteredCalendar() ;
449 void beamIncidenceList(QPtrList<Incidence>) ; 450 void beamIncidenceList(QPtrList<Incidence>) ;
450 void manageCategories(); 451 void manageCategories();
451 int addCategories(); 452 int addCategories();
452 void removeCategories(); 453 void removeCategories();
453 void setSyncDevice( QString ); 454 void setSyncDevice( QString );
454 void setSyncName( QString ); 455 void setSyncName( QString );
455 void showDay( QDate ); 456 void showDay( QDate );
456 void undo_delete(); 457 void undo_delete();
457 protected slots: 458 protected slots:
458 void timerAlarm(); 459 void timerAlarm();
459 void suspendAlarm(); 460 void suspendAlarm();
460 void beamDone( Ir *ir ); 461 void beamDone( Ir *ir );
461 /** Select a view or adapt the current view to display the specified dates. */ 462 /** Select a view or adapt the current view to display the specified dates. */
462 void showDates( const KCal::DateList & ); 463 void showDates( const KCal::DateList & );
463 void selectWeekNum ( int ); 464 void selectWeekNum ( int );
464 465
465 public: 466 public:
466 // show a standard warning 467 // show a standard warning
467 // returns KMsgBox::yesNoCancel() 468 // returns KMsgBox::yesNoCancel()
468 int msgCalModified(); 469 int msgCalModified();
469 virtual bool sync(KSyncManager* manager, QString filename, int mode); 470 virtual bool sync(KSyncManager* manager, QString filename, int mode);
470 471
471 virtual bool syncExternal(KSyncManager* manager, QString resource); 472 virtual bool syncExternal(KSyncManager* manager, QString resource);
472 virtual void removeSyncInfo( QString syncProfile); 473 virtual void removeSyncInfo( QString syncProfile);
473 void setSyncManager(KSyncManager* manager); 474 void setSyncManager(KSyncManager* manager);
474 void setLoadedFileVersion(QDateTime); 475 void setLoadedFileVersion(QDateTime);
475 bool checkFileVersion(QString fn); 476 bool checkFileVersion(QString fn);
476 bool checkFileChanged(QString fn); 477 bool checkFileChanged(QString fn);
477 Event* getLastSyncEvent(); 478 Event* getLastSyncEvent();
478 /** Adapt navigation units correpsonding to step size of navigation of the 479 /** Adapt navigation units correpsonding to step size of navigation of the
479 * current view. 480 * current view.
480 */ 481 */
481 void adaptNavigationUnits(); 482 void adaptNavigationUnits();
482 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); 483 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode );
483 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); 484 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false );
484 //Attendee* getYourAttendee(Event *event); 485 //Attendee* getYourAttendee(Event *event);
485 void setBlockShowDates( bool b ) { mBlockShowDates = b ;} 486 void setBlockShowDates( bool b ) { mBlockShowDates = b ;}
486 protected: 487 protected:
487 void schedule(Scheduler::Method, Incidence *incidence = 0); 488 void schedule(Scheduler::Method, Incidence *incidence = 0);
488 489
489 // returns KMsgBox::OKCandel() 490 // returns KMsgBox::OKCandel()
490 int msgItemDelete(const QString name); 491 int msgItemDelete(const QString name);
491 void showEventEditor(); 492 void showEventEditor();
492 void showTodoEditor(); 493 void showTodoEditor();
493 void writeLocale(); 494 void writeLocale();
494 Todo *selectedTodo(); 495 Todo *selectedTodo();
495 496
496 private: 497 private:
497 bool mBlockShowDates; 498 bool mBlockShowDates;
498 KSyncManager* mSyncManager; 499 KSyncManager* mSyncManager;
499 AlarmDialog * mAlarmDialog; 500 AlarmDialog * mAlarmDialog;
500 QString mAlarmNotification; 501 QString mAlarmNotification;
501 QString mSuspendAlarmNotification; 502 QString mSuspendAlarmNotification;
502 QTimer* mSuspendTimer; 503 QTimer* mSuspendTimer;
503 QTimer* mAlarmTimer; 504 QTimer* mAlarmTimer;
504 QTimer* mRecheckAlarmTimer; 505 QTimer* mRecheckAlarmTimer;
505 void computeAlarm( QString ); 506 void computeAlarm( QString );
506 void startAlarm( QString, QString ); 507 void startAlarm( QString, QString );
507 void setSyncEventsReadOnly(); 508 void setSyncEventsReadOnly();
508 509
509 QDateTime loadedFileVersion; 510 QDateTime loadedFileVersion;
510 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); 511 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete );
511 void checkExternalId( Incidence * inc ); 512 void checkExternalId( Incidence * inc );
512 int mGlobalSyncMode; 513 int mGlobalSyncMode;
513 QString mCurrentSyncDevice; 514 QString mCurrentSyncDevice;
514 QString mCurrentSyncName; 515 QString mCurrentSyncName;
515 KOBeamPrefs* beamDialog; 516 KOBeamPrefs* beamDialog;
516 void init(); 517 void init();
517 int mDatePickerMode; 518 int mDatePickerMode;
518 bool mFlagEditDescription; 519 bool mFlagEditDescription;
519 QDateTime mLastCalendarSync; 520 QDateTime mLastCalendarSync;
520 void createPrinter(); 521 void createPrinter();
521 522
522 void calendarModified( bool, Calendar * ); 523 void calendarModified( bool, Calendar * );
523 524
524 CalPrinter *mCalPrinter; 525 CalPrinter *mCalPrinter;
525 526
526 QSplitter *mPanner; 527 QSplitter *mPanner;
527 QSplitter *mLeftSplitter; 528 QSplitter *mLeftSplitter;
528 QWidget *mLeftFrame; 529 QWidget *mLeftFrame;
529 QWidgetStack *mRightFrame; 530 QWidgetStack *mRightFrame;
530 531
531 KDatePicker* mDatePicker; 532 KDatePicker* mDatePicker;
532 QVBox* mDateFrame; 533 QVBox* mDateFrame;
533 534
534 KDateNavigator *mDateNavigator; // widget showing small month view. 535 KDateNavigator *mDateNavigator; // widget showing small month view.
535 536
536 KOFilterView *mFilterView; 537 KOFilterView *mFilterView;
537 538
538 ResourceView *mResourceView; 539 ResourceView *mResourceView;
539 540
540 // calendar object for this viewing instance 541 // calendar object for this viewing instance
541 Calendar *mCalendar; 542 Calendar *mCalendar;
542 543
543 CalendarResourceManager *mResourceManager; 544 CalendarResourceManager *mResourceManager;
544 545
545 FileStorage *mStorage; 546 FileStorage *mStorage;
546 547
547 DateNavigator *mNavigator; 548 DateNavigator *mNavigator;
548 549
549 KOViewManager *mViewManager; 550 KOViewManager *mViewManager;
550 KODialogManager *mDialogManager; 551 KODialogManager *mDialogManager;
551 552
552 // Calendar filters 553 // Calendar filters
553 QPtrList<CalFilter> mFilters; 554 QPtrList<CalFilter> mFilters;
554 555
555 // various housekeeping variables. 556 // various housekeeping variables.
556 bool mModified; // flag indicating if calendar is modified 557 bool mModified; // flag indicating if calendar is modified
557 bool mReadOnly; // flag indicating if calendar is read-only 558 bool mReadOnly; // flag indicating if calendar is read-only
558 QDate mSaveSingleDate; 559 QDate mSaveSingleDate;
559 560
560 Incidence *mSelectedIncidence; 561 Incidence *mSelectedIncidence;
561 Incidence *mMoveIncidence; 562 Incidence *mMoveIncidence;
562 QDate mMoveIncidenceOldDate; 563 QDate mMoveIncidenceOldDate;
563 KOTodoView *mTodoList; 564 KOTodoView *mTodoList;
564 KOEventEditor * mEventEditor; 565 KOEventEditor * mEventEditor;
565 KOTodoEditor * mTodoEditor; 566 KOTodoEditor * mTodoEditor;
566 KOEventViewerDialog * mEventViewerDialog; 567 KOEventViewerDialog * mEventViewerDialog;
567 void keyPressEvent ( QKeyEvent *e) ; 568 void keyPressEvent ( QKeyEvent *e) ;
568 //QMap<Incidence*,KOIncidenceEditor*> mDialogList; 569 //QMap<Incidence*,KOIncidenceEditor*> mDialogList;
569}; 570};
570 571
571 572
572class CalendarViewVisitor : public Incidence::Visitor 573class CalendarViewVisitor : public Incidence::Visitor
573{ 574{
574 public: 575 public:
575 CalendarViewVisitor() : mView( 0 ) {} 576 CalendarViewVisitor() : mView( 0 ) {}
576 577
577 bool act( Incidence *incidence, CalendarView *view ) 578 bool act( Incidence *incidence, CalendarView *view )
578 { 579 {
579 mView = view; 580 mView = view;
580 return incidence->accept( *this ); 581 return incidence->accept( *this );
581 } 582 }
582 583
583 protected: 584 protected:
584 CalendarView *mView; 585 CalendarView *mView;
585}; 586};
586 587
587class ShowIncidenceVisitor : public CalendarViewVisitor 588class ShowIncidenceVisitor : public CalendarViewVisitor
588{ 589{
589 protected: 590 protected:
590 bool visit( Event *event ) { mView->showEvent( event ); return true; } 591 bool visit( Event *event ) { mView->showEvent( event ); return true; }
591 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } 592 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; }
592 bool visit( Journal * j ) { mView->showJournal( j );return true; } 593 bool visit( Journal * j ) { mView->showJournal( j );return true; }
593}; 594};
594 595
595class EditIncidenceVisitor : public CalendarViewVisitor 596class EditIncidenceVisitor : public CalendarViewVisitor
596{ 597{
597 protected: 598 protected:
598 bool visit( Event *event ) { mView->editEvent( event ); return true; } 599 bool visit( Event *event ) { mView->editEvent( event ); return true; }
599 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } 600 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; }
600 bool visit( Journal *j ) { mView->editJournal( j); return true; } 601 bool visit( Journal *j ) { mView->editJournal( j); return true; }
601}; 602};
602 603
603class DeleteIncidenceVisitor : public CalendarViewVisitor 604class DeleteIncidenceVisitor : public CalendarViewVisitor
604{ 605{
605 protected: 606 protected:
606 bool visit( Event *event ) { mView->deleteEvent( event ); return true; } 607 bool visit( Event *event ) { mView->deleteEvent( event ); return true; }
607 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } 608 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; }
608 bool visit( Journal * j) {mView->deleteJournal( j ); return true; } 609 bool visit( Journal * j) {mView->deleteJournal( j ); return true; }
609}; 610};
610 611
611#endif 612#endif
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 6ae4c6f..02d2585 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -1,1600 +1,1603 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#include <qpopupmenu.h> 20#include <qpopupmenu.h>
21#include <qfont.h> 21#include <qfont.h>
22#include <qfontmetrics.h> 22#include <qfontmetrics.h>
23#include <qkeycode.h> 23#include <qkeycode.h>
24#include <qhbox.h> 24#include <qhbox.h>
25#include <qvbox.h> 25#include <qvbox.h>
26#include <qwidgetstack.h> 26#include <qwidgetstack.h>
27#include <qpushbutton.h> 27#include <qpushbutton.h>
28#include <qtooltip.h> 28#include <qtooltip.h>
29#include <qpainter.h> 29#include <qpainter.h>
30#include <qtimer.h> 30#include <qtimer.h>
31#include <qwhatsthis.h> 31#include <qwhatsthis.h>
32#ifndef DESKTOP_VERSION 32#ifndef DESKTOP_VERSION
33#include <qpe/qpeapplication.h> 33#include <qpe/qpeapplication.h>
34#else 34#else
35#include <qapplication.h> 35#include <qapplication.h>
36#endif 36#endif
37 37
38#include <kdebug.h> 38#include <kdebug.h>
39#include <klocale.h> 39#include <klocale.h>
40#include <kglobal.h> 40#include <kglobal.h>
41#include <kconfig.h> 41#include <kconfig.h>
42#include <kiconloader.h> 42#include <kiconloader.h>
43 43
44#include <kcalendarsystem.h> 44#include <kcalendarsystem.h>
45 45
46#ifndef KORG_NOPRINTER 46#ifndef KORG_NOPRINTER
47#include "calprinter.h" 47#include "calprinter.h"
48#endif 48#endif
49#include "koprefs.h" 49#include "koprefs.h"
50#ifndef KORG_NOPLUGINS 50#ifndef KORG_NOPLUGINS
51#include "kocore.h" 51#include "kocore.h"
52#endif 52#endif
53#include "koglobals.h" 53#include "koglobals.h"
54#include <libkcal/kincidenceformatter.h> 54#include <libkcal/kincidenceformatter.h>
55 55
56#include "komonthview.h" 56#include "komonthview.h"
57 57
58#define PIXMAP_SIZE 5 58#define PIXMAP_SIZE 5
59#ifdef DESKTOP_VERSION 59#ifdef DESKTOP_VERSION
60QToolTipGroup *MonthViewCell::mToolTipGroup = 0; 60QToolTipGroup *MonthViewCell::mToolTipGroup = 0;
61#endif 61#endif
62class KNOWhatsThis :public QWhatsThis 62class KNOWhatsThis :public QWhatsThis
63{ 63{
64public: 64public:
65 KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; 65 KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { };
66 //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; 66 //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); };
67 67
68protected: 68protected:
69 virtual QString text( const QPoint& p) 69 virtual QString text( const QPoint& p)
70 { 70 {
71 return _wid->getWhatsThisText(p) ; 71 return _wid->getWhatsThisText(p) ;
72 }; 72 };
73private: 73private:
74 KNoScrollListBox* _wid; 74 KNoScrollListBox* _wid;
75 75
76}; 76};
77 77
78 78
79KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) 79KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name)
80 : QListBox(parent, name, WRepaintNoErase) 80 : QListBox(parent, name, WRepaintNoErase)
81{ 81{
82#ifndef DESKTOP_VERSION 82#ifndef DESKTOP_VERSION
83 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 83 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
84#endif 84#endif
85 mWT = new KNOWhatsThis(this); 85 mWT = new KNOWhatsThis(this);
86} 86}
87KNoScrollListBox::~KNoScrollListBox() 87KNoScrollListBox::~KNoScrollListBox()
88{ 88{
89 89
90} 90}
91QString KNoScrollListBox::getWhatsThisText(QPoint p) 91QString KNoScrollListBox::getWhatsThisText(QPoint p)
92{ 92{
93 QListBoxItem* item = itemAt ( p ); 93 QListBoxItem* item = itemAt ( p );
94 if ( ! item ) { 94 if ( ! item ) {
95 return i18n("Click in the cell\nto add an event!"); 95 return i18n("Click in the cell\nto add an event!");
96 } 96 }
97 return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence()); 97 return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence());
98} 98}
99void KNoScrollListBox::keyPressEvent(QKeyEvent *e) 99void KNoScrollListBox::keyPressEvent(QKeyEvent *e)
100{ 100{
101 101
102 switch(e->key()) { 102 switch(e->key()) {
103 case Key_Right: 103 case Key_Right:
104 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 104 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
105 { 105 {
106 e->ignore(); 106 e->ignore();
107 return; 107 return;
108 } 108 }
109 scrollBy(10,0); 109 scrollBy(10,0);
110 break; 110 break;
111 case Key_Left: 111 case Key_Left:
112 if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 112 if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
113 { 113 {
114 e->ignore(); 114 e->ignore();
115 return; 115 return;
116 } 116 }
117 scrollBy(-10,0); 117 scrollBy(-10,0);
118 break; 118 break;
119 case Key_Up: 119 case Key_Up:
120 if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { 120 if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) {
121 e->ignore(); 121 e->ignore();
122 break; 122 break;
123 } 123 }
124 setCurrentItem((currentItem()+count()-1)%count()); 124 setCurrentItem((currentItem()+count()-1)%count());
125 if(!itemVisible(currentItem())) { 125 if(!itemVisible(currentItem())) {
126 if((unsigned int) currentItem() == (count()-1)) { 126 if((unsigned int) currentItem() == (count()-1)) {
127 setTopItem(currentItem()-numItemsVisible()+1); 127 setTopItem(currentItem()-numItemsVisible()+1);
128 } else { 128 } else {
129 setTopItem(topItem()-1); 129 setTopItem(topItem()-1);
130 } 130 }
131 } 131 }
132 break; 132 break;
133 case Key_Down: 133 case Key_Down:
134 if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { 134 if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) {
135 e->ignore(); 135 e->ignore();
136 break; 136 break;
137 } 137 }
138 setCurrentItem((currentItem()+1)%count()); 138 setCurrentItem((currentItem()+1)%count());
139 if(!itemVisible(currentItem())) { 139 if(!itemVisible(currentItem())) {
140 if(currentItem() == 0) { 140 if(currentItem() == 0) {
141 setTopItem(0); 141 setTopItem(0);
142 } else { 142 } else {
143 setTopItem(topItem()+1); 143 setTopItem(topItem()+1);
144 } 144 }
145 } 145 }
146 break; 146 break;
147 case Key_I: 147 case Key_I:
148 QTimer::singleShot( 11, this, SLOT ( oneDown() ) ); 148 QTimer::singleShot( 11, this, SLOT ( oneDown() ) );
149 e->ignore(); 149 e->ignore();
150 break; 150 break;
151 case Key_Shift: 151 case Key_Shift:
152 emit shiftDown(); 152 emit shiftDown();
153 break; 153 break;
154 default: 154 default:
155 e->ignore(); 155 e->ignore();
156 break; 156 break;
157 } 157 }
158} 158}
159 159
160void KNoScrollListBox::oneDown() 160void KNoScrollListBox::oneDown()
161{ 161{
162 setCurrentItem((currentItem()+1)%count()); 162 setCurrentItem((currentItem()+1)%count());
163 if(!itemVisible(currentItem())) { 163 if(!itemVisible(currentItem())) {
164 if(currentItem() == 0) { 164 if(currentItem() == 0) {
165 setTopItem(0); 165 setTopItem(0);
166 } else { 166 } else {
167 setTopItem(topItem()+1); 167 setTopItem(topItem()+1);
168 } 168 }
169 } 169 }
170} 170}
171void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) 171void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e)
172{ 172{
173 switch(e->key()) { 173 switch(e->key()) {
174 case Key_Shift: 174 case Key_Shift:
175 emit shiftUp(); 175 emit shiftUp();
176 break; 176 break;
177 default: 177 default:
178 break; 178 break;
179 } 179 }
180} 180}
181 181
182void KNoScrollListBox::mousePressEvent(QMouseEvent *e) 182void KNoScrollListBox::mousePressEvent(QMouseEvent *e)
183{ 183{
184 QListBox::mousePressEvent(e); 184 QListBox::mousePressEvent(e);
185 185
186 if(e->button() == RightButton) { 186 if(e->button() == RightButton) {
187 emit rightClick(); 187 emit rightClick();
188 } 188 }
189} 189}
190 190
191MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) 191MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s)
192 : QListBoxItem() 192 : QListBoxItem()
193{ 193{
194 setText( s ); 194 setText( s );
195 195
196 mIncidence = incidence; 196 mIncidence = incidence;
197 mDate = qd; 197 mDate = qd;
198 // QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence )); 198 // QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence ));
199 mRecur = false; 199 mRecur = false;
200 mAlarm = false; 200 mAlarm = false;
201 mReply = false; 201 mReply = false;
202 mInfo = false; 202 mInfo = false;
203} 203}
204 204
205void MonthViewItem::paint(QPainter *p) 205void MonthViewItem::paint(QPainter *p)
206{ 206{
207#if QT_VERSION >= 0x030000 207#if QT_VERSION >= 0x030000
208 bool sel = isSelected(); 208 bool sel = isSelected();
209#else 209#else
210 bool sel = selected(); 210 bool sel = selected();
211#endif 211#endif
212 212
213 213
214 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) 214 if (KOPrefs::instance()->mMonthViewUsesCategoryColor)
215 { 215 {
216 p->setBackgroundColor( palette().color( QPalette::Normal, \ 216 p->setBackgroundColor( palette().color( QPalette::Normal, \
217 sel ? QColorGroup::Highlight : QColorGroup::Background ) ); 217 sel ? QColorGroup::Highlight : QColorGroup::Background ) );
218 p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); 218 p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) );
219 } 219 }
220 int x = 1; 220 int x = 1;
221 int y = 3;//(height() - mRecurPixmap.height()) /2; 221 int y = 3;//(height() - mRecurPixmap.height()) /2;
222 int size = PIXMAP_SIZE; 222 int size = PIXMAP_SIZE;
223 if ( QApplication::desktop()->width() < 300 ) 223 if ( QApplication::desktop()->width() < 300 )
224 size = 3; 224 size = 3;
225 if ( KOPrefs::instance()->mMonthShowIcons ) { 225 if ( KOPrefs::instance()->mMonthShowIcons ) {
226 if ( mInfo ) { 226 if ( mInfo ) {
227 p->fillRect ( x, y,size,size, Qt::darkGreen ); 227 p->fillRect ( x, y,size,size, Qt::darkGreen );
228 x += size + 1; 228 x += size + 1;
229 } 229 }
230 if ( mRecur ) { 230 if ( mRecur ) {
231 p->fillRect ( x, y,size,size, Qt::blue ); 231 p->fillRect ( x, y,size,size, Qt::blue );
232 x += size + 1; 232 x += size + 1;
233 } 233 }
234 if ( mAlarm ) { 234 if ( mAlarm ) {
235 p->fillRect ( x, y,size,size, Qt::red ); 235 p->fillRect ( x, y,size,size, Qt::red );
236 x += size + 1; 236 x += size + 1;
237 } 237 }
238 if ( mReply ) { 238 if ( mReply ) {
239 p->fillRect ( x, y,size,size, Qt::yellow ); 239 p->fillRect ( x, y,size,size, Qt::yellow );
240 x += size + 1; 240 x += size + 1;
241 } 241 }
242 } 242 }
243 QFontMetrics fm = p->fontMetrics(); 243 QFontMetrics fm = p->fontMetrics();
244 int yPos; 244 int yPos;
245 int pmheight = size; 245 int pmheight = size;
246 if( pmheight < fm.height() ) 246 if( pmheight < fm.height() )
247 yPos = fm.ascent() + fm.leading()/2; 247 yPos = fm.ascent() + fm.leading()/2;
248 else 248 else
249 yPos = pmheight/2 - fm.height()/2 + fm.ascent(); 249 yPos = pmheight/2 - fm.height()/2 + fm.ascent();
250 p->setPen( palette().color( QPalette::Normal, sel ? \ 250 p->setPen( palette().color( QPalette::Normal, sel ? \
251 QColorGroup::HighlightedText : QColorGroup::Foreground ) ); 251 QColorGroup::HighlightedText : QColorGroup::Foreground ) );
252 p->drawText( x, yPos, text() ); 252 p->drawText( x, yPos, text() );
253 if ( mIncidence->cancelled() ) { 253 if ( mIncidence->cancelled() ) {
254 int wid = fm.width( text() ); 254 int wid = fm.width( text() );
255 p->drawLine( x, yPos- fm.height()/2+3,x+wid, yPos- fm.height()/2 +3); 255 p->drawLine( x, yPos- fm.height()/2+3,x+wid, yPos- fm.height()/2 +3);
256 } 256 }
257 257
258} 258}
259 259
260int MonthViewItem::height(const QListBox *lb) const 260int MonthViewItem::height(const QListBox *lb) const
261{ 261{
262 return lb->fontMetrics().lineSpacing()+1; 262 return lb->fontMetrics().lineSpacing()+1;
263} 263}
264 264
265int MonthViewItem::width(const QListBox *lb) const 265int MonthViewItem::width(const QListBox *lb) const
266{ 266{
267 int size = PIXMAP_SIZE; 267 int size = PIXMAP_SIZE;
268 if ( QApplication::desktop()->width() < 300 ) 268 if ( QApplication::desktop()->width() < 300 )
269 size = 3; 269 size = 3;
270 int x = 1; 270 int x = 1;
271 if ( mInfo ) { 271 if ( mInfo ) {
272 x += size + 1; 272 x += size + 1;
273 } 273 }
274 if( mRecur ) { 274 if( mRecur ) {
275 x += size+1; 275 x += size+1;
276 } 276 }
277 if( mAlarm ) { 277 if( mAlarm ) {
278 x += size+1; 278 x += size+1;
279 } 279 }
280 if( mReply ) { 280 if( mReply ) {
281 x += size+1; 281 x += size+1;
282 } 282 }
283 283
284 return( x + lb->fontMetrics().width( text() ) + 1 ); 284 return( x + lb->fontMetrics().width( text() ) + 1 );
285} 285}
286 286
287 287
288MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) 288MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par )
289 : QWidget( par ), 289 : QWidget( par ),
290 mMonthView( parent ) 290 mMonthView( parent )
291{ 291{
292 292
293 QVBoxLayout *topLayout = new QVBoxLayout( this ); 293 QVBoxLayout *topLayout = new QVBoxLayout( this );
294 294
295 // mLabel = new QLabel( this );QPushButton 295 // mLabel = new QLabel( this );QPushButton
296 mLabel = new QPushButton( this ); 296 mLabel = new QPushButton( this );
297 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); 297 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain );
298 //mLabel->setLineWidth( 1 ); 298 //mLabel->setLineWidth( 1 );
299 //mLabel->setAlignment( AlignCenter ); 299 //mLabel->setAlignment( AlignCenter );
300 mLabel->setFlat( true ); 300 mLabel->setFlat( true );
301 mLabel->setFocusPolicy(NoFocus); 301 mLabel->setFocusPolicy(NoFocus);
302 mItemList = new KNoScrollListBox( this ); 302 mItemList = new KNoScrollListBox( this );
303 mItemList->setMinimumSize( 10, 10 ); 303 mItemList->setMinimumSize( 10, 10 );
304 mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain ); 304 mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain );
305 mItemList->setLineWidth( 1 ); 305 mItemList->setLineWidth( 1 );
306 topLayout->addWidget( mItemList ); 306 topLayout->addWidget( mItemList );
307 mLabel->raise(); 307 mLabel->raise();
308 // QColor( 0,0,255 ) QColor( 160,1600,255 ) 308 // QColor( 0,0,255 ) QColor( 160,1600,255 )
309 mStandardPalette = palette(); 309 mStandardPalette = palette();
310 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); 310 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) );
311 311
312 enableScrollBars( false ); 312 enableScrollBars( false );
313 updateConfig(); 313 updateConfig();
314 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); 314 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() ));
315 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); 315 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() ));
316 connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ), 316 connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ),
317 SLOT( defaultAction( QListBoxItem * ) ) ); 317 SLOT( defaultAction( QListBoxItem * ) ) );
318 connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *, 318 connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *,
319 const QPoint &) ), 319 const QPoint &) ),
320 SLOT( contextMenu( QListBoxItem * ) ) ); 320 SLOT( contextMenu( QListBoxItem * ) ) );
321 connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ), 321 connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ),
322 SLOT( selection( QListBoxItem * ) ) ); 322 SLOT( selection( QListBoxItem * ) ) );
323 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), 323 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ),
324 SLOT( cellClicked( QListBoxItem * ) ) ); 324 SLOT( cellClicked( QListBoxItem * ) ) );
325 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), 325 connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ),
326 SLOT( selection( QListBoxItem * ) ) ); 326 SLOT( selection( QListBoxItem * ) ) );
327} 327}
328#ifdef DESKTOP_VERSION 328#ifdef DESKTOP_VERSION
329QToolTipGroup *MonthViewCell::toolTipGroup() 329QToolTipGroup *MonthViewCell::toolTipGroup()
330{ 330{
331 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); 331 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0);
332 return mToolTipGroup; 332 return mToolTipGroup;
333} 333}
334#endif 334#endif
335 335
336void MonthViewCell::setDate( const QDate &date ) 336void MonthViewCell::setDate( const QDate &date )
337{ 337{
338 // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; 338 // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl;
339 mDate = date; 339 mDate = date;
340 340
341 341
342 342
343 //resizeEvent( 0 ); 343 //resizeEvent( 0 );
344} 344}
345 345
346QDate MonthViewCell::date() const 346QDate MonthViewCell::date() const
347{ 347{
348 return mDate; 348 return mDate;
349} 349}
350 350
351void MonthViewCell::setPrimary( bool primary ) 351void MonthViewCell::setPrimary( bool primary )
352{ 352{
353 mPrimary = primary; 353 mPrimary = primary;
354 //setMyPalette(); 354 //setMyPalette();
355} 355}
356void MonthViewCell::setMyPalette() 356void MonthViewCell::setMyPalette()
357{ 357{
358 358
359 if ( mHoliday) { 359 if ( mHoliday) {
360 setPalette( mHolidayPalette ); 360 setPalette( mHolidayPalette );
361 } else { 361 } else {
362 if ( mPrimary ) { 362 if ( mPrimary ) {
363 setPalette( mPrimaryPalette ); 363 setPalette( mPrimaryPalette );
364 } else { 364 } else {
365 setPalette( mNonPrimaryPalette ); 365 setPalette( mNonPrimaryPalette );
366 } 366 }
367 } 367 }
368 QPalette pal = palette(); 368 QPalette pal = palette();
369 369
370 mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); 370 mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) ));
371} 371}
372QPalette MonthViewCell::getPalette () 372QPalette MonthViewCell::getPalette ()
373{ 373{
374 if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) 374 if ( !KOPrefs::instance()->mMonthViewUsesDayColors )
375 return mStandardPalette; 375 return mStandardPalette;
376 if ( mHoliday) { 376 if ( mHoliday) {
377 return mHolidayPalette ; 377 return mHolidayPalette ;
378 } else { 378 } else {
379 if ( mPrimary ) { 379 if ( mPrimary ) {
380 return mPrimaryPalette ; 380 return mPrimaryPalette ;
381 } 381 }
382 } 382 }
383 return mNonPrimaryPalette; 383 return mNonPrimaryPalette;
384} 384}
385bool MonthViewCell::isPrimary() const 385bool MonthViewCell::isPrimary() const
386{ 386{
387 return mPrimary; 387 return mPrimary;
388} 388}
389 389
390void MonthViewCell::setHoliday( bool holiday ) 390void MonthViewCell::setHoliday( bool holiday )
391{ 391{
392 mHoliday = holiday; 392 mHoliday = holiday;
393 //setMyPalette(); 393 //setMyPalette();
394} 394}
395 395
396void MonthViewCell::setHoliday( const QString &holiday ) 396void MonthViewCell::setHoliday( const QString &holiday )
397{ 397{
398 mHolidayString = holiday; 398 mHolidayString = holiday;
399 399
400 if ( !holiday.isEmpty() ) { 400 if ( !holiday.isEmpty() ) {
401 setHoliday( true ); 401 setHoliday( true );
402 } 402 }
403} 403}
404void MonthViewCell::keyPressEvent ( QKeyEvent * e ) 404void MonthViewCell::keyPressEvent ( QKeyEvent * e )
405{ 405{
406 406
407 e->ignore(); 407 e->ignore();
408 408
409} 409}
410 410
411void MonthViewCell::startUpdateCell() 411void MonthViewCell::startUpdateCell()
412{ 412{
413 413
414 mItemList->setFocusPolicy(NoFocus); 414 mItemList->setFocusPolicy(NoFocus);
415 if ( !mMonthView->isUpdatePossible() ) 415 if ( !mMonthView->isUpdatePossible() )
416 return; 416 return;
417 417
418 /* 418 /*
419 if ( !isVisible() ){ 419 if ( !isVisible() ){
420 return; 420 return;
421 } 421 }
422 */ 422 */
423 // qDebug("MonthViewCell::updateCell() "); 423 // qDebug("MonthViewCell::updateCell() ");
424 setPrimary( mDate.month()%2 ); 424 setPrimary( mDate.month()%2 );
425 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); 425 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays);
426 if ( mDate == QDate::currentDate() ) { 426 if ( mDate == QDate::currentDate() ) {
427 mItemList->setLineWidth( 3 ); 427 mItemList->setLineWidth( 3 );
428 } else { 428 } else {
429 mItemList->setLineWidth( 1 ); 429 mItemList->setLineWidth( 1 );
430 } 430 }
431 mItemList->clear(); 431 mItemList->clear();
432 432
433#ifdef DESKTOP_VERSION 433#ifdef DESKTOP_VERSION
434 QToolTip::remove(this); 434 QToolTip::remove(this);
435#endif 435#endif
436 mToolTip = ""; 436 mToolTip = "";
437 //qApp->processEvents(); 437 //qApp->processEvents();
438 if ( !mHolidayString.isEmpty() ) { 438 if ( !mHolidayString.isEmpty() ) {
439 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); 439 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString );
440 item->setPalette( mHolidayPalette ); 440 item->setPalette( mHolidayPalette );
441 mItemList->insertItem( item ); 441 mItemList->insertItem( item );
442 mToolTip += mHolidayString+"\n"; 442 mToolTip += mHolidayString+"\n";
443 } 443 }
444} 444}
445 445
446void MonthViewCell::insertEvent(Event *event) 446void MonthViewCell::insertEvent(Event *event)
447{ 447{
448 448
449 mItemList->setFocusPolicy(WheelFocus); 449 mItemList->setFocusPolicy(WheelFocus);
450 if ( !(event->doesRecur() == Recurrence::rNone) ) { 450 if ( !(event->doesRecur() == Recurrence::rNone) ) {
451 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) 451 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily )
452 return; 452 return;
453 else 453 else
454 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) 454 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly )
455 return; 455 return;
456 } 456 }
457 457
458 if ( event->categories().contains("Holiday") || 458 if ( event->categories().contains("Holiday") ||
459 event->categories().contains(i18n("Holiday"))) { 459 event->categories().contains(i18n("Holiday"))) {
460 setHoliday( true ); 460 setHoliday( true );
461 if ( mDate.dayOfWeek() == 7 ) 461 if ( mDate.dayOfWeek() == 7 )
462 mItemList->setLineWidth( 3 ); 462 mItemList->setLineWidth( 3 );
463 } 463 }
464 QString text; 464 QString text;
465 if (event->isMultiDay()) { 465 if (event->isMultiDay()) {
466 QString prefix = "<->"; 466 QString prefix = "<->";
467 if ( event->doesRecur() ) { 467 if ( event->doesRecur() ) {
468 if ( event->recursOn( mDate) ) 468 if ( event->recursOn( mDate) )
469 prefix ="->" ; 469 prefix ="->" ;
470 else { 470 else {
471 int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); 471 int days = event->dtStart().date().daysTo ( event->dtEnd().date() );
472 if ( event->recursOn( mDate.addDays( -days)) ) 472 if ( event->recursOn( mDate.addDays( -days)) )
473 prefix ="<-" ; 473 prefix ="<-" ;
474 } 474 }
475 475
476 } else { 476 } else {
477 if (mDate == event->dtStart().date()) { 477 if (mDate == event->dtStart().date()) {
478 prefix ="->" ; 478 prefix ="->" ;
479 } else if (mDate == event->dtEnd().date()) { 479 } else if (mDate == event->dtEnd().date()) {
480 prefix ="<-" ; 480 prefix ="<-" ;
481 } 481 }
482 } 482 }
483 if ( !event->doesFloat() ) { 483 if ( !event->doesFloat() ) {
484 if ( mDate == event->dtStart().date () ) 484 if ( mDate == event->dtStart().date () )
485 prefix += KGlobal::locale()->formatTime(event->dtStart().time())+" "; 485 prefix += KGlobal::locale()->formatTime(event->dtStart().time())+" ";
486 else if ( mDate == event->dtEnd().date () ) 486 else if ( mDate == event->dtEnd().date () )
487 prefix += KGlobal::locale()->formatTime(event->dtEnd().time())+" "; 487 prefix += KGlobal::locale()->formatTime(event->dtEnd().time())+" ";
488 488
489 } 489 }
490 text = prefix + event->summary(); 490 text = prefix + event->summary();
491 mToolTip += text; 491 mToolTip += text;
492 } else { 492 } else {
493 if (event->doesFloat()) { 493 if (event->doesFloat()) {
494 text = event->summary(); 494 text = event->summary();
495 mToolTip += text; 495 mToolTip += text;
496 } 496 }
497 else { 497 else {
498 text = KGlobal::locale()->formatTime(event->dtStart().time()); 498 text = KGlobal::locale()->formatTime(event->dtStart().time());
499 text += " " + event->summary(); 499 text += " " + event->summary();
500 mToolTip += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); 500 mToolTip += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary();
501 } 501 }
502 } 502 }
503 503
504 MonthViewItem *item = new MonthViewItem( event, mDate, text ); 504 MonthViewItem *item = new MonthViewItem( event, mDate, text );
505 QPalette pal; 505 QPalette pal;
506 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 506 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
507 QStringList categories = event->categories(); 507 QStringList categories = event->categories();
508 QString cat = categories.first(); 508 QString cat = categories.first();
509 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 509 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
510 pal = getPalette(); 510 pal = getPalette();
511 if (cat.isEmpty()) { 511 if (cat.isEmpty()) {
512 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 512 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
513 } else { 513 } else {
514 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 514 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
515 } 515 }
516 516
517 } else { 517 } else {
518 if (cat.isEmpty()) { 518 if (cat.isEmpty()) {
519 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 519 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
520 } else { 520 } else {
521 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 521 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
522 } 522 }
523 } 523 }
524 524
525 } else { 525 } else {
526 pal = mStandardPalette ; 526 pal = mStandardPalette ;
527 } 527 }
528 item->setPalette( pal ); 528 item->setPalette( pal );
529 item->setRecur( event->recurrence()->doesRecur() ); 529 item->setRecur( event->recurrence()->doesRecur() );
530 item->setAlarm( event->isAlarmEnabled() ); 530 item->setAlarm( event->isAlarmEnabled() );
531 item->setMoreInfo( event->description().length() > 0 ); 531 item->setMoreInfo( event->description().length() > 0 );
532#ifdef DESKTOP_VERSION 532#ifdef DESKTOP_VERSION
533 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, 533 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails,
534 KOPrefs::instance()->email()); 534 KOPrefs::instance()->email());
535 if ( me != 0 ) { 535 if ( me != 0 ) {
536 if ( me->status() == Attendee::NeedsAction && me->RSVP()) 536 if ( me->status() == Attendee::NeedsAction && me->RSVP())
537 item->setReply(true); 537 item->setReply(true);
538 else 538 else
539 item->setReply(false); 539 item->setReply(false);
540 } else 540 } else
541 item->setReply(false); 541 item->setReply(false);
542#endif 542#endif
543 mItemList->insertItem( item ); 543 mItemList->insertItem( item );
544 mToolTip += "\n"; 544 mToolTip += "\n";
545} 545}
546void MonthViewCell::insertTodo(Todo *todo) 546void MonthViewCell::insertTodo(Todo *todo)
547{ 547{
548 mItemList->setFocusPolicy(WheelFocus); 548 mItemList->setFocusPolicy(WheelFocus);
549 QString text; 549 QString text;
550 if (todo->hasDueDate()) { 550 if (todo->hasDueDate()) {
551 if (!todo->doesFloat()) { 551 if (!todo->doesFloat()) {
552 text += KGlobal::locale()->formatTime(todo->dtDue().time()); 552 text += KGlobal::locale()->formatTime(todo->dtDue().time());
553 text += " "; 553 text += " ";
554 } 554 }
555 } 555 }
556 text += i18n("Td: %1").arg(todo->summary()); 556 text += i18n("Td: %1").arg(todo->summary());
557 557
558 MonthViewItem *item = new MonthViewItem( todo, mDate, text ); 558 MonthViewItem *item = new MonthViewItem( todo, mDate, text );
559 //item->setPalette( mStandardPalette ); 559 //item->setPalette( mStandardPalette );
560 QPalette pal; 560 QPalette pal;
561 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 561 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
562 QStringList categories = todo->categories(); 562 QStringList categories = todo->categories();
563 QString cat = categories.first(); 563 QString cat = categories.first();
564 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 564 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
565 pal = getPalette(); 565 pal = getPalette();
566 if (cat.isEmpty()) { 566 if (cat.isEmpty()) {
567 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 567 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
568 } else { 568 } else {
569 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 569 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
570 } 570 }
571 571
572 } else { 572 } else {
573 if (cat.isEmpty()) { 573 if (cat.isEmpty()) {
574 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 574 pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
575 } else { 575 } else {
576 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 576 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
577 } 577 }
578 } 578 }
579 579
580 } else { 580 } else {
581 pal = mStandardPalette ; 581 pal = mStandardPalette ;
582 } 582 }
583 item->setPalette( pal ); 583 item->setPalette( pal );
584 mItemList->insertItem( item ); 584 mItemList->insertItem( item );
585 mToolTip += text+"\n"; 585 mToolTip += text+"\n";
586} 586}
587void MonthViewCell::finishUpdateCell() 587void MonthViewCell::finishUpdateCell()
588{ 588{
589#ifdef DESKTOP_VERSION 589#ifdef DESKTOP_VERSION
590 if (mToolTip != "") 590 if (mToolTip != "")
591 QToolTip::add(this,mToolTip,toolTipGroup(),""); 591 QToolTip::add(this,mToolTip,toolTipGroup(),"");
592#endif 592#endif
593 mItemList->sort(); 593 mItemList->sort();
594 //setMyPalette(); 594 //setMyPalette();
595 setMyPalette(); 595 setMyPalette();
596 QString text; 596 QString text;
597 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; 597 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog;
598 if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { 598 if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) {
599 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; 599 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " ";
600 mLabel->resize( mLabelBigSize ); 600 mLabel->resize( mLabelBigSize );
601 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 601 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
602 } else { 602 } else {
603 mLabel->resize( mLabelSize ); 603 mLabel->resize( mLabelSize );
604 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 604 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
605 } 605 }
606 606
607 mLabel->setText( text ); 607 mLabel->setText( text );
608 resizeEvent( 0 ); 608 resizeEvent( 0 );
609} 609}
610void MonthViewCell::updateCell() 610void MonthViewCell::updateCell()
611{ 611{
612 qDebug("MonthViewCell::updateCell() "); 612 qDebug("MonthViewCell::updateCell() ");
613 if ( !mMonthView->isUpdatePossible() ) 613 if ( !mMonthView->isUpdatePossible() )
614 return; 614 return;
615 startUpdateCell(); 615 startUpdateCell();
616 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 616 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
617 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); 617 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true );
618 Event *event; 618 Event *event;
619 for( event = events.first(); event; event = events.next() ) { // for event 619 for( event = events.first(); event; event = events.next() ) { // for event
620 insertEvent(event); 620 insertEvent(event);
621 } 621 }
622 // insert due todos 622 // insert due todos
623 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); 623 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate );
624 Todo *todo; 624 Todo *todo;
625 for(todo = todos.first(); todo; todo = todos.next()) { 625 for(todo = todos.first(); todo; todo = todos.next()) {
626 insertTodo( todo ); 626 insertTodo( todo );
627 } 627 }
628 finishUpdateCell(); 628 finishUpdateCell();
629 // if ( isVisible()) 629 // if ( isVisible())
630 //qApp->processEvents(); 630 //qApp->processEvents();
631} 631}
632 632
633void MonthViewCell::updateConfig( bool bigFont ) // = false 633void MonthViewCell::updateConfig( bool bigFont ) // = false
634{ 634{
635 635
636 if ( bigFont ) { 636 if ( bigFont ) {
637 QFont fo = KOPrefs::instance()->mMonthViewFont; 637 QFont fo = KOPrefs::instance()->mMonthViewFont;
638 int ps = fo.pointSize() + 2; 638 int ps = fo.pointSize() + 2;
639 if ( ps < 18 ) 639 if ( ps < 18 )
640 ps += 2; 640 ps += 2;
641 fo.setPointSize( ps ); 641 fo.setPointSize( ps );
642 setFont( fo ); 642 setFont( fo );
643 } else 643 } else
644 setFont( KOPrefs::instance()->mMonthViewFont ); 644 setFont( KOPrefs::instance()->mMonthViewFont );
645 645
646 QFontMetrics fm( font() ); 646 QFontMetrics fm( font() );
647 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); 647 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 );
648 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); 648 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 );
649 mHolidayPalette = mStandardPalette; 649 mHolidayPalette = mStandardPalette;
650 mPrimaryPalette = mStandardPalette; 650 mPrimaryPalette = mStandardPalette;
651 mNonPrimaryPalette = mStandardPalette; 651 mNonPrimaryPalette = mStandardPalette;
652 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { 652 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) {
653 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); 653 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor );
654 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); 654 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor );
655 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); 655 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark());
656 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); 656 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark());
657 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); 657 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor);
658 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); 658 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor);
659 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); 659 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark());
660 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); 660 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor);
661 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); 661 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor);
662 } 662 }
663 //updateCell(); 663 //updateCell();
664} 664}
665 665
666void MonthViewCell::enableScrollBars( bool enabled ) 666void MonthViewCell::enableScrollBars( bool enabled )
667{ 667{
668 if ( enabled ) { 668 if ( enabled ) {
669 mItemList->setVScrollBarMode(QScrollView::Auto); 669 mItemList->setVScrollBarMode(QScrollView::Auto);
670 mItemList->setHScrollBarMode(QScrollView::Auto); 670 mItemList->setHScrollBarMode(QScrollView::Auto);
671 } else { 671 } else {
672 mItemList->setVScrollBarMode(QScrollView::AlwaysOff); 672 mItemList->setVScrollBarMode(QScrollView::AlwaysOff);
673 mItemList->setHScrollBarMode(QScrollView::AlwaysOff); 673 mItemList->setHScrollBarMode(QScrollView::AlwaysOff);
674 } 674 }
675} 675}
676 676
677Incidence *MonthViewCell::selectedIncidence() 677Incidence *MonthViewCell::selectedIncidence()
678{ 678{
679 int index = mItemList->currentItem(); 679 int index = mItemList->currentItem();
680 if ( index < 0 ) return 0; 680 if ( index < 0 ) return 0;
681 681
682 MonthViewItem *item = 682 MonthViewItem *item =
683 static_cast<MonthViewItem *>( mItemList->item( index ) ); 683 static_cast<MonthViewItem *>( mItemList->item( index ) );
684 684
685 if ( !item ) return 0; 685 if ( !item ) return 0;
686 686
687 return item->incidence(); 687 return item->incidence();
688} 688}
689 689
690QDate MonthViewCell::selectedIncidenceDate() 690QDate MonthViewCell::selectedIncidenceDate()
691{ 691{
692 QDate qd; 692 QDate qd;
693 int index = mItemList->currentItem(); 693 int index = mItemList->currentItem();
694 if ( index < 0 ) return qd; 694 if ( index < 0 ) return qd;
695 695
696 MonthViewItem *item = 696 MonthViewItem *item =
697 static_cast<MonthViewItem *>( mItemList->item( index ) ); 697 static_cast<MonthViewItem *>( mItemList->item( index ) );
698 698
699 if ( !item ) return qd; 699 if ( !item ) return qd;
700 700
701 return item->incidenceDate(); 701 return item->incidenceDate();
702} 702}
703 703
704void MonthViewCell::deselect() 704void MonthViewCell::deselect()
705{ 705{
706 mItemList->clearSelection(); 706 mItemList->clearSelection();
707 enableScrollBars( false ); 707 enableScrollBars( false );
708 // updateCell(); 708 // updateCell();
709} 709}
710void MonthViewCell::select() 710void MonthViewCell::select()
711{ 711{
712 ;// updateCell(); 712 ;// updateCell();
713} 713}
714 714
715void MonthViewCell::resizeEvent ( QResizeEvent * ) 715void MonthViewCell::resizeEvent ( QResizeEvent * )
716{ 716{
717 if ( !mMonthView->isUpdatePossible() ) 717 if ( !mMonthView->isUpdatePossible() )
718 return; 718 return;
719 719
720 int size = height() - mLabel->height() - 2; 720 int size = height() - mLabel->height() - 2;
721 if ( size > 0 ) 721 if ( size > 0 )
722 mItemList->verticalScrollBar()->setMaximumHeight( size ); 722 mItemList->verticalScrollBar()->setMaximumHeight( size );
723 size = width() - mLabel->width() -2; 723 size = width() - mLabel->width() -2;
724 if ( size > 0 ) 724 if ( size > 0 )
725 mItemList->horizontalScrollBar()->setMaximumWidth( size ); 725 mItemList->horizontalScrollBar()->setMaximumWidth( size );
726 mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() ); 726 mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() );
727 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 727 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
728} 728}
729 729
730void MonthViewCell::defaultAction( QListBoxItem *item ) 730void MonthViewCell::defaultAction( QListBoxItem *item )
731{ 731{
732 if ( !item ) return; 732 if ( !item ) return;
733 733
734 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 734 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
735 Incidence *incidence = eventItem->incidence(); 735 Incidence *incidence = eventItem->incidence();
736 if ( incidence ) mMonthView->defaultAction( incidence ); 736 if ( incidence ) mMonthView->defaultAction( incidence );
737} 737}
738void MonthViewCell::showDay() 738void MonthViewCell::showDay()
739{ 739{
740 emit showDaySignal( date() ); 740 emit showDaySignal( date() );
741} 741}
742void MonthViewCell::newEvent() 742void MonthViewCell::newEvent()
743{ 743{
744 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 744 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
745 emit newEventSignal( dt ); 745 emit newEventSignal( dt );
746} 746}
747void MonthViewCell::cellClicked( QListBoxItem *item ) 747void MonthViewCell::cellClicked( QListBoxItem *item )
748{ 748{
749 static QListBoxItem * lastClicked = 0; 749 static QListBoxItem * lastClicked = 0;
750 if ( item == 0 ) { 750 if ( item == 0 ) {
751 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 751 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
752 emit newEventSignal( dt ); 752 emit newEventSignal( dt );
753 return; 753 return;
754 } 754 }
755 /* 755 /*
756 if ( lastClicked ) 756 if ( lastClicked )
757 if ( ! item ) { 757 if ( ! item ) {
758 if ( lastClicked->listBox() != item->listBox() ) 758 if ( lastClicked->listBox() != item->listBox() )
759 lastClicked->listBox()->clearSelection(); 759 lastClicked->listBox()->clearSelection();
760 } 760 }
761 */ 761 */
762 762
763 mMonthView->setSelectedCell( this ); 763 mMonthView->setSelectedCell( this );
764 if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true ); 764 if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true );
765 select(); 765 select();
766} 766}
767 767
768void MonthViewCell::contextMenu( QListBoxItem *item ) 768void MonthViewCell::contextMenu( QListBoxItem *item )
769{ 769{
770 if ( !item ) return; 770 if ( !item ) return;
771 771
772 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 772 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
773 Incidence *incidence = eventItem->incidence(); 773 Incidence *incidence = eventItem->incidence();
774 if ( incidence ) mMonthView->showContextMenu( incidence ); 774 if ( incidence ) mMonthView->showContextMenu( incidence );
775} 775}
776 776
777void MonthViewCell::selection( QListBoxItem *item ) 777void MonthViewCell::selection( QListBoxItem *item )
778{ 778{
779 if ( !item ) return; 779 if ( !item ) return;
780 780
781 mMonthView->setSelectedCell( this ); 781 mMonthView->setSelectedCell( this );
782} 782}
783 783
784 784
785// ******************************************************************************* 785// *******************************************************************************
786// ******************************************************************************* 786// *******************************************************************************
787// ******************************************************************************* 787// *******************************************************************************
788 788
789 789
790KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) 790KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
791 : KOEventView( calendar, parent, name ), 791 : KOEventView( calendar, parent, name ),
792 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), 792 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ),
793 mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) 793 mWidthLongDayLabel( 0 ), mSelectedCell( 0 )
794{ 794{
795 mShortDayLabelsM = false; 795 mShortDayLabelsM = false;
796 mShortDayLabelsW = false; 796 mShortDayLabelsW = false;
797 skipResize = false; 797 skipResize = false;
798 clPending = true; 798 clPending = true;
799 mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); 799 mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" );
800 mWidStack = new QWidgetStack( this ); 800 mWidStack = new QWidgetStack( this );
801 QVBoxLayout* hb = new QVBoxLayout( this ); 801 QVBoxLayout* hb = new QVBoxLayout( this );
802 mMonthView = new QWidget( mWidStack ); 802 mMonthView = new QWidget( mWidStack );
803 mWeekView = new QWidget( mWidStack ); 803 mWeekView = new QWidget( mWidStack );
804#if QT_VERSION >= 0x030000 804#if QT_VERSION >= 0x030000
805 mWidStack->addWidget(mMonthView ); 805 mWidStack->addWidget(mMonthView );
806 mWidStack->addWidget(mWeekView ); 806 mWidStack->addWidget(mWeekView );
807#else 807#else
808 mWidStack->addWidget( mMonthView, 1 ); 808 mWidStack->addWidget( mMonthView, 1 );
809 mWidStack->addWidget( mWeekView , 1 ); 809 mWidStack->addWidget( mWeekView , 1 );
810#endif 810#endif
811 hb->addWidget( mNavigatorBar ); 811 hb->addWidget( mNavigatorBar );
812 hb->addWidget( mWidStack ); 812 hb->addWidget( mWidStack );
813 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); 813 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
814 mShowWeekView = KOPrefs::instance()->mMonthViewWeek; 814 mShowWeekView = KOPrefs::instance()->mMonthViewWeek;
815 if ( mShowWeekView ) 815 if ( mShowWeekView )
816 mWeekStartsMonday = true; 816 mWeekStartsMonday = true;
817 updatePossible = false; 817 updatePossible = false;
818 //updatePossible = true; 818 //updatePossible = true;
819 mCells.setAutoDelete( true ); 819 mCells.setAutoDelete( true );
820 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 820 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
821 mDayLabels.resize( mDaysPerWeek ); 821 mDayLabels.resize( mDaysPerWeek );
822 mDayLabelsW.resize( mDaysPerWeek ); 822 mDayLabelsW.resize( mDaysPerWeek );
823 QFont bfont = font(); 823 QFont bfont = font();
824 if ( QApplication::desktop()->width() < 650 ) { 824 if ( QApplication::desktop()->width() < 650 ) {
825 bfont.setPointSize( bfont.pointSize() - 2 ); 825 bfont.setPointSize( bfont.pointSize() - 2 );
826 } 826 }
827 bfont.setBold( true ); 827 bfont.setBold( true );
828 int i; 828 int i;
829 829
830 for( i = 0; i < mDaysPerWeek; i++ ) { 830 for( i = 0; i < mDaysPerWeek; i++ ) {
831 QLabel *label = new QLabel( mMonthView ); 831 QLabel *label = new QLabel( mMonthView );
832 label->setFont(bfont); 832 label->setFont(bfont);
833 label->setFrameStyle(QFrame::Panel|QFrame::Raised); 833 label->setFrameStyle(QFrame::Panel|QFrame::Raised);
834 label->setLineWidth(1); 834 label->setLineWidth(1);
835 label->setAlignment(AlignCenter); 835 label->setAlignment(AlignCenter);
836 mDayLabels.insert( i, label ); 836 mDayLabels.insert( i, label );
837 label = new QLabel( mWeekView ); 837 label = new QLabel( mWeekView );
838 label->setFont(bfont); 838 label->setFont(bfont);
839 label->setFrameStyle(QFrame::Panel|QFrame::Raised); 839 label->setFrameStyle(QFrame::Panel|QFrame::Raised);
840 label->setLineWidth(1); 840 label->setLineWidth(1);
841 label->setAlignment(AlignCenter); 841 label->setAlignment(AlignCenter);
842 mDayLabelsW.insert( i, label ); 842 mDayLabelsW.insert( i, label );
843 } 843 }
844 844
845 bfont.setBold( false ); 845 bfont.setBold( false );
846 mWeekLabels.resize( mNumWeeks+1 ); 846 mWeekLabels.resize( mNumWeeks+1 );
847 mWeekLabelsW.resize( 2 ); 847 mWeekLabelsW.resize( 2 );
848 for( i = 0; i < mNumWeeks+1; i++ ) { 848 for( i = 0; i < mNumWeeks+1; i++ ) {
849 KOWeekButton *label = new KOWeekButton( mMonthView ); 849 KOWeekButton *label = new KOWeekButton( mMonthView );
850 label->setFocusPolicy(NoFocus); 850 label->setFocusPolicy(NoFocus);
851 label->setFont(bfont); 851 label->setFont(bfont);
852 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); 852 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) );
853 label->setFlat(true); 853 label->setFlat(true);
854 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); 854 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed"));
855 //label->setFrameStyle(QFrame::Panel|QFrame::Raised); 855 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
856 //label->setLineWidth(1); 856 //label->setLineWidth(1);
857 //label->setAlignment(AlignCenter); 857 //label->setAlignment(AlignCenter);
858 mWeekLabels.insert( i, label ); 858 mWeekLabels.insert( i, label );
859 } 859 }
860 mWeekLabels[mNumWeeks]->setText( i18n("W")); 860 mWeekLabels[mNumWeeks]->setText( i18n("W"));
861 QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); 861 QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number"));
862 862
863 for( i = 0; i < 1+1; i++ ) { 863 for( i = 0; i < 1+1; i++ ) {
864 KOWeekButton *label = new KOWeekButton( mWeekView ); 864 KOWeekButton *label = new KOWeekButton( mWeekView );
865 label->setFocusPolicy(NoFocus); 865 label->setFocusPolicy(NoFocus);
866 label->setFont(bfont); 866 label->setFont(bfont);
867 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); 867 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) );
868 label->setFlat(true); 868 label->setFlat(true);
869 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); 869 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed"));
870 //label->setFrameStyle(QFrame::Panel|QFrame::Raised); 870 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
871 //label->setLineWidth(1); 871 //label->setLineWidth(1);
872 //label->setAlignment(AlignCenter); 872 //label->setAlignment(AlignCenter);
873 mWeekLabelsW.insert( i, label ); 873 mWeekLabelsW.insert( i, label );
874 } 874 }
875 mWeekLabelsW[1]->setText( i18n("W")); 875 mWeekLabelsW[1]->setText( i18n("W"));
876 876
877 877
878 int row, col; 878 int row, col;
879 mCells.resize( mNumCells ); 879 mCells.resize( mNumCells );
880 for( row = 0; row < mNumWeeks; ++row ) { 880 for( row = 0; row < mNumWeeks; ++row ) {
881 for( col = 0; col < mDaysPerWeek; ++col ) { 881 for( col = 0; col < mDaysPerWeek; ++col ) {
882 MonthViewCell *cell = new MonthViewCell( this, mMonthView ); 882 MonthViewCell *cell = new MonthViewCell( this, mMonthView );
883 mCells.insert( row * mDaysPerWeek + col, cell ); 883 mCells.insert( row * mDaysPerWeek + col, cell );
884 884
885 connect( cell, SIGNAL( defaultAction( Incidence * ) ), 885 connect( cell, SIGNAL( defaultAction( Incidence * ) ),
886 SLOT( defaultAction( Incidence * ) ) ); 886 SLOT( defaultAction( Incidence * ) ) );
887 connect( cell, SIGNAL( newEventSignal( QDateTime ) ), 887 connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
888 SIGNAL( newEventSignal( QDateTime ) ) ); 888 SIGNAL( newEventSignal( QDateTime ) ) );
889 connect( cell, SIGNAL( showDaySignal( QDate ) ), 889 connect( cell, SIGNAL( showDaySignal( QDate ) ),
890 SIGNAL( showDaySignal( QDate ) ) ); 890 SIGNAL( showDaySignal( QDate ) ) );
891 } 891 }
892 } 892 }
893 mCellsW.resize( mDaysPerWeek ); 893 mCellsW.resize( mDaysPerWeek );
894 for( col = 0; col < mDaysPerWeek; ++col ) { 894 for( col = 0; col < mDaysPerWeek; ++col ) {
895 MonthViewCell *cell = new MonthViewCell( this, mWeekView ); 895 MonthViewCell *cell = new MonthViewCell( this, mWeekView );
896 mCellsW.insert( col, cell ); 896 mCellsW.insert( col, cell );
897 897
898 connect( cell, SIGNAL( defaultAction( Incidence * ) ), 898 connect( cell, SIGNAL( defaultAction( Incidence * ) ),
899 SLOT( defaultAction( Incidence * ) ) ); 899 SLOT( defaultAction( Incidence * ) ) );
900 connect( cell, SIGNAL( newEventSignal( QDateTime ) ), 900 connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
901 SIGNAL( newEventSignal( QDateTime ) ) ); 901 SIGNAL( newEventSignal( QDateTime ) ) );
902 connect( cell, SIGNAL( showDaySignal( QDate ) ), 902 connect( cell, SIGNAL( showDaySignal( QDate ) ),
903 SIGNAL( showDaySignal( QDate ) ) ); 903 SIGNAL( showDaySignal( QDate ) ) );
904 cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); 904 cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont );
905 } 905 }
906 906
907 //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); 907 //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) );
908 mContextMenu = eventPopup(); 908 mContextMenu = eventPopup();
909 // updateConfig(); //useless here... 909 // updateConfig(); //useless here...
910 // ... but we need mWidthLongDayLabel computed 910 // ... but we need mWidthLongDayLabel computed
911 QFontMetrics fontmetric(mDayLabels[0]->font()); 911 QFontMetrics fontmetric(mDayLabels[0]->font());
912 mWidthLongDayLabel = 0; 912 mWidthLongDayLabel = 0;
913 for (int i = 0; i < 7; i++) { 913 for (int i = 0; i < 7; i++) {
914 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); 914 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1));
915 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; 915 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
916 } 916 }
917 917
918 //mWeekLabels[mNumWeeks]->setText( i18n("W")); 918 //mWeekLabels[mNumWeeks]->setText( i18n("W"));
919 919
920 if ( mShowWeekView ) 920 if ( mShowWeekView )
921 mWidStack->raiseWidget( mWeekView ); 921 mWidStack->raiseWidget( mWeekView );
922 else 922 else
923 mWidStack->raiseWidget( mMonthView ); 923 mWidStack->raiseWidget( mMonthView );
924 924
925 emit incidenceSelected( 0 ); 925 emit incidenceSelected( 0 );
926#ifndef DESKTOP_VERSION 926#ifndef DESKTOP_VERSION
927 resize( QApplication::desktop()->size() ); 927 resize( QApplication::desktop()->size() );
928 computeLayout(); 928#else
929 resize(640, 480 );
929#endif 930#endif
931 computeLayout();
932
930} 933}
931 934
932KOMonthView::~KOMonthView() 935KOMonthView::~KOMonthView()
933{ 936{
934 delete mContextMenu; 937 delete mContextMenu;
935} 938}
936 939
937void KOMonthView::selectInternalWeekNum ( int n ) 940void KOMonthView::selectInternalWeekNum ( int n )
938{ 941{
939 switchView(); 942 switchView();
940 emit selectWeekNum ( n ); 943 emit selectWeekNum ( n );
941} 944}
942 945
943int KOMonthView::currentWeek() 946int KOMonthView::currentWeek()
944{ 947{
945 if ( mShowWeekView ) 948 if ( mShowWeekView )
946 return mWeekLabelsW[0]->getWeekNum(); 949 return mWeekLabelsW[0]->getWeekNum();
947 return mWeekLabels[0]->getWeekNum(); 950 return mWeekLabels[0]->getWeekNum();
948} 951}
949void KOMonthView::switchView() 952void KOMonthView::switchView()
950{ 953{
951 954
952 if ( selectedCell( ) ) 955 if ( selectedCell( ) )
953 selectedCell()->deselect(); 956 selectedCell()->deselect();
954 mShowWeekView = !mShowWeekView; 957 mShowWeekView = !mShowWeekView;
955 KOPrefs::instance()->mMonthViewWeek = mShowWeekView; 958 KOPrefs::instance()->mMonthViewWeek = mShowWeekView;
956 if ( clPending ) { 959 if ( clPending ) {
957 computeLayout(); 960 computeLayout();
958 updateConfig(); 961 updateConfig();
959 } 962 }
960 if ( mShowWeekView ) 963 if ( mShowWeekView )
961 mWidStack->raiseWidget( mWeekView ); 964 mWidStack->raiseWidget( mWeekView );
962 else 965 else
963 mWidStack->raiseWidget( mMonthView ); 966 mWidStack->raiseWidget( mMonthView );
964 clPending = false; 967 clPending = false;
965} 968}
966 969
967int KOMonthView::maxDatesHint() 970int KOMonthView::maxDatesHint()
968{ 971{
969 return mNumCells; 972 return mNumCells;
970} 973}
971 974
972int KOMonthView::currentDateCount() 975int KOMonthView::currentDateCount()
973{ 976{
974 return mNumCells; 977 return mNumCells;
975} 978}
976 979
977QPtrList<Incidence> KOMonthView::selectedIncidences() 980QPtrList<Incidence> KOMonthView::selectedIncidences()
978{ 981{
979 QPtrList<Incidence> selected; 982 QPtrList<Incidence> selected;
980 983
981 if ( mSelectedCell ) { 984 if ( mSelectedCell ) {
982 Incidence *incidence = mSelectedCell->selectedIncidence(); 985 Incidence *incidence = mSelectedCell->selectedIncidence();
983 if ( incidence ) selected.append( incidence ); 986 if ( incidence ) selected.append( incidence );
984 } 987 }
985 988
986 return selected; 989 return selected;
987} 990}
988 991
989DateList KOMonthView::selectedDates() 992DateList KOMonthView::selectedDates()
990{ 993{
991 DateList selected; 994 DateList selected;
992 995
993 if ( mSelectedCell ) { 996 if ( mSelectedCell ) {
994 QDate qd = mSelectedCell->selectedIncidenceDate(); 997 QDate qd = mSelectedCell->selectedIncidenceDate();
995 if ( qd.isValid() ) selected.append( qd ); 998 if ( qd.isValid() ) selected.append( qd );
996 } 999 }
997 1000
998 return selected; 1001 return selected;
999} 1002}
1000 1003
1001void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, 1004void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd,
1002 const QDate &td) 1005 const QDate &td)
1003{ 1006{
1004#ifndef KORG_NOPRINTER 1007#ifndef KORG_NOPRINTER
1005 calPrinter->preview(CalPrinter::Month, fd, td); 1008 calPrinter->preview(CalPrinter::Month, fd, td);
1006#endif 1009#endif
1007} 1010}
1008 1011
1009void KOMonthView::updateConfig() 1012void KOMonthView::updateConfig()
1010{ 1013{
1011 1014
1012 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); 1015 mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
1013 1016
1014 if ( mShowWeekView ) { 1017 if ( mShowWeekView ) {
1015 mWeekStartsMonday = true; 1018 mWeekStartsMonday = true;
1016 } 1019 }
1017 QFontMetrics fontmetric(mDayLabels[0]->font()); 1020 QFontMetrics fontmetric(mDayLabels[0]->font());
1018 mWidthLongDayLabel = 0; 1021 mWidthLongDayLabel = 0;
1019 1022
1020 for (int i = 0; i < 7; i++) { 1023 for (int i = 0; i < 7; i++) {
1021 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); 1024 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1));
1022 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; 1025 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
1023 } 1026 }
1024 bool temp = mShowSatSunComp ; 1027 bool temp = mShowSatSunComp ;
1025 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 1028 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
1026 if ( ! mShowWeekView ) { 1029 if ( ! mShowWeekView ) {
1027 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) 1030 if ( temp != KOPrefs::instance()->mMonthViewSatSunTog )
1028 computeLayout(); 1031 computeLayout();
1029 } 1032 }
1030 updateDayLabels(); 1033 updateDayLabels();
1031 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); 1034 //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks);
1032 //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; 1035 //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks;
1033 //resizeEvent( 0 ); 1036 //resizeEvent( 0 );
1034 for (uint i = 0; i < mCells.count(); ++i) { 1037 for (uint i = 0; i < mCells.count(); ++i) {
1035 mCells[i]->updateConfig(); 1038 mCells[i]->updateConfig();
1036 } 1039 }
1037 1040
1038 for (uint i = 0; i < mCellsW.count(); ++i) { 1041 for (uint i = 0; i < mCellsW.count(); ++i) {
1039 mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); 1042 mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont);
1040 } 1043 }
1041#ifdef DESKTOP_VERSION 1044#ifdef DESKTOP_VERSION
1042 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); 1045 MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips);
1043#endif 1046#endif
1044 updateView(); 1047 updateView();
1045} 1048}
1046 1049
1047void KOMonthView::updateDayLabels() 1050void KOMonthView::updateDayLabels()
1048{ 1051{
1049 1052
1050 QPtrVector<QLabel> *mDayLabelsT; 1053 QPtrVector<QLabel> *mDayLabelsT;
1051 1054
1052 mDayLabelsT = &mDayLabelsW; 1055 mDayLabelsT = &mDayLabelsW;
1053 for (int i = 0; i < 7; i++) { 1056 for (int i = 0; i < 7; i++) {
1054 if (mWeekStartsMonday) { 1057 if (mWeekStartsMonday) {
1055 bool show = mShortDayLabelsW; 1058 bool show = mShortDayLabelsW;
1056 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) 1059 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() )
1057 show = true; 1060 show = true;
1058 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); 1061 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
1059 } else { 1062 } else {
1060 if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsW)); 1063 if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsW));
1061 else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsW)); 1064 else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsW));
1062 1065
1063 } 1066 }
1064 } 1067 }
1065 mDayLabelsT = &mDayLabels; 1068 mDayLabelsT = &mDayLabels;
1066 for (int i = 0; i < 7; i++) { 1069 for (int i = 0; i < 7; i++) {
1067 if (mWeekStartsMonday) { 1070 if (mWeekStartsMonday) {
1068 bool show = mShortDayLabelsM; 1071 bool show = mShortDayLabelsM;
1069 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) 1072 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() )
1070 show = true; 1073 show = true;
1071 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); 1074 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
1072 } else { 1075 } else {
1073 if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); 1076 if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM));
1074 else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); 1077 else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM));
1075 1078
1076 } 1079 }
1077 } 1080 }
1078 1081
1079} 1082}
1080 1083
1081void KOMonthView::showDates(const QDate &start, const QDate &) 1084void KOMonthView::showDates(const QDate &start, const QDate &)
1082{ 1085{
1083 // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; 1086 // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl;
1084 1087
1085 QPtrVector<MonthViewCell> *cells; 1088 QPtrVector<MonthViewCell> *cells;
1086 QPtrVector<QLabel> *dayLabels; 1089 QPtrVector<QLabel> *dayLabels;
1087 QPtrVector<KOWeekButton> *weekLabels; 1090 QPtrVector<KOWeekButton> *weekLabels;
1088 int weekNum = 6; 1091 int weekNum = 6;
1089 if ( mShowWeekView ) { 1092 if ( mShowWeekView ) {
1090 weekNum = 1; 1093 weekNum = 1;
1091 cells = &mCellsW; 1094 cells = &mCellsW;
1092 dayLabels = &mDayLabelsW; 1095 dayLabels = &mDayLabelsW;
1093 weekLabels = &mWeekLabelsW; 1096 weekLabels = &mWeekLabelsW;
1094 } else { 1097 } else {
1095 cells = &mCells; 1098 cells = &mCells;
1096 dayLabels = &mDayLabels; 1099 dayLabels = &mDayLabels;
1097 weekLabels = &mWeekLabels; 1100 weekLabels = &mWeekLabels;
1098 } 1101 }
1099 1102
1100 mStartDate = start; 1103 mStartDate = start;
1101 1104
1102 int startWeekDay = mWeekStartsMonday ? 1 : 7; 1105 int startWeekDay = mWeekStartsMonday ? 1 : 7;
1103 1106
1104 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { 1107 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) {
1105 mStartDate = mStartDate.addDays( -1 ); 1108 mStartDate = mStartDate.addDays( -1 );
1106 } 1109 }
1107 1110
1108 bool primary = false; 1111 bool primary = false;
1109 uint i; 1112 uint i;
1110 for( i = 0; i < (*cells).size(); ++i ) { 1113 for( i = 0; i < (*cells).size(); ++i ) {
1111 QDate date = mStartDate.addDays( i ); 1114 QDate date = mStartDate.addDays( i );
1112 (*cells)[i]->setDate( date ); 1115 (*cells)[i]->setDate( date );
1113 1116
1114#ifndef KORG_NOPLUGINS 1117#ifndef KORG_NOPLUGINS
1115 // add holiday, if present 1118 // add holiday, if present
1116 QString hstring(KOCore::self()->holiday(date)); 1119 QString hstring(KOCore::self()->holiday(date));
1117 (*cells)[i]->setHoliday( hstring ); 1120 (*cells)[i]->setHoliday( hstring );
1118#endif 1121#endif
1119 1122
1120 } 1123 }
1121 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); 1124 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 );
1122 for( i = 0; i < weekNum; ++i ) { 1125 for( i = 0; i < weekNum; ++i ) {
1123 int wno; 1126 int wno;
1124 // remember, according to ISO 8601, the first week of the year is the 1127 // remember, according to ISO 8601, the first week of the year is the
1125 // first week that contains a thursday. Thus we must subtract off 4, 1128 // first week that contains a thursday. Thus we must subtract off 4,
1126 // not just 1. 1129 // not just 1.
1127 int dayOfYear = date.dayOfYear(); 1130 int dayOfYear = date.dayOfYear();
1128 if (dayOfYear % 7 != 0) 1131 if (dayOfYear % 7 != 0)
1129 wno = dayOfYear / 7 + 1; 1132 wno = dayOfYear / 7 + 1;
1130 else 1133 else
1131 wno =dayOfYear / 7; 1134 wno =dayOfYear / 7;
1132 (*weekLabels)[i]->setWeekNum( wno ); 1135 (*weekLabels)[i]->setWeekNum( wno );
1133 date = date.addDays( 7 ); 1136 date = date.addDays( 7 );
1134 } 1137 }
1135 updateView(); 1138 updateView();
1136} 1139}
1137 1140
1138void KOMonthView::showEvents(QPtrList<Event>) 1141void KOMonthView::showEvents(QPtrList<Event>)
1139{ 1142{
1140 qDebug("KOMonthView::selectEvents is not implemented yet. "); 1143 qDebug("KOMonthView::selectEvents is not implemented yet. ");
1141} 1144}
1142 1145
1143void KOMonthView::changeEventDisplay(Event *, int) 1146void KOMonthView::changeEventDisplay(Event *, int)
1144{ 1147{
1145 // this should be re-written to be much more efficient, but this 1148 // this should be re-written to be much more efficient, but this
1146 // quick-and-dirty-hack gets the job done for right now. 1149 // quick-and-dirty-hack gets the job done for right now.
1147 updateView(); 1150 updateView();
1148} 1151}
1149 1152
1150void KOMonthView::updateView() 1153void KOMonthView::updateView()
1151{ 1154{
1152 1155
1153 if ( !updatePossible ) 1156 if ( !updatePossible )
1154 return; 1157 return;
1155 //QTime ti; 1158 //QTime ti;
1156 //ti.start(); 1159 //ti.start();
1157 QPtrVector<MonthViewCell> *cells; 1160 QPtrVector<MonthViewCell> *cells;
1158 if ( mShowWeekView ) { 1161 if ( mShowWeekView ) {
1159 cells = &mCellsW; 1162 cells = &mCellsW;
1160 } else { 1163 } else {
1161 cells = &mCells; 1164 cells = &mCells;
1162 } 1165 }
1163#if 1 1166#if 1
1164 int i; 1167 int i;
1165 int timeSpan = (*cells).size()-1; 1168 int timeSpan = (*cells).size()-1;
1166 if ( KOPrefs::instance()->mMonthViewWeek ) 1169 if ( KOPrefs::instance()->mMonthViewWeek )
1167 timeSpan = 6; 1170 timeSpan = 6;
1168 for( i = 0; i < timeSpan + 1; ++i ) { 1171 for( i = 0; i < timeSpan + 1; ++i ) {
1169 (*cells)[i]->startUpdateCell(); 1172 (*cells)[i]->startUpdateCell();
1170 } 1173 }
1171 1174
1172 QPtrList<Event> events = calendar()->events(); 1175 QPtrList<Event> events = calendar()->events();
1173 Event *event; 1176 Event *event;
1174 QDateTime dt; 1177 QDateTime dt;
1175 bool ok; 1178 bool ok;
1176 QDate endDate = mStartDate.addDays( timeSpan ); 1179 QDate endDate = mStartDate.addDays( timeSpan );
1177 for( event = events.first(); event; event = events.next() ) { // for event 1180 for( event = events.first(); event; event = events.next() ) { // for event
1178 if ( event->doesRecur() ) { 1181 if ( event->doesRecur() ) {
1179 bool last; 1182 bool last;
1180 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); 1183 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last );
1181 QDateTime incidenceEnd; 1184 QDateTime incidenceEnd;
1182 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); 1185 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() );
1183 bool invalid = false; 1186 bool invalid = false;
1184 while( true ) { 1187 while( true ) {
1185 if ( incidenceStart.isValid() ) { 1188 if ( incidenceStart.isValid() ) {
1186 incidenceEnd = incidenceStart.addDays( eventlen ); 1189 incidenceEnd = incidenceStart.addDays( eventlen );
1187 int st = incidenceStart.date().daysTo( endDate ); 1190 int st = incidenceStart.date().daysTo( endDate );
1188 if ( st >= 0 ) { // start before timeend 1191 if ( st >= 0 ) { // start before timeend
1189 int end = mStartDate.daysTo( incidenceEnd.date() ); 1192 int end = mStartDate.daysTo( incidenceEnd.date() );
1190 if ( end >= 0 ) { // end after timestart --- got one! 1193 if ( end >= 0 ) { // end after timestart --- got one!
1191 //normalize 1194 //normalize
1192 st = timeSpan - st; 1195 st = timeSpan - st;
1193 if ( st < 0 ) st = 0; 1196 if ( st < 0 ) st = 0;
1194 if ( end > timeSpan ) end = timeSpan; 1197 if ( end > timeSpan ) end = timeSpan;
1195 int iii; 1198 int iii;
1196 //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); 1199 //qDebug("found %s %d %d ",event->summary().latin1(), st, end );
1197 for ( iii = st;iii<= end;++iii) 1200 for ( iii = st;iii<= end;++iii)
1198 (*cells)[iii]->insertEvent( event ); 1201 (*cells)[iii]->insertEvent( event );
1199 } 1202 }
1200 } 1203 }
1201 } else { 1204 } else {
1202 if ( invalid ) 1205 if ( invalid )
1203 break; 1206 break;
1204 invalid = true; 1207 invalid = true;
1205 //qDebug("invalid %s", event->summary().latin1()); 1208 //qDebug("invalid %s", event->summary().latin1());
1206 incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; 1209 incidenceStart = QDateTime( mStartDate ).addSecs( -2 );;
1207 } 1210 }
1208 if ( last ) 1211 if ( last )
1209 break; 1212 break;
1210 bool ok; 1213 bool ok;
1211 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); 1214 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok );
1212 if ( ! ok ) 1215 if ( ! ok )
1213 break; 1216 break;
1214 if ( incidenceStart.date() > endDate ) 1217 if ( incidenceStart.date() > endDate )
1215 break; 1218 break;
1216 } 1219 }
1217 } else { // no recur 1220 } else { // no recur
1218 int st = event->dtStart().date().daysTo( endDate ); 1221 int st = event->dtStart().date().daysTo( endDate );
1219 if ( st >= 0 ) { // start before timeend 1222 if ( st >= 0 ) { // start before timeend
1220 int end = mStartDate.daysTo( event->dtEnd().date() ); 1223 int end = mStartDate.daysTo( event->dtEnd().date() );
1221 if ( end >= 0 ) { // end after timestart --- got one! 1224 if ( end >= 0 ) { // end after timestart --- got one!
1222 //normalize 1225 //normalize
1223 st = timeSpan - st; 1226 st = timeSpan - st;
1224 if ( st < 0 ) st = 0; 1227 if ( st < 0 ) st = 0;
1225 if ( end > timeSpan ) end = timeSpan; 1228 if ( end > timeSpan ) end = timeSpan;
1226 int iii; 1229 int iii;
1227 for ( iii = st;iii<= end;++iii) 1230 for ( iii = st;iii<= end;++iii)
1228 (*cells)[iii]->insertEvent( event ); 1231 (*cells)[iii]->insertEvent( event );
1229 } 1232 }
1230 } 1233 }
1231 } 1234 }
1232 } 1235 }
1233 // insert due todos 1236 // insert due todos
1234 QPtrList<Todo> todos = calendar()->todos( ); 1237 QPtrList<Todo> todos = calendar()->todos( );
1235 Todo *todo; 1238 Todo *todo;
1236 for(todo = todos.first(); todo; todo = todos.next()) { 1239 for(todo = todos.first(); todo; todo = todos.next()) {
1237 //insertTodo( todo ); 1240 //insertTodo( todo );
1238 if ( todo->hasDueDate() ) { 1241 if ( todo->hasDueDate() ) {
1239 int day = mStartDate.daysTo( todo->dtDue().date() ); 1242 int day = mStartDate.daysTo( todo->dtDue().date() );
1240 if ( day >= 0 && day < timeSpan + 1) { 1243 if ( day >= 0 && day < timeSpan + 1) {
1241 (*cells)[day]->insertTodo( todo ); 1244 (*cells)[day]->insertTodo( todo );
1242 } 1245 }
1243 } 1246 }
1244 } 1247 }
1245 1248
1246 for( i = 0; i < timeSpan+1; ++i ) { 1249 for( i = 0; i < timeSpan+1; ++i ) {
1247 (*cells)[i]->finishUpdateCell(); 1250 (*cells)[i]->finishUpdateCell();
1248 } 1251 }
1249 processSelectionChange(); 1252 processSelectionChange();
1250 (*cells)[0]->setFocus(); 1253 (*cells)[0]->setFocus();
1251 1254
1252 1255
1253#else 1256#else
1254 // old code 1257 // old code
1255 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); 1258 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ");
1256 int i; 1259 int i;
1257 for( i = 0; i < (*cells).count(); ++i ) { 1260 for( i = 0; i < (*cells).count(); ++i ) {
1258 (*cells)[i]->updateCell(); 1261 (*cells)[i]->updateCell();
1259 } 1262 }
1260 1263
1261 //qDebug("KOMonthView::updateView() "); 1264 //qDebug("KOMonthView::updateView() ");
1262 processSelectionChange(); 1265 processSelectionChange();
1263 // qDebug("---------------------------------------------------------------------+ "); 1266 // qDebug("---------------------------------------------------------------------+ ");
1264 (*cells)[0]->setFocus(); 1267 (*cells)[0]->setFocus();
1265#endif 1268#endif
1266 1269
1267 //qDebug("update time %d ", ti.elapsed()); 1270 //qDebug("update time %d ", ti.elapsed());
1268} 1271}
1269 1272
1270void KOMonthView::resizeEvent(QResizeEvent * e) 1273void KOMonthView::resizeEvent(QResizeEvent * e)
1271{ 1274{
1272 //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height()); 1275 //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height());
1273 computeLayout(); 1276 computeLayout();
1274 clPending = true; 1277 clPending = true;
1275 if ( mShowWeekView ) 1278 if ( mShowWeekView )
1276 mCellsW[0]->setFocus(); 1279 mCellsW[0]->setFocus();
1277 else 1280 else
1278 mCells[0]->setFocus(); 1281 mCells[0]->setFocus();
1279} 1282}
1280void KOMonthView::computeLayoutWeek() 1283void KOMonthView::computeLayoutWeek()
1281{ 1284{
1282 static int lastWid = 0; 1285 static int lastWid = 0;
1283 static int lastHei = 0; 1286 static int lastHei = 0;
1284 int daysToShow; 1287 int daysToShow;
1285 bool combinedSatSun = false; 1288 bool combinedSatSun = false;
1286 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { 1289 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
1287 daysToShow = 6; 1290 daysToShow = 6;
1288 combinedSatSun = true; 1291 combinedSatSun = true;
1289 } 1292 }
1290 int tWid = topLevelWidget()->size().width(); 1293 int tWid = topLevelWidget()->size().width();
1291 int tHei = topLevelWidget()->size().height(); 1294 int tHei = topLevelWidget()->size().height();
1292 1295
1293 int wid = width();//e 1296 int wid = width();//e
1294 int hei = height()-1-mNavigatorBar->height(); 1297 int hei = height()-1-mNavigatorBar->height();
1295 1298
1296 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) 1299 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei )
1297 return; 1300 return;
1298 1301
1299 if ( lastWid == width() && lastHei == height() ) 1302 if ( lastWid == width() && lastHei == height() )
1300 return; 1303 return;
1301 lastWid = width(); 1304 lastWid = width();
1302 lastHei = height(); 1305 lastHei = height();
1303 1306
1304 1307
1305 if ( wid < hei ) 1308 if ( wid < hei )
1306 daysToShow = 2; 1309 daysToShow = 2;
1307 else 1310 else
1308 daysToShow = 3; 1311 daysToShow = 3;
1309 mShowSatSunComp = true; 1312 mShowSatSunComp = true;
1310 combinedSatSun = true; 1313 combinedSatSun = true;
1311 1314
1312 //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ "); 1315 //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ ");
1313 QFontMetrics fm ( mWeekLabels[0]->font() ); 1316 QFontMetrics fm ( mWeekLabels[0]->font() );
1314 int weeklabelwid = fm.width( "888" ); 1317 int weeklabelwid = fm.width( "888" );
1315 wid -= weeklabelwid; 1318 wid -= weeklabelwid;
1316 1319
1317 int colWid = wid / daysToShow; 1320 int colWid = wid / daysToShow;
1318 int lastCol = wid - ( colWid*6 ); 1321 int lastCol = wid - ( colWid*6 );
1319 int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); 1322 int dayLabelHei = mDayLabelsW[0]->sizeHint().height();
1320 int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); 1323 int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow );
1321 int colModulo = wid % daysToShow; 1324 int colModulo = wid % daysToShow;
1322 int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; 1325 int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1;
1323 //qDebug("rowmod %d ", rowModulo); 1326 //qDebug("rowmod %d ", rowModulo);
1324 int i; 1327 int i;
1325 int x,y,w,h; 1328 int x,y,w,h;
1326 x= 0; 1329 x= 0;
1327 y= 0; 1330 y= 0;
1328 w = colWid; 1331 w = colWid;
1329 h = dayLabelHei ; 1332 h = dayLabelHei ;
1330 for ( i = 0; i < 7; i++) { 1333 for ( i = 0; i < 7; i++) {
1331 if ( i && !( i % daysToShow) && i < 6) { 1334 if ( i && !( i % daysToShow) && i < 6) {
1332 y += hei/(5-daysToShow); 1335 y += hei/(5-daysToShow);
1333 x = 0; 1336 x = 0;
1334 w = colWid; 1337 w = colWid;
1335 } 1338 }
1336 if ( ((i) % daysToShow) >= daysToShow-colModulo ) { 1339 if ( ((i) % daysToShow) >= daysToShow-colModulo ) {
1337 ++w; 1340 ++w;
1338 } 1341 }
1339 if ( i >= 5 ) { 1342 if ( i >= 5 ) {
1340 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w/2+w%2,h); 1343 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w/2+w%2,h);
1341 x -= (w/2 ); 1344 x -= (w/2 );
1342 } 1345 }
1343 else 1346 else
1344 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w,h); 1347 mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w,h);
1345 x += w; 1348 x += w;
1346 } 1349 }
1347 x= 0; 1350 x= 0;
1348 y= dayLabelHei; 1351 y= dayLabelHei;
1349 w = colWid; 1352 w = colWid;
1350 h = cellHei; 1353 h = cellHei;
1351 for ( i = 0; i < mCellsW.count(); ++i) { 1354 for ( i = 0; i < mCellsW.count(); ++i) {
1352 if ( i > 6 ) { 1355 if ( i > 6 ) {
1353 mCellsW[i]->hide(); 1356 mCellsW[i]->hide();
1354 continue; 1357 continue;
1355 } 1358 }
1356 1359
1357 w = colWid; 1360 w = colWid;
1358 if ( ((i) % daysToShow) >= daysToShow-colModulo ) { 1361 if ( ((i) % daysToShow) >= daysToShow-colModulo ) {
1359 ++w; 1362 ++w;
1360 } 1363 }
1361 if ( i == (daysToShow-1-rowModulo)*7) 1364 if ( i == (daysToShow-1-rowModulo)*7)
1362 ++h; 1365 ++h;
1363 1366
1364 if ( i >= 5 ) { 1367 if ( i >= 5 ) {
1365 if ( i ==5 ) { 1368 if ( i ==5 ) {
1366 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); 1369 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h/2 );
1367 x -= w ;y += h/2; 1370 x -= w ;y += h/2;
1368 } else { 1371 } else {
1369 if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { 1372 if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) {
1370 ++w; 1373 ++w;
1371 } 1374 }
1372 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); 1375 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 );
1373 y -= h/2; 1376 y -= h/2;
1374 } 1377 }
1375 } else 1378 } else
1376 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1379 mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h );
1377 1380
1378 1381
1379 x += w; 1382 x += w;
1380 if ( x + w/2 > wid ) { 1383 if ( x + w/2 > wid ) {
1381 x = 0; 1384 x = 0;
1382 y += h+dayLabelHei ; 1385 y += h+dayLabelHei ;
1383 } 1386 }
1384 } 1387 }
1385 y= dayLabelHei; 1388 y= dayLabelHei;
1386 h = cellHei ; 1389 h = cellHei ;
1387 mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); 1390 mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei);
1388 mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); 1391 mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei);
1389 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); 1392 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height());
1390 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); 1393 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height());
1391 mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ; 1394 mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ;
1392 updateDayLabels(); 1395 updateDayLabels();
1393 //bool forceUpdate = !updatePossible; 1396 //bool forceUpdate = !updatePossible;
1394 updatePossible = true; 1397 updatePossible = true;
1395 //mWeekLabels[mNumWeeks]->setText( i18n("M")); 1398 //mWeekLabels[mNumWeeks]->setText( i18n("M"));
1396 //if ( forceUpdate ) 1399 //if ( forceUpdate )
1397 // updateView(); 1400 // updateView();
1398} 1401}
1399void KOMonthView::computeLayout() 1402void KOMonthView::computeLayout()
1400{ 1403{
1401 1404
1402 1405
1403 static int lastWid = 0; 1406 static int lastWid = 0;
1404 static int lastHei = 0; 1407 static int lastHei = 0;
1405 1408
1406 if ( mShowWeekView ){ 1409 if ( mShowWeekView ){
1407 computeLayoutWeek(); 1410 computeLayoutWeek();
1408 return; 1411 return;
1409 } 1412 }
1410 int daysToShow = 7; 1413 int daysToShow = 7;
1411 bool combinedSatSun = false; 1414 bool combinedSatSun = false;
1412 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { 1415 if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
1413 daysToShow = 6; 1416 daysToShow = 6;
1414 combinedSatSun = true; 1417 combinedSatSun = true;
1415 } 1418 }
1416 int tWid = topLevelWidget()->size().width(); 1419 int tWid = topLevelWidget()->size().width();
1417 int tHei = topLevelWidget()->size().height(); 1420 int tHei = topLevelWidget()->size().height();
1418 1421
1419 int wid = width();//e 1422 int wid = width();//e
1420 int hei = height()-1-mNavigatorBar->height(); 1423 int hei = height()-1-mNavigatorBar->height();
1421 1424
1422 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) { 1425 if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) {
1423 return; 1426 return;
1424 } 1427 }
1425 if ( lastWid == width() && lastHei == height() ){ 1428 if ( lastWid == width() && lastHei == height() ){
1426 return; 1429 return;
1427 } 1430 }
1428 1431
1429 lastWid = width(); 1432 lastWid = width();
1430 lastHei = height(); 1433 lastHei = height();
1431 //qDebug("KOMonthView::computeLayout() MMM ------------------------------------ "); 1434 //qDebug("KOMonthView::computeLayout() MMM ------------------------------------ ");
1432 QFontMetrics fm ( mWeekLabels[0]->font() ); 1435 QFontMetrics fm ( mWeekLabels[0]->font() );
1433 int weeklabelwid = fm.width( "888" ); 1436 int weeklabelwid = fm.width( "888" );
1434 wid -= weeklabelwid; 1437 wid -= weeklabelwid;
1435 1438
1436 int colWid = wid / daysToShow; 1439 int colWid = wid / daysToShow;
1437 int lastCol = wid - ( colWid*6 ); 1440 int lastCol = wid - ( colWid*6 );
1438 int dayLabelHei = mDayLabels[0]->sizeHint().height(); 1441 int dayLabelHei = mDayLabels[0]->sizeHint().height();
1439 int cellHei = (hei - dayLabelHei) /6; 1442 int cellHei = (hei - dayLabelHei) /6;
1440 int colModulo = wid % daysToShow; 1443 int colModulo = wid % daysToShow;
1441 int rowModulo = (hei- dayLabelHei) % 6; 1444 int rowModulo = (hei- dayLabelHei) % 6;
1442 //qDebug("rowmod %d ", rowModulo); 1445 //qDebug("rowmod %d ", rowModulo);
1443 int i; 1446 int i;
1444 int x,y,w,h; 1447 int x,y,w,h;
1445 x= 0; 1448 x= 0;
1446 y= 0; 1449 y= 0;
1447 w = colWid; 1450 w = colWid;
1448 h = dayLabelHei ; 1451 h = dayLabelHei ;
1449 for ( i = 0; i < 7; i++) { 1452 for ( i = 0; i < 7; i++) {
1450 if ( i == daysToShow-colModulo ) 1453 if ( i == daysToShow-colModulo )
1451 ++w; 1454 ++w;
1452 if ( combinedSatSun ) { 1455 if ( combinedSatSun ) {
1453 if ( i >= daysToShow-1 ) { 1456 if ( i >= daysToShow-1 ) {
1454 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); 1457 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h);
1455 x -= w/2 ; 1458 x -= w/2 ;
1456 } 1459 }
1457 else 1460 else
1458 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 1461 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
1459 } else 1462 } else
1460 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 1463 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
1461 x += w; 1464 x += w;
1462 } 1465 }
1463 x= 0; 1466 x= 0;
1464 y= dayLabelHei; 1467 y= dayLabelHei;
1465 w = colWid; 1468 w = colWid;
1466 h = cellHei ; 1469 h = cellHei ;
1467 for ( i = 0; i < mCells.count(); ++i) { 1470 for ( i = 0; i < mCells.count(); ++i) {
1468 //qDebug("iii %d ", i); 1471 //qDebug("iii %d ", i);
1469 w = colWid; 1472 w = colWid;
1470 if ( ((i) % 7) >= 7-colModulo ) { 1473 if ( ((i) % 7) >= 7-colModulo ) {
1471 ++w; 1474 ++w;
1472 } 1475 }
1473 if ( i == (6-rowModulo)*7) 1476 if ( i == (6-rowModulo)*7)
1474 ++h; 1477 ++h;
1475 if ( combinedSatSun ) { 1478 if ( combinedSatSun ) {
1476 if ( (i)%7 >= daysToShow-1 ) { 1479 if ( (i)%7 >= daysToShow-1 ) {
1477 if ( (i)%7 == daysToShow-1 ) { 1480 if ( (i)%7 == daysToShow-1 ) {
1478 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); 1481 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 );
1479 x -= w ;y += h/2; 1482 x -= w ;y += h/2;
1480 } else { 1483 } else {
1481 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); 1484 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 );
1482 y -= h/2; 1485 y -= h/2;
1483 } 1486 }
1484 } else 1487 } else
1485 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1488 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
1486 1489
1487 } 1490 }
1488 else 1491 else
1489 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); 1492 mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
1490 x += w; 1493 x += w;
1491 if ( x + w/2 > wid ) { 1494 if ( x + w/2 > wid ) {
1492 x = 0; 1495 x = 0;
1493 y += h; 1496 y += h;
1494 } 1497 }
1495 } 1498 }
1496 y= dayLabelHei; 1499 y= dayLabelHei;
1497 h = cellHei ; 1500 h = cellHei ;
1498 for ( i = 0; i < 6; i++) { 1501 for ( i = 0; i < 6; i++) {
1499 if ( i == (6-rowModulo)) 1502 if ( i == (6-rowModulo))
1500 ++h; 1503 ++h;
1501 mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); 1504 mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h);
1502 y += h; 1505 y += h;
1503 } 1506 }
1504 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); 1507 mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei);
1505 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); 1508 // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height());
1506 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); 1509 //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height());
1507 mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ; 1510 mShortDayLabelsM = mDayLabels[0]->width()-2 < mWidthLongDayLabel ;
1508 updateDayLabels(); 1511 updateDayLabels();
1509 //bool forceUpdate = !updatePossible; 1512 //bool forceUpdate = !updatePossible;
1510 updatePossible = true; 1513 updatePossible = true;
1511 //mWeekLabels[mNumWeeks]->setText( i18n("W")); 1514 //mWeekLabels[mNumWeeks]->setText( i18n("W"));
1512} 1515}
1513 1516
1514void KOMonthView::showContextMenu( Incidence *incidence ) 1517void KOMonthView::showContextMenu( Incidence *incidence )
1515{ 1518{
1516 mContextMenu->showIncidencePopup(incidence); 1519 mContextMenu->showIncidencePopup(incidence);
1517 /* 1520 /*
1518 if( incidence && incidence->type() == "Event" ) { 1521 if( incidence && incidence->type() == "Event" ) {
1519 Event *event = static_cast<Event *>(incidence); 1522 Event *event = static_cast<Event *>(incidence);
1520 mContextMenu->showEventPopup(event); 1523 mContextMenu->showEventPopup(event);
1521 } else { 1524 } else {
1522 kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; 1525 kdDebug() << "MonthView::showContextMenu(): cast failed." << endl;
1523 } 1526 }
1524 */ 1527 */
1525} 1528}
1526MonthViewCell * KOMonthView::selectedCell( ) 1529MonthViewCell * KOMonthView::selectedCell( )
1527{ 1530{
1528 return mSelectedCell; 1531 return mSelectedCell;
1529} 1532}
1530void KOMonthView::setSelectedCell( MonthViewCell *cell ) 1533void KOMonthView::setSelectedCell( MonthViewCell *cell )
1531{ 1534{
1532 // qDebug("KOMonthView::setSelectedCell "); 1535 // qDebug("KOMonthView::setSelectedCell ");
1533 if ( mSelectedCell && mSelectedCell != cell ) { 1536 if ( mSelectedCell && mSelectedCell != cell ) {
1534 MonthViewCell * mvc = mSelectedCell; 1537 MonthViewCell * mvc = mSelectedCell;
1535 mSelectedCell = cell; 1538 mSelectedCell = cell;
1536 mvc->deselect(); 1539 mvc->deselect();
1537 } else 1540 } else
1538 mSelectedCell = cell; 1541 mSelectedCell = cell;
1539 // if ( mSelectedCell ) 1542 // if ( mSelectedCell )
1540 // mSelectedCell->select(); 1543 // mSelectedCell->select();
1541 if ( !mSelectedCell ) 1544 if ( !mSelectedCell )
1542 emit incidenceSelected( 0 ); 1545 emit incidenceSelected( 0 );
1543 else 1546 else
1544 emit incidenceSelected( mSelectedCell->selectedIncidence() ); 1547 emit incidenceSelected( mSelectedCell->selectedIncidence() );
1545} 1548}
1546 1549
1547void KOMonthView::processSelectionChange() 1550void KOMonthView::processSelectionChange()
1548{ 1551{
1549 QPtrList<Incidence> incidences = selectedIncidences(); 1552 QPtrList<Incidence> incidences = selectedIncidences();
1550 if (incidences.count() > 0) { 1553 if (incidences.count() > 0) {
1551 emit incidenceSelected( incidences.first() ); 1554 emit incidenceSelected( incidences.first() );
1552 } else { 1555 } else {
1553 emit incidenceSelected( 0 ); 1556 emit incidenceSelected( 0 );
1554 } 1557 }
1555} 1558}
1556 1559
1557void KOMonthView::clearSelection() 1560void KOMonthView::clearSelection()
1558{ 1561{
1559 if ( mSelectedCell ) { 1562 if ( mSelectedCell ) {
1560 mSelectedCell->deselect(); 1563 mSelectedCell->deselect();
1561 mSelectedCell = 0; 1564 mSelectedCell = 0;
1562 } 1565 }
1563} 1566}
1564void KOMonthView::keyPressEvent ( QKeyEvent * e ) 1567void KOMonthView::keyPressEvent ( QKeyEvent * e )
1565{ 1568{
1566 //qDebug("KOMonthView::keyPressEvent "); 1569 //qDebug("KOMonthView::keyPressEvent ");
1567 switch(e->key()) { 1570 switch(e->key()) {
1568 case Key_Up: 1571 case Key_Up:
1569 { 1572 {
1570 emit prevMonth(); 1573 emit prevMonth();
1571 if ( mShowWeekView ) 1574 if ( mShowWeekView )
1572 mCellsW[0]->setFocus(); 1575 mCellsW[0]->setFocus();
1573 else 1576 else
1574 mCells[0]->setFocus(); 1577 mCells[0]->setFocus();
1575 } 1578 }
1576 e->accept(); 1579 e->accept();
1577 break; 1580 break;
1578 case Key_Down: 1581 case Key_Down:
1579 { 1582 {
1580 emit nextMonth(); 1583 emit nextMonth();
1581 if ( mShowWeekView ) 1584 if ( mShowWeekView )
1582 mCellsW[0]->setFocus(); 1585 mCellsW[0]->setFocus();
1583 else 1586 else
1584 mCells[0]->setFocus(); 1587 mCells[0]->setFocus();
1585 1588
1586 } 1589 }
1587 e->accept(); 1590 e->accept();
1588 break; 1591 break;
1589 case Key_Return: 1592 case Key_Return:
1590 case Key_Enter: 1593 case Key_Enter:
1591 { 1594 {
1592 selectInternalWeekNum ( currentWeek() ); 1595 selectInternalWeekNum ( currentWeek() );
1593 } 1596 }
1594 e->accept(); 1597 e->accept();
1595 break; 1598 break;
1596 default: 1599 default:
1597 e->ignore(); 1600 e->ignore();
1598 break; 1601 break;
1599 } 1602 }
1600} 1603}
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp
index 576c265..5bfe2a1 100644
--- a/korganizer/koprefs.cpp
+++ b/korganizer/koprefs.cpp
@@ -1,490 +1,494 @@
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 <time.h> 24#include <time.h>
25#ifndef _WIN32_ 25#ifndef _WIN32_
26#include <unistd.h> 26#include <unistd.h>
27#endif 27#endif
28#include <qdir.h> 28#include <qdir.h>
29#include <qtextstream.h> 29#include <qtextstream.h>
30#include <qtextcodec.h> 30#include <qtextcodec.h>
31#include <qstring.h> 31#include <qstring.h>
32#include <qregexp.h> 32#include <qregexp.h>
33#include <qfont.h> 33#include <qfont.h>
34#include <qcolor.h> 34#include <qcolor.h>
35#include <qstringlist.h> 35#include <qstringlist.h>
36#include <stdlib.h> 36#include <stdlib.h>
37 37
38#include <kglobal.h> 38#include <kglobal.h>
39#include <kglobalsettings.h>
39#include <kconfig.h> 40#include <kconfig.h>
40#include <klocale.h> 41#include <klocale.h>
41#include <kdebug.h> 42#include <kdebug.h>
42#include <kemailsettings.h> 43#include <kemailsettings.h>
43#include <kstaticdeleter.h> 44#include <kstaticdeleter.h>
44#include <libkdepim/kpimglobalprefs.h> 45#include <libkdepim/kpimglobalprefs.h>
45 46
46#include "koprefs.h" 47#include "koprefs.h"
47#include "mainwindow.h" 48#include "mainwindow.h"
48 49
49KOPrefs *KOPrefs::mInstance = 0; 50KOPrefs *KOPrefs::mInstance = 0;
50static KStaticDeleter<KOPrefs> insd; 51static KStaticDeleter<KOPrefs> insd;
51 52
52KOPrefs::KOPrefs() : 53KOPrefs::KOPrefs() :
53 KPimPrefs("korganizerrc") 54 KPimPrefs("korganizerrc")
54{ 55{
55 mCategoryColors.setAutoDelete(true); 56 mCategoryColors.setAutoDelete(true);
56 fillMailDefaults(); 57 fillMailDefaults();
57 mDefaultCategoryColor = QColor(175,210,255);//196,196,196); 58 mDefaultCategoryColor = QColor(175,210,255);//196,196,196);
58 QColor defaultHolidayColor = QColor(255,0,0); 59 QColor defaultHolidayColor = QColor(255,0,0);
59 QColor defaultHighlightColor = QColor(129,112,255);//64,64,255); 60 QColor defaultHighlightColor = QColor(129,112,255);//64,64,255);
60 QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128); 61 QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128);
61 QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160); 62 QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160);
62 QColor defaultTodoDueTodayColor = QColor(255,220,100); 63 QColor defaultTodoDueTodayColor = QColor(255,220,100);
63 QColor defaultTodoOverdueColor = QColor(255,153,125); 64 QColor defaultTodoOverdueColor = QColor(255,153,125);
64 65
66 /*
65 mTimeBarFont = QFont("helvetica",10);//,QFont::Bold); 67 mTimeBarFont = QFont("helvetica",10);//,QFont::Bold);
66 mDefaultViewFont = QFont("helvetica",10); 68 mDefaultViewFont = QFont("helvetica",10);
67 mDefaultMonthViewFont = QFont("helvetica",8); 69 mDefaultMonthViewFont = QFont("helvetica",8);
68 mMarcusBainsFont= QFont("helvetica",10); 70 mMarcusBainsFont= QFont("helvetica",10);
69 mDateNavigatorFont= QFont("helvetica",10, QFont::Bold); 71 mDateNavigatorFont= QFont("helvetica",10, QFont::Bold);
70 mEditBoxFont = QFont("helvetica",12); 72 mEditBoxFont = QFont("helvetica",12);
71 mJornalViewFont = QFont("helvetica",12); 73 mJornalViewFont = QFont("helvetica",12);
74 */
75
72 76
73 KPrefs::setCurrentGroup("General"); 77 KPrefs::setCurrentGroup("General");
74 78
75 79
76 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); 80 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false);
77 81
78 addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true); 82 addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true);
79 addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true); 83 addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true);
80 addItemBool("ShowIconSearch",&mShowIconSearch,true); 84 addItemBool("ShowIconSearch",&mShowIconSearch,true);
81 addItemBool("ShowIconList",&mShowIconList,true); 85 addItemBool("ShowIconList",&mShowIconList,true);
82 addItemBool("ShowIconDay1",&mShowIconDay1,true); 86 addItemBool("ShowIconDay1",&mShowIconDay1,true);
83 addItemBool("ShowIconDay5",&mShowIconDay5,true); 87 addItemBool("ShowIconDay5",&mShowIconDay5,true);
84 addItemBool("ShowIconDay7",&mShowIconDay7,true); 88 addItemBool("ShowIconDay7",&mShowIconDay7,true);
85 addItemBool("ShowIconMonth",&mShowIconMonth,true); 89 addItemBool("ShowIconMonth",&mShowIconMonth,true);
86 addItemBool("ShowIconTodoview",&mShowIconTodoview,true); 90 addItemBool("ShowIconTodoview",&mShowIconTodoview,true);
87 addItemBool("ShowIconBackFast",&mShowIconBackFast,true); 91 addItemBool("ShowIconBackFast",&mShowIconBackFast,true);
88 addItemBool("ShowIconBack",&mShowIconBack,true); 92 addItemBool("ShowIconBack",&mShowIconBack,true);
89 addItemBool("ShowIconToday",&mShowIconToday,true); 93 addItemBool("ShowIconToday",&mShowIconToday,true);
90 addItemBool("ShowIconForward",&mShowIconForward,true); 94 addItemBool("ShowIconForward",&mShowIconForward,true);
91 addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true); 95 addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true);
92 addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,true); 96 addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,true);
93 addItemBool("ShowIconNextDays",&mShowIconNextDays,true); 97 addItemBool("ShowIconNextDays",&mShowIconNextDays,true);
94 addItemBool("ShowIconNext",&mShowIconNext,true); 98 addItemBool("ShowIconNext",&mShowIconNext,true);
95 addItemBool("ShowIconJournal",&mShowIconJournal,true); 99 addItemBool("ShowIconJournal",&mShowIconJournal,true);
96 addItemBool("ShowIconStretch",&mShowIconStretch,true); 100 addItemBool("ShowIconStretch",&mShowIconStretch,true);
97 addItemInt("LastLoadedLanguage",&mOldLanguage,0); 101 addItemInt("LastLoadedLanguage",&mOldLanguage,0);
98 102
99 addItemBool("AskForQuit",&mAskForQuit,false); 103 addItemBool("AskForQuit",&mAskForQuit,false);
100 104
101#ifndef DESKTOP_VERSION 105#ifndef DESKTOP_VERSION
102 addItemBool("ShowFullMenu",&mShowFullMenu,false); 106 addItemBool("ShowFullMenu",&mShowFullMenu,false);
103#else 107#else
104 addItemBool("ShowFullMenu",&mShowFullMenu,true); 108 addItemBool("ShowFullMenu",&mShowFullMenu,true);
105#endif 109#endif
106 addItemBool("ToolBarHor",&mToolBarHor, true ); 110 addItemBool("ToolBarHor",&mToolBarHor, true );
107 addItemBool("ToolBarUp",&mToolBarUp, false ); 111 addItemBool("ToolBarUp",&mToolBarUp, false );
108 addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false ); 112 addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false );
109 addItemInt("Whats Next Days",&mWhatsNextDays,3); 113 addItemInt("Whats Next Days",&mWhatsNextDays,3);
110 addItemInt("Whats Next Prios",&mWhatsNextPrios,1); 114 addItemInt("Whats Next Prios",&mWhatsNextPrios,1);
111 115
112 addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true); 116 addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true);
113 addItemBool("ShowTimeInAgenda",&mShowTimeInAgenda,true); 117 addItemBool("ShowTimeInAgenda",&mShowTimeInAgenda,true);
114 addItemBool("HideNonStartedTodos",&mHideNonStartedTodos,false); 118 addItemBool("HideNonStartedTodos",&mHideNonStartedTodos,false);
115 addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true); 119 addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true);
116 addItemInt("AllDay Size",&mAllDaySize,28); 120 addItemInt("AllDay Size",&mAllDaySize,28);
117 QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav"; 121 QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav";
118 addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm ); 122 addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm );
119 123
120 addItemStringList("LocationDefaults",&mLocationDefaults ); 124 addItemStringList("LocationDefaults",&mLocationDefaults );
121 addItemStringList("EventSummary User",&mEventSummaryUser); 125 addItemStringList("EventSummary User",&mEventSummaryUser);
122 addItemStringList("TodoSummary User",&mTodoSummaryUser); 126 addItemStringList("TodoSummary User",&mTodoSummaryUser);
123 127
124 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); 128 addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false);
125 addItemBool("Enable Project View",&mEnableProjectView,false); 129 addItemBool("Enable Project View",&mEnableProjectView,false);
126 addItemBool("Auto Save",&mAutoSave,false); 130 addItemBool("Auto Save",&mAutoSave,false);
127 addItemInt("Auto Save Interval",&mAutoSaveInterval,3); 131 addItemInt("Auto Save Interval",&mAutoSaveInterval,3);
128 addItemBool("Confirm Deletes",&mConfirm,true); 132 addItemBool("Confirm Deletes",&mConfirm,true);
129 addItemString("Archive File",&mArchiveFile); 133 addItemString("Archive File",&mArchiveFile);
130 addItemString("Html Export File",&mHtmlExportFile, 134 addItemString("Html Export File",&mHtmlExportFile,
131 QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html")); 135 QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html"));
132 addItemBool("Html With Save",&mHtmlWithSave,false); 136 addItemBool("Html With Save",&mHtmlWithSave,false);
133 137
134 KPrefs::setCurrentGroup("Personal Settings"); 138 KPrefs::setCurrentGroup("Personal Settings");
135 139
136 addItemInt("Mail Client",&mMailClient,MailClientKMail); 140 addItemInt("Mail Client",&mMailClient,MailClientKMail);
137 addItemBool("Use Control Center Email",&mEmailControlCenter,false); 141 addItemBool("Use Control Center Email",&mEmailControlCenter,false);
138 addItemBool("Bcc",&mBcc,false); 142 addItemBool("Bcc",&mBcc,false);
139 143
140 KPrefs::setCurrentGroup("Time & Date"); 144 KPrefs::setCurrentGroup("Time & Date");
141 145
142 146
143 addItemInt("Default Start Time",&mStartTime,10); 147 addItemInt("Default Start Time",&mStartTime,10);
144 addItemInt("Default Duration",&mDefaultDuration,2); 148 addItemInt("Default Duration",&mDefaultDuration,2);
145 addItemInt("Default Alarm Time",&mAlarmTime,3); 149 addItemInt("Default Alarm Time",&mAlarmTime,3);
146 KPrefs::setCurrentGroup("AlarmSettings"); 150 KPrefs::setCurrentGroup("AlarmSettings");
147 addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20); 151 addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20);
148 addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7); 152 addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7);
149 addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5); 153 addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5);
150 addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3); 154 addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3);
151 155
152 156
153 KPrefs::setCurrentGroup("Calendar"); 157 KPrefs::setCurrentGroup("Calendar");
154 158
155 addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar); 159 addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar);
156 160
157 KPrefs::setCurrentGroup("Fonts"); 161 KPrefs::setCurrentGroup("Fonts");
158 // qDebug(" KPrefs::setCurrentGroup(Fonts); "); 162 // qDebug(" KPrefs::setCurrentGroup(Fonts); ");
159 addItemFont("TimeBar Font",&mTimeBarFont); 163 addItemFont("TimeBar Font",&mTimeBarFont,KGlobalSettings::generalFont() );
160 addItemFont("MonthView Font",&mMonthViewFont); 164 addItemFont("MonthView Font",&mMonthViewFont,KGlobalSettings::generalFont());
161 addItemFont("AgendaView Font",&mAgendaViewFont); 165 addItemFont("AgendaView Font",&mAgendaViewFont,KGlobalSettings::generalFont());
162 addItemFont("MarcusBains Font",&mMarcusBainsFont); 166 addItemFont("MarcusBains Font",&mMarcusBainsFont,KGlobalSettings::generalFont());
163 addItemFont("TimeLabels Font",&mTimeLabelsFont); 167 addItemFont("TimeLabels Font",&mTimeLabelsFont,KGlobalSettings::generalFont());
164 addItemFont("TodoView Font",&mTodoViewFont); 168 addItemFont("TodoView Font",&mTodoViewFont,KGlobalSettings::generalFont());
165 addItemFont("ListView Font",&mListViewFont); 169 addItemFont("ListView Font",&mListViewFont,KGlobalSettings::generalFont());
166 addItemFont("DateNavigator Font",&mDateNavigatorFont); 170 addItemFont("DateNavigator Font",&mDateNavigatorFont,KGlobalSettings::generalFont());
167 addItemFont("EditBox Font",&mEditBoxFont); 171 addItemFont("EditBox Font",&mEditBoxFont,KGlobalSettings::generalFont());
168 addItemFont("JournalView Font",&mJornalViewFont); 172 addItemFont("JournalView Font",&mJornalViewFont,KGlobalSettings::generalFont());
169 addItemFont("WhatsNextView Font",&mWhatsNextFont); 173 addItemFont("WhatsNextView Font",&mWhatsNextFont,KGlobalSettings::generalFont());
170 addItemFont("EventView Font",&mEventViewFont); 174 addItemFont("EventView Font",&mEventViewFont,KGlobalSettings::generalFont());
171 175
172 KPrefs::setCurrentGroup("RemoteSyncing"); 176 KPrefs::setCurrentGroup("RemoteSyncing");
173 addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" ); 177 addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" );
174 addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" ); 178 addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" );
175 addItemBool("ShowSyncEvents",&mShowSyncEvents,false); 179 addItemBool("ShowSyncEvents",&mShowSyncEvents,false);
176 addItemInt("LastSyncTime",&mLastSyncTime,0); 180 addItemInt("LastSyncTime",&mLastSyncTime,0);
177 181
178#ifdef _WIN32_ 182#ifdef _WIN32_
179 QString hdp= locateLocal("data","korganizer")+"\\\\"; 183 QString hdp= locateLocal("data","korganizer")+"\\\\";
180#else 184#else
181 QString hdp= locateLocal("data","korganizer")+"/"; 185 QString hdp= locateLocal("data","korganizer")+"/";
182#endif 186#endif
183 187
184 KPrefs::setCurrentGroup("LoadSaveFileNames"); 188 KPrefs::setCurrentGroup("LoadSaveFileNames");
185 189
186 addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" ); 190 addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" );
187 addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" ); 191 addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" );
188 addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" ); 192 addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" );
189 addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); 193 addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" );
190 194
191 195
192 KPrefs::setCurrentGroup("Locale"); 196 KPrefs::setCurrentGroup("Locale");
193 addItemBool("ShortDateInViewer",&mShortDateInViewer,false); 197 addItemBool("ShortDateInViewer",&mShortDateInViewer,false);
194 198
195 199
196 KPrefs::setCurrentGroup("Colors"); 200 KPrefs::setCurrentGroup("Colors");
197 addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor); 201 addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor);
198 addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor); 202 addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor);
199 addItemColor("Event Color",&mEventColor,mDefaultCategoryColor); 203 addItemColor("Event Color",&mEventColor,mDefaultCategoryColor);
200 addItemColor("Todo done Color",&mTodoDoneColor,QColor(111,255,115) ); 204 addItemColor("Todo done Color",&mTodoDoneColor,QColor(111,255,115) );
201 addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor); 205 addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor);
202 addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor); 206 addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor);
203 addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor); 207 addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor);
204 addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor); 208 addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor);
205 addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 )); 209 addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 ));
206 addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 )); 210 addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 ));
207 addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 )); 211 addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 ));
208 addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true); 212 addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true);
209 addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true); 213 addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true);
210 addItemBool("MonthViewWeek",&mMonthViewWeek,false); 214 addItemBool("MonthViewWeek",&mMonthViewWeek,false);
211 addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false); 215 addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false);
212 addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 )); 216 addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 ));
213 addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 )); 217 addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 ));
214 addItemBool("UseAppColors",&mUseAppColors,false); 218 addItemBool("UseAppColors",&mUseAppColors,false);
215 219
216 220
217 221
218 KPrefs::setCurrentGroup("Views"); 222 KPrefs::setCurrentGroup("Views");
219 addItemBool("Show Date Navigator",&mShowDateNavigator,true); 223 addItemBool("Show Date Navigator",&mShowDateNavigator,true);
220 addItemInt("Hour Size",&mHourSize,8); 224 addItemInt("Hour Size",&mHourSize,8);
221 addItemBool("Show Daily Recurrences",&mDailyRecur,true); 225 addItemBool("Show Daily Recurrences",&mDailyRecur,true);
222 addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true); 226 addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true);
223 addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true); 227 addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true);
224 addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true); 228 addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true);
225 addItemBool("ShowShortMonthName",&mMonthShowShort,false); 229 addItemBool("ShowShortMonthName",&mMonthShowShort,false);
226 addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true); 230 addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true);
227#ifdef DESKTOP_VERION 231#ifdef DESKTOP_VERION
228 addItemBool("Enable ToolTips",&mEnableToolTips,true); 232 addItemBool("Enable ToolTips",&mEnableToolTips,true);
229#else 233#else
230 addItemBool("Enable ToolTips",&mEnableToolTips,false); 234 addItemBool("Enable ToolTips",&mEnableToolTips,false);
231#endif 235#endif
232 addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false); 236 addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false);
233 addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false); 237 addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false);
234 addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true); 238 addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true);
235 addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true); 239 addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true);
236 addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,true); 240 addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,true);
237 addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false); 241 addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false);
238 addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false); 242 addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false);
239 addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true); 243 addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true);
240 addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true); 244 addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true);
241 addItemBool("WNViewShowsParents",&mWNViewShowsParents,true);; 245 addItemBool("WNViewShowsParents",&mWNViewShowsParents,true);;
242 addItemBool("WNViewShowsPast",&mWNViewShowsPast,true); 246 addItemBool("WNViewShowsPast",&mWNViewShowsPast,true);
243 addItemBool("WNViewShowLocation",&mWNViewShowLocation,false); 247 addItemBool("WNViewShowLocation",&mWNViewShowLocation,false);
244 addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false); 248 addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false);
245 addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true); 249 addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true);
246 addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false); 250 addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false);
247 addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false); 251 addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false);
248 addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,true); 252 addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,true);
249 addItemBool("MonthViewUsesBigFont",&mMonthViewUsesBigFont,true); 253 addItemBool("MonthViewUsesBigFont",&mMonthViewUsesBigFont,true);
250 addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false); 254 addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false);
251 addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false); 255 addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false);
252#ifdef DESKTOP_VERSION 256#ifdef DESKTOP_VERSION
253 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true); 257 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true);
254#else 258#else
255 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false); 259 addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false);
256#endif 260#endif
257 addItemInt("Day Begins",&mDayBegins,7); 261 addItemInt("Day Begins",&mDayBegins,7);
258 addItemInt("Working Hours Start",&mWorkingHoursStart,8); 262 addItemInt("Working Hours Start",&mWorkingHoursStart,8);
259 addItemInt("Working Hours End",&mWorkingHoursEnd,17); 263 addItemInt("Working Hours End",&mWorkingHoursEnd,17);
260 addItemBool("Exclude Holidays",&mExcludeHolidays,true); 264 addItemBool("Exclude Holidays",&mExcludeHolidays,true);
261 addItemBool("Exclude Saturdays",&mExcludeSaturdays,true); 265 addItemBool("Exclude Saturdays",&mExcludeSaturdays,true);
262 266
263 addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false); 267 addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false);
264 addItemBool("Full View Month",&mFullViewMonth,true); 268 addItemBool("Full View Month",&mFullViewMonth,true);
265 addItemBool("Full View Todo",&mFullViewTodo,true); 269 addItemBool("Full View Todo",&mFullViewTodo,true);
266 addItemBool("Quick Todo",&mEnableQuickTodo,false); 270 addItemBool("Quick Todo",&mEnableQuickTodo,false);
267 271
268 addItemInt("Next X Days",&mNextXDays,3); 272 addItemInt("Next X Days",&mNextXDays,3);
269 273
270 KPrefs::setCurrentGroup("Printer"); 274 KPrefs::setCurrentGroup("Printer");
271 275
272 KPrefs::setCurrentGroup("Layout"); 276 KPrefs::setCurrentGroup("Layout");
273 277
274 addItemBool("CompactDialogs",&mCompactDialogs,false); 278 addItemBool("CompactDialogs",&mCompactDialogs,false);
275 addItemBool("VerticalScreen",&mVerticalScreen,true); 279 addItemBool("VerticalScreen",&mVerticalScreen,true);
276 280
277 KPrefs::setCurrentGroup("KOrganizer Plugins"); 281 KPrefs::setCurrentGroup("KOrganizer Plugins");
278 282
279 addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays"); 283 addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays");
280 284
281 KPrefs::setCurrentGroup("Group Scheduling"); 285 KPrefs::setCurrentGroup("Group Scheduling");
282 286
283 addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail); 287 addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail);
284 addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend); 288 addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend);
285 addItemStringList("AdditionalMails",&mAdditionalMails,""); 289 addItemStringList("AdditionalMails",&mAdditionalMails,"");
286 addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto); 290 addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto);
287 addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto); 291 addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto);
288 addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto); 292 addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto);
289 addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto); 293 addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto);
290 addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto); 294 addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto);
291 295
292 KPrefs::setCurrentGroup( "Editors" ); 296 KPrefs::setCurrentGroup( "Editors" );
293 297
294 addItemStringList( "EventTemplates", &mEventTemplates ); 298 addItemStringList( "EventTemplates", &mEventTemplates );
295 addItemStringList( "TodoTemplates", &mTodoTemplates ); 299 addItemStringList( "TodoTemplates", &mTodoTemplates );
296 300
297 addItemInt("DestinationPolicy",&mDestination,standardDestination); 301 addItemInt("DestinationPolicy",&mDestination,standardDestination);
298 302
299 303
300 304
301} 305}
302 306
303 307
304KOPrefs::~KOPrefs() 308KOPrefs::~KOPrefs()
305{ 309{
306 if (mInstance == this) 310 if (mInstance == this)
307 mInstance = insd.setObject(0); 311 mInstance = insd.setObject(0);
308 312
309 //qDebug("KOPrefs::~KOPrefs() "); 313 //qDebug("KOPrefs::~KOPrefs() ");
310} 314}
311 315
312 316
313KOPrefs *KOPrefs::instance() 317KOPrefs *KOPrefs::instance()
314{ 318{
315 if (!mInstance) { 319 if (!mInstance) {
316 mInstance = insd.setObject(new KOPrefs()); 320 mInstance = insd.setObject(new KOPrefs());
317 mInstance->readConfig(); 321 mInstance->readConfig();
318 } 322 }
319 323
320 return mInstance; 324 return mInstance;
321} 325}
322 326
323void KOPrefs::usrSetDefaults() 327void KOPrefs::usrSetDefaults()
324{ 328{
325 329
326} 330}
327 331
328void KOPrefs::fillMailDefaults() 332void KOPrefs::fillMailDefaults()
329{ 333{
330 if (mName.isEmpty()) mName = i18n("Anonymous"); 334 if (mName.isEmpty()) mName = i18n("Anonymous");
331 if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); 335 if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere");
332} 336}
333 337
334void KOPrefs::setTimeZoneIdDefault() 338void KOPrefs::setTimeZoneIdDefault()
335{ 339{
336 ; 340 ;
337} 341}
338 342
339void KOPrefs::setAllDefaults() 343void KOPrefs::setAllDefaults()
340{ 344{
341 setCategoryDefaults(); 345 setCategoryDefaults();
342 mEventSummaryUser = getDefaultList() ; 346 mEventSummaryUser = getDefaultList() ;
343 mTodoSummaryUser = getDefaultList() ; 347 mTodoSummaryUser = getDefaultList() ;
344 mLocationDefaults = getLocationDefaultList(); 348 mLocationDefaults = getLocationDefaultList();
345} 349}
346 350
347void KOPrefs::setCategoryDefaults() 351void KOPrefs::setCategoryDefaults()
348{ 352{
349 mCustomCategories.clear(); 353 mCustomCategories.clear();
350 mCustomCategories = getDefaultList(); 354 mCustomCategories = getDefaultList();
351 355
352 QStringList::Iterator it; 356 QStringList::Iterator it;
353 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { 357 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) {
354 setCategoryColor(*it,mDefaultCategoryColor); 358 setCategoryColor(*it,mDefaultCategoryColor);
355 } 359 }
356} 360}
357QStringList KOPrefs::getLocationDefaultList() 361QStringList KOPrefs::getLocationDefaultList()
358{ 362{
359 QStringList retval ; 363 QStringList retval ;
360 retval << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach") 364 retval << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach")
361 << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") 365 << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room")
362 << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten") 366 << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten")
363 << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ; 367 << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ;
364 // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") 368 // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("")
365 369
366 retval.sort(); 370 retval.sort();
367 return retval; 371 return retval;
368} 372}
369QStringList KOPrefs::getDefaultList() 373QStringList KOPrefs::getDefaultList()
370{ 374{
371 QStringList retval ; 375 QStringList retval ;
372 retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Business Travel") << i18n("Cinema") << i18n("Customer") 376 retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Business Travel") << i18n("Cinema") << i18n("Customer")
373 << i18n("Break")<< i18n("Breakfast")<< i18n("Competition")<< i18n("Dinner") 377 << i18n("Break")<< i18n("Breakfast")<< i18n("Competition")<< i18n("Dinner")
374 << i18n("Education")<< i18n("Family") << i18n("Favorites") << i18n("Festival")<< i18n("Fishing")<< i18n("Flight") << i18n("Gifts") 378 << i18n("Education")<< i18n("Family") << i18n("Favorites") << i18n("Festival")<< i18n("Fishing")<< i18n("Flight") << i18n("Gifts")
375 << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") << i18n("Hiking") << i18n("Hunting") << i18n("Key Customer") << i18n("Kids") 379 << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") << i18n("Hiking") << i18n("Hunting") << i18n("Key Customer") << i18n("Kids")
376 << i18n("Lunch") << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner")<< i18n("Party") << i18n("Personal") << i18n("Personal Travel") 380 << i18n("Lunch") << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner")<< i18n("Party") << i18n("Personal") << i18n("Personal Travel")
377 << i18n("PHB") << i18n("Phone Calls") << i18n("Projects") << i18n("Recurring") << i18n("School") << i18n("Shopping") 381 << i18n("PHB") << i18n("Phone Calls") << i18n("Projects") << i18n("Recurring") << i18n("School") << i18n("Shopping")
378 << i18n("Speach") << i18n("Special Occasion") << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV")<< i18n("University") 382 << i18n("Speach") << i18n("Special Occasion") << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV")<< i18n("University")
379 << i18n("Vacation") << i18n("VIP") << i18n("SyncEvent") ; 383 << i18n("Vacation") << i18n("VIP") << i18n("SyncEvent") ;
380 retval.sort(); 384 retval.sort();
381 //qDebug("cat %s ", retval.join("-").latin1()); 385 //qDebug("cat %s ", retval.join("-").latin1());
382 return retval; 386 return retval;
383} 387}
384 388
385void KOPrefs::usrReadConfig() 389void KOPrefs::usrReadConfig()
386{ 390{
387 config()->setGroup("General"); 391 config()->setGroup("General");
388 392
389 //qDebug("KOPrefs::usrReadConfig() "); 393 //qDebug("KOPrefs::usrReadConfig() ");
390 mCustomCategories = config()->readListEntry("Custom Categories"); 394 mCustomCategories = config()->readListEntry("Custom Categories");
391 mOldLoadedLanguage = mOldLanguage ; 395 mOldLoadedLanguage = mOldLanguage ;
392 mOldLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage; 396 mOldLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage;
393 if (mLocationDefaults.isEmpty()) { 397 if (mLocationDefaults.isEmpty()) {
394 mLocationDefaults = getLocationDefaultList(); 398 mLocationDefaults = getLocationDefaultList();
395 } 399 }
396 400
397 if (mEventSummaryUser.isEmpty()) { 401 if (mEventSummaryUser.isEmpty()) {
398 mEventSummaryUser = getDefaultList() ; 402 mEventSummaryUser = getDefaultList() ;
399 } 403 }
400 if (mTodoSummaryUser.isEmpty()) { 404 if (mTodoSummaryUser.isEmpty()) {
401 mTodoSummaryUser = getDefaultList() ; 405 mTodoSummaryUser = getDefaultList() ;
402 } 406 }
403 407
404 if (mCustomCategories.isEmpty()) setCategoryDefaults(); 408 if (mCustomCategories.isEmpty()) setCategoryDefaults();
405 409
406 config()->setGroup("Personal Settings"); 410 config()->setGroup("Personal Settings");
407 mName = config()->readEntry("user_name",""); 411 mName = config()->readEntry("user_name","");
408 mEmail = config()->readEntry("user_email",""); 412 mEmail = config()->readEntry("user_email","");
409 fillMailDefaults(); 413 fillMailDefaults();
410 414
411 config()->setGroup("Category Colors"); 415 config()->setGroup("Category Colors");
412 QStringList::Iterator it; 416 QStringList::Iterator it;
413 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { 417 for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) {
414 setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor)); 418 setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor));
415 419
416 } 420 }
417 421
418 KPimPrefs::usrReadConfig(); 422 KPimPrefs::usrReadConfig();
419} 423}
420 424
421 425
422void KOPrefs::usrWriteConfig() 426void KOPrefs::usrWriteConfig()
423{ 427{
424 config()->setGroup("General"); 428 config()->setGroup("General");
425 config()->writeEntry("Custom Categories",mCustomCategories); 429 config()->writeEntry("Custom Categories",mCustomCategories);
426 430
427 config()->setGroup("Personal Settings"); 431 config()->setGroup("Personal Settings");
428 config()->writeEntry("user_name",mName); 432 config()->writeEntry("user_name",mName);
429 config()->writeEntry("user_email",mEmail); 433 config()->writeEntry("user_email",mEmail);
430 434
431 config()->setGroup("Category Colors"); 435 config()->setGroup("Category Colors");
432 QDictIterator<QColor> it(mCategoryColors); 436 QDictIterator<QColor> it(mCategoryColors);
433 while (it.current()) { 437 while (it.current()) {
434 config()->writeEntry(it.currentKey(),*(it.current())); 438 config()->writeEntry(it.currentKey(),*(it.current()));
435 ++it; 439 ++it;
436 } 440 }
437 441
438 442
439 KPimPrefs::usrWriteConfig(); 443 KPimPrefs::usrWriteConfig();
440} 444}
441 445
442void KOPrefs::setCategoryColor(QString cat,const QColor & color) 446void KOPrefs::setCategoryColor(QString cat,const QColor & color)
443{ 447{
444 mCategoryColors.replace(cat,new QColor(color)); 448 mCategoryColors.replace(cat,new QColor(color));
445} 449}
446 450
447QColor *KOPrefs::categoryColor(QString cat) 451QColor *KOPrefs::categoryColor(QString cat)
448{ 452{
449 QColor *color = 0; 453 QColor *color = 0;
450 454
451 if (!cat.isEmpty()) color = mCategoryColors[cat]; 455 if (!cat.isEmpty()) color = mCategoryColors[cat];
452 456
453 if (color) return color; 457 if (color) return color;
454 else return &mDefaultCategoryColor; 458 else return &mDefaultCategoryColor;
455} 459}
456 460
457void KOPrefs::setFullName(const QString &name) 461void KOPrefs::setFullName(const QString &name)
458{ 462{
459 mName = name; 463 mName = name;
460} 464}
461 465
462void KOPrefs::setEmail(const QString &email) 466void KOPrefs::setEmail(const QString &email)
463{ 467{
464 //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() ); 468 //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() );
465 mEmail = email; 469 mEmail = email;
466} 470}
467 471
468QString KOPrefs::fullName() 472QString KOPrefs::fullName()
469{ 473{
470 if (mEmailControlCenter) { 474 if (mEmailControlCenter) {
471 KEMailSettings settings; 475 KEMailSettings settings;
472 return settings.getSetting(KEMailSettings::RealName); 476 return settings.getSetting(KEMailSettings::RealName);
473 } else { 477 } else {
474 return mName; 478 return mName;
475 } 479 }
476} 480}
477 481
478QString KOPrefs::email() 482QString KOPrefs::email()
479{ 483{
480 if (mEmailControlCenter) { 484 if (mEmailControlCenter) {
481 KEMailSettings settings; 485 KEMailSettings settings;
482 return settings.getSetting(KEMailSettings::EmailAddress); 486 return settings.getSetting(KEMailSettings::EmailAddress);
483 } else { 487 } else {
484 return mEmail; 488 return mEmail;
485 } 489 }
486} 490}
487KConfig* KOPrefs::getConfig() 491KConfig* KOPrefs::getConfig()
488{ 492{
489 return config(); 493 return config();
490} 494}
diff --git a/korganizer/ktimeedit.cpp b/korganizer/ktimeedit.cpp
index 5222ac9..61a0931 100644
--- a/korganizer/ktimeedit.cpp
+++ b/korganizer/ktimeedit.cpp
@@ -1,474 +1,476 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 1999 Preston Brown, Ian Dawes 3 Copyright (c) 1999 Preston Brown, Ian Dawes
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 <qkeycode.h> 24#include <qkeycode.h>
25#include <qcombobox.h> 25#include <qcombobox.h>
26#include <qdatetime.h> 26#include <qdatetime.h>
27#include <qlineedit.h> 27#include <qlineedit.h>
28#include <qlistbox.h> 28#include <qlistbox.h>
29#include <qapplication.h> 29#include <qapplication.h>
30 30
31#include <kmessagebox.h> 31#include <kmessagebox.h>
32#include <kglobal.h> 32#include <kglobal.h>
33#include <kdebug.h> 33#include <kdebug.h>
34#include <klocale.h> 34#include <klocale.h>
35#include <kpimglobalprefs.h> 35#include <kpimglobalprefs.h>
36 36
37#include "ktimeedit.h" 37#include "ktimeedit.h"
38#include "koprefs.h" 38#include "koprefs.h"
39#include <qvalidator.h> 39#include <qvalidator.h>
40 40
41// Validator for a time value with only hours and minutes (no seconds) 41// Validator for a time value with only hours and minutes (no seconds)
42// Mostly locale aware. Author: David Faure <faure@kde.org> 42// Mostly locale aware. Author: David Faure <faure@kde.org>
43 43
44// KTimeWidget/QTimeEdit provide nicer editing, but don't provide a combobox. 44// KTimeWidget/QTimeEdit provide nicer editing, but don't provide a combobox.
45// Difficult to get all in one... 45// Difficult to get all in one...
46// But Qt-3.2 will offer QLineEdit::setMask, so a "99:99" mask would help. 46// But Qt-3.2 will offer QLineEdit::setMask, so a "99:99" mask would help.
47KOTimeEdit::KOTimeEdit(QWidget *parent, QTime qt, const char *name) 47KOTimeEdit::KOTimeEdit(QWidget *parent, QTime qt, const char *name)
48 : QComboBox(TRUE, parent, name) 48 : QComboBox(TRUE, parent, name)
49{ 49{
50 setInsertionPolicy(NoInsertion); 50 setInsertionPolicy(NoInsertion);
51 mFlagKeyPressed = false; 51 mFlagKeyPressed = false;
52 52 if ( QApplication::desktop()->height() <= 480 ) {
53 if ( QApplication::desktop()->width() < 650 )
54 setSizeLimit ( 6 ); 53 setSizeLimit ( 6 );
55 mTime = qt; 54 } else {
55 setSizeLimit ( 12 );
56 }
57 mTime = qt;
56 58
57// mNoTimeString = i18n("No Time"); 59// mNoTimeString = i18n("No Time");
58// insertItem( mNoTimeString ); 60// insertItem( mNoTimeString );
59 61
60 // Fill combo box with selection of times in localized format. 62 // Fill combo box with selection of times in localized format.
61 QTime timeEntry(0,0,0); 63 QTime timeEntry(0,0,0);
62 do { 64 do {
63 insertItem(KGlobal::locale()->formatTime(timeEntry)); 65 insertItem(KGlobal::locale()->formatTime(timeEntry));
64 timeEntry = timeEntry.addSecs(60*15); 66 timeEntry = timeEntry.addSecs(60*15);
65 } while (!timeEntry.isNull()); 67 } while (!timeEntry.isNull());
66 // Add end of day. 68 // Add end of day.
67 insertItem( KGlobal::locale()->formatTime( QTime( 23, 59, 59 ) ) ); 69 insertItem( KGlobal::locale()->formatTime( QTime( 23, 59, 59 ) ) );
68 70
69 updateText(); 71 updateText();
70 setFocusPolicy(QWidget::StrongFocus); 72 setFocusPolicy(QWidget::StrongFocus);
71 73
72 connect(this, SIGNAL(activated(int)), this, SLOT(activ(int))); 74 connect(this, SIGNAL(activated(int)), this, SLOT(activ(int)));
73 connect(this, SIGNAL(highlighted(int)), this, SLOT(hilit(int))); 75 connect(this, SIGNAL(highlighted(int)), this, SLOT(hilit(int)));
74 connect(this,SIGNAL(textChanged(const QString&)),this,SLOT(changedText())); 76 connect(this,SIGNAL(textChanged(const QString&)),this,SLOT(changedText()));
75 QFontMetrics fm ( font() ); 77 QFontMetrics fm ( font() );
76 QString timeString = "24:00"; 78 QString timeString = "24:00";
77 if ( KPimGlobalPrefs::instance()->mPreferredTime == 1 ) 79 if ( KPimGlobalPrefs::instance()->mPreferredTime == 1 )
78 timeString = "02:00pm"; 80 timeString = "02:00pm";
79 int addSpace = 32; 81 int addSpace = 32;
80 if ( QApplication::desktop()->width() > 320 ) 82 if ( QApplication::desktop()->width() > 320 )
81 timeString += ":00"; 83 timeString += ":00";
82 setFixedWidth(fm.width( timeString ) + 32 ); 84 setFixedWidth(fm.width( timeString ) + 32 );
83 85
84 // Highlight Background and Textcolor change from default 86 // Highlight Background and Textcolor change from default
85 QPalette palette = QWidget::palette(); 87 QPalette palette = QWidget::palette();
86 unsigned char red, green, blue; 88 unsigned char red, green, blue;
87 red = palette.color( QPalette::Normal , QColorGroup::Background ).red() - 10; 89 red = palette.color( QPalette::Normal , QColorGroup::Background ).red() - 10;
88 green = palette.color( QPalette::Normal , QColorGroup::Background ).green() - 10; 90 green = palette.color( QPalette::Normal , QColorGroup::Background ).green() - 10;
89 blue = palette.color( QPalette::Normal , QColorGroup::Background ).blue() - 10; 91 blue = palette.color( QPalette::Normal , QColorGroup::Background ).blue() - 10;
90 palette.setColor( QColorGroup::Highlight, QColor(red,green,blue) ); 92 palette.setColor( QColorGroup::Highlight, QColor(red,green,blue) );
91 palette.setColor( QColorGroup::HighlightedText, palette.color( QPalette::Normal , QColorGroup::Foreground ) ); 93 palette.setColor( QColorGroup::HighlightedText, palette.color( QPalette::Normal , QColorGroup::Foreground ) );
92 setPalette( palette ); 94 setPalette( palette );
93} 95}
94 96
95KOTimeEdit::~KOTimeEdit() 97KOTimeEdit::~KOTimeEdit()
96{ 98{
97} 99}
98 100
99bool KOTimeEdit::hasTime() const 101bool KOTimeEdit::hasTime() const
100{ 102{
101 // Can't happen 103 // Can't happen
102 if ( currentText().isEmpty() ) return false; 104 if ( currentText().isEmpty() ) return false;
103 //if ( currentText() == mNoTimeString ) return false; 105 //if ( currentText() == mNoTimeString ) return false;
104 106
105 return true; // always 107 return true; // always
106} 108}
107 109
108QTime KOTimeEdit::getTime() const 110QTime KOTimeEdit::getTime() const
109{ 111{
110 return KGlobal::locale()->readTime(currentText()); 112 return KGlobal::locale()->readTime(currentText());
111} 113}
112/* 114/*
113QSizePolicy KOTimeEdit::sizePolicy() const 115QSizePolicy KOTimeEdit::sizePolicy() const
114{ 116{
115 // Set size policy to Fixed, because edit cannot contain more text than the 117 // Set size policy to Fixed, because edit cannot contain more text than the
116 // string representing the time. It doesn't make sense to provide more space. 118 // string representing the time. It doesn't make sense to provide more space.
117 QSizePolicy sizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); 119 QSizePolicy sizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
118 120
119 return sizePolicy; 121 return sizePolicy;
120} 122}
121*/ 123*/
122void KOTimeEdit::setTime(QTime newTime) 124void KOTimeEdit::setTime(QTime newTime)
123{ 125{
124 if ( mTime != newTime ) 126 if ( mTime != newTime )
125 { 127 {
126 mTime = newTime; 128 mTime = newTime;
127 updateText(); 129 updateText();
128 } 130 }
129 131
130} 132}
131 133
132void KOTimeEdit::activ(int i) 134void KOTimeEdit::activ(int i)
133{ 135{
134 // The last entry, 23:59, is a special case 136 // The last entry, 23:59, is a special case
135 if( i == count() - 1 ) 137 if( i == count() - 1 )
136 mTime = QTime( 23, 59, 0 ); 138 mTime = QTime( 23, 59, 0 );
137 else 139 else
138 mTime = QTime(0,0,0).addSecs(i*15*60); 140 mTime = QTime(0,0,0).addSecs(i*15*60);
139 emit timeChanged(mTime); 141 emit timeChanged(mTime);
140} 142}
141 143
142void KOTimeEdit::hilit(int ) 144void KOTimeEdit::hilit(int )
143{ 145{
144 // we don't currently need to do anything here. 146 // we don't currently need to do anything here.
145} 147}
146 148
147void KOTimeEdit::addTime(QTime qt, bool update) 149void KOTimeEdit::addTime(QTime qt, bool update)
148{ 150{
149 // Calculate the new time. 151 // Calculate the new time.
150 //qDebug("add h %d min %d ", qt.hour(),qt.minute() ); 152 //qDebug("add h %d min %d ", qt.hour(),qt.minute() );
151 mTime = mTime.addSecs(qt.minute()*60+qt.hour()*3600); 153 mTime = mTime.addSecs(qt.minute()*60+qt.hour()*3600);
152 // if ( update ) 154 // if ( update )
153 updateText(); 155 updateText();
154 emit timeChanged(mTime); 156 emit timeChanged(mTime);
155} 157}
156 158
157void KOTimeEdit::subTime(QTime qt, bool update) 159void KOTimeEdit::subTime(QTime qt, bool update)
158{ 160{
159 int h, m; 161 int h, m;
160 //qDebug("sub h %d min %d ", qt.hour(),qt.minute() ); 162 //qDebug("sub h %d min %d ", qt.hour(),qt.minute() );
161 163
162 mTime = mTime.addSecs(-(qt.minute()*60+qt.hour()*3600)); 164 mTime = mTime.addSecs(-(qt.minute()*60+qt.hour()*3600));
163 // store the newly calculated time. 165 // store the newly calculated time.
164 // mTime.setHMS(h, m, 0); 166 // mTime.setHMS(h, m, 0);
165 //if ( update ) 167 //if ( update )
166 updateText(); 168 updateText();
167 emit timeChanged(mTime); 169 emit timeChanged(mTime);
168} 170}
169 171
170// void KOTimeEdit::mouseReleaseEvent ( QMouseEvent * ) 172// void KOTimeEdit::mouseReleaseEvent ( QMouseEvent * )
171// { 173// {
172// qDebug("mouseReleaseEvent ( QMouseEvent * ) "); 174// qDebug("mouseReleaseEvent ( QMouseEvent * ) ");
173// } 175// }
174 176
175// void KOTimeEdit::focusInEvent ( QFocusEvent * ) 177// void KOTimeEdit::focusInEvent ( QFocusEvent * )
176// { 178// {
177// qDebug("focusInEvent ( QFocusEvent * ) "); 179// qDebug("focusInEvent ( QFocusEvent * ) ");
178// } 180// }
179 181
180void KOTimeEdit::keyReleaseEvent(QKeyEvent *e) 182void KOTimeEdit::keyReleaseEvent(QKeyEvent *e)
181{ 183{
182 if ( !e->isAutoRepeat() ) { 184 if ( !e->isAutoRepeat() ) {
183 mFlagKeyPressed = false; 185 mFlagKeyPressed = false;
184 } 186 }
185 187
186} 188}
187void KOTimeEdit::setSelect( int from, int to ) 189void KOTimeEdit::setSelect( int from, int to )
188{ 190{
189 if ( KOPrefs::instance()->mHightlightDateTimeEdit) 191 if ( KOPrefs::instance()->mHightlightDateTimeEdit)
190 lineEdit()->setSelection( from , to ); 192 lineEdit()->setSelection( from , to );
191} 193}
192 194
193 195
194void KOTimeEdit::keyPressEvent(QKeyEvent *e) 196void KOTimeEdit::keyPressEvent(QKeyEvent *e)
195{ 197{
196 198
197 qApp->processEvents(); 199 qApp->processEvents();
198 bool hour12Format = ( KPimGlobalPrefs::instance()->mPreferredTime == 1 ); 200 bool hour12Format = ( KPimGlobalPrefs::instance()->mPreferredTime == 1 );
199 int maxpos = hour12Format?7:5; 201 int maxpos = hour12Format?7:5;
200 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 202 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
201 e->ignore(); 203 e->ignore();
202 // qDebug(" ignore %d",e->isAutoRepeat() ); 204 // qDebug(" ignore %d",e->isAutoRepeat() );
203 return; 205 return;
204 } 206 }
205 if (! e->isAutoRepeat() ) { 207 if (! e->isAutoRepeat() ) {
206 mFlagKeyPressed = true; 208 mFlagKeyPressed = true;
207 } 209 }
208 // Tap -> Focus Next Widget 210 // Tap -> Focus Next Widget
209 if ( e->key() == Key_Tab ) { 211 if ( e->key() == Key_Tab ) {
210 QComboBox::keyPressEvent(e); 212 QComboBox::keyPressEvent(e);
211 return; 213 return;
212 } 214 }
213 215
214 // save Text from QLineEdit and CursorPosition 216 // save Text from QLineEdit and CursorPosition
215 QString text = lineEdit()->text(); 217 QString text = lineEdit()->text();
216 int cpos = lineEdit()->cursorPosition(); 218 int cpos = lineEdit()->cursorPosition();
217 // qDebug("cpos %d ", cpos); 219 // qDebug("cpos %d ", cpos);
218 220
219 // Switch for arrows, backspace and escape 221 // Switch for arrows, backspace and escape
220 switch(e->key()) { 222 switch(e->key()) {
221 case Key_Escape: 223 case Key_Escape:
222 lineEdit()->deselect(); 224 lineEdit()->deselect();
223 case Key_Tab: 225 case Key_Tab:
224 QComboBox::keyPressEvent(e); 226 QComboBox::keyPressEvent(e);
225 break; 227 break;
226 case Key_Up: 228 case Key_Up:
227 if ( e->state () == Qt::ControlButton ) { 229 if ( e->state () == Qt::ControlButton ) {
228 addTime(QTime(0,15,0), false ); 230 addTime(QTime(0,15,0), false );
229 lineEdit()->setCursorPosition(3); 231 lineEdit()->setCursorPosition(3);
230 setSelect( 3 , 2 ); 232 setSelect( 3 , 2 );
231 } 233 }
232 else 234 else
233 if ( e->state () == Qt::ShiftButton ) { 235 if ( e->state () == Qt::ShiftButton ) {
234 addTime(QTime(1,0,0), false ); 236 addTime(QTime(1,0,0), false );
235 lineEdit()->setCursorPosition(0); 237 lineEdit()->setCursorPosition(0);
236 setSelect( 0 , 2 ); 238 setSelect( 0 , 2 );
237 } 239 }
238 else 240 else
239 // switch time up, cursor location depend 241 // switch time up, cursor location depend
240 switch (cpos) { 242 switch (cpos) {
241 case 7: 243 case 7:
242 case 6: 244 case 6:
243 case 5: 245 case 5:
244 if(!hour12Format) { 246 if(!hour12Format) {
245 lineEdit()->setCursorPosition(cpos = 4); 247 lineEdit()->setCursorPosition(cpos = 4);
246 } else { 248 } else {
247 addTime(QTime(12,0,0), false ); 249 addTime(QTime(12,0,0), false );
248 setSelect ( 5 , 2 ); 250 setSelect ( 5 , 2 );
249 break; 251 break;
250 } 252 }
251 case 4: 253 case 4:
252 addTime(QTime(0,1,0), false ); 254 addTime(QTime(0,1,0), false );
253 setSelect ( cpos , 1 ); 255 setSelect ( cpos , 1 );
254 break; 256 break;
255 case 3: 257 case 3:
256 addTime(QTime(0,10,0), false ); 258 addTime(QTime(0,10,0), false );
257 setSelect ( cpos , 1 ); 259 setSelect ( cpos , 1 );
258 break; 260 break;
259 case 2: 261 case 2:
260 lineEdit()->setCursorPosition(--cpos); 262 lineEdit()->setCursorPosition(--cpos);
261 case 1: 263 case 1:
262 case 0: 264 case 0:
263 addTime(QTime(1,0,0), false ); 265 addTime(QTime(1,0,0), false );
264 setSelect ( 0, 2 ); 266 setSelect ( 0, 2 );
265 break; 267 break;
266 } 268 }
267 break; 269 break;
268 case Key_Down: 270 case Key_Down:
269 if ( e->state () == Qt::ControlButton ) { 271 if ( e->state () == Qt::ControlButton ) {
270 subTime(QTime(0,15,0), false ); 272 subTime(QTime(0,15,0), false );
271 lineEdit()->setCursorPosition(3); 273 lineEdit()->setCursorPosition(3);
272 setSelect( 3 , 2 ); 274 setSelect( 3 , 2 );
273 } 275 }
274 else 276 else
275 if ( e->state () == Qt::ShiftButton ) { 277 if ( e->state () == Qt::ShiftButton ) {
276 subTime(QTime(1,0,0), false ); 278 subTime(QTime(1,0,0), false );
277 lineEdit()->setCursorPosition(0); 279 lineEdit()->setCursorPosition(0);
278 setSelect( 0 , 2 ); 280 setSelect( 0 , 2 );
279 } 281 }
280 else 282 else
281 // switch time down, cursor location depend 283 // switch time down, cursor location depend
282 switch (cpos) { 284 switch (cpos) {
283 case 7: 285 case 7:
284 case 6: 286 case 6:
285 case 5: 287 case 5:
286 if(!hour12Format) { 288 if(!hour12Format) {
287 lineEdit()->setCursorPosition(cpos = 4); 289 lineEdit()->setCursorPosition(cpos = 4);
288 } else { 290 } else {
289 subTime(QTime(12,0,0), false ); 291 subTime(QTime(12,0,0), false );
290 setSelect ( 5 , 2 ); 292 setSelect ( 5 , 2 );
291 break; 293 break;
292 } 294 }
293 case 4: 295 case 4:
294 subTime(QTime(0,1,0), false ); 296 subTime(QTime(0,1,0), false );
295 setSelect ( cpos , 1 ); 297 setSelect ( cpos , 1 );
296 break; 298 break;
297 case 3: 299 case 3:
298 subTime(QTime(0,10,0), false ); 300 subTime(QTime(0,10,0), false );
299 setSelect ( cpos , 1 ); 301 setSelect ( cpos , 1 );
300 break; 302 break;
301 case 2: 303 case 2:
302 lineEdit()->setCursorPosition(--cpos); 304 lineEdit()->setCursorPosition(--cpos);
303 case 1: 305 case 1:
304 case 0: 306 case 0:
305 subTime(QTime(1,0,0), false ); 307 subTime(QTime(1,0,0), false );
306 setSelect ( 0 , 2 ); 308 setSelect ( 0 , 2 );
307 break; 309 break;
308 } 310 }
309 break; 311 break;
310 // set cursor to correct place 312 // set cursor to correct place
311 case Key_Left: 313 case Key_Left:
312 if ( cpos == 3 ) 314 if ( cpos == 3 )
313 --cpos; 315 --cpos;
314 if ( cpos > 0) { 316 if ( cpos > 0) {
315 lineEdit()->setCursorPosition(--cpos); 317 lineEdit()->setCursorPosition(--cpos);
316 setSelect ( cpos , 1 ); 318 setSelect ( cpos , 1 );
317 } 319 }
318 else 320 else
319 setSelect ( 0 , 1 ); 321 setSelect ( 0 , 1 );
320 break; 322 break;
321 // set cursor to correct place 323 // set cursor to correct place
322 case Key_Right: 324 case Key_Right:
323 if ( cpos == 1 ) 325 if ( cpos == 1 )
324 ++cpos; 326 ++cpos;
325 if ( cpos < maxpos ) { 327 if ( cpos < maxpos ) {
326 lineEdit()->setCursorPosition(++cpos); 328 lineEdit()->setCursorPosition(++cpos);
327 setSelect ( cpos , 1 ); 329 setSelect ( cpos , 1 );
328 } 330 }
329 break; 331 break;
330 // rest 332 // rest
331 case Key_Prior: 333 case Key_Prior:
332 subTime(QTime(1,0,0)); 334 subTime(QTime(1,0,0));
333 break; 335 break;
334 case Key_Next: 336 case Key_Next:
335 addTime(QTime(1,0,0)); 337 addTime(QTime(1,0,0));
336 break; 338 break;
337 case Key_Backspace: 339 case Key_Backspace:
338 qDebug("+++++++++++back "); 340 qDebug("+++++++++++back ");
339 if ( cpos > 0) { 341 if ( cpos > 0) {
340 if ( cpos == 3 ) 342 if ( cpos == 3 )
341 --cpos; 343 --cpos;
342 if ( cpos > 5) 344 if ( cpos > 5)
343 cpos = 5; 345 cpos = 5;
344 text.at( cpos-1 ) = '0'; 346 text.at( cpos-1 ) = '0';
345 lineEdit()->setText( text ); 347 lineEdit()->setText( text );
346 lineEdit()->setCursorPosition(--cpos); 348 lineEdit()->setCursorPosition(--cpos);
347 setSelect ( cpos , 1 ); 349 setSelect ( cpos , 1 );
348 changedText(); 350 changedText();
349 qDebug("---------back "); 351 qDebug("---------back ");
350 } 352 }
351 break; 353 break;
352 } // switch arrows 354 } // switch arrows
353 355
354 // if cursor at string end, alltext market and keyEvent don't ArrowLeft -> deselect and cpos 356 // if cursor at string end, alltext market and keyEvent don't ArrowLeft -> deselect and cpos
355 if( cpos > 4 && lineEdit()->markedText().length() == 5 && e->key() != Key_Left ) { 357 if( cpos > 4 && lineEdit()->markedText().length() == 5 && e->key() != Key_Left ) {
356 lineEdit()->deselect(); 358 lineEdit()->deselect();
357 cpos = 0; 359 cpos = 0;
358 lineEdit()->setCursorPosition(cpos); 360 lineEdit()->setCursorPosition(cpos);
359 setSelect(cpos , 1); 361 setSelect(cpos , 1);
360 } 362 }
361 363
362 if ( cpos == 2 ) { 364 if ( cpos == 2 ) {
363 lineEdit()->setCursorPosition(++cpos); 365 lineEdit()->setCursorPosition(++cpos);
364 } 366 }
365 367
366 // num keys when cursorPos preEnd 368 // num keys when cursorPos preEnd
367 if ( cpos < 5 ) { 369 if ( cpos < 5 ) {
368 // switch another keys 370 // switch another keys
369 switch(e->key()) { 371 switch(e->key()) {
370 case Key_Delete: 372 case Key_Delete:
371 text.at( cpos ) = '0'; 373 text.at( cpos ) = '0';
372 lineEdit()->setText( text ); 374 lineEdit()->setText( text );
373 lineEdit()->setCursorPosition(cpos); 375 lineEdit()->setCursorPosition(cpos);
374 setSelect ( cpos , 1 ); 376 setSelect ( cpos , 1 );
375 changedText(); 377 changedText();
376 break; 378 break;
377 case Key_9: 379 case Key_9:
378 case Key_8: 380 case Key_8:
379 case Key_7: 381 case Key_7:
380 case Key_6: 382 case Key_6:
381 if ( !(cpos == 1 || cpos == 4) ) 383 if ( !(cpos == 1 || cpos == 4) )
382 return; 384 return;
383 if ( cpos == 1 && text.at( 0 ) > '1') 385 if ( cpos == 1 && text.at( 0 ) > '1')
384 text.at( 0 ) = '1'; 386 text.at( 0 ) = '1';
385 case Key_5: 387 case Key_5:
386 case Key_4: 388 case Key_4:
387 case Key_3: 389 case Key_3:
388 if ( cpos < 1 ) 390 if ( cpos < 1 )
389 return; 391 return;
390 if ( hour12Format && cpos == 1 ) 392 if ( hour12Format && cpos == 1 )
391 return; 393 return;
392 case Key_2: 394 case Key_2:
393 if ( hour12Format && cpos == 0 ) 395 if ( hour12Format && cpos == 0 )
394 return; 396 return;
395 if ( cpos == 0 && text.at( 1 ) > '3') 397 if ( cpos == 0 && text.at( 1 ) > '3')
396 text.at( 1 ) = '3'; 398 text.at( 1 ) = '3';
397 case Key_1: 399 case Key_1:
398 case Key_0: 400 case Key_0:
399 if ( hour12Format ) { 401 if ( hour12Format ) {
400 if ( e->key() == Key_0 && cpos == 1 && text.at( 0 ) == '0' ) 402 if ( e->key() == Key_0 && cpos == 1 && text.at( 0 ) == '0' )
401 return; 403 return;
402 if ( e->key() == Key_0 && cpos == 0 && text.at( 1 ) == '0' ) 404 if ( e->key() == Key_0 && cpos == 0 && text.at( 1 ) == '0' )
403 text.at( 1 ) = '1'; 405 text.at( 1 ) = '1';
404 } 406 }
405 text.at( cpos ) = QChar ( e->key() ); 407 text.at( cpos ) = QChar ( e->key() );
406 lineEdit()->setText( text ); 408 lineEdit()->setText( text );
407 if ( cpos == 1 ) 409 if ( cpos == 1 )
408 ++cpos; 410 ++cpos;
409 if ( cpos < 5) 411 if ( cpos < 5)
410 lineEdit()->setCursorPosition(++cpos); 412 lineEdit()->setCursorPosition(++cpos);
411 setSelect( cpos , 1 ); 413 setSelect( cpos , 1 );
412 changedText(); 414 changedText();
413 break; 415 break;
414 case Key_Home: 416 case Key_Home:
415 lineEdit()->setCursorPosition(0); 417 lineEdit()->setCursorPosition(0);
416 setSelect( cpos , 1 ); 418 setSelect( cpos , 1 );
417 break; 419 break;
418 case Key_End: 420 case Key_End:
419 lineEdit()->setCursorPosition(5); 421 lineEdit()->setCursorPosition(5);
420 lineEdit()->deselect(); 422 lineEdit()->deselect();
421 break; 423 break;
422 default: 424 default:
423// QComboBox::keyPressEvent(e); 425// QComboBox::keyPressEvent(e);
424 break; 426 break;
425 } // switch num keys 427 } // switch num keys
426 } else if ( cpos == 5 ) {// if cpos < 5 428 } else if ( cpos == 5 ) {// if cpos < 5
427 if ( hour12Format ) { 429 if ( hour12Format ) {
428 if ( e->key() == Key_A ) { 430 if ( e->key() == Key_A ) {
429 text.at( 5 ) = 'a'; 431 text.at( 5 ) = 'a';
430 lineEdit()->setText( text ); 432 lineEdit()->setText( text );
431 lineEdit()->setCursorPosition(5); 433 lineEdit()->setCursorPosition(5);
432 434
433 } else if ( e->key() == Key_P ) { 435 } else if ( e->key() == Key_P ) {
434 text.at( 5 ) = 'p'; 436 text.at( 5 ) = 'p';
435 lineEdit()->setText( text ); 437 lineEdit()->setText( text );
436 lineEdit()->setCursorPosition(5); 438 lineEdit()->setCursorPosition(5);
437 439
438 } 440 }
439 } 441 }
440 } 442 }
441 443
442 444
443} 445}
444 446
445void KOTimeEdit::updateText() 447void KOTimeEdit::updateText()
446{ 448{
447 listBox()->blockSignals( true ); 449 listBox()->blockSignals( true );
448 blockSignals( true ); 450 blockSignals( true );
449 QString s = KGlobal::locale()->formatTime(mTime); 451 QString s = KGlobal::locale()->formatTime(mTime);
450 // Set the text but without emitting signals, nor losing the cursor position 452 // Set the text but without emitting signals, nor losing the cursor position
451 QLineEdit *line = lineEdit(); 453 QLineEdit *line = lineEdit();
452 line->blockSignals(true); 454 line->blockSignals(true);
453 int pos = line->cursorPosition(); 455 int pos = line->cursorPosition();
454 setCurrentItem((mTime.hour()*4)+(mTime.minute()/15)); 456 setCurrentItem((mTime.hour()*4)+(mTime.minute()/15));
455 line->setText(s); 457 line->setText(s);
456 line->setCursorPosition(pos); 458 line->setCursorPosition(pos);
457 line->blockSignals(false); 459 line->blockSignals(false);
458 blockSignals( false ); 460 blockSignals( false );
459 listBox()->blockSignals( false ); 461 listBox()->blockSignals( false );
460 462
461} 463}
462 464
463void KOTimeEdit::changedText() 465void KOTimeEdit::changedText()
464{ 466{
465 int pos = lineEdit()->cursorPosition(); 467 int pos = lineEdit()->cursorPosition();
466 mTime = getTime(); 468 mTime = getTime();
467 blockSignals( true ); 469 blockSignals( true );
468 QString text = lineEdit()->text(); 470 QString text = lineEdit()->text();
469 setCurrentItem((mTime.hour()*4)+(mTime.minute()/15)); 471 setCurrentItem((mTime.hour()*4)+(mTime.minute()/15));
470 lineEdit()->setText(text); 472 lineEdit()->setText(text);
471 blockSignals( false ); 473 blockSignals( false );
472 emit timeChanged(mTime); 474 emit timeChanged(mTime);
473 lineEdit()->setCursorPosition(pos); 475 lineEdit()->setCursorPosition(pos);
474} 476}
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 7810bf9..61c39f5 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1,2049 +1,2066 @@
1#include <stdlib.h> 1#include <stdlib.h>
2 2
3#include <qaction.h> 3#include <qaction.h>
4#include <qpopupmenu.h> 4#include <qpopupmenu.h>
5#include <qpainter.h> 5#include <qpainter.h>
6#include <qwhatsthis.h> 6#include <qwhatsthis.h>
7#include <qpushbutton.h> 7#include <qpushbutton.h>
8#include <qmessagebox.h> 8#include <qmessagebox.h>
9#include <qlineedit.h> 9#include <qlineedit.h>
10#include <qtextcodec.h> 10#include <qtextcodec.h>
11#include <qfile.h> 11#include <qfile.h>
12#include <qdir.h> 12#include <qdir.h>
13#include <qapp.h> 13#include <qapp.h>
14#include <qfileinfo.h> 14#include <qfileinfo.h>
15#include <qlabel.h> 15#include <qlabel.h>
16#include <qspinbox.h> 16#include <qspinbox.h>
17#include <qcheckbox.h> 17#include <qcheckbox.h>
18#include <qmap.h> 18#include <qmap.h>
19#include <qwmatrix.h> 19#include <qwmatrix.h>
20#include <qtextbrowser.h> 20#include <qtextbrowser.h>
21#include <qtextstream.h> 21#include <qtextstream.h>
22#ifndef DESKTOP_VERSION 22#ifndef DESKTOP_VERSION
23#include <qpe/global.h> 23#include <qpe/global.h>
24#include <qpe/qpemenubar.h> 24#include <qpe/qpemenubar.h>
25#include <qpe/qpetoolbar.h> 25#include <qpe/qpetoolbar.h>
26#include <qpe/resource.h> 26#include <qpe/resource.h>
27#include <qpe/qpeapplication.h> 27#include <qpe/qpeapplication.h>
28#include <qtopia/alarmserver.h> 28#include <qtopia/alarmserver.h>
29#include <qtopia/qcopenvelope_qws.h> 29#include <qtopia/qcopenvelope_qws.h>
30#include <unistd.h> // for sleep 30#include <unistd.h> // for sleep
31#else 31#else
32#include <qmenubar.h> 32#include <qmenubar.h>
33#include <qtoolbar.h> 33#include <qtoolbar.h>
34#include <qapplication.h> 34#include <qapplication.h>
35//#include <resource.h> 35//#include <resource.h>
36 36
37#endif 37#endif
38#include <libkcal/calendarlocal.h> 38#include <libkcal/calendarlocal.h>
39#include <libkcal/todo.h> 39#include <libkcal/todo.h>
40#include <libkcal/phoneformat.h> 40#include <libkcal/phoneformat.h>
41#include <libkdepim/ksyncprofile.h> 41#include <libkdepim/ksyncprofile.h>
42#include <libkdepim/phoneaccess.h> 42#include <libkdepim/phoneaccess.h>
43#include <libkcal/kincidenceformatter.h> 43#include <libkcal/kincidenceformatter.h>
44#include <libkdepim/kpimglobalprefs.h> 44#include <libkdepim/kpimglobalprefs.h>
45 45
46#include "calendarview.h" 46#include "calendarview.h"
47#include "koviewmanager.h" 47#include "koviewmanager.h"
48#include "datenavigator.h" 48#include "datenavigator.h"
49#include "koagendaview.h" 49#include "koagendaview.h"
50#include "koagenda.h" 50#include "koagenda.h"
51#include "kodialogmanager.h" 51#include "kodialogmanager.h"
52#include "kdialogbase.h" 52#include "kdialogbase.h"
53#include "kapplication.h" 53#include "kapplication.h"
54#include "kofilterview.h" 54#include "kofilterview.h"
55#include "kstandarddirs.h" 55#include "kstandarddirs.h"
56#include "koprefs.h" 56#include "koprefs.h"
57#include "kfiledialog.h" 57#include "kfiledialog.h"
58#include "koglobals.h" 58#include "koglobals.h"
59#include "kglobal.h" 59#include "kglobal.h"
60#include "klocale.h" 60#include "klocale.h"
61#include "kconfig.h" 61#include "kconfig.h"
62#include "simplealarmclient.h" 62#include "simplealarmclient.h"
63#include "externalapphandler.h" 63#include "externalapphandler.h"
64 64
65using namespace KCal; 65using namespace KCal;
66#ifndef _WIN32_ 66#ifndef _WIN32_
67#include <unistd.h> 67#include <unistd.h>
68#else 68#else
69#ifdef _OL_IMPORT_ 69#ifdef _OL_IMPORT_
70#include "koimportoldialog.h" 70#include "koimportoldialog.h"
71#endif 71#endif
72#endif 72#endif
73#include "mainwindow.h" 73#include "mainwindow.h"
74 74
75 75
76class KOex2phonePrefs : public QDialog 76class KOex2phonePrefs : public QDialog
77{ 77{
78 public: 78 public:
79 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 79 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
80 QDialog( parent, name, true ) 80 QDialog( parent, name, true )
81 { 81 {
82 setCaption( i18n("Export to phone options") ); 82 setCaption( i18n("Export to phone options") );
83 QVBoxLayout* lay = new QVBoxLayout( this ); 83 QVBoxLayout* lay = new QVBoxLayout( this );
84 lay->setSpacing( 3 ); 84 lay->setSpacing( 3 );
85 lay->setMargin( 3 ); 85 lay->setMargin( 3 );
86 QLabel *lab; 86 QLabel *lab;
87 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 87 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
88 lab->setAlignment (AlignHCenter ); 88 lab->setAlignment (AlignHCenter );
89 QHBox* temphb; 89 QHBox* temphb;
90 temphb = new QHBox( this ); 90 temphb = new QHBox( this );
91 new QLabel( i18n("I/O device: "), temphb ); 91 new QLabel( i18n("I/O device: "), temphb );
92 mPhoneDevice = new QLineEdit( temphb); 92 mPhoneDevice = new QLineEdit( temphb);
93 lay->addWidget( temphb ); 93 lay->addWidget( temphb );
94 temphb = new QHBox( this ); 94 temphb = new QHBox( this );
95 new QLabel( i18n("Connection: "), temphb ); 95 new QLabel( i18n("Connection: "), temphb );
96 mPhoneConnection = new QLineEdit( temphb); 96 mPhoneConnection = new QLineEdit( temphb);
97 lay->addWidget( temphb ); 97 lay->addWidget( temphb );
98 temphb = new QHBox( this ); 98 temphb = new QHBox( this );
99 new QLabel( i18n("Model(opt.): "), temphb ); 99 new QLabel( i18n("Model(opt.): "), temphb );
100 mPhoneModel = new QLineEdit( temphb); 100 mPhoneModel = new QLineEdit( temphb);
101 lay->addWidget( temphb ); 101 lay->addWidget( temphb );
102 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); 102 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this );
103 mWriteBackFuture->setChecked( true ); 103 mWriteBackFuture->setChecked( true );
104 lay->addWidget( mWriteBackFuture ); 104 lay->addWidget( mWriteBackFuture );
105 temphb = new QHBox( this ); 105 temphb = new QHBox( this );
106 new QLabel( i18n("Max. weeks in future: ") , temphb ); 106 new QLabel( i18n("Max. weeks in future: ") , temphb );
107 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); 107 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb);
108 mWriteBackFutureWeeks->setValue( 8 ); 108 mWriteBackFutureWeeks->setValue( 8 );
109 lay->addWidget( temphb ); 109 lay->addWidget( temphb );
110 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); 110 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) );
111 lab->setAlignment (AlignHCenter ); 111 lab->setAlignment (AlignHCenter );
112 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 112 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
113 lay->addWidget( ok ); 113 lay->addWidget( ok );
114 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 114 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
115 lay->addWidget( cancel ); 115 lay->addWidget( cancel );
116 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 116 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
117 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 117 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
118 resize( 220, 240 ); 118 resize( 220, 240 );
119 qApp->processEvents(); 119 qApp->processEvents();
120 int dw = QApplication::desktop()->width(); 120 int dw = QApplication::desktop()->width();
121 int dh = QApplication::desktop()->height(); 121 int dh = QApplication::desktop()->height();
122 move( (dw-width())/2, (dh - height() )/2 ); 122 move( (dw-width())/2, (dh - height() )/2 );
123 } 123 }
124 124
125public: 125public:
126 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 126 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
127 QCheckBox* mWriteBackFuture; 127 QCheckBox* mWriteBackFuture;
128 QSpinBox* mWriteBackFutureWeeks; 128 QSpinBox* mWriteBackFutureWeeks;
129}; 129};
130 130
131int globalFlagBlockStartup; 131int globalFlagBlockStartup;
132MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : 132MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
133 QMainWindow( parent, name ) 133 QMainWindow( parent, name )
134{ 134{
135 135
136 136
137#ifdef DESKTOP_VERSION 137#ifdef DESKTOP_VERSION
138 setFont( QFont("Arial"), 14 ); 138 setFont( QFont("Arial"), 14 );
139#endif 139#endif
140 mClosed = false; 140 mClosed = false;
141 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; 141 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
142 QString confFile = locateLocal("config","korganizerrc"); 142 QString confFile = locateLocal("config","korganizerrc");
143 QFileInfo finf ( confFile ); 143 QFileInfo finf ( confFile );
144 bool showWarning = !finf.exists(); 144 bool showWarning = !finf.exists();
145 setIcon(SmallIcon( "ko24" ) ); 145 setIcon(SmallIcon( "ko24" ) );
146 mBlockAtStartup = true; 146 mBlockAtStartup = true;
147 mFlagKeyPressed = false; 147 mFlagKeyPressed = false;
148 setCaption("KOrganizer/Pi"); 148 setCaption("KOrganizer/Pi");
149 KOPrefs *p = KOPrefs::instance(); 149 KOPrefs *p = KOPrefs::instance();
150 KPimGlobalPrefs::instance()->setGlobalConfig(); 150 KPimGlobalPrefs::instance()->setGlobalConfig();
151 if ( p->mHourSize > 22 ) 151 if ( p->mHourSize > 22 )
152 p->mHourSize = 22; 152 p->mHourSize = 22;
153 QMainWindow::ToolBarDock tbd; 153 QMainWindow::ToolBarDock tbd;
154 if ( p->mToolBarHor ) { 154 if ( p->mToolBarHor ) {
155 if ( p->mToolBarUp ) 155 if ( p->mToolBarUp )
156 tbd = Bottom; 156 tbd = Bottom;
157 else 157 else
158 tbd = Top; 158 tbd = Top;
159 } 159 }
160 else { 160 else {
161 if ( p->mToolBarUp ) 161 if ( p->mToolBarUp )
162 tbd = Right; 162 tbd = Right;
163 else 163 else
164 tbd = Left; 164 tbd = Left;
165 } 165 }
166 if ( KOPrefs::instance()->mUseAppColors ) 166 if ( KOPrefs::instance()->mUseAppColors )
167 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 167 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
168 globalFlagBlockStartup = 1; 168 globalFlagBlockStartup = 1;
169 iconToolBar = new QPEToolBar( this ); 169 iconToolBar = new QPEToolBar( this );
170 addToolBar (iconToolBar , tbd ); 170 addToolBar (iconToolBar , tbd );
171 mCalendarModifiedFlag = false; 171 mCalendarModifiedFlag = false;
172 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); 172 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
173 splash->setAlignment ( AlignCenter ); 173 splash->setAlignment ( AlignCenter );
174 setCentralWidget( splash ); 174 setCentralWidget( splash );
175#ifndef DESKTOP_VERSION 175#ifndef DESKTOP_VERSION
176 showMaximized(); 176 showMaximized();
177#endif 177#endif
178 178
179 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); 179 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
180 setDefaultPreferences(); 180 setDefaultPreferences();
181 mCalendar = new CalendarLocal(); 181 mCalendar = new CalendarLocal();
182 mView = new CalendarView( mCalendar, this,"mCalendar " ); 182 mView = new CalendarView( mCalendar, this,"mCalendar " );
183 mView->hide(); 183 mView->hide();
184 //mView->resize(splash->size() ); 184 //mView->resize(splash->size() );
185 initActions(); 185 initActions();
186 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); 186 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu);
187 mSyncManager->setBlockSave(false); 187 mSyncManager->setBlockSave(false);
188 mView->setSyncManager(mSyncManager); 188 mView->setSyncManager(mSyncManager);
189#ifndef DESKTOP_VERSION 189#ifndef DESKTOP_VERSION
190 iconToolBar->show(); 190 iconToolBar->show();
191 qApp->processEvents(); 191 qApp->processEvents();
192#endif 192#endif
193 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); 193 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
194 int vh = height() ; 194 int vh = height() ;
195 int vw = width(); 195 int vw = width();
196 //qDebug("Toolbar hei %d ",iconToolBar->height() ); 196 //qDebug("Toolbar hei %d ",iconToolBar->height() );
197 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 197 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
198 vh -= iconToolBar->height(); 198 vh -= iconToolBar->height();
199 } else { 199 } else {
200 vw -= iconToolBar->height(); 200 vw -= iconToolBar->height();
201 } 201 }
202 //mView->setMaximumSize( splash->size() ); 202 //mView->setMaximumSize( splash->size() );
203 //mView->resize( splash->size() ); 203 //mView->resize( splash->size() );
204 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 204 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
205 mView->readSettings(); 205 mView->readSettings();
206 bool newFile = false; 206 bool newFile = false;
207 if( !QFile::exists( defaultFileName() ) ) { 207 if( !QFile::exists( defaultFileName() ) ) {
208 QFileInfo finfo ( defaultFileName() ); 208 QFileInfo finfo ( defaultFileName() );
209 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); 209 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
210 qDebug("oldfile %s ", oldFile.latin1()); 210 qDebug("oldfile %s ", oldFile.latin1());
211 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n"; 211 QString message = "You are starting KO/Pi for the\nfirst time after updating to a\nversion >= 1.9.1. The location of the\ndefault calendar file has changed.\nA mycalendar.ics file was detected\nat the old location.\nThis file will be loaded now\nand stored at the new location!\n(Config file location has changed, too!)\nPlease read menu Help-What's New!\n";
212 finfo.setFile( oldFile ); 212 finfo.setFile( oldFile );
213 if (finfo.exists() ) { 213 if (finfo.exists() ) {
214 KMessageBox::information( this, message); 214 KMessageBox::information( this, message);
215 mView->openCalendar( oldFile ); 215 mView->openCalendar( oldFile );
216 qApp->processEvents(); 216 qApp->processEvents();
217 } else { 217 } else {
218 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); 218 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
219 finfo.setFile( oldFile ); 219 finfo.setFile( oldFile );
220 if (finfo.exists() ) { 220 if (finfo.exists() ) {
221 KMessageBox::information( this, message); 221 KMessageBox::information( this, message);
222 mView->openCalendar( oldFile ); 222 mView->openCalendar( oldFile );
223 qApp->processEvents(); 223 qApp->processEvents();
224 } 224 }
225 } 225 }
226 mView->saveCalendar( defaultFileName() ); 226 mView->saveCalendar( defaultFileName() );
227 newFile = true; 227 newFile = true;
228 } 228 }
229 229
230 QTime neededSaveTime = QDateTime::currentDateTime().time(); 230 QTime neededSaveTime = QDateTime::currentDateTime().time();
231 mView->openCalendar( defaultFileName() ); 231 mView->openCalendar( defaultFileName() );
232 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 232 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
233 qDebug("KO: Calendar loading time: %d ms",msNeeded ); 233 qDebug("KO: Calendar loading time: %d ms",msNeeded );
234 234
235 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { 235 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) {
236 KOPrefs::instance()->setAllDefaults(); 236 KOPrefs::instance()->setAllDefaults();
237 int count = mView->addCategories(); 237 int count = mView->addCategories();
238 } 238 }
239 processIncidenceSelection( 0 ); 239 processIncidenceSelection( 0 );
240 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), 240 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
241 SLOT( processIncidenceSelection( Incidence * ) ) ); 241 SLOT( processIncidenceSelection( Incidence * ) ) );
242 connect( mView, SIGNAL( modifiedChanged( bool ) ), 242 connect( mView, SIGNAL( modifiedChanged( bool ) ),
243 SLOT( slotModifiedChanged( bool ) ) ); 243 SLOT( slotModifiedChanged( bool ) ) );
244 244
245 245
246 connect( mView, SIGNAL( tempDisableBR(bool) ), 246 connect( mView, SIGNAL( tempDisableBR(bool) ),
247 SLOT( disableBR(bool) ) ); 247 SLOT( disableBR(bool) ) );
248 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); 248 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
249 mView->setModified( false ); 249 mView->setModified( false );
250 mBlockAtStartup = false; 250 mBlockAtStartup = false;
251 mView->setModified( false ); 251 mView->setModified( false );
252 setCentralWidget( mView ); 252 setCentralWidget( mView );
253 globalFlagBlockStartup = 0; 253 globalFlagBlockStartup = 0;
254 mView->show(); 254 mView->show();
255 delete splash; 255 delete splash;
256 if ( newFile ) 256 if ( newFile )
257 mView->updateConfig(); 257 mView->updateConfig();
258 // qApp->processEvents(); 258 // qApp->processEvents();
259 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 259 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
260 //fillSyncMenu(); 260 //fillSyncMenu();
261 261
262 262
263 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); 263 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) );
264 connect(mView , SIGNAL( save() ), this, SLOT( save() ) ); 264 connect(mView , SIGNAL( save() ), this, SLOT( save() ) );
265 connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) ); 265 connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) );
266 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 266 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
267 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 267 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
268 mSyncManager->setDefaultFileName( defaultFileName()); 268 mSyncManager->setDefaultFileName( defaultFileName());
269 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); 269 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) );
270 mSyncManager->fillSyncMenu(); 270 mSyncManager->fillSyncMenu();
271 271
272 272
273 273
274 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); 274 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
275 if ( showWarning ) { 275 if ( showWarning ) {
276 KMessageBox::information( this, 276 KMessageBox::information( this,
277 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information"); 277 "You are starting KO/Pi for the first time.\nPlease read menu: Help-What's New,\nif you did an update!\nPlease choose your timezone in the \nConfigure Dialog TAB Time Zone!\nPlease choose your language\nin the TAB Locale!\nYou get the Configure Dialog\nvia Menu: Actions - Configure....\nClick OK to show the Configure Dialog!\n", "KO/Pi information");
278 qApp->processEvents(); 278 qApp->processEvents();
279 mView->dialogManager()->showSyncOptions(); 279 mView->dialogManager()->showSyncOptions();
280 } 280 }
281 281
282 //US listen for result adressed from Ka/Pi 282 //US listen for result adressed from Ka/Pi
283#ifndef DESKTOP_VERSION 283#ifndef DESKTOP_VERSION
284 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 284 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
285#endif 285#endif
286#ifndef DESKTOP_VERSION 286#ifndef DESKTOP_VERSION
287 infrared = 0; 287 infrared = 0;
288#endif 288#endif
289 updateWeek( mView->startDate() ); 289 updateWeek( mView->startDate() );
290 connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), 290 connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ),
291 SLOT( updateWeekNum( const KCal::DateList & ) ) ); 291 SLOT( updateWeekNum( const KCal::DateList & ) ) );
292 mBRdisabled = false; 292 mBRdisabled = false;
293 //toggleBeamReceive(); 293 //toggleBeamReceive();
294} 294}
295MainWindow::~MainWindow() 295MainWindow::~MainWindow()
296{ 296{
297 //qDebug("MainWindow::~MainWindow() "); 297 //qDebug("MainWindow::~MainWindow() ");
298 //save toolbar location 298 //save toolbar location
299 delete mCalendar; 299 delete mCalendar;
300 delete mSyncManager; 300 delete mSyncManager;
301#ifndef DESKTOP_VERSION 301#ifndef DESKTOP_VERSION
302 if ( infrared ) 302 if ( infrared )
303 delete infrared; 303 delete infrared;
304#endif 304#endif
305 305
306 306
307} 307}
308 308
309void MainWindow::disableBR(bool b) 309void MainWindow::disableBR(bool b)
310{ 310{
311#ifndef DESKTOP_VERSION 311#ifndef DESKTOP_VERSION
312 if ( b ) { 312 if ( b ) {
313 if ( infrared ) { 313 if ( infrared ) {
314 toggleBeamReceive(); 314 toggleBeamReceive();
315 mBRdisabled = true; 315 mBRdisabled = true;
316 } 316 }
317 mBRdisabled = true; 317 mBRdisabled = true;
318 } else { 318 } else {
319 if ( mBRdisabled ) { 319 if ( mBRdisabled ) {
320 mBRdisabled = false; 320 mBRdisabled = false;
321 //makes no sense,because other cal ap is probably running 321 //makes no sense,because other cal ap is probably running
322 // toggleBeamReceive(); 322 // toggleBeamReceive();
323 } 323 }
324 } 324 }
325#endif 325#endif
326 326
327} 327}
328bool MainWindow::beamReceiveEnabled() 328bool MainWindow::beamReceiveEnabled()
329{ 329{
330#ifndef DESKTOP_VERSION 330#ifndef DESKTOP_VERSION
331 return ( infrared != 0 ); 331 return ( infrared != 0 );
332#endif 332#endif
333 return false; 333 return false;
334} 334}
335 335
336void MainWindow::toggleBeamReceive() 336void MainWindow::toggleBeamReceive()
337{ 337{
338 if ( mBRdisabled ) 338 if ( mBRdisabled )
339 return; 339 return;
340#ifndef DESKTOP_VERSION 340#ifndef DESKTOP_VERSION
341 if ( infrared ) { 341 if ( infrared ) {
342 qDebug("disable BeamReceive "); 342 qDebug("disable BeamReceive ");
343 delete infrared; 343 delete infrared;
344 infrared = 0; 344 infrared = 0;
345 brAction->setOn(false); 345 brAction->setOn(false);
346 return; 346 return;
347 } 347 }
348 qDebug("enable BeamReceive "); 348 qDebug("enable BeamReceive ");
349 brAction->setOn(true); 349 brAction->setOn(true);
350 infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ; 350 infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ;
351 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& ))); 351 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& )));
352#endif 352#endif
353} 353}
354void MainWindow::showMaximized () 354void MainWindow::showMaximized ()
355{ 355{
356#ifndef DESKTOP_VERSION 356#ifndef DESKTOP_VERSION
357 if ( ! globalFlagBlockStartup ) 357 if ( ! globalFlagBlockStartup )
358 if ( mClosed ) 358 if ( mClosed )
359 mView->goToday(); 359 mView->goToday();
360#endif 360#endif
361 QWidget::showMaximized () ; 361 QWidget::showMaximized () ;
362 mClosed = false; 362 mClosed = false;
363} 363}
364void MainWindow::closeEvent( QCloseEvent* ce ) 364void MainWindow::closeEvent( QCloseEvent* ce )
365{ 365{
366 366
367 367
368 368
369 if ( ! KOPrefs::instance()->mAskForQuit ) { 369 if ( ! KOPrefs::instance()->mAskForQuit ) {
370 saveOnClose(); 370 saveOnClose();
371 mClosed = true; 371 mClosed = true;
372 ce->accept(); 372 ce->accept();
373 return; 373 return;
374 374
375 } 375 }
376 376
377 switch( QMessageBox::information( this, "KO/Pi", 377 switch( QMessageBox::information( this, "KO/Pi",
378 i18n("Do you really want\nto close KO/Pi?"), 378 i18n("Do you really want\nto close KO/Pi?"),
379 i18n("Close"), i18n("No"), 379 i18n("Close"), i18n("No"),
380 0, 0 ) ) { 380 0, 0 ) ) {
381 case 0: 381 case 0:
382 saveOnClose(); 382 saveOnClose();
383 mClosed = true; 383 mClosed = true;
384 ce->accept(); 384 ce->accept();
385 break; 385 break;
386 case 1: 386 case 1:
387 ce->ignore(); 387 ce->ignore();
388 break; 388 break;
389 case 2: 389 case 2:
390 390
391 default: 391 default:
392 break; 392 break;
393 } 393 }
394 394
395 395
396} 396}
397 397
398void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) 398void MainWindow::recieve( const QCString& cmsg, const QByteArray& data )
399{ 399{
400 QDataStream stream( data, IO_ReadOnly ); 400 QDataStream stream( data, IO_ReadOnly );
401 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); 401 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" );
402 //QString datamess; 402 //QString datamess;
403 //qDebug("message "); 403 //qDebug("message ");
404 qDebug("KO: QCOP message received: %s ", cmsg.data() ); 404 qDebug("KO: QCOP message received: %s ", cmsg.data() );
405 405
406 if ( cmsg == "setDocument(QString)" ) { 406 if ( cmsg == "setDocument(QString)" ) {
407 QDataStream stream( data, IO_ReadOnly ); 407 QDataStream stream( data, IO_ReadOnly );
408 QString fileName; 408 QString fileName;
409 stream >> fileName; 409 stream >> fileName;
410 //qDebug("filename %s ", fileName.latin1()); 410 //qDebug("filename %s ", fileName.latin1());
411 showMaximized(); 411 showMaximized();
412 raise(); 412 raise();
413 KOPrefs::instance()->mLastSyncedLocalFile = fileName ; 413 KOPrefs::instance()->mLastSyncedLocalFile = fileName ;
414 mSyncManager->slotSyncMenu( 1002 ); 414 mSyncManager->slotSyncMenu( 1002 );
415 return; 415 return;
416 } 416 }
417 417
418 if ( cmsg == "-writeFile" ) { 418 if ( cmsg == "-writeFile" ) {
419 // I made from the "-writeFile" an "-writeAlarm" 419 // I made from the "-writeFile" an "-writeAlarm"
420 mView->viewManager()->showWhatsNextView(); 420 mView->viewManager()->showWhatsNextView();
421 mCalendar->checkAlarmForIncidence( 0, true); 421 mCalendar->checkAlarmForIncidence( 0, true);
422 showMaximized(); 422 showMaximized();
423 raise(); 423 raise();
424 return; 424 return;
425 425
426 } 426 }
427 if ( cmsg == "-writeFileSilent" ) { 427 if ( cmsg == "-writeFileSilent" ) {
428 // I made from the "-writeFile" an "-writeAlarm" 428 // I made from the "-writeFile" an "-writeAlarm"
429 // mView->viewManager()->showWhatsNextView(); 429 // mView->viewManager()->showWhatsNextView();
430 mCalendar->checkAlarmForIncidence( 0, true); 430 mCalendar->checkAlarmForIncidence( 0, true);
431 //showMaximized(); 431 //showMaximized();
432 //raise(); 432 //raise();
433 hide(); 433 hide();
434 return; 434 return;
435 } 435 }
436 if ( cmsg == "-newCountdown" ) { 436 if ( cmsg == "-newCountdown" ) {
437 qDebug("newCountdown "); 437 qDebug("newCountdown ");
438 438
439 } 439 }
440 QString msg ; 440 QString msg ;
441 QString allmsg = cmsg; 441 QString allmsg = cmsg;
442 while ( allmsg.length() > 0 ) { 442 while ( allmsg.length() > 0 ) {
443 int nextC = allmsg.find( "-", 1 ); 443 int nextC = allmsg.find( "-", 1 );
444 if ( nextC == -1 ) { 444 if ( nextC == -1 ) {
445 msg = allmsg; 445 msg = allmsg;
446 allmsg = ""; 446 allmsg = "";
447 } else{ 447 } else{
448 msg = allmsg.left( nextC ); 448 msg = allmsg.left( nextC );
449 allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); 449 allmsg = allmsg.mid( nextC, allmsg.length()-nextC );
450 } 450 }
451 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); 451 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() );
452 if ( msg == "-newEvent" ) { 452 if ( msg == "-newEvent" ) {
453 mView->newEvent(); 453 mView->newEvent();
454 } 454 }
455 if ( msg == "-newTodo" ) { 455 if ( msg == "-newTodo" ) {
456 mView->newTodo(); 456 mView->newTodo();
457 457
458 } 458 }
459 if ( msg == "-showWN" ) { 459 if ( msg == "-showWN" ) {
460 mView->viewManager()->showWhatsNextView(); 460 mView->viewManager()->showWhatsNextView();
461 } 461 }
462 if ( msg == "-showTodo" ) { 462 if ( msg == "-showTodo" ) {
463 mView->viewManager()->showTodoView(); 463 mView->viewManager()->showTodoView();
464 } 464 }
465 if ( msg == "-showList" ) { 465 if ( msg == "-showList" ) {
466 mView->viewManager()->showListView(); 466 mView->viewManager()->showListView();
467 } 467 }
468 else if ( msg == "-showDay" ) { 468 else if ( msg == "-showDay" ) {
469 mView->viewManager()->showDayView(); 469 mView->viewManager()->showDayView();
470 } 470 }
471 else if ( msg == "-showWWeek" ) { 471 else if ( msg == "-showWWeek" ) {
472 mView->viewManager()->showWorkWeekView(); 472 mView->viewManager()->showWorkWeekView();
473 } 473 }
474 else if ( msg == "-ringSync" ) { 474 else if ( msg == "-ringSync" ) {
475 mSyncManager->multiSync( false ); 475 mSyncManager->multiSync( false );
476 } 476 }
477 else if ( msg == "-showWeek" ) { 477 else if ( msg == "-showWeek" ) {
478 mView->viewManager()->showWeekView(); 478 mView->viewManager()->showWeekView();
479 } 479 }
480 else if ( msg == "-showTodo" ) { 480 else if ( msg == "-showTodo" ) {
481 mView->viewManager()->showTodoView(); 481 mView->viewManager()->showTodoView();
482 } 482 }
483 else if ( msg == "-showJournal" ) { 483 else if ( msg == "-showJournal" ) {
484 mView->dateNavigator()->selectDates( 1 ); 484 mView->dateNavigator()->selectDates( 1 );
485 mView->dateNavigator()->selectToday(); 485 mView->dateNavigator()->selectToday();
486 mView->viewManager()->showJournalView(); 486 mView->viewManager()->showJournalView();
487 } 487 }
488 else if ( msg == "-showKO" ) { 488 else if ( msg == "-showKO" ) {
489 mView->viewManager()->showNextXView(); 489 mView->viewManager()->showNextXView();
490 } 490 }
491 else if ( msg == "-showWNext" || msg == "nextView()" ) { 491 else if ( msg == "-showWNext" || msg == "nextView()" ) {
492 mView->viewManager()->showWhatsNextView(); 492 mView->viewManager()->showWhatsNextView();
493 } 493 }
494 else if ( msg == "-showNextXView" ) { 494 else if ( msg == "-showNextXView" ) {
495 mView->viewManager()->showNextXView(); 495 mView->viewManager()->showNextXView();
496 } 496 }
497 497
498 498
499 } 499 }
500 500
501 showMaximized(); 501 showMaximized();
502 raise(); 502 raise();
503} 503}
504 504
505QPixmap MainWindow::loadPixmap( QString name ) 505QPixmap MainWindow::loadPixmap( QString name )
506{ 506{
507 return SmallIcon( name ); 507 return SmallIcon( name );
508 508
509} 509}
510void MainWindow::initActions() 510void MainWindow::initActions()
511{ 511{
512 //KOPrefs::instance()->mShowFullMenu 512 //KOPrefs::instance()->mShowFullMenu
513 iconToolBar->clear(); 513 iconToolBar->clear();
514 KOPrefs *p = KOPrefs::instance(); 514 KOPrefs *p = KOPrefs::instance();
515 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); 515 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar );
516 516
517 QPopupMenu *viewMenu = new QPopupMenu( this ); 517 QPopupMenu *viewMenu = new QPopupMenu( this );
518 QPopupMenu *actionMenu = new QPopupMenu( this ); 518 QPopupMenu *actionMenu = new QPopupMenu( this );
519 QPopupMenu *importMenu = new QPopupMenu( this ); 519 QPopupMenu *importMenu = new QPopupMenu( this );
520 selectFilterMenu = new QPopupMenu( this ); 520 selectFilterMenu = new QPopupMenu( this );
521 selectFilterMenu->setCheckable( true ); 521 selectFilterMenu->setCheckable( true );
522 syncMenu = new QPopupMenu( this ); 522 syncMenu = new QPopupMenu( this );
523 configureAgendaMenu = new QPopupMenu( this ); 523 configureAgendaMenu = new QPopupMenu( this );
524 configureToolBarMenu = new QPopupMenu( this ); 524 configureToolBarMenu = new QPopupMenu( this );
525 QPopupMenu *helpMenu = new QPopupMenu( this ); 525 QPopupMenu *helpMenu = new QPopupMenu( this );
526 if ( KOPrefs::instance()->mShowFullMenu ) { 526 if ( KOPrefs::instance()->mShowFullMenu ) {
527 QMenuBar *menuBar1; 527 QMenuBar *menuBar1;
528 menuBar1 = menuBar(); 528 menuBar1 = menuBar();
529 menuBar1->insertItem( i18n("File"), importMenu ); 529 menuBar1->insertItem( i18n("File"), importMenu );
530 menuBar1->insertItem( i18n("View"), viewMenu ); 530 menuBar1->insertItem( i18n("View"), viewMenu );
531 menuBar1->insertItem( i18n("Actions"), actionMenu ); 531 menuBar1->insertItem( i18n("Actions"), actionMenu );
532#ifdef DESKTOP_VERSION 532#ifdef DESKTOP_VERSION
533 menuBar1->insertItem( i18n("Synchronize"), syncMenu ); 533 menuBar1->insertItem( i18n("Synchronize"), syncMenu );
534 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 534 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu );
535#else 535#else
536 menuBar1->insertItem( i18n("Sync"), syncMenu ); 536 menuBar1->insertItem( i18n("Sync"), syncMenu );
537 menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu ); 537 menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu );
538#endif 538#endif
539 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); 539 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu );
540 menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); 540 menuBar1->insertItem( i18n("Filter"),selectFilterMenu );
541 menuBar1->insertItem( i18n("Help"), helpMenu ); 541 menuBar1->insertItem( i18n("Help"), helpMenu );
542 } else { 542 } else {
543 QPEMenuBar *menuBar1; 543 QPEMenuBar *menuBar1;
544 menuBar1 = new QPEMenuBar( iconToolBar ); 544 menuBar1 = new QPEMenuBar( iconToolBar );
545 QPopupMenu *menuBar = new QPopupMenu( this ); 545 QPopupMenu *menuBar = new QPopupMenu( this );
546 menuBar1->insertItem( i18n("ME"), menuBar); 546 menuBar1->insertItem( i18n("ME"), menuBar);
547 menuBar->insertItem( i18n("File"), importMenu ); 547 menuBar->insertItem( i18n("File"), importMenu );
548 menuBar->insertItem( i18n("View"), viewMenu ); 548 menuBar->insertItem( i18n("View"), viewMenu );
549 menuBar->insertItem( i18n("Actions"), actionMenu ); 549 menuBar->insertItem( i18n("Actions"), actionMenu );
550 menuBar->insertItem( i18n("Synchronize"), syncMenu ); 550 menuBar->insertItem( i18n("Synchronize"), syncMenu );
551 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 551 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu );
552 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); 552 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu );
553 menuBar->insertItem( i18n("Filter"),selectFilterMenu ); 553 menuBar->insertItem( i18n("Filter"),selectFilterMenu );
554 menuBar->insertItem( i18n("Help"), helpMenu ); 554 menuBar->insertItem( i18n("Help"), helpMenu );
555 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); 555 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() );
556 menuBar1->setMaximumSize( menuBar1->sizeHint( )); 556 menuBar1->setMaximumSize( menuBar1->sizeHint( ));
557 } 557 }
558 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); 558 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
559 connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) ); 559 connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) );
560 QIconSet icon; 560 QIconSet icon;
561 int pixWid = 22, pixHei = 22; 561 int pixWid = 22, pixHei = 22;
562 QString pathString = ""; 562 QString pathString = "";
563 if ( !p->mToolBarMiniIcons ) { 563 if ( !p->mToolBarMiniIcons ) {
564 if ( QApplication::desktop()->width() < 480 ) { 564 if ( QApplication::desktop()->width() < 480 ) {
565 pathString += "icons16/"; 565 pathString += "icons16/";
566 pixWid = 18; pixHei = 16; 566 pixWid = 18; pixHei = 16;
567 } 567 }
568 } else { 568 } else {
569 pathString += "iconsmini/"; 569 pathString += "iconsmini/";
570 pixWid = 18; pixHei = 16; 570 pixWid = 18; pixHei = 16;
571 } 571 }
572 mWeekBgColor = iconToolBar->backgroundColor(); 572 mWeekBgColor = iconToolBar->backgroundColor();
573 mWeekPixmap.resize( pixWid , pixHei ); 573 mWeekPixmap.resize( pixWid , pixHei );
574 mWeekPixmap.fill( mWeekBgColor ); 574 mWeekPixmap.fill( mWeekBgColor );
575 icon = mWeekPixmap; 575 icon = mWeekPixmap;
576 mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this ); 576 mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this );
577 mWeekAction->addTo( iconToolBar ); 577 mWeekAction->addTo( iconToolBar );
578 mWeekFont = font(); 578 mWeekFont = font();
579 579
580 int fontPoint = mWeekFont.pointSize(); 580 int fontPoint = mWeekFont.pointSize();
581 QFontMetrics f( mWeekFont ); 581 QFontMetrics f( mWeekFont );
582 int fontWid = f.width( "30" ); 582 int fontWid = f.width( "30" );
583 while ( fontWid > pixWid ) { 583 while ( fontWid > pixWid ) {
584 --fontPoint; 584 --fontPoint;
585 mWeekFont.setPointSize( fontPoint ); 585 mWeekFont.setPointSize( fontPoint );
586 QFontMetrics f( mWeekFont ); 586 QFontMetrics f( mWeekFont );
587 fontWid = f.width( "30" ); 587 fontWid = f.width( "30" );
588 qDebug("dec-- "); 588 qDebug("dec-- ");
589 } 589 }
590 590
591 connect( mWeekAction, SIGNAL( activated() ), 591 connect( mWeekAction, SIGNAL( activated() ),
592 this, SLOT( weekAction() ) ); 592 this, SLOT( weekAction() ) );
593 593
594 connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) ); 594 connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) );
595 595
596 //#endif 596 //#endif
597 // ****************** 597 // ******************
598 QAction *action; 598 QAction *action;
599 // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); 599 // QPopupMenu *configureMenu= new QPopupMenu( menuBar );
600 configureToolBarMenu->setCheckable( true ); 600 configureToolBarMenu->setCheckable( true );
601 601
602 602
603 configureAgendaMenu->setCheckable( true ); 603 configureAgendaMenu->setCheckable( true );
604 int iii ; 604 int iii ;
605 for ( iii = 1;iii<= 10 ;++iii ){ 605 for ( iii = 1;iii<= 10 ;++iii ){
606 configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 ); 606 configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 );
607 } 607 }
608 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); 608 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu );
609 609
610 connect( configureAgendaMenu, SIGNAL( aboutToShow()), 610 connect( configureAgendaMenu, SIGNAL( aboutToShow()),
611 this, SLOT( showConfigureAgenda( ) ) ); 611 this, SLOT( showConfigureAgenda( ) ) );
612 612
613 icon = loadPixmap( pathString + "configure" ); 613 icon = loadPixmap( pathString + "configure" );
614 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); 614 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this );
615 action->addTo( actionMenu ); 615 action->addTo( actionMenu );
616 connect( action, SIGNAL( activated() ), 616 connect( action, SIGNAL( activated() ),
617 mView, SLOT( edit_options() ) ); 617 mView, SLOT( edit_options() ) );
618 actionMenu->insertSeparator(); 618 actionMenu->insertSeparator();
619 619
620 action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this ); 620 action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this );
621 action->addTo( actionMenu ); 621 action->addTo( actionMenu );
622 connect( action, SIGNAL( activated() ), 622 connect( action, SIGNAL( activated() ),
623 mView, SLOT( undo_delete() ) ); 623 mView, SLOT( undo_delete() ) );
624 actionMenu->insertSeparator(); 624 actionMenu->insertSeparator();
625 625
626 icon = loadPixmap( pathString + "newevent" ); 626 icon = loadPixmap( pathString + "newevent" );
627 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); 627 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 );
628 configureToolBarMenu->insertSeparator(); 628 configureToolBarMenu->insertSeparator();
629 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); 629 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 );
630 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); 630 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this );
631 ne_action->addTo( actionMenu ); 631 ne_action->addTo( actionMenu );
632 connect( ne_action, SIGNAL( activated() ), 632 connect( ne_action, SIGNAL( activated() ),
633 mView, SLOT( newEvent() ) ); 633 mView, SLOT( newEvent() ) );
634 icon = loadPixmap( pathString + "newtodo" ); 634 icon = loadPixmap( pathString + "newtodo" );
635 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); 635 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 );
636 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); 636 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this );
637 nt_action->addTo( actionMenu ); 637 nt_action->addTo( actionMenu );
638 connect( nt_action, SIGNAL( activated() ), 638 connect( nt_action, SIGNAL( activated() ),
639 mView, SLOT( newTodo() ) ); 639 mView, SLOT( newTodo() ) );
640 640
641 icon = loadPixmap( pathString + "today" ); 641 icon = loadPixmap( pathString + "today" );
642 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); 642 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this );
643 today_action->addTo( viewMenu ); 643 today_action->addTo( viewMenu );
644 connect( today_action, SIGNAL( activated() ), 644 connect( today_action, SIGNAL( activated() ),
645 mView, SLOT( goToday() ) ); 645 mView, SLOT( goToday() ) );
646 viewMenu->insertSeparator(); 646 viewMenu->insertSeparator();
647 647
648 icon = loadPixmap( pathString + "navi" ); 648 icon = loadPixmap( pathString + "navi" );
649 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); 649 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this );
650 action->addTo( viewMenu ); 650 action->addTo( viewMenu );
651 connect( action, SIGNAL( activated() ), 651 connect( action, SIGNAL( activated() ),
652 mView, SLOT( toggleDateNavigatorWidget() ) ); 652 mView, SLOT( toggleDateNavigatorWidget() ) );
653 mToggleNav = action ; 653 mToggleNav = action ;
654 icon = loadPixmap( pathString + "filter" ); 654 icon = loadPixmap( pathString + "filter" );
655 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); 655 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this );
656 action->addTo( viewMenu ); 656 action->addTo( viewMenu );
657 connect( action, SIGNAL( activated() ), 657 connect( action, SIGNAL( activated() ),
658 mView, SLOT( toggleFilter() ) ); 658 mView, SLOT( toggleFilter() ) );
659 mToggleFilter = action; 659 mToggleFilter = action;
660 icon = loadPixmap( pathString + "allday" ); 660 icon = loadPixmap( pathString + "allday" );
661 action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this ); 661 action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this );
662 action->addTo( viewMenu ); 662 action->addTo( viewMenu );
663 connect( action, SIGNAL( activated() ), 663 connect( action, SIGNAL( activated() ),
664 mView, SLOT( toggleAllDaySize() ) ); 664 mView, SLOT( toggleAllDaySize() ) );
665 mToggleAllday = action; 665 mToggleAllday = action;
666 666
667 667
668 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), 668 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ),
669 mToggleNav, SLOT( setEnabled ( bool ) ) ); 669 mToggleNav, SLOT( setEnabled ( bool ) ) );
670 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), 670 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ),
671 mToggleFilter, SLOT( setEnabled ( bool ) ) ); 671 mToggleFilter, SLOT( setEnabled ( bool ) ) );
672 connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), 672 connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ),
673 mToggleAllday, SLOT( setEnabled ( bool ) ) ); 673 mToggleAllday, SLOT( setEnabled ( bool ) ) );
674 674
675 viewMenu->insertSeparator(); 675 viewMenu->insertSeparator();
676 icon = loadPixmap( pathString + "picker" ); 676 icon = loadPixmap( pathString + "picker" );
677 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); 677 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this );
678 action->addTo( viewMenu ); 678 action->addTo( viewMenu );
679 connect( action, SIGNAL( activated() ), 679 connect( action, SIGNAL( activated() ),
680 mView, SLOT( showDatePicker() ) ); 680 mView, SLOT( showDatePicker() ) );
681 action->addTo( iconToolBar ); 681 action->addTo( iconToolBar );
682 viewMenu->insertSeparator(); 682 viewMenu->insertSeparator();
683 icon = loadPixmap( pathString + "list" ); 683 icon = loadPixmap( pathString + "list" );
684 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); 684 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 );
685 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); 685 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this );
686 showlist_action->addTo( viewMenu ); 686 showlist_action->addTo( viewMenu );
687 connect( showlist_action, SIGNAL( activated() ), 687 connect( showlist_action, SIGNAL( activated() ),
688 mView->viewManager(), SLOT( showListView() ) ); 688 mView->viewManager(), SLOT( showListView() ) );
689 689
690 690
691 icon = loadPixmap( pathString + "day" ); 691 icon = loadPixmap( pathString + "day" );
692 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); 692 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 );
693 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); 693 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this );
694 day1_action->addTo( viewMenu ); 694 day1_action->addTo( viewMenu );
695 // action->addTo( toolBar ); 695 // action->addTo( toolBar );
696 connect( day1_action, SIGNAL( activated() ), 696 connect( day1_action, SIGNAL( activated() ),
697 mView->viewManager(), SLOT( showDayView() ) ); 697 mView->viewManager(), SLOT( showDayView() ) );
698 698
699 icon = loadPixmap( pathString + "workweek" ); 699 icon = loadPixmap( pathString + "workweek" );
700 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); 700 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 );
701 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); 701 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this );
702 day5_action->addTo( viewMenu ); 702 day5_action->addTo( viewMenu );
703 connect( day5_action, SIGNAL( activated() ), 703 connect( day5_action, SIGNAL( activated() ),
704 mView->viewManager(), SLOT( showWorkWeekView() ) ); 704 mView->viewManager(), SLOT( showWorkWeekView() ) );
705 705
706 icon = loadPixmap( pathString + "week" ); 706 icon = loadPixmap( pathString + "week" );
707 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); 707 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 );
708 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); 708 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this );
709 day7_action->addTo( viewMenu ); 709 day7_action->addTo( viewMenu );
710 connect( day7_action, SIGNAL( activated() ), 710 connect( day7_action, SIGNAL( activated() ),
711 mView->viewManager(), SLOT( showWeekView() ) ); 711 mView->viewManager(), SLOT( showWeekView() ) );
712 712
713 icon = loadPixmap( pathString + "month" ); 713 icon = loadPixmap( pathString + "month" );
714 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); 714 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 );
715 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); 715 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this );
716 month_action->addTo( viewMenu ); 716 month_action->addTo( viewMenu );
717 connect( month_action, SIGNAL( activated() ), 717 connect( month_action, SIGNAL( activated() ),
718 mView->viewManager(), SLOT( showMonthView() ) ); 718 mView->viewManager(), SLOT( showMonthView() ) );
719 719
720 icon = loadPixmap( pathString + "todo" ); 720 icon = loadPixmap( pathString + "todo" );
721 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); 721 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 );
722 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); 722 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this );
723 todoview_action->addTo( viewMenu ); 723 todoview_action->addTo( viewMenu );
724 connect( todoview_action, SIGNAL( activated() ), 724 connect( todoview_action, SIGNAL( activated() ),
725 mView->viewManager(), SLOT( showTodoView() ) ); 725 mView->viewManager(), SLOT( showTodoView() ) );
726 726
727 icon = loadPixmap( pathString + "journal" ); 727 icon = loadPixmap( pathString + "journal" );
728 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); 728 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 );
729 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); 729 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this );
730 viewjournal_action->addTo( viewMenu ); 730 viewjournal_action->addTo( viewMenu );
731 connect( viewjournal_action, SIGNAL( activated() ), 731 connect( viewjournal_action, SIGNAL( activated() ),
732 mView->viewManager(), SLOT( showJournalView() ) ); 732 mView->viewManager(), SLOT( showJournalView() ) );
733 733
734 icon = loadPixmap( pathString + "xdays" ); 734 icon = loadPixmap( pathString + "xdays" );
735 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 ); 735 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 );
736 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); 736 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this );
737 xdays_action->addTo( viewMenu ); 737 xdays_action->addTo( viewMenu );
738 connect( xdays_action, SIGNAL( activated() ), 738 connect( xdays_action, SIGNAL( activated() ),
739 mView->viewManager(), SLOT( showNextXView() ) ); 739 mView->viewManager(), SLOT( showNextXView() ) );
740 740
741 icon = loadPixmap( pathString + "whatsnext" ); 741 icon = loadPixmap( pathString + "whatsnext" );
742 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 ); 742 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 );
743 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); 743 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this );
744 whatsnext_action->addTo( viewMenu ); 744 whatsnext_action->addTo( viewMenu );
745 connect( whatsnext_action, SIGNAL( activated() ), 745 connect( whatsnext_action, SIGNAL( activated() ),
746 mView->viewManager(), SLOT( showWhatsNextView() ) ); 746 mView->viewManager(), SLOT( showWhatsNextView() ) );
747 747
748#if 0 748#if 0
749 action = new QAction( "view_timespan", "Time Span", 0, this ); 749 action = new QAction( "view_timespan", "Time Span", 0, this );
750 action->addTo( viewMenu ); 750 action->addTo( viewMenu );
751 connect( action, SIGNAL( activated() ), 751 connect( action, SIGNAL( activated() ),
752 mView->viewManager(), SLOT( showTimeSpanView() ) ); 752 mView->viewManager(), SLOT( showTimeSpanView() ) );
753#endif 753#endif
754 754
755 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, 755 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0,
756 this ); 756 this );
757 mNewSubTodoAction->addTo( actionMenu ); 757 mNewSubTodoAction->addTo( actionMenu );
758 connect( mNewSubTodoAction, SIGNAL( activated() ), 758 connect( mNewSubTodoAction, SIGNAL( activated() ),
759 mView, SLOT( newSubTodo() ) ); 759 mView, SLOT( newSubTodo() ) );
760 760
761 actionMenu->insertSeparator(); 761 actionMenu->insertSeparator();
762 762
763 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); 763 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this );
764 mShowAction->addTo( actionMenu ); 764 mShowAction->addTo( actionMenu );
765 connect( mShowAction, SIGNAL( activated() ), 765 connect( mShowAction, SIGNAL( activated() ),
766 mView, SLOT( showIncidence() ) ); 766 mView, SLOT( showIncidence() ) );
767 767
768 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); 768 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this );
769 mEditAction->addTo( actionMenu ); 769 mEditAction->addTo( actionMenu );
770 connect( mEditAction, SIGNAL( activated() ), 770 connect( mEditAction, SIGNAL( activated() ),
771 mView, SLOT( editIncidence() ) ); 771 mView, SLOT( editIncidence() ) );
772 772
773 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); 773 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this );
774 mDeleteAction->addTo( actionMenu ); 774 mDeleteAction->addTo( actionMenu );
775 connect( mDeleteAction, SIGNAL( activated() ), 775 connect( mDeleteAction, SIGNAL( activated() ),
776 mView, SLOT( deleteIncidence() ) ); 776 mView, SLOT( deleteIncidence() ) );
777 777
778 778
779 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); 779 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this );
780 mCloneAction->addTo( actionMenu ); 780 mCloneAction->addTo( actionMenu );
781 connect( mCloneAction, SIGNAL( activated() ), 781 connect( mCloneAction, SIGNAL( activated() ),
782 mView, SLOT( cloneIncidence() ) ); 782 mView, SLOT( cloneIncidence() ) );
783 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); 783 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this );
784 mMoveAction->addTo( actionMenu ); 784 mMoveAction->addTo( actionMenu );
785 connect( mMoveAction, SIGNAL( activated() ), 785 connect( mMoveAction, SIGNAL( activated() ),
786 mView, SLOT( moveIncidence() ) ); 786 mView, SLOT( moveIncidence() ) );
787 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); 787 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this );
788 mBeamAction->addTo( actionMenu ); 788 mBeamAction->addTo( actionMenu );
789 connect( mBeamAction, SIGNAL( activated() ), 789 connect( mBeamAction, SIGNAL( activated() ),
790 mView, SLOT( beamIncidence() ) ); 790 mView, SLOT( beamIncidence() ) );
791 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); 791 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this );
792 mCancelAction->addTo( actionMenu ); 792 mCancelAction->addTo( actionMenu );
793 connect( mCancelAction, SIGNAL( activated() ), 793 connect( mCancelAction, SIGNAL( activated() ),
794 mView, SLOT( toggleCancelIncidence() ) ); 794 mView, SLOT( toggleCancelIncidence() ) );
795 795
796 actionMenu->insertSeparator(); 796 actionMenu->insertSeparator();
797 797
798 action = new QAction( "purge_completed", i18n("Purge Completed"), 0, 798 action = new QAction( "purge_completed", i18n("Purge Completed"), 0,
799 this ); 799 this );
800 action->addTo( actionMenu ); 800 action->addTo( actionMenu );
801 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); 801 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) );
802 802
803 icon = loadPixmap( pathString + "search" ); 803 icon = loadPixmap( pathString + "search" );
804 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); 804 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this );
805 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4); 805 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4);
806 search_action->addTo( actionMenu ); 806 search_action->addTo( actionMenu );
807 connect( search_action, SIGNAL( activated() ), 807 connect( search_action, SIGNAL( activated() ),
808 mView->dialogManager(), SLOT( showSearchDialog() ) ); 808 mView->dialogManager(), SLOT( showSearchDialog() ) );
809 809
810 810
811 811
812 if ( KOPrefs::instance()->mShowFullMenu ) { 812 if ( KOPrefs::instance()->mShowFullMenu ) {
813 actionMenu->insertSeparator(); 813 actionMenu->insertSeparator();
814 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); 814 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu );
815 815
816 } 816 }
817 // actionMenu->insertSeparator(); 817 // actionMenu->insertSeparator();
818 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, 818 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0,
819 this ); 819 this );
820 action->addTo( importMenu ); 820 action->addTo( importMenu );
821 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); 821 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) );
822 action = new QAction( "import_quick", i18n("Import last file"), 0, 822 action = new QAction( "import_quick", i18n("Import last file"), 0,
823 this ); 823 this );
824 action->addTo( importMenu ); 824 action->addTo( importMenu );
825 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); 825 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) );
826 importMenu->insertSeparator(); 826 importMenu->insertSeparator();
827 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, 827 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0,
828 this ); 828 this );
829 action->addTo( importMenu ); 829 action->addTo( importMenu );
830 connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); 830 connect( action, SIGNAL( activated() ), SLOT( importBday() ) );
831#ifndef DESKTOP_VERSION 831#ifndef DESKTOP_VERSION
832 importMenu->insertSeparator(); 832 importMenu->insertSeparator();
833 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, 833 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0,
834 this ); 834 this );
835 action->addTo( importMenu ); 835 action->addTo( importMenu );
836 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); 836 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) );
837#else 837#else
838#ifdef _OL_IMPORT_ 838#ifdef _OL_IMPORT_
839 importMenu->insertSeparator(); 839 importMenu->insertSeparator();
840 action = new QAction( "import_ol", i18n("Import from OL"), 0, 840 action = new QAction( "import_ol", i18n("Import from OL"), 0,
841 this ); 841 this );
842 action->addTo( importMenu ); 842 action->addTo( importMenu );
843 connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); 843 connect( action, SIGNAL( activated() ), SLOT( importOL() ) );
844#endif 844#endif
845#endif 845#endif
846 846
847 importMenu->insertSeparator(); 847 importMenu->insertSeparator();
848 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, 848 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0,
849 this ); 849 this );
850 action->addTo( importMenu ); 850 action->addTo( importMenu );
851 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); 851 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) );
852 852
853 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, 853 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0,
854 this ); 854 this );
855 action->addTo( importMenu ); 855 action->addTo( importMenu );
856 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); 856 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) );
857 857
858 importMenu->insertSeparator(); 858 importMenu->insertSeparator();
859 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, 859 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0,
860 this ); 860 this );
861 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); 861 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) );
862 862
863 863
864 //LR 864 //LR
865 QPopupMenu *ex2phone = new QPopupMenu( this ); 865 QPopupMenu *ex2phone = new QPopupMenu( this );
866 ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 866 ex2phone->insertItem(i18n("Complete calendar..."), 1 );
867 ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 867 ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
868 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); 868 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) );
869 importMenu->insertItem( i18n("Export to phone"), ex2phone ); 869 importMenu->insertItem( i18n("Export to phone"), ex2phone );
870 870
871 importMenu->insertSeparator(); 871 importMenu->insertSeparator();
872 action = new QAction( "manage cat", i18n("Manage new categories..."), 0, 872 action = new QAction( "manage cat", i18n("Manage new categories..."), 0,
873 this ); 873 this );
874 action->addTo( importMenu ); 874 action->addTo( importMenu );
875 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); 875 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) );
876#ifndef DESKTOP_VERSION 876#ifndef DESKTOP_VERSION
877 importMenu->insertSeparator(); 877 importMenu->insertSeparator();
878 brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0, 878 brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0,
879 this ); 879 this );
880 brAction->addTo( importMenu ); 880 brAction->addTo( importMenu );
881 brAction->setToggleAction (true ) ; 881 brAction->setToggleAction (true ) ;
882 connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) ); 882 connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) );
883 883
884 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, 884 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0,
885 this ); 885 this );
886 action->addTo( importMenu ); 886 action->addTo( importMenu );
887 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); 887 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) );
888 888
889 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, 889 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0,
890 this ); 890 this );
891 action->addTo( importMenu ); 891 action->addTo( importMenu );
892 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); 892 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) );
893#else 893#else
894 importMenu->insertSeparator(); 894 importMenu->insertSeparator();
895 icon = loadPixmap( pathString + "print" ); 895 icon = loadPixmap( pathString + "print" );
896 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); 896 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this );
897 action->addTo( importMenu ); 897 action->addTo( importMenu );
898 connect( action, SIGNAL( activated() ), 898 connect( action, SIGNAL( activated() ),
899 this, SLOT( printCal() ) ); 899 this, SLOT( printCal() ) );
900 900
901 icon = loadPixmap( pathString + "print" ); 901 icon = loadPixmap( pathString + "print" );
902 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); 902 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this );
903 action->addTo( importMenu ); 903 action->addTo( importMenu );
904 connect( action, SIGNAL( activated() ), 904 connect( action, SIGNAL( activated() ),
905 this, SLOT( printSel() ) ); 905 this, SLOT( printSel() ) );
906 action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this ); 906 action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this );
907 action->addTo( importMenu ); 907 action->addTo( importMenu );
908 connect( action, SIGNAL( activated() ), 908 connect( action, SIGNAL( activated() ),
909 mView->viewManager(), SIGNAL( printWNV() ) ); 909 mView->viewManager(), SIGNAL( printWNV() ) );
910#endif 910#endif
911 importMenu->insertSeparator(); 911 importMenu->insertSeparator();
912 action = new QAction( "beam all", i18n("Save"), 0, 912 action = new QAction( "beam all", i18n("Save"), 0,
913 this ); 913 this );
914 action->addTo( importMenu ); 914 action->addTo( importMenu );
915 connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); 915 connect( action, SIGNAL( activated() ), this, SLOT( save() ) );
916 action = new QAction( "beam all", i18n("Exit (+save)"), 0, 916 action = new QAction( "beam all", i18n("Exit (+save)"), 0,
917 this ); 917 this );
918 action->addTo( importMenu ); 918 action->addTo( importMenu );
919 connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); 919 connect( action, SIGNAL( activated() ), this, SLOT( close() ) );
920 920
921 //menuBar->insertItem( "Configure",configureMenu ); 921 //menuBar->insertItem( "Configure",configureMenu );
922 //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); 922 //configureMenu->insertItem( "Toolbar",configureToolBarMenu );
923 icon = loadPixmap( "korganizer/korganizer" ); 923 icon = loadPixmap( "korganizer/korganizer" );
924 924
925 action = new QAction( "Whats New", i18n("What's new?"), 0,this ); 925 action = new QAction( "Whats New", i18n("What's new?"), 0,this );
926 action->addTo( helpMenu ); 926 action->addTo( helpMenu );
927 connect( action, SIGNAL( activated() ), 927 connect( action, SIGNAL( activated() ),
928 SLOT( whatsNew() ) ); 928 SLOT( whatsNew() ) );
929 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); 929 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this );
930 action->addTo( helpMenu ); 930 action->addTo( helpMenu );
931 connect( action, SIGNAL( activated() ), 931 connect( action, SIGNAL( activated() ),
932 SLOT( features() ) ); 932 SLOT( features() ) );
933 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); 933 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this );
934 action->addTo( helpMenu ); 934 action->addTo( helpMenu );
935 connect( action, SIGNAL( activated() ), 935 connect( action, SIGNAL( activated() ),
936 SLOT( keyBindings() ) ); 936 SLOT( keyBindings() ) );
937 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); 937 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this );
938 action->addTo( helpMenu ); 938 action->addTo( helpMenu );
939 connect( action, SIGNAL( activated() ), 939 connect( action, SIGNAL( activated() ),
940 SLOT( synchowto() ) ); 940 SLOT( synchowto() ) );
941 action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this ); 941 action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this );
942 action->addTo( helpMenu ); 942 action->addTo( helpMenu );
943 connect( action, SIGNAL( activated() ), 943 connect( action, SIGNAL( activated() ),
944 SLOT( kdesynchowto() ) ); 944 SLOT( kdesynchowto() ) );
945 action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this ); 945 action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this );
946 action->addTo( helpMenu ); 946 action->addTo( helpMenu );
947 connect( action, SIGNAL( activated() ), 947 connect( action, SIGNAL( activated() ),
948 SLOT( multisynchowto() ) ); 948 SLOT( multisynchowto() ) );
949 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); 949 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this );
950 action->addTo( helpMenu ); 950 action->addTo( helpMenu );
951 connect( action, SIGNAL( activated() ), 951 connect( action, SIGNAL( activated() ),
952 SLOT( aboutAutoSaving() ) ); 952 SLOT( aboutAutoSaving() ) );
953 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); 953 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this );
954 action->addTo( helpMenu ); 954 action->addTo( helpMenu );
955 connect( action, SIGNAL( activated() ), 955 connect( action, SIGNAL( activated() ),
956 SLOT( aboutKnownBugs() ) ); 956 SLOT( aboutKnownBugs() ) );
957 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); 957 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this );
958 action->addTo( helpMenu ); 958 action->addTo( helpMenu );
959 connect( action, SIGNAL( activated() ), 959 connect( action, SIGNAL( activated() ),
960 SLOT( usertrans() ) ); 960 SLOT( usertrans() ) );
961 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); 961 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this );
962 action->addTo( helpMenu ); 962 action->addTo( helpMenu );
963 connect( action, SIGNAL( activated() ), 963 connect( action, SIGNAL( activated() ),
964 SLOT( faq() ) ); 964 SLOT( faq() ) );
965 action = new QAction( "licence", i18n("Licence..."), 0, this ); 965 action = new QAction( "licence", i18n("Licence..."), 0, this );
966 action->addTo( helpMenu ); 966 action->addTo( helpMenu );
967 connect( action, SIGNAL( activated() ), 967 connect( action, SIGNAL( activated() ),
968 SLOT( licence() ) ); 968 SLOT( licence() ) );
969 action = new QAction( "about", i18n("About..."), 0, this ); 969 action = new QAction( "about", i18n("About..."), 0, this );
970 action->addTo( helpMenu ); 970 action->addTo( helpMenu );
971 connect( action, SIGNAL( activated() ), 971 connect( action, SIGNAL( activated() ),
972 SLOT( about() ) ); 972 SLOT( about() ) );
973 //menuBar->insertSeparator(); 973 //menuBar->insertSeparator();
974 974
975 // ****************************************************** 975 // ******************************************************
976 // menubar icons 976 // menubar icons
977 977
978 978
979 iconToolBar->setHorizontalStretchable (true ); 979 iconToolBar->setHorizontalStretchable (true );
980 //menuBar->insertItem( iconToolBar ); 980 //menuBar->insertItem( iconToolBar );
981 //xdays_action 981 //xdays_action
982 if (p-> mShowIconNewEvent) 982 if (p-> mShowIconNewEvent)
983 ne_action->addTo( iconToolBar ); 983 ne_action->addTo( iconToolBar );
984 if (p->mShowIconNewTodo ) 984 if (p->mShowIconNewTodo )
985 nt_action->addTo( iconToolBar ); 985 nt_action->addTo( iconToolBar );
986 if (p-> mShowIconSearch) 986 if (p-> mShowIconSearch)
987 search_action->addTo( iconToolBar ); 987 search_action->addTo( iconToolBar );
988 if (p-> mShowIconNext) 988 if (p-> mShowIconNext)
989 whatsnext_action->addTo( iconToolBar ); 989 whatsnext_action->addTo( iconToolBar );
990 if (p-> mShowIconNextDays) 990 if (p-> mShowIconNextDays)
991 xdays_action->addTo( iconToolBar ); 991 xdays_action->addTo( iconToolBar );
992 if (p-> mShowIconList) 992 if (p-> mShowIconList)
993 showlist_action->addTo( iconToolBar ); 993 showlist_action->addTo( iconToolBar );
994 if (p-> mShowIconDay1) 994 if (p-> mShowIconDay1)
995 day1_action->addTo( iconToolBar ); 995 day1_action->addTo( iconToolBar );
996 if (p-> mShowIconDay5) 996 if (p-> mShowIconDay5)
997 day5_action->addTo( iconToolBar ); 997 day5_action->addTo( iconToolBar );
998 if (p-> mShowIconDay7) 998 if (p-> mShowIconDay7)
999 day7_action->addTo( iconToolBar ); 999 day7_action->addTo( iconToolBar );
1000 if (p-> mShowIconMonth) 1000 if (p-> mShowIconMonth)
1001 month_action->addTo( iconToolBar ); 1001 month_action->addTo( iconToolBar );
1002 if (p-> mShowIconTodoview) 1002 if (p-> mShowIconTodoview)
1003 todoview_action->addTo( iconToolBar ); 1003 todoview_action->addTo( iconToolBar );
1004 if (p-> mShowIconJournal) 1004 if (p-> mShowIconJournal)
1005 viewjournal_action->addTo( iconToolBar ); 1005 viewjournal_action->addTo( iconToolBar );
1006 icon = loadPixmap( pathString + "2leftarrowB" ); 1006 icon = loadPixmap( pathString + "2leftarrowB" );
1007 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); 1007 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14);
1008 if (p-> mShowIconBackFast) { 1008 if (p-> mShowIconBackFast) {
1009 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); 1009 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this );
1010 connect( action, SIGNAL( activated() ), 1010 connect( action, SIGNAL( activated() ),
1011 mView, SLOT( goPreviousMonth() ) ); 1011 mView, SLOT( goPreviousMonth() ) );
1012 action->addTo( iconToolBar ); 1012 action->addTo( iconToolBar );
1013 } 1013 }
1014 icon = loadPixmap( pathString + "1leftarrowB" ); 1014 icon = loadPixmap( pathString + "1leftarrowB" );
1015 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); 1015 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15);
1016 if (p-> mShowIconBack) { 1016 if (p-> mShowIconBack) {
1017 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); 1017 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this );
1018 connect( action, SIGNAL( activated() ), 1018 connect( action, SIGNAL( activated() ),
1019 mView, SLOT( goPrevious() ) ); 1019 mView, SLOT( goPrevious() ) );
1020 action->addTo( iconToolBar ); 1020 action->addTo( iconToolBar );
1021 } 1021 }
1022 icon = loadPixmap( pathString + "today" ); 1022 icon = loadPixmap( pathString + "today" );
1023 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); 1023 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130);
1024 if (p-> mShowIconToday) 1024 if (p-> mShowIconToday)
1025 today_action->addTo( iconToolBar ); 1025 today_action->addTo( iconToolBar );
1026 icon = loadPixmap( pathString + "1rightarrowB" ); 1026 icon = loadPixmap( pathString + "1rightarrowB" );
1027 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); 1027 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220);
1028 if (p-> mShowIconForward) { 1028 if (p-> mShowIconForward) {
1029 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); 1029 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this );
1030 connect( action, SIGNAL( activated() ), 1030 connect( action, SIGNAL( activated() ),
1031 mView, SLOT( goNext() ) ); 1031 mView, SLOT( goNext() ) );
1032 action->addTo( iconToolBar ); 1032 action->addTo( iconToolBar );
1033 } 1033 }
1034 icon = loadPixmap( pathString + "2rightarrowB" ); 1034 icon = loadPixmap( pathString + "2rightarrowB" );
1035 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); 1035 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230);
1036 if (p-> mShowIconForwardFast) { 1036 if (p-> mShowIconForwardFast) {
1037 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); 1037 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this );
1038 connect( action, SIGNAL( activated() ), 1038 connect( action, SIGNAL( activated() ),
1039 mView, SLOT( goNextMonth() ) ); 1039 mView, SLOT( goNextMonth() ) );
1040 action->addTo( iconToolBar ); 1040 action->addTo( iconToolBar );
1041 } 1041 }
1042 1042
1043 1043
1044 configureToolBarMenu->insertItem(i18n("What's This?"), 300); 1044 configureToolBarMenu->insertItem(i18n("What's This?"), 300);
1045 1045
1046 if (p-> mShowIconNewEvent) 1046 if (p-> mShowIconNewEvent)
1047 configureToolBarMenu->setItemChecked( 10, true ); 1047 configureToolBarMenu->setItemChecked( 10, true );
1048 if (p->mShowIconNewTodo ) 1048 if (p->mShowIconNewTodo )
1049 configureToolBarMenu->setItemChecked( 20, true ); 1049 configureToolBarMenu->setItemChecked( 20, true );
1050 if (p-> mShowIconSearch) 1050 if (p-> mShowIconSearch)
1051 configureToolBarMenu->setItemChecked( 120, true ); 1051 configureToolBarMenu->setItemChecked( 120, true );
1052 if (p-> mShowIconList) 1052 if (p-> mShowIconList)
1053 configureToolBarMenu->setItemChecked( 30, true ); 1053 configureToolBarMenu->setItemChecked( 30, true );
1054 if (p-> mShowIconDay1) 1054 if (p-> mShowIconDay1)
1055 configureToolBarMenu->setItemChecked( 40, true ); 1055 configureToolBarMenu->setItemChecked( 40, true );
1056 if (p-> mShowIconDay5) 1056 if (p-> mShowIconDay5)
1057 configureToolBarMenu->setItemChecked( 50, true ); 1057 configureToolBarMenu->setItemChecked( 50, true );
1058 if (p-> mShowIconDay7) 1058 if (p-> mShowIconDay7)
1059 configureToolBarMenu->setItemChecked( 60, true ); 1059 configureToolBarMenu->setItemChecked( 60, true );
1060 if (p-> mShowIconMonth) 1060 if (p-> mShowIconMonth)
1061 configureToolBarMenu->setItemChecked( 70, true ); 1061 configureToolBarMenu->setItemChecked( 70, true );
1062 if (p-> mShowIconTodoview) 1062 if (p-> mShowIconTodoview)
1063 configureToolBarMenu->setItemChecked( 80, true ); 1063 configureToolBarMenu->setItemChecked( 80, true );
1064 if (p-> mShowIconBackFast) 1064 if (p-> mShowIconBackFast)
1065 configureToolBarMenu->setItemChecked( 200, true ); 1065 configureToolBarMenu->setItemChecked( 200, true );
1066 if (p-> mShowIconBack) 1066 if (p-> mShowIconBack)
1067 configureToolBarMenu->setItemChecked( 210, true ); 1067 configureToolBarMenu->setItemChecked( 210, true );
1068 if (p-> mShowIconToday) 1068 if (p-> mShowIconToday)
1069 configureToolBarMenu->setItemChecked( 130, true ); 1069 configureToolBarMenu->setItemChecked( 130, true );
1070 if (p-> mShowIconForward) 1070 if (p-> mShowIconForward)
1071 configureToolBarMenu->setItemChecked( 220, true ); 1071 configureToolBarMenu->setItemChecked( 220, true );
1072 if (p-> mShowIconForwardFast) 1072 if (p-> mShowIconForwardFast)
1073 configureToolBarMenu->setItemChecked( 230, true ); 1073 configureToolBarMenu->setItemChecked( 230, true );
1074 if (p-> mShowIconNextDays) 1074 if (p-> mShowIconNextDays)
1075 configureToolBarMenu->setItemChecked( 100, true ); 1075 configureToolBarMenu->setItemChecked( 100, true );
1076 if (p-> mShowIconNext) 1076 if (p-> mShowIconNext)
1077 configureToolBarMenu->setItemChecked( 110, true ); 1077 configureToolBarMenu->setItemChecked( 110, true );
1078 if (p-> mShowIconJournal) 1078 if (p-> mShowIconJournal)
1079 configureToolBarMenu->setItemChecked( 90, true ); 1079 configureToolBarMenu->setItemChecked( 90, true );
1080 if (p-> mShowIconWhatsThis) 1080 if (p-> mShowIconWhatsThis)
1081 configureToolBarMenu->setItemChecked( 300, true ); 1081 configureToolBarMenu->setItemChecked( 300, true );
1082 1082
1083 QLabel* dummy = new QLabel( iconToolBar ); 1083 QLabel* dummy = new QLabel( iconToolBar );
1084 dummy->setBackgroundColor( iconToolBar->backgroundColor() ); 1084 dummy->setBackgroundColor( iconToolBar->backgroundColor() );
1085 if (!p-> mShowIconStretch) 1085 if (!p-> mShowIconStretch)
1086 iconToolBar->setStretchableWidget ( dummy ) ; 1086 iconToolBar->setStretchableWidget ( dummy ) ;
1087 else 1087 else
1088 configureToolBarMenu->setItemChecked( 5, true ); 1088 configureToolBarMenu->setItemChecked( 5, true );
1089 if (p-> mShowIconWhatsThis) 1089 if (p-> mShowIconWhatsThis)
1090 QWhatsThis::whatsThisButton ( iconToolBar ); 1090 QWhatsThis::whatsThisButton ( iconToolBar );
1091 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); 1091 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) );
1092 configureAgenda( p->mHourSize ); 1092 configureAgenda( p->mHourSize );
1093 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); 1093 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) );
1094} 1094}
1095 1095
1096void MainWindow::exportToPhone( int mode ) 1096void MainWindow::exportToPhone( int mode )
1097{ 1097{
1098 1098
1099 //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 1099 //ex2phone->insertItem(i18n("Complete calendar..."), 1 );
1100 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 1100 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
1101 KOex2phonePrefs ex2phone; 1101 KOex2phonePrefs ex2phone;
1102 1102
1103 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 1103 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
1104 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 1104 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
1105 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1105 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
1106 if ( mode == 1 ) 1106 if ( mode == 1 )
1107 ex2phone.setCaption(i18n("Export complete calendar")); 1107 ex2phone.setCaption(i18n("Export complete calendar"));
1108 if ( mode == 2 ) 1108 if ( mode == 2 )
1109 ex2phone.setCaption(i18n("Export filtered calendar")); 1109 ex2phone.setCaption(i18n("Export filtered calendar"));
1110 1110
1111 if ( !ex2phone.exec() ) { 1111 if ( !ex2phone.exec() ) {
1112 return; 1112 return;
1113 } 1113 }
1114 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 1114 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
1115 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 1115 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
1116 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 1116 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
1117 1117
1118 int inFuture = 0; 1118 int inFuture = 0;
1119 if ( ex2phone.mWriteBackFuture->isChecked() ) 1119 if ( ex2phone.mWriteBackFuture->isChecked() )
1120 inFuture = ex2phone.mWriteBackFutureWeeks->value(); 1120 inFuture = ex2phone.mWriteBackFutureWeeks->value();
1121 QPtrList<Incidence> delSel; 1121 QPtrList<Incidence> delSel;
1122 if ( mode == 1 ) 1122 if ( mode == 1 )
1123 delSel = mCalendar->rawIncidences(); 1123 delSel = mCalendar->rawIncidences();
1124 if ( mode == 2 ) 1124 if ( mode == 2 )
1125 delSel = mCalendar->incidences(); 1125 delSel = mCalendar->incidences();
1126 CalendarLocal* cal = new CalendarLocal(); 1126 CalendarLocal* cal = new CalendarLocal();
1127 cal->setLocalTime(); 1127 cal->setLocalTime();
1128 Incidence *incidence = delSel.first(); 1128 Incidence *incidence = delSel.first();
1129 QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); 1129 QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
1130 QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); 1130 QDateTime end = cur.addDays( ( inFuture +1 ) *7 );
1131 while ( incidence ) { 1131 while ( incidence ) {
1132 if ( incidence->type() != "Journal" ) { 1132 if ( incidence->type() != "Journal" ) {
1133 bool add = true; 1133 bool add = true;
1134 if ( inFuture ) { 1134 if ( inFuture ) {
1135 QDateTime dt; 1135 QDateTime dt;
1136 if ( incidence->type() == "Todo" ) { 1136 if ( incidence->type() == "Todo" ) {
1137 Todo * t = (Todo*)incidence; 1137 Todo * t = (Todo*)incidence;
1138 if ( t->hasDueDate() ) 1138 if ( t->hasDueDate() )
1139 dt = t->dtDue(); 1139 dt = t->dtDue();
1140 else 1140 else
1141 dt = cur.addSecs( 62 ); 1141 dt = cur.addSecs( 62 );
1142 } 1142 }
1143 else { 1143 else {
1144 bool ok; 1144 bool ok;
1145 dt = incidence->getNextOccurence( cur, &ok ); 1145 dt = incidence->getNextOccurence( cur, &ok );
1146 if ( !ok ) 1146 if ( !ok )
1147 dt = cur.addSecs( -62 ); 1147 dt = cur.addSecs( -62 );
1148 } 1148 }
1149 if ( dt < cur || dt > end ) { 1149 if ( dt < cur || dt > end ) {
1150 add = false; 1150 add = false;
1151 } 1151 }
1152 } 1152 }
1153 if ( add ) { 1153 if ( add ) {
1154 Incidence *in = incidence->clone(); 1154 Incidence *in = incidence->clone();
1155 cal->addIncidence( in ); 1155 cal->addIncidence( in );
1156 } 1156 }
1157 } 1157 }
1158 incidence = delSel.next(); 1158 incidence = delSel.next();
1159 } 1159 }
1160 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 1160 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
1161 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 1161 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
1162 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1162 KPimGlobalPrefs::instance()->mEx2PhoneModel );
1163 1163
1164 setCaption( i18n("Writing to phone...")); 1164 setCaption( i18n("Writing to phone..."));
1165 if ( PhoneFormat::writeToPhone( cal ) ) 1165 if ( PhoneFormat::writeToPhone( cal ) )
1166 setCaption( i18n("Export to phone successful!")); 1166 setCaption( i18n("Export to phone successful!"));
1167 else 1167 else
1168 setCaption( i18n("Error exporting to phone!")); 1168 setCaption( i18n("Error exporting to phone!"));
1169 delete cal; 1169 delete cal;
1170} 1170}
1171 1171
1172 1172
1173void MainWindow::setDefaultPreferences() 1173void MainWindow::setDefaultPreferences()
1174{ 1174{
1175 KOPrefs *p = KOPrefs::instance(); 1175 KOPrefs *p = KOPrefs::instance();
1176 1176
1177 p->mCompactDialogs = true; 1177 p->mCompactDialogs = true;
1178 p->mConfirm = true; 1178 p->mConfirm = true;
1179 // p->mEnableQuickTodo = false; 1179 // p->mEnableQuickTodo = false;
1180 1180
1181} 1181}
1182 1182
1183QString MainWindow::resourcePath() 1183QString MainWindow::resourcePath()
1184{ 1184{
1185 return KGlobal::iconLoader()->iconPath(); 1185 return KGlobal::iconLoader()->iconPath();
1186} 1186}
1187 1187
1188void MainWindow::displayText( QString text ,QString cap ) 1188void MainWindow::displayText( QString text ,QString cap )
1189{ 1189{
1190 QDialog dia( this, "name", true ); ; 1190 QDialog dia( this, "name", true ); ;
1191 dia.setCaption( cap ); 1191 dia.setCaption( cap );
1192 QVBoxLayout* lay = new QVBoxLayout( &dia ); 1192 QVBoxLayout* lay = new QVBoxLayout( &dia );
1193 lay->setSpacing( 3 ); 1193 lay->setSpacing( 3 );
1194 lay->setMargin( 3 ); 1194 lay->setMargin( 3 );
1195 QTextBrowser tb ( &dia ); 1195 QTextBrowser tb ( &dia );
1196 lay->addWidget( &tb ); 1196 lay->addWidget( &tb );
1197 tb.setText( text ); 1197 tb.setText( text );
1198#ifdef DESKTOP_VERSION 1198#ifdef DESKTOP_VERSION
1199 dia.resize( 640, 480); 1199 dia.resize( 640, 480);
1200#else 1200#else
1201 dia.showMaximized(); 1201 dia.showMaximized();
1202#endif 1202#endif
1203 dia.exec(); 1203 dia.exec();
1204} 1204}
1205 1205
1206void MainWindow::features() 1206void MainWindow::features()
1207{ 1207{
1208 1208
1209 KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" ); 1209 KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" );
1210} 1210}
1211 1211
1212void MainWindow::usertrans() 1212void MainWindow::usertrans()
1213{ 1213{
1214 1214
1215 KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" ); 1215 KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" );
1216} 1216}
1217 1217
1218void MainWindow::kdesynchowto() 1218void MainWindow::kdesynchowto()
1219{ 1219{
1220 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); 1220 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" );
1221} 1221}
1222void MainWindow::multisynchowto() 1222void MainWindow::multisynchowto()
1223{ 1223{
1224 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); 1224 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" );
1225} 1225}
1226void MainWindow::synchowto() 1226void MainWindow::synchowto()
1227{ 1227{
1228 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 1228 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
1229} 1229}
1230void MainWindow::faq() 1230void MainWindow::faq()
1231{ 1231{
1232 KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" ); 1232 KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" );
1233 1233
1234} 1234}
1235void MainWindow::whatsNew() 1235void MainWindow::whatsNew()
1236{ 1236{
1237 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 1237 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
1238 1238
1239} 1239}
1240void MainWindow::licence() 1240void MainWindow::licence()
1241{ 1241{
1242 KApplication::showLicence(); 1242 KApplication::showLicence();
1243 1243
1244} 1244}
1245void MainWindow::about() 1245void MainWindow::about()
1246{ 1246{
1247 QString version; 1247 QString version;
1248#include <../version> 1248#include <../version>
1249 QMessageBox::about( this, i18n("About KOrganizer/Pi"), 1249 QMessageBox::about( this, i18n("About KOrganizer/Pi"),
1250 i18n("KOrganizer/Platform-independent\n") + 1250 i18n("KOrganizer/Platform-independent\n") +
1251 "(KO/Pi) " + version + " - " + 1251 "(KO/Pi) " + version + " - " +
1252 1252
1253#ifdef DESKTOP_VERSION 1253#ifdef DESKTOP_VERSION
1254 i18n("Desktop Edition\n") + 1254 i18n("Desktop Edition\n") +
1255#else 1255#else
1256 i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") + 1256 i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") +
1257#endif 1257#endif
1258 i18n("(c)2004 Lutz Rogowski (rogowski@kde.org)\nKO/Pi is based on KOrganizer\n(c)2002,2003 Cornelius Schumacher\n(schumacher@kde.org) and the KDE team.\nKOrganizer/Pi is licensed under the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.pi-sync.net --- www.korganizer.org\nSpecial thanks to Michael and Ben\nfor intensive testing!") ); 1258 i18n("(c)2004 Lutz Rogowski (rogowski@kde.org)\nKO/Pi is based on KOrganizer\n(c)2002,2003 Cornelius Schumacher\n(schumacher@kde.org) and the KDE team.\nKOrganizer/Pi is licensed under the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.pi-sync.net --- www.korganizer.org\nSpecial thanks to Michael and Ben\nfor intensive testing!") );
1259} 1259}
1260void MainWindow::keyBindings() 1260void MainWindow::keyBindings()
1261{ 1261{
1262 QString cap = i18n("KO/Pi Keys + Colors"); 1262 QString cap = i18n("KO/Pi Keys + Colors");
1263 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + 1263 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") +
1264 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ 1264 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+
1265 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + 1265 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") +
1266 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ 1266 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+
1267 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ 1267 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+
1268 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ 1268 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+
1269 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ 1269 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+
1270 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ 1270 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+
1271 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ 1271 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+
1272 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ 1272 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+
1273 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ 1273 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+
1274 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ 1274 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+
1275 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ 1275 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+
1276 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ 1276 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+
1277 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ 1277 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+
1278 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ 1278 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+
1279 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ 1279 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+
1280 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ 1280 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+
1281 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ 1281 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+
1282 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ 1282 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+
1283 i18n("<p><h3>In agenda view:</h3></p>\n") + 1283 i18n("<p><h3>In agenda view:</h3></p>\n") +
1284 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ 1284 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+
1285 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ 1285 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+
1286 i18n("<p><h3>In todo view:</h3></p>\n") + 1286 i18n("<p><h3>In todo view:</h3></p>\n") +
1287 i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ 1287 i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+
1288 i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ 1288 i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+
1289 i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ 1289 i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+
1290 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ 1290 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+
1291 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1291 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1292 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ 1292 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+
1293 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ 1293 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+
1294 i18n("<p><h3>In list view:</h3></p>\n") + 1294 i18n("<p><h3>In list view:</h3></p>\n") +
1295 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1295 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1296 i18n("<p><b>return</b>: Select item+one step down</p>\n")+ 1296 i18n("<p><b>return</b>: Select item+one step down</p>\n")+
1297 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ 1297 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+
1298 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ 1298 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+
1299 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ 1299 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+
1300 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ 1300 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+
1301 i18n("<p><h3>In event/todo viewer:</h3></p>\n") + 1301 i18n("<p><h3>In event/todo viewer:</h3></p>\n") +
1302 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ 1302 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+
1303 i18n("<p><b>A</b>: Show agenda view.</p>\n")+ 1303 i18n("<p><b>A</b>: Show agenda view.</p>\n")+
1304 i18n("<p><b>E</b>: Edit item</p>\n") + 1304 i18n("<p><b>E</b>: Edit item</p>\n") +
1305 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + 1305 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") +
1306 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + 1306 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") +
1307 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ 1307 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+
1308 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ 1308 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+
1309 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ 1309 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+
1310 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ 1310 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+
1311 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ 1311 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+
1312 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + 1312 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") +
1313 i18n("<p><b>White</b>: Item readonly</p>\n"); 1313 i18n("<p><b>White</b>: Item readonly</p>\n");
1314 displayText( text, cap); 1314 displayText( text, cap);
1315} 1315}
1316void MainWindow::aboutAutoSaving() 1316void MainWindow::aboutAutoSaving()
1317{ 1317{
1318 QString text = i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configurable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n"); 1318 QString text = i18n("After changing something, the data is\nautomatically saved to the file\n~/kdepim/apps/korganizer/mycalendar.ics\nafter (configurable) three minutes.\nFor safety reasons there is one autosaving\nafter 10 minutes (of idle time) again. The \ndata is saved automatically when closing KO/Pi\nYou can create a backup file \nwith: File - Save Calendar Backup\n");
1319 1319
1320 KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text); 1320 KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text);
1321 1321
1322} 1322}
1323void MainWindow::aboutKnownBugs() 1323void MainWindow::aboutKnownBugs()
1324{ 1324{
1325 QMessageBox* msg; 1325 QMessageBox* msg;
1326 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), 1326 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"),
1327 i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+ 1327 i18n("1) Importing *.vcs or *.ics files from\nother applications may not work properly,\nif there are events with properties\nKO/Pi does not support.\n")+
1328 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ 1328 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+
1329 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + 1329 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") +
1330 i18n("\nor report them in the bugtracker on\n") + 1330 i18n("\nor report them in the bugtracker on\n") +
1331 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), 1331 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"),
1332 QMessageBox::NoIcon, 1332 QMessageBox::NoIcon,
1333 QMessageBox::Ok, 1333 QMessageBox::Ok,
1334 QMessageBox::NoButton, 1334 QMessageBox::NoButton,
1335 QMessageBox::NoButton); 1335 QMessageBox::NoButton);
1336 msg->exec(); 1336 msg->exec();
1337 delete msg; 1337 delete msg;
1338 1338
1339} 1339}
1340 1340
1341QString MainWindow::defaultFileName() 1341QString MainWindow::defaultFileName()
1342{ 1342{
1343 return locateLocal( "data", "korganizer/mycalendar.ics" ); 1343 return locateLocal( "data", "korganizer/mycalendar.ics" );
1344} 1344}
1345QString MainWindow::syncFileName() 1345QString MainWindow::syncFileName()
1346{ 1346{
1347#ifdef DESKTOP_VERSION 1347#ifdef DESKTOP_VERSION
1348 return locateLocal( "tmp", "synccalendar.ics" ); 1348 return locateLocal( "tmp", "synccalendar.ics" );
1349#else 1349#else
1350 return QString( "/tmp/synccalendar.ics" ); 1350 return QString( "/tmp/synccalendar.ics" );
1351#endif 1351#endif
1352} 1352}
1353void MainWindow::updateWeek(QDate seda) 1353void MainWindow::updateWeek(QDate seda)
1354{ 1354{
1355 int weekNum = 0; 1355 int weekNum = 0;
1356 QDate d = QDate ( seda.year(), 1,1); 1356 QDate d = QDate ( seda.year(), 1,1);
1357 seda = seda.addDays( 1-seda.dayOfWeek() );//we are on monday 1357 seda = seda.addDays( 1-seda.dayOfWeek() );//we are on monday
1358 if ( seda.addDays(6).year() != seda.year() ) { 1358 if ( seda.addDays(6).year() != seda.year() ) {
1359 if ( seda.year() != d.year() ) { 1359 if ( seda.year() != d.year() ) {
1360 if ( d.dayOfWeek() > 4 ) 1360 if ( d.dayOfWeek() > 4 )
1361 d = QDate ( seda.year(), 1,1); 1361 d = QDate ( seda.year(), 1,1);
1362 else 1362 else
1363 weekNum = 1; 1363 weekNum = 1;
1364 } else { 1364 } else {
1365 QDate dd( seda.year()+1, 1,1); 1365 QDate dd( seda.year()+1, 1,1);
1366 if ( dd.dayOfWeek() <= 4 ) 1366 if ( dd.dayOfWeek() <= 4 )
1367 weekNum = 1; 1367 weekNum = 1;
1368 } 1368 }
1369 } 1369 }
1370 if ( weekNum == 0 ){ 1370 if ( weekNum == 0 ){
1371 int dow = d.dayOfWeek(); 1371 int dow = d.dayOfWeek();
1372 if ( dow <= 4 ) 1372 if ( dow <= 4 )
1373 d = d.addDays( 1-dow ); 1373 d = d.addDays( 1-dow );
1374 else // 5,6,7 1374 else // 5,6,7
1375 d = d.addDays( 8-dow ); 1375 d = d.addDays( 8-dow );
1376 // we have the first week of the year.we are on monday 1376 // we have the first week of the year.we are on monday
1377 weekNum = d.daysTo( seda ) / 7 +1; 1377 weekNum = d.daysTo( seda ) / 7 +1;
1378 } 1378 }
1379 1379
1380 mWeekPixmap.fill( mWeekBgColor ); 1380 mWeekPixmap.fill( mWeekBgColor );
1381 QPainter p ( &mWeekPixmap ); 1381 QPainter p ( &mWeekPixmap );
1382 p.setFont( mWeekFont ); 1382 p.setFont( mWeekFont );
1383 p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) ); 1383 p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) );
1384 p.end(); 1384 p.end();
1385 QIconSet icon3 ( mWeekPixmap ); 1385 QIconSet icon3 ( mWeekPixmap );
1386 mWeekAction->setIconSet ( icon3 ); 1386 mWeekAction->setIconSet ( icon3 );
1387 1387
1388} 1388}
1389void MainWindow::updateWeekNum(const DateList &selectedDates) 1389void MainWindow::updateWeekNum(const DateList &selectedDates)
1390{ 1390{
1391 updateWeek( selectedDates.first() ); 1391 updateWeek( selectedDates.first() );
1392} 1392}
1393void MainWindow::processIncidenceSelection( Incidence *incidence ) 1393void MainWindow::processIncidenceSelection( Incidence *incidence )
1394{ 1394{
1395 1395
1396 if ( !incidence ) { 1396 if ( !incidence ) {
1397 enableIncidenceActions( false ); 1397 enableIncidenceActions( false );
1398 1398
1399 mNewSubTodoAction->setEnabled( false ); 1399 mNewSubTodoAction->setEnabled( false );
1400 setCaptionToDates(); 1400 setCaptionToDates();
1401 return; 1401 return;
1402 1402
1403 } 1403 }
1404 1404
1405 //KGlobal::locale()->formatDateTime(nextA, true); 1405 //KGlobal::locale()->formatDateTime(nextA, true);
1406 QString startString = ""; 1406 QString startString = "";
1407 if ( incidence->type() != "Todo" ) { 1407 if ( incidence->type() != "Todo" ) {
1408 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { 1408 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) {
1409 if ( incidence->doesFloat() ) { 1409 if ( incidence->doesFloat() ) {
1410 startString += ": "+incidence->dtStartDateStr( true ); 1410 startString += ": "+incidence->dtStartDateStr( true );
1411 startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); 1411 startString += " --- "+((Event*)incidence)->dtEndDateStr( true );
1412 1412
1413 } else { 1413 } else {
1414 startString = ": "+incidence->dtStartStr(true); 1414 startString = ": "+incidence->dtStartStr(true);
1415 startString += " --- "+((Event*)incidence)->dtEndStr(true); 1415 startString += " --- "+((Event*)incidence)->dtEndStr(true);
1416 1416
1417 } 1417 }
1418 1418
1419 } else { 1419 } else {
1420 if ( incidence->dtStart().time() != incidence->dtEnd().time() ) 1420 if ( incidence->dtStart().time() != incidence->dtEnd().time() )
1421 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ 1421 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+
1422 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); 1422 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time());
1423 if ( incidence->categories().contains( i18n("Birthday") ) || incidence->categories().contains( i18n("Anniversary") ) ) { 1423 if ( incidence->categories().contains( i18n("Birthday") ) || incidence->categories().contains( i18n("Anniversary") ) ) {
1424 bool ok; 1424 bool ok;
1425 QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok ); 1425 QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok );
1426 if ( ok ) { 1426 if ( ok ) {
1427 int years = noc.date().year() - incidence->dtStart().date().year(); 1427 int years = noc.date().year() - incidence->dtStart().date().year();
1428 startString += i18n(" (%1 y.)"). arg( years ); 1428 startString += i18n(" (%1 y.)"). arg( years );
1429 } 1429 }
1430 } 1430 }
1431 else 1431 else
1432 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); 1432 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true);
1433 } 1433 }
1434 1434
1435 } 1435 }
1436 else 1436 else
1437 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); 1437 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed");
1438 if ( !incidence->location().isEmpty() ) 1438 if ( !incidence->location().isEmpty() )
1439 startString += " (" +incidence->location()+")"; 1439 startString += " (" +incidence->location()+")";
1440 setCaption( incidence->summary()+startString); 1440 setCaption( incidence->summary()+startString);
1441 1441
1442 enableIncidenceActions( true ); 1442 enableIncidenceActions( true );
1443 1443
1444 if ( incidence->type() == "Event" ) { 1444 if ( incidence->type() == "Event" ) {
1445 mShowAction->setText( i18n("Show Event...") ); 1445 mShowAction->setText( i18n("Show Event...") );
1446 mEditAction->setText( i18n("Edit Event...") ); 1446 mEditAction->setText( i18n("Edit Event...") );
1447 mDeleteAction->setText( i18n("Delete Event...") ); 1447 mDeleteAction->setText( i18n("Delete Event...") );
1448 1448
1449 mNewSubTodoAction->setEnabled( false ); 1449 mNewSubTodoAction->setEnabled( false );
1450 } else if ( incidence->type() == "Todo" ) { 1450 } else if ( incidence->type() == "Todo" ) {
1451 mShowAction->setText( i18n("Show Todo...") ); 1451 mShowAction->setText( i18n("Show Todo...") );
1452 mEditAction->setText( i18n("Edit Todo...") ); 1452 mEditAction->setText( i18n("Edit Todo...") );
1453 mDeleteAction->setText( i18n("Delete Todo...") ); 1453 mDeleteAction->setText( i18n("Delete Todo...") );
1454 1454
1455 mNewSubTodoAction->setEnabled( true ); 1455 mNewSubTodoAction->setEnabled( true );
1456 } else { 1456 } else {
1457 mShowAction->setText( i18n("Show...") ); 1457 mShowAction->setText( i18n("Show...") );
1458 mShowAction->setText( i18n("Edit...") ); 1458 mShowAction->setText( i18n("Edit...") );
1459 mShowAction->setText( i18n("Delete...") ); 1459 mShowAction->setText( i18n("Delete...") );
1460 1460
1461 mNewSubTodoAction->setEnabled( false ); 1461 mNewSubTodoAction->setEnabled( false );
1462 } 1462 }
1463} 1463}
1464 1464
1465void MainWindow::enableIncidenceActions( bool enabled ) 1465void MainWindow::enableIncidenceActions( bool enabled )
1466{ 1466{
1467 mShowAction->setEnabled( enabled ); 1467 mShowAction->setEnabled( enabled );
1468 mEditAction->setEnabled( enabled ); 1468 mEditAction->setEnabled( enabled );
1469 mDeleteAction->setEnabled( enabled ); 1469 mDeleteAction->setEnabled( enabled );
1470 1470
1471 mCloneAction->setEnabled( enabled ); 1471 mCloneAction->setEnabled( enabled );
1472 mMoveAction->setEnabled( enabled ); 1472 mMoveAction->setEnabled( enabled );
1473 mBeamAction->setEnabled( enabled ); 1473 mBeamAction->setEnabled( enabled );
1474 mCancelAction->setEnabled( enabled ); 1474 mCancelAction->setEnabled( enabled );
1475} 1475}
1476 1476
1477void MainWindow::importOL() 1477void MainWindow::importOL()
1478{ 1478{
1479#ifdef _OL_IMPORT_ 1479#ifdef _OL_IMPORT_
1480 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); 1480 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this );
1481 id->exec(); 1481 id->exec();
1482 delete id; 1482 delete id;
1483 mView->updateView(); 1483 mView->updateView();
1484#endif 1484#endif
1485} 1485}
1486void MainWindow::importBday() 1486void MainWindow::importBday()
1487{ 1487{
1488 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1488 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1489 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), 1489 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"),
1490 i18n("Import!"), i18n("Cancel"), 0, 1490 i18n("Import!"), i18n("Cancel"), 0,
1491 0, 1 ); 1491 0, 1 );
1492 if ( result == 0 ) { 1492 if ( result == 0 ) {
1493 mView->importBday(); 1493 mView->importBday();
1494 1494
1495 } 1495 }
1496 1496
1497 1497
1498} 1498}
1499void MainWindow::importQtopia() 1499void MainWindow::importQtopia()
1500{ 1500{
1501#ifndef DESKTOP_VERSION 1501#ifndef DESKTOP_VERSION
1502 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1502 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1503 i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"), 1503 i18n("When importing a calendar twice\nduplicated events will be ignored!\nYou can create a backup file with\nFile - Save Calendar Backup\nto revert importing"),
1504 i18n("Import!"), i18n("Cancel"), 0, 1504 i18n("Import!"), i18n("Cancel"), 0,
1505 0, 1 ); 1505 0, 1 );
1506 if ( result == 0 ) { 1506 if ( result == 0 ) {
1507 QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); 1507 QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
1508 QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); 1508 QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
1509 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; 1509 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
1510 mView->importQtopia( categories, datebook, todolist ); 1510 mView->importQtopia( categories, datebook, todolist );
1511 } 1511 }
1512#else 1512#else
1513 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1513 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1514 i18n("Not supported \non desktop!\n"), 1514 i18n("Not supported \non desktop!\n"),
1515 i18n("Ok"), i18n("Cancel"), 0, 1515 i18n("Ok"), i18n("Cancel"), 0,
1516 0, 1 ); 1516 0, 1 );
1517 1517
1518#endif 1518#endif
1519} 1519}
1520 1520
1521void MainWindow::saveOnClose() 1521void MainWindow::saveOnClose()
1522{ 1522{
1523 KOPrefs *p = KOPrefs::instance(); 1523 KOPrefs *p = KOPrefs::instance();
1524 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); 1524 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
1525 p->mToolBarUp = iconToolBar->x() > width()/2 || 1525 p->mToolBarUp = iconToolBar->x() > width()/2 ||
1526 iconToolBar->y() > height()/2; 1526 iconToolBar->y() > height()/2;
1527 mView->writeSettings(); 1527 mView->writeSettings();
1528 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) 1528 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName()))
1529 save(); 1529 save();
1530} 1530}
1531void MainWindow::slotModifiedChanged( bool changed ) 1531void MainWindow::slotModifiedChanged( bool changed )
1532{ 1532{
1533 if ( mBlockAtStartup ) 1533 if ( mBlockAtStartup )
1534 return; 1534 return;
1535 1535
1536 int msec; 1536 int msec;
1537 // we store the changes after 1 minute, 1537 // we store the changes after 1 minute,
1538 // and for safety reasons after 10 minutes again 1538 // and for safety reasons after 10 minutes again
1539 if ( !mSyncManager->blockSave() ) 1539 if ( !mSyncManager->blockSave() )
1540 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1540 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1541 else 1541 else
1542 msec = 1000 * 600; 1542 msec = 1000 * 600;
1543 mSaveTimer.start( msec, true ); // 1 minute 1543 mSaveTimer.start( msec, true ); // 1 minute
1544 qDebug("KO: Saving File in %d secs!", msec/1000); 1544 qDebug("KO: Saving File in %d secs!", msec/1000);
1545 mCalendarModifiedFlag = true; 1545 mCalendarModifiedFlag = true;
1546} 1546}
1547void MainWindow::saveStopTimer() 1547void MainWindow::saveStopTimer()
1548{ 1548{
1549 mSaveTimer.stop(); 1549 mSaveTimer.stop();
1550 if (mSaveTimer.isActive() ) 1550 if (mSaveTimer.isActive() )
1551 qDebug("ti active "); 1551 qDebug("ti active ");
1552 else 1552 else
1553 qDebug("KO: Save timer stopped"); 1553 qDebug("KO: Save timer stopped");
1554} 1554}
1555void MainWindow::save() 1555void MainWindow::save()
1556{ 1556{
1557 if ( !mCalendarModifiedFlag ) { 1557 if ( !mCalendarModifiedFlag ) {
1558 qDebug("KO: Calendar not modified. Nothing saved."); 1558 qDebug("KO: Calendar not modified. Nothing saved.");
1559 return; 1559 return;
1560 } 1560 }
1561 if ( mSyncManager->blockSave() ) 1561 if ( mSyncManager->blockSave() )
1562 return; 1562 return;
1563 mSyncManager->setBlockSave(true); 1563 mSyncManager->setBlockSave(true);
1564 if ( mView->checkFileVersion( defaultFileName()) ) { 1564 if ( mView->checkFileVersion( defaultFileName()) ) {
1565 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1565 QTime neededSaveTime = QDateTime::currentDateTime().time();
1566 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1566 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1567 qDebug("KO: Start saving data to file!"); 1567 qDebug("KO: Start saving data to file!");
1568 mView->saveCalendar( defaultFileName() ); 1568 mView->saveCalendar( defaultFileName() );
1569 mCalendarModifiedFlag = false; 1569 mCalendarModifiedFlag = false;
1570 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 1570 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1571 qDebug("KO: Needed %d ms for saving.",msNeeded ); 1571 qDebug("KO: Needed %d ms for saving.",msNeeded );
1572 QString savemes; 1572 QString savemes;
1573 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 1573 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
1574 setCaption(savemes); 1574 setCaption(savemes);
1575 } else 1575 } else
1576 setCaption(i18n("Saving cancelled!")); 1576 setCaption(i18n("Saving cancelled!"));
1577 mSyncManager->setBlockSave( false ); 1577 mSyncManager->setBlockSave( false );
1578} 1578}
1579 1579
1580void MainWindow::keyReleaseEvent ( QKeyEvent * e) 1580void MainWindow::keyReleaseEvent ( QKeyEvent * e)
1581{ 1581{
1582 if ( !e->isAutoRepeat() ) { 1582 if ( !e->isAutoRepeat() ) {
1583 mFlagKeyPressed = false; 1583 mFlagKeyPressed = false;
1584 } 1584 }
1585} 1585}
1586void MainWindow::keyPressEvent ( QKeyEvent * e ) 1586void MainWindow::keyPressEvent ( QKeyEvent * e )
1587{ 1587{
1588 qApp->processEvents(); 1588 qApp->processEvents();
1589 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 1589 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1590 e->ignore(); 1590 e->ignore();
1591 // qDebug(" ignore %d",e->isAutoRepeat() ); 1591 // qDebug(" ignore %d",e->isAutoRepeat() );
1592 return; 1592 return;
1593 } 1593 }
1594 if (! e->isAutoRepeat() ) 1594 if (! e->isAutoRepeat() )
1595 mFlagKeyPressed = true; 1595 mFlagKeyPressed = true;
1596 KOPrefs *p = KOPrefs::instance(); 1596 KOPrefs *p = KOPrefs::instance();
1597 bool showSelectedDates = false; 1597 bool showSelectedDates = false;
1598 int size; 1598 int size;
1599 int pro = 0; 1599 int pro = 0;
1600 //qDebug("MainWindow::keyPressEvent "); 1600 //qDebug("MainWindow::keyPressEvent ");
1601 switch ( e->key() ) { 1601 switch ( e->key() ) {
1602 case Qt::Key_Right: 1602 case Qt::Key_Right:
1603 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1603 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1604 mView->goNextMonth(); 1604 mView->goNextMonth();
1605 else 1605 else
1606 mView->goNext(); 1606 mView->goNext();
1607 showSelectedDates = true; 1607 showSelectedDates = true;
1608 break; 1608 break;
1609 case Qt::Key_Left: 1609 case Qt::Key_Left:
1610 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1610 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1611 mView->goPreviousMonth(); 1611 mView->goPreviousMonth();
1612 else 1612 else
1613 mView->goPrevious(); 1613 mView->goPrevious();
1614 showSelectedDates = true; 1614 showSelectedDates = true;
1615 break; 1615 break;
1616 case Qt::Key_Down: 1616 case Qt::Key_Down:
1617 mView->viewManager()->agendaView()->scrollOneHourDown(); 1617 mView->viewManager()->agendaView()->scrollOneHourDown();
1618 break; 1618 break;
1619 case Qt::Key_Up: 1619 case Qt::Key_Up:
1620 mView->viewManager()->agendaView()->scrollOneHourUp(); 1620 mView->viewManager()->agendaView()->scrollOneHourUp();
1621 break; 1621 break;
1622 case Qt::Key_I: 1622 case Qt::Key_I:
1623 mView->showIncidence(); 1623 mView->showIncidence();
1624 break; 1624 break;
1625 case Qt::Key_Delete: 1625 case Qt::Key_Delete:
1626 case Qt::Key_Backspace: 1626 case Qt::Key_Backspace:
1627 mView->deleteIncidence(); 1627 mView->deleteIncidence();
1628 break; 1628 break;
1629 case Qt::Key_D: 1629 case Qt::Key_D:
1630 mView->viewManager()->showDayView(); 1630 mView->viewManager()->showDayView();
1631 showSelectedDates = true; 1631 showSelectedDates = true;
1632 break; 1632 break;
1633 case Qt::Key_O: 1633 case Qt::Key_O:
1634 mView->toggleFilerEnabled( ); 1634 mView->toggleFilerEnabled( );
1635 break; 1635 break;
1636 case Qt::Key_0: 1636 case Qt::Key_0:
1637 case Qt::Key_1: 1637 case Qt::Key_1:
1638 case Qt::Key_2: 1638 case Qt::Key_2:
1639 case Qt::Key_3: 1639 case Qt::Key_3:
1640 case Qt::Key_4: 1640 case Qt::Key_4:
1641 case Qt::Key_5: 1641 case Qt::Key_5:
1642 case Qt::Key_6: 1642 case Qt::Key_6:
1643 case Qt::Key_7: 1643 case Qt::Key_7:
1644 case Qt::Key_8: 1644 case Qt::Key_8:
1645 case Qt::Key_9: 1645 case Qt::Key_9:
1646 pro = e->key()-48; 1646 pro = e->key()-48;
1647 if ( pro == 0 ) 1647 if ( pro == 0 )
1648 pro = 10; 1648 pro = 10;
1649 if ( e->state() == Qt::ControlButton) 1649 if ( e->state() == Qt::ControlButton)
1650 pro += 10; 1650 pro += 10;
1651 break; 1651 break;
1652 case Qt::Key_M: 1652 case Qt::Key_M:
1653 mView->viewManager()->showMonthView(); 1653 mView->viewManager()->showMonthView();
1654 showSelectedDates = true; 1654 showSelectedDates = true;
1655 break; 1655 break;
1656 case Qt::Key_Insert: 1656 case Qt::Key_Insert:
1657 mView->newEvent(); 1657 mView->newEvent();
1658 break; 1658 break;
1659 case Qt::Key_S : 1659 case Qt::Key_S :
1660 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1660 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1661 mView->newSubTodo(); 1661 mView->newSubTodo();
1662 else 1662 else
1663 mView->dialogManager()->showSearchDialog(); 1663 mView->dialogManager()->showSearchDialog();
1664 break; 1664 break;
1665 case Qt::Key_Y : 1665 case Qt::Key_Y :
1666 case Qt::Key_Z : 1666 case Qt::Key_Z :
1667 mView->viewManager()->showWorkWeekView(); 1667 mView->viewManager()->showWorkWeekView();
1668 showSelectedDates = true; 1668 showSelectedDates = true;
1669 break; 1669 break;
1670 case Qt::Key_U : 1670 case Qt::Key_U :
1671 mView->viewManager()->showWeekView(); 1671 mView->viewManager()->showWeekView();
1672 showSelectedDates = true; 1672 showSelectedDates = true;
1673 break; 1673 break;
1674 case Qt::Key_H : 1674 case Qt::Key_H :
1675 keyBindings(); 1675 keyBindings();
1676 break; 1676 break;
1677 case Qt::Key_W: 1677 case Qt::Key_W:
1678 mView->viewManager()->showWhatsNextView(); 1678 mView->viewManager()->showWhatsNextView();
1679 break; 1679 break;
1680 case Qt::Key_L: 1680 case Qt::Key_L:
1681 mView->viewManager()->showListView(); 1681 mView->viewManager()->showListView();
1682 break; 1682 break;
1683 case Qt::Key_N: 1683 case Qt::Key_N:
1684 mView->viewManager()->showNextXView(); 1684 mView->viewManager()->showNextXView();
1685 showSelectedDates = true; 1685 showSelectedDates = true;
1686 break; 1686 break;
1687 case Qt::Key_V: 1687 case Qt::Key_V:
1688 mView->viewManager()->showTodoView(); 1688 mView->viewManager()->showTodoView();
1689 break; 1689 break;
1690 case Qt::Key_C: 1690 case Qt::Key_C:
1691 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); 1691 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() );
1692 break; 1692 break;
1693 case Qt::Key_P: 1693 case Qt::Key_P:
1694 mView->showDatePicker( ); 1694 mView->showDatePicker( );
1695 break; 1695 break;
1696 case Qt::Key_F: 1696 case Qt::Key_F:
1697 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1697 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1698 mView->editFilters(); 1698 mView->editFilters();
1699 else 1699 else
1700 mView->toggleFilter(); 1700 mView->toggleFilter();
1701 break; 1701 break;
1702 case Qt::Key_X: 1702 case Qt::Key_X:
1703 mView->toggleDateNavigatorWidget(); 1703 mView->toggleDateNavigatorWidget();
1704 break; 1704 break;
1705 case Qt::Key_Space: 1705 case Qt::Key_Space:
1706 mView->toggleExpand(); 1706 mView->toggleExpand();
1707 break; 1707 break;
1708 case Qt::Key_A: 1708 case Qt::Key_A:
1709 mView->toggleAllDaySize(); 1709 mView->toggleAllDaySize();
1710 break; 1710 break;
1711 case Qt::Key_T: 1711 case Qt::Key_T:
1712 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1712 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1713 mView->newTodo(); 1713 mView->newTodo();
1714 else { 1714 else {
1715 mView->goToday(); 1715 mView->goToday();
1716 showSelectedDates = true; 1716 showSelectedDates = true;
1717 } 1717 }
1718 break; 1718 break;
1719 case Qt::Key_J: 1719 case Qt::Key_J:
1720 mView->viewManager()->showJournalView(); 1720 mView->viewManager()->showJournalView();
1721 break; 1721 break;
1722 case Qt::Key_B: 1722 case Qt::Key_B:
1723 mView->editIncidenceDescription();; 1723 mView->editIncidenceDescription();;
1724 break; 1724 break;
1725 // case Qt::Key_Return: 1725 // case Qt::Key_Return:
1726 case Qt::Key_E: 1726 case Qt::Key_E:
1727 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1727 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1728 mView->newEvent(); 1728 mView->newEvent();
1729 else 1729 else
1730 mView->editIncidence(); 1730 mView->editIncidence();
1731 break; 1731 break;
1732 case Qt::Key_Plus: 1732 case Qt::Key_Plus:
1733 size = p->mHourSize +2; 1733 size = p->mHourSize +2;
1734 if ( size <= 22 ) 1734 if ( size <= 22 )
1735 configureAgenda( size ); 1735 configureAgenda( size );
1736 break; 1736 break;
1737 case Qt::Key_Minus: 1737 case Qt::Key_Minus:
1738 size = p->mHourSize - 2; 1738 size = p->mHourSize - 2;
1739 if ( size >= 4 ) 1739 if ( size >= 4 )
1740 configureAgenda( size ); 1740 configureAgenda( size );
1741 break; 1741 break;
1742 1742
1743 1743
1744 default: 1744 default:
1745 e->ignore(); 1745 e->ignore();
1746 } 1746 }
1747 if ( pro > 0 ) { 1747 if ( pro > 0 ) {
1748 mView->selectFilter( pro-1 ); 1748 mView->selectFilter( pro-1 );
1749 } 1749 }
1750 if ( showSelectedDates ) { 1750 if ( showSelectedDates ) {
1751 ;// setCaptionToDates(); 1751 ;// setCaptionToDates();
1752 } 1752 }
1753 1753
1754} 1754}
1755 1755
1756void MainWindow::fillFilterMenu() 1756void MainWindow::fillFilterMenu()
1757{ 1757{
1758 selectFilterMenu->clear(); 1758 selectFilterMenu->clear();
1759 bool disable = false; 1759 bool disable = false;
1760 selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 ); 1760 selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 );
1761 selectFilterMenu->insertSeparator(); 1761 selectFilterMenu->insertSeparator();
1762 if ( mView->filterView()->filtersEnabled() ) { 1762 if ( mView->filterView()->filtersEnabled() ) {
1763 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 1 ); 1763 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 1 );
1764 } 1764 }
1765 else { 1765 else {
1766 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 1 ); 1766 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 1 );
1767 disable = true; 1767 disable = true;
1768 } 1768 }
1769 selectFilterMenu->insertSeparator(); 1769 selectFilterMenu->insertSeparator();
1770 QPtrList<CalFilter> fili = mView->filters(); 1770 QPtrList<CalFilter> fili = mView->filters();
1771 CalFilter *curfilter = mView->filterView()->selectedFilter(); 1771 CalFilter *curfilter = mView->filterView()->selectedFilter();
1772 CalFilter *filter = fili.first(); 1772 CalFilter *filter = fili.first();
1773 int iii = 2; 1773 int iii = 2;
1774 while(filter) { 1774 while(filter) {
1775 selectFilterMenu->insertItem( filter->name(), iii ); 1775 selectFilterMenu->insertItem( filter->name(), iii );
1776 if ( filter == curfilter) 1776 if ( filter == curfilter)
1777 selectFilterMenu->setItemChecked( iii, true ); 1777 selectFilterMenu->setItemChecked( iii, true );
1778 if ( disable ) 1778 if ( disable )
1779 selectFilterMenu->setItemEnabled( iii, false ); 1779 selectFilterMenu->setItemEnabled( iii, false );
1780 filter = fili.next(); 1780 filter = fili.next();
1781 ++iii; 1781 ++iii;
1782 } 1782 }
1783} 1783}
1784void MainWindow::selectFilter( int fil ) 1784void MainWindow::selectFilter( int fil )
1785{ 1785{
1786 if ( fil == 0 ) { 1786 if ( fil == 0 ) {
1787 mView->editFilters( ); 1787 mView->editFilters( );
1788 } else if ( fil == 1 ){ 1788 } else if ( fil == 1 ){
1789 mView->toggleFilerEnabled( ); 1789 mView->toggleFilerEnabled( );
1790 } else { 1790 } else {
1791 mView->selectFilter( fil-2 ); 1791 mView->selectFilter( fil-2 );
1792 } 1792 }
1793} 1793}
1794void MainWindow::configureToolBar( int item ) 1794void MainWindow::configureToolBar( int item )
1795{ 1795{
1796 1796
1797 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); 1797 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) );
1798 KOPrefs *p = KOPrefs::instance(); 1798 KOPrefs *p = KOPrefs::instance();
1799 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); 1799 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 );
1800 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); 1800 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 );
1801 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); 1801 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 );
1802 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); 1802 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 );
1803 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); 1803 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 );
1804 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); 1804 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 );
1805 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); 1805 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 );
1806 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); 1806 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 );
1807 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); 1807 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 );
1808 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); 1808 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 );
1809 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); 1809 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 );
1810 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); 1810 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 );
1811 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); 1811 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 );
1812 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); 1812 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 );
1813 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); 1813 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 );
1814 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); 1814 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 );
1815 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); 1815 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 );
1816 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); 1816 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 );
1817 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); 1817 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 );
1818 // initActions(); 1818 // initActions();
1819} 1819}
1820 1820
1821void MainWindow::setCaptionToDates() 1821void MainWindow::setCaptionToDates()
1822{ 1822{
1823 QString selDates; 1823 QString selDates;
1824 selDates = KGlobal::locale()->formatDate(mView->startDate(), true); 1824 selDates = KGlobal::locale()->formatDate(mView->startDate(), true);
1825 if (mView->startDate() < mView->endDate() ) 1825 if (mView->startDate() < mView->endDate() )
1826 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); 1826 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true);
1827 else { 1827 else {
1828 QString addString; 1828 QString addString;
1829 if ( mView->startDate() == QDateTime::currentDateTime().date() ) 1829 if ( mView->startDate() == QDateTime::currentDateTime().date() )
1830 addString = i18n("Today"); 1830 addString = i18n("Today");
1831 else if ( mView->startDate() == QDateTime::currentDateTime().date().addDays(1) ) 1831 else if ( mView->startDate() == QDateTime::currentDateTime().date().addDays(1) )
1832 addString = i18n("Tomorrow"); 1832 addString = i18n("Tomorrow");
1833 if ( !addString.isEmpty() ) 1833 if ( !addString.isEmpty() )
1834 selDates = addString+", "+selDates ; 1834 selDates = addString+", "+selDates ;
1835 } 1835 }
1836 setCaption( i18n("Dates: ") + selDates ); 1836 setCaption( i18n("Dates: ") + selDates );
1837 1837
1838} 1838}
1839void MainWindow::showConfigureAgenda( ) 1839void MainWindow::showConfigureAgenda( )
1840{ 1840{
1841 int iii; 1841 int iii;
1842 for ( iii = 1;iii<= 10 ;++iii ){ 1842 for ( iii = 1;iii<= 10 ;++iii ){
1843 configureAgendaMenu->setItemChecked( (iii+1)*2, false ); 1843 configureAgendaMenu->setItemChecked( (iii+1)*2, false );
1844 } 1844 }
1845 configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true ); 1845 configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true );
1846} 1846}
1847void MainWindow::configureAgenda( int item ) 1847void MainWindow::configureAgenda( int item )
1848{ 1848{
1849 if ( KOPrefs::instance()->mHourSize == item ) 1849 if ( KOPrefs::instance()->mHourSize == item )
1850 return; 1850 return;
1851 KOPrefs::instance()->mHourSize=item; 1851 KOPrefs::instance()->mHourSize=item;
1852 mView->viewManager()->agendaView()->updateConfig(); 1852 mView->viewManager()->agendaView()->updateConfig();
1853} 1853}
1854 1854
1855void MainWindow::saveCalendar() 1855void MainWindow::saveCalendar()
1856{ 1856{
1857 QString fn = KOPrefs::instance()->mLastSaveFile; 1857 QString fn = KOPrefs::instance()->mLastSaveFile;
1858 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); 1858 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this );
1859 1859
1860 if ( fn == "" ) 1860 if ( fn == "" )
1861 return; 1861 return;
1862 QFileInfo info; 1862 QFileInfo info;
1863 info.setFile( fn ); 1863 info.setFile( fn );
1864 QString mes; 1864 QString mes;
1865 bool createbup = true; 1865 bool createbup = true;
1866 if ( info. exists() ) { 1866 if ( info. exists() ) {
1867 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; 1867 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ;
1868 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1868 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1869 i18n("Overwrite!"), i18n("Cancel"), 0, 1869 i18n("Overwrite!"), i18n("Cancel"), 0,
1870 0, 1 ); 1870 0, 1 );
1871 if ( result != 0 ) { 1871 if ( result != 0 ) {
1872 createbup = false; 1872 createbup = false;
1873 } 1873 }
1874 } 1874 }
1875 if ( createbup ) { 1875 if ( createbup ) {
1876 mView->saveCalendar( fn ); 1876 mView->saveCalendar( fn );
1877 mes = i18n("KO/Pi:Saved %1").arg(fn); 1877 mes = i18n("KO/Pi:Saved %1").arg(fn);
1878 KOPrefs::instance()->mLastSaveFile = fn; 1878 KOPrefs::instance()->mLastSaveFile = fn;
1879 setCaption(mes); 1879 setCaption(mes);
1880 } 1880 }
1881} 1881}
1882void MainWindow::loadCalendar() 1882void MainWindow::loadCalendar()
1883{ 1883{
1884 1884
1885 QString fn = KOPrefs::instance()->mLastLoadFile; 1885 QString fn = KOPrefs::instance()->mLastLoadFile;
1886 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); 1886 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this );
1887 1887
1888 if ( fn == "" ) 1888 if ( fn == "" )
1889 return; 1889 return;
1890 QFileInfo info; 1890 QFileInfo info;
1891 info.setFile( fn ); 1891 info.setFile( fn );
1892 QString mess; 1892 QString mess;
1893 bool loadbup = true; 1893 bool loadbup = true;
1894 if ( info. exists() ) { 1894 if ( info. exists() ) {
1895 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1895 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1896 int result = QMessageBox::warning( this, "KO/Pi: Warning!", 1896 int result = QMessageBox::warning( this, "KO/Pi: Warning!",
1897 mess, 1897 mess,
1898 i18n("Load!"), i18n("Cancel"), 0, 1898 i18n("Load!"), i18n("Cancel"), 0,
1899 0, 1 ); 1899 0, 1 );
1900 if ( result != 0 ) { 1900 if ( result != 0 ) {
1901 loadbup = false; 1901 loadbup = false;
1902 } 1902 }
1903 } else { 1903 } else {
1904 QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1904 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1905 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, 1905 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0,
1906 0, 1 ); 1906 0, 1 );
1907 1907
1908 return; 1908 return;
1909 } 1909 }
1910 if ( loadbup ) { 1910 if ( loadbup ) {
1911 mView->openCalendar( fn ); 1911 mView->openCalendar( fn );
1912 KOPrefs::instance()->mLastLoadFile = fn; 1912 KOPrefs::instance()->mLastLoadFile = fn;
1913 mess = i18n("KO/Pi:Loaded %1").arg(fn) ; 1913 mess = i18n("KO/Pi:Loaded %1").arg(fn) ;
1914 setCaption(mess); 1914 setCaption(mess);
1915 } 1915 }
1916 1916
1917} 1917}
1918void MainWindow::quickImportIcal() 1918void MainWindow::quickImportIcal()
1919{ 1919{
1920 importFile( KOPrefs::instance()->mLastImportFile, false ); 1920 importFile( KOPrefs::instance()->mLastImportFile, false );
1921} 1921}
1922void MainWindow::importFile( QString fn, bool quick ) 1922void MainWindow::importFile( QString fn, bool quick )
1923{ 1923{
1924 QFileInfo info; 1924 QFileInfo info;
1925 info.setFile( fn ); 1925 info.setFile( fn );
1926 QString mess; 1926 QString mess;
1927 bool loadbup = true; 1927 bool loadbup = true;
1928 if ( !info. exists() ) { 1928 if ( !info. exists() ) {
1929 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); 1929 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30));
1930 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1930 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1931 mess ); 1931 mess );
1932 return; 1932 return;
1933 } 1933 }
1934 int result = 0; 1934 int result = 0;
1935 if ( !quick ) { 1935 if ( !quick ) {
1936 mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1936 mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1937 result = QMessageBox::warning( this, "KO/Pi: Warning!", 1937 result = QMessageBox::warning( this, "KO/Pi: Warning!",
1938 mess, 1938 mess,
1939 "Import", "Cancel", 0, 1939 "Import", "Cancel", 0,
1940 0, 1 ); 1940 0, 1 );
1941 } 1941 }
1942 if ( result == 0 ) { 1942 if ( result == 0 ) {
1943 if ( mView->openCalendar( fn, true )) { 1943 if ( mView->openCalendar( fn, true )) {
1944 KOPrefs::instance()->mLastImportFile = fn; 1944 KOPrefs::instance()->mLastImportFile = fn;
1945 setCaption(i18n("Imported file successfully")); 1945 setCaption(i18n("Imported file successfully"));
1946 } else { 1946 } else {
1947 setCaption(i18n("Error importing file")); 1947 setCaption(i18n("Error importing file"));
1948 } 1948 }
1949 } 1949 }
1950} 1950}
1951 1951
1952void MainWindow::importIcal() 1952void MainWindow::importIcal()
1953{ 1953{
1954 1954
1955 QString fn =KOPrefs::instance()->mLastImportFile; 1955 QString fn =KOPrefs::instance()->mLastImportFile;
1956 1956
1957 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); 1957 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this );
1958 if ( fn == "" ) 1958 if ( fn == "" )
1959 return; 1959 return;
1960 importFile( fn, true ); 1960 importFile( fn, true );
1961 1961
1962} 1962}
1963 1963
1964void MainWindow::exportVCalendar() 1964void MainWindow::exportVCalendar()
1965{ 1965{
1966 QString fn = KOPrefs::instance()->mLastVcalFile; 1966 QString fn = KOPrefs::instance()->mLastVcalFile;
1967 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); 1967 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this );
1968 if ( fn == "" ) 1968 if ( fn == "" )
1969 return; 1969 return;
1970 QFileInfo info; 1970 QFileInfo info;
1971 info.setFile( fn ); 1971 info.setFile( fn );
1972 QString mes; 1972 QString mes;
1973 bool createbup = true; 1973 bool createbup = true;
1974 if ( info. exists() ) { 1974 if ( info. exists() ) {
1975 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 1975 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
1976 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1976 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1977 i18n("Overwrite!"), i18n("Cancel"), 0, 1977 i18n("Overwrite!"), i18n("Cancel"), 0,
1978 0, 1 ); 1978 0, 1 );
1979 if ( result != 0 ) { 1979 if ( result != 0 ) {
1980 createbup = false; 1980 createbup = false;
1981 } 1981 }
1982 } 1982 }
1983 if ( createbup ) { 1983 if ( createbup ) {
1984 if ( mView->exportVCalendar( fn ) ) { 1984 if ( mView->exportVCalendar( fn ) ) {
1985 KOPrefs::instance()->mLastVcalFile = fn; 1985 KOPrefs::instance()->mLastVcalFile = fn;
1986 if ( fn.length() > 20 ) 1986 if ( fn.length() > 20 )
1987 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; 1987 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ;
1988 else 1988 else
1989 mes = i18n("KO/Pi:Exported to %1").arg(fn ); 1989 mes = i18n("KO/Pi:Exported to %1").arg(fn );
1990 setCaption(mes); 1990 setCaption(mes);
1991 } 1991 }
1992 } 1992 }
1993 1993
1994} 1994}
1995 1995
1996void MainWindow::syncFileRequest() 1996void MainWindow::syncFileRequest()
1997{ 1997{
1998 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { 1998 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) {
1999 mSyncManager->slotSyncMenu( 999 ); 1999 mSyncManager->slotSyncMenu( 999 );
2000 } 2000 }
2001 save(); 2001 save();
2002} 2002}
2003void MainWindow::getFile( bool success ) 2003void MainWindow::getFile( bool success )
2004{ 2004{
2005 if ( ! success ) { 2005 if ( ! success ) {
2006 setCaption( i18n("Error receiving file. Nothing changed!") ); 2006 setCaption( i18n("Error receiving file. Nothing changed!") );
2007 return; 2007 return;
2008 } 2008 }
2009 mView->openCalendar( defaultFileName() ); 2009 mView->openCalendar( defaultFileName() );
2010 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { 2010 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) {
2011 mSyncManager->slotSyncMenu( 999 ); 2011 mSyncManager->slotSyncMenu( 999 );
2012 } 2012 }
2013 setCaption( i18n("Pi-Sync successful!") ); 2013 setCaption( i18n("Pi-Sync successful!") );
2014} 2014}
2015 2015
2016void MainWindow::printSel( ) 2016void MainWindow::printSel( )
2017{ 2017{
2018 mView->viewManager()->agendaView()->agenda()->printSelection(); 2018 mView->viewManager()->agendaView()->agenda()->printSelection();
2019} 2019}
2020 2020
2021void MainWindow::printCal() 2021void MainWindow::printCal()
2022{ 2022{
2023 mView->print();//mCp->showDialog(); 2023 mView->print();//mCp->showDialog();
2024} 2024}
2025 2025
2026 2026
2027#include "libkdepim/kdatepicker.h" 2027#include "libkdepim/kdatepicker.h"
2028#include <kdatetbl.h> 2028#include <kdatetbl.h>
2029void MainWindow::weekAction() 2029void MainWindow::weekAction()
2030{ 2030{
2031 int month; 2031 int month;
2032 KPopupFrame* popup = new KPopupFrame(this); 2032 KPopupFrame* popup = new KPopupFrame(this);
2033 int size = 12; 2033 KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(10, popup);
2034 if ( QApplication::desktop()->width() >= 480 )
2035 size = 18;
2036 KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(size, popup);
2037 // ----- 2034 // -----
2038 picker->resize(picker->sizeHint()); 2035 picker->resize(picker->sizeHint());
2039 popup->setMainWidget(picker); 2036 popup->setMainWidget(picker);
2040 picker->setFocus(); 2037 picker->setFocus();
2041 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); 2038 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int)));
2042 if(popup->exec(iconToolBar->mapToGlobal(QPoint(0, iconToolBar->height())))) 2039 int x = 0;
2040 int y = iconToolBar->height();
2041 int dX = 0;
2042 int dY = 0;
2043 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
2044 if ( iconToolBar->y() > height()/2 ) {
2045 dY = iconToolBar->height()+picker->sizeHint().height();
2046 y = 0;
2047 }
2048 } else {
2049 if ( iconToolBar->x() > width()/2 ) { // right side
2050 x=0;
2051 dX= iconToolBar->width()+picker->sizeHint().width();
2052 y = 0;
2053 } else {
2054 x= iconToolBar->width();
2055 y = 0;
2056 }
2057 }
2058 qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() );
2059 if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY))))
2043 { 2060 {
2044 month = picker->getResult(); 2061 month = picker->getResult();
2045 emit selectWeek ( month ); 2062 emit selectWeek ( month );
2046 //qDebug("weekSelected %d ", month); 2063 //qDebug("weekSelected %d ", month);
2047 } 2064 }
2048 delete popup; 2065 delete popup;
2049} 2066}
diff --git a/korganizer/navigatorbar.cpp b/korganizer/navigatorbar.cpp
index f05e6f6..4a31c77 100644
--- a/korganizer/navigatorbar.cpp
+++ b/korganizer/navigatorbar.cpp
@@ -1,202 +1,203 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24 24
25#include <qstring.h> 25#include <qstring.h>
26#include <qtooltip.h> 26#include <qtooltip.h>
27#include <qpushbutton.h> 27#include <qpushbutton.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#include <qframe.h> 29#include <qframe.h>
30#include <qlabel.h> 30#include <qlabel.h>
31#include <qpopupmenu.h> 31#include <qpopupmenu.h>
32#include <qapplication.h> 32#include <qapplication.h>
33 33
34#include <kdebug.h> 34#include <kdebug.h>
35#include <klocale.h> 35#include <klocale.h>
36#include <kglobal.h> 36#include <kglobal.h>
37#include <kiconloader.h> 37#include <kiconloader.h>
38#include "libkdepim/kdatepicker.h" 38#include "libkdepim/kdatepicker.h"
39#include <knotifyclient.h> 39#include <knotifyclient.h>
40#include "kdatetbl.h" 40#include "kdatetbl.h"
41 41
42#include "koglobals.h" 42#include "koglobals.h"
43#include <kglobalsettings.h>
43#include "koprefs.h" 44#include "koprefs.h"
44#ifndef KORG_NOPLUGINS 45#ifndef KORG_NOPLUGINS
45#include "kocore.h" 46#include "kocore.h"
46#endif 47#endif
47 48
48#include <kcalendarsystem.h> 49#include <kcalendarsystem.h>
49 50
50#include "navigatorbar.h" 51#include "navigatorbar.h"
51 52
52NavigatorBar::NavigatorBar( const QDate & date, QWidget *parent, const char *name ) 53NavigatorBar::NavigatorBar( const QDate & date, QWidget *parent, const char *name )
53 : QWidget( parent, name ) 54 : QWidget( parent, name )
54{ 55{
55 QBoxLayout *topLayout = new QHBoxLayout( this ); 56 QBoxLayout *topLayout = new QHBoxLayout( this );
56 57
57 // Set up the control buttons and date label 58 // Set up the control buttons and date label
58 mCtrlFrame = new QFrame( this ); 59 mCtrlFrame = new QFrame( this );
59 mCtrlFrame->setFrameStyle(QFrame::Panel|QFrame::Raised); 60 mCtrlFrame->setFrameStyle(QFrame::Panel|QFrame::Raised);
60 mCtrlFrame->setLineWidth(1); 61 mCtrlFrame->setLineWidth(1);
61 62
62 topLayout->addWidget( mCtrlFrame ); 63 topLayout->addWidget( mCtrlFrame );
63 64
64 QFont tfont = font(); 65 QFont tfont = KGlobalSettings::generalFont();//font();
65 if ( QApplication::desktop()->width() >= 480 ) 66 if ( QApplication::desktop()->width() >= 480 )
66 tfont.setPointSize(tfont.pointSize()+2); 67 tfont.setPointSize(tfont.pointSize()+2);
67 tfont.setBold(true); 68 tfont.setBold(true);
68 69
69 bool isRTL = KOGlobals::self()->reverseLayout(); 70 bool isRTL = KOGlobals::self()->reverseLayout();
70#ifndef DESKTOP_VERSION 71#ifndef DESKTOP_VERSION
71 bool isDesktop = false; 72 bool isDesktop = false;
72#else 73#else
73 bool isDesktop = true; 74 bool isDesktop = true;
74#endif 75#endif
75 if ( QString ( name ) == QString("useBigPixmaps") && QApplication::desktop()->width() > 320 ) 76 if ( QString ( name ) == QString("useBigPixmaps") && QApplication::desktop()->width() > 320 )
76 isDesktop = true; 77 isDesktop = true;
77 // Create backward navigation buttons 78 // Create backward navigation buttons
78 mPrevYear = new QPushButton( mCtrlFrame ); 79 mPrevYear = new QPushButton( mCtrlFrame );
79 mPrevYear->setPixmap( SmallIcon( isDesktop ? "2leftarrowB" : "2leftarrow" ) ); 80 mPrevYear->setPixmap( SmallIcon( isDesktop ? "2leftarrowB" : "2leftarrow" ) );
80 QToolTip::add( mPrevYear, i18n("Previous Year") ); 81 QToolTip::add( mPrevYear, i18n("Previous Year") );
81 82
82 mPrevMonth = new QPushButton( mCtrlFrame ); 83 mPrevMonth = new QPushButton( mCtrlFrame );
83 mPrevMonth->setPixmap( SmallIcon( isDesktop ? "1leftarrowB" : "1leftarrow") ); 84 mPrevMonth->setPixmap( SmallIcon( isDesktop ? "1leftarrowB" : "1leftarrow") );
84 QToolTip::add( mPrevMonth, i18n("Previous Month") ); 85 QToolTip::add( mPrevMonth, i18n("Previous Month") );
85 86
86 // Create forward navigation buttons 87 // Create forward navigation buttons
87 mNextMonth = new QPushButton( mCtrlFrame ); 88 mNextMonth = new QPushButton( mCtrlFrame );
88 mNextMonth->setPixmap( SmallIcon( isDesktop ? "1rightarrowB" : "1rightarrow") ); 89 mNextMonth->setPixmap( SmallIcon( isDesktop ? "1rightarrowB" : "1rightarrow") );
89 QToolTip::add( mNextMonth, i18n("Next Month") ); 90 QToolTip::add( mNextMonth, i18n("Next Month") );
90 91
91 mNextYear = new QPushButton( mCtrlFrame ); 92 mNextYear = new QPushButton( mCtrlFrame );
92 mNextYear->setPixmap( SmallIcon( isDesktop ? "2rightarrowB": "2rightarrow") ); 93 mNextYear->setPixmap( SmallIcon( isDesktop ? "2rightarrowB": "2rightarrow") );
93 QToolTip::add( mNextYear, i18n("Next Year") ); 94 QToolTip::add( mNextYear, i18n("Next Year") );
94 mSelectMonth = new QPushButton( mCtrlFrame ); 95 mSelectMonth = new QPushButton( mCtrlFrame );
95 // Create month name label 96 // Create month name label
96 //selectMonth->setFont( tfont ); 97 //selectMonth->setFont( tfont );
97 // selectMonth->setAlignment( AlignCenter ); 98 // selectMonth->setAlignment( AlignCenter );
98 //mDateLabel = new QLabel( selectMonth ); 99 //mDateLabel = new QLabel( selectMonth );
99 //mDateLabel->setFont( tfont ); 100 //mDateLabel->setFont( tfont );
100 //mDateLabel->setAlignment( AlignCenter ); 101 //mDateLabel->setAlignment( AlignCenter );
101 if ( QString ( name ) == QString("useBigPixmaps") ) { 102 if ( QString ( name ) == QString("useBigPixmaps") ) {
102 mNextMonth->setFlat( true); 103 mNextMonth->setFlat( true);
103 mNextYear->setFlat( true); 104 mNextYear->setFlat( true);
104 mSelectMonth->setFlat( true); 105 mSelectMonth->setFlat( true);
105 mPrevYear->setFlat( true); 106 mPrevYear->setFlat( true);
106 mPrevMonth->setFlat( true); 107 mPrevMonth->setFlat( true);
107 } 108 }
108 mSelectMonth->setFont( tfont ); 109 mSelectMonth->setFont( tfont );
109 // Set minimum width to width of widest month name label 110 // Set minimum width to width of widest month name label
110 int i; 111 int i;
111 int maxwidth = 0; 112 int maxwidth = 0;
112 QFontMetrics fm ( mSelectMonth->font() ); 113 QFontMetrics fm ( mSelectMonth->font() );
113 int width = fm.width("September '00" ); 114 int width = fm.width("September '00" );
114// for( i = 1; i <= KOGlobals::self()->calendarSystem()->monthsInYear(date); 115// for( i = 1; i <= KOGlobals::self()->calendarSystem()->monthsInYear(date);
115// ++i ) { 116// ++i ) {
116// //int width = fm.width( KOGlobals::self()->calendarSystem()->monthName(i, 117// //int width = fm.width( KOGlobals::self()->calendarSystem()->monthName(i,
117// // KOGlobals::self()->calendarSystem()->year(date) ) + " 2000" ); 118// // KOGlobals::self()->calendarSystem()->year(date) ) + " 2000" );
118// int width = fm.width("September 2000" ); 119// int width = fm.width("September 2000" );
119// if ( width > maxwidth ) maxwidth = width; 120// if ( width > maxwidth ) maxwidth = width;
120// } 121// }
121 maxwidth = width+2; 122 maxwidth = width+2;
122 int size = fm.height()+2; 123 int size = fm.height()+2;
123 if ( QApplication::desktop()->width() >= 480 ) { 124 if ( QApplication::desktop()->width() >= 480 ) {
124 size += 6; 125 size += 6;
125 maxwidth+= 6; 126 maxwidth+= 6;
126 } 127 }
127 128
128 mSelectMonth->setFixedWidth( maxwidth ); 129 mSelectMonth->setFixedWidth( maxwidth );
129 mSelectMonth->setFixedHeight( size ); 130 mSelectMonth->setFixedHeight( size );
130 mPrevYear->setFixedHeight( size ); 131 mPrevYear->setFixedHeight( size );
131 mPrevMonth->setFixedHeight( size ); 132 mPrevMonth->setFixedHeight( size );
132 mNextMonth->setFixedHeight( size ); 133 mNextMonth->setFixedHeight( size );
133 mNextYear->setFixedHeight ( size ); 134 mNextYear->setFixedHeight ( size );
134 // set up control frame layout 135 // set up control frame layout
135 QBoxLayout *ctrlLayout = new QHBoxLayout( mCtrlFrame, 1 ); 136 QBoxLayout *ctrlLayout = new QHBoxLayout( mCtrlFrame, 1 );
136 ctrlLayout->addWidget( mPrevYear, 3 ); 137 ctrlLayout->addWidget( mPrevYear, 3 );
137 ctrlLayout->addWidget( mPrevMonth, 3 ); 138 ctrlLayout->addWidget( mPrevMonth, 3 );
138 //ctrlLayout->addStretch( 1 ); 139 //ctrlLayout->addStretch( 1 );
139 // ctrlLayout->addSpacing( 1 ); 140 // ctrlLayout->addSpacing( 1 );
140 // ctrlLayout->addWidget( mDateLabel ); 141 // ctrlLayout->addWidget( mDateLabel );
141 ctrlLayout->addWidget( mSelectMonth ); 142 ctrlLayout->addWidget( mSelectMonth );
142 // ctrlLayout->addSpacing( 1 ); 143 // ctrlLayout->addSpacing( 1 );
143 // ctrlLayout->addStretch( 1 ); 144 // ctrlLayout->addStretch( 1 );
144 ctrlLayout->addWidget( mNextMonth, 3 ); 145 ctrlLayout->addWidget( mNextMonth, 3 );
145 ctrlLayout->addWidget( mNextYear, 3 ); 146 ctrlLayout->addWidget( mNextYear, 3 );
146 147
147 connect( mPrevYear, SIGNAL( clicked() ), SIGNAL( goPrevYear() ) ); 148 connect( mPrevYear, SIGNAL( clicked() ), SIGNAL( goPrevYear() ) );
148 connect( mPrevMonth, SIGNAL( clicked() ), SIGNAL( goPrevMonth() ) ); 149 connect( mPrevMonth, SIGNAL( clicked() ), SIGNAL( goPrevMonth() ) );
149 connect( mNextMonth, SIGNAL( clicked() ), SIGNAL( goNextMonth() ) ); 150 connect( mNextMonth, SIGNAL( clicked() ), SIGNAL( goNextMonth() ) );
150 connect( mNextYear, SIGNAL( clicked() ), SIGNAL( goNextYear() ) ); 151 connect( mNextYear, SIGNAL( clicked() ), SIGNAL( goNextYear() ) );
151 connect( mSelectMonth, SIGNAL( clicked() ),SLOT( selectMonth() ) ); 152 connect( mSelectMonth, SIGNAL( clicked() ),SLOT( selectMonth() ) );
152 mPrevYear->setFocusPolicy(NoFocus); 153 mPrevYear->setFocusPolicy(NoFocus);
153 mPrevMonth->setFocusPolicy(NoFocus); 154 mPrevMonth->setFocusPolicy(NoFocus);
154 mNextMonth->setFocusPolicy(NoFocus); 155 mNextMonth->setFocusPolicy(NoFocus);
155 mNextYear->setFocusPolicy(NoFocus); 156 mNextYear->setFocusPolicy(NoFocus);
156 mSelectMonth->setFocusPolicy(NoFocus); 157 mSelectMonth->setFocusPolicy(NoFocus);
157 setSizePolicy( QSizePolicy ( QSizePolicy::Expanding ,QSizePolicy::Fixed ) ); 158 setSizePolicy( QSizePolicy ( QSizePolicy::Expanding ,QSizePolicy::Fixed ) );
158 159
159} 160}
160 161
161NavigatorBar::~NavigatorBar() 162NavigatorBar::~NavigatorBar()
162{ 163{
163} 164}
164 165
165void NavigatorBar::selectMonth() 166void NavigatorBar::selectMonth()
166{ 167{
167 168
168 int month; 169 int month;
169 KPopupFrame* popup = new KPopupFrame(this); 170 KPopupFrame* popup = new KPopupFrame(this);
170 int size = 12; 171 int size = 12;
171 if ( QApplication::desktop()->width() >= 480 ) 172 if ( QApplication::desktop()->width() >= 480 )
172 size = 18; 173 size = 18;
173 KDateInternalMonthPicker* picker = new KDateInternalMonthPicker(size, popup); 174 KDateInternalMonthPicker* picker = new KDateInternalMonthPicker(size, popup);
174 // ----- 175 // -----
175 picker->resize(picker->sizeHint()); 176 picker->resize(picker->sizeHint());
176 popup->setMainWidget(picker); 177 popup->setMainWidget(picker);
177 picker->setFocus(); 178 picker->setFocus();
178 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); 179 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int)));
179 if(popup->exec(mSelectMonth->mapToGlobal(QPoint(0, mSelectMonth->height())))) 180 if(popup->exec(mSelectMonth->mapToGlobal(QPoint(0, mSelectMonth->height()))))
180 { 181 {
181 month = picker->getResult(); 182 month = picker->getResult();
182 emit monthSelected ( month ); 183 emit monthSelected ( month );
183 } else { 184 } else {
184 KNotifyClient::beep(); 185 KNotifyClient::beep();
185 } 186 }
186 delete popup; 187 delete popup;
187} 188}
188void NavigatorBar::selectDates( const KCal::DateList &dateList ) 189void NavigatorBar::selectDates( const KCal::DateList &dateList )
189{ 190{
190 if (dateList.count() > 0) { 191 if (dateList.count() > 0) {
191 QDate date = dateList.first(); 192 QDate date = dateList.first();
192 193
193 const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem(); 194 const KCalendarSystem *calSys = KOGlobals::self()->calendarSystem();
194 195
195 // compute the label at the top of the navigator 196 // compute the label at the top of the navigator
196 QString dtstr = i18n(calSys->monthName( date )) + " '" + 197 QString dtstr = i18n(calSys->monthName( date )) + " '" +
197 QString::number( calSys->year( date ) ).right(2); 198 QString::number( calSys->year( date ) ).right(2);
198 199
199 mSelectMonth->setText( dtstr ); 200 mSelectMonth->setText( dtstr );
200 } 201 }
201} 202}
202 203