summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-06-29 20:50:39 (UTC)
committer zautrix <zautrix>2005-06-29 20:50:39 (UTC)
commitd1ca2fd41cb1390843c974c985cae5912d458d51 (patch) (unidiff)
tree7df650cfed3562a9e98c9f1eac9da0ee6beec6c1
parentf55b992a98cc081207b23283aadcf2ecffc90a87 (diff)
downloadkdepimpi-d1ca2fd41cb1390843c974c985cae5912d458d51.zip
kdepimpi-d1ca2fd41cb1390843c974c985cae5912d458d51.tar.gz
kdepimpi-d1ca2fd41cb1390843c974c985cae5912d458d51.tar.bz2
fhhh
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 623cf9d..214b829 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,1987 +1,1989 @@
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 (preton.brown@yale.edu) 8 Preston Brown (preton.brown@yale.edu)
9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl) 9 Fester Zigterman (F.J.F.ZigtermanRustenburg@student.utwente.nl)
10 Ian Dawes (iadawes@globalserve.net) 10 Ian Dawes (iadawes@globalserve.net)
11 Laszlo Boloni (boloni@cs.purdue.edu) 11 Laszlo Boloni (boloni@cs.purdue.edu)
12 12
13 Copyright (c) 2000, 2001, 2002 13 Copyright (c) 2000, 2001, 2002
14 Cornelius Schumacher <schumacher@kde.org> 14 Cornelius Schumacher <schumacher@kde.org>
15 15
16 This program is free software; you can redistribute it and/or modify 16 This program is free software; you can redistribute it and/or modify
17 it under the terms of the GNU General Public License as published by 17 it under the terms of the GNU General Public License as published by
18 the Free Software Foundation; either version 2 of the License, or 18 the Free Software Foundation; either version 2 of the License, or
19 (at your option) any later version. 19 (at your option) any later version.
20 20
21 This program is distributed in the hope that it will be useful, 21 This program is distributed in the hope that it will be useful,
22 but WITHOUT ANY WARRANTY; without even the implied warranty of 22 but WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the 23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
24 GNU General Public License for more details. 24 GNU General Public License for more details.
25 25
26 You should have received a copy of the GNU General Public License 26 You should have received a copy of the GNU General Public License
27 along with this program; if not, write to the Free Software 27 along with this program; if not, write to the Free Software
28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 28 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29*/ 29*/
30 30
31#include <stdlib.h> 31#include <stdlib.h>
32 32
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qradiobutton.h> 34#include <qradiobutton.h>
35#include <qbuttongroup.h> 35#include <qbuttongroup.h>
36#include <qlayout.h> 36#include <qlayout.h>
37#include <qclipboard.h> 37#include <qclipboard.h>
38#include <qcursor.h> 38#include <qcursor.h>
39#include <qmessagebox.h> 39#include <qmessagebox.h>
40#include <qprogressbar.h> 40#include <qprogressbar.h>
41#include <qmultilineedit.h> 41#include <qmultilineedit.h>
42#include <qtimer.h> 42#include <qtimer.h>
43#include <qwidgetstack.h> 43#include <qwidgetstack.h>
44#include <qptrlist.h> 44#include <qptrlist.h>
45#include <qregexp.h> 45#include <qregexp.h>
46#include <qgroupbox.h> 46#include <qgroupbox.h>
47#include <qfile.h> 47#include <qfile.h>
48#include <qdir.h> 48#include <qdir.h>
49#ifndef KORG_NOSPLITTER 49#ifndef KORG_NOSPLITTER
50#include <qsplitter.h> 50#include <qsplitter.h>
51#endif 51#endif
52 52
53#include <kglobal.h> 53#include <kglobal.h>
54#include <kdebug.h> 54#include <kdebug.h>
55#include <kstandarddirs.h> 55#include <kstandarddirs.h>
56#include <kfiledialog.h> 56#include <kfiledialog.h>
57#include <kmessagebox.h> 57#include <kmessagebox.h>
58#include <knotifyclient.h> 58#include <knotifyclient.h>
59#include <kconfig.h> 59#include <kconfig.h>
60 60
61#include <libkdepim/ksyncprefsdialog.h> 61#include <libkdepim/ksyncprefsdialog.h>
62#include <krun.h> 62#include <krun.h>
63#include <kdirwatch.h> 63#include <kdirwatch.h>
64#include <libkdepim/kdatepicker.h> 64#include <libkdepim/kdatepicker.h>
65#include <libkdepim/ksyncprofile.h> 65#include <libkdepim/ksyncprofile.h>
66#include <libkdepim/kpimglobalprefs.h> 66#include <libkdepim/kpimglobalprefs.h>
67 67
68#include <libkcal/vcaldrag.h> 68#include <libkcal/vcaldrag.h>
69#include <libkcal/icaldrag.h> 69#include <libkcal/icaldrag.h>
70#include <libkcal/icalformat.h> 70#include <libkcal/icalformat.h>
71#include <libkcal/vcalformat.h> 71#include <libkcal/vcalformat.h>
72#include <libkcal/scheduler.h> 72#include <libkcal/scheduler.h>
73#include <libkcal/calendarlocal.h> 73#include <libkcal/calendarlocal.h>
74#include <libkcal/journal.h> 74#include <libkcal/journal.h>
75#include <libkcal/calfilter.h> 75#include <libkcal/calfilter.h>
76#include <libkcal/attendee.h> 76#include <libkcal/attendee.h>
77#include <libkcal/dndfactory.h> 77#include <libkcal/dndfactory.h>
78#include <libkcal/freebusy.h> 78#include <libkcal/freebusy.h>
79#include <libkcal/filestorage.h> 79#include <libkcal/filestorage.h>
80#include <libkcal/calendarresources.h> 80#include <libkcal/calendarresources.h>
81#include <libkcal/qtopiaformat.h> 81#include <libkcal/qtopiaformat.h>
82#include "../kalarmd/alarmdialog.h" 82#include "../kalarmd/alarmdialog.h"
83 83
84#ifndef DESKTOP_VERSION 84#ifndef DESKTOP_VERSION
85#include <libkcal/sharpformat.h> 85#include <libkcal/sharpformat.h>
86#include <externalapphandler.h> 86#include <externalapphandler.h>
87#endif 87#endif
88#include <libkcal/phoneformat.h> 88#include <libkcal/phoneformat.h>
89#ifndef KORG_NOMAIL 89#ifndef KORG_NOMAIL
90#include "komailclient.h" 90#include "komailclient.h"
91#endif 91#endif
92#ifndef KORG_NOPRINTER 92#ifndef KORG_NOPRINTER
93#include "calprinter.h" 93#include "calprinter.h"
94#endif 94#endif
95#ifndef KORG_NOPLUGINS 95#ifndef KORG_NOPLUGINS
96#include "kocore.h" 96#include "kocore.h"
97#endif 97#endif
98#include "koeventeditor.h" 98#include "koeventeditor.h"
99#include "kotodoeditor.h" 99#include "kotodoeditor.h"
100#include "koprefs.h" 100#include "koprefs.h"
101#include "koeventviewerdialog.h" 101#include "koeventviewerdialog.h"
102#include "publishdialog.h" 102#include "publishdialog.h"
103#include "kofilterview.h" 103#include "kofilterview.h"
104#include "koglobals.h" 104#include "koglobals.h"
105#include "koviewmanager.h" 105#include "koviewmanager.h"
106#include "koagendaview.h" 106#include "koagendaview.h"
107#include "kodialogmanager.h" 107#include "kodialogmanager.h"
108#include "outgoingdialog.h" 108#include "outgoingdialog.h"
109#include "incomingdialog.h" 109#include "incomingdialog.h"
110#include "datenavigatorcontainer.h" 110#include "datenavigatorcontainer.h"
111#include "statusdialog.h" 111#include "statusdialog.h"
112#include "kdatenavigator.h" 112#include "kdatenavigator.h"
113#include "kotodoview.h" 113#include "kotodoview.h"
114#include "datenavigator.h" 114#include "datenavigator.h"
115#include "resourceview.h" 115#include "resourceview.h"
116#include "navigatorbar.h" 116#include "navigatorbar.h"
117#include "searchdialog.h" 117#include "searchdialog.h"
118#include "mainwindow.h" 118#include "mainwindow.h"
119 119
120#include "calendarview.h" 120#include "calendarview.h"
121#ifndef DESKTOP_VERSION 121#ifndef DESKTOP_VERSION
122#include <qtopia/alarmserver.h> 122#include <qtopia/alarmserver.h>
123#endif 123#endif
124#ifndef _WIN32_ 124#ifndef _WIN32_
125#include <stdlib.h> 125#include <stdlib.h>
126#include <stdio.h> 126#include <stdio.h>
127#include <unistd.h> 127#include <unistd.h>
128#else 128#else
129#include <qprocess.h> 129#include <qprocess.h>
130#endif 130#endif
131 131
132#ifdef DESKTOP_VERSION 132#ifdef DESKTOP_VERSION
133#include <kabc/stdaddressbook.h> 133#include <kabc/stdaddressbook.h>
134#endif 134#endif
135using namespace KOrg; 135using namespace KOrg;
136using namespace KCal; 136using namespace KCal;
137extern int globalFlagBlockAgenda; 137extern int globalFlagBlockAgenda;
138extern int globalFlagBlockStartup; 138extern int globalFlagBlockStartup;
139 139
140 140
141MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent) 141MissedAlarmTextBrowser::MissedAlarmTextBrowser(QWidget *parent, QPtrList<Incidence> alarms,QDateTime start ) : QTextBrowser(parent)
142 142
143{ 143{
144 mAlarms = alarms; 144 mAlarms = alarms;
145 viewport()->setBackgroundColor( QColor( 255, 255, 255 ) ); 145 viewport()->setBackgroundColor( QColor( 255, 255, 255 ) );
146 QString mText = "<table width=\"100%\">\n"; 146 QString mText = "<table width=\"100%\">\n";
147 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; 147 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>";
148#ifdef DESKTOP_VERSION 148#ifdef DESKTOP_VERSION
149 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>"; 149 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h2>";
150#else 150#else
151 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>"; 151 mText += "<tr bgcolor=\"#5699CD\"><td align=\"center\"><h3>";
152#endif 152#endif
153 // mText += "<img src=\""; 153 // mText += "<img src=\"";
154 // mText += ipath; 154 // mText += ipath;
155 // mText += "\">"; 155 // mText += "\">";
156 //mEventDate = QDate::currentDate(); 156 //mEventDate = QDate::currentDate();
157#ifdef DESKTOP_VERSION 157#ifdef DESKTOP_VERSION
158 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>"; 158 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h2>";
159#else 159#else
160 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>"; 160 mText += "<font color=\"#FFFFFF\"> <em>" + i18n("You missed the alarms for the following events or todos:")+"</em></font></h3>";
161#endif 161#endif
162 //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; 162 //mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>";
163 163
164 Incidence * inc = getNextInc( start ); 164 Incidence * inc = getNextInc( start );
165 int time = 0; 165 int time = 0;
166 //mText += "<table>"; 166 //mText += "<table>";
167 while ( inc ) { 167 while ( inc ) {
168 QDateTime dt ; 168 QDateTime dt ;
169 QString tempText = "<a "; 169 QString tempText = "<a ";
170 bool ok; 170 bool ok;
171 dt = inc->getNextOccurence( start, &ok ); 171 dt = inc->getNextOccurence( start, &ok );
172 if ( !ok ) continue; 172 if ( !ok ) continue;
173 if ( inc->typeID() == eventID ) { 173 if ( inc->typeID() == eventID ) {
174 tempText += "href=\"event:"; 174 tempText += "href=\"event:";
175 } else if ( inc->typeID() == todoID ) { 175 } else if ( inc->typeID() == todoID ) {
176 tempText += "href=\"todo:"; 176 tempText += "href=\"todo:";
177 } 177 }
178 tempText += inc->uid() + "\">"; 178 tempText += inc->uid() + "\">";
179 if ( inc->typeID() == todoID ) 179 if ( inc->typeID() == todoID )
180 tempText += i18n("Todo: "); 180 tempText += i18n("Todo: ");
181 if ( inc->summary().length() > 0 ) 181 if ( inc->summary().length() > 0 )
182 tempText += inc->summary(); 182 tempText += inc->summary();
183 else 183 else
184 tempText += i18n("-no summary-"); 184 tempText += i18n("-no summary-");
185 QString timestr; 185 QString timestr;
186 if (!inc->doesFloat()) 186 if (!inc->doesFloat())
187 timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": "; 187 timestr = KGlobal::locale()->formatDateTime( dt, KOPrefs::instance()->mShortDateInViewer) +": ";
188 else 188 else
189 timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": "; 189 timestr = KGlobal::locale()->formatDate( dt.date() , KOPrefs::instance()->mShortDateInViewer) +": ";
190 if ( dt.date() < QDate::currentDate() && time == 0 ) { 190 if ( dt.date() < QDate::currentDate() && time == 0 ) {
191 mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>"; 191 mText += "</td></tr>\n<tr bgcolor=\"#FF997D\"><td>";
192 mText += "<table>"; 192 mText += "<table>";
193 time = 1; 193 time = 1;
194 } 194 }
195 if ( dt.date() == QDate::currentDate() && time <= 1 ) { 195 if ( dt.date() == QDate::currentDate() && time <= 1 ) {
196 if ( time > 0 ) 196 if ( time > 0 )
197 mText +="</table>"; 197 mText +="</table>";
198 mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>"; 198 mText += "</td></tr>\n<tr bgcolor=\"#FFDC64\"><td>";
199 mText += "<table>"; 199 mText += "<table>";
200 time = 2; 200 time = 2;
201 201
202 } 202 }
203 if ( dt.date() > QDate::currentDate() && time <= 2 ) { 203 if ( dt.date() > QDate::currentDate() && time <= 2 ) {
204 if ( time > 0 ) 204 if ( time > 0 )
205 mText +="</table>"; 205 mText +="</table>";
206 mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>"; 206 mText += "</td></tr>\n<tr bgcolor=\"#6AFF6A\"><td>";
207 mText += "<table>"; 207 mText += "<table>";
208 time = 3; 208 time = 3;
209 } 209 }
210 mText +="<tr><td><b>"; 210 mText +="<tr><td><b>";
211 mText += timestr; 211 mText += timestr;
212 mText += "</b></td><td>"; 212 mText += "</b></td><td>";
213 mText += tempText; 213 mText += tempText;
214 mText += "</td></tr>\n"; 214 mText += "</td></tr>\n";
215 inc = getNextInc( start ); 215 inc = getNextInc( start );
216 } 216 }
217 mText +="</table>"; 217 mText +="</table>";
218 setText( mText ); 218 setText( mText );
219} 219}
220 220
221MissedAlarmTextBrowser::~MissedAlarmTextBrowser() 221MissedAlarmTextBrowser::~MissedAlarmTextBrowser()
222{ 222{
223 //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() "); 223 //qDebug("delete MissedAlarmTextBrowser::~MissedAlarmTextBrowser() ");
224} 224}
225Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start ) 225Incidence * MissedAlarmTextBrowser::getNextInc( QDateTime start )
226{ 226{
227 QDateTime dt ; 227 QDateTime dt ;
228 Incidence * retInc; 228 Incidence * retInc;
229 Incidence * inc = mAlarms.first(); 229 Incidence * inc = mAlarms.first();
230 if ( inc == 0 ) 230 if ( inc == 0 )
231 return 0; 231 return 0;
232 bool ok; 232 bool ok;
233 dt = inc->getNextOccurence( start, &ok ); 233 dt = inc->getNextOccurence( start, &ok );
234 if ( ! ok ) return 0; 234 if ( ! ok ) return 0;
235 QDateTime dtn ; 235 QDateTime dtn ;
236 retInc = inc; 236 retInc = inc;
237 inc = mAlarms.next(); 237 inc = mAlarms.next();
238 while ( inc ) { 238 while ( inc ) {
239 dtn = inc->getNextOccurence( start, &ok ); 239 dtn = inc->getNextOccurence( start, &ok );
240 if ( ! ok ) return 0; 240 if ( ! ok ) return 0;
241 if ( dtn < dt ) { 241 if ( dtn < dt ) {
242 dt = dtn; 242 dt = dtn;
243 retInc = inc; 243 retInc = inc;
244 } 244 }
245 inc = mAlarms.next(); 245 inc = mAlarms.next();
246 } 246 }
247 mAlarms.remove( retInc ); 247 mAlarms.remove( retInc );
248 return retInc; 248 return retInc;
249 249
250} 250}
251void MissedAlarmTextBrowser::setSource(const QString & n) 251void MissedAlarmTextBrowser::setSource(const QString & n)
252{ 252{
253 if (n.startsWith("event:")) { 253 if (n.startsWith("event:")) {
254#ifdef DESKTOP_VERSION 254#ifdef DESKTOP_VERSION
255 emit showIncidence(n.mid(8)); 255 emit showIncidence(n.mid(8));
256#else 256#else
257 emit showIncidence(n.mid(6)); 257 emit showIncidence(n.mid(6));
258#endif 258#endif
259 return; 259 return;
260 } else if (n.startsWith("todo:")) { 260 } else if (n.startsWith("todo:")) {
261#ifdef DESKTOP_VERSION 261#ifdef DESKTOP_VERSION
262 emit showIncidence(n.mid(7)); 262 emit showIncidence(n.mid(7));
263#else 263#else
264 emit showIncidence(n.mid(5)); 264 emit showIncidence(n.mid(5));
265#endif 265#endif
266 return; 266 return;
267 } 267 }
268} 268}
269 269
270 270
271class KOBeamPrefs : public QDialog 271class KOBeamPrefs : public QDialog
272{ 272{
273 public: 273 public:
274 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) : 274 KOBeamPrefs( QWidget *parent=0, const char *name=0 ) :
275 QDialog( parent, name, true ) 275 QDialog( parent, name, true )
276 { 276 {
277 setCaption( i18n("Beam Options") ); 277 setCaption( i18n("Beam Options") );
278 QVBoxLayout* lay = new QVBoxLayout( this ); 278 QVBoxLayout* lay = new QVBoxLayout( this );
279 lay->setSpacing( 3 ); 279 lay->setSpacing( 3 );
280 lay->setMargin( 3 ); 280 lay->setMargin( 3 );
281 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this ); 281 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("File format"), this );
282 lay->addWidget( format ); 282 lay->addWidget( format );
283 format->setExclusive ( true ) ; 283 format->setExclusive ( true ) ;
284 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this ); 284 QButtonGroup* time = new QButtonGroup(1, Horizontal, i18n("Time format"), this );
285 lay->addWidget( time ); time->setExclusive ( true ) ; 285 lay->addWidget( time ); time->setExclusive ( true ) ;
286 vcal = new QRadioButton(" vCalendar ", format ); 286 vcal = new QRadioButton(" vCalendar ", format );
287 ical = new QRadioButton(" iCalendar ", format ); 287 ical = new QRadioButton(" iCalendar ", format );
288 vcal->setChecked( true ); 288 vcal->setChecked( true );
289 tz = new QRadioButton(i18n(" With timezone "), time ); 289 tz = new QRadioButton(i18n(" With timezone "), time );
290 local = new QRadioButton(i18n(" Local time "), time ); 290 local = new QRadioButton(i18n(" Local time "), time );
291 tz->setChecked( true ); 291 tz->setChecked( true );
292 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this ); 292 QPushButton * ok = new QPushButton( i18n("Beam via IR!"), this );
293 lay->addWidget( ok ); 293 lay->addWidget( ok );
294 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 294 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
295 lay->addWidget( cancel ); 295 lay->addWidget( cancel );
296 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 296 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
297 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 297 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
298 resize( 200, 200 ); 298 resize( 200, 200 );
299 } 299 }
300 300
301 bool beamVcal() { return vcal->isChecked(); } 301 bool beamVcal() { return vcal->isChecked(); }
302 bool beamLocal() { return local->isChecked(); } 302 bool beamLocal() { return local->isChecked(); }
303private: 303private:
304 QRadioButton* vcal, *ical, *local, *tz; 304 QRadioButton* vcal, *ical, *local, *tz;
305}; 305};
306class KOCatPrefs : public QDialog 306class KOCatPrefs : public QDialog
307{ 307{
308 public: 308 public:
309 KOCatPrefs( QWidget *parent=0, const char *name=0 ) : 309 KOCatPrefs( QWidget *parent=0, const char *name=0 ) :
310 QDialog( parent, name, true ) 310 QDialog( parent, name, true )
311 { 311 {
312 setCaption( i18n("Manage new Categories") ); 312 setCaption( i18n("Manage new Categories") );
313 QVBoxLayout* lay = new QVBoxLayout( this ); 313 QVBoxLayout* lay = new QVBoxLayout( this );
314 lay->setSpacing( 3 ); 314 lay->setSpacing( 3 );
315 lay->setMargin( 3 ); 315 lay->setMargin( 3 );
316 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 ); 316 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 );
317 lay->addWidget( lab ); 317 lay->addWidget( lab );
318 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this ); 318 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("New categories not in list:"), this );
319 lay->addWidget( format ); 319 lay->addWidget( format );
320 format->setExclusive ( true ) ; 320 format->setExclusive ( true ) ;
321 addCatBut = new QRadioButton(i18n("Add to category list"), format ); 321 addCatBut = new QRadioButton(i18n("Add to category list"), format );
322 new QRadioButton(i18n("Remove from Events/Todos"), format ); 322 new QRadioButton(i18n("Remove from Events/Todos"), format );
323 addCatBut->setChecked( true ); 323 addCatBut->setChecked( true );
324 QPushButton * ok = new QPushButton( i18n("OK"), this ); 324 QPushButton * ok = new QPushButton( i18n("OK"), this );
325 lay->addWidget( ok ); 325 lay->addWidget( ok );
326 QPushButton * cancel = new QPushButton( i18n("Cancel"), this ); 326 QPushButton * cancel = new QPushButton( i18n("Cancel"), this );
327 lay->addWidget( cancel ); 327 lay->addWidget( cancel );
328 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 328 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
329 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) ); 329 connect (cancel, SIGNAL(clicked() ), this, SLOT ( reject()) );
330 resize( 200, 200 ); 330 resize( 200, 200 );
331 } 331 }
332 332
333 bool addCat() { return addCatBut->isChecked(); } 333 bool addCat() { return addCatBut->isChecked(); }
334private: 334private:
335 QRadioButton* addCatBut; 335 QRadioButton* addCatBut;
336}; 336};
337 337
338 338
339 339
340CalendarView::CalendarView( CalendarResources *calendar, 340CalendarView::CalendarView( CalendarResources *calendar,
341 QWidget *parent, const char *name ) 341 QWidget *parent, const char *name )
342 : CalendarViewBase( parent, name ), 342 : CalendarViewBase( parent, name ),
343 mCalendar( calendar ), 343 mCalendar( calendar ),
344 mResourceManager( calendar->resourceManager() ) 344 mResourceManager( calendar->resourceManager() )
345{ 345{
346 346
347 mEventEditor = 0; 347 mEventEditor = 0;
348 mTodoEditor = 0; 348 mTodoEditor = 0;
349 349
350 init(); 350 init();
351} 351}
352 352
353CalendarView::CalendarView( Calendar *calendar, 353CalendarView::CalendarView( Calendar *calendar,
354 QWidget *parent, const char *name ) 354 QWidget *parent, const char *name )
355 : CalendarViewBase( parent, name ), 355 : CalendarViewBase( parent, name ),
356 mCalendar( calendar ), 356 mCalendar( calendar ),
357 mResourceManager( 0 ) 357 mResourceManager( 0 )
358{ 358{
359 359
360 mEventEditor = 0; 360 mEventEditor = 0;
361 mTodoEditor = 0; 361 mTodoEditor = 0;
362 init(); 362 init();
363} 363}
364 364
365void CalendarView::init() 365void CalendarView::init()
366{ 366{
367 mNextAlarmDateTime = QDateTime::currentDateTime(); 367 mNextAlarmDateTime = QDateTime::currentDateTime();
368 setFocusPolicy ( NoFocus ); 368 setFocusPolicy ( NoFocus );
369 mViewerCallerIsSearchDialog = false; 369 mViewerCallerIsSearchDialog = false;
370 mBlockShowDates = false; 370 mBlockShowDates = false;
371 371
372 mDatePickerMode = 0; 372 mDatePickerMode = 0;
373 mCurrentSyncDevice = ""; 373 mCurrentSyncDevice = "";
374 mViewManager = new KOViewManager( this ); 374 mViewManager = new KOViewManager( this );
375 mDialogManager = new KODialogManager( this ); 375 mDialogManager = new KODialogManager( this );
376 mEventViewerDialog = 0; 376 mEventViewerDialog = 0;
377 mModified = false; 377 mModified = false;
378 mReadOnly = false; 378 mReadOnly = false;
379 mSelectedIncidence = 0; 379 mSelectedIncidence = 0;
380 mCalPrinter = 0; 380 mCalPrinter = 0;
381 mFilters.setAutoDelete(true); 381 mFilters.setAutoDelete(true);
382 382
383 mCalendar->registerObserver( this ); 383 mCalendar->registerObserver( this );
384 // TODO: Make sure that view is updated, when calendar is changed. 384 // TODO: Make sure that view is updated, when calendar is changed.
385 385
386 mStorage = new FileStorage( mCalendar ); 386 mStorage = new FileStorage( mCalendar );
387 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 387 mNavigator = new DateNavigator( this, "datevav", mViewManager );
388 388
389 QBoxLayout *topLayout = (QBoxLayout*)layout(); 389 QBoxLayout *topLayout = (QBoxLayout*)layout();
390#ifndef KORG_NOSPLITTER 390#ifndef KORG_NOSPLITTER
391 // create the main layout frames. 391 // create the main layout frames.
392 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 392 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
393 topLayout->addWidget(mPanner); 393 topLayout->addWidget(mPanner);
394 394
395 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 395 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
396 "CalendarView::LeftFrame"); 396 "CalendarView::LeftFrame");
397 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 397 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
398 398
399 mDateNavigator = new DateNavigatorContainer( mLeftSplitter, 399 mDateNavigator = new DateNavigatorContainer( mLeftSplitter,
400 "CalendarView::DateNavigator" ); 400 "CalendarView::DateNavigator" );
401 401
402 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 402 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
403 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 403 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
404 mTodoList->setNavigator( mNavigator ); 404 mTodoList->setNavigator( mNavigator );
405 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 405 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
406 406
407#ifdef KORG_NORESOURCEVIEW 407#ifdef KORG_NORESOURCEVIEW
408 mResourceView = 0; 408 mResourceView = 0;
409#else 409#else
410 if ( mResourceManager ) { 410 if ( mResourceManager ) {
411 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 411 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
412 mResourceView->updateView(); 412 mResourceView->updateView();
413 connect( mResourceView, SIGNAL( resourcesChanged() ), 413 connect( mResourceView, SIGNAL( resourcesChanged() ),
414 SLOT( updateView() ) ); 414 SLOT( updateView() ) );
415 } else { 415 } else {
416 mResourceView = 0; 416 mResourceView = 0;
417 } 417 }
418#endif 418#endif
419 QWidget *rightBox = new QWidget( mPanner ); 419 QWidget *rightBox = new QWidget( mPanner );
420 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 420 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
421 421
422 mRightFrame = new QWidgetStack( rightBox ); 422 mRightFrame = new QWidgetStack( rightBox );
423 rightLayout->addWidget( mRightFrame, 1 ); 423 rightLayout->addWidget( mRightFrame, 1 );
424 424
425 mLeftFrame = mLeftSplitter; 425 mLeftFrame = mLeftSplitter;
426#else 426#else
427 //QWidget *mainBox = new QWidget( this ); 427 //QWidget *mainBox = new QWidget( this );
428 //QWidget *leftFrame = new QWidget( mainBox ); 428 //QWidget *leftFrame = new QWidget( mainBox );
429 //QBoxLayout * mainBoxLayout; 429 //QBoxLayout * mainBoxLayout;
430 if ( KOPrefs::instance()->mVerticalScreen ) { 430 if ( KOPrefs::instance()->mVerticalScreen ) {
431 //mainBoxLayout = new QVBoxLayout(mainBox); 431 //mainBoxLayout = new QVBoxLayout(mainBox);
432 //leftFrameLayout = new QHBoxLayout(leftFrame ); 432 //leftFrameLayout = new QHBoxLayout(leftFrame );
433 mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); 433 mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this );
434 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 434 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
435 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; 435 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);;
436 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 436 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
437 } else { 437 } else {
438 //mainBoxLayout = new QHBoxLayout(mainBox); 438 //mainBoxLayout = new QHBoxLayout(mainBox);
439 //leftFrameLayout = new QVBoxLayout(leftFrame ); 439 //leftFrameLayout = new QVBoxLayout(leftFrame );
440 mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 440 mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
441 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); 441 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left);
442 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); 442 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame);
443 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 443 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
444 } 444 }
445 mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); 445 mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) );
446 //QBoxLayout * leftFrameLayout; 446 //QBoxLayout * leftFrameLayout;
447 topLayout->addWidget( mMainFrame ); 447 topLayout->addWidget( mMainFrame );
448#ifdef DESKTOP_VERSION 448#ifdef DESKTOP_VERSION
449 mDateScrollBar = new QScrollBar ( 0, 364, 1,30, 200,QScrollBar::Horizontal, this ); 449 mDateScrollBar = new QScrollBar ( 0, 364, 1,30, 200,QScrollBar::Horizontal, this );
450 topLayout->addWidget( mDateScrollBar ); 450 topLayout->addWidget( mDateScrollBar );
451 connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) ); 451 connect( mDateScrollBar, SIGNAL( valueChanged ( int ) ),this, SLOT( scrollBarValue( int )) );
452 if ( QApplication::desktop()->width() < 800 )
453 mDateScrollBar->hide();
452#endif 454#endif
453 //mainBoxLayout->addWidget (mLeftFrame); 455 //mainBoxLayout->addWidget (mLeftFrame);
454 mDateNavigator = new DateNavigatorContainer( mLeftFrame, 456 mDateNavigator = new DateNavigatorContainer( mLeftFrame,
455 "CalendarView::DateNavigator" ); 457 "CalendarView::DateNavigator" );
456#if 0 458#if 0
457 // FIXME 459 // FIXME
458 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, 460 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE,
459 "CalendarView::DateNavigator", QDate::currentDate()); 461 "CalendarView::DateNavigator", QDate::currentDate());
460#endif 462#endif
461 // mDateNavigator->blockSignals( true ); 463 // mDateNavigator->blockSignals( true );
462 //leftFrameLayout->addWidget( mDateNavigator ); 464 //leftFrameLayout->addWidget( mDateNavigator );
463 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); 465 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall");
464 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); 466 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView");
465 mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); 467 mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView");
466 connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) ); 468 connect( mCalEditView, SIGNAL( calendarEnabled (int,bool) ),mCalendar, SLOT( setCalendarEnabled(int,bool)) );
467 connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) ); 469 connect( mCalEditView, SIGNAL( alarmEnabled(int,bool) ),mCalendar, SLOT( setAlarmEnabled(int,bool)) );
468 connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),mCalendar, SLOT( setReadOnly(int,bool)) ); 470 connect( mCalEditView, SIGNAL( calendarReadonly(int,bool) ),mCalendar, SLOT( setReadOnly(int,bool)) );
469 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) ); 471 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mCalendar, SLOT( setDefaultCalendar(int)) );
470 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) ); 472 connect( mCalEditView, SIGNAL( setCalendarDefault(int) ),mViewManager, SLOT( setDefaultCalendar(int)) );
471 connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) ); 473 connect( mCalEditView, SIGNAL( removeCalendar(int) ),mCalendar, SLOT( setCalendarRemove(int)) );
472 connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) ); 474 connect( mCalEditView, SIGNAL( calendarAdded(int) ),this, SLOT( addCalendarId(int)) );
473 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) ); 475 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateView()) );
474 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) ); 476 connect( mCalEditView, SIGNAL( needsUpdate() ),this, SLOT( updateUnmanagedViews()) );
475 477
476 mTodoList->setNavigator( mNavigator ); 478 mTodoList->setNavigator( mNavigator );
477#if 0 479#if 0
478 if ( QApplication::desktop()->width() < 480 ) { 480 if ( QApplication::desktop()->width() < 480 ) {
479 leftFrameLayout->addWidget(mFilterView); 481 leftFrameLayout->addWidget(mFilterView);
480 leftFrameLayout->addWidget(mTodoList, 2 ); 482 leftFrameLayout->addWidget(mTodoList, 2 );
481 483
482 } else { 484 } else {
483 leftFrameLayout->addWidget(mTodoList,2 ); 485 leftFrameLayout->addWidget(mTodoList,2 );
484 leftFrameLayout->addWidget(mFilterView ); 486 leftFrameLayout->addWidget(mFilterView );
485 } 487 }
486#endif 488#endif
487 mFilterView->hide(); 489 mFilterView->hide();
488 mCalEditView->hide(); 490 mCalEditView->hide();
489 QWidget *rightBox = new QWidget( mMainFrame ); 491 QWidget *rightBox = new QWidget( mMainFrame );
490 //mainBoxLayout->addWidget ( rightBox, 10 ); 492 //mainBoxLayout->addWidget ( rightBox, 10 );
491 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 493 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
492 mRightFrame = new QWidgetStack( rightBox ); 494 mRightFrame = new QWidgetStack( rightBox );
493 rightLayout->addWidget( mRightFrame, 10 ); 495 rightLayout->addWidget( mRightFrame, 10 );
494 496
495 //mLeftFrame = (QWidget *)leftFrame; 497 //mLeftFrame = (QWidget *)leftFrame;
496 if ( KOPrefs::instance()->mVerticalScreen ) { 498 if ( KOPrefs::instance()->mVerticalScreen ) {
497 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); 499 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() );
498 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); 500 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() );
499 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 501 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
500 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 502 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
501 } else { 503 } else {
502 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); 504 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() );
503 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 505 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
504 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 506 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
505 } 507 }
506 if ( !KOPrefs::instance()->mShowDateNavigator) 508 if ( !KOPrefs::instance()->mShowDateNavigator)
507 mDateNavigator->hide(); 509 mDateNavigator->hide();
508 //qDebug("Calendarview Size %d %d ", width(), height()); 510 //qDebug("Calendarview Size %d %d ", width(), height());
509#endif 511#endif
510 512
511 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 513 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
512 SLOT( showDates( const KCal::DateList & ) ) ); 514 SLOT( showDates( const KCal::DateList & ) ) );
513 515
514 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 516 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
515 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 517 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
516 518
517 519
518 520
519 connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), 521 connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ),
520 mViewManager, SLOT( showMonth( const QDate & ) ) ); 522 mViewManager, SLOT( showMonth( const QDate & ) ) );
521 523
522 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 524 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
523 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 525 mNavigator, SLOT( selectWeek( const QDate & ) ) );
524 526
525 connect( mDateNavigator, SIGNAL( goPrevYear() ), 527 connect( mDateNavigator, SIGNAL( goPrevYear() ),
526 mNavigator, SLOT( selectPreviousYear() ) ); 528 mNavigator, SLOT( selectPreviousYear() ) );
527 connect( mDateNavigator, SIGNAL( goNextYear() ), 529 connect( mDateNavigator, SIGNAL( goNextYear() ),
528 mNavigator, SLOT( selectNextYear() ) ); 530 mNavigator, SLOT( selectNextYear() ) );
529 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 531 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
530 mNavigator, SLOT( selectPreviousMonth() ) ); 532 mNavigator, SLOT( selectPreviousMonth() ) );
531 connect( mDateNavigator, SIGNAL( goNextMonth() ), 533 connect( mDateNavigator, SIGNAL( goNextMonth() ),
532 mNavigator, SLOT( selectNextMonth() ) ); 534 mNavigator, SLOT( selectNextMonth() ) );
533 535
534 connect( mDateNavigator, SIGNAL( goPrevious() ), 536 connect( mDateNavigator, SIGNAL( goPrevious() ),
535 mNavigator, SLOT( selectPrevious() ) ); 537 mNavigator, SLOT( selectPrevious() ) );
536 connect( mDateNavigator, SIGNAL( goNext() ), 538 connect( mDateNavigator, SIGNAL( goNext() ),
537 mNavigator, SLOT( selectNext() ) ); 539 mNavigator, SLOT( selectNext() ) );
538 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 540 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
539 mNavigator, SLOT( slotMonthSelect( int ) ) ); 541 mNavigator, SLOT( slotMonthSelect( int ) ) );
540 542
541 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 543 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
542 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 544 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
543#if 0 545#if 0
544 connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), 546 connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ),
545 SLOT( incidenceAdded( Incidence *) ) ); 547 SLOT( incidenceAdded( Incidence *) ) );
546#endif 548#endif
547 // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 549 // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
548 550
549 connect( this, SIGNAL( configChanged() ), 551 connect( this, SIGNAL( configChanged() ),
550 mDateNavigator, SLOT( updateConfig() ) ); 552 mDateNavigator, SLOT( updateConfig() ) );
551 553
552 connect( mTodoList, SIGNAL( newTodoSignal() ), 554 connect( mTodoList, SIGNAL( newTodoSignal() ),
553 SLOT( newTodo() ) ); 555 SLOT( newTodo() ) );
554 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 556 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
555 SLOT( newSubTodo( Todo * ) ) ); 557 SLOT( newSubTodo( Todo * ) ) );
556 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 558 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
557 SLOT( editTodo( Todo * ) ) ); 559 SLOT( editTodo( Todo * ) ) );
558 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 560 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
559 SLOT( showTodo( Todo *) ) ); 561 SLOT( showTodo( Todo *) ) );
560 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 562 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
561 SLOT( deleteTodo( Todo *) ) ); 563 SLOT( deleteTodo( Todo *) ) );
562 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 564 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
563 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 565 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
564 SLOT( purgeCompleted() ) ); 566 SLOT( purgeCompleted() ) );
565 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 567 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
566 SIGNAL( todoModified( Todo *, int ) ) ); 568 SIGNAL( todoModified( Todo *, int ) ) );
567 569
568 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 570 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
569 this, SLOT ( cloneIncidence( Incidence * ) ) ); 571 this, SLOT ( cloneIncidence( Incidence * ) ) );
570 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 572 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
571 this, SLOT (cancelIncidence( Incidence * ) ) ); 573 this, SLOT (cancelIncidence( Incidence * ) ) );
572 574
573 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 575 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
574 this, SLOT ( moveIncidence( Incidence * ) ) ); 576 this, SLOT ( moveIncidence( Incidence * ) ) );
575 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 577 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
576 this, SLOT ( beamIncidence( Incidence * ) ) ); 578 this, SLOT ( beamIncidence( Incidence * ) ) );
577 579
578 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 580 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
579 this, SLOT ( todo_unsub( Todo * ) ) ); 581 this, SLOT ( todo_unsub( Todo * ) ) );
580 582
581 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 583 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
582 this, SLOT ( todo_resub( Todo *,Todo * ) ) ); 584 this, SLOT ( todo_resub( Todo *,Todo * ) ) );
583 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 585 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
584 SLOT( updateTodo( Todo *, int ) ) ); 586 SLOT( updateTodo( Todo *, int ) ) );
585 connect( this, SIGNAL( todoModified( Todo *, int )), this, 587 connect( this, SIGNAL( todoModified( Todo *, int )), this,
586 SLOT( changeTodoDisplay( Todo *, int ) ) ); 588 SLOT( changeTodoDisplay( Todo *, int ) ) );
587 589
588 590
589 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 591 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
590 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 592 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
591 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 593 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
592 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 594 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
593 595
594 596
595 597
596 598
597 599
598 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 600 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
599 SLOT(checkClipboard())); 601 SLOT(checkClipboard()));
600 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 602 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
601 SLOT( processTodoListSelection( Incidence * ) ) ); 603 SLOT( processTodoListSelection( Incidence * ) ) );
602 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 604 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
603 605
604 // kdDebug() << "CalendarView::CalendarView() done" << endl; 606 // kdDebug() << "CalendarView::CalendarView() done" << endl;
605 607
606 mDateFrame = new QVBox(0,0,WType_Popup); 608 mDateFrame = new QVBox(0,0,WType_Popup);
607 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 609 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
608 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 610 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
609 mDateFrame->setLineWidth(3); 611 mDateFrame->setLineWidth(3);
610 mDateFrame->hide(); 612 mDateFrame->hide();
611 mDateFrame->setCaption( i18n( "Pick a date to display")); 613 mDateFrame->setCaption( i18n( "Pick a date to display"));
612 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 614 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
613 615
614 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 616 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
615 617
616 mEventEditor = mDialogManager->getEventEditor(); 618 mEventEditor = mDialogManager->getEventEditor();
617 mTodoEditor = mDialogManager->getTodoEditor(); 619 mTodoEditor = mDialogManager->getTodoEditor();
618 620
619 mFlagEditDescription = false; 621 mFlagEditDescription = false;
620 622
621 mSuspendTimer = new QTimer( this ); 623 mSuspendTimer = new QTimer( this );
622 mAlarmTimer = new QTimer( this ); 624 mAlarmTimer = new QTimer( this );
623 mRecheckAlarmTimer = new QTimer( this ); 625 mRecheckAlarmTimer = new QTimer( this );
624 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 626 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
625 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 627 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
626 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 628 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
627 mAlarmDialog = new AlarmDialog( this ); 629 mAlarmDialog = new AlarmDialog( this );
628 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 630 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
629 mAlarmDialog->setServerNotification( false ); 631 mAlarmDialog->setServerNotification( false );
630 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 632 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
631 633
632 634
633#ifndef DESKTOP_VERSION 635#ifndef DESKTOP_VERSION
634//US listen for arriving address resultsets 636//US listen for arriving address resultsets
635 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), 637 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)),
636 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 638 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
637#endif 639#endif
638 mDateNavigator->setCalendar( mCalendar ); 640 mDateNavigator->setCalendar( mCalendar );
639} 641}
640 642
641 643
642CalendarView::~CalendarView() 644CalendarView::~CalendarView()
643{ 645{
644 // kdDebug() << "~CalendarView()" << endl; 646 // kdDebug() << "~CalendarView()" << endl;
645 //qDebug("CalendarView::~CalendarView() "); 647 //qDebug("CalendarView::~CalendarView() ");
646 delete mDialogManager; 648 delete mDialogManager;
647 delete mViewManager; 649 delete mViewManager;
648 delete mStorage; 650 delete mStorage;
649 delete mDateFrame ; 651 delete mDateFrame ;
650 delete mEventViewerDialog; 652 delete mEventViewerDialog;
651 //kdDebug() << "~CalendarView() done" << endl; 653 //kdDebug() << "~CalendarView() done" << endl;
652} 654}
653void CalendarView::setScrollBarStep(int val ) 655void CalendarView::setScrollBarStep(int val )
654{ 656{
655#ifdef DESKTOP_VERSION 657#ifdef DESKTOP_VERSION
656 mDateScrollBar->setLineStep ( val ); 658 mDateScrollBar->setLineStep ( val );
657#endif 659#endif
658} 660}
659void CalendarView::scrollBarValue(int val ) 661void CalendarView::scrollBarValue(int val )
660{ 662{
661#ifdef DESKTOP_VERSION 663#ifdef DESKTOP_VERSION
662 if ( QApplication::desktop()->width() < 800 ) return; 664 if ( QApplication::desktop()->width() < 800 ) return;
663 static bool block = false; 665 static bool block = false;
664 if ( block ) return; 666 if ( block ) return;
665 block = true; 667 block = true;
666 val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep(); 668 val = val/mDateScrollBar->lineStep ()*mDateScrollBar->lineStep();
667 //qDebug("VAL %d ",val ); 669 //qDebug("VAL %d ",val );
668 int count = mNavigator->selectedDates().count(); 670 int count = mNavigator->selectedDates().count();
669 int year = mNavigator->selectedDates().first().year(); 671 int year = mNavigator->selectedDates().first().year();
670 int day = mNavigator->selectedDates().first().dayOfYear(); 672 int day = mNavigator->selectedDates().first().dayOfYear();
671 if ( val == day -1 ) { 673 if ( val == day -1 ) {
672 block = false; 674 block = false;
673 return; 675 return;
674 } 676 }
675 QDate d ( year,1,1 ); 677 QDate d ( year,1,1 );
676 mNavigator->selectDates( d.addDays( val ), count ); 678 mNavigator->selectDates( d.addDays( val ), count );
677 block = false; 679 block = false;
678#endif 680#endif
679 681
680} 682}
681 683
682void CalendarView::checkAlarms() 684void CalendarView::checkAlarms()
683{ 685{
684 KConfig *config = KOGlobals::config(); 686 KConfig *config = KOGlobals::config();
685 config->setGroup( "AppRun" ); 687 config->setGroup( "AppRun" );
686 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); 688 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) );
687 int daysto = dt.daysTo( QDate::currentDate() ); 689 int daysto = dt.daysTo( QDate::currentDate() );
688 int days = config->readNumEntry( "LatestProgramStopDays" , daysto); 690 int days = config->readNumEntry( "LatestProgramStopDays" , daysto);
689 dt = dt.addDays( days ); 691 dt = dt.addDays( days );
690 int secto = dt.secsTo( QDateTime::currentDateTime() ); 692 int secto = dt.secsTo( QDateTime::currentDateTime() );
691 int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30; 693 int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30;
692 //qDebug("KO: Reading program stop %d ", secs); 694 //qDebug("KO: Reading program stop %d ", secs);
693 //secs -= ( 3600 * 24*3 ); // debug only 695 //secs -= ( 3600 * 24*3 ); // debug only
694 QDateTime latest = dt.addSecs ( secs ); 696 QDateTime latest = dt.addSecs ( secs );
695 qDebug("KO: Last termination on %s ", latest.toString().latin1()); 697 qDebug("KO: Last termination on %s ", latest.toString().latin1());
696 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); 698 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() );
697 QPtrList<Incidence> el = mCalendar->rawIncidences(); 699 QPtrList<Incidence> el = mCalendar->rawIncidences();
698 QPtrList<Incidence> al; 700 QPtrList<Incidence> al;
699 Incidence* inL = el.first(); 701 Incidence* inL = el.first();
700 QDateTime cur = QDateTime::currentDateTime().addSecs(-59); 702 QDateTime cur = QDateTime::currentDateTime().addSecs(-59);
701 qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); 703 qDebug("KO: Checking alarm until %s ", cur.toString().latin1());
702 while ( inL ) { 704 while ( inL ) {
703 bool ok = false; 705 bool ok = false;
704 int offset = 0; 706 int offset = 0;
705 QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; 707 QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ;
706 if ( ok ) { 708 if ( ok ) {
707 //qDebug("OK %s",next.toString().latin1()); 709 //qDebug("OK %s",next.toString().latin1());
708 if ( next < cur ) { 710 if ( next < cur ) {
709 al.append( inL ); 711 al.append( inL );
710 //qDebug("found missed alarm: %s ", inL->summary().latin1() ); 712 //qDebug("found missed alarm: %s ", inL->summary().latin1() );
711 } 713 }
712 } 714 }
713 inL = el.next(); 715 inL = el.next();
714 } 716 }
715 if ( al.count() ) { 717 if ( al.count() ) {
716 QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); 718 QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop );
717 dia->setCaption( i18n("KO/Pi: Missing alarms!") ); 719 dia->setCaption( i18n("KO/Pi: Missing alarms!") );
718 QVBoxLayout* lay = new QVBoxLayout( dia ); 720 QVBoxLayout* lay = new QVBoxLayout( dia );
719 lay->setSpacing( 0 ); 721 lay->setSpacing( 0 );
720 lay->setMargin( 0 ); 722 lay->setMargin( 0 );
721 MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); 723 MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest );
722 connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); 724 connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) ));
723 lay->addWidget( matb ); 725 lay->addWidget( matb );
724 if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { 726 if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) {
725 int wid = 210; 727 int wid = 210;
726 int x = QApplication::desktop()->width() - wid - 7; 728 int x = QApplication::desktop()->width() - wid - 7;
727 int y = QApplication::desktop()->height() - wid - 70; 729 int y = QApplication::desktop()->height() - wid - 70;
728 dia->setGeometry ( x,y,wid,wid); 730 dia->setGeometry ( x,y,wid,wid);
729 } else { 731 } else {
730 int si = 220; 732 int si = 220;
731 if ( QApplication::desktop()->width() > 470 ) 733 if ( QApplication::desktop()->width() > 470 )
732 si = 400; 734 si = 400;
733 dia->resize(si,si/2); 735 dia->resize(si,si/2);
734 } 736 }
735 dia->setBackgroundColor( QColor( 255, 255, 255 ) ); 737 dia->setBackgroundColor( QColor( 255, 255, 255 ) );
736 dia->show(); 738 dia->show();
737 739
738 } 740 }
739} 741}
740void CalendarView::showDay( QDate d ) 742void CalendarView::showDay( QDate d )
741{ 743{
742 dateNavigator()->blockSignals( true ); 744 dateNavigator()->blockSignals( true );
743 dateNavigator()->selectDate( d ); 745 dateNavigator()->selectDate( d );
744 dateNavigator()->blockSignals( false ); 746 dateNavigator()->blockSignals( false );
745 mViewManager->showDayView(); 747 mViewManager->showDayView();
746 //dateNavigator()->selectDate( d ); 748 //dateNavigator()->selectDate( d );
747} 749}
748void CalendarView::timerAlarm() 750void CalendarView::timerAlarm()
749{ 751{
750 //qDebug("CalendarView::timerAlarm() "); 752 //qDebug("CalendarView::timerAlarm() ");
751 computeAlarm(mAlarmNotification ); 753 computeAlarm(mAlarmNotification );
752} 754}
753 755
754void CalendarView::suspendAlarm() 756void CalendarView::suspendAlarm()
755{ 757{
756 //qDebug(" CalendarView::suspendAlarm() "); 758 //qDebug(" CalendarView::suspendAlarm() ");
757 computeAlarm(mSuspendAlarmNotification ); 759 computeAlarm(mSuspendAlarmNotification );
758 760
759} 761}
760 762
761void CalendarView::startAlarm( QString mess , QString filename) 763void CalendarView::startAlarm( QString mess , QString filename)
762{ 764{
763 765
764 topLevelWidget()->showNormal(); 766 topLevelWidget()->showNormal();
765 topLevelWidget()->setActiveWindow(); 767 topLevelWidget()->setActiveWindow();
766 topLevelWidget()->raise(); 768 topLevelWidget()->raise();
767 769
768 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 770 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
769 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); 771 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
770 772
771} 773}
772 774
773void CalendarView::checkNextTimerAlarm() 775void CalendarView::checkNextTimerAlarm()
774{ 776{
775 mCalendar->checkAlarmForIncidence( 0, true ); 777 mCalendar->checkAlarmForIncidence( 0, true );
776} 778}
777 779
778void CalendarView::computeAlarm( QString msg ) 780void CalendarView::computeAlarm( QString msg )
779{ 781{
780 782
781 QString mess = msg; 783 QString mess = msg;
782 QString mAlarmMessage = mess.mid( 9 ); 784 QString mAlarmMessage = mess.mid( 9 );
783 QString filename = MainWindow::resourcePath(); 785 QString filename = MainWindow::resourcePath();
784 filename += "koalarm.wav"; 786 filename += "koalarm.wav";
785 QString tempfilename; 787 QString tempfilename;
786 if ( mess.left( 13 ) == "suspend_alarm") { 788 if ( mess.left( 13 ) == "suspend_alarm") {
787 bool error = false; 789 bool error = false;
788 int len = mess.mid( 13 ).find("+++"); 790 int len = mess.mid( 13 ).find("+++");
789 if ( len < 2 ) 791 if ( len < 2 )
790 error = true; 792 error = true;
791 else { 793 else {
792 tempfilename = mess.mid( 13, len ); 794 tempfilename = mess.mid( 13, len );
793 if ( !QFile::exists( tempfilename ) ) 795 if ( !QFile::exists( tempfilename ) )
794 error = true; 796 error = true;
795 } 797 }
796 if ( ! error ) { 798 if ( ! error ) {
797 filename = tempfilename; 799 filename = tempfilename;
798 } 800 }
799 mAlarmMessage = mess.mid( 13+len+3 ); 801 mAlarmMessage = mess.mid( 13+len+3 );
800 //qDebug("suspend file %s ",tempfilename.latin1() ); 802 //qDebug("suspend file %s ",tempfilename.latin1() );
801 startAlarm( mAlarmMessage, filename); 803 startAlarm( mAlarmMessage, filename);
802 return; 804 return;
803 } 805 }
804 if ( mess.left( 11 ) == "timer_alarm") { 806 if ( mess.left( 11 ) == "timer_alarm") {
805 //mTimerTime = 0; 807 //mTimerTime = 0;
806 startAlarm( mess.mid( 11 ), filename ); 808 startAlarm( mess.mid( 11 ), filename );
807 return; 809 return;
808 } 810 }
809 if ( mess.left( 10 ) == "proc_alarm") { 811 if ( mess.left( 10 ) == "proc_alarm") {
810 bool error = false; 812 bool error = false;
811 int len = mess.mid( 10 ).find("+++"); 813 int len = mess.mid( 10 ).find("+++");
812 if ( len < 2 ) 814 if ( len < 2 )
813 error = true; 815 error = true;
814 else { 816 else {
815 tempfilename = mess.mid( 10, len ); 817 tempfilename = mess.mid( 10, len );
816 if ( !QFile::exists( tempfilename ) ) 818 if ( !QFile::exists( tempfilename ) )
817 error = true; 819 error = true;
818 } 820 }
819 if ( error ) { 821 if ( error ) {
820 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 822 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
821 mAlarmMessage += mess.mid( 10+len+3+9 ); 823 mAlarmMessage += mess.mid( 10+len+3+9 );
822 } else { 824 } else {
823 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 825 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
824 //qDebug("-----system command %s ",tempfilename.latin1() ); 826 //qDebug("-----system command %s ",tempfilename.latin1() );
825#ifndef _WIN32_ 827#ifndef _WIN32_
826 if ( vfork () == 0 ) { 828 if ( vfork () == 0 ) {
827 execl ( tempfilename.latin1(), 0 ); 829 execl ( tempfilename.latin1(), 0 );
828 return; 830 return;
829 } 831 }
830#else 832#else
831 QProcess* p = new QProcess(); 833 QProcess* p = new QProcess();
832 p->addArgument( tempfilename.latin1() ); 834 p->addArgument( tempfilename.latin1() );
833 p->start(); 835 p->start();
834 return; 836 return;
835#endif 837#endif
836 838
837 return; 839 return;
838 } 840 }
839 841
840 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 842 //qDebug("+++++++system command %s ",tempfilename.latin1() );
841 } 843 }
842 if ( mess.left( 11 ) == "audio_alarm") { 844 if ( mess.left( 11 ) == "audio_alarm") {
843 bool error = false; 845 bool error = false;
844 int len = mess.mid( 11 ).find("+++"); 846 int len = mess.mid( 11 ).find("+++");
845 if ( len < 2 ) 847 if ( len < 2 )
846 error = true; 848 error = true;
847 else { 849 else {
848 tempfilename = mess.mid( 11, len ); 850 tempfilename = mess.mid( 11, len );
849 if ( !QFile::exists( tempfilename ) ) 851 if ( !QFile::exists( tempfilename ) )
850 error = true; 852 error = true;
851 } 853 }
852 if ( ! error ) { 854 if ( ! error ) {
853 filename = tempfilename; 855 filename = tempfilename;
854 } 856 }
855 mAlarmMessage = mess.mid( 11+len+3+9 ); 857 mAlarmMessage = mess.mid( 11+len+3+9 );
856 //qDebug("audio file command %s ",tempfilename.latin1() ); 858 //qDebug("audio file command %s ",tempfilename.latin1() );
857 } 859 }
858 if ( mess.left( 9 ) == "cal_alarm") { 860 if ( mess.left( 9 ) == "cal_alarm") {
859 mAlarmMessage = mess.mid( 9 ) ; 861 mAlarmMessage = mess.mid( 9 ) ;
860 } 862 }
861 863
862 startAlarm( mAlarmMessage, filename ); 864 startAlarm( mAlarmMessage, filename );
863 865
864 866
865} 867}
866 868
867void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 869void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
868{ 870{
869 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 871 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
870 872
871 mSuspendAlarmNotification = noti; 873 mSuspendAlarmNotification = noti;
872 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 874 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
873 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 875 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
874 mSuspendTimer->start( ms , true ); 876 mSuspendTimer->start( ms , true );
875 877
876} 878}
877 879
878void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 880void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
879{ 881{
880 mNextAlarmDateTime = qdt; 882 mNextAlarmDateTime = qdt;
881 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 883 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
882 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 884 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
883#ifndef DESKTOP_VERSION 885#ifndef DESKTOP_VERSION
884 AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); 886 AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() );
885#endif 887#endif
886 return; 888 return;
887 } 889 }
888 int maxSec; 890 int maxSec;
889 //maxSec = 5; //testing only 891 //maxSec = 5; //testing only
890 maxSec = 86400+3600; // one day+1hour 892 maxSec = 86400+3600; // one day+1hour
891 mAlarmNotification = noti; 893 mAlarmNotification = noti;
892 int sec = QDateTime::currentDateTime().secsTo( qdt ); 894 int sec = QDateTime::currentDateTime().secsTo( qdt );
893 if ( sec > maxSec ) { 895 if ( sec > maxSec ) {
894 mRecheckAlarmTimer->start( maxSec * 1000 ); 896 mRecheckAlarmTimer->start( maxSec * 1000 );
895 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 897 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
896 return; 898 return;
897 } else { 899 } else {
898 mRecheckAlarmTimer->stop(); 900 mRecheckAlarmTimer->stop();
899 } 901 }
900 //qDebug("Alarm timer started with secs: %d ", sec); 902 //qDebug("Alarm timer started with secs: %d ", sec);
901 mAlarmTimer->start( sec *1000 , true ); 903 mAlarmTimer->start( sec *1000 , true );
902 904
903} 905}
904// called by mRecheckAlarmTimer to get next alarm 906// called by mRecheckAlarmTimer to get next alarm
905// we need this, because a QTimer has only a max range of 25 days 907// we need this, because a QTimer has only a max range of 25 days
906void CalendarView::recheckTimerAlarm() 908void CalendarView::recheckTimerAlarm()
907{ 909{
908 mAlarmTimer->stop(); 910 mAlarmTimer->stop();
909 mRecheckAlarmTimer->stop(); 911 mRecheckAlarmTimer->stop();
910 mCalendar->checkAlarmForIncidence( 0, true ); 912 mCalendar->checkAlarmForIncidence( 0, true );
911} 913}
912void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 914void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
913{ 915{
914 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 916 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
915 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 917 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
916#ifndef DESKTOP_VERSION 918#ifndef DESKTOP_VERSION
917 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 919 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
918#endif 920#endif
919 return; 921 return;
920 } 922 }
921 mAlarmTimer->stop(); 923 mAlarmTimer->stop();
922} 924}
923void CalendarView::selectWeekNum ( int num ) 925void CalendarView::selectWeekNum ( int num )
924{ 926{
925 dateNavigator()->blockSignals( true ); 927 dateNavigator()->blockSignals( true );
926 dateNavigator()->selectWeek( num ); 928 dateNavigator()->selectWeek( num );
927 dateNavigator()->blockSignals( false ); 929 dateNavigator()->blockSignals( false );
928 mViewManager->showWeekView(); 930 mViewManager->showWeekView();
929} 931}
930KOViewManager *CalendarView::viewManager() 932KOViewManager *CalendarView::viewManager()
931{ 933{
932 return mViewManager; 934 return mViewManager;
933} 935}
934 936
935KODialogManager *CalendarView::dialogManager() 937KODialogManager *CalendarView::dialogManager()
936{ 938{
937 return mDialogManager; 939 return mDialogManager;
938} 940}
939 941
940QDate CalendarView::startDate() 942QDate CalendarView::startDate()
941{ 943{
942 DateList dates = mNavigator->selectedDates(); 944 DateList dates = mNavigator->selectedDates();
943 945
944 return dates.first(); 946 return dates.first();
945} 947}
946 948
947QDate CalendarView::endDate() 949QDate CalendarView::endDate()
948{ 950{
949 DateList dates = mNavigator->selectedDates(); 951 DateList dates = mNavigator->selectedDates();
950 952
951 return dates.last(); 953 return dates.last();
952} 954}
953 955
954 956
955void CalendarView::createPrinter() 957void CalendarView::createPrinter()
956{ 958{
957#ifndef KORG_NOPRINTER 959#ifndef KORG_NOPRINTER
958 if (!mCalPrinter) { 960 if (!mCalPrinter) {
959 mCalPrinter = new CalPrinter(this, mCalendar); 961 mCalPrinter = new CalPrinter(this, mCalendar);
960 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 962 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
961 } 963 }
962#endif 964#endif
963} 965}
964 966
965 967
966//KOPrefs::instance()->mWriteBackFile 968//KOPrefs::instance()->mWriteBackFile
967//KOPrefs::instance()->mWriteBackExistingOnly 969//KOPrefs::instance()->mWriteBackExistingOnly
968 970
969// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 971// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
970// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 972// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
971// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 973// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
972// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 974// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
973// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 975// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
974// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 976// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
975 977
976int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 978int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
977{ 979{
978 980
979 // 0 equal 981 // 0 equal
980 // 1 take local 982 // 1 take local
981 // 2 take remote 983 // 2 take remote
982 // 3 cancel 984 // 3 cancel
983 QDateTime lastSync = mLastCalendarSync; 985 QDateTime lastSync = mLastCalendarSync;
984 QDateTime localMod = local->lastModified(); 986 QDateTime localMod = local->lastModified();
985 QDateTime remoteMod = remote->lastModified(); 987 QDateTime remoteMod = remote->lastModified();
986 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 988 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
987 bool remCh, locCh; 989 bool remCh, locCh;
988 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 990 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
989 //if ( remCh ) 991 //if ( remCh )
990 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 992 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
991 locCh = ( localMod > mLastCalendarSync ); 993 locCh = ( localMod > mLastCalendarSync );
992 if ( !remCh && ! locCh ) { 994 if ( !remCh && ! locCh ) {
993 //qDebug("both not changed "); 995 //qDebug("both not changed ");
994 lastSync = localMod.addDays(1); 996 lastSync = localMod.addDays(1);
995 if ( mode <= SYNC_PREF_ASK ) 997 if ( mode <= SYNC_PREF_ASK )
996 return 0; 998 return 0;
997 } else { 999 } else {
998 if ( locCh ) { 1000 if ( locCh ) {
999 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); 1001 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1());
1000 lastSync = localMod.addDays( -1 ); 1002 lastSync = localMod.addDays( -1 );
1001 if ( !remCh ) 1003 if ( !remCh )
1002 remoteMod = ( lastSync.addDays( -1 ) ); 1004 remoteMod = ( lastSync.addDays( -1 ) );
1003 } else { 1005 } else {
1004 //qDebug(" not loc changed "); 1006 //qDebug(" not loc changed ");
1005 lastSync = localMod.addDays( 1 ); 1007 lastSync = localMod.addDays( 1 );
1006 if ( remCh ) 1008 if ( remCh )
1007 remoteMod =( lastSync.addDays( 1 ) ); 1009 remoteMod =( lastSync.addDays( 1 ) );
1008 1010
1009 } 1011 }
1010 } 1012 }
1011 full = true; 1013 full = true;
1012 if ( mode < SYNC_PREF_ASK ) 1014 if ( mode < SYNC_PREF_ASK )
1013 mode = SYNC_PREF_ASK; 1015 mode = SYNC_PREF_ASK;
1014 } else { 1016 } else {
1015 if ( localMod == remoteMod ) 1017 if ( localMod == remoteMod )
1016 // if ( local->revision() == remote->revision() ) 1018 // if ( local->revision() == remote->revision() )
1017 return 0; 1019 return 0;
1018 1020
1019 } 1021 }
1020 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 1022 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
1021 1023
1022 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); 1024 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision());
1023 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); 1025 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() );
1024 //full = true; //debug only 1026 //full = true; //debug only
1025 if ( full ) { 1027 if ( full ) {
1026 bool equ = false; 1028 bool equ = false;
1027 if ( local->typeID() == eventID ) { 1029 if ( local->typeID() == eventID ) {
1028 equ = (*((Event*) local) == *((Event*) remote)); 1030 equ = (*((Event*) local) == *((Event*) remote));
1029 } 1031 }
1030 else if ( local->typeID() == todoID ) 1032 else if ( local->typeID() == todoID )
1031 equ = (*((Todo*) local) == (*(Todo*) remote)); 1033 equ = (*((Todo*) local) == (*(Todo*) remote));
1032 else if ( local->typeID() == journalID ) 1034 else if ( local->typeID() == journalID )
1033 equ = (*((Journal*) local) == *((Journal*) remote)); 1035 equ = (*((Journal*) local) == *((Journal*) remote));
1034 if ( equ ) { 1036 if ( equ ) {
1035 //qDebug("equal "); 1037 //qDebug("equal ");
1036 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1038 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1037 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 1039 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
1038 } 1040 }
1039 if ( mode < SYNC_PREF_FORCE_LOCAL ) 1041 if ( mode < SYNC_PREF_FORCE_LOCAL )
1040 return 0; 1042 return 0;
1041 1043
1042 }//else //debug only 1044 }//else //debug only
1043 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 1045 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
1044 } 1046 }
1045 int result; 1047 int result;
1046 bool localIsNew; 1048 bool localIsNew;
1047 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() ); 1049 //qDebug("%s -- %s mLastCalendarSync %s lastsync %s --- local %s remote %s ",local->summary().latin1(), remote->summary().latin1(),mLastCalendarSync.toString().latin1() ,lastSync.toString().latin1() , localMod.toString().latin1() , remoteMod.toString().latin1() );
1048 1050
1049 1051
1050 // ************************************************ 1052 // ************************************************
1051 // ************************************************ 1053 // ************************************************
1052 // ************************************************ 1054 // ************************************************
1053 // We may have that lastSync > remoteMod AND lastSync > localMod 1055 // We may have that lastSync > remoteMod AND lastSync > localMod
1054 // BUT remoteMod != localMod 1056 // BUT remoteMod != localMod
1055 1057
1056 1058
1057 if ( full && mode < SYNC_PREF_NEWEST ) 1059 if ( full && mode < SYNC_PREF_NEWEST )
1058 mode = SYNC_PREF_ASK; 1060 mode = SYNC_PREF_ASK;
1059 1061
1060 switch( mode ) { 1062 switch( mode ) {
1061 case SYNC_PREF_LOCAL: 1063 case SYNC_PREF_LOCAL:
1062 if ( lastSync > remoteMod ) 1064 if ( lastSync > remoteMod )
1063 return 1; 1065 return 1;
1064 if ( lastSync > localMod ) 1066 if ( lastSync > localMod )
1065 return 2; 1067 return 2;
1066 return 1; 1068 return 1;
1067 break; 1069 break;
1068 case SYNC_PREF_REMOTE: 1070 case SYNC_PREF_REMOTE:
1069 if ( lastSync > localMod ) 1071 if ( lastSync > localMod )
1070 return 2; 1072 return 2;
1071 if ( lastSync > remoteMod ) 1073 if ( lastSync > remoteMod )
1072 return 1; 1074 return 1;
1073 return 2; 1075 return 2;
1074 break; 1076 break;
1075 case SYNC_PREF_NEWEST: 1077 case SYNC_PREF_NEWEST:
1076 if ( localMod >= remoteMod ) 1078 if ( localMod >= remoteMod )
1077 return 1; 1079 return 1;
1078 else 1080 else
1079 return 2; 1081 return 2;
1080 break; 1082 break;
1081 case SYNC_PREF_ASK: 1083 case SYNC_PREF_ASK:
1082 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 1084 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
1083 if ( lastSync > remoteMod && lastSync > localMod) 1085 if ( lastSync > remoteMod && lastSync > localMod)
1084 return 0; 1086 return 0;
1085 if ( lastSync > remoteMod ) 1087 if ( lastSync > remoteMod )
1086 return 1; 1088 return 1;
1087 if ( lastSync > localMod ) 1089 if ( lastSync > localMod )
1088 return 2; 1090 return 2;
1089 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 1091 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
1090 localIsNew = localMod >= remoteMod; 1092 localIsNew = localMod >= remoteMod;
1091 if ( localIsNew ) 1093 if ( localIsNew )
1092 getEventViewerDialog()->setColorMode( 1 ); 1094 getEventViewerDialog()->setColorMode( 1 );
1093 else 1095 else
1094 getEventViewerDialog()->setColorMode( 2 ); 1096 getEventViewerDialog()->setColorMode( 2 );
1095 getEventViewerDialog()->setIncidence(local); 1097 getEventViewerDialog()->setIncidence(local);
1096 if ( localIsNew ) 1098 if ( localIsNew )
1097 getEventViewerDialog()->setColorMode( 2 ); 1099 getEventViewerDialog()->setColorMode( 2 );
1098 else 1100 else
1099 getEventViewerDialog()->setColorMode( 1 ); 1101 getEventViewerDialog()->setColorMode( 1 );
1100 getEventViewerDialog()->addIncidence(remote); 1102 getEventViewerDialog()->addIncidence(remote);
1101 getEventViewerDialog()->setColorMode( 0 ); 1103 getEventViewerDialog()->setColorMode( 0 );
1102 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 1104 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
1103 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 1105 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
1104 getEventViewerDialog()->showMe(); 1106 getEventViewerDialog()->showMe();
1105 result = getEventViewerDialog()->executeS( localIsNew ); 1107 result = getEventViewerDialog()->executeS( localIsNew );
1106 return result; 1108 return result;
1107 1109
1108 break; 1110 break;
1109 case SYNC_PREF_FORCE_LOCAL: 1111 case SYNC_PREF_FORCE_LOCAL:
1110 return 1; 1112 return 1;
1111 break; 1113 break;
1112 case SYNC_PREF_FORCE_REMOTE: 1114 case SYNC_PREF_FORCE_REMOTE:
1113 return 2; 1115 return 2;
1114 break; 1116 break;
1115 1117
1116 default: 1118 default:
1117 // SYNC_PREF_TAKE_BOTH not implemented 1119 // SYNC_PREF_TAKE_BOTH not implemented
1118 break; 1120 break;
1119 } 1121 }
1120 return 0; 1122 return 0;
1121} 1123}
1122Event* CalendarView::getLastSyncEvent() 1124Event* CalendarView::getLastSyncEvent()
1123{ 1125{
1124 Event* lse; 1126 Event* lse;
1125 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 1127 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
1126 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 1128 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
1127 if (!lse) { 1129 if (!lse) {
1128 lse = new Event(); 1130 lse = new Event();
1129 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 1131 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
1130 QString sum = ""; 1132 QString sum = "";
1131 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 1133 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
1132 sum = "E: "; 1134 sum = "E: ";
1133 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 1135 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
1134 lse->setDtStart( mLastCalendarSync ); 1136 lse->setDtStart( mLastCalendarSync );
1135 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 1137 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
1136 lse->setCategories( i18n("SyncEvent") ); 1138 lse->setCategories( i18n("SyncEvent") );
1137 lse->setReadOnly( true ); 1139 lse->setReadOnly( true );
1138 mCalendar->addEvent( lse ); 1140 mCalendar->addEvent( lse );
1139 } 1141 }
1140 1142
1141 return lse; 1143 return lse;
1142 1144
1143} 1145}
1144 1146
1145// we check, if the to delete event has a id for a profile 1147// we check, if the to delete event has a id for a profile
1146// if yes, we set this id in the profile to delete 1148// if yes, we set this id in the profile to delete
1147void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 1149void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
1148{ 1150{
1149 if ( lastSync.count() == 0 ) { 1151 if ( lastSync.count() == 0 ) {
1150 //qDebug(" lastSync.count() == 0"); 1152 //qDebug(" lastSync.count() == 0");
1151 return; 1153 return;
1152 } 1154 }
1153 if ( toDelete->typeID() == journalID ) 1155 if ( toDelete->typeID() == journalID )
1154 return; 1156 return;
1155 1157
1156 Event* eve = lastSync.first(); 1158 Event* eve = lastSync.first();
1157 1159
1158 while ( eve ) { 1160 while ( eve ) {
1159 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 1161 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
1160 if ( !id.isEmpty() ) { 1162 if ( !id.isEmpty() ) {
1161 QString des = eve->description(); 1163 QString des = eve->description();
1162 QString pref = "e"; 1164 QString pref = "e";
1163 if ( toDelete->typeID() == todoID ) 1165 if ( toDelete->typeID() == todoID )
1164 pref = "t"; 1166 pref = "t";
1165 des += pref+ id + ","; 1167 des += pref+ id + ",";
1166 eve->setReadOnly( false ); 1168 eve->setReadOnly( false );
1167 eve->setDescription( des ); 1169 eve->setDescription( des );
1168 //qDebug("setdes %s ", des.latin1()); 1170 //qDebug("setdes %s ", des.latin1());
1169 eve->setReadOnly( true ); 1171 eve->setReadOnly( true );
1170 } 1172 }
1171 eve = lastSync.next(); 1173 eve = lastSync.next();
1172 } 1174 }
1173 1175
1174} 1176}
1175void CalendarView::checkExternalId( Incidence * inc ) 1177void CalendarView::checkExternalId( Incidence * inc )
1176{ 1178{
1177 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 1179 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
1178 checkExternSyncEvent( lastSync, inc ); 1180 checkExternSyncEvent( lastSync, inc );
1179 1181
1180} 1182}
1181bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 1183bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
1182{ 1184{
1183 bool syncOK = true; 1185 bool syncOK = true;
1184 int addedEvent = 0; 1186 int addedEvent = 0;
1185 int addedEventR = 0; 1187 int addedEventR = 0;
1186 int deletedEventR = 0; 1188 int deletedEventR = 0;
1187 int deletedEventL = 0; 1189 int deletedEventL = 0;
1188 int changedLocal = 0; 1190 int changedLocal = 0;
1189 int changedRemote = 0; 1191 int changedRemote = 0;
1190 int filteredIN = 0; 1192 int filteredIN = 0;
1191 int filteredOUT = 0; 1193 int filteredOUT = 0;
1192 //QPtrList<Event> el = local->rawEvents(); 1194 //QPtrList<Event> el = local->rawEvents();
1193 Event* eventR; 1195 Event* eventR;
1194 QString uid; 1196 QString uid;
1195 int take; 1197 int take;
1196 Event* eventL; 1198 Event* eventL;
1197 Event* eventRSync; 1199 Event* eventRSync;
1198 Event* eventLSync; 1200 Event* eventLSync;
1199 clearAllViews(); 1201 clearAllViews();
1200 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 1202 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
1201 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 1203 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
1202 bool fullDateRange = false; 1204 bool fullDateRange = false;
1203 local->resetTempSyncStat(); 1205 local->resetTempSyncStat();
1204 mLastCalendarSync = QDateTime::currentDateTime(); 1206 mLastCalendarSync = QDateTime::currentDateTime();
1205 if ( mSyncManager->syncWithDesktop() ) { 1207 if ( mSyncManager->syncWithDesktop() ) {
1206 remote->resetPilotStat(1); 1208 remote->resetPilotStat(1);
1207 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 1209 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
1208 mLastCalendarSync = KSyncManager::mRequestedSyncEvent; 1210 mLastCalendarSync = KSyncManager::mRequestedSyncEvent;
1209 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); 1211 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() );
1210 } else { 1212 } else {
1211 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 1213 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
1212 } 1214 }
1213 } 1215 }
1214 QDateTime modifiedCalendar = mLastCalendarSync; 1216 QDateTime modifiedCalendar = mLastCalendarSync;
1215 eventLSync = getLastSyncEvent(); 1217 eventLSync = getLastSyncEvent();
1216 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 1218 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
1217 if ( eventR ) { 1219 if ( eventR ) {
1218 eventRSync = (Event*) eventR->clone(); 1220 eventRSync = (Event*) eventR->clone();
1219 remote->deleteEvent(eventR ); 1221 remote->deleteEvent(eventR );
1220 1222
1221 } else { 1223 } else {
1222 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { 1224 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) {
1223 eventRSync = (Event*)eventLSync->clone(); 1225 eventRSync = (Event*)eventLSync->clone();
1224 } else { 1226 } else {
1225 fullDateRange = true; 1227 fullDateRange = true;
1226 eventRSync = new Event(); 1228 eventRSync = new Event();
1227 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 1229 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
1228 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 1230 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
1229 eventRSync->setDtStart( mLastCalendarSync ); 1231 eventRSync->setDtStart( mLastCalendarSync );
1230 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 1232 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
1231 eventRSync->setCategories( i18n("SyncEvent") ); 1233 eventRSync->setCategories( i18n("SyncEvent") );
1232 } 1234 }
1233 } 1235 }
1234 if ( eventLSync->dtStart() == mLastCalendarSync ) 1236 if ( eventLSync->dtStart() == mLastCalendarSync )
1235 fullDateRange = true; 1237 fullDateRange = true;
1236 1238
1237 if ( ! fullDateRange ) { 1239 if ( ! fullDateRange ) {
1238 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 1240 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
1239 1241
1240 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 1242 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
1241 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 1243 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
1242 fullDateRange = true; 1244 fullDateRange = true;
1243 } 1245 }
1244 } 1246 }
1245 if ( mSyncManager->syncWithDesktop() ) { 1247 if ( mSyncManager->syncWithDesktop() ) {
1246 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); 1248 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync );
1247 } 1249 }
1248 if ( fullDateRange ) 1250 if ( fullDateRange )
1249 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 1251 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
1250 else 1252 else
1251 mLastCalendarSync = eventLSync->dtStart(); 1253 mLastCalendarSync = eventLSync->dtStart();
1252 // for resyncing if own file has changed 1254 // for resyncing if own file has changed
1253 if ( mCurrentSyncDevice == "deleteaftersync" ) { 1255 if ( mCurrentSyncDevice == "deleteaftersync" ) {
1254 mLastCalendarSync = loadedFileVersion; 1256 mLastCalendarSync = loadedFileVersion;
1255 //qDebug("setting mLastCalendarSync "); 1257 //qDebug("setting mLastCalendarSync ");
1256 } 1258 }
1257 //qDebug("*************************** "); 1259 //qDebug("*************************** ");
1258 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); 1260 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange);
1259 QPtrList<Incidence> er = remote->rawIncidences(); 1261 QPtrList<Incidence> er = remote->rawIncidences();
1260 Incidence* inR = er.first(); 1262 Incidence* inR = er.first();
1261 Incidence* inL; 1263 Incidence* inL;
1262 QProgressBar bar( er.count(),0 ); 1264 QProgressBar bar( er.count(),0 );
1263 bar.setCaption (i18n("Syncing - close to abort!") ); 1265 bar.setCaption (i18n("Syncing - close to abort!") );
1264 1266
1265 // ************** setting up filter ************* 1267 // ************** setting up filter *************
1266 CalFilter *filterIN = 0; 1268 CalFilter *filterIN = 0;
1267 CalFilter *filterOUT = 0; 1269 CalFilter *filterOUT = 0;
1268 CalFilter *filter = mFilters.first(); 1270 CalFilter *filter = mFilters.first();
1269 while(filter) { 1271 while(filter) {
1270 if ( filter->name() == mSyncManager->mFilterInCal ) 1272 if ( filter->name() == mSyncManager->mFilterInCal )
1271 filterIN = filter; 1273 filterIN = filter;
1272 if ( filter->name() == mSyncManager->mFilterOutCal ) 1274 if ( filter->name() == mSyncManager->mFilterOutCal )
1273 filterOUT = filter; 1275 filterOUT = filter;
1274 filter = mFilters.next(); 1276 filter = mFilters.next();
1275 } 1277 }
1276 int w = 300; 1278 int w = 300;
1277 if ( QApplication::desktop()->width() < 320 ) 1279 if ( QApplication::desktop()->width() < 320 )
1278 w = 220; 1280 w = 220;
1279 int h = bar.sizeHint().height() ; 1281 int h = bar.sizeHint().height() ;
1280 int dw = QApplication::desktop()->width(); 1282 int dw = QApplication::desktop()->width();
1281 int dh = QApplication::desktop()->height(); 1283 int dh = QApplication::desktop()->height();
1282 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1284 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1283 bar.show(); 1285 bar.show();
1284 int modulo = (er.count()/10)+1; 1286 int modulo = (er.count()/10)+1;
1285 int incCounter = 0; 1287 int incCounter = 0;
1286 while ( inR ) { 1288 while ( inR ) {
1287 if ( ! bar.isVisible() ) 1289 if ( ! bar.isVisible() )
1288 return false; 1290 return false;
1289 if ( incCounter % modulo == 0 ) 1291 if ( incCounter % modulo == 0 )
1290 bar.setProgress( incCounter ); 1292 bar.setProgress( incCounter );
1291 ++incCounter; 1293 ++incCounter;
1292 uid = inR->uid(); 1294 uid = inR->uid();
1293 bool skipIncidence = false; 1295 bool skipIncidence = false;
1294 if ( uid.left(15) == QString("last-syncEvent-") ) 1296 if ( uid.left(15) == QString("last-syncEvent-") )
1295 skipIncidence = true; 1297 skipIncidence = true;
1296 QString idS; 1298 QString idS;
1297 qApp->processEvents(); 1299 qApp->processEvents();
1298 if ( !skipIncidence ) { 1300 if ( !skipIncidence ) {
1299 inL = local->incidence( uid ); 1301 inL = local->incidence( uid );
1300 if ( inL ) { // maybe conflict - same uid in both calendars 1302 if ( inL ) { // maybe conflict - same uid in both calendars
1301 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1303 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1302 //qDebug("take %d %s ", take, inL->summary().latin1()); 1304 //qDebug("take %d %s ", take, inL->summary().latin1());
1303 if ( take == 3 ) 1305 if ( take == 3 )
1304 return false; 1306 return false;
1305 if ( take == 1 ) {// take local ********************** 1307 if ( take == 1 ) {// take local **********************
1306 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1308 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1307 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1309 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1308 else 1310 else
1309 idS = inR->IDStr(); 1311 idS = inR->IDStr();
1310 remote->deleteIncidence( inR ); 1312 remote->deleteIncidence( inR );
1311 inR = inL->clone(); 1313 inR = inL->clone();
1312 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1314 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1313 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1315 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1314 inR->setIDStr( idS ); 1316 inR->setIDStr( idS );
1315 remote->addIncidence( inR ); 1317 remote->addIncidence( inR );
1316 if ( mSyncManager->syncWithDesktop() ) 1318 if ( mSyncManager->syncWithDesktop() )
1317 inR->setPilotId( 2 ); 1319 inR->setPilotId( 2 );
1318 ++changedRemote; 1320 ++changedRemote;
1319 } else {// take remote ********************** 1321 } else {// take remote **********************
1320 idS = inL->IDStr(); 1322 idS = inL->IDStr();
1321 int pid = inL->pilotId(); 1323 int pid = inL->pilotId();
1322 local->deleteIncidence( inL ); 1324 local->deleteIncidence( inL );
1323 inL = inR->clone(); 1325 inL = inR->clone();
1324 if ( mSyncManager->syncWithDesktop() ) 1326 if ( mSyncManager->syncWithDesktop() )
1325 inL->setPilotId( pid ); 1327 inL->setPilotId( pid );
1326 inL->setIDStr( idS ); 1328 inL->setIDStr( idS );
1327 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1329 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1328 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1330 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1329 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1331 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1330 } 1332 }
1331 local->addIncidence( inL ); 1333 local->addIncidence( inL );
1332 ++changedLocal; 1334 ++changedLocal;
1333 } 1335 }
1334 } 1336 }
1335 } else { // no conflict ********** add or delete remote 1337 } else { // no conflict ********** add or delete remote
1336 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ 1338 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){
1337 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1339 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1338 QString des = eventLSync->description(); 1340 QString des = eventLSync->description();
1339 QString pref = "e"; 1341 QString pref = "e";
1340 if ( inR->typeID() == todoID ) 1342 if ( inR->typeID() == todoID )
1341 pref = "t"; 1343 pref = "t";
1342 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1344 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1343 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1345 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1344 //remote->deleteIncidence( inR ); 1346 //remote->deleteIncidence( inR );
1345 ++deletedEventR; 1347 ++deletedEventR;
1346 } else { 1348 } else {
1347 inR->setLastModified( modifiedCalendar ); 1349 inR->setLastModified( modifiedCalendar );
1348 inL = inR->clone(); 1350 inL = inR->clone();
1349 inL->setIDStr( ":" ); 1351 inL->setIDStr( ":" );
1350 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1352 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1351 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1353 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1352 local->addIncidence( inL ); 1354 local->addIncidence( inL );
1353 ++addedEvent; 1355 ++addedEvent;
1354 1356
1355 } 1357 }
1356 } else { 1358 } else {
1357 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1359 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1358 inR->setLastModified( modifiedCalendar ); 1360 inR->setLastModified( modifiedCalendar );
1359 inL = inR->clone(); 1361 inL = inR->clone();
1360 inL->setIDStr( ":" ); 1362 inL->setIDStr( ":" );
1361 local->addIncidence( inL ); 1363 local->addIncidence( inL );
1362 ++addedEvent; 1364 ++addedEvent;
1363 1365
1364 } else { 1366 } else {
1365 checkExternSyncEvent(eventRSyncSharp, inR); 1367 checkExternSyncEvent(eventRSyncSharp, inR);
1366 remote->deleteIncidence( inR ); 1368 remote->deleteIncidence( inR );
1367 ++deletedEventR; 1369 ++deletedEventR;
1368 } 1370 }
1369 } 1371 }
1370 } else { 1372 } else {
1371 ++filteredIN; 1373 ++filteredIN;
1372 } 1374 }
1373 } 1375 }
1374 } 1376 }
1375 inR = er.next(); 1377 inR = er.next();
1376 } 1378 }
1377 QPtrList<Incidence> el = local->rawIncidences(); 1379 QPtrList<Incidence> el = local->rawIncidences();
1378 inL = el.first(); 1380 inL = el.first();
1379 modulo = (el.count()/10)+1; 1381 modulo = (el.count()/10)+1;
1380 bar.setCaption (i18n("Add / remove events") ); 1382 bar.setCaption (i18n("Add / remove events") );
1381 bar.setTotalSteps ( el.count() ) ; 1383 bar.setTotalSteps ( el.count() ) ;
1382 bar.show(); 1384 bar.show();
1383 incCounter = 0; 1385 incCounter = 0;
1384 1386
1385 while ( inL ) { 1387 while ( inL ) {
1386 1388
1387 qApp->processEvents(); 1389 qApp->processEvents();
1388 if ( ! bar.isVisible() ) 1390 if ( ! bar.isVisible() )
1389 return false; 1391 return false;
1390 if ( incCounter % modulo == 0 ) 1392 if ( incCounter % modulo == 0 )
1391 bar.setProgress( incCounter ); 1393 bar.setProgress( incCounter );
1392 ++incCounter; 1394 ++incCounter;
1393 uid = inL->uid(); 1395 uid = inL->uid();
1394 bool skipIncidence = false; 1396 bool skipIncidence = false;
1395 if ( uid.left(15) == QString("last-syncEvent-") ) 1397 if ( uid.left(15) == QString("last-syncEvent-") )
1396 skipIncidence = true; 1398 skipIncidence = true;
1397 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) 1399 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID )
1398 skipIncidence = true; 1400 skipIncidence = true;
1399 if ( !skipIncidence ) { 1401 if ( !skipIncidence ) {
1400 inR = remote->incidence( uid ); 1402 inR = remote->incidence( uid );
1401 if ( ! inR ) { 1403 if ( ! inR ) {
1402 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ 1404 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){
1403 // no conflict ********** add or delete local 1405 // no conflict ********** add or delete local
1404 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1406 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1405 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1407 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1406 checkExternSyncEvent(eventLSyncSharp, inL); 1408 checkExternSyncEvent(eventLSyncSharp, inL);
1407 local->deleteIncidence( inL ); 1409 local->deleteIncidence( inL );
1408 ++deletedEventL; 1410 ++deletedEventL;
1409 } else { 1411 } else {
1410 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1412 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1411 inL->removeID(mCurrentSyncDevice ); 1413 inL->removeID(mCurrentSyncDevice );
1412 ++addedEventR; 1414 ++addedEventR;
1413 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1415 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1414 inL->setLastModified( modifiedCalendar ); 1416 inL->setLastModified( modifiedCalendar );
1415 inR = inL->clone(); 1417 inR = inL->clone();
1416 inR->setIDStr( ":" ); 1418 inR->setIDStr( ":" );
1417 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1419 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1418 remote->addIncidence( inR ); 1420 remote->addIncidence( inR );
1419 } 1421 }
1420 } 1422 }
1421 } else { 1423 } else {
1422 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1424 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1423 checkExternSyncEvent(eventLSyncSharp, inL); 1425 checkExternSyncEvent(eventLSyncSharp, inL);
1424 local->deleteIncidence( inL ); 1426 local->deleteIncidence( inL );
1425 ++deletedEventL; 1427 ++deletedEventL;
1426 } else { 1428 } else {
1427 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1429 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1428 ++addedEventR; 1430 ++addedEventR;
1429 inL->setLastModified( modifiedCalendar ); 1431 inL->setLastModified( modifiedCalendar );
1430 inR = inL->clone(); 1432 inR = inL->clone();
1431 inR->setIDStr( ":" ); 1433 inR->setIDStr( ":" );
1432 remote->addIncidence( inR ); 1434 remote->addIncidence( inR );
1433 } 1435 }
1434 } 1436 }
1435 } 1437 }
1436 } else { 1438 } else {
1437 ++filteredOUT; 1439 ++filteredOUT;
1438 } 1440 }
1439 } 1441 }
1440 } 1442 }
1441 inL = el.next(); 1443 inL = el.next();
1442 } 1444 }
1443 int delFut = 0; 1445 int delFut = 0;
1444 int remRem = 0; 1446 int remRem = 0;
1445 if ( mSyncManager->mWriteBackInFuture ) { 1447 if ( mSyncManager->mWriteBackInFuture ) {
1446 er = remote->rawIncidences(); 1448 er = remote->rawIncidences();
1447 remRem = er.count(); 1449 remRem = er.count();
1448 inR = er.first(); 1450 inR = er.first();
1449 QDateTime dt; 1451 QDateTime dt;
1450 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); 1452 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) );
1451 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); 1453 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 );
1452 while ( inR ) { 1454 while ( inR ) {
1453 if ( inR->typeID() == todoID ) { 1455 if ( inR->typeID() == todoID ) {
1454 Todo * t = (Todo*)inR; 1456 Todo * t = (Todo*)inR;
1455 if ( t->hasDueDate() ) 1457 if ( t->hasDueDate() )
1456 dt = t->dtDue(); 1458 dt = t->dtDue();
1457 else 1459 else
1458 dt = cur.addSecs( 62 ); 1460 dt = cur.addSecs( 62 );
1459 } 1461 }
1460 else if (inR->typeID() == eventID ) { 1462 else if (inR->typeID() == eventID ) {
1461 bool ok; 1463 bool ok;
1462 dt = inR->getNextOccurence( cur, &ok ); 1464 dt = inR->getNextOccurence( cur, &ok );
1463 if ( !ok ) 1465 if ( !ok )
1464 dt = cur.addSecs( -62 ); 1466 dt = cur.addSecs( -62 );
1465 } 1467 }
1466 else 1468 else
1467 dt = inR->dtStart(); 1469 dt = inR->dtStart();
1468 if ( dt < cur || dt > end ) { 1470 if ( dt < cur || dt > end ) {
1469 remote->deleteIncidence( inR ); 1471 remote->deleteIncidence( inR );
1470 ++delFut; 1472 ++delFut;
1471 } 1473 }
1472 inR = er.next(); 1474 inR = er.next();
1473 } 1475 }
1474 } 1476 }
1475 bar.hide(); 1477 bar.hide();
1476 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1478 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1477 eventLSync->setReadOnly( false ); 1479 eventLSync->setReadOnly( false );
1478 eventLSync->setDtStart( mLastCalendarSync ); 1480 eventLSync->setDtStart( mLastCalendarSync );
1479 eventRSync->setDtStart( mLastCalendarSync ); 1481 eventRSync->setDtStart( mLastCalendarSync );
1480 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1482 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1481 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1483 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1482 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1484 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1483 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1485 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1484 eventLSync->setReadOnly( true ); 1486 eventLSync->setReadOnly( true );
1485 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); 1487 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL );
1486 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... 1488 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal...
1487 remote->addEvent( eventRSync ); 1489 remote->addEvent( eventRSync );
1488 else 1490 else
1489 delete eventRSync; 1491 delete eventRSync;
1490 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); 1492 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() );
1491 QString mes; 1493 QString mes;
1492 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); 1494 mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT );
1493 QString delmess; 1495 QString delmess;
1494 if ( delFut ) { 1496 if ( delFut ) {
1495 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut); 1497 delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are more\nthan %d weeks in the past or\nmore than %d weeks in the future.\nAfter skipping, remote has\n%d calendar/todo items."), delFut,mSyncManager->mWriteBackInPast,mSyncManager->mWriteBackInFuture, remRem-delFut);
1496 mes += delmess; 1498 mes += delmess;
1497 } 1499 }
1498 mes = i18n("Local calendar changed!\n") +mes; 1500 mes = i18n("Local calendar changed!\n") +mes;
1499 mCalendar->checkAlarmForIncidence( 0, true ); 1501 mCalendar->checkAlarmForIncidence( 0, true );
1500 qDebug( mes ); 1502 qDebug( mes );
1501 if ( mSyncManager->mShowSyncSummary ) { 1503 if ( mSyncManager->mShowSyncSummary ) {
1502 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 1504 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
1503 i18n("KO/Pi Synchronization"),i18n("Write back"))) { 1505 i18n("KO/Pi Synchronization"),i18n("Write back"))) {
1504 qDebug("KO: WB cancelled "); 1506 qDebug("KO: WB cancelled ");
1505 mSyncManager->mWriteBackFile = false; 1507 mSyncManager->mWriteBackFile = false;
1506 return syncOK; 1508 return syncOK;
1507 } 1509 }
1508 } 1510 }
1509 return syncOK; 1511 return syncOK;
1510} 1512}
1511 1513
1512void CalendarView::setSyncDevice( QString s ) 1514void CalendarView::setSyncDevice( QString s )
1513{ 1515{
1514 mCurrentSyncDevice= s; 1516 mCurrentSyncDevice= s;
1515} 1517}
1516void CalendarView::setSyncName( QString s ) 1518void CalendarView::setSyncName( QString s )
1517{ 1519{
1518 mCurrentSyncName= s; 1520 mCurrentSyncName= s;
1519} 1521}
1520bool CalendarView::syncCalendar(QString filename, int mode) 1522bool CalendarView::syncCalendar(QString filename, int mode)
1521{ 1523{
1522 //qDebug("syncCalendar %s ", filename.latin1()); 1524 //qDebug("syncCalendar %s ", filename.latin1());
1523 mGlobalSyncMode = SYNC_MODE_NORMAL; 1525 mGlobalSyncMode = SYNC_MODE_NORMAL;
1524 CalendarLocal* calendar = new CalendarLocal(); 1526 CalendarLocal* calendar = new CalendarLocal();
1525 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1527 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1526 FileStorage* storage = new FileStorage( calendar ); 1528 FileStorage* storage = new FileStorage( calendar );
1527 bool syncOK = false; 1529 bool syncOK = false;
1528 storage->setFileName( filename ); 1530 storage->setFileName( filename );
1529 // qDebug("loading ... "); 1531 // qDebug("loading ... ");
1530 if ( storage->load() ) { 1532 if ( storage->load() ) {
1531 getEventViewerDialog()->setSyncMode( true ); 1533 getEventViewerDialog()->setSyncMode( true );
1532 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1534 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1533 getEventViewerDialog()->setSyncMode( false ); 1535 getEventViewerDialog()->setSyncMode( false );
1534 if ( syncOK ) { 1536 if ( syncOK ) {
1535 if ( mSyncManager->mWriteBackFile ) 1537 if ( mSyncManager->mWriteBackFile )
1536 { 1538 {
1537 storage->setSaveFormat( new ICalFormat() ); 1539 storage->setSaveFormat( new ICalFormat() );
1538 storage->save(); 1540 storage->save();
1539 } 1541 }
1540 } 1542 }
1541 setModified( true ); 1543 setModified( true );
1542 } 1544 }
1543 delete storage; 1545 delete storage;
1544 delete calendar; 1546 delete calendar;
1545 if ( syncOK ) 1547 if ( syncOK )
1546 updateView(); 1548 updateView();
1547 return syncOK; 1549 return syncOK;
1548} 1550}
1549 1551
1550void CalendarView::syncExternal( int mode ) 1552void CalendarView::syncExternal( int mode )
1551{ 1553{
1552 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1554 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1553 1555
1554 qApp->processEvents(); 1556 qApp->processEvents();
1555 CalendarLocal* calendar = new CalendarLocal(); 1557 CalendarLocal* calendar = new CalendarLocal();
1556 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1558 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1557 bool syncOK = false; 1559 bool syncOK = false;
1558 bool loadSuccess = false; 1560 bool loadSuccess = false;
1559 PhoneFormat* phoneFormat = 0; 1561 PhoneFormat* phoneFormat = 0;
1560 emit tempDisableBR(true); 1562 emit tempDisableBR(true);
1561#ifndef DESKTOP_VERSION 1563#ifndef DESKTOP_VERSION
1562 SharpFormat* sharpFormat = 0; 1564 SharpFormat* sharpFormat = 0;
1563 if ( mode == 0 ) { // sharp 1565 if ( mode == 0 ) { // sharp
1564 sharpFormat = new SharpFormat () ; 1566 sharpFormat = new SharpFormat () ;
1565 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1567 loadSuccess = sharpFormat->load( calendar, mCalendar );
1566 1568
1567 } else 1569 } else
1568#endif 1570#endif
1569 if ( mode == 1 ) { // phone 1571 if ( mode == 1 ) { // phone
1570 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1572 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1571 mSyncManager->mPhoneDevice, 1573 mSyncManager->mPhoneDevice,
1572 mSyncManager->mPhoneConnection, 1574 mSyncManager->mPhoneConnection,
1573 mSyncManager->mPhoneModel); 1575 mSyncManager->mPhoneModel);
1574 loadSuccess = phoneFormat->load( calendar,mCalendar); 1576 loadSuccess = phoneFormat->load( calendar,mCalendar);
1575 1577
1576 } else { 1578 } else {
1577 emit tempDisableBR(false); 1579 emit tempDisableBR(false);
1578 return; 1580 return;
1579 } 1581 }
1580 if ( loadSuccess ) { 1582 if ( loadSuccess ) {
1581 getEventViewerDialog()->setSyncMode( true ); 1583 getEventViewerDialog()->setSyncMode( true );
1582 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1584 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1583 getEventViewerDialog()->setSyncMode( false ); 1585 getEventViewerDialog()->setSyncMode( false );
1584 qApp->processEvents(); 1586 qApp->processEvents();
1585 if ( syncOK ) { 1587 if ( syncOK ) {
1586 if ( mSyncManager->mWriteBackFile ) 1588 if ( mSyncManager->mWriteBackFile )
1587 { 1589 {
1588 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1590 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1589 Incidence* inc = iL.first(); 1591 Incidence* inc = iL.first();
1590 if ( phoneFormat ) { 1592 if ( phoneFormat ) {
1591 while ( inc ) { 1593 while ( inc ) {
1592 inc->removeID(mCurrentSyncDevice); 1594 inc->removeID(mCurrentSyncDevice);
1593 inc = iL.next(); 1595 inc = iL.next();
1594 } 1596 }
1595 } 1597 }
1596#ifndef DESKTOP_VERSION 1598#ifndef DESKTOP_VERSION
1597 if ( sharpFormat ) 1599 if ( sharpFormat )
1598 sharpFormat->save(calendar); 1600 sharpFormat->save(calendar);
1599#endif 1601#endif
1600 if ( phoneFormat ) 1602 if ( phoneFormat )
1601 phoneFormat->save(calendar); 1603 phoneFormat->save(calendar);
1602 iL = calendar->rawIncidences(); 1604 iL = calendar->rawIncidences();
1603 inc = iL.first(); 1605 inc = iL.first();
1604 Incidence* loc; 1606 Incidence* loc;
1605 while ( inc ) { 1607 while ( inc ) {
1606 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1608 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1607 loc = mCalendar->incidence(inc->uid() ); 1609 loc = mCalendar->incidence(inc->uid() );
1608 if ( loc ) { 1610 if ( loc ) {
1609 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1611 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1610 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1612 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1611 } 1613 }
1612 } 1614 }
1613 inc = iL.next(); 1615 inc = iL.next();
1614 } 1616 }
1615 Incidence* lse = getLastSyncEvent(); 1617 Incidence* lse = getLastSyncEvent();
1616 if ( lse ) { 1618 if ( lse ) {
1617 lse->setReadOnly( false ); 1619 lse->setReadOnly( false );
1618 lse->setDescription( "" ); 1620 lse->setDescription( "" );
1619 lse->setReadOnly( true ); 1621 lse->setReadOnly( true );
1620 } 1622 }
1621 } 1623 }
1622 } else { 1624 } else {
1623 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 1625 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
1624 } 1626 }
1625 setModified( true ); 1627 setModified( true );
1626 } else { 1628 } else {
1627 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1629 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1628 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1630 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1629 question, i18n("Ok")) ; 1631 question, i18n("Ok")) ;
1630 1632
1631 } 1633 }
1632 delete calendar; 1634 delete calendar;
1633 updateView(); 1635 updateView();
1634 emit tempDisableBR(false); 1636 emit tempDisableBR(false);
1635 return ;//syncOK; 1637 return ;//syncOK;
1636 1638
1637} 1639}
1638 1640
1639bool CalendarView::importBday() 1641bool CalendarView::importBday()
1640{ 1642{
1641#ifndef KORG_NOKABC 1643#ifndef KORG_NOKABC
1642 1644
1643#ifdef DESKTOP_VERSION 1645#ifdef DESKTOP_VERSION
1644 int curCal = mCalendar->defaultCalendar(); 1646 int curCal = mCalendar->defaultCalendar();
1645 int bd = mCalEditView->getBirtdayID(); 1647 int bd = mCalEditView->getBirtdayID();
1646 if ( bd == 0 ) 1648 if ( bd == 0 )
1647 return false; 1649 return false;
1648 mCalendar->setDefaultCalendar( bd ); 1650 mCalendar->setDefaultCalendar( bd );
1649 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1651 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1650 KABC::AddressBook::Iterator it; 1652 KABC::AddressBook::Iterator it;
1651 int count = 0; 1653 int count = 0;
1652 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1654 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1653 ++count; 1655 ++count;
1654 } 1656 }
1655 QProgressBar bar(count,0 ); 1657 QProgressBar bar(count,0 );
1656 int w = 300; 1658 int w = 300;
1657 if ( QApplication::desktop()->width() < 320 ) 1659 if ( QApplication::desktop()->width() < 320 )
1658 w = 220; 1660 w = 220;
1659 int h = bar.sizeHint().height() ; 1661 int h = bar.sizeHint().height() ;
1660 int dw = QApplication::desktop()->width(); 1662 int dw = QApplication::desktop()->width();
1661 int dh = QApplication::desktop()->height(); 1663 int dh = QApplication::desktop()->height();
1662 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1664 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1663 bar.show(); 1665 bar.show();
1664 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1666 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1665 qApp->processEvents(); 1667 qApp->processEvents();
1666 count = 0; 1668 count = 0;
1667 int addCount = 0; 1669 int addCount = 0;
1668 KCal::Attendee* a = 0; 1670 KCal::Attendee* a = 0;
1669 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1671 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1670 if ( ! bar.isVisible() ) 1672 if ( ! bar.isVisible() )
1671 return false; 1673 return false;
1672 bar.setProgress( count++ ); 1674 bar.setProgress( count++ );
1673 qApp->processEvents(); 1675 qApp->processEvents();
1674 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1676 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1675 if ( (*it).birthday().date().isValid() ){ 1677 if ( (*it).birthday().date().isValid() ){
1676 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1678 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1677 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1679 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1678 ++addCount; 1680 ++addCount;
1679 } 1681 }
1680 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1682 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1681 if ( anni.isValid() ){ 1683 if ( anni.isValid() ){
1682 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1684 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1683 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1685 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1684 ++addCount; 1686 ++addCount;
1685 } 1687 }
1686 } 1688 }
1687 mCalendar->setDefaultCalendar( curCal ); 1689 mCalendar->setDefaultCalendar( curCal );
1688 updateView(); 1690 updateView();
1689 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1691 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1690#else //DESKTOP_VERSION 1692#else //DESKTOP_VERSION
1691 1693
1692 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 1694 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
1693 // the result should now arrive through method insertBirthdays 1695 // the result should now arrive through method insertBirthdays
1694 1696
1695#endif //DESKTOP_VERSION 1697#endif //DESKTOP_VERSION
1696 1698
1697#endif //KORG_NOKABC 1699#endif //KORG_NOKABC
1698 1700
1699 1701
1700 return true; 1702 return true;
1701} 1703}
1702 1704
1703// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI 1705// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
1704void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, 1706void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
1705 const QStringList& anniversaryList, const QStringList& realNameList, 1707 const QStringList& anniversaryList, const QStringList& realNameList,
1706 const QStringList& emailList, const QStringList& assembledNameList, 1708 const QStringList& emailList, const QStringList& assembledNameList,
1707 const QStringList& uidList) 1709 const QStringList& uidList)
1708{ 1710{
1709 1711
1710 //qDebug("KO::CalendarView::insertBirthdays"); 1712 //qDebug("KO::CalendarView::insertBirthdays");
1711 if (uid == this->name()) 1713 if (uid == this->name())
1712 { 1714 {
1713 int curCal = mCalendar->defaultCalendar(); 1715 int curCal = mCalendar->defaultCalendar();
1714 int bd = mCalEditView->getBirtdayID(); 1716 int bd = mCalEditView->getBirtdayID();
1715 if ( bd == 0 ) 1717 if ( bd == 0 )
1716 return; 1718 return;
1717 mCalendar->setDefaultCalendar( bd ); 1719 mCalendar->setDefaultCalendar( bd );
1718 1720
1719 1721
1720 int count = birthdayList.count(); 1722 int count = birthdayList.count();
1721 int addCount = 0; 1723 int addCount = 0;
1722 KCal::Attendee* a = 0; 1724 KCal::Attendee* a = 0;
1723 1725
1724 //qDebug("CalView 1 %i", count); 1726 //qDebug("CalView 1 %i", count);
1725 1727
1726 QProgressBar bar(count,0 ); 1728 QProgressBar bar(count,0 );
1727 int w = 300; 1729 int w = 300;
1728 if ( QApplication::desktop()->width() < 320 ) 1730 if ( QApplication::desktop()->width() < 320 )
1729 w = 220; 1731 w = 220;
1730 int h = bar.sizeHint().height() ; 1732 int h = bar.sizeHint().height() ;
1731 int dw = QApplication::desktop()->width(); 1733 int dw = QApplication::desktop()->width();
1732 int dh = QApplication::desktop()->height(); 1734 int dh = QApplication::desktop()->height();
1733 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1735 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1734 bar.show(); 1736 bar.show();
1735 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 1737 bar.setCaption (i18n("inserting birthdays - close to abort!") );
1736 qApp->processEvents(); 1738 qApp->processEvents();
1737 1739
1738 QDate birthday; 1740 QDate birthday;
1739 QDate anniversary; 1741 QDate anniversary;
1740 QString realName; 1742 QString realName;
1741 QString email; 1743 QString email;
1742 QString assembledName; 1744 QString assembledName;
1743 QString uid; 1745 QString uid;
1744 bool ok = true; 1746 bool ok = true;
1745 for ( int i = 0; i < count; i++) 1747 for ( int i = 0; i < count; i++)
1746 { 1748 {
1747 if ( ! bar.isVisible() ) 1749 if ( ! bar.isVisible() )
1748 return; 1750 return;
1749 bar.setProgress( i ); 1751 bar.setProgress( i );
1750 qApp->processEvents(); 1752 qApp->processEvents();
1751 1753
1752 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); 1754 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
1753 if (!ok) { 1755 if (!ok) {
1754 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); 1756 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
1755 } 1757 }
1756 1758
1757 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); 1759 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
1758 if (!ok) { 1760 if (!ok) {
1759 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); 1761 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
1760 } 1762 }
1761 realName = realNameList[i]; 1763 realName = realNameList[i];
1762 email = emailList[i]; 1764 email = emailList[i];
1763 assembledName = assembledNameList[i]; 1765 assembledName = assembledNameList[i];
1764 uid = uidList[i]; 1766 uid = uidList[i];
1765 //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() ); 1767 //qDebug("insert birthday in KO/Pi: %s,%s,%s,%s: %s, %s", realName.latin1(), email.latin1(), assembledName.latin1(), uid.latin1(), birthdayList[i].latin1(), anniversaryList[i].latin1() );
1766 1768
1767 if ( birthday.isValid() ){ 1769 if ( birthday.isValid() ){
1768 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1770 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1769 KCal::Attendee::ReqParticipant,uid) ; 1771 KCal::Attendee::ReqParticipant,uid) ;
1770 if ( addAnniversary( birthday, assembledName, a, true ) ) 1772 if ( addAnniversary( birthday, assembledName, a, true ) )
1771 ++addCount; 1773 ++addCount;
1772 } 1774 }
1773 1775
1774 if ( anniversary.isValid() ){ 1776 if ( anniversary.isValid() ){
1775 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1777 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1776 KCal::Attendee::ReqParticipant,uid) ; 1778 KCal::Attendee::ReqParticipant,uid) ;
1777 if ( addAnniversary( anniversary, assembledName, a, false ) ) 1779 if ( addAnniversary( anniversary, assembledName, a, false ) )
1778 ++addCount; 1780 ++addCount;
1779 } 1781 }
1780 } 1782 }
1781 1783
1782 mCalendar->setDefaultCalendar( curCal ); 1784 mCalendar->setDefaultCalendar( curCal );
1783 updateView(); 1785 updateView();
1784 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1786 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1785 1787
1786 } 1788 }
1787 1789
1788} 1790}
1789 1791
1790 1792
1791 1793
1792bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1794bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1793{ 1795{
1794 //qDebug("addAnni "); 1796 //qDebug("addAnni ");
1795 Event * ev = new Event(); 1797 Event * ev = new Event();
1796 ev->setOrganizer(KOPrefs::instance()->email()); 1798 ev->setOrganizer(KOPrefs::instance()->email());
1797 if ( a ) { 1799 if ( a ) {
1798 ev->addAttendee( a ); 1800 ev->addAttendee( a );
1799 } 1801 }
1800 QString kind; 1802 QString kind;
1801 if ( birthday ) { 1803 if ( birthday ) {
1802 kind = i18n( "Birthday" ); 1804 kind = i18n( "Birthday" );
1803 ev->setSummary( name + " (" + QString::number(date.year()) +")"); 1805 ev->setSummary( name + " (" + QString::number(date.year()) +")");
1804 } 1806 }
1805 else { 1807 else {
1806 kind = i18n( "Anniversary" ); 1808 kind = i18n( "Anniversary" );
1807 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); 1809 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind );
1808 } 1810 }
1809 ev->setCategories( kind ); 1811 ev->setCategories( kind );
1810 ev->setDtStart( QDateTime(date) ); 1812 ev->setDtStart( QDateTime(date) );
1811 ev->setDtEnd( QDateTime(date) ); 1813 ev->setDtEnd( QDateTime(date) );
1812 ev->setFloats( true ); 1814 ev->setFloats( true );
1813 Recurrence * rec = ev->recurrence(); 1815 Recurrence * rec = ev->recurrence();
1814 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1816 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1815 rec->addYearlyNum( date.month() ); 1817 rec->addYearlyNum( date.month() );
1816 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1818 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1817 delete ev; 1819 delete ev;
1818 return false; 1820 return false;
1819 } 1821 }
1820 return true; 1822 return true;
1821 1823
1822} 1824}
1823bool CalendarView::importQtopia( const QString &categories, 1825bool CalendarView::importQtopia( const QString &categories,
1824 const QString &datebook, 1826 const QString &datebook,
1825 const QString &todolist ) 1827 const QString &todolist )
1826{ 1828{
1827 1829
1828 QtopiaFormat qtopiaFormat; 1830 QtopiaFormat qtopiaFormat;
1829 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1831 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1830 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1832 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1831 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1833 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1832 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1834 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1833 1835
1834 updateView(); 1836 updateView();
1835 return true; 1837 return true;
1836 1838
1837#if 0 1839#if 0
1838 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1840 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1839 mCurrentSyncDevice = "qtopia-XML"; 1841 mCurrentSyncDevice = "qtopia-XML";
1840 if ( mSyncManager->mAskForPreferences ) 1842 if ( mSyncManager->mAskForPreferences )
1841 edit_sync_options(); 1843 edit_sync_options();
1842 qApp->processEvents(); 1844 qApp->processEvents();
1843 CalendarLocal* calendar = new CalendarLocal(); 1845 CalendarLocal* calendar = new CalendarLocal();
1844 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1846 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1845 bool syncOK = false; 1847 bool syncOK = false;
1846 QtopiaFormat qtopiaFormat; 1848 QtopiaFormat qtopiaFormat;
1847 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1849 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1848 bool loadOk = true; 1850 bool loadOk = true;
1849 if ( !categories.isEmpty() ) 1851 if ( !categories.isEmpty() )
1850 loadOk = qtopiaFormat.load( calendar, categories ); 1852 loadOk = qtopiaFormat.load( calendar, categories );
1851 if ( loadOk && !datebook.isEmpty() ) 1853 if ( loadOk && !datebook.isEmpty() )
1852 loadOk = qtopiaFormat.load( calendar, datebook ); 1854 loadOk = qtopiaFormat.load( calendar, datebook );
1853 if ( loadOk && !todolist.isEmpty() ) 1855 if ( loadOk && !todolist.isEmpty() )
1854 loadOk = qtopiaFormat.load( calendar, todolist ); 1856 loadOk = qtopiaFormat.load( calendar, todolist );
1855 1857
1856 if ( loadOk ) { 1858 if ( loadOk ) {
1857 getEventViewerDialog()->setSyncMode( true ); 1859 getEventViewerDialog()->setSyncMode( true );
1858 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1860 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1859 getEventViewerDialog()->setSyncMode( false ); 1861 getEventViewerDialog()->setSyncMode( false );
1860 qApp->processEvents(); 1862 qApp->processEvents();
1861 if ( syncOK ) { 1863 if ( syncOK ) {
1862 if ( mSyncManager->mWriteBackFile ) 1864 if ( mSyncManager->mWriteBackFile )
1863 { 1865 {
1864 // write back XML file 1866 // write back XML file
1865 1867
1866 } 1868 }
1867 setModified( true ); 1869 setModified( true );
1868 } 1870 }
1869 } else { 1871 } else {
1870 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1872 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1871 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1873 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1872 question, i18n("Ok")) ; 1874 question, i18n("Ok")) ;
1873 } 1875 }
1874 delete calendar; 1876 delete calendar;
1875 updateView(); 1877 updateView();
1876 return syncOK; 1878 return syncOK;
1877 1879
1878 1880
1879#endif 1881#endif
1880 1882
1881} 1883}
1882 1884
1883void CalendarView::setSyncEventsReadOnly() 1885void CalendarView::setSyncEventsReadOnly()
1884{ 1886{
1885 mCalendar->setSyncEventsReadOnly(); 1887 mCalendar->setSyncEventsReadOnly();
1886} 1888}
1887 1889
1888bool CalendarView::loadCalendars() 1890bool CalendarView::loadCalendars()
1889{ 1891{
1890 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 1892 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
1891 KopiCalendarFile * cal = calendars.first(); 1893 KopiCalendarFile * cal = calendars.first();
1892 mCalendar->setDefaultCalendar( 1 ); 1894 mCalendar->setDefaultCalendar( 1 );
1893 openCalendar( MainWindow::defaultFileName(), false ); 1895 openCalendar( MainWindow::defaultFileName(), false );
1894 cal = calendars.next(); 1896 cal = calendars.next();
1895 while ( cal ) { 1897 while ( cal ) {
1896 addCalendar( cal ); 1898 addCalendar( cal );
1897 cal = calendars.next(); 1899 cal = calendars.next();
1898 } 1900 }
1899 restoreCalendarSettings(); 1901 restoreCalendarSettings();
1900 return true; 1902 return true;
1901} 1903}
1902bool CalendarView::restoreCalendarSettings() 1904bool CalendarView::restoreCalendarSettings()
1903{ 1905{
1904 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; 1906 QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars;
1905 KopiCalendarFile * cal = calendars.first(); 1907 KopiCalendarFile * cal = calendars.first();
1906 while ( cal ) { 1908 while ( cal ) {
1907 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); 1909 mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled );
1908 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); 1910 mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled );
1909 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); 1911 mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly );
1910 if ( cal->isStandard ) 1912 if ( cal->isStandard )
1911 mCalendar->setDefaultCalendar( cal->mCalNumber ); 1913 mCalendar->setDefaultCalendar( cal->mCalNumber );
1912 cal = calendars.next(); 1914 cal = calendars.next();
1913 } 1915 }
1914 setSyncEventsReadOnly(); 1916 setSyncEventsReadOnly();
1915 mCalendar->reInitAlarmSettings(); 1917 mCalendar->reInitAlarmSettings();
1916 updateUnmanagedViews(); 1918 updateUnmanagedViews();
1917 updateView(); 1919 updateView();
1918 return true; 1920 return true;
1919} 1921}
1920void CalendarView::addCalendarId( int id ) 1922void CalendarView::addCalendarId( int id )
1921{ 1923{
1922 KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id ); 1924 KopiCalendarFile * cal = KOPrefs::instance()->getCalendar( id );
1923 addCalendar( cal ); 1925 addCalendar( cal );
1924} 1926}
1925bool CalendarView::addCalendar( KopiCalendarFile * cal ) 1927bool CalendarView::addCalendar( KopiCalendarFile * cal )
1926{ 1928{
1927 cal->mErrorOnLoad = false; 1929 cal->mErrorOnLoad = false;
1928 if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) { 1930 if ( mCalendar->addCalendarFile( cal->mFileName, cal->mCalNumber )) {
1929 cal->mLoadDt = QDateTime::currentDateTime(); 1931 cal->mLoadDt = QDateTime::currentDateTime();
1930 return true; 1932 return true;
1931 } 1933 }
1932 qDebug("KO: Error adding calendar file %1 ",cal->mFileName.latin1() ); 1934 qDebug("KO: Error adding calendar file %1 ",cal->mFileName.latin1() );
1933 KMessageBox::error(this,i18n("Error loading calendar file\n%1.").arg(cal->mFileName)); 1935 KMessageBox::error(this,i18n("Error loading calendar file\n%1.").arg(cal->mFileName));
1934 cal->mErrorOnLoad = true; 1936 cal->mErrorOnLoad = true;
1935 return false; 1937 return false;
1936} 1938}
1937bool CalendarView::openCalendar(QString filename, bool merge) 1939bool CalendarView::openCalendar(QString filename, bool merge)
1938{ 1940{
1939 1941
1940 if (filename.isEmpty()) { 1942 if (filename.isEmpty()) {
1941 return false; 1943 return false;
1942 } 1944 }
1943 1945
1944 if (!QFile::exists(filename)) { 1946 if (!QFile::exists(filename)) {
1945 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1947 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1946 return false; 1948 return false;
1947 } 1949 }
1948 1950
1949 globalFlagBlockAgenda = 1; 1951 globalFlagBlockAgenda = 1;
1950 clearAllViews(); 1952 clearAllViews();
1951 if (!merge) { 1953 if (!merge) {
1952 mViewManager->setDocumentId( filename ); 1954 mViewManager->setDocumentId( filename );
1953 mCalendar->close(); 1955 mCalendar->close();
1954 } 1956 }
1955 mStorage->setFileName( filename ); 1957 mStorage->setFileName( filename );
1956 1958
1957 if ( mStorage->load() ) { 1959 if ( mStorage->load() ) {
1958 if ( merge ) ;//setModified( true ); 1960 if ( merge ) ;//setModified( true );
1959 else { 1961 else {
1960 //setModified( true ); 1962 //setModified( true );
1961 mViewManager->setDocumentId( filename ); 1963 mViewManager->setDocumentId( filename );
1962 mDialogManager->setDocumentId( filename ); 1964 mDialogManager->setDocumentId( filename );
1963 mTodoList->setDocumentId( filename ); 1965 mTodoList->setDocumentId( filename );
1964 } 1966 }
1965 globalFlagBlockAgenda = 2; 1967 globalFlagBlockAgenda = 2;
1966 // if ( getLastSyncEvent() ) 1968 // if ( getLastSyncEvent() )
1967 // getLastSyncEvent()->setReadOnly( true ); 1969 // getLastSyncEvent()->setReadOnly( true );
1968 mCalendar->reInitAlarmSettings(); 1970 mCalendar->reInitAlarmSettings();
1969 setSyncEventsReadOnly(); 1971 setSyncEventsReadOnly();
1970 updateUnmanagedViews(); 1972 updateUnmanagedViews();
1971 updateView(); 1973 updateView();
1972 if ( filename != MainWindow::defaultFileName() ) { 1974 if ( filename != MainWindow::defaultFileName() ) {
1973 saveCalendar( MainWindow::defaultFileName() ); 1975 saveCalendar( MainWindow::defaultFileName() );
1974 } else { 1976 } else {
1975 QFileInfo finf ( MainWindow::defaultFileName()); 1977 QFileInfo finf ( MainWindow::defaultFileName());
1976 if ( finf.exists() ) { 1978 if ( finf.exists() ) {
1977 setLoadedFileVersion( finf.lastModified () ); 1979 setLoadedFileVersion( finf.lastModified () );
1978 } 1980 }
1979 } 1981 }
1980 return true; 1982 return true;
1981 } else { 1983 } else {
1982 // while failing to load, the calendar object could 1984 // while failing to load, the calendar object could
1983 // have become partially populated. Clear it out. 1985 // have become partially populated. Clear it out.
1984 if ( !merge ) { 1986 if ( !merge ) {
1985 mCalendar->close(); 1987 mCalendar->close();
1986 mViewManager->setDocumentId( filename ); 1988 mViewManager->setDocumentId( filename );
1987 mDialogManager->setDocumentId( filename ); 1989 mDialogManager->setDocumentId( filename );