summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-01-22 10:18:16 (UTC)
committer zautrix <zautrix>2005-01-22 10:18:16 (UTC)
commit6946f6ab0ee6eeafee0c8ff5d33fffc0826c7452 (patch) (unidiff)
tree006248579ca44ad2e0c1a67db55b1a8013180ed7 /korganizer
parentb715b109b70b8cd24a2d9da1d4863c44d79fb2a4 (diff)
downloadkdepimpi-6946f6ab0ee6eeafee0c8ff5d33fffc0826c7452.zip
kdepimpi-6946f6ab0ee6eeafee0c8ff5d33fffc0826c7452.tar.gz
kdepimpi-6946f6ab0ee6eeafee0c8ff5d33fffc0826c7452.tar.bz2
some small fixes
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp52
-rw-r--r--korganizer/calendarview.h2
-rw-r--r--korganizer/koeditorgeneral.cpp20
-rw-r--r--korganizer/koeditorgeneral.h1
-rw-r--r--korganizer/kotodoview.cpp5
-rw-r--r--korganizer/mainwindow.cpp11
6 files changed, 65 insertions, 26 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 8f05276..038da54 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,3885 +1,3905 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 3
4 Requires the Qt and KDE widget libraries, available at no cost at 4 Requires the Qt and KDE widget libraries, available at no cost at
5 http://www.troll.no and http://www.kde.org respectively 5 http://www.troll.no and http://www.kde.org respectively
6 6
7 Copyright (c) 1997, 1998, 1999 7 Copyright (c) 1997, 1998, 1999
8 Preston Brown (preston.brown@yale.edu) 8 Preston Brown (preston.brown@yale.edu)
9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) 9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl)
10 Ian Dawes (iadawes@globalserve.net) 10 Ian Dawes (iadawes@globalserve.net)
11 Laszlo Boloni (boloni@cs.purdue.edu) 11 Laszlo Boloni (boloni@cs.purdue.edu)
12 12
13 Copyright (c) 2000, 2001, 2002 13 Copyright (c) 2000, 2001, 2002
14 Cornelius Schumacher <schumacher@kde.org> 14 Cornelius Schumacher <schumacher@kde.org>
15 15
16 This program is free software; you can redistribute it and/or modify 16 This program is free software; you can redistribute it and/or modify
17 it under the terms of the GNU General Public License as published by 17 it under the terms of the GNU General Public License as published by
18 the Free Software Foundation; either version 2 of the License, or 18 the Free Software Foundation; either version 2 of the License, or
19 (at your option) any later version. 19 (at your option) any later version.
20 20
21 This program is distributed in the hope that it will be useful, 21 This program is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of 22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
24 GNU General Public License for more details. 24 GNU General Public License for more details.
25 25
26 You should have received a copy of the GNU General Public License 26 You should have received a copy of the GNU General Public License
27 along with this program; if not, write to the Free Software 27 along with this program; if not, write to the Free Software
28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29*/ 29*/
30 30
31#include <stdlib.h> 31#include <stdlib.h>
32 32
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qradiobutton.h> 34#include <qradiobutton.h>
35#include <qbuttongroup.h> 35#include <qbuttongroup.h>
36#include <qlayout.h> 36#include <qlayout.h>
37#include <qclipboard.h> 37#include <qclipboard.h>
38#include <qcursor.h> 38#include <qcursor.h>
39#include <qmessagebox.h> 39#include <qmessagebox.h>
40#include <qprogressbar.h> 40#include <qprogressbar.h>
41#include <qmultilineedit.h> 41#include <qmultilineedit.h>
42#include <qtimer.h> 42#include <qtimer.h>
43#include <qwidgetstack.h> 43#include <qwidgetstack.h>
44#include <qptrlist.h> 44#include <qptrlist.h>
45#include <qregexp.h> 45#include <qregexp.h>
46#include <qgroupbox.h> 46#include <qgroupbox.h>
47#include <qfile.h> 47#include <qfile.h>
48#include <qdir.h> 48#include <qdir.h>
49#ifndef KORG_NOSPLITTER 49#ifndef KORG_NOSPLITTER
50#include <qsplitter.h> 50#include <qsplitter.h>
51#endif 51#endif
52 52
53#include <kglobal.h> 53#include <kglobal.h>
54#include <kdebug.h> 54#include <kdebug.h>
55#include <kstandarddirs.h> 55#include <kstandarddirs.h>
56#include <kfiledialog.h> 56#include <kfiledialog.h>
57#include <kmessagebox.h> 57#include <kmessagebox.h>
58#include <knotifyclient.h> 58#include <knotifyclient.h>
59#include <kconfig.h> 59#include <kconfig.h>
60 60
61#include <libkdepim/ksyncprefsdialog.h> 61#include <libkdepim/ksyncprefsdialog.h>
62#include <krun.h> 62#include <krun.h>
63#include <kdirwatch.h> 63#include <kdirwatch.h>
64#include <libkdepim/kdatepicker.h> 64#include <libkdepim/kdatepicker.h>
65#include <libkdepim/ksyncprofile.h> 65#include <libkdepim/ksyncprofile.h>
66#include <libkdepim/kpimglobalprefs.h> 66#include <libkdepim/kpimglobalprefs.h>
67 67
68#include <libkcal/vcaldrag.h> 68#include <libkcal/vcaldrag.h>
69#include <libkcal/icaldrag.h> 69#include <libkcal/icaldrag.h>
70#include <libkcal/icalformat.h> 70#include <libkcal/icalformat.h>
71#include <libkcal/vcalformat.h> 71#include <libkcal/vcalformat.h>
72#include <libkcal/scheduler.h> 72#include <libkcal/scheduler.h>
73#include <libkcal/calendarlocal.h> 73#include <libkcal/calendarlocal.h>
74#include <libkcal/journal.h> 74#include <libkcal/journal.h>
75#include <libkcal/calfilter.h> 75#include <libkcal/calfilter.h>
76#include <libkcal/attendee.h> 76#include <libkcal/attendee.h>
77#include <libkcal/dndfactory.h> 77#include <libkcal/dndfactory.h>
78#include <libkcal/freebusy.h> 78#include <libkcal/freebusy.h>
79#include <libkcal/filestorage.h> 79#include <libkcal/filestorage.h>
80#include <libkcal/calendarresources.h> 80#include <libkcal/calendarresources.h>
81#include <libkcal/qtopiaformat.h> 81#include <libkcal/qtopiaformat.h>
82#include "../kalarmd/alarmdialog.h" 82#include "../kalarmd/alarmdialog.h"
83 83
84#ifndef DESKTOP_VERSION 84#ifndef DESKTOP_VERSION
85#include <libkcal/sharpformat.h> 85#include <libkcal/sharpformat.h>
86#include <externalapphandler.h> 86#include <externalapphandler.h>
87#endif 87#endif
88#include <libkcal/phoneformat.h> 88#include <libkcal/phoneformat.h>
89#ifndef KORG_NOMAIL 89#ifndef KORG_NOMAIL
90#include "komailclient.h" 90#include "komailclient.h"
91#endif 91#endif
92#ifndef KORG_NOPRINTER 92#ifndef KORG_NOPRINTER
93#include "calprinter.h" 93#include "calprinter.h"
94#endif 94#endif
95#ifndef KORG_NOPLUGINS 95#ifndef KORG_NOPLUGINS
96#include "kocore.h" 96#include "kocore.h"
97#endif 97#endif
98#include "koeventeditor.h" 98#include "koeventeditor.h"
99#include "kotodoeditor.h" 99#include "kotodoeditor.h"
100#include "koprefs.h" 100#include "koprefs.h"
101#include "koeventviewerdialog.h" 101#include "koeventviewerdialog.h"
102#include "publishdialog.h" 102#include "publishdialog.h"
103#include "kofilterview.h" 103#include "kofilterview.h"
104#include "koglobals.h" 104#include "koglobals.h"
105#include "koviewmanager.h" 105#include "koviewmanager.h"
106#include "koagendaview.h" 106#include "koagendaview.h"
107#include "kodialogmanager.h" 107#include "kodialogmanager.h"
108#include "outgoingdialog.h" 108#include "outgoingdialog.h"
109#include "incomingdialog.h" 109#include "incomingdialog.h"
110#include "statusdialog.h" 110#include "statusdialog.h"
111#include "kdatenavigator.h" 111#include "kdatenavigator.h"
112#include "kotodoview.h" 112#include "kotodoview.h"
113#include "datenavigator.h" 113#include "datenavigator.h"
114#include "resourceview.h" 114#include "resourceview.h"
115#include "navigatorbar.h" 115#include "navigatorbar.h"
116#include "searchdialog.h" 116#include "searchdialog.h"
117#include "mainwindow.h" 117#include "mainwindow.h"
118 118
119#include "calendarview.h" 119#include "calendarview.h"
120#ifndef DESKTOP_VERSION 120#ifndef DESKTOP_VERSION
121#include <qtopia/alarmserver.h> 121#include <qtopia/alarmserver.h>
122#endif 122#endif
123#ifndef _WIN32_ 123#ifndef _WIN32_
124#include <stdlib.h> 124#include <stdlib.h>
125#include <stdio.h> 125#include <stdio.h>
126#include <unistd.h> 126#include <unistd.h>
127#else 127#else
128#include <qprocess.h> 128#include <qprocess.h>
129#endif 129#endif
130 130
131#ifdef DESKTOP_VERSION 131#ifdef DESKTOP_VERSION
132#include <kabc/stdaddressbook.h> 132#include <kabc/stdaddressbook.h>
133#endif 133#endif
134using namespace KOrg; 134using namespace KOrg;
135using namespace KCal; 135using namespace KCal;
136extern int globalFlagBlockAgenda; 136extern int globalFlagBlockAgenda;
137extern int globalFlagBlockStartup; 137extern int globalFlagBlockStartup;
138 138
139 139
140 140
141class KOBeamPrefs : public QDialog 141class KOBeamPrefs : public QDialog
142{ 142{
143 public: 143 public:
144 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : 144 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) :
145 QDialog( parent, name, true ) 145 QDialog( parent, name, true )
146 { 146 {
147 setCaption( i18n("Beam Options") ); 147 setCaption( i18n("Beam Options") );
148 QVBoxLayout* lay = new QVBoxLayout( this ); 148 QVBoxLayout* lay = new QVBoxLayout( this );
149 lay->setSpacing( 3 ); 149 lay->setSpacing( 3 );
150 lay->setMargin( 3 ); 150 lay->setMargin( 3 );
151 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); 151 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this );
152 lay->addWidget( format ); 152 lay->addWidget( format );
153 format->setExclusive ( true ) ; 153 format->setExclusive ( true ) ;
154 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); 154 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this );
155 lay->addWidget( time ); time->setExclusive ( true ) ; 155 lay->addWidget( time ); time->setExclusive ( true ) ;
156 vcal = new QRadioButton(" vCalendar ", format ); 156 vcal = new QRadioButton(" vCalendar ", format );
157 ical = new QRadioButton(" iCalendar ", format ); 157 ical = new QRadioButton(" iCalendar ", format );
158 vcal->setChecked( true ); 158 vcal->setChecked( true );
159 tz = new QRadioButton(i18n(" With timezone "), time ); 159 tz = new QRadioButton(i18n(" With timezone "), time );
160 local = new QRadioButton(i18n(" Local time "), time ); 160 local = new QRadioButton(i18n(" Local time "), time );
161 tz->setChecked( true ); 161 tz->setChecked( true );
162 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); 162 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this );
163 lay->addWidget( ok ); 163 lay->addWidget( ok );
164 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 164 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
165 lay->addWidget( cancel ); 165 lay->addWidget( cancel );
166 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 166 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
167 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 167 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
168 resize( 200, 200 ); 168 resize( 200, 200 );
169 } 169 }
170 170
171 bool beamVcal() { return vcal->isChecked(); } 171 bool beamVcal() { return vcal->isChecked(); }
172 bool beamLocal() { return local->isChecked(); } 172 bool beamLocal() { return local->isChecked(); }
173private: 173private:
174 QRadioButton* vcal, *ical, *local, *tz; 174 QRadioButton* vcal, *ical, *local, *tz;
175}; 175};
176class KOCatPrefs : public QDialog 176class KOCatPrefs : public QDialog
177{ 177{
178 public: 178 public:
179 KOCatPrefs( QWidget *parent=0, const char *name=0 ) : 179 KOCatPrefs( QWidget *parent=0, const char *name=0 ) :
180 QDialog( parent, name, true ) 180 QDialog( parent, name, true )
181 { 181 {
182 setCaption( i18n("Manage new Categories") ); 182 setCaption( i18n("Manage new Categories") );
183 QVBoxLayout* lay = new QVBoxLayout( this ); 183 QVBoxLayout* lay = new QVBoxLayout( this );
184 lay->setSpacing( 3 ); 184 lay->setSpacing( 3 );
185 lay->setMargin( 3 ); 185 lay->setMargin( 3 );
186 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this ); 186 QLabel * lab = new QLabel( i18n("After importing/loading/syncing\nthere may be new categories in\nevents or todos\nwhich are not in the category list.\nPlease choose what to do:\n "), this );
187 lay->addWidget( lab ); 187 lay->addWidget( lab );
188 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 188 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
189 lay->addWidget( format ); 189 lay->addWidget( format );
190 format->setExclusive ( true ) ; 190 format->setExclusive ( true ) ;
191 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 191 addCatBut = new QRadioButton(i18n("Add to category list"), format );
192 new QRadioButton(i18n("Remove from Events/Todos"), format ); 192 new QRadioButton(i18n("Remove from Events/Todos"), format );
193 addCatBut->setChecked( true ); 193 addCatBut->setChecked( true );
194 QPushButton * ok = new QPushButton( i18n("OK"), this ); 194 QPushButton * ok = new QPushButton( i18n("OK"), this );
195 lay->addWidget( ok ); 195 lay->addWidget( ok );
196 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 196 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
197 lay->addWidget( cancel ); 197 lay->addWidget( cancel );
198 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 198 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
199 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 199 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
200 resize( 200, 200 ); 200 resize( 200, 200 );
201 } 201 }
202 202
203 bool addCat() { return addCatBut->isChecked(); } 203 bool addCat() { return addCatBut->isChecked(); }
204private: 204private:
205 QRadioButton* addCatBut; 205 QRadioButton* addCatBut;
206}; 206};
207 207
208 208
209 209
210CalendarView::CalendarView( CalendarResources *calendar, 210CalendarView::CalendarView( CalendarResources *calendar,
211 QWidget *parent, const char *name ) 211 QWidget *parent, const char *name )
212 : CalendarViewBase( parent, name ), 212 : CalendarViewBase( parent, name ),
213 mCalendar( calendar ), 213 mCalendar( calendar ),
214 mResourceManager( calendar->resourceManager() ) 214 mResourceManager( calendar->resourceManager() )
215{ 215{
216 216
217 mEventEditor = 0; 217 mEventEditor = 0;
218 mTodoEditor = 0; 218 mTodoEditor = 0;
219 219
220 init(); 220 init();
221} 221}
222 222
223CalendarView::CalendarView( Calendar *calendar, 223CalendarView::CalendarView( Calendar *calendar,
224 QWidget *parent, const char *name ) 224 QWidget *parent, const char *name )
225 : CalendarViewBase( parent, name ), 225 : CalendarViewBase( parent, name ),
226 mCalendar( calendar ), 226 mCalendar( calendar ),
227 mResourceManager( 0 ) 227 mResourceManager( 0 )
228{ 228{
229 229
230 mEventEditor = 0; 230 mEventEditor = 0;
231 mTodoEditor = 0; 231 mTodoEditor = 0;
232 init();} 232 init();}
233 233
234void CalendarView::init() 234void CalendarView::init()
235{ 235{
236 mBlockShowDates = false; 236 mBlockShowDates = false;
237 beamDialog = new KOBeamPrefs(); 237 beamDialog = new KOBeamPrefs();
238 mDatePickerMode = 0; 238 mDatePickerMode = 0;
239 mCurrentSyncDevice = ""; 239 mCurrentSyncDevice = "";
240 writeLocale(); 240 writeLocale();
241 mViewManager = new KOViewManager( this ); 241 mViewManager = new KOViewManager( this );
242 mDialogManager = new KODialogManager( this ); 242 mDialogManager = new KODialogManager( this );
243 mEventViewerDialog = 0; 243 mEventViewerDialog = 0;
244 mModified = false; 244 mModified = false;
245 mReadOnly = false; 245 mReadOnly = false;
246 mSelectedIncidence = 0; 246 mSelectedIncidence = 0;
247 mCalPrinter = 0; 247 mCalPrinter = 0;
248 mFilters.setAutoDelete(true); 248 mFilters.setAutoDelete(true);
249 249
250 mCalendar->registerObserver( this ); 250 mCalendar->registerObserver( this );
251 // TODO: Make sure that view is updated, when calendar is changed. 251 // TODO: Make sure that view is updated, when calendar is changed.
252 252
253 mStorage = new FileStorage( mCalendar ); 253 mStorage = new FileStorage( mCalendar );
254 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 254 mNavigator = new DateNavigator( this, "datevav", mViewManager );
255 255
256 QBoxLayout *topLayout = (QBoxLayout*)layout(); 256 QBoxLayout *topLayout = (QBoxLayout*)layout();
257#ifndef KORG_NOSPLITTER 257#ifndef KORG_NOSPLITTER
258 // create the main layout frames. 258 // create the main layout frames.
259 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 259 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
260 topLayout->addWidget(mPanner); 260 topLayout->addWidget(mPanner);
261 261
262 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 262 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
263 "CalendarView::LeftFrame"); 263 "CalendarView::LeftFrame");
264 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 264 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
265 265
266 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, 266 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE,
267 "CalendarView::DateNavigator", QDate::currentDate() ); 267 "CalendarView::DateNavigator", QDate::currentDate() );
268 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 268 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
269 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 269 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
270 mTodoList->setNavigator( mNavigator ); 270 mTodoList->setNavigator( mNavigator );
271 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 271 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
272 272
273#ifdef KORG_NORESOURCEVIEW 273#ifdef KORG_NORESOURCEVIEW
274 mResourceView = 0; 274 mResourceView = 0;
275#else 275#else
276 if ( mResourceManager ) { 276 if ( mResourceManager ) {
277 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 277 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
278 mResourceView->updateView(); 278 mResourceView->updateView();
279 connect( mResourceView, SIGNAL( resourcesChanged() ), 279 connect( mResourceView, SIGNAL( resourcesChanged() ),
280 SLOT( updateView() ) ); 280 SLOT( updateView() ) );
281 } else { 281 } else {
282 mResourceView = 0; 282 mResourceView = 0;
283 } 283 }
284#endif 284#endif
285 QWidget *rightBox = new QWidget( mPanner ); 285 QWidget *rightBox = new QWidget( mPanner );
286 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 286 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
287 287
288 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 288 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
289 rightLayout->addWidget( mNavigatorBar ); 289 rightLayout->addWidget( mNavigatorBar );
290 290
291 mRightFrame = new QWidgetStack( rightBox ); 291 mRightFrame = new QWidgetStack( rightBox );
292 rightLayout->addWidget( mRightFrame, 1 ); 292 rightLayout->addWidget( mRightFrame, 1 );
293 293
294 mLeftFrame = mLeftSplitter; 294 mLeftFrame = mLeftSplitter;
295#else 295#else
296 QWidget *mainBox = new QWidget( this ); 296 QWidget *mainBox = new QWidget( this );
297 QWidget *leftFrame = new QWidget( mainBox ); 297 QWidget *leftFrame = new QWidget( mainBox );
298 298
299 QBoxLayout * mainBoxLayout; 299 QBoxLayout * mainBoxLayout;
300 QBoxLayout * leftFrameLayout; 300 QBoxLayout * leftFrameLayout;
301 if ( KOPrefs::instance()->mVerticalScreen ) { 301 if ( KOPrefs::instance()->mVerticalScreen ) {
302 mainBoxLayout = new QVBoxLayout(mainBox); 302 mainBoxLayout = new QVBoxLayout(mainBox);
303 leftFrameLayout = new QHBoxLayout(leftFrame ); 303 leftFrameLayout = new QHBoxLayout(leftFrame );
304 } else { 304 } else {
305 mainBoxLayout = new QHBoxLayout(mainBox); 305 mainBoxLayout = new QHBoxLayout(mainBox);
306 leftFrameLayout = new QVBoxLayout(leftFrame ); 306 leftFrameLayout = new QVBoxLayout(leftFrame );
307 } 307 }
308 topLayout->addWidget( mainBox ); 308 topLayout->addWidget( mainBox );
309 mainBoxLayout->addWidget (leftFrame); 309 mainBoxLayout->addWidget (leftFrame);
310 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, 310 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE,
311 "CalendarView::DateNavigator", QDate::currentDate()); 311 "CalendarView::DateNavigator", QDate::currentDate());
312 // mDateNavigator->blockSignals( true ); 312 // mDateNavigator->blockSignals( true );
313 leftFrameLayout->addWidget( mDateNavigator ); 313 leftFrameLayout->addWidget( mDateNavigator );
314 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); 314 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView");
315 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall"); 315 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolistsmall");
316 mTodoList->setNavigator( mNavigator ); 316 mTodoList->setNavigator( mNavigator );
317 317
318 if ( QApplication::desktop()->width() < 480 ) { 318 if ( QApplication::desktop()->width() < 480 ) {
319 leftFrameLayout->addWidget(mFilterView); 319 leftFrameLayout->addWidget(mFilterView);
320 leftFrameLayout->addWidget(mTodoList, 2 ); 320 leftFrameLayout->addWidget(mTodoList, 2 );
321 321
322 } else { 322 } else {
323 leftFrameLayout->addWidget(mTodoList,2 ); 323 leftFrameLayout->addWidget(mTodoList,2 );
324 leftFrameLayout->addWidget(mFilterView ); 324 leftFrameLayout->addWidget(mFilterView );
325 } 325 }
326 mFilterView->hide(); 326 mFilterView->hide();
327 QWidget *rightBox = new QWidget( mainBox ); 327 QWidget *rightBox = new QWidget( mainBox );
328 mainBoxLayout->addWidget ( rightBox, 10 ); 328 mainBoxLayout->addWidget ( rightBox, 10 );
329 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 329 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
330 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 330 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
331 mRightFrame = new QWidgetStack( rightBox ); 331 mRightFrame = new QWidgetStack( rightBox );
332 rightLayout->addWidget( mNavigatorBar ); 332 rightLayout->addWidget( mNavigatorBar );
333 rightLayout->addWidget( mRightFrame, 10 ); 333 rightLayout->addWidget( mRightFrame, 10 );
334 334
335 mLeftFrame = leftFrame; 335 mLeftFrame = leftFrame;
336 if ( KOPrefs::instance()->mVerticalScreen ) { 336 if ( KOPrefs::instance()->mVerticalScreen ) {
337 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 337 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
338 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 338 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
339 } else { 339 } else {
340 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 340 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
341 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 341 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
342 } 342 }
343 if ( !KOPrefs::instance()->mShowDateNavigator) 343 if ( !KOPrefs::instance()->mShowDateNavigator)
344 mDateNavigator->hide(); 344 mDateNavigator->hide();
345 //qDebug("Calendarview Size %d %d ", width(), height()); 345 //qDebug("Calendarview Size %d %d ", width(), height());
346#endif 346#endif
347 347
348 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 348 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
349 SLOT( showDates( const KCal::DateList & ) ) ); 349 SLOT( showDates( const KCal::DateList & ) ) );
350 350
351 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 351 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
352 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 352 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
353 connect( mNavigatorBar, SIGNAL( goPrevYear() ), 353 connect( mNavigatorBar, SIGNAL( goPrevYear() ),
354 mNavigator, SLOT( selectPreviousYear() ) ); 354 mNavigator, SLOT( selectPreviousYear() ) );
355 connect( mNavigatorBar, SIGNAL( goNextYear() ), 355 connect( mNavigatorBar, SIGNAL( goNextYear() ),
356 mNavigator, SLOT( selectNextYear() ) ); 356 mNavigator, SLOT( selectNextYear() ) );
357 connect( mNavigatorBar, SIGNAL( goPrevMonth() ), 357 connect( mNavigatorBar, SIGNAL( goPrevMonth() ),
358 mNavigator, SLOT( selectPreviousMonth() ) ); 358 mNavigator, SLOT( selectPreviousMonth() ) );
359 connect( mNavigatorBar, SIGNAL( goNextMonth() ), 359 connect( mNavigatorBar, SIGNAL( goNextMonth() ),
360 mNavigator, SLOT( selectNextMonth() ) ); 360 mNavigator, SLOT( selectNextMonth() ) );
361 361
362 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 362 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
363 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); 363 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) );
364 364
365 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 365 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
366 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 366 mNavigator, SLOT( selectWeek( const QDate & ) ) );
367 367
368 connect( mDateNavigator, SIGNAL( goPrevYear() ), 368 connect( mDateNavigator, SIGNAL( goPrevYear() ),
369 mNavigator, SLOT( selectPreviousYear() ) ); 369 mNavigator, SLOT( selectPreviousYear() ) );
370 connect( mDateNavigator, SIGNAL( goNextYear() ), 370 connect( mDateNavigator, SIGNAL( goNextYear() ),
371 mNavigator, SLOT( selectNextYear() ) ); 371 mNavigator, SLOT( selectNextYear() ) );
372 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 372 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
373 mNavigator, SLOT( selectPreviousMonth() ) ); 373 mNavigator, SLOT( selectPreviousMonth() ) );
374 connect( mDateNavigator, SIGNAL( goNextMonth() ), 374 connect( mDateNavigator, SIGNAL( goNextMonth() ),
375 mNavigator, SLOT( selectNextMonth() ) ); 375 mNavigator, SLOT( selectNextMonth() ) );
376 376
377 connect( mDateNavigator, SIGNAL( goPrevious() ), 377 connect( mDateNavigator, SIGNAL( goPrevious() ),
378 mNavigator, SLOT( selectPrevious() ) ); 378 mNavigator, SLOT( selectPrevious() ) );
379 connect( mDateNavigator, SIGNAL( goNext() ), 379 connect( mDateNavigator, SIGNAL( goNext() ),
380 mNavigator, SLOT( selectNext() ) ); 380 mNavigator, SLOT( selectNext() ) );
381 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 381 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
382 mNavigator, SLOT( slotMonthSelect( int ) ) ); 382 mNavigator, SLOT( slotMonthSelect( int ) ) );
383 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), 383 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ),
384 mNavigator, SLOT( slotMonthSelect( int ) ) ); 384 mNavigator, SLOT( slotMonthSelect( int ) ) );
385 385
386 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 386 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
387 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 387 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
388 388
389 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), 389 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ),
390 SLOT( eventAdded( Event *) ) ); 390 SLOT( eventAdded( Event *) ) );
391 391
392 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 392 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
393 393
394 connect( this, SIGNAL( configChanged() ), 394 connect( this, SIGNAL( configChanged() ),
395 mDateNavigator, SLOT( updateConfig() ) ); 395 mDateNavigator, SLOT( updateConfig() ) );
396 396
397 connect( mTodoList, SIGNAL( newTodoSignal() ), 397 connect( mTodoList, SIGNAL( newTodoSignal() ),
398 SLOT( newTodo() ) ); 398 SLOT( newTodo() ) );
399 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 399 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
400 SLOT( newSubTodo( Todo * ) ) ); 400 SLOT( newSubTodo( Todo * ) ) );
401 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 401 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
402 SLOT( editTodo( Todo * ) ) ); 402 SLOT( editTodo( Todo * ) ) );
403 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 403 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
404 SLOT( showTodo( Todo *) ) ); 404 SLOT( showTodo( Todo *) ) );
405 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 405 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
406 SLOT( deleteTodo( Todo *) ) ); 406 SLOT( deleteTodo( Todo *) ) );
407 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 407 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
408 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 408 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
409 SLOT( purgeCompleted() ) ); 409 SLOT( purgeCompleted() ) );
410 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 410 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
411 SIGNAL( todoModified( Todo *, int ) ) ); 411 SIGNAL( todoModified( Todo *, int ) ) );
412 412
413 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 413 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
414 this, SLOT ( cloneIncidence( Incidence * ) ) ); 414 this, SLOT ( cloneIncidence( Incidence * ) ) );
415 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 415 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
416 this, SLOT (cancelIncidence( Incidence * ) ) ); 416 this, SLOT (cancelIncidence( Incidence * ) ) );
417 417
418 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 418 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
419 this, SLOT ( moveIncidence( Incidence * ) ) ); 419 this, SLOT ( moveIncidence( Incidence * ) ) );
420 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 420 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
421 this, SLOT ( beamIncidence( Incidence * ) ) ); 421 this, SLOT ( beamIncidence( Incidence * ) ) );
422 422
423 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 423 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
424 this, SLOT ( todo_unsub( Todo * ) ) ); 424 this, SLOT ( todo_unsub( Todo * ) ) );
425 425
426 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 426 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
427 this, SLOT ( todo_resub( Todo *,Todo * ) ) ); 427 this, SLOT ( todo_resub( Todo *,Todo * ) ) );
428 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 428 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
429 SLOT( updateTodo( Todo *, int ) ) ); 429 SLOT( updateTodo( Todo *, int ) ) );
430 connect( this, SIGNAL( todoModified( Todo *, int )), this, 430 connect( this, SIGNAL( todoModified( Todo *, int )), this,
431 SLOT( changeTodoDisplay( Todo *, int ) ) ); 431 SLOT( changeTodoDisplay( Todo *, int ) ) );
432 432
433 433
434 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 434 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
435 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 435 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
436 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 436 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
437 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 437 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
438 438
439 439
440 440
441 441
442 442
443 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 443 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
444 SLOT(checkClipboard())); 444 SLOT(checkClipboard()));
445 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 445 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
446 SLOT( processTodoListSelection( Incidence * ) ) ); 446 SLOT( processTodoListSelection( Incidence * ) ) );
447 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 447 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
448 448
449 // kdDebug() << "CalendarView::CalendarView() done" << endl; 449 // kdDebug() << "CalendarView::CalendarView() done" << endl;
450 450
451 mDateFrame = new QVBox(0,0,WType_Popup); 451 mDateFrame = new QVBox(0,0,WType_Popup);
452 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 452 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
453 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 453 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
454 mDateFrame->setLineWidth(3); 454 mDateFrame->setLineWidth(3);
455 mDateFrame->hide(); 455 mDateFrame->hide();
456 mDateFrame->setCaption( i18n( "Pick a date to display")); 456 mDateFrame->setCaption( i18n( "Pick a date to display"));
457 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 457 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
458 458
459 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 459 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
460 460
461 mEventEditor = mDialogManager->getEventEditor(); 461 mEventEditor = mDialogManager->getEventEditor();
462 mTodoEditor = mDialogManager->getTodoEditor(); 462 mTodoEditor = mDialogManager->getTodoEditor();
463 463
464 mFlagEditDescription = false; 464 mFlagEditDescription = false;
465 465
466 mSuspendTimer = new QTimer( this ); 466 mSuspendTimer = new QTimer( this );
467 mAlarmTimer = new QTimer( this ); 467 mAlarmTimer = new QTimer( this );
468 mRecheckAlarmTimer = new QTimer( this ); 468 mRecheckAlarmTimer = new QTimer( this );
469 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 469 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
470 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 470 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
471 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 471 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
472 mAlarmDialog = new AlarmDialog( this ); 472 mAlarmDialog = new AlarmDialog( this );
473 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 473 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
474 mAlarmDialog->setServerNotification( false ); 474 mAlarmDialog->setServerNotification( false );
475 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 475 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
476 476
477 477
478#ifndef DESKTOP_VERSION 478#ifndef DESKTOP_VERSION
479//US listen for arriving address resultsets 479//US listen for arriving address resultsets
480 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), 480 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)),
481 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 481 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
482#endif 482#endif
483 483
484} 484}
485 485
486 486
487CalendarView::~CalendarView() 487CalendarView::~CalendarView()
488{ 488{
489 // kdDebug() << "~CalendarView()" << endl; 489 // kdDebug() << "~CalendarView()" << endl;
490 //qDebug("CalendarView::~CalendarView() "); 490 //qDebug("CalendarView::~CalendarView() ");
491 delete mDialogManager; 491 delete mDialogManager;
492 delete mViewManager; 492 delete mViewManager;
493 delete mStorage; 493 delete mStorage;
494 delete mDateFrame ; 494 delete mDateFrame ;
495 delete beamDialog; 495 delete beamDialog;
496 //kdDebug() << "~CalendarView() done" << endl; 496 //kdDebug() << "~CalendarView() done" << endl;
497} 497}
498 498
499void CalendarView::showDay( QDate d ) 499void CalendarView::showDay( QDate d )
500{ 500{
501 dateNavigator()->blockSignals( true ); 501 dateNavigator()->blockSignals( true );
502 dateNavigator()->selectDate( d ); 502 dateNavigator()->selectDate( d );
503 dateNavigator()->blockSignals( false ); 503 dateNavigator()->blockSignals( false );
504 mViewManager->showDayView(); 504 mViewManager->showDayView();
505 //dateNavigator()->selectDate( d ); 505 //dateNavigator()->selectDate( d );
506} 506}
507void CalendarView::timerAlarm() 507void CalendarView::timerAlarm()
508{ 508{
509 //qDebug("CalendarView::timerAlarm() "); 509 //qDebug("CalendarView::timerAlarm() ");
510 computeAlarm(mAlarmNotification ); 510 computeAlarm(mAlarmNotification );
511} 511}
512 512
513void CalendarView::suspendAlarm() 513void CalendarView::suspendAlarm()
514{ 514{
515 //qDebug(" CalendarView::suspendAlarm() "); 515 //qDebug(" CalendarView::suspendAlarm() ");
516 computeAlarm(mSuspendAlarmNotification ); 516 computeAlarm(mSuspendAlarmNotification );
517 517
518} 518}
519 519
520void CalendarView::startAlarm( QString mess , QString filename) 520void CalendarView::startAlarm( QString mess , QString filename)
521{ 521{
522 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 522 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
523 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); 523 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
524 524
525} 525}
526 526
527void CalendarView::checkNextTimerAlarm() 527void CalendarView::checkNextTimerAlarm()
528{ 528{
529 mCalendar->checkAlarmForIncidence( 0, true ); 529 mCalendar->checkAlarmForIncidence( 0, true );
530} 530}
531 531
532void CalendarView::computeAlarm( QString msg ) 532void CalendarView::computeAlarm( QString msg )
533{ 533{
534 534
535 QString mess = msg; 535 QString mess = msg;
536 QString mAlarmMessage = mess.mid( 9 ); 536 QString mAlarmMessage = mess.mid( 9 );
537 QString filename = MainWindow::resourcePath(); 537 QString filename = MainWindow::resourcePath();
538 filename += "koalarm.wav"; 538 filename += "koalarm.wav";
539 QString tempfilename; 539 QString tempfilename;
540 if ( mess.left( 13 ) == "suspend_alarm") { 540 if ( mess.left( 13 ) == "suspend_alarm") {
541 bool error = false; 541 bool error = false;
542 int len = mess.mid( 13 ).find("+++"); 542 int len = mess.mid( 13 ).find("+++");
543 if ( len < 2 ) 543 if ( len < 2 )
544 error = true; 544 error = true;
545 else { 545 else {
546 tempfilename = mess.mid( 13, len ); 546 tempfilename = mess.mid( 13, len );
547 if ( !QFile::exists( tempfilename ) ) 547 if ( !QFile::exists( tempfilename ) )
548 error = true; 548 error = true;
549 } 549 }
550 if ( ! error ) { 550 if ( ! error ) {
551 filename = tempfilename; 551 filename = tempfilename;
552 } 552 }
553 mAlarmMessage = mess.mid( 13+len+3 ); 553 mAlarmMessage = mess.mid( 13+len+3 );
554 //qDebug("suspend file %s ",tempfilename.latin1() ); 554 //qDebug("suspend file %s ",tempfilename.latin1() );
555 startAlarm( mAlarmMessage, filename); 555 startAlarm( mAlarmMessage, filename);
556 return; 556 return;
557 } 557 }
558 if ( mess.left( 11 ) == "timer_alarm") { 558 if ( mess.left( 11 ) == "timer_alarm") {
559 //mTimerTime = 0; 559 //mTimerTime = 0;
560 startAlarm( mess.mid( 11 ), filename ); 560 startAlarm( mess.mid( 11 ), filename );
561 return; 561 return;
562 } 562 }
563 if ( mess.left( 10 ) == "proc_alarm") { 563 if ( mess.left( 10 ) == "proc_alarm") {
564 bool error = false; 564 bool error = false;
565 int len = mess.mid( 10 ).find("+++"); 565 int len = mess.mid( 10 ).find("+++");
566 if ( len < 2 ) 566 if ( len < 2 )
567 error = true; 567 error = true;
568 else { 568 else {
569 tempfilename = mess.mid( 10, len ); 569 tempfilename = mess.mid( 10, len );
570 if ( !QFile::exists( tempfilename ) ) 570 if ( !QFile::exists( tempfilename ) )
571 error = true; 571 error = true;
572 } 572 }
573 if ( error ) { 573 if ( error ) {
574 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 574 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
575 mAlarmMessage += mess.mid( 10+len+3+9 ); 575 mAlarmMessage += mess.mid( 10+len+3+9 );
576 } else { 576 } else {
577 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 577 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
578 //qDebug("-----system command %s ",tempfilename.latin1() ); 578 //qDebug("-----system command %s ",tempfilename.latin1() );
579#ifndef _WIN32_ 579#ifndef _WIN32_
580 if ( vfork () == 0 ) { 580 if ( vfork () == 0 ) {
581 execl ( tempfilename.latin1(), 0 ); 581 execl ( tempfilename.latin1(), 0 );
582 return; 582 return;
583 } 583 }
584#else 584#else
585 QProcess* p = new QProcess(); 585 QProcess* p = new QProcess();
586 p->addArgument( tempfilename.latin1() ); 586 p->addArgument( tempfilename.latin1() );
587 p->start(); 587 p->start();
588 return; 588 return;
589#endif 589#endif
590 590
591 return; 591 return;
592 } 592 }
593 593
594 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 594 //qDebug("+++++++system command %s ",tempfilename.latin1() );
595 } 595 }
596 if ( mess.left( 11 ) == "audio_alarm") { 596 if ( mess.left( 11 ) == "audio_alarm") {
597 bool error = false; 597 bool error = false;
598 int len = mess.mid( 11 ).find("+++"); 598 int len = mess.mid( 11 ).find("+++");
599 if ( len < 2 ) 599 if ( len < 2 )
600 error = true; 600 error = true;
601 else { 601 else {
602 tempfilename = mess.mid( 11, len ); 602 tempfilename = mess.mid( 11, len );
603 if ( !QFile::exists( tempfilename ) ) 603 if ( !QFile::exists( tempfilename ) )
604 error = true; 604 error = true;
605 } 605 }
606 if ( ! error ) { 606 if ( ! error ) {
607 filename = tempfilename; 607 filename = tempfilename;
608 } 608 }
609 mAlarmMessage = mess.mid( 11+len+3+9 ); 609 mAlarmMessage = mess.mid( 11+len+3+9 );
610 //qDebug("audio file command %s ",tempfilename.latin1() ); 610 //qDebug("audio file command %s ",tempfilename.latin1() );
611 } 611 }
612 if ( mess.left( 9 ) == "cal_alarm") { 612 if ( mess.left( 9 ) == "cal_alarm") {
613 mAlarmMessage = mess.mid( 9 ) ; 613 mAlarmMessage = mess.mid( 9 ) ;
614 } 614 }
615 615
616 startAlarm( mAlarmMessage, filename ); 616 startAlarm( mAlarmMessage, filename );
617 617
618 618
619} 619}
620 620
621void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 621void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
622{ 622{
623 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 623 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
624 624
625 mSuspendAlarmNotification = noti; 625 mSuspendAlarmNotification = noti;
626 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 626 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
627 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 627 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
628 mSuspendTimer->start( ms , true ); 628 mSuspendTimer->start( ms , true );
629 629
630} 630}
631 631
632void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 632void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
633{ 633{
634 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 634 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
635 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 635 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
636#ifndef DESKTOP_VERSION 636#ifndef DESKTOP_VERSION
637 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); 637 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() );
638#endif 638#endif
639 return; 639 return;
640 } 640 }
641 int maxSec; 641 int maxSec;
642 //maxSec = 5; //testing only 642 //maxSec = 5; //testing only
643 maxSec = 86400+3600; // one day+1hour 643 maxSec = 86400+3600; // one day+1hour
644 mAlarmNotification = noti; 644 mAlarmNotification = noti;
645 int sec = QDateTime::currentDateTime().secsTo( qdt ); 645 int sec = QDateTime::currentDateTime().secsTo( qdt );
646 if ( sec > maxSec ) { 646 if ( sec > maxSec ) {
647 mRecheckAlarmTimer->start( maxSec * 1000 ); 647 mRecheckAlarmTimer->start( maxSec * 1000 );
648 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 648 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
649 return; 649 return;
650 } else { 650 } else {
651 mRecheckAlarmTimer->stop(); 651 mRecheckAlarmTimer->stop();
652 } 652 }
653 //qDebug("Alarm timer started with secs: %d ", sec); 653 //qDebug("Alarm timer started with secs: %d ", sec);
654 mAlarmTimer->start( sec *1000 , true ); 654 mAlarmTimer->start( sec *1000 , true );
655 655
656} 656}
657// called by mRecheckAlarmTimer to get next alarm 657// called by mRecheckAlarmTimer to get next alarm
658// we need this, because a QTimer has only a max range of 25 days 658// we need this, because a QTimer has only a max range of 25 days
659void CalendarView::recheckTimerAlarm() 659void CalendarView::recheckTimerAlarm()
660{ 660{
661 mAlarmTimer->stop(); 661 mAlarmTimer->stop();
662 mRecheckAlarmTimer->stop(); 662 mRecheckAlarmTimer->stop();
663 mCalendar->checkAlarmForIncidence( 0, true ); 663 mCalendar->checkAlarmForIncidence( 0, true );
664} 664}
665void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 665void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
666{ 666{
667 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 667 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
668 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 668 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
669#ifndef DESKTOP_VERSION 669#ifndef DESKTOP_VERSION
670 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 670 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
671#endif 671#endif
672 return; 672 return;
673 } 673 }
674 mAlarmTimer->stop(); 674 mAlarmTimer->stop();
675} 675}
676void CalendarView::selectWeekNum ( int num ) 676void CalendarView::selectWeekNum ( int num )
677{ 677{
678 dateNavigator()->blockSignals( true ); 678 dateNavigator()->blockSignals( true );
679 dateNavigator()->selectWeek( num ); 679 dateNavigator()->selectWeek( num );
680 dateNavigator()->blockSignals( false ); 680 dateNavigator()->blockSignals( false );
681 mViewManager->showWeekView(); 681 mViewManager->showWeekView();
682} 682}
683KOViewManager *CalendarView::viewManager() 683KOViewManager *CalendarView::viewManager()
684{ 684{
685 return mViewManager; 685 return mViewManager;
686} 686}
687 687
688KODialogManager *CalendarView::dialogManager() 688KODialogManager *CalendarView::dialogManager()
689{ 689{
690 return mDialogManager; 690 return mDialogManager;
691} 691}
692 692
693QDate CalendarView::startDate() 693QDate CalendarView::startDate()
694{ 694{
695 DateList dates = mNavigator->selectedDates(); 695 DateList dates = mNavigator->selectedDates();
696 696
697 return dates.first(); 697 return dates.first();
698} 698}
699 699
700QDate CalendarView::endDate() 700QDate CalendarView::endDate()
701{ 701{
702 DateList dates = mNavigator->selectedDates(); 702 DateList dates = mNavigator->selectedDates();
703 703
704 return dates.last(); 704 return dates.last();
705} 705}
706 706
707 707
708void CalendarView::createPrinter() 708void CalendarView::createPrinter()
709{ 709{
710#ifndef KORG_NOPRINTER 710#ifndef KORG_NOPRINTER
711 if (!mCalPrinter) { 711 if (!mCalPrinter) {
712 mCalPrinter = new CalPrinter(this, mCalendar); 712 mCalPrinter = new CalPrinter(this, mCalendar);
713 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 713 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
714 } 714 }
715#endif 715#endif
716} 716}
717 717
718 718
719//KOPrefs::instance()->mWriteBackFile 719//KOPrefs::instance()->mWriteBackFile
720//KOPrefs::instance()->mWriteBackExistingOnly 720//KOPrefs::instance()->mWriteBackExistingOnly
721 721
722// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 722// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
723// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 723// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
724// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 724// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
725// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 725// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
726// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 726// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
727// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 727// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
728 728
729int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 729int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
730{ 730{
731 731
732 // 0 equal 732 // 0 equal
733 // 1 take local 733 // 1 take local
734 // 2 take remote 734 // 2 take remote
735 // 3 cancel 735 // 3 cancel
736 QDateTime lastSync = mLastCalendarSync; 736 QDateTime lastSync = mLastCalendarSync;
737 QDateTime localMod = local->lastModified(); 737 QDateTime localMod = local->lastModified();
738 QDateTime remoteMod = remote->lastModified(); 738 QDateTime remoteMod = remote->lastModified();
739 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 739 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
740 bool remCh, locCh; 740 bool remCh, locCh;
741 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 741 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
742 //if ( remCh ) 742 //if ( remCh )
743 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 743 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
744 locCh = ( localMod > mLastCalendarSync ); 744 locCh = ( localMod > mLastCalendarSync );
745 if ( !remCh && ! locCh ) { 745 if ( !remCh && ! locCh ) {
746 //qDebug("both not changed "); 746 //qDebug("both not changed ");
747 lastSync = localMod.addDays(1); 747 lastSync = localMod.addDays(1);
748 if ( mode <= SYNC_PREF_ASK ) 748 if ( mode <= SYNC_PREF_ASK )
749 return 0; 749 return 0;
750 } else { 750 } else {
751 if ( locCh ) { 751 if ( locCh ) {
752 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); 752 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1());
753 lastSync = localMod.addDays( -1 ); 753 lastSync = localMod.addDays( -1 );
754 if ( !remCh ) 754 if ( !remCh )
755 remoteMod = ( lastSync.addDays( -1 ) ); 755 remoteMod = ( lastSync.addDays( -1 ) );
756 } else { 756 } else {
757 //qDebug(" not loc changed "); 757 //qDebug(" not loc changed ");
758 lastSync = localMod.addDays( 1 ); 758 lastSync = localMod.addDays( 1 );
759 if ( remCh ) 759 if ( remCh )
760 remoteMod =( lastSync.addDays( 1 ) ); 760 remoteMod =( lastSync.addDays( 1 ) );
761 761
762 } 762 }
763 } 763 }
764 full = true; 764 full = true;
765 if ( mode < SYNC_PREF_ASK ) 765 if ( mode < SYNC_PREF_ASK )
766 mode = SYNC_PREF_ASK; 766 mode = SYNC_PREF_ASK;
767 } else { 767 } else {
768 if ( localMod == remoteMod ) 768 if ( localMod == remoteMod )
769 // if ( local->revision() == remote->revision() ) 769 // if ( local->revision() == remote->revision() )
770 return 0; 770 return 0;
771 771
772 } 772 }
773 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 773 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
774 774
775 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); 775 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision());
776 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); 776 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() );
777 //full = true; //debug only 777 //full = true; //debug only
778 if ( full ) { 778 if ( full ) {
779 bool equ = false; 779 bool equ = false;
780 if ( local->type() == "Event" ) { 780 if ( local->type() == "Event" ) {
781 equ = (*((Event*) local) == *((Event*) remote)); 781 equ = (*((Event*) local) == *((Event*) remote));
782 } 782 }
783 else if ( local->type() =="Todo" ) 783 else if ( local->type() =="Todo" )
784 equ = (*((Todo*) local) == (*(Todo*) remote)); 784 equ = (*((Todo*) local) == (*(Todo*) remote));
785 else if ( local->type() =="Journal" ) 785 else if ( local->type() =="Journal" )
786 equ = (*((Journal*) local) == *((Journal*) remote)); 786 equ = (*((Journal*) local) == *((Journal*) remote));
787 if ( equ ) { 787 if ( equ ) {
788 //qDebug("equal "); 788 //qDebug("equal ");
789 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 789 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
790 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 790 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
791 } 791 }
792 if ( mode < SYNC_PREF_FORCE_LOCAL ) 792 if ( mode < SYNC_PREF_FORCE_LOCAL )
793 return 0; 793 return 0;
794 794
795 }//else //debug only 795 }//else //debug only
796 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 796 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
797 } 797 }
798 int result; 798 int result;
799 bool localIsNew; 799 bool localIsNew;
800 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); 800 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() );
801 801
802 if ( full && mode < SYNC_PREF_NEWEST ) 802 if ( full && mode < SYNC_PREF_NEWEST )
803 mode = SYNC_PREF_ASK; 803 mode = SYNC_PREF_ASK;
804 804
805 switch( mode ) { 805 switch( mode ) {
806 case SYNC_PREF_LOCAL: 806 case SYNC_PREF_LOCAL:
807 if ( lastSync > remoteMod ) 807 if ( lastSync > remoteMod )
808 return 1; 808 return 1;
809 if ( lastSync > localMod ) 809 if ( lastSync > localMod )
810 return 2; 810 return 2;
811 return 1; 811 return 1;
812 break; 812 break;
813 case SYNC_PREF_REMOTE: 813 case SYNC_PREF_REMOTE:
814 if ( lastSync > remoteMod ) 814 if ( lastSync > remoteMod )
815 return 1; 815 return 1;
816 if ( lastSync > localMod ) 816 if ( lastSync > localMod )
817 return 2; 817 return 2;
818 return 2; 818 return 2;
819 break; 819 break;
820 case SYNC_PREF_NEWEST: 820 case SYNC_PREF_NEWEST:
821 if ( localMod > remoteMod ) 821 if ( localMod > remoteMod )
822 return 1; 822 return 1;
823 else 823 else
824 return 2; 824 return 2;
825 break; 825 break;
826 case SYNC_PREF_ASK: 826 case SYNC_PREF_ASK:
827 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 827 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
828 if ( lastSync > remoteMod ) 828 if ( lastSync > remoteMod )
829 return 1; 829 return 1;
830 if ( lastSync > localMod ) 830 if ( lastSync > localMod )
831 return 2; 831 return 2;
832 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 832 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
833 localIsNew = localMod >= remoteMod; 833 localIsNew = localMod >= remoteMod;
834 if ( localIsNew ) 834 if ( localIsNew )
835 getEventViewerDialog()->setColorMode( 1 ); 835 getEventViewerDialog()->setColorMode( 1 );
836 else 836 else
837 getEventViewerDialog()->setColorMode( 2 ); 837 getEventViewerDialog()->setColorMode( 2 );
838 getEventViewerDialog()->setIncidence(local); 838 getEventViewerDialog()->setIncidence(local);
839 if ( localIsNew ) 839 if ( localIsNew )
840 getEventViewerDialog()->setColorMode( 2 ); 840 getEventViewerDialog()->setColorMode( 2 );
841 else 841 else
842 getEventViewerDialog()->setColorMode( 1 ); 842 getEventViewerDialog()->setColorMode( 1 );
843 getEventViewerDialog()->addIncidence(remote); 843 getEventViewerDialog()->addIncidence(remote);
844 getEventViewerDialog()->setColorMode( 0 ); 844 getEventViewerDialog()->setColorMode( 0 );
845 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 845 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
846 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 846 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
847 getEventViewerDialog()->showMe(); 847 getEventViewerDialog()->showMe();
848 result = getEventViewerDialog()->executeS( localIsNew ); 848 result = getEventViewerDialog()->executeS( localIsNew );
849 return result; 849 return result;
850 850
851 break; 851 break;
852 case SYNC_PREF_FORCE_LOCAL: 852 case SYNC_PREF_FORCE_LOCAL:
853 return 1; 853 return 1;
854 break; 854 break;
855 case SYNC_PREF_FORCE_REMOTE: 855 case SYNC_PREF_FORCE_REMOTE:
856 return 2; 856 return 2;
857 break; 857 break;
858 858
859 default: 859 default:
860 // SYNC_PREF_TAKE_BOTH not implemented 860 // SYNC_PREF_TAKE_BOTH not implemented
861 break; 861 break;
862 } 862 }
863 return 0; 863 return 0;
864} 864}
865Event* CalendarView::getLastSyncEvent() 865Event* CalendarView::getLastSyncEvent()
866{ 866{
867 Event* lse; 867 Event* lse;
868 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 868 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
869 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 869 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
870 if (!lse) { 870 if (!lse) {
871 lse = new Event(); 871 lse = new Event();
872 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 872 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
873 QString sum = ""; 873 QString sum = "";
874 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 874 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
875 sum = "E: "; 875 sum = "E: ";
876 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 876 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
877 lse->setDtStart( mLastCalendarSync ); 877 lse->setDtStart( mLastCalendarSync );
878 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 878 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
879 lse->setCategories( i18n("SyncEvent") ); 879 lse->setCategories( i18n("SyncEvent") );
880 lse->setReadOnly( true ); 880 lse->setReadOnly( true );
881 mCalendar->addEvent( lse ); 881 mCalendar->addEvent( lse );
882 } 882 }
883 883
884 return lse; 884 return lse;
885 885
886} 886}
887 887
888// we check, if the to delete event has a id for a profile 888// we check, if the to delete event has a id for a profile
889// if yes, we set this id in the profile to delete 889// if yes, we set this id in the profile to delete
890void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 890void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
891{ 891{
892 if ( lastSync.count() == 0 ) { 892 if ( lastSync.count() == 0 ) {
893 //qDebug(" lastSync.count() == 0"); 893 //qDebug(" lastSync.count() == 0");
894 return; 894 return;
895 } 895 }
896 if ( toDelete->type() == "Journal" ) 896 if ( toDelete->type() == "Journal" )
897 return; 897 return;
898 898
899 Event* eve = lastSync.first(); 899 Event* eve = lastSync.first();
900 900
901 while ( eve ) { 901 while ( eve ) {
902 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 902 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
903 if ( !id.isEmpty() ) { 903 if ( !id.isEmpty() ) {
904 QString des = eve->description(); 904 QString des = eve->description();
905 QString pref = "e"; 905 QString pref = "e";
906 if ( toDelete->type() == "Todo" ) 906 if ( toDelete->type() == "Todo" )
907 pref = "t"; 907 pref = "t";
908 des += pref+ id + ","; 908 des += pref+ id + ",";
909 eve->setReadOnly( false ); 909 eve->setReadOnly( false );
910 eve->setDescription( des ); 910 eve->setDescription( des );
911 //qDebug("setdes %s ", des.latin1()); 911 //qDebug("setdes %s ", des.latin1());
912 eve->setReadOnly( true ); 912 eve->setReadOnly( true );
913 } 913 }
914 eve = lastSync.next(); 914 eve = lastSync.next();
915 } 915 }
916 916
917} 917}
918void CalendarView::checkExternalId( Incidence * inc ) 918void CalendarView::checkExternalId( Incidence * inc )
919{ 919{
920 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 920 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
921 checkExternSyncEvent( lastSync, inc ); 921 checkExternSyncEvent( lastSync, inc );
922 922
923} 923}
924bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 924bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
925{ 925{
926 bool syncOK = true; 926 bool syncOK = true;
927 int addedEvent = 0; 927 int addedEvent = 0;
928 int addedEventR = 0; 928 int addedEventR = 0;
929 int deletedEventR = 0; 929 int deletedEventR = 0;
930 int deletedEventL = 0; 930 int deletedEventL = 0;
931 int changedLocal = 0; 931 int changedLocal = 0;
932 int changedRemote = 0; 932 int changedRemote = 0;
933 int filteredIN = 0; 933 int filteredIN = 0;
934 int filteredOUT = 0; 934 int filteredOUT = 0;
935 //QPtrList<Event> el = local->rawEvents(); 935 //QPtrList<Event> el = local->rawEvents();
936 Event* eventR; 936 Event* eventR;
937 QString uid; 937 QString uid;
938 int take; 938 int take;
939 Event* eventL; 939 Event* eventL;
940 Event* eventRSync; 940 Event* eventRSync;
941 Event* eventLSync; 941 Event* eventLSync;
942 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 942 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
943 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 943 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
944 bool fullDateRange = false; 944 bool fullDateRange = false;
945 local->resetTempSyncStat(); 945 local->resetTempSyncStat();
946 mLastCalendarSync = QDateTime::currentDateTime(); 946 mLastCalendarSync = QDateTime::currentDateTime();
947 if ( mSyncManager->syncWithDesktop() ) { 947 if ( mSyncManager->syncWithDesktop() ) {
948 remote->resetPilotStat(1); 948 remote->resetPilotStat(1);
949 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 949 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
950 mLastCalendarSync = KSyncManager::mRequestedSyncEvent; 950 mLastCalendarSync = KSyncManager::mRequestedSyncEvent;
951 qDebug("using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); 951 qDebug("using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() );
952 } else { 952 } else {
953 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 953 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
954 } 954 }
955 } 955 }
956 QDateTime modifiedCalendar = mLastCalendarSync; 956 QDateTime modifiedCalendar = mLastCalendarSync;
957 eventLSync = getLastSyncEvent(); 957 eventLSync = getLastSyncEvent();
958 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 958 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
959 if ( eventR ) { 959 if ( eventR ) {
960 eventRSync = (Event*) eventR->clone(); 960 eventRSync = (Event*) eventR->clone();
961 remote->deleteEvent(eventR ); 961 remote->deleteEvent(eventR );
962 962
963 } else { 963 } else {
964 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { 964 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) {
965 eventRSync = (Event*)eventLSync->clone(); 965 eventRSync = (Event*)eventLSync->clone();
966 } else { 966 } else {
967 fullDateRange = true; 967 fullDateRange = true;
968 eventRSync = new Event(); 968 eventRSync = new Event();
969 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 969 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
970 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 970 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
971 eventRSync->setDtStart( mLastCalendarSync ); 971 eventRSync->setDtStart( mLastCalendarSync );
972 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 972 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
973 eventRSync->setCategories( i18n("SyncEvent") ); 973 eventRSync->setCategories( i18n("SyncEvent") );
974 } 974 }
975 } 975 }
976 if ( eventLSync->dtStart() == mLastCalendarSync ) 976 if ( eventLSync->dtStart() == mLastCalendarSync )
977 fullDateRange = true; 977 fullDateRange = true;
978 978
979 if ( ! fullDateRange ) { 979 if ( ! fullDateRange ) {
980 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 980 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
981 981
982 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 982 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
983 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 983 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
984 fullDateRange = true; 984 fullDateRange = true;
985 } 985 }
986 } 986 }
987 if ( mSyncManager->syncWithDesktop() ) { 987 if ( mSyncManager->syncWithDesktop() ) {
988 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); 988 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync );
989 } 989 }
990 if ( fullDateRange ) 990 if ( fullDateRange )
991 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 991 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
992 else 992 else
993 mLastCalendarSync = eventLSync->dtStart(); 993 mLastCalendarSync = eventLSync->dtStart();
994 // for resyncing if own file has changed 994 // for resyncing if own file has changed
995 if ( mCurrentSyncDevice == "deleteaftersync" ) { 995 if ( mCurrentSyncDevice == "deleteaftersync" ) {
996 mLastCalendarSync = loadedFileVersion; 996 mLastCalendarSync = loadedFileVersion;
997 //qDebug("setting mLastCalendarSync "); 997 //qDebug("setting mLastCalendarSync ");
998 } 998 }
999 //qDebug("*************************** "); 999 //qDebug("*************************** ");
1000 qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); 1000 qDebug("mLastCalendarSync %s full: %d",mLastCalendarSync.toString().latin1(), fullDateRange);
1001 QPtrList<Incidence> er = remote->rawIncidences(); 1001 QPtrList<Incidence> er = remote->rawIncidences();
1002 Incidence* inR = er.first(); 1002 Incidence* inR = er.first();
1003 Incidence* inL; 1003 Incidence* inL;
1004 QProgressBar bar( er.count(),0 ); 1004 QProgressBar bar( er.count(),0 );
1005 bar.setCaption (i18n("Syncing - close to abort!") ); 1005 bar.setCaption (i18n("Syncing - close to abort!") );
1006 1006
1007 // ************** setting up filter ************* 1007 // ************** setting up filter *************
1008 CalFilter *filterIN = 0; 1008 CalFilter *filterIN = 0;
1009 CalFilter *filterOUT = 0; 1009 CalFilter *filterOUT = 0;
1010 CalFilter *filter = mFilters.first(); 1010 CalFilter *filter = mFilters.first();
1011 while(filter) { 1011 while(filter) {
1012 if ( filter->name() == mSyncManager->mFilterInCal ) 1012 if ( filter->name() == mSyncManager->mFilterInCal )
1013 filterIN = filter; 1013 filterIN = filter;
1014 if ( filter->name() == mSyncManager->mFilterOutCal ) 1014 if ( filter->name() == mSyncManager->mFilterOutCal )
1015 filterOUT = filter; 1015 filterOUT = filter;
1016 filter = mFilters.next(); 1016 filter = mFilters.next();
1017 } 1017 }
1018 int w = 300; 1018 int w = 300;
1019 if ( QApplication::desktop()->width() < 320 ) 1019 if ( QApplication::desktop()->width() < 320 )
1020 w = 220; 1020 w = 220;
1021 int h = bar.sizeHint().height() ; 1021 int h = bar.sizeHint().height() ;
1022 int dw = QApplication::desktop()->width(); 1022 int dw = QApplication::desktop()->width();
1023 int dh = QApplication::desktop()->height(); 1023 int dh = QApplication::desktop()->height();
1024 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1024 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1025 bar.show(); 1025 bar.show();
1026 int modulo = (er.count()/10)+1; 1026 int modulo = (er.count()/10)+1;
1027 int incCounter = 0; 1027 int incCounter = 0;
1028 while ( inR ) { 1028 while ( inR ) {
1029 if ( ! bar.isVisible() ) 1029 if ( ! bar.isVisible() )
1030 return false; 1030 return false;
1031 if ( incCounter % modulo == 0 ) 1031 if ( incCounter % modulo == 0 )
1032 bar.setProgress( incCounter ); 1032 bar.setProgress( incCounter );
1033 ++incCounter; 1033 ++incCounter;
1034 uid = inR->uid(); 1034 uid = inR->uid();
1035 bool skipIncidence = false; 1035 bool skipIncidence = false;
1036 if ( uid.left(15) == QString("last-syncEvent-") ) 1036 if ( uid.left(15) == QString("last-syncEvent-") )
1037 skipIncidence = true; 1037 skipIncidence = true;
1038 QString idS; 1038 QString idS;
1039 qApp->processEvents(); 1039 qApp->processEvents();
1040 if ( !skipIncidence ) { 1040 if ( !skipIncidence ) {
1041 inL = local->incidence( uid ); 1041 inL = local->incidence( uid );
1042 if ( inL ) { // maybe conflict - same uid in both calendars 1042 if ( inL ) { // maybe conflict - same uid in both calendars
1043 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1043 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1044 //qDebug("take %d %s ", take, inL->summary().latin1()); 1044 //qDebug("take %d %s ", take, inL->summary().latin1());
1045 if ( take == 3 ) 1045 if ( take == 3 )
1046 return false; 1046 return false;
1047 if ( take == 1 ) {// take local ********************** 1047 if ( take == 1 ) {// take local **********************
1048 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1048 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1049 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1049 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1050 else 1050 else
1051 idS = inR->IDStr(); 1051 idS = inR->IDStr();
1052 remote->deleteIncidence( inR ); 1052 remote->deleteIncidence( inR );
1053 inR = inL->clone(); 1053 inR = inL->clone();
1054 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1054 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1055 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1055 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1056 inR->setIDStr( idS ); 1056 inR->setIDStr( idS );
1057 remote->addIncidence( inR ); 1057 remote->addIncidence( inR );
1058 if ( mSyncManager->syncWithDesktop() ) 1058 if ( mSyncManager->syncWithDesktop() )
1059 inR->setPilotId( 2 ); 1059 inR->setPilotId( 2 );
1060 ++changedRemote; 1060 ++changedRemote;
1061 } else {// take remote ********************** 1061 } else {// take remote **********************
1062 idS = inL->IDStr(); 1062 idS = inL->IDStr();
1063 int pid = inL->pilotId(); 1063 int pid = inL->pilotId();
1064 local->deleteIncidence( inL ); 1064 local->deleteIncidence( inL );
1065 inL = inR->clone(); 1065 inL = inR->clone();
1066 if ( mSyncManager->syncWithDesktop() ) 1066 if ( mSyncManager->syncWithDesktop() )
1067 inL->setPilotId( pid ); 1067 inL->setPilotId( pid );
1068 inL->setIDStr( idS ); 1068 inL->setIDStr( idS );
1069 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1069 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1070 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1070 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1071 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1071 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1072 } 1072 }
1073 local->addIncidence( inL ); 1073 local->addIncidence( inL );
1074 ++changedLocal; 1074 ++changedLocal;
1075 } 1075 }
1076 } 1076 }
1077 } else { // no conflict ********** add or delete remote 1077 } else { // no conflict ********** add or delete remote
1078 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ 1078 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){
1079 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1079 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1080 QString des = eventLSync->description(); 1080 QString des = eventLSync->description();
1081 QString pref = "e"; 1081 QString pref = "e";
1082 if ( inR->type() == "Todo" ) 1082 if ( inR->type() == "Todo" )
1083 pref = "t"; 1083 pref = "t";
1084 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1084 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1085 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1085 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1086 //remote->deleteIncidence( inR ); 1086 //remote->deleteIncidence( inR );
1087 ++deletedEventR; 1087 ++deletedEventR;
1088 } else { 1088 } else {
1089 inR->setLastModified( modifiedCalendar ); 1089 inR->setLastModified( modifiedCalendar );
1090 inL = inR->clone(); 1090 inL = inR->clone();
1091 inL->setIDStr( ":" ); 1091 inL->setIDStr( ":" );
1092 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1092 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1093 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1093 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1094 local->addIncidence( inL ); 1094 local->addIncidence( inL );
1095 ++addedEvent; 1095 ++addedEvent;
1096 1096
1097 } 1097 }
1098 } else { 1098 } else {
1099 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1099 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1100 inR->setLastModified( modifiedCalendar ); 1100 inR->setLastModified( modifiedCalendar );
1101 inL = inR->clone(); 1101 inL = inR->clone();
1102 inL->setIDStr( ":" ); 1102 inL->setIDStr( ":" );
1103 local->addIncidence( inL ); 1103 local->addIncidence( inL );
1104 ++addedEvent; 1104 ++addedEvent;
1105 1105
1106 } else { 1106 } else {
1107 checkExternSyncEvent(eventRSyncSharp, inR); 1107 checkExternSyncEvent(eventRSyncSharp, inR);
1108 remote->deleteIncidence( inR ); 1108 remote->deleteIncidence( inR );
1109 ++deletedEventR; 1109 ++deletedEventR;
1110 } 1110 }
1111 } 1111 }
1112 } else { 1112 } else {
1113 ++filteredIN; 1113 ++filteredIN;
1114 } 1114 }
1115 } 1115 }
1116 } 1116 }
1117 inR = er.next(); 1117 inR = er.next();
1118 } 1118 }
1119 QPtrList<Incidence> el = local->rawIncidences(); 1119 QPtrList<Incidence> el = local->rawIncidences();
1120 inL = el.first(); 1120 inL = el.first();
1121 modulo = (el.count()/10)+1; 1121 modulo = (el.count()/10)+1;
1122 bar.setCaption (i18n("Add / remove events") ); 1122 bar.setCaption (i18n("Add / remove events") );
1123 bar.setTotalSteps ( el.count() ) ; 1123 bar.setTotalSteps ( el.count() ) ;
1124 bar.show(); 1124 bar.show();
1125 incCounter = 0; 1125 incCounter = 0;
1126 1126
1127 while ( inL ) { 1127 while ( inL ) {
1128 1128
1129 qApp->processEvents(); 1129 qApp->processEvents();
1130 if ( ! bar.isVisible() ) 1130 if ( ! bar.isVisible() )
1131 return false; 1131 return false;
1132 if ( incCounter % modulo == 0 ) 1132 if ( incCounter % modulo == 0 )
1133 bar.setProgress( incCounter ); 1133 bar.setProgress( incCounter );
1134 ++incCounter; 1134 ++incCounter;
1135 uid = inL->uid(); 1135 uid = inL->uid();
1136 bool skipIncidence = false; 1136 bool skipIncidence = false;
1137 if ( uid.left(15) == QString("last-syncEvent-") ) 1137 if ( uid.left(15) == QString("last-syncEvent-") )
1138 skipIncidence = true; 1138 skipIncidence = true;
1139 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) 1139 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" )
1140 skipIncidence = true; 1140 skipIncidence = true;
1141 if ( !skipIncidence ) { 1141 if ( !skipIncidence ) {
1142 inR = remote->incidence( uid ); 1142 inR = remote->incidence( uid );
1143 if ( ! inR ) { 1143 if ( ! inR ) {
1144 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ 1144 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){
1145 // no conflict ********** add or delete local 1145 // no conflict ********** add or delete local
1146 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1146 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1147 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1147 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1148 checkExternSyncEvent(eventLSyncSharp, inL); 1148 checkExternSyncEvent(eventLSyncSharp, inL);
1149 local->deleteIncidence( inL ); 1149 local->deleteIncidence( inL );
1150 ++deletedEventL; 1150 ++deletedEventL;
1151 } else { 1151 } else {
1152 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1152 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1153 inL->removeID(mCurrentSyncDevice ); 1153 inL->removeID(mCurrentSyncDevice );
1154 ++addedEventR; 1154 ++addedEventR;
1155 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1155 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1156 inL->setLastModified( modifiedCalendar ); 1156 inL->setLastModified( modifiedCalendar );
1157 inR = inL->clone(); 1157 inR = inL->clone();
1158 inR->setIDStr( ":" ); 1158 inR->setIDStr( ":" );
1159 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1159 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1160 remote->addIncidence( inR ); 1160 remote->addIncidence( inR );
1161 } 1161 }
1162 } 1162 }
1163 } else { 1163 } else {
1164 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1164 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1165 checkExternSyncEvent(eventLSyncSharp, inL); 1165 checkExternSyncEvent(eventLSyncSharp, inL);
1166 local->deleteIncidence( inL ); 1166 local->deleteIncidence( inL );
1167 ++deletedEventL; 1167 ++deletedEventL;
1168 } else { 1168 } else {
1169 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1169 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1170 ++addedEventR; 1170 ++addedEventR;
1171 inL->setLastModified( modifiedCalendar ); 1171 inL->setLastModified( modifiedCalendar );
1172 inR = inL->clone(); 1172 inR = inL->clone();
1173 inR->setIDStr( ":" ); 1173 inR->setIDStr( ":" );
1174 remote->addIncidence( inR ); 1174 remote->addIncidence( inR );
1175 } 1175 }
1176 } 1176 }
1177 } 1177 }
1178 } else { 1178 } else {
1179 ++filteredOUT; 1179 ++filteredOUT;
1180 } 1180 }
1181 } 1181 }
1182 } 1182 }
1183 inL = el.next(); 1183 inL = el.next();
1184 } 1184 }
1185 int delFut = 0; 1185 int delFut = 0;
1186 int remRem = 0; 1186 int remRem = 0;
1187 if ( mSyncManager->mWriteBackInFuture ) { 1187 if ( mSyncManager->mWriteBackInFuture ) {
1188 er = remote->rawIncidences(); 1188 er = remote->rawIncidences();
1189 remRem = er.count(); 1189 remRem = er.count();
1190 inR = er.first(); 1190 inR = er.first();
1191 QDateTime dt; 1191 QDateTime dt;
1192 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); 1192 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) );
1193 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); 1193 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 );
1194 while ( inR ) { 1194 while ( inR ) {
1195 if ( inR->type() == "Todo" ) { 1195 if ( inR->type() == "Todo" ) {
1196 Todo * t = (Todo*)inR; 1196 Todo * t = (Todo*)inR;
1197 if ( t->hasDueDate() ) 1197 if ( t->hasDueDate() )
1198 dt = t->dtDue(); 1198 dt = t->dtDue();
1199 else 1199 else
1200 dt = cur.addSecs( 62 ); 1200 dt = cur.addSecs( 62 );
1201 } 1201 }
1202 else if (inR->type() == "Event" ) { 1202 else if (inR->type() == "Event" ) {
1203 bool ok; 1203 bool ok;
1204 dt = inR->getNextOccurence( cur, &ok ); 1204 dt = inR->getNextOccurence( cur, &ok );
1205 if ( !ok ) 1205 if ( !ok )
1206 dt = cur.addSecs( -62 ); 1206 dt = cur.addSecs( -62 );
1207 } 1207 }
1208 else 1208 else
1209 dt = inR->dtStart(); 1209 dt = inR->dtStart();
1210 if ( dt < cur || dt > end ) { 1210 if ( dt < cur || dt > end ) {
1211 remote->deleteIncidence( inR ); 1211 remote->deleteIncidence( inR );
1212 ++delFut; 1212 ++delFut;
1213 } 1213 }
1214 inR = er.next(); 1214 inR = er.next();
1215 } 1215 }
1216 } 1216 }
1217 bar.hide(); 1217 bar.hide();
1218 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1218 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1219 eventLSync->setReadOnly( false ); 1219 eventLSync->setReadOnly( false );
1220 eventLSync->setDtStart( mLastCalendarSync ); 1220 eventLSync->setDtStart( mLastCalendarSync );
1221 eventRSync->setDtStart( mLastCalendarSync ); 1221 eventRSync->setDtStart( mLastCalendarSync );
1222 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1222 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1223 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1223 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1224 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1224 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1225 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1225 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1226 eventLSync->setReadOnly( true ); 1226 eventLSync->setReadOnly( true );
1227 qDebug("********** %d %d ", mGlobalSyncMode == SYNC_MODE_NORMAL, mSyncManager->syncWithDesktop() ); 1227 qDebug("********** %d %d ", mGlobalSyncMode == SYNC_MODE_NORMAL, mSyncManager->syncWithDesktop() );
1228 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... 1228 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal...
1229 remote->addEvent( eventRSync ); 1229 remote->addEvent( eventRSync );
1230 else 1230 else
1231 delete eventRSync; 1231 delete eventRSync;
1232 QString mes; 1232 QString mes;
1233 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); 1233 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT );
1234 QString delmess; 1234 QString delmess;
1235 if ( delFut ) { 1235 if ( delFut ) {
1236 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); 1236 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut);
1237 mes += delmess; 1237 mes += delmess;
1238 } 1238 }
1239 mes = i18n("Local calendar changed!\n") +mes; 1239 mes = i18n("Local calendar changed!\n") +mes;
1240 mCalendar->checkAlarmForIncidence( 0, true ); 1240 mCalendar->checkAlarmForIncidence( 0, true );
1241 qDebug( mes ); 1241 qDebug( mes );
1242 if ( mSyncManager->mShowSyncSummary ) { 1242 if ( mSyncManager->mShowSyncSummary ) {
1243 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 1243 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
1244 i18n("KO/Pi Synchronization"),i18n("Write back"))) { 1244 i18n("KO/Pi Synchronization"),i18n("Write back"))) {
1245 qDebug("cancelled "); 1245 qDebug("cancelled ");
1246 return false; 1246 return false;
1247 } 1247 }
1248 } 1248 }
1249 return syncOK; 1249 return syncOK;
1250} 1250}
1251 1251
1252void CalendarView::setSyncDevice( QString s ) 1252void CalendarView::setSyncDevice( QString s )
1253{ 1253{
1254 mCurrentSyncDevice= s; 1254 mCurrentSyncDevice= s;
1255} 1255}
1256void CalendarView::setSyncName( QString s ) 1256void CalendarView::setSyncName( QString s )
1257{ 1257{
1258 mCurrentSyncName= s; 1258 mCurrentSyncName= s;
1259} 1259}
1260bool CalendarView::syncCalendar(QString filename, int mode) 1260bool CalendarView::syncCalendar(QString filename, int mode)
1261{ 1261{
1262 //qDebug("syncCalendar %s ", filename.latin1()); 1262 //qDebug("syncCalendar %s ", filename.latin1());
1263 mGlobalSyncMode = SYNC_MODE_NORMAL; 1263 mGlobalSyncMode = SYNC_MODE_NORMAL;
1264 CalendarLocal* calendar = new CalendarLocal(); 1264 CalendarLocal* calendar = new CalendarLocal();
1265 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1265 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1266 FileStorage* storage = new FileStorage( calendar ); 1266 FileStorage* storage = new FileStorage( calendar );
1267 bool syncOK = false; 1267 bool syncOK = false;
1268 storage->setFileName( filename ); 1268 storage->setFileName( filename );
1269 // qDebug("loading ... "); 1269 // qDebug("loading ... ");
1270 if ( storage->load() ) { 1270 if ( storage->load() ) {
1271 getEventViewerDialog()->setSyncMode( true ); 1271 getEventViewerDialog()->setSyncMode( true );
1272 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1272 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1273 getEventViewerDialog()->setSyncMode( false ); 1273 getEventViewerDialog()->setSyncMode( false );
1274 if ( syncOK ) { 1274 if ( syncOK ) {
1275 if ( mSyncManager->mWriteBackFile ) 1275 if ( mSyncManager->mWriteBackFile )
1276 { 1276 {
1277 storage->setSaveFormat( new ICalFormat() ); 1277 storage->setSaveFormat( new ICalFormat() );
1278 storage->save(); 1278 storage->save();
1279 } 1279 }
1280 } 1280 }
1281 setModified( true ); 1281 setModified( true );
1282 } 1282 }
1283 delete storage; 1283 delete storage;
1284 delete calendar; 1284 delete calendar;
1285 if ( syncOK ) 1285 if ( syncOK )
1286 updateView(); 1286 updateView();
1287 return syncOK; 1287 return syncOK;
1288} 1288}
1289 1289
1290void CalendarView::syncExternal( int mode ) 1290void CalendarView::syncExternal( int mode )
1291{ 1291{
1292 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1292 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1293 1293
1294 qApp->processEvents(); 1294 qApp->processEvents();
1295 CalendarLocal* calendar = new CalendarLocal(); 1295 CalendarLocal* calendar = new CalendarLocal();
1296 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1296 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1297 bool syncOK = false; 1297 bool syncOK = false;
1298 bool loadSuccess = false; 1298 bool loadSuccess = false;
1299 PhoneFormat* phoneFormat = 0; 1299 PhoneFormat* phoneFormat = 0;
1300 emit tempDisableBR(true); 1300 emit tempDisableBR(true);
1301#ifndef DESKTOP_VERSION 1301#ifndef DESKTOP_VERSION
1302 SharpFormat* sharpFormat = 0; 1302 SharpFormat* sharpFormat = 0;
1303 if ( mode == 0 ) { // sharp 1303 if ( mode == 0 ) { // sharp
1304 sharpFormat = new SharpFormat () ; 1304 sharpFormat = new SharpFormat () ;
1305 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1305 loadSuccess = sharpFormat->load( calendar, mCalendar );
1306 1306
1307 } else 1307 } else
1308#endif 1308#endif
1309 if ( mode == 1 ) { // phone 1309 if ( mode == 1 ) { // phone
1310 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1310 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1311 mSyncManager->mPhoneDevice, 1311 mSyncManager->mPhoneDevice,
1312 mSyncManager->mPhoneConnection, 1312 mSyncManager->mPhoneConnection,
1313 mSyncManager->mPhoneModel); 1313 mSyncManager->mPhoneModel);
1314 loadSuccess = phoneFormat->load( calendar,mCalendar); 1314 loadSuccess = phoneFormat->load( calendar,mCalendar);
1315 1315
1316 } else { 1316 } else {
1317 emit tempDisableBR(false); 1317 emit tempDisableBR(false);
1318 return; 1318 return;
1319 } 1319 }
1320 if ( loadSuccess ) { 1320 if ( loadSuccess ) {
1321 getEventViewerDialog()->setSyncMode( true ); 1321 getEventViewerDialog()->setSyncMode( true );
1322 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1322 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1323 getEventViewerDialog()->setSyncMode( false ); 1323 getEventViewerDialog()->setSyncMode( false );
1324 qApp->processEvents(); 1324 qApp->processEvents();
1325 if ( syncOK ) { 1325 if ( syncOK ) {
1326 if ( mSyncManager->mWriteBackFile ) 1326 if ( mSyncManager->mWriteBackFile )
1327 { 1327 {
1328 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1328 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1329 Incidence* inc = iL.first(); 1329 Incidence* inc = iL.first();
1330 if ( phoneFormat ) { 1330 if ( phoneFormat ) {
1331 while ( inc ) { 1331 while ( inc ) {
1332 inc->removeID(mCurrentSyncDevice); 1332 inc->removeID(mCurrentSyncDevice);
1333 inc = iL.next(); 1333 inc = iL.next();
1334 } 1334 }
1335 } 1335 }
1336#ifndef DESKTOP_VERSION 1336#ifndef DESKTOP_VERSION
1337 if ( sharpFormat ) 1337 if ( sharpFormat )
1338 sharpFormat->save(calendar); 1338 sharpFormat->save(calendar);
1339#endif 1339#endif
1340 if ( phoneFormat ) 1340 if ( phoneFormat )
1341 phoneFormat->save(calendar); 1341 phoneFormat->save(calendar);
1342 iL = calendar->rawIncidences(); 1342 iL = calendar->rawIncidences();
1343 inc = iL.first(); 1343 inc = iL.first();
1344 Incidence* loc; 1344 Incidence* loc;
1345 while ( inc ) { 1345 while ( inc ) {
1346 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1346 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1347 loc = mCalendar->incidence(inc->uid() ); 1347 loc = mCalendar->incidence(inc->uid() );
1348 if ( loc ) { 1348 if ( loc ) {
1349 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1349 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1350 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1350 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1351 } 1351 }
1352 } 1352 }
1353 inc = iL.next(); 1353 inc = iL.next();
1354 } 1354 }
1355 Incidence* lse = getLastSyncEvent(); 1355 Incidence* lse = getLastSyncEvent();
1356 if ( lse ) { 1356 if ( lse ) {
1357 lse->setReadOnly( false ); 1357 lse->setReadOnly( false );
1358 lse->setDescription( "" ); 1358 lse->setDescription( "" );
1359 lse->setReadOnly( true ); 1359 lse->setReadOnly( true );
1360 } 1360 }
1361 } 1361 }
1362 } else { 1362 } else {
1363 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 1363 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
1364 } 1364 }
1365 setModified( true ); 1365 setModified( true );
1366 } else { 1366 } else {
1367 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1367 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1368 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1368 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1369 question, i18n("Ok")) ; 1369 question, i18n("Ok")) ;
1370 1370
1371 } 1371 }
1372 delete calendar; 1372 delete calendar;
1373 updateView(); 1373 updateView();
1374 emit tempDisableBR(false); 1374 emit tempDisableBR(false);
1375 return ;//syncOK; 1375 return ;//syncOK;
1376 1376
1377} 1377}
1378 1378
1379bool CalendarView::importBday() 1379bool CalendarView::importBday()
1380{ 1380{
1381#ifndef KORG_NOKABC 1381#ifndef KORG_NOKABC
1382 1382
1383#ifdef DESKTOP_VERSION 1383#ifdef DESKTOP_VERSION
1384 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1384 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1385 KABC::AddressBook::Iterator it; 1385 KABC::AddressBook::Iterator it;
1386 int count = 0; 1386 int count = 0;
1387 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1387 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1388 ++count; 1388 ++count;
1389 } 1389 }
1390 QProgressBar bar(count,0 ); 1390 QProgressBar bar(count,0 );
1391 int w = 300; 1391 int w = 300;
1392 if ( QApplication::desktop()->width() < 320 ) 1392 if ( QApplication::desktop()->width() < 320 )
1393 w = 220; 1393 w = 220;
1394 int h = bar.sizeHint().height() ; 1394 int h = bar.sizeHint().height() ;
1395 int dw = QApplication::desktop()->width(); 1395 int dw = QApplication::desktop()->width();
1396 int dh = QApplication::desktop()->height(); 1396 int dh = QApplication::desktop()->height();
1397 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1397 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1398 bar.show(); 1398 bar.show();
1399 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1399 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1400 qApp->processEvents(); 1400 qApp->processEvents();
1401 count = 0; 1401 count = 0;
1402 int addCount = 0; 1402 int addCount = 0;
1403 KCal::Attendee* a = 0; 1403 KCal::Attendee* a = 0;
1404 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1404 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1405 if ( ! bar.isVisible() ) 1405 if ( ! bar.isVisible() )
1406 return false; 1406 return false;
1407 bar.setProgress( count++ ); 1407 bar.setProgress( count++ );
1408 qApp->processEvents(); 1408 qApp->processEvents();
1409 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1409 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1410 if ( (*it).birthday().date().isValid() ){ 1410 if ( (*it).birthday().date().isValid() ){
1411 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1411 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1412 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1412 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1413 ++addCount; 1413 ++addCount;
1414 } 1414 }
1415 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1415 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1416 if ( anni.isValid() ){ 1416 if ( anni.isValid() ){
1417 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1417 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1418 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1418 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1419 ++addCount; 1419 ++addCount;
1420 } 1420 }
1421 } 1421 }
1422 updateView(); 1422 updateView();
1423 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1423 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1424#else //DESKTOP_VERSION 1424#else //DESKTOP_VERSION
1425 1425
1426 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 1426 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
1427 // the result should now arrive through method insertBirthdays 1427 // the result should now arrive through method insertBirthdays
1428 1428
1429#endif //DESKTOP_VERSION 1429#endif //DESKTOP_VERSION
1430 1430
1431#endif //KORG_NOKABC 1431#endif //KORG_NOKABC
1432 1432
1433 1433
1434 return true; 1434 return true;
1435} 1435}
1436 1436
1437// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI 1437// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
1438void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, 1438void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
1439 const QStringList& anniversaryList, const QStringList& realNameList, 1439 const QStringList& anniversaryList, const QStringList& realNameList,
1440 const QStringList& emailList, const QStringList& assembledNameList, 1440 const QStringList& emailList, const QStringList& assembledNameList,
1441 const QStringList& uidList) 1441 const QStringList& uidList)
1442{ 1442{
1443 qDebug("CalendarView::insertBirthdays"); 1443 qDebug("CalendarView::insertBirthdays");
1444 if (uid == this->name()) 1444 if (uid == this->name())
1445 { 1445 {
1446 int count = birthdayList.count(); 1446 int count = birthdayList.count();
1447 int addCount = 0; 1447 int addCount = 0;
1448 KCal::Attendee* a = 0; 1448 KCal::Attendee* a = 0;
1449 1449
1450 qDebug("CalView 1 %i", count); 1450 qDebug("CalView 1 %i", count);
1451 1451
1452 QProgressBar bar(count,0 ); 1452 QProgressBar bar(count,0 );
1453 int w = 300; 1453 int w = 300;
1454 if ( QApplication::desktop()->width() < 320 ) 1454 if ( QApplication::desktop()->width() < 320 )
1455 w = 220; 1455 w = 220;
1456 int h = bar.sizeHint().height() ; 1456 int h = bar.sizeHint().height() ;
1457 int dw = QApplication::desktop()->width(); 1457 int dw = QApplication::desktop()->width();
1458 int dh = QApplication::desktop()->height(); 1458 int dh = QApplication::desktop()->height();
1459 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1459 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1460 bar.show(); 1460 bar.show();
1461 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 1461 bar.setCaption (i18n("inserting birthdays - close to abort!") );
1462 qApp->processEvents(); 1462 qApp->processEvents();
1463 1463
1464 QDate birthday; 1464 QDate birthday;
1465 QDate anniversary; 1465 QDate anniversary;
1466 QString realName; 1466 QString realName;
1467 QString email; 1467 QString email;
1468 QString assembledName; 1468 QString assembledName;
1469 QString uid; 1469 QString uid;
1470 bool ok = true; 1470 bool ok = true;
1471 for ( int i = 0; i < count; i++) 1471 for ( int i = 0; i < count; i++)
1472 { 1472 {
1473 if ( ! bar.isVisible() ) 1473 if ( ! bar.isVisible() )
1474 return; 1474 return;
1475 bar.setProgress( i ); 1475 bar.setProgress( i );
1476 qApp->processEvents(); 1476 qApp->processEvents();
1477 1477
1478 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); 1478 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
1479 if (!ok) { 1479 if (!ok) {
1480 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); 1480 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
1481 } 1481 }
1482 1482
1483 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); 1483 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
1484 if (!ok) { 1484 if (!ok) {
1485 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); 1485 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
1486 } 1486 }
1487 realName = realNameList[i]; 1487 realName = realNameList[i];
1488 email = emailList[i]; 1488 email = emailList[i];
1489 assembledName = assembledNameList[i]; 1489 assembledName = assembledNameList[i];
1490 uid = uidList[i]; 1490 uid = uidList[i];
1491 //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); 1491 //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() );
1492 1492
1493 if ( birthday.isValid() ){ 1493 if ( birthday.isValid() ){
1494 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1494 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1495 KCal::Attendee::ReqParticipant,uid) ; 1495 KCal::Attendee::ReqParticipant,uid) ;
1496 if ( addAnniversary( birthday, assembledName, a, true ) ) 1496 if ( addAnniversary( birthday, assembledName, a, true ) )
1497 ++addCount; 1497 ++addCount;
1498 } 1498 }
1499 1499
1500 if ( anniversary.isValid() ){ 1500 if ( anniversary.isValid() ){
1501 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1501 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1502 KCal::Attendee::ReqParticipant,uid) ; 1502 KCal::Attendee::ReqParticipant,uid) ;
1503 if ( addAnniversary( anniversary, assembledName, a, false ) ) 1503 if ( addAnniversary( anniversary, assembledName, a, false ) )
1504 ++addCount; 1504 ++addCount;
1505 } 1505 }
1506 } 1506 }
1507 1507
1508 updateView(); 1508 updateView();
1509 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1509 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1510 1510
1511 } 1511 }
1512 1512
1513} 1513}
1514 1514
1515 1515
1516 1516
1517bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1517bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1518{ 1518{
1519 //qDebug("addAnni "); 1519 //qDebug("addAnni ");
1520 Event * ev = new Event(); 1520 Event * ev = new Event();
1521 if ( a ) { 1521 if ( a ) {
1522 ev->addAttendee( a ); 1522 ev->addAttendee( a );
1523 } 1523 }
1524 QString kind; 1524 QString kind;
1525 if ( birthday ) 1525 if ( birthday )
1526 kind = i18n( "Birthday" ); 1526 kind = i18n( "Birthday" );
1527 else 1527 else
1528 kind = i18n( "Anniversary" ); 1528 kind = i18n( "Anniversary" );
1529 ev->setSummary( name + " - " + kind ); 1529 ev->setSummary( name + " - " + kind );
1530 ev->setOrganizer(a->email()); 1530 ev->setOrganizer(a->email());
1531 ev->setCategories( kind ); 1531 ev->setCategories( kind );
1532 ev->setDtStart( QDateTime(date) ); 1532 ev->setDtStart( QDateTime(date) );
1533 ev->setDtEnd( QDateTime(date) ); 1533 ev->setDtEnd( QDateTime(date) );
1534 ev->setFloats( true ); 1534 ev->setFloats( true );
1535 Recurrence * rec = ev->recurrence(); 1535 Recurrence * rec = ev->recurrence();
1536 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1536 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1537 rec->addYearlyNum( date.month() ); 1537 rec->addYearlyNum( date.month() );
1538 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1538 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1539 delete ev; 1539 delete ev;
1540 return false; 1540 return false;
1541 } 1541 }
1542 return true; 1542 return true;
1543 1543
1544} 1544}
1545bool CalendarView::importQtopia( const QString &categories, 1545bool CalendarView::importQtopia( const QString &categories,
1546 const QString &datebook, 1546 const QString &datebook,
1547 const QString &todolist ) 1547 const QString &todolist )
1548{ 1548{
1549 1549
1550 QtopiaFormat qtopiaFormat; 1550 QtopiaFormat qtopiaFormat;
1551 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1551 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1552 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1552 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1553 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1553 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1554 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1554 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1555 1555
1556 updateView(); 1556 updateView();
1557 return true; 1557 return true;
1558 1558
1559#if 0 1559#if 0
1560 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1560 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1561 mCurrentSyncDevice = "qtopia-XML"; 1561 mCurrentSyncDevice = "qtopia-XML";
1562 if ( mSyncManager->mAskForPreferences ) 1562 if ( mSyncManager->mAskForPreferences )
1563 edit_sync_options(); 1563 edit_sync_options();
1564 qApp->processEvents(); 1564 qApp->processEvents();
1565 CalendarLocal* calendar = new CalendarLocal(); 1565 CalendarLocal* calendar = new CalendarLocal();
1566 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1566 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1567 bool syncOK = false; 1567 bool syncOK = false;
1568 QtopiaFormat qtopiaFormat; 1568 QtopiaFormat qtopiaFormat;
1569 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1569 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1570 bool loadOk = true; 1570 bool loadOk = true;
1571 if ( !categories.isEmpty() ) 1571 if ( !categories.isEmpty() )
1572 loadOk = qtopiaFormat.load( calendar, categories ); 1572 loadOk = qtopiaFormat.load( calendar, categories );
1573 if ( loadOk && !datebook.isEmpty() ) 1573 if ( loadOk && !datebook.isEmpty() )
1574 loadOk = qtopiaFormat.load( calendar, datebook ); 1574 loadOk = qtopiaFormat.load( calendar, datebook );
1575 if ( loadOk && !todolist.isEmpty() ) 1575 if ( loadOk && !todolist.isEmpty() )
1576 loadOk = qtopiaFormat.load( calendar, todolist ); 1576 loadOk = qtopiaFormat.load( calendar, todolist );
1577 1577
1578 if ( loadOk ) { 1578 if ( loadOk ) {
1579 getEventViewerDialog()->setSyncMode( true ); 1579 getEventViewerDialog()->setSyncMode( true );
1580 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1580 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1581 getEventViewerDialog()->setSyncMode( false ); 1581 getEventViewerDialog()->setSyncMode( false );
1582 qApp->processEvents(); 1582 qApp->processEvents();
1583 if ( syncOK ) { 1583 if ( syncOK ) {
1584 if ( mSyncManager->mWriteBackFile ) 1584 if ( mSyncManager->mWriteBackFile )
1585 { 1585 {
1586 // write back XML file 1586 // write back XML file
1587 1587
1588 } 1588 }
1589 setModified( true ); 1589 setModified( true );
1590 } 1590 }
1591 } else { 1591 } else {
1592 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1592 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1593 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1593 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1594 question, i18n("Ok")) ; 1594 question, i18n("Ok")) ;
1595 } 1595 }
1596 delete calendar; 1596 delete calendar;
1597 updateView(); 1597 updateView();
1598 return syncOK; 1598 return syncOK;
1599 1599
1600 1600
1601#endif 1601#endif
1602 1602
1603} 1603}
1604 1604
1605void CalendarView::setSyncEventsReadOnly() 1605void CalendarView::setSyncEventsReadOnly()
1606{ 1606{
1607 Event * ev; 1607 Event * ev;
1608 QPtrList<Event> eL = mCalendar->rawEvents(); 1608 QPtrList<Event> eL = mCalendar->rawEvents();
1609 ev = eL.first(); 1609 ev = eL.first();
1610 while ( ev ) { 1610 while ( ev ) {
1611 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1611 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1612 ev->setReadOnly( true ); 1612 ev->setReadOnly( true );
1613 ev = eL.next(); 1613 ev = eL.next();
1614 } 1614 }
1615} 1615}
1616bool CalendarView::openCalendar(QString filename, bool merge) 1616bool CalendarView::openCalendar(QString filename, bool merge)
1617{ 1617{
1618 1618
1619 if (filename.isEmpty()) { 1619 if (filename.isEmpty()) {
1620 return false; 1620 return false;
1621 } 1621 }
1622 1622
1623 if (!QFile::exists(filename)) { 1623 if (!QFile::exists(filename)) {
1624 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1624 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1625 return false; 1625 return false;
1626 } 1626 }
1627 1627
1628 globalFlagBlockAgenda = 1; 1628 globalFlagBlockAgenda = 1;
1629 if (!merge) mCalendar->close(); 1629 if (!merge) mCalendar->close();
1630 1630
1631 mStorage->setFileName( filename ); 1631 mStorage->setFileName( filename );
1632 1632
1633 if ( mStorage->load() ) { 1633 if ( mStorage->load() ) {
1634 if ( merge ) ;//setModified( true ); 1634 if ( merge ) ;//setModified( true );
1635 else { 1635 else {
1636 //setModified( true ); 1636 //setModified( true );
1637 mViewManager->setDocumentId( filename ); 1637 mViewManager->setDocumentId( filename );
1638 mDialogManager->setDocumentId( filename ); 1638 mDialogManager->setDocumentId( filename );
1639 mTodoList->setDocumentId( filename ); 1639 mTodoList->setDocumentId( filename );
1640 } 1640 }
1641 globalFlagBlockAgenda = 2; 1641 globalFlagBlockAgenda = 2;
1642 // if ( getLastSyncEvent() ) 1642 // if ( getLastSyncEvent() )
1643 // getLastSyncEvent()->setReadOnly( true ); 1643 // getLastSyncEvent()->setReadOnly( true );
1644 mCalendar->reInitAlarmSettings(); 1644 mCalendar->reInitAlarmSettings();
1645 setSyncEventsReadOnly(); 1645 setSyncEventsReadOnly();
1646 updateUnmanagedViews(); 1646 updateUnmanagedViews();
1647 updateView(); 1647 updateView();
1648 if ( filename != MainWindow::defaultFileName() ) { 1648 if ( filename != MainWindow::defaultFileName() ) {
1649 saveCalendar( MainWindow::defaultFileName() ); 1649 saveCalendar( MainWindow::defaultFileName() );
1650 } else { 1650 } else {
1651 QFileInfo finf ( MainWindow::defaultFileName()); 1651 QFileInfo finf ( MainWindow::defaultFileName());
1652 if ( finf.exists() ) { 1652 if ( finf.exists() ) {
1653 setLoadedFileVersion( finf.lastModified () ); 1653 setLoadedFileVersion( finf.lastModified () );
1654 } 1654 }
1655 } 1655 }
1656 return true; 1656 return true;
1657 } else { 1657 } else {
1658 // while failing to load, the calendar object could 1658 // while failing to load, the calendar object could
1659 // have become partially populated. Clear it out. 1659 // have become partially populated. Clear it out.
1660 if ( !merge ) { 1660 if ( !merge ) {
1661 mCalendar->close(); 1661 mCalendar->close();
1662 mViewManager->setDocumentId( filename ); 1662 mViewManager->setDocumentId( filename );
1663 mDialogManager->setDocumentId( filename ); 1663 mDialogManager->setDocumentId( filename );
1664 mTodoList->setDocumentId( filename ); 1664 mTodoList->setDocumentId( filename );
1665 } 1665 }
1666 1666
1667 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1667 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1668 1668
1669 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 1669 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
1670 globalFlagBlockAgenda = 2; 1670 globalFlagBlockAgenda = 2;
1671 mCalendar->reInitAlarmSettings(); 1671 mCalendar->reInitAlarmSettings();
1672 setSyncEventsReadOnly(); 1672 setSyncEventsReadOnly();
1673 updateUnmanagedViews(); 1673 updateUnmanagedViews();
1674 updateView(); 1674 updateView();
1675 } 1675 }
1676 return false; 1676 return false;
1677} 1677}
1678void CalendarView::showOpenError() 1678void CalendarView::showOpenError()
1679{ 1679{
1680 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 1680 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
1681} 1681}
1682void CalendarView::setLoadedFileVersion(QDateTime dt) 1682void CalendarView::setLoadedFileVersion(QDateTime dt)
1683{ 1683{
1684 loadedFileVersion = dt; 1684 loadedFileVersion = dt;
1685} 1685}
1686bool CalendarView::checkFileChanged(QString fn) 1686bool CalendarView::checkFileChanged(QString fn)
1687{ 1687{
1688 QFileInfo finf ( fn ); 1688 QFileInfo finf ( fn );
1689 if ( !finf.exists() ) 1689 if ( !finf.exists() )
1690 return true; 1690 return true;
1691 QDateTime dt = finf.lastModified (); 1691 QDateTime dt = finf.lastModified ();
1692 if ( dt <= loadedFileVersion ) 1692 if ( dt <= loadedFileVersion )
1693 return false; 1693 return false;
1694 return true; 1694 return true;
1695 1695
1696} 1696}
1697void CalendarView::watchSavedFile() 1697void CalendarView::watchSavedFile()
1698{ 1698{
1699 QFileInfo finf ( MainWindow::defaultFileName()); 1699 QFileInfo finf ( MainWindow::defaultFileName());
1700 if ( !finf.exists() ) 1700 if ( !finf.exists() )
1701 return; 1701 return;
1702 QDateTime dt = finf.lastModified (); 1702 QDateTime dt = finf.lastModified ();
1703 if ( dt < loadedFileVersion ) { 1703 if ( dt < loadedFileVersion ) {
1704 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 1704 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
1705 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 1705 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1706 return; 1706 return;
1707 } 1707 }
1708 loadedFileVersion = dt; 1708 loadedFileVersion = dt;
1709} 1709}
1710 1710
1711bool CalendarView::checkFileVersion(QString fn) 1711bool CalendarView::checkFileVersion(QString fn)
1712{ 1712{
1713 QFileInfo finf ( fn ); 1713 QFileInfo finf ( fn );
1714 if ( !finf.exists() ) 1714 if ( !finf.exists() )
1715 return true; 1715 return true;
1716 QDateTime dt = finf.lastModified (); 1716 QDateTime dt = finf.lastModified ();
1717 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1717 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1718 //qDebug("file on disk version %s",dt.toString().latin1()); 1718 //qDebug("file on disk version %s",dt.toString().latin1());
1719 if ( dt <= loadedFileVersion ) 1719 if ( dt <= loadedFileVersion )
1720 return true; 1720 return true;
1721 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , 1721 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) ,
1722 i18n("KO/Pi Warning"),i18n("Overwrite"), 1722 i18n("KO/Pi Warning"),i18n("Overwrite"),
1723 i18n("Sync+save")); 1723 i18n("Sync+save"));
1724 1724
1725 if ( km == KMessageBox::Cancel ) 1725 if ( km == KMessageBox::Cancel )
1726 return false; 1726 return false;
1727 if ( km == KMessageBox::Yes ) 1727 if ( km == KMessageBox::Yes )
1728 return true; 1728 return true;
1729 1729
1730 setSyncDevice("deleteaftersync" ); 1730 setSyncDevice("deleteaftersync" );
1731 mSyncManager->mAskForPreferences = true; 1731 mSyncManager->mAskForPreferences = true;
1732 mSyncManager->mSyncAlgoPrefs = 3; 1732 mSyncManager->mSyncAlgoPrefs = 3;
1733 mSyncManager->mWriteBackFile = false; 1733 mSyncManager->mWriteBackFile = false;
1734 mSyncManager->mWriteBackExistingOnly = false; 1734 mSyncManager->mWriteBackExistingOnly = false;
1735 mSyncManager->mShowSyncSummary = false; 1735 mSyncManager->mShowSyncSummary = false;
1736 syncCalendar( fn, 3 ); 1736 syncCalendar( fn, 3 );
1737 Event * e = getLastSyncEvent(); 1737 Event * e = getLastSyncEvent();
1738 mCalendar->deleteEvent ( e ); 1738 mCalendar->deleteEvent ( e );
1739 updateView(); 1739 updateView();
1740 return true; 1740 return true;
1741} 1741}
1742 1742
1743bool CalendarView::saveCalendar( QString filename ) 1743bool CalendarView::saveCalendar( QString filename )
1744{ 1744{
1745 1745
1746 // Store back all unsaved data into calendar object 1746 // Store back all unsaved data into calendar object
1747 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1747 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1748 if ( mViewManager->currentView() ) 1748 if ( mViewManager->currentView() )
1749 mViewManager->currentView()->flushView(); 1749 mViewManager->currentView()->flushView();
1750 1750
1751 1751
1752 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 1752 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
1753 mStorage->setSaveFormat( new ICalFormat() ); 1753 mStorage->setSaveFormat( new ICalFormat() );
1754 mStorage->setFileName( filename ); 1754 mStorage->setFileName( filename );
1755 bool success; 1755 bool success;
1756 success = mStorage->save(); 1756 success = mStorage->save();
1757 if ( !success ) { 1757 if ( !success ) {
1758 return false; 1758 return false;
1759 } 1759 }
1760 if ( filename == MainWindow::defaultFileName() ) { 1760 if ( filename == MainWindow::defaultFileName() ) {
1761 setLoadedFileVersion( lfv ); 1761 setLoadedFileVersion( lfv );
1762 watchSavedFile(); 1762 watchSavedFile();
1763 } 1763 }
1764 return true; 1764 return true;
1765} 1765}
1766 1766
1767void CalendarView::closeCalendar() 1767void CalendarView::closeCalendar()
1768{ 1768{
1769 1769
1770 // child windows no longer valid 1770 // child windows no longer valid
1771 emit closingDown(); 1771 emit closingDown();
1772 1772
1773 mCalendar->close(); 1773 mCalendar->close();
1774 setModified(false); 1774 setModified(false);
1775 updateView(); 1775 updateView();
1776} 1776}
1777 1777
1778void CalendarView::archiveCalendar() 1778void CalendarView::archiveCalendar()
1779{ 1779{
1780 mDialogManager->showArchiveDialog(); 1780 mDialogManager->showArchiveDialog();
1781} 1781}
1782 1782
1783 1783
1784void CalendarView::readSettings() 1784void CalendarView::readSettings()
1785{ 1785{
1786 1786
1787 1787
1788 // mViewManager->showAgendaView(); 1788 // mViewManager->showAgendaView();
1789 QString str; 1789 QString str;
1790 //qDebug("CalendarView::readSettings() "); 1790 //qDebug("CalendarView::readSettings() ");
1791 // read settings from the KConfig, supplying reasonable 1791 // read settings from the KConfig, supplying reasonable
1792 // defaults where none are to be found 1792 // defaults where none are to be found
1793 KConfig *config = KOGlobals::config(); 1793 KConfig *config = KOGlobals::config();
1794#ifndef KORG_NOSPLITTER 1794#ifndef KORG_NOSPLITTER
1795 config->setGroup("KOrganizer Geometry"); 1795 config->setGroup("KOrganizer Geometry");
1796 1796
1797 QValueList<int> sizes = config->readIntListEntry("Separator1"); 1797 QValueList<int> sizes = config->readIntListEntry("Separator1");
1798 if (sizes.count() != 2) { 1798 if (sizes.count() != 2) {
1799 sizes << mDateNavigator->minimumSizeHint().width(); 1799 sizes << mDateNavigator->minimumSizeHint().width();
1800 sizes << 300; 1800 sizes << 300;
1801 } 1801 }
1802 mPanner->setSizes(sizes); 1802 mPanner->setSizes(sizes);
1803 1803
1804 sizes = config->readIntListEntry("Separator2"); 1804 sizes = config->readIntListEntry("Separator2");
1805 if ( ( mResourceView && sizes.count() == 4 ) || 1805 if ( ( mResourceView && sizes.count() == 4 ) ||
1806 ( !mResourceView && sizes.count() == 3 ) ) { 1806 ( !mResourceView && sizes.count() == 3 ) ) {
1807 mLeftSplitter->setSizes(sizes); 1807 mLeftSplitter->setSizes(sizes);
1808 } 1808 }
1809#endif 1809#endif
1810 globalFlagBlockAgenda = 1; 1810 globalFlagBlockAgenda = 1;
1811 mViewManager->showAgendaView(); 1811 mViewManager->showAgendaView();
1812 //mViewManager->readSettings( config ); 1812 //mViewManager->readSettings( config );
1813 mTodoList->restoreLayout(config,QString("Todo Layout")); 1813 mTodoList->restoreLayout(config,QString("Todo Layout"));
1814 readFilterSettings(config); 1814 readFilterSettings(config);
1815 config->setGroup( "Views" ); 1815 config->setGroup( "Views" );
1816 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 1816 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
1817 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 1817 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
1818 else if ( dateCount == 7 ) mNavigator->selectWeek(); 1818 else if ( dateCount == 7 ) mNavigator->selectWeek();
1819 else mNavigator->selectDates( dateCount ); 1819 else mNavigator->selectDates( dateCount );
1820 // mViewManager->readSettings( config ); 1820 // mViewManager->readSettings( config );
1821 updateConfig(); 1821 updateConfig();
1822 globalFlagBlockAgenda = 2; 1822 globalFlagBlockAgenda = 2;
1823 mViewManager->readSettings( config ); 1823 mViewManager->readSettings( config );
1824#ifdef DESKTOP_VERSION 1824#ifdef DESKTOP_VERSION
1825 config->setGroup("WidgetLayout"); 1825 config->setGroup("WidgetLayout");
1826 QStringList list; 1826 QStringList list;
1827 list = config->readListEntry("MainLayout"); 1827 list = config->readListEntry("MainLayout");
1828 int x,y,w,h; 1828 int x,y,w,h;
1829 if ( ! list.isEmpty() ) { 1829 if ( ! list.isEmpty() ) {
1830 x = list[0].toInt(); 1830 x = list[0].toInt();
1831 y = list[1].toInt(); 1831 y = list[1].toInt();
1832 w = list[2].toInt(); 1832 w = list[2].toInt();
1833 h = list[3].toInt(); 1833 h = list[3].toInt();
1834 topLevelWidget()->setGeometry(x,y,w,h); 1834 topLevelWidget()->setGeometry(x,y,w,h);
1835 1835
1836 } else { 1836 } else {
1837 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 1837 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
1838 } 1838 }
1839 list = config->readListEntry("EditEventLayout"); 1839 list = config->readListEntry("EditEventLayout");
1840 if ( ! list.isEmpty() ) { 1840 if ( ! list.isEmpty() ) {
1841 x = list[0].toInt(); 1841 x = list[0].toInt();
1842 y = list[1].toInt(); 1842 y = list[1].toInt();
1843 w = list[2].toInt(); 1843 w = list[2].toInt();
1844 h = list[3].toInt(); 1844 h = list[3].toInt();
1845 mEventEditor->setGeometry(x,y,w,h); 1845 mEventEditor->setGeometry(x,y,w,h);
1846 1846
1847 } 1847 }
1848 list = config->readListEntry("EditTodoLayout"); 1848 list = config->readListEntry("EditTodoLayout");
1849 if ( ! list.isEmpty() ) { 1849 if ( ! list.isEmpty() ) {
1850 x = list[0].toInt(); 1850 x = list[0].toInt();
1851 y = list[1].toInt(); 1851 y = list[1].toInt();
1852 w = list[2].toInt(); 1852 w = list[2].toInt();
1853 h = list[3].toInt(); 1853 h = list[3].toInt();
1854 mTodoEditor->setGeometry(x,y,w,h); 1854 mTodoEditor->setGeometry(x,y,w,h);
1855 1855
1856 } 1856 }
1857 list = config->readListEntry("ViewerLayout"); 1857 list = config->readListEntry("ViewerLayout");
1858 if ( ! list.isEmpty() ) { 1858 if ( ! list.isEmpty() ) {
1859 x = list[0].toInt(); 1859 x = list[0].toInt();
1860 y = list[1].toInt(); 1860 y = list[1].toInt();
1861 w = list[2].toInt(); 1861 w = list[2].toInt();
1862 h = list[3].toInt(); 1862 h = list[3].toInt();
1863 getEventViewerDialog()->setGeometry(x,y,w,h); 1863 getEventViewerDialog()->setGeometry(x,y,w,h);
1864 } 1864 }
1865#endif 1865#endif
1866 1866
1867} 1867}
1868 1868
1869 1869
1870void CalendarView::writeSettings() 1870void CalendarView::writeSettings()
1871{ 1871{
1872 // kdDebug() << "CalendarView::writeSettings" << endl; 1872 // kdDebug() << "CalendarView::writeSettings" << endl;
1873 1873
1874 KConfig *config = KOGlobals::config(); 1874 KConfig *config = KOGlobals::config();
1875 1875
1876#ifndef KORG_NOSPLITTER 1876#ifndef KORG_NOSPLITTER
1877 config->setGroup("KOrganizer Geometry"); 1877 config->setGroup("KOrganizer Geometry");
1878 1878
1879 QValueList<int> list = mPanner->sizes(); 1879 QValueList<int> list = mPanner->sizes();
1880 config->writeEntry("Separator1",list); 1880 config->writeEntry("Separator1",list);
1881 1881
1882 list = mLeftSplitter->sizes(); 1882 list = mLeftSplitter->sizes();
1883 config->writeEntry("Separator2",list); 1883 config->writeEntry("Separator2",list);
1884#endif 1884#endif
1885 1885
1886 mViewManager->writeSettings( config ); 1886 mViewManager->writeSettings( config );
1887 mTodoList->saveLayout(config,QString("Todo Layout")); 1887 mTodoList->saveLayout(config,QString("Todo Layout"));
1888 mDialogManager->writeSettings( config ); 1888 mDialogManager->writeSettings( config );
1889 //KOPrefs::instance()->usrWriteConfig(); 1889 //KOPrefs::instance()->usrWriteConfig();
1890 KOPrefs::instance()->writeConfig(); 1890 KOPrefs::instance()->writeConfig();
1891 1891
1892 writeFilterSettings(config); 1892 writeFilterSettings(config);
1893 1893
1894 config->setGroup( "Views" ); 1894 config->setGroup( "Views" );
1895 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 1895 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
1896 1896
1897#ifdef DESKTOP_VERSION 1897#ifdef DESKTOP_VERSION
1898 config->setGroup("WidgetLayout"); 1898 config->setGroup("WidgetLayout");
1899 QStringList list ;//= config->readListEntry("MainLayout"); 1899 QStringList list ;//= config->readListEntry("MainLayout");
1900 int x,y,w,h; 1900 int x,y,w,h;
1901 QWidget* wid; 1901 QWidget* wid;
1902 wid = topLevelWidget(); 1902 wid = topLevelWidget();
1903 x = wid->geometry().x(); 1903 x = wid->geometry().x();
1904 y = wid->geometry().y(); 1904 y = wid->geometry().y();
1905 w = wid->width(); 1905 w = wid->width();
1906 h = wid->height(); 1906 h = wid->height();
1907 list.clear(); 1907 list.clear();
1908 list << QString::number( x ); 1908 list << QString::number( x );
1909 list << QString::number( y ); 1909 list << QString::number( y );
1910 list << QString::number( w ); 1910 list << QString::number( w );
1911 list << QString::number( h ); 1911 list << QString::number( h );
1912 config->writeEntry("MainLayout",list ); 1912 config->writeEntry("MainLayout",list );
1913 1913
1914 wid = mEventEditor; 1914 wid = mEventEditor;
1915 x = wid->geometry().x(); 1915 x = wid->geometry().x();
1916 y = wid->geometry().y(); 1916 y = wid->geometry().y();
1917 w = wid->width(); 1917 w = wid->width();
1918 h = wid->height(); 1918 h = wid->height();
1919 list.clear(); 1919 list.clear();
1920 list << QString::number( x ); 1920 list << QString::number( x );
1921 list << QString::number( y ); 1921 list << QString::number( y );
1922 list << QString::number( w ); 1922 list << QString::number( w );
1923 list << QString::number( h ); 1923 list << QString::number( h );
1924 config->writeEntry("EditEventLayout",list ); 1924 config->writeEntry("EditEventLayout",list );
1925 1925
1926 wid = mTodoEditor; 1926 wid = mTodoEditor;
1927 x = wid->geometry().x(); 1927 x = wid->geometry().x();
1928 y = wid->geometry().y(); 1928 y = wid->geometry().y();
1929 w = wid->width(); 1929 w = wid->width();
1930 h = wid->height(); 1930 h = wid->height();
1931 list.clear(); 1931 list.clear();
1932 list << QString::number( x ); 1932 list << QString::number( x );
1933 list << QString::number( y ); 1933 list << QString::number( y );
1934 list << QString::number( w ); 1934 list << QString::number( w );
1935 list << QString::number( h ); 1935 list << QString::number( h );
1936 config->writeEntry("EditTodoLayout",list ); 1936 config->writeEntry("EditTodoLayout",list );
1937 wid = getEventViewerDialog(); 1937 wid = getEventViewerDialog();
1938 x = wid->geometry().x(); 1938 x = wid->geometry().x();
1939 y = wid->geometry().y(); 1939 y = wid->geometry().y();
1940 w = wid->width(); 1940 w = wid->width();
1941 h = wid->height(); 1941 h = wid->height();
1942 list.clear(); 1942 list.clear();
1943 list << QString::number( x ); 1943 list << QString::number( x );
1944 list << QString::number( y ); 1944 list << QString::number( y );
1945 list << QString::number( w ); 1945 list << QString::number( w );
1946 list << QString::number( h ); 1946 list << QString::number( h );
1947 config->writeEntry("ViewerLayout",list ); 1947 config->writeEntry("ViewerLayout",list );
1948 wid = mDialogManager->getSearchDialog(); 1948 wid = mDialogManager->getSearchDialog();
1949 if ( wid ) { 1949 if ( wid ) {
1950 x = wid->geometry().x(); 1950 x = wid->geometry().x();
1951 y = wid->geometry().y(); 1951 y = wid->geometry().y();
1952 w = wid->width(); 1952 w = wid->width();
1953 h = wid->height(); 1953 h = wid->height();
1954 list.clear(); 1954 list.clear();
1955 list << QString::number( x ); 1955 list << QString::number( x );
1956 list << QString::number( y ); 1956 list << QString::number( y );
1957 list << QString::number( w ); 1957 list << QString::number( w );
1958 list << QString::number( h ); 1958 list << QString::number( h );
1959 config->writeEntry("SearchLayout",list ); 1959 config->writeEntry("SearchLayout",list );
1960 } 1960 }
1961#endif 1961#endif
1962 1962
1963 1963
1964 config->sync(); 1964 config->sync();
1965} 1965}
1966 1966
1967void CalendarView::readFilterSettings(KConfig *config) 1967void CalendarView::readFilterSettings(KConfig *config)
1968{ 1968{
1969 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 1969 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
1970 1970
1971 mFilters.clear(); 1971 mFilters.clear();
1972 1972
1973 config->setGroup("General"); 1973 config->setGroup("General");
1974 QStringList filterList = config->readListEntry("CalendarFilters"); 1974 QStringList filterList = config->readListEntry("CalendarFilters");
1975 1975
1976 QStringList::ConstIterator it = filterList.begin(); 1976 QStringList::ConstIterator it = filterList.begin();
1977 QStringList::ConstIterator end = filterList.end(); 1977 QStringList::ConstIterator end = filterList.end();
1978 while(it != end) { 1978 while(it != end) {
1979 // kdDebug() << " filter: " << (*it) << endl; 1979 // kdDebug() << " filter: " << (*it) << endl;
1980 1980
1981 CalFilter *filter; 1981 CalFilter *filter;
1982 filter = new CalFilter(*it); 1982 filter = new CalFilter(*it);
1983 config->setGroup("Filter_" + (*it)); 1983 config->setGroup("Filter_" + (*it));
1984 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 1984 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
1985 filter->setCriteria(config->readNumEntry("Criteria",0)); 1985 filter->setCriteria(config->readNumEntry("Criteria",0));
1986 filter->setCategoryList(config->readListEntry("CategoryList")); 1986 filter->setCategoryList(config->readListEntry("CategoryList"));
1987 mFilters.append(filter); 1987 mFilters.append(filter);
1988 1988
1989 ++it; 1989 ++it;
1990 } 1990 }
1991 1991
1992 if (mFilters.count() == 0) { 1992 if (mFilters.count() == 0) {
1993 CalFilter *filter = new CalFilter(i18n("Default")); 1993 CalFilter *filter = new CalFilter(i18n("Default"));
1994 mFilters.append(filter); 1994 mFilters.append(filter);
1995 } 1995 }
1996 mFilterView->updateFilters(); 1996 mFilterView->updateFilters();
1997 config->setGroup("FilterView"); 1997 config->setGroup("FilterView");
1998 1998
1999 mFilterView->blockSignals(true); 1999 mFilterView->blockSignals(true);
2000 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 2000 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
2001 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 2001 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
2002 mFilterView->blockSignals(false); 2002 mFilterView->blockSignals(false);
2003 // We do it manually to avoid it being done twice by the above calls 2003 // We do it manually to avoid it being done twice by the above calls
2004 updateFilter(); 2004 updateFilter();
2005} 2005}
2006 2006
2007void CalendarView::writeFilterSettings(KConfig *config) 2007void CalendarView::writeFilterSettings(KConfig *config)
2008{ 2008{
2009 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 2009 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
2010 2010
2011 QStringList filterList; 2011 QStringList filterList;
2012 2012
2013 CalFilter *filter = mFilters.first(); 2013 CalFilter *filter = mFilters.first();
2014 while(filter) { 2014 while(filter) {
2015 // kdDebug() << " fn: " << filter->name() << endl; 2015 // kdDebug() << " fn: " << filter->name() << endl;
2016 filterList << filter->name(); 2016 filterList << filter->name();
2017 config->setGroup("Filter_" + filter->name()); 2017 config->setGroup("Filter_" + filter->name());
2018 config->writeEntry("Criteria",filter->criteria()); 2018 config->writeEntry("Criteria",filter->criteria());
2019 config->writeEntry("CategoryList",filter->categoryList()); 2019 config->writeEntry("CategoryList",filter->categoryList());
2020 filter = mFilters.next(); 2020 filter = mFilters.next();
2021 } 2021 }
2022 config->setGroup("General"); 2022 config->setGroup("General");
2023 config->writeEntry("CalendarFilters",filterList); 2023 config->writeEntry("CalendarFilters",filterList);
2024 2024
2025 config->setGroup("FilterView"); 2025 config->setGroup("FilterView");
2026 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 2026 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
2027 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 2027 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
2028} 2028}
2029 2029
2030 2030
2031void CalendarView::goToday() 2031void CalendarView::goToday()
2032{ 2032{
2033 if ( mViewManager->currentView()->isMonthView() ) 2033 if ( mViewManager->currentView()->isMonthView() )
2034 mNavigator->selectTodayMonth(); 2034 mNavigator->selectTodayMonth();
2035 else 2035 else
2036 mNavigator->selectToday(); 2036 mNavigator->selectToday();
2037} 2037}
2038 2038
2039void CalendarView::goNext() 2039void CalendarView::goNext()
2040{ 2040{
2041 mNavigator->selectNext(); 2041 mNavigator->selectNext();
2042} 2042}
2043 2043
2044void CalendarView::goPrevious() 2044void CalendarView::goPrevious()
2045{ 2045{
2046 mNavigator->selectPrevious(); 2046 mNavigator->selectPrevious();
2047} 2047}
2048void CalendarView::goNextMonth() 2048void CalendarView::goNextMonth()
2049{ 2049{
2050 mNavigator->selectNextMonth(); 2050 mNavigator->selectNextMonth();
2051} 2051}
2052 2052
2053void CalendarView::goPreviousMonth() 2053void CalendarView::goPreviousMonth()
2054{ 2054{
2055 mNavigator->selectPreviousMonth(); 2055 mNavigator->selectPreviousMonth();
2056} 2056}
2057void CalendarView::writeLocale() 2057void CalendarView::writeLocale()
2058{ 2058{
2059 //KPimGlobalPrefs::instance()->setGlobalConfig(); 2059 //KPimGlobalPrefs::instance()->setGlobalConfig();
2060#if 0 2060#if 0
2061 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); 2061 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime );
2062 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); 2062 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday );
2063 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); 2063 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate );
2064 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); 2064 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage );
2065 QString dummy = KOPrefs::instance()->mUserDateFormatLong; 2065 QString dummy = KOPrefs::instance()->mUserDateFormatLong;
2066 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 2066 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
2067 dummy = KOPrefs::instance()->mUserDateFormatShort; 2067 dummy = KOPrefs::instance()->mUserDateFormatShort;
2068 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 2068 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
2069 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, 2069 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving,
2070 KOPrefs::instance()->mDaylightsavingStart, 2070 KOPrefs::instance()->mDaylightsavingStart,
2071 KOPrefs::instance()->mDaylightsavingEnd ); 2071 KOPrefs::instance()->mDaylightsavingEnd );
2072 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); 2072 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId );
2073#endif 2073#endif
2074} 2074}
2075void CalendarView::updateConfig() 2075void CalendarView::updateConfig()
2076{ 2076{
2077 writeLocale(); 2077 writeLocale();
2078 if ( KOPrefs::instance()->mUseAppColors ) 2078 if ( KOPrefs::instance()->mUseAppColors )
2079 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 2079 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
2080 emit configChanged(); 2080 emit configChanged();
2081 mTodoList->updateConfig(); 2081 mTodoList->updateConfig();
2082 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 2082 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
2083 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2083 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2084 // To make the "fill window" configurations work 2084 // To make the "fill window" configurations work
2085 //mViewManager->raiseCurrentView(); 2085 //mViewManager->raiseCurrentView();
2086} 2086}
2087 2087
2088 2088
2089void CalendarView::eventChanged(Event *event) 2089void CalendarView::eventChanged(Event *event)
2090{ 2090{
2091 changeEventDisplay(event,KOGlobals::EVENTEDITED); 2091 changeEventDisplay(event,KOGlobals::EVENTEDITED);
2092 //updateUnmanagedViews(); 2092 //updateUnmanagedViews();
2093} 2093}
2094 2094
2095void CalendarView::eventAdded(Event *event) 2095void CalendarView::eventAdded(Event *event)
2096{ 2096{
2097 changeEventDisplay(event,KOGlobals::EVENTADDED); 2097 changeEventDisplay(event,KOGlobals::EVENTADDED);
2098} 2098}
2099 2099
2100void CalendarView::eventToBeDeleted(Event *) 2100void CalendarView::eventToBeDeleted(Event *)
2101{ 2101{
2102 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 2102 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
2103} 2103}
2104 2104
2105void CalendarView::eventDeleted() 2105void CalendarView::eventDeleted()
2106{ 2106{
2107 changeEventDisplay(0,KOGlobals::EVENTDELETED); 2107 changeEventDisplay(0,KOGlobals::EVENTDELETED);
2108} 2108}
2109void CalendarView::changeTodoDisplay(Todo *which, int action) 2109void CalendarView::changeTodoDisplay(Todo *which, int action)
2110{ 2110{
2111 changeIncidenceDisplay((Incidence *)which, action); 2111 changeIncidenceDisplay((Incidence *)which, action);
2112 mDateNavigator->updateView(); //LR 2112 mDateNavigator->updateView(); //LR
2113 //mDialogManager->updateSearchDialog(); 2113 //mDialogManager->updateSearchDialog();
2114 2114
2115 if (which) { 2115 if (which) {
2116 mViewManager->updateWNview(); 2116 mViewManager->updateWNview();
2117 //mTodoList->updateView(); 2117 //mTodoList->updateView();
2118 } 2118 }
2119 2119
2120} 2120}
2121 2121
2122void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 2122void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
2123{ 2123{
2124 updateUnmanagedViews(); 2124 updateUnmanagedViews();
2125 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 2125 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
2126 if ( action == KOGlobals::EVENTDELETED ) { //delete 2126 if ( action == KOGlobals::EVENTDELETED ) { //delete
2127 mCalendar->checkAlarmForIncidence( 0, true ); 2127 mCalendar->checkAlarmForIncidence( 0, true );
2128 if ( mEventViewerDialog ) 2128 if ( mEventViewerDialog )
2129 mEventViewerDialog->hide(); 2129 mEventViewerDialog->hide();
2130 } 2130 }
2131 else 2131 else
2132 mCalendar->checkAlarmForIncidence( which , false ); 2132 mCalendar->checkAlarmForIncidence( which , false );
2133} 2133}
2134 2134
2135// most of the changeEventDisplays() right now just call the view's 2135// most of the changeEventDisplays() right now just call the view's
2136// total update mode, but they SHOULD be recoded to be more refresh-efficient. 2136// total update mode, but they SHOULD be recoded to be more refresh-efficient.
2137void CalendarView::changeEventDisplay(Event *which, int action) 2137void CalendarView::changeEventDisplay(Event *which, int action)
2138{ 2138{
2139 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 2139 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
2140 changeIncidenceDisplay((Incidence *)which, action); 2140 changeIncidenceDisplay((Incidence *)which, action);
2141 mDateNavigator->updateView(); 2141 mDateNavigator->updateView();
2142 //mDialogManager->updateSearchDialog(); 2142 //mDialogManager->updateSearchDialog();
2143 2143
2144 if (which) { 2144 if (which) {
2145 // If there is an event view visible update the display 2145 // If there is an event view visible update the display
2146 mViewManager->currentView()->changeEventDisplay(which,action); 2146 mViewManager->currentView()->changeEventDisplay(which,action);
2147 // TODO: check, if update needed 2147 // TODO: check, if update needed
2148 // if (which->getTodoStatus()) { 2148 // if (which->getTodoStatus()) {
2149 mTodoList->updateView(); 2149 mTodoList->updateView();
2150 // } 2150 // }
2151 } else { 2151 } else {
2152 mViewManager->currentView()->updateView(); 2152 mViewManager->currentView()->updateView();
2153 } 2153 }
2154} 2154}
2155 2155
2156 2156
2157void CalendarView::updateTodoViews() 2157void CalendarView::updateTodoViews()
2158{ 2158{
2159 2159
2160 mTodoList->updateView(); 2160 mTodoList->updateView();
2161 mViewManager->currentView()->updateView(); 2161 mViewManager->currentView()->updateView();
2162 2162
2163} 2163}
2164 2164
2165 2165
2166void CalendarView::updateView(const QDate &start, const QDate &end) 2166void CalendarView::updateView(const QDate &start, const QDate &end)
2167{ 2167{
2168 mTodoList->updateView(); 2168 mTodoList->updateView();
2169 mViewManager->updateView(start, end); 2169 mViewManager->updateView(start, end);
2170 //mDateNavigator->updateView(); 2170 //mDateNavigator->updateView();
2171} 2171}
2172 2172
2173void CalendarView::updateView() 2173void CalendarView::updateView()
2174{ 2174{
2175 DateList tmpList = mNavigator->selectedDates(); 2175 DateList tmpList = mNavigator->selectedDates();
2176 2176
2177 if ( KOPrefs::instance()->mHideNonStartedTodos ) 2177 if ( KOPrefs::instance()->mHideNonStartedTodos )
2178 mTodoList->updateView(); 2178 mTodoList->updateView();
2179 // We assume that the navigator only selects consecutive days. 2179 // We assume that the navigator only selects consecutive days.
2180 updateView( tmpList.first(), tmpList.last() ); 2180 updateView( tmpList.first(), tmpList.last() );
2181} 2181}
2182 2182
2183void CalendarView::updateUnmanagedViews() 2183void CalendarView::updateUnmanagedViews()
2184{ 2184{
2185 mDateNavigator->updateDayMatrix(); 2185 mDateNavigator->updateDayMatrix();
2186} 2186}
2187 2187
2188int CalendarView::msgItemDelete() 2188int CalendarView::msgItemDelete(const QString name)
2189{ 2189{
2190 return KMessageBox::warningContinueCancel(this, 2190 return KMessageBox::warningContinueCancel(this,name +"\n\n"+
2191 i18n("This item will be\npermanently deleted."), 2191 i18n("This item will be\npermanently deleted."),
2192 i18n("KO/Pi Confirmation"),i18n("Delete")); 2192 i18n("KO/Pi Confirmation"),i18n("Delete"));
2193} 2193}
2194 2194
2195 2195
2196void CalendarView::edit_cut() 2196void CalendarView::edit_cut()
2197{ 2197{
2198 Event *anEvent=0; 2198 Event *anEvent=0;
2199 2199
2200 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2200 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2201 2201
2202 if (mViewManager->currentView()->isEventView()) { 2202 if (mViewManager->currentView()->isEventView()) {
2203 if ( incidence && incidence->type() == "Event" ) { 2203 if ( incidence && incidence->type() == "Event" ) {
2204 anEvent = static_cast<Event *>(incidence); 2204 anEvent = static_cast<Event *>(incidence);
2205 } 2205 }
2206 } 2206 }
2207 2207
2208 if (!anEvent) { 2208 if (!anEvent) {
2209 KNotifyClient::beep(); 2209 KNotifyClient::beep();
2210 return; 2210 return;
2211 } 2211 }
2212 DndFactory factory( mCalendar ); 2212 DndFactory factory( mCalendar );
2213 factory.cutEvent(anEvent); 2213 factory.cutEvent(anEvent);
2214 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2214 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2215} 2215}
2216 2216
2217void CalendarView::edit_copy() 2217void CalendarView::edit_copy()
2218{ 2218{
2219 Event *anEvent=0; 2219 Event *anEvent=0;
2220 2220
2221 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2221 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2222 2222
2223 if (mViewManager->currentView()->isEventView()) { 2223 if (mViewManager->currentView()->isEventView()) {
2224 if ( incidence && incidence->type() == "Event" ) { 2224 if ( incidence && incidence->type() == "Event" ) {
2225 anEvent = static_cast<Event *>(incidence); 2225 anEvent = static_cast<Event *>(incidence);
2226 } 2226 }
2227 } 2227 }
2228 2228
2229 if (!anEvent) { 2229 if (!anEvent) {
2230 KNotifyClient::beep(); 2230 KNotifyClient::beep();
2231 return; 2231 return;
2232 } 2232 }
2233 DndFactory factory( mCalendar ); 2233 DndFactory factory( mCalendar );
2234 factory.copyEvent(anEvent); 2234 factory.copyEvent(anEvent);
2235} 2235}
2236 2236
2237void CalendarView::edit_paste() 2237void CalendarView::edit_paste()
2238{ 2238{
2239 QDate date = mNavigator->selectedDates().first(); 2239 QDate date = mNavigator->selectedDates().first();
2240 2240
2241 DndFactory factory( mCalendar ); 2241 DndFactory factory( mCalendar );
2242 Event *pastedEvent = factory.pasteEvent( date ); 2242 Event *pastedEvent = factory.pasteEvent( date );
2243 2243
2244 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 2244 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
2245} 2245}
2246 2246
2247void CalendarView::edit_options() 2247void CalendarView::edit_options()
2248{ 2248{
2249 mDialogManager->showOptionsDialog(); 2249 mDialogManager->showOptionsDialog();
2250 //writeSettings(); 2250 //writeSettings();
2251} 2251}
2252 2252
2253 2253
2254void CalendarView::slotSelectPickerDate( QDate d) 2254void CalendarView::slotSelectPickerDate( QDate d)
2255{ 2255{
2256 mDateFrame->hide(); 2256 mDateFrame->hide();
2257 if ( mDatePickerMode == 1 ) { 2257 if ( mDatePickerMode == 1 ) {
2258 mNavigator->slotDaySelect( d ); 2258 mNavigator->slotDaySelect( d );
2259 } else if ( mDatePickerMode == 2 ) { 2259 } else if ( mDatePickerMode == 2 ) {
2260 if ( mMoveIncidence->type() == "Todo" ) { 2260 if ( mMoveIncidence->type() == "Todo" ) {
2261 Todo * to = (Todo *) mMoveIncidence; 2261 Todo * to = (Todo *) mMoveIncidence;
2262 QTime tim; 2262 QTime tim;
2263 if ( to->hasDueDate() ) 2263 if ( to->hasDueDate() )
2264 tim = to->dtDue().time(); 2264 tim = to->dtDue().time();
2265 else { 2265 else {
2266 tim = QTime ( 0,0,0 ); 2266 tim = QTime ( 0,0,0 );
2267 to->setFloats( true ); 2267 to->setFloats( true );
2268 to->setHasDueDate( true ); 2268 to->setHasDueDate( true );
2269 } 2269 }
2270 QDateTime dt ( d,tim ); 2270 QDateTime dt ( d,tim );
2271 to->setDtDue( dt ); 2271 to->setDtDue( dt );
2272 todoChanged( to ); 2272 todoChanged( to );
2273 } else { 2273 } else {
2274 if ( mMoveIncidence->doesRecur() ) { 2274 if ( mMoveIncidence->doesRecur() ) {
2275#if 0 2275#if 0
2276 // PENDING implement this 2276 // PENDING implement this
2277 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); 2277 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate );
2278 mCalendar()->addIncidence( newInc ); 2278 mCalendar()->addIncidence( newInc );
2279 if ( mMoveIncidence->type() == "Todo" ) 2279 if ( mMoveIncidence->type() == "Todo" )
2280 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); 2280 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED );
2281 else 2281 else
2282 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); 2282 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED);
2283 mMoveIncidence = newInc; 2283 mMoveIncidence = newInc;
2284 2284
2285#endif 2285#endif
2286 } 2286 }
2287 QTime tim = mMoveIncidence->dtStart().time(); 2287 QTime tim = mMoveIncidence->dtStart().time();
2288 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2288 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2289 QDateTime dt ( d,tim ); 2289 QDateTime dt ( d,tim );
2290 mMoveIncidence->setDtStart( dt ); 2290 mMoveIncidence->setDtStart( dt );
2291 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2291 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2292 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2292 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2293 } 2293 }
2294 2294
2295 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2295 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2296 } 2296 }
2297} 2297}
2298 2298
2299void CalendarView::removeCategories() 2299void CalendarView::removeCategories()
2300{ 2300{
2301 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2301 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2302 QStringList catList = KOPrefs::instance()->mCustomCategories; 2302 QStringList catList = KOPrefs::instance()->mCustomCategories;
2303 QStringList catIncList; 2303 QStringList catIncList;
2304 QStringList newCatList; 2304 QStringList newCatList;
2305 Incidence* inc = incList.first(); 2305 Incidence* inc = incList.first();
2306 int i; 2306 int i;
2307 int count = 0; 2307 int count = 0;
2308 while ( inc ) { 2308 while ( inc ) {
2309 newCatList.clear(); 2309 newCatList.clear();
2310 catIncList = inc->categories() ; 2310 catIncList = inc->categories() ;
2311 for( i = 0; i< catIncList.count(); ++i ) { 2311 for( i = 0; i< catIncList.count(); ++i ) {
2312 if ( catList.contains (catIncList[i])) 2312 if ( catList.contains (catIncList[i]))
2313 newCatList.append( catIncList[i] ); 2313 newCatList.append( catIncList[i] );
2314 } 2314 }
2315 newCatList.sort(); 2315 newCatList.sort();
2316 inc->setCategories( newCatList.join(",") ); 2316 inc->setCategories( newCatList.join(",") );
2317 inc = incList.next(); 2317 inc = incList.next();
2318 } 2318 }
2319} 2319}
2320 2320
2321int CalendarView::addCategories() 2321int CalendarView::addCategories()
2322{ 2322{
2323 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2323 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2324 QStringList catList = KOPrefs::instance()->mCustomCategories; 2324 QStringList catList = KOPrefs::instance()->mCustomCategories;
2325 QStringList catIncList; 2325 QStringList catIncList;
2326 Incidence* inc = incList.first(); 2326 Incidence* inc = incList.first();
2327 int i; 2327 int i;
2328 int count = 0; 2328 int count = 0;
2329 while ( inc ) { 2329 while ( inc ) {
2330 catIncList = inc->categories() ; 2330 catIncList = inc->categories() ;
2331 for( i = 0; i< catIncList.count(); ++i ) { 2331 for( i = 0; i< catIncList.count(); ++i ) {
2332 if ( !catList.contains (catIncList[i])) { 2332 if ( !catList.contains (catIncList[i])) {
2333 catList.append( catIncList[i] ); 2333 catList.append( catIncList[i] );
2334 //qDebug("add cat %s ", catIncList[i].latin1()); 2334 //qDebug("add cat %s ", catIncList[i].latin1());
2335 ++count; 2335 ++count;
2336 } 2336 }
2337 } 2337 }
2338 inc = incList.next(); 2338 inc = incList.next();
2339 } 2339 }
2340 catList.sort(); 2340 catList.sort();
2341 KOPrefs::instance()->mCustomCategories = catList; 2341 KOPrefs::instance()->mCustomCategories = catList;
2342 return count; 2342 return count;
2343} 2343}
2344 2344
2345void CalendarView::manageCategories() 2345void CalendarView::manageCategories()
2346{ 2346{
2347 KOCatPrefs* cp = new KOCatPrefs(); 2347 KOCatPrefs* cp = new KOCatPrefs();
2348 cp->show(); 2348 cp->show();
2349 int w =cp->sizeHint().width() ; 2349 int w =cp->sizeHint().width() ;
2350 int h = cp->sizeHint().height() ; 2350 int h = cp->sizeHint().height() ;
2351 int dw = QApplication::desktop()->width(); 2351 int dw = QApplication::desktop()->width();
2352 int dh = QApplication::desktop()->height(); 2352 int dh = QApplication::desktop()->height();
2353 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2353 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2354 if ( !cp->exec() ) { 2354 if ( !cp->exec() ) {
2355 delete cp; 2355 delete cp;
2356 return; 2356 return;
2357 } 2357 }
2358 int count = 0; 2358 int count = 0;
2359 if ( cp->addCat() ) { 2359 if ( cp->addCat() ) {
2360 count = addCategories(); 2360 count = addCategories();
2361 if ( count ) { 2361 if ( count ) {
2362 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2362 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2363 writeSettings(); 2363 writeSettings();
2364 } else 2364 } else
2365 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); 2365 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! "));
2366 } else { 2366 } else {
2367 removeCategories(); 2367 removeCategories();
2368 updateView(); 2368 updateView();
2369 } 2369 }
2370 delete cp; 2370 delete cp;
2371} 2371}
2372 2372
2373void CalendarView::beamIncidence(Incidence * Inc) 2373void CalendarView::beamIncidence(Incidence * Inc)
2374{ 2374{
2375 QPtrList<Incidence> delSel ; 2375 QPtrList<Incidence> delSel ;
2376 delSel.append(Inc); 2376 delSel.append(Inc);
2377 beamIncidenceList( delSel ); 2377 beamIncidenceList( delSel );
2378} 2378}
2379void CalendarView::beamCalendar() 2379void CalendarView::beamCalendar()
2380{ 2380{
2381 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2381 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2382 //qDebug("beamCalendar() "); 2382 //qDebug("beamCalendar() ");
2383 beamIncidenceList( delSel ); 2383 beamIncidenceList( delSel );
2384} 2384}
2385void CalendarView::beamFilteredCalendar() 2385void CalendarView::beamFilteredCalendar()
2386{ 2386{
2387 QPtrList<Incidence> delSel = mCalendar->incidences(); 2387 QPtrList<Incidence> delSel = mCalendar->incidences();
2388 //qDebug("beamFilteredCalendar() "); 2388 //qDebug("beamFilteredCalendar() ");
2389 beamIncidenceList( delSel ); 2389 beamIncidenceList( delSel );
2390} 2390}
2391void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2391void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2392{ 2392{
2393 if ( beamDialog->exec () == QDialog::Rejected ) 2393 if ( beamDialog->exec () == QDialog::Rejected )
2394 return; 2394 return;
2395#ifdef DESKTOP_VERSION 2395#ifdef DESKTOP_VERSION
2396 QString fn = locateLocal( "tmp", "kopibeamfile" ); 2396 QString fn = locateLocal( "tmp", "kopibeamfile" );
2397#else 2397#else
2398 QString fn = "/tmp/kopibeamfile"; 2398 QString fn = "/tmp/kopibeamfile";
2399#endif 2399#endif
2400 QString mes; 2400 QString mes;
2401 bool createbup = true; 2401 bool createbup = true;
2402 if ( createbup ) { 2402 if ( createbup ) {
2403 QString description = "\n"; 2403 QString description = "\n";
2404 CalendarLocal* cal = new CalendarLocal(); 2404 CalendarLocal* cal = new CalendarLocal();
2405 if ( beamDialog->beamLocal() ) 2405 if ( beamDialog->beamLocal() )
2406 cal->setLocalTime(); 2406 cal->setLocalTime();
2407 else 2407 else
2408 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2408 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2409 Incidence *incidence = delSel.first(); 2409 Incidence *incidence = delSel.first();
2410 bool addText = false; 2410 bool addText = false;
2411 if ( delSel.count() < 10 ) 2411 if ( delSel.count() < 10 )
2412 addText = true; 2412 addText = true;
2413 else { 2413 else {
2414 description.sprintf(i18n(" %d items?"),delSel.count() ); 2414 description.sprintf(i18n(" %d items?"),delSel.count() );
2415 } 2415 }
2416 while ( incidence ) { 2416 while ( incidence ) {
2417 Incidence *in = incidence->clone(); 2417 Incidence *in = incidence->clone();
2418 if ( ! in->summary().isEmpty() ) { 2418 if ( ! in->summary().isEmpty() ) {
2419 in->setDescription(""); 2419 in->setDescription("");
2420 } else { 2420 } else {
2421 in->setSummary( in->description().left(20)); 2421 in->setSummary( in->description().left(20));
2422 in->setDescription(""); 2422 in->setDescription("");
2423 } 2423 }
2424 if ( addText ) 2424 if ( addText )
2425 description += in->summary() + "\n"; 2425 description += in->summary() + "\n";
2426 cal->addIncidence( in ); 2426 cal->addIncidence( in );
2427 incidence = delSel.next(); 2427 incidence = delSel.next();
2428 } 2428 }
2429 if ( beamDialog->beamVcal() ) { 2429 if ( beamDialog->beamVcal() ) {
2430 fn += ".vcs"; 2430 fn += ".vcs";
2431 FileStorage storage( cal, fn, new VCalFormat ); 2431 FileStorage storage( cal, fn, new VCalFormat );
2432 storage.save(); 2432 storage.save();
2433 } else { 2433 } else {
2434 fn += ".ics"; 2434 fn += ".ics";
2435 FileStorage storage( cal, fn, new ICalFormat( ) ); 2435 FileStorage storage( cal, fn, new ICalFormat( ) );
2436 storage.save(); 2436 storage.save();
2437 } 2437 }
2438 delete cal; 2438 delete cal;
2439 mes = i18n("KO/Pi: Ready for beaming"); 2439 mes = i18n("KO/Pi: Ready for beaming");
2440 topLevelWidget()->setCaption(mes); 2440 topLevelWidget()->setCaption(mes);
2441 KApplication::convert2latin1( fn ); 2441 KApplication::convert2latin1( fn );
2442#ifndef DESKTOP_VERSION 2442#ifndef DESKTOP_VERSION
2443 Ir *ir = new Ir( this ); 2443 Ir *ir = new Ir( this );
2444 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 2444 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2445 ir->send( fn, description, "text/x-vCalendar" ); 2445 ir->send( fn, description, "text/x-vCalendar" );
2446#endif 2446#endif
2447 } 2447 }
2448} 2448}
2449void CalendarView::beamDone( Ir *ir ) 2449void CalendarView::beamDone( Ir *ir )
2450{ 2450{
2451#ifndef DESKTOP_VERSION 2451#ifndef DESKTOP_VERSION
2452 delete ir; 2452 delete ir;
2453#endif 2453#endif
2454 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); 2454 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") );
2455 topLevelWidget()->raise(); 2455 topLevelWidget()->raise();
2456} 2456}
2457 2457
2458void CalendarView::moveIncidence(Incidence * inc ) 2458void CalendarView::moveIncidence(Incidence * inc )
2459{ 2459{
2460 if ( !inc ) return; 2460 if ( !inc ) return;
2461 // qDebug("showDatePickerForIncidence( ) "); 2461 // qDebug("showDatePickerForIncidence( ) ");
2462 if ( mDateFrame->isVisible() ) 2462 if ( mDateFrame->isVisible() )
2463 mDateFrame->hide(); 2463 mDateFrame->hide();
2464 else { 2464 else {
2465 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; 2465 int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ;
2466 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; 2466 int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ;
2467 int dw = QApplication::desktop()->width(); 2467 int dw = QApplication::desktop()->width();
2468 int dh = QApplication::desktop()->height(); 2468 int dh = QApplication::desktop()->height();
2469 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2469 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2470 mDateFrame->show(); 2470 mDateFrame->show();
2471 } 2471 }
2472 mDatePickerMode = 2; 2472 mDatePickerMode = 2;
2473 mMoveIncidence = inc ; 2473 mMoveIncidence = inc ;
2474 QDate da; 2474 QDate da;
2475 if ( mMoveIncidence->type() == "Todo" ) { 2475 if ( mMoveIncidence->type() == "Todo" ) {
2476 Todo * to = (Todo *) mMoveIncidence; 2476 Todo * to = (Todo *) mMoveIncidence;
2477 if ( to->hasDueDate() ) 2477 if ( to->hasDueDate() )
2478 da = to->dtDue().date(); 2478 da = to->dtDue().date();
2479 else 2479 else
2480 da = QDate::currentDate(); 2480 da = QDate::currentDate();
2481 } else { 2481 } else {
2482 da = mMoveIncidence->dtStart().date(); 2482 da = mMoveIncidence->dtStart().date();
2483 } 2483 }
2484 //PENDING set date for recurring incidence to date of recurrence 2484 //PENDING set date for recurring incidence to date of recurrence
2485 //mMoveIncidenceOldDate; 2485 //mMoveIncidenceOldDate;
2486 mDatePicker->setDate( da ); 2486 mDatePicker->setDate( da );
2487} 2487}
2488void CalendarView::showDatePicker( ) 2488void CalendarView::showDatePicker( )
2489{ 2489{
2490 //qDebug("CalendarView::showDatePicker( ) "); 2490 //qDebug("CalendarView::showDatePicker( ) ");
2491 if ( mDateFrame->isVisible() ) 2491 if ( mDateFrame->isVisible() )
2492 mDateFrame->hide(); 2492 mDateFrame->hide();
2493 else { 2493 else {
2494 int w =mDatePicker->sizeHint().width() ; 2494 int w =mDatePicker->sizeHint().width() ;
2495 int h = mDatePicker->sizeHint().height() ; 2495 int h = mDatePicker->sizeHint().height() ;
2496 int dw = QApplication::desktop()->width(); 2496 int dw = QApplication::desktop()->width();
2497 int dh = QApplication::desktop()->height(); 2497 int dh = QApplication::desktop()->height();
2498 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2498 mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2499 mDateFrame->show(); 2499 mDateFrame->show();
2500 } 2500 }
2501 mDatePickerMode = 1; 2501 mDatePickerMode = 1;
2502 mDatePicker->setDate( mNavigator->selectedDates().first() ); 2502 mDatePicker->setDate( mNavigator->selectedDates().first() );
2503} 2503}
2504 2504
2505void CalendarView::showEventEditor() 2505void CalendarView::showEventEditor()
2506{ 2506{
2507#ifdef DESKTOP_VERSION 2507#ifdef DESKTOP_VERSION
2508 mEventEditor->show(); 2508 mEventEditor->show();
2509#else 2509#else
2510 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { 2510 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) {
2511 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2511 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2512 qDebug("CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); 2512 qDebug("CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() );
2513 delete mEventEditor; 2513 delete mEventEditor;
2514 mEventEditor = mDialogManager->getEventEditor(); 2514 mEventEditor = mDialogManager->getEventEditor();
2515 } 2515 }
2516 mEventEditor->showMaximized(); 2516 mEventEditor->showMaximized();
2517 topLevelWidget()->setCaption( i18n("") ); 2517 topLevelWidget()->setCaption( i18n("") );
2518#endif 2518#endif
2519} 2519}
2520void CalendarView::showTodoEditor() 2520void CalendarView::showTodoEditor()
2521{ 2521{
2522#ifdef DESKTOP_VERSION 2522#ifdef DESKTOP_VERSION
2523 mTodoEditor->show(); 2523 mTodoEditor->show();
2524#else 2524#else
2525 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { 2525 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) {
2526 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2526 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2527 qDebug("CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); 2527 qDebug("CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() );
2528 delete mTodoEditor; 2528 delete mTodoEditor;
2529 mTodoEditor = mDialogManager->getTodoEditor(); 2529 mTodoEditor = mDialogManager->getTodoEditor();
2530 } 2530 }
2531 mTodoEditor->showMaximized(); 2531 mTodoEditor->showMaximized();
2532 topLevelWidget()->setCaption( i18n("") ); 2532 topLevelWidget()->setCaption( i18n("") );
2533#endif 2533#endif
2534} 2534}
2535 2535
2536void CalendarView::cloneIncidence() 2536void CalendarView::cloneIncidence()
2537{ 2537{
2538 Incidence *incidence = currentSelection(); 2538 Incidence *incidence = currentSelection();
2539 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2539 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2540 if ( incidence ) { 2540 if ( incidence ) {
2541 cloneIncidence(incidence); 2541 cloneIncidence(incidence);
2542 } 2542 }
2543} 2543}
2544void CalendarView::moveIncidence() 2544void CalendarView::moveIncidence()
2545{ 2545{
2546 Incidence *incidence = currentSelection(); 2546 Incidence *incidence = currentSelection();
2547 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2547 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2548 if ( incidence ) { 2548 if ( incidence ) {
2549 moveIncidence(incidence); 2549 moveIncidence(incidence);
2550 } 2550 }
2551} 2551}
2552void CalendarView::beamIncidence() 2552void CalendarView::beamIncidence()
2553{ 2553{
2554 Incidence *incidence = currentSelection(); 2554 Incidence *incidence = currentSelection();
2555 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2555 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2556 if ( incidence ) { 2556 if ( incidence ) {
2557 beamIncidence(incidence); 2557 beamIncidence(incidence);
2558 } 2558 }
2559} 2559}
2560void CalendarView::toggleCancelIncidence() 2560void CalendarView::toggleCancelIncidence()
2561{ 2561{
2562 Incidence *incidence = currentSelection(); 2562 Incidence *incidence = currentSelection();
2563 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2563 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2564 if ( incidence ) { 2564 if ( incidence ) {
2565 cancelIncidence(incidence); 2565 cancelIncidence(incidence);
2566 } 2566 }
2567} 2567}
2568 2568
2569 2569
2570void CalendarView::cancelIncidence(Incidence * inc ) 2570void CalendarView::cancelIncidence(Incidence * inc )
2571{ 2571{
2572 inc->setCancelled( ! inc->cancelled() ); 2572 inc->setCancelled( ! inc->cancelled() );
2573 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 2573 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
2574 updateView(); 2574 updateView();
2575} 2575}
2576void CalendarView::cloneIncidence(Incidence * orgInc ) 2576void CalendarView::cloneIncidence(Incidence * orgInc )
2577{ 2577{
2578 Incidence * newInc = orgInc->clone(); 2578 Incidence * newInc = orgInc->clone();
2579 newInc->recreate(); 2579 newInc->recreate();
2580 2580
2581 if ( newInc->type() == "Todo" ) { 2581 if ( newInc->type() == "Todo" ) {
2582 Todo* t = (Todo*) newInc; 2582 Todo* t = (Todo*) newInc;
2583 showTodoEditor(); 2583 showTodoEditor();
2584 mTodoEditor->editTodo( t ); 2584 mTodoEditor->editTodo( t );
2585 if ( mTodoEditor->exec() ) { 2585 if ( mTodoEditor->exec() ) {
2586 mCalendar->addTodo( t ); 2586 mCalendar->addTodo( t );
2587 updateView(); 2587 updateView();
2588 } else { 2588 } else {
2589 delete t; 2589 delete t;
2590 } 2590 }
2591 } 2591 }
2592 else { 2592 else {
2593 Event* e = (Event*) newInc; 2593 Event* e = (Event*) newInc;
2594 showEventEditor(); 2594 showEventEditor();
2595 mEventEditor->editEvent( e ); 2595 mEventEditor->editEvent( e );
2596 if ( mEventEditor->exec() ) { 2596 if ( mEventEditor->exec() ) {
2597 mCalendar->addEvent( e ); 2597 mCalendar->addEvent( e );
2598 updateView(); 2598 updateView();
2599 } else { 2599 } else {
2600 delete e; 2600 delete e;
2601 } 2601 }
2602 } 2602 }
2603} 2603}
2604 2604
2605void CalendarView::newEvent() 2605void CalendarView::newEvent()
2606{ 2606{
2607 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 2607 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
2608 KOAgendaView *aView = mViewManager->agendaView(); 2608 KOAgendaView *aView = mViewManager->agendaView();
2609 if (aView) { 2609 if (aView) {
2610 if (aView->selectionStart().isValid()) { 2610 if (aView->selectionStart().isValid()) {
2611 if (aView->selectedIsAllDay()) { 2611 if (aView->selectedIsAllDay()) {
2612 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 2612 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
2613 } else { 2613 } else {
2614 newEvent(aView->selectionStart(),aView->selectionEnd()); 2614 newEvent(aView->selectionStart(),aView->selectionEnd());
2615 } 2615 }
2616 return; 2616 return;
2617 } 2617 }
2618 } 2618 }
2619 2619
2620 QDate date = mNavigator->selectedDates().first(); 2620 QDate date = mNavigator->selectedDates().first();
2621 QDateTime current = QDateTime::currentDateTime(); 2621 QDateTime current = QDateTime::currentDateTime();
2622 if ( date <= current.date() ) { 2622 if ( date <= current.date() ) {
2623 int hour = current.time().hour() +1; 2623 int hour = current.time().hour() +1;
2624 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 2624 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
2625 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2625 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2626 } else 2626 } else
2627 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 2627 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
2628 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 2628 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
2629 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 2629 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
2630} 2630}
2631 2631
2632void CalendarView::newEvent(QDateTime fh) 2632void CalendarView::newEvent(QDateTime fh)
2633{ 2633{
2634 newEvent(fh, 2634 newEvent(fh,
2635 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 2635 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
2636} 2636}
2637 2637
2638void CalendarView::newEvent(QDate dt) 2638void CalendarView::newEvent(QDate dt)
2639{ 2639{
2640 newEvent(QDateTime(dt, QTime(0,0,0)), 2640 newEvent(QDateTime(dt, QTime(0,0,0)),
2641 QDateTime(dt, QTime(0,0,0)), true); 2641 QDateTime(dt, QTime(0,0,0)), true);
2642} 2642}
2643 2643
2644void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 2644void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
2645{ 2645{
2646 2646
2647 showEventEditor(); 2647 showEventEditor();
2648 mEventEditor->newEvent(fromHint,toHint,allDay); 2648 mEventEditor->newEvent(fromHint,toHint,allDay);
2649 if ( mFilterView->filtersEnabled() ) { 2649 if ( mFilterView->filtersEnabled() ) {
2650 CalFilter *filter = mFilterView->selectedFilter(); 2650 CalFilter *filter = mFilterView->selectedFilter();
2651 if (filter && filter->showCategories()) { 2651 if (filter && filter->showCategories()) {
2652 mEventEditor->setCategories(filter->categoryList().join(",") ); 2652 mEventEditor->setCategories(filter->categoryList().join(",") );
2653 } 2653 }
2654 if ( filter ) 2654 if ( filter )
2655 mEventEditor->setSecrecy( filter->getSecrecy() ); 2655 mEventEditor->setSecrecy( filter->getSecrecy() );
2656 } 2656 }
2657} 2657}
2658void CalendarView::todoAdded(Todo * t) 2658void CalendarView::todoAdded(Todo * t)
2659{ 2659{
2660 2660
2661 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 2661 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
2662 updateTodoViews(); 2662 updateTodoViews();
2663} 2663}
2664void CalendarView::todoChanged(Todo * t) 2664void CalendarView::todoChanged(Todo * t)
2665{ 2665{
2666 emit todoModified( t, 4 ); 2666 emit todoModified( t, 4 );
2667 // updateTodoViews(); 2667 // updateTodoViews();
2668} 2668}
2669void CalendarView::todoToBeDeleted(Todo *) 2669void CalendarView::todoToBeDeleted(Todo *)
2670{ 2670{
2671 //qDebug("todoToBeDeleted(Todo *) "); 2671 //qDebug("todoToBeDeleted(Todo *) ");
2672 updateTodoViews(); 2672 updateTodoViews();
2673} 2673}
2674void CalendarView::todoDeleted() 2674void CalendarView::todoDeleted()
2675{ 2675{
2676 //qDebug(" todoDeleted()"); 2676 //qDebug(" todoDeleted()");
2677 updateTodoViews(); 2677 updateTodoViews();
2678} 2678}
2679 2679
2680 2680
2681 2681
2682void CalendarView::newTodo() 2682void CalendarView::newTodo()
2683{ 2683{
2684 2684
2685 showTodoEditor(); 2685 showTodoEditor();
2686 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); 2686 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true);
2687 if ( mFilterView->filtersEnabled() ) { 2687 if ( mFilterView->filtersEnabled() ) {
2688 CalFilter *filter = mFilterView->selectedFilter(); 2688 CalFilter *filter = mFilterView->selectedFilter();
2689 if (filter && filter->showCategories()) { 2689 if (filter && filter->showCategories()) {
2690 mTodoEditor->setCategories(filter->categoryList().join(",") ); 2690 mTodoEditor->setCategories(filter->categoryList().join(",") );
2691 } 2691 }
2692 if ( filter ) 2692 if ( filter )
2693 mTodoEditor->setSecrecy( filter->getSecrecy() ); 2693 mTodoEditor->setSecrecy( filter->getSecrecy() );
2694 } 2694 }
2695} 2695}
2696 2696
2697void CalendarView::newSubTodo() 2697void CalendarView::newSubTodo()
2698{ 2698{
2699 Todo *todo = selectedTodo(); 2699 Todo *todo = selectedTodo();
2700 if ( todo ) newSubTodo( todo ); 2700 if ( todo ) newSubTodo( todo );
2701} 2701}
2702 2702
2703void CalendarView::newSubTodo(Todo *parentEvent) 2703void CalendarView::newSubTodo(Todo *parentEvent)
2704{ 2704{
2705 2705
2706 showTodoEditor(); 2706 showTodoEditor();
2707 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); 2707 mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true);
2708} 2708}
2709 2709
2710void CalendarView::newFloatingEvent() 2710void CalendarView::newFloatingEvent()
2711{ 2711{
2712 DateList tmpList = mNavigator->selectedDates(); 2712 DateList tmpList = mNavigator->selectedDates();
2713 QDate date = tmpList.first(); 2713 QDate date = tmpList.first();
2714 2714
2715 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 2715 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
2716 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 2716 QDateTime( date, QTime( 12, 0, 0 ) ), true );
2717} 2717}
2718 2718
2719 2719
2720void CalendarView::editEvent( Event *event ) 2720void CalendarView::editEvent( Event *event )
2721{ 2721{
2722 2722
2723 if ( !event ) return; 2723 if ( !event ) return;
2724 if ( event->isReadOnly() ) { 2724 if ( event->isReadOnly() ) {
2725 showEvent( event ); 2725 showEvent( event );
2726 return; 2726 return;
2727 } 2727 }
2728 showEventEditor(); 2728 showEventEditor();
2729 mEventEditor->editEvent( event , mFlagEditDescription); 2729 mEventEditor->editEvent( event , mFlagEditDescription);
2730} 2730}
2731void CalendarView::editJournal( Journal *jour ) 2731void CalendarView::editJournal( Journal *jour )
2732{ 2732{
2733 if ( !jour ) return; 2733 if ( !jour ) return;
2734 mDialogManager->hideSearchDialog(); 2734 mDialogManager->hideSearchDialog();
2735 mViewManager->showJournalView(); 2735 mViewManager->showJournalView();
2736 mNavigator->slotDaySelect( jour->dtStart().date() ); 2736 mNavigator->slotDaySelect( jour->dtStart().date() );
2737} 2737}
2738void CalendarView::editTodo( Todo *todo ) 2738void CalendarView::editTodo( Todo *todo )
2739{ 2739{
2740 if ( !todo ) return; 2740 if ( !todo ) return;
2741 2741
2742 if ( todo->isReadOnly() ) { 2742 if ( todo->isReadOnly() ) {
2743 showTodo( todo ); 2743 showTodo( todo );
2744 return; 2744 return;
2745 } 2745 }
2746 showTodoEditor(); 2746 showTodoEditor();
2747 mTodoEditor->editTodo( todo ,mFlagEditDescription); 2747 mTodoEditor->editTodo( todo ,mFlagEditDescription);
2748 2748
2749} 2749}
2750 2750
2751KOEventViewerDialog* CalendarView::getEventViewerDialog() 2751KOEventViewerDialog* CalendarView::getEventViewerDialog()
2752{ 2752{
2753 if ( !mEventViewerDialog ) { 2753 if ( !mEventViewerDialog ) {
2754 mEventViewerDialog = new KOEventViewerDialog(this); 2754 mEventViewerDialog = new KOEventViewerDialog(this);
2755 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 2755 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
2756 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 2756 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
2757 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 2757 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
2758 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 2758 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
2759 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 2759 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
2760 viewManager(), SLOT( showAgendaView( bool ) ) ); 2760 viewManager(), SLOT( showAgendaView( bool ) ) );
2761 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), 2761 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ),
2762 this, SLOT( todoChanged(Todo *) ) ); 2762 this, SLOT( todoChanged(Todo *) ) );
2763 mEventViewerDialog->resize( 640, 480 ); 2763 mEventViewerDialog->resize( 640, 480 );
2764 2764
2765 } 2765 }
2766 return mEventViewerDialog; 2766 return mEventViewerDialog;
2767} 2767}
2768void CalendarView::showEvent(Event *event) 2768void CalendarView::showEvent(Event *event)
2769{ 2769{
2770 getEventViewerDialog()->setEvent(event); 2770 getEventViewerDialog()->setEvent(event);
2771 getEventViewerDialog()->showMe(); 2771 getEventViewerDialog()->showMe();
2772} 2772}
2773 2773
2774void CalendarView::showTodo(Todo *event) 2774void CalendarView::showTodo(Todo *event)
2775{ 2775{
2776 getEventViewerDialog()->setTodo(event); 2776 getEventViewerDialog()->setTodo(event);
2777 getEventViewerDialog()->showMe(); 2777 getEventViewerDialog()->showMe();
2778} 2778}
2779void CalendarView::showJournal( Journal *jour ) 2779void CalendarView::showJournal( Journal *jour )
2780{ 2780{
2781 getEventViewerDialog()->setJournal(jour); 2781 getEventViewerDialog()->setJournal(jour);
2782 getEventViewerDialog()->showMe(); 2782 getEventViewerDialog()->showMe();
2783 2783
2784} 2784}
2785// void CalendarView::todoModified (Todo *event, int changed) 2785// void CalendarView::todoModified (Todo *event, int changed)
2786// { 2786// {
2787// // if (mDialogList.find (event) != mDialogList.end ()) { 2787// // if (mDialogList.find (event) != mDialogList.end ()) {
2788// // kdDebug() << "Todo modified and open" << endl; 2788// // kdDebug() << "Todo modified and open" << endl;
2789// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 2789// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
2790// // temp->modified (changed); 2790// // temp->modified (changed);
2791 2791
2792// // } 2792// // }
2793 2793
2794// mViewManager->updateView(); 2794// mViewManager->updateView();
2795// } 2795// }
2796 2796
2797void CalendarView::appointment_show() 2797void CalendarView::appointment_show()
2798{ 2798{
2799 Event *anEvent = 0; 2799 Event *anEvent = 0;
2800 2800
2801 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2801 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2802 2802
2803 if (mViewManager->currentView()->isEventView()) { 2803 if (mViewManager->currentView()->isEventView()) {
2804 if ( incidence && incidence->type() == "Event" ) { 2804 if ( incidence && incidence->type() == "Event" ) {
2805 anEvent = static_cast<Event *>(incidence); 2805 anEvent = static_cast<Event *>(incidence);
2806 } 2806 }
2807 } 2807 }
2808 2808
2809 if (!anEvent) { 2809 if (!anEvent) {
2810 KNotifyClient::beep(); 2810 KNotifyClient::beep();
2811 return; 2811 return;
2812 } 2812 }
2813 2813
2814 showEvent(anEvent); 2814 showEvent(anEvent);
2815} 2815}
2816 2816
2817void CalendarView::appointment_edit() 2817void CalendarView::appointment_edit()
2818{ 2818{
2819 Event *anEvent = 0; 2819 Event *anEvent = 0;
2820 2820
2821 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2821 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2822 2822
2823 if (mViewManager->currentView()->isEventView()) { 2823 if (mViewManager->currentView()->isEventView()) {
2824 if ( incidence && incidence->type() == "Event" ) { 2824 if ( incidence && incidence->type() == "Event" ) {
2825 anEvent = static_cast<Event *>(incidence); 2825 anEvent = static_cast<Event *>(incidence);
2826 } 2826 }
2827 } 2827 }
2828 2828
2829 if (!anEvent) { 2829 if (!anEvent) {
2830 KNotifyClient::beep(); 2830 KNotifyClient::beep();
2831 return; 2831 return;
2832 } 2832 }
2833 2833
2834 editEvent(anEvent); 2834 editEvent(anEvent);
2835} 2835}
2836 2836
2837void CalendarView::appointment_delete() 2837void CalendarView::appointment_delete()
2838{ 2838{
2839 Event *anEvent = 0; 2839 Event *anEvent = 0;
2840 2840
2841 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2841 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2842 2842
2843 if (mViewManager->currentView()->isEventView()) { 2843 if (mViewManager->currentView()->isEventView()) {
2844 if ( incidence && incidence->type() == "Event" ) { 2844 if ( incidence && incidence->type() == "Event" ) {
2845 anEvent = static_cast<Event *>(incidence); 2845 anEvent = static_cast<Event *>(incidence);
2846 } 2846 }
2847 } 2847 }
2848 2848
2849 if (!anEvent) { 2849 if (!anEvent) {
2850 KNotifyClient::beep(); 2850 KNotifyClient::beep();
2851 return; 2851 return;
2852 } 2852 }
2853 2853
2854 deleteEvent(anEvent); 2854 deleteEvent(anEvent);
2855} 2855}
2856 2856
2857void CalendarView::todo_resub( Todo * parent, Todo * sub ) 2857void CalendarView::todo_resub( Todo * parent, Todo * sub )
2858{ 2858{
2859 if (!sub) return; 2859 if (!sub) return;
2860 if (!parent) return; 2860 if (!parent) return;
2861 if ( sub->relatedTo() ) 2861 if ( sub->relatedTo() )
2862 sub->relatedTo()->removeRelation(sub); 2862 sub->relatedTo()->removeRelation(sub);
2863 sub->setRelatedTo(parent); 2863 sub->setRelatedTo(parent);
2864 sub->setRelatedToUid(parent->uid()); 2864 sub->setRelatedToUid(parent->uid());
2865 parent->addRelation(sub); 2865 parent->addRelation(sub);
2866 sub->updated(); 2866 sub->updated();
2867 parent->updated(); 2867 parent->updated();
2868 setModified(true); 2868 setModified(true);
2869 updateView(); 2869 updateView();
2870} 2870}
2871void CalendarView::todo_unsub(Todo *anTodo ) 2871void CalendarView::todo_unsub(Todo *anTodo )
2872{ 2872{
2873 // Todo *anTodo = selectedTodo(); 2873 // Todo *anTodo = selectedTodo();
2874 if (!anTodo) return; 2874 if (!anTodo) return;
2875 if (!anTodo->relatedTo()) return; 2875 if (!anTodo->relatedTo()) return;
2876 anTodo->relatedTo()->removeRelation(anTodo); 2876 anTodo->relatedTo()->removeRelation(anTodo);
2877 anTodo->setRelatedTo(0); 2877 anTodo->setRelatedTo(0);
2878 anTodo->updated(); 2878 anTodo->updated();
2879 anTodo->setRelatedToUid(""); 2879 anTodo->setRelatedToUid("");
2880 setModified(true); 2880 setModified(true);
2881 updateView(); 2881 updateView();
2882} 2882}
2883 2883
2884void CalendarView::deleteTodo(Todo *todo) 2884void CalendarView::deleteTodo(Todo *todo)
2885{ 2885{
2886 if (!todo) { 2886 if (!todo) {
2887 KNotifyClient::beep(); 2887 KNotifyClient::beep();
2888 return; 2888 return;
2889 } 2889 }
2890 if (KOPrefs::instance()->mConfirm) { 2890 if (KOPrefs::instance()->mConfirm) {
2891 switch (msgItemDelete()) { 2891 QString text = todo->summary().left(20);
2892 if (!todo->relations().isEmpty()) {
2893 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!");
2894
2895 }
2896 switch (msgItemDelete(text)) {
2892 case KMessageBox::Continue: // OK 2897 case KMessageBox::Continue: // OK
2898 bool deleteT = false;
2893 if (!todo->relations().isEmpty()) { 2899 if (!todo->relations().isEmpty()) {
2894 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), 2900 deleteT = removeCompletedSubTodos( todo );
2895 i18n("Delete To-Do")); 2901 }
2896 } else { 2902 // deleteT == true: todo already deleted in removeCompletedSubTodos
2903 if ( !deleteT ) {
2897 checkExternalId( todo ); 2904 checkExternalId( todo );
2898 calendar()->deleteTodo(todo); 2905 calendar()->deleteTodo(todo);
2899 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 2906 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2900 updateView(); 2907 updateView();
2901 } 2908 }
2902 break; 2909 break;
2903 } // switch 2910 } // switch
2904 } else { 2911 } else {
2905 if (!todo->relations().isEmpty()) { 2912 checkExternalId( todo );
2906 KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), 2913 mCalendar->deleteTodo(todo);
2907 i18n("Delete To-Do")); 2914 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2908 } else { 2915 updateView();
2909 checkExternalId( todo );
2910 mCalendar->deleteTodo(todo);
2911 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
2912 updateView();
2913 }
2914 } 2916 }
2917
2915 emit updateSearchDialog(); 2918 emit updateSearchDialog();
2916} 2919}
2917void CalendarView::deleteJournal(Journal *jour) 2920void CalendarView::deleteJournal(Journal *jour)
2918{ 2921{
2919 if (!jour) { 2922 if (!jour) {
2920 KNotifyClient::beep(); 2923 KNotifyClient::beep();
2921 return; 2924 return;
2922 } 2925 }
2923 if (KOPrefs::instance()->mConfirm) { 2926 if (KOPrefs::instance()->mConfirm) {
2924 switch (msgItemDelete()) { 2927 switch (msgItemDelete( jour->description().left(20))) {
2925 case KMessageBox::Continue: // OK 2928 case KMessageBox::Continue: // OK
2926 calendar()->deleteJournal(jour); 2929 calendar()->deleteJournal(jour);
2927 updateView(); 2930 updateView();
2928 break; 2931 break;
2929 } // switch 2932 } // switch
2930 } else { 2933 } else {
2931 calendar()->deleteJournal(jour);; 2934 calendar()->deleteJournal(jour);;
2932 updateView(); 2935 updateView();
2933 } 2936 }
2934 emit updateSearchDialog(); 2937 emit updateSearchDialog();
2935} 2938}
2936 2939
2937void CalendarView::deleteEvent(Event *anEvent) 2940void CalendarView::deleteEvent(Event *anEvent)
2938{ 2941{
2939 if (!anEvent) { 2942 if (!anEvent) {
2940 KNotifyClient::beep(); 2943 KNotifyClient::beep();
2941 return; 2944 return;
2942 } 2945 }
2943 2946
2944 if (anEvent->recurrence()->doesRecur()) { 2947 if (anEvent->recurrence()->doesRecur()) {
2945 QDate itemDate = mViewManager->currentSelectionDate(); 2948 QDate itemDate = mViewManager->currentSelectionDate();
2946 int km; 2949 int km;
2947 if (!itemDate.isValid()) { 2950 if (!itemDate.isValid()) {
2948 //kdDebug() << "Date Not Valid" << endl; 2951 //kdDebug() << "Date Not Valid" << endl;
2949 if (KOPrefs::instance()->mConfirm) { 2952 if (KOPrefs::instance()->mConfirm) {
2950 km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + 2953 km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) +
2951 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), 2954 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"),
2952 i18n("KO/Pi Confirmation"),i18n("Delete All")); 2955 i18n("KO/Pi Confirmation"),i18n("Delete All"));
2953 if ( km == KMessageBox::Continue ) 2956 if ( km == KMessageBox::Continue )
2954 km = KMessageBox::No; // No = all below 2957 km = KMessageBox::No; // No = all below
2955 } else 2958 } else
2956 km = KMessageBox::No; 2959 km = KMessageBox::No;
2957 } else { 2960 } else {
2958 km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + 2961 km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) +
2959 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ 2962 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+
2960 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), 2963 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"),
2961 i18n("KO/Pi Confirmation"),i18n("Current"), 2964 i18n("KO/Pi Confirmation"),i18n("Current"),
2962 i18n("All")); 2965 i18n("All"));
2963 } 2966 }
2964 switch(km) { 2967 switch(km) {
2965 2968
2966 case KMessageBox::No: // Continue // all 2969 case KMessageBox::No: // Continue // all
2967 //qDebug("KMessageBox::No "); 2970 //qDebug("KMessageBox::No ");
2968 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 2971 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
2969 schedule(Scheduler::Cancel,anEvent); 2972 schedule(Scheduler::Cancel,anEvent);
2970 2973
2971 checkExternalId( anEvent); 2974 checkExternalId( anEvent);
2972 mCalendar->deleteEvent(anEvent); 2975 mCalendar->deleteEvent(anEvent);
2973 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); 2976 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED);
2974 break; 2977 break;
2975 2978
2976 // Disabled because it does not work 2979 // Disabled because it does not work
2977 //#if 0 2980 //#if 0
2978 case KMessageBox::Yes: // just this one 2981 case KMessageBox::Yes: // just this one
2979 //QDate qd = mNavigator->selectedDates().first(); 2982 //QDate qd = mNavigator->selectedDates().first();
2980 //if (!qd.isValid()) { 2983 //if (!qd.isValid()) {
2981 // kdDebug() << "no date selected, or invalid date" << endl; 2984 // kdDebug() << "no date selected, or invalid date" << endl;
2982 // KNotifyClient::beep(); 2985 // KNotifyClient::beep();
2983 // return; 2986 // return;
2984 //} 2987 //}
2985 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); 2988 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1);
2986 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { 2989 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) {
2987 anEvent->addExDate(itemDate); 2990 anEvent->addExDate(itemDate);
2988 int duration = anEvent->recurrence()->duration(); 2991 int duration = anEvent->recurrence()->duration();
2989 if ( duration > 0 ) { 2992 if ( duration > 0 ) {
2990 anEvent->recurrence()->setDuration( duration - 1 ); 2993 anEvent->recurrence()->setDuration( duration - 1 );
2991 } 2994 }
2992 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); 2995 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED);
2993 } 2996 }
2994 break; 2997 break;
2995 //#endif 2998 //#endif
2996 } // switch 2999 } // switch
2997 } else { 3000 } else {
2998 if (KOPrefs::instance()->mConfirm) { 3001 if (KOPrefs::instance()->mConfirm) {
2999 switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + 3002 switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) +
3000 i18n("\nAre you sure you want\nto delete this event?"), 3003 i18n("\nAre you sure you want\nto delete this event?"),
3001 i18n("KO/Pi Confirmation"),i18n("Delete"))) { 3004 i18n("KO/Pi Confirmation"),i18n("Delete"))) {
3002 case KMessageBox::Continue: // OK 3005 case KMessageBox::Continue: // OK
3003 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3006 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3004 schedule(Scheduler::Cancel,anEvent); 3007 schedule(Scheduler::Cancel,anEvent);
3005 checkExternalId( anEvent); 3008 checkExternalId( anEvent);
3006 mCalendar->deleteEvent(anEvent); 3009 mCalendar->deleteEvent(anEvent);
3007 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3010 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3008 break; 3011 break;
3009 } // switch 3012 } // switch
3010 } else { 3013 } else {
3011 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3014 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3012 schedule(Scheduler::Cancel,anEvent); 3015 schedule(Scheduler::Cancel,anEvent);
3013 checkExternalId( anEvent); 3016 checkExternalId( anEvent);
3014 mCalendar->deleteEvent(anEvent); 3017 mCalendar->deleteEvent(anEvent);
3015 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3018 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3016 } 3019 }
3017 } // if-else 3020 } // if-else
3018 emit updateSearchDialog(); 3021 emit updateSearchDialog();
3019} 3022}
3020 3023
3021bool CalendarView::deleteEvent(const QString &uid) 3024bool CalendarView::deleteEvent(const QString &uid)
3022{ 3025{
3023 Event *ev = mCalendar->event(uid); 3026 Event *ev = mCalendar->event(uid);
3024 if (ev) { 3027 if (ev) {
3025 deleteEvent(ev); 3028 deleteEvent(ev);
3026 return true; 3029 return true;
3027 } else { 3030 } else {
3028 return false; 3031 return false;
3029 } 3032 }
3030} 3033}
3031 3034
3032/*****************************************************************************/ 3035/*****************************************************************************/
3033 3036
3034void CalendarView::action_mail() 3037void CalendarView::action_mail()
3035{ 3038{
3036#ifndef KORG_NOMAIL 3039#ifndef KORG_NOMAIL
3037 KOMailClient mailClient; 3040 KOMailClient mailClient;
3038 3041
3039 Incidence *incidence = currentSelection(); 3042 Incidence *incidence = currentSelection();
3040 3043
3041 if (!incidence) { 3044 if (!incidence) {
3042 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3045 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3043 return; 3046 return;
3044 } 3047 }
3045 if(incidence->attendeeCount() == 0 ) { 3048 if(incidence->attendeeCount() == 0 ) {
3046 KMessageBox::sorry(this, 3049 KMessageBox::sorry(this,
3047 i18n("Can't generate mail:\nNo attendees defined.\n")); 3050 i18n("Can't generate mail:\nNo attendees defined.\n"));
3048 return; 3051 return;
3049 } 3052 }
3050 3053
3051 CalendarLocal cal_tmp; 3054 CalendarLocal cal_tmp;
3052 Event *event = 0; 3055 Event *event = 0;
3053 Event *ev = 0; 3056 Event *ev = 0;
3054 if ( incidence && incidence->type() == "Event" ) { 3057 if ( incidence && incidence->type() == "Event" ) {
3055 event = static_cast<Event *>(incidence); 3058 event = static_cast<Event *>(incidence);
3056 ev = new Event(*event); 3059 ev = new Event(*event);
3057 cal_tmp.addEvent(ev); 3060 cal_tmp.addEvent(ev);
3058 } 3061 }
3059 ICalFormat mForm(); 3062 ICalFormat mForm();
3060 QString attachment = mForm.toString( &cal_tmp ); 3063 QString attachment = mForm.toString( &cal_tmp );
3061 if (ev) delete(ev); 3064 if (ev) delete(ev);
3062 3065
3063 mailClient.mailAttendees(currentSelection(), attachment); 3066 mailClient.mailAttendees(currentSelection(), attachment);
3064 3067
3065#endif 3068#endif
3066 3069
3067#if 0 3070#if 0
3068 Event *anEvent = 0; 3071 Event *anEvent = 0;
3069 if (mViewManager->currentView()->isEventView()) { 3072 if (mViewManager->currentView()->isEventView()) {
3070 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); 3073 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first());
3071 } 3074 }
3072 3075
3073 if (!anEvent) { 3076 if (!anEvent) {
3074 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3077 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3075 return; 3078 return;
3076 } 3079 }
3077 if(anEvent->attendeeCount() == 0 ) { 3080 if(anEvent->attendeeCount() == 0 ) {
3078 KMessageBox::sorry(this, 3081 KMessageBox::sorry(this,
3079 i18n("Can't generate mail:\nNo attendees defined.\n")); 3082 i18n("Can't generate mail:\nNo attendees defined.\n"));
3080 return; 3083 return;
3081 } 3084 }
3082 3085
3083 mailobject.emailEvent(anEvent); 3086 mailobject.emailEvent(anEvent);
3084#endif 3087#endif
3085} 3088}
3086 3089
3087 3090
3088void CalendarView::schedule_publish(Incidence *incidence) 3091void CalendarView::schedule_publish(Incidence *incidence)
3089{ 3092{
3090 Event *event = 0; 3093 Event *event = 0;
3091 Todo *todo = 0; 3094 Todo *todo = 0;
3092 3095
3093 if (incidence == 0) { 3096 if (incidence == 0) {
3094 incidence = mViewManager->currentView()->selectedIncidences().first(); 3097 incidence = mViewManager->currentView()->selectedIncidences().first();
3095 if (incidence == 0) { 3098 if (incidence == 0) {
3096 incidence = mTodoList->selectedIncidences().first(); 3099 incidence = mTodoList->selectedIncidences().first();
3097 } 3100 }
3098 } 3101 }
3099 if ( incidence && incidence->type() == "Event" ) { 3102 if ( incidence && incidence->type() == "Event" ) {
3100 event = static_cast<Event *>(incidence); 3103 event = static_cast<Event *>(incidence);
3101 } else { 3104 } else {
3102 if ( incidence && incidence->type() == "Todo" ) { 3105 if ( incidence && incidence->type() == "Todo" ) {
3103 todo = static_cast<Todo *>(incidence); 3106 todo = static_cast<Todo *>(incidence);
3104 } 3107 }
3105 } 3108 }
3106 3109
3107 if (!event && !todo) { 3110 if (!event && !todo) {
3108 KMessageBox::sorry(this,i18n("No event selected.")); 3111 KMessageBox::sorry(this,i18n("No event selected."));
3109 return; 3112 return;
3110 } 3113 }
3111 3114
3112 PublishDialog *publishdlg = new PublishDialog(); 3115 PublishDialog *publishdlg = new PublishDialog();
3113 if (incidence->attendeeCount()>0) { 3116 if (incidence->attendeeCount()>0) {
3114 QPtrList<Attendee> attendees = incidence->attendees(); 3117 QPtrList<Attendee> attendees = incidence->attendees();
3115 attendees.first(); 3118 attendees.first();
3116 while ( attendees.current()!=0 ) { 3119 while ( attendees.current()!=0 ) {
3117 publishdlg->addAttendee(attendees.current()); 3120 publishdlg->addAttendee(attendees.current());
3118 attendees.next(); 3121 attendees.next();
3119 } 3122 }
3120 } 3123 }
3121 bool send = true; 3124 bool send = true;
3122 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { 3125 if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) {
3123 if ( publishdlg->exec() != QDialog::Accepted ) 3126 if ( publishdlg->exec() != QDialog::Accepted )
3124 send = false; 3127 send = false;
3125 } 3128 }
3126 if ( send ) { 3129 if ( send ) {
3127 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3130 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3128 if ( event ) { 3131 if ( event ) {
3129 Event *ev = new Event(*event); 3132 Event *ev = new Event(*event);
3130 ev->registerObserver(0); 3133 ev->registerObserver(0);
3131 ev->clearAttendees(); 3134 ev->clearAttendees();
3132 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3135 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3133 delete(ev); 3136 delete(ev);
3134 } 3137 }
3135 } else { 3138 } else {
3136 if ( todo ) { 3139 if ( todo ) {
3137 Todo *ev = new Todo(*todo); 3140 Todo *ev = new Todo(*todo);
3138 ev->registerObserver(0); 3141 ev->registerObserver(0);
3139 ev->clearAttendees(); 3142 ev->clearAttendees();
3140 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { 3143 if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) {
3141 delete(ev); 3144 delete(ev);
3142 } 3145 }
3143 } 3146 }
3144 } 3147 }
3145 } 3148 }
3146 delete publishdlg; 3149 delete publishdlg;
3147} 3150}
3148 3151
3149void CalendarView::schedule_request(Incidence *incidence) 3152void CalendarView::schedule_request(Incidence *incidence)
3150{ 3153{
3151 schedule(Scheduler::Request,incidence); 3154 schedule(Scheduler::Request,incidence);
3152} 3155}
3153 3156
3154void CalendarView::schedule_refresh(Incidence *incidence) 3157void CalendarView::schedule_refresh(Incidence *incidence)
3155{ 3158{
3156 schedule(Scheduler::Refresh,incidence); 3159 schedule(Scheduler::Refresh,incidence);
3157} 3160}
3158 3161
3159void CalendarView::schedule_cancel(Incidence *incidence) 3162void CalendarView::schedule_cancel(Incidence *incidence)
3160{ 3163{
3161 schedule(Scheduler::Cancel,incidence); 3164 schedule(Scheduler::Cancel,incidence);
3162} 3165}
3163 3166
3164void CalendarView::schedule_add(Incidence *incidence) 3167void CalendarView::schedule_add(Incidence *incidence)
3165{ 3168{
3166 schedule(Scheduler::Add,incidence); 3169 schedule(Scheduler::Add,incidence);
3167} 3170}
3168 3171
3169void CalendarView::schedule_reply(Incidence *incidence) 3172void CalendarView::schedule_reply(Incidence *incidence)
3170{ 3173{
3171 schedule(Scheduler::Reply,incidence); 3174 schedule(Scheduler::Reply,incidence);
3172} 3175}
3173 3176
3174void CalendarView::schedule_counter(Incidence *incidence) 3177void CalendarView::schedule_counter(Incidence *incidence)
3175{ 3178{
3176 schedule(Scheduler::Counter,incidence); 3179 schedule(Scheduler::Counter,incidence);
3177} 3180}
3178 3181
3179void CalendarView::schedule_declinecounter(Incidence *incidence) 3182void CalendarView::schedule_declinecounter(Incidence *incidence)
3180{ 3183{
3181 schedule(Scheduler::Declinecounter,incidence); 3184 schedule(Scheduler::Declinecounter,incidence);
3182} 3185}
3183 3186
3184void CalendarView::schedule_publish_freebusy(int daysToPublish) 3187void CalendarView::schedule_publish_freebusy(int daysToPublish)
3185{ 3188{
3186 QDateTime start = QDateTime::currentDateTime(); 3189 QDateTime start = QDateTime::currentDateTime();
3187 QDateTime end = start.addDays(daysToPublish); 3190 QDateTime end = start.addDays(daysToPublish);
3188 3191
3189 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); 3192 FreeBusy *freebusy = new FreeBusy(mCalendar, start, end);
3190 freebusy->setOrganizer(KOPrefs::instance()->email()); 3193 freebusy->setOrganizer(KOPrefs::instance()->email());
3191 3194
3192 3195
3193 PublishDialog *publishdlg = new PublishDialog(); 3196 PublishDialog *publishdlg = new PublishDialog();
3194 if ( publishdlg->exec() == QDialog::Accepted ) { 3197 if ( publishdlg->exec() == QDialog::Accepted ) {
3195 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3198 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3196 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { 3199 if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) {
3197 delete(freebusy); 3200 delete(freebusy);
3198 } 3201 }
3199 } 3202 }
3200 delete publishdlg; 3203 delete publishdlg;
3201} 3204}
3202 3205
3203void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) 3206void CalendarView::schedule(Scheduler::Method method, Incidence *incidence)
3204{ 3207{
3205 Event *event = 0; 3208 Event *event = 0;
3206 Todo *todo = 0; 3209 Todo *todo = 0;
3207 3210
3208 if (incidence == 0) { 3211 if (incidence == 0) {
3209 incidence = mViewManager->currentView()->selectedIncidences().first(); 3212 incidence = mViewManager->currentView()->selectedIncidences().first();
3210 if (incidence == 0) { 3213 if (incidence == 0) {
3211 incidence = mTodoList->selectedIncidences().first(); 3214 incidence = mTodoList->selectedIncidences().first();
3212 } 3215 }
3213 } 3216 }
3214 if ( incidence && incidence->type() == "Event" ) { 3217 if ( incidence && incidence->type() == "Event" ) {
3215 event = static_cast<Event *>(incidence); 3218 event = static_cast<Event *>(incidence);
3216 } 3219 }
3217 if ( incidence && incidence->type() == "Todo" ) { 3220 if ( incidence && incidence->type() == "Todo" ) {
3218 todo = static_cast<Todo *>(incidence); 3221 todo = static_cast<Todo *>(incidence);
3219 } 3222 }
3220 3223
3221 if (!event && !todo) { 3224 if (!event && !todo) {
3222 KMessageBox::sorry(this,i18n("No event selected.")); 3225 KMessageBox::sorry(this,i18n("No event selected."));
3223 return; 3226 return;
3224 } 3227 }
3225 3228
3226 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { 3229 if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) {
3227 KMessageBox::sorry(this,i18n("The event has no attendees.")); 3230 KMessageBox::sorry(this,i18n("The event has no attendees."));
3228 return; 3231 return;
3229 } 3232 }
3230 3233
3231 Event *ev = 0; 3234 Event *ev = 0;
3232 if (event) ev = new Event(*event); 3235 if (event) ev = new Event(*event);
3233 Todo *to = 0; 3236 Todo *to = 0;
3234 if (todo) to = new Todo(*todo); 3237 if (todo) to = new Todo(*todo);
3235 3238
3236 if (method == Scheduler::Reply || method == Scheduler::Refresh) { 3239 if (method == Scheduler::Reply || method == Scheduler::Refresh) {
3237 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); 3240 Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email());
3238 if (!me) { 3241 if (!me) {
3239 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); 3242 KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails."));
3240 return; 3243 return;
3241 } 3244 }
3242 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { 3245 if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) {
3243 StatusDialog *statdlg = new StatusDialog(this); 3246 StatusDialog *statdlg = new StatusDialog(this);
3244 if (!statdlg->exec()==QDialog::Accepted) return; 3247 if (!statdlg->exec()==QDialog::Accepted) return;
3245 me->setStatus( statdlg->status() ); 3248 me->setStatus( statdlg->status() );
3246 delete(statdlg); 3249 delete(statdlg);
3247 } 3250 }
3248 Attendee *menew = new Attendee(*me); 3251 Attendee *menew = new Attendee(*me);
3249 if (ev) { 3252 if (ev) {
3250 ev->clearAttendees(); 3253 ev->clearAttendees();
3251 ev->addAttendee(menew,false); 3254 ev->addAttendee(menew,false);
3252 } else { 3255 } else {
3253 if (to) { 3256 if (to) {
3254 todo->clearAttendees(); 3257 todo->clearAttendees();
3255 todo->addAttendee(menew,false); 3258 todo->addAttendee(menew,false);
3256 } 3259 }
3257 } 3260 }
3258 } 3261 }
3259 3262
3260 OutgoingDialog *dlg = mDialogManager->outgoingDialog(); 3263 OutgoingDialog *dlg = mDialogManager->outgoingDialog();
3261 if (ev) { 3264 if (ev) {
3262 if ( !dlg->addMessage(ev,method) ) delete(ev); 3265 if ( !dlg->addMessage(ev,method) ) delete(ev);
3263 } else { 3266 } else {
3264 if (to) { 3267 if (to) {
3265 if ( !dlg->addMessage(to,method) ) delete(to); 3268 if ( !dlg->addMessage(to,method) ) delete(to);
3266 } 3269 }
3267 } 3270 }
3268} 3271}
3269 3272
3270void CalendarView::openAddressbook() 3273void CalendarView::openAddressbook()
3271{ 3274{
3272 KRun::runCommand("kaddressbook"); 3275 KRun::runCommand("kaddressbook");
3273} 3276}
3274 3277
3275void CalendarView::setModified(bool modified) 3278void CalendarView::setModified(bool modified)
3276{ 3279{
3277 if ( modified ) 3280 if ( modified )
3278 emit signalmodified(); 3281 emit signalmodified();
3279 if (mModified != modified) { 3282 if (mModified != modified) {
3280 mModified = modified; 3283 mModified = modified;
3281 emit modifiedChanged(mModified); 3284 emit modifiedChanged(mModified);
3282 } 3285 }
3283} 3286}
3284 3287
3285bool CalendarView::isReadOnly() 3288bool CalendarView::isReadOnly()
3286{ 3289{
3287 return mReadOnly; 3290 return mReadOnly;
3288} 3291}
3289 3292
3290void CalendarView::setReadOnly(bool readOnly) 3293void CalendarView::setReadOnly(bool readOnly)
3291{ 3294{
3292 if (mReadOnly != readOnly) { 3295 if (mReadOnly != readOnly) {
3293 mReadOnly = readOnly; 3296 mReadOnly = readOnly;
3294 emit readOnlyChanged(mReadOnly); 3297 emit readOnlyChanged(mReadOnly);
3295 } 3298 }
3296} 3299}
3297 3300
3298bool CalendarView::isModified() 3301bool CalendarView::isModified()
3299{ 3302{
3300 return mModified; 3303 return mModified;
3301} 3304}
3302 3305
3303void CalendarView::printSetup() 3306void CalendarView::printSetup()
3304{ 3307{
3305#ifndef KORG_NOPRINTER 3308#ifndef KORG_NOPRINTER
3306 createPrinter(); 3309 createPrinter();
3307 3310
3308 mCalPrinter->setupPrinter(); 3311 mCalPrinter->setupPrinter();
3309#endif 3312#endif
3310} 3313}
3311 3314
3312void CalendarView::print() 3315void CalendarView::print()
3313{ 3316{
3314#ifndef KORG_NOPRINTER 3317#ifndef KORG_NOPRINTER
3315 createPrinter(); 3318 createPrinter();
3316 3319
3317 DateList tmpDateList = mNavigator->selectedDates(); 3320 DateList tmpDateList = mNavigator->selectedDates();
3318 mCalPrinter->print(CalPrinter::Month, 3321 mCalPrinter->print(CalPrinter::Month,
3319 tmpDateList.first(), tmpDateList.last()); 3322 tmpDateList.first(), tmpDateList.last());
3320#endif 3323#endif
3321} 3324}
3322 3325
3323void CalendarView::printPreview() 3326void CalendarView::printPreview()
3324{ 3327{
3325#ifndef KORG_NOPRINTER 3328#ifndef KORG_NOPRINTER
3326 kdDebug() << "CalendarView::printPreview()" << endl; 3329 kdDebug() << "CalendarView::printPreview()" << endl;
3327 3330
3328 createPrinter(); 3331 createPrinter();
3329 3332
3330 DateList tmpDateList = mNavigator->selectedDates(); 3333 DateList tmpDateList = mNavigator->selectedDates();
3331 3334
3332 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), 3335 mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(),
3333 tmpDateList.last()); 3336 tmpDateList.last());
3334#endif 3337#endif
3335} 3338}
3336 3339
3337void CalendarView::exportICalendar() 3340void CalendarView::exportICalendar()
3338{ 3341{
3339 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); 3342 QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this);
3340 3343
3341 // Force correct extension 3344 // Force correct extension
3342 if (filename.right(4) != ".ics") filename += ".ics"; 3345 if (filename.right(4) != ".ics") filename += ".ics";
3343 3346
3344 FileStorage storage( mCalendar, filename, new ICalFormat() ); 3347 FileStorage storage( mCalendar, filename, new ICalFormat() );
3345 storage.save(); 3348 storage.save();
3346} 3349}
3347 3350
3348bool CalendarView::exportVCalendar( QString filename ) 3351bool CalendarView::exportVCalendar( QString filename )
3349{ 3352{
3350 if (mCalendar->journals().count() > 0) { 3353 if (mCalendar->journals().count() > 0) {
3351 int result = KMessageBox::warningContinueCancel(this, 3354 int result = KMessageBox::warningContinueCancel(this,
3352 i18n("The journal entries can not be\nexported to a vCalendar file."), 3355 i18n("The journal entries can not be\nexported to a vCalendar file."),
3353 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 3356 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
3354 true); 3357 true);
3355 if (result != KMessageBox::Continue) return false; 3358 if (result != KMessageBox::Continue) return false;
3356 } 3359 }
3357 3360
3358 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); 3361 //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this);
3359 3362
3360 // Force correct extension 3363 // Force correct extension
3361 if (filename.right(4) != ".vcs") filename += ".vcs"; 3364 if (filename.right(4) != ".vcs") filename += ".vcs";
3362 3365
3363 FileStorage storage( mCalendar, filename, new VCalFormat ); 3366 FileStorage storage( mCalendar, filename, new VCalFormat );
3364 return storage.save(); 3367 return storage.save();
3365 3368
3366} 3369}
3367 3370
3368void CalendarView::eventUpdated(Incidence *) 3371void CalendarView::eventUpdated(Incidence *)
3369{ 3372{
3370 setModified(); 3373 setModified();
3371 // Don't call updateView here. The code, which has caused the update of the 3374 // Don't call updateView here. The code, which has caused the update of the
3372 // event is responsible for updating the view. 3375 // event is responsible for updating the view.
3373 // updateView(); 3376 // updateView();
3374} 3377}
3375 3378
3376void CalendarView::adaptNavigationUnits() 3379void CalendarView::adaptNavigationUnits()
3377{ 3380{
3378 if (mViewManager->currentView()->isEventView()) { 3381 if (mViewManager->currentView()->isEventView()) {
3379 int days = mViewManager->currentView()->currentDateCount(); 3382 int days = mViewManager->currentView()->currentDateCount();
3380 if (days == 1) { 3383 if (days == 1) {
3381 emit changeNavStringPrev(i18n("&Previous Day")); 3384 emit changeNavStringPrev(i18n("&Previous Day"));
3382 emit changeNavStringNext(i18n("&Next Day")); 3385 emit changeNavStringNext(i18n("&Next Day"));
3383 } else { 3386 } else {
3384 emit changeNavStringPrev(i18n("&Previous Week")); 3387 emit changeNavStringPrev(i18n("&Previous Week"));
3385 emit changeNavStringNext(i18n("&Next Week")); 3388 emit changeNavStringNext(i18n("&Next Week"));
3386 } 3389 }
3387 } 3390 }
3388} 3391}
3389 3392
3390void CalendarView::processMainViewSelection( Incidence *incidence ) 3393void CalendarView::processMainViewSelection( Incidence *incidence )
3391{ 3394{
3392 if ( incidence ) mTodoList->clearSelection(); 3395 if ( incidence ) mTodoList->clearSelection();
3393 processIncidenceSelection( incidence ); 3396 processIncidenceSelection( incidence );
3394} 3397}
3395 3398
3396void CalendarView::processTodoListSelection( Incidence *incidence ) 3399void CalendarView::processTodoListSelection( Incidence *incidence )
3397{ 3400{
3398 if ( incidence && mViewManager->currentView() ) { 3401 if ( incidence && mViewManager->currentView() ) {
3399 mViewManager->currentView()->clearSelection(); 3402 mViewManager->currentView()->clearSelection();
3400 } 3403 }
3401 processIncidenceSelection( incidence ); 3404 processIncidenceSelection( incidence );
3402} 3405}
3403 3406
3404void CalendarView::processIncidenceSelection( Incidence *incidence ) 3407void CalendarView::processIncidenceSelection( Incidence *incidence )
3405{ 3408{
3406 if ( incidence == mSelectedIncidence ) return; 3409 if ( incidence == mSelectedIncidence ) return;
3407 3410
3408 mSelectedIncidence = incidence; 3411 mSelectedIncidence = incidence;
3409 3412
3410 emit incidenceSelected( mSelectedIncidence ); 3413 emit incidenceSelected( mSelectedIncidence );
3411 3414
3412 if ( incidence && incidence->type() == "Event" ) { 3415 if ( incidence && incidence->type() == "Event" ) {
3413 Event *event = static_cast<Event *>( incidence ); 3416 Event *event = static_cast<Event *>( incidence );
3414 if ( event->organizer() == KOPrefs::instance()->email() ) { 3417 if ( event->organizer() == KOPrefs::instance()->email() ) {
3415 emit organizerEventsSelected( true ); 3418 emit organizerEventsSelected( true );
3416 } else { 3419 } else {
3417 emit organizerEventsSelected(false); 3420 emit organizerEventsSelected(false);
3418 } 3421 }
3419 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3422 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3420 KOPrefs::instance()->email() ) ) { 3423 KOPrefs::instance()->email() ) ) {
3421 emit groupEventsSelected( true ); 3424 emit groupEventsSelected( true );
3422 } else { 3425 } else {
3423 emit groupEventsSelected(false); 3426 emit groupEventsSelected(false);
3424 } 3427 }
3425 return; 3428 return;
3426 } else { 3429 } else {
3427 if ( incidence && incidence->type() == "Todo" ) { 3430 if ( incidence && incidence->type() == "Todo" ) {
3428 emit todoSelected( true ); 3431 emit todoSelected( true );
3429 Todo *event = static_cast<Todo *>( incidence ); 3432 Todo *event = static_cast<Todo *>( incidence );
3430 if ( event->organizer() == KOPrefs::instance()->email() ) { 3433 if ( event->organizer() == KOPrefs::instance()->email() ) {
3431 emit organizerEventsSelected( true ); 3434 emit organizerEventsSelected( true );
3432 } else { 3435 } else {
3433 emit organizerEventsSelected(false); 3436 emit organizerEventsSelected(false);
3434 } 3437 }
3435 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, 3438 if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails,
3436 KOPrefs::instance()->email() ) ) { 3439 KOPrefs::instance()->email() ) ) {
3437 emit groupEventsSelected( true ); 3440 emit groupEventsSelected( true );
3438 } else { 3441 } else {
3439 emit groupEventsSelected(false); 3442 emit groupEventsSelected(false);
3440 } 3443 }
3441 return; 3444 return;
3442 } else { 3445 } else {
3443 emit todoSelected( false ); 3446 emit todoSelected( false );
3444 emit organizerEventsSelected(false); 3447 emit organizerEventsSelected(false);
3445 emit groupEventsSelected(false); 3448 emit groupEventsSelected(false);
3446 } 3449 }
3447 return; 3450 return;
3448 } 3451 }
3449 3452
3450 /* if ( incidence && incidence->type() == "Todo" ) { 3453 /* if ( incidence && incidence->type() == "Todo" ) {
3451 emit todoSelected( true ); 3454 emit todoSelected( true );
3452 } else { 3455 } else {
3453 emit todoSelected( false ); 3456 emit todoSelected( false );
3454 }*/ 3457 }*/
3455} 3458}
3456 3459
3457 3460
3458void CalendarView::checkClipboard() 3461void CalendarView::checkClipboard()
3459{ 3462{
3460#ifndef KORG_NODND 3463#ifndef KORG_NODND
3461 if (ICalDrag::canDecode(QApplication::clipboard()->data())) { 3464 if (ICalDrag::canDecode(QApplication::clipboard()->data())) {
3462 emit pasteEnabled(true); 3465 emit pasteEnabled(true);
3463 } else { 3466 } else {
3464 emit pasteEnabled(false); 3467 emit pasteEnabled(false);
3465 } 3468 }
3466#endif 3469#endif
3467} 3470}
3468 3471
3469void CalendarView::showDates(const DateList &selectedDates) 3472void CalendarView::showDates(const DateList &selectedDates)
3470{ 3473{
3471 // kdDebug() << "CalendarView::selectDates()" << endl; 3474 // kdDebug() << "CalendarView::selectDates()" << endl;
3472 3475
3473 3476
3474 if ( !mBlockShowDates ) { 3477 if ( !mBlockShowDates ) {
3475 if ( mViewManager->currentView() ) { 3478 if ( mViewManager->currentView() ) {
3476 updateView( selectedDates.first(), selectedDates.last() ); 3479 updateView( selectedDates.first(), selectedDates.last() );
3477 } else { 3480 } else {
3478 mViewManager->showAgendaView(); 3481 mViewManager->showAgendaView();
3479 } 3482 }
3480 } 3483 }
3481 3484
3482 QString selDates; 3485 QString selDates;
3483 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); 3486 selDates = KGlobal::locale()->formatDate( selectedDates.first(), true);
3484 if (selectedDates.first() < selectedDates.last() ) 3487 if (selectedDates.first() < selectedDates.last() )
3485 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); 3488 selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true);
3489 else {
3490 QString addString;
3491 if ( selectedDates.first() == QDateTime::currentDateTime().date() )
3492 addString = i18n("Today");
3493 else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(1) )
3494 addString = i18n("Tomorrow");
3495 else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) )
3496 addString = i18n("Yesterday");
3497 else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) )
3498 addString = i18n("Day before yesterday");
3499 else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(2) )
3500 addString = i18n("Day after tomorrow");
3501 if ( !addString.isEmpty() ) {
3502 topLevelWidget()->setCaption( addString+", " + selDates );
3503 return;
3504 }
3505 }
3486 topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); 3506 topLevelWidget()->setCaption( i18n("Dates: ") + selDates );
3487 3507
3488} 3508}
3489 3509
3490QPtrList<CalFilter> CalendarView::filters() 3510QPtrList<CalFilter> CalendarView::filters()
3491{ 3511{
3492 return mFilters; 3512 return mFilters;
3493 3513
3494} 3514}
3495void CalendarView::editFilters() 3515void CalendarView::editFilters()
3496{ 3516{
3497 // kdDebug() << "CalendarView::editFilters()" << endl; 3517 // kdDebug() << "CalendarView::editFilters()" << endl;
3498 3518
3499 CalFilter *filter = mFilters.first(); 3519 CalFilter *filter = mFilters.first();
3500 while(filter) { 3520 while(filter) {
3501 kdDebug() << " Filter: " << filter->name() << endl; 3521 kdDebug() << " Filter: " << filter->name() << endl;
3502 filter = mFilters.next(); 3522 filter = mFilters.next();
3503 } 3523 }
3504 3524
3505 mDialogManager->showFilterEditDialog(&mFilters); 3525 mDialogManager->showFilterEditDialog(&mFilters);
3506} 3526}
3507void CalendarView::toggleFilter() 3527void CalendarView::toggleFilter()
3508{ 3528{
3509 showFilter(! mFilterView->isVisible()); 3529 showFilter(! mFilterView->isVisible());
3510} 3530}
3511 3531
3512KOFilterView *CalendarView::filterView() 3532KOFilterView *CalendarView::filterView()
3513{ 3533{
3514 return mFilterView; 3534 return mFilterView;
3515} 3535}
3516void CalendarView::selectFilter( int fil ) 3536void CalendarView::selectFilter( int fil )
3517{ 3537{
3518 mFilterView->setSelectedFilter( fil ); 3538 mFilterView->setSelectedFilter( fil );
3519} 3539}
3520void CalendarView::showFilter(bool visible) 3540void CalendarView::showFilter(bool visible)
3521{ 3541{
3522 if (visible) mFilterView->show(); 3542 if (visible) mFilterView->show();
3523 else mFilterView->hide(); 3543 else mFilterView->hide();
3524} 3544}
3525void CalendarView::toggleFilerEnabled( ) 3545void CalendarView::toggleFilerEnabled( )
3526{ 3546{
3527 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); 3547 mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() );
3528 if ( !mFilterView->filtersEnabled() ) 3548 if ( !mFilterView->filtersEnabled() )
3529 topLevelWidget()->setCaption( i18n("Filter disabled ") ); 3549 topLevelWidget()->setCaption( i18n("Filter disabled ") );
3530 3550
3531} 3551}
3532void CalendarView::updateFilter() 3552void CalendarView::updateFilter()
3533{ 3553{
3534 CalFilter *filter = mFilterView->selectedFilter(); 3554 CalFilter *filter = mFilterView->selectedFilter();
3535 if (filter) { 3555 if (filter) {
3536 if (mFilterView->filtersEnabled()) { 3556 if (mFilterView->filtersEnabled()) {
3537 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); 3557 topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() );
3538 filter->setEnabled(true); 3558 filter->setEnabled(true);
3539 } 3559 }
3540 else filter->setEnabled(false); 3560 else filter->setEnabled(false);
3541 mCalendar->setFilter(filter); 3561 mCalendar->setFilter(filter);
3542 updateView(); 3562 updateView();
3543 } 3563 }
3544} 3564}
3545 3565
3546void CalendarView::filterEdited() 3566void CalendarView::filterEdited()
3547{ 3567{
3548 mFilterView->updateFilters(); 3568 mFilterView->updateFilters();
3549 updateFilter(); 3569 updateFilter();
3550 writeSettings(); 3570 writeSettings();
3551} 3571}
3552 3572
3553 3573
3554void CalendarView::takeOverEvent() 3574void CalendarView::takeOverEvent()
3555{ 3575{
3556 Incidence *incidence = currentSelection(); 3576 Incidence *incidence = currentSelection();
3557 3577
3558 if (!incidence) return; 3578 if (!incidence) return;
3559 3579
3560 incidence->setOrganizer(KOPrefs::instance()->email()); 3580 incidence->setOrganizer(KOPrefs::instance()->email());
3561 incidence->recreate(); 3581 incidence->recreate();
3562 incidence->setReadOnly(false); 3582 incidence->setReadOnly(false);
3563 3583
3564 updateView(); 3584 updateView();
3565} 3585}
3566 3586
3567void CalendarView::takeOverCalendar() 3587void CalendarView::takeOverCalendar()
3568{ 3588{
3569 // TODO: Create Calendar::allIncidences() function and use it here 3589 // TODO: Create Calendar::allIncidences() function and use it here
3570 3590
3571 QPtrList<Event> events = mCalendar->events(); 3591 QPtrList<Event> events = mCalendar->events();
3572 for(uint i=0; i<events.count(); ++i) { 3592 for(uint i=0; i<events.count(); ++i) {
3573 events.at(i)->setOrganizer(KOPrefs::instance()->email()); 3593 events.at(i)->setOrganizer(KOPrefs::instance()->email());
3574 events.at(i)->recreate(); 3594 events.at(i)->recreate();
3575 events.at(i)->setReadOnly(false); 3595 events.at(i)->setReadOnly(false);
3576 } 3596 }
3577 3597
3578 QPtrList<Todo> todos = mCalendar->todos(); 3598 QPtrList<Todo> todos = mCalendar->todos();
3579 for(uint i=0; i<todos.count(); ++i) { 3599 for(uint i=0; i<todos.count(); ++i) {
3580 todos.at(i)->setOrganizer(KOPrefs::instance()->email()); 3600 todos.at(i)->setOrganizer(KOPrefs::instance()->email());
3581 todos.at(i)->recreate(); 3601 todos.at(i)->recreate();
3582 todos.at(i)->setReadOnly(false); 3602 todos.at(i)->setReadOnly(false);
3583 } 3603 }
3584 3604
3585 QPtrList<Journal> journals = mCalendar->journals(); 3605 QPtrList<Journal> journals = mCalendar->journals();
3586 for(uint i=0; i<journals.count(); ++i) { 3606 for(uint i=0; i<journals.count(); ++i) {
3587 journals.at(i)->setOrganizer(KOPrefs::instance()->email()); 3607 journals.at(i)->setOrganizer(KOPrefs::instance()->email());
3588 journals.at(i)->recreate(); 3608 journals.at(i)->recreate();
3589 journals.at(i)->setReadOnly(false); 3609 journals.at(i)->setReadOnly(false);
3590 } 3610 }
3591 3611
3592 updateView(); 3612 updateView();
3593} 3613}
3594 3614
3595void CalendarView::showIntro() 3615void CalendarView::showIntro()
3596{ 3616{
3597 kdDebug() << "To be implemented." << endl; 3617 kdDebug() << "To be implemented." << endl;
3598} 3618}
3599 3619
3600QWidgetStack *CalendarView::viewStack() 3620QWidgetStack *CalendarView::viewStack()
3601{ 3621{
3602 return mRightFrame; 3622 return mRightFrame;
3603} 3623}
3604 3624
3605QWidget *CalendarView::leftFrame() 3625QWidget *CalendarView::leftFrame()
3606{ 3626{
3607 return mLeftFrame; 3627 return mLeftFrame;
3608} 3628}
3609 3629
3610DateNavigator *CalendarView::dateNavigator() 3630DateNavigator *CalendarView::dateNavigator()
3611{ 3631{
3612 return mNavigator; 3632 return mNavigator;
3613} 3633}
3614 3634
3615KDateNavigator* CalendarView::dateNavigatorWidget() 3635KDateNavigator* CalendarView::dateNavigatorWidget()
3616{ 3636{
3617 return mDateNavigator; 3637 return mDateNavigator;
3618} 3638}
3619void CalendarView::toggleDateNavigatorWidget() 3639void CalendarView::toggleDateNavigatorWidget()
3620{ 3640{
3621 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; 3641 KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ;
3622 if (!KOPrefs::instance()->mShowDateNavigator ) 3642 if (!KOPrefs::instance()->mShowDateNavigator )
3623 mDateNavigator->hide(); 3643 mDateNavigator->hide();
3624 else 3644 else
3625 mDateNavigator->show(); 3645 mDateNavigator->show();
3626} 3646}
3627void CalendarView::addView(KOrg::BaseView *view) 3647void CalendarView::addView(KOrg::BaseView *view)
3628{ 3648{
3629 mViewManager->addView(view); 3649 mViewManager->addView(view);
3630} 3650}
3631 3651
3632void CalendarView::showView(KOrg::BaseView *view) 3652void CalendarView::showView(KOrg::BaseView *view)
3633{ 3653{
3634 mViewManager->showView(view, mLeftFrame->isVisible()); 3654 mViewManager->showView(view, mLeftFrame->isVisible());
3635} 3655}
3636 3656
3637Incidence *CalendarView::currentSelection() 3657Incidence *CalendarView::currentSelection()
3638{ 3658{
3639 return mViewManager->currentSelection(); 3659 return mViewManager->currentSelection();
3640} 3660}
3641void CalendarView::toggleAllDaySize() 3661void CalendarView::toggleAllDaySize()
3642{ 3662{
3643 /* 3663 /*
3644 if ( KOPrefs::instance()->mAllDaySize > 47 ) 3664 if ( KOPrefs::instance()->mAllDaySize > 47 )
3645 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; 3665 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2;
3646 else 3666 else
3647 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; 3667 KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2;
3648 */ 3668 */
3649 viewManager()->agendaView()->toggleAllDay(); 3669 viewManager()->agendaView()->toggleAllDay();
3650} 3670}
3651void CalendarView::toggleExpand() 3671void CalendarView::toggleExpand()
3652{ 3672{
3653 // if ( mLeftFrame->isHidden() ) { 3673 // if ( mLeftFrame->isHidden() ) {
3654 // mLeftFrame->show(); 3674 // mLeftFrame->show();
3655 // emit calendarViewExpanded( false ); 3675 // emit calendarViewExpanded( false );
3656 // } else { 3676 // } else {
3657 // mLeftFrame->hide(); 3677 // mLeftFrame->hide();
3658 // emit calendarViewExpanded( true ); 3678 // emit calendarViewExpanded( true );
3659 // } 3679 // }
3660 3680
3661 globalFlagBlockAgenda = 1; 3681 globalFlagBlockAgenda = 1;
3662 emit calendarViewExpanded( !mLeftFrame->isHidden() ); 3682 emit calendarViewExpanded( !mLeftFrame->isHidden() );
3663 globalFlagBlockAgenda = 5; 3683 globalFlagBlockAgenda = 5;
3664 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); 3684 mViewManager->raiseCurrentView( !mLeftFrame->isHidden() );
3665 //mViewManager->showView( 0, true ); 3685 //mViewManager->showView( 0, true );
3666} 3686}
3667 3687
3668void CalendarView::calendarModified( bool modified, Calendar * ) 3688void CalendarView::calendarModified( bool modified, Calendar * )
3669{ 3689{
3670 setModified( modified ); 3690 setModified( modified );
3671} 3691}
3672 3692
3673Todo *CalendarView::selectedTodo() 3693Todo *CalendarView::selectedTodo()
3674{ 3694{
3675 Incidence *incidence = currentSelection(); 3695 Incidence *incidence = currentSelection();
3676 if ( incidence && incidence->type() == "Todo" ) { 3696 if ( incidence && incidence->type() == "Todo" ) {
3677 return static_cast<Todo *>( incidence ); 3697 return static_cast<Todo *>( incidence );
3678 } 3698 }
3679 3699
3680 incidence = mTodoList->selectedIncidences().first(); 3700 incidence = mTodoList->selectedIncidences().first();
3681 if ( incidence && incidence->type() == "Todo" ) { 3701 if ( incidence && incidence->type() == "Todo" ) {
3682 return static_cast<Todo *>( incidence ); 3702 return static_cast<Todo *>( incidence );
3683 } 3703 }
3684 3704
3685 return 0; 3705 return 0;
3686} 3706}
3687 3707
3688void CalendarView::dialogClosing(Incidence *in) 3708void CalendarView::dialogClosing(Incidence *in)
3689{ 3709{
3690 // mDialogList.remove(in); 3710 // mDialogList.remove(in);
3691} 3711}
3692 3712
3693void CalendarView::showIncidence() 3713void CalendarView::showIncidence()
3694{ 3714{
3695 Incidence *incidence = currentSelection(); 3715 Incidence *incidence = currentSelection();
3696 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3716 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3697 if ( incidence ) { 3717 if ( incidence ) {
3698 ShowIncidenceVisitor v; 3718 ShowIncidenceVisitor v;
3699 v.act( incidence, this ); 3719 v.act( incidence, this );
3700 } 3720 }
3701} 3721}
3702void CalendarView::editIncidenceDescription() 3722void CalendarView::editIncidenceDescription()
3703{ 3723{
3704 mFlagEditDescription = true; 3724 mFlagEditDescription = true;
3705 editIncidence(); 3725 editIncidence();
3706 mFlagEditDescription = false; 3726 mFlagEditDescription = false;
3707} 3727}
3708void CalendarView::editIncidence() 3728void CalendarView::editIncidence()
3709{ 3729{
3710 // qDebug("editIncidence() "); 3730 // qDebug("editIncidence() ");
3711 Incidence *incidence = currentSelection(); 3731 Incidence *incidence = currentSelection();
3712 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3732 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3713 if ( incidence ) { 3733 if ( incidence ) {
3714 EditIncidenceVisitor v; 3734 EditIncidenceVisitor v;
3715 v.act( incidence, this ); 3735 v.act( incidence, this );
3716 } 3736 }
3717} 3737}
3718 3738
3719void CalendarView::deleteIncidence() 3739void CalendarView::deleteIncidence()
3720{ 3740{
3721 Incidence *incidence = currentSelection(); 3741 Incidence *incidence = currentSelection();
3722 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3742 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3723 if ( incidence ) { 3743 if ( incidence ) {
3724 deleteIncidence(incidence); 3744 deleteIncidence(incidence);
3725 } 3745 }
3726} 3746}
3727 3747
3728void CalendarView::showIncidence(Incidence *incidence) 3748void CalendarView::showIncidence(Incidence *incidence)
3729{ 3749{
3730 if ( incidence ) { 3750 if ( incidence ) {
3731 ShowIncidenceVisitor v; 3751 ShowIncidenceVisitor v;
3732 v.act( incidence, this ); 3752 v.act( incidence, this );
3733 } 3753 }
3734} 3754}
3735 3755
3736void CalendarView::editIncidence(Incidence *incidence) 3756void CalendarView::editIncidence(Incidence *incidence)
3737{ 3757{
3738 if ( incidence ) { 3758 if ( incidence ) {
3739 3759
3740 EditIncidenceVisitor v; 3760 EditIncidenceVisitor v;
3741 v.act( incidence, this ); 3761 v.act( incidence, this );
3742 3762
3743 } 3763 }
3744} 3764}
3745 3765
3746void CalendarView::deleteIncidence(Incidence *incidence) 3766void CalendarView::deleteIncidence(Incidence *incidence)
3747{ 3767{
3748 //qDebug(" CalendarView::deleteIncidence "); 3768 //qDebug(" CalendarView::deleteIncidence ");
3749 if ( incidence ) { 3769 if ( incidence ) {
3750 DeleteIncidenceVisitor v; 3770 DeleteIncidenceVisitor v;
3751 v.act( incidence, this ); 3771 v.act( incidence, this );
3752 } 3772 }
3753} 3773}
3754 3774
3755 3775
3756void CalendarView::lookForOutgoingMessages() 3776void CalendarView::lookForOutgoingMessages()
3757{ 3777{
3758 OutgoingDialog *ogd = mDialogManager->outgoingDialog(); 3778 OutgoingDialog *ogd = mDialogManager->outgoingDialog();
3759 ogd->loadMessages(); 3779 ogd->loadMessages();
3760} 3780}
3761 3781
3762void CalendarView::lookForIncomingMessages() 3782void CalendarView::lookForIncomingMessages()
3763{ 3783{
3764 IncomingDialog *icd = mDialogManager->incomingDialog(); 3784 IncomingDialog *icd = mDialogManager->incomingDialog();
3765 icd->retrieve(); 3785 icd->retrieve();
3766} 3786}
3767 3787
3768bool CalendarView::removeCompletedSubTodos( Todo* t ) 3788bool CalendarView::removeCompletedSubTodos( Todo* t )
3769{ 3789{
3770 bool deleteTodo = true; 3790 bool deleteTodo = true;
3771 QPtrList<Incidence> subTodos; 3791 QPtrList<Incidence> subTodos;
3772 Incidence *aTodo; 3792 Incidence *aTodo;
3773 subTodos = t->relations(); 3793 subTodos = t->relations();
3774 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { 3794 for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) {
3775 if (! removeCompletedSubTodos( (Todo*) aTodo )) 3795 if (! removeCompletedSubTodos( (Todo*) aTodo ))
3776 deleteTodo = false; 3796 deleteTodo = false;
3777 } 3797 }
3778 if ( deleteTodo ) { 3798 if ( deleteTodo ) {
3779 if ( t->isCompleted() ) { 3799 if ( t->isCompleted() ) {
3780 checkExternalId( t ); 3800 checkExternalId( t );
3781 mCalendar->deleteTodo( t ); 3801 mCalendar->deleteTodo( t );
3782 changeTodoDisplay( t,KOGlobals::EVENTDELETED ); 3802 changeTodoDisplay( t,KOGlobals::EVENTDELETED );
3783 } 3803 }
3784 else 3804 else
3785 deleteTodo = false; 3805 deleteTodo = false;
3786 } 3806 }
3787 return deleteTodo; 3807 return deleteTodo;
3788 3808
3789} 3809}
3790void CalendarView::purgeCompleted() 3810void CalendarView::purgeCompleted()
3791{ 3811{
3792 int result = KMessageBox::warningContinueCancel(this, 3812 int result = KMessageBox::warningContinueCancel(this,
3793 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); 3813 i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge"));
3794 3814
3795 if (result == KMessageBox::Continue) { 3815 if (result == KMessageBox::Continue) {
3796 3816
3797 QPtrList<Todo> todoCal; 3817 QPtrList<Todo> todoCal;
3798 QPtrList<Todo> rootTodos; 3818 QPtrList<Todo> rootTodos;
3799 //QPtrList<Incidence> rel; 3819 //QPtrList<Incidence> rel;
3800 Todo *aTodo;//, *rTodo; 3820 Todo *aTodo;//, *rTodo;
3801 Incidence *rIncidence; 3821 Incidence *rIncidence;
3802 bool childDelete = false; 3822 bool childDelete = false;
3803 bool deletedOne = true; 3823 bool deletedOne = true;
3804 todoCal = calendar()->todos(); 3824 todoCal = calendar()->todos();
3805 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { 3825 for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) {
3806 if ( !aTodo->relatedTo() ) 3826 if ( !aTodo->relatedTo() )
3807 rootTodos.append( aTodo ); 3827 rootTodos.append( aTodo );
3808 } 3828 }
3809 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { 3829 for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) {
3810 removeCompletedSubTodos( aTodo ); 3830 removeCompletedSubTodos( aTodo );
3811 } 3831 }
3812 3832
3813 updateView(); 3833 updateView();
3814 } 3834 }
3815} 3835}
3816 3836
3817void CalendarView::slotCalendarChanged() 3837void CalendarView::slotCalendarChanged()
3818{ 3838{
3819 ; 3839 ;
3820} 3840}
3821 3841
3822NavigatorBar *CalendarView::navigatorBar() 3842NavigatorBar *CalendarView::navigatorBar()
3823{ 3843{
3824 return mNavigatorBar; 3844 return mNavigatorBar;
3825} 3845}
3826 3846
3827 3847
3828 3848
3829void CalendarView::keyPressEvent ( QKeyEvent *e) 3849void CalendarView::keyPressEvent ( QKeyEvent *e)
3830{ 3850{
3831 //qDebug(" alendarView::keyPressEvent "); 3851 //qDebug(" alendarView::keyPressEvent ");
3832 e->ignore(); 3852 e->ignore();
3833} 3853}
3834 3854
3835 3855
3836bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) 3856bool CalendarView::sync(KSyncManager* manager, QString filename, int mode)
3837{ 3857{
3838 // mSyncManager = manager; 3858 // mSyncManager = manager;
3839 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { 3859 if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) {
3840 qDebug("SyncKDE request detected!"); 3860 qDebug("SyncKDE request detected!");
3841 } 3861 }
3842 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 3862 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
3843 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 3863 mCurrentSyncName = mSyncManager->getCurrentSyncName();
3844 return syncCalendar( filename, mode ); 3864 return syncCalendar( filename, mode );
3845} 3865}
3846bool CalendarView::syncExternal(KSyncManager* manager, QString resource) 3866bool CalendarView::syncExternal(KSyncManager* manager, QString resource)
3847{ 3867{
3848 //mSyncManager = manager; 3868 //mSyncManager = manager;
3849 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); 3869 mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice();
3850 mCurrentSyncName = mSyncManager->getCurrentSyncName(); 3870 mCurrentSyncName = mSyncManager->getCurrentSyncName();
3851 if ( resource == "sharp" ) 3871 if ( resource == "sharp" )
3852 syncExternal( 0 ); 3872 syncExternal( 0 );
3853 if ( resource == "phone" ) 3873 if ( resource == "phone" )
3854 syncExternal( 1 ); 3874 syncExternal( 1 );
3855 // pending setmodified 3875 // pending setmodified
3856 return true; 3876 return true;
3857} 3877}
3858void CalendarView::setSyncManager(KSyncManager* manager) 3878void CalendarView::setSyncManager(KSyncManager* manager)
3859{ 3879{
3860 mSyncManager = manager; 3880 mSyncManager = manager;
3861} 3881}
3862 3882
3863void CalendarView::removeSyncInfo( QString syncProfile) 3883void CalendarView::removeSyncInfo( QString syncProfile)
3864{ 3884{
3865 qDebug("removeSyncInfo for profile %s ", syncProfile.latin1()); 3885 qDebug("removeSyncInfo for profile %s ", syncProfile.latin1());
3866 mCalendar->removeSyncInfo( syncProfile ); 3886 mCalendar->removeSyncInfo( syncProfile );
3867 3887
3868} 3888}
3869 3889
3870void CalendarView::undo_delete() 3890void CalendarView::undo_delete()
3871{ 3891{
3872 //qDebug("undo_delete() "); 3892 //qDebug("undo_delete() ");
3873 Incidence* undo = mCalendar->undoIncidence(); 3893 Incidence* undo = mCalendar->undoIncidence();
3874 if ( !undo ) { 3894 if ( !undo ) {
3875 KMessageBox::sorry(this,i18n("There is nothing to undo!"), 3895 KMessageBox::sorry(this,i18n("There is nothing to undo!"),
3876 i18n("KO/Pi")); 3896 i18n("KO/Pi"));
3877 return; 3897 return;
3878 } 3898 }
3879 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + 3899 if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) +
3880 i18n("\nAre you sure you want\nto restore this?"), 3900 i18n("\nAre you sure you want\nto restore this?"),
3881 i18n("KO/Pi Confirmation"),i18n("Restore"))) { 3901 i18n("KO/Pi Confirmation"),i18n("Restore"))) {
3882 mCalendar->undoDeleteIncidence(); 3902 mCalendar->undoDeleteIncidence();
3883 updateView(); 3903 updateView();
3884 } 3904 }
3885} 3905}
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index e27da9a..c8d6bdd 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -1,610 +1,610 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000, 2001 3 Copyright (c) 2000, 2001
4 Cornelius Schumacher <schumacher@kde.org> 4 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This program is free software; you can redistribute it and/or modify 6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 9 (at your option) any later version.
10 10
11 This program is distributed in the hope that it will be useful, 11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 19
20 As a special exception, permission is given to link this program 20 As a special exception, permission is given to link this program
21 with any edition of Qt, and distribute the resulting executable, 21 with any edition of Qt, and distribute the resulting executable,
22 without including the source code for Qt in the source distribution. 22 without including the source code for Qt in the source distribution.
23*/ 23*/
24#ifndef CALENDARVIEW_H 24#ifndef CALENDARVIEW_H
25#define CALENDARVIEW_H 25#define CALENDARVIEW_H
26 26
27#include <qframe.h> 27#include <qframe.h>
28#include <qlayout.h> 28#include <qlayout.h>
29#include <qwidget.h> 29#include <qwidget.h>
30#include <qptrlist.h> 30#include <qptrlist.h>
31#include <qvbox.h> 31#include <qvbox.h>
32#include <qmap.h> 32#include <qmap.h>
33#ifndef DESKTOP_VERSION 33#ifndef DESKTOP_VERSION
34#include <qtopia/ir.h> 34#include <qtopia/ir.h>
35#else 35#else
36#define Ir char 36#define Ir char
37#endif 37#endif
38#include <libkcal/calendar.h> 38#include <libkcal/calendar.h>
39#include <libkcal/scheduler.h> 39#include <libkcal/scheduler.h>
40#include <libkcal/calendarresources.h> 40#include <libkcal/calendarresources.h>
41#include <libkcal/resourcecalendar.h> 41#include <libkcal/resourcecalendar.h>
42 42
43#include <korganizer/calendarviewbase.h> 43#include <korganizer/calendarviewbase.h>
44 44
45#include <ksyncmanager.h> 45#include <ksyncmanager.h>
46 46
47class QWidgetStack; 47class QWidgetStack;
48class QSplitter; 48class QSplitter;
49 49
50class CalPrinter; 50class CalPrinter;
51class KOFilterView; 51class KOFilterView;
52class KOViewManager; 52class KOViewManager;
53class KODialogManager; 53class KODialogManager;
54class KOTodoView; 54class KOTodoView;
55class KDateNavigator; 55class KDateNavigator;
56class DateNavigator; 56class DateNavigator;
57class KOIncidenceEditor; 57class KOIncidenceEditor;
58class KDatePicker; 58class KDatePicker;
59class ResourceView; 59class ResourceView;
60class NavigatorBar; 60class NavigatorBar;
61class KOEventEditor; 61class KOEventEditor;
62class KOTodoEditor ; 62class KOTodoEditor ;
63class KOEventViewerDialog; 63class KOEventViewerDialog;
64class KOBeamPrefs; 64class KOBeamPrefs;
65class KSyncProfile; 65class KSyncProfile;
66class AlarmDialog; 66class AlarmDialog;
67class KCal::Attendee; 67class KCal::Attendee;
68 68
69namespace KCal { class FileStorage; } 69namespace KCal { class FileStorage; }
70 70
71using namespace KCal; 71using namespace KCal;
72 72
73/** 73/**
74 This is the main calendar widget. It provides the different vies on t he 74 This is the main calendar widget. It provides the different vies on t he
75 calendar data as well as the date navigator. It also handles synchronisation 75 calendar data as well as the date navigator. It also handles synchronisation
76 of the different views and controls the different dialogs like preferences, 76 of the different views and controls the different dialogs like preferences,
77 event editor, search dialog etc. 77 event editor, search dialog etc.
78 78
79 @short main calendar view widget 79 @short main calendar view widget
80 @author Cornelius Schumacher 80 @author Cornelius Schumacher
81*/ 81*/
82class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface 82class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer, public KSyncInterface
83{ 83{
84 Q_OBJECT 84 Q_OBJECT
85 public: 85 public:
86 /** 86 /**
87 Constructs a new calendar view widget. 87 Constructs a new calendar view widget.
88 88
89 @param calendar calendar document 89 @param calendar calendar document
90 @param parent parent window 90 @param parent parent window
91 @param name Qt internal widget object name 91 @param name Qt internal widget object name
92 */ 92 */
93 CalendarView( CalendarResources *calendar, QWidget *parent = 0, 93 CalendarView( CalendarResources *calendar, QWidget *parent = 0,
94 const char *name = 0 ); 94 const char *name = 0 );
95 CalendarView( Calendar *calendar, QWidget *parent = 0, 95 CalendarView( Calendar *calendar, QWidget *parent = 0,
96 const char *name = 0 ); 96 const char *name = 0 );
97 virtual ~CalendarView(); 97 virtual ~CalendarView();
98 98
99 Calendar *calendar() { return mCalendar; } 99 Calendar *calendar() { return mCalendar; }
100 100
101 KOViewManager *viewManager(); 101 KOViewManager *viewManager();
102 KODialogManager *dialogManager(); 102 KODialogManager *dialogManager();
103 103
104 QDate startDate(); 104 QDate startDate();
105 QDate endDate(); 105 QDate endDate();
106 106
107 QWidgetStack *viewStack(); 107 QWidgetStack *viewStack();
108 QWidget *leftFrame(); 108 QWidget *leftFrame();
109 NavigatorBar *navigatorBar(); 109 NavigatorBar *navigatorBar();
110 110
111 DateNavigator *dateNavigator(); 111 DateNavigator *dateNavigator();
112 KDateNavigator *dateNavigatorWidget(); 112 KDateNavigator *dateNavigatorWidget();
113 113
114 void addView(KOrg::BaseView *); 114 void addView(KOrg::BaseView *);
115 void showView(KOrg::BaseView *); 115 void showView(KOrg::BaseView *);
116 KOEventViewerDialog* getEventViewerDialog(); 116 KOEventViewerDialog* getEventViewerDialog();
117 Incidence *currentSelection(); 117 Incidence *currentSelection();
118 118
119 signals: 119 signals:
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 = false); 228 void newEvent(QDateTime, QDateTime, bool allDay = false);
229 void newEvent(QDateTime fh); 229 void newEvent(QDateTime fh);
230 void newEvent(QDate dt); 230 void newEvent(QDate dt);
231 /** create new event without having a date hint. Takes current date as 231 /** create new event without having a date hint. Takes current date as
232 default hint. */ 232 default hint. */
233 void newEvent(); 233 void newEvent();
234 void newFloatingEvent(); 234 void newFloatingEvent();
235 235
236 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ 236 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/
237 void showIncidence(Incidence *); 237 void showIncidence(Incidence *);
238 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ 238 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/
239 void editIncidence(Incidence *); 239 void editIncidence(Incidence *);
240 /** Delete the supplied incidence. It calls the correct deleteXXX method*/ 240 /** Delete the supplied incidence. It calls the correct deleteXXX method*/
241 void deleteIncidence(Incidence *); 241 void deleteIncidence(Incidence *);
242 void cloneIncidence(Incidence *); 242 void cloneIncidence(Incidence *);
243 void cancelIncidence(Incidence *); 243 void cancelIncidence(Incidence *);
244 /** Create an editor for the supplied event. */ 244 /** Create an editor for the supplied event. */
245 void editEvent(Event *); 245 void editEvent(Event *);
246 /** Delete the supplied event. */ 246 /** Delete the supplied event. */
247 void deleteEvent(Event *); 247 void deleteEvent(Event *);
248 /** Delete the event with the given unique ID. Returns false, if event wasn't 248 /** Delete the event with the given unique ID. Returns false, if event wasn't
249 found. */ 249 found. */
250 bool deleteEvent(const QString &uid); 250 bool deleteEvent(const QString &uid);
251 /** Create a read-only viewer dialog for the supplied event. */ 251 /** Create a read-only viewer dialog for the supplied event. */
252 void showEvent(Event *); 252 void showEvent(Event *);
253 253
254 void editJournal(Journal *); 254 void editJournal(Journal *);
255 void showJournal(Journal *); 255 void showJournal(Journal *);
256 void deleteJournal(Journal *); 256 void deleteJournal(Journal *);
257 /** Create an editor dialog for a todo */ 257 /** Create an editor dialog for a todo */
258 void editTodo(Todo *); 258 void editTodo(Todo *);
259 /** Create a read-only viewer dialog for the supplied todo */ 259 /** Create a read-only viewer dialog for the supplied todo */
260 void showTodo(Todo *); 260 void showTodo(Todo *);
261 /** create new todo */ 261 /** create new todo */
262 void newTodo(); 262 void newTodo();
263 /** create new todo with a parent todo */ 263 /** create new todo with a parent todo */
264 void newSubTodo(); 264 void newSubTodo();
265 /** create new todo with a parent todo */ 265 /** create new todo with a parent todo */
266 void newSubTodo(Todo *); 266 void newSubTodo(Todo *);
267 /** Delete todo */ 267 /** Delete todo */
268 void deleteTodo(Todo *); 268 void deleteTodo(Todo *);
269 269
270 270
271 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is 271 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is
272 * emitted as result. */ 272 * emitted as result. */
273 void checkClipboard(); 273 void checkClipboard();
274 274
275 /** using the KConfig associated with the kapp variable, read in the 275 /** using the KConfig associated with the kapp variable, read in the
276 * settings from the config file. 276 * settings from the config file.
277 */ 277 */
278 void readSettings(); 278 void readSettings();
279 279
280 /** write current state to config file. */ 280 /** write current state to config file. */
281 void writeSettings(); 281 void writeSettings();
282 282
283 /** read settings for calendar filters */ 283 /** read settings for calendar filters */
284 void readFilterSettings(KConfig *config); 284 void readFilterSettings(KConfig *config);
285 285
286 /** write settings for calendar filters */ 286 /** write settings for calendar filters */
287 void writeFilterSettings(KConfig *config); 287 void writeFilterSettings(KConfig *config);
288 288
289 /** passes on the message that an event has changed to the currently 289 /** passes on the message that an event has changed to the currently
290 * activated view so that it can make appropriate display changes. */ 290 * activated view so that it can make appropriate display changes. */
291 void changeEventDisplay(Event *, int); 291 void changeEventDisplay(Event *, int);
292 void changeIncidenceDisplay(Incidence *, int); 292 void changeIncidenceDisplay(Incidence *, int);
293 void changeTodoDisplay(Todo *, int); 293 void changeTodoDisplay(Todo *, int);
294 294
295 void eventAdded(Event *); 295 void eventAdded(Event *);
296 void eventChanged(Event *); 296 void eventChanged(Event *);
297 void eventToBeDeleted(Event *); 297 void eventToBeDeleted(Event *);
298 void eventDeleted(); 298 void eventDeleted();
299 299
300 void todoAdded(Todo *); 300 void todoAdded(Todo *);
301 void todoChanged(Todo *); 301 void todoChanged(Todo *);
302 void todoToBeDeleted(Todo *); 302 void todoToBeDeleted(Todo *);
303 void todoDeleted(); 303 void todoDeleted();
304 304
305 void updateView(const QDate &start, const QDate &end); 305 void updateView(const QDate &start, const QDate &end);
306 void updateView(); 306 void updateView();
307 307
308 /** Full update of visible todo views */ 308 /** Full update of visible todo views */
309 void updateTodoViews(); 309 void updateTodoViews();
310 310
311 void updateUnmanagedViews(); 311 void updateUnmanagedViews();
312 312
313 /** cut the current appointment to the clipboard */ 313 /** cut the current appointment to the clipboard */
314 void edit_cut(); 314 void edit_cut();
315 315
316 /** copy the current appointment(s) to the clipboard */ 316 /** copy the current appointment(s) to the clipboard */
317 void edit_copy(); 317 void edit_copy();
318 318
319 /** paste the current vobject(s) in the clipboard buffer into calendar */ 319 /** paste the current vobject(s) in the clipboard buffer into calendar */
320 void edit_paste(); 320 void edit_paste();
321 321
322 /** edit viewing and configuration options. */ 322 /** edit viewing and configuration options. */
323 void edit_options(); 323 void edit_options();
324 /** 324 /**
325 Functions for printing, previewing a print, and setting up printing 325 Functions for printing, previewing a print, and setting up printing
326 parameters. 326 parameters.
327 */ 327 */
328 void print(); 328 void print();
329 void printSetup(); 329 void printSetup();
330 void printPreview(); 330 void printPreview();
331 331
332 /** Export as iCalendar file */ 332 /** Export as iCalendar file */
333 void exportICalendar(); 333 void exportICalendar();
334 334
335 /** Export as vCalendar file */ 335 /** Export as vCalendar file */
336 bool exportVCalendar( QString fn); 336 bool exportVCalendar( QString fn);
337 337
338 /** pop up a dialog to show an existing appointment. */ 338 /** pop up a dialog to show an existing appointment. */
339 void appointment_show(); 339 void appointment_show();
340 /** 340 /**
341 * pop up an Appointment Dialog to edit an existing appointment.Get 341 * pop up an Appointment Dialog to edit an existing appointment.Get
342 * information on the appointment from the list of unique IDs that is 342 * information on the appointment from the list of unique IDs that is
343 * currently in the View, called currIds. 343 * currently in the View, called currIds.
344 */ 344 */
345 void appointment_edit(); 345 void appointment_edit();
346 /** 346 /**
347 * pop up dialog confirming deletion of currently selected event in the 347 * pop up dialog confirming deletion of currently selected event in the
348 * View. 348 * View.
349 */ 349 */
350 void appointment_delete(); 350 void appointment_delete();
351 351
352 /** mails the currently selected event to a particular user as a vCalendar 352 /** mails the currently selected event to a particular user as a vCalendar
353 attachment. */ 353 attachment. */
354 void action_mail(); 354 void action_mail();
355 355
356 /* frees a subtodo from it's relation */ 356 /* frees a subtodo from it's relation */
357 void todo_unsub( Todo * ); 357 void todo_unsub( Todo * );
358 void todo_resub( Todo * parent, Todo * sub ); 358 void todo_resub( Todo * parent, Todo * sub );
359 359
360 /** Take ownership of selected event. */ 360 /** Take ownership of selected event. */
361 void takeOverEvent(); 361 void takeOverEvent();
362 362
363 /** Take ownership of all events in calendar. */ 363 /** Take ownership of all events in calendar. */
364 void takeOverCalendar(); 364 void takeOverCalendar();
365 365
366 /** query whether or not the calendar is "dirty". */ 366 /** query whether or not the calendar is "dirty". */
367 bool isModified(); 367 bool isModified();
368 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ 368 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */
369 void setModified(bool modified=true); 369 void setModified(bool modified=true);
370 370
371 /** query if the calendar is read-only. */ 371 /** query if the calendar is read-only. */
372 bool isReadOnly(); 372 bool isReadOnly();
373 /** set state of calendar to read-only */ 373 /** set state of calendar to read-only */
374 void setReadOnly(bool readOnly=true); 374 void setReadOnly(bool readOnly=true);
375 375
376 void eventUpdated(Incidence *); 376 void eventUpdated(Incidence *);
377 377
378 /* iTIP scheduling actions */ 378 /* iTIP scheduling actions */
379 void schedule_publish(Incidence *incidence = 0); 379 void schedule_publish(Incidence *incidence = 0);
380 void schedule_request(Incidence *incidence = 0); 380 void schedule_request(Incidence *incidence = 0);
381 void schedule_refresh(Incidence *incidence = 0); 381 void schedule_refresh(Incidence *incidence = 0);
382 void schedule_cancel(Incidence *incidence = 0); 382 void schedule_cancel(Incidence *incidence = 0);
383 void schedule_add(Incidence *incidence = 0); 383 void schedule_add(Incidence *incidence = 0);
384 void schedule_reply(Incidence *incidence = 0); 384 void schedule_reply(Incidence *incidence = 0);
385 void schedule_counter(Incidence *incidence = 0); 385 void schedule_counter(Incidence *incidence = 0);
386 void schedule_declinecounter(Incidence *incidence = 0); 386 void schedule_declinecounter(Incidence *incidence = 0);
387 void schedule_publish_freebusy(int daysToPublish = 30); 387 void schedule_publish_freebusy(int daysToPublish = 30);
388 388
389 void openAddressbook(); 389 void openAddressbook();
390 390
391 void editFilters(); 391 void editFilters();
392 void toggleFilerEnabled(); 392 void toggleFilerEnabled();
393 QPtrList<CalFilter> filters(); 393 QPtrList<CalFilter> filters();
394 void toggleFilter(); 394 void toggleFilter();
395 void showFilter(bool visible); 395 void showFilter(bool visible);
396 void updateFilter(); 396 void updateFilter();
397 void filterEdited(); 397 void filterEdited();
398 void selectFilter( int ); 398 void selectFilter( int );
399 KOFilterView *filterView(); 399 KOFilterView *filterView();
400 400
401 void showIntro(); 401 void showIntro();
402 402
403 /** Move the curdatepient view date to today */ 403 /** Move the curdatepient view date to today */
404 void goToday(); 404 void goToday();
405 405
406 /** Move to the next date(s) in the current view */ 406 /** Move to the next date(s) in the current view */
407 void goNext(); 407 void goNext();
408 408
409 /** Move to the previous date(s) in the current view */ 409 /** Move to the previous date(s) in the current view */
410 void goPrevious(); 410 void goPrevious();
411 /** Move to the next date(s) in the current view */ 411 /** Move to the next date(s) in the current view */
412 void goNextMonth(); 412 void goNextMonth();
413 413
414 /** Move to the previous date(s) in the current view */ 414 /** Move to the previous date(s) in the current view */
415 void goPreviousMonth(); 415 void goPreviousMonth();
416 416
417 void toggleExpand(); 417 void toggleExpand();
418 void toggleDateNavigatorWidget(); 418 void toggleDateNavigatorWidget();
419 void toggleAllDaySize(); 419 void toggleAllDaySize();
420 void dialogClosing(Incidence *); 420 void dialogClosing(Incidence *);
421 421
422 /** Look for new messages in the inbox */ 422 /** Look for new messages in the inbox */
423 void lookForIncomingMessages(); 423 void lookForIncomingMessages();
424 /** Look for new messages in the outbox */ 424 /** Look for new messages in the outbox */
425 void lookForOutgoingMessages(); 425 void lookForOutgoingMessages();
426 426
427 void processMainViewSelection( Incidence * ); 427 void processMainViewSelection( Incidence * );
428 void processTodoListSelection( Incidence * ); 428 void processTodoListSelection( Incidence * );
429 429
430 void processIncidenceSelection( Incidence * ); 430 void processIncidenceSelection( Incidence * );
431 431
432 void purgeCompleted(); 432 void purgeCompleted();
433 bool removeCompletedSubTodos( Todo* ); 433 bool removeCompletedSubTodos( Todo* );
434 void slotCalendarChanged(); 434 void slotCalendarChanged();
435 bool importBday(); 435 bool importBday();
436 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); 436 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday );
437 bool importQtopia( const QString &categoriesFile, 437 bool importQtopia( const QString &categoriesFile,
438 const QString &datebookFile, 438 const QString &datebookFile,
439 const QString &tasklistFile ); 439 const QString &tasklistFile );
440 void syncExternal( int mode ); 440 void syncExternal( int mode );
441 void slotSelectPickerDate( QDate ) ; 441 void slotSelectPickerDate( QDate ) ;
442 void showDatePicker( ) ; 442 void showDatePicker( ) ;
443 void moveIncidence(Incidence *) ; 443 void moveIncidence(Incidence *) ;
444 void beamIncidence(Incidence *) ; 444 void beamIncidence(Incidence *) ;
445 void beamCalendar() ; 445 void beamCalendar() ;
446 void beamFilteredCalendar() ; 446 void beamFilteredCalendar() ;
447 void beamIncidenceList(QPtrList<Incidence>) ; 447 void beamIncidenceList(QPtrList<Incidence>) ;
448 void manageCategories(); 448 void manageCategories();
449 int addCategories(); 449 int addCategories();
450 void removeCategories(); 450 void removeCategories();
451 void setSyncDevice( QString ); 451 void setSyncDevice( QString );
452 void setSyncName( QString ); 452 void setSyncName( QString );
453 void showDay( QDate ); 453 void showDay( QDate );
454 void undo_delete(); 454 void undo_delete();
455 protected slots: 455 protected slots:
456 void timerAlarm(); 456 void timerAlarm();
457 void suspendAlarm(); 457 void suspendAlarm();
458 void beamDone( Ir *ir ); 458 void beamDone( Ir *ir );
459 /** Select a view or adapt the current view to display the specified dates. */ 459 /** Select a view or adapt the current view to display the specified dates. */
460 void showDates( const KCal::DateList & ); 460 void showDates( const KCal::DateList & );
461 void selectWeekNum ( int ); 461 void selectWeekNum ( int );
462 462
463 public: 463 public:
464 // show a standard warning 464 // show a standard warning
465 // returns KMsgBox::yesNoCancel() 465 // returns KMsgBox::yesNoCancel()
466 int msgCalModified(); 466 int msgCalModified();
467 virtual bool sync(KSyncManager* manager, QString filename, int mode); 467 virtual bool sync(KSyncManager* manager, QString filename, int mode);
468 468
469 virtual bool syncExternal(KSyncManager* manager, QString resource); 469 virtual bool syncExternal(KSyncManager* manager, QString resource);
470 virtual void removeSyncInfo( QString syncProfile); 470 virtual void removeSyncInfo( QString syncProfile);
471 void setSyncManager(KSyncManager* manager); 471 void setSyncManager(KSyncManager* manager);
472 void setLoadedFileVersion(QDateTime); 472 void setLoadedFileVersion(QDateTime);
473 bool checkFileVersion(QString fn); 473 bool checkFileVersion(QString fn);
474 bool checkFileChanged(QString fn); 474 bool checkFileChanged(QString fn);
475 Event* getLastSyncEvent(); 475 Event* getLastSyncEvent();
476 /** Adapt navigation units correpsonding to step size of navigation of the 476 /** Adapt navigation units correpsonding to step size of navigation of the
477 * current view. 477 * current view.
478 */ 478 */
479 void adaptNavigationUnits(); 479 void adaptNavigationUnits();
480 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); 480 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode );
481 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); 481 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false );
482 //Attendee* getYourAttendee(Event *event); 482 //Attendee* getYourAttendee(Event *event);
483 void setBlockShowDates( bool b ) { mBlockShowDates = b ;} 483 void setBlockShowDates( bool b ) { mBlockShowDates = b ;}
484 protected: 484 protected:
485 void schedule(Scheduler::Method, Incidence *incidence = 0); 485 void schedule(Scheduler::Method, Incidence *incidence = 0);
486 486
487 // returns KMsgBox::OKCandel() 487 // returns KMsgBox::OKCandel()
488 int msgItemDelete(); 488 int msgItemDelete(const QString name);
489 void showEventEditor(); 489 void showEventEditor();
490 void showTodoEditor(); 490 void showTodoEditor();
491 void writeLocale(); 491 void writeLocale();
492 Todo *selectedTodo(); 492 Todo *selectedTodo();
493 493
494 private: 494 private:
495 bool mBlockShowDates; 495 bool mBlockShowDates;
496 KSyncManager* mSyncManager; 496 KSyncManager* mSyncManager;
497 AlarmDialog * mAlarmDialog; 497 AlarmDialog * mAlarmDialog;
498 QString mAlarmNotification; 498 QString mAlarmNotification;
499 QString mSuspendAlarmNotification; 499 QString mSuspendAlarmNotification;
500 QTimer* mSuspendTimer; 500 QTimer* mSuspendTimer;
501 QTimer* mAlarmTimer; 501 QTimer* mAlarmTimer;
502 QTimer* mRecheckAlarmTimer; 502 QTimer* mRecheckAlarmTimer;
503 void computeAlarm( QString ); 503 void computeAlarm( QString );
504 void startAlarm( QString, QString ); 504 void startAlarm( QString, QString );
505 void setSyncEventsReadOnly(); 505 void setSyncEventsReadOnly();
506 506
507 QDateTime loadedFileVersion; 507 QDateTime loadedFileVersion;
508 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); 508 void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete );
509 void checkExternalId( Incidence * inc ); 509 void checkExternalId( Incidence * inc );
510 int mGlobalSyncMode; 510 int mGlobalSyncMode;
511 QString mCurrentSyncDevice; 511 QString mCurrentSyncDevice;
512 QString mCurrentSyncName; 512 QString mCurrentSyncName;
513 KOBeamPrefs* beamDialog; 513 KOBeamPrefs* beamDialog;
514 void init(); 514 void init();
515 int mDatePickerMode; 515 int mDatePickerMode;
516 bool mFlagEditDescription; 516 bool mFlagEditDescription;
517 QDateTime mLastCalendarSync; 517 QDateTime mLastCalendarSync;
518 void createPrinter(); 518 void createPrinter();
519 519
520 void calendarModified( bool, Calendar * ); 520 void calendarModified( bool, Calendar * );
521 521
522 CalPrinter *mCalPrinter; 522 CalPrinter *mCalPrinter;
523 523
524 QSplitter *mPanner; 524 QSplitter *mPanner;
525 QSplitter *mLeftSplitter; 525 QSplitter *mLeftSplitter;
526 QWidget *mLeftFrame; 526 QWidget *mLeftFrame;
527 QWidgetStack *mRightFrame; 527 QWidgetStack *mRightFrame;
528 528
529 KDatePicker* mDatePicker; 529 KDatePicker* mDatePicker;
530 QVBox* mDateFrame; 530 QVBox* mDateFrame;
531 NavigatorBar *mNavigatorBar; 531 NavigatorBar *mNavigatorBar;
532 532
533 KDateNavigator *mDateNavigator; // widget showing small month view. 533 KDateNavigator *mDateNavigator; // widget showing small month view.
534 534
535 KOFilterView *mFilterView; 535 KOFilterView *mFilterView;
536 536
537 ResourceView *mResourceView; 537 ResourceView *mResourceView;
538 538
539 // calendar object for this viewing instance 539 // calendar object for this viewing instance
540 Calendar *mCalendar; 540 Calendar *mCalendar;
541 541
542 CalendarResourceManager *mResourceManager; 542 CalendarResourceManager *mResourceManager;
543 543
544 FileStorage *mStorage; 544 FileStorage *mStorage;
545 545
546 DateNavigator *mNavigator; 546 DateNavigator *mNavigator;
547 547
548 KOViewManager *mViewManager; 548 KOViewManager *mViewManager;
549 KODialogManager *mDialogManager; 549 KODialogManager *mDialogManager;
550 550
551 // Calendar filters 551 // Calendar filters
552 QPtrList<CalFilter> mFilters; 552 QPtrList<CalFilter> mFilters;
553 553
554 // various housekeeping variables. 554 // various housekeeping variables.
555 bool mModified; // flag indicating if calendar is modified 555 bool mModified; // flag indicating if calendar is modified
556 bool mReadOnly; // flag indicating if calendar is read-only 556 bool mReadOnly; // flag indicating if calendar is read-only
557 QDate mSaveSingleDate; 557 QDate mSaveSingleDate;
558 558
559 Incidence *mSelectedIncidence; 559 Incidence *mSelectedIncidence;
560 Incidence *mMoveIncidence; 560 Incidence *mMoveIncidence;
561 QDate mMoveIncidenceOldDate; 561 QDate mMoveIncidenceOldDate;
562 KOTodoView *mTodoList; 562 KOTodoView *mTodoList;
563 KOEventEditor * mEventEditor; 563 KOEventEditor * mEventEditor;
564 KOTodoEditor * mTodoEditor; 564 KOTodoEditor * mTodoEditor;
565 KOEventViewerDialog * mEventViewerDialog; 565 KOEventViewerDialog * mEventViewerDialog;
566 void keyPressEvent ( QKeyEvent *e) ; 566 void keyPressEvent ( QKeyEvent *e) ;
567 //QMap<Incidence*,KOIncidenceEditor*> mDialogList; 567 //QMap<Incidence*,KOIncidenceEditor*> mDialogList;
568}; 568};
569 569
570 570
571class CalendarViewVisitor : public Incidence::Visitor 571class CalendarViewVisitor : public Incidence::Visitor
572{ 572{
573 public: 573 public:
574 CalendarViewVisitor() : mView( 0 ) {} 574 CalendarViewVisitor() : mView( 0 ) {}
575 575
576 bool act( Incidence *incidence, CalendarView *view ) 576 bool act( Incidence *incidence, CalendarView *view )
577 { 577 {
578 mView = view; 578 mView = view;
579 return incidence->accept( *this ); 579 return incidence->accept( *this );
580 } 580 }
581 581
582 protected: 582 protected:
583 CalendarView *mView; 583 CalendarView *mView;
584}; 584};
585 585
586class ShowIncidenceVisitor : public CalendarViewVisitor 586class ShowIncidenceVisitor : public CalendarViewVisitor
587{ 587{
588 protected: 588 protected:
589 bool visit( Event *event ) { mView->showEvent( event ); return true; } 589 bool visit( Event *event ) { mView->showEvent( event ); return true; }
590 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } 590 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; }
591 bool visit( Journal * j ) { mView->showJournal( j );return true; } 591 bool visit( Journal * j ) { mView->showJournal( j );return true; }
592}; 592};
593 593
594class EditIncidenceVisitor : public CalendarViewVisitor 594class EditIncidenceVisitor : public CalendarViewVisitor
595{ 595{
596 protected: 596 protected:
597 bool visit( Event *event ) { mView->editEvent( event ); return true; } 597 bool visit( Event *event ) { mView->editEvent( event ); return true; }
598 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } 598 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; }
599 bool visit( Journal *j ) { mView->editJournal( j); return true; } 599 bool visit( Journal *j ) { mView->editJournal( j); return true; }
600}; 600};
601 601
602class DeleteIncidenceVisitor : public CalendarViewVisitor 602class DeleteIncidenceVisitor : public CalendarViewVisitor
603{ 603{
604 protected: 604 protected:
605 bool visit( Event *event ) { mView->deleteEvent( event ); return true; } 605 bool visit( Event *event ) { mView->deleteEvent( event ); return true; }
606 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } 606 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; }
607 bool visit( Journal * j) {mView->deleteJournal( j ); return true; } 607 bool visit( Journal * j) {mView->deleteJournal( j ); return true; }
608}; 608};
609 609
610#endif 610#endif
diff --git a/korganizer/koeditorgeneral.cpp b/korganizer/koeditorgeneral.cpp
index 94e1f4c..b4fe965 100644
--- a/korganizer/koeditorgeneral.cpp
+++ b/korganizer/koeditorgeneral.cpp
@@ -1,504 +1,518 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qwidget.h> 24#include <qwidget.h>
25#include <qtooltip.h> 25#include <qtooltip.h>
26#include <qlayout.h> 26#include <qlayout.h>
27#include <qvbox.h> 27#include <qvbox.h>
28#include <qbuttongroup.h> 28#include <qbuttongroup.h>
29#include <qvgroupbox.h> 29#include <qvgroupbox.h>
30#include <qwidgetstack.h> 30#include <qwidgetstack.h>
31#include <qdatetime.h> 31#include <qdatetime.h>
32#include <qfile.h> 32#include <qfile.h>
33 33
34 34
35#include <kglobal.h> 35#include <kglobal.h>
36#include <kdebug.h> 36#include <kdebug.h>
37#include <klocale.h> 37#include <klocale.h>
38#include <kiconloader.h> 38#include <kiconloader.h>
39#include <kmessagebox.h> 39#include <kmessagebox.h>
40#include <kfiledialog.h> 40#include <kfiledialog.h>
41#include <kstandarddirs.h> 41#include <kstandarddirs.h>
42 42
43#include <libkcal/todo.h> 43#include <libkcal/todo.h>
44#include <libkcal/event.h> 44#include <libkcal/event.h>
45#include <libkdepim/categoryselectdialog.h> 45#include <libkdepim/categoryselectdialog.h>
46#include <libkdepim/kdateedit.h> 46#include <libkdepim/kdateedit.h>
47 47
48#include "koprefs.h" 48#include "koprefs.h"
49#include "koglobals.h" 49#include "koglobals.h"
50 50
51#include "koeditorgeneral.h" 51#include "koeditorgeneral.h"
52#include "kolocationbox.h" 52#include "kolocationbox.h"
53#ifndef DESKTOP_VERSION 53#ifndef DESKTOP_VERSION
54#include <qpe/qpeapplication.h> 54#include <qpe/qpeapplication.h>
55#else 55#else
56#include <qapplication.h> 56#include <qapplication.h>
57#endif 57#endif
58 58
59KOEditorGeneral::KOEditorGeneral(QObject* parent, const char* name) : 59KOEditorGeneral::KOEditorGeneral(QObject* parent, const char* name) :
60 QObject( parent, name) 60 QObject( parent, name)
61{ 61{
62} 62}
63 63
64KOEditorGeneral::~KOEditorGeneral() 64KOEditorGeneral::~KOEditorGeneral()
65{ 65{
66} 66}
67 67
68void KOEditorGeneral::initHeader(QWidget *parent,QBoxLayout *topLayout) 68void KOEditorGeneral::initHeader(QWidget *parent,QBoxLayout *topLayout)
69{ 69{
70 QGridLayout *headerLayout = new QGridLayout(topLayout); 70 QGridLayout *headerLayout = new QGridLayout(topLayout);
71 71
72#if 0 72#if 0
73 mOwnerLabel = new QLabel(i18n("Owner:"),parent); 73 mOwnerLabel = new QLabel(i18n("Owner:"),parent);
74 headerLayout->addMultiCellWidget(mOwnerLabel,0,0,0,1); 74 headerLayout->addMultiCellWidget(mOwnerLabel,0,0,0,1);
75#endif 75#endif
76 76
77 QLabel *summaryLabel = new QLabel(i18n("Summary:"),parent); 77 QLabel *summaryLabel = new QLabel(i18n("Summary:"),parent);
78 headerLayout->addWidget(summaryLabel,1,0); 78 headerLayout->addWidget(summaryLabel,1,0);
79 79
80 mSummaryEdit = new KOLocationBox(TRUE,parent, 10); 80 mSummaryEdit = new KOLocationBox(TRUE,parent, 10);
81 mSummaryEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); 81 mSummaryEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) );
82 //mSummaryEdit->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5 ,(QSizePolicy::SizeType)3 ,FALSE) ); 82 //mSummaryEdit->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5 ,(QSizePolicy::SizeType)3 ,FALSE) );
83 //qDebug("h %d %d ", summaryLabel->sizeHint().height(),mSummaryEdit->sizeHint().height() ); 83 //qDebug("h %d %d ", summaryLabel->sizeHint().height(),mSummaryEdit->sizeHint().height() );
84 int hei = (summaryLabel->sizeHint().height() + mSummaryEdit->sizeHint().height())/2; 84 int hei = (summaryLabel->sizeHint().height() + mSummaryEdit->sizeHint().height())/2;
85 if ( QApplication::desktop()->width() > 320 ) 85 if ( QApplication::desktop()->width() > 320 )
86 mSummaryEdit->setMaximumHeight( hei +6 ); 86 mSummaryEdit->setMaximumHeight( hei +6 );
87 //qDebug("%d %d %d %d %d %d ", QSizePolicy::Fixed , QSizePolicy::Minimum , QSizePolicy:: Maximum , QSizePolicy:: Preferred , QSizePolicy:: MinimumExpanding , QSizePolicy::Expanding ); 87 //qDebug("%d %d %d %d %d %d ", QSizePolicy::Fixed , QSizePolicy::Minimum , QSizePolicy:: Maximum , QSizePolicy:: Preferred , QSizePolicy:: MinimumExpanding , QSizePolicy::Expanding );
88 // SizeType { Fixed = 0, Minimum = MayGrow, Maximum = MayShrink, Preferred = MayGrow|MayShrink, MinimumExpanding = Minimum|ExpMask, Expanding = MinimumExpanding|MayShrink } 88 // SizeType { Fixed = 0, Minimum = MayGrow, Maximum = MayShrink, Preferred = MayGrow|MayShrink, MinimumExpanding = Minimum|ExpMask, Expanding = MinimumExpanding|MayShrink }
89 // mSummaryEdit = new QLineEdit(parent); 89 // mSummaryEdit = new QLineEdit(parent);
90 headerLayout->addWidget(mSummaryEdit,1,1); 90 headerLayout->addWidget(mSummaryEdit,1,1);
91 connect ( mSummaryEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); 91 connect ( mSummaryEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) );
92 92
93 QLabel *locationLabel = new QLabel(i18n("Location:"),parent); 93 QLabel *locationLabel = new QLabel(i18n("Location:"),parent);
94 headerLayout->addWidget(locationLabel,2,0); 94 headerLayout->addWidget(locationLabel,2,0);
95 95
96 mLocationEdit = new KOLocationBox(TRUE,parent,10); 96 mLocationEdit = new KOLocationBox(TRUE,parent,10);
97 mLocationEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); 97 mLocationEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) );
98 if ( QApplication::desktop()->width() > 320 ) 98 if ( QApplication::desktop()->width() > 320 )
99 mLocationEdit->setMaximumHeight( hei + 6); 99 mLocationEdit->setMaximumHeight( hei + 6);
100 100
101 // mLocationEdit = new QLineEdit(parent); 101 // mLocationEdit = new QLineEdit(parent);
102 connect ( mLocationEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); 102 connect ( mLocationEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) );
103 headerLayout->addWidget(mLocationEdit,2,1); 103 headerLayout->addWidget(mLocationEdit,2,1);
104 headerLayout->setColStretch( 1, 10); 104 headerLayout->setColStretch( 1, 10);
105} 105}
106void KOEditorGeneral::setFocusOn( int i ) 106void KOEditorGeneral::setFocusOn( int i )
107{ 107{
108 qApp->processEvents(); 108 qApp->processEvents();
109 if ( i == 1 ) { 109 if ( i == 1 ) {
110 mDescriptionEdit->setFocus(); 110 mDescriptionEdit->setFocus();
111 mDescriptionEdit->setCursorPosition( mDescriptionEdit->numLines (), 333); 111 mDescriptionEdit->setCursorPosition( mDescriptionEdit->numLines (), 333);
112 } 112 }
113 if ( i == 2 ) { 113 if ( i == 2 ) {
114 mSummaryEdit->setFocus(); 114 mSummaryEdit->setFocus();
115 } 115 }
116 116
117} 117}
118void KOEditorGeneral::editCategories() 118void KOEditorGeneral::editCategories()
119{ 119{
120 // qDebug("KOEditorGeneral::editCategories() "); 120 // qDebug("KOEditorGeneral::editCategories() ");
121 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); 121 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 );
122 connect(csd,SIGNAL(categoriesSelected(const QString &)), this ,SLOT(setCategories(const QString &))); 122 connect(csd,SIGNAL(categoriesSelected(const QString &)), this ,SLOT(setCategories(const QString &)));
123 //KOGlobals::fitDialogToScreen( csd ); 123 //KOGlobals::fitDialogToScreen( csd );
124 csd->setSelected( QStringList::split (",", mCategoriesLabel->text()) ); 124 csd->setSelected( QStringList::split (",", mCategoriesLabel->text()) );
125 csd->exec(); 125 csd->exec();
126 delete csd; 126 delete csd;
127} 127}
128void KOEditorGeneral::initCategories(QWidget *parent, QBoxLayout *topLayout) 128void KOEditorGeneral::initCategories(QWidget *parent, QBoxLayout *topLayout)
129{ 129{
130 QBoxLayout *categoriesLayout = new QHBoxLayout( topLayout ); 130 QBoxLayout *categoriesLayout = new QHBoxLayout( topLayout );
131 131
132 mCategoriesButton = new QPushButton(parent); 132 mCategoriesButton = new QPushButton(parent);
133 mCategoriesButton->setText(i18n("Categories...")); 133 mCategoriesButton->setText(i18n("Categories..."));
134 connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() )); 134 connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() ));
135 categoriesLayout->addWidget(mCategoriesButton); 135 categoriesLayout->addWidget(mCategoriesButton);
136 136
137 mCategoriesLabel = new QLabel(parent); 137 mCategoriesLabel = new QLabel(parent);
138 mCategoriesLabel->setFrameStyle(QFrame::Panel|QFrame::Sunken); 138 mCategoriesLabel->setFrameStyle(QFrame::Panel|QFrame::Sunken);
139 categoriesLayout->addWidget(mCategoriesLabel,1); 139 categoriesLayout->addWidget(mCategoriesLabel,1);
140} 140}
141 141
142void KOEditorGeneral::initSecrecy(QWidget *parent, QBoxLayout *topLayout) 142void KOEditorGeneral::initSecrecy(QWidget *parent, QBoxLayout *topLayout)
143{ 143{
144 QBoxLayout *secrecyLayout = new QHBoxLayout( topLayout ); 144 QBoxLayout *secrecyLayout = new QHBoxLayout( topLayout );
145 145
146 QLabel *secrecyLabel = new QLabel(i18n("Access:"),parent); 146 QLabel *secrecyLabel = new QLabel(i18n("Access:"),parent);
147 mCancelBox = new QCheckBox ( i18n("Cancelled"), parent); 147 mCancelBox = new QCheckBox ( i18n("Cancelled"), parent);
148 secrecyLayout->addWidget(mCancelBox); 148 secrecyLayout->addWidget(mCancelBox);
149 secrecyLayout->addWidget(secrecyLabel); 149 secrecyLayout->addWidget(secrecyLabel);
150 150
151 mSecrecyCombo = new QComboBox(parent); 151 mSecrecyCombo = new QComboBox(parent);
152 mSecrecyCombo->insertStringList(Incidence::secrecyList()); 152 mSecrecyCombo->insertStringList(Incidence::secrecyList());
153 secrecyLayout->addWidget(mSecrecyCombo); 153 secrecyLayout->addWidget(mSecrecyCombo);
154} 154}
155 155
156void KOEditorGeneral::initDescription(QWidget *parent,QBoxLayout *topLayout) 156void KOEditorGeneral::initDescription(QWidget *parent,QBoxLayout *topLayout)
157{ 157{
158 mDescriptionEdit = new KTextEdit(parent); 158 mDescriptionEdit = new KTextEdit(parent);
159 mDescriptionEdit->setFont(KOPrefs::instance()->mEditBoxFont ); 159 mDescriptionEdit->setFont(KOPrefs::instance()->mEditBoxFont );
160 mDescriptionEdit->append(""); 160 mDescriptionEdit->append("");
161 mDescriptionEdit->setReadOnly(false); 161 mDescriptionEdit->setReadOnly(false);
162 mDescriptionEdit->setOverwriteMode(false); 162 mDescriptionEdit->setOverwriteMode(false);
163 mDescriptionEdit->setWordWrap( KTextEdit::WidgetWidth ); 163 mDescriptionEdit->setWordWrap( KTextEdit::WidgetWidth );
164 topLayout->addWidget(mDescriptionEdit); 164 topLayout->addWidget(mDescriptionEdit);
165#ifndef DESKTOP_VERSION 165#ifndef DESKTOP_VERSION
166 QPEApplication::setStylusOperation( mDescriptionEdit, QPEApplication::RightOnHold ); 166 QPEApplication::setStylusOperation( mDescriptionEdit, QPEApplication::RightOnHold );
167#endif 167#endif
168 168
169} 169}
170 170
171void KOEditorGeneral::initAlarm(QWidget *parent,QBoxLayout *topLayout) 171void KOEditorGeneral::initAlarm(QWidget *parent,QBoxLayout *topLayout)
172{ 172{
173 QBoxLayout *alarmLayout = new QHBoxLayout(topLayout); 173 QBoxLayout *alarmLayout = new QHBoxLayout(topLayout);
174 174
175 //mAlarmBell = new QLabel(parent); 175 //mAlarmBell = new QLabel(parent);
176 //mAlarmBell->setPixmap(SmallIcon("bell")); 176 //mAlarmBell->setPixmap(SmallIcon("bell"));
177 //alarmLayout->addWidget(mAlarmBell); 177 //alarmLayout->addWidget(mAlarmBell);
178 if ( QApplication::desktop()->width() < 320 ) 178 if ( QApplication::desktop()->width() < 320 )
179 mAlarmButton = new QCheckBox(i18n("Rem."),parent); 179 mAlarmButton = new QCheckBox(i18n("Rem."),parent);
180 else 180 else
181 mAlarmButton = new QCheckBox(i18n("Reminder:"),parent); 181 mAlarmButton = new QCheckBox(i18n("Reminder:"),parent);
182 182
183 connect(mAlarmButton, SIGNAL(toggled(bool)), SLOT(enableAlarmEdit(bool))); 183 connect(mAlarmButton, SIGNAL(toggled(bool)), SLOT(enableAlarmEdit(bool)));
184 alarmLayout->addWidget(mAlarmButton); 184 alarmLayout->addWidget(mAlarmButton);
185 185
186 mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ; 186 mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ;
187 alarmLayout->addWidget(mAlarmTimeEdit); 187 alarmLayout->addWidget(mAlarmTimeEdit);
188 mAlarmIncrCombo = new QComboBox(false, parent); 188 mAlarmIncrCombo = new QComboBox(false, parent);
189 if ( QApplication::desktop()->width() < 320 ) { 189 if ( QApplication::desktop()->width() < 320 ) {
190 mAlarmIncrCombo->insertItem(i18n("min")); 190 mAlarmIncrCombo->insertItem(i18n("min"));
191 mAlarmIncrCombo->insertItem(i18n("hou")); 191 mAlarmIncrCombo->insertItem(i18n("hou"));
192 mAlarmIncrCombo->insertItem(i18n("day")); 192 mAlarmIncrCombo->insertItem(i18n("day"));
193 mAlarmTimeEdit->setMaximumWidth( mAlarmTimeEdit->sizeHint().width() ); 193 mAlarmTimeEdit->setMaximumWidth( mAlarmTimeEdit->sizeHint().width() );
194 mAlarmIncrCombo->setMaximumWidth( mAlarmIncrCombo->sizeHint().width() ); 194 mAlarmIncrCombo->setMaximumWidth( mAlarmIncrCombo->sizeHint().width() );
195 } else { 195 } else {
196 mAlarmIncrCombo->insertItem(i18n("minute(s)")); 196 mAlarmIncrCombo->insertItem(i18n("minute(s)"));
197 mAlarmIncrCombo->insertItem(i18n("hour(s)")); 197 mAlarmIncrCombo->insertItem(i18n("hour(s)"));
198 mAlarmIncrCombo->insertItem(i18n("day(s)")); 198 mAlarmIncrCombo->insertItem(i18n("day(s)"));
199 } 199 }
200 200
201 // mAlarmIncrCombo->setMinimumHeight(20); 201 // mAlarmIncrCombo->setMinimumHeight(20);
202 alarmLayout->addWidget(mAlarmIncrCombo); 202 alarmLayout->addWidget(mAlarmIncrCombo);
203 mAlarmSoundButton = new QPushButton(parent); 203 mAlarmSoundButton = new QPushButton(parent);
204 mAlarmSoundButton->setPixmap(SmallIcon("playsound")); 204 mAlarmSoundButton->setPixmap(SmallIcon("playsound"));
205 mAlarmSoundButton->setToggleButton(true); 205 mAlarmSoundButton->setToggleButton(true);
206 QToolTip::add(mAlarmSoundButton, i18n("No sound set")); 206 QToolTip::add(mAlarmSoundButton, i18n("No sound set"));
207 connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound())); 207 connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound()));
208 alarmLayout->addWidget(mAlarmSoundButton); 208 alarmLayout->addWidget(mAlarmSoundButton);
209 209
210 mAlarmProgramButton = new QPushButton(parent); 210 mAlarmProgramButton = new QPushButton(parent);
211 mAlarmProgramButton->setPixmap(SmallIcon("run")); 211 mAlarmProgramButton->setPixmap(SmallIcon("run"));
212 mAlarmProgramButton->setToggleButton(true); 212 mAlarmProgramButton->setToggleButton(true);
213 QToolTip::add(mAlarmProgramButton, i18n("No program set")); 213 QToolTip::add(mAlarmProgramButton, i18n("No program set"));
214 connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram())); 214 connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram()));
215 alarmLayout->addWidget(mAlarmProgramButton); 215 alarmLayout->addWidget(mAlarmProgramButton);
216 mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 ); 216 mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 );
217 mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 ); 217 mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 );
218 // if ( KOPrefs::instance()->mCompactDialogs ) { 218 // if ( KOPrefs::instance()->mCompactDialogs ) {
219 // mAlarmSoundButton->hide(); 219 // mAlarmSoundButton->hide();
220 // mAlarmProgramButton->hide(); 220 // mAlarmProgramButton->hide();
221 // } 221 // }
222} 222}
223 223
224void KOEditorGeneral::pickAlarmSound() 224void KOEditorGeneral::pickAlarmSound()
225{ 225{
226 226
227 //QString prefix = mAlarmSound; 227 //QString prefix = mAlarmSound;
228 if (!mAlarmSoundButton->isOn()) { 228 if (!mAlarmSoundButton->isOn()) {
229 //mAlarmSound = ""; 229 //mAlarmSound = "";
230 QToolTip::remove(mAlarmSoundButton); 230 QToolTip::remove(mAlarmSoundButton);
231 QToolTip::add(mAlarmSoundButton, i18n("No sound set")); 231 QToolTip::add(mAlarmSoundButton, i18n("No sound set"));
232 mAlarmProgramButton->setOn(true); 232 mAlarmProgramButton->setOn(true);
233 mAlarmSoundButton->setOn(false); 233 mAlarmSoundButton->setOn(false);
234 } else { 234 } else {
235 QString fileName(KFileDialog::getOpenFileName(mAlarmSound, 235 QString fileName(KFileDialog::getOpenFileName(mAlarmSound,
236 i18n("*.wav|Wav Files"), 0)); 236 i18n("*.wav|Wav Files"), 0));
237 if (!fileName.isEmpty()) { 237 if (!fileName.isEmpty()) {
238 mAlarmSound = fileName; 238 mAlarmSound = fileName;
239 QToolTip::remove(mAlarmSoundButton); 239 QToolTip::remove(mAlarmSoundButton);
240 QString dispStr = i18n("Playing '%1'").arg(fileName); 240 QString dispStr = i18n("Playing '%1'").arg(fileName);
241 QToolTip::add(mAlarmSoundButton, dispStr); 241 QToolTip::add(mAlarmSoundButton, dispStr);
242 mAlarmProgramButton->setOn(false); 242 mAlarmProgramButton->setOn(false);
243 mAlarmSoundButton->setOn(true); 243 mAlarmSoundButton->setOn(true);
244 } else { 244 } else {
245 mAlarmProgramButton->setOn(true); 245 mAlarmProgramButton->setOn(true);
246 mAlarmSoundButton->setOn(false); 246 mAlarmSoundButton->setOn(false);
247 247
248 } 248 }
249 } 249 }
250 250
251 if (mAlarmProgramButton->isOn()) 251 if (mAlarmProgramButton->isOn())
252 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + mAlarmProgram ); 252 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + mAlarmProgram );
253 if ( mAlarmSoundButton->isOn()) 253 if ( mAlarmSoundButton->isOn())
254 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio.Al.: ") + mAlarmSound ); 254 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio.Al.: ") + mAlarmSound );
255} 255}
256 256
257void KOEditorGeneral::pickAlarmProgram() 257void KOEditorGeneral::pickAlarmProgram()
258{ 258{
259 if (!mAlarmProgramButton->isOn()) { 259 if (!mAlarmProgramButton->isOn()) {
260 //mAlarmProgram = ""; 260 //mAlarmProgram = "";
261 QToolTip::remove(mAlarmProgramButton); 261 QToolTip::remove(mAlarmProgramButton);
262 QToolTip::add(mAlarmProgramButton, i18n("No program set")); 262 QToolTip::add(mAlarmProgramButton, i18n("No program set"));
263 mAlarmProgramButton->setOn(false); 263 mAlarmProgramButton->setOn(false);
264 mAlarmSoundButton->setOn(true); 264 mAlarmSoundButton->setOn(true);
265 } else { 265 } else {
266 QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm.: ") , 0)); 266 QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm.: ") , 0));
267 if (!fileName.isEmpty()) { 267 if (!fileName.isEmpty()) {
268 mAlarmProgram = fileName; 268 mAlarmProgram = fileName;
269 QToolTip::remove(mAlarmProgramButton); 269 QToolTip::remove(mAlarmProgramButton);
270 QString dispStr = i18n("Running '%1'").arg(fileName); 270 QString dispStr = i18n("Running '%1'").arg(fileName);
271 QToolTip::add(mAlarmProgramButton, dispStr); 271 QToolTip::add(mAlarmProgramButton, dispStr);
272 mAlarmSoundButton->setOn(false); 272 mAlarmSoundButton->setOn(false);
273 mAlarmProgramButton->setOn(true); 273 mAlarmProgramButton->setOn(true);
274 } else { 274 } else {
275 mAlarmProgramButton->setOn(false); 275 mAlarmProgramButton->setOn(false);
276 mAlarmSoundButton->setOn(true); 276 mAlarmSoundButton->setOn(true);
277 } 277 }
278 } 278 }
279 if (mAlarmProgramButton->isOn()) 279 if (mAlarmProgramButton->isOn())
280 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + mAlarmProgram ); 280 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + mAlarmProgram );
281 if ( mAlarmSoundButton->isOn()) 281 if ( mAlarmSoundButton->isOn())
282 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Sound.Al.: ") + mAlarmSound ); 282 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Sound.Al.: ") + mAlarmSound );
283} 283}
284 284
285 285
286QString KOEditorGeneral::getFittingPath( const QString s )
287{
288 int maxlen = 50;
289 if ( QApplication::desktop()->width() < 640 ) {
290 if ( QApplication::desktop()->width() < 320 )
291 maxlen = 22;
292 else
293 maxlen = 35;
294 }
295 if ( s.length() > maxlen ) {
296 return "..."+s.right(maxlen -3);
297 }
298 return s;
299}
286 300
287void KOEditorGeneral::enableAlarmEdit(bool enable) 301void KOEditorGeneral::enableAlarmEdit(bool enable)
288{ 302{
289 if ( enable ) { 303 if ( enable ) {
290 if (!mAlarmProgramButton->isOn() && !mAlarmSoundButton->isOn()) { 304 if (!mAlarmProgramButton->isOn() && !mAlarmSoundButton->isOn()) {
291 mAlarmSoundButton->setOn( true ); 305 mAlarmSoundButton->setOn( true );
292 if ( mAlarmSound.isEmpty() ) 306 if ( mAlarmSound.isEmpty() )
293 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; 307 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
294 else { 308 else {
295 if ( ! QFile::exists( mAlarmSound ) ) 309 if ( ! QFile::exists( mAlarmSound ) )
296 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; 310 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
297 } 311 }
298 } 312 }
299 if (mAlarmProgramButton->isOn()) 313 if (mAlarmProgramButton->isOn())
300 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + mAlarmProgram ); 314 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) );
301 if (!mAlarmSound.isEmpty() && mAlarmSoundButton->isOn()) 315 if (!mAlarmSound.isEmpty() && mAlarmSoundButton->isOn())
302 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Sound.Al.: ") + mAlarmSound ); 316 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) );
303 } 317 }
304 else { 318 else {
305 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Alarm disabled")); 319 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Alarm disabled for this item"));
306 320
307 } 321 }
308 mAlarmTimeEdit->setEnabled(enable); 322 mAlarmTimeEdit->setEnabled(enable);
309 mAlarmSoundButton->setEnabled(enable); 323 mAlarmSoundButton->setEnabled(enable);
310 mAlarmProgramButton->setEnabled(enable); 324 mAlarmProgramButton->setEnabled(enable);
311 mAlarmIncrCombo->setEnabled(enable); 325 mAlarmIncrCombo->setEnabled(enable);
312} 326}
313 327
314void KOEditorGeneral::disableAlarmEdit(bool disable) 328void KOEditorGeneral::disableAlarmEdit(bool disable)
315{ 329{
316 enableAlarmEdit( !disable ); 330 enableAlarmEdit( !disable );
317} 331}
318 332
319void KOEditorGeneral::enableAlarm( bool enable ) 333void KOEditorGeneral::enableAlarm( bool enable )
320{ 334{
321 enableAlarmEdit( enable ); 335 enableAlarmEdit( enable );
322} 336}
323 337
324void KOEditorGeneral::alarmDisable(bool disable) 338void KOEditorGeneral::alarmDisable(bool disable)
325{ 339{
326 if (!disable) { 340 if (!disable) {
327 //mAlarmBell->setEnabled(true); 341 //mAlarmBell->setEnabled(true);
328 mAlarmButton->setEnabled(true); 342 mAlarmButton->setEnabled(true);
329 } else { 343 } else {
330 //mAlarmBell->setEnabled(false); 344 //mAlarmBell->setEnabled(false);
331 mAlarmButton->setEnabled(false); 345 mAlarmButton->setEnabled(false);
332 mAlarmButton->setChecked(false); 346 mAlarmButton->setChecked(false);
333 mAlarmTimeEdit->setEnabled(false); 347 mAlarmTimeEdit->setEnabled(false);
334 mAlarmSoundButton->setEnabled(false); 348 mAlarmSoundButton->setEnabled(false);
335 mAlarmProgramButton->setEnabled(false); 349 mAlarmProgramButton->setEnabled(false);
336 mAlarmIncrCombo->setEnabled(false); 350 mAlarmIncrCombo->setEnabled(false);
337 } 351 }
338} 352}
339 353
340void KOEditorGeneral::setCategories(const QString &str) 354void KOEditorGeneral::setCategories(const QString &str)
341{ 355{
342 mCategoriesLabel->setText(str); 356 mCategoriesLabel->setText(str);
343} 357}
344 358
345void KOEditorGeneral::setDefaults(bool allDay) 359void KOEditorGeneral::setDefaults(bool allDay)
346{ 360{
347#if 0 361#if 0
348 mOwnerLabel->setText(i18n("Owner: ") + KOPrefs::instance()->fullName()); 362 mOwnerLabel->setText(i18n("Owner: ") + KOPrefs::instance()->fullName());
349#endif 363#endif
350 364
351 enableAlarmEdit( !allDay ); 365 enableAlarmEdit( !allDay );
352 366
353 // TODO: Implement a KPrefsComboItem to solve this in a clean way. 367 // TODO: Implement a KPrefsComboItem to solve this in a clean way.
354 int alarmTime; 368 int alarmTime;
355 int a[] = { 1,5,10,15,30,60,180, 1440 }; 369 int a[] = { 1,5,10,15,30,60,180, 1440 };
356 int index = KOPrefs::instance()->mAlarmTime; 370 int index = KOPrefs::instance()->mAlarmTime;
357 if (index < 0 || index > 7) { 371 if (index < 0 || index > 7) {
358 alarmTime = 15; 372 alarmTime = 15;
359 } else { 373 } else {
360 alarmTime = a[index]; 374 alarmTime = a[index];
361 } 375 }
362 mAlarmButton ->setChecked( false ); 376 mAlarmButton ->setChecked( false );
363 mAlarmTimeEdit->setValue(alarmTime); 377 mAlarmTimeEdit->setValue(alarmTime);
364 mAlarmIncrCombo->setCurrentItem(0); 378 mAlarmIncrCombo->setCurrentItem(0);
365 enableAlarmEdit( false ); 379 enableAlarmEdit( false );
366 //alarmDisable (false); 380 //alarmDisable (false);
367 mSecrecyCombo->setCurrentItem(Incidence::SecrecyPublic); 381 mSecrecyCombo->setCurrentItem(Incidence::SecrecyPublic);
368 mCancelBox->setChecked( false ); 382 mCancelBox->setChecked( false );
369 mSummaryEdit->setEditText(""); 383 mSummaryEdit->setEditText("");
370 mLocationEdit->setEditText(""); 384 mLocationEdit->setEditText("");
371 mDescriptionEdit->setText(""); 385 mDescriptionEdit->setText("");
372 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; 386 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
373 setCategories(""); 387 setCategories("");
374} 388}
375void KOEditorGeneral::setSecrecy( int num ) 389void KOEditorGeneral::setSecrecy( int num )
376{ 390{
377 mSecrecyCombo->setCurrentItem(num); 391 mSecrecyCombo->setCurrentItem(num);
378} 392}
379void KOEditorGeneral::readIncidence(Incidence *event) 393void KOEditorGeneral::readIncidence(Incidence *event)
380{ 394{
381 395
382 mAlarmIncrCombo->setCurrentItem(0); 396 mAlarmIncrCombo->setCurrentItem(0);
383 mSummaryEdit->setEditText(event->summary()); 397 mSummaryEdit->setEditText(event->summary());
384 mLocationEdit->setEditText(event->location()); 398 mLocationEdit->setEditText(event->location());
385 mDescriptionEdit->setText(event->description()); 399 mDescriptionEdit->setText(event->description());
386 400
387#if 0 401#if 0
388 // organizer information 402 // organizer information
389 mOwnerLabel->setText(i18n("Owner: ") + event->organizer()); 403 mOwnerLabel->setText(i18n("Owner: ") + event->organizer());
390#endif 404#endif
391 405
392 enableAlarmEdit( event->isAlarmEnabled() ); 406 enableAlarmEdit( event->isAlarmEnabled() );
393 //qDebug("KOEditorGeneral::readIncidence(Incidence *event) "); 407 //qDebug("KOEditorGeneral::readIncidence(Incidence *event) ");
394 if(!event->isAlarmEnabled()) { 408 if(!event->isAlarmEnabled()) {
395 // TODO: Implement a KPrefsComboItem to solve this in a clean way. 409 // TODO: Implement a KPrefsComboItem to solve this in a clean way.
396 int alarmTime; 410 int alarmTime;
397 int a[] = { 1,5,10,15,30,60,180, 1440 }; 411 int a[] = { 1,5,10,15,30,60,180, 1440 };
398 int index = KOPrefs::instance()->mAlarmTime; 412 int index = KOPrefs::instance()->mAlarmTime;
399 if (index < 0 || index > 7) { 413 if (index < 0 || index > 7) {
400 alarmTime = 15; 414 alarmTime = 15;
401 } else { 415 } else {
402 alarmTime = a[index]; 416 alarmTime = a[index];
403 } 417 }
404 mAlarmTimeEdit->setValue(alarmTime); 418 mAlarmTimeEdit->setValue(alarmTime);
405 } 419 }
406 mAlarmButton->setChecked( event->isAlarmEnabled() ); 420 mAlarmButton->setChecked( event->isAlarmEnabled() );
407 mSecrecyCombo->setCurrentItem(event->secrecy()); 421 mSecrecyCombo->setCurrentItem(event->secrecy());
408 mCancelBox->setChecked( event->cancelled() ); 422 mCancelBox->setChecked( event->cancelled() );
409 mAlarmProgramButton->setOn(false); 423 mAlarmProgramButton->setOn(false);
410 mAlarmSoundButton->setOn(false); 424 mAlarmSoundButton->setOn(false);
411 425
412 // set up alarm stuff 426 // set up alarm stuff
413 QPtrList<Alarm> alarms = event->alarms(); 427 QPtrList<Alarm> alarms = event->alarms();
414 Alarm* alarm; 428 Alarm* alarm;
415 mAlarmIncrCombo->setCurrentItem(0); 429 mAlarmIncrCombo->setCurrentItem(0);
416 for ( alarm = alarms.first(); alarm; alarm = alarms.next() ) { 430 for ( alarm = alarms.first(); alarm; alarm = alarms.next() ) {
417 int offset; 431 int offset;
418 if ( alarm->hasTime() ) { 432 if ( alarm->hasTime() ) {
419 QDateTime t = alarm->time(); 433 QDateTime t = alarm->time();
420 offset = event->dtStart().secsTo( t ); 434 offset = event->dtStart().secsTo( t );
421 } else { 435 } else {
422 offset = alarm->startOffset().asSeconds(); 436 offset = alarm->startOffset().asSeconds();
423 } 437 }
424 if ( offset != 0 ) { 438 if ( offset != 0 ) {
425 offset = offset / -60; // make minutes 439 offset = offset / -60; // make minutes
426 if (offset % 60 == 0) { // divides evenly into hours? 440 if (offset % 60 == 0) { // divides evenly into hours?
427 offset = offset / 60; 441 offset = offset / 60;
428 mAlarmIncrCombo->setCurrentItem(1); 442 mAlarmIncrCombo->setCurrentItem(1);
429 if (offset % 24 == 0) { // divides evenly into days? 443 if (offset % 24 == 0) { // divides evenly into days?
430 offset = offset / 24; 444 offset = offset / 24;
431 mAlarmIncrCombo->setCurrentItem(2); 445 mAlarmIncrCombo->setCurrentItem(2);
432 } 446 }
433 } 447 }
434 } 448 }
435 mAlarmTimeEdit->setValue( offset ); 449 mAlarmTimeEdit->setValue( offset );
436 if (alarm->type() == Alarm::Procedure) { 450 if (alarm->type() == Alarm::Procedure) {
437 451
438 mAlarmProgram = alarm->programFile(); 452 mAlarmProgram = alarm->programFile();
439 mAlarmProgramButton->setOn(true); 453 mAlarmProgramButton->setOn(true);
440 QString dispStr = i18n("Running '%1'").arg(mAlarmProgram); 454 QString dispStr = i18n("Running '%1'").arg(mAlarmProgram);
441 QToolTip::add(mAlarmProgramButton, dispStr); 455 QToolTip::add(mAlarmProgramButton, dispStr);
442 } 456 }
443 else if (alarm->type() == Alarm::Audio) { 457 else if (alarm->type() == Alarm::Audio) {
444 mAlarmSound = alarm->audioFile(); 458 mAlarmSound = alarm->audioFile();
445 if ( ! QFile::exists( mAlarmSound ) ) 459 if ( ! QFile::exists( mAlarmSound ) )
446 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; 460 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
447 mAlarmSoundButton->setOn(true); 461 mAlarmSoundButton->setOn(true);
448 QString dispStr = i18n("Playing '%1'").arg(mAlarmSound); 462 QString dispStr = i18n("Playing '%1'").arg(mAlarmSound);
449 QToolTip::add(mAlarmSoundButton, dispStr); 463 QToolTip::add(mAlarmSoundButton, dispStr);
450 } 464 }
451 mAlarmButton->setChecked(alarm->enabled()); 465 mAlarmButton->setChecked(alarm->enabled());
452 enableAlarmEdit( alarm->enabled() ); 466 enableAlarmEdit( alarm->enabled() );
453 //qDebug("nableAlarmEdit( alarm->enabled() )********* "); 467 //qDebug("nableAlarmEdit( alarm->enabled() )********* ");
454 // TODO: Deal with multiple alarms 468 // TODO: Deal with multiple alarms
455 break; // For now, stop after the first alarm 469 break; // For now, stop after the first alarm
456 } 470 }
457 471
458 setCategories(event->categoriesStr()); 472 setCategories(event->categoriesStr());
459} 473}
460 474
461void KOEditorGeneral::writeIncidence(Incidence *event) 475void KOEditorGeneral::writeIncidence(Incidence *event)
462{ 476{
463 // kdDebug() << "KOEditorGeneral::writeEvent()" << endl; 477 // kdDebug() << "KOEditorGeneral::writeEvent()" << endl;
464 mLocationEdit->save(KOLocationBox::LOCATION); 478 mLocationEdit->save(KOLocationBox::LOCATION);
465 event->setSummary(mSummaryEdit->currentText()); 479 event->setSummary(mSummaryEdit->currentText());
466 event->setLocation(mLocationEdit->currentText()); 480 event->setLocation(mLocationEdit->currentText());
467 event->setDescription(mDescriptionEdit->text()); 481 event->setDescription(mDescriptionEdit->text());
468 event->setCategories(mCategoriesLabel->text()); 482 event->setCategories(mCategoriesLabel->text());
469 event->setSecrecy(mSecrecyCombo->currentItem()); 483 event->setSecrecy(mSecrecyCombo->currentItem());
470 event->setCancelled(mCancelBox->isChecked() );; 484 event->setCancelled(mCancelBox->isChecked() );;
471 // alarm stuff 485 // alarm stuff
472 if (mAlarmButton->isChecked()) { 486 if (mAlarmButton->isChecked()) {
473 if (event->alarms().count() == 0) 487 if (event->alarms().count() == 0)
474 event->newAlarm(); 488 event->newAlarm();
475 QPtrList<Alarm> alarms = event->alarms(); 489 QPtrList<Alarm> alarms = event->alarms();
476 Alarm *alarm; 490 Alarm *alarm;
477 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { 491 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) {
478 alarm->setEnabled(true); 492 alarm->setEnabled(true);
479 int j = mAlarmTimeEdit->value()* -60; 493 int j = mAlarmTimeEdit->value()* -60;
480 if (mAlarmIncrCombo->currentItem() == 1) 494 if (mAlarmIncrCombo->currentItem() == 1)
481 j = j * 60; 495 j = j * 60;
482 else if (mAlarmIncrCombo->currentItem() == 2) 496 else if (mAlarmIncrCombo->currentItem() == 2)
483 j = j * (60 * 24); 497 j = j * (60 * 24);
484 alarm->setStartOffset( j ); 498 alarm->setStartOffset( j );
485 499
486 if (!mAlarmProgram.isEmpty() && mAlarmProgramButton->isOn()) { 500 if (!mAlarmProgram.isEmpty() && mAlarmProgramButton->isOn()) {
487 alarm->setProcedureAlarm(mAlarmProgram); 501 alarm->setProcedureAlarm(mAlarmProgram);
488 } 502 }
489 else if (!mAlarmSound.isEmpty() && mAlarmSoundButton->isOn()) 503 else if (!mAlarmSound.isEmpty() && mAlarmSoundButton->isOn())
490 alarm->setAudioAlarm(mAlarmSound); 504 alarm->setAudioAlarm(mAlarmSound);
491 else 505 else
492 alarm->setType(Alarm::Invalid); 506 alarm->setType(Alarm::Invalid);
493 //alarm->setAudioAlarm("default"); 507 //alarm->setAudioAlarm("default");
494 // TODO: Deal with multiple alarms 508 // TODO: Deal with multiple alarms
495 break; // For now, stop after the first alarm 509 break; // For now, stop after the first alarm
496 } 510 }
497 } else { 511 } else {
498 Alarm* alarm = event->alarms().first(); 512 Alarm* alarm = event->alarms().first();
499 if ( alarm ) { 513 if ( alarm ) {
500 alarm->setEnabled(false); 514 alarm->setEnabled(false);
501 alarm->setType(Alarm::Invalid); 515 alarm->setType(Alarm::Invalid);
502 } 516 }
503 } 517 }
504} 518}
diff --git a/korganizer/koeditorgeneral.h b/korganizer/koeditorgeneral.h
index c58335e..de8edaf 100644
--- a/korganizer/koeditorgeneral.h
+++ b/korganizer/koeditorgeneral.h
@@ -1,112 +1,113 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23#ifndef KOEDITORGENERAL_H 23#ifndef KOEDITORGENERAL_H
24#define KOEDITORGENERAL_H 24#define KOEDITORGENERAL_H
25 25
26#include <qframe.h> 26#include <qframe.h>
27#include <qlabel.h> 27#include <qlabel.h>
28#include <qcheckbox.h> 28#include <qcheckbox.h>
29#include <qpushbutton.h> 29#include <qpushbutton.h>
30#include <qgroupbox.h> 30#include <qgroupbox.h>
31#include <qlineedit.h> 31#include <qlineedit.h>
32#include <qcombobox.h> 32#include <qcombobox.h>
33#include <qlistview.h> 33#include <qlistview.h>
34#include <qradiobutton.h> 34#include <qradiobutton.h>
35#include <qlayout.h> 35#include <qlayout.h>
36#include <qspinbox.h> 36#include <qspinbox.h>
37 37
38#include <ktextedit.h> 38#include <ktextedit.h>
39#include <krestrictedline.h> 39#include <krestrictedline.h>
40 40
41#include <libkcal/incidence.h> 41#include <libkcal/incidence.h>
42 42
43#include "ktimeedit.h" 43#include "ktimeedit.h"
44 44
45class KDateEdit; 45class KDateEdit;
46class KOLocationBox; 46class KOLocationBox;
47using namespace KCal; 47using namespace KCal;
48 48
49class KOEditorGeneral : public QObject 49class KOEditorGeneral : public QObject
50{ 50{
51 Q_OBJECT 51 Q_OBJECT
52 public: 52 public:
53 KOEditorGeneral (QObject* parent=0,const char* name=0); 53 KOEditorGeneral (QObject* parent=0,const char* name=0);
54 virtual ~KOEditorGeneral(); 54 virtual ~KOEditorGeneral();
55 void setFocusOn( int i ); 55 void setFocusOn( int i );
56 void initHeader(QWidget *,QBoxLayout *); 56 void initHeader(QWidget *,QBoxLayout *);
57 void initDescription(QWidget *,QBoxLayout *); 57 void initDescription(QWidget *,QBoxLayout *);
58 void initSecrecy(QWidget *,QBoxLayout *); 58 void initSecrecy(QWidget *,QBoxLayout *);
59 void initCategories(QWidget *,QBoxLayout *); 59 void initCategories(QWidget *,QBoxLayout *);
60 void initAlarm(QWidget *,QBoxLayout *); 60 void initAlarm(QWidget *,QBoxLayout *);
61 61
62 /** Set widgets to default values */ 62 /** Set widgets to default values */
63 void setDefaults(bool allDay); 63 void setDefaults(bool allDay);
64 /** Read event object and setup widgets accordingly */ 64 /** Read event object and setup widgets accordingly */
65 void readIncidence(Incidence *); 65 void readIncidence(Incidence *);
66 /** Write event settings to event object */ 66 /** Write event settings to event object */
67 void writeIncidence(Incidence *); 67 void writeIncidence(Incidence *);
68 68
69 /** Check if the input is valid. */ 69 /** Check if the input is valid. */
70 bool validateInput() { return true; } 70 bool validateInput() { return true; }
71 71
72 void enableAlarm( bool enable ); 72 void enableAlarm( bool enable );
73 void setSecrecy( int num ); 73 void setSecrecy( int num );
74 public slots: 74 public slots:
75 void setCategories(const QString &); 75 void setCategories(const QString &);
76 void editCategories(); 76 void editCategories();
77 77
78 protected slots: 78 protected slots:
79 void enableAlarmEdit( bool enable ); 79 void enableAlarmEdit( bool enable );
80 void disableAlarmEdit( bool disable ); 80 void disableAlarmEdit( bool disable );
81 void alarmDisable( bool disable ); 81 void alarmDisable( bool disable );
82 void pickAlarmSound(); 82 void pickAlarmSound();
83 void pickAlarmProgram(); 83 void pickAlarmProgram();
84 84
85 signals: 85 signals:
86 void openCategoryDialog(); 86 void openCategoryDialog();
87 void allAccepted(); 87 void allAccepted();
88 88
89 protected: 89 protected:
90 //QLineEdit *mSummaryEdit; 90 //QLineEdit *mSummaryEdit;
91 //QLineEdit *mLocationEdit; 91 //QLineEdit *mLocationEdit;
92 KOLocationBox *mSummaryEdit; 92 KOLocationBox *mSummaryEdit;
93 KOLocationBox *mLocationEdit; 93 KOLocationBox *mLocationEdit;
94 QLabel *mAlarmBell; 94 QLabel *mAlarmBell;
95 QCheckBox *mAlarmButton; 95 QCheckBox *mAlarmButton;
96 QSpinBox *mAlarmTimeEdit; 96 QSpinBox *mAlarmTimeEdit;
97 QPushButton *mAlarmSoundButton; 97 QPushButton *mAlarmSoundButton;
98 QPushButton *mAlarmProgramButton; 98 QPushButton *mAlarmProgramButton;
99 QComboBox *mAlarmIncrCombo; 99 QComboBox *mAlarmIncrCombo;
100 KTextEdit *mDescriptionEdit; 100 KTextEdit *mDescriptionEdit;
101 QLabel *mOwnerLabel; 101 QLabel *mOwnerLabel;
102 QComboBox *mSecrecyCombo; 102 QComboBox *mSecrecyCombo;
103 QCheckBox *mCancelBox; 103 QCheckBox *mCancelBox;
104 QPushButton *mCategoriesButton; 104 QPushButton *mCategoriesButton;
105 QLabel *mCategoriesLabel; 105 QLabel *mCategoriesLabel;
106 106
107 private: 107 private:
108 QString getFittingPath( const QString ) ;
108 QString mAlarmSound; 109 QString mAlarmSound;
109 QString mAlarmProgram; 110 QString mAlarmProgram;
110}; 111};
111 112
112#endif 113#endif
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index 97b4a03..30adb06 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -1,1157 +1,1152 @@
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 27
28#include <qvbox.h> 28#include <qvbox.h>
29#include <kdebug.h> 29#include <kdebug.h>
30#include "koprefs.h" 30#include "koprefs.h"
31#include <klocale.h> 31#include <klocale.h>
32#include <kglobal.h> 32#include <kglobal.h>
33#include <kiconloader.h> 33#include <kiconloader.h>
34#include <kmessagebox.h> 34#include <kmessagebox.h>
35 35
36#include <libkcal/icaldrag.h> 36#include <libkcal/icaldrag.h>
37#include <libkcal/vcaldrag.h> 37#include <libkcal/vcaldrag.h>
38#include <libkcal/calfilter.h> 38#include <libkcal/calfilter.h>
39#include <libkcal/dndfactory.h> 39#include <libkcal/dndfactory.h>
40#include <libkcal/calendarresources.h> 40#include <libkcal/calendarresources.h>
41#include <libkcal/resourcecalendar.h> 41#include <libkcal/resourcecalendar.h>
42#include <kresources/resourceselectdialog.h> 42#include <kresources/resourceselectdialog.h>
43#ifndef DESKTOP_VERSION 43#ifndef DESKTOP_VERSION
44#include <qpe/qpeapplication.h> 44#include <qpe/qpeapplication.h>
45#else 45#else
46#include <qapplication.h> 46#include <qapplication.h>
47#endif 47#endif
48#ifndef KORG_NOPRINTER 48#ifndef KORG_NOPRINTER
49#include "calprinter.h" 49#include "calprinter.h"
50#endif 50#endif
51#include "docprefs.h" 51#include "docprefs.h"
52 52
53#include "kotodoview.h" 53#include "kotodoview.h"
54using namespace KOrg; 54using namespace KOrg;
55 55
56KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent, 56KOTodoListView::KOTodoListView(Calendar *calendar,QWidget *parent,
57 const char *name) : 57 const char *name) :
58 KListView(parent,name) 58 KListView(parent,name)
59{ 59{
60 mName = QString ( name ); 60 mName = QString ( name );
61 mCalendar = calendar; 61 mCalendar = calendar;
62#ifndef DESKTOP_VERSION 62#ifndef DESKTOP_VERSION
63 QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); 63 QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold );
64#endif 64#endif
65 mOldCurrent = 0; 65 mOldCurrent = 0;
66 mMousePressed = false; 66 mMousePressed = false;
67 67
68 setAcceptDrops(true); 68 setAcceptDrops(true);
69 viewport()->setAcceptDrops(true); 69 viewport()->setAcceptDrops(true);
70 int size = 16; 70 int size = 16;
71 if (qApp->desktop()->width() < 300 ) 71 if (qApp->desktop()->width() < 300 )
72 size = 12; 72 size = 12;
73 setTreeStepSize( size + 6 ); 73 setTreeStepSize( size + 6 );
74 74
75} 75}
76 76
77void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e) 77void KOTodoListView::contentsDragEnterEvent(QDragEnterEvent *e)
78{ 78{
79#ifndef KORG_NODND 79#ifndef KORG_NODND
80// kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl; 80// kdDebug() << "KOTodoListView::contentsDragEnterEvent" << endl;
81 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && 81 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
82 !QTextDrag::canDecode( e ) ) { 82 !QTextDrag::canDecode( e ) ) {
83 e->ignore(); 83 e->ignore();
84 return; 84 return;
85 } 85 }
86 86
87 mOldCurrent = currentItem(); 87 mOldCurrent = currentItem();
88#endif 88#endif
89} 89}
90 90
91 91
92void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e) 92void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e)
93{ 93{
94#ifndef KORG_NODND 94#ifndef KORG_NODND
95// kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl; 95// kdDebug() << "KOTodoListView::contentsDragMoveEvent" << endl;
96 96
97 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && 97 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
98 !QTextDrag::canDecode( e ) ) { 98 !QTextDrag::canDecode( e ) ) {
99 e->ignore(); 99 e->ignore();
100 return; 100 return;
101 } 101 }
102 102
103 e->accept(); 103 e->accept();
104#endif 104#endif
105} 105}
106 106
107void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) 107void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *)
108{ 108{
109#ifndef KORG_NODND 109#ifndef KORG_NODND
110// kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; 110// kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl;
111 111
112 setCurrentItem(mOldCurrent); 112 setCurrentItem(mOldCurrent);
113 setSelected(mOldCurrent,true); 113 setSelected(mOldCurrent,true);
114#endif 114#endif
115} 115}
116 116
117void KOTodoListView::contentsDropEvent(QDropEvent *e) 117void KOTodoListView::contentsDropEvent(QDropEvent *e)
118{ 118{
119#ifndef KORG_NODND 119#ifndef KORG_NODND
120// kdDebug() << "KOTodoListView::contentsDropEvent" << endl; 120// kdDebug() << "KOTodoListView::contentsDropEvent" << endl;
121 121
122 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && 122 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
123 !QTextDrag::canDecode( e ) ) { 123 !QTextDrag::canDecode( e ) ) {
124 e->ignore(); 124 e->ignore();
125 return; 125 return;
126 } 126 }
127 127
128 DndFactory factory( mCalendar ); 128 DndFactory factory( mCalendar );
129 Todo *todo = factory.createDropTodo(e); 129 Todo *todo = factory.createDropTodo(e);
130 130
131 if (todo) { 131 if (todo) {
132 e->acceptAction(); 132 e->acceptAction();
133 133
134 KOTodoViewItem *destination = 134 KOTodoViewItem *destination =
135 (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); 135 (KOTodoViewItem *)itemAt(contentsToViewport(e->pos()));
136 Todo *destinationEvent = 0; 136 Todo *destinationEvent = 0;
137 if (destination) destinationEvent = destination->todo(); 137 if (destination) destinationEvent = destination->todo();
138 138
139 Todo *existingTodo = mCalendar->todo(todo->uid()); 139 Todo *existingTodo = mCalendar->todo(todo->uid());
140 140
141 if(existingTodo) { 141 if(existingTodo) {
142// kdDebug() << "Drop existing Todo" << endl; 142// kdDebug() << "Drop existing Todo" << endl;
143 Incidence *to = destinationEvent; 143 Incidence *to = destinationEvent;
144 while(to) { 144 while(to) {
145 if (to->uid() == todo->uid()) { 145 if (to->uid() == todo->uid()) {
146 KMessageBox::sorry(this, 146 KMessageBox::sorry(this,
147 i18n("Cannot move To-Do to itself or a child of itself"), 147 i18n("Cannot move To-Do to itself or a child of itself"),
148 i18n("Drop To-Do")); 148 i18n("Drop To-Do"));
149 delete todo; 149 delete todo;
150 return; 150 return;
151 } 151 }
152 to = to->relatedTo(); 152 to = to->relatedTo();
153 } 153 }
154 existingTodo->setRelatedTo(destinationEvent); 154 existingTodo->setRelatedTo(destinationEvent);
155 emit todoDropped(todo); 155 emit todoDropped(todo);
156 delete todo; 156 delete todo;
157 } else { 157 } else {
158// kdDebug() << "Drop new Todo" << endl; 158// kdDebug() << "Drop new Todo" << endl;
159 todo->setRelatedTo(destinationEvent); 159 todo->setRelatedTo(destinationEvent);
160 mCalendar->addTodo(todo); 160 mCalendar->addTodo(todo);
161 161
162 emit todoDropped(todo); 162 emit todoDropped(todo);
163 } 163 }
164 } 164 }
165 else { 165 else {
166 QString text; 166 QString text;
167 if (QTextDrag::decode(e,text)) { 167 if (QTextDrag::decode(e,text)) {
168 //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); 168 //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) );
169 KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); 169 KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) ));
170 kdDebug() << "Dropped : " << text << endl; 170 kdDebug() << "Dropped : " << text << endl;
171 QStringList emails = QStringList::split(",",text); 171 QStringList emails = QStringList::split(",",text);
172 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { 172 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) {
173 kdDebug() << " Email: " << (*it) << endl; 173 kdDebug() << " Email: " << (*it) << endl;
174 int pos = (*it).find("<"); 174 int pos = (*it).find("<");
175 QString name = (*it).left(pos); 175 QString name = (*it).left(pos);
176 QString email = (*it).mid(pos); 176 QString email = (*it).mid(pos);
177 if (!email.isEmpty() && todoi) { 177 if (!email.isEmpty() && todoi) {
178 todoi->todo()->addAttendee(new Attendee(name,email)); 178 todoi->todo()->addAttendee(new Attendee(name,email));
179 } 179 }
180 } 180 }
181 } 181 }
182 else { 182 else {
183 kdDebug() << "KOTodoListView::contentsDropEvent(): Todo from drop not decodable" << endl; 183 kdDebug() << "KOTodoListView::contentsDropEvent(): Todo from drop not decodable" << endl;
184 e->ignore(); 184 e->ignore();
185 } 185 }
186 } 186 }
187#endif 187#endif
188} 188}
189 189
190void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) 190void KOTodoListView::contentsMousePressEvent(QMouseEvent* e)
191{ 191{
192 QListView::contentsMousePressEvent(e); 192 QListView::contentsMousePressEvent(e);
193#ifndef KORG_NODND 193#ifndef KORG_NODND
194 QPoint p(contentsToViewport(e->pos())); 194 QPoint p(contentsToViewport(e->pos()));
195 QListViewItem *i = itemAt(p); 195 QListViewItem *i = itemAt(p);
196 if (i) { 196 if (i) {
197 // if the user clicked into the root decoration of the item, don't 197 // if the user clicked into the root decoration of the item, don't
198 // try to start a drag! 198 // try to start a drag!
199 if (p.x() > header()->sectionPos(header()->mapToIndex(0)) + 199 if (p.x() > header()->sectionPos(header()->mapToIndex(0)) +
200 treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + 200 treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) +
201 itemMargin() || 201 itemMargin() ||
202 p.x() < header()->sectionPos(header()->mapToIndex(0))) { 202 p.x() < header()->sectionPos(header()->mapToIndex(0))) {
203 if (e->button()==Qt::LeftButton) { 203 if (e->button()==Qt::LeftButton) {
204 mPressPos = e->pos(); 204 mPressPos = e->pos();
205 mMousePressed = true; 205 mMousePressed = true;
206 } 206 }
207 } 207 }
208 } 208 }
209#endif 209#endif
210} 210}
211 211
212void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) 212void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e)
213{ 213{
214 214
215#ifndef KORG_NODND 215#ifndef KORG_NODND
216// kdDebug() << "KOTodoListView::contentsMouseMoveEvent()" << endl; 216// kdDebug() << "KOTodoListView::contentsMouseMoveEvent()" << endl;
217 QListView::contentsMouseMoveEvent(e); 217 QListView::contentsMouseMoveEvent(e);
218 if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > 218 if (mMousePressed && (mPressPos - e->pos()).manhattanLength() >
219 QApplication::startDragDistance()) { 219 QApplication::startDragDistance()) {
220 mMousePressed = false; 220 mMousePressed = false;
221 QListViewItem *item = itemAt(contentsToViewport(mPressPos)); 221 QListViewItem *item = itemAt(contentsToViewport(mPressPos));
222 if (item) { 222 if (item) {
223// kdDebug() << "Start Drag for item " << item->text(0) << endl; 223// kdDebug() << "Start Drag for item " << item->text(0) << endl;
224 DndFactory factory( mCalendar ); 224 DndFactory factory( mCalendar );
225 ICalDrag *vd = factory.createDragTodo( 225 ICalDrag *vd = factory.createDragTodo(
226 ((KOTodoViewItem *)item)->todo(),viewport()); 226 ((KOTodoViewItem *)item)->todo(),viewport());
227 if (vd->drag()) { 227 if (vd->drag()) {
228 kdDebug() << "KOTodoListView::contentsMouseMoveEvent(): Delete drag source" << endl; 228 kdDebug() << "KOTodoListView::contentsMouseMoveEvent(): Delete drag source" << endl;
229 } 229 }
230/* 230/*
231 QString source = fullPath(item); 231 QString source = fullPath(item);
232 if ( QFile::exists(source) ) { 232 if ( QFile::exists(source) ) {
233 QUriDrag* ud = new QUriDrag(viewport()); 233 QUriDrag* ud = new QUriDrag(viewport());
234 ud->setFilenames( source ); 234 ud->setFilenames( source );
235 if ( ud->drag() ) 235 if ( ud->drag() )
236 QMessageBox::information( this, "Drag source", 236 QMessageBox::information( this, "Drag source",
237 QString("Delete ")+source, "Not implemented" ); 237 QString("Delete ")+source, "Not implemented" );
238*/ 238*/
239 } 239 }
240 } 240 }
241#endif 241#endif
242} 242}
243void KOTodoListView::keyPressEvent ( QKeyEvent * e ) 243void KOTodoListView::keyPressEvent ( QKeyEvent * e )
244{ 244{
245 245
246 QListViewItem* cn; 246 QListViewItem* cn;
247 if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { 247 if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) {
248 cn = currentItem(); 248 cn = currentItem();
249 if ( cn ) { 249 if ( cn ) {
250 KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); 250 KOTodoViewItem* ci = (KOTodoViewItem*)( cn );
251 if ( ci ){ 251 if ( ci ){
252 if ( e->state() == ShiftButton ) 252 if ( e->state() == ShiftButton )
253 ci->setOn( false ); 253 ci->setOn( false );
254 else 254 else
255 ci->setOn( true ); 255 ci->setOn( true );
256 cn = cn->nextSibling(); 256 cn = cn->nextSibling();
257 if ( cn ) { 257 if ( cn ) {
258 setCurrentItem ( cn ); 258 setCurrentItem ( cn );
259 ensureItemVisible ( cn ); 259 ensureItemVisible ( cn );
260 } 260 }
261 261
262 } 262 }
263 } 263 }
264 264
265 return; 265 return;
266 } 266 }
267 267
268 // qDebug("KOTodoListView::keyPressEvent "); 268 // qDebug("KOTodoListView::keyPressEvent ");
269 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { 269 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) {
270 switch ( e->key() ) { 270 switch ( e->key() ) {
271 case Qt::Key_Down: 271 case Qt::Key_Down:
272 case Qt::Key_Up: 272 case Qt::Key_Up:
273 QListView::keyPressEvent ( e ); 273 QListView::keyPressEvent ( e );
274 break; 274 break;
275 case Qt::Key_Left: 275 case Qt::Key_Left:
276 case Qt::Key_Right: 276 case Qt::Key_Right:
277 QListView::keyPressEvent ( e ); 277 QListView::keyPressEvent ( e );
278 e->accept(); 278 e->accept();
279 return; 279 return;
280 break; 280 break;
281 default: 281 default:
282 e->ignore(); 282 e->ignore();
283 break; 283 break;
284 } 284 }
285 return; 285 return;
286 } 286 }
287 e->ignore(); 287 e->ignore();
288} 288}
289void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) 289void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e)
290{ 290{
291 QListView::contentsMouseReleaseEvent(e); 291 QListView::contentsMouseReleaseEvent(e);
292 mMousePressed = false; 292 mMousePressed = false;
293} 293}
294 294
295void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) 295void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e)
296{ 296{
297 if (!e) return; 297 if (!e) return;
298 298
299 QPoint vp = contentsToViewport(e->pos()); 299 QPoint vp = contentsToViewport(e->pos());
300 300
301 QListViewItem *item = itemAt(vp); 301 QListViewItem *item = itemAt(vp);
302 302
303 emit double_Clicked(item); 303 emit double_Clicked(item);
304 if (!item) return; 304 if (!item) return;
305 305
306 emit doubleClicked(item,vp,0); 306 emit doubleClicked(item,vp,0);
307} 307}
308 308
309///////////////////////////////////////////////////////////////////////////// 309/////////////////////////////////////////////////////////////////////////////
310 310
311KOQuickTodo::KOQuickTodo(QWidget *parent) : 311KOQuickTodo::KOQuickTodo(QWidget *parent) :
312 QLineEdit(parent) 312 QLineEdit(parent)
313{ 313{
314 setText(i18n("Click to add a new Todo")); 314 setText(i18n("Click to add a new Todo"));
315} 315}
316 316
317void KOQuickTodo::focusInEvent(QFocusEvent *ev) 317void KOQuickTodo::focusInEvent(QFocusEvent *ev)
318{ 318{
319 if ( text()==i18n("Click to add a new Todo") ) 319 if ( text()==i18n("Click to add a new Todo") )
320 setText(""); 320 setText("");
321 QLineEdit::focusInEvent(ev); 321 QLineEdit::focusInEvent(ev);
322} 322}
323 323
324void KOQuickTodo::focusOutEvent(QFocusEvent *ev) 324void KOQuickTodo::focusOutEvent(QFocusEvent *ev)
325{ 325{
326 setText(i18n("Click to add a new Todo")); 326 setText(i18n("Click to add a new Todo"));
327 QLineEdit::focusOutEvent(ev); 327 QLineEdit::focusOutEvent(ev);
328} 328}
329 329
330///////////////////////////////////////////////////////////////////////////// 330/////////////////////////////////////////////////////////////////////////////
331 331
332KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : 332KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) :
333 KOrg::BaseView(calendar,parent,name) 333 KOrg::BaseView(calendar,parent,name)
334{ 334{
335 mNavigator = 0; 335 mNavigator = 0;
336 QBoxLayout *topLayout = new QVBoxLayout(this); 336 QBoxLayout *topLayout = new QVBoxLayout(this);
337 mName = QString ( name ); 337 mName = QString ( name );
338 mBlockUpdate = false; 338 mBlockUpdate = false;
339 mQuickAdd = new KOQuickTodo(this); 339 mQuickAdd = new KOQuickTodo(this);
340 topLayout->addWidget(mQuickAdd); 340 topLayout->addWidget(mQuickAdd);
341 341
342 if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); 342 if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide();
343 343
344 mTodoListView = new KOTodoListView(calendar,this, name ); 344 mTodoListView = new KOTodoListView(calendar,this, name );
345 topLayout->addWidget(mTodoListView); 345 topLayout->addWidget(mTodoListView);
346 //mTodoListView->header()->setMaximumHeight(30); 346 //mTodoListView->header()->setMaximumHeight(30);
347 mTodoListView->setRootIsDecorated(true); 347 mTodoListView->setRootIsDecorated(true);
348 mTodoListView->setAllColumnsShowFocus(true); 348 mTodoListView->setAllColumnsShowFocus(true);
349 349
350 mTodoListView->setShowSortIndicator(true); 350 mTodoListView->setShowSortIndicator(true);
351 351
352 mTodoListView->addColumn(i18n("Todo")); 352 mTodoListView->addColumn(i18n("Todo"));
353 mTodoListView->addColumn(i18n("Prio")); 353 mTodoListView->addColumn(i18n("Prio"));
354 mTodoListView->setColumnAlignment(1,AlignHCenter); 354 mTodoListView->setColumnAlignment(1,AlignHCenter);
355 mTodoListView->addColumn(i18n("Complete")); 355 mTodoListView->addColumn(i18n("Complete"));
356 mTodoListView->setColumnAlignment(2,AlignCenter); 356 mTodoListView->setColumnAlignment(2,AlignCenter);
357 357
358 mTodoListView->addColumn(i18n("Due Date")); 358 mTodoListView->addColumn(i18n("Due Date"));
359 mTodoListView->setColumnAlignment(3,AlignLeft); 359 mTodoListView->setColumnAlignment(3,AlignLeft);
360 mTodoListView->addColumn(i18n("Due Time")); 360 mTodoListView->addColumn(i18n("Due Time"));
361 mTodoListView->setColumnAlignment(4,AlignHCenter); 361 mTodoListView->setColumnAlignment(4,AlignHCenter);
362 362
363 mTodoListView->addColumn(i18n("Start Date")); 363 mTodoListView->addColumn(i18n("Start Date"));
364 mTodoListView->setColumnAlignment(5,AlignLeft); 364 mTodoListView->setColumnAlignment(5,AlignLeft);
365 mTodoListView->addColumn(i18n("Start Time")); 365 mTodoListView->addColumn(i18n("Start Time"));
366 mTodoListView->setColumnAlignment(6,AlignHCenter); 366 mTodoListView->setColumnAlignment(6,AlignHCenter);
367 367
368 mTodoListView->addColumn(i18n("Cancelled")); 368 mTodoListView->addColumn(i18n("Cancelled"));
369 mTodoListView->addColumn(i18n("Categories")); 369 mTodoListView->addColumn(i18n("Categories"));
370#if 0 370#if 0
371 mTodoListView->addColumn(i18n("Sort Id")); 371 mTodoListView->addColumn(i18n("Sort Id"));
372 mTodoListView->setColumnAlignment(4,AlignHCenter); 372 mTodoListView->setColumnAlignment(4,AlignHCenter);
373#endif 373#endif
374 374
375 mTodoListView->setMinimumHeight( 60 ); 375 mTodoListView->setMinimumHeight( 60 );
376 mTodoListView->setItemsRenameable( true ); 376 mTodoListView->setItemsRenameable( true );
377 mTodoListView->setRenameable( 0 ); 377 mTodoListView->setRenameable( 0 );
378 mTodoListView->setColumnWidth( 0, 120 ); 378 mTodoListView->setColumnWidth( 0, 120 );
379 mTodoListView->setColumnWidthMode(0, QListView::Manual); 379 mTodoListView->setColumnWidthMode(0, QListView::Manual);
380 mTodoListView->setColumnWidthMode(1, QListView::Manual); 380 mTodoListView->setColumnWidthMode(1, QListView::Manual);
381 mTodoListView->setColumnWidthMode(2, QListView::Manual); 381 mTodoListView->setColumnWidthMode(2, QListView::Manual);
382 mTodoListView->setColumnWidthMode(3, QListView::Manual); 382 mTodoListView->setColumnWidthMode(3, QListView::Manual);
383 mTodoListView->setColumnWidthMode(4, QListView::Manual); 383 mTodoListView->setColumnWidthMode(4, QListView::Manual);
384 mTodoListView->setColumnWidthMode(5, QListView::Manual); 384 mTodoListView->setColumnWidthMode(5, QListView::Manual);
385 mTodoListView->setColumnWidthMode(6, QListView::Manual); 385 mTodoListView->setColumnWidthMode(6, QListView::Manual);
386 mTodoListView->setColumnWidthMode(7, QListView::Manual); 386 mTodoListView->setColumnWidthMode(7, QListView::Manual);
387 mTodoListView->setColumnWidthMode(8, QListView::Manual); 387 mTodoListView->setColumnWidthMode(8, QListView::Manual);
388 388
389 389
390 mPriorityPopupMenu = new QPopupMenu(this); 390 mPriorityPopupMenu = new QPopupMenu(this);
391 for (int i = 1; i <= 5; i++) { 391 for (int i = 1; i <= 5; i++) {
392 QString label = QString ("%1").arg (i); 392 QString label = QString ("%1").arg (i);
393 mPriority[mPriorityPopupMenu->insertItem (label)] = i; 393 mPriority[mPriorityPopupMenu->insertItem (label)] = i;
394 } 394 }
395 connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); 395 connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int)));
396 396
397 mPercentageCompletedPopupMenu = new QPopupMenu(this); 397 mPercentageCompletedPopupMenu = new QPopupMenu(this);
398 for (int i = 0; i <= 100; i+=20) { 398 for (int i = 0; i <= 100; i+=20) {
399 QString label = QString ("%1 %").arg (i); 399 QString label = QString ("%1 %").arg (i);
400 mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; 400 mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i;
401 } 401 }
402 connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); 402 connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int)));
403 403
404 404
405 405
406 mItemPopupMenu = new QPopupMenu(this); 406 mItemPopupMenu = new QPopupMenu(this);
407 mItemPopupMenu->insertItem(i18n("Show..."), this, 407 mItemPopupMenu->insertItem(i18n("Show..."), this,
408 SLOT (showTodo())); 408 SLOT (showTodo()));
409 mItemPopupMenu->insertItem(i18n("Edit..."), this, 409 mItemPopupMenu->insertItem(i18n("Edit..."), this,
410 SLOT (editTodo())); 410 SLOT (editTodo()));
411 mItemPopupMenu->insertItem( i18n("Delete"), this, 411 mItemPopupMenu->insertItem( i18n("Delete"), this,
412 SLOT (deleteTodo())); 412 SLOT (deleteTodo()));
413 mItemPopupMenu->insertItem( i18n("Clone..."), this, 413 mItemPopupMenu->insertItem( i18n("Clone..."), this,
414 SLOT (cloneTodo())); 414 SLOT (cloneTodo()));
415 mItemPopupMenu->insertItem( i18n("Move..."), this, 415 mItemPopupMenu->insertItem( i18n("Move..."), this,
416 SLOT (moveTodo())); 416 SLOT (moveTodo()));
417 mItemPopupMenu->insertItem( i18n("Beam..."), this, 417 mItemPopupMenu->insertItem( i18n("Beam..."), this,
418 SLOT (beamTodo())); 418 SLOT (beamTodo()));
419 mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, 419 mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this,
420 SLOT (cancelTodo())); 420 SLOT (cancelTodo()));
421 mItemPopupMenu->insertSeparator(); 421 mItemPopupMenu->insertSeparator();
422 422
423 mItemPopupMenu->insertItem( i18n("New Todo..."), this, 423 mItemPopupMenu->insertItem( i18n("New Todo..."), this,
424 SLOT (newTodo())); 424 SLOT (newTodo()));
425 mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, 425 mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this,
426 SLOT (newSubTodo())); 426 SLOT (newSubTodo()));
427 mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, 427 mItemPopupMenu->insertItem(i18n("Unparent Todo"), this,
428 SLOT (unparentTodo()),0,21); 428 SLOT (unparentTodo()),0,21);
429 mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, 429 mItemPopupMenu->insertItem(i18n("Reparent Todo"), this,
430 SLOT (reparentTodo()),0,22); 430 SLOT (reparentTodo()),0,22);
431 mItemPopupMenu->insertSeparator(); 431 mItemPopupMenu->insertSeparator();
432 mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"), 432 mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"),
433 this, SLOT( purgeCompleted() ) ); 433 this, SLOT( purgeCompleted() ) );
434 mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), 434 mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"),
435 this, SLOT( toggleCompleted() ),0, 33 ); 435 this, SLOT( toggleCompleted() ),0, 33 );
436 mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), 436 mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"),
437 this, SLOT( toggleQuickTodo() ),0, 34 ); 437 this, SLOT( toggleQuickTodo() ),0, 34 );
438 mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), 438 mItemPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"),
439 this, SLOT( toggleRunning() ),0, 35 ); 439 this, SLOT( toggleRunning() ),0, 35 );
440 440
441 mPopupMenu = new QPopupMenu(this); 441 mPopupMenu = new QPopupMenu(this);
442 mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, 442 mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this,
443 SLOT (newTodo()),0,1); 443 SLOT (newTodo()),0,1);
444 mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"), 444 mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"),
445 this, SLOT(purgeCompleted()),0,2); 445 this, SLOT(purgeCompleted()),0,2);
446 mPopupMenu->insertItem(i18n("Show Completed"), 446 mPopupMenu->insertItem(i18n("Show Completed"),
447 this, SLOT( toggleCompleted() ),0,3 ); 447 this, SLOT( toggleCompleted() ),0,3 );
448 mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), 448 mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"),
449 this, SLOT( toggleQuickTodo() ),0,4 ); 449 this, SLOT( toggleQuickTodo() ),0,4 );
450 mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"), 450 mPopupMenu->insertItem(i18n("toggle running todo","Hide not Running"),
451 this, SLOT( toggleRunning() ),0,5 ); 451 this, SLOT( toggleRunning() ),0,5 );
452 mDocPrefs = new DocPrefs( name ); 452 mDocPrefs = new DocPrefs( name );
453 453
454 mPopupMenu->setCheckable( true ); 454 mPopupMenu->setCheckable( true );
455 mItemPopupMenu->setCheckable( true ); 455 mItemPopupMenu->setCheckable( true );
456 456
457 457
458 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); 458 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo );
459 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); 459 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo );
460 460
461 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); 461 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo);
462 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); 462 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo );
463 463
464 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); 464 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos);
465 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); 465 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos );
466 466
467 467
468 // Double clicking conflicts with opening/closing the subtree 468 // Double clicking conflicts with opening/closing the subtree
469 connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), 469 connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ),
470 SLOT( editItem( QListViewItem *) ) ); 470 SLOT( editItem( QListViewItem *) ) );
471 /* 471 /*
472 connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, 472 connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *,
473 const QPoint &,int ) ), 473 const QPoint &,int ) ),
474 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); 474 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) );
475 */ 475 */
476 connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, 476 connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *,
477 const QPoint &,int ) ), 477 const QPoint &,int ) ),
478 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); 478 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) );
479 connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), 479 connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ),
480 SLOT( itemClicked( QListViewItem * ) ) ); 480 SLOT( itemClicked( QListViewItem * ) ) );
481 connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), 481 connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ),
482 SLOT( itemDoubleClicked( QListViewItem * ) ) ); 482 SLOT( itemDoubleClicked( QListViewItem * ) ) );
483 connect( mTodoListView, SIGNAL( todoDropped( Todo * ) ), 483 connect( mTodoListView, SIGNAL( todoDropped( Todo * ) ),
484 SLOT( updateView() ) ); 484 SLOT( updateView() ) );
485 connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), 485 connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ),
486 SLOT( itemStateChanged( QListViewItem * ) ) ); 486 SLOT( itemStateChanged( QListViewItem * ) ) );
487 connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), 487 connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ),
488 SLOT( itemStateChanged( QListViewItem * ) ) ); 488 SLOT( itemStateChanged( QListViewItem * ) ) );
489 489
490#if 0 490#if 0
491 connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), 491 connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)),
492 SLOT(selectionChanged(QListViewItem *))); 492 SLOT(selectionChanged(QListViewItem *)));
493 connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), 493 connect(mTodoListView,SIGNAL(clicked(QListViewItem *)),
494 SLOT(selectionChanged(QListViewItem *))); 494 SLOT(selectionChanged(QListViewItem *)));
495 connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), 495 connect(mTodoListView,SIGNAL(pressed(QListViewItem *)),
496 SLOT(selectionChanged(QListViewItem *))); 496 SLOT(selectionChanged(QListViewItem *)));
497#endif 497#endif
498 connect( mTodoListView, SIGNAL(selectionChanged() ), 498 connect( mTodoListView, SIGNAL(selectionChanged() ),
499 SLOT( processSelectionChange() ) ); 499 SLOT( processSelectionChange() ) );
500 connect( mQuickAdd, SIGNAL( returnPressed () ), 500 connect( mQuickAdd, SIGNAL( returnPressed () ),
501 SLOT( addQuickTodo() ) ); 501 SLOT( addQuickTodo() ) );
502 502
503} 503}
504 504
505KOTodoView::~KOTodoView() 505KOTodoView::~KOTodoView()
506{ 506{
507 delete mDocPrefs; 507 delete mDocPrefs;
508} 508}
509 509
510void KOTodoView::jumpToDate () 510void KOTodoView::jumpToDate ()
511{ 511{
512 // if (mActiveItem) { 512 // if (mActiveItem) {
513// mActiveItem->todo()); 513// mActiveItem->todo());
514// if ( mActiveItem->todo()->hasDueDate() ) 514// if ( mActiveItem->todo()->hasDueDate() )
515// emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); 515// emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() );
516} 516}
517 517
518void KOTodoView::updateView() 518void KOTodoView::updateView()
519{ 519{
520 pendingSubtodo = 0; 520 pendingSubtodo = 0;
521 if ( mBlockUpdate ) { 521 if ( mBlockUpdate ) {
522 //qDebug("blocked "); 522 //qDebug("blocked ");
523 return; 523 return;
524 } 524 }
525 //qDebug("update "); 525 //qDebug("update ");
526// kdDebug() << "KOTodoView::updateView()" << endl; 526// kdDebug() << "KOTodoView::updateView()" << endl;
527 QFont fo = KOPrefs::instance()->mTodoViewFont; 527 QFont fo = KOPrefs::instance()->mTodoViewFont;
528 mTodoListView->clear(); 528 mTodoListView->clear();
529 if ( mName == "todolistsmall" ) { 529 if ( mName == "todolistsmall" ) {
530 if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { 530 if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) {
531 int ps = fo.pointSize() -2; 531 int ps = fo.pointSize() -2;
532 if ( ps > 12 ) 532 if ( ps > 12 )
533 ps -= 2; 533 ps -= 2;
534 fo.setPointSize( ps ); 534 fo.setPointSize( ps );
535 } 535 }
536 } 536 }
537 537
538 mTodoListView->setFont( fo ); 538 mTodoListView->setFont( fo );
539 // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); 539 // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont );
540 //mTodoListView->header()->setMaximumHeight(fm.height()); 540 //mTodoListView->header()->setMaximumHeight(fm.height());
541 QPtrList<Todo> todoList = calendar()->todos(); 541 QPtrList<Todo> todoList = calendar()->todos();
542 542
543/* 543/*
544 kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; 544 kdDebug() << "KOTodoView::updateView(): Todo List:" << endl;
545 Event *t; 545 Event *t;
546 for(t = todoList.first(); t; t = todoList.next()) { 546 for(t = todoList.first(); t; t = todoList.next()) {
547 kdDebug() << " " << t->getSummary() << endl; 547 kdDebug() << " " << t->getSummary() << endl;
548 548
549 if (t->getRelatedTo()) { 549 if (t->getRelatedTo()) {
550 kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; 550 kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl;
551 } 551 }
552 552
553 QPtrList<Event> l = t->getRelations(); 553 QPtrList<Event> l = t->getRelations();
554 Event *c; 554 Event *c;
555 for(c=l.first();c;c=l.next()) { 555 for(c=l.first();c;c=l.next()) {
556 kdDebug() << " - relation: " << c->getSummary() << endl; 556 kdDebug() << " - relation: " << c->getSummary() << endl;
557 } 557 }
558 } 558 }
559*/ 559*/
560 560
561 // Put for each Event a KOTodoViewItem in the list view. Don't rely on a 561 // Put for each Event a KOTodoViewItem in the list view. Don't rely on a
562 // specific order of events. That means that we have to generate parent items 562 // specific order of events. That means that we have to generate parent items
563 // recursively for proper hierarchical display of Todos. 563 // recursively for proper hierarchical display of Todos.
564 mTodoMap.clear(); 564 mTodoMap.clear();
565 Todo *todo; 565 Todo *todo;
566 todo = todoList.first();// todo; todo = todoList.next()) { 566 todo = todoList.first();// todo; todo = todoList.next()) {
567 while ( todo ) { 567 while ( todo ) {
568 bool next = true; 568 bool next = true;
569 // qDebug("todo %s ", todo->summary().latin1()); 569 // qDebug("todo %s ", todo->summary().latin1());
570 Incidence *incidence = todo->relatedTo(); 570 Incidence *incidence = todo->relatedTo();
571 while ( incidence ) { 571 while ( incidence ) {
572 if ( incidence->type() == "Todo") { 572 if ( incidence->type() == "Todo") {
573 //qDebug("related %s ",incidence->summary().latin1() ); 573 //qDebug("related %s ",incidence->summary().latin1() );
574 if ( !(todoList.contains ( ((Todo* )incidence ) ) )) { 574 if ( !(todoList.contains ( ((Todo* )incidence ) ) )) {
575 //qDebug("related not found "); 575 //qDebug("related not found ");
576 todoList.remove( ); 576 todoList.remove( );
577 todo = todoList.current(); 577 todo = todoList.current();
578 next = false; 578 next = false;
579 incidence = 0; 579 incidence = 0;
580 580
581 } else { 581 } else {
582 //qDebug("related found "); 582 //qDebug("related found ");
583 incidence = incidence->relatedTo(); 583 incidence = incidence->relatedTo();
584 } 584 }
585 } else 585 } else
586 incidence = 0; 586 incidence = 0;
587 } 587 }
588 if ( next ) 588 if ( next )
589 todo = todoList.next(); 589 todo = todoList.next();
590 } 590 }
591// qDebug("again .... "); 591// qDebug("again .... ");
592// for(todo = todoList.first(); todo; todo = todoList.next()) { 592// for(todo = todoList.first(); todo; todo = todoList.next()) {
593 593
594// qDebug("yytodo %s ", todo->summary().latin1()); 594// qDebug("yytodo %s ", todo->summary().latin1());
595// } 595// }
596 //qDebug("for "); 596 //qDebug("for ");
597 for(todo = todoList.first(); todo; todo = todoList.next()) { 597 for(todo = todoList.first(); todo; todo = todoList.next()) {
598 if (!mTodoMap.contains(todo) && checkTodo( todo ) ) 598 if (!mTodoMap.contains(todo) && checkTodo( todo ) )
599 { 599 {
600 insertTodoItem(todo); 600 insertTodoItem(todo);
601 } 601 }
602 } 602 }
603 //qDebug("for end "); 603 //qDebug("for end ");
604 // Restore opened/closed state 604 // Restore opened/closed state
605 mTodoListView->blockSignals( true ); 605 mTodoListView->blockSignals( true );
606 if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); 606 if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() );
607 mTodoListView->blockSignals( false ); 607 mTodoListView->blockSignals( false );
608 mTodoListView->setFocus(); 608 mTodoListView->setFocus();
609 processSelectionChange(); 609 processSelectionChange();
610} 610}
611 611
612bool KOTodoView::checkTodo( Todo * todo ) 612bool KOTodoView::checkTodo( Todo * todo )
613{ 613{
614 614
615 if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) 615 if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() )
616 return false; 616 return false;
617 if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { 617 if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) {
618 if ( todo->hasStartDate() ) 618 if ( todo->hasStartDate() )
619 if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) 619 if ( mNavigator->selectedDates().last() < todo->dtStart().date() )
620 return false; 620 return false;
621 if ( todo->hasDueDate() ) 621 if ( todo->hasDueDate() )
622 if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) 622 if ( mNavigator->selectedDates().first() > todo->dtDue().date() )
623 return false; 623 return false;
624 } 624 }
625 return true; 625 return true;
626} 626}
627 627
628void KOTodoView::restoreItemState( QListViewItem *item ) 628void KOTodoView::restoreItemState( QListViewItem *item )
629{ 629{
630 pendingSubtodo = 0; 630 pendingSubtodo = 0;
631 while( item ) { 631 while( item ) {
632 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 632 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
633 todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); 633 todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) );
634 if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); 634 if( item->childCount() > 0 ) restoreItemState( item->firstChild() );
635 item = item->nextSibling(); 635 item = item->nextSibling();
636 } 636 }
637} 637}
638 638
639 639
640QMap<Todo *,KOTodoViewItem *>::ConstIterator 640QMap<Todo *,KOTodoViewItem *>::ConstIterator
641 KOTodoView::insertTodoItem(Todo *todo) 641 KOTodoView::insertTodoItem(Todo *todo)
642{ 642{
643 643
644// kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; 644// kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl;
645 // TODO: Check, if dynmaic cast is necessary 645 // TODO: Check, if dynmaic cast is necessary
646 646
647 pendingSubtodo = 0; 647 pendingSubtodo = 0;
648 Incidence *incidence = todo->relatedTo(); 648 Incidence *incidence = todo->relatedTo();
649 if (incidence && incidence->type() == "Todo") { 649 if (incidence && incidence->type() == "Todo") {
650 Todo *relatedTodo = static_cast<Todo *>(incidence); 650 Todo *relatedTodo = static_cast<Todo *>(incidence);
651 651
652// kdDebug() << " has Related" << endl; 652// kdDebug() << " has Related" << endl;
653 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; 653 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator;
654 itemIterator = mTodoMap.find(relatedTodo); 654 itemIterator = mTodoMap.find(relatedTodo);
655 if (itemIterator == mTodoMap.end()) { 655 if (itemIterator == mTodoMap.end()) {
656// kdDebug() << " related not yet in list" << endl; 656// kdDebug() << " related not yet in list" << endl;
657 itemIterator = insertTodoItem (relatedTodo); 657 itemIterator = insertTodoItem (relatedTodo);
658 } 658 }
659 // isn't this pretty stupid? We give one Todo to the KOTodoViewItem 659 // isn't this pretty stupid? We give one Todo to the KOTodoViewItem
660 // and one into the map. Sure finding is more easy but why? -zecke 660 // and one into the map. Sure finding is more easy but why? -zecke
661 KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); 661 KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this);
662 return mTodoMap.insert(todo,todoItem); 662 return mTodoMap.insert(todo,todoItem);
663 } else { 663 } else {
664// kdDebug() << " no Related" << endl; 664// kdDebug() << " no Related" << endl;
665 // see above -zecke 665 // see above -zecke
666 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); 666 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this);
667 return mTodoMap.insert(todo,todoItem); 667 return mTodoMap.insert(todo,todoItem);
668 } 668 }
669} 669}
670 670
671 671
672void KOTodoView::updateConfig() 672void KOTodoView::updateConfig()
673{ 673{
674 updateView(); 674 updateView();
675 mTodoListView->repaintContents(); 675 mTodoListView->repaintContents();
676} 676}
677 677
678QPtrList<Incidence> KOTodoView::selectedIncidences() 678QPtrList<Incidence> KOTodoView::selectedIncidences()
679{ 679{
680 QPtrList<Incidence> selected; 680 QPtrList<Incidence> selected;
681 681
682 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); 682 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem());
683// if (!item) item = mActiveItem; 683// if (!item) item = mActiveItem;
684 if (item) selected.append(item->todo()); 684 if (item) selected.append(item->todo());
685 685
686 return selected; 686 return selected;
687} 687}
688 688
689QPtrList<Todo> KOTodoView::selectedTodos() 689QPtrList<Todo> KOTodoView::selectedTodos()
690{ 690{
691 QPtrList<Todo> selected; 691 QPtrList<Todo> selected;
692 692
693 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); 693 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem());
694// if (!item) item = mActiveItem; 694// if (!item) item = mActiveItem;
695 if (item) selected.append(item->todo()); 695 if (item) selected.append(item->todo());
696 696
697 return selected; 697 return selected;
698} 698}
699 699
700void KOTodoView::changeEventDisplay(Event *, int) 700void KOTodoView::changeEventDisplay(Event *, int)
701{ 701{
702 updateView(); 702 updateView();
703} 703}
704 704
705void KOTodoView::showDates(const QDate &, const QDate &) 705void KOTodoView::showDates(const QDate &, const QDate &)
706{ 706{
707} 707}
708 708
709void KOTodoView::showEvents(QPtrList<Event>) 709void KOTodoView::showEvents(QPtrList<Event>)
710{ 710{
711 kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; 711 kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl;
712} 712}
713 713
714void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, 714void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd,
715 const QDate &td) 715 const QDate &td)
716{ 716{
717#ifndef KORG_NOPRINTER 717#ifndef KORG_NOPRINTER
718 calPrinter->preview(CalPrinter::Todolist, fd, td); 718 calPrinter->preview(CalPrinter::Todolist, fd, td);
719#endif 719#endif
720} 720}
721 721
722void KOTodoView::editItem(QListViewItem *item ) 722void KOTodoView::editItem(QListViewItem *item )
723{ 723{
724 // qDebug("editItem(QListViewItem *item ) "); 724 // qDebug("editItem(QListViewItem *item ) ");
725 emit editTodoSignal(((KOTodoViewItem *)item)->todo()); 725 emit editTodoSignal(((KOTodoViewItem *)item)->todo());
726} 726}
727 727
728void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) 728void KOTodoView::showItem(QListViewItem *item,const QPoint &,int)
729{ 729{
730 emit showTodoSignal(((KOTodoViewItem *)item)->todo()); 730 emit showTodoSignal(((KOTodoViewItem *)item)->todo());
731} 731}
732 732
733void KOTodoView::popupMenu(QListViewItem *item,const QPoint &,int column) 733void KOTodoView::popupMenu(QListViewItem *item,const QPoint &,int column)
734{ 734{
735 pendingSubtodo = 0; 735 pendingSubtodo = 0;
736 mActiveItem = (KOTodoViewItem *)item; 736 mActiveItem = (KOTodoViewItem *)item;
737 if (item) { 737 if (item) {
738 switch (column){ 738 switch (column){
739 case 1: 739 case 1:
740 mPriorityPopupMenu->popup(QCursor::pos ()); break; 740 mPriorityPopupMenu->popup(QCursor::pos ()); break;
741 case 2: 741 case 2:
742 mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; 742 mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break;
743 case 3: 743 case 3:
744 moveTodo(); 744 moveTodo();
745 break; 745 break;
746 case 8: 746 case 8:
747 getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; 747 getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break;
748 default: 748 default:
749 mItemPopupMenu->popup(QCursor::pos()); 749 mItemPopupMenu->popup(QCursor::pos());
750 } 750 }
751 } else mPopupMenu->popup(QCursor::pos()); 751 } else mPopupMenu->popup(QCursor::pos());
752} 752}
753void KOTodoView::newTodo() 753void KOTodoView::newTodo()
754{ 754{
755 emit newTodoSignal(); 755 emit newTodoSignal();
756} 756}
757 757
758void KOTodoView::newSubTodo() 758void KOTodoView::newSubTodo()
759{ 759{
760 if (mActiveItem) { 760 if (mActiveItem) {
761 emit newSubTodoSignal(mActiveItem->todo()); 761 emit newSubTodoSignal(mActiveItem->todo());
762 } 762 }
763} 763}
764void KOTodoView::unparentTodo() 764void KOTodoView::unparentTodo()
765{ 765{
766 if (mActiveItem) { 766 if (mActiveItem) {
767 emit unparentTodoSignal(mActiveItem->todo()); 767 emit unparentTodoSignal(mActiveItem->todo());
768 } 768 }
769} 769}
770 770
771void KOTodoView::reparentTodo() 771void KOTodoView::reparentTodo()
772{ 772{
773 if (mActiveItem) { 773 if (mActiveItem) {
774 qDebug("KOTodoView::reparentTodo() "); 774 qDebug("KOTodoView::reparentTodo() ");
775 topLevelWidget()->setCaption(i18n("Click on new parent item")); 775 topLevelWidget()->setCaption(i18n("Click on new parent item"));
776 pendingSubtodo = mActiveItem; 776 pendingSubtodo = mActiveItem;
777 } 777 }
778} 778}
779void KOTodoView::editTodo() 779void KOTodoView::editTodo()
780{ 780{
781 if (mActiveItem) { 781 if (mActiveItem) {
782 emit editTodoSignal(mActiveItem->todo()); 782 emit editTodoSignal(mActiveItem->todo());
783 } 783 }
784} 784}
785void KOTodoView::cloneTodo() 785void KOTodoView::cloneTodo()
786{ 786{
787 if (mActiveItem) { 787 if (mActiveItem) {
788 emit cloneTodoSignal((Incidence*)mActiveItem->todo()); 788 emit cloneTodoSignal((Incidence*)mActiveItem->todo());
789 } 789 }
790} 790}
791void KOTodoView::cancelTodo() 791void KOTodoView::cancelTodo()
792{ 792{
793 if (mActiveItem) { 793 if (mActiveItem) {
794 emit cancelTodoSignal((Incidence*)mActiveItem->todo()); 794 emit cancelTodoSignal((Incidence*)mActiveItem->todo());
795 } 795 }
796} 796}
797void KOTodoView::moveTodo() 797void KOTodoView::moveTodo()
798{ 798{
799 if (mActiveItem) { 799 if (mActiveItem) {
800 emit moveTodoSignal((Incidence*)mActiveItem->todo()); 800 emit moveTodoSignal((Incidence*)mActiveItem->todo());
801 } 801 }
802} 802}
803void KOTodoView::beamTodo() 803void KOTodoView::beamTodo()
804{ 804{
805 if (mActiveItem) { 805 if (mActiveItem) {
806 emit beamTodoSignal((Incidence*)mActiveItem->todo()); 806 emit beamTodoSignal((Incidence*)mActiveItem->todo());
807 } 807 }
808} 808}
809 809
810 810
811void KOTodoView::showTodo() 811void KOTodoView::showTodo()
812{ 812{
813 if (mActiveItem) { 813 if (mActiveItem) {
814 emit showTodoSignal(mActiveItem->todo()); 814 emit showTodoSignal(mActiveItem->todo());
815 } 815 }
816} 816}
817 817
818void KOTodoView::deleteTodo() 818void KOTodoView::deleteTodo()
819{ 819{
820 if (mActiveItem) { 820 if (mActiveItem) {
821 if (mActiveItem->childCount()) {
822 KMessageBox::sorry(this,i18n("Cannot delete To-Do which has children."),
823 i18n("Delete To-Do"));
824 } else {
825 emit deleteTodoSignal(mActiveItem->todo()); 821 emit deleteTodoSignal(mActiveItem->todo());
826 }
827 } 822 }
828} 823}
829 824
830void KOTodoView::setNewPriority(int index) 825void KOTodoView::setNewPriority(int index)
831{ 826{
832 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 827 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
833 mActiveItem->todo()->setPriority(mPriority[index]); 828 mActiveItem->todo()->setPriority(mPriority[index]);
834 mActiveItem->construct(); 829 mActiveItem->construct();
835 todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); 830 todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED);
836 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 831 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
837 } 832 }
838} 833}
839 834
840void KOTodoView::setNewPercentage(int index) 835void KOTodoView::setNewPercentage(int index)
841{ 836{
842 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 837 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
843 if (mPercentage[index] == 100) { 838 if (mPercentage[index] == 100) {
844 mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); 839 mActiveItem->todo()->setCompleted(QDateTime::currentDateTime());
845 } else { 840 } else {
846 mActiveItem->todo()->setCompleted(false); 841 mActiveItem->todo()->setCompleted(false);
847 } 842 }
848 mActiveItem->todo()->setPercentComplete(mPercentage[index]); 843 mActiveItem->todo()->setPercentComplete(mPercentage[index]);
849 mActiveItem->construct(); 844 mActiveItem->construct();
850 todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); 845 todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED);
851 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 846 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
852 } 847 }
853} 848}
854 849
855 850
856QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) 851QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem)
857{ 852{
858 QPopupMenu* tempMenu = new QPopupMenu (this); 853 QPopupMenu* tempMenu = new QPopupMenu (this);
859 QStringList checkedCategories = todoItem->todo()->categories (); 854 QStringList checkedCategories = todoItem->todo()->categories ();
860 855
861 tempMenu->setCheckable (true); 856 tempMenu->setCheckable (true);
862 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); 857 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin ();
863 it != KOPrefs::instance()->mCustomCategories.end (); 858 it != KOPrefs::instance()->mCustomCategories.end ();
864 ++it) { 859 ++it) {
865 int index = tempMenu->insertItem (*it); 860 int index = tempMenu->insertItem (*it);
866 mCategory[index] = *it; 861 mCategory[index] = *it;
867 if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); 862 if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true);
868 } 863 }
869 864
870 connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); 865 connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int)));
871 return tempMenu; 866 return tempMenu;
872 867
873 868
874} 869}
875void KOTodoView::changedCategories(int index) 870void KOTodoView::changedCategories(int index)
876{ 871{
877 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 872 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
878 QStringList categories = mActiveItem->todo()->categories (); 873 QStringList categories = mActiveItem->todo()->categories ();
879 if (categories.find (mCategory[index]) != categories.end ()) 874 if (categories.find (mCategory[index]) != categories.end ())
880 categories.remove (mCategory[index]); 875 categories.remove (mCategory[index]);
881 else 876 else
882 categories.insert (categories.end(), mCategory[index]); 877 categories.insert (categories.end(), mCategory[index]);
883 categories.sort (); 878 categories.sort ();
884 mActiveItem->todo()->setCategories (categories); 879 mActiveItem->todo()->setCategories (categories);
885 mActiveItem->construct(); 880 mActiveItem->construct();
886 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 881 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
887 todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); 882 todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED);
888 } 883 }
889} 884}
890void KOTodoView::itemDoubleClicked(QListViewItem *item) 885void KOTodoView::itemDoubleClicked(QListViewItem *item)
891{ 886{
892 if ( pendingSubtodo != 0 ) { 887 if ( pendingSubtodo != 0 ) {
893 topLevelWidget()->setCaption(i18n("Reparenting aborted!")); 888 topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
894 } 889 }
895 pendingSubtodo = 0; 890 pendingSubtodo = 0;
896 if (!item) { 891 if (!item) {
897 newTodo(); 892 newTodo();
898 return; 893 return;
899 } 894 }
900 if ( KOPrefs::instance()->mEditOnDoubleClick ) 895 if ( KOPrefs::instance()->mEditOnDoubleClick )
901 editItem( item ); 896 editItem( item );
902 else 897 else
903 showItem( item , QPoint(), 0 ); 898 showItem( item , QPoint(), 0 );
904} 899}
905void KOTodoView::itemClicked(QListViewItem *item) 900void KOTodoView::itemClicked(QListViewItem *item)
906{ 901{
907 902
908 if (!item) { 903 if (!item) {
909 if ( pendingSubtodo != 0 ) { 904 if ( pendingSubtodo != 0 ) {
910 topLevelWidget()->setCaption(i18n("Reparenting aborted!")); 905 topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
911 } 906 }
912 pendingSubtodo = 0; 907 pendingSubtodo = 0;
913 return; 908 return;
914 } 909 }
915 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 910 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
916 if ( pendingSubtodo != 0 ) { 911 if ( pendingSubtodo != 0 ) {
917 bool allowReparent = true; 912 bool allowReparent = true;
918 QListViewItem *par = item; 913 QListViewItem *par = item;
919 while ( par ) { 914 while ( par ) {
920 if ( par == pendingSubtodo ) { 915 if ( par == pendingSubtodo ) {
921 allowReparent = false; 916 allowReparent = false;
922 break; 917 break;
923 } 918 }
924 par = par->parent(); 919 par = par->parent();
925 } 920 }
926 if ( !allowReparent ) { 921 if ( !allowReparent ) {
927 topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); 922 topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!"));
928 qDebug("Recursive reparenting not possible "); 923 qDebug("Recursive reparenting not possible ");
929 pendingSubtodo = 0; 924 pendingSubtodo = 0;
930 } else { 925 } else {
931 Todo* newParent = todoItem->todo(); 926 Todo* newParent = todoItem->todo();
932 Todo* newSub = pendingSubtodo->todo(); 927 Todo* newSub = pendingSubtodo->todo();
933 pendingSubtodo = 0; 928 pendingSubtodo = 0;
934 emit reparentTodoSignal( newParent,newSub ); 929 emit reparentTodoSignal( newParent,newSub );
935 return; 930 return;
936 } 931 }
937 } 932 }
938 int completed = todoItem->todo()->isCompleted(); // Completed or not? 933 int completed = todoItem->todo()->isCompleted(); // Completed or not?
939 934
940 if (todoItem->isOn()) { 935 if (todoItem->isOn()) {
941 if (!completed) { 936 if (!completed) {
942 todoItem->todo()->setCompleted(QDateTime::currentDateTime()); 937 todoItem->todo()->setCompleted(QDateTime::currentDateTime());
943 } 938 }
944 } else { 939 } else {
945 if (completed) { 940 if (completed) {
946 todoItem->todo()->setCompleted(false); 941 todoItem->todo()->setCompleted(false);
947 } 942 }
948 } 943 }
949} 944}
950 945
951void KOTodoView::setDocumentId( const QString &id ) 946void KOTodoView::setDocumentId( const QString &id )
952{ 947{
953 kdDebug() << "KOTodoView::setDocumentId()" << endl; 948 kdDebug() << "KOTodoView::setDocumentId()" << endl;
954 949
955 mDocPrefs->setDoc( id ); 950 mDocPrefs->setDoc( id );
956} 951}
957 952
958void KOTodoView::itemStateChanged( QListViewItem *item ) 953void KOTodoView::itemStateChanged( QListViewItem *item )
959{ 954{
960 if (!item) return; 955 if (!item) return;
961 956
962 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 957 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
963 958
964// kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; 959// kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl;
965 960
966 if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); 961 if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() );
967} 962}
968 963
969void KOTodoView::saveLayout(KConfig *config, const QString &group) const 964void KOTodoView::saveLayout(KConfig *config, const QString &group) const
970{ 965{
971 mTodoListView->saveLayout(config,group); 966 mTodoListView->saveLayout(config,group);
972} 967}
973 968
974void KOTodoView::restoreLayout(KConfig *config, const QString &group) 969void KOTodoView::restoreLayout(KConfig *config, const QString &group)
975{ 970{
976 mTodoListView->restoreLayout(config,group); 971 mTodoListView->restoreLayout(config,group);
977} 972}
978 973
979void KOTodoView::processSelectionChange() 974void KOTodoView::processSelectionChange()
980{ 975{
981// kdDebug() << "KOTodoView::processSelectionChange()" << endl; 976// kdDebug() << "KOTodoView::processSelectionChange()" << endl;
982 977
983 KOTodoViewItem *item = 978 KOTodoViewItem *item =
984 static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); 979 static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() );
985 980
986 if ( !item ) { 981 if ( !item ) {
987 emit incidenceSelected( 0 ); 982 emit incidenceSelected( 0 );
988 } else { 983 } else {
989 emit incidenceSelected( item->todo() ); 984 emit incidenceSelected( item->todo() );
990 } 985 }
991} 986}
992 987
993void KOTodoView::modified(bool b) 988void KOTodoView::modified(bool b)
994{ 989{
995 emit isModified(b); 990 emit isModified(b);
996} 991}
997void KOTodoView::setTodoModified( Todo* todo ) 992void KOTodoView::setTodoModified( Todo* todo )
998{ 993{
999 todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); 994 todoModified( todo, KOGlobals::UNKNOWN_MODIFIED );
1000} 995}
1001void KOTodoView::clearSelection() 996void KOTodoView::clearSelection()
1002{ 997{
1003 mTodoListView->selectAll( false ); 998 mTodoListView->selectAll( false );
1004} 999}
1005 1000
1006void KOTodoView::purgeCompleted() 1001void KOTodoView::purgeCompleted()
1007{ 1002{
1008 emit purgeCompletedSignal(); 1003 emit purgeCompletedSignal();
1009} 1004}
1010void KOTodoView::toggleQuickTodo() 1005void KOTodoView::toggleQuickTodo()
1011{ 1006{
1012 if ( mQuickAdd->isVisible() ) { 1007 if ( mQuickAdd->isVisible() ) {
1013 mQuickAdd->hide(); 1008 mQuickAdd->hide();
1014 KOPrefs::instance()->mEnableQuickTodo = false; 1009 KOPrefs::instance()->mEnableQuickTodo = false;
1015 } 1010 }
1016 else { 1011 else {
1017 mQuickAdd->show(); 1012 mQuickAdd->show();
1018 KOPrefs::instance()->mEnableQuickTodo = true; 1013 KOPrefs::instance()->mEnableQuickTodo = true;
1019 } 1014 }
1020 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); 1015 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo);
1021 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); 1016 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo );
1022} 1017}
1023 1018
1024void KOTodoView::toggleRunning() 1019void KOTodoView::toggleRunning()
1025{ 1020{
1026 KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; 1021 KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos;
1027 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); 1022 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos);
1028 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); 1023 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos );
1029 updateView(); 1024 updateView();
1030} 1025}
1031 1026
1032void KOTodoView::toggleCompleted() 1027void KOTodoView::toggleCompleted()
1033{ 1028{
1034 KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; 1029 KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo;
1035 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); 1030 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo );
1036 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); 1031 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo );
1037 updateView(); 1032 updateView();
1038} 1033}
1039 1034
1040void KOTodoView::addQuickTodo() 1035void KOTodoView::addQuickTodo()
1041{ 1036{
1042 Todo *todo = new Todo(); 1037 Todo *todo = new Todo();
1043 todo->setSummary(mQuickAdd->text()); 1038 todo->setSummary(mQuickAdd->text());
1044 todo->setOrganizer(KOPrefs::instance()->email()); 1039 todo->setOrganizer(KOPrefs::instance()->email());
1045 CalFilter * cf = mCalendar->filter(); 1040 CalFilter * cf = mCalendar->filter();
1046 if ( cf ) { 1041 if ( cf ) {
1047 if ( cf->isEnabled()&& cf->showCategories()) { 1042 if ( cf->isEnabled()&& cf->showCategories()) {
1048 todo->setCategories(cf->categoryList()); 1043 todo->setCategories(cf->categoryList());
1049 } 1044 }
1050 if ( cf->isEnabled() ) 1045 if ( cf->isEnabled() )
1051 todo->setSecrecy( cf->getSecrecy()); 1046 todo->setSecrecy( cf->getSecrecy());
1052 } 1047 }
1053 mCalendar->addTodo(todo); 1048 mCalendar->addTodo(todo);
1054 mQuickAdd->setText(""); 1049 mQuickAdd->setText("");
1055 todoModified (todo, KOGlobals::EVENTADDED ); 1050 todoModified (todo, KOGlobals::EVENTADDED );
1056 updateView(); 1051 updateView();
1057} 1052}
1058void KOTodoView::keyPressEvent ( QKeyEvent * e ) 1053void KOTodoView::keyPressEvent ( QKeyEvent * e )
1059{ 1054{
1060 // e->ignore(); 1055 // e->ignore();
1061 //return; 1056 //return;
1062 //qDebug("KOTodoView::keyPressEvent "); 1057 //qDebug("KOTodoView::keyPressEvent ");
1063 switch ( e->key() ) { 1058 switch ( e->key() ) {
1064 case Qt::Key_Down: 1059 case Qt::Key_Down:
1065 case Qt::Key_Up: 1060 case Qt::Key_Up:
1066 QWidget::keyPressEvent ( e ); 1061 QWidget::keyPressEvent ( e );
1067 break; 1062 break;
1068 1063
1069 case Qt::Key_Q: 1064 case Qt::Key_Q:
1070 toggleQuickTodo(); 1065 toggleQuickTodo();
1071 break; 1066 break;
1072 case Qt::Key_U: 1067 case Qt::Key_U:
1073 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { 1068 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) {
1074 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1069 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1075 unparentTodo(); 1070 unparentTodo();
1076 e->accept(); 1071 e->accept();
1077 } else 1072 } else
1078 e->ignore(); 1073 e->ignore();
1079 break; 1074 break;
1080 case Qt::Key_S: 1075 case Qt::Key_S:
1081 if ( e->state() == Qt::ControlButton ) { 1076 if ( e->state() == Qt::ControlButton ) {
1082 e->ignore(); 1077 e->ignore();
1083 break; 1078 break;
1084 } 1079 }
1085 if ( e->state() == Qt::ShiftButton ) { 1080 if ( e->state() == Qt::ShiftButton ) {
1086 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1081 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1087 reparentTodo(); 1082 reparentTodo();
1088 e->accept(); 1083 e->accept();
1089 } else 1084 } else
1090 e->ignore(); 1085 e->ignore();
1091 break; 1086 break;
1092 case Qt::Key_P: 1087 case Qt::Key_P:
1093 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { 1088 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) {
1094 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1089 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1095 if ( pendingSubtodo ) 1090 if ( pendingSubtodo )
1096 itemClicked(mActiveItem); 1091 itemClicked(mActiveItem);
1097 e->accept(); 1092 e->accept();
1098 } else 1093 } else
1099 e->ignore(); 1094 e->ignore();
1100 break; 1095 break;
1101 case Qt::Key_Escape: 1096 case Qt::Key_Escape:
1102 if ( pendingSubtodo ) { 1097 if ( pendingSubtodo ) {
1103 itemClicked(0); 1098 itemClicked(0);
1104 e->accept(); 1099 e->accept();
1105 } else 1100 } else
1106 e->ignore(); 1101 e->ignore();
1107 break; 1102 break;
1108 default: 1103 default:
1109 e->ignore(); 1104 e->ignore();
1110 } 1105 }
1111 1106
1112 if ( true ) { 1107 if ( true ) {
1113 if ( e->key() == Qt::Key_I ) { 1108 if ( e->key() == Qt::Key_I ) {
1114 KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); 1109 KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem();
1115 if ( cn ) { 1110 if ( cn ) {
1116 mActiveItem = cn; 1111 mActiveItem = cn;
1117 KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); 1112 KOTodoViewItem* ci = (KOTodoViewItem*)( cn );
1118 if ( ci ){ 1113 if ( ci ){
1119 showTodo(); 1114 showTodo();
1120 cn = (KOTodoViewItem*)cn->itemBelow(); 1115 cn = (KOTodoViewItem*)cn->itemBelow();
1121 if ( cn ) { 1116 if ( cn ) {
1122 mTodoListView->setCurrentItem ( cn ); 1117 mTodoListView->setCurrentItem ( cn );
1123 mTodoListView->ensureItemVisible ( cn ); 1118 mTodoListView->ensureItemVisible ( cn );
1124 } 1119 }
1125 1120
1126 } 1121 }
1127 } 1122 }
1128 e->accept(); 1123 e->accept();
1129 1124
1130 } 1125 }
1131 1126
1132 } 1127 }
1133 1128
1134} 1129}
1135void KOTodoView::updateTodo( Todo * t, int type ) 1130void KOTodoView::updateTodo( Todo * t, int type )
1136{ 1131{
1137 if ( mBlockUpdate) 1132 if ( mBlockUpdate)
1138 return; 1133 return;
1139 1134
1140 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; 1135 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator;
1141 itemIterator = mTodoMap.find(t); 1136 itemIterator = mTodoMap.find(t);
1142 if (itemIterator != mTodoMap.end()) { 1137 if (itemIterator != mTodoMap.end()) {
1143 (*itemIterator)->construct(); 1138 (*itemIterator)->construct();
1144 } else { 1139 } else {
1145 if ( type == KOGlobals::EVENTADDED ) { 1140 if ( type == KOGlobals::EVENTADDED ) {
1146 insertTodoItem( t ); 1141 insertTodoItem( t );
1147 } 1142 }
1148 } 1143 }
1149 1144
1150} 1145}
1151 1146
1152void KOTodoView::todoModified(Todo * t , int p ) 1147void KOTodoView::todoModified(Todo * t , int p )
1153{ 1148{
1154 mBlockUpdate = true; 1149 mBlockUpdate = true;
1155 emit todoModifiedSignal ( t, p ); 1150 emit todoModifiedSignal ( t, p );
1156 mBlockUpdate = false; 1151 mBlockUpdate = false;
1157} 1152}
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 151b55b..7b07a2e 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1,1902 +1,1911 @@
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#include "koimportoldialog.h" 69#include "koimportoldialog.h"
70#endif 70#endif
71#include "mainwindow.h" 71#include "mainwindow.h"
72 72
73class KOex2phonePrefs : public QDialog 73class KOex2phonePrefs : public QDialog
74{ 74{
75 public: 75 public:
76 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) : 76 KOex2phonePrefs( QWidget *parent=0, const char *name=0 ) :
77 QDialog( parent, name, true ) 77 QDialog( parent, name, true )
78 { 78 {
79 setCaption( i18n("Export to phone options") ); 79 setCaption( i18n("Export to phone options") );
80 QVBoxLayout* lay = new QVBoxLayout( this ); 80 QVBoxLayout* lay = new QVBoxLayout( this );
81 lay->setSpacing( 3 ); 81 lay->setSpacing( 3 );
82 lay->setMargin( 3 ); 82 lay->setMargin( 3 );
83 QLabel *lab; 83 QLabel *lab;
84 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) ); 84 lay->addWidget(lab = new QLabel( i18n("Please read Help-Sync Howto\nto know what settings to use."), this ) );
85 lab->setAlignment (AlignHCenter ); 85 lab->setAlignment (AlignHCenter );
86 QHBox* temphb; 86 QHBox* temphb;
87 temphb = new QHBox( this ); 87 temphb = new QHBox( this );
88 new QLabel( i18n("I/O device: "), temphb ); 88 new QLabel( i18n("I/O device: "), temphb );
89 mPhoneDevice = new QLineEdit( temphb); 89 mPhoneDevice = new QLineEdit( temphb);
90 lay->addWidget( temphb ); 90 lay->addWidget( temphb );
91 temphb = new QHBox( this ); 91 temphb = new QHBox( this );
92 new QLabel( i18n("Connection: "), temphb ); 92 new QLabel( i18n("Connection: "), temphb );
93 mPhoneConnection = new QLineEdit( temphb); 93 mPhoneConnection = new QLineEdit( temphb);
94 lay->addWidget( temphb ); 94 lay->addWidget( temphb );
95 temphb = new QHBox( this ); 95 temphb = new QHBox( this );
96 new QLabel( i18n("Model(opt.): "), temphb ); 96 new QLabel( i18n("Model(opt.): "), temphb );
97 mPhoneModel = new QLineEdit( temphb); 97 mPhoneModel = new QLineEdit( temphb);
98 lay->addWidget( temphb ); 98 lay->addWidget( temphb );
99 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this ); 99 mWriteBackFuture= new QCheckBox( i18n("Write back events in future only"), this );
100 mWriteBackFuture->setChecked( true ); 100 mWriteBackFuture->setChecked( true );
101 lay->addWidget( mWriteBackFuture ); 101 lay->addWidget( mWriteBackFuture );
102 temphb = new QHBox( this ); 102 temphb = new QHBox( this );
103 new QLabel( i18n("Max. weeks in future: ") , temphb ); 103 new QLabel( i18n("Max. weeks in future: ") , temphb );
104 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb); 104 mWriteBackFutureWeeks= new QSpinBox(1,104, 1, temphb);
105 mWriteBackFutureWeeks->setValue( 8 ); 105 mWriteBackFutureWeeks->setValue( 8 );
106 lay->addWidget( temphb ); 106 lay->addWidget( temphb );
107 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) ); 107 lay->addWidget(lab = new QLabel( i18n("NOTE: This will remove all old\ntodo/calendar data on phone!"), this ) );
108 lab->setAlignment (AlignHCenter ); 108 lab->setAlignment (AlignHCenter );
109 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this ); 109 QPushButton * ok = new QPushButton( i18n("Export to mobile phone!"), this );
110 lay->addWidget( ok ); 110 lay->addWidget( ok );
111 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 111 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
112 lay->addWidget( cancel ); 112 lay->addWidget( cancel );
113 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 113 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
114 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 114 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
115 resize( 220, 240 ); 115 resize( 220, 240 );
116 qApp->processEvents(); 116 qApp->processEvents();
117 int dw = QApplication::desktop()->width(); 117 int dw = QApplication::desktop()->width();
118 int dh = QApplication::desktop()->height(); 118 int dh = QApplication::desktop()->height();
119 move( (dw-width())/2, (dh - height() )/2 ); 119 move( (dw-width())/2, (dh - height() )/2 );
120 } 120 }
121 121
122public: 122public:
123 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel; 123 QLineEdit* mPhoneConnection, *mPhoneDevice, *mPhoneModel;
124 QCheckBox* mWriteBackFuture; 124 QCheckBox* mWriteBackFuture;
125 QSpinBox* mWriteBackFutureWeeks; 125 QSpinBox* mWriteBackFutureWeeks;
126}; 126};
127 127
128int globalFlagBlockStartup; 128int globalFlagBlockStartup;
129MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : 129MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
130 QMainWindow( parent, name ) 130 QMainWindow( parent, name )
131{ 131{
132 132
133#ifdef DESKTOP_VERSION 133#ifdef DESKTOP_VERSION
134 setFont( QFont("Arial"), 14 ); 134 setFont( QFont("Arial"), 14 );
135#endif 135#endif
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 > 18 ) 147 if ( p->mHourSize > 18 )
148 p->mHourSize = 18; 148 p->mHourSize = 18;
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 168
169 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this ); 169 QLabel* splash = new QLabel(i18n("KO/Pi is starting ... "), this );
170 splash->setAlignment ( AlignCenter ); 170 splash->setAlignment ( AlignCenter );
171 setCentralWidget( splash ); 171 setCentralWidget( splash );
172#ifndef DESKTOP_VERSION 172#ifndef DESKTOP_VERSION
173 showMaximized(); 173 showMaximized();
174#endif 174#endif
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()->setCategoryDefaults(); 232 KOPrefs::instance()->setCategoryDefaults();
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(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); 260 connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) );
261 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); 261 connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) );
262 mSyncManager->setDefaultFileName( defaultFileName()); 262 mSyncManager->setDefaultFileName( defaultFileName());
263 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); 263 connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) );
264 mSyncManager->fillSyncMenu(); 264 mSyncManager->fillSyncMenu();
265 265
266 266
267 267
268 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins ); 268 mView->viewManager()->agendaView()->setStartHour( KOPrefs::instance()->mDayBegins );
269 if ( showWarning ) { 269 if ( showWarning ) {
270 KMessageBox::information( this, 270 KMessageBox::information( this,
271 "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"); 271 "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");
272 qApp->processEvents(); 272 qApp->processEvents();
273 mView->dialogManager()->showSyncOptions(); 273 mView->dialogManager()->showSyncOptions();
274 } 274 }
275 275
276 //US listen for result adressed from Ka/Pi 276 //US listen for result adressed from Ka/Pi
277#ifndef DESKTOP_VERSION 277#ifndef DESKTOP_VERSION
278 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & ))); 278 connect(qApp, SIGNAL (appMessage ( const QCString &, const QByteArray & )), ExternalAppHandler::instance(), SLOT (appMessage ( const QCString &, const QByteArray & )));
279#endif 279#endif
280#ifndef DESKTOP_VERSION 280#ifndef DESKTOP_VERSION
281 infrared = 0; 281 infrared = 0;
282#endif 282#endif
283 283
284 mBRdisabled = false; 284 mBRdisabled = false;
285 //toggleBeamReceive(); 285 //toggleBeamReceive();
286} 286}
287MainWindow::~MainWindow() 287MainWindow::~MainWindow()
288{ 288{
289 //qDebug("MainWindow::~MainWindow() "); 289 //qDebug("MainWindow::~MainWindow() ");
290 //save toolbar location 290 //save toolbar location
291 delete mCalendar; 291 delete mCalendar;
292 delete mSyncManager; 292 delete mSyncManager;
293#ifndef DESKTOP_VERSION 293#ifndef DESKTOP_VERSION
294 if ( infrared ) 294 if ( infrared )
295 delete infrared; 295 delete infrared;
296#endif 296#endif
297 297
298 298
299} 299}
300 300
301void MainWindow::disableBR(bool b) 301void MainWindow::disableBR(bool b)
302{ 302{
303#ifndef DESKTOP_VERSION 303#ifndef DESKTOP_VERSION
304 if ( b ) { 304 if ( b ) {
305 if ( infrared ) { 305 if ( infrared ) {
306 toggleBeamReceive(); 306 toggleBeamReceive();
307 mBRdisabled = true; 307 mBRdisabled = true;
308 } 308 }
309 mBRdisabled = true; 309 mBRdisabled = true;
310 } else { 310 } else {
311 if ( mBRdisabled ) { 311 if ( mBRdisabled ) {
312 mBRdisabled = false; 312 mBRdisabled = false;
313 //makes no sense,because other cal ap is probably running 313 //makes no sense,because other cal ap is probably running
314 // toggleBeamReceive(); 314 // toggleBeamReceive();
315 } 315 }
316 } 316 }
317#endif 317#endif
318 318
319} 319}
320bool MainWindow::beamReceiveEnabled() 320bool MainWindow::beamReceiveEnabled()
321{ 321{
322#ifndef DESKTOP_VERSION 322#ifndef DESKTOP_VERSION
323 return ( infrared != 0 ); 323 return ( infrared != 0 );
324#endif 324#endif
325 return false; 325 return false;
326} 326}
327 327
328void MainWindow::toggleBeamReceive() 328void MainWindow::toggleBeamReceive()
329{ 329{
330 if ( mBRdisabled ) 330 if ( mBRdisabled )
331 return; 331 return;
332#ifndef DESKTOP_VERSION 332#ifndef DESKTOP_VERSION
333 if ( infrared ) { 333 if ( infrared ) {
334 qDebug("disable BeamReceive "); 334 qDebug("disable BeamReceive ");
335 delete infrared; 335 delete infrared;
336 infrared = 0; 336 infrared = 0;
337 brAction->setOn(false); 337 brAction->setOn(false);
338 return; 338 return;
339 } 339 }
340 qDebug("enable BeamReceive "); 340 qDebug("enable BeamReceive ");
341 brAction->setOn(true); 341 brAction->setOn(true);
342 infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ; 342 infrared = new QCopChannel("QPE/Application/datebook",this, "channel" ) ;
343 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& ))); 343 QObject::connect( infrared, SIGNAL (received ( const QCString &, const QByteArray & )),this, SLOT(recieve( const QCString&, const QByteArray& )));
344#endif 344#endif
345} 345}
346void MainWindow::showMaximized () 346void MainWindow::showMaximized ()
347{ 347{
348#ifndef DESKTOP_VERSION 348#ifndef DESKTOP_VERSION
349 if ( ! globalFlagBlockStartup ) 349 if ( ! globalFlagBlockStartup )
350 if ( mClosed ) 350 if ( mClosed )
351 mView->goToday(); 351 mView->goToday();
352#endif 352#endif
353 QWidget::showMaximized () ; 353 QWidget::showMaximized () ;
354 mClosed = false; 354 mClosed = false;
355} 355}
356void MainWindow::closeEvent( QCloseEvent* ce ) 356void MainWindow::closeEvent( QCloseEvent* ce )
357{ 357{
358 358
359 359
360 360
361 if ( ! KOPrefs::instance()->mAskForQuit ) { 361 if ( ! KOPrefs::instance()->mAskForQuit ) {
362 saveOnClose(); 362 saveOnClose();
363 mClosed = true; 363 mClosed = true;
364 ce->accept(); 364 ce->accept();
365 return; 365 return;
366 366
367 } 367 }
368 368
369 switch( QMessageBox::information( this, "KO/Pi", 369 switch( QMessageBox::information( this, "KO/Pi",
370 i18n("Do you really want\nto close KO/Pi?"), 370 i18n("Do you really want\nto close KO/Pi?"),
371 i18n("Close"), i18n("No"), 371 i18n("Close"), i18n("No"),
372 0, 0 ) ) { 372 0, 0 ) ) {
373 case 0: 373 case 0:
374 saveOnClose(); 374 saveOnClose();
375 mClosed = true; 375 mClosed = true;
376 ce->accept(); 376 ce->accept();
377 break; 377 break;
378 case 1: 378 case 1:
379 ce->ignore(); 379 ce->ignore();
380 break; 380 break;
381 case 2: 381 case 2:
382 382
383 default: 383 default:
384 break; 384 break;
385 } 385 }
386 386
387 387
388} 388}
389 389
390void MainWindow::recieve( const QCString& cmsg, const QByteArray& data ) 390void MainWindow::recieve( const QCString& cmsg, const QByteArray& data )
391{ 391{
392 QDataStream stream( data, IO_ReadOnly ); 392 QDataStream stream( data, IO_ReadOnly );
393 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" ); 393 // QMessageBox::about( this, "About KOrganizer/Pi", "*" +msg +"*" );
394 //QString datamess; 394 //QString datamess;
395 //qDebug("message "); 395 //qDebug("message ");
396 qDebug("KO: QCOP message received: %s ", cmsg.data() ); 396 qDebug("KO: QCOP message received: %s ", cmsg.data() );
397 397
398 if ( cmsg == "setDocument(QString)" ) { 398 if ( cmsg == "setDocument(QString)" ) {
399 QDataStream stream( data, IO_ReadOnly ); 399 QDataStream stream( data, IO_ReadOnly );
400 QString fileName; 400 QString fileName;
401 stream >> fileName; 401 stream >> fileName;
402 //qDebug("filename %s ", fileName.latin1()); 402 //qDebug("filename %s ", fileName.latin1());
403 showMaximized(); 403 showMaximized();
404 raise(); 404 raise();
405 KOPrefs::instance()->mLastSyncedLocalFile = fileName ; 405 KOPrefs::instance()->mLastSyncedLocalFile = fileName ;
406 mSyncManager->slotSyncMenu( 1002 ); 406 mSyncManager->slotSyncMenu( 1002 );
407 return; 407 return;
408 } 408 }
409 409
410 if ( cmsg == "-writeFile" ) { 410 if ( cmsg == "-writeFile" ) {
411 // I made from the "-writeFile" an "-writeAlarm" 411 // I made from the "-writeFile" an "-writeAlarm"
412 mView->viewManager()->showWhatsNextView(); 412 mView->viewManager()->showWhatsNextView();
413 mCalendar->checkAlarmForIncidence( 0, true); 413 mCalendar->checkAlarmForIncidence( 0, true);
414 showMaximized(); 414 showMaximized();
415 raise(); 415 raise();
416 return; 416 return;
417 417
418 } 418 }
419 if ( cmsg == "-writeFileSilent" ) { 419 if ( cmsg == "-writeFileSilent" ) {
420 // I made from the "-writeFile" an "-writeAlarm" 420 // I made from the "-writeFile" an "-writeAlarm"
421 // mView->viewManager()->showWhatsNextView(); 421 // mView->viewManager()->showWhatsNextView();
422 mCalendar->checkAlarmForIncidence( 0, true); 422 mCalendar->checkAlarmForIncidence( 0, true);
423 //showMaximized(); 423 //showMaximized();
424 //raise(); 424 //raise();
425 hide(); 425 hide();
426 return; 426 return;
427 } 427 }
428 if ( cmsg == "-newCountdown" ) { 428 if ( cmsg == "-newCountdown" ) {
429 qDebug("newCountdown "); 429 qDebug("newCountdown ");
430 430
431 } 431 }
432 QString msg ; 432 QString msg ;
433 QString allmsg = cmsg; 433 QString allmsg = cmsg;
434 while ( allmsg.length() > 0 ) { 434 while ( allmsg.length() > 0 ) {
435 int nextC = allmsg.find( "-", 1 ); 435 int nextC = allmsg.find( "-", 1 );
436 if ( nextC == -1 ) { 436 if ( nextC == -1 ) {
437 msg = allmsg; 437 msg = allmsg;
438 allmsg = ""; 438 allmsg = "";
439 } else{ 439 } else{
440 msg = allmsg.left( nextC ); 440 msg = allmsg.left( nextC );
441 allmsg = allmsg.mid( nextC, allmsg.length()-nextC ); 441 allmsg = allmsg.mid( nextC, allmsg.length()-nextC );
442 } 442 }
443 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() ); 443 //qDebug("msg: %s all: %s ", msg.latin1(), allmsg.latin1() );
444 if ( msg == "-newEvent" ) { 444 if ( msg == "-newEvent" ) {
445 mView->newEvent(); 445 mView->newEvent();
446 } 446 }
447 if ( msg == "-newTodo" ) { 447 if ( msg == "-newTodo" ) {
448 mView->newTodo(); 448 mView->newTodo();
449 449
450 } 450 }
451 if ( msg == "-showWN" ) { 451 if ( msg == "-showWN" ) {
452 mView->viewManager()->showWhatsNextView(); 452 mView->viewManager()->showWhatsNextView();
453 } 453 }
454 if ( msg == "-showTodo" ) { 454 if ( msg == "-showTodo" ) {
455 mView->viewManager()->showTodoView(); 455 mView->viewManager()->showTodoView();
456 } 456 }
457 if ( msg == "-showList" ) { 457 if ( msg == "-showList" ) {
458 mView->viewManager()->showListView(); 458 mView->viewManager()->showListView();
459 } 459 }
460 else if ( msg == "-showDay" ) { 460 else if ( msg == "-showDay" ) {
461 mView->viewManager()->showDayView(); 461 mView->viewManager()->showDayView();
462 } 462 }
463 else if ( msg == "-showWWeek" ) { 463 else if ( msg == "-showWWeek" ) {
464 mView->viewManager()->showWorkWeekView(); 464 mView->viewManager()->showWorkWeekView();
465 } 465 }
466 else if ( msg == "-ringSync" ) { 466 else if ( msg == "-ringSync" ) {
467 mSyncManager->multiSync( false ); 467 mSyncManager->multiSync( false );
468 } 468 }
469 else if ( msg == "-showWeek" ) { 469 else if ( msg == "-showWeek" ) {
470 mView->viewManager()->showWeekView(); 470 mView->viewManager()->showWeekView();
471 } 471 }
472 else if ( msg == "-showTodo" ) { 472 else if ( msg == "-showTodo" ) {
473 mView->viewManager()->showTodoView(); 473 mView->viewManager()->showTodoView();
474 } 474 }
475 else if ( msg == "-showJournal" ) { 475 else if ( msg == "-showJournal" ) {
476 mView->dateNavigator()->selectDates( 1 ); 476 mView->dateNavigator()->selectDates( 1 );
477 mView->dateNavigator()->selectToday(); 477 mView->dateNavigator()->selectToday();
478 mView->viewManager()->showJournalView(); 478 mView->viewManager()->showJournalView();
479 } 479 }
480 else if ( msg == "-showKO" ) { 480 else if ( msg == "-showKO" ) {
481 mView->viewManager()->showNextXView(); 481 mView->viewManager()->showNextXView();
482 } 482 }
483 else if ( msg == "-showWNext" || msg == "nextView()" ) { 483 else if ( msg == "-showWNext" || msg == "nextView()" ) {
484 mView->viewManager()->showWhatsNextView(); 484 mView->viewManager()->showWhatsNextView();
485 } 485 }
486 else if ( msg == "-showNextXView" ) { 486 else if ( msg == "-showNextXView" ) {
487 mView->viewManager()->showNextXView(); 487 mView->viewManager()->showNextXView();
488 } 488 }
489 489
490 490
491 } 491 }
492 492
493 showMaximized(); 493 showMaximized();
494 raise(); 494 raise();
495} 495}
496 496
497QPixmap MainWindow::loadPixmap( QString name ) 497QPixmap MainWindow::loadPixmap( QString name )
498{ 498{
499 return SmallIcon( name ); 499 return SmallIcon( name );
500 500
501} 501}
502void MainWindow::initActions() 502void MainWindow::initActions()
503{ 503{
504 //KOPrefs::instance()->mShowFullMenu 504 //KOPrefs::instance()->mShowFullMenu
505 iconToolBar->clear(); 505 iconToolBar->clear();
506 KOPrefs *p = KOPrefs::instance(); 506 KOPrefs *p = KOPrefs::instance();
507 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar ); 507 //QPEMenuBar *menuBar1;// = new QPEMenuBar( iconToolBar );
508 508
509 QPopupMenu *viewMenu = new QPopupMenu( this ); 509 QPopupMenu *viewMenu = new QPopupMenu( this );
510 QPopupMenu *actionMenu = new QPopupMenu( this ); 510 QPopupMenu *actionMenu = new QPopupMenu( this );
511 QPopupMenu *importMenu = new QPopupMenu( this ); 511 QPopupMenu *importMenu = new QPopupMenu( this );
512 selectFilterMenu = new QPopupMenu( this ); 512 selectFilterMenu = new QPopupMenu( this );
513 selectFilterMenu->setCheckable( true ); 513 selectFilterMenu->setCheckable( true );
514 syncMenu = new QPopupMenu( this ); 514 syncMenu = new QPopupMenu( this );
515 configureAgendaMenu = new QPopupMenu( this ); 515 configureAgendaMenu = new QPopupMenu( this );
516 configureToolBarMenu = new QPopupMenu( this ); 516 configureToolBarMenu = new QPopupMenu( this );
517 QPopupMenu *helpMenu = new QPopupMenu( this ); 517 QPopupMenu *helpMenu = new QPopupMenu( this );
518 if ( KOPrefs::instance()->mShowFullMenu ) { 518 if ( KOPrefs::instance()->mShowFullMenu ) {
519 QMenuBar *menuBar1; 519 QMenuBar *menuBar1;
520 menuBar1 = menuBar(); 520 menuBar1 = menuBar();
521 menuBar1->insertItem( i18n("File"), importMenu ); 521 menuBar1->insertItem( i18n("File"), importMenu );
522 menuBar1->insertItem( i18n("View"), viewMenu ); 522 menuBar1->insertItem( i18n("View"), viewMenu );
523 menuBar1->insertItem( i18n("Actions"), actionMenu ); 523 menuBar1->insertItem( i18n("Actions"), actionMenu );
524 menuBar1->insertItem( i18n("Synchronize"), syncMenu ); 524 menuBar1->insertItem( i18n("Synchronize"), syncMenu );
525 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 525 menuBar1->insertItem( i18n("AgendaSize"),configureAgendaMenu );
526 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu ); 526 //menuBar1->insertItem( i18n("Toolbar"),configureToolBarMenu );
527 menuBar1->insertItem( i18n("Filter"),selectFilterMenu ); 527 menuBar1->insertItem( i18n("Filter"),selectFilterMenu );
528 menuBar1->insertItem( i18n("Help"), helpMenu ); 528 menuBar1->insertItem( i18n("Help"), helpMenu );
529 } else { 529 } else {
530 QPEMenuBar *menuBar1; 530 QPEMenuBar *menuBar1;
531 menuBar1 = new QPEMenuBar( iconToolBar ); 531 menuBar1 = new QPEMenuBar( iconToolBar );
532 QPopupMenu *menuBar = new QPopupMenu( this ); 532 QPopupMenu *menuBar = new QPopupMenu( this );
533 menuBar1->insertItem( i18n("ME"), menuBar); 533 menuBar1->insertItem( i18n("ME"), menuBar);
534 menuBar->insertItem( i18n("File"), importMenu ); 534 menuBar->insertItem( i18n("File"), importMenu );
535 menuBar->insertItem( i18n("View"), viewMenu ); 535 menuBar->insertItem( i18n("View"), viewMenu );
536 menuBar->insertItem( i18n("Actions"), actionMenu ); 536 menuBar->insertItem( i18n("Actions"), actionMenu );
537 menuBar->insertItem( i18n("Synchronize"), syncMenu ); 537 menuBar->insertItem( i18n("Synchronize"), syncMenu );
538 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu ); 538 menuBar->insertItem( i18n("AgendaSize"),configureAgendaMenu );
539 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu ); 539 menuBar->insertItem( i18n("Toolbar"),configureToolBarMenu );
540 menuBar->insertItem( i18n("Filter"),selectFilterMenu ); 540 menuBar->insertItem( i18n("Filter"),selectFilterMenu );
541 menuBar->insertItem( i18n("Help"), helpMenu ); 541 menuBar->insertItem( i18n("Help"), helpMenu );
542 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() ); 542 //menuBar1->setMaximumWidth( menuBar1->sizeHint().width() );
543 menuBar1->setMaximumSize( menuBar1->sizeHint( )); 543 menuBar1->setMaximumSize( menuBar1->sizeHint( ));
544 } 544 }
545 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) ); 545 connect ( selectFilterMenu, SIGNAL( activated ( int ) ), this, SLOT (selectFilter( int ) ) );
546 connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) ); 546 connect ( selectFilterMenu, SIGNAL( aboutToShow () ), this, SLOT (fillFilterMenu() ) );
547 547
548 // ****************** 548 // ******************
549 QAction *action; 549 QAction *action;
550 QIconSet icon; 550 QIconSet icon;
551 // QPopupMenu *configureMenu= new QPopupMenu( menuBar ); 551 // QPopupMenu *configureMenu= new QPopupMenu( menuBar );
552 configureToolBarMenu->setCheckable( true ); 552 configureToolBarMenu->setCheckable( true );
553 553
554 QString pathString = ""; 554 QString pathString = "";
555 if ( !p->mToolBarMiniIcons ) { 555 if ( !p->mToolBarMiniIcons ) {
556 if ( QApplication::desktop()->width() < 480 ) 556 if ( QApplication::desktop()->width() < 480 )
557 pathString += "icons16/"; 557 pathString += "icons16/";
558 } else 558 } else
559 pathString += "iconsmini/"; 559 pathString += "iconsmini/";
560 configureAgendaMenu->setCheckable( true ); 560 configureAgendaMenu->setCheckable( true );
561 configureAgendaMenu->insertItem(i18n("Tiny"), 4 ); 561 configureAgendaMenu->insertItem(i18n("Tiny"), 4 );
562 configureAgendaMenu->insertItem(i18n("Small"), 6 ); 562 configureAgendaMenu->insertItem(i18n("Small"), 6 );
563 configureAgendaMenu->insertItem(i18n("Medium"), 8 ); 563 configureAgendaMenu->insertItem(i18n("Medium"), 8 );
564 configureAgendaMenu->insertItem(i18n("Normal"), 10 ); 564 configureAgendaMenu->insertItem(i18n("Normal"), 10 );
565 configureAgendaMenu->insertItem(i18n("Large"), 12 ); 565 configureAgendaMenu->insertItem(i18n("Large"), 12 );
566 configureAgendaMenu->insertItem(i18n("Big"), 14 ); 566 configureAgendaMenu->insertItem(i18n("Big"), 14 );
567 configureAgendaMenu->insertItem(i18n("Bigger"), 16 ); 567 configureAgendaMenu->insertItem(i18n("Bigger"), 16 );
568 configureAgendaMenu->insertItem(i18n("Biggest"), 18 ); 568 configureAgendaMenu->insertItem(i18n("Biggest"), 18 );
569 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu ); 569 //configureMenu->insertItem( "AgendaSize",configureAgendaMenu );
570 570
571 icon = loadPixmap( pathString + "configure" ); 571 icon = loadPixmap( pathString + "configure" );
572 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this ); 572 action = new QAction( i18n("Configure"),icon, i18n("Configure..."), 0, this );
573 action->addTo( actionMenu ); 573 action->addTo( actionMenu );
574 connect( action, SIGNAL( activated() ), 574 connect( action, SIGNAL( activated() ),
575 mView, SLOT( edit_options() ) ); 575 mView, SLOT( edit_options() ) );
576 actionMenu->insertSeparator(); 576 actionMenu->insertSeparator();
577 577
578 action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this ); 578 action = new QAction( i18n("Undo Delete"), i18n("Undo Delete..."), 0, this );
579 action->addTo( actionMenu ); 579 action->addTo( actionMenu );
580 connect( action, SIGNAL( activated() ), 580 connect( action, SIGNAL( activated() ),
581 mView, SLOT( undo_delete() ) ); 581 mView, SLOT( undo_delete() ) );
582 actionMenu->insertSeparator(); 582 actionMenu->insertSeparator();
583 583
584 icon = loadPixmap( pathString + "newevent" ); 584 icon = loadPixmap( pathString + "newevent" );
585 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 ); 585 configureToolBarMenu->insertItem(i18n("Stretched TB"), 5 );
586 configureToolBarMenu->insertSeparator(); 586 configureToolBarMenu->insertSeparator();
587 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 ); 587 configureToolBarMenu->insertItem(icon, i18n("New Event..."), 10 );
588 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this ); 588 QAction* ne_action = new QAction( i18n("New Event..."), icon, i18n("New Event..."), 0, this );
589 ne_action->addTo( actionMenu ); 589 ne_action->addTo( actionMenu );
590 connect( ne_action, SIGNAL( activated() ), 590 connect( ne_action, SIGNAL( activated() ),
591 mView, SLOT( newEvent() ) ); 591 mView, SLOT( newEvent() ) );
592 icon = loadPixmap( pathString + "newtodo" ); 592 icon = loadPixmap( pathString + "newtodo" );
593 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 ); 593 configureToolBarMenu->insertItem(icon, i18n("New Todo..."), 20 );
594 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this ); 594 QAction* nt_action = new QAction( i18n("New Todo..."), icon, i18n("New Todo..."), 0, this );
595 nt_action->addTo( actionMenu ); 595 nt_action->addTo( actionMenu );
596 connect( nt_action, SIGNAL( activated() ), 596 connect( nt_action, SIGNAL( activated() ),
597 mView, SLOT( newTodo() ) ); 597 mView, SLOT( newTodo() ) );
598 icon = loadPixmap( pathString + "navi" ); 598 icon = loadPixmap( pathString + "navi" );
599 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this ); 599 action = new QAction( i18n("Toggle DateNavigator"), icon, i18n("Toggle DateNavigator"), 0, this );
600 action->addTo( viewMenu ); 600 action->addTo( viewMenu );
601 connect( action, SIGNAL( activated() ), 601 connect( action, SIGNAL( activated() ),
602 mView, SLOT( toggleDateNavigatorWidget() ) ); 602 mView, SLOT( toggleDateNavigatorWidget() ) );
603 icon = loadPixmap( pathString + "filter" ); 603 icon = loadPixmap( pathString + "filter" );
604 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this ); 604 action = new QAction( i18n("Toggle FilterView"), icon, i18n("Toggle FilterView"), 0, this );
605 action->addTo( viewMenu ); 605 action->addTo( viewMenu );
606 connect( action, SIGNAL( activated() ), 606 connect( action, SIGNAL( activated() ),
607 mView, SLOT( toggleFilter() ) ); 607 mView, SLOT( toggleFilter() ) );
608 action = new QAction( i18n("Toggle Allday"), i18n("Toggle Allday"), 0, this ); 608 action = new QAction( i18n("Toggle Allday"), i18n("Toggle Allday"), 0, this );
609 action->addTo( viewMenu ); 609 action->addTo( viewMenu );
610 connect( action, SIGNAL( activated() ), 610 connect( action, SIGNAL( activated() ),
611 mView, SLOT( toggleAllDaySize() ) ); 611 mView, SLOT( toggleAllDaySize() ) );
612 612
613 viewMenu->insertSeparator(); 613 viewMenu->insertSeparator();
614 icon = loadPixmap( pathString + "picker" ); 614 icon = loadPixmap( pathString + "picker" );
615 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this ); 615 action = new QAction( i18n("Date Picker"), icon, i18n("Date Picker"), 0, this );
616 action->addTo( viewMenu ); 616 action->addTo( viewMenu );
617 connect( action, SIGNAL( activated() ), 617 connect( action, SIGNAL( activated() ),
618 mView, SLOT( showDatePicker() ) ); 618 mView, SLOT( showDatePicker() ) );
619 action->addTo( iconToolBar ); 619 action->addTo( iconToolBar );
620 viewMenu->insertSeparator(); 620 viewMenu->insertSeparator();
621 icon = loadPixmap( pathString + "list" ); 621 icon = loadPixmap( pathString + "list" );
622 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 ); 622 configureToolBarMenu->insertItem(icon, i18n("List View"), 30 );
623 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this ); 623 QAction* showlist_action = new QAction( i18n("List View"), icon, i18n("List View"), 0, this );
624 showlist_action->addTo( viewMenu ); 624 showlist_action->addTo( viewMenu );
625 connect( showlist_action, SIGNAL( activated() ), 625 connect( showlist_action, SIGNAL( activated() ),
626 mView->viewManager(), SLOT( showListView() ) ); 626 mView->viewManager(), SLOT( showListView() ) );
627 627
628 628
629 icon = loadPixmap( pathString + "day" ); 629 icon = loadPixmap( pathString + "day" );
630 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 ); 630 configureToolBarMenu->insertItem(icon, i18n("Day View"), 40 );
631 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this ); 631 QAction* day1_action = new QAction( i18n("Day View"), icon, i18n("Day View"), 0, this );
632 day1_action->addTo( viewMenu ); 632 day1_action->addTo( viewMenu );
633 // action->addTo( toolBar ); 633 // action->addTo( toolBar );
634 connect( day1_action, SIGNAL( activated() ), 634 connect( day1_action, SIGNAL( activated() ),
635 mView->viewManager(), SLOT( showDayView() ) ); 635 mView->viewManager(), SLOT( showDayView() ) );
636 636
637 icon = loadPixmap( pathString + "workweek" ); 637 icon = loadPixmap( pathString + "workweek" );
638 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 ); 638 configureToolBarMenu->insertItem(icon, i18n("Work Week"), 50 );
639 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this ); 639 QAction* day5_action = new QAction( i18n("Work Week"), icon, i18n("Work Week"), 0, this );
640 day5_action->addTo( viewMenu ); 640 day5_action->addTo( viewMenu );
641 connect( day5_action, SIGNAL( activated() ), 641 connect( day5_action, SIGNAL( activated() ),
642 mView->viewManager(), SLOT( showWorkWeekView() ) ); 642 mView->viewManager(), SLOT( showWorkWeekView() ) );
643 643
644 icon = loadPixmap( pathString + "week" ); 644 icon = loadPixmap( pathString + "week" );
645 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 ); 645 configureToolBarMenu->insertItem(icon, i18n("Week"), 60 );
646 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this ); 646 QAction* day7_action = new QAction( i18n("Week"), icon, i18n("Week"), 0, this );
647 day7_action->addTo( viewMenu ); 647 day7_action->addTo( viewMenu );
648 connect( day7_action, SIGNAL( activated() ), 648 connect( day7_action, SIGNAL( activated() ),
649 mView->viewManager(), SLOT( showWeekView() ) ); 649 mView->viewManager(), SLOT( showWeekView() ) );
650 650
651 icon = loadPixmap( pathString + "month" ); 651 icon = loadPixmap( pathString + "month" );
652 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 ); 652 configureToolBarMenu->insertItem(icon, i18n("Month"), 70 );
653 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this ); 653 QAction* month_action = new QAction( i18n("Month"), icon, i18n("Month"), 0, this );
654 month_action->addTo( viewMenu ); 654 month_action->addTo( viewMenu );
655 connect( month_action, SIGNAL( activated() ), 655 connect( month_action, SIGNAL( activated() ),
656 mView->viewManager(), SLOT( showMonthView() ) ); 656 mView->viewManager(), SLOT( showMonthView() ) );
657 657
658 icon = loadPixmap( pathString + "todo" ); 658 icon = loadPixmap( pathString + "todo" );
659 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 ); 659 configureToolBarMenu->insertItem(icon, i18n("Todo View"), 80 );
660 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this ); 660 QAction* todoview_action = new QAction( i18n("Todo View"), icon, i18n("Todo View"), 0, this );
661 todoview_action->addTo( viewMenu ); 661 todoview_action->addTo( viewMenu );
662 connect( todoview_action, SIGNAL( activated() ), 662 connect( todoview_action, SIGNAL( activated() ),
663 mView->viewManager(), SLOT( showTodoView() ) ); 663 mView->viewManager(), SLOT( showTodoView() ) );
664 664
665 icon = loadPixmap( pathString + "journal" ); 665 icon = loadPixmap( pathString + "journal" );
666 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 ); 666 configureToolBarMenu->insertItem(icon, i18n("Journal"), 90 );
667 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this ); 667 QAction* viewjournal_action = new QAction( i18n("Journal"), icon, i18n("Journal"), 0, this );
668 viewjournal_action->addTo( viewMenu ); 668 viewjournal_action->addTo( viewMenu );
669 connect( viewjournal_action, SIGNAL( activated() ), 669 connect( viewjournal_action, SIGNAL( activated() ),
670 mView->viewManager(), SLOT( showJournalView() ) ); 670 mView->viewManager(), SLOT( showJournalView() ) );
671 671
672 icon = loadPixmap( pathString + "xdays" ); 672 icon = loadPixmap( pathString + "xdays" );
673 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 ); 673 configureToolBarMenu->insertItem(icon, i18n("Next days"), 100,4 );
674 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this ); 674 QAction* xdays_action = new QAction( i18n("Next days"), icon, i18n("Next days"), 0, this );
675 xdays_action->addTo( viewMenu ); 675 xdays_action->addTo( viewMenu );
676 connect( xdays_action, SIGNAL( activated() ), 676 connect( xdays_action, SIGNAL( activated() ),
677 mView->viewManager(), SLOT( showNextXView() ) ); 677 mView->viewManager(), SLOT( showNextXView() ) );
678 678
679 icon = loadPixmap( pathString + "whatsnext" ); 679 icon = loadPixmap( pathString + "whatsnext" );
680 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 ); 680 configureToolBarMenu->insertItem(icon, i18n("What's Next"), 110, 4 );
681 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this ); 681 QAction* whatsnext_action = new QAction( i18n("What's Next"), icon, i18n("What's Next"), 0, this );
682 whatsnext_action->addTo( viewMenu ); 682 whatsnext_action->addTo( viewMenu );
683 connect( whatsnext_action, SIGNAL( activated() ), 683 connect( whatsnext_action, SIGNAL( activated() ),
684 mView->viewManager(), SLOT( showWhatsNextView() ) ); 684 mView->viewManager(), SLOT( showWhatsNextView() ) );
685 685
686#if 0 686#if 0
687 action = new QAction( "view_timespan", "Time Span", 0, this ); 687 action = new QAction( "view_timespan", "Time Span", 0, this );
688 action->addTo( viewMenu ); 688 action->addTo( viewMenu );
689 connect( action, SIGNAL( activated() ), 689 connect( action, SIGNAL( activated() ),
690 mView->viewManager(), SLOT( showTimeSpanView() ) ); 690 mView->viewManager(), SLOT( showTimeSpanView() ) );
691#endif 691#endif
692 692
693 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0, 693 mNewSubTodoAction = new QAction( "new_subtodo", i18n("New Sub-Todo..."), 0,
694 this ); 694 this );
695 mNewSubTodoAction->addTo( actionMenu ); 695 mNewSubTodoAction->addTo( actionMenu );
696 connect( mNewSubTodoAction, SIGNAL( activated() ), 696 connect( mNewSubTodoAction, SIGNAL( activated() ),
697 mView, SLOT( newSubTodo() ) ); 697 mView, SLOT( newSubTodo() ) );
698 698
699 actionMenu->insertSeparator(); 699 actionMenu->insertSeparator();
700 700
701 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this ); 701 mShowAction = new QAction( "show_incidence", i18n("Show..."), 0, this );
702 mShowAction->addTo( actionMenu ); 702 mShowAction->addTo( actionMenu );
703 connect( mShowAction, SIGNAL( activated() ), 703 connect( mShowAction, SIGNAL( activated() ),
704 mView, SLOT( showIncidence() ) ); 704 mView, SLOT( showIncidence() ) );
705 705
706 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this ); 706 mEditAction = new QAction( "edit_incidence", i18n("Edit..."), 0, this );
707 mEditAction->addTo( actionMenu ); 707 mEditAction->addTo( actionMenu );
708 connect( mEditAction, SIGNAL( activated() ), 708 connect( mEditAction, SIGNAL( activated() ),
709 mView, SLOT( editIncidence() ) ); 709 mView, SLOT( editIncidence() ) );
710 710
711 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this ); 711 mDeleteAction = new QAction( "delete_incidence", i18n("Delete..."), 0, this );
712 mDeleteAction->addTo( actionMenu ); 712 mDeleteAction->addTo( actionMenu );
713 connect( mDeleteAction, SIGNAL( activated() ), 713 connect( mDeleteAction, SIGNAL( activated() ),
714 mView, SLOT( deleteIncidence() ) ); 714 mView, SLOT( deleteIncidence() ) );
715 715
716 716
717 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this ); 717 mCloneAction = new QAction( "clone_incidence", i18n("Clone..."), 0, this );
718 mCloneAction->addTo( actionMenu ); 718 mCloneAction->addTo( actionMenu );
719 connect( mCloneAction, SIGNAL( activated() ), 719 connect( mCloneAction, SIGNAL( activated() ),
720 mView, SLOT( cloneIncidence() ) ); 720 mView, SLOT( cloneIncidence() ) );
721 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this ); 721 mMoveAction = new QAction( "Move_incidence", i18n("Move..."), 0, this );
722 mMoveAction->addTo( actionMenu ); 722 mMoveAction->addTo( actionMenu );
723 connect( mMoveAction, SIGNAL( activated() ), 723 connect( mMoveAction, SIGNAL( activated() ),
724 mView, SLOT( moveIncidence() ) ); 724 mView, SLOT( moveIncidence() ) );
725 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this ); 725 mBeamAction = new QAction( "Beam_incidence", i18n("Beam..."), 0, this );
726 mBeamAction->addTo( actionMenu ); 726 mBeamAction->addTo( actionMenu );
727 connect( mBeamAction, SIGNAL( activated() ), 727 connect( mBeamAction, SIGNAL( activated() ),
728 mView, SLOT( beamIncidence() ) ); 728 mView, SLOT( beamIncidence() ) );
729 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this ); 729 mCancelAction = new QAction( "Cancel_incidence", i18n("Toggle Cancel"), 0, this );
730 mCancelAction->addTo( actionMenu ); 730 mCancelAction->addTo( actionMenu );
731 connect( mCancelAction, SIGNAL( activated() ), 731 connect( mCancelAction, SIGNAL( activated() ),
732 mView, SLOT( toggleCancelIncidence() ) ); 732 mView, SLOT( toggleCancelIncidence() ) );
733 733
734 actionMenu->insertSeparator(); 734 actionMenu->insertSeparator();
735 735
736 action = new QAction( "purge_completed", i18n("Purge Completed"), 0, 736 action = new QAction( "purge_completed", i18n("Purge Completed"), 0,
737 this ); 737 this );
738 action->addTo( actionMenu ); 738 action->addTo( actionMenu );
739 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) ); 739 connect( action, SIGNAL( activated() ), mView, SLOT( purgeCompleted() ) );
740 740
741 icon = loadPixmap( pathString + "search" ); 741 icon = loadPixmap( pathString + "search" );
742 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this ); 742 QAction* search_action = new QAction( i18n("Search"), icon, i18n("Search..."), 0, this );
743 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4); 743 configureToolBarMenu->insertItem(icon, i18n("Search"), 120 , 4);
744 search_action->addTo( actionMenu ); 744 search_action->addTo( actionMenu );
745 connect( search_action, SIGNAL( activated() ), 745 connect( search_action, SIGNAL( activated() ),
746 mView->dialogManager(), SLOT( showSearchDialog() ) ); 746 mView->dialogManager(), SLOT( showSearchDialog() ) );
747 747
748 icon = loadPixmap( pathString + "today" ); 748 icon = loadPixmap( pathString + "today" );
749 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130); 749 configureToolBarMenu->insertItem(icon, i18n("Go to Today"), 130);
750 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this ); 750 QAction* today_action = new QAction( i18n("Go to Today"), icon, i18n("Go to Today"), 0, this );
751 today_action->addTo( actionMenu ); 751 today_action->addTo( actionMenu );
752 connect( today_action, SIGNAL( activated() ), 752 connect( today_action, SIGNAL( activated() ),
753 mView, SLOT( goToday() ) ); 753 mView, SLOT( goToday() ) );
754 754
755 if ( KOPrefs::instance()->mShowFullMenu ) { 755 if ( KOPrefs::instance()->mShowFullMenu ) {
756 actionMenu->insertSeparator(); 756 actionMenu->insertSeparator();
757 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu ); 757 actionMenu->insertItem( i18n("Configure Toolbar"),configureToolBarMenu );
758 758
759 } 759 }
760 // actionMenu->insertSeparator(); 760 // actionMenu->insertSeparator();
761 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0, 761 action = new QAction( "import_qtopia", i18n("Import (*.ics/*.vcs) file"), 0,
762 this ); 762 this );
763 action->addTo( importMenu ); 763 action->addTo( importMenu );
764 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) ); 764 connect( action, SIGNAL( activated() ), SLOT( importIcal() ) );
765 action = new QAction( "import_quick", i18n("Import last file"), 0, 765 action = new QAction( "import_quick", i18n("Import last file"), 0,
766 this ); 766 this );
767 action->addTo( importMenu ); 767 action->addTo( importMenu );
768 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) ); 768 connect( action, SIGNAL( activated() ), SLOT( quickImportIcal() ) );
769 importMenu->insertSeparator(); 769 importMenu->insertSeparator();
770 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0, 770 action = new QAction( "import_bday", i18n("Import Birthdays (KA/Pi)"), 0,
771 this ); 771 this );
772 action->addTo( importMenu ); 772 action->addTo( importMenu );
773 connect( action, SIGNAL( activated() ), SLOT( importBday() ) ); 773 connect( action, SIGNAL( activated() ), SLOT( importBday() ) );
774#ifndef DESKTOP_VERSION 774#ifndef DESKTOP_VERSION
775 importMenu->insertSeparator(); 775 importMenu->insertSeparator();
776 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0, 776 action = new QAction( "import_qtopia", i18n("Import Opie/Qtopia Cal."), 0,
777 this ); 777 this );
778 action->addTo( importMenu ); 778 action->addTo( importMenu );
779 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) ); 779 connect( action, SIGNAL( activated() ), SLOT( importQtopia() ) );
780#else 780#else
781#ifdef _WIN32_ 781#ifdef _WIN32_
782 importMenu->insertSeparator(); 782 importMenu->insertSeparator();
783 action = new QAction( "import_ol", i18n("Import from OL"), 0, 783 action = new QAction( "import_ol", i18n("Import from OL"), 0,
784 this ); 784 this );
785 action->addTo( importMenu ); 785 action->addTo( importMenu );
786 connect( action, SIGNAL( activated() ), SLOT( importOL() ) ); 786 connect( action, SIGNAL( activated() ), SLOT( importOL() ) );
787#endif 787#endif
788#endif 788#endif
789 789
790 importMenu->insertSeparator(); 790 importMenu->insertSeparator();
791 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0, 791 action = new QAction( "load_cal", i18n("Load Calendar Backup"), 0,
792 this ); 792 this );
793 action->addTo( importMenu ); 793 action->addTo( importMenu );
794 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) ); 794 connect( action, SIGNAL( activated() ), SLOT( loadCalendar() ) );
795 795
796 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0, 796 action = new QAction( "save_cal", i18n("Save Calendar Backup"), 0,
797 this ); 797 this );
798 action->addTo( importMenu ); 798 action->addTo( importMenu );
799 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) ); 799 connect( action, SIGNAL( activated() ), SLOT( saveCalendar() ) );
800 800
801 importMenu->insertSeparator(); 801 importMenu->insertSeparator();
802 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0, 802 action = new QAction( "import_qtopia", i18n("Export VCalendar"), 0,
803 this ); 803 this );
804 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) ); 804 action->addTo( importMenu ); connect( action, SIGNAL( activated() ), SLOT( exportVCalendar() ) );
805 805
806 806
807 //LR 807 //LR
808 QPopupMenu *ex2phone = new QPopupMenu( this ); 808 QPopupMenu *ex2phone = new QPopupMenu( this );
809 ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 809 ex2phone->insertItem(i18n("Complete calendar..."), 1 );
810 ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 810 ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
811 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) ); 811 connect( ex2phone, SIGNAL( activated(int) ), this, SLOT( exportToPhone( int)) );
812 importMenu->insertItem( i18n("Export to phone"), ex2phone ); 812 importMenu->insertItem( i18n("Export to phone"), ex2phone );
813 813
814 importMenu->insertSeparator(); 814 importMenu->insertSeparator();
815 action = new QAction( "manage cat", i18n("Manage new categories..."), 0, 815 action = new QAction( "manage cat", i18n("Manage new categories..."), 0,
816 this ); 816 this );
817 action->addTo( importMenu ); 817 action->addTo( importMenu );
818 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) ); 818 connect( action, SIGNAL( activated() ), mView, SLOT( manageCategories() ) );
819#ifndef DESKTOP_VERSION 819#ifndef DESKTOP_VERSION
820 importMenu->insertSeparator(); 820 importMenu->insertSeparator();
821 brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0, 821 brAction = new QAction( "beam toggle", i18n("Beam receive enabled"), 0,
822 this ); 822 this );
823 brAction->addTo( importMenu ); 823 brAction->addTo( importMenu );
824 brAction->setToggleAction (true ) ; 824 brAction->setToggleAction (true ) ;
825 connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) ); 825 connect( brAction, SIGNAL( activated() ), this, SLOT( toggleBeamReceive() ) );
826 826
827 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0, 827 action = new QAction( "beam all", i18n("Beam complete calendar..."), 0,
828 this ); 828 this );
829 action->addTo( importMenu ); 829 action->addTo( importMenu );
830 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) ); 830 connect( action, SIGNAL( activated() ), mView, SLOT( beamCalendar() ) );
831 831
832 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0, 832 action = new QAction( "beam all", i18n("Beam filtered calendar..."), 0,
833 this ); 833 this );
834 action->addTo( importMenu ); 834 action->addTo( importMenu );
835 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) ); 835 connect( action, SIGNAL( activated() ), mView, SLOT( beamFilteredCalendar()) );
836#else 836#else
837 importMenu->insertSeparator(); 837 importMenu->insertSeparator();
838 icon = loadPixmap( pathString + "print" ); 838 icon = loadPixmap( pathString + "print" );
839 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this ); 839 action = new QAction( i18n("Print calendar..."),icon,i18n("Print calendar..."), 0, this );
840 action->addTo( importMenu ); 840 action->addTo( importMenu );
841 connect( action, SIGNAL( activated() ), 841 connect( action, SIGNAL( activated() ),
842 this, SLOT( printCal() ) ); 842 this, SLOT( printCal() ) );
843 843
844 icon = loadPixmap( pathString + "print" ); 844 icon = loadPixmap( pathString + "print" );
845 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this ); 845 action = new QAction( i18n("Print agenda selection..."),icon,i18n("Print agenda selection..."), 0, this );
846 action->addTo( importMenu ); 846 action->addTo( importMenu );
847 connect( action, SIGNAL( activated() ), 847 connect( action, SIGNAL( activated() ),
848 this, SLOT( printSel() ) ); 848 this, SLOT( printSel() ) );
849 action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this ); 849 action = new QAction( i18n("Print What's Next View..."),icon,i18n("Print What's Next View..."), 0, this );
850 action->addTo( importMenu ); 850 action->addTo( importMenu );
851 connect( action, SIGNAL( activated() ), 851 connect( action, SIGNAL( activated() ),
852 mView->viewManager(), SIGNAL( printWNV() ) ); 852 mView->viewManager(), SIGNAL( printWNV() ) );
853#endif 853#endif
854 importMenu->insertSeparator(); 854 importMenu->insertSeparator();
855 action = new QAction( "beam all", i18n("Save"), 0, 855 action = new QAction( "beam all", i18n("Save"), 0,
856 this ); 856 this );
857 action->addTo( importMenu ); 857 action->addTo( importMenu );
858 connect( action, SIGNAL( activated() ), this, SLOT( save() ) ); 858 connect( action, SIGNAL( activated() ), this, SLOT( save() ) );
859 action = new QAction( "beam all", i18n("Exit (+save)"), 0, 859 action = new QAction( "beam all", i18n("Exit (+save)"), 0,
860 this ); 860 this );
861 action->addTo( importMenu ); 861 action->addTo( importMenu );
862 connect( action, SIGNAL( activated() ), this, SLOT( close() ) ); 862 connect( action, SIGNAL( activated() ), this, SLOT( close() ) );
863 863
864 //menuBar->insertItem( "Configure",configureMenu ); 864 //menuBar->insertItem( "Configure",configureMenu );
865 //configureMenu->insertItem( "Toolbar",configureToolBarMenu ); 865 //configureMenu->insertItem( "Toolbar",configureToolBarMenu );
866 icon = loadPixmap( "korganizer/korganizer" ); 866 icon = loadPixmap( "korganizer/korganizer" );
867 867
868 action = new QAction( "Whats New", i18n("What's new?"), 0,this ); 868 action = new QAction( "Whats New", i18n("What's new?"), 0,this );
869 action->addTo( helpMenu ); 869 action->addTo( helpMenu );
870 connect( action, SIGNAL( activated() ), 870 connect( action, SIGNAL( activated() ),
871 SLOT( whatsNew() ) ); 871 SLOT( whatsNew() ) );
872 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this ); 872 action = new QAction( "featureHowto", i18n("Features + hints..."), 0,this );
873 action->addTo( helpMenu ); 873 action->addTo( helpMenu );
874 connect( action, SIGNAL( activated() ), 874 connect( action, SIGNAL( activated() ),
875 SLOT( features() ) ); 875 SLOT( features() ) );
876 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this ); 876 action = new QAction( "Keys + Colors", i18n("Keys + Colors..."), 0, this );
877 action->addTo( helpMenu ); 877 action->addTo( helpMenu );
878 connect( action, SIGNAL( activated() ), 878 connect( action, SIGNAL( activated() ),
879 SLOT( keyBindings() ) ); 879 SLOT( keyBindings() ) );
880 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this ); 880 action = new QAction( "Sync Howto", i18n("Sync HowTo..."), 0,this );
881 action->addTo( helpMenu ); 881 action->addTo( helpMenu );
882 connect( action, SIGNAL( activated() ), 882 connect( action, SIGNAL( activated() ),
883 SLOT( synchowto() ) ); 883 SLOT( synchowto() ) );
884 action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this ); 884 action = new QAction( "KDE Sync Howto", i18n("KDE Sync HowTo..."), 0,this );
885 action->addTo( helpMenu ); 885 action->addTo( helpMenu );
886 connect( action, SIGNAL( activated() ), 886 connect( action, SIGNAL( activated() ),
887 SLOT( kdesynchowto() ) ); 887 SLOT( kdesynchowto() ) );
888 action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this ); 888 action = new QAction( "Multi Sync Howto", i18n("Multi Sync HowTo..."), 0,this );
889 action->addTo( helpMenu ); 889 action->addTo( helpMenu );
890 connect( action, SIGNAL( activated() ), 890 connect( action, SIGNAL( activated() ),
891 SLOT( multisynchowto() ) ); 891 SLOT( multisynchowto() ) );
892 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this ); 892 action = new QAction( "Auto saving", i18n("Auto saving..."), 0, this );
893 action->addTo( helpMenu ); 893 action->addTo( helpMenu );
894 connect( action, SIGNAL( activated() ), 894 connect( action, SIGNAL( activated() ),
895 SLOT( aboutAutoSaving() ) ); 895 SLOT( aboutAutoSaving() ) );
896 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this ); 896 action = new QAction( "Problemd", i18n("Known Problems..."), 0,this );
897 action->addTo( helpMenu ); 897 action->addTo( helpMenu );
898 connect( action, SIGNAL( activated() ), 898 connect( action, SIGNAL( activated() ),
899 SLOT( aboutKnownBugs() ) ); 899 SLOT( aboutKnownBugs() ) );
900 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this ); 900 action = new QAction( "Translate Howto", i18n("User translation..."), 0,this );
901 action->addTo( helpMenu ); 901 action->addTo( helpMenu );
902 connect( action, SIGNAL( activated() ), 902 connect( action, SIGNAL( activated() ),
903 SLOT( usertrans() ) ); 903 SLOT( usertrans() ) );
904 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this ); 904 action = new QAction( "Frequently asked questions", i18n("FAQ..."), 0,this );
905 action->addTo( helpMenu ); 905 action->addTo( helpMenu );
906 connect( action, SIGNAL( activated() ), 906 connect( action, SIGNAL( activated() ),
907 SLOT( faq() ) ); 907 SLOT( faq() ) );
908 action = new QAction( "licence", i18n("Licence..."), 0, this ); 908 action = new QAction( "licence", i18n("Licence..."), 0, this );
909 action->addTo( helpMenu ); 909 action->addTo( helpMenu );
910 connect( action, SIGNAL( activated() ), 910 connect( action, SIGNAL( activated() ),
911 SLOT( licence() ) ); 911 SLOT( licence() ) );
912 action = new QAction( "about", i18n("About..."), 0, this ); 912 action = new QAction( "about", i18n("About..."), 0, this );
913 action->addTo( helpMenu ); 913 action->addTo( helpMenu );
914 connect( action, SIGNAL( activated() ), 914 connect( action, SIGNAL( activated() ),
915 SLOT( about() ) ); 915 SLOT( about() ) );
916 //menuBar->insertSeparator(); 916 //menuBar->insertSeparator();
917 917
918 // ****************************************************** 918 // ******************************************************
919 // menubar icons 919 // menubar icons
920 920
921 921
922 iconToolBar->setHorizontalStretchable (true ); 922 iconToolBar->setHorizontalStretchable (true );
923 //menuBar->insertItem( iconToolBar ); 923 //menuBar->insertItem( iconToolBar );
924 //xdays_action 924 //xdays_action
925 if (p-> mShowIconNewEvent) 925 if (p-> mShowIconNewEvent)
926 ne_action->addTo( iconToolBar ); 926 ne_action->addTo( iconToolBar );
927 if (p->mShowIconNewTodo ) 927 if (p->mShowIconNewTodo )
928 nt_action->addTo( iconToolBar ); 928 nt_action->addTo( iconToolBar );
929 if (p-> mShowIconSearch) 929 if (p-> mShowIconSearch)
930 search_action->addTo( iconToolBar ); 930 search_action->addTo( iconToolBar );
931 if (p-> mShowIconNext) 931 if (p-> mShowIconNext)
932 whatsnext_action->addTo( iconToolBar ); 932 whatsnext_action->addTo( iconToolBar );
933 if (p-> mShowIconNextDays) 933 if (p-> mShowIconNextDays)
934 xdays_action->addTo( iconToolBar ); 934 xdays_action->addTo( iconToolBar );
935 if (p-> mShowIconList) 935 if (p-> mShowIconList)
936 showlist_action->addTo( iconToolBar ); 936 showlist_action->addTo( iconToolBar );
937 if (p-> mShowIconDay1) 937 if (p-> mShowIconDay1)
938 day1_action->addTo( iconToolBar ); 938 day1_action->addTo( iconToolBar );
939 if (p-> mShowIconDay5) 939 if (p-> mShowIconDay5)
940 day5_action->addTo( iconToolBar ); 940 day5_action->addTo( iconToolBar );
941 if (p-> mShowIconDay7) 941 if (p-> mShowIconDay7)
942 day7_action->addTo( iconToolBar ); 942 day7_action->addTo( iconToolBar );
943 if (p-> mShowIconMonth) 943 if (p-> mShowIconMonth)
944 month_action->addTo( iconToolBar ); 944 month_action->addTo( iconToolBar );
945 if (p-> mShowIconTodoview) 945 if (p-> mShowIconTodoview)
946 todoview_action->addTo( iconToolBar ); 946 todoview_action->addTo( iconToolBar );
947 if (p-> mShowIconJournal) 947 if (p-> mShowIconJournal)
948 viewjournal_action->addTo( iconToolBar ); 948 viewjournal_action->addTo( iconToolBar );
949 icon = loadPixmap( pathString + "2leftarrowB" ); 949 icon = loadPixmap( pathString + "2leftarrowB" );
950 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14); 950 configureToolBarMenu->insertItem(icon, i18n("Prev. month"), 200, 14);
951 if (p-> mShowIconBackFast) { 951 if (p-> mShowIconBackFast) {
952 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this ); 952 action = new QAction( i18n("Prev. month"), icon, i18n("Prev. month"),0 , this );
953 connect( action, SIGNAL( activated() ), 953 connect( action, SIGNAL( activated() ),
954 mView, SLOT( goPreviousMonth() ) ); 954 mView, SLOT( goPreviousMonth() ) );
955 action->addTo( iconToolBar ); 955 action->addTo( iconToolBar );
956 } 956 }
957 icon = loadPixmap( pathString + "1leftarrowB" ); 957 icon = loadPixmap( pathString + "1leftarrowB" );
958 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15); 958 configureToolBarMenu->insertItem(icon, i18n("Go backward"), 210,15);
959 if (p-> mShowIconBack) { 959 if (p-> mShowIconBack) {
960 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this ); 960 action = new QAction( i18n("Go backward"), icon, i18n("Go backward"),0 , this );
961 connect( action, SIGNAL( activated() ), 961 connect( action, SIGNAL( activated() ),
962 mView, SLOT( goPrevious() ) ); 962 mView, SLOT( goPrevious() ) );
963 action->addTo( iconToolBar ); 963 action->addTo( iconToolBar );
964 } 964 }
965 if (p-> mShowIconToday) 965 if (p-> mShowIconToday)
966 today_action->addTo( iconToolBar ); 966 today_action->addTo( iconToolBar );
967 icon = loadPixmap( pathString + "1rightarrowB" ); 967 icon = loadPixmap( pathString + "1rightarrowB" );
968 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220); 968 configureToolBarMenu->insertItem(icon, i18n("Go forward"), 220);
969 if (p-> mShowIconForward) { 969 if (p-> mShowIconForward) {
970 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this ); 970 action = new QAction( i18n("Go forward"), icon, i18n("Go forward"),0 , this );
971 connect( action, SIGNAL( activated() ), 971 connect( action, SIGNAL( activated() ),
972 mView, SLOT( goNext() ) ); 972 mView, SLOT( goNext() ) );
973 action->addTo( iconToolBar ); 973 action->addTo( iconToolBar );
974 } 974 }
975 icon = loadPixmap( pathString + "2rightarrowB" ); 975 icon = loadPixmap( pathString + "2rightarrowB" );
976 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230); 976 configureToolBarMenu->insertItem(icon, i18n("Next month"), 230);
977 if (p-> mShowIconForwardFast) { 977 if (p-> mShowIconForwardFast) {
978 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this ); 978 action = new QAction( i18n("Next month"), icon, i18n("Next month"),0 , this );
979 connect( action, SIGNAL( activated() ), 979 connect( action, SIGNAL( activated() ),
980 mView, SLOT( goNextMonth() ) ); 980 mView, SLOT( goNextMonth() ) );
981 action->addTo( iconToolBar ); 981 action->addTo( iconToolBar );
982 } 982 }
983 983
984 984
985 configureToolBarMenu->insertItem(i18n("What's This?"), 300); 985 configureToolBarMenu->insertItem(i18n("What's This?"), 300);
986 986
987 if (p-> mShowIconNewEvent) 987 if (p-> mShowIconNewEvent)
988 configureToolBarMenu->setItemChecked( 10, true ); 988 configureToolBarMenu->setItemChecked( 10, true );
989 if (p->mShowIconNewTodo ) 989 if (p->mShowIconNewTodo )
990 configureToolBarMenu->setItemChecked( 20, true ); 990 configureToolBarMenu->setItemChecked( 20, true );
991 if (p-> mShowIconSearch) 991 if (p-> mShowIconSearch)
992 configureToolBarMenu->setItemChecked( 120, true ); 992 configureToolBarMenu->setItemChecked( 120, true );
993 if (p-> mShowIconList) 993 if (p-> mShowIconList)
994 configureToolBarMenu->setItemChecked( 30, true ); 994 configureToolBarMenu->setItemChecked( 30, true );
995 if (p-> mShowIconDay1) 995 if (p-> mShowIconDay1)
996 configureToolBarMenu->setItemChecked( 40, true ); 996 configureToolBarMenu->setItemChecked( 40, true );
997 if (p-> mShowIconDay5) 997 if (p-> mShowIconDay5)
998 configureToolBarMenu->setItemChecked( 50, true ); 998 configureToolBarMenu->setItemChecked( 50, true );
999 if (p-> mShowIconDay7) 999 if (p-> mShowIconDay7)
1000 configureToolBarMenu->setItemChecked( 60, true ); 1000 configureToolBarMenu->setItemChecked( 60, true );
1001 if (p-> mShowIconMonth) 1001 if (p-> mShowIconMonth)
1002 configureToolBarMenu->setItemChecked( 70, true ); 1002 configureToolBarMenu->setItemChecked( 70, true );
1003 if (p-> mShowIconTodoview) 1003 if (p-> mShowIconTodoview)
1004 configureToolBarMenu->setItemChecked( 80, true ); 1004 configureToolBarMenu->setItemChecked( 80, true );
1005 if (p-> mShowIconBackFast) 1005 if (p-> mShowIconBackFast)
1006 configureToolBarMenu->setItemChecked( 200, true ); 1006 configureToolBarMenu->setItemChecked( 200, true );
1007 if (p-> mShowIconBack) 1007 if (p-> mShowIconBack)
1008 configureToolBarMenu->setItemChecked( 210, true ); 1008 configureToolBarMenu->setItemChecked( 210, true );
1009 if (p-> mShowIconToday) 1009 if (p-> mShowIconToday)
1010 configureToolBarMenu->setItemChecked( 130, true ); 1010 configureToolBarMenu->setItemChecked( 130, true );
1011 if (p-> mShowIconForward) 1011 if (p-> mShowIconForward)
1012 configureToolBarMenu->setItemChecked( 220, true ); 1012 configureToolBarMenu->setItemChecked( 220, true );
1013 if (p-> mShowIconForwardFast) 1013 if (p-> mShowIconForwardFast)
1014 configureToolBarMenu->setItemChecked( 230, true ); 1014 configureToolBarMenu->setItemChecked( 230, true );
1015 if (p-> mShowIconNextDays) 1015 if (p-> mShowIconNextDays)
1016 configureToolBarMenu->setItemChecked( 100, true ); 1016 configureToolBarMenu->setItemChecked( 100, true );
1017 if (p-> mShowIconNext) 1017 if (p-> mShowIconNext)
1018 configureToolBarMenu->setItemChecked( 110, true ); 1018 configureToolBarMenu->setItemChecked( 110, true );
1019 if (p-> mShowIconJournal) 1019 if (p-> mShowIconJournal)
1020 configureToolBarMenu->setItemChecked( 90, true ); 1020 configureToolBarMenu->setItemChecked( 90, true );
1021 if (p-> mShowIconWhatsThis) 1021 if (p-> mShowIconWhatsThis)
1022 configureToolBarMenu->setItemChecked( 300, true ); 1022 configureToolBarMenu->setItemChecked( 300, true );
1023 1023
1024 QLabel* dummy = new QLabel( iconToolBar ); 1024 QLabel* dummy = new QLabel( iconToolBar );
1025 dummy->setBackgroundColor( iconToolBar->backgroundColor() ); 1025 dummy->setBackgroundColor( iconToolBar->backgroundColor() );
1026 if (!p-> mShowIconStretch) 1026 if (!p-> mShowIconStretch)
1027 iconToolBar->setStretchableWidget ( dummy ) ; 1027 iconToolBar->setStretchableWidget ( dummy ) ;
1028 else 1028 else
1029 configureToolBarMenu->setItemChecked( 5, true ); 1029 configureToolBarMenu->setItemChecked( 5, true );
1030 if (p-> mShowIconWhatsThis) 1030 if (p-> mShowIconWhatsThis)
1031 QWhatsThis::whatsThisButton ( iconToolBar ); 1031 QWhatsThis::whatsThisButton ( iconToolBar );
1032 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) ); 1032 connect( configureToolBarMenu, SIGNAL( activated( int ) ),this, SLOT(configureToolBar( int ) ) );
1033 configureAgenda( p->mHourSize ); 1033 configureAgenda( p->mHourSize );
1034 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) ); 1034 connect( configureAgendaMenu, SIGNAL( activated( int ) ),this, SLOT(configureAgenda( int ) ) );
1035} 1035}
1036 1036
1037void MainWindow::exportToPhone( int mode ) 1037void MainWindow::exportToPhone( int mode )
1038{ 1038{
1039 1039
1040 //ex2phone->insertItem(i18n("Complete calendar..."), 1 ); 1040 //ex2phone->insertItem(i18n("Complete calendar..."), 1 );
1041 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 ); 1041 //ex2phone->insertItem(i18n("Filtered calendar..."), 2 );
1042 KOex2phonePrefs ex2phone; 1042 KOex2phonePrefs ex2phone;
1043 1043
1044 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection ); 1044 ex2phone.mPhoneConnection->setText( KPimGlobalPrefs::instance()->mEx2PhoneConnection );
1045 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice ); 1045 ex2phone.mPhoneDevice->setText( KPimGlobalPrefs::instance()->mEx2PhoneDevice );
1046 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1046 ex2phone.mPhoneModel->setText( KPimGlobalPrefs::instance()->mEx2PhoneModel );
1047 if ( mode == 1 ) 1047 if ( mode == 1 )
1048 ex2phone.setCaption(i18n("Export complete calendar")); 1048 ex2phone.setCaption(i18n("Export complete calendar"));
1049 if ( mode == 2 ) 1049 if ( mode == 2 )
1050 ex2phone.setCaption(i18n("Export filtered calendar")); 1050 ex2phone.setCaption(i18n("Export filtered calendar"));
1051 1051
1052 if ( !ex2phone.exec() ) { 1052 if ( !ex2phone.exec() ) {
1053 return; 1053 return;
1054 } 1054 }
1055 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text(); 1055 KPimGlobalPrefs::instance()->mEx2PhoneConnection = ex2phone.mPhoneConnection->text();
1056 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text(); 1056 KPimGlobalPrefs::instance()->mEx2PhoneDevice = ex2phone.mPhoneDevice->text();
1057 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text(); 1057 KPimGlobalPrefs::instance()->mEx2PhoneModel = ex2phone.mPhoneModel->text();
1058 1058
1059 int inFuture = 0; 1059 int inFuture = 0;
1060 if ( ex2phone.mWriteBackFuture->isChecked() ) 1060 if ( ex2phone.mWriteBackFuture->isChecked() )
1061 inFuture = ex2phone.mWriteBackFutureWeeks->value(); 1061 inFuture = ex2phone.mWriteBackFutureWeeks->value();
1062 QPtrList<Incidence> delSel; 1062 QPtrList<Incidence> delSel;
1063 if ( mode == 1 ) 1063 if ( mode == 1 )
1064 delSel = mCalendar->rawIncidences(); 1064 delSel = mCalendar->rawIncidences();
1065 if ( mode == 2 ) 1065 if ( mode == 2 )
1066 delSel = mCalendar->incidences(); 1066 delSel = mCalendar->incidences();
1067 CalendarLocal* cal = new CalendarLocal(); 1067 CalendarLocal* cal = new CalendarLocal();
1068 cal->setLocalTime(); 1068 cal->setLocalTime();
1069 Incidence *incidence = delSel.first(); 1069 Incidence *incidence = delSel.first();
1070 QDateTime cur = QDateTime::currentDateTime().addDays( -7 ); 1070 QDateTime cur = QDateTime::currentDateTime().addDays( -7 );
1071 QDateTime end = cur.addDays( ( inFuture +1 ) *7 ); 1071 QDateTime end = cur.addDays( ( inFuture +1 ) *7 );
1072 while ( incidence ) { 1072 while ( incidence ) {
1073 if ( incidence->type() != "Journal" ) { 1073 if ( incidence->type() != "Journal" ) {
1074 bool add = true; 1074 bool add = true;
1075 if ( inFuture ) { 1075 if ( inFuture ) {
1076 QDateTime dt; 1076 QDateTime dt;
1077 if ( incidence->type() == "Todo" ) { 1077 if ( incidence->type() == "Todo" ) {
1078 Todo * t = (Todo*)incidence; 1078 Todo * t = (Todo*)incidence;
1079 if ( t->hasDueDate() ) 1079 if ( t->hasDueDate() )
1080 dt = t->dtDue(); 1080 dt = t->dtDue();
1081 else 1081 else
1082 dt = cur.addSecs( 62 ); 1082 dt = cur.addSecs( 62 );
1083 } 1083 }
1084 else { 1084 else {
1085 bool ok; 1085 bool ok;
1086 dt = incidence->getNextOccurence( cur, &ok ); 1086 dt = incidence->getNextOccurence( cur, &ok );
1087 if ( !ok ) 1087 if ( !ok )
1088 dt = cur.addSecs( -62 ); 1088 dt = cur.addSecs( -62 );
1089 } 1089 }
1090 if ( dt < cur || dt > end ) { 1090 if ( dt < cur || dt > end ) {
1091 add = false; 1091 add = false;
1092 } 1092 }
1093 } 1093 }
1094 if ( add ) { 1094 if ( add ) {
1095 Incidence *in = incidence->clone(); 1095 Incidence *in = incidence->clone();
1096 cal->addIncidence( in ); 1096 cal->addIncidence( in );
1097 } 1097 }
1098 } 1098 }
1099 incidence = delSel.next(); 1099 incidence = delSel.next();
1100 } 1100 }
1101 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice, 1101 PhoneAccess::writeConfig( KPimGlobalPrefs::instance()->mEx2PhoneDevice,
1102 KPimGlobalPrefs::instance()->mEx2PhoneConnection, 1102 KPimGlobalPrefs::instance()->mEx2PhoneConnection,
1103 KPimGlobalPrefs::instance()->mEx2PhoneModel ); 1103 KPimGlobalPrefs::instance()->mEx2PhoneModel );
1104 1104
1105 setCaption( i18n("Writing to phone...")); 1105 setCaption( i18n("Writing to phone..."));
1106 if ( PhoneFormat::writeToPhone( cal ) ) 1106 if ( PhoneFormat::writeToPhone( cal ) )
1107 setCaption( i18n("Export to phone successful!")); 1107 setCaption( i18n("Export to phone successful!"));
1108 else 1108 else
1109 setCaption( i18n("Error exporting to phone!")); 1109 setCaption( i18n("Error exporting to phone!"));
1110 delete cal; 1110 delete cal;
1111} 1111}
1112 1112
1113 1113
1114void MainWindow::setDefaultPreferences() 1114void MainWindow::setDefaultPreferences()
1115{ 1115{
1116 KOPrefs *p = KOPrefs::instance(); 1116 KOPrefs *p = KOPrefs::instance();
1117 1117
1118 p->mCompactDialogs = true; 1118 p->mCompactDialogs = true;
1119 p->mConfirm = true; 1119 p->mConfirm = true;
1120 // p->mEnableQuickTodo = false; 1120 // p->mEnableQuickTodo = false;
1121 1121
1122} 1122}
1123 1123
1124QString MainWindow::resourcePath() 1124QString MainWindow::resourcePath()
1125{ 1125{
1126 return KGlobal::iconLoader()->iconPath(); 1126 return KGlobal::iconLoader()->iconPath();
1127} 1127}
1128 1128
1129void MainWindow::displayText( QString text ,QString cap ) 1129void MainWindow::displayText( QString text ,QString cap )
1130{ 1130{
1131 QDialog dia( this, "name", true ); ; 1131 QDialog dia( this, "name", true ); ;
1132 dia.setCaption( cap ); 1132 dia.setCaption( cap );
1133 QVBoxLayout* lay = new QVBoxLayout( &dia ); 1133 QVBoxLayout* lay = new QVBoxLayout( &dia );
1134 lay->setSpacing( 3 ); 1134 lay->setSpacing( 3 );
1135 lay->setMargin( 3 ); 1135 lay->setMargin( 3 );
1136 QTextBrowser tb ( &dia ); 1136 QTextBrowser tb ( &dia );
1137 lay->addWidget( &tb ); 1137 lay->addWidget( &tb );
1138 tb.setText( text ); 1138 tb.setText( text );
1139#ifdef DESKTOP_VERSION 1139#ifdef DESKTOP_VERSION
1140 dia.resize( 640, 480); 1140 dia.resize( 640, 480);
1141#else 1141#else
1142 dia.showMaximized(); 1142 dia.showMaximized();
1143#endif 1143#endif
1144 dia.exec(); 1144 dia.exec();
1145} 1145}
1146 1146
1147void MainWindow::features() 1147void MainWindow::features()
1148{ 1148{
1149 1149
1150 KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" ); 1150 KApplication::showFile( i18n("KO/Pi Features and hints"), "kdepim/korganizer/featuresKOPI.txt" );
1151} 1151}
1152 1152
1153void MainWindow::usertrans() 1153void MainWindow::usertrans()
1154{ 1154{
1155 1155
1156 KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" ); 1156 KApplication::showFile( i18n("KO/Pi User translation HowTo"), "kdepim/korganizer/usertranslationHOWTO.txt" );
1157} 1157}
1158 1158
1159void MainWindow::kdesynchowto() 1159void MainWindow::kdesynchowto()
1160{ 1160{
1161 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" ); 1161 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/Zaurus-KDE_syncHowTo.txt" );
1162} 1162}
1163void MainWindow::multisynchowto() 1163void MainWindow::multisynchowto()
1164{ 1164{
1165 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" ); 1165 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/MultiSyncHowTo.txt" );
1166} 1166}
1167void MainWindow::synchowto() 1167void MainWindow::synchowto()
1168{ 1168{
1169 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" ); 1169 KApplication::showFile( "KDE-Pim/Pi Synchronization HowTo", "kdepim/SyncHowto.txt" );
1170} 1170}
1171void MainWindow::faq() 1171void MainWindow::faq()
1172{ 1172{
1173 KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" ); 1173 KApplication::showFile( i18n("KO/Pi FAQ"), "kdepim/korganizer/kopiFAQ.txt" );
1174 1174
1175} 1175}
1176void MainWindow::whatsNew() 1176void MainWindow::whatsNew()
1177{ 1177{
1178 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" ); 1178 KApplication::showFile( "KDE-Pim/Pi Version Info", "kdepim/WhatsNew.txt" );
1179 1179
1180} 1180}
1181void MainWindow::licence() 1181void MainWindow::licence()
1182{ 1182{
1183 KApplication::showLicence(); 1183 KApplication::showLicence();
1184 1184
1185} 1185}
1186void MainWindow::about() 1186void MainWindow::about()
1187{ 1187{
1188 QString version; 1188 QString version;
1189#include <../version> 1189#include <../version>
1190 QMessageBox::about( this, i18n("About KOrganizer/Pi"), 1190 QMessageBox::about( this, i18n("About KOrganizer/Pi"),
1191 i18n("KOrganizer/Platform-independent\n") + 1191 i18n("KOrganizer/Platform-independent\n") +
1192 "(KO/Pi) " + version + " - " + 1192 "(KO/Pi) " + version + " - " +
1193 1193
1194#ifdef DESKTOP_VERSION 1194#ifdef DESKTOP_VERSION
1195 i18n("Desktop Edition\n") + 1195 i18n("Desktop Edition\n") +
1196#else 1196#else
1197 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") + 1197 i18n("PDA-Edition\nfor: Zaurus 5x00 / 7x0 / 8x0\n") +
1198#endif 1198#endif
1199 i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") ); 1199 i18n("(c) 2004 Lutz Rogowski\nEmail:lutz@pi-sync.net\nKO/Pi is based on KOrganizer\n(c) 2002,2003 Cornelius Schumacher\nEmail: schumacher@kde.org\nKOrganizer/Pi is licensed\nunder the GPL.\nKO/Pi can be compiled for\nLinux, Zaurus-PDA and Windows\nwww.korganizer.org\nwww.pi-sync.net\n") );
1200} 1200}
1201void MainWindow::keyBindings() 1201void MainWindow::keyBindings()
1202{ 1202{
1203 QString cap = i18n("KO/Pi Keys + Colors"); 1203 QString cap = i18n("KO/Pi Keys + Colors");
1204 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") + 1204 QString text = i18n("<p><h2>KO/Pi key shortcuts:</h2></p>\n") +
1205 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+ 1205 i18n("<p><b>H</b>: This help dialog | <b>S</b>: Search dialog</p>\n")+
1206 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") + 1206 i18n("<p><b>I</b>: Show info for selected event/todo</p>\n") +
1207 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+ 1207 i18n("<p><b>Space</b>: Toggle fullscreen | <b>P</b>: Date picker</p>\n")+
1208 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+ 1208 i18n("<p><b>F</b>: Toggle filterview |<b>F+ctrl</b>: Edit filter </p>\n")+
1209 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+ 1209 i18n("<p><b>O</b>: Filter On/Off | <b>J</b>: Journal view</p>\n")+
1210 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+ 1210 i18n("<p><b>1-0</b> (+<b>ctrl</b>): Select filter 1-10 (11-20)</p>\n")+
1211 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+ 1211 i18n("<p><b>N</b>: Next days view| <b>W</b>: What's next view\n ")+
1212 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+ 1212 i18n("<p><b>V</b>: Todo view | <b>L</b>: Event list view</p>\n")+
1213 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+ 1213 i18n("<p><b>Z,Y</b>: Work week view | <b>U</b>: Week view</p>\n")+
1214 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+ 1214 i18n("<p><b>D</b>: One day view | <b>M</b>: Month view</p>\n")+
1215 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+ 1215 i18n("<p><b>E</b>: Edit selected item |<b> E+ctrl</b>: New Event</p>\n")+
1216 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+ 1216 i18n("<p><b>T</b>: Goto today | <b>T+ctrl</b>: New Todo</p>\n")+
1217 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+ 1217 i18n("<p><b>S+ctrl</b>: Add sub-todo | <b>X</b>: Toggle datenavigator</p>\n")+
1218 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+ 1218 i18n("<p><b>+,-</b> : Zoom in/out agenda | <b>A</b>: Toggle allday agenda height</p>\n")+
1219 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+ 1219 i18n("<p><b>C</b>: Show current time in agenda view</p>\n")+
1220 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+ 1220 i18n("<p><b>B</b>: Edit description (details) of selected item</p>\n")+
1221 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+ 1221 i18n("<p><b>right</b>: Next week | <b>right+ctrl</b>: Next month</p>\n")+
1222 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+ 1222 i18n("<p><b>left</b>: Prev. week | <b>left+ctrl</b>: Prev. month</p>\n")+
1223 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+ 1223 i18n("<p><b>del,backspace</b>: Delete selected item</p>\n")+
1224 i18n("<p><h3>In agenda view:</h3></p>\n") + 1224 i18n("<p><h3>In agenda view:</h3></p>\n") +
1225 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+ 1225 i18n("<p><b>up/down</b>: Scroll agenda view</p>\n")+
1226 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+ 1226 i18n("<p><b>ctrl+up/down</b>: Scroll small todo view</p>\n")+
1227 i18n("<p><h3>In todo view:</h3></p>\n") + 1227 i18n("<p><h3>In todo view:</h3></p>\n") +
1228 i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+ 1228 i18n("<p><b>shift+U</b>: <b>U</b>nparent todo (make root todo)</p>\n")+
1229 i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+ 1229 i18n("<p><b>shift+S</b>: Make <b>S</b>ubtodo (reparent todo)</p>\n")+
1230 i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+ 1230 i18n("<p><b>shift+P</b>: Make new <b>P</b>arent for todo selected with shift+S</p>\n")+
1231 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+ 1231 i18n("<p><b>Q</b>: Toggle quick todo line edit.</p>\n")+
1232 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1232 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1233 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+ 1233 i18n("<p><b>return</b>: Mark item as completed+one step down.</p>\n")+
1234 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+ 1234 i18n("<p><b>return+shift</b>: Mark item as not completed+one step down</p>\n")+
1235 i18n("<p><h3>In list view:</h3></p>\n") + 1235 i18n("<p><h3>In list view:</h3></p>\n") +
1236 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+ 1236 i18n("<p><b>I</b>: Show info of current item+one step down.</p>\n")+
1237 i18n("<p><b>return</b>: Select item+one step down</p>\n")+ 1237 i18n("<p><b>return</b>: Select item+one step down</p>\n")+
1238 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+ 1238 i18n("<p><b>return+shift</b>: Deselect item+one step down</p>\n")+
1239 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+ 1239 i18n("<p><b>up/down</b>: Next/prev item</p>\n")+
1240 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+ 1240 i18n("<p><b>ctrl+up/down</b>: Goto up/down by 20% of items</p>\n")+
1241 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+ 1241 i18n("<p><b>shift+up/down</b>: Goto first/last item</p>\n")+
1242 i18n("<p><h3>In event/todo viewer:</h3></p>\n") + 1242 i18n("<p><h3>In event/todo viewer:</h3></p>\n") +
1243 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+ 1243 i18n("<p><b>I,C</b>: Close dialog.</p>\n")+
1244 i18n("<p><b>A</b>: Show agenda view.</p>\n")+ 1244 i18n("<p><b>A</b>: Show agenda view.</p>\n")+
1245 i18n("<p><b>E</b>: Edit item</p>\n") + 1245 i18n("<p><b>E</b>: Edit item</p>\n") +
1246 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") + 1246 i18n("<p><h2>KO/Pi icon colors:</h2></p>\n") +
1247 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") + 1247 i18n("<p><b>(for square icons in agenda and month view)</b></p>\n") +
1248 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+ 1248 i18n("<p><b>Cross</b>: Item cancelled.([c] in Whats'Next view)</p>\n")+
1249 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+ 1249 i18n("<p><b>Red</b>: Alarm set.([a] in Whats'Next view)</p>\n")+
1250 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+ 1250 i18n("<p><b>Blue</b>: Recurrent event.([r] in Whats'Next view)</p>\n")+
1251 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+ 1251 i18n("<p><b>Dark green</b>: Information(description) available.([i] in WN view)</p>\n")+
1252 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+ 1252 i18n("<p><b>Black</b>: Event/todo with attendees. You are the organizer!</p>\n")+
1253 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") + 1253 i18n("<p><b>Dark yellow</b>: Event/todo with attendees.</p>\n") +
1254 i18n("<p><b>White</b>: Item readonly</p>\n"); 1254 i18n("<p><b>White</b>: Item readonly</p>\n");
1255 displayText( text, cap); 1255 displayText( text, cap);
1256} 1256}
1257void MainWindow::aboutAutoSaving() 1257void MainWindow::aboutAutoSaving()
1258{ 1258{
1259 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"); 1259 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");
1260 1260
1261 KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text); 1261 KApplication::showText( i18n("Auto Saving in KOrganizer/Pi"), text);
1262 1262
1263} 1263}
1264void MainWindow::aboutKnownBugs() 1264void MainWindow::aboutKnownBugs()
1265{ 1265{
1266 QMessageBox* msg; 1266 QMessageBox* msg;
1267 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"), 1267 msg = new QMessageBox( i18n("Known Problems in KOrganizer/Pi"),
1268 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")+ 1268 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")+
1269 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+ 1269 i18n("2) Audio alarm daemon\nfor Zaurus is available!\nas an additional small application\n")+
1270 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") + 1270 i18n("\nPlease report unexpected behaviour to\nlutz@pi-sync.net\n") +
1271 i18n("\nor report them in the bugtracker on\n") + 1271 i18n("\nor report them in the bugtracker on\n") +
1272 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"), 1272 i18n("\nhttp://sourceforge.net/projects/kdepimpi\n"),
1273 QMessageBox::NoIcon, 1273 QMessageBox::NoIcon,
1274 QMessageBox::Ok, 1274 QMessageBox::Ok,
1275 QMessageBox::NoButton, 1275 QMessageBox::NoButton,
1276 QMessageBox::NoButton); 1276 QMessageBox::NoButton);
1277 msg->exec(); 1277 msg->exec();
1278 delete msg; 1278 delete msg;
1279 1279
1280} 1280}
1281 1281
1282QString MainWindow::defaultFileName() 1282QString MainWindow::defaultFileName()
1283{ 1283{
1284 return locateLocal( "data", "korganizer/mycalendar.ics" ); 1284 return locateLocal( "data", "korganizer/mycalendar.ics" );
1285} 1285}
1286QString MainWindow::syncFileName() 1286QString MainWindow::syncFileName()
1287{ 1287{
1288#ifdef DESKTOP_VERSION 1288#ifdef DESKTOP_VERSION
1289 return locateLocal( "tmp", "synccalendar.ics" ); 1289 return locateLocal( "tmp", "synccalendar.ics" );
1290#else 1290#else
1291 return QString( "/tmp/synccalendar.ics" ); 1291 return QString( "/tmp/synccalendar.ics" );
1292#endif 1292#endif
1293} 1293}
1294 1294
1295void MainWindow::processIncidenceSelection( Incidence *incidence ) 1295void MainWindow::processIncidenceSelection( Incidence *incidence )
1296{ 1296{
1297 if ( !incidence ) { 1297 if ( !incidence ) {
1298 enableIncidenceActions( false ); 1298 enableIncidenceActions( false );
1299 1299
1300 mNewSubTodoAction->setEnabled( false ); 1300 mNewSubTodoAction->setEnabled( false );
1301 setCaptionToDates(); 1301 setCaptionToDates();
1302 return; 1302 return;
1303 1303
1304 } 1304 }
1305 1305
1306 //KGlobal::locale()->formatDateTime(nextA, true); 1306 //KGlobal::locale()->formatDateTime(nextA, true);
1307 QString startString = ""; 1307 QString startString = "";
1308 if ( incidence->type() != "Todo" ) { 1308 if ( incidence->type() != "Todo" ) {
1309 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) { 1309 if ( incidence->dtStart().date() < incidence->dtEnd().date() ) {
1310 if ( incidence->doesFloat() ) { 1310 if ( incidence->doesFloat() ) {
1311 startString += ": "+incidence->dtStartDateStr( true ); 1311 startString += ": "+incidence->dtStartDateStr( true );
1312 startString += " --- "+((Event*)incidence)->dtEndDateStr( true ); 1312 startString += " --- "+((Event*)incidence)->dtEndDateStr( true );
1313 1313
1314 } else { 1314 } else {
1315 startString = ": "+incidence->dtStartStr(true); 1315 startString = ": "+incidence->dtStartStr(true);
1316 startString += " --- "+((Event*)incidence)->dtEndStr(true); 1316 startString += " --- "+((Event*)incidence)->dtEndStr(true);
1317 1317
1318 } 1318 }
1319 1319
1320 } else { 1320 } else {
1321 if ( incidence->dtStart().time() != incidence->dtEnd().time() ) 1321 if ( incidence->dtStart().time() != incidence->dtEnd().time() )
1322 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+ 1322 startString = ": "+KGlobal::locale()->formatTime(incidence->dtStart().time())+
1323 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time()); 1323 "-"+KGlobal::locale()->formatTime(incidence->dtEnd().time());
1324 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true); 1324 startString +=" "+KGlobal::locale()->formatDate( incidence->dtStart().date(), true);
1325 } 1325 }
1326 1326
1327 } 1327 }
1328 else 1328 else
1329 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed"); 1329 startString = i18n(": (Prio ") +QString::number( (( KCal::Todo*)incidence)->priority() ) +") "+QString::number( (( KCal::Todo*)incidence)->percentComplete() ) +i18n("\% completed");
1330 if ( !incidence->location().isEmpty() ) 1330 if ( !incidence->location().isEmpty() )
1331 startString += " (" +incidence->location()+")"; 1331 startString += " (" +incidence->location()+")";
1332 setCaption( incidence->summary()+startString); 1332 setCaption( incidence->summary()+startString);
1333 1333
1334 enableIncidenceActions( true ); 1334 enableIncidenceActions( true );
1335 1335
1336 if ( incidence->type() == "Event" ) { 1336 if ( incidence->type() == "Event" ) {
1337 mShowAction->setText( i18n("Show Event...") ); 1337 mShowAction->setText( i18n("Show Event...") );
1338 mEditAction->setText( i18n("Edit Event...") ); 1338 mEditAction->setText( i18n("Edit Event...") );
1339 mDeleteAction->setText( i18n("Delete Event...") ); 1339 mDeleteAction->setText( i18n("Delete Event...") );
1340 1340
1341 mNewSubTodoAction->setEnabled( false ); 1341 mNewSubTodoAction->setEnabled( false );
1342 } else if ( incidence->type() == "Todo" ) { 1342 } else if ( incidence->type() == "Todo" ) {
1343 mShowAction->setText( i18n("Show Todo...") ); 1343 mShowAction->setText( i18n("Show Todo...") );
1344 mEditAction->setText( i18n("Edit Todo...") ); 1344 mEditAction->setText( i18n("Edit Todo...") );
1345 mDeleteAction->setText( i18n("Delete Todo...") ); 1345 mDeleteAction->setText( i18n("Delete Todo...") );
1346 1346
1347 mNewSubTodoAction->setEnabled( true ); 1347 mNewSubTodoAction->setEnabled( true );
1348 } else { 1348 } else {
1349 mShowAction->setText( i18n("Show...") ); 1349 mShowAction->setText( i18n("Show...") );
1350 mShowAction->setText( i18n("Edit...") ); 1350 mShowAction->setText( i18n("Edit...") );
1351 mShowAction->setText( i18n("Delete...") ); 1351 mShowAction->setText( i18n("Delete...") );
1352 1352
1353 mNewSubTodoAction->setEnabled( false ); 1353 mNewSubTodoAction->setEnabled( false );
1354 } 1354 }
1355} 1355}
1356 1356
1357void MainWindow::enableIncidenceActions( bool enabled ) 1357void MainWindow::enableIncidenceActions( bool enabled )
1358{ 1358{
1359 mShowAction->setEnabled( enabled ); 1359 mShowAction->setEnabled( enabled );
1360 mEditAction->setEnabled( enabled ); 1360 mEditAction->setEnabled( enabled );
1361 mDeleteAction->setEnabled( enabled ); 1361 mDeleteAction->setEnabled( enabled );
1362 1362
1363 mCloneAction->setEnabled( enabled ); 1363 mCloneAction->setEnabled( enabled );
1364 mMoveAction->setEnabled( enabled ); 1364 mMoveAction->setEnabled( enabled );
1365 mBeamAction->setEnabled( enabled ); 1365 mBeamAction->setEnabled( enabled );
1366 mCancelAction->setEnabled( enabled ); 1366 mCancelAction->setEnabled( enabled );
1367} 1367}
1368 1368
1369void MainWindow::importOL() 1369void MainWindow::importOL()
1370{ 1370{
1371#ifdef _WIN32_ 1371#ifdef _WIN32_
1372 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this ); 1372 KOImportOLdialog *id = new KOImportOLdialog("Import from OL - select folder!" , mView->calendar(),this );
1373 id->exec(); 1373 id->exec();
1374 delete id; 1374 delete id;
1375 mView->updateView(); 1375 mView->updateView();
1376#endif 1376#endif
1377} 1377}
1378void MainWindow::importBday() 1378void MainWindow::importBday()
1379{ 1379{
1380 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1380 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1381 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"), 1381 i18n("When importing birthdays twice\nduplicated events will be ignored,\nif the event has not been\nchanged in KO/Pi!\n"),
1382 i18n("Import!"), i18n("Cancel"), 0, 1382 i18n("Import!"), i18n("Cancel"), 0,
1383 0, 1 ); 1383 0, 1 );
1384 if ( result == 0 ) { 1384 if ( result == 0 ) {
1385 mView->importBday(); 1385 mView->importBday();
1386 1386
1387 } 1387 }
1388 1388
1389 1389
1390} 1390}
1391void MainWindow::importQtopia() 1391void MainWindow::importQtopia()
1392{ 1392{
1393#ifndef DESKTOP_VERSION 1393#ifndef DESKTOP_VERSION
1394 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1394 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1395 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"), 1395 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"),
1396 i18n("Import!"), i18n("Cancel"), 0, 1396 i18n("Import!"), i18n("Cancel"), 0,
1397 0, 1 ); 1397 0, 1 );
1398 if ( result == 0 ) { 1398 if ( result == 0 ) {
1399 QString datebook = Global::applicationFileName( "datebook", "datebook.xml"); 1399 QString datebook = Global::applicationFileName( "datebook", "datebook.xml");
1400 QString todolist = Global::applicationFileName( "todolist", "todolist.xml"); 1400 QString todolist = Global::applicationFileName( "todolist", "todolist.xml");
1401 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml"; 1401 QString categories = QString( getenv( "HOME" ) ) + "/Settings/Categories.xml";
1402 mView->importQtopia( categories, datebook, todolist ); 1402 mView->importQtopia( categories, datebook, todolist );
1403 } 1403 }
1404#else 1404#else
1405 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1405 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1406 i18n("Not supported \non desktop!\n"), 1406 i18n("Not supported \non desktop!\n"),
1407 i18n("Ok"), i18n("Cancel"), 0, 1407 i18n("Ok"), i18n("Cancel"), 0,
1408 0, 1 ); 1408 0, 1 );
1409 1409
1410#endif 1410#endif
1411} 1411}
1412 1412
1413void MainWindow::saveOnClose() 1413void MainWindow::saveOnClose()
1414{ 1414{
1415 KOPrefs *p = KOPrefs::instance(); 1415 KOPrefs *p = KOPrefs::instance();
1416 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal ); 1416 p->mToolBarHor = ( iconToolBar->orientation () == Qt:: Horizontal );
1417 p->mToolBarUp = iconToolBar->x() > width()/2 || 1417 p->mToolBarUp = iconToolBar->x() > width()/2 ||
1418 iconToolBar->y() > height()/2; 1418 iconToolBar->y() > height()/2;
1419 mView->writeSettings(); 1419 mView->writeSettings();
1420 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName())) 1420 if ( mCalendarModifiedFlag || mView->checkFileChanged( defaultFileName()))
1421 save(); 1421 save();
1422} 1422}
1423void MainWindow::slotModifiedChanged( bool changed ) 1423void MainWindow::slotModifiedChanged( bool changed )
1424{ 1424{
1425 if ( mBlockAtStartup ) 1425 if ( mBlockAtStartup )
1426 return; 1426 return;
1427 int msec; 1427 int msec;
1428 // we store the changes after 1 minute, 1428 // we store the changes after 1 minute,
1429 // and for safety reasons after 10 minutes again 1429 // and for safety reasons after 10 minutes again
1430 if ( !mSyncManager->blockSave() ) 1430 if ( !mSyncManager->blockSave() )
1431 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000; 1431 msec = (1000 * 60*KOPrefs::instance()->mAutoSaveInterval) +1000;
1432 else 1432 else
1433 msec = 1000 * 600; 1433 msec = 1000 * 600;
1434 mSaveTimer.start( msec, true ); // 1 minute 1434 mSaveTimer.start( msec, true ); // 1 minute
1435 qDebug("KO: Saving File in %d secs!", msec/1000); 1435 qDebug("KO: Saving File in %d secs!", msec/1000);
1436 mCalendarModifiedFlag = true; 1436 mCalendarModifiedFlag = true;
1437} 1437}
1438void MainWindow::save() 1438void MainWindow::save()
1439{ 1439{
1440 if ( mSyncManager->blockSave() ) 1440 if ( mSyncManager->blockSave() )
1441 return; 1441 return;
1442 mSyncManager->setBlockSave(true); 1442 mSyncManager->setBlockSave(true);
1443 if ( mView->checkFileVersion( defaultFileName()) ) { 1443 if ( mView->checkFileVersion( defaultFileName()) ) {
1444 1444
1445 QTime neededSaveTime = QDateTime::currentDateTime().time(); 1445 QTime neededSaveTime = QDateTime::currentDateTime().time();
1446 setCaption(i18n("KO/Pi:Saving Data to File ..." )); 1446 setCaption(i18n("KO/Pi:Saving Data to File ..." ));
1447 qDebug("KO: Start saving data to file!"); 1447 qDebug("KO: Start saving data to file!");
1448 mView->saveCalendar( defaultFileName() ); 1448 mView->saveCalendar( defaultFileName() );
1449 1449
1450 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 1450 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
1451 qDebug("KO: Needed %d ms for saving.",msNeeded ); 1451 qDebug("KO: Needed %d ms for saving.",msNeeded );
1452 QString savemes; 1452 QString savemes;
1453 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 ); 1453 savemes.sprintf(i18n("KO/Pi:File Saved. Needed %d sec, %d ms"),(msNeeded/1000)%100,msNeeded%1000 );
1454 setCaption(savemes); 1454 setCaption(savemes);
1455 } else 1455 } else
1456 setCaption(i18n("Saving cancelled!")); 1456 setCaption(i18n("Saving cancelled!"));
1457 mCalendarModifiedFlag = false; 1457 mCalendarModifiedFlag = false;
1458 mSyncManager->setBlockSave( false ); 1458 mSyncManager->setBlockSave( false );
1459} 1459}
1460 1460
1461void MainWindow::keyReleaseEvent ( QKeyEvent * e) 1461void MainWindow::keyReleaseEvent ( QKeyEvent * e)
1462{ 1462{
1463 if ( !e->isAutoRepeat() ) { 1463 if ( !e->isAutoRepeat() ) {
1464 mFlagKeyPressed = false; 1464 mFlagKeyPressed = false;
1465 } 1465 }
1466} 1466}
1467void MainWindow::keyPressEvent ( QKeyEvent * e ) 1467void MainWindow::keyPressEvent ( QKeyEvent * e )
1468{ 1468{
1469 qApp->processEvents(); 1469 qApp->processEvents();
1470 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 1470 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
1471 e->ignore(); 1471 e->ignore();
1472 // qDebug(" ignore %d",e->isAutoRepeat() ); 1472 // qDebug(" ignore %d",e->isAutoRepeat() );
1473 return; 1473 return;
1474 } 1474 }
1475 if (! e->isAutoRepeat() ) 1475 if (! e->isAutoRepeat() )
1476 mFlagKeyPressed = true; 1476 mFlagKeyPressed = true;
1477 KOPrefs *p = KOPrefs::instance(); 1477 KOPrefs *p = KOPrefs::instance();
1478 bool showSelectedDates = false; 1478 bool showSelectedDates = false;
1479 int size; 1479 int size;
1480 int pro = 0; 1480 int pro = 0;
1481 //qDebug("MainWindow::keyPressEvent "); 1481 //qDebug("MainWindow::keyPressEvent ");
1482 switch ( e->key() ) { 1482 switch ( e->key() ) {
1483 case Qt::Key_Right: 1483 case Qt::Key_Right:
1484 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1484 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1485 mView->goNextMonth(); 1485 mView->goNextMonth();
1486 else 1486 else
1487 mView->goNext(); 1487 mView->goNext();
1488 showSelectedDates = true; 1488 showSelectedDates = true;
1489 break; 1489 break;
1490 case Qt::Key_Left: 1490 case Qt::Key_Left:
1491 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1491 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1492 mView->goPreviousMonth(); 1492 mView->goPreviousMonth();
1493 else 1493 else
1494 mView->goPrevious(); 1494 mView->goPrevious();
1495 showSelectedDates = true; 1495 showSelectedDates = true;
1496 break; 1496 break;
1497 case Qt::Key_Down: 1497 case Qt::Key_Down:
1498 mView->viewManager()->agendaView()->scrollOneHourDown(); 1498 mView->viewManager()->agendaView()->scrollOneHourDown();
1499 break; 1499 break;
1500 case Qt::Key_Up: 1500 case Qt::Key_Up:
1501 mView->viewManager()->agendaView()->scrollOneHourUp(); 1501 mView->viewManager()->agendaView()->scrollOneHourUp();
1502 break; 1502 break;
1503 case Qt::Key_I: 1503 case Qt::Key_I:
1504 mView->showIncidence(); 1504 mView->showIncidence();
1505 break; 1505 break;
1506 case Qt::Key_Delete: 1506 case Qt::Key_Delete:
1507 case Qt::Key_Backspace: 1507 case Qt::Key_Backspace:
1508 mView->deleteIncidence(); 1508 mView->deleteIncidence();
1509 break; 1509 break;
1510 case Qt::Key_D: 1510 case Qt::Key_D:
1511 mView->viewManager()->showDayView(); 1511 mView->viewManager()->showDayView();
1512 showSelectedDates = true; 1512 showSelectedDates = true;
1513 break; 1513 break;
1514 case Qt::Key_O: 1514 case Qt::Key_O:
1515 mView->toggleFilerEnabled( ); 1515 mView->toggleFilerEnabled( );
1516 break; 1516 break;
1517 case Qt::Key_0: 1517 case Qt::Key_0:
1518 case Qt::Key_1: 1518 case Qt::Key_1:
1519 case Qt::Key_2: 1519 case Qt::Key_2:
1520 case Qt::Key_3: 1520 case Qt::Key_3:
1521 case Qt::Key_4: 1521 case Qt::Key_4:
1522 case Qt::Key_5: 1522 case Qt::Key_5:
1523 case Qt::Key_6: 1523 case Qt::Key_6:
1524 case Qt::Key_7: 1524 case Qt::Key_7:
1525 case Qt::Key_8: 1525 case Qt::Key_8:
1526 case Qt::Key_9: 1526 case Qt::Key_9:
1527 pro = e->key()-48; 1527 pro = e->key()-48;
1528 if ( pro == 0 ) 1528 if ( pro == 0 )
1529 pro = 10; 1529 pro = 10;
1530 if ( e->state() == Qt::ControlButton) 1530 if ( e->state() == Qt::ControlButton)
1531 pro += 10; 1531 pro += 10;
1532 break; 1532 break;
1533 case Qt::Key_M: 1533 case Qt::Key_M:
1534 mView->viewManager()->showMonthView(); 1534 mView->viewManager()->showMonthView();
1535 showSelectedDates = true; 1535 showSelectedDates = true;
1536 break; 1536 break;
1537 case Qt::Key_Insert: 1537 case Qt::Key_Insert:
1538 mView->newEvent(); 1538 mView->newEvent();
1539 break; 1539 break;
1540 case Qt::Key_S : 1540 case Qt::Key_S :
1541 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton) 1541 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton)
1542 mView->newSubTodo(); 1542 mView->newSubTodo();
1543 else 1543 else
1544 mView->dialogManager()->showSearchDialog(); 1544 mView->dialogManager()->showSearchDialog();
1545 break; 1545 break;
1546 case Qt::Key_Y : 1546 case Qt::Key_Y :
1547 case Qt::Key_Z : 1547 case Qt::Key_Z :
1548 mView->viewManager()->showWorkWeekView(); 1548 mView->viewManager()->showWorkWeekView();
1549 showSelectedDates = true; 1549 showSelectedDates = true;
1550 break; 1550 break;
1551 case Qt::Key_U : 1551 case Qt::Key_U :
1552 mView->viewManager()->showWeekView(); 1552 mView->viewManager()->showWeekView();
1553 showSelectedDates = true; 1553 showSelectedDates = true;
1554 break; 1554 break;
1555 case Qt::Key_H : 1555 case Qt::Key_H :
1556 keyBindings(); 1556 keyBindings();
1557 break; 1557 break;
1558 case Qt::Key_W: 1558 case Qt::Key_W:
1559 mView->viewManager()->showWhatsNextView(); 1559 mView->viewManager()->showWhatsNextView();
1560 break; 1560 break;
1561 case Qt::Key_L: 1561 case Qt::Key_L:
1562 mView->viewManager()->showListView(); 1562 mView->viewManager()->showListView();
1563 break; 1563 break;
1564 case Qt::Key_N: 1564 case Qt::Key_N:
1565 mView->viewManager()->showNextXView(); 1565 mView->viewManager()->showNextXView();
1566 showSelectedDates = true; 1566 showSelectedDates = true;
1567 break; 1567 break;
1568 case Qt::Key_V: 1568 case Qt::Key_V:
1569 mView->viewManager()->showTodoView(); 1569 mView->viewManager()->showTodoView();
1570 break; 1570 break;
1571 case Qt::Key_C: 1571 case Qt::Key_C:
1572 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() ); 1572 mView->viewManager()->agendaView()->setStartHour( QTime::currentTime ().hour() );
1573 break; 1573 break;
1574 case Qt::Key_P: 1574 case Qt::Key_P:
1575 mView->showDatePicker( ); 1575 mView->showDatePicker( );
1576 break; 1576 break;
1577 case Qt::Key_F: 1577 case Qt::Key_F:
1578 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1578 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1579 mView->editFilters(); 1579 mView->editFilters();
1580 else 1580 else
1581 mView->toggleFilter(); 1581 mView->toggleFilter();
1582 break; 1582 break;
1583 case Qt::Key_X: 1583 case Qt::Key_X:
1584 mView->toggleDateNavigatorWidget(); 1584 mView->toggleDateNavigatorWidget();
1585 break; 1585 break;
1586 case Qt::Key_Space: 1586 case Qt::Key_Space:
1587 mView->toggleExpand(); 1587 mView->toggleExpand();
1588 break; 1588 break;
1589 case Qt::Key_A: 1589 case Qt::Key_A:
1590 mView->toggleAllDaySize(); 1590 mView->toggleAllDaySize();
1591 break; 1591 break;
1592 case Qt::Key_T: 1592 case Qt::Key_T:
1593 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1593 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1594 mView->newTodo(); 1594 mView->newTodo();
1595 else { 1595 else {
1596 mView->goToday(); 1596 mView->goToday();
1597 showSelectedDates = true; 1597 showSelectedDates = true;
1598 } 1598 }
1599 break; 1599 break;
1600 case Qt::Key_J: 1600 case Qt::Key_J:
1601 mView->viewManager()->showJournalView(); 1601 mView->viewManager()->showJournalView();
1602 break; 1602 break;
1603 case Qt::Key_B: 1603 case Qt::Key_B:
1604 mView->editIncidenceDescription();; 1604 mView->editIncidenceDescription();;
1605 break; 1605 break;
1606 // case Qt::Key_Return: 1606 // case Qt::Key_Return:
1607 case Qt::Key_E: 1607 case Qt::Key_E:
1608 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) 1608 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
1609 mView->newEvent(); 1609 mView->newEvent();
1610 else 1610 else
1611 mView->editIncidence(); 1611 mView->editIncidence();
1612 break; 1612 break;
1613 case Qt::Key_Plus: 1613 case Qt::Key_Plus:
1614 size = p->mHourSize +2; 1614 size = p->mHourSize +2;
1615 if ( size <= 18 ) 1615 if ( size <= 18 )
1616 configureAgenda( size ); 1616 configureAgenda( size );
1617 break; 1617 break;
1618 case Qt::Key_Minus: 1618 case Qt::Key_Minus:
1619 size = p->mHourSize - 2; 1619 size = p->mHourSize - 2;
1620 if ( size >= 4 ) 1620 if ( size >= 4 )
1621 configureAgenda( size ); 1621 configureAgenda( size );
1622 break; 1622 break;
1623 1623
1624 1624
1625 default: 1625 default:
1626 e->ignore(); 1626 e->ignore();
1627 } 1627 }
1628 if ( pro > 0 ) { 1628 if ( pro > 0 ) {
1629 mView->selectFilter( pro-1 ); 1629 mView->selectFilter( pro-1 );
1630 } 1630 }
1631 if ( showSelectedDates ) { 1631 if ( showSelectedDates ) {
1632 ;// setCaptionToDates(); 1632 ;// setCaptionToDates();
1633 } 1633 }
1634 1634
1635} 1635}
1636 1636
1637void MainWindow::fillFilterMenu() 1637void MainWindow::fillFilterMenu()
1638{ 1638{
1639 selectFilterMenu->clear(); 1639 selectFilterMenu->clear();
1640 bool disable = false; 1640 bool disable = false;
1641 selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 ); 1641 selectFilterMenu->insertItem(i18n ( "Edit Filters" ), 0 );
1642 selectFilterMenu->insertSeparator(); 1642 selectFilterMenu->insertSeparator();
1643 if ( mView->filterView()->filtersEnabled() ) { 1643 if ( mView->filterView()->filtersEnabled() ) {
1644 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 1 ); 1644 selectFilterMenu->insertItem(i18n ( "Turn filter off" ), 1 );
1645 } 1645 }
1646 else { 1646 else {
1647 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 1 ); 1647 selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 1 );
1648 disable = true; 1648 disable = true;
1649 } 1649 }
1650 selectFilterMenu->insertSeparator(); 1650 selectFilterMenu->insertSeparator();
1651 QPtrList<CalFilter> fili = mView->filters(); 1651 QPtrList<CalFilter> fili = mView->filters();
1652 CalFilter *curfilter = mView->filterView()->selectedFilter(); 1652 CalFilter *curfilter = mView->filterView()->selectedFilter();
1653 CalFilter *filter = fili.first(); 1653 CalFilter *filter = fili.first();
1654 int iii = 2; 1654 int iii = 2;
1655 while(filter) { 1655 while(filter) {
1656 selectFilterMenu->insertItem( filter->name(), iii ); 1656 selectFilterMenu->insertItem( filter->name(), iii );
1657 if ( filter == curfilter) 1657 if ( filter == curfilter)
1658 selectFilterMenu->setItemChecked( iii, true ); 1658 selectFilterMenu->setItemChecked( iii, true );
1659 if ( disable ) 1659 if ( disable )
1660 selectFilterMenu->setItemEnabled( iii, false ); 1660 selectFilterMenu->setItemEnabled( iii, false );
1661 filter = fili.next(); 1661 filter = fili.next();
1662 ++iii; 1662 ++iii;
1663 } 1663 }
1664} 1664}
1665void MainWindow::selectFilter( int fil ) 1665void MainWindow::selectFilter( int fil )
1666{ 1666{
1667 if ( fil == 0 ) { 1667 if ( fil == 0 ) {
1668 mView->editFilters( ); 1668 mView->editFilters( );
1669 } else if ( fil == 1 ){ 1669 } else if ( fil == 1 ){
1670 mView->toggleFilerEnabled( ); 1670 mView->toggleFilerEnabled( );
1671 } else { 1671 } else {
1672 mView->selectFilter( fil-2 ); 1672 mView->selectFilter( fil-2 );
1673 } 1673 }
1674} 1674}
1675void MainWindow::configureToolBar( int item ) 1675void MainWindow::configureToolBar( int item )
1676{ 1676{
1677 1677
1678 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); 1678 configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) );
1679 KOPrefs *p = KOPrefs::instance(); 1679 KOPrefs *p = KOPrefs::instance();
1680 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); 1680 p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 );
1681 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); 1681 p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 );
1682 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); 1682 p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 );
1683 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); 1683 p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 );
1684 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); 1684 p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 );
1685 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); 1685 p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 );
1686 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); 1686 p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 );
1687 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); 1687 p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 );
1688 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); 1688 p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 );
1689 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); 1689 p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 );
1690 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); 1690 p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 );
1691 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); 1691 p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 );
1692 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); 1692 p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 );
1693 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); 1693 p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 );
1694 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); 1694 p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 );
1695 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); 1695 p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 );
1696 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); 1696 p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 );
1697 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); 1697 p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 );
1698 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); 1698 p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 );
1699 // initActions(); 1699 // initActions();
1700} 1700}
1701 1701
1702void MainWindow::setCaptionToDates() 1702void MainWindow::setCaptionToDates()
1703{ 1703{
1704 QString selDates; 1704 QString selDates;
1705 selDates = KGlobal::locale()->formatDate(mView->startDate(), true); 1705 selDates = KGlobal::locale()->formatDate(mView->startDate(), true);
1706 if (mView->startDate() < mView->endDate() ) 1706 if (mView->startDate() < mView->endDate() )
1707 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); 1707 selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true);
1708 else {
1709 QString addString;
1710 if ( mView->startDate() == QDateTime::currentDateTime().date() )
1711 addString = i18n("Today");
1712 else if ( mView->startDate() == QDateTime::currentDateTime().date().addDays(1) )
1713 addString = i18n("Tomorrow");
1714 if ( !addString.isEmpty() )
1715 selDates = addString+", "+selDates ;
1716 }
1708 setCaption( i18n("Dates: ") + selDates ); 1717 setCaption( i18n("Dates: ") + selDates );
1709 1718
1710} 1719}
1711// parameter item == 0: reinit 1720// parameter item == 0: reinit
1712void MainWindow::configureAgenda( int item ) 1721void MainWindow::configureAgenda( int item )
1713{ 1722{
1714 1723
1715 KOPrefs *p = KOPrefs::instance(); 1724 KOPrefs *p = KOPrefs::instance();
1716 1725
1717 int i; 1726 int i;
1718 // do not allow 4 for widgets higher than 480 1727 // do not allow 4 for widgets higher than 480
1719 // if ( QApplication::desktop()->height() > 480 ) { 1728 // if ( QApplication::desktop()->height() > 480 ) {
1720// if ( item == 4 ) 1729// if ( item == 4 )
1721// item = 6; 1730// item = 6;
1722// } 1731// }
1723 for ( i = 4; i <= 18; i= i+2 ) 1732 for ( i = 4; i <= 18; i= i+2 )
1724 configureAgendaMenu->setItemChecked( i, false ); 1733 configureAgendaMenu->setItemChecked( i, false );
1725 configureAgendaMenu->setItemChecked( item, true ); 1734 configureAgendaMenu->setItemChecked( item, true );
1726 if ( p->mHourSize == item ) 1735 if ( p->mHourSize == item )
1727 return; 1736 return;
1728 p->mHourSize=item; 1737 p->mHourSize=item;
1729 mView->viewManager()->agendaView()->updateConfig(); 1738 mView->viewManager()->agendaView()->updateConfig();
1730} 1739}
1731 1740
1732void MainWindow::saveCalendar() 1741void MainWindow::saveCalendar()
1733{ 1742{
1734 QString fn = KOPrefs::instance()->mLastSaveFile; 1743 QString fn = KOPrefs::instance()->mLastSaveFile;
1735 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); 1744 fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this );
1736 1745
1737 if ( fn == "" ) 1746 if ( fn == "" )
1738 return; 1747 return;
1739 QFileInfo info; 1748 QFileInfo info;
1740 info.setFile( fn ); 1749 info.setFile( fn );
1741 QString mes; 1750 QString mes;
1742 bool createbup = true; 1751 bool createbup = true;
1743 if ( info. exists() ) { 1752 if ( info. exists() ) {
1744 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; 1753 mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ;
1745 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1754 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1746 i18n("Overwrite!"), i18n("Cancel"), 0, 1755 i18n("Overwrite!"), i18n("Cancel"), 0,
1747 0, 1 ); 1756 0, 1 );
1748 if ( result != 0 ) { 1757 if ( result != 0 ) {
1749 createbup = false; 1758 createbup = false;
1750 } 1759 }
1751 } 1760 }
1752 if ( createbup ) { 1761 if ( createbup ) {
1753 mView->saveCalendar( fn ); 1762 mView->saveCalendar( fn );
1754 mes = i18n("KO/Pi:Saved %1").arg(fn); 1763 mes = i18n("KO/Pi:Saved %1").arg(fn);
1755 KOPrefs::instance()->mLastSaveFile = fn; 1764 KOPrefs::instance()->mLastSaveFile = fn;
1756 setCaption(mes); 1765 setCaption(mes);
1757 } 1766 }
1758} 1767}
1759void MainWindow::loadCalendar() 1768void MainWindow::loadCalendar()
1760{ 1769{
1761 1770
1762 QString fn = KOPrefs::instance()->mLastLoadFile; 1771 QString fn = KOPrefs::instance()->mLastLoadFile;
1763 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); 1772 fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this );
1764 1773
1765 if ( fn == "" ) 1774 if ( fn == "" )
1766 return; 1775 return;
1767 QFileInfo info; 1776 QFileInfo info;
1768 info.setFile( fn ); 1777 info.setFile( fn );
1769 QString mess; 1778 QString mess;
1770 bool loadbup = true; 1779 bool loadbup = true;
1771 if ( info. exists() ) { 1780 if ( info. exists() ) {
1772 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); 1781 mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false ));
1773 int result = QMessageBox::warning( this, "KO/Pi: Warning!", 1782 int result = QMessageBox::warning( this, "KO/Pi: Warning!",
1774 mess, 1783 mess,
1775 i18n("Load!"), i18n("Cancel"), 0, 1784 i18n("Load!"), i18n("Cancel"), 0,
1776 0, 1 ); 1785 0, 1 );
1777 if ( result != 0 ) { 1786 if ( result != 0 ) {
1778 loadbup = false; 1787 loadbup = false;
1779 } 1788 }
1780 } else { 1789 } else {
1781 QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1790 QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1782 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, 1791 i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0,
1783 0, 1 ); 1792 0, 1 );
1784 1793
1785 return; 1794 return;
1786 } 1795 }
1787 if ( loadbup ) { 1796 if ( loadbup ) {
1788 mView->openCalendar( fn ); 1797 mView->openCalendar( fn );
1789 KOPrefs::instance()->mLastLoadFile = fn; 1798 KOPrefs::instance()->mLastLoadFile = fn;
1790 mess = i18n("KO/Pi:Loaded %1").arg(fn) ; 1799 mess = i18n("KO/Pi:Loaded %1").arg(fn) ;
1791 setCaption(mess); 1800 setCaption(mess);
1792 } 1801 }
1793 1802
1794} 1803}
1795void MainWindow::quickImportIcal() 1804void MainWindow::quickImportIcal()
1796{ 1805{
1797 importFile( KOPrefs::instance()->mLastImportFile, false ); 1806 importFile( KOPrefs::instance()->mLastImportFile, false );
1798} 1807}
1799void MainWindow::importFile( QString fn, bool quick ) 1808void MainWindow::importFile( QString fn, bool quick )
1800{ 1809{
1801 QFileInfo info; 1810 QFileInfo info;
1802 info.setFile( fn ); 1811 info.setFile( fn );
1803 QString mess; 1812 QString mess;
1804 bool loadbup = true; 1813 bool loadbup = true;
1805 if ( !info. exists() ) { 1814 if ( !info. exists() ) {
1806 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); 1815 mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30));
1807 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), 1816 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),
1808 mess ); 1817 mess );
1809 return; 1818 return;
1810 } 1819 }
1811 int result = 0; 1820 int result = 0;
1812 if ( !quick ) { 1821 if ( !quick ) {
1813 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 )); 1822 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 ));
1814 result = QMessageBox::warning( this, "KO/Pi: Warning!", 1823 result = QMessageBox::warning( this, "KO/Pi: Warning!",
1815 mess, 1824 mess,
1816 "Import", "Cancel", 0, 1825 "Import", "Cancel", 0,
1817 0, 1 ); 1826 0, 1 );
1818 } 1827 }
1819 if ( result == 0 ) { 1828 if ( result == 0 ) {
1820 if ( mView->openCalendar( fn, true )) { 1829 if ( mView->openCalendar( fn, true )) {
1821 KOPrefs::instance()->mLastImportFile = fn; 1830 KOPrefs::instance()->mLastImportFile = fn;
1822 setCaption(i18n("Imported file successfully")); 1831 setCaption(i18n("Imported file successfully"));
1823 } else { 1832 } else {
1824 setCaption(i18n("Error importing file")); 1833 setCaption(i18n("Error importing file"));
1825 } 1834 }
1826 } 1835 }
1827} 1836}
1828 1837
1829void MainWindow::importIcal() 1838void MainWindow::importIcal()
1830{ 1839{
1831 1840
1832 QString fn =KOPrefs::instance()->mLastImportFile; 1841 QString fn =KOPrefs::instance()->mLastImportFile;
1833 1842
1834 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); 1843 fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this );
1835 if ( fn == "" ) 1844 if ( fn == "" )
1836 return; 1845 return;
1837 importFile( fn, true ); 1846 importFile( fn, true );
1838 1847
1839} 1848}
1840 1849
1841void MainWindow::exportVCalendar() 1850void MainWindow::exportVCalendar()
1842{ 1851{
1843 QString fn = KOPrefs::instance()->mLastVcalFile; 1852 QString fn = KOPrefs::instance()->mLastVcalFile;
1844 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); 1853 fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this );
1845 if ( fn == "" ) 1854 if ( fn == "" )
1846 return; 1855 return;
1847 QFileInfo info; 1856 QFileInfo info;
1848 info.setFile( fn ); 1857 info.setFile( fn );
1849 QString mes; 1858 QString mes;
1850 bool createbup = true; 1859 bool createbup = true;
1851 if ( info. exists() ) { 1860 if ( info. exists() ) {
1852 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 1861 mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
1853 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 1862 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
1854 i18n("Overwrite!"), i18n("Cancel"), 0, 1863 i18n("Overwrite!"), i18n("Cancel"), 0,
1855 0, 1 ); 1864 0, 1 );
1856 if ( result != 0 ) { 1865 if ( result != 0 ) {
1857 createbup = false; 1866 createbup = false;
1858 } 1867 }
1859 } 1868 }
1860 if ( createbup ) { 1869 if ( createbup ) {
1861 if ( mView->exportVCalendar( fn ) ) { 1870 if ( mView->exportVCalendar( fn ) ) {
1862 KOPrefs::instance()->mLastVcalFile = fn; 1871 KOPrefs::instance()->mLastVcalFile = fn;
1863 if ( fn.length() > 20 ) 1872 if ( fn.length() > 20 )
1864 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; 1873 mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ;
1865 else 1874 else
1866 mes = i18n("KO/Pi:Exported to %1").arg(fn ); 1875 mes = i18n("KO/Pi:Exported to %1").arg(fn );
1867 setCaption(mes); 1876 setCaption(mes);
1868 } 1877 }
1869 } 1878 }
1870 1879
1871} 1880}
1872 1881
1873void MainWindow::syncFileRequest() 1882void MainWindow::syncFileRequest()
1874{ 1883{
1875 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { 1884 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) {
1876 mSyncManager->slotSyncMenu( 999 ); 1885 mSyncManager->slotSyncMenu( 999 );
1877 } 1886 }
1878 save(); 1887 save();
1879} 1888}
1880void MainWindow::getFile( bool success ) 1889void MainWindow::getFile( bool success )
1881{ 1890{
1882 if ( ! success ) { 1891 if ( ! success ) {
1883 setCaption( i18n("Error receiving file. Nothing changed!") ); 1892 setCaption( i18n("Error receiving file. Nothing changed!") );
1884 return; 1893 return;
1885 } 1894 }
1886 mView->openCalendar( defaultFileName() ); 1895 mView->openCalendar( defaultFileName() );
1887 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { 1896 if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) {
1888 mSyncManager->slotSyncMenu( 999 ); 1897 mSyncManager->slotSyncMenu( 999 );
1889 } 1898 }
1890 setCaption( i18n("Pi-Sync successful!") ); 1899 setCaption( i18n("Pi-Sync successful!") );
1891} 1900}
1892 1901
1893void MainWindow::printSel( ) 1902void MainWindow::printSel( )
1894{ 1903{
1895 mView->viewManager()->agendaView()->agenda()->printSelection(); 1904 mView->viewManager()->agendaView()->agenda()->printSelection();
1896} 1905}
1897 1906
1898void MainWindow::printCal() 1907void MainWindow::printCal()
1899{ 1908{
1900 mView->print();//mCp->showDialog(); 1909 mView->print();//mCp->showDialog();
1901} 1910}
1902 1911