summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-07-03 16:49:55 (UTC)
committer zautrix <zautrix>2004-07-03 16:49:55 (UTC)
commit1da48d95d970233f0d1ea9a7fba5c98cfcf24798 (patch) (unidiff)
treeae690b33cbe50291a610842e24de33f9d766f2f2
parente3b89230f065c48c84b48c88edb6eb088374c487 (diff)
downloadkdepimpi-1da48d95d970233f0d1ea9a7fba5c98cfcf24798.zip
kdepimpi-1da48d95d970233f0d1ea9a7fba5c98cfcf24798.tar.gz
kdepimpi-1da48d95d970233f0d1ea9a7fba5c98cfcf24798.tar.bz2
Alarm Bugfix. Added connection to KM. Cleaned up main.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp31
-rw-r--r--korganizer/calendarview.h4
-rw-r--r--korganizer/koeventviewer.cpp80
-rw-r--r--korganizer/koeventviewer.h1
-rw-r--r--korganizer/main.cpp32
5 files changed, 93 insertions, 55 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index bf98ad4..c3c3d47 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,1636 +1,1661 @@
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 "kosyncprefsdialog.h" 61#include "kosyncprefsdialog.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 66
67#include <libkcal/vcaldrag.h> 67#include <libkcal/vcaldrag.h>
68#include <libkcal/icaldrag.h> 68#include <libkcal/icaldrag.h>
69#include <libkcal/icalformat.h> 69#include <libkcal/icalformat.h>
70#include <libkcal/vcalformat.h> 70#include <libkcal/vcalformat.h>
71#include <libkcal/scheduler.h> 71#include <libkcal/scheduler.h>
72#include <libkcal/calendarlocal.h> 72#include <libkcal/calendarlocal.h>
73#include <libkcal/journal.h> 73#include <libkcal/journal.h>
74#include <libkcal/calfilter.h> 74#include <libkcal/calfilter.h>
75#include <libkcal/attendee.h> 75#include <libkcal/attendee.h>
76#include <libkcal/dndfactory.h> 76#include <libkcal/dndfactory.h>
77#include <libkcal/freebusy.h> 77#include <libkcal/freebusy.h>
78#include <libkcal/filestorage.h> 78#include <libkcal/filestorage.h>
79#include <libkcal/calendarresources.h> 79#include <libkcal/calendarresources.h>
80#include <libkcal/qtopiaformat.h> 80#include <libkcal/qtopiaformat.h>
81#include "../kalarmd/alarmdialog.h" 81#include "../kalarmd/alarmdialog.h"
82 82
83#ifndef DESKTOP_VERSION 83#ifndef DESKTOP_VERSION
84#include <libkcal/sharpformat.h> 84#include <libkcal/sharpformat.h>
85#endif 85#endif
86#ifndef KORG_NOMAIL 86#ifndef KORG_NOMAIL
87#include "komailclient.h" 87#include "komailclient.h"
88#endif 88#endif
89#ifndef KORG_NOPRINTER 89#ifndef KORG_NOPRINTER
90#include "calprinter.h" 90#include "calprinter.h"
91#endif 91#endif
92#ifndef KORG_NOPLUGINS 92#ifndef KORG_NOPLUGINS
93#include "kocore.h" 93#include "kocore.h"
94#endif 94#endif
95#include "koeventeditor.h" 95#include "koeventeditor.h"
96#include "kotodoeditor.h" 96#include "kotodoeditor.h"
97#include "koprefs.h" 97#include "koprefs.h"
98#include "koeventviewerdialog.h" 98#include "koeventviewerdialog.h"
99#include "publishdialog.h" 99#include "publishdialog.h"
100#include "kofilterview.h" 100#include "kofilterview.h"
101#include "koglobals.h" 101#include "koglobals.h"
102#include "koviewmanager.h" 102#include "koviewmanager.h"
103#include "koagendaview.h" 103#include "koagendaview.h"
104#include "kodialogmanager.h" 104#include "kodialogmanager.h"
105#include "outgoingdialog.h" 105#include "outgoingdialog.h"
106#include "incomingdialog.h" 106#include "incomingdialog.h"
107#include "statusdialog.h" 107#include "statusdialog.h"
108#include "kdatenavigator.h" 108#include "kdatenavigator.h"
109#include "kotodoview.h" 109#include "kotodoview.h"
110#include "datenavigator.h" 110#include "datenavigator.h"
111#include "resourceview.h" 111#include "resourceview.h"
112#include "navigatorbar.h" 112#include "navigatorbar.h"
113#include "searchdialog.h" 113#include "searchdialog.h"
114#include "mainwindow.h" 114#include "mainwindow.h"
115 115
116#include "calendarview.h" 116#include "calendarview.h"
117#ifndef DESKTOP_VERSION 117#ifndef DESKTOP_VERSION
118#include <qtopia/alarmserver.h> 118#include <qtopia/alarmserver.h>
119#endif 119#endif
120#ifndef _WIN32_ 120#ifndef _WIN32_
121#include <stdlib.h> 121#include <stdlib.h>
122#include <stdio.h> 122#include <stdio.h>
123#include <unistd.h> 123#include <unistd.h>
124#else 124#else
125#include <qprocess.h> 125#include <qprocess.h>
126#endif 126#endif
127using namespace KOrg; 127using namespace KOrg;
128using namespace KCal; 128using namespace KCal;
129extern int globalFlagBlockAgenda; 129extern int globalFlagBlockAgenda;
130extern int globalFlagBlockStartup; 130extern int globalFlagBlockStartup;
131 131
132#define SYNC_MODE_NORMAL 0 132#define SYNC_MODE_NORMAL 0
133#define SYNC_MODE_SHARP 1 133#define SYNC_MODE_SHARP 1
134#define SYNC_MODE_QTOPIA 2 134#define SYNC_MODE_QTOPIA 2
135 135
136class KOBeamPrefs : public QDialog 136class KOBeamPrefs : public QDialog
137{ 137{
138 public: 138 public:
139 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : 139 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) :
140 QDialog( parent, name, true ) 140 QDialog( parent, name, true )
141 { 141 {
142 setCaption( i18n("Beam Options") ); 142 setCaption( i18n("Beam Options") );
143 QVBoxLayout* lay = new QVBoxLayout( this ); 143 QVBoxLayout* lay = new QVBoxLayout( this );
144 lay->setSpacing( 3 ); 144 lay->setSpacing( 3 );
145 lay->setMargin( 3 ); 145 lay->setMargin( 3 );
146 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); 146 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this );
147 lay->addWidget( format ); 147 lay->addWidget( format );
148 format->setExclusive ( true ) ; 148 format->setExclusive ( true ) ;
149 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); 149 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this );
150 lay->addWidget( time ); time->setExclusive ( true ) ; 150 lay->addWidget( time ); time->setExclusive ( true ) ;
151 vcal = new QRadioButton(" vCalendar ", format ); 151 vcal = new QRadioButton(" vCalendar ", format );
152 ical = new QRadioButton(" iCalendar ", format ); 152 ical = new QRadioButton(" iCalendar ", format );
153 vcal->setChecked( true ); 153 vcal->setChecked( true );
154 tz = new QRadioButton(i18n(" With timezone "), time ); 154 tz = new QRadioButton(i18n(" With timezone "), time );
155 local = new QRadioButton(i18n(" Local time "), time ); 155 local = new QRadioButton(i18n(" Local time "), time );
156 tz->setChecked( true ); 156 tz->setChecked( true );
157 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); 157 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this );
158 lay->addWidget( ok ); 158 lay->addWidget( ok );
159 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 159 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
160 lay->addWidget( cancel ); 160 lay->addWidget( cancel );
161 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 161 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
162 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 162 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
163 resize( 200, 200 ); 163 resize( 200, 200 );
164 } 164 }
165 165
166 bool beamVcal() { return vcal->isChecked(); } 166 bool beamVcal() { return vcal->isChecked(); }
167 bool beamLocal() { return local->isChecked(); } 167 bool beamLocal() { return local->isChecked(); }
168private: 168private:
169 QRadioButton* vcal, *ical, *local, *tz; 169 QRadioButton* vcal, *ical, *local, *tz;
170}; 170};
171class KOCatPrefs : public QDialog 171class KOCatPrefs : public QDialog
172{ 172{
173 public: 173 public:
174 KOCatPrefs( QWidget *parent=0, const char *name=0 ) : 174 KOCatPrefs( QWidget *parent=0, const char *name=0 ) :
175 QDialog( parent, name, true ) 175 QDialog( parent, name, true )
176 { 176 {
177 setCaption( i18n("Manage new Categories") ); 177 setCaption( i18n("Manage new Categories") );
178 QVBoxLayout* lay = new QVBoxLayout( this ); 178 QVBoxLayout* lay = new QVBoxLayout( this );
179 lay->setSpacing( 3 ); 179 lay->setSpacing( 3 );
180 lay->setMargin( 3 ); 180 lay->setMargin( 3 );
181 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 ); 181 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 );
182 lay->addWidget( lab ); 182 lay->addWidget( lab );
183 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 183 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
184 lay->addWidget( format ); 184 lay->addWidget( format );
185 format->setExclusive ( true ) ; 185 format->setExclusive ( true ) ;
186 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 186 addCatBut = new QRadioButton(i18n("Add to category list"), format );
187 new QRadioButton(i18n("Remove from Events/Todos"), format ); 187 new QRadioButton(i18n("Remove from Events/Todos"), format );
188 addCatBut->setChecked( true ); 188 addCatBut->setChecked( true );
189 QPushButton * ok = new QPushButton( i18n("OK"), this ); 189 QPushButton * ok = new QPushButton( i18n("OK"), this );
190 lay->addWidget( ok ); 190 lay->addWidget( ok );
191 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 191 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
192 lay->addWidget( cancel ); 192 lay->addWidget( cancel );
193 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 193 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
194 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 194 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
195 resize( 200, 200 ); 195 resize( 200, 200 );
196 } 196 }
197 197
198 bool addCat() { return addCatBut->isChecked(); } 198 bool addCat() { return addCatBut->isChecked(); }
199private: 199private:
200 QRadioButton* addCatBut; 200 QRadioButton* addCatBut;
201}; 201};
202 202
203 203
204 204
205CalendarView::CalendarView( CalendarResources *calendar, 205CalendarView::CalendarView( CalendarResources *calendar,
206 QWidget *parent, const char *name ) 206 QWidget *parent, const char *name )
207 : CalendarViewBase( parent, name ), 207 : CalendarViewBase( parent, name ),
208 mCalendar( calendar ), 208 mCalendar( calendar ),
209 mResourceManager( calendar->resourceManager() ) 209 mResourceManager( calendar->resourceManager() )
210{ 210{
211 211
212 mEventEditor = 0; 212 mEventEditor = 0;
213 mTodoEditor = 0; 213 mTodoEditor = 0;
214 214
215 init(); 215 init();
216} 216}
217 217
218CalendarView::CalendarView( Calendar *calendar, 218CalendarView::CalendarView( Calendar *calendar,
219 QWidget *parent, const char *name ) 219 QWidget *parent, const char *name )
220 : CalendarViewBase( parent, name ), 220 : CalendarViewBase( parent, name ),
221 mCalendar( calendar ), 221 mCalendar( calendar ),
222 mResourceManager( 0 ) 222 mResourceManager( 0 )
223{ 223{
224 224
225 mEventEditor = 0; 225 mEventEditor = 0;
226 mTodoEditor = 0; 226 mTodoEditor = 0;
227 init();} 227 init();}
228 228
229void CalendarView::init() 229void CalendarView::init()
230{ 230{
231 beamDialog = new KOBeamPrefs(); 231 beamDialog = new KOBeamPrefs();
232 mDatePickerMode = 0; 232 mDatePickerMode = 0;
233 mCurrentSyncDevice = ""; 233 mCurrentSyncDevice = "";
234 writeLocale(); 234 writeLocale();
235 mViewManager = new KOViewManager( this ); 235 mViewManager = new KOViewManager( this );
236 mDialogManager = new KODialogManager( this ); 236 mDialogManager = new KODialogManager( this );
237 mEventViewerDialog = 0; 237 mEventViewerDialog = 0;
238 mModified = false; 238 mModified = false;
239 mReadOnly = false; 239 mReadOnly = false;
240 mSelectedIncidence = 0; 240 mSelectedIncidence = 0;
241 mSyncProfiles.setAutoDelete(true); 241 mSyncProfiles.setAutoDelete(true);
242 mCalPrinter = 0; 242 mCalPrinter = 0;
243 mFilters.setAutoDelete(true); 243 mFilters.setAutoDelete(true);
244 244
245 mCalendar->registerObserver( this ); 245 mCalendar->registerObserver( this );
246 // TODO: Make sure that view is updated, when calendar is changed. 246 // TODO: Make sure that view is updated, when calendar is changed.
247 247
248 mStorage = new FileStorage( mCalendar ); 248 mStorage = new FileStorage( mCalendar );
249 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 249 mNavigator = new DateNavigator( this, "datevav", mViewManager );
250 250
251 QBoxLayout *topLayout = (QBoxLayout*)layout(); 251 QBoxLayout *topLayout = (QBoxLayout*)layout();
252#ifndef KORG_NOSPLITTER 252#ifndef KORG_NOSPLITTER
253 // create the main layout frames. 253 // create the main layout frames.
254 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 254 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
255 topLayout->addWidget(mPanner); 255 topLayout->addWidget(mPanner);
256 256
257 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 257 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
258 "CalendarView::LeftFrame"); 258 "CalendarView::LeftFrame");
259 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 259 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
260 260
261 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE, 261 mDateNavigator = new KDateNavigator(mLeftSplitter, mCalendar, TRUE,
262 "CalendarView::DateNavigator", QDate::currentDate() ); 262 "CalendarView::DateNavigator", QDate::currentDate() );
263 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 263 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
264 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 264 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
265 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 265 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
266 266
267#ifdef KORG_NORESOURCEVIEW 267#ifdef KORG_NORESOURCEVIEW
268 mResourceView = 0; 268 mResourceView = 0;
269#else 269#else
270 if ( mResourceManager ) { 270 if ( mResourceManager ) {
271 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 271 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
272 mResourceView->updateView(); 272 mResourceView->updateView();
273 connect( mResourceView, SIGNAL( resourcesChanged() ), 273 connect( mResourceView, SIGNAL( resourcesChanged() ),
274 SLOT( updateView() ) ); 274 SLOT( updateView() ) );
275 } else { 275 } else {
276 mResourceView = 0; 276 mResourceView = 0;
277 } 277 }
278#endif 278#endif
279 QWidget *rightBox = new QWidget( mPanner ); 279 QWidget *rightBox = new QWidget( mPanner );
280 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 280 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
281 281
282 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 282 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
283 rightLayout->addWidget( mNavigatorBar ); 283 rightLayout->addWidget( mNavigatorBar );
284 284
285 mRightFrame = new QWidgetStack( rightBox ); 285 mRightFrame = new QWidgetStack( rightBox );
286 rightLayout->addWidget( mRightFrame, 1 ); 286 rightLayout->addWidget( mRightFrame, 1 );
287 287
288 mLeftFrame = mLeftSplitter; 288 mLeftFrame = mLeftSplitter;
289#else 289#else
290 QWidget *mainBox = new QWidget( this ); 290 QWidget *mainBox = new QWidget( this );
291 QWidget *leftFrame = new QWidget( mainBox ); 291 QWidget *leftFrame = new QWidget( mainBox );
292 292
293 QBoxLayout * mainBoxLayout; 293 QBoxLayout * mainBoxLayout;
294 QBoxLayout * leftFrameLayout; 294 QBoxLayout * leftFrameLayout;
295 if ( KOPrefs::instance()->mVerticalScreen ) { 295 if ( KOPrefs::instance()->mVerticalScreen ) {
296 mainBoxLayout = new QVBoxLayout(mainBox); 296 mainBoxLayout = new QVBoxLayout(mainBox);
297 leftFrameLayout = new QHBoxLayout(leftFrame ); 297 leftFrameLayout = new QHBoxLayout(leftFrame );
298 } else { 298 } else {
299 mainBoxLayout = new QHBoxLayout(mainBox); 299 mainBoxLayout = new QHBoxLayout(mainBox);
300 leftFrameLayout = new QVBoxLayout(leftFrame ); 300 leftFrameLayout = new QVBoxLayout(leftFrame );
301 } 301 }
302 topLayout->addWidget( mainBox ); 302 topLayout->addWidget( mainBox );
303 mainBoxLayout->addWidget (leftFrame); 303 mainBoxLayout->addWidget (leftFrame);
304 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE, 304 mDateNavigator = new KDateNavigator(leftFrame, mCalendar, TRUE,
305 "CalendarView::DateNavigator", QDate::currentDate()); 305 "CalendarView::DateNavigator", QDate::currentDate());
306 // mDateNavigator->blockSignals( true ); 306 // mDateNavigator->blockSignals( true );
307 leftFrameLayout->addWidget( mDateNavigator ); 307 leftFrameLayout->addWidget( mDateNavigator );
308 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView"); 308 mFilterView = new KOFilterView(&mFilters,leftFrame,"CalendarView::FilterView");
309 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolist"); 309 mTodoList = new KOTodoView(mCalendar, leftFrame, "todolist");
310 310
311 if ( QApplication::desktop()->width() < 480 ) { 311 if ( QApplication::desktop()->width() < 480 ) {
312 leftFrameLayout->addWidget(mFilterView); 312 leftFrameLayout->addWidget(mFilterView);
313 leftFrameLayout->addWidget(mTodoList, 2 ); 313 leftFrameLayout->addWidget(mTodoList, 2 );
314 314
315 } else { 315 } else {
316 leftFrameLayout->addWidget(mTodoList,2 ); 316 leftFrameLayout->addWidget(mTodoList,2 );
317 leftFrameLayout->addWidget(mFilterView ); 317 leftFrameLayout->addWidget(mFilterView );
318 } 318 }
319 mFilterView->hide(); 319 mFilterView->hide();
320 QWidget *rightBox = new QWidget( mainBox ); 320 QWidget *rightBox = new QWidget( mainBox );
321 mainBoxLayout->addWidget ( rightBox, 10 ); 321 mainBoxLayout->addWidget ( rightBox, 10 );
322 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 322 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
323 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" ); 323 mNavigatorBar = new NavigatorBar( QDate::currentDate(), rightBox, "useBigPixmaps" );
324 mRightFrame = new QWidgetStack( rightBox ); 324 mRightFrame = new QWidgetStack( rightBox );
325 rightLayout->addWidget( mNavigatorBar ); 325 rightLayout->addWidget( mNavigatorBar );
326 rightLayout->addWidget( mRightFrame, 10 ); 326 rightLayout->addWidget( mRightFrame, 10 );
327 327
328 mLeftFrame = leftFrame; 328 mLeftFrame = leftFrame;
329 if ( KOPrefs::instance()->mVerticalScreen ) { 329 if ( KOPrefs::instance()->mVerticalScreen ) {
330 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 330 mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
331 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 331 leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
332 } else { 332 } else {
333 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 333 mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
334 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 334 leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
335 } 335 }
336 336
337 //qDebug("Calendarview Size %d %d ", width(), height()); 337 //qDebug("Calendarview Size %d %d ", width(), height());
338#endif 338#endif
339 339
340 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 340 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
341 SLOT( showDates( const KCal::DateList & ) ) ); 341 SLOT( showDates( const KCal::DateList & ) ) );
342 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 342 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
343 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 343 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
344 344
345 connect( mNavigatorBar, SIGNAL( goPrevYear() ), 345 connect( mNavigatorBar, SIGNAL( goPrevYear() ),
346 mNavigator, SLOT( selectPreviousYear() ) ); 346 mNavigator, SLOT( selectPreviousYear() ) );
347 connect( mNavigatorBar, SIGNAL( goNextYear() ), 347 connect( mNavigatorBar, SIGNAL( goNextYear() ),
348 mNavigator, SLOT( selectNextYear() ) ); 348 mNavigator, SLOT( selectNextYear() ) );
349 connect( mNavigatorBar, SIGNAL( goPrevMonth() ), 349 connect( mNavigatorBar, SIGNAL( goPrevMonth() ),
350 mNavigator, SLOT( selectPreviousMonth() ) ); 350 mNavigator, SLOT( selectPreviousMonth() ) );
351 connect( mNavigatorBar, SIGNAL( goNextMonth() ), 351 connect( mNavigatorBar, SIGNAL( goNextMonth() ),
352 mNavigator, SLOT( selectNextMonth() ) ); 352 mNavigator, SLOT( selectNextMonth() ) );
353 353
354 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 354 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
355 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) ); 355 mNavigatorBar, SLOT( selectDates( const KCal::DateList & ) ) );
356 356
357 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 357 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
358 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 358 mNavigator, SLOT( selectWeek( const QDate & ) ) );
359 359
360 connect( mDateNavigator, SIGNAL( goPrevYear() ), 360 connect( mDateNavigator, SIGNAL( goPrevYear() ),
361 mNavigator, SLOT( selectPreviousYear() ) ); 361 mNavigator, SLOT( selectPreviousYear() ) );
362 connect( mDateNavigator, SIGNAL( goNextYear() ), 362 connect( mDateNavigator, SIGNAL( goNextYear() ),
363 mNavigator, SLOT( selectNextYear() ) ); 363 mNavigator, SLOT( selectNextYear() ) );
364 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 364 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
365 mNavigator, SLOT( selectPreviousMonth() ) ); 365 mNavigator, SLOT( selectPreviousMonth() ) );
366 connect( mDateNavigator, SIGNAL( goNextMonth() ), 366 connect( mDateNavigator, SIGNAL( goNextMonth() ),
367 mNavigator, SLOT( selectNextMonth() ) ); 367 mNavigator, SLOT( selectNextMonth() ) );
368 368
369 connect( mDateNavigator, SIGNAL( goPrevious() ), 369 connect( mDateNavigator, SIGNAL( goPrevious() ),
370 mNavigator, SLOT( selectPrevious() ) ); 370 mNavigator, SLOT( selectPrevious() ) );
371 connect( mDateNavigator, SIGNAL( goNext() ), 371 connect( mDateNavigator, SIGNAL( goNext() ),
372 mNavigator, SLOT( selectNext() ) ); 372 mNavigator, SLOT( selectNext() ) );
373 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 373 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
374 mNavigator, SLOT( slotMonthSelect( int ) ) ); 374 mNavigator, SLOT( slotMonthSelect( int ) ) );
375 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ), 375 connect( mNavigatorBar, SIGNAL( monthSelected ( int ) ),
376 mNavigator, SLOT( slotMonthSelect( int ) ) ); 376 mNavigator, SLOT( slotMonthSelect( int ) ) );
377 377
378 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 378 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
379 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 379 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
380 380
381 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ), 381 connect( mDateNavigator, SIGNAL( eventDropped( Event * ) ),
382 SLOT( eventAdded( Event *) ) ); 382 SLOT( eventAdded( Event *) ) );
383 383
384 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 384 connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
385 385
386 connect( this, SIGNAL( configChanged() ), 386 connect( this, SIGNAL( configChanged() ),
387 mDateNavigator, SLOT( updateConfig() ) ); 387 mDateNavigator, SLOT( updateConfig() ) );
388 388
389 connect( mTodoList, SIGNAL( newTodoSignal() ), 389 connect( mTodoList, SIGNAL( newTodoSignal() ),
390 SLOT( newTodo() ) ); 390 SLOT( newTodo() ) );
391 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 391 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
392 SLOT( newSubTodo( Todo * ) ) ); 392 SLOT( newSubTodo( Todo * ) ) );
393 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 393 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
394 SLOT( editTodo( Todo * ) ) ); 394 SLOT( editTodo( Todo * ) ) );
395 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 395 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
396 SLOT( showTodo( Todo *) ) ); 396 SLOT( showTodo( Todo *) ) );
397 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 397 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
398 SLOT( deleteTodo( Todo *) ) ); 398 SLOT( deleteTodo( Todo *) ) );
399 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 399 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
400 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 400 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
401 SLOT( purgeCompleted() ) ); 401 SLOT( purgeCompleted() ) );
402 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 402 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
403 SIGNAL( todoModified( Todo *, int ) ) ); 403 SIGNAL( todoModified( Todo *, int ) ) );
404 404
405 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 405 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
406 this, SLOT ( cloneIncidence( Incidence * ) ) ); 406 this, SLOT ( cloneIncidence( Incidence * ) ) );
407 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 407 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
408 this, SLOT (cancelIncidence( Incidence * ) ) ); 408 this, SLOT (cancelIncidence( Incidence * ) ) );
409 409
410 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 410 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
411 this, SLOT ( moveIncidence( Incidence * ) ) ); 411 this, SLOT ( moveIncidence( Incidence * ) ) );
412 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 412 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
413 this, SLOT ( beamIncidence( Incidence * ) ) ); 413 this, SLOT ( beamIncidence( Incidence * ) ) );
414 414
415 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 415 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
416 this, SLOT ( todo_unsub( Todo * ) ) ); 416 this, SLOT ( todo_unsub( Todo * ) ) );
417 417
418 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 418 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
419 SLOT( updateTodo( Todo *, int ) ) ); 419 SLOT( updateTodo( Todo *, int ) ) );
420 connect( this, SIGNAL( todoModified( Todo *, int )), this, 420 connect( this, SIGNAL( todoModified( Todo *, int )), this,
421 SLOT( changeTodoDisplay( Todo *, int ) ) ); 421 SLOT( changeTodoDisplay( Todo *, int ) ) );
422 422
423 423
424 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 424 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
425 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 425 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
426 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 426 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
427 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 427 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
428 428
429 429
430 430
431 431
432 432
433 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 433 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
434 SLOT(checkClipboard())); 434 SLOT(checkClipboard()));
435 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 435 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
436 SLOT( processTodoListSelection( Incidence * ) ) ); 436 SLOT( processTodoListSelection( Incidence * ) ) );
437 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 437 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
438 438
439 // kdDebug() << "CalendarView::CalendarView() done" << endl; 439 // kdDebug() << "CalendarView::CalendarView() done" << endl;
440 440
441 mDateFrame = new QVBox(0,0,WType_Popup); 441 mDateFrame = new QVBox(0,0,WType_Popup);
442 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 442 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
443 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 443 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
444 mDateFrame->setLineWidth(3); 444 mDateFrame->setLineWidth(3);
445 mDateFrame->hide(); 445 mDateFrame->hide();
446 mDateFrame->setCaption( i18n( "Pick a date to display")); 446 mDateFrame->setCaption( i18n( "Pick a date to display"));
447 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 447 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
448 448
449 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 449 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
450 450
451 mEventEditor = mDialogManager->getEventEditor(); 451 mEventEditor = mDialogManager->getEventEditor();
452 mTodoEditor = mDialogManager->getTodoEditor(); 452 mTodoEditor = mDialogManager->getTodoEditor();
453 453
454 mFlagEditDescription = false; 454 mFlagEditDescription = false;
455 455
456 mSuspendTimer = new QTimer( this ); 456 mSuspendTimer = new QTimer( this );
457 mAlarmTimer = new QTimer( this ); 457 mAlarmTimer = new QTimer( this );
458 mRecheckAlarmTimer = new QTimer( this );
459 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
458 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 460 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
459 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 461 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
460 mAlarmDialog = new AlarmDialog( this ); 462 mAlarmDialog = new AlarmDialog( this );
461 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 463 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
462 mAlarmDialog->setServerNotification( false ); 464 mAlarmDialog->setServerNotification( false );
463 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 465 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
464} 466}
465 467
466 468
467CalendarView::~CalendarView() 469CalendarView::~CalendarView()
468{ 470{
469 // kdDebug() << "~CalendarView()" << endl; 471 // kdDebug() << "~CalendarView()" << endl;
470 //qDebug("CalendarView::~CalendarView() "); 472 //qDebug("CalendarView::~CalendarView() ");
471 delete mDialogManager; 473 delete mDialogManager;
472 delete mViewManager; 474 delete mViewManager;
473 delete mStorage; 475 delete mStorage;
474 delete mDateFrame ; 476 delete mDateFrame ;
475 delete beamDialog; 477 delete beamDialog;
476 //kdDebug() << "~CalendarView() done" << endl; 478 //kdDebug() << "~CalendarView() done" << endl;
477} 479}
478void CalendarView::timerAlarm() 480void CalendarView::timerAlarm()
479{ 481{
480 //qDebug("CalendarView::timerAlarm() "); 482 //qDebug("CalendarView::timerAlarm() ");
481 computeAlarm(mAlarmNotification ); 483 computeAlarm(mAlarmNotification );
482} 484}
483 485
484void CalendarView::suspendAlarm() 486void CalendarView::suspendAlarm()
485{ 487{
486 //qDebug(" CalendarView::suspendAlarm() "); 488 //qDebug(" CalendarView::suspendAlarm() ");
487 computeAlarm(mSuspendAlarmNotification ); 489 computeAlarm(mSuspendAlarmNotification );
488 490
489} 491}
490 492
491void CalendarView::startAlarm( QString mess , QString filename) 493void CalendarView::startAlarm( QString mess , QString filename)
492{ 494{
493 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 495 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
496 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
494 497
495} 498}
496 499
500void CalendarView::checkNextTimerAlarm()
501{
502 mCalendar->checkAlarmForIncidence( 0, true );
503}
497 504
498void CalendarView::computeAlarm( QString msg ) 505void CalendarView::computeAlarm( QString msg )
499{ 506{
500 507
501 QString mess = msg; 508 QString mess = msg;
502 QString mAlarmMessage = mess.mid( 9 ); 509 QString mAlarmMessage = mess.mid( 9 );
503 QString filename = MainWindow::resourcePath(); 510 QString filename = MainWindow::resourcePath();
504 filename += "koalarm.wav"; 511 filename += "koalarm.wav";
505 QString tempfilename; 512 QString tempfilename;
506 if ( mess.left( 13 ) == "suspend_alarm") { 513 if ( mess.left( 13 ) == "suspend_alarm") {
507 bool error = false; 514 bool error = false;
508 int len = mess.mid( 13 ).find("+++"); 515 int len = mess.mid( 13 ).find("+++");
509 if ( len < 2 ) 516 if ( len < 2 )
510 error = true; 517 error = true;
511 else { 518 else {
512 tempfilename = mess.mid( 13, len ); 519 tempfilename = mess.mid( 13, len );
513 if ( !QFile::exists( tempfilename ) ) 520 if ( !QFile::exists( tempfilename ) )
514 error = true; 521 error = true;
515 } 522 }
516 if ( ! error ) { 523 if ( ! error ) {
517 filename = tempfilename; 524 filename = tempfilename;
518 } 525 }
519 mAlarmMessage = mess.mid( 13+len+3 ); 526 mAlarmMessage = mess.mid( 13+len+3 );
520 //qDebug("suspend file %s ",tempfilename.latin1() ); 527 //qDebug("suspend file %s ",tempfilename.latin1() );
521 startAlarm( mAlarmMessage, filename); 528 startAlarm( mAlarmMessage, filename);
522 return; 529 return;
523 } 530 }
524 if ( mess.left( 11 ) == "timer_alarm") { 531 if ( mess.left( 11 ) == "timer_alarm") {
525 //mTimerTime = 0; 532 //mTimerTime = 0;
526 startAlarm( mess.mid( 11 ), filename ); 533 startAlarm( mess.mid( 11 ), filename );
527 return; 534 return;
528 } 535 }
529 if ( mess.left( 10 ) == "proc_alarm") { 536 if ( mess.left( 10 ) == "proc_alarm") {
530 bool error = false; 537 bool error = false;
531 int len = mess.mid( 10 ).find("+++"); 538 int len = mess.mid( 10 ).find("+++");
532 if ( len < 2 ) 539 if ( len < 2 )
533 error = true; 540 error = true;
534 else { 541 else {
535 tempfilename = mess.mid( 10, len ); 542 tempfilename = mess.mid( 10, len );
536 if ( !QFile::exists( tempfilename ) ) 543 if ( !QFile::exists( tempfilename ) )
537 error = true; 544 error = true;
538 } 545 }
539 if ( error ) { 546 if ( error ) {
540 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 547 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
541 mAlarmMessage += mess.mid( 10+len+3+9 ); 548 mAlarmMessage += mess.mid( 10+len+3+9 );
542 } else { 549 } else {
543 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 550 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
544 //qDebug("-----system command %s ",tempfilename.latin1() ); 551 //qDebug("-----system command %s ",tempfilename.latin1() );
545#ifndef _WIN32_ 552#ifndef _WIN32_
546 if ( vfork () == 0 ) { 553 if ( vfork () == 0 ) {
547 execl ( tempfilename.latin1(), 0 ); 554 execl ( tempfilename.latin1(), 0 );
548 return; 555 return;
549 } 556 }
550#else 557#else
551 QProcess* p = new QProcess(); 558 QProcess* p = new QProcess();
552 p->addArgument( tempfilename.latin1() ); 559 p->addArgument( tempfilename.latin1() );
553 p->start(); 560 p->start();
554 return; 561 return;
555#endif 562#endif
556 563
557 return; 564 return;
558 } 565 }
559 566
560 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 567 //qDebug("+++++++system command %s ",tempfilename.latin1() );
561 } 568 }
562 if ( mess.left( 11 ) == "audio_alarm") { 569 if ( mess.left( 11 ) == "audio_alarm") {
563 bool error = false; 570 bool error = false;
564 int len = mess.mid( 11 ).find("+++"); 571 int len = mess.mid( 11 ).find("+++");
565 if ( len < 2 ) 572 if ( len < 2 )
566 error = true; 573 error = true;
567 else { 574 else {
568 tempfilename = mess.mid( 11, len ); 575 tempfilename = mess.mid( 11, len );
569 if ( !QFile::exists( tempfilename ) ) 576 if ( !QFile::exists( tempfilename ) )
570 error = true; 577 error = true;
571 } 578 }
572 if ( ! error ) { 579 if ( ! error ) {
573 filename = tempfilename; 580 filename = tempfilename;
574 } 581 }
575 mAlarmMessage = mess.mid( 11+len+3+9 ); 582 mAlarmMessage = mess.mid( 11+len+3+9 );
576 //qDebug("audio file command %s ",tempfilename.latin1() ); 583 //qDebug("audio file command %s ",tempfilename.latin1() );
577 } 584 }
578 if ( mess.left( 9 ) == "cal_alarm") { 585 if ( mess.left( 9 ) == "cal_alarm") {
579 mAlarmMessage = mess.mid( 9 ) ; 586 mAlarmMessage = mess.mid( 9 ) ;
580 } 587 }
581 588
582 startAlarm( mAlarmMessage, filename ); 589 startAlarm( mAlarmMessage, filename );
583 590
584 591
585} 592}
586 593
587void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 594void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
588{ 595{
589 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 596 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
590 597
591 mSuspendAlarmNotification = noti; 598 mSuspendAlarmNotification = noti;
592 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 599 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
593 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 600 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
594 mSuspendTimer->start( ms , true ); 601 mSuspendTimer->start( ms , true );
595 602
596} 603}
597 604
598void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 605void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
599{ 606{
600 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 607 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
601 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 608 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
602#ifndef DESKTOP_VERSION 609#ifndef DESKTOP_VERSION
603 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() ); 610 AlarmServer::addAlarm ( qdt,"koalarm", noti.latin1() );
604#endif 611#endif
605 return; 612 return;
606 } 613 }
614 int maxSec;
615 //maxSec = 5; //testing only
616 maxSec = 86400+3600; // one day+1hour
607 mAlarmNotification = noti; 617 mAlarmNotification = noti;
608 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 618 int sec = QDateTime::currentDateTime().secsTo( qdt );
609 //qDebug("Alarm timer started with secs: %d ", ms/1000); 619 if ( sec > maxSec ) {
610 mAlarmTimer->start( ms , true ); 620 mRecheckAlarmTimer->start( maxSec * 1000 );
621 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
622 return;
623 } else {
624 mRecheckAlarmTimer->stop();
625 }
626 //qDebug("Alarm timer started with secs: %d ", sec);
627 mAlarmTimer->start( sec *1000 , true );
611 628
612} 629}
630// called by mRecheckAlarmTimer to get next alarm
631// we need this, because a QTimer has only a max range of 25 days
632void CalendarView::recheckTimerAlarm()
633{
634 mAlarmTimer->stop();
635 mRecheckAlarmTimer->stop();
636 mCalendar->checkAlarmForIncidence( 0, true );
637}
613void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 638void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
614{ 639{
615 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 640 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
616 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 641 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
617#ifndef DESKTOP_VERSION 642#ifndef DESKTOP_VERSION
618 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 643 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
619#endif 644#endif
620 return; 645 return;
621 } 646 }
622 mAlarmTimer->stop(); 647 mAlarmTimer->stop();
623} 648}
624void CalendarView::selectWeekNum ( int num ) 649void CalendarView::selectWeekNum ( int num )
625{ 650{
626 dateNavigator()->selectWeek( num ); 651 dateNavigator()->selectWeek( num );
627 mViewManager->showWeekView(); 652 mViewManager->showWeekView();
628} 653}
629KOViewManager *CalendarView::viewManager() 654KOViewManager *CalendarView::viewManager()
630{ 655{
631 return mViewManager; 656 return mViewManager;
632} 657}
633 658
634KODialogManager *CalendarView::dialogManager() 659KODialogManager *CalendarView::dialogManager()
635{ 660{
636 return mDialogManager; 661 return mDialogManager;
637} 662}
638 663
639QDate CalendarView::startDate() 664QDate CalendarView::startDate()
640{ 665{
641 DateList dates = mNavigator->selectedDates(); 666 DateList dates = mNavigator->selectedDates();
642 667
643 return dates.first(); 668 return dates.first();
644} 669}
645 670
646QDate CalendarView::endDate() 671QDate CalendarView::endDate()
647{ 672{
648 DateList dates = mNavigator->selectedDates(); 673 DateList dates = mNavigator->selectedDates();
649 674
650 return dates.last(); 675 return dates.last();
651} 676}
652 677
653 678
654void CalendarView::createPrinter() 679void CalendarView::createPrinter()
655{ 680{
656#ifndef KORG_NOPRINTER 681#ifndef KORG_NOPRINTER
657 if (!mCalPrinter) { 682 if (!mCalPrinter) {
658 mCalPrinter = new CalPrinter(this, mCalendar); 683 mCalPrinter = new CalPrinter(this, mCalendar);
659 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 684 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
660 } 685 }
661#endif 686#endif
662} 687}
663 688
664void CalendarView::confSync() 689void CalendarView::confSync()
665{ 690{
666 static KOSyncPrefsDialog* sp = 0; 691 static KOSyncPrefsDialog* sp = 0;
667 if ( ! sp ) { 692 if ( ! sp ) {
668 sp = new KOSyncPrefsDialog( this, "syncprefs", true ); 693 sp = new KOSyncPrefsDialog( this, "syncprefs", true );
669 } 694 }
670 sp->usrReadConfig(); 695 sp->usrReadConfig();
671#ifndef DESKTOP_VERSION 696#ifndef DESKTOP_VERSION
672 sp->showMaximized(); 697 sp->showMaximized();
673#else 698#else
674 sp->show(); 699 sp->show();
675#endif 700#endif
676 sp->exec(); 701 sp->exec();
677 702
678} 703}
679 704
680 705
681//KOPrefs::instance()->mWriteBackFile 706//KOPrefs::instance()->mWriteBackFile
682//KOPrefs::instance()->mWriteBackExistingOnly 707//KOPrefs::instance()->mWriteBackExistingOnly
683 708
684// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 709// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
685// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 710// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
686// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 711// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
687// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 712// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
688// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 713// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
689// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 714// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
690 715
691int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 716int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
692{ 717{
693 718
694 //void setZaurusId(int id); 719 //void setZaurusId(int id);
695 // int zaurusId() const; 720 // int zaurusId() const;
696 // void setZaurusUid(int id); 721 // void setZaurusUid(int id);
697 // int zaurusUid() const; 722 // int zaurusUid() const;
698 // void setZaurusStat(int id); 723 // void setZaurusStat(int id);
699 // int zaurusStat() const; 724 // int zaurusStat() const;
700 // 0 equal 725 // 0 equal
701 // 1 take local 726 // 1 take local
702 // 2 take remote 727 // 2 take remote
703 // 3 cancel 728 // 3 cancel
704 QDateTime lastSync = mLastCalendarSync; 729 QDateTime lastSync = mLastCalendarSync;
705 if ( mGlobalSyncMode == SYNC_MODE_SHARP ) { 730 if ( mGlobalSyncMode == SYNC_MODE_SHARP ) {
706 bool remCh, locCh; 731 bool remCh, locCh;
707 remCh = ( remote->zaurusUid() != local->zaurusUid() ); 732 remCh = ( remote->zaurusUid() != local->zaurusUid() );
708 locCh = ( local->zaurusStat() != local->revision() ); 733 locCh = ( local->zaurusStat() != local->revision() );
709 //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() ); 734 //qDebug("locCh %d remCh %d locuid %d remuid %d", locCh, remCh,local->zaurusUid(), remote->zaurusUid() );
710 if ( !remCh && ! locCh ) { 735 if ( !remCh && ! locCh ) {
711 //qDebug("both not changed "); 736 //qDebug("both not changed ");
712 lastSync = local->lastModified().addDays(1); 737 lastSync = local->lastModified().addDays(1);
713 } else { 738 } else {
714 if ( locCh ) { 739 if ( locCh ) {
715 //qDebug("loc changed %d %d", local->zaurusStat(), local->revision() ); 740 //qDebug("loc changed %d %d", local->zaurusStat(), local->revision() );
716 lastSync = local->lastModified().addDays( -1 ); 741 lastSync = local->lastModified().addDays( -1 );
717 if ( !remCh ) 742 if ( !remCh )
718 remote->setLastModified( lastSync.addDays( -1 ) ); 743 remote->setLastModified( lastSync.addDays( -1 ) );
719 } else { 744 } else {
720 //qDebug(" not loc changed "); 745 //qDebug(" not loc changed ");
721 lastSync = local->lastModified().addDays( 1 ); 746 lastSync = local->lastModified().addDays( 1 );
722 if ( remCh ) 747 if ( remCh )
723 remote->setLastModified( lastSync.addDays( 1 ) ); 748 remote->setLastModified( lastSync.addDays( 1 ) );
724 749
725 } 750 }
726 } 751 }
727 full = true; 752 full = true;
728 if ( mode < 3 ) 753 if ( mode < 3 )
729 mode = 3; 754 mode = 3;
730 } else { 755 } else {
731 if ( local->lastModified() == remote->lastModified() ) 756 if ( local->lastModified() == remote->lastModified() )
732 if ( local->revision() == remote->revision() ) 757 if ( local->revision() == remote->revision() )
733 return 0; 758 return 0;
734 759
735 } 760 }
736 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 761 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
737 762
738 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision()); 763 //qDebug("%s %d %s %d", local->lastModified().toString().latin1() , local->revision(), remote->lastModified().toString().latin1(), remote->revision());
739 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() ); 764 //qDebug("%d %d %d %d ", local->lastModified().time().second(), local->lastModified().time().msec(), remote->lastModified().time().second(), remote->lastModified().time().msec() );
740 //full = true; //debug only 765 //full = true; //debug only
741 if ( full ) { 766 if ( full ) {
742 bool equ = false; 767 bool equ = false;
743 if ( local->type() == "Event" ) { 768 if ( local->type() == "Event" ) {
744 equ = (*((Event*) local) == *((Event*) remote)); 769 equ = (*((Event*) local) == *((Event*) remote));
745 } 770 }
746 else if ( local->type() =="Todo" ) 771 else if ( local->type() =="Todo" )
747 equ = (*((Todo*) local) == (*(Todo*) remote)); 772 equ = (*((Todo*) local) == (*(Todo*) remote));
748 else if ( local->type() =="Journal" ) 773 else if ( local->type() =="Journal" )
749 equ = (*((Journal*) local) == *((Journal*) remote)); 774 equ = (*((Journal*) local) == *((Journal*) remote));
750 if ( equ ) { 775 if ( equ ) {
751 //qDebug("equal "); 776 //qDebug("equal ");
752 if ( mGlobalSyncMode == SYNC_MODE_SHARP ) { 777 if ( mGlobalSyncMode == SYNC_MODE_SHARP ) {
753 local->setZaurusUid( remote->zaurusUid() ); 778 local->setZaurusUid( remote->zaurusUid() );
754 } 779 }
755 if ( mode < 4 ) 780 if ( mode < 4 )
756 return 0; 781 return 0;
757 782
758 }//else //debug only 783 }//else //debug only
759 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 784 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
760 } 785 }
761 int result; 786 int result;
762 bool localIsNew; 787 bool localIsNew;
763 if ( full && mode < 2 ) 788 if ( full && mode < 2 )
764 mode = 3; 789 mode = 3;
765 790
766 switch( mode ) { 791 switch( mode ) {
767 case 0: 792 case 0:
768 if ( lastSync > remote->lastModified() ) 793 if ( lastSync > remote->lastModified() )
769 return 1; 794 return 1;
770 if ( lastSync > local->lastModified() ) 795 if ( lastSync > local->lastModified() )
771 return 2; 796 return 2;
772 return 1; 797 return 1;
773 break; 798 break;
774 case 1: 799 case 1:
775 if ( lastSync > remote->lastModified() ) 800 if ( lastSync > remote->lastModified() )
776 return 1; 801 return 1;
777 if ( lastSync > local->lastModified() ) 802 if ( lastSync > local->lastModified() )
778 return 2; 803 return 2;
779 return 2; 804 return 2;
780 break; 805 break;
781 case 2: 806 case 2:
782 if ( local->lastModified() > remote->lastModified() ) 807 if ( local->lastModified() > remote->lastModified() )
783 return 1; 808 return 1;
784 else 809 else
785 return 2; 810 return 2;
786 break; 811 break;
787 case 3: 812 case 3:
788 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); 813 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() );
789 if ( lastSync > remote->lastModified() ) 814 if ( lastSync > remote->lastModified() )
790 return 1; 815 return 1;
791 if ( lastSync > local->lastModified() ) 816 if ( lastSync > local->lastModified() )
792 return 2; 817 return 2;
793 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() ); 818 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), local->lastModified().toString().latin1(), remote->lastModified().toString().latin1() );
794 localIsNew = local->lastModified() > remote->lastModified(); 819 localIsNew = local->lastModified() > remote->lastModified();
795 if ( localIsNew ) 820 if ( localIsNew )
796 getEventViewerDialog()->setColorMode( 1 ); 821 getEventViewerDialog()->setColorMode( 1 );
797 else 822 else
798 getEventViewerDialog()->setColorMode( 2 ); 823 getEventViewerDialog()->setColorMode( 2 );
799 getEventViewerDialog()->setIncidence(local); 824 getEventViewerDialog()->setIncidence(local);
800 if ( localIsNew ) 825 if ( localIsNew )
801 getEventViewerDialog()->setColorMode( 2 ); 826 getEventViewerDialog()->setColorMode( 2 );
802 else 827 else
803 getEventViewerDialog()->setColorMode( 1 ); 828 getEventViewerDialog()->setColorMode( 1 );
804 getEventViewerDialog()->addIncidence(remote); 829 getEventViewerDialog()->addIncidence(remote);
805 getEventViewerDialog()->setColorMode( 0 ); 830 getEventViewerDialog()->setColorMode( 0 );
806 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 831 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
807 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 832 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
808 getEventViewerDialog()->showMe(); 833 getEventViewerDialog()->showMe();
809 result = getEventViewerDialog()->executeS( localIsNew ); 834 result = getEventViewerDialog()->executeS( localIsNew );
810 return result; 835 return result;
811 836
812 break; 837 break;
813 case 4: 838 case 4:
814 return 1; 839 return 1;
815 break; 840 break;
816 case 5: 841 case 5:
817 return 2; 842 return 2;
818 break; 843 break;
819 844
820 default: 845 default:
821 break; 846 break;
822 } 847 }
823 return 0; 848 return 0;
824} 849}
825Event* CalendarView::getLastSyncEvent() 850Event* CalendarView::getLastSyncEvent()
826{ 851{
827 Event* lse; 852 Event* lse;
828 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 853 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
829 lse = mCalendar->event( "last-syncEvent-device-"+mCurrentSyncDevice ); 854 lse = mCalendar->event( "last-syncEvent-device-"+mCurrentSyncDevice );
830 if (!lse) { 855 if (!lse) {
831 lse = new Event(); 856 lse = new Event();
832 lse->setUid( "last-syncEvent-device-"+mCurrentSyncDevice ); 857 lse->setUid( "last-syncEvent-device-"+mCurrentSyncDevice );
833 lse->setSummary(mCurrentSyncDevice + i18n(" - sync event")); 858 lse->setSummary(mCurrentSyncDevice + i18n(" - sync event"));
834 lse->setDtStart( mLastCalendarSync ); 859 lse->setDtStart( mLastCalendarSync );
835 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 860 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
836 lse->setCategories( i18n("SyncEvent") ); 861 lse->setCategories( i18n("SyncEvent") );
837 lse->setReadOnly( true ); 862 lse->setReadOnly( true );
838 mCalendar->addEvent( lse ); 863 mCalendar->addEvent( lse );
839 } 864 }
840 865
841 return lse; 866 return lse;
842 867
843} 868}
844void CalendarView::checkSharpEvent( Event* lastSync, Incidence* toDelete ) 869void CalendarView::checkSharpEvent( Event* lastSync, Incidence* toDelete )
845{ 870{
846 if ( ! lastSync ) 871 if ( ! lastSync )
847 return; 872 return;
848 if ( toDelete->zaurusId() < 0 ) 873 if ( toDelete->zaurusId() < 0 )
849 return; 874 return;
850 if ( toDelete->type() == "Journal" ) 875 if ( toDelete->type() == "Journal" )
851 return; 876 return;
852 QString des = lastSync->description(); 877 QString des = lastSync->description();
853 QString pref = "e"; 878 QString pref = "e";
854 if ( toDelete->type() == "Todo" ) 879 if ( toDelete->type() == "Todo" )
855 pref = "t"; 880 pref = "t";
856 des += pref+ QString::number ( toDelete->zaurusId() ) + ","; 881 des += pref+ QString::number ( toDelete->zaurusId() ) + ",";
857 lastSync->setReadOnly( false ); 882 lastSync->setReadOnly( false );
858 lastSync->setDescription( des ); 883 lastSync->setDescription( des );
859 lastSync->setReadOnly( true ); 884 lastSync->setReadOnly( true );
860 885
861} 886}
862bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 887bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
863{ 888{
864 bool syncOK = true; 889 bool syncOK = true;
865 int addedEvent = 0; 890 int addedEvent = 0;
866 int addedEventR = 0; 891 int addedEventR = 0;
867 int deletedEventR = 0; 892 int deletedEventR = 0;
868 int deletedEventL = 0; 893 int deletedEventL = 0;
869 int changedLocal = 0; 894 int changedLocal = 0;
870 int changedRemote = 0; 895 int changedRemote = 0;
871 //QPtrList<Event> el = local->rawEvents(); 896 //QPtrList<Event> el = local->rawEvents();
872 Event* eventR; 897 Event* eventR;
873 QString uid; 898 QString uid;
874 int take; 899 int take;
875 Event* eventL; 900 Event* eventL;
876 Event* eventRSync; 901 Event* eventRSync;
877 Event* eventLSync; 902 Event* eventLSync;
878 Event* eventRSyncSharp = remote->event( "last-syncEvent-device-Sharp-DTM"); 903 Event* eventRSyncSharp = remote->event( "last-syncEvent-device-Sharp-DTM");
879 Event* eventLSyncSharp = local->event( "last-syncEvent-device-Sharp-DTM"); 904 Event* eventLSyncSharp = local->event( "last-syncEvent-device-Sharp-DTM");
880 bool fullDateRange = false; 905 bool fullDateRange = false;
881 mLastCalendarSync = QDateTime::currentDateTime(); 906 mLastCalendarSync = QDateTime::currentDateTime();
882 QDateTime modifiedCalendar = mLastCalendarSync;; 907 QDateTime modifiedCalendar = mLastCalendarSync;;
883 eventR = remote->event("last-syncEvent-device-"+mCurrentSyncName ); 908 eventR = remote->event("last-syncEvent-device-"+mCurrentSyncName );
884 if ( eventR ) { 909 if ( eventR ) {
885 eventRSync = (Event*) eventR->clone(); 910 eventRSync = (Event*) eventR->clone();
886 remote->deleteEvent(eventR ); 911 remote->deleteEvent(eventR );
887 912
888 } else { 913 } else {
889 fullDateRange = true; 914 fullDateRange = true;
890 eventRSync = new Event(); 915 eventRSync = new Event();
891 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 916 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
892 eventRSync->setUid("last-syncEvent-device-"+mCurrentSyncName ); 917 eventRSync->setUid("last-syncEvent-device-"+mCurrentSyncName );
893 eventRSync->setDtStart( mLastCalendarSync ); 918 eventRSync->setDtStart( mLastCalendarSync );
894 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 919 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
895 eventRSync->setCategories( i18n("SyncEvent") ); 920 eventRSync->setCategories( i18n("SyncEvent") );
896 } 921 }
897 eventLSync = getLastSyncEvent(); 922 eventLSync = getLastSyncEvent();
898 if ( eventLSync->dtStart() == mLastCalendarSync ) 923 if ( eventLSync->dtStart() == mLastCalendarSync )
899 fullDateRange = true; 924 fullDateRange = true;
900 925
901 if ( ! fullDateRange ) { 926 if ( ! fullDateRange ) {
902 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 927 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
903 928
904 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 929 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
905 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 930 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
906 fullDateRange = true; 931 fullDateRange = true;
907 } 932 }
908 } 933 }
909 if ( fullDateRange ) 934 if ( fullDateRange )
910 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 935 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
911 else 936 else
912 mLastCalendarSync = eventLSync->dtStart(); 937 mLastCalendarSync = eventLSync->dtStart();
913 // for resyncing if own file has changed 938 // for resyncing if own file has changed
914 if ( mCurrentSyncDevice == "deleteaftersync" ) { 939 if ( mCurrentSyncDevice == "deleteaftersync" ) {
915 mLastCalendarSync = loadedFileVersion; 940 mLastCalendarSync = loadedFileVersion;
916 qDebug("setting mLastCalendarSync "); 941 qDebug("setting mLastCalendarSync ");
917 } 942 }
918 //qDebug("*************************** "); 943 //qDebug("*************************** ");
919 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() ); 944 qDebug("mLastCalendarSync %s ",mLastCalendarSync.toString().latin1() );
920 QPtrList<Incidence> er = remote->rawIncidences(); 945 QPtrList<Incidence> er = remote->rawIncidences();
921 Incidence* inR = er.first(); 946 Incidence* inR = er.first();
922 Incidence* inL; 947 Incidence* inL;
923 QProgressBar bar( er.count(),0 ); 948 QProgressBar bar( er.count(),0 );
924 bar.setCaption (i18n("Syncing - close to abort!") ); 949 bar.setCaption (i18n("Syncing - close to abort!") );
925 950
926 int w = 300; 951 int w = 300;
927 if ( QApplication::desktop()->width() < 320 ) 952 if ( QApplication::desktop()->width() < 320 )
928 w = 220; 953 w = 220;
929 int h = bar.sizeHint().height() ; 954 int h = bar.sizeHint().height() ;
930 int dw = QApplication::desktop()->width(); 955 int dw = QApplication::desktop()->width();
931 int dh = QApplication::desktop()->height(); 956 int dh = QApplication::desktop()->height();
932 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 957 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
933 bar.show(); 958 bar.show();
934 int modulo = (er.count()/10)+1; 959 int modulo = (er.count()/10)+1;
935 int incCounter = 0; 960 int incCounter = 0;
936 while ( inR ) { 961 while ( inR ) {
937 if ( ! bar.isVisible() ) 962 if ( ! bar.isVisible() )
938 return false; 963 return false;
939 if ( incCounter % modulo == 0 ) 964 if ( incCounter % modulo == 0 )
940 bar.setProgress( incCounter ); 965 bar.setProgress( incCounter );
941 ++incCounter; 966 ++incCounter;
942 uid = inR->uid(); 967 uid = inR->uid();
943 bool skipIncidence = false; 968 bool skipIncidence = false;
944 if ( uid.left(21) == QString("last-syncEvent-device") ) 969 if ( uid.left(21) == QString("last-syncEvent-device") )
945 skipIncidence = true; 970 skipIncidence = true;
946 971
947 qApp->processEvents(); 972 qApp->processEvents();
948 if ( !skipIncidence ) { 973 if ( !skipIncidence ) {
949 inL = local->incidence( uid ); 974 inL = local->incidence( uid );
950 if ( inL ) { // maybe conflict - same uid in both calendars 975 if ( inL ) { // maybe conflict - same uid in both calendars
951 int maxrev = inL->revision(); 976 int maxrev = inL->revision();
952 if ( maxrev < inR->revision() ) 977 if ( maxrev < inR->revision() )
953 maxrev = inR->revision(); 978 maxrev = inR->revision();
954 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 979 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
955 //qDebug("take %d %s ", take, inL->summary().latin1()); 980 //qDebug("take %d %s ", take, inL->summary().latin1());
956 if ( take == 3 ) 981 if ( take == 3 )
957 return false; 982 return false;
958 if ( take == 1 ) {// take local 983 if ( take == 1 ) {// take local
959 inL->setZaurusUid( inR->zaurusUid() ); 984 inL->setZaurusUid( inR->zaurusUid() );
960 remote->deleteIncidence( inR ); 985 remote->deleteIncidence( inR );
961 if ( inL->revision() < maxrev ) 986 if ( inL->revision() < maxrev )
962 inL->setRevision( maxrev ); 987 inL->setRevision( maxrev );
963 remote->addIncidence( inL->clone() ); 988 remote->addIncidence( inL->clone() );
964 ++changedRemote; 989 ++changedRemote;
965 } else { 990 } else {
966 if ( inR->revision() < maxrev ) 991 if ( inR->revision() < maxrev )
967 inR->setRevision( maxrev ); 992 inR->setRevision( maxrev );
968 local->deleteIncidence( inL ); 993 local->deleteIncidence( inL );
969 local->addIncidence( inR->clone() ); 994 local->addIncidence( inR->clone() );
970 ++changedLocal; 995 ++changedLocal;
971 } 996 }
972 } 997 }
973 } else { // no conflict 998 } else { // no conflict
974 if ( mGlobalSyncMode == SYNC_MODE_SHARP ) { 999 if ( mGlobalSyncMode == SYNC_MODE_SHARP ) {
975 QString des = eventLSync->description(); 1000 QString des = eventLSync->description();
976 QString pref = "e"; 1001 QString pref = "e";
977 if ( inR->type() == "Todo" ) 1002 if ( inR->type() == "Todo" )
978 pref = "t"; 1003 pref = "t";
979 if ( des.find(pref+QString::number( inR->zaurusId() ) +"," ) >= 0 && mode != 5) { // delete it 1004 if ( des.find(pref+QString::number( inR->zaurusId() ) +"," ) >= 0 && mode != 5) { // delete it
980 inR->setZaurusStat( -3 ); 1005 inR->setZaurusStat( -3 );
981 //remote->deleteIncidence( inR ); 1006 //remote->deleteIncidence( inR );
982 ++deletedEventR; 1007 ++deletedEventR;
983 } else { 1008 } else {
984 inR->setLastModified( modifiedCalendar ); 1009 inR->setLastModified( modifiedCalendar );
985 local->addIncidence( inR->clone() ); 1010 local->addIncidence( inR->clone() );
986 ++addedEvent; 1011 ++addedEvent;
987 } 1012 }
988 } else { 1013 } else {
989 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1014 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
990 inR->setLastModified( modifiedCalendar ); 1015 inR->setLastModified( modifiedCalendar );
991 local->addIncidence( inR->clone() ); 1016 local->addIncidence( inR->clone() );
992 ++addedEvent; 1017 ++addedEvent;
993 } else { 1018 } else {
994 checkSharpEvent(eventRSyncSharp, inR); 1019 checkSharpEvent(eventRSyncSharp, inR);
995 remote->deleteIncidence( inR ); 1020 remote->deleteIncidence( inR );
996 ++deletedEventR; 1021 ++deletedEventR;
997 } 1022 }
998 } 1023 }
999 } 1024 }
1000 } 1025 }
1001 inR = er.next(); 1026 inR = er.next();
1002 } 1027 }
1003 QPtrList<Incidence> el = local->rawIncidences(); 1028 QPtrList<Incidence> el = local->rawIncidences();
1004 inL = el.first(); 1029 inL = el.first();
1005 modulo = (el.count()/10)+1; 1030 modulo = (el.count()/10)+1;
1006 bar.setCaption (i18n("Add / remove events") ); 1031 bar.setCaption (i18n("Add / remove events") );
1007 bar.setTotalSteps ( el.count() ) ; 1032 bar.setTotalSteps ( el.count() ) ;
1008 bar.show(); 1033 bar.show();
1009 incCounter = 0; 1034 incCounter = 0;
1010 1035
1011 while ( inL ) { 1036 while ( inL ) {
1012 1037
1013 qApp->processEvents(); 1038 qApp->processEvents();
1014 if ( ! bar.isVisible() ) 1039 if ( ! bar.isVisible() )
1015 return false; 1040 return false;
1016 if ( incCounter % modulo == 0 ) 1041 if ( incCounter % modulo == 0 )
1017 bar.setProgress( incCounter ); 1042 bar.setProgress( incCounter );
1018 ++incCounter; 1043 ++incCounter;
1019 uid = inL->uid(); 1044 uid = inL->uid();
1020 bool skipIncidence = false; 1045 bool skipIncidence = false;
1021 if ( uid.left(21) == QString("last-syncEvent-device") ) 1046 if ( uid.left(21) == QString("last-syncEvent-device") )
1022 skipIncidence = true; 1047 skipIncidence = true;
1023 if ( mGlobalSyncMode == SYNC_MODE_SHARP && inL->type() == "Journal" ) 1048 if ( mGlobalSyncMode == SYNC_MODE_SHARP && inL->type() == "Journal" )
1024 skipIncidence = true; 1049 skipIncidence = true;
1025 if ( !skipIncidence ) { 1050 if ( !skipIncidence ) {
1026 inR = remote->incidence( uid ); 1051 inR = remote->incidence( uid );
1027 if ( ! inR ) { 1052 if ( ! inR ) {
1028 if ( mGlobalSyncMode == SYNC_MODE_SHARP ) { 1053 if ( mGlobalSyncMode == SYNC_MODE_SHARP ) {
1029 if ( inL->zaurusId() >= 0 && mode != 4 ) { 1054 if ( inL->zaurusId() >= 0 && mode != 4 ) {
1030 local->deleteIncidence( inL ); 1055 local->deleteIncidence( inL );
1031 ++deletedEventL; 1056 ++deletedEventL;
1032 } else { 1057 } else {
1033 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { 1058 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
1034 inL->setZaurusId( -1 ); 1059 inL->setZaurusId( -1 );
1035 ++addedEventR; 1060 ++addedEventR;
1036 inL->setLastModified( modifiedCalendar ); 1061 inL->setLastModified( modifiedCalendar );
1037 remote->addIncidence( inL->clone() ); 1062 remote->addIncidence( inL->clone() );
1038 } 1063 }
1039 } 1064 }
1040 } else { 1065 } else {
1041 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1066 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1042 checkSharpEvent(eventLSyncSharp, inL); 1067 checkSharpEvent(eventLSyncSharp, inL);
1043 local->deleteIncidence( inL ); 1068 local->deleteIncidence( inL );
1044 ++deletedEventL; 1069 ++deletedEventL;
1045 } else { 1070 } else {
1046 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { 1071 if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) {
1047 ++addedEventR; 1072 ++addedEventR;
1048 inL->setLastModified( modifiedCalendar ); 1073 inL->setLastModified( modifiedCalendar );
1049 remote->addIncidence( inL->clone() ); 1074 remote->addIncidence( inL->clone() );
1050 } 1075 }
1051 } 1076 }
1052 } 1077 }
1053 } 1078 }
1054 } 1079 }
1055 inL = el.next(); 1080 inL = el.next();
1056 } 1081 }
1057 1082
1058 bar.hide(); 1083 bar.hide();
1059 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1084 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1060 eventLSync->setReadOnly( false ); 1085 eventLSync->setReadOnly( false );
1061 eventLSync->setDtStart( mLastCalendarSync ); 1086 eventLSync->setDtStart( mLastCalendarSync );
1062 eventRSync->setDtStart( mLastCalendarSync ); 1087 eventRSync->setDtStart( mLastCalendarSync );
1063 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1088 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1064 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1089 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1065 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1090 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1066 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1091 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1067 eventLSync->setReadOnly( true ); 1092 eventLSync->setReadOnly( true );
1068 if ( mGlobalSyncMode == SYNC_MODE_NORMAL) 1093 if ( mGlobalSyncMode == SYNC_MODE_NORMAL)
1069 remote->addEvent( eventRSync ); 1094 remote->addEvent( eventRSync );
1070 QString mes; 1095 QString mes;
1071 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"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR ); 1096 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"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR );
1072 if ( KOPrefs::instance()->mShowSyncSummary ) { 1097 if ( KOPrefs::instance()->mShowSyncSummary ) {
1073 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") ); 1098 KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") );
1074 } 1099 }
1075 qDebug( mes ); 1100 qDebug( mes );
1076 mCalendar->checkAlarmForIncidence( 0, true ); 1101 mCalendar->checkAlarmForIncidence( 0, true );
1077 return syncOK; 1102 return syncOK;
1078} 1103}
1079 1104
1080void CalendarView::setSyncDevice( QString s ) 1105void CalendarView::setSyncDevice( QString s )
1081{ 1106{
1082 mCurrentSyncDevice= s; 1107 mCurrentSyncDevice= s;
1083} 1108}
1084void CalendarView::setSyncName( QString s ) 1109void CalendarView::setSyncName( QString s )
1085{ 1110{
1086 mCurrentSyncName= s; 1111 mCurrentSyncName= s;
1087} 1112}
1088bool CalendarView::syncCalendar(QString filename, int mode) 1113bool CalendarView::syncCalendar(QString filename, int mode)
1089{ 1114{
1090 mGlobalSyncMode = SYNC_MODE_NORMAL; 1115 mGlobalSyncMode = SYNC_MODE_NORMAL;
1091 CalendarLocal* calendar = new CalendarLocal(); 1116 CalendarLocal* calendar = new CalendarLocal();
1092 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1117 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1093 FileStorage* storage = new FileStorage( calendar ); 1118 FileStorage* storage = new FileStorage( calendar );
1094 bool syncOK = false; 1119 bool syncOK = false;
1095 storage->setFileName( filename ); 1120 storage->setFileName( filename );
1096 // qDebug("loading ... "); 1121 // qDebug("loading ... ");
1097 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) { 1122 if ( storage->load(KOPrefs::instance()->mUseQuicksave) ) {
1098 getEventViewerDialog()->setSyncMode( true ); 1123 getEventViewerDialog()->setSyncMode( true );
1099 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1124 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1100 getEventViewerDialog()->setSyncMode( false ); 1125 getEventViewerDialog()->setSyncMode( false );
1101 if ( syncOK ) { 1126 if ( syncOK ) {
1102 if ( KOPrefs::instance()->mWriteBackFile ) 1127 if ( KOPrefs::instance()->mWriteBackFile )
1103 { 1128 {
1104 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 1129 storage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
1105 storage->save(); 1130 storage->save();
1106 } 1131 }
1107 } 1132 }
1108 setModified( true ); 1133 setModified( true );
1109 } 1134 }
1110 delete storage; 1135 delete storage;
1111 delete calendar; 1136 delete calendar;
1112 if ( syncOK ) 1137 if ( syncOK )
1113 updateView(); 1138 updateView();
1114 return syncOK; 1139 return syncOK;
1115} 1140}
1116void CalendarView::syncSharp() 1141void CalendarView::syncSharp()
1117{ 1142{
1118#ifndef DESKTOP_VERSION 1143#ifndef DESKTOP_VERSION
1119 mGlobalSyncMode = SYNC_MODE_SHARP; 1144 mGlobalSyncMode = SYNC_MODE_SHARP;
1120 //mCurrentSyncDevice = "sharp-DTM"; 1145 //mCurrentSyncDevice = "sharp-DTM";
1121 if ( KOPrefs::instance()->mAskForPreferences ) 1146 if ( KOPrefs::instance()->mAskForPreferences )
1122 edit_sync_options(); 1147 edit_sync_options();
1123 qApp->processEvents(); 1148 qApp->processEvents();
1124 CalendarLocal* calendar = new CalendarLocal(); 1149 CalendarLocal* calendar = new CalendarLocal();
1125 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1150 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1126 bool syncOK = false; 1151 bool syncOK = false;
1127 SharpFormat sharpFormat; 1152 SharpFormat sharpFormat;
1128 if ( sharpFormat.load( calendar, mCalendar ) ) { 1153 if ( sharpFormat.load( calendar, mCalendar ) ) {
1129 getEventViewerDialog()->setSyncMode( true ); 1154 getEventViewerDialog()->setSyncMode( true );
1130 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); 1155 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
1131 getEventViewerDialog()->setSyncMode( false ); 1156 getEventViewerDialog()->setSyncMode( false );
1132 qApp->processEvents(); 1157 qApp->processEvents();
1133 if ( syncOK ) { 1158 if ( syncOK ) {
1134 if ( KOPrefs::instance()->mWriteBackFile ) 1159 if ( KOPrefs::instance()->mWriteBackFile )
1135 { 1160 {
1136 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1161 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1137 Incidence* inc = iL.first(); 1162 Incidence* inc = iL.first();
1138 while ( inc ) { 1163 while ( inc ) {
1139 inc->setZaurusStat( inc->revision () ); 1164 inc->setZaurusStat( inc->revision () );
1140 inc = iL.next(); 1165 inc = iL.next();
1141 } 1166 }
1142 // pending: clean last sync event description 1167 // pending: clean last sync event description
1143 sharpFormat.save(calendar); 1168 sharpFormat.save(calendar);
1144 iL = calendar->rawIncidences(); 1169 iL = calendar->rawIncidences();
1145 inc = iL.first(); 1170 inc = iL.first();
1146 Incidence* loc; 1171 Incidence* loc;
1147 while ( inc ) { 1172 while ( inc ) {
1148 if ( inc->zaurusStat() == -4 ) { 1173 if ( inc->zaurusStat() == -4 ) {
1149 loc = mCalendar->incidence(inc->uid() ); 1174 loc = mCalendar->incidence(inc->uid() );
1150 if ( loc ) { 1175 if ( loc ) {
1151 loc->setZaurusId( inc->zaurusId() ); 1176 loc->setZaurusId( inc->zaurusId() );
1152 loc->setZaurusUid( inc->zaurusUid() ); 1177 loc->setZaurusUid( inc->zaurusUid() );
1153 } 1178 }
1154 } 1179 }
1155 inc = iL.next(); 1180 inc = iL.next();
1156 } 1181 }
1157 Incidence* lse = getLastSyncEvent(); 1182 Incidence* lse = getLastSyncEvent();
1158 if ( lse ) { 1183 if ( lse ) {
1159 lse->setReadOnly( false ); 1184 lse->setReadOnly( false );
1160 lse->setDescription( "" ); 1185 lse->setDescription( "" );
1161 lse->setReadOnly( true ); 1186 lse->setReadOnly( true );
1162 } 1187 }
1163 } 1188 }
1164 } 1189 }
1165 setModified( true ); 1190 setModified( true );
1166 } else { 1191 } else {
1167 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1192 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1168 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1193 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1169 question, i18n("Ok")) ; 1194 question, i18n("Ok")) ;
1170 1195
1171 } 1196 }
1172 delete calendar; 1197 delete calendar;
1173 updateView(); 1198 updateView();
1174 return ;//syncOK; 1199 return ;//syncOK;
1175#endif 1200#endif
1176} 1201}
1177 1202
1178 1203
1179#include <kabc/stdaddressbook.h> 1204#include <kabc/stdaddressbook.h>
1180bool CalendarView::importBday() 1205bool CalendarView::importBday()
1181{ 1206{
1182 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1207 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1183 KABC::AddressBook::Iterator it; 1208 KABC::AddressBook::Iterator it;
1184 int count = 0; 1209 int count = 0;
1185 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1210 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1186 ++count; 1211 ++count;
1187 } 1212 }
1188 QProgressBar bar(count,0 ); 1213 QProgressBar bar(count,0 );
1189 int w = 300; 1214 int w = 300;
1190 if ( QApplication::desktop()->width() < 320 ) 1215 if ( QApplication::desktop()->width() < 320 )
1191 w = 220; 1216 w = 220;
1192 int h = bar.sizeHint().height() ; 1217 int h = bar.sizeHint().height() ;
1193 int dw = QApplication::desktop()->width(); 1218 int dw = QApplication::desktop()->width();
1194 int dh = QApplication::desktop()->height(); 1219 int dh = QApplication::desktop()->height();
1195 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1220 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1196 bar.show(); 1221 bar.show();
1197 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1222 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1198 qApp->processEvents(); 1223 qApp->processEvents();
1199 count = 0; 1224 count = 0;
1200 int addCount = 0; 1225 int addCount = 0;
1201 KCal::Attendee* a = 0; 1226 KCal::Attendee* a = 0;
1202 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1227 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1203 if ( ! bar.isVisible() ) 1228 if ( ! bar.isVisible() )
1204 return false; 1229 return false;
1205 bar.setProgress( count++ ); 1230 bar.setProgress( count++ );
1206 qApp->processEvents(); 1231 qApp->processEvents();
1207 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1232 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1208 if ( (*it).birthday().date().isValid() ){ 1233 if ( (*it).birthday().date().isValid() ){
1209 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1234 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1210 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1235 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1211 ++addCount; 1236 ++addCount;
1212 } 1237 }
1213 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1238 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1214 if ( anni.isValid() ){ 1239 if ( anni.isValid() ){
1215 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1240 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1216 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1241 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1217 ++addCount; 1242 ++addCount;
1218 } 1243 }
1219 } 1244 }
1220 updateView(); 1245 updateView();
1221 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1246 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1222 return true; 1247 return true;
1223} 1248}
1224 1249
1225bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1250bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1226{ 1251{
1227 //qDebug("addAnni "); 1252 //qDebug("addAnni ");
1228 Event * ev = new Event(); 1253 Event * ev = new Event();
1229 if ( a ) { 1254 if ( a ) {
1230 ev->addAttendee( a ); 1255 ev->addAttendee( a );
1231 } 1256 }
1232 QString kind; 1257 QString kind;
1233 if ( birthday ) 1258 if ( birthday )
1234 kind = i18n( "Birthday" ); 1259 kind = i18n( "Birthday" );
1235 else 1260 else
1236 kind = i18n( "Anniversary" ); 1261 kind = i18n( "Anniversary" );
1237 ev->setSummary( name + " - " + kind ); 1262 ev->setSummary( name + " - " + kind );
1238 ev->setOrganizer( "nobody@nowhere" ); 1263 ev->setOrganizer( "nobody@nowhere" );
1239 ev->setCategories( kind ); 1264 ev->setCategories( kind );
1240 ev->setDtStart( QDateTime(date) ); 1265 ev->setDtStart( QDateTime(date) );
1241 ev->setDtEnd( QDateTime(date) ); 1266 ev->setDtEnd( QDateTime(date) );
1242 ev->setFloats( true ); 1267 ev->setFloats( true );
1243 Recurrence * rec = ev->recurrence(); 1268 Recurrence * rec = ev->recurrence();
1244 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1269 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1245 rec->addYearlyNum( date.month() ); 1270 rec->addYearlyNum( date.month() );
1246 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1271 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1247 delete ev; 1272 delete ev;
1248 return false; 1273 return false;
1249 } 1274 }
1250 return true; 1275 return true;
1251 1276
1252} 1277}
1253bool CalendarView::importQtopia( const QString &categories, 1278bool CalendarView::importQtopia( const QString &categories,
1254 const QString &datebook, 1279 const QString &datebook,
1255 const QString &todolist ) 1280 const QString &todolist )
1256{ 1281{
1257 1282
1258 QtopiaFormat qtopiaFormat; 1283 QtopiaFormat qtopiaFormat;
1259 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1284 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1260 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1285 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1261 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1286 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1262 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1287 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1263 1288
1264 updateView(); 1289 updateView();
1265 return true; 1290 return true;
1266 1291
1267#if 0 1292#if 0
1268 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1293 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1269 mCurrentSyncDevice = "qtopia-XML"; 1294 mCurrentSyncDevice = "qtopia-XML";
1270 if ( KOPrefs::instance()->mAskForPreferences ) 1295 if ( KOPrefs::instance()->mAskForPreferences )
1271 edit_sync_options(); 1296 edit_sync_options();
1272 qApp->processEvents(); 1297 qApp->processEvents();
1273 CalendarLocal* calendar = new CalendarLocal(); 1298 CalendarLocal* calendar = new CalendarLocal();
1274 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId); 1299 calendar->setTimeZoneId(KOPrefs::instance()->mTimeZoneId);
1275 bool syncOK = false; 1300 bool syncOK = false;
1276 QtopiaFormat qtopiaFormat; 1301 QtopiaFormat qtopiaFormat;
1277 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1302 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1278 bool loadOk = true; 1303 bool loadOk = true;
1279 if ( !categories.isEmpty() ) 1304 if ( !categories.isEmpty() )
1280 loadOk = qtopiaFormat.load( calendar, categories ); 1305 loadOk = qtopiaFormat.load( calendar, categories );
1281 if ( loadOk && !datebook.isEmpty() ) 1306 if ( loadOk && !datebook.isEmpty() )
1282 loadOk = qtopiaFormat.load( calendar, datebook ); 1307 loadOk = qtopiaFormat.load( calendar, datebook );
1283 if ( loadOk && !todolist.isEmpty() ) 1308 if ( loadOk && !todolist.isEmpty() )
1284 loadOk = qtopiaFormat.load( calendar, todolist ); 1309 loadOk = qtopiaFormat.load( calendar, todolist );
1285 1310
1286 if ( loadOk ) { 1311 if ( loadOk ) {
1287 getEventViewerDialog()->setSyncMode( true ); 1312 getEventViewerDialog()->setSyncMode( true );
1288 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs ); 1313 syncOK = synchronizeCalendar( mCalendar, calendar, KOPrefs::instance()->mSyncAlgoPrefs );
1289 getEventViewerDialog()->setSyncMode( false ); 1314 getEventViewerDialog()->setSyncMode( false );
1290 qApp->processEvents(); 1315 qApp->processEvents();
1291 if ( syncOK ) { 1316 if ( syncOK ) {
1292 if ( KOPrefs::instance()->mWriteBackFile ) 1317 if ( KOPrefs::instance()->mWriteBackFile )
1293 { 1318 {
1294 // write back XML file 1319 // write back XML file
1295 1320
1296 } 1321 }
1297 setModified( true ); 1322 setModified( true );
1298 } 1323 }
1299 } else { 1324 } else {
1300 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1325 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1301 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1326 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1302 question, i18n("Ok")) ; 1327 question, i18n("Ok")) ;
1303 } 1328 }
1304 delete calendar; 1329 delete calendar;
1305 updateView(); 1330 updateView();
1306 return syncOK; 1331 return syncOK;
1307 1332
1308 1333
1309#endif 1334#endif
1310 1335
1311} 1336}
1312 1337
1313void CalendarView::setSyncEventsReadOnly() 1338void CalendarView::setSyncEventsReadOnly()
1314{ 1339{
1315 Event * ev; 1340 Event * ev;
1316 QPtrList<Event> eL = mCalendar->rawEvents(); 1341 QPtrList<Event> eL = mCalendar->rawEvents();
1317 ev = eL.first(); 1342 ev = eL.first();
1318 while ( ev ) { 1343 while ( ev ) {
1319 if ( ev->uid().left(21) == QString("last-syncEvent-device") ) 1344 if ( ev->uid().left(21) == QString("last-syncEvent-device") )
1320 ev->setReadOnly( true ); 1345 ev->setReadOnly( true );
1321 ev = eL.next(); 1346 ev = eL.next();
1322 } 1347 }
1323} 1348}
1324bool CalendarView::openCalendar(QString filename, bool merge) 1349bool CalendarView::openCalendar(QString filename, bool merge)
1325{ 1350{
1326 1351
1327 if (filename.isEmpty()) { 1352 if (filename.isEmpty()) {
1328 return false; 1353 return false;
1329 } 1354 }
1330 1355
1331 if (!QFile::exists(filename)) { 1356 if (!QFile::exists(filename)) {
1332 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1357 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1333 return false; 1358 return false;
1334 } 1359 }
1335 1360
1336 globalFlagBlockAgenda = 1; 1361 globalFlagBlockAgenda = 1;
1337 if (!merge) mCalendar->close(); 1362 if (!merge) mCalendar->close();
1338 1363
1339 mStorage->setFileName( filename ); 1364 mStorage->setFileName( filename );
1340 1365
1341 if ( mStorage->load(KOPrefs::instance()->mUseQuicksave) ) { 1366 if ( mStorage->load(KOPrefs::instance()->mUseQuicksave) ) {
1342 if ( merge ) ;//setModified( true ); 1367 if ( merge ) ;//setModified( true );
1343 else { 1368 else {
1344 //setModified( true ); 1369 //setModified( true );
1345 mViewManager->setDocumentId( filename ); 1370 mViewManager->setDocumentId( filename );
1346 mDialogManager->setDocumentId( filename ); 1371 mDialogManager->setDocumentId( filename );
1347 mTodoList->setDocumentId( filename ); 1372 mTodoList->setDocumentId( filename );
1348 } 1373 }
1349 globalFlagBlockAgenda = 2; 1374 globalFlagBlockAgenda = 2;
1350 // if ( getLastSyncEvent() ) 1375 // if ( getLastSyncEvent() )
1351 // getLastSyncEvent()->setReadOnly( true ); 1376 // getLastSyncEvent()->setReadOnly( true );
1352 mCalendar->reInitAlarmSettings(); 1377 mCalendar->reInitAlarmSettings();
1353 setSyncEventsReadOnly(); 1378 setSyncEventsReadOnly();
1354 updateUnmanagedViews(); 1379 updateUnmanagedViews();
1355 updateView(); 1380 updateView();
1356 if ( filename != MainWindow::defaultFileName() ) 1381 if ( filename != MainWindow::defaultFileName() )
1357 saveCalendar( MainWindow::defaultFileName() ); 1382 saveCalendar( MainWindow::defaultFileName() );
1358 loadedFileVersion = QDateTime::currentDateTime(); 1383 loadedFileVersion = QDateTime::currentDateTime();
1359 return true; 1384 return true;
1360 } else { 1385 } else {
1361 // while failing to load, the calendar object could 1386 // while failing to load, the calendar object could
1362 // have become partially populated. Clear it out. 1387 // have become partially populated. Clear it out.
1363 if ( !merge ) mCalendar->close(); 1388 if ( !merge ) mCalendar->close();
1364 1389
1365 KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1390 KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1366 1391
1367 globalFlagBlockAgenda = 2; 1392 globalFlagBlockAgenda = 2;
1368 updateView(); 1393 updateView();
1369 } 1394 }
1370 return false; 1395 return false;
1371} 1396}
1372void CalendarView::setLoadedFileVersion(QDateTime dt) 1397void CalendarView::setLoadedFileVersion(QDateTime dt)
1373{ 1398{
1374 loadedFileVersion = dt; 1399 loadedFileVersion = dt;
1375} 1400}
1376bool CalendarView::checkFileChanged(QString fn) 1401bool CalendarView::checkFileChanged(QString fn)
1377{ 1402{
1378 QFileInfo finf ( fn ); 1403 QFileInfo finf ( fn );
1379 if ( !finf.exists() ) 1404 if ( !finf.exists() )
1380 return true; 1405 return true;
1381 QDateTime dt = finf.lastModified (); 1406 QDateTime dt = finf.lastModified ();
1382 if ( dt <= loadedFileVersion ) 1407 if ( dt <= loadedFileVersion )
1383 return false; 1408 return false;
1384 return true; 1409 return true;
1385 1410
1386} 1411}
1387bool CalendarView::checkFileVersion(QString fn) 1412bool CalendarView::checkFileVersion(QString fn)
1388{ 1413{
1389 QFileInfo finf ( fn ); 1414 QFileInfo finf ( fn );
1390 if ( !finf.exists() ) 1415 if ( !finf.exists() )
1391 return true; 1416 return true;
1392 QDateTime dt = finf.lastModified (); 1417 QDateTime dt = finf.lastModified ();
1393 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1418 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1394 //qDebug("file on disk version %s",dt.toString().latin1()); 1419 //qDebug("file on disk version %s",dt.toString().latin1());
1395 if ( dt <= loadedFileVersion ) 1420 if ( dt <= loadedFileVersion )
1396 return true; 1421 return true;
1397 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, false)) , 1422 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, false)) ,
1398 i18n("KO/Pi Warning"),i18n("Overwrite"), 1423 i18n("KO/Pi Warning"),i18n("Overwrite"),
1399 i18n("Sync+save")); 1424 i18n("Sync+save"));
1400 1425
1401 if ( km == KMessageBox::Cancel ) 1426 if ( km == KMessageBox::Cancel )
1402 return false; 1427 return false;
1403 if ( km == KMessageBox::Yes ) 1428 if ( km == KMessageBox::Yes )
1404 return true; 1429 return true;
1405 1430
1406 setSyncDevice("deleteaftersync" ); 1431 setSyncDevice("deleteaftersync" );
1407 KOPrefs::instance()->mAskForPreferences = true; 1432 KOPrefs::instance()->mAskForPreferences = true;
1408 KOPrefs::instance()->mSyncAlgoPrefs = 3; 1433 KOPrefs::instance()->mSyncAlgoPrefs = 3;
1409 KOPrefs::instance()->mWriteBackFile = false; 1434 KOPrefs::instance()->mWriteBackFile = false;
1410 KOPrefs::instance()->mWriteBackExistingOnly = false; 1435 KOPrefs::instance()->mWriteBackExistingOnly = false;
1411 KOPrefs::instance()->mShowSyncSummary = false; 1436 KOPrefs::instance()->mShowSyncSummary = false;
1412 syncCalendar( fn, 3 ); 1437 syncCalendar( fn, 3 );
1413 Event * e = getLastSyncEvent(); 1438 Event * e = getLastSyncEvent();
1414 mCalendar->deleteEvent ( e ); 1439 mCalendar->deleteEvent ( e );
1415 updateView(); 1440 updateView();
1416 return true; 1441 return true;
1417} 1442}
1418 1443
1419bool CalendarView::saveCalendar( QString filename ) 1444bool CalendarView::saveCalendar( QString filename )
1420{ 1445{
1421 1446
1422 // Store back all unsaved data into calendar object 1447 // Store back all unsaved data into calendar object
1423 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1448 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1424 if ( mViewManager->currentView() ) 1449 if ( mViewManager->currentView() )
1425 mViewManager->currentView()->flushView(); 1450 mViewManager->currentView()->flushView();
1426 1451
1427 //mStorage->setFileName( filename ); 1452 //mStorage->setFileName( filename );
1428 1453
1429 mStorage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) ); 1454 mStorage->setSaveFormat( new ICalFormat( KOPrefs::instance()->mUseQuicksave) );
1430 mStorage->setFileName( filename ); 1455 mStorage->setFileName( filename );
1431 bool success; 1456 bool success;
1432 success = mStorage->save(); 1457 success = mStorage->save();
1433 if ( !success ) { 1458 if ( !success ) {
1434 return false; 1459 return false;
1435 } 1460 }
1436 1461
1437 return true; 1462 return true;
1438} 1463}
1439 1464
1440void CalendarView::closeCalendar() 1465void CalendarView::closeCalendar()
1441{ 1466{
1442 1467
1443 // child windows no longer valid 1468 // child windows no longer valid
1444 emit closingDown(); 1469 emit closingDown();
1445 1470
1446 mCalendar->close(); 1471 mCalendar->close();
1447 setModified(false); 1472 setModified(false);
1448 updateView(); 1473 updateView();
1449} 1474}
1450 1475
1451void CalendarView::archiveCalendar() 1476void CalendarView::archiveCalendar()
1452{ 1477{
1453 mDialogManager->showArchiveDialog(); 1478 mDialogManager->showArchiveDialog();
1454} 1479}
1455 1480
1456 1481
1457void CalendarView::readSettings() 1482void CalendarView::readSettings()
1458{ 1483{
1459 1484
1460 1485
1461 // mViewManager->showAgendaView(); 1486 // mViewManager->showAgendaView();
1462 QString str; 1487 QString str;
1463 //qDebug("CalendarView::readSettings() "); 1488 //qDebug("CalendarView::readSettings() ");
1464 // read settings from the KConfig, supplying reasonable 1489 // read settings from the KConfig, supplying reasonable
1465 // defaults where none are to be found 1490 // defaults where none are to be found
1466 KConfig *config = KOGlobals::config(); 1491 KConfig *config = KOGlobals::config();
1467#ifndef KORG_NOSPLITTER 1492#ifndef KORG_NOSPLITTER
1468 config->setGroup("KOrganizer Geometry"); 1493 config->setGroup("KOrganizer Geometry");
1469 1494
1470 QValueList<int> sizes = config->readIntListEntry("Separator1"); 1495 QValueList<int> sizes = config->readIntListEntry("Separator1");
1471 if (sizes.count() != 2) { 1496 if (sizes.count() != 2) {
1472 sizes << mDateNavigator->minimumSizeHint().width(); 1497 sizes << mDateNavigator->minimumSizeHint().width();
1473 sizes << 300; 1498 sizes << 300;
1474 } 1499 }
1475 mPanner->setSizes(sizes); 1500 mPanner->setSizes(sizes);
1476 1501
1477 sizes = config->readIntListEntry("Separator2"); 1502 sizes = config->readIntListEntry("Separator2");
1478 if ( ( mResourceView && sizes.count() == 4 ) || 1503 if ( ( mResourceView && sizes.count() == 4 ) ||
1479 ( !mResourceView && sizes.count() == 3 ) ) { 1504 ( !mResourceView && sizes.count() == 3 ) ) {
1480 mLeftSplitter->setSizes(sizes); 1505 mLeftSplitter->setSizes(sizes);
1481 } 1506 }
1482#endif 1507#endif
1483 globalFlagBlockAgenda = 1; 1508 globalFlagBlockAgenda = 1;
1484 mViewManager->showAgendaView(); 1509 mViewManager->showAgendaView();
1485 //mViewManager->readSettings( config ); 1510 //mViewManager->readSettings( config );
1486 mTodoList->restoreLayout(config,QString("Todo Layout")); 1511 mTodoList->restoreLayout(config,QString("Todo Layout"));
1487 readFilterSettings(config); 1512 readFilterSettings(config);
1488 config->setGroup( "Views" ); 1513 config->setGroup( "Views" );
1489 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 1514 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
1490 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 1515 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
1491 else if ( dateCount == 7 ) mNavigator->selectWeek(); 1516 else if ( dateCount == 7 ) mNavigator->selectWeek();
1492 else mNavigator->selectDates( dateCount ); 1517 else mNavigator->selectDates( dateCount );
1493 // mViewManager->readSettings( config ); 1518 // mViewManager->readSettings( config );
1494 updateConfig(); 1519 updateConfig();
1495 globalFlagBlockAgenda = 2; 1520 globalFlagBlockAgenda = 2;
1496 mViewManager->readSettings( config ); 1521 mViewManager->readSettings( config );
1497#ifdef DESKTOP_VERSION 1522#ifdef DESKTOP_VERSION
1498 config->setGroup("WidgetLayout"); 1523 config->setGroup("WidgetLayout");
1499 QStringList list; 1524 QStringList list;
1500 list = config->readListEntry("MainLayout"); 1525 list = config->readListEntry("MainLayout");
1501 int x,y,w,h; 1526 int x,y,w,h;
1502 if ( ! list.isEmpty() ) { 1527 if ( ! list.isEmpty() ) {
1503 x = list[0].toInt(); 1528 x = list[0].toInt();
1504 y = list[1].toInt(); 1529 y = list[1].toInt();
1505 w = list[2].toInt(); 1530 w = list[2].toInt();
1506 h = list[3].toInt(); 1531 h = list[3].toInt();
1507 topLevelWidget()->setGeometry(x,y,w,h); 1532 topLevelWidget()->setGeometry(x,y,w,h);
1508 1533
1509 } else { 1534 } else {
1510 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 1535 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
1511 } 1536 }
1512 list = config->readListEntry("EditEventLayout"); 1537 list = config->readListEntry("EditEventLayout");
1513 if ( ! list.isEmpty() ) { 1538 if ( ! list.isEmpty() ) {
1514 x = list[0].toInt(); 1539 x = list[0].toInt();
1515 y = list[1].toInt(); 1540 y = list[1].toInt();
1516 w = list[2].toInt(); 1541 w = list[2].toInt();
1517 h = list[3].toInt(); 1542 h = list[3].toInt();
1518 mEventEditor->setGeometry(x,y,w,h); 1543 mEventEditor->setGeometry(x,y,w,h);
1519 1544
1520 } 1545 }
1521 list = config->readListEntry("EditTodoLayout"); 1546 list = config->readListEntry("EditTodoLayout");
1522 if ( ! list.isEmpty() ) { 1547 if ( ! list.isEmpty() ) {
1523 x = list[0].toInt(); 1548 x = list[0].toInt();
1524 y = list[1].toInt(); 1549 y = list[1].toInt();
1525 w = list[2].toInt(); 1550 w = list[2].toInt();
1526 h = list[3].toInt(); 1551 h = list[3].toInt();
1527 mTodoEditor->setGeometry(x,y,w,h); 1552 mTodoEditor->setGeometry(x,y,w,h);
1528 1553
1529 } 1554 }
1530 list = config->readListEntry("ViewerLayout"); 1555 list = config->readListEntry("ViewerLayout");
1531 if ( ! list.isEmpty() ) { 1556 if ( ! list.isEmpty() ) {
1532 x = list[0].toInt(); 1557 x = list[0].toInt();
1533 y = list[1].toInt(); 1558 y = list[1].toInt();
1534 w = list[2].toInt(); 1559 w = list[2].toInt();
1535 h = list[3].toInt(); 1560 h = list[3].toInt();
1536 getEventViewerDialog()->setGeometry(x,y,w,h); 1561 getEventViewerDialog()->setGeometry(x,y,w,h);
1537 } 1562 }
1538#endif 1563#endif
1539 1564
1540 1565
1541 // pending read sync settings; 1566 // pending read sync settings;
1542 mSyncProfileNames.clear(); 1567 mSyncProfileNames.clear();
1543 mSyncProfileNames << "Profile_1"; 1568 mSyncProfileNames << "Profile_1";
1544 mSyncProfileNames << "Profile_2"; 1569 mSyncProfileNames << "Profile_2";
1545 mSyncProfileNames << "Profile_3"; 1570 mSyncProfileNames << "Profile_3";
1546 mSyncProfileNames << "Profile_4"; 1571 mSyncProfileNames << "Profile_4";
1547 mSyncProfileNames << "Profile_5"; 1572 mSyncProfileNames << "Profile_5";
1548 KSyncProfile* temp = new KSyncProfile (); 1573 KSyncProfile* temp = new KSyncProfile ();
1549 temp->setName("Profile_1" ); 1574 temp->setName("Profile_1" );
1550 mSyncProfiles.append( temp ); 1575 mSyncProfiles.append( temp );
1551 temp = new KSyncProfile (); 1576 temp = new KSyncProfile ();
1552 temp->setName("Profile_2" ); 1577 temp->setName("Profile_2" );
1553 mSyncProfiles.append( temp ); 1578 mSyncProfiles.append( temp );
1554 temp = new KSyncProfile (); 1579 temp = new KSyncProfile ();
1555 temp->setName("Profile_3" ); 1580 temp->setName("Profile_3" );
1556 mSyncProfiles.append( temp ); 1581 mSyncProfiles.append( temp );
1557 temp = new KSyncProfile (); 1582 temp = new KSyncProfile ();
1558 temp->setName("Profile_4" ); 1583 temp->setName("Profile_4" );
1559 mSyncProfiles.append( temp ); 1584 mSyncProfiles.append( temp );
1560 temp = new KSyncProfile (); 1585 temp = new KSyncProfile ();
1561 temp->setName("Profile_5" ); 1586 temp->setName("Profile_5" );
1562 mSyncProfiles.append( temp ); 1587 mSyncProfiles.append( temp );
1563} 1588}
1564 1589
1565 1590
1566void CalendarView::writeSettings() 1591void CalendarView::writeSettings()
1567{ 1592{
1568 // kdDebug() << "CalendarView::writeSettings" << endl; 1593 // kdDebug() << "CalendarView::writeSettings" << endl;
1569 1594
1570 KConfig *config = KOGlobals::config(); 1595 KConfig *config = KOGlobals::config();
1571 1596
1572#ifndef KORG_NOSPLITTER 1597#ifndef KORG_NOSPLITTER
1573 config->setGroup("KOrganizer Geometry"); 1598 config->setGroup("KOrganizer Geometry");
1574 1599
1575 QValueList<int> list = mPanner->sizes(); 1600 QValueList<int> list = mPanner->sizes();
1576 config->writeEntry("Separator1",list); 1601 config->writeEntry("Separator1",list);
1577 1602
1578 list = mLeftSplitter->sizes(); 1603 list = mLeftSplitter->sizes();
1579 config->writeEntry("Separator2",list); 1604 config->writeEntry("Separator2",list);
1580#endif 1605#endif
1581 1606
1582 mViewManager->writeSettings( config ); 1607 mViewManager->writeSettings( config );
1583 mTodoList->saveLayout(config,QString("Todo Layout")); 1608 mTodoList->saveLayout(config,QString("Todo Layout"));
1584 mDialogManager->writeSettings( config ); 1609 mDialogManager->writeSettings( config );
1585 //KOPrefs::instance()->usrWriteConfig(); 1610 //KOPrefs::instance()->usrWriteConfig();
1586 KOPrefs::instance()->writeConfig(); 1611 KOPrefs::instance()->writeConfig();
1587 1612
1588 writeFilterSettings(config); 1613 writeFilterSettings(config);
1589 1614
1590 config->setGroup( "Views" ); 1615 config->setGroup( "Views" );
1591 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 1616 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
1592 1617
1593#ifdef DESKTOP_VERSION 1618#ifdef DESKTOP_VERSION
1594 config->setGroup("WidgetLayout"); 1619 config->setGroup("WidgetLayout");
1595 QStringList list ;//= config->readListEntry("MainLayout"); 1620 QStringList list ;//= config->readListEntry("MainLayout");
1596 int x,y,w,h; 1621 int x,y,w,h;
1597 QWidget* wid; 1622 QWidget* wid;
1598 wid = topLevelWidget(); 1623 wid = topLevelWidget();
1599 x = wid->geometry().x(); 1624 x = wid->geometry().x();
1600 y = wid->geometry().y(); 1625 y = wid->geometry().y();
1601 w = wid->width(); 1626 w = wid->width();
1602 h = wid->height(); 1627 h = wid->height();
1603 list.clear(); 1628 list.clear();
1604 list << QString::number( x ); 1629 list << QString::number( x );
1605 list << QString::number( y ); 1630 list << QString::number( y );
1606 list << QString::number( w ); 1631 list << QString::number( w );
1607 list << QString::number( h ); 1632 list << QString::number( h );
1608 config->writeEntry("MainLayout",list ); 1633 config->writeEntry("MainLayout",list );
1609 1634
1610 wid = mEventEditor; 1635 wid = mEventEditor;
1611 x = wid->geometry().x(); 1636 x = wid->geometry().x();
1612 y = wid->geometry().y(); 1637 y = wid->geometry().y();
1613 w = wid->width(); 1638 w = wid->width();
1614 h = wid->height(); 1639 h = wid->height();
1615 list.clear(); 1640 list.clear();
1616 list << QString::number( x ); 1641 list << QString::number( x );
1617 list << QString::number( y ); 1642 list << QString::number( y );
1618 list << QString::number( w ); 1643 list << QString::number( w );
1619 list << QString::number( h ); 1644 list << QString::number( h );
1620 config->writeEntry("EditEventLayout",list ); 1645 config->writeEntry("EditEventLayout",list );
1621 1646
1622 wid = mTodoEditor; 1647 wid = mTodoEditor;
1623 x = wid->geometry().x(); 1648 x = wid->geometry().x();
1624 y = wid->geometry().y(); 1649 y = wid->geometry().y();
1625 w = wid->width(); 1650 w = wid->width();
1626 h = wid->height(); 1651 h = wid->height();
1627 list.clear(); 1652 list.clear();
1628 list << QString::number( x ); 1653 list << QString::number( x );
1629 list << QString::number( y ); 1654 list << QString::number( y );
1630 list << QString::number( w ); 1655 list << QString::number( w );
1631 list << QString::number( h ); 1656 list << QString::number( h );
1632 config->writeEntry("EditTodoLayout",list ); 1657 config->writeEntry("EditTodoLayout",list );
1633 wid = getEventViewerDialog(); 1658 wid = getEventViewerDialog();
1634 x = wid->geometry().x(); 1659 x = wid->geometry().x();
1635 y = wid->geometry().y(); 1660 y = wid->geometry().y();
1636 w = wid->width(); 1661 w = wid->width();
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index e7aa351..fda02f7 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -1,586 +1,588 @@
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
45class QWidgetStack; 45class QWidgetStack;
46class QSplitter; 46class QSplitter;
47 47
48class CalPrinter; 48class CalPrinter;
49class KOFilterView; 49class KOFilterView;
50class KOViewManager; 50class KOViewManager;
51class KODialogManager; 51class KODialogManager;
52class KOTodoView; 52class KOTodoView;
53class KDateNavigator; 53class KDateNavigator;
54class DateNavigator; 54class DateNavigator;
55class KOIncidenceEditor; 55class KOIncidenceEditor;
56class KDatePicker; 56class KDatePicker;
57class ResourceView; 57class ResourceView;
58class NavigatorBar; 58class NavigatorBar;
59class KOEventEditor; 59class KOEventEditor;
60class KOTodoEditor ; 60class KOTodoEditor ;
61class KOEventViewerDialog; 61class KOEventViewerDialog;
62class KOBeamPrefs; 62class KOBeamPrefs;
63class KSyncProfile; 63class KSyncProfile;
64class AlarmDialog; 64class AlarmDialog;
65class KCal::Attendee; 65class KCal::Attendee;
66 66
67namespace KCal { class FileStorage; } 67namespace KCal { class FileStorage; }
68 68
69using namespace KCal; 69using namespace KCal;
70 70
71/** 71/**
72 This is the main calendar widget. It provides the different vies on t he 72 This is the main calendar widget. It provides the different vies on t he
73 calendar data as well as the date navigator. It also handles synchronisation 73 calendar data as well as the date navigator. It also handles synchronisation
74 of the different views and controls the different dialogs like preferences, 74 of the different views and controls the different dialogs like preferences,
75 event editor, search dialog etc. 75 event editor, search dialog etc.
76 76
77 @short main calendar view widget 77 @short main calendar view widget
78 @author Cornelius Schumacher 78 @author Cornelius Schumacher
79*/ 79*/
80class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer 80class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Observer
81{ 81{
82 Q_OBJECT 82 Q_OBJECT
83 public: 83 public:
84 /** 84 /**
85 Constructs a new calendar view widget. 85 Constructs a new calendar view widget.
86 86
87 @param calendar calendar document 87 @param calendar calendar document
88 @param parent parent window 88 @param parent parent window
89 @param name Qt internal widget object name 89 @param name Qt internal widget object name
90 */ 90 */
91 CalendarView( CalendarResources *calendar, QWidget *parent = 0, 91 CalendarView( CalendarResources *calendar, QWidget *parent = 0,
92 const char *name = 0 ); 92 const char *name = 0 );
93 CalendarView( Calendar *calendar, QWidget *parent = 0, 93 CalendarView( Calendar *calendar, QWidget *parent = 0,
94 const char *name = 0 ); 94 const char *name = 0 );
95 virtual ~CalendarView(); 95 virtual ~CalendarView();
96 96
97 Calendar *calendar() { return mCalendar; } 97 Calendar *calendar() { return mCalendar; }
98 98
99 KOViewManager *viewManager(); 99 KOViewManager *viewManager();
100 KODialogManager *dialogManager(); 100 KODialogManager *dialogManager();
101 101
102 QDate startDate(); 102 QDate startDate();
103 QDate endDate(); 103 QDate endDate();
104 104
105 QWidgetStack *viewStack(); 105 QWidgetStack *viewStack();
106 QWidget *leftFrame(); 106 QWidget *leftFrame();
107 NavigatorBar *navigatorBar(); 107 NavigatorBar *navigatorBar();
108 108
109 DateNavigator *dateNavigator(); 109 DateNavigator *dateNavigator();
110 KDateNavigator *dateNavigatorWidget(); 110 KDateNavigator *dateNavigatorWidget();
111 111
112 void addView(KOrg::BaseView *); 112 void addView(KOrg::BaseView *);
113 void showView(KOrg::BaseView *); 113 void showView(KOrg::BaseView *);
114 KOEventViewerDialog* getEventViewerDialog(); 114 KOEventViewerDialog* getEventViewerDialog();
115 Incidence *currentSelection(); 115 Incidence *currentSelection();
116 116
117 signals: 117 signals:
118 /** This todo has been modified */ 118 /** This todo has been modified */
119 void todoModified(Todo *, int); 119 void todoModified(Todo *, int);
120 120
121 /** when change is made to options dialog, the topwidget will catch this 121 /** when change is made to options dialog, the topwidget will catch this
122 * and emit this signal which notifies all widgets which have registered 122 * and emit this signal which notifies all widgets which have registered
123 * for notification to update their settings. */ 123 * for notification to update their settings. */
124 void configChanged(); 124 void configChanged();
125 /** emitted when the topwidget is closing down, so that any attached 125 /** emitted when the topwidget is closing down, so that any attached
126 child windows can also close. */ 126 child windows can also close. */
127 void closingDown(); 127 void closingDown();
128 /** emitted right before we die */ 128 /** emitted right before we die */
129 void closed(QWidget *); 129 void closed(QWidget *);
130 130
131 /** Emitted when state of modified flag changes */ 131 /** Emitted when state of modified flag changes */
132 void modifiedChanged(bool); 132 void modifiedChanged(bool);
133 void signalmodified(); 133 void signalmodified();
134 134
135 /** Emitted when state of read-only flag changes */ 135 /** Emitted when state of read-only flag changes */
136 void readOnlyChanged(bool); 136 void readOnlyChanged(bool);
137 137
138 /** Emitted when the unit of navigation changes */ 138 /** Emitted when the unit of navigation changes */
139 void changeNavStringPrev(const QString &); 139 void changeNavStringPrev(const QString &);
140 void changeNavStringNext(const QString &); 140 void changeNavStringNext(const QString &);
141 141
142 /** Emitted when state of events selection has changed and user is organizer*/ 142 /** Emitted when state of events selection has changed and user is organizer*/
143 void organizerEventsSelected(bool); 143 void organizerEventsSelected(bool);
144 /** Emitted when state of events selection has changed and user is attendee*/ 144 /** Emitted when state of events selection has changed and user is attendee*/
145 void groupEventsSelected(bool); 145 void groupEventsSelected(bool);
146 /** 146 /**
147 Emitted when an incidence gets selected. If the selection is cleared the 147 Emitted when an incidence gets selected. If the selection is cleared the
148 signal is emitted with 0 as argument. 148 signal is emitted with 0 as argument.
149 */ 149 */
150 void incidenceSelected( Incidence * ); 150 void incidenceSelected( Incidence * );
151 /** Emitted, when a todoitem is selected or deselected. */ 151 /** Emitted, when a todoitem is selected or deselected. */
152 void todoSelected( bool ); 152 void todoSelected( bool );
153 153
154 /** 154 /**
155 Emitted, when clipboard content changes. Parameter indicates if paste 155 Emitted, when clipboard content changes. Parameter indicates if paste
156 is possible or not. 156 is possible or not.
157 */ 157 */
158 void pasteEnabled(bool); 158 void pasteEnabled(bool);
159 159
160 /** Emitted, when the number of incoming messages has changed. */ 160 /** Emitted, when the number of incoming messages has changed. */
161 void numIncomingChanged(int); 161 void numIncomingChanged(int);
162 162
163 /** Emitted, when the number of outgoing messages has changed. */ 163 /** Emitted, when the number of outgoing messages has changed. */
164 void numOutgoingChanged(int); 164 void numOutgoingChanged(int);
165 165
166 /** Send status message, which can e.g. be displayed in the status bar. */ 166 /** Send status message, which can e.g. be displayed in the status bar. */
167 void statusMessage(const QString &); 167 void statusMessage(const QString &);
168 168
169 void calendarViewExpanded( bool ); 169 void calendarViewExpanded( bool );
170 void updateSearchDialog(); 170 void updateSearchDialog();
171 171
172 172
173 public slots: 173 public slots:
174 174 void recheckTimerAlarm();
175 void checkNextTimerAlarm();
175 void addAlarm(const QDateTime &qdt, const QString &noti ); 176 void addAlarm(const QDateTime &qdt, const QString &noti );
176 void addSuspendAlarm(const QDateTime &qdt, const QString &noti ); 177 void addSuspendAlarm(const QDateTime &qdt, const QString &noti );
177 void removeAlarm(const QDateTime &qdt, const QString &noti ); 178 void removeAlarm(const QDateTime &qdt, const QString &noti );
178 179
179 /** options dialog made a changed to the configuration. we catch this 180 /** options dialog made a changed to the configuration. we catch this
180 * and notify all widgets which need to update their configuration. */ 181 * and notify all widgets which need to update their configuration. */
181 void updateConfig(); 182 void updateConfig();
182 183
183 /** 184 /**
184 Load calendar from file \a filename. If \a merge is true, load 185 Load calendar from file \a filename. If \a merge is true, load
185 calendar into existing one, if it is false, clear calendar, before 186 calendar into existing one, if it is false, clear calendar, before
186 loading. Return true, if calendar could be successfully loaded. 187 loading. Return true, if calendar could be successfully loaded.
187 */ 188 */
188 bool openCalendar(QString filename, bool merge=false); 189 bool openCalendar(QString filename, bool merge=false);
189 bool syncCalendar(QString filename,int mode = 0 ); 190 bool syncCalendar(QString filename,int mode = 0 );
190 191
191 /** 192 /**
192 Save calendar data to file. Return true if calendar could be 193 Save calendar data to file. Return true if calendar could be
193 successfully saved. 194 successfully saved.
194 */ 195 */
195 bool saveCalendar(QString filename); 196 bool saveCalendar(QString filename);
196 197
197 /** 198 /**
198 Close calendar. Clear calendar data and reset views to display an empty 199 Close calendar. Clear calendar data and reset views to display an empty
199 calendar. 200 calendar.
200 */ 201 */
201 void closeCalendar(); 202 void closeCalendar();
202 203
203 /** Archive old events of calendar */ 204 /** Archive old events of calendar */
204 void archiveCalendar(); 205 void archiveCalendar();
205 206
206 void showIncidence(); 207 void showIncidence();
207 void editIncidence(); 208 void editIncidence();
208 void editIncidenceDescription(); 209 void editIncidenceDescription();
209 void deleteIncidence(); 210 void deleteIncidence();
210 211
211 /** create an editeventwin with supplied date/time, and if bool is true, 212 /** create an editeventwin with supplied date/time, and if bool is true,
212 * make the event take all day. */ 213 * make the event take all day. */
213 void newEvent(QDateTime, QDateTime, bool allDay = false); 214 void newEvent(QDateTime, QDateTime, bool allDay = false);
214 void newEvent(QDateTime fh); 215 void newEvent(QDateTime fh);
215 void newEvent(QDate dt); 216 void newEvent(QDate dt);
216 /** create new event without having a date hint. Takes current date as 217 /** create new event without having a date hint. Takes current date as
217 default hint. */ 218 default hint. */
218 void newEvent(); 219 void newEvent();
219 void newFloatingEvent(); 220 void newFloatingEvent();
220 221
221 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/ 222 /** Create a read-only viewer dialog for the supplied incidence. It calls the correct showXXX method*/
222 void showIncidence(Incidence *); 223 void showIncidence(Incidence *);
223 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/ 224 /** Create an editor for the supplied incidence. It calls the correct editXXX method*/
224 void editIncidence(Incidence *); 225 void editIncidence(Incidence *);
225 /** Delete the supplied incidence. It calls the correct deleteXXX method*/ 226 /** Delete the supplied incidence. It calls the correct deleteXXX method*/
226 void deleteIncidence(Incidence *); 227 void deleteIncidence(Incidence *);
227 void cloneIncidence(Incidence *); 228 void cloneIncidence(Incidence *);
228 void cancelIncidence(Incidence *); 229 void cancelIncidence(Incidence *);
229 /** Create an editor for the supplied event. */ 230 /** Create an editor for the supplied event. */
230 void editEvent(Event *); 231 void editEvent(Event *);
231 /** Delete the supplied event. */ 232 /** Delete the supplied event. */
232 void deleteEvent(Event *); 233 void deleteEvent(Event *);
233 /** Delete the event with the given unique ID. Returns false, if event wasn't 234 /** Delete the event with the given unique ID. Returns false, if event wasn't
234 found. */ 235 found. */
235 bool deleteEvent(const QString &uid); 236 bool deleteEvent(const QString &uid);
236 /** Create a read-only viewer dialog for the supplied event. */ 237 /** Create a read-only viewer dialog for the supplied event. */
237 void showEvent(Event *); 238 void showEvent(Event *);
238 239
239 void editJournal(Journal *); 240 void editJournal(Journal *);
240 void showJournal(Journal *); 241 void showJournal(Journal *);
241 void deleteJournal(Journal *); 242 void deleteJournal(Journal *);
242 /** Create an editor dialog for a todo */ 243 /** Create an editor dialog for a todo */
243 void editTodo(Todo *); 244 void editTodo(Todo *);
244 /** Create a read-only viewer dialog for the supplied todo */ 245 /** Create a read-only viewer dialog for the supplied todo */
245 void showTodo(Todo *); 246 void showTodo(Todo *);
246 /** create new todo */ 247 /** create new todo */
247 void newTodo(); 248 void newTodo();
248 /** create new todo with a parent todo */ 249 /** create new todo with a parent todo */
249 void newSubTodo(); 250 void newSubTodo();
250 /** create new todo with a parent todo */ 251 /** create new todo with a parent todo */
251 void newSubTodo(Todo *); 252 void newSubTodo(Todo *);
252 /** Delete todo */ 253 /** Delete todo */
253 void deleteTodo(Todo *); 254 void deleteTodo(Todo *);
254 255
255 256
256 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is 257 /** Check if clipboard contains vCalendar event. The signal pasteEnabled() is
257 * emitted as result. */ 258 * emitted as result. */
258 void checkClipboard(); 259 void checkClipboard();
259 260
260 /** using the KConfig associated with the kapp variable, read in the 261 /** using the KConfig associated with the kapp variable, read in the
261 * settings from the config file. 262 * settings from the config file.
262 */ 263 */
263 void readSettings(); 264 void readSettings();
264 265
265 /** write current state to config file. */ 266 /** write current state to config file. */
266 void writeSettings(); 267 void writeSettings();
267 268
268 /** read settings for calendar filters */ 269 /** read settings for calendar filters */
269 void readFilterSettings(KConfig *config); 270 void readFilterSettings(KConfig *config);
270 271
271 /** write settings for calendar filters */ 272 /** write settings for calendar filters */
272 void writeFilterSettings(KConfig *config); 273 void writeFilterSettings(KConfig *config);
273 274
274 /** passes on the message that an event has changed to the currently 275 /** passes on the message that an event has changed to the currently
275 * activated view so that it can make appropriate display changes. */ 276 * activated view so that it can make appropriate display changes. */
276 void changeEventDisplay(Event *, int); 277 void changeEventDisplay(Event *, int);
277 void changeIncidenceDisplay(Incidence *, int); 278 void changeIncidenceDisplay(Incidence *, int);
278 void changeTodoDisplay(Todo *, int); 279 void changeTodoDisplay(Todo *, int);
279 280
280 void eventAdded(Event *); 281 void eventAdded(Event *);
281 void eventChanged(Event *); 282 void eventChanged(Event *);
282 void eventToBeDeleted(Event *); 283 void eventToBeDeleted(Event *);
283 void eventDeleted(); 284 void eventDeleted();
284 285
285 void todoAdded(Todo *); 286 void todoAdded(Todo *);
286 void todoChanged(Todo *); 287 void todoChanged(Todo *);
287 void todoToBeDeleted(Todo *); 288 void todoToBeDeleted(Todo *);
288 void todoDeleted(); 289 void todoDeleted();
289 290
290 void updateView(const QDate &start, const QDate &end); 291 void updateView(const QDate &start, const QDate &end);
291 void updateView(); 292 void updateView();
292 293
293 /** Full update of visible todo views */ 294 /** Full update of visible todo views */
294 void updateTodoViews(); 295 void updateTodoViews();
295 296
296 void updateUnmanagedViews(); 297 void updateUnmanagedViews();
297 298
298 /** cut the current appointment to the clipboard */ 299 /** cut the current appointment to the clipboard */
299 void edit_cut(); 300 void edit_cut();
300 301
301 /** copy the current appointment(s) to the clipboard */ 302 /** copy the current appointment(s) to the clipboard */
302 void edit_copy(); 303 void edit_copy();
303 304
304 /** paste the current vobject(s) in the clipboard buffer into calendar */ 305 /** paste the current vobject(s) in the clipboard buffer into calendar */
305 void edit_paste(); 306 void edit_paste();
306 307
307 /** edit viewing and configuration options. */ 308 /** edit viewing and configuration options. */
308 void edit_options(); 309 void edit_options();
309 void edit_sync_options(); 310 void edit_sync_options();
310 /** 311 /**
311 Functions for printing, previewing a print, and setting up printing 312 Functions for printing, previewing a print, and setting up printing
312 parameters. 313 parameters.
313 */ 314 */
314 void print(); 315 void print();
315 void printSetup(); 316 void printSetup();
316 void printPreview(); 317 void printPreview();
317 318
318 /** Export as iCalendar file */ 319 /** Export as iCalendar file */
319 void exportICalendar(); 320 void exportICalendar();
320 321
321 /** Export as vCalendar file */ 322 /** Export as vCalendar file */
322 bool exportVCalendar( QString fn); 323 bool exportVCalendar( QString fn);
323 324
324 /** pop up a dialog to show an existing appointment. */ 325 /** pop up a dialog to show an existing appointment. */
325 void appointment_show(); 326 void appointment_show();
326 /** 327 /**
327 * pop up an Appointment Dialog to edit an existing appointment.Get 328 * pop up an Appointment Dialog to edit an existing appointment.Get
328 * information on the appointment from the list of unique IDs that is 329 * information on the appointment from the list of unique IDs that is
329 * currently in the View, called currIds. 330 * currently in the View, called currIds.
330 */ 331 */
331 void appointment_edit(); 332 void appointment_edit();
332 /** 333 /**
333 * pop up dialog confirming deletion of currently selected event in the 334 * pop up dialog confirming deletion of currently selected event in the
334 * View. 335 * View.
335 */ 336 */
336 void appointment_delete(); 337 void appointment_delete();
337 338
338 /** mails the currently selected event to a particular user as a vCalendar 339 /** mails the currently selected event to a particular user as a vCalendar
339 attachment. */ 340 attachment. */
340 void action_mail(); 341 void action_mail();
341 342
342 /* frees a subtodo from it's relation */ 343 /* frees a subtodo from it's relation */
343 void todo_unsub( Todo * ); 344 void todo_unsub( Todo * );
344 345
345 /** Take ownership of selected event. */ 346 /** Take ownership of selected event. */
346 void takeOverEvent(); 347 void takeOverEvent();
347 348
348 /** Take ownership of all events in calendar. */ 349 /** Take ownership of all events in calendar. */
349 void takeOverCalendar(); 350 void takeOverCalendar();
350 351
351 /** query whether or not the calendar is "dirty". */ 352 /** query whether or not the calendar is "dirty". */
352 bool isModified(); 353 bool isModified();
353 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */ 354 /** set the state of calendar. Modified means "dirty", i.e. needing a save. */
354 void setModified(bool modified=true); 355 void setModified(bool modified=true);
355 356
356 /** query if the calendar is read-only. */ 357 /** query if the calendar is read-only. */
357 bool isReadOnly(); 358 bool isReadOnly();
358 /** set state of calendar to read-only */ 359 /** set state of calendar to read-only */
359 void setReadOnly(bool readOnly=true); 360 void setReadOnly(bool readOnly=true);
360 361
361 void eventUpdated(Incidence *); 362 void eventUpdated(Incidence *);
362 363
363 /* iTIP scheduling actions */ 364 /* iTIP scheduling actions */
364 void schedule_publish(Incidence *incidence = 0); 365 void schedule_publish(Incidence *incidence = 0);
365 void schedule_request(Incidence *incidence = 0); 366 void schedule_request(Incidence *incidence = 0);
366 void schedule_refresh(Incidence *incidence = 0); 367 void schedule_refresh(Incidence *incidence = 0);
367 void schedule_cancel(Incidence *incidence = 0); 368 void schedule_cancel(Incidence *incidence = 0);
368 void schedule_add(Incidence *incidence = 0); 369 void schedule_add(Incidence *incidence = 0);
369 void schedule_reply(Incidence *incidence = 0); 370 void schedule_reply(Incidence *incidence = 0);
370 void schedule_counter(Incidence *incidence = 0); 371 void schedule_counter(Incidence *incidence = 0);
371 void schedule_declinecounter(Incidence *incidence = 0); 372 void schedule_declinecounter(Incidence *incidence = 0);
372 void schedule_publish_freebusy(int daysToPublish = 30); 373 void schedule_publish_freebusy(int daysToPublish = 30);
373 374
374 void openAddressbook(); 375 void openAddressbook();
375 376
376 void editFilters(); 377 void editFilters();
377 void toggleFilerEnabled(); 378 void toggleFilerEnabled();
378 379
379 void toggleFilter(); 380 void toggleFilter();
380 void showFilter(bool visible); 381 void showFilter(bool visible);
381 void updateFilter(); 382 void updateFilter();
382 void filterEdited(); 383 void filterEdited();
383 void selectFilter( int ); 384 void selectFilter( int );
384 385
385 void showIntro(); 386 void showIntro();
386 387
387 /** Move the curdatepient view date to today */ 388 /** Move the curdatepient view date to today */
388 void goToday(); 389 void goToday();
389 390
390 /** Move to the next date(s) in the current view */ 391 /** Move to the next date(s) in the current view */
391 void goNext(); 392 void goNext();
392 393
393 /** Move to the previous date(s) in the current view */ 394 /** Move to the previous date(s) in the current view */
394 void goPrevious(); 395 void goPrevious();
395 /** Move to the next date(s) in the current view */ 396 /** Move to the next date(s) in the current view */
396 void goNextMonth(); 397 void goNextMonth();
397 398
398 /** Move to the previous date(s) in the current view */ 399 /** Move to the previous date(s) in the current view */
399 void goPreviousMonth(); 400 void goPreviousMonth();
400 401
401 void toggleExpand(); 402 void toggleExpand();
402 void toggleDateNavigatorWidget(); 403 void toggleDateNavigatorWidget();
403 void toggleAllDaySize(); 404 void toggleAllDaySize();
404 void dialogClosing(Incidence *); 405 void dialogClosing(Incidence *);
405 406
406 /** Look for new messages in the inbox */ 407 /** Look for new messages in the inbox */
407 void lookForIncomingMessages(); 408 void lookForIncomingMessages();
408 /** Look for new messages in the outbox */ 409 /** Look for new messages in the outbox */
409 void lookForOutgoingMessages(); 410 void lookForOutgoingMessages();
410 411
411 void processMainViewSelection( Incidence * ); 412 void processMainViewSelection( Incidence * );
412 void processTodoListSelection( Incidence * ); 413 void processTodoListSelection( Incidence * );
413 414
414 void processIncidenceSelection( Incidence * ); 415 void processIncidenceSelection( Incidence * );
415 416
416 void purgeCompleted(); 417 void purgeCompleted();
417 bool removeCompletedSubTodos( Todo* ); 418 bool removeCompletedSubTodos( Todo* );
418 void slotCalendarChanged(); 419 void slotCalendarChanged();
419 bool importBday(); 420 bool importBday();
420 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday ); 421 bool addAnniversary( QDate data, QString name, KCal::Attendee* a , bool birthday );
421 bool importQtopia( const QString &categoriesFile, 422 bool importQtopia( const QString &categoriesFile,
422 const QString &datebookFile, 423 const QString &datebookFile,
423 const QString &tasklistFile ); 424 const QString &tasklistFile );
424 void syncSharp( ); 425 void syncSharp( );
425 void slotSelectPickerDate( QDate ) ; 426 void slotSelectPickerDate( QDate ) ;
426 void showDatePicker( ) ; 427 void showDatePicker( ) ;
427 void moveIncidence(Incidence *) ; 428 void moveIncidence(Incidence *) ;
428 void beamIncidence(Incidence *) ; 429 void beamIncidence(Incidence *) ;
429 void beamCalendar() ; 430 void beamCalendar() ;
430 void beamFilteredCalendar() ; 431 void beamFilteredCalendar() ;
431 void beamIncidenceList(QPtrList<Incidence>) ; 432 void beamIncidenceList(QPtrList<Incidence>) ;
432 void manageCategories(); 433 void manageCategories();
433 int addCategories(); 434 int addCategories();
434 void removeCategories(); 435 void removeCategories();
435 void setSyncDevice( QString ); 436 void setSyncDevice( QString );
436 void setSyncName( QString ); 437 void setSyncName( QString );
437 protected slots: 438 protected slots:
438 void timerAlarm(); 439 void timerAlarm();
439 void suspendAlarm(); 440 void suspendAlarm();
440 void beamDone( Ir *ir ); 441 void beamDone( Ir *ir );
441 /** Select a view or adapt the current view to display the specified dates. */ 442 /** Select a view or adapt the current view to display the specified dates. */
442 void showDates( const KCal::DateList & ); 443 void showDates( const KCal::DateList & );
443 void selectWeekNum ( int ); 444 void selectWeekNum ( int );
444 445
445 public: 446 public:
446 // show a standard warning 447 // show a standard warning
447 // returns KMsgBox::yesNoCancel() 448 // returns KMsgBox::yesNoCancel()
448 int msgCalModified(); 449 int msgCalModified();
449 void confSync(); 450 void confSync();
450 void setLoadedFileVersion(QDateTime); 451 void setLoadedFileVersion(QDateTime);
451 bool checkFileVersion(QString fn); 452 bool checkFileVersion(QString fn);
452 bool checkFileChanged(QString fn); 453 bool checkFileChanged(QString fn);
453 Event* getLastSyncEvent(); 454 Event* getLastSyncEvent();
454 /** Adapt navigation units correpsonding to step size of navigation of the 455 /** Adapt navigation units correpsonding to step size of navigation of the
455 * current view. 456 * current view.
456 */ 457 */
457 void adaptNavigationUnits(); 458 void adaptNavigationUnits();
458 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode ); 459 bool synchronizeCalendar( Calendar* local, Calendar* remote, int mode );
459 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false ); 460 int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false );
460 //Attendee* getYourAttendee(Event *event); 461 //Attendee* getYourAttendee(Event *event);
461 protected: 462 protected:
462 void schedule(Scheduler::Method, Incidence *incidence = 0); 463 void schedule(Scheduler::Method, Incidence *incidence = 0);
463 464
464 // returns KMsgBox::OKCandel() 465 // returns KMsgBox::OKCandel()
465 int msgItemDelete(); 466 int msgItemDelete();
466 void showEventEditor(); 467 void showEventEditor();
467 void showTodoEditor(); 468 void showTodoEditor();
468 void writeLocale(); 469 void writeLocale();
469 Todo *selectedTodo(); 470 Todo *selectedTodo();
470 471
471 private: 472 private:
472 AlarmDialog * mAlarmDialog; 473 AlarmDialog * mAlarmDialog;
473 QString mAlarmNotification; 474 QString mAlarmNotification;
474 QString mSuspendAlarmNotification; 475 QString mSuspendAlarmNotification;
475 QTimer* mSuspendTimer; 476 QTimer* mSuspendTimer;
476 QTimer* mAlarmTimer; 477 QTimer* mAlarmTimer;
478 QTimer* mRecheckAlarmTimer;
477 void computeAlarm( QString ); 479 void computeAlarm( QString );
478 void startAlarm( QString, QString ); 480 void startAlarm( QString, QString );
479 void setSyncEventsReadOnly(); 481 void setSyncEventsReadOnly();
480 482
481 QDateTime loadedFileVersion; 483 QDateTime loadedFileVersion;
482 void checkSharpEvent( Event* lastSync, Incidence* toDelete ); 484 void checkSharpEvent( Event* lastSync, Incidence* toDelete );
483 QPtrList<KSyncProfile> mSyncProfiles; 485 QPtrList<KSyncProfile> mSyncProfiles;
484 QStringList mSyncProfileNames; 486 QStringList mSyncProfileNames;
485 void checkZaurusId( int id, bool todo = false ); 487 void checkZaurusId( int id, bool todo = false );
486 int mGlobalSyncMode; 488 int mGlobalSyncMode;
487 QString mCurrentSyncDevice; 489 QString mCurrentSyncDevice;
488 QString mCurrentSyncName; 490 QString mCurrentSyncName;
489 KOBeamPrefs* beamDialog; 491 KOBeamPrefs* beamDialog;
490 void init(); 492 void init();
491 int mDatePickerMode; 493 int mDatePickerMode;
492 bool mFlagEditDescription; 494 bool mFlagEditDescription;
493 QDateTime mLastCalendarSync; 495 QDateTime mLastCalendarSync;
494 void createPrinter(); 496 void createPrinter();
495 497
496 void calendarModified( bool, Calendar * ); 498 void calendarModified( bool, Calendar * );
497 499
498 CalPrinter *mCalPrinter; 500 CalPrinter *mCalPrinter;
499 501
500 QSplitter *mPanner; 502 QSplitter *mPanner;
501 QSplitter *mLeftSplitter; 503 QSplitter *mLeftSplitter;
502 QWidget *mLeftFrame; 504 QWidget *mLeftFrame;
503 QWidgetStack *mRightFrame; 505 QWidgetStack *mRightFrame;
504 506
505 KDatePicker* mDatePicker; 507 KDatePicker* mDatePicker;
506 QVBox* mDateFrame; 508 QVBox* mDateFrame;
507 NavigatorBar *mNavigatorBar; 509 NavigatorBar *mNavigatorBar;
508 510
509 KDateNavigator *mDateNavigator; // widget showing small month view. 511 KDateNavigator *mDateNavigator; // widget showing small month view.
510 512
511 KOFilterView *mFilterView; 513 KOFilterView *mFilterView;
512 514
513 ResourceView *mResourceView; 515 ResourceView *mResourceView;
514 516
515 // calendar object for this viewing instance 517 // calendar object for this viewing instance
516 Calendar *mCalendar; 518 Calendar *mCalendar;
517 519
518 CalendarResourceManager *mResourceManager; 520 CalendarResourceManager *mResourceManager;
519 521
520 FileStorage *mStorage; 522 FileStorage *mStorage;
521 523
522 DateNavigator *mNavigator; 524 DateNavigator *mNavigator;
523 525
524 KOViewManager *mViewManager; 526 KOViewManager *mViewManager;
525 KODialogManager *mDialogManager; 527 KODialogManager *mDialogManager;
526 528
527 // Calendar filters 529 // Calendar filters
528 QPtrList<CalFilter> mFilters; 530 QPtrList<CalFilter> mFilters;
529 531
530 // various housekeeping variables. 532 // various housekeeping variables.
531 bool mModified; // flag indicating if calendar is modified 533 bool mModified; // flag indicating if calendar is modified
532 bool mReadOnly; // flag indicating if calendar is read-only 534 bool mReadOnly; // flag indicating if calendar is read-only
533 QDate mSaveSingleDate; 535 QDate mSaveSingleDate;
534 536
535 Incidence *mSelectedIncidence; 537 Incidence *mSelectedIncidence;
536 Incidence *mMoveIncidence; 538 Incidence *mMoveIncidence;
537 539
538 KOTodoView *mTodoList; 540 KOTodoView *mTodoList;
539 KOEventEditor * mEventEditor; 541 KOEventEditor * mEventEditor;
540 KOTodoEditor * mTodoEditor; 542 KOTodoEditor * mTodoEditor;
541 KOEventViewerDialog * mEventViewerDialog; 543 KOEventViewerDialog * mEventViewerDialog;
542 void keyPressEvent ( QKeyEvent *e) ; 544 void keyPressEvent ( QKeyEvent *e) ;
543 //QMap<Incidence*,KOIncidenceEditor*> mDialogList; 545 //QMap<Incidence*,KOIncidenceEditor*> mDialogList;
544}; 546};
545 547
546 548
547class CalendarViewVisitor : public Incidence::Visitor 549class CalendarViewVisitor : public Incidence::Visitor
548{ 550{
549 public: 551 public:
550 CalendarViewVisitor() : mView( 0 ) {} 552 CalendarViewVisitor() : mView( 0 ) {}
551 553
552 bool act( Incidence *incidence, CalendarView *view ) 554 bool act( Incidence *incidence, CalendarView *view )
553 { 555 {
554 mView = view; 556 mView = view;
555 return incidence->accept( *this ); 557 return incidence->accept( *this );
556 } 558 }
557 559
558 protected: 560 protected:
559 CalendarView *mView; 561 CalendarView *mView;
560}; 562};
561 563
562class ShowIncidenceVisitor : public CalendarViewVisitor 564class ShowIncidenceVisitor : public CalendarViewVisitor
563{ 565{
564 protected: 566 protected:
565 bool visit( Event *event ) { mView->showEvent( event ); return true; } 567 bool visit( Event *event ) { mView->showEvent( event ); return true; }
566 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; } 568 bool visit( Todo *todo ) { mView->showTodo( todo ); return true; }
567 bool visit( Journal * j ) { mView->showJournal( j );return true; } 569 bool visit( Journal * j ) { mView->showJournal( j );return true; }
568}; 570};
569 571
570class EditIncidenceVisitor : public CalendarViewVisitor 572class EditIncidenceVisitor : public CalendarViewVisitor
571{ 573{
572 protected: 574 protected:
573 bool visit( Event *event ) { mView->editEvent( event ); return true; } 575 bool visit( Event *event ) { mView->editEvent( event ); return true; }
574 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; } 576 bool visit( Todo *todo ) { mView->editTodo( todo ); return true; }
575 bool visit( Journal *j ) { mView->editJournal( j); return true; } 577 bool visit( Journal *j ) { mView->editJournal( j); return true; }
576}; 578};
577 579
578class DeleteIncidenceVisitor : public CalendarViewVisitor 580class DeleteIncidenceVisitor : public CalendarViewVisitor
579{ 581{
580 protected: 582 protected:
581 bool visit( Event *event ) { mView->deleteEvent( event ); return true; } 583 bool visit( Event *event ) { mView->deleteEvent( event ); return true; }
582 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; } 584 bool visit( Todo *todo ) { mView->deleteTodo( todo ); return true; }
583 bool visit( Journal * j) {mView->deleteJournal( j ); return true; } 585 bool visit( Journal * j) {mView->deleteJournal( j ); return true; }
584}; 586};
585 587
586#endif 588#endif
diff --git a/korganizer/koeventviewer.cpp b/korganizer/koeventviewer.cpp
index bac66d3..1f69700 100644
--- a/korganizer/koeventviewer.cpp
+++ b/korganizer/koeventviewer.cpp
@@ -1,509 +1,541 @@
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 19
20#include <qcstring.h> 20#include <qcstring.h>
21#include <qwhatsthis.h> 21#include <qwhatsthis.h>
22#include <qdialog.h> 22#include <qdialog.h>
23#include <qapplication.h> 23#include <qapplication.h>
24#include <qlabel.h> 24#include <qlabel.h>
25#include <qlayout.h> 25#include <qlayout.h>
26 26
27#include <klocale.h> 27#include <klocale.h>
28#include <kapplication.h> 28#include <kapplication.h>
29#include <libkcal/event.h> 29#include <libkcal/event.h>
30#include <libkcal/todo.h> 30#include <libkcal/todo.h>
31#include <kdebug.h> 31#include <kdebug.h>
32#include <kiconloader.h> 32#include <kiconloader.h>
33#include <krun.h> 33#include <krun.h>
34#include <kglobal.h> 34#include <kglobal.h>
35#include <kprocess.h> 35#include <kprocess.h>
36#include "koprefs.h" 36#include "koprefs.h"
37 37
38#include <libkdepim/addresseeview.h> 38#include <libkdepim/addresseeview.h>
39#include <kabc/stdaddressbook.h> 39#include <kabc/stdaddressbook.h>
40 40
41#ifndef KORG_NODCOP 41#ifndef KORG_NODCOP
42#include <dcopclient.h> 42#include <dcopclient.h>
43#include "korganizer.h" 43#include "korganizer.h"
44#include "koprefs.h" 44#include "koprefs.h"
45#include "actionmanager.h" 45#include "actionmanager.h"
46#endif 46#endif
47 47
48#include "koeventviewer.h" 48#include "koeventviewer.h"
49#ifndef KORG_NOKABC 49#ifndef KORG_NOKABC
50#include <kabc/stdaddressbook.h> 50#include <kabc/stdaddressbook.h>
51#define size count 51#define size count
52#endif 52#endif
53#ifndef DESKTOP_VERSION
54#include <qtopia/qcopenvelope_qws.h>
55#endif
56
53KOEventViewer::KOEventViewer(QWidget *parent,const char *name) 57KOEventViewer::KOEventViewer(QWidget *parent,const char *name)
54 : QTextBrowser(parent,name) 58 : QTextBrowser(parent,name)
55{ 59{
56 mSyncMode = false; 60 mSyncMode = false;
57 mColorMode = 0; 61 mColorMode = 0;
58} 62}
59 63
60KOEventViewer::~KOEventViewer() 64KOEventViewer::~KOEventViewer()
61{ 65{
62} 66}
63 67
64void KOEventViewer::setSource(const QString& n) 68void KOEventViewer::setSource(const QString& n)
65{ 69{
66 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 70
67 KABC::AddressBook::Iterator it; 71 if ( n.left(3) == "uid" ) {
68 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 72 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
69 // LR I do not understand, why the uid string is different on zaurus and desktop 73 KABC::AddressBook::Iterator it;
74 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
75 // LR I do not understand, why the uid string is different on zaurus and desktop
70#ifdef DESKTOP_VERSION 76#ifdef DESKTOP_VERSION
71 QString uid = "uid://"+(*it).uid(); 77 QString uid = "uid://"+(*it).uid();
72#else 78#else
73 QString uid = "uid:"+(*it).uid(); 79 QString uid = "uid:"+(*it).uid();
74#endif 80#endif
75 //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1()); 81 //qDebug("for *%s* +%s+ ", n.latin1(), uid.latin1());
76 if (n == uid ) { 82 if (n == uid ) {
77 //qDebug("found %s ",(*it).mobileHomePhone().latin1() ); 83 //qDebug("found %s ",(*it).mobileHomePhone().latin1() );
78 QDialog dia( this,"dia123", true ); 84 QDialog dia( this,"dia123", true );
79 dia.setCaption( i18n("Details of attendee") ); 85 dia.setCaption( i18n("Details of attendee") );
80 QVBoxLayout lay ( &dia ); 86 QVBoxLayout lay ( &dia );
81 KPIM::AddresseeView av ( &dia ); 87 KPIM::AddresseeView av ( &dia );
82 av.setAddressee( (*it) ); 88 av.setAddressee( (*it) );
83 lay.addWidget( &av ); 89 lay.addWidget( &av );
84 if ( QApplication::desktop()->width() < 480 ) 90 if ( QApplication::desktop()->width() < 480 )
85 dia.resize( 220, 240); 91 dia.resize( 220, 240);
86 else { 92 else {
87 dia.resize( 400,400); 93 dia.resize( 400,400);
88 94
95 }
96 dia.exec();
97 break;
98 }
89 } 99 }
90 dia.exec(); 100 return;
91 break; 101 }
92 } 102 if ( n.left(6) == "mailto" ) {
93 } 103 // qDebug("KOEventViewer::setSource %s ", n.mid(7).latin1());
104#ifndef DESKTOP_VERSION
105 QCopEnvelope e("QPE/Application/kmpi", "newMail(QString)" );
106 e << n.mid(7);
107#endif
108
109 }
94 110
95 111
96#ifndef KORG_NODCOP 112#ifndef KORG_NODCOP
97 kdDebug() << "KOEventViewer::setSource(): " << n << endl; 113 kdDebug() << "KOEventViewer::setSource(): " << n << endl;
98 QString tmpStr; 114 QString tmpStr;
99 if (n.startsWith("mailto:")) { 115 if (n.startsWith("mailto:")) {
100 KApplication::kApplication()->invokeMailer(n.mid(7),QString::null); 116 KApplication::kApplication()->invokeMailer(n.mid(7),QString::null);
101 //emit showIncidence(n); 117 //emit showIncidence(n);
102 return; 118 return;
103 } else if (n.startsWith("uid:")) { 119 } else if (n.startsWith("uid:")) {
104 DCOPClient *client = KApplication::kApplication()->dcopClient(); 120 DCOPClient *client = KApplication::kApplication()->dcopClient();
105 const QByteArray noParamData; 121 const QByteArray noParamData;
106 const QByteArray paramData; 122 const QByteArray paramData;
107 QByteArray replyData; 123 QByteArray replyData;
108 QCString replyTypeStr; 124 QCString replyTypeStr;
109#define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData)) 125#define PING_ABBROWSER (client->call("kaddressbook", "KAddressBookIface", "interfaces()", noParamData, replyTypeStr, replyData))
110 bool foundAbbrowser = PING_ABBROWSER; 126 bool foundAbbrowser = PING_ABBROWSER;
111 127
112 if (foundAbbrowser) { 128 if (foundAbbrowser) {
113 //KAddressbook is already running, so just DCOP to it to bring up the contact editor 129 //KAddressbook is already running, so just DCOP to it to bring up the contact editor
114 //client->send("kaddressbook","KAddressBookIface", 130 //client->send("kaddressbook","KAddressBookIface",
115 QDataStream arg(paramData, IO_WriteOnly); 131 QDataStream arg(paramData, IO_WriteOnly);
116 arg << n.mid(6); 132 arg << n.mid(6);
117 client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData); 133 client->send("kaddressbook", "KAddressBookIface", "showContactEditor( QString )", paramData);
118 return; 134 return;
119 } else { 135 } else {
120 /* 136 /*
121 KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater. 137 KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater.
122 We start it without its main interface 138 We start it without its main interface
123 */ 139 */
124 KIconLoader* iconLoader = new KIconLoader(); 140 KIconLoader* iconLoader = new KIconLoader();
125 QString iconPath = iconLoader->iconPath("go",KIcon::Small); 141 QString iconPath = iconLoader->iconPath("go",KIcon::Small);
126 ActionManager::setStartedKAddressBook(true); 142 ActionManager::setStartedKAddressBook(true);
127 tmpStr = "kaddressbook --editor-only --uid "; 143 tmpStr = "kaddressbook --editor-only --uid ";
128 tmpStr += KProcess::quote(n.mid(6)); 144 tmpStr += KProcess::quote(n.mid(6));
129 KRun::runCommand(tmpStr,"KAddressBook",iconPath); 145 KRun::runCommand(tmpStr,"KAddressBook",iconPath);
130 return; 146 return;
131 } 147 }
132 } else { 148 } else {
133 //QTextBrowser::setSource(n); 149 //QTextBrowser::setSource(n);
134 } 150 }
135#endif 151#endif
136} 152}
137 153
138void KOEventViewer::addTag(const QString & tag,const QString & text) 154void KOEventViewer::addTag(const QString & tag,const QString & text)
139{ 155{
140 int number=text.contains("\n"); 156 int number=text.contains("\n");
141 QString str = "<" + tag + ">"; 157 QString str = "<" + tag + ">";
142 QString tmpText=text; 158 QString tmpText=text;
143 QString tmpStr=str; 159 QString tmpStr=str;
144 if(number !=-1) 160 if(number !=-1)
145 { 161 {
146 if (number > 0) { 162 if (number > 0) {
147 int pos=0; 163 int pos=0;
148 QString tmp; 164 QString tmp;
149 for(int i=0;i<=number;i++) { 165 for(int i=0;i<=number;i++) {
150 pos=tmpText.find("\n"); 166 pos=tmpText.find("\n");
151 tmp=tmpText.left(pos); 167 tmp=tmpText.left(pos);
152 tmpText=tmpText.right(tmpText.length()-pos-1); 168 tmpText=tmpText.right(tmpText.length()-pos-1);
153 tmpStr+=tmp+"<br>"; 169 tmpStr+=tmp+"<br>";
154 } 170 }
155 } 171 }
156 else tmpStr += tmpText; 172 else tmpStr += tmpText;
157 tmpStr+="</" + tag + ">"; 173 tmpStr+="</" + tag + ">";
158 mText.append(tmpStr); 174 mText.append(tmpStr);
159 } 175 }
160 else 176 else
161 { 177 {
162 str += text + "</" + tag + ">"; 178 str += text + "</" + tag + ">";
163 mText.append(str); 179 mText.append(str);
164 } 180 }
165} 181}
166 182
167void KOEventViewer::setColorMode( int m ) 183void KOEventViewer::setColorMode( int m )
168{ 184{
169 mColorMode = m; 185 mColorMode = m;
170} 186}
171void KOEventViewer::appendEvent(Event *event, int mode ) 187void KOEventViewer::appendEvent(Event *event, int mode )
172{ 188{
189 mMailSubject = "";
173 mCurrentIncidence = event; 190 mCurrentIncidence = event;
174 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 191 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
175 topLevelWidget()->setCaption(i18n("Event Viewer")); 192 topLevelWidget()->setCaption(i18n("Event Viewer"));
176 if ( mode == 0 ) { 193 if ( mode == 0 ) {
177 addTag("h2",event->summary()); 194 addTag("h2",event->summary());
178 } 195 }
179 else { 196 else {
180 if ( mColorMode == 1 ) { 197 if ( mColorMode == 1 ) {
181 mText +="<font color=\"#00A000\">"; 198 mText +="<font color=\"#00A000\">";
182 } 199 }
183 if ( mColorMode == 2 ) { 200 if ( mColorMode == 2 ) {
184 mText +="<font color=\"#C00000\">"; 201 mText +="<font color=\"#C00000\">";
185 } 202 }
186 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; 203 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>";
187 if ( mode == 1 ) { 204 if ( mode == 1 ) {
188 addTag("h2",i18n( "Local: " ) +event->summary()); 205 addTag("h2",i18n( "Local: " ) +event->summary());
189 } else { 206 } else {
190 addTag("h2",i18n( "Remote: " ) +event->summary()); 207 addTag("h2",i18n( "Remote: " ) +event->summary());
191 } 208 }
192 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); 209 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
193 if ( mColorMode ) 210 if ( mColorMode )
194 mText += "</font>"; 211 mText += "</font>";
195 } 212 }
213 mMailSubject += i18n( "Meeting " )+ event->summary();
196 if (event->cancelled ()) { 214 if (event->cancelled ()) {
197 mText +="<font color=\"#B00000\">"; 215 mText +="<font color=\"#B00000\">";
198 addTag("i",i18n("This event has been cancelled!")); 216 addTag("i",i18n("This event has been cancelled!"));
199 mText.append("<br>"); 217 mText.append("<br>");
200 mText += "</font>"; 218 mText += "</font>";
219 mMailSubject += i18n("(cancelled)");
201 } 220 }
202 if (!event->location().isEmpty()) { 221 if (!event->location().isEmpty()) {
203 addTag("b",i18n("Location: ")); 222 addTag("b",i18n("Location: "));
204 mText.append(event->location()+"<br>"); 223 mText.append(event->location()+"<br>");
224 mMailSubject += i18n(" at ") + event->location();
205 } 225 }
206 if (event->doesFloat()) { 226 if (event->doesFloat()) {
207 if (event->isMultiDay()) { 227 if (event->isMultiDay()) {
208 mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") 228 mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>")
209 .arg(event->dtStartDateStr(shortDate)) 229 .arg(event->dtStartDateStr(shortDate))
210 .arg(event->dtEndDateStr(shortDate))); 230 .arg(event->dtEndDateStr(shortDate)));
211 } else { 231 } else {
212 mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); 232 mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate )));
213 } 233 }
214 } else { 234 } else {
215 if (event->isMultiDay()) { 235 if (event->isMultiDay()) {
216 mText.append(i18n("<p><b>From:</b> %1</p> ") 236 mText.append(i18n("<p><b>From:</b> %1</p> ")
217 .arg(event->dtStartStr( shortDate))); 237 .arg(event->dtStartStr( shortDate)));
218 mText.append(i18n("<p><b>To:</b> %1</p>") 238 mText.append(i18n("<p><b>To:</b> %1</p>")
219 .arg(event->dtEndStr(shortDate))); 239 .arg(event->dtEndStr(shortDate)));
220 } else { 240 } else {
221 mText.append(i18n("<p><b>On:</b> %1</p> ") 241 mText.append(i18n("<p><b>On:</b> %1</p> ")
222 .arg(event->dtStartDateStr( shortDate ))); 242 .arg(event->dtStartDateStr( shortDate )));
223 mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") 243 mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>")
224 .arg(event->dtStartTimeStr()) 244 .arg(event->dtStartTimeStr())
225 .arg(event->dtEndTimeStr())); 245 .arg(event->dtEndTimeStr()));
226 } 246 }
227 } 247 }
228 248
229 if (event->recurrence()->doesRecur()) { 249 if (event->recurrence()->doesRecur()) {
230 250
231 QString recurText = event->recurrence()->recurrenceText(); 251 QString recurText = event->recurrence()->recurrenceText();
232 addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); 252 addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>");
233 bool last; 253 bool last;
234 QDate start = QDate::currentDate(); 254 QDate start = QDate::currentDate();
235 QDate next; 255 QDate next;
236 next = event->recurrence()->getPreviousDate( start , &last ); 256 next = event->recurrence()->getPreviousDate( start , &last );
237 if ( !last ) { 257 if ( !last ) {
238 next = event->recurrence()->getNextDate( start.addDays( - 1 ) ); 258 next = event->recurrence()->getNextDate( start.addDays( - 1 ) );
239 addTag("p",i18n("<b>Next recurrence is on:</b>") ); 259 addTag("p",i18n("<b>Next recurrence is on:</b>") );
240 addTag("p", KGlobal::locale()->formatDate( next, shortDate )); 260 addTag("p", KGlobal::locale()->formatDate( next, shortDate ));
261 QDateTime nextdt = QDateTime( next, event->dtStart().time());
262 mMailSubject += i18n(" - " )+ KGlobal::locale()->formatDateTime( nextdt, true );
263
241 } else { 264 } else {
242 addTag("p",i18n("<b>Last recurrence was on:</b>") ); 265 addTag("p",i18n("<b>Last recurrence was on:</b>") );
243 addTag("p", KGlobal::locale()->formatDate( next, shortDate )); 266 addTag("p", KGlobal::locale()->formatDate( next, shortDate ));
244 } 267 }
268 } else {
269 mMailSubject += i18n(" - " )+event->dtStartStr( true );
270
245 } 271 }
246 272
247 273
248 if (event->isAlarmEnabled()) { 274 if (event->isAlarmEnabled()) {
249 Alarm *alarm =event->alarms().first() ; 275 Alarm *alarm =event->alarms().first() ;
250 QDateTime t = alarm->time(); 276 QDateTime t = alarm->time();
251 int min = t.secsTo( event->dtStart() )/60; 277 int min = t.secsTo( event->dtStart() )/60;
252 QString s =i18n("( %1 min before )").arg( min ); 278 QString s =i18n("( %1 min before )").arg( min );
253 addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); 279 addTag("p",i18n("<b>Alarm on: ") + s +" </b>");
254 addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); 280 addTag("p", KGlobal::locale()->formatDateTime( t, shortDate ));
255 //addTag("p",s); 281 //addTag("p",s);
256 } 282 }
257 283
258 addTag("b",i18n("Access: ")); 284 addTag("b",i18n("Access: "));
259 mText.append(event->secrecyStr()+"<br>"); 285 mText.append(event->secrecyStr()+"<br>");
260 if (!event->description().isEmpty()) { 286 if (!event->description().isEmpty()) {
261 addTag("p",i18n("<b>Details: </b>")); 287 addTag("p",i18n("<b>Details: </b>"));
262 addTag("p",event->description()); 288 addTag("p",event->description());
263 } 289 }
264 290
265 formatCategories(event); 291 formatCategories(event);
266 292
267 formatReadOnly(event); 293 formatReadOnly(event);
268 formatAttendees(event); 294 formatAttendees(event);
269 295
270 setText(mText); 296 setText(mText);
271 //QWhatsThis::add(this,mText); 297 //QWhatsThis::add(this,mText);
272 298
273} 299}
274 300
275void KOEventViewer::appendTodo(Todo *event, int mode ) 301void KOEventViewer::appendTodo(Todo *event, int mode )
276{ 302{
303 mMailSubject = "";
277 mCurrentIncidence = event; 304 mCurrentIncidence = event;
278 topLevelWidget()->setCaption(i18n("Todo Viewer")); 305 topLevelWidget()->setCaption(i18n("Todo Viewer"));
279 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 306 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
280 if (mode == 0 ) 307 if (mode == 0 )
281 addTag("h2",event->summary()); 308 addTag("h2",event->summary());
282 else { 309 else {
283 if ( mColorMode == 1 ) { 310 if ( mColorMode == 1 ) {
284 mText +="<font color=\"#00A000\">"; 311 mText +="<font color=\"#00A000\">";
285 } 312 }
286 if ( mColorMode == 2 ) { 313 if ( mColorMode == 2 ) {
287 mText +="<font color=\"#B00000\">"; 314 mText +="<font color=\"#B00000\">";
288 } 315 }
289 if ( mode == 1 ) { 316 if ( mode == 1 ) {
290 addTag("h2",i18n( "Local: " ) +event->summary()); 317 addTag("h2",i18n( "Local: " ) +event->summary());
291 } else { 318 } else {
292 addTag("h2",i18n( "Remote: " ) +event->summary()); 319 addTag("h2",i18n( "Remote: " ) +event->summary());
293 } 320 }
294 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); 321 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
295 if ( mColorMode ) 322 if ( mColorMode )
296 mText += "</font>"; 323 mText += "</font>";
297 } 324 }
325 mMailSubject += i18n( "Todo " )+ event->summary();
298 if (event->cancelled ()) { 326 if (event->cancelled ()) {
299 mText +="<font color=\"#B00000\">"; 327 mText +="<font color=\"#B00000\">";
300 addTag("i",i18n("This todo has been cancelled!")); 328 addTag("i",i18n("This todo has been cancelled!"));
301 mText.append("<br>"); 329 mText.append("<br>");
302 mText += "</font>"; 330 mText += "</font>";
331 mMailSubject += i18n("(cancelled)");
303 } 332 }
304 333
305 if (!event->location().isEmpty()) { 334 if (!event->location().isEmpty()) {
306 addTag("b",i18n("Location: ")); 335 addTag("b",i18n("Location: "));
307 mText.append(event->location()+"<br>"); 336 mText.append(event->location()+"<br>");
337 mMailSubject += i18n(" at ") + event->location();
308 } 338 }
309 if (event->hasDueDate()) { 339 if (event->hasDueDate()) {
310 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer))); 340 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(KOPrefs::instance()->mShortDateInViewer)));
341 mMailSubject += i18n(" - " )+event->dtDueStr( true );
311 } 342 }
312 addTag("b",i18n("Access: ")); 343 addTag("b",i18n("Access: "));
313 mText.append(event->secrecyStr()+"<br>"); 344 mText.append(event->secrecyStr()+"<br>");
314 if (!event->description().isEmpty()) { 345 if (!event->description().isEmpty()) {
315 addTag("p",i18n("<b>Details: </b>")); 346 addTag("p",i18n("<b>Details: </b>"));
316 addTag("p",event->description()); 347 addTag("p",event->description());
317 } 348 }
318 349
319 formatCategories(event); 350 formatCategories(event);
320 351
321 mText.append(i18n("<p><b>Priority:</b> %2</p>") 352 mText.append(i18n("<p><b>Priority:</b> %2</p>")
322 .arg(QString::number(event->priority()))); 353 .arg(QString::number(event->priority())));
323 354
324 mText.append(i18n("<p><i>%1 % completed</i></p>") 355 mText.append(i18n("<p><i>%1 % completed</i></p>")
325 .arg(event->percentComplete())); 356 .arg(event->percentComplete()));
326 357
327 formatReadOnly(event); 358 formatReadOnly(event);
328 formatAttendees(event); 359 formatAttendees(event);
329 360
330 setText(mText); 361 setText(mText);
331} 362}
332 363
333void KOEventViewer::formatCategories(Incidence *event) 364void KOEventViewer::formatCategories(Incidence *event)
334{ 365{
335 if (!event->categoriesStr().isEmpty()) { 366 if (!event->categoriesStr().isEmpty()) {
336 if (event->categories().count() == 1) { 367 if (event->categories().count() == 1) {
337 addTag("h3",i18n("Category")); 368 addTag("h3",i18n("Category"));
338 } else { 369 } else {
339 addTag("h3",i18n("Categories")); 370 addTag("h3",i18n("Categories"));
340 } 371 }
341 addTag("p",event->categoriesStr()); 372 addTag("p",event->categoriesStr());
342 } 373 }
343} 374}
344void KOEventViewer::formatAttendees(Incidence *event) 375void KOEventViewer::formatAttendees(Incidence *event)
345{ 376{
346 QPtrList<Attendee> attendees = event->attendees(); 377 QPtrList<Attendee> attendees = event->attendees();
347 if (attendees.count()) { 378 if (attendees.count()) {
348 379
349 380
350 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); 381 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small);
351 addTag("h3",i18n("Organizer")); 382 addTag("h3",i18n("Organizer"));
352 mText.append("<ul><li>"); 383 mText.append("<ul><li>");
353#ifndef KORG_NOKABC 384#ifndef KORG_NOKABC
354 385
355 KABC::AddressBook *add_book = KABC::StdAddressBook::self(); 386 KABC::AddressBook *add_book = KABC::StdAddressBook::self();
356 KABC::Addressee::List addressList; 387 KABC::Addressee::List addressList;
357 addressList = add_book->findByEmail(event->organizer()); 388 addressList = add_book->findByEmail(event->organizer());
358 KABC::Addressee o = addressList.first(); 389 KABC::Addressee o = addressList.first();
359 if (!o.isEmpty() && addressList.size()<2) { 390 if (!o.isEmpty() && addressList.size()<2) {
360 mText += "<a href=\"uid:" + o.uid() + "\">"; 391 mText += "<a href=\"uid:" + o.uid() + "\">";
361 mText += o.formattedName(); 392 mText += o.formattedName();
362 mText += "</a>\n"; 393 mText += "</a>\n";
363 } else { 394 } else {
364 mText.append(event->organizer()); 395 mText.append(event->organizer());
365 } 396 }
366#else 397#else
367 mText.append(event->organizer()); 398 mText.append(event->organizer());
368#endif 399#endif
369 400
370 if (iconPath) { 401 if (iconPath) {
371 mText += " <a href=\"mailto:" + event->organizer() + "\">"; 402 mText += " <a href=\"mailto:" + event->organizer() + "\">";
372 mText += "<IMG src=\"" + iconPath + "\">"; 403 mText += "<IMG src=\"" + iconPath + "\">";
373 mText += "</a>\n"; 404 mText += "</a>\n";
374 } 405 }
375 mText.append("</li></ul>"); 406 mText.append("</li></ul>");
376 407
377 addTag("h3",i18n("Attendees")); 408 addTag("h3",i18n("Attendees"));
378 Attendee *a; 409 Attendee *a;
379 mText.append("<ul>"); 410 mText.append("<ul>");
380 for(a=attendees.first();a;a=attendees.next()) { 411 for(a=attendees.first();a;a=attendees.next()) {
381#ifndef KORG_NOKABC 412#ifndef KORG_NOKABC
382 if (a->name().isEmpty()) { 413 if (a->name().isEmpty()) {
383 addressList = add_book->findByEmail(a->email()); 414 addressList = add_book->findByEmail(a->email());
384 KABC::Addressee o = addressList.first(); 415 KABC::Addressee o = addressList.first();
385 if (!o.isEmpty() && addressList.size()<2) { 416 if (!o.isEmpty() && addressList.size()<2) {
386 mText += "<a href=\"uid:" + o.uid() + "\">"; 417 mText += "<a href=\"uid:" + o.uid() + "\">";
387 mText += o.formattedName(); 418 mText += o.formattedName();
388 mText += "</a>\n"; 419 mText += "</a>\n";
389 } else { 420 } else {
390 mText += "<li>"; 421 mText += "<li>";
391 mText.append(a->email()); 422 mText.append(a->email());
392 mText += "\n"; 423 mText += "\n";
393 } 424 }
394 } else { 425 } else {
395 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 426 mText += "<li><a href=\"uid:" + a->uid() + "\">";
396 if (!a->name().isEmpty()) mText += a->name(); 427 if (!a->name().isEmpty()) mText += a->name();
397 else mText += a->email(); 428 else mText += a->email();
398 mText += "</a>\n"; 429 mText += "</a>\n";
399 } 430 }
400#else 431#else
401 //qDebug("nokabc "); 432 //qDebug("nokabc ");
402 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 433 mText += "<li><a href=\"uid:" + a->uid() + "\">";
403 if (!a->name().isEmpty()) mText += a->name(); 434 if (!a->name().isEmpty()) mText += a->name();
404 else mText += a->email(); 435 else mText += a->email();
405 mText += "</a>\n"; 436 mText += "</a>\n";
406#endif 437#endif
407 438
439
408 if (!a->email().isEmpty()) { 440 if (!a->email().isEmpty()) {
409 if (iconPath) { 441 if (iconPath) {
410 mText += "<a href=\"mailto:" + a->name() +" "+ "<" + a->email() + ">" + "\">"; 442 mText += "<a href=\"mailto:" + a->name() +" <" + a->email() + ">:" + mMailSubject + "\">";
411 mText += "<IMG src=\"" + iconPath + "\">"; 443 mText += "<IMG src=\"" + iconPath + "\">";
412 mText += "</a>\n"; 444 mText += "</a>\n";
413 } 445 }
414 } 446 }
415 if (a->status() != Attendee::NeedsAction ) 447 if (a->status() != Attendee::NeedsAction )
416 mText +="[" + a->statusStr() + "] "; 448 mText +="[" + a->statusStr() + "] ";
417 if (a->role() == Attendee::Chair ) 449 if (a->role() == Attendee::Chair )
418 mText +="(" + a->roleStr().left(1) + ".)"; 450 mText +="(" + a->roleStr().left(1) + ".)";
419 } 451 }
420 mText.append("</li></ul>"); 452 mText.append("</li></ul>");
421 } 453 }
422 454
423} 455}
424void KOEventViewer::appendJournal(Journal *jour, int mode ) 456void KOEventViewer::appendJournal(Journal *jour, int mode )
425{ 457{
426 bool shortDate = KOPrefs::instance()->mShortDateInViewer; 458 bool shortDate = KOPrefs::instance()->mShortDateInViewer;
427 if (mode == 0 ) 459 if (mode == 0 )
428 addTag("h2",i18n("Journal from: ")); 460 addTag("h2",i18n("Journal from: "));
429 else { 461 else {
430 if ( mode == 1 ) { 462 if ( mode == 1 ) {
431 addTag("h2",i18n( "Local: " ) +i18n("Journal from: ")); 463 addTag("h2",i18n( "Local: " ) +i18n("Journal from: "));
432 } else { 464 } else {
433 addTag("h2",i18n( "Remote: " ) +i18n("Journal from: ")); 465 addTag("h2",i18n( "Remote: " ) +i18n("Journal from: "));
434 } 466 }
435 addTag("h3",i18n( "Last modified " ) + KGlobal::locale()->formatDateTime(jour->lastModified(),shortDate ) ); 467 addTag("h3",i18n( "Last modified " ) + KGlobal::locale()->formatDateTime(jour->lastModified(),shortDate ) );
436 } 468 }
437 topLevelWidget()->setCaption("Journal Viewer"); 469 topLevelWidget()->setCaption("Journal Viewer");
438 mText.append(i18n("<h3> %1 </h3> ").arg(jour->dtStartDateStr(KOPrefs::instance()->mShortDateInViewer))); 470 mText.append(i18n("<h3> %1 </h3> ").arg(jour->dtStartDateStr(KOPrefs::instance()->mShortDateInViewer)));
439 if (!jour->description().isEmpty()) { 471 if (!jour->description().isEmpty()) {
440 addTag("p",jour->description()); 472 addTag("p",jour->description());
441 } 473 }
442 setText(mText); 474 setText(mText);
443} 475}
444 476
445void KOEventViewer::formatReadOnly(Incidence *event) 477void KOEventViewer::formatReadOnly(Incidence *event)
446{ 478{
447 if (event->isReadOnly()) { 479 if (event->isReadOnly()) {
448 addTag("p","<em>(" + i18n("read-only") + ")</em>"); 480 addTag("p","<em>(" + i18n("read-only") + ")</em>");
449 } 481 }
450} 482}
451void KOEventViewer::setSyncMode( bool b ) 483void KOEventViewer::setSyncMode( bool b )
452{ 484{
453 mSyncMode = b; 485 mSyncMode = b;
454} 486}
455 487
456 488
457void KOEventViewer::setTodo(Todo *event, bool clearV ) 489void KOEventViewer::setTodo(Todo *event, bool clearV )
458{ 490{
459 if ( clearV ) 491 if ( clearV )
460 clearEvents(); 492 clearEvents();
461 if ( mSyncMode ) { 493 if ( mSyncMode ) {
462 if ( clearV ) 494 if ( clearV )
463 appendTodo(event,1 ); 495 appendTodo(event,1 );
464 else 496 else
465 appendTodo(event,2); 497 appendTodo(event,2);
466 } else 498 } else
467 appendTodo(event); 499 appendTodo(event);
468} 500}
469void KOEventViewer::setJournal(Journal *event, bool clearV ) 501void KOEventViewer::setJournal(Journal *event, bool clearV )
470{ 502{
471 if ( clearV ) 503 if ( clearV )
472 clearEvents(); 504 clearEvents();
473 if ( mSyncMode ) { 505 if ( mSyncMode ) {
474 if ( clearV ) 506 if ( clearV )
475 appendJournal(event, 1); 507 appendJournal(event, 1);
476 else 508 else
477 appendJournal(event, 2); 509 appendJournal(event, 2);
478 } else 510 } else
479 appendJournal(event); 511 appendJournal(event);
480} 512}
481 513
482void KOEventViewer::setEvent(Event *event) 514void KOEventViewer::setEvent(Event *event)
483{ 515{
484 clearEvents(); 516 clearEvents();
485 if ( mSyncMode ) 517 if ( mSyncMode )
486 appendEvent(event, 1); 518 appendEvent(event, 1);
487 else 519 else
488 appendEvent(event); 520 appendEvent(event);
489} 521}
490 522
491void KOEventViewer::addEvent(Event *event) 523void KOEventViewer::addEvent(Event *event)
492{ 524{
493 if ( mSyncMode ) 525 if ( mSyncMode )
494 appendEvent(event, 2); 526 appendEvent(event, 2);
495 else 527 else
496 appendEvent(event); 528 appendEvent(event);
497} 529}
498 530
499void KOEventViewer::clearEvents(bool now) 531void KOEventViewer::clearEvents(bool now)
500{ 532{
501 mText = ""; 533 mText = "";
502 if (now) setText(mText); 534 if (now) setText(mText);
503} 535}
504 536
505void KOEventViewer::addText(QString text) 537void KOEventViewer::addText(QString text)
506{ 538{
507 mText.append(text); 539 mText.append(text);
508 setText(mText); 540 setText(mText);
509} 541}
diff --git a/korganizer/koeventviewer.h b/korganizer/koeventviewer.h
index 74f1135..0cd3f33 100644
--- a/korganizer/koeventviewer.h
+++ b/korganizer/koeventviewer.h
@@ -1,73 +1,74 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/ 18*/
19#ifndef KOEVENTVIEWER_H 19#ifndef KOEVENTVIEWER_H
20#define KOEVENTVIEWER_H 20#define KOEVENTVIEWER_H
21// 21//
22// Viewer widget for events. 22// Viewer widget for events.
23// 23//
24 24
25#include <qtextbrowser.h> 25#include <qtextbrowser.h>
26 26
27#include <libkcal/event.h> 27#include <libkcal/event.h>
28#include <libkcal/journal.h> 28#include <libkcal/journal.h>
29 29
30 30
31using namespace KCal; 31using namespace KCal;
32 32
33class KOEventViewer : public QTextBrowser { 33class KOEventViewer : public QTextBrowser {
34 Q_OBJECT 34 Q_OBJECT
35 public: 35 public:
36 KOEventViewer(QWidget *parent=0,const char *name=0); 36 KOEventViewer(QWidget *parent=0,const char *name=0);
37 virtual ~KOEventViewer(); 37 virtual ~KOEventViewer();
38 38
39 void setSource(const QString &); 39 void setSource(const QString &);
40 void setEvent(Event *event); 40 void setEvent(Event *event);
41 void addEvent(Event *event); 41 void addEvent(Event *event);
42 void setTodo(Todo *event, bool clearV = true ); 42 void setTodo(Todo *event, bool clearV = true );
43 void setJournal(Journal *jour, bool clearV = true ); 43 void setJournal(Journal *jour, bool clearV = true );
44 44
45 void appendEvent(Event *event, int mode = 0 ); 45 void appendEvent(Event *event, int mode = 0 );
46 void appendTodo(Todo *event, int mode = 0 ); 46 void appendTodo(Todo *event, int mode = 0 );
47 void appendJournal(Journal *jour, int mode = 0 ); 47 void appendJournal(Journal *jour, int mode = 0 );
48 48
49 void clearEvents(bool now=false); 49 void clearEvents(bool now=false);
50 50
51 void addText(QString text); 51 void addText(QString text);
52 void setSyncMode( bool ); 52 void setSyncMode( bool );
53 void setColorMode( int ); 53 void setColorMode( int );
54 54
55 protected: 55 protected:
56 int mColorMode; 56 int mColorMode;
57 void addTag(const QString & tag,const QString & text); 57 void addTag(const QString & tag,const QString & text);
58 58
59 void formatCategories(Incidence *event); 59 void formatCategories(Incidence *event);
60 void formatAttendees(Incidence *event); 60 void formatAttendees(Incidence *event);
61 void formatReadOnly(Incidence *event); 61 void formatReadOnly(Incidence *event);
62 62
63 private: 63 private:
64 QTextBrowser *mEventTextView; 64 QTextBrowser *mEventTextView;
65 bool mSyncMode; 65 bool mSyncMode;
66 66
67 QString mText; 67 QString mText;
68 QString mMailSubject;
68 Incidence* mCurrentIncidence; 69 Incidence* mCurrentIncidence;
69 signals: 70 signals:
70 void launchaddressbook(QString uid); 71 void launchaddressbook(QString uid);
71}; 72};
72 73
73#endif 74#endif
diff --git a/korganizer/main.cpp b/korganizer/main.cpp
index a357988..69ef294 100644
--- a/korganizer/main.cpp
+++ b/korganizer/main.cpp
@@ -1,109 +1,87 @@
1 1
2 2
3#ifndef DESKTOP_VERSION 3#ifndef DESKTOP_VERSION
4#include <qpe/qpeapplication.h> 4#include <qpe/qpeapplication.h>
5#include <qpe/global.h> 5#include <qpe/global.h>
6#include <stdlib.h> 6#include <stdlib.h>
7#else 7#else
8#include <qapplication.h> 8#include <qapplication.h>
9#include <qstring.h> 9#include <qstring.h>
10#include <qwindowsstyle.h> 10#include <qwindowsstyle.h>
11#include <qplatinumstyle.h> 11#include <qplatinumstyle.h>
12#include <qsgistyle.h> 12#include <qsgistyle.h>
13#endif 13#endif
14 14
15#include <qdir.h> 15#include <qdir.h>
16#include <kstandarddirs.h> 16#include <kstandarddirs.h>
17#include <kglobal.h> 17#include <kglobal.h>
18#include <stdio.h> 18#include <stdio.h>
19#include "mainwindow.h" 19#include "mainwindow.h"
20 20
21int main( int argc, char **argv ) 21int main( int argc, char **argv )
22{ 22{
23#ifndef DESKTOP_VERSION 23#ifndef DESKTOP_VERSION
24 QPEApplication a( argc, argv ); 24 QPEApplication a( argc, argv );
25 a.setKeepRunning (); 25 a.setKeepRunning ();
26#else 26#else
27 QApplication a( argc, argv ); 27 QApplication a( argc, argv );
28 QApplication::setStyle( new QPlatinumStyle ()); 28 QApplication::setStyle( new QPlatinumStyle ());
29#endif 29#endif
30 bool exitHelp = false; 30 bool exitHelp = false;
31 if ( argc > 1 ) { 31 if ( argc > 1 ) {
32 QString command = argv[1]; 32 QString command = argv[1];
33 if ( command == "-help" ){ 33 if ( command == "-help" ){
34 printf("KO/Pi command line commands:\n"); 34 printf("KO/Pi command line commands:\n");
35 printf(" no command: Start KO/Pi in usual way\n"); 35 printf(" no command: Start KO/Pi in usual way\n");
36 printf(" -help: This output\n"); 36 printf(" -help: This output\n");
37 printf("Next Option: Open or Show after start:\n"); 37 printf("Next Option: Open or Show after start:\n");
38 printf(" -newTodo: New Todo dialog\n"); 38 printf(" -newTodo: New Todo dialog\n");
39 printf(" -newEvent: New Event dialog\n"); 39 printf(" -newEvent: New Event dialog\n");
40 printf(" -showList: List view\n"); 40 printf(" -showList: List view\n");
41 printf(" -showDay: Day view\n"); 41 printf(" -showDay: Day view\n");
42 printf(" -showWWeek: Work Week view\n"); 42 printf(" -showWWeek: Work Week view\n");
43 printf(" -showWeek: Week view\n"); 43 printf(" -showWeek: Week view\n");
44 printf(" -showTodo: Todo view\n"); 44 printf(" -showTodo: Todo view\n");
45 printf(" -showJournal: Journal view\n"); 45 printf(" -showJournal: Journal view\n");
46 printf(" -showKO: Next Days view\n"); 46 printf(" -showKO: Next Days view\n");
47 printf(" -showWNext: What's Next view\n"); 47 printf(" -showWNext: What's Next view\n");
48 printf(" -showNextXView: Next X View\n"); 48 printf(" -showNextXView: Next X View\n");
49 printf(" -new[Y] and -show[X] may be used togehther\n"); 49 printf(" -new[Y] and -show[X] may be used togehther\n");
50 printf(" KO/Pi is exiting now. Bye!\n"); 50 printf(" KO/Pi is exiting now. Bye!\n");
51 exitHelp = true; 51 exitHelp = true;
52 } 52 }
53 } 53 }
54 if ( ! exitHelp ) { 54 if ( ! exitHelp ) {
55 KGlobal::setAppName( "korganizer" ); 55 KGlobal::setAppName( "korganizer" );
56 56 QString fileName ;
57
58 QString fileName ;
59#ifndef DESKTOP_VERSION 57#ifndef DESKTOP_VERSION
60 QString appdir = QDir::homeDirPath() + "/kdepim/apps/" + KGlobal::getAppName();
61 KStandardDirs::setAppDir( appdir );
62
63 fileName = getenv("QPEDIR"); 58 fileName = getenv("QPEDIR");
64 KGlobal::iconLoader()->setIconPath( fileName +"/pics/kdepim/korganizer/"); 59 KGlobal::iconLoader()->setIconPath( fileName +"/pics/kdepim/korganizer/");
65#else 60#else
66 61 fileName = qApp->applicationDirPath () + "/kdepim/korganizer/";
67#ifndef _WIN32_ 62 KGlobal::iconLoader()->setIconPath(QDir::convertSeparators(fileName));
68 fileName = qApp->applicationDirPath () + "/kdepim/korganizer/";
69#else
70 fileName = qApp->applicationDirPath () + "\\kdepim\\korganizer\\";
71#endif
72
73 KGlobal::iconLoader()->setIconPath(fileName);
74
75 QString appdir = QDir::homeDirPath();
76 //appdir = "C:\\";
77 if ( appdir.right(1) == "\\" || appdir.right(1) == "/" )
78 appdir += "korganizer";
79 else
80 appdir += "/korganizer";
81 KStandardDirs::setAppDir( QDir::convertSeparators( appdir ));
82 // qDebug(" %s ",KStandardDirs::appDir().latin1() );
83#endif 63#endif
84 QDir app_dir; 64 KStandardDirs::setAppDir( QDir::convertSeparators(locateLocal("data", "korganizer")));
85 if ( !app_dir.exists(KStandardDirs::appDir()) ) 65 MainWindow m;
86 app_dir.mkdir (KStandardDirs::appDir());
87 MainWindow m;
88#ifndef DESKTOP_VERSION 66#ifndef DESKTOP_VERSION
89 QObject::connect( &a, SIGNAL (appMessage ( const QCString &, const QByteArray & )),&m, SLOT(recieve( const QCString&, const QByteArray& ))); 67 QObject::connect( &a, SIGNAL (appMessage ( const QCString &, const QByteArray & )),&m, SLOT(recieve( const QCString&, const QByteArray& )));
90 a.showMainWidget(&m ); 68 a.showMainWidget(&m );
91#else 69#else
92 a.setMainWidget(&m ); 70 a.setMainWidget(&m );
93 m.show(); 71 m.show();
94 //m.resize( 800, 600 ); 72 //m.resize( 800, 600 );
95 QObject::connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); 73 QObject::connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
96#endif 74#endif
97 if ( argc > 1 ) { 75 if ( argc > 1 ) {
98 QCString command = argv[1]; 76 QCString command = argv[1];
99 if ( argc > 2 ) 77 if ( argc > 2 )
100 command += argv[2]; 78 command += argv[2];
101 qApp->processEvents(); 79 qApp->processEvents();
102 m.recieve(command, QByteArray() ); 80 m.recieve(command, QByteArray() );
103 81
104 } 82 }
105 a.exec(); 83 a.exec();
106 84
107 } 85 }
108 qDebug("KO: Bye! "); 86 qDebug("KO: Bye! ");
109} 87}