summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-06-11 18:34:05 (UTC)
committer zautrix <zautrix>2005-06-11 18:34:05 (UTC)
commitb56d3be87557510285d3381250faf9b7af300680 (patch) (unidiff)
tree887e24db261f56f78dda8397196a6125cc346fc5
parent81370a5f955c2710b6e9336b6c412c8d630ef72a (diff)
downloadkdepimpi-b56d3be87557510285d3381250faf9b7af300680.zip
kdepimpi-b56d3be87557510285d3381250faf9b7af300680.tar.gz
kdepimpi-b56d3be87557510285d3381250faf9b7af300680.tar.bz2
fixxx
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp39
-rw-r--r--microkde/kfiledialog.cpp2
2 files changed, 31 insertions, 10 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 8f5de4d..753d81f 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1,2938 +1,2959 @@
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 beamDialog = new KOBeamPrefs(); 371 beamDialog = new KOBeamPrefs();
372 mDatePickerMode = 0; 372 mDatePickerMode = 0;
373 mCurrentSyncDevice = ""; 373 mCurrentSyncDevice = "";
374 writeLocale(); 374 writeLocale();
375 mViewManager = new KOViewManager( this ); 375 mViewManager = new KOViewManager( this );
376 mDialogManager = new KODialogManager( this ); 376 mDialogManager = new KODialogManager( this );
377 mEventViewerDialog = 0; 377 mEventViewerDialog = 0;
378 mModified = false; 378 mModified = false;
379 mReadOnly = false; 379 mReadOnly = false;
380 mSelectedIncidence = 0; 380 mSelectedIncidence = 0;
381 mCalPrinter = 0; 381 mCalPrinter = 0;
382 mFilters.setAutoDelete(true); 382 mFilters.setAutoDelete(true);
383 383
384 mCalendar->registerObserver( this ); 384 mCalendar->registerObserver( this );
385 // TODO: Make sure that view is updated, when calendar is changed. 385 // TODO: Make sure that view is updated, when calendar is changed.
386 386
387 mStorage = new FileStorage( mCalendar ); 387 mStorage = new FileStorage( mCalendar );
388 mNavigator = new DateNavigator( this, "datevav", mViewManager ); 388 mNavigator = new DateNavigator( this, "datevav", mViewManager );
389 389
390 QBoxLayout *topLayout = (QBoxLayout*)layout(); 390 QBoxLayout *topLayout = (QBoxLayout*)layout();
391#ifndef KORG_NOSPLITTER 391#ifndef KORG_NOSPLITTER
392 // create the main layout frames. 392 // create the main layout frames.
393 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner"); 393 mPanner = new QSplitter(QSplitter::Horizontal,this,"CalendarView::Panner");
394 topLayout->addWidget(mPanner); 394 topLayout->addWidget(mPanner);
395 395
396 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner, 396 mLeftSplitter = new QSplitter(QSplitter::Vertical,mPanner,
397 "CalendarView::LeftFrame"); 397 "CalendarView::LeftFrame");
398 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize); 398 mPanner->setResizeMode(mLeftSplitter,QSplitter::KeepSize);
399 399
400 mDateNavigator = new DateNavigatorContainer( mLeftSplitter, 400 mDateNavigator = new DateNavigatorContainer( mLeftSplitter,
401 "CalendarView::DateNavigator" ); 401 "CalendarView::DateNavigator" );
402 402
403 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize); 403 mLeftSplitter->setResizeMode(mDateNavigator,QSplitter::KeepSize);
404 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2"); 404 mTodoList = new KOTodoView(mCalendar, mLeftSplitter, "todolist_small2");
405 mTodoList->setNavigator( mNavigator ); 405 mTodoList->setNavigator( mNavigator );
406 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView"); 406 mFilterView = new KOFilterView(&mFilters,mLeftSplitter,"CalendarView::FilterView");
407 407
408#ifdef KORG_NORESOURCEVIEW 408#ifdef KORG_NORESOURCEVIEW
409 mResourceView = 0; 409 mResourceView = 0;
410#else 410#else
411 if ( mResourceManager ) { 411 if ( mResourceManager ) {
412 mResourceView = new ResourceView( mResourceManager, mLeftSplitter ); 412 mResourceView = new ResourceView( mResourceManager, mLeftSplitter );
413 mResourceView->updateView(); 413 mResourceView->updateView();
414 connect( mResourceView, SIGNAL( resourcesChanged() ), 414 connect( mResourceView, SIGNAL( resourcesChanged() ),
415 SLOT( updateView() ) ); 415 SLOT( updateView() ) );
416 } else { 416 } else {
417 mResourceView = 0; 417 mResourceView = 0;
418 } 418 }
419#endif 419#endif
420 QWidget *rightBox = new QWidget( mPanner ); 420 QWidget *rightBox = new QWidget( mPanner );
421 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 421 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
422 422
423 mRightFrame = new QWidgetStack( rightBox ); 423 mRightFrame = new QWidgetStack( rightBox );
424 rightLayout->addWidget( mRightFrame, 1 ); 424 rightLayout->addWidget( mRightFrame, 1 );
425 425
426 mLeftFrame = mLeftSplitter; 426 mLeftFrame = mLeftSplitter;
427#else 427#else
428 //QWidget *mainBox = new QWidget( this ); 428 //QWidget *mainBox = new QWidget( this );
429 //QWidget *leftFrame = new QWidget( mainBox ); 429 //QWidget *leftFrame = new QWidget( mainBox );
430 //QBoxLayout * mainBoxLayout; 430 //QBoxLayout * mainBoxLayout;
431 if ( KOPrefs::instance()->mVerticalScreen ) { 431 if ( KOPrefs::instance()->mVerticalScreen ) {
432 //mainBoxLayout = new QVBoxLayout(mainBox); 432 //mainBoxLayout = new QVBoxLayout(mainBox);
433 //leftFrameLayout = new QHBoxLayout(leftFrame ); 433 //leftFrameLayout = new QHBoxLayout(leftFrame );
434 mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this ); 434 mMainFrame = new KDGanttMinimizeSplitter( Qt::Vertical, this );
435 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 435 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
436 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);; 436 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, mMainFrame);;
437 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); 437 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Right );
438 } else { 438 } else {
439 //mainBoxLayout = new QHBoxLayout(mainBox); 439 //mainBoxLayout = new QHBoxLayout(mainBox);
440 //leftFrameLayout = new QVBoxLayout(leftFrame ); 440 //leftFrameLayout = new QVBoxLayout(leftFrame );
441 mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this); 441 mMainFrame = new KDGanttMinimizeSplitter( Qt::Horizontal, this);
442 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left); 442 mMainFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Left);
443 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame); 443 mLeftFrame = new KDGanttMinimizeSplitter( Qt::Vertical, mMainFrame);
444 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 444 mLeftFrame->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
445 } 445 }
446 mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) ); 446 mMainFrame->setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) );
447 //QBoxLayout * leftFrameLayout; 447 //QBoxLayout * leftFrameLayout;
448 topLayout->addWidget( mMainFrame ); 448 topLayout->addWidget( mMainFrame );
449 //mainBoxLayout->addWidget (mLeftFrame); 449 //mainBoxLayout->addWidget (mLeftFrame);
450 mDateNavigator = new DateNavigatorContainer( mLeftFrame, 450 mDateNavigator = new DateNavigatorContainer( mLeftFrame,
451 "CalendarView::DateNavigator" ); 451 "CalendarView::DateNavigator" );
452#if 0 452#if 0
453 // FIXME 453 // FIXME
454 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE, 454 mDateNavigator = new KDateNavigator(mLeftFrame, mCalendar, TRUE,
455 "CalendarView::DateNavigator", QDate::currentDate()); 455 "CalendarView::DateNavigator", QDate::currentDate());
456#endif 456#endif
457 // mDateNavigator->blockSignals( true ); 457 // mDateNavigator->blockSignals( true );
458 //leftFrameLayout->addWidget( mDateNavigator ); 458 //leftFrameLayout->addWidget( mDateNavigator );
459 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall"); 459 mTodoList = new KOTodoView(mCalendar, mLeftFrame, "todolistsmall");
460 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView"); 460 mFilterView = new KOFilterView(&mFilters,mLeftFrame,"CalendarView::FilterView");
461 mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView"); 461 mCalEditView = new KOCalEditView(mLeftFrame,"CalendarView::CaleditView");
462 mTodoList->setNavigator( mNavigator ); 462 mTodoList->setNavigator( mNavigator );
463#if 0 463#if 0
464 if ( QApplication::desktop()->width() < 480 ) { 464 if ( QApplication::desktop()->width() < 480 ) {
465 leftFrameLayout->addWidget(mFilterView); 465 leftFrameLayout->addWidget(mFilterView);
466 leftFrameLayout->addWidget(mTodoList, 2 ); 466 leftFrameLayout->addWidget(mTodoList, 2 );
467 467
468 } else { 468 } else {
469 leftFrameLayout->addWidget(mTodoList,2 ); 469 leftFrameLayout->addWidget(mTodoList,2 );
470 leftFrameLayout->addWidget(mFilterView ); 470 leftFrameLayout->addWidget(mFilterView );
471 } 471 }
472#endif 472#endif
473 mFilterView->hide(); 473 mFilterView->hide();
474 mCalEditView->hide(); 474 mCalEditView->hide();
475 QWidget *rightBox = new QWidget( mMainFrame ); 475 QWidget *rightBox = new QWidget( mMainFrame );
476 //mainBoxLayout->addWidget ( rightBox, 10 ); 476 //mainBoxLayout->addWidget ( rightBox, 10 );
477 QBoxLayout *rightLayout = new QVBoxLayout( rightBox ); 477 QBoxLayout *rightLayout = new QVBoxLayout( rightBox );
478 mRightFrame = new QWidgetStack( rightBox ); 478 mRightFrame = new QWidgetStack( rightBox );
479 rightLayout->addWidget( mRightFrame, 10 ); 479 rightLayout->addWidget( mRightFrame, 10 );
480 480
481 //mLeftFrame = (QWidget *)leftFrame; 481 //mLeftFrame = (QWidget *)leftFrame;
482 if ( KOPrefs::instance()->mVerticalScreen ) { 482 if ( KOPrefs::instance()->mVerticalScreen ) {
483 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() ); 483 //mDateNavigator->setFixedHeight( mDateNavigator->sizeHint().height() );
484 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() ); 484 //mDateNavigator->setMinimumWidth( mDateNavigator->sizeHint().width() );
485 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() ); 485 //mTodoList->setFixedHeight( mDateNavigator->sizeHint().height() );
486 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() ); 486 //leftFrame->setFixedHeight( mDateNavigator->sizeHint().height() );
487 } else { 487 } else {
488 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() ); 488 //mDateNavigator->setFixedWidth( mDateNavigator->sizeHint().width() );
489 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() ); 489 //mTodoList->setFixedWidth( mDateNavigator->sizeHint().width() );
490 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() ); 490 //leftFrame->setFixedWidth( mDateNavigator->sizeHint().width() );
491 } 491 }
492 if ( !KOPrefs::instance()->mShowDateNavigator) 492 if ( !KOPrefs::instance()->mShowDateNavigator)
493 mDateNavigator->hide(); 493 mDateNavigator->hide();
494 //qDebug("Calendarview Size %d %d ", width(), height()); 494 //qDebug("Calendarview Size %d %d ", width(), height());
495#endif 495#endif
496 496
497 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 497 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
498 SLOT( showDates( const KCal::DateList & ) ) ); 498 SLOT( showDates( const KCal::DateList & ) ) );
499 499
500 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 500 connect( mNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
501 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 501 mDateNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
502 502
503 503
504 504
505 connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ), 505 connect( mDateNavigator, SIGNAL( showMonth( const QDate & ) ),
506 mViewManager, SLOT( showMonth( const QDate & ) ) ); 506 mViewManager, SLOT( showMonth( const QDate & ) ) );
507 507
508 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ), 508 connect( mDateNavigator, SIGNAL( weekClicked( const QDate & ) ),
509 mNavigator, SLOT( selectWeek( const QDate & ) ) ); 509 mNavigator, SLOT( selectWeek( const QDate & ) ) );
510 510
511 connect( mDateNavigator, SIGNAL( goPrevYear() ), 511 connect( mDateNavigator, SIGNAL( goPrevYear() ),
512 mNavigator, SLOT( selectPreviousYear() ) ); 512 mNavigator, SLOT( selectPreviousYear() ) );
513 connect( mDateNavigator, SIGNAL( goNextYear() ), 513 connect( mDateNavigator, SIGNAL( goNextYear() ),
514 mNavigator, SLOT( selectNextYear() ) ); 514 mNavigator, SLOT( selectNextYear() ) );
515 connect( mDateNavigator, SIGNAL( goPrevMonth() ), 515 connect( mDateNavigator, SIGNAL( goPrevMonth() ),
516 mNavigator, SLOT( selectPreviousMonth() ) ); 516 mNavigator, SLOT( selectPreviousMonth() ) );
517 connect( mDateNavigator, SIGNAL( goNextMonth() ), 517 connect( mDateNavigator, SIGNAL( goNextMonth() ),
518 mNavigator, SLOT( selectNextMonth() ) ); 518 mNavigator, SLOT( selectNextMonth() ) );
519 519
520 connect( mDateNavigator, SIGNAL( goPrevious() ), 520 connect( mDateNavigator, SIGNAL( goPrevious() ),
521 mNavigator, SLOT( selectPrevious() ) ); 521 mNavigator, SLOT( selectPrevious() ) );
522 connect( mDateNavigator, SIGNAL( goNext() ), 522 connect( mDateNavigator, SIGNAL( goNext() ),
523 mNavigator, SLOT( selectNext() ) ); 523 mNavigator, SLOT( selectNext() ) );
524 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ), 524 connect( mDateNavigator, SIGNAL( monthSelected ( int ) ),
525 mNavigator, SLOT( slotMonthSelect( int ) ) ); 525 mNavigator, SLOT( slotMonthSelect( int ) ) );
526 526
527 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ), 527 connect( mDateNavigator, SIGNAL( datesSelected( const KCal::DateList & ) ),
528 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) ); 528 mNavigator, SLOT( selectDates( const KCal::DateList & ) ) );
529#if 0 529#if 0
530 connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ), 530 connect( mDateNavigator, SIGNAL( incidenceDropped( Incidence * ) ),
531 SLOT( incidenceAdded( Incidence *) ) ); 531 SLOT( incidenceAdded( Incidence *) ) );
532#endif 532#endif
533 // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView())); 533 // connect(mDateNavigator,SIGNAL(dayPassed(QDate)),SLOT(updateView()));
534 534
535 connect( this, SIGNAL( configChanged() ), 535 connect( this, SIGNAL( configChanged() ),
536 mDateNavigator, SLOT( updateConfig() ) ); 536 mDateNavigator, SLOT( updateConfig() ) );
537 537
538 connect( mTodoList, SIGNAL( newTodoSignal() ), 538 connect( mTodoList, SIGNAL( newTodoSignal() ),
539 SLOT( newTodo() ) ); 539 SLOT( newTodo() ) );
540 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ), 540 connect( mTodoList, SIGNAL( newSubTodoSignal( Todo *) ),
541 SLOT( newSubTodo( Todo * ) ) ); 541 SLOT( newSubTodo( Todo * ) ) );
542 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ), 542 connect( mTodoList, SIGNAL( editTodoSignal( Todo * ) ),
543 SLOT( editTodo( Todo * ) ) ); 543 SLOT( editTodo( Todo * ) ) );
544 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ), 544 connect( mTodoList, SIGNAL( showTodoSignal( Todo * ) ),
545 SLOT( showTodo( Todo *) ) ); 545 SLOT( showTodo( Todo *) ) );
546 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ), 546 connect( mTodoList, SIGNAL( deleteTodoSignal( Todo *) ),
547 SLOT( deleteTodo( Todo *) ) ); 547 SLOT( deleteTodo( Todo *) ) );
548 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) ); 548 connect( this, SIGNAL( configChanged()), mTodoList, SLOT( updateConfig() ) );
549 connect( mTodoList, SIGNAL( purgeCompletedSignal() ), 549 connect( mTodoList, SIGNAL( purgeCompletedSignal() ),
550 SLOT( purgeCompleted() ) ); 550 SLOT( purgeCompleted() ) );
551 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), 551 connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ),
552 SIGNAL( todoModified( Todo *, int ) ) ); 552 SIGNAL( todoModified( Todo *, int ) ) );
553 553
554 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), 554 connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ),
555 this, SLOT ( cloneIncidence( Incidence * ) ) ); 555 this, SLOT ( cloneIncidence( Incidence * ) ) );
556 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), 556 connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ),
557 this, SLOT (cancelIncidence( Incidence * ) ) ); 557 this, SLOT (cancelIncidence( Incidence * ) ) );
558 558
559 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), 559 connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ),
560 this, SLOT ( moveIncidence( Incidence * ) ) ); 560 this, SLOT ( moveIncidence( Incidence * ) ) );
561 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), 561 connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ),
562 this, SLOT ( beamIncidence( Incidence * ) ) ); 562 this, SLOT ( beamIncidence( Incidence * ) ) );
563 563
564 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), 564 connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ),
565 this, SLOT ( todo_unsub( Todo * ) ) ); 565 this, SLOT ( todo_unsub( Todo * ) ) );
566 566
567 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), 567 connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ),
568 this, SLOT ( todo_resub( Todo *,Todo * ) ) ); 568 this, SLOT ( todo_resub( Todo *,Todo * ) ) );
569 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, 569 connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList,
570 SLOT( updateTodo( Todo *, int ) ) ); 570 SLOT( updateTodo( Todo *, int ) ) );
571 connect( this, SIGNAL( todoModified( Todo *, int )), this, 571 connect( this, SIGNAL( todoModified( Todo *, int )), this,
572 SLOT( changeTodoDisplay( Todo *, int ) ) ); 572 SLOT( changeTodoDisplay( Todo *, int ) ) );
573 573
574 574
575 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); 575 connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) );
576 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); 576 connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) );
577 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); 577 connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) );
578 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); 578 connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) );
579 579
580 580
581 581
582 582
583 583
584 connect(QApplication::clipboard(),SIGNAL(dataChanged()), 584 connect(QApplication::clipboard(),SIGNAL(dataChanged()),
585 SLOT(checkClipboard())); 585 SLOT(checkClipboard()));
586 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), 586 connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ),
587 SLOT( processTodoListSelection( Incidence * ) ) ); 587 SLOT( processTodoListSelection( Incidence * ) ) );
588 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); 588 connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool)));
589 589
590 // kdDebug() << "CalendarView::CalendarView() done" << endl; 590 // kdDebug() << "CalendarView::CalendarView() done" << endl;
591 591
592 mDateFrame = new QVBox(0,0,WType_Popup); 592 mDateFrame = new QVBox(0,0,WType_Popup);
593 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); 593 //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised);
594 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); 594 mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised );
595 mDateFrame->setLineWidth(3); 595 mDateFrame->setLineWidth(3);
596 mDateFrame->hide(); 596 mDateFrame->hide();
597 mDateFrame->setCaption( i18n( "Pick a date to display")); 597 mDateFrame->setCaption( i18n( "Pick a date to display"));
598 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); 598 mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() );
599 599
600 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); 600 connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate)));
601 601
602 mEventEditor = mDialogManager->getEventEditor(); 602 mEventEditor = mDialogManager->getEventEditor();
603 mTodoEditor = mDialogManager->getTodoEditor(); 603 mTodoEditor = mDialogManager->getTodoEditor();
604 604
605 mFlagEditDescription = false; 605 mFlagEditDescription = false;
606 606
607 mSuspendTimer = new QTimer( this ); 607 mSuspendTimer = new QTimer( this );
608 mAlarmTimer = new QTimer( this ); 608 mAlarmTimer = new QTimer( this );
609 mRecheckAlarmTimer = new QTimer( this ); 609 mRecheckAlarmTimer = new QTimer( this );
610 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); 610 connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) );
611 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); 611 connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) );
612 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); 612 connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) );
613 mAlarmDialog = new AlarmDialog( this ); 613 mAlarmDialog = new AlarmDialog( this );
614 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); 614 connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) );
615 mAlarmDialog->setServerNotification( false ); 615 mAlarmDialog->setServerNotification( false );
616 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); 616 mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime );
617 617
618 618
619#ifndef DESKTOP_VERSION 619#ifndef DESKTOP_VERSION
620//US listen for arriving address resultsets 620//US listen for arriving address resultsets
621 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), 621 connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)),
622 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); 622 this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)));
623#endif 623#endif
624 mDateNavigator->setCalendar( mCalendar ); 624 mDateNavigator->setCalendar( mCalendar );
625} 625}
626 626
627 627
628CalendarView::~CalendarView() 628CalendarView::~CalendarView()
629{ 629{
630 // kdDebug() << "~CalendarView()" << endl; 630 // kdDebug() << "~CalendarView()" << endl;
631 //qDebug("CalendarView::~CalendarView() "); 631 //qDebug("CalendarView::~CalendarView() ");
632 delete mDialogManager; 632 delete mDialogManager;
633 delete mViewManager; 633 delete mViewManager;
634 delete mStorage; 634 delete mStorage;
635 delete mDateFrame ; 635 delete mDateFrame ;
636 delete beamDialog; 636 delete beamDialog;
637 delete mEventViewerDialog; 637 delete mEventViewerDialog;
638 //kdDebug() << "~CalendarView() done" << endl; 638 //kdDebug() << "~CalendarView() done" << endl;
639} 639}
640void CalendarView::checkAlarms() 640void CalendarView::checkAlarms()
641{ 641{
642 KConfig *config = KOGlobals::config(); 642 KConfig *config = KOGlobals::config();
643 config->setGroup( "AppRun" ); 643 config->setGroup( "AppRun" );
644 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) ); 644 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) );
645 int daysto = dt.daysTo( QDate::currentDate() );
646 int days = config->readNumEntry( "LatestProgramStopDays" , daysto);
647 dt = dt.addDays( days );
645 int secto = dt.secsTo( QDateTime::currentDateTime() ); 648 int secto = dt.secsTo( QDateTime::currentDateTime() );
646 int secs = config->readNumEntry( "LatestProgramStop" , secto) - 30; 649 int secs = config->readNumEntry( "LatestProgramStopSecs" , secto) - 30;
647 qDebug("KO: Reading program stop %d ", secs); 650 //qDebug("KO: Reading program stop %d ", secs);
648 //secs -= ( 3600 * 24*3 ); // debug only 651 //secs -= ( 3600 * 24*3 ); // debug only
649 QDateTime latest = dt.addSecs ( secs ); 652 QDateTime latest = dt.addSecs ( secs );
650 qDebug("KO: Last termination on %s ", latest.toString().latin1()); 653 qDebug("KO: Last termination on %s ", latest.toString().latin1());
651 qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); 654 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() );
652 QPtrList<Incidence> el = mCalendar->rawIncidences(); 655 QPtrList<Incidence> el = mCalendar->rawIncidences();
653 QPtrList<Incidence> al; 656 QPtrList<Incidence> al;
654 Incidence* inL = el.first(); 657 Incidence* inL = el.first();
655 QDateTime cur = QDateTime::currentDateTime().addSecs(-59); 658 QDateTime cur = QDateTime::currentDateTime().addSecs(-59);
656 qDebug("KO: Checking alarm until %s ", cur.toString().latin1()); 659 qDebug("KO: Checking alarm until %s ", cur.toString().latin1());
657 while ( inL ) { 660 while ( inL ) {
658 bool ok = false; 661 bool ok = false;
659 int offset = 0; 662 int offset = 0;
660 QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ; 663 QDateTime next = inL->getNextAlarmDateTime(& ok, &offset, latest ) ;
661 if ( ok ) { 664 if ( ok ) {
662 //qDebug("OK %s",next.toString().latin1()); 665 //qDebug("OK %s",next.toString().latin1());
663 if ( next < cur ) { 666 if ( next < cur ) {
664 al.append( inL ); 667 al.append( inL );
665 //qDebug("found missed alarm: %s ", inL->summary().latin1() ); 668 //qDebug("found missed alarm: %s ", inL->summary().latin1() );
666 } 669 }
667 } 670 }
668 inL = el.next(); 671 inL = el.next();
669 } 672 }
670 if ( al.count() ) { 673 if ( al.count() ) {
671 QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop ); 674 QDialog* dia = new QDialog( this, "huhu", false, WDestructiveClose | WStyle_StaysOnTop );
672 dia->setCaption( i18n("KO/Pi: Missing alarms!") ); 675 dia->setCaption( i18n("KO/Pi: Missing alarms!") );
673 QVBoxLayout* lay = new QVBoxLayout( dia ); 676 QVBoxLayout* lay = new QVBoxLayout( dia );
674 lay->setSpacing( 0 ); 677 lay->setSpacing( 0 );
675 lay->setMargin( 0 ); 678 lay->setMargin( 0 );
676 MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest ); 679 MissedAlarmTextBrowser* matb = new MissedAlarmTextBrowser ( dia, al, latest );
677 connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); 680 connect( matb, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) ));
678 lay->addWidget( matb ); 681 lay->addWidget( matb );
679 if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) { 682 if ( QApplication::desktop()->width() == 480 || QApplication::desktop()->width() == 640 ) {
680 int wid = 210; 683 int wid = 210;
681 int x = QApplication::desktop()->width() - wid - 7; 684 int x = QApplication::desktop()->width() - wid - 7;
682 int y = QApplication::desktop()->height() - wid - 70; 685 int y = QApplication::desktop()->height() - wid - 70;
683 dia->setGeometry ( x,y,wid,wid); 686 dia->setGeometry ( x,y,wid,wid);
684 } else { 687 } else {
685 int si = 220; 688 int si = 220;
686 if ( QApplication::desktop()->width() > 470 ) 689 if ( QApplication::desktop()->width() > 470 )
687 si = 400; 690 si = 400;
688 dia->resize(si,si/2); 691 dia->resize(si,si/2);
689 } 692 }
690 dia->setBackgroundColor( QColor( 255, 255, 255 ) ); 693 dia->setBackgroundColor( QColor( 255, 255, 255 ) );
691 dia->show(); 694 dia->show();
692 695
693 } 696 }
694} 697}
695void CalendarView::showDay( QDate d ) 698void CalendarView::showDay( QDate d )
696{ 699{
697 dateNavigator()->blockSignals( true ); 700 dateNavigator()->blockSignals( true );
698 dateNavigator()->selectDate( d ); 701 dateNavigator()->selectDate( d );
699 dateNavigator()->blockSignals( false ); 702 dateNavigator()->blockSignals( false );
700 mViewManager->showDayView(); 703 mViewManager->showDayView();
701 //dateNavigator()->selectDate( d ); 704 //dateNavigator()->selectDate( d );
702} 705}
703void CalendarView::timerAlarm() 706void CalendarView::timerAlarm()
704{ 707{
705 //qDebug("CalendarView::timerAlarm() "); 708 //qDebug("CalendarView::timerAlarm() ");
706 computeAlarm(mAlarmNotification ); 709 computeAlarm(mAlarmNotification );
707} 710}
708 711
709void CalendarView::suspendAlarm() 712void CalendarView::suspendAlarm()
710{ 713{
711 //qDebug(" CalendarView::suspendAlarm() "); 714 //qDebug(" CalendarView::suspendAlarm() ");
712 computeAlarm(mSuspendAlarmNotification ); 715 computeAlarm(mSuspendAlarmNotification );
713 716
714} 717}
715 718
716void CalendarView::startAlarm( QString mess , QString filename) 719void CalendarView::startAlarm( QString mess , QString filename)
717{ 720{
718 721
719 topLevelWidget()->showNormal(); 722 topLevelWidget()->showNormal();
720 topLevelWidget()->setActiveWindow(); 723 topLevelWidget()->setActiveWindow();
721 topLevelWidget()->raise(); 724 topLevelWidget()->raise();
722 725
723 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount ); 726 mAlarmDialog->eventNotification( mess, KOPrefs::instance()->mAlarmPlayBeeps, filename, true,KOPrefs::instance()->mAlarmBeepInterval ,KOPrefs::instance()->mAlarmSuspendCount );
724 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) ); 727 QTimer::singleShot( 3000, this, SLOT( checkNextTimerAlarm() ) );
725 728
726} 729}
727 730
728void CalendarView::checkNextTimerAlarm() 731void CalendarView::checkNextTimerAlarm()
729{ 732{
730 mCalendar->checkAlarmForIncidence( 0, true ); 733 mCalendar->checkAlarmForIncidence( 0, true );
731} 734}
732 735
733void CalendarView::computeAlarm( QString msg ) 736void CalendarView::computeAlarm( QString msg )
734{ 737{
735 738
736 QString mess = msg; 739 QString mess = msg;
737 QString mAlarmMessage = mess.mid( 9 ); 740 QString mAlarmMessage = mess.mid( 9 );
738 QString filename = MainWindow::resourcePath(); 741 QString filename = MainWindow::resourcePath();
739 filename += "koalarm.wav"; 742 filename += "koalarm.wav";
740 QString tempfilename; 743 QString tempfilename;
741 if ( mess.left( 13 ) == "suspend_alarm") { 744 if ( mess.left( 13 ) == "suspend_alarm") {
742 bool error = false; 745 bool error = false;
743 int len = mess.mid( 13 ).find("+++"); 746 int len = mess.mid( 13 ).find("+++");
744 if ( len < 2 ) 747 if ( len < 2 )
745 error = true; 748 error = true;
746 else { 749 else {
747 tempfilename = mess.mid( 13, len ); 750 tempfilename = mess.mid( 13, len );
748 if ( !QFile::exists( tempfilename ) ) 751 if ( !QFile::exists( tempfilename ) )
749 error = true; 752 error = true;
750 } 753 }
751 if ( ! error ) { 754 if ( ! error ) {
752 filename = tempfilename; 755 filename = tempfilename;
753 } 756 }
754 mAlarmMessage = mess.mid( 13+len+3 ); 757 mAlarmMessage = mess.mid( 13+len+3 );
755 //qDebug("suspend file %s ",tempfilename.latin1() ); 758 //qDebug("suspend file %s ",tempfilename.latin1() );
756 startAlarm( mAlarmMessage, filename); 759 startAlarm( mAlarmMessage, filename);
757 return; 760 return;
758 } 761 }
759 if ( mess.left( 11 ) == "timer_alarm") { 762 if ( mess.left( 11 ) == "timer_alarm") {
760 //mTimerTime = 0; 763 //mTimerTime = 0;
761 startAlarm( mess.mid( 11 ), filename ); 764 startAlarm( mess.mid( 11 ), filename );
762 return; 765 return;
763 } 766 }
764 if ( mess.left( 10 ) == "proc_alarm") { 767 if ( mess.left( 10 ) == "proc_alarm") {
765 bool error = false; 768 bool error = false;
766 int len = mess.mid( 10 ).find("+++"); 769 int len = mess.mid( 10 ).find("+++");
767 if ( len < 2 ) 770 if ( len < 2 )
768 error = true; 771 error = true;
769 else { 772 else {
770 tempfilename = mess.mid( 10, len ); 773 tempfilename = mess.mid( 10, len );
771 if ( !QFile::exists( tempfilename ) ) 774 if ( !QFile::exists( tempfilename ) )
772 error = true; 775 error = true;
773 } 776 }
774 if ( error ) { 777 if ( error ) {
775 mAlarmMessage = "Procedure Alarm\nError - File not found\n"; 778 mAlarmMessage = "Procedure Alarm\nError - File not found\n";
776 mAlarmMessage += mess.mid( 10+len+3+9 ); 779 mAlarmMessage += mess.mid( 10+len+3+9 );
777 } else { 780 } else {
778 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent"); 781 //QCopEnvelope e("QPE/Application/kopi", "-writeFileSilent");
779 //qDebug("-----system command %s ",tempfilename.latin1() ); 782 //qDebug("-----system command %s ",tempfilename.latin1() );
780#ifndef _WIN32_ 783#ifndef _WIN32_
781 if ( vfork () == 0 ) { 784 if ( vfork () == 0 ) {
782 execl ( tempfilename.latin1(), 0 ); 785 execl ( tempfilename.latin1(), 0 );
783 return; 786 return;
784 } 787 }
785#else 788#else
786 QProcess* p = new QProcess(); 789 QProcess* p = new QProcess();
787 p->addArgument( tempfilename.latin1() ); 790 p->addArgument( tempfilename.latin1() );
788 p->start(); 791 p->start();
789 return; 792 return;
790#endif 793#endif
791 794
792 return; 795 return;
793 } 796 }
794 797
795 //qDebug("+++++++system command %s ",tempfilename.latin1() ); 798 //qDebug("+++++++system command %s ",tempfilename.latin1() );
796 } 799 }
797 if ( mess.left( 11 ) == "audio_alarm") { 800 if ( mess.left( 11 ) == "audio_alarm") {
798 bool error = false; 801 bool error = false;
799 int len = mess.mid( 11 ).find("+++"); 802 int len = mess.mid( 11 ).find("+++");
800 if ( len < 2 ) 803 if ( len < 2 )
801 error = true; 804 error = true;
802 else { 805 else {
803 tempfilename = mess.mid( 11, len ); 806 tempfilename = mess.mid( 11, len );
804 if ( !QFile::exists( tempfilename ) ) 807 if ( !QFile::exists( tempfilename ) )
805 error = true; 808 error = true;
806 } 809 }
807 if ( ! error ) { 810 if ( ! error ) {
808 filename = tempfilename; 811 filename = tempfilename;
809 } 812 }
810 mAlarmMessage = mess.mid( 11+len+3+9 ); 813 mAlarmMessage = mess.mid( 11+len+3+9 );
811 //qDebug("audio file command %s ",tempfilename.latin1() ); 814 //qDebug("audio file command %s ",tempfilename.latin1() );
812 } 815 }
813 if ( mess.left( 9 ) == "cal_alarm") { 816 if ( mess.left( 9 ) == "cal_alarm") {
814 mAlarmMessage = mess.mid( 9 ) ; 817 mAlarmMessage = mess.mid( 9 ) ;
815 } 818 }
816 819
817 startAlarm( mAlarmMessage, filename ); 820 startAlarm( mAlarmMessage, filename );
818 821
819 822
820} 823}
821 824
822void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti ) 825void CalendarView::addSuspendAlarm(const QDateTime &qdt, const QString &noti )
823{ 826{
824 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 827 //qDebug("+++++addSUSPENDAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
825 828
826 mSuspendAlarmNotification = noti; 829 mSuspendAlarmNotification = noti;
827 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000; 830 int ms = QDateTime::currentDateTime().secsTo( qdt )*1000;
828 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000); 831 //qDebug("Suspend Alarm timer started with secs: %d ", ms/1000);
829 mSuspendTimer->start( ms , true ); 832 mSuspendTimer->start( ms , true );
830 833
831} 834}
832 835
833void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti ) 836void CalendarView::addAlarm(const QDateTime &qdt, const QString &noti )
834{ 837{
835 mNextAlarmDateTime = qdt; 838 mNextAlarmDateTime = qdt;
836 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 839 //qDebug("+++++addAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
837 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 840 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
838#ifndef DESKTOP_VERSION 841#ifndef DESKTOP_VERSION
839 AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() ); 842 AlarmServer::addAlarm ( qdt,"koalarm", noti.utf8() );
840#endif 843#endif
841 return; 844 return;
842 } 845 }
843 int maxSec; 846 int maxSec;
844 //maxSec = 5; //testing only 847 //maxSec = 5; //testing only
845 maxSec = 86400+3600; // one day+1hour 848 maxSec = 86400+3600; // one day+1hour
846 mAlarmNotification = noti; 849 mAlarmNotification = noti;
847 int sec = QDateTime::currentDateTime().secsTo( qdt ); 850 int sec = QDateTime::currentDateTime().secsTo( qdt );
848 if ( sec > maxSec ) { 851 if ( sec > maxSec ) {
849 mRecheckAlarmTimer->start( maxSec * 1000 ); 852 mRecheckAlarmTimer->start( maxSec * 1000 );
850 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec ); 853 // qDebug("recheck Alarm timer started with secs: %d next alarm in sec:%d", maxSec,sec );
851 return; 854 return;
852 } else { 855 } else {
853 mRecheckAlarmTimer->stop(); 856 mRecheckAlarmTimer->stop();
854 } 857 }
855 //qDebug("Alarm timer started with secs: %d ", sec); 858 //qDebug("Alarm timer started with secs: %d ", sec);
856 mAlarmTimer->start( sec *1000 , true ); 859 mAlarmTimer->start( sec *1000 , true );
857 860
858} 861}
859// called by mRecheckAlarmTimer to get next alarm 862// called by mRecheckAlarmTimer to get next alarm
860// we need this, because a QTimer has only a max range of 25 days 863// we need this, because a QTimer has only a max range of 25 days
861void CalendarView::recheckTimerAlarm() 864void CalendarView::recheckTimerAlarm()
862{ 865{
863 mAlarmTimer->stop(); 866 mAlarmTimer->stop();
864 mRecheckAlarmTimer->stop(); 867 mRecheckAlarmTimer->stop();
865 mCalendar->checkAlarmForIncidence( 0, true ); 868 mCalendar->checkAlarmForIncidence( 0, true );
866} 869}
867void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti ) 870void CalendarView::removeAlarm(const QDateTime &qdt, const QString &noti )
868{ 871{
869 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() ); 872 //qDebug("-----removeAlarm %s %s ", qdt.toString().latin1() , noti.latin1() );
870 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) { 873 if ( ! KOPrefs::instance()->mUseInternalAlarmNotification ) {
871#ifndef DESKTOP_VERSION 874#ifndef DESKTOP_VERSION
872 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() ); 875 AlarmServer::deleteAlarm (qdt ,"koalarm" ,noti.latin1() );
873#endif 876#endif
874 return; 877 return;
875 } 878 }
876 mAlarmTimer->stop(); 879 mAlarmTimer->stop();
877} 880}
878void CalendarView::selectWeekNum ( int num ) 881void CalendarView::selectWeekNum ( int num )
879{ 882{
880 dateNavigator()->blockSignals( true ); 883 dateNavigator()->blockSignals( true );
881 dateNavigator()->selectWeek( num ); 884 dateNavigator()->selectWeek( num );
882 dateNavigator()->blockSignals( false ); 885 dateNavigator()->blockSignals( false );
883 mViewManager->showWeekView(); 886 mViewManager->showWeekView();
884} 887}
885KOViewManager *CalendarView::viewManager() 888KOViewManager *CalendarView::viewManager()
886{ 889{
887 return mViewManager; 890 return mViewManager;
888} 891}
889 892
890KODialogManager *CalendarView::dialogManager() 893KODialogManager *CalendarView::dialogManager()
891{ 894{
892 return mDialogManager; 895 return mDialogManager;
893} 896}
894 897
895QDate CalendarView::startDate() 898QDate CalendarView::startDate()
896{ 899{
897 DateList dates = mNavigator->selectedDates(); 900 DateList dates = mNavigator->selectedDates();
898 901
899 return dates.first(); 902 return dates.first();
900} 903}
901 904
902QDate CalendarView::endDate() 905QDate CalendarView::endDate()
903{ 906{
904 DateList dates = mNavigator->selectedDates(); 907 DateList dates = mNavigator->selectedDates();
905 908
906 return dates.last(); 909 return dates.last();
907} 910}
908 911
909 912
910void CalendarView::createPrinter() 913void CalendarView::createPrinter()
911{ 914{
912#ifndef KORG_NOPRINTER 915#ifndef KORG_NOPRINTER
913 if (!mCalPrinter) { 916 if (!mCalPrinter) {
914 mCalPrinter = new CalPrinter(this, mCalendar); 917 mCalPrinter = new CalPrinter(this, mCalendar);
915 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig())); 918 connect(this, SIGNAL(configChanged()), mCalPrinter, SLOT(updateConfig()));
916 } 919 }
917#endif 920#endif
918} 921}
919 922
920 923
921//KOPrefs::instance()->mWriteBackFile 924//KOPrefs::instance()->mWriteBackFile
922//KOPrefs::instance()->mWriteBackExistingOnly 925//KOPrefs::instance()->mWriteBackExistingOnly
923 926
924// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict")); 927// 0 syncPrefsGroup->addRadio(i18n("Take local entry on conflict"));
925// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict")); 928// 1 syncPrefsGroup->addRadio(i18n("Take remote entry on conflict"));
926// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict")); 929// 2 syncPrefsGroup->addRadio(i18n("Take newest entry on conflict"));
927// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict")); 930// 3 syncPrefsGroup->addRadio(i18n("Ask for every entry on conflict"));
928// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always")); 931// 4 syncPrefsGroup->addRadio(i18n("Force take local entry always"));
929// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always")); 932// 5 syncPrefsGroup->addRadio(i18n("Force take remote entry always"));
930 933
931int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full ) 934int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , bool full )
932{ 935{
933 936
934 // 0 equal 937 // 0 equal
935 // 1 take local 938 // 1 take local
936 // 2 take remote 939 // 2 take remote
937 // 3 cancel 940 // 3 cancel
938 QDateTime lastSync = mLastCalendarSync; 941 QDateTime lastSync = mLastCalendarSync;
939 QDateTime localMod = local->lastModified(); 942 QDateTime localMod = local->lastModified();
940 QDateTime remoteMod = remote->lastModified(); 943 QDateTime remoteMod = remote->lastModified();
941 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 944 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
942 bool remCh, locCh; 945 bool remCh, locCh;
943 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) ); 946 remCh = ( remote->getCsum(mCurrentSyncDevice) != local->getCsum(mCurrentSyncDevice) );
944 //if ( remCh ) 947 //if ( remCh )
945 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() ); 948 //qDebug("loc %s rem %s", local->getCsum(mCurrentSyncDevice).latin1(), remote->getCsum(mCurrentSyncDevice).latin1() );
946 locCh = ( localMod > mLastCalendarSync ); 949 locCh = ( localMod > mLastCalendarSync );
947 if ( !remCh && ! locCh ) { 950 if ( !remCh && ! locCh ) {
948 //qDebug("both not changed "); 951 //qDebug("both not changed ");
949 lastSync = localMod.addDays(1); 952 lastSync = localMod.addDays(1);
950 if ( mode <= SYNC_PREF_ASK ) 953 if ( mode <= SYNC_PREF_ASK )
951 return 0; 954 return 0;
952 } else { 955 } else {
953 if ( locCh ) { 956 if ( locCh ) {
954 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1()); 957 //qDebug("loc changed %d %s %s", local->revision() , localMod.toString().latin1(), mLastCalendarSync.toString().latin1());
955 lastSync = localMod.addDays( -1 ); 958 lastSync = localMod.addDays( -1 );
956 if ( !remCh ) 959 if ( !remCh )
957 remoteMod = ( lastSync.addDays( -1 ) ); 960 remoteMod = ( lastSync.addDays( -1 ) );
958 } else { 961 } else {
959 //qDebug(" not loc changed "); 962 //qDebug(" not loc changed ");
960 lastSync = localMod.addDays( 1 ); 963 lastSync = localMod.addDays( 1 );
961 if ( remCh ) 964 if ( remCh )
962 remoteMod =( lastSync.addDays( 1 ) ); 965 remoteMod =( lastSync.addDays( 1 ) );
963 966
964 } 967 }
965 } 968 }
966 full = true; 969 full = true;
967 if ( mode < SYNC_PREF_ASK ) 970 if ( mode < SYNC_PREF_ASK )
968 mode = SYNC_PREF_ASK; 971 mode = SYNC_PREF_ASK;
969 } else { 972 } else {
970 if ( localMod == remoteMod ) 973 if ( localMod == remoteMod )
971 // if ( local->revision() == remote->revision() ) 974 // if ( local->revision() == remote->revision() )
972 return 0; 975 return 0;
973 976
974 } 977 }
975 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() ); 978 // qDebug(" %d %d conflict on %s %s ", mode, full, local->summary().latin1(), remote->summary().latin1() );
976 979
977 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision()); 980 //qDebug("%s %d %s %d", localMod.toString().latin1() , local->revision(), remoteMod.toString().latin1(), remote->revision());
978 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() ); 981 //qDebug("%d %d %d %d ", localMod.time().second(), localMod.time().msec(), remoteMod.time().second(), remoteMod.time().msec() );
979 //full = true; //debug only 982 //full = true; //debug only
980 if ( full ) { 983 if ( full ) {
981 bool equ = false; 984 bool equ = false;
982 if ( local->typeID() == eventID ) { 985 if ( local->typeID() == eventID ) {
983 equ = (*((Event*) local) == *((Event*) remote)); 986 equ = (*((Event*) local) == *((Event*) remote));
984 } 987 }
985 else if ( local->typeID() == todoID ) 988 else if ( local->typeID() == todoID )
986 equ = (*((Todo*) local) == (*(Todo*) remote)); 989 equ = (*((Todo*) local) == (*(Todo*) remote));
987 else if ( local->typeID() == journalID ) 990 else if ( local->typeID() == journalID )
988 equ = (*((Journal*) local) == *((Journal*) remote)); 991 equ = (*((Journal*) local) == *((Journal*) remote));
989 if ( equ ) { 992 if ( equ ) {
990 //qDebug("equal "); 993 //qDebug("equal ");
991 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 994 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
992 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) ); 995 local->setCsum( mCurrentSyncDevice, remote->getCsum(mCurrentSyncDevice) );
993 } 996 }
994 if ( mode < SYNC_PREF_FORCE_LOCAL ) 997 if ( mode < SYNC_PREF_FORCE_LOCAL )
995 return 0; 998 return 0;
996 999
997 }//else //debug only 1000 }//else //debug only
998 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1()); 1001 //qDebug("not equal %s %s ", local->summary().latin1(), remote->summary().latin1());
999 } 1002 }
1000 int result; 1003 int result;
1001 bool localIsNew; 1004 bool localIsNew;
1002 //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() ); 1005 //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() );
1003 1006
1004 1007
1005 // ************************************************ 1008 // ************************************************
1006 // ************************************************ 1009 // ************************************************
1007 // ************************************************ 1010 // ************************************************
1008 // We may have that lastSync > remoteMod AND lastSync > localMod 1011 // We may have that lastSync > remoteMod AND lastSync > localMod
1009 // BUT remoteMod != localMod 1012 // BUT remoteMod != localMod
1010 1013
1011 1014
1012 if ( full && mode < SYNC_PREF_NEWEST ) 1015 if ( full && mode < SYNC_PREF_NEWEST )
1013 mode = SYNC_PREF_ASK; 1016 mode = SYNC_PREF_ASK;
1014 1017
1015 switch( mode ) { 1018 switch( mode ) {
1016 case SYNC_PREF_LOCAL: 1019 case SYNC_PREF_LOCAL:
1017 if ( lastSync > remoteMod ) 1020 if ( lastSync > remoteMod )
1018 return 1; 1021 return 1;
1019 if ( lastSync > localMod ) 1022 if ( lastSync > localMod )
1020 return 2; 1023 return 2;
1021 return 1; 1024 return 1;
1022 break; 1025 break;
1023 case SYNC_PREF_REMOTE: 1026 case SYNC_PREF_REMOTE:
1024 if ( lastSync > localMod ) 1027 if ( lastSync > localMod )
1025 return 2; 1028 return 2;
1026 if ( lastSync > remoteMod ) 1029 if ( lastSync > remoteMod )
1027 return 1; 1030 return 1;
1028 return 2; 1031 return 2;
1029 break; 1032 break;
1030 case SYNC_PREF_NEWEST: 1033 case SYNC_PREF_NEWEST:
1031 if ( localMod >= remoteMod ) 1034 if ( localMod >= remoteMod )
1032 return 1; 1035 return 1;
1033 else 1036 else
1034 return 2; 1037 return 2;
1035 break; 1038 break;
1036 case SYNC_PREF_ASK: 1039 case SYNC_PREF_ASK:
1037 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 1040 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
1038 if ( lastSync > remoteMod && lastSync > localMod) 1041 if ( lastSync > remoteMod && lastSync > localMod)
1039 return 0; 1042 return 0;
1040 if ( lastSync > remoteMod ) 1043 if ( lastSync > remoteMod )
1041 return 1; 1044 return 1;
1042 if ( lastSync > localMod ) 1045 if ( lastSync > localMod )
1043 return 2; 1046 return 2;
1044 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() ); 1047 //qDebug("lsy %s --- lo %s --- re %s ", lastSync.toString().latin1(), localMod.toString().latin1(), remoteMod.toString().latin1() );
1045 localIsNew = localMod >= remoteMod; 1048 localIsNew = localMod >= remoteMod;
1046 if ( localIsNew ) 1049 if ( localIsNew )
1047 getEventViewerDialog()->setColorMode( 1 ); 1050 getEventViewerDialog()->setColorMode( 1 );
1048 else 1051 else
1049 getEventViewerDialog()->setColorMode( 2 ); 1052 getEventViewerDialog()->setColorMode( 2 );
1050 getEventViewerDialog()->setIncidence(local); 1053 getEventViewerDialog()->setIncidence(local);
1051 if ( localIsNew ) 1054 if ( localIsNew )
1052 getEventViewerDialog()->setColorMode( 2 ); 1055 getEventViewerDialog()->setColorMode( 2 );
1053 else 1056 else
1054 getEventViewerDialog()->setColorMode( 1 ); 1057 getEventViewerDialog()->setColorMode( 1 );
1055 getEventViewerDialog()->addIncidence(remote); 1058 getEventViewerDialog()->addIncidence(remote);
1056 getEventViewerDialog()->setColorMode( 0 ); 1059 getEventViewerDialog()->setColorMode( 0 );
1057 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() ); 1060 //qDebug("local %d remote %d ",local->relatedTo(),remote->relatedTo() );
1058 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!")); 1061 getEventViewerDialog()->setCaption( mCurrentSyncDevice +i18n(" : Conflict! Please choose entry!"));
1059 getEventViewerDialog()->showMe(); 1062 getEventViewerDialog()->showMe();
1060 result = getEventViewerDialog()->executeS( localIsNew ); 1063 result = getEventViewerDialog()->executeS( localIsNew );
1061 return result; 1064 return result;
1062 1065
1063 break; 1066 break;
1064 case SYNC_PREF_FORCE_LOCAL: 1067 case SYNC_PREF_FORCE_LOCAL:
1065 return 1; 1068 return 1;
1066 break; 1069 break;
1067 case SYNC_PREF_FORCE_REMOTE: 1070 case SYNC_PREF_FORCE_REMOTE:
1068 return 2; 1071 return 2;
1069 break; 1072 break;
1070 1073
1071 default: 1074 default:
1072 // SYNC_PREF_TAKE_BOTH not implemented 1075 // SYNC_PREF_TAKE_BOTH not implemented
1073 break; 1076 break;
1074 } 1077 }
1075 return 0; 1078 return 0;
1076} 1079}
1077Event* CalendarView::getLastSyncEvent() 1080Event* CalendarView::getLastSyncEvent()
1078{ 1081{
1079 Event* lse; 1082 Event* lse;
1080 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); 1083 //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() );
1081 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); 1084 lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice );
1082 if (!lse) { 1085 if (!lse) {
1083 lse = new Event(); 1086 lse = new Event();
1084 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); 1087 lse->setUid( "last-syncEvent-"+mCurrentSyncDevice );
1085 QString sum = ""; 1088 QString sum = "";
1086 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) 1089 if ( mSyncManager->mExternSyncProfiles.contains( mCurrentSyncDevice ) )
1087 sum = "E: "; 1090 sum = "E: ";
1088 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); 1091 lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event"));
1089 lse->setDtStart( mLastCalendarSync ); 1092 lse->setDtStart( mLastCalendarSync );
1090 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 1093 lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
1091 lse->setCategories( i18n("SyncEvent") ); 1094 lse->setCategories( i18n("SyncEvent") );
1092 lse->setReadOnly( true ); 1095 lse->setReadOnly( true );
1093 mCalendar->addEvent( lse ); 1096 mCalendar->addEvent( lse );
1094 } 1097 }
1095 1098
1096 return lse; 1099 return lse;
1097 1100
1098} 1101}
1099 1102
1100// we check, if the to delete event has a id for a profile 1103// we check, if the to delete event has a id for a profile
1101// if yes, we set this id in the profile to delete 1104// if yes, we set this id in the profile to delete
1102void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) 1105void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete )
1103{ 1106{
1104 if ( lastSync.count() == 0 ) { 1107 if ( lastSync.count() == 0 ) {
1105 //qDebug(" lastSync.count() == 0"); 1108 //qDebug(" lastSync.count() == 0");
1106 return; 1109 return;
1107 } 1110 }
1108 if ( toDelete->typeID() == journalID ) 1111 if ( toDelete->typeID() == journalID )
1109 return; 1112 return;
1110 1113
1111 Event* eve = lastSync.first(); 1114 Event* eve = lastSync.first();
1112 1115
1113 while ( eve ) { 1116 while ( eve ) {
1114 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name 1117 QString id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name
1115 if ( !id.isEmpty() ) { 1118 if ( !id.isEmpty() ) {
1116 QString des = eve->description(); 1119 QString des = eve->description();
1117 QString pref = "e"; 1120 QString pref = "e";
1118 if ( toDelete->typeID() == todoID ) 1121 if ( toDelete->typeID() == todoID )
1119 pref = "t"; 1122 pref = "t";
1120 des += pref+ id + ","; 1123 des += pref+ id + ",";
1121 eve->setReadOnly( false ); 1124 eve->setReadOnly( false );
1122 eve->setDescription( des ); 1125 eve->setDescription( des );
1123 //qDebug("setdes %s ", des.latin1()); 1126 //qDebug("setdes %s ", des.latin1());
1124 eve->setReadOnly( true ); 1127 eve->setReadOnly( true );
1125 } 1128 }
1126 eve = lastSync.next(); 1129 eve = lastSync.next();
1127 } 1130 }
1128 1131
1129} 1132}
1130void CalendarView::checkExternalId( Incidence * inc ) 1133void CalendarView::checkExternalId( Incidence * inc )
1131{ 1134{
1132 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ; 1135 QPtrList<Event> lastSync = mCalendar->getExternLastSyncEvents() ;
1133 checkExternSyncEvent( lastSync, inc ); 1136 checkExternSyncEvent( lastSync, inc );
1134 1137
1135} 1138}
1136bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) 1139bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
1137{ 1140{
1138 bool syncOK = true; 1141 bool syncOK = true;
1139 int addedEvent = 0; 1142 int addedEvent = 0;
1140 int addedEventR = 0; 1143 int addedEventR = 0;
1141 int deletedEventR = 0; 1144 int deletedEventR = 0;
1142 int deletedEventL = 0; 1145 int deletedEventL = 0;
1143 int changedLocal = 0; 1146 int changedLocal = 0;
1144 int changedRemote = 0; 1147 int changedRemote = 0;
1145 int filteredIN = 0; 1148 int filteredIN = 0;
1146 int filteredOUT = 0; 1149 int filteredOUT = 0;
1147 //QPtrList<Event> el = local->rawEvents(); 1150 //QPtrList<Event> el = local->rawEvents();
1148 Event* eventR; 1151 Event* eventR;
1149 QString uid; 1152 QString uid;
1150 int take; 1153 int take;
1151 Event* eventL; 1154 Event* eventL;
1152 Event* eventRSync; 1155 Event* eventRSync;
1153 Event* eventLSync; 1156 Event* eventLSync;
1154 clearAllViews(); 1157 clearAllViews();
1155 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); 1158 QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents();
1156 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); 1159 QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents();
1157 bool fullDateRange = false; 1160 bool fullDateRange = false;
1158 local->resetTempSyncStat(); 1161 local->resetTempSyncStat();
1159 mLastCalendarSync = QDateTime::currentDateTime(); 1162 mLastCalendarSync = QDateTime::currentDateTime();
1160 if ( mSyncManager->syncWithDesktop() ) { 1163 if ( mSyncManager->syncWithDesktop() ) {
1161 remote->resetPilotStat(1); 1164 remote->resetPilotStat(1);
1162 if ( KSyncManager::mRequestedSyncEvent.isValid() ) { 1165 if ( KSyncManager::mRequestedSyncEvent.isValid() ) {
1163 mLastCalendarSync = KSyncManager::mRequestedSyncEvent; 1166 mLastCalendarSync = KSyncManager::mRequestedSyncEvent;
1164 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() ); 1167 qDebug("KO: using extern time for calendar sync: %s ", mLastCalendarSync.toString().latin1() );
1165 } else { 1168 } else {
1166 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime "); 1169 qDebug("KSyncManager::mRequestedSyncEvent has invalid datatime ");
1167 } 1170 }
1168 } 1171 }
1169 QDateTime modifiedCalendar = mLastCalendarSync; 1172 QDateTime modifiedCalendar = mLastCalendarSync;
1170 eventLSync = getLastSyncEvent(); 1173 eventLSync = getLastSyncEvent();
1171 eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); 1174 eventR = remote->event("last-syncEvent-"+mCurrentSyncName );
1172 if ( eventR ) { 1175 if ( eventR ) {
1173 eventRSync = (Event*) eventR->clone(); 1176 eventRSync = (Event*) eventR->clone();
1174 remote->deleteEvent(eventR ); 1177 remote->deleteEvent(eventR );
1175 1178
1176 } else { 1179 } else {
1177 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) { 1180 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL || mSyncManager->syncWithDesktop()) {
1178 eventRSync = (Event*)eventLSync->clone(); 1181 eventRSync = (Event*)eventLSync->clone();
1179 } else { 1182 } else {
1180 fullDateRange = true; 1183 fullDateRange = true;
1181 eventRSync = new Event(); 1184 eventRSync = new Event();
1182 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); 1185 eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event"));
1183 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); 1186 eventRSync->setUid("last-syncEvent-"+mCurrentSyncName );
1184 eventRSync->setDtStart( mLastCalendarSync ); 1187 eventRSync->setDtStart( mLastCalendarSync );
1185 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); 1188 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) );
1186 eventRSync->setCategories( i18n("SyncEvent") ); 1189 eventRSync->setCategories( i18n("SyncEvent") );
1187 } 1190 }
1188 } 1191 }
1189 if ( eventLSync->dtStart() == mLastCalendarSync ) 1192 if ( eventLSync->dtStart() == mLastCalendarSync )
1190 fullDateRange = true; 1193 fullDateRange = true;
1191 1194
1192 if ( ! fullDateRange ) { 1195 if ( ! fullDateRange ) {
1193 if ( eventLSync->dtStart() != eventRSync->dtStart() ) { 1196 if ( eventLSync->dtStart() != eventRSync->dtStart() ) {
1194 1197
1195 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() ); 1198 // qDebug("set fulldate to true %s %s" ,eventLSync->dtStart().toString().latin1(), eventRSync->dtStart().toString().latin1() );
1196 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec()); 1199 //qDebug("%d %d %d %d ", eventLSync->dtStart().time().second(), eventLSync->dtStart().time().msec() , eventRSync->dtStart().time().second(), eventRSync->dtStart().time().msec());
1197 fullDateRange = true; 1200 fullDateRange = true;
1198 } 1201 }
1199 } 1202 }
1200 if ( mSyncManager->syncWithDesktop() ) { 1203 if ( mSyncManager->syncWithDesktop() ) {
1201 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync ); 1204 fullDateRange = ( eventLSync->dtStart() <= mLastCalendarSync && eventLSync->dtStart().addSecs(1) >= mLastCalendarSync );
1202 } 1205 }
1203 if ( fullDateRange ) 1206 if ( fullDateRange )
1204 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365); 1207 mLastCalendarSync = QDateTime::currentDateTime().addDays( -100*365);
1205 else 1208 else
1206 mLastCalendarSync = eventLSync->dtStart(); 1209 mLastCalendarSync = eventLSync->dtStart();
1207 // for resyncing if own file has changed 1210 // for resyncing if own file has changed
1208 if ( mCurrentSyncDevice == "deleteaftersync" ) { 1211 if ( mCurrentSyncDevice == "deleteaftersync" ) {
1209 mLastCalendarSync = loadedFileVersion; 1212 mLastCalendarSync = loadedFileVersion;
1210 //qDebug("setting mLastCalendarSync "); 1213 //qDebug("setting mLastCalendarSync ");
1211 } 1214 }
1212 //qDebug("*************************** "); 1215 //qDebug("*************************** ");
1213 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange); 1216 qDebug("KO: mLastCalendarSync %s .Full: %d",mLastCalendarSync.toString().latin1(), fullDateRange);
1214 QPtrList<Incidence> er = remote->rawIncidences(); 1217 QPtrList<Incidence> er = remote->rawIncidences();
1215 Incidence* inR = er.first(); 1218 Incidence* inR = er.first();
1216 Incidence* inL; 1219 Incidence* inL;
1217 QProgressBar bar( er.count(),0 ); 1220 QProgressBar bar( er.count(),0 );
1218 bar.setCaption (i18n("Syncing - close to abort!") ); 1221 bar.setCaption (i18n("Syncing - close to abort!") );
1219 1222
1220 // ************** setting up filter ************* 1223 // ************** setting up filter *************
1221 CalFilter *filterIN = 0; 1224 CalFilter *filterIN = 0;
1222 CalFilter *filterOUT = 0; 1225 CalFilter *filterOUT = 0;
1223 CalFilter *filter = mFilters.first(); 1226 CalFilter *filter = mFilters.first();
1224 while(filter) { 1227 while(filter) {
1225 if ( filter->name() == mSyncManager->mFilterInCal ) 1228 if ( filter->name() == mSyncManager->mFilterInCal )
1226 filterIN = filter; 1229 filterIN = filter;
1227 if ( filter->name() == mSyncManager->mFilterOutCal ) 1230 if ( filter->name() == mSyncManager->mFilterOutCal )
1228 filterOUT = filter; 1231 filterOUT = filter;
1229 filter = mFilters.next(); 1232 filter = mFilters.next();
1230 } 1233 }
1231 int w = 300; 1234 int w = 300;
1232 if ( QApplication::desktop()->width() < 320 ) 1235 if ( QApplication::desktop()->width() < 320 )
1233 w = 220; 1236 w = 220;
1234 int h = bar.sizeHint().height() ; 1237 int h = bar.sizeHint().height() ;
1235 int dw = QApplication::desktop()->width(); 1238 int dw = QApplication::desktop()->width();
1236 int dh = QApplication::desktop()->height(); 1239 int dh = QApplication::desktop()->height();
1237 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1240 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1238 bar.show(); 1241 bar.show();
1239 int modulo = (er.count()/10)+1; 1242 int modulo = (er.count()/10)+1;
1240 int incCounter = 0; 1243 int incCounter = 0;
1241 while ( inR ) { 1244 while ( inR ) {
1242 if ( ! bar.isVisible() ) 1245 if ( ! bar.isVisible() )
1243 return false; 1246 return false;
1244 if ( incCounter % modulo == 0 ) 1247 if ( incCounter % modulo == 0 )
1245 bar.setProgress( incCounter ); 1248 bar.setProgress( incCounter );
1246 ++incCounter; 1249 ++incCounter;
1247 uid = inR->uid(); 1250 uid = inR->uid();
1248 bool skipIncidence = false; 1251 bool skipIncidence = false;
1249 if ( uid.left(15) == QString("last-syncEvent-") ) 1252 if ( uid.left(15) == QString("last-syncEvent-") )
1250 skipIncidence = true; 1253 skipIncidence = true;
1251 QString idS; 1254 QString idS;
1252 qApp->processEvents(); 1255 qApp->processEvents();
1253 if ( !skipIncidence ) { 1256 if ( !skipIncidence ) {
1254 inL = local->incidence( uid ); 1257 inL = local->incidence( uid );
1255 if ( inL ) { // maybe conflict - same uid in both calendars 1258 if ( inL ) { // maybe conflict - same uid in both calendars
1256 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1259 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1257 //qDebug("take %d %s ", take, inL->summary().latin1()); 1260 //qDebug("take %d %s ", take, inL->summary().latin1());
1258 if ( take == 3 ) 1261 if ( take == 3 )
1259 return false; 1262 return false;
1260 if ( take == 1 ) {// take local ********************** 1263 if ( take == 1 ) {// take local **********************
1261 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1264 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1262 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1265 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1263 else 1266 else
1264 idS = inR->IDStr(); 1267 idS = inR->IDStr();
1265 remote->deleteIncidence( inR ); 1268 remote->deleteIncidence( inR );
1266 inR = inL->clone(); 1269 inR = inL->clone();
1267 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1270 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1268 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1271 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1269 inR->setIDStr( idS ); 1272 inR->setIDStr( idS );
1270 remote->addIncidence( inR ); 1273 remote->addIncidence( inR );
1271 if ( mSyncManager->syncWithDesktop() ) 1274 if ( mSyncManager->syncWithDesktop() )
1272 inR->setPilotId( 2 ); 1275 inR->setPilotId( 2 );
1273 ++changedRemote; 1276 ++changedRemote;
1274 } else {// take remote ********************** 1277 } else {// take remote **********************
1275 idS = inL->IDStr(); 1278 idS = inL->IDStr();
1276 int pid = inL->pilotId(); 1279 int pid = inL->pilotId();
1277 local->deleteIncidence( inL ); 1280 local->deleteIncidence( inL );
1278 inL = inR->clone(); 1281 inL = inR->clone();
1279 if ( mSyncManager->syncWithDesktop() ) 1282 if ( mSyncManager->syncWithDesktop() )
1280 inL->setPilotId( pid ); 1283 inL->setPilotId( pid );
1281 inL->setIDStr( idS ); 1284 inL->setIDStr( idS );
1282 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1285 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1283 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1286 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1284 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1287 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1285 } 1288 }
1286 local->addIncidence( inL ); 1289 local->addIncidence( inL );
1287 ++changedLocal; 1290 ++changedLocal;
1288 } 1291 }
1289 } 1292 }
1290 } else { // no conflict ********** add or delete remote 1293 } else { // no conflict ********** add or delete remote
1291 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){ 1294 if ( !filterIN || filterIN->filterCalendarItem( inR ) ){
1292 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1295 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1293 QString des = eventLSync->description(); 1296 QString des = eventLSync->description();
1294 QString pref = "e"; 1297 QString pref = "e";
1295 if ( inR->typeID() == todoID ) 1298 if ( inR->typeID() == todoID )
1296 pref = "t"; 1299 pref = "t";
1297 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it 1300 if ( des.find(pref+ inR->getID(mCurrentSyncDevice) +"," ) >= 0 && mode != 5) { // delete it
1298 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE ); 1301 inR->setTempSyncStat( SYNC_TEMPSTATE_DELETE );
1299 //remote->deleteIncidence( inR ); 1302 //remote->deleteIncidence( inR );
1300 ++deletedEventR; 1303 ++deletedEventR;
1301 } else { 1304 } else {
1302 inR->setLastModified( modifiedCalendar ); 1305 inR->setLastModified( modifiedCalendar );
1303 inL = inR->clone(); 1306 inL = inR->clone();
1304 inL->setIDStr( ":" ); 1307 inL->setIDStr( ":" );
1305 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1308 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1306 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) ); 1309 inL->setID( mCurrentSyncDevice, inR->getID(mCurrentSyncDevice) );
1307 local->addIncidence( inL ); 1310 local->addIncidence( inL );
1308 ++addedEvent; 1311 ++addedEvent;
1309 1312
1310 } 1313 }
1311 } else { 1314 } else {
1312 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { 1315 if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) {
1313 inR->setLastModified( modifiedCalendar ); 1316 inR->setLastModified( modifiedCalendar );
1314 inL = inR->clone(); 1317 inL = inR->clone();
1315 inL->setIDStr( ":" ); 1318 inL->setIDStr( ":" );
1316 local->addIncidence( inL ); 1319 local->addIncidence( inL );
1317 ++addedEvent; 1320 ++addedEvent;
1318 1321
1319 } else { 1322 } else {
1320 checkExternSyncEvent(eventRSyncSharp, inR); 1323 checkExternSyncEvent(eventRSyncSharp, inR);
1321 remote->deleteIncidence( inR ); 1324 remote->deleteIncidence( inR );
1322 ++deletedEventR; 1325 ++deletedEventR;
1323 } 1326 }
1324 } 1327 }
1325 } else { 1328 } else {
1326 ++filteredIN; 1329 ++filteredIN;
1327 } 1330 }
1328 } 1331 }
1329 } 1332 }
1330 inR = er.next(); 1333 inR = er.next();
1331 } 1334 }
1332 QPtrList<Incidence> el = local->rawIncidences(); 1335 QPtrList<Incidence> el = local->rawIncidences();
1333 inL = el.first(); 1336 inL = el.first();
1334 modulo = (el.count()/10)+1; 1337 modulo = (el.count()/10)+1;
1335 bar.setCaption (i18n("Add / remove events") ); 1338 bar.setCaption (i18n("Add / remove events") );
1336 bar.setTotalSteps ( el.count() ) ; 1339 bar.setTotalSteps ( el.count() ) ;
1337 bar.show(); 1340 bar.show();
1338 incCounter = 0; 1341 incCounter = 0;
1339 1342
1340 while ( inL ) { 1343 while ( inL ) {
1341 1344
1342 qApp->processEvents(); 1345 qApp->processEvents();
1343 if ( ! bar.isVisible() ) 1346 if ( ! bar.isVisible() )
1344 return false; 1347 return false;
1345 if ( incCounter % modulo == 0 ) 1348 if ( incCounter % modulo == 0 )
1346 bar.setProgress( incCounter ); 1349 bar.setProgress( incCounter );
1347 ++incCounter; 1350 ++incCounter;
1348 uid = inL->uid(); 1351 uid = inL->uid();
1349 bool skipIncidence = false; 1352 bool skipIncidence = false;
1350 if ( uid.left(15) == QString("last-syncEvent-") ) 1353 if ( uid.left(15) == QString("last-syncEvent-") )
1351 skipIncidence = true; 1354 skipIncidence = true;
1352 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) 1355 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID )
1353 skipIncidence = true; 1356 skipIncidence = true;
1354 if ( !skipIncidence ) { 1357 if ( !skipIncidence ) {
1355 inR = remote->incidence( uid ); 1358 inR = remote->incidence( uid );
1356 if ( ! inR ) { 1359 if ( ! inR ) {
1357 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ 1360 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){
1358 // no conflict ********** add or delete local 1361 // no conflict ********** add or delete local
1359 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1362 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1360 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1363 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1361 checkExternSyncEvent(eventLSyncSharp, inL); 1364 checkExternSyncEvent(eventLSyncSharp, inL);
1362 local->deleteIncidence( inL ); 1365 local->deleteIncidence( inL );
1363 ++deletedEventL; 1366 ++deletedEventL;
1364 } else { 1367 } else {
1365 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1368 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1366 inL->removeID(mCurrentSyncDevice ); 1369 inL->removeID(mCurrentSyncDevice );
1367 ++addedEventR; 1370 ++addedEventR;
1368 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1371 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1369 inL->setLastModified( modifiedCalendar ); 1372 inL->setLastModified( modifiedCalendar );
1370 inR = inL->clone(); 1373 inR = inL->clone();
1371 inR->setIDStr( ":" ); 1374 inR->setIDStr( ":" );
1372 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1375 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1373 remote->addIncidence( inR ); 1376 remote->addIncidence( inR );
1374 } 1377 }
1375 } 1378 }
1376 } else { 1379 } else {
1377 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1380 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1378 checkExternSyncEvent(eventLSyncSharp, inL); 1381 checkExternSyncEvent(eventLSyncSharp, inL);
1379 local->deleteIncidence( inL ); 1382 local->deleteIncidence( inL );
1380 ++deletedEventL; 1383 ++deletedEventL;
1381 } else { 1384 } else {
1382 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1385 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1383 ++addedEventR; 1386 ++addedEventR;
1384 inL->setLastModified( modifiedCalendar ); 1387 inL->setLastModified( modifiedCalendar );
1385 inR = inL->clone(); 1388 inR = inL->clone();
1386 inR->setIDStr( ":" ); 1389 inR->setIDStr( ":" );
1387 remote->addIncidence( inR ); 1390 remote->addIncidence( inR );
1388 } 1391 }
1389 } 1392 }
1390 } 1393 }
1391 } else { 1394 } else {
1392 ++filteredOUT; 1395 ++filteredOUT;
1393 } 1396 }
1394 } 1397 }
1395 } 1398 }
1396 inL = el.next(); 1399 inL = el.next();
1397 } 1400 }
1398 int delFut = 0; 1401 int delFut = 0;
1399 int remRem = 0; 1402 int remRem = 0;
1400 if ( mSyncManager->mWriteBackInFuture ) { 1403 if ( mSyncManager->mWriteBackInFuture ) {
1401 er = remote->rawIncidences(); 1404 er = remote->rawIncidences();
1402 remRem = er.count(); 1405 remRem = er.count();
1403 inR = er.first(); 1406 inR = er.first();
1404 QDateTime dt; 1407 QDateTime dt;
1405 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) ); 1408 QDateTime cur = QDateTime::currentDateTime().addDays( -(mSyncManager->mWriteBackInPast * 7) );
1406 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 ); 1409 QDateTime end = QDateTime::currentDateTime().addDays( (mSyncManager->mWriteBackInFuture ) *7 );
1407 while ( inR ) { 1410 while ( inR ) {
1408 if ( inR->typeID() == todoID ) { 1411 if ( inR->typeID() == todoID ) {
1409 Todo * t = (Todo*)inR; 1412 Todo * t = (Todo*)inR;
1410 if ( t->hasDueDate() ) 1413 if ( t->hasDueDate() )
1411 dt = t->dtDue(); 1414 dt = t->dtDue();
1412 else 1415 else
1413 dt = cur.addSecs( 62 ); 1416 dt = cur.addSecs( 62 );
1414 } 1417 }
1415 else if (inR->typeID() == eventID ) { 1418 else if (inR->typeID() == eventID ) {
1416 bool ok; 1419 bool ok;
1417 dt = inR->getNextOccurence( cur, &ok ); 1420 dt = inR->getNextOccurence( cur, &ok );
1418 if ( !ok ) 1421 if ( !ok )
1419 dt = cur.addSecs( -62 ); 1422 dt = cur.addSecs( -62 );
1420 } 1423 }
1421 else 1424 else
1422 dt = inR->dtStart(); 1425 dt = inR->dtStart();
1423 if ( dt < cur || dt > end ) { 1426 if ( dt < cur || dt > end ) {
1424 remote->deleteIncidence( inR ); 1427 remote->deleteIncidence( inR );
1425 ++delFut; 1428 ++delFut;
1426 } 1429 }
1427 inR = er.next(); 1430 inR = er.next();
1428 } 1431 }
1429 } 1432 }
1430 bar.hide(); 1433 bar.hide();
1431 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); 1434 mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 );
1432 eventLSync->setReadOnly( false ); 1435 eventLSync->setReadOnly( false );
1433 eventLSync->setDtStart( mLastCalendarSync ); 1436 eventLSync->setDtStart( mLastCalendarSync );
1434 eventRSync->setDtStart( mLastCalendarSync ); 1437 eventRSync->setDtStart( mLastCalendarSync );
1435 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1438 eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1436 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); 1439 eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) );
1437 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; 1440 eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ;
1438 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); 1441 eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName );
1439 eventLSync->setReadOnly( true ); 1442 eventLSync->setReadOnly( true );
1440 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); 1443 qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL );
1441 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... 1444 if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal...
1442 remote->addEvent( eventRSync ); 1445 remote->addEvent( eventRSync );
1443 else 1446 else
1444 delete eventRSync; 1447 delete eventRSync;
1445 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); 1448 qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() );
1446 QString mes; 1449 QString mes;
1447 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 ); 1450 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 );
1448 QString delmess; 1451 QString delmess;
1449 if ( delFut ) { 1452 if ( delFut ) {
1450 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); 1453 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);
1451 mes += delmess; 1454 mes += delmess;
1452 } 1455 }
1453 mes = i18n("Local calendar changed!\n") +mes; 1456 mes = i18n("Local calendar changed!\n") +mes;
1454 mCalendar->checkAlarmForIncidence( 0, true ); 1457 mCalendar->checkAlarmForIncidence( 0, true );
1455 qDebug( mes ); 1458 qDebug( mes );
1456 if ( mSyncManager->mShowSyncSummary ) { 1459 if ( mSyncManager->mShowSyncSummary ) {
1457 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes, 1460 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, mes,
1458 i18n("KO/Pi Synchronization"),i18n("Write back"))) { 1461 i18n("KO/Pi Synchronization"),i18n("Write back"))) {
1459 qDebug("KO: WB cancelled "); 1462 qDebug("KO: WB cancelled ");
1460 mSyncManager->mWriteBackFile = false; 1463 mSyncManager->mWriteBackFile = false;
1461 return syncOK; 1464 return syncOK;
1462 } 1465 }
1463 } 1466 }
1464 return syncOK; 1467 return syncOK;
1465} 1468}
1466 1469
1467void CalendarView::setSyncDevice( QString s ) 1470void CalendarView::setSyncDevice( QString s )
1468{ 1471{
1469 mCurrentSyncDevice= s; 1472 mCurrentSyncDevice= s;
1470} 1473}
1471void CalendarView::setSyncName( QString s ) 1474void CalendarView::setSyncName( QString s )
1472{ 1475{
1473 mCurrentSyncName= s; 1476 mCurrentSyncName= s;
1474} 1477}
1475bool CalendarView::syncCalendar(QString filename, int mode) 1478bool CalendarView::syncCalendar(QString filename, int mode)
1476{ 1479{
1477 //qDebug("syncCalendar %s ", filename.latin1()); 1480 //qDebug("syncCalendar %s ", filename.latin1());
1478 mGlobalSyncMode = SYNC_MODE_NORMAL; 1481 mGlobalSyncMode = SYNC_MODE_NORMAL;
1479 CalendarLocal* calendar = new CalendarLocal(); 1482 CalendarLocal* calendar = new CalendarLocal();
1480 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1483 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1481 FileStorage* storage = new FileStorage( calendar ); 1484 FileStorage* storage = new FileStorage( calendar );
1482 bool syncOK = false; 1485 bool syncOK = false;
1483 storage->setFileName( filename ); 1486 storage->setFileName( filename );
1484 // qDebug("loading ... "); 1487 // qDebug("loading ... ");
1485 if ( storage->load() ) { 1488 if ( storage->load() ) {
1486 getEventViewerDialog()->setSyncMode( true ); 1489 getEventViewerDialog()->setSyncMode( true );
1487 syncOK = synchronizeCalendar( mCalendar, calendar, mode ); 1490 syncOK = synchronizeCalendar( mCalendar, calendar, mode );
1488 getEventViewerDialog()->setSyncMode( false ); 1491 getEventViewerDialog()->setSyncMode( false );
1489 if ( syncOK ) { 1492 if ( syncOK ) {
1490 if ( mSyncManager->mWriteBackFile ) 1493 if ( mSyncManager->mWriteBackFile )
1491 { 1494 {
1492 storage->setSaveFormat( new ICalFormat() ); 1495 storage->setSaveFormat( new ICalFormat() );
1493 storage->save(); 1496 storage->save();
1494 } 1497 }
1495 } 1498 }
1496 setModified( true ); 1499 setModified( true );
1497 } 1500 }
1498 delete storage; 1501 delete storage;
1499 delete calendar; 1502 delete calendar;
1500 if ( syncOK ) 1503 if ( syncOK )
1501 updateView(); 1504 updateView();
1502 return syncOK; 1505 return syncOK;
1503} 1506}
1504 1507
1505void CalendarView::syncExternal( int mode ) 1508void CalendarView::syncExternal( int mode )
1506{ 1509{
1507 mGlobalSyncMode = SYNC_MODE_EXTERNAL; 1510 mGlobalSyncMode = SYNC_MODE_EXTERNAL;
1508 1511
1509 qApp->processEvents(); 1512 qApp->processEvents();
1510 CalendarLocal* calendar = new CalendarLocal(); 1513 CalendarLocal* calendar = new CalendarLocal();
1511 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1514 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1512 bool syncOK = false; 1515 bool syncOK = false;
1513 bool loadSuccess = false; 1516 bool loadSuccess = false;
1514 PhoneFormat* phoneFormat = 0; 1517 PhoneFormat* phoneFormat = 0;
1515 emit tempDisableBR(true); 1518 emit tempDisableBR(true);
1516#ifndef DESKTOP_VERSION 1519#ifndef DESKTOP_VERSION
1517 SharpFormat* sharpFormat = 0; 1520 SharpFormat* sharpFormat = 0;
1518 if ( mode == 0 ) { // sharp 1521 if ( mode == 0 ) { // sharp
1519 sharpFormat = new SharpFormat () ; 1522 sharpFormat = new SharpFormat () ;
1520 loadSuccess = sharpFormat->load( calendar, mCalendar ); 1523 loadSuccess = sharpFormat->load( calendar, mCalendar );
1521 1524
1522 } else 1525 } else
1523#endif 1526#endif
1524 if ( mode == 1 ) { // phone 1527 if ( mode == 1 ) { // phone
1525 phoneFormat = new PhoneFormat (mCurrentSyncDevice, 1528 phoneFormat = new PhoneFormat (mCurrentSyncDevice,
1526 mSyncManager->mPhoneDevice, 1529 mSyncManager->mPhoneDevice,
1527 mSyncManager->mPhoneConnection, 1530 mSyncManager->mPhoneConnection,
1528 mSyncManager->mPhoneModel); 1531 mSyncManager->mPhoneModel);
1529 loadSuccess = phoneFormat->load( calendar,mCalendar); 1532 loadSuccess = phoneFormat->load( calendar,mCalendar);
1530 1533
1531 } else { 1534 } else {
1532 emit tempDisableBR(false); 1535 emit tempDisableBR(false);
1533 return; 1536 return;
1534 } 1537 }
1535 if ( loadSuccess ) { 1538 if ( loadSuccess ) {
1536 getEventViewerDialog()->setSyncMode( true ); 1539 getEventViewerDialog()->setSyncMode( true );
1537 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1540 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1538 getEventViewerDialog()->setSyncMode( false ); 1541 getEventViewerDialog()->setSyncMode( false );
1539 qApp->processEvents(); 1542 qApp->processEvents();
1540 if ( syncOK ) { 1543 if ( syncOK ) {
1541 if ( mSyncManager->mWriteBackFile ) 1544 if ( mSyncManager->mWriteBackFile )
1542 { 1545 {
1543 QPtrList<Incidence> iL = mCalendar->rawIncidences(); 1546 QPtrList<Incidence> iL = mCalendar->rawIncidences();
1544 Incidence* inc = iL.first(); 1547 Incidence* inc = iL.first();
1545 if ( phoneFormat ) { 1548 if ( phoneFormat ) {
1546 while ( inc ) { 1549 while ( inc ) {
1547 inc->removeID(mCurrentSyncDevice); 1550 inc->removeID(mCurrentSyncDevice);
1548 inc = iL.next(); 1551 inc = iL.next();
1549 } 1552 }
1550 } 1553 }
1551#ifndef DESKTOP_VERSION 1554#ifndef DESKTOP_VERSION
1552 if ( sharpFormat ) 1555 if ( sharpFormat )
1553 sharpFormat->save(calendar); 1556 sharpFormat->save(calendar);
1554#endif 1557#endif
1555 if ( phoneFormat ) 1558 if ( phoneFormat )
1556 phoneFormat->save(calendar); 1559 phoneFormat->save(calendar);
1557 iL = calendar->rawIncidences(); 1560 iL = calendar->rawIncidences();
1558 inc = iL.first(); 1561 inc = iL.first();
1559 Incidence* loc; 1562 Incidence* loc;
1560 while ( inc ) { 1563 while ( inc ) {
1561 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) { 1564 if ( inc->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID ) {
1562 loc = mCalendar->incidence(inc->uid() ); 1565 loc = mCalendar->incidence(inc->uid() );
1563 if ( loc ) { 1566 if ( loc ) {
1564 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) ); 1567 loc->setID(mCurrentSyncDevice, inc->getID(mCurrentSyncDevice) );
1565 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) ); 1568 loc->setCsum( mCurrentSyncDevice, inc->getCsum(mCurrentSyncDevice) );
1566 } 1569 }
1567 } 1570 }
1568 inc = iL.next(); 1571 inc = iL.next();
1569 } 1572 }
1570 Incidence* lse = getLastSyncEvent(); 1573 Incidence* lse = getLastSyncEvent();
1571 if ( lse ) { 1574 if ( lse ) {
1572 lse->setReadOnly( false ); 1575 lse->setReadOnly( false );
1573 lse->setDescription( "" ); 1576 lse->setDescription( "" );
1574 lse->setReadOnly( true ); 1577 lse->setReadOnly( true );
1575 } 1578 }
1576 } 1579 }
1577 } else { 1580 } else {
1578 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") ); 1581 topLevelWidget()->setCaption( i18n("Sync cancelled or failed.") );
1579 } 1582 }
1580 setModified( true ); 1583 setModified( true );
1581 } else { 1584 } else {
1582 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ; 1585 QString question = i18n("Sorry, the database access\ncommand failed!\n\nNothing synced!\n") ;
1583 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"), 1586 QMessageBox::information( 0, i18n("KO/Pi Import - ERROR"),
1584 question, i18n("Ok")) ; 1587 question, i18n("Ok")) ;
1585 1588
1586 } 1589 }
1587 delete calendar; 1590 delete calendar;
1588 updateView(); 1591 updateView();
1589 emit tempDisableBR(false); 1592 emit tempDisableBR(false);
1590 return ;//syncOK; 1593 return ;//syncOK;
1591 1594
1592} 1595}
1593 1596
1594bool CalendarView::importBday() 1597bool CalendarView::importBday()
1595{ 1598{
1596#ifndef KORG_NOKABC 1599#ifndef KORG_NOKABC
1597 1600
1598#ifdef DESKTOP_VERSION 1601#ifdef DESKTOP_VERSION
1599 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true ); 1602 KABC::StdAddressBook* AddressBook = KABC::StdAddressBook::self( true );
1600 KABC::AddressBook::Iterator it; 1603 KABC::AddressBook::Iterator it;
1601 int count = 0; 1604 int count = 0;
1602 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1605 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1603 ++count; 1606 ++count;
1604 } 1607 }
1605 QProgressBar bar(count,0 ); 1608 QProgressBar bar(count,0 );
1606 int w = 300; 1609 int w = 300;
1607 if ( QApplication::desktop()->width() < 320 ) 1610 if ( QApplication::desktop()->width() < 320 )
1608 w = 220; 1611 w = 220;
1609 int h = bar.sizeHint().height() ; 1612 int h = bar.sizeHint().height() ;
1610 int dw = QApplication::desktop()->width(); 1613 int dw = QApplication::desktop()->width();
1611 int dh = QApplication::desktop()->height(); 1614 int dh = QApplication::desktop()->height();
1612 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1615 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1613 bar.show(); 1616 bar.show();
1614 bar.setCaption (i18n("Reading addressbook - close to abort!") ); 1617 bar.setCaption (i18n("Reading addressbook - close to abort!") );
1615 qApp->processEvents(); 1618 qApp->processEvents();
1616 count = 0; 1619 count = 0;
1617 int addCount = 0; 1620 int addCount = 0;
1618 KCal::Attendee* a = 0; 1621 KCal::Attendee* a = 0;
1619 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) { 1622 for( it = AddressBook->begin(); it != AddressBook->end(); ++it ) {
1620 if ( ! bar.isVisible() ) 1623 if ( ! bar.isVisible() )
1621 return false; 1624 return false;
1622 bar.setProgress( count++ ); 1625 bar.setProgress( count++ );
1623 qApp->processEvents(); 1626 qApp->processEvents();
1624 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() ); 1627 //qDebug("add BDay %s %s", (*it).realName().latin1(),(*it).birthday().date().toString().latin1() );
1625 if ( (*it).birthday().date().isValid() ){ 1628 if ( (*it).birthday().date().isValid() ){
1626 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1629 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1627 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) ) 1630 if ( addAnniversary( (*it).birthday().date(), (*it).assembledName(), a, true ) )
1628 ++addCount; 1631 ++addCount;
1629 } 1632 }
1630 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); 1633 QDate anni = KGlobal::locale()->readDate( (*it).custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d");
1631 if ( anni.isValid() ){ 1634 if ( anni.isValid() ){
1632 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ; 1635 a = new KCal::Attendee( (*it).realName(), (*it).preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,(*it).uid()) ;
1633 if ( addAnniversary( anni, (*it).assembledName(), a, false ) ) 1636 if ( addAnniversary( anni, (*it).assembledName(), a, false ) )
1634 ++addCount; 1637 ++addCount;
1635 } 1638 }
1636 } 1639 }
1637 updateView(); 1640 updateView();
1638 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1641 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1639#else //DESKTOP_VERSION 1642#else //DESKTOP_VERSION
1640 1643
1641 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); 1644 ExternalAppHandler::instance()->requestBirthdayListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/);
1642 // the result should now arrive through method insertBirthdays 1645 // the result should now arrive through method insertBirthdays
1643 1646
1644#endif //DESKTOP_VERSION 1647#endif //DESKTOP_VERSION
1645 1648
1646#endif //KORG_NOKABC 1649#endif //KORG_NOKABC
1647 1650
1648 1651
1649 return true; 1652 return true;
1650} 1653}
1651 1654
1652// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI 1655// This method will be called from Ka/Pi as a response to requestBirthdayListFromKAPI
1653void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList, 1656void CalendarView::insertBirthdays(const QString& uid, const QStringList& birthdayList,
1654 const QStringList& anniversaryList, const QStringList& realNameList, 1657 const QStringList& anniversaryList, const QStringList& realNameList,
1655 const QStringList& emailList, const QStringList& assembledNameList, 1658 const QStringList& emailList, const QStringList& assembledNameList,
1656 const QStringList& uidList) 1659 const QStringList& uidList)
1657{ 1660{
1658 //qDebug("KO::CalendarView::insertBirthdays"); 1661 //qDebug("KO::CalendarView::insertBirthdays");
1659 if (uid == this->name()) 1662 if (uid == this->name())
1660 { 1663 {
1661 int count = birthdayList.count(); 1664 int count = birthdayList.count();
1662 int addCount = 0; 1665 int addCount = 0;
1663 KCal::Attendee* a = 0; 1666 KCal::Attendee* a = 0;
1664 1667
1665 //qDebug("CalView 1 %i", count); 1668 //qDebug("CalView 1 %i", count);
1666 1669
1667 QProgressBar bar(count,0 ); 1670 QProgressBar bar(count,0 );
1668 int w = 300; 1671 int w = 300;
1669 if ( QApplication::desktop()->width() < 320 ) 1672 if ( QApplication::desktop()->width() < 320 )
1670 w = 220; 1673 w = 220;
1671 int h = bar.sizeHint().height() ; 1674 int h = bar.sizeHint().height() ;
1672 int dw = QApplication::desktop()->width(); 1675 int dw = QApplication::desktop()->width();
1673 int dh = QApplication::desktop()->height(); 1676 int dh = QApplication::desktop()->height();
1674 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1677 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1675 bar.show(); 1678 bar.show();
1676 bar.setCaption (i18n("inserting birthdays - close to abort!") ); 1679 bar.setCaption (i18n("inserting birthdays - close to abort!") );
1677 qApp->processEvents(); 1680 qApp->processEvents();
1678 1681
1679 QDate birthday; 1682 QDate birthday;
1680 QDate anniversary; 1683 QDate anniversary;
1681 QString realName; 1684 QString realName;
1682 QString email; 1685 QString email;
1683 QString assembledName; 1686 QString assembledName;
1684 QString uid; 1687 QString uid;
1685 bool ok = true; 1688 bool ok = true;
1686 for ( int i = 0; i < count; i++) 1689 for ( int i = 0; i < count; i++)
1687 { 1690 {
1688 if ( ! bar.isVisible() ) 1691 if ( ! bar.isVisible() )
1689 return; 1692 return;
1690 bar.setProgress( i ); 1693 bar.setProgress( i );
1691 qApp->processEvents(); 1694 qApp->processEvents();
1692 1695
1693 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok); 1696 birthday = KGlobal::locale()->readDate(birthdayList[i], KLocale::ISODate, &ok);
1694 if (!ok) { 1697 if (!ok) {
1695 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1()); 1698 ;//qDebug("CalendarView::insertBirthdays found invalid birthday: %s",birthdayList[i].latin1());
1696 } 1699 }
1697 1700
1698 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok); 1701 anniversary = KGlobal::locale()->readDate(anniversaryList[i], KLocale::ISODate, &ok);
1699 if (!ok) { 1702 if (!ok) {
1700 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1()); 1703 ;//qDebug("CalendarView::insertBirthdays found invalid anniversary: %s",anniversaryList[i].latin1());
1701 } 1704 }
1702 realName = realNameList[i]; 1705 realName = realNameList[i];
1703 email = emailList[i]; 1706 email = emailList[i];
1704 assembledName = assembledNameList[i]; 1707 assembledName = assembledNameList[i];
1705 uid = uidList[i]; 1708 uid = uidList[i];
1706 //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() ); 1709 //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() );
1707 1710
1708 if ( birthday.isValid() ){ 1711 if ( birthday.isValid() ){
1709 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1712 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1710 KCal::Attendee::ReqParticipant,uid) ; 1713 KCal::Attendee::ReqParticipant,uid) ;
1711 if ( addAnniversary( birthday, assembledName, a, true ) ) 1714 if ( addAnniversary( birthday, assembledName, a, true ) )
1712 ++addCount; 1715 ++addCount;
1713 } 1716 }
1714 1717
1715 if ( anniversary.isValid() ){ 1718 if ( anniversary.isValid() ){
1716 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction, 1719 a = new KCal::Attendee( realName, email,false,KCal::Attendee::NeedsAction,
1717 KCal::Attendee::ReqParticipant,uid) ; 1720 KCal::Attendee::ReqParticipant,uid) ;
1718 if ( addAnniversary( anniversary, assembledName, a, false ) ) 1721 if ( addAnniversary( anniversary, assembledName, a, false ) )
1719 ++addCount; 1722 ++addCount;
1720 } 1723 }
1721 } 1724 }
1722 1725
1723 updateView(); 1726 updateView();
1724 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!")); 1727 topLevelWidget()->setCaption(QString::number( addCount )+ i18n(" birthdays/anniversaries added!"));
1725 1728
1726 } 1729 }
1727 1730
1728} 1731}
1729 1732
1730 1733
1731 1734
1732bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday) 1735bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a, bool birthday)
1733{ 1736{
1734 //qDebug("addAnni "); 1737 //qDebug("addAnni ");
1735 Event * ev = new Event(); 1738 Event * ev = new Event();
1736 ev->setOrganizer(KOPrefs::instance()->email()); 1739 ev->setOrganizer(KOPrefs::instance()->email());
1737 if ( a ) { 1740 if ( a ) {
1738 ev->addAttendee( a ); 1741 ev->addAttendee( a );
1739 } 1742 }
1740 QString kind; 1743 QString kind;
1741 if ( birthday ) { 1744 if ( birthday ) {
1742 kind = i18n( "Birthday" ); 1745 kind = i18n( "Birthday" );
1743 ev->setSummary( name + " (" + QString::number(date.year()) +")"); 1746 ev->setSummary( name + " (" + QString::number(date.year()) +")");
1744 } 1747 }
1745 else { 1748 else {
1746 kind = i18n( "Anniversary" ); 1749 kind = i18n( "Anniversary" );
1747 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); 1750 ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind );
1748 } 1751 }
1749 ev->setCategories( kind ); 1752 ev->setCategories( kind );
1750 ev->setDtStart( QDateTime(date) ); 1753 ev->setDtStart( QDateTime(date) );
1751 ev->setDtEnd( QDateTime(date) ); 1754 ev->setDtEnd( QDateTime(date) );
1752 ev->setFloats( true ); 1755 ev->setFloats( true );
1753 Recurrence * rec = ev->recurrence(); 1756 Recurrence * rec = ev->recurrence();
1754 rec->setYearly(Recurrence::rYearlyMonth,1,-1); 1757 rec->setYearly(Recurrence::rYearlyMonth,1,-1);
1755 rec->addYearlyNum( date.month() ); 1758 rec->addYearlyNum( date.month() );
1756 if ( !mCalendar->addAnniversaryNoDup( ev ) ) { 1759 if ( !mCalendar->addAnniversaryNoDup( ev ) ) {
1757 delete ev; 1760 delete ev;
1758 return false; 1761 return false;
1759 } 1762 }
1760 return true; 1763 return true;
1761 1764
1762} 1765}
1763bool CalendarView::importQtopia( const QString &categories, 1766bool CalendarView::importQtopia( const QString &categories,
1764 const QString &datebook, 1767 const QString &datebook,
1765 const QString &todolist ) 1768 const QString &todolist )
1766{ 1769{
1767 1770
1768 QtopiaFormat qtopiaFormat; 1771 QtopiaFormat qtopiaFormat;
1769 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1772 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1770 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories ); 1773 if ( !categories.isEmpty() ) qtopiaFormat.load( mCalendar, categories );
1771 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook ); 1774 if ( !datebook.isEmpty() ) qtopiaFormat.load( mCalendar, datebook );
1772 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist ); 1775 if ( !todolist.isEmpty() ) qtopiaFormat.load( mCalendar, todolist );
1773 1776
1774 updateView(); 1777 updateView();
1775 return true; 1778 return true;
1776 1779
1777#if 0 1780#if 0
1778 mGlobalSyncMode = SYNC_MODE_QTOPIA; 1781 mGlobalSyncMode = SYNC_MODE_QTOPIA;
1779 mCurrentSyncDevice = "qtopia-XML"; 1782 mCurrentSyncDevice = "qtopia-XML";
1780 if ( mSyncManager->mAskForPreferences ) 1783 if ( mSyncManager->mAskForPreferences )
1781 edit_sync_options(); 1784 edit_sync_options();
1782 qApp->processEvents(); 1785 qApp->processEvents();
1783 CalendarLocal* calendar = new CalendarLocal(); 1786 CalendarLocal* calendar = new CalendarLocal();
1784 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 1787 calendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
1785 bool syncOK = false; 1788 bool syncOK = false;
1786 QtopiaFormat qtopiaFormat; 1789 QtopiaFormat qtopiaFormat;
1787 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories)); 1790 qtopiaFormat.setCategoriesList ( &(KOPrefs::instance()->mCustomCategories));
1788 bool loadOk = true; 1791 bool loadOk = true;
1789 if ( !categories.isEmpty() ) 1792 if ( !categories.isEmpty() )
1790 loadOk = qtopiaFormat.load( calendar, categories ); 1793 loadOk = qtopiaFormat.load( calendar, categories );
1791 if ( loadOk && !datebook.isEmpty() ) 1794 if ( loadOk && !datebook.isEmpty() )
1792 loadOk = qtopiaFormat.load( calendar, datebook ); 1795 loadOk = qtopiaFormat.load( calendar, datebook );
1793 if ( loadOk && !todolist.isEmpty() ) 1796 if ( loadOk && !todolist.isEmpty() )
1794 loadOk = qtopiaFormat.load( calendar, todolist ); 1797 loadOk = qtopiaFormat.load( calendar, todolist );
1795 1798
1796 if ( loadOk ) { 1799 if ( loadOk ) {
1797 getEventViewerDialog()->setSyncMode( true ); 1800 getEventViewerDialog()->setSyncMode( true );
1798 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs ); 1801 syncOK = synchronizeCalendar( mCalendar, calendar, mSyncManager->mSyncAlgoPrefs );
1799 getEventViewerDialog()->setSyncMode( false ); 1802 getEventViewerDialog()->setSyncMode( false );
1800 qApp->processEvents(); 1803 qApp->processEvents();
1801 if ( syncOK ) { 1804 if ( syncOK ) {
1802 if ( mSyncManager->mWriteBackFile ) 1805 if ( mSyncManager->mWriteBackFile )
1803 { 1806 {
1804 // write back XML file 1807 // write back XML file
1805 1808
1806 } 1809 }
1807 setModified( true ); 1810 setModified( true );
1808 } 1811 }
1809 } else { 1812 } else {
1810 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ; 1813 QString question = i18n("Sorry, the file loading\ncommand failed!\n\nNothing synced!\n") ;
1811 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"), 1814 QMessageBox::information( 0, i18n("KO/Pi Sync - ERROR"),
1812 question, i18n("Ok")) ; 1815 question, i18n("Ok")) ;
1813 } 1816 }
1814 delete calendar; 1817 delete calendar;
1815 updateView(); 1818 updateView();
1816 return syncOK; 1819 return syncOK;
1817 1820
1818 1821
1819#endif 1822#endif
1820 1823
1821} 1824}
1822 1825
1823void CalendarView::setSyncEventsReadOnly() 1826void CalendarView::setSyncEventsReadOnly()
1824{ 1827{
1825 Event * ev; 1828 Event * ev;
1826 QPtrList<Event> eL = mCalendar->rawEvents(); 1829 QPtrList<Event> eL = mCalendar->rawEvents();
1827 ev = eL.first(); 1830 ev = eL.first();
1828 while ( ev ) { 1831 while ( ev ) {
1829 if ( ev->uid().left(15) == QString("last-syncEvent-") ) 1832 if ( ev->uid().left(15) == QString("last-syncEvent-") )
1830 ev->setReadOnly( true ); 1833 ev->setReadOnly( true );
1831 ev = eL.next(); 1834 ev = eL.next();
1832 } 1835 }
1833} 1836}
1834bool CalendarView::openCalendar(QString filename, bool merge) 1837bool CalendarView::openCalendar(QString filename, bool merge)
1835{ 1838{
1836 1839
1837 if (filename.isEmpty()) { 1840 if (filename.isEmpty()) {
1838 return false; 1841 return false;
1839 } 1842 }
1840 1843
1841 if (!QFile::exists(filename)) { 1844 if (!QFile::exists(filename)) {
1842 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename)); 1845 KMessageBox::error(this,i18n("File does not exist:\n '%1'.").arg(filename));
1843 return false; 1846 return false;
1844 } 1847 }
1845 1848
1846 globalFlagBlockAgenda = 1; 1849 globalFlagBlockAgenda = 1;
1847 clearAllViews(); 1850 clearAllViews();
1848 if (!merge) { 1851 if (!merge) {
1849 mViewManager->setDocumentId( filename ); 1852 mViewManager->setDocumentId( filename );
1850 mCalendar->close(); 1853 mCalendar->close();
1851 } 1854 }
1852 mStorage->setFileName( filename ); 1855 mStorage->setFileName( filename );
1853 1856
1854 if ( mStorage->load() ) { 1857 if ( mStorage->load() ) {
1855 if ( merge ) ;//setModified( true ); 1858 if ( merge ) ;//setModified( true );
1856 else { 1859 else {
1857 //setModified( true ); 1860 //setModified( true );
1858 mViewManager->setDocumentId( filename ); 1861 mViewManager->setDocumentId( filename );
1859 mDialogManager->setDocumentId( filename ); 1862 mDialogManager->setDocumentId( filename );
1860 mTodoList->setDocumentId( filename ); 1863 mTodoList->setDocumentId( filename );
1861 } 1864 }
1862 globalFlagBlockAgenda = 2; 1865 globalFlagBlockAgenda = 2;
1863 // if ( getLastSyncEvent() ) 1866 // if ( getLastSyncEvent() )
1864 // getLastSyncEvent()->setReadOnly( true ); 1867 // getLastSyncEvent()->setReadOnly( true );
1865 mCalendar->reInitAlarmSettings(); 1868 mCalendar->reInitAlarmSettings();
1866 setSyncEventsReadOnly(); 1869 setSyncEventsReadOnly();
1867 updateUnmanagedViews(); 1870 updateUnmanagedViews();
1868 updateView(); 1871 updateView();
1869 if ( filename != MainWindow::defaultFileName() ) { 1872 if ( filename != MainWindow::defaultFileName() ) {
1870 saveCalendar( MainWindow::defaultFileName() ); 1873 saveCalendar( MainWindow::defaultFileName() );
1871 } else { 1874 } else {
1872 QFileInfo finf ( MainWindow::defaultFileName()); 1875 QFileInfo finf ( MainWindow::defaultFileName());
1873 if ( finf.exists() ) { 1876 if ( finf.exists() ) {
1874 setLoadedFileVersion( finf.lastModified () ); 1877 setLoadedFileVersion( finf.lastModified () );
1875 } 1878 }
1876 } 1879 }
1877 return true; 1880 return true;
1878 } else { 1881 } else {
1879 // while failing to load, the calendar object could 1882 // while failing to load, the calendar object could
1880 // have become partially populated. Clear it out. 1883 // have become partially populated. Clear it out.
1881 if ( !merge ) { 1884 if ( !merge ) {
1882 mCalendar->close(); 1885 mCalendar->close();
1883 mViewManager->setDocumentId( filename ); 1886 mViewManager->setDocumentId( filename );
1884 mDialogManager->setDocumentId( filename ); 1887 mDialogManager->setDocumentId( filename );
1885 mTodoList->setDocumentId( filename ); 1888 mTodoList->setDocumentId( filename );
1886 } 1889 }
1887 1890
1888 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename)); 1891 //KMessageBox::error(this,i18n("Couldn't load calendar\n '%1'.").arg(filename));
1889 1892
1890 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) ); 1893 QTimer::singleShot ( 1, this, SLOT ( showOpenError() ) );
1891 globalFlagBlockAgenda = 2; 1894 globalFlagBlockAgenda = 2;
1892 mCalendar->reInitAlarmSettings(); 1895 mCalendar->reInitAlarmSettings();
1893 setSyncEventsReadOnly(); 1896 setSyncEventsReadOnly();
1894 updateUnmanagedViews(); 1897 updateUnmanagedViews();
1895 updateView(); 1898 updateView();
1896 } 1899 }
1897 return false; 1900 return false;
1898} 1901}
1899void CalendarView::showOpenError() 1902void CalendarView::showOpenError()
1900{ 1903{
1901 KMessageBox::error(this,i18n("Couldn't load calendar\n.")); 1904 KMessageBox::error(this,i18n("Couldn't load calendar\n."));
1902} 1905}
1903void CalendarView::setLoadedFileVersion(QDateTime dt) 1906void CalendarView::setLoadedFileVersion(QDateTime dt)
1904{ 1907{
1905 loadedFileVersion = dt; 1908 loadedFileVersion = dt;
1906} 1909}
1907bool CalendarView::checkFileChanged(QString fn) 1910bool CalendarView::checkFileChanged(QString fn)
1908{ 1911{
1909 QFileInfo finf ( fn ); 1912 QFileInfo finf ( fn );
1910 if ( !finf.exists() ) 1913 if ( !finf.exists() )
1911 return true; 1914 return true;
1912 QDateTime dt = finf.lastModified (); 1915 QDateTime dt = finf.lastModified ();
1913 if ( dt <= loadedFileVersion ) 1916 if ( dt <= loadedFileVersion )
1914 return false; 1917 return false;
1915 return true; 1918 return true;
1916 1919
1917} 1920}
1918void CalendarView::watchSavedFile() 1921void CalendarView::watchSavedFile()
1919{ 1922{
1920 QFileInfo finf ( MainWindow::defaultFileName()); 1923 QFileInfo finf ( MainWindow::defaultFileName());
1921 if ( !finf.exists() ) 1924 if ( !finf.exists() )
1922 return; 1925 return;
1923 QDateTime dt = finf.lastModified (); 1926 QDateTime dt = finf.lastModified ();
1924 if ( dt < loadedFileVersion ) { 1927 if ( dt < loadedFileVersion ) {
1925 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1()); 1928 //qDebug("watch %s %s ", dt.toString().latin1(), loadedFileVersion.toString().latin1());
1926 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) ); 1929 QTimer::singleShot( 1000 , this, SLOT ( watchSavedFile() ) );
1927 return; 1930 return;
1928 } 1931 }
1929 loadedFileVersion = dt; 1932 loadedFileVersion = dt;
1930} 1933}
1931 1934
1932bool CalendarView::checkFileVersion(QString fn) 1935bool CalendarView::checkFileVersion(QString fn)
1933{ 1936{
1934 QFileInfo finf ( fn ); 1937 QFileInfo finf ( fn );
1935 if ( !finf.exists() ) 1938 if ( !finf.exists() )
1936 return true; 1939 return true;
1937 QDateTime dt = finf.lastModified (); 1940 QDateTime dt = finf.lastModified ();
1938 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1()); 1941 //qDebug("loaded file version %s",loadedFileVersion.toString().latin1());
1939 //qDebug("file on disk version %s",dt.toString().latin1()); 1942 //qDebug("file on disk version %s",dt.toString().latin1());
1940 if ( dt <= loadedFileVersion ) 1943 if ( dt <= loadedFileVersion )
1941 return true; 1944 return true;
1942 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) , 1945 int km = KMessageBox::warningYesNoCancel(this, i18n("\nThe file on disk has changed!\nFile size: %1 bytes.\nLast modified: %2\nDo you want to:\n\n - Save and overwrite file?\n - Sync with file, then save?\n - Cancel without saving? \n").arg( QString::number( finf.size())).arg( KGlobal::locale()->formatDateTime(finf.lastModified (), true, true)) ,
1943 i18n("KO/Pi Warning"),i18n("Overwrite"), 1946 i18n("KO/Pi Warning"),i18n("Overwrite"),
1944 i18n("Sync+save")); 1947 i18n("Sync+save"));
1945 1948
1946 if ( km == KMessageBox::Cancel ) 1949 if ( km == KMessageBox::Cancel )
1947 return false; 1950 return false;
1948 if ( km == KMessageBox::Yes ) 1951 if ( km == KMessageBox::Yes )
1949 return true; 1952 return true;
1950 1953
1951 setSyncDevice("deleteaftersync" ); 1954 setSyncDevice("deleteaftersync" );
1952 mSyncManager->mAskForPreferences = true; 1955 mSyncManager->mAskForPreferences = true;
1953 mSyncManager->mSyncAlgoPrefs = 3; 1956 mSyncManager->mSyncAlgoPrefs = 3;
1954 mSyncManager->mWriteBackFile = false; 1957 mSyncManager->mWriteBackFile = false;
1955 mSyncManager->mWriteBackExistingOnly = false; 1958 mSyncManager->mWriteBackExistingOnly = false;
1956 mSyncManager->mShowSyncSummary = false; 1959 mSyncManager->mShowSyncSummary = false;
1957 syncCalendar( fn, 3 ); 1960 syncCalendar( fn, 3 );
1958 Event * e = getLastSyncEvent(); 1961 Event * e = getLastSyncEvent();
1959 if ( e ) 1962 if ( e )
1960 deleteEvent ( e ); 1963 deleteEvent ( e );
1961 updateView(); 1964 updateView();
1962 return true; 1965 return true;
1963} 1966}
1964 1967
1965bool CalendarView::saveCalendar( QString filename ) 1968bool CalendarView::saveCalendar( QString filename )
1966{ 1969{
1967 1970
1968 // Store back all unsaved data into calendar object 1971 // Store back all unsaved data into calendar object
1969 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); 1972 // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() );
1970 if ( mViewManager->currentView() ) 1973 if ( mViewManager->currentView() )
1971 mViewManager->currentView()->flushView(); 1974 mViewManager->currentView()->flushView();
1972 1975
1973 1976
1974 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2); 1977 QDateTime lfv = QDateTime::currentDateTime().addSecs( -2);
1975 mStorage->setSaveFormat( new ICalFormat() ); 1978 mStorage->setSaveFormat( new ICalFormat() );
1976 mStorage->setFileName( filename ); 1979 mStorage->setFileName( filename );
1977 bool success; 1980 bool success;
1978 success = mStorage->save(); 1981 success = mStorage->save();
1979 if ( !success ) { 1982 if ( !success ) {
1980 return false; 1983 return false;
1981 } 1984 }
1982 if ( filename == MainWindow::defaultFileName() ) { 1985 if ( filename == MainWindow::defaultFileName() ) {
1983 setLoadedFileVersion( lfv ); 1986 setLoadedFileVersion( lfv );
1984 watchSavedFile(); 1987 watchSavedFile();
1985 } 1988 }
1986 return true; 1989 return true;
1987} 1990}
1988 1991
1989void CalendarView::closeCalendar() 1992void CalendarView::closeCalendar()
1990{ 1993{
1991 1994
1992 // child windows no longer valid 1995 // child windows no longer valid
1993 clearAllViews(); 1996 clearAllViews();
1994 emit closingDown(); 1997 emit closingDown();
1995 1998
1996 mCalendar->close(); 1999 mCalendar->close();
1997 setModified(false); 2000 setModified(false);
1998 updateView(); 2001 updateView();
1999} 2002}
2000 2003
2001void CalendarView::archiveCalendar() 2004void CalendarView::archiveCalendar()
2002{ 2005{
2003 mDialogManager->showArchiveDialog(); 2006 mDialogManager->showArchiveDialog();
2004} 2007}
2005 2008
2006 2009
2007void CalendarView::readSettings() 2010void CalendarView::readSettings()
2008{ 2011{
2009 2012
2010 2013
2011 // mViewManager->showAgendaView(); 2014 // mViewManager->showAgendaView();
2012 QString str; 2015 QString str;
2013 //qDebug("CalendarView::readSettings() "); 2016 //qDebug("CalendarView::readSettings() ");
2014 // read settings from the KConfig, supplying reasonable 2017 // read settings from the KConfig, supplying reasonable
2015 // defaults where none are to be found 2018 // defaults where none are to be found
2016 KConfig *config = KOGlobals::config(); 2019 KConfig *config = KOGlobals::config();
2017#ifndef KORG_NOSPLITTER 2020#ifndef KORG_NOSPLITTER
2018 config->setGroup("KOrganizer Geometry"); 2021 config->setGroup("KOrganizer Geometry");
2019 2022
2020 QValueList<int> sizes = config->readIntListEntry("Separator1"); 2023 QValueList<int> sizes = config->readIntListEntry("Separator1");
2021 if (sizes.count() != 2) { 2024 if (sizes.count() != 2) {
2022 sizes << mDateNavigator->minimumSizeHint().width(); 2025 sizes << mDateNavigator->minimumSizeHint().width();
2023 sizes << 300; 2026 sizes << 300;
2024 } 2027 }
2025 mPanner->setSizes(sizes); 2028 mPanner->setSizes(sizes);
2026 2029
2027 sizes = config->readIntListEntry("Separator2"); 2030 sizes = config->readIntListEntry("Separator2");
2028 if ( ( mResourceView && sizes.count() == 4 ) || 2031 if ( ( mResourceView && sizes.count() == 4 ) ||
2029 ( !mResourceView && sizes.count() == 3 ) ) { 2032 ( !mResourceView && sizes.count() == 3 ) ) {
2030 mLeftSplitter->setSizes(sizes); 2033 mLeftSplitter->setSizes(sizes);
2031 } 2034 }
2032#endif 2035#endif
2033 globalFlagBlockAgenda = 1; 2036 globalFlagBlockAgenda = 1;
2034 mViewManager->showAgendaView(); 2037 mViewManager->showAgendaView();
2035 //mViewManager->readSettings( config ); 2038 //mViewManager->readSettings( config );
2036 mTodoList->restoreLayout(config,QString("Todo Layout")); 2039 mTodoList->restoreLayout(config,QString("Todo Layout"));
2037 readFilterSettings(config); 2040 readFilterSettings(config);
2038 2041
2039#ifdef DESKTOP_VERSION 2042#ifdef DESKTOP_VERSION
2040 config->setGroup("WidgetLayout"); 2043 config->setGroup("WidgetLayout");
2041 QStringList list; 2044 QStringList list;
2042 list = config->readListEntry("MainLayout"); 2045 list = config->readListEntry("MainLayout");
2043 int x,y,w,h; 2046 int x,y,w,h;
2044 if ( ! list.isEmpty() ) { 2047 if ( ! list.isEmpty() ) {
2045 x = list[0].toInt(); 2048 x = list[0].toInt();
2046 y = list[1].toInt(); 2049 y = list[1].toInt();
2047 w = list[2].toInt(); 2050 w = list[2].toInt();
2048 h = list[3].toInt(); 2051 h = list[3].toInt();
2049 KApplication::testCoords( &x,&y,&w,&h ); 2052 KApplication::testCoords( &x,&y,&w,&h );
2050 topLevelWidget()->setGeometry(x,y,w,h); 2053 topLevelWidget()->setGeometry(x,y,w,h);
2051 2054
2052 } else { 2055 } else {
2053 topLevelWidget()->setGeometry( 40 ,40 , 640, 440); 2056 topLevelWidget()->setGeometry( 40 ,40 , 640, 440);
2054 } 2057 }
2055 list = config->readListEntry("EditEventLayout"); 2058 list = config->readListEntry("EditEventLayout");
2056 if ( ! list.isEmpty() ) { 2059 if ( ! list.isEmpty() ) {
2057 x = list[0].toInt(); 2060 x = list[0].toInt();
2058 y = list[1].toInt(); 2061 y = list[1].toInt();
2059 w = list[2].toInt(); 2062 w = list[2].toInt();
2060 h = list[3].toInt(); 2063 h = list[3].toInt();
2061 KApplication::testCoords( &x,&y,&w,&h ); 2064 KApplication::testCoords( &x,&y,&w,&h );
2062 mEventEditor->setGeometry(x,y,w,h); 2065 mEventEditor->setGeometry(x,y,w,h);
2063 2066
2064 } 2067 }
2065 list = config->readListEntry("EditTodoLayout"); 2068 list = config->readListEntry("EditTodoLayout");
2066 if ( ! list.isEmpty() ) { 2069 if ( ! list.isEmpty() ) {
2067 x = list[0].toInt(); 2070 x = list[0].toInt();
2068 y = list[1].toInt(); 2071 y = list[1].toInt();
2069 w = list[2].toInt(); 2072 w = list[2].toInt();
2070 h = list[3].toInt(); 2073 h = list[3].toInt();
2071 KApplication::testCoords( &x,&y,&w,&h ); 2074 KApplication::testCoords( &x,&y,&w,&h );
2072 mTodoEditor->setGeometry(x,y,w,h); 2075 mTodoEditor->setGeometry(x,y,w,h);
2073 2076
2074 } 2077 }
2075 list = config->readListEntry("ViewerLayout"); 2078 list = config->readListEntry("ViewerLayout");
2076 if ( ! list.isEmpty() ) { 2079 if ( ! list.isEmpty() ) {
2077 x = list[0].toInt(); 2080 x = list[0].toInt();
2078 y = list[1].toInt(); 2081 y = list[1].toInt();
2079 w = list[2].toInt(); 2082 w = list[2].toInt();
2080 h = list[3].toInt(); 2083 h = list[3].toInt();
2081 KApplication::testCoords( &x,&y,&w,&h ); 2084 KApplication::testCoords( &x,&y,&w,&h );
2082 getEventViewerDialog()->setGeometry(x,y,w,h); 2085 getEventViewerDialog()->setGeometry(x,y,w,h);
2083 } 2086 }
2084#endif 2087#endif
2085 config->setGroup( "Views" ); 2088 config->setGroup( "Views" );
2086 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 2089 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
2087 2090
2088 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame"); 2091 QValueList<int> sizes = config->readIntListEntry("Left Splitter Frame");
2089 2092
2090 int resetval = 0; 2093 int resetval = 0;
2091 int maxVal = 0; 2094 int maxVal = 0;
2092 if (sizes.count() != 3) { 2095 if (sizes.count() != 3) {
2093 if ( KOPrefs::instance()->mVerticalScreen ) { 2096 if ( KOPrefs::instance()->mVerticalScreen ) {
2094 resetval = mDateNavigator->sizeHint().width()+2; 2097 resetval = mDateNavigator->sizeHint().width()+2;
2095 } else { 2098 } else {
2096 resetval = mDateNavigator->sizeHint().height()+2; 2099 resetval = mDateNavigator->sizeHint().height()+2;
2097 } 2100 }
2098 } 2101 }
2099 if ( resetval ) { 2102 if ( resetval ) {
2100 sizes.clear(); 2103 sizes.clear();
2101 if ( KOPrefs::instance()->mVerticalScreen ) { 2104 if ( KOPrefs::instance()->mVerticalScreen ) {
2102 maxVal = QApplication::desktop()->width() -10; 2105 maxVal = QApplication::desktop()->width() -10;
2103 } else { 2106 } else {
2104 maxVal = QApplication::desktop()->height()-10; 2107 maxVal = QApplication::desktop()->height()-10;
2105 } 2108 }
2106 sizes << resetval; 2109 sizes << resetval;
2107 if ( maxVal < resetval + resetval) 2110 if ( maxVal < resetval + resetval)
2108 resetval = maxVal - resetval; 2111 resetval = maxVal - resetval;
2109 sizes << resetval; 2112 sizes << resetval;
2110 sizes << 100; 2113 sizes << 100;
2111 } 2114 }
2112 mLeftFrame->setSizes(sizes); 2115 mLeftFrame->setSizes(sizes);
2113 sizes = config->readIntListEntry("Main Splitter Frame"); 2116 sizes = config->readIntListEntry("Main Splitter Frame");
2114 resetval = 0; 2117 resetval = 0;
2115 maxVal = 0; 2118 maxVal = 0;
2116 if (sizes.count() != 2) { 2119 if (sizes.count() != 2) {
2117 if ( !KOPrefs::instance()->mVerticalScreen ) { 2120 if ( !KOPrefs::instance()->mVerticalScreen ) {
2118 resetval = mDateNavigator->sizeHint().width()+2; 2121 resetval = mDateNavigator->sizeHint().width()+2;
2119 } else { 2122 } else {
2120 resetval = mDateNavigator->sizeHint().height()+2; 2123 resetval = mDateNavigator->sizeHint().height()+2;
2121 } 2124 }
2122 } 2125 }
2123 if ( resetval ) { 2126 if ( resetval ) {
2124 sizes.clear(); 2127 sizes.clear();
2125 if ( !KOPrefs::instance()->mVerticalScreen ) { 2128 if ( !KOPrefs::instance()->mVerticalScreen ) {
2126 maxVal = QApplication::desktop()->width() -10; 2129 maxVal = QApplication::desktop()->width() -10;
2127 } else { 2130 } else {
2128 maxVal = QApplication::desktop()->height()-10; 2131 maxVal = QApplication::desktop()->height()-10;
2129 } 2132 }
2130 sizes << resetval; 2133 sizes << resetval;
2131 if ( maxVal < resetval + resetval) 2134 if ( maxVal < resetval + resetval)
2132 resetval = maxVal - resetval; 2135 resetval = maxVal - resetval;
2133 sizes << resetval; 2136 sizes << resetval;
2134 } 2137 }
2135 mMainFrame->setSizes(sizes); 2138 mMainFrame->setSizes(sizes);
2136 if ( dateCount == 5 ) mNavigator->selectWorkWeek(); 2139 if ( dateCount == 5 ) mNavigator->selectWorkWeek();
2137 else if ( dateCount == 7 ) mNavigator->selectWeek(); 2140 else if ( dateCount == 7 ) mNavigator->selectWeek();
2138 else mNavigator->selectDates( dateCount ); 2141 else mNavigator->selectDates( dateCount );
2139 // mViewManager->readSettings( config ); 2142 // mViewManager->readSettings( config );
2140 updateConfig(); 2143 updateConfig();
2141 globalFlagBlockAgenda = 2; 2144 globalFlagBlockAgenda = 2;
2142 mViewManager->readSettings( config ); 2145 mViewManager->readSettings( config );
2143 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) ); 2146 QTimer::singleShot( 1, mDateNavigator, SLOT ( setResizeEnabled() ) );
2144} 2147}
2145 2148
2146 2149
2147void CalendarView::writeSettings() 2150void CalendarView::writeSettings()
2148{ 2151{
2149 // kdDebug() << "CalendarView::writeSettings" << endl; 2152 // kdDebug() << "CalendarView::writeSettings" << endl;
2150 2153
2151 KConfig *config = KOGlobals::config(); 2154 KConfig *config = KOGlobals::config();
2152 2155
2153 mViewManager->writeSettings( config ); 2156 mViewManager->writeSettings( config );
2154 mTodoList->saveLayout(config,QString("Todo Layout")); 2157 mTodoList->saveLayout(config,QString("Todo Layout"));
2155 mDialogManager->writeSettings( config ); 2158 mDialogManager->writeSettings( config );
2156 //KOPrefs::instance()->usrWriteConfig(); 2159 //KOPrefs::instance()->usrWriteConfig();
2157 KOPrefs::instance()->writeConfig(); 2160 KOPrefs::instance()->writeConfig();
2158 2161
2159 writeFilterSettings(config); 2162 writeFilterSettings(config);
2160 config->setGroup( "AppRun" ); 2163 config->setGroup( "AppRun" );
2161 QDateTime dt ( QDate (2005,3,1), QTime( 0,0,0 ) ); 2164 QDateTime dt ( QDate (2005,1,1), QTime( 0,0,0 ) );
2165 int days = dt.daysTo( QDate::currentDate() );
2166 dt = dt.addDays( days );
2162 int secs = dt.secsTo( QDateTime::currentDateTime() ); 2167 int secs = dt.secsTo( QDateTime::currentDateTime() );
2163 config->writeEntry( "LatestProgramStop", secs ); 2168 config->writeEntry( "LatestProgramStopDays", days );
2164 qDebug("KO: Writing stop time: %d ", secs); 2169 config->writeEntry( "LatestProgramStopSecs", secs );
2165 qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() ); 2170 //qDebug("KO: Writing stop time: %d ", secs);
2166 QDateTime latest = dt.addSecs ( secs ); 2171 //qDebug("KO: Current Time %s ",QDateTime::currentDateTime().toString().latin1() );
2167 qDebug("KO: Test termination on %s ", latest.toString().latin1()); 2172 //QDateTime latest = dt.addSecs ( secs );
2173 //qDebug("KO: Termination on %s ", latest.toString().latin1());
2168 config->setGroup( "Views" ); 2174 config->setGroup( "Views" );
2169 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() ); 2175 config->writeEntry( "ShownDatesCount", mNavigator->selectedDates().count() );
2170 2176
2177#if 0
2178 qDebug("********************* ");
2179 qDebug("Testcode secsto ");
2180 QDateTime dt_nodaylight ( QDate (2005,3,26), QTime( 0,0,0 ) );
2181 QDateTime dt_daylight ( QDate (2005,3,29), QTime( 0,0,0 ) );
2182 int secsto = dt_nodaylight.secsTo( dt_daylight );
2183 QDateTime dt_daylight_wrong = dt_nodaylight.addSecs( secsto );
2184 qDebug("dt nodaylight %s ",dt_nodaylight.toString().latin1() );
2185 qDebug("dt daylight %s ",dt_daylight.toString().latin1() );
2186 qDebug("dt daylight_wrong %s ",dt_daylight_wrong.toString().latin1() );
2187 qDebug("Computed secsTo %d . in minutes: %d . in hours: %d ", secsto, secsto/60, secsto/3600);
2188 qDebug("********************* testcode end");
2189
2190#endif
2191
2171 QValueList<int> listINT = mLeftFrame->sizes(); 2192 QValueList<int> listINT = mLeftFrame->sizes();
2172 config->writeEntry("Left Splitter Frame",listINT); 2193 config->writeEntry("Left Splitter Frame",listINT);
2173 QValueList<int> listINT2 = mMainFrame->sizes(); 2194 QValueList<int> listINT2 = mMainFrame->sizes();
2174 config->writeEntry("Main Splitter Frame",listINT2); 2195 config->writeEntry("Main Splitter Frame",listINT2);
2175#ifdef DESKTOP_VERSION 2196#ifdef DESKTOP_VERSION
2176 config->setGroup("WidgetLayout"); 2197 config->setGroup("WidgetLayout");
2177 QStringList list ;//= config->readListEntry("MainLayout"); 2198 QStringList list ;//= config->readListEntry("MainLayout");
2178 int x,y,w,h; 2199 int x,y,w,h;
2179 QWidget* wid; 2200 QWidget* wid;
2180 wid = topLevelWidget(); 2201 wid = topLevelWidget();
2181 x = wid->geometry().x(); 2202 x = wid->geometry().x();
2182 y = wid->geometry().y(); 2203 y = wid->geometry().y();
2183 w = wid->width(); 2204 w = wid->width();
2184 h = wid->height(); 2205 h = wid->height();
2185 list.clear(); 2206 list.clear();
2186 list << QString::number( x ); 2207 list << QString::number( x );
2187 list << QString::number( y ); 2208 list << QString::number( y );
2188 list << QString::number( w ); 2209 list << QString::number( w );
2189 list << QString::number( h ); 2210 list << QString::number( h );
2190 config->writeEntry("MainLayout",list ); 2211 config->writeEntry("MainLayout",list );
2191 2212
2192 wid = mEventEditor; 2213 wid = mEventEditor;
2193 x = wid->geometry().x(); 2214 x = wid->geometry().x();
2194 y = wid->geometry().y(); 2215 y = wid->geometry().y();
2195 w = wid->width(); 2216 w = wid->width();
2196 h = wid->height(); 2217 h = wid->height();
2197 list.clear(); 2218 list.clear();
2198 list << QString::number( x ); 2219 list << QString::number( x );
2199 list << QString::number( y ); 2220 list << QString::number( y );
2200 list << QString::number( w ); 2221 list << QString::number( w );
2201 list << QString::number( h ); 2222 list << QString::number( h );
2202 config->writeEntry("EditEventLayout",list ); 2223 config->writeEntry("EditEventLayout",list );
2203 2224
2204 wid = mTodoEditor; 2225 wid = mTodoEditor;
2205 x = wid->geometry().x(); 2226 x = wid->geometry().x();
2206 y = wid->geometry().y(); 2227 y = wid->geometry().y();
2207 w = wid->width(); 2228 w = wid->width();
2208 h = wid->height(); 2229 h = wid->height();
2209 list.clear(); 2230 list.clear();
2210 list << QString::number( x ); 2231 list << QString::number( x );
2211 list << QString::number( y ); 2232 list << QString::number( y );
2212 list << QString::number( w ); 2233 list << QString::number( w );
2213 list << QString::number( h ); 2234 list << QString::number( h );
2214 config->writeEntry("EditTodoLayout",list ); 2235 config->writeEntry("EditTodoLayout",list );
2215 wid = getEventViewerDialog(); 2236 wid = getEventViewerDialog();
2216 x = wid->geometry().x(); 2237 x = wid->geometry().x();
2217 y = wid->geometry().y(); 2238 y = wid->geometry().y();
2218 w = wid->width(); 2239 w = wid->width();
2219 h = wid->height(); 2240 h = wid->height();
2220 list.clear(); 2241 list.clear();
2221 list << QString::number( x ); 2242 list << QString::number( x );
2222 list << QString::number( y ); 2243 list << QString::number( y );
2223 list << QString::number( w ); 2244 list << QString::number( w );
2224 list << QString::number( h ); 2245 list << QString::number( h );
2225 config->writeEntry("ViewerLayout",list ); 2246 config->writeEntry("ViewerLayout",list );
2226 wid = mDialogManager->getSearchDialog(); 2247 wid = mDialogManager->getSearchDialog();
2227 if ( wid ) { 2248 if ( wid ) {
2228 x = wid->geometry().x(); 2249 x = wid->geometry().x();
2229 y = wid->geometry().y(); 2250 y = wid->geometry().y();
2230 w = wid->width(); 2251 w = wid->width();
2231 h = wid->height(); 2252 h = wid->height();
2232 list.clear(); 2253 list.clear();
2233 list << QString::number( x ); 2254 list << QString::number( x );
2234 list << QString::number( y ); 2255 list << QString::number( y );
2235 list << QString::number( w ); 2256 list << QString::number( w );
2236 list << QString::number( h ); 2257 list << QString::number( h );
2237 config->writeEntry("SearchLayout",list ); 2258 config->writeEntry("SearchLayout",list );
2238 } 2259 }
2239#endif 2260#endif
2240 2261
2241 2262
2242 config->sync(); 2263 config->sync();
2243} 2264}
2244 2265
2245void CalendarView::readFilterSettings(KConfig *config) 2266void CalendarView::readFilterSettings(KConfig *config)
2246{ 2267{
2247 // kdDebug() << "CalendarView::readFilterSettings()" << endl; 2268 // kdDebug() << "CalendarView::readFilterSettings()" << endl;
2248 2269
2249 mFilters.clear(); 2270 mFilters.clear();
2250 2271
2251 config->setGroup("General"); 2272 config->setGroup("General");
2252 QStringList filterList = config->readListEntry("CalendarFilters"); 2273 QStringList filterList = config->readListEntry("CalendarFilters");
2253 2274
2254 QStringList::ConstIterator it = filterList.begin(); 2275 QStringList::ConstIterator it = filterList.begin();
2255 QStringList::ConstIterator end = filterList.end(); 2276 QStringList::ConstIterator end = filterList.end();
2256 while(it != end) { 2277 while(it != end) {
2257 // kdDebug() << " filter: " << (*it) << endl; 2278 // kdDebug() << " filter: " << (*it) << endl;
2258 2279
2259 CalFilter *filter; 2280 CalFilter *filter;
2260 filter = new CalFilter(*it); 2281 filter = new CalFilter(*it);
2261 config->setGroup("Filter_" + (*it).utf8()); 2282 config->setGroup("Filter_" + (*it).utf8());
2262 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) ); 2283 //qDebug("readFilterSettings %d ",config->readNumEntry("Criteria",0) );
2263 filter->setCriteria(config->readNumEntry("Criteria",0)); 2284 filter->setCriteria(config->readNumEntry("Criteria",0));
2264 filter->setCategoryList(config->readListEntry("CategoryList")); 2285 filter->setCategoryList(config->readListEntry("CategoryList"));
2265 mFilters.append(filter); 2286 mFilters.append(filter);
2266 2287
2267 ++it; 2288 ++it;
2268 } 2289 }
2269 2290
2270 if (mFilters.count() == 0) { 2291 if (mFilters.count() == 0) {
2271 CalFilter *filter = new CalFilter(i18n("Default")); 2292 CalFilter *filter = new CalFilter(i18n("Default"));
2272 mFilters.append(filter); 2293 mFilters.append(filter);
2273 } 2294 }
2274 mFilterView->updateFilters(); 2295 mFilterView->updateFilters();
2275 config->setGroup("FilterView"); 2296 config->setGroup("FilterView");
2276 2297
2277 mFilterView->blockSignals(true); 2298 mFilterView->blockSignals(true);
2278 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled")); 2299 mFilterView->setFiltersEnabled(config->readBoolEntry("FilterEnabled"));
2279 mFilterView->setSelectedFilter(config->readEntry("Current Filter")); 2300 mFilterView->setSelectedFilter(config->readEntry("Current Filter"));
2280 mFilterView->blockSignals(false); 2301 mFilterView->blockSignals(false);
2281 // We do it manually to avoid it being done twice by the above calls 2302 // We do it manually to avoid it being done twice by the above calls
2282 updateFilter(); 2303 updateFilter();
2283} 2304}
2284 2305
2285void CalendarView::writeFilterSettings(KConfig *config) 2306void CalendarView::writeFilterSettings(KConfig *config)
2286{ 2307{
2287 // kdDebug() << "CalendarView::writeFilterSettings()" << endl; 2308 // kdDebug() << "CalendarView::writeFilterSettings()" << endl;
2288 2309
2289 QStringList filterList; 2310 QStringList filterList;
2290 2311
2291 CalFilter *filter = mFilters.first(); 2312 CalFilter *filter = mFilters.first();
2292 while(filter) { 2313 while(filter) {
2293 // kdDebug() << " fn: " << filter->name() << endl; 2314 // kdDebug() << " fn: " << filter->name() << endl;
2294 filterList << filter->name(); 2315 filterList << filter->name();
2295 config->setGroup("Filter_" + filter->name().utf8()); 2316 config->setGroup("Filter_" + filter->name().utf8());
2296 config->writeEntry("Criteria",filter->criteria()); 2317 config->writeEntry("Criteria",filter->criteria());
2297 config->writeEntry("CategoryList",filter->categoryList()); 2318 config->writeEntry("CategoryList",filter->categoryList());
2298 filter = mFilters.next(); 2319 filter = mFilters.next();
2299 } 2320 }
2300 config->setGroup("General"); 2321 config->setGroup("General");
2301 config->writeEntry("CalendarFilters",filterList); 2322 config->writeEntry("CalendarFilters",filterList);
2302 2323
2303 config->setGroup("FilterView"); 2324 config->setGroup("FilterView");
2304 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 2325 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
2305 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 2326 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
2306} 2327}
2307 2328
2308 2329
2309void CalendarView::goToday() 2330void CalendarView::goToday()
2310{ 2331{
2311 if ( mViewManager->currentView()->isMonthView() ) 2332 if ( mViewManager->currentView()->isMonthView() )
2312 mNavigator->selectTodayMonth(); 2333 mNavigator->selectTodayMonth();
2313 else 2334 else
2314 mNavigator->selectToday(); 2335 mNavigator->selectToday();
2315} 2336}
2316 2337
2317void CalendarView::goNext() 2338void CalendarView::goNext()
2318{ 2339{
2319 mNavigator->selectNext(); 2340 mNavigator->selectNext();
2320} 2341}
2321 2342
2322void CalendarView::goPrevious() 2343void CalendarView::goPrevious()
2323{ 2344{
2324 mNavigator->selectPrevious(); 2345 mNavigator->selectPrevious();
2325} 2346}
2326void CalendarView::goNextMonth() 2347void CalendarView::goNextMonth()
2327{ 2348{
2328 mNavigator->selectNextMonth(); 2349 mNavigator->selectNextMonth();
2329} 2350}
2330 2351
2331void CalendarView::goPreviousMonth() 2352void CalendarView::goPreviousMonth()
2332{ 2353{
2333 mNavigator->selectPreviousMonth(); 2354 mNavigator->selectPreviousMonth();
2334} 2355}
2335void CalendarView::writeLocale() 2356void CalendarView::writeLocale()
2336{ 2357{
2337 //KPimGlobalPrefs::instance()->setGlobalConfig(); 2358 //KPimGlobalPrefs::instance()->setGlobalConfig();
2338#if 0 2359#if 0
2339 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime ); 2360 KGlobal::locale()->setHore24Format( !KOPrefs::instance()->mPreferredTime );
2340 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday ); 2361 KGlobal::locale()->setWeekStartMonday( !KOPrefs::instance()->mWeekStartsOnSunday );
2341 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate ); 2362 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)KOPrefs::instance()->mPreferredDate );
2342 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage ); 2363 KGlobal::locale()->setLanguage( KOPrefs::instance()->mPreferredLanguage );
2343 QString dummy = KOPrefs::instance()->mUserDateFormatLong; 2364 QString dummy = KOPrefs::instance()->mUserDateFormatLong;
2344 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 2365 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
2345 dummy = KOPrefs::instance()->mUserDateFormatShort; 2366 dummy = KOPrefs::instance()->mUserDateFormatShort;
2346 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 2367 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
2347 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving, 2368 KGlobal::locale()->setDaylightSaving( KOPrefs::instance()->mUseDaylightsaving,
2348 KOPrefs::instance()->mDaylightsavingStart, 2369 KOPrefs::instance()->mDaylightsavingStart,
2349 KOPrefs::instance()->mDaylightsavingEnd ); 2370 KOPrefs::instance()->mDaylightsavingEnd );
2350 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId ); 2371 KGlobal::locale()->setTimezone( KPimGlobalPrefs::instance()->mTimeZoneId );
2351#endif 2372#endif
2352} 2373}
2353void CalendarView::updateConfig() 2374void CalendarView::updateConfig()
2354{ 2375{
2355 writeLocale(); 2376 writeLocale();
2356 if ( KOPrefs::instance()->mUseAppColors ) 2377 if ( KOPrefs::instance()->mUseAppColors )
2357 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 2378 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
2358 emit configChanged(); 2379 emit configChanged();
2359 mTodoList->updateConfig(); 2380 mTodoList->updateConfig();
2360 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 2381 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
2361 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2382 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2362 // To make the "fill window" configurations work 2383 // To make the "fill window" configurations work
2363 //mViewManager->raiseCurrentView(); 2384 //mViewManager->raiseCurrentView();
2364} 2385}
2365 2386
2366 2387
2367void CalendarView::eventChanged(Event *event) 2388void CalendarView::eventChanged(Event *event)
2368{ 2389{
2369 changeEventDisplay(event,KOGlobals::EVENTEDITED); 2390 changeEventDisplay(event,KOGlobals::EVENTEDITED);
2370 //updateUnmanagedViews(); 2391 //updateUnmanagedViews();
2371} 2392}
2372 2393
2373void CalendarView::eventAdded(Event *event) 2394void CalendarView::eventAdded(Event *event)
2374{ 2395{
2375 changeEventDisplay(event,KOGlobals::EVENTADDED); 2396 changeEventDisplay(event,KOGlobals::EVENTADDED);
2376} 2397}
2377 2398
2378void CalendarView::eventToBeDeleted(Event *) 2399void CalendarView::eventToBeDeleted(Event *)
2379{ 2400{
2380 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; 2401 kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl;
2381} 2402}
2382 2403
2383void CalendarView::eventDeleted() 2404void CalendarView::eventDeleted()
2384{ 2405{
2385 changeEventDisplay(0,KOGlobals::EVENTDELETED); 2406 changeEventDisplay(0,KOGlobals::EVENTDELETED);
2386} 2407}
2387void CalendarView::changeTodoDisplay(Todo *which, int action) 2408void CalendarView::changeTodoDisplay(Todo *which, int action)
2388{ 2409{
2389 changeIncidenceDisplay((Incidence *)which, action); 2410 changeIncidenceDisplay((Incidence *)which, action);
2390 mDateNavigator->updateView(); //LR 2411 mDateNavigator->updateView(); //LR
2391 //mDialogManager->updateSearchDialog(); 2412 //mDialogManager->updateSearchDialog();
2392 2413
2393 if (which) { 2414 if (which) {
2394 mViewManager->updateWNview(); 2415 mViewManager->updateWNview();
2395 //mTodoList->updateView(); 2416 //mTodoList->updateView();
2396 } 2417 }
2397 2418
2398} 2419}
2399 2420
2400void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 2421void CalendarView::changeIncidenceDisplay(Incidence *which, int action)
2401{ 2422{
2402 updateUnmanagedViews(); 2423 updateUnmanagedViews();
2403 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); 2424 //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action );
2404 if ( action == KOGlobals::EVENTDELETED ) { //delete 2425 if ( action == KOGlobals::EVENTDELETED ) { //delete
2405 mCalendar->checkAlarmForIncidence( 0, true ); 2426 mCalendar->checkAlarmForIncidence( 0, true );
2406 if ( mEventViewerDialog ) 2427 if ( mEventViewerDialog )
2407 mEventViewerDialog->hide(); 2428 mEventViewerDialog->hide();
2408 } 2429 }
2409 else 2430 else
2410 mCalendar->checkAlarmForIncidence( which , false ); 2431 mCalendar->checkAlarmForIncidence( which , false );
2411} 2432}
2412 2433
2413// most of the changeEventDisplays() right now just call the view's 2434// most of the changeEventDisplays() right now just call the view's
2414// total update mode, but they SHOULD be recoded to be more refresh-efficient. 2435// total update mode, but they SHOULD be recoded to be more refresh-efficient.
2415void CalendarView::changeEventDisplay(Event *which, int action) 2436void CalendarView::changeEventDisplay(Event *which, int action)
2416{ 2437{
2417 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 2438 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
2418 changeIncidenceDisplay((Incidence *)which, action); 2439 changeIncidenceDisplay((Incidence *)which, action);
2419 mDateNavigator->updateView(); 2440 mDateNavigator->updateView();
2420 //mDialogManager->updateSearchDialog(); 2441 //mDialogManager->updateSearchDialog();
2421 2442
2422 if (which) { 2443 if (which) {
2423 // If there is an event view visible update the display 2444 // If there is an event view visible update the display
2424 mViewManager->currentView()->changeEventDisplay(which,action); 2445 mViewManager->currentView()->changeEventDisplay(which,action);
2425 // TODO: check, if update needed 2446 // TODO: check, if update needed
2426 // if (which->getTodoStatus()) { 2447 // if (which->getTodoStatus()) {
2427 mTodoList->updateView(); 2448 mTodoList->updateView();
2428 // } 2449 // }
2429 } else { 2450 } else {
2430 mViewManager->currentView()->updateView(); 2451 mViewManager->currentView()->updateView();
2431 } 2452 }
2432} 2453}
2433 2454
2434 2455
2435void CalendarView::updateTodoViews() 2456void CalendarView::updateTodoViews()
2436{ 2457{
2437 mTodoList->updateView(); 2458 mTodoList->updateView();
2438 mViewManager->currentView()->updateView(); 2459 mViewManager->currentView()->updateView();
2439 2460
2440} 2461}
2441 2462
2442 2463
2443void CalendarView::updateView(const QDate &start, const QDate &end) 2464void CalendarView::updateView(const QDate &start, const QDate &end)
2444{ 2465{
2445 mTodoList->updateView(); 2466 mTodoList->updateView();
2446 mViewManager->updateView(start, end); 2467 mViewManager->updateView(start, end);
2447 //mDateNavigator->updateView(); 2468 //mDateNavigator->updateView();
2448} 2469}
2449 2470
2450void CalendarView::clearAllViews() 2471void CalendarView::clearAllViews()
2451{ 2472{
2452 mTodoList->clearList(); 2473 mTodoList->clearList();
2453 mViewManager->clearAllViews(); 2474 mViewManager->clearAllViews();
2454 SearchDialog * sd = mDialogManager->getSearchDialog(); 2475 SearchDialog * sd = mDialogManager->getSearchDialog();
2455 if ( sd ) { 2476 if ( sd ) {
2456 KOListView* kol = sd->listview(); 2477 KOListView* kol = sd->listview();
2457 if ( kol ) 2478 if ( kol )
2458 kol->clearList(); 2479 kol->clearList();
2459 } 2480 }
2460} 2481}
2461void CalendarView::updateView() 2482void CalendarView::updateView()
2462{ 2483{
2463 DateList tmpList = mNavigator->selectedDates(); 2484 DateList tmpList = mNavigator->selectedDates();
2464 2485
2465 if ( KOPrefs::instance()->mHideNonStartedTodos ) 2486 if ( KOPrefs::instance()->mHideNonStartedTodos )
2466 mTodoList->updateView(); 2487 mTodoList->updateView();
2467 // We assume that the navigator only selects consecutive days. 2488 // We assume that the navigator only selects consecutive days.
2468 updateView( tmpList.first(), tmpList.last() ); 2489 updateView( tmpList.first(), tmpList.last() );
2469} 2490}
2470 2491
2471void CalendarView::updateUnmanagedViews() 2492void CalendarView::updateUnmanagedViews()
2472{ 2493{
2473 mDateNavigator->updateDayMatrix(); 2494 mDateNavigator->updateDayMatrix();
2474} 2495}
2475 2496
2476int CalendarView::msgItemDelete(const QString name) 2497int CalendarView::msgItemDelete(const QString name)
2477{ 2498{
2478 return KMessageBox::warningContinueCancel(this,name +"\n\n"+ 2499 return KMessageBox::warningContinueCancel(this,name +"\n\n"+
2479 i18n("This item will be\npermanently deleted."), 2500 i18n("This item will be\npermanently deleted."),
2480 i18n("KO/Pi Confirmation"),i18n("Delete")); 2501 i18n("KO/Pi Confirmation"),i18n("Delete"));
2481} 2502}
2482 2503
2483 2504
2484void CalendarView::edit_cut() 2505void CalendarView::edit_cut()
2485{ 2506{
2486 Event *anEvent=0; 2507 Event *anEvent=0;
2487 2508
2488 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2509 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2489 2510
2490 if (mViewManager->currentView()->isEventView()) { 2511 if (mViewManager->currentView()->isEventView()) {
2491 if ( incidence && incidence->typeID() == eventID ) { 2512 if ( incidence && incidence->typeID() == eventID ) {
2492 anEvent = static_cast<Event *>(incidence); 2513 anEvent = static_cast<Event *>(incidence);
2493 } 2514 }
2494 } 2515 }
2495 2516
2496 if (!anEvent) { 2517 if (!anEvent) {
2497 KNotifyClient::beep(); 2518 KNotifyClient::beep();
2498 return; 2519 return;
2499 } 2520 }
2500 DndFactory factory( mCalendar ); 2521 DndFactory factory( mCalendar );
2501 factory.cutIncidence(anEvent); 2522 factory.cutIncidence(anEvent);
2502 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2523 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2503} 2524}
2504 2525
2505void CalendarView::edit_copy() 2526void CalendarView::edit_copy()
2506{ 2527{
2507 Event *anEvent=0; 2528 Event *anEvent=0;
2508 2529
2509 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2530 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2510 2531
2511 if (mViewManager->currentView()->isEventView()) { 2532 if (mViewManager->currentView()->isEventView()) {
2512 if ( incidence && incidence->typeID() == eventID ) { 2533 if ( incidence && incidence->typeID() == eventID ) {
2513 anEvent = static_cast<Event *>(incidence); 2534 anEvent = static_cast<Event *>(incidence);
2514 } 2535 }
2515 } 2536 }
2516 2537
2517 if (!anEvent) { 2538 if (!anEvent) {
2518 KNotifyClient::beep(); 2539 KNotifyClient::beep();
2519 return; 2540 return;
2520 } 2541 }
2521 DndFactory factory( mCalendar ); 2542 DndFactory factory( mCalendar );
2522 factory.copyIncidence(anEvent); 2543 factory.copyIncidence(anEvent);
2523} 2544}
2524 2545
2525void CalendarView::edit_paste() 2546void CalendarView::edit_paste()
2526{ 2547{
2527 QDate date = mNavigator->selectedDates().first(); 2548 QDate date = mNavigator->selectedDates().first();
2528 2549
2529 DndFactory factory( mCalendar ); 2550 DndFactory factory( mCalendar );
2530 Event *pastedEvent = (Event *)factory.pasteIncidence( date ); 2551 Event *pastedEvent = (Event *)factory.pasteIncidence( date );
2531 2552
2532 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 2553 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
2533} 2554}
2534void CalendarView::edit_global_options() 2555void CalendarView::edit_global_options()
2535{ 2556{
2536 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; 2557 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId;
2537 emit save(); 2558 emit save();
2538 emit saveStopTimer(); 2559 emit saveStopTimer();
2539 mDialogManager->showGlobalOptionsDialog(); 2560 mDialogManager->showGlobalOptionsDialog();
2540 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { 2561 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) {
2541 emit saveStopTimer(); 2562 emit saveStopTimer();
2542 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), 2563 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto apply timezone changes?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"),
2543 i18n("Timezone settings"),i18n("Reload"))) { 2564 i18n("Timezone settings"),i18n("Reload"))) {
2544 qDebug("KO: TZ reload cancelled "); 2565 qDebug("KO: TZ reload cancelled ");
2545 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2566 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2546 return; 2567 return;
2547 } 2568 }
2548 qDebug("KO: Timezone change "); 2569 qDebug("KO: Timezone change ");
2549 openCalendar( MainWindow::defaultFileName() ); 2570 openCalendar( MainWindow::defaultFileName() );
2550 setModified(true); 2571 setModified(true);
2551 } 2572 }
2552 else 2573 else
2553 qDebug("KO: No tz change "); 2574 qDebug("KO: No tz change ");
2554} 2575}
2555void CalendarView::edit_options() 2576void CalendarView::edit_options()
2556{ 2577{
2557 mDialogManager->showOptionsDialog(); 2578 mDialogManager->showOptionsDialog();
2558} 2579}
2559 2580
2560 2581
2561void CalendarView::slotSelectPickerDate( QDate d) 2582void CalendarView::slotSelectPickerDate( QDate d)
2562{ 2583{
2563 mDateFrame->hide(); 2584 mDateFrame->hide();
2564 if ( mDatePickerMode == 1 ) { 2585 if ( mDatePickerMode == 1 ) {
2565 mNavigator->slotDaySelect( d ); 2586 mNavigator->slotDaySelect( d );
2566 } else if ( mDatePickerMode == 2 ) { 2587 } else if ( mDatePickerMode == 2 ) {
2567 if ( mMoveIncidence->typeID() == todoID ) { 2588 if ( mMoveIncidence->typeID() == todoID ) {
2568 Todo * to = (Todo *) mMoveIncidence; 2589 Todo * to = (Todo *) mMoveIncidence;
2569 QTime tim; 2590 QTime tim;
2570 int len = 0; 2591 int len = 0;
2571 if ( to->hasStartDate() && to->hasDueDate() ) 2592 if ( to->hasStartDate() && to->hasDueDate() )
2572 len = to->dtStart().secsTo( to->dtDue()); 2593 len = to->dtStart().secsTo( to->dtDue());
2573 if ( to->hasDueDate() ) 2594 if ( to->hasDueDate() )
2574 tim = to->dtDue().time(); 2595 tim = to->dtDue().time();
2575 else { 2596 else {
2576 tim = QTime ( 0,0,0 ); 2597 tim = QTime ( 0,0,0 );
2577 to->setFloats( true ); 2598 to->setFloats( true );
2578 to->setHasDueDate( true ); 2599 to->setHasDueDate( true );
2579 } 2600 }
2580 QDateTime dt ( d,tim ); 2601 QDateTime dt ( d,tim );
2581 to->setDtDue( dt ); 2602 to->setDtDue( dt );
2582 2603
2583 if ( to->hasStartDate() ) { 2604 if ( to->hasStartDate() ) {
2584 if ( len>0 ) 2605 if ( len>0 )
2585 to->setDtStart(to->dtDue().addSecs( -len )); 2606 to->setDtStart(to->dtDue().addSecs( -len ));
2586 else 2607 else
2587 if (to->dtStart() > to->dtDue() ) 2608 if (to->dtStart() > to->dtDue() )
2588 to->setDtStart(to->dtDue().addDays( -3 )); 2609 to->setDtStart(to->dtDue().addDays( -3 ));
2589 } 2610 }
2590 2611
2591 todoChanged( to ); 2612 todoChanged( to );
2592 } else { 2613 } else {
2593 if ( mMoveIncidence->doesRecur() ) { 2614 if ( mMoveIncidence->doesRecur() ) {
2594#if 0 2615#if 0
2595 // PENDING implement this 2616 // PENDING implement this
2596 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); 2617 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate );
2597 mCalendar()->addIncidence( newInc ); 2618 mCalendar()->addIncidence( newInc );
2598 if ( mMoveIncidence->typeID() == todoID ) 2619 if ( mMoveIncidence->typeID() == todoID )
2599 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); 2620 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED );
2600 else 2621 else
2601 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); 2622 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED);
2602 mMoveIncidence = newInc; 2623 mMoveIncidence = newInc;
2603 2624
2604#endif 2625#endif
2605 } 2626 }
2606 QTime tim = mMoveIncidence->dtStart().time(); 2627 QTime tim = mMoveIncidence->dtStart().time();
2607 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2628 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2608 QDateTime dt ( d,tim ); 2629 QDateTime dt ( d,tim );
2609 mMoveIncidence->setDtStart( dt ); 2630 mMoveIncidence->setDtStart( dt );
2610 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2631 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2611 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2632 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2612 } 2633 }
2613 2634
2614 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2635 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2615 } 2636 }
2616} 2637}
2617 2638
2618void CalendarView::removeCategories() 2639void CalendarView::removeCategories()
2619{ 2640{
2620 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2641 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2621 QStringList catList = KOPrefs::instance()->mCustomCategories; 2642 QStringList catList = KOPrefs::instance()->mCustomCategories;
2622 QStringList catIncList; 2643 QStringList catIncList;
2623 QStringList newCatList; 2644 QStringList newCatList;
2624 Incidence* inc = incList.first(); 2645 Incidence* inc = incList.first();
2625 int i; 2646 int i;
2626 int count = 0; 2647 int count = 0;
2627 while ( inc ) { 2648 while ( inc ) {
2628 newCatList.clear(); 2649 newCatList.clear();
2629 catIncList = inc->categories() ; 2650 catIncList = inc->categories() ;
2630 for( i = 0; i< catIncList.count(); ++i ) { 2651 for( i = 0; i< catIncList.count(); ++i ) {
2631 if ( catList.contains (catIncList[i])) 2652 if ( catList.contains (catIncList[i]))
2632 newCatList.append( catIncList[i] ); 2653 newCatList.append( catIncList[i] );
2633 } 2654 }
2634 newCatList.sort(); 2655 newCatList.sort();
2635 inc->setCategories( newCatList.join(",") ); 2656 inc->setCategories( newCatList.join(",") );
2636 inc = incList.next(); 2657 inc = incList.next();
2637 } 2658 }
2638} 2659}
2639 2660
2640int CalendarView::addCategories() 2661int CalendarView::addCategories()
2641{ 2662{
2642 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2663 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2643 QStringList catList = KOPrefs::instance()->mCustomCategories; 2664 QStringList catList = KOPrefs::instance()->mCustomCategories;
2644 QStringList catIncList; 2665 QStringList catIncList;
2645 Incidence* inc = incList.first(); 2666 Incidence* inc = incList.first();
2646 int i; 2667 int i;
2647 int count = 0; 2668 int count = 0;
2648 while ( inc ) { 2669 while ( inc ) {
2649 catIncList = inc->categories() ; 2670 catIncList = inc->categories() ;
2650 for( i = 0; i< catIncList.count(); ++i ) { 2671 for( i = 0; i< catIncList.count(); ++i ) {
2651 if ( !catList.contains (catIncList[i])) { 2672 if ( !catList.contains (catIncList[i])) {
2652 catList.append( catIncList[i] ); 2673 catList.append( catIncList[i] );
2653 //qDebug("add cat %s ", catIncList[i].latin1()); 2674 //qDebug("add cat %s ", catIncList[i].latin1());
2654 ++count; 2675 ++count;
2655 } 2676 }
2656 } 2677 }
2657 inc = incList.next(); 2678 inc = incList.next();
2658 } 2679 }
2659 catList.sort(); 2680 catList.sort();
2660 KOPrefs::instance()->mCustomCategories = catList; 2681 KOPrefs::instance()->mCustomCategories = catList;
2661 return count; 2682 return count;
2662} 2683}
2663 2684
2664void CalendarView::manageCategories() 2685void CalendarView::manageCategories()
2665{ 2686{
2666 KOCatPrefs* cp = new KOCatPrefs(); 2687 KOCatPrefs* cp = new KOCatPrefs();
2667 cp->show(); 2688 cp->show();
2668 int w =cp->sizeHint().width() ; 2689 int w =cp->sizeHint().width() ;
2669 int h = cp->sizeHint().height() ; 2690 int h = cp->sizeHint().height() ;
2670 int dw = QApplication::desktop()->width(); 2691 int dw = QApplication::desktop()->width();
2671 int dh = QApplication::desktop()->height(); 2692 int dh = QApplication::desktop()->height();
2672 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2693 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2673 if ( !cp->exec() ) { 2694 if ( !cp->exec() ) {
2674 delete cp; 2695 delete cp;
2675 return; 2696 return;
2676 } 2697 }
2677 int count = 0; 2698 int count = 0;
2678 if ( cp->addCat() ) { 2699 if ( cp->addCat() ) {
2679 count = addCategories(); 2700 count = addCategories();
2680 if ( count ) { 2701 if ( count ) {
2681 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2702 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2682 writeSettings(); 2703 writeSettings();
2683 } else 2704 } else
2684 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); 2705 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! "));
2685 } else { 2706 } else {
2686 removeCategories(); 2707 removeCategories();
2687 updateView(); 2708 updateView();
2688 } 2709 }
2689 delete cp; 2710 delete cp;
2690} 2711}
2691 2712
2692void CalendarView::beamIncidence(Incidence * Inc) 2713void CalendarView::beamIncidence(Incidence * Inc)
2693{ 2714{
2694 QPtrList<Incidence> delSel ; 2715 QPtrList<Incidence> delSel ;
2695 delSel.append(Inc); 2716 delSel.append(Inc);
2696 beamIncidenceList( delSel ); 2717 beamIncidenceList( delSel );
2697} 2718}
2698void CalendarView::beamCalendar() 2719void CalendarView::beamCalendar()
2699{ 2720{
2700 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2721 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2701 //qDebug("beamCalendar() "); 2722 //qDebug("beamCalendar() ");
2702 beamIncidenceList( delSel ); 2723 beamIncidenceList( delSel );
2703} 2724}
2704void CalendarView::beamFilteredCalendar() 2725void CalendarView::beamFilteredCalendar()
2705{ 2726{
2706 QPtrList<Incidence> delSel = mCalendar->incidences(); 2727 QPtrList<Incidence> delSel = mCalendar->incidences();
2707 //qDebug("beamFilteredCalendar() "); 2728 //qDebug("beamFilteredCalendar() ");
2708 beamIncidenceList( delSel ); 2729 beamIncidenceList( delSel );
2709} 2730}
2710void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2731void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2711{ 2732{
2712 if ( beamDialog->exec () == QDialog::Rejected ) 2733 if ( beamDialog->exec () == QDialog::Rejected )
2713 return; 2734 return;
2714#ifdef DESKTOP_VERSION 2735#ifdef DESKTOP_VERSION
2715 QString fn = locateLocal( "tmp", "kopibeamfile" ); 2736 QString fn = locateLocal( "tmp", "kopibeamfile" );
2716#else 2737#else
2717 QString fn = "/tmp/kopibeamfile"; 2738 QString fn = "/tmp/kopibeamfile";
2718#endif 2739#endif
2719 QString mes; 2740 QString mes;
2720 bool createbup = true; 2741 bool createbup = true;
2721 if ( createbup ) { 2742 if ( createbup ) {
2722 QString description = "\n"; 2743 QString description = "\n";
2723 CalendarLocal* cal = new CalendarLocal(); 2744 CalendarLocal* cal = new CalendarLocal();
2724 if ( beamDialog->beamLocal() ) 2745 if ( beamDialog->beamLocal() )
2725 cal->setLocalTime(); 2746 cal->setLocalTime();
2726 else 2747 else
2727 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2748 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2728 Incidence *incidence = delSel.first(); 2749 Incidence *incidence = delSel.first();
2729 bool addText = false; 2750 bool addText = false;
2730 if ( delSel.count() < 10 ) 2751 if ( delSel.count() < 10 )
2731 addText = true; 2752 addText = true;
2732 else { 2753 else {
2733 description.sprintf(i18n(" %d items?"),delSel.count() ); 2754 description.sprintf(i18n(" %d items?"),delSel.count() );
2734 } 2755 }
2735 while ( incidence ) { 2756 while ( incidence ) {
2736 Incidence *in = incidence->clone(); 2757 Incidence *in = incidence->clone();
2737 if ( ! in->summary().isEmpty() ) { 2758 if ( ! in->summary().isEmpty() ) {
2738 in->setDescription(""); 2759 in->setDescription("");
2739 } else { 2760 } else {
2740 in->setSummary( in->description().left(20)); 2761 in->setSummary( in->description().left(20));
2741 in->setDescription(""); 2762 in->setDescription("");
2742 } 2763 }
2743 if ( addText ) 2764 if ( addText )
2744 description += in->summary() + "\n"; 2765 description += in->summary() + "\n";
2745 cal->addIncidence( in ); 2766 cal->addIncidence( in );
2746 incidence = delSel.next(); 2767 incidence = delSel.next();
2747 } 2768 }
2748 if ( beamDialog->beamVcal() ) { 2769 if ( beamDialog->beamVcal() ) {
2749 fn += ".vcs"; 2770 fn += ".vcs";
2750 FileStorage storage( cal, fn, new VCalFormat ); 2771 FileStorage storage( cal, fn, new VCalFormat );
2751 storage.save(); 2772 storage.save();
2752 } else { 2773 } else {
2753 fn += ".ics"; 2774 fn += ".ics";
2754 FileStorage storage( cal, fn, new ICalFormat( ) ); 2775 FileStorage storage( cal, fn, new ICalFormat( ) );
2755 storage.save(); 2776 storage.save();
2756 } 2777 }
2757 delete cal; 2778 delete cal;
2758 mes = i18n("KO/Pi: Ready for beaming"); 2779 mes = i18n("KO/Pi: Ready for beaming");
2759 topLevelWidget()->setCaption(mes); 2780 topLevelWidget()->setCaption(mes);
2760 KApplication::convert2latin1( fn ); 2781 KApplication::convert2latin1( fn );
2761#ifndef DESKTOP_VERSION 2782#ifndef DESKTOP_VERSION
2762 Ir *ir = new Ir( this ); 2783 Ir *ir = new Ir( this );
2763 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 2784 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
2764 ir->send( fn, description, "text/x-vCalendar" ); 2785 ir->send( fn, description, "text/x-vCalendar" );
2765#endif 2786#endif
2766 } 2787 }
2767} 2788}
2768void CalendarView::beamDone( Ir *ir ) 2789void CalendarView::beamDone( Ir *ir )
2769{ 2790{
2770#ifndef DESKTOP_VERSION 2791#ifndef DESKTOP_VERSION
2771 delete ir; 2792 delete ir;
2772#endif 2793#endif
2773 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); 2794 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") );
2774 topLevelWidget()->raise(); 2795 topLevelWidget()->raise();
2775} 2796}
2776 2797
2777void CalendarView::moveIncidence(Incidence * inc ) 2798void CalendarView::moveIncidence(Incidence * inc )
2778{ 2799{
2779 if ( !inc ) return; 2800 if ( !inc ) return;
2780 showDatePickerPopup(); 2801 showDatePickerPopup();
2781 mDatePickerMode = 2; 2802 mDatePickerMode = 2;
2782 mMoveIncidence = inc ; 2803 mMoveIncidence = inc ;
2783 QDate da; 2804 QDate da;
2784 if ( mMoveIncidence->typeID() == todoID ) { 2805 if ( mMoveIncidence->typeID() == todoID ) {
2785 Todo * to = (Todo *) mMoveIncidence; 2806 Todo * to = (Todo *) mMoveIncidence;
2786 if ( to->hasDueDate() ) 2807 if ( to->hasDueDate() )
2787 da = to->dtDue().date(); 2808 da = to->dtDue().date();
2788 else 2809 else
2789 da = QDate::currentDate(); 2810 da = QDate::currentDate();
2790 } else { 2811 } else {
2791 da = mMoveIncidence->dtStart().date(); 2812 da = mMoveIncidence->dtStart().date();
2792 } 2813 }
2793 //PENDING set date for recurring incidence to date of recurrence 2814 //PENDING set date for recurring incidence to date of recurrence
2794 //mMoveIncidenceOldDate; 2815 //mMoveIncidenceOldDate;
2795 mDatePicker->setDate( da ); 2816 mDatePicker->setDate( da );
2796} 2817}
2797void CalendarView::showDatePickerPopup() 2818void CalendarView::showDatePickerPopup()
2798{ 2819{
2799 if ( mDateFrame->isVisible() ) 2820 if ( mDateFrame->isVisible() )
2800 mDateFrame->hide(); 2821 mDateFrame->hide();
2801 else { 2822 else {
2802 int offX = 0, offY = 0; 2823 int offX = 0, offY = 0;
2803#ifdef DESKTOP_VERSION 2824#ifdef DESKTOP_VERSION
2804 int w =mDatePicker->sizeHint().width() ; 2825 int w =mDatePicker->sizeHint().width() ;
2805 int h = mDatePicker->sizeHint().height() ; 2826 int h = mDatePicker->sizeHint().height() ;
2806 int dw = topLevelWidget()->width(); 2827 int dw = topLevelWidget()->width();
2807 int dh = topLevelWidget()->height(); 2828 int dh = topLevelWidget()->height();
2808 offX = topLevelWidget()->x(); 2829 offX = topLevelWidget()->x();
2809 offY = topLevelWidget()->y(); 2830 offY = topLevelWidget()->y();
2810#else 2831#else
2811 int w =mDatePicker->sizeHint().width() ; 2832 int w =mDatePicker->sizeHint().width() ;
2812 int h = mDatePicker->sizeHint().height() ; 2833 int h = mDatePicker->sizeHint().height() ;
2813 int dw = QApplication::desktop()->width(); 2834 int dw = QApplication::desktop()->width();
2814 int dh = QApplication::desktop()->height(); 2835 int dh = QApplication::desktop()->height();
2815#endif 2836#endif
2816 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); 2837 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h );
2817 mDateFrame->show(); 2838 mDateFrame->show();
2818 } 2839 }
2819} 2840}
2820void CalendarView::showDatePicker( ) 2841void CalendarView::showDatePicker( )
2821{ 2842{
2822 showDatePickerPopup(); 2843 showDatePickerPopup();
2823 mDatePickerMode = 1; 2844 mDatePickerMode = 1;
2824 mDatePicker->setDate( mNavigator->selectedDates().first() ); 2845 mDatePicker->setDate( mNavigator->selectedDates().first() );
2825} 2846}
2826 2847
2827void CalendarView::showEventEditor() 2848void CalendarView::showEventEditor()
2828{ 2849{
2829#ifdef DESKTOP_VERSION 2850#ifdef DESKTOP_VERSION
2830 int x,y,w,h; 2851 int x,y,w,h;
2831 x = mEventEditor->geometry().x(); 2852 x = mEventEditor->geometry().x();
2832 y = mEventEditor->geometry().y(); 2853 y = mEventEditor->geometry().y();
2833 w = mEventEditor->width(); 2854 w = mEventEditor->width();
2834 h = mEventEditor->height(); 2855 h = mEventEditor->height();
2835 mEventEditor->show(); 2856 mEventEditor->show();
2836 mEventEditor->setGeometry(x,y,w,h); 2857 mEventEditor->setGeometry(x,y,w,h);
2837#else 2858#else
2838 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { 2859 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) {
2839 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2860 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2840 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); 2861 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() );
2841 qApp->processEvents(); 2862 qApp->processEvents();
2842 delete mEventEditor; 2863 delete mEventEditor;
2843 mEventEditor = mDialogManager->getEventEditor(); 2864 mEventEditor = mDialogManager->getEventEditor();
2844 topLevelWidget()->setCaption( i18n("") ); 2865 topLevelWidget()->setCaption( i18n("") );
2845 } 2866 }
2846 mEventEditor->showMaximized(); 2867 mEventEditor->showMaximized();
2847#endif 2868#endif
2848} 2869}
2849void CalendarView::showTodoEditor() 2870void CalendarView::showTodoEditor()
2850{ 2871{
2851#ifdef DESKTOP_VERSION 2872#ifdef DESKTOP_VERSION
2852 int x,y,w,h; 2873 int x,y,w,h;
2853 x = mTodoEditor->geometry().x(); 2874 x = mTodoEditor->geometry().x();
2854 y = mTodoEditor->geometry().y(); 2875 y = mTodoEditor->geometry().y();
2855 w = mTodoEditor->width(); 2876 w = mTodoEditor->width();
2856 h = mTodoEditor->height(); 2877 h = mTodoEditor->height();
2857 mTodoEditor->show(); 2878 mTodoEditor->show();
2858 mTodoEditor->setGeometry(x,y,w,h); 2879 mTodoEditor->setGeometry(x,y,w,h);
2859#else 2880#else
2860 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { 2881 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) {
2861 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 2882 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
2862 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); 2883 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() );
2863 qApp->processEvents(); 2884 qApp->processEvents();
2864 delete mTodoEditor; 2885 delete mTodoEditor;
2865 mTodoEditor = mDialogManager->getTodoEditor(); 2886 mTodoEditor = mDialogManager->getTodoEditor();
2866 topLevelWidget()->setCaption( i18n("") ); 2887 topLevelWidget()->setCaption( i18n("") );
2867 } 2888 }
2868 mTodoEditor->showMaximized(); 2889 mTodoEditor->showMaximized();
2869#endif 2890#endif
2870} 2891}
2871 2892
2872void CalendarView::cloneIncidence() 2893void CalendarView::cloneIncidence()
2873{ 2894{
2874 Incidence *incidence = currentSelection(); 2895 Incidence *incidence = currentSelection();
2875 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2896 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2876 if ( incidence ) { 2897 if ( incidence ) {
2877 cloneIncidence(incidence); 2898 cloneIncidence(incidence);
2878 } 2899 }
2879} 2900}
2880void CalendarView::moveIncidence() 2901void CalendarView::moveIncidence()
2881{ 2902{
2882 Incidence *incidence = currentSelection(); 2903 Incidence *incidence = currentSelection();
2883 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2904 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2884 if ( incidence ) { 2905 if ( incidence ) {
2885 moveIncidence(incidence); 2906 moveIncidence(incidence);
2886 } 2907 }
2887} 2908}
2888void CalendarView::beamIncidence() 2909void CalendarView::beamIncidence()
2889{ 2910{
2890 Incidence *incidence = currentSelection(); 2911 Incidence *incidence = currentSelection();
2891 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2912 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2892 if ( incidence ) { 2913 if ( incidence ) {
2893 beamIncidence(incidence); 2914 beamIncidence(incidence);
2894 } 2915 }
2895} 2916}
2896void CalendarView::toggleCancelIncidence() 2917void CalendarView::toggleCancelIncidence()
2897{ 2918{
2898 Incidence *incidence = currentSelection(); 2919 Incidence *incidence = currentSelection();
2899 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 2920 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
2900 if ( incidence ) { 2921 if ( incidence ) {
2901 cancelIncidence(incidence); 2922 cancelIncidence(incidence);
2902 } 2923 }
2903} 2924}
2904 2925
2905 2926
2906void CalendarView::cancelIncidence(Incidence * inc ) 2927void CalendarView::cancelIncidence(Incidence * inc )
2907{ 2928{
2908 inc->setCancelled( ! inc->cancelled() ); 2929 inc->setCancelled( ! inc->cancelled() );
2909 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 2930 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
2910 updateView(); 2931 updateView();
2911} 2932}
2912void CalendarView::cloneIncidence(Incidence * orgInc ) 2933void CalendarView::cloneIncidence(Incidence * orgInc )
2913{ 2934{
2914 Incidence * newInc = orgInc->clone(); 2935 Incidence * newInc = orgInc->clone();
2915 newInc->recreate(); 2936 newInc->recreate();
2916 2937
2917 if ( newInc->typeID() == todoID ) { 2938 if ( newInc->typeID() == todoID ) {
2918 Todo* t = (Todo*) newInc; 2939 Todo* t = (Todo*) newInc;
2919 bool cloneSub = false; 2940 bool cloneSub = false;
2920 if ( orgInc->relations().count() ) { 2941 if ( orgInc->relations().count() ) {
2921 int result = KMessageBox::warningYesNoCancel(this, 2942 int result = KMessageBox::warningYesNoCancel(this,
2922 i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( newInc->summary().left ( 25 ) ), 2943 i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( newInc->summary().left ( 25 ) ),
2923 i18n("Todo has subtodos"), 2944 i18n("Todo has subtodos"),
2924 i18n("Yes"), 2945 i18n("Yes"),
2925 i18n("No")); 2946 i18n("No"));
2926 2947
2927 if ( result == KMessageBox::Cancel ) { 2948 if ( result == KMessageBox::Cancel ) {
2928 delete t; 2949 delete t;
2929 return; 2950 return;
2930 } 2951 }
2931 if (result == KMessageBox::Yes) cloneSub = true; 2952 if (result == KMessageBox::Yes) cloneSub = true;
2932 } 2953 }
2933 showTodoEditor(); 2954 showTodoEditor();
2934 mTodoEditor->editTodo( t ); 2955 mTodoEditor->editTodo( t );
2935 if ( mTodoEditor->exec() ) { 2956 if ( mTodoEditor->exec() ) {
2936 if ( cloneSub ) { 2957 if ( cloneSub ) {
2937 orgInc->cloneRelations( t ); 2958 orgInc->cloneRelations( t );
2938 mCalendar->addIncidenceBranch( t ); 2959 mCalendar->addIncidenceBranch( t );
diff --git a/microkde/kfiledialog.cpp b/microkde/kfiledialog.cpp
index c64f325..383e711 100644
--- a/microkde/kfiledialog.cpp
+++ b/microkde/kfiledialog.cpp
@@ -1,88 +1,88 @@
1#include <kfiledialog.h> 1#include <kfiledialog.h>
2#include <qdialog.h> 2#include <qdialog.h>
3#include <qlayout.h> 3#include <qlayout.h>
4#include <qdir.h> 4#include <qdir.h>
5#include <qfileinfo.h> 5#include <qfileinfo.h>
6#include <qapplication.h> 6#include <qapplication.h>
7 7
8#ifndef DESKTOP_VERSION 8#ifndef DESKTOP_VERSION
9//US orig#include <ofileselector.h> 9//US orig#include <ofileselector.h>
10#include <ofileselector_p.h> 10#include <ofileselector_p.h>
11QString KFileDialog::getSaveFileName( const QString & fn, 11QString KFileDialog::getSaveFileName( const QString & fn,
12 const QString & cap , QWidget * par ) 12 const QString & cap , QWidget * par )
13{ 13{
14 QString retfile = ""; 14 QString retfile = "";
15 QDialog dia ( par, "input-dialog", true ); 15 QDialog dia ( par, "input-dialog", true );
16 QVBoxLayout lay( &dia ); 16 QVBoxLayout lay( &dia );
17 lay.setMargin(7); 17 lay.setMargin(7);
18 lay.setSpacing(7); 18 lay.setSpacing(7);
19 QString file = fn; 19 QString file = fn;
20 if ( file.isEmpty() ) 20 if ( file.isEmpty() )
21 file = QDir::homeDirPath()+"/*"; 21 file = QDir::homeDirPath()+"/*";
22 QFileInfo fi ( file ); 22 QFileInfo fi ( file );
23 OFileSelector o ( &dia,OFileSelector::FileSelector, OFileSelector::Save, fi.dirPath(true), fi.fileName() ); 23 OFileSelector o ( &dia,OFileSelector::FileSelector, OFileSelector::Save, fi.dirPath(true), fi.fileName() );
24 QObject::connect ( &o, SIGNAL( ok() ), &dia, SLOT ( accept () ) ); 24 QObject::connect ( &o, SIGNAL( ok() ), &dia, SLOT ( accept () ) );
25 lay.addWidget( &o); 25 lay.addWidget( &o);
26 // o.setNewVisible( true ); 26 // o.setNewVisible( true );
27 // o.setNameVisible( true ); 27 // o.setNameVisible( true );
28 dia.showMaximized(); 28 dia.showMaximized();
29 if ( cap.isEmpty() ) 29 if ( cap.isEmpty() )
30 dia.setCaption( file ); 30 dia.setCaption( file );
31 else 31 else
32 dia.setCaption( cap ); 32 dia.setCaption( cap );
33 int res = dia.exec(); 33 int res = dia.exec();
34 if ( res ) 34 if ( res )
35 retfile = o.selectedName(); 35 retfile = o.selectedName();
36 return retfile; 36 return retfile;
37} 37}
38 38
39QString KFileDialog::getOpenFileName( const QString & fn, 39QString KFileDialog::getOpenFileName( const QString & fn,
40 const QString & cap, QWidget * par ) 40 const QString & cap, QWidget * par )
41{ 41{
42 QString retfile = ""; 42 QString retfile = "";
43 QDialog dia ( par, "input-dialog", true ); 43 QDialog dia ( par, "input-dialog", true );
44 // QLineEdit lab ( &dia ); 44 // QLineEdit lab ( &dia );
45 QVBoxLayout lay( &dia ); 45 QVBoxLayout lay( &dia );
46 lay.setMargin(7); 46 lay.setMargin(7);
47 lay.setSpacing(7); 47 lay.setSpacing(7);
48 QString file = fn; 48 QString file = fn;
49 if ( file.isEmpty() ) 49 if ( file.isEmpty() )
50 file = QDir::homeDirPath()+"/*";; 50 file = QDir::homeDirPath()+"/*";;
51 QFileInfo fi ( file ); 51 QFileInfo fi ( file );
52 OFileSelector o ( &dia,OFileSelector::FileSelector, OFileSelector::Open, fi.dirPath(true), fi.fileName() ); 52 OFileSelector o ( &dia,OFileSelector::FileSelector, OFileSelector::Open, fi.dirPath(true), fi.fileName() );
53 QObject::connect ( &o, SIGNAL( ok() ), &dia, SLOT ( accept () ) ); 53 QObject::connect ( &o, SIGNAL( ok() ), &dia, SLOT ( accept () ) );
54 lay.addWidget( &o); 54 lay.addWidget( &o);
55 dia.showMaximized(); 55 dia.showMaximized();
56 dia.setCaption( cap ); 56 dia.setCaption( cap );
57 int res = dia.exec(); 57 int res = dia.exec();
58 if ( res ) 58 if ( res )
59 retfile = o.selectedName(); 59 retfile = o.selectedName();
60 return retfile; 60 return retfile;
61} 61}
62QString KFileDialog::getExistingDirectory( const QString & fn, 62QString KFileDialog::getExistingDirectory( const QString & fn,
63 const QString & cap, QWidget * par ) 63 const QString & cap, QWidget * par )
64{ 64{
65 return KFileDialog::getSaveFileName( fn, cap, pr ); 65 return KFileDialog::getSaveFileName( fn, cap, par );
66} 66}
67#else 67#else
68 68
69#include <qfiledialog.h> 69#include <qfiledialog.h>
70 70
71QString KFileDialog::getSaveFileName( const QString & fn, 71QString KFileDialog::getSaveFileName( const QString & fn,
72 const QString & cap , QWidget * par ) 72 const QString & cap , QWidget * par )
73{ 73{
74 return QFileDialog::getSaveFileName( fn, QString::null, par, "openfile", cap ); 74 return QFileDialog::getSaveFileName( fn, QString::null, par, "openfile", cap );
75} 75}
76QString KFileDialog::getOpenFileName( const QString & fn, 76QString KFileDialog::getOpenFileName( const QString & fn,
77 const QString & cap, QWidget * par ) 77 const QString & cap, QWidget * par )
78{ 78{
79 79
80 return QFileDialog::getOpenFileName( fn, QString::null, par, "openfile", cap ); 80 return QFileDialog::getOpenFileName( fn, QString::null, par, "openfile", cap );
81} 81}
82QString KFileDialog::getExistingDirectory( const QString & fn, 82QString KFileDialog::getExistingDirectory( const QString & fn,
83 const QString & cap, QWidget * par ) 83 const QString & cap, QWidget * par )
84{ 84{
85 return QFileDialog::getExistingDirectory( fn, par, "exidtingdir", cap ); 85 return QFileDialog::getExistingDirectory( fn, par, "exidtingdir", cap );
86} 86}
87#endif 87#endif
88 88