summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-02-23 18:47:45 (UTC)
committer zautrix <zautrix>2005-02-23 18:47:45 (UTC)
commit31f24d21cd23bb7e4033e7ffa000e6c979133ce7 (patch) (unidiff)
tree2fa81f67efc6544a3664e6039a9602ef6f3466b9
parentfaedffc5ce8391204e0340a21eaaf582319ac824 (diff)
downloadkdepimpi-31f24d21cd23bb7e4033e7ffa000e6c979133ce7.zip
kdepimpi-31f24d21cd23bb7e4033e7ffa000e6c979133ce7.tar.gz
kdepimpi-31f24d21cd23bb7e4033e7ffa000e6c979133ce7.tar.bz2
many focus fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp54
-rw-r--r--korganizer/calendarview.h3
-rw-r--r--korganizer/koeventviewer.h2
-rw-r--r--korganizer/koeventviewerdialog.cpp21
-rw-r--r--korganizer/koeventviewerdialog.h10
-rw-r--r--korganizer/kolistview.cpp8
-rw-r--r--korganizer/kolistview.h1
-rw-r--r--korganizer/kotodoview.cpp22
-rw-r--r--korganizer/mainwindow.cpp1
9 files changed, 111 insertions, 11 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 3dac20b..1009956 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,3924 +1,3974 @@
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 234
234void CalendarView::init() 235void CalendarView::init()
235{ 236{
237
238 setFocusPolicy ( WheelFocus );
239 mViewerCallerIsSearchDialog = false;
236 mBlockShowDates = false; 240 mBlockShowDates = false;
237 beamDialog = new KOBeamPrefs(); 241 beamDialog = new KOBeamPrefs();
238 mDatePickerMode = 0; 242 mDatePickerMode = 0;
239 mCurrentSyncDevice = ""; 243 mCurrentSyncDevice = "";
240 writeLocale(); 244 writeLocale();
241 mViewManager = new KOViewManager( this ); 245 mViewManager = new KOViewManager( this );
242 mDialogManager = new KODialogManager( this ); 246 mDialogManager = new KODialogManager( this );
243 mEventViewerDialog = 0; 247 mEventViewerDialog = 0;
244 mModified = false; 248 mModified = false;
245 mReadOnly = false; 249 mReadOnly = false;
246 mSelectedIncidence = 0; 250 mSelectedIncidence = 0;
247 mCalPrinter = 0; 251 mCalPrinter = 0;
248 mFilters.setAutoDelete(true); 252 mFilters.setAutoDelete(true);
249 253
250 mCalendar->registerObserver( this ); 254 mCalendar->registerObserver( this );
251 // TODO: Make sure that view is updated, when calendar is changed. 255 // TODO: Make sure that view is updated, when calendar is changed.
252 256
253 mStorage = new FileStorage( mCalendar ); 257 mStorage = new FileStorage( mCalendar );
254 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 258 mNavigator = new DateNavigator( this, "datevav", mViewManager );
255 259
256 QBoxLayout *topLayout = (QBoxLayout*)layout(); 260 QBoxLayout *topLayout = (QBoxLayout*)layout();
257#ifndef KORG_NOSPLITTER 261#ifndef KORG_NOSPLITTER
258 // create the main layout frames. 262 // create the main layout frames.
259 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 263 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
260 topLayout->addWidget(mPanner); 264 topLayout->addWidget(mPanner);
261 265
262 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 266 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
263 "CalendarView::LeftFrame"); 267 "CalendarView::LeftFrame");
264 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 268 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
265 269
266 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, 270 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE,
267 "CalendarView::DateNavigator", QDate::currentDate() ); 271 "CalendarView::DateNavigator", QDate::currentDate() );
268 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 272 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
269 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 273 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
270 mTodoList->setNavigator( mNavigator ); 274 mTodoList->setNavigator( mNavigator );
271 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 275 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
272 276
273#ifdef KORG_NORESOURCEVIEW 277#ifdef KORG_NORESOURCEVIEW
274 mResourceView = 0; 278 mResourceView = 0;
275#else 279#else
276 if ( mResourceManager ) { 280 if ( mResourceManager ) {
277 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 281 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
278 mResourceView->updateView(); 282 mResourceView->updateView();
279 connect( mResourceView, SIGNAL( resourcesChanged() ), 283 connect( mResourceView, SIGNAL( resourcesChanged() ),
280 SLOT( updateView() ) ); 284 SLOT( updateView() ) );
281 } else { 285 } else {
282 mResourceView = 0; 286 mResourceView = 0;
283 } 287 }
284#endif 288#endif
285 QWidget *rightBox = new QWidget( mPanner ); 289 QWidget *rightBox = new QWidget( mPanner );
286 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 290 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
287 291
288 mRightFrame = new QWidgetStack( rightBox ); 292 mRightFrame = new QWidgetStack( rightBox );
289 rightLayout->addWidget( mRightFrame, 1 ); 293 rightLayout->addWidget( mRightFrame, 1 );
290 294
291 mLeftFrame = mLeftSplitter; 295 mLeftFrame = mLeftSplitter;
292#else 296#else
293 QWidget *mainBox = new QWidget( this ); 297 QWidget *mainBox = new QWidget( this );
294 QWidget *leftFrame = new QWidget( mainBox ); 298 QWidget *leftFrame = new QWidget( mainBox );
295 299
296 QBoxLayout * mainBoxLayout; 300 QBoxLayout * mainBoxLayout;
297 QBoxLayout * leftFrameLayout; 301 QBoxLayout * leftFrameLayout;
298 if ( KOPrefs::instance()->mVerticalScreen ) { 302 if ( KOPrefs::instance()->mVerticalScreen ) {
299 mainBoxLayout = new QVBoxLayout(mainBox); 303 mainBoxLayout = new QVBoxLayout(mainBox);
300 leftFrameLayout = new QHBoxLayout(leftFrame ); 304 leftFrameLayout = new QHBoxLayout(leftFrame );
301 } else { 305 } else {
302 mainBoxLayout = new QHBoxLayout(mainBox); 306 mainBoxLayout = new QHBoxLayout(mainBox);
303 leftFrameLayout = new QVBoxLayout(leftFrame ); 307 leftFrameLayout = new QVBoxLayout(leftFrame );
304 } 308 }
305 topLayout->addWidget( mainBox ); 309 topLayout->addWidget( mainBox );
306 mainBoxLayout->addWidget (leftFrame); 310 mainBoxLayout->addWidget (leftFrame);
307 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, 311 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE,
308 "CalendarView::DateNavigator", QDate::currentDate()); 312 "CalendarView::DateNavigator", QDate::currentDate());
309 // mDateNavigator->blockSignals( true ); 313 // mDateNavigator->blockSignals( true );
310 leftFrameLayout->addWidget( mDateNavigator ); 314 leftFrameLayout->addWidget( mDateNavigator );
311 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); 315 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView");
312 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall"); 316 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall");
313 mTodoList->setNavigator( mNavigator ); 317 mTodoList->setNavigator( mNavigator );
314 318
315 if ( QApplication::desktop()->width() < 480 ) { 319 if ( QApplication::desktop()->width() < 480 ) {
316 leftFrameLayout->addWidget(mFilterView); 320 leftFrameLayout->addWidget(mFilterView);
317 leftFrameLayout->addWidget(mTodoList, 2 ); 321 leftFrameLayout->addWidget(mTodoList, 2 );
318 322
319 } else { 323 } else {
320 leftFrameLayout->addWidget(mTodoList,2 ); 324 leftFrameLayout->addWidget(mTodoList,2 );
321 leftFrameLayout->addWidget(mFilterView ); 325 leftFrameLayout->addWidget(mFilterView );
322 } 326 }
323 mFilterView->hide(); 327 mFilterView->hide();
324 QWidget *rightBox = new QWidget( mainBox ); 328 QWidget *rightBox = new QWidget( mainBox );
325 mainBoxLayout->addWidget ( rightBox, 10 ); 329 mainBoxLayout->addWidget ( rightBox, 10 );
326 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 330 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
327 mRightFrame = new QWidgetStack( rightBox ); 331 mRightFrame = new QWidgetStack( rightBox );
328 rightLayout->addWidget( mRightFrame, 10 ); 332 rightLayout->addWidget( mRightFrame, 10 );
329 333
330 mLeftFrame = leftFrame; 334 mLeftFrame = leftFrame;
331 if ( KOPrefs::instance()->mVerticalScreen ) { 335 if ( KOPrefs::instance()->mVerticalScreen ) {
332 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 336 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
333 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 337 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
334 } else { 338 } else {
335 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 339 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
336 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 340 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
337 } 341 }
338 if ( !KOPrefs::instance()->mShowDateNavigator) 342 if ( !KOPrefs::instance()->mShowDateNavigator)
339 mDateNavigator->hide(); 343 mDateNavigator->hide();
340 //qDebug("Calendarview Size %d %d ", width(), height()); 344 //qDebug("Calendarview Size %d %d ", width(), height());
341#endif 345#endif
342 346
343 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 347 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
344 SLOT( showDates( const KCal::DateList & ) ) ); 348 SLOT( showDates( const KCal::DateList & ) ) );
345 349
346 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 350 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
347 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 351 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
348 352
349 353
350 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 354 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
351 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 355 mNavigator, SLOT( selectWeek( const QDate & ) ) );
352 356
353 connect( mDateNavigator, SIGNAL( goPrevYear() ), 357 connect( mDateNavigator, SIGNAL( goPrevYear() ),
354 mNavigator, SLOT( selectPreviousYear() ) ); 358 mNavigator, SLOT( selectPreviousYear() ) );
355 connect( mDateNavigator, SIGNAL( goNextYear() ), 359 connect( mDateNavigator, SIGNAL( goNextYear() ),
356 mNavigator, SLOT( selectNextYear() ) ); 360 mNavigator, SLOT( selectNextYear() ) );
357 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 361 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
358 mNavigator, SLOT( selectPreviousMonth() ) ); 362 mNavigator, SLOT( selectPreviousMonth() ) );
359 connect( mDateNavigator, SIGNAL( goNextMonth() ), 363 connect( mDateNavigator, SIGNAL( goNextMonth() ),
360 mNavigator, SLOT( selectNextMonth() ) ); 364 mNavigator, SLOT( selectNextMonth() ) );
361 365
362 connect( mDateNavigator, SIGNAL( goPrevious() ), 366 connect( mDateNavigator, SIGNAL( goPrevious() ),
363 mNavigator, SLOT( selectPrevious() ) ); 367 mNavigator, SLOT( selectPrevious() ) );
364 connect( mDateNavigator, SIGNAL( goNext() ), 368 connect( mDateNavigator, SIGNAL( goNext() ),
365 mNavigator, SLOT( selectNext() ) ); 369 mNavigator, SLOT( selectNext() ) );
366 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 370 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
367 mNavigator, SLOT( slotMonthSelect( int ) ) ); 371 mNavigator, SLOT( slotMonthSelect( int ) ) );
368 372
369 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 373 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
370 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 374 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
371 375
372 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), 376 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ),
373 SLOT( eventAdded( Event *) ) ); 377 SLOT( eventAdded( Event *) ) );
374 378
375 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 379 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
376 380
377 connect( this, SIGNAL( configChanged() ), 381 connect( this, SIGNAL( configChanged() ),
378 mDateNavigator, SLOT( updateConfig() ) ); 382 mDateNavigator, SLOT( updateConfig() ) );
379 383
380 connect( mTodoList, SIGNAL( newTodoSignal() ), 384 connect( mTodoList, SIGNAL( newTodoSignal() ),
381 SLOT( newTodo() ) ); 385 SLOT( newTodo() ) );
382 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 386 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
383 SLOT( newSubTodo( Todo * ) ) ); 387 SLOT( newSubTodo( Todo * ) ) );
384 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 388 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
385 SLOT( editTodo( Todo * ) ) ); 389 SLOT( editTodo( Todo * ) ) );
386 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 390 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
387 SLOT( showTodo( Todo *) ) ); 391 SLOT( showTodo( Todo *) ) );
388 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 392 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
389 SLOT( deleteTodo( Todo *) ) ); 393 SLOT( deleteTodo( Todo *) ) );
390 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 394 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
391 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 395 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
392 SLOT( purgeCompleted() ) ); 396 SLOT( purgeCompleted() ) );
393 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 397 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
394 SIGNAL( todoModified( Todo *, int ) ) ); 398 SIGNAL( todoModified( Todo *, int ) ) );
395 399
396 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 400 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
397 this, SLOT ( cloneIncidence( Incidence * ) ) ); 401 this, SLOT ( cloneIncidence( Incidence * ) ) );
398 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 402 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
399 this, SLOT (cancelIncidence( Incidence * ) ) ); 403 this, SLOT (cancelIncidence( Incidence * ) ) );
400 404
401 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 405 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
402 this, SLOT ( moveIncidence( Incidence * ) ) ); 406 this, SLOT ( moveIncidence( Incidence * ) ) );
403 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 407 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
404 this, SLOT ( beamIncidence( Incidence * ) ) ); 408 this, SLOT ( beamIncidence( Incidence * ) ) );
405 409
406 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 410 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
407 this, SLOT ( todo_unsub( Todo * ) ) ); 411 this, SLOT ( todo_unsub( Todo * ) ) );
408 412
409 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 413 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
410 this, SLOT ( todo_resub( Todo *,Todo * ) ) ); 414 this, SLOT ( todo_resub( Todo *,Todo * ) ) );
411 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 415 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
412 SLOT( updateTodo( Todo *, int ) ) ); 416 SLOT( updateTodo( Todo *, int ) ) );
413 connect( this, SIGNAL( todoModified( Todo *, int )), this, 417 connect( this, SIGNAL( todoModified( Todo *, int )), this,
414 SLOT( changeTodoDisplay( Todo *, int ) ) ); 418 SLOT( changeTodoDisplay( Todo *, int ) ) );
415 419
416 420
417 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 421 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
418 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 422 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
419 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 423 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 & ) ) ); 424 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
421 425
422 426
423 427
424 428
425 429
426 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 430 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
427 SLOT(checkClipboard())); 431 SLOT(checkClipboard()));
428 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 432 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
429 SLOT( processTodoListSelection( Incidence * ) ) ); 433 SLOT( processTodoListSelection( Incidence * ) ) );
430 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 434 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
431 435
432 // kdDebug() << "CalendarView::CalendarView() done" << endl; 436 // kdDebug() << "CalendarView::CalendarView() done" << endl;
433 437
434 mDateFrame = new QVBox(0,0,WType_Popup); 438 mDateFrame = new QVBox(0,0,WType_Popup);
435 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 439 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
436 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 440 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
437 mDateFrame->setLineWidth(3); 441 mDateFrame->setLineWidth(3);
438 mDateFrame->hide(); 442 mDateFrame->hide();
439 mDateFrame->setCaption( i18n( "Pick a date to display")); 443 mDateFrame->setCaption( i18n( "Pick a date to display"));
440 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 444 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
441 445
442 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 446 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
443 447
444 mEventEditor = mDialogManager->getEventEditor(); 448 mEventEditor = mDialogManager->getEventEditor();
445 mTodoEditor = mDialogManager->getTodoEditor(); 449 mTodoEditor = mDialogManager->getTodoEditor();
446 450
447 mFlagEditDescription = false; 451 mFlagEditDescription = false;
448 452
449 mSuspendTimer = new QTimer( this ); 453 mSuspendTimer = new QTimer( this );
450 mAlarmTimer = new QTimer( this ); 454 mAlarmTimer = new QTimer( this );
451 mRecheckAlarmTimer = new QTimer( this ); 455 mRecheckAlarmTimer = new QTimer( this );
452 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 456 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
453 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 457 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
454 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 458 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
455 mAlarmDialog = new AlarmDialog( this ); 459 mAlarmDialog = new AlarmDialog( this );
456 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 460 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
457 mAlarmDialog->setServerNotification( false ); 461 mAlarmDialog->setServerNotification( false );
458 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 462 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
459 463
460 464
461#ifndef DESKTOP_VERSION 465#ifndef DESKTOP_VERSION
462//US listen for arriving address resultsets 466//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&)), 467 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&))); 468 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
465#endif 469#endif
466 470
467} 471}
468 472
469 473
470CalendarView::~CalendarView() 474CalendarView::~CalendarView()
471{ 475{
472 // kdDebug() << "~CalendarView()" << endl; 476 // kdDebug() << "~CalendarView()" << endl;
473 //qDebug("CalendarView::~CalendarView() "); 477 //qDebug("CalendarView::~CalendarView() ");
474 delete mDialogManager; 478 delete mDialogManager;
475 delete mViewManager; 479 delete mViewManager;
476 delete mStorage; 480 delete mStorage;
477 delete mDateFrame ; 481 delete mDateFrame ;
478 delete beamDialog; 482 delete beamDialog;
479 //kdDebug() << "~CalendarView() done" << endl; 483 //kdDebug() << "~CalendarView() done" << endl;
480} 484}
481 485
482void CalendarView::showDay( QDate d ) 486void CalendarView::showDay( QDate d )
483{ 487{
484 dateNavigator()->blockSignals( true ); 488 dateNavigator()->blockSignals( true );
485 dateNavigator()->selectDate( d ); 489 dateNavigator()->selectDate( d );
486 dateNavigator()->blockSignals( false ); 490 dateNavigator()->blockSignals( false );
487 mViewManager->showDayView(); 491 mViewManager->showDayView();
488 //dateNavigator()->selectDate( d ); 492 //dateNavigator()->selectDate( d );
489} 493}
490void CalendarView::timerAlarm() 494void CalendarView::timerAlarm()
491{ 495{
492 //qDebug("CalendarView::timerAlarm() "); 496 //qDebug("CalendarView::timerAlarm() ");
493 computeAlarm(mAlarmNotification ); 497 computeAlarm(mAlarmNotification );
494} 498}
495 499
496void CalendarView::suspendAlarm() 500void CalendarView::suspendAlarm()
497{ 501{
498 //qDebug(" CalendarView::suspendAlarm() "); 502 //qDebug(" CalendarView::suspendAlarm() ");
499 computeAlarm(mSuspendAlarmNotification ); 503 computeAlarm(mSuspendAlarmNotification );
500 504
501} 505}
502 506
503void CalendarView::startAlarm( QString mess , QString filename) 507void CalendarView::startAlarm( QString mess , QString filename)
504{ 508{
505 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 509 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
506 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); 510 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
507 511
508} 512}
509 513
510void CalendarView::checkNextTimerAlarm() 514void CalendarView::checkNextTimerAlarm()
511{ 515{
512 mCalendar->checkAlarmForIncidence( 0, true ); 516 mCalendar->checkAlarmForIncidence( 0, true );
513} 517}
514 518
515void CalendarView::computeAlarm( QString msg ) 519void CalendarView::computeAlarm( QString msg )
516{ 520{
517 521
518 QString mess = msg; 522 QString mess = msg;
519 QString mAlarmMessage = mess.mid( 9 ); 523 QString mAlarmMessage = mess.mid( 9 );
520 QString filename = MainWindow::resourcePath(); 524 QString filename = MainWindow::resourcePath();
521 filename += "koalarm.wav"; 525 filename += "koalarm.wav";
522 QString tempfilename; 526 QString tempfilename;
523 if ( mess.left( 13 ) == "suspend_alarm") { 527 if ( mess.left( 13 ) == "suspend_alarm") {
524 bool error = false; 528 bool error = false;
525 int len = mess.mid( 13 ).find("+++"); 529 int len = mess.mid( 13 ).find("+++");
526 if ( len < 2 ) 530 if ( len < 2 )
527 error = true; 531 error = true;
528 else { 532 else {
529 tempfilename = mess.mid( 13, len ); 533 tempfilename = mess.mid( 13, len );
530 if ( !QFile::exists( tempfilename ) ) 534 if ( !QFile::exists( tempfilename ) )
531 error = true; 535 error = true;
532 } 536 }
533 if ( ! error ) { 537 if ( ! error ) {
534 filename = tempfilename; 538 filename = tempfilename;
535 } 539 }
536 mAlarmMessage = mess.mid( 13+len+3 ); 540 mAlarmMessage = mess.mid( 13+len+3 );
537 //qDebug("suspend file %s ",tempfilename.latin1() ); 541 //qDebug("suspend file %s ",tempfilename.latin1() );
538 startAlarm( mAlarmMessage, filename); 542 startAlarm( mAlarmMessage, filename);
539 return; 543 return;
540 } 544 }
541 if ( mess.left( 11 ) == "timer_alarm") { 545 if ( mess.left( 11 ) == "timer_alarm") {
542 //mTimerTime = 0; 546 //mTimerTime = 0;
543 startAlarm( mess.mid( 11 ), filename ); 547 startAlarm( mess.mid( 11 ), filename );
544 return; 548 return;
545 } 549 }
546 if ( mess.left( 10 ) == "proc_alarm") { 550 if ( mess.left( 10 ) == "proc_alarm") {
547 bool error = false; 551 bool error = false;
548 int len = mess.mid( 10 ).find("+++"); 552 int len = mess.mid( 10 ).find("+++");
549 if ( len < 2 ) 553 if ( len < 2 )
550 error = true; 554 error = true;
551 else { 555 else {
552 tempfilename = mess.mid( 10, len ); 556 tempfilename = mess.mid( 10, len );
553 if ( !QFile::exists( tempfilename ) ) 557 if ( !QFile::exists( tempfilename ) )
554 error = true; 558 error = true;
555 } 559 }
556 if ( error ) { 560 if ( error ) {
557 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 561 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
558 mAlarmMessage += mess.mid( 10+len+3+9 ); 562 mAlarmMessage += mess.mid( 10+len+3+9 );
559 } else { 563 } else {
560 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 564 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
561 //qDebug("-----system command %s ",tempfilename.latin1() ); 565 //qDebug("-----system command %s ",tempfilename.latin1() );
562#ifndef _WIN32_ 566#ifndef _WIN32_
563 if ( vfork () == 0 ) { 567 if ( vfork () == 0 ) {
564 execl ( tempfilename.latin1(), 0 ); 568 execl ( tempfilename.latin1(), 0 );
565 return; 569 return;
566 } 570 }
567#else 571#else
568 QProcess* p = new QProcess(); 572 QProcess* p = new QProcess();
569 p->addArgument( tempfilename.latin1() ); 573 p->addArgument( tempfilename.latin1() );
570 p->start(); 574 p->start();
571 return; 575 return;
572#endif 576#endif
573 577
574 return; 578 return;
575 } 579 }
576 580
577 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 581 //qDebug("+++++++system command %s ",tempfilename.latin1() );
578 } 582 }
579 if ( mess.left( 11 ) == "audio_alarm") { 583 if ( mess.left( 11 ) == "audio_alarm") {
580 bool error = false; 584 bool error = false;
581 int len = mess.mid( 11 ).find("+++"); 585 int len = mess.mid( 11 ).find("+++");
582 if ( len < 2 ) 586 if ( len < 2 )
583 error = true; 587 error = true;
584 else { 588 else {
585 tempfilename = mess.mid( 11, len ); 589 tempfilename = mess.mid( 11, len );
586 if ( !QFile::exists( tempfilename ) ) 590 if ( !QFile::exists( tempfilename ) )
587 error = true; 591 error = true;
588 } 592 }
589 if ( ! error ) { 593 if ( ! error ) {
590 filename = tempfilename; 594 filename = tempfilename;
591 } 595 }
592 mAlarmMessage = mess.mid( 11+len+3+9 ); 596 mAlarmMessage = mess.mid( 11+len+3+9 );
593 //qDebug("audio file command %s ",tempfilename.latin1() ); 597 //qDebug("audio file command %s ",tempfilename.latin1() );
594 } 598 }
595 if ( mess.left( 9 ) == "cal_alarm") { 599 if ( mess.left( 9 ) == "cal_alarm") {
596 mAlarmMessage = mess.mid( 9 ) ; 600 mAlarmMessage = mess.mid( 9 ) ;
597 } 601 }
598 602
599 startAlarm( mAlarmMessage, filename ); 603 startAlarm( mAlarmMessage, filename );
600 604
601 605
602} 606}
603 607
604void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 608void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
605{ 609{
606 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 610 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
607 611
608 mSuspendAlarmNotification = noti; 612 mSuspendAlarmNotification = noti;
609 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 613 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
610 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 614 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
611 mSuspendTimer->start( ms , true ); 615 mSuspendTimer->start( ms , true );
612 616
613} 617}
614 618
615void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 619void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
616{ 620{
617 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 621 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
618 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 622 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
619#ifndef DESKTOP_VERSION 623#ifndef DESKTOP_VERSION
620 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); 624 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() );
621#endif 625#endif
622 return; 626 return;
623 } 627 }
624 int maxSec; 628 int maxSec;
625 //maxSec = 5; //testing only 629 //maxSec = 5; //testing only
626 maxSec = 86400+3600; // one day+1hour 630 maxSec = 86400+3600; // one day+1hour
627 mAlarmNotification = noti; 631 mAlarmNotification = noti;
628 int sec = QDateTime::currentDateTime().secsTo( qdt ); 632 int sec = QDateTime::currentDateTime().secsTo( qdt );
629 if ( sec > maxSec ) { 633 if ( sec > maxSec ) {
630 mRecheckAlarmTimer->start( maxSec * 1000 ); 634 mRecheckAlarmTimer->start( maxSec * 1000 );
631 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 635 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
632 return; 636 return;
633 } else { 637 } else {
634 mRecheckAlarmTimer->stop(); 638 mRecheckAlarmTimer->stop();
635 } 639 }
636 //qDebug("Alarm timer started with secs: %d ", sec); 640 //qDebug("Alarm timer started with secs: %d ", sec);
637 mAlarmTimer->start( sec *1000 , true ); 641 mAlarmTimer->start( sec *1000 , true );
638 642
639} 643}
640// called by mRecheckAlarmTimer to get next alarm 644// called by mRecheckAlarmTimer to get next alarm
641// we need this, because a QTimer has only a max range of 25 days 645// we need this, because a QTimer has only a max range of 25 days
642void CalendarView::recheckTimerAlarm() 646void CalendarView::recheckTimerAlarm()
643{ 647{
644 mAlarmTimer->stop(); 648 mAlarmTimer->stop();
645 mRecheckAlarmTimer->stop(); 649 mRecheckAlarmTimer->stop();
646 mCalendar->checkAlarmForIncidence( 0, true ); 650 mCalendar->checkAlarmForIncidence( 0, true );
647} 651}
648void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 652void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
649{ 653{
650 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 654 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
651 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 655 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
652#ifndef DESKTOP_VERSION 656#ifndef DESKTOP_VERSION
653 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 657 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
654#endif 658#endif
655 return; 659 return;
656 } 660 }
657 mAlarmTimer->stop(); 661 mAlarmTimer->stop();
658} 662}
659void CalendarView::selectWeekNum ( int num ) 663void CalendarView::selectWeekNum ( int num )
660{ 664{
661 dateNavigator()->blockSignals( true ); 665 dateNavigator()->blockSignals( true );
662 dateNavigator()->selectWeek( num ); 666 dateNavigator()->selectWeek( num );
663 dateNavigator()->blockSignals( false ); 667 dateNavigator()->blockSignals( false );
664 mViewManager->showWeekView(); 668 mViewManager->showWeekView();
665} 669}
666KOViewManager *CalendarView::viewManager() 670KOViewManager *CalendarView::viewManager()
667{ 671{
668 return mViewManager; 672 return mViewManager;
669} 673}
670 674
671KODialogManager *CalendarView::dialogManager() 675KODialogManager *CalendarView::dialogManager()
672{ 676{
673 return mDialogManager; 677 return mDialogManager;
674} 678}
675 679
676QDate CalendarView::startDate() 680QDate CalendarView::startDate()
677{ 681{
678 DateList dates = mNavigator->selectedDates(); 682 DateList dates = mNavigator->selectedDates();
679 683
680 return dates.first(); 684 return dates.first();
681} 685}
682 686
683QDate CalendarView::endDate() 687QDate CalendarView::endDate()
684{ 688{
685 DateList dates = mNavigator->selectedDates(); 689 DateList dates = mNavigator->selectedDates();
686 690
687 return dates.last(); 691 return dates.last();
688} 692}
689 693
690 694
691void CalendarView::createPrinter() 695void CalendarView::createPrinter()
692{ 696{
693#ifndef KORG_NOPRINTER 697#ifndef KORG_NOPRINTER
694 if (!mCalPrinter) { 698 if (!mCalPrinter) {
695 mCalPrinter = new CalPrinter(this, mCalendar); 699 mCalPrinter = new CalPrinter(this, mCalendar);
696 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 700 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
697 } 701 }
698#endif 702#endif
699} 703}
700 704
701 705
702//KOPrefs::instance()->mWriteBackFile 706//KOPrefs::instance()->mWriteBackFile
703//KOPrefs::instance()->mWriteBackExistingOnly 707//KOPrefs::instance()->mWriteBackExistingOnly
704 708
705// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 709// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
706// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 710// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
707// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 711// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
708// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 712// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
709// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 713// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
710// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 714// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
711 715
712int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 716int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
713{ 717{
714 718
715 // 0 equal 719 // 0 equal
716 // 1 take local 720 // 1 take local
717 // 2 take remote 721 // 2 take remote
718 // 3 cancel 722 // 3 cancel
719 QDateTime lastSync = mLastCalendarSync; 723 QDateTime lastSync = mLastCalendarSync;
720 QDateTime localMod = local->lastModified(); 724 QDateTime localMod = local->lastModified();
721 QDateTime remoteMod = remote->lastModified(); 725 QDateTime remoteMod = remote->lastModified();
722 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 726 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
723 bool remCh, locCh; 727 bool remCh, locCh;
724 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 728 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
725 //if ( remCh ) 729 //if ( remCh )
726 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 730 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
727 locCh = ( localMod > mLastCalendarSync ); 731 locCh = ( localMod > mLastCalendarSync );
728 if ( !remCh && ! locCh ) { 732 if ( !remCh && ! locCh ) {
729 //qDebug("both not changed "); 733 //qDebug("both not changed ");
730 lastSync = localMod.addDays(1); 734 lastSync = localMod.addDays(1);
731 if ( mode <= SYNC_PREF_ASK ) 735 if ( mode <= SYNC_PREF_ASK )
732 return 0; 736 return 0;
733 } else { 737 } else {
734 if ( locCh ) { 738 if ( locCh ) {
735 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); 739 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1());
736 lastSync = localMod.addDays( -1 ); 740 lastSync = localMod.addDays( -1 );
737 if ( !remCh ) 741 if ( !remCh )
738 remoteMod = ( lastSync.addDays( -1 ) ); 742 remoteMod = ( lastSync.addDays( -1 ) );
739 } else { 743 } else {
740 //qDebug(" not loc changed "); 744 //qDebug(" not loc changed ");
741 lastSync = localMod.addDays( 1 ); 745 lastSync = localMod.addDays( 1 );
742 if ( remCh ) 746 if ( remCh )
743 remoteMod =( lastSync.addDays( 1 ) ); 747 remoteMod =( lastSync.addDays( 1 ) );
744 748
745 } 749 }
746 } 750 }
747 full = true; 751 full = true;
748 if ( mode < SYNC_PREF_ASK ) 752 if ( mode < SYNC_PREF_ASK )
749 mode = SYNC_PREF_ASK; 753 mode = SYNC_PREF_ASK;
750 } else { 754 } else {
751 if ( localMod == remoteMod ) 755 if ( localMod == remoteMod )
752 // if ( local->revision() == remote->revision() ) 756 // if ( local->revision() == remote->revision() )
753 return 0; 757 return 0;
754 758
755 } 759 }
756 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 760 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
757 761
758 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); 762 //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() ); 763 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() );
760 //full = true; //debug only 764 //full = true; //debug only
761 if ( full ) { 765 if ( full ) {
762 bool equ = false; 766 bool equ = false;
763 if ( local->type() == "Event" ) { 767 if ( local->type() == "Event" ) {
764 equ = (*((Event*) local) == *((Event*) remote)); 768 equ = (*((Event*) local) == *((Event*) remote));
765 } 769 }
766 else if ( local->type() =="Todo" ) 770 else if ( local->type() =="Todo" )
767 equ = (*((Todo*) local) == (*(Todo*) remote)); 771 equ = (*((Todo*) local) == (*(Todo*) remote));
768 else if ( local->type() =="Journal" ) 772 else if ( local->type() =="Journal" )
769 equ = (*((Journal*) local) == *((Journal*) remote)); 773 equ = (*((Journal*) local) == *((Journal*) remote));
770 if ( equ ) { 774 if ( equ ) {
771 //qDebug("equal "); 775 //qDebug("equal ");
772 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 776 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
773 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 777 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
774 } 778 }
775 if ( mode < SYNC_PREF_FORCE_LOCAL ) 779 if ( mode < SYNC_PREF_FORCE_LOCAL )
776 return 0; 780 return 0;
777 781
778 }//else //debug only 782 }//else //debug only
779 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 783 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
780 } 784 }
781 int result; 785 int result;
782 bool localIsNew; 786 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() ); 787 //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 788
785 if ( full && mode < SYNC_PREF_NEWEST ) 789 if ( full && mode < SYNC_PREF_NEWEST )
786 mode = SYNC_PREF_ASK; 790 mode = SYNC_PREF_ASK;
787 791
788 switch( mode ) { 792 switch( mode ) {
789 case SYNC_PREF_LOCAL: 793 case SYNC_PREF_LOCAL:
790 if ( lastSync > remoteMod ) 794 if ( lastSync > remoteMod )
791 return 1; 795 return 1;
792 if ( lastSync > localMod ) 796 if ( lastSync > localMod )
793 return 2; 797 return 2;
794 return 1; 798 return 1;
795 break; 799 break;
796 case SYNC_PREF_REMOTE: 800 case SYNC_PREF_REMOTE:
797 if ( lastSync > remoteMod ) 801 if ( lastSync > remoteMod )
798 return 1; 802 return 1;
799 if ( lastSync > localMod ) 803 if ( lastSync > localMod )
800 return 2; 804 return 2;
801 return 2; 805 return 2;
802 break; 806 break;
803 case SYNC_PREF_NEWEST: 807 case SYNC_PREF_NEWEST:
804 if ( localMod > remoteMod ) 808 if ( localMod > remoteMod )
805 return 1; 809 return 1;
806 else 810 else
807 return 2; 811 return 2;
808 break; 812 break;
809 case SYNC_PREF_ASK: 813 case SYNC_PREF_ASK:
810 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 814 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
811 if ( lastSync > remoteMod ) 815 if ( lastSync > remoteMod )
812 return 1; 816 return 1;
813 if ( lastSync > localMod ) 817 if ( lastSync > localMod )
814 return 2; 818 return 2;
815 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 819 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
816 localIsNew = localMod >= remoteMod; 820 localIsNew = localMod >= remoteMod;
817 if ( localIsNew ) 821 if ( localIsNew )
818 getEventViewerDialog()->setColorMode( 1 ); 822 getEventViewerDialog()->setColorMode( 1 );
819 else 823 else
820 getEventViewerDialog()->setColorMode( 2 ); 824 getEventViewerDialog()->setColorMode( 2 );
821 getEventViewerDialog()->setIncidence(local); 825 getEventViewerDialog()->setIncidence(local);
822 if ( localIsNew ) 826 if ( localIsNew )
823 getEventViewerDialog()->setColorMode( 2 ); 827 getEventViewerDialog()->setColorMode( 2 );
824 else 828 else
825 getEventViewerDialog()->setColorMode( 1 ); 829 getEventViewerDialog()->setColorMode( 1 );
826 getEventViewerDialog()->addIncidence(remote); 830 getEventViewerDialog()->addIncidence(remote);
827 getEventViewerDialog()->setColorMode( 0 ); 831 getEventViewerDialog()->setColorMode( 0 );
828 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 832 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
829 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 833 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
830 getEventViewerDialog()->showMe(); 834 getEventViewerDialog()->showMe();
831 result = getEventViewerDialog()->executeS( localIsNew ); 835 result = getEventViewerDialog()->executeS( localIsNew );
832 return result; 836 return result;
833 837
834 break; 838 break;
835 case SYNC_PREF_FORCE_LOCAL: 839 case SYNC_PREF_FORCE_LOCAL:
836 return 1; 840 return 1;
837 break; 841 break;
838 case SYNC_PREF_FORCE_REMOTE: 842 case SYNC_PREF_FORCE_REMOTE:
839 return 2; 843 return 2;
840 break; 844 break;
841 845
842 default: 846 default:
843 // SYNC_PREF_TAKE_BOTH not implemented 847 // SYNC_PREF_TAKE_BOTH not implemented
844 break; 848 break;
845 } 849 }
846 return 0; 850 return 0;
847} 851}
848Event* CalendarView::getLastSyncEvent() 852Event* CalendarView::getLastSyncEvent()
849{ 853{
850 Event* lse; 854 Event* lse;
851 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 855 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
852 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 856 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
853 if (!lse) { 857 if (!lse) {
854 lse = new Event(); 858 lse = new Event();
855 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 859 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
856 QString sum = ""; 860 QString sum = "";
857 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 861 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
858 sum = "E: "; 862 sum = "E: ";
859 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 863 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
860 lse->setDtStart( mLastCalendarSync ); 864 lse->setDtStart( mLastCalendarSync );
861 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 865 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
862 lse->setCategories( i18n("SyncEvent") ); 866 lse->setCategories( i18n("SyncEvent") );
863 lse->setReadOnly( true ); 867 lse->setReadOnly( true );
864 mCalendar->addEvent( lse ); 868 mCalendar->addEvent( lse );
865 } 869 }
866 870
867 return lse; 871 return lse;
868 872
869} 873}
870 874
871// we check, if the to delete event has a id for a profile 875// 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 876// if yes, we set this id in the profile to delete
873void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 877void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
874{ 878{
875 if ( lastSync.count() == 0 ) { 879 if ( lastSync.count() == 0 ) {
876 //qDebug(" lastSync.count() == 0"); 880 //qDebug(" lastSync.count() == 0");
877 return; 881 return;
878 } 882 }
879 if ( toDelete->type() == "Journal" ) 883 if ( toDelete->type() == "Journal" )
880 return; 884 return;
881 885
882 Event* eve = lastSync.first(); 886 Event* eve = lastSync.first();
883 887
884 while ( eve ) { 888 while ( eve ) {
885 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 889 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
886 if ( !id.isEmpty() ) { 890 if ( !id.isEmpty() ) {
887 QString des = eve->description(); 891 QString des = eve->description();
888 QString pref = "e"; 892 QString pref = "e";
889 if ( toDelete->type() == "Todo" ) 893 if ( toDelete->type() == "Todo" )
890 pref = "t"; 894 pref = "t";
891 des += pref+ id + ","; 895 des += pref+ id + ",";
892 eve->setReadOnly( false ); 896 eve->setReadOnly( false );
893 eve->setDescription( des ); 897 eve->setDescription( des );
894 //qDebug("setdes %s ", des.latin1()); 898 //qDebug("setdes %s ", des.latin1());
895 eve->setReadOnly( true ); 899 eve->setReadOnly( true );
896 } 900 }
897 eve = lastSync.next(); 901 eve = lastSync.next();
898 } 902 }
899 903
900} 904}
901void CalendarView::checkExternalId( Incidence * inc ) 905void CalendarView::checkExternalId( Incidence * inc )
902{ 906{
903 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 907 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
904 checkExternSyncEvent( lastSync, inc ); 908 checkExternSyncEvent( lastSync, inc );
905 909
906} 910}
907bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 911bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
908{ 912{
909 bool syncOK = true; 913 bool syncOK = true;
910 int addedEvent = 0; 914 int addedEvent = 0;
911 int addedEventR = 0; 915 int addedEventR = 0;
912 int deletedEventR = 0; 916 int deletedEventR = 0;
913 int deletedEventL = 0; 917 int deletedEventL = 0;
914 int changedLocal = 0; 918 int changedLocal = 0;
915 int changedRemote = 0; 919 int changedRemote = 0;
916 int filteredIN = 0; 920 int filteredIN = 0;
917 int filteredOUT = 0; 921 int filteredOUT = 0;
918 //QPtrList<Event> el = local->rawEvents(); 922 //QPtrList<Event> el = local->rawEvents();
919 Event* eventR; 923 Event* eventR;
920 QString uid; 924 QString uid;
921 int take; 925 int take;
922 Event* eventL; 926 Event* eventL;
923 Event* eventRSync; 927 Event* eventRSync;
924 Event* eventLSync; 928 Event* eventLSync;
925 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 929 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
926 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 930 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
927 bool fullDateRange = false; 931 bool fullDateRange = false;
928 local->resetTempSyncStat(); 932 local->resetTempSyncStat();
929 mLastCalendarSync = QDateTime::currentDateTime(); 933 mLastCalendarSync = QDateTime::currentDateTime();
930 if ( mSyncManager->syncWithDesktop() ) { 934 if ( mSyncManager->syncWithDesktop() ) {
931 remote->resetPilotStat(1); 935 remote->resetPilotStat(1);
932 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 936 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
933 mLastCalendarSync = KSyncManager::mRequestedSyncEvent; 937 mLastCalendarSync = KSyncManager::mRequestedSyncEvent;
934 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); 938 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() );
935 } else { 939 } else {
936 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 940 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
937 } 941 }
938 } 942 }
939 QDateTime modifiedCalendar = mLastCalendarSync; 943 QDateTime modifiedCalendar = mLastCalendarSync;
940 eventLSync = getLastSyncEvent(); 944 eventLSync = getLastSyncEvent();
941 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 945 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
942 if ( eventR ) { 946 if ( eventR ) {
943 eventRSync = (Event*) eventR->clone(); 947 eventRSync = (Event*) eventR->clone();
944 remote->deleteEvent(eventR ); 948 remote->deleteEvent(eventR );
945 949
946 } else { 950 } else {
947 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { 951 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) {
948 eventRSync = (Event*)eventLSync->clone(); 952 eventRSync = (Event*)eventLSync->clone();
949 } else { 953 } else {
950 fullDateRange = true; 954 fullDateRange = true;
951 eventRSync = new Event(); 955 eventRSync = new Event();
952 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 956 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
953 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 957 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
954 eventRSync->setDtStart( mLastCalendarSync ); 958 eventRSync->setDtStart( mLastCalendarSync );
955 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 959 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
956 eventRSync->setCategories( i18n("SyncEvent") ); 960 eventRSync->setCategories( i18n("SyncEvent") );
957 } 961 }
958 } 962 }
959 if ( eventLSync->dtStart() == mLastCalendarSync ) 963 if ( eventLSync->dtStart() == mLastCalendarSync )
960 fullDateRange = true; 964 fullDateRange = true;
961 965
962 if ( ! fullDateRange ) { 966 if ( ! fullDateRange ) {
963 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 967 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
964 968
965 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 969 // 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()); 970 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
967 fullDateRange = true; 971 fullDateRange = true;
968 } 972 }
969 } 973 }
970 if ( mSyncManager->syncWithDesktop() ) { 974 if ( mSyncManager->syncWithDesktop() ) {
971 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); 975 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync );
972 } 976 }
973 if ( fullDateRange ) 977 if ( fullDateRange )
974 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 978 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
975 else 979 else
976 mLastCalendarSync = eventLSync->dtStart(); 980 mLastCalendarSync = eventLSync->dtStart();
977 // for resyncing if own file has changed 981 // for resyncing if own file has changed
978 if ( mCurrentSyncDevice == "deleteaftersync" ) { 982 if ( mCurrentSyncDevice == "deleteaftersync" ) {
979 mLastCalendarSync = loadedFileVersion; 983 mLastCalendarSync = loadedFileVersion;
980 //qDebug("setting mLastCalendarSync "); 984 //qDebug("setting mLastCalendarSync ");
981 } 985 }
982 //qDebug("*************************** "); 986 //qDebug("*************************** ");
983 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); 987 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange);
984 QPtrList<Incidence> er = remote->rawIncidences(); 988 QPtrList<Incidence> er = remote->rawIncidences();
985 Incidence* inR = er.first(); 989 Incidence* inR = er.first();
986 Incidence* inL; 990 Incidence* inL;
987 QProgressBar bar( er.count(),0 ); 991 QProgressBar bar( er.count(),0 );
988 bar.setCaption (i18n("Syncing - close to abort!") ); 992 bar.setCaption (i18n("Syncing - close to abort!") );
989 993
990 // ************** setting up filter ************* 994 // ************** setting up filter *************
991 CalFilter *filterIN = 0; 995 CalFilter *filterIN = 0;
992 CalFilter *filterOUT = 0; 996 CalFilter *filterOUT = 0;
993 CalFilter *filter = mFilters.first(); 997 CalFilter *filter = mFilters.first();
994 while(filter) { 998 while(filter) {
995 if ( filter->name() == mSyncManager->mFilterInCal ) 999 if ( filter->name() == mSyncManager->mFilterInCal )
996 filterIN = filter; 1000 filterIN = filter;
997 if ( filter->name() == mSyncManager->mFilterOutCal ) 1001 if ( filter->name() == mSyncManager->mFilterOutCal )
998 filterOUT = filter; 1002 filterOUT = filter;
999 filter = mFilters.next(); 1003 filter = mFilters.next();
1000 } 1004 }
1001 int w = 300; 1005 int w = 300;
1002 if ( QApplication::desktop()->width() < 320 ) 1006 if ( QApplication::desktop()->width() < 320 )
1003 w = 220; 1007 w = 220;
1004 int h = bar.sizeHint().height() ; 1008 int h = bar.sizeHint().height() ;
1005 int dw = QApplication::desktop()->width(); 1009 int dw = QApplication::desktop()->width();
1006 int dh = QApplication::desktop()->height(); 1010 int dh = QApplication::desktop()->height();
1007 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1011 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1008 bar.show(); 1012 bar.show();
1009 int modulo = (er.count()/10)+1; 1013 int modulo = (er.count()/10)+1;
1010 int incCounter = 0; 1014 int incCounter = 0;
1011 while ( inR ) { 1015 while ( inR ) {
1012 if ( ! bar.isVisible() ) 1016 if ( ! bar.isVisible() )
1013 return false; 1017 return false;
1014 if ( incCounter % modulo == 0 ) 1018 if ( incCounter % modulo == 0 )
1015 bar.setProgress( incCounter ); 1019 bar.setProgress( incCounter );
1016 ++incCounter; 1020 ++incCounter;
1017 uid = inR->uid(); 1021 uid = inR->uid();
1018 bool skipIncidence = false; 1022 bool skipIncidence = false;
1019 if ( uid.left(15) == QString("last-syncEvent-") ) 1023 if ( uid.left(15) == QString("last-syncEvent-") )
1020 skipIncidence = true; 1024 skipIncidence = true;
1021 QString idS; 1025 QString idS;
1022 qApp->processEvents(); 1026 qApp->processEvents();
1023 if ( !skipIncidence ) { 1027 if ( !skipIncidence ) {
1024 inL = local->incidence( uid ); 1028 inL = local->incidence( uid );
1025 if ( inL ) { // maybe conflict - same uid in both calendars 1029 if ( inL ) { // maybe conflict - same uid in both calendars
1026 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1030 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1027 //qDebug("take %d %s ", take, inL->summary().latin1()); 1031 //qDebug("take %d %s ", take, inL->summary().latin1());
1028 if ( take == 3 ) 1032 if ( take == 3 )
1029 return false; 1033 return false;
1030 if ( take == 1 ) {// take local ********************** 1034 if ( take == 1 ) {// take local **********************
1031 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1035 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1032 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1036 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1033 else 1037 else
1034 idS = inR->IDStr(); 1038 idS = inR->IDStr();
1035 remote->deleteIncidence( inR ); 1039 remote->deleteIncidence( inR );
1036 inR = inL->clone(); 1040 inR = inL->clone();
1037 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1041 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1038 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1042 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1039 inR->setIDStr( idS ); 1043 inR->setIDStr( idS );
1040 remote->addIncidence( inR ); 1044 remote->addIncidence( inR );
1041 if ( mSyncManager->syncWithDesktop() ) 1045 if ( mSyncManager->syncWithDesktop() )
1042 inR->setPilotId( 2 ); 1046 inR->setPilotId( 2 );
1043 ++changedRemote; 1047 ++changedRemote;
1044 } else {// take remote ********************** 1048 } else {// take remote **********************
1045 idS = inL->IDStr(); 1049 idS = inL->IDStr();
1046 int pid = inL->pilotId(); 1050 int pid = inL->pilotId();
1047 local->deleteIncidence( inL ); 1051 local->deleteIncidence( inL );
1048 inL = inR->clone(); 1052 inL = inR->clone();
1049 if ( mSyncManager->syncWithDesktop() ) 1053 if ( mSyncManager->syncWithDesktop() )
1050 inL->setPilotId( pid ); 1054 inL->setPilotId( pid );
1051 inL->setIDStr( idS ); 1055 inL->setIDStr( idS );
1052 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1056 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1053 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1057 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1054 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1058 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1055 } 1059 }
1056 local->addIncidence( inL ); 1060 local->addIncidence( inL );
1057 ++changedLocal; 1061 ++changedLocal;
1058 } 1062 }
1059 } 1063 }
1060 } else { // no conflict ********** add or delete remote 1064 } else { // no conflict ********** add or delete remote
1061 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ 1065 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){
1062 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1066 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1063 QString des = eventLSync->description(); 1067 QString des = eventLSync->description();
1064 QString pref = "e"; 1068 QString pref = "e";
1065 if ( inR->type() == "Todo" ) 1069 if ( inR->type() == "Todo" )
1066 pref = "t"; 1070 pref = "t";
1067 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1071 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1068 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1072 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1069 //remote->deleteIncidence( inR ); 1073 //remote->deleteIncidence( inR );
1070 ++deletedEventR; 1074 ++deletedEventR;
1071 } else { 1075 } else {
1072 inR->setLastModified( modifiedCalendar ); 1076 inR->setLastModified( modifiedCalendar );
1073 inL = inR->clone(); 1077 inL = inR->clone();
1074 inL->setIDStr( ":" ); 1078 inL->setIDStr( ":" );
1075 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1079 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1076 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1080 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1077 local->addIncidence( inL ); 1081 local->addIncidence( inL );
1078 ++addedEvent; 1082 ++addedEvent;
1079 1083
1080 } 1084 }
1081 } else { 1085 } else {
1082 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1086 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1083 inR->setLastModified( modifiedCalendar ); 1087 inR->setLastModified( modifiedCalendar );
1084 inL = inR->clone(); 1088 inL = inR->clone();
1085 inL->setIDStr( ":" ); 1089 inL->setIDStr( ":" );
1086 local->addIncidence( inL ); 1090 local->addIncidence( inL );
1087 ++addedEvent; 1091 ++addedEvent;
1088 1092
1089 } else { 1093 } else {
1090 checkExternSyncEvent(eventRSyncSharp, inR); 1094 checkExternSyncEvent(eventRSyncSharp, inR);
1091 remote->deleteIncidence( inR ); 1095 remote->deleteIncidence( inR );
1092 ++deletedEventR; 1096 ++deletedEventR;
1093 } 1097 }
1094 } 1098 }
1095 } else { 1099 } else {
1096 ++filteredIN; 1100 ++filteredIN;
1097 } 1101 }
1098 } 1102 }
1099 } 1103 }
1100 inR = er.next(); 1104 inR = er.next();
1101 } 1105 }
1102 QPtrList<Incidence> el = local->rawIncidences(); 1106 QPtrList<Incidence> el = local->rawIncidences();
1103 inL = el.first(); 1107 inL = el.first();
1104 modulo = (el.count()/10)+1; 1108 modulo = (el.count()/10)+1;
1105 bar.setCaption (i18n("Add / remove events") ); 1109 bar.setCaption (i18n("Add / remove events") );
1106 bar.setTotalSteps ( el.count() ) ; 1110 bar.setTotalSteps ( el.count() ) ;
1107 bar.show(); 1111 bar.show();
1108 incCounter = 0; 1112 incCounter = 0;
1109 1113
1110 while ( inL ) { 1114 while ( inL ) {
1111 1115
1112 qApp->processEvents(); 1116 qApp->processEvents();
1113 if ( ! bar.isVisible() ) 1117 if ( ! bar.isVisible() )
1114 return false; 1118 return false;
1115 if ( incCounter % modulo == 0 ) 1119 if ( incCounter % modulo == 0 )
1116 bar.setProgress( incCounter ); 1120 bar.setProgress( incCounter );
1117 ++incCounter; 1121 ++incCounter;
1118 uid = inL->uid(); 1122 uid = inL->uid();
1119 bool skipIncidence = false; 1123 bool skipIncidence = false;
1120 if ( uid.left(15) == QString("last-syncEvent-") ) 1124 if ( uid.left(15) == QString("last-syncEvent-") )
1121 skipIncidence = true; 1125 skipIncidence = true;
1122 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) 1126 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
1123 skipIncidence = true; 1127 skipIncidence = true;
1124 if ( !skipIncidence ) { 1128 if ( !skipIncidence ) {
1125 inR = remote->incidence( uid ); 1129 inR = remote->incidence( uid );
1126 if ( ! inR ) { 1130 if ( ! inR ) {
1127 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ 1131 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){
1128 // no conflict ********** add or delete local 1132 // no conflict ********** add or delete local
1129 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1133 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1130 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1134 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1131 checkExternSyncEvent(eventLSyncSharp, inL); 1135 checkExternSyncEvent(eventLSyncSharp, inL);
1132 local->deleteIncidence( inL ); 1136 local->deleteIncidence( inL );
1133 ++deletedEventL; 1137 ++deletedEventL;
1134 } else { 1138 } else {
1135 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1139 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1136 inL->removeID(mCurrentSyncDevice ); 1140 inL->removeID(mCurrentSyncDevice );
1137 ++addedEventR; 1141 ++addedEventR;
1138 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1142 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1139 inL->setLastModified( modifiedCalendar ); 1143 inL->setLastModified( modifiedCalendar );
1140 inR = inL->clone(); 1144 inR = inL->clone();
1141 inR->setIDStr( ":" ); 1145 inR->setIDStr( ":" );
1142 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1146 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1143 remote->addIncidence( inR ); 1147 remote->addIncidence( inR );
1144 } 1148 }
1145 } 1149 }
1146 } else { 1150 } else {
1147 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1151 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1148 checkExternSyncEvent(eventLSyncSharp, inL); 1152 checkExternSyncEvent(eventLSyncSharp, inL);
1149 local->deleteIncidence( inL ); 1153 local->deleteIncidence( inL );
1150 ++deletedEventL; 1154 ++deletedEventL;
1151 } else { 1155 } else {
1152 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1156 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1153 ++addedEventR; 1157 ++addedEventR;
1154 inL->setLastModified( modifiedCalendar ); 1158 inL->setLastModified( modifiedCalendar );
1155 inR = inL->clone(); 1159 inR = inL->clone();
1156 inR->setIDStr( ":" ); 1160 inR->setIDStr( ":" );
1157 remote->addIncidence( inR ); 1161 remote->addIncidence( inR );
1158 } 1162 }
1159 } 1163 }
1160 } 1164 }
1161 } else { 1165 } else {
1162 ++filteredOUT; 1166 ++filteredOUT;
1163 } 1167 }
1164 } 1168 }
1165 } 1169 }
1166 inL = el.next(); 1170 inL = el.next();
1167 } 1171 }
1168 int delFut = 0; 1172 int delFut = 0;
1169 int remRem = 0; 1173 int remRem = 0;
1170 if ( mSyncManager->mWriteBackInFuture ) { 1174 if ( mSyncManager->mWriteBackInFuture ) {
1171 er = remote->rawIncidences(); 1175 er = remote->rawIncidences();
1172 remRem = er.count(); 1176 remRem = er.count();
1173 inR = er.first(); 1177 inR = er.first();
1174 QDateTime dt; 1178 QDateTime dt;
1175 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); 1179 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) );
1176 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); 1180 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 );
1177 while ( inR ) { 1181 while ( inR ) {
1178 if ( inR->type() == "Todo" ) { 1182 if ( inR->type() == "Todo" ) {
1179 Todo * t = (Todo*)inR; 1183 Todo * t = (Todo*)inR;
1180 if ( t->hasDueDate() ) 1184 if ( t->hasDueDate() )
1181 dt = t->dtDue(); 1185 dt = t->dtDue();
1182 else 1186 else
1183 dt = cur.addSecs( 62 ); 1187 dt = cur.addSecs( 62 );
1184 } 1188 }
1185 else if (inR->type() == "Event" ) { 1189 else if (inR->type() == "Event" ) {
1186 bool ok; 1190 bool ok;
1187 dt = inR->getNextOccurence( cur, &ok ); 1191 dt = inR->getNextOccurence( cur, &ok );
1188 if ( !ok ) 1192 if ( !ok )
1189 dt = cur.addSecs( -62 ); 1193 dt = cur.addSecs( -62 );
1190 } 1194 }
1191 else 1195 else
1192 dt = inR->dtStart(); 1196 dt = inR->dtStart();
1193 if ( dt < cur || dt > end ) { 1197 if ( dt < cur || dt > end ) {
1194 remote->deleteIncidence( inR ); 1198 remote->deleteIncidence( inR );
1195 ++delFut; 1199 ++delFut;
1196 } 1200 }
1197 inR = er.next(); 1201 inR = er.next();
1198 } 1202 }
1199 } 1203 }
1200 bar.hide(); 1204 bar.hide();
1201 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1205 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1202 eventLSync->setReadOnly( false ); 1206 eventLSync->setReadOnly( false );
1203 eventLSync->setDtStart( mLastCalendarSync ); 1207 eventLSync->setDtStart( mLastCalendarSync );
1204 eventRSync->setDtStart( mLastCalendarSync ); 1208 eventRSync->setDtStart( mLastCalendarSync );
1205 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1209 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1206 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1210 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1207 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1211 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1208 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1212 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1209 eventLSync->setReadOnly( true ); 1213 eventLSync->setReadOnly( true );
1210 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); 1214 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL );
1211 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... 1215 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal...
1212 remote->addEvent( eventRSync ); 1216 remote->addEvent( eventRSync );
1213 else 1217 else
1214 delete eventRSync; 1218 delete eventRSync;
1215 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); 1219 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() );
1216 QString mes; 1220 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 ); 1221 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; 1222 QString delmess;
1219 if ( delFut ) { 1223 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); 1224 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; 1225 mes += delmess;
1222 } 1226 }
1223 mes = i18n("Local calendar changed!\n") +mes; 1227 mes = i18n("Local calendar changed!\n") +mes;
1224 mCalendar->checkAlarmForIncidence( 0, true ); 1228 mCalendar->checkAlarmForIncidence( 0, true );
1225 qDebug( mes ); 1229 qDebug( mes );
1226 if ( mSyncManager->mShowSyncSummary ) { 1230 if ( mSyncManager->mShowSyncSummary ) {
1227 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 1231 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
1228 i18n("KO/Pi Synchronization"),i18n("Write back"))) { 1232 i18n("KO/Pi Synchronization"),i18n("Write back"))) {
1229 qDebug("KO: WB cancelled "); 1233 qDebug("KO: WB cancelled ");
1230 mSyncManager->mWriteBackFile = false; 1234 mSyncManager->mWriteBackFile = false;
1231 return syncOK; 1235 return syncOK;
1232 } 1236 }
1233 } 1237 }
1234 return syncOK; 1238 return syncOK;
1235} 1239}
1236 1240
1237void CalendarView::setSyncDevice( QString s ) 1241void CalendarView::setSyncDevice( QString s )
1238{ 1242{
1239 mCurrentSyncDevice= s; 1243 mCurrentSyncDevice= s;
1240} 1244}
1241void CalendarView::setSyncName( QString s ) 1245void CalendarView::setSyncName( QString s )
1242{ 1246{
1243 mCurrentSyncName= s; 1247 mCurrentSyncName= s;
1244} 1248}
1245bool CalendarView::syncCalendar(QString filename, int mode) 1249bool CalendarView::syncCalendar(QString filename, int mode)
1246{ 1250{
1247 //qDebug("syncCalendar %s ", filename.latin1()); 1251 //qDebug("syncCalendar %s ", filename.latin1());
1248 mGlobalSyncMode = SYNC_MODE_NORMAL; 1252 mGlobalSyncMode = SYNC_MODE_NORMAL;
1249 CalendarLocal* calendar = new CalendarLocal(); 1253 CalendarLocal* calendar = new CalendarLocal();
1250 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1254 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1251 FileStorage* storage = new FileStorage( calendar ); 1255 FileStorage* storage = new FileStorage( calendar );
1252 bool syncOK = false; 1256 bool syncOK = false;
1253 storage->setFileName( filename ); 1257 storage->setFileName( filename );
1254 // qDebug("loading ... "); 1258 // qDebug("loading ... ");
1255 if ( storage->load() ) { 1259 if ( storage->load() ) {
1256 getEventViewerDialog()->setSyncMode( true ); 1260 getEventViewerDialog()->setSyncMode( true );
1257 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1261 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1258 getEventViewerDialog()->setSyncMode( false ); 1262 getEventViewerDialog()->setSyncMode( false );
1259 if ( syncOK ) { 1263 if ( syncOK ) {
1260 if ( mSyncManager->mWriteBackFile ) 1264 if ( mSyncManager->mWriteBackFile )
1261 { 1265 {
1262 storage->setSaveFormat( new ICalFormat() ); 1266 storage->setSaveFormat( new ICalFormat() );
1263 storage->save(); 1267 storage->save();
1264 } 1268 }
1265 } 1269 }
1266 setModified( true ); 1270 setModified( true );
1267 } 1271 }
1268 delete storage; 1272 delete storage;
1269 delete calendar; 1273 delete calendar;
1270 if ( syncOK ) 1274 if ( syncOK )
1271 updateView(); 1275 updateView();
1272 return syncOK; 1276 return syncOK;
1273} 1277}
1274 1278
1275void CalendarView::syncExternal( int mode ) 1279void CalendarView::syncExternal( int mode )
1276{ 1280{
1277 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1281 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1278 1282
1279 qApp->processEvents(); 1283 qApp->processEvents();
1280 CalendarLocal* calendar = new CalendarLocal(); 1284 CalendarLocal* calendar = new CalendarLocal();
1281 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1285 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1282 bool syncOK = false; 1286 bool syncOK = false;
1283 bool loadSuccess = false; 1287 bool loadSuccess = false;
1284 PhoneFormat* phoneFormat = 0; 1288 PhoneFormat* phoneFormat = 0;
1285 emit tempDisableBR(true); 1289 emit tempDisableBR(true);
1286#ifndef DESKTOP_VERSION 1290#ifndef DESKTOP_VERSION
1287 SharpFormat* sharpFormat = 0; 1291 SharpFormat* sharpFormat = 0;
1288 if ( mode == 0 ) { // sharp 1292 if ( mode == 0 ) { // sharp
1289 sharpFormat = new SharpFormat () ; 1293 sharpFormat = new SharpFormat () ;
1290 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1294 loadSuccess = sharpFormat->load( calendar, mCalendar );
1291 1295
1292 } else 1296 } else
1293#endif 1297#endif
1294 if ( mode == 1 ) { // phone 1298 if ( mode == 1 ) { // phone
1295 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1299 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1296 mSyncManager->mPhoneDevice, 1300 mSyncManager->mPhoneDevice,
1297 mSyncManager->mPhoneConnection, 1301 mSyncManager->mPhoneConnection,
1298 mSyncManager->mPhoneModel); 1302 mSyncManager->mPhoneModel);
1299 loadSuccess = phoneFormat->load( calendar,mCalendar); 1303 loadSuccess = phoneFormat->load( calendar,mCalendar);
1300 1304
1301 } else { 1305 } else {
1302 emit tempDisableBR(false); 1306 emit tempDisableBR(false);
1303 return; 1307 return;
1304 } 1308 }
1305 if ( loadSuccess ) { 1309 if ( loadSuccess ) {
1306 getEventViewerDialog()->setSyncMode( true ); 1310 getEventViewerDialog()->setSyncMode( true );
1307 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1311 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1308 getEventViewerDialog()->setSyncMode( false ); 1312 getEventViewerDialog()->setSyncMode( false );
1309 qApp->processEvents(); 1313 qApp->processEvents();
1310 if ( syncOK ) { 1314 if ( syncOK ) {
1311 if ( mSyncManager->mWriteBackFile ) 1315 if ( mSyncManager->mWriteBackFile )
1312 { 1316 {
1313 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1317 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1314 Incidence* inc = iL.first(); 1318 Incidence* inc = iL.first();
1315 if ( phoneFormat ) { 1319 if ( phoneFormat ) {
1316 while ( inc ) { 1320 while ( inc ) {
1317 inc->removeID(mCurrentSyncDevice); 1321 inc->removeID(mCurrentSyncDevice);
1318 inc = iL.next(); 1322 inc = iL.next();
1319 } 1323 }
1320 } 1324 }
1321#ifndef DESKTOP_VERSION 1325#ifndef DESKTOP_VERSION
1322 if ( sharpFormat ) 1326 if ( sharpFormat )
1323 sharpFormat->save(calendar); 1327 sharpFormat->save(calendar);
1324#endif 1328#endif
1325 if ( phoneFormat ) 1329 if ( phoneFormat )
1326 phoneFormat->save(calendar); 1330 phoneFormat->save(calendar);
1327 iL = calendar->rawIncidences(); 1331 iL = calendar->rawIncidences();
1328 inc = iL.first(); 1332 inc = iL.first();
1329 Incidence* loc; 1333 Incidence* loc;
1330 while ( inc ) { 1334 while ( inc ) {
1331 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1335 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1332 loc = mCalendar->incidence(inc->uid() ); 1336 loc = mCalendar->incidence(inc->uid() );
1333 if ( loc ) { 1337 if ( loc ) {
1334 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1338 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1335 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1339 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1336 } 1340 }
1337 } 1341 }
1338 inc = iL.next(); 1342 inc = iL.next();
1339 } 1343 }
1340 Incidence* lse = getLastSyncEvent(); 1344 Incidence* lse = getLastSyncEvent();
1341 if ( lse ) { 1345 if ( lse ) {
1342 lse->setReadOnly( false ); 1346 lse->setReadOnly( false );
1343 lse->setDescription( "" ); 1347 lse->setDescription( "" );
1344 lse->setReadOnly( true ); 1348 lse->setReadOnly( true );
1345 } 1349 }
1346 } 1350 }
1347 } else { 1351 } else {
1348 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 1352 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
1349 } 1353 }
1350 setModified( true ); 1354 setModified( true );
1351 } else { 1355 } else {
1352 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1356 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1353 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1357 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1354 question, i18n("Ok")) ; 1358 question, i18n("Ok")) ;
1355 1359
1356 } 1360 }
1357 delete calendar; 1361 delete calendar;
1358 updateView(); 1362 updateView();
1359 emit tempDisableBR(false); 1363 emit tempDisableBR(false);
1360 return ;//syncOK; 1364 return ;//syncOK;
1361 1365
1362} 1366}
1363 1367
1364bool CalendarView::importBday() 1368bool CalendarView::importBday()
1365{ 1369{
1366#ifndef KORG_NOKABC 1370#ifndef KORG_NOKABC
1367 1371
1368#ifdef DESKTOP_VERSION 1372#ifdef DESKTOP_VERSION
1369 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1373 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1370 KABC::AddressBook::Iterator it; 1374 KABC::AddressBook::Iterator it;
1371 int count = 0; 1375 int count = 0;
1372 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1376 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1373 ++count; 1377 ++count;
1374 } 1378 }
1375 QProgressBar bar(count,0 ); 1379 QProgressBar bar(count,0 );
1376 int w = 300; 1380 int w = 300;
1377 if ( QApplication::desktop()->width() < 320 ) 1381 if ( QApplication::desktop()->width() < 320 )
1378 w = 220; 1382 w = 220;
1379 int h = bar.sizeHint().height() ; 1383 int h = bar.sizeHint().height() ;
1380 int dw = QApplication::desktop()->width(); 1384 int dw = QApplication::desktop()->width();
1381 int dh = QApplication::desktop()->height(); 1385 int dh = QApplication::desktop()->height();
1382 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1386 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1383 bar.show(); 1387 bar.show();
1384 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1388 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1385 qApp->processEvents(); 1389 qApp->processEvents();
1386 count = 0; 1390 count = 0;
1387 int addCount = 0; 1391 int addCount = 0;
1388 KCal::Attendee* a = 0; 1392 KCal::Attendee* a = 0;
1389 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1393 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1390 if ( ! bar.isVisible() ) 1394 if ( ! bar.isVisible() )
1391 return false; 1395 return false;
1392 bar.setProgress( count++ ); 1396 bar.setProgress( count++ );
1393 qApp->processEvents(); 1397 qApp->processEvents();
1394 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1398 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1395 if ( (*it).birthday().date().isValid() ){ 1399 if ( (*it).birthday().date().isValid() ){
1396 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1400 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1397 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1401 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1398 ++addCount; 1402 ++addCount;
1399 } 1403 }
1400 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1404 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1401 if ( anni.isValid() ){ 1405 if ( anni.isValid() ){
1402 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1406 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1403 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1407 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1404 ++addCount; 1408 ++addCount;
1405 } 1409 }
1406 } 1410 }
1407 updateView(); 1411 updateView();
1408 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1412 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1409#else //DESKTOP_VERSION 1413#else //DESKTOP_VERSION
1410 1414
1411 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 1415 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
1412 // the result should now arrive through method insertBirthdays 1416 // the result should now arrive through method insertBirthdays
1413 1417
1414#endif //DESKTOP_VERSION 1418#endif //DESKTOP_VERSION
1415 1419
1416#endif //KORG_NOKABC 1420#endif //KORG_NOKABC
1417 1421
1418 1422
1419 return true; 1423 return true;
1420} 1424}
1421 1425
1422// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI 1426// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
1423void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, 1427void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
1424 const QStringList& anniversaryList, const QStringList& realNameList, 1428 const QStringList& anniversaryList, const QStringList& realNameList,
1425 const QStringList& emailList, const QStringList& assembledNameList, 1429 const QStringList& emailList, const QStringList& assembledNameList,
1426 const QStringList& uidList) 1430 const QStringList& uidList)
1427{ 1431{
1428 //qDebug("KO::CalendarView::insertBirthdays"); 1432 //qDebug("KO::CalendarView::insertBirthdays");
1429 if (uid == this->name()) 1433 if (uid == this->name())
1430 { 1434 {
1431 int count = birthdayList.count(); 1435 int count = birthdayList.count();
1432 int addCount = 0; 1436 int addCount = 0;
1433 KCal::Attendee* a = 0; 1437 KCal::Attendee* a = 0;
1434 1438
1435 //qDebug("CalView 1 %i", count); 1439 //qDebug("CalView 1 %i", count);
1436 1440
1437 QProgressBar bar(count,0 ); 1441 QProgressBar bar(count,0 );
1438 int w = 300; 1442 int w = 300;
1439 if ( QApplication::desktop()->width() < 320 ) 1443 if ( QApplication::desktop()->width() < 320 )
1440 w = 220; 1444 w = 220;
1441 int h = bar.sizeHint().height() ; 1445 int h = bar.sizeHint().height() ;
1442 int dw = QApplication::desktop()->width(); 1446 int dw = QApplication::desktop()->width();
1443 int dh = QApplication::desktop()->height(); 1447 int dh = QApplication::desktop()->height();
1444 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1448 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1445 bar.show(); 1449 bar.show();
1446 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 1450 bar.setCaption (i18n("inserting birthdays - close to abort!") );
1447 qApp->processEvents(); 1451 qApp->processEvents();
1448 1452
1449 QDate birthday; 1453 QDate birthday;
1450 QDate anniversary; 1454 QDate anniversary;
1451 QString realName; 1455 QString realName;
1452 QString email; 1456 QString email;
1453 QString assembledName; 1457 QString assembledName;
1454 QString uid; 1458 QString uid;
1455 bool ok = true; 1459 bool ok = true;
1456 for ( int i = 0; i < count; i++) 1460 for ( int i = 0; i < count; i++)
1457 { 1461 {
1458 if ( ! bar.isVisible() ) 1462 if ( ! bar.isVisible() )
1459 return; 1463 return;
1460 bar.setProgress( i ); 1464 bar.setProgress( i );
1461 qApp->processEvents(); 1465 qApp->processEvents();
1462 1466
1463 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); 1467 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
1464 if (!ok) { 1468 if (!ok) {
1465 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); 1469 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
1466 } 1470 }
1467 1471
1468 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); 1472 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
1469 if (!ok) { 1473 if (!ok) {
1470 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); 1474 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
1471 } 1475 }
1472 realName = realNameList[i]; 1476 realName = realNameList[i];
1473 email = emailList[i]; 1477 email = emailList[i];
1474 assembledName = assembledNameList[i]; 1478 assembledName = assembledNameList[i];
1475 uid = uidList[i]; 1479 uid = uidList[i];
1476 //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() ); 1480 //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() );
1477 1481
1478 if ( birthday.isValid() ){ 1482 if ( birthday.isValid() ){
1479 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1483 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1480 KCal::Attendee::ReqParticipant,uid) ; 1484 KCal::Attendee::ReqParticipant,uid) ;
1481 if ( addAnniversary( birthday, assembledName, a, true ) ) 1485 if ( addAnniversary( birthday, assembledName, a, true ) )
1482 ++addCount; 1486 ++addCount;
1483 } 1487 }
1484 1488
1485 if ( anniversary.isValid() ){ 1489 if ( anniversary.isValid() ){
1486 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1490 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1487 KCal::Attendee::ReqParticipant,uid) ; 1491 KCal::Attendee::ReqParticipant,uid) ;
1488 if ( addAnniversary( anniversary, assembledName, a, false ) ) 1492 if ( addAnniversary( anniversary, assembledName, a, false ) )
1489 ++addCount; 1493 ++addCount;
1490 } 1494 }
1491 } 1495 }
1492 1496
1493 updateView(); 1497 updateView();
1494 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1498 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1495 1499
1496 } 1500 }
1497 1501
1498} 1502}
1499 1503
1500 1504
1501 1505
1502bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1506bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1503{ 1507{
1504 //qDebug("addAnni "); 1508 //qDebug("addAnni ");
1505 Event * ev = new Event(); 1509 Event * ev = new Event();
1506 ev->setOrganizer(KOPrefs::instance()->email()); 1510 ev->setOrganizer(KOPrefs::instance()->email());
1507 if ( a ) { 1511 if ( a ) {
1508 ev->addAttendee( a ); 1512 ev->addAttendee( a );
1509 } 1513 }
1510 QString kind; 1514 QString kind;
1511 if ( birthday ) { 1515 if ( birthday ) {
1512 kind = i18n( "Birthday" ); 1516 kind = i18n( "Birthday" );
1513 ev->setSummary( name + " (" + QString::number(date.year()) +")"); 1517 ev->setSummary( name + " (" + QString::number(date.year()) +")");
1514 } 1518 }
1515 else { 1519 else {
1516 kind = i18n( "Anniversary" ); 1520 kind = i18n( "Anniversary" );
1517 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); 1521 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind );
1518 } 1522 }
1519 ev->setCategories( kind ); 1523 ev->setCategories( kind );
1520 ev->setDtStart( QDateTime(date) ); 1524 ev->setDtStart( QDateTime(date) );
1521 ev->setDtEnd( QDateTime(date) ); 1525 ev->setDtEnd( QDateTime(date) );
1522 ev->setFloats( true ); 1526 ev->setFloats( true );
1523 Recurrence * rec = ev->recurrence(); 1527 Recurrence * rec = ev->recurrence();
1524 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1528 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1525 rec->addYearlyNum( date.month() ); 1529 rec->addYearlyNum( date.month() );
1526 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1530 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1527 delete ev; 1531 delete ev;
1528 return false; 1532 return false;
1529 } 1533 }
1530 return true; 1534 return true;
1531 1535
1532} 1536}
1533bool CalendarView::importQtopia( const QString &categories, 1537bool CalendarView::importQtopia( const QString &categories,
1534 const QString &datebook, 1538 const QString &datebook,
1535 const QString &todolist ) 1539 const QString &todolist )
1536{ 1540{
1537 1541
1538 QtopiaFormat qtopiaFormat; 1542 QtopiaFormat qtopiaFormat;
1539 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1543 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1540 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1544 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1541 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1545 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1542 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1546 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1543 1547
1544 updateView(); 1548 updateView();
1545 return true; 1549 return true;
1546 1550
1547#if 0 1551#if 0
1548 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1552 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1549 mCurrentSyncDevice = "qtopia-XML"; 1553 mCurrentSyncDevice = "qtopia-XML";
1550 if ( mSyncManager->mAskForPreferences ) 1554 if ( mSyncManager->mAskForPreferences )
1551 edit_sync_options(); 1555 edit_sync_options();
1552 qApp->processEvents(); 1556 qApp->processEvents();
1553 CalendarLocal* calendar = new CalendarLocal(); 1557 CalendarLocal* calendar = new CalendarLocal();
1554 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1558 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1555 bool syncOK = false; 1559 bool syncOK = false;
1556 QtopiaFormat qtopiaFormat; 1560 QtopiaFormat qtopiaFormat;
1557 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1561 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1558 bool loadOk = true; 1562 bool loadOk = true;
1559 if ( !categories.isEmpty() ) 1563 if ( !categories.isEmpty() )
1560 loadOk = qtopiaFormat.load( calendar, categories ); 1564 loadOk = qtopiaFormat.load( calendar, categories );
1561 if ( loadOk && !datebook.isEmpty() ) 1565 if ( loadOk && !datebook.isEmpty() )
1562 loadOk = qtopiaFormat.load( calendar, datebook ); 1566 loadOk = qtopiaFormat.load( calendar, datebook );
1563 if ( loadOk && !todolist.isEmpty() ) 1567 if ( loadOk && !todolist.isEmpty() )
1564 loadOk = qtopiaFormat.load( calendar, todolist ); 1568 loadOk = qtopiaFormat.load( calendar, todolist );
1565 1569
1566 if ( loadOk ) { 1570 if ( loadOk ) {
1567 getEventViewerDialog()->setSyncMode( true ); 1571 getEventViewerDialog()->setSyncMode( true );
1568 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1572 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1569 getEventViewerDialog()->setSyncMode( false ); 1573 getEventViewerDialog()->setSyncMode( false );
1570 qApp->processEvents(); 1574 qApp->processEvents();
1571 if ( syncOK ) { 1575 if ( syncOK ) {
1572 if ( mSyncManager->mWriteBackFile ) 1576 if ( mSyncManager->mWriteBackFile )
1573 { 1577 {
1574 // write back XML file 1578 // write back XML file
1575 1579
1576 } 1580 }
1577 setModified( true ); 1581 setModified( true );
1578 } 1582 }
1579 } else { 1583 } else {
1580 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1584 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1581 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1585 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1582 question, i18n("Ok")) ; 1586 question, i18n("Ok")) ;
1583 } 1587 }
1584 delete calendar; 1588 delete calendar;
1585 updateView(); 1589 updateView();
1586 return syncOK; 1590 return syncOK;
1587 1591
1588 1592
1589#endif 1593#endif
1590 1594
1591} 1595}
1592 1596
1593void CalendarView::setSyncEventsReadOnly() 1597void CalendarView::setSyncEventsReadOnly()
1594{ 1598{
1595 Event * ev; 1599 Event * ev;
1596 QPtrList<Event> eL = mCalendar->rawEvents(); 1600 QPtrList<Event> eL = mCalendar->rawEvents();
1597 ev = eL.first(); 1601 ev = eL.first();
1598 while ( ev ) { 1602 while ( ev ) {
1599 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1603 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1600 ev->setReadOnly( true ); 1604 ev->setReadOnly( true );
1601 ev = eL.next(); 1605 ev = eL.next();
1602 } 1606 }
1603} 1607}
1604bool CalendarView::openCalendar(QString filename, bool merge) 1608bool CalendarView::openCalendar(QString filename, bool merge)
1605{ 1609{
1606 1610
1607 if (filename.isEmpty()) { 1611 if (filename.isEmpty()) {
1608 return false; 1612 return false;
1609 } 1613 }
1610 1614
1611 if (!QFile::exists(filename)) { 1615 if (!QFile::exists(filename)) {
1612 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1616 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1613 return false; 1617 return false;
1614 } 1618 }
1615 1619
1616 globalFlagBlockAgenda = 1; 1620 globalFlagBlockAgenda = 1;
1617 if (!merge) mCalendar->close(); 1621 if (!merge) mCalendar->close();
1618 1622
1619 mStorage->setFileName( filename ); 1623 mStorage->setFileName( filename );
1620 1624
1621 if ( mStorage->load() ) { 1625 if ( mStorage->load() ) {
1622 if ( merge ) ;//setModified( true ); 1626 if ( merge ) ;//setModified( true );
1623 else { 1627 else {
1624 //setModified( true ); 1628 //setModified( true );
1625 mViewManager->setDocumentId( filename ); 1629 mViewManager->setDocumentId( filename );
1626 mDialogManager->setDocumentId( filename ); 1630 mDialogManager->setDocumentId( filename );
1627 mTodoList->setDocumentId( filename ); 1631 mTodoList->setDocumentId( filename );
1628 } 1632 }
1629 globalFlagBlockAgenda = 2; 1633 globalFlagBlockAgenda = 2;
1630 // if ( getLastSyncEvent() ) 1634 // if ( getLastSyncEvent() )
1631 // getLastSyncEvent()->setReadOnly( true ); 1635 // getLastSyncEvent()->setReadOnly( true );
1632 mCalendar->reInitAlarmSettings(); 1636 mCalendar->reInitAlarmSettings();
1633 setSyncEventsReadOnly(); 1637 setSyncEventsReadOnly();
1634 updateUnmanagedViews(); 1638 updateUnmanagedViews();
1635 updateView(); 1639 updateView();
1636 if ( filename != MainWindow::defaultFileName() ) { 1640 if ( filename != MainWindow::defaultFileName() ) {
1637 saveCalendar( MainWindow::defaultFileName() ); 1641 saveCalendar( MainWindow::defaultFileName() );
1638 } else { 1642 } else {
1639 QFileInfo finf ( MainWindow::defaultFileName()); 1643 QFileInfo finf ( MainWindow::defaultFileName());
1640 if ( finf.exists() ) { 1644 if ( finf.exists() ) {
1641 setLoadedFileVersion( finf.lastModified () ); 1645 setLoadedFileVersion( finf.lastModified () );
1642 } 1646 }
1643 } 1647 }
1644 return true; 1648 return true;
1645 } else { 1649 } else {
1646 // while failing to load, the calendar object could 1650 // while failing to load, the calendar object could
1647 // have become partially populated. Clear it out. 1651 // have become partially populated. Clear it out.
1648 if ( !merge ) { 1652 if ( !merge ) {
1649 mCalendar->close(); 1653 mCalendar->close();
1650 mViewManager->setDocumentId( filename ); 1654 mViewManager->setDocumentId( filename );
1651 mDialogManager->setDocumentId( filename ); 1655 mDialogManager->setDocumentId( filename );
1652 mTodoList->setDocumentId( filename ); 1656 mTodoList->setDocumentId( filename );
1653 } 1657 }
1654 1658
1655 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1659 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1656 1660
1657 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 1661 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
1658 globalFlagBlockAgenda = 2; 1662 globalFlagBlockAgenda = 2;
1659 mCalendar->reInitAlarmSettings(); 1663 mCalendar->reInitAlarmSettings();
1660 setSyncEventsReadOnly(); 1664 setSyncEventsReadOnly();
1661 updateUnmanagedViews(); 1665 updateUnmanagedViews();
1662 updateView(); 1666 updateView();
1663 } 1667 }
1664 return false; 1668 return false;
1665} 1669}
1666void CalendarView::showOpenError() 1670void CalendarView::showOpenError()
1667{ 1671{
1668 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 1672 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
1669} 1673}
1670void CalendarView::setLoadedFileVersion(QDateTime dt) 1674void CalendarView::setLoadedFileVersion(QDateTime dt)
1671{ 1675{
1672 loadedFileVersion = dt; 1676 loadedFileVersion = dt;
1673} 1677}
1674bool CalendarView::checkFileChanged(QString fn) 1678bool CalendarView::checkFileChanged(QString fn)
1675{ 1679{
1676 QFileInfo finf ( fn ); 1680 QFileInfo finf ( fn );
1677 if ( !finf.exists() ) 1681 if ( !finf.exists() )
1678 return true; 1682 return true;
1679 QDateTime dt = finf.lastModified (); 1683 QDateTime dt = finf.lastModified ();
1680 if ( dt <= loadedFileVersion ) 1684 if ( dt <= loadedFileVersion )
1681 return false; 1685 return false;
1682 return true; 1686 return true;
1683 1687
1684} 1688}
1685void CalendarView::watchSavedFile() 1689void CalendarView::watchSavedFile()
1686{ 1690{
1687 QFileInfo finf ( MainWindow::defaultFileName()); 1691 QFileInfo finf ( MainWindow::defaultFileName());
1688 if ( !finf.exists() ) 1692 if ( !finf.exists() )
1689 return; 1693 return;
1690 QDateTime dt = finf.lastModified (); 1694 QDateTime dt = finf.lastModified ();
1691 if ( dt < loadedFileVersion ) { 1695 if ( dt < loadedFileVersion ) {
1692 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 1696 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
1693 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 1697 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1694 return; 1698 return;
1695 } 1699 }
1696 loadedFileVersion = dt; 1700 loadedFileVersion = dt;
1697} 1701}
1698 1702
1699bool CalendarView::checkFileVersion(QString fn) 1703bool CalendarView::checkFileVersion(QString fn)
1700{ 1704{
1701 QFileInfo finf ( fn ); 1705 QFileInfo finf ( fn );
1702 if ( !finf.exists() ) 1706 if ( !finf.exists() )
1703 return true; 1707 return true;
1704 QDateTime dt = finf.lastModified (); 1708 QDateTime dt = finf.lastModified ();
1705 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1709 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1706 //qDebug("file on disk version %s",dt.toString().latin1()); 1710 //qDebug("file on disk version %s",dt.toString().latin1());
1707 if ( dt <= loadedFileVersion ) 1711 if ( dt <= loadedFileVersion )
1708 return true; 1712 return true;
1709 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)) , 1713 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)) ,
1710 i18n("KO/Pi Warning"),i18n("Overwrite"), 1714 i18n("KO/Pi Warning"),i18n("Overwrite"),
1711 i18n("Sync+save")); 1715 i18n("Sync+save"));
1712 1716
1713 if ( km == KMessageBox::Cancel ) 1717 if ( km == KMessageBox::Cancel )
1714 return false; 1718 return false;
1715 if ( km == KMessageBox::Yes ) 1719 if ( km == KMessageBox::Yes )
1716 return true; 1720 return true;
1717 1721
1718 setSyncDevice("deleteaftersync" ); 1722 setSyncDevice("deleteaftersync" );
1719 mSyncManager->mAskForPreferences = true; 1723 mSyncManager->mAskForPreferences = true;
1720 mSyncManager->mSyncAlgoPrefs = 3; 1724 mSyncManager->mSyncAlgoPrefs = 3;
1721 mSyncManager->mWriteBackFile = false; 1725 mSyncManager->mWriteBackFile = false;
1722 mSyncManager->mWriteBackExistingOnly = false; 1726 mSyncManager->mWriteBackExistingOnly = false;
1723 mSyncManager->mShowSyncSummary = false; 1727 mSyncManager->mShowSyncSummary = false;
1724 syncCalendar( fn, 3 ); 1728 syncCalendar( fn, 3 );
1725 Event * e = getLastSyncEvent(); 1729 Event * e = getLastSyncEvent();
1726 mCalendar->deleteEvent ( e ); 1730 mCalendar->deleteEvent ( e );
1727 updateView(); 1731 updateView();
1728 return true; 1732 return true;
1729} 1733}
1730 1734
1731bool CalendarView::saveCalendar( QString filename ) 1735bool CalendarView::saveCalendar( QString filename )
1732{ 1736{
1733 1737
1734 // Store back all unsaved data into calendar object 1738 // Store back all unsaved data into calendar object
1735 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1739 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1736 if ( mViewManager->currentView() ) 1740 if ( mViewManager->currentView() )
1737 mViewManager->currentView()->flushView(); 1741 mViewManager->currentView()->flushView();
1738 1742
1739 1743
1740 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 1744 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
1741 mStorage->setSaveFormat( new ICalFormat() ); 1745 mStorage->setSaveFormat( new ICalFormat() );
1742 mStorage->setFileName( filename ); 1746 mStorage->setFileName( filename );
1743 bool success; 1747 bool success;
1744 success = mStorage->save(); 1748 success = mStorage->save();
1745 if ( !success ) { 1749 if ( !success ) {
1746 return false; 1750 return false;
1747 } 1751 }
1748 if ( filename == MainWindow::defaultFileName() ) { 1752 if ( filename == MainWindow::defaultFileName() ) {
1749 setLoadedFileVersion( lfv ); 1753 setLoadedFileVersion( lfv );
1750 watchSavedFile(); 1754 watchSavedFile();
1751 } 1755 }
1752 return true; 1756 return true;
1753} 1757}
1754 1758
1755void CalendarView::closeCalendar() 1759void CalendarView::closeCalendar()
1756{ 1760{
1757 1761
1758 // child windows no longer valid 1762 // child windows no longer valid
1759 emit closingDown(); 1763 emit closingDown();
1760 1764
1761 mCalendar->close(); 1765 mCalendar->close();
1762 setModified(false); 1766 setModified(false);
1763 updateView(); 1767 updateView();
1764} 1768}
1765 1769
1766void CalendarView::archiveCalendar() 1770void CalendarView::archiveCalendar()
1767{ 1771{
1768 mDialogManager->showArchiveDialog(); 1772 mDialogManager->showArchiveDialog();
1769} 1773}
1770 1774
1771 1775
1772void CalendarView::readSettings() 1776void CalendarView::readSettings()
1773{ 1777{
1774 1778
1775 1779
1776 // mViewManager->showAgendaView(); 1780 // mViewManager->showAgendaView();
1777 QString str; 1781 QString str;
1778 //qDebug("CalendarView::readSettings() "); 1782 //qDebug("CalendarView::readSettings() ");
1779 // read settings from the KConfig, supplying reasonable 1783 // read settings from the KConfig, supplying reasonable
1780 // defaults where none are to be found 1784 // defaults where none are to be found
1781 KConfig *config = KOGlobals::config(); 1785 KConfig *config = KOGlobals::config();
1782#ifndef KORG_NOSPLITTER 1786#ifndef KORG_NOSPLITTER
1783 config->setGroup("KOrganizer Geometry"); 1787 config->setGroup("KOrganizer Geometry");
1784 1788
1785 QValueList<int> sizes = config->readIntListEntry("Separator1"); 1789 QValueList<int> sizes = config->readIntListEntry("Separator1");
1786 if (sizes.count() != 2) { 1790 if (sizes.count() != 2) {
1787 sizes << mDateNavigator->minimumSizeHint().width(); 1791 sizes << mDateNavigator->minimumSizeHint().width();
1788 sizes << 300; 1792 sizes << 300;
1789 } 1793 }
1790 mPanner->setSizes(sizes); 1794 mPanner->setSizes(sizes);
1791 1795
1792 sizes = config->readIntListEntry("Separator2"); 1796 sizes = config->readIntListEntry("Separator2");
1793 if ( ( mResourceView && sizes.count() == 4 ) || 1797 if ( ( mResourceView && sizes.count() == 4 ) ||
1794 ( !mResourceView && sizes.count() == 3 ) ) { 1798 ( !mResourceView && sizes.count() == 3 ) ) {
1795 mLeftSplitter->setSizes(sizes); 1799 mLeftSplitter->setSizes(sizes);
1796 } 1800 }
1797#endif 1801#endif
1798 globalFlagBlockAgenda = 1; 1802 globalFlagBlockAgenda = 1;
1799 mViewManager->showAgendaView(); 1803 mViewManager->showAgendaView();
1800 //mViewManager->readSettings( config ); 1804 //mViewManager->readSettings( config );
1801 mTodoList->restoreLayout(config,QString("Todo Layout")); 1805 mTodoList->restoreLayout(config,QString("Todo Layout"));
1802 readFilterSettings(config); 1806 readFilterSettings(config);
1803 config->setGroup( "Views" ); 1807 config->setGroup( "Views" );
1804 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 1808 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
1805 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 1809 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
1806 else if ( dateCount == 7 ) mNavigator->selectWeek(); 1810 else if ( dateCount == 7 ) mNavigator->selectWeek();
1807 else mNavigator->selectDates( dateCount ); 1811 else mNavigator->selectDates( dateCount );
1808 // mViewManager->readSettings( config ); 1812 // mViewManager->readSettings( config );
1809 updateConfig(); 1813 updateConfig();
1810 globalFlagBlockAgenda = 2; 1814 globalFlagBlockAgenda = 2;
1811 mViewManager->readSettings( config ); 1815 mViewManager->readSettings( config );
1812#ifdef DESKTOP_VERSION 1816#ifdef DESKTOP_VERSION
1813 config->setGroup("WidgetLayout"); 1817 config->setGroup("WidgetLayout");
1814 QStringList list; 1818 QStringList list;
1815 list = config->readListEntry("MainLayout"); 1819 list = config->readListEntry("MainLayout");
1816 int x,y,w,h; 1820 int x,y,w,h;
1817 if ( ! list.isEmpty() ) { 1821 if ( ! list.isEmpty() ) {
1818 x = list[0].toInt(); 1822 x = list[0].toInt();
1819 y = list[1].toInt(); 1823 y = list[1].toInt();
1820 w = list[2].toInt(); 1824 w = list[2].toInt();
1821 h = list[3].toInt(); 1825 h = list[3].toInt();
1822 topLevelWidget()->setGeometry(x,y,w,h); 1826 topLevelWidget()->setGeometry(x,y,w,h);
1823 1827
1824 } else { 1828 } else {
1825 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 1829 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
1826 } 1830 }
1827 list = config->readListEntry("EditEventLayout"); 1831 list = config->readListEntry("EditEventLayout");
1828 if ( ! list.isEmpty() ) { 1832 if ( ! list.isEmpty() ) {
1829 x = list[0].toInt(); 1833 x = list[0].toInt();
1830 y = list[1].toInt(); 1834 y = list[1].toInt();
1831 w = list[2].toInt(); 1835 w = list[2].toInt();
1832 h = list[3].toInt(); 1836 h = list[3].toInt();
1833 mEventEditor->setGeometry(x,y,w,h); 1837 mEventEditor->setGeometry(x,y,w,h);
1834 1838
1835 } 1839 }
1836 list = config->readListEntry("EditTodoLayout"); 1840 list = config->readListEntry("EditTodoLayout");
1837 if ( ! list.isEmpty() ) { 1841 if ( ! list.isEmpty() ) {
1838 x = list[0].toInt(); 1842 x = list[0].toInt();
1839 y = list[1].toInt(); 1843 y = list[1].toInt();
1840 w = list[2].toInt(); 1844 w = list[2].toInt();
1841 h = list[3].toInt(); 1845 h = list[3].toInt();
1842 mTodoEditor->setGeometry(x,y,w,h); 1846 mTodoEditor->setGeometry(x,y,w,h);
1843 1847
1844 } 1848 }
1845 list = config->readListEntry("ViewerLayout"); 1849 list = config->readListEntry("ViewerLayout");
1846 if ( ! list.isEmpty() ) { 1850 if ( ! list.isEmpty() ) {
1847 x = list[0].toInt(); 1851 x = list[0].toInt();
1848 y = list[1].toInt(); 1852 y = list[1].toInt();
1849 w = list[2].toInt(); 1853 w = list[2].toInt();
1850 h = list[3].toInt(); 1854 h = list[3].toInt();
1851 getEventViewerDialog()->setGeometry(x,y,w,h); 1855 getEventViewerDialog()->setGeometry(x,y,w,h);
1852 } 1856 }
1853#endif 1857#endif
1854 1858
1855} 1859}
1856 1860
1857 1861
1858void CalendarView::writeSettings() 1862void CalendarView::writeSettings()
1859{ 1863{
1860 // kdDebug() << "CalendarView::writeSettings" << endl; 1864 // kdDebug() << "CalendarView::writeSettings" << endl;
1861 1865
1862 KConfig *config = KOGlobals::config(); 1866 KConfig *config = KOGlobals::config();
1863 1867
1864#ifndef KORG_NOSPLITTER 1868#ifndef KORG_NOSPLITTER
1865 config->setGroup("KOrganizer Geometry"); 1869 config->setGroup("KOrganizer Geometry");
1866 1870
1867 QValueList<int> list = mPanner->sizes(); 1871 QValueList<int> list = mPanner->sizes();
1868 config->writeEntry("Separator1",list); 1872 config->writeEntry("Separator1",list);
1869 1873
1870 list = mLeftSplitter->sizes(); 1874 list = mLeftSplitter->sizes();
1871 config->writeEntry("Separator2",list); 1875 config->writeEntry("Separator2",list);
1872#endif 1876#endif
1873 1877
1874 mViewManager->writeSettings( config ); 1878 mViewManager->writeSettings( config );
1875 mTodoList->saveLayout(config,QString("Todo Layout")); 1879 mTodoList->saveLayout(config,QString("Todo Layout"));
1876 mDialogManager->writeSettings( config ); 1880 mDialogManager->writeSettings( config );
1877 //KOPrefs::instance()->usrWriteConfig(); 1881 //KOPrefs::instance()->usrWriteConfig();
1878 KOPrefs::instance()->writeConfig(); 1882 KOPrefs::instance()->writeConfig();
1879 1883
1880 writeFilterSettings(config); 1884 writeFilterSettings(config);
1881 1885
1882 config->setGroup( "Views" ); 1886 config->setGroup( "Views" );
1883 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 1887 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
1884 1888
1885#ifdef DESKTOP_VERSION 1889#ifdef DESKTOP_VERSION
1886 config->setGroup("WidgetLayout"); 1890 config->setGroup("WidgetLayout");
1887 QStringList list ;//= config->readListEntry("MainLayout"); 1891 QStringList list ;//= config->readListEntry("MainLayout");
1888 int x,y,w,h; 1892 int x,y,w,h;
1889 QWidget* wid; 1893 QWidget* wid;
1890 wid = topLevelWidget(); 1894 wid = topLevelWidget();
1891 x = wid->geometry().x(); 1895 x = wid->geometry().x();
1892 y = wid->geometry().y(); 1896 y = wid->geometry().y();
1893 w = wid->width(); 1897 w = wid->width();
1894 h = wid->height(); 1898 h = wid->height();
1895 list.clear(); 1899 list.clear();
1896 list << QString::number( x ); 1900 list << QString::number( x );
1897 list << QString::number( y ); 1901 list << QString::number( y );
1898 list << QString::number( w ); 1902 list << QString::number( w );
1899 list << QString::number( h ); 1903 list << QString::number( h );
1900 config->writeEntry("MainLayout",list ); 1904 config->writeEntry("MainLayout",list );
1901 1905
1902 wid = mEventEditor; 1906 wid = mEventEditor;
1903 x = wid->geometry().x(); 1907 x = wid->geometry().x();
1904 y = wid->geometry().y(); 1908 y = wid->geometry().y();
1905 w = wid->width(); 1909 w = wid->width();
1906 h = wid->height(); 1910 h = wid->height();
1907 list.clear(); 1911 list.clear();
1908 list << QString::number( x ); 1912 list << QString::number( x );
1909 list << QString::number( y ); 1913 list << QString::number( y );
1910 list << QString::number( w ); 1914 list << QString::number( w );
1911 list << QString::number( h ); 1915 list << QString::number( h );
1912 config->writeEntry("EditEventLayout",list ); 1916 config->writeEntry("EditEventLayout",list );
1913 1917
1914 wid = mTodoEditor; 1918 wid = mTodoEditor;
1915 x = wid->geometry().x(); 1919 x = wid->geometry().x();
1916 y = wid->geometry().y(); 1920 y = wid->geometry().y();
1917 w = wid->width(); 1921 w = wid->width();
1918 h = wid->height(); 1922 h = wid->height();
1919 list.clear(); 1923 list.clear();
1920 list << QString::number( x ); 1924 list << QString::number( x );
1921 list << QString::number( y ); 1925 list << QString::number( y );
1922 list << QString::number( w ); 1926 list << QString::number( w );
1923 list << QString::number( h ); 1927 list << QString::number( h );
1924 config->writeEntry("EditTodoLayout",list ); 1928 config->writeEntry("EditTodoLayout",list );
1925 wid = getEventViewerDialog(); 1929 wid = getEventViewerDialog();
1926 x = wid->geometry().x(); 1930 x = wid->geometry().x();
1927 y = wid->geometry().y(); 1931 y = wid->geometry().y();
1928 w = wid->width(); 1932 w = wid->width();
1929 h = wid->height(); 1933 h = wid->height();
1930 list.clear(); 1934 list.clear();
1931 list << QString::number( x ); 1935 list << QString::number( x );
1932 list << QString::number( y ); 1936 list << QString::number( y );
1933 list << QString::number( w ); 1937 list << QString::number( w );
1934 list << QString::number( h ); 1938 list << QString::number( h );
1935 config->writeEntry("ViewerLayout",list ); 1939 config->writeEntry("ViewerLayout",list );
1936 wid = mDialogManager->getSearchDialog(); 1940 wid = mDialogManager->getSearchDialog();
1937 if ( wid ) { 1941 if ( wid ) {
1938 x = wid->geometry().x(); 1942 x = wid->geometry().x();
1939 y = wid->geometry().y(); 1943 y = wid->geometry().y();
1940 w = wid->width(); 1944 w = wid->width();
1941 h = wid->height(); 1945 h = wid->height();
1942 list.clear(); 1946 list.clear();
1943 list << QString::number( x ); 1947 list << QString::number( x );
1944 list << QString::number( y ); 1948 list << QString::number( y );
1945 list << QString::number( w ); 1949 list << QString::number( w );
1946 list << QString::number( h ); 1950 list << QString::number( h );
1947 config->writeEntry("SearchLayout",list ); 1951 config->writeEntry("SearchLayout",list );
1948 } 1952 }
1949#endif 1953#endif
1950 1954
1951 1955
1952 config->sync(); 1956 config->sync();
1953} 1957}
1954 1958
1955void CalendarView::readFilterSettings(KConfig *config) 1959void CalendarView::readFilterSettings(KConfig *config)
1956{ 1960{
1957 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 1961 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
1958 1962
1959 mFilters.clear(); 1963 mFilters.clear();
1960 1964
1961 config->setGroup("General"); 1965 config->setGroup("General");
1962 QStringList filterList = config->readListEntry("CalendarFilters"); 1966 QStringList filterList = config->readListEntry("CalendarFilters");
1963 1967
1964 QStringList::ConstIterator it = filterList.begin(); 1968 QStringList::ConstIterator it = filterList.begin();
1965 QStringList::ConstIterator end = filterList.end(); 1969 QStringList::ConstIterator end = filterList.end();
1966 while(it != end) { 1970 while(it != end) {
1967 // kdDebug() << " filter: " << (*it) << endl; 1971 // kdDebug() << " filter: " << (*it) << endl;
1968 1972
1969 CalFilter *filter; 1973 CalFilter *filter;
1970 filter = new CalFilter(*it); 1974 filter = new CalFilter(*it);
1971 config->setGroup("Filter_" + (*it)); 1975 config->setGroup("Filter_" + (*it));
1972 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 1976 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
1973 filter->setCriteria(config->readNumEntry("Criteria",0)); 1977 filter->setCriteria(config->readNumEntry("Criteria",0));
1974 filter->setCategoryList(config->readListEntry("CategoryList")); 1978 filter->setCategoryList(config->readListEntry("CategoryList"));
1975 mFilters.append(filter); 1979 mFilters.append(filter);
1976 1980
1977 ++it; 1981 ++it;
1978 } 1982 }
1979 1983
1980 if (mFilters.count() == 0) { 1984 if (mFilters.count() == 0) {
1981 CalFilter *filter = new CalFilter(i18n("Default")); 1985 CalFilter *filter = new CalFilter(i18n("Default"));
1982 mFilters.append(filter); 1986 mFilters.append(filter);
1983 } 1987 }
1984 mFilterView->updateFilters(); 1988 mFilterView->updateFilters();
1985 config->setGroup("FilterView"); 1989 config->setGroup("FilterView");
1986 1990
1987 mFilterView->blockSignals(true); 1991 mFilterView->blockSignals(true);
1988 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 1992 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
1989 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 1993 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
1990 mFilterView->blockSignals(false); 1994 mFilterView->blockSignals(false);
1991 // We do it manually to avoid it being done twice by the above calls 1995 // We do it manually to avoid it being done twice by the above calls
1992 updateFilter(); 1996 updateFilter();
1993} 1997}
1994 1998
1995void CalendarView::writeFilterSettings(KConfig *config) 1999void CalendarView::writeFilterSettings(KConfig *config)
1996{ 2000{
1997 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 2001 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
1998 2002
1999 QStringList filterList; 2003 QStringList filterList;
2000 2004
2001 CalFilter *filter = mFilters.first(); 2005 CalFilter *filter = mFilters.first();
2002 while(filter) { 2006 while(filter) {
2003 // kdDebug() << " fn: " << filter->name() << endl; 2007 // kdDebug() << " fn: " << filter->name() << endl;
2004 filterList << filter->name(); 2008 filterList << filter->name();
2005 config->setGroup("Filter_" + filter->name()); 2009 config->setGroup("Filter_" + filter->name());
2006 config->writeEntry("Criteria",filter->criteria()); 2010 config->writeEntry("Criteria",filter->criteria());
2007 config->writeEntry("CategoryList",filter->categoryList()); 2011 config->writeEntry("CategoryList",filter->categoryList());
2008 filter = mFilters.next(); 2012 filter = mFilters.next();
2009 } 2013 }
2010 config->setGroup("General"); 2014 config->setGroup("General");
2011 config->writeEntry("CalendarFilters",filterList); 2015 config->writeEntry("CalendarFilters",filterList);
2012 2016
2013 config->setGroup("FilterView"); 2017 config->setGroup("FilterView");
2014 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 2018 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
2015 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 2019 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
2016} 2020}
2017 2021
2018 2022
2019void CalendarView::goToday() 2023void CalendarView::goToday()
2020{ 2024{
2021 if ( mViewManager->currentView()->isMonthView() ) 2025 if ( mViewManager->currentView()->isMonthView() )
2022 mNavigator->selectTodayMonth(); 2026 mNavigator->selectTodayMonth();
2023 else 2027 else
2024 mNavigator->selectToday(); 2028 mNavigator->selectToday();
2025} 2029}
2026 2030
2027void CalendarView::goNext() 2031void CalendarView::goNext()
2028{ 2032{
2029 mNavigator->selectNext(); 2033 mNavigator->selectNext();
2030} 2034}
2031 2035
2032void CalendarView::goPrevious() 2036void CalendarView::goPrevious()
2033{ 2037{
2034 mNavigator->selectPrevious(); 2038 mNavigator->selectPrevious();
2035} 2039}
2036void CalendarView::goNextMonth() 2040void CalendarView::goNextMonth()
2037{ 2041{
2038 mNavigator->selectNextMonth(); 2042 mNavigator->selectNextMonth();
2039} 2043}
2040 2044
2041void CalendarView::goPreviousMonth() 2045void CalendarView::goPreviousMonth()
2042{ 2046{
2043 mNavigator->selectPreviousMonth(); 2047 mNavigator->selectPreviousMonth();
2044} 2048}
2045void CalendarView::writeLocale() 2049void CalendarView::writeLocale()
2046{ 2050{
2047 //KPimGlobalPrefs::instance()->setGlobalConfig(); 2051 //KPimGlobalPrefs::instance()->setGlobalConfig();
2048#if 0 2052#if 0
2049 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); 2053 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime );
2050 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); 2054 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday );
2051 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); 2055 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate );
2052 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); 2056 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage );
2053 QString dummy = KOPrefs::instance()->mUserDateFormatLong; 2057 QString dummy = KOPrefs::instance()->mUserDateFormatLong;
2054 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 2058 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
2055 dummy = KOPrefs::instance()->mUserDateFormatShort; 2059 dummy = KOPrefs::instance()->mUserDateFormatShort;
2056 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 2060 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
2057 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, 2061 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving,
2058 KOPrefs::instance()->mDaylightsavingStart, 2062 KOPrefs::instance()->mDaylightsavingStart,
2059 KOPrefs::instance()->mDaylightsavingEnd ); 2063 KOPrefs::instance()->mDaylightsavingEnd );
2060 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); 2064 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId );
2061#endif 2065#endif
2062} 2066}
2063void CalendarView::updateConfig() 2067void CalendarView::updateConfig()
2064{ 2068{
2065 writeLocale(); 2069 writeLocale();
2066 if ( KOPrefs::instance()->mUseAppColors ) 2070 if ( KOPrefs::instance()->mUseAppColors )
2067 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 2071 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
2068 emit configChanged(); 2072 emit configChanged();
2069 mTodoList->updateConfig(); 2073 mTodoList->updateConfig();
2070 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 2074 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
2071 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2075 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2072 // To make the "fill window" configurations work 2076 // To make the "fill window" configurations work
2073 //mViewManager->raiseCurrentView(); 2077 //mViewManager->raiseCurrentView();
2074} 2078}
2075 2079
2076 2080
2077void CalendarView::eventChanged(Event *event) 2081void CalendarView::eventChanged(Event *event)
2078{ 2082{
2079 changeEventDisplay(event,KOGlobals::EVENTEDITED); 2083 changeEventDisplay(event,KOGlobals::EVENTEDITED);
2080 //updateUnmanagedViews(); 2084 //updateUnmanagedViews();
2081} 2085}
2082 2086
2083void CalendarView::eventAdded(Event *event) 2087void CalendarView::eventAdded(Event *event)
2084{ 2088{
2085 changeEventDisplay(event,KOGlobals::EVENTADDED); 2089 changeEventDisplay(event,KOGlobals::EVENTADDED);
2086} 2090}
2087 2091
2088void CalendarView::eventToBeDeleted(Event *) 2092void CalendarView::eventToBeDeleted(Event *)
2089{ 2093{
2090 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 2094 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
2091} 2095}
2092 2096
2093void CalendarView::eventDeleted() 2097void CalendarView::eventDeleted()
2094{ 2098{
2095 changeEventDisplay(0,KOGlobals::EVENTDELETED); 2099 changeEventDisplay(0,KOGlobals::EVENTDELETED);
2096} 2100}
2097void CalendarView::changeTodoDisplay(Todo *which, int action) 2101void CalendarView::changeTodoDisplay(Todo *which, int action)
2098{ 2102{
2099 changeIncidenceDisplay((Incidence *)which, action); 2103 changeIncidenceDisplay((Incidence *)which, action);
2100 mDateNavigator->updateView(); //LR 2104 mDateNavigator->updateView(); //LR
2101 //mDialogManager->updateSearchDialog(); 2105 //mDialogManager->updateSearchDialog();
2102 2106
2103 if (which) { 2107 if (which) {
2104 mViewManager->updateWNview(); 2108 mViewManager->updateWNview();
2105 //mTodoList->updateView(); 2109 //mTodoList->updateView();
2106 } 2110 }
2107 2111
2108} 2112}
2109 2113
2110void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 2114void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
2111{ 2115{
2112 updateUnmanagedViews(); 2116 updateUnmanagedViews();
2113 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 2117 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
2114 if ( action == KOGlobals::EVENTDELETED ) { //delete 2118 if ( action == KOGlobals::EVENTDELETED ) { //delete
2115 mCalendar->checkAlarmForIncidence( 0, true ); 2119 mCalendar->checkAlarmForIncidence( 0, true );
2116 if ( mEventViewerDialog ) 2120 if ( mEventViewerDialog )
2117 mEventViewerDialog->hide(); 2121 mEventViewerDialog->hide();
2118 } 2122 }
2119 else 2123 else
2120 mCalendar->checkAlarmForIncidence( which , false ); 2124 mCalendar->checkAlarmForIncidence( which , false );
2121} 2125}
2122 2126
2123// most of the changeEventDisplays() right now just call the view's 2127// most of the changeEventDisplays() right now just call the view's
2124// total update mode, but they SHOULD be recoded to be more refresh-efficient. 2128// total update mode, but they SHOULD be recoded to be more refresh-efficient.
2125void CalendarView::changeEventDisplay(Event *which, int action) 2129void CalendarView::changeEventDisplay(Event *which, int action)
2126{ 2130{
2127 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 2131 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
2128 changeIncidenceDisplay((Incidence *)which, action); 2132 changeIncidenceDisplay((Incidence *)which, action);
2129 mDateNavigator->updateView(); 2133 mDateNavigator->updateView();
2130 //mDialogManager->updateSearchDialog(); 2134 //mDialogManager->updateSearchDialog();
2131 2135
2132 if (which) { 2136 if (which) {
2133 // If there is an event view visible update the display 2137 // If there is an event view visible update the display
2134 mViewManager->currentView()->changeEventDisplay(which,action); 2138 mViewManager->currentView()->changeEventDisplay(which,action);
2135 // TODO: check, if update needed 2139 // TODO: check, if update needed
2136 // if (which->getTodoStatus()) { 2140 // if (which->getTodoStatus()) {
2137 mTodoList->updateView(); 2141 mTodoList->updateView();
2138 // } 2142 // }
2139 } else { 2143 } else {
2140 mViewManager->currentView()->updateView(); 2144 mViewManager->currentView()->updateView();
2141 } 2145 }
2142} 2146}
2143 2147
2144 2148
2145void CalendarView::updateTodoViews() 2149void CalendarView::updateTodoViews()
2146{ 2150{
2147 mTodoList->updateView(); 2151 mTodoList->updateView();
2148 mViewManager->currentView()->updateView(); 2152 mViewManager->currentView()->updateView();
2149 2153
2150} 2154}
2151 2155
2152 2156
2153void CalendarView::updateView(const QDate &start, const QDate &end) 2157void CalendarView::updateView(const QDate &start, const QDate &end)
2154{ 2158{
2155 mTodoList->updateView(); 2159 mTodoList->updateView();
2156 mViewManager->updateView(start, end); 2160 mViewManager->updateView(start, end);
2157 //mDateNavigator->updateView(); 2161 //mDateNavigator->updateView();
2158} 2162}
2159 2163
2160void CalendarView::updateView() 2164void CalendarView::updateView()
2161{ 2165{
2162 DateList tmpList = mNavigator->selectedDates(); 2166 DateList tmpList = mNavigator->selectedDates();
2163 2167
2164 if ( KOPrefs::instance()->mHideNonStartedTodos ) 2168 if ( KOPrefs::instance()->mHideNonStartedTodos )
2165 mTodoList->updateView(); 2169 mTodoList->updateView();
2166 // We assume that the navigator only selects consecutive days. 2170 // We assume that the navigator only selects consecutive days.
2167 updateView( tmpList.first(), tmpList.last() ); 2171 updateView( tmpList.first(), tmpList.last() );
2168} 2172}
2169 2173
2170void CalendarView::updateUnmanagedViews() 2174void CalendarView::updateUnmanagedViews()
2171{ 2175{
2172 mDateNavigator->updateDayMatrix(); 2176 mDateNavigator->updateDayMatrix();
2173} 2177}
2174 2178
2175int CalendarView::msgItemDelete(const QString name) 2179int CalendarView::msgItemDelete(const QString name)
2176{ 2180{
2177 return KMessageBox::warningContinueCancel(this,name +"\n\n"+ 2181 return KMessageBox::warningContinueCancel(this,name +"\n\n"+
2178 i18n("This item will be\npermanently deleted."), 2182 i18n("This item will be\npermanently deleted."),
2179 i18n("KO/Pi Confirmation"),i18n("Delete")); 2183 i18n("KO/Pi Confirmation"),i18n("Delete"));
2180} 2184}
2181 2185
2182 2186
2183void CalendarView::edit_cut() 2187void CalendarView::edit_cut()
2184{ 2188{
2185 Event *anEvent=0; 2189 Event *anEvent=0;
2186 2190
2187 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2191 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2188 2192
2189 if (mViewManager->currentView()->isEventView()) { 2193 if (mViewManager->currentView()->isEventView()) {
2190 if ( incidence && incidence->type() == "Event" ) { 2194 if ( incidence && incidence->type() == "Event" ) {
2191 anEvent = static_cast<Event *>(incidence); 2195 anEvent = static_cast<Event *>(incidence);
2192 } 2196 }
2193 } 2197 }
2194 2198
2195 if (!anEvent) { 2199 if (!anEvent) {
2196 KNotifyClient::beep(); 2200 KNotifyClient::beep();
2197 return; 2201 return;
2198 } 2202 }
2199 DndFactory factory( mCalendar ); 2203 DndFactory factory( mCalendar );
2200 factory.cutIncidence(anEvent); 2204 factory.cutIncidence(anEvent);
2201 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2205 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2202} 2206}
2203 2207
2204void CalendarView::edit_copy() 2208void CalendarView::edit_copy()
2205{ 2209{
2206 Event *anEvent=0; 2210 Event *anEvent=0;
2207 2211
2208 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2212 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2209 2213
2210 if (mViewManager->currentView()->isEventView()) { 2214 if (mViewManager->currentView()->isEventView()) {
2211 if ( incidence && incidence->type() == "Event" ) { 2215 if ( incidence && incidence->type() == "Event" ) {
2212 anEvent = static_cast<Event *>(incidence); 2216 anEvent = static_cast<Event *>(incidence);
2213 } 2217 }
2214 } 2218 }
2215 2219
2216 if (!anEvent) { 2220 if (!anEvent) {
2217 KNotifyClient::beep(); 2221 KNotifyClient::beep();
2218 return; 2222 return;
2219 } 2223 }
2220 DndFactory factory( mCalendar ); 2224 DndFactory factory( mCalendar );
2221 factory.copyIncidence(anEvent); 2225 factory.copyIncidence(anEvent);
2222} 2226}
2223 2227
2224void CalendarView::edit_paste() 2228void CalendarView::edit_paste()
2225{ 2229{
2226 QDate date = mNavigator->selectedDates().first(); 2230 QDate date = mNavigator->selectedDates().first();
2227 2231
2228 DndFactory factory( mCalendar ); 2232 DndFactory factory( mCalendar );
2229 Event *pastedEvent = (Event *)factory.pasteIncidence( date ); 2233 Event *pastedEvent = (Event *)factory.pasteIncidence( date );
2230 2234
2231 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 2235 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
2232} 2236}
2233 2237
2234void CalendarView::edit_options() 2238void CalendarView::edit_options()
2235{ 2239{
2236 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; 2240 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId;
2237 emit save(); 2241 emit save();
2238 emit saveStopTimer(); 2242 emit saveStopTimer();
2239 mDialogManager->showOptionsDialog(); 2243 mDialogManager->showOptionsDialog();
2240 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { 2244 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) {
2241 emit saveStopTimer(); 2245 emit saveStopTimer();
2242 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!"), 2246 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!"),
2243 i18n("Timezone settings"),i18n("Reload"))) { 2247 i18n("Timezone settings"),i18n("Reload"))) {
2244 qDebug("KO: TZ reload cancelled "); 2248 qDebug("KO: TZ reload cancelled ");
2245 return; 2249 return;
2246 } 2250 }
2247 qDebug("KO: Timezone change "); 2251 qDebug("KO: Timezone change ");
2248 openCalendar( MainWindow::defaultFileName() ); 2252 openCalendar( MainWindow::defaultFileName() );
2249 setModified(true); 2253 setModified(true);
2250 } 2254 }
2251 else 2255 else
2252 qDebug("KO: No tz change "); 2256 qDebug("KO: No tz change ");
2253 2257
2254} 2258}
2255 2259
2256 2260
2257void CalendarView::slotSelectPickerDate( QDate d) 2261void CalendarView::slotSelectPickerDate( QDate d)
2258{ 2262{
2259 mDateFrame->hide(); 2263 mDateFrame->hide();
2260 if ( mDatePickerMode == 1 ) { 2264 if ( mDatePickerMode == 1 ) {
2261 mNavigator->slotDaySelect( d ); 2265 mNavigator->slotDaySelect( d );
2262 } else if ( mDatePickerMode == 2 ) { 2266 } else if ( mDatePickerMode == 2 ) {
2263 if ( mMoveIncidence->type() == "Todo" ) { 2267 if ( mMoveIncidence->type() == "Todo" ) {
2264 Todo * to = (Todo *) mMoveIncidence; 2268 Todo * to = (Todo *) mMoveIncidence;
2265 QTime tim; 2269 QTime tim;
2266 int len = 0; 2270 int len = 0;
2267 if ( to->hasStartDate() && to->hasDueDate() ) 2271 if ( to->hasStartDate() && to->hasDueDate() )
2268 len = to->dtStart().secsTo( to->dtDue()); 2272 len = to->dtStart().secsTo( to->dtDue());
2269 if ( to->hasDueDate() ) 2273 if ( to->hasDueDate() )
2270 tim = to->dtDue().time(); 2274 tim = to->dtDue().time();
2271 else { 2275 else {
2272 tim = QTime ( 0,0,0 ); 2276 tim = QTime ( 0,0,0 );
2273 to->setFloats( true ); 2277 to->setFloats( true );
2274 to->setHasDueDate( true ); 2278 to->setHasDueDate( true );
2275 } 2279 }
2276 QDateTime dt ( d,tim ); 2280 QDateTime dt ( d,tim );
2277 to->setDtDue( dt ); 2281 to->setDtDue( dt );
2278 2282
2279 if ( to->hasStartDate() ) { 2283 if ( to->hasStartDate() ) {
2280 if ( len>0 ) 2284 if ( len>0 )
2281 to->setDtStart(to->dtDue().addSecs( -len )); 2285 to->setDtStart(to->dtDue().addSecs( -len ));
2282 else 2286 else
2283 if (to->dtStart() > to->dtDue() ) 2287 if (to->dtStart() > to->dtDue() )
2284 to->setDtStart(to->dtDue().addDays( -3 )); 2288 to->setDtStart(to->dtDue().addDays( -3 ));
2285 } 2289 }
2286 2290
2287 todoChanged( to ); 2291 todoChanged( to );
2288 } else { 2292 } else {
2289 if ( mMoveIncidence->doesRecur() ) { 2293 if ( mMoveIncidence->doesRecur() ) {
2290#if 0 2294#if 0
2291 // PENDING implement this 2295 // PENDING implement this
2292 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); 2296 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate );
2293 mCalendar()->addIncidence( newInc ); 2297 mCalendar()->addIncidence( newInc );
2294 if ( mMoveIncidence->type() == "Todo" ) 2298 if ( mMoveIncidence->type() == "Todo" )
2295 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); 2299 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED );
2296 else 2300 else
2297 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); 2301 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED);
2298 mMoveIncidence = newInc; 2302 mMoveIncidence = newInc;
2299 2303
2300#endif 2304#endif
2301 } 2305 }
2302 QTime tim = mMoveIncidence->dtStart().time(); 2306 QTime tim = mMoveIncidence->dtStart().time();
2303 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2307 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2304 QDateTime dt ( d,tim ); 2308 QDateTime dt ( d,tim );
2305 mMoveIncidence->setDtStart( dt ); 2309 mMoveIncidence->setDtStart( dt );
2306 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2310 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2307 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2311 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2308 } 2312 }
2309 2313
2310 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2314 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2311 } 2315 }
2312} 2316}
2313 2317
2314void CalendarView::removeCategories() 2318void CalendarView::removeCategories()
2315{ 2319{
2316 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2320 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2317 QStringList catList = KOPrefs::instance()->mCustomCategories; 2321 QStringList catList = KOPrefs::instance()->mCustomCategories;
2318 QStringList catIncList; 2322 QStringList catIncList;
2319 QStringList newCatList; 2323 QStringList newCatList;
2320 Incidence* inc = incList.first(); 2324 Incidence* inc = incList.first();
2321 int i; 2325 int i;
2322 int count = 0; 2326 int count = 0;
2323 while ( inc ) { 2327 while ( inc ) {
2324 newCatList.clear(); 2328 newCatList.clear();
2325 catIncList = inc->categories() ; 2329 catIncList = inc->categories() ;
2326 for( i = 0; i< catIncList.count(); ++i ) { 2330 for( i = 0; i< catIncList.count(); ++i ) {
2327 if ( catList.contains (catIncList[i])) 2331 if ( catList.contains (catIncList[i]))
2328 newCatList.append( catIncList[i] ); 2332 newCatList.append( catIncList[i] );
2329 } 2333 }
2330 newCatList.sort(); 2334 newCatList.sort();
2331 inc->setCategories( newCatList.join(",") ); 2335 inc->setCategories( newCatList.join(",") );
2332 inc = incList.next(); 2336 inc = incList.next();
2333 } 2337 }
2334} 2338}
2335 2339
2336int CalendarView::addCategories() 2340int CalendarView::addCategories()
2337{ 2341{
2338 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2342 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2339 QStringList catList = KOPrefs::instance()->mCustomCategories; 2343 QStringList catList = KOPrefs::instance()->mCustomCategories;
2340 QStringList catIncList; 2344 QStringList catIncList;
2341 Incidence* inc = incList.first(); 2345 Incidence* inc = incList.first();
2342 int i; 2346 int i;
2343 int count = 0; 2347 int count = 0;
2344 while ( inc ) { 2348 while ( inc ) {
2345 catIncList = inc->categories() ; 2349 catIncList = inc->categories() ;
2346 for( i = 0; i< catIncList.count(); ++i ) { 2350 for( i = 0; i< catIncList.count(); ++i ) {
2347 if ( !catList.contains (catIncList[i])) { 2351 if ( !catList.contains (catIncList[i])) {
2348 catList.append( catIncList[i] ); 2352 catList.append( catIncList[i] );
2349 //qDebug("add cat %s ", catIncList[i].latin1()); 2353 //qDebug("add cat %s ", catIncList[i].latin1());
2350 ++count; 2354 ++count;
2351 } 2355 }
2352 } 2356 }
2353 inc = incList.next(); 2357 inc = incList.next();
2354 } 2358 }
2355 catList.sort(); 2359 catList.sort();
2356 KOPrefs::instance()->mCustomCategories = catList; 2360 KOPrefs::instance()->mCustomCategories = catList;
2357 return count; 2361 return count;
2358} 2362}
2359 2363
2360void CalendarView::manageCategories() 2364void CalendarView::manageCategories()
2361{ 2365{
2362 KOCatPrefs* cp = new KOCatPrefs(); 2366 KOCatPrefs* cp = new KOCatPrefs();
2363 cp->show(); 2367 cp->show();
2364 int w =cp->sizeHint().width() ; 2368 int w =cp->sizeHint().width() ;
2365 int h = cp->sizeHint().height() ; 2369 int h = cp->sizeHint().height() ;
2366 int dw = QApplication::desktop()->width(); 2370 int dw = QApplication::desktop()->width();
2367 int dh = QApplication::desktop()->height(); 2371 int dh = QApplication::desktop()->height();
2368 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2372 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2369 if ( !cp->exec() ) { 2373 if ( !cp->exec() ) {
2370 delete cp; 2374 delete cp;
2371 return; 2375 return;
2372 } 2376 }
2373 int count = 0; 2377 int count = 0;
2374 if ( cp->addCat() ) { 2378 if ( cp->addCat() ) {
2375 count = addCategories(); 2379 count = addCategories();
2376 if ( count ) { 2380 if ( count ) {
2377 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2381 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2378 writeSettings(); 2382 writeSettings();
2379 } else 2383 } else
2380 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); 2384 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! "));
2381 } else { 2385 } else {
2382 removeCategories(); 2386 removeCategories();
2383 updateView(); 2387 updateView();
2384 } 2388 }
2385 delete cp; 2389 delete cp;
2386} 2390}
2387 2391
2388void CalendarView::beamIncidence(Incidence * Inc) 2392void CalendarView::beamIncidence(Incidence * Inc)
2389{ 2393{
2390 QPtrList<Incidence> delSel ; 2394 QPtrList<Incidence> delSel ;
2391 delSel.append(Inc); 2395 delSel.append(Inc);
2392 beamIncidenceList( delSel ); 2396 beamIncidenceList( delSel );
2393} 2397}
2394void CalendarView::beamCalendar() 2398void CalendarView::beamCalendar()
2395{ 2399{
2396 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2400 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2397 //qDebug("beamCalendar() "); 2401 //qDebug("beamCalendar() ");
2398 beamIncidenceList( delSel ); 2402 beamIncidenceList( delSel );
2399} 2403}
2400void CalendarView::beamFilteredCalendar() 2404void CalendarView::beamFilteredCalendar()
2401{ 2405{
2402 QPtrList<Incidence> delSel = mCalendar->incidences(); 2406 QPtrList<Incidence> delSel = mCalendar->incidences();
2403 //qDebug("beamFilteredCalendar() "); 2407 //qDebug("beamFilteredCalendar() ");
2404 beamIncidenceList( delSel ); 2408 beamIncidenceList( delSel );
2405} 2409}
2406void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2410void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2407{ 2411{
2408 if ( beamDialog->exec () == QDialog::Rejected ) 2412 if ( beamDialog->exec () == QDialog::Rejected )
2409 return; 2413 return;
2410#ifdef DESKTOP_VERSION 2414#ifdef DESKTOP_VERSION
2411 QString fn = locateLocal( "tmp", "kopibeamfile" ); 2415 QString fn = locateLocal( "tmp", "kopibeamfile" );
2412#else 2416#else
2413 QString fn = "/tmp/kopibeamfile"; 2417 QString fn = "/tmp/kopibeamfile";
2414#endif 2418#endif
2415 QString mes; 2419 QString mes;
2416 bool createbup = true; 2420 bool createbup = true;
2417 if ( createbup ) { 2421 if ( createbup ) {
2418 QString description = "\n"; 2422 QString description = "\n";
2419 CalendarLocal* cal = new CalendarLocal(); 2423 CalendarLocal* cal = new CalendarLocal();
2420 if ( beamDialog->beamLocal() ) 2424 if ( beamDialog->beamLocal() )
2421 cal->setLocalTime(); 2425 cal->setLocalTime();
2422 else 2426 else
2423 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2427 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2424 Incidence *incidence = delSel.first(); 2428 Incidence *incidence = delSel.first();
2425 bool addText = false; 2429 bool addText = false;
2426 if ( delSel.count() < 10 ) 2430 if ( delSel.count() < 10 )
2427 addText = true; 2431 addText = true;
2428 else { 2432 else {
2429 description.sprintf(i18n(" %d items?"),delSel.count() ); 2433 description.sprintf(i18n(" %d items?"),delSel.count() );
2430 } 2434 }
2431 while ( incidence ) { 2435 while ( incidence ) {
2432 Incidence *in = incidence->clone(); 2436 Incidence *in = incidence->clone();
2433 if ( ! in->summary().isEmpty() ) { 2437 if ( ! in->summary().isEmpty() ) {
2434 in->setDescription(""); 2438 in->setDescription("");
2435 } else { 2439 } else {
2436 in->setSummary( in->description().left(20)); 2440 in->setSummary( in->description().left(20));
2437 in->setDescription(""); 2441 in->setDescription("");
2438 } 2442 }
2439 if ( addText ) 2443 if ( addText )
2440 description += in->summary() + "\n"; 2444 description += in->summary() + "\n";
2441 cal->addIncidence( in ); 2445 cal->addIncidence( in );
2442 incidence = delSel.next(); 2446 incidence = delSel.next();
2443 } 2447 }
2444 if ( beamDialog->beamVcal() ) { 2448 if ( beamDialog->beamVcal() ) {
2445 fn += ".vcs"; 2449 fn += ".vcs";
2446 FileStorage storage( cal, fn, new VCalFormat ); 2450 FileStorage storage( cal, fn, new VCalFormat );
2447 storage.save(); 2451 storage.save();
2448 } else { 2452 } else {
2449 fn += ".ics"; 2453 fn += ".ics";
2450 FileStorage storage( cal, fn, new ICalFormat( ) ); 2454 FileStorage storage( cal, fn, new ICalFormat( ) );
2451 storage.save(); 2455 storage.save();
2452 } 2456 }
2453 delete cal; 2457 delete cal;
2454 mes = i18n("KO/Pi: Ready for beaming"); 2458 mes = i18n("KO/Pi: Ready for beaming");
2455 topLevelWidget()->setCaption(mes); 2459 topLevelWidget()->setCaption(mes);
2456 KApplication::convert2latin1( fn ); 2460 KApplication::convert2latin1( fn );
2457#ifndef DESKTOP_VERSION 2461#ifndef DESKTOP_VERSION
2458 Ir *ir = new Ir( this ); 2462 Ir *ir = new Ir( this );
2459 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 2463 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2460 ir->send( fn, description, "text/x-vCalendar" ); 2464 ir->send( fn, description, "text/x-vCalendar" );
2461#endif 2465#endif
2462 } 2466 }
2463} 2467}
2464void CalendarView::beamDone( Ir *ir ) 2468void CalendarView::beamDone( Ir *ir )
2465{ 2469{
2466#ifndef DESKTOP_VERSION 2470#ifndef DESKTOP_VERSION
2467 delete ir; 2471 delete ir;
2468#endif 2472#endif
2469 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); 2473 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") );
2470 topLevelWidget()->raise(); 2474 topLevelWidget()->raise();
2471} 2475}
2472 2476
2473void CalendarView::moveIncidence(Incidence * inc ) 2477void CalendarView::moveIncidence(Incidence * inc )
2474{ 2478{
2475 if ( !inc ) return; 2479 if ( !inc ) return;
2476 showDatePickerPopup(); 2480 showDatePickerPopup();
2477 mDatePickerMode = 2; 2481 mDatePickerMode = 2;
2478 mMoveIncidence = inc ; 2482 mMoveIncidence = inc ;
2479 QDate da; 2483 QDate da;
2480 if ( mMoveIncidence->type() == "Todo" ) { 2484 if ( mMoveIncidence->type() == "Todo" ) {
2481 Todo * to = (Todo *) mMoveIncidence; 2485 Todo * to = (Todo *) mMoveIncidence;
2482 if ( to->hasDueDate() ) 2486 if ( to->hasDueDate() )
2483 da = to->dtDue().date(); 2487 da = to->dtDue().date();
2484 else 2488 else
2485 da = QDate::currentDate(); 2489 da = QDate::currentDate();
2486 } else { 2490 } else {
2487 da = mMoveIncidence->dtStart().date(); 2491 da = mMoveIncidence->dtStart().date();
2488 } 2492 }
2489 //PENDING set date for recurring incidence to date of recurrence 2493 //PENDING set date for recurring incidence to date of recurrence
2490 //mMoveIncidenceOldDate; 2494 //mMoveIncidenceOldDate;
2491 mDatePicker->setDate( da ); 2495 mDatePicker->setDate( da );
2492} 2496}
2493void CalendarView::showDatePickerPopup() 2497void CalendarView::showDatePickerPopup()
2494{ 2498{
2495 if ( mDateFrame->isVisible() ) 2499 if ( mDateFrame->isVisible() )
2496 mDateFrame->hide(); 2500 mDateFrame->hide();
2497 else { 2501 else {
2498 int offX = 0, offY = 0; 2502 int offX = 0, offY = 0;
2499#ifdef DESKTOP_VERSION 2503#ifdef DESKTOP_VERSION
2500 int w =mDatePicker->sizeHint().width() ; 2504 int w =mDatePicker->sizeHint().width() ;
2501 int h = mDatePicker->sizeHint().height() ; 2505 int h = mDatePicker->sizeHint().height() ;
2502 int dw = topLevelWidget()->width(); 2506 int dw = topLevelWidget()->width();
2503 int dh = topLevelWidget()->height(); 2507 int dh = topLevelWidget()->height();
2504 offX = topLevelWidget()->x(); 2508 offX = topLevelWidget()->x();
2505 offY = topLevelWidget()->y(); 2509 offY = topLevelWidget()->y();
2506#else 2510#else
2507 int w =mDatePicker->sizeHint().width() ; 2511 int w =mDatePicker->sizeHint().width() ;
2508 int h = mDatePicker->sizeHint().height() ; 2512 int h = mDatePicker->sizeHint().height() ;
2509 int dw = QApplication::desktop()->width(); 2513 int dw = QApplication::desktop()->width();
2510 int dh = QApplication::desktop()->height(); 2514 int dh = QApplication::desktop()->height();
2511#endif 2515#endif
2512 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); 2516 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h );
2513 mDateFrame->show(); 2517 mDateFrame->show();
2514 } 2518 }
2515} 2519}
2516void CalendarView::showDatePicker( ) 2520void CalendarView::showDatePicker( )
2517{ 2521{
2518 showDatePickerPopup(); 2522 showDatePickerPopup();
2519 mDatePickerMode = 1; 2523 mDatePickerMode = 1;
2520 mDatePicker->setDate( mNavigator->selectedDates().first() ); 2524 mDatePicker->setDate( mNavigator->selectedDates().first() );
2521} 2525}
2522 2526
2523void CalendarView::showEventEditor() 2527void CalendarView::showEventEditor()
2524{ 2528{
2525#ifdef DESKTOP_VERSION 2529#ifdef DESKTOP_VERSION
2526 mEventEditor->show(); 2530 mEventEditor->show();
2527#else 2531#else
2528 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { 2532 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) {
2529 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2533 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2530 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); 2534 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() );
2531 qApp->processEvents(); 2535 qApp->processEvents();
2532 delete mEventEditor; 2536 delete mEventEditor;
2533 mEventEditor = mDialogManager->getEventEditor(); 2537 mEventEditor = mDialogManager->getEventEditor();
2534 topLevelWidget()->setCaption( i18n("") ); 2538 topLevelWidget()->setCaption( i18n("") );
2535 } 2539 }
2536 mEventEditor->showMaximized(); 2540 mEventEditor->showMaximized();
2537#endif 2541#endif
2538} 2542}
2539void CalendarView::showTodoEditor() 2543void CalendarView::showTodoEditor()
2540{ 2544{
2541#ifdef DESKTOP_VERSION 2545#ifdef DESKTOP_VERSION
2542 mTodoEditor->show(); 2546 mTodoEditor->show();
2543#else 2547#else
2544 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { 2548 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) {
2545 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2549 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2546 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); 2550 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() );
2547 qApp->processEvents(); 2551 qApp->processEvents();
2548 delete mTodoEditor; 2552 delete mTodoEditor;
2549 mTodoEditor = mDialogManager->getTodoEditor(); 2553 mTodoEditor = mDialogManager->getTodoEditor();
2550 topLevelWidget()->setCaption( i18n("") ); 2554 topLevelWidget()->setCaption( i18n("") );
2551 } 2555 }
2552 mTodoEditor->showMaximized(); 2556 mTodoEditor->showMaximized();
2553#endif 2557#endif
2554} 2558}
2555 2559
2556void CalendarView::cloneIncidence() 2560void CalendarView::cloneIncidence()
2557{ 2561{
2558 Incidence *incidence = currentSelection(); 2562 Incidence *incidence = currentSelection();
2559 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2563 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2560 if ( incidence ) { 2564 if ( incidence ) {
2561 cloneIncidence(incidence); 2565 cloneIncidence(incidence);
2562 } 2566 }
2563} 2567}
2564void CalendarView::moveIncidence() 2568void CalendarView::moveIncidence()
2565{ 2569{
2566 Incidence *incidence = currentSelection(); 2570 Incidence *incidence = currentSelection();
2567 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2571 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2568 if ( incidence ) { 2572 if ( incidence ) {
2569 moveIncidence(incidence); 2573 moveIncidence(incidence);
2570 } 2574 }
2571} 2575}
2572void CalendarView::beamIncidence() 2576void CalendarView::beamIncidence()
2573{ 2577{
2574 Incidence *incidence = currentSelection(); 2578 Incidence *incidence = currentSelection();
2575 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2579 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2576 if ( incidence ) { 2580 if ( incidence ) {
2577 beamIncidence(incidence); 2581 beamIncidence(incidence);
2578 } 2582 }
2579} 2583}
2580void CalendarView::toggleCancelIncidence() 2584void CalendarView::toggleCancelIncidence()
2581{ 2585{
2582 Incidence *incidence = currentSelection(); 2586 Incidence *incidence = currentSelection();
2583 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2587 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2584 if ( incidence ) { 2588 if ( incidence ) {
2585 cancelIncidence(incidence); 2589 cancelIncidence(incidence);
2586 } 2590 }
2587} 2591}
2588 2592
2589 2593
2590void CalendarView::cancelIncidence(Incidence * inc ) 2594void CalendarView::cancelIncidence(Incidence * inc )
2591{ 2595{
2592 inc->setCancelled( ! inc->cancelled() ); 2596 inc->setCancelled( ! inc->cancelled() );
2593 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 2597 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
2594 updateView(); 2598 updateView();
2595} 2599}
2596void CalendarView::cloneIncidence(Incidence * orgInc ) 2600void CalendarView::cloneIncidence(Incidence * orgInc )
2597{ 2601{
2598 Incidence * newInc = orgInc->clone(); 2602 Incidence * newInc = orgInc->clone();
2599 newInc->recreate(); 2603 newInc->recreate();
2600 2604
2601 if ( newInc->type() == "Todo" ) { 2605 if ( newInc->type() == "Todo" ) {
2602 Todo* t = (Todo*) newInc; 2606 Todo* t = (Todo*) newInc;
2603 showTodoEditor(); 2607 showTodoEditor();
2604 mTodoEditor->editTodo( t ); 2608 mTodoEditor->editTodo( t );
2605 if ( mTodoEditor->exec() ) { 2609 if ( mTodoEditor->exec() ) {
2606 mCalendar->addTodo( t ); 2610 mCalendar->addTodo( t );
2607 updateView(); 2611 updateView();
2608 } else { 2612 } else {
2609 delete t; 2613 delete t;
2610 } 2614 }
2611 } 2615 }
2612 else { 2616 else {
2613 Event* e = (Event*) newInc; 2617 Event* e = (Event*) newInc;
2614 showEventEditor(); 2618 showEventEditor();
2615 mEventEditor->editEvent( e ); 2619 mEventEditor->editEvent( e );
2616 if ( mEventEditor->exec() ) { 2620 if ( mEventEditor->exec() ) {
2617 mCalendar->addEvent( e ); 2621 mCalendar->addEvent( e );
2618 updateView(); 2622 updateView();
2619 } else { 2623 } else {
2620 delete e; 2624 delete e;
2621 } 2625 }
2622 } 2626 }
2627 setActiveWindow();
2623} 2628}
2624 2629
2625void CalendarView::newEvent() 2630void CalendarView::newEvent()
2626{ 2631{
2627 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 2632 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
2628 KOAgendaView *aView = mViewManager->agendaView(); 2633 KOAgendaView *aView = mViewManager->agendaView();
2629 if (aView) { 2634 if (aView) {
2630 if (aView->selectionStart().isValid()) { 2635 if (aView->selectionStart().isValid()) {
2631 if (aView->selectedIsAllDay()) { 2636 if (aView->selectedIsAllDay()) {
2632 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 2637 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
2633 } else { 2638 } else {
2634 newEvent(aView->selectionStart(),aView->selectionEnd()); 2639 newEvent(aView->selectionStart(),aView->selectionEnd());
2635 } 2640 }
2636 return; 2641 return;
2637 } 2642 }
2638 } 2643 }
2639 2644
2640 QDate date = mNavigator->selectedDates().first(); 2645 QDate date = mNavigator->selectedDates().first();
2641 QDateTime current = QDateTime::currentDateTime(); 2646 QDateTime current = QDateTime::currentDateTime();
2642 if ( date <= current.date() ) { 2647 if ( date <= current.date() ) {
2643 int hour = current.time().hour() +1; 2648 int hour = current.time().hour() +1;
2644 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 2649 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
2645 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2650 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2646 } else 2651 } else
2647 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 2652 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
2648 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 2653 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
2649 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2654 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2650} 2655}
2651 2656
2652void CalendarView::newEvent(QDateTime fh) 2657void CalendarView::newEvent(QDateTime fh)
2653{ 2658{
2654 newEvent(fh, 2659 newEvent(fh,
2655 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 2660 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
2656} 2661}
2657 2662
2658void CalendarView::newEvent(QDate dt) 2663void CalendarView::newEvent(QDate dt)
2659{ 2664{
2660 newEvent(QDateTime(dt, QTime(0,0,0)), 2665 newEvent(QDateTime(dt, QTime(0,0,0)),
2661 QDateTime(dt, QTime(0,0,0)), true); 2666 QDateTime(dt, QTime(0,0,0)), true);
2662} 2667}
2663void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) 2668void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint)
2664{ 2669{
2665 newEvent(fromHint, toHint, false); 2670 newEvent(fromHint, toHint, false);
2666} 2671}
2667void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 2672void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
2668{ 2673{
2669 2674
2670 showEventEditor(); 2675 showEventEditor();
2671 mEventEditor->newEvent(fromHint,toHint,allDay); 2676 mEventEditor->newEvent(fromHint,toHint,allDay);
2672 if ( mFilterView->filtersEnabled() ) { 2677 if ( mFilterView->filtersEnabled() ) {
2673 CalFilter *filter = mFilterView->selectedFilter(); 2678 CalFilter *filter = mFilterView->selectedFilter();
2674 if (filter && filter->showCategories()) { 2679 if (filter && filter->showCategories()) {
2675 mEventEditor->setCategories(filter->categoryList().join(",") ); 2680 mEventEditor->setCategories(filter->categoryList().join(",") );
2676 } 2681 }
2677 if ( filter ) 2682 if ( filter )
2678 mEventEditor->setSecrecy( filter->getSecrecy() ); 2683 mEventEditor->setSecrecy( filter->getSecrecy() );
2679 } 2684 }
2685 mEventEditor->exec();
2686 setActiveWindow();
2680} 2687}
2681void CalendarView::todoAdded(Todo * t) 2688void CalendarView::todoAdded(Todo * t)
2682{ 2689{
2683 2690
2684 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 2691 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
2685 updateTodoViews(); 2692 updateTodoViews();
2686} 2693}
2687void CalendarView::todoChanged(Todo * t) 2694void CalendarView::todoChanged(Todo * t)
2688{ 2695{
2689 emit todoModified( t, 4 ); 2696 emit todoModified( t, 4 );
2690 // updateTodoViews(); 2697 // updateTodoViews();
2691} 2698}
2692void CalendarView::todoToBeDeleted(Todo *) 2699void CalendarView::todoToBeDeleted(Todo *)
2693{ 2700{
2694 //qDebug("todoToBeDeleted(Todo *) "); 2701 //qDebug("todoToBeDeleted(Todo *) ");
2695 updateTodoViews(); 2702 updateTodoViews();
2696} 2703}
2697void CalendarView::todoDeleted() 2704void CalendarView::todoDeleted()
2698{ 2705{
2699 //qDebug(" todoDeleted()"); 2706 //qDebug(" todoDeleted()");
2700 updateTodoViews(); 2707 updateTodoViews();
2701} 2708}
2702 2709
2703 2710
2704void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) 2711void CalendarView::newTodoDateTime( QDateTime dt, bool allday )
2705{ 2712{
2706 showTodoEditor(); 2713 showTodoEditor();
2707 mTodoEditor->newTodo(dt,0,allday); 2714 mTodoEditor->newTodo(dt,0,allday);
2708 if ( mFilterView->filtersEnabled() ) { 2715 if ( mFilterView->filtersEnabled() ) {
2709 CalFilter *filter = mFilterView->selectedFilter(); 2716 CalFilter *filter = mFilterView->selectedFilter();
2710 if (filter && filter->showCategories()) { 2717 if (filter && filter->showCategories()) {
2711 mTodoEditor->setCategories(filter->categoryList().join(",") ); 2718 mTodoEditor->setCategories(filter->categoryList().join(",") );
2712 } 2719 }
2713 if ( filter ) 2720 if ( filter )
2714 mTodoEditor->setSecrecy( filter->getSecrecy() ); 2721 mTodoEditor->setSecrecy( filter->getSecrecy() );
2715 } 2722 }
2723 mTodoEditor->exec();
2724 setActiveWindow();
2716} 2725}
2717 2726
2718void CalendarView::newTodo() 2727void CalendarView::newTodo()
2719{ 2728{
2720 newTodoDateTime( QDateTime(),true ); 2729 newTodoDateTime( QDateTime(),true );
2721} 2730}
2722 2731
2723void CalendarView::newSubTodo() 2732void CalendarView::newSubTodo()
2724{ 2733{
2725 Todo *todo = selectedTodo(); 2734 Todo *todo = selectedTodo();
2726 if ( todo ) newSubTodo( todo ); 2735 if ( todo ) newSubTodo( todo );
2727} 2736}
2728 2737
2729void CalendarView::newSubTodo(Todo *parentEvent) 2738void CalendarView::newSubTodo(Todo *parentEvent)
2730{ 2739{
2731 2740
2732 showTodoEditor(); 2741 showTodoEditor();
2733 mTodoEditor->newTodo(QDateTime(),parentEvent,true); 2742 mTodoEditor->newTodo(QDateTime(),parentEvent,true);
2743 mTodoEditor->exec();
2744 setActiveWindow();
2734} 2745}
2735 2746
2736void CalendarView::newFloatingEvent() 2747void CalendarView::newFloatingEvent()
2737{ 2748{
2738 DateList tmpList = mNavigator->selectedDates(); 2749 DateList tmpList = mNavigator->selectedDates();
2739 QDate date = tmpList.first(); 2750 QDate date = tmpList.first();
2740 2751
2741 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 2752 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
2742 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 2753 QDateTime( date, QTime( 12, 0, 0 ) ), true );
2743} 2754}
2744 2755
2745 2756
2746void CalendarView::editEvent( Event *event ) 2757void CalendarView::editEvent( Event *event )
2747{ 2758{
2748 2759
2749 if ( !event ) return; 2760 if ( !event ) return;
2750 if ( event->isReadOnly() ) { 2761 if ( event->isReadOnly() ) {
2751 showEvent( event ); 2762 showEvent( event );
2752 return; 2763 return;
2753 } 2764 }
2754 showEventEditor(); 2765 showEventEditor();
2755 mEventEditor->editEvent( event , mFlagEditDescription); 2766 mEventEditor->editEvent( event , mFlagEditDescription);
2767 mEventEditor->exec();
2768 setActiveWindow();
2769
2756} 2770}
2757void CalendarView::editJournal( Journal *jour ) 2771void CalendarView::editJournal( Journal *jour )
2758{ 2772{
2759 if ( !jour ) return; 2773 if ( !jour ) return;
2760 mDialogManager->hideSearchDialog(); 2774 mDialogManager->hideSearchDialog();
2761 mViewManager->showJournalView(); 2775 mViewManager->showJournalView();
2762 mNavigator->slotDaySelect( jour->dtStart().date() ); 2776 mNavigator->slotDaySelect( jour->dtStart().date() );
2763} 2777}
2764void CalendarView::editTodo( Todo *todo ) 2778void CalendarView::editTodo( Todo *todo )
2765{ 2779{
2766 if ( !todo ) return; 2780 if ( !todo ) return;
2767 2781
2768 if ( todo->isReadOnly() ) { 2782 if ( todo->isReadOnly() ) {
2769 showTodo( todo ); 2783 showTodo( todo );
2770 return; 2784 return;
2771 } 2785 }
2772 showTodoEditor(); 2786 showTodoEditor();
2773 mTodoEditor->editTodo( todo ,mFlagEditDescription); 2787 mTodoEditor->editTodo( todo ,mFlagEditDescription);
2788 mTodoEditor->exec();
2789 setActiveWindow();
2774 2790
2775} 2791}
2776 2792
2777KOEventViewerDialog* CalendarView::getEventViewerDialog() 2793KOEventViewerDialog* CalendarView::getEventViewerDialog()
2778{ 2794{
2779 if ( !mEventViewerDialog ) { 2795 if ( !mEventViewerDialog ) {
2780 mEventViewerDialog = new KOEventViewerDialog(this); 2796 mEventViewerDialog = new KOEventViewerDialog(this);
2781 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 2797 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
2782 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 2798 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
2783 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 2799 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
2784 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 2800 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
2785 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 2801 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
2786 viewManager(), SLOT( showAgendaView( bool ) ) ); 2802 viewManager(), SLOT( showAgendaView( bool ) ) );
2803 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()),
2804 this, SLOT( slotViewerClosed() ) );
2787 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), 2805 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ),
2788 this, SLOT( todoChanged(Todo *) ) ); 2806 this, SLOT( todoChanged(Todo *) ) );
2789 mEventViewerDialog->resize( 640, 480 ); 2807 mEventViewerDialog->resize( 640, 480 );
2790 2808
2791 } 2809 }
2792 return mEventViewerDialog; 2810 return mEventViewerDialog;
2793} 2811}
2794void CalendarView::showEvent(Event *event) 2812void CalendarView::showEvent(Event *event)
2795{ 2813{
2796 getEventViewerDialog()->setEvent(event); 2814 getEventViewerDialog()->setEvent(event);
2797 getEventViewerDialog()->showMe(); 2815 getEventViewerDialog()->showMe();
2798} 2816}
2799 2817
2800void CalendarView::showTodo(Todo *event) 2818void CalendarView::showTodo(Todo *event)
2801{ 2819{
2802 getEventViewerDialog()->setTodo(event); 2820 getEventViewerDialog()->setTodo(event);
2803 getEventViewerDialog()->showMe(); 2821 getEventViewerDialog()->showMe();
2804} 2822}
2805void CalendarView::showJournal( Journal *jour ) 2823void CalendarView::showJournal( Journal *jour )
2806{ 2824{
2807 getEventViewerDialog()->setJournal(jour); 2825 getEventViewerDialog()->setJournal(jour);
2808 getEventViewerDialog()->showMe(); 2826 getEventViewerDialog()->showMe();
2809 2827
2810} 2828}
2811// void CalendarView::todoModified (Todo *event, int changed) 2829// void CalendarView::todoModified (Todo *event, int changed)
2812// { 2830// {
2813// // if (mDialogList.find (event) != mDialogList.end ()) { 2831// // if (mDialogList.find (event) != mDialogList.end ()) {
2814// // kdDebug() << "Todo modified and open" << endl; 2832// // kdDebug() << "Todo modified and open" << endl;
2815// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 2833// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
2816// // temp->modified (changed); 2834// // temp->modified (changed);
2817 2835
2818// // } 2836// // }
2819 2837
2820// mViewManager->updateView(); 2838// mViewManager->updateView();
2821// } 2839// }
2822 2840
2823void CalendarView::appointment_show() 2841void CalendarView::appointment_show()
2824{ 2842{
2825 Event *anEvent = 0; 2843 Event *anEvent = 0;
2826 2844
2827 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2845 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2828 2846
2829 if (mViewManager->currentView()->isEventView()) { 2847 if (mViewManager->currentView()->isEventView()) {
2830 if ( incidence && incidence->type() == "Event" ) { 2848 if ( incidence && incidence->type() == "Event" ) {
2831 anEvent = static_cast<Event *>(incidence); 2849 anEvent = static_cast<Event *>(incidence);
2832 } 2850 }
2833 } 2851 }
2834 2852
2835 if (!anEvent) { 2853 if (!anEvent) {
2836 KNotifyClient::beep(); 2854 KNotifyClient::beep();
2837 return; 2855 return;
2838 } 2856 }
2839 2857
2840 showEvent(anEvent); 2858 showEvent(anEvent);
2841} 2859}
2842 2860
2843void CalendarView::appointment_edit() 2861void CalendarView::appointment_edit()
2844{ 2862{
2845 Event *anEvent = 0; 2863 Event *anEvent = 0;
2846 2864
2847 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2865 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2848 2866
2849 if (mViewManager->currentView()->isEventView()) { 2867 if (mViewManager->currentView()->isEventView()) {
2850 if ( incidence && incidence->type() == "Event" ) { 2868 if ( incidence && incidence->type() == "Event" ) {
2851 anEvent = static_cast<Event *>(incidence); 2869 anEvent = static_cast<Event *>(incidence);
2852 } 2870 }
2853 } 2871 }
2854 2872
2855 if (!anEvent) { 2873 if (!anEvent) {
2856 KNotifyClient::beep(); 2874 KNotifyClient::beep();
2857 return; 2875 return;
2858 } 2876 }
2859 2877
2860 editEvent(anEvent); 2878 editEvent(anEvent);
2861} 2879}
2862 2880
2863void CalendarView::appointment_delete() 2881void CalendarView::appointment_delete()
2864{ 2882{
2865 Event *anEvent = 0; 2883 Event *anEvent = 0;
2866 2884
2867 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2885 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2868 2886
2869 if (mViewManager->currentView()->isEventView()) { 2887 if (mViewManager->currentView()->isEventView()) {
2870 if ( incidence && incidence->type() == "Event" ) { 2888 if ( incidence && incidence->type() == "Event" ) {
2871 anEvent = static_cast<Event *>(incidence); 2889 anEvent = static_cast<Event *>(incidence);
2872 } 2890 }
2873 } 2891 }
2874 2892
2875 if (!anEvent) { 2893 if (!anEvent) {
2876 KNotifyClient::beep(); 2894 KNotifyClient::beep();
2877 return; 2895 return;
2878 } 2896 }
2879 2897
2880 deleteEvent(anEvent); 2898 deleteEvent(anEvent);
2881} 2899}
2882 2900
2883void CalendarView::todo_resub( Todo * parent, Todo * sub ) 2901void CalendarView::todo_resub( Todo * parent, Todo * sub )
2884{ 2902{
2885 if (!sub) return; 2903 if (!sub) return;
2886 if (!parent) return; 2904 if (!parent) return;
2887 if ( sub->relatedTo() ) 2905 if ( sub->relatedTo() )
2888 sub->relatedTo()->removeRelation(sub); 2906 sub->relatedTo()->removeRelation(sub);
2889 sub->setRelatedTo(parent); 2907 sub->setRelatedTo(parent);
2890 sub->setRelatedToUid(parent->uid()); 2908 sub->setRelatedToUid(parent->uid());
2891 parent->addRelation(sub); 2909 parent->addRelation(sub);
2892 sub->updated(); 2910 sub->updated();
2893 parent->updated(); 2911 parent->updated();
2894 setModified(true); 2912 setModified(true);
2895 updateView(); 2913 updateView();
2896} 2914}
2897void CalendarView::todo_unsub(Todo *anTodo ) 2915void CalendarView::todo_unsub(Todo *anTodo )
2898{ 2916{
2899 // Todo *anTodo = selectedTodo(); 2917 // Todo *anTodo = selectedTodo();
2900 if (!anTodo) return; 2918 if (!anTodo) return;
2901 if (!anTodo->relatedTo()) return; 2919 if (!anTodo->relatedTo()) return;
2902 anTodo->relatedTo()->removeRelation(anTodo); 2920 anTodo->relatedTo()->removeRelation(anTodo);
2903 anTodo->setRelatedTo(0); 2921 anTodo->setRelatedTo(0);
2904 anTodo->updated(); 2922 anTodo->updated();
2905 anTodo->setRelatedToUid(""); 2923 anTodo->setRelatedToUid("");
2906 setModified(true); 2924 setModified(true);
2907 updateView(); 2925 updateView();
2908} 2926}
2909 2927
2910void CalendarView::deleteTodo(Todo *todo) 2928void CalendarView::deleteTodo(Todo *todo)
2911{ 2929{
2912 if (!todo) { 2930 if (!todo) {
2913 KNotifyClient::beep(); 2931 KNotifyClient::beep();
2914 return; 2932 return;
2915 } 2933 }
2916 if (KOPrefs::instance()->mConfirm) { 2934 if (KOPrefs::instance()->mConfirm) {
2917 QString text = todo->summary().left(20); 2935 QString text = todo->summary().left(20);
2918 if (!todo->relations().isEmpty()) { 2936 if (!todo->relations().isEmpty()) {
2919 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); 2937 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!");
2920 2938
2921 } 2939 }
2922 switch (msgItemDelete(text)) { 2940 switch (msgItemDelete(text)) {
2923 case KMessageBox::Continue: // OK 2941 case KMessageBox::Continue: // OK
2924 bool deleteT = false; 2942 bool deleteT = false;
2925 if (!todo->relations().isEmpty()) { 2943 if (!todo->relations().isEmpty()) {
2926 deleteT = removeCompletedSubTodos( todo ); 2944 deleteT = removeCompletedSubTodos( todo );
2927 } 2945 }
2928 // deleteT == true: todo already deleted in removeCompletedSubTodos 2946 // deleteT == true: todo already deleted in removeCompletedSubTodos
2929 if ( !deleteT ) { 2947 if ( !deleteT ) {
2930 checkExternalId( todo ); 2948 checkExternalId( todo );
2931 calendar()->deleteTodo(todo); 2949 calendar()->deleteTodo(todo);
2932 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2950 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2933 updateView(); 2951 updateView();
2934 } 2952 }
2935 break; 2953 break;
2936 } // switch 2954 } // switch
2937 } else { 2955 } else {
2938 checkExternalId( todo ); 2956 checkExternalId( todo );
2939 mCalendar->deleteTodo(todo); 2957 mCalendar->deleteTodo(todo);
2940 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2958 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2941 updateView(); 2959 updateView();
2942 } 2960 }
2943 2961
2944 emit updateSearchDialog(); 2962 emit updateSearchDialog();
2945} 2963}
2946void CalendarView::deleteJournal(Journal *jour) 2964void CalendarView::deleteJournal(Journal *jour)
2947{ 2965{
2948 if (!jour) { 2966 if (!jour) {
2949 KNotifyClient::beep(); 2967 KNotifyClient::beep();
2950 return; 2968 return;
2951 } 2969 }
2952 if (KOPrefs::instance()->mConfirm) { 2970 if (KOPrefs::instance()->mConfirm) {
2953 switch (msgItemDelete( jour->description().left(20))) { 2971 switch (msgItemDelete( jour->description().left(20))) {
2954 case KMessageBox::Continue: // OK 2972 case KMessageBox::Continue: // OK
2955 calendar()->deleteJournal(jour); 2973 calendar()->deleteJournal(jour);
2956 updateView(); 2974 updateView();
2957 break; 2975 break;
2958 } // switch 2976 } // switch
2959 } else { 2977 } else {
2960 calendar()->deleteJournal(jour);; 2978 calendar()->deleteJournal(jour);;
2961 updateView(); 2979 updateView();
2962 } 2980 }
2963 emit updateSearchDialog(); 2981 emit updateSearchDialog();
2964} 2982}
2965 2983
2966void CalendarView::deleteEvent(Event *anEvent) 2984void CalendarView::deleteEvent(Event *anEvent)
2967{ 2985{
2968 if (!anEvent) { 2986 if (!anEvent) {
2969 KNotifyClient::beep(); 2987 KNotifyClient::beep();
2970 return; 2988 return;
2971 } 2989 }
2972 2990
2973 if (anEvent->recurrence()->doesRecur()) { 2991 if (anEvent->recurrence()->doesRecur()) {
2974 QDate itemDate = mViewManager->currentSelectionDate(); 2992 QDate itemDate = mViewManager->currentSelectionDate();
2975 int km; 2993 int km;
2976 if (!itemDate.isValid()) { 2994 if (!itemDate.isValid()) {
2977 //kdDebug() << "Date Not Valid" << endl; 2995 //kdDebug() << "Date Not Valid" << endl;
2978 if (KOPrefs::instance()->mConfirm) { 2996 if (KOPrefs::instance()->mConfirm) {
2979 km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + 2997 km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) +
2980 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), 2998 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"),
2981 i18n("KO/Pi Confirmation"),i18n("Delete All")); 2999 i18n("KO/Pi Confirmation"),i18n("Delete All"));
2982 if ( km == KMessageBox::Continue ) 3000 if ( km == KMessageBox::Continue )
2983 km = KMessageBox::No; // No = all below 3001 km = KMessageBox::No; // No = all below
2984 } else 3002 } else
2985 km = KMessageBox::No; 3003 km = KMessageBox::No;
2986 } else { 3004 } else {
2987 km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + 3005 km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) +
2988 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ 3006 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+
2989 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), 3007 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"),
2990 i18n("KO/Pi Confirmation"),i18n("Current"), 3008 i18n("KO/Pi Confirmation"),i18n("Current"),
2991 i18n("All")); 3009 i18n("All"));
2992 } 3010 }
2993 switch(km) { 3011 switch(km) {
2994 3012
2995 case KMessageBox::No: // Continue // all 3013 case KMessageBox::No: // Continue // all
2996 //qDebug("KMessageBox::No "); 3014 //qDebug("KMessageBox::No ");
2997 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3015 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2998 schedule(Scheduler::Cancel,anEvent); 3016 schedule(Scheduler::Cancel,anEvent);
2999 3017
3000 checkExternalId( anEvent); 3018 checkExternalId( anEvent);
3001 mCalendar->deleteEvent(anEvent); 3019 mCalendar->deleteEvent(anEvent);
3002 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); 3020 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED);
3003 break; 3021 break;
3004 3022
3005 // Disabled because it does not work 3023 // Disabled because it does not work
3006 //#if 0 3024 //#if 0
3007 case KMessageBox::Yes: // just this one 3025 case KMessageBox::Yes: // just this one
3008 //QDate qd = mNavigator->selectedDates().first(); 3026 //QDate qd = mNavigator->selectedDates().first();
3009 //if (!qd.isValid()) { 3027 //if (!qd.isValid()) {
3010 // kdDebug() << "no date selected, or invalid date" << endl; 3028 // kdDebug() << "no date selected, or invalid date" << endl;
3011 // KNotifyClient::beep(); 3029 // KNotifyClient::beep();
3012 // return; 3030 // return;
3013 //} 3031 //}
3014 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); 3032 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1);
3015 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { 3033 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) {
3016 anEvent->addExDate(itemDate); 3034 anEvent->addExDate(itemDate);
3017 int duration = anEvent->recurrence()->duration(); 3035 int duration = anEvent->recurrence()->duration();
3018 if ( duration > 0 ) { 3036 if ( duration > 0 ) {
3019 anEvent->recurrence()->setDuration( duration - 1 ); 3037 anEvent->recurrence()->setDuration( duration - 1 );
3020 } 3038 }
3021 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); 3039 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED);
3022 } 3040 }
3023 break; 3041 break;
3024 //#endif 3042 //#endif
3025 } // switch 3043 } // switch
3026 } else { 3044 } else {
3027 if (KOPrefs::instance()->mConfirm) { 3045 if (KOPrefs::instance()->mConfirm) {
3028 switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + 3046 switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) +
3029 i18n("\nAre you sure you want\nto delete this event?"), 3047 i18n("\nAre you sure you want\nto delete this event?"),
3030 i18n("KO/Pi Confirmation"),i18n("Delete"))) { 3048 i18n("KO/Pi Confirmation"),i18n("Delete"))) {
3031 case KMessageBox::Continue: // OK 3049 case KMessageBox::Continue: // OK
3032 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3050 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3033 schedule(Scheduler::Cancel,anEvent); 3051 schedule(Scheduler::Cancel,anEvent);
3034 checkExternalId( anEvent); 3052 checkExternalId( anEvent);
3035 mCalendar->deleteEvent(anEvent); 3053 mCalendar->deleteEvent(anEvent);
3036 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3054 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3037 break; 3055 break;
3038 } // switch 3056 } // switch
3039 } else { 3057 } else {
3040 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3058 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3041 schedule(Scheduler::Cancel,anEvent); 3059 schedule(Scheduler::Cancel,anEvent);
3042 checkExternalId( anEvent); 3060 checkExternalId( anEvent);
3043 mCalendar->deleteEvent(anEvent); 3061 mCalendar->deleteEvent(anEvent);
3044 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3062 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3045 } 3063 }
3046 } // if-else 3064 } // if-else
3047 emit updateSearchDialog(); 3065 emit updateSearchDialog();
3048} 3066}
3049 3067
3050bool CalendarView::deleteEvent(const QString &uid) 3068bool CalendarView::deleteEvent(const QString &uid)
3051{ 3069{
3052 Event *ev = mCalendar->event(uid); 3070 Event *ev = mCalendar->event(uid);
3053 if (ev) { 3071 if (ev) {
3054 deleteEvent(ev); 3072 deleteEvent(ev);
3055 return true; 3073 return true;
3056 } else { 3074 } else {
3057 return false; 3075 return false;
3058 } 3076 }
3059} 3077}
3060 3078
3061/*****************************************************************************/ 3079/*****************************************************************************/
3062 3080
3063void CalendarView::action_mail() 3081void CalendarView::action_mail()
3064{ 3082{
3065#ifndef KORG_NOMAIL 3083#ifndef KORG_NOMAIL
3066 KOMailClient mailClient; 3084 KOMailClient mailClient;
3067 3085
3068 Incidence *incidence = currentSelection(); 3086 Incidence *incidence = currentSelection();
3069 3087
3070 if (!incidence) { 3088 if (!incidence) {
3071 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3089 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3072 return; 3090 return;
3073 } 3091 }
3074 if(incidence->attendeeCount() == 0 ) { 3092 if(incidence->attendeeCount() == 0 ) {
3075 KMessageBox::sorry(this, 3093 KMessageBox::sorry(this,
3076 i18n("Can't generate mail:\nNo attendees defined.\n")); 3094 i18n("Can't generate mail:\nNo attendees defined.\n"));
3077 return; 3095 return;
3078 } 3096 }
3079 3097
3080 CalendarLocal cal_tmp; 3098 CalendarLocal cal_tmp;
3081 Event *event = 0; 3099 Event *event = 0;
3082 Event *ev = 0; 3100 Event *ev = 0;
3083 if ( incidence && incidence->type() == "Event" ) { 3101 if ( incidence && incidence->type() == "Event" ) {
3084 event = static_cast<Event *>(incidence); 3102 event = static_cast<Event *>(incidence);
3085 ev = new Event(*event); 3103 ev = new Event(*event);
3086 cal_tmp.addEvent(ev); 3104 cal_tmp.addEvent(ev);
3087 } 3105 }
3088 ICalFormat mForm(); 3106 ICalFormat mForm();
3089 QString attachment = mForm.toString( &cal_tmp ); 3107 QString attachment = mForm.toString( &cal_tmp );
3090 if (ev) delete(ev); 3108 if (ev) delete(ev);
3091 3109
3092 mailClient.mailAttendees(currentSelection(), attachment); 3110 mailClient.mailAttendees(currentSelection(), attachment);
3093 3111
3094#endif 3112#endif
3095 3113
3096#if 0 3114#if 0
3097 Event *anEvent = 0; 3115 Event *anEvent = 0;
3098 if (mViewManager->currentView()->isEventView()) { 3116 if (mViewManager->currentView()->isEventView()) {
3099 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); 3117 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first());
3100 } 3118 }
3101 3119
3102 if (!anEvent) { 3120 if (!anEvent) {
3103 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3121 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3104 return; 3122 return;
3105 } 3123 }
3106 if(anEvent->attendeeCount() == 0 ) { 3124 if(anEvent->attendeeCount() == 0 ) {
3107 KMessageBox::sorry(this, 3125 KMessageBox::sorry(this,
3108 i18n("Can't generate mail:\nNo attendees defined.\n")); 3126 i18n("Can't generate mail:\nNo attendees defined.\n"));
3109 return; 3127 return;
3110 } 3128 }
3111 3129
3112 mailobject.emailEvent(anEvent); 3130 mailobject.emailEvent(anEvent);
3113#endif 3131#endif
3114} 3132}
3115 3133
3116 3134
3117void CalendarView::schedule_publish(Incidence *incidence) 3135void CalendarView::schedule_publish(Incidence *incidence)
3118{ 3136{
3119 Event *event = 0; 3137 Event *event = 0;
3120 Todo *todo = 0; 3138 Todo *todo = 0;
3121 3139
3122 if (incidence == 0) { 3140 if (incidence == 0) {
3123 incidence = mViewManager->currentView()->selectedIncidences().first(); 3141 incidence = mViewManager->currentView()->selectedIncidences().first();
3124 if (incidence == 0) { 3142 if (incidence == 0) {
3125 incidence = mTodoList->selectedIncidences().first(); 3143 incidence = mTodoList->selectedIncidences().first();
3126 } 3144 }
3127 } 3145 }
3128 if ( incidence && incidence->type() == "Event" ) { 3146 if ( incidence && incidence->type() == "Event" ) {
3129 event = static_cast<Event *>(incidence); 3147 event = static_cast<Event *>(incidence);
3130 } else { 3148 } else {
3131 if ( incidence && incidence->type() == "Todo" ) { 3149 if ( incidence && incidence->type() == "Todo" ) {
3132 todo = static_cast<Todo *>(incidence); 3150 todo = static_cast<Todo *>(incidence);
3133 } 3151 }
3134 } 3152 }
3135 3153
3136 if (!event && !todo) { 3154 if (!event && !todo) {
3137 KMessageBox::sorry(this,i18n("No event selected.")); 3155 KMessageBox::sorry(this,i18n("No event selected."));
3138 return; 3156 return;
3139 } 3157 }
3140 3158
3141 PublishDialog *publishdlg = new PublishDialog(); 3159 PublishDialog *publishdlg = new PublishDialog();
3142 if (incidence->attendeeCount()>0) { 3160 if (incidence->attendeeCount()>0) {
3143 QPtrList<Attendee> attendees = incidence->attendees(); 3161 QPtrList<Attendee> attendees = incidence->attendees();
3144 attendees.first(); 3162 attendees.first();
3145 while ( attendees.current()!=0 ) { 3163 while ( attendees.current()!=0 ) {
3146 publishdlg->addAttendee(attendees.current()); 3164 publishdlg->addAttendee(attendees.current());
3147 attendees.next(); 3165 attendees.next();
3148 } 3166 }
3149 } 3167 }
3150 bool send = true; 3168 bool send = true;
3151 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { 3169 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) {
3152 if ( publishdlg->exec() != QDialog::Accepted ) 3170 if ( publishdlg->exec() != QDialog::Accepted )
3153 send = false; 3171 send = false;
3154 } 3172 }
3155 if ( send ) { 3173 if ( send ) {
3156 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3174 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3157 if ( event ) { 3175 if ( event ) {
3158 Event *ev = new Event(*event); 3176 Event *ev = new Event(*event);
3159 ev->registerObserver(0); 3177 ev->registerObserver(0);
3160 ev->clearAttendees(); 3178 ev->clearAttendees();
3161 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3179 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3162 delete(ev); 3180 delete(ev);
3163 } 3181 }
3164 } else { 3182 } else {
3165 if ( todo ) { 3183 if ( todo ) {
3166 Todo *ev = new Todo(*todo); 3184 Todo *ev = new Todo(*todo);
3167 ev->registerObserver(0); 3185 ev->registerObserver(0);
3168 ev->clearAttendees(); 3186 ev->clearAttendees();
3169 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3187 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3170 delete(ev); 3188 delete(ev);
3171 } 3189 }
3172 } 3190 }
3173 } 3191 }
3174 } 3192 }
3175 delete publishdlg; 3193 delete publishdlg;
3176} 3194}
3177 3195
3178void CalendarView::schedule_request(Incidence *incidence) 3196void CalendarView::schedule_request(Incidence *incidence)
3179{ 3197{
3180 schedule(Scheduler::Request,incidence); 3198 schedule(Scheduler::Request,incidence);
3181} 3199}
3182 3200
3183void CalendarView::schedule_refresh(Incidence *incidence) 3201void CalendarView::schedule_refresh(Incidence *incidence)
3184{ 3202{
3185 schedule(Scheduler::Refresh,incidence); 3203 schedule(Scheduler::Refresh,incidence);
3186} 3204}
3187 3205
3188void CalendarView::schedule_cancel(Incidence *incidence) 3206void CalendarView::schedule_cancel(Incidence *incidence)
3189{ 3207{
3190 schedule(Scheduler::Cancel,incidence); 3208 schedule(Scheduler::Cancel,incidence);
3191} 3209}
3192 3210
3193void CalendarView::schedule_add(Incidence *incidence) 3211void CalendarView::schedule_add(Incidence *incidence)
3194{ 3212{
3195 schedule(Scheduler::Add,incidence); 3213 schedule(Scheduler::Add,incidence);
3196} 3214}
3197 3215
3198void CalendarView::schedule_reply(Incidence *incidence) 3216void CalendarView::schedule_reply(Incidence *incidence)
3199{ 3217{
3200 schedule(Scheduler::Reply,incidence); 3218 schedule(Scheduler::Reply,incidence);
3201} 3219}
3202 3220
3203void CalendarView::schedule_counter(Incidence *incidence) 3221void CalendarView::schedule_counter(Incidence *incidence)
3204{ 3222{
3205 schedule(Scheduler::Counter,incidence); 3223 schedule(Scheduler::Counter,incidence);
3206} 3224}
3207 3225
3208void CalendarView::schedule_declinecounter(Incidence *incidence) 3226void CalendarView::schedule_declinecounter(Incidence *incidence)
3209{ 3227{
3210 schedule(Scheduler::Declinecounter,incidence); 3228 schedule(Scheduler::Declinecounter,incidence);
3211} 3229}
3212 3230
3213void CalendarView::schedule_publish_freebusy(int daysToPublish) 3231void CalendarView::schedule_publish_freebusy(int daysToPublish)
3214{ 3232{
3215 QDateTime start = QDateTime::currentDateTime(); 3233 QDateTime start = QDateTime::currentDateTime();
3216 QDateTime end = start.addDays(daysToPublish); 3234 QDateTime end = start.addDays(daysToPublish);
3217 3235
3218 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); 3236 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end);
3219 freebusy->setOrganizer(KOPrefs::instance()->email()); 3237 freebusy->setOrganizer(KOPrefs::instance()->email());
3220 3238
3221 3239
3222 PublishDialog *publishdlg = new PublishDialog(); 3240 PublishDialog *publishdlg = new PublishDialog();
3223 if ( publishdlg->exec() == QDialog::Accepted ) { 3241 if ( publishdlg->exec() == QDialog::Accepted ) {
3224 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3242 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3225 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { 3243 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) {
3226 delete(freebusy); 3244 delete(freebusy);
3227 } 3245 }
3228 } 3246 }
3229 delete publishdlg; 3247 delete publishdlg;
3230} 3248}
3231 3249
3232void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) 3250void CalendarView::schedule(Scheduler::Method method, Incidence *incidence)
3233{ 3251{
3234 Event *event = 0; 3252 Event *event = 0;
3235 Todo *todo = 0; 3253 Todo *todo = 0;
3236 3254
3237 if (incidence == 0) { 3255 if (incidence == 0) {
3238 incidence = mViewManager->currentView()->selectedIncidences().first(); 3256 incidence = mViewManager->currentView()->selectedIncidences().first();
3239 if (incidence == 0) { 3257 if (incidence == 0) {
3240 incidence = mTodoList->selectedIncidences().first(); 3258 incidence = mTodoList->selectedIncidences().first();
3241 } 3259 }
3242 } 3260 }
3243 if ( incidence && incidence->type() == "Event" ) { 3261 if ( incidence && incidence->type() == "Event" ) {
3244 event = static_cast<Event *>(incidence); 3262 event = static_cast<Event *>(incidence);
3245 } 3263 }
3246 if ( incidence && incidence->type() == "Todo" ) { 3264 if ( incidence && incidence->type() == "Todo" ) {
3247 todo = static_cast<Todo *>(incidence); 3265 todo = static_cast<Todo *>(incidence);
3248 } 3266 }
3249 3267
3250 if (!event && !todo) { 3268 if (!event && !todo) {
3251 KMessageBox::sorry(this,i18n("No event selected.")); 3269 KMessageBox::sorry(this,i18n("No event selected."));
3252 return; 3270 return;
3253 } 3271 }
3254 3272
3255 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { 3273 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) {
3256 KMessageBox::sorry(this,i18n("The event has no attendees.")); 3274 KMessageBox::sorry(this,i18n("The event has no attendees."));
3257 return; 3275 return;
3258 } 3276 }
3259 3277
3260 Event *ev = 0; 3278 Event *ev = 0;
3261 if (event) ev = new Event(*event); 3279 if (event) ev = new Event(*event);
3262 Todo *to = 0; 3280 Todo *to = 0;
3263 if (todo) to = new Todo(*todo); 3281 if (todo) to = new Todo(*todo);
3264 3282
3265 if (method == Scheduler::Reply || method == Scheduler::Refresh) { 3283 if (method == Scheduler::Reply || method == Scheduler::Refresh) {
3266 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 3284 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
3267 if (!me) { 3285 if (!me) {
3268 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); 3286 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails."));
3269 return; 3287 return;
3270 } 3288 }
3271 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { 3289 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) {
3272 StatusDialog *statdlg = new StatusDialog(this); 3290 StatusDialog *statdlg = new StatusDialog(this);
3273 if (!statdlg->exec()==QDialog::Accepted) return; 3291 if (!statdlg->exec()==QDialog::Accepted) return;
3274 me->setStatus( statdlg->status() ); 3292 me->setStatus( statdlg->status() );
3275 delete(statdlg); 3293 delete(statdlg);
3276 } 3294 }
3277 Attendee *menew = new Attendee(*me); 3295 Attendee *menew = new Attendee(*me);
3278 if (ev) { 3296 if (ev) {
3279 ev->clearAttendees(); 3297 ev->clearAttendees();
3280 ev->addAttendee(menew,false); 3298 ev->addAttendee(menew,false);
3281 } else { 3299 } else {
3282 if (to) { 3300 if (to) {
3283 todo->clearAttendees(); 3301 todo->clearAttendees();
3284 todo->addAttendee(menew,false); 3302 todo->addAttendee(menew,false);
3285 } 3303 }
3286 } 3304 }
3287 } 3305 }
3288 3306
3289 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3307 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3290 if (ev) { 3308 if (ev) {
3291 if ( !dlg->addMessage(ev,method) ) delete(ev); 3309 if ( !dlg->addMessage(ev,method) ) delete(ev);
3292 } else { 3310 } else {
3293 if (to) { 3311 if (to) {
3294 if ( !dlg->addMessage(to,method) ) delete(to); 3312 if ( !dlg->addMessage(to,method) ) delete(to);
3295 } 3313 }
3296 } 3314 }
3297} 3315}
3298 3316
3299void CalendarView::openAddressbook() 3317void CalendarView::openAddressbook()
3300{ 3318{
3301 KRun::runCommand("kaddressbook"); 3319 KRun::runCommand("kaddressbook");
3302} 3320}
3303 3321
3304void CalendarView::setModified(bool modified) 3322void CalendarView::setModified(bool modified)
3305{ 3323{
3306 if ( modified ) 3324 if ( modified )
3307 emit signalmodified(); 3325 emit signalmodified();
3308 if (mModified != modified) { 3326 if (mModified != modified) {
3309 mModified = modified; 3327 mModified = modified;
3310 emit modifiedChanged(mModified); 3328 emit modifiedChanged(mModified);
3311 } 3329 }
3312} 3330}
3313 3331
3314bool CalendarView::isReadOnly() 3332bool CalendarView::isReadOnly()
3315{ 3333{
3316 return mReadOnly; 3334 return mReadOnly;
3317} 3335}
3318 3336
3319void CalendarView::setReadOnly(bool readOnly) 3337void CalendarView::setReadOnly(bool readOnly)
3320{ 3338{
3321 if (mReadOnly != readOnly) { 3339 if (mReadOnly != readOnly) {
3322 mReadOnly = readOnly; 3340 mReadOnly = readOnly;
3323 emit readOnlyChanged(mReadOnly); 3341 emit readOnlyChanged(mReadOnly);
3324 } 3342 }
3325} 3343}
3326 3344
3327bool CalendarView::isModified() 3345bool CalendarView::isModified()
3328{ 3346{
3329 return mModified; 3347 return mModified;
3330} 3348}
3331 3349
3332void CalendarView::printSetup() 3350void CalendarView::printSetup()
3333{ 3351{
3334#ifndef KORG_NOPRINTER 3352#ifndef KORG_NOPRINTER
3335 createPrinter(); 3353 createPrinter();
3336 3354
3337 mCalPrinter->setupPrinter(); 3355 mCalPrinter->setupPrinter();
3338#endif 3356#endif
3339} 3357}
3340 3358
3341void CalendarView::print() 3359void CalendarView::print()
3342{ 3360{
3343#ifndef KORG_NOPRINTER 3361#ifndef KORG_NOPRINTER
3344 createPrinter(); 3362 createPrinter();
3345 3363
3346 DateList tmpDateList = mNavigator->selectedDates(); 3364 DateList tmpDateList = mNavigator->selectedDates();
3347 mCalPrinter->print(CalPrinter::Month, 3365 mCalPrinter->print(CalPrinter::Month,
3348 tmpDateList.first(), tmpDateList.last()); 3366 tmpDateList.first(), tmpDateList.last());
3349#endif 3367#endif
3350} 3368}
3351 3369
3352void CalendarView::printPreview() 3370void CalendarView::printPreview()
3353{ 3371{
3354#ifndef KORG_NOPRINTER 3372#ifndef KORG_NOPRINTER
3355 kdDebug() << "CalendarView::printPreview()" << endl; 3373 kdDebug() << "CalendarView::printPreview()" << endl;
3356 3374
3357 createPrinter(); 3375 createPrinter();
3358 3376
3359 DateList tmpDateList = mNavigator->selectedDates(); 3377 DateList tmpDateList = mNavigator->selectedDates();
3360 3378
3361 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), 3379 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(),
3362 tmpDateList.last()); 3380 tmpDateList.last());
3363#endif 3381#endif
3364} 3382}
3365 3383
3366void CalendarView::exportICalendar() 3384void CalendarView::exportICalendar()
3367{ 3385{
3368 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); 3386 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this);
3369 3387
3370 // Force correct extension 3388 // Force correct extension
3371 if (filename.right(4) != ".ics") filename += ".ics"; 3389 if (filename.right(4) != ".ics") filename += ".ics";
3372 3390
3373 FileStorage storage( mCalendar, filename, new ICalFormat() ); 3391 FileStorage storage( mCalendar, filename, new ICalFormat() );
3374 storage.save(); 3392 storage.save();
3375} 3393}
3376 3394
3377bool CalendarView::exportVCalendar( QString filename ) 3395bool CalendarView::exportVCalendar( QString filename )
3378{ 3396{
3379 if (mCalendar->journals().count() > 0) { 3397 if (mCalendar->journals().count() > 0) {
3380 int result = KMessageBox::warningContinueCancel(this, 3398 int result = KMessageBox::warningContinueCancel(this,
3381 i18n("The journal entries can not be\nexported to a vCalendar file."), 3399 i18n("The journal entries can not be\nexported to a vCalendar file."),
3382 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 3400 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
3383 true); 3401 true);
3384 if (result != KMessageBox::Continue) return false; 3402 if (result != KMessageBox::Continue) return false;
3385 } 3403 }
3386 3404
3387 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); 3405 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this);
3388 3406
3389 // Force correct extension 3407 // Force correct extension
3390 if (filename.right(4) != ".vcs") filename += ".vcs"; 3408 if (filename.right(4) != ".vcs") filename += ".vcs";
3391 3409
3392 FileStorage storage( mCalendar, filename, new VCalFormat ); 3410 FileStorage storage( mCalendar, filename, new VCalFormat );
3393 return storage.save(); 3411 return storage.save();
3394 3412
3395} 3413}
3396 3414
3397void CalendarView::eventUpdated(Incidence *) 3415void CalendarView::eventUpdated(Incidence *)
3398{ 3416{
3399 setModified(); 3417 setModified();
3400 // Don't call updateView here. The code, which has caused the update of the 3418 // Don't call updateView here. The code, which has caused the update of the
3401 // event is responsible for updating the view. 3419 // event is responsible for updating the view.
3402 // updateView(); 3420 // updateView();
3403} 3421}
3404 3422
3405void CalendarView::adaptNavigationUnits() 3423void CalendarView::adaptNavigationUnits()
3406{ 3424{
3407 if (mViewManager->currentView()->isEventView()) { 3425 if (mViewManager->currentView()->isEventView()) {
3408 int days = mViewManager->currentView()->currentDateCount(); 3426 int days = mViewManager->currentView()->currentDateCount();
3409 if (days == 1) { 3427 if (days == 1) {
3410 emit changeNavStringPrev(i18n("&Previous Day")); 3428 emit changeNavStringPrev(i18n("&Previous Day"));
3411 emit changeNavStringNext(i18n("&Next Day")); 3429 emit changeNavStringNext(i18n("&Next Day"));
3412 } else { 3430 } else {
3413 emit changeNavStringPrev(i18n("&Previous Week")); 3431 emit changeNavStringPrev(i18n("&Previous Week"));
3414 emit changeNavStringNext(i18n("&Next Week")); 3432 emit changeNavStringNext(i18n("&Next Week"));
3415 } 3433 }
3416 } 3434 }
3417} 3435}
3418 3436
3419void CalendarView::processMainViewSelection( Incidence *incidence ) 3437void CalendarView::processMainViewSelection( Incidence *incidence )
3420{ 3438{
3421 if ( incidence ) mTodoList->clearSelection(); 3439 if ( incidence ) mTodoList->clearSelection();
3422 processIncidenceSelection( incidence ); 3440 processIncidenceSelection( incidence );
3423} 3441}
3424 3442
3425void CalendarView::processTodoListSelection( Incidence *incidence ) 3443void CalendarView::processTodoListSelection( Incidence *incidence )
3426{ 3444{
3427 if ( incidence && mViewManager->currentView() ) { 3445 if ( incidence && mViewManager->currentView() ) {
3428 mViewManager->currentView()->clearSelection(); 3446 mViewManager->currentView()->clearSelection();
3429 } 3447 }
3430 processIncidenceSelection( incidence ); 3448 processIncidenceSelection( incidence );
3431} 3449}
3432 3450
3433void CalendarView::processIncidenceSelection( Incidence *incidence ) 3451void CalendarView::processIncidenceSelection( Incidence *incidence )
3434{ 3452{
3435 if ( incidence == mSelectedIncidence ) return; 3453 if ( incidence == mSelectedIncidence ) return;
3436 3454
3437 mSelectedIncidence = incidence; 3455 mSelectedIncidence = incidence;
3438 3456
3439 emit incidenceSelected( mSelectedIncidence ); 3457 emit incidenceSelected( mSelectedIncidence );
3440 3458
3441 if ( incidence && incidence->type() == "Event" ) { 3459 if ( incidence && incidence->type() == "Event" ) {
3442 Event *event = static_cast<Event *>( incidence ); 3460 Event *event = static_cast<Event *>( incidence );
3443 if ( event->organizer() == KOPrefs::instance()->email() ) { 3461 if ( event->organizer() == KOPrefs::instance()->email() ) {
3444 emit organizerEventsSelected( true ); 3462 emit organizerEventsSelected( true );
3445 } else { 3463 } else {
3446 emit organizerEventsSelected(false); 3464 emit organizerEventsSelected(false);
3447 } 3465 }
3448 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3466 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3449 KOPrefs::instance()->email() ) ) { 3467 KOPrefs::instance()->email() ) ) {
3450 emit groupEventsSelected( true ); 3468 emit groupEventsSelected( true );
3451 } else { 3469 } else {
3452 emit groupEventsSelected(false); 3470 emit groupEventsSelected(false);
3453 } 3471 }
3454 return; 3472 return;
3455 } else { 3473 } else {
3456 if ( incidence && incidence->type() == "Todo" ) { 3474 if ( incidence && incidence->type() == "Todo" ) {
3457 emit todoSelected( true ); 3475 emit todoSelected( true );
3458 Todo *event = static_cast<Todo *>( incidence ); 3476 Todo *event = static_cast<Todo *>( incidence );
3459 if ( event->organizer() == KOPrefs::instance()->email() ) { 3477 if ( event->organizer() == KOPrefs::instance()->email() ) {
3460 emit organizerEventsSelected( true ); 3478 emit organizerEventsSelected( true );
3461 } else { 3479 } else {
3462 emit organizerEventsSelected(false); 3480 emit organizerEventsSelected(false);
3463 } 3481 }
3464 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3482 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3465 KOPrefs::instance()->email() ) ) { 3483 KOPrefs::instance()->email() ) ) {
3466 emit groupEventsSelected( true ); 3484 emit groupEventsSelected( true );
3467 } else { 3485 } else {
3468 emit groupEventsSelected(false); 3486 emit groupEventsSelected(false);
3469 } 3487 }
3470 return; 3488 return;
3471 } else { 3489 } else {
3472 emit todoSelected( false ); 3490 emit todoSelected( false );
3473 emit organizerEventsSelected(false); 3491 emit organizerEventsSelected(false);
3474 emit groupEventsSelected(false); 3492 emit groupEventsSelected(false);
3475 } 3493 }
3476 return; 3494 return;
3477 } 3495 }
3478 3496
3479 /* if ( incidence && incidence->type() == "Todo" ) { 3497 /* if ( incidence && incidence->type() == "Todo" ) {
3480 emit todoSelected( true ); 3498 emit todoSelected( true );
3481 } else { 3499 } else {
3482 emit todoSelected( false ); 3500 emit todoSelected( false );
3483 }*/ 3501 }*/
3484} 3502}
3485 3503
3486 3504
3487void CalendarView::checkClipboard() 3505void CalendarView::checkClipboard()
3488{ 3506{
3489#ifndef KORG_NODND 3507#ifndef KORG_NODND
3490 if (ICalDrag::canDecode(QApplication::clipboard()->data())) { 3508 if (ICalDrag::canDecode(QApplication::clipboard()->data())) {
3491 emit pasteEnabled(true); 3509 emit pasteEnabled(true);
3492 } else { 3510 } else {
3493 emit pasteEnabled(false); 3511 emit pasteEnabled(false);
3494 } 3512 }
3495#endif 3513#endif
3496} 3514}
3497 3515
3498void CalendarView::showDates(const DateList &selectedDates) 3516void CalendarView::showDates(const DateList &selectedDates)
3499{ 3517{
3500 // kdDebug() << "CalendarView::selectDates()" << endl; 3518 // kdDebug() << "CalendarView::selectDates()" << endl;
3501 3519
3502 3520
3503 if ( !mBlockShowDates ) { 3521 if ( !mBlockShowDates ) {
3504 if ( mViewManager->currentView() ) { 3522 if ( mViewManager->currentView() ) {
3505 updateView( selectedDates.first(), selectedDates.last() ); 3523 updateView( selectedDates.first(), selectedDates.last() );
3506 } else { 3524 } else {
3507 mViewManager->showAgendaView(); 3525 mViewManager->showAgendaView();
3508 } 3526 }
3509 } 3527 }
3510 3528
3511 QString selDates; 3529 QString selDates;
3512 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); 3530 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true);
3513 if (selectedDates.first() < selectedDates.last() ) 3531 if (selectedDates.first() < selectedDates.last() )
3514 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); 3532 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true);
3515 else { 3533 else {
3516 QString addString; 3534 QString addString;
3517 if ( selectedDates.first() == QDateTime::currentDateTime().date() ) 3535 if ( selectedDates.first() == QDateTime::currentDateTime().date() )
3518 addString = i18n("Today"); 3536 addString = i18n("Today");
3519 else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) 3537 else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(1) )
3520 addString = i18n("Tomorrow"); 3538 addString = i18n("Tomorrow");
3521 else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) 3539 else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) )
3522 addString = i18n("Yesterday"); 3540 addString = i18n("Yesterday");
3523 else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) 3541 else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) )
3524 addString = i18n("Day before yesterday"); 3542 addString = i18n("Day before yesterday");
3525 else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) 3543 else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(2) )
3526 addString = i18n("Day after tomorrow"); 3544 addString = i18n("Day after tomorrow");
3527 if ( !addString.isEmpty() ) { 3545 if ( !addString.isEmpty() ) {
3528 topLevelWidget()->setCaption( addString+", " + selDates ); 3546 topLevelWidget()->setCaption( addString+", " + selDates );
3529 return; 3547 return;
3530 } 3548 }
3531 } 3549 }
3532 topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); 3550 topLevelWidget()->setCaption( i18n("Dates: ") + selDates );
3533 3551
3534} 3552}
3535 3553
3536QPtrList<CalFilter> CalendarView::filters() 3554QPtrList<CalFilter> CalendarView::filters()
3537{ 3555{
3538 return mFilters; 3556 return mFilters;
3539 3557
3540} 3558}
3541void CalendarView::editFilters() 3559void CalendarView::editFilters()
3542{ 3560{
3543 // kdDebug() << "CalendarView::editFilters()" << endl; 3561 // kdDebug() << "CalendarView::editFilters()" << endl;
3544 3562
3545 CalFilter *filter = mFilters.first(); 3563 CalFilter *filter = mFilters.first();
3546 while(filter) { 3564 while(filter) {
3547 kdDebug() << " Filter: " << filter->name() << endl; 3565 kdDebug() << " Filter: " << filter->name() << endl;
3548 filter = mFilters.next(); 3566 filter = mFilters.next();
3549 } 3567 }
3550 3568
3551 mDialogManager->showFilterEditDialog(&mFilters); 3569 mDialogManager->showFilterEditDialog(&mFilters);
3552} 3570}
3553void CalendarView::toggleFilter() 3571void CalendarView::toggleFilter()
3554{ 3572{
3555 showFilter(! mFilterView->isVisible()); 3573 showFilter(! mFilterView->isVisible());
3556} 3574}
3557 3575
3558KOFilterView *CalendarView::filterView() 3576KOFilterView *CalendarView::filterView()
3559{ 3577{
3560 return mFilterView; 3578 return mFilterView;
3561} 3579}
3562void CalendarView::selectFilter( int fil ) 3580void CalendarView::selectFilter( int fil )
3563{ 3581{
3564 mFilterView->setSelectedFilter( fil ); 3582 mFilterView->setSelectedFilter( fil );
3565} 3583}
3566void CalendarView::showFilter(bool visible) 3584void CalendarView::showFilter(bool visible)
3567{ 3585{
3568 if (visible) mFilterView->show(); 3586 if (visible) mFilterView->show();
3569 else mFilterView->hide(); 3587 else mFilterView->hide();
3570} 3588}
3571void CalendarView::toggleFilerEnabled( ) 3589void CalendarView::toggleFilerEnabled( )
3572{ 3590{
3573 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); 3591 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() );
3574 if ( !mFilterView->filtersEnabled() ) 3592 if ( !mFilterView->filtersEnabled() )
3575 topLevelWidget()->setCaption( i18n("Filter disabled ") ); 3593 topLevelWidget()->setCaption( i18n("Filter disabled ") );
3576 3594
3577} 3595}
3578void CalendarView::updateFilter() 3596void CalendarView::updateFilter()
3579{ 3597{
3580 CalFilter *filter = mFilterView->selectedFilter(); 3598 CalFilter *filter = mFilterView->selectedFilter();
3581 if (filter) { 3599 if (filter) {
3582 if (mFilterView->filtersEnabled()) { 3600 if (mFilterView->filtersEnabled()) {
3583 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); 3601 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() );
3584 filter->setEnabled(true); 3602 filter->setEnabled(true);
3585 } 3603 }
3586 else filter->setEnabled(false); 3604 else filter->setEnabled(false);
3587 mCalendar->setFilter(filter); 3605 mCalendar->setFilter(filter);
3588 updateView(); 3606 updateView();
3589 } 3607 }
3590} 3608}
3591 3609
3592void CalendarView::filterEdited() 3610void CalendarView::filterEdited()
3593{ 3611{
3594 mFilterView->updateFilters(); 3612 mFilterView->updateFilters();
3595 updateFilter(); 3613 updateFilter();
3596 writeSettings(); 3614 writeSettings();
3597} 3615}
3598 3616
3599 3617
3600void CalendarView::takeOverEvent() 3618void CalendarView::takeOverEvent()
3601{ 3619{
3602 Incidence *incidence = currentSelection(); 3620 Incidence *incidence = currentSelection();
3603 3621
3604 if (!incidence) return; 3622 if (!incidence) return;
3605 3623
3606 incidence->setOrganizer(KOPrefs::instance()->email()); 3624 incidence->setOrganizer(KOPrefs::instance()->email());
3607 incidence->recreate(); 3625 incidence->recreate();
3608 incidence->setReadOnly(false); 3626 incidence->setReadOnly(false);
3609 3627
3610 updateView(); 3628 updateView();
3611} 3629}
3612 3630
3613void CalendarView::takeOverCalendar() 3631void CalendarView::takeOverCalendar()
3614{ 3632{
3615 // TODO: Create Calendar::allIncidences() function and use it here 3633 // TODO: Create Calendar::allIncidences() function and use it here
3616 3634
3617 QPtrList<Event> events = mCalendar->events(); 3635 QPtrList<Event> events = mCalendar->events();
3618 for(uint i=0; i<events.count(); ++i) { 3636 for(uint i=0; i<events.count(); ++i) {
3619 events.at(i)->setOrganizer(KOPrefs::instance()->email()); 3637 events.at(i)->setOrganizer(KOPrefs::instance()->email());
3620 events.at(i)->recreate(); 3638 events.at(i)->recreate();
3621 events.at(i)->setReadOnly(false); 3639 events.at(i)->setReadOnly(false);
3622 } 3640 }
3623 3641
3624 QPtrList<Todo> todos = mCalendar->todos(); 3642 QPtrList<Todo> todos = mCalendar->todos();
3625 for(uint i=0; i<todos.count(); ++i) { 3643 for(uint i=0; i<todos.count(); ++i) {
3626 todos.at(i)->setOrganizer(KOPrefs::instance()->email()); 3644 todos.at(i)->setOrganizer(KOPrefs::instance()->email());
3627 todos.at(i)->recreate(); 3645 todos.at(i)->recreate();
3628 todos.at(i)->setReadOnly(false); 3646 todos.at(i)->setReadOnly(false);
3629 } 3647 }
3630 3648
3631 QPtrList<Journal> journals = mCalendar->journals(); 3649 QPtrList<Journal> journals = mCalendar->journals();
3632 for(uint i=0; i<journals.count(); ++i) { 3650 for(uint i=0; i<journals.count(); ++i) {
3633 journals.at(i)->setOrganizer(KOPrefs::instance()->email()); 3651 journals.at(i)->setOrganizer(KOPrefs::instance()->email());
3634 journals.at(i)->recreate(); 3652 journals.at(i)->recreate();
3635 journals.at(i)->setReadOnly(false); 3653 journals.at(i)->setReadOnly(false);
3636 } 3654 }
3637 3655
3638 updateView(); 3656 updateView();
3639} 3657}
3640 3658
3641void CalendarView::showIntro() 3659void CalendarView::showIntro()
3642{ 3660{
3643 kdDebug() << "To be implemented." << endl; 3661 kdDebug() << "To be implemented." << endl;
3644} 3662}
3645 3663
3646QWidgetStack *CalendarView::viewStack() 3664QWidgetStack *CalendarView::viewStack()
3647{ 3665{
3648 return mRightFrame; 3666 return mRightFrame;
3649} 3667}
3650 3668
3651QWidget *CalendarView::leftFrame() 3669QWidget *CalendarView::leftFrame()
3652{ 3670{
3653 return mLeftFrame; 3671 return mLeftFrame;
3654} 3672}
3655 3673
3656DateNavigator *CalendarView::dateNavigator() 3674DateNavigator *CalendarView::dateNavigator()
3657{ 3675{
3658 return mNavigator; 3676 return mNavigator;
3659} 3677}
3660 3678
3661KDateNavigator* CalendarView::dateNavigatorWidget() 3679KDateNavigator* CalendarView::dateNavigatorWidget()
3662{ 3680{
3663 return mDateNavigator; 3681 return mDateNavigator;
3664} 3682}
3665void CalendarView::toggleDateNavigatorWidget() 3683void CalendarView::toggleDateNavigatorWidget()
3666{ 3684{
3667 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; 3685 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ;
3668 if (!KOPrefs::instance()->mShowDateNavigator ) 3686 if (!KOPrefs::instance()->mShowDateNavigator )
3669 mDateNavigator->hide(); 3687 mDateNavigator->hide();
3670 else 3688 else
3671 mDateNavigator->show(); 3689 mDateNavigator->show();
3672} 3690}
3673void CalendarView::addView(KOrg::BaseView *view) 3691void CalendarView::addView(KOrg::BaseView *view)
3674{ 3692{
3675 mViewManager->addView(view); 3693 mViewManager->addView(view);
3676} 3694}
3677 3695
3678void CalendarView::showView(KOrg::BaseView *view) 3696void CalendarView::showView(KOrg::BaseView *view)
3679{ 3697{
3680 mViewManager->showView(view, mLeftFrame->isVisible()); 3698 mViewManager->showView(view, mLeftFrame->isVisible());
3681} 3699}
3682 3700
3683Incidence *CalendarView::currentSelection() 3701Incidence *CalendarView::currentSelection()
3684{ 3702{
3685 return mViewManager->currentSelection(); 3703 return mViewManager->currentSelection();
3686} 3704}
3687void CalendarView::toggleAllDaySize() 3705void CalendarView::toggleAllDaySize()
3688{ 3706{
3689 /* 3707 /*
3690 if ( KOPrefs::instance()->mAllDaySize > 47 ) 3708 if ( KOPrefs::instance()->mAllDaySize > 47 )
3691 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; 3709 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2;
3692 else 3710 else
3693 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; 3711 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2;
3694 */ 3712 */
3695 viewManager()->agendaView()->toggleAllDay(); 3713 viewManager()->agendaView()->toggleAllDay();
3696} 3714}
3697void CalendarView::toggleExpand() 3715void CalendarView::toggleExpand()
3698{ 3716{
3699 // if ( mLeftFrame->isHidden() ) { 3717 // if ( mLeftFrame->isHidden() ) {
3700 // mLeftFrame->show(); 3718 // mLeftFrame->show();
3701 // emit calendarViewExpanded( false ); 3719 // emit calendarViewExpanded( false );
3702 // } else { 3720 // } else {
3703 // mLeftFrame->hide(); 3721 // mLeftFrame->hide();
3704 // emit calendarViewExpanded( true ); 3722 // emit calendarViewExpanded( true );
3705 // } 3723 // }
3706 //qDebug(" CalendarView::toggleExpand()"); 3724 //qDebug(" CalendarView::toggleExpand()");
3707 globalFlagBlockAgenda = 1; 3725 globalFlagBlockAgenda = 1;
3708 emit calendarViewExpanded( !mLeftFrame->isHidden() ); 3726 emit calendarViewExpanded( !mLeftFrame->isHidden() );
3709 globalFlagBlockAgenda = 5; 3727 globalFlagBlockAgenda = 5;
3710 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); 3728 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() );
3711 //mViewManager->showView( 0, true ); 3729 //mViewManager->showView( 0, true );
3712} 3730}
3713 3731
3714void CalendarView::calendarModified( bool modified, Calendar * ) 3732void CalendarView::calendarModified( bool modified, Calendar * )
3715{ 3733{
3716 setModified( modified ); 3734 setModified( modified );
3717} 3735}
3718 3736
3719Todo *CalendarView::selectedTodo() 3737Todo *CalendarView::selectedTodo()
3720{ 3738{
3721 Incidence *incidence = currentSelection(); 3739 Incidence *incidence = currentSelection();
3722 if ( incidence && incidence->type() == "Todo" ) { 3740 if ( incidence && incidence->type() == "Todo" ) {
3723 return static_cast<Todo *>( incidence ); 3741 return static_cast<Todo *>( incidence );
3724 } 3742 }
3725 3743
3726 incidence = mTodoList->selectedIncidences().first(); 3744 incidence = mTodoList->selectedIncidences().first();
3727 if ( incidence && incidence->type() == "Todo" ) { 3745 if ( incidence && incidence->type() == "Todo" ) {
3728 return static_cast<Todo *>( incidence ); 3746 return static_cast<Todo *>( incidence );
3729 } 3747 }
3730 3748
3731 return 0; 3749 return 0;
3732} 3750}
3733 3751
3734void CalendarView::dialogClosing(Incidence *in) 3752void CalendarView::dialogClosing(Incidence *in)
3735{ 3753{
3736 // mDialogList.remove(in); 3754 // mDialogList.remove(in);
3737} 3755}
3738 3756
3739void CalendarView::showIncidence() 3757void CalendarView::showIncidence()
3740{ 3758{
3759 mViewerCallerIsSearchDialog = false;
3741 Incidence *incidence = currentSelection(); 3760 Incidence *incidence = currentSelection();
3742 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3761 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3743 if ( incidence ) { 3762 if ( incidence ) {
3744 ShowIncidenceVisitor v; 3763 ShowIncidenceVisitor v;
3745 v.act( incidence, this ); 3764 v.act( incidence, this );
3746 } 3765 }
3747} 3766}
3748void CalendarView::editIncidenceDescription() 3767void CalendarView::editIncidenceDescription()
3749{ 3768{
3750 mFlagEditDescription = true; 3769 mFlagEditDescription = true;
3751 editIncidence(); 3770 editIncidence();
3752 mFlagEditDescription = false; 3771 mFlagEditDescription = false;
3753} 3772}
3754void CalendarView::editIncidence() 3773void CalendarView::editIncidence()
3755{ 3774{
3756 // qDebug("editIncidence() "); 3775 // qDebug("editIncidence() ");
3757 Incidence *incidence = currentSelection(); 3776 Incidence *incidence = currentSelection();
3758 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3777 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3759 if ( incidence ) { 3778 if ( incidence ) {
3760 EditIncidenceVisitor v; 3779 EditIncidenceVisitor v;
3761 v.act( incidence, this ); 3780 v.act( incidence, this );
3762 } 3781 }
3763} 3782}
3764 3783
3765void CalendarView::deleteIncidence() 3784void CalendarView::deleteIncidence()
3766{ 3785{
3767 Incidence *incidence = currentSelection(); 3786 Incidence *incidence = currentSelection();
3768 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3787 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3769 if ( incidence ) { 3788 if ( incidence ) {
3770 deleteIncidence(incidence); 3789 deleteIncidence(incidence);
3771 } 3790 }
3772} 3791}
3773 3792
3774void CalendarView::showIncidence(Incidence *incidence) 3793void CalendarView::showIncidence(Incidence *incidence)
3775{ 3794{
3795 mViewerCallerIsSearchDialog = false;
3796 //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() );
3797 if ( sender() && mDialogManager->getSearchDialog() ) {
3798 if ( sender () == mDialogManager->getSearchDialog()->listview() ) {
3799 mViewerCallerIsSearchDialog = true;
3800 }
3801 }
3776 if ( incidence ) { 3802 if ( incidence ) {
3777 ShowIncidenceVisitor v; 3803 ShowIncidenceVisitor v;
3778 v.act( incidence, this ); 3804 v.act( incidence, this );
3779 } 3805 }
3780} 3806}
3781 3807
3782void CalendarView::editIncidence(Incidence *incidence) 3808void CalendarView::editIncidence(Incidence *incidence)
3783{ 3809{
3784 if ( incidence ) { 3810 if ( incidence ) {
3785 3811
3786 EditIncidenceVisitor v; 3812 EditIncidenceVisitor v;
3787 v.act( incidence, this ); 3813 v.act( incidence, this );
3788 3814
3789 } 3815 }
3790} 3816}
3791 3817
3792void CalendarView::deleteIncidence(Incidence *incidence) 3818void CalendarView::deleteIncidence(Incidence *incidence)
3793{ 3819{
3794 //qDebug(" CalendarView::deleteIncidence "); 3820 //qDebug(" CalendarView::deleteIncidence ");
3795 if ( incidence ) { 3821 if ( incidence ) {
3796 DeleteIncidenceVisitor v; 3822 DeleteIncidenceVisitor v;
3797 v.act( incidence, this ); 3823 v.act( incidence, this );
3798 } 3824 }
3799} 3825}
3800 3826
3801 3827
3802void CalendarView::lookForOutgoingMessages() 3828void CalendarView::lookForOutgoingMessages()
3803{ 3829{
3804 OutgoingDialog *ogd = mDialogManager->outgoingDialog(); 3830 OutgoingDialog *ogd = mDialogManager->outgoingDialog();
3805 ogd->loadMessages(); 3831 ogd->loadMessages();
3806} 3832}
3807 3833
3808void CalendarView::lookForIncomingMessages() 3834void CalendarView::lookForIncomingMessages()
3809{ 3835{
3810 IncomingDialog *icd = mDialogManager->incomingDialog(); 3836 IncomingDialog *icd = mDialogManager->incomingDialog();
3811 icd->retrieve(); 3837 icd->retrieve();
3812} 3838}
3813 3839
3814bool CalendarView::removeCompletedSubTodos( Todo* t ) 3840bool CalendarView::removeCompletedSubTodos( Todo* t )
3815{ 3841{
3816 bool deleteTodo = true; 3842 bool deleteTodo = true;
3817 QPtrList<Incidence> subTodos; 3843 QPtrList<Incidence> subTodos;
3818 Incidence *aTodo; 3844 Incidence *aTodo;
3819 subTodos = t->relations(); 3845 subTodos = t->relations();
3820 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { 3846 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
3821 if (! removeCompletedSubTodos( (Todo*) aTodo )) 3847 if (! removeCompletedSubTodos( (Todo*) aTodo ))
3822 deleteTodo = false; 3848 deleteTodo = false;
3823 } 3849 }
3824 if ( deleteTodo ) { 3850 if ( deleteTodo ) {
3825 if ( t->isCompleted() && !t->doesRecur()) { 3851 if ( t->isCompleted() && !t->doesRecur()) {
3826 checkExternalId( t ); 3852 checkExternalId( t );
3827 mCalendar->deleteTodo( t ); 3853 mCalendar->deleteTodo( t );
3828 changeTodoDisplay( t,KOGlobals::EVENTDELETED ); 3854 changeTodoDisplay( t,KOGlobals::EVENTDELETED );
3829 } 3855 }
3830 else 3856 else
3831 deleteTodo = false; 3857 deleteTodo = false;
3832 } 3858 }
3833 return deleteTodo; 3859 return deleteTodo;
3834 3860
3835} 3861}
3836void CalendarView::purgeCompleted() 3862void CalendarView::purgeCompleted()
3837{ 3863{
3838 int result = KMessageBox::warningContinueCancel(this, 3864 int result = KMessageBox::warningContinueCancel(this,
3839 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); 3865 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge"));
3840 3866
3841 if (result == KMessageBox::Continue) { 3867 if (result == KMessageBox::Continue) {
3842 3868
3843 QPtrList<Todo> todoCal; 3869 QPtrList<Todo> todoCal;
3844 QPtrList<Todo> rootTodos; 3870 QPtrList<Todo> rootTodos;
3845 //QPtrList<Incidence> rel; 3871 //QPtrList<Incidence> rel;
3846 Todo *aTodo;//, *rTodo; 3872 Todo *aTodo;//, *rTodo;
3847 Incidence *rIncidence; 3873 Incidence *rIncidence;
3848 bool childDelete = false; 3874 bool childDelete = false;
3849 bool deletedOne = true; 3875 bool deletedOne = true;
3850 todoCal = calendar()->todos(); 3876 todoCal = calendar()->todos();
3851 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { 3877 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
3852 if ( !aTodo->relatedTo() ) 3878 if ( !aTodo->relatedTo() )
3853 rootTodos.append( aTodo ); 3879 rootTodos.append( aTodo );
3854 } 3880 }
3855 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { 3881 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) {
3856 removeCompletedSubTodos( aTodo ); 3882 removeCompletedSubTodos( aTodo );
3857 } 3883 }
3858 3884
3859 updateView(); 3885 updateView();
3860 } 3886 }
3861} 3887}
3862 3888
3863void CalendarView::slotCalendarChanged() 3889void CalendarView::slotCalendarChanged()
3864{ 3890{
3865 ; 3891 ;
3866} 3892}
3867 3893
3868void CalendarView::keyPressEvent ( QKeyEvent *e) 3894void CalendarView::keyPressEvent ( QKeyEvent *e)
3869{ 3895{
3870 //qDebug(" alendarView::keyPressEvent "); 3896 //qDebug(" alendarView::keyPressEvent ");
3871 e->ignore(); 3897 e->ignore();
3872} 3898}
3873 3899
3874 3900
3875bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) 3901bool CalendarView::sync(KSyncManager* manager, QString filename, int mode)
3876{ 3902{
3877 // mSyncManager = manager; 3903 // mSyncManager = manager;
3878 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { 3904 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) {
3879 qDebug("KO: SyncKDE request detected!"); 3905 qDebug("KO: SyncKDE request detected!");
3880 } 3906 }
3881 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 3907 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
3882 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 3908 mCurrentSyncName = mSyncManager->getCurrentSyncName();
3883 return syncCalendar( filename, mode ); 3909 return syncCalendar( filename, mode );
3884} 3910}
3885bool CalendarView::syncExternal(KSyncManager* manager, QString resource) 3911bool CalendarView::syncExternal(KSyncManager* manager, QString resource)
3886{ 3912{
3887 //mSyncManager = manager; 3913 //mSyncManager = manager;
3888 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 3914 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
3889 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 3915 mCurrentSyncName = mSyncManager->getCurrentSyncName();
3890 if ( resource == "sharp" ) 3916 if ( resource == "sharp" )
3891 syncExternal( 0 ); 3917 syncExternal( 0 );
3892 if ( resource == "phone" ) 3918 if ( resource == "phone" )
3893 syncExternal( 1 ); 3919 syncExternal( 1 );
3894 // pending setmodified 3920 // pending setmodified
3895 return true; 3921 return true;
3896} 3922}
3897void CalendarView::setSyncManager(KSyncManager* manager) 3923void CalendarView::setSyncManager(KSyncManager* manager)
3898{ 3924{
3899 mSyncManager = manager; 3925 mSyncManager = manager;
3900} 3926}
3901 3927
3902void CalendarView::removeSyncInfo( QString syncProfile) 3928void CalendarView::removeSyncInfo( QString syncProfile)
3903{ 3929{
3904 qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); 3930 qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1());
3905 mCalendar->removeSyncInfo( syncProfile ); 3931 mCalendar->removeSyncInfo( syncProfile );
3906 3932
3907} 3933}
3908 3934
3909void CalendarView::undo_delete() 3935void CalendarView::undo_delete()
3910{ 3936{
3911 //qDebug("undo_delete() "); 3937 //qDebug("undo_delete() ");
3912 Incidence* undo = mCalendar->undoIncidence(); 3938 Incidence* undo = mCalendar->undoIncidence();
3913 if ( !undo ) { 3939 if ( !undo ) {
3914 KMessageBox::sorry(this,i18n("There is nothing to undo!"), 3940 KMessageBox::sorry(this,i18n("There is nothing to undo!"),
3915 i18n("KO/Pi")); 3941 i18n("KO/Pi"));
3916 return; 3942 return;
3917 } 3943 }
3918 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + 3944 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) +
3919 i18n("\nAre you sure you want\nto restore this?"), 3945 i18n("\nAre you sure you want\nto restore this?"),
3920 i18n("KO/Pi Confirmation"),i18n("Restore"))) { 3946 i18n("KO/Pi Confirmation"),i18n("Restore"))) {
3921 mCalendar->undoDeleteIncidence(); 3947 mCalendar->undoDeleteIncidence();
3922 updateView(); 3948 updateView();
3923 } 3949 }
3924} 3950}
3951
3952void CalendarView::slotViewerClosed()
3953{
3954 QTimer::singleShot( 50, this, SLOT ( resetFocus() ) );
3955}
3956
3957void CalendarView::resetFocus()
3958{
3959 if ( mViewerCallerIsSearchDialog ) {
3960 if ( mDialogManager->getSearchDialog()->isVisible() ){
3961 mDialogManager->getSearchDialog()->raise();
3962 mDialogManager->getSearchDialog()->setActiveWindow();
3963 mDialogManager->getSearchDialog()->listview()->resetFocus();
3964 } else
3965 mViewerCallerIsSearchDialog = false;
3966 }
3967 if ( !mViewerCallerIsSearchDialog ) {
3968 //mViewManager->currentView()->setFocus();
3969 //qDebug("sssssssssssssssset focus ");
3970 setActiveWindow();
3971 //setFocus();
3972 }
3973 mViewerCallerIsSearchDialog = false;
3974}
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index e626ea3..664d700 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -1,612 +1,615 @@
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 showDatePickerPopup() ;
446 void moveIncidence(Incidence *) ; 446 void moveIncidence(Incidence *) ;
447 void beamIncidence(Incidence *) ; 447 void beamIncidence(Incidence *) ;
448 void beamCalendar() ; 448 void beamCalendar() ;
449 void beamFilteredCalendar() ; 449 void beamFilteredCalendar() ;
450 void beamIncidenceList(QPtrList<Incidence>) ; 450 void beamIncidenceList(QPtrList<Incidence>) ;
451 void manageCategories(); 451 void manageCategories();
452 int addCategories(); 452 int addCategories();
453 void removeCategories(); 453 void removeCategories();
454 void setSyncDevice( QString ); 454 void setSyncDevice( QString );
455 void setSyncName( QString ); 455 void setSyncName( QString );
456 void showDay( QDate ); 456 void showDay( QDate );
457 void undo_delete(); 457 void undo_delete();
458 protected slots: 458 protected slots:
459 void resetFocus();
460 void slotViewerClosed();
459 void timerAlarm(); 461 void timerAlarm();
460 void suspendAlarm(); 462 void suspendAlarm();
461 void beamDone( Ir *ir ); 463 void beamDone( Ir *ir );
462 /** Select a view or adapt the current view to display the specified dates. */ 464 /** Select a view or adapt the current view to display the specified dates. */
463 void showDates( const KCal::DateList & ); 465 void showDates( const KCal::DateList & );
464 void selectWeekNum ( int ); 466 void selectWeekNum ( int );
465 467
466 public: 468 public:
467 // show a standard warning 469 // show a standard warning
468 // returns KMsgBox::yesNoCancel() 470 // returns KMsgBox::yesNoCancel()
469 int msgCalModified(); 471 int msgCalModified();
470 virtual bool sync(KSyncManager* manager, QString filename, int mode); 472 virtual bool sync(KSyncManager* manager, QString filename, int mode);
471 473
472 virtual bool syncExternal(KSyncManager* manager, QString resource); 474 virtual bool syncExternal(KSyncManager* manager, QString resource);
473 virtual void removeSyncInfo( QString syncProfile); 475 virtual void removeSyncInfo( QString syncProfile);
474 void setSyncManager(KSyncManager* manager); 476 void setSyncManager(KSyncManager* manager);
475 void setLoadedFileVersion(QDateTime); 477 void setLoadedFileVersion(QDateTime);
476 bool checkFileVersion(QString fn); 478 bool checkFileVersion(QString fn);
477 bool checkFileChanged(QString fn); 479 bool checkFileChanged(QString fn);
478 Event* getLastSyncEvent(); 480 Event* getLastSyncEvent();
479 /** Adapt navigation units correpsonding to step size of navigation of the 481 /** Adapt navigation units correpsonding to step size of navigation of the
480 * current view. 482 * current view.
481 */ 483 */
482 void adaptNavigationUnits(); 484 void adaptNavigationUnits();
483 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); 485 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode );
484 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); 486 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false );
485 //Attendee* getYourAttendee(Event *event); 487 //Attendee* getYourAttendee(Event *event);
486 void setBlockShowDates( bool b ) { mBlockShowDates = b ;} 488 void setBlockShowDates( bool b ) { mBlockShowDates = b ;}
487 protected: 489 protected:
488 void schedule(Scheduler::Method, Incidence *incidence = 0); 490 void schedule(Scheduler::Method, Incidence *incidence = 0);
489 491
490 // returns KMsgBox::OKCandel() 492 // returns KMsgBox::OKCandel()
491 int msgItemDelete(const QString name); 493 int msgItemDelete(const QString name);
492 void showEventEditor(); 494 void showEventEditor();
493 void showTodoEditor(); 495 void showTodoEditor();
494 void writeLocale(); 496 void writeLocale();
495 Todo *selectedTodo(); 497 Todo *selectedTodo();
496 498
497 private: 499 private:
500 bool mViewerCallerIsSearchDialog;
498 bool mBlockShowDates; 501 bool mBlockShowDates;
499 KSyncManager* mSyncManager; 502 KSyncManager* mSyncManager;
500 AlarmDialog * mAlarmDialog; 503 AlarmDialog * mAlarmDialog;
501 QString mAlarmNotification; 504 QString mAlarmNotification;
502 QString mSuspendAlarmNotification; 505 QString mSuspendAlarmNotification;
503 QTimer* mSuspendTimer; 506 QTimer* mSuspendTimer;
504 QTimer* mAlarmTimer; 507 QTimer* mAlarmTimer;
505 QTimer* mRecheckAlarmTimer; 508 QTimer* mRecheckAlarmTimer;
506 void computeAlarm( QString ); 509 void computeAlarm( QString );
507 void startAlarm( QString, QString ); 510 void startAlarm( QString, QString );
508 void setSyncEventsReadOnly(); 511 void setSyncEventsReadOnly();
509 512
510 QDateTime loadedFileVersion; 513 QDateTime loadedFileVersion;
511 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); 514 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete );
512 void checkExternalId( Incidence * inc ); 515 void checkExternalId( Incidence * inc );
513 int mGlobalSyncMode; 516 int mGlobalSyncMode;
514 QString mCurrentSyncDevice; 517 QString mCurrentSyncDevice;
515 QString mCurrentSyncName; 518 QString mCurrentSyncName;
516 KOBeamPrefs* beamDialog; 519 KOBeamPrefs* beamDialog;
517 void init(); 520 void init();
518 int mDatePickerMode; 521 int mDatePickerMode;
519 bool mFlagEditDescription; 522 bool mFlagEditDescription;
520 QDateTime mLastCalendarSync; 523 QDateTime mLastCalendarSync;
521 void createPrinter(); 524 void createPrinter();
522 525
523 void calendarModified( bool, Calendar * ); 526 void calendarModified( bool, Calendar * );
524 527
525 CalPrinter *mCalPrinter; 528 CalPrinter *mCalPrinter;
526 529
527 QSplitter *mPanner; 530 QSplitter *mPanner;
528 QSplitter *mLeftSplitter; 531 QSplitter *mLeftSplitter;
529 QWidget *mLeftFrame; 532 QWidget *mLeftFrame;
530 QWidgetStack *mRightFrame; 533 QWidgetStack *mRightFrame;
531 534
532 KDatePicker* mDatePicker; 535 KDatePicker* mDatePicker;
533 QVBox* mDateFrame; 536 QVBox* mDateFrame;
534 537
535 KDateNavigator *mDateNavigator; // widget showing small month view. 538 KDateNavigator *mDateNavigator; // widget showing small month view.
536 539
537 KOFilterView *mFilterView; 540 KOFilterView *mFilterView;
538 541
539 ResourceView *mResourceView; 542 ResourceView *mResourceView;
540 543
541 // calendar object for this viewing instance 544 // calendar object for this viewing instance
542 Calendar *mCalendar; 545 Calendar *mCalendar;
543 546
544 CalendarResourceManager *mResourceManager; 547 CalendarResourceManager *mResourceManager;
545 548
546 FileStorage *mStorage; 549 FileStorage *mStorage;
547 550
548 DateNavigator *mNavigator; 551 DateNavigator *mNavigator;
549 552
550 KOViewManager *mViewManager; 553 KOViewManager *mViewManager;
551 KODialogManager *mDialogManager; 554 KODialogManager *mDialogManager;
552 555
553 // Calendar filters 556 // Calendar filters
554 QPtrList<CalFilter> mFilters; 557 QPtrList<CalFilter> mFilters;
555 558
556 // various housekeeping variables. 559 // various housekeeping variables.
557 bool mModified; // flag indicating if calendar is modified 560 bool mModified; // flag indicating if calendar is modified
558 bool mReadOnly; // flag indicating if calendar is read-only 561 bool mReadOnly; // flag indicating if calendar is read-only
559 QDate mSaveSingleDate; 562 QDate mSaveSingleDate;
560 563
561 Incidence *mSelectedIncidence; 564 Incidence *mSelectedIncidence;
562 Incidence *mMoveIncidence; 565 Incidence *mMoveIncidence;
563 QDate mMoveIncidenceOldDate; 566 QDate mMoveIncidenceOldDate;
564 KOTodoView *mTodoList; 567 KOTodoView *mTodoList;
565 KOEventEditor * mEventEditor; 568 KOEventEditor * mEventEditor;
566 KOTodoEditor * mTodoEditor; 569 KOTodoEditor * mTodoEditor;
567 KOEventViewerDialog * mEventViewerDialog; 570 KOEventViewerDialog * mEventViewerDialog;
568 void keyPressEvent ( QKeyEvent *e) ; 571 void keyPressEvent ( QKeyEvent *e) ;
569 //QMap<Incidence*,KOIncidenceEditor*> mDialogList; 572 //QMap<Incidence*,KOIncidenceEditor*> mDialogList;
570}; 573};
571 574
572 575
573class CalendarViewVisitor : public Incidence::Visitor 576class CalendarViewVisitor : public Incidence::Visitor
574{ 577{
575 public: 578 public:
576 CalendarViewVisitor() : mView( 0 ) {} 579 CalendarViewVisitor() : mView( 0 ) {}
577 580
578 bool act( Incidence *incidence, CalendarView *view ) 581 bool act( Incidence *incidence, CalendarView *view )
579 { 582 {
580 mView = view; 583 mView = view;
581 return incidence->accept( *this ); 584 return incidence->accept( *this );
582 } 585 }
583 586
584 protected: 587 protected:
585 CalendarView *mView; 588 CalendarView *mView;
586}; 589};
587 590
588class ShowIncidenceVisitor : public CalendarViewVisitor 591class ShowIncidenceVisitor : public CalendarViewVisitor
589{ 592{
590 protected: 593 protected:
591 bool visit( Event *event ) { mView->showEvent( event ); return true; } 594 bool visit( Event *event ) { mView->showEvent( event ); return true; }
592 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } 595 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; }
593 bool visit( Journal * j ) { mView->showJournal( j );return true; } 596 bool visit( Journal * j ) { mView->showJournal( j );return true; }
594}; 597};
595 598
596class EditIncidenceVisitor : public CalendarViewVisitor 599class EditIncidenceVisitor : public CalendarViewVisitor
597{ 600{
598 protected: 601 protected:
599 bool visit( Event *event ) { mView->editEvent( event ); return true; } 602 bool visit( Event *event ) { mView->editEvent( event ); return true; }
600 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } 603 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; }
601 bool visit( Journal *j ) { mView->editJournal( j); return true; } 604 bool visit( Journal *j ) { mView->editJournal( j); return true; }
602}; 605};
603 606
604class DeleteIncidenceVisitor : public CalendarViewVisitor 607class DeleteIncidenceVisitor : public CalendarViewVisitor
605{ 608{
606 protected: 609 protected:
607 bool visit( Event *event ) { mView->deleteEvent( event ); return true; } 610 bool visit( Event *event ) { mView->deleteEvent( event ); return true; }
608 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } 611 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; }
609 bool visit( Journal * j) {mView->deleteJournal( j ); return true; } 612 bool visit( Journal * j) {mView->deleteJournal( j ); return true; }
610}; 613};
611 614
612#endif 615#endif
diff --git a/korganizer/koeventviewer.h b/korganizer/koeventviewer.h
index d8142ca..2d4a08e 100644
--- a/korganizer/koeventviewer.h
+++ b/korganizer/koeventviewer.h
@@ -1,76 +1,76 @@
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#ifndef KOEVENTVIEWER_H 19#ifndef KOEVENTVIEWER_H
20#define KOEVENTVIEWER_H 20#define KOEVENTVIEWER_H
21// 21//
22// Viewer widget for events. 22// Viewer widget for events.
23// 23//
24 24
25#include <qtextbrowser.h> 25#include <qtextbrowser.h>
26 26
27#include <libkcal/event.h> 27#include <libkcal/event.h>
28#include <libkcal/journal.h> 28#include <libkcal/journal.h>
29 29
30 30
31using namespace KCal; 31using namespace KCal;
32 32
33class KOEventViewer : public QTextBrowser { 33class KOEventViewer : public QTextBrowser {
34 Q_OBJECT 34 Q_OBJECT
35 public: 35 public:
36 KOEventViewer(QWidget *parent=0,const char *name=0); 36 KOEventViewer(QWidget *parent=0,const char *name=0);
37 virtual ~KOEventViewer(); 37 virtual ~KOEventViewer();
38 38
39 void setSource(const QString &); 39 void setSource(const QString &);
40 void setEvent(Event *event); 40 void setEvent(Event *event);
41 void addEvent(Event *event); 41 void addEvent(Event *event);
42 void setTodo(Todo *event, bool clearV = true ); 42 void setTodo(Todo *event, bool clearV = true );
43 void setJournal(Journal *jour, bool clearV = true ); 43 void setJournal(Journal *jour, bool clearV = true );
44 44
45 void appendEvent(Event *event, int mode = 0 ); 45 void appendEvent(Event *event, int mode = 0 );
46 void appendTodo(Todo *event, int mode = 0 ); 46 void appendTodo(Todo *event, int mode = 0 );
47 void appendJournal(Journal *jour, int mode = 0 ); 47 void appendJournal(Journal *jour, int mode = 0 );
48 48
49 void clearEvents(bool now=false); 49 void clearEvents(bool now=false);
50 50
51 void addText(QString text); 51 void addText(QString text);
52 void setSyncMode( bool ); 52 void setSyncMode( bool );
53 void setColorMode( int ); 53 void setColorMode( int );
54 void mailToAttendees( bool all ); 54 void mailToAttendees( bool all );
55 55
56 protected: 56 protected:
57 int mColorMode; 57 int mColorMode;
58 void addTag(const QString & tag,const QString & text); 58 void addTag(const QString & tag,const QString & text);
59 59
60 void formatCategories(Incidence *event); 60 void formatCategories(Incidence *event);
61 void formatAttendees(Incidence *event); 61 void formatAttendees(Incidence *event);
62 void formatReadOnly(Incidence *event); 62 void formatReadOnly(Incidence *event);
63 void keyPressEvent ( QKeyEvent * e ); 63 void keyPressEvent ( QKeyEvent * e );
64 64
65 private: 65 private:
66 QTextBrowser *mEventTextView; 66 QTextBrowser *mEventTextView;
67 bool mSyncMode; 67 bool mSyncMode;
68 68
69 QString mText; 69 QString mText;
70 QString mMailSubject; 70 QString mMailSubject;
71 Incidence* mCurrentIncidence; 71 Incidence* mCurrentIncidence;
72 signals: 72 signals:
73 void launchaddressbook(QString uid); 73 void launchaddressbook(QString uid);
74}; 74};
75 75
76#endif 76#endif
diff --git a/korganizer/koeventviewerdialog.cpp b/korganizer/koeventviewerdialog.cpp
index 23e62d3..8bada3b 100644
--- a/korganizer/koeventviewerdialog.cpp
+++ b/korganizer/koeventviewerdialog.cpp
@@ -1,266 +1,283 @@
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 <klocale.h> 20#include <klocale.h>
21 21
22#include <libkcal/event.h> 22#include <libkcal/event.h>
23#include <qtimer.h>
23#include <qpushbutton.h> 24#include <qpushbutton.h>
24 25
25#include "koeventviewer.h" 26#include "koeventviewer.h"
26#include "koprefs.h" 27#include "koprefs.h"
27#include <libkcal/todo.h> 28#include <libkcal/todo.h>
28#include "qapp.h" 29#include "qapp.h"
29 30
30#include "koeventviewerdialog.h" 31#include "koeventviewerdialog.h"
31extern int globalFlagBlockAgenda; 32extern int globalFlagBlockAgenda;
32 33
33KOEventViewerDialog::KOEventViewerDialog(QWidget *parent,const char *name) 34KOEventViewerDialog::KOEventViewerDialog(QWidget *parent,const char *name)
34 : KDialogBase(parent,name, 35 : KDialogBase(parent,name,
35#ifndef DESKTOP_VERSION 36#ifndef DESKTOP_VERSION
36 true , 37 true ,
37#else 38#else
38 false, 39 false,
39#endif 40#endif
40 i18n("Event Viewer"),Ok|User1|Close,Close, false, i18n("Agenda")) 41 i18n("Event Viewer"),Ok|User1|Close,Close, false, i18n("Agenda"))
41{ 42{
42 43 sendSignalViewerClosed = true;
43 mEventViewer = new KOEventViewer(this); 44 mEventViewer = new KOEventViewer(this);
44 mEventViewer->setFont( KOPrefs::instance()->mEventViewFont ); 45 mEventViewer->setFont( KOPrefs::instance()->mEventViewFont );
45 setMainWidget(mEventViewer); 46 setMainWidget(mEventViewer);
46 setButtonText(Ok, i18n("Edit") ); 47 setButtonText(Ok, i18n("Edit") );
47 48
48 QObject::connect(findButton( Ok ),SIGNAL(clicked()), 49 QObject::connect(findButton( Ok ),SIGNAL(clicked()),
49 SLOT(editIncidence())); 50 SLOT(editIncidence()));
50 QObject::connect(this,SIGNAL(user1Clicked()), 51 QObject::connect(this,SIGNAL(user1Clicked()),
51 SLOT(showIncidence())); 52 SLOT(showIncidence()));
52 mIncidence = 0; 53 mIncidence = 0;
53 // TODO: Set a sensible size (based on the content?). 54 // TODO: Set a sensible size (based on the content?).
54 //showMaximized(); 55 //showMaximized();
55 //qDebug("++++++++++++KOEventViewerDialog() "); 56 //qDebug("++++++++++++KOEventViewerDialog() ");
56 // if ( KOPrefs::instance()->mCompactDialogs ) { 57 // if ( KOPrefs::instance()->mCompactDialogs ) {
57// setFixedSize( 240,284 ); 58// setFixedSize( 240,284 );
58// move( 0, 15 ); 59// move( 0, 15 );
59// } else { 60// } else {
60// setMinimumSize(300,200); 61// setMinimumSize(300,200);
61// resize(320,300); 62// resize(320,300);
62// } 63// }
63 mSyncMode = false; 64 mSyncMode = false;
64 mSyncResult = 0; 65 mSyncResult = 0;
65 66
66} 67}
67 68
68KOEventViewerDialog::~KOEventViewerDialog() 69KOEventViewerDialog::~KOEventViewerDialog()
69{ 70{
70 //qDebug("-------~KOEventViewerDialog() "); 71 //qDebug("-------~KOEventViewerDialog() ");
71} 72}
72void KOEventViewerDialog::showMe() 73void KOEventViewerDialog::showMe()
73{ 74{
74 75
75#ifdef DESKTOP_VERSION 76#ifdef DESKTOP_VERSION
76 show(); 77 show();
77#else 78#else
78 showMaximized(); 79 showMaximized();
79#endif 80#endif
80 setActiveWindow(); 81 setActiveWindow();
81 mEventViewer->setFocus(); 82 mEventViewer->setFocus();
82 83
83} 84}
84void KOEventViewerDialog::setSyncMode( bool b ) 85void KOEventViewerDialog::setSyncMode( bool b )
85{ 86{
86 mSyncMode = b; 87 mSyncMode = b;
87 //qDebug("KOEventViewerDialog::setSyncMode %d ",mSyncMode ); 88 //qDebug("KOEventViewerDialog::setSyncMode %d ",mSyncMode );
88 if ( mSyncMode ) { 89 if ( mSyncMode ) {
89 findButton( Close )->setText( i18n("Cancel Sync")); 90 findButton( Close )->setText( i18n("Cancel Sync"));
90 findButton( Ok )->setText( i18n("Remote")); 91 findButton( Ok )->setText( i18n("Remote"));
91 findButton( User1 )->setText( i18n("Local")); 92 findButton( User1 )->setText( i18n("Local"));
92 } else { 93 } else {
93 findButton( Close )->setText( i18n("Close")); 94 findButton( Close )->setText( i18n("Close"));
94 findButton( Ok )->setText( i18n("Edit")); 95 findButton( Ok )->setText( i18n("Edit"));
95 findButton( User1 )->setText( i18n("Agenda")); 96 findButton( User1 )->setText( i18n("Agenda"));
96 } 97 }
97 mEventViewer->setSyncMode( b ); 98 mEventViewer->setSyncMode( b );
98} 99}
99void KOEventViewerDialog::setColorMode( int m ) 100void KOEventViewerDialog::setColorMode( int m )
100{ 101{
101 mEventViewer->setColorMode( m ); 102 mEventViewer->setColorMode( m );
102} 103}
103int KOEventViewerDialog::executeS( bool local ) 104int KOEventViewerDialog::executeS( bool local )
104{ 105{
105 mSyncResult = 3; 106 mSyncResult = 3;
106 if ( local ) 107 if ( local )
107 findButton( User1 )->setFocus(); 108 findButton( User1 )->setFocus();
108 else 109 else
109 findButton( Ok )->setFocus(); 110 findButton( Ok )->setFocus();
110 exec(); 111 exec();
111 return mSyncResult; 112 return mSyncResult;
112} 113}
113 114
114void KOEventViewerDialog::updateConfig() 115void KOEventViewerDialog::updateConfig()
115{ 116{
116 mEventViewer->setFont( KOPrefs::instance()->mEventViewFont ); 117 mEventViewer->setFont( KOPrefs::instance()->mEventViewFont );
117 118
118} 119}
119void KOEventViewerDialog::setEvent(Event *event) 120void KOEventViewerDialog::setEvent(Event *event)
120{ 121{
121 mEventViewer->setEvent(event); 122 mEventViewer->setEvent(event);
122 mIncidence = event; 123 mIncidence = event;
123 mEventViewer->setFocus(); 124 mEventViewer->setFocus();
124 //findButton( Close )->setFocus(); 125 //findButton( Close )->setFocus();
125 if ( !mSyncMode ) { 126 if ( !mSyncMode ) {
126 findButton( User1 )->setText( i18n("Agenda")); 127 findButton( User1 )->setText( i18n("Agenda"));
127 } 128 }
128} 129}
129void KOEventViewerDialog::setIncidence(Incidence *in ) 130void KOEventViewerDialog::setIncidence(Incidence *in )
130{ 131{
131 if ( in->type() == "Event" ) 132 if ( in->type() == "Event" )
132 setEvent( (Event*) in ); 133 setEvent( (Event*) in );
133 else if ( in->type() =="Todo" ) 134 else if ( in->type() =="Todo" )
134 setTodo( (Todo*) in ); 135 setTodo( (Todo*) in );
135 else if ( in->type() =="Journal" ) 136 else if ( in->type() =="Journal" )
136 setJournal( (Journal*) in ); 137 setJournal( (Journal*) in );
137} 138}
138void KOEventViewerDialog::addIncidence(Incidence *in) 139void KOEventViewerDialog::addIncidence(Incidence *in)
139{ 140{
140 if ( in->type() == "Event" ) 141 if ( in->type() == "Event" )
141 addEvent( (Event*) in ); 142 addEvent( (Event*) in );
142 else if ( in->type() =="Todo" ) 143 else if ( in->type() =="Todo" )
143 mEventViewer->setTodo( (Todo*) in, false ); 144 mEventViewer->setTodo( (Todo*) in, false );
144 else if ( in->type() =="Journal" ) 145 else if ( in->type() =="Journal" )
145 mEventViewer->setJournal( (Journal*) in, false ); 146 mEventViewer->setJournal( (Journal*) in, false );
146 if ( mSyncMode ) { 147 if ( mSyncMode ) {
147 findButton( User1 )->setFocus(); 148 findButton( User1 )->setFocus();
148 setCaption(i18n("Conflict! Please choose entry")); 149 setCaption(i18n("Conflict! Please choose entry"));
149 } 150 }
150} 151}
151 152
152void KOEventViewerDialog::addEvent(Event *event) 153void KOEventViewerDialog::addEvent(Event *event)
153{ 154{
154 mEventViewer->addEvent(event); 155 mEventViewer->addEvent(event);
155 mIncidence = event; 156 mIncidence = event;
156 mEventViewer->setFocus(); 157 mEventViewer->setFocus();
157 //findButton( Close )->setFocus(); 158 //findButton( Close )->setFocus();
158 if ( !mSyncMode ) { 159 if ( !mSyncMode ) {
159 findButton( User1 )->setText( i18n("Agenda")); 160 findButton( User1 )->setText( i18n("Agenda"));
160 } 161 }
161} 162}
162 163
163void KOEventViewerDialog::setTodo(Todo *event) 164void KOEventViewerDialog::setTodo(Todo *event)
164{ 165{
165 mEventViewer->setTodo(event); 166 mEventViewer->setTodo(event);
166 mIncidence = (Incidence*)event; 167 mIncidence = (Incidence*)event;
167 mEventViewer->setFocus(); 168 mEventViewer->setFocus();
168 //findButton( Close )->setFocus(); 169 //findButton( Close )->setFocus();
169 if ( !mSyncMode ) { 170 if ( !mSyncMode ) {
170 findButton( User1 )->setText( i18n("Set complete")); 171 findButton( User1 )->setText( i18n("Set complete"));
171 } 172 }
172} 173}
173void KOEventViewerDialog::setJournal(Journal *j) 174void KOEventViewerDialog::setJournal(Journal *j)
174{ 175{
175 mEventViewer->setJournal(j); 176 mEventViewer->setJournal(j);
176 mIncidence = (Incidence*)j; 177 mIncidence = (Incidence*)j;
177 mEventViewer->setFocus(); 178 mEventViewer->setFocus();
178 //findButton( Close )->setFocus(); 179 //findButton( Close )->setFocus();
179 if ( !mSyncMode ) { 180 if ( !mSyncMode ) {
180 findButton( User1 )->setText( i18n("Agenda")); 181 findButton( User1 )->setText( i18n("Agenda"));
181 } 182 }
182} 183}
183 184
184void KOEventViewerDialog::addText(QString text) 185void KOEventViewerDialog::addText(QString text)
185{ 186{
186 mEventViewer->addText(text); 187 mEventViewer->addText(text);
187 mEventViewer->setFocus(); 188 mEventViewer->setFocus();
188 //findButton( Close )->setFocus(); 189 //findButton( Close )->setFocus();
189} 190}
190void KOEventViewerDialog::editIncidence() 191void KOEventViewerDialog::editIncidence()
191{ 192{
193 sendSignalViewerClosed = false;
192 if ( mSyncMode ) { 194 if ( mSyncMode ) {
193 mSyncResult = 2; 195 mSyncResult = 2;
194 accept(); 196 accept();
195 return; 197 return;
196 } 198 }
197 if ( mIncidence ){ 199 if ( mIncidence ){
198#ifndef DESKTOP_VERSION 200#ifndef DESKTOP_VERSION
199 hide(); 201 hide();
200#endif 202#endif
201 emit editIncidence( mIncidence ); 203 emit editIncidence( mIncidence );
202 } 204 }
203} 205}
204void KOEventViewerDialog::showIncidence() 206void KOEventViewerDialog::showIncidence()
205{ 207{
206 208 sendSignalViewerClosed = false;
207 if ( mSyncMode ) { 209 if ( mSyncMode ) {
208 mSyncResult = 1; 210 mSyncResult = 1;
209 accept(); 211 accept();
210 return; 212 return;
211 } 213 }
212 214
213 if ( mIncidence ){ 215 if ( mIncidence ){
214#ifndef DESKTOP_VERSION 216#ifndef DESKTOP_VERSION
215 hide(); 217 hide();
216#endif 218#endif
217 QDate date; 219 QDate date;
218 if ( mIncidence->type() == "Todo" ) { 220 if ( mIncidence->type() == "Todo" ) {
219 /* 221 /*
220 if ( ((Todo*)mIncidence)->hasDueDate() ) 222 if ( ((Todo*)mIncidence)->hasDueDate() )
221 date = ((Todo*)mIncidence)->dtDue().date(); 223 date = ((Todo*)mIncidence)->dtDue().date();
222 else { 224 else {
223 globalFlagBlockAgenda = 2; 225 globalFlagBlockAgenda = 2;
224 emit showAgendaView( false ); 226 emit showAgendaView( false );
225 return; 227 return;
226 } 228 }
227 */ 229 */
228 ((Todo*)mIncidence)->setCompleted( true ); 230 ((Todo*)mIncidence)->setCompleted( true );
229 ((Todo*)mIncidence)->setCompleted(QDateTime::currentDateTime() ); 231 ((Todo*)mIncidence)->setCompleted(QDateTime::currentDateTime() );
230 hide(); 232 hide();
231 emit todoCompleted(((Todo*)mIncidence)); 233 emit todoCompleted(((Todo*)mIncidence));
232 return; 234 return;
233 235
234 } else 236 } else
235 date = mIncidence->dtStart().date(); 237 date = mIncidence->dtStart().date();
236 globalFlagBlockAgenda = 1; 238 globalFlagBlockAgenda = 1;
237 emit showAgendaView( false ); 239 emit showAgendaView( false );
238 globalFlagBlockAgenda = 2; 240 globalFlagBlockAgenda = 2;
239 emit jumpToTime( date ); 241 emit jumpToTime( date );
240 } 242 }
241} 243}
242void KOEventViewerDialog::keyPressEvent ( QKeyEvent * e ) 244void KOEventViewerDialog::keyPressEvent ( QKeyEvent * e )
243{ 245{
244 switch ( e->key() ) { 246 switch ( e->key() ) {
245 247
246 case Qt::Key_A : 248 case Qt::Key_A :
247 case Qt::Key_L : 249 case Qt::Key_L :
248 showIncidence(); 250 showIncidence();
249 break; 251 break;
250 case Qt::Key_E : 252 case Qt::Key_E :
251 case Qt::Key_R : 253 case Qt::Key_R :
252 editIncidence(); 254 editIncidence();
253 break; 255 break;
254 case Qt::Key_C: 256 case Qt::Key_C:
255 case Qt::Key_Escape: 257 case Qt::Key_Escape:
256 close(); 258 close();
257 break; 259 break;
258 case Qt::Key_I: 260 case Qt::Key_I:
259 accept(); 261 accept();
260 break; 262 break;
261 default: 263 default:
262 KDialogBase::keyPressEvent ( e ); 264 KDialogBase::keyPressEvent ( e );
263 break; 265 break;
264 } 266 }
265 267
266} 268}
269void KOEventViewerDialog::hideEvent ( QHideEvent * e )
270{
271 KDialogBase::hideEvent ( e );
272 QTimer::singleShot( 1, this, SLOT (slotViewerClosed() ) );
273}
274
275void KOEventViewerDialog::slotViewerClosed()
276{
277 if ( sendSignalViewerClosed ) {
278 //qDebug("KOEventViewerDialog::hideEvent ");
279 emit signalViewerClosed();
280 }
281 sendSignalViewerClosed = true;
282}
283
diff --git a/korganizer/koeventviewerdialog.h b/korganizer/koeventviewerdialog.h
index b6b4103..36431ad 100644
--- a/korganizer/koeventviewerdialog.h
+++ b/korganizer/koeventviewerdialog.h
@@ -1,71 +1,75 @@
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#ifndef KOEVENTVIEWERDIALOG_H 19#ifndef KOEVENTVIEWERDIALOG_H
20#define KOEVENTVIEWERDIALOG_H 20#define KOEVENTVIEWERDIALOG_H
21// 21//
22// Viewer dialog for events. 22// Viewer dialog for events.
23// 23//
24 24
25#include <qtextview.h> 25#include <qtextview.h>
26 26
27#include <kdialogbase.h> 27#include <kdialogbase.h>
28 28
29#include <libkcal/event.h> 29#include <libkcal/event.h>
30 30
31using namespace KCal; 31using namespace KCal;
32 32
33class KOEventViewer; 33class KOEventViewer;
34 34
35class KOEventViewerDialog : public KDialogBase { 35class KOEventViewerDialog : public KDialogBase {
36 Q_OBJECT 36 Q_OBJECT
37 public: 37 public:
38 KOEventViewerDialog(QWidget *parent=0,const char *name=0); 38 KOEventViewerDialog(QWidget *parent=0,const char *name=0);
39 virtual ~KOEventViewerDialog(); 39 virtual ~KOEventViewerDialog();
40 40
41 void setEvent(Event *event); 41 void setEvent(Event *event);
42 void addEvent(Event *event); 42 void addEvent(Event *event);
43 void setTodo(Todo *event); 43 void setTodo(Todo *event);
44 void setJournal(Journal *journal); 44 void setJournal(Journal *journal);
45 void setIncidence(Incidence *inc); 45 void setIncidence(Incidence *inc);
46 void addIncidence(Incidence *inc); 46 void addIncidence(Incidence *inc);
47 void addText(QString text); 47 void addText(QString text);
48 void showMe(); 48 void showMe();
49 void setSyncMode( bool ); 49 void setSyncMode( bool );
50 void setColorMode( int m ); 50 void setColorMode( int m );
51 int executeS( bool ); 51 int executeS( bool );
52 public slots: 52 public slots:
53 void updateConfig(); 53 void updateConfig();
54 signals: 54 signals:
55 void editIncidence( Incidence* ); 55 void editIncidence( Incidence* );
56 void jumpToTime( const QDate &); 56 void jumpToTime( const QDate &);
57 void showAgendaView( bool ); 57 void showAgendaView( bool );
58 void todoCompleted(Todo*); 58 void todoCompleted(Todo*);
59 void signalViewerClosed();
59private slots: 60private slots:
61 void slotViewerClosed();
60 void editIncidence(); 62 void editIncidence();
61 void showIncidence(); 63 void showIncidence();
62 64 protected:
65 void hideEvent ( QHideEvent * e );
63 private: 66 private:
67 bool sendSignalViewerClosed;
64 bool mSyncMode; 68 bool mSyncMode;
65 int mSyncResult; 69 int mSyncResult;
66 KOEventViewer *mEventViewer; 70 KOEventViewer *mEventViewer;
67 Incidence* mIncidence; 71 Incidence* mIncidence;
68 void keyPressEvent ( QKeyEvent * e ); 72 void keyPressEvent ( QKeyEvent * e );
69}; 73};
70 74
71#endif 75#endif
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp
index 4a6e17d..6acee75 100644
--- a/korganizer/kolistview.cpp
+++ b/korganizer/kolistview.cpp
@@ -1,1186 +1,1190 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 1999 Preston Brown 3 Copyright (c) 1999 Preston Brown
4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2000,2001 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 <qlistview.h> 25#include <qlistview.h>
26#include <qlayout.h> 26#include <qlayout.h>
27#include <qlabel.h> 27#include <qlabel.h>
28#include <qpopupmenu.h> 28#include <qpopupmenu.h>
29#include <qprogressbar.h> 29#include <qprogressbar.h>
30#include <qfileinfo.h> 30#include <qfileinfo.h>
31#include <qmessagebox.h> 31#include <qmessagebox.h>
32#include <qdialog.h> 32#include <qdialog.h>
33#include <qtextstream.h> 33#include <qtextstream.h>
34#include <qdir.h> 34#include <qdir.h>
35#include <qwhatsthis.h> 35#include <qwhatsthis.h>
36#include <qregexp.h> 36#include <qregexp.h>
37 37
38#include <klocale.h> 38#include <klocale.h>
39#include <kdebug.h> 39#include <kdebug.h>
40#include <kiconloader.h> 40#include <kiconloader.h>
41#include <kglobal.h> 41#include <kglobal.h>
42 42
43#include <libkdepim/kpimglobalprefs.h> 43#include <libkdepim/kpimglobalprefs.h>
44#include <libkcal/calendar.h> 44#include <libkcal/calendar.h>
45#include <libkcal/calendarlocal.h> 45#include <libkcal/calendarlocal.h>
46#include <libkcal/icalformat.h> 46#include <libkcal/icalformat.h>
47#include <libkcal/vcalformat.h> 47#include <libkcal/vcalformat.h>
48#include <libkcal/recurrence.h> 48#include <libkcal/recurrence.h>
49#include <libkcal/filestorage.h> 49#include <libkcal/filestorage.h>
50#include <libkdepim/categoryselectdialog.h> 50#include <libkdepim/categoryselectdialog.h>
51#include <libkcal/kincidenceformatter.h> 51#include <libkcal/kincidenceformatter.h>
52#ifndef DESKTOP_VERSION 52#ifndef DESKTOP_VERSION
53#include <qpe/qpeapplication.h> 53#include <qpe/qpeapplication.h>
54#else 54#else
55#include <qapplication.h> 55#include <qapplication.h>
56#endif 56#endif
57 57
58#ifndef KORG_NOPRINTER 58#ifndef KORG_NOPRINTER
59#include "calprinter.h" 59#include "calprinter.h"
60#endif 60#endif
61#include "koglobals.h" 61#include "koglobals.h"
62#include "koprefs.h" 62#include "koprefs.h"
63#include "kfiledialog.h" 63#include "kfiledialog.h"
64 64
65#include "kolistview.h" 65#include "kolistview.h"
66 66
67 67
68 68
69 69
70class KOListViewWhatsThis :public QWhatsThis 70class KOListViewWhatsThis :public QWhatsThis
71{ 71{
72public: 72public:
73 KOListViewWhatsThis( QWidget *wid, KOListView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; 73 KOListViewWhatsThis( QWidget *wid, KOListView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { };
74 74
75protected: 75protected:
76 virtual QString text( const QPoint& p) 76 virtual QString text( const QPoint& p)
77 { 77 {
78 return _view->getWhatsThisText(p) ; 78 return _view->getWhatsThisText(p) ;
79 } 79 }
80private: 80private:
81 QWidget* _wid; 81 QWidget* _wid;
82 KOListView * _view; 82 KOListView * _view;
83}; 83};
84 84
85 85
86ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date ) 86ListItemVisitor::ListItemVisitor(KOListViewItem *item, QDate date )
87{ 87{
88 mItem = item; 88 mItem = item;
89 mDate = date; 89 mDate = date;
90} 90}
91 91
92ListItemVisitor::~ListItemVisitor() 92ListItemVisitor::~ListItemVisitor()
93{ 93{
94} 94}
95 95
96bool ListItemVisitor::visit(Event *e) 96bool ListItemVisitor::visit(Event *e)
97{ 97{
98 98
99 bool ok = false; 99 bool ok = false;
100 QString start, end; 100 QString start, end;
101 QDate ds, de; 101 QDate ds, de;
102 if ( e->doesRecur() ) { 102 if ( e->doesRecur() ) {
103 ds = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date(); 103 ds = e->getNextOccurence( QDateTime( mDate, QTime(0,0,0)), &ok ).date();
104 if ( ok ) { 104 if ( ok ) {
105 int days = e->dtStart().date().daysTo(e->dtEnd().date() ); 105 int days = e->dtStart().date().daysTo(e->dtEnd().date() );
106 start = KGlobal::locale()->formatDate(ds,true); 106 start = KGlobal::locale()->formatDate(ds,true);
107 de = ds.addDays( days); 107 de = ds.addDays( days);
108 end = KGlobal::locale()->formatDate(de,true); 108 end = KGlobal::locale()->formatDate(de,true);
109 } 109 }
110 110
111 } 111 }
112 if ( ! ok ) { 112 if ( ! ok ) {
113 start =e->dtStartDateStr(); 113 start =e->dtStartDateStr();
114 end = e->dtEndDateStr(); 114 end = e->dtEndDateStr();
115 ds = e->dtStart().date(); 115 ds = e->dtStart().date();
116 de = e->dtEnd().date(); 116 de = e->dtEnd().date();
117 } 117 }
118 mItem->setText(0,e->summary()); 118 mItem->setText(0,e->summary());
119 mItem->setText(1,start); 119 mItem->setText(1,start);
120 mItem->setText(2,e->dtStartTimeStr()); 120 mItem->setText(2,e->dtStartTimeStr());
121 mItem->setText(3,end); 121 mItem->setText(3,end);
122 mItem->setText(4,e->dtEndTimeStr()); 122 mItem->setText(4,e->dtEndTimeStr());
123 mItem->setText(5,e->isAlarmEnabled() ? i18n("Yes") : i18n("No")); 123 mItem->setText(5,e->isAlarmEnabled() ? i18n("Yes") : i18n("No"));
124 mItem->setText(6, e->recurrence()->recurrenceText()); 124 mItem->setText(6, e->recurrence()->recurrenceText());
125 mItem->setText(7,"---"); 125 mItem->setText(7,"---");
126 mItem->setText(8,"---"); 126 mItem->setText(8,"---");
127 mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No")); 127 mItem->setText(9, e->cancelled() ? i18n("Yes") : i18n("No"));
128 mItem->setText(10,e->categoriesStr()); 128 mItem->setText(10,e->categoriesStr());
129 129
130 QString key; 130 QString key;
131 QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time(); 131 QTime t = e->doesFloat() ? QTime(0,0) : e->dtStart().time();
132 key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute()); 132 key.sprintf("%04d%02d%02d%02d%02d",ds.year(),ds.month(),ds.day(),t.hour(),t.minute());
133 mItem->setSortKey(1,key); 133 mItem->setSortKey(1,key);
134 134
135 t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time(); 135 t = e->doesFloat() ? QTime(0,0) : e->dtEnd().time();
136 key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute()); 136 key.sprintf("%04d%02d%02d%02d%02d",de.year(),de.month(),de.day(),t.hour(),t.minute());
137 mItem->setSortKey(3,key); 137 mItem->setSortKey(3,key);
138 138
139 return true; 139 return true;
140} 140}
141 141
142bool ListItemVisitor::visit(Todo *t) 142bool ListItemVisitor::visit(Todo *t)
143{ 143{
144 mItem->setText(0,i18n("Todo: %1").arg(t->summary())); 144 mItem->setText(0,i18n("Todo: %1").arg(t->summary()));
145 if (t->hasStartDate()) { 145 if (t->hasStartDate()) {
146 mItem->setText(1,t->dtStartDateStr()); 146 mItem->setText(1,t->dtStartDateStr());
147 if (t->doesFloat()) { 147 if (t->doesFloat()) {
148 mItem->setText(2,"---"); 148 mItem->setText(2,"---");
149 } else { 149 } else {
150 mItem->setText(2,t->dtStartTimeStr()); 150 mItem->setText(2,t->dtStartTimeStr());
151 } 151 }
152 } else { 152 } else {
153 mItem->setText(1,"---"); 153 mItem->setText(1,"---");
154 mItem->setText(2,"---"); 154 mItem->setText(2,"---");
155 } 155 }
156 mItem->setText(3,"---"); 156 mItem->setText(3,"---");
157 mItem->setText(4,"---"); 157 mItem->setText(4,"---");
158 mItem->setText(5,t->isAlarmEnabled() ? i18n("Yes") : i18n("No")); 158 mItem->setText(5,t->isAlarmEnabled() ? i18n("Yes") : i18n("No"));
159 mItem->setText(6, t->recurrence()->recurrenceText()); 159 mItem->setText(6, t->recurrence()->recurrenceText());
160 if (t->hasDueDate()) { 160 if (t->hasDueDate()) {
161 mItem->setText(7,t->dtDueDateStr()); 161 mItem->setText(7,t->dtDueDateStr());
162 if (t->doesFloat()) { 162 if (t->doesFloat()) {
163 mItem->setText(8,"---"); 163 mItem->setText(8,"---");
164 } else { 164 } else {
165 mItem->setText(8,t->dtDueTimeStr()); 165 mItem->setText(8,t->dtDueTimeStr());
166 } 166 }
167 } else { 167 } else {
168 mItem->setText(7,"---"); 168 mItem->setText(7,"---");
169 mItem->setText(8,"---"); 169 mItem->setText(8,"---");
170 } 170 }
171 mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No")); 171 mItem->setText(9, t->cancelled() ? i18n("Yes") : i18n("No"));
172 mItem->setText(10,t->categoriesStr()); 172 mItem->setText(10,t->categoriesStr());
173 173
174 QString key; 174 QString key;
175 QDate d; 175 QDate d;
176 if (t->hasDueDate()) { 176 if (t->hasDueDate()) {
177 d = t->dtDue().date(); 177 d = t->dtDue().date();
178 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time(); 178 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtDue().time();
179 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); 179 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute());
180 mItem->setSortKey(7,key); 180 mItem->setSortKey(7,key);
181 } 181 }
182 if ( t->hasStartDate() ) { 182 if ( t->hasStartDate() ) {
183 d = t->dtStart().date(); 183 d = t->dtStart().date();
184 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time(); 184 QTime tm = t->doesFloat() ? QTime(0,0) : t->dtStart().time();
185 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute()); 185 key.sprintf("%04d%02d%02d%02d%02d",d.year(),d.month(),d.day(),tm.hour(),tm.minute());
186 mItem->setSortKey(1,key); 186 mItem->setSortKey(1,key);
187 } 187 }
188 return true; 188 return true;
189} 189}
190 190
191bool ListItemVisitor::visit(Journal * j) 191bool ListItemVisitor::visit(Journal * j)
192{ 192{
193 QString des = j->description().left(30); 193 QString des = j->description().left(30);
194 des = des.simplifyWhiteSpace (); 194 des = des.simplifyWhiteSpace ();
195 des.replace (QRegExp ("\\n"),"" ); 195 des.replace (QRegExp ("\\n"),"" );
196 des.replace (QRegExp ("\\r"),"" ); 196 des.replace (QRegExp ("\\r"),"" );
197 mItem->setText(0,i18n("Journal: ")+des.left(25)); 197 mItem->setText(0,i18n("Journal: ")+des.left(25));
198 mItem->setText(1,j->dtStartDateStr()); 198 mItem->setText(1,j->dtStartDateStr());
199 mItem->setText(2,"---"); 199 mItem->setText(2,"---");
200 mItem->setText(3,"---"); 200 mItem->setText(3,"---");
201 mItem->setText(4,"---"); 201 mItem->setText(4,"---");
202 mItem->setText(5,"---"); 202 mItem->setText(5,"---");
203 mItem->setText(6,"---"); 203 mItem->setText(6,"---");
204 mItem->setText(7,j->dtStartDateStr()); 204 mItem->setText(7,j->dtStartDateStr());
205 mItem->setText(8,"---"); 205 mItem->setText(8,"---");
206 mItem->setText(9,"---"); 206 mItem->setText(9,"---");
207 mItem->setText(10,i18n("Last Modified: ")+ KGlobal::locale()->formatDateTime( j->lastModified() , true) ); 207 mItem->setText(10,i18n("Last Modified: ")+ KGlobal::locale()->formatDateTime( j->lastModified() , true) );
208 208
209 QString key; 209 QString key;
210 QDate d = j->dtStart().date(); 210 QDate d = j->dtStart().date();
211 key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); 211 key.sprintf("%04d%02d%02d",d.year(),d.month(),d.day());
212 mItem->setSortKey(1,key); 212 mItem->setSortKey(1,key);
213 mItem->setSortKey(7,key); 213 mItem->setSortKey(7,key);
214 214
215 return true; 215 return true;
216} 216}
217 217
218KOListView::KOListView(Calendar *calendar, QWidget *parent, 218KOListView::KOListView(Calendar *calendar, QWidget *parent,
219 const char *name) 219 const char *name)
220 : KOEventView(calendar, parent, name) 220 : KOEventView(calendar, parent, name)
221{ 221{
222 mActiveItem = 0; 222 mActiveItem = 0;
223 mListView = new KOListViewListView(this); 223 mListView = new KOListViewListView(this);
224 mListView->addColumn(i18n("Summary")); 224 mListView->addColumn(i18n("Summary"));
225 mListView->addColumn(i18n("Start Date")); 225 mListView->addColumn(i18n("Start Date"));
226 mListView->addColumn(i18n("Start Time")); 226 mListView->addColumn(i18n("Start Time"));
227 mListView->addColumn(i18n("End Date")); 227 mListView->addColumn(i18n("End Date"));
228 mListView->addColumn(i18n("End Time")); 228 mListView->addColumn(i18n("End Time"));
229 mListView->addColumn(i18n("Alarm")); // alarm set? 229 mListView->addColumn(i18n("Alarm")); // alarm set?
230 mListView->addColumn(i18n("Recurs")); // recurs? 230 mListView->addColumn(i18n("Recurs")); // recurs?
231 mListView->addColumn(i18n("Due Date")); 231 mListView->addColumn(i18n("Due Date"));
232 mListView->addColumn(i18n("Due Time")); 232 mListView->addColumn(i18n("Due Time"));
233 mListView->addColumn(i18n("Cancelled")); 233 mListView->addColumn(i18n("Cancelled"));
234 mListView->addColumn(i18n("Categories")); 234 mListView->addColumn(i18n("Categories"));
235 235
236 mListView->setColumnAlignment(0,AlignLeft); 236 mListView->setColumnAlignment(0,AlignLeft);
237 mListView->setColumnAlignment(1,AlignLeft); 237 mListView->setColumnAlignment(1,AlignLeft);
238 mListView->setColumnAlignment(2,AlignHCenter); 238 mListView->setColumnAlignment(2,AlignHCenter);
239 mListView->setColumnAlignment(3,AlignLeft); 239 mListView->setColumnAlignment(3,AlignLeft);
240 mListView->setColumnAlignment(4,AlignHCenter); 240 mListView->setColumnAlignment(4,AlignHCenter);
241 mListView->setColumnAlignment(5,AlignLeft); 241 mListView->setColumnAlignment(5,AlignLeft);
242 mListView->setColumnAlignment(6,AlignLeft); 242 mListView->setColumnAlignment(6,AlignLeft);
243 mListView->setColumnAlignment(7,AlignLeft); 243 mListView->setColumnAlignment(7,AlignLeft);
244 mListView->setColumnAlignment(8,AlignLeft); 244 mListView->setColumnAlignment(8,AlignLeft);
245 mListView->setColumnAlignment(9,AlignLeft); 245 mListView->setColumnAlignment(9,AlignLeft);
246 mListView->setColumnAlignment(10,AlignLeft); 246 mListView->setColumnAlignment(10,AlignLeft);
247 mListView->setColumnWidthMode(10, QListView::Manual); 247 mListView->setColumnWidthMode(10, QListView::Manual);
248 new KOListViewWhatsThis(mListView->viewport(),this); 248 new KOListViewWhatsThis(mListView->viewport(),this);
249 249
250 int iii = 0; 250 int iii = 0;
251 for ( iii = 0; iii< 10 ; ++iii ) 251 for ( iii = 0; iii< 10 ; ++iii )
252 mListView->setColumnWidthMode( iii, QListView::Manual ); 252 mListView->setColumnWidthMode( iii, QListView::Manual );
253 253
254 QBoxLayout *layoutTop = new QVBoxLayout(this); 254 QBoxLayout *layoutTop = new QVBoxLayout(this);
255 layoutTop->addWidget(mListView); 255 layoutTop->addWidget(mListView);
256 mListView->setFont ( KOPrefs::instance()->mListViewFont ); 256 mListView->setFont ( KOPrefs::instance()->mListViewFont );
257 mPopupMenu = eventPopup(); 257 mPopupMenu = eventPopup();
258 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 258 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
259 i18n("Select all"),this, 259 i18n("Select all"),this,
260 SLOT(allSelection()),true); 260 SLOT(allSelection()),true);
261 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 261 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
262 i18n("Deselect all"),this, 262 i18n("Deselect all"),this,
263 SLOT(clearSelection()),true); 263 SLOT(clearSelection()),true);
264 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 264 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
265 i18n("Delete all selected"),this, 265 i18n("Delete all selected"),this,
266 SLOT(deleteAll()),true); 266 SLOT(deleteAll()),true);
267 mPopupMenu->insertSeparator(); 267 mPopupMenu->insertSeparator();
268 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 268 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
269 i18n("Save selected to file..."),this, 269 i18n("Save selected to file..."),this,
270 SLOT(saveToFile()),true); 270 SLOT(saveToFile()),true);
271 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 271 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
272 i18n("Save Journal/Description..."),this, 272 i18n("Save Journal/Description..."),this,
273 SLOT(saveDescriptionToFile()),true); 273 SLOT(saveDescriptionToFile()),true);
274 // mPopupMenu->insertSeparator(); 274 // mPopupMenu->insertSeparator();
275 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 275 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
276 i18n("Add Categ. to selected..."),this, 276 i18n("Add Categ. to selected..."),this,
277 SLOT(addCat()),true); 277 SLOT(addCat()),true);
278 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 278 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
279 i18n("Set Categ. for selected..."),this, 279 i18n("Set Categ. for selected..."),this,
280 SLOT(setCat()),true); 280 SLOT(setCat()),true);
281 //mPopupMenu->insertSeparator(); 281 //mPopupMenu->insertSeparator();
282 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 282 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
283 i18n("Set alarm for selected..."),this, 283 i18n("Set alarm for selected..."),this,
284 SLOT(setAlarm()),true); 284 SLOT(setAlarm()),true);
285 285
286 286
287#ifndef DESKTOP_VERSION 287#ifndef DESKTOP_VERSION
288 mPopupMenu->insertSeparator(); 288 mPopupMenu->insertSeparator();
289 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()), 289 mPopupMenu->addAdditionalItem(QIconSet(QPixmap()),
290 i18n("Beam selected via IR"),this, 290 i18n("Beam selected via IR"),this,
291 SLOT(beamSelected()),true); 291 SLOT(beamSelected()),true);
292#endif 292#endif
293 /* 293 /*
294 mPopupMenu = new QPopupMenu; 294 mPopupMenu = new QPopupMenu;
295 mPopupMenu->insertItem(i18n("Edit Event"), this, 295 mPopupMenu->insertItem(i18n("Edit Event"), this,
296 SLOT (editEvent())); 296 SLOT (editEvent()));
297 mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this, 297 mPopupMenu->insertItem(SmallIcon("delete"), i18n("Delete Event"), this,
298 SLOT (deleteEvent())); 298 SLOT (deleteEvent()));
299 mPopupMenu->insertSeparator(); 299 mPopupMenu->insertSeparator();
300 mPopupMenu->insertItem(i18n("Show Dates"), this, 300 mPopupMenu->insertItem(i18n("Show Dates"), this,
301 SLOT(showDates())); 301 SLOT(showDates()));
302 mPopupMenu->insertItem(i18n("Hide Dates"), this, 302 mPopupMenu->insertItem(i18n("Hide Dates"), this,
303 SLOT(hideDates())); 303 SLOT(hideDates()));
304 */ 304 */
305 QObject::connect(mListView,SIGNAL( newEvent()), 305 QObject::connect(mListView,SIGNAL( newEvent()),
306 this,SIGNAL(signalNewEvent())); 306 this,SIGNAL(signalNewEvent()));
307 QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)), 307 QObject::connect(mListView,SIGNAL(doubleClicked(QListViewItem *)),
308 this,SLOT(defaultItemAction(QListViewItem *))); 308 this,SLOT(defaultItemAction(QListViewItem *)));
309 QObject::connect(mListView,SIGNAL(rightButtonClicked ( QListViewItem *, 309 QObject::connect(mListView,SIGNAL(rightButtonClicked ( QListViewItem *,
310 const QPoint &, int )), 310 const QPoint &, int )),
311 this,SLOT(popupMenu(QListViewItem *,const QPoint &,int))); 311 this,SLOT(popupMenu(QListViewItem *,const QPoint &,int)));
312 QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)), 312 QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)),
313 SLOT(processSelectionChange(QListViewItem *))); 313 SLOT(processSelectionChange(QListViewItem *)));
314 QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)), 314 QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)),
315 SIGNAL(showIncidenceSignal(Incidence *)) ); 315 SIGNAL(showIncidenceSignal(Incidence *)) );
316 316
317 readSettings(KOGlobals::config(),"KOListView Layout"); 317 readSettings(KOGlobals::config(),"KOListView Layout");
318} 318}
319 319
320KOListView::~KOListView() 320KOListView::~KOListView()
321{ 321{
322 delete mPopupMenu; 322 delete mPopupMenu;
323} 323}
324QString KOListView::getWhatsThisText(QPoint p) 324QString KOListView::getWhatsThisText(QPoint p)
325{ 325{
326 KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p ); 326 KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p );
327 if ( item ) 327 if ( item )
328 return KIncidenceFormatter::instance()->getFormattedText( item->data(), 328 return KIncidenceFormatter::instance()->getFormattedText( item->data(),
329 KOPrefs::instance()->mWTshowDetails, 329 KOPrefs::instance()->mWTshowDetails,
330 KOPrefs::instance()->mWTshowCreated, 330 KOPrefs::instance()->mWTshowCreated,
331 KOPrefs::instance()->mWTshowChanged); 331 KOPrefs::instance()->mWTshowChanged);
332 return i18n("That is the list view" ); 332 return i18n("That is the list view" );
333 333
334} 334}
335 335
336void KOListView::updateList() 336void KOListView::updateList()
337{ 337{
338 // qDebug(" KOListView::updateList() "); 338 // qDebug(" KOListView::updateList() ");
339 339
340} 340}
341 341
342void KOListView::addCat( ) 342void KOListView::addCat( )
343{ 343{
344 setCategories( false ); 344 setCategories( false );
345} 345}
346void KOListView::setCat() 346void KOListView::setCat()
347{ 347{
348 setCategories( true ); 348 setCategories( true );
349} 349}
350void KOListView::setAlarm() 350void KOListView::setAlarm()
351{ 351{
352 KOAlarmPrefs kap( this); 352 KOAlarmPrefs kap( this);
353 if ( !kap.exec() ) 353 if ( !kap.exec() )
354 return; 354 return;
355 355
356 356
357 QStringList itemList; 357 QStringList itemList;
358 QPtrList<KOListViewItem> sel ; 358 QPtrList<KOListViewItem> sel ;
359 QListViewItem *qitem = mListView->firstChild (); 359 QListViewItem *qitem = mListView->firstChild ();
360 while ( qitem ) { 360 while ( qitem ) {
361 if ( qitem->isSelected() ) { 361 if ( qitem->isSelected() ) {
362 Incidence* inc = ((KOListViewItem *) qitem)->data(); 362 Incidence* inc = ((KOListViewItem *) qitem)->data();
363 if ( inc->type() != "Journal" ) { 363 if ( inc->type() != "Journal" ) {
364 if ( inc->type() == "Todo" ) { 364 if ( inc->type() == "Todo" ) {
365 if ( ((Todo*)inc)->hasDueDate() ) 365 if ( ((Todo*)inc)->hasDueDate() )
366 sel.append(((KOListViewItem *)qitem)); 366 sel.append(((KOListViewItem *)qitem));
367 } else 367 } else
368 sel.append(((KOListViewItem *)qitem)); 368 sel.append(((KOListViewItem *)qitem));
369 } 369 }
370 } 370 }
371 qitem = qitem->nextSibling(); 371 qitem = qitem->nextSibling();
372 } 372 }
373 int count = 0; 373 int count = 0;
374 KOListViewItem * item, *temp; 374 KOListViewItem * item, *temp;
375 item = sel.first(); 375 item = sel.first();
376 Incidence* inc; 376 Incidence* inc;
377 while ( item ) { 377 while ( item ) {
378 inc = item->data(); 378 inc = item->data();
379 ++count; 379 ++count;
380 if (kap.mAlarmButton->isChecked()) { 380 if (kap.mAlarmButton->isChecked()) {
381 if (inc->alarms().count() == 0) 381 if (inc->alarms().count() == 0)
382 inc->newAlarm(); 382 inc->newAlarm();
383 QPtrList<Alarm> alarms = inc->alarms(); 383 QPtrList<Alarm> alarms = inc->alarms();
384 Alarm *alarm; 384 Alarm *alarm;
385 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { 385 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) {
386 alarm->setEnabled(true); 386 alarm->setEnabled(true);
387 int j = kap.mAlarmTimeEdit->value()* -60; 387 int j = kap.mAlarmTimeEdit->value()* -60;
388 if (kap.mAlarmIncrCombo->currentItem() == 1) 388 if (kap.mAlarmIncrCombo->currentItem() == 1)
389 j = j * 60; 389 j = j * 60;
390 else if (kap.mAlarmIncrCombo->currentItem() == 2) 390 else if (kap.mAlarmIncrCombo->currentItem() == 2)
391 j = j * (60 * 24); 391 j = j * (60 * 24);
392 alarm->setStartOffset( j ); 392 alarm->setStartOffset( j );
393 393
394 if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) { 394 if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) {
395 alarm->setProcedureAlarm(kap.mAlarmProgram); 395 alarm->setProcedureAlarm(kap.mAlarmProgram);
396 } 396 }
397 else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn()) 397 else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn())
398 alarm->setAudioAlarm(kap.mAlarmSound); 398 alarm->setAudioAlarm(kap.mAlarmSound);
399 else 399 else
400 alarm->setType(Alarm::Invalid); 400 alarm->setType(Alarm::Invalid);
401 //alarm->setAudioAlarm("default"); 401 //alarm->setAudioAlarm("default");
402 // TODO: Deal with multiple alarms 402 // TODO: Deal with multiple alarms
403 break; // For now, stop after the first alarm 403 break; // For now, stop after the first alarm
404 } 404 }
405 } else { 405 } else {
406 Alarm* alarm = inc->alarms().first(); 406 Alarm* alarm = inc->alarms().first();
407 if ( alarm ) { 407 if ( alarm ) {
408 alarm->setEnabled(false); 408 alarm->setEnabled(false);
409 alarm->setType(Alarm::Invalid); 409 alarm->setType(Alarm::Invalid);
410 } 410 }
411 } 411 }
412 temp = item; 412 temp = item;
413 item = sel.next(); 413 item = sel.next();
414 mUidDict.remove( inc->uid() ); 414 mUidDict.remove( inc->uid() );
415 delete temp;; 415 delete temp;;
416 addIncidence( inc ); 416 addIncidence( inc );
417 } 417 }
418 topLevelWidget()->setCaption( i18n("Canged alarm for %1 items").arg( count ) ); 418 topLevelWidget()->setCaption( i18n("Canged alarm for %1 items").arg( count ) );
419 qDebug("KO: Set alarm for %d items", count); 419 qDebug("KO: Set alarm for %d items", count);
420 calendar()->reInitAlarmSettings(); 420 calendar()->reInitAlarmSettings();
421} 421}
422void KOListView::setCategories( bool removeOld ) 422void KOListView::setCategories( bool removeOld )
423{ 423{
424 424
425 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); 425 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 );
426 if (! csd->exec()) { 426 if (! csd->exec()) {
427 delete csd; 427 delete csd;
428 return; 428 return;
429 } 429 }
430 QStringList catList = csd->selectedCategories(); 430 QStringList catList = csd->selectedCategories();
431 delete csd; 431 delete csd;
432 // if ( catList.count() == 0 ) 432 // if ( catList.count() == 0 )
433 // return; 433 // return;
434 catList.sort(); 434 catList.sort();
435 QString categoriesStr = catList.join(","); 435 QString categoriesStr = catList.join(",");
436 int i; 436 int i;
437 QStringList itemList; 437 QStringList itemList;
438 QPtrList<KOListViewItem> sel ; 438 QPtrList<KOListViewItem> sel ;
439 QListViewItem *qitem = mListView->firstChild (); 439 QListViewItem *qitem = mListView->firstChild ();
440 while ( qitem ) { 440 while ( qitem ) {
441 if ( qitem->isSelected() ) { 441 if ( qitem->isSelected() ) {
442 sel.append(((KOListViewItem *)qitem)); 442 sel.append(((KOListViewItem *)qitem));
443 } 443 }
444 qitem = qitem->nextSibling(); 444 qitem = qitem->nextSibling();
445 } 445 }
446 KOListViewItem * item, *temp; 446 KOListViewItem * item, *temp;
447 item = sel.first(); 447 item = sel.first();
448 Incidence* inc; 448 Incidence* inc;
449 while ( item ) { 449 while ( item ) {
450 inc = item->data(); 450 inc = item->data();
451 if ( removeOld ) { 451 if ( removeOld ) {
452 inc->setCategories( categoriesStr ); 452 inc->setCategories( categoriesStr );
453 } else { 453 } else {
454 itemList = QStringList::split (",", inc->categoriesStr() ); 454 itemList = QStringList::split (",", inc->categoriesStr() );
455 for( i = 0; i< catList.count(); ++i ) { 455 for( i = 0; i< catList.count(); ++i ) {
456 if ( !itemList.contains (catList[i])) 456 if ( !itemList.contains (catList[i]))
457 itemList.append( catList[i] ); 457 itemList.append( catList[i] );
458 } 458 }
459 itemList.sort(); 459 itemList.sort();
460 inc->setCategories( itemList.join(",") ); 460 inc->setCategories( itemList.join(",") );
461 } 461 }
462 temp = item; 462 temp = item;
463 item = sel.next(); 463 item = sel.next();
464 mUidDict.remove( inc->uid() ); 464 mUidDict.remove( inc->uid() );
465 delete temp;; 465 delete temp;;
466 addIncidence( inc ); 466 addIncidence( inc );
467 } 467 }
468} 468}
469 469
470void KOListView::beamSelected() 470void KOListView::beamSelected()
471{ 471{
472 int icount = 0; 472 int icount = 0;
473 QPtrList<Incidence> delSel ; 473 QPtrList<Incidence> delSel ;
474 QListViewItem *item = mListView->firstChild (); 474 QListViewItem *item = mListView->firstChild ();
475 while ( item ) { 475 while ( item ) {
476 if ( item->isSelected() ) { 476 if ( item->isSelected() ) {
477 delSel.append(((KOListViewItem *)item)->data()); 477 delSel.append(((KOListViewItem *)item)->data());
478 ++icount; 478 ++icount;
479 } 479 }
480 480
481 item = item->nextSibling(); 481 item = item->nextSibling();
482 } 482 }
483 if ( icount ) { 483 if ( icount ) {
484 emit beamIncidenceList( delSel ); 484 emit beamIncidenceList( delSel );
485 return; 485 return;
486 QString fn ; 486 QString fn ;
487 fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs"; 487 fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs";
488 QString mes; 488 QString mes;
489 bool createbup = true; 489 bool createbup = true;
490 if ( createbup ) { 490 if ( createbup ) {
491 QString description = "\n"; 491 QString description = "\n";
492 CalendarLocal* cal = new CalendarLocal(); 492 CalendarLocal* cal = new CalendarLocal();
493 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 493 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
494 Incidence *incidence = delSel.first(); 494 Incidence *incidence = delSel.first();
495 while ( incidence ) { 495 while ( incidence ) {
496 Incidence *in = incidence->clone(); 496 Incidence *in = incidence->clone();
497 description += in->summary() + "\n"; 497 description += in->summary() + "\n";
498 cal->addIncidence( in ); 498 cal->addIncidence( in );
499 incidence = delSel.next(); 499 incidence = delSel.next();
500 } 500 }
501 FileStorage storage( cal, fn, new VCalFormat ); 501 FileStorage storage( cal, fn, new VCalFormat );
502 storage.save(); 502 storage.save();
503 delete cal; 503 delete cal;
504 mes = i18n("KO/Pi: Ready for beaming"); 504 mes = i18n("KO/Pi: Ready for beaming");
505 topLevelWidget()->setCaption(mes); 505 topLevelWidget()->setCaption(mes);
506 506
507#ifndef DESKTOP_VERSION 507#ifndef DESKTOP_VERSION
508 Ir *ir = new Ir( this ); 508 Ir *ir = new Ir( this );
509 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 509 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
510 ir->send( fn, description, "text/x-vCalendar" ); 510 ir->send( fn, description, "text/x-vCalendar" );
511#endif 511#endif
512 } 512 }
513 } 513 }
514} 514}
515void KOListView::beamDone( Ir *ir ) 515void KOListView::beamDone( Ir *ir )
516{ 516{
517#ifndef DESKTOP_VERSION 517#ifndef DESKTOP_VERSION
518 delete ir; 518 delete ir;
519#endif 519#endif
520 topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done")); 520 topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done"));
521} 521}
522 522
523void KOListView::saveDescriptionToFile() 523void KOListView::saveDescriptionToFile()
524{ 524{
525 525
526 int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), 526 int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"),
527 i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), 527 i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."),
528 i18n("Continue"), i18n("Cancel"), 0, 528 i18n("Continue"), i18n("Cancel"), 0,
529 0, 1 ); 529 0, 1 );
530 if ( result != 0 ) { 530 if ( result != 0 ) {
531 return; 531 return;
532 } 532 }
533 int icount = 0; 533 int icount = 0;
534 QPtrList<Incidence> delSel ; 534 QPtrList<Incidence> delSel ;
535 QListViewItem *item = mListView->firstChild (); 535 QListViewItem *item = mListView->firstChild ();
536 while ( item ) { 536 while ( item ) {
537 if ( item->isSelected() ) { 537 if ( item->isSelected() ) {
538 delSel.append(((KOListViewItem *)item)->data()); 538 delSel.append(((KOListViewItem *)item)->data());
539 ++icount; 539 ++icount;
540 } 540 }
541 541
542 item = item->nextSibling(); 542 item = item->nextSibling();
543 } 543 }
544 if ( icount ) { 544 if ( icount ) {
545 QString fn = KOPrefs::instance()->mLastSaveFile; 545 QString fn = KOPrefs::instance()->mLastSaveFile;
546 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); 546 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this );
547 547
548 if ( fn == "" ) 548 if ( fn == "" )
549 return; 549 return;
550 QFileInfo info; 550 QFileInfo info;
551 info.setFile( fn ); 551 info.setFile( fn );
552 QString mes; 552 QString mes;
553 bool createbup = true; 553 bool createbup = true;
554 if ( info. exists() ) { 554 if ( info. exists() ) {
555 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 555 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
556 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 556 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
557 i18n("Overwrite!"), i18n("Cancel"), 0, 557 i18n("Overwrite!"), i18n("Cancel"), 0,
558 0, 1 ); 558 0, 1 );
559 if ( result != 0 ) { 559 if ( result != 0 ) {
560 createbup = false; 560 createbup = false;
561 } 561 }
562 } 562 }
563 if ( createbup ) { 563 if ( createbup ) {
564 QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") + 564 QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") +
565 KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false); 565 KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false);
566 Incidence *incidence = delSel.first(); 566 Incidence *incidence = delSel.first();
567 icount = 0; 567 icount = 0;
568 while ( incidence ) { 568 while ( incidence ) {
569 if ( incidence->type() == "Journal" ) { 569 if ( incidence->type() == "Journal" ) {
570 text += "\n************************************\n"; 570 text += "\n************************************\n";
571 text += i18n("Journal from: ") +incidence->dtStartDateStr( false ); 571 text += i18n("Journal from: ") +incidence->dtStartDateStr( false );
572 text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); 572 text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false);
573 text +="\n" + i18n("Description: ") + "\n"+ incidence->description(); 573 text +="\n" + i18n("Description: ") + "\n"+ incidence->description();
574 ++icount; 574 ++icount;
575 575
576 } else { 576 } else {
577 if ( !incidence->description().isEmpty() ) { 577 if ( !incidence->description().isEmpty() ) {
578 text += "\n************************************\n"; 578 text += "\n************************************\n";
579 if ( incidence->type() == "Todo" ) 579 if ( incidence->type() == "Todo" )
580 text += i18n("To-Do: "); 580 text += i18n("To-Do: ");
581 text += incidence->summary(); 581 text += incidence->summary();
582 if ( incidence->hasStartDate() ) 582 if ( incidence->hasStartDate() )
583 text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false ); 583 text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false );
584 text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); 584 text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false);
585 if ( !incidence->location().isEmpty() ) 585 if ( !incidence->location().isEmpty() )
586 text += "\n" +i18n("Location: ") + incidence->location(); 586 text += "\n" +i18n("Location: ") + incidence->location();
587 text += "\n" + i18n("Description: ") + "\n" + incidence->description(); 587 text += "\n" + i18n("Description: ") + "\n" + incidence->description();
588 ++icount; 588 ++icount;
589 589
590 } 590 }
591 } 591 }
592 incidence = delSel.next(); 592 incidence = delSel.next();
593 } 593 }
594 QFile file( fn ); 594 QFile file( fn );
595 if (!file.open( IO_WriteOnly ) ) { 595 if (!file.open( IO_WriteOnly ) ) {
596 topLevelWidget()->setCaption(i18n("File open error - nothing saved!") ); 596 topLevelWidget()->setCaption(i18n("File open error - nothing saved!") );
597 return; 597 return;
598 } 598 }
599 QTextStream ts( &file ); 599 QTextStream ts( &file );
600 ts << text; 600 ts << text;
601 file.close(); 601 file.close();
602 //qDebug("%s ", text.latin1()); 602 //qDebug("%s ", text.latin1());
603 mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount ); 603 mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount );
604 KOPrefs::instance()->mLastSaveFile = fn; 604 KOPrefs::instance()->mLastSaveFile = fn;
605 topLevelWidget()->setCaption(mes); 605 topLevelWidget()->setCaption(mes);
606 } 606 }
607 } 607 }
608} 608}
609void KOListView::saveToFile() 609void KOListView::saveToFile()
610{ 610{
611 611
612 int icount = 0; 612 int icount = 0;
613 QPtrList<Incidence> delSel ; 613 QPtrList<Incidence> delSel ;
614 QListViewItem *item = mListView->firstChild (); 614 QListViewItem *item = mListView->firstChild ();
615 while ( item ) { 615 while ( item ) {
616 if ( item->isSelected() ) { 616 if ( item->isSelected() ) {
617 delSel.append(((KOListViewItem *)item)->data()); 617 delSel.append(((KOListViewItem *)item)->data());
618 ++icount; 618 ++icount;
619 } 619 }
620 620
621 item = item->nextSibling(); 621 item = item->nextSibling();
622 } 622 }
623 if ( icount ) { 623 if ( icount ) {
624 QString fn = KOPrefs::instance()->mLastSaveFile; 624 QString fn = KOPrefs::instance()->mLastSaveFile;
625 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); 625 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this );
626 626
627 if ( fn == "" ) 627 if ( fn == "" )
628 return; 628 return;
629 QFileInfo info; 629 QFileInfo info;
630 info.setFile( fn ); 630 info.setFile( fn );
631 QString mes; 631 QString mes;
632 bool createbup = true; 632 bool createbup = true;
633 if ( info. exists() ) { 633 if ( info. exists() ) {
634 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 634 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
635 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 635 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
636 i18n("Overwrite!"), i18n("Cancel"), 0, 636 i18n("Overwrite!"), i18n("Cancel"), 0,
637 0, 1 ); 637 0, 1 );
638 if ( result != 0 ) { 638 if ( result != 0 ) {
639 createbup = false; 639 createbup = false;
640 } 640 }
641 } 641 }
642 if ( createbup ) { 642 if ( createbup ) {
643 CalendarLocal cal; 643 CalendarLocal cal;
644 cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 644 cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
645 Incidence *incidence = delSel.first(); 645 Incidence *incidence = delSel.first();
646 while ( incidence ) { 646 while ( incidence ) {
647 cal.addIncidence( incidence->clone() ); 647 cal.addIncidence( incidence->clone() );
648 incidence = delSel.next(); 648 incidence = delSel.next();
649 } 649 }
650 ICalFormat format; 650 ICalFormat format;
651 format.save( &cal, fn ); 651 format.save( &cal, fn );
652 mes = i18n("KO/Pi:Saved %1").arg(fn ); 652 mes = i18n("KO/Pi:Saved %1").arg(fn );
653 KOPrefs::instance()->mLastSaveFile = fn; 653 KOPrefs::instance()->mLastSaveFile = fn;
654 topLevelWidget()->setCaption(mes); 654 topLevelWidget()->setCaption(mes);
655 } 655 }
656 } 656 }
657} 657}
658void KOListView::deleteAll() 658void KOListView::deleteAll()
659{ 659{
660 int icount = 0; 660 int icount = 0;
661 QPtrList<Incidence> delSel ; 661 QPtrList<Incidence> delSel ;
662 QListViewItem *item = mListView->firstChild (); 662 QListViewItem *item = mListView->firstChild ();
663 while ( item ) { 663 while ( item ) {
664 if ( item->isSelected() ) { 664 if ( item->isSelected() ) {
665 delSel.append(((KOListViewItem *)item)->data()); 665 delSel.append(((KOListViewItem *)item)->data());
666 ++icount; 666 ++icount;
667 } 667 }
668 668
669 item = item->nextSibling(); 669 item = item->nextSibling();
670 } 670 }
671 if ( icount ) { 671 if ( icount ) {
672 Incidence *incidence = delSel.first(); 672 Incidence *incidence = delSel.first();
673 Incidence *toDelete; 673 Incidence *toDelete;
674 KOPrefs *p = KOPrefs::instance(); 674 KOPrefs *p = KOPrefs::instance();
675 bool confirm = p->mConfirm; 675 bool confirm = p->mConfirm;
676 QString mess; 676 QString mess;
677 mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount ); 677 mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount );
678 if ( KMessageBox::Continue == KMessageBox::warningContinueCancel(this, mess + i18n("All selected items will be\npermanently deleted.\n(Deleting items will take\nsome time on a PDA)\n"), i18n("KO/Pi Confirmation"),i18n("Delete")) ) { 678 if ( KMessageBox::Continue == KMessageBox::warningContinueCancel(this, mess + i18n("All selected items will be\npermanently deleted.\n(Deleting items will take\nsome time on a PDA)\n"), i18n("KO/Pi Confirmation"),i18n("Delete")) ) {
679 p->mConfirm = false; 679 p->mConfirm = false;
680 int delCounter = 0; 680 int delCounter = 0;
681 QDialog dia ( this, "p-dialog", true ); 681 QDialog dia ( this, "p-dialog", true );
682 QLabel lab (i18n("Close dialog to abort deletion!"), &dia ); 682 QLabel lab (i18n("Close dialog to abort deletion!"), &dia );
683 QVBoxLayout lay( &dia ); 683 QVBoxLayout lay( &dia );
684 lay.setMargin(7); 684 lay.setMargin(7);
685 lay.setSpacing(7); 685 lay.setSpacing(7);
686 lay.addWidget( &lab); 686 lay.addWidget( &lab);
687 QProgressBar bar( icount, &dia ); 687 QProgressBar bar( icount, &dia );
688 lay.addWidget( &bar); 688 lay.addWidget( &bar);
689 int w = 220; 689 int w = 220;
690 int h = 50; 690 int h = 50;
691 int dw = QApplication::desktop()->width(); 691 int dw = QApplication::desktop()->width();
692 int dh = QApplication::desktop()->height(); 692 int dh = QApplication::desktop()->height();
693 dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 693 dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
694 //dia.resize( 240,50 ); 694 //dia.resize( 240,50 );
695 dia.show(); 695 dia.show();
696 696
697 while ( incidence ) { 697 while ( incidence ) {
698 bar.setProgress( delCounter ); 698 bar.setProgress( delCounter );
699 mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter ); 699 mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter );
700 dia.setCaption( mess ); 700 dia.setCaption( mess );
701 qApp->processEvents(); 701 qApp->processEvents();
702 toDelete = (incidence); 702 toDelete = (incidence);
703 incidence = delSel.next(); 703 incidence = delSel.next();
704 emit deleteIncidenceSignal(toDelete ); 704 emit deleteIncidenceSignal(toDelete );
705 if ( dia.result() != 0 ) 705 if ( dia.result() != 0 )
706 break; 706 break;
707 707
708 } 708 }
709 mess = mess.sprintf( i18n("%d items remaining in list."), count() ); 709 mess = mess.sprintf( i18n("%d items remaining in list."), count() );
710 topLevelWidget ()->setCaption( mess ); 710 topLevelWidget ()->setCaption( mess );
711 p->mConfirm = confirm; 711 p->mConfirm = confirm;
712 } 712 }
713 } 713 }
714 714
715 715
716} 716}
717int KOListView::maxDatesHint() 717int KOListView::maxDatesHint()
718{ 718{
719 return 0; 719 return 0;
720} 720}
721 721
722int KOListView::currentDateCount() 722int KOListView::currentDateCount()
723{ 723{
724 return 0; 724 return 0;
725} 725}
726 726
727QPtrList<Incidence> KOListView::selectedIncidences() 727QPtrList<Incidence> KOListView::selectedIncidences()
728{ 728{
729 QPtrList<Incidence> eventList; 729 QPtrList<Incidence> eventList;
730 QListViewItem *item = mListView->firstChild (); 730 QListViewItem *item = mListView->firstChild ();
731 while ( item ) { 731 while ( item ) {
732 if ( item->isSelected() ) { 732 if ( item->isSelected() ) {
733 eventList.append(((KOListViewItem *)item)->data()); 733 eventList.append(((KOListViewItem *)item)->data());
734 } 734 }
735 735
736 item = item->nextSibling(); 736 item = item->nextSibling();
737 } 737 }
738 738
739 // // QListViewItem *item = mListView->selectedItem(); 739 // // QListViewItem *item = mListView->selectedItem();
740 //if (item) eventList.append(((KOListViewItem *)item)->data()); 740 //if (item) eventList.append(((KOListViewItem *)item)->data());
741 741
742 return eventList; 742 return eventList;
743} 743}
744 744
745DateList KOListView::selectedDates() 745DateList KOListView::selectedDates()
746{ 746{
747 DateList eventList; 747 DateList eventList;
748 return eventList; 748 return eventList;
749} 749}
750 750
751void KOListView::showDates(bool show) 751void KOListView::showDates(bool show)
752{ 752{
753 // Shouldn't we set it to a value greater 0? When showDates is called with 753 // Shouldn't we set it to a value greater 0? When showDates is called with
754 // show == true at first, then the columnwidths are set to zero. 754 // show == true at first, then the columnwidths are set to zero.
755 static int oldColWidth1 = 0; 755 static int oldColWidth1 = 0;
756 static int oldColWidth3 = 0; 756 static int oldColWidth3 = 0;
757 757
758 if (!show) { 758 if (!show) {
759 oldColWidth1 = mListView->columnWidth(1); 759 oldColWidth1 = mListView->columnWidth(1);
760 oldColWidth3 = mListView->columnWidth(3); 760 oldColWidth3 = mListView->columnWidth(3);
761 mListView->setColumnWidth(1, 0); 761 mListView->setColumnWidth(1, 0);
762 mListView->setColumnWidth(3, 0); 762 mListView->setColumnWidth(3, 0);
763 } else { 763 } else {
764 mListView->setColumnWidth(1, oldColWidth1); 764 mListView->setColumnWidth(1, oldColWidth1);
765 mListView->setColumnWidth(3, oldColWidth3); 765 mListView->setColumnWidth(3, oldColWidth3);
766 } 766 }
767 mListView->repaint(); 767 mListView->repaint();
768} 768}
769 769
770void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd, 770void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd,
771 const QDate &td) 771 const QDate &td)
772{ 772{
773#ifndef KORG_NOPRINTER 773#ifndef KORG_NOPRINTER
774 calPrinter->preview(CalPrinter::Day, fd, td); 774 calPrinter->preview(CalPrinter::Day, fd, td);
775#endif 775#endif
776} 776}
777 777
778void KOListView::showDates() 778void KOListView::showDates()
779{ 779{
780 showDates(true); 780 showDates(true);
781} 781}
782 782
783void KOListView::hideDates() 783void KOListView::hideDates()
784{ 784{
785 showDates(false); 785 showDates(false);
786} 786}
787 787void KOListView::resetFocus()
788{
789 mListView->setFocus();
790}
788void KOListView::updateView() 791void KOListView::updateView()
789{ 792{
790 mListView->setFocus(); 793 mListView->setFocus();
791 if ( mListView->firstChild () ) 794 if ( mListView->firstChild () )
792 mListView->setCurrentItem( mListView->firstChild () ); 795 mListView->setCurrentItem( mListView->firstChild () );
793} 796}
794void KOListView::updateConfig() 797void KOListView::updateConfig()
795{ 798{
796 799
797 mListView->setFont ( KOPrefs::instance()->mListViewFont ); 800 mListView->setFont ( KOPrefs::instance()->mListViewFont );
798 updateView(); 801 updateView();
799 802
800} 803}
801void KOListView::setStartDate(const QDate &start) 804void KOListView::setStartDate(const QDate &start)
802{ 805{
803 mStartDate = start; 806 mStartDate = start;
804} 807}
805 808
806void KOListView::showDates(const QDate &start, const QDate &end) 809void KOListView::showDates(const QDate &start, const QDate &end)
807{ 810{
808 clear(); 811 clear();
809 mStartDate = start; 812 mStartDate = start;
810 QDate date = start; 813 QDate date = start;
811 QPtrList<Journal> j_list; 814 QPtrList<Journal> j_list;
812 while( date <= end ) { 815 while( date <= end ) {
813 addEvents(calendar()->events(date)); 816 addEvents(calendar()->events(date));
814 addTodos(calendar()->todos(date)); 817 addTodos(calendar()->todos(date));
815 Journal* jo = calendar()->journal(date); 818 Journal* jo = calendar()->journal(date);
816 if ( jo ) 819 if ( jo )
817 j_list.append( jo ); 820 j_list.append( jo );
818 date = date.addDays( 1 ); 821 date = date.addDays( 1 );
819 } 822 }
820 addJournals(j_list); 823 addJournals(j_list);
821 emit incidenceSelected( 0 ); 824 emit incidenceSelected( 0 );
822 updateView(); 825 updateView();
823 826
824} 827}
825 828
826void KOListView::addEvents(QPtrList<Event> eventList) 829void KOListView::addEvents(QPtrList<Event> eventList)
827{ 830{
828 Event *ev; 831 Event *ev;
829 for(ev = eventList.first(); ev; ev = eventList.next()) { 832 for(ev = eventList.first(); ev; ev = eventList.next()) {
830 addIncidence(ev); 833 addIncidence(ev);
831 } 834 }
832 if ( !mListView->currentItem() ){ 835 if ( !mListView->currentItem() ){
833 updateView(); 836 updateView();
834 } 837 }
835} 838}
836 839
837void KOListView::addTodos(QPtrList<Todo> eventList) 840void KOListView::addTodos(QPtrList<Todo> eventList)
838{ 841{
839 Todo *ev; 842 Todo *ev;
840 for(ev = eventList.first(); ev; ev = eventList.next()) { 843 for(ev = eventList.first(); ev; ev = eventList.next()) {
841 addIncidence(ev); 844 addIncidence(ev);
842 } 845 }
843 if ( !mListView->currentItem() ){ 846 if ( !mListView->currentItem() ){
844 updateView(); 847 updateView();
845 } 848 }
846} 849}
847void KOListView::addJournals(QPtrList<Journal> eventList) 850void KOListView::addJournals(QPtrList<Journal> eventList)
848{ 851{
849 Journal *ev; 852 Journal *ev;
850 for(ev = eventList.first(); ev; ev = eventList.next()) { 853 for(ev = eventList.first(); ev; ev = eventList.next()) {
851 addIncidence(ev); 854 addIncidence(ev);
852 } 855 }
853 if ( !mListView->currentItem() ){ 856 if ( !mListView->currentItem() ){
854 updateView(); 857 updateView();
855 } 858 }
856} 859}
857 860
858void KOListView::addIncidence(Incidence *incidence) 861void KOListView::addIncidence(Incidence *incidence)
859{ 862{
860 if ( mUidDict.find( incidence->uid() ) ) return; 863 if ( mUidDict.find( incidence->uid() ) ) return;
861 864
862 // mListView->setFont ( KOPrefs::instance()->mListViewFont ); 865 // mListView->setFont ( KOPrefs::instance()->mListViewFont );
863 mUidDict.insert( incidence->uid(), incidence ); 866 mUidDict.insert( incidence->uid(), incidence );
864 867
865 KOListViewItem *item = new KOListViewItem( incidence, mListView ); 868 KOListViewItem *item = new KOListViewItem( incidence, mListView );
866 ListItemVisitor v(item, mStartDate ); 869 ListItemVisitor v(item, mStartDate );
867 if (incidence->accept(v)) return; 870 if (incidence->accept(v)) return;
868 else delete item; 871 else delete item;
869 //qDebug("delete item "); 872 //qDebug("delete item ");
870} 873}
871 874
872void KOListView::showEvents(QPtrList<Event> eventList) 875void KOListView::showEvents(QPtrList<Event> eventList)
873{ 876{
874 clear(); 877 clear();
875 878
876 addEvents(eventList); 879 addEvents(eventList);
877 880
878 // After new creation of list view no events are selected. 881 // After new creation of list view no events are selected.
879 emit incidenceSelected( 0 ); 882 emit incidenceSelected( 0 );
880} 883}
881int KOListView::count() 884int KOListView::count()
882{ 885{
883 return mListView->childCount(); 886 return mListView->childCount();
884} 887}
885 888
886void KOListView::changeEventDisplay(Event *event, int action) 889void KOListView::changeEventDisplay(Event *event, int action)
887{ 890{
888 KOListViewItem *item; 891 KOListViewItem *item;
889 892
890 switch(action) { 893 switch(action) {
891 case KOGlobals::EVENTADDED: 894 case KOGlobals::EVENTADDED:
892 addIncidence( event ); 895 addIncidence( event );
893 break; 896 break;
894 case KOGlobals::EVENTEDITED: 897 case KOGlobals::EVENTEDITED:
895 item = getItemForEvent(event); 898 item = getItemForEvent(event);
896 if (item) { 899 if (item) {
897 mUidDict.remove( event->uid() ); 900 mUidDict.remove( event->uid() );
898 delete item; 901 delete item;
899 addIncidence( event ); 902 addIncidence( event );
900 } 903 }
901 break; 904 break;
902 case KOGlobals::EVENTDELETED: 905 case KOGlobals::EVENTDELETED:
903 item = getItemForEvent(event); 906 item = getItemForEvent(event);
904 if (item) { 907 if (item) {
905 mUidDict.remove( event->uid() ); 908 mUidDict.remove( event->uid() );
906 delete item; 909 delete item;
907 } 910 }
908 break; 911 break;
909 default: 912 default:
910 ; 913 ;
911 } 914 }
912} 915}
913 916
914KOListViewItem *KOListView::getItemForEvent(Event *event) 917KOListViewItem *KOListView::getItemForEvent(Event *event)
915{ 918{
916 KOListViewItem *item = (KOListViewItem *)mListView->firstChild(); 919 KOListViewItem *item = (KOListViewItem *)mListView->firstChild();
917 while (item) { 920 while (item) {
918 if (item->data() == event) return item; 921 if (item->data() == event) return item;
919 item = (KOListViewItem *)item->nextSibling(); 922 item = (KOListViewItem *)item->nextSibling();
920 } 923 }
921 return 0; 924 return 0;
922} 925}
923 926
924void KOListView::defaultItemAction(QListViewItem *i) 927void KOListView::defaultItemAction(QListViewItem *i)
925{ 928{
926 KOListViewItem *item = static_cast<KOListViewItem *>( i ); 929 KOListViewItem *item = static_cast<KOListViewItem *>( i );
927 if ( item ) defaultAction( item->data() ); 930 if ( item ) defaultAction( item->data() );
928 931
929} 932}
930 933
931void KOListView::popupMenu(QListViewItem *item,const QPoint &,int) 934void KOListView::popupMenu(QListViewItem *item,const QPoint &,int)
932{ 935{
933 mActiveItem = (KOListViewItem *)item; 936 mActiveItem = (KOListViewItem *)item;
934 if (mActiveItem) { 937 if (mActiveItem) {
935 Incidence *incidence = mActiveItem->data(); 938 Incidence *incidence = mActiveItem->data();
936 mPopupMenu->showIncidencePopup(incidence); 939 mPopupMenu->showIncidencePopup(incidence);
937 940
938 /* 941 /*
939 if ( incidence && incidence->type() == "Event" ) { 942 if ( incidence && incidence->type() == "Event" ) {
940 Event *event = static_cast<Event *>( incidence ); 943 Event *event = static_cast<Event *>( incidence );
941 mPopupMenu->showEventPopup(event); 944 mPopupMenu->showEventPopup(event);
942 } 945 }
943 */ 946 */
944 } 947 }
945} 948}
946 949
947void KOListView::readSettings(KConfig *config, QString setting) 950void KOListView::readSettings(KConfig *config, QString setting)
948{ 951{
949 // qDebug("KOListView::readSettings "); 952 // qDebug("KOListView::readSettings ");
950 mListView->restoreLayout(config,setting); 953 mListView->restoreLayout(config,setting);
951} 954}
952 955
953void KOListView::writeSettings(KConfig *config, QString setting) 956void KOListView::writeSettings(KConfig *config, QString setting)
954{ 957{
955 // qDebug("KOListView::writeSettings "); 958 // qDebug("KOListView::writeSettings ");
956 mListView->saveLayout(config, setting); 959 mListView->saveLayout(config, setting);
957} 960}
958 961
959void KOListView::processSelectionChange(QListViewItem *) 962void KOListView::processSelectionChange(QListViewItem *)
960{ 963{
961 964
962 KOListViewItem *item = 965 KOListViewItem *item =
963 static_cast<KOListViewItem *>( mListView->currentItem() ); 966 static_cast<KOListViewItem *>( mListView->currentItem() );
964 967
965 if ( !item ) { 968 if ( !item ) {
966 emit incidenceSelected( 0 ); 969 emit incidenceSelected( 0 );
967 } else { 970 } else {
968 emit incidenceSelected( item->data() ); 971 emit incidenceSelected( item->data() );
969 } 972 }
970} 973}
971 974
972void KOListView::clearSelection() 975void KOListView::clearSelection()
973{ 976{
974 mListView->selectAll( false ); 977 mListView->selectAll( false );
975} 978}
976void KOListView::allSelection() 979void KOListView::allSelection()
977{ 980{
978 mListView->selectAll( true ); 981 mListView->selectAll( true );
979} 982}
980 983
981void KOListView::clear() 984void KOListView::clear()
982{ 985{
983 mListView->clear(); 986 mListView->clear();
984 mUidDict.clear(); 987 mUidDict.clear();
985} 988}
986 989
987Incidence* KOListView::currentItem() 990Incidence* KOListView::currentItem()
988{ 991{
989 if ( mListView->currentItem() ) 992 if ( mListView->currentItem() )
990 return ((KOListViewItem*) mListView->currentItem())->data(); 993 return ((KOListViewItem*) mListView->currentItem())->data();
991 return 0; 994 return 0;
992} 995}
993void KOListView::keyPressEvent ( QKeyEvent *e) 996void KOListView::keyPressEvent ( QKeyEvent *e)
994{ 997{
995 998
996 if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) { 999 if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) {
997 deleteAll(); 1000 deleteAll();
998 return; 1001 return;
999 } 1002 }
1000 1003
1001 e->ignore(); 1004 e->ignore();
1002} 1005}
1003void KOListViewListView::keyPressEvent ( QKeyEvent *e) 1006void KOListViewListView::keyPressEvent ( QKeyEvent *e)
1004{ 1007{
1005 1008
1006 switch ( e->key() ) { 1009 switch ( e->key() ) {
1007 case Qt::Key_Down: 1010 case Qt::Key_Down:
1008 if ( e->state() == ShiftButton ) { 1011 if ( e->state() == ShiftButton ) {
1009 QListViewItem* cn = currentItem(); 1012 QListViewItem* cn = currentItem();
1010 if ( !cn ) 1013 if ( !cn )
1011 cn = firstChild(); 1014 cn = firstChild();
1012 if ( !cn ) 1015 if ( !cn )
1013 return; 1016 return;
1014 while ( cn->nextSibling() ) 1017 while ( cn->nextSibling() )
1015 cn = cn->nextSibling(); 1018 cn = cn->nextSibling();
1016 setCurrentItem ( cn ); 1019 setCurrentItem ( cn );
1017 ensureItemVisible ( cn ); 1020 ensureItemVisible ( cn );
1018 1021
1019 e->accept(); 1022 e->accept();
1020 return; 1023 return;
1021 } 1024 }
1022 if ( e->state() == ControlButton ) { 1025 if ( e->state() == ControlButton ) {
1023 int count = childCount (); 1026 int count = childCount ();
1024 int jump = count / 5; 1027 int jump = count / 5;
1025 QListViewItem* cn; 1028 QListViewItem* cn;
1026 cn = currentItem(); 1029 cn = currentItem();
1027 if ( ! cn ) 1030 if ( ! cn )
1028 return; 1031 return;
1029 if ( jump == 0 ) 1032 if ( jump == 0 )
1030 jump = 1; 1033 jump = 1;
1031 while ( jump && cn->nextSibling() ) { 1034 while ( jump && cn->nextSibling() ) {
1032 cn = cn->nextSibling(); 1035 cn = cn->nextSibling();
1033 --jump; 1036 --jump;
1034 } 1037 }
1035 setCurrentItem ( cn ); 1038 setCurrentItem ( cn );
1036 ensureItemVisible ( cn ); 1039 ensureItemVisible ( cn );
1037 1040
1038 } else 1041 } else
1039 QListView::keyPressEvent ( e ) ; 1042 QListView::keyPressEvent ( e ) ;
1040 e->accept(); 1043 e->accept();
1041 break; 1044 break;
1042 1045
1043 case Qt::Key_Up: 1046 case Qt::Key_Up:
1044 if ( e->state() == ShiftButton ) { 1047 if ( e->state() == ShiftButton ) {
1045 QListViewItem* cn = firstChild(); 1048 QListViewItem* cn = firstChild();
1046 if ( cn ) { 1049 if ( cn ) {
1047 setCurrentItem ( cn ); 1050 setCurrentItem ( cn );
1048 ensureItemVisible ( cn ); 1051 ensureItemVisible ( cn );
1049 } 1052 }
1050 e->accept(); 1053 e->accept();
1051 return; 1054 return;
1052 } 1055 }
1053 if ( e->state() == ControlButton ) { 1056 if ( e->state() == ControlButton ) {
1054 int count = childCount (); 1057 int count = childCount ();
1055 int jump = count / 5; 1058 int jump = count / 5;
1056 QListViewItem* cn; 1059 QListViewItem* cn;
1057 cn = currentItem(); 1060 cn = currentItem();
1058 if ( ! cn ) 1061 if ( ! cn )
1059 return; 1062 return;
1060 if ( jump == 0 ) 1063 if ( jump == 0 )
1061 jump = 1; 1064 jump = 1;
1062 while ( jump && cn->itemAbove ()) { 1065 while ( jump && cn->itemAbove ()) {
1063 cn = cn->itemAbove (); 1066 cn = cn->itemAbove ();
1064 --jump; 1067 --jump;
1065 } 1068 }
1066 setCurrentItem ( cn ); 1069 setCurrentItem ( cn );
1067 ensureItemVisible ( cn ); 1070 ensureItemVisible ( cn );
1068 } else 1071 } else
1069 QListView::keyPressEvent ( e ) ; 1072 QListView::keyPressEvent ( e ) ;
1070 e->accept(); 1073 e->accept();
1071 break; 1074 break;
1072 case Qt::Key_I: { 1075 case Qt::Key_I: {
1073 QListViewItem* cn; 1076 QListViewItem* cn;
1074 cn = currentItem(); 1077 cn = currentItem();
1075 if ( cn ) { 1078 if ( cn ) {
1076 KOListViewItem* ci = (KOListViewItem*)( cn ); 1079 KOListViewItem* ci = (KOListViewItem*)( cn );
1077 if ( ci ){ 1080 if ( ci ){
1078 emit showIncidence( ci->data()); 1081 //emit showIncidence( ci->data());
1079 cn = cn->nextSibling(); 1082 cn = cn->nextSibling();
1080 if ( cn ) { 1083 if ( cn ) {
1081 setCurrentItem ( cn ); 1084 setCurrentItem ( cn );
1082 ensureItemVisible ( cn ); 1085 ensureItemVisible ( cn );
1086 emit showIncidence( ci->data());
1083 } 1087 }
1084 } 1088 }
1085 } 1089 }
1086 e->accept(); 1090 e->accept();
1087 } 1091 }
1088 break; 1092 break;
1089 case Qt::Key_Return: 1093 case Qt::Key_Return:
1090 case Qt::Key_Enter: 1094 case Qt::Key_Enter:
1091 { 1095 {
1092 QListViewItem* cn; 1096 QListViewItem* cn;
1093 cn = currentItem(); 1097 cn = currentItem();
1094 if ( cn ) { 1098 if ( cn ) {
1095 KOListViewItem* ci = (KOListViewItem*)( cn ); 1099 KOListViewItem* ci = (KOListViewItem*)( cn );
1096 if ( ci ){ 1100 if ( ci ){
1097 if ( e->state() == ShiftButton ) 1101 if ( e->state() == ShiftButton )
1098 ci->setSelected( false ); 1102 ci->setSelected( false );
1099 else 1103 else
1100 ci->setSelected( true ); 1104 ci->setSelected( true );
1101 cn = cn->nextSibling(); 1105 cn = cn->nextSibling();
1102 if ( cn ) { 1106 if ( cn ) {
1103 setCurrentItem ( cn ); 1107 setCurrentItem ( cn );
1104 ensureItemVisible ( cn ); 1108 ensureItemVisible ( cn );
1105 } 1109 }
1106 } 1110 }
1107 } 1111 }
1108 e->accept(); 1112 e->accept();
1109 } 1113 }
1110 break; 1114 break;
1111 default: 1115 default:
1112 e->ignore(); 1116 e->ignore();
1113 } 1117 }
1114} 1118}
1115KOListViewListView::KOListViewListView(KOListView * lv ) 1119KOListViewListView::KOListViewListView(KOListView * lv )
1116 : KListView( lv ) 1120 : KListView( lv )
1117{ 1121{
1118#ifndef DESKTOP_VERSION 1122#ifndef DESKTOP_VERSION
1119 QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); 1123 QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold );
1120#endif 1124#endif
1121 mYMousePos = -1000; 1125 mYMousePos = -1000;
1122 setSelectionMode( QListView::Multi ); 1126 setSelectionMode( QListView::Multi );
1123 setMultiSelection( true); 1127 setMultiSelection( true);
1124 mAllowPopupMenu = true; 1128 mAllowPopupMenu = true;
1125 mMouseDown = false; 1129 mMouseDown = false;
1126 1130
1127} 1131}
1128void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e) 1132void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e)
1129{ 1133{
1130 if (!e) return; 1134 if (!e) return;
1131 QPoint vp = contentsToViewport(e->pos()); 1135 QPoint vp = contentsToViewport(e->pos());
1132 QListViewItem *item = itemAt(vp); 1136 QListViewItem *item = itemAt(vp);
1133 if (!item) { 1137 if (!item) {
1134 emit newEvent(); 1138 emit newEvent();
1135 return; 1139 return;
1136 } 1140 }
1137 KListView::contentsMouseDoubleClickEvent(e); 1141 KListView::contentsMouseDoubleClickEvent(e);
1138} 1142}
1139 1143
1140 1144
1141void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) 1145void KOListViewListView::contentsMousePressEvent(QMouseEvent *e)
1142{ 1146{
1143 //qDebug("contentsMousePressEvent++++ "); 1147 //qDebug("contentsMousePressEvent++++ ");
1144 if (! mMouseDown ) { 1148 if (! mMouseDown ) {
1145 mAllowPopupMenu = true; 1149 mAllowPopupMenu = true;
1146 mYMousePos = mapToGlobal( (e->pos())).y(); 1150 mYMousePos = mapToGlobal( (e->pos())).y();
1147 } 1151 }
1148 if ( e->button() == RightButton && mMouseDown ) 1152 if ( e->button() == RightButton && mMouseDown )
1149 return; 1153 return;
1150 if ( e->button() == LeftButton ) 1154 if ( e->button() == LeftButton )
1151 mMouseDown = true; 1155 mMouseDown = true;
1152 KListView::contentsMousePressEvent( e ); 1156 KListView::contentsMousePressEvent( e );
1153} 1157}
1154void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) 1158void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e)
1155{ 1159{
1156 //qDebug("contentsMouseReleaseEv---- "); 1160 //qDebug("contentsMouseReleaseEv---- ");
1157 if ( ! mMouseDown ) { 1161 if ( ! mMouseDown ) {
1158 if ( e->button() == RightButton && ! mAllowPopupMenu ) 1162 if ( e->button() == RightButton && ! mAllowPopupMenu )
1159 return; 1163 return;
1160 QListViewItem* ci = currentItem(); 1164 QListViewItem* ci = currentItem();
1161 if ( ci ) 1165 if ( ci )
1162 ci->setSelected( true ); 1166 ci->setSelected( true );
1163 KListView::contentsMouseReleaseEvent(e); 1167 KListView::contentsMouseReleaseEvent(e);
1164 return; 1168 return;
1165 } 1169 }
1166 if ( e->button() == LeftButton ) 1170 if ( e->button() == LeftButton )
1167 mMouseDown = false; 1171 mMouseDown = false;
1168 if ( e->button() == RightButton && ! mAllowPopupMenu ) 1172 if ( e->button() == RightButton && ! mAllowPopupMenu )
1169 return; 1173 return;
1170 if ( e->button() == RightButton ) { 1174 if ( e->button() == RightButton ) {
1171 QListViewItem* ci = currentItem(); 1175 QListViewItem* ci = currentItem();
1172 if ( ci ) 1176 if ( ci )
1173 ci->setSelected( true ); 1177 ci->setSelected( true );
1174 } 1178 }
1175 KListView::contentsMouseReleaseEvent(e); 1179 KListView::contentsMouseReleaseEvent(e);
1176} 1180}
1177void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) 1181void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e)
1178{ 1182{
1179 // qDebug("contentsMouseMoveEv....... "); 1183 // qDebug("contentsMouseMoveEv....... ");
1180 // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() ); 1184 // qDebug("start: %d current %d ",mYMousePos , mapToGlobal( (e->pos())).y() );
1181 int diff = mYMousePos - mapToGlobal( (e->pos())).y(); 1185 int diff = mYMousePos - mapToGlobal( (e->pos())).y();
1182 if ( diff < 0 ) diff = -diff; 1186 if ( diff < 0 ) diff = -diff;
1183 if ( diff > 20 ) 1187 if ( diff > 20 )
1184 mAllowPopupMenu = false; 1188 mAllowPopupMenu = false;
1185 KListView::contentsMouseMoveEvent(e); 1189 KListView::contentsMouseMoveEvent(e);
1186} 1190}
diff --git a/korganizer/kolistview.h b/korganizer/kolistview.h
index bd5bd12..c86449d 100644
--- a/korganizer/kolistview.h
+++ b/korganizer/kolistview.h
@@ -1,303 +1,304 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 1999 Preston Brown 3 Copyright (c) 1999 Preston Brown
4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2000,2001 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 _KOLISTVIEW_H 24#ifndef _KOLISTVIEW_H
25#define _KOLISTVIEW_H 25#define _KOLISTVIEW_H
26 26
27#include <qlistview.h> 27#include <qlistview.h>
28#include <qmap.h> 28#include <qmap.h>
29#include <qdict.h> 29#include <qdict.h>
30 30
31#include <klistview.h> 31#include <klistview.h>
32 32
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/incidence.h> 38#include <libkcal/incidence.h>
39 39
40#include "koeventview.h" 40#include "koeventview.h"
41#include "customlistviewitem.h" 41#include "customlistviewitem.h"
42 42
43using namespace KCal; 43using namespace KCal;
44 44
45 45
46 46
47#include <qpushbutton.h> 47#include <qpushbutton.h>
48#include <qlayout.h> 48#include <qlayout.h>
49#include <qdialog.h> 49#include <qdialog.h>
50#include <qcombobox.h> 50#include <qcombobox.h>
51#include <qspinbox.h> 51#include <qspinbox.h>
52#include <qtooltip.h> 52#include <qtooltip.h>
53#include <qcheckbox.h> 53#include <qcheckbox.h>
54#include <qhbox.h> 54#include <qhbox.h>
55#include <qlabel.h> 55#include <qlabel.h>
56#include <kiconloader.h> 56#include <kiconloader.h>
57#include "kfiledialog.h" 57#include "kfiledialog.h"
58#include "koprefs.h" 58#include "koprefs.h"
59class KOAlarmPrefs : public QDialog 59class KOAlarmPrefs : public QDialog
60{ 60{
61 Q_OBJECT 61 Q_OBJECT
62 public: 62 public:
63 KOAlarmPrefs( QWidget *par=0, const char *name=0 ) : 63 KOAlarmPrefs( QWidget *par=0, const char *name=0 ) :
64 QDialog( par, name, true ) 64 QDialog( par, name, true )
65 { 65 {
66 setCaption( i18n("Alarm Options") ); 66 setCaption( i18n("Alarm Options") );
67 QVBoxLayout* alarmLayout = new QVBoxLayout( this ); 67 QVBoxLayout* alarmLayout = new QVBoxLayout( this );
68 alarmLayout->setSpacing( 3 ); 68 alarmLayout->setSpacing( 3 );
69 alarmLayout->setMargin( 3 ); 69 alarmLayout->setMargin( 3 );
70 QWidget *parent = this; 70 QWidget *parent = this;
71 mAlarmButton = new QCheckBox(i18n("Set reminder ON with offset to:"),parent); 71 mAlarmButton = new QCheckBox(i18n("Set reminder ON with offset to:"),parent);
72 alarmLayout->addWidget(mAlarmButton); 72 alarmLayout->addWidget(mAlarmButton);
73 mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ; 73 mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ;
74 mAlarmTimeEdit->setValue( 15 ); 74 mAlarmTimeEdit->setValue( 15 );
75 alarmLayout->addWidget(mAlarmTimeEdit); 75 alarmLayout->addWidget(mAlarmTimeEdit);
76 mAlarmIncrCombo = new QComboBox(false, parent); 76 mAlarmIncrCombo = new QComboBox(false, parent);
77 mAlarmIncrCombo->insertItem(i18n("minute(s)")); 77 mAlarmIncrCombo->insertItem(i18n("minute(s)"));
78 mAlarmIncrCombo->insertItem(i18n("hour(s)")); 78 mAlarmIncrCombo->insertItem(i18n("hour(s)"));
79 mAlarmIncrCombo->insertItem(i18n("day(s)")); 79 mAlarmIncrCombo->insertItem(i18n("day(s)"));
80 alarmLayout->addWidget(mAlarmIncrCombo); 80 alarmLayout->addWidget(mAlarmIncrCombo);
81 QHBox * hb = new QHBox ( parent ); 81 QHBox * hb = new QHBox ( parent );
82 alarmLayout->addWidget(hb); 82 alarmLayout->addWidget(hb);
83 mAlarmSoundButton = new QPushButton(hb); 83 mAlarmSoundButton = new QPushButton(hb);
84 mAlarmSoundButton->setPixmap(SmallIcon("playsound")); 84 mAlarmSoundButton->setPixmap(SmallIcon("playsound"));
85 mAlarmSoundButton->setToggleButton(true); 85 mAlarmSoundButton->setToggleButton(true);
86 connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound())); 86 connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound()));
87 mAlarmProgramButton = new QPushButton(hb); 87 mAlarmProgramButton = new QPushButton(hb);
88 mAlarmProgramButton->setPixmap(SmallIcon("run")); 88 mAlarmProgramButton->setPixmap(SmallIcon("run"));
89 mAlarmProgramButton->setToggleButton(true); 89 mAlarmProgramButton->setToggleButton(true);
90 connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram())); 90 connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram()));
91 mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 ); 91 mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 );
92 mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 ); 92 mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 );
93 mAlarmLabel = new QLabel( this ); 93 mAlarmLabel = new QLabel( this );
94 alarmLayout->addWidget( mAlarmLabel ); 94 alarmLayout->addWidget( mAlarmLabel );
95 mAlarmLabel->setText( "..."+KOPrefs::instance()->mDefaultAlarmFile.right( 30 ) ); 95 mAlarmLabel->setText( "..."+KOPrefs::instance()->mDefaultAlarmFile.right( 30 ) );
96 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; 96 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
97 mAlarmSoundButton->setOn( true ); 97 mAlarmSoundButton->setOn( true );
98 QPushButton * ok = new QPushButton( i18n("Set Alarm!"), this ); 98 QPushButton * ok = new QPushButton( i18n("Set Alarm!"), this );
99 alarmLayout->addWidget( ok ); 99 alarmLayout->addWidget( ok );
100 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 100 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
101 alarmLayout->addWidget( cancel ); 101 alarmLayout->addWidget( cancel );
102 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 102 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
103 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 103 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
104 resize( 200, 200 ); 104 resize( 200, 200 );
105 105
106 } 106 }
107 107
108 108
109 109
110 QString mAlarmSound, mAlarmProgram ; 110 QString mAlarmSound, mAlarmProgram ;
111 QCheckBox* mAlarmButton; 111 QCheckBox* mAlarmButton;
112 QSpinBox* mAlarmTimeEdit; 112 QSpinBox* mAlarmTimeEdit;
113 QLabel* mAlarmLabel; 113 QLabel* mAlarmLabel;
114 QComboBox* mAlarmIncrCombo ; 114 QComboBox* mAlarmIncrCombo ;
115 QPushButton* mAlarmSoundButton ,*mAlarmProgramButton; 115 QPushButton* mAlarmSoundButton ,*mAlarmProgramButton;
116private slots: 116private slots:
117 117
118void pickAlarmSound() 118void pickAlarmSound()
119{ 119{
120 //QString prefix = mAlarmSound; 120 //QString prefix = mAlarmSound;
121 if (!mAlarmSoundButton->isOn()) { 121 if (!mAlarmSoundButton->isOn()) {
122 //mAlarmSound = ""; 122 //mAlarmSound = "";
123 QToolTip::remove(mAlarmSoundButton); 123 QToolTip::remove(mAlarmSoundButton);
124 QToolTip::add(mAlarmSoundButton, i18n("No sound set")); 124 QToolTip::add(mAlarmSoundButton, i18n("No sound set"));
125 mAlarmProgramButton->setOn(true); 125 mAlarmProgramButton->setOn(true);
126 mAlarmSoundButton->setOn(false); 126 mAlarmSoundButton->setOn(false);
127 } else { 127 } else {
128 QString fileName(KFileDialog::getOpenFileName(mAlarmSound, 128 QString fileName(KFileDialog::getOpenFileName(mAlarmSound,
129 i18n("*.wav|Wav Files"), 0)); 129 i18n("*.wav|Wav Files"), 0));
130 if (!fileName.isEmpty()) { 130 if (!fileName.isEmpty()) {
131 mAlarmSound = fileName; 131 mAlarmSound = fileName;
132 mAlarmLabel->setText( "..."+fileName.right( 30 ) ); 132 mAlarmLabel->setText( "..."+fileName.right( 30 ) );
133 QToolTip::remove(mAlarmSoundButton); 133 QToolTip::remove(mAlarmSoundButton);
134 QString dispStr = i18n("Playing '%1'").arg(fileName); 134 QString dispStr = i18n("Playing '%1'").arg(fileName);
135 QToolTip::add(mAlarmSoundButton, dispStr); 135 QToolTip::add(mAlarmSoundButton, dispStr);
136 mAlarmProgramButton->setOn(false); 136 mAlarmProgramButton->setOn(false);
137 mAlarmSoundButton->setOn(true); 137 mAlarmSoundButton->setOn(true);
138 } else { 138 } else {
139 mAlarmProgramButton->setOn(true); 139 mAlarmProgramButton->setOn(true);
140 mAlarmSoundButton->setOn(false); 140 mAlarmSoundButton->setOn(false);
141 141
142 } 142 }
143 } 143 }
144}; 144};
145 145
146void pickAlarmProgram() 146void pickAlarmProgram()
147{ 147{
148 if (!mAlarmProgramButton->isOn()) { 148 if (!mAlarmProgramButton->isOn()) {
149 //mAlarmProgram = ""; 149 //mAlarmProgram = "";
150 QToolTip::remove(mAlarmProgramButton); 150 QToolTip::remove(mAlarmProgramButton);
151 QToolTip::add(mAlarmProgramButton, i18n("No program set")); 151 QToolTip::add(mAlarmProgramButton, i18n("No program set"));
152 mAlarmProgramButton->setOn(false); 152 mAlarmProgramButton->setOn(false);
153 mAlarmSoundButton->setOn(true); 153 mAlarmSoundButton->setOn(true);
154 } else { 154 } else {
155 QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm.: ") , 0)); 155 QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm.: ") , 0));
156 if (!fileName.isEmpty()) { 156 if (!fileName.isEmpty()) {
157 mAlarmProgram = fileName; 157 mAlarmProgram = fileName;
158 mAlarmLabel->setText( "..."+fileName.right( 30 ) ); 158 mAlarmLabel->setText( "..."+fileName.right( 30 ) );
159 QToolTip::remove(mAlarmProgramButton); 159 QToolTip::remove(mAlarmProgramButton);
160 QString dispStr = i18n("Running '%1'").arg(fileName); 160 QString dispStr = i18n("Running '%1'").arg(fileName);
161 QToolTip::add(mAlarmProgramButton, dispStr); 161 QToolTip::add(mAlarmProgramButton, dispStr);
162 mAlarmSoundButton->setOn(false); 162 mAlarmSoundButton->setOn(false);
163 mAlarmProgramButton->setOn(true); 163 mAlarmProgramButton->setOn(true);
164 } else { 164 } else {
165 mAlarmProgramButton->setOn(false); 165 mAlarmProgramButton->setOn(false);
166 mAlarmSoundButton->setOn(true); 166 mAlarmSoundButton->setOn(true);
167 } 167 }
168 } 168 }
169}; 169};
170 170
171}; 171};
172 172
173 173
174 174
175 175
176 176
177 177
178 178
179typedef CustomListViewItem<Incidence *> KOListViewItem; 179typedef CustomListViewItem<Incidence *> KOListViewItem;
180 180
181/** 181/**
182 This class provides the initialisation of a KOListViewItem for calendar 182 This class provides the initialisation of a KOListViewItem for calendar
183 components using the Incidence::Visitor. 183 components using the Incidence::Visitor.
184*/ 184*/
185class ListItemVisitor : public Incidence::Visitor 185class ListItemVisitor : public Incidence::Visitor
186{ 186{
187 public: 187 public:
188 ListItemVisitor(KOListViewItem *, QDate d); 188 ListItemVisitor(KOListViewItem *, QDate d);
189 ~ListItemVisitor(); 189 ~ListItemVisitor();
190 190
191 bool visit(Event *); 191 bool visit(Event *);
192 bool visit(Todo *); 192 bool visit(Todo *);
193 bool visit(Journal *); 193 bool visit(Journal *);
194 194
195 private: 195 private:
196 KOListViewItem *mItem; 196 KOListViewItem *mItem;
197 QDate mDate; 197 QDate mDate;
198}; 198};
199 199
200/** 200/**
201 This class provides a multi-column list view of events. It can 201 This class provides a multi-column list view of events. It can
202 display events from one particular day or several days, it doesn't 202 display events from one particular day or several days, it doesn't
203 matter. To use a view that only handles one day at a time, use 203 matter. To use a view that only handles one day at a time, use
204 KODayListView. 204 KODayListView.
205 205
206 @short multi-column list view of various events. 206 @short multi-column list view of various events.
207 @author Preston Brown <pbrown@kde.org> 207 @author Preston Brown <pbrown@kde.org>
208 @see KOBaseView, KODayListView 208 @see KOBaseView, KODayListView
209*/ 209*/
210class KOListView; 210class KOListView;
211 211
212class KOListViewListView : public KListView 212class KOListViewListView : public KListView
213{ 213{
214 Q_OBJECT 214 Q_OBJECT
215 public: 215 public:
216 KOListViewListView(KOListView * lv ); 216 KOListViewListView(KOListView * lv );
217 signals: 217 signals:
218 void newEvent(); 218 void newEvent();
219 void showIncidence( Incidence* ); 219 void showIncidence( Incidence* );
220 private: 220 private:
221 void keyPressEvent ( QKeyEvent * ) ; 221 void keyPressEvent ( QKeyEvent * ) ;
222 void contentsMouseDoubleClickEvent(QMouseEvent *e); 222 void contentsMouseDoubleClickEvent(QMouseEvent *e);
223 void contentsMousePressEvent(QMouseEvent *e); 223 void contentsMousePressEvent(QMouseEvent *e);
224 void contentsMouseReleaseEvent(QMouseEvent *e); 224 void contentsMouseReleaseEvent(QMouseEvent *e);
225 void contentsMouseMoveEvent(QMouseEvent *e); 225 void contentsMouseMoveEvent(QMouseEvent *e);
226 bool mAllowPopupMenu; 226 bool mAllowPopupMenu;
227 bool mMouseDown; 227 bool mMouseDown;
228 int mYMousePos; 228 int mYMousePos;
229}; 229};
230 230
231class KOListView : public KOEventView 231class KOListView : public KOEventView
232{ 232{
233 Q_OBJECT 233 Q_OBJECT
234 public: 234 public:
235 KOListView(Calendar *calendar, QWidget *parent = 0, 235 KOListView(Calendar *calendar, QWidget *parent = 0,
236 const char *name = 0); 236 const char *name = 0);
237 ~KOListView(); 237 ~KOListView();
238 238
239 virtual int maxDatesHint(); 239 virtual int maxDatesHint();
240 virtual int currentDateCount(); 240 virtual int currentDateCount();
241 virtual QPtrList<Incidence> selectedIncidences(); 241 virtual QPtrList<Incidence> selectedIncidences();
242 virtual DateList selectedDates(); 242 virtual DateList selectedDates();
243 243
244 void showDates(bool show); 244 void showDates(bool show);
245 Incidence* currentItem(); 245 Incidence* currentItem();
246 void addTodos(QPtrList<Todo> eventList); 246 void addTodos(QPtrList<Todo> eventList);
247 void addJournals(QPtrList<Journal> eventList); 247 void addJournals(QPtrList<Journal> eventList);
248 virtual void printPreview(CalPrinter *calPrinter, 248 virtual void printPreview(CalPrinter *calPrinter,
249 const QDate &, const QDate &); 249 const QDate &, const QDate &);
250 250
251 void readSettings(KConfig *config, QString setting = "KOListView Layout"); 251 void readSettings(KConfig *config, QString setting = "KOListView Layout");
252 void writeSettings(KConfig *config, QString setting = "KOListView Layout"); 252 void writeSettings(KConfig *config, QString setting = "KOListView Layout");
253 void updateList(); 253 void updateList();
254 void setStartDate(const QDate &start); 254 void setStartDate(const QDate &start);
255 int count(); 255 int count();
256 QString getWhatsThisText(QPoint p); 256 QString getWhatsThisText(QPoint p);
257 void resetFocus();
257 signals: 258 signals:
258 void signalNewEvent(); 259 void signalNewEvent();
259 void beamIncidenceList(QPtrList<Incidence>); 260 void beamIncidenceList(QPtrList<Incidence>);
260 261
261 public slots: 262 public slots:
262 virtual void updateView(); 263 virtual void updateView();
263 virtual void showDates(const QDate &start, const QDate &end); 264 virtual void showDates(const QDate &start, const QDate &end);
264 virtual void showEvents(QPtrList<Event> eventList); 265 virtual void showEvents(QPtrList<Event> eventList);
265 void clearSelection(); 266 void clearSelection();
266 void allSelection(); 267 void allSelection();
267 268
268 void clear(); 269 void clear();
269 void beamDone( Ir *ir ); 270 void beamDone( Ir *ir );
270 void showDates(); 271 void showDates();
271 void hideDates(); 272 void hideDates();
272 void deleteAll(); 273 void deleteAll();
273 void saveToFile(); 274 void saveToFile();
274 void saveDescriptionToFile(); 275 void saveDescriptionToFile();
275 void beamSelected(); 276 void beamSelected();
276 void updateConfig(); 277 void updateConfig();
277 void addCat(); 278 void addCat();
278 void setCat(); 279 void setCat();
279 void setAlarm(); 280 void setAlarm();
280 void setCategories( bool removeOld ); 281 void setCategories( bool removeOld );
281 void changeEventDisplay(Event *, int); 282 void changeEventDisplay(Event *, int);
282 283
283 void defaultItemAction(QListViewItem *item); 284 void defaultItemAction(QListViewItem *item);
284 void popupMenu(QListViewItem *item,const QPoint &,int); 285 void popupMenu(QListViewItem *item,const QPoint &,int);
285 286
286 protected slots: 287 protected slots:
287 void processSelectionChange(QListViewItem *); 288 void processSelectionChange(QListViewItem *);
288 289
289 protected: 290 protected:
290 void addEvents(QPtrList<Event> eventList); 291 void addEvents(QPtrList<Event> eventList);
291 void addIncidence(Incidence *); 292 void addIncidence(Incidence *);
292 KOListViewItem *getItemForEvent(Event *event); 293 KOListViewItem *getItemForEvent(Event *event);
293 294
294 private: 295 private:
295 KOListViewListView *mListView; 296 KOListViewListView *mListView;
296 KOEventPopupMenu *mPopupMenu; 297 KOEventPopupMenu *mPopupMenu;
297 KOListViewItem *mActiveItem; 298 KOListViewItem *mActiveItem;
298 QDict<Incidence> mUidDict; 299 QDict<Incidence> mUidDict;
299 QDate mStartDate; 300 QDate mStartDate;
300 void keyPressEvent ( QKeyEvent * ) ; 301 void keyPressEvent ( QKeyEvent * ) ;
301}; 302};
302 303
303#endif 304#endif
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index 3483e95..5e8ea27 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -1,1318 +1,1340 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qlayout.h> 24#include <qlayout.h>
25#include <qheader.h> 25#include <qheader.h>
26#include <qcursor.h> 26#include <qcursor.h>
27#include <qwhatsthis.h> 27#include <qwhatsthis.h>
28 28
29#include <qvbox.h> 29#include <qvbox.h>
30#include <kdebug.h> 30#include <kdebug.h>
31#include "koprefs.h" 31#include "koprefs.h"
32#include <klocale.h> 32#include <klocale.h>
33#include <kglobal.h> 33#include <kglobal.h>
34#include <kiconloader.h> 34#include <kiconloader.h>
35#include <kmessagebox.h> 35#include <kmessagebox.h>
36 36
37#include <libkcal/icaldrag.h> 37#include <libkcal/icaldrag.h>
38#include <libkcal/vcaldrag.h> 38#include <libkcal/vcaldrag.h>
39#include <libkcal/calfilter.h> 39#include <libkcal/calfilter.h>
40#include <libkcal/dndfactory.h> 40#include <libkcal/dndfactory.h>
41#include <libkcal/calendarresources.h> 41#include <libkcal/calendarresources.h>
42#include <libkcal/resourcecalendar.h> 42#include <libkcal/resourcecalendar.h>
43#include <kresources/resourceselectdialog.h> 43#include <kresources/resourceselectdialog.h>
44#include <libkcal/kincidenceformatter.h> 44#include <libkcal/kincidenceformatter.h>
45#ifndef DESKTOP_VERSION 45#ifndef DESKTOP_VERSION
46#include <qpe/qpeapplication.h> 46#include <qpe/qpeapplication.h>
47#else 47#else
48#include <qapplication.h> 48#include <qapplication.h>
49#endif 49#endif
50#ifndef KORG_NOPRINTER 50#ifndef KORG_NOPRINTER
51#include "calprinter.h" 51#include "calprinter.h"
52#endif 52#endif
53#include "docprefs.h" 53#include "docprefs.h"
54 54
55#include "kotodoview.h" 55#include "kotodoview.h"
56using namespace KOrg; 56using namespace KOrg;
57 57
58 58
59class KOTodoViewWhatsThis :public QWhatsThis 59class KOTodoViewWhatsThis :public QWhatsThis
60{ 60{
61public: 61public:
62 KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { }; 62 KOTodoViewWhatsThis( QWidget *wid, KOTodoView* view ) : QWhatsThis( wid ), _wid(wid),_view (view) { };
63 63
64protected: 64protected:
65 virtual QString text( const QPoint& p) 65 virtual QString text( const QPoint& p)
66 { 66 {
67 return _view->getWhatsThisText(p) ; 67 return _view->getWhatsThisText(p) ;
68 } 68 }
69private: 69private:
70 QWidget* _wid; 70 QWidget* _wid;
71 KOTodoView * _view; 71 KOTodoView * _view;
72}; 72};
73 73
74KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, 74KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent,
75 const char *name) : 75 const char *name) :
76 KListView(parent,name) 76 KListView(parent,name)
77{ 77{
78 mName = QString ( name ); 78 mName = QString ( name );
79 mCalendar = calendar; 79 mCalendar = calendar;
80#ifndef DESKTOP_VERSION 80#ifndef DESKTOP_VERSION
81 QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); 81 QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold );
82#endif 82#endif
83 mOldCurrent = 0; 83 mOldCurrent = 0;
84 mMousePressed = false; 84 mMousePressed = false;
85 85
86 setAcceptDrops(true); 86 setAcceptDrops(true);
87 viewport()->setAcceptDrops(true); 87 viewport()->setAcceptDrops(true);
88 int size = 16; 88 int size = 16;
89 if (qApp->desktop()->width() < 300 ) 89 if (qApp->desktop()->width() < 300 )
90 size = 12; 90 size = 12;
91 setTreeStepSize( size + 6 ); 91 setTreeStepSize( size + 6 );
92 92
93} 93}
94 94
95void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) 95void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e)
96{ 96{
97#ifndef KORG_NODND 97#ifndef KORG_NODND
98// kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; 98// kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl;
99 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && 99 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
100 !QTextDrag::canDecode( e ) ) { 100 !QTextDrag::canDecode( e ) ) {
101 e->ignore(); 101 e->ignore();
102 return; 102 return;
103 } 103 }
104 104
105 mOldCurrent = currentItem(); 105 mOldCurrent = currentItem();
106#endif 106#endif
107} 107}
108 108
109 109
110void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e) 110void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e)
111{ 111{
112#ifndef KORG_NODND 112#ifndef KORG_NODND
113// kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl; 113// kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl;
114 114
115 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && 115 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
116 !QTextDrag::canDecode( e ) ) { 116 !QTextDrag::canDecode( e ) ) {
117 e->ignore(); 117 e->ignore();
118 return; 118 return;
119 } 119 }
120 120
121 e->accept(); 121 e->accept();
122#endif 122#endif
123} 123}
124 124
125void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) 125void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *)
126{ 126{
127#ifndef KORG_NODND 127#ifndef KORG_NODND
128// kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; 128// kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl;
129 129
130 setCurrentItem(mOldCurrent); 130 setCurrentItem(mOldCurrent);
131 setSelected(mOldCurrent,true); 131 setSelected(mOldCurrent,true);
132#endif 132#endif
133} 133}
134 134
135void KOTodoListView::contentsDropEvent(QDropEvent *e) 135void KOTodoListView::contentsDropEvent(QDropEvent *e)
136{ 136{
137#ifndef KORG_NODND 137#ifndef KORG_NODND
138// kdDebug() << "KOTodoListView::contentsDropEvent" << endl; 138// kdDebug() << "KOTodoListView::contentsDropEvent" << endl;
139 139
140 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && 140 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
141 !QTextDrag::canDecode( e ) ) { 141 !QTextDrag::canDecode( e ) ) {
142 e->ignore(); 142 e->ignore();
143 return; 143 return;
144 } 144 }
145 145
146 DndFactory factory( mCalendar ); 146 DndFactory factory( mCalendar );
147 Todo *todo = factory.createDropTodo(e); 147 Todo *todo = factory.createDropTodo(e);
148 148
149 if (todo) { 149 if (todo) {
150 e->acceptAction(); 150 e->acceptAction();
151 151
152 KOTodoViewItem *destination = 152 KOTodoViewItem *destination =
153 (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); 153 (KOTodoViewItem *)itemAt(contentsToViewport(e->pos()));
154 Todo *destinationEvent = 0; 154 Todo *destinationEvent = 0;
155 if (destination) destinationEvent = destination->todo(); 155 if (destination) destinationEvent = destination->todo();
156 156
157 Todo *existingTodo = mCalendar->todo(todo->uid()); 157 Todo *existingTodo = mCalendar->todo(todo->uid());
158 158
159 if(existingTodo) { 159 if(existingTodo) {
160 Incidence *to = destinationEvent; 160 Incidence *to = destinationEvent;
161 while(to) { 161 while(to) {
162 if (to->uid() == todo->uid()) { 162 if (to->uid() == todo->uid()) {
163 KMessageBox::sorry(this, 163 KMessageBox::sorry(this,
164 i18n("Cannot move To-Do to itself\nor a child of itself"), 164 i18n("Cannot move To-Do to itself\nor a child of itself"),
165 i18n("Drop To-Do")); 165 i18n("Drop To-Do"));
166 delete todo; 166 delete todo;
167 return; 167 return;
168 } 168 }
169 to = to->relatedTo(); 169 to = to->relatedTo();
170 } 170 }
171 internalDrop = true; 171 internalDrop = true;
172 if ( destinationEvent ) 172 if ( destinationEvent )
173 reparentTodoSignal( destinationEvent, existingTodo ); 173 reparentTodoSignal( destinationEvent, existingTodo );
174 else 174 else
175 unparentTodoSignal(existingTodo); 175 unparentTodoSignal(existingTodo);
176 delete todo; 176 delete todo;
177 } else { 177 } else {
178 mCalendar->addTodo(todo); 178 mCalendar->addTodo(todo);
179 emit todoDropped(todo, KOGlobals::EVENTADDED); 179 emit todoDropped(todo, KOGlobals::EVENTADDED);
180 if ( destinationEvent ) 180 if ( destinationEvent )
181 reparentTodoSignal( destinationEvent, todo ); 181 reparentTodoSignal( destinationEvent, todo );
182 } 182 }
183 } 183 }
184 else { 184 else {
185 QString text; 185 QString text;
186 if (QTextDrag::decode(e,text)) { 186 if (QTextDrag::decode(e,text)) {
187 //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); 187 //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) );
188 KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); 188 KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) ));
189 qDebug("Dropped : " + text); 189 qDebug("Dropped : " + text);
190 QStringList emails = QStringList::split(",",text); 190 QStringList emails = QStringList::split(",",text);
191 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { 191 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) {
192 int pos = (*it).find("<"); 192 int pos = (*it).find("<");
193 QString name = (*it).left(pos); 193 QString name = (*it).left(pos);
194 QString email = (*it).mid(pos); 194 QString email = (*it).mid(pos);
195 if (!email.isEmpty() && todoi) { 195 if (!email.isEmpty() && todoi) {
196 todoi->todo()->addAttendee(new Attendee(name,email)); 196 todoi->todo()->addAttendee(new Attendee(name,email));
197 } 197 }
198 } 198 }
199 } 199 }
200 else { 200 else {
201 qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); 201 qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable ");
202 e->ignore(); 202 e->ignore();
203 } 203 }
204 } 204 }
205#endif 205#endif
206} 206}
207 207
208void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) 208void KOTodoListView::contentsMousePressEvent(QMouseEvent* e)
209{ 209{
210#ifndef KORG_NODND 210#ifndef KORG_NODND
211 QPoint p(contentsToViewport(e->pos())); 211 QPoint p(contentsToViewport(e->pos()));
212 QListViewItem *i = itemAt(p); 212 QListViewItem *i = itemAt(p);
213 mMousePressed = false; 213 mMousePressed = false;
214 if (i) { 214 if (i) {
215 // if the user clicked into the root decoration of the item, don't 215 // if the user clicked into the root decoration of the item, don't
216 // try to start a drag! 216 // try to start a drag!
217 if (p.x() > header()->sectionPos(header()->mapToIndex(0)) + 217 if (p.x() > header()->sectionPos(header()->mapToIndex(0)) +
218 treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + 218 treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) +
219 itemMargin() || 219 itemMargin() ||
220 p.x() < header()->sectionPos(header()->mapToIndex(0))) { 220 p.x() < header()->sectionPos(header()->mapToIndex(0))) {
221 if (e->button()==Qt::LeftButton) { 221 if (e->button()==Qt::LeftButton) {
222 mPressPos = e->pos(); 222 mPressPos = e->pos();
223 mMousePressed = true; 223 mMousePressed = true;
224 } 224 }
225 } 225 }
226 } 226 }
227#endif 227#endif
228 QListView::contentsMousePressEvent(e); 228 QListView::contentsMousePressEvent(e);
229} 229}
230void KOTodoListView::paintEvent(QPaintEvent* e) 230void KOTodoListView::paintEvent(QPaintEvent* e)
231{ 231{
232 emit paintNeeded(); 232 emit paintNeeded();
233 QListView::paintEvent( e); 233 QListView::paintEvent( e);
234} 234}
235void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) 235void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e)
236{ 236{
237 237
238#ifndef KORG_NODND 238#ifndef KORG_NODND
239 //QListView::contentsMouseMoveEvent(e); 239 //QListView::contentsMouseMoveEvent(e);
240 if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > 240 if (mMousePressed && (mPressPos - e->pos()).manhattanLength() >
241 QApplication::startDragDistance()*3) { 241 QApplication::startDragDistance()*3) {
242 mMousePressed = false; 242 mMousePressed = false;
243 QListViewItem *item = itemAt(contentsToViewport(mPressPos)); 243 QListViewItem *item = itemAt(contentsToViewport(mPressPos));
244 if (item) { 244 if (item) {
245 DndFactory factory( mCalendar ); 245 DndFactory factory( mCalendar );
246 ICalDrag *vd = factory.createDrag( 246 ICalDrag *vd = factory.createDrag(
247 ((KOTodoViewItem *)item)->todo(),viewport()); 247 ((KOTodoViewItem *)item)->todo(),viewport());
248 internalDrop = false; 248 internalDrop = false;
249 // we cannot do any senseful here, because the DnD is still broken in Qt 249 // we cannot do any senseful here, because the DnD is still broken in Qt
250 if (vd->drag()) { 250 if (vd->drag()) {
251 if ( !internalDrop ) { 251 if ( !internalDrop ) {
252 //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); 252 //emit deleteTodo( ((KOTodoViewItem *)item)->todo() );
253 qDebug("Dnd: External move: Delete drag source "); 253 qDebug("Dnd: External move: Delete drag source ");
254 } else 254 } else
255 qDebug("Dnd: Internal move "); 255 qDebug("Dnd: Internal move ");
256 256
257 } else { 257 } else {
258 if ( !internalDrop ) { 258 if ( !internalDrop ) {
259 qDebug("Dnd: External Copy"); 259 qDebug("Dnd: External Copy");
260 } else 260 } else
261 qDebug("DnD: Internal copy: Copy pending"); 261 qDebug("DnD: Internal copy: Copy pending");
262 } 262 }
263 } 263 }
264 } 264 }
265#endif 265#endif
266} 266}
267void KOTodoListView::keyPressEvent ( QKeyEvent * e ) 267void KOTodoListView::keyPressEvent ( QKeyEvent * e )
268{ 268{
269 269
270 QListViewItem* cn; 270 QListViewItem* cn;
271 if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { 271 if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) {
272 cn = currentItem(); 272 cn = currentItem();
273 if ( cn ) { 273 if ( cn ) {
274 KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); 274 KOTodoViewItem* ci = (KOTodoViewItem*)( cn );
275 if ( ci ){ 275 if ( ci ){
276 if ( e->state() == ShiftButton ) 276 if ( e->state() == ShiftButton )
277 ci->setOn( false ); 277 ci->setOn( false );
278 else 278 else
279 ci->setOn( true ); 279 ci->setOn( true );
280 cn = cn->itemBelow(); 280 cn = cn->itemBelow();
281 if ( cn ) { 281 if ( cn ) {
282 setCurrentItem ( cn ); 282 setCurrentItem ( cn );
283 ensureItemVisible ( cn ); 283 ensureItemVisible ( cn );
284 } 284 }
285 285
286 } 286 }
287 } 287 }
288 288
289 return; 289 return;
290 } 290 }
291 291
292 // qDebug("KOTodoListView::keyPressEvent "); 292 // qDebug("KOTodoListView::keyPressEvent ");
293 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { 293 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) {
294 switch ( e->key() ) { 294 switch ( e->key() ) {
295 case Qt::Key_Down: 295 case Qt::Key_Down:
296 case Qt::Key_Up: 296 case Qt::Key_Up:
297 QListView::keyPressEvent ( e ); 297 QListView::keyPressEvent ( e );
298 break; 298 break;
299 case Qt::Key_Left: 299 case Qt::Key_Left:
300 case Qt::Key_Right: 300 case Qt::Key_Right:
301 QListView::keyPressEvent ( e ); 301 QListView::keyPressEvent ( e );
302 e->accept(); 302 e->accept();
303 return; 303 return;
304 break; 304 break;
305 default: 305 default:
306 e->ignore(); 306 e->ignore();
307 break; 307 break;
308 } 308 }
309 return; 309 return;
310 } 310 }
311 e->ignore(); 311 e->ignore();
312} 312}
313void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) 313void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e)
314{ 314{
315 QListView::contentsMouseReleaseEvent(e); 315 QListView::contentsMouseReleaseEvent(e);
316 mMousePressed = false; 316 mMousePressed = false;
317} 317}
318 318
319void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) 319void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e)
320{ 320{
321 if (!e) return; 321 if (!e) return;
322 322
323 QPoint vp = contentsToViewport(e->pos()); 323 QPoint vp = contentsToViewport(e->pos());
324 324
325 QListViewItem *item = itemAt(vp); 325 QListViewItem *item = itemAt(vp);
326 326
327 emit double_Clicked(item); 327 emit double_Clicked(item);
328 if (!item) return; 328 if (!item) return;
329 329
330 emit doubleClicked(item,vp,0); 330 emit doubleClicked(item,vp,0);
331} 331}
332 332
333///////////////////////////////////////////////////////////////////////////// 333/////////////////////////////////////////////////////////////////////////////
334 334
335KOQuickTodo::KOQuickTodo(QWidget *parent) : 335KOQuickTodo::KOQuickTodo(QWidget *parent) :
336 QLineEdit(parent) 336 QLineEdit(parent)
337{ 337{
338 setText(i18n("Click to add a new Todo")); 338 setText(i18n("Click to add a new Todo"));
339} 339}
340 340
341void KOQuickTodo::focusInEvent(QFocusEvent *ev) 341void KOQuickTodo::focusInEvent(QFocusEvent *ev)
342{ 342{
343 if ( text()==i18n("Click to add a new Todo") ) 343 if ( text()==i18n("Click to add a new Todo") )
344 setText(""); 344 setText("");
345 QLineEdit::focusInEvent(ev); 345 QLineEdit::focusInEvent(ev);
346} 346}
347 347
348void KOQuickTodo::focusOutEvent(QFocusEvent *ev) 348void KOQuickTodo::focusOutEvent(QFocusEvent *ev)
349{ 349{
350 setText(i18n("Click to add a new Todo")); 350 setText(i18n("Click to add a new Todo"));
351 QLineEdit::focusOutEvent(ev); 351 QLineEdit::focusOutEvent(ev);
352} 352}
353 353
354///////////////////////////////////////////////////////////////////////////// 354/////////////////////////////////////////////////////////////////////////////
355 355
356KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : 356KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) :
357 KOrg::BaseView(calendar,parent,name) 357 KOrg::BaseView(calendar,parent,name)
358{ 358{
359 mPendingUpdateBeforeRepaint = false; 359 mPendingUpdateBeforeRepaint = false;
360 isFlatDisplay = false; 360 isFlatDisplay = false;
361 mNavigator = 0; 361 mNavigator = 0;
362 QBoxLayout *topLayout = new QVBoxLayout(this); 362 QBoxLayout *topLayout = new QVBoxLayout(this);
363 mName = QString ( name ); 363 mName = QString ( name );
364 mBlockUpdate = false; 364 mBlockUpdate = false;
365 mQuickAdd = new KOQuickTodo(this); 365 mQuickAdd = new KOQuickTodo(this);
366 topLayout->addWidget(mQuickAdd); 366 topLayout->addWidget(mQuickAdd);
367 367
368 if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); 368 if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide();
369 369
370 mTodoListView = new KOTodoListView(calendar,this, name ); 370 mTodoListView = new KOTodoListView(calendar,this, name );
371 topLayout->addWidget(mTodoListView); 371 topLayout->addWidget(mTodoListView);
372 //mTodoListView->header()->setMaximumHeight(30); 372 //mTodoListView->header()->setMaximumHeight(30);
373 mTodoListView->setRootIsDecorated(true); 373 mTodoListView->setRootIsDecorated(true);
374 mTodoListView->setAllColumnsShowFocus(true); 374 mTodoListView->setAllColumnsShowFocus(true);
375 375
376 mTodoListView->setShowSortIndicator(true); 376 mTodoListView->setShowSortIndicator(true);
377 377
378 mTodoListView->addColumn(i18n("Todo")); 378 mTodoListView->addColumn(i18n("Todo"));
379 mTodoListView->addColumn(i18n("Prio")); 379 mTodoListView->addColumn(i18n("Prio"));
380 mTodoListView->setColumnAlignment(1,AlignHCenter); 380 mTodoListView->setColumnAlignment(1,AlignHCenter);
381 mTodoListView->addColumn(i18n("Complete")); 381 mTodoListView->addColumn(i18n("Complete"));
382 mTodoListView->setColumnAlignment(2,AlignCenter); 382 mTodoListView->setColumnAlignment(2,AlignCenter);
383 383
384 mTodoListView->addColumn(i18n("Due Date")); 384 mTodoListView->addColumn(i18n("Due Date"));
385 mTodoListView->setColumnAlignment(3,AlignLeft); 385 mTodoListView->setColumnAlignment(3,AlignLeft);
386 mTodoListView->addColumn(i18n("Due Time")); 386 mTodoListView->addColumn(i18n("Due Time"));
387 mTodoListView->setColumnAlignment(4,AlignHCenter); 387 mTodoListView->setColumnAlignment(4,AlignHCenter);
388 388
389 mTodoListView->addColumn(i18n("Start Date")); 389 mTodoListView->addColumn(i18n("Start Date"));
390 mTodoListView->setColumnAlignment(5,AlignLeft); 390 mTodoListView->setColumnAlignment(5,AlignLeft);
391 mTodoListView->addColumn(i18n("Start Time")); 391 mTodoListView->addColumn(i18n("Start Time"));
392 mTodoListView->setColumnAlignment(6,AlignHCenter); 392 mTodoListView->setColumnAlignment(6,AlignHCenter);
393 393
394 mTodoListView->addColumn(i18n("Cancelled")); 394 mTodoListView->addColumn(i18n("Cancelled"));
395 mTodoListView->addColumn(i18n("Categories")); 395 mTodoListView->addColumn(i18n("Categories"));
396#if 0 396#if 0
397 mTodoListView->addColumn(i18n("Sort Id")); 397 mTodoListView->addColumn(i18n("Sort Id"));
398 mTodoListView->setColumnAlignment(4,AlignHCenter); 398 mTodoListView->setColumnAlignment(4,AlignHCenter);
399#endif 399#endif
400 400
401 mTodoListView->setMinimumHeight( 60 ); 401 mTodoListView->setMinimumHeight( 60 );
402 mTodoListView->setItemsRenameable( true ); 402 mTodoListView->setItemsRenameable( true );
403 mTodoListView->setRenameable( 0 ); 403 mTodoListView->setRenameable( 0 );
404 mTodoListView->setColumnWidth( 0, 120 ); 404 mTodoListView->setColumnWidth( 0, 120 );
405 mTodoListView->setColumnWidthMode(0, QListView::Manual); 405 mTodoListView->setColumnWidthMode(0, QListView::Manual);
406 mTodoListView->setColumnWidthMode(1, QListView::Manual); 406 mTodoListView->setColumnWidthMode(1, QListView::Manual);
407 mTodoListView->setColumnWidthMode(2, QListView::Manual); 407 mTodoListView->setColumnWidthMode(2, QListView::Manual);
408 mTodoListView->setColumnWidthMode(3, QListView::Manual); 408 mTodoListView->setColumnWidthMode(3, QListView::Manual);
409 mTodoListView->setColumnWidthMode(4, QListView::Manual); 409 mTodoListView->setColumnWidthMode(4, QListView::Manual);
410 mTodoListView->setColumnWidthMode(5, QListView::Manual); 410 mTodoListView->setColumnWidthMode(5, QListView::Manual);
411 mTodoListView->setColumnWidthMode(6, QListView::Manual); 411 mTodoListView->setColumnWidthMode(6, QListView::Manual);
412 mTodoListView->setColumnWidthMode(7, QListView::Manual); 412 mTodoListView->setColumnWidthMode(7, QListView::Manual);
413 mTodoListView->setColumnWidthMode(8, QListView::Manual); 413 mTodoListView->setColumnWidthMode(8, QListView::Manual);
414 414
415 415
416 new KOTodoViewWhatsThis(mTodoListView->viewport(),this); 416 new KOTodoViewWhatsThis(mTodoListView->viewport(),this);
417 417
418 mPriorityPopupMenu = new QPopupMenu(this); 418 mPriorityPopupMenu = new QPopupMenu(this);
419 for (int i = 1; i <= 5; i++) { 419 for (int i = 1; i <= 5; i++) {
420 QString label = QString ("%1").arg (i); 420 QString label = QString ("%1").arg (i);
421 mPriority[mPriorityPopupMenu->insertItem (label)] = i; 421 mPriority[mPriorityPopupMenu->insertItem (label)] = i;
422 } 422 }
423 connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); 423 connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int)));
424 424
425 mPercentageCompletedPopupMenu = new QPopupMenu(this); 425 mPercentageCompletedPopupMenu = new QPopupMenu(this);
426 for (int i = 0; i <= 100; i+=20) { 426 for (int i = 0; i <= 100; i+=20) {
427 QString label = QString ("%1 %").arg (i); 427 QString label = QString ("%1 %").arg (i);
428 mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; 428 mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i;
429 } 429 }
430 connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); 430 connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int)));
431 431
432 432
433 433
434 mItemPopupMenu = new QPopupMenu(this); 434 mItemPopupMenu = new QPopupMenu(this);
435 mItemPopupMenu->insertItem(i18n("Show..."), this, 435 mItemPopupMenu->insertItem(i18n("Show..."), this,
436 SLOT (showTodo())); 436 SLOT (showTodo()));
437 mItemPopupMenu->insertItem(i18n("Edit..."), this, 437 mItemPopupMenu->insertItem(i18n("Edit..."), this,
438 SLOT (editTodo())); 438 SLOT (editTodo()));
439 mItemPopupMenu->insertItem( i18n("Delete"), this, 439 mItemPopupMenu->insertItem( i18n("Delete"), this,
440 SLOT (deleteTodo())); 440 SLOT (deleteTodo()));
441 mItemPopupMenu->insertItem( i18n("Clone..."), this, 441 mItemPopupMenu->insertItem( i18n("Clone..."), this,
442 SLOT (cloneTodo())); 442 SLOT (cloneTodo()));
443 mItemPopupMenu->insertItem( i18n("Move..."), this, 443 mItemPopupMenu->insertItem( i18n("Move..."), this,
444 SLOT (moveTodo())); 444 SLOT (moveTodo()));
445 mItemPopupMenu->insertItem( i18n("Beam..."), this, 445 mItemPopupMenu->insertItem( i18n("Beam..."), this,
446 SLOT (beamTodo())); 446 SLOT (beamTodo()));
447 mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, 447 mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this,
448 SLOT (cancelTodo())); 448 SLOT (cancelTodo()));
449 mItemPopupMenu->insertSeparator(); 449 mItemPopupMenu->insertSeparator();
450 450
451 mItemPopupMenu->insertItem( i18n("New Todo..."), this, 451 mItemPopupMenu->insertItem( i18n("New Todo..."), this,
452 SLOT (newTodo())); 452 SLOT (newTodo()));
453 mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, 453 mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this,
454 SLOT (newSubTodo())); 454 SLOT (newSubTodo()));
455 mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, 455 mItemPopupMenu->insertItem(i18n("Unparent Todo"), this,
456 SLOT (unparentTodo()),0,21); 456 SLOT (unparentTodo()),0,21);
457 mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, 457 mItemPopupMenu->insertItem(i18n("Reparent Todo"), this,
458 SLOT (reparentTodo()),0,22); 458 SLOT (reparentTodo()),0,22);
459 mItemPopupMenu->insertSeparator(); 459 mItemPopupMenu->insertSeparator();
460#if 0 460#if 0
461 mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"), 461 mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"),
462 this, SLOT( purgeCompleted() ) ); 462 this, SLOT( purgeCompleted() ) );
463 mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), 463 mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"),
464 this, SLOT( toggleCompleted() ),0, 33 ); 464 this, SLOT( toggleCompleted() ),0, 33 );
465 mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), 465 mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"),
466 this, SLOT( toggleQuickTodo() ),0, 34 ); 466 this, SLOT( toggleQuickTodo() ),0, 34 );
467 mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), 467 mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"),
468 this, SLOT( toggleRunning() ),0, 35 ); 468 this, SLOT( toggleRunning() ),0, 35 );
469 469
470#endif 470#endif
471 mPopupMenu = new QPopupMenu(this); 471 mPopupMenu = new QPopupMenu(this);
472 mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, 472 mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this,
473 SLOT (newTodo()),0,1); 473 SLOT (newTodo()),0,1);
474 mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"), 474 mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"),
475 this, SLOT(purgeCompleted()),0,2); 475 this, SLOT(purgeCompleted()),0,2);
476 mPopupMenu->insertItem(i18n("Show Completed"), 476 mPopupMenu->insertItem(i18n("Show Completed"),
477 this, SLOT( toggleCompleted() ),0,3 ); 477 this, SLOT( toggleCompleted() ),0,3 );
478 mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), 478 mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"),
479 this, SLOT( toggleQuickTodo() ),0,4 ); 479 this, SLOT( toggleQuickTodo() ),0,4 );
480 mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), 480 mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"),
481 this, SLOT( toggleRunning() ),0,5 ); 481 this, SLOT( toggleRunning() ),0,5 );
482 mPopupMenu->insertItem(i18n(" set all open","Display all opened"), 482 mPopupMenu->insertItem(i18n(" set all open","Display all opened"),
483 this, SLOT( setAllOpen() ),0,6 ); 483 this, SLOT( setAllOpen() ),0,6 );
484 mPopupMenu->insertItem(i18n(" set all close","Display all closed"), 484 mPopupMenu->insertItem(i18n(" set all close","Display all closed"),
485 this, SLOT( setAllClose() ),0,7 ); 485 this, SLOT( setAllClose() ),0,7 );
486 mPopupMenu->insertItem(i18n(" set all flat","Display all flat"), 486 mPopupMenu->insertItem(i18n(" set all flat","Display all flat"),
487 this, SLOT( setAllFlat() ),0,8 ); 487 this, SLOT( setAllFlat() ),0,8 );
488 mDocPrefs = new DocPrefs( name ); 488 mDocPrefs = new DocPrefs( name );
489 489
490 mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu ); 490 mItemPopupMenu->insertItem(i18n("Todo View"),mPopupMenu );
491 mPopupMenu->setCheckable( true ); 491 mPopupMenu->setCheckable( true );
492 mItemPopupMenu->setCheckable( true ); 492 mItemPopupMenu->setCheckable( true );
493 493
494 494
495 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); 495 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo );
496 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); 496 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo );
497 497
498 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); 498 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo);
499 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); 499 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo );
500 500
501 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); 501 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos);
502 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); 502 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos );
503 503
504 504
505 // Double clicking conflicts with opening/closing the subtree 505 // Double clicking conflicts with opening/closing the subtree
506 connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), 506 connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ),
507 SLOT( editItem( QListViewItem *) ) ); 507 SLOT( editItem( QListViewItem *) ) );
508 /* 508 /*
509 connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, 509 connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *,
510 const QPoint &,int ) ), 510 const QPoint &,int ) ),
511 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); 511 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) );
512 */ 512 */
513 connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, 513 connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *,
514 const QPoint &,int ) ), 514 const QPoint &,int ) ),
515 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); 515 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) );
516 connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), 516 connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ),
517 SLOT( itemClicked( QListViewItem * ) ) ); 517 SLOT( itemClicked( QListViewItem * ) ) );
518 connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), 518 connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ),
519 SLOT( itemDoubleClicked( QListViewItem * ) ) ); 519 SLOT( itemDoubleClicked( QListViewItem * ) ) );
520 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), 520 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ),
521 SLOT( updateView() ) ); 521 SLOT( updateView() ) );
522 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), 522 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ),
523 SLOT( todoModified(Todo *, int) ) ); 523 SLOT( todoModified(Todo *, int) ) );
524 connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), 524 connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ),
525 SLOT( itemStateChanged( QListViewItem * ) ) ); 525 SLOT( itemStateChanged( QListViewItem * ) ) );
526 connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), 526 connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ),
527 SLOT( itemStateChanged( QListViewItem * ) ) ); 527 SLOT( itemStateChanged( QListViewItem * ) ) );
528 connect( mTodoListView, SIGNAL( paintNeeded() ), 528 connect( mTodoListView, SIGNAL( paintNeeded() ),
529 SLOT( paintNeeded()) ); 529 SLOT( paintNeeded()) );
530 530
531#if 0 531#if 0
532 connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), 532 connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)),
533 SLOT(selectionChanged(QListViewItem *))); 533 SLOT(selectionChanged(QListViewItem *)));
534 connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), 534 connect(mTodoListView,SIGNAL(clicked(QListViewItem *)),
535 SLOT(selectionChanged(QListViewItem *))); 535 SLOT(selectionChanged(QListViewItem *)));
536 connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), 536 connect(mTodoListView,SIGNAL(pressed(QListViewItem *)),
537 SLOT(selectionChanged(QListViewItem *))); 537 SLOT(selectionChanged(QListViewItem *)));
538#endif 538#endif
539 539
540 connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); 540 connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) ));
541 connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); 541 connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) ));
542 connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); 542 connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) ));
543 543
544 connect( mTodoListView, SIGNAL(selectionChanged() ), 544 connect( mTodoListView, SIGNAL(selectionChanged() ),
545 SLOT( processSelectionChange() ) ); 545 SLOT( processSelectionChange() ) );
546 connect( mQuickAdd, SIGNAL( returnPressed () ), 546 connect( mQuickAdd, SIGNAL( returnPressed () ),
547 SLOT( addQuickTodo() ) ); 547 SLOT( addQuickTodo() ) );
548 548
549} 549}
550 550
551KOTodoView::~KOTodoView() 551KOTodoView::~KOTodoView()
552{ 552{
553 delete mDocPrefs; 553 delete mDocPrefs;
554} 554}
555QString KOTodoView::getWhatsThisText(QPoint p) 555QString KOTodoView::getWhatsThisText(QPoint p)
556{ 556{
557 KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p ); 557 KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p );
558 if ( item ) 558 if ( item )
559 return KIncidenceFormatter::instance()->getFormattedText( item->todo(), 559 return KIncidenceFormatter::instance()->getFormattedText( item->todo(),
560 KOPrefs::instance()->mWTshowDetails, 560 KOPrefs::instance()->mWTshowDetails,
561 KOPrefs::instance()->mWTshowCreated, 561 KOPrefs::instance()->mWTshowCreated,
562 KOPrefs::instance()->mWTshowChanged); 562 KOPrefs::instance()->mWTshowChanged);
563 return i18n("That is the todo view" ); 563 return i18n("That is the todo view" );
564 564
565} 565}
566 566
567void KOTodoView::jumpToDate () 567void KOTodoView::jumpToDate ()
568{ 568{
569 // if (mActiveItem) { 569 // if (mActiveItem) {
570// mActiveItem->todo()); 570// mActiveItem->todo());
571// if ( mActiveItem->todo()->hasDueDate() ) 571// if ( mActiveItem->todo()->hasDueDate() )
572// emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); 572// emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() );
573} 573}
574void KOTodoView::paintNeeded() 574void KOTodoView::paintNeeded()
575{ 575{
576 if ( mPendingUpdateBeforeRepaint ) { 576 if ( mPendingUpdateBeforeRepaint ) {
577 updateView(); 577 updateView();
578 mPendingUpdateBeforeRepaint = false; 578 mPendingUpdateBeforeRepaint = false;
579 } 579 }
580} 580}
581void KOTodoView::paintEvent(QPaintEvent * pevent) 581void KOTodoView::paintEvent(QPaintEvent * pevent)
582{ 582{
583 if ( mPendingUpdateBeforeRepaint ) { 583 if ( mPendingUpdateBeforeRepaint ) {
584 updateView(); 584 updateView();
585 mPendingUpdateBeforeRepaint = false; 585 mPendingUpdateBeforeRepaint = false;
586 } 586 }
587 KOrg::BaseView::paintEvent( pevent); 587 KOrg::BaseView::paintEvent( pevent);
588} 588}
589 589
590void KOTodoView::updateView() 590void KOTodoView::updateView()
591{ 591{
592 pendingSubtodo = 0; 592 pendingSubtodo = 0;
593 if ( mBlockUpdate ) { 593 if ( mBlockUpdate ) {
594 return; 594 return;
595 } 595 }
596 if ( !isVisible() ) { 596 if ( !isVisible() ) {
597 mPendingUpdateBeforeRepaint = true; 597 mPendingUpdateBeforeRepaint = true;
598 return; 598 return;
599 } 599 }
600 //qDebug("KOTodoView::updateView() %x", this); 600 //qDebug("KOTodoView::updateView() %x", this);
601 if ( isFlatDisplay ) { 601 if ( isFlatDisplay ) {
602 displayAllFlat(); 602 displayAllFlat();
603 return; 603 return;
604 } 604 }
605 //qDebug("update "); 605 //qDebug("update ");
606// kdDebug() << "KOTodoView::updateView()" << endl; 606// kdDebug() << "KOTodoView::updateView()" << endl;
607 QFont fo = KOPrefs::instance()->mTodoViewFont; 607 QFont fo = KOPrefs::instance()->mTodoViewFont;
608 Incidence* oldInc = 0;
609 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
610 if (mActiveItem)
611 oldInc = mActiveItem->todo();
612
608 mTodoListView->clear(); 613 mTodoListView->clear();
609 if ( mName == "todolistsmall" ) { 614 if ( mName == "todolistsmall" ) {
610 if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { 615 if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) {
611 int ps = fo.pointSize() -2; 616 int ps = fo.pointSize() -2;
612 if ( ps > 12 ) 617 if ( ps > 12 )
613 ps -= 2; 618 ps -= 2;
614 fo.setPointSize( ps ); 619 fo.setPointSize( ps );
615 } 620 }
616 } 621 }
617 622
618 mTodoListView->setFont( fo ); 623 mTodoListView->setFont( fo );
619 // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); 624 // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont );
620 //mTodoListView->header()->setMaximumHeight(fm.height()); 625 //mTodoListView->header()->setMaximumHeight(fm.height());
621 QPtrList<Todo> todoList = calendar()->todos(); 626 QPtrList<Todo> todoList = calendar()->todos();
622 627
623/* 628/*
624 kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; 629 kdDebug() << "KOTodoView::updateView(): Todo List:" << endl;
625 Event *t; 630 Event *t;
626 for(t = todoList.first(); t; t = todoList.next()) { 631 for(t = todoList.first(); t; t = todoList.next()) {
627 kdDebug() << " " << t->getSummary() << endl; 632 kdDebug() << " " << t->getSummary() << endl;
628 633
629 if (t->getRelatedTo()) { 634 if (t->getRelatedTo()) {
630 kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; 635 kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl;
631 } 636 }
632 637
633 QPtrList<Event> l = t->getRelations(); 638 QPtrList<Event> l = t->getRelations();
634 Event *c; 639 Event *c;
635 for(c=l.first();c;c=l.next()) { 640 for(c=l.first();c;c=l.next()) {
636 kdDebug() << " - relation: " << c->getSummary() << endl; 641 kdDebug() << " - relation: " << c->getSummary() << endl;
637 } 642 }
638 } 643 }
639*/ 644*/
640 645
641 // Put for each Event a KOTodoViewItem in the list view. Don't rely on a 646 // Put for each Event a KOTodoViewItem in the list view. Don't rely on a
642 // specific order of events. That means that we have to generate parent items 647 // specific order of events. That means that we have to generate parent items
643 // recursively for proper hierarchical display of Todos. 648 // recursively for proper hierarchical display of Todos.
644 mTodoMap.clear(); 649 mTodoMap.clear();
645 Todo *todo; 650 Todo *todo;
646 todo = todoList.first();// todo; todo = todoList.next()) { 651 todo = todoList.first();// todo; todo = todoList.next()) {
647 while ( todo ) { 652 while ( todo ) {
648 bool next = true; 653 bool next = true;
649 // qDebug("todo %s ", todo->summary().latin1()); 654 // qDebug("todo %s ", todo->summary().latin1());
650 Incidence *incidence = todo->relatedTo(); 655 Incidence *incidence = todo->relatedTo();
651 while ( incidence ) { 656 while ( incidence ) {
652 if ( incidence->type() == "Todo") { 657 if ( incidence->type() == "Todo") {
653 //qDebug("related %s ",incidence->summary().latin1() ); 658 //qDebug("related %s ",incidence->summary().latin1() );
654 if ( !(todoList.contains ( ((Todo* )incidence ) ) )) { 659 if ( !(todoList.contains ( ((Todo* )incidence ) ) )) {
655 //qDebug("related not found "); 660 //qDebug("related not found ");
656 todoList.remove( ); 661 todoList.remove( );
657 todo = todoList.current(); 662 todo = todoList.current();
658 next = false; 663 next = false;
659 incidence = 0; 664 incidence = 0;
660 665
661 } else { 666 } else {
662 //qDebug("related found "); 667 //qDebug("related found ");
663 incidence = incidence->relatedTo(); 668 incidence = incidence->relatedTo();
664 } 669 }
665 } else 670 } else
666 incidence = 0; 671 incidence = 0;
667 } 672 }
668 if ( next ) 673 if ( next )
669 todo = todoList.next(); 674 todo = todoList.next();
670 } 675 }
671// qDebug("again .... "); 676// qDebug("again .... ");
672// for(todo = todoList.first(); todo; todo = todoList.next()) { 677// for(todo = todoList.first(); todo; todo = todoList.next()) {
673 678
674// qDebug("yytodo %s ", todo->summary().latin1()); 679// qDebug("yytodo %s ", todo->summary().latin1());
675// } 680// }
676 //qDebug("for "); 681 //qDebug("for ");
677 for(todo = todoList.first(); todo; todo = todoList.next()) { 682 for(todo = todoList.first(); todo; todo = todoList.next()) {
678 if (!mTodoMap.contains(todo) && checkTodo( todo ) ) 683 if (!mTodoMap.contains(todo) && checkTodo( todo ) )
679 { 684 {
680 insertTodoItem(todo); 685 insertTodoItem(todo);
681 } 686 }
682 } 687 }
683 //qDebug("for end "); 688 //qDebug("for end ");
684 // Restore opened/closed state 689 // Restore opened/closed state
685 mTodoListView->blockSignals( true ); 690 mTodoListView->blockSignals( true );
686 if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); 691 if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() );
687 mTodoListView->blockSignals( false ); 692 mTodoListView->blockSignals( false );
688 mTodoListView->setFocus(); 693 mTodoListView->setFocus();
694 if ( mTodoListView->firstChild () ) {
695 if ( oldInc ) {
696 KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild ();
697 while ( item ) {
698 if ( item->todo() == oldInc ) {
699 mTodoListView->setCurrentItem( item );
700 mTodoListView->ensureItemVisible( item );
701 break;
702 }
703 item = (KOTodoViewItem*)item->itemBelow();
704 }
705 if ( ! item )
706 mTodoListView->setCurrentItem( mTodoListView->firstChild () );
707 } else {
708 mTodoListView->setCurrentItem( mTodoListView->firstChild () );
709 }
710 }
689 processSelectionChange(); 711 processSelectionChange();
690} 712}
691 713
692bool KOTodoView::checkTodo( Todo * todo ) 714bool KOTodoView::checkTodo( Todo * todo )
693{ 715{
694 716
695 if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) 717 if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() )
696 return false; 718 return false;
697 if ( !todo->isCompleted() ) { 719 if ( !todo->isCompleted() ) {
698 if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) 720 if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() )
699 return true; 721 return true;
700 } 722 }
701 if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { 723 if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) {
702 if ( todo->hasStartDate() ) 724 if ( todo->hasStartDate() )
703 if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) 725 if ( mNavigator->selectedDates().last() < todo->dtStart().date() )
704 return false; 726 return false;
705 if ( todo->hasDueDate() ) 727 if ( todo->hasDueDate() )
706 if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) 728 if ( mNavigator->selectedDates().first() > todo->dtDue().date() )
707 return false; 729 return false;
708 } 730 }
709 return true; 731 return true;
710} 732}
711 733
712void KOTodoView::restoreItemState( QListViewItem *item ) 734void KOTodoView::restoreItemState( QListViewItem *item )
713{ 735{
714 pendingSubtodo = 0; 736 pendingSubtodo = 0;
715 while( item ) { 737 while( item ) {
716 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 738 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
717 todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); 739 todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) );
718 if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); 740 if( item->childCount() > 0 ) restoreItemState( item->firstChild() );
719 item = item->nextSibling(); 741 item = item->nextSibling();
720 } 742 }
721} 743}
722 744
723 745
724QMap<Todo *,KOTodoViewItem *>::ConstIterator 746QMap<Todo *,KOTodoViewItem *>::ConstIterator
725 KOTodoView::insertTodoItem(Todo *todo) 747 KOTodoView::insertTodoItem(Todo *todo)
726{ 748{
727 749
728// kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; 750// kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl;
729 // TODO: Check, if dynmaic cast is necessary 751 // TODO: Check, if dynmaic cast is necessary
730 752
731 pendingSubtodo = 0; 753 pendingSubtodo = 0;
732 Incidence *incidence = todo->relatedTo(); 754 Incidence *incidence = todo->relatedTo();
733 if (incidence && incidence->type() == "Todo") { 755 if (incidence && incidence->type() == "Todo") {
734 Todo *relatedTodo = static_cast<Todo *>(incidence); 756 Todo *relatedTodo = static_cast<Todo *>(incidence);
735 757
736// kdDebug() << " has Related" << endl; 758// kdDebug() << " has Related" << endl;
737 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; 759 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator;
738 itemIterator = mTodoMap.find(relatedTodo); 760 itemIterator = mTodoMap.find(relatedTodo);
739 if (itemIterator == mTodoMap.end()) { 761 if (itemIterator == mTodoMap.end()) {
740// kdDebug() << " related not yet in list" << endl; 762// kdDebug() << " related not yet in list" << endl;
741 itemIterator = insertTodoItem (relatedTodo); 763 itemIterator = insertTodoItem (relatedTodo);
742 } 764 }
743 // isn't this pretty stupid? We give one Todo to the KOTodoViewItem 765 // isn't this pretty stupid? We give one Todo to the KOTodoViewItem
744 // and one into the map. Sure finding is more easy but why? -zecke 766 // and one into the map. Sure finding is more easy but why? -zecke
745 KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); 767 KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this);
746 return mTodoMap.insert(todo,todoItem); 768 return mTodoMap.insert(todo,todoItem);
747 } else { 769 } else {
748// kdDebug() << " no Related" << endl; 770// kdDebug() << " no Related" << endl;
749 // see above -zecke 771 // see above -zecke
750 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); 772 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this);
751 return mTodoMap.insert(todo,todoItem); 773 return mTodoMap.insert(todo,todoItem);
752 } 774 }
753} 775}
754 776
755 777
756void KOTodoView::updateConfig() 778void KOTodoView::updateConfig()
757{ 779{
758 updateView(); 780 updateView();
759 mTodoListView->repaintContents(); 781 mTodoListView->repaintContents();
760} 782}
761 783
762QPtrList<Incidence> KOTodoView::selectedIncidences() 784QPtrList<Incidence> KOTodoView::selectedIncidences()
763{ 785{
764 QPtrList<Incidence> selected; 786 QPtrList<Incidence> selected;
765 787
766 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); 788 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem());
767// if (!item) item = mActiveItem; 789// if (!item) item = mActiveItem;
768 if (item) selected.append(item->todo()); 790 if (item) selected.append(item->todo());
769 791
770 return selected; 792 return selected;
771} 793}
772 794
773QPtrList<Todo> KOTodoView::selectedTodos() 795QPtrList<Todo> KOTodoView::selectedTodos()
774{ 796{
775 QPtrList<Todo> selected; 797 QPtrList<Todo> selected;
776 798
777 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); 799 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem());
778// if (!item) item = mActiveItem; 800// if (!item) item = mActiveItem;
779 if (item) selected.append(item->todo()); 801 if (item) selected.append(item->todo());
780 802
781 return selected; 803 return selected;
782} 804}
783 805
784void KOTodoView::changeEventDisplay(Event *, int) 806void KOTodoView::changeEventDisplay(Event *, int)
785{ 807{
786 updateView(); 808 updateView();
787} 809}
788 810
789void KOTodoView::showDates(const QDate &, const QDate &) 811void KOTodoView::showDates(const QDate &, const QDate &)
790{ 812{
791} 813}
792 814
793void KOTodoView::showEvents(QPtrList<Event>) 815void KOTodoView::showEvents(QPtrList<Event>)
794{ 816{
795 kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; 817 kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl;
796} 818}
797 819
798void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, 820void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd,
799 const QDate &td) 821 const QDate &td)
800{ 822{
801#ifndef KORG_NOPRINTER 823#ifndef KORG_NOPRINTER
802 calPrinter->preview(CalPrinter::Todolist, fd, td); 824 calPrinter->preview(CalPrinter::Todolist, fd, td);
803#endif 825#endif
804} 826}
805 827
806void KOTodoView::editItem(QListViewItem *item ) 828void KOTodoView::editItem(QListViewItem *item )
807{ 829{
808 // qDebug("editItem(QListViewItem *item ) "); 830 // qDebug("editItem(QListViewItem *item ) ");
809 emit editTodoSignal(((KOTodoViewItem *)item)->todo()); 831 emit editTodoSignal(((KOTodoViewItem *)item)->todo());
810} 832}
811 833
812void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) 834void KOTodoView::showItem(QListViewItem *item,const QPoint &,int)
813{ 835{
814 emit showTodoSignal(((KOTodoViewItem *)item)->todo()); 836 emit showTodoSignal(((KOTodoViewItem *)item)->todo());
815} 837}
816 838
817void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) 839void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column)
818{ 840{
819 pendingSubtodo = 0; 841 pendingSubtodo = 0;
820 mActiveItem = (KOTodoViewItem *)item; 842 mActiveItem = (KOTodoViewItem *)item;
821 if (item) { 843 if (item) {
822 switch (column){ 844 switch (column){
823 case 1: 845 case 1:
824 mPriorityPopupMenu->popup(QCursor::pos ()); break; 846 mPriorityPopupMenu->popup(QCursor::pos ()); break;
825 case 2: 847 case 2:
826 mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; 848 mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break;
827 case 3: 849 case 3:
828 moveTodo(); 850 moveTodo();
829 break; 851 break;
830 case 8: 852 case 8:
831 getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; 853 getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break;
832 default: 854 default:
833 mItemPopupMenu->popup(QCursor::pos()); 855 mItemPopupMenu->popup(QCursor::pos());
834 } 856 }
835 } else mPopupMenu->popup(QCursor::pos()); 857 } else mPopupMenu->popup(QCursor::pos());
836} 858}
837void KOTodoView::newTodo() 859void KOTodoView::newTodo()
838{ 860{
839 emit newTodoSignal(); 861 emit newTodoSignal();
840} 862}
841 863
842void KOTodoView::newSubTodo() 864void KOTodoView::newSubTodo()
843{ 865{
844 if (mActiveItem) { 866 if (mActiveItem) {
845 emit newSubTodoSignal(mActiveItem->todo()); 867 emit newSubTodoSignal(mActiveItem->todo());
846 } 868 }
847} 869}
848void KOTodoView::unparentTodo() 870void KOTodoView::unparentTodo()
849{ 871{
850 if (mActiveItem) { 872 if (mActiveItem) {
851 emit unparentTodoSignal(mActiveItem->todo()); 873 emit unparentTodoSignal(mActiveItem->todo());
852 } 874 }
853} 875}
854 876
855void KOTodoView::reparentTodo() 877void KOTodoView::reparentTodo()
856{ 878{
857 if (mActiveItem) { 879 if (mActiveItem) {
858 qDebug("KOTodoView::reparentTodo() "); 880 qDebug("KOTodoView::reparentTodo() ");
859 topLevelWidget()->setCaption(i18n("Click on new parent item")); 881 topLevelWidget()->setCaption(i18n("Click on new parent item"));
860 pendingSubtodo = mActiveItem; 882 pendingSubtodo = mActiveItem;
861 } 883 }
862} 884}
863void KOTodoView::editTodo() 885void KOTodoView::editTodo()
864{ 886{
865 if (mActiveItem) { 887 if (mActiveItem) {
866 emit editTodoSignal(mActiveItem->todo()); 888 emit editTodoSignal(mActiveItem->todo());
867 } 889 }
868} 890}
869void KOTodoView::cloneTodo() 891void KOTodoView::cloneTodo()
870{ 892{
871 if (mActiveItem) { 893 if (mActiveItem) {
872 emit cloneTodoSignal((Incidence*)mActiveItem->todo()); 894 emit cloneTodoSignal((Incidence*)mActiveItem->todo());
873 } 895 }
874} 896}
875void KOTodoView::cancelTodo() 897void KOTodoView::cancelTodo()
876{ 898{
877 if (mActiveItem) { 899 if (mActiveItem) {
878 emit cancelTodoSignal((Incidence*)mActiveItem->todo()); 900 emit cancelTodoSignal((Incidence*)mActiveItem->todo());
879 } 901 }
880} 902}
881void KOTodoView::moveTodo() 903void KOTodoView::moveTodo()
882{ 904{
883 if (mActiveItem) { 905 if (mActiveItem) {
884 emit moveTodoSignal((Incidence*)mActiveItem->todo()); 906 emit moveTodoSignal((Incidence*)mActiveItem->todo());
885 } 907 }
886} 908}
887void KOTodoView::beamTodo() 909void KOTodoView::beamTodo()
888{ 910{
889 if (mActiveItem) { 911 if (mActiveItem) {
890 emit beamTodoSignal((Incidence*)mActiveItem->todo()); 912 emit beamTodoSignal((Incidence*)mActiveItem->todo());
891 } 913 }
892} 914}
893 915
894 916
895void KOTodoView::showTodo() 917void KOTodoView::showTodo()
896{ 918{
897 if (mActiveItem) { 919 if (mActiveItem) {
898 emit showTodoSignal(mActiveItem->todo()); 920 emit showTodoSignal(mActiveItem->todo());
899 } 921 }
900} 922}
901 923
902void KOTodoView::deleteTodo() 924void KOTodoView::deleteTodo()
903{ 925{
904 if (mActiveItem) { 926 if (mActiveItem) {
905 emit deleteTodoSignal(mActiveItem->todo()); 927 emit deleteTodoSignal(mActiveItem->todo());
906 } 928 }
907} 929}
908 930
909void KOTodoView::setNewPriority(int index) 931void KOTodoView::setNewPriority(int index)
910{ 932{
911 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 933 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
912 mActiveItem->todo()->setPriority(mPriority[index]); 934 mActiveItem->todo()->setPriority(mPriority[index]);
913 mActiveItem->construct(); 935 mActiveItem->construct();
914 todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); 936 todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED);
915 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 937 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
916 } 938 }
917} 939}
918 940
919void KOTodoView::setNewPercentage(int index) 941void KOTodoView::setNewPercentage(int index)
920{ 942{
921 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 943 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
922 944
923 if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { 945 if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) {
924 mActiveItem->setOn( true ); 946 mActiveItem->setOn( true );
925 return; 947 return;
926 } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { 948 } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) {
927 KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); 949 KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent()));
928 if ( par && par->isOn() ) 950 if ( par && par->isOn() )
929 par->setOn( false ); 951 par->setOn( false );
930 } 952 }
931 if (mPercentage[index] == 100) { 953 if (mPercentage[index] == 100) {
932 mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); 954 mActiveItem->todo()->setCompleted(QDateTime::currentDateTime());
933 } else { 955 } else {
934 mActiveItem->todo()->setCompleted(false); 956 mActiveItem->todo()->setCompleted(false);
935 } 957 }
936 mActiveItem->todo()->setPercentComplete(mPercentage[index]); 958 mActiveItem->todo()->setPercentComplete(mPercentage[index]);
937 mActiveItem->construct(); 959 mActiveItem->construct();
938 todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); 960 todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED);
939 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 961 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
940 } 962 }
941} 963}
942 964
943 965
944QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) 966QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem)
945{ 967{
946 QPopupMenu* tempMenu = new QPopupMenu (this); 968 QPopupMenu* tempMenu = new QPopupMenu (this);
947 QStringList checkedCategories = todoItem->todo()->categories (); 969 QStringList checkedCategories = todoItem->todo()->categories ();
948 970
949 tempMenu->setCheckable (true); 971 tempMenu->setCheckable (true);
950 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); 972 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin ();
951 it != KOPrefs::instance()->mCustomCategories.end (); 973 it != KOPrefs::instance()->mCustomCategories.end ();
952 ++it) { 974 ++it) {
953 int index = tempMenu->insertItem (*it); 975 int index = tempMenu->insertItem (*it);
954 mCategory[index] = *it; 976 mCategory[index] = *it;
955 if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); 977 if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true);
956 } 978 }
957 979
958 connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); 980 connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int)));
959 return tempMenu; 981 return tempMenu;
960 982
961 983
962} 984}
963void KOTodoView::changedCategories(int index) 985void KOTodoView::changedCategories(int index)
964{ 986{
965 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 987 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
966 QStringList categories = mActiveItem->todo()->categories (); 988 QStringList categories = mActiveItem->todo()->categories ();
967 QString colcat = categories.first(); 989 QString colcat = categories.first();
968 if (categories.find (mCategory[index]) != categories.end ()) 990 if (categories.find (mCategory[index]) != categories.end ())
969 categories.remove (mCategory[index]); 991 categories.remove (mCategory[index]);
970 else 992 else
971 categories.insert (categories.end(), mCategory[index]); 993 categories.insert (categories.end(), mCategory[index]);
972 categories.sort (); 994 categories.sort ();
973 if ( !colcat.isEmpty() ) { 995 if ( !colcat.isEmpty() ) {
974 if ( categories.find ( colcat ) != categories.end () ) { 996 if ( categories.find ( colcat ) != categories.end () ) {
975 categories.remove( colcat ); 997 categories.remove( colcat );
976 categories.prepend( colcat ); 998 categories.prepend( colcat );
977 } 999 }
978 } 1000 }
979 mActiveItem->todo()->setCategories (categories); 1001 mActiveItem->todo()->setCategories (categories);
980 mActiveItem->construct(); 1002 mActiveItem->construct();
981 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 1003 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
982 todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); 1004 todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED);
983 } 1005 }
984} 1006}
985void KOTodoView::itemDoubleClicked(QListViewItem *item) 1007void KOTodoView::itemDoubleClicked(QListViewItem *item)
986{ 1008{
987 if ( pendingSubtodo != 0 ) { 1009 if ( pendingSubtodo != 0 ) {
988 topLevelWidget()->setCaption(i18n("Reparenting aborted!")); 1010 topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
989 } 1011 }
990 pendingSubtodo = 0; 1012 pendingSubtodo = 0;
991 if (!item) { 1013 if (!item) {
992 newTodo(); 1014 newTodo();
993 return; 1015 return;
994 } 1016 }
995 if ( KOPrefs::instance()->mEditOnDoubleClick ) 1017 if ( KOPrefs::instance()->mEditOnDoubleClick )
996 editItem( item ); 1018 editItem( item );
997 else 1019 else
998 showItem( item , QPoint(), 0 ); 1020 showItem( item , QPoint(), 0 );
999} 1021}
1000void KOTodoView::itemClicked(QListViewItem *item) 1022void KOTodoView::itemClicked(QListViewItem *item)
1001{ 1023{
1002 1024
1003 if (!item) { 1025 if (!item) {
1004 if ( pendingSubtodo != 0 ) { 1026 if ( pendingSubtodo != 0 ) {
1005 topLevelWidget()->setCaption(i18n("Reparenting aborted!")); 1027 topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
1006 } 1028 }
1007 pendingSubtodo = 0; 1029 pendingSubtodo = 0;
1008 return; 1030 return;
1009 } 1031 }
1010 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 1032 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
1011 if ( pendingSubtodo != 0 ) { 1033 if ( pendingSubtodo != 0 ) {
1012 bool allowReparent = true; 1034 bool allowReparent = true;
1013 QListViewItem *par = item; 1035 QListViewItem *par = item;
1014 while ( par ) { 1036 while ( par ) {
1015 if ( par == pendingSubtodo ) { 1037 if ( par == pendingSubtodo ) {
1016 allowReparent = false; 1038 allowReparent = false;
1017 break; 1039 break;
1018 } 1040 }
1019 par = par->parent(); 1041 par = par->parent();
1020 } 1042 }
1021 if ( !allowReparent ) { 1043 if ( !allowReparent ) {
1022 topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); 1044 topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!"));
1023 qDebug("Recursive reparenting not possible "); 1045 qDebug("Recursive reparenting not possible ");
1024 pendingSubtodo = 0; 1046 pendingSubtodo = 0;
1025 } else { 1047 } else {
1026 Todo* newParent = todoItem->todo(); 1048 Todo* newParent = todoItem->todo();
1027 Todo* newSub = pendingSubtodo->todo(); 1049 Todo* newSub = pendingSubtodo->todo();
1028 pendingSubtodo = 0; 1050 pendingSubtodo = 0;
1029 emit reparentTodoSignal( newParent,newSub ); 1051 emit reparentTodoSignal( newParent,newSub );
1030 return; 1052 return;
1031 } 1053 }
1032 } 1054 }
1033#if 0 1055#if 0
1034 // handled by the item itself 1056 // handled by the item itself
1035 bool completed = todoItem->todo()->isCompleted(); // Completed or not? 1057 bool completed = todoItem->todo()->isCompleted(); // Completed or not?
1036 qDebug("com %d ",completed ); 1058 qDebug("com %d ",completed );
1037 qDebug("itemclicked "); 1059 qDebug("itemclicked ");
1038 if (todoItem->isOn()) { 1060 if (todoItem->isOn()) {
1039 qDebug("on "); 1061 qDebug("on ");
1040 if (!completed) { 1062 if (!completed) {
1041 qDebug("set true "); 1063 qDebug("set true ");
1042 todoItem->todo()->setCompleted(QDateTime::currentDateTime()); 1064 todoItem->todo()->setCompleted(QDateTime::currentDateTime());
1043 } 1065 }
1044 } else { 1066 } else {
1045 qDebug("not on "); 1067 qDebug("not on ");
1046 if (completed) { 1068 if (completed) {
1047 qDebug("set false "); 1069 qDebug("set false ");
1048 todoItem->todo()->setCompleted(false); 1070 todoItem->todo()->setCompleted(false);
1049 } 1071 }
1050 } 1072 }
1051#endif 1073#endif
1052} 1074}
1053 1075
1054void KOTodoView::setDocumentId( const QString &id ) 1076void KOTodoView::setDocumentId( const QString &id )
1055{ 1077{
1056 kdDebug() << "KOTodoView::setDocumentId()" << endl; 1078 kdDebug() << "KOTodoView::setDocumentId()" << endl;
1057 1079
1058 mDocPrefs->setDoc( id ); 1080 mDocPrefs->setDoc( id );
1059} 1081}
1060 1082
1061void KOTodoView::itemStateChanged( QListViewItem *item ) 1083void KOTodoView::itemStateChanged( QListViewItem *item )
1062{ 1084{
1063 if (!item) return; 1085 if (!item) return;
1064 1086
1065 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 1087 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
1066 1088
1067// kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; 1089// kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl;
1068 1090
1069 if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); 1091 if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() );
1070} 1092}
1071 1093
1072void KOTodoView::saveLayout(KConfig *config, const QString &group) const 1094void KOTodoView::saveLayout(KConfig *config, const QString &group) const
1073{ 1095{
1074 mTodoListView->saveLayout(config,group); 1096 mTodoListView->saveLayout(config,group);
1075} 1097}
1076 1098
1077void KOTodoView::restoreLayout(KConfig *config, const QString &group) 1099void KOTodoView::restoreLayout(KConfig *config, const QString &group)
1078{ 1100{
1079 mTodoListView->restoreLayout(config,group); 1101 mTodoListView->restoreLayout(config,group);
1080} 1102}
1081 1103
1082void KOTodoView::processSelectionChange() 1104void KOTodoView::processSelectionChange()
1083{ 1105{
1084// kdDebug() << "KOTodoView::processSelectionChange()" << endl; 1106// kdDebug() << "KOTodoView::processSelectionChange()" << endl;
1085 1107
1086 KOTodoViewItem *item = 1108 KOTodoViewItem *item =
1087 static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); 1109 static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() );
1088 1110
1089 if ( !item ) { 1111 if ( !item ) {
1090 emit incidenceSelected( 0 ); 1112 emit incidenceSelected( 0 );
1091 } else { 1113 } else {
1092 emit incidenceSelected( item->todo() ); 1114 emit incidenceSelected( item->todo() );
1093 } 1115 }
1094} 1116}
1095 1117
1096void KOTodoView::modified(bool b) 1118void KOTodoView::modified(bool b)
1097{ 1119{
1098 emit isModified(b); 1120 emit isModified(b);
1099} 1121}
1100void KOTodoView::setTodoModified( Todo* todo ) 1122void KOTodoView::setTodoModified( Todo* todo )
1101{ 1123{
1102 todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); 1124 todoModified( todo, KOGlobals::UNKNOWN_MODIFIED );
1103} 1125}
1104void KOTodoView::clearSelection() 1126void KOTodoView::clearSelection()
1105{ 1127{
1106 mTodoListView->selectAll( false ); 1128 mTodoListView->selectAll( false );
1107} 1129}
1108void KOTodoView::setAllOpen() 1130void KOTodoView::setAllOpen()
1109{ 1131{
1110 if ( isFlatDisplay ) { 1132 if ( isFlatDisplay ) {
1111 isFlatDisplay = false; 1133 isFlatDisplay = false;
1112 mPopupMenu->setItemChecked( 8,false ); 1134 mPopupMenu->setItemChecked( 8,false );
1113 updateView(); 1135 updateView();
1114 } 1136 }
1115 setOpen(mTodoListView->firstChild(), true); 1137 setOpen(mTodoListView->firstChild(), true);
1116} 1138}
1117void KOTodoView::setAllClose() 1139void KOTodoView::setAllClose()
1118{ 1140{
1119 if ( isFlatDisplay ) { 1141 if ( isFlatDisplay ) {
1120 isFlatDisplay = false; 1142 isFlatDisplay = false;
1121 mPopupMenu->setItemChecked( 8,false ); 1143 mPopupMenu->setItemChecked( 8,false );
1122 updateView(); 1144 updateView();
1123 } 1145 }
1124 setOpen(mTodoListView->firstChild(), false); 1146 setOpen(mTodoListView->firstChild(), false);
1125} 1147}
1126void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) 1148void KOTodoView::setOpen( QListViewItem* item, bool setOpenI)
1127{ 1149{
1128 1150
1129 while ( item ) { 1151 while ( item ) {
1130 setOpen( item->firstChild(), setOpenI ); 1152 setOpen( item->firstChild(), setOpenI );
1131 item->setOpen( setOpenI ); 1153 item->setOpen( setOpenI );
1132 item = item->nextSibling(); 1154 item = item->nextSibling();
1133 } 1155 }
1134} 1156}
1135 1157
1136void KOTodoView::displayAllFlat() 1158void KOTodoView::displayAllFlat()
1137{ 1159{
1138 pendingSubtodo = 0; 1160 pendingSubtodo = 0;
1139 if ( mBlockUpdate ) { 1161 if ( mBlockUpdate ) {
1140 return; 1162 return;
1141 } 1163 }
1142 mPopupMenu->setItemChecked( 8,true ); 1164 mPopupMenu->setItemChecked( 8,true );
1143 isFlatDisplay = true; 1165 isFlatDisplay = true;
1144 QPtrList<Todo> todoList = calendar()->todos(); 1166 QPtrList<Todo> todoList = calendar()->todos();
1145 mTodoMap.clear(); 1167 mTodoMap.clear();
1146 mTodoListView->clear(); 1168 mTodoListView->clear();
1147 Todo *todo; 1169 Todo *todo;
1148 for(todo = todoList.first(); todo; todo = todoList.next()) { 1170 for(todo = todoList.first(); todo; todo = todoList.next()) {
1149 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); 1171 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this);
1150 mTodoMap.insert(todo,todoItem); 1172 mTodoMap.insert(todo,todoItem);
1151 } 1173 }
1152 mTodoListView->setFocus(); 1174 mTodoListView->setFocus();
1153 processSelectionChange(); 1175 processSelectionChange();
1154} 1176}
1155 1177
1156void KOTodoView::setAllFlat() 1178void KOTodoView::setAllFlat()
1157{ 1179{
1158 if ( isFlatDisplay ) { 1180 if ( isFlatDisplay ) {
1159 isFlatDisplay = false; 1181 isFlatDisplay = false;
1160 mPopupMenu->setItemChecked( 8,false ); 1182 mPopupMenu->setItemChecked( 8,false );
1161 updateView(); 1183 updateView();
1162 return; 1184 return;
1163 } 1185 }
1164 displayAllFlat(); 1186 displayAllFlat();
1165} 1187}
1166 1188
1167void KOTodoView::purgeCompleted() 1189void KOTodoView::purgeCompleted()
1168{ 1190{
1169 emit purgeCompletedSignal(); 1191 emit purgeCompletedSignal();
1170} 1192}
1171void KOTodoView::toggleQuickTodo() 1193void KOTodoView::toggleQuickTodo()
1172{ 1194{
1173 if ( mQuickAdd->isVisible() ) { 1195 if ( mQuickAdd->isVisible() ) {
1174 mQuickAdd->hide(); 1196 mQuickAdd->hide();
1175 KOPrefs::instance()->mEnableQuickTodo = false; 1197 KOPrefs::instance()->mEnableQuickTodo = false;
1176 } 1198 }
1177 else { 1199 else {
1178 mQuickAdd->show(); 1200 mQuickAdd->show();
1179 KOPrefs::instance()->mEnableQuickTodo = true; 1201 KOPrefs::instance()->mEnableQuickTodo = true;
1180 } 1202 }
1181 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); 1203 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo);
1182 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); 1204 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo );
1183} 1205}
1184 1206
1185void KOTodoView::toggleRunning() 1207void KOTodoView::toggleRunning()
1186{ 1208{
1187 KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; 1209 KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos;
1188 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); 1210 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos);
1189 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); 1211 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos );
1190 updateView(); 1212 updateView();
1191} 1213}
1192 1214
1193void KOTodoView::toggleCompleted() 1215void KOTodoView::toggleCompleted()
1194{ 1216{
1195 KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; 1217 KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo;
1196 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); 1218 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo );
1197 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); 1219 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo );
1198 updateView(); 1220 updateView();
1199} 1221}
1200 1222
1201void KOTodoView::addQuickTodo() 1223void KOTodoView::addQuickTodo()
1202{ 1224{
1203 Todo *todo = new Todo(); 1225 Todo *todo = new Todo();
1204 todo->setSummary(mQuickAdd->text()); 1226 todo->setSummary(mQuickAdd->text());
1205 todo->setOrganizer(KOPrefs::instance()->email()); 1227 todo->setOrganizer(KOPrefs::instance()->email());
1206 CalFilter * cf = mCalendar->filter(); 1228 CalFilter * cf = mCalendar->filter();
1207 if ( cf ) { 1229 if ( cf ) {
1208 if ( cf->isEnabled()&& cf->showCategories()) { 1230 if ( cf->isEnabled()&& cf->showCategories()) {
1209 todo->setCategories(cf->categoryList()); 1231 todo->setCategories(cf->categoryList());
1210 } 1232 }
1211 if ( cf->isEnabled() ) 1233 if ( cf->isEnabled() )
1212 todo->setSecrecy( cf->getSecrecy()); 1234 todo->setSecrecy( cf->getSecrecy());
1213 } 1235 }
1214 mCalendar->addTodo(todo); 1236 mCalendar->addTodo(todo);
1215 mQuickAdd->setText(""); 1237 mQuickAdd->setText("");
1216 todoModified (todo, KOGlobals::EVENTADDED ); 1238 todoModified (todo, KOGlobals::EVENTADDED );
1217 updateView(); 1239 updateView();
1218} 1240}
1219void KOTodoView::keyPressEvent ( QKeyEvent * e ) 1241void KOTodoView::keyPressEvent ( QKeyEvent * e )
1220{ 1242{
1221 // e->ignore(); 1243 // e->ignore();
1222 //return; 1244 //return;
1223 //qDebug("KOTodoView::keyPressEvent "); 1245 //qDebug("KOTodoView::keyPressEvent ");
1224 switch ( e->key() ) { 1246 switch ( e->key() ) {
1225 case Qt::Key_Down: 1247 case Qt::Key_Down:
1226 case Qt::Key_Up: 1248 case Qt::Key_Up:
1227 QWidget::keyPressEvent ( e ); 1249 QWidget::keyPressEvent ( e );
1228 break; 1250 break;
1229 1251
1230 case Qt::Key_Q: 1252 case Qt::Key_Q:
1231 toggleQuickTodo(); 1253 toggleQuickTodo();
1232 break; 1254 break;
1233 case Qt::Key_U: 1255 case Qt::Key_U:
1234 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { 1256 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) {
1235 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1257 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1236 unparentTodo(); 1258 unparentTodo();
1237 e->accept(); 1259 e->accept();
1238 } else 1260 } else
1239 e->ignore(); 1261 e->ignore();
1240 break; 1262 break;
1241 case Qt::Key_S: 1263 case Qt::Key_S:
1242 if ( e->state() == Qt::ControlButton ) { 1264 if ( e->state() == Qt::ControlButton ) {
1243 e->ignore(); 1265 e->ignore();
1244 break; 1266 break;
1245 } 1267 }
1246 if ( e->state() == Qt::ShiftButton ) { 1268 if ( e->state() == Qt::ShiftButton ) {
1247 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1269 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1248 reparentTodo(); 1270 reparentTodo();
1249 e->accept(); 1271 e->accept();
1250 } else 1272 } else
1251 e->ignore(); 1273 e->ignore();
1252 break; 1274 break;
1253 case Qt::Key_P: 1275 case Qt::Key_P:
1254 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { 1276 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) {
1255 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1277 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1256 if ( pendingSubtodo ) 1278 if ( pendingSubtodo )
1257 itemClicked(mActiveItem); 1279 itemClicked(mActiveItem);
1258 e->accept(); 1280 e->accept();
1259 } else 1281 } else
1260 e->ignore(); 1282 e->ignore();
1261 break; 1283 break;
1262 case Qt::Key_Escape: 1284 case Qt::Key_Escape:
1263 if ( pendingSubtodo ) { 1285 if ( pendingSubtodo ) {
1264 itemClicked(0); 1286 itemClicked(0);
1265 e->accept(); 1287 e->accept();
1266 } else 1288 } else
1267 e->ignore(); 1289 e->ignore();
1268 break; 1290 break;
1269 default: 1291 default:
1270 e->ignore(); 1292 e->ignore();
1271 } 1293 }
1272 1294
1273 if ( true ) { 1295 if ( true ) {
1274 if ( e->key() == Qt::Key_I ) { 1296 if ( e->key() == Qt::Key_I ) {
1275 KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); 1297 KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem();
1276 if ( cn ) { 1298 if ( cn ) {
1277 mActiveItem = cn; 1299 mActiveItem = cn;
1278 KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); 1300 KOTodoViewItem* ci = (KOTodoViewItem*)( cn );
1279 if ( ci ){ 1301 if ( ci ){
1280 showTodo(); 1302 showTodo();
1281 cn = (KOTodoViewItem*)cn->itemBelow(); 1303 cn = (KOTodoViewItem*)cn->itemBelow();
1282 if ( cn ) { 1304 if ( cn ) {
1283 mTodoListView->setCurrentItem ( cn ); 1305 mTodoListView->setCurrentItem ( cn );
1284 mTodoListView->ensureItemVisible ( cn ); 1306 mTodoListView->ensureItemVisible ( cn );
1285 } 1307 }
1286 1308
1287 } 1309 }
1288 } 1310 }
1289 e->accept(); 1311 e->accept();
1290 1312
1291 } 1313 }
1292 1314
1293 } 1315 }
1294 1316
1295} 1317}
1296void KOTodoView::updateTodo( Todo * t, int type ) 1318void KOTodoView::updateTodo( Todo * t, int type )
1297{ 1319{
1298 if ( mBlockUpdate) 1320 if ( mBlockUpdate)
1299 return; 1321 return;
1300 1322
1301 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; 1323 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator;
1302 itemIterator = mTodoMap.find(t); 1324 itemIterator = mTodoMap.find(t);
1303 if (itemIterator != mTodoMap.end()) { 1325 if (itemIterator != mTodoMap.end()) {
1304 (*itemIterator)->construct(); 1326 (*itemIterator)->construct();
1305 } else { 1327 } else {
1306 if ( type == KOGlobals::EVENTADDED ) { 1328 if ( type == KOGlobals::EVENTADDED ) {
1307 insertTodoItem( t ); 1329 insertTodoItem( t );
1308 } 1330 }
1309 } 1331 }
1310 1332
1311} 1333}
1312 1334
1313void KOTodoView::todoModified(Todo * t , int p ) 1335void KOTodoView::todoModified(Todo * t , int p )
1314{ 1336{
1315 mBlockUpdate = true; 1337 mBlockUpdate = true;
1316 emit todoModifiedSignal ( t, p ); 1338 emit todoModifiedSignal ( t, p );
1317 mBlockUpdate = false; 1339 mBlockUpdate = false;
1318} 1340}
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 4f2cccf..2de7f28 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1,2095 +1,2094 @@
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 mClosed = false; 136 mClosed = false;
137 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc"; 137 //QString confFile = KStandardDirs::appDir() + "config/korganizerrc";
138 QString confFile = locateLocal("config","korganizerrc"); 138 QString confFile = locateLocal("config","korganizerrc");
139 QFileInfo finf ( confFile ); 139 QFileInfo finf ( confFile );
140 bool showWarning = !finf.exists(); 140 bool showWarning = !finf.exists();
141 setIcon(SmallIcon( "ko24" ) ); 141 setIcon(SmallIcon( "ko24" ) );
142 mBlockAtStartup = true; 142 mBlockAtStartup = true;
143 mFlagKeyPressed = false; 143 mFlagKeyPressed = false;
144 setCaption("KOrganizer/Pi"); 144 setCaption("KOrganizer/Pi");
145 KOPrefs *p = KOPrefs::instance(); 145 KOPrefs *p = KOPrefs::instance();
146 KPimGlobalPrefs::instance()->setGlobalConfig(); 146 KPimGlobalPrefs::instance()->setGlobalConfig();
147 if ( p->mHourSize > 22 ) 147 if ( p->mHourSize > 22 )
148 p->mHourSize = 22; 148 p->mHourSize = 22;
149 QMainWindow::ToolBarDock tbd; 149 QMainWindow::ToolBarDock tbd;
150 if ( p->mToolBarHor ) { 150 if ( p->mToolBarHor ) {
151 if ( p->mToolBarUp ) 151 if ( p->mToolBarUp )
152 tbd = Bottom; 152 tbd = Bottom;
153 else 153 else
154 tbd = Top; 154 tbd = Top;
155 } 155 }
156 else { 156 else {
157 if ( p->mToolBarUp ) 157 if ( p->mToolBarUp )
158 tbd = Right; 158 tbd = Right;
159 else 159 else
160 tbd = Left; 160 tbd = Left;
161 } 161 }
162 if ( KOPrefs::instance()->mUseAppColors ) 162 if ( KOPrefs::instance()->mUseAppColors )
163 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 163 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
164 globalFlagBlockStartup = 1; 164 globalFlagBlockStartup = 1;
165 iconToolBar = new QPEToolBar( this ); 165 iconToolBar = new QPEToolBar( this );
166 addToolBar (iconToolBar , tbd ); 166 addToolBar (iconToolBar , tbd );
167 mCalendarModifiedFlag = false; 167 mCalendarModifiedFlag = false;
168 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); 168 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
169 splash->setAlignment ( AlignCenter ); 169 splash->setAlignment ( AlignCenter );
170 setCentralWidget( splash ); 170 setCentralWidget( splash );
171#ifndef DESKTOP_VERSION 171#ifndef DESKTOP_VERSION
172 showMaximized(); 172 showMaximized();
173#endif 173#endif
174 174
175 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ()); 175 //qDebug("Mainwidget x %d y %d w %d h %d", x(), y(), width(), height ());
176 setDefaultPreferences(); 176 setDefaultPreferences();
177 mCalendar = new CalendarLocal(); 177 mCalendar = new CalendarLocal();
178 mView = new CalendarView( mCalendar, this,"mCalendar " ); 178 mView = new CalendarView( mCalendar, this,"mCalendar " );
179 mView->hide(); 179 mView->hide();
180 //mView->resize(splash->size() ); 180 //mView->resize(splash->size() );
181 initActions(); 181 initActions();
182 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu); 182 mSyncManager = new KSyncManager((QWidget*)this, (KSyncInterface*)mView, KSyncManager::KOPI, KOPrefs::instance(), syncMenu);
183 mSyncManager->setBlockSave(false); 183 mSyncManager->setBlockSave(false);
184 mView->setSyncManager(mSyncManager); 184 mView->setSyncManager(mSyncManager);
185#ifndef DESKTOP_VERSION 185#ifndef DESKTOP_VERSION
186 iconToolBar->show(); 186 iconToolBar->show();
187 qApp->processEvents(); 187 qApp->processEvents();
188#endif 188#endif
189 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ()); 189 //qDebug("Splashwidget x %d y %d w %d h %d", splash-> x(), splash->y(), splash->width(),splash-> height ());
190 int vh = height() ; 190 int vh = height() ;
191 int vw = width(); 191 int vw = width();
192 //qDebug("Toolbar hei %d ",iconToolBar->height() ); 192 //qDebug("Toolbar hei %d ",iconToolBar->height() );
193 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 193 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
194 vh -= iconToolBar->height(); 194 vh -= iconToolBar->height();
195 } else { 195 } else {
196 vw -= iconToolBar->height(); 196 vw -= iconToolBar->height();
197 } 197 }
198 //mView->setMaximumSize( splash->size() ); 198 //mView->setMaximumSize( splash->size() );
199 //mView->resize( splash->size() ); 199 //mView->resize( splash->size() );
200 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 200 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
201 mView->readSettings(); 201 mView->readSettings();
202 bool newFile = false; 202 bool newFile = false;
203 if( !QFile::exists( defaultFileName() ) ) { 203 if( !QFile::exists( defaultFileName() ) ) {
204 QFileInfo finfo ( defaultFileName() ); 204 QFileInfo finfo ( defaultFileName() );
205 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics"); 205 QString oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/Applications/korganizer/mycalendar.ics");
206 qDebug("oldfile %s ", oldFile.latin1()); 206 qDebug("oldfile %s ", oldFile.latin1());
207 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"; 207 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";
208 finfo.setFile( oldFile ); 208 finfo.setFile( oldFile );
209 if (finfo.exists() ) { 209 if (finfo.exists() ) {
210 KMessageBox::information( this, message); 210 KMessageBox::information( this, message);
211 mView->openCalendar( oldFile ); 211 mView->openCalendar( oldFile );
212 qApp->processEvents(); 212 qApp->processEvents();
213 } else { 213 } else {
214 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics"); 214 oldFile = QDir::convertSeparators( QDir::homeDirPath()+"/korganizer/mycalendar.ics");
215 finfo.setFile( oldFile ); 215 finfo.setFile( oldFile );
216 if (finfo.exists() ) { 216 if (finfo.exists() ) {
217 KMessageBox::information( this, message); 217 KMessageBox::information( this, message);
218 mView->openCalendar( oldFile ); 218 mView->openCalendar( oldFile );
219 qApp->processEvents(); 219 qApp->processEvents();
220 } 220 }
221 } 221 }
222 mView->saveCalendar( defaultFileName() ); 222 mView->saveCalendar( defaultFileName() );
223 newFile = true; 223 newFile = true;
224 } 224 }
225 225
226 QTime neededSaveTime = QDateTime::currentDateTime().time(); 226 QTime neededSaveTime = QDateTime::currentDateTime().time();
227 mView->openCalendar( defaultFileName() ); 227 mView->openCalendar( defaultFileName() );
228 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 228 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
229 qDebug("KO: Calendar loading time: %d ms",msNeeded ); 229 qDebug("KO: Calendar loading time: %d ms",msNeeded );
230 230
231 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) { 231 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) {
232 KOPrefs::instance()->setAllDefaults(); 232 KOPrefs::instance()->setAllDefaults();
233 int count = mView->addCategories(); 233 int count = mView->addCategories();
234 } 234 }
235 processIncidenceSelection( 0 ); 235 processIncidenceSelection( 0 );
236 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), 236 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
237 SLOT( processIncidenceSelection( Incidence * ) ) ); 237 SLOT( processIncidenceSelection( Incidence * ) ) );
238 connect( mView, SIGNAL( modifiedChanged( bool ) ), 238 connect( mView, SIGNAL( modifiedChanged( bool ) ),
239 SLOT( slotModifiedChanged( bool ) ) ); 239 SLOT( slotModifiedChanged( bool ) ) );
240 240
241 241
242 connect( mView, SIGNAL( tempDisableBR(bool) ), 242 connect( mView, SIGNAL( tempDisableBR(bool) ),
243 SLOT( disableBR(bool) ) ); 243 SLOT( disableBR(bool) ) );
244 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); 244 connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) );
245 mView->setModified( false ); 245 mView->setModified( false );
246 mBlockAtStartup = false; 246 mBlockAtStartup = false;
247 mView->setModified( false ); 247 mView->setModified( false );
248 setCentralWidget( mView ); 248 setCentralWidget( mView );
249 globalFlagBlockStartup = 0; 249 globalFlagBlockStartup = 0;
250 mView->show(); 250 mView->show();
251 delete splash; 251 delete splash;
252 if ( newFile ) 252 if ( newFile )
253 mView->updateConfig(); 253 mView->updateConfig();
254 // qApp->processEvents(); 254 // qApp->processEvents();
255 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ()); 255 //qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
256 //fillSyncMenu(); 256 //fillSyncMenu();
257 257
258 258
259 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); 259 connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) );
260 connect(mView , SIGNAL( save() ), this, SLOT( save() ) ); 260 connect(mView , SIGNAL( save() ), this, SLOT( save() ) );
261 connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) ); 261 connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) );
262 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 262 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
263 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 263 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
264 mSyncManager->setDefaultFileName( sentSyncFile()); 264 mSyncManager->setDefaultFileName( sentSyncFile());
265 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); 265 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) );
266 mSyncManager->fillSyncMenu(); 266 mSyncManager->fillSyncMenu();
267 267
268 268
269 269
270 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); 270 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
271 if ( showWarning ) { 271 if ( showWarning ) {
272 KMessageBox::information( this, 272 KMessageBox::information( this,
273 "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"); 273 "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");
274 qApp->processEvents(); 274 qApp->processEvents();
275 mView->dialogManager()->showSyncOptions(); 275 mView->dialogManager()->showSyncOptions();
276 } 276 }
277 277
278 //US listen for result adressed from Ka/Pi 278 //US listen for result adressed from Ka/Pi
279#ifndef DESKTOP_VERSION 279#ifndef DESKTOP_VERSION
280 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 280 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
281#endif 281#endif
282#ifndef DESKTOP_VERSION 282#ifndef DESKTOP_VERSION
283 infrared = 0; 283 infrared = 0;
284#endif 284#endif
285 updateWeek( mView->startDate() ); 285 updateWeek( mView->startDate() );
286 connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), 286 connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ),
287 SLOT( updateWeekNum( const KCal::DateList & ) ) ); 287 SLOT( updateWeekNum( const KCal::DateList & ) ) );
288 mBRdisabled = false; 288 mBRdisabled = false;
289 //toggleBeamReceive(); 289 //toggleBeamReceive();
290 setFocusPolicy ( WheelFocus );
291} 290}
292MainWindow::~MainWindow() 291MainWindow::~MainWindow()
293{ 292{
294 //qDebug("MainWindow::~MainWindow() "); 293 //qDebug("MainWindow::~MainWindow() ");
295 //save toolbar location 294 //save toolbar location
296 delete mCalendar; 295 delete mCalendar;
297 delete mSyncManager; 296 delete mSyncManager;
298#ifndef DESKTOP_VERSION 297#ifndef DESKTOP_VERSION
299 if ( infrared ) 298 if ( infrared )
300 delete infrared; 299 delete infrared;
301#endif 300#endif
302 301
303 302
304} 303}
305 304
306void MainWindow::disableBR(bool b) 305void MainWindow::disableBR(bool b)
307{ 306{
308#ifndef DESKTOP_VERSION 307#ifndef DESKTOP_VERSION
309 if ( b ) { 308 if ( b ) {
310 if ( infrared ) { 309 if ( infrared ) {
311 toggleBeamReceive(); 310 toggleBeamReceive();
312 mBRdisabled = true; 311 mBRdisabled = true;
313 } 312 }
314 mBRdisabled = true; 313 mBRdisabled = true;
315 } else { 314 } else {
316 if ( mBRdisabled ) { 315 if ( mBRdisabled ) {
317 mBRdisabled = false; 316 mBRdisabled = false;
318 //makes no sense,because other cal ap is probably running 317 //makes no sense,because other cal ap is probably running
319 // toggleBeamReceive(); 318 // toggleBeamReceive();
320 } 319 }
321 } 320 }
322#endif 321#endif
323 322
324} 323}
325bool MainWindow::beamReceiveEnabled() 324bool MainWindow::beamReceiveEnabled()
326{ 325{
327#ifndef DESKTOP_VERSION 326#ifndef DESKTOP_VERSION
328 return ( infrared != 0 ); 327 return ( infrared != 0 );
329#endif 328#endif
330 return false; 329 return false;
331} 330}
332 331
333void MainWindow::toggleBeamReceive() 332void MainWindow::toggleBeamReceive()
334{ 333{
335 if ( mBRdisabled ) 334 if ( mBRdisabled )
336 return; 335 return;
337#ifndef DESKTOP_VERSION 336#ifndef DESKTOP_VERSION
338 if ( infrared ) { 337 if ( infrared ) {
339 qDebug("disable BeamReceive "); 338 qDebug("disable BeamReceive ");
340 delete infrared; 339 delete infrared;
341 infrared = 0; 340 infrared = 0;
342 brAction->setOn(false); 341 brAction->setOn(false);
343 return; 342 return;
344 } 343 }
345 qDebug("enable BeamReceive "); 344 qDebug("enable BeamReceive ");
346 brAction->setOn(true); 345 brAction->setOn(true);
347 infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ; 346 infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ;
348 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& ))); 347 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& )));
349#endif 348#endif
350} 349}
351void MainWindow::showMaximized () 350void MainWindow::showMaximized ()
352{ 351{
353#ifndef DESKTOP_VERSION 352#ifndef DESKTOP_VERSION
354 if ( ! globalFlagBlockStartup ) 353 if ( ! globalFlagBlockStartup )
355 if ( mClosed ) 354 if ( mClosed )
356 mView->goToday(); 355 mView->goToday();
357#endif 356#endif
358 QWidget::showMaximized () ; 357 QWidget::showMaximized () ;
359 mClosed = false; 358 mClosed = false;
360} 359}
361void MainWindow::closeEvent( QCloseEvent* ce ) 360void MainWindow::closeEvent( QCloseEvent* ce )
362{ 361{
363 362
364 363
365 364
366 if ( ! KOPrefs::instance()->mAskForQuit ) { 365 if ( ! KOPrefs::instance()->mAskForQuit ) {
367 saveOnClose(); 366 saveOnClose();
368 mClosed = true; 367 mClosed = true;
369 ce->accept(); 368 ce->accept();
370 return; 369 return;
371 370
372 } 371 }
373 372
374 switch( QMessageBox::information( this, "KO/Pi", 373 switch( QMessageBox::information( this, "KO/Pi",
375 i18n("Do you really want\nto close KO/Pi?"), 374 i18n("Do you really want\nto close KO/Pi?"),
376 i18n("Close"), i18n("No"), 375 i18n("Close"), i18n("No"),
377 0, 0 ) ) { 376 0, 0 ) ) {
378 case 0: 377 case 0:
379 saveOnClose(); 378 saveOnClose();
380 mClosed = true; 379 mClosed = true;
381 ce->accept(); 380 ce->accept();
382 break; 381 break;
383 case 1: 382 case 1:
384 ce->ignore(); 383 ce->ignore();
385 break; 384 break;
386 case 2: 385 case 2:
387 386
388 default: 387 default:
389 break; 388 break;
390 } 389 }
391 390
392 391
393} 392}
394 393
395void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) 394void MainWindow::recieve( const QCString& cmsg, const QByteArray& data )
396{ 395{
397 QDataStream stream( data, IO_ReadOnly ); 396 QDataStream stream( data, IO_ReadOnly );
398 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); 397 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" );
399 //QString datamess; 398 //QString datamess;
400 //qDebug("message "); 399 //qDebug("message ");
401 qDebug("KO: QCOP message received: %s ", cmsg.data() ); 400 qDebug("KO: QCOP message received: %s ", cmsg.data() );
402 401
403 if ( cmsg == "setDocument(QString)" ) { 402 if ( cmsg == "setDocument(QString)" ) {
404 QDataStream stream( data, IO_ReadOnly ); 403 QDataStream stream( data, IO_ReadOnly );
405 QString fileName; 404 QString fileName;
406 stream >> fileName; 405 stream >> fileName;
407 //qDebug("filename %s ", fileName.latin1()); 406 //qDebug("filename %s ", fileName.latin1());
408 showMaximized(); 407 showMaximized();
409 raise(); 408 raise();
410 KOPrefs::instance()->mLastSyncedLocalFile = fileName ; 409 KOPrefs::instance()->mLastSyncedLocalFile = fileName ;
411 mSyncManager->slotSyncMenu( 1002 ); 410 mSyncManager->slotSyncMenu( 1002 );
412 return; 411 return;
413 } 412 }
414 413
415 if ( cmsg == "-writeFile" ) { 414 if ( cmsg == "-writeFile" ) {
416 // I made from the "-writeFile" an "-writeAlarm" 415 // I made from the "-writeFile" an "-writeAlarm"
417 mView->viewManager()->showWhatsNextView(); 416 mView->viewManager()->showWhatsNextView();
418 mCalendar->checkAlarmForIncidence( 0, true); 417 mCalendar->checkAlarmForIncidence( 0, true);
419 showMaximized(); 418 showMaximized();
420 raise(); 419 raise();
421 return; 420 return;
422 421
423 } 422 }
424 if ( cmsg == "-writeFileSilent" ) { 423 if ( cmsg == "-writeFileSilent" ) {
425 // I made from the "-writeFile" an "-writeAlarm" 424 // I made from the "-writeFile" an "-writeAlarm"
426 // mView->viewManager()->showWhatsNextView(); 425 // mView->viewManager()->showWhatsNextView();
427 mCalendar->checkAlarmForIncidence( 0, true); 426 mCalendar->checkAlarmForIncidence( 0, true);
428 //showMaximized(); 427 //showMaximized();
429 //raise(); 428 //raise();
430 hide(); 429 hide();
431 return; 430 return;
432 } 431 }
433 if ( cmsg == "-newCountdown" ) { 432 if ( cmsg == "-newCountdown" ) {
434 qDebug("newCountdown "); 433 qDebug("newCountdown ");
435 434
436 } 435 }
437 QString msg ; 436 QString msg ;
438 QString allmsg = cmsg; 437 QString allmsg = cmsg;
439 while ( allmsg.length() > 0 ) { 438 while ( allmsg.length() > 0 ) {
440 int nextC = allmsg.find( "-", 1 ); 439 int nextC = allmsg.find( "-", 1 );
441 if ( nextC == -1 ) { 440 if ( nextC == -1 ) {
442 msg = allmsg; 441 msg = allmsg;
443 allmsg = ""; 442 allmsg = "";
444 } else{ 443 } else{
445 msg = allmsg.left( nextC ); 444 msg = allmsg.left( nextC );
446 allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); 445 allmsg = allmsg.mid( nextC, allmsg.length()-nextC );
447 } 446 }
448 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); 447 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() );
449 if ( msg == "-newEvent" ) { 448 if ( msg == "-newEvent" ) {
450 mView->newEvent(); 449 mView->newEvent();
451 } 450 }
452 if ( msg == "-newTodo" ) { 451 if ( msg == "-newTodo" ) {
453 mView->newTodo(); 452 mView->newTodo();
454 453
455 } 454 }
456 if ( msg == "-showWN" ) { 455 if ( msg == "-showWN" ) {
457 mView->viewManager()->showWhatsNextView(); 456 mView->viewManager()->showWhatsNextView();
458 } 457 }
459 if ( msg == "-showTodo" ) { 458 if ( msg == "-showTodo" ) {
460 mView->viewManager()->showTodoView(); 459 mView->viewManager()->showTodoView();
461 } 460 }
462 if ( msg == "-showList" ) { 461 if ( msg == "-showList" ) {
463 mView->viewManager()->showListView(); 462 mView->viewManager()->showListView();
464 } 463 }
465 else if ( msg == "-showDay" ) { 464 else if ( msg == "-showDay" ) {
466 mView->viewManager()->showDayView(); 465 mView->viewManager()->showDayView();
467 } 466 }
468 else if ( msg == "-showWWeek" ) { 467 else if ( msg == "-showWWeek" ) {
469 mView->viewManager()->showWorkWeekView(); 468 mView->viewManager()->showWorkWeekView();
470 } 469 }
471 else if ( msg == "-ringSync" ) { 470 else if ( msg == "-ringSync" ) {
472 mSyncManager->multiSync( false ); 471 mSyncManager->multiSync( false );
473 } 472 }
474 else if ( msg == "-showWeek" ) { 473 else if ( msg == "-showWeek" ) {
475 mView->viewManager()->showWeekView(); 474 mView->viewManager()->showWeekView();
476 } 475 }
477 else if ( msg == "-showTodo" ) { 476 else if ( msg == "-showTodo" ) {
478 mView->viewManager()->showTodoView(); 477 mView->viewManager()->showTodoView();
479 } 478 }
480 else if ( msg == "-showJournal" ) { 479 else if ( msg == "-showJournal" ) {
481 mView->dateNavigator()->selectDates( 1 ); 480 mView->dateNavigator()->selectDates( 1 );
482 mView->dateNavigator()->selectToday(); 481 mView->dateNavigator()->selectToday();
483 mView->viewManager()->showJournalView(); 482 mView->viewManager()->showJournalView();
484 } 483 }
485 else if ( msg == "-showKO" ) { 484 else if ( msg == "-showKO" ) {
486 mView->viewManager()->showNextXView(); 485 mView->viewManager()->showNextXView();
487 } 486 }
488 else if ( msg == "-showWNext" || msg == "nextView()" ) { 487 else if ( msg == "-showWNext" || msg == "nextView()" ) {
489 mView->viewManager()->showWhatsNextView(); 488 mView->viewManager()->showWhatsNextView();
490 } 489 }
491 else if ( msg == "-showNextXView" ) { 490 else if ( msg == "-showNextXView" ) {
492 mView->viewManager()->showNextXView(); 491 mView->viewManager()->showNextXView();
493 } 492 }
494 493
495 494
496 } 495 }
497 496
498 showMaximized(); 497 showMaximized();
499 raise(); 498 raise();
500} 499}
501 500
502QPixmap MainWindow::loadPixmap( QString name ) 501QPixmap MainWindow::loadPixmap( QString name )
503{ 502{
504 return SmallIcon( name ); 503 return SmallIcon( name );
505 504
506} 505}
507void MainWindow::initActions() 506void MainWindow::initActions()
508{ 507{
509 //KOPrefs::instance()->mShowFullMenu 508 //KOPrefs::instance()->mShowFullMenu
510 iconToolBar->clear(); 509 iconToolBar->clear();
511 KOPrefs *p = KOPrefs::instance(); 510 KOPrefs *p = KOPrefs::instance();
512 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); 511 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar );
513 512
514 QPopupMenu *viewMenu = new QPopupMenu( this ); 513 QPopupMenu *viewMenu = new QPopupMenu( this );
515 QPopupMenu *actionMenu = new QPopupMenu( this ); 514 QPopupMenu *actionMenu = new QPopupMenu( this );
516 QPopupMenu *importMenu = new QPopupMenu( this ); 515 QPopupMenu *importMenu = new QPopupMenu( this );
517 selectFilterMenu = new QPopupMenu( this ); 516 selectFilterMenu = new QPopupMenu( this );
518 selectFilterMenu->setCheckable( true ); 517 selectFilterMenu->setCheckable( true );
519 syncMenu = new QPopupMenu( this ); 518 syncMenu = new QPopupMenu( this );
520 configureAgendaMenu = new QPopupMenu( this ); 519 configureAgendaMenu = new QPopupMenu( this );
521 configureToolBarMenu = new QPopupMenu( this ); 520 configureToolBarMenu = new QPopupMenu( this );
522 QPopupMenu *helpMenu = new QPopupMenu( this ); 521 QPopupMenu *helpMenu = new QPopupMenu( this );
523 if ( KOPrefs::instance()->mShowFullMenu ) { 522 if ( KOPrefs::instance()->mShowFullMenu ) {
524 QMenuBar *menuBar1; 523 QMenuBar *menuBar1;
525 menuBar1 = menuBar(); 524 menuBar1 = menuBar();
526 menuBar1->insertItem( i18n("File"), importMenu ); 525 menuBar1->insertItem( i18n("File"), importMenu );
527 menuBar1->insertItem( i18n("View"), viewMenu ); 526 menuBar1->insertItem( i18n("View"), viewMenu );
528 menuBar1->insertItem( i18n("Actions"), actionMenu ); 527 menuBar1->insertItem( i18n("Actions"), actionMenu );
529#ifdef DESKTOP_VERSION 528#ifdef DESKTOP_VERSION
530 menuBar1->insertItem( i18n("Synchronize"), syncMenu ); 529 menuBar1->insertItem( i18n("Synchronize"), syncMenu );
531 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 530 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu );
532#else 531#else
533 menuBar1->insertItem( i18n("Sync"), syncMenu ); 532 menuBar1->insertItem( i18n("Sync"), syncMenu );
534 menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu ); 533 menuBar1->insertItem( i18n("Agenda"),configureAgendaMenu );
535#endif 534#endif
536 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); 535 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu );
537 menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); 536 menuBar1->insertItem( i18n("Filter"),selectFilterMenu );
538 menuBar1->insertItem( i18n("Help"), helpMenu ); 537 menuBar1->insertItem( i18n("Help"), helpMenu );
539 } else { 538 } else {
540 QPEMenuBar *menuBar1; 539 QPEMenuBar *menuBar1;
541 menuBar1 = new QPEMenuBar( iconToolBar ); 540 menuBar1 = new QPEMenuBar( iconToolBar );
542 QPopupMenu *menuBar = new QPopupMenu( this ); 541 QPopupMenu *menuBar = new QPopupMenu( this );
543 menuBar1->insertItem( i18n("ME"), menuBar); 542 menuBar1->insertItem( i18n("ME"), menuBar);
544 menuBar->insertItem( i18n("File"), importMenu ); 543 menuBar->insertItem( i18n("File"), importMenu );
545 menuBar->insertItem( i18n("View"), viewMenu ); 544 menuBar->insertItem( i18n("View"), viewMenu );
546 menuBar->insertItem( i18n("Actions"), actionMenu ); 545 menuBar->insertItem( i18n("Actions"), actionMenu );
547 menuBar->insertItem( i18n("Synchronize"), syncMenu ); 546 menuBar->insertItem( i18n("Synchronize"), syncMenu );
548 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 547 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu );
549 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); 548 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu );
550 menuBar->insertItem( i18n("Filter"),selectFilterMenu ); 549 menuBar->insertItem( i18n("Filter"),selectFilterMenu );
551 menuBar->insertItem( i18n("Help"), helpMenu ); 550 menuBar->insertItem( i18n("Help"), helpMenu );
552 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); 551 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() );
553 menuBar1->setMaximumSize( menuBar1->sizeHint( )); 552 menuBar1->setMaximumSize( menuBar1->sizeHint( ));
554 } 553 }
555 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); 554 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
556 connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) ); 555 connect ( selectFilterMenu, SIGNAL( aboutToShow() ), this, SLOT (fillFilterMenu() ) );
557 QIconSet icon; 556 QIconSet icon;
558 int pixWid = 22, pixHei = 22; 557 int pixWid = 22, pixHei = 22;
559 QString pathString = ""; 558 QString pathString = "";
560 if ( !p->mToolBarMiniIcons ) { 559 if ( !p->mToolBarMiniIcons ) {
561 if ( QApplication::desktop()->width() < 480 ) { 560 if ( QApplication::desktop()->width() < 480 ) {
562 pathString += "icons16/"; 561 pathString += "icons16/";
563 pixWid = 18; pixHei = 16; 562 pixWid = 18; pixHei = 16;
564 } 563 }
565 } else { 564 } else {
566 pathString += "iconsmini/"; 565 pathString += "iconsmini/";
567 pixWid = 18; pixHei = 16; 566 pixWid = 18; pixHei = 16;
568 } 567 }
569 mWeekBgColor = iconToolBar->backgroundColor(); 568 mWeekBgColor = iconToolBar->backgroundColor();
570 mWeekPixmap.resize( pixWid , pixHei ); 569 mWeekPixmap.resize( pixWid , pixHei );
571 mWeekPixmap.fill( mWeekBgColor ); 570 mWeekPixmap.fill( mWeekBgColor );
572 icon = mWeekPixmap; 571 icon = mWeekPixmap;
573 mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this ); 572 mWeekAction = new QAction( i18n("Select week number"),icon, i18n("Select week number"), 0, this );
574 if ( p-> mShowIconWeekNum ) 573 if ( p-> mShowIconWeekNum )
575 mWeekAction->addTo( iconToolBar ); 574 mWeekAction->addTo( iconToolBar );
576 mWeekFont = font(); 575 mWeekFont = font();
577 576
578 int fontPoint = mWeekFont.pointSize(); 577 int fontPoint = mWeekFont.pointSize();
579 QFontMetrics f( mWeekFont ); 578 QFontMetrics f( mWeekFont );
580 int fontWid = f.width( "30" ); 579 int fontWid = f.width( "30" );
581 while ( fontWid > pixWid ) { 580 while ( fontWid > pixWid ) {
582 --fontPoint; 581 --fontPoint;
583 mWeekFont.setPointSize( fontPoint ); 582 mWeekFont.setPointSize( fontPoint );
584 QFontMetrics f( mWeekFont ); 583 QFontMetrics f( mWeekFont );
585 fontWid = f.width( "30" ); 584 fontWid = f.width( "30" );
586 qDebug("dec-- "); 585 qDebug("dec-- ");
587 } 586 }
588 587
589 connect( mWeekAction, SIGNAL( activated() ), 588 connect( mWeekAction, SIGNAL( activated() ),
590 this, SLOT( weekAction() ) ); 589 this, SLOT( weekAction() ) );
591 590
592 connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) ); 591 connect( this, SIGNAL( selectWeek ( int ) ), mView->dateNavigator(), SLOT( selectWeek ( int ) ) );
593 592
594 //#endif 593 //#endif
595 // ****************** 594 // ******************
596 QAction *action; 595 QAction *action;
597 // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); 596 // QPopupMenu *configureMenu= new QPopupMenu( menuBar );
598 configureToolBarMenu->setCheckable( true ); 597 configureToolBarMenu->setCheckable( true );
599 598
600 599
601 configureAgendaMenu->setCheckable( true ); 600 configureAgendaMenu->setCheckable( true );
602 int iii ; 601 int iii ;
603 for ( iii = 1;iii<= 10 ;++iii ){ 602 for ( iii = 1;iii<= 10 ;++iii ){
604 configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 ); 603 configureAgendaMenu->insertItem(i18n("Size %1").arg(iii), (iii+1)*2 );
605 } 604 }
606 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); 605 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu );
607 606
608 connect( configureAgendaMenu, SIGNAL( aboutToShow()), 607 connect( configureAgendaMenu, SIGNAL( aboutToShow()),
609 this, SLOT( showConfigureAgenda( ) ) ); 608 this, SLOT( showConfigureAgenda( ) ) );
610 609
611 icon = loadPixmap( pathString + "configure" ); 610 icon = loadPixmap( pathString + "configure" );
612 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); 611 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this );
613 action->addTo( actionMenu ); 612 action->addTo( actionMenu );
614 connect( action, SIGNAL( activated() ), 613 connect( action, SIGNAL( activated() ),
615 mView, SLOT( edit_options() ) ); 614 mView, SLOT( edit_options() ) );
616 actionMenu->insertSeparator(); 615 actionMenu->insertSeparator();
617 616
618 action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this ); 617 action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this );
619 action->addTo( actionMenu ); 618 action->addTo( actionMenu );
620 connect( action, SIGNAL( activated() ), 619 connect( action, SIGNAL( activated() ),
621 mView, SLOT( undo_delete() ) ); 620 mView, SLOT( undo_delete() ) );
622 actionMenu->insertSeparator(); 621 actionMenu->insertSeparator();
623 622
624 icon = loadPixmap( pathString + "newevent" ); 623 icon = loadPixmap( pathString + "newevent" );
625 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); 624 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 );
626 configureToolBarMenu->insertSeparator(); 625 configureToolBarMenu->insertSeparator();
627 configureToolBarMenu->insertItem(i18n("Week Number"), 400); 626 configureToolBarMenu->insertItem(i18n("Week Number"), 400);
628 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); 627 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 );
629 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); 628 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this );
630 ne_action->addTo( actionMenu ); 629 ne_action->addTo( actionMenu );
631 connect( ne_action, SIGNAL( activated() ), 630 connect( ne_action, SIGNAL( activated() ),
632 mView, SLOT( newEvent() ) ); 631 mView, SLOT( newEvent() ) );
633 icon = loadPixmap( pathString + "newtodo" ); 632 icon = loadPixmap( pathString + "newtodo" );
634 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); 633 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 );
635 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); 634 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this );
636 nt_action->addTo( actionMenu ); 635 nt_action->addTo( actionMenu );
637 connect( nt_action, SIGNAL( activated() ), 636 connect( nt_action, SIGNAL( activated() ),
638 mView, SLOT( newTodo() ) ); 637 mView, SLOT( newTodo() ) );
639 638
640 icon = loadPixmap( pathString + "today" ); 639 icon = loadPixmap( pathString + "today" );
641 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); 640 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this );
642 today_action->addTo( viewMenu ); 641 today_action->addTo( viewMenu );
643 connect( today_action, SIGNAL( activated() ), 642 connect( today_action, SIGNAL( activated() ),
644 mView, SLOT( goToday() ) ); 643 mView, SLOT( goToday() ) );
645 viewMenu->insertSeparator(); 644 viewMenu->insertSeparator();
646 645
647 icon = loadPixmap( pathString + "navi" ); 646 icon = loadPixmap( pathString + "navi" );
648 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); 647 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this );
649 action->addTo( viewMenu ); 648 action->addTo( viewMenu );
650 connect( action, SIGNAL( activated() ), 649 connect( action, SIGNAL( activated() ),
651 mView, SLOT( toggleDateNavigatorWidget() ) ); 650 mView, SLOT( toggleDateNavigatorWidget() ) );
652 mToggleNav = action ; 651 mToggleNav = action ;
653 icon = loadPixmap( pathString + "filter" ); 652 icon = loadPixmap( pathString + "filter" );
654 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); 653 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this );
655 action->addTo( viewMenu ); 654 action->addTo( viewMenu );
656 connect( action, SIGNAL( activated() ), 655 connect( action, SIGNAL( activated() ),
657 mView, SLOT( toggleFilter() ) ); 656 mView, SLOT( toggleFilter() ) );
658 mToggleFilter = action; 657 mToggleFilter = action;
659 icon = loadPixmap( pathString + "allday" ); 658 icon = loadPixmap( pathString + "allday" );
660 action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this ); 659 action = new QAction( i18n("Toggle Allday"), icon,i18n("Toggle Allday"), 0, this );
661 action->addTo( viewMenu ); 660 action->addTo( viewMenu );
662 connect( action, SIGNAL( activated() ), 661 connect( action, SIGNAL( activated() ),
663 mView, SLOT( toggleAllDaySize() ) ); 662 mView, SLOT( toggleAllDaySize() ) );
664 mToggleAllday = action; 663 mToggleAllday = action;
665 664
666 665
667 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), 666 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ),
668 mToggleNav, SLOT( setEnabled ( bool ) ) ); 667 mToggleNav, SLOT( setEnabled ( bool ) ) );
669 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ), 668 connect( mView->viewManager(), SIGNAL( signalFullScreen( bool ) ),
670 mToggleFilter, SLOT( setEnabled ( bool ) ) ); 669 mToggleFilter, SLOT( setEnabled ( bool ) ) );
671 connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ), 670 connect( mView->viewManager(), SIGNAL( signalAgendaView( bool ) ),
672 mToggleAllday, SLOT( setEnabled ( bool ) ) ); 671 mToggleAllday, SLOT( setEnabled ( bool ) ) );
673 672
674 viewMenu->insertSeparator(); 673 viewMenu->insertSeparator();
675 icon = loadPixmap( pathString + "picker" ); 674 icon = loadPixmap( pathString + "picker" );
676 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); 675 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this );
677 action->addTo( viewMenu ); 676 action->addTo( viewMenu );
678 connect( action, SIGNAL( activated() ), 677 connect( action, SIGNAL( activated() ),
679 mView, SLOT( showDatePicker() ) ); 678 mView, SLOT( showDatePicker() ) );
680 action->addTo( iconToolBar ); 679 action->addTo( iconToolBar );
681 viewMenu->insertSeparator(); 680 viewMenu->insertSeparator();
682 icon = loadPixmap( pathString + "list" ); 681 icon = loadPixmap( pathString + "list" );
683 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); 682 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 );
684 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); 683 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this );
685 showlist_action->addTo( viewMenu ); 684 showlist_action->addTo( viewMenu );
686 connect( showlist_action, SIGNAL( activated() ), 685 connect( showlist_action, SIGNAL( activated() ),
687 mView->viewManager(), SLOT( showListView() ) ); 686 mView->viewManager(), SLOT( showListView() ) );
688 687
689 688
690 icon = loadPixmap( pathString + "day" ); 689 icon = loadPixmap( pathString + "day" );
691 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); 690 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 );
692 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); 691 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this );
693 day1_action->addTo( viewMenu ); 692 day1_action->addTo( viewMenu );
694 // action->addTo( toolBar ); 693 // action->addTo( toolBar );
695 connect( day1_action, SIGNAL( activated() ), 694 connect( day1_action, SIGNAL( activated() ),
696 mView->viewManager(), SLOT( showDayView() ) ); 695 mView->viewManager(), SLOT( showDayView() ) );
697 696
698 icon = loadPixmap( pathString + "workweek" ); 697 icon = loadPixmap( pathString + "workweek" );
699 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); 698 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 );
700 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); 699 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this );
701 day5_action->addTo( viewMenu ); 700 day5_action->addTo( viewMenu );
702 connect( day5_action, SIGNAL( activated() ), 701 connect( day5_action, SIGNAL( activated() ),
703 mView->viewManager(), SLOT( showWorkWeekView() ) ); 702 mView->viewManager(), SLOT( showWorkWeekView() ) );
704 703
705 icon = loadPixmap( pathString + "week" ); 704 icon = loadPixmap( pathString + "week" );
706 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); 705 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 );
707 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); 706 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this );
708 day7_action->addTo( viewMenu ); 707 day7_action->addTo( viewMenu );
709 connect( day7_action, SIGNAL( activated() ), 708 connect( day7_action, SIGNAL( activated() ),
710 mView->viewManager(), SLOT( showWeekView() ) ); 709 mView->viewManager(), SLOT( showWeekView() ) );
711 710
712 icon = loadPixmap( pathString + "workweek2" ); 711 icon = loadPixmap( pathString + "workweek2" );
713 configureToolBarMenu->insertItem(icon, i18n("List week view"), 75 ); 712 configureToolBarMenu->insertItem(icon, i18n("List week view"), 75 );
714 QAction* day6_action = new QAction( i18n("List week"), icon, i18n("List week"), 0, this ); 713 QAction* day6_action = new QAction( i18n("List week"), icon, i18n("List week"), 0, this );
715 day6_action->addTo( viewMenu ); 714 day6_action->addTo( viewMenu );
716 connect( day6_action, SIGNAL( activated() ), 715 connect( day6_action, SIGNAL( activated() ),
717 mView->viewManager(), SLOT( showMonthViewWeek() ) ); 716 mView->viewManager(), SLOT( showMonthViewWeek() ) );
718 717
719 icon = loadPixmap( pathString + "month" ); 718 icon = loadPixmap( pathString + "month" );
720 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); 719 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 );
721 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); 720 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this );
722 month_action->addTo( viewMenu ); 721 month_action->addTo( viewMenu );
723 connect( month_action, SIGNAL( activated() ), 722 connect( month_action, SIGNAL( activated() ),
724 mView->viewManager(), SLOT( showMonthView() ) ); 723 mView->viewManager(), SLOT( showMonthView() ) );
725 724
726 icon = loadPixmap( pathString + "todo" ); 725 icon = loadPixmap( pathString + "todo" );
727 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); 726 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 );
728 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); 727 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this );
729 todoview_action->addTo( viewMenu ); 728 todoview_action->addTo( viewMenu );
730 connect( todoview_action, SIGNAL( activated() ), 729 connect( todoview_action, SIGNAL( activated() ),
731 mView->viewManager(), SLOT( showTodoView() ) ); 730 mView->viewManager(), SLOT( showTodoView() ) );
732 731
733 icon = loadPixmap( pathString + "journal" ); 732 icon = loadPixmap( pathString + "journal" );
734 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); 733 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 );
735 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); 734 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this );
736 viewjournal_action->addTo( viewMenu ); 735 viewjournal_action->addTo( viewMenu );
737 connect( viewjournal_action, SIGNAL( activated() ), 736 connect( viewjournal_action, SIGNAL( activated() ),
738 mView->viewManager(), SLOT( showJournalView() ) ); 737 mView->viewManager(), SLOT( showJournalView() ) );
739 738
740 icon = loadPixmap( pathString + "xdays" ); 739 icon = loadPixmap( pathString + "xdays" );
741 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 ); 740 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 );
742 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); 741 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this );
743 xdays_action->addTo( viewMenu ); 742 xdays_action->addTo( viewMenu );
744 connect( xdays_action, SIGNAL( activated() ), 743 connect( xdays_action, SIGNAL( activated() ),
745 mView->viewManager(), SLOT( showNextXView() ) ); 744 mView->viewManager(), SLOT( showNextXView() ) );
746 745
747 icon = loadPixmap( pathString + "whatsnext" ); 746 icon = loadPixmap( pathString + "whatsnext" );
748 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 ); 747 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 );
749 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); 748 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this );
750 whatsnext_action->addTo( viewMenu ); 749 whatsnext_action->addTo( viewMenu );
751 connect( whatsnext_action, SIGNAL( activated() ), 750 connect( whatsnext_action, SIGNAL( activated() ),
752 mView->viewManager(), SLOT( showWhatsNextView() ) ); 751 mView->viewManager(), SLOT( showWhatsNextView() ) );
753 752
754#if 0 753#if 0
755 action = new QAction( "view_timespan", "Time Span", 0, this ); 754 action = new QAction( "view_timespan", "Time Span", 0, this );
756 action->addTo( viewMenu ); 755 action->addTo( viewMenu );
757 connect( action, SIGNAL( activated() ), 756 connect( action, SIGNAL( activated() ),
758 mView->viewManager(), SLOT( showTimeSpanView() ) ); 757 mView->viewManager(), SLOT( showTimeSpanView() ) );
759#endif 758#endif
760 759
761 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, 760 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0,
762 this ); 761 this );
763 mNewSubTodoAction->addTo( actionMenu ); 762 mNewSubTodoAction->addTo( actionMenu );
764 connect( mNewSubTodoAction, SIGNAL( activated() ), 763 connect( mNewSubTodoAction, SIGNAL( activated() ),
765 mView, SLOT( newSubTodo() ) ); 764 mView, SLOT( newSubTodo() ) );
766 765
767 actionMenu->insertSeparator(); 766 actionMenu->insertSeparator();
768 767
769 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); 768 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this );
770 mShowAction->addTo( actionMenu ); 769 mShowAction->addTo( actionMenu );
771 connect( mShowAction, SIGNAL( activated() ), 770 connect( mShowAction, SIGNAL( activated() ),
772 mView, SLOT( showIncidence() ) ); 771 mView, SLOT( showIncidence() ) );
773 772
774 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); 773 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this );
775 mEditAction->addTo( actionMenu ); 774 mEditAction->addTo( actionMenu );
776 connect( mEditAction, SIGNAL( activated() ), 775 connect( mEditAction, SIGNAL( activated() ),
777 mView, SLOT( editIncidence() ) ); 776 mView, SLOT( editIncidence() ) );
778 777
779 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); 778 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this );
780 mDeleteAction->addTo( actionMenu ); 779 mDeleteAction->addTo( actionMenu );
781 connect( mDeleteAction, SIGNAL( activated() ), 780 connect( mDeleteAction, SIGNAL( activated() ),
782 mView, SLOT( deleteIncidence() ) ); 781 mView, SLOT( deleteIncidence() ) );
783 782
784 783
785 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); 784 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this );
786 mCloneAction->addTo( actionMenu ); 785 mCloneAction->addTo( actionMenu );
787 connect( mCloneAction, SIGNAL( activated() ), 786 connect( mCloneAction, SIGNAL( activated() ),
788 mView, SLOT( cloneIncidence() ) ); 787 mView, SLOT( cloneIncidence() ) );
789 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); 788 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this );
790 mMoveAction->addTo( actionMenu ); 789 mMoveAction->addTo( actionMenu );
791 connect( mMoveAction, SIGNAL( activated() ), 790 connect( mMoveAction, SIGNAL( activated() ),
792 mView, SLOT( moveIncidence() ) ); 791 mView, SLOT( moveIncidence() ) );
793 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); 792 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this );
794 mBeamAction->addTo( actionMenu ); 793 mBeamAction->addTo( actionMenu );
795 connect( mBeamAction, SIGNAL( activated() ), 794 connect( mBeamAction, SIGNAL( activated() ),
796 mView, SLOT( beamIncidence() ) ); 795 mView, SLOT( beamIncidence() ) );
797 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); 796 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this );
798 mCancelAction->addTo( actionMenu ); 797 mCancelAction->addTo( actionMenu );
799 connect( mCancelAction, SIGNAL( activated() ), 798 connect( mCancelAction, SIGNAL( activated() ),
800 mView, SLOT( toggleCancelIncidence() ) ); 799 mView, SLOT( toggleCancelIncidence() ) );
801 800
802 actionMenu->insertSeparator(); 801 actionMenu->insertSeparator();
803 802
804 action = new QAction( "purge_completed", i18n("Purge Completed"), 0, 803 action = new QAction( "purge_completed", i18n("Purge Completed"), 0,
805 this ); 804 this );
806 action->addTo( actionMenu ); 805 action->addTo( actionMenu );
807 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); 806 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) );
808 807
809 icon = loadPixmap( pathString + "search" ); 808 icon = loadPixmap( pathString + "search" );
810 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); 809 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this );
811 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4); 810 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4);
812 search_action->addTo( actionMenu ); 811 search_action->addTo( actionMenu );
813 connect( search_action, SIGNAL( activated() ), 812 connect( search_action, SIGNAL( activated() ),
814 mView->dialogManager(), SLOT( showSearchDialog() ) ); 813 mView->dialogManager(), SLOT( showSearchDialog() ) );
815 814
816 815
817 816
818 if ( KOPrefs::instance()->mShowFullMenu ) { 817 if ( KOPrefs::instance()->mShowFullMenu ) {
819 actionMenu->insertSeparator(); 818 actionMenu->insertSeparator();
820 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); 819 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu );
821 820
822 } 821 }
823 // actionMenu->insertSeparator(); 822 // actionMenu->insertSeparator();
824 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, 823 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0,
825 this ); 824 this );
826 action->addTo( importMenu ); 825 action->addTo( importMenu );
827 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); 826 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) );
828 action = new QAction( "import_quick", i18n("Import last file"), 0, 827 action = new QAction( "import_quick", i18n("Import last file"), 0,
829 this ); 828 this );
830 action->addTo( importMenu ); 829 action->addTo( importMenu );
831 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); 830 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) );
832 importMenu->insertSeparator(); 831 importMenu->insertSeparator();
833 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, 832 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0,
834 this ); 833 this );
835 action->addTo( importMenu ); 834 action->addTo( importMenu );
836 connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); 835 connect( action, SIGNAL( activated() ), SLOT( importBday() ) );
837#ifndef DESKTOP_VERSION 836#ifndef DESKTOP_VERSION
838 importMenu->insertSeparator(); 837 importMenu->insertSeparator();
839 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, 838 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0,
840 this ); 839 this );
841 action->addTo( importMenu ); 840 action->addTo( importMenu );
842 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); 841 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) );
843#else 842#else
844#ifdef _OL_IMPORT_ 843#ifdef _OL_IMPORT_
845 importMenu->insertSeparator(); 844 importMenu->insertSeparator();
846 action = new QAction( "import_ol", i18n("Import from OL"), 0, 845 action = new QAction( "import_ol", i18n("Import from OL"), 0,
847 this ); 846 this );
848 action->addTo( importMenu ); 847 action->addTo( importMenu );
849 connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); 848 connect( action, SIGNAL( activated() ), SLOT( importOL() ) );
850#endif 849#endif
851#endif 850#endif
852 851
853 importMenu->insertSeparator(); 852 importMenu->insertSeparator();
854 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, 853 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0,
855 this ); 854 this );
856 action->addTo( importMenu ); 855 action->addTo( importMenu );
857 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); 856 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) );
858 857
859 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, 858 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0,
860 this ); 859 this );
861 action->addTo( importMenu ); 860 action->addTo( importMenu );
862 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); 861 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) );
863 862
864 importMenu->insertSeparator(); 863 importMenu->insertSeparator();
865 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, 864 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0,
866 this ); 865 this );
867 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); 866 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) );
868 867
869 868
870 //LR 869 //LR
871 QPopupMenu *ex2phone = new QPopupMenu( this ); 870 QPopupMenu *ex2phone = new QPopupMenu( this );
872 ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 871 ex2phone->insertItem(i18n("Complete calendar..."), 1 );
873 ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 872 ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
874 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); 873 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) );
875 importMenu->insertItem( i18n("Export to phone"), ex2phone ); 874 importMenu->insertItem( i18n("Export to phone"), ex2phone );
876 875
877 importMenu->insertSeparator(); 876 importMenu->insertSeparator();
878 action = new QAction( "manage cat", i18n("Manage new categories..."), 0, 877 action = new QAction( "manage cat", i18n("Manage new categories..."), 0,
879 this ); 878 this );
880 action->addTo( importMenu ); 879 action->addTo( importMenu );
881 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); 880 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) );
882#ifndef DESKTOP_VERSION 881#ifndef DESKTOP_VERSION
883 importMenu->insertSeparator(); 882 importMenu->insertSeparator();
884 brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0, 883 brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0,
885 this ); 884 this );
886 brAction->addTo( importMenu ); 885 brAction->addTo( importMenu );
887 brAction->setToggleAction (true ) ; 886 brAction->setToggleAction (true ) ;
888 connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) ); 887 connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) );
889 888
890 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, 889 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0,
891 this ); 890 this );
892 action->addTo( importMenu ); 891 action->addTo( importMenu );
893 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); 892 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) );
894 893
895 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, 894 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0,
896 this ); 895 this );
897 action->addTo( importMenu ); 896 action->addTo( importMenu );
898 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); 897 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) );
899#else 898#else
900 importMenu->insertSeparator(); 899 importMenu->insertSeparator();
901 icon = loadPixmap( pathString + "print" ); 900 icon = loadPixmap( pathString + "print" );
902 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); 901 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this );
903 action->addTo( importMenu ); 902 action->addTo( importMenu );
904 connect( action, SIGNAL( activated() ), 903 connect( action, SIGNAL( activated() ),
905 this, SLOT( printCal() ) ); 904 this, SLOT( printCal() ) );
906 905
907 icon = loadPixmap( pathString + "print" ); 906 icon = loadPixmap( pathString + "print" );
908 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); 907 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this );
909 action->addTo( importMenu ); 908 action->addTo( importMenu );
910 connect( action, SIGNAL( activated() ), 909 connect( action, SIGNAL( activated() ),
911 this, SLOT( printSel() ) ); 910 this, SLOT( printSel() ) );
912 action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this ); 911 action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this );
913 action->addTo( importMenu ); 912 action->addTo( importMenu );
914 connect( action, SIGNAL( activated() ), 913 connect( action, SIGNAL( activated() ),
915 mView->viewManager(), SIGNAL( printWNV() ) ); 914 mView->viewManager(), SIGNAL( printWNV() ) );
916#endif 915#endif
917 importMenu->insertSeparator(); 916 importMenu->insertSeparator();
918 action = new QAction( "beam all", i18n("Save"), 0, 917 action = new QAction( "beam all", i18n("Save"), 0,
919 this ); 918 this );
920 action->addTo( importMenu ); 919 action->addTo( importMenu );
921 connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); 920 connect( action, SIGNAL( activated() ), this, SLOT( save() ) );
922 action = new QAction( "beam all", i18n("Exit (+save)"), 0, 921 action = new QAction( "beam all", i18n("Exit (+save)"), 0,
923 this ); 922 this );
924 action->addTo( importMenu ); 923 action->addTo( importMenu );
925 connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); 924 connect( action, SIGNAL( activated() ), this, SLOT( close() ) );
926 925
927 //menuBar->insertItem( "Configure",configureMenu ); 926 //menuBar->insertItem( "Configure",configureMenu );
928 //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); 927 //configureMenu->insertItem( "Toolbar",configureToolBarMenu );
929 icon = loadPixmap( "korganizer/korganizer" ); 928 icon = loadPixmap( "korganizer/korganizer" );
930 929
931 action = new QAction( "Whats New", i18n("What's new?"), 0,this ); 930 action = new QAction( "Whats New", i18n("What's new?"), 0,this );
932 action->addTo( helpMenu ); 931 action->addTo( helpMenu );
933 connect( action, SIGNAL( activated() ), 932 connect( action, SIGNAL( activated() ),
934 SLOT( whatsNew() ) ); 933 SLOT( whatsNew() ) );
935 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); 934 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this );
936 action->addTo( helpMenu ); 935 action->addTo( helpMenu );
937 connect( action, SIGNAL( activated() ), 936 connect( action, SIGNAL( activated() ),
938 SLOT( features() ) ); 937 SLOT( features() ) );
939 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); 938 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this );
940 action->addTo( helpMenu ); 939 action->addTo( helpMenu );
941 connect( action, SIGNAL( activated() ), 940 connect( action, SIGNAL( activated() ),
942 SLOT( keyBindings() ) ); 941 SLOT( keyBindings() ) );
943 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); 942 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this );
944 action->addTo( helpMenu ); 943 action->addTo( helpMenu );
945 connect( action, SIGNAL( activated() ), 944 connect( action, SIGNAL( activated() ),
946 SLOT( synchowto() ) ); 945 SLOT( synchowto() ) );
947 action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this ); 946 action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this );
948 action->addTo( helpMenu ); 947 action->addTo( helpMenu );
949 connect( action, SIGNAL( activated() ), 948 connect( action, SIGNAL( activated() ),
950 SLOT( kdesynchowto() ) ); 949 SLOT( kdesynchowto() ) );
951 action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this ); 950 action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this );
952 action->addTo( helpMenu ); 951 action->addTo( helpMenu );
953 connect( action, SIGNAL( activated() ), 952 connect( action, SIGNAL( activated() ),
954 SLOT( multisynchowto() ) ); 953 SLOT( multisynchowto() ) );
955 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); 954 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this );
956 action->addTo( helpMenu ); 955 action->addTo( helpMenu );
957 connect( action, SIGNAL( activated() ), 956 connect( action, SIGNAL( activated() ),
958 SLOT( aboutAutoSaving() ) ); 957 SLOT( aboutAutoSaving() ) );
959 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); 958 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this );
960 action->addTo( helpMenu ); 959 action->addTo( helpMenu );
961 connect( action, SIGNAL( activated() ), 960 connect( action, SIGNAL( activated() ),
962 SLOT( aboutKnownBugs() ) ); 961 SLOT( aboutKnownBugs() ) );
963 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); 962 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this );
964 action->addTo( helpMenu ); 963 action->addTo( helpMenu );
965 connect( action, SIGNAL( activated() ), 964 connect( action, SIGNAL( activated() ),
966 SLOT( usertrans() ) ); 965 SLOT( usertrans() ) );
967 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); 966 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this );
968 action->addTo( helpMenu ); 967 action->addTo( helpMenu );
969 connect( action, SIGNAL( activated() ), 968 connect( action, SIGNAL( activated() ),
970 SLOT( faq() ) ); 969 SLOT( faq() ) );
971 action = new QAction( "licence", i18n("Licence..."), 0, this ); 970 action = new QAction( "licence", i18n("Licence..."), 0, this );
972 action->addTo( helpMenu ); 971 action->addTo( helpMenu );
973 connect( action, SIGNAL( activated() ), 972 connect( action, SIGNAL( activated() ),
974 SLOT( licence() ) ); 973 SLOT( licence() ) );
975 action = new QAction( "about", i18n("About..."), 0, this ); 974 action = new QAction( "about", i18n("About..."), 0, this );
976 action->addTo( helpMenu ); 975 action->addTo( helpMenu );
977 connect( action, SIGNAL( activated() ), 976 connect( action, SIGNAL( activated() ),
978 SLOT( about() ) ); 977 SLOT( about() ) );
979 //menuBar->insertSeparator(); 978 //menuBar->insertSeparator();
980 979
981 // ****************************************************** 980 // ******************************************************
982 // menubar icons 981 // menubar icons
983 982
984 983
985 iconToolBar->setHorizontalStretchable (true ); 984 iconToolBar->setHorizontalStretchable (true );
986 //menuBar->insertItem( iconToolBar ); 985 //menuBar->insertItem( iconToolBar );
987 //xdays_action 986 //xdays_action
988 if (p-> mShowIconNewEvent) 987 if (p-> mShowIconNewEvent)
989 ne_action->addTo( iconToolBar ); 988 ne_action->addTo( iconToolBar );
990 if (p->mShowIconNewTodo ) 989 if (p->mShowIconNewTodo )
991 nt_action->addTo( iconToolBar ); 990 nt_action->addTo( iconToolBar );
992 if (p-> mShowIconSearch) 991 if (p-> mShowIconSearch)
993 search_action->addTo( iconToolBar ); 992 search_action->addTo( iconToolBar );
994 if (p-> mShowIconNext) 993 if (p-> mShowIconNext)
995 whatsnext_action->addTo( iconToolBar ); 994 whatsnext_action->addTo( iconToolBar );
996 if (p-> mShowIconNextDays) 995 if (p-> mShowIconNextDays)
997 xdays_action->addTo( iconToolBar ); 996 xdays_action->addTo( iconToolBar );
998 if (p-> mShowIconList) 997 if (p-> mShowIconList)
999 showlist_action->addTo( iconToolBar ); 998 showlist_action->addTo( iconToolBar );
1000 if (p-> mShowIconDay1) 999 if (p-> mShowIconDay1)
1001 day1_action->addTo( iconToolBar ); 1000 day1_action->addTo( iconToolBar );
1002 if (p-> mShowIconDay5) 1001 if (p-> mShowIconDay5)
1003 day5_action->addTo( iconToolBar ); 1002 day5_action->addTo( iconToolBar );
1004 if (p-> mShowIconDay7) 1003 if (p-> mShowIconDay7)
1005 day7_action->addTo( iconToolBar ); 1004 day7_action->addTo( iconToolBar );
1006 if (p-> mShowIconDay6) 1005 if (p-> mShowIconDay6)
1007 day6_action->addTo( iconToolBar ); 1006 day6_action->addTo( iconToolBar );
1008 if (p-> mShowIconMonth) 1007 if (p-> mShowIconMonth)
1009 month_action->addTo( iconToolBar ); 1008 month_action->addTo( iconToolBar );
1010 if (p-> mShowIconTodoview) 1009 if (p-> mShowIconTodoview)
1011 todoview_action->addTo( iconToolBar ); 1010 todoview_action->addTo( iconToolBar );
1012 if (p-> mShowIconJournal) 1011 if (p-> mShowIconJournal)
1013 viewjournal_action->addTo( iconToolBar ); 1012 viewjournal_action->addTo( iconToolBar );
1014 icon = loadPixmap( pathString + "2leftarrowB" ); 1013 icon = loadPixmap( pathString + "2leftarrowB" );
1015 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); 1014 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14);
1016 if (p-> mShowIconBackFast) { 1015 if (p-> mShowIconBackFast) {
1017 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); 1016 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this );
1018 connect( action, SIGNAL( activated() ), 1017 connect( action, SIGNAL( activated() ),
1019 mView, SLOT( goPreviousMonth() ) ); 1018 mView, SLOT( goPreviousMonth() ) );
1020 action->addTo( iconToolBar ); 1019 action->addTo( iconToolBar );
1021 } 1020 }
1022 icon = loadPixmap( pathString + "1leftarrowB" ); 1021 icon = loadPixmap( pathString + "1leftarrowB" );
1023 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); 1022 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15);
1024 if (p-> mShowIconBack) { 1023 if (p-> mShowIconBack) {
1025 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); 1024 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this );
1026 connect( action, SIGNAL( activated() ), 1025 connect( action, SIGNAL( activated() ),
1027 mView, SLOT( goPrevious() ) ); 1026 mView, SLOT( goPrevious() ) );
1028 action->addTo( iconToolBar ); 1027 action->addTo( iconToolBar );
1029 } 1028 }
1030 icon = loadPixmap( pathString + "today" ); 1029 icon = loadPixmap( pathString + "today" );
1031 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); 1030 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130);
1032 if (p-> mShowIconToday) 1031 if (p-> mShowIconToday)
1033 today_action->addTo( iconToolBar ); 1032 today_action->addTo( iconToolBar );
1034 icon = loadPixmap( pathString + "1rightarrowB" ); 1033 icon = loadPixmap( pathString + "1rightarrowB" );
1035 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); 1034 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220);
1036 if (p-> mShowIconForward) { 1035 if (p-> mShowIconForward) {
1037 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); 1036 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this );
1038 connect( action, SIGNAL( activated() ), 1037 connect( action, SIGNAL( activated() ),
1039 mView, SLOT( goNext() ) ); 1038 mView, SLOT( goNext() ) );
1040 action->addTo( iconToolBar ); 1039 action->addTo( iconToolBar );
1041 } 1040 }
1042 icon = loadPixmap( pathString + "2rightarrowB" ); 1041 icon = loadPixmap( pathString + "2rightarrowB" );
1043 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); 1042 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230);
1044 if (p-> mShowIconForwardFast) { 1043 if (p-> mShowIconForwardFast) {
1045 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); 1044 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this );
1046 connect( action, SIGNAL( activated() ), 1045 connect( action, SIGNAL( activated() ),
1047 mView, SLOT( goNextMonth() ) ); 1046 mView, SLOT( goNextMonth() ) );
1048 action->addTo( iconToolBar ); 1047 action->addTo( iconToolBar );
1049 } 1048 }
1050 1049
1051 1050
1052 configureToolBarMenu->insertItem(i18n("What's This?"), 300); 1051 configureToolBarMenu->insertItem(i18n("What's This?"), 300);
1053 1052
1054 if (p-> mShowIconNewEvent) 1053 if (p-> mShowIconNewEvent)
1055 configureToolBarMenu->setItemChecked( 10, true ); 1054 configureToolBarMenu->setItemChecked( 10, true );
1056 if (p->mShowIconNewTodo ) 1055 if (p->mShowIconNewTodo )
1057 configureToolBarMenu->setItemChecked( 20, true ); 1056 configureToolBarMenu->setItemChecked( 20, true );
1058 if (p-> mShowIconSearch) 1057 if (p-> mShowIconSearch)
1059 configureToolBarMenu->setItemChecked( 120, true ); 1058 configureToolBarMenu->setItemChecked( 120, true );
1060 if (p-> mShowIconList) 1059 if (p-> mShowIconList)
1061 configureToolBarMenu->setItemChecked( 30, true ); 1060 configureToolBarMenu->setItemChecked( 30, true );
1062 if (p-> mShowIconDay1) 1061 if (p-> mShowIconDay1)
1063 configureToolBarMenu->setItemChecked( 40, true ); 1062 configureToolBarMenu->setItemChecked( 40, true );
1064 if (p-> mShowIconDay5) 1063 if (p-> mShowIconDay5)
1065 configureToolBarMenu->setItemChecked( 50, true ); 1064 configureToolBarMenu->setItemChecked( 50, true );
1066 if (p-> mShowIconDay6) 1065 if (p-> mShowIconDay6)
1067 configureToolBarMenu->setItemChecked( 75, true ); 1066 configureToolBarMenu->setItemChecked( 75, true );
1068 if (p-> mShowIconDay7) 1067 if (p-> mShowIconDay7)
1069 configureToolBarMenu->setItemChecked( 60, true ); 1068 configureToolBarMenu->setItemChecked( 60, true );
1070 if (p-> mShowIconMonth) 1069 if (p-> mShowIconMonth)
1071 configureToolBarMenu->setItemChecked( 70, true ); 1070 configureToolBarMenu->setItemChecked( 70, true );
1072 if (p-> mShowIconTodoview) 1071 if (p-> mShowIconTodoview)
1073 configureToolBarMenu->setItemChecked( 80, true ); 1072 configureToolBarMenu->setItemChecked( 80, true );
1074 if (p-> mShowIconBackFast) 1073 if (p-> mShowIconBackFast)
1075 configureToolBarMenu->setItemChecked( 200, true ); 1074 configureToolBarMenu->setItemChecked( 200, true );
1076 if (p-> mShowIconBack) 1075 if (p-> mShowIconBack)
1077 configureToolBarMenu->setItemChecked( 210, true ); 1076 configureToolBarMenu->setItemChecked( 210, true );
1078 if (p-> mShowIconToday) 1077 if (p-> mShowIconToday)
1079 configureToolBarMenu->setItemChecked( 130, true ); 1078 configureToolBarMenu->setItemChecked( 130, true );
1080 if (p-> mShowIconForward) 1079 if (p-> mShowIconForward)
1081 configureToolBarMenu->setItemChecked( 220, true ); 1080 configureToolBarMenu->setItemChecked( 220, true );
1082 if (p-> mShowIconForwardFast) 1081 if (p-> mShowIconForwardFast)
1083 configureToolBarMenu->setItemChecked( 230, true ); 1082 configureToolBarMenu->setItemChecked( 230, true );
1084 if (p-> mShowIconNextDays) 1083 if (p-> mShowIconNextDays)
1085 configureToolBarMenu->setItemChecked( 100, true ); 1084 configureToolBarMenu->setItemChecked( 100, true );
1086 if (p-> mShowIconNext) 1085 if (p-> mShowIconNext)
1087 configureToolBarMenu->setItemChecked( 110, true ); 1086 configureToolBarMenu->setItemChecked( 110, true );
1088 if (p-> mShowIconJournal) 1087 if (p-> mShowIconJournal)
1089 configureToolBarMenu->setItemChecked( 90, true ); 1088 configureToolBarMenu->setItemChecked( 90, true );
1090 if (p-> mShowIconWhatsThis) 1089 if (p-> mShowIconWhatsThis)
1091 configureToolBarMenu->setItemChecked( 300, true ); 1090 configureToolBarMenu->setItemChecked( 300, true );
1092 if (p-> mShowIconWeekNum) 1091 if (p-> mShowIconWeekNum)
1093 configureToolBarMenu->setItemChecked( 400, true ); 1092 configureToolBarMenu->setItemChecked( 400, true );
1094 QLabel* dummy = new QLabel( iconToolBar ); 1093 QLabel* dummy = new QLabel( iconToolBar );
1095 dummy->setBackgroundColor( iconToolBar->backgroundColor() ); 1094 dummy->setBackgroundColor( iconToolBar->backgroundColor() );
1096 if (!p-> mShowIconStretch) 1095 if (!p-> mShowIconStretch)
1097 iconToolBar->setStretchableWidget ( dummy ) ; 1096 iconToolBar->setStretchableWidget ( dummy ) ;
1098 else 1097 else
1099 configureToolBarMenu->setItemChecked( 5, true ); 1098 configureToolBarMenu->setItemChecked( 5, true );
1100 if (p-> mShowIconWhatsThis) 1099 if (p-> mShowIconWhatsThis)
1101 QWhatsThis::whatsThisButton ( iconToolBar ); 1100 QWhatsThis::whatsThisButton ( iconToolBar );
1102 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); 1101 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) );
1103 configureAgenda( p->mHourSize ); 1102 configureAgenda( p->mHourSize );
1104 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); 1103 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) );
1105} 1104}
1106 1105
1107void MainWindow::exportToPhone( int mode ) 1106void MainWindow::exportToPhone( int mode )
1108{ 1107{
1109 1108
1110 //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 1109 //ex2phone->insertItem(i18n("Complete calendar..."), 1 );
1111 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 1110 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
1112 KOex2phonePrefs ex2phone; 1111 KOex2phonePrefs ex2phone;
1113 1112
1114 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 1113 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
1115 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 1114 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
1116 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1115 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
1117 if ( mode == 1 ) 1116 if ( mode == 1 )
1118 ex2phone.setCaption(i18n("Export complete calendar")); 1117 ex2phone.setCaption(i18n("Export complete calendar"));
1119 if ( mode == 2 ) 1118 if ( mode == 2 )
1120 ex2phone.setCaption(i18n("Export filtered calendar")); 1119 ex2phone.setCaption(i18n("Export filtered calendar"));
1121 1120
1122 if ( !ex2phone.exec() ) { 1121 if ( !ex2phone.exec() ) {
1123 return; 1122 return;
1124 } 1123 }
1125 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 1124 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
1126 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 1125 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
1127 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 1126 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
1128 1127
1129 int inFuture = 0; 1128 int inFuture = 0;
1130 if ( ex2phone.mWriteBackFuture->isChecked() ) 1129 if ( ex2phone.mWriteBackFuture->isChecked() )
1131 inFuture = ex2phone.mWriteBackFutureWeeks->value(); 1130 inFuture = ex2phone.mWriteBackFutureWeeks->value();
1132 QPtrList<Incidence> delSel; 1131 QPtrList<Incidence> delSel;
1133 if ( mode == 1 ) 1132 if ( mode == 1 )
1134 delSel = mCalendar->rawIncidences(); 1133 delSel = mCalendar->rawIncidences();
1135 if ( mode == 2 ) 1134 if ( mode == 2 )
1136 delSel = mCalendar->incidences(); 1135 delSel = mCalendar->incidences();
1137 CalendarLocal* cal = new CalendarLocal(); 1136 CalendarLocal* cal = new CalendarLocal();
1138 cal->setLocalTime(); 1137 cal->setLocalTime();
1139 Incidence *incidence = delSel.first(); 1138 Incidence *incidence = delSel.first();
1140 QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); 1139 QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
1141 QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); 1140 QDateTime end = cur.addDays( ( inFuture +1 ) *7 );
1142 while ( incidence ) { 1141 while ( incidence ) {
1143 if ( incidence->type() != "Journal" ) { 1142 if ( incidence->type() != "Journal" ) {
1144 bool add = true; 1143 bool add = true;
1145 if ( inFuture ) { 1144 if ( inFuture ) {
1146 QDateTime dt; 1145 QDateTime dt;
1147 if ( incidence->type() == "Todo" ) { 1146 if ( incidence->type() == "Todo" ) {
1148 Todo * t = (Todo*)incidence; 1147 Todo * t = (Todo*)incidence;
1149 if ( t->hasDueDate() ) 1148 if ( t->hasDueDate() )
1150 dt = t->dtDue(); 1149 dt = t->dtDue();
1151 else 1150 else
1152 dt = cur.addSecs( 62 ); 1151 dt = cur.addSecs( 62 );
1153 } 1152 }
1154 else { 1153 else {
1155 bool ok; 1154 bool ok;
1156 dt = incidence->getNextOccurence( cur, &ok ); 1155 dt = incidence->getNextOccurence( cur, &ok );
1157 if ( !ok ) 1156 if ( !ok )
1158 dt = cur.addSecs( -62 ); 1157 dt = cur.addSecs( -62 );
1159 } 1158 }
1160 if ( dt < cur || dt > end ) { 1159 if ( dt < cur || dt > end ) {
1161 add = false; 1160 add = false;
1162 } 1161 }
1163 } 1162 }
1164 if ( add ) { 1163 if ( add ) {
1165 Incidence *in = incidence->clone(); 1164 Incidence *in = incidence->clone();
1166 cal->addIncidence( in ); 1165 cal->addIncidence( in );
1167 } 1166 }
1168 } 1167 }
1169 incidence = delSel.next(); 1168 incidence = delSel.next();
1170 } 1169 }
1171 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 1170 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
1172 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 1171 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
1173 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1172 KPimGlobalPrefs::instance()->mEx2PhoneModel );
1174 1173
1175 setCaption( i18n("Writing to phone...")); 1174 setCaption( i18n("Writing to phone..."));
1176 if ( PhoneFormat::writeToPhone( cal ) ) 1175 if ( PhoneFormat::writeToPhone( cal ) )
1177 setCaption( i18n("Export to phone successful!")); 1176 setCaption( i18n("Export to phone successful!"));
1178 else 1177 else
1179 setCaption( i18n("Error exporting to phone!")); 1178 setCaption( i18n("Error exporting to phone!"));
1180 delete cal; 1179 delete cal;
1181} 1180}
1182 1181
1183 1182
1184void MainWindow::setDefaultPreferences() 1183void MainWindow::setDefaultPreferences()
1185{ 1184{
1186 KOPrefs *p = KOPrefs::instance(); 1185 KOPrefs *p = KOPrefs::instance();
1187 1186
1188 p->mCompactDialogs = true; 1187 p->mCompactDialogs = true;
1189 p->mConfirm = true; 1188 p->mConfirm = true;
1190 // p->mEnableQuickTodo = false; 1189 // p->mEnableQuickTodo = false;
1191 1190
1192} 1191}
1193 1192
1194QString MainWindow::resourcePath() 1193QString MainWindow::resourcePath()
1195{ 1194{
1196 return KGlobal::iconLoader()->iconPath(); 1195 return KGlobal::iconLoader()->iconPath();
1197} 1196}
1198 1197
1199void MainWindow::displayText( QString text ,QString cap ) 1198void MainWindow::displayText( QString text ,QString cap )
1200{ 1199{
1201 QDialog dia( this, "name", true ); ; 1200 QDialog dia( this, "name", true ); ;
1202 dia.setCaption( cap ); 1201 dia.setCaption( cap );
1203 QVBoxLayout* lay = new QVBoxLayout( &dia ); 1202 QVBoxLayout* lay = new QVBoxLayout( &dia );
1204 lay->setSpacing( 3 ); 1203 lay->setSpacing( 3 );
1205 lay->setMargin( 3 ); 1204 lay->setMargin( 3 );
1206 QTextBrowser tb ( &dia ); 1205 QTextBrowser tb ( &dia );
1207 lay->addWidget( &tb ); 1206 lay->addWidget( &tb );
1208 tb.setText( text ); 1207 tb.setText( text );
1209#ifdef DESKTOP_VERSION 1208#ifdef DESKTOP_VERSION
1210 dia.resize( 640, 480); 1209 dia.resize( 640, 480);
1211#else 1210#else
1212 dia.showMaximized(); 1211 dia.showMaximized();
1213#endif 1212#endif
1214 dia.exec(); 1213 dia.exec();
1215} 1214}
1216 1215
1217void MainWindow::features() 1216void MainWindow::features()
1218{ 1217{
1219 1218
1220 KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" ); 1219 KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" );
1221} 1220}
1222 1221
1223void MainWindow::usertrans() 1222void MainWindow::usertrans()
1224{ 1223{
1225 1224
1226 KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" ); 1225 KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" );
1227} 1226}
1228 1227
1229void MainWindow::kdesynchowto() 1228void MainWindow::kdesynchowto()
1230{ 1229{
1231 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); 1230 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" );
1232} 1231}
1233void MainWindow::multisynchowto() 1232void MainWindow::multisynchowto()
1234{ 1233{
1235 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); 1234 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" );
1236} 1235}
1237void MainWindow::synchowto() 1236void MainWindow::synchowto()
1238{ 1237{
1239 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 1238 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
1240} 1239}
1241void MainWindow::faq() 1240void MainWindow::faq()
1242{ 1241{
1243 KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" ); 1242 KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" );
1244 1243
1245} 1244}
1246void MainWindow::whatsNew() 1245void MainWindow::whatsNew()
1247{ 1246{
1248 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 1247 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
1249 1248
1250} 1249}
1251void MainWindow::licence() 1250void MainWindow::licence()
1252{ 1251{
1253 KApplication::showLicence(); 1252 KApplication::showLicence();
1254 1253
1255} 1254}
1256void MainWindow::about() 1255void MainWindow::about()
1257{ 1256{
1258 QString version; 1257 QString version;
1259#include <../version> 1258#include <../version>
1260 QMessageBox::about( this, i18n("About KOrganizer/Pi"), 1259 QMessageBox::about( this, i18n("About KOrganizer/Pi"),
1261 i18n("KOrganizer/Platform-independent\n") + 1260 i18n("KOrganizer/Platform-independent\n") +
1262 "(KO/Pi) " + version + " - " + 1261 "(KO/Pi) " + version + " - " +
1263 1262
1264#ifdef DESKTOP_VERSION 1263#ifdef DESKTOP_VERSION
1265 i18n("Desktop Edition\n") + 1264 i18n("Desktop Edition\n") +
1266#else 1265#else
1267 i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") + 1266 i18n("PDA-Edition\nfor: Zaurus 5x00/7x0/860/3000/6000\n") +
1268#endif 1267#endif
1269 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!") ); 1268 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!") );
1270} 1269}
1271void MainWindow::keyBindings() 1270void MainWindow::keyBindings()
1272{ 1271{
1273 QString cap = i18n("KO/Pi Keys + Colors"); 1272 QString cap = i18n("KO/Pi Keys + Colors");
1274 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + 1273 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") +
1275 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ 1274 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+
1276 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + 1275 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") +
1277 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ 1276 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+
1278 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ 1277 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+
1279 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ 1278 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+
1280 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ 1279 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+
1281 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ 1280 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+
1282 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ 1281 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+
1283 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ 1282 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+
1284 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ 1283 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+
1285 i18n("<p><b>K</b>: Week view in Month view syle</p>\n")+ 1284 i18n("<p><b>K</b>: Week view in Month view syle</p>\n")+
1286 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ 1285 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+
1287 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ 1286 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+
1288 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ 1287 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+
1289 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ 1288 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+
1290 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ 1289 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+
1291 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ 1290 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+
1292 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ 1291 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+
1293 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ 1292 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+
1294 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ 1293 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+
1295 i18n("<p><h3>In agenda view:</h3></p>\n") + 1294 i18n("<p><h3>In agenda view:</h3></p>\n") +
1296 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ 1295 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+
1297 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ 1296 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+
1298 i18n("<p><h3>In todo view:</h3></p>\n") + 1297 i18n("<p><h3>In todo view:</h3></p>\n") +
1299 i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ 1298 i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+
1300 i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ 1299 i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+
1301 i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ 1300 i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+
1302 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ 1301 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+
1303 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1302 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1304 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ 1303 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+
1305 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ 1304 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+
1306 i18n("<p><h3>In list view:</h3></p>\n") + 1305 i18n("<p><h3>In list view:</h3></p>\n") +
1307 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1306 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1308 i18n("<p><b>return</b>: Select item+one step down</p>\n")+ 1307 i18n("<p><b>return</b>: Select item+one step down</p>\n")+
1309 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ 1308 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+
1310 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ 1309 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+
1311 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ 1310 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+
1312 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ 1311 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+
1313 i18n("<p><h3>In event/todo viewer:</h3></p>\n") + 1312 i18n("<p><h3>In event/todo viewer:</h3></p>\n") +
1314 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ 1313 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+
1315 i18n("<p><b>A</b>: Show agenda view.</p>\n")+ 1314 i18n("<p><b>A</b>: Show agenda view.</p>\n")+
1316 i18n("<p><b>E</b>: Edit item</p>\n") + 1315 i18n("<p><b>E</b>: Edit item</p>\n") +
1317 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + 1316 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") +
1318 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + 1317 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") +
1319 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ 1318 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+
1320 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ 1319 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+
1321 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ 1320 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+
1322 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ 1321 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+
1323 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ 1322 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+
1324 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + 1323 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") +
1325 i18n("<p><b>White</b>: Item readonly</p>\n"); 1324 i18n("<p><b>White</b>: Item readonly</p>\n");
1326 displayText( text, cap); 1325 displayText( text, cap);
1327} 1326}
1328void MainWindow::aboutAutoSaving() 1327void MainWindow::aboutAutoSaving()
1329{ 1328{
1330 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"); 1329 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");
1331 1330
1332 KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text); 1331 KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text);
1333 1332
1334} 1333}
1335void MainWindow::aboutKnownBugs() 1334void MainWindow::aboutKnownBugs()
1336{ 1335{
1337 QMessageBox* msg; 1336 QMessageBox* msg;
1338 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), 1337 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"),
1339 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")+ 1338 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")+
1340 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ 1339 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+
1341 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + 1340 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") +
1342 i18n("\nor report them in the bugtracker on\n") + 1341 i18n("\nor report them in the bugtracker on\n") +
1343 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), 1342 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"),
1344 QMessageBox::NoIcon, 1343 QMessageBox::NoIcon,
1345 QMessageBox::Ok, 1344 QMessageBox::Ok,
1346 QMessageBox::NoButton, 1345 QMessageBox::NoButton,
1347 QMessageBox::NoButton); 1346 QMessageBox::NoButton);
1348 msg->exec(); 1347 msg->exec();
1349 delete msg; 1348 delete msg;
1350 1349
1351} 1350}
1352 1351
1353QString MainWindow::defaultFileName() 1352QString MainWindow::defaultFileName()
1354{ 1353{
1355 return locateLocal( "data", "korganizer/mycalendar.ics" ); 1354 return locateLocal( "data", "korganizer/mycalendar.ics" );
1356} 1355}
1357QString MainWindow::syncFileName() 1356QString MainWindow::syncFileName()
1358{ 1357{
1359#ifdef DESKTOP_VERSION 1358#ifdef DESKTOP_VERSION
1360 return locateLocal( "tmp", "synccalendar.ics" ); 1359 return locateLocal( "tmp", "synccalendar.ics" );
1361#else 1360#else
1362 return QString( "/tmp/synccalendar.ics" ); 1361 return QString( "/tmp/synccalendar.ics" );
1363#endif 1362#endif
1364} 1363}
1365void MainWindow::updateWeek(QDate seda) 1364void MainWindow::updateWeek(QDate seda)
1366{ 1365{
1367 int weekNum = 0; 1366 int weekNum = 0;
1368 QDate d = QDate ( seda.year(), 1,1); 1367 QDate d = QDate ( seda.year(), 1,1);
1369 seda = seda.addDays( 1-seda.dayOfWeek() );//we are on monday 1368 seda = seda.addDays( 1-seda.dayOfWeek() );//we are on monday
1370 if ( seda.addDays(6).year() != seda.year() ) { 1369 if ( seda.addDays(6).year() != seda.year() ) {
1371 if ( seda.year() != d.year() ) { 1370 if ( seda.year() != d.year() ) {
1372 if ( d.dayOfWeek() > 4 ) 1371 if ( d.dayOfWeek() > 4 )
1373 d = QDate ( seda.year(), 1,1); 1372 d = QDate ( seda.year(), 1,1);
1374 else 1373 else
1375 weekNum = 1; 1374 weekNum = 1;
1376 } else { 1375 } else {
1377 QDate dd( seda.year()+1, 1,1); 1376 QDate dd( seda.year()+1, 1,1);
1378 if ( dd.dayOfWeek() <= 4 ) 1377 if ( dd.dayOfWeek() <= 4 )
1379 weekNum = 1; 1378 weekNum = 1;
1380 } 1379 }
1381 } 1380 }
1382 if ( weekNum == 0 ){ 1381 if ( weekNum == 0 ){
1383 int dow = d.dayOfWeek(); 1382 int dow = d.dayOfWeek();
1384 if ( dow <= 4 ) 1383 if ( dow <= 4 )
1385 d = d.addDays( 1-dow ); 1384 d = d.addDays( 1-dow );
1386 else // 5,6,7 1385 else // 5,6,7
1387 d = d.addDays( 8-dow ); 1386 d = d.addDays( 8-dow );
1388 // we have the first week of the year.we are on monday 1387 // we have the first week of the year.we are on monday
1389 weekNum = d.daysTo( seda ) / 7 +1; 1388 weekNum = d.daysTo( seda ) / 7 +1;
1390 } 1389 }
1391 1390
1392 mWeekPixmap.fill( mWeekBgColor ); 1391 mWeekPixmap.fill( mWeekBgColor );
1393 QPainter p ( &mWeekPixmap ); 1392 QPainter p ( &mWeekPixmap );
1394 p.setFont( mWeekFont ); 1393 p.setFont( mWeekFont );
1395 p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) ); 1394 p.drawText( 0,0,mWeekPixmap.width(), mWeekPixmap.height(),AlignCenter, QString::number( weekNum) );
1396 p.end(); 1395 p.end();
1397 QIconSet icon3 ( mWeekPixmap ); 1396 QIconSet icon3 ( mWeekPixmap );
1398 mWeekAction->setIconSet ( icon3 ); 1397 mWeekAction->setIconSet ( icon3 );
1399 1398
1400} 1399}
1401void MainWindow::updateWeekNum(const DateList &selectedDates) 1400void MainWindow::updateWeekNum(const DateList &selectedDates)
1402{ 1401{
1403 updateWeek( selectedDates.first() ); 1402 updateWeek( selectedDates.first() );
1404} 1403}
1405void MainWindow::processIncidenceSelection( Incidence *incidence ) 1404void MainWindow::processIncidenceSelection( Incidence *incidence )
1406{ 1405{
1407 1406
1408 if ( !incidence ) { 1407 if ( !incidence ) {
1409 enableIncidenceActions( false ); 1408 enableIncidenceActions( false );
1410 1409
1411 mNewSubTodoAction->setEnabled( false ); 1410 mNewSubTodoAction->setEnabled( false );
1412 setCaptionToDates(); 1411 setCaptionToDates();
1413 return; 1412 return;
1414 1413
1415 } 1414 }
1416 1415
1417 //KGlobal::locale()->formatDateTime(nextA, true); 1416 //KGlobal::locale()->formatDateTime(nextA, true);
1418 QString startString = ""; 1417 QString startString = "";
1419 if ( incidence->type() != "Todo" ) { 1418 if ( incidence->type() != "Todo" ) {
1420 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { 1419 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) {
1421 if ( incidence->doesFloat() ) { 1420 if ( incidence->doesFloat() ) {
1422 startString += ": "+incidence->dtStartDateStr( true ); 1421 startString += ": "+incidence->dtStartDateStr( true );
1423 startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); 1422 startString += " --- "+((Event*)incidence)->dtEndDateStr( true );
1424 1423
1425 } else { 1424 } else {
1426 startString = ": "+incidence->dtStartStr(true); 1425 startString = ": "+incidence->dtStartStr(true);
1427 startString += " --- "+((Event*)incidence)->dtEndStr(true); 1426 startString += " --- "+((Event*)incidence)->dtEndStr(true);
1428 1427
1429 } 1428 }
1430 1429
1431 } else { 1430 } else {
1432 if ( incidence->dtStart().time() != incidence->dtEnd().time() ) 1431 if ( incidence->dtStart().time() != incidence->dtEnd().time() )
1433 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ 1432 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+
1434 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); 1433 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time());
1435 if ( incidence->categories().contains( i18n("Birthday") ) || incidence->categories().contains( i18n("Anniversary") ) ) { 1434 if ( incidence->categories().contains( i18n("Birthday") ) || incidence->categories().contains( i18n("Anniversary") ) ) {
1436 bool ok; 1435 bool ok;
1437 QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok ); 1436 QDateTime noc = incidence->getNextOccurence( mView->startDate().addDays(-1), &ok );
1438 if ( ok ) { 1437 if ( ok ) {
1439 int years = noc.date().year() - incidence->dtStart().date().year(); 1438 int years = noc.date().year() - incidence->dtStart().date().year();
1440 startString += i18n(" (%1 y.)"). arg( years ); 1439 startString += i18n(" (%1 y.)"). arg( years );
1441 } 1440 }
1442 } 1441 }
1443 else 1442 else
1444 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); 1443 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true);
1445 } 1444 }
1446 1445
1447 } 1446 }
1448 else 1447 else
1449 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); 1448 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed");
1450 if ( !incidence->location().isEmpty() ) 1449 if ( !incidence->location().isEmpty() )
1451 startString += " (" +incidence->location()+")"; 1450 startString += " (" +incidence->location()+")";
1452 setCaption( incidence->summary()+startString); 1451 setCaption( incidence->summary()+startString);
1453 1452
1454 enableIncidenceActions( true ); 1453 enableIncidenceActions( true );
1455 1454
1456 if ( incidence->type() == "Event" ) { 1455 if ( incidence->type() == "Event" ) {
1457 mShowAction->setText( i18n("Show Event...") ); 1456 mShowAction->setText( i18n("Show Event...") );
1458 mEditAction->setText( i18n("Edit Event...") ); 1457 mEditAction->setText( i18n("Edit Event...") );
1459 mDeleteAction->setText( i18n("Delete Event...") ); 1458 mDeleteAction->setText( i18n("Delete Event...") );
1460 1459
1461 mNewSubTodoAction->setEnabled( false ); 1460 mNewSubTodoAction->setEnabled( false );
1462 } else if ( incidence->type() == "Todo" ) { 1461 } else if ( incidence->type() == "Todo" ) {
1463 mShowAction->setText( i18n("Show Todo...") ); 1462 mShowAction->setText( i18n("Show Todo...") );
1464 mEditAction->setText( i18n("Edit Todo...") ); 1463 mEditAction->setText( i18n("Edit Todo...") );
1465 mDeleteAction->setText( i18n("Delete Todo...") ); 1464 mDeleteAction->setText( i18n("Delete Todo...") );
1466 1465
1467 mNewSubTodoAction->setEnabled( true ); 1466 mNewSubTodoAction->setEnabled( true );
1468 } else { 1467 } else {
1469 mShowAction->setText( i18n("Show...") ); 1468 mShowAction->setText( i18n("Show...") );
1470 mShowAction->setText( i18n("Edit...") ); 1469 mShowAction->setText( i18n("Edit...") );
1471 mShowAction->setText( i18n("Delete...") ); 1470 mShowAction->setText( i18n("Delete...") );
1472 1471
1473 mNewSubTodoAction->setEnabled( false ); 1472 mNewSubTodoAction->setEnabled( false );
1474 } 1473 }
1475} 1474}
1476 1475
1477void MainWindow::enableIncidenceActions( bool enabled ) 1476void MainWindow::enableIncidenceActions( bool enabled )
1478{ 1477{
1479 mShowAction->setEnabled( enabled ); 1478 mShowAction->setEnabled( enabled );
1480 mEditAction->setEnabled( enabled ); 1479 mEditAction->setEnabled( enabled );
1481 mDeleteAction->setEnabled( enabled ); 1480 mDeleteAction->setEnabled( enabled );
1482 1481
1483 mCloneAction->setEnabled( enabled ); 1482 mCloneAction->setEnabled( enabled );
1484 mMoveAction->setEnabled( enabled ); 1483 mMoveAction->setEnabled( enabled );
1485 mBeamAction->setEnabled( enabled ); 1484 mBeamAction->setEnabled( enabled );
1486 mCancelAction->setEnabled( enabled ); 1485 mCancelAction->setEnabled( enabled );
1487} 1486}
1488 1487
1489void MainWindow::importOL() 1488void MainWindow::importOL()
1490{ 1489{
1491#ifdef _OL_IMPORT_ 1490#ifdef _OL_IMPORT_
1492 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); 1491 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this );
1493 id->exec(); 1492 id->exec();
1494 delete id; 1493 delete id;
1495 mView->updateView(); 1494 mView->updateView();
1496#endif 1495#endif
1497} 1496}
1498void MainWindow::importBday() 1497void MainWindow::importBday()
1499{ 1498{
1500 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1499 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1501 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), 1500 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"),
1502 i18n("Import!"), i18n("Cancel"), 0, 1501 i18n("Import!"), i18n("Cancel"), 0,
1503 0, 1 ); 1502 0, 1 );
1504 if ( result == 0 ) { 1503 if ( result == 0 ) {
1505 mView->importBday(); 1504 mView->importBday();
1506 1505
1507 } 1506 }
1508 1507
1509 1508
1510} 1509}
1511void MainWindow::importQtopia() 1510void MainWindow::importQtopia()
1512{ 1511{
1513#ifndef DESKTOP_VERSION 1512#ifndef DESKTOP_VERSION
1514 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1513 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1515 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"), 1514 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"),
1516 i18n("Import!"), i18n("Cancel"), 0, 1515 i18n("Import!"), i18n("Cancel"), 0,
1517 0, 1 ); 1516 0, 1 );
1518 if ( result == 0 ) { 1517 if ( result == 0 ) {
1519 QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); 1518 QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
1520 QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); 1519 QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
1521 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; 1520 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
1522 mView->importQtopia( categories, datebook, todolist ); 1521 mView->importQtopia( categories, datebook, todolist );
1523 } 1522 }
1524#else 1523#else
1525 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1524 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1526 i18n("Not supported \non desktop!\n"), 1525 i18n("Not supported \non desktop!\n"),
1527 i18n("Ok"), i18n("Cancel"), 0, 1526 i18n("Ok"), i18n("Cancel"), 0,
1528 0, 1 ); 1527 0, 1 );
1529 1528
1530#endif 1529#endif
1531} 1530}
1532 1531
1533void MainWindow::saveOnClose() 1532void MainWindow::saveOnClose()
1534{ 1533{
1535 KOPrefs *p = KOPrefs::instance(); 1534 KOPrefs *p = KOPrefs::instance();
1536 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); 1535 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
1537 p->mToolBarUp = iconToolBar->x() > width()/2 || 1536 p->mToolBarUp = iconToolBar->x() > width()/2 ||
1538 iconToolBar->y() > height()/2; 1537 iconToolBar->y() > height()/2;
1539 mView->writeSettings(); 1538 mView->writeSettings();
1540 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) 1539 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName()))
1541 save(); 1540 save();
1542} 1541}
1543void MainWindow::slotModifiedChanged( bool changed ) 1542void MainWindow::slotModifiedChanged( bool changed )
1544{ 1543{
1545 if ( mBlockAtStartup ) 1544 if ( mBlockAtStartup )
1546 return; 1545 return;
1547 1546
1548 int msec; 1547 int msec;
1549 // we store the changes after 1 minute, 1548 // we store the changes after 1 minute,
1550 // and for safety reasons after 10 minutes again 1549 // and for safety reasons after 10 minutes again
1551 if ( !mSyncManager->blockSave() ) 1550 if ( !mSyncManager->blockSave() )
1552 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1551 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1553 else 1552 else
1554 msec = 1000 * 600; 1553 msec = 1000 * 600;
1555 mSaveTimer.start( msec, true ); // 1 minute 1554 mSaveTimer.start( msec, true ); // 1 minute
1556 qDebug("KO: Saving File in %d secs!", msec/1000); 1555 qDebug("KO: Saving File in %d secs!", msec/1000);
1557 mCalendarModifiedFlag = true; 1556 mCalendarModifiedFlag = true;
1558} 1557}
1559void MainWindow::saveStopTimer() 1558void MainWindow::saveStopTimer()
1560{ 1559{
1561 mSaveTimer.stop(); 1560 mSaveTimer.stop();
1562 if (mSaveTimer.isActive() ) 1561 if (mSaveTimer.isActive() )
1563 qDebug("ti active "); 1562 qDebug("ti active ");
1564 else 1563 else
1565 qDebug("KO: Save timer stopped"); 1564 qDebug("KO: Save timer stopped");
1566} 1565}
1567void MainWindow::save() 1566void MainWindow::save()
1568{ 1567{
1569 if ( !mCalendarModifiedFlag ) { 1568 if ( !mCalendarModifiedFlag ) {
1570 qDebug("KO: Calendar not modified. Nothing saved."); 1569 qDebug("KO: Calendar not modified. Nothing saved.");
1571 return; 1570 return;
1572 } 1571 }
1573 if ( mSyncManager->blockSave() ) 1572 if ( mSyncManager->blockSave() )
1574 return; 1573 return;
1575 mSyncManager->setBlockSave(true); 1574 mSyncManager->setBlockSave(true);
1576 if ( mView->checkFileVersion( defaultFileName()) ) { 1575 if ( mView->checkFileVersion( defaultFileName()) ) {
1577 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1576 QTime neededSaveTime = QDateTime::currentDateTime().time();
1578 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1577 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1579 qDebug("KO: Start saving data to file!"); 1578 qDebug("KO: Start saving data to file!");
1580 mView->saveCalendar( defaultFileName() ); 1579 mView->saveCalendar( defaultFileName() );
1581 mCalendarModifiedFlag = false; 1580 mCalendarModifiedFlag = false;
1582 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 1581 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1583 qDebug("KO: Needed %d ms for saving.",msNeeded ); 1582 qDebug("KO: Needed %d ms for saving.",msNeeded );
1584 QString savemes; 1583 QString savemes;
1585 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 1584 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
1586 setCaption(savemes); 1585 setCaption(savemes);
1587 } else 1586 } else
1588 setCaption(i18n("Saving cancelled!")); 1587 setCaption(i18n("Saving cancelled!"));
1589 mSyncManager->setBlockSave( false ); 1588 mSyncManager->setBlockSave( false );
1590} 1589}
1591 1590
1592void MainWindow::keyReleaseEvent ( QKeyEvent * e) 1591void MainWindow::keyReleaseEvent ( QKeyEvent * e)
1593{ 1592{
1594 if ( !e->isAutoRepeat() ) { 1593 if ( !e->isAutoRepeat() ) {
1595 mFlagKeyPressed = false; 1594 mFlagKeyPressed = false;
1596 } 1595 }
1597} 1596}
1598void MainWindow::keyPressEvent ( QKeyEvent * e ) 1597void MainWindow::keyPressEvent ( QKeyEvent * e )
1599{ 1598{
1600 qApp->processEvents(); 1599 qApp->processEvents();
1601 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 1600 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1602 e->ignore(); 1601 e->ignore();
1603 // qDebug(" ignore %d",e->isAutoRepeat() ); 1602 // qDebug(" ignore %d",e->isAutoRepeat() );
1604 return; 1603 return;
1605 } 1604 }
1606 if (! e->isAutoRepeat() ) 1605 if (! e->isAutoRepeat() )
1607 mFlagKeyPressed = true; 1606 mFlagKeyPressed = true;
1608 KOPrefs *p = KOPrefs::instance(); 1607 KOPrefs *p = KOPrefs::instance();
1609 bool showSelectedDates = false; 1608 bool showSelectedDates = false;
1610 int size; 1609 int size;
1611 int pro = 0; 1610 int pro = 0;
1612 //qDebug("MainWindow::keyPressEvent "); 1611 //qDebug("MainWindow::keyPressEvent ");
1613 switch ( e->key() ) { 1612 switch ( e->key() ) {
1614 case Qt::Key_Right: 1613 case Qt::Key_Right:
1615 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1614 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1616 mView->goNextMonth(); 1615 mView->goNextMonth();
1617 else 1616 else
1618 mView->goNext(); 1617 mView->goNext();
1619 showSelectedDates = true; 1618 showSelectedDates = true;
1620 break; 1619 break;
1621 case Qt::Key_Left: 1620 case Qt::Key_Left:
1622 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1621 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1623 mView->goPreviousMonth(); 1622 mView->goPreviousMonth();
1624 else 1623 else
1625 mView->goPrevious(); 1624 mView->goPrevious();
1626 showSelectedDates = true; 1625 showSelectedDates = true;
1627 break; 1626 break;
1628 case Qt::Key_Down: 1627 case Qt::Key_Down:
1629 mView->viewManager()->agendaView()->scrollOneHourDown(); 1628 mView->viewManager()->agendaView()->scrollOneHourDown();
1630 break; 1629 break;
1631 case Qt::Key_Up: 1630 case Qt::Key_Up:
1632 mView->viewManager()->agendaView()->scrollOneHourUp(); 1631 mView->viewManager()->agendaView()->scrollOneHourUp();
1633 break; 1632 break;
1634 case Qt::Key_K: 1633 case Qt::Key_K:
1635 mView->viewManager()->showMonthViewWeek(); 1634 mView->viewManager()->showMonthViewWeek();
1636 break; 1635 break;
1637 case Qt::Key_I: 1636 case Qt::Key_I:
1638 mView->showIncidence(); 1637 mView->showIncidence();
1639 break; 1638 break;
1640 case Qt::Key_Delete: 1639 case Qt::Key_Delete:
1641 case Qt::Key_Backspace: 1640 case Qt::Key_Backspace:
1642 mView->deleteIncidence(); 1641 mView->deleteIncidence();
1643 break; 1642 break;
1644 case Qt::Key_D: 1643 case Qt::Key_D:
1645 mView->viewManager()->showDayView(); 1644 mView->viewManager()->showDayView();
1646 showSelectedDates = true; 1645 showSelectedDates = true;
1647 break; 1646 break;
1648 case Qt::Key_O: 1647 case Qt::Key_O:
1649 mView->toggleFilerEnabled( ); 1648 mView->toggleFilerEnabled( );
1650 break; 1649 break;
1651 case Qt::Key_0: 1650 case Qt::Key_0:
1652 case Qt::Key_1: 1651 case Qt::Key_1:
1653 case Qt::Key_2: 1652 case Qt::Key_2:
1654 case Qt::Key_3: 1653 case Qt::Key_3:
1655 case Qt::Key_4: 1654 case Qt::Key_4:
1656 case Qt::Key_5: 1655 case Qt::Key_5:
1657 case Qt::Key_6: 1656 case Qt::Key_6:
1658 case Qt::Key_7: 1657 case Qt::Key_7:
1659 case Qt::Key_8: 1658 case Qt::Key_8:
1660 case Qt::Key_9: 1659 case Qt::Key_9:
1661 pro = e->key()-48; 1660 pro = e->key()-48;
1662 if ( pro == 0 ) 1661 if ( pro == 0 )
1663 pro = 10; 1662 pro = 10;
1664 if ( e->state() == Qt::ControlButton) 1663 if ( e->state() == Qt::ControlButton)
1665 pro += 10; 1664 pro += 10;
1666 break; 1665 break;
1667 case Qt::Key_M: 1666 case Qt::Key_M:
1668 mView->viewManager()->showMonthView(); 1667 mView->viewManager()->showMonthView();
1669 showSelectedDates = true; 1668 showSelectedDates = true;
1670 break; 1669 break;
1671 case Qt::Key_Insert: 1670 case Qt::Key_Insert:
1672 mView->newEvent(); 1671 mView->newEvent();
1673 break; 1672 break;
1674 case Qt::Key_S : 1673 case Qt::Key_S :
1675 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1674 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1676 mView->newSubTodo(); 1675 mView->newSubTodo();
1677 else 1676 else
1678 mView->dialogManager()->showSearchDialog(); 1677 mView->dialogManager()->showSearchDialog();
1679 break; 1678 break;
1680 case Qt::Key_Y : 1679 case Qt::Key_Y :
1681 case Qt::Key_Z : 1680 case Qt::Key_Z :
1682 mView->viewManager()->showWorkWeekView(); 1681 mView->viewManager()->showWorkWeekView();
1683 showSelectedDates = true; 1682 showSelectedDates = true;
1684 break; 1683 break;
1685 case Qt::Key_U : 1684 case Qt::Key_U :
1686 mView->viewManager()->showWeekView(); 1685 mView->viewManager()->showWeekView();
1687 showSelectedDates = true; 1686 showSelectedDates = true;
1688 break; 1687 break;
1689 case Qt::Key_H : 1688 case Qt::Key_H :
1690 keyBindings(); 1689 keyBindings();
1691 break; 1690 break;
1692 case Qt::Key_W: 1691 case Qt::Key_W:
1693 mView->viewManager()->showWhatsNextView(); 1692 mView->viewManager()->showWhatsNextView();
1694 break; 1693 break;
1695 case Qt::Key_L: 1694 case Qt::Key_L:
1696 mView->viewManager()->showListView(); 1695 mView->viewManager()->showListView();
1697 break; 1696 break;
1698 case Qt::Key_N: 1697 case Qt::Key_N:
1699 mView->viewManager()->showNextXView(); 1698 mView->viewManager()->showNextXView();
1700 showSelectedDates = true; 1699 showSelectedDates = true;
1701 break; 1700 break;
1702 case Qt::Key_V: 1701 case Qt::Key_V:
1703 mView->viewManager()->showTodoView(); 1702 mView->viewManager()->showTodoView();
1704 break; 1703 break;
1705 case Qt::Key_C: 1704 case Qt::Key_C:
1706 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); 1705 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() );
1707 break; 1706 break;
1708 case Qt::Key_P: 1707 case Qt::Key_P:
1709 mView->showDatePicker( ); 1708 mView->showDatePicker( );
1710 break; 1709 break;
1711 case Qt::Key_F: 1710 case Qt::Key_F:
1712 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1711 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1713 mView->editFilters(); 1712 mView->editFilters();
1714 else 1713 else
1715 mView->toggleFilter(); 1714 mView->toggleFilter();
1716 break; 1715 break;
1717 case Qt::Key_X: 1716 case Qt::Key_X:
1718 mView->toggleDateNavigatorWidget(); 1717 mView->toggleDateNavigatorWidget();
1719 break; 1718 break;
1720 case Qt::Key_Space: 1719 case Qt::Key_Space:
1721 mView->toggleExpand(); 1720 mView->toggleExpand();
1722 break; 1721 break;
1723 case Qt::Key_A: 1722 case Qt::Key_A:
1724 mView->toggleAllDaySize(); 1723 mView->toggleAllDaySize();
1725 break; 1724 break;
1726 case Qt::Key_T: 1725 case Qt::Key_T:
1727 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1726 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1728 mView->newTodo(); 1727 mView->newTodo();
1729 else { 1728 else {
1730 mView->goToday(); 1729 mView->goToday();
1731 showSelectedDates = true; 1730 showSelectedDates = true;
1732 } 1731 }
1733 break; 1732 break;
1734 case Qt::Key_J: 1733 case Qt::Key_J:
1735 mView->viewManager()->showJournalView(); 1734 mView->viewManager()->showJournalView();
1736 break; 1735 break;
1737 case Qt::Key_B: 1736 case Qt::Key_B:
1738 mView->editIncidenceDescription();; 1737 mView->editIncidenceDescription();;
1739 break; 1738 break;
1740 // case Qt::Key_Return: 1739 // case Qt::Key_Return:
1741 case Qt::Key_E: 1740 case Qt::Key_E:
1742 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1741 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1743 mView->newEvent(); 1742 mView->newEvent();
1744 else 1743 else
1745 mView->editIncidence(); 1744 mView->editIncidence();
1746 break; 1745 break;
1747 case Qt::Key_Plus: 1746 case Qt::Key_Plus:
1748 size = p->mHourSize +2; 1747 size = p->mHourSize +2;
1749 if ( size <= 22 ) 1748 if ( size <= 22 )
1750 configureAgenda( size ); 1749 configureAgenda( size );
1751 break; 1750 break;
1752 case Qt::Key_Minus: 1751 case Qt::Key_Minus:
1753 size = p->mHourSize - 2; 1752 size = p->mHourSize - 2;
1754 if ( size >= 4 ) 1753 if ( size >= 4 )
1755 configureAgenda( size ); 1754 configureAgenda( size );
1756 break; 1755 break;
1757 1756
1758 1757
1759 default: 1758 default:
1760 e->ignore(); 1759 e->ignore();
1761 } 1760 }
1762 if ( pro > 0 ) { 1761 if ( pro > 0 ) {
1763 mView->selectFilter( pro-1 ); 1762 mView->selectFilter( pro-1 );
1764 } 1763 }
1765 if ( showSelectedDates ) { 1764 if ( showSelectedDates ) {
1766 ;// setCaptionToDates(); 1765 ;// setCaptionToDates();
1767 } 1766 }
1768 1767
1769} 1768}
1770 1769
1771void MainWindow::fillFilterMenu() 1770void MainWindow::fillFilterMenu()
1772{ 1771{
1773 selectFilterMenu->clear(); 1772 selectFilterMenu->clear();
1774 bool disable = false; 1773 bool disable = false;
1775 selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 ); 1774 selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 );
1776 selectFilterMenu->insertSeparator(); 1775 selectFilterMenu->insertSeparator();
1777 if ( mView->filterView()->filtersEnabled() ) { 1776 if ( mView->filterView()->filtersEnabled() ) {
1778 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 1 ); 1777 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 1 );
1779 } 1778 }
1780 else { 1779 else {
1781 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 1 ); 1780 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 1 );
1782 disable = true; 1781 disable = true;
1783 } 1782 }
1784 selectFilterMenu->insertSeparator(); 1783 selectFilterMenu->insertSeparator();
1785 QPtrList<CalFilter> fili = mView->filters(); 1784 QPtrList<CalFilter> fili = mView->filters();
1786 CalFilter *curfilter = mView->filterView()->selectedFilter(); 1785 CalFilter *curfilter = mView->filterView()->selectedFilter();
1787 CalFilter *filter = fili.first(); 1786 CalFilter *filter = fili.first();
1788 int iii = 2; 1787 int iii = 2;
1789 while(filter) { 1788 while(filter) {
1790 selectFilterMenu->insertItem( filter->name(), iii ); 1789 selectFilterMenu->insertItem( filter->name(), iii );
1791 if ( filter == curfilter) 1790 if ( filter == curfilter)
1792 selectFilterMenu->setItemChecked( iii, true ); 1791 selectFilterMenu->setItemChecked( iii, true );
1793 if ( disable ) 1792 if ( disable )
1794 selectFilterMenu->setItemEnabled( iii, false ); 1793 selectFilterMenu->setItemEnabled( iii, false );
1795 filter = fili.next(); 1794 filter = fili.next();
1796 ++iii; 1795 ++iii;
1797 } 1796 }
1798} 1797}
1799void MainWindow::selectFilter( int fil ) 1798void MainWindow::selectFilter( int fil )
1800{ 1799{
1801 if ( fil == 0 ) { 1800 if ( fil == 0 ) {
1802 mView->editFilters( ); 1801 mView->editFilters( );
1803 } else if ( fil == 1 ){ 1802 } else if ( fil == 1 ){
1804 mView->toggleFilerEnabled( ); 1803 mView->toggleFilerEnabled( );
1805 } else { 1804 } else {
1806 mView->selectFilter( fil-2 ); 1805 mView->selectFilter( fil-2 );
1807 } 1806 }
1808} 1807}
1809void MainWindow::configureToolBar( int item ) 1808void MainWindow::configureToolBar( int item )
1810{ 1809{
1811 1810
1812 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); 1811 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) );
1813 KOPrefs *p = KOPrefs::instance(); 1812 KOPrefs *p = KOPrefs::instance();
1814 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); 1813 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 );
1815 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); 1814 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 );
1816 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); 1815 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 );
1817 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); 1816 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 );
1818 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); 1817 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 );
1819 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); 1818 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 );
1820 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); 1819 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 );
1821 p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 ); 1820 p-> mShowIconDay6= configureToolBarMenu->isItemChecked( 75 );
1822 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); 1821 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 );
1823 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); 1822 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 );
1824 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); 1823 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 );
1825 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); 1824 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 );
1826 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); 1825 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 );
1827 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); 1826 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 );
1828 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); 1827 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 );
1829 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); 1828 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 );
1830 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); 1829 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 );
1831 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); 1830 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 );
1832 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); 1831 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 );
1833 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); 1832 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 );
1834 p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 ); 1833 p-> mShowIconWeekNum= configureToolBarMenu->isItemChecked( 400 );
1835 // initActions(); 1834 // initActions();
1836} 1835}
1837 1836
1838void MainWindow::setCaptionToDates() 1837void MainWindow::setCaptionToDates()
1839{ 1838{
1840 QString selDates; 1839 QString selDates;
1841 selDates = KGlobal::locale()->formatDate(mView->startDate(), true); 1840 selDates = KGlobal::locale()->formatDate(mView->startDate(), true);
1842 if (mView->startDate() < mView->endDate() ) 1841 if (mView->startDate() < mView->endDate() )
1843 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); 1842 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true);
1844 else { 1843 else {
1845 QString addString; 1844 QString addString;
1846 if ( mView->startDate() == QDateTime::currentDateTime().date() ) 1845 if ( mView->startDate() == QDateTime::currentDateTime().date() )
1847 addString = i18n("Today"); 1846 addString = i18n("Today");
1848 else if ( mView->startDate() == QDateTime::currentDateTime().date().addDays(1) ) 1847 else if ( mView->startDate() == QDateTime::currentDateTime().date().addDays(1) )
1849 addString = i18n("Tomorrow"); 1848 addString = i18n("Tomorrow");
1850 if ( !addString.isEmpty() ) 1849 if ( !addString.isEmpty() )
1851 selDates = addString+", "+selDates ; 1850 selDates = addString+", "+selDates ;
1852 } 1851 }
1853 setCaption( i18n("Dates: ") + selDates ); 1852 setCaption( i18n("Dates: ") + selDates );
1854 1853
1855} 1854}
1856void MainWindow::showConfigureAgenda( ) 1855void MainWindow::showConfigureAgenda( )
1857{ 1856{
1858 int iii; 1857 int iii;
1859 for ( iii = 1;iii<= 10 ;++iii ){ 1858 for ( iii = 1;iii<= 10 ;++iii ){
1860 configureAgendaMenu->setItemChecked( (iii+1)*2, false ); 1859 configureAgendaMenu->setItemChecked( (iii+1)*2, false );
1861 } 1860 }
1862 configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true ); 1861 configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true );
1863} 1862}
1864void MainWindow::configureAgenda( int item ) 1863void MainWindow::configureAgenda( int item )
1865{ 1864{
1866 if ( KOPrefs::instance()->mHourSize == item ) 1865 if ( KOPrefs::instance()->mHourSize == item )
1867 return; 1866 return;
1868 KOPrefs::instance()->mHourSize=item; 1867 KOPrefs::instance()->mHourSize=item;
1869 mView->viewManager()->agendaView()->updateConfig(); 1868 mView->viewManager()->agendaView()->updateConfig();
1870} 1869}
1871 1870
1872void MainWindow::saveCalendar() 1871void MainWindow::saveCalendar()
1873{ 1872{
1874 QString fn = KOPrefs::instance()->mLastSaveFile; 1873 QString fn = KOPrefs::instance()->mLastSaveFile;
1875 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); 1874 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this );
1876 1875
1877 if ( fn == "" ) 1876 if ( fn == "" )
1878 return; 1877 return;
1879 QFileInfo info; 1878 QFileInfo info;
1880 info.setFile( fn ); 1879 info.setFile( fn );
1881 QString mes; 1880 QString mes;
1882 bool createbup = true; 1881 bool createbup = true;
1883 if ( info. exists() ) { 1882 if ( info. exists() ) {
1884 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; 1883 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ;
1885 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1884 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1886 i18n("Overwrite!"), i18n("Cancel"), 0, 1885 i18n("Overwrite!"), i18n("Cancel"), 0,
1887 0, 1 ); 1886 0, 1 );
1888 if ( result != 0 ) { 1887 if ( result != 0 ) {
1889 createbup = false; 1888 createbup = false;
1890 } 1889 }
1891 } 1890 }
1892 if ( createbup ) { 1891 if ( createbup ) {
1893 mView->saveCalendar( fn ); 1892 mView->saveCalendar( fn );
1894 mes = i18n("KO/Pi:Saved %1").arg(fn); 1893 mes = i18n("KO/Pi:Saved %1").arg(fn);
1895 KOPrefs::instance()->mLastSaveFile = fn; 1894 KOPrefs::instance()->mLastSaveFile = fn;
1896 setCaption(mes); 1895 setCaption(mes);
1897 } 1896 }
1898} 1897}
1899void MainWindow::loadCalendar() 1898void MainWindow::loadCalendar()
1900{ 1899{
1901 1900
1902 QString fn = KOPrefs::instance()->mLastLoadFile; 1901 QString fn = KOPrefs::instance()->mLastLoadFile;
1903 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); 1902 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this );
1904 1903
1905 if ( fn == "" ) 1904 if ( fn == "" )
1906 return; 1905 return;
1907 QFileInfo info; 1906 QFileInfo info;
1908 info.setFile( fn ); 1907 info.setFile( fn );
1909 QString mess; 1908 QString mess;
1910 bool loadbup = true; 1909 bool loadbup = true;
1911 if ( info. exists() ) { 1910 if ( info. exists() ) {
1912 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1911 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1913 int result = QMessageBox::warning( this, "KO/Pi: Warning!", 1912 int result = QMessageBox::warning( this, "KO/Pi: Warning!",
1914 mess, 1913 mess,
1915 i18n("Load!"), i18n("Cancel"), 0, 1914 i18n("Load!"), i18n("Cancel"), 0,
1916 0, 1 ); 1915 0, 1 );
1917 if ( result != 0 ) { 1916 if ( result != 0 ) {
1918 loadbup = false; 1917 loadbup = false;
1919 } 1918 }
1920 } else { 1919 } else {
1921 QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1920 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1922 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, 1921 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0,
1923 0, 1 ); 1922 0, 1 );
1924 1923
1925 return; 1924 return;
1926 } 1925 }
1927 if ( loadbup ) { 1926 if ( loadbup ) {
1928 mView->openCalendar( fn ); 1927 mView->openCalendar( fn );
1929 KOPrefs::instance()->mLastLoadFile = fn; 1928 KOPrefs::instance()->mLastLoadFile = fn;
1930 mess = i18n("KO/Pi:Loaded %1").arg(fn) ; 1929 mess = i18n("KO/Pi:Loaded %1").arg(fn) ;
1931 setCaption(mess); 1930 setCaption(mess);
1932 } 1931 }
1933 1932
1934} 1933}
1935void MainWindow::quickImportIcal() 1934void MainWindow::quickImportIcal()
1936{ 1935{
1937 importFile( KOPrefs::instance()->mLastImportFile, false ); 1936 importFile( KOPrefs::instance()->mLastImportFile, false );
1938} 1937}
1939void MainWindow::importFile( QString fn, bool quick ) 1938void MainWindow::importFile( QString fn, bool quick )
1940{ 1939{
1941 QFileInfo info; 1940 QFileInfo info;
1942 info.setFile( fn ); 1941 info.setFile( fn );
1943 QString mess; 1942 QString mess;
1944 bool loadbup = true; 1943 bool loadbup = true;
1945 if ( !info. exists() ) { 1944 if ( !info. exists() ) {
1946 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); 1945 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30));
1947 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1946 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1948 mess ); 1947 mess );
1949 return; 1948 return;
1950 } 1949 }
1951 int result = 0; 1950 int result = 0;
1952 if ( !quick ) { 1951 if ( !quick ) {
1953 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 )); 1952 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 ));
1954 result = QMessageBox::warning( this, "KO/Pi: Warning!", 1953 result = QMessageBox::warning( this, "KO/Pi: Warning!",
1955 mess, 1954 mess,
1956 "Import", "Cancel", 0, 1955 "Import", "Cancel", 0,
1957 0, 1 ); 1956 0, 1 );
1958 } 1957 }
1959 if ( result == 0 ) { 1958 if ( result == 0 ) {
1960 if ( mView->openCalendar( fn, true )) { 1959 if ( mView->openCalendar( fn, true )) {
1961 KOPrefs::instance()->mLastImportFile = fn; 1960 KOPrefs::instance()->mLastImportFile = fn;
1962 setCaption(i18n("Imported file successfully")); 1961 setCaption(i18n("Imported file successfully"));
1963 } else { 1962 } else {
1964 setCaption(i18n("Error importing file")); 1963 setCaption(i18n("Error importing file"));
1965 } 1964 }
1966 } 1965 }
1967} 1966}
1968 1967
1969void MainWindow::importIcal() 1968void MainWindow::importIcal()
1970{ 1969{
1971 1970
1972 QString fn =KOPrefs::instance()->mLastImportFile; 1971 QString fn =KOPrefs::instance()->mLastImportFile;
1973 1972
1974 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); 1973 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this );
1975 if ( fn == "" ) 1974 if ( fn == "" )
1976 return; 1975 return;
1977 importFile( fn, true ); 1976 importFile( fn, true );
1978 1977
1979} 1978}
1980 1979
1981void MainWindow::exportVCalendar() 1980void MainWindow::exportVCalendar()
1982{ 1981{
1983 QString fn = KOPrefs::instance()->mLastVcalFile; 1982 QString fn = KOPrefs::instance()->mLastVcalFile;
1984 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); 1983 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this );
1985 if ( fn == "" ) 1984 if ( fn == "" )
1986 return; 1985 return;
1987 QFileInfo info; 1986 QFileInfo info;
1988 info.setFile( fn ); 1987 info.setFile( fn );
1989 QString mes; 1988 QString mes;
1990 bool createbup = true; 1989 bool createbup = true;
1991 if ( info. exists() ) { 1990 if ( info. exists() ) {
1992 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 1991 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
1993 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1992 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1994 i18n("Overwrite!"), i18n("Cancel"), 0, 1993 i18n("Overwrite!"), i18n("Cancel"), 0,
1995 0, 1 ); 1994 0, 1 );
1996 if ( result != 0 ) { 1995 if ( result != 0 ) {
1997 createbup = false; 1996 createbup = false;
1998 } 1997 }
1999 } 1998 }
2000 if ( createbup ) { 1999 if ( createbup ) {
2001 if ( mView->exportVCalendar( fn ) ) { 2000 if ( mView->exportVCalendar( fn ) ) {
2002 KOPrefs::instance()->mLastVcalFile = fn; 2001 KOPrefs::instance()->mLastVcalFile = fn;
2003 if ( fn.length() > 20 ) 2002 if ( fn.length() > 20 )
2004 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; 2003 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ;
2005 else 2004 else
2006 mes = i18n("KO/Pi:Exported to %1").arg(fn ); 2005 mes = i18n("KO/Pi:Exported to %1").arg(fn );
2007 setCaption(mes); 2006 setCaption(mes);
2008 } 2007 }
2009 } 2008 }
2010 2009
2011} 2010}
2012QString MainWindow::sentSyncFile() 2011QString MainWindow::sentSyncFile()
2013{ 2012{
2014#ifdef DESKTOP_VERSION 2013#ifdef DESKTOP_VERSION
2015 return locateLocal( "tmp", "copysynccal.ics" ); 2014 return locateLocal( "tmp", "copysynccal.ics" );
2016#else 2015#else
2017 return QString( "/tmp/copysynccal.ics" ); 2016 return QString( "/tmp/copysynccal.ics" );
2018#endif 2017#endif
2019} 2018}
2020 2019
2021void MainWindow::syncFileRequest() 2020void MainWindow::syncFileRequest()
2022{ 2021{
2023 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { 2022 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) {
2024 mSyncManager->slotSyncMenu( 999 ); 2023 mSyncManager->slotSyncMenu( 999 );
2025 } 2024 }
2026 2025
2027 setCaption(i18n("Saving Data to temp file ..." )); 2026 setCaption(i18n("Saving Data to temp file ..." ));
2028 mView->saveCalendar( sentSyncFile() ); 2027 mView->saveCalendar( sentSyncFile() );
2029 setCaption(i18n("Data saved to temp file!" )); 2028 setCaption(i18n("Data saved to temp file!" ));
2030 2029
2031} 2030}
2032void MainWindow::getFile( bool success ) 2031void MainWindow::getFile( bool success )
2033{ 2032{
2034 if ( ! success ) { 2033 if ( ! success ) {
2035 setCaption( i18n("Error receiving file. Nothing changed!") ); 2034 setCaption( i18n("Error receiving file. Nothing changed!") );
2036 return; 2035 return;
2037 } 2036 }
2038 mView->openCalendar( sentSyncFile() ); 2037 mView->openCalendar( sentSyncFile() );
2039 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { 2038 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) {
2040 mSyncManager->slotSyncMenu( 999 ); 2039 mSyncManager->slotSyncMenu( 999 );
2041 } 2040 }
2042 setCaption( i18n("Pi-Sync successful!") ); 2041 setCaption( i18n("Pi-Sync successful!") );
2043} 2042}
2044 2043
2045void MainWindow::printSel( ) 2044void MainWindow::printSel( )
2046{ 2045{
2047 mView->viewManager()->agendaView()->agenda()->printSelection(); 2046 mView->viewManager()->agendaView()->agenda()->printSelection();
2048} 2047}
2049 2048
2050void MainWindow::printCal() 2049void MainWindow::printCal()
2051{ 2050{
2052 mView->print();//mCp->showDialog(); 2051 mView->print();//mCp->showDialog();
2053} 2052}
2054 2053
2055 2054
2056#include "libkdepim/kdatepicker.h" 2055#include "libkdepim/kdatepicker.h"
2057#include <kdatetbl.h> 2056#include <kdatetbl.h>
2058void MainWindow::weekAction() 2057void MainWindow::weekAction()
2059{ 2058{
2060 int month; 2059 int month;
2061 KPopupFrame* popup = new KPopupFrame(this); 2060 KPopupFrame* popup = new KPopupFrame(this);
2062 KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup); 2061 KDateInternalWeekPicker* picker = new KDateInternalWeekPicker(popup);
2063 // ----- 2062 // -----
2064 picker->resize(picker->sizeHint()); 2063 picker->resize(picker->sizeHint());
2065 popup->setMainWidget(picker); 2064 popup->setMainWidget(picker);
2066 picker->setFocus(); 2065 picker->setFocus();
2067 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); 2066 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int)));
2068 int x = 0; 2067 int x = 0;
2069 int y = iconToolBar->height(); 2068 int y = iconToolBar->height();
2070 int dX = 0; 2069 int dX = 0;
2071 int dY = 0; 2070 int dY = 0;
2072 if ( iconToolBar->orientation () == Qt:: Horizontal ) { 2071 if ( iconToolBar->orientation () == Qt:: Horizontal ) {
2073 if ( iconToolBar->y() > height()/2 ) { 2072 if ( iconToolBar->y() > height()/2 ) {
2074 dY = picker->sizeHint().height()+8; 2073 dY = picker->sizeHint().height()+8;
2075 y = 0; 2074 y = 0;
2076 } 2075 }
2077 } else { 2076 } else {
2078 if ( iconToolBar->x() > width()/2 ) { // right side 2077 if ( iconToolBar->x() > width()/2 ) { // right side
2079 x=0; 2078 x=0;
2080 dX= picker->sizeHint().width()+8; 2079 dX= picker->sizeHint().width()+8;
2081 y = 0; 2080 y = 0;
2082 } else { 2081 } else {
2083 x= iconToolBar->width(); 2082 x= iconToolBar->width();
2084 y = 0; 2083 y = 0;
2085 } 2084 }
2086 } 2085 }
2087 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() ); 2086 //qDebug("dax %d dy %d %d %d ", dX, dY, iconToolBar->x(), iconToolBar->y() );
2088 if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY)))) 2087 if(popup->exec(iconToolBar->mapToGlobal(QPoint(x,y)-QPoint( dX,dY))))
2089 { 2088 {
2090 month = picker->getResult(); 2089 month = picker->getResult();
2091 emit selectWeek ( month ); 2090 emit selectWeek ( month );
2092 //qDebug("weekSelected %d ", month); 2091 //qDebug("weekSelected %d ", month);
2093 } 2092 }
2094 delete popup; 2093 delete popup;
2095} 2094}